```
feat(shopro/split): 优化汇付分账查询功能 - 重构汇付渠道状态查询逻辑,新增 queryHuifuChannelStatus 方法处理支付查单和分账查询 - 支持未 confirm 时使用支付查单,有 confirm_hf_seq_id 时查询分账结果 - 优化异常处理机制,区分 HttpResponseException 和其他异常类型 - 改进前端显示逻辑,根据返回数据类型展示更详细的查询结果信息 - 增强错误提示和用户体验,提供更精确的反馈信息 ```
这个提交包含在:
@@ -225,8 +225,7 @@ class Order extends Base
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if (($row['channel'] ?? 'wechat') === 'huifu' && class_exists('\\addons\\shopro_huifu\\library\\HuifuSplitService')) {
|
if (($row['channel'] ?? 'wechat') === 'huifu' && class_exists('\\addons\\shopro_huifu\\library\\HuifuSplitService')) {
|
||||||
$service = new \addons\shopro_huifu\library\HuifuSplitService();
|
$result = $this->queryHuifuChannelStatus($row);
|
||||||
$result = $service->querySplit($row['transaction_id']);
|
|
||||||
} elseif ((new SplitConfig())->isHuifuMode()) {
|
} elseif ((new SplitConfig())->isHuifuMode()) {
|
||||||
$this->error('当前为汇付分账,请对 channel=huifu 的分账记录查询,或到汇付控台查看分账结果');
|
$this->error('当前为汇付分账,请对 channel=huifu 的分账记录查询,或到汇付控台查看分账结果');
|
||||||
} else {
|
} else {
|
||||||
@@ -236,11 +235,34 @@ class Order extends Base
|
|||||||
'transaction_id' => $row['transaction_id'],
|
'transaction_id' => $row['transaction_id'],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
$row->wx_result = json_encode($result, JSON_UNESCAPED_UNICODE);
|
} catch (\think\exception\HttpResponseException $e) {
|
||||||
$row->save();
|
throw $e;
|
||||||
$this->success('查询成功', null, $result);
|
} catch (\Throwable $e) {
|
||||||
} catch (\Exception $e) {
|
$this->error('查询失败:' . ($e->getMessage() ?: '未知错误'));
|
||||||
$this->error($e->getMessage());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$row->wx_result = json_encode($result, JSON_UNESCAPED_UNICODE);
|
||||||
|
$row->save();
|
||||||
|
$this->success('查询成功', null, $result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 汇付:未 confirm 成功时用支付查单;已有 confirm_hf_seq_id 时再查分账结果
|
||||||
|
*/
|
||||||
|
protected function queryHuifuChannelStatus($row)
|
||||||
|
{
|
||||||
|
$payload = [];
|
||||||
|
if (class_exists('\\addons\\shopro_huifu\\library\\HuifuQueryService')) {
|
||||||
|
$payload['pay_query'] = (new \addons\shopro_huifu\library\HuifuQueryService())->queryByOrderSn($row['order_sn']);
|
||||||
|
}
|
||||||
|
$confirmSeq = trim((string) ($row['confirm_hf_seq_id'] ?? ''));
|
||||||
|
if ($confirmSeq !== '') {
|
||||||
|
$service = new \addons\shopro_huifu\library\HuifuSplitService();
|
||||||
|
$payload['split_query'] = $service->querySplit($confirmSeq);
|
||||||
|
}
|
||||||
|
if (empty($payload)) {
|
||||||
|
throw new \RuntimeException('汇付查询组件不可用');
|
||||||
|
}
|
||||||
|
return $payload;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -90,19 +90,40 @@ define(['jquery', 'bootstrap', 'backend', 'form'], function ($, undefined, Backe
|
|||||||
},
|
},
|
||||||
query(id) {
|
query(id) {
|
||||||
Fast.api.ajax({ url: 'shopro/split/order/query/ids/' + id, type: 'POST' }, (ret, res) => {
|
Fast.api.ajax({ url: 'shopro/split/order/query/ids/' + id, type: 'POST' }, (ret, res) => {
|
||||||
var hint = '已同步通道状态并更新记录';
|
var hint = (res && res.msg) ? res.msg : '已同步通道状态并更新记录';
|
||||||
if (res.data) {
|
var d = (res && res.data) ? res.data : {};
|
||||||
try {
|
if (typeof d === 'string') {
|
||||||
var d = typeof res.data === 'string' ? JSON.parse(res.data) : res.data;
|
try { d = JSON.parse(d); } catch (e) { d = {}; }
|
||||||
var parts = [d.resp_desc, d.resp_code, d.bank_message, d.status].filter(Boolean);
|
|
||||||
if (parts.length) {
|
|
||||||
hint += ':' + parts.join(' ');
|
|
||||||
}
|
|
||||||
} catch (e) { /* ignore */ }
|
|
||||||
}
|
}
|
||||||
Layer.msg(hint, { time: 4000 });
|
var parts = [];
|
||||||
|
if (d.pay_query) {
|
||||||
|
var pq = d.pay_query;
|
||||||
|
if (pq.fund_freeze_stat) {
|
||||||
|
parts.push('资金状态 ' + pq.fund_freeze_stat);
|
||||||
|
}
|
||||||
|
if (pq.unconfirm_amt != null) {
|
||||||
|
parts.push('待确认 ' + pq.unconfirm_amt);
|
||||||
|
}
|
||||||
|
if (pq.trans_stat) {
|
||||||
|
parts.push('交易 ' + pq.trans_stat);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (d.split_query) {
|
||||||
|
var sq = d.split_query;
|
||||||
|
parts = parts.concat([sq.resp_desc, sq.resp_code, sq.status].filter(Boolean));
|
||||||
|
}
|
||||||
|
if (!parts.length) {
|
||||||
|
parts = [d.resp_desc, d.resp_code, d.bank_message, d.status].filter(Boolean);
|
||||||
|
}
|
||||||
|
if (parts.length) {
|
||||||
|
hint += ':' + parts.join(' · ');
|
||||||
|
}
|
||||||
|
Layer.msg(hint, { time: 5000 });
|
||||||
this.getList();
|
this.getList();
|
||||||
return false;
|
return false;
|
||||||
|
}, (res) => {
|
||||||
|
var msg = (res && res.msg) ? res.msg : '查询失败,请稍后重试';
|
||||||
|
Layer.msg(msg, { time: 4000 });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
在新工单中引用
屏蔽一个用户