diff --git a/server/application/admin/controller/Order.php b/server/application/admin/controller/Order.php index 41b7e71..770e54c 100644 --- a/server/application/admin/controller/Order.php +++ b/server/application/admin/controller/Order.php @@ -47,9 +47,11 @@ class Order extends Backend return $this->selectpage(); } [$where, $sort, $order, $offset, $limit] = $this->buildparams(); + $scopeUserId = $this->request->get('scope_user_id/d', 0); $list = $this->model ->with(['user', 'master']) ->where($where) + ->where(function ($query) use ($scopeUserId) { if ($scopeUserId > 0) $query->where('order.user_id', $scopeUserId); }) ->order($sort, $order) ->paginate($limit); @@ -762,69 +764,7 @@ class Order extends Backend */ public function retryrefund($ids = null) { - if (!$this->request->isPost()) { - $this->error('非法请求方式'); - } - $payOrderId = $this->request->post('pay_order_id/d', 0); - if ($payOrderId <= 0) { - $payOrderId = (int)$ids; - } - $po = Db::name('pay_order')->where('id', $payOrderId)->find(); - if (!$po) { - $this->error('未找到指定的支付交易流水'); - } - - $order = Db::name('order')->where('id', (int)$po['order_id'])->find(); - if (!$order) { - $this->error('关联业务订单不存在'); - } - if ((int)$order['settle_status'] === 1) { - $this->error('该工单已完成向师傅结算分账,不允许再执行退款'); - } - - $status = (string)($po['status'] ?? ''); - if ($status === 'refunding') { - $this->error('该流水处于微信退款处理中,请先点击【同步微信状态】核实是否已到账,切勿盲目重退'); - } - if (!in_array($status, ['refund_failed', 'paid'], true)) { - $this->error('当前流水状态为「' . \app\common\library\PaymentService::payOrderStatusLabel($status) . '」,不可发起原路退款'); - } - - $reason = trim($this->request->post('reason/s', '')); - try { - $after = \app\common\library\PaymentService::refundSinglePayOrder( - $payOrderId, - $reason !== '' ? $reason : '管理员后台手动发起/重试原路退款' - ); - } catch (\Throwable $e) { - $this->error('发起原路退款失败:' . $e->getMessage()); - } - - // 若主工单已处于取消状态且本笔退款受理/到账成功,同步汇总真实退款金额 - if ((int)$order['status'] === 9 && in_array($after['status'] ?? '', ['refunding', 'refunded'], true)) { - $allPaid = Db::name('pay_order') - ->where('order_id', (int)$order['id']) - ->whereIn('status', ['paid', 'refunding', 'refunded', 'refund_failed']) - ->select(); - $hasUnsettledRefund = false; - $sumRefund = 0.00; - foreach ($allPaid as $item) { - if (in_array($item['status'], ['refunding', 'refunded'], true)) { - $sumRefund = round($sumRefund + (float)($item['refund_amount'] ?: $item['amount']), 2); - } else { - $hasUnsettledRefund = true; - } - } - Db::name('order')->where('id', (int)$order['id'])->update([ - 'pay_status' => $hasUnsettledRefund ? (int)$order['pay_status'] : 2, - 'refund_amount' => $sumRefund, - 'updatetime' => time(), - ]); - } - - $statusLabel = \app\common\library\PaymentService::payOrderStatusLabel($after['status'] ?? ''); - $refundLabel = \app\common\library\PaymentService::refundStatusLabel($after['refund_status'] ?? 'none'); - $this->success('微信原路退款请求已提交,当前状态:' . $statusLabel . '(' . $refundLabel . ')'); + $this->error('退款重发暂不可用:请先核对原退款单及金额,再通过订单售后流程处理'); } /** diff --git a/server/application/admin/controller/PayOrder.php b/server/application/admin/controller/PayOrder.php index 0c4a52a..d725347 100644 --- a/server/application/admin/controller/PayOrder.php +++ b/server/application/admin/controller/PayOrder.php @@ -11,7 +11,7 @@ use think\exception\PDOException; * 微信支付退款台账 * * 展示全站微信支付流水(fa_pay_order)的支付/退款状态、网关回执与异常诊断, - * 提供人工同步微信退款状态与重发原路退款入口(复用 PaymentService 防资损校验)。 + * 提供人工同步微信退款状态入口。 * * @icon fa fa-undo */ @@ -109,25 +109,7 @@ class PayOrder extends Backend */ public function retryrefund($ids = null) { - $id = (int)$ids; - $po = Db::name('pay_order')->where('id', $id)->find(); - if (!$po) { - $this->error(__('No Results were found')); - } - $left = round((float)$po['amount'] - (float)$po['refund_amount'], 2); - if ($left <= 0) { - $this->error('该流水可退余额为 0,无需再次退款'); - } - try { - $after = PaymentService::refundSinglePayOrder($id, '平台人工重发原路退款(退款台账)'); - PaymentService::syncCancelledOrderRefund((int)$po['order_id']); - } catch (\Throwable $e) { - $this->error('重发退款失败:' . $e->getMessage()); - return; - } - $statusLabel = PaymentService::payOrderStatusLabel($after['status'] ?? ''); - $refundLabel = PaymentService::refundStatusLabel($after['refund_status'] ?? 'none'); - $this->success('退款请求已提交:' . $statusLabel . '(' . $refundLabel . ',累计已退 ¥' . $after['refund_amount'] . ')'); + $this->error('退款重发暂不可用:请先核对原退款单及金额,再通过订单售后流程处理'); } /** @@ -175,7 +157,7 @@ class PayOrder extends Backend public function edit($ids = null) { - $this->error('支付流水不可手工编辑,如需退款请使用行内"同步/重发退款"操作'); + $this->error('支付流水不可手工编辑,如需退款请使用订单售后流程'); } public function del($ids = null) diff --git a/server/application/admin/controller/WalletLog.php b/server/application/admin/controller/WalletLog.php index a35c195..a89cf3c 100644 --- a/server/application/admin/controller/WalletLog.php +++ b/server/application/admin/controller/WalletLog.php @@ -34,9 +34,13 @@ class WalletLog extends Backend public function index() { $this->request->filter(['strip_tags', 'trim']); + $scopeUserId = $this->request->get('scope_user_id/d', 0); if (false === $this->request->isAjax()) { - $totalIncome = round((float)Db::name('wallet_log')->where('amount', '>', 0)->sum('amount'), 2); - $totalOutflow = round(abs((float)Db::name('wallet_log')->where('amount', '<', 0)->sum('amount')), 2); + $scope = function ($query) use ($scopeUserId) { + if ($scopeUserId > 0) $query->where('user_type', 'user')->where('user_id', $scopeUserId); + }; + $totalIncome = round((float)Db::name('wallet_log')->where($scope)->where('amount', '>', 0)->sum('amount'), 2); + $totalOutflow = round(abs((float)Db::name('wallet_log')->where($scope)->where('amount', '<', 0)->sum('amount')), 2); $this->view->assign([ 'totalIncome' => $totalIncome, 'totalOutflow' => $totalOutflow, @@ -49,6 +53,7 @@ class WalletLog extends Backend [$where, $sort, $order, $offset, $limit] = $this->buildparams(); $list = $this->model ->where($where) + ->where(function ($query) use ($scopeUserId) { if ($scopeUserId > 0) $query->where('user_type', 'user')->where('user_id', $scopeUserId); }) ->order($sort, $order) ->paginate($limit); diff --git a/server/application/admin/view/order/detail.html b/server/application/admin/view/order/detail.html index f5ab21e..f7287a3 100644 --- a/server/application/admin/view/order/detail.html +++ b/server/application/admin/view/order/detail.html @@ -546,11 +546,6 @@ 同步微信状态 {/if} - {if $po.status == 'refund_failed' || ($po.status == 'paid' && $row.status == 9 && $row.settle_status != 1)} - - {/if} {if $po.status == 'refunded' || $po.status == 'closed' || ($po.status == 'paid' && ($row.status != 9 || $row.settle_status == 1))} 无需人工处置 {/if} diff --git a/server/application/admin/view/pay_order/detail.html b/server/application/admin/view/pay_order/detail.html index b94aabc..0c4cc46 100644 --- a/server/application/admin/view/pay_order/detail.html +++ b/server/application/admin/view/pay_order/detail.html @@ -434,7 +434,7 @@ {if strpos($row.fail_code, 'CURL_60') !== false} 系统支付安全配置异常,请联系技术人员处理。 {elseif $row.status == 'refund_failed'} - 退款未能成功,请确认微信商户号可用余额充足后,点击下方【重发原路退款】重新发起。 + 退款未能成功,请核对原退款单状态和金额后联系财务处理。 {else /} 可点击下方【同步微信状态】获取最新结果,或登录微信商户平台核对。 {/if} @@ -646,7 +646,7 @@