|
|
@ -81,7 +81,8 @@ UPDATE daily_report r |
|
|
|
INNER JOIN (select count(bbv.id) as scount, bbv.modelSid, bbv.modelConfigSid, bbm.orgSid useOrgSid |
|
|
|
from anrui_buscenter.bus_main_deposit bbm |
|
|
|
left join anrui_buscenter.bus_deposit_vehicle bbv on bbv.billSid = bbm.sid |
|
|
|
where bbm.createTime like concat('%', CURDATE(), '%') and bbm.nodeState = '已办结' |
|
|
|
where bbm.createTime like concat('%', CURDATE(), '%') |
|
|
|
and bbm.nodeState = '已办结' |
|
|
|
GROUP BY `useOrgSid`, |
|
|
|
`modelSid`, |
|
|
|
`modelConfigSid` |
|
|
@ -98,7 +99,8 @@ UPDATE daily_report r |
|
|
|
INNER JOIN (select count(bbv.id) as scount, bbv.modelSid, bbv.modelConfigSid, bbm.orgSid useOrgSid |
|
|
|
from anrui_buscenter.bus_main_deposit bbm |
|
|
|
left join anrui_buscenter.bus_deposit_vehicle bbv on bbv.billSid = bbm.sid |
|
|
|
where bbm.createTime like concat('%', DATE_FORMAT(CURDATE(), '%Y-%m'), '%') and bbm.nodeState = '已办结' |
|
|
|
where bbm.createTime like concat('%', DATE_FORMAT(CURDATE(), '%Y-%m'), '%') |
|
|
|
and bbm.nodeState = '已办结' |
|
|
|
GROUP BY `useOrgSid`, |
|
|
|
`modelSid`, |
|
|
|
`modelConfigSid` |
|
|
@ -116,7 +118,8 @@ UPDATE daily_report r |
|
|
|
left join anrui_buscenter.bus_sales_order_model bm on bm.salesOrderSid = bo.sid |
|
|
|
left join anrui_buscenter.bus_sales_order_vehicle bv on bv.salesOrderSid = bo.sid |
|
|
|
where bo.closingDate like concat('%', CURDATE(), '%') |
|
|
|
and bo.payTypeKey = 1 and bo.nodeState = '已办结' |
|
|
|
and bo.payTypeKey = 1 |
|
|
|
and bo.nodeState = '已办结' |
|
|
|
group by useOrgSid, modelSid, modelConfigSid |
|
|
|
) AS s ON r.useOrgSid = s.useOrgSid |
|
|
|
AND r.vehModelSid = s.modelSid |
|
|
@ -130,7 +133,8 @@ UPDATE daily_report r |
|
|
|
left join anrui_buscenter.bus_sales_order_model bm on bm.salesOrderSid = bo.sid |
|
|
|
left join anrui_buscenter.bus_sales_order_vehicle bv on bv.salesOrderSid = bo.sid |
|
|
|
where bo.closingDate like concat('%', CURDATE(), '%') |
|
|
|
and bo.payTypeKey = 2 and bo.nodeState = '已办结' |
|
|
|
and bo.payTypeKey = 2 |
|
|
|
and bo.nodeState = '已办结' |
|
|
|
group by useOrgSid, modelSid, modelConfigSid |
|
|
|
) AS s ON r.useOrgSid = s.useOrgSid |
|
|
|
AND r.vehModelSid = s.modelSid |
|
|
@ -164,7 +168,8 @@ UPDATE daily_report r |
|
|
|
left join anrui_buscenter.bus_sales_order_model bm on bm.salesOrderSid = bo.sid |
|
|
|
left join anrui_buscenter.bus_sales_order_vehicle bv on bv.salesOrderSid = bo.sid |
|
|
|
where bo.closingDate like concat('%', DATE_FORMAT(CURDATE(), '%Y-%m'), '%') |
|
|
|
and bo.payTypeKey = 1 and bo.nodeState = '已办结' |
|
|
|
and bo.payTypeKey = 1 |
|
|
|
and bo.nodeState = '已办结' |
|
|
|
group by useOrgSid, modelSid, modelConfigSid |
|
|
|
) AS s ON r.useOrgSid = s.useOrgSid |
|
|
|
AND r.vehModelSid = s.modelSid |
|
|
@ -178,7 +183,8 @@ UPDATE daily_report r |
|
|
|
left join anrui_buscenter.bus_sales_order_model bm on bm.salesOrderSid = bo.sid |
|
|
|
left join anrui_buscenter.bus_sales_order_vehicle bv on bv.salesOrderSid = bo.sid |
|
|
|
where bo.closingDate like concat('%', DATE_FORMAT(CURDATE(), '%Y-%m'), '%') |
|
|
|
and bo.payTypeKey = 2 and bo.nodeState = '已办结' |
|
|
|
and bo.payTypeKey = 2 |
|
|
|
and bo.nodeState = '已办结' |
|
|
|
group by useOrgSid, modelSid, modelConfigSid |
|
|
|
) AS s ON r.useOrgSid = s.useOrgSid |
|
|
|
AND r.vehModelSid = s.modelSid |
|
|
@ -223,13 +229,15 @@ WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); |
|
|
|
|
|
|
|
-- 本日销售全款 |
|
|
|
UPDATE daily_report r |
|
|
|
INNER JOIN (select count(bv.id) as scount, bv.modelSid, bv.modelConfigSid, bv.useOrgSid |
|
|
|
INNER JOIN (select sum(ss.scount) as scount, ss.modelSid, ss.modelConfigSid, ss.useOrgSid |
|
|
|
from (select count(bv.id) as scount, bv.modelSid, bv.modelConfigSid, bv.useOrgSid |
|
|
|
from anrui_base.base_vehicle bv |
|
|
|
left join anrui_base.base_vehicle_out bvo on bv.sid = bvo.vinSid |
|
|
|
left join anrui_base.base_vehicle_out_apply bvoa on bvoa.sid = bvo.mainSid |
|
|
|
where bv.salesDate like concat('%', CURDATE(), '%') |
|
|
|
and bvoa.saleTypeKey = '001' |
|
|
|
group by useOrgSid, modelSid, modelConfigSid |
|
|
|
group by bv.useOrgSid, bv.modelSid, bv.modelConfigSid) ss |
|
|
|
group by ss.useOrgSid, ss.modelSid, ss.modelConfigSid |
|
|
|
) AS s ON r.useOrgSid = s.useOrgSid |
|
|
|
AND r.vehModelSid = s.modelSid |
|
|
|
AND r.vehMConfigSid = s.modelConfigSid |
|
|
@ -237,13 +245,15 @@ SET r.`sale_full_day` = s.scount |
|
|
|
WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); |
|
|
|
-- 本日销售贷款 |
|
|
|
UPDATE daily_report r |
|
|
|
INNER JOIN (select count(bv.id) as scount, bv.modelSid, bv.modelConfigSid, bv.useOrgSid |
|
|
|
INNER JOIN (select sum(ss.scount) as scount, ss.modelSid, ss.modelConfigSid, ss.useOrgSid |
|
|
|
from (select count(bv.id) as scount, bv.modelSid, bv.modelConfigSid, bv.useOrgSid |
|
|
|
from anrui_base.base_vehicle bv |
|
|
|
left join anrui_base.base_vehicle_out bvo on bv.sid = bvo.vinSid |
|
|
|
left join anrui_base.base_vehicle_out_apply bvoa on bvoa.sid = bvo.mainSid |
|
|
|
where bv.salesDate like concat('%', CURDATE(), '%') |
|
|
|
and bvoa.saleTypeKey = '002' |
|
|
|
group by useOrgSid, modelSid, modelConfigSid |
|
|
|
group by bv.useOrgSid, bv.modelSid, bv.modelConfigSid) ss |
|
|
|
group by ss.useOrgSid, ss.modelSid, ss.modelConfigSid |
|
|
|
) AS s ON r.useOrgSid = s.useOrgSid |
|
|
|
AND r.vehModelSid = s.modelSid |
|
|
|
AND r.vehMConfigSid = s.modelConfigSid |
|
|
@ -268,13 +278,15 @@ WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); |
|
|
|
|
|
|
|
-- 本月销售全款 |
|
|
|
UPDATE daily_report r |
|
|
|
INNER JOIN (select count(bv.id) as scount, bv.modelSid, bv.modelConfigSid, bv.useOrgSid |
|
|
|
INNER JOIN (select sum(ss.scount) as scount, ss.modelSid, ss.modelConfigSid, ss.useOrgSid |
|
|
|
from (select count(bv.id) as scount, bv.modelSid, bv.modelConfigSid, bv.useOrgSid |
|
|
|
from anrui_base.base_vehicle bv |
|
|
|
left join anrui_base.base_vehicle_out bvo on bv.sid = bvo.vinSid |
|
|
|
left join anrui_base.base_vehicle_out_apply bvoa on bvoa.sid = bvo.mainSid |
|
|
|
where bv.salesDate like concat('%', DATE_FORMAT(CURDATE(), '%Y-%m'), '%') |
|
|
|
and bvoa.saleTypeKey = '001' |
|
|
|
group by useOrgSid, modelSid, modelConfigSid |
|
|
|
group by bv.useOrgSid, bv.modelSid, bv.modelConfigSid) ss |
|
|
|
group by ss.useOrgSid, ss.modelSid, ss.modelConfigSid |
|
|
|
) AS s ON r.useOrgSid = s.useOrgSid |
|
|
|
AND r.vehModelSid = s.modelSid |
|
|
|
AND r.vehMConfigSid = s.modelConfigSid |
|
|
@ -282,13 +294,15 @@ SET r.`sale_full_month` = s.scount |
|
|
|
WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); |
|
|
|
-- 本月销售贷款 |
|
|
|
UPDATE daily_report r |
|
|
|
INNER JOIN (select count(bv.id) as scount, bv.modelSid, bv.modelConfigSid, bv.useOrgSid |
|
|
|
INNER JOIN (select sum(ss.scount) as scount, ss.modelSid, ss.modelConfigSid, ss.useOrgSid |
|
|
|
from (select count(bv.id) as scount, bv.modelSid, bv.modelConfigSid, bv.useOrgSid |
|
|
|
from anrui_base.base_vehicle bv |
|
|
|
left join anrui_base.base_vehicle_out bvo on bv.sid = bvo.vinSid |
|
|
|
left join anrui_base.base_vehicle_out_apply bvoa on bvoa.sid = bvo.mainSid |
|
|
|
where bv.salesDate like concat('%', DATE_FORMAT(CURDATE(), '%Y-%m'), '%') |
|
|
|
and bvoa.saleTypeKey = '002' |
|
|
|
group by useOrgSid, modelSid, modelConfigSid |
|
|
|
group by bv.useOrgSid, bv.modelSid, bv.modelConfigSid) ss |
|
|
|
group by ss.useOrgSid, ss.modelSid, ss.modelConfigSid |
|
|
|
) AS s ON r.useOrgSid = s.useOrgSid |
|
|
|
AND r.vehModelSid = s.modelSid |
|
|
|
AND r.vehMConfigSid = s.modelConfigSid |
|
|
@ -320,7 +334,8 @@ UPDATE daily_report r |
|
|
|
left join anrui_base.base_vehicle_out_apply bvoa on bvoa.sid = bvo.mainSid |
|
|
|
where bv.salesDate like concat('%', DATE_FORMAT(CURDATE(), '%Y'), '%') |
|
|
|
and bvoa.saleTypeKey = '001' |
|
|
|
group by bv.useOrgSid, bv.modelSid, bv.modelConfigSid) ss group by ss.useOrgSid, ss.modelSid, ss.modelConfigSid |
|
|
|
group by bv.useOrgSid, bv.modelSid, bv.modelConfigSid) ss |
|
|
|
group by ss.useOrgSid, ss.modelSid, ss.modelConfigSid |
|
|
|
) AS s ON r.useOrgSid = s.useOrgSid |
|
|
|
AND r.vehModelSid = s.modelSid |
|
|
|
AND r.vehMConfigSid = s.modelConfigSid |
|
|
@ -335,7 +350,8 @@ UPDATE daily_report r |
|
|
|
left join anrui_base.base_vehicle_out_apply bvoa on bvoa.sid = bvo.mainSid |
|
|
|
where bv.salesDate like concat('%', DATE_FORMAT(CURDATE(), '%Y'), '%') |
|
|
|
and bvoa.saleTypeKey = '002' |
|
|
|
group by bv.useOrgSid, bv.modelSid, bv.modelConfigSid) ss group by ss.useOrgSid, ss.modelSid, ss.modelConfigSid |
|
|
|
group by bv.useOrgSid, bv.modelSid, bv.modelConfigSid) ss |
|
|
|
group by ss.useOrgSid, ss.modelSid, ss.modelConfigSid |
|
|
|
) AS s ON r.useOrgSid = s.useOrgSid |
|
|
|
AND r.vehModelSid = s.modelSid |
|
|
|
AND r.vehMConfigSid = s.modelConfigSid |
|
|
@ -559,19 +575,24 @@ WHERE DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); |
|
|
|
|
|
|
|
-- 存销比 |
|
|
|
update daily_report r inner join ( |
|
|
|
select ddr.useOrgSid, ddr.vehModelSid, ddr.vehMConfigSid,(select COALESCE(SUM(dr.sale_subtotal_month), 0) as subtotal |
|
|
|
from daily_report dr |
|
|
|
where (DATE_FORMAT(createTime, '%Y-%m') LIKE DATE_FORMAT(DATE_SUB(CURDATE(), INTERVAL 1 MONTH), '%Y-%m') |
|
|
|
OR DATE_FORMAT(createTime, '%Y-%m') LIKE DATE_FORMAT(DATE_SUB(CURDATE(), INTERVAL 2 MONTH), '%Y-%m') |
|
|
|
OR DATE_FORMAT(createTime, '%Y-%m') LIKE DATE_FORMAT(DATE_SUB(CURDATE(), INTERVAL 3 MONTH), '%Y-%m') |
|
|
|
) and dr.useOrgSid = ddr.useOrgSid and dr.vehModelSid = ddr.vehModelSid and dr.vehMConfigSid = ddr.vehMConfigSid) as subtotal |
|
|
|
from daily_report ddr where DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE() group by ddr.useOrgSid, ddr.vehModelSid, ddr.vehMConfigSid) s |
|
|
|
select sum(ss.scount) as scount, ss.modelSid, ss.modelConfigSid, ss.useOrgSid |
|
|
|
from (select count(bv.id) as scount, bv.modelSid, bv.modelConfigSid, bv.useOrgSid |
|
|
|
from anrui_base.base_vehicle bv |
|
|
|
left join anrui_base.base_vehicle_out bvo on bv.sid = bvo.vinSid |
|
|
|
left join anrui_base.base_vehicle_out_apply bvoa on bvoa.sid = bvo.mainSid |
|
|
|
where (DATE_FORMAT(bv.salesDate, '%Y-%m') LIKE DATE_FORMAT(DATE_SUB(CURDATE(), INTERVAL 1 MONTH), '%Y-%m') |
|
|
|
OR DATE_FORMAT(bv.salesDate, '%Y-%m') LIKE DATE_FORMAT(DATE_SUB(CURDATE(), INTERVAL 2 MONTH), '%Y-%m') |
|
|
|
OR DATE_FORMAT(bv.salesDate, '%Y-%m') LIKE DATE_FORMAT(DATE_SUB(CURDATE(), INTERVAL 3 MONTH), '%Y-%m') |
|
|
|
) |
|
|
|
and (bvoa.saleTypeKey = '001' or bvoa.saleTypeKey = '002') |
|
|
|
group by bv.useOrgSid, bv.modelSid, bv.modelConfigSid) ss |
|
|
|
group by ss.useOrgSid, ss.modelSid, ss.modelConfigSid) s |
|
|
|
on r.useOrgSid = s.useOrgSid |
|
|
|
and r.vehModelSid = s.vehModelSid |
|
|
|
and r.vehMConfigSid = s.vehMConfigSid |
|
|
|
set saleOfStockRatio =if(ROUND(s.subtotal / 3, 2) = 0, |
|
|
|
concat((stock_subtotal + pcOrder_subtotal),':1'), |
|
|
|
concat((stock_subtotal + pcOrder_subtotal),':', ROUND(s.subtotal / 3, 2))) |
|
|
|
and r.vehModelSid = s.modelSid |
|
|
|
and r.vehMConfigSid = s.modelConfigSid |
|
|
|
set saleOfStockRatio =if(ROUND(s.scount / 3, 2) = 0, |
|
|
|
stock_subtotal + pcOrder_subtotal, |
|
|
|
ROUND((stock_subtotal + pcOrder_subtotal) / ROUND(s.scount / 3, 2), 2)) |
|
|
|
where DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); |
|
|
|
|
|
|
|
-- 库存小计 |
|
|
@ -579,36 +600,51 @@ update daily_report |
|
|
|
set stock_total = (stock_subtotal + pcOrder_subtotal) |
|
|
|
where DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); |
|
|
|
|
|
|
|
|
|
|
|
-- ============================================== |
|
|
|
-- 欠款出库数量、欠款出库金额万元、金融未放款数量、金融未放款金额(万元) |
|
|
|
-- 欠款出库数量--截止当日欠款出库申请通过且未回清款的台数 |
|
|
|
update daily_report r inner join (select sum(cc.scount) as scount,cc.useOrgSid, cc.vehMConfigSid, cc.vehModelSid from ( |
|
|
|
select count(bdad.id) as scount, ba.useOrgSid, bm.modelConfigSid as vehMConfigSid, bm.modelSid as vehModelSid |
|
|
|
update daily_report r inner join (select sum(cc.scount) as scount, cc.useOrgSid, cc.vehMConfigSid, cc.vehModelSid |
|
|
|
from ( |
|
|
|
select count(bdad.id) as scount, |
|
|
|
ba.useOrgSid, |
|
|
|
bm.modelConfigSid as vehMConfigSid, |
|
|
|
bm.modelSid as vehModelSid |
|
|
|
from anrui_buscenter.bus_delivered_apply_details bdad |
|
|
|
left join anrui_buscenter.bus_delivered_apply ba on ba.sid = bdad.applySid |
|
|
|
left join anrui_buscenter.bus_sales_order_vehicle bv on bv.sid = bdad.busVinSid |
|
|
|
left join anrui_buscenter.bus_sales_order bo on bo.sid = bv.salesOrderSid |
|
|
|
left join anrui_buscenter.bus_sales_order_model bm on bm.salesOrderSid = bo.sid |
|
|
|
left join anrui_fin.fin_uncollected_receivables_detailed fd on fd.busVinSid = bdad.busVinSid |
|
|
|
left join anrui_fin.fin_selected_receivables_detailed fs on fs.receivablesSid = fd.sid |
|
|
|
left join anrui_fin.fin_uncollected_receivables_detailed fd |
|
|
|
on fd.busVinSid = bdad.busVinSid |
|
|
|
left join anrui_fin.fin_selected_receivables_detailed fs |
|
|
|
on fs.receivablesSid = fd.sid |
|
|
|
where ba.nodeState = '已办结' |
|
|
|
and ba.typeState = 1 |
|
|
|
group by bdad.busVinSid, ba.useOrgSid, bm.modelSid, bm.modelConfigSid |
|
|
|
having sum(fd.reveivableMoney) > ifnull(sum(fs.subscriptionMoney), 0) |
|
|
|
union all |
|
|
|
select count(bdad.id) as scount,ba.useOrgSid,bm.modelConfigSid as vehMConfigSid, bm.modelSid as vehModelSid |
|
|
|
select count(bdad.id) as scount, |
|
|
|
ba.useOrgSid, |
|
|
|
bm.modelConfigSid as vehMConfigSid, |
|
|
|
bm.modelSid as vehModelSid |
|
|
|
from anrui_buscenter.bus_arrears_carry_vehicle_details bdad |
|
|
|
left join anrui_buscenter.bus_arrears_carry_vehicle_apply ba on ba.sid = bdad.applySid |
|
|
|
left join anrui_buscenter.bus_arrears_carry_vehicle_apply ba |
|
|
|
on ba.sid = bdad.applySid |
|
|
|
left join anrui_buscenter.bus_sales_order_vehicle bv on bv.linkSid = bdad.vinSid |
|
|
|
left join anrui_buscenter.bus_sales_order bo on bo.sid = bv.salesOrderSid |
|
|
|
left join anrui_buscenter.bus_sales_order_model bm on bm.salesOrderSid = bo.sid |
|
|
|
left join anrui_fin.fin_uncollected_receivables_detailed fd on fd.busVinSid = bv.sid |
|
|
|
left join anrui_fin.fin_selected_receivables_detailed fs on fs.receivablesSid = fd.sid |
|
|
|
left join anrui_fin.fin_uncollected_receivables_detailed fd |
|
|
|
on fd.busVinSid = bv.sid |
|
|
|
left join anrui_fin.fin_selected_receivables_detailed fs |
|
|
|
on fs.receivablesSid = fd.sid |
|
|
|
left join anrui_base.base_vehicle bbv on bbv.sid = bv.linkSid |
|
|
|
where ba.nodeState = '已办结' and ba.paymentMethodKey = 1 and bbv.vehicleState = '0002' |
|
|
|
where ba.nodeState = '已办结' |
|
|
|
and ba.paymentMethodKey = 1 |
|
|
|
and bbv.vehicleState = '0002' |
|
|
|
group by bv.sid, ba.useOrgSid, bm.modelSid, bm.modelConfigSid |
|
|
|
having sum(fd.reveivableMoney) > ifnull(sum(fs.subscriptionMoney), 0)) cc |
|
|
|
) s |
|
|
|
) s |
|
|
|
on r.useOrgSid = s.useOrgSid |
|
|
|
and r.vehModelSid = s.vehModelSid |
|
|
|
and r.vehMConfigSid = s.vehMConfigSid |
|
|
@ -617,7 +653,8 @@ where DATE_FORMAT(createTime, '%Y-%m-%d') = CURDATE(); |
|
|
|
|
|
|
|
|
|
|
|
-- 欠款出库金融--截止当日欠款出库申请通过且未回清款的台数欠款总额 |
|
|
|
update daily_report r inner join (select sum(cc.scount) as scount,cc.useOrgSid, cc.vehMConfigSid, cc.vehModelSid from ( |
|
|
|
update daily_report r inner join (select sum(cc.scount) as scount, cc.useOrgSid, cc.vehMConfigSid, cc.vehModelSid |
|
|
|
from ( |
|
|
|
select (sum(fd.reveivableMoney) - sum(fs.subscriptionMoney)) as scount, |
|
|
|
ba.useOrgSid, |
|
|
|
bm.modelConfigSid as vehMConfigSid, |
|
|
@ -627,23 +664,33 @@ update daily_report r inner join (select sum(cc.scount) as scount,cc.useOrgSid, |
|
|
|
left join anrui_buscenter.bus_sales_order_vehicle bv on bv.sid = bdad.busVinSid |
|
|
|
left join anrui_buscenter.bus_sales_order bo on bo.sid = bv.salesOrderSid |
|
|
|
left join anrui_buscenter.bus_sales_order_model bm on bm.salesOrderSid = bo.sid |
|
|
|
left join anrui_fin.fin_uncollected_receivables_detailed fd on fd.busVinSid = bdad.busVinSid |
|
|
|
left join anrui_fin.fin_selected_receivables_detailed fs on fs.receivablesSid = fd.sid |
|
|
|
left join anrui_fin.fin_uncollected_receivables_detailed fd |
|
|
|
on fd.busVinSid = bdad.busVinSid |
|
|
|
left join anrui_fin.fin_selected_receivables_detailed fs |
|
|
|
on fs.receivablesSid = fd.sid |
|
|
|
where ba.nodeState = '已办结' |
|
|
|
and ba.typeState = 1 |
|
|
|
group by bdad.busVinSid, ba.useOrgSid, bm.modelSid, bm.modelConfigSid |
|
|
|
having sum(fd.reveivableMoney) > ifnull(sum(fs.subscriptionMoney), 0) |
|
|
|
union all |
|
|
|
select (sum(fd.reveivableMoney) - sum(fs.subscriptionMoney)) as scount,ba.useOrgSid,bm.modelConfigSid as vehMConfigSid, bm.modelSid as vehModelSid |
|
|
|
select (sum(fd.reveivableMoney) - sum(fs.subscriptionMoney)) as scount, |
|
|
|
ba.useOrgSid, |
|
|
|
bm.modelConfigSid as vehMConfigSid, |
|
|
|
bm.modelSid as vehModelSid |
|
|
|
from anrui_buscenter.bus_arrears_carry_vehicle_details bdad |
|
|
|
left join anrui_buscenter.bus_arrears_carry_vehicle_apply ba on ba.sid = bdad.applySid |
|
|
|
left join anrui_buscenter.bus_arrears_carry_vehicle_apply ba |
|
|
|
on ba.sid = bdad.applySid |
|
|
|
left join anrui_buscenter.bus_sales_order_vehicle bv on bv.linkSid = bdad.vinSid |
|
|
|
left join anrui_buscenter.bus_sales_order bo on bo.sid = bv.salesOrderSid |
|
|
|
left join anrui_buscenter.bus_sales_order_model bm on bm.salesOrderSid = bo.sid |
|
|
|
left join anrui_fin.fin_uncollected_receivables_detailed fd on fd.busVinSid = bv.sid |
|
|
|
left join anrui_fin.fin_selected_receivables_detailed fs on fs.receivablesSid = fd.sid |
|
|
|
left join anrui_fin.fin_uncollected_receivables_detailed fd |
|
|
|
on fd.busVinSid = bv.sid |
|
|
|
left join anrui_fin.fin_selected_receivables_detailed fs |
|
|
|
on fs.receivablesSid = fd.sid |
|
|
|
left join anrui_base.base_vehicle bbv on bbv.sid = bv.linkSid |
|
|
|
where ba.nodeState = '已办结' and ba.paymentMethodKey = 1 and bbv.vehicleState = '0002' |
|
|
|
where ba.nodeState = '已办结' |
|
|
|
and ba.paymentMethodKey = 1 |
|
|
|
and bbv.vehicleState = '0002' |
|
|
|
group by bv.sid, ba.useOrgSid, bm.modelSid, bm.modelConfigSid |
|
|
|
having sum(fd.reveivableMoney) > ifnull(sum(fs.subscriptionMoney), 0)) cc |
|
|
|
) s |
|
|
|