Commit 3551fc32 by 杨树贤

设置上架有效期限制

parent 61c1c3f3
...@@ -87,15 +87,15 @@ CACHE_DRIVER=file ...@@ -87,15 +87,15 @@ CACHE_DRIVER=file
SESSION_DRIVER=file SESSION_DRIVER=file
QUEUE_DRIVER=redis QUEUE_DRIVER=redis
REDIS_HOST=192.168.1.234 REDIS_HOST=redis.liexindev.me
REDIS_PASSWORD=icDb29mLy2s REDIS_PASSWORD=icDb29mLy2s
REDIS_PORT=6379 REDIS_PORT=6379
REDIS_USER_HOST=192.168.1.234 REDIS_USER_HOST=redis.liexindev.me
REDIS_USER_PASSWORD=icDb29mLy2s REDIS_USER_PASSWORD=icDb29mLy2s
REDIS_USER_PORT=6379 REDIS_USER_PORT=6379
REDIS_READ_HOST=192.168.1.234 REDIS_READ_HOST=redis.liexindev.me
REDIS_READ_PASSWORD=icDb29mLy2s REDIS_READ_PASSWORD=icDb29mLy2s
REDIS_READ_PORT=6379 REDIS_READ_PORT=6379
......
...@@ -192,6 +192,7 @@ class SkuApiController extends Controller ...@@ -192,6 +192,7 @@ class SkuApiController extends Controller
$supplierGroup = $request->input('supplier_group'); $supplierGroup = $request->input('supplier_group');
$supplierCode = $request->input('supplier_code'); $supplierCode = $request->input('supplier_code');
$cpTimeDays = $request->input('cp_time_day'); $cpTimeDays = $request->input('cp_time_day');
$dayType = $request->input('day_type');
if (!$setType) { if (!$setType) {
$this->response(-1, '请选择设置类型'); $this->response(-1, '请选择设置类型');
} }
...@@ -201,7 +202,7 @@ class SkuApiController extends Controller ...@@ -201,7 +202,7 @@ class SkuApiController extends Controller
if ($setType == 2 && empty($supplierCode)) { if ($setType == 2 && empty($supplierCode)) {
$this->response(-2, '单个设置必须选择对应的供应商编码'); $this->response(-2, '单个设置必须选择对应的供应商编码');
} }
$result = (new SkuService())->setSupplierSkuCpTimeLimit($setType, $supplierGroup, $supplierCode, $cpTimeDays); $result = (new SkuService())->setSupplierSkuCpTimeLimit($setType, $supplierGroup, $supplierCode,$dayType, $cpTimeDays);
$this->response(0, '设置上架有效期成功'); $this->response(0, '设置上架有效期成功');
} }
} }
...@@ -1144,7 +1144,7 @@ class DataService ...@@ -1144,7 +1144,7 @@ class DataService
//获取非原厂,非api对接的,有sku的正式供应商列表 //获取非原厂,非api对接的,有sku的正式供应商列表
public function getOffShelfSupplierList() public function getOffShelfSupplierList()
{ {
$suppliers = SupplierChannelModel::where('sku_num', '>', 0)->where('supplier_group','!=',4) $suppliers = SupplierChannelModel::where('sku_num', '>', 0)->where('supplier_group', '!=', 4)
->where('is_type', 0)->get()->toArray(); ->where('is_type', 0)->get()->toArray();
$supplierList = []; $supplierList = [];
foreach ($suppliers as $supplier) { foreach ($suppliers as $supplier) {
...@@ -1157,7 +1157,7 @@ class DataService ...@@ -1157,7 +1157,7 @@ class DataService
echo json_encode($supplierList); echo json_encode($supplierList);
} }
//获取上传了平台合作协议的供应商 //获取上传了平台合作协议的供应商
public function exportHasCooperationAgreementSupplierList() public function exportHasCooperationAgreementSupplierList()
{ {
...@@ -1194,4 +1194,25 @@ class DataService ...@@ -1194,4 +1194,25 @@ class DataService
}); });
})->export('csv'); })->export('csv');
} }
//初始化主营品牌到上传限制
public function initialMainBrandsToSkuRuler()
{
$suppliers = SupplierChannelModel::where('main_brands', '!=', '')->where('is_type', 0)->get()->toArray();
$redis = new RedisModel();
foreach ($suppliers as $supplier) {
if (trim($supplier['main_brands'], ',')) {
$mainBrands = explode(',', trim($supplier['main_brands'], ','));
$ruler = $redis->hget('supplier_sku_upload_ruler_v2', $supplier['supplier_id']);
if ($ruler){
$ruler = json_decode($ruler, true);
$ruler['upload_allow_brands'] = $mainBrands;
}else{
$ruler['upload_allow_brands'] = $mainBrands;
}
dump(json_encode($ruler));
// $redis->hset('supplier_sku_upload_ruler_v2', $supplier['supplier_id'], json_encode($ruler));
}
}
}
} }
\ No newline at end of file
...@@ -351,8 +351,11 @@ class SkuService ...@@ -351,8 +351,11 @@ class SkuService
} }
//设置上架有效期 //设置上架有效期
public function setSupplierSkuCpTimeLimit($setType, $supplierGroup, $supplierCode, $cpTimeDay) public function setSupplierSkuCpTimeLimit($setType, $supplierGroup, $supplierCode, $dayType, $cpTimeDay)
{ {
if ($dayType == 2) {
$cpTimeDay = -1;
}
$cpTimeDay = (int)$cpTimeDay; $cpTimeDay = (int)$cpTimeDay;
$redis = new RedisModel(); $redis = new RedisModel();
//批量设置 //批量设置
...@@ -374,7 +377,7 @@ class SkuService ...@@ -374,7 +377,7 @@ class SkuService
$originDays = $originDays ? $originDays . '天' : '[ ]'; $originDays = $originDays ? $originDays . '天' : '[ ]';
} }
$ruler['upload_validity_period'] = $cpTimeDay; $ruler['upload_validity_period'] = $cpTimeDay;
(new SupplierService())->saveSkuCpTimeRulerToRedis($supplierId,$ruler); (new SupplierService())->saveSkuCpTimeRulerToRedis($supplierId, $ruler);
(new LogService())->AddLog($supplierId, LogModel::UPDATE_OPERATE, '批量配置供应商sku上架有效期', '上架有效期修由' . $originDays . '改为' . $cpTimeDay . '天'); (new LogService())->AddLog($supplierId, LogModel::UPDATE_OPERATE, '批量配置供应商sku上架有效期', '上架有效期修由' . $originDays . '改为' . $cpTimeDay . '天');
} }
} }
...@@ -398,7 +401,7 @@ class SkuService ...@@ -398,7 +401,7 @@ class SkuService
$originDays = $originDays ? $originDays . '天' : '[ ]'; $originDays = $originDays ? $originDays . '天' : '[ ]';
} }
$ruler['upload_validity_period'] = $cpTimeDay; $ruler['upload_validity_period'] = $cpTimeDay;
(new SupplierService())->saveSkuCpTimeRulerToRedis($supplierId,$ruler); (new SupplierService())->saveSkuCpTimeRulerToRedis($supplierId, $ruler);
(new LogService())->AddLog($supplierId, LogModel::UPDATE_OPERATE, '批量配置供应商sku上架有效期', '上架有效期修由' . $originDays . '改为' . $cpTimeDay . '天'); (new LogService())->AddLog($supplierId, LogModel::UPDATE_OPERATE, '批量配置供应商sku上架有效期', '上架有效期修由' . $originDays . '改为' . $cpTimeDay . '天');
} }
} }
......
...@@ -67,7 +67,7 @@ Route::group(['middleware' => ['external'], 'namespace' => 'Sync'], function () ...@@ -67,7 +67,7 @@ Route::group(['middleware' => ['external'], 'namespace' => 'Sync'], function ()
}); });
Route::match(['get', 'post'], '/test', function () { Route::match(['get', 'post'], '/test', function () {
(new \App\Http\Services\DataService())->exportHasCooperationAgreementSupplierList(); (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(),
......
...@@ -43,6 +43,17 @@ ...@@ -43,6 +43,17 @@
} }
}); });
form.on('select(day_type)', function (data) {
console.log(data.value)
if (data.value === '2') {
$('#cp_time_day').attr('disabled', true);
$('#cp_time_day').addClass('layui-disabled');
}else{
$('#cp_time_day').attr('disabled', false);
$('#cp_time_day').removeClass('layui-disabled');
}
});
form.on('submit(cancel)', function (data) { form.on('submit(cancel)', function (data) {
admin.closeThisDialog(); admin.closeThisDialog();
}); });
......
...@@ -25,11 +25,19 @@ ...@@ -25,11 +25,19 @@
</div> </div>
</div> </div>
<div class="layui-form-item"> <div class="layui-form-item">
<label class="layui-form-label" style="width: 150px"><span class="require"></span>上架有效期配置</label> <div class="layui-inline">
<div class="layui-input-inline"> <label class="layui-form-label" style="width: 150px"><span class="require"></span>上架有效期配置</label>
<input type="text" name="cp_time_day" id="cp_time_day" <div class="layui-input-inline">
placeholder="(天数)" class="layui-input" <input type="text" name="cp_time_day" id="cp_time_day"
value=""> placeholder="(天数)" class="layui-input"
value="">
</div>
</div>
<div class="layui-inline">
<select name="day_type" lay-filter="day_type">
<option value="1">自定义</option>
<option value="2">无限制</option>
</select>
</div> </div>
</div> </div>
<div class="layui-form-item"> <div class="layui-form-item">
......
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