From 4b4545442b9afff5ec20cfb837ae2693c9b9d207 Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Thu, 17 Oct 2024 23:15:35 +0800 Subject: [PATCH] 1 --- rule/service_award_dividend/return.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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 {