|
|
|
@ -1,7 +1,7 @@
|
|
|
|
|
<?php
|
|
|
|
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
|
|
|
|
|
|
|
|
|
define('PAY_OTHER','15017,15008,15006,15020');
|
|
|
|
|
define('PAY_OTHER','15006, 15017,15008,15006,15020');
|
|
|
|
|
|
|
|
|
|
class Vendor_money_model extends CI_Model {
|
|
|
|
|
|
|
|
|
@ -12,7 +12,7 @@ class Vendor_money_model extends CI_Model {
|
|
|
|
|
bcscale(4);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function checked_group_list($vendor, $sourcetype, $start_date, $end_date, $all_vendor)
|
|
|
|
|
public function checked_group_list($vendor, $sourcetype, $start_date, $end_date, $all_vendor, $duplicate_gri)
|
|
|
|
|
{
|
|
|
|
|
$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
|
|
|
|
@ -70,7 +70,7 @@ class Vendor_money_model extends CI_Model {
|
|
|
|
|
) 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_VEI_SN in ($vendor, 1343)
|
|
|
|
|
and GAI_Type in (" . PAY_OTHER . ")
|
|
|
|
|
) as 地接社收款
|
|
|
|
|
,coli.COLI_OPI_ID
|
|
|
|
@ -85,6 +85,7 @@ class Vendor_money_model extends CI_Model {
|
|
|
|
|
)
|
|
|
|
|
and CGI_Checked=1
|
|
|
|
|
and GRI_OrderType=227002
|
|
|
|
|
and COLI_SN not in ($duplicate_gri)
|
|
|
|
|
and exists (
|
|
|
|
|
select 1 from BIZ_ConfirmLineDetail where COLD_COLI_SN=coli.COLI_SN
|
|
|
|
|
and DeleteFlag=0
|
|
|
|
@ -165,6 +166,10 @@ class Vendor_money_model extends CI_Model {
|
|
|
|
|
WHERE CGI_Checked=1
|
|
|
|
|
AND CGI_GRI_SN=GCI_GRI_SN
|
|
|
|
|
AND CGI_ArriveDate BETWEEN '$start_date' AND '$end_date')
|
|
|
|
|
and not exists (
|
|
|
|
|
select 1 from GroupCombineInfo g2 where g2.GCI_combineNo=gci.GCI_combineNo
|
|
|
|
|
and g2.GCI_VEI_SN<>gci.GCI_VEI_SN
|
|
|
|
|
)
|
|
|
|
|
) AS group_cost
|
|
|
|
|
) as tmp
|
|
|
|
|
GROUP BY tmp.vendor_code ";
|
|
|
|
@ -479,7 +484,10 @@ class Vendor_money_model extends CI_Model {
|
|
|
|
|
,(select SUM(CONVERT(float, GCI_agencyReceipt)) from GroupCombineInfo where GCI_combineNo=group_cost.GCI_combineNo
|
|
|
|
|
) as agency_receive_price
|
|
|
|
|
FROM
|
|
|
|
|
(SELECT isnull(gci.GCI_combineNo,'1') GCI_combineNo
|
|
|
|
|
(SELECT case when gci.GCI_combineNo is null then '1'
|
|
|
|
|
when gci.GCI_combineNo='cancel' then convert(varchar(10),gci.GCI_SN)
|
|
|
|
|
else gci.GCI_combineNo end
|
|
|
|
|
as GCI_combineNo
|
|
|
|
|
,GCI_VEI_SN
|
|
|
|
|
FROM GroupCombineInfo gci
|
|
|
|
|
WHERE 1=1
|
|
|
|
@ -490,7 +498,9 @@ class Vendor_money_model extends CI_Model {
|
|
|
|
|
WHERE CGI_Checked=1
|
|
|
|
|
AND CGI_GRI_SN=GCI_GRI_SN
|
|
|
|
|
AND CGI_ArriveDate BETWEEN '$start_date' AND '$end_date')
|
|
|
|
|
group by isnull(gci.GCI_combineNo,'1')
|
|
|
|
|
group by case when gci.GCI_combineNo is null then '1'
|
|
|
|
|
when gci.GCI_combineNo='cancel' then convert(varchar(10),gci.GCI_SN)
|
|
|
|
|
else gci.GCI_combineNo end
|
|
|
|
|
,GCI_VEI_SN
|
|
|
|
|
) AS group_cost
|
|
|
|
|
order by GCI_combineNo desc";
|
|
|
|
@ -498,6 +508,52 @@ class Vendor_money_model extends CI_Model {
|
|
|
|
|
return $query->result_array();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function get_duplicate_vei_combineno($start_date, $end_date, $all_vendor)
|
|
|
|
|
{
|
|
|
|
|
$sql = "SELECT pure_group.*
|
|
|
|
|
,(select isnull(SUM(GAI_SSJE),0) from BIZ_GroupAccountInfo
|
|
|
|
|
where DeleteFlag=0 and GAI_GRI_SN=COLI_SN
|
|
|
|
|
and GAI_VEI_SN in ($all_vendor)
|
|
|
|
|
and GAI_Type in (" . PAY_OTHER . ")
|
|
|
|
|
) as vendor_sum
|
|
|
|
|
,(select isnull(SUM(GAI_SSJE),0) from BIZ_GroupAccountInfo
|
|
|
|
|
where DeleteFlag=0 and GAI_COLI_SN=COLI_SN
|
|
|
|
|
) as total_receipt
|
|
|
|
|
,(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 trippest_sum
|
|
|
|
|
,0 as other_price_sum,0 as other_cost_sum,0 as other_vendorprice_RMB_sum
|
|
|
|
|
from (SELECT GCI_combineNo
|
|
|
|
|
,(select top 1 GCI_VEI_SN from groupcombineinfo g1 where g1.gci_combineno=vendor_group.GCI_combineNo) as vendor1
|
|
|
|
|
,(select top 1 c.COLI_SN from groupcombineinfo g1
|
|
|
|
|
inner join BIZ_ConfirmLineInfo c on COLI_GRI_SN=GCI_GRI_SN
|
|
|
|
|
where g1.gci_combineno=vendor_group.GCI_combineNo
|
|
|
|
|
) as COLI_SN
|
|
|
|
|
,(SELECT isnull(SUM(CONVERT(float, isnull(gcod.GCOD_sumMoney,0))),0)
|
|
|
|
|
FROM GroupCombineOperationDetail gcod
|
|
|
|
|
WHERE gcod.GCOD_GCI_combineNo=GCI_combineNo
|
|
|
|
|
AND gcod.GCOD_operationType<> 'otherReceives'
|
|
|
|
|
) as pure_cost
|
|
|
|
|
from (
|
|
|
|
|
select GCI_combineNo ,GCI_VEI_SN
|
|
|
|
|
from GroupCombineInfo where 1=1
|
|
|
|
|
and GCI_VEI_SN in ($all_vendor)
|
|
|
|
|
AND EXISTS
|
|
|
|
|
( SELECT 1
|
|
|
|
|
FROM CK_GroupInfo
|
|
|
|
|
WHERE CGI_Checked=1
|
|
|
|
|
AND CGI_GRI_SN=GCI_GRI_SN
|
|
|
|
|
AND CGI_ArriveDate BETWEEN '$start_date' AND '$end_date')
|
|
|
|
|
group by GCI_combineNo, GCI_VEI_SN
|
|
|
|
|
) as vendor_group
|
|
|
|
|
group by vendor_group.GCI_combineNo
|
|
|
|
|
having COUNT(1)>1
|
|
|
|
|
) as pure_group";
|
|
|
|
|
$query = $this->HT->query($sql);
|
|
|
|
|
return $query->result_array();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* End of file vendor_money.php */
|
|
|
|
|