fix(admin): 下线退款重发功能并优化用户详情页布局
- 移除后台订单和支付流水的退款重发按钮及接口 - 新增用户详情页分区导航和资金流水筛选功能 - 升级账号安全页面为企业资质认证功能 - 新增企业资质相关测试用例和图标 - 升级版本号至1.0.96
这个提交包含在:
@@ -47,9 +47,11 @@ class Order extends Backend
|
||||
return $this->selectpage();
|
||||
}
|
||||
[$where, $sort, $order, $offset, $limit] = $this->buildparams();
|
||||
$scopeUserId = $this->request->get('scope_user_id/d', 0);
|
||||
$list = $this->model
|
||||
->with(['user', 'master'])
|
||||
->where($where)
|
||||
->where(function ($query) use ($scopeUserId) { if ($scopeUserId > 0) $query->where('order.user_id', $scopeUserId); })
|
||||
->order($sort, $order)
|
||||
->paginate($limit);
|
||||
|
||||
@@ -762,69 +764,7 @@ class Order extends Backend
|
||||
*/
|
||||
public function retryrefund($ids = null)
|
||||
{
|
||||
if (!$this->request->isPost()) {
|
||||
$this->error('非法请求方式');
|
||||
}
|
||||
$payOrderId = $this->request->post('pay_order_id/d', 0);
|
||||
if ($payOrderId <= 0) {
|
||||
$payOrderId = (int)$ids;
|
||||
}
|
||||
$po = Db::name('pay_order')->where('id', $payOrderId)->find();
|
||||
if (!$po) {
|
||||
$this->error('未找到指定的支付交易流水');
|
||||
}
|
||||
|
||||
$order = Db::name('order')->where('id', (int)$po['order_id'])->find();
|
||||
if (!$order) {
|
||||
$this->error('关联业务订单不存在');
|
||||
}
|
||||
if ((int)$order['settle_status'] === 1) {
|
||||
$this->error('该工单已完成向师傅结算分账,不允许再执行退款');
|
||||
}
|
||||
|
||||
$status = (string)($po['status'] ?? '');
|
||||
if ($status === 'refunding') {
|
||||
$this->error('该流水处于微信退款处理中,请先点击【同步微信状态】核实是否已到账,切勿盲目重退');
|
||||
}
|
||||
if (!in_array($status, ['refund_failed', 'paid'], true)) {
|
||||
$this->error('当前流水状态为「' . \app\common\library\PaymentService::payOrderStatusLabel($status) . '」,不可发起原路退款');
|
||||
}
|
||||
|
||||
$reason = trim($this->request->post('reason/s', ''));
|
||||
try {
|
||||
$after = \app\common\library\PaymentService::refundSinglePayOrder(
|
||||
$payOrderId,
|
||||
$reason !== '' ? $reason : '管理员后台手动发起/重试原路退款'
|
||||
);
|
||||
} catch (\Throwable $e) {
|
||||
$this->error('发起原路退款失败:' . $e->getMessage());
|
||||
}
|
||||
|
||||
// 若主工单已处于取消状态且本笔退款受理/到账成功,同步汇总真实退款金额
|
||||
if ((int)$order['status'] === 9 && in_array($after['status'] ?? '', ['refunding', 'refunded'], true)) {
|
||||
$allPaid = Db::name('pay_order')
|
||||
->where('order_id', (int)$order['id'])
|
||||
->whereIn('status', ['paid', 'refunding', 'refunded', 'refund_failed'])
|
||||
->select();
|
||||
$hasUnsettledRefund = false;
|
||||
$sumRefund = 0.00;
|
||||
foreach ($allPaid as $item) {
|
||||
if (in_array($item['status'], ['refunding', 'refunded'], true)) {
|
||||
$sumRefund = round($sumRefund + (float)($item['refund_amount'] ?: $item['amount']), 2);
|
||||
} else {
|
||||
$hasUnsettledRefund = true;
|
||||
}
|
||||
}
|
||||
Db::name('order')->where('id', (int)$order['id'])->update([
|
||||
'pay_status' => $hasUnsettledRefund ? (int)$order['pay_status'] : 2,
|
||||
'refund_amount' => $sumRefund,
|
||||
'updatetime' => time(),
|
||||
]);
|
||||
}
|
||||
|
||||
$statusLabel = \app\common\library\PaymentService::payOrderStatusLabel($after['status'] ?? '');
|
||||
$refundLabel = \app\common\library\PaymentService::refundStatusLabel($after['refund_status'] ?? 'none');
|
||||
$this->success('微信原路退款请求已提交,当前状态:' . $statusLabel . '(' . $refundLabel . ')');
|
||||
$this->error('退款重发暂不可用:请先核对原退款单及金额,再通过订单售后流程处理');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -11,7 +11,7 @@ use think\exception\PDOException;
|
||||
* 微信支付退款台账
|
||||
*
|
||||
* 展示全站微信支付流水(fa_pay_order)的支付/退款状态、网关回执与异常诊断,
|
||||
* 提供人工同步微信退款状态与重发原路退款入口(复用 PaymentService 防资损校验)。
|
||||
* 提供人工同步微信退款状态入口。
|
||||
*
|
||||
* @icon fa fa-undo
|
||||
*/
|
||||
@@ -109,25 +109,7 @@ class PayOrder extends Backend
|
||||
*/
|
||||
public function retryrefund($ids = null)
|
||||
{
|
||||
$id = (int)$ids;
|
||||
$po = Db::name('pay_order')->where('id', $id)->find();
|
||||
if (!$po) {
|
||||
$this->error(__('No Results were found'));
|
||||
}
|
||||
$left = round((float)$po['amount'] - (float)$po['refund_amount'], 2);
|
||||
if ($left <= 0) {
|
||||
$this->error('该流水可退余额为 0,无需再次退款');
|
||||
}
|
||||
try {
|
||||
$after = PaymentService::refundSinglePayOrder($id, '平台人工重发原路退款(退款台账)');
|
||||
PaymentService::syncCancelledOrderRefund((int)$po['order_id']);
|
||||
} catch (\Throwable $e) {
|
||||
$this->error('重发退款失败:' . $e->getMessage());
|
||||
return;
|
||||
}
|
||||
$statusLabel = PaymentService::payOrderStatusLabel($after['status'] ?? '');
|
||||
$refundLabel = PaymentService::refundStatusLabel($after['refund_status'] ?? 'none');
|
||||
$this->success('退款请求已提交:' . $statusLabel . '(' . $refundLabel . ',累计已退 ¥' . $after['refund_amount'] . ')');
|
||||
$this->error('退款重发暂不可用:请先核对原退款单及金额,再通过订单售后流程处理');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -175,7 +157,7 @@ class PayOrder extends Backend
|
||||
|
||||
public function edit($ids = null)
|
||||
{
|
||||
$this->error('支付流水不可手工编辑,如需退款请使用行内"同步/重发退款"操作');
|
||||
$this->error('支付流水不可手工编辑,如需退款请使用订单售后流程');
|
||||
}
|
||||
|
||||
public function del($ids = null)
|
||||
|
||||
@@ -34,9 +34,13 @@ class WalletLog extends Backend
|
||||
public function index()
|
||||
{
|
||||
$this->request->filter(['strip_tags', 'trim']);
|
||||
$scopeUserId = $this->request->get('scope_user_id/d', 0);
|
||||
if (false === $this->request->isAjax()) {
|
||||
$totalIncome = round((float)Db::name('wallet_log')->where('amount', '>', 0)->sum('amount'), 2);
|
||||
$totalOutflow = round(abs((float)Db::name('wallet_log')->where('amount', '<', 0)->sum('amount')), 2);
|
||||
$scope = function ($query) use ($scopeUserId) {
|
||||
if ($scopeUserId > 0) $query->where('user_type', 'user')->where('user_id', $scopeUserId);
|
||||
};
|
||||
$totalIncome = round((float)Db::name('wallet_log')->where($scope)->where('amount', '>', 0)->sum('amount'), 2);
|
||||
$totalOutflow = round(abs((float)Db::name('wallet_log')->where($scope)->where('amount', '<', 0)->sum('amount')), 2);
|
||||
$this->view->assign([
|
||||
'totalIncome' => $totalIncome,
|
||||
'totalOutflow' => $totalOutflow,
|
||||
@@ -49,6 +53,7 @@ class WalletLog extends Backend
|
||||
[$where, $sort, $order, $offset, $limit] = $this->buildparams();
|
||||
$list = $this->model
|
||||
->where($where)
|
||||
->where(function ($query) use ($scopeUserId) { if ($scopeUserId > 0) $query->where('user_type', 'user')->where('user_id', $scopeUserId); })
|
||||
->order($sort, $order)
|
||||
->paginate($limit);
|
||||
|
||||
|
||||
@@ -546,11 +546,6 @@
|
||||
<i class="fa fa-refresh"></i> 同步微信状态
|
||||
</button>
|
||||
{/if}
|
||||
{if $po.status == 'refund_failed' || ($po.status == 'paid' && $row.status == 9 && $row.settle_status != 1)}
|
||||
<button type="button" class="btn btn-xs btn-danger js-retry-refund" data-id="{$po.id}" data-outno="{$po.out_trade_no|htmlentities}">
|
||||
<i class="fa fa-undo"></i> 重试原路退款
|
||||
</button>
|
||||
{/if}
|
||||
{if $po.status == 'refunded' || $po.status == 'closed' || ($po.status == 'paid' && ($row.status != 9 || $row.settle_status == 1))}
|
||||
<span class="text-muted" style="font-size:11px;">无需人工处置</span>
|
||||
{/if}
|
||||
|
||||
@@ -434,7 +434,7 @@
|
||||
{if strpos($row.fail_code, 'CURL_60') !== false}
|
||||
系统支付安全配置异常,请联系技术人员处理。
|
||||
{elseif $row.status == 'refund_failed'}
|
||||
退款未能成功,请确认微信商户号可用余额充足后,点击下方【重发原路退款】重新发起。
|
||||
退款未能成功,请核对原退款单状态和金额后联系财务处理。
|
||||
{else /}
|
||||
可点击下方【同步微信状态】获取最新结果,或登录微信商户平台核对。
|
||||
{/if}
|
||||
@@ -646,7 +646,7 @@
|
||||
<div class="po-footer-bar">
|
||||
<div class="po-footer-tip">
|
||||
<i class="fa fa-info-circle text-primary"></i>
|
||||
<span>系统会自动核对微信已退金额,不会重复退款。</span>
|
||||
<span>如退款异常,请先核对原退款单和金额,再通过订单售后流程处理。</span>
|
||||
</div>
|
||||
<div class="po-footer-actions">
|
||||
{if $row.scene != 'recharge' && in_array($row.status, ['paid', 'refunding', 'refunded', 'refund_failed'])}
|
||||
@@ -654,11 +654,6 @@
|
||||
<i class="fa fa-refresh"></i> 同步微信状态
|
||||
</button>
|
||||
{/if}
|
||||
{if $row.scene != 'recharge' && ($row.status == 'refund_failed' || ($row.status == 'paid' && $refundableAmount > 0)) && $refundableAmount > 0}
|
||||
<button type="button" class="btn btn-danger js-action-retry" data-id="{$row.id}">
|
||||
<i class="fa fa-undo"></i> 重发原路退款 (¥{$refundableAmount})
|
||||
</button>
|
||||
{/if}
|
||||
<button type="button" class="btn btn-default js-modal-close">
|
||||
<i class="fa fa-times"></i> 关闭
|
||||
</button>
|
||||
@@ -760,34 +755,6 @@
|
||||
return;
|
||||
}
|
||||
|
||||
var retryBtn = e.target.closest ? e.target.closest('.js-action-retry') : null;
|
||||
if (retryBtn) {
|
||||
e.preventDefault();
|
||||
var rid = retryBtn.getAttribute('data-id');
|
||||
var FastApi2 = window.Fast || (parent && parent.Fast);
|
||||
var LayerApi = window.Layer || (parent && parent.Layer);
|
||||
if (!FastApi2 || !LayerApi) return;
|
||||
LayerApi.confirm('确定对该笔流水重新发起微信原路退款吗?系统将自动退剩余可退金额。', {
|
||||
title: '重发原路退款确认',
|
||||
icon: 3
|
||||
}, function (index) {
|
||||
LayerApi.close(index);
|
||||
retryBtn.disabled = true;
|
||||
FastApi2.api.ajax({ url: 'pay_order/retryrefund/ids/' + rid, data: {} }, function (data, ret) {
|
||||
retryBtn.disabled = false;
|
||||
notifySuccess((ret && ret.msg) || '退款请求已发起');
|
||||
if (parent && parent.$ && parent.$('#table').length) {
|
||||
parent.$('#table').bootstrapTable('refresh');
|
||||
}
|
||||
setTimeout(function () { window.location.reload(); }, 800);
|
||||
return false;
|
||||
}, function (data, ret) {
|
||||
retryBtn.disabled = false;
|
||||
notifyError((ret && ret.msg) || '重退失败');
|
||||
return false;
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
|
||||
@@ -201,7 +201,6 @@
|
||||
<div id="toolbar" class="toolbar">
|
||||
<a href="javascript:;" class="btn btn-primary btn-refresh" title="刷新"><i class="fa fa-refresh"></i> 刷新</a>
|
||||
<button type="button" id="js-sync-pay-order" class="btn btn-info btn-disabled disabled"><i class="fa fa-exchange"></i> 批量同步微信状态</button>
|
||||
{if !$rechargeOnly}<button type="button" id="js-retry-refund" class="btn btn-danger btn-disabled disabled"><i class="fa fa-undo"></i> 批量重发原路退款</button>{/if}
|
||||
</div>
|
||||
|
||||
<!-- 表格 -->
|
||||
|
||||
@@ -25,6 +25,9 @@
|
||||
.ud-card-hd { padding: 10px 16px; background: #f8fafc; border-bottom: 1px solid #e2e8f0; font-size: 13.5px; font-weight: 700; color: #1e293b; display: flex; align-items: center; gap: 8px; }
|
||||
.ud-card-hd i { color: #ea580c; }
|
||||
.ud-card-bd { padding: 14px 16px; }
|
||||
.ud-section-nav { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
|
||||
.ud-section-nav a { padding: 5px 10px; border: 1px solid #e2e8f0; border-radius: 5px; color: #475569; background: #fff; }
|
||||
.ud-stat small { display: block; max-width: 180px; color: #64748b; font-size: 11px; font-weight: normal; }
|
||||
</style>
|
||||
|
||||
<div class="ud-wrap">
|
||||
@@ -61,7 +64,8 @@
|
||||
</div>
|
||||
<div class="ud-stat">
|
||||
<b>¥{$totalSpent}</b>
|
||||
<span>累计实付</span>
|
||||
<span>已支付订单金额(退款前)</span>
|
||||
<small>不含已取消订单,未扣除退款</small>
|
||||
</div>
|
||||
<div class="ud-stat">
|
||||
<b>¥{$row.money}</b>
|
||||
@@ -70,17 +74,25 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{if !empty($enterpriseCert)}
|
||||
<div class="ud-card">
|
||||
<nav class="ud-section-nav" aria-label="详情分区">
|
||||
<a href="#enterprise-cert">企业资质</a><a href="#user-addresses">地址</a><a href="#user-coupons">优惠券</a><a href="#user-wallet">资金流水</a><a href="#user-orders">订单</a>
|
||||
</nav>
|
||||
|
||||
<div class="ud-card" id="enterprise-cert">
|
||||
<div class="ud-card-hd"><i class="fa fa-certificate"></i> 企业资质认证</div>
|
||||
<div class="ud-card-bd">
|
||||
{if !empty($enterpriseCert)}
|
||||
<table class="table table-bordered table-condensed" style="margin-bottom:0;"><tbody>
|
||||
<tr><th>企业名称</th><td>{$enterpriseCert.company_name|htmlentities}</td><th>营业执照号码</th><td>{$enterpriseCert.license_no|htmlentities}</td></tr>
|
||||
<tr><th>法人姓名</th><td>{$enterpriseCert.legal_person|default='未填写'|htmlentities}</td><th>审核结果</th><td>{if $enterpriseCert.verify_status=='pass'}已通过{elseif $enterpriseCert.verify_status=='pending'/}待审核{else/}已驳回:{$enterpriseCert.audit_msg|htmlentities}{/if}</td></tr>
|
||||
<tr><th>提交时间</th><td>{if $enterpriseCert.createtime}{$enterpriseCert.createtime|datetime}{else/}未记录{/if}</td><th>营业执照图片</th><td>{if !empty($enterpriseCert.license_image)}<a class="js-image-preview-link" href="{:htmlentities(cdnurl($enterpriseCert.license_image, true))}" target="_blank" rel="noopener noreferrer">查看营业执照</a>{else/}未提供{/if}</td></tr>
|
||||
</tbody></table>
|
||||
{else /}
|
||||
<span class="text-muted">未提交企业资质</span>
|
||||
{/if}
|
||||
{if $auth->check('merchant/certificates')}<p style="margin:10px 0 0;"><a href="{:url('merchant/certificates')}" class="addtabsit" title="企业资质审核">进入企业资质审核</a></p>{/if}
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{if !empty($merchantProfile) && !empty($merchantProfile.id) && $auth->check('merchant/detail')}
|
||||
<div class="ud-card">
|
||||
@@ -109,8 +121,8 @@
|
||||
<div class="row">
|
||||
<!-- 常用上门服务地址簿 -->
|
||||
<div class="col-xs-12 col-sm-6">
|
||||
<div class="ud-card">
|
||||
<div class="ud-card-hd"><i class="fa fa-map-marker"></i> 常用上门服务地址簿 ({:count($addressList)})</div>
|
||||
<div class="ud-card" id="user-addresses">
|
||||
<div class="ud-card-hd"><i class="fa fa-map-marker"></i> 上门服务地址(最多显示 6 条)</div>
|
||||
<div class="ud-card-bd">
|
||||
{if !empty($addressList)}
|
||||
<table class="table table-bordered table-condensed" style="font-size:12px; margin-bottom:0;">
|
||||
@@ -138,8 +150,8 @@
|
||||
|
||||
<!-- 优惠券领取与核销 -->
|
||||
<div class="col-xs-12 col-sm-6">
|
||||
<div class="ud-card">
|
||||
<div class="ud-card-hd"><i class="fa fa-ticket"></i> 优惠券领用与核销记录 ({:count($coupons)})</div>
|
||||
<div class="ud-card" id="user-coupons">
|
||||
<div class="ud-card-hd"><i class="fa fa-ticket"></i> 最近优惠券记录(最多显示 8 条)</div>
|
||||
<div class="ud-card-bd">
|
||||
{if !empty($coupons)}
|
||||
<table class="table table-bordered table-condensed" style="font-size:12px; margin-bottom:0;">
|
||||
@@ -175,9 +187,9 @@
|
||||
</div>
|
||||
|
||||
<!-- 近期资金收支流水 -->
|
||||
<div class="ud-card" style="margin-bottom:16px;">
|
||||
<div class="ud-card" id="user-wallet" style="margin-bottom:16px;">
|
||||
<div class="ud-card-hd" style="display:flex;align-items:center;justify-content:space-between;">
|
||||
<span><i class="fa fa-money"></i> 账户收支明细 ({:count($recentWalletLogs)})</span>
|
||||
<span><i class="fa fa-money"></i> 账户收支明细(最近 6 条) {if $auth->check('wallet_log/index')}<a href="{:url('wallet_log/index', ['scope_user_id' => $row.id])}" class="addtabsit" title="用户全部资金流水">查看全部</a>{/if}</span>
|
||||
<span class="text-muted" style="font-weight:normal;font-size:12px;">实时账户余额:<strong style="color:#ea580c;font-size:14px;">¥{$row.money}</strong></span>
|
||||
</div>
|
||||
<div class="ud-card-bd">
|
||||
@@ -189,7 +201,7 @@
|
||||
<tbody>
|
||||
{foreach name="recentWalletLogs" item="wl"}
|
||||
<tr>
|
||||
<td><code>#WL{$wl.id}</code></td>
|
||||
<td>{if $auth->check('wallet_log/detail')}<a href="{:url('wallet_log/detail', ['ids' => $wl.id])}" class="dialogit" data-title="资金流水详情">#WL{$wl.id}</a>{else/}<code>#WL{$wl.id}</code>{/if}</td>
|
||||
<td>
|
||||
{if $wl.type=='recharge'}<span class="label label-success">账户充值</span>
|
||||
{elseif $wl.type=='consume'/}<span class="label label-warning">余额消费</span>
|
||||
@@ -214,8 +226,8 @@
|
||||
</div>
|
||||
|
||||
<!-- 近期服务订单记录 -->
|
||||
<div class="ud-card" style="margin-bottom:0;">
|
||||
<div class="ud-card-hd"><i class="fa fa-list-alt"></i> 近期预约下单记录 ({:count($recentOrders)})</div>
|
||||
<div class="ud-card" id="user-orders" style="margin-bottom:0;">
|
||||
<div class="ud-card-hd"><i class="fa fa-list-alt"></i> 近期预约下单记录(最多显示 8 条) {if $auth->check('order/index')}<a href="{:url('order/index', ['scope_user_id' => $row.id])}" class="addtabsit" title="用户全部订单">查看全部</a>{/if}</div>
|
||||
<div class="ud-card-bd">
|
||||
{if !empty($recentOrders)}
|
||||
<table class="table table-bordered table-hover table-condensed" style="font-size:12px; margin-bottom:0;">
|
||||
@@ -225,7 +237,7 @@
|
||||
<tbody>
|
||||
{foreach name="recentOrders" item="o"}
|
||||
<tr>
|
||||
<td><code>{$o.order_no|htmlentities}</code></td>
|
||||
<td>{if $auth->check('order/detail')}<a href="{:url('order/detail', ['ids' => $o.id])}" class="dialogit" data-title="订单详情">{$o.order_no|htmlentities}</a>{else/}<code>{$o.order_no|htmlentities}</code>{/if}</td>
|
||||
<td><strong>{$o.service_name|htmlentities}</strong></td>
|
||||
<td>{$o.province|htmlentities}{$o.city|htmlentities}{$o.district|htmlentities}{$o.address|htmlentities}</td>
|
||||
<td>{$o.master_name|default='待指派'|htmlentities}</td>
|
||||
|
||||
@@ -1408,6 +1408,11 @@ class Master extends Base
|
||||
throw new \InvalidArgumentException('可提现余额不足');
|
||||
}
|
||||
|
||||
// 同一师傅的申请在行锁内串行检查每日次数和金额。
|
||||
$validated = FinanceConfigService::validateWithdrawRequest($lockedMaster, $amount, $channel, $account);
|
||||
$wdCfg = $validated['cfg'];
|
||||
$fee = $validated['fee'];
|
||||
$arrive = $validated['arrive_amount'];
|
||||
$newMoney = round((float)$lockedMaster['money'] - $amount, 2);
|
||||
$newFrozen = round((float)$lockedMaster['frozen_money'] + $amount, 2);
|
||||
|
||||
|
||||
@@ -1476,6 +1476,18 @@ class PaymentService
|
||||
return $wd;
|
||||
}
|
||||
|
||||
if ((string)$lockedWd['out_bill_no'] !== $outBillNo) {
|
||||
throw new \RuntimeException('转账单号已变更,请重新查询');
|
||||
}
|
||||
if (in_array($lockedWd['status'], ['done', 'reject'], true)) {
|
||||
$compatible = ($lockedWd['status'] === 'done' && $wxState === 'SUCCESS')
|
||||
|| ($lockedWd['status'] === 'reject' && in_array($wxState, ['FAIL', 'CANCELLED'], true));
|
||||
if (!$compatible && in_array($wxState, ['SUCCESS', 'FAIL', 'CANCELLED'], true)) {
|
||||
throw new \RuntimeException('微信转账终态与本地记录不一致,请人工核查');
|
||||
}
|
||||
Db::commit();
|
||||
return $lockedWd;
|
||||
}
|
||||
$masterId = (int)$lockedWd['master_id'];
|
||||
$master = Db::name('master')->where('id', $masterId)->lock(true)->find();
|
||||
$amount = round((float)$lockedWd['amount'], 2);
|
||||
@@ -2320,14 +2332,18 @@ class PaymentService
|
||||
throw new \InvalidArgumentException('充值支付单不存在');
|
||||
}
|
||||
|
||||
if ($payOrder['scene'] !== 'recharge') {
|
||||
throw new \InvalidArgumentException('该支付单不是充值流水');
|
||||
}
|
||||
if ($payOrder['status'] === 'paid') {
|
||||
return [
|
||||
'paid' => true,
|
||||
'already_processed' => true,
|
||||
'amount' => (float)$payOrder['amount'],
|
||||
'user_id' => (int)$payOrder['user_id'],
|
||||
'paid' => true, 'already_processed' => true,
|
||||
'amount' => (float)$payOrder['amount'], 'user_id' => (int)$payOrder['user_id'],
|
||||
];
|
||||
}
|
||||
if ($payOrder['status'] !== 'pending') {
|
||||
throw new \InvalidArgumentException('充值单当前状态不允许再次入账');
|
||||
}
|
||||
|
||||
$wxSvc = new WxPayV3Service();
|
||||
if ($wxTxData === null) {
|
||||
@@ -2352,10 +2368,16 @@ class PaymentService
|
||||
Db::startTrans();
|
||||
try {
|
||||
$lockedPay = Db::name('pay_order')->where('id', (int)$payOrder['id'])->lock(true)->find();
|
||||
if (!$lockedPay || $lockedPay['scene'] !== 'recharge') {
|
||||
throw new \InvalidArgumentException('充值流水不存在或场景不正确');
|
||||
}
|
||||
if ($lockedPay['status'] === 'paid') {
|
||||
Db::commit();
|
||||
return ['paid' => true, 'already_processed' => true, 'amount' => (float)$lockedPay['amount']];
|
||||
}
|
||||
if ($lockedPay['status'] !== 'pending') {
|
||||
throw new \InvalidArgumentException('充值单当前状态不允许再次入账');
|
||||
}
|
||||
|
||||
$uid = (int)$lockedPay['user_id'];
|
||||
$lockedUser = Db::name('user')->where('id', $uid)->lock(true)->find();
|
||||
@@ -2492,6 +2514,29 @@ class PaymentService
|
||||
throw new \RuntimeException('订单不存在');
|
||||
}
|
||||
|
||||
// 事务外的订单快照可能已经过期,持锁后必须重新验证所有影响扣款的状态和金额。
|
||||
if ($scene === 'order' && ((int)$lockedOrder['pay_status'] !== 0
|
||||
|| (int)$lockedOrder['status'] !== OrderStatus::PENDING_PAY
|
||||
|| round((float)$lockedOrder['pay_amount'], 2) !== $payAmount)) {
|
||||
throw new \InvalidArgumentException('订单状态或金额已变更,请刷新后重试');
|
||||
}
|
||||
if ($scene === 'diff' && ((int)$lockedOrder['diff_status'] !== 1
|
||||
|| round((float)$lockedOrder['diff_amount'], 2) !== $payAmount)) {
|
||||
throw new \InvalidArgumentException('增项状态或金额已变更,请刷新后重试');
|
||||
}
|
||||
if ($scene === 'quote') {
|
||||
$lockedQuote = Db::name('order_quote')->where('id', $quoteId)->where('order_id', $orderId)->lock(true)->find();
|
||||
if ((int)$lockedOrder['status'] !== OrderStatus::QUOTING || (int)$lockedOrder['master_id'] > 0
|
||||
|| !$lockedQuote || $lockedQuote['status'] !== 'wait'
|
||||
|| (int)$lockedQuote['master_id'] !== $masterId
|
||||
|| round((float)$lockedQuote['amount'], 2) !== round((float)$quote['amount'], 2)
|
||||
|| round((float)$lockedOrder['discount_amount'], 2) !== round((float)$order['discount_amount'], 2)
|
||||
|| (int)$lockedOrder['pay_status'] !== (int)$order['pay_status']
|
||||
|| round((float)$lockedOrder['pay_amount'], 2) !== round((float)$order['pay_amount'], 2)) {
|
||||
throw new \InvalidArgumentException('报价或订单状态已变更,请刷新后重试');
|
||||
}
|
||||
$quote = $lockedQuote;
|
||||
}
|
||||
$newBalance = round($userMoney - $payAmount, 2);
|
||||
|
||||
// 1. 扣减用户余额
|
||||
|
||||
@@ -4,7 +4,7 @@ return array (
|
||||
'name' => '优匠优服',
|
||||
'beian' => '',
|
||||
'cdnurl' => '',
|
||||
'version' => '1.0.95',
|
||||
'version' => '1.0.96',
|
||||
'timezone' => 'Asia/Shanghai',
|
||||
'forbiddenip' => '',
|
||||
'languages' =>
|
||||
|
||||
@@ -214,29 +214,6 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'backend/admin-table-layout',
|
||||
$btn.prop('disabled', false);
|
||||
});
|
||||
});
|
||||
$(document).off('click', '.js-retry-refund').on('click', '.js-retry-refund', function () {
|
||||
var $btn = $(this);
|
||||
var id = $btn.data('id');
|
||||
var outNo = $btn.data('outno') || '';
|
||||
if (!id) return;
|
||||
Layer.confirm('确认向微信支付发起(或重试)原路退款?<br><small class="text-muted">商户单号:' + escapeHtml(outNo) + '</small>', {
|
||||
title: '确认原路退款',
|
||||
icon: 3
|
||||
}, function (idx) {
|
||||
Layer.close(idx);
|
||||
$btn.prop('disabled', true);
|
||||
Fast.api.ajax({
|
||||
url: 'order/retryrefund',
|
||||
type: 'post',
|
||||
data: { pay_order_id: id }
|
||||
}, function () {
|
||||
location.reload();
|
||||
return false;
|
||||
}, function () {
|
||||
$btn.prop('disabled', false);
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
api: {
|
||||
bindevent: function () {
|
||||
|
||||
@@ -101,27 +101,6 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'backend/admin-table-layout',
|
||||
Layer.alert(ret.msg);
|
||||
return false;
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'retryrefund',
|
||||
text: '重发退款',
|
||||
title: '重新发起微信原路退款(退该笔剩余可退金额)',
|
||||
icon: 'fa fa-undo',
|
||||
classname: 'btn btn-xs btn-danger btn-ajax btn-retry-po',
|
||||
url: 'pay_order/retryrefund',
|
||||
confirm: '确定对该笔流水重新发起微信原路退款吗?系统将自动退剩余可退金额并核实旧退款单状态。',
|
||||
visible: function (row) {
|
||||
var left = Number(row.amount) - Number(row.refund_amount);
|
||||
return row.scene !== 'recharge' && (row.status === 'refund_failed' || (row.status === 'paid' && left > 0)) && left > 0;
|
||||
},
|
||||
success: function (data, ret) {
|
||||
table.bootstrapTable('refresh');
|
||||
return false;
|
||||
},
|
||||
error: function (data, ret) {
|
||||
Layer.alert(ret.msg);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
], formatter: Table.api.formatter.buttons}
|
||||
],
|
||||
@@ -184,35 +163,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'backend/admin-table-layout',
|
||||
});
|
||||
});
|
||||
|
||||
// 工具栏批量操作:重发原路退款
|
||||
$(document).on('click', '#js-retry-refund', function () {
|
||||
var ids = Table.api.selectedids(table);
|
||||
if (!ids.length) return;
|
||||
Layer.confirm('确定对已选 ' + ids.length + ' 笔流水重发微信原路退款吗?系统将自动退每笔流水的剩余可退金额。', function (index) {
|
||||
Layer.close(index);
|
||||
var ok = 0, failMsg = [];
|
||||
$.each(ids, function (i, id) {
|
||||
Fast.api.ajax({
|
||||
url: 'pay_order/retryrefund/ids/' + id,
|
||||
data: {},
|
||||
}, function (data, ret) {
|
||||
ok++;
|
||||
if (ok + failMsg.length === ids.length) {
|
||||
Toastr.success('重退完成:成功 ' + ok + ' 笔' + (failMsg.length ? ',失败:' + failMsg.join('; ') : ''));
|
||||
table.bootstrapTable('refresh');
|
||||
}
|
||||
return true;
|
||||
}, function (data, ret) {
|
||||
failMsg.push('#' + id + ' ' + ret.msg);
|
||||
if (failMsg.length + ok === ids.length) {
|
||||
Toastr.warning('重退完成:成功 ' + ok + ' 笔,失败 ' + failMsg.length + ' 笔(' + failMsg.join('; ') + ')');
|
||||
table.bootstrapTable('refresh');
|
||||
}
|
||||
return true;
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
},
|
||||
recharges: function () {
|
||||
Controller.index();
|
||||
|
||||
@@ -33,6 +33,15 @@ function request(route, data, token, html) { return new Promise((resolve, reject
|
||||
response = await request('/s.php/index/login', null, null, true);
|
||||
let csrf = (response.text.match(/name="__token__"[^>]*value="([^"]+)"/) || [])[1]; assert.ok(csrf, 'admin login CSRF');
|
||||
result = JSON.parse((await request('/s.php/index/login', {username: process.env.TEST_ADMIN_USER || 'admin', password: process.env.TEST_ADMIN_PASSWORD, __token__: csrf})).text); assert.strictEqual(result.code, 1, result.msg);
|
||||
response = await request('/s.php/user/user/detail/ids/' + uid, null, null, true);
|
||||
assert.strictEqual(response.status, 200); assert.ok(response.text.includes('营业执照图片')); assert.ok(response.text.includes(image));
|
||||
assert.ok(response.text.includes('提交时间')); assert.ok(response.text.includes('退款前')); assert.ok(response.text.includes('最近 6 条'));
|
||||
response = await request('/s.php/order/index?scope_user_id=' + uid + '&limit=1');
|
||||
result = JSON.parse(response.text); assert.strictEqual(Number(result.total), Number(sql(`SELECT COUNT(*) FROM fa_order WHERE user_id=${uid}`)), 'orders scoped to user');
|
||||
response = await request('/s.php/wallet_log/index?scope_user_id=' + uid + '&limit=1');
|
||||
result = JSON.parse(response.text); assert.strictEqual(Number(result.total), Number(sql(`SELECT COUNT(*) FROM fa_wallet_log WHERE user_type='user' AND user_id=${uid}`)), 'wallet logs scoped to user');
|
||||
response = await request('/s.php/wallet_log/index?scope_user_id=' + uid, null, null, true);
|
||||
assert.strictEqual(response.status, 200); assert.ok(response.text.includes('table'), 'scoped wallet page renders');
|
||||
// Unselected accounts have a default user_type but must not appear under personal users.
|
||||
sql(`UPDATE fa_user SET identity_selected=0 WHERE id=${uid}`);
|
||||
response = await request('/s.php/user/user/index?filter=' + encodeURIComponent(JSON.stringify({user_type:'personal'})) + '&op=' + encodeURIComponent(JSON.stringify({user_type:'='})) + '&limit=1000');
|
||||
|
||||
46
tests/fund_safety_regression.php
普通文件
46
tests/fund_safety_regression.php
普通文件
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
define('APP_PATH', __DIR__ . '/../server/application/');
|
||||
require __DIR__ . '/../server/thinkphp/base.php';
|
||||
\think\App::initCommon();
|
||||
use app\common\library\PaymentService;
|
||||
use think\Db;
|
||||
$failures = [];
|
||||
function check($name, callable $test) { global $failures; try { $test(); echo "PASS $name\n"; } catch (\Throwable $e) { $failures[] = "$name: " . $e->getMessage(); echo "FAIL $name: " . $e->getMessage() . "\n"; } }
|
||||
Db::startTrans();
|
||||
try {
|
||||
$uid = (int)Db::name('user')->value('id');
|
||||
$user = Db::name('user')->where('id',$uid)->find();
|
||||
$base = Db::name('order')->find();
|
||||
if (!$user || !$base) throw new RuntimeException('Missing local test fixtures');
|
||||
$tag = bin2hex(random_bytes(6));
|
||||
$payId = Db::name('pay_order')->insertGetId(['out_trade_no'=>'TREC'.$tag,'order_id'=>0,'order_no'=>'','user_id'=>$uid,'scene'=>'recharge','openid'=>'TEST','amount'=>'1.00','status'=>'refunded','refund_amount'=>'1.00','refund_status'=>'success']);
|
||||
$tx = ['trade_state'=>'SUCCESS','amount'=>['total'=>100],'transaction_id'=>'TEST'];
|
||||
check('refunded recharge cannot be credited again', function() use($uid,$payId,$tag,$tx) {
|
||||
$before=Db::name('user')->where('id',$uid)->value('money');
|
||||
try { PaymentService::confirmRechargePay('TREC'.$tag,$tx); } catch (\Throwable $e) {}
|
||||
$pay=Db::name('pay_order')->where('id',$payId)->find(); $after=Db::name('user')->where('id',$uid)->value('money');
|
||||
if ($pay['status'] !== 'refunded' || (float)$before !== (float)$after) throw new RuntimeException('refunded recharge credited again');
|
||||
});
|
||||
$wrongId=Db::name('pay_order')->insertGetId(['out_trade_no'=>'TORD'.$tag,'order_id'=>0,'order_no'=>'','user_id'=>$uid,'scene'=>'order','openid'=>'TEST','amount'=>'1.00','status'=>'pending']);
|
||||
check('order payment cannot be confirmed as recharge', function() use($wrongId,$tag,$tx) {
|
||||
try { PaymentService::confirmRechargePay('TORD'.$tag,$tx); } catch (\Throwable $e) {}
|
||||
if (Db::name('pay_order')->where('id',$wrongId)->value('status') !== 'pending') throw new RuntimeException('order treated as recharge');
|
||||
});
|
||||
check('stale order snapshot cannot charge twice', function() use($base,$uid,$tag) {
|
||||
unset($base['id']); $base['order_no']='TST'.$tag; $base['user_id']=$uid; $base['pay_amount']='0.01'; $base['pay_status']=0; $base['status']=0;
|
||||
$id=Db::name('order')->insertGetId($base); $stale=Db::name('order')->where('id',$id)->find();
|
||||
Db::name('order')->where('id',$id)->update(['pay_status'=>1]); Db::name('user')->where('id',$uid)->update(['money'=>'10.00']);
|
||||
try { PaymentService::payOrderByBalance($stale,$uid,'order'); } catch (\Throwable $e) {}
|
||||
if ((float)Db::name('user')->where('id',$uid)->value('money') !== 10.0) throw new RuntimeException('stale snapshot charged');
|
||||
});
|
||||
$master=Db::name('master')->find();
|
||||
if ($master) {
|
||||
$wdId=Db::name('withdraw')->insertGetId(['master_id'=>$master['id'],'amount'=>'1.00','fee'=>'0.00','arrive_amount'=>'1.00','channel'=>'wechat','account'=>'test','status'=>'done','out_bill_no'=>'TEST'.$tag,'transfer_state'=>'SUCCESS','createtime'=>time(),'updatetime'=>time()]);
|
||||
check('late transfer processing does not reopen terminal withdrawal', function() use($wdId) {
|
||||
PaymentService::syncWithdrawTransfer($wdId,['state'=>'PROCESSING']);
|
||||
if (Db::name('withdraw')->where('id',$wdId)->value('status') !== 'done') throw new RuntimeException('terminal withdrawal reopened');
|
||||
});
|
||||
}
|
||||
} finally { Db::rollback(); }
|
||||
if ($failures) exit(1);
|
||||
|
||||
@@ -227,10 +227,6 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="menu-item clickable-hover" @tap="go('/pages/mine/security')">
|
||||
<view class="mi-left"><image class="mi-ico" src="/static/icons/master/menu-account-security.svg" mode="aspectFit" /><text class="mi-title">账号安全</text></view>
|
||||
<view class="mi-right"><image class="mi-arrow" src="/static/icons/arrow-right.svg" mode="aspectFit" /></view>
|
||||
</view>
|
||||
<view class="menu-item clickable-hover" @tap="openAgreementPicker">
|
||||
<view class="mi-left">
|
||||
<image class="mi-ico" src="/static/icons/master/menu-agreement.svg" mode="aspectFit" />
|
||||
|
||||
@@ -1,14 +1,39 @@
|
||||
<template>
|
||||
<view class="page">
|
||||
<YjyfNavBar theme="white" title="账号安全" :border="true" :showBack="returnOrder ? true : null" :customBack="!!returnOrder" @back="leaveSetup" />
|
||||
<view v-if="loaded" class="card">
|
||||
<view class="row" @tap="openPassword('login')"><text>登录密码</text><view class="value">{{ status.has_login_password ? '修改' : '设置' }} <image class="arrow" src="/static/icons/arrow-right.svg" mode="aspectFit" /></view></view>
|
||||
<view class="row" @tap="openPassword('payment')"><text>支付密码</text><view class="value">{{ status.has_payment_password ? '修改' : '设置' }} <image class="arrow" src="/static/icons/arrow-right.svg" mode="aspectFit" /></view></view>
|
||||
<view class="row" @tap="openCert"><text>企业资质认证</text><view class="value">{{ certText }} <image class="arrow" src="/static/icons/arrow-right.svg" mode="aspectFit" /></view></view>
|
||||
<YjyfNavBar theme="white" :title="setupFromPayment ? '设置支付密码' : mode === 'cert' ? '企业资质认证' : '账号安全'" :border="true" :showBack="mode === 'cert' || setupFromPayment ? true : null" :customBack="mode === 'cert' || setupFromPayment" @back="handleBack" />
|
||||
<template v-if="mode !== 'cert' && !setupFromPayment">
|
||||
<view v-if="loaded" class="card">
|
||||
<view class="row" @tap="openCert"><text>企业资质认证</text><view class="value"><text :class="{ attention: !cert || cert.verify_status === 'reject' }">{{ certText }}</text><image class="arrow" src="/static/icons/arrow-right.svg" mode="aspectFit" /></view></view>
|
||||
<view class="row" @tap="openPassword('login')"><text>登录密码</text><view class="value">{{ status.has_login_password ? '已设置' : '未设置' }}<image class="arrow" src="/static/icons/arrow-right.svg" mode="aspectFit" /></view></view>
|
||||
<view class="row" @tap="openPassword('payment')"><text>支付密码</text><view class="value">{{ status.has_payment_password ? '已设置' : '未设置' }}<image class="arrow" src="/static/icons/arrow-right.svg" mode="aspectFit" /></view></view>
|
||||
</view>
|
||||
<view v-if="loaded" class="logout" @tap="logout">退出登录</view>
|
||||
</template>
|
||||
<view v-else-if="mode === 'cert'" class="cert-page">
|
||||
<view class="cert-accent"></view>
|
||||
<view class="cert-card">
|
||||
<view class="cert-notice">为保障账号和交易安全,请上传真实有效的营业执照进行企业资质认证。<text>企业信息仅用于资质审核。</text></view>
|
||||
<view class="cert-content">
|
||||
<view class="cert-heading"><text class="required">*</text>上传营业执照照片</view>
|
||||
<view class="cert-description">上传后将自动识别企业信息,请核对识别结果。若识别有误或识别失败,可手动修改;请确保照片清晰完整。</view>
|
||||
<text v-if="cert && cert.verify_status === 'reject'" class="reject">审核未通过:{{ cert.audit_msg }}</text>
|
||||
<view class="upload" @tap="chooseLicense">
|
||||
<image v-if="imagePreview" :src="imagePreview" mode="aspectFit" class="license" />
|
||||
<image v-else src="/static/icons/enterprise-license.svg" mode="aspectFit" class="license-illustration" />
|
||||
<text>{{ busy ? '处理中...' : licenseImage ? '重新上传营业执照' : '上传营业执照' }}</text>
|
||||
</view>
|
||||
<view v-if="licenseImage" class="cert-fields">
|
||||
<view class="field"><text>企业名称</text><input v-model="companyName" placeholder="请输入企业名称" /></view>
|
||||
<view class="field"><text>营业执照号码</text><input v-model="licenseNo" placeholder="请输入营业执照号码" maxlength="18" /></view>
|
||||
<view class="field"><text>法人姓名</text><input v-model="legalPerson" placeholder="请输入法人姓名(选填)" /></view>
|
||||
<button class="primary" :disabled="busy" @tap="submitCert">提交审核</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="mode" class="mask">
|
||||
<view v-if="mode && mode !== 'cert'" class="mask">
|
||||
<view class="sheet">
|
||||
<view class="sheet-head"><text class="title">{{ sheetTitle }}</text><text class="close" @tap="close">取消</text></view>
|
||||
<view class="sheet-head"><text class="title">{{ sheetTitle }}</text><text class="close" @tap="cancelSheet">取消</text></view>
|
||||
<template v-if="mode === 'login'">
|
||||
<input v-if="status.has_login_password" v-model="oldPassword" class="input" password placeholder="请输入原登录密码" />
|
||||
<input v-model="newPassword" class="input" password maxlength="30" placeholder="新登录密码(6至30位)" />
|
||||
@@ -29,15 +54,7 @@
|
||||
<input v-model="confirmPassword" class="input" type="number" password maxlength="6" placeholder="再次输入支付密码" />
|
||||
<button class="primary" :disabled="busy" @tap="savePassword">确认</button>
|
||||
</template>
|
||||
<template v-else>
|
||||
<text v-if="cert && cert.verify_status === 'reject'" class="hint">审核未通过:{{ cert.audit_msg }}</text>
|
||||
<text class="hint">上传后将通过腾讯云识别营业执照,请核对识别信息后提交。</text>
|
||||
<input v-model="companyName" class="input" placeholder="请输入企业名称" />
|
||||
<input v-model="licenseNo" class="input" placeholder="请输入营业执照号码" maxlength="18" />
|
||||
<input v-model="legalPerson" class="input" placeholder="请输入法人姓名(选填)" />
|
||||
<view class="upload" @tap="chooseLicense"><image v-if="imagePreview" :src="imagePreview" mode="aspectFit" class="license"/><text>{{ licenseImage ? '重新上传营业执照' : '上传营业执照' }}</text></view>
|
||||
<button class="primary" :disabled="busy" @tap="submitCert">提交审核</button>
|
||||
</template>
|
||||
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -51,12 +68,13 @@
|
||||
import { finishPaymentSetup } from '@/utils/payment-setup.mjs';
|
||||
const loaded = ref(false), busy = ref(false), mode = ref('');
|
||||
const returnOrder = ref('');
|
||||
let setupFromPayment = false, setupOpened = false;
|
||||
const setupFromPayment = ref(false);
|
||||
let setupOpened = false;
|
||||
const status = ref({}), oldPassword = ref(''), newPassword = ref(''), confirmPassword = ref('');
|
||||
const companyName = ref(''), licenseNo = ref(''), legalPerson = ref(''), licenseImage = ref(''), imagePreview = ref('');
|
||||
const cert = computed(() => status.value.enterprise_cert || null);
|
||||
const certText = computed(() => cert.value ? ({ pending: '审核中', pass: '已认证', reject: '未通过,可重提' }[cert.value.verify_status] || '') : '未认证');
|
||||
const sheetTitle = computed(() => mode.value === 'login' ? '登录密码' : mode.value === 'payment' ? '支付密码' : '企业资质认证');
|
||||
const sheetTitle = computed(() => mode.value === 'login' ? '登录密码' : '支付密码');
|
||||
async function load() { try { status.value = await api.securityStatus(); loaded.value = true; } catch (e) {} }
|
||||
function close() { if (busy.value) return; mode.value = ''; oldPassword.value = ''; newPassword.value = ''; confirmPassword.value = ''; }
|
||||
function openPassword(which) { mode.value = which; }
|
||||
@@ -89,7 +107,7 @@
|
||||
if (!firstSetup) await api.changePaymentPassword({ old_password: oldPassword.value, new_password: newPassword.value });
|
||||
else await api.setPaymentPassword({ login_password: oldPassword.value, new_password: newPassword.value });
|
||||
busy.value = false; close(); uni.showToast({ title: '保存成功' });
|
||||
if (setupFromPayment && firstSetup) {
|
||||
if (setupFromPayment.value && firstSetup) {
|
||||
try { await finishPaymentSetup(uni, returnOrder.value); } catch (e) { uni.showToast({ title: e.message, icon: 'none' }); }
|
||||
} else await load();
|
||||
} catch (e) {} finally { busy.value = false; }
|
||||
@@ -97,6 +115,7 @@
|
||||
function chooseLicense() { if (busy.value) return; uni.chooseImage({ count: 1, sizeType: ['compressed'], success: async res => {
|
||||
busy.value = true; try {
|
||||
const uploaded = await api.upload(res.tempFilePaths[0], 'cert'); licenseImage.value = uploaded.url; imagePreview.value = uploaded.fullurl || res.tempFilePaths[0];
|
||||
companyName.value = ''; licenseNo.value = ''; legalPerson.value = '';
|
||||
try { const recognized = await api.recognizeEnterpriseLicense({ license_image: uploaded.url }); companyName.value = recognized.company_name; licenseNo.value = recognized.license_no; legalPerson.value = recognized.legal_person; }
|
||||
catch (e) { /* Recognition errors are displayed by the request layer; manual entry remains available. */ }
|
||||
} catch (e) {} finally { busy.value = false; }
|
||||
@@ -107,22 +126,26 @@
|
||||
busy.value = true;
|
||||
try { await api.submitEnterpriseCert({ company_name: companyName.value.trim(), license_no: licenseNo.value.trim(), legal_person: legalPerson.value.trim(), license_image: licenseImage.value }); busy.value = false; close(); await load(); uni.showToast({ title: '提交成功' }); } catch (e) {} finally { busy.value = false; }
|
||||
}
|
||||
function handleBack() { if (mode.value === 'cert') { close(); return; } if (!busy.value) leaveSetup(); }
|
||||
function cancelSheet() { if (busy.value) return; if (setupFromPayment.value) leaveSetup(); else close(); }
|
||||
function logout() { uni.showModal({ title: '退出登录', content: '确认退出当前登录账号?', success: (result) => { if (result.confirm) { clearAuth(); uni.reLaunch({ url: '/pages/login/login' }); } } }); }
|
||||
async function leaveSetup() {
|
||||
try { await finishPaymentSetup(uni, returnOrder.value); } catch (e) { uni.showToast({ title: e.message, icon: 'none' }); }
|
||||
}
|
||||
onLoad((options) => {
|
||||
setupFromPayment = !!(options && options.setupPayment === '1');
|
||||
setupFromPayment.value = !!(options && options.setupPayment === '1');
|
||||
const id = String((options && options.returnOrder) || '');
|
||||
if (setupFromPayment && /^[1-9]\d*$/.test(id) && Number.isSafeInteger(Number(id))) returnOrder.value = id;
|
||||
if (setupFromPayment.value && /^[1-9]\d*$/.test(id) && Number.isSafeInteger(Number(id))) returnOrder.value = id;
|
||||
});
|
||||
onBackPress(() => {
|
||||
if (!returnOrder.value) return false;
|
||||
leaveSetup();
|
||||
if (mode.value === 'cert') { if (!busy.value) close(); return true; }
|
||||
if (!setupFromPayment.value) return false;
|
||||
if (!busy.value) leaveSetup();
|
||||
return true;
|
||||
});
|
||||
onShow(async () => {
|
||||
await load();
|
||||
if (!loaded.value || !setupFromPayment || setupOpened) return;
|
||||
if (!loaded.value || !setupFromPayment.value || setupOpened) return;
|
||||
setupOpened = true;
|
||||
if (status.value.has_payment_password) await leaveSetup();
|
||||
else openPassword('payment');
|
||||
@@ -131,12 +154,33 @@
|
||||
<style lang="scss" scoped>
|
||||
@import '@/uni.scss';
|
||||
.page { min-height: 100vh; background: $yjyf-bg-page; }
|
||||
.card { margin: 24rpx; padding: 0 28rpx; background: $yjyf-bg-card; border-radius: 20rpx; }
|
||||
.row { min-height: 100rpx; display: flex; align-items: center; justify-content: space-between; border-bottom: 1rpx solid $yjyf-border-color; color: $yjyf-text-main; font-size: 30rpx; }
|
||||
.row:last-child { border-bottom: 0; }.value { color: $yjyf-text-secondary; font-size: 26rpx; display: flex; align-items: center; }.arrow { width: 26rpx; height: 26rpx; margin-left: 10rpx; }
|
||||
.card { margin: 24rpx; padding: 0 28rpx; background: $yjyf-bg-card; border-radius: 16rpx; }
|
||||
.row { min-height: 104rpx; display: flex; align-items: center; justify-content: space-between; border-bottom: 1rpx solid $yjyf-border-color; color: $yjyf-text-regular; font-size: 30rpx; }
|
||||
.row:last-child { border-bottom: 0; }
|
||||
.value { color: $yjyf-text-secondary; font-size: 28rpx; display: flex; align-items: center; }
|
||||
.attention { color: $yjyf-primary; }
|
||||
.arrow { width: 26rpx; height: 26rpx; margin-left: 10rpx; }
|
||||
.logout { margin: 56rpx 24rpx 0; padding: 30rpx; border-radius: 16rpx; background: $yjyf-bg-card; text-align: center; color: $yjyf-primary; font-size: 30rpx; }
|
||||
.cert-page { position: relative; padding: 64rpx 24rpx 48rpx; }
|
||||
.cert-accent { position: absolute; top: 0; left: 0; right: 0; height: 200rpx; background: $yjyf-gradient-primary; }
|
||||
.cert-card { position: relative; overflow: hidden; border-radius: 16rpx; background: $yjyf-bg-card; }
|
||||
.cert-notice { padding: 28rpx; background: $yjyf-primary-bg; color: $yjyf-text-regular; font-size: 27rpx; line-height: 1.7; }
|
||||
.cert-notice text { color: $yjyf-danger; }
|
||||
.cert-content { padding: 32rpx 28rpx 40rpx; }
|
||||
.cert-heading { color: $yjyf-text-main; font-size: 32rpx; font-weight: 600; }
|
||||
.required, .reject { color: $yjyf-danger; }
|
||||
.cert-description { margin-top: 16rpx; color: $yjyf-text-regular; font-size: 27rpx; line-height: 1.65; }
|
||||
.reject { display: block; margin-top: 20rpx; font-size: 26rpx; }
|
||||
.upload { width: 300rpx; min-height: 260rpx; box-sizing: border-box; margin: 32rpx auto 0; padding: 24rpx; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16rpx; color: $yjyf-primary; background: $yjyf-primary-bg; border: 2rpx dashed $yjyf-primary; font-size: 28rpx; font-weight: 600; }
|
||||
.license-illustration { width: 200rpx; height: 140rpx; }
|
||||
.license { width: 240rpx; height: 160rpx; }
|
||||
.cert-fields { margin-top: 32rpx; }
|
||||
.field { display: flex; align-items: center; min-height: 92rpx; border-bottom: 1rpx solid $yjyf-border-color; color: $yjyf-text-regular; font-size: 27rpx; }
|
||||
.field text { width: 200rpx; flex-shrink: 0; }
|
||||
.field input { flex: 1; min-width: 0; font-size: 27rpx; }
|
||||
.mask { position: fixed; inset: 0; z-index: 1000; background: rgba(0,0,0,.5); display: flex; align-items: flex-end; }
|
||||
.sheet { width: 100%; max-height: 90vh; overflow-y: auto; padding: 30rpx 30rpx calc(30rpx + env(safe-area-inset-bottom)); border-radius: 24rpx 24rpx 0 0; background: $yjyf-bg-card; }
|
||||
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24rpx; }.title { color: $yjyf-text-main; font-size: 32rpx; font-weight: 600; }.close { color: $yjyf-text-secondary; font-size: 28rpx; }
|
||||
.input { height: 88rpx; padding: 0 20rpx; margin-bottom: 16rpx; background: $yjyf-bg-page; border-radius: 12rpx; font-size: 28rpx; }.hint { display: block; margin: 12rpx 0; color: $yjyf-text-secondary; font-size: 24rpx; }
|
||||
.primary { margin-top: 22rpx; background: $yjyf-gradient-primary; color: $yjyf-bg-card; font-size: 30rpx; }.upload { display: flex; flex-direction: column; align-items: center; gap: 10rpx; padding: 24rpx; color: $yjyf-primary; border: 1rpx solid $yjyf-border-color; font-size: 26rpx; }.license { width: 300rpx; height: 180rpx; }
|
||||
.primary { margin-top: 32rpx; background: $yjyf-gradient-primary; color: $yjyf-bg-card; font-size: 30rpx; }
|
||||
</style>
|
||||
|
||||
@@ -313,18 +313,6 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 虚拟号保护开关 -->
|
||||
<view class="form-row sub-row">
|
||||
<view class="fr-label flex-row-center" @tap="showVirtualHelp">
|
||||
<view class="virtual-checkbox" :class="{ on: form.use_virtual }" @tap.stop="form.use_virtual = !form.use_virtual">
|
||||
<image class="vc-icon" v-if="form.use_virtual" src="/static/icons/check-white.svg" mode="aspectFit" />
|
||||
</view>
|
||||
<text class="sub-label-txt">虚拟号</text>
|
||||
<image class="sub-info-icon" src="/static/icons/info-orange.svg" mode="aspectFit" />
|
||||
</view>
|
||||
<text class="sub-hint-txt">隐藏真实号码,防骚扰泄露</text>
|
||||
</view>
|
||||
|
||||
<!-- 客户地址(省市区选择 + 地图定位选点 + 师傅运力提示) -->
|
||||
<view class="form-row addr-col-row">
|
||||
<view class="addr-top-line">
|
||||
@@ -1918,7 +1906,6 @@
|
||||
const form = reactive({
|
||||
contact: '',
|
||||
mobile: '',
|
||||
use_virtual: true,
|
||||
province: '',
|
||||
city: '',
|
||||
district: '',
|
||||
@@ -2205,16 +2192,6 @@
|
||||
scheduleCalc();
|
||||
}
|
||||
|
||||
function showVirtualHelp() {
|
||||
uni.showModal({
|
||||
title: '虚拟号保护说明',
|
||||
content: '开启后,师傅只能通过平台虚拟转接号码与您联系,隐藏您的真实手机号码,服务完成后自动失效。',
|
||||
showCancel: false,
|
||||
confirmText: '我知道了',
|
||||
confirmColor: '#F0710D'
|
||||
});
|
||||
}
|
||||
|
||||
// 智能粘贴识别
|
||||
const rawAddressText = ref('');
|
||||
|
||||
@@ -2571,7 +2548,6 @@
|
||||
floor: form.floor,
|
||||
has_elevator: form.has_elevator,
|
||||
urgent: isUrgent.value ? 1 : 0,
|
||||
use_virtual: form.use_virtual ? 1 : 0,
|
||||
auto_quote_timeout: (priceType.value === 'fixed' && autoQuote.value) ? (Number(autoQuoteHours.value) || 24) * 3600 : 0,
|
||||
appoint_time: targetTime,
|
||||
remark: form.remark,
|
||||
@@ -3468,52 +3444,6 @@
|
||||
box-shadow: 0 4rpx 20rpx rgba(31, 31, 31, 0.04);
|
||||
}
|
||||
|
||||
.sub-row {
|
||||
min-height: 76rpx;
|
||||
padding: 4rpx 0;
|
||||
}
|
||||
|
||||
.flex-row-center {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12rpx;
|
||||
}
|
||||
|
||||
.virtual-checkbox {
|
||||
width: 34rpx;
|
||||
height: 34rpx;
|
||||
border-radius: 6rpx;
|
||||
border: 2rpx solid #CCCCCC;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.virtual-checkbox.on {
|
||||
background: #F0710D;
|
||||
border-color: #F0710D;
|
||||
}
|
||||
|
||||
.vc-icon {
|
||||
width: 22rpx;
|
||||
height: 22rpx;
|
||||
}
|
||||
|
||||
.sub-label-txt {
|
||||
font-size: 28rpx;
|
||||
color: #1F1F1F;
|
||||
}
|
||||
|
||||
.sub-info-icon {
|
||||
width: 32rpx;
|
||||
height: 32rpx;
|
||||
}
|
||||
|
||||
.sub-hint-txt {
|
||||
font-size: 24rpx;
|
||||
color: #999999;
|
||||
}
|
||||
|
||||
.addr-col-row {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 140" fill="none">
|
||||
<path d="M17 39V17h22M161 17h22v22M17 101v22h22M161 123h22v-22" stroke="#F0710D" stroke-width="3" stroke-linecap="round"/>
|
||||
<rect x="44" y="28" width="112" height="84" rx="4" fill="#fff" stroke="#F0F0F2" stroke-width="2"/>
|
||||
<circle cx="100" cy="48" r="10" fill="#F0710D"/>
|
||||
<path d="M97 48l2 2 4-5" stroke="#fff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M69 70h62M69 80h62M69 90h45" stroke="#C8C7CC" stroke-width="4" stroke-linecap="round"/>
|
||||
</svg>
|
||||
|
之后 宽度: | 高度: | 大小: 565 B |
在新工单中引用
屏蔽一个用户