From 1c3f77dd554386129c1cb1ddf47f4ece9b0fb69d Mon Sep 17 00:00:00 2001 From: chen Date: Sat, 26 Sep 2026 14:21:34 +0800 Subject: [PATCH] =?UTF-8?q?fix(partner):=20=E5=AE=8C=E5=96=84=20updateAgen?= =?UTF-8?q?tOrderTime=20=E5=85=BC=E5=AE=B9=20AgentModel=20=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E4=B8=8E=E8=87=AA=E5=8A=A8=E5=BB=BA=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/partner/PartnerRewardService.php | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/addons/shopro/service/partner/PartnerRewardService.php b/addons/shopro/service/partner/PartnerRewardService.php index aa57980..c5d28c3 100644 --- a/addons/shopro/service/partner/PartnerRewardService.php +++ b/addons/shopro/service/partner/PartnerRewardService.php @@ -241,22 +241,34 @@ class PartnerRewardService protected function updateAgentOrderTime($userId, $timestamp) { + if (!$userId) { + return; + } $agent = AgentModel::where('user_id', $userId)->find(); if (!$agent) { try { $agentService = new \addons\shopro\service\commission\Agent($userId); - $agent = $agentService->createNewAgent(); + $agentService->createNewAgent(); } catch (\Throwable $e) {} - if (!$agent) { - $agent = AgentModel::where('user_id', $userId)->find(); - } + $agent = AgentModel::where('user_id', $userId)->find(); } - if ($agent) { + if ($agent && is_object($agent)) { $current = intval($agent->last_self_order_time ?? 0); if ($timestamp >= $current) { $agent->last_self_order_time = $timestamp; $agent->save(); } + } else { + // 合伙人模式下首购未建档时自愈建立品酒师档案 + try { + \think\Db::name('shopro_commission_agent')->insert([ + 'user_id' => $userId, + 'level' => 1, + 'status' => 'normal', + 'last_self_order_time' => $timestamp, + 'createtime' => time() + ]); + } catch (\Throwable $e) {} } }