ViolationProduct.php 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510
  1. <?php
  2. namespace App\Models\Manager\Process;
  3. use Illuminate\Database\Eloquent\Factories\HasFactory;
  4. use Illuminate\Database\Eloquent\Model;
  5. use Illuminate\Support\Facades\DB;
  6. use App\Models\Manager\Process\ViolationProductMember as ViolationProductMemberModel;
  7. use App\Facades\Servers\Logs\Log;
  8. use App\Models\Manager\Process\Notices as NoticesModel;
  9. use App\Models\Manager\Personnel\Employee as EmployeeModel;
  10. /**
  11. * 违规处理-违规商品模型
  12. * @author: 唐远望
  13. * @version: 1.0
  14. * @date: 2025-12-08
  15. */
  16. class ViolationProduct extends Model
  17. {
  18. use HasFactory;
  19. // 与模型关联的表名
  20. protected $table = 'process_violation_product';
  21. // 是否主动维护时间戳
  22. public $timestamps = false;
  23. // 定义时间戳字段名
  24. // const CREATED_AT = 'insert_time';
  25. // const UPDATED_AT = 'update_time';
  26. /**
  27. * 平台定义
  28. * @author 唐远望
  29. * @version 1.0
  30. * @date 2025-12-31
  31. */
  32. public function platform_data()
  33. {
  34. //平台0=全部,1=淘宝,2=京东,3=拼多多,4=美团,5=药师帮,6=1药城,7=药九九,8=药易购,9=药帮忙,10=熊猫药药11=药房网
  35. $platform_data = [
  36. '全部' => '0',
  37. '淘宝' => '1',
  38. '京东' => '2',
  39. '拼多多' => '3',
  40. '美团' => '4',
  41. '药师帮' => '5',
  42. '1药城' => '6',
  43. '药九九' => '7',
  44. '药易购' => '8',
  45. '药帮忙' => '9',
  46. '熊猫药药' => '10',
  47. '药房网' => '11'
  48. ];
  49. return $platform_data;
  50. }
  51. /**
  52. * 添加
  53. * @author 唐远望
  54. * @version 1.0
  55. * @date 2025-12-08
  56. */
  57. public function addViolationProduct_content($data)
  58. {
  59. $insert_data = [
  60. 'company_id' => $data['company_id'],
  61. 'source_id' => $data['source_id'],
  62. 'first_responsible_person' => $data['first_responsible_person'] ? ',' . $data['first_responsible_person'] . ',' : '',
  63. 'responsible_person' => $data['responsible_person'] ? ',' . $data['responsible_person'] . ',' : '',
  64. 'platform' => $data['platform'],
  65. 'company_name' => $data['company_name'],
  66. 'product_brand' => isset($data['product_brand']) ? $data['product_brand'] : '',
  67. 'product_name' => $data['product_name'],
  68. 'product_specs' => $data['product_specs'],
  69. 'online_posting_count' => isset($data['online_posting_count']) && is_numeric($data['online_posting_count']) ? $data['online_posting_count'] : 1,
  70. 'continuous_listing_count' => isset($data['continuous_listing_count']) && is_numeric($data['continuous_listing_count']) ? $data['continuous_listing_count'] : 1,
  71. 'social_credit_code' => $data['social_credit_code'],
  72. 'province_id' => $data['province_id'],
  73. 'province_name' => isset($data['province_name']) ? $data['province_name'] : '',
  74. 'city_id' => $data['city_id'],
  75. 'city_name' => isset($data['city_name']) ? $data['city_name'] : '',
  76. 'area_info' => $data['area_info'],
  77. 'link_url' => $data['link_url'],
  78. 'store_name' => $data['store_name'],
  79. 'anonymous_store_name' => isset($data['anonymous_store_name']) ? $data['anonymous_store_name'] : '',
  80. 'source_responsible_person' => $data['source_responsible_person'] ? ',' . $data['source_responsible_person'] . ',' : '',
  81. 'category_name' => $data['category_name'],
  82. 'company_category_name' => $data['company_category_name'],
  83. 'processing_status' => '1',
  84. 'insert_time' => time(),
  85. 'scrape_date' => isset($data['scrape_date']) ? $data['scrape_date'] : '',
  86. 'collection_time' => isset($data['collection_time']) ? $data['collection_time'] : '',
  87. 'shipment_province_id' => isset($data['shipment_province_id']) ? $data['shipment_province_id'] : '0', // 发货省份id
  88. 'shipment_province_name' => isset($data['shipment_province_name']) ? $data['shipment_province_name'] : '', // 发货省份
  89. 'shipment_city_id' => isset($data['shipment_city_id']) ? $data['shipment_city_id'] : '0', // 发货城市id
  90. 'shipment_city_name' => isset($data['shipment_city_name']) ? $data['shipment_city_name'] : '', // 发货城市
  91. ];
  92. $ViolationProduct_id = $this->insertGetId($insert_data);
  93. return $ViolationProduct_id;
  94. }
  95. /**
  96. * 写入数据
  97. * @author 唐远望
  98. * @version 1.0
  99. * @date 2025-12-08
  100. * @param $data
  101. * @return bool
  102. */
  103. public function addViolationProduct($data, $is_import = false)
  104. {
  105. if ($is_import == false) {
  106. //去重规则:品牌方公司ID+店铺公司名称+店铺名称+品牌名称+商品名称+规格+盒数(针对采集)
  107. $source_where[] = ['company_id', '=', $data['company_id']]; //品牌方公司ID
  108. $source_where[] = ['company_name', '=', $data['company_name']]; //店铺公司名称
  109. $source_where[] = ['store_name', '=', $data['store_name']]; //店铺名称
  110. $source_where[] = ['product_brand', '=', $data['product_brand']]; //品牌名称
  111. $source_where[] = ['product_name', '=', $data['product_name']]; //商品名称
  112. $source_where[] = ['product_specs', '=', $data['product_specs']]; //规格
  113. $source_id_log = $this->where($source_where)->count();
  114. if ($source_id_log > 0) {
  115. return true;
  116. }
  117. }
  118. DB::beginTransaction();
  119. try {
  120. //执行挂网数据统计
  121. $data = $this->handleCountData($data);
  122. $ViolationProductMemberModel = new ViolationProductMemberModel();
  123. $insert_data = [
  124. 'company_id' => $data['company_id'],
  125. 'source_id' => $data['source_id'],
  126. 'first_responsible_person' => $data['first_responsible_person'] ? ',' . $data['first_responsible_person'] . ',' : '',
  127. 'responsible_person' => $data['responsible_person'] ? ',' . $data['responsible_person'] . ',' : '',
  128. 'platform' => $data['platform'],
  129. 'company_name' => $data['company_name'],
  130. 'product_brand' => isset($data['product_brand']) ? $data['product_brand'] : '',
  131. 'product_name' => $data['product_name'],
  132. 'product_specs' => $data['product_specs'],
  133. 'online_posting_count' => isset($data['online_posting_count']) && is_numeric($data['online_posting_count']) ? $data['online_posting_count'] : 1,
  134. 'continuous_listing_count' => isset($data['continuous_listing_count']) && is_numeric($data['continuous_listing_count']) ? $data['continuous_listing_count'] : 1,
  135. 'social_credit_code' => $data['social_credit_code'],
  136. 'province_id' => $data['province_id'],
  137. 'province_name' => isset($data['province_name']) ? $data['province_name'] : '',
  138. 'city_id' => $data['city_id'],
  139. 'city_name' => isset($data['city_name']) ? $data['city_name'] : '',
  140. 'area_info' => $data['area_info'],
  141. 'link_url' => $data['link_url'],
  142. 'store_name' => $data['store_name'],
  143. 'anonymous_store_name' => isset($data['anonymous_store_name']) ? $data['anonymous_store_name'] : '',
  144. 'source_responsible_person' => $data['source_responsible_person'] ? ',' . $data['source_responsible_person'] . ',' : '',
  145. 'category_name' => $data['category_name'],
  146. 'company_category_name' => $data['company_category_name'],
  147. 'processing_status' => '1',
  148. 'insert_time' => time(),
  149. 'scrape_date' => isset($data['scrape_date']) ? $data['scrape_date'] : '',
  150. 'collection_time' => isset($data['collection_time']) ? $data['collection_time'] : '',
  151. 'shipment_province_id' => isset($data['shipment_province_id']) ? $data['shipment_province_id'] : '0', // 发货省份id
  152. 'shipment_province_name' => isset($data['shipment_province_name']) ? $data['shipment_province_name'] : '', // 发货省份
  153. 'shipment_city_id' => isset($data['shipment_city_id']) ? $data['shipment_city_id'] : '0', // 发货城市id
  154. 'shipment_city_name' => isset($data['shipment_city_name']) ? $data['shipment_city_name'] : '', // 发货城市
  155. ];
  156. $ViolationProduct_id = $this->insertGetId($insert_data);
  157. $first_responsible_persons = $data['first_responsible_person'] != '' ? explode(',', $data['first_responsible_person']) : [];
  158. $first_responsible_person_data = [];
  159. if (count($first_responsible_persons) > 0) {
  160. foreach ($first_responsible_persons as $key => $employee_id) {
  161. //如果不是数字或者为空,则跳过
  162. if ($employee_id == '' || is_null($employee_id) || !is_numeric($employee_id)) continue;
  163. $first_responsible_person_data[] = [
  164. 'violation_product_logid' => $ViolationProduct_id,
  165. 'employee_id' => $employee_id,
  166. 'duty_type' => 1, //责任类型1=第一责任人,2=责任人,3=溯源责任人
  167. ];
  168. }
  169. }
  170. $ViolationProductMemberModel->insert($first_responsible_person_data);
  171. $responsible_persons = $data['responsible_person'] != '' ? explode(',', $data['responsible_person']) : [];
  172. $responsible_person_data = [];
  173. if (count($responsible_persons) > 0) {
  174. foreach ($responsible_persons as $key => $employee_id) {
  175. //如果不是数字或者为空,则跳过
  176. if ($employee_id == '' || is_null($employee_id) || !is_numeric($employee_id)) continue;
  177. $responsible_person_data[] = [
  178. 'violation_product_logid' => $ViolationProduct_id,
  179. 'employee_id' => $employee_id,
  180. 'duty_type' => 2, //责任类型1=第一责任人,2=责任人,3=溯源责任人
  181. ];
  182. }
  183. }
  184. $ViolationProductMemberModel->insert($responsible_person_data);
  185. $source_responsible_persons = $data['source_responsible_person'] != '' ? explode(',', $data['source_responsible_person']) : [];
  186. $source_responsible_person_data = [];
  187. if (count($source_responsible_persons) > 0) {
  188. foreach ($source_responsible_persons as $key => $employee_id) {
  189. //如果不是数字或者为空,则跳过
  190. if ($employee_id == '' || is_null($employee_id) || !is_numeric($employee_id)) continue;
  191. $source_responsible_person_data[] = [
  192. 'violation_product_logid' => $ViolationProduct_id,
  193. 'employee_id' => $employee_id,
  194. 'duty_type' => 3, //责任类型1=第一责任人,2=责任人,3=溯源责任人
  195. ];
  196. }
  197. }
  198. $ViolationProductMemberModel->insert($source_responsible_person_data);
  199. //添加通知
  200. // $this->addNotices($insert_data, $ViolationProduct_id);
  201. DB::commit();
  202. return true;
  203. // 成功处理...
  204. } catch (\Exception $e) {
  205. DB::rollBack();
  206. // 错误处理...
  207. Log::info('job_error', '数据清洗-新增违规商品处理记录失败', ['data' => $data, 'error' => $e->getMessage()]);
  208. return false;
  209. }
  210. }
  211. /**
  212. * 处理连续挂网&累计挂网数据统计
  213. * @author 唐远望
  214. * @version 1.0
  215. * @date 2026-05-07
  216. *
  217. */
  218. public function handleCountData($product_data_info)
  219. {
  220. $collect_config_info = $product_data_info['collect_config_info'];
  221. if (trim($collect_config_info) == '') return $product_data_info;
  222. $collect_config_info = json_decode($collect_config_info, true); //{"sampling_cycle": "", "sampling_start_time": "", "sampling_end_time": ""}
  223. //采集周期
  224. $sampling_cycle = isset($collect_config_info['sampling_cycle']) ? explode(',',$collect_config_info['sampling_cycle']) : '';
  225. //采集开始时间
  226. $sampling_start_time = isset($collect_config_info['sampling_start_time']) ? $collect_config_info['sampling_start_time'] : '';
  227. //采集结束时间
  228. $sampling_end_time = isset($collect_config_info['sampling_end_time']) ? $collect_config_info['sampling_end_time'] : '';
  229. if (!is_array($sampling_cycle)) return $product_data_info;
  230. $current_time = time();
  231. //如果当前时间在采集开始时间结束时间范围内,则进行连续挂网和累计挂网统计
  232. if ($sampling_start_time != '' && $sampling_end_time != '' && $current_time >= $sampling_start_time && $current_time <= $sampling_end_time) {
  233. // 获取采集时间是星期几
  234. $collection_time = strtotime($product_data_info['collection_time']);
  235. $now_week = date('w', $collection_time);
  236. if ($now_week == 0) {
  237. $now_week = 7;
  238. }
  239. if(!in_array($now_week, $sampling_cycle)){
  240. return $product_data_info;
  241. }
  242. //查询当前商品是否在上一个周期采集中过
  243. $up_scrape_date_time = $collection_time - 7 * 24 * 3600;//查询上周这个时间点
  244. $up_scrape_date = date('Y-m-d', $up_scrape_date_time);
  245. $source_last_week_where[] = ['company_id', '=', $product_data_info['company_id']]; //品牌方公司ID
  246. $source_last_week_where[] = ['platform', '=', $product_data_info['platform']]; //挂网平台ID
  247. $source_last_week_where[] = ['company_name', '=', $product_data_info['company_name']]; //店铺公司名称
  248. $source_last_week_where[] = ['store_name', '=', $product_data_info['store_name']]; //店铺名称
  249. $source_last_week_where[] = ['product_brand', '=', $product_data_info['product_brand']]; //品牌名称
  250. $source_last_week_where[] = ['product_name', '=', $product_data_info['product_name']]; //商品名称
  251. $source_last_week_where[] = ['product_specs', '=', $product_data_info['product_specs']]; //规格
  252. $source_last_week_where[] = ['scrape_date', '=', $up_scrape_date]; //上个周期采集日期
  253. $source_last_week_log = $this->where($source_last_week_where)->count();
  254. if ($source_last_week_log > 0) {
  255. $product_data_info['continuous_listing_count'] = $product_data_info['continuous_listing_count'] + 1; //连续挂网次数+1
  256. }
  257. //查询当前商品上次连续挂网次数
  258. $source_last_time_where[] = ['company_id', '=', $product_data_info['company_id']]; //品牌方公司ID
  259. $source_last_time_where[] = ['platform', '=', $product_data_info['platform']]; //挂网平台ID
  260. $source_last_time_where[] = ['company_name', '=', $product_data_info['company_name']]; //店铺公司名称
  261. $source_last_time_where[] = ['store_name', '=', $product_data_info['store_name']]; //店铺名称
  262. $source_last_time_where[] = ['product_brand', '=', $product_data_info['product_brand']]; //品牌名称
  263. $source_last_time_where[] = ['product_name', '=', $product_data_info['product_name']]; //商品名称
  264. $source_last_time_where[] = ['product_specs', '=', $product_data_info['product_specs']]; //规格
  265. $source_last_time_log = $this->where($source_last_time_where)->orderbyDesc('scrape_date')->first();
  266. if (!empty($source_last_time_log)) {
  267. $product_data_info['online_posting_count'] = $source_last_time_log->online_posting_count + 1; //累计挂网次数+1
  268. }
  269. } else if ($sampling_start_time != '' && $sampling_end_time == '' && $current_time >= $sampling_start_time) {
  270. //如果当前时间在采集开始时间结束时间未设置,则进行连续挂网和累计挂网统计
  271. // 获取采集时间是星期几
  272. $collection_time = strtotime($product_data_info['collection_time']);
  273. $now_week = date('w', $collection_time);
  274. if ($now_week == 0) {
  275. $now_week = 7;
  276. }
  277. if(!in_array($now_week, $sampling_cycle)){
  278. return $product_data_info;
  279. }
  280. //查询当前商品是否在上一个周期采集中过
  281. $up_scrape_date_time = $collection_time - 7 * 24 * 3600;//查询上周这个时间点
  282. //查询当前商品上次采集记录
  283. $up_scrape_date = date('Y-m-d', $up_scrape_date_time);
  284. $source_last_week_where[] = ['company_id', '=', $product_data_info['company_id']]; //品牌方公司ID
  285. $source_last_week_where[] = ['platform', '=', $product_data_info['platform']]; //挂网平台ID
  286. $source_last_week_where[] = ['company_name', '=', $product_data_info['company_name']]; //店铺公司名称
  287. $source_last_week_where[] = ['store_name', '=', $product_data_info['store_name']]; //店铺名称
  288. $source_last_week_where[] = ['product_brand', '=', $product_data_info['product_brand']]; //品牌名称
  289. $source_last_week_where[] = ['product_name', '=', $product_data_info['product_name']]; //商品名称
  290. $source_last_week_where[] = ['product_specs', '=', $product_data_info['product_specs']]; //规格
  291. $source_last_week_where[] = ['scrape_date', '=', $up_scrape_date]; //上个周期采集日期
  292. $source_last_week_log = $this->where($source_last_week_where)->count();
  293. if ($source_last_week_log > 0) {
  294. $product_data_info['continuous_listing_count'] = $product_data_info['continuous_listing_count'] + 1; //连续挂网次数+1
  295. }
  296. //查询当前商品上次连续挂网次数
  297. $source_last_time_where[] = ['company_id', '=', $product_data_info['company_id']]; //品牌方公司ID
  298. $source_last_time_where[] = ['platform', '=', $product_data_info['platform']]; //挂网平台ID
  299. $source_last_time_where[] = ['company_name', '=', $product_data_info['company_name']]; //店铺公司名称
  300. $source_last_time_where[] = ['store_name', '=', $product_data_info['store_name']]; //店铺名称
  301. $source_last_time_where[] = ['product_brand', '=', $product_data_info['product_brand']]; //品牌名称
  302. $source_last_time_where[] = ['product_name', '=', $product_data_info['product_name']]; //商品名称
  303. $source_last_time_where[] = ['product_specs', '=', $product_data_info['product_specs']]; //规格
  304. $source_last_time_log = $this->where($source_last_time_where)->orderbyDesc('scrape_date')->first();
  305. if (!empty($source_last_time_log)) {
  306. $product_data_info['online_posting_count'] = $source_last_time_log->online_posting_count + 1; //累计挂网次数+1
  307. }
  308. }
  309. return $product_data_info;
  310. }
  311. /**
  312. * 处理通知消息
  313. * @author 唐远望
  314. * @version 1.0
  315. * @date 2026-03-21
  316. * @param $data
  317. * @return bool
  318. */
  319. public function addNotices($low_price_data, $data_logid)
  320. {
  321. //添加通知
  322. $NoticesModel = new NoticesModel();
  323. $EmployeeModel = new EmployeeModel();
  324. $notices_data = [];
  325. if ($low_price_data['first_responsible_person'] != '' && $low_price_data['responsible_person'] != '') {
  326. //合并数据并去重
  327. $first_responsible_persons = array_unique(explode(',', $low_price_data['first_responsible_person']));
  328. $responsible_persons = array_unique(explode(',', $low_price_data['responsible_person']));
  329. $all_persons = array_merge($first_responsible_persons, $responsible_persons);
  330. //查询已已经开启通知设置的用户
  331. $employee_ids = $EmployeeModel->whereIn('id', $all_persons)->where('open_notice', 0)->pluck('id')->toArray();
  332. if (count($employee_ids) == 0) return true;
  333. foreach ($employee_ids as $key => $employee_id) {
  334. if ($employee_id == '' || is_null($employee_id)) continue;
  335. $notices_data[] = [
  336. 'company_id' => $low_price_data['company_id'],
  337. 'custom_uid' => $employee_id,
  338. 'title' => '您有一条新的禁止商品待处理,请及时查看。',
  339. 'content_type' => '2', //内容类型1=低价挂网2=禁止挂网3=违规店铺
  340. 'data_logid' => $data_logid,
  341. 'insert_time' => time()
  342. ];
  343. }
  344. $NoticesModel->insert($notices_data);
  345. } else if ($low_price_data['first_responsible_person'] != '') {
  346. $first_responsible_persons = array_unique(explode(',', $low_price_data['first_responsible_person']));
  347. //查询已已经开启通知设置的用户
  348. $employee_ids = $EmployeeModel->whereIn('id', $first_responsible_persons)->where('open_notice', 0)->pluck('id')->toArray();
  349. if (count($employee_ids) == 0) return true;
  350. foreach ($employee_ids as $key => $employee_id) {
  351. if ($employee_id == '' || is_null($employee_id)) continue;
  352. $notices_data[] = [
  353. 'company_id' => $low_price_data['company_id'],
  354. 'custom_uid' => $employee_id,
  355. 'title' => '您有一条新的禁止商品待处理,请及时查看。',
  356. 'content_type' => '2', //内容类型1=低价挂网2=禁止挂网3=违规店铺
  357. 'data_logid' => $data_logid,
  358. 'insert_time' => time()
  359. ];
  360. }
  361. $NoticesModel->insert($notices_data);
  362. } else if ($low_price_data['responsible_person'] != '') {
  363. $responsible_persons = array_unique(explode(',', $low_price_data['responsible_person']));
  364. //查询已已经开启通知设置的用户
  365. $employee_ids = $EmployeeModel->whereIn('id', $responsible_persons)->where('open_notice', 0)->pluck('id')->toArray();
  366. if (count($employee_ids) == 0) return true;
  367. foreach ($employee_ids as $key => $employee_id) {
  368. if ($employee_id == '' || is_null($employee_id)) continue;
  369. $notices_data[] = [
  370. 'company_id' => $low_price_data['company_id'],
  371. 'custom_uid' => $employee_id,
  372. 'title' => '您有一条新的禁止商品待处理,请及时查看。',
  373. 'content_type' => '2', //内容类型1=低价挂网2=禁止挂网3=违规店铺
  374. 'data_logid' => $data_logid,
  375. 'insert_time' => time()
  376. ];
  377. }
  378. $NoticesModel->insert($notices_data);
  379. }
  380. return true;
  381. }
  382. /**
  383. * 编辑内容
  384. * @author 唐远望
  385. * @version 1.0
  386. * @date 2025-12-08
  387. * @param $data
  388. * @return bool
  389. */
  390. public function editViolationProduct_content($where, $data)
  391. {
  392. $ViolationProduct = $this->where($where)->first();
  393. if (!$ViolationProduct) {
  394. return false;
  395. }
  396. $ViolationProduct->company_id = $data['company_id'];
  397. $ViolationProduct->first_responsible_person = $data['first_responsible_person'];
  398. $ViolationProduct->responsible_person = $data['responsible_person'];
  399. $ViolationProduct->platform = $data['platform'];
  400. $ViolationProduct->company_name = $data['company_name'];
  401. $ViolationProduct->product_name = $data['product_name'];
  402. $ViolationProduct->product_specs = $data['product_specs'];
  403. $ViolationProduct->online_posting_count = $data['online_posting_count'];
  404. $ViolationProduct->link_url = $data['link_url'];
  405. $ViolationProduct->store_name = $data['store_name'];
  406. $ViolationProduct->source_responsible_person = $data['source_responsible_person'];
  407. $ViolationProduct->update_time = time();
  408. $ViolationProduct->save();
  409. return true;
  410. }
  411. /**
  412. * 更新数据
  413. * @author 唐远望
  414. * @version 1.0
  415. * @date 2025-12-08
  416. * @param $data
  417. * @return bool
  418. */
  419. public function updateViolationProduct($where, $data)
  420. {
  421. DB::beginTransaction();
  422. try {
  423. $this->editViolationProduct_content($where, $data);
  424. DB::commit();
  425. return true;
  426. // 成功处理...
  427. } catch (\Exception $e) {
  428. DB::rollBack();
  429. // 错误处理...
  430. return false;
  431. }
  432. }
  433. /**
  434. * 修改状态
  435. * @author 唐远望
  436. * @version 1.0
  437. * @date 2025-12-08
  438. * @param $id
  439. * @param $status
  440. * @return bool
  441. */
  442. public function changeStatus($where, $status)
  443. {
  444. $ViolationProduct = $this->where($where)->first();
  445. if (!$ViolationProduct) {
  446. return false;
  447. }
  448. $ViolationProduct->status = $status;
  449. $ViolationProduct->update_time = time();
  450. $ViolationProduct->save();
  451. return true;
  452. }
  453. /**
  454. * 修改处理状态
  455. * @author 唐远望
  456. * @version 1.0
  457. * @date 2025-12-08
  458. * @param $id
  459. * @param $processing_status
  460. * @return bool
  461. */
  462. public function changeProcessingStatus($where, $processing_status)
  463. {
  464. $ViolationProduct = $this->where($where)->first();
  465. if (!$ViolationProduct) {
  466. return false;
  467. }
  468. $ViolationProduct->processing_status = $processing_status;
  469. $ViolationProduct->update_time = time();
  470. $ViolationProduct->save();
  471. return true;
  472. }
  473. /**
  474. * 删除数据
  475. * @author 唐远望
  476. * @version 1.0
  477. * @date 2025-12-08
  478. * @param $id
  479. * @return bool
  480. */
  481. public function deleteViolationProduct($where)
  482. {
  483. $ViolationProduct = $this->where($where)->first();
  484. if (!$ViolationProduct) {
  485. return false;
  486. }
  487. $ViolationProduct->delete();
  488. return true;
  489. }
  490. }