@ -44,7 +44,6 @@ class TulanduoApi extends CI_Controller
// public $neworder_url = "http://djb3c.ltsoftware.net:9921/action/api/addOrUpdateRouteOrder/";
// 发送到图兰朵系统接口的参数jsonParams
// public $params;
public function __construct(){
parent::__construct();
@ -54,7 +53,6 @@ class TulanduoApi extends CI_Controller
// $this->output->enable_profiler(TRUE);
// $this->params = new stdClass();
/** test */
// $this->userId = "358";
// $this->key = "a08f26ddc5b1bd4c8e5eafcac28fc1ec";
@ -65,6 +63,7 @@ class TulanduoApi extends CI_Controller
// 桂林海纳国旅
// $this->userId = "18";
// $this->key = "d05c25e6e6c5d4898161e0aaf700d9c7";
mb_regex_encoding("UTF-8");
}
public function get_orderlist()
@ -73,8 +72,8 @@ class TulanduoApi extends CI_Controller
->setKey($this->key)
->setPageSize(20)
->setPageIndex(1)
->setStartTravelDate("2018-04-20 ") // test
->setEndTravelDate("2018-04-20 ")
->setStartTravelDate("2018-04-21 ") // test
->setEndTravelDate("2018-04-21 ")
// ->setStartOrderDate("2018-04-13")
// ->setEndOrderDate("2018-04-13")
;
@ -111,7 +110,12 @@ class TulanduoApi extends CI_Controller
$cnt = 0;
$pag_no_tmp = $this->pag_no_tmp();
mb_regex_encoding("UTF-8");
$unique_order = array();
foreach ($all_list as $k => $vo) {
if (in_array($vo['orderId'], $unique_order)) {
continue;
}
$unique_order[] = $vo['orderId'];
$vo['agcOrderNo'] = mb_ereg_replace('(\s| )', '', $vo['agcOrderNo']); // 去掉中文的全角空格
$PAG_Code = $pag_sub = null;
preg_match('^[a-zA-Z]+\-[0-9\-]+^', $this->characet($vo['routeName'], "UTF-8"), $temp_array);
@ -181,7 +185,7 @@ log_message('error','new coli ' . $this->Orders_model->BIZ_COLI_ID);
$this->Orders_model->COLD_EndDate = $vo['leaveDate'];
$this->Orders_model->COLD_PersonNum = $vo['adultNum'];
$this->Orders_model->COLD_ChildNum = $vo['childNum'];
$this->Orders_model->cold_state = $vo['orderStatus']==1 ? 7 : 4; // 7已确认(已收款) // 4 下计划未确认(已收款)
$this->Orders_model->cold_state = $vo['orderStatus']==1 ? 7 : 4; // 7已确认 // 4 下计划未确认
$this->Orders_model->DeleteFlag = 0;
$this->Orders_model->COLD_PlanVEI_SN = empty($this->city_info[$vo['operationDep']]) ? 1343 : $this->city_info[$vo['operationDep']]['PlanVEI_SN'];
$this->Orders_model->COLD_MemoText = $COLD_MemoText;
@ -213,18 +217,25 @@ log_message('error','new coli ' . $this->Orders_model->BIZ_COLI_ID);
return;
}
public function update _HT_order_operation($coli_sn=null)
public function insert _HT_order_operation($coli_sn=null)
{
$this->load->model('Order_update');
if ($coli_sn !== null) {
$to_update_list = $this->Orders_model->get_groupCombineInfo($coli_sn);
} else {
$startDate = date('Y-m-d');
$endDate = date('Y-m-d', strtotime("+1 days")); // test
$startDate = ('2018-04-21');
$endDate = ('2018-04-22'); // test
// $startDate = date('Y-m-d');
// $endDate = date('Y-m-d', strtotime("+4 days"));
$to_update_list = $this->Orders_model->get_groupCombineInfo(0, $startDate, $endDate);
}
$unique_orderGroupCombine = array();
$unique_order = array();
foreach ($to_update_list as $key => $order) {
if (in_array($order->GCI_VendorOrderId, $unique_order)) {
continue;
}
$unique_order[] = $order->GCI_VendorOrderId;
$this->tld_order->setOrderId($order->GCI_VendorOrderId)
->setUserId($this->userId)
->setKey($this->key);
@ -234,22 +245,33 @@ log_message('error','new coli ' . $this->Orders_model->BIZ_COLI_ID);
log_message('error','TulanduoApi get_orderdetail failed. Msg:' . $detail_jsonResp->errMsg . "; Request: " . $this->tld_order->getBizContent());
return;
}
// $allDetails_to_HT = "";
// $allDetails_to_HT .= "日程: ";
// foreach ($detail_jsonResp->orderDetail->scheduleDetails as $vsd) {
// $allDetails_to_HT .= $vsd->travelDate .": ". $vsd->title . "; ";
// }
// $allDetails_to_HT .= "导游: ";
// foreach ($detail_jsonResp->orderDetail->operationDetails->guiderOperations as $vg) {
// $allDetails_to_HT .= $vg->name ." (". $vg->mobelPhone . "); ";
// }
$allDetails_to_HT = "";
$allDetails_to_HT .= "\r\n日程: ";
foreach ($detail_jsonResp->orderDetail->scheduleDetails as $vsd) {
$allDetails_to_HT .= $vsd->travelDate .": ". $vsd->title . "; ";
}
if (isset($detail_jsonResp->orderDetail->operationDetails->guiderOperations) ) {
$allDetails_to_HT .= "\r\n导游: ";
foreach ($detail_jsonResp->orderDetail->operationDetails->guiderOperations as $vg) {
$allDetails_to_HT .= $vg->name ." (". $vg->mobelPhone . "); ";
}
}
if (isset($detail_jsonResp->orderDetail->operationDetails->touristCarOperations) ) {
$allDetails_to_HT .= "\r\n用车: ";
foreach ($detail_jsonResp->orderDetail->operationDetails->touristCarOperations as $vtc) {
$allDetails_to_HT .= $vtc->name .": " . $vtc->driver." (". $vtc->driverTel . ") ";
$allDetails_to_HT .= "[". $vtc->remark . "]; ";
}
}
/** HT 开始 */
/** UPDATE */
/** BIZ_ConfirmLineInfo */
$this->Order_update->coli_where_update = " COLI_SN=" . $order->GCI_COLI_SN;
$this->Order_update->coli_where_update = " COLI_SN=" . $order->COLI_SN;
$old_memo = mb_strstr($order->COLI_Memo, "orderRemark", true) ? mb_strstr($order->COLI_Memo, "orderRemark", true) : $order->COLI_Memo;
$old_detail = mb_strstr($order->COLI_OrderDetailText, "operations", true) ? mb_strstr($order->COLI_OrderDetailText, "operations", true) : $order->COLI_OrderDetailText;
$coli_update_column = array(
"COLI_Memo" => $order->COLI_Memo . "\r\n" . $detail_jsonResp->orderDetail->orderRemark . "\r\n"
// ,"COLI_OrderDetailText" => $order->COLI_OrderDetailText . "\r\n" . $allDetails_to_HT . "\r\n"
"COLI_Memo" => $old_memo . "orderRemark \r\n" . $detail_jsonResp->orderDetail->orderRemark . "\r\n"
,"COLI_OrderDetailText" => $old_detail . "operations \r\n" . $allDetails_to_HT . "\r\n"
);
$this->Order_update->biz_confirmlineinfo_update($coli_update_column);
/** BIZ_ConfirmLineDetail */ // nothing to update
@ -282,12 +304,73 @@ log_message('error','new coli ' . $this->Orders_model->BIZ_COLI_ID);
$this->Orders_model->POI_EndTime = $detail_jsonResp->orderDetail->leaveDate;
$this->Orders_model->POI_QuotationType = 1; // 1 报价 2 网络支付价 3 促销价
$this->Orders_model->biz_packageorder_save();
/** BIZ_GroupAccountInfo */
// 团款, 只有其他社的订单, 目的地项目组的团款已经直接收入海纳账户
$paytype = 15006; // 地接代收
$pay_currency = 'RMB';
// 删除旧的录入
$this->Orders_model->biz_groupaccountinfo_cut($order->COLI_SN, $paytype);
if (isset($detail_jsonResp->orderDetail->travelFees) & & $order->GCI_FromAgc != "D目的地桂林组") {
foreach ($detail_jsonResp->orderDetail->travelFees as $ktf => $vtf) {
if ($vtf->reviewStatus == 0) { // 未审核的
continue;
}
$this->Orders_model->GAI_COLI_SN = $order->COLI_SN;
$this->Orders_model->GAI_GRI_SN = $order->COLI_GRI_SN;
$this->Orders_model->GAI_COLI_ID = $order->COLI_ID;
$this->Orders_model->GAI_Type = $paytype;
$this->Orders_model->GAI_SQJE = $vtf->sumMoney;
$this->Orders_model->GAI_SQJECurrency = $pay_currency;
$this->Orders_model->GAI_Memo = $vtf->type . ", " . $vtf->remark;
$this->Orders_model->biz_groupaccountinfo_save();
}
}
// 代收
if (isset($detail_jsonResp->orderDetail->replaceCollections)) {
foreach ($detail_jsonResp->orderDetail->replaceCollections as $krc => $vrc) {
if ($vrc->reviewStatus == 0) {
continue;
}
$this->Orders_model->GAI_COLI_SN = $order->COLI_SN;
$this->Orders_model->GAI_GRI_SN = $order->COLI_GRI_SN;
$this->Orders_model->GAI_COLI_ID = $order->COLI_ID;
$this->Orders_model->GAI_Type = $paytype;
$this->Orders_model->GAI_SQJE = $vrc->money;
$this->Orders_model->GAI_SQJECurrency = $pay_currency;
$this->Orders_model->GAI_Memo = $vrc->type . ", " . $vrc->remark;
$this->Orders_model->biz_groupaccountinfo_save();
}
}
// 代付
if (isset($detail_jsonResp->orderDetail->replacePays)) {
foreach ($detail_jsonResp->orderDetail->replacePays as $krp => $vrp) {
if ($vrp->reviewStatus == 0) {
continue;
}
$this->Orders_model->GAI_COLI_SN = $order->COLI_SN;
$this->Orders_model->GAI_GRI_SN = $order->COLI_GRI_SN;
$this->Orders_model->GAI_COLI_ID = $order->COLI_ID;
$this->Orders_model->GAI_Type = $paytype;
$this->Orders_model->GAI_SQJE = "-" . $vrp->money;
$this->Orders_model->GAI_SQJECurrency = $pay_currency;
$this->Orders_model->GAI_Memo = $vrp->type . ", " . $vrp->remark;
$this->Orders_model->biz_groupaccountinfo_save();
}
}
/*BIZ_GroupCombineOperationDetail*/
if ( ! isset($detail_jsonResp->orderDetail->groupOrderNo)) {
continue;
}
if (in_array($detail_jsonResp->orderDetail->groupOrderNo, $unique_orderGroupCombine)) {
continue;
}
$unique_orderGroupCombine[] = $detail_jsonResp->orderDetail->groupOrderNo;
// 删除旧的录入
$this->Orders_model->biz_groupcombineoperationdetail_cut($detail_jsonResp->orderDetail->groupOrderNo);
// 门票
if (isset($detail_jsonResp->orderDetail->operationDetails->sceneryOperations) & &
($this->Orders_model->combineoperation_exist($detail_jsonResp->orderDetail->groupOrderNo, "sceneryOperations")) === array() ) {
if (isset($detail_jsonResp->orderDetail->operationDetails->sceneryOperations)) {
foreach ($detail_jsonResp->orderDetail->operationDetails->sceneryOperations as $ks => $vso) {
$this->Orders_model->GCOD_GCI_combineNo = isset($detail_jsonResp->orderDetail->groupOrderNo) ? $detail_jsonResp->orderDetail->groupOrderNo : "";
$this->Orders_model->GCOD_GCI_combineNo = $detail_jsonResp->orderDetail->groupOrderNo;
$this->Orders_model->GCOD_operationType = "sceneryOperations";
$this->Orders_model->GCOD_subType = $vso->type;
$this->Orders_model->GCOD_title = $vso->name;
@ -306,10 +389,9 @@ log_message('error','new coli ' . $this->Orders_model->BIZ_COLI_ID);
}
// 用房 ...
// 用餐
if (isset($detail_jsonResp->orderDetail->operationDetails->restraurantOperations) & &
($this->Orders_model->combineoperation_exist($detail_jsonResp->orderDetail->groupOrderNo, "restraurantOperations")) === array() ) {
if (isset($detail_jsonResp->orderDetail->operationDetails->restraurantOperations) ) {
foreach ($detail_jsonResp->orderDetail->operationDetails->restraurantOperations as $vro) {
$this->Orders_model->GCOD_GCI_combineNo = isset($detail_jsonResp->orderDetail->groupOrderNo) ? $detail_jsonResp->orderDetail->groupOrderNo : "" ;
$this->Orders_model->GCOD_GCI_combineNo = $detail_jsonResp->orderDetail->groupOrderNo ;
$this->Orders_model->GCOD_operationType = "restraurantOperations";
$this->Orders_model->GCOD_subType = $vro->type;
$this->Orders_model->GCOD_title = $vro->name;
@ -327,10 +409,9 @@ log_message('error','new coli ' . $this->Orders_model->BIZ_COLI_ID);
}
}
// 用车
if (isset($detail_jsonResp->orderDetail->operationDetails->touristCarOperations) & &
($this->Orders_model->combineoperation_exist($detail_jsonResp->orderDetail->groupOrderNo, "touristCarOperations")) === array() ) {
if (isset($detail_jsonResp->orderDetail->operationDetails->touristCarOperations)) {
foreach ($detail_jsonResp->orderDetail->operationDetails->touristCarOperations as $vco) {
$this->Orders_model->GCOD_GCI_combineNo = isset($detail_jsonResp->orderDetail->groupOrderNo) ? $detail_jsonResp->orderDetail->groupOrderNo : "" ;
$this->Orders_model->GCOD_GCI_combineNo = $detail_jsonResp->orderDetail->groupOrderNo ;
$this->Orders_model->GCOD_operationType = "touristCarOperations";
$this->Orders_model->GCOD_subType = $vco->type;
$this->Orders_model->GCOD_title = $vco->name;
@ -348,10 +429,9 @@ log_message('error','new coli ' . $this->Orders_model->BIZ_COLI_ID);
}
}
// 导游服务
if (isset($detail_jsonResp->orderDetail->operationDetails->guiderOperations) & &
($this->Orders_model->combineoperation_exist($detail_jsonResp->orderDetail->groupOrderNo, "guiderOperations")) === array() ) {
if (isset($detail_jsonResp->orderDetail->operationDetails->guiderOperations) ) {
foreach ($detail_jsonResp->orderDetail->operationDetails->guiderOperations as $vgo) {
$this->Orders_model->GCOD_GCI_combineNo = isset($detail_jsonResp->orderDetail->groupOrderNo) ? $detail_jsonResp->orderDetail->groupOrderNo : "" ;
$this->Orders_model->GCOD_GCI_combineNo = $detail_jsonResp->orderDetail->groupOrderNo ;
$this->Orders_model->GCOD_operationType = "guiderOperations";
$this->Orders_model->GCOD_subType = "";
$this->Orders_model->GCOD_title = "";