fix(partner): 完善 updateAgentOrderTime 兼容 AgentModel 查询与自动建档
这个提交包含在:
@@ -241,22 +241,34 @@ class PartnerRewardService
|
|||||||
|
|
||||||
protected function updateAgentOrderTime($userId, $timestamp)
|
protected function updateAgentOrderTime($userId, $timestamp)
|
||||||
{
|
{
|
||||||
|
if (!$userId) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
$agent = AgentModel::where('user_id', $userId)->find();
|
$agent = AgentModel::where('user_id', $userId)->find();
|
||||||
if (!$agent) {
|
if (!$agent) {
|
||||||
try {
|
try {
|
||||||
$agentService = new \addons\shopro\service\commission\Agent($userId);
|
$agentService = new \addons\shopro\service\commission\Agent($userId);
|
||||||
$agent = $agentService->createNewAgent();
|
$agentService->createNewAgent();
|
||||||
} catch (\Throwable $e) {}
|
} 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);
|
$current = intval($agent->last_self_order_time ?? 0);
|
||||||
if ($timestamp >= $current) {
|
if ($timestamp >= $current) {
|
||||||
$agent->last_self_order_time = $timestamp;
|
$agent->last_self_order_time = $timestamp;
|
||||||
$agent->save();
|
$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) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
在新工单中引用
屏蔽一个用户