Commit 588f2adb by 杨树贤

供应商需求20230516

parent 821d21b5
...@@ -106,10 +106,14 @@ class SkuService ...@@ -106,10 +106,14 @@ class SkuService
$goodsTag = $redis->hget('goods_tag', $item['goods_id']); $goodsTag = $redis->hget('goods_tag', $item['goods_id']);
$goodsTag = $goodsTag ? json_decode($goodsTag, true) : ''; $goodsTag = $goodsTag ? json_decode($goodsTag, true) : '';
$item['sku_tags'] = $goodsTag ? array_get($goodsTag, 'customer_tag') : ''; $item['sku_tags'] = $goodsTag ? array_get($goodsTag, 'customer_tag') : '';
$item['source_name'] = ''; //去db找出相关数据,有些数据只能去db找....
if (!empty($item['source'])) { $dbInfo = getSpuSkuDb($item['goods_id']);
$item['source_name'] = array_get(config('field.SkuSource'), $item['source'], ''); $connection = DB::connection($dbInfo["db"]);
} $table = $dbInfo['table'];
$selectFields = ['goods_id', 'create_time', 'eccn', 'source', 'encoded'];
$skuDBData = $connection->table($table)->select($selectFields)->where('goods_id', $item['goods_id'])->first();
$skuDBData = $skuDBData ? $skuDBData : [];
$item['source_name'] = array_get(config('field.SkuSource'), $skuDBData['source'], '');
return $item; return $item;
}, $list); }, $list);
$list = $this->transformInvalidSkuTag($list); $list = $this->transformInvalidSkuTag($list);
...@@ -280,14 +284,14 @@ class SkuService ...@@ -280,14 +284,14 @@ class SkuService
//获取第一次上传sku时间和最后一次上传sku时间 //获取第一次上传sku时间和最后一次上传sku时间
public static function getUploadTimeBySupplierCodes($supplierCodes = [], $type = 'first') public static function getUploadTimeBySupplierCodes($supplierCodes = [], $type = 'first')
{ {
$supplierCodesTemp = array_map(function ($value){ $supplierCodesTemp = array_map(function ($value) {
return "'" . $value . "'"; return "'" . $value . "'";
}, $supplierCodes); }, $supplierCodes);
$supplierCodeInSql = implode(',', $supplierCodesTemp); $supplierCodeInSql = implode(',', $supplierCodesTemp);
if ($type == 'last') { if ($type == 'last') {
$rawSql = 'SELECT supplier_code,create_time FROM (SELECT supplier_code,max(create_time) AS create_time FROM lie_sku_upload_log GROUP BY supplier_code) AS temp WHERE supplier_code IN ('.$supplierCodeInSql.')'; $rawSql = 'SELECT supplier_code,create_time FROM (SELECT supplier_code,max(create_time) AS create_time FROM lie_sku_upload_log GROUP BY supplier_code) AS temp WHERE supplier_code IN (' . $supplierCodeInSql . ')';
} else { } else {
$rawSql = 'SELECT supplier_code,create_time FROM (SELECT supplier_code,min(create_time) AS create_time FROM lie_sku_upload_log GROUP BY supplier_code) AS temp WHERE supplier_code IN ('.$supplierCodeInSql.')'; $rawSql = 'SELECT supplier_code,create_time FROM (SELECT supplier_code,min(create_time) AS create_time FROM lie_sku_upload_log GROUP BY supplier_code) AS temp WHERE supplier_code IN (' . $supplierCodeInSql . ')';
} }
$data = DB::connection('spu') $data = DB::connection('spu')
->select($rawSql); ->select($rawSql);
......
...@@ -447,11 +447,25 @@ class SupplierService ...@@ -447,11 +447,25 @@ class SupplierService
{ {
$yunxinChannelUserName = (new AdminUserService())->getAdminUserNameByCodeId($yunxinChannelUid); $yunxinChannelUserName = (new AdminUserService())->getAdminUserNameByCodeId($yunxinChannelUid);
$logService = new LogService(); $logService = new LogService();
$redis = new RedisModel();
foreach ($supplierIds as $supplierId) { foreach ($supplierIds as $supplierId) {
$preYunxinChannelUid = SupplierChannelModel::where('supplier_id', $supplierId)->value('yunxin_channel_uid'); $preYunxinChannelUid = SupplierChannelModel::where('supplier_id', $supplierId)->value('yunxin_channel_uid');
SupplierChannelModel::where('supplier_id', $supplierId)->update([ SupplierChannelModel::where('supplier_id', $supplierId)->update([
'yunxin_channel_uid' => $yunxinChannelUid 'yunxin_channel_uid' => $yunxinChannelUid
]); ]);
$supplier = SupplierChannelModel::where('supplier_id', $supplierId)->first()->toArray();
//还要丢队列给批量修改sku的内部编码
$redisKey = 'lie_supplier_change_yunxin_user_' . $supplierId;
if ($redis->get($redisKey)) {
$data = [
'canal' => $supplier['supplier_code'],
"encoded" => $yunxinChannelUid,
];
//改成队列
(new SkuService())->batchUpdateEncodedQueue($data);
$redis->set($redisKey, 1);
$redis->expire($redisKey, 60 * 60 * 3);
}
$preYunxinChannelUserName = (new AdminUserService())->getAdminUserNameByCodeId($preYunxinChannelUid); $preYunxinChannelUserName = (new AdminUserService())->getAdminUserNameByCodeId($preYunxinChannelUid);
$content = "将SKU采购员由 [${preYunxinChannelUserName}] 改为 [${yunxinChannelUserName}]"; $content = "将SKU采购员由 [${preYunxinChannelUserName}] 改为 [${yunxinChannelUserName}]";
$logService->AddIgnoreAuditCheckLog($supplierId, LogModel::UPDATE_OPERATE, '分配渠道开发员', $content); $logService->AddIgnoreAuditCheckLog($supplierId, LogModel::UPDATE_OPERATE, '分配渠道开发员', $content);
......
...@@ -30,9 +30,9 @@ class SupplierAttachmentValidator ...@@ -30,9 +30,9 @@ class SupplierAttachmentValidator
$supplierGroup = SupplierChannelModel::where('supplier_id', $attachment['supplier_id']) $supplierGroup = SupplierChannelModel::where('supplier_id', $attachment['supplier_id'])
->value('supplier_group'); ->value('supplier_group');
//供应商为混合分销的时候,代理证的有效期必填 //供应商为混合分销的时候,代理证的有效期必填
if ($supplierGroup == SupplierChannelModel::SUPPLIER_GROUP_MIX && !$attachment['validity_period']) { if ($supplierGroup == SupplierChannelModel::SUPPLIER_GROUP_MIX && !$attachment['validity_period']) {
return '供应商为混合分销的时候,代理证的必须为自定义且必填'; return '供应商为混合分销的时候,代理证的必须为自定义且必填';
} }
if ($validator->fails()) { if ($validator->fails()) {
......
...@@ -150,7 +150,7 @@ class SupplierValidator ...@@ -150,7 +150,7 @@ class SupplierValidator
if (empty($validateData['supplier_type'])) { if (empty($validateData['supplier_type'])) {
return '请选择供应商类型'; return '请选择供应商类型';
} }
if ($validateData['supplier_type'] == 2 && in_array($validateData['supplier_name'], if ($validateData['supplier_type'] == SupplierChannelModel::SUPPLIER_TYPE_TEMPORARY && in_array($validateData['supplier_name'],
config('field.SkipChangeSupplierTypeNames'))) { config('field.SkipChangeSupplierTypeNames'))) {
$errorMessageList[] = '该供应商是代购供应商,不能修改为临时供应商'; $errorMessageList[] = '该供应商是代购供应商,不能修改为临时供应商';
} }
...@@ -162,10 +162,10 @@ class SupplierValidator ...@@ -162,10 +162,10 @@ class SupplierValidator
$attachmentFields = array_unique(array_get($validateData, 'field_name', [])); $attachmentFields = array_unique(array_get($validateData, 'field_name', []));
$attachmentPeriods = array_unique(array_get($validateData, 'validity_period', [])); $attachmentPeriods = array_unique(array_get($validateData, 'validity_period', []));
//这里的校验是当供应商性质为7(混合分销)的时候,代理证的有效期不能为空 //这里的校验是当供应商性质为7(混合分销)的时候,代理证的有效期不能为空
foreach ($attachmentFields as $key => $attachmentField) { foreach ($attachmentFields as $key => $attachmentField) {
if ($attachmentField == 'proxy_certificate' && empty($attachmentPeriods[$key])) { if ($attachmentField == 'proxy_certificate' && empty($attachmentPeriods[$key])) {
$errorMessageList[] = '供应商性质为混合分销时,附件中代理证的有效期为必填,请检查对应代理证的附件有效期'; $errorMessageList[] = '供应商性质为混合分销时,附件中代理证的有效期为必填,请检查对应代理证的附件有效期';
} }
} }
...@@ -205,10 +205,10 @@ class SupplierValidator ...@@ -205,10 +205,10 @@ class SupplierValidator
if ($validateData['supplier_group'] == SupplierChannelModel::SUPPLIER_GROUP_MIX) { if ($validateData['supplier_group'] == SupplierChannelModel::SUPPLIER_GROUP_MIX) {
if (!in_array('proxy_certificate', $attachmentFields)) { if (!in_array('proxy_certificate', $attachmentFields)) {
$errorMessageList[] = '供应商性质为混合分销,代理证必须上传'; $errorMessageList[] = '供应商性质为混合分销,代理证必须上传';
} }
if (!in_array('quality_assurance_agreement', $attachmentFields)) { if (!in_array('quality_assurance_agreement', $attachmentFields) && $validateData['supplier_type'] == SupplierChannelModel::SUPPLIER_TYPE_OFFICIAL) {
$errorMessageList[] = '供应商性质为混合分销,品质保证协议必须上传'; $errorMessageList[] = '供应商性质为混合分销商并且供应商类型为正式时,品质保证协议必须上传';
} }
//还有代理证的有效期为必填 //还有代理证的有效期为必填
if (!in_array('proxy_certificate', $attachmentFields)) { if (!in_array('proxy_certificate', $attachmentFields)) {
......
...@@ -278,3 +278,26 @@ function exportCsv($data, $filename, $column) ...@@ -278,3 +278,26 @@ function exportCsv($data, $filename, $column)
} }
exit(); exit();
} }
/*
* 解析SPU和SKU的ID
* @$id sku 或者 spu id
* @return array db 数据库,table 表名
*/
function getSpuSkuDb($id)
{
$data['db'] = 'sku_0';
$data['table'] = 'lie_sku_0';
$type = substr($id, 0, 1);
$dbcode = substr($id, -2, 1);
$tablecode = substr($id, -1);
if ($type == 1) {
$data['db'] = 'sku_' . $dbcode;
$data['table'] = 'sku_' . $tablecode;
}
if ($type == 2) {
$data['db'] = 'spu';
$data['table'] = 'spu_' . $tablecode;
}
return $data;
}
\ No newline at end of file
...@@ -36,7 +36,7 @@ class SupplierChannelModel extends Model ...@@ -36,7 +36,7 @@ class SupplierChannelModel extends Model
//供应商类型 //供应商类型
const SUPPLIER_GROUP_ORIGINAL = 1; //原厂 const SUPPLIER_GROUP_ORIGINAL = 1; //原厂
const SUPPLIER_GROUP_PROXY = 4; //代理 const SUPPLIER_GROUP_PROXY = 4; //代理
const SUPPLIER_GROUP_MIX = 7; //混合分销 const SUPPLIER_GROUP_MIX = 7; //混合分销
//供应商地区 //供应商地区
const REGION_CN = 2; //国内 const REGION_CN = 2; //国内
......
...@@ -224,6 +224,126 @@ return [ ...@@ -224,6 +224,126 @@ return [
'strict' => false, 'strict' => false,
], ],
'sku_0' => [
'driver' => 'mysql',
'host' => env('DB_SPU_HOST', ''),
'database' => 'liexin_sku_0',
'username' => env('DB_SPU_USERNAME', ''),
'password' => env('DB_SPU_PASSWORD', ''),
'port' => env('DB_SPU_PORT', 3306),
'charset' => 'utf8',
'collation' => 'utf8_general_ci',
'prefix' => 'lie_',
'strict' => false,
],
'sku_1' => [
'driver' => 'mysql',
'host' => env('DB_SPU_HOST', ''),
'database' => 'liexin_sku_1',
'username' => env('DB_SPU_USERNAME', ''),
'password' => env('DB_SPU_PASSWORD', ''),
'port' => env('DB_SPU_PORT', 3306),
'charset' => 'utf8',
'collation' => 'utf8_general_ci',
'prefix' => 'lie_',
'strict' => false,
],
'sku_2' => [
'driver' => 'mysql',
'host' => env('DB_SPU_HOST', ''),
'database' => 'liexin_sku_2',
'username' => env('DB_SPU_USERNAME', ''),
'password' => env('DB_SPU_PASSWORD', ''),
'port' => env('DB_SPU_PORT', 3306),
'charset' => 'utf8',
'collation' => 'utf8_general_ci',
'prefix' => 'lie_',
'strict' => false,
],
'sku_3' => [
'driver' => 'mysql',
'host' => env('DB_SPU_HOST', ''),
'database' => 'liexin_sku_3',
'username' => env('DB_SPU_USERNAME', ''),
'password' => env('DB_SPU_PASSWORD', ''),
'port' => env('DB_SPU_PORT', 3306),
'charset' => 'utf8',
'collation' => 'utf8_general_ci',
'prefix' => 'lie_',
'strict' => false,
],
'sku_4' => [
'driver' => 'mysql',
'host' => env('DB_SPU_HOST', ''),
'database' => 'liexin_sku_4',
'username' => env('DB_SPU_USERNAME', ''),
'password' => env('DB_SPU_PASSWORD', ''),
'port' => env('DB_SPU_PORT', 3306),
'charset' => 'utf8',
'collation' => 'utf8_general_ci',
'prefix' => 'lie_',
'strict' => false,
],
'sku_5' => [
'driver' => 'mysql',
'host' => env('DB_SPU_HOST', ''),
'database' => 'liexin_sku_5',
'username' => env('DB_SPU_USERNAME', ''),
'password' => env('DB_SPU_PASSWORD', ''),
'port' => env('DB_SPU_PORT', 3306),
'charset' => 'utf8',
'collation' => 'utf8_general_ci',
'prefix' => 'lie_',
'strict' => false,
],
'sku_6' => [
'driver' => 'mysql',
'host' => env('DB_SPU_HOST', ''),
'database' => 'liexin_sku_6',
'username' => env('DB_SPU_USERNAME', ''),
'password' => env('DB_SPU_PASSWORD', ''),
'port' => env('DB_SPU_PORT', 3306),
'charset' => 'utf8',
'collation' => 'utf8_general_ci',
'prefix' => 'lie_',
'strict' => false,
],
'sku_7' => [
'driver' => 'mysql',
'host' => env('DB_SPU_HOST', ''),
'database' => 'liexin_sku_7',
'username' => env('DB_SPU_USERNAME', ''),
'password' => env('DB_SPU_PASSWORD', ''),
'port' => env('DB_SPU_PORT', 3306),
'charset' => 'utf8',
'collation' => 'utf8_general_ci',
'prefix' => 'lie_',
'strict' => false,
],
'sku_8' => [
'driver' => 'mysql',
'host' => env('DB_SPU_HOST', ''),
'database' => 'liexin_sku_8',
'username' => env('DB_SPU_USERNAME', ''),
'password' => env('DB_SPU_PASSWORD', ''),
'port' => env('DB_SPU_PORT', 3306),
'charset' => 'utf8',
'collation' => 'utf8_general_ci',
'prefix' => 'lie_',
'strict' => false,
],
'sku_9' => [
'driver' => 'mysql',
'host' => env('DB_SPU_HOST', ''),
'database' => 'liexin_sku_9',
'username' => env('DB_SPU_USERNAME', ''),
'password' => env('DB_SPU_PASSWORD', ''),
'port' => env('DB_SPU_PORT', 3306),
'charset' => 'utf8',
'collation' => 'utf8_general_ci',
'prefix' => 'lie_',
'strict' => false,
],
'rabbitmq' => [ 'rabbitmq' => [
'driver' => 'rabbitmq', 'driver' => 'rabbitmq',
'host' => env('RABBITMQ_HOST', '127.0.0.1'), 'host' => env('RABBITMQ_HOST', '127.0.0.1'),
......
...@@ -21,7 +21,7 @@ return [ ...@@ -21,7 +21,7 @@ return [
2 => '现货商', 2 => '现货商',
4 => '原厂', 4 => '原厂',
1 => '代理商', 1 => '代理商',
7 => '混合分销', 7 => '混合分销',
5 => '分销平台', 5 => '分销平台',
3 => '方案商', 3 => '方案商',
6 => '代工厂', 6 => '代工厂',
......
...@@ -105,7 +105,7 @@ ...@@ -105,7 +105,7 @@
} }
}, },
{ {
field: ' source_name', title: '接入方式', align: 'center', width: 150 field: 'source_name', title: '接入方式', align: 'center', width: 150
}, },
{field: 'audit_user', title: '审核人', align: 'center', width: 100}, {field: 'audit_user', title: '审核人', align: 'center', width: 100},
{field: 'update_time', title: '更新时间', align: 'center', width: 150}, {field: 'update_time', title: '更新时间', align: 'center', width: 150},
......
...@@ -163,7 +163,7 @@ ...@@ -163,7 +163,7 @@
} }
}); });
//监听供应商性质选择,如果为混合分销,那么要展示混合分销品牌设置 //监听供应商性质选择,如果为混合分销商,那么要展示混合分销商品牌设置
form.on('select(supplier_group)', function (data) { form.on('select(supplier_group)', function (data) {
if (data.value === '7') { if (data.value === '7') {
$('#agency_brands_div').show(); $('#agency_brands_div').show();
......
...@@ -84,7 +84,7 @@ ...@@ -84,7 +84,7 @@
fileTemplateObj.find('#validity_period').removeClass('layui-input validity_period layui-disabled'); fileTemplateObj.find('#validity_period').removeClass('layui-input validity_period layui-disabled');
fileTemplateObj.find('#validity_period').prop('disabled', false); fileTemplateObj.find('#validity_period').prop('disabled', false);
form.render(); form.render();
//如果是混合分销,同时还是代理证类型,那么有效期要默认自定义 //如果是混合分销,同时还是代理证类型,那么有效期要默认自定义
let supplierGroup = $('#supplier_group').val(); let supplierGroup = $('#supplier_group').val();
if (supplierGroup === '7' && fileType === 'proxy_certificate') { if (supplierGroup === '7' && fileType === 'proxy_certificate') {
let selector = $('#' + fileType + '_file_div').find('select').last(); let selector = $('#' + fileType + '_file_div').find('select').last();
......
...@@ -216,7 +216,7 @@ ...@@ -216,7 +216,7 @@
id="main_brands"> id="main_brands">
</div> </div>
</div> </div>
{{--选择“混合分销”时,在主营品牌下面新增一栏“代理品牌”;代理品牌取值同主营品牌一样--}} {{--选择“混合分销”时,在主营品牌下面新增一栏“代理品牌”;代理品牌取值同主营品牌一样--}}
<div class="layui-form-item" id="agency_brands_div" style="display: none"> <div class="layui-form-item" id="agency_brands_div" style="display: none">
<label class="layui-form-label"> <label class="layui-form-label">
<span class="require">*</span> <span class="require">*</span>
......
...@@ -223,7 +223,7 @@ ...@@ -223,7 +223,7 @@
id="main_brands"> id="main_brands">
</div> </div>
</div> </div>
{{--选择“混合分销”时,在主营品牌下面新增一栏“代理品牌”;代理品牌取值同主营品牌一样--}} {{--选择“混合分销”时,在主营品牌下面新增一栏“代理品牌”;代理品牌取值同主营品牌一样--}}
<div class="layui-form-item" id="agency_brands_div" <div class="layui-form-item" id="agency_brands_div"
style=" style="
@if(!empty($supplier)&&$supplier['supplier_group']!=\App\Model\SupplierChannelModel::SUPPLIER_GROUP_MIX) @if(!empty($supplier)&&$supplier['supplier_group']!=\App\Model\SupplierChannelModel::SUPPLIER_GROUP_MIX)
......
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