diff --git a/app/AdminAgent/Extensions/Grid/AuditRefund.php b/app/AdminAgent/Extensions/Grid/AuditRefund.php index d7275ab..465f334 100644 --- a/app/AdminAgent/Extensions/Grid/AuditRefund.php +++ b/app/AdminAgent/Extensions/Grid/AuditRefund.php @@ -78,10 +78,24 @@ class AuditRefund extends RowAction // 参数分别为:微信订单号、商户退款单号、订单金额、退款金额、其他参数 foreach ($log as $k=>$v) { $refund_no = $order->refund_info['refund_no'] . '-' . $v['id']; - $app->refund->byTransactionId($v->transaction_id, $refund_no, $v->money, $v->money, $config); + $money = intval(0 - $v->money * 100); + $result = $app->refund->byTransactionId($v->transaction_id, $refund_no, $money, $money); + + //存入UserMoneyLog + if (isset($result['return_code'], $result['result_code']) && $result['return_code'] == 'SUCCESS' && $result['result_code'] == 'SUCCESS') { + UserMoneyLog::query()->insert([ + 'user_id' => $order->user_id, + 'agent_id' => $order->agent_id, + 'money' => $result['refund_fee'] / 100, + 'order_id' => $order->id, + 'type' => 2, + 'desc' => DB::raw("LEFT('退款:{$order->title}', 250)"), + 'transaction_id' => $result['transaction_id'], + 'created_at' => now(), //模型没有updated_at,无法自动写入时间 + ]); + } } - //退款回调之后再存入UserMoneyLog DB::commit(); return $this->response()->success("操作成功,已向微信申请退款,款项将原路退还")->refresh();