Commit 94953e01 by 杨树贤

加入限制

parent 0b7e1243
......@@ -255,7 +255,7 @@ class SupplierApiController extends Controller
{
if (empty(request()->user->codeId)) {
$this->response(-1, '没有内部编码,请先去设置编码');
$this->response(-1, '没有内部编码,请先去设置编码');
}
$list = (new SupplierService())->getSupplierList($request->all());
$this->response(0, 'ok', $list['data'], $list['total']);
......@@ -517,6 +517,22 @@ class SupplierApiController extends Controller
}
$service = new SupplierService();
$result = $service->allocateChannelUser($supplierId, $channelUid, $channelUserType);
} else if ($channelUserType == SupplierContactModel::CHANNEL_USER_TYPE_INVENTORY) {
$service = new SupplierContactService();
if (!$service->validateDataFollowerDepartment($channelUid)) {
$this->response(-1, '数据跟单员必须属于部门ID为113或137的部门');
}
$check = $adminService->checkIsResignedByCodeId($channelUid);
if ($check) {
$this->response(-1, '该采购员已经离职,请选择其他人员');
}
$contactModel = new SupplierContactModel();
$contact = $contactModel->where('supplier_id', $supplierId)->where('channel_user_type', $channelUserType)->where('can_check_uids', $channelUid)->first();
if ($contact) {
$this->response(-1, '该供应商已经存在同名的华云采购员,请选择其他人员');
}
$service = new SupplierService();
$result = $service->allocateChannelUser($supplierId, $channelUid, $channelUserType);
} else {
$check = $adminService->checkIsResignedByCodeId($channelUid);
if ($check) {
......
......@@ -103,6 +103,14 @@ class SupplierContactApiController extends Controller
$this->response(-1, $validateResult);
}
$service = new SupplierContactService();
//如果channel_user_type=4,那么就要校验当前can_check_uids的部门id是否是113或137
if ($data['channel_user_type'] == 4) {
if (!$service->validateDataFollowerDepartment($data['can_check_uids'])) {
$this->response(-1, '数据跟单员必须属于部门ID为113或137的部门');
}
}
$hasNeedReplaceContact = $service->getNeedReplaceContact($data['supplier_id'], $data['can_check_uids'], $data['channel_user_type']);
$result = $service->saveContact($data);
if (!$result) {
......
......@@ -6,6 +6,8 @@ namespace App\Http\Services;
use App\Model\LogModel;
use App\Model\RedisModel;
use App\Model\UserInfoModel;
use App\Model\IntracodeModel;
use App\Model\SupplierChannelModel;
use App\Model\SupplierContactModel;
......@@ -203,15 +205,32 @@ class SupplierContactService
public function updateSupplierCodeData($supplierId)
{
//还要把采购员的列表写到特定redis字段给商品新增服务使用
$supplier = SupplierChannelModel::where('supplier_id', $supplierId)->select(['supplier_code', 'channel_uid'])->first();
$redis = new RedisModel();
$supplierCodeData = $redis->hget('supplier_code', $supplier->supplier_code);
if ($supplierCodeData) {
$supplierCodeData = json_decode($supplierCodeData, true);
$supplierCodeData['channel_uid'] = $supplier->channel_uid;
$redis->hset('supplier_code', $supplier->supplier_code, json_encode($supplierCodeData));
}
//还要把采购员的列表写到特定redis字段给商品新增服务使用
$supplier = SupplierChannelModel::where('supplier_id', $supplierId)->select(['supplier_code', 'channel_uid'])->first();
$redis = new RedisModel();
$supplierCodeData = $redis->hget('supplier_code', $supplier->supplier_code);
if ($supplierCodeData) {
$supplierCodeData = json_decode($supplierCodeData, true);
$supplierCodeData['channel_uid'] = $supplier->channel_uid;
$redis->hset('supplier_code', $supplier->supplier_code, json_encode($supplierCodeData));
}
}
//如果channel_user_type=4,那么就要校验当前can_check_uids的部门id是否是113或137
public function validateDataFollowerDepartment($codeId)
{
// 通过codeId获取adminId
$adminId = (new IntracodeModel())->where('code_id', $codeId)->value('admin_id');
if (!$adminId) {
return false;
}
// 通过adminId获取departmentId
$departmentId = UserInfoModel::where('userId', $adminId)->value('department_id');
if (!$departmentId) {
return false;
}
// 校验部门ID是否为113
return in_array($departmentId, [113, 137]);
}
}
......@@ -14,6 +14,7 @@ class SupplierContactModel extends Model
const CHANNEL_USER_TYPE_LIEXIN = 1;
const CHANNEL_USER_TYPE_JD = 2;
const CHANNEL_USER_TYPE_IEDGE = 3;
const CHANNEL_USER_TYPE_INVENTORY = 4;
public function AddInfo($SupplierID = '', $data = '')
{
......
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