|
@@ -18,6 +18,60 @@ import java.util.Map;
|
|
|
* @date 2024-01-10 14:10
|
|
* @date 2024-01-10 14:10
|
|
|
*/
|
|
*/
|
|
|
public class TransferUtils {
|
|
public class TransferUtils {
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 插入收入归属
|
|
|
|
|
+ * @param entProfit
|
|
|
|
|
+ * @param entAccount
|
|
|
|
|
+ * @param entAccountCard
|
|
|
|
|
+ * @param applyAmount
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ public static List<InvAccountOp> invAccountEntOpList(JSONObject entProfit,InvAccount entAccount, InvAccountCard entAccountCard, String applyAmount){
|
|
|
|
|
+ List<InvAccountOp> list = new ArrayList<>();
|
|
|
|
|
+ if (entProfit != null) {
|
|
|
|
|
+ for (Map.Entry<String, Object> entry : entProfit.entrySet()) {
|
|
|
|
|
+ if (Integer.parseInt(entry.getValue().toString()) != 0) {
|
|
|
|
|
+ InvAccountOp invAccountOp = new InvAccountOp();
|
|
|
|
|
+ invAccountOp.setAccountId(entAccount.getAccountId());
|
|
|
|
|
+ invAccountOp.setAccountName(entAccount.getAccountName());
|
|
|
|
|
+ invAccountOp.setCardNum(entAccountCard.getBankCardNum());
|
|
|
|
|
+ invAccountOp.setCardName(entAccountCard.getBankName());
|
|
|
|
|
+ invAccountOp.setProfit(entry.getKey());
|
|
|
|
|
+ invAccountOp.setMoney(new BigDecimal(entry.getValue().toString()).multiply(new BigDecimal(applyAmount)).divide(new BigDecimal(100), 2, RoundingMode.HALF_UP).toString());
|
|
|
|
|
+ list.add(invAccountOp);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return list;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 插入支出归属
|
|
|
|
|
+ * @param outProfit
|
|
|
|
|
+ * @param outAccount
|
|
|
|
|
+ * @param outAccountCard
|
|
|
|
|
+ * @param applyAmount
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ public static List<InvAccountOp> invAccountOutOpList(JSONObject outProfit,InvAccount outAccount, InvAccountCard outAccountCard, String applyAmount){
|
|
|
|
|
+ List<InvAccountOp> list = new ArrayList<>();
|
|
|
|
|
+ for (Map.Entry<String, Object> entry : outProfit.entrySet()) {
|
|
|
|
|
+ if (Integer.parseInt(entry.getValue().toString()) != 0) {
|
|
|
|
|
+ InvAccountOp invAccountOp = new InvAccountOp();
|
|
|
|
|
+ invAccountOp.setAccountId(outAccount.getAccountId());
|
|
|
|
|
+ invAccountOp.setAccountName(outAccount.getAccountName());
|
|
|
|
|
+ invAccountOp.setCardNum(outAccountCard.getBankCardNum());
|
|
|
|
|
+ invAccountOp.setCardName(outAccountCard.getBankName());
|
|
|
|
|
+ invAccountOp.setProfit(entry.getKey());
|
|
|
|
|
+ invAccountOp.setMoney(new BigDecimal(String.valueOf(entry.getValue())).multiply(new BigDecimal(applyAmount)).divide(new BigDecimal("100"), 2, RoundingMode.HALF_UP).negate().toString());
|
|
|
|
|
+ list.add(invAccountOp);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return list;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 转账成功后添加支出账户操作信息
|
|
* 转账成功后添加支出账户操作信息
|
|
|
*/
|
|
*/
|
|
@@ -27,7 +81,7 @@ public class TransferUtils {
|
|
|
InvAccountOperate operate = operate(insAccountExcel, insAccountOperate);
|
|
InvAccountOperate operate = operate(insAccountExcel, insAccountOperate);
|
|
|
operate.setRevenueOutlay("1");
|
|
operate.setRevenueOutlay("1");
|
|
|
JSONObject outProfit = insAccountExcel.getOutProfit();
|
|
JSONObject outProfit = insAccountExcel.getOutProfit();
|
|
|
- for (Map.Entry<String, Object> entry : outProfit.entrySet()){
|
|
|
|
|
|
|
+ for (Map.Entry<String, Object> entry : outProfit.entrySet()) {
|
|
|
outProfit.put(entry.getKey(), new BigDecimal(String.valueOf(entry.getValue())).negate().toString());
|
|
outProfit.put(entry.getKey(), new BigDecimal(String.valueOf(entry.getValue())).negate().toString());
|
|
|
}
|
|
}
|
|
|
operate.setOutProfit(outProfit);
|
|
operate.setOutProfit(outProfit);
|
|
@@ -51,7 +105,6 @@ public class TransferUtils {
|
|
|
operate.setEnterCardNum(insAccountExcel.getEnterCardNum());
|
|
operate.setEnterCardNum(insAccountExcel.getEnterCardNum());
|
|
|
return operate;
|
|
return operate;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
private static InvAccountOperate operate(InvAccountExcel invAccountExcel, InvAccountOperate invAccountOperate) {
|
|
private static InvAccountOperate operate(InvAccountExcel invAccountExcel, InvAccountOperate invAccountOperate) {
|
|
|
invAccountOperate.setApplicant(invAccountExcel.getApplicant());
|
|
invAccountOperate.setApplicant(invAccountExcel.getApplicant());
|
|
|
invAccountOperate.setApplySector(invAccountExcel.getApplySector());
|
|
invAccountOperate.setApplySector(invAccountExcel.getApplySector());
|
|
@@ -67,12 +120,29 @@ public class TransferUtils {
|
|
|
return invAccountOperate;
|
|
return invAccountOperate;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
- * 内部转内部方法
|
|
|
|
|
|
|
+ * 判断各余额是否足够
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param outAccountCard
|
|
|
|
|
+ * @param entAccountCard
|
|
|
|
|
+ * @param ApplyAmount
|
|
|
|
|
+ * @return
|
|
|
*/
|
|
*/
|
|
|
- public static List<InvAccountCard> insideTransfer(InvAccountCard outAccountCard, InvAccountCard enterAccountCard, InvAccountExcel invAccountExcel) {
|
|
|
|
|
- List<InvAccountCard> list = new ArrayList<>();
|
|
|
|
|
- if (outAccountCard != null && enterAccountCard != null && invAccountExcel != null) {
|
|
|
|
|
|
|
+ public static Boolean lenss(InvAccountCard outAccountCard, InvAccountCard entAccountCard, InvAccount outAccount, InvAccount entAccount, String ApplyAmount) {
|
|
|
|
|
+
|
|
|
|
|
+ if (entAccountCard == null || entAccount == null) {
|
|
|
|
|
+ throw new SystemException("收入卡或收入账户为空");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (outAccountCard == null || outAccount == null) {
|
|
|
|
|
+ throw new SystemException("转出卡或转出账户为空");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (ApplyAmount == null) {
|
|
|
|
|
+ throw new SystemException("金额为空");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (outAccount.getOuterFlag().equals("0")) {
|
|
|
//公户单日转账剩余
|
|
//公户单日转账剩余
|
|
|
BigDecimal pubDayLinesExcess = new BigDecimal(outAccountCard.getPubDayLinesExcess());
|
|
BigDecimal pubDayLinesExcess = new BigDecimal(outAccountCard.getPubDayLinesExcess());
|
|
|
//私户单日转账剩余
|
|
//私户单日转账剩余
|
|
@@ -88,124 +158,199 @@ public class TransferUtils {
|
|
|
//单日转账笔数剩余
|
|
//单日转账笔数剩余
|
|
|
long dayStrokeNumExcess = Long.parseLong(outAccountCard.getDayStrokeNumExcess());
|
|
long dayStrokeNumExcess = Long.parseLong(outAccountCard.getDayStrokeNumExcess());
|
|
|
//申请金额
|
|
//申请金额
|
|
|
- BigDecimal insAccountExcelApplyAmount = new BigDecimal(invAccountExcel.getApplyAmount());
|
|
|
|
|
-
|
|
|
|
|
- //转出账户现支出金额
|
|
|
|
|
- BigDecimal outAccountSpend = new BigDecimal(outAccountCard.getSpend());
|
|
|
|
|
|
|
+ BigDecimal invApplyAmount = new BigDecimal(ApplyAmount);
|
|
|
|
|
|
|
|
|
|
+ //转出账户余额
|
|
|
BigDecimal outAccountBalance = new BigDecimal(outAccountCard.getBalance());
|
|
BigDecimal outAccountBalance = new BigDecimal(outAccountCard.getBalance());
|
|
|
|
|
|
|
|
- if (outAccountBalance.compareTo(insAccountExcelApplyAmount) < 0) {
|
|
|
|
|
- //转出账户余额不足
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if (outAccountBalance.compareTo(invApplyAmount) < 0) {
|
|
|
throw new SystemException("转出账户余额不足");
|
|
throw new SystemException("转出账户余额不足");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ if (entAccountCard.getAccountQuality().equals("0")) {
|
|
|
|
|
+ //收入账户为公户
|
|
|
|
|
+ if (dayStrokeNumExcess <= 0) {
|
|
|
|
|
+ throw new SystemException("公户单日转账笔数不足");
|
|
|
|
|
+ }
|
|
|
|
|
+ //判断单日转账金额是否超过
|
|
|
|
|
+ if (pubDayLinesExcess.compareTo(BigDecimal.valueOf(0)) != 0 && pubDayLinesExcess.compareTo(invApplyAmount) < 0) {
|
|
|
|
|
+ throw new SystemException("公户单日转账金额不足");
|
|
|
|
|
+ }
|
|
|
|
|
+ //判断年额度是否超过
|
|
|
|
|
+ if (pubYearExcess.compareTo(BigDecimal.valueOf(0)) != 0 && pubYearExcess.compareTo(invApplyAmount) < 0) {
|
|
|
|
|
+ throw new SystemException("公户年额度不足");
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- if (enterAccountCard.getAccountQuality().equals("0")) {
|
|
|
|
|
- //公户操作
|
|
|
|
|
- if (pubSingleLines.compareTo(insAccountExcelApplyAmount) > 0){
|
|
|
|
|
- //收入方增加余额
|
|
|
|
|
-
|
|
|
|
|
- list.add(pubAccountUtils(dayStrokeNumExcess,pubDayLinesExcess,pubYearExcess,insAccountExcelApplyAmount,outAccountCard,outAccountSpend));
|
|
|
|
|
- list.add(enterAccountUtils( enterAccountCard, insAccountExcelApplyAmount));
|
|
|
|
|
- return list;
|
|
|
|
|
|
|
+ if (pubSingleLines.compareTo(invApplyAmount) < 0) {
|
|
|
|
|
+ throw new SystemException("公户转账金额超出单笔限额");
|
|
|
}
|
|
}
|
|
|
- throw new SystemException("公户转账金额超出单笔限额");
|
|
|
|
|
} else {
|
|
} else {
|
|
|
- if(priSingleLines.compareTo(insAccountExcelApplyAmount) > 0){
|
|
|
|
|
- //私户操作
|
|
|
|
|
-
|
|
|
|
|
- list.add(priAccountUtils(dayStrokeNumExcess,priDayLinesExcess,insAccountExcelApplyAmount, priYearExcess,outAccountSpend,outAccountCard));
|
|
|
|
|
- list.add(enterAccountUtils( enterAccountCard, insAccountExcelApplyAmount));
|
|
|
|
|
-
|
|
|
|
|
- return list;
|
|
|
|
|
|
|
+ //收入账户为私户
|
|
|
|
|
+ if (dayStrokeNumExcess <= 0) {
|
|
|
|
|
+ throw new SystemException("私户单日转账笔数不足");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (priDayLinesExcess.compareTo(BigDecimal.valueOf(0)) != 0 && priDayLinesExcess.compareTo(invApplyAmount) < 0) {
|
|
|
|
|
+ throw new SystemException("私户单日转账金额不足");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (priYearExcess.compareTo(BigDecimal.valueOf(0)) != 0 && priYearExcess.compareTo(invApplyAmount) < 0) {
|
|
|
|
|
+ throw new SystemException("私户年额度不足");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (priSingleLines.compareTo(invApplyAmount) > -1) {
|
|
|
|
|
+ throw new SystemException("私户转账金额超出单笔限额");
|
|
|
}
|
|
}
|
|
|
- throw new SystemException("私户转账金额超出单笔限额");
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- return list;
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 外部转内部方法
|
|
|
|
|
|
|
+ * 判断归属是否分配完毕
|
|
|
|
|
+ * @param outProfit
|
|
|
|
|
+ * @param entProfit
|
|
|
|
|
+ * @return
|
|
|
*/
|
|
*/
|
|
|
- public static InvAccountCard outsideTransfer(InvAccountCard enterAccountCard, InvAccountOperate invAccountOperate) {
|
|
|
|
|
- if (enterAccountCard == null || invAccountOperate == null) {
|
|
|
|
|
- throw new SystemException("收入账户为空");
|
|
|
|
|
|
|
+ public static Boolean isProfitFull (JSONObject outProfit,JSONObject entProfit) {
|
|
|
|
|
+ BigDecimal outAmount = new BigDecimal(0);
|
|
|
|
|
+ BigDecimal entAmount = new BigDecimal(0);
|
|
|
|
|
+ for (Map.Entry<String, Object> entry : outProfit.entrySet()) {
|
|
|
|
|
+ outAmount = outAmount.add(new BigDecimal(entry.getValue().toString()));
|
|
|
|
|
+ }
|
|
|
|
|
+ for (Map.Entry<String, Object> entry : entProfit.entrySet()) {
|
|
|
|
|
+ entAmount = entAmount.add(new BigDecimal(entry.getValue().toString()));
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!String.valueOf(outAmount).equals("100")) {
|
|
|
|
|
+ throw new SystemException("支出金额未完全分配");
|
|
|
}
|
|
}
|
|
|
|
|
+ if (!String.valueOf(entAmount).equals("100")) {
|
|
|
|
|
+ throw new SystemException("收入金额未完全分配");
|
|
|
|
|
+ }
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- BigDecimal applyAmount = new BigDecimal(invAccountOperate.getApplyAmount());
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 转给私户扣除余额方法
|
|
|
|
|
+ */
|
|
|
|
|
+ private static InvAccountCard priAccountUtils(InvAccountCard outAccountCard, String invAccountExcelApplyAmount) {
|
|
|
|
|
+ String spend = outAccountCard.getSpend();
|
|
|
|
|
+ String dayStrokeNumExcess = outAccountCard.getDayStrokeNumExcess();
|
|
|
|
|
+ String priDayLinesExcess = outAccountCard.getPriDayLinesExcess();
|
|
|
|
|
+ String priYearExcess = outAccountCard.getPriYearExcess();
|
|
|
|
|
+
|
|
|
|
|
+ outAccountCard.setSpend(new BigDecimal(spend).add(new BigDecimal(invAccountExcelApplyAmount)).toString());
|
|
|
|
|
+ outAccountCard.setBalance(new BigDecimal(outAccountCard.getBalance()).subtract(new BigDecimal(invAccountExcelApplyAmount)).toString());
|
|
|
|
|
+ outAccountCard.setDayStrokeNumExcess(String.valueOf(Integer.parseInt(dayStrokeNumExcess) - 1));
|
|
|
|
|
+ outAccountCard.setPriDayLinesExcess(new BigDecimal(priDayLinesExcess).subtract(new BigDecimal(invAccountExcelApplyAmount)).toString());
|
|
|
|
|
+ outAccountCard.setPriYearExcess(new BigDecimal(priYearExcess).subtract(new BigDecimal(invAccountExcelApplyAmount)).toString());
|
|
|
|
|
+ return outAccountCard;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- return enterAccountUtils(enterAccountCard, applyAmount);
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 转给公户扣除余额方法
|
|
|
|
|
+ */
|
|
|
|
|
+ private static InvAccountCard pubAccountUtils(InvAccountCard outAccountCard, String invAccountExcelApplyAmount) {
|
|
|
|
|
+ String spend = outAccountCard.getSpend();
|
|
|
|
|
+ String dayStrokeNumExcess = outAccountCard.getDayStrokeNumExcess();
|
|
|
|
|
+ String pubDayLinesExcess = outAccountCard.getPubDayLinesExcess();
|
|
|
|
|
+ String pubYearExcess = outAccountCard.getPubYearExcess();
|
|
|
|
|
+ BigDecimal bigDecimal = new BigDecimal(invAccountExcelApplyAmount);
|
|
|
|
|
+
|
|
|
|
|
+ //支出方减少余额
|
|
|
|
|
+ outAccountCard.setSpend(new BigDecimal(spend).add(bigDecimal).toString());
|
|
|
|
|
+ outAccountCard.setBalance(new BigDecimal(outAccountCard.getBalance()).subtract(bigDecimal).toString());
|
|
|
|
|
+ //公户单日转账笔数减少
|
|
|
|
|
+ outAccountCard.setDayStrokeNumExcess(String.valueOf(Integer.parseInt(dayStrokeNumExcess) - 1));
|
|
|
|
|
+ //公户单日转账剩余减少
|
|
|
|
|
+ outAccountCard.setPubDayLinesExcess(new BigDecimal(pubDayLinesExcess).subtract(bigDecimal).toString());
|
|
|
|
|
+ //公户年额度减少
|
|
|
|
|
+ outAccountCard.setPubYearExcess(new BigDecimal(pubYearExcess).subtract(bigDecimal).toString());
|
|
|
|
|
+ return outAccountCard;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 撤销发票方法
|
|
|
|
|
|
|
+ * 内部转内部方法
|
|
|
*/
|
|
*/
|
|
|
- public static List<InvAccountCard> quashOutsideTransfer(InvAccountCard outAccountCard,InvAccountCard enterAccountCard, InvAccountIncoice invAccountIncoice) {
|
|
|
|
|
- if (enterAccountCard == null || invAccountIncoice == null) {
|
|
|
|
|
- throw new SystemException("账户为空");
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ public static List<InvAccountCard> insideTransfer(InvAccountCard outAccountCard, InvAccount outAccount, InvAccountCard enterAccountCard, InvAccount enterAccount, String applyAmount) {
|
|
|
|
|
|
|
|
|
|
|
|
|
- BigDecimal applyAmount = new BigDecimal(invAccountIncoice.getInvoiceMoney());
|
|
|
|
|
List<InvAccountCard> list = new ArrayList<>();
|
|
List<InvAccountCard> list = new ArrayList<>();
|
|
|
- list.add(enterAccountBreakUtils(enterAccountCard, applyAmount));
|
|
|
|
|
- list.add(outAccountBreakUtils(outAccountCard, applyAmount));
|
|
|
|
|
- return list;
|
|
|
|
|
|
|
+
|
|
|
|
|
+ TransferUtils.lenss(outAccountCard, enterAccountCard, outAccount, enterAccount, applyAmount);
|
|
|
|
|
+
|
|
|
|
|
+ if (enterAccountCard.getAccountQuality().equals("0")) {
|
|
|
|
|
+ list.add(pubAccountUtils(outAccountCard, applyAmount));
|
|
|
|
|
+ list.add(enterAccountUtils(enterAccountCard, applyAmount));
|
|
|
|
|
+ return list;
|
|
|
|
|
+
|
|
|
|
|
+ } else {
|
|
|
|
|
+ //私户操作
|
|
|
|
|
+ list.add(priAccountUtils(outAccountCard, applyAmount));
|
|
|
|
|
+ list.add(enterAccountUtils(enterAccountCard, applyAmount));
|
|
|
|
|
+ return list;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 内部转外部方法
|
|
* 内部转外部方法
|
|
|
*/
|
|
*/
|
|
|
- public static List<InvAccountCard> enterDeTransfer(InvAccountCard outAccountCard, InvAccountCard enterAccountCard, InvAccountExcel invAccountExcel) {
|
|
|
|
|
|
|
+ public static List<InvAccountCard> enterDeTransfer(InvAccountCard outAccountCard, InvAccount outAccount, InvAccountCard enterAccountCard, InvAccount enterAccount, String applyAmount) {
|
|
|
List<InvAccountCard> list = new ArrayList<>();
|
|
List<InvAccountCard> list = new ArrayList<>();
|
|
|
- if (outAccountCard != null && enterAccountCard != null && invAccountExcel != null) {
|
|
|
|
|
- //公户单日转账剩余
|
|
|
|
|
- BigDecimal pubDayLinesExcess = new BigDecimal(outAccountCard.getPubDayLinesExcess());
|
|
|
|
|
- //私户单日转账剩余
|
|
|
|
|
- BigDecimal priDayLinesExcess = new BigDecimal(outAccountCard.getPriDayLinesExcess());
|
|
|
|
|
- //公户年额度剩余
|
|
|
|
|
- BigDecimal pubYearExcess = new BigDecimal(outAccountCard.getPubYearExcess());
|
|
|
|
|
- //私户年额度剩余
|
|
|
|
|
- BigDecimal priYearExcess = new BigDecimal(outAccountCard.getPriYearExcess());
|
|
|
|
|
- //单日转账笔数剩余
|
|
|
|
|
- long dayStrokeNumExcess = Long.parseLong(outAccountCard.getDayStrokeNumExcess());
|
|
|
|
|
- //申请金额
|
|
|
|
|
- BigDecimal insAccountExcelApplyAmount = new BigDecimal(invAccountExcel.getApplyAmount());
|
|
|
|
|
- //转出账户现支出金额
|
|
|
|
|
- BigDecimal outAccountSpend = new BigDecimal(outAccountCard.getSpend());
|
|
|
|
|
-
|
|
|
|
|
- if (invAccountExcel.getOutAccountQuality().equals("0")) {
|
|
|
|
|
- //公户操作
|
|
|
|
|
- list.add(pubAccountUtils(dayStrokeNumExcess,pubDayLinesExcess,pubYearExcess,insAccountExcelApplyAmount,outAccountCard,outAccountSpend));
|
|
|
|
|
- return list;
|
|
|
|
|
-
|
|
|
|
|
- } else {
|
|
|
|
|
- //私户操作
|
|
|
|
|
- list.add(priAccountUtils(dayStrokeNumExcess,priDayLinesExcess,insAccountExcelApplyAmount, priYearExcess,outAccountSpend,outAccountCard));
|
|
|
|
|
- return list;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ TransferUtils.lenss(outAccountCard, enterAccountCard, outAccount, enterAccount, applyAmount);
|
|
|
|
|
+
|
|
|
|
|
+ if (enterAccountCard.getAccountQuality().equals("0")) {
|
|
|
|
|
+ //公户操作
|
|
|
|
|
+ list.add(pubAccountUtils(outAccountCard, applyAmount));
|
|
|
|
|
+ } else {
|
|
|
|
|
+ //私户操作
|
|
|
|
|
+ list.add(priAccountUtils(outAccountCard, applyAmount));
|
|
|
}
|
|
}
|
|
|
return list;
|
|
return list;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 外部转内部方法
|
|
|
|
|
+ */
|
|
|
|
|
+ public static InvAccountCard outsideTransfer(InvAccountCard outAccountCard, InvAccount outAccount, InvAccountCard enterAccountCard, InvAccount enterAccount, String applyAmount) {
|
|
|
|
|
+ TransferUtils.lenss(outAccountCard, enterAccountCard, outAccount, enterAccount, applyAmount);
|
|
|
|
|
+
|
|
|
|
|
+ return enterAccountUtils(enterAccountCard, applyAmount);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 收入方增加利润方法
|
|
* 收入方增加利润方法
|
|
|
*
|
|
*
|
|
|
* @return
|
|
* @return
|
|
|
*/
|
|
*/
|
|
|
- private static InvAccountCard enterAccountUtils(InvAccountCard enterAccountCard, BigDecimal invAccountExcelApplyAmount) {
|
|
|
|
|
- if(enterAccountCard.getBalance()!=null && !enterAccountCard.getBalance().isEmpty()){
|
|
|
|
|
- enterAccountCard.setBalance(new BigDecimal(enterAccountCard.getBalance()).add(invAccountExcelApplyAmount).toString());
|
|
|
|
|
|
|
+ private static InvAccountCard enterAccountUtils(InvAccountCard enterAccountCard, String invAccountExcelApplyAmount) {
|
|
|
|
|
+ if (enterAccountCard.getBalance() != null && !enterAccountCard.getBalance().isEmpty()) {
|
|
|
|
|
+ enterAccountCard.setBalance(new BigDecimal(enterAccountCard.getBalance()).add(new BigDecimal(invAccountExcelApplyAmount)).toString());
|
|
|
}
|
|
}
|
|
|
return enterAccountCard;
|
|
return enterAccountCard;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 撤销发票方法
|
|
|
|
|
+ */
|
|
|
|
|
+ public static List<InvAccountCard> quashOutsideTransfer(InvAccountCard outAccountCard, InvAccountCard enterAccountCard, InvAccountIncoice invAccountIncoice) {
|
|
|
|
|
+ if (enterAccountCard == null || invAccountIncoice == null) {
|
|
|
|
|
+ throw new SystemException("账户为空");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ BigDecimal applyAmount = new BigDecimal(invAccountIncoice.getInvoiceMoney());
|
|
|
|
|
+ List<InvAccountCard> list = new ArrayList<>();
|
|
|
|
|
+ list.add(enterAccountBreakUtils(enterAccountCard, applyAmount));
|
|
|
|
|
+ list.add(outAccountBreakUtils(outAccountCard, applyAmount));
|
|
|
|
|
+ return list;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 收入方回滚利润方法
|
|
* 收入方回滚利润方法
|
|
@@ -223,61 +368,10 @@ public class TransferUtils {
|
|
|
* @return
|
|
* @return
|
|
|
*/
|
|
*/
|
|
|
private static InvAccountCard outAccountBreakUtils(InvAccountCard enterAccountCard, BigDecimal invAccountExcelApplyAmount) {
|
|
private static InvAccountCard outAccountBreakUtils(InvAccountCard enterAccountCard, BigDecimal invAccountExcelApplyAmount) {
|
|
|
- if (enterAccountCard.getBalance()!=null && !enterAccountCard.getBalance().isEmpty()){
|
|
|
|
|
|
|
+ if (enterAccountCard.getBalance() != null && !enterAccountCard.getBalance().isEmpty()) {
|
|
|
enterAccountCard.setBalance(new BigDecimal(enterAccountCard.getBalance()).add(invAccountExcelApplyAmount).toString());
|
|
enterAccountCard.setBalance(new BigDecimal(enterAccountCard.getBalance()).add(invAccountExcelApplyAmount).toString());
|
|
|
}
|
|
}
|
|
|
return enterAccountCard;
|
|
return enterAccountCard;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * 公户扣除余额方法
|
|
|
|
|
- */
|
|
|
|
|
- private static InvAccountCard pubAccountUtils(long dayStrokeNumExcess, BigDecimal pubDayLinesExcess, BigDecimal pubYearExcess, BigDecimal invAccountExcelApplyAmount, InvAccountCard outAccountCard,BigDecimal outAccountSpend) {
|
|
|
|
|
- //判断单日转账笔数是否超过
|
|
|
|
|
- if (dayStrokeNumExcess <= 0) {
|
|
|
|
|
- throw new SystemException("公户单日转账笔数不足");
|
|
|
|
|
- }
|
|
|
|
|
- //判断单日转账金额是否超过
|
|
|
|
|
- if (pubDayLinesExcess.compareTo(BigDecimal.valueOf(0)) != 0 && pubDayLinesExcess.compareTo(invAccountExcelApplyAmount) < 0) {
|
|
|
|
|
- throw new SystemException("公户单日转账金额不足");
|
|
|
|
|
- }
|
|
|
|
|
- //判断年额度是否超过
|
|
|
|
|
- if (pubYearExcess.compareTo(BigDecimal.valueOf(0)) != 0 && pubYearExcess.compareTo(invAccountExcelApplyAmount) < 0) {
|
|
|
|
|
- throw new SystemException("公户年额度不足");
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- //支出方减少余额
|
|
|
|
|
- outAccountCard.setSpend(outAccountSpend.add(invAccountExcelApplyAmount).toString());
|
|
|
|
|
- outAccountCard.setBalance(new BigDecimal(outAccountCard.getBalance()).subtract(invAccountExcelApplyAmount).toString());
|
|
|
|
|
- //公户单日转账笔数减少
|
|
|
|
|
- outAccountCard.setDayStrokeNumExcess(String.valueOf(dayStrokeNumExcess - 1));
|
|
|
|
|
- //公户单日转账剩余减少
|
|
|
|
|
- outAccountCard.setPubDayLinesExcess(pubDayLinesExcess.subtract(invAccountExcelApplyAmount).toString());
|
|
|
|
|
- //公户年额度减少
|
|
|
|
|
- outAccountCard.setPubYearExcess(pubYearExcess.subtract(invAccountExcelApplyAmount).toString());
|
|
|
|
|
- return outAccountCard;
|
|
|
|
|
- }
|
|
|
|
|
- /**
|
|
|
|
|
- * 私户扣除余额方法
|
|
|
|
|
- */
|
|
|
|
|
- private static InvAccountCard priAccountUtils(long dayStrokeNumExcess, BigDecimal priDayLinesExcess, BigDecimal invAccountExcelApplyAmount, BigDecimal priYearExcess, BigDecimal outAccountSpend,InvAccountCard outAccountCard) {
|
|
|
|
|
- if (dayStrokeNumExcess <= 0) {
|
|
|
|
|
- throw new SystemException("私户单日转账笔数不足");
|
|
|
|
|
- }
|
|
|
|
|
- if (priDayLinesExcess.compareTo(BigDecimal.valueOf(0)) != 0 && priDayLinesExcess.compareTo(invAccountExcelApplyAmount) < 0) {
|
|
|
|
|
- throw new SystemException("私户单日转账金额不足");
|
|
|
|
|
- }
|
|
|
|
|
- if (priYearExcess.compareTo(BigDecimal.valueOf(0)) != 0 && priYearExcess.compareTo(invAccountExcelApplyAmount) < 0) {
|
|
|
|
|
- throw new SystemException("私户年额度不足");
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- outAccountCard.setSpend(outAccountSpend.add(invAccountExcelApplyAmount).toString());
|
|
|
|
|
- outAccountCard.setBalance(new BigDecimal(outAccountCard.getBalance()).subtract(invAccountExcelApplyAmount).toString());
|
|
|
|
|
- outAccountCard.setDayStrokeNumExcess(String.valueOf(dayStrokeNumExcess - 1));
|
|
|
|
|
- outAccountCard.setPriDayLinesExcess(priDayLinesExcess.subtract(invAccountExcelApplyAmount).toString());
|
|
|
|
|
- outAccountCard.setPriYearExcess(priYearExcess.subtract(invAccountExcelApplyAmount).toString());
|
|
|
|
|
- return outAccountCard;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
}
|
|
}
|