Commit 99ae5d21 by 杨树贤

优化批量设置有效期

parent b54064f6
...@@ -1203,6 +1203,10 @@ class DataService ...@@ -1203,6 +1203,10 @@ class DataService
$suppliers = SupplierChannelModel::where('main_brands', '!=', '')->where('is_type', 0)->get()->toArray(); $suppliers = SupplierChannelModel::where('main_brands', '!=', '')->where('is_type', 0)->get()->toArray();
$redis = new RedisModel(); $redis = new RedisModel();
foreach ($suppliers as $supplier) { foreach ($suppliers as $supplier) {
if (DataManageModel::where('canal', $supplier['supplier_code'])->where('is_type', 0)->exists()) {
dump("大数据供应商");
continue;
}
if (trim($supplier['main_brands'], ',')) { if (trim($supplier['main_brands'], ',')) {
$mainBrands = explode(',', trim($supplier['main_brands'], ',')); $mainBrands = explode(',', trim($supplier['main_brands'], ','));
$ruler = $redis->hget('supplier_sku_upload_ruler_v2', $supplier['supplier_id']); $ruler = $redis->hget('supplier_sku_upload_ruler_v2', $supplier['supplier_id']);
...@@ -1220,7 +1224,7 @@ class DataService ...@@ -1220,7 +1224,7 @@ class DataService
//初始化品牌数量限制(还要跳过API对接的供应商) //初始化品牌数量限制(还要跳过API对接的供应商)
public function initialMainBrandsLimit() public function initialMainBrandsLimit()
{ {
$suppliers = SupplierChannelModel::where('is_type', 0)->get()->toArray(); $suppliers = SupplierChannelModel::where('is_type', 0)->where('main_brands_limit',0)->get()->toArray();
foreach ($suppliers as $supplier) { foreach ($suppliers as $supplier) {
//判断是否是API对接的供应商 //判断是否是API对接的供应商
if (DataManageModel::where('canal', $supplier['supplier_code'])->where('is_type', 0)->exists()) { if (DataManageModel::where('canal', $supplier['supplier_code'])->where('is_type', 0)->exists()) {
......
...@@ -30,7 +30,7 @@ class LogService ...@@ -30,7 +30,7 @@ class LogService
} }
//批量添加日志 //批量添加日志
public function BatchAddLogs($supplierIds,$type,$action,$content,$remark) public function BatchAddLogs($supplierIds,$type,$action,$content,$remark = '')
{ {
$adminId = request()->user->userId; $adminId = request()->user->userId;
$adminName = request()->user->name; $adminName = request()->user->name;
...@@ -47,7 +47,6 @@ class LogService ...@@ -47,7 +47,6 @@ class LogService
'add_time' => time(), 'add_time' => time(),
]; ];
} }
$model = new LogModel(); $model = new LogModel();
return $model->insert($data); return $model->insert($data);
} }
......
...@@ -361,9 +361,9 @@ class SkuService ...@@ -361,9 +361,9 @@ class SkuService
$redis = new RedisModel(); $redis = new RedisModel();
//批量设置 //批量设置
if ($setType == 1) { if ($setType == 1) {
$suppliers = SupplierChannelModel::where('supplier_group', $supplierGroup)->select()->toArray(); $supplierIds = SupplierChannelModel::where('supplier_group', $supplierGroup)->where('is_type',0)
$supplierIds = array_column($suppliers, 'supplier_ids'); ->pluck('supplier_id')->toArray();
$supplierIds = collect($supplierIds)->chunk(100)->toArray(); $supplierIds = collect($supplierIds)->chunk(300)->toArray();
foreach ($supplierIds as $supplierIdList) { foreach ($supplierIds as $supplierIdList) {
//先去批量设置过期时间限制天数 //先去批量设置过期时间限制天数
SupplierChannelModel::whereIn('supplier_id', $supplierIdList)->update([ SupplierChannelModel::whereIn('supplier_id', $supplierIdList)->update([
...@@ -378,9 +378,11 @@ class SkuService ...@@ -378,9 +378,11 @@ class SkuService
$originDays = $originDays ? $originDays . '天' : '[ ]'; $originDays = $originDays ? $originDays . '天' : '[ ]';
} }
$ruler['upload_validity_period'] = $cpTimeDay; $ruler['upload_validity_period'] = $cpTimeDay;
(new SupplierService())->saveSkuCpTimeRulerToRedis($supplierId, $ruler); $ruler = json_encode($ruler);
(new LogService())->AddLog($supplierId, LogModel::UPDATE_OPERATE, '批量配置供应商sku上架有效期', '上架有效期修由' . $originDays . '改为' . $cpTimeDay . '天'); $redis->hset('supplier_sku_upload_ruler_v2', $supplierId, $ruler);
} }
(new LogService())->BatchAddLogs($supplierIdList, LogModel::UPDATE_OPERATE, '批量配置供应商sku上架有效期', '上架有效期修改为' . $cpTimeDay . '天');
} }
} }
......
...@@ -67,7 +67,8 @@ Route::group(['middleware' => ['external'], 'namespace' => 'Sync'], function () ...@@ -67,7 +67,8 @@ Route::group(['middleware' => ['external'], 'namespace' => 'Sync'], function ()
}); });
Route::match(['get', 'post'], '/test', function () { Route::match(['get', 'post'], '/test', function () {
(new \App\Http\Services\DataService())->deleteSupplierAccount(); (new \App\Http\Services\DataService())->initialMainBrandsLimit();
(new \App\Http\Services\DataService())->initialMainBrandsToSkuRuler();
// \App\Model\SupplierChannelModel::where('supplier_name', '深圳市金开盛电子有限公司')->update([ // \App\Model\SupplierChannelModel::where('supplier_name', '深圳市金开盛电子有限公司')->update([
// 'status' => 2, // 'status' => 2,
// 'update_time' => time(), // 'update_time' => time(),
......
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