CinemaServer.php 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. <?php
  2. namespace app\admin\server\life;
  3. use app\admin\model\LifeCinema;
  4. use app\admin\model\SystemMenu;
  5. use support\Redis;
  6. class CinemaServer
  7. {
  8. /**
  9. * Notes:获取影片列表
  10. * @param string $keywords
  11. * @param int $page
  12. * @param int $limit
  13. * @return array
  14. * User: ZQ
  15. * Date: 2022/9/13
  16. */
  17. public static function getCinemaList(int $page, int $limit, string $keywords)
  18. {
  19. [$list, $count] = LifeCinema::getCinemaList($page, $limit, $keywords);
  20. if (!empty($list)){
  21. foreach ($list as $k => $v){
  22. $list[$k]['cinema_director'] = explode(',',$v['cinema_director']);
  23. $list[$k]['cinema_star'] = explode(',',$v['cinema_star']);
  24. $list[$k]['cinema_performers'] = explode(',',$v['cinema_performers']);
  25. $list[$k]['cinema_create_time'] = date('Y-m-d H:i:s',$v['cinema_create_time']);
  26. if (!empty($v['cinema_update_time'])){
  27. $list[$k]['cinema_update_time'] = date('Y-m-d H:i:s',$v['cinema_update_time']);
  28. }
  29. }
  30. }
  31. return compact('list', 'page', 'limit', 'count');
  32. }
  33. /**
  34. * Notes:修改影片
  35. * @param string $cinema_name
  36. * @param int $cinema_id
  37. * @return int
  38. * User: ZQ
  39. * Date: 2022/9/3
  40. */
  41. public static function updateCinema($cinema_id, $cinema_name, $cinema_video, $cinema_mold, $cinema_director, $cinema_star, $cinema_price, $cinema_introduction, $cinema_performers, $cinema_seat, $cinema_length, $cinema_time, $cinema_label, $cinema_img, $cinema_status, $cinema_week, $admin_id)
  42. {
  43. LifeCinema::affairBegin();
  44. try {
  45. $where = [];
  46. $where['cinema_id'] = $cinema_id;
  47. $data = [];
  48. $data['cinema_name'] = $cinema_name;
  49. $data['cinema_video'] = $cinema_video;
  50. $data['cinema_mold'] = implode(',',$cinema_mold);
  51. $data['cinema_director'] = implode(',',$cinema_director);
  52. $data['cinema_price'] = $cinema_price;
  53. $data['cinema_star'] = implode(',',$cinema_star);
  54. $data['cinema_introduction'] = $cinema_introduction;
  55. $data['cinema_performers'] = implode(',',$cinema_performers);
  56. $data['cinema_seat'] = $cinema_seat;
  57. $data['cinema_length'] = $cinema_length;
  58. $data['cinema_week'] = is_array($cinema_week) ? implode(',', $cinema_week) : $cinema_week;
  59. $data['cinema_time'] = is_array($cinema_time) ? implode('~', $cinema_time) : $cinema_time;
  60. $data['cinema_label'] = $cinema_label;
  61. $data['cinema_img'] = $cinema_img;
  62. $data['cinema_status'] = $cinema_status;
  63. $data['cinema_update_time'] = time();
  64. $result = LifeCinema::where($where)->update($data);
  65. if ($result !== false){
  66. $msg = '管理员:' . $admin_id . '在:' . date("Y-m-d H:i:s", time()) . '修改万悦影院影片-编号: ' . $cinema_id;
  67. plog('life-cinema-update', '悦活-万悦影院-修改影片', $msg);
  68. LifeCinema::affairCommit();
  69. return true;
  70. }
  71. throw new \Exception('操作失败!');
  72. }catch (\Exception $exception){
  73. LifeCinema::affairRollback();
  74. throw new \Exception($exception->getMessage(), 500);
  75. }
  76. }
  77. /**
  78. * Notes:删除影片
  79. * @param int $cinema_id
  80. * @return int
  81. * User: ZQ
  82. * Date: 2022/9/13
  83. */
  84. public static function delCinema($cinema_id,$admin_id)
  85. {
  86. LifeCinema::affairBegin();
  87. try {
  88. $where = [];
  89. $where['cinema_id'] = $cinema_id;
  90. $data['cinema_is_del'] = 1;
  91. $result = LifeCinema::where($where)->update($data);
  92. if (!empty($result)){
  93. $msg = '管理员:' . $admin_id . '在:' . date("Y-m-d H:i:s", time()) . '删除万悦影院影片-编号: ' . $cinema_id;
  94. plog('life-cinema-delete', '悦活-万悦影院-删除影片', $msg);
  95. LifeCinema::affairCommit();
  96. return true;
  97. }else{
  98. return false;
  99. }
  100. }catch (\Exception $exception){
  101. LifeCinema::affairRollback();
  102. throw new \Exception($exception->getMessage(), 500);
  103. }
  104. }
  105. /**
  106. * Notes: 添加影片
  107. * @param string $cinema_name
  108. * @param array $cinema_rules
  109. * @return int
  110. * User: ZQ
  111. * Date: 2022/9/13
  112. */
  113. public static function insertCinema($cinema_name, $cinema_video, $cinema_mold, $cinema_director, $cinema_star, $cinema_price, $cinema_introduction, $cinema_performers, $cinema_seat, $cinema_length, $cinema_time, $cinema_label, $cinema_img, $cinema_status, $cinema_week, $admin_id)
  114. {
  115. LifeCinema::affairBegin();
  116. try {
  117. $data = [];
  118. $data['cinema_name'] = $cinema_name;
  119. $data['cinema_video'] = $cinema_video;
  120. $data['cinema_mold'] = implode(',',$cinema_mold);
  121. $data['cinema_director'] = implode(',',$cinema_director);
  122. $data['cinema_price'] = $cinema_price;
  123. $data['cinema_star'] = implode(',',$cinema_star);
  124. $data['cinema_introduction'] = $cinema_introduction;
  125. $data['cinema_performers'] = implode(',',$cinema_performers);
  126. $data['cinema_seat'] = $cinema_seat;
  127. $data['cinema_length'] = $cinema_length;
  128. $data['cinema_week'] = is_array($cinema_week) ? implode(',', $cinema_week) : $cinema_week;
  129. $data['cinema_time'] = is_array($cinema_time) ? implode('~', $cinema_time) : $cinema_time;
  130. $data['cinema_label'] = $cinema_label;
  131. $data['cinema_img'] = $cinema_img;
  132. $data['cinema_status'] = $cinema_status;
  133. $data['cinema_create_time'] = time();
  134. $result = LifeCinema::insertGetId($data);
  135. if (!empty($result)){
  136. $msg = '管理员:' . $admin_id . '在:' . date("Y-m-d H:i:s", time()) . '添加万悦影院影片-编号: ' . $result;
  137. plog('life-cinema-create', '悦活-万悦影院-添加影片', $msg);
  138. LifeCinema::affairCommit();
  139. return $result;
  140. }
  141. throw new \Exception('操作失败!');
  142. }catch (\Exception $exception){
  143. LifeCinema::affairRollback();
  144. throw new \Exception($exception->getMessage(), 500);
  145. }
  146. }
  147. /**
  148. * Notes:查询影片
  149. * @param int $cinema_id
  150. * @return int
  151. * User: ZQ
  152. * Date: 2022/9/13
  153. */
  154. public static function cinemaInfo($cinema_id)
  155. {
  156. $where = [];
  157. $where['cinema_id'] = $cinema_id;
  158. $result = LifeCinema::where($where)->first();
  159. if (!empty($result)){
  160. $cinema_mold = explode(',',$result['cinema_mold']);
  161. if (!empty($cinema_mold)){
  162. for ($i=0;$i<count($cinema_mold);$i++){
  163. $mold[] = (int)$cinema_mold[$i];
  164. }
  165. $result['cinema_mold'] = $mold;
  166. }
  167. $director = explode(',',$result['cinema_director']);
  168. if (!empty($director)){
  169. for ($s=0;$s<count($director);$s++){
  170. $cinema_director[] = (int)$director[$s];
  171. }
  172. $result['cinema_director'] = $cinema_director;
  173. }
  174. $cinema_star = explode(',',$result['cinema_star']);
  175. if (!empty($cinema_star)){
  176. for ($k=0;$k<count($cinema_star);$k++){
  177. $star[] = (int)$cinema_star[$k];
  178. }
  179. $result['cinema_star'] = $star;
  180. }
  181. $cinema_performers = explode(',',$result['cinema_performers']);
  182. if (!empty($cinema_performers)){
  183. for ($a=0;$a<count($cinema_performers);$a++){
  184. $performers[] = (int)$cinema_performers[$a];
  185. }
  186. $result['cinema_performers'] = $performers;
  187. }
  188. $result['cinema_create_time'] = date('Y-m-d H:i:s',$result['cinema_create_time']);
  189. if (!empty($result['cinema_update_time'])){
  190. $result['cinema_update_time'] = date('Y-m-d H:i:s',$result['cinema_update_time']);
  191. }
  192. }
  193. return $result;
  194. }
  195. /**
  196. * Notes:修改影片状态
  197. * @param string $cinema_name
  198. * @param int $cinema_status
  199. * @return int
  200. * User: ZQ
  201. * Date: 2022/9/15
  202. */
  203. public static function updateStatus($cinema_id, $cinema_status)
  204. {
  205. LifeCinema::affairBegin();
  206. try {
  207. $where = [];
  208. $where['cinema_id'] = $cinema_id;
  209. $data = [];
  210. $data['cinema_status'] = $cinema_status;
  211. $result = LifeCinema::where($where)->update($data);
  212. if ($result !== false){
  213. LifeCinema::affairCommit();
  214. return true;
  215. }
  216. throw new \Exception('操作失败!');
  217. }catch (\Exception $exception){
  218. LifeCinema::affairRollback();
  219. throw new \Exception($exception->getMessage(), 500);
  220. }
  221. }
  222. }