diff --git a/rule/service_award_dividend/return.go b/rule/service_award_dividend/return.go index fd35ce7..349041c 100644 --- a/rule/service_award_dividend/return.go +++ b/rule/service_award_dividend/return.go @@ -226,7 +226,6 @@ func CouponReward(eg *xorm.Engine, uid int) { } func BatchInsertMallUserCoupon(engine *xorm.Engine, mallCouponScheme model.MallCouponScheme, uid int) error { user, _ := db.UserFindByID(engine, uid) - var userCoupons []*model.MallUserCoupon var startTime time.Time var endTime time.Time var now = time.Now() @@ -237,9 +236,7 @@ func BatchInsertMallUserCoupon(engine *xorm.Engine, mallCouponScheme model.MallC startTime = now endTime = now.Add(time.Hour * 24 * time.Duration(mallCouponScheme.ValidDayNum)) } - if mallCouponScheme.LeftNum < 0 { - mallCouponScheme.LeftNum = 0 - } + var tmp = make([]map[string]interface{}, 0) json.Unmarshal([]byte(mallCouponScheme.LvNum), &tmp) if len(tmp) == 0 { @@ -247,7 +244,11 @@ func BatchInsertMallUserCoupon(engine *xorm.Engine, mallCouponScheme model.MallC } for _, v := range tmp { if zhios_order_relate_utils.AnyToString(v["id"]) == zhios_order_relate_utils.IntToStr(user.Level) { + var userCoupons []*model.MallUserCoupon tmpData := v + if mallCouponScheme.LeftNum < 0 { + mallCouponScheme.LeftNum = 0 + } perUserNum := zhios_order_relate_utils.StrToInt(zhios_order_relate_utils.AnyToString(tmpData["count"])) leftNum := mallCouponScheme.LeftNum - perUserNum if leftNum < 0 {