aa
This commit is contained in:
@@ -466,8 +466,8 @@ func (v *UserCoupons) TableIndex() [][]string {
|
||||
type StoreCoupons struct {
|
||||
ModelIDCULD
|
||||
|
||||
CouponID int `orm:"column(coupon_id)" json:"couponID"` //优惠券ID
|
||||
StoreID string `orm:"column(store_id)" json:"storeID"` //storeID
|
||||
CouponID int `orm:"column(coupon_id)" json:"couponID"` //优惠券ID
|
||||
StoreID int `orm:"column(store_id)" json:"storeID"` //storeID
|
||||
}
|
||||
|
||||
func (v *StoreCoupons) TableIndex() [][]string {
|
||||
|
||||
@@ -2172,6 +2172,13 @@ func AddCoupons(ctx *jxcontext.Context, coupons *model.Coupons, count int, store
|
||||
coupons.CouponStatus = model.CouponStatusRe
|
||||
}
|
||||
}
|
||||
if coupons.IsAll == model.NO {
|
||||
if len(storeIDs) == 0 {
|
||||
return fmt.Errorf("不是全国生效则必须选择生效门店!")
|
||||
}
|
||||
} else {
|
||||
storeIDs = []int{} //全国不需要选门店
|
||||
}
|
||||
if coupons.UpperLimit == 0 || coupons.Cut == 0 {
|
||||
return fmt.Errorf("请输入正确的满减!")
|
||||
} else {
|
||||
@@ -2187,7 +2194,19 @@ func AddCoupons(ctx *jxcontext.Context, coupons *model.Coupons, count int, store
|
||||
}
|
||||
for i := 1; i < count; i++ {
|
||||
dao.WrapAddIDCULDEntity(coupons, ctx.GetUserName())
|
||||
dao.CreateEntity(db, coupons)
|
||||
if err = dao.CreateEntity(db, coupons); err == nil {
|
||||
//门店优惠券表
|
||||
if coupons.IsAll == 0 {
|
||||
for _, v := range storeIDs {
|
||||
storeCoupons := &model.StoreCoupons{
|
||||
CouponID: int(coupons.ID),
|
||||
StoreID: v,
|
||||
}
|
||||
dao.WrapAddIDCULEntity(storeCoupons, ctx.GetUserName())
|
||||
dao.CreateEntity(db, v)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user