feat(split): 优化汇付分账服务逻辑并增强重试功能

- 修改HuifuSplitService中分账状态查询逻辑,从检查状态[1,2]改为仅检查状态2
- 更新删除条件,从删除状态4改为删除状态[1,4]
- 在分账明细为空时添加详细的错误提示信息
- 新增retryByOrderId方法支持订单ID重试
- 优化后台控制器中的重试逻辑,添加分账记录存在性验证
- 改进错误提示信息,提供更准确的失败原因说明
```
这个提交包含在:
可乐加冰
2026-10-02 14:26:17 +08:00
父节点 246935728e
当前提交 f238ff212a
共有 2 个文件被更改,包括 45 次插入 和 27 次删除

查看文件

@@ -27,11 +27,11 @@ class HuifuSplitService
return false;
}
$exists = SplitOrder::where('order_id', $orderId)->where('channel', 'huifu')->where('status', 'in', [1, 2])->find();
if ($exists) {
$done = SplitOrder::where('order_id', $orderId)->where('channel', 'huifu')->where('status', 2)->find();
if ($done) {
return true;
}
SplitOrder::where('order_id', $orderId)->where('channel', 'huifu')->where('status', 4)->delete();
SplitOrder::where('order_id', $orderId)->where('channel', 'huifu')->where('status', 'in', [1, 4])->delete();
$calculator = new SplitCalculator();
$items = $calculator->calculate($orderId);
@@ -41,6 +41,8 @@ class HuifuSplitService
if ($rewardCount + $regionalCount > 0) {
\think\Log::warning('[shopro_huifu] split skipped order_id=' . $orderId . ' reason=receiver_missing_or_no_huifu_id');
}
$msg = '分账明细为空:请检查分账金额来源、汇付接收方(huifu_id)与佣金/规则是否大于0';
$this->markFailed($orderId, 'HFPS' . date('YmdHis') . $orderId, $order, [], $msg);
return false;
}
@@ -117,7 +119,16 @@ class HuifuSplitService
if (!$splitOrder || $splitOrder['channel'] !== 'huifu') {
return false;
}
return $this->executeByOrderId($splitOrder['order_id']);
return $this->executeByOrderId((int) $splitOrder['order_id']);
}
public function retryByOrderId($orderId)
{
$orderId = (int) $orderId;
if ($orderId <= 0) {
return false;
}
return $this->executeByOrderId($orderId);
}
protected function confirm($ext, array $acctInfos, $confirmReqSeqId)