소스 검색

feat: 优化充值订单号

CalciumIon 1 년 전
부모
커밋
88ba8a840e
2개의 변경된 파일5개의 추가작업 그리고 5개의 파일을 삭제
  1. 2 2
      controller/topup.go
  2. 3 3
      controller/user.go

+ 2 - 2
controller/topup.go

@@ -101,8 +101,8 @@ func RequestEpay(c *gin.Context) {
 	}
 	uri, params, err := client.Purchase(&epay.PurchaseArgs{
 		Type:           payType,
-		ServiceTradeNo: "A" + tradeNo,
-		Name:           "B" + tradeNo,
+		ServiceTradeNo: fmt.Sprintf("USR%d-%s", id, tradeNo),
+		Name:           fmt.Sprintf("TUC%d", req.Amount),
 		Money:          strconv.FormatFloat(payMoney, 'f', 2, 64),
 		Device:         epay.PC,
 		NotifyUrl:      notifyUrl,

+ 3 - 3
controller/user.go

@@ -791,11 +791,11 @@ type topUpRequest struct {
 	Key string `json:"key"`
 }
 
-var lock = sync.Mutex{}
+var topUpLock = sync.Mutex{}
 
 func TopUp(c *gin.Context) {
-	lock.Lock()
-	defer lock.Unlock()
+	topUpLock.Lock()
+	defer topUpLock.Unlock()
 	req := topUpRequest{}
 	err := c.ShouldBindJSON(&req)
 	if err != nil {