diff --git a/db/schema_recharge_order_menu.sql b/db/schema_recharge_order_menu.sql new file mode 100644 index 0000000..1e3d3a9 --- /dev/null +++ b/db/schema_recharge_order_menu.sql @@ -0,0 +1,5 @@ +-- 独立充值订单列表;退款仍由服务端安全拦截。 +INSERT INTO `fa_auth_rule` (`type`,`pid`,`name`,`title`,`icon`,`condition`,`remark`,`ismenu`,`createtime`,`updatetime`,`weigh`,`status`) +SELECT 'file', p.id, 'pay_order/recharges', '充值订单', 'fa fa-credit-card', '', '用户微信在线充值订单', 1, UNIX_TIMESTAMP(), UNIX_TIMESTAMP(), 146, 'normal' +FROM `fa_auth_rule` p WHERE p.name='finance_manage' +AND NOT EXISTS (SELECT 1 FROM (SELECT name FROM `fa_auth_rule`) existing WHERE existing.name='pay_order/recharges'); diff --git a/server/application/admin/controller/Invoice.php b/server/application/admin/controller/Invoice.php index 35ab260..b6baac1 100644 --- a/server/application/admin/controller/Invoice.php +++ b/server/application/admin/controller/Invoice.php @@ -77,6 +77,7 @@ class Invoice extends Backend } $linkedOrders = InvoiceService::fetchLinkedOrders((string)$row['order_ids'], (int)$row['id']); $this->view->assign('row', $row); + $this->view->assign('invoiceIsImage', $this->isInvoiceImage((string)$row['invoice_file'])); $this->view->assign('linkedOrders', $linkedOrders); $this->view->assign('flowOptions', []); return $this->view->fetch('edit'); @@ -94,6 +95,7 @@ class Invoice extends Backend if (false === $this->request->isPost()) { $linkedOrders = InvoiceService::fetchLinkedOrders((string)$row['order_ids'], (int)$row['id']); $this->view->assign('row', $row); + $this->view->assign('invoiceIsImage', $this->isInvoiceImage((string)$row['invoice_file'])); $this->view->assign('linkedOrders', $linkedOrders); $this->view->assign('flowOptions', $this->statusFlow[$row['status']] ?? []); return $this->view->fetch(); @@ -169,6 +171,14 @@ class Invoice extends Backend $this->success(); } + /** 判断发票附件是否为可直接显示的图片,忽略 URL 查询参数。 */ + protected function isInvoiceImage($file) + { + $path = parse_url($file, PHP_URL_PATH); + $extension = strtolower(pathinfo(is_string($path) ? $path : '', PATHINFO_EXTENSION)); + return in_array($extension, ['jpg', 'jpeg', 'png', 'gif', 'webp', 'bmp'], true); + } + /** * 开票申请仅由用户/商户端发起,禁止后台手工添加 */ diff --git a/server/application/admin/controller/Order.php b/server/application/admin/controller/Order.php index 1394b60..c213fcd 100644 --- a/server/application/admin/controller/Order.php +++ b/server/application/admin/controller/Order.php @@ -670,18 +670,13 @@ class Order extends Backend unset($appeal); // 10. 微信支付与原路退款交易流水(含失败错误码及中文诊断原因) - $sceneMap = [ - 'order' => '主订单支付', - 'quote' => '选定师傅报价', - 'diff' => '增项补差价', - 'batch' => '批量下单', - ]; + $sceneMap = (new \app\admin\model\PayOrder)->getSceneList(); $payOrders = Db::name('pay_order') ->where('order_id', (int)$row['id']) ->order('id desc') ->select(); foreach ($payOrders as &$poItem) { - $poItem['scene_text'] = $sceneMap[$poItem['scene'] ?? ''] ?? ($poItem['scene'] ?? '-'); + $poItem['scene_text'] = $sceneMap[$poItem['scene'] ?? ''] ?? '未知场景'; $poItem['status_text'] = \app\common\library\PaymentService::payOrderStatusLabel($poItem['status'] ?? ''); $poItem['refund_status_text'] = \app\common\library\PaymentService::refundStatusLabel($poItem['refund_status'] ?? 'none'); $poItem['payment_type_text'] = OrderDetailDisplay::paymentRecordType($poItem); @@ -849,7 +844,9 @@ class Order extends Backend $orderRefunded = 0.00; $orderRefundable = 0.00; + $sceneMap = (new \app\admin\model\PayOrder)->getSceneList(); foreach ($payRows as &$po) { + $po['scene_text'] = $sceneMap[$po['scene'] ?? ''] ?? '未知场景'; $po['status_text'] = \app\common\library\PaymentService::payOrderStatusLabel($po['status']); $po['refund_total'] = round((float)$po['refund_amount'], 2); $po['refund_left'] = round((float)$po['amount'] - (float)$po['refund_amount'], 2); @@ -872,11 +869,12 @@ class Order extends Backend } elseif ((int)$order['settle_status'] === 1) { $blockReason = '该工单已完成向师傅结算分账,不允许售后退款(请先与师傅线下协商追回)'; } elseif (!$hasWxPayRows) { - $blockReason = '该订单为 mock/月结等线下渠道支付,无微信支付流水,无法线上原路退款,请联系财务线下人工处理并登记'; + $blockReason = '该订单无可用的线上支付流水,无法线上原路退款,请联系财务线下人工处理并登记'; } elseif ($orderRefundable <= 0) { $blockReason = '该订单的支付流水已全部退款,无可退余额'; } $this->view->assign('row', $order); + $this->view->assign('paymentTypeLabel', OrderDetailDisplay::paymentType($order['pay_type'] ?? '')); $this->view->assign('payRows', $payRows); $this->view->assign('orderRefunded', $orderRefunded); $this->view->assign('orderRefundable', $orderRefundable); diff --git a/server/application/admin/controller/PayOrder.php b/server/application/admin/controller/PayOrder.php index 2202369..c16b62b 100644 --- a/server/application/admin/controller/PayOrder.php +++ b/server/application/admin/controller/PayOrder.php @@ -42,28 +42,43 @@ class PayOrder extends Backend */ public function index() { + $rechargeOnly = strtolower($this->request->action()) === 'recharges'; $this->request->filter(['strip_tags', 'trim']); if (false === $this->request->isAjax()) { + $this->view->assign('rechargeOnly', $rechargeOnly); + $base = function () use ($rechargeOnly) { + $query = Db::name('pay_order'); + return $rechargeOnly ? $query->where('scene', 'recharge') : $query; + }; $stats = [ - 'total_count' => $this->model->count(), - 'total_paid_amount' => (float)$this->model->whereIn('status', ['paid', 'refunded', 'refunding', 'refund_failed'])->sum('amount'), - 'total_refund_amount' => (float)$this->model->sum('refund_amount'), - 'refunding_count' => $this->model->where('status', 'refunding')->whereOr('refund_status', 'processing')->count(), - 'abnormal_count' => $this->model->whereIn('status', ['pay_failed', 'refund_failed'])->whereOr('refund_status', 'abnormal')->count(), + 'total_count' => $base()->count(), + 'total_paid_amount' => (float)$base()->whereIn('status', ['paid', 'refunded', 'refunding', 'refund_failed'])->sum('amount'), + 'total_refund_amount' => (float)$base()->sum('refund_amount'), + 'refunding_count' => $base()->where(function ($q) { $q->where('status', 'refunding')->whereOr('refund_status', 'processing'); })->count(), + 'abnormal_count' => $base()->where(function ($q) { $q->whereIn('status', ['pay_failed', 'refund_failed'])->whereOr('refund_status', 'abnormal'); })->count(), ]; $this->view->assign('stats', $stats); - return $this->view->fetch(); + return $this->view->fetch('index'); } [$where, $sort, $order, $offset, $limit] = $this->buildparams(); - $list = $this->model + $query = $this->model ->with(['order', 'user']) - ->where($where) + ->where($where); + if ($rechargeOnly) { + $query->where('pay_order.scene', 'recharge'); + } + $list = $query ->order($sort, $order) ->paginate($limit); $result = ['total' => $list->total(), 'rows' => $list->items()]; return json($result); } + public function recharges() + { + return $this->index(); + } + /** * 主动向微信查询该笔流水的最新支付/退款状态并落库 */ @@ -136,14 +151,8 @@ class PayOrder extends Backend $user = $userId ? Db::name('user')->where('id', $userId)->field('id,nickname,username,mobile,avatar')->find() : null; $refundableAmount = round((float)$row['amount'] - (float)$row['refund_amount'], 2); - $sceneMap = [ - 'order' => '订单支付', - 'quote' => '报价支付', - 'diff' => '增项补差', - 'batch' => '批次支付', - 'recharge' => '用户充值' - ]; - $sceneText = $sceneMap[$row['scene']] ?? $row['scene']; + $sceneMap = $this->model->getSceneList(); + $sceneText = $sceneMap[$row['scene']] ?? '未知场景'; $this->view->assign('row', $row); $this->view->assign('order', $order ?: []); diff --git a/server/application/admin/controller/Settle.php b/server/application/admin/controller/Settle.php index bf60abb..82bc1fd 100644 --- a/server/application/admin/controller/Settle.php +++ b/server/application/admin/controller/Settle.php @@ -218,6 +218,7 @@ class Settle extends Backend 'order' => $order ?: [], 'master' => $master ?: [], 'walletLogs' => $walletLogs, + 'walletTypeList' => (new \app\admin\model\WalletLog)->getTypeList(), ]); } } diff --git a/server/application/admin/controller/Withdraw.php b/server/application/admin/controller/Withdraw.php index e94b0dc..535fda8 100644 --- a/server/application/admin/controller/Withdraw.php +++ b/server/application/admin/controller/Withdraw.php @@ -102,6 +102,8 @@ class Withdraw extends Backend 'master' => $master ?: [], 'recentSettles' => $recentSettles, 'walletLogs' => $walletLogs, + 'verifyStatusList' => ['pending' => '审核中', 'pass' => '已认证', 'reject' => '审核未通过'], + 'walletTypeList' => (new \app\admin\model\WalletLog)->getTypeList(), ]); return $this->view->fetch(); } diff --git a/server/application/admin/controller/user/User.php b/server/application/admin/controller/user/User.php index c145df7..10e8eee 100755 --- a/server/application/admin/controller/user/User.php +++ b/server/application/admin/controller/user/User.php @@ -205,6 +205,7 @@ class User extends Backend 'recentOrders' => $recentOrders, 'coupons' => $coupons, 'recentWalletLogs' => $recentWalletLogs, + 'walletTypeList' => (new \app\admin\model\WalletLog)->getTypeList(), 'orderCount' => (int)($orderAgg['total_cnt'] ?? 0), 'totalSpent' => number_format((float)($orderAgg['total_spent'] ?? 0), 2, '.', ''), ]); diff --git a/server/application/admin/model/PayOrder.php b/server/application/admin/model/PayOrder.php index 5173fef..89ab34e 100644 --- a/server/application/admin/model/PayOrder.php +++ b/server/application/admin/model/PayOrder.php @@ -30,7 +30,7 @@ class PayOrder extends Model */ public function getStatusList() { - return ['pending' => '待支付', 'paid' => '已支付', 'refunded' => '已退款', 'refunding' => '退款处理中', 'refund_failed' => '退款失败', 'closed' => '已关闭']; + return ['pending' => '待支付', 'paid' => '已支付', 'pay_failed' => '支付失败', 'refunded' => '已退款', 'refunding' => '退款处理中', 'refund_failed' => '退款失败', 'closed' => '已关闭']; } public function getStatusTextAttr($value, $data) @@ -60,7 +60,7 @@ class PayOrder extends Model */ public function getSceneList() { - return ['order' => '订单支付', 'prepay' => '预付款充值']; + return ['order' => '订单支付', 'quote' => '报价支付', 'diff' => '增项补差', 'batch' => '批次支付', 'recharge' => '用户在线充值', 'prepay' => '预付款充值']; } public function getSceneTextAttr($value, $data) diff --git a/server/application/admin/view/appeal/detail.html b/server/application/admin/view/appeal/detail.html index 052b301..17f2044 100644 --- a/server/application/admin/view/appeal/detail.html +++ b/server/application/admin/view/appeal/detail.html @@ -14,12 +14,12 @@
{$order.order_no|htmlentities}- {$typeList[$row.type]|default=$row.type|htmlentities} + {$typeList[$row.type]|default='未知类型'|htmlentities} 提交于 {:date('Y-m-d H:i', $row.createtime)}
{$order.order_no|htmlentities}
- {$orderStatusMap[$order.status]|default=$order.status}
+ {$orderStatusMap[$order.status]|default='未知状态'}
{$row.tax_no|htmlentities}{else/}-{/if}- 计价模式:{$priceTypeList[$row.price_type]|default=$row.price_type|htmlentities} + 计价模式:{$priceTypeList[$row.price_type]|default='未知类型'|htmlentities} | 支付状态: {if $row.pay_status == 1}已支付 diff --git a/server/application/admin/view/pay_order/detail.html b/server/application/admin/view/pay_order/detail.html index a2dbc06..d4a99fe 100644 --- a/server/application/admin/view/pay_order/detail.html +++ b/server/application/admin/view/pay_order/detail.html @@ -654,7 +654,7 @@ 同步微信状态 {/if} - {if ($row.status == 'refund_failed' || ($row.status == 'paid' && $refundableAmount > 0)) && $refundableAmount > 0} + {if $row.scene != 'recharge' && ($row.status == 'refund_failed' || ($row.status == 'paid' && $refundableAmount > 0)) && $refundableAmount > 0} diff --git a/server/application/admin/view/pay_order/index.html b/server/application/admin/view/pay_order/index.html index edadc89..da7c805 100644 --- a/server/application/admin/view/pay_order/index.html +++ b/server/application/admin/view/pay_order/index.html @@ -187,7 +187,7 @@
- 该结算单已于 {:$row.settle_time ? date('Y-m-d H:i:s', $row.settle_time) : '-'} 归档(状态:{$statusList[$row.status]|default=$row.status}),账务已锁定。 + 该结算单已于 {:$row.settle_time ? date('Y-m-d H:i:s', $row.settle_time) : '-'} 归档(状态:{$statusList[$row.status]|default='未知状态'}),账务已锁定。
#WL{$wl.id}{$row.account|default='微信零钱'|htmlentities}{$row.out_bill_no|htmlentities}{$row.transfer_bill_no|default='-'|htmlentities}{$wl.type|htmlentities}{$walletTypeList[$wl.type]|default='未知类型'|htmlentities}{$channelList[$row.channel]|default=$row.channel} · {$row.account|default='微信零钱'|htmlentities}
+{$channelList[$row.channel]|default='未知类型'} · {$row.account|default='微信零钱'|htmlentities}