From 0525265074e7e22109e3e749029034151ad76d1e Mon Sep 17 00:00:00 2001 From: chen Date: Sat, 26 Sep 2026 14:22:43 +0800 Subject: [PATCH] =?UTF-8?q?fix(settle):=20=E5=A2=9E=E5=BC=BA=20DailySettle?= =?UTF-8?q?Service=20ext=20=E6=95=B0=E7=BB=84=E4=BF=9D=E6=8A=A4=E5=B9=B6?= =?UTF-8?q?=E5=AE=8C=E5=96=84=E5=85=A8=E6=94=B6=E7=9B=8A=E7=BB=88=E5=AE=A1?= =?UTF-8?q?=E6=96=AD=E8=A8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- addons/shopro/service/partner/DailySettleService.php | 12 ++++++++++++ .../partner/verify_full_order_rewards_and_settle.php | 8 +++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/addons/shopro/service/partner/DailySettleService.php b/addons/shopro/service/partner/DailySettleService.php index 8e85dad..0a78937 100644 --- a/addons/shopro/service/partner/DailySettleService.php +++ b/addons/shopro/service/partner/DailySettleService.php @@ -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([ diff --git a/tests/partner/verify_full_order_rewards_and_settle.php b/tests/partner/verify_full_order_rewards_and_settle.php index 8d0a093..bb2f3ee 100644 --- a/tests/partner/verify_full_order_rewards_and_settle.php +++ b/tests/partner/verify_full_order_rewards_and_settle.php @@ -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"; }