Browse Source

debug order refund pay

abiao 5 years ago
parent
commit
c8a34b7332

+ 18 - 1
go/gopath/src/fohow.com/apps/controllers/railsadmin_controller/order_refund_controller.go

@@ -6,6 +6,8 @@ import (
 	"fohow.com/apps/models/balance_model"
 	"fohow.com/apps/models/order_model"
 	"fohow.com/libs/wx_mp"
+	"math/rand"
+	"strings"
 
 	"github.com/astaxie/beego"
 	"strconv"
@@ -76,7 +78,7 @@ func (self *RailsadminController) OrderRefund() {
 		//微信支付金额原路退款
 		if o.PaiedPrice > int64(0) {
 			outTradeNo := fmt.Sprintf("%s-%d", refund.OrderId, refund.Id)
-			outRefundNo := fmt.Sprintf("%s-%d", refund.OrderId, refund.Id)
+			outRefundNo := createOrderId("refund")
 			remark := fmt.Sprintf("%s%s", refund.OrderId, "退款")
 			payData := wx_mp.GetRefundDataPay(outTradeNo, outRefundNo, o.TotalPrice, o.TradeNo, remark)
 			if payData != nil {
@@ -89,3 +91,18 @@ func (self *RailsadminController) OrderRefund() {
 
 	self.ServeJSON()
 }
+
+//生成订单ID
+func createOrderId(prefix string) string {
+	n1 := time.Now().UnixNano()
+	n2 := RandInt64(100, 999)
+	oId := strings.ToUpper(fmt.Sprintf("%s%d%d", prefix, n1, n2))
+	return oId
+}
+
+func RandInt64(min, max int64) int64 {
+	if min >= max || min == 0 || max == 0 {
+		return max
+	}
+	return rand.Int63n(max-min) + min
+}