|
- <?php
- /**
- *
- * ============================================================================
- * * 版权所有 蜘蛛出行 * *
- * 网站地址: http://www.zhizhuchuxing.com
- * ----------------------------------------------------------------------------
- * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和
- * 使用;不允许对程序代码以任何形式任何目的的再发布。
- * ============================================================================
- * Author By: 张帅
- * PhpStorm SubmitData.php
- * Create By 2017/4/20 10:48 $
- */
-
- namespace backend\modules\api\logic;
-
- use backend\modules\api\models\OperaProductRun;
- use backend\modules\api\models\OrderComment;
- use backend\modules\api\models\OrderGroupConnect;
- use backend\modules\api\models\OrderHtConsumeStock;
- use backend\modules\api\models\OrderOperaLog;
- use backend\modules\api\models\OrderPayDetail;
- use backend\modules\api\models\OrderPayMain;
- use backend\modules\api\models\OrderStatusLog;
- use backend\modules\api\models\OrderTitle;
- use backend\modules\api\models\RunBus;
- use backend\modules\api\models\RunHotel;
- use backend\modules\api\models\RunHotelDistrib;
- use backend\modules\api\models\RunProd;
- use backend\modules\api\models\RunStock;
- use backend\modules\api\models\OrderHtStatusLog;
- use backend\modules\api\models\OperaHotelLog;
- use yii\db\Exception;
- use backend\modules\api\models\OrderMain;
- use yii\db\Expression;
- use yii\db\Query;
- use Yii;
-
- class SubmitGroupData extends Query
- {
- public $order_title_base;//组合订单数据配置
-
- public $order_group_connect_base;//组合订单关联配置
-
- public $order_main_base = [];//订单基础配置
-
- public $pay_main_base = [];//主支付记录基础配置
-
- public $pay_detail_base = [];//支付明细基础配置
-
- public $order_id_arr = [];//订单id数组
-
- public $order_main_arr = [];//订单数组
-
- public $pay_main_arr = [];//主支付记录数组
-
- public $pay_detail_arr = [];//支付明细记录
-
- public $stock_order_arr = [];//库存相关修改数组
-
- public $order_title_id = 0;//组合订单号
-
- public $product_result;//预定产品信息
-
- /**
- * Function Description:获取基础信息
- * Function Name: getBaseData
- * @param array $order_title_base 组合订单数据配置
- * @param array $order_group_connect_base 组合订单关联配置
- * @param array $order_main_base 订单基础配置
- * @param array $order_main_arr 订单数组
- * @param array $pay_main_base 主支付记录基础配置
- * @param array $pay_main_arr 主支付记录数组
- * @param array $pay_detail_base 支付明细基础配置
- * @param array $pay_detail_arr 支付明细记录
- * @param array $order_id_arr 订单id数组
- * @param array $stock_order_arr 库存相关修改数组
- * @param array $product_result 预定产品信息
- *
- * @author 张帅
- */
- public function getBaseData($order_title_base, $order_group_connect_base, $order_main_base, $order_main_arr, $pay_main_base, $pay_main_arr, $pay_detail_base, $pay_detail_arr, $order_id_arr, $stock_order_arr, $product_result)
- {
- $this->order_title_base = $order_title_base;//组合订单数据配置
- $this->order_group_connect_base = $order_group_connect_base;//组合订单关联配置
- $this->order_main_base = $order_main_base;//订单基础配置
-
- $order_arr = [];//订单数组
- foreach ($order_main_arr as $key => $vel) {
- $order_arr[$vel['ID']] = $vel;
- }
- $this->order_main_arr = $order_arr;//订单数组
-
- $this->pay_main_base = $pay_main_base;//主支付记录基础配置
- $this->pay_main_arr = $pay_main_arr;//主支付记录数组
- $this->pay_detail_base = $pay_detail_base;//支付明细基础配置
- $this->pay_detail_arr = $pay_detail_arr;//支付明细记录
- $this->order_id_arr = $order_id_arr;//订单id数组
- $this->stock_order_arr = $stock_order_arr;//库存相关修改数组
-
- $this->product_result = $product_result;//预定产品信息
- }
-
- /**
- * Function Description:提交order_main数据
- * Function Name: submitOrderMain
- *
- *
- * @author 张帅
- */
- public function submitOrderMain()
- {
- try {
- #region 获取提交的表头和值
- $order_main_base = $this->order_main_base;
- $order_main_key = array_keys($order_main_base);
- $order_main_vel = $this->order_main_arr;
- #endregion
-
- #region 组合订单下单更新ORDER_TITLE_ID
- if ($this->order_title_id != 0) {
- foreach ($order_main_vel as $key => $vel) {
- if ($vel['AGENT_LEVEL'] == 1) { //只有终端订单才加上order_title_id
- $order_main_vel[$key]['ORDER_TITLE_ID'] = $this->order_title_id;
- }
- }
- }
- #endregion
-
- $this->order_main_arr = $order_main_vel;
-
- #region 提交数据
- $order_main = new OrderMain();
- $res = $order_main::find()->createCommand()->batchInsert(OrderMain::tableName(), $order_main_key, $order_main_vel)->execute();
- if (!$res) {
- $error = $order_main->getErrors();
- throw new Exception(json_encode($error));
- }
- #endregion
-
- $json['code'] = '0';
- $json['info'] = '成功';
-
- } catch (Exception $e) {
- $json['code'] = '1';
- $json['info'] = '失败';
- $json['error'] = '提交order_main数据:' . $e->getMessage();
- }
-
- return $json;
- }
-
- /**
- * Function Description:提交order_pay_main数据
- * Function Name: submitOrderPayMain
- *
- * @return mixed
- *
- * @author 张帅
- */
- public function submitOrderPayMain()
- {
- try {
- #region 获取提交的表头和值
- $pay_main_base = $this->pay_main_base;
- $pay_main_key = array_keys($pay_main_base);
- $pay_main_vel = $this->pay_main_arr;
- #endregion
-
- #region 提交数据
- $order_pay_main = new OrderPayMain();
- $res = $order_pay_main::find()->createCommand()->batchInsert(OrderPayMain::tableName(), $pay_main_key, $pay_main_vel)->execute();
- if (!$res) {
- $error = $order_pay_main->getErrors();
- throw new Exception(json_encode($error));
- }
- #endregion
-
- $json['code'] = '0';
- $json['info'] = '成功';
-
- } catch (Exception $e) {
- $json['code'] = '1';
- $json['info'] = '失败';
- $json['error'] = '提交order_pay_main数据:' . $e->getMessage();
- }
-
- return $json;
- }
-
- /**
- * Function Description:提交order_pay_detail数据
- * Function Name: submitOrderPayDetail
- *
- * @return mixed
- *
- * @author 张帅
- */
- public function submitOrderPayDetail()
- {
- try {
- #region 获取提交的表头和值
- $pay_detail_base = $this->pay_detail_base;
- $pay_detail_key = array_keys($pay_detail_base);
- $pay_detail_vel = $this->pay_detail_arr;
- #endregion
-
- #region 提交数据
- $order_pay_detail = new OrderPayDetail();
- $res = $order_pay_detail::find()->createCommand()->batchInsert(OrderPayDetail::tableName(), $pay_detail_key, $pay_detail_vel)->execute();
- if (!$res) {
- $error = $order_pay_detail->getErrors();
- throw new Exception(json_encode($error));
- }
- #endregion
-
- $json['code'] = '0';
- $json['info'] = '成功';
-
- } catch (Exception $e) {
- $json['code'] = '1';
- $json['info'] = '失败';
- $json['error'] = '提交order_pay_detail数据:' . $e->getMessage();
- }
-
- return $json;
- }
-
- /**
- * Function Description:修改巴士库存
- * Function Name: updateBusStockInfo
- *
- * @return mixed
- *
- * @author 张帅
- */
- public function updateBusStockInfo()
- {
- try {
- #region 1.更新run_x
- $run_x_arr = $this->stock_order_arr['run_x_arr'];
- foreach ($run_x_arr as $key => $vel) {
- $run_month = date('Ym', strtotime($vel['run_date']));//run_x表名
- $update_sql = 'update run_' . $run_month . '
- set order_main_id = ' . $vel['order_main_id'] . ',
- order_main_prod_id = ' . $vel['order_main_prod_id'] . ',
- order_prod_id = ' . $vel['order_prod_id'] . ',
- seat_status = ' . $vel['seat_status'] . ',
- order_lock_user_id = ' . $vel['order_lock_user_id'] . ',
- order_lock_time = \'' . $vel['order_lock_time'] . '\'
- where id in (' . implode(',', $vel['run_x_id']) . ')';
-
- $res = Yii::$app->db->createCommand($update_sql)->execute();
- if (!$res) {
- throw new Exception('占位失败');
- }
- }
- #endregion
-
- #region 2.更新run_bus
- $run_bus = new RunBus();
- $run_bus_arr = $this->stock_order_arr['run_bus_arr'];
- foreach ($run_bus_arr as $key => $vel) {
- $update_value = [
- 'UPDATE_USER_ID' => $vel['update_user_id'],
- 'UPDATE_TIME' => $vel['update_time'],
- 'SALED_COUNT' => new Expression('SALED_COUNT+' . $vel['num']),
- ];
- $update_where = [
- 'and',
- ['=', 'run_id', $vel['run_id']],
- ['=', 'bus_order_id', $vel['bus_order_id']],
- ['=', 'cancel_flag', 0],
- ];
- $res = $run_bus::updateAll($update_value, $update_where);
- if (!$res) {
- $error = $run_bus->getErrors();
- throw new Exception(json_encode($error));
- }
- }
- #endregion
-
- #region 2.1 更新bus_cost
- foreach ($run_bus_arr as $k => $v) {
- $res = SubmitBusAgentOrder::updateBusCost($v['run_id'], $v['bus_order_id']);
- if (!file_exists(__DIR__ . '/../log/bus_cost')) {
- mkdir(__DIR__ . '/../log/bus_cost');
- }
- file_put_contents(__DIR__ . '/../log/bus_cost/' . date("Y-m-d") . '.log', date("Y-m-d H:i:s") . json_encode($res) . PHP_EOL, FILE_APPEND);
- }
- #endregion
-
- #region 3.更新run_prod
- $run_prod = new RunProd();
- $run_prod_arr = $this->stock_order_arr['run_prod_arr'];
- foreach ($run_prod_arr as $key => $vel) {
- $update_value = [
- 'UPDATE_USER_ID' => $vel['update_user_id'],
- 'UPDATE_TIME' => $vel['update_time'],
- 'SALED_COUNT' => new Expression('SALED_COUNT+' . $vel['num']),
- ];
- $update_where = [
- 'and',
- ['=', 'run_id', $vel['run_id']],
- ['=', 'prod_id', $vel['ticket_id']],
- ['=', 'cancel_flag', 0],
- ];
- $res = $run_prod::updateAll($update_value, $update_where);
- if (!$res) {
- $error = $run_prod->getErrors();
- throw new Exception(json_encode($error));
- }
- }
- #endregion
-
- #region 4.更新run_stock
- $run_stock = new RunStock();
- $run_stock_arr = $this->stock_order_arr['run_stock_arr'];
- foreach ($run_stock_arr as $key => $vel) {
- $update_value = [
- 'UPDATE_USER_ID' => $vel['update_user_id'],
- 'UPDATE_TIME' => $vel['update_time'],
- 'SALED_COUNT' => new Expression('SALED_COUNT+' . $vel['num']),
- ];
- $update_where = [
- 'and',
- ['=', 'run_id', $vel['run_id']],
- ['=', 'seq_id', $vel['seq_id']],
- ['=', 'seat_type', $vel['seat_type']],
- ['=', 'cancel_flag', 0],
- ];
- $res = $run_stock::updateAll($update_value, $update_where);
- if (!$res) {
- $error = $run_stock->getErrors();
- throw new Exception(json_encode($error));
- }
- }
- #endregion
-
- $json['code'] = '0';
- $json['info'] = '成功';
- } catch (Exception $e) {
- $json['code'] = '1';
- $json['info'] = '失败';
- $json['error'] = '修改巴士库存失败:' . $e->getMessage();
- }
-
- return $json;
- }
-
- /**
- * Function Description:修改酒店库存
- * Function Name: updateHotelStockInfo
- *
- * @return mixed
- *
- * @author 张帅
- */
- public function updateHotelStockInfo()
- {
-
- try {
- #region 1.更新run_hotel
- $run_hotel = new RunHotel();
- $run_hotel_arr = $this->stock_order_arr['run_hotel_arr'];
- foreach ($run_hotel_arr as $key => $vel) {
- $update_value = [
- 'UPDATE_USER_ID' => $vel['update_user_id'],
- 'UPDATE_TIME' => $vel['update_time'],
- 'REMAINING_COUNT' => new Expression('REMAINING_COUNT-' . $vel['num']),
- 'SALED_COUNT' => new Expression('SALED_COUNT+' . $vel['num']),
- ];
- $update_where = [
- 'and',
- ['=', 'hotel_id', $vel['hotel_id']],
- ['=', 'base_room_type', $vel['base_room_type']],
- ['=', 'run_date', $vel['run_date']],
- ['=', 'stock_type', $vel['stock_type']],
- ];
- $res = $run_hotel::updateAll($update_value, $update_where);
- if (!$res) {
- $error = $run_hotel->getErrors();
- throw new Exception(json_encode($error));
- }
- }
- #endregion
-
- #region 2.更新run_hotel_distrib
- $run_hotel_distrib = new RunHotelDistrib();
- $run_hotel_distrib_arr = $this->stock_order_arr['run_hotel_distrib_arr'];
- foreach ($run_hotel_distrib_arr as $key => $vel) {
- $update_value = [
- 'UPDATE_USER_ID' => $vel['update_user_id'],
- 'UPDATE_TIME' => $vel['update_time'],
- 'REMAINING_COUNT' => new Expression('REMAINING_COUNT-' . $vel['num']),
- 'SALED_COUNT' => new Expression('SALED_COUNT+' . $vel['saled_count']),
- ];
- $update_where = [
- 'and',
- ['=', 'distrib_id', $vel['channel_id']],
- ['=', 'hotel_id', $vel['hotel_id']],
- ['=', 'base_room_type', $vel['base_room_type']],
- ['=', 'room_type', $vel['room_type']],
- ['=', 'run_date', $vel['run_date']],
- ];
- $res = $run_hotel_distrib::updateAll($update_value, $update_where);
- if (!$res) {
- $error = $run_hotel_distrib->getErrors();
- throw new Exception(json_encode($error));
- }
- }
- #endregion
-
- #region 3.修改渠道库存
- $run_hotel_disperse_result = $this->stock_order_arr['run_hotel_disperse_result'];
- #region 3.1 渠道借房
- if (count($run_hotel_disperse_result['run_hotel_distrib_disperse_arr']) > 0) {
- foreach ($run_hotel_disperse_result['run_hotel_distrib_disperse_arr'] as $key => $vel) {
- $update_value = [
- 'UPDATE_USER_ID' => $vel['update_user_id'],
- 'UPDATE_TIME' => $vel['update_time'],
- 'REMAINING_COUNT' => new Expression('REMAINING_COUNT-' . $vel['num']),
- ];
- $update_where = [
- 'and',
- ['=', 'distrib_id', $vel['distrib_id']],
- ['=', 'hotel_id', $vel['hotel_id']],
- ['=', 'base_room_type', $vel['base_room_type']],
- ['=', 'room_type', $vel['room_type']],
- ['=', 'run_date', $vel['run_date']],
- ];
- $res = $run_hotel_distrib::updateAll($update_value, $update_where);
- if (!$res) {
- $error = $run_hotel_distrib->getErrors();
- throw new Exception(json_encode($error));
- }
- }
- }
- #endregion
-
- #region 3.2 订单借房记录
- if (count($run_hotel_disperse_result['order_ht_consume_stock']) > 0) {
- $order_ht_consume_stock = new OrderHtConsumeStock();
- $order_ht_consume_stock_vel = [];
- $order_ht_consume_stock_key = ['order_id', 'distrib_id', 'run_date', 'consume_stock_count'];
- foreach ($run_hotel_disperse_result['order_ht_consume_stock'] as $key => $vel) {
- $order_ht_consume_stock_vel[] = [
- 'order_id' => $vel['order_id'],
- 'distrib_id' => $vel['distrib_id'],
- 'run_date' => $vel['run_date'],
- 'consume_stock_count' => $vel['num'],
- ];
- }
- $res = $order_ht_consume_stock::find()->createCommand()->batchInsert(OrderHtConsumeStock::tableName(), $order_ht_consume_stock_key, $order_ht_consume_stock_vel)->execute();
- if (!$res) {
- $error = $order_ht_consume_stock->getErrors();
- throw new Exception(json_encode($error));
- }
- }
- #endregion
-
- #region 4.更新order_comment
- if (count($this->stock_order_arr['order_comment_arr']) > 0) {
- $order_comment_vel = $this->stock_order_arr['order_comment_arr'];
- $order_comment_key = array_keys($order_comment_vel[0]);
- #region 提交数据
- $order_comment = new OrderComment();
- $res = $order_comment::find()->createCommand()->batchInsert(OrderComment::tableName(), $order_comment_key, $order_comment_vel)->execute();
- if (!$res) {
- $error = $order_comment->getErrors();
- throw new Exception(json_encode($error));
- }
- #endregion
- }
- #endregion
-
- #endregion
-
- $json['code'] = '0';
- $json['info'] = '成功';
- } catch (Exception $e) {
- $json['code'] = '1';
- $json['info'] = '失败';
- $json['error'] = '修改酒店库存:' . $e->getMessage();
- }
-
- return $json;
- }
-
- /**
- * Function Description:修改门票库存
- * Function Name: updateTicketStockInfo
- *
- * @return mixed
- *
- * @author 张帅
- */
- public function updateTicketStockInfo()
- {
- try {
- #region 更新opera_product_run
- $opera_product_run = new OperaProductRun();
- $opera_product_run_arr = $this->stock_order_arr['opera_product_run_arr'];
- foreach ($opera_product_run_arr as $key => $vel) {
- $update_value = [
- 'UPDATE_USER_ID' => $vel['update_user_id'],
- 'UPDATE_TIME' => $vel['update_time'],
- 'SALED_COUNT' => new Expression('SALED_COUNT+' . $vel['num']),
- ];
- $update_where = [
- 'and',
- ['=', 'prod_id', $vel['ticket_id']],
- ['=', 'run_date', $vel['run_date']],
- ['=', 'cancel_flag', 0],
- ];
- $res = $opera_product_run::updateAll($update_value, $update_where);
-
- if (!$res) {
- $error = $opera_product_run->getErrors();
- throw new Exception(json_encode($error));
- }
- }
- #endregion
-
- $json['code'] = '0';
- $json['info'] = '成功';
- } catch (Exception $e) {
- $json['code'] = '1';
- $json['info'] = '失败';
- $json['error'] = '修改门票库存:' . $e->getMessage();
- }
-
- return $json;
- }
-
- /**
- * Function Description:提交组合订单信息
- * Function Name: submitOrderTitle
- *
- * @return mixed
- *
- * @author 张帅
- */
- public function submitOrderTitle()
- {
- try {
- $order_title = new OrderTitle();
- $order_group_connect = new OrderGroupConnect();
-
- $order_group_connect_vel = [];//组合订单关联数组
- $order_group_connect_key = array_keys($this->order_group_connect_base);//组合订单关联表头
-
-
- $order_title_base = $this->order_title_base;//组合订单数据配置
- $order_id_arr = $this->order_id_arr;//订单id数组
-
- #region 提交order_title数据
-
- #region 巴士产品订单号
- if (isset($order_id_arr['bus_product'])) {
- $order_title_base['bus_order'] = implode(',', $order_id_arr['bus_product']);//对应子巴士产品订单号,多个用逗号隔开
- #region 获取组合订单关联数组
- foreach ($order_id_arr['bus_product'] as $key => $vel) {
- $order_group_connect_one = $this->order_group_connect_base;
- $order_group_connect_one['order_main_id'] = $vel;
- $order_group_connect_one['order_type'] = 1;
- $order_group_connect_vel[] = $order_group_connect_one;
- }
- #endregion
- }
- #endregion
-
- #region 酒店产品订单号
- if (isset($order_id_arr['hotel_product'])) {
- $order_title_base['hotel_order'] = implode(',', $order_id_arr['hotel_product']);//对应酒店子产品订单号,多个用逗号隔开
- #region 获取组合订单关联数组
- foreach ($order_id_arr['hotel_product'] as $key => $vel) {
- $order_group_connect_one = $this->order_group_connect_base;
- $order_group_connect_one['order_main_id'] = $vel;
- $order_group_connect_one['order_type'] = 2;
- $order_group_connect_vel[] = $order_group_connect_one;
- }
- #endregion
- }
- #endregion
-
- #region 门票产品订单号
- if (isset($order_id_arr['ticket_product'])) {
- $order_title_base['ticket_order'] = implode(',', $order_id_arr['ticket_product']);//对应门票子产品订单号,多个用逗号隔开
- #region 获取组合订单关联数组
- foreach ($order_id_arr['ticket_product'] as $key => $vel) {
- $order_group_connect_one = $this->order_group_connect_base;
- $order_group_connect_one['order_main_id'] = $vel;
- $order_group_connect_one['order_type'] = 3;
- $order_group_connect_vel[] = $order_group_connect_one;
- }
- #endregion
- }
- #endregion
-
- $order_title->attributes = $order_title_base;
- $res = $order_title->insert();
- if (!$res) {
- $error = $order_title->getErrors();
- throw new Exception(json_encode($error));
- }
-
- $order_title_id = $order_title->order_title_id;
-
- $this->order_title_id = $order_title_id;
-
- #endregion
-
- #region 提交order_group_connect数据
- foreach ($order_group_connect_vel as $key => $vel) {
- $order_group_connect_vel[$key]['order_title_id'] = $order_title_id;
- }
-
- $res = $order_group_connect::find()->createCommand()->batchInsert(OrderGroupConnect::tableName(), $order_group_connect_key, $order_group_connect_vel)->execute();
- if (!$res) {
- $error = $order_group_connect->getErrors();
- throw new Exception(json_encode($error));
- }
- #endregion
-
-
- $json['code'] = '0';
- $json['info'] = '成功';
- $json['order_title_id'] = $order_title_id;
- } catch (Exception $e) {
- $json['code'] = '1';
- $json['info'] = '失败';
- $json['error'] = '提交组合订单信息:' . $e->getMessage();
- }
-
- return $json;
- }
-
- /**
- * Function Description:提交巴士日志
- * Function Name: submitBusLog
- *
- * @return mixed
- *
- * @author 温依莅
- */
- public function submitBusLog()
- {
- $order_id_arr = $this->order_id_arr;//订单id数组
- $bus_order_arr = $order_id_arr['bus_product'];//巴士订单数组
- $order_main_arr = $this->order_main_arr;//订单数据
- $order_base_info = $this->product_result['order_info'];//订单基础配置
-
- $bus_product_list = array();//巴士产品信息(包含代售信息)
- //这里对巴士产品信息按主订单号重排,方便下面订单日志对代售信息插入对应数据
- foreach ($this->product_result['bus_product'] as $bk => $bv) {
- $bus_product_list[$bv['order_id']] = $bv;
- }
-
- $order_opera_log_vel = [];//巴士操作日志
- $order_opera_log_key = [];//巴士操作日志表头
- $order_status_log_vel = [];//巴士状态日志
- $order_status_log_key = [];//巴士状态日志表头
-
- try {
- foreach ($bus_order_arr as $key => $vel) {
- $order_info = $order_main_arr[$vel];//订单详情
- /*$order_num = explode('|', $order_info['ORDER_DESCRIPTION']);
- $order_num = end($order_num);//订单人数*/
-
- #region 添加巴士日志
- foreach ($bus_product_list[$key]['agent_list'] as $ik => $iv) {
- $title_info = ($iv['agent_level'] == 1 ? '【组合订单号:' . $order_info['ORDER_TITLE_ID'] . '】' : '');
- $order_opera_log_one = [
- 'order_id' => $iv['order_id'],
- 'opera_user_id' => $iv['agent_level'] == 1 ? $order_info['CREATE_USER_ID'] : 2,
- 'opera_type' => 1,
- 'opera_time' => date('Y-m-d H:i:s'),
- 'opera_detail' => '创建订单,出发日期' . $order_info['RUN_DATE'] . ',订单渠道:' . $iv['outside_sale_org_name'] . ',单价' . $iv['price'] . ',总额' . $iv['total_order_price'] . ',联系人信息:' . $order_info['CUSTOMER_NAME'] . ',' . $order_info['CUSTOMER_MOBILE'] . ',' . $order_info['CUSTOMER_ID_NO'] . ',备注信息:' . $order_info['CUSTOMER_MEMO'] . $title_info,
- 'member_id' => $order_info['MEMBER_ID'],
- 'opera_platform' => '统一下单',
- ];
- if (count($order_opera_log_key) == 0) {
- $order_opera_log_key = array_keys($order_opera_log_one);//巴士操作日志表头
- }
- $order_opera_log_vel[] = $order_opera_log_one;//巴士操作日志
- }
-
- #endregion
-
- #region 添加巴士订单状态
- $order_status = $order_info['ORDER_PAY_STATUS'] == 1 ? [451, 452, 453] : [451];
- foreach ($order_status as $status_key => $status_vel) {
- foreach ($bus_product_list[$key]['agent_list'] as $ik => $iv) {
- $order_status_log_one = [
- 'order_id' => $iv['order_id'],
- 'new_status' => $status_vel,
- 'change_time' => date('Y-m-d H:i:s'),
- ];
- if (count($order_status_log_key) == 0) {
- $order_status_log_key = array_keys($order_status_log_one);//巴士状态日志表头
- }
- $order_status_log_vel[] = $order_status_log_one;//巴士状态日志
- }
- }
- #endregion
- }
-
- #region 提交巴士日志
- $order_opera_log = new OrderOperaLog();
- $res = $order_opera_log::find()->createCommand()->batchInsert(OrderOperaLog::tableName(), $order_opera_log_key, $order_opera_log_vel)->execute();
- if (!$res) {
- $error = $order_opera_log->getErrors();
- throw new Exception(json_encode($error));
- }
- #endregion
-
- #region 提交巴士订单状态
- $order_status_log = new OrderStatusLog();
- $res = $order_status_log::find()->createCommand()->batchInsert(OrderStatusLog::tableName(), $order_status_log_key, $order_status_log_vel)->execute();
- if (!$res) {
- $error = $order_status_log->getErrors();
- throw new Exception(json_encode($error));
- }
-
- $json['code'] = '0';
- $json['info'] = '成功';
- #endregion
-
- } catch (Exception $e) {
- $json['code'] = '1';
- $json['info'] = '失败';
- $json['error'] = '提交巴士日志:' . $e->getMessage();
- }
-
- return $json;
- }
-
- /**
- * Function Description:提交酒店日志
- * Function Name: submitHotelLog
- *
- * @return mixed
- *
- * @author 温依莅
- */
- public function submitHotelLog()
- {
- $order_id_arr = $this->order_id_arr;//订单id数组
- $hotel_order_arr = $order_id_arr['hotel_product'];//酒店订单数组
- $order_main_arr = $this->order_main_arr;//订单数据
-
- $opera_hotel_log_vel = [];//酒店操作日志
- $opera_hotel_log_key = [];//酒店操作日志表头
- $order_ht_status_log_vel = [];//酒店状态日志
- $order_ht_status_log_key = [];//酒店状态日志表头
-
- try {
- foreach ($hotel_order_arr as $key => $vel) {
- $order_info = $order_main_arr[$vel];//订单详情
-
- #region 添加酒店日志
- $opera_hotel_log_one = [
- 'CREATE_USER_ID' => $order_info['CREATE_USER_ID'],
- 'CREATE_TIME' => $order_info['CREATE_TIME'],
- 'LOG_TYPE' => 3,
- 'HOTEL_ID' => $order_info['PARENT_PROD_ID'],
- 'PARENT_ROOM_TYPE' => 0,
- 'ROOM_TYPE' => $order_info['PROD_ID'],
- 'LOG_DESC' => '组合订单:创建订单号为' . $order_info['ORDER_ID'] . '的订单,组合订单号:' . $order_info['ORDER_TITLE_ID'],
- 'ORDER_ID' => $order_info['ORDER_ID'],
- ];
- if (count($opera_hotel_log_key) == 0) {
- $opera_hotel_log_key = array_keys($opera_hotel_log_one);//酒店操作日志表头
- }
- $opera_hotel_log_vel[] = $opera_hotel_log_one;//酒店操作日志
- #endregion
-
- #region 添加酒店订单状态
- $order_ht_status_log_one = [
- 'ORDER_ID' => $order_info['ORDER_ID'],
- 'ORDER_STATUS' => 313,
- 'BEFORE_STATUS' => 0,
- 'CREATE_USER_ID' => $order_info['CREATE_USER_ID'],
- 'CREATE_TIME' => $order_info['CREATE_TIME'],
- 'UPDATE_USER_ID' => $order_info['CREATE_USER_ID'],
- 'UPDATE_TIME' => $order_info['CREATE_TIME'],
- 'CANCEL_FLAG' => 1,
- ];
- $order_ht_status_log_two = [
- 'ORDER_ID' => $order_info['ORDER_ID'],
- 'ORDER_STATUS' => 198,
- 'BEFORE_STATUS' => 313,
- 'CREATE_USER_ID' => $order_info['CREATE_USER_ID'],
- 'CREATE_TIME' => $order_info['CREATE_TIME'],
- 'UPDATE_USER_ID' => $order_info['CREATE_USER_ID'],
- 'UPDATE_TIME' => $order_info['CREATE_TIME'],
- 'CANCEL_FLAG' => 0,
- ];
- if (count($order_ht_status_log_key) == 0) {
- $order_ht_status_log_key = array_keys($order_ht_status_log_one);//酒店状态日志表头
- }
- $order_ht_status_log_vel[] = $order_ht_status_log_one;//酒店状态日志
-
- $order_ht_status_log_vel[] = $order_ht_status_log_two;//酒店状态日志
- #endregion
- }
-
- #region 提交酒店日志
- $opera_hotel_log = new OperaHotelLog();
- $res = $opera_hotel_log::find()->createCommand()->batchInsert(OperaHotelLog::tableName(), $opera_hotel_log_key, $opera_hotel_log_vel)->execute();
- if (!$res) {
- $error = $opera_hotel_log->getErrors();
- throw new Exception(json_encode($error));
- }
- #endregion
-
- #region 提交酒店订单状态
- $order_ht_status_log = new OrderHtStatusLog();
- $res = $order_ht_status_log::find()->createCommand()->batchInsert(OrderHtStatusLog::tableName(), $order_ht_status_log_key, $order_ht_status_log_vel)->execute();
- if (!$res) {
- $error = $order_ht_status_log->getErrors();
- throw new Exception(json_encode($error));
- }
-
- $json['code'] = '0';
- $json['info'] = '成功';
- #endregion
-
- } catch (Exception $e) {
- $json['code'] = '1';
- $json['info'] = '失败';
- $json['error'] = '提交酒店日志:' . $e->getMessage();
- }
-
- return $json;
- }
- }
|