LowPriceGoods.php 28 KB

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