huangjiajun 2 mesi fa
parent
commit
aebe8d6e12
1 ha cambiato i file con 12 aggiunte e 8 eliminazioni
  1. +12
    -8
      app/svc/svc_order.go

+ 12
- 8
app/svc/svc_order.go Vedi File

@@ -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("不满足优惠条件")
}
}
}


Caricamento…
Annulla
Salva