|
|
@@ -9,6 +9,8 @@ use App\Models\Manager\WashConfig\ViolationStore as ViolationStoreModel;
|
|
|
use App\Models\Manager\WashConfig\ViolationProductCompany as ViolationProductCompanyModel;
|
|
|
use App\Models\Manager\WashConfig\ProductCategory as ProductCategoryModel;
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
+use App\Models\Manager\WashConfig\LowPriceGoods as LowPriceGoodsModel;
|
|
|
+use Illuminate\Support\Carbon;
|
|
|
|
|
|
/**
|
|
|
* 数据清洗-禁止产品配置
|
|
|
@@ -126,9 +128,19 @@ class ViolationProduct extends Controller
|
|
|
* @date 2025-12-03
|
|
|
*
|
|
|
*/
|
|
|
- public function add(Request $request, ViolationProductModel $ViolationProductModel)
|
|
|
+ public function add(Request $request, ViolationProductModel $ViolationProductModel,LowPriceGoodsModel $LowPriceGoodsModel)
|
|
|
{
|
|
|
$request->scene('add')->validate();
|
|
|
+ //获取禁止商品启动数量
|
|
|
+ $violation_product_count = $ViolationProductModel->where('status', 0)->count();
|
|
|
+ //获取低价挂网商品启用数量
|
|
|
+ $lowprice_product_count = $LowPriceGoodsModel->where('status', 0)->count();
|
|
|
+ //计算总数量
|
|
|
+ $product_totle = $violation_product_count + $lowprice_product_count;
|
|
|
+ //判断是否超过限制
|
|
|
+ if ($product_totle >= 50) {
|
|
|
+ return json_send(['code' => 'error', 'msg' => '启用数量超过限制,低价挂网和禁止商品不能超过50条']);
|
|
|
+ }
|
|
|
// 接收数据
|
|
|
$all_data = request()->all();
|
|
|
$store_scope = request('store_scope', '');
|
|
|
@@ -146,6 +158,8 @@ class ViolationProduct extends Controller
|
|
|
$all_data['sampling_cycle'] = $sampling_cycle;
|
|
|
$all_data['sampling_start_time'] = strtotime($sampling_start_time . '00:00:00');
|
|
|
$all_data['sampling_end_time'] = strtotime($sampling_end_time . '23:59:59');
|
|
|
+ $allow_sampling_time = Carbon::tomorrow()->startOfDay()->getTimestamp();// 明天的开始时间(允许开始采集时间校验)
|
|
|
+ if ($all_data['sampling_start_time'] < $allow_sampling_time) return json_send(['code' => 'error', 'msg' => '采集最早开始时间为明天']);
|
|
|
//查询是否存在
|
|
|
$map = ['product_name' => $all_data['product_name'], 'product_specs' => $all_data['product_specs'], 'platform' => $all_data['platform']];
|
|
|
$data = $ViolationProductModel->where($map)->first();
|
|
|
@@ -200,6 +214,11 @@ class ViolationProduct extends Controller
|
|
|
$where = ['id' => $id];
|
|
|
$ViolationProduct = $ViolationProductModel->where($where)->first();
|
|
|
if (!$ViolationProduct) return json_send(['code' => 'error', 'msg' => '记录不存在']);
|
|
|
+ //如果修改采集周期,则校验采集时间是否在明天以后
|
|
|
+ if ($sampling_cycle != $ViolationProduct->sampling_cycle) {
|
|
|
+ $allow_sampling_time = Carbon::tomorrow()->startOfDay()->getTimestamp(); // 明天的开始时间(允许开始采集时间校验)
|
|
|
+ if ($all_data['sampling_start_time'] < $allow_sampling_time) return json_send(['code' => 'error', 'msg' => '采集最早开始时间为明天']);
|
|
|
+ }
|
|
|
$result = $ViolationProductModel->editViolationProduct_content($ViolationProduct, $all_data);
|
|
|
// 如果操作失败
|
|
|
if (!$result) return json_send(['code' => 'error', 'msg' => '修改失败']);
|
|
|
@@ -219,13 +238,25 @@ class ViolationProduct extends Controller
|
|
|
* @date 2025-12-03
|
|
|
*
|
|
|
*/
|
|
|
- public function set_status(Request $request, ViolationProductModel $ViolationProductModel)
|
|
|
+ public function set_status(Request $request, ViolationProductModel $ViolationProductModel,LowPriceGoodsModel $LowPriceGoodsModel)
|
|
|
{
|
|
|
// 验证参数
|
|
|
$request->scene('set_status')->validate();
|
|
|
// 接收数据
|
|
|
$id = request('id', 0);
|
|
|
$status = request('status', 0);
|
|
|
+ if ($status == 0) {
|
|
|
+ //获取禁止商品启动数量
|
|
|
+ $violation_product_count = $ViolationProductModel->where('status', 0)->count();
|
|
|
+ //获取低价挂网商品启用数量
|
|
|
+ $lowprice_product_count = $LowPriceGoodsModel->where('status', 0)->count();
|
|
|
+ //计算总数量
|
|
|
+ $product_totle = $violation_product_count + $lowprice_product_count;
|
|
|
+ //判断是否超过限制
|
|
|
+ if ($product_totle >= 50) {
|
|
|
+ return json_send(['code' => 'error', 'msg' => '启用数量超过限制,低价挂网和禁止商品不能超过50条']);
|
|
|
+ }
|
|
|
+ }
|
|
|
// 查询用户
|
|
|
$where = ['id' => $id];
|
|
|
$ViolationProduct = $ViolationProductModel->where($where)->first();
|