退款回调

This commit is contained in:
chenbo 2023-11-21 17:22:45 +08:00
parent 0e95637a2b
commit ce9590b4ec
1 changed files with 5 additions and 0 deletions

View File

@ -244,6 +244,7 @@ class WeChatPayMerchantService extends BasePayService
if (empty($order)) { if (empty($order)) {
throw new Exception('回调订单不存在'); throw new Exception('回调订单不存在');
} }
// 防止重复操作
if ($order['pay_status'] == PayOrderEnum::PAY_STATUS_ISPAID && !empty($order['transaction_id'])) { if ($order['pay_status'] == PayOrderEnum::PAY_STATUS_ISPAID && !empty($order['transaction_id'])) {
return true; return true;
} }
@ -278,6 +279,10 @@ class WeChatPayMerchantService extends BasePayService
\think\facade\Log::info(['退款回调信息', $message]); \think\facade\Log::info(['退款回调信息', $message]);
if($message['refund_status'] === 'SUCCESS') { if($message['refund_status'] === 'SUCCESS') {
$refundOrder = RefundOrder::where(['out_trade_no', $message['out_trade_no'], 'refund_sn'=>$message['out_refund_no']])->find(); $refundOrder = RefundOrder::where(['out_trade_no', $message['out_trade_no'], 'refund_sn'=>$message['out_refund_no']])->find();
// 防止重复操作
if ($refundOrder['refund_status'] == 1 && !empty($order['refund_id'])) {
return true;
}
$refundOrder->refund_status = 1; $refundOrder->refund_status = 1;
$refundOrder->refund_id = $message['refund_id']; $refundOrder->refund_id = $message['refund_id'];
$refundOrder->finish_time = time(); $refundOrder->finish_time = time();