huangjiajun 2 months ago
parent
commit
4b4545442b
1 changed files with 5 additions and 4 deletions
  1. +5
    -4
      rule/service_award_dividend/return.go

+ 5
- 4
rule/service_award_dividend/return.go View File

@@ -226,7 +226,6 @@ func CouponReward(eg *xorm.Engine, uid int) {
} }
func BatchInsertMallUserCoupon(engine *xorm.Engine, mallCouponScheme model.MallCouponScheme, uid int) error { func BatchInsertMallUserCoupon(engine *xorm.Engine, mallCouponScheme model.MallCouponScheme, uid int) error {
user, _ := db.UserFindByID(engine, uid) user, _ := db.UserFindByID(engine, uid)
var userCoupons []*model.MallUserCoupon
var startTime time.Time var startTime time.Time
var endTime time.Time var endTime time.Time
var now = time.Now() var now = time.Now()
@@ -237,9 +236,7 @@ func BatchInsertMallUserCoupon(engine *xorm.Engine, mallCouponScheme model.MallC
startTime = now startTime = now
endTime = now.Add(time.Hour * 24 * time.Duration(mallCouponScheme.ValidDayNum)) endTime = now.Add(time.Hour * 24 * time.Duration(mallCouponScheme.ValidDayNum))
} }
if mallCouponScheme.LeftNum < 0 {
mallCouponScheme.LeftNum = 0
}

var tmp = make([]map[string]interface{}, 0) var tmp = make([]map[string]interface{}, 0)
json.Unmarshal([]byte(mallCouponScheme.LvNum), &tmp) json.Unmarshal([]byte(mallCouponScheme.LvNum), &tmp)
if len(tmp) == 0 { if len(tmp) == 0 {
@@ -247,7 +244,11 @@ func BatchInsertMallUserCoupon(engine *xorm.Engine, mallCouponScheme model.MallC
} }
for _, v := range tmp { for _, v := range tmp {
if zhios_order_relate_utils.AnyToString(v["id"]) == zhios_order_relate_utils.IntToStr(user.Level) { if zhios_order_relate_utils.AnyToString(v["id"]) == zhios_order_relate_utils.IntToStr(user.Level) {
var userCoupons []*model.MallUserCoupon
tmpData := v tmpData := v
if mallCouponScheme.LeftNum < 0 {
mallCouponScheme.LeftNum = 0
}
perUserNum := zhios_order_relate_utils.StrToInt(zhios_order_relate_utils.AnyToString(tmpData["count"])) perUserNum := zhios_order_relate_utils.StrToInt(zhios_order_relate_utils.AnyToString(tmpData["count"]))
leftNum := mallCouponScheme.LeftNum - perUserNum leftNum := mallCouponScheme.LeftNum - perUserNum
if leftNum < 0 { if leftNum < 0 {


Loading…
Cancel
Save