diff --git a/webht/third_party/trippestOrderSync/models/orderFinance_model.php b/webht/third_party/trippestOrderSync/models/orderFinance_model.php index f95fcb82..bbd89829 100644 --- a/webht/third_party/trippestOrderSync/models/orderFinance_model.php +++ b/webht/third_party/trippestOrderSync/models/orderFinance_model.php @@ -16,11 +16,9 @@ class OrderFinance_model extends CI_Model { coli.COLI_WebCode as Agenter, coli.COLI_ApplyDate as reservedate ,coli.COLI_Cost as basemoney - ,coli.COLI_Price*6.77 OrderPrice - -- ,dbo.ConvertToRMB('USD',ISNULL(coli.COLI_Price,0)) OrderPrice + ,dbo.ConvertToRMB('USD',ISNULL(coli.COLI_Price,0)) OrderPrice ,gri.GRI_SN ,gri.GRI_No as TuanName ,opi.OPI_Name as ChinaName,opi.OPI_SN as operater,opi.OPI_DEI_SN - -- ,GETDATE() as builddate ,gut.GUT_NationalityID,COI2_Country as country ,( select top 1 BPE_GuestType @@ -204,14 +202,13 @@ class OrderFinance_model extends CI_Model { /** 图兰朵包价线路产品 */ public function insert_report_tour_tulanduo($report_tour_arr=array()) { -$this->HT2 = $this->load->database('INFO', TRUE); // test 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->HT2->update_string('tourmanager.dbo.Report_Tour', $vrt, $where); - $this->HT2->query($update_sql); + $update_sql = $this->HT->update_string('tourmanager.dbo.Report_Tour', $vrt, $where); + $this->HT->query($update_sql); } else { - $this->HT2->insert('tourmanager.dbo.Report_Tour', $vrt); + $this->HT->insert('tourmanager.dbo.Report_Tour', $vrt); } } return TRUE; @@ -220,18 +217,17 @@ $this->HT2 = $this->load->database('INFO', TRUE); // test /** 火车票 */ public function insert_report_train($coli_sn=0) { -$this->HT2 = $this->load->database('INFO', TRUE); // test $train_cost = $this->get_train_cost($coli_sn); foreach ($train_cost as $ktc => $vtc) { if ($this->report_train_exists($vtc->OrderNumber, $vtc->TrainNo) === TRUE) { $where = " OrderNumber='" . $vtc->OrderNumber . "' AND TrainNo='" . $vtc->TrainNo . "' "; - $update_sql = $this->HT2->update_string('tourmanager.dbo.report_Train', json_decode(json_encode($vtc), TRUE), $where); - $this->HT2->query($update_sql); + $update_sql = $this->HT->update_string('tourmanager.dbo.report_Train', json_decode(json_encode($vtc), TRUE), $where); + $this->HT->query($update_sql); } else { - $this->HT2->insert('tourmanager.dbo.report_Train', json_decode(json_encode($vtc), TRUE)); + $this->HT->insert('tourmanager.dbo.report_Train', json_decode(json_encode($vtc), TRUE)); } } - return $this->HT2->query("SELECT * from tourmanager.dbo.report_Train inner join BIZ_ConfirmLineInfo on COLI_ID=OrderNumber WHERE COLI_SN=$coli_sn order by OrderID desc")->result(); + return $this->HT->query("SELECT * from tourmanager.dbo.report_Train inner join BIZ_ConfirmLineInfo on COLI_ID=OrderNumber WHERE COLI_SN=$coli_sn order by OrderID desc")->result(); } public function get_train_cost($coli_sn=0) { @@ -244,10 +240,9 @@ $this->HT2 = $this->load->database('INFO', TRUE); // test isnull(COLD_PersonNum,0)+ISNULL(COLD_ChildNum,0) as PassengerNo, adultcost adultPrice, COLD_TotalCost as TotalCost, - COLD_TotalPrice*6.77 as TotalPrice, --test + dbo.ConvertToRMB('USD',COLD_TotalPrice) as TotalPrice, SUBSTRING(VEI2_CompanyBN,1,50) TrainProvide, - ' ' as TrainBZ, -- test - -- case when dbo.GetBIZTrainVEIDebt(COLD_SN)='YES' then '挂账' else ' ' end as TrainBZ, + case when dbo.GetBIZTrainVEIDebt(COLD_SN)='YES' then '挂账' else ' ' end as TrainBZ, 0 as orderstats from BIZ_ConfirmLineDetail inner join BIZ_ConfirmLineInfo on COLI_SN=COLD_COLI_SN @@ -262,18 +257,17 @@ $this->HT2 = $this->load->database('INFO', TRUE); // test /** 酒店 */ public function insert_report_hotel($coli_sn=0) { -$this->HT2 = $this->load->database('INFO', TRUE); // test $hotel_cost = $this->get_hotel_cost($coli_sn); foreach ($hotel_cost as $khc => $vhc) { if ($this->report_room_exists($vhc->ordernumber, $vhc->hotelName) === TRUE) { $where = " ordernumber='" . $vhc->ordernumber . "' AND hotelName='" . $vhc->hotelName . "' "; - $update_sql = $this->HT2->update_string('tourmanager.dbo.report_room', json_decode(json_encode($vhc), TRUE), $where); - $this->HT2->query($update_sql); + $update_sql = $this->HT->update_string('tourmanager.dbo.report_room', json_decode(json_encode($vhc), TRUE), $where); + $this->HT->query($update_sql); } else { - $this->HT2->insert('tourmanager.dbo.report_room', json_decode(json_encode($vhc), TRUE)); + $this->HT->insert('tourmanager.dbo.report_room', json_decode(json_encode($vhc), TRUE)); } } - return $this->HT2->query("SELECT * from tourmanager.dbo.report_room inner join BIZ_ConfirmLineInfo on COLI_ID=ordernumber WHERE COLI_SN=$coli_sn order by orderId desc")->result(); + return $this->HT->query("SELECT * from tourmanager.dbo.report_room inner join BIZ_ConfirmLineInfo on COLI_ID=ordernumber WHERE COLI_SN=$coli_sn order by orderId desc")->result(); } public function get_hotel_cost($coli_sn) { @@ -294,13 +288,12 @@ $this->HT2 = $this->load->database('INFO', TRUE); // test COLD_Count roomnumber, isnull(HOI_ExtraNum,0) AS ExtraBedNumber, COLD_DayCount=DATEDIFF(DAY,COLD_StartDate,COLD_EndDate) as jianyeshu, - COLD_TotalCost jianyecost, -- test - -- COLD_TotalCost*1.0/dbo.ZeroToOne(DATEDIFF(DAY,COLD_StartDate,COLD_EndDate)) as jianyecost, + COLD_TotalCost*1.0/dbo.ZeroToOne(DATEDIFF(DAY,COLD_StartDate,COLD_EndDate)) as jianyecost, 0 as ExtraBedCost, 0 as ExtraBedPrice, COLD_TotalCost roomcost, - COLD_TotalPrice*6.77 as roomprice, - (COLD_TotalPrice/1.03*6.77)-COLD_TotalCost as roomprofit, + dbo.ConvertToRMB('USD',COLD_TotalPrice) as roomprice, + dbo.ConvertToRMB('USD',(COLD_TotalPrice/1.03))-COLD_TotalCost as roomprofit, SUBSTRING(VendorInfo2.VEI2_CompanyBN,1,50) AS roomprovide, SUBSTRING(COLD_Describe,1,150) roombz, 0 as orderstats @@ -325,10 +318,10 @@ $this->HT2 = $this->load->database('INFO', TRUE); // test foreach ($other_tour_cost as $kotc => $votc) { if ($this->report_tour_exists($votc->ordernumber, $votc->tourCode) === TRUE) { $where = " ordernumber='" . $votc->ordernumber . "' AND tourCode='" . $votc->tourCode . "'"; - $update_sql = $this->HT2->update_string('tourmanager.dbo.Report_Tour', json_decode(json_encode($votc), TRUE), $where); - $this->HT2->query($update_sql); + $update_sql = $this->HT->update_string('tourmanager.dbo.Report_Tour', json_decode(json_encode($votc), TRUE), $where); + $this->HT->query($update_sql); } else { - $this->HT2->insert('tourmanager.dbo.Report_Tour', json_decode(json_encode($votc), TRUE)); + $this->HT->insert('tourmanager.dbo.Report_Tour', json_decode(json_encode($votc), TRUE)); } } @@ -366,10 +359,8 @@ $this->HT2 = $this->load->database('INFO', TRUE); // test ORDER BY PKP_PriceGrade ) as tourCostRSx, dbo.BIZ_ConfirmLineDetail.COLD_TotalCost tourcost, - -- dbo.ConvertToRMB('USD',dbo.BIZ_ConfirmLineDetail.COLD_TotalPrice) tourPrice, - -- dbo.ConvertToRMB('USD',dbo.BIZ_ConfirmLineDetail.COLD_TotalPrice)-dbo.BIZ_ConfirmLineDetail.COLD_TotalCost as tourProfit, - dbo.BIZ_ConfirmLineDetail.COLD_TotalPrice*6.77 tourPrice, - (dbo.BIZ_ConfirmLineDetail.COLD_TotalPrice*6.77)-dbo.BIZ_ConfirmLineDetail.COLD_TotalCost as tourProfit, + dbo.ConvertToRMB('USD',dbo.BIZ_ConfirmLineDetail.COLD_TotalPrice) tourPrice, + dbo.ConvertToRMB('USD',dbo.BIZ_ConfirmLineDetail.COLD_TotalPrice)-dbo.BIZ_ConfirmLineDetail.COLD_TotalCost as tourProfit, SUBSTRING(isnull(dbo.VEndorInfo2.VEI2_CompanyBN,'.'),1,50) as tourProvide, SUBSTRING(dbo.BIZ_ConfirmLineDetail.COLD_Describe,1,70) as tourBZ, 0 as orderstats @@ -387,28 +378,25 @@ $this->HT2 = $this->load->database('INFO', TRUE); // test /** 单团财务表 */ public function insert_report_order($report_order_arr=array(), $coli_sn=0, $gri_sn=0) { -$this->HT2 = $this->load->database('INFO', TRUE); // test if ( $this->report_order_exists($coli_sn, $gri_sn) === TRUE ) { $where = " ordernumber='" . $report_order_arr['ordernumber'] . "' "; - $update_sql = $this->HT2->update_string('tourmanager.dbo.report_order', $report_order_arr, $where); - $this->HT2->query($update_sql); + $update_sql = $this->HT->update_string('tourmanager.dbo.report_order', $report_order_arr, $where); + $this->HT->query($update_sql); } else { - $this->HT2->insert('tourmanager.dbo.report_order', $report_order_arr); + $this->HT->insert('tourmanager.dbo.report_order', $report_order_arr); } return $this->get_report_order($report_order_arr['ordernumber']); } public function get_report_order($coli_id=0) { -$this->HT2 = $this->load->database('INFO', TRUE); // test - return $this->HT2->query("SELECT top 1 * from tourmanager.dbo.report_order WHERE ordernumber='$coli_id' order by orderID desc")->row(); + return $this->HT->query("SELECT top 1 * from tourmanager.dbo.report_order WHERE ordernumber='$coli_id' order by orderID desc")->row(); } public function convert_to_RMB($money=0, $fromCurrency='USD') { -$this->HT2 = $this->load->database('INFO', TRUE); // test // [dbo].[ConvertToRMB](@TargetCurrency varchar(6), @SourceMoney decimal(18,5)) - return $this->HT2->query("SELECT tourmanager.dbo.[ConvertToRMB]('$fromCurrency',$money) as rmb ")->row()->rmb; + return $this->HT->query("SELECT tourmanager.dbo.[ConvertToRMB]('$fromCurrency',$money) as rmb ")->row()->rmb; } public function get_report_order_xh()