新增了 取消未支付订单
This commit is contained in:
+5
-5
@@ -10,13 +10,13 @@ func StartCron() {
|
||||
c := cron.New(cron.WithSeconds())
|
||||
|
||||
// 系统优惠卷过期
|
||||
//_, err := c.AddFunc("* * * * * *", crontab.SystemCouponExpire)
|
||||
//if err != nil {
|
||||
// panic("定时器启动失败:" + err.Error())
|
||||
//}
|
||||
_, err := c.AddFunc("0 0 0 * * *", crontab.SystemCouponExpire)
|
||||
if err != nil {
|
||||
panic("定时器启动失败:" + err.Error())
|
||||
}
|
||||
|
||||
// 用户优惠卷过期
|
||||
_, err := c.AddFunc("0 0 0 * * *", crontab.UserCouponExpire)
|
||||
_, err = c.AddFunc("0 0 0 * * *", crontab.UserCouponExpire)
|
||||
if err != nil {
|
||||
panic("定时器启动失败:" + err.Error())
|
||||
}
|
||||
|
||||
+20
-17
@@ -23,33 +23,36 @@ func StartRabbitMq() {
|
||||
|
||||
// StartRabbitMqConsume 启动消费者端
|
||||
func StartRabbitMqConsume() {
|
||||
// 用户优惠卷过期
|
||||
s := rabbitMq.ConsumeS{
|
||||
QueueName: "user.coupon.expired.delay.queue",
|
||||
ExchangeName: "amqp.delay.direct",
|
||||
RoutingKey: "UserCouponExpired",
|
||||
Handler: consumer.UserCouponExpire,
|
||||
}
|
||||
go startConsumer(s)
|
||||
|
||||
// 系统优惠卷过期
|
||||
s = rabbitMq.ConsumeS{
|
||||
QueueName: "coupon.expired.delay.queue",
|
||||
ExchangeName: "amqp.delay.direct",
|
||||
RoutingKey: "CouponExpired",
|
||||
Handler: consumer.CouponExpire,
|
||||
}
|
||||
|
||||
go startConsumer(s)
|
||||
|
||||
// 取消未支付订单
|
||||
s = rabbitMq.ConsumeS{
|
||||
QueueName: "cancel.unpay.order.delay.queue",
|
||||
ExchangeName: "amqp.delay.direct",
|
||||
RoutingKey: "CancelUnPayOrder",
|
||||
Handler: consumer.CancelUnPayOrder,
|
||||
}
|
||||
|
||||
// 用户优惠卷过期
|
||||
go startConsumer(s)
|
||||
}
|
||||
|
||||
// UserCouponExpire 用户优惠卷过期
|
||||
//func userCouponExpire() {
|
||||
// go func() {
|
||||
// err := rabbitMq.Consume(
|
||||
// "user.coupon.expired.delay.queue", // 交换机名称
|
||||
// "amqp.delay.direct", // 队列名称
|
||||
// "UserCouponExpired", // 路由键
|
||||
// consumer.UserCouponExpire, // 消息处理函数
|
||||
// )
|
||||
// if err != nil {
|
||||
// fmt.Println(err.Error())
|
||||
// utils.LogJsonErr("消费用户优惠卷过期队列失败", err)
|
||||
// }
|
||||
// }()
|
||||
//}
|
||||
|
||||
// startConsumer 启动指定的消费者协程
|
||||
func startConsumer(s rabbitMq.ConsumeS) {
|
||||
go func() {
|
||||
|
||||
Reference in New Issue
Block a user