@ -176,18 +176,27 @@ class OrderFinance_model extends CI_Model {
}
/** 图兰朵包价线路产品 */
public function insert_report_tour_tulanduo($report_tour_arr=array())
public function insert_report_tour_tulanduo($report_tour_arr=array(), $update_flag=false )
{
$this->HT2 = $this->load->database('INFO', TRUE); // test
foreach ($report_tour_arr as $krt => $vrt) {
$this->HT2->insert('tourmanager.dbo.Report_Tour', $vrt);
if ($update_flag === 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);
} else {
$this->HT2->insert('tourmanager.dbo.Report_Tour', $vrt);
}
}
return TRUE;
}
/** 火车票 */
public function insert_report_train($coli_sn=0)
public function insert_report_train($coli_sn=0, $update_flag=false )
{
if ($update_flag === TRUE) {
return $this->update_report_train($coli_sn);
}
// INSERT INTO report_Train(
// OrderNumber,
// TrainNo,
@ -225,10 +234,46 @@ $this->HT2 = $this->load->database('INFO', TRUE); // test
return $this->HT->query($sql)->result();
// return $this->HT->query("SELECT top 1 * from tourmanager.dbo.report_Train inner join BIZ_ConfirmLineInfo on COLI_ID=OrderNumber WHERE COLI_SN=$coli_sn order by OrderID desc")->row();
}
public function update_report_train($coli_sn=0)
{
$this->HT2 = $this->load->database('INFO', TRUE); // test
$update_data = $this->get_train_cost($coli_sn);
$where = " OrderNumber='" . $update_data->OrderNumber . "' AND TrainNo='" . $update_data->TrainNo . "' ";
$update_sql = $this->HT2->update_string('tourmanager.dbo.report_Train', $update_data, $where);
return $this->HT2->query($update_sql);
}
public function get_train_cost($coli_sn=0)
{
$sql = "SELECT
dbo.BIZ_ConfirmLineInfo.COLI_ID OrderNumber,
FlightsNo TrainNo,
DepartureCity,
ArrivalCity,
left(convert(varchar,DepartureDate,120),10) as DepartureDate,
isnull(COLD_PersonNum,0)+ISNULL(COLD_ChildNum,0) as PassengerNo,
adultcost adultPrice,
COLD_TotalCost as TotalCost,
COLD_TotalPrice*6.77 as TotalPrice, --test
VEI2_CompanyBN TrainProvide,
' ' as TrainBZ, -- test
-- 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
inner join BIZ_FlightsOrderInfo on FOI_COLD_SN = COLD_SN
left join VEndorInfo2 on COLD_PlanVEI_SN = VEI2_VEI_SN and VEI2_LGC = 2
where COLD_COLI_SN = $coli_sn
and isnull(BIZ_ConfirmLineDetail.DeleteFlag,0)=0
and COLD_ServiceType = '2' ";
return $this->HT->query($sql)->row();
}
/** 酒店 */
public function insert_report_hotel($coli_sn=0)
public function insert_report_hotel($coli_sn=0, $update_flag=false )
{
if ($update_flag === TRUE) {
return $this->update_report_hotel($coli_sn);
}
// INSERT INTO report_room( ordernumber, hotelName, cityName, hotelStar, roomtype, starttime, endtime, roomnumber, ExtraBedNumber, jianyeshu, jianyecost, ExtraBedCost, ExtraBedPrice, roomcost, roomprice, roomprofit, roomprovide, roombz, orderstats)
$sql = "
SELECT coli_id,
@ -271,10 +316,63 @@ $this->HT2 = $this->load->database('INFO', TRUE); // test
return $this->HT->query($sql)->result();
// return $this->HT->query("SELECT top 1 * from tourmanager.dbo.report_room inner join BIZ_ConfirmLineInfo on COLI_ID=ordernumber WHERE COLI_SN=$coli_sn order by orderId desc")->row();
}
public function update_report_hotel($coli_sn)
{
$this->HT2 = $this->load->database('INFO', TRUE); // test
$update_data = $this->get_hotel_cost($coli_sn);
$where = " ordernumber='" . $update_data->ordernumber . "' AND hotelName='" . $update_data->hotelName . "' ";
$update_sql = $this->HT2->update_string('tourmanager.dbo.report_room', $update_data, $where);
return $this->HT2->query($update_sql);
}
public function get_hotel_cost($coli_sn)
{
$sql = "
SELECT coli_id ordernumber,
v2.VEI2_CompanyBN AS hotelName,
cityinfo2.CII2_Name AS cityName,
(SELECT SGC_ServiceGrade
FROM servicegradecode2
WHERE SGC2_LGC=2
AND SGC2_SGC_SN=Isnull(VEI_Grade,-1)) AS hotelStar,
(SELECT ROT2_TypeName
FROM roomtype2
WHERE ROT2_ROT_SN=ISNULL(COLD_ServiceSN2,-1)
AND ROT2_LGC=1) AS roomtype,
left(convert(varchar,COLD_StartDate,120),10) AS starttime,
left(convert(varchar,COLD_EndDate,120),10) AS endtime,
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,
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,
VendorInfo2.VEI2_CompanyBN AS roomprovide,
COLD_Describe roombz,
0 as orderstats
FROM BIZ_ConfirmLineDetail
INNER JOIN BIZ_ConfirmLineInfo ON COLD_COLI_SN=COLI_SN
LEFT JOIN BIZ_HotelOrderInfo ON HOI_COLD_SN = COLD_SN
LEFT JOIN VEndorInfo2 ON COLD_PlanVEI_SN = VEI2_VEI_SN AND VEI2_LGC = 2
LEFT JOIN Vendorinfo2 AS V2 ON COLD_ServiceSN = V2.VEI2_VEI_SN AND V2.VEI2_LGC = 2
LEFT JOIN VendorInfo ON COLD_ServiceSN = VEI_SN
LEFT JOIN cityinfo2 ON vendorinfo.VEI_CII_Name=cityinfo2.CII2_CII_SN AND cityinfo2.CII2_LGC=2
WHERE COLD_COLI_SN = $coli_sn
AND BIZ_ConfirmLineDetail.DeleteFlag = 0
AND COLD_ServiceType = 'A'
";
return $this->HT->query($sql)->row();
}
/** 非图兰朵供应商的包价线路产品 */
public function insert_report_tour_others($coli_sn=0)
public function insert_report_tour_others($coli_sn=0, $update_flag=false )
{
if ($update_flag === TRUE) {
return $this->update_report_tour_others($coli_sn);
}
// INSERT INTO report_tour(
// ordernumber,
// tourCode,
@ -338,14 +436,78 @@ $this->HT2 = $this->load->database('INFO', TRUE); // test
return $this->HT->query($sql)->result();
// return $this->HT->query("SELECT top 1 * from tourmanager.dbo.report_tour inner join BIZ_ConfirmLineInfo on COLI_ID=ordernumber WHERE COLI_SN=$coli_sn order by orderId desc")->row();
// $this->HT->query($sql);
return TRUE;
}
public function update_report_tour_others($coli_sn)
{
$this->HT2 = $this->load->database('INFO', TRUE); // test
$update_data = $this->get_report_tour_others_cost($coli_sn);
$where = " ordernumber='" . $update_data->ordernumber . "' AND tourCode='" . $update_data->tourCode . "' ";
$update_sql = $this->HT2->update_string('tourmanager.dbo.report_tour', $update_data, $where);
return $this->HT2->query($update_sql);
}
public function get_report_tour_others_cost($coli_sn=0)
{
$sql = "SELECT
dbo.BIZ_ConfirmLineInfo.COLI_ID ordernumber,
dbo.BIZ_PackageInfo.PAG_Code tourCode,
dbo.BIZ_PackageInfo.PAG_Title tourname,
SUBSTRING(CONVERT(varchar,dbo.BIZ_ConfirmLineDetail.COLD_StartDate, 120), 1, 10) AS tourtime,
dbo.BIZ_ConfirmLineDetail.COLD_PersonNum tourRSd,
dbo.BIZ_ConfirmLineDetail.COLD_ChildNum tourRSx,
--@AdultCost,
(select top 1 PKP_AdultCost
from BIZ_PackagePrice
where PKP_PAG_SN=COLD_ServiceSN
and PKP_VEI_SN=COLD_PlanVEI_SN
and PKP_PersonStart< =isnull(COLD_PersonNum,0)+isnull(COLD_ChildNum,0)
and PKP_PersonStop >=isnull(COLD_PersonNum,0)+isnull(COLD_ChildNum,0)
and PKP_ValidDate < = CONVERT(varchar(100),COLD_StartDate,23)
and PKP_InvalidDate >= CONVERT(varchar(100),COLD_StartDate,23)
ORDER BY PKP_PriceGrade
) as tourCostRsd,
--@ChildCost,
(select top 1 PKP_ChildCost
from BIZ_PackagePrice
where PKP_PAG_SN=COLD_ServiceSN
and PKP_VEI_SN=COLD_PlanVEI_SN
and PKP_PersonStart< =isnull(COLD_PersonNum,0)+isnull(COLD_ChildNum,0)
and PKP_PersonStop >=isnull(COLD_PersonNum,0)+isnull(COLD_ChildNum,0)
and PKP_ValidDate < = CONVERT(varchar(100),COLD_StartDate,23)
and PKP_InvalidDate >= CONVERT(varchar(100),COLD_StartDate,23)
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,
isnull(dbo.VEndorInfo2.VEI2_CompanyBN,'.') as tourProvide,
SUBSTRING(dbo.BIZ_ConfirmLineDetail.COLD_Describe,1,70) as tourBZ,
0 as orderstats
FROM dbo.BIZ_ConfirmLineDetail
inner join BIZ_ConfirmLineInfo on COLI_SN=COLD_COLI_SN
LEFT OUTER JOIN dbo.VEndorInfo2 ON dbo.VEndorInfo2.VEI2_VEI_SN = dbo.BIZ_ConfirmLineDetail.COLD_PlanVEI_SN AND dbo.VEndorInfo2.VEI2_LGC = 2
INNER JOIN dbo.BIZ_PackageInfo ON dbo.BIZ_ConfirmLineDetail.COLD_ServiceSN = dbo.BIZ_PackageInfo.PAG_SN
WHERE (dbo.BIZ_ConfirmLineDetail.COLD_ServiceType='D')
AND (dbo.BIZ_ConfirmLineDetail.DeleteFlag = 0)
AND (dbo.BIZ_ConfirmLineDetail.COLD_COLI_SN=$coli_sn)
and dbo.BIZ_ConfirmLineDetail.COLD_PlanVEI_SN not in (1343,29188,30548,30016) ";
return $this->HT->query($sql)->row();
}
public function insert_report_order($report_order_arr=array())
public function insert_report_order($report_order_arr=array(), $update_flag=false )
{
$this->HT2 = $this->load->database('INFO', TRUE); // test
if ($update_flag === 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);
}
$this->HT2->insert('tourmanager.dbo.report_order', $report_order_arr);
return $this->HT2->query("SELECT top 1 * from tourmanager.dbo.report_order WHERE ordernumber=? order by orderID desc",array($report_order_arr['ordernumber']))->row();
return $this->HT2->query("SELECT top 1 * from tourmanager.dbo.report_order WHERE ordernumber=? order by orderID desc",
array($report_order_arr['ordernumber']))->row();
// return TRUE;
}