发放优惠卷,增加过期队列时间处理
This commit is contained in:
parent
cb00d5a082
commit
3a0ebf9a36
@ -187,7 +187,14 @@ func (r *CouponService) AddSystemCoupon(req requests.AddSystemCoupon) (bool, err
|
||||
|
||||
// 时间区间
|
||||
if req.ValidStartTime != nil {
|
||||
t, err := time.Parse("2006-01-02 15:04:05", *req.ValidStartTime)
|
||||
// 获取本地时区
|
||||
location, err := time.LoadLocation("Local")
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
return false, errors.New("新增失败")
|
||||
}
|
||||
|
||||
t, err := time.ParseInLocation("2006-01-02 15:04:05", *req.ValidStartTime, location)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
return false, errors.New("新增失败")
|
||||
@ -199,7 +206,15 @@ func (r *CouponService) AddSystemCoupon(req requests.AddSystemCoupon) (bool, err
|
||||
}
|
||||
|
||||
if req.ValidEndTime != nil {
|
||||
t, err := time.Parse("2006-01-02 15:04:05", *req.ValidEndTime)
|
||||
// 获取本地时区
|
||||
location, err := time.LoadLocation("Local")
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
return false, errors.New("新增失败")
|
||||
}
|
||||
|
||||
t, err := time.ParseInLocation("2006-01-02 15:04:05", *req.ValidEndTime, location)
|
||||
fmt.Println(t)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
return false, errors.New("新增失败")
|
||||
@ -272,7 +287,7 @@ func (r *CouponService) AddSystemCoupon(req requests.AddSystemCoupon) (bool, err
|
||||
|
||||
// 增加优惠卷过期队列
|
||||
if coupon.ValidType == 1 {
|
||||
validEndTime := time.Time(*coupon.ValidStartTime)
|
||||
validEndTime := time.Time(*coupon.ValidEndTime)
|
||||
|
||||
// 计算当天的结束时间
|
||||
now := time.Now()
|
||||
@ -293,7 +308,7 @@ func (r *CouponService) AddSystemCoupon(req requests.AddSystemCoupon) (bool, err
|
||||
data := make(map[string]interface{})
|
||||
data["coupon_id"] = fmt.Sprintf("%d", coupon.CouponId)
|
||||
|
||||
delay := validEndTime.Sub(time.Now())
|
||||
delay := validEndTime.Sub(now)
|
||||
|
||||
if delay < 10 {
|
||||
delay = 10 * time.Second
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user