Commit 0dad2b95 by 杨树贤

完成京东采购员需求

parent 1e6380d8
# Add directories or file patterns to ignore during indexing (e.g. foo/ or *.csv)
vendor/
...@@ -10,6 +10,7 @@ use Illuminate\Http\Response; ...@@ -10,6 +10,7 @@ use Illuminate\Http\Response;
use App\Http\Services\CrmService; use App\Http\Services\CrmService;
use App\Http\Services\LogService; use App\Http\Services\LogService;
use App\Model\SupplierChannelModel; use App\Model\SupplierChannelModel;
use App\Model\SupplierContactModel;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use App\Http\Services\CompanyService; use App\Http\Services\CompanyService;
...@@ -183,7 +184,6 @@ class SupplierApiController extends Controller ...@@ -183,7 +184,6 @@ class SupplierApiController extends Controller
//待确认要透传到数据库里面去 //待确认要透传到数据库里面去
if ($checkCompanyEntity == 0) { if ($checkCompanyEntity == 0) {
$channel['is_entity'] = 0; $channel['is_entity'] = 0;
} }
if ($checkCompanyEntity == -1) { if ($checkCompanyEntity == -1) {
$this->response(-1, '该供应商为实体名单,不允许建档'); $this->response(-1, '该供应商为实体名单,不允许建档');
...@@ -450,57 +450,56 @@ class SupplierApiController extends Controller ...@@ -450,57 +450,56 @@ class SupplierApiController extends Controller
} }
//分配采购员(支持批量操作) //分配采购员(支持批量操作)
public function AllocateChannelUser($request) public function BatchAllocateChannelUser($request)
{ {
$channelUid = $request->get('channel_uid'); $channelUid = $request->get('channel_uid');
$supplierId = $request->get('supplier_id'); $channelUserType = $request->get('channel_user_type');
$supplierIds = $request->get('supplier_ids');
$supplierIds = explode(',', $supplierIds);
if (empty($channelUid)) { if (empty($channelUid)) {
$this->response(-1, '采购员不能为空'); $this->response(-1, '采购员不能为空');
} }
if (empty($channelUserType)) {
$this->response(-1, '采购员类型不能为空');
}
$channelUserTypeList = explode(',', $channelUserType);
$adminService = new AdminUserService(); $adminService = new AdminUserService();
foreach ($supplierIds as $supplierId) {
foreach ($channelUserTypeList as $channelUserType) {
if ($channelUserType == SupplierContactModel::CHANNEL_USER_TYPE_LIEXIN) {
$check = $adminService->checkIsResignedByCodeId($channelUid); $check = $adminService->checkIsResignedByCodeId($channelUid);
if ($check) { if ($check) {
$this->response(-1, '该采购员已经离职,请选择其他人员'); $this->response(-1, '该采购员已经离职,请选择其他人员');
} }
$model = new SupplierChannelModel(); //判断联系人里面是否存在对应类型的采购员
$supplier = $model->where('supplier_id', $supplierId)->first(); $contactModel = new SupplierContactModel();
$supplier = $supplier ? $supplier->toArray() : []; $contact = $contactModel->where('supplier_id', $supplierId)->where('channel_user_type', $channelUserType)->where('can_check_uids', $channelUid)->first();
$preChannelUid = $supplier['channel_uid']; if ($contact) {
$preChannelUid = explode(',', $preChannelUid); $this->response(-1, '该供应商已经存在同名的猎芯采购员,请选择其他人员');
//如果之前已经存在对应的采购,直接返回错误
if (in_array($channelUid, $preChannelUid)) {
$this->response(-1, '此采购员已经存在,请重新选择');
} }
$service = new SupplierService(); $service = new SupplierService();
$result = $service->allocateChannelUser($supplierId, $channelUid); $result = $service->allocateChannelUser($supplierId, $channelUid, $channelUserType);
if (!$result) { } else {
$this->response(-1, '添加采购员失败');
}
$this->response(0, '添加采购员成功');
}
//分配采购员(支持批量操作)
public function BatchAllocateChannelUser($request)
{
$channelUid = $request->get('channel_uid');
$supplierIds = $request->get('supplier_ids');
if (empty($channelUid)) {
$this->response(-1, '采购员不能为空');
}
$adminService = new AdminUserService();
$check = $adminService->checkIsResignedByCodeId($channelUid); $check = $adminService->checkIsResignedByCodeId($channelUid);
if ($check) { if ($check) {
$this->response(-1, '该采购员已经离职,请选择其他人员'); $this->response(-1, '该采购员已经离职,请选择其他人员');
} }
$supplierIds = explode(',', $supplierIds); $contactModel = new SupplierContactModel();
foreach ($supplierIds as $supplierId) { $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(); $service = new SupplierService();
$result = $service->allocateChannelUser($supplierId, $channelUid); $result = $service->allocateChannelUser($supplierId, $channelUid, $channelUserType);
if (!$result) { }
$this->response(-1, '添加采购员失败');
} }
} }
if (!$result) {
$this->response(-1, '添加采购员失败');
}
$this->response(0, '添加采购员成功'); $this->response(0, '添加采购员成功');
} }
......
...@@ -39,12 +39,11 @@ class SupplierContactApiController extends Controller ...@@ -39,12 +39,11 @@ class SupplierContactApiController extends Controller
//大家都可以查看离职的采购员的联系人 //大家都可以查看离职的采购员的联系人
$allCanCheckUids = SupplierContactModel::where('supplier_id', $supplierId)->pluck('can_check_uids')->toArray(); $allCanCheckUids = SupplierContactModel::where('supplier_id', $supplierId)->pluck('can_check_uids')->toArray();
$resignedUsers = (new AdminUserService())->getResignedUsers(); $resignedUsers = (new AdminUserService())->getResignedUsers();
// $resignedUserCodes = array_column($resignedUsers, 'code_id'); // $resignedUserCodes = array_column($resignedUsers, 'code_id');
$resignedUserCodes = []; $resignedUserCodes = [];
$resignedCanCheckUids = array_intersect($allCanCheckUids, $resignedUserCodes); $resignedCanCheckUids = array_intersect($allCanCheckUids, $resignedUserCodes);
//不能查看所有的,就是说只能看绑定的采购的 //不能查看所有的,就是说只能看绑定的采购的
if ($canViewAllSupplierContact) { if ($canViewAllSupplierContact) {
} elseif ($canViewSubordinateSupplierContact) { } elseif ($canViewSubordinateSupplierContact) {
//查看下级 //查看下级
$departmentService = new DepartmentService(); $departmentService = new DepartmentService();
...@@ -92,6 +91,7 @@ class SupplierContactApiController extends Controller ...@@ -92,6 +91,7 @@ class SupplierContactApiController extends Controller
'supplier_mobile', 'supplier_mobile',
'supplier_email', 'supplier_email',
'supplier_position', 'supplier_position',
'channel_user_type',
'can_check_uids' 'can_check_uids'
]); ]);
$data = BatchTrim($data); $data = BatchTrim($data);
...@@ -103,7 +103,7 @@ class SupplierContactApiController extends Controller ...@@ -103,7 +103,7 @@ class SupplierContactApiController extends Controller
$this->response(-1, $validateResult); $this->response(-1, $validateResult);
} }
$service = new SupplierContactService(); $service = new SupplierContactService();
$hasNeedReplaceContact = $service->getNeedReplaceContact($data['supplier_id'], $data['can_check_uids']); $hasNeedReplaceContact = $service->getNeedReplaceContact($data['supplier_id'], $data['can_check_uids'], $data['channel_user_type']);
$result = $service->saveContact($data); $result = $service->saveContact($data);
if (!$result) { if (!$result) {
$this->response(-1, '操作失败'); $this->response(-1, '操作失败');
...@@ -111,7 +111,8 @@ class SupplierContactApiController extends Controller ...@@ -111,7 +111,8 @@ class SupplierContactApiController extends Controller
//有需要自动替换补全数据操作后的提示 //有需要自动替换补全数据操作后的提示
if ($hasNeedReplaceContact) { if ($hasNeedReplaceContact) {
$this->response(0, '系统检测到当前采购有默认的空联系人,直接更新对应数据'); $channelUserTypeName = array_get(config('field.ChannelUserType'), $data['channel_user_type']);
$this->response(0, '系统检测到当前采购(' . $channelUserTypeName . ')有默认的空联系人,直接更新对应数据');
} else { } else {
$this->response(0, '保存成功'); $this->response(0, '保存成功');
} }
...@@ -130,8 +131,10 @@ class SupplierContactApiController extends Controller ...@@ -130,8 +131,10 @@ class SupplierContactApiController extends Controller
//从主表里面删除对应的采购 //从主表里面删除对应的采购
//先去判断这个采购是不是唯一的 //先去判断这个采购是不是唯一的
$canCheckUids = $contact['can_check_uids']; $canCheckUids = $contact['can_check_uids'];
$userNum = $model->where('supplier_id', $contact['supplier_id'])->where('can_check_uids', $userNum = $model->where('supplier_id', $contact['supplier_id'])->where(
$canCheckUids)->count(); 'can_check_uids',
$canCheckUids
)->count();
if ($userNum === 1) { if ($userNum === 1) {
//如果只有一个,那就可以去主表删除对应的采购员了 //如果只有一个,那就可以去主表删除对应的采购员了
$supplierModel = new SupplierChannelModel(); $supplierModel = new SupplierChannelModel();
...@@ -168,8 +171,10 @@ class SupplierContactApiController extends Controller ...@@ -168,8 +171,10 @@ class SupplierContactApiController extends Controller
$type = $request->input('type'); $type = $request->input('type');
$contact = SupplierContactModel::select([$type, 'supplier_consignee', 'contact_id', 'supplier_id'])->where('contact_id', $contactId)->first()->toArray(); $contact = SupplierContactModel::select([$type, 'supplier_consignee', 'contact_id', 'supplier_id'])->where('contact_id', $contactId)->first()->toArray();
$logService = new LogService(); $logService = new LogService();
$content = $request->user->name . ' 查看了联系人 ' . $contact['supplier_consignee'] . ' 的' . array_get(config('field.SupplierContactFieldMap'), $content = $request->user->name . ' 查看了联系人 ' . $contact['supplier_consignee'] . ' 的' . array_get(
$type); config('field.SupplierContactFieldMap'),
$type
);
$logService->AddLog($contact['supplier_id'], LogModel::VIEW_OPERATE, '查看供应商基本资料', $content); $logService->AddLog($contact['supplier_id'], LogModel::VIEW_OPERATE, '查看供应商基本资料', $content);
$this->response(0, 'ok', $contact); $this->response(0, 'ok', $contact);
} }
...@@ -206,7 +211,8 @@ class SupplierContactApiController extends Controller ...@@ -206,7 +211,8 @@ class SupplierContactApiController extends Controller
DB::connection('web')->transaction(function () use ($supplierId, $channelUid, $originCanCheckUids, $newCanCheckUids) { DB::connection('web')->transaction(function () use ($supplierId, $channelUid, $originCanCheckUids, $newCanCheckUids) {
//还要判断是否是芯链采购员 //还要判断是否是芯链采购员
if (SupplierChannelModel::where('yunxin_channel_uid', $originCanCheckUids)->where('supplier_id', $supplierId) if (SupplierChannelModel::where('yunxin_channel_uid', $originCanCheckUids)->where('supplier_id', $supplierId)
->exists()) { ->exists()
) {
SupplierChannelModel::where('supplier_id', $supplierId)->update(['yunxin_channel_uid' => $newCanCheckUids]); SupplierChannelModel::where('supplier_id', $supplierId)->update(['yunxin_channel_uid' => $newCanCheckUids]);
} }
...@@ -226,7 +232,6 @@ class SupplierContactApiController extends Controller ...@@ -226,7 +232,6 @@ class SupplierContactApiController extends Controller
return SupplierContactModel::where('supplier_id', $supplierId)->where('can_check_uids', $originCanCheckUids) return SupplierContactModel::where('supplier_id', $supplierId)->where('can_check_uids', $originCanCheckUids)
->update(['can_check_uids' => $newCanCheckUids]); ->update(['can_check_uids' => $newCanCheckUids]);
}); });
}); });
$this->response(0, '转移供应商联系人成功'); $this->response(0, '转移供应商联系人成功');
......
...@@ -26,8 +26,7 @@ use function foo\func; ...@@ -26,8 +26,7 @@ use function foo\func;
class SupplierController extends Controller class SupplierController extends Controller
{ {
public function info(Request $request, $id = '') public function info(Request $request, $id = '')
{ { {
{
if ($request->path() == '/') { if ($request->path() == '/') {
$path = 'web/index'; $path = 'web/index';
} else { } else {
...@@ -81,13 +80,16 @@ class SupplierController extends Controller ...@@ -81,13 +80,16 @@ class SupplierController extends Controller
} }
$this->data['statusData'] = $statusData; $this->data['statusData'] = $statusData;
$stockupTypeData = []; $stockupTypeData = [];
foreach (config('fixed.StockupType') as $key => $value) { $stockupTypeList = config('fixed.StockupType');
sort($stockupTypeList, SORT_ASC);
foreach ($stockupTypeList as $key => $value) {
$stockupTypeData[] = [ $stockupTypeData[] = [
'name' => $value, 'name' => $value,
'value' => $key, 'value' => $key,
]; ];
} }
$this->data['stockupTypeData'] = $stockupTypeData; $this->data['stockupTypeData'] = $stockupTypeData;
$levelData = []; $levelData = [];
foreach (config('field.LevelMap') as $key => $value) { foreach (config('field.LevelMap') as $key => $value) {
$levelData[] = [ $levelData[] = [
...@@ -173,7 +175,7 @@ class SupplierController extends Controller ...@@ -173,7 +175,7 @@ class SupplierController extends Controller
//省市区数据放到script模板 //省市区数据放到script模板
$regionService = new RegionService(); $regionService = new RegionService();
$this->data['region_data'] = $regionService->getCityRegionData(); $this->data['region_data'] = $regionService->getCityRegionData();
$this->data['nationList'] = NationModel::pluck('name_cn','nation_id')->toArray(); $this->data['nationList'] = NationModel::pluck('name_cn', 'nation_id')->toArray();
$this->data['brand_init_value'] = []; $this->data['brand_init_value'] = [];
$this->data['agency_brand_init_value'] = []; $this->data['agency_brand_init_value'] = [];
//编辑 //编辑
...@@ -181,8 +183,11 @@ class SupplierController extends Controller ...@@ -181,8 +183,11 @@ class SupplierController extends Controller
$this->data['title'] = '编辑供应商'; $this->data['title'] = '编辑供应商';
$this->data['supplierInfo'] = $supplierService->getSupplier($supplierId); $this->data['supplierInfo'] = $supplierService->getSupplier($supplierId);
$DB = DB::connection('yunxin'); $DB = DB::connection('yunxin');
$supplierAccountInfo = $DB->table('supplier_account')->where("supplier_com_id", "=", $supplierAccountInfo = $DB->table('supplier_account')->where(
$supplierId)->select('mobile', "password_raw")->first(); "supplier_com_id",
"=",
$supplierId
)->select('mobile', "password_raw")->first();
$this->data['supplier_account_info'] = $supplierAccountInfo; $this->data['supplier_account_info'] = $supplierAccountInfo;
$this->data['address'] = $supplierService->getAddress($supplierId); $this->data['address'] = $supplierService->getAddress($supplierId);
} else { } else {
...@@ -237,8 +242,10 @@ class SupplierController extends Controller ...@@ -237,8 +242,10 @@ class SupplierController extends Controller
]); ]);
$this->data['supplier'] = $supplier; $this->data['supplier'] = $supplier;
$this->data['address'] = $supplierService->getAddress($supplierId); $this->data['address'] = $supplierService->getAddress($supplierId);
$this->data['ignore_supplier_type_change_tips'] = in_array($supplier['supplier_name'], $this->data['ignore_supplier_type_change_tips'] = in_array(
config('field.SkipChangeSupplierTypeNames')); $supplier['supplier_name'],
config('field.SkipChangeSupplierTypeNames')
);
$this->data['sku_upload_log_count'] = (new SkuUploadLogService())->getSkuUploadLogCount($supplierId); $this->data['sku_upload_log_count'] = (new SkuUploadLogService())->getSkuUploadLogCount($supplierId);
$this->data['brand_init_value'] = (new StandardBrandService())->getBrandInitValue($supplier['main_brands']); $this->data['brand_init_value'] = (new StandardBrandService())->getBrandInitValue($supplier['main_brands']);
$this->data['exclude_brand_init_value'] = (new StandardBrandService())->getBrandInitValue($supplier['main_brands']); $this->data['exclude_brand_init_value'] = (new StandardBrandService())->getBrandInitValue($supplier['main_brands']);
...@@ -317,6 +324,14 @@ class SupplierController extends Controller ...@@ -317,6 +324,14 @@ class SupplierController extends Controller
$this->data['suppliers'] = $suppliers; $this->data['suppliers'] = $suppliers;
$intraCodeModel = new IntracodeModel(); $intraCodeModel = new IntracodeModel();
$this->data['userCodes'] = $intraCodeModel->getChannelUsersEncode(false); $this->data['userCodes'] = $intraCodeModel->getChannelUsersEncode(false);
$channelUserTypeForXmSelect = [];
foreach (config('field.ChannelUserType') as $key => $value) {
$channelUserTypeForXmSelect[] = [
'value' => $key,
'name' => $value,
];
}
$this->data['channelUserTypeForXmSelect'] = $channelUserTypeForXmSelect;
return $this->view('添加采购员'); return $this->view('添加采购员');
} }
...@@ -435,5 +450,4 @@ class SupplierController extends Controller ...@@ -435,5 +450,4 @@ class SupplierController extends Controller
$this->data['userCodes'] = (new IntracodeModel())->getSampleEncode(); $this->data['userCodes'] = (new IntracodeModel())->getSampleEncode();
return $this->view('供应商交接'); return $this->view('供应商交接');
} }
} }
...@@ -49,7 +49,7 @@ class SupplierContactService ...@@ -49,7 +49,7 @@ class SupplierContactService
$supplierId = $contact['supplier_id']; $supplierId = $contact['supplier_id'];
$supplierModel = new SupplierChannelModel(); $supplierModel = new SupplierChannelModel();
//去判断该供应商是否已经有相同的can_check_uids并且是空联系人 //去判断该供应商是否已经有相同的can_check_uids并且是空联系人
$needReplaceContact = $this->getNeedReplaceContact($supplierId, $contact['can_check_uids']); $needReplaceContact = $this->getNeedReplaceContact($supplierId, $contact['can_check_uids'], $contact['channel_user_type']);
if (!empty($contact['contact_id'])) { if (!empty($contact['contact_id'])) {
$contact['update_time'] = time(); $contact['update_time'] = time();
$contactId = $contact['contact_id']; $contactId = $contact['contact_id'];
...@@ -103,7 +103,7 @@ class SupplierContactService ...@@ -103,7 +103,7 @@ class SupplierContactService
//判断是否需要替换掉空的联系方式而不是新增,因为新增的时候,可能添加的采购已经在数据库有了(之前从金蝶导过来的) //判断是否需要替换掉空的联系方式而不是新增,因为新增的时候,可能添加的采购已经在数据库有了(之前从金蝶导过来的)
//有的话,就把这次新增的联系方式更新到这个采购里面去 //有的话,就把这次新增的联系方式更新到这个采购里面去
public function getNeedReplaceContact($supplierId, $canCheckUids) public function getNeedReplaceContact($supplierId, $canCheckUids, $channelUserType)
{ {
$contactModel = new SupplierContactModel(); $contactModel = new SupplierContactModel();
$contact = $contactModel->where('supplier_id', $supplierId)->where('can_check_uids', $canCheckUids) $contact = $contactModel->where('supplier_id', $supplierId)->where('can_check_uids', $canCheckUids)
...@@ -111,7 +111,9 @@ class SupplierContactService ...@@ -111,7 +111,9 @@ class SupplierContactService
->where('supplier_position', '') ->where('supplier_position', '')
->where('supplier_email', '') ->where('supplier_email', '')
->where('supplier_mobile', '') ->where('supplier_mobile', '')
->where('supplier_telephone', '')->first(); ->where('supplier_telephone', '')
->where('channel_user_type', $channelUserType)
->first();
return !empty($contact) ? $contact->toArray() : []; return !empty($contact) ? $contact->toArray() : [];
} }
......
...@@ -629,19 +629,18 @@ class SupplierService ...@@ -629,19 +629,18 @@ class SupplierService
} }
//分配采购员 //分配采购员
public function allocateChannelUser($supplierId, $channelUid, $needLog = true) public function allocateChannelUser($supplierId, $channelUid, $channelUserType, $needLog = true)
{ {
$supplier = SupplierChannelModel::where('supplier_id', $supplierId)->first(); $supplier = SupplierChannelModel::where('supplier_id', $supplierId)->first();
if (empty($supplier)) { if (empty($supplier)) {
return true; return true;
} }
$supplier = $supplier->toArray(); $supplier = $supplier->toArray();
$preChannelUid = explode(',', $supplier['channel_uid']); $exists = SupplierContactModel::where('supplier_id', $supplierId)->where('channel_user_type', $channelUserType)->where('can_check_uids', $channelUid)->exists();
//如果之前已经存在对应的采购,直接返回 if ($exists) {
if (in_array($channelUid, $preChannelUid)) {
return true; return true;
} }
$result = DB::connection('web')->transaction(function () use ($supplierId, $channelUid, $needLog) { $result = DB::connection('web')->transaction(function () use ($supplierId, $channelUid, $needLog, $channelUserType) {
$supplier = SupplierChannelModel::where('supplier_id', $supplierId)->first(); $supplier = SupplierChannelModel::where('supplier_id', $supplierId)->first();
$supplier = $supplier ? $supplier->toArray() : []; $supplier = $supplier ? $supplier->toArray() : [];
$preChannelUid = $supplier['channel_uid']; $preChannelUid = $supplier['channel_uid'];
...@@ -659,16 +658,18 @@ class SupplierService ...@@ -659,16 +658,18 @@ class SupplierService
} else { } else {
$result = SupplierChannelModel::where('supplier_id', $supplierId)->update([ $result = SupplierChannelModel::where('supplier_id', $supplierId)->update([
'channel_uid' => $preChannelUid, 'channel_uid' => $preChannelUid,
'update_time' => time(),
]); ]);
} }
$contactResult = false; $contactResult = false;
if ($result) { if ($result !== false) {
$contactModel = new SupplierContactModel(); $contactModel = new SupplierContactModel();
$contact = [ $contact = [
'supplier_id' => $supplierId, 'supplier_id' => $supplierId,
'can_check_uids' => $channelUid, 'can_check_uids' => $channelUid,
'channel_user_type' => $channelUserType,
'add_time' => time(), 'add_time' => time(),
'admin_id' => !empty(request()->user->userId) ? request()->user->userId : 1000, 'admin_id' => !empty(request()->user->userId) ? request()->user->userId : 1000,
]; ];
...@@ -682,7 +683,8 @@ class SupplierService ...@@ -682,7 +683,8 @@ class SupplierService
$channelUser = $adminUserService->getAdminUserInfoByCodeId($channelUid); $channelUser = $adminUserService->getAdminUserInfoByCodeId($channelUid);
$channelUserName = array_get($channelUser, 'name', ' '); $channelUserName = array_get($channelUser, 'name', ' ');
$logService = new LogService(); $logService = new LogService();
$content = "添加采购员 : " . $channelUserName; $channelUserTypeName = array_get(config('field.ChannelUserType'), $channelUserType, '未知类型');
$content = "添加{$channelUserTypeName}采购员 : " . $channelUserName;
$logService->AddIgnoreAuditCheckLog($supplierId, LogModel::UPDATE_OPERATE, '添加采购员', $content); $logService->AddIgnoreAuditCheckLog($supplierId, LogModel::UPDATE_OPERATE, '添加采购员', $content);
} }
return $contactResult; return $contactResult;
......
...@@ -46,6 +46,7 @@ class SupplierContactTransformer ...@@ -46,6 +46,7 @@ class SupplierContactTransformer
} }
} }
$item['channel_user_type_name'] = array_get(config('field.ChannelUserType'), $item['channel_user_type']);
} }
unset($item); unset($item);
......
...@@ -35,10 +35,25 @@ class SupplierTransformer ...@@ -35,10 +35,25 @@ class SupplierTransformer
$lastUploadSkuTimes = SkuService::getUploadTimeBySupplierCodes(array_column($list, 'supplier_code'), 'last'); $lastUploadSkuTimes = SkuService::getUploadTimeBySupplierCodes(array_column($list, 'supplier_code'), 'last');
//创建人部门map //创建人部门map
$createUserDepartmentNameMap = (new DepartmentService())->getDepartmentNameMapByUserIds(array_column($list,'create_uid')); $createUserDepartmentNameMap = (new DepartmentService())->getDepartmentNameMapByUserIds(array_column($list, 'create_uid'));
//获取所有供应商id
$supplierIds = array_column($list, 'supplier_id');
//然后获取所有采购员类型为2的联系人
$contactModel = new SupplierContactModel();
$contacts = $contactModel->select(['supplier_id', 'can_check_uids'])->whereIn('supplier_id', $supplierIds)->where('channel_user_type', 2)->get()->groupBy('supplier_id');
$contacts = $contacts->toArray();
foreach ($contacts as $key => $value) {
$contacts[$key] = array_map(function ($item) use ($users) {
$item['name'] = array_get($users, $item['can_check_uids']);
return $item;
}, $value);
}
foreach ($list as &$supplier) { foreach ($list as &$supplier) {
$supplier['viewed'] = array_get($viewData, $supplier['supplier_id'], false); $supplier['viewed'] = array_get($viewData, $supplier['supplier_id'], false);
$supplier['jd_channel_user'] = trim(implode(',', array_column(array_get($contacts, $supplier['supplier_id'], []), 'name')),',');
$supplier['jd_channel_user_id'] = trim(implode(',', array_column(array_get($contacts, $supplier['supplier_id'], []), 'can_check_uids')),',');
$supplier = $this->getStockupType($supplier); $supplier = $this->getStockupType($supplier);
$supplier['supplier_group'] = array_get(config('fixed.SupplierGroup'), $supplier['supplier_group'], '未设置'); $supplier['supplier_group'] = array_get(config('fixed.SupplierGroup'), $supplier['supplier_group'], '未设置');
$supplier['purchase_type_name'] = array_get(config('field.PurchaseType'), $supplier['purchase_type'], '无'); $supplier['purchase_type_name'] = array_get(config('field.PurchaseType'), $supplier['purchase_type'], '无');
...@@ -103,23 +118,35 @@ class SupplierTransformer ...@@ -103,23 +118,35 @@ class SupplierTransformer
$onJobUserNameList = array_values($onJobChannelUsers); $onJobUserNameList = array_values($onJobChannelUsers);
$channelUserNameList = !empty($supplier['channel_username']) ? explode(',', $channelUserNameList = !empty($supplier['channel_username']) ? explode(',',
$supplier['channel_username']) : []; $supplier['channel_username']) : [];
$jdChannelUserNameList = !empty($supplier['jd_channel_user']) ? explode(',',
$supplier['jd_channel_user']) : [];
if (empty($supplier['channel_uid'])) { if (empty($supplier['channel_uid'])) {
$supplier['resign_channel_username'] = $supplier['on_job_channel_username'] = ''; $supplier['resign_channel_username'] = $supplier['on_job_channel_username'] = '';
continue; continue;
} }
$resignChannelUserNameList = $onJobChannelUserNameList = []; $resignChannelUserNameList = $onJobChannelUserNameList = [];
$jdResignChannelUserNameList = $jdOnJobChannelUserNameList = [];
if (!empty($supplier['jd_channel_user_id'])) {
//然后判断哪些是离职,哪些是在职的 //然后判断哪些是离职,哪些是在职的
foreach ($channelUserNameList as $username) { foreach ($jdChannelUserNameList as $username) {
if (!in_array($username, $onJobUserNameList)) { if (!in_array($username, $onJobUserNameList)) {
$resignChannelUserNameList[] = $username; $resignChannelUserNameList[] = $username;
} else { } else {
$onJobChannelUserNameList[] = $username; $onJobChannelUserNameList[] = $username;
} }
} }
}
$supplier['resign_channel_username'] = $resignChannelUserNameList ? implode(',', $supplier['resign_channel_username'] = $resignChannelUserNameList ? implode(',',
$resignChannelUserNameList) : ''; $resignChannelUserNameList) : '';
$supplier['on_job_channel_username'] = $onJobChannelUserNameList ? implode(',', $supplier['on_job_channel_username'] = $onJobChannelUserNameList ? implode(',',
$onJobChannelUserNameList) : ''; $onJobChannelUserNameList) : '';
$supplier['jd_resign_channel_username'] = $jdResignChannelUserNameList ? implode(',',
$resignChannelUserNameList) : '';
$supplier['jd_on_job_channel_username'] = $jdOnJobChannelUserNameList ? implode(',',
$onJobChannelUserNameList) : '';
} }
unset($supplier); unset($supplier);
return $suppliers; return $suppliers;
......
...@@ -11,6 +11,9 @@ class SupplierContactModel extends Model ...@@ -11,6 +11,9 @@ class SupplierContactModel extends Model
protected $table = 'supplier_contact'; protected $table = 'supplier_contact';
public $timestamps = false; public $timestamps = false;
const CHANNEL_USER_TYPE_LIEXIN = 1;
const CHANNEL_USER_TYPE_JD = 2;
public function AddInfo($SupplierID = '', $data = '') public function AddInfo($SupplierID = '', $data = '')
{ {
if (empty($SupplierID) || empty($data) || !is_array($data)) { if (empty($SupplierID) || empty($data) || !is_array($data)) {
......
...@@ -355,5 +355,10 @@ return [ ...@@ -355,5 +355,10 @@ return [
2 => '高', 2 => '高',
1 => '中', 1 => '中',
0 => '低', 0 => '低',
] ],
'ChannelUserType' => [
1 => '猎芯采购',
2 => '京东采购',
],
]; ];
...@@ -87,6 +87,7 @@ return [ ...@@ -87,6 +87,7 @@ return [
2 => '猎芯仓库', 2 => '猎芯仓库',
4 => '现货寄售', 4 => '现货寄售',
5 => '芯链商家', 5 => '芯链商家',
6 => '京东商家',
], ],
'SupplierPayType' => [ 'SupplierPayType' => [
......
...@@ -233,6 +233,19 @@ ...@@ -233,6 +233,19 @@
{field: 'purchase_username', title: '渠道开发员', align: 'center', width: 110}, {field: 'purchase_username', title: '渠道开发员', align: 'center', width: 110},
{field: 'yunxin_channel_username', title: '线上采购员', align: 'center', width: 110}, {field: 'yunxin_channel_username', title: '线上采购员', align: 'center', width: 110},
{
field: 'jd_channel_username', title: '京东采购员', align: 'center', width: 130, templet: function (data) {
if (data.jd_resign_channel_username) {
if (data.jd_on_job_channel_username) {
return `<span>${data.jd_on_job_channel_username}</span>` + `,<span style="color: #D7D7D7">${data.jd_resign_channel_username}</span>`;
} else {
return `<span style="color: #D7D7D7">${data.jd_resign_channel_username}</span>`
}
} else {
return `<span>${data.on_job_channel_username}</span>`;
}
}
},
{field: 'has_sku', title: 'SKU上传', align: 'center', width: 80}, {field: 'has_sku', title: 'SKU上传', align: 'center', width: 80},
{ {
field: 'uploaded_sku', title: 'SKU合作', align: 'center', width: 80, templet: function (data) { field: 'uploaded_sku', title: 'SKU合作', align: 'center', width: 80, templet: function (data) {
......
...@@ -61,7 +61,7 @@ ...@@ -61,7 +61,7 @@
}, },
{field: 'supplier_fax', title: '传真', align: 'center', width: 140}, {field: 'supplier_fax', title: '传真', align: 'center', width: 140},
{field: 'channel_name', title: '<span class="require">* </span>采购员', align: 'center', width: 110}, {field: 'channel_name', title: '<span class="require">* </span>采购员', align: 'center', width: 110},
{field: 'working_status', title: '采购员状态', align: 'center', width: 120}, {field: 'channel_user_type_name', title: '<span class="require">* </span>采购员类型', align: 'center', width: 110}, {field: 'working_status', title: '采购员状态', align: 'center', width: 120},
]], ]],
id: 'contactList', id: 'contactList',
page: {}, page: {},
...@@ -73,7 +73,7 @@ ...@@ -73,7 +73,7 @@
layer.open({ layer.open({
type: 2, type: 2,
content: '/supplier_contact/AddSupplierContact?view=iframe&supplier_id=' + supplierId, content: '/supplier_contact/AddSupplierContact?view=iframe&supplier_id=' + supplierId,
area: ['600px', '525px'], area: ['600px', '625px'],
title: '新增联系人', title: '新增联系人',
end: function () { // 监听弹窗关闭 end: function () { // 监听弹窗关闭
// location.href = '/supplier/UpdateSupplier?view=iframe&tab=contact&supplier_id='+supplierId; // location.href = '/supplier/UpdateSupplier?view=iframe&tab=contact&supplier_id='+supplierId;
......
...@@ -68,6 +68,11 @@ ...@@ -68,6 +68,11 @@
$userCodes,['required'=>true]) !!} $userCodes,['required'=>true]) !!}
</div> </div>
<div class="layui-form-item"> <div class="layui-form-item">
@inject('statusPresenter','App\Presenters\StatusPresenter')
{!! $statusPresenter->render('channel_user_type','采购员类型','',
config('field.ChannelUserType'),['required'=>true]) !!}
</div>
<div class="layui-form-item">
<div align="center" style="margin-top: 20px"> <div align="center" style="margin-top: 20px">
<button type="button" class="layui-btn layui-btn-info submit-loading" lay-submit lay-filter="load">确认</button> <button type="button" class="layui-btn layui-btn-info submit-loading" lay-submit lay-filter="load">确认</button>
</div> </div>
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
} }
</style> </style>
<div class="layui-card"> <div class="layui-card">
<div class="layui-card-header" style="height: 170px"> <div class="layui-card-header" style="height: 270px">
<blockquote class="layui-elem-quote layui-text"> <blockquote class="layui-elem-quote layui-text">
<b>采购员设置</b> <b>采购员设置</b>
</blockquote> </blockquote>
...@@ -18,6 +18,13 @@ ...@@ -18,6 +18,13 @@
</div> </div>
</div> </div>
<div class="layui-form-item"> <div class="layui-form-item">
<div class="layui-inline" style="margin-left: -30px">
@inject('multiSelectPresenter','App\Presenters\MultiSelectorPresenter')
{!! $multiSelectPresenter->render('channel_user_type','采购员类型',1,
$channelUserTypeForXmSelect,['required'=>true,'width'=>'150px']) !!}
</div>
</div>
<div class="layui-form-item">
<div align="center" style="margin-top: 10px;text-align: right"> <div align="center" style="margin-top: 10px;text-align: right">
<button type="button" class="layui-btn layui-btn-sm layui-btn-info submit-loading" lay-submit <button type="button" class="layui-btn layui-btn-sm layui-btn-info submit-loading" lay-submit
lay-filter="auditSupplier">确认 lay-filter="auditSupplier">确认
......
...@@ -70,6 +70,11 @@ ...@@ -70,6 +70,11 @@
$userCodes,['required'=>true]) !!} $userCodes,['required'=>true]) !!}
</div> </div>
<div class="layui-form-item"> <div class="layui-form-item">
@inject('statusPresenter','App\Presenters\StatusPresenter')
{!! $statusPresenter->render('channel_user_type','采购员类型',$contact['channel_user_type'],
config('field.ChannelUserType'),['required'=>true]) !!}
</div>
<div class="layui-form-item">
<div align="center" style="margin-top: 20px"> <div align="center" style="margin-top: 20px">
<button type="button" class="layui-btn layui-btn-info submit-loading" lay-submit lay-filter="load">确认</button> <button type="button" class="layui-btn layui-btn-info submit-loading" lay-submit lay-filter="load">确认</button>
</div> </div>
......
...@@ -35,11 +35,12 @@ ...@@ -35,11 +35,12 @@
<?php /* 拉黑*/ ?> <?php /* 拉黑*/ ?>
<?php /* </button>*/ ?> <?php /* </button>*/ ?>
<?php endif; ?> <?php endif; ?>
<?php if(request()->user->userId==1000 || request()->user->userId==2082): ?>
<button type="button" class="layui-btn layui-btn-sm" title="该操作可以将供应商同步到供应商" <button type="button" class="layui-btn layui-btn-sm" title="该操作可以将供应商同步到供应商"
id="sync_supplier_to_erp"> id="sync_supplier_to_erp">
金蝶同步 金蝶同步
</button> </button>
<?php if(request()->user->userId==1000 || request()->user->userId==2082): ?>
<button type="button" class="layui-btn layui-btn-sm" title="该操作可以将供应商同步到一体化" <button type="button" class="layui-btn layui-btn-sm" title="该操作可以将供应商同步到一体化"
id="sync_supplier_to_united"> id="sync_supplier_to_united">
一体化同步 一体化同步
......
...@@ -233,6 +233,19 @@ ...@@ -233,6 +233,19 @@
{field: 'purchase_username', title: '渠道开发员', align: 'center', width: 110}, {field: 'purchase_username', title: '渠道开发员', align: 'center', width: 110},
{field: 'yunxin_channel_username', title: '线上采购员', align: 'center', width: 110}, {field: 'yunxin_channel_username', title: '线上采购员', align: 'center', width: 110},
{
field: 'jd_channel_username', title: '京东采购员', align: 'center', width: 130, templet: function (data) {
if (data.jd_resign_channel_username) {
if (data.jd_on_job_channel_username) {
return `<span>${data.jd_on_job_channel_username}</span>` + `,<span style="color: #D7D7D7">${data.jd_resign_channel_username}</span>`;
} else {
return `<span style="color: #D7D7D7">${data.jd_resign_channel_username}</span>`
}
} else {
return `<span>${data.on_job_channel_username}</span>`;
}
}
},
{field: 'has_sku', title: 'SKU上传', align: 'center', width: 80}, {field: 'has_sku', title: 'SKU上传', align: 'center', width: 80},
{ {
field: 'uploaded_sku', title: 'SKU合作', align: 'center', width: 80, templet: function (data) { field: 'uploaded_sku', title: 'SKU合作', align: 'center', width: 80, templet: function (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