文件
yjyf/server/application/admin/controller/RechargeRefund.php
MiAn 8a35d93a15 feat(front): 新增售后申请图片上传功能
- 支持最多上传3张售后凭证图片
- 提供图片预览和删除功能
- 上传图片随售后申请一起提交
2026-11-20 17:30:27 +08:00

78 行
3.6 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')
->field('r.*,p.out_trade_no,u.mobile,u.nickname');
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);
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();
}
}