feat(front): 新增售后申请图片上传功能

- 支持最多上传3张售后凭证图片
- 提供图片预览和删除功能
- 上传图片随售后申请一起提交
这个提交包含在:
2026-11-20 17:30:27 +08:00
父节点 f4f0c5513e
当前提交 8a35d93a15
共有 15 个文件被更改,包括 90 次插入 和 34 次删除

查看文件

@@ -1,9 +1,12 @@
INSERT INTO `fa_auth_rule` (`type`,`pid`,`name`,`title`,`icon`,`condition`,`remark`,`ismenu`,`createtime`,`updatetime`,`weigh`,`status`)
SELECT 'file',p.id,'recharge_refund','充值退款审核','fa fa-undo','','用户充值原路退款及审核',1,UNIX_TIMESTAMP(),UNIX_TIMESTAMP(),145,'normal'
SELECT 'file',p.id,'recharge_refund','充值退款记录','fa fa-undo','','用户充值原路退款记录',1,UNIX_TIMESTAMP(),UNIX_TIMESTAMP(),145,'normal'
FROM `fa_auth_rule` p WHERE p.name='finance_manage' AND NOT EXISTS (SELECT 1 FROM (SELECT name FROM `fa_auth_rule`) x WHERE x.name='recharge_refund');
INSERT INTO `fa_auth_rule` (`type`,`pid`,`name`,`title`,`icon`,`condition`,`remark`,`ismenu`,`createtime`,`updatetime`,`weigh`,`status`)
SELECT 'file',p.id,permissions.name,permissions.title,'fa fa-circle-o','','',0,UNIX_TIMESTAMP(),UNIX_TIMESTAMP(),0,'normal'
FROM `fa_auth_rule` p JOIN (
SELECT 'recharge_refund/index' AS name,'查看' AS title UNION ALL SELECT 'recharge_refund/create','申请退款' UNION ALL SELECT 'recharge_refund/review','审核退款' UNION ALL SELECT 'recharge_refund/resolve','查询与重试'
SELECT 'recharge_refund/index' AS name,'查看' AS title UNION ALL SELECT 'recharge_refund/create','发起退款' UNION ALL SELECT 'recharge_refund/review','处理未提交退款' UNION ALL SELECT 'recharge_refund/resolve','查询与重试'
) permissions WHERE p.name='recharge_refund' AND NOT EXISTS (SELECT 1 FROM (SELECT name FROM `fa_auth_rule`) x WHERE x.name=permissions.name);
UPDATE `fa_auth_rule` SET `title`='充值退款记录', `remark`='用户充值原路退款记录', `updatetime`=UNIX_TIMESTAMP() WHERE `name`='recharge_refund';
UPDATE `fa_auth_rule` SET `title`='发起退款', `updatetime`=UNIX_TIMESTAMP() WHERE `name`='recharge_refund/create';
UPDATE `fa_auth_rule` SET `title`='处理未提交退款', `updatetime`=UNIX_TIMESTAMP() WHERE `name`='recharge_refund/review';

查看文件

@@ -26,9 +26,11 @@ class RechargeRefund extends Backend
if (!$pay) $this->error('充值订单不存在');
if ($this->request->isPost()) {
$this->token();
try { RechargeRefundService::create((int)$ids, $this->request->post('amount', ''), $this->request->post('reason', ''), $this->auth->id); }
try { $refund = RechargeRefundService::create((int)$ids, $this->request->post('amount', ''), $this->request->post('reason', ''), $this->auth->id); }
catch (\Throwable $e) { $this->error($e->getMessage()); }
$this->success('退款申请已提交,余额已占用,等待审核');
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'));
@@ -45,15 +47,13 @@ class RechargeRefund extends Backend
try {
if ($action === 'reject') {
RechargeRefundService::reject((int)$ids, $this->auth->id, $this->request->post('note', ''));
$this->success('已驳回并释放余额');
$this->success('已取消并释放余额');
}
if ($action !== 'approve') throw new \InvalidArgumentException('无效操作');
RechargeRefundService::begin((int)$ids, $this->auth->id, $this->request->post('note', ''));
RechargeRefundService::submit((int)$ids, $this->auth->id);
} catch (\think\exception\HttpResponseException $e) { throw $e; }
catch (\Throwable $e) { $this->error($e->getMessage()); }
try { RechargeRefundService::send((int)$ids); }
catch (\Throwable $e) { $this->error('申请已审核,微信结果待核实,余额保持占用:' . $e->getMessage()); }
$this->success('退款请求已处理,请查看退款状态');
catch (\Throwable $e) { $this->error('处理未完成,请查看退款记录及余额占用状态:' . $e->getMessage()); }
$this->success('退款已发起,请查看退款状态');
}
$this->view->assign('row', $row);
return $this->view->fetch();

