Commit 865d0fea by 杨树贤

优化

parent e390d2ae
Showing with 46 additions and 7 deletions
......@@ -1145,14 +1145,53 @@ class SupplierService
}
$result['debug_info']['assign_type'] = '现货商-分配4人';
} else {
// 代理商/原厂:随机选商品供应链部数据跟单采购组的其中1人
$randomFollower = $dataFollowerGroup[array_rand($dataFollowerGroup)];
$codeId = $adminUserService->getCodeIdByUserName($randomFollower);
if ($codeId) {
$assignCodeIds[] = $codeId;
// 代理商/原厂:只分配1人
// 先检查是否已有数据跟单员
$existingDataFollower = SupplierContactModel::where('supplier_id', $supplierId)
->where('channel_user_type', SupplierContactModel::CHANNEL_USER_TYPE_INVENTORY)
->first();
if ($existingDataFollower) {
// 已有数据跟单员,检查是否有对应的猎芯采购员(同一人)
$existingLiexin = SupplierContactModel::where('supplier_id', $supplierId)
->where('can_check_uids', $existingDataFollower->can_check_uids)
->where('channel_user_type', SupplierContactModel::CHANNEL_USER_TYPE_LIEXIN)
->exists();
if ($existingLiexin) {
// 已有数据跟单员和对应的猎芯采购员(同一人),跳过
$result['success'] = true;
$result['reason'] = '代理商/原厂已有猎芯采购和数据跟单员(同一人),跳过';
$result['debug_info']['existing_code_id'] = $existingDataFollower->can_check_uids;
return $result;
} else {
// 有数据跟单员但没有对应的猎芯采购员,用已有的数据跟单员分配猎芯采购
$assignCodeIds[] = $existingDataFollower->can_check_uids;
$result['debug_info']['assign_type'] = '代理商/原厂-使用已有数据跟单员分配猎芯采购';
$result['debug_info']['existing_follower_code_id'] = $existingDataFollower->can_check_uids;
}
} else {
// 没有数据跟单员,检查是否有猎芯采购
$existingLiexin = SupplierContactModel::where('supplier_id', $supplierId)
->where('channel_user_type', SupplierContactModel::CHANNEL_USER_TYPE_LIEXIN)
->first();
if ($existingLiexin) {
// 有猎芯采购但没有数据跟单员,用已有的猎芯采购员分配数据跟单员
$assignCodeIds[] = $existingLiexin->can_check_uids;
$result['debug_info']['assign_type'] = '代理商/原厂-使用已有猎芯采购分配数据跟单员';
$result['debug_info']['existing_liexin_code_id'] = $existingLiexin->can_check_uids;
} else {
// 都没有,随机选商品供应链部数据跟单采购组的其中1人
$randomFollower = $dataFollowerGroup[array_rand($dataFollowerGroup)];
$codeId = $adminUserService->getCodeIdByUserName($randomFollower);
if ($codeId) {
$assignCodeIds[] = $codeId;
}
$result['debug_info']['assign_type'] = '代理商/原厂-随机分配1人';
$result['debug_info']['random_follower'] = $randomFollower;
}
}
$result['debug_info']['assign_type'] = '代理商/原厂-随机分配1人';
$result['debug_info']['random_follower'] = $randomFollower;
}
} elseif ($isXinZhiGongYingLian) {
// 属于新质供应链部:默认欧阳海梅
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment