From 846df5ab833d060dd7babc41c7635eb48eb78b20 Mon Sep 17 00:00:00 2001 From: zhangbb Date: Mon, 25 May 2020 14:27:11 +0800 Subject: [PATCH] =?UTF-8?q?1.=E5=A4=A9=E6=B4=A5=E5=8D=A1=E6=89=A3=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E6=B3=A8=E9=87=8A=EF=BC=8C=E4=BC=98=E5=8C=96=E5=86=85?= =?UTF-8?q?=E5=AE=B9=EF=BC=8C=E4=BF=AE=E5=A4=8D=E5=BD=93=E6=89=A3=E6=AC=BE?= =?UTF-8?q?=E9=87=91=E9=A2=9D=E4=B8=BA=E9=99=90=E9=A2=9D=E7=9A=84=E5=80=8D?= =?UTF-8?q?=E6=95=B0=E6=97=B6=E9=80=A0=E6=88=90=E7=9A=84=E5=AE=9E=E6=94=B6?= =?UTF-8?q?=E8=A1=A8=E9=87=91=E9=A2=9D=E4=B8=BA0=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cache/CollectAuditInfoCacheTj.java | 150 ++++++++++-------- 1 file changed, 86 insertions(+), 64 deletions(-) diff --git a/src_tenwa/com/tenwa/collectaudit/cache/CollectAuditInfoCacheTj.java b/src_tenwa/com/tenwa/collectaudit/cache/CollectAuditInfoCacheTj.java index 0662b1816..602a98ad6 100644 --- a/src_tenwa/com/tenwa/collectaudit/cache/CollectAuditInfoCacheTj.java +++ b/src_tenwa/com/tenwa/collectaudit/cache/CollectAuditInfoCacheTj.java @@ -828,30 +828,35 @@ public class CollectAuditInfoCacheTj { String bank_name = bo.getAttribute("BANK_NAME").toString(); int m = 0; String[] singleRent = null; + BigDecimal mi = new BigDecimal(rent); + List codelist = JBOFactory.getFactory().getBizObjectManager(CODE_LIBRARY.CLASS_NAME).createQuery("O.codeno = 'TjbankType' and O.itemdescribe is not null ").getResultList(false); for (BizObject code : codelist) { String itemname = code.getAttribute("itemname").toString().trim(); - double itemdescribe = code.getAttribute("itemdescribe").getDouble(); - if (bank_name.indexOf(itemname) !=-1 && Double.parseDouble(bo.getAttribute("rent").toString()) > itemdescribe) { - BigDecimal mi = new BigDecimal(bo.getAttribute("rent").toString()); - int singlerent = mi.multiply(new BigDecimal(100)).intValue(); - BigDecimal mj = new BigDecimal(itemdescribe); - long divide = mj.multiply(new BigDecimal(100)).longValue(); - if(divide!=0){ - int k = (int) Math.floor(singlerent/divide); - int l = (int) Math.ceil(singlerent%divide); - for (int j = 0; j < k; j++) { - m++; - } - if (l!=0) { - m++; - } - singleRent = new String[m]; - for (int i = 0; i < k; i++) { - singleRent[i] = itemdescribe+""; - } - singleRent[m-1] = String.format("%.2f",bo.getAttribute("rent").getDouble() - k*itemdescribe); - break;//如果匹配到,则跳出循环 + if (bank_name.indexOf(itemname) !=-1) { + BigDecimal limit_money = new BigDecimal(code.getAttribute("itemdescribe").getString()); + BigDecimal mj = limit_money; + if(mi.compareTo(mj)==1){ + int singlerent = mi.multiply(new BigDecimal(100)).intValue(); + int divide = mj.multiply(new BigDecimal(100)).intValue(); + if(divide!=0){ + int k = singlerent/divide; + int l = singlerent%divide; + for (int j = 0; j < k; j++) { + m++; + } + if (l!=0) { + m++; + } + singleRent = new String[m]; + for (int i = 0; i < k; i++) { + singleRent[i] = limit_money.toString(); + } + if(l!=0){ + singleRent[m-1] = mi.subtract(mj.multiply(new BigDecimal(k))).setScale(2, BigDecimal.ROUND_HALF_UP).toString(); + } + break;//如果匹配到,则跳出循环 + } } } } @@ -871,6 +876,7 @@ public class CollectAuditInfoCacheTj { for (int i = 1; i <= snArray.length; i++) { Map map = querySingleBatchCollect(tx, bo, query_sn, snArray[(i-1)]); if (snArray.length == 1) { + //回盘成功 if (map.containsKey("RET_CODE") && "0000".equals(map.get("RET_CODE"))) { querysingleCollectMoeny(tx, bc, bo, rent,i+""); //更新收付状态 @@ -888,6 +894,7 @@ public class CollectAuditInfoCacheTj { bo.setAttributeValue("BATCH_STATUS", "complete"); //bo.setAttributeValue("rent", bo.getAttribute("rent").toString()); saveBuckle(bo,tx,sn,rent); + //处理中 }else if (map.containsKey("RET_CODE") && ("2007".equals(map.get("RET_CODE")) || "2005".equals(map.get("RET_CODE")) || "2003".equals(map.get("RET_CODE")) || "2001".equals(map.get("RET_CODE")) || "2000".equals(map.get("RET_CODE")))){ //更新银联处理中的反馈信息 bc.createQuery("update O set O.COLLECT_MSG=:COLLECT_MSG where O.id=:id") @@ -895,6 +902,7 @@ public class CollectAuditInfoCacheTj { .setParameter("id", bo.getAttribute("id").toString()).executeUpdate(); bo.setAttributeValue("COLLECT_MSG", map.get("ERR_MSG")); saveBuckle(bo,tx,sn,"0.00"); + //扣款失败 }else{ //更新收付状态 bc.createQuery("update O set O.COLLECT_STATUS=:COLLECT_STATUS ,O.COLLECT_MSG=:COLLECT_MSG,O.BATCH_STATUS=:BATCH_STATUS,O.BATCH_NO='',O.BATCH_SN='' where O.id=:id") @@ -927,7 +935,7 @@ public class CollectAuditInfoCacheTj { bo.setAttributeValue("COLLECT_MSG", "批量代收,收款成功"); bo.setAttributeValue("BATCH_STATUS", "complete"); //bo.setAttributeValue("rent", bo.getAttribute("rent").toString()); - saveBuckle(bo,tx,i+"",singleRent[i-1]); + saveBuckle(bo,tx,snArray[(i-1)],singleRent[i-1]); }else{ //更新收付状态 bc.createQuery("update O set O.COLLECT_STATUS=:COLLECT_STATUS ,O.COLLECT_MSG=:COLLECT_MSG,O.BATCH_STATUS=:BATCH_STATUS where O.id=:id") @@ -938,15 +946,15 @@ public class CollectAuditInfoCacheTj { bo.setAttributeValue("COLLECT_STATUS", "部分收款"); bo.setAttributeValue("COLLECT_MSG", map.get("ERR_MSG")); bo.setAttributeValue("BATCH_STATUS", "complete"); - saveBuckle(bo,tx,i+"",singleRent[i-1]); + saveBuckle(bo,tx,snArray[(i-1)],singleRent[i-1]); } }else if (map.containsKey("RET_CODE") && ("2007".equals(map.get("RET_CODE")) || "2005".equals(map.get("RET_CODE")) || "2003".equals(map.get("RET_CODE")) || "2001".equals(map.get("RET_CODE")) || "2000".equals(map.get("RET_CODE")))){ //更新银联处理中的反馈信息 bc.createQuery("update O set O.COLLECT_MSG=:COLLECT_MSG where O.id=:id") .setParameter("COLLECT_MSG", map.get("ERR_MSG")) .setParameter("id", bo.getAttribute("id").toString()).executeUpdate(); - bo.setAttributeValue("COLLECT_MSG", map.get("ERR_MSG")); - saveBuckle(bo,tx,i+"","0.00"); + bo.setAttributeValue("COLLECT_MSG", map.get("ER R_MSG")); + saveBuckle(bo,tx,snArray[(i-1)],"0.00"); }else{//批量拆分多笔扣款,如果扣款成功条数未 0 ,则更新扣款状态为 未扣款 if (i == snArray.length && n == 0) { //更新收付状态 @@ -958,7 +966,7 @@ public class CollectAuditInfoCacheTj { bo.setAttributeValue("COLLECT_STATUS", "未收款"); bo.setAttributeValue("COLLECT_MSG", map.get("ERR_MSG")); bo.setAttributeValue("BATCH_STATUS", ""); - saveBuckle(bo,tx,i+"","0.00"); + saveBuckle(bo,tx,snArray[(i-1)],"0.00"); } } } @@ -1176,6 +1184,7 @@ public class CollectAuditInfoCacheTj { savaFile(tx, strResp,batch_title,bo); } Map map = getRetAndCodeByBatch(strResp); + //包含RET_CODE说明响应没有成功 if (map.containsKey("RET_CODE")) {//清空批量代收状态 for (BizObject biz : list) { //清空批量处理状态 @@ -1189,6 +1198,7 @@ public class CollectAuditInfoCacheTj { trans.commit(); } }else{ + //响应成功 int m = 0;//统计发送的代收的批数 for (int n = 1; n <= map.size(); n++) { if (map.containsKey("SN"+n)) { @@ -1196,10 +1206,12 @@ public class CollectAuditInfoCacheTj { } } for (int k = 1; k <= m; k++) { + //每条响应成功 if (map.containsKey("REQ_SN") && map.containsKey("RET_CODE"+k) && "0000".equals(map.get("RET_CODE"+k))) { JBOTransaction trans = JBOFactory.createJBOTransaction(); BizObjectManager bm = JBOFactory.getFactory().getManager(LC_RENT_PLAN.CLASS_NAME,trans); BizObject bo0 = bm.createQuery("O.BATCH_NO=:BATCH_NO and O.BATCH_SN like '%"+map.get("SN"+k)+"%'").setParameter("BATCH_NO", map.get("REQ_SN")).getSingleResult(false); + //不知道为啥这么写 if (bo0 != null && "process".equals(bo0.getAttribute("BATCH_STATUS"))) { bm.createQuery("update O set O.BATCH_STATUS=:BATCH_STATUS where O.BATCH_NO=:BATCH_NO and O.BATCH_SN like '%"+map.get("SN"+k)+"%' ") .setParameter("BATCH_STATUS", "process")//处理状态标记为--处理中 @@ -1258,34 +1270,34 @@ public class CollectAuditInfoCacheTj { strbuff.append(""); strbuff.append(""); strbuff.append(""); + //总金额 BigDecimal mutly = new BigDecimal("0"); + //总条数 int i = 0; for (BizObject bo : list) { - String single = bo.getAttribute("rent").toString(); - BigDecimal m = new BigDecimal(single); - mutly = mutly.add(m); + String single_s = bo.getAttribute("rent").toString(); + BigDecimal m_s = new BigDecimal(single_s); + mutly = mutly.add(m_s); String bank_name = bo.getAttribute("BANK_NAME").toString(); List codelist = JBOFactory.getFactory().getBizObjectManager(CODE_LIBRARY.CLASS_NAME).createQuery("O.codeno = 'TjbankType' and O.itemdescribe is not null ").getResultList(false); //数据字典中的itemdescribe字段代表银行单笔限 - double itemdescribe = 0; + BigDecimal itemdescribe = new BigDecimal("0"); boolean flag = false; for (BizObject code : codelist) { String itemnameTmp = code.getAttribute("itemname").toString().trim(); - double itemdescribeTmp = code.getAttribute("itemdescribe").getDouble(); String itemdescribeTmp1 = code.getAttribute("itemdescribe").toString(); if (bank_name.indexOf(itemnameTmp) != -1 && itemdescribeTmp1 != null && !"".equals(itemdescribeTmp1)) { - itemdescribe = new BigDecimal(itemdescribeTmp).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); + itemdescribe = new BigDecimal(itemdescribeTmp1).setScale(2, BigDecimal.ROUND_HALF_UP); flag = true; break; } } - - if (flag == true && Double.parseDouble(bo.getAttribute("rent").toString()) > itemdescribe) { - BigDecimal mi = new BigDecimal(bo.getAttribute("rent").toString()); - int singlerent = mi.multiply(new BigDecimal(100)).intValue(); - int singleitem = new BigDecimal(itemdescribe).multiply(new BigDecimal(100)).intValue(); - int k = (int) Math.floor(singlerent/singleitem); - int l = (int) Math.ceil(singlerent%singleitem); + if (flag == true && m_s.compareTo(itemdescribe)==1) { + BigDecimal mi_s = m_s; + int singlerent = mi_s.multiply(new BigDecimal(100)).intValue(); + int singleitem = itemdescribe.multiply(new BigDecimal(100)).intValue(); + int k = singlerent/singleitem; + int l = singlerent%singleitem; for (int j = 0; j < k; j++) { i++; } @@ -1316,33 +1328,36 @@ public class CollectAuditInfoCacheTj { String account = biz.getAttribute("account").toString(); String bank_name = biz.getAttribute("BANK_NAME").toString(); List codelist = JBOFactory.getFactory().getBizObjectManager(CODE_LIBRARY.CLASS_NAME).createQuery("O.codeno = 'TjbankType' and O.itemdescribe is not null ").getResultList(false); - double itemdescribe = 0; + BigDecimal itemdescribe = new BigDecimal("0"); boolean flag = false; for (BizObject code : codelist) { String itemnameTmp = code.getAttribute("itemname").toString().trim(); - double itemdescribeTmp = code.getAttribute("itemdescribe").getDouble(); String itemdescribeTmp1 = code.getAttribute("itemdescribe").toString(); if (bank_name.indexOf(itemnameTmp) != -1 && itemdescribeTmp1 != null && !"".equals(itemdescribeTmp1)) { - itemdescribe = new BigDecimal(itemdescribeTmp).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); + itemdescribe = new BigDecimal(itemdescribeTmp1).setScale(2, BigDecimal.ROUND_HALF_UP); flag = true; break; } } - if (flag == true && Double.parseDouble(biz.getAttribute("rent").toString()) > itemdescribe) { - BigDecimal mi = new BigDecimal(biz.getAttribute("rent").toString()); + if (flag == true && m.compareTo(itemdescribe)==1) { + BigDecimal mi = m; int singlerent = mi.multiply(new BigDecimal(100)).intValue(); - int singleitem = new BigDecimal(itemdescribe).multiply(new BigDecimal(100)).intValue(); - int k = (int) Math.floor(singlerent/singleitem); - int l = (int) Math.ceil(singlerent%singleitem); + int singleitem = itemdescribe.multiply(new BigDecimal(100)).intValue(); + int k = singlerent/singleitem; + int l = singlerent%singleitem; for (int k2 = 1; k2 <= k; k2++) { Trans_Detail trans_detail = new Trans_Detail(); String sn = ""; - if (item >= 9&&item<99) { - sn = "000"+ (++item); - }else if(item >= 99){ - sn = "00"+ (++item); - }else{ + if(item < 9){ sn = "0000"+ (++item); + }else if (item >= 9&&item<99) { + sn = "000"+ (++item); + }else if(item >= 99&&item<999){ + sn = "00"+ (++item); + }else if(item >= 999&&item<9999){ + sn = "0"+ (++item); + }else{ + sn = "" + (++item); } //追加批量处理状态 JBOTransaction trans = JBOFactory.createJBOTransaction(); @@ -1374,17 +1389,20 @@ public class CollectAuditInfoCacheTj { strbuff.append(EntityTransform.toXmlByBatchCollect(trans_detail)); } if (l != 0) { - String surprent = String.format("%.2f", biz.getAttribute("rent").getDouble() - k*itemdescribe); - BigDecimal mj = new BigDecimal(surprent); + BigDecimal mj = mi.subtract(itemdescribe.multiply(new BigDecimal(k))).setScale(2, BigDecimal.ROUND_HALF_UP); String singlerent0 = String.valueOf(mj.multiply(new BigDecimal(100)).longValue()); Trans_Detail trans_detail = new Trans_Detail(); String sn = ""; - if (item >= 9&&item<99) { - sn = "000"+ (++item); - }else if(item >= 99){ - sn = "00"+ (++item); - }else{ + if(item < 9){ sn = "0000"+ (++item); + }else if (item >= 9&&item<99) { + sn = "000"+ (++item); + }else if(item >= 99&&item<999){ + sn = "00"+ (++item); + }else if(item >= 999&&item<9999){ + sn = "0"+ (++item); + }else{ + sn = "" + (++item); } //追加批量处理状态 JBOTransaction trans = JBOFactory.createJBOTransaction(); @@ -1418,12 +1436,16 @@ public class CollectAuditInfoCacheTj { }else{ Trans_Detail trans_detail = new Trans_Detail(); String sn = ""; - if (item >= 9&&item<99) { - sn = "000"+ (++item); - }else if(item >= 99){ - sn = "00"+ (++item); - }else{ + if(item < 9){ sn = "0000"+ (++item); + }else if (item >= 9&&item<99) { + sn = "000"+ (++item); + }else if(item >= 99&&item<999){ + sn = "00"+ (++item); + }else if(item >= 999&&item<9999){ + sn = "0"+ (++item); + }else{ + sn = "" + (++item); } //追加批量处理状态 JBOTransaction trans = JBOFactory.createJBOTransaction();