feat: 新增充值订单独立管理模块及退款安全拦截
- 新增充值订单菜单及独立路由 - 禁用通用退款入口处理充值订单 - 完善支付场景类型及状态显示 - 补充充值退款测试用例 - 优化各模块未知状态显示提示 - 升级版本号至1.0.94
这个提交包含在:
@@ -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 ?: []);
|
||||
|
||||
在新工单中引用
屏蔽一个用户