34 lines
1.1 KiB
Go
34 lines
1.1 KiB
Go
package do
|
|
|
|
import (
|
|
"PaymentCenter/app/constants/common"
|
|
"PaymentCenter/app/models/paychannelmodel"
|
|
"PaymentCenter/app/third/paymentService"
|
|
"github.com/bytedance/sonic"
|
|
)
|
|
|
|
var RefundWayList = map[int]func(commonRefundInfo *paymentService.OrderRefundRequest, channel *paychannelmodel.PayChannel) error{
|
|
common.PAY_CHANNEL_WECHAT_H5: WechatH5Refund,
|
|
common.PAY_CHANNEL_ALIPAY_WEB: AlipayWebRefund,
|
|
}
|
|
|
|
func WechatH5Refund(commonRefundInfo *paymentService.OrderRefundRequest, channel *paychannelmodel.PayChannel) error {
|
|
commonRefundInfo.PayChannel = common.PAY_CHANNLE_TYPE_WECHAT
|
|
err := sonic.Unmarshal([]byte(channel.ExtJson), &commonRefundInfo.Wx)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
commonRefundInfo.Wx.AppId = channel.AppId
|
|
return nil
|
|
}
|
|
|
|
func AlipayWebRefund(commonRefundInfo *paymentService.OrderRefundRequest, channel *paychannelmodel.PayChannel) error {
|
|
commonRefundInfo.PayChannel = common.PAY_CHANNLE_TYPE_ZFB
|
|
err := sonic.Unmarshal([]byte(channel.ExtJson), &commonRefundInfo.Ali)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
commonRefundInfo.Ali.AppId = channel.AppId
|
|
return nil
|
|
}
|