1234567891011121314151617181920212223242526272829303132333435363738 |
- package facade
- import (
- "eta/eta_mini_ht_api/api"
- logger "eta/eta_mini_ht_api/common/component/log"
- "eta/eta_mini_ht_api/domian/order"
- "eta/eta_mini_ht_api/service/payment"
- )
- const (
- channelWeChat = "7"
- timeoutSeconds = "900"
- )
- var (
- htTradeApi = api.GetPaymentInstance()
- )
- func PayOrder(userId, templateUserId int, productOrder order.ProductOrderDTO) (tradeOrderNo string, err error) {
- //先获取支付对接平台的支付订单号
- req := api.PaymentOrderRequest{
- BillNo: productOrder.OrderID,
- Body: productOrder.ProductDescription,
- ChannelTypeCode: channelWeChat,
- Optional: "",
- Subject: productOrder.ProductName,
- TimeoutExpress: timeoutSeconds,
- TotalFee: productOrder.TotalAmount,
- }
- tradeOrderNo, err = htTradeApi.CreatePaymentOrder(req)
- tradeOrderNo = order.GenerateTradeOrderNo()
- err = payment.CreatePaymentOrder(userId, templateUserId, productOrder.OrderID, tradeOrderNo)
- if err != nil {
- logger.Error("创建支付订单失败:%v", err)
- return
- }
- return
- }
|