Merge branch 'trippest' into plan-auto-send

feature/pay
lyt 7 years ago
commit d1f38a6163

@ -134,7 +134,7 @@ class TulanduoApi extends CI_Controller
$unique_order[] = $vo['orderId'];
// paypal 手续费订单没有团号
$vo['agcOrderNo'] = (isset($vo['agcOrderNo'])&&$vo['agcOrderNo']!="") ? $vo['agcOrderNo'] : $vo['groupOrderNo'];
$vo['agcOrderNo'] = trim_groupCode(trim($vo['agcOrderNo'])); // 去掉中文的全角空格
$vo['agcOrderNo'] = (trim($vo['agcOrderNo'])); // 去掉中文的全角空格
$this->Orders_model->BIZ_COLI_SN = null;
$this->Orders_model->GRI_SN = null;
@ -143,9 +143,14 @@ class TulanduoApi extends CI_Controller
// set GCI_SN
$this->Orders_model->get_SN_by_vendorOrderId($vo['orderId'], $tmpv); // 查询订单是否已经录入过
if ($this->Orders_model->BIZ_COLI_SN === null) {
$real_groupCode = analysis_groupCode($vo['agcOrderNo']);
$real_groupCode_info = analysis_groupCode($vo['agcOrderNo']);
$real_groupCode = $real_groupCode_info["cut"];
// set BIZ_COLI_SN, GRI_SN at Orders_model
$this->Orders_model->get_SN_by_groupCode($real_groupCode, $vo['orderId']);
$group_info = $this->Orders_model->get_SN_by_groupCode($real_groupCode, $vo['orderId']);
if (empty($group_info)) {
$real_groupCode = $real_groupCode_info["all"];
$group_info = $this->Orders_model->get_SN_by_groupCode($real_groupCode, $vo['orderId']);
}
}
if ($this->Orders_model->GRI_SN === null) {
/** GRoupInfo */
@ -191,12 +196,19 @@ class TulanduoApi extends CI_Controller
} else {
// $startDate = ('2018-04-21');
// $endDate = ('2018-04-22'); // test
$startDate = date('Y-m-d', strtotime("-4 days"));
$startDate = date('Y-m-d');
$endDate = date('Y-m-d', strtotime("+2 days"));
$to_update_list = $this->Orders_model->get_groupCombineInfo(0, null, $startDate, $endDate);
if (empty($to_update_list)) {
$to_update_list = $this->Orders_model->get_groupCombineInfo_finance();
}
}
if (empty($to_update_list)) {
return false;
}
$unique_orderGroupCombine = array(); // 录入拼团调度时,避免重复
$order = $to_update_list[0];
log_message('error','vendorID ' . $order->GCI_VendorOrderId);
$this->tld_order->setOrderId($order->GCI_VendorOrderId)
->setUserId($this->userId)
->setKey($this->key);
@ -216,7 +228,14 @@ class TulanduoApi extends CI_Controller
}
return;
}
$detail_jsonResp->orderDetail->agcOrderNo = trim_groupCode(trim($detail_jsonResp->orderDetail->agcOrderNo)); // 去掉中文的全角空格
if (isset($detail_jsonResp->orderDetail->agcOrderNo) && $detail_jsonResp->orderDetail->agcOrderNo!="") {
} else {
$detail_jsonResp->orderDetail->agcOrderNo = $detail_jsonResp->orderDetail->groupOrderNo;
}
if (isset($detail_jsonResp->orderDetail->groupOrderNo)) {
$detail_jsonResp->orderDetail->groupOrderNo = (trim($detail_jsonResp->orderDetail->groupOrderNo));
}
$detail_jsonResp->orderDetail->agcOrderNo = (trim($detail_jsonResp->orderDetail->agcOrderNo)); // 去掉中文的全角空格
// 目的地的团已经主动取消, 只有其他渠道的团需要更新状态
if (mb_strstr($detail_jsonResp->orderDetail->agcOrderNo, "取消") !== false) {
$this->plan_cancel($order->GCI_VendorOrderId);
@ -248,7 +267,8 @@ class TulanduoApi extends CI_Controller
$getInfo_byGroupCode = null;
$getInfo_byGroupCodeArr = array();
if (isset($detail_jsonResp->orderDetail->agcOrderNo) && $detail_jsonResp->orderDetail->agcOrderNo != "") {
$real_groupCode = analysis_groupCode($detail_jsonResp->orderDetail->agcOrderNo);
$real_groupCode_info = analysis_groupCode($detail_jsonResp->orderDetail->agcOrderNo);
$real_groupCode = $real_groupCode_info['cut'];
$getInfo_byGroupCodeArr = $this->Orders_model->get_order_by_groupcode($real_groupCode);
}
$duplicate = false;
@ -256,12 +276,12 @@ class TulanduoApi extends CI_Controller
if (intval($order->COLI_OPI_ID) === 435 || $order->COLI_ID === null || empty($getInfo_byGroupCodeArr)) {
if ( empty($getInfo_byGroupCodeArr)){
$getInfo_byGroupCode = null; // 没有该团号的团信息
} elseif (strval($getInfo_byGroupCodeArr[0]->COLI_OPI_ID) !== '435') { // 避免intval(null)=0
} elseif ($order->COLI_ID !== null && strval($getInfo_byGroupCodeArr[0]->COLI_OPI_ID) !== '435') { // 避免intval(null)=0
$getInfo_byGroupCode = $getInfo_byGroupCodeArr[0]; // 渠道和目的地有重复操作的团
$duplicate = true;
} else {
foreach ($getInfo_byGroupCodeArr as $kg => $vg) {
if ($vg->GRI_No === mb_substr($detail_jsonResp->orderDetail->agcOrderNo, 0, 49)) {
if ($vg->GRI_No === substr(trim_str($detail_jsonResp->orderDetail->agcOrderNo), 0, 49)) {
// 地接拆分的团号,需要全部匹配; 否则为没有团信息
$getInfo_byGroupCode = $vg;
break;
@ -287,13 +307,14 @@ class TulanduoApi extends CI_Controller
$cold_sn = $this->insert_cold($order_detail_arr);
}
$groupSN = isset($groupSN) ? $groupSN : $getInfo_byGroupCode->GRI_SN;
$coli_sn = isset($coli_sn) ? $coli_sn : $getInfo_byGroupCode->COLI_SN;
$coli_sn = isset($coli_sn)&&intval($coli_sn)!==0 ? $coli_sn : $getInfo_byGroupCode->COLI_SN;
$coli_id = isset($coli_id) ? $coli_id : $getInfo_byGroupCode->COLI_ID;
$cold_sn = isset($cold_sn) ? $cold_sn : $getInfo_byGroupCode->COLD_SN;
$coli_opi_id = 435;
$coli_memo = ($getInfo_byGroupCode !== null) ? $getInfo_byGroupCode->COLI_Memo : "";
$coli_state = ($getInfo_byGroupCode !== null) ? $getInfo_byGroupCode->COLI_State : 9;
$coli_opi_id = ($getInfo_byGroupCode !== null) ? $getInfo_byGroupCode->COLI_OPI_ID : 435;
$coli_memo = ($getInfo_byGroupCode !== null) ? $getInfo_byGroupCode->COLI_Memo : "";
$coli_state = ($getInfo_byGroupCode !== null) ? $getInfo_byGroupCode->COLI_State : 9;
$coli_orderdetailtext = ($getInfo_byGroupCode !== null) ? $getInfo_byGroupCode->COLI_OrderDetailText : "";
$cold_memotext = isset($cold_sn) ? $this->Orders_model->COLD_MemoText : $getInfo_byGroupCode->COLD_MemoText;
} else {
// 已找到的目的地发的计划
// $getInfo_byGroupCode = $order;
@ -306,6 +327,7 @@ class TulanduoApi extends CI_Controller
$cold_sn = $order->COLD_SN; // ???多个子订单 !!!仅用于435创建的订单的更新, 因此仅一个
$coli_opi_id = $order->COLI_OPI_ID;
$coli_orderdetailtext = $order->COLI_OrderDetailText;
$cold_memotext = $order->COLD_MemoText;
}
/** UPDATE */
// HT 订单有重复时, 以图兰朵的团号为正确的订单, 原本已录入的设为无效
@ -355,34 +377,41 @@ class TulanduoApi extends CI_Controller
,"COLI_OrderDetailText" => $new_detail
);
if (intval($coli_opi_id)===435) {
$coli_update_column["COLI_IsSuccess"] = 1; // 表示成行订单
$coli_update_column["COLI_State"] = $coli_state;
$coli_update_column["COLI_Price"] = $travel_fee;
$coli_update_column["COLI_CUrrency"] = $travel_fee_currency;
$coli_update_column["COLI_GroupCode"] = mb_substr($detail_jsonResp->orderDetail->agcOrderNo, 0, 49);
$coli_update_column["COLI_GroupCode"] = substr(trim_str($detail_jsonResp->orderDetail->agcOrderNo), 0, 49);
}
$this->Order_update->biz_confirmlineinfo_update($coli_update_column);
/**
* update BIZ_ConfirmLineDetail
* insert BIZ_BookPeople,BIZ_PackageOrderInfo
*/
/** BIZ_ConfirmLineDetail */
$pag_info = $this->analysis_productcode($detail_jsonResp->orderDetail->routeName, $detail_jsonResp->orderDetail->orderId);
$COLD_MemoText = raw_json_encode(array("Pick up"=>$detail_jsonResp->orderDetail->toTraffic, "Drop off"=>$detail_jsonResp->orderDetail->backTraffic));
$new_memotext = trim($cold_memotext)===""||(json_decode($cold_memotext)!==null&&!is_numeric(json_decode($cold_memotext))) ? $COLD_MemoText : $cold_memotext;
$cold_update_column = array(
"COLD_MemoText" => $new_memotext
);
if (intval($coli_opi_id)===435) {
$cold_update_column['COLD_MemoText'] = $COLD_MemoText;
$cold_update_column['COLD_PersonNum'] = $detail_jsonResp->orderDetail->adultNum;
$cold_update_column["COLD_ChildNum"] = $detail_jsonResp->orderDetail->childNum;
$cold_update_column["COLD_ServiceSN"] = $pag_info->serviceinfo->PAG2_PAG_SN;
$cold_update_column["COLD_ServiceSN2"] = $pag_info->pag_sub;
$cold_update_column["COLD_ServiceCity"] = $pag_info->serviceinfo->PAG_CII_SN;
}
$this->Order_update->cold_where_update = " COLD_SN=" . $cold_sn;
$this->Order_update->biz_confirmlinedetail_update($cold_update_column);
if (intval($coli_opi_id) === 435) {
/** BIZ_ConfirmLineDetail */
$pag_info = $this->analysis_productcode($detail_jsonResp->orderDetail->routeName, $detail_jsonResp->orderDetail->orderId);
$cold_update_column = array(
"COLD_PersonNum" => $detail_jsonResp->orderDetail->adultNum
,"COLD_ChildNum" => $detail_jsonResp->orderDetail->childNum
,"COLD_ServiceSN" => $pag_info->serviceinfo->PAG2_PAG_SN
,"COLD_ServiceSN2" => $pag_info->pag_sub
,"COLD_ServiceCity" => $pag_info->serviceinfo->PAG_CII_SN
);
$this->Order_update->cold_where_update = " COLD_SN=" . $cold_sn;
$this->Order_update->biz_confirmlinedetail_update($cold_update_column);
/** INSERT */
/*BIZ_BookPeople*/
if ($this->Orders_model->bookpeople_exist($cold_sn) === array()) {
if (isset($detail_jsonResp->orderDetail->customers)) {
foreach ($detail_jsonResp->orderDetail->customers as $kd => $vd) {
$this->Orders_model->BPE_FirstName = $vd->name;
$this->Orders_model->BPE_FirstName = substr($vd->name, 0, 40);
$this->Orders_model->BPE_GuestType = $vd->peopleType=="成人" ? 1 : 2;
$this->Orders_model->BPE_Passport = $vd->documentNo;
$bpe_sn[] = $this->Orders_model->biz_book_people_save();
@ -411,42 +440,39 @@ class TulanduoApi extends CI_Controller
// 删除旧的录入
$this->Orders_model->biz_groupaccountinfo_cut($coli_sn, $paytype);
if (intval($latest_order_detail[0]->COLI_OPI_ID)===435) {
$gai_vei_sn = $latest_order_detail[0]->COLD_PlanVEI_SN;
// 团款
if (isset($detail_jsonResp->orderDetail->travelFees) ) {
foreach ($detail_jsonResp->orderDetail->travelFees as $ktf => $vtf) {
$this->insert_gai($coli_sn, $groupSN, $coli_id, $paytype, $pay_currency, $vtf->sumMoney, $vtf->sumMoney, $auto_text . "代收" . $vtf->type . ", " . $vtf->remark);
$this->insert_gai($coli_sn, $groupSN, $coli_id, $paytype, $pay_currency, $vtf->sumMoney, $vtf->sumMoney,$gai_vei_sn, $auto_text . "团款" . $vtf->type . ", " . $vtf->remark);
}
}
// 目的地项目组的订单为了避免重复录入, 外联会沟通录入, 这里不写入.
// 代收
if (isset($detail_jsonResp->orderDetail->replaceCollections) ) {
foreach ($detail_jsonResp->orderDetail->replaceCollections as $krc => $vrc) {
$this->insert_gai($coli_sn, $groupSN, $coli_id, $paytype, $pay_currency, $vrc->money, $vrc->money, $auto_text . "代收" . $vrc->type . ", " . $vrc->remark);
}
}
// 此处代收是地接社角度的代收, 计算利润时需扣减还给地接社, 因此录入为负.
// 代付同理
// if (isset($detail_jsonResp->orderDetail->replaceCollections) ) {
// foreach ($detail_jsonResp->orderDetail->replaceCollections as $krc => $vrc) {
// $this->insert_gai($coli_sn, $groupSN, $coli_id, $paytype, $pay_currency, '-' . $vrc->money, '-' . $vrc->money,$gai_vei_sn, $auto_text . "代收" . $vrc->type . ", " . $vrc->remark);
// }
// }
if (isset($detail_jsonResp->orderDetail->operationDetails->otherReceives) ) {
foreach ($detail_jsonResp->orderDetail->operationDetails->otherReceives as $koor => $voor) {
$this->insert_gai($coli_sn, $groupSN, $coli_id, $paytype, $pay_currency, $voor->sumMoney, $voor->sumMoney, $auto_text . "代收" . $voor->type . ", " . $voor->remark);
$this->insert_gai($coli_sn, $groupSN, $coli_id, $paytype, $pay_currency, $voor->sumMoney, $voor->sumMoney, $gai_vei_sn, $auto_text . "其他收入" . $voor->type . ", " . $voor->remark);
}
}
// 代付
if (isset($detail_jsonResp->orderDetail->replacePays) ) {
foreach ($detail_jsonResp->orderDetail->replacePays as $krp => $vrp) {
$GAI_SQJE = "-" . $vrp->money;
$GAI_SSJE = "-" . $vrp->money;
$GAI_Memo = $auto_text . $vrp->type . ", " . $vrp->remark;
$this->insert_gai($coli_sn, $groupSN, $coli_id, $paytype, $pay_currency, $GAI_SQJE, $GAI_SSJE, $GAI_Memo);
}
}
// if (isset($detail_jsonResp->orderDetail->replacePays) ) {
// foreach ($detail_jsonResp->orderDetail->replacePays as $krp => $vrp) {
// $GAI_SQJE = $vrp->money;
// $GAI_SSJE = $vrp->money;
// $GAI_Memo = $auto_text . "代付" . $vrp->type . ", " . $vrp->remark;
// $this->insert_gai($coli_sn, $groupSN, $coli_id, $paytype, $pay_currency, $GAI_SQJE, $GAI_SSJE, $gai_vei_sn, $GAI_Memo);
// }
// }
}
/*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;
if ( isset($detail_jsonResp->orderDetail->groupOrderNo) ) {
// 删除旧的录入
$this->Orders_model->biz_groupcombineoperationdetail_cut($detail_jsonResp->orderDetail->groupOrderNo);
// 门票
@ -501,7 +527,7 @@ class TulanduoApi extends CI_Controller
$this->Orders_model->GCOD_subType = $vco->type;
$this->Orders_model->GCOD_title = $vco->name;
$this->Orders_model->GCOD_dutyName = $vco->driver;
$this->Orders_model->GCOD_dutyTel = $vco->driverTel;
$this->Orders_model->GCOD_dutyTel = trim_str($vco->driverTel);
$this->Orders_model->GCOD_startDate = $vco->startDate;
$this->Orders_model->GCOD_endDate = $vco->endDate;
$this->Orders_model->GCOD_sumMoney = $vco->sumMoney;
@ -522,7 +548,7 @@ class TulanduoApi extends CI_Controller
$this->Orders_model->GCOD_subType = "";
$this->Orders_model->GCOD_title = "";
$this->Orders_model->GCOD_dutyName = $vgo->name;
$this->Orders_model->GCOD_dutyTel = $vgo->mobelPhone;
$this->Orders_model->GCOD_dutyTel = trim_str($vgo->mobelPhone);
$this->Orders_model->GCOD_dutyPhoto = isset($vgo->guiderPhoto) ? $vgo->guiderPhoto : '';
$this->Orders_model->GCOD_startDate = $vgo->startDate;
$this->Orders_model->GCOD_endDate = $vgo->endDate;
@ -576,6 +602,7 @@ class TulanduoApi extends CI_Controller
$this->Orders_model->biz_groupcombineoperationdetail_save();
}
}
}
$output_text = "Got order operations from TuLanDuo:" . $detail_jsonResp->orderDetail->orderId . ". " . $coli_id;
log_message('error', $output_text);
echo $output_text;
@ -589,6 +616,7 @@ class TulanduoApi extends CI_Controller
public $date_roll = 0;
public function get_history_order_list($oldest_date=null)
{
return false; // 已全部结束
// 避免执行超时, 滚动3次之后结束
if ($this->date_roll > 2) {
log_message('error', "Got order list from TuLanDuo. Roll end. " . $oldest_date);
@ -603,6 +631,8 @@ class TulanduoApi extends CI_Controller
$endTravelDate = $oldest_date;
$start_date = $this->input->get_post("start");
$end_date = $this->input->get_post("end");
// $date_type = "travel";
// $date_type = isset($this->input->get_post("end")) ? $this->input->get_post("end") : "travel";
$startTravelDate = $start_date ? $start_date : $startTravelDate;
$endTravelDate = $end_date ? $end_date : $endTravelDate;
$this->tld_order->setUserId($this->userId)
@ -635,6 +665,7 @@ class TulanduoApi extends CI_Controller
}
$all_vendor_order_id = array_map(function($ele){ return $ele['orderId'];}, $all_list);
$all_vendor_order_id_str = implode(',', $all_vendor_order_id);
$exists_ht = $exists_ht_order_id = null;
$exists_ht = $this->sync_model->get_exists_vendorOrderId($all_vendor_order_id_str);
$exists_ht_order_id = array_map(function($ele){ return intval($ele->GCI_VendorOrderId);}, $exists_ht);
$to_insert = array_diff($all_vendor_order_id, $exists_ht_order_id);
@ -647,14 +678,20 @@ class TulanduoApi extends CI_Controller
if ( ! in_array($vo['orderId'], $to_insert)) {
continue;
}
$vo['agcOrderNo'] = trim_groupCode(trim($vo['agcOrderNo'])); // 去掉中文的全角空格
$vo['agcOrderNo'] = (isset($vo['agcOrderNo'])&&$vo['agcOrderNo']!="") ? $vo['agcOrderNo'] : $vo['groupOrderNo'];
$vo['agcOrderNo'] = (trim($vo['agcOrderNo'])); // 去掉中文的全角空格
$tmpv = $this->city_info[$vo['operationDep']]['PlanVEI_SN'] ? $this->city_info[$vo['operationDep']]['PlanVEI_SN'] : 1343;
$this->Orders_model->BIZ_COLI_SN = null;
$this->Orders_model->GRI_SN = null;
if ( isset($vo['agcOrderNo']) && $vo['agcOrderNo'] != "") {
$real_groupCode = analysis_groupCode($vo['agcOrderNo']);
$real_groupCode_info = analysis_groupCode($vo['agcOrderNo']);
$real_groupCode = $real_groupCode_info["cut"];
// check BIZ_COLI_SN,GRI_SN
$this->Orders_model->get_SN_by_groupCode($real_groupCode, $vo['orderId']);
$group_info = $this->Orders_model->get_SN_by_groupCode($real_groupCode, $vo['orderId']);
if (empty($group_info)) {
$real_groupCode = $real_groupCode_info["all"];
$group_info = $this->Orders_model->get_SN_by_groupCode($real_groupCode, $vo['orderId']);
}
}
/** INSERT */
/** GRoupInfo */
@ -680,7 +717,7 @@ class TulanduoApi extends CI_Controller
return;
}
public function insert_gai($coli_sn, $gri_sn, $coli_id, $paytype, $currency, $sqje, $ssje, $memo="")
public function insert_gai($coli_sn, $gri_sn, $coli_id, $paytype, $currency, $sqje, $ssje, $gai_vei_sn, $memo="")
{
$this->Orders_model->GAI_Operator = 435;
$this->Orders_model->GAI_COLI_SN = $coli_sn;
@ -692,6 +729,7 @@ class TulanduoApi extends CI_Controller
$this->Orders_model->GAI_SSJE = $ssje;
$this->Orders_model->GAI_SSDate = date("Y-m-d H:i:s");
$this->Orders_model->GAI_Memo = $memo;
$this->Orders_model->GAI_VEI_SN = $gai_vei_sn;
return $this->Orders_model->biz_groupaccountinfo_save();
}
@ -739,9 +777,9 @@ class TulanduoApi extends CI_Controller
$travelDate = new DateTime($list_ele['travelDate']);
$leaveDate = new DateTime($list_ele['leaveDate']);
$date_diff = $travelDate->diff($leaveDate);
$this->Orders_model->GRI_No = mb_substr($list_ele['agcOrderNo'], 0, 49);
$this->Orders_model->GRI_No = substr(trim_str($list_ele['agcOrderNo']), 0, 49);
$this->Orders_model->GRI_OrderType = 227002; // 商务
$this->Orders_model->GRI_Name = mb_substr($list_ele['agcOrderNo'], 0, 49);
$this->Orders_model->GRI_Name = substr(trim_str($list_ele['agcOrderNo']), 0, 49);
$this->Orders_model->GRI_PersonNum = $list_ele['adultNum']+$list_ele['childNum'];
$this->Orders_model->GRI_Days = intval($date_diff->format('%R%a')+1);
$this->Orders_model->GRI_IsCancel = 0;
@ -815,6 +853,7 @@ class TulanduoApi extends CI_Controller
$this->Order_update->coli_where_update = " COLI_ID='" . $COLI_ID . "'";
$coli_update_column = array(
"COLI_State" => 40
,"COLI_IsSuccess" => NULL
);
return $this->Order_update->biz_confirmlineinfo_update($coli_update_column);
}
@ -846,12 +885,13 @@ class TulanduoApi extends CI_Controller
/*!
* 发送预订计划到地接系统
* TODO read word into remark
* @date 2018-05-02
* @param string $COLI_ID HT系统订单号
*/
public function order_push($COLI_ID="") // test
{
exit();
// exit();
/** 目的地 test */
$this->userId = "358";
$this->key = "a08f26ddc5b1bd4c8e5eafcac28fc1ec";
@ -883,7 +923,7 @@ class TulanduoApi extends CI_Controller
->setDestination($scheduleDetails[0]->CII2_Name)
->setTravelDate(strstr($orderinfo[0]->COLD_StartDate, " ", true))
->setLeavedDate(strstr($orderinfo[0]->COLD_EndDate, " ", true))
->setOrderRemark($orderinfo[0]->COLI_Memo . "\r\n" . $orderinfo[0]->COLD_Memo . "\r\n" . $orderinfo[0]->COLD_MemoText); // todo 抵离交通
->setOrderRemark(trim($orderinfo[0]->COLI_Memo . "\r\n" . $orderinfo[0]->COLD_Memo . "\r\n" . $orderinfo[0]->COLD_MemoText)); // todo 抵离交通
foreach ($guestlist as $key => $vg) {
$this->tldOrderBuilder->setCustomersName($key, $vg->BPE_FirstName)
->setCustomersPeopleType($key, ($vg->BPE_GuestType==1 ? "成人" : "儿童"))
@ -907,16 +947,17 @@ class TulanduoApi extends CI_Controller
->setTravelFeesSumMoney($kf, $vf->GAI_SSJE)
->setTravelFeesRemark($kf, $vf->GAI_Memo);
}
$resp = $this->excute_curl($this->neworder_url, $this->tldOrderBuilder);
var_dump(($this->tldOrderBuilder->getBizContent()));
// $resp = $this->excute_curl($this->neworder_url, $this->tldOrderBuilder);
/** BIZ_GroupCombineInfo */
if (json_decode($resp)->status == 1) {
log_message('error','in GCI ' . json_decode($resp)->responseData->orderId);
$this->Orders_model->GCI_COLI_SN = $orderinfo[0]->COLI_SN;
$this->Orders_model->GCI_GRI_SN = $orderinfo[0]->COLI_GRI_SN;
$this->Orders_model->GCI_VendorOrderId = json_decode($resp)->responseData->orderId;
$this->Orders_model->GCI_FromAgc = "D目的地桂林组";
$this->Orders_model->biz_groupcombineinfo_save();
}
// if (json_decode($resp)->status == 1) {
// log_message('error','in GCI ' . json_decode($resp)->responseData->orderId);
// $this->Orders_model->GCI_COLI_SN = $orderinfo[0]->COLI_SN;
// $this->Orders_model->GCI_GRI_SN = $orderinfo[0]->COLI_GRI_SN;
// $this->Orders_model->GCI_VendorOrderId = json_decode($resp)->responseData->orderId;
// $this->Orders_model->GCI_FromAgc = "D目的地桂林组";
// $this->Orders_model->biz_groupcombineinfo_save();
// }
// email 供应商 todo
echo "Order Push done.";
return;
@ -1066,9 +1107,12 @@ log_message('error','in GCI ' . json_decode($resp)->responseData->orderId);
,"北京精品游D2目的地" => "BJSIC-42"
,"北京精品游D3目的地" => "BJSIC-43"
,"北京单租车服务(目的地)" => "BJALC-209"
,"北京单租车接送(常规)" => "BJALC-209"
,"北京单租车接送服务(目的地)" => "BJALC-209"
,"北京市内-天津新港大车接送(目的地)" => "BJSIC-16"
,"天津新港-北京市内大车接送(目的地)" => "BJSIC-16"
,"箭扣-慕田峪徒步一日游(目的地)" => "BJSIC-45"
,"箭扣-慕田峪徒步一日游PVT目的地" => "BJSIC-45"
,"箭扣-慕田峪长城徒步拼团(目的地)" => "BJSIC-45"
,"司马台西-金山岭徒步一日游(目的地)" => "BJSIC-46"
,"司马台西-金山岭徒步一日游PVT目的地" => "BJSIC-46"
@ -1076,22 +1120,29 @@ log_message('error','in GCI ' . json_decode($resp)->responseData->orderId);
,"慕田峪半日游拼团(目的地)" => "BJSIC-47"
,"慕田峪半日游PVT目的地" => "BJSIC-47"
,"古北口长城徒步一日游(目的地)" => "BJSIC-48"
,"古北口(目的地)" => "BJSIC-48"
,"半日游广场故宫拼团(目的地)" => "BJSIC-41"
// ,=>
,"西安精品一日游(目的地)" => "XASIC-41"
,"西安精品一日游PVT目的地" => "XASIC-41"
,"西安市内精品一日游(目的地)" => "XASIC-41"
,"西安精品两日游(目的地)" => "XASIC-42"
,"西安单租车服务(目的地)" => "XASIC-17"
,"西安单租车接送服务(目的地)" => "XASIC-17"
,"西安单租车接送服务" => "XASIC-17"
,"西安兵马俑精品一日游(目的地)" => "XASIC-41"
,"西安兵马俑精华一日游(目的地)" => "XASIC-41"
,"西安兵马俑精品半日游(目的地)" => "XASIC-15"
,"西安兵马俑精品半日游PVT目的地" => "XASIC-15"
,"西安汉阳陵市内精品一日游(目的地)" => "XASIC-42"
// ,=>
,"上海精品一日游(目的地)" => "SHSIC-41"
,"上海精品游PVT线路目的地" => "SHSIC-41"
,"上海市内精品一日游(目的地)" => "SHSIC-42"
,"周庄锦溪精品一日游(目的地)" => "SHSIC-43"
,"苏州精品一日游(目的地)" => "SHSIC-44"
,"上海单租车(目的地)" => "SHSIC-45" //"SHALC-6,7,8,9"
,"上海单租车接送服务(目的地)" => "SHSIC-45" //"SHALC-6,7,8,9"
);
}

@ -7,25 +7,154 @@ class Api extends CI_Controller {
parent::__construct();
mb_regex_encoding("UTF-8");
$this->load->helper('array');
$this->load->library('trippest');
$this->load->model('Orders_query', 'Orders_model');
header('Access-Control-Allow-Origin:*');
header('Access-Control-Allow-Methods:POST, GET');
header('Access-Control-Max-Age:0');
header('Access-Control-Allow-Headers:x-requested-with, Content-Type');
header('Access-Control-Allow-Credentials:true');
}
public function index()
{
// echo "string";
// return;
$this->operation_detail();
}
public function operation_detail($find=null)
{
header('Access-Control-Allow-Origin:*');
header('Access-Control-Allow-Methods:POST, GET');
header('Access-Control-Max-Age:0');
header('Access-Control-Allow-Headers:x-requested-with, Content-Type');
header('Access-Control-Allow-Credentials:true');
($find===null) ? $find = $this->input->get_post('q') : null;
$find = (mb_strlen($find)<9) ? null : $this->input->get_post('q');
preg_match('/[\d]+\-?[\w]*/', characet($find, "UTF-8"), $temp_array);
$find = $temp_array[0];
$order_plan = $this->Orders_model->get_order_vendorplan($find);
if ($find===null || $order_plan == null) {
$ret['status'] = 0;
$ret['msg'] = "Not Found.";
return $this->output->set_content_type('application/json')->set_output(json_encode($ret));
}
$ret['status'] = 1;
$ret['msg'] = "";
$gri_sn = $order_plan[0]->VAS_GRI_SN;
$group_number_info = analysis_groupCode($order_plan[0]->COLI_GroupCode);
$ret['group_number'] = $group_number_info["all"];
$operation_info = $ht_tourguide = $this->tourguide_common($gri_sn);
if (empty($operation_info)) {
return $this->operation_detail_tulanduo($find);
}
$ret['operation'] = $operation_info;
/** 外联信息 */
$raw_opi_id = 0;
if (intval($order_plan[0]->COLI_OPI_ID) === 435) {
$real_code_info = analysis_groupCode($ret['group_number']);
$raw_opi_id = $this->Orders_model->get_gri_opi_id($real_code_info['cut']);
} else {
$raw_opi_id = $order_plan[0]->COLI_OPI_ID;
}
$operator = $this->Orders_model->get_operator($raw_opi_id);
if ( ! empty($operator)) {
$ret['operator']['chinese_name'] = $operator->OPI_Name;
$ret['operator']['mobile'] = $operator->OPI_MoveTelephone;
$ret['operator']['email'] = $operator->OPI_Email;
$ret['operator']['english_name'] = $operator->OPI2_Name;
// 英文名没有
if ($operator->OPI_FirstName == null || $operator->OPI2_Name == null ) {
$ret['operator']['english_name'] = ucfirst(strstr($operator->OPI_Email, "@", true));
}
}
return $this->output->set_content_type('application/json')->set_output(json_encode($ret));
}
public function tourguide_common($gri_sn)
{
$operation = array();
$tourguide = $this->Orders_model->get_plan_tourguide($gri_sn);
if (empty($tourguide)) {
return null;
}
$order_detail = $this->Orders_model->get_order_detail($gri_sn);
foreach ($order_detail as $kd => $poi) {
$operation_tmp = array();
$operation_tmp['start_date'] = substr($poi->COLD_StartDate, 0, 10);
$out_datetime = strtotime($poi->COLD_StartDate);
$out_datetime2 = strtotime($poi->COLD_EndDate);
$operation_tmp['dateWeek_text'] = date('D', $out_datetime);
$operation_tmp['dateDay_text'] = date('d', $out_datetime);
$operation_tmp['dateMonth_text'] = date('M', $out_datetime);
$operation_tmp['dateYear_text'] = date('Y', $out_datetime);
if ($out_datetime !== $out_datetime2) {
$operation_tmp['start_date'] = $poi->COLD_StartDate . " to " . $poi->COLD_EndDate;
}
$operation_tmp['tour_name'] = $poi->PAG2_Name;
$code_name = $this->trippest->tour_name(strtoupper($poi->pag_code));
if ($code_name !== "") {
$operation_tmp['tour_name'] = $code_name;
}
// 领队名字
$operation_tmp['leader_name'] = trim($poi->GUT_FirstName . " " . $poi->GUT_LastName);
// 行程人数
$operation_tmp['personNum_text'] = $poi->COLD_PersonNum + $poi->COLD_ChildNum;
$operation_tmp['personNum_text'] .= " (" . $poi->COLD_PersonNum . " Adult(s)";
if ($poi->COLD_ChildNum > 0) {
$operation_tmp['personNum_text'] .= " " . $poi->COLD_ChildNum . " Child(ren)";
}
$operation_tmp['personNum_text'] .= ")" ;
// 人数
$operation_tmp['adult_number'] = $poi->COLD_PersonNum;
$operation_tmp['kid_number'] = $poi->COLD_ChildNum;
// 酒店
$operation_tmp['hotel_name'] = $poi->POI_Hotel;
$operation_tmp['hotel_address'] = $poi->POI_HotelAddress;
$operation_tmp['hotel_tel'] = $poi->POI_HotelPhone;
// 航班/车次
$operation_tmp['flights_no'] = $poi->POI_FlightsNo;
$operation_tmp['flights_airport'] = $poi->POI_AirPort;
// 接送信息
$operation_tmp['pick_up'] = "";
$operation_tmp['drop_off'] = "";
$decode_MemoText = $memo_text_tmp = "";
$operation_tmp['pick_up'] = trim(substr(strstr(strstr($poi->COLI_OrderDetailText, "Pick Up From:"), "\n", true), 13));
$operation_tmp['drop_off'] = trim(substr(strstr(strstr($poi->COLI_OrderDetailText, "Drop Off:"), "\n" , true), 9));
if ($operation_tmp['pick_up'] === "") {
if (strval($poi->PAGS_Direction) === '0') {
$operation_tmp['pick_up'] .= $poi->POI_FlightsNo . " " . $poi->POI_AirPort;
$operation_tmp['drop_off'] .= $poi->POI_Hotel;
} else if (strval($poi->PAGS_Direction) === '1') {
$operation_tmp['pick_up'] .= $poi->POI_Hotel;
$operation_tmp['drop_off'] .= $poi->POI_FlightsNo . " " . $poi->POI_AirPort;
} else { // if ($poi->POI_FlightsNo != "")
$operation_tmp['pick_up'] .= $poi->POI_Hotel;
// $operation_tmp['drop_off'] .= $poi->POI_FlightsNo . " " . $poi->POI_AirPort; // 结束后送机
}
}
$opd = new stdclass();
foreach ($tourguide as $key => $tgi) {
if ($poi->COLD_PlanVEI_SN === $tgi->EOI_VEI_SN
// && strcmp($operation_tmp['start_date_raw'], substr($poi->COLD_StartDate, 0, 10) ) === 0
) {
$opd = $tgi;
}
}
if (empty($opd)) {
$opd = $tgi[0];
}
$tourguide_tmp['guide_name'] = $opd->TGI2_Name;
$tourguide_tmp['guide_tel'] = $opd->TGI_Mobile;
$tourguide_tmp['guide_pic'] = "";
// $tourguide_tmp['using_startdate'] = $opd->GCOD_startDate;
// $tourguide_tmp['using_enddate'] = $opd->GCOD_endDate;
$operation_tmp['tourguide'][] = $tourguide_tmp;
$tourguide_tmp = array();
$operation[] = $operation_tmp;
}
return $operation;
}
public function operation_detail_tulanduo($find=null)
{
// ($find===null) ? $find = $this->input->get_post('q') : null;
// $find = (mb_strlen($find)<9) ? null : $this->input->get_post('q');
$order_project = $this->Orders_model->get_package_order($find);
if ($find===null || $order_project == null) {
$ret['status'] = 0;
@ -34,7 +163,8 @@ class Api extends CI_Controller {
}
$ret['status'] = 1;
$ret['msg'] = "";
$ret['group_number'] = $order_project[0]->COLI_GroupCode;
$group_number_info = analysis_groupCode($order_project[0]->COLI_GroupCode);
$ret['group_number'] = $group_number_info["all"];
$all_combine_no = array_unique(array_map(function($ele)
{
return $ele->GCI_combineNo;
@ -59,6 +189,11 @@ class Api extends CI_Controller {
$ret['operation'][$value->GCOD_startDate]['cardriver'][] = $tmp_car;
// 出团时间
$ret['operation'][$value->GCOD_startDate]['start_date'] = $value->GCOD_startDate;
if ( ! isset($ret['operation'][$value->GCOD_startDate]['end_date'])
|| strtotime($ret['operation'][$value->GCOD_startDate]['end_date']) > strtotime($value->GCOD_endDate)
) {
$ret['operation'][$value->GCOD_startDate]['end_date'] = $value->GCOD_endDate;
}
}
else if ($value->GCOD_operationType === 'guiderOperations') {
$tmp_g = array();
@ -71,19 +206,29 @@ class Api extends CI_Controller {
$ret['operation'][$value->GCOD_startDate]['tourguide'][] = $tmp_g;
// 出团时间
$ret['operation'][$value->GCOD_startDate]['start_date'] = $value->GCOD_startDate;
if ( ! isset($ret['operation'][$value->GCOD_startDate]['end_date'])
|| strtotime($ret['operation'][$value->GCOD_startDate]['end_date']) > strtotime($value->GCOD_endDate)
) {
$ret['operation'][$value->GCOD_startDate]['end_date']= $value->GCOD_endDate;
}
}
}
// 加上行程
$num_index = 0;
foreach ($ret['operation'] as $kro => &$vro) {
$vro['start_date_raw'] = $vro['start_date'];
$out_datetime = strtotime($vro['start_date']);
$out_datetime2 = strtotime($vro['end_date']);
$vro['dateWeek_text'] = date('D', $out_datetime);
$vro['dateDay_text'] = date('d', $out_datetime);
$vro['dateMonth_text'] = date('M', $out_datetime);
$vro['dateYear_text'] = date('Y', $out_datetime);
if ($out_datetime !== $out_datetime2) {
$vro['start_date'] = $vro['start_date'] . " to " . $vro['end_date'];
}
$poi = new stdclass();
foreach ($order_project as $kd => $poi_info) {
if (strcmp($vro['start_date'], substr($poi_info->COLD_StartDate, 0, 10) ) === 0) {
if (strcmp($vro['start_date_raw'], substr($poi_info->COLD_StartDate, 0, 10) ) === 0) {
if (count((array)$poi)===0) {
$poi = $poi_info;
} else if ($poi->POI_Hotel == "") {
@ -103,6 +248,10 @@ class Api extends CI_Controller {
$vro['cold_date'] = $poi->COLD_StartDate;
$vro['cold_enddate'] = $poi->COLD_EndDate;
$vro['tour_name'] = $poi->PAG2_Name;
$code_name = $this->trippest->tour_name(strtoupper($poi->pag_code));
if ($code_name !== "") {
$vro['tour_name'] = $code_name;
}
// 领队名字
$vro['leader_name'] = trim($poi->GUT_FirstName . " " . $poi->GUT_LastName);
// 行程人数
@ -126,11 +275,16 @@ class Api extends CI_Controller {
$vro['pick_up'] = "";
$vro['drop_off'] = "";
$decode_MemoText = $memo_text_tmp = "";
if ($num_index == 0) {
if ($vro['pick_up'] === "" && $poi->COLD_MemoText != null && json_decode($poi->COLD_MemoText) != null) {
$decode_MemoText = json_decode($poi->COLD_MemoText, true);
$vro['pick_up'] = $decode_MemoText['Pick up'];
$vro['drop_off'] = $decode_MemoText['Drop off'];
}
if ($vro['pick_up'] === "" && $num_index == 0) {
$vro['pick_up'] = trim(substr(strstr(strstr($poi->COLI_OrderDetailText, "Pick Up From:"), "\n", true), 13));
$vro['drop_off'] = trim(substr(strstr(strstr($poi->COLI_OrderDetailText, "Drop Off:"), "\n" , true), 9));
}
// if ($vro['pick_up'] === "") {
if ($vro['pick_up'] === "") {
if (strval($poi->PAGS_Direction) === '0') {
$vro['pick_up'] .= $poi->POI_FlightsNo . " " . $poi->POI_AirPort;
$vro['drop_off'] .= $poi->POI_Hotel;
@ -141,10 +295,7 @@ class Api extends CI_Controller {
$vro['pick_up'] .= $poi->POI_Hotel;
// $vro['drop_off'] .= $poi->POI_FlightsNo . " " . $poi->POI_AirPort; // 结束后送机
}
// }
// if ($vro['pick_up'] === "" && $poi->POI_FlightsNo == '') {
// $vro['pick_up'] = $vro['drop_off'] = $poi->POI_Hotel;
// }
}
$num_index++;
}
unset($vro);
@ -152,8 +303,8 @@ class Api extends CI_Controller {
$ret['operation'] = array_values($ret['operation']);
$ret_operation = array();
foreach ($ret['operation'] as $ko => $vo) {
if (strtotime($vo['start_date']) >= strtotime($vo['cold_date'])
&& strtotime($vo['start_date']) <= strtotime($vo['cold_enddate'])) {
if (strtotime($vo['start_date_raw']) >= strtotime($vo['cold_date'])
&& strtotime($vo['start_date_raw']) <= strtotime($vo['cold_enddate'])) {
unset($vo['cold_date']);
unset($vo['cold_enddate']);
$ret_operation[] = $vo;
@ -164,8 +315,8 @@ class Api extends CI_Controller {
/** 外联信息 */
$raw_opi_id = 0;
if (intval($order_project[0]->COLI_OPI_ID) === 435) {
$real_code = analysis_groupCode($ret['group_number']);
$raw_opi_id = $this->Orders_model->get_gri_opi_id($real_code);
$real_code_info = analysis_groupCode($ret['group_number']);
$raw_opi_id = $this->Orders_model->get_gri_opi_id($real_code_info['cut']);
} else {
$raw_opi_id = $order_project[0]->COLI_OPI_ID;
}

@ -54,8 +54,9 @@ class Order_finance extends CI_Controller {
* * 获取拼团总人数, 价格人等
* * 分别计算每次拼团成本
* * * 写入report_tour
* * * 其他产品项目, report_train, report_hotel等
* * 所有产品总成本
* * * 写入核算管理CK_GroupInfo
* * * [此处不做]写入核算管理CK_GroupInfo
* * * 写入单团财务表report_order
* END
*/
@ -244,7 +245,7 @@ class Order_finance extends CI_Controller {
return null;
}
$ret->coli_sn = $coli_sn;
$all_pags = array_map(function($ele){ return $ele->PAG_Code;}, $all_orders);
$all_pags = array_map(function($ele){ return mb_strtoupper($ele->PAG_Code);}, $all_orders);
$all_pag = array_unique($all_pags);
$combine_pag_arr = array();
$pvt_code = $this->forbidden_combine();
@ -274,7 +275,7 @@ class Order_finance extends CI_Controller {
$all_orders[] = $ve;
}
// 重新计算重复次数
$all_pags = array_filter(array_map(function($ele){ return $ele->PAG_Code;}, $all_orders));
$all_pags = array_filter(array_map(function($ele){ return mb_strtoupper($ele->PAG_Code);}, $all_orders));
// 重复的产品号; 可混拼的产品
$repeat_code = array();
$code_count = array_count_values($all_pags);
@ -283,8 +284,9 @@ class Order_finance extends CI_Controller {
continue;
}
$tmp = null;
$tmp = $this->get_allowed_combine($vp);
$tmp = $this->get_allowed_combine(mb_strtoupper($vp));
$this_allowed = ($tmp === null) ? null : array_diff($tmp, $all_pag); // diff((31,41), (31,41,47)) ==> ()
// $this_allowed = ($tmp === null) ? null : array_diff($all_pag, $tmp); // diff((31,41), (31,41,47)) ==> ()
if (empty($this_allowed) && $tmp !== null) {
$combine_pag_arr[] = $tmp; // push (31,41)
}
@ -308,17 +310,24 @@ class Order_finance extends CI_Controller {
}
$ret->combine_pags = my_array_unique($combine_pag_arr);
$ret->combine_pags = $ret->combine_pags[0]; // 这里用0是因为一个拼团应该只有一组或一个产品
// 一些不在常规混拼的团, 仅有一个拼团号的订单则加上该团
foreach ($all_orders as $key => $value) {
if ($value->combine_cnt === 1) {
$ret->combine_pags[] = mb_strtoupper($value->PAG_Code);
}
}
$ret->combine_pags = array_values(array_unique($ret->combine_pags));
$ret->person_num = 0;
$ret->PAG_Code = "";
$ret->order_cost = array();
$pag_sns = array();
$unique_coli = array();
foreach ($all_orders as $ko => $vo) {
if (in_array($vo->PAG_Code, $ret->combine_pags)) {
if (in_array(mb_strtoupper($vo->PAG_Code), $ret->combine_pags)) {
$pag_sns[] = $vo->COLD_ServiceSN;
// 整团单拼时, 避免重复计算人数
// 订单人数不重复计
if ( ! in_array($vo->PAG_Code, $pvt_code) && ! in_array($vo->COLI_SN, $unique_coli)) {
if ( ! in_array(mb_strtoupper($vo->PAG_Code), $pvt_code) && ! in_array($vo->COLI_SN, $unique_coli)) {
$unique_coli[] = $vo->COLI_SN;
$ret->person_num += $vo->COLD_PersonNum + $vo->COLD_ChildNum;
}
@ -329,8 +338,9 @@ class Order_finance extends CI_Controller {
$tour_s->person_num = $vo->COLD_PersonNum + $vo->COLD_ChildNum;
$tour_s->adult_num = $vo->COLD_PersonNum;
$tour_s->child_num = $vo->COLD_ChildNum;
$tour_s->PAG_code = $vo->PAG_Code;
$tour_s->real_code = isset($vo->real_code) ? $vo->real_code : $vo->PAG_Code;
$tour_s->PAG_code = mb_strtoupper($vo->PAG_Code);
// $tour_s->real_code = isset($vo->real_code) ? $vo->real_code : $vo->PAG_Code;
$tour_s->real_code = isset($vo->real_code)&&in_array($vo->real_code, $ret->combine_pags) ? $vo->real_code : mb_strtoupper($vo->PAG_Code);
$tour_s->real_pag_sn = isset($vo->real_pag_sn) ? $vo->real_pag_sn : $vo->COLD_ServiceSN;
$tour_s->totalPrice = $vo->COLD_TotalPrice;
$ret->order_cost[] = $tour_s;
@ -351,8 +361,8 @@ class Order_finance extends CI_Controller {
foreach ($ret->order_cost as $kc => $voc) {
$ret->order_cost[$kc]->order_cost_sum = bcmul($voc->person_num, $ret->person_cost);
}
return $ret;
// return $this->output->set_content_type('application/json')->set_output(json_encode($ret, JSON_UNESCAPED_UNICODE));
return $ret;
}
/*!
@ -376,7 +386,7 @@ class Order_finance extends CI_Controller {
$ret->totalPrice = bcadd($ret->totalPrice, $val->COLD_TotalPrice);
}
// 预定的产品数
$ret->tour_count = count(array_unique(array_map(function($ele) {return $ele->PAG_Code;}, $all_orders)));
$ret->tour_count = count(array_unique(array_map(function($ele) {return mb_strtoupper($ele->PAG_Code);}, $all_orders)));
$person_num = $this->OrderFinance_model->get_order_person_num($coli_sn);
$ret->person_num = $person_num->person_num;
$ret->adult_num = $person_num->adult_num;
@ -390,7 +400,7 @@ class Order_finance extends CI_Controller {
$ret->comment = "PVT,共" . $ret->person_num . "人";
$pag_sns = array_values(array_unique(array_map(function($ele) {return $ele->COLD_ServiceSN;}, $all_orders)));
$pags_info = $this->OrderFinance_model->get_pag_info(implode(',', $pag_sns));
$ret->PAG_Code = implode(",", array_values(array_unique(array_map(function($ele) {return $ele->PAG_Code;}, $pags_info))));
$ret->PAG_Code = implode(",", array_values(array_unique(array_map(function($ele) {return mb_strtoupper($ele->PAG_Code);}, $pags_info))));
$ret->vendor_name = implode(",", array_values(array_unique(array_map(function($ele) {return $ele->VEI2_CompanyBN;}, $pags_info)))) ;
$ret->pag_name = implode(";\r\n", array_map(function($ele) {return $ele->PAG_Title;}, $pags_info)) ;
return $ret;

@ -0,0 +1,191 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Send_operation extends CI_Controller {
public function __construct(){
parent::__construct();
mb_regex_encoding("UTF-8");
bcscale(4);
$this->load->helper('array');
$this->load->model('Send_operation_model', 'send_model');
$this->send_url = 'https://www.mycht.cn/webht.php/apps/messagecenter/index/send_message/';
header('Access-Control-Allow-Origin:*');
header('Access-Control-Allow-Methods:POST, GET');
header('Access-Control-Max-Age:0');
header('Access-Control-Allow-Headers:x-requested-with, Content-Type');
header('Access-Control-Allow-Credentials:true');
}
public function index()
{
$this->sms_log();
return;
}
public function sms_log()
{
$date = $this->input->get_post("date");
$date = $date ? $date : date('Y-m-d', strtotime("+1 day"));
$ready_order["date"] = $date;
$COLI_ID = $this->input->get_post("order_id");
$ready_order["order_id"] = $COLI_ID;
$ready_order["list"] = $this->send_model->daytour_order_ready_for_send(trim($COLI_ID), $date, "no_send_state");
$this->load->view('sms_log', $ready_order);
return;
}
public function order_sms_list($COLI_SN)
{
$data['list'] = $this->send_model->order_sms_list($COLI_SN);
$list_table = $this->load->view('order_sms_list', $data, true);
$this->output->set_content_type('application/json')->set_output(json_encode($list_table));
return;
}
/*!
* 通过短信发送导游信息给预定了Day Tour的客人
* * 每天9:00, 16:00 尝试发送
* * 第二次发送之后仍然发送失败或没有调度信息, 反馈到Alex邮箱
* * 这里只是Day Tour 订单, 不含单接送, 因此每个订单仅发送一次
* @date 2018-09-25
*/
/*!
* 模板内容
* 2018-10-22
* 【桂林海纳国旅】Hi {1}, your guide on {2} is {3}, localmobile is {4}. He/she'll call you at the hotel, or leave a message tonight. You can find more info by inputting booking No. {5} at https://www.trippest.com/track-your-trip. Wish you a wonderful day with Trippest!
*/
public function daytour($COLI_ID="")
{
$now_h = date("H");
$time_flag = "";
if ($now_h < 9 || $now_h > 19) {
echo "Break time.";
return false;
} else if ($now_h >= 9 && $now_h < 16) {
$time_flag = "try1";
} else {
$time_flag = "try2";
}
$date = date('Y-m-d', strtotime("+1 day"));
if (trim($COLI_ID) !== "") {
$date = null;
$time_flag = "handle";
}
$ready_order = $this->send_model->daytour_order_ready_for_send(trim($COLI_ID), $date, $time_flag);
if (empty($ready_order)) {
echo "Empty. ";
return false;
}
$order = $ready_order[0];
if (strtotime($order->COLD_StartDate) < strtotime(date('Y-m-d')) ) {
echo "已过期";
return;
}
$last_update = "";
$guide_name = "";
if ($order->gcod != null) {
$split_gcod = explode("@", $order->gcod);
$guide_name = $split_gcod[0];
$guide_tel = $split_gcod[1];
$last_update = $split_gcod[2] . " " . $split_gcod[3];
} else {
$guide_name = strstr($order->eva, "@", true);
$guide_tel = substr(strstr($order->eva, "@"), 1);
}
$send_body = array(
"one" => trim($order->guest_name)
,"two" => substr($order->COLD_StartDate, 0, 10)
,"three" => $guide_name
,"four" => "+86 " . $guide_tel
,"five" => $order->COLI_ID
,"phone" => real_phone_number($order->GUT_TEL, mb_ereg_replace('[\D]', '', $order->GUT_POST))
,"nation_code" => mb_ereg_replace('[\D]', '', $order->GUT_POST)
);
$cb_db = array(
"TPSL_COLI_SN" => $order->COLI_SN
,"TPSL_nationCode" => $send_body['nation_code']
,"TPSL_mobile" => $send_body['phone']
,"TPSL_msgType" => 'guide'
,"TPSL_sendState" => 0
);
$ht_id = $this->send_model->insert_trippest_sms_log($cb_db);
$error_msg = "";
$send_time = date("Y-m-d H:i:s");
if ($guide_name != null) {
$send_cb = $this->excute_curl($this->send_url, $send_body);
$send_cb_obj = json_decode($send_cb);
$update_cb_db["TPSL_sendTime"] = $send_time;
$update_cb_db["TPSL_sendContent"] = json_encode($send_body);
$update_cb_db['TPSL_sendState'] = $send_cb_obj->result===0 ? 1 : 0;
$update_cb_db['TPSL_callbackJson'] = $send_cb;
$update_cb_db['TPSL_callbackTime'] = date("Y-m-d H:i:s");
$update_where = " TPSL_SN=" . $ht_id;
$ht_id = $this->send_model->update_trippest_sms_log($update_where, $update_cb_db);
$send_cb_obj->errmsg!=="OK" ? $error_msg=$send_cb_obj->errmsg : null;
}
if ($time_flag === "try1") {
return;
}
if ($guide_name == null || $error_msg !== "") {
// 没有调度或发送失败
// to Alex
$operator_mailbody = "<p> Dear Alex: </p>" .
"<p>导游信息发送客人失败:<br /></p>" .
"<p>订单号:" . $order->COLI_ID ."</p>" .
"<p>发团时间:" . substr($order->COLD_StartDate, 0, 10) ."</p>" .
"<p>导游信息:" . $guide_name . "(" . $guide_tel . ")" ."</p>" .
"<p>导游更新时间:" . $last_update ."</p>" .
"<p>发送时间:" . $send_time ."</p>";
if ($error_msg !== "") {
$operator_mailbody .= "<p>发送失败信息:" . $error_msg . "</p>";
}
$operator_mailbody .= "<p><a href='https://www.trippest.com/track-your-trip/'>Tracking Link</a>.</p>";
$operator_mailbody .= "<p> 此邮件由系统自动发送, 请勿回复.</p>";
$this->send_model->SendMail(
"chinahighlights",
"webform@chinahighlights.net",
"YSL",
"alex@chinahighlights.net", // ysl email alex@chinahighlights.net
'#SMS send fail# ' . $order->COLI_ID,
$operator_mailbody);
}
echo "已发送";
return;
}
protected function excute_curl($url, $postBody) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FAILONERROR, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"Accept: application/json"
));
if (empty($postBody)) {
return false;
}
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postBody);
$reponse = curl_exec($ch);
// $eval_resp = json_decode($reponse);
if (curl_errno($ch)) {
log_message('error', "curl error : ".curl_error($ch) . "; curl postBodyString: ".json_encode($postBody));
} else {
$httpStatusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if (200 !== $httpStatusCode) {
log_message('error', "curl response Status Code: ".$httpStatusCode."; curl postBodyString: ".json_encode($postBody));
}
}
curl_close($ch);
return $reponse;
}
}
/* End of file send_operation.php */
/* Location: ./webht/third_party/trippestOrderSync/controllers/send_operation.php */

@ -117,27 +117,34 @@ function raw_json_encode($input, $flags = 0) {
function analysis_groupCode($groupCode)
{
mb_regex_encoding("UTF-8");
$groupCode = trim_groupCode(trim($groupCode));
$groupCode = trim_str(trim($groupCode));
preg_match('/[\w\s\-]+/', characet($groupCode, "UTF-8"), $temp_array);
// $temp_array[0] = strrchr($temp_array[0], " ") ? mb_strstr($temp_array[0], " ",true) : $temp_array[0];
if (empty($temp_array)) {
return trim_str(trim($groupCode));
}
$tmp_groupCode = explode("-", trim($temp_array[0]));
$real_groupCode = $tmp_groupCode[0];
if (isset($tmp_groupCode[1])) {
$real_groupCode .= "-";
$real_groupCode .= mb_strstr($tmp_groupCode[1], "", true)!==false ? mb_strstr($tmp_groupCode[1], "", true) : $tmp_groupCode[1];
// $real_groupCode .= mb_strstr($tmp_groupCode[1], "", true)!==false ? mb_strstr($tmp_groupCode[1], "", true) : $tmp_groupCode[1];
$order_id = mb_strstr($tmp_groupCode[1], "", true)!==false ? mb_strstr($tmp_groupCode[1], "", true) : $tmp_groupCode[1];
$order_id = mb_strstr($order_id, " ", true)!==false ? mb_strstr($order_id, " ", true) : $order_id;
}
$ret["cut"] = trim_str(trim($real_groupCode));
for ($i=2; $i < count($tmp_groupCode); $i++) {
if (strlen($tmp_groupCode[$i]) > 4) {
$real_groupCode .= "-";
$real_groupCode .= mb_strstr($tmp_groupCode[$i], "", true)!==false ? mb_strstr($tmp_groupCode[$i], "", true) : $tmp_groupCode[$i];
}
}
$real_groupCode = trim_groupCode(trim($real_groupCode));
return $real_groupCode;
$real_groupCode = trim_str(trim($real_groupCode));
$ret["all"] = $real_groupCode;
return $ret;
}
function trim_groupCode($groupCode)
function trim_str($groupCode)
{
return mb_ereg_replace('( | | )', '', $groupCode);
return mb_ereg_replace('( | |)', '', $groupCode);
}
/*!
* 转换字符集编码
@ -155,3 +162,10 @@ function characet($data, $targetCharset) {
}
return $data;
}
function real_phone_number($phone, $nation_code)
{
$nation_str = "+" . $nation_code;
$cut_nation = str_replace($nation_str, "", $phone);
return mb_ereg_replace('[\D]', '', $cut_nation);
}

@ -0,0 +1,38 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Trippest
{
protected $ci;
public function __construct()
{
$this->ci =& get_instance();
}
public function tour_name($pag_code)
{
$name = "";
switch ($pag_code) {
case 'BJSIC-41':
$name = "One Day Beijing Highlights Tour";
break;
case 'BJSIC-42':
$name = "Two-Day Beijing Boutique Small Group Tour";
break;
case 'BJSIC-43':
$name = "Three-Day Beijing Discovery Tour";
break;
default:
# code...
break;
}
return $name;
}
}
/* End of file trippest.php */
/* Location: ./third_party/trippestOrderSync/libraries/trippest.php */

@ -64,6 +64,8 @@ class OrderFinance_model extends CI_Model {
/**
* 拼团号下的所有订单
* * 仅包价线路产品
* * 2018-10-10 增加按COLD_PersonNum降序排序, 计算拼团人数时按多的算.
* 180217342 订单中2人参加两个项目拼同一个团但是人数不同
*/
public function get_all_combine_order($combineNo="", $processed_code=array())
{
@ -74,15 +76,16 @@ class OrderFinance_model extends CI_Model {
,PAG_Code ,pag_sub.PAGS_CN_Title, cold.COLD_StartDate,PAG_DefaultVEI_SN
,COLD_PersonNum ,COLD_ChildNum , cold.COLD_StartDate,COLD_EndDate, cold.COLD_TotalPrice
--,PAG_Title
,(select count(1) from GroupCombineInfo where gci_gri_sn=coli_gri_sn) as combine_cnt
from GroupCombineInfo gci
inner join BIZ_ConfirmLineInfo coli on gci.GCI_GRI_SN=COLI_GRI_SN
inner join BIZ_ConfirmLineInfo coli on gci.GCI_GRI_SN=COLI_GRI_SN and coli.COLI_State NOT IN (30,40,50)
inner join BIZ_ConfirmLineDetail cold on cold.COLD_COLI_SN=coli.COLI_SN
and cold.COLD_ServiceType='D' and cold.DeleteFlag=0 and COLD_PlanVEI_SN in (1343,29188,30548,30016)
left join BIZ_PackageInfo pag on PAG_SN=COLD_ServiceSN
left join BIZ_PackageInfoSub pag_sub on pag_sub.PAGS_SN=COLD_ServiceSN2
where gci.GCI_combineNo =?
$processed_sql
order by GCI_combineNo,cold.COLD_StartDate";
order by GCI_combineNo asc,cold.COLD_StartDate asc,cold.COLD_PersonNum desc";
return $this->HT->query($sql, array($combineNo))->result();
}
@ -165,6 +168,9 @@ class OrderFinance_model extends CI_Model {
/** 获取产品信息:产品名称,供应商等 */
public function get_pag_info($PAG_SN_str="")
{
if ($PAG_SN_str=="") {
return array();
}
$sql = "SELECT pag.PAG_SN,PAG_Code,PAG_DefaultVEI_SN,PAG_Title,vei2.VEI2_CompanyBN
from BIZ_PackageInfo pag
inner join VEndorInfo2 vei2 on VEI2_VEI_SN=PAG_DefaultVEI_SN and VEI2_LGC=2
@ -201,9 +207,15 @@ class OrderFinance_model extends CI_Model {
}
/** 判断各种项目的报表是否已存在 */
public function report_tour_exists($coli_id=null, $tourCode=null)
public function report_tour_exists($coli_id=null, $tourCode=null, $tourBz=null)
{
$sql = "SELECT top 1 ordernumber from report_tour where ordernumber=? and tourCode=?";
$sql = "SELECT top 10 ordernumber from report_tour where ordernumber=? and tourCode=? ";
if ($tourBz) {
$tourBz = mb_ereg_replace('[^a-zA-Z0-9\-\[\]]', '', strstr($tourBz, ",", true));
$tourBz = str_replace("[", "[[]", $tourBz);
$sql .= " and (tourBz like '%" . $this->HT->escape_like_str($tourBz) . "%'
OR tourBz='') ";
}
$num_rows = $this->HT->query($sql, array($coli_id, $tourCode))->num_rows();
return $num_rows>0;
}
@ -230,13 +242,20 @@ class OrderFinance_model extends CI_Model {
public function insert_report_tour_tulanduo($report_tour_arr=array())
{
foreach ($report_tour_arr as $krt => $vrt) {
if ($this->report_tour_exists($vrt['ordernumber'], $vrt['tourCode']) === TRUE) {
$where = " ordernumber='" . $vrt['ordernumber'] . "' AND tourCode='" . $vrt['tourCode'] . "'";
$update_sql = $this->HT->update_string('tourmanager.dbo.Report_Tour', $vrt, $where);
$this->HT->query($update_sql);
} else {
$this->HT->insert('tourmanager.dbo.Report_Tour', $vrt);
$tourBz_tmp = "";
if ($this->report_tour_exists($vrt['ordernumber'], $vrt['tourCode'], $vrt['tourBZ']) === TRUE) {
$where = " ordernumber='" . $vrt['ordernumber'] . "' AND tourCode='" . $vrt['tourCode'] . "' ";
$tourBz_tmp = mb_ereg_replace('[^a-zA-Z0-9\-\[\]]', '', strstr($vrt['tourBZ'], ",", true));
$tourBz_tmp = str_replace("[", "[[]", $tourBz_tmp);
$where .= " AND (tourBZ like '%" . $this->HT->escape_like_str($tourBz_tmp) . "%'
OR tourBZ='') ";
$delete_sql = "DELETE FROM tourmanager.dbo.Report_Tour where " . $where;
// $update_sql = $this->HT->update_string('tourmanager.dbo.Report_Tour', $vrt, $where);
$this->HT->query($delete_sql);
}
// else {
$this->HT->insert('tourmanager.dbo.Report_Tour', $vrt);
// }
}
return TRUE;
}
@ -343,8 +362,9 @@ class OrderFinance_model extends CI_Model {
{
$other_tour_cost = $this->get_report_tour_others_cost($coli_sn);
foreach ($other_tour_cost as $kotc => $votc) {
if ($this->report_tour_exists($votc->ordernumber, $votc->tourCode) === TRUE) {
if ($this->report_tour_exists($votc->ordernumber, $votc->tourCode, $votc->tourBZ) === TRUE) {
$where = " ordernumber='" . $votc->ordernumber . "' AND tourCode='" . $votc->tourCode . "'";
$where .= " AND tourBZ='" . $votc->tourBZ . "' ";
$update_sql = $this->HT->update_string('tourmanager.dbo.Report_Tour', json_decode(json_encode($votc), TRUE), $where);
$this->HT->query($update_sql);
} else {

@ -131,10 +131,14 @@ class Orders_model extends CI_Model {
*/
public function get_groupCombineInfo($coli_sn=0, $get_vendorID=null, $startDate=null, $endDate=NULL)
{
$createTime_format = date('H')>12 ? 'Y-m-d 13:00:00' : 'Y-m-d 00:00:00';
$sql = "SELECT top 1 coli.COLI_ID, coli.COLI_SN, coli.COLI_GRI_SN, cold.COLD_SN, coli.COLI_OrderDetailText, coli.COLI_Memo,coli.COLI_State,coli.COLI_OPI_ID,
cold.COLD_PlanVEI_SN, gci.*,'0' as 'isHistory'
cold.COLD_PlanVEI_SN, cold.COLD_MemoText, gci.*,'0' as 'isHistory'
FROM GroupCombineInfo gci
LEFT JOIN BIZ_ConfirmLineInfo coli ON coli.COLI_GRI_SN=gci.GCI_GRI_SN --and coli.COLI_State NOT IN ('30','40','50')
LEFT JOIN BIZ_ConfirmLineInfo coli ON coli.COLI_GRI_SN=gci.GCI_GRI_SN
--and coli.COLI_State NOT IN ('30','40','50')
and coli.COLI_State<>50
and (select OPI_DEI_SN from OperatorInfo where OPI_SN=coli.COLI_OPI_ID)=30
LEFT JOIN BIZ_ConfirmLineDetail cold ON cold.COLD_COLI_SN=coli.COLI_SN
WHERE 1=1 ";
if ($coli_sn !== 0) {
@ -144,33 +148,52 @@ class Orders_model extends CI_Model {
$sql .= " and GCI_VendorOrderId='$get_vendorID' ";
}
if ($startDate !== NULL) {
$sql .= " and gci.GCI_travelDate between '$startDate' and '$endDate' and gci.GCI_createTime < '" . date('Y-m-d') . "' ";
$sql .= " and gci.GCI_travelDate between '$startDate' and '$endDate'
and gci.GCI_createTime < '" . date($createTime_format) . "' ";
}
// 近期的订单同步完成之后, 同步历史数据
$sql .= " UNION ALL ";
$sql .= " SELECT top 1 coli.COLI_ID, coli.COLI_SN, coli.COLI_GRI_SN, cold.COLD_SN, coli.COLI_OrderDetailText, coli.COLI_Memo,coli.COLI_State,coli.COLI_OPI_ID,
cold.COLD_PlanVEI_SN, gci.*,'1' as 'isHistory'
from GroupCombineInfo gci
inner join GRoupInfo on GRI_SN=GCI_GRI_SN and GRI_No<>''
LEFT JOIN BIZ_ConfirmLineInfo coli ON coli.COLI_GRI_SN=gci.GCI_GRI_SN
LEFT JOIN BIZ_ConfirmLineDetail cold ON cold.COLD_COLI_SN=coli.COLI_SN
where
GCI_combineNo is not null and GCI_combineNo not in ('cancel','forbidden')
and GCI_leaveDate < '" . date('Y-m-d', strtotime("-7 days")) . "'
and GCI_combineNo not like '%取消%'
and not exists (
select GCOD_SN from GroupCombineOperationDetail gcod where gcod.GCOD_GCI_combineNo=GCI_combineNo
)
and 0 < (
select sum(isnull(COLD_PersonNum,0)+isnull(COLD_ChildNum,0)+isnull(COLD_BabyNum,0)) person from BIZ_ConfirmLineInfo
inner join BIZ_ConfirmLineDetail on COLD_COLI_SN=COLI_SN
where COLI_GRI_SN=gri_sn
) ";
// 这个sql很慢, 导致锁表, 分开处理
// $sql .= " UNION ALL ";
// $sql .= " SELECT top 1 coli.COLI_ID, coli.COLI_SN, coli.COLI_GRI_SN, cold.COLD_SN, coli.COLI_OrderDetailText, coli.COLI_Memo,coli.COLI_State,coli.COLI_OPI_ID,
// cold.COLD_PlanVEI_SN, cold.COLD_MemoText, gci.*,'1' as 'isHistory'
// from GroupCombineInfo gci
// inner join GRoupInfo on GRI_SN=GCI_GRI_SN and GRI_No<>''
// LEFT JOIN BIZ_ConfirmLineInfo coli ON coli.COLI_GRI_SN=gci.GCI_GRI_SN
// and coli.COLI_State<>50
// and (select OPI_DEI_SN from OperatorInfo where OPI_SN=coli.COLI_OPI_ID)=30
// LEFT JOIN BIZ_ConfirmLineDetail cold ON cold.COLD_COLI_SN=coli.COLI_SN
// where
// GCI_combineNo is not null and GCI_combineNo not in ('cancel','forbidden')
// and GCI_leaveDate < '" . date('Y-m-d', strtotime("-7 days")) . "'
// and gci.GCI_createTime < '" . date('Y-m-d') . "'
// and GCI_combineNo not like '%取消%'
// ";
$sql .= " ORDER BY isHistory ASC,GCI_createTime ASC ";
$query = $this->HT->query($sql);
return $query->result();
}
public function get_groupCombineInfo_finance()
{
$sql = " SELECT top 1 coli.COLI_ID, coli.COLI_SN, coli.COLI_GRI_SN, cold.COLD_SN, coli.COLI_OrderDetailText, coli.COLI_Memo,coli.COLI_State,coli.COLI_OPI_ID,
cold.COLD_PlanVEI_SN, cold.COLD_MemoText, gci.*,'1' as 'isHistory'
from GroupCombineInfo gci
inner join GRoupInfo on GRI_SN=GCI_GRI_SN and GRI_No<>''
LEFT JOIN BIZ_ConfirmLineInfo coli ON coli.COLI_GRI_SN=gci.GCI_GRI_SN
and coli.COLI_State<>50
and (select OPI_DEI_SN from OperatorInfo where OPI_SN=coli.COLI_OPI_ID)=30
LEFT JOIN BIZ_ConfirmLineDetail cold ON cold.COLD_COLI_SN=coli.COLI_SN
where
GCI_combineNo is not null and GCI_combineNo not in ('cancel','forbidden')
and GCI_travelDate between '2018-06-01' and '2018-06-30 23:59:59'
and gci.GCI_createTime < '2018-10-24'
and GCI_combineNo not like '%取消%'
";
$sql .= " ORDER BY isHistory ASC,GCI_createTime ASC ";
$query = $this->HT->query($sql);
return $query->result();
}
/*!
* 获取团计划信息的记录 - 根据地接社订单id
* 计划变更和订单状态确认时使用
@ -534,7 +557,7 @@ class Orders_model extends CI_Model {
inner join BIZ_ConfirmLineDetail cold on cold.COLD_COLI_SN=COLI_SN --and COLI_State not in (30,40,50)
LEFT JOIN GRoupInfo gri ON coli.COLI_GRI_SN=gri.GRI_SN and GRI_OrderType=227002
and gri.GRI_operator<>435 and gri.GRI_operator is not null
WHERE coli.COLI_Department=30 and gri.GRI_No LIKE '%$code%'
WHERE (select OPI_DEI_SN from OperatorInfo where OPI_SN=COLI_OPI_ID)=30 and gri.GRI_No LIKE '%$code%'
order by COLI_SN desc"; // and gri.GRI_Name like '%$NoName%'
$query = $this->HT->query($sql);
if ($query->num_rows() > 0) {
@ -559,11 +582,12 @@ class Orders_model extends CI_Model {
coli.COLI_OrderDetailText,
coli.COLI_State,coli.COLI_OPI_ID,coli.COLI_Price,coli.COLI_CUrrency
GRI_OPI_ID,GRI_operator,GRI_No,GRI_Name,
coli.COLI_Memo
coli.COLI_Memo,cold.COLD_MemoText
FROM BIZ_ConfirmLineInfo coli
inner join BIZ_ConfirmLineDetail cold on cold.COLD_COLI_SN=COLI_SN
left JOIN GRoupInfo gri ON coli.COLI_GRI_SN=gri.GRI_SN and GRI_OrderType=227002
WHERE coli.COLI_Department=30 and gri.GRI_No LIKE '%$code%'
WHERE (select OPI_DEI_SN from OperatorInfo where OPI_SN=COLI_OPI_ID)=30
and coli.COLI_State<>50 and gri.GRI_No LIKE '%$code%'
order by case COLI_OPI_ID when 435 then 1 else 0 end asc,COLI_SN desc";
$query = $this->HT->query($sql);
return $query->result();
@ -1261,6 +1285,7 @@ class Orders_model extends CI_Model {
public $GAI_SSJE;
public $GAI_SSDate;
public $GAI_Operator;
public $GAI_VEI_SN;
public $GAI_Memo="";
public function biz_groupaccountinfo_save()
{
@ -1276,6 +1301,7 @@ class Orders_model extends CI_Model {
. " GAI_SSJE, \n"
. " GAI_SSDate, \n"
. " GAI_Operator, \n"
. " GAI_VEI_SN, \n"
. " GAI_Memo \n"
. " ) \n"
. "VALUES \n"
@ -1290,6 +1316,7 @@ class Orders_model extends CI_Model {
. " ?, \n"
. " ?, \n"
. " ?, \n"
. " ?, \n"
. " ? \n"
. " )";
$query = $this->HT->query($sql, array(
@ -1303,6 +1330,7 @@ class Orders_model extends CI_Model {
,$this->GAI_SSJE
,$this->GAI_SSDate
,$this->GAI_Operator
,$this->GAI_VEI_SN
,$this->GAI_Memo
));
return $query;

@ -24,11 +24,60 @@ class Orders_query extends CI_Model {
return 0;
}
public function get_order_vendorplan($COLI_ID)
{
$sql = "SELECT COLI_GroupCode,COLI_OPI_ID,vas.*
from BIZ_ConfirmLineInfo coli
left join VendorArrangeState vas on VAS_GRI_SN=COLI_GRI_SN
where COLI_GroupCode like '%" . $this->HT->escape_like_str($COLI_ID) . "%'
OR COLI_ID like '%" . $this->HT->escape_like_str($COLI_ID) . "%'
OR COLI_PriceMemo like '%" . $this->HT->escape_like_str($COLI_ID) . "%'
";
return $this->HT->query($sql)->result();
}
public function get_order_detail($GRI_SN)
{
$sql = "SELECT
pag2.PAG2_Name
,(select PAG_code from biz_packageinfo where pag_sn=COLD_ServiceSN) as pag_code
,pags.PAGS_Direction,pags.PAGS_describ
,poi.POI_Hotel,poi.POI_HotelAddress,poi.POI_HotelPhone
,poi.POI_AirPort,poi.POI_FlightsNo
,GUT_FirstName,GUT_LastName
,cold.*,coli.*
from BIZ_ConfirmLineDetail cold
inner join BIZ_ConfirmLineInfo coli on COLI_SN=COLD_COLI_SN and cold.DeleteFlag=0
inner join BIZ_PackageOrderInfo poi on poi.POI_COLD_SN=COLD_SN
inner join BIZ_GUEST g on g.GUT_SN=COLI_GUT_SN
left join BIZ_PackageInfo2 pag2 on pag2.PAG2_PAG_SN=COLD_ServiceSN and pag2.PAG2_LGC=1
left join BIZ_PackageInfoSub pags on pags.PAGS_SN=cold.COLD_ServiceSN2
where COLI_GRI_SN=$GRI_SN
order by COLD_StartDate ";
return $this->HT->query($sql)->result();
}
public function get_plan_tourguide($GRI_SN=0)
{
$GRI_SN = $GRI_SN==NULL ? 0 : $GRI_SN;
$sql = "SELECT tgi_info.TGI_SN,tgi_info.TGI2_Name,tgi_info.TGI_Mobile
,eoi.EOI_GetDate,eoi.EOI_Date,eoi.EOI_VEI_SN
from Eva_ObjectInfo eoi
left join
( select TGI_SN,TGI_Mobile,TGI2_Name from TouristGuideInfo tgi
left join TouristGuideInfo2 tgi2 on TGI2_TGI_SN=TGI_SN and TGI2_LGC=1
) as tgi_info on tgi_info.TGI_SN=eoi.EOI_ObjSN
where eoi.EOI_Type=3 and EOI_gri_sn=$GRI_SN
order by eoi.EOI_GetDate ";
return $this->HT->query($sql)->result();
}
function get_package_order($COLI_ID)
{
$order_info_sql = "SELECT
GCI_SN,GCI_VendorOrderId,GCI_combineNo
,COLI_SN,COLI_ID,COLD_SN,COLI_GroupCode,COLI_OPI_ID,COLI_OrderDetailText
,(select PAG_code from biz_packageinfo where pag_sn=COLD_ServiceSN) as pag_code
,COLI_SN,COLI_ID,COLD_SN,COLI_GroupCode,COLI_OPI_ID,COLI_OrderDetailText,COLI_PriceMemo
,COLD_ServiceSN,COLD_PersonNum,COLD_ChildNum,COLD_StartDate,COLD_EndDate,cold.COLD_MemoText
,pags.PAGS_Direction,pags.PAGS_describ
,pag2.PAG2_Name
@ -44,18 +93,11 @@ class Orders_query extends CI_Model {
left join BIZ_PackageInfoSub pags on pags.PAGS_SN=cold.COLD_ServiceSN2
where COLI_GroupCode like '%" . $this->HT->escape_like_str($COLI_ID) . "%'
OR COLI_ID like '%" . $this->HT->escape_like_str($COLI_ID) . "%'
OR COLI_PriceMemo like '%" . $this->HT->escape_like_str($COLI_ID) . "%'
order by COLD_StartDate asc";
// OR COLI_ID like '%" . $this->HT->escape_like_str($COLI_ID) . "%'
$order_info_query = $this->HT->query($order_info_sql);
$ret = $order_info_query->result();
// if ($order_info_query->num_rows() > 0) {
// $operation_sql = "SELECT gcod.*
// from GroupCombineOperationDetail gcod
// where GCOD_GCI_combineNo=?
// and gcod.GCOD_operationType in ('touristCarOperations','guiderOperations')";
// $operation_info = $this->HT->query($operation_sql, array($ret['order_info'][0]->GCI_combineNo));
// $ret['operation_info'] = $operation_info->result();
// }
return $ret;
}

@ -0,0 +1,160 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Send_operation_model extends CI_Model {
function __construct() {
parent::__construct();
$this->HT = $this->load->database('HT', TRUE);
$this->info = $this->load->database('INFO', TRUE);
}
public function daytour_order_ready_for_send($COLI_ID="", $date, $time_flag="no_send_state")
{
$today = date('Y-m-d 16:00:00');
switch ($time_flag) {
case 'try1':
$send_state = " ";
break;
case 'try2':
$send_state = " and (TPSL_sendState=1 OR TPSL_logTime > '$today') ";
break;
case 'handle':
$send_state = " and (TPSL_sendState=1) ";
break;
case '':
default:
$send_state = "";
break;
}
$send_state_sql = " and not exists (
select TPSL_SN from InfoManager.dbo.trippest_sms_log
where TPSL_COLI_SN=coli.COLI_SN
$send_state
) ";
$top = " TOP 1 ";
$sms_state = "";
if ($time_flag == "no_send_state") {
$send_state_sql = "";
$top = "";
$sms_state = " ,(SELECT top 1 TPSL_sendState from InfoManager.dbo.trippest_sms_log
where TPSL_COLI_SN=coli.COLI_SN
and TPSL_sendContent like '%'+CONVERT(VARCHAR(10),CONVERT(DATE, COLD_StartDate))+'%'
order by TPSL_sendState desc
) as send_state";
}
$search_sql = " AND COLD_StartDate ='$date' ";
if ($COLI_ID !== "") {
$search_sql = " AND COLI_ID='" . $COLI_ID . "'";
}
$sql = "SELECT $top
COLI_GroupCode,COLI_SN,COLI_ID
$sms_state
,GUT_POST,GUT_TEL
,PAG_Code
,g.GUT_FirstName+' '+g.GUT_LastName guest_name
,(
select top 1 GCOD_dutyName+'@'+GCOD_dutyTel+'@'+convert(varchar(20),GCOD_creatTime)+'@'+convert(varchar(20),GCI_createTime)
from GroupCombineInfo
inner join GroupCombineOperationDetail on GCOD_GCI_combineNo=GCI_combineNo
AND GCI_combineNo not IN ('cancel','forbidden')
where GCI_GRI_SN=COLI_GRI_SN
AND GCOD_operationType='guiderOperations'
) as gcod
,(
select top 1 TGI2_Name+'@'+TGI_Mobile from Eva_ObjectInfo
left join
( select TGI_SN,TGI_Mobile,TGI2_Name from TouristGuideInfo tgi
left join TouristGuideInfo2 tgi2 on TGI2_TGI_SN=TGI_SN and TGI2_LGC=1
) as tgi_info on tgi_info.TGI_SN=EOI_ObjSN
where EOI_GRI_SN=COLI_GRI_SN and EOI_Type=3
) as eva
,COLD_StartDate
from BIZ_ConfirmLineInfo coli
inner join BIZ_ConfirmLineDetail cold on COLI_SN=COLD_COLI_SN
INNER JOIN BIZ_GUEST g ON g.GUT_SN=COLI_GUT_SN
and GUT_TEL is not null and GUT_TEL<>'' and GUT_POST<>''
INNER JOIN BIZ_PackageInfo pag ON pag.PAG_SN=COLD_ServiceSN
WHERE 1=1
and COLI_State not in (30,40,50)
$search_sql
AND '39009'<>PAG_ExtendType
$send_state_sql
and (exists (
select top 1 1 from GroupCombineInfo
inner join GroupCombineOperationDetail on GCOD_GCI_combineNo=GCI_combineNo
AND GCI_combineNo not IN ('cancel','forbidden')
where GCI_GRI_SN=COLI_GRI_SN
AND GCOD_operationType='guiderOperations'
)
OR exists (
select top 1 1 from Eva_ObjectInfo
where EOI_GRI_SN=COLI_GRI_SN and EOI_Type=3
)
)
ORDER BY COLD_StartDate, COLI_SN";
$query = $this->HT->query($sql);
return $query->result();
}
public function insert_trippest_sms_log($column)
{
$this->info->insert("trippest_sms_log", $column);
return $this->info->insert_id();
}
public function update_trippest_sms_log($where, $column)
{
if ($where == "" || empty($column)) {
return false;
}
$update_str = $this->info->update_string('trippest_sms_log', $column, $where);
$update_exc = $this->info->query($update_str);
return $update_exc;
}
/** 暂时不用了 */
public function if_order_sent($COLI_SN, $msgType='guide')
{
$sql = "SELECT *
FROM [infomanager].[dbo].[trippest_sms_log]
where [TPSL_COLI_SN]=$COLI_SN
and [TPSL_sendState]=1
and TPSL_msgType='$msgType'
";
return $this->info->query($sql)->row();
}
/*
* 发送邮件
*/
function SendMail($fromName, $fromEmail, $toName, $toEmail, $subject, $body) {
$sql = "INSERT INTO tourmanager.dbo.Email_AutomaticSend \n"
. " ( \n"
. " M_ReplyToName, M_ReplyToEmail, M_ToName, M_ToEmail, M_Title, M_Body, M_Web, \n"
. " M_FromName, M_State \n"
. " ) \n"
. "VALUES \n"
. " ( \n"
. " ?, ?, ?, ?, ?, N?, ?, ?, 0 \n"
. " ) ";
$query = $this->info->query($sql,
array(substr($fromName, 0, 127), $fromEmail, substr($toName, 0, 127), $toEmail, $subject, $body, 'trippest SMS send fail', 'chinahighlighgts')
);
return $query;
}
function order_sms_list($COLI_SN=0)
{
$sql = "SELECT *
FROM [infomanager].[dbo].[trippest_sms_log]
where [TPSL_COLI_SN]=$COLI_SN
order by TPSL_logTime ";
return $this->HT->query($sql)->result();
}
}
/* End of file send_operation_model.php */
/* Location: ./webht/third_party/trippestOrderSync/models/send_operation_model.php */

@ -26,6 +26,7 @@ class Tulanduo_sync_model extends CI_Model {
*/
public function get_oldest_offset()
{
$ret_date = "";
$sql = "SELECT DISTINCT TOP 10 CAST(GCI_travelDate as DATE) old_date from GroupCombineInfo
order by old_date asc";
$all_date = $this->HT->query($sql)->result();
@ -37,11 +38,22 @@ class Tulanduo_sync_model extends CI_Model {
$d1 = new DateTime($all_date_arr[$i]);
$d2 = new DateTime($all_date_arr[$i-1]);
$date_diff = $d2->diff($d1);
if (intval($date_diff->format('%R%a')) > 1) {
return $all_date_arr[$i];
if (intval($date_diff->format('%R%a')) > 1 && !in_array($all_date_arr[$i], $this->empty_date()) ) {
$ret_date = $all_date_arr[$i];
break;
}
}
return $all_date_arr[0];
if ($ret_date==="") {
$ret_date = $all_date_arr[0];
}
return $ret_date;
}
private function empty_date()
{
return array(
"2018-02-06" // 2018-02-05 没有团
,"2017-01-17"
);
}
/*!
* 图兰朵订单在HT内的信息

@ -0,0 +1,25 @@
<table class="table table-bordered table-hover">
<thead>
<tr>
<th>发送时间</th>
<th>失败原因</th>
</tr>
</thead>
<tbody>
<?php
foreach ($list as $key => $value) {
$tmp_msg = null;
if ($value->TPSL_callbackJson == null) {
$tmp_msg = "无导游安排";
} else {
$tmp_msg = json_decode($value->TPSL_callbackJson);
$tmp_msg = $tmp_msg->errmsg;
}
?>
<tr>
<td> <?php echo $value->TPSL_logTime; ?> </td>
<td> <?php echo $tmp_msg; ?> </td>
</tr>
<?php } ?>
</tbody>
</table>

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save