|
|
@@ -79,7 +79,7 @@ class Product extends Controller
|
|
|
* @date 2026-03-25
|
|
|
*
|
|
|
*/
|
|
|
- public function product_name_specs_list(Request $request, ProductModel $ProductModel,ProductKeywordModel $ProductKeywordModel)
|
|
|
+ public function product_name_specs_list(Request $request, ProductModel $ProductModel, ProductKeywordModel $ProductKeywordModel)
|
|
|
{
|
|
|
|
|
|
$request->scene('product_name_specs_list')->validate();
|
|
|
@@ -96,41 +96,40 @@ class Product extends Controller
|
|
|
$product_brand = request('product_brand', '');
|
|
|
$platform = request('platform', '');
|
|
|
// 时间条件
|
|
|
- if ($start_time){
|
|
|
- $map[] = ['insert_time', '>=', strtotime($start_time)];
|
|
|
- $map2[] = ['insert_time', '>=', strtotime($start_time)];
|
|
|
- $map3[] = ['insert_time', '>=', strtotime($start_time)];
|
|
|
+ if ($start_time) {
|
|
|
+ $map[] = ['insert_time', '>=', strtotime($start_time)];
|
|
|
+ $map2[] = ['insert_time', '>=', strtotime($start_time)];
|
|
|
+ $map3[] = ['insert_time', '>=', strtotime($start_time)];
|
|
|
}
|
|
|
- if ($end_time){
|
|
|
- $map[] = ['insert_time', '<=', strtotime($end_time)];
|
|
|
- $map2[] = ['insert_time', '<=', strtotime($end_time)];
|
|
|
- $map3[] = ['insert_time', '<=', strtotime($end_time)];
|
|
|
-
|
|
|
+ if ($end_time) {
|
|
|
+ $map[] = ['insert_time', '<=', strtotime($end_time)];
|
|
|
+ $map2[] = ['insert_time', '<=', strtotime($end_time)];
|
|
|
+ $map3[] = ['insert_time', '<=', strtotime($end_time)];
|
|
|
}
|
|
|
// 其他条件
|
|
|
$map[] = ['status', '=', 0];
|
|
|
if ($product_name) $map2[] = ['product_name', 'like', "%$product_name%"];
|
|
|
- if (is_numeric($platform) || $platform){
|
|
|
- $map[] = ['platform', 'like', "%$platform%"];
|
|
|
- $map2[] = ['platform', 'like', "%$platform%"];
|
|
|
- $map3[] = ['platform', 'like', "%$platform%"];
|
|
|
+ if (is_numeric($platform) || $platform) {
|
|
|
+ $map[] = ['platform', 'like', "%$platform%"];
|
|
|
+ $map2[] = ['platform', 'like', "%$platform%"];
|
|
|
+ $map3[] = ['platform', 'like', "%$platform%"];
|
|
|
}
|
|
|
if ($product_brand) $map[] = ['product_brand', 'like', "%$product_brand%"];
|
|
|
// 权限判断
|
|
|
if ($is_admin != 1 && $company_id != 0) {
|
|
|
$map[] = ['company_id', '=', $company_id];
|
|
|
- $map2[] = ['company_id', '=', $company_id];
|
|
|
- $map3[] = ['company_id', '=', $company_id];
|
|
|
+ $map2[] = ['company_id', '=', $company_id];
|
|
|
+ $map3[] = ['company_id', '=', $company_id];
|
|
|
} else {
|
|
|
$map[] = ['company_id', '=', $admin_company_id];
|
|
|
- $map2[] = ['company_id', '=', $admin_company_id];
|
|
|
- $map3[] = ['company_id', '=', $admin_company_id];
|
|
|
+ $map2[] = ['company_id', '=', $admin_company_id];
|
|
|
+ $map3[] = ['company_id', '=', $admin_company_id];
|
|
|
}
|
|
|
// 查询数据
|
|
|
$result = $ProductModel->query()
|
|
|
->where($map)
|
|
|
->where([['product_brand', '!=', ''], ['product_brand', '!=', null]])
|
|
|
- ->select([DB::raw('MAX(id) as id'),'product_brand'])
|
|
|
+ ->select([DB::raw('MAX(id) as id'), 'product_brand'])
|
|
|
->groupBy(['product_brand'])
|
|
|
->orderByDesc('id')->get()->toarray();
|
|
|
if (!$result) return json_send(['code' => 'success', 'msg' => '获取成功', 'data' => []]);
|
|
|
@@ -154,6 +153,7 @@ class Product extends Controller
|
|
|
->where($map3)
|
|
|
->where([['product_specs', '!=', ''], ['product_specs', '!=', null]])
|
|
|
->where(['product_name' => $value2['product_name']])
|
|
|
+ ->where(['product_brand' => $value['product_brand']])
|
|
|
->select([DB::raw('MAX(id) as id'), 'product_specs'])
|
|
|
->groupBy(['product_specs'])
|
|
|
->orderByDesc('id')->get()->toarray();
|
|
|
@@ -162,8 +162,8 @@ class Product extends Controller
|
|
|
foreach ($product_specs as $key3 => $value3) {
|
|
|
$product_specs_item = isset($value3['product_specs']) ? explode(',', $value3['product_specs']) : '';
|
|
|
//合并数组
|
|
|
- if(!empty($product_specs_item)){
|
|
|
- $product_specs_tring = array_merge($product_specs_tring, $product_specs_item);
|
|
|
+ if (!empty($product_specs_item)) {
|
|
|
+ $product_specs_tring = array_merge($product_specs_tring, $product_specs_item);
|
|
|
}
|
|
|
}
|
|
|
//去重
|
|
|
@@ -260,7 +260,7 @@ class Product extends Controller
|
|
|
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' => '采集结束时间必须大于当前时间']);
|
|
|
//查询是否存在
|
|
|
- $map = ['product_brand'=> $product_brand, 'product_name' => $all_data['product_name'], 'product_specs' => $all_data['product_specs'], 'platform' => $all_data['platform']];
|
|
|
+ $map = ['product_brand' => $product_brand, 'product_name' => $all_data['product_name'], 'product_specs' => $all_data['product_specs'], 'platform' => $all_data['platform']];
|
|
|
if ($is_admin != 1 && $company_id != 0) {
|
|
|
$map['company_id'] = $company_id;
|
|
|
$all_data['company_id'] = $company_id;
|
|
|
@@ -327,7 +327,7 @@ class Product extends Controller
|
|
|
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' => '采集结束时间必须大于当前时间']);
|
|
|
//查询是否存在
|
|
|
- $map = ['product_brand'=> $product_brand, 'product_name' => $all_data['product_name'], 'product_specs' => $all_data['product_specs'], 'platform' => $all_data['platform']];
|
|
|
+ $map = ['product_brand' => $product_brand, 'product_name' => $all_data['product_name'], 'product_specs' => $all_data['product_specs'], 'platform' => $all_data['platform']];
|
|
|
if ($is_admin != 1 && $company_id != 0) {
|
|
|
$map['company_id'] = $company_id;
|
|
|
} else {
|