feat: 新增充值订单独立管理模块及退款安全拦截
- 新增充值订单菜单及独立路由 - 禁用通用退款入口处理充值订单 - 完善支付场景类型及状态显示 - 补充充值退款测试用例 - 优化各模块未知状态显示提示 - 升级版本号至1.0.94
这个提交包含在:
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 开票申请仅由用户/商户端发起,禁止后台手工添加
|
||||
*/
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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 ?: []);
|
||||
|
||||
@@ -218,6 +218,7 @@ class Settle extends Backend
|
||||
'order' => $order ?: [],
|
||||
'master' => $master ?: [],
|
||||
'walletLogs' => $walletLogs,
|
||||
'walletTypeList' => (new \app\admin\model\WalletLog)->getTypeList(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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, '.', ''),
|
||||
]);
|
||||
|
||||
在新工单中引用
屏蔽一个用户