|
@@ -78,7 +78,7 @@ class Product extends Controller
|
|
|
$result['data'][$key]['product_specs'] = $product_specs ? array_filter($product_specs) : '';
|
|
$result['data'][$key]['product_specs'] = $product_specs ? array_filter($product_specs) : '';
|
|
|
$sampling_cycle = isset($value['sampling_cycle']) ? explode(',', $value['sampling_cycle']) : '';
|
|
$sampling_cycle = isset($value['sampling_cycle']) ? explode(',', $value['sampling_cycle']) : '';
|
|
|
$result['data'][$key]['sampling_cycle'] = $sampling_cycle ? array_filter($sampling_cycle) : '';
|
|
$result['data'][$key]['sampling_cycle'] = $sampling_cycle ? array_filter($sampling_cycle) : '';
|
|
|
- $round_number_config = isset($value['round_number_config']) ? json_decode($value['round_number_config'],true) : '';
|
|
|
|
|
|
|
+ $round_number_config = isset($value['round_number_config']) ? json_decode($value['round_number_config'], true) : '';
|
|
|
$result['data'][$key]['round_number_config'] = $round_number_config ? array_filter($round_number_config) : '';
|
|
$result['data'][$key]['round_number_config'] = $round_number_config ? array_filter($round_number_config) : '';
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -218,7 +218,7 @@ class Product extends Controller
|
|
|
$data->product_specs = $product_specs ? array_filter($product_specs) : '';
|
|
$data->product_specs = $product_specs ? array_filter($product_specs) : '';
|
|
|
$sampling_cycle = isset($data->sampling_cycle) ? explode(',', $data->sampling_cycle) : '';
|
|
$sampling_cycle = isset($data->sampling_cycle) ? explode(',', $data->sampling_cycle) : '';
|
|
|
$data->sampling_cycle = $sampling_cycle ? array_filter($sampling_cycle) : '';
|
|
$data->sampling_cycle = $sampling_cycle ? array_filter($sampling_cycle) : '';
|
|
|
- $round_number_config = isset($data->round_number_config) ? json_decode($data->round_number_config,true) : '';
|
|
|
|
|
|
|
+ $round_number_config = isset($data->round_number_config) ? json_decode($data->round_number_config, true) : '';
|
|
|
$data->round_number_config = $round_number_config ? array_filter($round_number_config) : '';
|
|
$data->round_number_config = $round_number_config ? array_filter($round_number_config) : '';
|
|
|
// 加载模板
|
|
// 加载模板
|
|
|
return json_send(['code' => 'success', 'msg' => '获取成功', 'data' => $data]);
|
|
return json_send(['code' => 'success', 'msg' => '获取成功', 'data' => $data]);
|
|
@@ -259,7 +259,7 @@ class Product extends Controller
|
|
|
$round_number = request('round_number', 1);
|
|
$round_number = request('round_number', 1);
|
|
|
$is_multiple_accounts = request('is_multiple_accounts', 0);
|
|
$is_multiple_accounts = request('is_multiple_accounts', 0);
|
|
|
$round_number_config = request('round_number_config', '');
|
|
$round_number_config = request('round_number_config', '');
|
|
|
- $all_data['round_number_config'] = !empty($round_number_config) ? json_encode($round_number_config):'';
|
|
|
|
|
|
|
+ $all_data['round_number_config'] = !empty($round_number_config) ? json_encode($round_number_config) : '';
|
|
|
$all_data['is_multiple_accounts'] = $is_multiple_accounts;
|
|
$all_data['is_multiple_accounts'] = $is_multiple_accounts;
|
|
|
$all_data['round_number'] = $round_number;
|
|
$all_data['round_number'] = $round_number;
|
|
|
$all_data['sampling_cycle'] = $sampling_cycle;
|
|
$all_data['sampling_cycle'] = $sampling_cycle;
|
|
@@ -267,7 +267,7 @@ class Product extends Controller
|
|
|
$all_data['sampling_end_time'] = $sampling_end_time ? strtotime($sampling_end_time . '23:59:59') : '0';
|
|
$all_data['sampling_end_time'] = $sampling_end_time ? strtotime($sampling_end_time . '23:59:59') : '0';
|
|
|
$all_data['minimum_order_quantity'] = $minimum_order_quantity;
|
|
$all_data['minimum_order_quantity'] = $minimum_order_quantity;
|
|
|
|
|
|
|
|
- if(is_numeric($round_number) && $round_number > 3) return json_send(['code' => 'error', 'msg' => '轮次数量不能超过3']);
|
|
|
|
|
|
|
+ if (is_numeric($round_number) && $round_number > 3) return json_send(['code' => 'error', 'msg' => '轮次数量不能超过3']);
|
|
|
if ($all_data['sampling_start_time'] && strtotime(date('Y-m-d', $all_data['sampling_start_time']) . '23:59:59') < time()) return json_send(['code' => 'error', 'msg' => '采集开始时间必须大于当前时间']);
|
|
if ($all_data['sampling_start_time'] && strtotime(date('Y-m-d', $all_data['sampling_start_time']) . '23:59:59') < time()) return json_send(['code' => 'error', 'msg' => '采集开始时间必须大于当前时间']);
|
|
|
if ($all_data['sampling_end_time'] && $all_data['sampling_end_time'] < time()) return json_send(['code' => 'error', 'msg' => '采集结束时间必须大于当前时间']);
|
|
if ($all_data['sampling_end_time'] && $all_data['sampling_end_time'] < time()) return json_send(['code' => 'error', 'msg' => '采集结束时间必须大于当前时间']);
|
|
|
|
|
|
|
@@ -375,7 +375,7 @@ class Product extends Controller
|
|
|
$round_number = request('round_number', 1);
|
|
$round_number = request('round_number', 1);
|
|
|
$is_multiple_accounts = request('is_multiple_accounts', 0);
|
|
$is_multiple_accounts = request('is_multiple_accounts', 0);
|
|
|
$round_number_config = request('round_number_config', '');
|
|
$round_number_config = request('round_number_config', '');
|
|
|
- $all_data['round_number_config'] = !empty($round_number_config) ? json_encode($round_number_config):'';
|
|
|
|
|
|
|
+ $all_data['round_number_config'] = !empty($round_number_config) ? json_encode($round_number_config) : '';
|
|
|
$all_data['is_multiple_accounts'] = $is_multiple_accounts;
|
|
$all_data['is_multiple_accounts'] = $is_multiple_accounts;
|
|
|
$all_data['round_number'] = $round_number;
|
|
$all_data['round_number'] = $round_number;
|
|
|
$all_data['sampling_cycle'] = $sampling_cycle;
|
|
$all_data['sampling_cycle'] = $sampling_cycle;
|
|
@@ -383,7 +383,7 @@ class Product extends Controller
|
|
|
$all_data['sampling_end_time'] = $sampling_end_time ? strtotime($sampling_end_time . '23:59:59') : '0';
|
|
$all_data['sampling_end_time'] = $sampling_end_time ? strtotime($sampling_end_time . '23:59:59') : '0';
|
|
|
$all_data['minimum_order_quantity'] = $minimum_order_quantity;
|
|
$all_data['minimum_order_quantity'] = $minimum_order_quantity;
|
|
|
|
|
|
|
|
- if(is_numeric($round_number) && $round_number > 3) return json_send(['code' => 'error', 'msg' => '轮次数量不能超过3']);
|
|
|
|
|
|
|
+ if (is_numeric($round_number) && $round_number > 3) return json_send(['code' => 'error', 'msg' => '轮次数量不能超过3']);
|
|
|
if ($all_data['sampling_start_time'] && strtotime(date('Y-m-d', $all_data['sampling_start_time']) . '23:59:59') < time()) return json_send(['code' => 'error', 'msg' => '采集开始时间必须大于当前时间']);
|
|
if ($all_data['sampling_start_time'] && strtotime(date('Y-m-d', $all_data['sampling_start_time']) . '23:59:59') < time()) return json_send(['code' => 'error', 'msg' => '采集开始时间必须大于当前时间']);
|
|
|
if ($all_data['sampling_end_time'] && $all_data['sampling_end_time'] < time()) return json_send(['code' => 'error', 'msg' => '采集结束时间必须大于当前时间']);
|
|
if ($all_data['sampling_end_time'] && $all_data['sampling_end_time'] < time()) return json_send(['code' => 'error', 'msg' => '采集结束时间必须大于当前时间']);
|
|
|
|
|
|
|
@@ -515,23 +515,65 @@ class Product extends Controller
|
|
|
$platform_data = $ProductModel->platform_index_data();
|
|
$platform_data = $ProductModel->platform_index_data();
|
|
|
foreach ($platforms as $platform) {
|
|
foreach ($platforms as $platform) {
|
|
|
$product_specs_log = $ProductModel
|
|
$product_specs_log = $ProductModel
|
|
|
- ->whereRaw("FIND_IN_SET(?, platform)", [$platform])
|
|
|
|
|
- ->where(['product_brand' => $Product->product_brand, 'product_name' => $Product->product_name, 'status' => '0', 'company_id' => $Product->company_id])
|
|
|
|
|
- ->where('id', '!=', $id)
|
|
|
|
|
- ->where(function ($query) use ($product_specs) {
|
|
|
|
|
- // 平台条件(固定)
|
|
|
|
|
- $query->where(function ($query_li) use ($product_specs) {
|
|
|
|
|
- if (!empty($product_specs)) {
|
|
|
|
|
- foreach ($product_specs as $product_spec) {
|
|
|
|
|
- if (empty($product_specs)) continue;
|
|
|
|
|
- $query_li->orWhereRaw("FIND_IN_SET(?, product_specs)", [$product_spec]);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- });
|
|
|
|
|
- })->first();
|
|
|
|
|
|
|
+ ->orWhereRaw(function ($querys) use ($product_specs, $platform, $Product) {
|
|
|
|
|
+ $querys->whereRaw("FIND_IN_SET(?, platform)", [$platform])
|
|
|
|
|
+ ->where([
|
|
|
|
|
+ 'product_brand' => $Product->product_brand,
|
|
|
|
|
+ 'product_name' => $Product->product_name,
|
|
|
|
|
+ 'status' => '0',
|
|
|
|
|
+ 'company_id' => $Product->company_id
|
|
|
|
|
+ ])
|
|
|
|
|
+ ->where('id', '!=', $Product->id)
|
|
|
|
|
+ ->where(function ($query) use ($product_specs) {
|
|
|
|
|
+ // 平台条件(固定)
|
|
|
|
|
+ $query->where(function ($query_li) use ($product_specs) {
|
|
|
|
|
+ if (!empty($product_specs)) {
|
|
|
|
|
+ foreach ($product_specs as $product_spec) {
|
|
|
|
|
+ if (empty($product_specs)) continue;
|
|
|
|
|
+ $query_li->orWhereRaw("FIND_IN_SET(?, product_specs)", [$product_spec]);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
|
|
+ //记录的开始跟结束时间是否在当前记录的采集开始时间结束时间之内
|
|
|
|
|
+ if ($Product->sampling_start_time > 0 && $Product->sampling_end_time > 0) {
|
|
|
|
|
+ $querys->where(function ($query_li) use ($Product) {
|
|
|
|
|
+ $query_li->where('sampling_start_time', '<=', $Product->sampling_start_time)
|
|
|
|
|
+ ->where('sampling_end_time', '>=', $Product->sampling_end_time);
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ ->orWhereRaw(function ($querys) use ($product_specs, $platform, $Product) {
|
|
|
|
|
+ $querys->whereRaw("FIND_IN_SET(?, platform)", [$platform])
|
|
|
|
|
+ ->where([
|
|
|
|
|
+ 'product_brand' => $Product->product_brand,
|
|
|
|
|
+ 'product_name' => $Product->product_name,
|
|
|
|
|
+ 'status' => '0',
|
|
|
|
|
+ 'company_id' => $Product->company_id
|
|
|
|
|
+ ])
|
|
|
|
|
+ ->where('id', '!=', $Product->id)
|
|
|
|
|
+ ->where(function ($query) use ($product_specs) {
|
|
|
|
|
+ // 平台条件(固定)
|
|
|
|
|
+ $query->where(function ($query_li) use ($product_specs) {
|
|
|
|
|
+ if (!empty($product_specs)) {
|
|
|
|
|
+ foreach ($product_specs as $product_spec) {
|
|
|
|
|
+ if (empty($product_specs)) continue;
|
|
|
|
|
+ $query_li->orWhereRaw("FIND_IN_SET(?, product_specs)", [$product_spec]);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
|
|
+ //记录的开始跟结束时间是否在当前记录的采集开始时间结束时间之内
|
|
|
|
|
+ if ($Product->sampling_start_time > 0 && $Product->sampling_end_time == 0) {
|
|
|
|
|
+ $querys->where(function ($query_li) use ($Product) {
|
|
|
|
|
+ $query_li->where('sampling_start_time', '>=', $Product->sampling_start_time);
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ ->first();
|
|
|
$platform_name = isset($platform_data[$platform]) ? $platform_data[$platform] : '';
|
|
$platform_name = isset($platform_data[$platform]) ? $platform_data[$platform] : '';
|
|
|
if (!empty($product_specs_log) && $status == 0) {
|
|
if (!empty($product_specs_log) && $status == 0) {
|
|
|
- return json_send(['code' => 'error', 'msg' => $platform_name . '存在重复的商品规格启用记录']);
|
|
|
|
|
|
|
+ return json_send(['code' => 'error', 'msg' => $platform_name . '时间范围内存在重复的商品规格启用记录']);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|