Переглянути джерело

promotion add cash and cent

abiao 5 роки тому
батько
коміт
c0bf973386

+ 15 - 0
go/gopath/src/fohow.com/apps/helpers/promotion_helper.go

@@ -1,6 +1,9 @@
 package helpers
 
 import (
+	"fmt"
+	"fohow.com/apps/models/balance_model"
+	"fohow.com/apps/models/cent_model"
 	"fohow.com/apps/models/order_model"
 	"fohow.com/apps/models/product_model"
 	"github.com/astaxie/beego"
@@ -91,6 +94,7 @@ func SetOrderPromotion(orderId string, wxUid int64) {
 			beego.Warn("totalFlag%v", totalFlag)
 			beego.Warn("numsFlag%v", numsFlag)
 			beego.Warn("nums%d", nums)*/
+		//满足促销条件
 		if firstFlag && totalFlag && numsFlag {
 			if item.SendProd1 > 0 && item.SendNums1 > 0 {
 				sendNums1 := nums * item.SendNums1
@@ -111,6 +115,17 @@ func SetOrderPromotion(orderId string, wxUid int64) {
 				product := product_model.GetProductById(item.SendProd3, true)
 				go order_model.SendCreate(order.OrderId, order.Id, product.Id, product.Price, product.Price, product.Name, sendNums3)
 			}
+			//赠送积分 or 代办费
+			if item.Cash > 0 {
+				source := balance_model.BALANCE_SOURCE_PROMOTION
+				remark := fmt.Sprintf("促销赠送代金券")
+				new(balance_model.Balance).Create(order.WxUserId, order.UserId, item.Cash, source, order.OrderId, remark)
+			}
+			if item.Cent > 0 {
+				source := cent_model.PROMOTION_SEND
+				remark := fmt.Sprintf("促销活动赠送")
+				new(cent_model.CentBalance).Create(order.WxUserId, item.Cent, source, order.OrderId, remark)
+			}
 		}
 	}
 }

+ 5 - 0
go/gopath/src/fohow.com/apps/models/balance_model/balance.go

@@ -48,6 +48,9 @@ const (
 	BALANCE_SOURCE_DEDUCT      = "deduct"
 	BALANCE_SOURCE_DEDUCT_NAME = "扣除"
 
+	BALANCE_SOURCE_PROMOTION      = "promotion"
+	BALANCE_SOURCE_PROMOTION_NAME = "促销赠送"
+
 	PAY_WAY_TYPE_SERVICE_WXPAY = "service_wxpay"
 )
 
@@ -130,6 +133,8 @@ func (self *Balance) GetSourceName() string {
 		sourceName = BALANCE_FREND_BUY_NAME
 	case SHOP_APPYCATION:
 		sourceName = SHOP_APPYCATION_NAME
+	case BALANCE_SOURCE_PROMOTION:
+		sourceName = BALANCE_SOURCE_PROMOTION_NAME
 	}
 	return sourceName
 }

+ 6 - 0
go/gopath/src/fohow.com/apps/models/cent_model/cent_balance.go

@@ -33,6 +33,8 @@ const (
 	CENT_NEW_MAN_NAME      = "新人注册"
 	EXCXHANGE_PRODUCT      = "exchange_product"
 	EXCXHANGE_PRODUCT_NAME = "购物扣除"
+	PROMOTION_SEND         = "promotion_send"
+	PROMOTION_SEND_NAME    = "促销活动赠送"
 	PRE_KEY_DAILY          = "day_sign"
 )
 
@@ -93,6 +95,10 @@ func (self *CentBalance) GetSourceName() string {
 		sourceName = CENT_FIRST_LOGIN_NAME
 	case CENT_NEW_MAN:
 		sourceName = CENT_NEW_MAN_NAME
+	case EXCXHANGE_PRODUCT:
+		sourceName = EXCXHANGE_PRODUCT_NAME
+	case PROMOTION_SEND:
+		sourceName = PROMOTION_SEND_NAME
 	}
 	return sourceName
 }

+ 2 - 0
go/gopath/src/fohow.com/apps/models/order_model/promotion.go

@@ -35,6 +35,8 @@ type Promotion struct {
 	SendNums2 int64     `orm:"column(send_nums2)"                      json:"send_nums2"`    // int(11)
 	SendProd3 int64     `orm:"column(send_prod3)"                      json:"send_prod3"`    // int(11)
 	SendNums3 int64     `orm:"column(send_nums3)"                      json:"send_nums3"`    // int(11)
+	Cash      int64     `orm:"column(cash)"                            json:"cash"`          // int(11)
+	Cent      int64     `orm:"column(cent)"                            json:"cent"`          // int(11)
 	CreatedAt time.Time `orm:"column(created_at);null;auto_now_add;type(datetime)" json:"-"` // datetime
 	UpdatedAt time.Time `orm:"column(updated_at);null;auto_now;type(datetime)"     json:"-"` // datetime
 }