查看文件

@@ -187,7 +187,7 @@
</div>
<div class="po-guide-body">
<strong>操作指引:</strong>
{if $rechargeOnly}可对已支付的充值订单申请原路退款,提交后占用余额,审核通过后向微信退款。{else /}展示全站微信支付与原路退款记录。充值退款请使用充值订单中的专用入口。{/if}
{if $rechargeOnly}可对已支付的充值订单发起原路退款,确认后占用余额并向微信提交退款。{else /}展示全站微信支付与原路退款记录。充值退款请使用充值订单中的专用入口。{/if}
</div>
</div>

查看文件

@@ -4,5 +4,5 @@
<div class="form-group"><label class="control-label col-sm-3">充值 / 已退</label><div class="col-sm-8"><p class="form-control-static">¥{$pay.amount|htmlentities} / ¥{$pay.refund_amount|htmlentities},当前可用余额 ¥{$balance|htmlentities}</p></div></div>
<div class="form-group"><label class="control-label col-sm-3">退款金额</label><div class="col-sm-8"><input class="form-control" name="amount" data-rule="required" placeholder="最多两位小数"></div></div>
<div class="form-group"><label class="control-label col-sm-3">退款原因</label><div class="col-sm-8"><textarea class="form-control" name="reason" maxlength="255" data-rule="required"></textarea></div></div>
<div class="form-group"><div class="col-sm-offset-3 col-sm-8"><p>提交后将立即占用余额,审核通过后向微信发起退款。</p><button type="submit" class="btn btn-primary">提交申请</button></div></div>
<div class="form-group"><div class="col-sm-offset-3 col-sm-8"><p>确认后立即占用余额并向微信发起原路退款。</p><button type="submit" class="btn btn-primary">确认退款</button></div></div>
</form>

查看文件

