酒店预订平台
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 
 
 
 

114 satır
3.2 KiB

  1. <?php
  2. namespace app\admin\controller;
  3. use app\admin\dao\CfRoomPlanDao;
  4. use app\admin\dao\GroupDao;
  5. use app\admin\model\Area;
  6. use app\common\controller\Backend;
  7. use think\Db;
  8. use think\exception\PDOException;
  9. use think\exception\ValidateException;
  10. /**
  11. * 配置-房型方案
  12. *
  13. * @icon fa fa-circle-o
  14. */
  15. class CfRoomPlan extends Backend
  16. {
  17. protected $noNeedRight = ['getList',"list","save","delAll"];
  18. /**
  19. * CfRoomPlan模型对象
  20. * @var \app\admin\model\CfRoomPlan
  21. */
  22. protected $model = null;
  23. private $continuity_type=[
  24. 0=>"无限制",
  25. 1=>"连住几晚",
  26. 2=>"连住几晚及以上",
  27. 3=>"连住几晚及其倍数"
  28. ];
  29. public function _initialize()
  30. {
  31. parent::_initialize();
  32. $this->model = new \app\admin\model\CfRoomPlan;
  33. }
  34. public function import()
  35. {
  36. parent::import();
  37. }
  38. /**
  39. * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
  40. * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
  41. * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
  42. */
  43. public function getList(){
  44. $groupDao = new GroupDao();
  45. $group_id = $groupDao->getTopGroup($this->auth->getGroupIds()[0]);
  46. $name=$this->request->post('name');
  47. $keyValue=$this->request->post('keyValue');
  48. $this->model->field('id,plan_name as name,purchase_user_id,plan_memo');
  49. $where = ["del_flag"=>0,"group_id"=>$group_id];
  50. if($keyValue){
  51. $where = ['id'=>$keyValue,"del_flag"=>0,"group_id"=>$group_id];
  52. }elseif($name){
  53. $where = ['plan_name'=>['like','%'.$name.'%'],"del_flag"=>0,"group_id"=>$group_id];
  54. }
  55. $roomId =$this->request->get('room_id');
  56. if ($roomId){
  57. $where["room_id"] = $roomId;
  58. }
  59. $result= $this->model->where($where)->select();
  60. if($keyValue){
  61. return json(['list' => $result]);
  62. }
  63. return json(['list' => $result]);
  64. }
  65. /**
  66. * 获取列表
  67. * @return \think\response\Json
  68. */
  69. public function list(){
  70. $params=$this->request->post();
  71. $params['create_id']=$this->auth->id;
  72. $groupDao = new GroupDao();
  73. $params['group_id'] = $groupDao->getTopGroup($this->auth->getGroupIds()[0]);
  74. $service = new CfRoomPlanDao();
  75. return json($service->getList($params));
  76. }
  77. /**
  78. * 保存记录
  79. * @return \think\response\Json
  80. */
  81. public function save(){
  82. $params=$this->request->post();
  83. $params['create_id']=$this->auth->id;
  84. $groupDao = new GroupDao();
  85. $params['group_id'] = $groupDao->getTopGroup($this->auth->getGroupIds()[0]);
  86. $service = new CfRoomPlanDao();
  87. return json($service->save($params));
  88. }
  89. /**
  90. * 删除
  91. * @return \think\response\Json
  92. */
  93. public function delAll(){
  94. $params=$this->request->post();
  95. $service = new CfRoomPlanDao();
  96. return json($service->del($params));
  97. }
  98. }