修改APP额度查询金额数据不正确问题

This commit is contained in:
zhangjun 2020-08-04 18:36:40 +08:00
parent 9c05815ab1
commit 2397c6424d

View File

@ -211,11 +211,14 @@ public class ApplyArchiveServiceImpl implements ApplyArchiveService{
Map<String, Object> testMap = (Map<String, Object>) MultipartDataUtil
.readRequestParam(request, "UTF-8");
fieldMap = (Map<String, Object>) testMap.get("fieldMap");
String userId = fieldMap.get("belongorg") == null ? "" : fieldMap.get("belongorg").toString();
//String userId = fieldMap.get("belongorg") == null ? "" : fieldMap.get("belongorg").toString();
String userId = fieldMap.get("userid") == null ? "" : fieldMap.get("userid").toString();
ASUser asUser = new ASUser(userId);
String orgID = asUser.getOrgID();
String sql = "";
//sql = "select o.distributor_no,ifnull(b.caution_money,0) as bcaution_money,ifnull(t.caution_money,0) as tcaution_money,ifnull(sum(b.caution_money),0) - ifnull(sum(t.caution_money),0) as surrende,o.total,o.usedlines,o.relines from vi_distributor_lines o left join d_depositcharge_info b on b.distributor_id = o.distributor_no and b.money_type = 'bondcollect' left join d_depositreturn_info t on t.distributor_id = o.distributor_no and t.money_type = 'bondreturn' group by o.distributor_no";
//sql = "SELECT o.distributor_no,IFNULL(b.caution_money,0) AS bcaution_money,IFNULL(t.caution_money,0) AS tcaution_money,IFNULL(SUM(b.caution_money),0) - IFNULL(SUM(t.caution_money),0) AS surrende,o.total,o.usedlines,o.relines FROM vi_distributor_lines o LEFT JOIN d_depositcharge_info b ON b.distributor_id = o.distributor_no AND b.money_type = 'bondcollect' LEFT JOIN d_depositreturn_info t ON t.distributor_id = o.distributor_no AND t.money_type = 'bondreturn' WHERE o.distributor_no=(SELECT distributor_no FROM distributor_info WHERE orgid='"+userId+"') ";
sql = "SELECT o.distributor_no,IFNULL(b.caution_money,0) AS bcaution_money,IFNULL(t.caution_money,0) AS tcaution_money,IFNULL(SUM(b.caution_money),0) - IFNULL(SUM(t.caution_money),0) AS surrende,o.total,IFNULL(lccs.fact_money,0) AS usedlines,ROUND(IFNULL(o.total,0)-(IFNULL(vlrp.corpus_over,0)),2) AS relines FROM vi_distributor_lines o LEFT JOIN d_depositcharge_info b ON b.distributor_id = o.distributor_no AND b.money_type = 'bondcollect' LEFT JOIN d_depositreturn_info t ON t.distributor_id = o.distributor_no AND t.money_type = 'bondreturn' LEFT JOIN (SELECT SUM(vlrp.corpus_over) corpus_over,di.distributor_no FROM vi_lc_rent_plan11 vlrp LEFT JOIN lb_contract_info lci ON vlrp.contract_id = lci.id LEFT JOIN distributor_info di ON lci.distributor_id = di.distributor_no GROUP BY di.distributor_no) vlrp ON vlrp.distributor_no=o.distributor_no LEFT JOIN (SELECT lci.distributor_id,SUM(lcc.clean_lease_money) fact_money FROM lc_calc_condition lcc LEFT JOIN lb_contract_info lci ON lci.id=lcc.contract_id WHERE (lci.CONTRACT_STATUS BETWEEN 31 AND 100 OR lci.CONTRACT_STATUS='103' OR lci.CONTRACT_STATUS='105') GROUP BY lci.distributor_id) lccs ON lccs.distributor_id=o.distributor_no WHERE o.distributor_no=(SELECT distributor_no FROM distributor_info WHERE orgid='"+userId+"') ";
sql = "SELECT O.DISTRIBUTOR_NO,TOTAL,O.USEDLINES,O.RELINES,CAUTION_MONEY FROM vi_distributor_lines O LEFT JOIN (SELECT SUM(CAUTION_MONEY) AS CAUTION_MONEY,distributor_id,money_type FROM d_depositcharge_info WHERE money_type = 'bondcollect' GROUP BY distributor_id) b ON b.distributor_id = O.distributor_no WHERE O.distributor_no=(SELECT distributor_no FROM distributor_info WHERE orgid='"+orgID+"') ";
List<Map<String, String>> dataList = DataOperatorUtil.getDataBySql(sql);
if(dataList.size()>0){
Map<String, Object> body = new HashMap<String, Object>();
@ -442,7 +445,7 @@ public class ApplyArchiveServiceImpl implements ApplyArchiveService{
String orgID = asUser.getOrgID();
String sql = "";
//sql = "select t.plan_date,t.rent,t.contract_id,sum(t.residue_rent) as residue_rent from (select lrp.plan_date,lrp.rent,lrp.contract_id,ifnull(sum(lrp.rent),0) - ifnull(sum(lri.rent),0) as residue_rent from lc_rent_plan lrp left join lc_rent_income lri on lri.plan_id=lrp.id WHERE lrp.plan_date <NOW() group by lrp.id ) t where t.residue_rent>=0 group by t.plan_date order by t.plan_date asc limit 0,30 ";
sql = "SELECT LEFT(lrp.plan_date,7),SUM(IFNULL(lrp.rent,0)) AS rent,SUM(IFNULL(lrp.rent,0))-SUM(IFNULL(lri.rent,0)) AS residue_rent FROM lc_rent_plan lrp LEFT JOIN (SELECT SUM(rent) rent,contract_id,plan_list FROM lc_rent_income GROUP BY contract_id,plan_list) lri ON lrp.contract_id=lri.contract_id AND lrp.plan_list=lri.plan_list LEFT JOIN lb_contract_info lci ON lci.id=lrp.contract_id WHERE lci.distributor_id=(SELECT distributor_no FROM distributor_info WHERE orgid='"+orgID+"') AND lrp.plan_date <NOW() GROUP BY LEFT(lrp.plan_date,7) ORDER BY LEFT(lrp.plan_date,7) DESC LIMIT 0,12 ";
sql = "SELECT LEFT(lrp.plan_date,7) as plan_date,SUM(IFNULL(lrp.rent,0)) AS rent,SUM(IFNULL(lrp.rent,0))-SUM(IFNULL(lri.rent,0)) AS residue_rent FROM lc_rent_plan lrp LEFT JOIN (SELECT SUM(rent) rent,contract_id,plan_list FROM lc_rent_income GROUP BY contract_id,plan_list) lri ON lrp.contract_id=lri.contract_id AND lrp.plan_list=lri.plan_list LEFT JOIN lb_contract_info lci ON lci.id=lrp.contract_id WHERE lci.distributor_id=(SELECT distributor_no FROM distributor_info WHERE orgid='"+orgID+"') AND lrp.plan_date <NOW() GROUP BY LEFT(lrp.plan_date,7) ORDER BY LEFT(lrp.plan_date,7) DESC LIMIT 0,12 ";
List<Map<String, String>> dataList = DataOperatorUtil.getDataBySql(sql);
if(dataList.size()>0){
Map<String, Object> body = new HashMap<String, Object>();