fix(settle): 增强 DailySettleService ext 数组保护并完善全收益终审断言
这个提交包含在:
@@ -110,6 +110,9 @@ class DailySettleService
|
||||
foreach ($unsettledOrders as $o) {
|
||||
$freshExt = \think\Db::name('shopro_order')->where('id', $o['id'])->value('ext');
|
||||
$ext = is_array($freshExt) ? $freshExt : (json_decode($freshExt ?? '', true) ?: []);
|
||||
if (!is_array($ext)) {
|
||||
$ext = [];
|
||||
}
|
||||
$ext['madow_settled'] = 1;
|
||||
$ext['madow_settle_time'] = time();
|
||||
\think\Db::name('shopro_order')->where('id', $o['id'])->update([
|
||||
@@ -149,6 +152,9 @@ class DailySettleService
|
||||
foreach ($unsettledVenueOrders as $o) {
|
||||
$freshExt = \think\Db::name('shopro_order')->where('id', $o['id'])->value('ext');
|
||||
$ext = is_array($freshExt) ? $freshExt : (json_decode($freshExt ?? '', true) ?: []);
|
||||
if (!is_array($ext)) {
|
||||
$ext = [];
|
||||
}
|
||||
$ext['venue_settled'] = 1;
|
||||
$ext['venue_settle_time'] = time();
|
||||
\think\Db::name('shopro_order')->where('id', $o['id'])->update([
|
||||
@@ -163,6 +169,9 @@ class DailySettleService
|
||||
foreach ($allQualifiedOrders as $o) {
|
||||
$freshExt = \think\Db::name('shopro_order')->where('id', $o['id'])->value('ext');
|
||||
$ext = is_array($freshExt) ? $freshExt : (json_decode($freshExt ?? '', true) ?: []);
|
||||
if (!is_array($ext)) {
|
||||
$ext = [];
|
||||
}
|
||||
if (empty($ext['county_settled'])) {
|
||||
$unsettledCountyOrders[] = $o;
|
||||
$rules = PartnerConfig::getOrderEffectiveRules($o);
|
||||
@@ -185,6 +194,9 @@ class DailySettleService
|
||||
foreach ($unsettledCountyOrders as $o) {
|
||||
$freshExt = \think\Db::name('shopro_order')->where('id', $o['id'])->value('ext');
|
||||
$ext = is_array($freshExt) ? $freshExt : (json_decode($freshExt ?? '', true) ?: []);
|
||||
if (!is_array($ext)) {
|
||||
$ext = [];
|
||||
}
|
||||
$ext['county_settled'] = 1;
|
||||
$ext['county_settle_time'] = time();
|
||||
\think\Db::name('shopro_order')->where('id', $o['id'])->update([
|
||||
|
||||
@@ -338,18 +338,20 @@ class FullOrderRewardVerification
|
||||
$this->assert(!empty($agentD['last_self_order_time']), "买家 D last_self_order_time 已成功激活");
|
||||
|
||||
// 调用 IdentityService 检查输出的时间戳与天数
|
||||
$attached = IdentityService::attachAgent($agentD);
|
||||
$agentModelD = \app\admin\model\shopro\commission\Agent::where('user_id', $buyerId)->find();
|
||||
$attached = IdentityService::attachAgent($agentModelD);
|
||||
$this->assert($attached['active_30d'] === true, "买家 D active_30d 为 true (活跃有效)");
|
||||
$this->assert($attached['active_status'] === 'active', "买家 D active_status 为 'active' (正常活跃)");
|
||||
$this->assert($attached['days_remaining'] == 30, "买家 D 剩余天数满额显示 30 天 (实际: {$attached['days_remaining']})");
|
||||
|
||||
// 校验到期时间戳:订单支付时刻 + 30 * 86400 (方案 A 精确顺延)
|
||||
$expectedExpire = intval($order->paid_time) + 30 * 86400;
|
||||
$paidTimestamp = is_numeric($order->paid_time) ? intval($order->paid_time) : strtotime($order->paid_time);
|
||||
$expectedExpire = $paidTimestamp + 30 * 86400;
|
||||
$this->assert($attached['expire_time'] == $expectedExpire, "到期时间戳精确顺延720小时,绝无零点截断 (实际: {$attached['expire_time']}, 期望: {$expectedExpire})");
|
||||
|
||||
// 验证直推人 C 也获得双向保活更新
|
||||
$agentC = Db::name('shopro_commission_agent')->where('user_id', $chain['c']->id)->find();
|
||||
$this->assert($agentC['last_self_order_time'] >= $order->paid_time, "直推上级 C 同样被直推订单双向激活保活");
|
||||
$this->assert($agentC['last_self_order_time'] >= $paidTimestamp, "直推上级 C 同样被直推订单双向激活保活");
|
||||
|
||||
echo "\n";
|
||||
}
|
||||
|
||||
在新工单中引用
屏蔽一个用户