|
@@ -6,7 +6,7 @@ use App\Http\Controllers\Controller;
|
|
|
use App\Http\Requests\Manager\Collect\Product as Request;
|
|
use App\Http\Requests\Manager\Collect\Product as Request;
|
|
|
use App\Models\Manager\Collect\Product as ProductModel;
|
|
use App\Models\Manager\Collect\Product as ProductModel;
|
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
-use Illuminate\Support\Carbon;
|
|
|
|
|
|
|
+use App\Models\Manager\Collect\ProductKeyword as ProductKeywordModel;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 采集配置-商品管理
|
|
* 采集配置-商品管理
|
|
@@ -79,7 +79,7 @@ class Product extends Controller
|
|
|
* @date 2026-03-25
|
|
* @date 2026-03-25
|
|
|
*
|
|
*
|
|
|
*/
|
|
*/
|
|
|
- public function product_name_specs_list(Request $request, ProductModel $ProductModel)
|
|
|
|
|
|
|
+ public function product_name_specs_list(Request $request, ProductModel $ProductModel,ProductKeywordModel $ProductKeywordModel)
|
|
|
{
|
|
{
|
|
|
|
|
|
|
|
$request->scene('product_name_specs_list')->validate();
|
|
$request->scene('product_name_specs_list')->validate();
|
|
@@ -138,13 +138,18 @@ class Product extends Controller
|
|
|
$product_list = $ProductModel->query()
|
|
$product_list = $ProductModel->query()
|
|
|
->where($map2)
|
|
->where($map2)
|
|
|
->where([['product_name', '!=', ''], ['product_name', '!=', null]])
|
|
->where([['product_name', '!=', ''], ['product_name', '!=', null]])
|
|
|
- ->with(['product_keyword'])
|
|
|
|
|
->where(['product_brand' => $value['product_brand']])
|
|
->where(['product_brand' => $value['product_brand']])
|
|
|
->select([DB::raw('MAX(id) as id'), 'product_name'])
|
|
->select([DB::raw('MAX(id) as id'), 'product_name'])
|
|
|
->groupBy(['product_name'])
|
|
->groupBy(['product_name'])
|
|
|
->orderByDesc('id')->get()->toarray();
|
|
->orderByDesc('id')->get()->toarray();
|
|
|
if (!empty($product_list)) {
|
|
if (!empty($product_list)) {
|
|
|
foreach ($product_list as $key2 => $value2) {
|
|
foreach ($product_list as $key2 => $value2) {
|
|
|
|
|
+ $product_keyword = $ProductKeywordModel->query()
|
|
|
|
|
+ ->where(['collect_product_id' => $value2['id']])
|
|
|
|
|
+ ->select('keyword')
|
|
|
|
|
+ ->groupBy(['keyword'])
|
|
|
|
|
+ ->get()->toarray();
|
|
|
|
|
+ $product_list[$key2]['product_keyword'] = $product_keyword ? array_column($product_keyword, 'keyword') : [];
|
|
|
$product_specs = $ProductModel->query()
|
|
$product_specs = $ProductModel->query()
|
|
|
->where($map3)
|
|
->where($map3)
|
|
|
->where([['product_specs', '!=', ''], ['product_specs', '!=', null]])
|
|
->where([['product_specs', '!=', ''], ['product_specs', '!=', null]])
|
|
@@ -152,15 +157,20 @@ class Product extends Controller
|
|
|
->select([DB::raw('MAX(id) as id'), 'product_specs'])
|
|
->select([DB::raw('MAX(id) as id'), 'product_specs'])
|
|
|
->groupBy(['product_specs'])
|
|
->groupBy(['product_specs'])
|
|
|
->orderByDesc('id')->get()->toarray();
|
|
->orderByDesc('id')->get()->toarray();
|
|
|
|
|
+ $product_specs_tring = [];
|
|
|
if (count($product_specs) > 0) {
|
|
if (count($product_specs) > 0) {
|
|
|
foreach ($product_specs as $key3 => $value3) {
|
|
foreach ($product_specs as $key3 => $value3) {
|
|
|
$product_specs_item = isset($value3['product_specs']) ? explode(',', $value3['product_specs']) : '';
|
|
$product_specs_item = isset($value3['product_specs']) ? explode(',', $value3['product_specs']) : '';
|
|
|
- //移除空数组
|
|
|
|
|
- $product_specs[$key3]['product_specs'] = $product_specs_item ? array_filter($product_specs_item) : '';
|
|
|
|
|
|
|
+ //合并数组
|
|
|
|
|
+ if(!empty($product_specs_item)){
|
|
|
|
|
+ $product_specs_tring = array_merge($product_specs_tring, $product_specs_item);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
+ //去重
|
|
|
|
|
+ $product_specs_tring = array_unique($product_specs_tring);
|
|
|
}
|
|
}
|
|
|
//移除空数组
|
|
//移除空数组
|
|
|
- $product_list[$key2]['product_specs'] = $product_specs ? array_filter($product_specs) : '';
|
|
|
|
|
|
|
+ $product_list[$key2]['product_specs'] = $product_specs_tring ? array_filter($product_specs_tring) : '';
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
$result[$key]['product_list'] = !empty($product_list) ? $product_list : [];
|
|
$result[$key]['product_list'] = !empty($product_list) ? $product_list : [];
|