From a0ad992ab1680e12011cb97505e204dadc9f1a5d Mon Sep 17 00:00:00 2001 From: JNG <365252428@qq.com> Date: Tue, 3 Feb 2026 19:41:43 +0800 Subject: [PATCH] Update bundleOrder.go --- pkg/service/bundle/bundleOrder.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkg/service/bundle/bundleOrder.go b/pkg/service/bundle/bundleOrder.go index 3813d38..be5ea12 100644 --- a/pkg/service/bundle/bundleOrder.go +++ b/pkg/service/bundle/bundleOrder.go @@ -7,6 +7,7 @@ import ( "fonchain-fiee/api/accountFiee" "fonchain-fiee/api/bundle" "fonchain-fiee/api/order" + "fonchain-fiee/pkg/cache" "fonchain-fiee/pkg/model/login" "fonchain-fiee/pkg/service" "fonchain-fiee/pkg/service/bundle/common" @@ -213,6 +214,14 @@ func CreateBundleOrderSignature(c *gin.Context) { return } + // Redis 防重复提交:同一用户5秒内只能提交一次订单 + lockKey := fmt.Sprintf("create_bundle_order_%d", userInfo.ID) + reply := cache.RedisClient.SetNX(lockKey, 1, 5*time.Second) + if !reply.Val() { + service.Error(c, errors.New("请勿重复提交订单,请稍后再试")) + return + } + // 校验套餐是否已购买 if err := logic.CheckUserOrder(userInfo.ID); err != nil { service.Error(c, err)