酒店预订平台
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.
 
 
 
 
 
 

211 lines
6.0 KiB

  1. <?php
  2. namespace app\admin\controller;
  3. use app\admin\dao\FileDao;
  4. use app\admin\dao\GroupDao;
  5. use app\admin\dao\OrderMainDao;
  6. use app\admin\dao\OrderMemoDao;
  7. use app\admin\model\Area;
  8. use app\admin\service\OrderMainService;
  9. use app\common\controller\Backend;
  10. use think\Db;
  11. use think\exception\PDOException;
  12. use think\exception\ValidateException;
  13. use think\Loader;
  14. /**
  15. * 订单主管理
  16. *
  17. * @icon fa fa-circle-o
  18. */
  19. class OrderMain extends Backend
  20. {
  21. protected $noNeedRight = ['getOrderList',"save","delSubOrder","subOrderSave","getShowInfo","newAdd","insertOrderMain","addMemo","getMemoList","setHotFlag","addFileInfo","getFileList","setFinanceMemo"];
  22. /**
  23. * OrderMain模型对象
  24. * @var \app\admin\model\OrderMain
  25. */
  26. protected $model = null;
  27. public function _initialize()
  28. {
  29. parent::_initialize();
  30. $this->model = new \app\admin\model\OrderMain;
  31. $this->relationSearch = true;
  32. }
  33. public function import()
  34. {
  35. parent::import();
  36. }
  37. /**
  38. * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
  39. * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
  40. * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
  41. */
  42. /**
  43. * 订单页面保存接口
  44. * @return \think\response\Json
  45. */
  46. public function save(){
  47. $params=$this->request->post();
  48. $params['create_id']=$this->auth->id;
  49. $groupDao = new GroupDao();
  50. $params['group_id'] = $groupDao->getTopGroup($this->auth->getGroupIds()[0]);
  51. $orderMainService = new OrderMainService();
  52. Db::startTrans();
  53. $result = $orderMainService->saveOrder($params);
  54. if (!$result['flag']) {
  55. Db::rollback();
  56. } else {
  57. Db::commit();
  58. }
  59. return json($result);
  60. }
  61. /**
  62. * 子订单保存接口
  63. * @return \think\response\Json
  64. */
  65. public function subOrderSave(){
  66. $params=$this->request->post();
  67. $params['create_id']=$this->auth->id;
  68. $groupDao = new GroupDao();
  69. $params['group_id'] = $groupDao->getTopGroup($this->auth->getGroupIds()[0]);
  70. $orderMainService = new OrderMainService();
  71. Db::startTrans();
  72. $result = $orderMainService->subOrderSave($params);
  73. if (!$result['flag']) {
  74. Db::rollback();
  75. } else {
  76. Db::commit();
  77. }
  78. return json($result);
  79. }
  80. /**
  81. * 删除子订单
  82. * @return \think\response\Json
  83. */
  84. public function delSubOrder(){
  85. $params=$this->request->post();
  86. $orderMainService = new OrderMainService();
  87. $result = $orderMainService->delSubOrder($params);
  88. return json($result);
  89. }
  90. /**
  91. * 获取订单详情
  92. * @return \think\response\Json
  93. */
  94. public function getShowInfo(){
  95. $params=$this->request->post();
  96. $orderMainService = new OrderMainService();
  97. $result = $orderMainService->getOrderInfo($params['id']);
  98. return json($result);
  99. }
  100. public function newAdd(){
  101. $params=$this->request->post();
  102. $hotelMain = $params["orderMain"];
  103. $this->insertOrderMain($hotelMain);
  104. return ;
  105. }
  106. private function insertOrderMain($params){
  107. $orderMain = new \app\admin\model\OrderMain();
  108. $params['create_id']=$this->auth->id;
  109. $params['group_id']=$this->auth->getGroupIds()[0];
  110. $result = $orderMain->allowField(true)->save($params);
  111. }
  112. /**
  113. * 获取订单列表
  114. * @return \think\response\Json
  115. */
  116. public function getOrderList(){
  117. $params=$this->request->post();
  118. $groupDao = new GroupDao();
  119. $params['group_id'] = $groupDao->getTopGroup($this->auth->getGroupIds()[0]);
  120. $orderMainService = new OrderMainService();
  121. $result = $orderMainService->getOrderList($params);
  122. return json($result);
  123. }
  124. /**
  125. * 添加备注记录
  126. * @return \think\response\Json
  127. */
  128. public function addMemo(){
  129. $params=$this->request->post();
  130. $params['create_id']=$this->auth->id;
  131. $orderMemoDao = new OrderMemoDao();
  132. $result = $orderMemoDao->save($params);
  133. //更新备注
  134. $orderMod = new \app\admin\model\OrderMain();
  135. $orderMod->save(["order_memo"=>$params["memo"]],["id"=>$params["order_id"]]);
  136. return json($result);
  137. }
  138. /**
  139. * 获取备注记录
  140. * @return \think\response\Json
  141. */
  142. public function getMemoList(){
  143. $params=$this->request->post();
  144. $orderMemoDao = new OrderMemoDao();
  145. $result = $orderMemoDao->getListByWhere($params);
  146. return json($result);
  147. }
  148. /**
  149. * 设置标记
  150. * @return \think\response\Json
  151. */
  152. public function setHotFlag(){
  153. $params=$this->request->post();
  154. $model = new OrderMainDao();
  155. $result = $model->setHotFlag($params["order_id"],$params["val"]);
  156. return json($result);
  157. }
  158. /**
  159. * 添加附件记录
  160. * @return \think\response\Json
  161. */
  162. public function addFileInfo(){
  163. $params=$this->request->post();
  164. $params['create_id']=$this->auth->id;
  165. $model = new FileDao();
  166. $result = $model->addInfo($params["type"],$params["file"],$params['name'],$params['id'],$params['create_id']);
  167. return json($result);
  168. }
  169. /**
  170. * 获取附件列表
  171. * @return \think\response\Json
  172. */
  173. public function getFileList(){
  174. $params=$this->request->post();
  175. $model = new FileDao();
  176. $result = $model->getList($params["type"],$params['id']);
  177. return json($result);
  178. }
  179. /**
  180. * 设置财务备注
  181. * @return \think\response\Json
  182. */
  183. public function setFinanceMemo(){
  184. $params=$this->request->post();
  185. $orderMainService = new OrderMainService();
  186. $result = $orderMainService->setFinanceMemo($params);
  187. return json($result);
  188. }
  189. }