LowPriceGoods.php 27 KB

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