Commit 588f2adb by 杨树贤

供应商需求20230516

parent 821d21b5
......@@ -106,10 +106,14 @@ class SkuService
$goodsTag = $redis->hget('goods_tag', $item['goods_id']);
$goodsTag = $goodsTag ? json_decode($goodsTag, true) : '';
$item['sku_tags'] = $goodsTag ? array_get($goodsTag, 'customer_tag') : '';
$item['source_name'] = '';
if (!empty($item['source'])) {
$item['source_name'] = array_get(config('field.SkuSource'), $item['source'], '');
}
//去db找出相关数据,有些数据只能去db找....
$dbInfo = getSpuSkuDb($item['goods_id']);
$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;
}, $list);
$list = $this->transformInvalidSkuTag($list);
......@@ -280,14 +284,14 @@ class SkuService
//获取第一次上传sku时间和最后一次上传sku时间
public static function getUploadTimeBySupplierCodes($supplierCodes = [], $type = 'first')
{
$supplierCodesTemp = array_map(function ($value){
$supplierCodesTemp = array_map(function ($value) {
return "'" . $value . "'";
}, $supplierCodes);
$supplierCodeInSql = implode(',', $supplierCodesTemp);
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 {
$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')
->select($rawSql);
......
......@@ -447,11 +447,25 @@ class SupplierService
{
$yunxinChannelUserName = (new AdminUserService())->getAdminUserNameByCodeId($yunxinChannelUid);
$logService = new LogService();
$redis = new RedisModel();
foreach ($supplierIds as $supplierId) {
$preYunxinChannelUid = SupplierChannelModel::where('supplier_id', $supplierId)->value('yunxin_channel_uid');
SupplierChannelModel::where('supplier_id', $supplierId)->update([
'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);
$content = "将SKU采购员由 [${preYunxinChannelUserName}] 改为 [${yunxinChannelUserName}]";
$logService->AddIgnoreAuditCheckLog($supplierId, LogModel::UPDATE_OPERATE, '分配渠道开发员', $content);
......
......@@ -30,9 +30,9 @@ class SupplierAttachmentValidator
$supplierGroup = SupplierChannelModel::where('supplier_id', $attachment['supplier_id'])
->value('supplier_group');
//供应商为混合分销的时候,代理证的有效期必填
//供应商为混合分销的时候,代理证的有效期必填
if ($supplierGroup == SupplierChannelModel::SUPPLIER_GROUP_MIX && !$attachment['validity_period']) {
return '供应商为混合分销的时候,代理证的必须为自定义且必填';
return '供应商为混合分销的时候,代理证的必须为自定义且必填';
}
if ($validator->fails()) {
......
......@@ -150,7 +150,7 @@ class SupplierValidator
if (empty($validateData['supplier_type'])) {
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'))) {
$errorMessageList[] = '该供应商是代购供应商,不能修改为临时供应商';
}
......@@ -162,10 +162,10 @@ class SupplierValidator
$attachmentFields = array_unique(array_get($validateData, 'field_name', []));
$attachmentPeriods = array_unique(array_get($validateData, 'validity_period', []));
//这里的校验是当供应商性质为7(混合分销)的时候,代理证的有效期不能为空
//这里的校验是当供应商性质为7(混合分销)的时候,代理证的有效期不能为空
foreach ($attachmentFields as $key => $attachmentField) {
if ($attachmentField == 'proxy_certificate' && empty($attachmentPeriods[$key])) {
$errorMessageList[] = '供应商性质为混合分销时,附件中代理证的有效期为必填,请检查对应代理证的附件有效期';
$errorMessageList[] = '供应商性质为混合分销时,附件中代理证的有效期为必填,请检查对应代理证的附件有效期';
}
}
......@@ -205,10 +205,10 @@ class SupplierValidator
if ($validateData['supplier_group'] == SupplierChannelModel::SUPPLIER_GROUP_MIX) {
if (!in_array('proxy_certificate', $attachmentFields)) {
$errorMessageList[] = '供应商性质为混合分销,代理证必须上传';
$errorMessageList[] = '供应商性质为混合分销,代理证必须上传';
}
if (!in_array('quality_assurance_agreement', $attachmentFields)) {
$errorMessageList[] = '供应商性质为混合分销,品质保证协议必须上传';
if (!in_array('quality_assurance_agreement', $attachmentFields) && $validateData['supplier_type'] == SupplierChannelModel::SUPPLIER_TYPE_OFFICIAL) {
$errorMessageList[] = '供应商性质为混合分销商并且供应商类型为正式时,品质保证协议必须上传';
}
//还有代理证的有效期为必填
if (!in_array('proxy_certificate', $attachmentFields)) {
......
......@@ -278,3 +278,26 @@ function exportCsv($data, $filename, $column)
}
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
//供应商类型
const SUPPLIER_GROUP_ORIGINAL = 1; //原厂
const SUPPLIER_GROUP_PROXY = 4; //代理
const SUPPLIER_GROUP_MIX = 7; //混合分销
const SUPPLIER_GROUP_MIX = 7; //混合分销
//供应商地区
const REGION_CN = 2; //国内
......
......@@ -224,6 +224,126 @@ return [
'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' => [
'driver' => 'rabbitmq',
'host' => env('RABBITMQ_HOST', '127.0.0.1'),
......
......@@ -21,7 +21,7 @@ return [
2 => '现货商',
4 => '原厂',
1 => '代理商',
7 => '混合分销',
7 => '混合分销',
5 => '分销平台',
3 => '方案商',
6 => '代工厂',
......
......@@ -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: 'update_time', title: '更新时间', align: 'center', width: 150},
......
......@@ -163,7 +163,7 @@
}
});
//监听供应商性质选择,如果为混合分销,那么要展示混合分销品牌设置
//监听供应商性质选择,如果为混合分销商,那么要展示混合分销商品牌设置
form.on('select(supplier_group)', function (data) {
if (data.value === '7') {
$('#agency_brands_div').show();
......
......@@ -84,7 +84,7 @@
fileTemplateObj.find('#validity_period').removeClass('layui-input validity_period layui-disabled');
fileTemplateObj.find('#validity_period').prop('disabled', false);
form.render();
//如果是混合分销,同时还是代理证类型,那么有效期要默认自定义
//如果是混合分销,同时还是代理证类型,那么有效期要默认自定义
let supplierGroup = $('#supplier_group').val();
if (supplierGroup === '7' && fileType === 'proxy_certificate') {
let selector = $('#' + fileType + '_file_div').find('select').last();
......
......@@ -216,7 +216,7 @@
id="main_brands">
</div>
</div>
{{--选择“混合分销”时,在主营品牌下面新增一栏“代理品牌”;代理品牌取值同主营品牌一样--}}
{{--选择“混合分销”时,在主营品牌下面新增一栏“代理品牌”;代理品牌取值同主营品牌一样--}}
<div class="layui-form-item" id="agency_brands_div" style="display: none">
<label class="layui-form-label">
<span class="require">*</span>
......
......@@ -223,7 +223,7 @@
id="main_brands">
</div>
</div>
{{--选择“混合分销”时,在主营品牌下面新增一栏“代理品牌”;代理品牌取值同主营品牌一样--}}
{{--选择“混合分销”时,在主营品牌下面新增一栏“代理品牌”;代理品牌取值同主营品牌一样--}}
<div class="layui-form-item" id="agency_brands_div"
style="
@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