LowPriceGoods.php 27 KB

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