|
|
@@ -25,6 +25,7 @@ use app\common\enum\AfterSaleEnum;
|
|
|
use app\common\enum\AfterSaleLogEnum;
|
|
|
use app\common\enum\NoticeEnum;
|
|
|
use app\common\model\AfterSale;
|
|
|
+use app\common\model\Refund;
|
|
|
use app\common\service\after_sale\AfterSaleService;
|
|
|
use app\common\logic\AccountLogLogic;
|
|
|
use app\common\model\User;
|
|
|
@@ -267,18 +268,38 @@ class MixedPayService extends BasePayService
|
|
|
|
|
|
// 处理微信退款
|
|
|
if ($refundWechatAmount > 0) {
|
|
|
- $refundData = [
|
|
|
- 'transaction_id' => $order['transaction_id'],
|
|
|
- 'refund_sn' => 'mixed_refund_' . $order['sn'] . '_' . time(),
|
|
|
- 'total_fee' => $wechatAmount,
|
|
|
- 'refund_fee' => $refundWechatAmount,
|
|
|
- ];
|
|
|
-
|
|
|
- $result = $this->wechatPayService->refund($refundData);
|
|
|
+
|
|
|
+ $pay = new WeChatPayService($order['order_terminal']);
|
|
|
+ $result = $pay->refund([
|
|
|
+ 'transaction_id' => $order['transaction_id'],
|
|
|
+ 'refund_sn' => 'mixed_refund_' . $order['sn'] . '_' . time(),
|
|
|
+ 'total_fee' => $wechatAmount,
|
|
|
+ 'refund_fee' => $refundWechatAmount,
|
|
|
+ ]);
|
|
|
+
|
|
|
if ($result !== true) {
|
|
|
- throw new \Exception('微信退款失败:' . $this->wechatPayService->getError());
|
|
|
+ throw new \Exception($pay->realPay()->getMessage());
|
|
|
}
|
|
|
|
|
|
+// //更新退款日志记录
|
|
|
+// Refund::update([
|
|
|
+// 'wechat_refund_id' => 0,
|
|
|
+// 'refund_status' => 1,
|
|
|
+// 'refund_msg' => json_encode([], JSON_UNESCAPED_UNICODE),
|
|
|
+// ], ['id' => self::$refund['id']]);
|
|
|
+
|
|
|
+// $refundData = [
|
|
|
+// 'transaction_id' => $order['transaction_id'],
|
|
|
+// 'refund_sn' => 'mixed_refund_' . $order['sn'] . '_' . time(),
|
|
|
+// 'total_fee' => $wechatAmount,
|
|
|
+// 'refund_fee' => $refundWechatAmount,
|
|
|
+// ];
|
|
|
+//
|
|
|
+// $result = $this->wechatPayService->refund($refundData);
|
|
|
+// if ($result !== true) {
|
|
|
+// throw new \Exception('微信退款失败:' . $this->wechatPayService->getError());
|
|
|
+// }
|
|
|
+
|
|
|
file_put_contents(
|
|
|
runtime_path() . 'log' . DIRECTORY_SEPARATOR . 'mixed_refund_debug_' . date('Y-m-d') . '.log',
|
|
|
"[" . date('Y-m-d H:i:s') . "] 微信退款完成: {$refundWechatAmount}" . PHP_EOL,
|