@ -27,7 +27,7 @@ class Tulanduo
)
);
/*!
* test
* test:
*/
// private $send_host = array(
// "30" => array(
@ -45,10 +45,11 @@ class Tulanduo
// 29188 95c3b0d958a79a1216e651df182b3cb4
// 30548 9db75a2dc17156eb122364295804b7a2
// test
// test:
// public $list_url = "http://ltdj.ltsoftware.net:19919/action/api/searchRouteOrder/";
// public $detail_url = "http://ltdj.ltsoftware.net:19919/action/api/detailRouteOrder/";
// public $neworder_url = "http://ltdj.ltsoftware.net:19919/action/api/addOrUpdateRouteOrder/";
// public $neworder_url = "http://ltdj.ltsoftware.net:18888/action/api/addOrUpdateRouteOrder/";
// Live
public $list_url = "http://djb3c.ltsoftware.net:9921/action/api/searchRouteOrder/";
public $detail_url = "http://djb3c.ltsoftware.net:9921/action/api/detailRouteOrder/";
@ -86,13 +87,11 @@ class Tulanduo
}
// 商务
if (strval($order->GRI_OrderType) === "227002") {
return false; // for Trippest deploy
return $this->push_biz($order, strval($order->GRI_OrderType));
return $this->push_biz($order);
}
// 传统订单
if (strval($order->GRI_OrderType) === "227001") {
return false; // for Trippest deploy
return $this->push_tour($order, strval($order->GRI_OrderType));
return $this->push_tour($order);
}
return "[Tulanduo>order_push] No function match. ";
@ -101,9 +100,8 @@ class Tulanduo
/*!
* 发送线路订单计划
*/
public function push_tour($vas=null, $gri_ordertype='227001' )
public function push_tour($vas=null)
{
return false; // for Trippest deploy
$gri_sn = $vas->GRI_SN;
$vas_sn = $vas->VAS_SN;
$vei_sn = $vas->VAS_VEI_SN;
@ -130,7 +128,6 @@ class Tulanduo
$grd_apart_info = $this->tour_apart($grd_info);
$big_order_index = 0;
$expect_order_cnt = count($grd_apart_info['com'])+intval(!empty($grd_apart_info['big_pvt']))+intval(!empty($grd_apart_info['pvt']));
// echo json_encode($grd_info);exit;
foreach ($grd_apart_info as $group_key => $grd_a) {
$big_order_index = $this->tour_apart_order_exec($group_key, $vas, $request_info, $guestlist, $grd_a, $big_order_index);
}
@ -146,7 +143,7 @@ class Tulanduo
* @Date: 2019-05-30 16:11:34
* @Desc: 执行发送订单计划信息. 参数已拆分归类好的行程
*/
public function tour_apart_order_exec($group_type, $vas, $request_info, $guestlist, $grd, $total_order_index)
public function tour_apart_order_exec($group_type, $vas, $request_info, $guestlist=null , $grd, $total_order_index)
{
if (empty($grd)) {
return $total_order_index;
@ -159,8 +156,8 @@ class Tulanduo
$all_grd = array($grd);
$routeName = "中华游" . $grd['details'][0]->tocity . "常规线路";
$routeType = $routeName;
$agcOrderNo = $vas->GRI_Name . "-" . $grd['details'][0]->citycode . "-" . $total_order_index ;
$agcOrderNo .= "(" . $vas->operator . ")";
$agcOrderNo = $vas->GRI_Name;
// $agcOrderNo .= "(" . $vas->operator . ")";
$order_type = 1;
break;
case 'pvt':
@ -169,8 +166,8 @@ class Tulanduo
$routeName = empty($grd['details'][0]->GRD_Landscape) ? $grd['details'][0]->PAG_Title : $grd['details'][0]->GRD_Landscape;
$routeName .= "(" . $grd['details'][0]->PAG_Code . ")";
$routeType = $grd['details'][0]->tocity . "目的地线路";
$agcOrderNo = $vas->GRI_Name . "-" . $grd['details'][0]->citycode . "-" . $total_order_index ;
$agcOrderNo .= "(" . $vas->operator . ")";
$agcOrderNo = $vas->GRI_Name;
// $agcOrderNo .= "(" . $vas->operator . ")";
$order_type = 1;
break;
case 'com':
@ -187,8 +184,8 @@ class Tulanduo
$routeName = $vo['details'][0]->GRD_Landscape . "(" . $vo['details'][0]->PAG_Code . ")";
}
$routeType = $vo['details'][0]->tocity . "目的地线路";
$agcOrderNo = $vas->GRI_Name . "-" . $vo['details'][0]->citycode . "-" . $total_order_index ;
$agcOrderNo .= "(" . $vas->operator . ")";
$agcOrderNo = $vas->GRI_Name;
// $agcOrderNo .= "(" . $vas->operator . ")";
}
$first_date = $vo['details'][0]->day_no_raw;
$last_date = COUNT($vo['details'])-1;
@ -209,6 +206,10 @@ class Tulanduo
// ->setRoomStandard($request_info->GCI_HotelRequest) // 住房标准
->setRouteStandard($request_info->GCI_Request) // 行程服务标准
;
if ($guestlist===null) {
$g_cold_str = array_map(function ($ele){return $ele->GRD_COLD_SN;}, $vo['details']);
$guestlist = $this->ci->BIZ_order->get_guestlist(implode(',',$g_cold_str));
}
foreach ($guestlist as $key => $vg) {
$this->ci->tldOrderBuilder->setCustomersName($key, $vg->MemberName )
->setCustomersPeopleType($key, (calc_age_type($vg->BirthDay)==1 ? "成人" : "儿童"))
@ -250,16 +251,25 @@ class Tulanduo
->setScheduleDetailsDinner($kd, (trim($vgrd->GRD_Meal_S)==="" ? 0 : 1 ))
->setScheduleDetailsLunch($kd, (trim($vgrd->GRD_Meal_L)==="" ? 0 : 1 ))
;
if (isset($vgrd->hotel_checkin)) {
$this->ci->tldOrderBuilder->setRoomStandard(trim($vgrd->hotel_checkin));
}
if (isset($vgrd->to_traffic)) {
$this->ci->tldOrderBuilder->setToTraffic(trim($vgrd->to_traffic));
}
if (isset($vgrd->back_traffic)) {
$this->ci->tldOrderBuilder->setBackTraffic(trim($vgrd->back_traffic));
}
if (isset($vgrd->vendor_memo)) {
$this->ci->tldOrderBuilder->setOrderRemark(trim($vgrd->vendor_memo));
}
}
}
}
// 查询是否变更 TODO: deprecated at 2019-05
// 查询是否变更 deprecated at 2019-05
$sync_orderstate = 10;
$this->ci->tldOrderBuilder->clearModifyLogInfo();
$resp = $this->excute_curl($this->neworder_url, $this->ci->tldOrderBuilder);
// $resp = '{"status":1,"errMsg":"","responseData":{"orderId":' . rand(1000,9999) . '}}'; // test:
echo $this->ci->tldOrderBuilder->getBizContent();
log_message('error',$resp);
$response = json_decode($resp);
if ($response->status == 1) {
/** VendorPlanSync */
@ -299,6 +309,10 @@ log_message('error',$resp);
{
$apart = array(); $ret = array();
foreach ($all_pag_info as $key => $pag) {
if ( ! isset($pag->PAG_DEI_SN)) {
// 通宵火车或其他, 不含该社行程
continue;
}
// CH下的产品编号修正
if (intval($pag->PAG_DEI_SN)===1 & & ! empty($pag->PAG_Code)) {
$pag->PAG_Code = $this->ci->trippest->ch_code_transfer( mb_strtoupper($pag->PAG_Code));
@ -360,21 +374,205 @@ log_message('error',$resp);
* @Date: 2019-06-04 11:47:38
* @Desc: 发送商务订单计划
*/
public function push_biz($vas=null, $gri_ordertype='227002' )
public function push_biz($vas=null)
{
$userId = $this->send_host["1"]["userId"];
$userKey = $this->send_host["1"]["key"];
$gri_sn = $vas->GRI_SN;
$vas_sn = $vas->VAS_SN;
$vei_sn = $vas->VAS_VEI_SN;
$grd_info = $this->ci->Group_model->get_vendor_plan_info($gri_sn, $vei_sn);
$grd_info = $this->ci->Group_model->get_vendor_plan_info($gri_sn, $vei_sn, true );
if (empty($grd_info)) {
$this->ci->Group_model->set_plan_received($vas_sn);
return false;
}
$route_name = "";
$order_type = 1;
$COLD_SN_str = implode(',', array_map( function($element){return $element->GRD_COLD_SN;}, $grd_info )) ;
$all_colds = $this->ci->BIZ_order->get_all_cold($COLD_SN_str);
$coli_sn = $all_colds[0]->COLI_SN;
$train_coldsn_arr = array();$train_order = array();
$pag_coldsn_arr = array();$pag_order = array();
foreach ($all_colds as $kd => $vcold) {
if (strval($vcold->COLD_ServiceType)==='2') {
$train_coldsn_arr[] = $vcold->COLD_SN;
continue;
}
if (strval($vcold->COLD_ServiceType)==='D') {
$pag_coldsn_arr[] = $vcold->COLD_SN;
continue;
}
}
if ( ! empty($train_coldsn_arr)) {
$route_name .= $route_name==="" ? "" : "+";
$route_name .= "火车票预订";
$order_type = 1;
$train_order = $this->ci->BIZ_order->get_train_flight_order(implode(',', $train_coldsn_arr));
$agcOrderNo = $vas->GRI_Name;
$last_date = count($train_order)-1;
$end_date = strstr($train_order[$last_date]->COLD_EndDate, " ", true);
$end_date = $end_date ? $end_date : strstr($train_order[0]->COLD_StartDate, " ", true);
$this->ci->tldOrderBuilder->setUserId($userId)
->setKey($userKey)
->setOrderType($order_type)
->setRouteName($route_name)
->setRouteType("火车票预订")
->setAgcOrderNo($agcOrderNo)
->setAdultNum($train_order[0]->adult_num)
->setChildNum($train_order[0]->child_num)
->setDestination($train_order[0]->city_name)
->setTravelDate(strstr($train_order[0]->COLD_StartDate, " ", true))
->setLeavedDate($end_date)
;
$train_guest_list = $this->ci->BIZ_order->get_guestlist(implode(',', $train_coldsn_arr));
// 客人列表
foreach ($train_guest_list as $key => $vg) {
$this_otherinfo = "";
$this->ci->tldOrderBuilder->setCustomersName($key, $vg->BPE_FirstName . " " . $vg->BPE_LastName )
->setCustomersPeopleType($key, ($vg->BPE_GuestType==1 ? "成人" : "儿童"))
->setCustomersDocumentType($key, "护照") // Passport No.
->setCustomersDocumentNo($key, $vg->BPE_Passport)
;
$this_otherinfo .= $this->ci->BIZ_order->GetNationalityName($vg->BPE_Nationality);
// todo:电话
// if (trim($vf['cold'][0]->GUT_TEL) != "" & & $key===0) {
// $this_otherinfo .= "; 电话:";
// $this_otherinfo .= trim($vf["cold"][0]->GUT_POST)!=="" ? "+".trim($vf["cold"][0]->GUT_POST) : "" ;
// $this_otherinfo .= " " . trim($vf["cold"][0]->GUT_TEL);
// $this->ci->tldOrderBuilder->setCustomersOtherInfo($key, $this_otherinfo);
// }
}
$s_index = 0;
foreach ($train_order as $train) {
$this_content = '';
$this_content .= $train->departure_date . " " . $train->depart_station . "-" . $train->arrival_station . " " . $train->FlightsNo ;
$this_content .= "(" . $train->duration . ")" . " " . $train->cabin_name . " " . $train->adultcost . "元\r\n";
$this_content .= "请购票成功后通知外联。";
if (trim($train->TicketAddress) != '') {
$this_content .= "并于客人入住前两天,快递送达客人酒店,谢谢!\r\n";
$this_content .= $train->TicketAddress;
}
$this->ci->tldOrderBuilder->setScheduleDetailsTitle($s_index, $train->departure_date)
->setScheduleDetailsContent($s_index, $this_content)
;
$s_index++;
}
$this->ci->tldOrderBuilder->clearModifyLogInfo();
// echo $this->ci->tldOrderBuilder->getBizContent();exit;
$resp = $this->excute_curl($this->neworder_url, $this->ci->tldOrderBuilder);
$response = json_decode($resp);
$sync_orderstate = 10;
$vps_sn = 0;
if ($response->status == 1) {
/** VendorPlanSync */
$sync_ret = array(
"VPS_VAS_SN" => $vas_sn
,"VPS_GRI_SN" => $gri_sn
,"VPS_VEI_SN" => $vei_sn
,"VPS_startDate" => strstr($train_order[0]->COLD_StartDate, " ", true)
,"VPS_endDate" => $end_date
,"VPS_sendHost" => $userId
,"VPS_externalId" => $response->responseData->orderId
,"VPS_externalorderType" => $order_type
,"VPS_externalorderState" => $sync_orderstate
,"VPS_sendTime" => date('Y-m-d H:i:s')
);
if ($vps_sn === 0) {
$sync_id = $this->ci->Group_model->insert_VendorPlanSync($sync_ret);
$this->ci->BIZ_order->insert_biz_order_log($coli_sn, "vendorPlanSendout_");
}
/** VendorArrangeState VAS_IsReceive */
$this->ci->Group_model->set_plan_received($vas_sn);
}
}
if ( ! empty($pag_coldsn_arr)) {
$this->biz_pag_order_exec($vas,$grd_info);
}
return false;
}
private function biz_pag_order_exec($vas, $grd)
{
if (empty($grd)) {
return false;
}
// 补全小包价的日程
$complete_grd = array();
$special_grd = array();
$normal_grd = array();
// object 在foreach中自身会被改变, 先转换成array
$grd = json_decode(json_encode($grd), true);
foreach ($grd as $kp => $vpag) {
$hotels_traffic = $this->ci->BIZ_order->get_package_order($vpag['GRD_COLD_SN']);
$vpag['GRD_Hotel'] = $hotels_traffic[0]->POI_Hotel;
$vpag['to_traffic'] = $hotels_traffic[0]->POI_Hotel;
$vpag['back_traffic'] = $hotels_traffic[0]->POI_Hotel;
// if (trim($hotels_traffic[0]->POI_HotelAddress) != "") {
// $vpag['GRD_Hotel'] .= "\r\n酒店地址:" . $hotels_traffic[0]->POI_HotelAddress;
// }
$vpag['hotel_checkin'] = trim($hotels_traffic[0]->POI_HotelCheckInName)!=="" ? "入住人:".$hotels_traffic[0]->POI_HotelCheckInName : "";
$vpag['hotel_checkin'] .= trim($hotels_traffic[0]->POI_HotelCheckIn)!=="" ? " 入住日期:".$hotels_traffic[0]->POI_HotelCheckIn : "";
if ($hotels_traffic[0]->POI_FlightsNo) {
$vpag['GRD_Traffic'] = $hotels_traffic[0]->POI_FlightsNo;
if ($hotels_traffic[0]->POI_FromCity || $hotels_traffic[0]->POI_ToCity) {
$vpag['GRD_Traffic'] .= ", (" . $hotels_traffic[0]->POI_FromCity . "-" . $hotels_traffic[0]->POI_ToCity . ")";
}
if ($hotels_traffic[0]->POI_Time || $hotels_traffic[0]->POI_EndTime) {
$vpag['GRD_Traffic'] .= ", " . $hotels_traffic[0]->POI_Time . " " . $hotels_traffic[0]->POI_EndTime;
}
if ($hotels_traffic[0]->POI_AirPort) {
$vpag['GRD_Traffic'] .= ", " . $hotels_traffic[0]->POI_AirPort;
}
}
if (isset($this->ci->trippest->special_route[$vpag['PAG_Code']])) {
$this_pag_total_day = $this->ci->trippest->special_route[$vpag['PAG_Code']]['day'];
$this_code = $vpag['PAG_Code'];
for($p=0; $p< $this_pag_total_day; $p++) {
$vpag['GRD_OrderDate'] = date("Y-m-d", strtotime("+$p day", strtotime($vpag['day_no_raw'])));
$vpag['day_no_raw'] = $vpag['GRD_OrderDate'];
$vpag['PAG_Code'] = $this->ci->trippest->special_route[$this_code]['code'][$p];
$pag_detail = $this->ci->BIZ_order->get_packageDetails("'" . $vpag['PAG_Code'] . "'", implode(",",$this->vendor_ids), false);
$vpag['PAG_Title'] = $pag_detail[0]->PAG2_Name;
$vpag['GRD_Landscape'] = $vpag['PAG_Title'];
$vpag['GRD_Meal_L'] = (in_array($pag_detail[0]->PAG_Meal, array('61002', '61004')) ? "1" : "");
$vpag['GRD_Meal_S'] = (in_array($pag_detail[0]->PAG_Meal, array('61003', '61004')) ? "1" : "");
$special_grd[] = $vpag;
}
} else {
$pag_detail = $this->ci->BIZ_order->get_packageDetails("'" . $vpag['PAG_Code'] . "'", implode(",",$this->vendor_ids), false);
$vpag['GRD_Meal_L'] = (in_array($pag_detail[0]->PAG_Meal, array('61002', '61004')) ? "1" : "");
$vpag['GRD_Meal_S'] = (in_array($pag_detail[0]->PAG_Meal, array('61003', '61004')) ? "1" : "");
// 接送的子订单行程
if (isset($vpag['PAG_sub_sn']) & & $vpag['PAG_sub_sn'] != 0) {
$sub_pag = $this->ci->BIZ_order->get_sub_pag_info($vpag['PAG_sub_sn']);
if (! empty($sub_pag)) {
$vpag['GRD_Landscape'] = "[" . $sub_pag->PAGS_CN_Title . "] " . $vpag['GRD_Landscape'];
if (strval($sub_pag->PAGS_Direction) === '0') {
$vpag['to_traffic'] = $vpag['GRD_Traffic'];
} else {
$vpag['back_traffic'] = $vpag['GRD_Traffic'];
}
}
}
$normal_grd[] = $vpag;
}
}
$complete_grd = array_merge($special_grd, $normal_grd);
$complete_grd = json_decode(json_encode($complete_grd));
$grd_apart_info = $this->tour_apart($complete_grd);
// echo json_encode($grd_apart_info);exit;
$request_info = $this->ci->Group_model->get_plan_request($vas->GRI_SN);
$big_order_index = 0;
$expect_order_cnt = count($grd_apart_info['com'])+intval(!empty($grd_apart_info['big_pvt']))+intval(!empty($grd_apart_info['pvt']));
foreach ($grd_apart_info as $group_key => $grd_part) {
$big_order_index = $this->tour_apart_order_exec($group_key, $vas, $request_info, null, $grd_part, $big_order_index);
}
if ($big_order_index === $expect_order_cnt) {
/** VendorArrangeState VAS_IsReceive */
$this->ci->Group_model->set_plan_received($vas->VAS_SN);
}
}
/*!
* 发送目的地项目组预订计划到图兰朵地接系统
*/
@ -430,7 +628,7 @@ log_message('error',$resp);
if ( ! in_array($cold->COLD_SN, $processed_cold) & & $cold->pag_code != '') {
$processed_cold[] = $cold->COLD_SN;
$all_package = $this->ci->trippest->tour_code($cold->pag_code);
$pag_info = $this->ci->BIZ_order->get_packageDetails(my_implode("'",",",$all_package));
$pag_info = $this->ci->BIZ_order->get_packageDetails(my_implode("'",",",$all_package), implode(",",$this->vendor_ids) );
if ($set_pvt==='1') {
$fill_order[0]["cold"][] = $cold;
} else {
@ -446,7 +644,7 @@ log_message('error',$resp);
$multi_package = $this->ci->trippest->tour_code($vcd->pag_code);
$pvt_pagcode = array_merge($pvt_pagcode, $multi_package);
}
$fill_order[0]["package_info"] = $this->ci->BIZ_order->get_packageDetails(my_implode("'",",",$pvt_pagcode));
$fill_order[0]["package_info"] = $this->ci->BIZ_order->get_packageDetails(my_implode("'",",",$pvt_pagcode), implode(",",$this->vendor_ids) );
}
// $fill_order = array_values($fill_order);
$i=0;
@ -471,12 +669,16 @@ log_message('error',$resp);
$extra_day = $this->ci->trippest->special_route[$vf["cold"][0]->pag_code]["day"]-1;
$end_date = date("Y-m-d", strtotime("+$extra_day day", strtotime($vf["cold"][0]->COLD_StartDate)));
}
$agcOrderNo = $vf["cold"][0]->COLI_GroupCode . "-" . $vf["package_info"][0]->city_code;
// $agcOrderNo = $vf["cold"][0]->COLI_GroupCode . "-" . $vf["package_info"][0]->city_code;
if ($take_apart===true) {
$agcOrderNo .= "-" . $i;
// $agcOrderNo .= "-" . $i;
$tour_code = mb_strtoupper($vf["cold"][0]->pag_code);
}
$agcOrderNo .= "(" . $vf["cold"][0]->operator . ")";
// $agcOrderNo .= "(" . $vf["cold"][0]->operator . ")";
$agcOrderNo = $vf["cold"][0]->COLI_GroupCode;
if (trim($vf["cold"][0]->COLI_PriceMemo) !== '') {
$agcOrderNo .= " (" . $vf["cold"][0]->COLI_PriceMemo . ")";
}
$order_remark = "";
if ($i===1) { // 只写一次备注.备注中可能包含代收信息,避免多次收取
$order_remark_arr = array_filter(array_map( function($element){return $element->COLD_vendorMemo;}, $vf["cold"] )) ;
@ -580,7 +782,7 @@ log_message('error',$resp);
$schedule_obj[$e_day]['date'] = $e_day;
$fill_date[] = $e_day;
$schedule_obj[$e_day]['code'] = $this->ci->trippest->special_route[$vs->PAG_Code]['code'][$j];
$pag_detail = $this->ci->BIZ_order->get_packageDetails("'" . $schedule_obj[$e_day]['code'] . "'");
$pag_detail = $this->ci->BIZ_order->get_packageDetails("'" . $schedule_obj[$e_day]['code'] . "'", implode(",",$this->vendor_ids) );
$schedule_obj[$e_day]['title'] = $pag_detail[0]->PAG2_Name;
$schedule_obj[$e_day]['lunch'] = (in_array($pag_detail[0]->PAG_Meal, array('61002', '61004')) ? 1 : 0);
$schedule_obj[$e_day]['dinner'] = (in_array($pag_detail[0]->PAG_Meal, array('61003', '61004')) ? 1 : 0);
@ -604,7 +806,7 @@ log_message('error',$resp);
$date_e = new DateTime(strstr($vs->COLD_EndDate, " ", TRUE));
$date_d = $date_e->diff($date_s);
$d_t = ($date_d->format("%a"));
if ($d_t > 0) {
if ($d_t > 0 & & empty($fill_date) ) {
for ($d_i=0; $d_i < ($d_t+1); $d_i++) {
$f_d = date('Y-m-d', strtotime("+$d_i day", strtotime(substr($vs->COLD_StartDate, 0, 10))));
$schedule_obj[$f_d] = $schedule_obj[substr($vs->COLD_StartDate, 0, 10)];
@ -700,7 +902,7 @@ log_message('error',$resp);
$this->ci->BIZ_order->insert_biz_order_log($coli_sn, "vendorPlanUpdateSendout_" . $tour_code);
}
/** VendorArrangeState VAS_IsReceive */
$this->ci->Group_model->set_plan_received($vas_sn);
$this->ci->Group_model->set_plan_received($vas_sn, $gri_sn );
}
}
return "[Tulanduo>push_trippest] Done. " . $COLI_ID;
@ -708,7 +910,7 @@ log_message('error',$resp);
public function tourguide_update($input, $vps, $eva)
{
return false; // for Trippest deploy
return false;
$ret['status'] = -1;
$ret['err'] = 100;
$ret['errMsg'] = "未知错误";
@ -782,7 +984,7 @@ log_message('error',$resp);
*/
public function order_change()
{
return false; // for Trippest deploy
return false;
$this->load->model('Order_update');
$ret['status'] = -1;
$ret['errMsg'] = "未知错误";