This commit is contained in:
wucongxing8150 2024-08-30 09:08:51 +08:00
parent 18c7ac3ae0
commit b5631c2ffb
4 changed files with 38 additions and 3 deletions

View File

@ -76,7 +76,7 @@ func CancelUnPayOrder(msg amqp091.Delivery) {
if err != nil {
tx.Rollback()
utils.LogJsonErr("consumer.CancelUnPayOrder:", "订单异常")
_ = msg.Ack(false)
_ = msg.Reject(false)
return
}
@ -101,7 +101,7 @@ func CancelUnPayOrder(msg amqp091.Delivery) {
if err != nil {
tx.Rollback()
utils.LogJsonErr("consumer.CancelUnPayOrder:", "订单异常")
_ = msg.Ack(false)
_ = msg.Reject(false)
return
}

View File

@ -1,5 +1,37 @@
package consumer
func checkHandleNumber(key string) {
import (
"context"
"hepa-calc-api/global"
"strconv"
"time"
)
// 检测执行次数
func checkHandleNumber(key string) bool {
c := context.Background()
res, _ := global.Redis.Get(c, key).Result()
if res == "" {
// 添加缓存
_, _ = global.Redis.Set(c, key, 1, (60*60*2)*time.Second).Result()
return true
}
// string转int
handleNum, err := strconv.Atoi(res)
if err != nil {
return false
}
if handleNum > 3 {
// 加入短信队列,通知管理员
// 返回false删除掉缓存
global.Redis.Del(c, key)
}
// 增加1次
global.Redis.Incr(c, key)
return true
}

View File

@ -61,6 +61,8 @@ func (b *UserCollection) GetUserCollectionPage(c *gin.Context) {
// PutUserCollection 收藏题目
func (r *UserCollection) PutUserCollection(c *gin.Context) {
utils.LogJsonInfo("test", "1222333")
userCollectionRequest := requests.UserCollectionRequest{}
req := userCollectionRequest.PutUserCollection
if err := c.ShouldBindJSON(&req); err != nil {

View File

@ -226,6 +226,7 @@ func (r *OrderSingleService) AddOrderSingle(tx *gorm.DB, UserId, QuestionId int6
utils.LogJsonErr("添加处理取消未支付订单队列失败:", err.Error())
return nil, errors.New("订单创建失败")
}
fmt.Println("添加队列成功")
}
// 会员支付