ViolationStore.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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 ViolationStore extends Model
  13. {
  14. use HasFactory;
  15. // 与模型关联的表名
  16. protected $table = 'process_violation_store';
  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 addViolationStore_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. 'link_url' => $data['link_url'],
  36. 'store_name' => $data['store_name'],
  37. 'source_responsible_person' => $data['source_responsible_person'],
  38. 'processing_status' => '1',
  39. 'insert_time' => time(),
  40. ];
  41. $ViolationStore_id = $this->insertGetId($insert_data);
  42. return $ViolationStore_id;
  43. }
  44. /**
  45. * 写入数据
  46. * @author 唐远望
  47. * @version 1.0
  48. * @date 2025-12-09
  49. * @param $data
  50. * @return bool
  51. */
  52. public function addViolationStore($data)
  53. {
  54. DB::beginTransaction();
  55. try {
  56. $this->addViolationStore_content($data);
  57. DB::commit();
  58. return true;
  59. // 成功处理...
  60. } catch (\Exception $e) {
  61. DB::rollBack();
  62. // 错误处理...
  63. return false;
  64. }
  65. }
  66. /**
  67. * 编辑内容
  68. * @author 唐远望
  69. * @version 1.0
  70. * @date 2025-12-09
  71. * @param $data
  72. * @return bool
  73. */
  74. public function editViolationStore_content($where, $data)
  75. {
  76. $ViolationStore = $this->where($where)->first();
  77. if (!$ViolationStore) {
  78. return false;
  79. }
  80. $ViolationStore->first_responsible_person = $data['first_responsible_person'];
  81. $ViolationStore->responsible_person = $data['responsible_person'];
  82. $ViolationStore->platform = $data['platform'];
  83. $ViolationStore->company_name = $data['company_name'];
  84. $ViolationStore->link_url = $data['link_url'];
  85. $ViolationStore->store_name = $data['store_name'];
  86. $ViolationStore->source_responsible_person = $data['source_responsible_person'];
  87. $ViolationStore->update_time = time();
  88. $ViolationStore->save();
  89. return true;
  90. }
  91. /**
  92. * 更新数据
  93. * @author 唐远望
  94. * @version 1.0
  95. * @date 2025-12-09
  96. * @param $data
  97. * @return bool
  98. */
  99. public function updateViolationStore($where, $data)
  100. {
  101. DB::beginTransaction();
  102. try {
  103. $this->editViolationStore_content($where, $data);
  104. DB::commit();
  105. return true;
  106. // 成功处理...
  107. } catch (\Exception $e) {
  108. DB::rollBack();
  109. // 错误处理...
  110. return false;
  111. }
  112. }
  113. /**
  114. * 修改状态
  115. * @author 唐远望
  116. * @version 1.0
  117. * @date 2025-12-09
  118. * @param $id
  119. * @param $status
  120. * @return bool
  121. */
  122. public function changeStatus($where, $status)
  123. {
  124. $ViolationStore = $this->where($where)->first();
  125. if (!$ViolationStore) {
  126. return false;
  127. }
  128. $ViolationStore->status = $status;
  129. $ViolationStore->update_time = time();
  130. $ViolationStore->save();
  131. return true;
  132. }
  133. /**
  134. * 修改处理状态
  135. * @author 唐远望
  136. * @version 1.0
  137. * @date 2025-12-09
  138. * @param $id
  139. * @param $processing_status
  140. * @return bool
  141. */
  142. public function changeProcessingStatus($where, $processing_status)
  143. {
  144. $ViolationStore = $this->where($where)->first();
  145. if (!$ViolationStore) {
  146. return false;
  147. }
  148. $ViolationStore->processing_status = $processing_status;
  149. $ViolationStore->update_time = time();
  150. $ViolationStore->save();
  151. return true;
  152. }
  153. /**
  154. * 删除数据
  155. * @author 唐远望
  156. * @version 1.0
  157. * @date 2025-12-09
  158. * @param $id
  159. * @return bool
  160. */
  161. public function deleteViolationStore($where)
  162. {
  163. $ViolationStore = $this->where($where)->first();
  164. if (!$ViolationStore) {
  165. return false;
  166. }
  167. $ViolationStore->delete();
  168. return true;
  169. }
  170. }