ViolationProduct.php 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550
  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. 'merge_city_id' => $data['merge_city_id'],
  92. 'merge_province_id' => $data['merge_province_id'],
  93. 'merge_city_name' => $data['merge_city_name'],
  94. 'merge_province_name' => $data['merge_province_name'],
  95. 'snapshot_url' => isset($data['snapshot_url']) ? $data['snapshot_url'] : '', // 商品快照地址
  96. ];
  97. $ViolationProduct_id = $this->insertGetId($insert_data);
  98. return $ViolationProduct_id;
  99. }
  100. /**
  101. * 写入数据
  102. * @author 唐远望
  103. * @version 1.0
  104. * @date 2025-12-08
  105. * @param $data
  106. * @return bool
  107. */
  108. public function addViolationProduct($data, $is_import = false)
  109. {
  110. if ($is_import == false) {
  111. //去重规则:品牌方公司ID+店铺公司名称+店铺名称+品牌名称+商品名称+规格+盒数(针对采集)
  112. $source_where[] = ['company_id', '=', $data['company_id']]; //品牌方公司ID
  113. $source_where[] = ['company_name', '=', $data['company_name']]; //店铺公司名称
  114. $source_where[] = ['store_name', '=', $data['store_name']]; //店铺名称
  115. $source_where[] = ['product_brand', '=', $data['product_brand']]; //品牌名称
  116. $source_where[] = ['product_name', '=', $data['product_name']]; //商品名称
  117. $source_where[] = ['product_specs', '=', $data['product_specs']]; //规格
  118. $source_where[] = ['scrape_date', '=', $data['scrape_date']]; //采集日期
  119. $source_id_log = $this->where($source_where)->count();
  120. if ($source_id_log > 0) {
  121. return true;
  122. }
  123. }
  124. DB::beginTransaction();
  125. try {
  126. //执行挂网数据统计
  127. $data = $this->handleCountData($data);
  128. $ViolationProductMemberModel = new ViolationProductMemberModel();
  129. $insert_data = [
  130. 'company_id' => $data['company_id'],
  131. 'source_id' => $data['source_id'],
  132. 'first_responsible_person' => $data['first_responsible_person'] ? ',' . $data['first_responsible_person'] . ',' : '',
  133. 'responsible_person' => $data['responsible_person'] ? ',' . $data['responsible_person'] . ',' : '',
  134. 'platform' => $data['platform'],
  135. 'company_name' => $data['company_name'],
  136. 'product_brand' => isset($data['product_brand']) ? $data['product_brand'] : '',
  137. 'product_name' => $data['product_name'],
  138. 'product_specs' => $data['product_specs'],
  139. 'online_posting_count' => isset($data['online_posting_count']) && is_numeric($data['online_posting_count']) ? $data['online_posting_count'] : 1,
  140. 'continuous_listing_count' => isset($data['continuous_listing_count']) && is_numeric($data['continuous_listing_count']) ? $data['continuous_listing_count'] : 1,
  141. 'social_credit_code' => $data['social_credit_code'],
  142. 'province_id' => $data['province_id'],
  143. 'province_name' => isset($data['province_name']) ? $data['province_name'] : '',
  144. 'city_id' => $data['city_id'],
  145. 'city_name' => isset($data['city_name']) ? $data['city_name'] : '',
  146. 'area_info' => $data['area_info'],
  147. 'link_url' => $data['link_url'],
  148. 'store_name' => $data['store_name'],
  149. 'anonymous_store_name' => isset($data['anonymous_store_name']) ? $data['anonymous_store_name'] : '',
  150. 'source_responsible_person' => $data['source_responsible_person'] ? ',' . $data['source_responsible_person'] . ',' : '',
  151. 'category_name' => $data['category_name'],
  152. 'company_category_name' => $data['company_category_name'],
  153. 'processing_status' => '1',
  154. 'insert_time' => time(),
  155. 'scrape_date' => isset($data['scrape_date']) ? $data['scrape_date'] : '',
  156. 'collection_time' => isset($data['collection_time']) ? $data['collection_time'] : '',
  157. 'shipment_province_id' => isset($data['shipment_province_id']) ? $data['shipment_province_id'] : '0', // 发货省份id
  158. 'shipment_province_name' => isset($data['shipment_province_name']) ? $data['shipment_province_name'] : '', // 发货省份
  159. 'shipment_city_id' => isset($data['shipment_city_id']) ? $data['shipment_city_id'] : '0', // 发货城市id
  160. 'shipment_city_name' => isset($data['shipment_city_name']) ? $data['shipment_city_name'] : '', // 发货城市
  161. 'merge_city_id' => $data['merge_city_id'],
  162. 'merge_province_id' => $data['merge_province_id'],
  163. 'merge_city_name' => $data['merge_city_name'],
  164. 'merge_province_name' => $data['merge_province_name'],
  165. 'snapshot_url' => isset($data['snapshot_url']) ? $data['snapshot_url'] : '', // 商品快照地址
  166. ];
  167. $ViolationProduct_id = $this->insertGetId($insert_data);
  168. $first_responsible_persons = $data['first_responsible_person'] != '' ? explode(',', $data['first_responsible_person']) : [];
  169. $first_responsible_person_data = [];
  170. if (count($first_responsible_persons) > 0) {
  171. foreach ($first_responsible_persons as $key => $employee_id) {
  172. //如果不是数字或者为空,则跳过
  173. if ($employee_id == '' || is_null($employee_id) || !is_numeric($employee_id)) continue;
  174. $first_responsible_person_data[] = [
  175. 'violation_product_logid' => $ViolationProduct_id,
  176. 'employee_id' => $employee_id,
  177. 'duty_type' => 1, //责任类型1=第一责任人,2=责任人,3=溯源责任人
  178. ];
  179. }
  180. }
  181. $ViolationProductMemberModel->insert($first_responsible_person_data);
  182. $responsible_persons = $data['responsible_person'] != '' ? explode(',', $data['responsible_person']) : [];
  183. $responsible_person_data = [];
  184. if (count($responsible_persons) > 0) {
  185. foreach ($responsible_persons as $key => $employee_id) {
  186. //如果不是数字或者为空,则跳过
  187. if ($employee_id == '' || is_null($employee_id) || !is_numeric($employee_id)) continue;
  188. $responsible_person_data[] = [
  189. 'violation_product_logid' => $ViolationProduct_id,
  190. 'employee_id' => $employee_id,
  191. 'duty_type' => 2, //责任类型1=第一责任人,2=责任人,3=溯源责任人
  192. ];
  193. }
  194. }
  195. $ViolationProductMemberModel->insert($responsible_person_data);
  196. $source_responsible_persons = $data['source_responsible_person'] != '' ? explode(',', $data['source_responsible_person']) : [];
  197. $source_responsible_person_data = [];
  198. if (count($source_responsible_persons) > 0) {
  199. foreach ($source_responsible_persons as $key => $employee_id) {
  200. //如果不是数字或者为空,则跳过
  201. if ($employee_id == '' || is_null($employee_id) || !is_numeric($employee_id)) continue;
  202. $source_responsible_person_data[] = [
  203. 'violation_product_logid' => $ViolationProduct_id,
  204. 'employee_id' => $employee_id,
  205. 'duty_type' => 3, //责任类型1=第一责任人,2=责任人,3=溯源责任人
  206. ];
  207. }
  208. }
  209. $ViolationProductMemberModel->insert($source_responsible_person_data);
  210. //添加通知
  211. // $this->addNotices($insert_data, $ViolationProduct_id);
  212. DB::commit();
  213. return true;
  214. // 成功处理...
  215. } catch (\Exception $e) {
  216. DB::rollBack();
  217. // 错误处理...
  218. Log::info('job_error', '数据清洗-新增违规商品处理记录失败', ['data' => $data, 'error' => $e->getMessage()]);
  219. return false;
  220. }
  221. }
  222. function getLastSamplingInfo($currentWeek, $samplingCycle)
  223. {
  224. // 获取所有小于当前星期的配置
  225. $previousWeeks = array_filter($samplingCycle, function ($week) use ($currentWeek) {
  226. return $week < $currentWeek;
  227. });
  228. if (!empty($previousWeeks)) {
  229. // 存在小于当前星期的配置,取最大值
  230. $lastWeek = max($previousWeeks);
  231. $daysToSubtract = $currentWeek - $lastWeek;
  232. } else {
  233. // 不存在(当前是最小的),取最大的配置星期(跨周)
  234. $lastWeek = max($samplingCycle);
  235. $daysToSubtract = $currentWeek + (7 - $lastWeek);
  236. }
  237. return [
  238. 'last_week' => $lastWeek,
  239. 'days_to_subtract' => $daysToSubtract
  240. ];
  241. }
  242. /**
  243. * 处理连续挂网&累计挂网数据统计
  244. * @author 唐远望
  245. * @version 1.0
  246. * @date 2026-05-07
  247. *
  248. */
  249. public function handleCountData($product_data_info)
  250. {
  251. $collect_config_info = isset($product_data_info['collect_config_info']) ? $product_data_info['collect_config_info'] : ''; //采集配置信息
  252. if (trim($collect_config_info) == '') return $product_data_info;
  253. $collect_config_info = json_decode($collect_config_info, true); //{"sampling_cycle": "", "sampling_start_time": "", "sampling_end_time": ""}
  254. //采集周期
  255. $sampling_cycle = isset($collect_config_info['sampling_cycle']) ? explode(',', $collect_config_info['sampling_cycle']) : '';
  256. //采集开始时间
  257. $sampling_start_time = isset($collect_config_info['sampling_start_time']) ? $collect_config_info['sampling_start_time'] : '';
  258. //采集结束时间
  259. $sampling_end_time = isset($collect_config_info['sampling_end_time']) ? $collect_config_info['sampling_end_time'] : '';
  260. if (!is_array($sampling_cycle)) return $product_data_info;
  261. $current_time = time();
  262. //如果当前时间在采集开始时间结束时间范围内,则进行连续挂网和累计挂网统计
  263. if ($sampling_start_time != '' && $sampling_end_time != '' && $current_time >= $sampling_start_time && $current_time <= $sampling_end_time) {
  264. // 获取采集时间是星期几
  265. $collection_time = strtotime($product_data_info['collection_time']);
  266. $now_week = date('w', $collection_time);
  267. if ($now_week == 0) {
  268. $now_week = 7;
  269. }
  270. if (!in_array($now_week, $sampling_cycle)) {
  271. return $product_data_info;
  272. }
  273. //排序$sampling_cycle从小到大
  274. sort($sampling_cycle);
  275. // 使用
  276. $result = $this->getLastSamplingInfo($now_week, $sampling_cycle);
  277. $days_to_subtract = isset($result['days_to_subtract']) ? $result['days_to_subtract'] : 0;
  278. //查询当前商品是否在上一个周期采集中过
  279. $up_scrape_date_time = $collection_time - $days_to_subtract * 24 * 3600; //查询上周这个时间点
  280. $up_scrape_date = date('Y-m-d', $up_scrape_date_time);
  281. $source_last_week_where[] = ['company_id', '=', $product_data_info['company_id']]; //品牌方公司ID
  282. $source_last_week_where[] = ['platform', '=', $product_data_info['platform']]; //挂网平台ID
  283. $source_last_week_where[] = ['company_name', '=', $product_data_info['company_name']]; //店铺公司名称
  284. $source_last_week_where[] = ['store_name', '=', $product_data_info['store_name']]; //店铺名称
  285. $source_last_week_where[] = ['product_brand', '=', $product_data_info['product_brand']]; //品牌名称
  286. $source_last_week_where[] = ['product_name', '=', $product_data_info['product_name']]; //商品名称
  287. $source_last_week_where[] = ['product_specs', '=', $product_data_info['product_specs']]; //规格
  288. $source_last_week_where[] = ['scrape_date', '=', $up_scrape_date]; //上个周期采集日期
  289. $source_last_week_log = $this->where($source_last_week_where)->count();
  290. if ($source_last_week_log > 0) {
  291. $product_data_info['continuous_listing_count'] = $product_data_info['continuous_listing_count'] + 1; //连续挂网次数+1
  292. }
  293. //查询当前商品上次连续挂网次数
  294. $source_last_time_where[] = ['company_id', '=', $product_data_info['company_id']]; //品牌方公司ID
  295. $source_last_time_where[] = ['platform', '=', $product_data_info['platform']]; //挂网平台ID
  296. $source_last_time_where[] = ['company_name', '=', $product_data_info['company_name']]; //店铺公司名称
  297. $source_last_time_where[] = ['store_name', '=', $product_data_info['store_name']]; //店铺名称
  298. $source_last_time_where[] = ['product_brand', '=', $product_data_info['product_brand']]; //品牌名称
  299. $source_last_time_where[] = ['product_name', '=', $product_data_info['product_name']]; //商品名称
  300. $source_last_time_where[] = ['product_specs', '=', $product_data_info['product_specs']]; //规格
  301. $source_last_time_log = $this->where($source_last_time_where)->orderbyDesc('scrape_date')->first();
  302. if (!empty($source_last_time_log)) {
  303. $product_data_info['online_posting_count'] = $source_last_time_log->online_posting_count + 1; //累计挂网次数+1
  304. }
  305. } else if ($sampling_start_time != '' && $sampling_end_time == '' && $current_time >= $sampling_start_time) {
  306. //如果当前时间在采集开始时间结束时间未设置,则进行连续挂网和累计挂网统计
  307. // 获取采集时间是星期几
  308. $collection_time = strtotime($product_data_info['collection_time']);
  309. $now_week = date('w', $collection_time);
  310. if ($now_week == 0) {
  311. $now_week = 7;
  312. }
  313. if (!in_array($now_week, $sampling_cycle)) {
  314. return $product_data_info;
  315. }
  316. //查询当前商品是否在上一个周期采集中过
  317. $up_scrape_date_time = $collection_time - 7 * 24 * 3600; //查询上周这个时间点
  318. //查询当前商品上次采集记录
  319. $up_scrape_date = date('Y-m-d', $up_scrape_date_time);
  320. $source_last_week_where[] = ['company_id', '=', $product_data_info['company_id']]; //品牌方公司ID
  321. $source_last_week_where[] = ['platform', '=', $product_data_info['platform']]; //挂网平台ID
  322. $source_last_week_where[] = ['company_name', '=', $product_data_info['company_name']]; //店铺公司名称
  323. $source_last_week_where[] = ['store_name', '=', $product_data_info['store_name']]; //店铺名称
  324. $source_last_week_where[] = ['product_brand', '=', $product_data_info['product_brand']]; //品牌名称
  325. $source_last_week_where[] = ['product_name', '=', $product_data_info['product_name']]; //商品名称
  326. $source_last_week_where[] = ['product_specs', '=', $product_data_info['product_specs']]; //规格
  327. $source_last_week_where[] = ['scrape_date', '=', $up_scrape_date]; //上个周期采集日期
  328. $source_last_week_log = $this->where($source_last_week_where)->count();
  329. if ($source_last_week_log > 0) {
  330. $product_data_info['continuous_listing_count'] = $product_data_info['continuous_listing_count'] + 1; //连续挂网次数+1
  331. }
  332. //查询当前商品上次连续挂网次数
  333. $source_last_time_where[] = ['company_id', '=', $product_data_info['company_id']]; //品牌方公司ID
  334. $source_last_time_where[] = ['platform', '=', $product_data_info['platform']]; //挂网平台ID
  335. $source_last_time_where[] = ['company_name', '=', $product_data_info['company_name']]; //店铺公司名称
  336. $source_last_time_where[] = ['store_name', '=', $product_data_info['store_name']]; //店铺名称
  337. $source_last_time_where[] = ['product_brand', '=', $product_data_info['product_brand']]; //品牌名称
  338. $source_last_time_where[] = ['product_name', '=', $product_data_info['product_name']]; //商品名称
  339. $source_last_time_where[] = ['product_specs', '=', $product_data_info['product_specs']]; //规格
  340. $source_last_time_log = $this->where($source_last_time_where)->orderbyDesc('scrape_date')->first();
  341. if (!empty($source_last_time_log)) {
  342. $product_data_info['online_posting_count'] = $source_last_time_log->online_posting_count + 1; //累计挂网次数+1
  343. }
  344. }
  345. return $product_data_info;
  346. }
  347. /**
  348. * 处理通知消息
  349. * @author 唐远望
  350. * @version 1.0
  351. * @date 2026-03-21
  352. * @param $data
  353. * @return bool
  354. */
  355. public function addNotices($low_price_data, $data_logid)
  356. {
  357. //添加通知
  358. $NoticesModel = new NoticesModel();
  359. $EmployeeModel = new EmployeeModel();
  360. $notices_data = [];
  361. if ($low_price_data['first_responsible_person'] != '' && $low_price_data['responsible_person'] != '') {
  362. //合并数据并去重
  363. $first_responsible_persons = array_unique(explode(',', $low_price_data['first_responsible_person']));
  364. $responsible_persons = array_unique(explode(',', $low_price_data['responsible_person']));
  365. $all_persons = array_merge($first_responsible_persons, $responsible_persons);
  366. //查询已已经开启通知设置的用户
  367. $employee_ids = $EmployeeModel->whereIn('id', $all_persons)->where('open_notice', 0)->pluck('id')->toArray();
  368. if (count($employee_ids) == 0) return true;
  369. foreach ($employee_ids as $key => $employee_id) {
  370. if ($employee_id == '' || is_null($employee_id)) continue;
  371. $notices_data[] = [
  372. 'company_id' => $low_price_data['company_id'],
  373. 'custom_uid' => $employee_id,
  374. 'title' => '您有一条新的禁止商品待处理,请及时查看。',
  375. 'content_type' => '2', //内容类型1=低价挂网2=禁止挂网3=违规店铺
  376. 'data_logid' => $data_logid,
  377. 'insert_time' => time()
  378. ];
  379. }
  380. $NoticesModel->insert($notices_data);
  381. } else if ($low_price_data['first_responsible_person'] != '') {
  382. $first_responsible_persons = array_unique(explode(',', $low_price_data['first_responsible_person']));
  383. //查询已已经开启通知设置的用户
  384. $employee_ids = $EmployeeModel->whereIn('id', $first_responsible_persons)->where('open_notice', 0)->pluck('id')->toArray();
  385. if (count($employee_ids) == 0) return true;
  386. foreach ($employee_ids as $key => $employee_id) {
  387. if ($employee_id == '' || is_null($employee_id)) continue;
  388. $notices_data[] = [
  389. 'company_id' => $low_price_data['company_id'],
  390. 'custom_uid' => $employee_id,
  391. 'title' => '您有一条新的禁止商品待处理,请及时查看。',
  392. 'content_type' => '2', //内容类型1=低价挂网2=禁止挂网3=违规店铺
  393. 'data_logid' => $data_logid,
  394. 'insert_time' => time()
  395. ];
  396. }
  397. $NoticesModel->insert($notices_data);
  398. } else if ($low_price_data['responsible_person'] != '') {
  399. $responsible_persons = array_unique(explode(',', $low_price_data['responsible_person']));
  400. //查询已已经开启通知设置的用户
  401. $employee_ids = $EmployeeModel->whereIn('id', $responsible_persons)->where('open_notice', 0)->pluck('id')->toArray();
  402. if (count($employee_ids) == 0) return true;
  403. foreach ($employee_ids as $key => $employee_id) {
  404. if ($employee_id == '' || is_null($employee_id)) continue;
  405. $notices_data[] = [
  406. 'company_id' => $low_price_data['company_id'],
  407. 'custom_uid' => $employee_id,
  408. 'title' => '您有一条新的禁止商品待处理,请及时查看。',
  409. 'content_type' => '2', //内容类型1=低价挂网2=禁止挂网3=违规店铺
  410. 'data_logid' => $data_logid,
  411. 'insert_time' => time()
  412. ];
  413. }
  414. $NoticesModel->insert($notices_data);
  415. }
  416. return true;
  417. }
  418. /**
  419. * 编辑内容
  420. * @author 唐远望
  421. * @version 1.0
  422. * @date 2025-12-08
  423. * @param $data
  424. * @return bool
  425. */
  426. public function editViolationProduct_content($where, $data)
  427. {
  428. $ViolationProduct = $this->where($where)->first();
  429. if (!$ViolationProduct) {
  430. return false;
  431. }
  432. $ViolationProduct->company_id = $data['company_id'];
  433. $ViolationProduct->first_responsible_person = $data['first_responsible_person'];
  434. $ViolationProduct->responsible_person = $data['responsible_person'];
  435. $ViolationProduct->platform = $data['platform'];
  436. $ViolationProduct->company_name = $data['company_name'];
  437. $ViolationProduct->product_name = $data['product_name'];
  438. $ViolationProduct->product_specs = $data['product_specs'];
  439. $ViolationProduct->online_posting_count = $data['online_posting_count'];
  440. $ViolationProduct->link_url = $data['link_url'];
  441. $ViolationProduct->store_name = $data['store_name'];
  442. $ViolationProduct->source_responsible_person = $data['source_responsible_person'];
  443. $ViolationProduct->update_time = time();
  444. $ViolationProduct->save();
  445. return true;
  446. }
  447. /**
  448. * 更新数据
  449. * @author 唐远望
  450. * @version 1.0
  451. * @date 2025-12-08
  452. * @param $data
  453. * @return bool
  454. */
  455. public function updateViolationProduct($where, $data)
  456. {
  457. DB::beginTransaction();
  458. try {
  459. $this->editViolationProduct_content($where, $data);
  460. DB::commit();
  461. return true;
  462. // 成功处理...
  463. } catch (\Exception $e) {
  464. DB::rollBack();
  465. // 错误处理...
  466. return false;
  467. }
  468. }
  469. /**
  470. * 修改状态
  471. * @author 唐远望
  472. * @version 1.0
  473. * @date 2025-12-08
  474. * @param $id
  475. * @param $status
  476. * @return bool
  477. */
  478. public function changeStatus($where, $status)
  479. {
  480. $ViolationProduct = $this->where($where)->first();
  481. if (!$ViolationProduct) {
  482. return false;
  483. }
  484. $ViolationProduct->status = $status;
  485. $ViolationProduct->update_time = time();
  486. $ViolationProduct->save();
  487. return true;
  488. }
  489. /**
  490. * 修改处理状态
  491. * @author 唐远望
  492. * @version 1.0
  493. * @date 2025-12-08
  494. * @param $id
  495. * @param $processing_status
  496. * @return bool
  497. */
  498. public function changeProcessingStatus($where, $processing_status)
  499. {
  500. $ViolationProduct = $this->where($where)->first();
  501. if (!$ViolationProduct) {
  502. return false;
  503. }
  504. $ViolationProduct->processing_status = $processing_status;
  505. $ViolationProduct->update_time = time();
  506. $ViolationProduct->save();
  507. return true;
  508. }
  509. /**
  510. * 删除数据
  511. * @author 唐远望
  512. * @version 1.0
  513. * @date 2025-12-08
  514. * @param $id
  515. * @return bool
  516. */
  517. public function deleteViolationProduct($where)
  518. {
  519. $ViolationProduct = $this->where($where)->first();
  520. if (!$ViolationProduct) {
  521. return false;
  522. }
  523. $ViolationProduct->delete();
  524. return true;
  525. }
  526. }