@@ -1,11 +1,11 @@
<div class="panel panel-default panel-intro">
<div class="panel-heading"><h4>充值退款申请</h4><p>退款处理中、状态未知及异常时,余额保持占用;请核实微信状态。</p></div>
<div class="panel-heading"><h4>充值退款记录</h4><p>退款处理中、状态未知及异常时,余额保持占用;请核实微信状态。</p></div>
<div class="panel-body">
<form class="form-inline" method="get"><label>状态 <select name="status" class="form-control"><option value="">全部</option><option value="pending">待审核</option><option value="submitting">提交中</option><option value="processing">退款处理中</option><option value="unknown">结果未知</option><option value="abnormal">异常待处理</option><option value="success">退款成功</option><option value="closed">微信关闭</option><option value="rejected">已驳回</option></select></label> <button class="btn btn-default">查询</button></form>
<div class="table-responsive"><table class="table table-striped table-bordered"><thead><tr><th>申请单号</th><th>充值支付单号</th><th>用户</th><th>金额</th><th>状态</th><th>申请原因 / 审核备注</th><th>操作人 / 审核人 ID</th><th>申请时间</th><th>操作</th></tr></thead><tbody>
<form class="form-inline" method="get"><label>状态 <select name="status" class="form-control"><option value="">全部</option><option value="pending">待提交</option><option value="submitting">提交中</option><option value="processing">退款处理中</option><option value="unknown">结果未知</option><option value="abnormal">异常待处理</option><option value="success">退款成功</option><option value="closed">微信关闭</option><option value="rejected">已取消</option></select></label> <button class="btn btn-default">查询</button></form>
<div class="table-responsive"><table class="table table-striped table-bordered"><thead><tr><th>退款单号</th><th>充值支付单号</th><th>用户</th><th>金额</th><th>状态</th><th>退款原因 / 处理备注</th><th>操作人 / 处理人 ID</th><th>创建时间</th><th>操作</th></tr></thead><tbody>
{volist name="list" id="row"}
<tr><td>{$row.refund_no|htmlentities}</td><td>{$row.out_trade_no|htmlentities}</td><td>{$row.nickname|htmlentities} {$row.mobile|htmlentities}</td><td>¥{$row.amount|htmlentities}</td><td>{$row.status|htmlentities}</td><td>{$row.reason|htmlentities}<br>{$row.audit_note|htmlentities}<br>{$row.error|htmlentities}</td><td>{$row.operator_id|htmlentities} / {$row.reviewer_id|htmlentities}</td><td>{$row.createtime|date='Y-m-d H:i:s',###}</td><td>
{if $row.status == 'pending' && $auth->check('recharge_refund/review')}<a href="{:url('recharge_refund/review', ['ids'=>$row.id])}" class="btn btn-xs btn-primary btn-dialog" title="审核退款">审核</a>{/if}
{if $row.status == 'pending' && $auth->check('recharge_refund/review')}<a href="{:url('recharge_refund/review', ['ids'=>$row.id])}" class="btn btn-xs btn-primary btn-dialog" title="处理未提交退款">处理</a>{/if}
{if in_array($row.status, ['submitting','unknown','processing','abnormal']) && $auth->check('recharge_refund/resolve')}<a href="{:url('recharge_refund/resolve', ['ids'=>$row.id])}" class="btn btn-xs btn-warning btn-dialog" title="处理退款">处理</a>{/if}
</td></tr>
{/volist}

查看文件

@@ -2,8 +2,8 @@
{:token()}
<div class="form-group"><label class="control-label col-sm-3">退款单号</label><div class="col-sm-8"><p class="form-control-static">{$row.refund_no|htmlentities}</p></div></div>
<div class="form-group"><label class="control-label col-sm-3">退款金额</label><div class="col-sm-8"><p class="form-control-static">¥{$row.amount|htmlentities}</p></div></div>
<div class="form-group"><label class="control-label col-sm-3">申请原因</label><div class="col-sm-8"><p class="form-control-static">{$row.reason|htmlentities}</p></div></div>
<div class="form-group"><label class="control-label col-sm-3">审核结果</label><div class="col-sm-8"><select name="action" class="form-control"><option value="approve">通过并发起微信退款</option><option value="reject">驳回并释放余额</option></select></div></div>
<div class="form-group"><label class="control-label col-sm-3">审核备注</label><div class="col-sm-8"><textarea class="form-control" name="note" maxlength="255" placeholder="驳回时必填"></textarea></div></div>
<div class="form-group"><div class="col-sm-offset-3 col-sm-8"><button type="submit" class="btn btn-primary">确认审核</button></div></div>
<div class="form-group"><label class="control-label col-sm-3">退款原因</label><div class="col-sm-8"><p class="form-control-static">{$row.reason|htmlentities}</p></div></div>
<div class="form-group"><label class="control-label col-sm-3">处理方式</label><div class="col-sm-8"><select name="action" class="form-control"><option value="approve">继续发起微信退款</option><option value="reject">取消并释放余额</option></select></div></div>
<div class="form-group"><label class="control-label col-sm-3">处理备注</label><div class="col-sm-8"><textarea class="form-control" name="note" maxlength="255" placeholder="取消时必填"></textarea></div></div>
<div class="form-group"><div class="col-sm-offset-3 col-sm-8"><button type="submit" class="btn btn-primary">确认处理</button></div></div>
</form>

查看文件

@@ -3337,12 +3337,12 @@ class Master extends Base
default:
return [
[
'title' => '电子特种作业操作证示例',
'title' => '特种作业操作证正面示例',
'url' => '/static/images/master/cert-sample-special-card.png',
],
[
'title' => '纸质特种作业资格证示例',
'url' => '/static/images/master/cert-sample-qualification.png',
'title' => '特种作业操作证背面示例',
'url' => '/static/images/master/cert-sample-special-card-back.png',
],
];
}

