PerformersServer.php 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. <?php
  2. namespace app\admin\server\life;
  3. use app\admin\model\LifeCinemaPerformers;
  4. class PerformersServer
  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/13
  14. */
  15. public static function getPerformersList(int $page, int $limit, string $keywords)
  16. {
  17. [$list, $count] = LifeCinemaPerformers::getPerformersList($page, $limit, $keywords);
  18. if (!empty($list)){
  19. foreach ($list as $k => $v){
  20. $list[$k]['performers_create_time'] = date('Y-m-d H:i:s',$v['performers_create_time']);
  21. if (!empty($v['performers_update_time'])){
  22. $list[$k]['performers_update_time'] = date('Y-m-d H:i:s',$v['performers_update_time']);
  23. }
  24. }
  25. }
  26. return compact('list', 'page', 'limit', 'count');
  27. }
  28. /**
  29. * Notes:所有演职
  30. * @return array
  31. * User: ZQ
  32. * Date: 2022/9/3
  33. */
  34. public static function getPerformersAll($type)
  35. {
  36. return LifeCinemaPerformers::getPerformersAll($type);
  37. }
  38. /**
  39. * Notes:修改演职
  40. * @param string $performers_name
  41. * @param int $performers_id
  42. * @return int
  43. * User: ZQ
  44. * Date: 2022/9/3
  45. */
  46. public static function updatePerformers($performers_id, $performers_name, $performers_img, $performers_type, $performers_introduction, $admin_id)
  47. {
  48. LifeCinemaPerformers::affairBegin();
  49. try {
  50. $where = [];
  51. $where['performers_id'] = $performers_id;
  52. $data = [];
  53. $data['performers_name'] = $performers_name;
  54. $data['performers_img'] = $performers_img;
  55. $data['performers_type'] = $performers_type;
  56. $data['performers_introduction'] = $performers_introduction;
  57. $data['performers_update_time'] = time();
  58. $result = LifeCinemaPerformers::where($where)->update($data);
  59. if ($result !== false){
  60. $msg = '管理员:' . $admin_id . '在:' . date("Y-m-d H:i:s", time()) . '修改万悦影院演职-编号: ' . $performers_id;
  61. plog('life-performers-update', '悦活-万悦影院-修改演职', $msg);
  62. LifeCinemaPerformers::affairCommit();
  63. return true;
  64. }
  65. throw new \Exception('操作失败!');
  66. }catch (\Exception $exception){
  67. LifeCinemaPerformers::affairRollback();
  68. throw new \Exception($exception->getMessage(), 500);
  69. }
  70. }
  71. /**
  72. * Notes:删除演职
  73. * @param int $performers_id
  74. * @return int
  75. * User: ZQ
  76. * Date: 2022/9/13
  77. */
  78. public static function delPerformers($performers_id,$admin_id)
  79. {
  80. LifeCinemaPerformers::affairBegin();
  81. try {
  82. $where = [];
  83. $where['performers_id'] = $performers_id;
  84. $data['performers_is_del'] = 1;
  85. $result = LifeCinemaPerformers::where($where)->update($data);
  86. if (!empty($result)){
  87. $msg = '管理员:' . $admin_id . '在:' . date("Y-m-d H:i:s", time()) . '删除万悦影院演职-编号: ' . $performers_id;
  88. plog('life-performers-delete', '悦活-万悦影院-删除演职', $msg);
  89. LifeCinemaPerformers::affairCommit();
  90. return true;
  91. }else{
  92. return false;
  93. }
  94. }catch (\Exception $exception){
  95. LifeCinemaPerformers::affairRollback();
  96. throw new \Exception($exception->getMessage(), 500);
  97. }
  98. }
  99. /**
  100. * Notes: 添加演职
  101. * @param string $performers_name
  102. * @param array $performers_rules
  103. * @return int
  104. * User: ZQ
  105. * Date: 2022/9/13
  106. */
  107. public static function insertPerformers($performers_name, $performers_img, $performers_type, $performers_introduction, $admin_id)
  108. {
  109. LifeCinemaPerformers::affairBegin();
  110. try {
  111. $data = [];
  112. $data['performers_name'] = $performers_name;
  113. $data['performers_img'] = $performers_img;
  114. $data['performers_type'] = $performers_type;
  115. $data['performers_introduction'] = $performers_introduction;
  116. $data['performers_create_time'] = time();
  117. $result = LifeCinemaPerformers::insertGetId($data);
  118. if (!empty($result)){
  119. $msg = '管理员:' . $admin_id . '在:' . date("Y-m-d H:i:s", time()) . '添加万悦影院演职-编号: ' . $result;
  120. plog('life-performers-create', '悦活-万悦影院-添加演职', $msg);
  121. LifeCinemaPerformers::affairCommit();
  122. return $result;
  123. }
  124. throw new \Exception('操作失败!');
  125. }catch (\Exception $exception){
  126. LifeCinemaPerformers::affairRollback();
  127. throw new \Exception($exception->getMessage(), 500);
  128. }
  129. }
  130. /**
  131. * Notes:查询演职
  132. * @param int $performers_id
  133. * @return int
  134. * User: ZQ
  135. * Date: 2022/9/13
  136. */
  137. public static function performersInfo($performers_id)
  138. {
  139. $where = [];
  140. $where['performers_id'] = $performers_id;
  141. $result = LifeCinemaPerformers::where($where)->first();
  142. if (!empty($result)){
  143. $result['performers_create_time'] = date('Y-m-d H:i:s',$result['performers_create_time']);
  144. if (!empty($result['performers_update_time'])){
  145. $result['performers_update_time'] = date('Y-m-d H:i:s',$result['performers_update_time']);
  146. }
  147. }
  148. return $result;
  149. }
  150. /**
  151. * Notes:修改演职状态
  152. * @param string $performers_name
  153. * @param int $performers_status
  154. * @return int
  155. * User: ZQ
  156. * Date: 2022/9/15
  157. */
  158. public static function updateStatus($performers_id, $performers_status)
  159. {
  160. LifeCinemaPerformers::affairBegin();
  161. try {
  162. $where = [];
  163. $where['performers_id'] = $performers_id;
  164. $data = [];
  165. $data['performers_status'] = $performers_status;
  166. $result = LifeCinemaPerformers::where($where)->update($data);
  167. if ($result !== false){
  168. LifeCinemaPerformers::affairCommit();
  169. return true;
  170. }
  171. throw new \Exception('操作失败!');
  172. }catch (\Exception $exception){
  173. LifeCinemaPerformers::affairRollback();
  174. throw new \Exception($exception->getMessage(), 500);
  175. }
  176. }
  177. }