,data_tmp.total_income-(round(HT_haina_receipt,1)+ ROUND(HT_agency_receipt,1)) as 'total_income_err' --'海纳收入差额'
,(select top 1 GCI_combineNo from groupcombineinfo where gci_gri_sn=data_tmp.GRI_SN) as combineNo
,(select top 1 GCI_combineNo from groupcombineinfo where gci_gri_sn=data_tmp.GRI_SN order by GCI_combineNo desc) as combineNo
,(select top 1 GCI_VendorOrderId from groupcombineinfo
where gci_gri_sn=data_tmp.GRI_SN and ( GCI_createTime<'$expire_fresh' )
where gci_gri_sn=data_tmp.GRI_SN and ( GCI_createTime<'$expire_fresh' or (GCI_createTime>'$expire_fresh' and isnull(convert(decimal(10,2),GCI_priceCNY),0)=0) )
order by GCI_createTime
) as vendor_order
,* from
(
@ -421,6 +422,9 @@ class Vendor_money_model extends CI_Model {
and DeleteFlag=0
--and isnull(GAI_VEI_SN,0) in (0,)
) as HT_haina_receipt,
(select top 1 CONVERT(varchar(10),ISNULL( GAI_SQJE,0)) + isnull(GAI_SQJECurrency,'')+',' + isnull(GAI_Memo,'') from BIZ_GroupAccountInfo ga where ga.DeleteFlag=0 and GAI_COLI_SN=COLI_SN
and GAI_SQJE>0 and isnull(GAI_SSJE,0)=0
) as ht_receipt_memo,
(select SUM(ABS(GAI_SSJE)) from BIZ_GroupAccountInfo ga where ga.DeleteFlag=0 and GAI_COLI_SN=COLI_SN
and GAI_SSJE<0
) as refund,
@ -480,7 +484,7 @@ class Vendor_money_model extends CI_Model {
)
OR exists (
select 1 from groupcombineinfo
where gci_gri_sn=data_tmp.GRI_SN and ( GCI_createTime<'$expire_fresh' or GCI_combineNo is null)
where gci_gri_sn=data_tmp.GRI_SN and ( GCI_createTime<'$expire_fresh' AND GCI_combineNo is null)
)
order by total_income_err desc,agency_receipt_err desc,HT_receipt_err desc";