kobe6258 преди 1 ден
родител
ревизия
bad02a3a8b
променени са 3 файла, в които са добавени 6 реда и са изтрити 4 реда
  1. 1 1
      controllers/payment/payment_controller.go
  2. 2 1
      domian/order/trade_order.go
  3. 3 2
      service/facade/ht_trade_service.go

+ 1 - 1
controllers/payment/payment_controller.go

@@ -97,7 +97,7 @@ func (pc *PaymentController) PayOrder() {
 				pc.FailedResult("支付失败,正式用户信息不存在", result)
 			}
 			var payOrderDTO orderDomian.PayOrderDTO
-			payOrderDTO, err = facade.PayOrder(officialUser.ID, userInfo.Id, productOrder)
+			payOrderDTO, err = facade.PayOrder(officialUser.ID, userInfo.Id, userInfo.OpenId, productOrder)
 			if err != nil {
 				pc.FailedResult("支付订单创建失败", result)
 				err = exception.NewWithException(exception.CreatePaymentOrderFailed, err.Error())

+ 2 - 1
domian/order/trade_order.go

@@ -23,7 +23,7 @@ const (
 	RefundFail                = "fail"
 	PaySuccess                = "success"
 	PayFail                   = "fail"
-	PayUrlTemplate            = "{{.Url}}?appId={{.AppId}}&totalOrder={{.Amount}}&sorderNo={{.TradeOrderNo}}&title={{.ProductTitle}}&description={{.ProductDescription}}&buyerId={{.BuyerId}}&payType={{.PayType}}"
+	PayUrlTemplate            = "{{.Url}}?appId={{.AppId}}&totalOrder={{.Amount}}&sorderNo={{.TradeOrderNo}}&title={{.ProductTitle}}&description={{.ProductDescription}}&buyerId={{.BuyerId}}&payType={{.PayType}}&openid={{.OpenId}}"
 )
 
 type PaymentWay string
@@ -38,6 +38,7 @@ type PayOrderDTO struct {
 	ProductOrderNo     string
 	TradeOrderNo       string
 	PaymentToken       string
+	OpenId             string
 }
 
 type TradeOrderDTO struct {

+ 3 - 2
service/facade/ht_trade_service.go

@@ -15,7 +15,7 @@ const (
 	channelWeChat      = "7"
 	timeoutSeconds     = "900"
 	BeforeOrderClose   = 1 * time.Second
-	DefaultDescription = "期海通行"
+	DefaultDescription = "期海通行小程序商品订单"
 )
 
 var (
@@ -23,7 +23,7 @@ var (
 	htConfig   = config.GetConfig(contants.HT).(*config.HTBizConfig)
 )
 
-func PayOrder(userId, templateUserId int, productOrder order.ProductOrderDTO) (payOrderDTO order.PayOrderDTO, err error) {
+func PayOrder(userId, templateUserId int, openId string, productOrder order.ProductOrderDTO) (payOrderDTO order.PayOrderDTO, err error) {
 	//在redis中生成token,前端通过token获取订单状态
 	expiredTime := productOrder.ExpiredTime.Sub(time.Now().Add(BeforeOrderClose))
 	tradeOrderNo := order.GenerateTradeOrderNo()
@@ -57,6 +57,7 @@ func PayOrder(userId, templateUserId int, productOrder order.ProductOrderDTO) (p
 	payOrderDTO.ProductOrderNo = productOrder.OrderID
 	payOrderDTO.ProductTitle = productOrder.ProductName
 	payOrderDTO.ProductDescription = description
+	payOrderDTO.OpenId = openId
 	//微信用户的ID
 	payOrderDTO.BuyerId = templateUserId
 	payOrderDTO.PayType = "1,2"