From f27a9e8b840e418a42de864b87d00629b7a67e69 Mon Sep 17 00:00:00 2001 From: pangyang <475446853@qq.com> Date: Tue, 7 Jun 2022 16:57:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=80=E7=A5=A8=E9=A1=B5=E9=9D=A2=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/InvLinkInfoServiceImpl.java | 34 +++++++++++++++---- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/invoice/src/main/java/com/djy/invoice/service/impl/InvLinkInfoServiceImpl.java b/invoice/src/main/java/com/djy/invoice/service/impl/InvLinkInfoServiceImpl.java index 3338050..2502178 100644 --- a/invoice/src/main/java/com/djy/invoice/service/impl/InvLinkInfoServiceImpl.java +++ b/invoice/src/main/java/com/djy/invoice/service/impl/InvLinkInfoServiceImpl.java @@ -111,6 +111,8 @@ public class InvLinkInfoServiceImpl implements InvLinkInfoService { } + String gid = ""; + String bsno=""; InvBusinessInfo businessinfo = invBusinessInfoMapper.getByBusiness(business); if(null != businessinfo){ try { @@ -120,8 +122,12 @@ public class InvLinkInfoServiceImpl implements InvLinkInfoService { } // invBusinessInfoMapper.deleteByGID(businessinfo); invBusinessInfoMapper.updateInvBusinessInfo(businessinfo); + gid = businessinfo.getGID(); + bsno = businessinfo.getBSNO(); }else{ invBusinessInfoMapper.add(business); + gid = business.getGID(); + bsno = business.getBSNO(); } @@ -132,8 +138,8 @@ public class InvLinkInfoServiceImpl implements InvLinkInfoService { JSONObject feeobject = feearray.getJSONObject(j); InvFeeInfo fee = JSONObject.parseObject(feeobject.toJSONString() , InvFeeInfo.class);// 将string类型直接封装成对象 fee.setGID((String)feeobject.get("FeeId")); - fee.setBSNO(business.getBSNO()); - fee.setBusinessId(business.getGID()); + fee.setBSNO(bsno); + fee.setBusinessId(gid); fee.setLinkId(linkinfo.getGID()); try { fee.setCreateTime(sdf.parse(sdf.format(new Date()))); @@ -832,19 +838,33 @@ public class InvLinkInfoServiceImpl implements InvLinkInfoService { fee.setLinkId(info.getGID()); fee.setCurrency("RMB"); List fees = invFeeInfoMapper.getListBylink(fee); - BigDecimal sumfees = fees.stream().map(InvFeeInfo::getAmount).reduce(BigDecimal.ZERO,BigDecimal::add); - int rmbamount = getInvoiceAmount(fees,link,sumfees); + int rmbamount =0; + BigDecimal sumfees = new BigDecimal(0); + if(null != fees && fees.size()>0){ + sumfees = fees.stream().map(InvFeeInfo::getAmount).reduce(BigDecimal.ZERO,BigDecimal::add); + rmbamount = getInvoiceAmount(fees,link,sumfees); + } + + + + InvFeeInfo feeNoRmb = new InvFeeInfo(); feeNoRmb.setLinkId(info.getGID()); List feesNoRmb = invFeeInfoMapper.getListBylinkNoRmb(feeNoRmb); - BigDecimal usdfees = feesNoRmb.stream().map(InvFeeInfo::getAmount).reduce(BigDecimal.ZERO,BigDecimal::add); - int usdamount = getInvoiceAmount(feesNoRmb,link,usdfees); + int usdamount =0; + BigDecimal usdInvoiceAmount = new BigDecimal(0); + BigDecimal usdfees = new BigDecimal(0); + if(null != feesNoRmb && feesNoRmb.size()>0){ + usdfees = feesNoRmb.stream().map(InvFeeInfo::getAmount).reduce(BigDecimal.ZERO,BigDecimal::add); + usdamount = getInvoiceAmount(feesNoRmb,link,usdfees); + usdInvoiceAmount = usdfees.multiply(feesNoRmb.get(0).getExchangeRate()).setScale(2,BigDecimal.ROUND_HALF_UP); + } + - BigDecimal usdInvoiceAmount = usdfees.multiply(feesNoRmb.get(0).getExchangeRate()).setScale(2,BigDecimal.ROUND_HALF_UP); link.setUsdInvoiceAmount(usdInvoiceAmount); link.setInvoiceAmount(rmbamount+usdamount);