|
- <?php
- /**
- * 订单模块
- * Class GroupOrderController
- * @package backend\modules\zzcs\controllers
- */
-
- namespace backend\modules\zzcs\controllers;
-
- use backend\modules\api\models\OrderTitle;
- use backend\modules\api\util\Util;
- use backend\modules\zzcs\logic\SubmitGroupOrder;
- use backend\modules\zzcs\models\OperaHotel;
- use backend\modules\zzcs\models\OperaLine;
- use backend\modules\zzcs\models\BaseSupplier;
- use backend\modules\zzcs\models\OperaProduct;
- use backend\modules\zzcs\logic\GroupOrderList;
- use backend\modules\zzcs\logic\GroupModify;
- use backend\modules\zzcs\models\BaseUser;
- use backend\modules\zzcs\models\OrderTitleCancelRequest;
- use common\components\zOfficeWechat;
- use common\models\Msg;
- use common\models\Utils;
- use common\util\CtripUtil;
- use yii\base\Exception;
- use yii\web\Controller;
- use Yii;
-
-
- class GroupOrderController extends Controller
- {
- public $layout = '@backend/modules/zzcs/views/layouts/zzcs';
- public $enableCsrfValidation = false;
-
- public function actionIndex()
- {
- return 'Hello';
- }
-
- /**
- * Function Description:组合产品订单列表
- * Function Name: actionGroupOrderList
- *
- * @return string
- *
- * @author 娄梦宁
- */
- public function actionGroupOrderList()
- {
- $date_type = Yii::$app->request->get('date_type', 1);//时间范围类型
- $start_date = Yii::$app->request->get('start_date', date('Y-m-d'));//起始日期
- $end_date = Yii::$app->request->get('end_date', date('Y-m-d'));//截止日期
- $supplier_id = Yii::$app->request->get('supplier_id', -1);//订单渠道
- $prod_name = Yii::$app->request->get('prod_name', '');//产品名称
- $order_status = Yii::$app->request->get('order_status', 0);//订单状态
- $select_more = Yii::$app->request->get('select_more', '');//更多查询
- $page_size = Yii::$app->request->get('page_size', 10);//每页显示数
- $current_page = Yii::$app->request->get('current_page', 1);//当前页数
- $prod_type = Yii::$app->request->get('prod_type', '-1');//产品组合类型
- $group_order_list = new GroupOrderList();
- $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);
- return $this->render('group-order-list', $data);
- }
-
- /**
- * Function Description:导出excel信息
- * Function Name: actionExportGroupOrder
- *
- *
- * @author 娄梦宁
- */
- public function actionExportGroupOrder()
- {
- $date_type = Yii::$app->request->get('date_type', 1);//时间范围类型
- $start_date = Yii::$app->request->get('start_date', date('Y-m-d'));//起始日期
- $end_date = Yii::$app->request->get('end_date', date('Y-m-d'));//截止日期
- $supplier_id = Yii::$app->request->get('supplier_id', -1);//订单渠道
- $prod_name = Yii::$app->request->get('prod_name', '');//产品名称
- $order_status = Yii::$app->request->get('order_status', 0);//订单状态
- $select_more = Yii::$app->request->get('select_more', '');//更多查询
- $prod_type = Yii::$app->request->get('prod_type', '-1');//产品组合类型
- $group_order_list = new GroupOrderList();
- $group_order_list->ExportGroupOrder($date_type, $start_date, $end_date, $supplier_id, $prod_name, $order_status, $select_more, $prod_type);
-
- }
-
- /**
- * Function Description:订单状态数据
- * Function Name: actionGetTypeArr
- *
- * @return string
- *
- * @author 娄梦宁
- */
- public function actionGetTypeArr()
- {
- $date_type = Yii::$app->request->post('date_type', 1);//时间范围类型
- $start_date = Yii::$app->request->post('start_date', date('Y-m-d', strtotime('-1 day')));//起始日期
- $end_date = Yii::$app->request->post('end_date', date('Y-m-d'));//截止日期
- $supplier_id = Yii::$app->request->post('supplier_id', -1);//订单渠道
- $prod_name = Yii::$app->request->post('prod_name', '');//产品名称
- $order_status = Yii::$app->request->post('order_status', 0);//订单状态
- $select_more = Yii::$app->request->post('select_more', '');//更多查询
- $prod_type = Yii::$app->request->post('prod_type', '-1');//产品组合类型
- $group_order_list = new GroupOrderList();
- $result = $group_order_list->get_type_arr($date_type, $start_date, $end_date, $supplier_id, $prod_name, $order_status, $select_more, $prod_type);
- return json_encode($result);
- }
-
- /**
- * Function Description:组合订单取消订单
- * Function Name: actionCancelGroupOrder
- *
- * @return string
- *
- * @author 娄梦宁
- */
- public function actionCancelGroupOrder()
- {
- $order_id = Yii::$app->request->post('order_id');//取消的组合订单id
- $reason = Yii::$app->request->post('order_id');//取消原因
- $group_order_list = new GroupOrderList();
- $result = $group_order_list->CancelGroupOrder($order_id, $reason);
- return $result;
- }
-
- /**
- * Function Description:组合订单下单页面获取财务信息
- * Function Name: actionGetFinanceInfo
- *
- * @return string
- *
- * @author 娄梦宁
- */
- public function actionGetFinanceInfo()
- {
- $prod_info = Yii::$app->request->post('prod_info', '');//组合订单的子产品信息
- $group_order_list = new GroupOrderList();
- $result = $group_order_list->countCost(json_decode($prod_info, true));
- return json_encode($result);
- }
-
- /**
- * Function Description:组合订单修改订单页面修改财务信息
- * Function Name: actionGetFinanceInfoForUpt
- *
- * @return string
- *
- * @author 娄梦宁
- */
- public function actionGetFinanceInfoForUpt()
- {
- $prod_info = Yii::$app->request->post('prod_info', '');//组合订单的子产品信息
- $group_order_list = new GroupOrderList();
- $result = $group_order_list->countCostForUpt($prod_info);
- return json_encode($result);
- }
-
- /**
- * Function Description:组合订单修改订单页面获取财务信息
- * Function Name: actionGetFinanceInfoForShow
- *
- * @return string
- *
- * @author 娄梦宁
- */
- public function actionGetFinanceInfoForShow()
- {
- $prod_info = Yii::$app->request->post('prod_info', '');//组合订单的子产品信息
- $group_order_list = new GroupOrderList();
- $result = $group_order_list->countCostForShow($prod_info);
- return json_encode($result);
- }
-
-
- /**
- * Function Description:组合产品修改页
- * Function Name: actionGoodsModify
- *
- * @return string
- *
- * @author 温依莅
- */
- public function actionGoodsModify()
- {
- $view = Yii::$app->view;
- $view->title = '组合订单修改';
- $group_order_id = Yii::$app->request->get('group_order_id', -1);
- //调用model处理得到组合产品修改相关信息
- $GroupModify = new GroupModify();
-
- $data = $GroupModify->getGroupOrderInfo($group_order_id);
- //print_r($data);exit;
- return $this->render('goods-modify', $data);
- }
-
- /**
- * Function Description:组合产品修改 pjax获取更新后的财务信息数据
- * Function Name: actionGetUpdateFinanceInfo
- *
- * @return string
- *
- * @author 温依莅
- */
- public function actionGetUpdateFinanceInfo()
- {
- $prod_info = Yii::$app->request->post('prod_info', -1);
-
- //调用model处理得到组合产品修改相关信息
-
- $group_order_list = new GroupOrderList();
- $finance_data = $group_order_list->countCostForShow($prod_info);
-
- return $this->renderPartial('group-modify-finance', ['finance_data' => $finance_data]);
- }
-
- /**
- * Function Description:修改组合产品订单
- * Function Name: actionSubmitBusOrder
- *
- *
- * @author 温依莅
- */
- public function actionModifyGroupOrder()
- {
-
- $GroupModify = new GroupModify();
-
- //获取参数
- $order_title_id = Yii::$app->request->post('order_title_id', -1);//组合产品订单号
- $customer_info_arr = Yii::$app->request->post('customer_info_arr', -1);//组合产品订单号
- $final_json = Yii::$app->request->post('final_json', -1);//获取json数组
- $ori_group_order_price = Yii::$app->request->post('ori_group_order_price', -1);//组合产品原实收总价
- $group_order_price = Yii::$app->request->post('group_order_price', -1);//组合产品现实收总价
-
-
- $bus_list_info = json_decode($final_json, true);
- $customer_info = json_decode($customer_info_arr, true);
- if ($order_title_id == -1 || $final_json == -1 || $ori_group_order_price == -1 || $group_order_price == -1 || $bus_list_info === null || !$customer_info) {
- $json = array();
- $json['code'] = 1;
- $json['info'] = '参数有误';
- return json_encode($json);
- }
-
- //调用GroupModify的ModifyGroupOrder方法处理修改请求
- $result = $GroupModify->ModifyGroupHub($order_title_id, $customer_info, $bus_list_info, $ori_group_order_price, $group_order_price);
-
- return json_encode($result);
-
- }
-
- /**
- * Function Description:提交组合订单页
- * Function Name: actionSubmitGroupOrderInfo
- *
- * @return string
- *
- * @author 张帅
- */
- public function actionSubmitGroupOrderInfo()
- {
- $base_supplier = new BaseSupplier();
- $opera_line = new OperaLine();
- $opera_product = new OperaProduct();
- $opera_hotel = new OperaHotel();
-
- #region 获取渠道列表
- $channel_list = $base_supplier->getChannelName();
- #endregion
-
- #region 获取巴士线路列表
- $bus_line_list = $opera_line->getLineInfo();
- #endregion
-
- #region 获取票种销售列表
- $ticket_list = $opera_product->getTicketName();
- #endregion
-
- #region 获取酒店产品列表
- $hotel_list = $opera_hotel->getHotelName();
- #endregion
-
- #region 获取用户主体
- $user_id = Yii::$app->request->cookies->getValue('user_id', 2);
- $model_user = new BaseUser();
- $user_info = $model_user->getUserInfo($user_id);
- #endregion
-
-
- $date['channel_list'] = $channel_list;
- $date['bus_line_list'] = $bus_line_list;
- $date['ticket_list'] = $ticket_list;
- $date['hotel_list'] = $hotel_list;
- $date['main_corp_id'] = $user_info[0]["MAIN_CORP_ID"];
- return $this->render('submit-group-order', $date);
- }
-
- /**
- * Function Description:获取巴士产品
- * Function Name: actionGetBusProInfoByLine
- *
- * @return string
- *
- * @author 张帅
- */
- public function actionGetBusProInfoByLine()
- {
- $submit_group_order = new SubmitGroupOrder();
-
- #region 1.获取参数
- $channel_id = Yii::$app->request->post('channel_id', 6);//渠道id
- $line_id = Yii::$app->request->post('line_id', 451430);//线路id
- $run_date = Yii::$app->request->post('run_date', '2017-04-10');//出行日期
- $line_type = Yii::$app->request->post('line_type', 255);//线路类型
- #endregion
-
- $result = $submit_group_order->getBusProInfoByLine($channel_id, $line_id, $run_date, $line_type);
-
- $json['code'] = 0;
- $json['info'] = '获取成功';
- $json['list'] = $result;
- return json_encode($json);
- }
-
- /**
- * Function Description:获取酒店产品
- * Function Name: actionGetHotelProInfo
- *
- * @return string
- *
- * @author 张帅
- */
- public function actionGetHotelProInfo()
- {
- $submit_group_order = new SubmitGroupOrder();
-
- #region 1.获取参数
- $channel_id = Yii::$app->request->post('channel_id');//渠道id
- $hotel_id = Yii::$app->request->post('hotel_id');//酒店id
- $base_room_type = Yii::$app->request->post('base_room_type');//基础房型
- $room_type = Yii::$app->request->post('room_type');//房间类型
- $start_date = Yii::$app->request->post('start_date');//入住日期 格式:2017-06-17
- $end_date = Yii::$app->request->post('end_date');//离店日期
- #endregion
-
- $result = $submit_group_order->getHotelProInfo($channel_id, $hotel_id, $base_room_type, $room_type, $start_date, $end_date);
- $json['code'] = 0;
- $json['info'] = '获取成功';
- $json['list'] = $result;
- return json_encode($json);
- }
-
- /**
- * Function Description:获取门票产品
- * Function Name: actionGetTicketProInfoById
- *
- * @return string
- *
- * @author 张帅
- */
- public function actionGetTicketProInfoById()
- {
- $submit_group_order = new SubmitGroupOrder();
-
- #region 1.获取参数
- $ticket_id = Yii::$app->request->post('ticket_id', 448234);//主门票id
- $run_date = Yii::$app->request->post('run_date', '2017-04-10');//线路id
- $to_org_id = Yii::$app->request->post('to_org_id', 0);
- #endregion
-
- $result = $submit_group_order->getTicketProInfoById($ticket_id, $run_date, $to_org_id);
- $json['code'] = 0;
- $json['info'] = '获取成功';
- $json['list'] = $result;
- return json_encode($json);
- }
-
- /**
- * Function Description:获取销售类型
- * Function Name: actionGetChannelSaleType
- *
- * @return string
- *
- * @author 张帅
- */
- public function actionGetChannelSaleType()
- {
- $submit_group_order = new SubmitGroupOrder();
-
- #region 1.获取参数
- $channel_id = Yii::$app->request->post('channel_id', 6);//渠道id
- #endregion
-
- $result = $submit_group_order->getChannelSaleType($channel_id);
-
- $json['code'] = 0;
- $json['info'] = '获取成功';
- $json['list'] = $result;
- return json_encode($json);
- }
-
- /**
- * Function Description:获取可选线路
- * Function Name: actionGetProductBaseInfo
- *
- * @return string
- *
- * @author 张帅
- */
- public function actionGetProductBaseInfo()
- {
- $submit_group_order = new SubmitGroupOrder();
-
- #region 1.获取参数
- $line_type = Yii::$app->request->post('line_type', 0);//线路类型
- $channel_id = Yii::$app->request->post('channel_id', 0);//渠道id
- #endregion
-
- $result = $submit_group_order->getLineInfo($line_type, $channel_id);
-
- $json['code'] = 0;
- $json['info'] = '获取成功';
- $json['list'] = $result;
- return json_encode($json);
- }
-
- /**
- * Function Description:提交组合订单
- * Function Name: actionSubmitGroupOrder
- *
- * @return string
- *
- * @author 张帅
- */
- public function actionSubmitGroupOrder()
- {
- $submit_group_order = new SubmitGroupOrder();
- $group_order_list = new GroupOrderList();
-
- #region 1.获取参数
- $product_name = Yii::$app->request->post('product_name');//产品名称
- $channel_id = Yii::$app->request->post('channel_id');//渠道id
- $channel_order_no = Yii::$app->request->post('channel_order_no', '');//渠道订单号
- $bus_product = Yii::$app->request->post('bus_product', '');//巴士产品
- $hotel_product = Yii::$app->request->post('hotel_product', '');//酒店产品
- $ticket_product = Yii::$app->request->post('ticket_product', '');//门票产品
- $customer_info = Yii::$app->request->post('customer_info', '');//顾客信息
- $finance_info = Yii::$app->request->post('finance_info');//财务信息
- $group_order_price = Yii::$app->request->post('group_order_price');//组合产品销售价格
- #endregion
- #region 获取提交订单的数据
- $data = $submit_group_order->getSubmitGroupOrderData($product_name, $channel_id, $channel_order_no, $bus_product, $hotel_product, $ticket_product, $customer_info);
- if (isset($data['code']) && $data['code'] == '1') {
- return json_encode($data);
- }
- #endregion
-
- $data['group_order_price'] = $group_order_price;//组合产品销售价格
- $data['action'] = 'submit_group_order';
-
- $result = Msg::httpRequest(CS1_DOMAIN . '/api/submit-order', $data);
- $result = json_decode($result, true);
- if ($result['code'] != '0') {
- return json_encode($result);
- }
-
- //$result = $group_order_list->InsertGroupCost($result,$finance_info); 该步已整合进前面的统一下单接口
-
-
- return json_encode($result);
- }
-
- /**
- * Des:取消审核订单操作
- * Name: actionCancelRequestOpt
- * @return string
- * @author 倪宗锋
- */
- public function actionCancelRequestOpt()
- {
- $params = [
- 'opt' => Yii::$app->request->post('opt', ''),//类型 1取消 2确认
- 'order_id' => Yii::$app->request->post('order_id', ''),//订单ID
- ];
- $type = $params['opt'] == 1 ? 2 : 3;
- $result = CtripUtil::NoticeOrderCancel($params['order_id'], $type);
- return json_encode($result);
- }
- }
|