ViolationProductMember.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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. /**
  7. * 违规处理-违规商品处理人员关系模型
  8. * @author: 唐远望
  9. * @version: 1.0
  10. * @date: 2025-12-10
  11. */
  12. class ViolationProductMember extends Model
  13. {
  14. use HasFactory;
  15. // 与模型关联的表名
  16. protected $table = 'process_violation_product_member';
  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-10
  27. */
  28. public function addViolationProductMember_content($data)
  29. {
  30. $insert_data = [
  31. 'violation_product_logid' => $data['violation_product_logid'],
  32. 'employee_id' => $data['employee_id'],
  33. 'duty_type' => $data['duty_type'],
  34. ];
  35. $ViolationProductMember_id = $this->insertGetId($insert_data);
  36. return $ViolationProductMember_id;
  37. }
  38. /**
  39. * 写入数据
  40. * @author 唐远望
  41. * @version 1.0
  42. * @date 2025-12-10
  43. * @param $data
  44. * @return bool
  45. */
  46. public function addViolationProductMember($data)
  47. {
  48. DB::beginTransaction();
  49. try {
  50. $this->addViolationProductMember_content($data);
  51. DB::commit();
  52. return true;
  53. // 成功处理...
  54. } catch (\Exception $e) {
  55. DB::rollBack();
  56. // 错误处理...
  57. return false;
  58. }
  59. }
  60. /**
  61. * 编辑内容
  62. * @author 唐远望
  63. * @version 1.0
  64. * @date 2025-12-10
  65. * @param $data
  66. * @return bool
  67. */
  68. public function editViolationProductMember_content($where, $data)
  69. {
  70. $ViolationProductMember = $this->where($where)->first();
  71. if (!$ViolationProductMember) {
  72. return false;
  73. }
  74. $ViolationProductMember->violation_product_logid = $data['violation_product_logid'];
  75. $ViolationProductMember->employee_id = $data['employee_id'];
  76. $ViolationProductMember->duty_type = $data['duty_type'];
  77. $ViolationProductMember->save();
  78. return true;
  79. }
  80. /**
  81. * 更新数据
  82. * @author 唐远望
  83. * @version 1.0
  84. * @date 2025-12-10
  85. * @param $data
  86. * @return bool
  87. */
  88. public function updateViolationProductMember($where, $data)
  89. {
  90. DB::beginTransaction();
  91. try {
  92. $this->editViolationProductMember_content($where, $data);
  93. DB::commit();
  94. return true;
  95. // 成功处理...
  96. } catch (\Exception $e) {
  97. DB::rollBack();
  98. // 错误处理...
  99. return false;
  100. }
  101. }
  102. /**
  103. * 删除数据
  104. * @author 唐远望
  105. * @version 1.0
  106. * @date 2025-12-10
  107. * @param $id
  108. * @return bool
  109. */
  110. public function deleteViolationProductMember($where)
  111. {
  112. $ViolationProductMember = $this->where($where)->first();
  113. if (!$ViolationProductMember) {
  114. return false;
  115. }
  116. $ViolationProductMember->delete();
  117. return true;
  118. }
  119. }