diff --git a/pkg/service/bundle/bundleOrder.go b/pkg/service/bundle/bundleOrder.go index 7c0fd35..691434b 100644 --- a/pkg/service/bundle/bundleOrder.go +++ b/pkg/service/bundle/bundleOrder.go @@ -35,6 +35,25 @@ func CreateBundleOrderSignature(c *gin.Context) { // 获取 用户信息 userInfo := login.GetUserInfoFromC(c) + // 校验 当前用户只能买一次套餐 + orderRecordsListReq := bundle.OrderRecordsRequest{ + CustomerID: strconv.FormatUint(userInfo.ID, 10), + } + orderRecordsList, orderRecordsListErr := service.BundleProvider.OrderRecordsList(context.Background(), &orderRecordsListReq) + if orderRecordsListErr != nil { + service.Error(c, orderRecordsListErr) + return + } + + if orderRecordsList.OrderRecords != nil { + for _, order := range orderRecordsList.OrderRecords { + if order.CustomerID == strconv.FormatUint(userInfo.ID, 10) { + service.Error(c, errors.New(common.HadOrder)) + return + } + } + } + req.CustomerNum = userInfo.SubNum req.CustomerName = userInfo.Name req.CustomerID = strconv.FormatUint(userInfo.ID, 10) diff --git a/pkg/service/bundle/common/msg.go b/pkg/service/bundle/common/msg.go index b22bafb..102d3b0 100644 --- a/pkg/service/bundle/common/msg.go +++ b/pkg/service/bundle/common/msg.go @@ -15,6 +15,8 @@ const ( NotMatchOrderInfo = "非当前用户订单信息不可操作" HadPay = "订单已支付" + + HadOrder = "您已购买过套餐,无法再次购买" ) // stripe