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.
 
 
 
 
 
 

491 lines
17 KiB

  1. <?php
  2. /**
  3. * 订单模块
  4. * Class GroupOrderController
  5. * @package backend\modules\zzcs\controllers
  6. */
  7. namespace backend\modules\zzcs\controllers;
  8. use backend\modules\api\models\OrderTitle;
  9. use backend\modules\api\util\Util;
  10. use backend\modules\zzcs\logic\SubmitGroupOrder;
  11. use backend\modules\zzcs\models\OperaHotel;
  12. use backend\modules\zzcs\models\OperaLine;
  13. use backend\modules\zzcs\models\BaseSupplier;
  14. use backend\modules\zzcs\models\OperaProduct;
  15. use backend\modules\zzcs\logic\GroupOrderList;
  16. use backend\modules\zzcs\logic\GroupModify;
  17. use backend\modules\zzcs\models\BaseUser;
  18. use backend\modules\zzcs\models\OrderTitleCancelRequest;
  19. use common\components\zOfficeWechat;
  20. use common\models\Msg;
  21. use common\models\Utils;
  22. use common\util\CtripUtil;
  23. use yii\base\Exception;
  24. use yii\web\Controller;
  25. use Yii;
  26. class GroupOrderController extends Controller
  27. {
  28. public $layout = '@backend/modules/zzcs/views/layouts/zzcs';
  29. public $enableCsrfValidation = false;
  30. public function actionIndex()
  31. {
  32. return 'Hello';
  33. }
  34. /**
  35. * Function Description:组合产品订单列表
  36. * Function Name: actionGroupOrderList
  37. *
  38. * @return string
  39. *
  40. * @author 娄梦宁
  41. */
  42. public function actionGroupOrderList()
  43. {
  44. $date_type = Yii::$app->request->get('date_type', 1);//时间范围类型
  45. $start_date = Yii::$app->request->get('start_date', date('Y-m-d'));//起始日期
  46. $end_date = Yii::$app->request->get('end_date', date('Y-m-d'));//截止日期
  47. $supplier_id = Yii::$app->request->get('supplier_id', -1);//订单渠道
  48. $prod_name = Yii::$app->request->get('prod_name', '');//产品名称
  49. $order_status = Yii::$app->request->get('order_status', 0);//订单状态
  50. $select_more = Yii::$app->request->get('select_more', '');//更多查询
  51. $page_size = Yii::$app->request->get('page_size', 10);//每页显示数
  52. $current_page = Yii::$app->request->get('current_page', 1);//当前页数
  53. $prod_type = Yii::$app->request->get('prod_type', '-1');//产品组合类型
  54. $group_order_list = new GroupOrderList();
  55. $data = $group_order_list->getGroupOrderList($date_type, $start_date, $end_date, $supplier_id, $prod_name, $order_status, $select_more, $page_size, $current_page, $prod_type);
  56. return $this->render('group-order-list', $data);
  57. }
  58. /**
  59. * Function Description:导出excel信息
  60. * Function Name: actionExportGroupOrder
  61. *
  62. *
  63. * @author 娄梦宁
  64. */
  65. public function actionExportGroupOrder()
  66. {
  67. $date_type = Yii::$app->request->get('date_type', 1);//时间范围类型
  68. $start_date = Yii::$app->request->get('start_date', date('Y-m-d'));//起始日期
  69. $end_date = Yii::$app->request->get('end_date', date('Y-m-d'));//截止日期
  70. $supplier_id = Yii::$app->request->get('supplier_id', -1);//订单渠道
  71. $prod_name = Yii::$app->request->get('prod_name', '');//产品名称
  72. $order_status = Yii::$app->request->get('order_status', 0);//订单状态
  73. $select_more = Yii::$app->request->get('select_more', '');//更多查询
  74. $prod_type = Yii::$app->request->get('prod_type', '-1');//产品组合类型
  75. $group_order_list = new GroupOrderList();
  76. $group_order_list->ExportGroupOrder($date_type, $start_date, $end_date, $supplier_id, $prod_name, $order_status, $select_more, $prod_type);
  77. }
  78. /**
  79. * Function Description:订单状态数据
  80. * Function Name: actionGetTypeArr
  81. *
  82. * @return string
  83. *
  84. * @author 娄梦宁
  85. */
  86. public function actionGetTypeArr()
  87. {
  88. $date_type = Yii::$app->request->post('date_type', 1);//时间范围类型
  89. $start_date = Yii::$app->request->post('start_date', date('Y-m-d', strtotime('-1 day')));//起始日期
  90. $end_date = Yii::$app->request->post('end_date', date('Y-m-d'));//截止日期
  91. $supplier_id = Yii::$app->request->post('supplier_id', -1);//订单渠道
  92. $prod_name = Yii::$app->request->post('prod_name', '');//产品名称
  93. $order_status = Yii::$app->request->post('order_status', 0);//订单状态
  94. $select_more = Yii::$app->request->post('select_more', '');//更多查询
  95. $prod_type = Yii::$app->request->post('prod_type', '-1');//产品组合类型
  96. $group_order_list = new GroupOrderList();
  97. $result = $group_order_list->get_type_arr($date_type, $start_date, $end_date, $supplier_id, $prod_name, $order_status, $select_more, $prod_type);
  98. return json_encode($result);
  99. }
  100. /**
  101. * Function Description:组合订单取消订单
  102. * Function Name: actionCancelGroupOrder
  103. *
  104. * @return string
  105. *
  106. * @author 娄梦宁
  107. */
  108. public function actionCancelGroupOrder()
  109. {
  110. $order_id = Yii::$app->request->post('order_id');//取消的组合订单id
  111. $reason = Yii::$app->request->post('order_id');//取消原因
  112. $group_order_list = new GroupOrderList();
  113. $result = $group_order_list->CancelGroupOrder($order_id, $reason);
  114. return $result;
  115. }
  116. /**
  117. * Function Description:组合订单下单页面获取财务信息
  118. * Function Name: actionGetFinanceInfo
  119. *
  120. * @return string
  121. *
  122. * @author 娄梦宁
  123. */
  124. public function actionGetFinanceInfo()
  125. {
  126. $prod_info = Yii::$app->request->post('prod_info', '');//组合订单的子产品信息
  127. $group_order_list = new GroupOrderList();
  128. $result = $group_order_list->countCost(json_decode($prod_info, true));
  129. return json_encode($result);
  130. }
  131. /**
  132. * Function Description:组合订单修改订单页面修改财务信息
  133. * Function Name: actionGetFinanceInfoForUpt
  134. *
  135. * @return string
  136. *
  137. * @author 娄梦宁
  138. */
  139. public function actionGetFinanceInfoForUpt()
  140. {
  141. $prod_info = Yii::$app->request->post('prod_info', '');//组合订单的子产品信息
  142. $group_order_list = new GroupOrderList();
  143. $result = $group_order_list->countCostForUpt($prod_info);
  144. return json_encode($result);
  145. }
  146. /**
  147. * Function Description:组合订单修改订单页面获取财务信息
  148. * Function Name: actionGetFinanceInfoForShow
  149. *
  150. * @return string
  151. *
  152. * @author 娄梦宁
  153. */
  154. public function actionGetFinanceInfoForShow()
  155. {
  156. $prod_info = Yii::$app->request->post('prod_info', '');//组合订单的子产品信息
  157. $group_order_list = new GroupOrderList();
  158. $result = $group_order_list->countCostForShow($prod_info);
  159. return json_encode($result);
  160. }
  161. /**
  162. * Function Description:组合产品修改页
  163. * Function Name: actionGoodsModify
  164. *
  165. * @return string
  166. *
  167. * @author 温依莅
  168. */
  169. public function actionGoodsModify()
  170. {
  171. $view = Yii::$app->view;
  172. $view->title = '组合订单修改';
  173. $group_order_id = Yii::$app->request->get('group_order_id', -1);
  174. //调用model处理得到组合产品修改相关信息
  175. $GroupModify = new GroupModify();
  176. $data = $GroupModify->getGroupOrderInfo($group_order_id);
  177. //print_r($data);exit;
  178. return $this->render('goods-modify', $data);
  179. }
  180. /**
  181. * Function Description:组合产品修改 pjax获取更新后的财务信息数据
  182. * Function Name: actionGetUpdateFinanceInfo
  183. *
  184. * @return string
  185. *
  186. * @author 温依莅
  187. */
  188. public function actionGetUpdateFinanceInfo()
  189. {
  190. $prod_info = Yii::$app->request->post('prod_info', -1);
  191. //调用model处理得到组合产品修改相关信息
  192. $group_order_list = new GroupOrderList();
  193. $finance_data = $group_order_list->countCostForShow($prod_info);
  194. return $this->renderPartial('group-modify-finance', ['finance_data' => $finance_data]);
  195. }
  196. /**
  197. * Function Description:修改组合产品订单
  198. * Function Name: actionSubmitBusOrder
  199. *
  200. *
  201. * @author 温依莅
  202. */
  203. public function actionModifyGroupOrder()
  204. {
  205. $GroupModify = new GroupModify();
  206. //获取参数
  207. $order_title_id = Yii::$app->request->post('order_title_id', -1);//组合产品订单号
  208. $customer_info_arr = Yii::$app->request->post('customer_info_arr', -1);//组合产品订单号
  209. $final_json = Yii::$app->request->post('final_json', -1);//获取json数组
  210. $ori_group_order_price = Yii::$app->request->post('ori_group_order_price', -1);//组合产品原实收总价
  211. $group_order_price = Yii::$app->request->post('group_order_price', -1);//组合产品现实收总价
  212. $bus_list_info = json_decode($final_json, true);
  213. $customer_info = json_decode($customer_info_arr, true);
  214. if ($order_title_id == -1 || $final_json == -1 || $ori_group_order_price == -1 || $group_order_price == -1 || $bus_list_info === null || !$customer_info) {
  215. $json = array();
  216. $json['code'] = 1;
  217. $json['info'] = '参数有误';
  218. return json_encode($json);
  219. }
  220. //调用GroupModify的ModifyGroupOrder方法处理修改请求
  221. $result = $GroupModify->ModifyGroupHub($order_title_id, $customer_info, $bus_list_info, $ori_group_order_price, $group_order_price);
  222. return json_encode($result);
  223. }
  224. /**
  225. * Function Description:提交组合订单页
  226. * Function Name: actionSubmitGroupOrderInfo
  227. *
  228. * @return string
  229. *
  230. * @author 张帅
  231. */
  232. public function actionSubmitGroupOrderInfo()
  233. {
  234. $base_supplier = new BaseSupplier();
  235. $opera_line = new OperaLine();
  236. $opera_product = new OperaProduct();
  237. $opera_hotel = new OperaHotel();
  238. #region 获取渠道列表
  239. $channel_list = $base_supplier->getChannelName();
  240. #endregion
  241. #region 获取巴士线路列表
  242. $bus_line_list = $opera_line->getLineInfo();
  243. #endregion
  244. #region 获取票种销售列表
  245. $ticket_list = $opera_product->getTicketName();
  246. #endregion
  247. #region 获取酒店产品列表
  248. $hotel_list = $opera_hotel->getHotelName();
  249. #endregion
  250. #region 获取用户主体
  251. $user_id = Yii::$app->request->cookies->getValue('user_id', 2);
  252. $model_user = new BaseUser();
  253. $user_info = $model_user->getUserInfo($user_id);
  254. #endregion
  255. $date['channel_list'] = $channel_list;
  256. $date['bus_line_list'] = $bus_line_list;
  257. $date['ticket_list'] = $ticket_list;
  258. $date['hotel_list'] = $hotel_list;
  259. $date['main_corp_id'] = $user_info[0]["MAIN_CORP_ID"];
  260. return $this->render('submit-group-order', $date);
  261. }
  262. /**
  263. * Function Description:获取巴士产品
  264. * Function Name: actionGetBusProInfoByLine
  265. *
  266. * @return string
  267. *
  268. * @author 张帅
  269. */
  270. public function actionGetBusProInfoByLine()
  271. {
  272. $submit_group_order = new SubmitGroupOrder();
  273. #region 1.获取参数
  274. $channel_id = Yii::$app->request->post('channel_id', 6);//渠道id
  275. $line_id = Yii::$app->request->post('line_id', 451430);//线路id
  276. $run_date = Yii::$app->request->post('run_date', '2017-04-10');//出行日期
  277. $line_type = Yii::$app->request->post('line_type', 255);//线路类型
  278. #endregion
  279. $result = $submit_group_order->getBusProInfoByLine($channel_id, $line_id, $run_date, $line_type);
  280. $json['code'] = 0;
  281. $json['info'] = '获取成功';
  282. $json['list'] = $result;
  283. return json_encode($json);
  284. }
  285. /**
  286. * Function Description:获取酒店产品
  287. * Function Name: actionGetHotelProInfo
  288. *
  289. * @return string
  290. *
  291. * @author 张帅
  292. */
  293. public function actionGetHotelProInfo()
  294. {
  295. $submit_group_order = new SubmitGroupOrder();
  296. #region 1.获取参数
  297. $channel_id = Yii::$app->request->post('channel_id');//渠道id
  298. $hotel_id = Yii::$app->request->post('hotel_id');//酒店id
  299. $base_room_type = Yii::$app->request->post('base_room_type');//基础房型
  300. $room_type = Yii::$app->request->post('room_type');//房间类型
  301. $start_date = Yii::$app->request->post('start_date');//入住日期 格式:2017-06-17
  302. $end_date = Yii::$app->request->post('end_date');//离店日期
  303. #endregion
  304. $result = $submit_group_order->getHotelProInfo($channel_id, $hotel_id, $base_room_type, $room_type, $start_date, $end_date);
  305. $json['code'] = 0;
  306. $json['info'] = '获取成功';
  307. $json['list'] = $result;
  308. return json_encode($json);
  309. }
  310. /**
  311. * Function Description:获取门票产品
  312. * Function Name: actionGetTicketProInfoById
  313. *
  314. * @return string
  315. *
  316. * @author 张帅
  317. */
  318. public function actionGetTicketProInfoById()
  319. {
  320. $submit_group_order = new SubmitGroupOrder();
  321. #region 1.获取参数
  322. $ticket_id = Yii::$app->request->post('ticket_id', 448234);//主门票id
  323. $run_date = Yii::$app->request->post('run_date', '2017-04-10');//线路id
  324. $to_org_id = Yii::$app->request->post('to_org_id', 0);
  325. #endregion
  326. $result = $submit_group_order->getTicketProInfoById($ticket_id, $run_date, $to_org_id);
  327. $json['code'] = 0;
  328. $json['info'] = '获取成功';
  329. $json['list'] = $result;
  330. return json_encode($json);
  331. }
  332. /**
  333. * Function Description:获取销售类型
  334. * Function Name: actionGetChannelSaleType
  335. *
  336. * @return string
  337. *
  338. * @author 张帅
  339. */
  340. public function actionGetChannelSaleType()
  341. {
  342. $submit_group_order = new SubmitGroupOrder();
  343. #region 1.获取参数
  344. $channel_id = Yii::$app->request->post('channel_id', 6);//渠道id
  345. #endregion
  346. $result = $submit_group_order->getChannelSaleType($channel_id);
  347. $json['code'] = 0;
  348. $json['info'] = '获取成功';
  349. $json['list'] = $result;
  350. return json_encode($json);
  351. }
  352. /**
  353. * Function Description:获取可选线路
  354. * Function Name: actionGetProductBaseInfo
  355. *
  356. * @return string
  357. *
  358. * @author 张帅
  359. */
  360. public function actionGetProductBaseInfo()
  361. {
  362. $submit_group_order = new SubmitGroupOrder();
  363. #region 1.获取参数
  364. $line_type = Yii::$app->request->post('line_type', 0);//线路类型
  365. $channel_id = Yii::$app->request->post('channel_id', 0);//渠道id
  366. #endregion
  367. $result = $submit_group_order->getLineInfo($line_type, $channel_id);
  368. $json['code'] = 0;
  369. $json['info'] = '获取成功';
  370. $json['list'] = $result;
  371. return json_encode($json);
  372. }
  373. /**
  374. * Function Description:提交组合订单
  375. * Function Name: actionSubmitGroupOrder
  376. *
  377. * @return string
  378. *
  379. * @author 张帅
  380. */
  381. public function actionSubmitGroupOrder()
  382. {
  383. $submit_group_order = new SubmitGroupOrder();
  384. $group_order_list = new GroupOrderList();
  385. #region 1.获取参数
  386. $product_name = Yii::$app->request->post('product_name');//产品名称
  387. $channel_id = Yii::$app->request->post('channel_id');//渠道id
  388. $channel_order_no = Yii::$app->request->post('channel_order_no', '');//渠道订单号
  389. $bus_product = Yii::$app->request->post('bus_product', '');//巴士产品
  390. $hotel_product = Yii::$app->request->post('hotel_product', '');//酒店产品
  391. $ticket_product = Yii::$app->request->post('ticket_product', '');//门票产品
  392. $customer_info = Yii::$app->request->post('customer_info', '');//顾客信息
  393. $finance_info = Yii::$app->request->post('finance_info');//财务信息
  394. $group_order_price = Yii::$app->request->post('group_order_price');//组合产品销售价格
  395. #endregion
  396. #region 获取提交订单的数据
  397. $data = $submit_group_order->getSubmitGroupOrderData($product_name, $channel_id, $channel_order_no, $bus_product, $hotel_product, $ticket_product, $customer_info);
  398. if (isset($data['code']) && $data['code'] == '1') {
  399. return json_encode($data);
  400. }
  401. #endregion
  402. $data['group_order_price'] = $group_order_price;//组合产品销售价格
  403. $data['action'] = 'submit_group_order';
  404. $result = Msg::httpRequest(CS1_DOMAIN . '/api/submit-order', $data);
  405. $result = json_decode($result, true);
  406. if ($result['code'] != '0') {
  407. return json_encode($result);
  408. }
  409. //$result = $group_order_list->InsertGroupCost($result,$finance_info); 该步已整合进前面的统一下单接口
  410. return json_encode($result);
  411. }
  412. /**
  413. * Des:取消审核订单操作
  414. * Name: actionCancelRequestOpt
  415. * @return string
  416. * @author 倪宗锋
  417. */
  418. public function actionCancelRequestOpt()
  419. {
  420. $params = [
  421. 'opt' => Yii::$app->request->post('opt', ''),//类型 1取消 2确认
  422. 'order_id' => Yii::$app->request->post('order_id', ''),//订单ID
  423. ];
  424. $type = $params['opt'] == 1 ? 2 : 3;
  425. $result = CtripUtil::NoticeOrderCancel($params['order_id'], $type);
  426. return json_encode($result);
  427. }
  428. }