Procházet zdrojové kódy

Merge branch 'ht_3.3_payment' into debug

kobe6258 před 2 dny
rodič
revize
e5536c67a6

+ 7 - 0
common/exception/exc_enums.go

@@ -358,3 +358,10 @@ func NewWithException(code int, exception string) *EtaError {
 	}
 	return newExceptionWithOrgMsg(code, err, exception).(*EtaError)
 }
+func NewExceptionWithOutError(code int) *EtaError {
+	err := ErrorMap[code]
+	if stringUtils.IsBlank(err) {
+		return newException(UnknownError, ErrorMap[UnknownError]).(*EtaError)
+	}
+	return newException(0, err).(*EtaError)
+}

+ 2 - 2
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())
@@ -155,7 +155,7 @@ func (pc *PaymentController) PayOrderStatus(token string) {
 		}
 		if paymentParams.Status == payUtils.PENDING {
 			pc.FailedResult("微信支付发起中,请耐心等待", result)
-			err = exception.New(exception.GetPaymentTokenFailed)
+			err = exception.NewExceptionWithOutError(exception.GetPaymentTokenFailed)
 			return
 		}
 		if paymentParams.Status == payUtils.READY {

+ 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"