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' =>
|
||||
|
||||
在新工单中引用
屏蔽一个用户