新增了 取消未支付订单

This commit is contained in:
2024-07-31 17:07:51 +08:00
parent 1e1ce24939
commit 9182bf0c16
13 changed files with 378 additions and 39 deletions
+20 -3
View File
@@ -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
}
}
}
-4
View File
@@ -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)
}
}