f
This commit is contained in:
@@ -144,17 +144,21 @@ func (a *AliPayService) CreateAlipayOrder(ctx context.Context, amount float64, s
|
||||
}
|
||||
|
||||
// AliRefund 发起支付宝退款。orderPayTime 为订单支付时间(或创建时间);仅当落在 [2026-01-25 16:38:17, 2026-02-02 18:26) 区间内时使用 bak 商户号,否则使用正式商户号;传 nil 则使用正式商户号。
|
||||
func (a *AliPayService) AliRefund(ctx context.Context, outTradeNo string, refundAmount float64, orderPayTime *time.Time) (*alipay.TradeRefundRsp, error) {
|
||||
// outRequestNo 为商户退款请求号,同一笔退款需唯一;传空则使用 "refund-"+outTradeNo,重试时建议传入唯一号避免支付宝报重复。
|
||||
func (a *AliPayService) AliRefund(ctx context.Context, outTradeNo string, refundAmount float64, orderPayTime *time.Time, outRequestNo string) (*alipay.TradeRefundRsp, error) {
|
||||
client := a.AlipayClient
|
||||
if orderPayTime != nil && a.AlipayClientBak != nil &&
|
||||
!orderPayTime.Before(AlipayBakRefundStart) && orderPayTime.Before(AlipayBakRefundEnd) {
|
||||
client = a.AlipayClientBak
|
||||
}
|
||||
|
||||
if outRequestNo == "" {
|
||||
outRequestNo = fmt.Sprintf("refund-%s", outTradeNo)
|
||||
}
|
||||
refund := alipay.TradeRefund{
|
||||
OutTradeNo: outTradeNo,
|
||||
RefundAmount: lzUtils.ToAlipayAmount(refundAmount),
|
||||
OutRequestNo: fmt.Sprintf("refund-%s", outTradeNo),
|
||||
OutRequestNo: outRequestNo,
|
||||
}
|
||||
|
||||
refundResp, err := client.TradeRefund(ctx, refund)
|
||||
|
||||
Reference in New Issue
Block a user