ViolationProduct.php 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. <?php
  2. namespace App\Models\Api\Process;
  3. use Illuminate\Database\Eloquent\Factories\HasFactory;
  4. use Illuminate\Database\Eloquent\Model;
  5. use Illuminate\Support\Facades\DB;
  6. /**
  7. * 违规处理-违规商品模型
  8. * @author: 唐远望
  9. * @version: 1.0
  10. * @date: 2025-12-09
  11. */
  12. class ViolationProduct extends Model
  13. {
  14. use HasFactory;
  15. // 与模型关联的表名
  16. protected $table = 'process_violation_product';
  17. // 是否主动维护时间戳
  18. public $timestamps = false;
  19. // 定义时间戳字段名
  20. // const CREATED_AT = 'insert_time';
  21. // const UPDATED_AT = 'update_time';
  22. /**
  23. * 添加
  24. * @author 唐远望
  25. * @version 1.0
  26. * @date 2025-12-09
  27. */
  28. public function addViolationProduct_content($data)
  29. {
  30. $insert_data = [
  31. 'first_responsible_person' => $data['first_responsible_person'],
  32. 'responsible_person' => $data['responsible_person'],
  33. 'platform' => $data['platform'],
  34. 'company_name' => $data['company_name'],
  35. 'product_name' => $data['product_name'],
  36. 'product_specs' => $data['product_specs'],
  37. 'online_posting_cunt' => $data['online_posting_cunt'],
  38. 'link_url' => $data['link_url'],
  39. 'store_name' => $data['store_name'],
  40. 'source_responsible_person' => $data['source_responsible_person'],
  41. 'processing_status' => '1',
  42. 'insert_time' => time(),
  43. ];
  44. $ViolationProduct_id = $this->insertGetId($insert_data);
  45. return $ViolationProduct_id;
  46. }
  47. /**
  48. * 写入数据
  49. * @author 唐远望
  50. * @version 1.0
  51. * @date 2025-12-09
  52. * @param $data
  53. * @return bool
  54. */
  55. public function addViolationProduct($data)
  56. {
  57. DB::beginTransaction();
  58. try {
  59. $this->addViolationProduct_content($data);
  60. DB::commit();
  61. return true;
  62. // 成功处理...
  63. } catch (\Exception $e) {
  64. DB::rollBack();
  65. // 错误处理...
  66. return false;
  67. }
  68. }
  69. /**
  70. * 编辑内容
  71. * @author 唐远望
  72. * @version 1.0
  73. * @date 2025-12-09
  74. * @param $data
  75. * @return bool
  76. */
  77. public function editViolationProduct_content($where, $data)
  78. {
  79. $ViolationProduct = $this->where($where)->first();
  80. if (!$ViolationProduct) {
  81. return false;
  82. }
  83. $ViolationProduct->first_responsible_person = $data['first_responsible_person'];
  84. $ViolationProduct->responsible_person = $data['responsible_person'];
  85. $ViolationProduct->platform = $data['platform'];
  86. $ViolationProduct->company_name = $data['company_name'];
  87. $ViolationProduct->product_name = $data['product_name'];
  88. $ViolationProduct->product_specs = $data['product_specs'];
  89. $ViolationProduct->online_posting_cunt = $data['online_posting_cunt'];
  90. $ViolationProduct->link_url = $data['link_url'];
  91. $ViolationProduct->store_name = $data['store_name'];
  92. $ViolationProduct->source_responsible_person = $data['source_responsible_person'];
  93. $ViolationProduct->update_time = time();
  94. $ViolationProduct->save();
  95. return true;
  96. }
  97. /**
  98. * 更新数据
  99. * @author 唐远望
  100. * @version 1.0
  101. * @date 2025-12-09
  102. * @param $data
  103. * @return bool
  104. */
  105. public function updateViolationProduct($where, $data)
  106. {
  107. DB::beginTransaction();
  108. try {
  109. $this->editViolationProduct_content($where, $data);
  110. DB::commit();
  111. return true;
  112. // 成功处理...
  113. } catch (\Exception $e) {
  114. DB::rollBack();
  115. // 错误处理...
  116. return false;
  117. }
  118. }
  119. /**
  120. * 修改状态
  121. * @author 唐远望
  122. * @version 1.0
  123. * @date 2025-12-09
  124. * @param $id
  125. * @param $status
  126. * @return bool
  127. */
  128. public function changeStatus($where, $status)
  129. {
  130. $ViolationProduct = $this->where($where)->first();
  131. if (!$ViolationProduct) {
  132. return false;
  133. }
  134. $ViolationProduct->status = $status;
  135. $ViolationProduct->update_time = time();
  136. $ViolationProduct->save();
  137. return true;
  138. }
  139. /**
  140. * 修改处理状态
  141. * @author 唐远望
  142. * @version 1.0
  143. * @date 2025-12-09
  144. * @param $id
  145. * @param $processing_status
  146. * @return bool
  147. */
  148. public function changeProcessingStatus($where, $processing_status)
  149. {
  150. $ViolationProduct = $this->where($where)->first();
  151. if (!$ViolationProduct) {
  152. return false;
  153. }
  154. $ViolationProduct->processing_status = $processing_status;
  155. $ViolationProduct->update_time = time();
  156. $ViolationProduct->save();
  157. return true;
  158. }
  159. /**
  160. * 删除数据
  161. * @author 唐远望
  162. * @version 1.0
  163. * @date 2025-12-09
  164. * @param $id
  165. * @return bool
  166. */
  167. public function deleteViolationProduct($where)
  168. {
  169. $ViolationProduct = $this->where($where)->first();
  170. if (!$ViolationProduct) {
  171. return false;
  172. }
  173. $ViolationProduct->delete();
  174. return true;
  175. }
  176. }