$data['first_responsible_person'], 'responsible_person' => $data['responsible_person'], 'platform' => $data['platform'], 'company_name' => $data['company_name'], 'product_name' => $data['product_name'], 'product_specs' => $data['product_specs'], 'online_posting_cunt' => $data['online_posting_cunt'], 'link_url' => $data['link_url'], 'store_name' => $data['store_name'], 'source_responsible_person' => $data['source_responsible_person'], 'processing_status' => '1', 'insert_time' => time(), ]; $ViolationProduct_id = $this->insertGetId($insert_data); return $ViolationProduct_id; } /** * 写入数据 * @author 唐远望 * @version 1.0 * @date 2025-12-08 * @param $data * @return bool */ public function addViolationProduct($data) { DB::beginTransaction(); try { $ViolationProductMemberModel = new ViolationProductMemberModel(); $insert_data = [ 'first_responsible_person' => $data['first_responsible_person'], 'responsible_person' => $data['responsible_person'], 'platform' => $data['platform'], 'company_name' => $data['company_name'], 'product_name' => $data['product_name'], 'product_specs' => $data['product_specs'], 'online_posting_cunt' => $data['online_posting_cunt'], 'link_url' => $data['link_url'], 'store_name' => $data['store_name'], 'source_responsible_person' => $data['source_responsible_person'], 'processing_status' => '1', 'insert_time' => time(), ]; $ViolationProduct_id = $this->insertGetId($insert_data); $first_responsible_persons = explode(',', $data['first_responsible_person']); $first_responsible_person_data = []; if (count($first_responsible_persons) > 0) { foreach ($first_responsible_persons as $key => $employee_id) { $first_responsible_person_data[] = [ 'violation_product_logid' => $ViolationProduct_id, 'employee_id' => $employee_id, 'duty_type' => 1, //责任类型1=第一责任人,2=责任人,3=溯源责任人 ]; } } $ViolationProductMemberModel->inser($first_responsible_person_data); $responsible_persons = explode(',', $data['responsible_person']); $responsible_person_data = []; if (count($responsible_persons) > 0) { foreach ($responsible_persons as $key => $employee_id) { $responsible_person_data[] = [ 'violation_product_logid' => $ViolationProduct_id, 'employee_id' => $employee_id, 'duty_type' => 2, //责任类型1=第一责任人,2=责任人,3=溯源责任人 ]; } } $ViolationProductMemberModel->inser($responsible_person_data); $source_responsible_persons = explode(',', $data['source_responsible_person']); $source_responsible_person_data = []; if (count($source_responsible_persons) > 0) { foreach ($source_responsible_persons as $key => $employee_id) { $source_responsible_person_data[] = [ 'violation_product_logid' => $ViolationProduct_id, 'employee_id' => $employee_id, 'duty_type' => 3, //责任类型1=第一责任人,2=责任人,3=溯源责任人 ]; } } $ViolationProductMemberModel->inser($source_responsible_person_data); DB::commit(); return true; // 成功处理... } catch (\Exception $e) { DB::rollBack(); // 错误处理... return false; } } /** * 编辑内容 * @author 唐远望 * @version 1.0 * @date 2025-12-08 * @param $data * @return bool */ public function editViolationProduct_content($where, $data) { $ViolationProduct = $this->where($where)->first(); if (!$ViolationProduct) { return false; } $ViolationProduct->first_responsible_person = $data['first_responsible_person']; $ViolationProduct->responsible_person = $data['responsible_person']; $ViolationProduct->platform = $data['platform']; $ViolationProduct->company_name = $data['company_name']; $ViolationProduct->product_name = $data['product_name']; $ViolationProduct->product_specs = $data['product_specs']; $ViolationProduct->online_posting_cunt = $data['online_posting_cunt']; $ViolationProduct->link_url = $data['link_url']; $ViolationProduct->store_name = $data['store_name']; $ViolationProduct->source_responsible_person = $data['source_responsible_person']; $ViolationProduct->update_time = time(); $ViolationProduct->save(); return true; } /** * 更新数据 * @author 唐远望 * @version 1.0 * @date 2025-12-08 * @param $data * @return bool */ public function updateViolationProduct($where, $data) { DB::beginTransaction(); try { $this->editViolationProduct_content($where, $data); DB::commit(); return true; // 成功处理... } catch (\Exception $e) { DB::rollBack(); // 错误处理... return false; } } /** * 修改状态 * @author 唐远望 * @version 1.0 * @date 2025-12-08 * @param $id * @param $status * @return bool */ public function changeStatus($where, $status) { $ViolationProduct = $this->where($where)->first(); if (!$ViolationProduct) { return false; } $ViolationProduct->status = $status; $ViolationProduct->update_time = time(); $ViolationProduct->save(); return true; } /** * 修改处理状态 * @author 唐远望 * @version 1.0 * @date 2025-12-08 * @param $id * @param $processing_status * @return bool */ public function changeProcessingStatus($where, $processing_status) { $ViolationProduct = $this->where($where)->first(); if (!$ViolationProduct) { return false; } $ViolationProduct->processing_status = $processing_status; $ViolationProduct->update_time = time(); $ViolationProduct->save(); return true; } /** * 删除数据 * @author 唐远望 * @version 1.0 * @date 2025-12-08 * @param $id * @return bool */ public function deleteViolationProduct($where) { $ViolationProduct = $this->where($where)->first(); if (!$ViolationProduct) { return false; } $ViolationProduct->delete(); return true; } }