|
@@ -13,7 +13,7 @@ type HTFuturesTradeController struct {
|
|
}
|
|
}
|
|
|
|
|
|
type ss struct {
|
|
type ss struct {
|
|
- ID string `json:"id"`
|
|
|
|
|
|
+ Success bool `json:"success"`
|
|
User int `json:"user"`
|
|
User int `json:"user"`
|
|
TradeOrderNo string `json:"tradeOrderNo"`
|
|
TradeOrderNo string `json:"tradeOrderNo"`
|
|
}
|
|
}
|
|
@@ -26,14 +26,16 @@ type ss struct {
|
|
func (h *HTFuturesTradeController) InformPaymentResult() {
|
|
func (h *HTFuturesTradeController) InformPaymentResult() {
|
|
controllers.WrapWebhook(&h.WebHookController, func() (result *controllers.WrapData, err error) {
|
|
controllers.WrapWebhook(&h.WebHookController, func() (result *controllers.WrapData, err error) {
|
|
result = h.InitWrapData("同步风险等级")
|
|
result = h.InitWrapData("同步风险等级")
|
|
- ss := new(ss)
|
|
|
|
- h.GetPostParams(ss)
|
|
|
|
-
|
|
|
|
- logger.Info("支付结果通知: %v", ss)
|
|
|
|
-
|
|
|
|
- //privateKey, err := authUtils.ParsePrivateKey(htConfig.GetWebhookPrivateKey())
|
|
|
|
- _ = product.OpenProduct(ss.User, ss.ID)
|
|
|
|
-
|
|
|
|
|
|
+ s := new(ss)
|
|
|
|
+ h.GetPostParams(s)
|
|
|
|
+ logger.Info("支付结果通知: %v", s)
|
|
|
|
+ if s.Success {
|
|
|
|
+ productOrderNo, _ := orderService.DealPayment(s.TradeOrderNo, orderService.PaySuccess)
|
|
|
|
+ //privateKey, err := authUtils.ParsePrivateKey(htConfig.GetWebhookPrivateKey())
|
|
|
|
+ _ = product.OpenProduct(s.User, productOrderNo)
|
|
|
|
+ } else {
|
|
|
|
+ _, _ = orderService.DealPayment(s.TradeOrderNo, orderService.PayFail)
|
|
|
|
+ }
|
|
//htConfig := config.GetConfig(contants.HT).(*config.HTBizConfig)
|
|
//htConfig := config.GetConfig(contants.HT).(*config.HTBizConfig)
|
|
//webhookRequest := new(WebhookRequest)
|
|
//webhookRequest := new(WebhookRequest)
|
|
//h.GetPostParams(webhookRequest)
|
|
//h.GetPostParams(webhookRequest)
|
|
@@ -73,20 +75,27 @@ func (h *HTFuturesTradeController) InformPaymentResult() {
|
|
func (h *HTFuturesTradeController) InformRefundResult() {
|
|
func (h *HTFuturesTradeController) InformRefundResult() {
|
|
controllers.WrapWebhook(&h.WebHookController, func() (result *controllers.WrapData, err error) {
|
|
controllers.WrapWebhook(&h.WebHookController, func() (result *controllers.WrapData, err error) {
|
|
result = h.InitWrapData("同步风险等级")
|
|
result = h.InitWrapData("同步风险等级")
|
|
- ss := new(ss)
|
|
|
|
- h.GetPostParams(ss)
|
|
|
|
- flow, err := orderService.DealRefund(ss.TradeOrderNo, orderService.RefundSuccess)
|
|
|
|
- if err != nil {
|
|
|
|
- logger.Error("退款订单处理失败: %v", err)
|
|
|
|
- err = exception.NewWithException(exception.RefundDealFail, err.Error())
|
|
|
|
- h.FailedResult("退款订单处理失败", result)
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
- //处理退款订单
|
|
|
|
- if true {
|
|
|
|
- _ = product.CloseProduct(ss.User, flow.ProductOrderNo)
|
|
|
|
|
|
+ s := new(ss)
|
|
|
|
+ h.GetPostParams(s)
|
|
|
|
+ if s.Success {
|
|
|
|
+ flow, RefundErr := orderService.DealRefund(s.TradeOrderNo, orderService.RefundSuccess)
|
|
|
|
+ if RefundErr != nil {
|
|
|
|
+ logger.Error("退款订单处理失败: %v", err)
|
|
|
|
+ err = exception.NewWithException(exception.RefundDealFail, err.Error())
|
|
|
|
+ h.FailedResult("退款订单处理失败", result)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ //处理退款订单
|
|
|
|
+ _ = product.CloseProduct(s.User, flow.ProductOrderNo)
|
|
|
|
+ } else {
|
|
|
|
+ _, RefundErr := orderService.DealRefund(s.TradeOrderNo, orderService.RefundFail)
|
|
|
|
+ if RefundErr != nil {
|
|
|
|
+ logger.Error("退款订单处理失败: %v", err)
|
|
|
|
+ err = exception.NewWithException(exception.RefundDealFail, err.Error())
|
|
|
|
+ h.FailedResult("退款订单处理失败", result)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
}
|
|
}
|
|
-
|
|
|
|
//创建meta_info
|
|
//创建meta_info
|
|
//htConfig := config.GetConfig(contants.HT).(*config.HTBizConfig)
|
|
//htConfig := config.GetConfig(contants.HT).(*config.HTBizConfig)
|
|
//webhookRequest := new(WebhookRequest)
|
|
//webhookRequest := new(WebhookRequest)
|