diff --git a/webht/third_party/trippestOrderSync/controllers/TulanduoApi.php b/webht/third_party/trippestOrderSync/controllers/TulanduoApi.php index cb5be68c..9118adc0 100644 --- a/webht/third_party/trippestOrderSync/controllers/TulanduoApi.php +++ b/webht/third_party/trippestOrderSync/controllers/TulanduoApi.php @@ -341,18 +341,18 @@ class TulanduoApi extends CI_Controller $getInfo_byGroupCode = $this->Orders_model->get_SN_by_groupCode($real_groupCode, $real_groupCode); } $groupSN = $getInfo_byGroupCode!==null ? $getInfo_byGroupCode->GRI_SN : $order->COLI_GRI_SN; - $coli_sn = $getInfo_byGroupCode!==null ? $getInfo_byGroupCode->COLI_SN : $order->COLI_SN; - $coli_id = $getInfo_byGroupCode!==null ? $getInfo_byGroupCode->COLI_ID : $order->COLI_ID; - $coli_memo = $getInfo_byGroupCode!==null ? $getInfo_byGroupCode->COLI_Memo : $order->COLI_Memo; - $coli_orderdetailtext = $getInfo_byGroupCode!==null ? $getInfo_byGroupCode->COLI_OrderDetailText : $order->COLI_OrderDetailText; - $coli_state = $getInfo_byGroupCode!==null ? + $coli_sn = isset($getInfo_byGroupCode->COLI_SN) ? $getInfo_byGroupCode->COLI_SN : $order->COLI_SN; + $coli_id = isset($getInfo_byGroupCode->COLI_SN) ? $getInfo_byGroupCode->COLI_ID : $order->COLI_ID; + $coli_memo = isset($getInfo_byGroupCode->COLI_SN) ? $getInfo_byGroupCode->COLI_Memo : $order->COLI_Memo; + $coli_orderdetailtext = isset($getInfo_byGroupCode->COLI_SN) ? $getInfo_byGroupCode->COLI_OrderDetailText : $order->COLI_OrderDetailText; + $coli_state = isset($getInfo_byGroupCode->COLI_SN) ? (intval($getInfo_byGroupCode->COLI_OPI_ID)===435 ? 9 : $getInfo_byGroupCode->COLI_State) : 9; - $cold_sn = $getInfo_byGroupCode!==null ? $getInfo_byGroupCode->COLD_SN : $order->COLD_SN; + $cold_sn = isset($getInfo_byGroupCode->COLI_SN) ? $getInfo_byGroupCode->COLD_SN : $order->COLD_SN; // HT 订单有重复时, 以图兰朵的团号为正确的订单, 原本已录入的设为无效 if ($getInfo_byGroupCode === null) { } elseif ($getInfo_byGroupCode->GRI_SN != $order->COLI_GRI_SN && in_array($order->GCI_FromAgc, array("D目的地桂林组", "Trippest"))) { - if ( $order->COLI_ID) { + if ( $order->COLI_ID && $order->COLI_ID != $getInfo_byGroupCode->COLI_ID) { $allDetails_to_HT .= "\r\n疑似重复,请更新订单状态:" . $order->COLI_ID; if (intval($order->COLI_OPI_ID) === 435 ) { $this->order_cancel($order->COLI_ID); @@ -386,10 +386,10 @@ class TulanduoApi extends CI_Controller } unset($vtf); } - $travel_fee = $getInfo_byGroupCode!==null ? + $travel_fee = isset($getInfo_byGroupCode->COLI_SN) ? (intval($getInfo_byGroupCode->COLI_OPI_ID)===435 ? $travel_fee : $getInfo_byGroupCode->COLI_Price) : $travel_fee; - $travel_fee_currency = $getInfo_byGroupCode!==null ? + $travel_fee_currency = isset($getInfo_byGroupCode->COLI_SN) ? (intval($getInfo_byGroupCode->COLI_OPI_ID)===435 ? $travel_fee_currency : $getInfo_byGroupCode->COLI_CUrrency) : $travel_fee_currency; $coli_update_column = array( @@ -401,16 +401,20 @@ class TulanduoApi extends CI_Controller ); $this->Order_update->biz_confirmlineinfo_update($coli_update_column); /** BIZ_ConfirmLineDetail */ // nothing to update + // query latest order detail + $latest_order_detail = $this->Orders_model->get_orderinfo_detail($coli_id); /** INSERT */ /*BIZ_BookPeople*/ if ($this->Orders_model->bookpeople_exist($cold_sn) === array()) { - foreach ($detail_jsonResp->orderDetail->customers as $kd => $vd) { - $this->Orders_model->BPE_FirstName = $vd->name; - $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(); - // BIZ_BookPeopleList - $this->Orders_model->biz_bookpeople_List_save($cold_sn, $this->Orders_model->BPE_SN); + 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_GuestType = $vd->peopleType=="成人" ? 1 : 2; + $this->Orders_model->BPE_Passport = $vd->documentNo; + $bpe_sn[] = $this->Orders_model->biz_book_people_save(); + // BIZ_BookPeopleList + $this->Orders_model->biz_bookpeople_List_save($cold_sn, $this->Orders_model->BPE_SN); + } } } /*BIZ_PackageOrderInfo*/ @@ -429,7 +433,7 @@ class TulanduoApi extends CI_Controller $auto_text = "dataAutoEnter "; // 删除旧的录入 $this->Orders_model->biz_groupaccountinfo_cut($coli_sn, $paytype); - if (isset($detail_jsonResp->orderDetail->travelFees) && ! in_array($order->GCI_FromAgc, array("D目的地桂林组", "Trippest")) ) { + if (isset($detail_jsonResp->orderDetail->travelFees) && intval($latest_order_detail[0]->COLI_OPI_ID===435) ) { foreach ($detail_jsonResp->orderDetail->travelFees as $ktf => $vtf) { // if ($vtf->reviewStatus == 0) { // 未审核的 // continue; @@ -449,7 +453,7 @@ class TulanduoApi extends CI_Controller } // 目的地项目组的订单为了避免重复录入, 外联会沟通录入, 这里不写入. todo // 代收 - if (isset($detail_jsonResp->orderDetail->replaceCollections) && ! in_array($order->GCI_FromAgc, array("D目的地桂林组", "Trippest")) ) { + if (isset($detail_jsonResp->orderDetail->replaceCollections) && intval($latest_order_detail[0]->COLI_OPI_ID===435) ) { foreach ($detail_jsonResp->orderDetail->replaceCollections as $krc => $vrc) { // if ($vrc->reviewStatus == 0) { // continue; @@ -468,7 +472,7 @@ class TulanduoApi extends CI_Controller } } // 代付 - if (isset($detail_jsonResp->orderDetail->replacePays) && ! in_array($order->GCI_FromAgc, array("D目的地桂林组", "Trippest")) ) { + if (isset($detail_jsonResp->orderDetail->replacePays) && intval($latest_order_detail[0]->COLI_OPI_ID===435) ) { foreach ($detail_jsonResp->orderDetail->replacePays as $krp => $vrp) { // if ($vrp->reviewStatus == 0) { // continue; @@ -830,7 +834,9 @@ log_message('error','in GCI ' . json_decode($resp)->responseData->orderId); $temp_array[0] = strrchr($temp_array[0], " ") ? mb_strstr($temp_array[0], " ",true) : $temp_array[0]; $tmp_groupCode = explode("-", trim($temp_array[0])); $real_groupCode = $tmp_groupCode[0] . "-"; - $real_groupCode .= mb_strstr($tmp_groupCode[1], "(", true)!==false ? mb_strstr($tmp_groupCode[1], "(", true) : $tmp_groupCode[1]; + if (isset($tmp_groupCode[1])) { + $real_groupCode .= mb_strstr($tmp_groupCode[1], "(", true)!==false ? mb_strstr($tmp_groupCode[1], "(", true) : $tmp_groupCode[1]; + } $real_groupCode = mb_ereg_replace('( )', '', trim($real_groupCode)); return $real_groupCode; } diff --git a/webht/third_party/trippestOrderSync/models/orders_model.php b/webht/third_party/trippestOrderSync/models/orders_model.php index 0e23532c..b74d9cbc 100644 --- a/webht/third_party/trippestOrderSync/models/orders_model.php +++ b/webht/third_party/trippestOrderSync/models/orders_model.php @@ -145,17 +145,18 @@ class Orders_model extends CI_Model { if ($startDate !== NULL) { $sql .= " and gci.GCI_travelDate between '$startDate' and '$endDate' "; // test } - $sql .= "UNION SELECT top 50 - 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.* - 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_ConfirmLineDetail cold ON cold.COLD_COLI_SN=coli.COLI_SN - WHERE 1=1 - and COLI_OPI_ID=435 and COLI_Price is null - order by GCI_travelDate"; - // -- and (GCI_combineNo='' or GCI_combineNo is null) - // -- and GCI_travelDate < GETDATE() + // $sql .= "UNION SELECT top 50 + // 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.* + // 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_ConfirmLineDetail cold ON cold.COLD_COLI_SN=coli.COLI_SN + // WHERE 1=1 + // and not exists ( + // select * from BIZ_GroupAccountInfo where GAI_COLI_SN=COLI_SN + // ) + // and COLI_OPI_ID=435 + // order by GCI_travelDate"; $query = $this->HT->query($sql); return $query->result(); } @@ -518,12 +519,14 @@ class Orders_model extends CI_Model { $gri_query = $this->HT->query($gri_sql); if ($gri_query->num_rows() > 0) { $this->GRI_SN = $gri_query->row()->GRI_SN; + $this->GRI_No = $gri_query->row()->GRI_No; $this->GRI_operator = $gri_query->row()->GRI_operator; $coli_sql = "SELECT top 1 COLI_SN,gri.GRI_SN,cold.COLD_PlanVEI_SN,cold.COLD_SN,coli.COLI_ID,coli.COLI_Memo, coli.COLI_OrderDetailText,coli.COLI_State,coli.COLI_OPI_ID,coli.COLI_Price,coli.COLI_CUrrency 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 - where COLI_GRI_SN=" . $this->GRI_SN; + where COLI_GroupCode like '%$code%' "; + // where COLI_GRI_SN=" . $this->GRI_SN; $coli_query = $this->HT->query($coli_sql); if ($coli_query->num_rows() > 0) { $this->BIZ_COLI_SN = $coli_query->row()->COLI_SN;