From 41356f92b18787c0cfff3d777be5eeba0053d03f Mon Sep 17 00:00:00 2001 From: pangyang <475446853@qq.com> Date: Thu, 2 Jun 2022 11:16:32 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=80=E7=A5=A8=E6=A8=A1=E5=9D=97=E5=8F=91?= =?UTF-8?q?=E7=A5=A8=E5=88=86=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/djy/invoice/model/InvLinkInfo.java | 4 + .../service/impl/InvLinkInfoServiceImpl.java | 162 ++++++++++++++++++ 2 files changed, 166 insertions(+) diff --git a/invoice/src/main/java/com/djy/invoice/model/InvLinkInfo.java b/invoice/src/main/java/com/djy/invoice/model/InvLinkInfo.java index dd7b0da..32b50d1 100644 --- a/invoice/src/main/java/com/djy/invoice/model/InvLinkInfo.java +++ b/invoice/src/main/java/com/djy/invoice/model/InvLinkInfo.java @@ -65,6 +65,10 @@ public class InvLinkInfo { private BigDecimal rmbFees; private BigDecimal usdFess; + //发票数量 + private int invoiceAmount; + //usd转为人民币金额 + private BigDecimal usdInvoiceAmount; } 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 7aa429a..1ac2a7f 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 @@ -197,6 +197,147 @@ public class InvLinkInfoServiceImpl implements InvLinkInfoService { return split; } + + int getInvoiceAmount(List fees,InvLinkInfo link,BigDecimal sumfees){ + + List list = new ArrayList<>(); + + if(null != fees && fees.size()>0){ + + + + BigDecimal checkinvocie = new BigDecimal(0); + + if("RMB".equals(fees.get(0).getCurrency())){ + checkinvocie = invoiceAmount; + }else{ + checkinvocie = invoiceAmount.divide(fees.get(0).getExchangeRate()).setScale(2,BigDecimal.ROUND_HALF_UP); + } + + + + //如果费用总计小于等于最大开票金额 + if(checkinvocie.compareTo(sumfees) == 1){ + InvInvoiceInfo invoice = new InvInvoiceInfo(); + list.add(invoice); + + }else{ + + BigDecimal amount = new BigDecimal(0); +// List details = new ArrayList<>(); + List splits = new ArrayList<>(); + InvInvoiceInfo invoice = null; + for(int i=0;i(); + if(remainAmount.compareTo(new BigDecimal(0))==1){ + InvInvoiceSplit split = getInvInvoiceSplit(new InvInvoiceInfo(),new InvInvoiceDetail(),feeinfo,link,amount); + splits.add(split); + } + }else{ + //生成发票和发票明细 + invoice = new InvInvoiceInfo(); + list.add(invoice); + + + if((i==fees.size()-1) && (feeinfo.getAmount().compareTo(new BigDecimal(0))== 1)){ + invoice = new InvInvoiceInfo(); + list.add(invoice); + } + + amount = feeinfo.getAmount(); + + } + + }else{ + //如果amount等于最大开票金额 + if(amount.compareTo(checkinvocie)==0){ + //生成发票和发票明细 + invoice = new InvInvoiceInfo(); + list.add(invoice); + amount = new BigDecimal(0); + splits = new ArrayList<>(); + }else{ + //生成发票分配 + InvInvoiceSplit split = getInvInvoiceSplit(new InvInvoiceInfo(),new InvInvoiceDetail(),feeinfo,link,feeinfo.getAmount()); + splits.add(split); + + if(i==fees.size()-1){ + BigDecimal sums = splits.stream().map(InvInvoiceSplit::getAmountTotal).reduce(BigDecimal.ZERO,BigDecimal::add); + invoice = new InvInvoiceInfo(); + list.add(invoice); + } + + } + } + + } + + } + } + } + + return list.size(); + + } + + + void invoicepzRmb(List fees,InvLinkInfo link,BigDecimal sumfees){ if(null != fees && fees.size()>0){ @@ -242,6 +383,7 @@ public class InvLinkInfoServiceImpl implements InvLinkInfoService { BigDecimal[] results = feeinfo.getAmount().divideAndRemainder(checkinvocie); int size = results[0].intValue(); for(int m=0;m fees = invFeeInfoMapper.getListBylink(fee); BigDecimal sumfees = fees.stream().map(InvFeeInfo::getAmount).reduce(BigDecimal.ZERO,BigDecimal::add); + int 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); + + BigDecimal usdInvoiceAmount = usdfees.multiply(feesNoRmb.get(0).getExchangeRate()).setScale(2,BigDecimal.ROUND_HALF_UP); + + link.setUsdInvoiceAmount(usdInvoiceAmount); + link.setInvoiceAmount(rmbamount+usdamount); link.setBillList(businesses); link.setRmbFees(sumfees);