Commit bf1160c9 by 杨树贤

显示跟单采购员

parent 54c1cad7
...@@ -36,9 +36,6 @@ class SupplierService ...@@ -36,9 +36,6 @@ class SupplierService
if (!empty($map['is_export'])) { if (!empty($map['is_export'])) {
$list = $query->get()->toArray(); $list = $query->get()->toArray();
} else { } else {
// $sql = $query->toSql();
// $bindings = $query->getBindings();
// dd($sql, $bindings);
$list = $query->paginate($limit)->toArray(); $list = $query->paginate($limit)->toArray();
$transformer = new SupplierTransformer(); $transformer = new SupplierTransformer();
$list['data'] = $transformer->transformList($list['data']); $list['data'] = $transformer->transformList($list['data']);
......
...@@ -40,22 +40,41 @@ class SupplierTransformer ...@@ -40,22 +40,41 @@ class SupplierTransformer
//获取所有供应商id //获取所有供应商id
$supplierIds = array_column($list, 'supplier_id'); $supplierIds = array_column($list, 'supplier_id');
//然后获取所有采购员类型为2的联系人 //然后获取所有采购员类型为2(京东)和4(跟货采购员)的联系人
$jdContacts = $inventoryContacts = [];
$contactModel = new SupplierContactModel(); $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 = $contactModel->select(['supplier_id', 'can_check_uids', 'channel_user_type'])->whereIn('supplier_id', $supplierIds)->whereIn('channel_user_type', [2, 4])->get()->groupBy('supplier_id');
$contacts = $contacts->toArray(); $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);
}
$hasOrderContractMap = SupplierContractService::hasOrderContractMap($supplierIds); $hasOrderContractMap = SupplierContractService::hasOrderContractMap($supplierIds);
foreach ($list as &$supplier) { foreach ($list as &$supplier) {
$supplierContacts = array_get($contacts, $supplier['supplier_id'], []);
$jdContacts = $inventoryContacts = [];
foreach ($supplierContacts as $value) {
if ($value['channel_user_type'] == 2) {
$jdContacts[] = $value;
} elseif ($value['channel_user_type'] == 4) {
$inventoryContacts[] = $value;
}
}
// 处理京东联系人
$jdContacts = array_map(function ($item) use ($users) {
$item['name'] = array_get($users, $item['can_check_uids']);
return $item;
}, $jdContacts);
// 处理跟货采购员联系人
$inventoryContacts = array_map(function ($item) use ($users) {
$item['name'] = array_get($users, $item['can_check_uids']);
return $item;
}, $inventoryContacts);
$supplier['has_order_contract'] = array_get($hasOrderContractMap, $supplier['supplier_id'], -1); $supplier['has_order_contract'] = array_get($hasOrderContractMap, $supplier['supplier_id'], -1);
$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['jd_channel_user'] = trim(implode(',', array_column($jdContacts, 'name')), ',');
$supplier['jd_channel_user_id'] = trim(implode(',', array_column($jdContacts, 'can_check_uids')), ',');
$supplier['inventory_channel_user'] = trim(implode(',', array_column($inventoryContacts, 'name')), ',');
$supplier['inventory_channel_user_id'] = trim(implode(',', array_column($inventoryContacts, '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'], '无');
...@@ -89,12 +108,13 @@ class SupplierTransformer ...@@ -89,12 +108,13 @@ class SupplierTransformer
$supplier['create_name'] = array_get($userInfo, 'name'); $supplier['create_name'] = array_get($userInfo, 'name');
} }
$supplier['sign_com_name'] = array_get(CrmService::getSignCompanyListMap(), $supplier['sign_com_id']); $supplier['sign_com_name'] = array_get(CrmService::getSignCompanyListMap(), $supplier['sign_com_id']);
$supplier['last_upload_sku_time'] = array_get($lastUploadSkuTimes, $supplier['supplier_code']) ? date('Y-m-d H:i:s', $supplier['last_upload_sku_time'] = array_get($lastUploadSkuTimes, $supplier['supplier_code']) ? date(
$lastUploadSkuTimes[$supplier['supplier_code']]) : ''; 'Y-m-d H:i:s',
$lastUploadSkuTimes[$supplier['supplier_code']]
) : '';
//创建时间和最后上传时间互相补充 //创建时间和最后上传时间互相补充
$supplier['last_upload_sku_time'] = $supplier['last_upload_sku_time'] ?: $supplier['sku_create_time']; $supplier['last_upload_sku_time'] = $supplier['last_upload_sku_time'] ?: $supplier['sku_create_time'];
//$supplier['sku_create_time'] = $supplier['sku_create_time'] ?: $supplier['last_upload_sku_time'];
//获取最新修改人以及下级审核员 //获取最新修改人以及下级审核员
$log = LogModel::getLastLog($supplier['supplier_id']); $log = LogModel::getLastLog($supplier['supplier_id']);
...@@ -107,7 +127,7 @@ class SupplierTransformer ...@@ -107,7 +127,7 @@ class SupplierTransformer
$supplier['blacklist_reason'] = $supplier['blacklist']['reason']; $supplier['blacklist_reason'] = $supplier['blacklist']['reason'];
} }
//创建人部门 //创建人部门
$supplier['create_user_department_name'] = array_get($createUserDepartmentNameMap,$supplier['create_uid']); $supplier['create_user_department_name'] = array_get($createUserDepartmentNameMap, $supplier['create_uid']);
} }
unset($supplier); unset($supplier);
return $list; return $list;
...@@ -119,20 +139,26 @@ class SupplierTransformer ...@@ -119,20 +139,26 @@ class SupplierTransformer
foreach ($suppliers as &$supplier) { foreach ($suppliers as &$supplier) {
$onJobChannelUsers = (new IntracodeModel())->getSampleEncode(); $onJobChannelUsers = (new IntracodeModel())->getSampleEncode();
$onJobUserNameList = array_values($onJobChannelUsers); $onJobUserNameList = array_values($onJobChannelUsers);
$channelUserNameList = !empty($supplier['channel_username']) ? explode(',', $channelUserNameList = !empty($supplier['channel_username']) ? explode(
$supplier['channel_username']) : []; ',',
$jdChannelUserNameList = !empty($supplier['jd_channel_user']) ? explode(',', $supplier['channel_username']
$supplier['jd_channel_user']) : []; ) : [];
if (empty($supplier['channel_uid'])) { $jdChannelUserNameList = !empty($supplier['jd_channel_user']) ? explode(
$supplier['resign_channel_username'] = $supplier['on_job_channel_username'] = ''; ',',
continue; $supplier['jd_channel_user']
} ) : [];
$inventoryChannelUserNameList = !empty($supplier['inventory_channel_user']) ? explode(
',',
$supplier['inventory_channel_user']
) : [];
$resignChannelUserNameList = $onJobChannelUserNameList = []; $resignChannelUserNameList = $onJobChannelUserNameList = [];
$jdResignChannelUserNameList = $jdOnJobChannelUserNameList = []; $jdResignChannelUserNameList = $jdOnJobChannelUserNameList = [];
$inventoryResignChannelUser = $inventoryOnJobChannelUser = [];
if (!empty($supplier['jd_channel_user_id'])) { if (!empty($supplier['jd_channel_user_id'])) {
//然后判断哪些是离职,哪些是在职的 //然后判断哪些是离职,哪些是在职的
foreach ($jdChannelUserNameList as $username) { foreach ($jdChannelUserNameList as $username) {
if (!in_array($username, $onJobUserNameList)) { if (!in_array($username, $onJobUserNameList)) {
$jdResignChannelUserNameList[] = $username; $jdResignChannelUserNameList[] = $username;
} else { } else {
...@@ -144,22 +170,49 @@ class SupplierTransformer ...@@ -144,22 +170,49 @@ class SupplierTransformer
if (!empty($supplier['channel_uid'])) { if (!empty($supplier['channel_uid'])) {
//然后判断哪些是离职,哪些是在职的 //然后判断哪些是离职,哪些是在职的
foreach ($channelUserNameList as $username) { foreach ($channelUserNameList 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(',', if (!empty($supplier['inventory_channel_user_id'])) {
$resignChannelUserNameList) : ''; //然后判断哪些是离职,哪些是在职的
$supplier['on_job_channel_username'] = $onJobChannelUserNameList ? implode(',', foreach ($inventoryChannelUserNameList as $username) {
$onJobChannelUserNameList) : ''; if (!in_array($username, $onJobUserNameList)) {
$supplier['jd_resign_channel_username'] = $jdResignChannelUserNameList ? implode(',', $inventoryResignChannelUser[] = $username;
$jdResignChannelUserNameList) : ''; } else {
$supplier['jd_on_job_channel_username'] = $jdOnJobChannelUserNameList ? implode(',', $inventoryOnJobChannelUser[] = $username;
$jdOnJobChannelUserNameList) : ''; }
}
}
$supplier['resign_channel_username'] = $resignChannelUserNameList ? implode(
',',
$resignChannelUserNameList
) : '';
$supplier['on_job_channel_username'] = $onJobChannelUserNameList ? implode(
',',
$onJobChannelUserNameList
) : '';
$supplier['jd_resign_channel_username'] = $jdResignChannelUserNameList ? implode(
',',
$jdResignChannelUserNameList
) : '';
$supplier['jd_on_job_channel_username'] = $jdOnJobChannelUserNameList ? implode(
',',
$jdOnJobChannelUserNameList
) : '';
$supplier['inventory_resign_channel_username'] = $inventoryResignChannelUser ? implode(
',',
$inventoryResignChannelUser
) : '';
$supplier['inventory_on_job_channel_username'] = $inventoryOnJobChannelUser ? implode(
',',
$inventoryOnJobChannelUser
) : '';
} }
unset($supplier); unset($supplier);
return $suppliers; return $suppliers;
...@@ -216,8 +269,10 @@ class SupplierTransformer ...@@ -216,8 +269,10 @@ class SupplierTransformer
$intraCodeModel = new IntracodeModel(); $intraCodeModel = new IntracodeModel();
$users = $intraCodeModel->getSampleEncode(true); $users = $intraCodeModel->getSampleEncode(true);
$supplier['stockup_type_data'] = $this->transformStockupTypeData($supplier['stockup_type']); $supplier['stockup_type_data'] = $this->transformStockupTypeData($supplier['stockup_type']);
$supplier['established_time'] = !empty($supplier['established_time']) ? date('Y-m-d', $supplier['established_time'] = !empty($supplier['established_time']) ? date(
$supplier['established_time']) : ''; 'Y-m-d',
$supplier['established_time']
) : '';
$supplier = $this->getStockupType($supplier); $supplier = $this->getStockupType($supplier);
$supplier['sign_com_name'] = array_get(CrmService::getSignCompanyListMap(), $supplier['sign_com_id']); $supplier['sign_com_name'] = array_get(CrmService::getSignCompanyListMap(), $supplier['sign_com_id']);
$supplier['status_name'] = array_get(config('fixed.SupplierStatus'), $supplier['status']); $supplier['status_name'] = array_get(config('fixed.SupplierStatus'), $supplier['status']);
...@@ -256,10 +311,15 @@ class SupplierTransformer ...@@ -256,10 +311,15 @@ class SupplierTransformer
//获取最近修改信息 //获取最近修改信息
$log = LogModel::getLastLog($supplier['supplier_id']); $log = LogModel::getLastLog($supplier['supplier_id']);
$supplier['last_update_name'] = $log['admin_name'] ?: '无'; $supplier['last_update_name'] = $log['admin_name'] ?: '无';
$supplier['last_update_time'] = empty($supplier['last_update_time']) ? ($log['add_time'] ? date('Y-m-d H:i:s', $supplier['last_update_time'] = empty($supplier['last_update_time']) ? ($log['add_time'] ? date(
$log['add_time']) : '无') : '无'; 'Y-m-d H:i:s',
$supplier['has_certification_name'] = array_get(config('fixed.CertificationStatus'), $log['add_time']
array_get($supplier, 'has_certification', ''), ''); ) : '无') : '无';
$supplier['has_certification_name'] = array_get(
config('fixed.CertificationStatus'),
array_get($supplier, 'has_certification', ''),
''
);
$supplier['sku_tag_name'] = array_get(config('field.SkuTag'), array_get($supplier, 'sku_tag', ''), '无'); $supplier['sku_tag_name'] = array_get(config('field.SkuTag'), array_get($supplier, 'sku_tag', ''), '无');
$supplier['sku_mode_name'] = array_get(config('field.SkuMode'), array_get($supplier, 'sku_mode', ''), '无'); $supplier['sku_mode_name'] = array_get(config('field.SkuMode'), array_get($supplier, 'sku_mode', ''), '无');
$supplier['purchase_type_name'] = array_get(config('field.PurchaseType'), $supplier['purchase_type'], '无'); $supplier['purchase_type_name'] = array_get(config('field.PurchaseType'), $supplier['purchase_type'], '无');
...@@ -434,5 +494,4 @@ class SupplierTransformer ...@@ -434,5 +494,4 @@ class SupplierTransformer
} }
return implode(',', $skuOptionalBatchText); return implode(',', $skuOptionalBatchText);
} }
} }
...@@ -368,6 +368,7 @@ return [ ...@@ -368,6 +368,7 @@ return [
1 => '猎芯采购', 1 => '猎芯采购',
2 => '京东采购', 2 => '京东采购',
3 => '华云采购', 3 => '华云采购',
4 => '数据跟单员',
], ],
'SkuOptionalBatch' => [ 'SkuOptionalBatch' => [
......
...@@ -269,7 +269,7 @@ ...@@ -269,7 +269,7 @@
{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) { field: 'jd_channel_username', title: '京东采购员', align: 'center', width: 130, templet: function (data) {
if (data.jd_resign_channel_username) { if (data.jd_resign_channel_username) {
if (data.jd_on_job_channel_username) { if (data.jd_on_job_channel_username) {
...@@ -282,6 +282,19 @@ ...@@ -282,6 +282,19 @@
} }
} }
}, },
{
field: 'inventory_channel_username', title: '数据跟单员', align: 'center', width: 130, templet: function (data) {
if (data.inventory_resign_channel_username) {
if (data.inventory_on_job_channel_username) {
return `<span>${data.inventory_on_job_channel_username}</span>` + `,<span style="color: #D7D7D7">${data.inventory_resign_channel_username}</span>`;
} else {
return `<span style="color: #D7D7D7">${data.inventory_resign_channel_username}</span>`
}
} else {
return `<span>${data.inventory_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) {
......
...@@ -269,7 +269,7 @@ ...@@ -269,7 +269,7 @@
{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) { field: 'jd_channel_username', title: '京东采购员', align: 'center', width: 130, templet: function (data) {
if (data.jd_resign_channel_username) { if (data.jd_resign_channel_username) {
if (data.jd_on_job_channel_username) { if (data.jd_on_job_channel_username) {
...@@ -282,6 +282,19 @@ ...@@ -282,6 +282,19 @@
} }
} }
}, },
{
field: 'inventory_channel_username', title: '数据跟单员', align: 'center', width: 130, templet: function (data) {
if (data.inventory_resign_channel_username) {
if (data.inventory_on_job_channel_username) {
return `<span>${data.inventory_on_job_channel_username}</span>` + `,<span style="color: #D7D7D7">${data.inventory_resign_channel_username}</span>`;
} else {
return `<span style="color: #D7D7D7">${data.inventory_resign_channel_username}</span>`
}
} else {
return `<span>${data.inventory_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