|
|
@ -279,4 +279,155 @@ |
|
|
|
ORDER BY a.division_name desc, a.year DESC; |
|
|
|
|
|
|
|
</select> |
|
|
|
|
|
|
|
<select id="getBrandsNameList" resultType="com.yxt.anrui.reportcenter.api.factoryDailyReport.YearAllVo"> |
|
|
|
SELECT |
|
|
|
date_info.brandName as name, |
|
|
|
date_info.brandSid AS linkSid, |
|
|
|
COUNT(DISTINCT LEFT(date_info.date_str, 4)) AS colspan |
|
|
|
FROM ( |
|
|
|
-- 单车返利表 |
|
|
|
SELECT |
|
|
|
brandSid,brandName, |
|
|
|
palceGenDate AS date_str |
|
|
|
FROM anrui_scm.scm_veh_rebate |
|
|
|
WHERE orgPath LIKE concat('%/',#{divisionSid},'/%') |
|
|
|
AND palceGenDate IS NOT NULL |
|
|
|
AND LEFT(palceGenDate, 4) != '' and LEFT(palceGenDate, 4) is not null |
|
|
|
|
|
|
|
UNION ALL |
|
|
|
|
|
|
|
-- 专项返利表 |
|
|
|
SELECT |
|
|
|
brandSid,brandName, |
|
|
|
palceGenDate AS date_str |
|
|
|
FROM anrui_scm.scm_special_rebate |
|
|
|
WHERE orgPath LIKE concat('%/',#{divisionSid},'/%') |
|
|
|
AND palceGenDate IS NOT NULL |
|
|
|
AND LEFT(palceGenDate, 4) != '' and LEFT(palceGenDate, 4) is not null |
|
|
|
|
|
|
|
UNION ALL |
|
|
|
|
|
|
|
-- 回款返利表 |
|
|
|
SELECT |
|
|
|
brandSid,brandName, |
|
|
|
collectionDate AS date_str |
|
|
|
FROM anrui_scm.scm_collection_rebate |
|
|
|
WHERE orgPath LIKE concat('%/',#{divisionSid},'/%') |
|
|
|
AND collectionDate IS NOT NULL |
|
|
|
AND LEFT(collectionDate, 4) != '' and LEFT(collectionDate, 4) is not null |
|
|
|
) AS date_info |
|
|
|
GROUP BY |
|
|
|
date_info.brandSid |
|
|
|
ORDER BY |
|
|
|
date_info.brandSid desc; |
|
|
|
</select> |
|
|
|
|
|
|
|
<select id="getSybList2" resultType="com.yxt.anrui.reportcenter.api.factoryDailyReport.FactoryDaliyReportVo"> |
|
|
|
SELECT |
|
|
|
a.year, |
|
|
|
a.division_name, |
|
|
|
a.brandSid, |
|
|
|
ROUND(SUM(a.estimateRebate), 2) AS estimate, |
|
|
|
ROUND(SUM(a.uploadMoney), 2) AS upload, |
|
|
|
ROUND(SUM(a.adjustmentMoney), 2) AS adjust, |
|
|
|
ROUND(SUM(a.notUploadMoney), 2) AS notUploadMoney, |
|
|
|
ROUND(SUM(a.fee), 2) AS fee, |
|
|
|
ROUND(SUM(a.expense_payment), 2) AS expense_payment, |
|
|
|
ROUND(SUM(a.pending_payment), 2) AS pending_payment, |
|
|
|
ROUND(SUM(a.offset_payment), 2) AS offset_payment, |
|
|
|
ROUND(SUM(a.remaining_payment), 2) AS remaining_payment, |
|
|
|
ROUND(SUM(a.unuploaded_rebate), 2) AS unuploaded_rebate |
|
|
|
FROM ( |
|
|
|
SELECT |
|
|
|
brandSid, |
|
|
|
LEFT(palceGenDate, 4) AS year, |
|
|
|
SUBSTRING_INDEX(SUBSTRING_INDEX(orgPath, '/', 2), '/', -1) AS division_name, |
|
|
|
SUM(estimateRebate) estimateRebate, |
|
|
|
SUM(uploadMoney) uploadMoney, |
|
|
|
SUM(adjustmentMoney) adjustmentMoney, |
|
|
|
SUM( |
|
|
|
estimateRebate + |
|
|
|
IFNULL(CASE WHEN isAdjustment = '是' AND adjustmentState = 1 THEN adjustmentMoney ELSE 0 END, 0) |
|
|
|
- IFNULL(uploadMoney, 0) - IFNULL(secondaryUploadMoney, 0) |
|
|
|
) AS notUploadMoney, |
|
|
|
SUM( |
|
|
|
estimateRebate + |
|
|
|
IFNULL(CASE WHEN isAdjustment = '是' AND adjustmentState = 1 THEN adjustmentMoney ELSE 0 END, 0) |
|
|
|
- (uploadMoney + secondaryUploadMoney) |
|
|
|
) AS unuploaded_rebate, |
|
|
|
SUM(onceTreatCost + secondTreatCost + tempTreatCost + expectTreatCost + expectSuppCost + |
|
|
|
onceSuppCost + secondSuppCost + tempSuppCost) AS fee, |
|
|
|
SUM(onceTreatCost + secondTreatCost + tempTreatCost) AS expense_payment, |
|
|
|
SUM(expectTreatCost) AS pending_payment, |
|
|
|
SUM(expectSuppCost + onceSuppCost + secondSuppCost + tempSuppCost) AS offset_payment, |
|
|
|
SUM( |
|
|
|
estimateRebate - (uploadMoney + secondaryUploadMoney) |
|
|
|
- (onceTreatCost + secondTreatCost + tempTreatCost) |
|
|
|
- expectTreatCost |
|
|
|
- (expectSuppCost + onceSuppCost + secondSuppCost + tempSuppCost) |
|
|
|
) AS remaining_payment |
|
|
|
FROM anrui_scm.scm_veh_rebate |
|
|
|
where SUBSTRING_INDEX(SUBSTRING_INDEX(orgPath, '/', 2), '/', -1) = #{divisionSid} |
|
|
|
GROUP BY LEFT(palceGenDate, 4),brandSid |
|
|
|
|
|
|
|
UNION ALL |
|
|
|
|
|
|
|
SELECT |
|
|
|
brandSid, |
|
|
|
LEFT(palceGenDate, 4) AS year, |
|
|
|
SUBSTRING_INDEX(SUBSTRING_INDEX(orgPath, '/', 2), '/', -1) AS division_name, |
|
|
|
SUM(estimateRebate) estimateRebate, |
|
|
|
SUM(uploadMoney) uploadMoney, |
|
|
|
SUM(adjustmentMoney) adjustmentMoney, |
|
|
|
SUM( |
|
|
|
estimateRebate + |
|
|
|
IFNULL(CASE WHEN isAdjustment = '是' AND adjustmentState = 1 THEN adjustmentMoney ELSE 0 END, 0) |
|
|
|
- IFNULL(uploadMoney, 0) - IFNULL(secondaryUploadMoney, 0) |
|
|
|
) AS notUploadMoney, |
|
|
|
SUM( |
|
|
|
estimateRebate + |
|
|
|
IFNULL(CASE WHEN isAdjustment = '是' AND adjustmentState = 1 THEN adjustmentMoney ELSE 0 END, 0) |
|
|
|
- (uploadMoney + secondaryUploadMoney) |
|
|
|
) AS unuploaded_rebate, |
|
|
|
SUM(onceTreatCost + secondTreatCost + tempTreatCost + expectTreatCost + expectSuppCost + |
|
|
|
onceSuppCost + secondSuppCost + tempSuppCost) AS fee, |
|
|
|
SUM(onceTreatCost + secondTreatCost + tempTreatCost) AS expense_payment, |
|
|
|
SUM(expectTreatCost) AS pending_payment, |
|
|
|
SUM(expectSuppCost + onceSuppCost + secondSuppCost + tempSuppCost) AS offset_payment, |
|
|
|
SUM( |
|
|
|
estimateRebate - (uploadMoney + secondaryUploadMoney) |
|
|
|
- (onceTreatCost + secondTreatCost + tempTreatCost) |
|
|
|
- expectTreatCost |
|
|
|
- (expectSuppCost + onceSuppCost + secondSuppCost + tempSuppCost) |
|
|
|
) AS remaining_payment |
|
|
|
FROM anrui_scm.scm_special_rebate |
|
|
|
where SUBSTRING_INDEX(SUBSTRING_INDEX(orgPath, '/', 2), '/', -1) = #{divisionSid} |
|
|
|
GROUP BY LEFT(palceGenDate, 4), brandSid |
|
|
|
|
|
|
|
UNION ALL |
|
|
|
|
|
|
|
SELECT |
|
|
|
brandSid, |
|
|
|
LEFT(collectionDate, 4) AS year, |
|
|
|
SUBSTRING_INDEX(SUBSTRING_INDEX(orgPath, '/', 2), '/', -1) AS division_name, |
|
|
|
SUM(estimateRebate) estimateRebate, |
|
|
|
SUM(uploadMoney) uploadMoney, |
|
|
|
SUM(adjustmentMoney) adjustmentMoney, |
|
|
|
SUM(estimateRebate + IFNULL(adjustmentMoney, 0) - IFNULL(uploadMoney, 0)) AS notUploadMoney, |
|
|
|
SUM(estimateRebate + IFNULL(adjustmentMoney, 0) - uploadMoney) AS unuploaded_rebate, |
|
|
|
0 AS fee, |
|
|
|
0 AS expense_payment, |
|
|
|
0 AS pending_payment, |
|
|
|
0 AS offset_payment, |
|
|
|
SUM(estimateRebate - uploadMoney) AS remaining_payment |
|
|
|
FROM anrui_scm.scm_collection_rebate |
|
|
|
where SUBSTRING_INDEX(SUBSTRING_INDEX(orgPath, '/', 2), '/', -1) = #{divisionSid} |
|
|
|
GROUP BY LEFT(collectionDate, 4), brandSid |
|
|
|
) a |
|
|
|
WHERE a.year IS NOT NULL AND a.year != '' |
|
|
|
GROUP BY a.year, a.brandSid |
|
|
|
ORDER BY a.brandSid desc, a.year DESC; |
|
|
|
|
|
|
|
</select> |
|
|
|
</mapper> |