酒店预订平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

137 lines
3.9 KiB

  1. <?php
  2. namespace app\admin\controller;
  3. use app\admin\dao\GroupDao;
  4. use app\admin\model\Area;
  5. use app\admin\service\OrderMainService;
  6. use app\common\controller\Backend;
  7. use think\Db;
  8. use think\exception\PDOException;
  9. use think\exception\ValidateException;
  10. use think\Loader;
  11. /**
  12. * 订单主管理
  13. *
  14. * @icon fa fa-circle-o
  15. */
  16. class OrderMain extends Backend
  17. {
  18. protected $noNeedRight = ['getOrderList',"save","delSubOrder","subOrderSave","getShowInfo","newAdd","insertOrderMain"];
  19. /**
  20. * OrderMain模型对象
  21. * @var \app\admin\model\OrderMain
  22. */
  23. protected $model = null;
  24. public function _initialize()
  25. {
  26. parent::_initialize();
  27. $this->model = new \app\admin\model\OrderMain;
  28. $this->relationSearch = true;
  29. }
  30. public function import()
  31. {
  32. parent::import();
  33. }
  34. /**
  35. * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
  36. * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
  37. * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
  38. */
  39. /**
  40. * 订单页面保存接口
  41. * @return \think\response\Json
  42. */
  43. public function save(){
  44. $params=$this->request->post();
  45. $params['create_id']=$this->auth->id;
  46. $groupDao = new GroupDao();
  47. $params['group_id'] = $groupDao->getTopGroup($this->auth->getGroupIds()[0]);
  48. $orderMainService = new OrderMainService();
  49. Db::startTrans();
  50. $result = $orderMainService->saveOrder($params);
  51. if (!$result['flag']) {
  52. Db::rollback();
  53. } else {
  54. Db::commit();
  55. }
  56. return json($result);
  57. }
  58. /**
  59. * 子订单保存接口
  60. * @return \think\response\Json
  61. */
  62. public function subOrderSave(){
  63. $params=$this->request->post();
  64. $params['create_id']=$this->auth->id;
  65. $groupDao = new GroupDao();
  66. $params['group_id'] = $groupDao->getTopGroup($this->auth->getGroupIds()[0]);
  67. $orderMainService = new OrderMainService();
  68. Db::startTrans();
  69. $result = $orderMainService->subOrderSave($params);
  70. if (!$result['flag']) {
  71. Db::rollback();
  72. } else {
  73. Db::commit();
  74. }
  75. return json($result);
  76. }
  77. /**
  78. * 删除子订单
  79. * @return \think\response\Json
  80. */
  81. public function delSubOrder(){
  82. $params=$this->request->post();
  83. $orderMainService = new OrderMainService();
  84. $result = $orderMainService->delSubOrder($params);
  85. return json($result);
  86. }
  87. /**
  88. * 获取订单详情
  89. * @return \think\response\Json
  90. */
  91. public function getShowInfo(){
  92. $params=$this->request->post();
  93. $orderMainService = new OrderMainService();
  94. $result = $orderMainService->getOrderInfo($params['id']);
  95. return json($result);
  96. }
  97. public function newAdd(){
  98. $params=$this->request->post();
  99. $hotelMain = $params["orderMain"];
  100. $this->insertOrderMain($hotelMain);
  101. return ;
  102. }
  103. private function insertOrderMain($params){
  104. $orderMain = new \app\admin\model\OrderMain();
  105. $params['create_id']=$this->auth->id;
  106. $params['group_id']=$this->auth->getGroupIds()[0];
  107. $result = $orderMain->allowField(true)->save($params);
  108. }
  109. /**
  110. * 获取订单列表
  111. * @return \think\response\Json
  112. */
  113. public function getOrderList(){
  114. $params=$this->request->post();
  115. $groupDao = new GroupDao();
  116. $params['group_id'] = $groupDao->getTopGroup($this->auth->getGroupIds()[0]);
  117. $orderMainService = new OrderMainService();
  118. $result = $orderMainService->getOrderList($params);
  119. return json($result);
  120. }
  121. }