LowPriceGoods.php 26 KB

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