|
@@ -7,6 +7,13 @@ use Illuminate\Http\Request;
|
|
|
use App\Models\Manager\Process\LowPriceGoods as LowPriceGoodsModel;
|
|
use App\Models\Manager\Process\LowPriceGoods as LowPriceGoodsModel;
|
|
|
use App\Models\Manager\Process\ViolationProduct as ViolationProductModel;
|
|
use App\Models\Manager\Process\ViolationProduct as ViolationProductModel;
|
|
|
use App\Models\Manager\Process\ViolationStore as ViolationStoreModel;
|
|
use App\Models\Manager\Process\ViolationStore as ViolationStoreModel;
|
|
|
|
|
+use App\Models\Manager\Personnel\EmployeeArea as EmployeeAreaModel;
|
|
|
|
|
+use App\Models\Manager\Personnel\Employee as EmployeeModel;
|
|
|
|
|
+use App\Models\Manager\WashConfig\ViolationCompany as ViolationCompanyModel;
|
|
|
|
|
+use App\Models\Manager\WashConfig\ViolationCompanyMember as ViolationCompanyMemberModel;
|
|
|
|
|
+use App\Models\Manager\Personnel\EmployeePlatform as EmployeePlatformModel;
|
|
|
|
|
+use App\Models\Manager\Process\LowPriceGoodsMember as LowPriceGoodsMemberModel;
|
|
|
|
|
+use Illuminate\Support\Facades\DB;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 清洗后的数据处理
|
|
* 清洗后的数据处理
|
|
@@ -16,13 +23,335 @@ use App\Models\Manager\Process\ViolationStore as ViolationStoreModel;
|
|
|
*/
|
|
*/
|
|
|
class CollectData extends Controller
|
|
class CollectData extends Controller
|
|
|
{
|
|
{
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 低价商品数据数据清洗-回填责任人
|
|
|
|
|
+ * @author: 唐远望
|
|
|
|
|
+ * @version: 1.0
|
|
|
|
|
+ * @date: 2026-04-29
|
|
|
|
|
+ */
|
|
|
|
|
+ public function low_price_product_collect_data(LowPriceGoodsModel $LowPriceGoodsModel) {
|
|
|
|
|
+ //获取非导入的低价商品清洗数据
|
|
|
|
|
+ $map = [];
|
|
|
|
|
+ $map[] = ['merge_city_id', '!=', '0'];
|
|
|
|
|
+ $map[] = ['first_responsible_person', '=', ''];
|
|
|
|
|
+ $map[] = ['responsible_person', '=', ''];
|
|
|
|
|
+ $map[] = ['source_responsible_person', '=', ''];
|
|
|
|
|
+ $limit = '100';
|
|
|
|
|
+ DB::beginTransaction();
|
|
|
|
|
+ try {
|
|
|
|
|
+ $result = $LowPriceGoodsModel->where($map)->orderByDesc('id')->paginate($limit)->toarray();
|
|
|
|
|
+ if (!empty($result['data'])) {
|
|
|
|
|
+ foreach ($result['data'] as $key => $product_data) {
|
|
|
|
|
+ $specify_responsible_person = 0;
|
|
|
|
|
+ //获取指定人员信息
|
|
|
|
|
+ $insert_product_data = [];
|
|
|
|
|
+ if ($specify_responsible_person == 0) {
|
|
|
|
|
+ $product_data['qualification_number'] = $product_data['social_credit_code'];
|
|
|
|
|
+ $product_data['platform_id'] = $product_data['platform'];
|
|
|
|
|
+ $insert_product_data = $this->get_responsible_person_info($product_data);
|
|
|
|
|
+ }
|
|
|
|
|
+ $update_data = $insert_product_data;
|
|
|
|
|
+ if (!empty($update_data) && count($update_data) > 0) {
|
|
|
|
|
+ $LowPriceGoodsModel->where('id', $product_data['id'])->update($update_data);
|
|
|
|
|
+ $this->insert_low_product_responsible_person_info($product_data, $insert_product_data);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ DB::commit();
|
|
|
|
|
+ return json_send(['code' => 'success', 'msg' => '执行成功', 'data' => count($result['data'])]);
|
|
|
|
|
+ // 成功处理...
|
|
|
|
|
+ } catch (\Exception $e) {
|
|
|
|
|
+ DB::rollBack();
|
|
|
|
|
+ return json_send(['code' => 'error', 'msg' => '执行失败', 'data' => $e->getMessage()]);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 写入处理低价商品-责任人信息
|
|
|
|
|
+ * @author: 唐远望
|
|
|
|
|
+ * @version: 1.0
|
|
|
|
|
+ * @date: 2026-05-18
|
|
|
|
|
+ */
|
|
|
|
|
+ public function insert_low_product_responsible_person_info($product_data, $insert_product_data)
|
|
|
|
|
+ {
|
|
|
|
|
+ $LowPriceGoodsMemberModel = new LowPriceGoodsMemberModel();
|
|
|
|
|
+ // $LowPriceGoodsModel->where('id', $product_data['id'])->update($update_data);
|
|
|
|
|
+ $LowPriceGoods_id = $product_data['id'];
|
|
|
|
|
+ $data['first_responsible_person'] = isset($insert_product_data['first_responsible_person']) ? $insert_product_data['first_responsible_person'] : '';
|
|
|
|
|
+ $first_responsible_persons = $data['first_responsible_person'] != '' ? explode(',', $data['first_responsible_person']) : [];
|
|
|
|
|
+ $first_responsible_person_data = [];
|
|
|
|
|
+ if (count($first_responsible_persons) > 0) {
|
|
|
|
|
+ foreach ($first_responsible_persons as $key => $employee_id) {
|
|
|
|
|
+ //如果不是数字或者为空,则跳过
|
|
|
|
|
+ if ($employee_id == '' || is_null($employee_id) || !is_numeric($employee_id)) continue;
|
|
|
|
|
+ $first_responsible_person_data[] = [
|
|
|
|
|
+ 'lowprice_product_logid' => $LowPriceGoods_id,
|
|
|
|
|
+ 'employee_id' => $employee_id,
|
|
|
|
|
+ 'duty_type' => 1, //责任类型1=第一责任人,2=责任人,3=溯源责任人
|
|
|
|
|
+ ];
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ $LowPriceGoodsMemberModel->insert($first_responsible_person_data);
|
|
|
|
|
+ $data['responsible_person'] = isset($insert_product_data['responsible_person']) ? $insert_product_data['responsible_person'] : '';
|
|
|
|
|
+ $responsible_persons = $data['responsible_person'] != '' ? explode(',', $data['responsible_person']) : [];
|
|
|
|
|
+ $responsible_person_data = [];
|
|
|
|
|
+ if (count($responsible_persons) > 0) {
|
|
|
|
|
+ foreach ($responsible_persons as $key => $employee_id) {
|
|
|
|
|
+ //如果不是数字或者为空,则跳过
|
|
|
|
|
+ if ($employee_id == '' || is_null($employee_id) || !is_numeric($employee_id)) continue;
|
|
|
|
|
+ $responsible_person_data[] = [
|
|
|
|
|
+ 'lowprice_product_logid' => $LowPriceGoods_id,
|
|
|
|
|
+ 'employee_id' => $employee_id,
|
|
|
|
|
+ 'duty_type' => 2, //责任类型1=第一责任人,2=责任人,3=溯源责任人
|
|
|
|
|
+ ];
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ $LowPriceGoodsMemberModel->insert($responsible_person_data);
|
|
|
|
|
+ $data['source_responsible_person'] = isset($insert_product_data['source_responsible_person']) ? $insert_product_data['source_responsible_person'] : '';
|
|
|
|
|
+ $source_responsible_persons = $data['source_responsible_person'] != '' ? explode(',', $data['source_responsible_person']) : [];
|
|
|
|
|
+ $source_responsible_person_data = [];
|
|
|
|
|
+ if (count($source_responsible_persons) > 0) {
|
|
|
|
|
+ foreach ($source_responsible_persons as $key => $employee_id) {
|
|
|
|
|
+ //如果不是数字或者为空,则跳过
|
|
|
|
|
+ if ($employee_id == '' || is_null($employee_id) || !is_numeric($employee_id)) continue;
|
|
|
|
|
+ $source_responsible_person_data[] = [
|
|
|
|
|
+ 'lowprice_product_logid' => $LowPriceGoods_id,
|
|
|
|
|
+ 'employee_id' => $employee_id,
|
|
|
|
|
+ 'duty_type' => 3, //责任类型1=第一责任人,2=责任人,3=溯源责任人
|
|
|
|
|
+ ];
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ $LowPriceGoodsMemberModel->insert($source_responsible_person_data);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 根据规则获取责任人分配信息
|
|
|
|
|
+ * @author: 唐远望
|
|
|
|
|
+ * @version: 1.0
|
|
|
|
|
+ * @date: 2026-05-18
|
|
|
|
|
+ */
|
|
|
|
|
+ public function get_responsible_person_info($product_data)
|
|
|
|
|
+ {
|
|
|
|
|
+ $EmployeeAreaModel = new EmployeeAreaModel();
|
|
|
|
|
+ $EmployeePlatformModel = new EmployeePlatformModel();
|
|
|
|
|
+ $ViolationCompanyModel = new ViolationCompanyModel();
|
|
|
|
|
+ $ViolationCompanyMemberModel = new ViolationCompanyMemberModel();
|
|
|
|
|
+ $company_id = $product_data['company_id'];
|
|
|
|
|
+ //获取指定人员信息
|
|
|
|
|
+ $insert_product_data = [];
|
|
|
|
|
+ //获取店铺责任人信息
|
|
|
|
|
+ $ViolationStoreModel = new ViolationStoreModel();
|
|
|
|
|
+ $store_data_info = $ViolationStoreModel->where('company_id', $company_id)->where('store_name', $product_data['store_name'])->where('status', '0')->first();
|
|
|
|
|
+ if (!empty($store_data_info) && trim($store_data_info->employee_ids) != '') {
|
|
|
|
|
+ //查询店铺第一责任人信息
|
|
|
|
|
+ $EmployeeModel = new EmployeeModel();
|
|
|
|
|
+ $store_where_query = [];
|
|
|
|
|
+ $employee_id_store = explode(',', $store_data_info->employee_ids);
|
|
|
|
|
+ $store_where_query[] = ['company_id', '=', $company_id];
|
|
|
|
|
+ $store_where_query[] = ['status', '=', 0];
|
|
|
|
|
+ $store_where_query[] = ['duty_type', '=', 1]; //责任类型1=第一责任人,2=责任人
|
|
|
|
|
+ $first_responsible_person = $EmployeeModel->whereIn('id', $employee_id_store)->where($store_where_query)->pluck('id')->implode(',');
|
|
|
|
|
+ $insert_product_data['first_responsible_person'] = $first_responsible_person;
|
|
|
|
|
+ //查询店铺责任人信息
|
|
|
|
|
+ $EmployeeModel = new EmployeeModel();
|
|
|
|
|
+ $store_where_query = [];
|
|
|
|
|
+ $employee_id_store = explode(',', $store_data_info->employee_ids);
|
|
|
|
|
+ $store_where_query[] = ['company_id', '=', $company_id];
|
|
|
|
|
+ $store_where_query[] = ['status', '=', 0];
|
|
|
|
|
+ $store_where_query[] = ['duty_type', '=', 2]; //责任类型1=第一责任人,2=责任人
|
|
|
|
|
+ $responsible_person = $EmployeeModel->whereIn('id', $employee_id_store)->where($store_where_query)->pluck('id')->implode(',');
|
|
|
|
|
+ $insert_product_data['responsible_person'] = $responsible_person;
|
|
|
|
|
+ //溯源责任人
|
|
|
|
|
+ $source_responsible_person = '';
|
|
|
|
|
+ if ($first_responsible_person && $responsible_person) {
|
|
|
|
|
+ //转换成数组,合并后在去重
|
|
|
|
|
+ $first_responsible_person = explode(',', $first_responsible_person);
|
|
|
|
|
+ $responsible_person = explode(',', $responsible_person);
|
|
|
|
|
+ $source_responsible_person = array_unique(array_merge($first_responsible_person, $responsible_person));
|
|
|
|
|
+ $source_responsible_person = ',' . implode(',', $source_responsible_person) . ',';
|
|
|
|
|
+ } else if ($first_responsible_person) {
|
|
|
|
|
+ $source_responsible_person = $first_responsible_person;
|
|
|
|
|
+ } else if ($responsible_person) {
|
|
|
|
|
+ $source_responsible_person = $responsible_person;
|
|
|
|
|
+ }
|
|
|
|
|
+ $insert_product_data['source_responsible_person'] = $source_responsible_person;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ //获取公司绑定责任人信息
|
|
|
|
|
+ $company_data = $ViolationCompanyModel->leftjoin('washconfig_company_category', 'washconfig_company_category.id', '=', 'washconfig_violation_company.category_id')
|
|
|
|
|
+ ->where('washconfig_violation_company.social_credit_code', $product_data['qualification_number'])
|
|
|
|
|
+ ->where('washconfig_violation_company.company_id', $company_id)
|
|
|
|
|
+ ->select(['washconfig_violation_company.id', 'washconfig_company_category.name as category_name'])->first();
|
|
|
|
|
+ $employee_id_list = [];
|
|
|
|
|
+ if ($company_data) {
|
|
|
|
|
+ $employee_id_list = $ViolationCompanyMemberModel->where('company_logid', $company_data->id)->pluck('employee_id')->toarray();
|
|
|
|
|
+ $insert_product_data['company_category_name'] = $company_data->category_name ? $company_data->category_name : '';
|
|
|
|
|
+ }
|
|
|
|
|
+ $where_query1 = [];
|
|
|
|
|
+ $where_query2 = [];
|
|
|
|
|
+ $where_query3 = [];
|
|
|
|
|
+ //查询指定公司第一责任人
|
|
|
|
|
+ if (!empty($employee_id_list)) {
|
|
|
|
|
+ $where_query1[] = ['company_id', '=', $company_id];
|
|
|
|
|
+ $where_query1[] = ['id', 'in', $employee_id_list];
|
|
|
|
|
+ $where_query1[] = ['status', '=', 0];
|
|
|
|
|
+ $where_query1[] = ['duty_type', '=', 1]; //责任类型1=第一责任人,2=责任人
|
|
|
|
|
+ }
|
|
|
|
|
+ //查询地区配置的第一责任人
|
|
|
|
|
+ $employee_id_area = $EmployeeAreaModel->where('city_id', $product_data['city_id'])->pluck('employee_id')->toarray();
|
|
|
|
|
+ if (!empty($employee_id_area)) {
|
|
|
|
|
+ $where_query2[] = ['company_id', '=', $company_id];
|
|
|
|
|
+ $where_query2[] = ['id', 'in', $employee_id_area];
|
|
|
|
|
+ $where_query2[] = ['status', '=', 0];
|
|
|
|
|
+ $where_query2[] = ['duty_type', '=', 1]; //责任类型1=第一责任人,2=责任人
|
|
|
|
|
+ }
|
|
|
|
|
+ //查询平台配置的第一责任人
|
|
|
|
|
+ $employee_id_platform = $EmployeePlatformModel->where('platform_id', $product_data['platform_id'])->pluck('employee_id')->toarray();
|
|
|
|
|
+ if (!empty($employee_id_platform)) {
|
|
|
|
|
+ $where_query3[] = ['company_id', '=', $company_id];
|
|
|
|
|
+ $where_query3[] = ['id', 'in', $employee_id_platform];
|
|
|
|
|
+ $where_query3[] = ['status', '=', 0];
|
|
|
|
|
+ $where_query3[] = ['duty_type', '=', 1]; //责任类型1=第一责任人,2=责任人
|
|
|
|
|
+ }
|
|
|
|
|
+ //并行查询第一责任人
|
|
|
|
|
+ $EmployeeModel = new EmployeeModel();
|
|
|
|
|
+ $EmployeeModel = $EmployeeModel
|
|
|
|
|
+ ->orWhere(function ($q) use ($employee_id_list, $company_id) {
|
|
|
|
|
+ if (!empty($employee_id_list)) {
|
|
|
|
|
+ $q->where('company_id', $company_id)
|
|
|
|
|
+ ->orWhereIn('id', $employee_id_list)
|
|
|
|
|
+ ->where('duty_type', 1)
|
|
|
|
|
+ ->where('status', 0);
|
|
|
|
|
+ }
|
|
|
|
|
+ })->orWhere(function ($q) use ($employee_id_area, $company_id) {
|
|
|
|
|
+ if (!empty($employee_id_area)) {
|
|
|
|
|
+ $q->where('company_id', $company_id)
|
|
|
|
|
+ ->whereIn('id', $employee_id_area)
|
|
|
|
|
+ ->where('duty_type', 1)
|
|
|
|
|
+ ->where('status', 0);
|
|
|
|
|
+ }
|
|
|
|
|
+ })->orWhere(function ($q) use ($employee_id_platform, $company_id) {
|
|
|
|
|
+ if (!empty($employee_id_platform)) {
|
|
|
|
|
+ $q->where('company_id', $company_id)
|
|
|
|
|
+ ->whereIn('id', $employee_id_platform)
|
|
|
|
|
+ ->where('duty_type', 1)
|
|
|
|
|
+ ->where('status', 0);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ $first_responsible_person = $EmployeeModel->pluck('id')->implode(',');
|
|
|
|
|
+
|
|
|
|
|
+ //当以上规则匹配不到责任人时,则去查询发货地区信息关联责任人
|
|
|
|
|
+ if (trim($first_responsible_person) == '' && trim($product_data['shipment_city_id']) != '') {
|
|
|
|
|
+ $employee_id_area = $EmployeeAreaModel->where('company_id', $company_id)->where('city_id', $product_data['shipment_city_id'])->pluck('employee_id')->toarray();
|
|
|
|
|
+ if (!empty($employee_id_area)) {
|
|
|
|
|
+ $where_city = [];
|
|
|
|
|
+ $where_city[] = ['company_id', '=', $company_id];
|
|
|
|
|
+ $where_city[] = ['status', '=', 0];
|
|
|
|
|
+ $where_city[] = ['duty_type', '=', 1]; //责任类型1=第一责任人,2=责任人
|
|
|
|
|
+ $EmployeeModel = new EmployeeModel();
|
|
|
|
|
+ $first_responsible_person = $EmployeeModel->whereIn('id', $employee_id_area)->where($where_city)->pluck('id')->implode(',');
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //调试记录查询条件
|
|
|
|
|
+ $insert_product_data['first_responsible_person'] = $first_responsible_person;
|
|
|
|
|
+ //查询责任人
|
|
|
|
|
+ $where_query1 = [];
|
|
|
|
|
+ $where_query2 = [];
|
|
|
|
|
+ $where_query3 = [];
|
|
|
|
|
+ //查询指定公司责任人
|
|
|
|
|
+ if (!empty($employee_id_list)) {
|
|
|
|
|
+ $where_query1[] = ['company_id', '=', $company_id];
|
|
|
|
|
+ $where_query1[] = ['id', 'in', $employee_id_list];
|
|
|
|
|
+ $where_query1[] = ['status', '=', 0];
|
|
|
|
|
+ $where_query1[] = ['duty_type', '=', 2]; //责任类型1=第一责任人,2=责任人
|
|
|
|
|
+ }
|
|
|
|
|
+ //查询地区配置的员工
|
|
|
|
|
+ $employee_id_area = $EmployeeAreaModel->where('city_id', $product_data['city_id'])->pluck('employee_id')->toarray();
|
|
|
|
|
+ if (!empty($employee_id_area)) {
|
|
|
|
|
+ $where_query2[] = ['company_id', '=', $company_id];
|
|
|
|
|
+ $where_query2[] = ['id', 'in', $employee_id_area];
|
|
|
|
|
+ $where_query2[] = ['status', '=', 0];
|
|
|
|
|
+ $where_query2[] = ['duty_type', '=', 2]; //责任类型1=第一责任人,2=责任人
|
|
|
|
|
+ }
|
|
|
|
|
+ //查询平台配置的员工
|
|
|
|
|
+ $employee_id_platform = $EmployeePlatformModel->where('platform_id', $product_data['platform_id'])->pluck('employee_id')->toarray();
|
|
|
|
|
+ if (!empty($employee_id_platform)) {
|
|
|
|
|
+ $where_query3[] = ['company_id', '=', $company_id];
|
|
|
|
|
+ $where_query3[] = ['id', 'in', $employee_id_platform];
|
|
|
|
|
+ $where_query3[] = ['status', '=', 0];
|
|
|
|
|
+ $where_query3[] = ['duty_type', '=', 2]; //责任类型1=第一责任人,2=责任人
|
|
|
|
|
+ }
|
|
|
|
|
+ //并行查询责任人
|
|
|
|
|
+ $EmployeeModel = new EmployeeModel();
|
|
|
|
|
+ $EmployeeModel = $EmployeeModel
|
|
|
|
|
+ ->orWhere(function ($q) use ($employee_id_list, $company_id) {
|
|
|
|
|
+ if (!empty($employee_id_list)) {
|
|
|
|
|
+ $q->where('company_id', $company_id)
|
|
|
|
|
+ ->orWhereIn('id', $employee_id_list)
|
|
|
|
|
+ ->where('duty_type', 2)
|
|
|
|
|
+ ->where('status', 0);
|
|
|
|
|
+ }
|
|
|
|
|
+ })->orWhere(function ($q) use ($employee_id_area, $company_id) {
|
|
|
|
|
+ if (!empty($employee_id_area)) {
|
|
|
|
|
+ $q->where('company_id', $company_id)
|
|
|
|
|
+ ->whereIn('id', $employee_id_area)
|
|
|
|
|
+ ->where('duty_type', 2)
|
|
|
|
|
+ ->where('status', 0);
|
|
|
|
|
+ }
|
|
|
|
|
+ })->orWhere(function ($q) use ($employee_id_platform, $company_id) {
|
|
|
|
|
+ if (!empty($employee_id_platform)) {
|
|
|
|
|
+ $q->where('company_id', $company_id)
|
|
|
|
|
+ ->whereIn('id', $employee_id_platform)
|
|
|
|
|
+ ->where('duty_type', 2)
|
|
|
|
|
+ ->where('status', 0);
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ $responsible_person = $EmployeeModel->pluck('id')->implode(',');
|
|
|
|
|
+
|
|
|
|
|
+ //当以上规则匹配不到责任人时,则去查询发货地区信息关联责任人
|
|
|
|
|
+ if (trim($responsible_person) == '' && trim($product_data['shipment_city_id']) != '') {
|
|
|
|
|
+ $employee_id_area = $EmployeeAreaModel->where('company_id', $company_id)->where('city_id', $product_data['shipment_city_id'])->pluck('employee_id')->toarray();
|
|
|
|
|
+ if (!empty($employee_id_area)) {
|
|
|
|
|
+ $where_city = [];
|
|
|
|
|
+ $where_city[] = ['company_id', '=', $company_id];
|
|
|
|
|
+ $where_city[] = ['status', '=', 0];
|
|
|
|
|
+ $where_city[] = ['duty_type', '=', 2]; //责任类型1=第一责任人,2=责任人
|
|
|
|
|
+ $EmployeeModel = new EmployeeModel();
|
|
|
|
|
+ $responsible_person = $EmployeeModel->whereIn('id', $employee_id_area)->where($where_city)->pluck('id')->implode(',');
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ $insert_product_data['responsible_person'] = $responsible_person;
|
|
|
|
|
+
|
|
|
|
|
+ //溯源责任人
|
|
|
|
|
+ $source_responsible_person = '';
|
|
|
|
|
+ if ($first_responsible_person && $responsible_person) {
|
|
|
|
|
+ //转换成数组,合并后在去重
|
|
|
|
|
+ $first_responsible_person = explode(',', $first_responsible_person);
|
|
|
|
|
+ $responsible_person = explode(',', $responsible_person);
|
|
|
|
|
+ $source_responsible_person = array_unique(array_merge($first_responsible_person, $responsible_person));
|
|
|
|
|
+ $source_responsible_person = ',' . implode(',', $source_responsible_person) . ',';
|
|
|
|
|
+ } else if ($first_responsible_person) {
|
|
|
|
|
+ $source_responsible_person = $first_responsible_person;
|
|
|
|
|
+ } else if ($responsible_person) {
|
|
|
|
|
+ $source_responsible_person = $responsible_person;
|
|
|
|
|
+ }
|
|
|
|
|
+ $insert_product_data['source_responsible_person'] = $source_responsible_person;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return $insert_product_data;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 低价商品清洗数据回填
|
|
* 低价商品清洗数据回填
|
|
|
* @author: 唐远望
|
|
* @author: 唐远望
|
|
|
* @version: 1.0
|
|
* @version: 1.0
|
|
|
* @date: 2026-04-29
|
|
* @date: 2026-04-29
|
|
|
*/
|
|
*/
|
|
|
- public function low_price_product_collect_data(LowPriceGoodsModel $LowPriceGoodsModel)
|
|
|
|
|
|
|
+ public function low_price_product_collect_collection_time_data(LowPriceGoodsModel $LowPriceGoodsModel)
|
|
|
{
|
|
{
|
|
|
//获取非导入的低价商品清洗数据
|
|
//获取非导入的低价商品清洗数据
|
|
|
$map = [];
|
|
$map = [];
|
|
@@ -54,23 +383,50 @@ class CollectData extends Controller
|
|
|
{
|
|
{
|
|
|
//获取非导入的低价商品清洗数据
|
|
//获取非导入的低价商品清洗数据
|
|
|
$map = [];
|
|
$map = [];
|
|
|
- $map[] = ['process_violation_product.source_id', '!=', '0'];
|
|
|
|
|
- $map[] = ['process_violation_product.collection_time', '==', '0'];
|
|
|
|
|
- $map[] = ['scrape_data.insert_time', '!=', 'null'];
|
|
|
|
|
- $limit = '10000';
|
|
|
|
|
- $result = $ViolationProductModel->leftjoin('scrape_data', 'scrape_data.id', '=', 'process_violation_product.source_id')
|
|
|
|
|
- ->where($map)->select(['process_violation_product.id', 'scrape_data.insert_time as collect_collection_time'])
|
|
|
|
|
- ->orderByDesc('id')->paginate($limit)->toarray();
|
|
|
|
|
- if (!empty($result['data'])) {
|
|
|
|
|
- foreach ($result['data'] as $key => $value) {
|
|
|
|
|
- if (empty($value['collect_collection_time'])) {
|
|
|
|
|
- continue;
|
|
|
|
|
|
|
+ $map[] = ['merge_city_id', '!=', '0'];
|
|
|
|
|
+ $map[] = ['first_responsible_person', '=', ''];
|
|
|
|
|
+ $map[] = ['responsible_person', '=', ''];
|
|
|
|
|
+ $map[] = ['source_responsible_person', '=', ''];
|
|
|
|
|
+ $limit = '100';
|
|
|
|
|
+ DB::beginTransaction();
|
|
|
|
|
+ try {
|
|
|
|
|
+ $result = $ViolationProductModel->where($map)->orderByDesc('id')->paginate($limit)->toarray();
|
|
|
|
|
+ if (!empty($result['data'])) {
|
|
|
|
|
+ foreach ($result['data'] as $key => $product_data) {
|
|
|
|
|
+ $specify_responsible_person = 0;
|
|
|
|
|
+ //获取指定人员信息
|
|
|
|
|
+ $insert_product_data = [];
|
|
|
|
|
+ if ($specify_responsible_person == 0) {
|
|
|
|
|
+ $product_data['qualification_number'] = $product_data['social_credit_code'];
|
|
|
|
|
+ $product_data['platform_id'] = $product_data['platform'];
|
|
|
|
|
+ $insert_product_data = $this->get_responsible_person_info($product_data);
|
|
|
|
|
+ }
|
|
|
|
|
+ $update_data = $insert_product_data;
|
|
|
|
|
+ if (!empty($update_data) && count($update_data) > 0) {
|
|
|
|
|
+ $ViolationProductModel->where('id', $product_data['id'])->update($update_data);
|
|
|
|
|
+ $this->insert_violation_product_responsible_person_info($product_data, $insert_product_data);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- $update_data['collection_time'] = strtotime($value['collect_collection_time']);
|
|
|
|
|
- $ViolationProductModel->where('id', $value['id'])->update($update_data);
|
|
|
|
|
}
|
|
}
|
|
|
|
|
+ DB::commit();
|
|
|
|
|
+ return json_send(['code' => 'success', 'msg' => '执行成功', 'data' => count($result['data'])]);
|
|
|
|
|
+ // 成功处理...
|
|
|
|
|
+ } catch (\Exception $e) {
|
|
|
|
|
+ DB::rollBack();
|
|
|
|
|
+ return json_send(['code' => 'error', 'msg' => '执行失败', 'data' => $e->getMessage()]);
|
|
|
}
|
|
}
|
|
|
- return json_send(['code' => 'success', 'msg' => '执行成功', 'data' => count($result['data'])]);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 写入处理禁止商品-责任人信息
|
|
|
|
|
+ * @author: 唐远望
|
|
|
|
|
+ * @version: 1.0
|
|
|
|
|
+ * @date: 2026-05-18
|
|
|
|
|
+ */
|
|
|
|
|
+ public function insert_violation_product_responsible_person_info($product_data, $insert_product_data)
|
|
|
|
|
+ {
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
/**
|
|
/**
|
|
|
* 违规店铺清洗数据回填
|
|
* 违规店铺清洗数据回填
|