Commit 2d5b9796 by 杨树贤

优化判断

parent 84207fea
......@@ -36,9 +36,13 @@ class AdminUserService
return $userInfoModel->whereIn('userId', $adminIds)->get()->toArray();
}
public function getCodeIdByUserName($userName)
public function getCodeIdByUserName($userName, $isOnWork = false)
{
$userId = UserInfoModel::where('name', $userName)->value('userId');
$query = UserInfoModel::where('name', $userName);
if ($isOnWork) {
$query = $query->where('status', '!=', 4);
}
$userId = $query->value('userId');
$codeId = IntracodeModel::where('admin_id', $userId)->value('code_id');
return $codeId;
}
......@@ -124,6 +128,4 @@ class AdminUserService
$intraCodeModel = new IntracodeModel();
return $intraCodeModel->getEncodeByUserIds($userIds);
}
}
......@@ -1138,7 +1138,7 @@ class SupplierService
if ($supplierGroup == SupplierChannelModel::SUPPLIER_GROUP_SPOT) {
// 现货商:分配商品供应链部数据跟单采购组的4个人
foreach ($dataFollowerGroup as $followerName) {
$codeId = $adminUserService->getCodeIdByUserName($followerName);
$codeId = $adminUserService->getCodeIdByUserName($followerName, true);
if ($codeId) {
$assignCodeIds[] = $codeId;
}
......@@ -1181,7 +1181,7 @@ class SupplierService
$existingLiexinCodeId = $existingLiexin->can_check_uids;
$isInDataFollowerGroup = false;
foreach ($dataFollowerGroup as $followerName) {
$codeId = $adminUserService->getCodeIdByUserName($followerName);
$codeId = $adminUserService->getCodeIdByUserName($followerName, true);
if ($codeId && $codeId == $existingLiexinCodeId) {
$isInDataFollowerGroup = true;
break;
......@@ -1196,7 +1196,7 @@ class SupplierService
} else {
// 猎芯采购不是四个人中的一个,随机选商品供应链部数据跟单采购组的其中1人
$randomFollower = $dataFollowerGroup[array_rand($dataFollowerGroup)];
$codeId = $adminUserService->getCodeIdByUserName($randomFollower);
$codeId = $adminUserService->getCodeIdByUserName($randomFollower, true);
if ($codeId) {
$assignCodeIds[] = $codeId;
}
......@@ -1207,7 +1207,7 @@ class SupplierService
} else {
// 都没有,随机选商品供应链部数据跟单采购组的其中1人
$randomFollower = $dataFollowerGroup[array_rand($dataFollowerGroup)];
$codeId = $adminUserService->getCodeIdByUserName($randomFollower);
$codeId = $adminUserService->getCodeIdByUserName($randomFollower, true);
if ($codeId) {
$assignCodeIds[] = $codeId;
}
......@@ -1219,7 +1219,7 @@ class SupplierService
} elseif ($isXinZhiGongYingLian) {
// 属于新质供应链部:默认欧阳海梅
$defaultName = config('field.XinzhiDefaultDataFollowerName', '欧阳海梅');
$codeId = $adminUserService->getCodeIdByUserName($defaultName);
$codeId = $adminUserService->getCodeIdByUserName($defaultName, true);
if ($codeId) {
$assignCodeIds[] = $codeId;
}
......@@ -1336,7 +1336,7 @@ class SupplierService
$isProdMode = ($mode === 'prod');
// 构建查询
$query = SupplierChannelModel::where('is_type', 0)->where('supplier_id','>',13856)
$query = SupplierChannelModel::where('is_type', 0)->where('supplier_id', '>', 13856)
->where('yunxin_channel_uid', '!=', '');
// 如果num>0则限制数量,否则不限制
......
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