ht_trade_service.go 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. package facade
  2. import (
  3. "eta/eta_mini_ht_api/api"
  4. logger "eta/eta_mini_ht_api/common/component/log"
  5. "eta/eta_mini_ht_api/domian/order"
  6. "eta/eta_mini_ht_api/service/payment"
  7. )
  8. const (
  9. channelWeChat = "7"
  10. timeoutSeconds = "900"
  11. )
  12. var (
  13. htTradeApi = api.GetPaymentInstance()
  14. )
  15. func PayOrder(userId, templateUserId int, productOrder order.ProductOrderDTO) (tradeOrderNo string, err error) {
  16. //先获取支付对接平台的支付订单号
  17. req := api.PaymentOrderRequest{
  18. BillNo: productOrder.OrderID,
  19. Body: productOrder.ProductDescription,
  20. ChannelTypeCode: channelWeChat,
  21. Optional: "",
  22. Subject: productOrder.ProductName,
  23. TimeoutExpress: timeoutSeconds,
  24. TotalFee: productOrder.TotalAmount,
  25. }
  26. tradeOrderNo, err = htTradeApi.CreatePaymentOrder(req)
  27. tradeOrderNo = order.GenerateTradeOrderNo()
  28. err = payment.CreatePaymentOrder(userId, templateUserId, productOrder.OrderID, tradeOrderNo)
  29. if err != nil {
  30. logger.Error("创建支付订单失败:%v", err)
  31. return
  32. }
  33. return
  34. }