SchedulingServer.php 6.5 KB

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