From aebe8d6e12fab60b085e02bc1a7a660e0885fa1b Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Wed, 18 Sep 2024 16:43:38 +0800 Subject: [PATCH] 1 --- app/svc/svc_order.go | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/app/svc/svc_order.go b/app/svc/svc_order.go index eaa2da8..3795ff4 100644 --- a/app/svc/svc_order.go +++ b/app/svc/svc_order.go @@ -235,8 +235,8 @@ func CommCoupon(c *gin.Context, totalPrice string) map[string]interface{} { var ActCouponUserList []*model.CommunityTeamCouponUser sess := engine. Where("store_type=? and uid = ? AND is_use = ? AND (valid_time_start < ? AND valid_time_end > ?)", 0, - user.Info.Uid, 0, now, now) - err = sess.Find(&ActCouponUserList) + user.Info.Uid, 1, now, now) + err = sess.Limit(100).OrderBy("valid_time_end asc,id asc").Find(&ActCouponUserList) if err != nil { return map[string]interface{}{} } @@ -251,8 +251,8 @@ func CommCoupon(c *gin.Context, totalPrice string) map[string]interface{} { merchantSchemeMap[v.Id] = v } - var couponList []md.CouponList // 可使用的 - couponList = make([]md.CouponList, 0) + couponList := make([]md.CouponList, 0) + notCouponList := make([]md.CouponList, 0) count := 0 for _, item := range ActCouponUserList { var coupon = md.CouponList{ @@ -295,10 +295,14 @@ func CommCoupon(c *gin.Context, totalPrice string) map[string]interface{} { } if coupon.IsCanUse == "1" { count++ + couponList = append(couponList, coupon) + } else { + notCouponList = append(notCouponList, coupon) } - couponList = append(couponList, coupon) } - + for _, v := range notCouponList { + couponList = append(couponList, v) + } returnData := map[string]interface{}{ "total": utils.IntToStr(count), "coupon_list": couponList, @@ -649,7 +653,7 @@ func CouponProcess(c *gin.Context, sess *xorm.Session, total string, args md.Ord // 获取优惠券信息 var mallUserCoupon model.CommunityTeamCouponUser isExist, err := sess. - Where("id = ? AND uid = ? AND is_use = ? AND (valid_time_start < ? AND valid_time_end > ?)", args.CouponId, user.Info.Uid, 0, now, now). + Where("id = ? AND uid = ? AND is_use = ? AND (valid_time_start < ? AND valid_time_end > ?)", args.CouponId, user.Info.Uid, 1, now, now). Get(&mallUserCoupon) if err != nil { return "", "", err @@ -678,7 +682,7 @@ func CouponProcess(c *gin.Context, sess *xorm.Session, total string, args md.Ord } else { if mallUserCoupon.Kind == 1 { //立减 if utils.StrToFloat64(specialTotal) < utils.StrToFloat64(reduce.String()) { - return "", "", errors.New("付款金额有误") + return "", "", errors.New("不满足优惠条件") } } }