MoldServer.php 5.6 KB

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