|
- <?php
- /**
- *
- * ============================================================================
- * * 版权所有 蜘蛛出行 * *
- * 网站地址: http://www.zhizhuchuxing.com
- * ----------------------------------------------------------------------------
- * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和
- * 使用;不允许对程序代码以任何形式任何目的的再发布。
- * ============================================================================
- * Author By: 温依莅
- * PhpStorm SubmitTouristOrder.php 自由行产品下单函数
- * Create By 2017/7/5 10:35 $
- */
-
- namespace backend\modules\api\logic;
-
-
- use yii\db\Query;
- use common\models\Msg;
- use backend\modules\api\logic\TouristToResource;
- use backend\modules\api\logic\GetTouristStock;
-
- class SubmitTouristOrder extends Query
- {
- /**
- * Function Description:
- * Function Name: submitTouristGroupOrder
- * @param string $sign 自由行产品标识sign,格式 TR-10001,其中10001位自由行tourist_id
- * @param string $date 产品起始日期
- * @param string $prod_arr 票种信息(成人,儿童)格式 : [{"prod_id":"TR-10001-1","prod_name":"成人票","prod_num":"2"},{"prod_id":"TR-10001-2","prod_name":"儿童票","prod_num":"1"}
- * @param string $customer_info 顾客信息 格式: {"customer_name":"测试员","customer_mobile":"15753206507","customer_id_type":"150","customer_id_no":"370689656896523698","customer_memo":"测试组合接口"}
- * @param string $order_info 订单信息 格式:{"user_id":"2","member_id":"1","outside_sale_org_id":"164","outside_sale_order_no":"smile small","order_book_status":0,"pay_type":275,"order_pay_status":1,"sales_man":""}
- * @param string $passenger_info 出行人信息 格式:[{\"passenger_name\":\"1\",\"passenger_mobile\":\"\",\"passenger_cardid\":\"34032119890824499X\"},{\"passenger_name\":\"1\",\"passenger_mobile\":\"\",\"passenger_cardid\":\"34032119890824499X\"},{\"passenger_name\":\"1\",\"passenger_mobile\":\"\",\"passenger_cardid\":\"34032119890824499X\"},{\"passenger_name\":\"1\",\"passenger_mobile\":\"\",\"passenger_cardid\":\"34032119890824499X\"},{\"passenger_name\":\"1\",\"passenger_mobile\":\"\",\"passenger_cardid\":\"34032119890824499X\"}]",
- * @return array
- *
- * @author 温依莅
- */
- public function submitTouristGroupOrder($sign, $date, $prod_arr, $customer_info, $order_info,$passenger_info,$insurance,$buy_insurance,$auth_code,$user_key,$user,$userId,$request_time)
- {
- $stockObj = new GetTouristStock();
- $transObj = new TouristToResource();
- $result = array();
- //1,将自由行下单参数转为组合产品下单参数
- $tourist_id = $stockObj->getTouristPara($sign)['real_id'];
- $order_info_arr = json_decode($order_info, true);
- $tourist_org_id = $order_info_arr['outside_sale_org_id'];//自由行产品销售渠道id,区别于下面的[该用户所在运营主体的]内部采购渠道id
- $user_id = $order_info_arr['user_id'];
- $trans_res = $transObj->getTouristToAll($tourist_id, $date, json_decode($prod_arr, true), json_decode($customer_info, true), json_decode($order_info, true),$tourist_org_id);
- if ($trans_res['code'] != '0') {
- $result['code'] = '1';
- $result['info'] = '产品不可售';
- return $result;
- }
- //2,对参数做进一步处理
- #2.1得到组合订单价格
- $total_res = $stockObj->getTouristPayTotal($tourist_id, $date, $tourist_org_id, $user_id, json_decode($prod_arr, true));
- if ($total_res['code'] != '0') {
- $result['code'] = '1';
- $result['info'] = $total_res['info'];
- return $result;
- }
- $group_order_price = $total_res['list']['total_money'];//总售价
- $adult_num = $total_res['list']['extra_info']['adult_num'];//成人数
- $child_num = $total_res['list']['extra_info']['child_num'];//儿童数
- #2.2其他参数
- $trans_arr = $trans_res['list'];
- $data['product_name'] = $trans_arr['product_name'];
- $data['bus_product'] = empty($trans_arr['bus_product']) ? '' : json_encode($trans_arr['bus_product']);
- $data['hotel_product'] = empty($trans_arr['hotel_product']) ? '' : json_encode($trans_arr['hotel_product']);
- $data['ticket_product'] = empty($trans_arr['ticket_product']) ? '' : json_encode($trans_arr['ticket_product']);
- $data['customer_info'] = json_encode($trans_arr['customer_info']);
- $data['order_info'] = json_encode($trans_arr['order_info']);//这里内含的outside_sale_org_id为该运营主体对应的内部采购渠道id
- $data['group_order_price'] = $group_order_price;//组合产品销售价格
-
- #自由行产品下单增加的参数
- $data['tourist_mark'] = $tourist_id;//$tourist_mark 标志该组合下单是否是自由行产品下单:0表示否,如是则为 tourist_id
- $data['tourist_org_id'] = $tourist_org_id;//自由行产品销售渠道id,区别于order_info里的outside_sale_org_id[运营主体所对应]内部采购渠道id
- $data['tourist_extra_info'] = json_encode(array('adult_num' => $adult_num, 'child_num' => $child_num));//自由行产品附属信息(成人和儿童数)
- $data['action'] = 'submit_group_order';
- $data['passenger_info'] = $passenger_info;
- $data['buy_insurance'] = $buy_insurance;
- $data['insurance'] = $insurance;
- $data['auth_code'] = $auth_code;
- $data['user_key'] = $user_key;
- $data['user'] = $user;
- $data['user_id'] = $userId;
- $data['request_time'] = $request_time;
- $data['tourist_id'] = $tourist_id;
- $data['date'] = $date;
- //3,调用组合产品下单接口,下单
- $res = Msg::httpRequest(CS1_DOMAIN . '/api/submit-order', $data);
- $result = json_decode($res, true);
- return $result;
- }
-
- }
|