diff --git a/webht/third_party/vendorPlanSync/controllers/Tulanduo.php b/webht/third_party/vendorPlanSync/controllers/Tulanduo.php index ca706f63..dafb11ad 100644 --- a/webht/third_party/vendorPlanSync/controllers/Tulanduo.php +++ b/webht/third_party/vendorPlanSync/controllers/Tulanduo.php @@ -78,19 +78,70 @@ class Tulanduo extends CI_Controller } // 传统订单 if (strval($order->GRI_OrderType) === "227001") { + return $this->push_tour($order); } return "[Tulanduo>order_push] No function match. "; } + /*! + * 发送线路订单计划 + * @date 2018-11-22 + */ + public function push_tour($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; + $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", "
", $change_info); + $agcOrderNo = $vas->GRI_Name; + // $grd_info = $this->Group_model->get_vendor_plan_info($gri_sn, $vei_sn); + // $all_day_no = array_map(function($ele){return $ele->GRD_DayNo;}, $grd_info); + $routeType = "桂林海纳国旅"; // todo + $arrange_info = $this->Group_model->get_arrange_info($gri_sn, $vei_sn); + $routeName = "中华游" . $arrange_info[0]->tocity . "常规线路"; // todo + $last_date = count($arrange_info)-1; + $end_date = strstr($arrange_info[$last_date]->ACI_OrderDate, " ", true); + $this->tldOrderBuilder->setUserId($userId) + ->setKey($userKey) + ->setOrderType(1) + ->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(strstr($arrange_info[0]->ACI_OrderDate, " ", true)) + ->setLeavedDate($end_date) + // ->setOrderRemark($order_remark) + ; + $guestlist = $this->Group_model->get_customer_list($gri_sn); // todo orders_model + foreach ($guestlist as $key => $vg) { + $this->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); + } + return $this->tldOrderBuilder->getBizContent(); + } + /*! * 发送目的地项目组预订计划到图兰朵地接系统 * 地接社未接收的或有变更的 - * @date 2018-05-02 + * @date 2018-10-26 */ public function push_trippest($vas=null) { - return "[Tulanduo>push_trippest] Done. "; + return "[Tulanduo>push_trippest] Done. "; // test /** 目的地 */ $userId = $this->send_host["30"]["userId"]; $userKey = $this->send_host["30"]["key"]; diff --git a/webht/third_party/vendorPlanSync/helpers/array_helper.php b/webht/third_party/vendorPlanSync/helpers/array_helper.php index 3d265013..1fb1f504 100644 --- a/webht/third_party/vendorPlanSync/helpers/array_helper.php +++ b/webht/third_party/vendorPlanSync/helpers/array_helper.php @@ -166,3 +166,20 @@ function real_phone_number($phone, $nation_code) return mb_ereg_replace('[\D]', '', $cut_nation); } +function calc_age($birthday) +{ + $now = new DateTime(); + $birth = new DateTime(strstr($birthday, " ", TRUE)); + $date_d = $now->diff($birth); + $d_t = ($date_d->format("%y")); + return $d_t; +} + +function calc_age_type($birthday) +{ + $age = calc_age($birthday); + if ($age > 17) { + return 1; + } + return 2; +} diff --git a/webht/third_party/vendorPlanSync/models/Group_model.php b/webht/third_party/vendorPlanSync/models/Group_model.php index e7aa68c1..5b480627 100644 --- a/webht/third_party/vendorPlanSync/models/Group_model.php +++ b/webht/third_party/vendorPlanSync/models/Group_model.php @@ -13,7 +13,7 @@ class Group_model extends CI_Model { $top_sql = $top>0 ? " TOP $top " : ""; $gri_sql = $gri_sn===0 ? "" : " and GRI_SN=$gri_sn "; $sql = "SELECT $top_sql VAS_IsConfirm, VAS_SendVary, - GRI_OrderType, GRI_SN, GRI_No, GRI_operator, + GRI_OrderType, GRI_SN, GRI_No, GRI_operator,GRI_Name, (select OPI_DEI_SN from OperatorInfo where OPI_SN=GRI_operator) as department, vas.* from VendorArrangeState vas @@ -26,7 +26,7 @@ class Group_model extends CI_Model { and VAS_IsConfirm=0 and EOI_GetDate between '$start_date' and '$end_date' -- and VAS_VEI_SN in (29188, 1343, 30548) -- test - and GRI_OrderType=227002 -- test + -- and GRI_OrderType=227002 -- test and (VAS_IsReceive=0 or (VAS_SendTime > ISNULL(VAS_ReceiveTime,0))) "; $sql .= " order by EOI_GetDate asc, vas.VAS_IsConfirm asc"; return $this->HT->query($sql)->result(); @@ -54,6 +54,54 @@ class Group_model extends CI_Model { return $this->HT->query($sql)->result(); } + public function get_arrange_info($gri_sn, $vendor_id) + { + $param_arr = array($gri_sn, $vendor_id); + $sql = "SELECT + (select CII2_Name from CItyInfo2 + where CII2_CII_SN=ACI_FromCity and CII2_LGC=2) as fromcity, + (select CII2_Name from CItyInfo2 + where CII2_CII_SN=ACI_ToCity and CII2_LGC=2) as tocity, + * + from ArrangeConfirmInfo aci + where 1=1 + and aci.ACI_GRI_SN=? + and aci.ACI_VEI_SN=? + order by ACI_DayNo,ACI_SNInOneDay "; + return $this->HT->query($sql, $param_arr)->result(); + } + + public function get_customer_list($gri_sn) + { + $sql = "SELECT ( + SELECT (isnull(MEI_LastName,'') +' / '+ isnull(MEI_FirstName,'')) CustomerName + from MemberInfo + where MEI_SN=CUL_CUI_SN + ) as MemberName, + (select MEI_BirthDay from MemberInfo where MEI_SN=CUL_CUI_SN) as BirthDay, + ISNULL((select SYC2_CodeDiscribe + from V_System_Code + where LGC_LGC=2 + and SYC_SN=( + select top 1 MEI_Gender from MemberInfo + where MEI_SN=CUL_CUI_SN)),'' + ) Gender, + (select COI2_Country from V_Country_Info + where LGC_LGC = 2 + and COI_SN in (select MEI_Country from MemberInfo where MEI_SN=CUL_CUI_SN) + ) as Country, + (select MEI_PassportNo from MemberInfo where MEI_SN=CUL_CUI_SN) PassportNo, + (select MEI_PassportValidDate from MemberInfo where MEI_SN=CUL_CUI_SN) PassportValidDate + -- ,(select dbo.GetSysCodeName(MEI_Occupation,2) from MemberInfo where MEI_SN=CUL_CUI_SN) as Occupation + from CustomerList + where isnull(CUL_IsAgent,0)=0 + and isnull(CUL_IsEmergency,0)=0 + and isnull(CUL_IsTJR,0)=0 + and CUL_COLI_SN in (select COLI_SN from ConfirmLineInfo where COLI_GRI_SN=?) + order by CUL_Order"; + return $this->HT->query($sql, array($gri_sn))->result(); + } + public function get_sync_info($vas, $tour_code="") { $sql = "SELECT *