新增了 取消未支付订单
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
package crontab
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"hepa-calc-api/api/dao"
|
||||
"hepa-calc-api/api/model"
|
||||
"hepa-calc-api/extend/rabbitMq"
|
||||
"hepa-calc-api/utils"
|
||||
"time"
|
||||
)
|
||||
@@ -19,12 +21,27 @@ func SystemCouponExpire() {
|
||||
// 计算过期时间
|
||||
validEndTime := time.Time(coupon.ValidEndTime)
|
||||
|
||||
diffTime := validEndTime.Sub(time.Now())
|
||||
if diffTime < 5*time.Second {
|
||||
diffTime = 5 * time.Second
|
||||
delay := validEndTime.Sub(time.Now())
|
||||
if delay < 5*time.Second {
|
||||
delay = 5 * time.Second
|
||||
}
|
||||
|
||||
// 添加处理优惠卷过期队列
|
||||
data := make(map[string]interface{})
|
||||
data["coupon_id"] = fmt.Sprintf("%d", coupon.CouponId)
|
||||
|
||||
p := rabbitMq.PublishS{
|
||||
QueueName: "coupon.expired.delay.queue",
|
||||
ExchangeName: "amqp.delay.direct",
|
||||
RoutingKey: "CouponExpired",
|
||||
Message: data,
|
||||
Delay: delay,
|
||||
}
|
||||
err := p.PublishWithDelay()
|
||||
if err != nil {
|
||||
utils.LogJsonErr("添加处理优惠卷过期队列失败:", err.Error())
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -42,10 +42,6 @@ func UserCouponExpire() {
|
||||
utils.LogJsonErr("添加处理用户优惠卷过期队列失败:", err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Println(userCoupon.UserCouponId)
|
||||
now := time.Now().Format("2006-01-02 15:04:05")
|
||||
fmt.Println("添加队列成功" + now)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user