瀏覽代碼

商品订单

kobe6258 4 月之前
父節點
當前提交
2d450212f2
共有 1 個文件被更改,包括 12 次插入1 次删除
  1. 12 1
      controllers/order.go

+ 12 - 1
controllers/order.go

@@ -9,6 +9,7 @@ import (
 	"fmt"
 	"github.com/rdlucklib/rdluck_tools/paging"
 	"github.com/xuri/excelize/v2"
+	"math/rand"
 	"net/http"
 	"net/url"
 	"strconv"
@@ -738,8 +739,9 @@ func (this *OrderController) Refund() {
 		br.ErrMsg = "退款失败,原订单未完成支付"
 		return
 	}
+	aa := GenerateProductOrderNo()
 	refundOrder := &models.TradeOrder{
-		TransactionId:    productOrder.TradeNO,
+		TransactionId:    aa,
 		OrgTransactionId: productOrder.TradeNO,
 		ProductOrderId:   productOrder.OrderID,
 		PaymentAccount:   tradeOrder.PaymentAccount,
@@ -767,6 +769,15 @@ func (this *OrderController) Refund() {
 	br.Success = true
 	br.Msg = "退款处理成功"
 }
+func GenerateProductOrderNo() string {
+	timestamp := time.Now().UnixNano() / 1000000 // 毫秒级时间戳
+	// 生成随机数
+	rand.New(rand.NewSource(time.Now().UnixNano()))
+	randomPart := rand.Intn(999999)
+	// 格式化订单号
+	orderNumber := fmt.Sprintf("R%d%06d", timestamp, randomPart)
+	return orderNumber
+}
 
 // RefundDetail
 // @Title 退款详情