修改优惠卷发放数量问题
This commit is contained in:
parent
d6e28d292e
commit
7af51c49ce
@ -148,12 +148,6 @@ func (r *CouponService) ReceiveCoupon(req requestsV1.ReceiveCoupon) (g *dtoV1.Re
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检测优惠卷过期时间
|
|
||||||
now = now.Add(time.Minute * 10)
|
|
||||||
if coupon.ValidType == 1 {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// 检测用户是否已领取该优惠卷
|
// 检测用户是否已领取该优惠卷
|
||||||
userCouponDao := dao.UserCouponDao{}
|
userCouponDao := dao.UserCouponDao{}
|
||||||
|
|
||||||
@ -179,6 +173,14 @@ func (r *CouponService) ReceiveCoupon(req requestsV1.ReceiveCoupon) (g *dtoV1.Re
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
// 增加优惠卷发放数量
|
||||||
|
err = couponDao.Inc(tx, couponId, "coupon_take_count", req.Quantity)
|
||||||
|
if err != nil {
|
||||||
|
tx.Rollback()
|
||||||
|
return nil, errors.New("发放失败")
|
||||||
|
}
|
||||||
|
|
||||||
|
for i := 0; i < req.Quantity; i++ {
|
||||||
// 添加用户优惠卷表
|
// 添加用户优惠卷表
|
||||||
UserCouponModel := &model.UserCoupon{
|
UserCouponModel := &model.UserCoupon{
|
||||||
UserId: user.UserId,
|
UserId: user.UserId,
|
||||||
@ -204,13 +206,8 @@ func (r *CouponService) ReceiveCoupon(req requestsV1.ReceiveCoupon) (g *dtoV1.Re
|
|||||||
return nil, errors.New("发放失败")
|
return nil, errors.New("发放失败")
|
||||||
}
|
}
|
||||||
|
|
||||||
// 增加优惠卷发放数量
|
// 同类型优惠卷只添加一次弹窗
|
||||||
err = couponDao.Inc(tx, couponId, "coupon_take_count", req.Quantity)
|
if i == 0 {
|
||||||
if err != nil {
|
|
||||||
tx.Rollback()
|
|
||||||
return nil, errors.New("发放失败")
|
|
||||||
}
|
|
||||||
|
|
||||||
// 添加弹窗表
|
// 添加弹窗表
|
||||||
if coupon.IsPopup == 1 {
|
if coupon.IsPopup == 1 {
|
||||||
popupModel := &model.Popup{
|
popupModel := &model.Popup{
|
||||||
@ -247,6 +244,7 @@ func (r *CouponService) ReceiveCoupon(req requestsV1.ReceiveCoupon) (g *dtoV1.Re
|
|||||||
return nil, errors.New("发放失败")
|
return nil, errors.New("发放失败")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 增加优惠卷过期队列
|
// 增加优惠卷过期队列
|
||||||
// 计算当天的结束时间
|
// 计算当天的结束时间
|
||||||
@ -287,6 +285,7 @@ func (r *CouponService) ReceiveCoupon(req requestsV1.ReceiveCoupon) (g *dtoV1.Re
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
tx.Commit()
|
tx.Commit()
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user