diff --git a/webht/third_party/vendorPlanSync/controllers/Tulanduo.php b/webht/third_party/vendorPlanSync/controllers/Tulanduo.php
index 92750fce..427937c9 100644
--- a/webht/third_party/vendorPlanSync/controllers/Tulanduo.php
+++ b/webht/third_party/vendorPlanSync/controllers/Tulanduo.php
@@ -3,6 +3,8 @@
if (!defined('BASEPATH'))
exit('No direct script access allowed');
+GLOBAL $__HAINA_VEI__;
+
class Tulanduo extends CI_Controller
{
/** Live */
@@ -56,6 +58,7 @@ class Tulanduo extends CI_Controller
parent::__construct();
mb_regex_encoding("UTF-8");
bcscale(4);
+ $GLOBALS['__HAINA_VEI__'] = 30561;
$this->load->helper('array');
$this->load->library('trippest');
$this->load->model('Group_model');
@@ -65,7 +68,7 @@ class Tulanduo extends CI_Controller
$this->load->model('TuLanDuo_addOrUpdateRouteOrderContentBuilder', 'tldOrderBuilder');
// $this->output->enable_profiler(TRUE);
- $this->vendor_ids = $this->trippest->tulanduo_vei_sn;
+ $this->vendor_ids = array(1343,30548,29188);
}
public function order_push($order=null)
@@ -243,6 +246,7 @@ class Tulanduo extends CI_Controller
*/
public function push_trippest($vas=null)
{
+log_message('error',__LINE__);
// return "[Tulanduo>push_trippest] Done. "; // test
/** 目的地 */
$userId = $this->send_host["30"]["userId"];
@@ -262,33 +266,63 @@ class Tulanduo extends CI_Controller
$orderinfo = $this->BIZ_order->get_orderinfo_detail($gri_sn, $vei_sn_str);
if(empty($orderinfo)) {return "[Tulanduo>push_trippest] Not found order detail. ";}
$COLI_ID = $orderinfo[0]->COLI_ID;
- $set_pvt = strval($orderinfo[0]->COLI_PVT);
- $travelFees = $this->BIZ_order->get_paymentDetails($COLI_ID);
+ $set_pvt = strval($orderinfo[0]->is_pvt);
+ // TODO 增加收款方参数, 增加代收款项
+log_message('error',__LINE__);
+ $vei_with_haina = $GLOBALS['__HAINA_VEI__'] . "," . $vei_sn_str;
+ $all_payment = $this->BIZ_order->get_paymentDetails($COLI_ID, $vei_with_haina);
+ $travel_fees = array();
+ $replace_collections = array();
+log_message('error',__LINE__);
+ foreach ($all_payment as $kall => $vall) {
+ if (in_array($vall->payment_vei, array($GLOBALS['__HAINA_VEI__'], 0)) ) {
+ $travel_fees[] = $vall;
+ } else {
+ $replace_collections[] = $vall;
+ }
+ }
+log_message('error',__LINE__);
// 按产品拆分 todo:按订单类型拆分? 单团/拼团
$fill_order = array();
$processed_date = array();
$processed_cold = array();
foreach ($orderinfo as $ko => $cold) {
+ // $cold->package_info = array();
if ( ! in_array($cold->COLD_SN, $processed_cold) && $cold->pag_code != '') {
$processed_cold[] = $cold->COLD_SN;
$all_package = $this->trippest->tour_code($cold->pag_code);
$pag_info = $this->BIZ_order->get_packageDetails(my_implode("'",",",$all_package));
if ($set_pvt==='1') {
+ // $cold->package_info[] = $cold->pag_code;
$fill_order[0]["cold"][] = $cold;
- $fill_order[0]["package_info"] = $pag_info; // todo ??? 这里是否丢失了产品
+ // $fill_order[0]["package_info"] = $pag_info; // todo ??? 这里是否丢失了产品
} else {
$fill_order[$cold->pag_code]["cold"][] = $cold;
$fill_order[$cold->pag_code]["package_info"] = $pag_info;
}
}
}
+ // 多产品PVT的合并
+ $pvt_pagcode = array();
+ if ($set_pvt==='1') {
+ foreach ($fill_order[0]['cold'] as $kcd => $vcd) {
+ $multi_package = $this->trippest->tour_code($vcd->pag_code);
+ $pvt_pagcode = array_merge($pvt_pagcode, $multi_package);
+ }
+ $fill_order[0]["package_info"] = $this->BIZ_order->get_packageDetails(my_implode("'",",",$pvt_pagcode));
+ }
// $fill_order = array_values($fill_order);
$i=0;
$take_apart = count($fill_order)>1 ? true : false;
foreach ($fill_order as $kf => $vf) {
$i++;
$this->tldOrderBuilder->resetBizContent();
- $order_type = intval($vf["package_info"][0]->PAG_ExtendType)===39009 ? 1 : 2;
+ $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 = intval($vf["package_info"][0]->PAG_ExtendType)===39009 ? 1 : 2;
+ }
$last_code = count($vf["package_info"])-1;
$last_date = count($vf["cold"])-1;
$tour_code = "";
@@ -306,10 +340,8 @@ class Tulanduo extends CI_Controller
$tour_code = mb_strtoupper($vf["cold"][0]->pag_code);
}
$agcOrderNo .= "(" . $vf["cold"][0]->operator . ")";
- $order_remark = "";
- if (trim($vf['cold'][0]->GUT_TEL) != "") {
- $order_remark = "预定人电话:" . trim($vf["cold"][0]->GUT_TEL);
- }
+ $order_remark = ""; // todo
+
$COLD_SN_str = implode(',', array_map( function($element){return $element->COLD_SN;}, $vf["cold"] )) ;
$guestlist = $this->BIZ_order->get_guestlist($COLD_SN_str);
$this->tldOrderBuilder->setUserId($userId)
@@ -329,12 +361,23 @@ class Tulanduo extends CI_Controller
// ->setToTraffic($toTraffic)
// ->setBackTraffic($backTraffic)
;
+ // 客人列表
foreach ($guestlist as $key => $vg) {
+ $this_otherinfo = "";
$this->tldOrderBuilder->setCustomersName($key, $vg->BPE_FirstName . " " . $vg->BPE_LastName )
->setCustomersPeopleType($key, ($vg->BPE_GuestType==1 ? "成人" : "儿童"))
->setCustomersDocumentType($key, "护照") // Passport No.
->setCustomersDocumentNo($key, $vg->BPE_Passport)
- ->setCustomersOtherInfo($key, $this->BIZ_order->GetNationalityName($vg->BPE_Nationality));
+ // ->setCustomersOtherInfo($key, $this->BIZ_order->GetNationalityName($vg->BPE_Nationality))
+ ;
+ $this_otherinfo .= $this->BIZ_order->GetNationalityName($vg->BPE_Nationality);
+ if (trim($vf['cold'][0]->GUT_TEL) != "" && $key===0) {
+ // $order_remark = "预定人电话:" . trim($vf["cold"][0]->GUT_TEL);
+ $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->tldOrderBuilder->setCustomersOtherInfo($key, $this_otherinfo);
+ }
}
$scheduleDetails = $this->BIZ_order->get_scheduleDetails($COLD_SN_str);
$schedule_obj = array();
@@ -363,6 +406,8 @@ class Tulanduo extends CI_Controller
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 ($hotels[0]->POI_FlightsNo) {
$this_content .= "\r\n航/车次:" . $hotels[0]->POI_FlightsNo;
if ($hotels[0]->POI_FromCity || $hotels[0]->POI_ToCity) {
@@ -457,7 +502,7 @@ class Tulanduo extends CI_Controller
}
// 拆分的订单团款录第一个
if ($i===1) {
- foreach ($travelFees as $kf => $vf) {
+ foreach ($travel_fees as $kf => $vf) {
$this->tldOrderBuilder->setTravelFeesType($kf, "Per Group")
->setTravelFeesMoney($kf, $vf->GAI_SSJE)
->setTravelFeesNum($kf, 1)
@@ -465,32 +510,21 @@ class Tulanduo extends CI_Controller
->setTravelFeesSumMoney($kf, $vf->GAI_SSJE)
->setTravelFeesRemark($kf, $vf->GAI_Memo);
}
+ foreach ($replace_collections as $krc => $vrc) {
+ $this->tldOrderBuilder->setReplaceCollectionsType($krc, "Per Group")
+ ->setReplaceCollectionsMoney($krc, $vrc->GAI_SSJE)
+ ->setReplaceCollectionsRemark($krc, $vrc->GAI_Memo);
+ }
}
- // 查询是否变更
+ // 查询是否变更 TODO deprecated
$sync_orderstate = 10;
$vps_sn = 0;
$vendor_orderid = 0;
- $plan_detail_page_url = "http://p.mycht.cn/Cooperate/Plan_Detail.aspx?GSN=" . $gri_sn;
- $plan_detail_page = "
计划下载:$plan_detail_page_url
";
- if (intval($is_send_vary)===1) {
- $vps = $this->Group_model->get_sync_info($vas_sn, $tour_code);
- if ( ! empty($vps)) {
- $vps_sn = $vps->VPS_SN;
- $vendor_orderid = $vps->VPS_externalId;
- $sync_orderstate = 11;
- $modifyLogInfo = "$plan_detail_page
$change_info
";
- $this->tldOrderBuilder->setOrderId($vendor_orderid)
- ->setModifyLogInfo($modifyLogInfo)
- ;
- }
- } else {
- $modifyLogInfo = $plan_detail_page;
- $this->tldOrderBuilder->clearModifyLogInfo();
- $this->tldOrderBuilder->setModifyLogInfo($modifyLogInfo)
- ;
- }
+ $this->tldOrderBuilder->clearModifyLogInfo();
$resp = $this->excute_curl($this->neworder_url, $this->tldOrderBuilder);
// $resp = '{"status":1,"errMsg":"","responseData":{"orderId":' . rand(1000,9999) . '}}'; // test
+echo $this->tldOrderBuilder->getBizContent();
+log_message('error',$resp);
$response = json_decode($resp);
if ($response->status == 1) {
/** VendorPlanSync */
@@ -516,7 +550,7 @@ class Tulanduo extends CI_Controller
$this->Group_model->set_plan_received($vas_sn);
}
}
- return "[Tulanduo>push_trippest] Done. ";
+ return "[Tulanduo>push_trippest] Done. " . $COLI_ID;
}
public function tourguide_update($input, $vps, $eva)
diff --git a/webht/third_party/vendorPlanSync/controllers/index.php b/webht/third_party/vendorPlanSync/controllers/index.php
index 95f4d734..243df62d 100644
--- a/webht/third_party/vendorPlanSync/controllers/index.php
+++ b/webht/third_party/vendorPlanSync/controllers/index.php
@@ -21,10 +21,10 @@ class Index extends CI_Controller {
* * 使用供应商平台登陆账号获取接口的key
*/
- public function index()
+ public function index($GRI_SN=0)
{
$auto_vendor_str = implode(",", $this->vendor->auto_vendor);
- return $this->push(0, $auto_vendor_str);
+ return $this->push($GRI_SN, $auto_vendor_str);
}
public function push($GRI_SN=0, $vendor_str=null)
@@ -32,6 +32,7 @@ class Index extends CI_Controller {
$start_date = date('Y-m-d');
$end_date = date('Y-m-d 23:59:59', strtotime("+2 months"));
$ready_to_send = $this->Group_model->get_plan_not_received(1, $GRI_SN, $vendor_str, $start_date, $end_date);
+log_message('error',var_export($ready_to_send, 1));
if (empty($ready_to_send)) {
return $this->output->set_output("empty");
}
@@ -41,8 +42,8 @@ class Index extends CI_Controller {
require_once($controller_name . ".php");
$vendor_class = new $controller_name();
$call_fun = $vendor_class->order_push($order);
- log_message('error',"Call [$controller_name>order_push] " . $order->GRI_SN);
- return $this->output->set_output($call_fun . $order->GRI_SN);
+ log_message('error',"Call [$controller_name>order_push] " . $order->GRI_SN . ". " . $call_fun);
+ return $this->output->set_output($call_fun . ". " . $order->GRI_SN);
}
return $this->output->set_output("Not found vendor function. " . $order->GRI_SN);
}
diff --git a/webht/third_party/vendorPlanSync/libraries/trippest.php b/webht/third_party/vendorPlanSync/libraries/trippest.php
index dfc48fe6..ebba5748 100644
--- a/webht/third_party/vendorPlanSync/libraries/trippest.php
+++ b/webht/third_party/vendorPlanSync/libraries/trippest.php
@@ -10,8 +10,6 @@ class Trippest
$this->ci =& get_instance();
}
- public $tulanduo_vei_sn = array(1343,30548,29188);
-
public function tour_name($pag_code)
{
$name = "";
diff --git a/webht/third_party/vendorPlanSync/models/BIZ_orders_model.php b/webht/third_party/vendorPlanSync/models/BIZ_orders_model.php
index bef796ca..9e3cf896 100644
--- a/webht/third_party/vendorPlanSync/models/BIZ_orders_model.php
+++ b/webht/third_party/vendorPlanSync/models/BIZ_orders_model.php
@@ -41,6 +41,7 @@ class BIZ_Orders_model extends CI_Model {
cold.COLD_ServiceSN2,
cold.COLD_ServiceCity,
gut.GUT_NationalityID,
+ isnull(COLI_PVT, 0) is_pvt,
(select opi2_name from tourmanager.dbo.operatorinfo2 where opi2_opi_sn=coli_opi_id and opi2_lgc=2) as operator,
*
FROM BIZ_ConfirmLineInfo coli
@@ -102,18 +103,32 @@ class BIZ_Orders_model extends CI_Model {
$sql = "SELECT *
from BIZ_PackageOrderInfo poi
where poi.POI_COLD_SN IN ($COLD_SN_str)";
+log_message('error',$sql);
return $this->HT->query($sql)->result();
}
- public function get_paymentDetails($COLI_ID)
+ /*!
+ * [get_paymentDetails description]
+ * @date 2019-05-22
+ * VEI:
+ * * 30561 桂林海纳国旅
+ * GAI_Type
+ * * 15006 地接代收
+ * * 15008 现付
+ * * 15017 内部转账
+ * * 15020 地接社代收
+ */
+ public function get_paymentDetails($COLI_ID, $vei_sn_str)
{
- $sql = "SELECT *
+ $sql = "SELECT ISNULL(bgai.GAI_VEI_SN,0) payment_vei
+ ,*
FROM BIZ_GroupAccountInfo bgai
INNER JOIN BIZ_ConfirmLineInfo coli ON bgai.GAI_COLI_SN=coli.COLI_SN
- WHERE bgai.DeleteFlag=0 AND bgai.GAI_Type NOT IN (15006,15008,15017)
- AND ISNULL(bgai.GAI_VEI_SN,0)<>1343
+ WHERE bgai.DeleteFlag=0 --AND bgai.GAI_Type NOT IN (15006,15008,15017)
+ AND ISNULL(bgai.GAI_VEI_SN,0) in (0,$vei_sn_str)
AND bgai.GAI_SQJE > 0
AND coli_ID = '$COLI_ID'";
+log_message('error',$sql);
$query = $this->HT->query($sql);
return $query->result();
}
diff --git a/webht/third_party/vendorPlanSync/models/Group_model.php b/webht/third_party/vendorPlanSync/models/Group_model.php
index e17b8b5e..18ed0239 100644
--- a/webht/third_party/vendorPlanSync/models/Group_model.php
+++ b/webht/third_party/vendorPlanSync/models/Group_model.php
@@ -24,14 +24,16 @@ class Group_model extends CI_Model {
$sql .= $gri_sn!==0 ? $gri_sql : "
and VAS_IsCancel=0 and VAS_Delete=0 and vas.DeleteFlag=0
and VAS_IsSendSucceed=1
- and VAS_IsConfirm=0
+ -- and VAS_IsConfirm=0
and EOI_GetDate between '$start_date' and '$end_date'
and VAS_VEI_SN in ($vendor_str)
- and GRI_operator in (161,443,61) -- 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";
-// log_message('error',$sql);
+ and GRI_operator in (161,443,61) -- 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_SendTime asc, vas.VAS_IsConfirm asc";
+log_message('error',$sql);
return $this->HT->query($sql)->result();
}
@@ -229,6 +231,8 @@ class Group_model extends CI_Model {
public function set_plan_received($vas_sn=0)
{
$sql = "UPDATE VendorArrangeState set VAS_IsReceive=1,VAS_ReceiveTime=GETDATE() where VAS_SN=? ";
+log_message('error',$sql);
+ return $sql; // testing
return $this->HT->query($sql, array($vas_sn));
}
@@ -256,6 +260,9 @@ class Group_model extends CI_Model {
public function insert_VendorPlanSync($sync_arr=array())
{
+ $ss = $this->HT->insert_string('VendorPlanSendout', $sync_arr); // testing
+log_message('error',$ss);
+ return $ss;
$this->HT->insert('VendorPlanSendout', $sync_arr);
return $this->HT->query("SELECT MAX(VPS_SN) VPS_SN from VendorPlanSendout")
->row()->VPS_SN;
@@ -265,6 +272,8 @@ class Group_model extends CI_Model {
{
$where = " VPS_SN=" . $vps;
$update_sql = $this->HT->update_string('VendorPlanSendout', $sync_arr, $where);
+log_message('error',$update_sql);
+ return $update_sql; // testing
return $this->HT->query($update_sql);
}