|
@@ -6,6 +6,7 @@ use App\Http\Controllers\Api\Api;
|
|
|
use App\Http\Requests\Api\Process\ViolationProduct as Request;
|
|
use App\Http\Requests\Api\Process\ViolationProduct as Request;
|
|
|
use App\Models\Api\Process\ViolationProduct as ViolationProductModel;
|
|
use App\Models\Api\Process\ViolationProduct as ViolationProductModel;
|
|
|
use App\Models\Api\Personnel\Employee as EmployeeModel;
|
|
use App\Models\Api\Personnel\Employee as EmployeeModel;
|
|
|
|
|
+use App\Models\Api\Process\ViolationProductMember as ViolationProductMemberModel;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 违规处理-违规商品
|
|
* 违规处理-违规商品
|
|
@@ -23,7 +24,7 @@ class ViolationProduct extends Api
|
|
|
* @date 2025-12-09
|
|
* @date 2025-12-09
|
|
|
*
|
|
*
|
|
|
*/
|
|
*/
|
|
|
- public function list(Request $request, ViolationProductModel $ViolationProductModel,EmployeeModel $EmployeeModel)
|
|
|
|
|
|
|
+ public function list(Request $request, ViolationProductModel $ViolationProductModel,EmployeeModel $EmployeeModel,ViolationProductMemberModel $ViolationProductMemberModel)
|
|
|
{
|
|
{
|
|
|
$user_info = $this->checkLogin();
|
|
$user_info = $this->checkLogin();
|
|
|
if (!$user_info) return json_send(['code' => 'error', 'msg' => '请先登录']);
|
|
if (!$user_info) return json_send(['code' => 'error', 'msg' => '请先登录']);
|
|
@@ -36,33 +37,88 @@ class ViolationProduct extends Api
|
|
|
$start_time = request('start_time', '');
|
|
$start_time = request('start_time', '');
|
|
|
$end_time = request('end_time', '');
|
|
$end_time = request('end_time', '');
|
|
|
$product_name = request('product_name', '');
|
|
$product_name = request('product_name', '');
|
|
|
|
|
+ $product_names = request('product_names', '');
|
|
|
$first_responsible_person = request('first_responsible_person', '');
|
|
$first_responsible_person = request('first_responsible_person', '');
|
|
|
$responsible_person = request('responsible_person', '');
|
|
$responsible_person = request('responsible_person', '');
|
|
|
$platform = request('platform', '');
|
|
$platform = request('platform', '');
|
|
|
$company_name = request('company_name', '');
|
|
$company_name = request('company_name', '');
|
|
|
$store_name = request('store_name', '');
|
|
$store_name = request('store_name', '');
|
|
|
|
|
+ $store_names = request('store_names', '');
|
|
|
$source_responsible_person = request('source_responsible_person', '');
|
|
$source_responsible_person = request('source_responsible_person', '');
|
|
|
$processing_status = request('processing_status', '');
|
|
$processing_status = request('processing_status', '');
|
|
|
- $product_name = request('product_name', '');
|
|
|
|
|
$product_specs = request('product_specs', '');
|
|
$product_specs = request('product_specs', '');
|
|
|
$online_posting_cunt = request('online_posting_cunt', '');
|
|
$online_posting_cunt = request('online_posting_cunt', '');
|
|
|
// 时间条件
|
|
// 时间条件
|
|
|
if ($start_time) $map[] = ['insert_time', '>=', strtotime($start_time)];
|
|
if ($start_time) $map[] = ['insert_time', '>=', strtotime($start_time)];
|
|
|
if ($end_time) $map[] = ['insert_time', '<=', strtotime($end_time)];
|
|
if ($end_time) $map[] = ['insert_time', '<=', strtotime($end_time)];
|
|
|
// 其他条件
|
|
// 其他条件
|
|
|
- if ($status) $map[] = ['status', '=', $status];
|
|
|
|
|
if ($product_name) $map[] = ['product_name', 'like', "%$product_name%"];
|
|
if ($product_name) $map[] = ['product_name', 'like', "%$product_name%"];
|
|
|
|
|
+ if ($store_name) $map[] = ['store_name','like',"%$store_name%"];
|
|
|
|
|
|
|
|
- if ($first_responsible_person) $map[] = ['first_responsible_person', 'like', "%$first_responsible_person%"];
|
|
|
|
|
- if ($responsible_person) $map[] = ['responsible_person', 'like', "%$responsible_person%"];
|
|
|
|
|
- if ($platform) $map[] = ['platform', 'like', "%$platform%"];
|
|
|
|
|
- if ($company_name) $map[] = ['company_name', 'like', "%$company_name%"];
|
|
|
|
|
- if ($store_name) $map[] = ['store_name', 'like', "%$store_name%"];
|
|
|
|
|
- if ($source_responsible_person) $map[] = ['source_responsible_person', 'like', "%$source_responsible_person%"];
|
|
|
|
|
- if ($processing_status) $map[] = ['processing_status', '=', $processing_status];
|
|
|
|
|
- if ($product_name) $map[] = ['product_name', 'like', "%$product_name%"];
|
|
|
|
|
- if ($product_specs) $map[] = ['product_specs', 'like', "%$product_specs%"];
|
|
|
|
|
- if ($online_posting_cunt) $map[] = ['online_posting_cunt', '=', $online_posting_cunt];
|
|
|
|
|
|
|
+ //多选平台查询
|
|
|
|
|
+ if($platform && is_string($platform)){
|
|
|
|
|
+ $platform = explode(',', $platform);
|
|
|
|
|
+ $ViolationProductModel=$ViolationProductModel->whereIn('platform', $platform);
|
|
|
|
|
+ }
|
|
|
|
|
+ //多选处理状态查询
|
|
|
|
|
+ if($processing_status && is_string($processing_status)){
|
|
|
|
|
+ $processing_status = explode(',', $processing_status);
|
|
|
|
|
+ $ViolationProductModel=$ViolationProductModel->whereIn('processing_status', $processing_status);
|
|
|
|
|
+ }
|
|
|
|
|
+ //多选状态查询
|
|
|
|
|
+ if($status && is_string($status)){
|
|
|
|
|
+ $status = explode(',', $status);
|
|
|
|
|
+ $ViolationProductModel=$ViolationProductModel->whereIn('status', $status);
|
|
|
|
|
+ }
|
|
|
|
|
+ //多选店铺名称查询
|
|
|
|
|
+ if($store_names && is_string($store_names)){
|
|
|
|
|
+ $store_names = explode(',', $store_names);
|
|
|
|
|
+ $ViolationProductModel=$ViolationProductModel->whereIn('store_name', $store_names);
|
|
|
|
|
+ }
|
|
|
|
|
+ //多选违规挂网次数查询
|
|
|
|
|
+ if($online_posting_cunt && is_string($online_posting_cunt)){
|
|
|
|
|
+ $online_posting_cunt = explode(',', $online_posting_cunt);
|
|
|
|
|
+ $ViolationProductModel=$ViolationProductModel->whereIn('online_posting_cunt', $online_posting_cunt);
|
|
|
|
|
+ }
|
|
|
|
|
+ //多选规格查询
|
|
|
|
|
+ if($product_specs && is_string($product_specs)){
|
|
|
|
|
+ $product_specs = explode(',', $product_specs);
|
|
|
|
|
+ $ViolationProductModel=$ViolationProductModel->whereIn('product_specs', $product_specs);
|
|
|
|
|
+ }
|
|
|
|
|
+ //多选商品查询
|
|
|
|
|
+ if ($product_names && is_string($product_names)) {
|
|
|
|
|
+ $product_names = explode(',', $product_names);
|
|
|
|
|
+ $ViolationProductModel=$ViolationProductModel->whereIn('product_name', $product_names);
|
|
|
|
|
+ }
|
|
|
|
|
+ //多选公司查询
|
|
|
|
|
+ if ($company_name && is_string($company_name)) {
|
|
|
|
|
+ $company_name = explode(',', $company_name);
|
|
|
|
|
+ $ViolationProductModel=$ViolationProductModel->whereIn('company_name', $company_name);
|
|
|
|
|
+ }
|
|
|
|
|
+ //多选第一责任人
|
|
|
|
|
+ if ($first_responsible_person && is_string($first_responsible_person)) {
|
|
|
|
|
+ $first_responsible_person = explode(',', $first_responsible_person);
|
|
|
|
|
+ $subQuery = $ViolationProductMemberModel->whereIn('employee_id', $first_responsible_person)->distinct('lowprice_product_logid')->select('lowprice_product_logid');
|
|
|
|
|
+ $ViolationProductModel = $ViolationProductModel->whereIn('id', function ($query1) use ($subQuery) {
|
|
|
|
|
+ $query1->select('lowprice_product_logid')->fromSub($subQuery, 'sub1');
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ //多选责任人
|
|
|
|
|
+ if ($responsible_person && is_string($responsible_person)) {
|
|
|
|
|
+ $responsible_person = explode(',', $responsible_person);
|
|
|
|
|
+ $subQuery = $ViolationProductMemberModel->whereIn('employee_id', $responsible_person)->distinct('lowprice_product_logid')->select('lowprice_product_logid');
|
|
|
|
|
+ $ViolationProductModel = $ViolationProductModel->whereIn('id', function ($query1) use ($subQuery) {
|
|
|
|
|
+ $query1->select('lowprice_product_logid')->fromSub($subQuery, 'sub1');
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ //多选溯源责任人
|
|
|
|
|
+ if ($source_responsible_person && is_string($source_responsible_person)) {
|
|
|
|
|
+ $source_responsible_person = explode(',', $source_responsible_person);
|
|
|
|
|
+ $subQuery = $ViolationProductMemberModel->whereIn('employee_id', $source_responsible_person)->distinct('lowprice_product_logid')->select('lowprice_product_logid');
|
|
|
|
|
+ $ViolationProductModel = $ViolationProductModel->whereIn('id', function ($query1) use ($subQuery) {
|
|
|
|
|
+ $query1->select('lowprice_product_logid')->fromSub($subQuery, 'sub1');
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
// 查询数据
|
|
// 查询数据
|
|
|
$map1 = array_merge($map, [['first_responsible_person', 'like',"%,$user_id,%"]]);
|
|
$map1 = array_merge($map, [['first_responsible_person', 'like',"%,$user_id,%"]]);
|
|
|
$map2 = array_merge($map, [['responsible_person', 'like',"%,$user_id,%"]]);
|
|
$map2 = array_merge($map, [['responsible_person', 'like',"%,$user_id,%"]]);
|