新增了次数限制
This commit is contained in:
parent
b5631c2ffb
commit
a50bc2a20c
@ -23,7 +23,7 @@ type cancelUnPayOrderData struct {
|
||||
func CancelUnPayOrder(msg amqp091.Delivery) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
utils.LogJsonInfo("consumer.CancelUnPayOrder:", r)
|
||||
utils.LogJsonErr("consumer.CancelUnPayOrder:", r)
|
||||
_ = msg.Reject(false)
|
||||
}
|
||||
}()
|
||||
@ -43,6 +43,15 @@ func CancelUnPayOrder(msg amqp091.Delivery) {
|
||||
return
|
||||
}
|
||||
|
||||
// 检测执行次数
|
||||
key := "CancelUnPayOrder" + data.OrderId
|
||||
res := checkHandleNumber(key)
|
||||
if res == false {
|
||||
utils.LogJsonErr("consumer.CancelUnPayOrder:", "超出最大执行次数或检测错误")
|
||||
_ = msg.Ack(false)
|
||||
return
|
||||
}
|
||||
|
||||
orderId, err := strconv.ParseInt(data.OrderId, 10, 64)
|
||||
if err != nil {
|
||||
_ = msg.Ack(false)
|
||||
|
||||
@ -20,7 +20,7 @@ type couponExpireData struct {
|
||||
func CouponExpire(msg amqp091.Delivery) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
utils.LogJsonInfo("consumer.CouponExpire:", r)
|
||||
utils.LogJsonErr("consumer.CouponExpire:", r)
|
||||
_ = msg.Reject(false)
|
||||
}
|
||||
}()
|
||||
|
||||
@ -20,7 +20,7 @@ type userCouponExpireData struct {
|
||||
func UserCouponExpire(msg amqp091.Delivery) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
utils.LogJsonInfo("consumer.UserCouponExpire:", r)
|
||||
utils.LogJsonErr("consumer.UserCouponExpire:", r)
|
||||
_ = msg.Reject(false)
|
||||
}
|
||||
}()
|
||||
|
||||
@ -20,7 +20,7 @@ type userMemberExpireData struct {
|
||||
func UserMemberExpire(msg amqp091.Delivery) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
utils.LogJsonInfo("consumer.UserMemberExpire:", r)
|
||||
utils.LogJsonErr("consumer.UserMemberExpire:", r)
|
||||
_ = msg.Reject(false)
|
||||
}
|
||||
}()
|
||||
@ -40,6 +40,15 @@ func UserMemberExpire(msg amqp091.Delivery) {
|
||||
return
|
||||
}
|
||||
|
||||
// 检测执行次数
|
||||
key := "UserMemberExpire" + data.UserId
|
||||
res := checkHandleNumber(key)
|
||||
if res == false {
|
||||
utils.LogJsonErr("consumer.UserMemberExpire:", "超出最大执行次数或检测错误")
|
||||
_ = msg.Ack(false)
|
||||
return
|
||||
}
|
||||
|
||||
userId, err := strconv.ParseInt(data.UserId, 10, 64)
|
||||
if err != nil {
|
||||
_ = msg.Ack(false)
|
||||
|
||||
@ -28,6 +28,7 @@ func checkHandleNumber(key string) bool {
|
||||
|
||||
// 返回false,删除掉缓存
|
||||
global.Redis.Del(c, key)
|
||||
return false
|
||||
}
|
||||
|
||||
// 增加1次
|
||||
|
||||
@ -61,8 +61,6 @@ 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 {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user