|
|
|
@ -54,6 +54,9 @@ class Tulanduo
|
|
|
|
|
public $detail_url = "http://djb3c.ltsoftware.net:9921/action/api/detailRouteOrder/";
|
|
|
|
|
public $neworder_url = "http://djb3c.ltsoftware.net:9921/action/api/addOrUpdateRouteOrder/";
|
|
|
|
|
|
|
|
|
|
private $tulanduo_trippest_pag = array();
|
|
|
|
|
private $tulanduo_trippest_code = array();
|
|
|
|
|
|
|
|
|
|
public function __construct(){
|
|
|
|
|
$this->ci =& get_instance();
|
|
|
|
|
mb_regex_encoding("UTF-8");
|
|
|
|
@ -72,6 +75,11 @@ class Tulanduo
|
|
|
|
|
|
|
|
|
|
public function order_push($order=null)
|
|
|
|
|
{
|
|
|
|
|
// 初始化所有Trippest合作项目的包价产品
|
|
|
|
|
$this->tulanduo_trippest_pag = $this->ci->BIZ_order->get_packageDetails('', implode(',', $this->vendor_ids));
|
|
|
|
|
$this->tulanduo_trippest_code = array_map(function($ele){return mb_strtoupper($ele->PAG_Code);}, $this->tulanduo_trippest_pag);
|
|
|
|
|
$this->tulanduo_trippest_pag = array_combine($this->tulanduo_trippest_code, $this->tulanduo_trippest_pag);
|
|
|
|
|
|
|
|
|
|
// 目的地计划
|
|
|
|
|
if (strval($order->GRI_OrderType) === "227002" && strval($order->department) === "30") {
|
|
|
|
|
return $this->push_trippest($order);
|
|
|
|
@ -79,12 +87,12 @@ class Tulanduo
|
|
|
|
|
// 商务
|
|
|
|
|
if (strval($order->GRI_OrderType) === "227002") {
|
|
|
|
|
return false; // for Trippest deploy
|
|
|
|
|
return $this->push_tour($order);
|
|
|
|
|
return $this->push_biz($order, strval($order->GRI_OrderType));
|
|
|
|
|
}
|
|
|
|
|
// 传统订单
|
|
|
|
|
if (strval($order->GRI_OrderType) === "227001") {
|
|
|
|
|
return false; // for Trippest deploy
|
|
|
|
|
return $this->push_tour($order);
|
|
|
|
|
return $this->push_tour($order, strval($order->GRI_OrderType));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return "[Tulanduo>order_push] No function match. ";
|
|
|
|
@ -92,147 +100,283 @@ class Tulanduo
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* 发送线路订单计划
|
|
|
|
|
* @date 2018-11-22
|
|
|
|
|
*/
|
|
|
|
|
public function push_tour($vas=null)
|
|
|
|
|
public function push_tour($vas=null, $gri_ordertype='227001')
|
|
|
|
|
{
|
|
|
|
|
return false; // for Trippest deploy
|
|
|
|
|
$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;
|
|
|
|
|
$is_send_vary = $vas->VAS_SendVary;
|
|
|
|
|
$change_info = $vas->VAS_ChangeText;
|
|
|
|
|
if (trim($change_info) !== "") {
|
|
|
|
|
preg_match_all('/(.*)={6}(.*)(\d{4}\-\d{2}\-\d{2})/ismU', characet($change_info,'UTF-8'), $change_arr);
|
|
|
|
|
$change_info = $change_arr[0][0];
|
|
|
|
|
}
|
|
|
|
|
$change_info = str_replace("\n", "<br>", $change_info);
|
|
|
|
|
$grd_info = $this->ci->Group_model->get_vendor_plan_info($gri_sn, $vei_sn);
|
|
|
|
|
if (empty($grd_info)) {
|
|
|
|
|
$this->ci->Group_model->set_plan_received($vas_sn);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
$all_day_no = array_map(function($ele){return $ele->GRD_DayNo;}, $grd_info);
|
|
|
|
|
$arrange_info = $this->ci->Group_model->get_arrange_info($gri_sn, $vei_sn);
|
|
|
|
|
$routeName = "中华游" . $arrange_info[0]->tocity . "线路"; // TODO 线路名称
|
|
|
|
|
$routeType = "桂林海纳国旅"; // TODO 线路类型
|
|
|
|
|
$agcOrderNo = $vas->GRI_Name . "-" . $arrange_info[0]->citycode;
|
|
|
|
|
$agcOrderNo .= "(" . $vas->operator . ")";
|
|
|
|
|
$first_date = $grd_info[0]->day_no_raw;
|
|
|
|
|
$last_date = count($grd_info)-1;
|
|
|
|
|
$end_date = $grd_info[$last_date]->day_no_raw;
|
|
|
|
|
$request_info = $this->ci->Group_model->get_plan_request($gri_sn);
|
|
|
|
|
$order_type = 1;
|
|
|
|
|
$this->ci->tldOrderBuilder->setUserId($userId)
|
|
|
|
|
->setKey($userKey)
|
|
|
|
|
->setOrderType($order_type)
|
|
|
|
|
->setRouteName($routeName)
|
|
|
|
|
->setRouteType($routeType)
|
|
|
|
|
->setAgcOrderNo($agcOrderNo)
|
|
|
|
|
->setAdultNum(intval($arrange_info[0]->ACI_PersonNum))
|
|
|
|
|
->setChildNum(intval(bcadd($arrange_info[0]->ACI_ChildNum, $arrange_info[0]->ACI_BabyNum)))
|
|
|
|
|
->setDestination($arrange_info[0]->tocity)
|
|
|
|
|
->setTravelDate($first_date)
|
|
|
|
|
->setLeavedDate($end_date)
|
|
|
|
|
// ->setOrderRemark($order_remark) // 订单备注 TODO
|
|
|
|
|
->setRoomStandard($request_info->GCI_HotelRequest) // 住房标准
|
|
|
|
|
->setRouteStandard($request_info->GCI_Request) // 行程服务标准
|
|
|
|
|
;
|
|
|
|
|
$guestlist = $this->ci->orders_model->get_customer_list($gri_sn);
|
|
|
|
|
foreach ($guestlist as $key => $vg) {
|
|
|
|
|
$this->ci->tldOrderBuilder->setCustomersName($key, $vg->MemberName )
|
|
|
|
|
->setCustomersPeopleType($key, (calc_age_type($vg->BirthDay)==1 ? "成人" : "儿童"))
|
|
|
|
|
->setCustomersDocumentType($key, "护照") // Passport No.
|
|
|
|
|
->setCustomersDocumentNo($key, $vg->PassportNo)
|
|
|
|
|
->setCustomersOtherInfo($key, $vg->Country);
|
|
|
|
|
$request_info = $this->ci->Group_model->get_plan_request($vas->GRI_SN);
|
|
|
|
|
/**
|
|
|
|
|
* TODO:团队类型? 先写2
|
|
|
|
|
* ??是否同一天含多个包价项目
|
|
|
|
|
*/
|
|
|
|
|
/*!
|
|
|
|
|
// 同一天含多个包价产品时, 需要先合并.避免丢失
|
|
|
|
|
$all_trippest_package = array_filter(array_map(function ($ele){return $ele->pag_code_arr;}, $grd_info));
|
|
|
|
|
$reduce_package_code = array();
|
|
|
|
|
foreach ($all_trippest_package as $ktp => $vtp) {
|
|
|
|
|
$reduce_package_code = array_merge($reduce_package_code, $vtp);
|
|
|
|
|
}
|
|
|
|
|
// $travel_fee = 0;
|
|
|
|
|
// foreach ($arrange_info as $kaci => $vaci) {
|
|
|
|
|
// $travel_fee = bcadd($travel_fee, $vaci->ACI_Amount);
|
|
|
|
|
// }
|
|
|
|
|
// // TODO 是否需要travelFee
|
|
|
|
|
// $this->ci->tldOrderBuilder->setTravelFeesType(0, "Per Group")
|
|
|
|
|
// ->setTravelFeesMoney(0, $travel_fee)
|
|
|
|
|
// ->setTravelFeesNum(0, 1)
|
|
|
|
|
// ->setTravelFeesUnit(0, 1)
|
|
|
|
|
// ->setTravelFeesSumMoney(0, $travel_fee)
|
|
|
|
|
// ->setTravelFeesRemark(0, "");
|
|
|
|
|
// 补全空的日期,行程为空
|
|
|
|
|
$date1 = new DateTime($first_date);
|
|
|
|
|
$date_end = new DateTime($end_date);
|
|
|
|
|
$date_diff = $date_end->diff($date1);
|
|
|
|
|
$d = ($date_diff->format("%a"));
|
|
|
|
|
$all_date = array();
|
|
|
|
|
for ($j=0; $j < ($d+1); $j++) {
|
|
|
|
|
$all_date[] = date('Y-m-d', strtotime("+$j day", strtotime($first_date)));
|
|
|
|
|
$reduce_package_code = array_filter($reduce_package_code);
|
|
|
|
|
*/
|
|
|
|
|
$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);
|
|
|
|
|
}
|
|
|
|
|
$real_date = array_map(function ($ele){return $ele->day_no_raw;}, $grd_info);
|
|
|
|
|
foreach ($all_date as $kd => $vd) {
|
|
|
|
|
if ( ! in_array($vd, $real_date)) {
|
|
|
|
|
$this->ci->tldOrderBuilder->setScheduleDetailsTitle($kd, "无")
|
|
|
|
|
->setScheduleDetailsContent($kd, "无")
|
|
|
|
|
->setScheduleDetailsAccommodation($kd, "")
|
|
|
|
|
// ->setScheduleDetailsTraffic($kd, ($vso->PAG_Vehicle>60001 ? 1 : 0))
|
|
|
|
|
->setScheduleDetailsBreakFirst($kd, 0 )
|
|
|
|
|
->setScheduleDetailsDinner($kd, 0)
|
|
|
|
|
->setScheduleDetailsLunch($kd, 0)
|
|
|
|
|
;
|
|
|
|
|
continue;
|
|
|
|
|
if ($big_order_index === $expect_order_cnt) {
|
|
|
|
|
/** VendorArrangeState VAS_IsReceive */
|
|
|
|
|
$this->ci->Group_model->set_plan_received($vas_sn);
|
|
|
|
|
}
|
|
|
|
|
return "[Tulanduo>push_tour] Done. ";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* @Author: LYT
|
|
|
|
|
* @Date: 2019-05-30 16:11:34
|
|
|
|
|
* @Desc: 执行发送订单计划信息. 参数已拆分归类好的行程
|
|
|
|
|
*/
|
|
|
|
|
public function tour_apart_order_exec($group_type, $vas, $request_info, $guestlist, $grd, $total_order_index)
|
|
|
|
|
{
|
|
|
|
|
if (empty($grd)) {
|
|
|
|
|
return $total_order_index;
|
|
|
|
|
}
|
|
|
|
|
$userId = $this->send_host["1"]["userId"];
|
|
|
|
|
$userKey = $this->send_host["1"]["key"];
|
|
|
|
|
switch ($group_type) {
|
|
|
|
|
case 'big_pvt':
|
|
|
|
|
$total_order_index ++;
|
|
|
|
|
$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 . ")";
|
|
|
|
|
$order_type = 1;
|
|
|
|
|
break;
|
|
|
|
|
case 'pvt':
|
|
|
|
|
$total_order_index ++;
|
|
|
|
|
$all_grd = array($grd);
|
|
|
|
|
$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 . ")";
|
|
|
|
|
$order_type = 1;
|
|
|
|
|
break;
|
|
|
|
|
case 'com':
|
|
|
|
|
default:
|
|
|
|
|
$all_grd = ($grd);
|
|
|
|
|
$order_type = 2;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
foreach ($all_grd as $ko => $vo) {
|
|
|
|
|
if ($order_type === 2) {
|
|
|
|
|
$total_order_index ++;
|
|
|
|
|
$routeName = $vo['PAG_Name'];
|
|
|
|
|
if (empty($routeName)) {
|
|
|
|
|
$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 . ")";
|
|
|
|
|
}
|
|
|
|
|
foreach ($grd_info as $kgrd => $vgrd) {
|
|
|
|
|
if ($vd==$vgrd->day_no_raw) {
|
|
|
|
|
$this->ci->tldOrderBuilder->setScheduleDetailsTitle($kd, $vgrd->GRD_OrderDate)
|
|
|
|
|
->setScheduleDetailsContent($kd, $vgrd->GRD_Landscape)
|
|
|
|
|
->setScheduleDetailsAccommodation($kd, $vgrd->GRD_Hotel)
|
|
|
|
|
->setScheduleDetailsTraffic($kd, ($vgrd->GRD_Traffic))
|
|
|
|
|
->setScheduleDetailsBreakFirst($kd, 0 )
|
|
|
|
|
->setScheduleDetailsDinner($kd, (trim($vgrd->GRD_Meal_S)==="" ? 0 : 1 ))
|
|
|
|
|
->setScheduleDetailsLunch($kd, (trim($vgrd->GRD_Meal_L)==="" ? 0 : 1 ))
|
|
|
|
|
;
|
|
|
|
|
$first_date = $vo['details'][0]->day_no_raw;
|
|
|
|
|
$last_date = COUNT($vo['details'])-1;
|
|
|
|
|
$end_date = $vo['details'][$last_date]->day_no_raw;
|
|
|
|
|
$this->ci->tldOrderBuilder->resetBizContent();
|
|
|
|
|
$this->ci->tldOrderBuilder->setUserId($userId)
|
|
|
|
|
->setKey($userKey)
|
|
|
|
|
->setOrderType($order_type)
|
|
|
|
|
->setRouteName($routeName)
|
|
|
|
|
->setRouteType($routeType)
|
|
|
|
|
->setAgcOrderNo($agcOrderNo)
|
|
|
|
|
->setAdultNum(intval($vo['details'][0]->ACI_PersonNum))
|
|
|
|
|
->setChildNum(intval(bcadd($vo['details'][0]->ACI_ChildNum, $vo['details'][0]->ACI_BabyNum)))
|
|
|
|
|
->setDestination($vo['details'][0]->tocity)
|
|
|
|
|
->setTravelDate($first_date)
|
|
|
|
|
->setLeavedDate($end_date)
|
|
|
|
|
// ->setOrderRemark($order_remark) // 订单备注 TODO:
|
|
|
|
|
// ->setRoomStandard($request_info->GCI_HotelRequest) // 住房标准
|
|
|
|
|
->setRouteStandard($request_info->GCI_Request) // 行程服务标准
|
|
|
|
|
;
|
|
|
|
|
foreach ($guestlist as $key => $vg) {
|
|
|
|
|
$this->ci->tldOrderBuilder->setCustomersName($key, $vg->MemberName )
|
|
|
|
|
->setCustomersPeopleType($key, (calc_age_type($vg->BirthDay)==1 ? "成人" : "儿童"))
|
|
|
|
|
->setCustomersDocumentType($key, "护照") // Passport No.
|
|
|
|
|
->setCustomersDocumentNo($key, $vg->PassportNo)
|
|
|
|
|
->setCustomersOtherInfo($key, $vg->Country . "; " . $vg->phone);
|
|
|
|
|
}
|
|
|
|
|
// 补全空的日期,行程为空
|
|
|
|
|
$date1 = new DateTime($first_date);
|
|
|
|
|
$date_end = new DateTime($end_date);
|
|
|
|
|
$date_diff = $date_end->diff($date1);
|
|
|
|
|
$d = ($date_diff->format("%a"));
|
|
|
|
|
$all_date = array();
|
|
|
|
|
for ($j=0; $j < ($d+1); $j++) {
|
|
|
|
|
$all_date[] = date('Y-m-d', strtotime("+$j day", strtotime($first_date)));
|
|
|
|
|
}
|
|
|
|
|
$real_date = array_map(function ($ele){return $ele->day_no_raw;}, $vo['details']);
|
|
|
|
|
foreach ($all_date as $kd => $vd) {
|
|
|
|
|
if ( ! in_array($vd, $real_date)) {
|
|
|
|
|
$this->ci->tldOrderBuilder->setScheduleDetailsTitle($kd, "无")
|
|
|
|
|
->setScheduleDetailsContent($kd, "无")
|
|
|
|
|
->setScheduleDetailsAccommodation($kd, "")
|
|
|
|
|
// ->setScheduleDetailsTraffic($kd, ($vso->PAG_Vehicle>60001 ? 1 : 0))
|
|
|
|
|
->setScheduleDetailsBreakFirst($kd, 0 )
|
|
|
|
|
->setScheduleDetailsDinner($kd, 0)
|
|
|
|
|
->setScheduleDetailsLunch($kd, 0)
|
|
|
|
|
;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
foreach ($vo['details'] as $kgrd => $vgrd) {
|
|
|
|
|
if ($vd==$vgrd->day_no_raw) {
|
|
|
|
|
$this->ci->tldOrderBuilder->setScheduleDetailsTitle($kd, $vgrd->GRD_OrderDate)
|
|
|
|
|
->setScheduleDetailsContent($kd,
|
|
|
|
|
$vgrd->GRD_LeaveCity . "-" . $vgrd->GRD_ServiceCity . "\r\n" .
|
|
|
|
|
$vgrd->GRD_Landscape . "\r\n" . $vgrd->GRD_Traffic)
|
|
|
|
|
->setScheduleDetailsAccommodation($kd, $vgrd->GRD_Hotel)
|
|
|
|
|
->setScheduleDetailsTraffic($kd, ($vgrd->GRD_Traffic))
|
|
|
|
|
->setScheduleDetailsBreakFirst($kd, 0 )
|
|
|
|
|
->setScheduleDetailsDinner($kd, (trim($vgrd->GRD_Meal_S)==="" ? 0 : 1 ))
|
|
|
|
|
->setScheduleDetailsLunch($kd, (trim($vgrd->GRD_Meal_L)==="" ? 0 : 1 ))
|
|
|
|
|
;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 查询是否变更 TODO deprecated
|
|
|
|
|
$sync_orderstate = 10;
|
|
|
|
|
$vps_sn = 0;
|
|
|
|
|
$vendor_orderid = 0;
|
|
|
|
|
$this->ci->tldOrderBuilder->clearModifyLogInfo();
|
|
|
|
|
// $resp = $this->excute_curl($this->neworder_url, $this->ci->tldOrderBuilder);
|
|
|
|
|
$resp = '{"status":1,"errMsg":"","responseData":{"orderId":' . rand(1000,9999) . '}}'; // test
|
|
|
|
|
// 查询是否变更 TODO: 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 */
|
|
|
|
|
$sync_ret = array(
|
|
|
|
|
"VPS_VAS_SN" => $vas_sn
|
|
|
|
|
,"VPS_GRI_SN" => $gri_sn
|
|
|
|
|
,"VPS_VEI_SN" => $vei_sn
|
|
|
|
|
,"VPS_startDate" => $first_date
|
|
|
|
|
,"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) {
|
|
|
|
|
$response = json_decode($resp);
|
|
|
|
|
if ($response->status == 1) {
|
|
|
|
|
/** VendorPlanSync */
|
|
|
|
|
$sync_ret = array(
|
|
|
|
|
"VPS_VAS_SN" => $vas->VAS_SN
|
|
|
|
|
,"VPS_GRI_SN" => $vas->GRI_SN
|
|
|
|
|
,"VPS_VEI_SN" => $vas->VAS_VEI_SN
|
|
|
|
|
,"VPS_startDate" => $first_date
|
|
|
|
|
,"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')
|
|
|
|
|
);
|
|
|
|
|
$sync_id = $this->ci->Group_model->insert_VendorPlanSync($sync_ret);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return $total_order_index;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* @Author: LYT
|
|
|
|
|
* @Date: 2019-05-29 14:54:17
|
|
|
|
|
* @Desc: 线路订单计划拆分.
|
|
|
|
|
* 合并同样的行程
|
|
|
|
|
* 根据行程类型拆分
|
|
|
|
|
* @return $ret = array(
|
|
|
|
|
* 'big_pvt'=>array(), // 不是合作项目的产品
|
|
|
|
|
* 'pvt'=>array(), // 合作项目中的pvt
|
|
|
|
|
* 'com'=>array( // 合作项目中的拼团
|
|
|
|
|
* 'details' => [],'PAG_Code'=> 'XXX'
|
|
|
|
|
* )
|
|
|
|
|
* )
|
|
|
|
|
*/
|
|
|
|
|
public function tour_apart($all_pag_info)
|
|
|
|
|
{
|
|
|
|
|
$apart = array(); $ret = array();
|
|
|
|
|
foreach ($all_pag_info as $key => $pag) {
|
|
|
|
|
// 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));
|
|
|
|
|
$pag->PAG_ExtendType = $this->tulanduo_trippest_pag[$pag->PAG_Code]->PAG_ExtendType;
|
|
|
|
|
}
|
|
|
|
|
if (empty($pag->PAG_Code)) // 已在grd查询中增加是否目的地产品的判断
|
|
|
|
|
{
|
|
|
|
|
$apart['big_pvt']['details'][] = $pag;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (empty($pag->PAG_Title) ) {
|
|
|
|
|
$pag->PAG_Title = $this->tulanduo_trippest_pag[$pag->PAG_Code]->PAG_Title;
|
|
|
|
|
}
|
|
|
|
|
// 合作的产品
|
|
|
|
|
if ($this->ci->trippest->if_tour_pvt(array($pag))===1) {
|
|
|
|
|
$apart["pvt"]['details'][] = $pag;
|
|
|
|
|
} else {
|
|
|
|
|
$update = $this->ci->Group_model->update_VendorPlanSync($vps_sn, $sync_ret);
|
|
|
|
|
$apart["com"]['details'][$pag->PAG_Code][] = $pag;
|
|
|
|
|
}
|
|
|
|
|
/** VendorArrangeState VAS_IsReceive */
|
|
|
|
|
}
|
|
|
|
|
$apart_com = array();
|
|
|
|
|
if ( ! empty($apart['com'])) {
|
|
|
|
|
$all_com_pag = array_keys($apart['com']['details']);
|
|
|
|
|
$full_pag = array();
|
|
|
|
|
$process_pag = array();
|
|
|
|
|
foreach ($all_com_pag as $kp => $vp) {
|
|
|
|
|
$apart_com[$vp]['details'] = array();
|
|
|
|
|
$this_include_pags = $this->ci->trippest->tour_code($vp);
|
|
|
|
|
if( isset($this->ci->trippest->special_route[$vp]) ) {
|
|
|
|
|
$full_pag = array_diff($this_include_pags, array_merge($full_pag,$process_pag));
|
|
|
|
|
foreach ($this_include_pags as $vi) {
|
|
|
|
|
if ($vi !== $vp) {
|
|
|
|
|
unset($apart_com[$vi]);
|
|
|
|
|
}
|
|
|
|
|
// $apart_com[$vp]['details'][] = $apart['com']['details'][$vi];
|
|
|
|
|
$apart_com[$vp]['details'] = array_merge($apart_com[$vp]['details'], $apart['com']['details'][$vi]);
|
|
|
|
|
$apart_com[$vp]['PAG_Code'] = $vp;
|
|
|
|
|
$apart_com[$vp]['PAG_Name'] = $this->ci->trippest->special_route[$vp]['name'];
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$full_pag = array_merge($full_pag, $this_include_pags);
|
|
|
|
|
// $apart_com[$vp]['details'][] = $apart['com']['details'][$vp];
|
|
|
|
|
$apart_com[$vp]['details'] = array_merge($apart_com[$vp]['details'], $apart['com']['details'][$vp]);
|
|
|
|
|
$apart_com[$vp]['PAG_Code'] = $vp;
|
|
|
|
|
$apart_com[$vp]['PAG_Name'] = "";
|
|
|
|
|
}
|
|
|
|
|
$process_pag[] = $vp;
|
|
|
|
|
$this_include_pags = array();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$ret['big_pvt'] = empty($apart['big_pvt']) ? null : $apart['big_pvt'];
|
|
|
|
|
$ret['pvt'] = empty($apart['pvt']['details']) ? null : ($apart['pvt']);
|
|
|
|
|
$ret['com'] = array_values($apart_com);
|
|
|
|
|
return $ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* @Author: LYT
|
|
|
|
|
* @Date: 2019-06-04 11:47:38
|
|
|
|
|
* @Desc: 发送商务订单计划
|
|
|
|
|
*/
|
|
|
|
|
public function push_biz($vas=null, $gri_ordertype='227002')
|
|
|
|
|
{
|
|
|
|
|
$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);
|
|
|
|
|
if (empty($grd_info)) {
|
|
|
|
|
$this->ci->Group_model->set_plan_received($vas_sn);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
// return $this->ci->tldOrderBuilder->getBizContent() . "[Tulanduo>push_tour] Done. ";
|
|
|
|
|
return "[Tulanduo>push_tour] Done. ";
|
|
|
|
|
$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);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* 发送目的地项目组预订计划到图兰朵地接系统
|
|
|
|
|
* 地接社未接收的或有变更的
|
|
|
|
|
* @date 2018-10-26
|
|
|
|
|
*/
|
|
|
|
|
public function push_trippest($vas=null)
|
|
|
|
|
{
|
|
|
|
@ -243,13 +387,6 @@ log_message('error',$resp);
|
|
|
|
|
$gri_sn = $vas->GRI_SN;
|
|
|
|
|
$vas_sn = $vas->VAS_SN;
|
|
|
|
|
$vei_sn = $vas->VAS_VEI_SN;
|
|
|
|
|
$is_send_vary = $vas->VAS_SendVary;
|
|
|
|
|
$change_info = $vas->VAS_ChangeText;
|
|
|
|
|
if (trim($change_info) !== "") {
|
|
|
|
|
preg_match_all('/(.*)={6}(.*)(\d{4}\-\d{2}\-\d{2})/ismU', characet($change_info,'UTF-8'), $change_arr);
|
|
|
|
|
$change_info = $change_arr[0][0];
|
|
|
|
|
}
|
|
|
|
|
$change_info = str_replace("\n", "<br>", $change_info);
|
|
|
|
|
$vei_sn_str = implode(",", $this->vendor_ids);
|
|
|
|
|
$orderinfo = $this->ci->BIZ_order->get_orderinfo_detail($gri_sn, $vei_sn_str);
|
|
|
|
|
if(empty($orderinfo)) {return "[Tulanduo>push_trippest] Not found order detail. ";}
|
|
|
|
@ -321,8 +458,7 @@ log_message('error',$resp);
|
|
|
|
|
$this->ci->tldOrderBuilder->resetBizContent();
|
|
|
|
|
$order_type = $set_pvt;
|
|
|
|
|
if ($set_pvt==='0') {
|
|
|
|
|
$code_type_arr = array_map(function($pag) { return intval($pag->PAG_ExtendType); }, $vf["package_info"]);
|
|
|
|
|
$order_type = in_array(39009, $code_type_arr) ? 1 : 2;
|
|
|
|
|
$order_type = $this->ci->trippest->if_tour_pvt($vf["package_info"]);
|
|
|
|
|
}
|
|
|
|
|
$last_code = count($vf["package_info"])-1;
|
|
|
|
|
$last_date = count($vf["cold"])-1;
|
|
|
|
@ -361,7 +497,7 @@ log_message('error',$resp);
|
|
|
|
|
->setTravelDate(strstr($vf["cold"][0]->COLD_StartDate, " ", true))
|
|
|
|
|
->setLeavedDate($end_date)
|
|
|
|
|
->setOrderRemark($order_remark)
|
|
|
|
|
// todo 抵离交通
|
|
|
|
|
// todo: 抵离交通
|
|
|
|
|
// ->setToTraffic($toTraffic)
|
|
|
|
|
// ->setBackTraffic($backTraffic)
|
|
|
|
|
;
|
|
|
|
@ -408,8 +544,17 @@ log_message('error',$resp);
|
|
|
|
|
if (trim($hotels[0]->POI_HotelAddress) != "") {
|
|
|
|
|
$this_content .= "\r\n酒店地址:" . $hotels[0]->POI_HotelAddress;
|
|
|
|
|
}
|
|
|
|
|
$this_content .= trim($hotels[0]->POI_HotelCheckInName)!=="" ? "\r\n入住人:".$hotels[0]->POI_HotelCheckInName : "";
|
|
|
|
|
$this_content .= trim($hotels[0]->POI_HotelCheckIn)!=="" ? "\r\n入住日期:".$hotels[0]->POI_HotelCheckIn : "";
|
|
|
|
|
if (trim($hotels[0]->POI_Hotel) != '') {
|
|
|
|
|
$this->ci->tldOrderBuilder->setToTraffic($hotels[0]->POI_Hotel);
|
|
|
|
|
$this->ci->tldOrderBuilder->setBackTraffic($hotels[0]->POI_Hotel);
|
|
|
|
|
}
|
|
|
|
|
$checkin_name = trim($hotels[0]->POI_HotelCheckInName)!=="" ? "\r\n入住人:".$hotels[0]->POI_HotelCheckInName : "";
|
|
|
|
|
$checkin_date = trim($hotels[0]->POI_HotelCheckIn)!=="" ? "\r\n入住日期:".$hotels[0]->POI_HotelCheckIn : "";
|
|
|
|
|
$this_content .= $checkin_name;
|
|
|
|
|
$this_content .= $checkin_date;
|
|
|
|
|
if ($checkin_name!=='' || $checkin_date!=='') {
|
|
|
|
|
$this->ci->tldOrderBuilder->setRoomStandard(trim($checkin_name) . ", " . trim($checkin_date));
|
|
|
|
|
}
|
|
|
|
|
if ($hotels[0]->POI_FlightsNo) {
|
|
|
|
|
$this_content .= "\r\n航/车次:" . $hotels[0]->POI_FlightsNo;
|
|
|
|
|
if ($hotels[0]->POI_FromCity || $hotels[0]->POI_ToCity) {
|
|
|
|
@ -458,7 +603,7 @@ log_message('error',$resp);
|
|
|
|
|
$date_s = new DateTime(strstr($vs->COLD_StartDate, " ", TRUE));
|
|
|
|
|
$date_e = new DateTime(strstr($vs->COLD_EndDate, " ", TRUE));
|
|
|
|
|
$date_d = $date_e->diff($date_s);
|
|
|
|
|
$d_t = ($date_d->format("%d"));
|
|
|
|
|
$d_t = ($date_d->format("%a"));
|
|
|
|
|
if ($d_t > 0) {
|
|
|
|
|
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))));
|
|
|
|
@ -504,20 +649,28 @@ log_message('error',$resp);
|
|
|
|
|
}
|
|
|
|
|
// 拆分的订单团款录第一个
|
|
|
|
|
if ($i===1) {
|
|
|
|
|
$fee_index=0;
|
|
|
|
|
if ( ! empty($travel_fees) ) {
|
|
|
|
|
$this->ci->tldOrderBuilder->setTravelFeesType(0, "Per Group")
|
|
|
|
|
->setTravelFeesMoney(0, $travel_fees->SUM_SSJE)
|
|
|
|
|
->setTravelFeesNum(0, 1)
|
|
|
|
|
->setTravelFeesUnit(0, 1)
|
|
|
|
|
->setTravelFeesSumMoney(0, $travel_fees->SUM_SSJE);
|
|
|
|
|
$this->ci->tldOrderBuilder->setTravelFeesType($fee_index, "Per Group")
|
|
|
|
|
->setTravelFeesMoney($fee_index, $travel_fees->SUM_SSJE)
|
|
|
|
|
->setTravelFeesNum($fee_index, 1)
|
|
|
|
|
->setTravelFeesUnit($fee_index, 1)
|
|
|
|
|
->setTravelFeesSumMoney($fee_index, $travel_fees->SUM_SSJE);
|
|
|
|
|
++$fee_index;
|
|
|
|
|
}
|
|
|
|
|
if ( ! empty($replace_collections) ) {
|
|
|
|
|
$this->ci->tldOrderBuilder->setReplaceCollectionsType(0, "Per Group")
|
|
|
|
|
->setReplaceCollectionsMoney(0, $replace_collections->SUM_SSJE)
|
|
|
|
|
->setReplaceCollectionsRemark(0, $replace_collections->ALL_Memo);
|
|
|
|
|
$this->ci->tldOrderBuilder->setTravelFeesType($fee_index, "Per Group")
|
|
|
|
|
->setTravelFeesMoney($fee_index, $replace_collections->SUM_SSJE)
|
|
|
|
|
->setTravelFeesNum($fee_index, 1)
|
|
|
|
|
->setTravelFeesUnit($fee_index, 1)
|
|
|
|
|
->setTravelFeesSumMoney($fee_index, $replace_collections->SUM_SSJE)
|
|
|
|
|
->setTravelFeesRemark($fee_index, "代收; " . $replace_collections->ALL_Memo);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 查询是否变更 TODO deprecated
|
|
|
|
|
// 查询是否变更 TODO: deprecated
|
|
|
|
|
$sync_orderstate = 10;
|
|
|
|
|
$vps_sn = 0;
|
|
|
|
|
$vendor_orderid = 0;
|
|
|
|
@ -571,7 +724,7 @@ log_message('error',$resp);
|
|
|
|
|
->setUserId($userId)
|
|
|
|
|
->setKey($userKey);
|
|
|
|
|
$detail_resp = $this->excute_curl($this->detail_url, $this->tld_order);
|
|
|
|
|
// $detail_resp = '{"status":1,"errMsg":"","orderDetail":{"orderId":' . rand(1000,9999) . ',"operationDetails": {"guiderOperations":[{"name":"北京翟梦琪Susie","mobelPhone":"18801326155","startDate":"2017-04-25","endDate":"2017-04-25","sumMoney":400,"remark":"","guiderPhoto":"http://djb3c.ltsoftware.net:9921/projects/djb3c//uploadImages/guider/1526898234415.png"}]}}}'; // test
|
|
|
|
|
// $detail_resp = '{"status":1,"errMsg":"","orderDetail":{"orderId":' . rand(1000,9999) . ',"operationDetails": {"guiderOperations":[{"name":"北京翟梦琪Susie","mobelPhone":"18801326155","startDate":"2017-04-25","endDate":"2017-04-25","sumMoney":400,"remark":"","guiderPhoto":"http://djb3c.ltsoftware.net:9921/projects/djb3c//uploadImages/guider/1526898234415.png"}]}}}'; // test:
|
|
|
|
|
$detail_jsonResp = json_decode($detail_resp);
|
|
|
|
|
// 判断
|
|
|
|
|
if ($detail_jsonResp->status !== 1) {
|
|
|
|
@ -640,7 +793,7 @@ log_message('error',$resp);
|
|
|
|
|
$ret['errMsg'] = "身份验证失败.";
|
|
|
|
|
return $this->output->set_content_type('application/json')->set_output(json_encode($ret));
|
|
|
|
|
}
|
|
|
|
|
// $vendorID = 29188;//29188 1343; // test
|
|
|
|
|
// $vendorID = 29188;//29188 1343; // test:
|
|
|
|
|
$vas_info = array();
|
|
|
|
|
if (in_array($input['agcName'], array("D目的地桂林组", "Trippest"))) {
|
|
|
|
|
$vas_info = $this->BIZ_order->get_vendorarrangestate_byVendor($input['orderId'], $vendorID);
|
|
|
|
@ -693,7 +846,6 @@ log_message('error',$resp);
|
|
|
|
|
return $this->output->set_content_type('application/json')->set_output(json_encode($ret));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private function excute_curl($url, $content_builder)
|
|
|
|
|
{
|
|
|
|
|
$ch = curl_init();
|
|
|
|
|