查看文件

@@ -2579,7 +2579,7 @@ class PaymentService
}
Db::name('order')->where('id', $orderId)->update($quoteOrderUpdate);
self::addOrderLog($orderId, OrderStatus::SCHEDULED, '买家选定师傅报价并使用余额支付差价 ¥' . number_format($payAmount, 2, '.', ''), 'user', $operatorUid);
self::sendMasterAndUserMessage($masterId, $operatorUid, '师傅已被选定', '客户已选定您的报价并完成支付,请及时预约上门');
self::sendNotify('master', $masterId, '师傅已被选定', '客户已选定您的报价并完成支付,请及时预约上门', 'order', $orderId);
} elseif ($scene === 'diff') {
$newPayTotal = round((float)$lockedOrder['pay_amount'] + $payAmount, 2);
$newTotalAmount = round((float)$lockedOrder['total_amount'] + $payAmount, 2);

查看文件

@@ -36,13 +36,19 @@ final class RechargeRefundService
} catch (\Throwable $e) { Db::rollback(); throw $e; }
}
public static function submit($refundId, $operatorId)
{
self::begin($refundId, $operatorId, '');
return self::send($refundId);
}
public static function begin($refundId, $reviewerId, $note)
{
if ((int)$reviewerId <= 0 || mb_strlen(trim((string)$note)) > 255) throw new \InvalidArgumentException('审核信息不正确');
$changed = Db::name('recharge_refund')->where('id', (int)$refundId)->where('status', 'pending')->update([
'status'=>'submitting', 'reviewer_id'=>(int)$reviewerId, 'audit_note'=>trim((string)$note), 'updatetime'=>time()
]);
if (!$changed) throw new \InvalidArgumentException('退款申请不在待审核状态');
if (!$changed) throw new \InvalidArgumentException('退款记录不在待提交状态');
return Db::name('recharge_refund')->where('id', (int)$refundId)->find();
}
@@ -125,18 +131,18 @@ final class RechargeRefundService
public static function reject($refundId, $reviewerId, $note)
{
$note = trim((string)$note);
if ($note === '' || mb_strlen($note) > 255 || (int)$reviewerId <= 0) throw new \InvalidArgumentException('请填写驳回原因');
if ($note === '' || mb_strlen($note) > 255 || (int)$reviewerId <= 0) throw new \InvalidArgumentException('请填写取消原因');
$initial = Db::name('recharge_refund')->where('id', (int)$refundId)->find();
if (!$initial) throw new \InvalidArgumentException('退款申请不存在');
Db::startTrans();
try {
$user = Db::name('user')->where('id', (int)$initial['user_id'])->lock(true)->find();
$refund = Db::name('recharge_refund')->where('id', (int)$refundId)->lock(true)->find();
if (!$user || !$refund || $refund['status'] !== 'pending') throw new \InvalidArgumentException('当前状态不允许驳回');
if (!$user || !$refund || $refund['status'] !== 'pending') throw new \InvalidArgumentException('当前状态不允许取消');
$balance = number_format(((int)round((float)$user['money'] * 100) + (int)round((float)$refund['amount'] * 100)) / 100, 2, '.', '');
$now = time();
Db::name('user')->where('id', (int)$user['id'])->update(['money'=>$balance,'updatetime'=>$now]);
Db::name('wallet_log')->insert(['user_type'=>'user','user_id'=>(int)$user['id'],'type'=>'recharge_refund_release','amount'=>$refund['amount'],'balance'=>$balance,'order_id'=>0,'remark'=>'充值退款驳回释放余额(退款单 '.$refund['refund_no'].')','createtime'=>$now]);
Db::name('wallet_log')->insert(['user_type'=>'user','user_id'=>(int)$user['id'],'type'=>'recharge_refund_release','amount'=>$refund['amount'],'balance'=>$balance,'order_id'=>0,'remark'=>'充值退款取消释放余额(退款单 '.$refund['refund_no'].')','createtime'=>$now]);
Db::name('recharge_refund')->where('id', (int)$refundId)->update(['status'=>'rejected','reviewer_id'=>(int)$reviewerId,'audit_note'=>$note,'updatetime'=>$now]);
Db::commit();
} catch (\Throwable $e) { Db::rollback(); throw $e; }

查看文件

@@ -67,8 +67,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'backend/admin-table-layout',
{field: 'operate', title: '操作', table: table, events: Table.api.events.operate, buttons: [
{
name: 'rechargerefund',
text: '申请退款',
title: '申请充值原路退款',
text: '退款',
title: '充值原路退款',
classname: 'btn btn-xs btn-warning btn-dialog',
url: 'recharge_refund/create',
visible: function (row) { return row.scene === 'recharge' && row.status === 'paid' && Number(row.amount) > Number(row.refund_amount); }

查看文件

@@ -0,0 +1,8 @@
const fs = require('fs');
const assert = require('assert');
const source = fs.readFileSync('server/application/common/library/PaymentService.php', 'utf8');
const quoteSection = source.slice(source.indexOf("// 与微信支付路径(confirmOrderPay scene=quote)口径保持一致:"), source.indexOf("} elseif ($scene === 'diff')", source.indexOf("// 与微信支付路径(confirmOrderPay scene=quote)口径保持一致:")));
assert(quoteSection.includes("self::sendNotify('master', $masterId, '师傅已被选定'"), '余额支付选定报价后应仅向师傅发送师傅视角通知');
assert(!quoteSection.includes('self::sendMasterAndUserMessage('), '师傅视角通知不应发给买家');
assert(quoteSection.includes("'order', $orderId"), '师傅通知应关联对应工单');
console.log('余额支付报价通知归属检查通过');

查看文件

@@ -20,14 +20,16 @@ namespace {
\think\Db::name('user')->where('id',1)->update(['money'=>'50.00']);
$id=\think\Db::name('pay_order')->insertGetId(['out_trade_no'=>'TEST'.bin2hex(random_bytes(10)), 'order_id'=>0,'order_no'=>'','user_id'=>1,'scene'=>'recharge','openid'=>'TEST','amount'=>'100.00','status'=>'paid']);
$r=\app\common\library\RechargeRefundService::create($id,'20.00','客服退款',1);
\app\common\library\RechargeRefundService::begin($r['id'],1,'同意');
try { \app\common\library\RechargeRefundService::send($r['id']); throw new \Exception('Expected timeout'); }
try { \app\common\library\RechargeRefundService::submit($r['id'],1); throw new \Exception('Expected timeout'); }
catch (\RuntimeException $e) { if ($e->getMessage() !== 'TIMEOUT') throw $e; }
$row=\think\Db::name('recharge_refund')->where('id',$r['id'])->find();
if ($row['status'] !== 'unknown' || (float)\think\Db::name('user')->where('id',1)->value('money') !== 30.0) throw new \Exception('Timeout failed to preserve reservation');
\app\common\library\RechargeRefundService::send($r['id']);
$row=\think\Db::name('recharge_refund')->where('id',$r['id'])->find();
if ($row['status'] !== 'success' || (float)\think\Db::name('pay_order')->where('id',$id)->value('refund_amount') !== 20.0) throw new \Exception('Retry failed');
$next = \app\common\library\RechargeRefundService::create($id,'10.00','客服退款',1);
$done = \app\common\library\RechargeRefundService::submit($next['id'],1);
if ($done['status'] !== 'success' || (float)\think\Db::name('pay_order')->where('id',$id)->value('refund_amount') !== 30.0) throw new \Exception('Direct submission failed');
echo "Recharge gateway timeout and retry passed\n";
} finally { \think\Db::rollback(); }
}

查看文件

@@ -378,7 +378,14 @@
:placeholder="order ? '留空申请全额退款 ¥' + order.pay_amount : '留空申请全额退款'"
/>
</view>
<text class="aftersale-tip">提交后进入平台仲裁队列(1~2 个工作日),仲裁通过将按微信原路退回您的支付账户</text>
<view class="aftersale-images">
<view v-for="(image, index) in complaintImages" :key="image.url" class="aftersale-image-item">
<image class="aftersale-image" :src="image.preview" mode="aspectFill" @tap="previewComplaintImage(index)" />
<view class="aftersale-image-remove" @tap="complaintImages.splice(index, 1)">移除</view>
</view>
<view v-if="complaintImages.length < 3" class="aftersale-image-add" @tap="chooseComplaintImages">{{ complaintUploading ? '上传中' : '添加图片' }}</view>
</view>
<text class="aftersale-tip">可上传最多 3 张图片。平台核实后将通知处理结果。</text>
<view class="modal-btns">
<view class="m-btn cancel clickable-hover" @tap="showComplaintModal = false">取消</view>
<view class="m-btn confirm clickable-hover" @tap="submitComplaint">提交申请</view>
@@ -446,6 +453,8 @@
const showComplaintModal = ref(false);
const complaintReason = ref('');
const complaintAmount = ref('');
const complaintImages = ref([]);
const complaintUploading = ref(false);
const submittingComplaint = ref(false);
const actionBusy = ref(false);
const activeVideoUrl = ref('');
@@ -556,11 +565,33 @@
function openComplaintModal() {
complaintReason.value = '';
complaintAmount.value = '';
complaintImages.value = [];
showComplaintModal.value = true;
}
function chooseComplaintImages() {
if (complaintUploading.value) return;
uni.chooseImage({ count: 3 - complaintImages.value.length, sizeType: ['compressed'], success: async (res) => {
complaintUploading.value = true;
try {
for (const path of res.tempFilePaths) {
const uploaded = await api.upload(path, 'other');
if (!uploaded || !uploaded.url) throw new Error('图片上传失败');
complaintImages.value.push({ url: uploaded.url, preview: uploaded.fullurl || path });
}
} catch (e) {
uni.showToast({ title: '图片上传失败,请重试', icon: 'none' });
} finally { complaintUploading.value = false; }
} });
}
function previewComplaintImage(index) {
const urls = complaintImages.value.map(item => item.preview);
uni.previewImage({ current: urls[index], urls });
}
async function submitComplaint() {
if (submittingComplaint.value) return;
if (submittingComplaint.value || complaintUploading.value) return;
if (!complaintReason.value.trim() || complaintReason.value.trim().length < 10) {
uni.showToast({ title: '请填写至少 10 个字的售后说明', icon: 'none' });
return;
@@ -576,6 +607,7 @@
order_id: orderId,
content: complaintReason.value.trim(),
refund_expect: complaintAmount.value !== '' ? amountNum : 0,
images: complaintImages.value.map(item => item.url).join(','),
});
showComplaintModal.value = false;
uni.showToast({ title: '售后申请已提交', icon: 'success' });
@@ -1637,6 +1669,11 @@
}
/* 售后退款申请表单 */
.aftersale-images { display: flex; flex-wrap: wrap; gap: 16rpx; margin-top: 20rpx; }
.aftersale-image-item { display: flex; flex-direction: column; align-items: center; }
.aftersale-image { width: 128rpx; height: 128rpx; border-radius: $yjyf-radius-md; }
.aftersale-image-remove { color: $yjyf-danger; font-size: 24rpx; padding: 8rpx; }
.aftersale-image-add { width: 128rpx; height: 128rpx; display: flex; align-items: center; justify-content: center; color: $yjyf-text-secondary; border: 1rpx solid $yjyf-border-color; border-radius: $yjyf-radius-md; font-size: 24rpx; }
.aftersale-amount-row {
display: flex;
align-items: center;

二进制文件未显示。

之后

宽度:  |  高度:  |  大小: 148 KiB

二进制文件未显示。

之后

宽度:  |  高度:  |  大小: 107 KiB