diff --git a/webht/third_party/trippestOrderSync/controllers/TulanduoApi.php b/webht/third_party/trippestOrderSync/controllers/TulanduoApi.php index 4dd918a5..ba83d1d4 100644 --- a/webht/third_party/trippestOrderSync/controllers/TulanduoApi.php +++ b/webht/third_party/trippestOrderSync/controllers/TulanduoApi.php @@ -369,7 +369,7 @@ class TulanduoApi extends CI_Controller ,"GCI_leaveDate" => $detail_jsonResp->orderDetail->leaveDate ,"GCI_createTime" => date('Y-m-d H:i:s') ); - $this->Order_update->biz_groupcombineinfo_update($gci_update_column); + $gci_info = $this->Order_update->biz_groupcombineinfo_update($gci_update_column); /** GRoupInfo */ $coli_groupcode_ht = analysis_groupCode($getInfo_byGroupCode->COLI_GroupCode); $groupcode_ht = $coli_groupcode_ht['cut']; @@ -395,6 +395,12 @@ class TulanduoApi extends CI_Controller $new_memo = trim($detail_jsonResp->orderDetail->orderRemark)=="" ? $old_memo : $old_memo . " orderRemark\r\n" . $detail_jsonResp->orderDetail->orderRemark . "\r\n"; $old_detail = mb_strstr($coli_orderdetailtext, " operations", true)!==false ? mb_strstr($coli_orderdetailtext, " operations", true) : $coli_orderdetailtext; $new_detail = trim($allDetails_to_HT)=="" ? $old_detail : $old_detail . " operations\r\n" . $allDetails_to_HT . "\r\n"; + // 判断收款方并提示 + $finance_memo = ""; + if (intval($coli_opi_id) === 435 && in_array($gci_info->GCI_FromAgc, array("D目的地桂林组", "Trippest"))) { + $finance_memo .= "备注: 本订单组团社是渠道, 账单收款方应为地接社代收, 同步回来却是Trippest自营, 请注意核对.\r\n"; + $new_memo .= mb_strstr($new_memo, "orderRemark", true)!==false ? $finance_memo : ("orderRemark " . $finance_memo); + } // 团款总金额 // 渠道实收 $travel_fee = 0; @@ -691,6 +697,11 @@ class TulanduoApi extends CI_Controller $output_text = "Got order operations from TuLanDuo:" . $detail_jsonResp->orderDetail->orderId . ". " . $coli_id; log_message('error', $output_text); echo $output_text; + if (strval($order->isHistory) === '1') { + require_once('order_finance.php'); + $vendor_class = new Order_finance(); + $vendor_class->single_order_report($coli_sn); + } return; } diff --git a/webht/third_party/trippestOrderSync/controllers/order_finance.php b/webht/third_party/trippestOrderSync/controllers/order_finance.php index ee9bac2f..e4c06133 100644 --- a/webht/third_party/trippestOrderSync/controllers/order_finance.php +++ b/webht/third_party/trippestOrderSync/controllers/order_finance.php @@ -168,6 +168,7 @@ class Order_finance extends CI_Controller { $report_tour_pvt['tourProvide'] = mb_substr($cpvt->vendor_name, 0, 50); $report_tour_pvt['tourBZ'] = mb_substr($cpvt->comment, 0, 150); $report_tour_pvt['orderstats'] = 0; + $report_tour_pvt['RPT_COLD_SN'] = $cpvt->cold_sn[0]; // 成本详情 $report_tour_pvt['RPT_Car'] = $cpvt->cost_category['touristCarOperations']; $report_tour_pvt['RPT_Meal'] = $cpvt->cost_category['restraurantOperations']; @@ -196,6 +197,7 @@ class Order_finance extends CI_Controller { $cost_c['tourCostRsd'] = $cost->person_cost; $cost_c['tourCostRSx'] = $cost->person_cost; $cost_c['tourcost'] = $cost->order_cost[0]->order_cost_sum; + $cost_c['RPT_COLD_SN'] = $cost->order_cost[0]->COLD_SN; $cost_c_price = 0; foreach ($cost->order_cost as $koc => $coc) { if ($coc->PAG_code === $coc->real_code) { diff --git a/webht/third_party/trippestOrderSync/models/order_update.php b/webht/third_party/trippestOrderSync/models/order_update.php index bff88fd2..8b0bd495 100644 --- a/webht/third_party/trippestOrderSync/models/order_update.php +++ b/webht/third_party/trippestOrderSync/models/order_update.php @@ -53,7 +53,7 @@ class Order_update extends CI_Model { } $update_str = $this->HT->update_string('GroupCombineInfo', $column_data, $this->gci_where_update); $update_exc = $this->HT->query($update_str); - return $update_exc; + return $this->HT->query("SELECT top 1 * from GroupCombineInfo WHERE " . $this->gci_where_update)->row(); } /*! diff --git a/webht/third_party/trippestOrderSync/models/orders_model.php b/webht/third_party/trippestOrderSync/models/orders_model.php index a25828f3..e32fbaf3 100644 --- a/webht/third_party/trippestOrderSync/models/orders_model.php +++ b/webht/third_party/trippestOrderSync/models/orders_model.php @@ -176,7 +176,12 @@ class Orders_model extends CI_Model { public function get_groupCombineInfo_finance() { // return array(); // 历史数据已获取完毕 - $to_update_cost_date = date("Y-m-d", strtotime("-45 days")); + // $to_update_cost_date = date("Y-m-d", strtotime("-45 days")); + $to_update_month_begin = date('Y-m-01', strtotime("-4 months", strtotime(date("Y-m-d")))); + $to_update_month_end = date('Y-m-01', strtotime("-3 months", strtotime(date("Y-m-d")))); + $end_d = strtotime($to_update_month_end)-1; + $to_update_month_end = date("Y-m-d 23:59:59", $end_d); + $set_time = date("Y-m-d 00:00:00", strtotime("+50 days",$end_d)); $last_update_time = date("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, cold.COLD_MemoText, gci.*,'1' as 'isHistory' @@ -189,15 +194,15 @@ class Orders_model extends CI_Model { where GCI_combineNo is not null and GCI_combineNo not in ('cancel','forbidden') -- 45天前的订单 - and gci.gci_leaveDate = '$to_update_cost_date' + --and gci.gci_leaveDate = '$to_update_cost_date' -- 今天更新一次 and gci.GCI_createTime < '$last_update_time' -- 已生成账单的不再自动同步 and NOT exists ( select 1 from report_order where ordernumber=COLI_ID and orderstats=1 ) --- and GCI_travelDate between '2018-08-01' and '2018-08-31 23:59:59' --- and gci.GCI_createTime < '2018-12-06 14:00:00' + and GCI_travelDate between '$to_update_month_begin' and '$to_update_month_end' + and gci.GCI_createTime < '$set_time' and GCI_combineNo not like '%取消%' "; $sql .= " ORDER BY isHistory ASC,GCI_createTime ASC "; @@ -1280,8 +1285,8 @@ class Orders_model extends CI_Model { public function biz_groupaccountinfo_cut($coli_sn, $paytype) { $sql = "DELETE from BIZ_GroupAccountInfo - WHERE GAI_COLI_SN=? AND GAI_Type=? AND GAI_Operator = 435"; - $query = $this->HT->query($sql, array($coli_sn, $paytype)); + WHERE GAI_COLI_SN=? AND GAI_Operator = 435"; // AND GAI_Type=?, $paytype + $query = $this->HT->query($sql, array($coli_sn)); return $query; }