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) {} } }