|
|
|
@ -17,6 +17,7 @@ class Vendor_money_model extends CI_Model {
|
|
|
|
|
$sql = "SELECT sum_opi.COLI_OPI_ID,sum(sum_opi.海纳收款) as trippest_sum,sum(sum_opi.地接社收款) as vendor_sum,
|
|
|
|
|
sum(sum_opi.other_price_RMB) as other_price_sum
|
|
|
|
|
, sum(sum_opi.other_cost_RMB) as other_cost_sum
|
|
|
|
|
,sum(sum_opi.other_vendorprice_RMB) as other_vendorprice_RMB_sum
|
|
|
|
|
from (
|
|
|
|
|
SELECT
|
|
|
|
|
(select isnull(SUM(COLD_TotalPrice),0) from BIZ_ConfirmLineDetail cold
|
|
|
|
@ -31,6 +32,11 @@ class Vendor_money_model extends CI_Model {
|
|
|
|
|
and COLD_PlanVEI_SN IN ($all_vendor)
|
|
|
|
|
and cold.DeleteFlag=0
|
|
|
|
|
) as other_cost_RMB,
|
|
|
|
|
(dbo.ConvertToRMB('USD',other_vendor_price)) as other_vendorprice_RMB,
|
|
|
|
|
case when other_vendor_price > 0 then
|
|
|
|
|
(总收款-dbo.ConvertToRMB('USD',other_vendor_price))
|
|
|
|
|
else 海纳收款_origin end
|
|
|
|
|
as 海纳收款,
|
|
|
|
|
*
|
|
|
|
|
from (
|
|
|
|
|
select
|
|
|
|
@ -40,6 +46,13 @@ class Vendor_money_model extends CI_Model {
|
|
|
|
|
and COLD_ServiceType='D'
|
|
|
|
|
and DeleteFlag=0
|
|
|
|
|
) as service_cnt,
|
|
|
|
|
(select isnull(SUM(COLD_TotalPrice),0) from BIZ_ConfirmLineDetail
|
|
|
|
|
where COLD_COLI_SN=COLI_SN
|
|
|
|
|
--and COLD_ServiceType='D'
|
|
|
|
|
and DeleteFlag=0
|
|
|
|
|
and COLD_PlanVEI_SN<>$vendor
|
|
|
|
|
and COLD_PlanVEI_SN not in ($all_vendor)
|
|
|
|
|
) as other_vendor_price,
|
|
|
|
|
COLI.COLI_sourcetype,
|
|
|
|
|
COLI.COLI_Price,
|
|
|
|
|
coli.COLI_Currency,
|
|
|
|
@ -54,9 +67,10 @@ class Vendor_money_model extends CI_Model {
|
|
|
|
|
(select isnull(SUM(GAI_SSJE),0) from BIZ_GroupAccountInfo
|
|
|
|
|
where DeleteFlag=0 and GAI_COLI_SN=COLI_SN
|
|
|
|
|
and GAI_Type not in (" . PAY_OTHER . ")
|
|
|
|
|
) as 海纳收款,
|
|
|
|
|
) as 海纳收款_origin,
|
|
|
|
|
(select isnull(SUM(GAI_SSJE),0) from BIZ_GroupAccountInfo
|
|
|
|
|
where DeleteFlag=0 and GAI_COLI_SN=COLI_SN
|
|
|
|
|
and GAI_VEI_SN=$vendor
|
|
|
|
|
and GAI_Type in (" . PAY_OTHER . ")
|
|
|
|
|
) as 地接社收款
|
|
|
|
|
,coli.COLI_OPI_ID
|
|
|
|
@ -158,6 +172,58 @@ class Vendor_money_model extends CI_Model {
|
|
|
|
|
return $query->result_array();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function trippest_order_multi_city($start_date, $end_date, $all_vendor)
|
|
|
|
|
{
|
|
|
|
|
$sql = "SELECT COLI_SN,COLI_ID,COLI_GroupCode,
|
|
|
|
|
(select top 1 ISNULL(GCI_combineNo,'') from GroupCombineInfo where GCI_GRI_SN=COLI_GRI_SN) as gci_no,
|
|
|
|
|
convert(date,cgi.CGI_ArriveDate) CGI_ArriveDate,
|
|
|
|
|
COLI.COLI_sourcetype, COLI.COLI_Price, coli.COLI_Currency,
|
|
|
|
|
(select isnull(SUM(dbo.ConvertToRMB('USD',COLD_TotalPrice)),0) from BIZ_ConfirmLineDetail
|
|
|
|
|
where COLD_COLI_SN=COLI_SN
|
|
|
|
|
and DeleteFlag=0
|
|
|
|
|
and COLD_PlanVEI_SN not in ($all_vendor)
|
|
|
|
|
) as other_vendorprice_RMB
|
|
|
|
|
,(select isnull(SUM(dbo.ConvertToRMB('USD',COLD_TotalPrice)),0) from BIZ_ConfirmLineDetail
|
|
|
|
|
where COLD_COLI_SN=COLI_SN
|
|
|
|
|
and DeleteFlag=0
|
|
|
|
|
and COLD_PlanVEI_SN in ($all_vendor)
|
|
|
|
|
) as this_vendorprice_RMB
|
|
|
|
|
,(SELECT isnull(SUM(GAI_SSJE),0)
|
|
|
|
|
FROM BIZ_GroupAccountInfo
|
|
|
|
|
WHERE DeleteFlag=0
|
|
|
|
|
AND GAI_COLI_SN=COLI_SN
|
|
|
|
|
) AS money_sum
|
|
|
|
|
,(select dbo.[GetVendorName](COLD_PlanVEI_SN,2) from BIZ_ConfirmLineDetail
|
|
|
|
|
where COLD_COLI_SN=COLI_SN
|
|
|
|
|
and DeleteFlag=0
|
|
|
|
|
and COLD_PlanVEI_SN in ($all_vendor)
|
|
|
|
|
) as vendor_name
|
|
|
|
|
FROM CK_GroupInfo cgi
|
|
|
|
|
INNER JOIN GRoupInfo gri ON CGI_GRI_SN=GRI_SN
|
|
|
|
|
INNER JOIN BIZ_ConfirmLineInfo coli ON COLI_GRI_SN=GRI_SN
|
|
|
|
|
WHERE 1=1
|
|
|
|
|
AND CGI_ArriveDate BETWEEN '$start_date' and '$end_date'
|
|
|
|
|
AND EXISTS
|
|
|
|
|
(SELECT 1
|
|
|
|
|
FROM OperatorInfo
|
|
|
|
|
WHERE OPI_DEI_SN=30
|
|
|
|
|
AND OPI_SN=CGI_OPI_SN)
|
|
|
|
|
AND CGI_Checked=1
|
|
|
|
|
AND GRI_OrderType=227002
|
|
|
|
|
AND COLI_OPI_ID <> 435
|
|
|
|
|
AND exists (
|
|
|
|
|
select 1 from BIZ_ConfirmLineDetail where COLD_COLI_SN=COLI_SN
|
|
|
|
|
and COLD_PlanVEI_SN in ($all_vendor) --in ($all_vendor)
|
|
|
|
|
)
|
|
|
|
|
AND exists (
|
|
|
|
|
select 1 from BIZ_ConfirmLineDetail where COLD_COLI_SN=COLI_SN
|
|
|
|
|
and COLD_PlanVEI_SN not in ($all_vendor)
|
|
|
|
|
)
|
|
|
|
|
ORDER BY COLI_sourcetype ";
|
|
|
|
|
$query = $this->HT->query($sql);
|
|
|
|
|
return $query->result_array();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|