NoticetServer.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <?php
  2. namespace app\admin\server\notice;
  3. use app\admin\model\Notice;
  4. class NoticetServer
  5. {
  6. /**
  7. * Notes:获取业务员列表
  8. * @param string $keywords
  9. * @param int $page
  10. * @param int $limit
  11. * @return array
  12. * User: ZQ
  13. * Date: 2022/9/27
  14. */
  15. public static function getNoticeList(int $page, int $limit,string $keywords)
  16. {
  17. [$list,$count] = Notice::getNoticeList($page, $limit, $keywords);
  18. if (!empty($list)){
  19. foreach ($list as $k => $v){
  20. $list[$k]['shop_create_time'] = date('Y-m-d H:i:s', $v['shop_create_time']);
  21. if (!empty($v['shop_update_time'])){
  22. $list[$k]['shop_update_time'] = date('Y-m-d H:i:s', $v['shop_update_time']);
  23. }
  24. }
  25. }
  26. return compact('list', 'page', 'limit', 'count');
  27. }
  28. /**
  29. * Notes:修改业务员
  30. * @param string $notice_title
  31. * @param string $notice_introduce
  32. * @param string $notic_content
  33. * @param int $notice_id
  34. * @return int
  35. * User: ZQ
  36. * Date: 2022/9/13
  37. */
  38. public static function updateNotice($notice_id, $notice_title, $notice_introduce, $notic_content)
  39. {
  40. Notice::affairBegin();
  41. try {
  42. $where = [];
  43. $where['notice_id'] = $notice_id;
  44. $data = [];
  45. if (!empty($notice_title)){
  46. $data['notice_title'] = $notice_title;
  47. }
  48. if (!empty($notice_introduce)){
  49. $data['notice_introduce'] = $notice_introduce;
  50. }
  51. if (!empty($notic_content)){
  52. $data['notic_content'] = $notic_content;
  53. }
  54. $result = Notice::where($where)->update($data);
  55. if ($result !== false){
  56. Notice::affairCommit();
  57. return true;
  58. }
  59. throw new \Exception('操作失败!');
  60. }catch (\Exception $exception){
  61. Notice::affairRollback();
  62. throw new \Exception($exception->getMessage(), 500);
  63. }
  64. }
  65. /**
  66. * Notes:删除业务员
  67. * @param int $notice_id
  68. * @return int
  69. * User: ZQ
  70. * Date: 2022/9/3
  71. */
  72. public static function delNotice($notice_id)
  73. {
  74. Notice::affairBegin();
  75. try {
  76. $where = [];
  77. $where['menu_id'] = $notice_id;
  78. $data['notice_del'] = 2;
  79. $result = Notice::where($where)->update($data);
  80. if (!empty($result)){
  81. Notice::affairCommit();
  82. return true;
  83. }else{
  84. return false;
  85. }
  86. }catch (\Exception $exception){
  87. Notice::affairRollback();
  88. throw new \Exception($exception->getMessage(), 500);
  89. }
  90. }
  91. /**
  92. * Notes: 添加业务员
  93. * @param int $notice_pid
  94. * @param string $notice_name
  95. * @param int $notice_type
  96. * @param int $notice_sort
  97. * @return int
  98. * User: ZQ
  99. * Date: 2022/9/14
  100. */
  101. public static function insertNotice($notice_title, $notice_introduce, $notic_content)
  102. {
  103. Notice::affairBegin();
  104. try {
  105. $data = [];
  106. $data['notice_title'] = $notice_title;
  107. $data['notice_introduce'] = $notice_introduce;
  108. $data['notic_content'] = $notic_content;
  109. $result = Notice::insertGetId($data);
  110. if (!empty($result)){
  111. Notice::affairCommit();
  112. return $result;
  113. }
  114. throw new \Exception('操作失败!');
  115. }catch (\Exception $exception){
  116. Notice::affairRollback();
  117. throw new \Exception($exception->getMessage(), 500);
  118. }
  119. }
  120. /**
  121. * Notes:查询业务员
  122. * @param int $notice_id
  123. * @return int
  124. * User: ZQ
  125. * Date: 2022/9/13
  126. */
  127. public static function noticeInfo($notice_id)
  128. {
  129. $where = [];
  130. $where['notice_del'] = 0;
  131. $where['notice_id'] = $notice_id;
  132. $result = Notice::where($where)->first();
  133. return $result;
  134. }
  135. }