- 调整财务相关菜单名称、排序与权限逻辑 - 新增充值订单与退款记录的页签切换功能 - 修改结算时间、状态等术语表述,优化理解性 - 隐藏非核心列表字段,简化页面展示 - 完善钱包流水统计说明,明确数据口径 - 新增企业资质审核相关关联入口 - 修复充值退款菜单重复显示问题 - 新增相关测试用例保障功能稳定性
86 行
4.2 KiB
PHP
86 行
4.2 KiB
PHP
<?php
|
|
namespace app\admin\controller;
|
|
|
|
use app\common\controller\Backend;
|
|
use app\common\library\RechargeRefundService;
|
|
use think\Db;
|
|
|
|
class RechargeRefund extends Backend
|
|
{
|
|
public function index()
|
|
{
|
|
$status = trim((string)$this->request->get('status', ''));
|
|
$query = Db::name('recharge_refund')->alias('r')
|
|
->join('pay_order p', 'p.id=r.pay_order_id', 'LEFT')
|
|
->join('user u', 'u.id=r.user_id', 'LEFT')
|
|
->join('admin operator', 'operator.id=r.operator_id', 'LEFT')
|
|
->join('admin reviewer', 'reviewer.id=r.reviewer_id', 'LEFT')
|
|
->field('r.*,p.out_trade_no,u.mobile,u.nickname,operator.nickname AS operator_name,reviewer.nickname AS reviewer_name');
|
|
if ($status !== '') $query->where('r.status', $status);
|
|
$list = $query->order('r.id desc')->paginate(20, false, ['query'=>$this->request->get()]);
|
|
$this->view->assign('list', $list);
|
|
$this->view->assign('selectedStatus', $status);
|
|
$this->view->assign('statusLabels', [
|
|
'pending' => '待提交', 'submitting' => '提交中', 'processing' => '退款处理中',
|
|
'unknown' => '结果待核查', 'abnormal' => '异常待处理', 'success' => '退款成功',
|
|
'closed' => '微信关闭', 'rejected' => '已取消',
|
|
]);
|
|
return $this->view->fetch();
|
|
}
|
|
|
|
public function create($ids = null)
|
|
{
|
|
$pay = Db::name('pay_order')->where('id', (int)$ids)->where('scene', 'recharge')->find();
|
|
if (!$pay) $this->error('充值订单不存在');
|
|
if ($this->request->isPost()) {
|
|
$this->token();
|
|
try { $refund = RechargeRefundService::create((int)$ids, $this->request->post('amount', ''), $this->request->post('reason', ''), $this->auth->id); }
|
|
catch (\Throwable $e) { $this->error($e->getMessage()); }
|
|
try { $result = RechargeRefundService::submit((int)$refund['id'], $this->auth->id); }
|
|
catch (\Throwable $e) { $this->error('退款记录已创建,余额保持占用;请到充值退款记录核实处理:' . $e->getMessage()); }
|
|
$this->success('退款已发起,当前状态:' . $result['status']);
|
|
}
|
|
$this->view->assign('pay', $pay);
|
|
$this->view->assign('balance', Db::name('user')->where('id', (int)$pay['user_id'])->value('money'));
|
|
return $this->view->fetch();
|
|
}
|
|
|
|
public function review($ids = null)
|
|
{
|
|
$row = Db::name('recharge_refund')->where('id', (int)$ids)->find();
|
|
if (!$row) $this->error('退款申请不存在');
|
|
if ($this->request->isPost()) {
|
|
$this->token();
|
|
$action = $this->request->post('action', '');
|
|
try {
|
|
if ($action === 'reject') {
|
|
RechargeRefundService::reject((int)$ids, $this->auth->id, $this->request->post('note', ''));
|
|
$this->success('已取消并释放余额');
|
|
}
|
|
if ($action !== 'approve') throw new \InvalidArgumentException('无效操作');
|
|
RechargeRefundService::submit((int)$ids, $this->auth->id);
|
|
} catch (\think\exception\HttpResponseException $e) { throw $e; }
|
|
catch (\Throwable $e) { $this->error('处理未完成,请查看退款记录及余额占用状态:' . $e->getMessage()); }
|
|
$this->success('退款已发起,请查看退款状态');
|
|
}
|
|
$this->view->assign('row', $row);
|
|
return $this->view->fetch();
|
|
}
|
|
|
|
public function resolve($ids = null)
|
|
{
|
|
$row = Db::name('recharge_refund')->where('id', (int)$ids)->find();
|
|
if (!$row) $this->error('退款申请不存在');
|
|
if ($this->request->isPost()) {
|
|
$this->token();
|
|
try {
|
|
if ($this->request->post('action', '') === 'retry') RechargeRefundService::send((int)$ids);
|
|
else RechargeRefundService::sync((int)$ids);
|
|
} catch (\Throwable $e) { $this->error('处理失败,余额保持占用:' . $e->getMessage()); }
|
|
$this->success('处理完成,请查看退款状态');
|
|
}
|
|
$this->view->assign('row', $row);
|
|
return $this->view->fetch();
|
|
}
|
|
}
|