|
|
@@ -20,13 +20,14 @@ import java.util.Map;
|
|
|
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){
|
|
|
+ public static List<InvAccountOp> invAccountEntOpList(JSONObject entProfit, InvAccount entAccount, InvAccountCard entAccountCard, String applyAmount, String operateId) {
|
|
|
List<InvAccountOp> list = new ArrayList<>();
|
|
|
if (entProfit != null) {
|
|
|
for (Map.Entry<String, Object> entry : entProfit.entrySet()) {
|
|
|
@@ -36,6 +37,7 @@ public class TransferUtils {
|
|
|
invAccountOp.setAccountName(entAccount.getAccountName());
|
|
|
invAccountOp.setCardNum(entAccountCard.getBankCardNum());
|
|
|
invAccountOp.setCardName(entAccountCard.getBankName());
|
|
|
+ invAccountOp.setAccountOperateId(operateId);
|
|
|
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);
|
|
|
@@ -48,13 +50,14 @@ public class TransferUtils {
|
|
|
|
|
|
/**
|
|
|
* 插入支出归属
|
|
|
+ *
|
|
|
* @param outProfit
|
|
|
* @param outAccount
|
|
|
* @param outAccountCard
|
|
|
* @param applyAmount
|
|
|
* @return
|
|
|
*/
|
|
|
- public static List<InvAccountOp> invAccountOutOpList(JSONObject outProfit,InvAccount outAccount, InvAccountCard outAccountCard, String applyAmount){
|
|
|
+ public static List<InvAccountOp> invAccountOutOpList(JSONObject outProfit, InvAccount outAccount, InvAccountCard outAccountCard, String applyAmount, String operateId) {
|
|
|
List<InvAccountOp> list = new ArrayList<>();
|
|
|
for (Map.Entry<String, Object> entry : outProfit.entrySet()) {
|
|
|
if (Integer.parseInt(entry.getValue().toString()) != 0) {
|
|
|
@@ -64,6 +67,7 @@ public class TransferUtils {
|
|
|
invAccountOp.setCardNum(outAccountCard.getBankCardNum());
|
|
|
invAccountOp.setCardName(outAccountCard.getBankName());
|
|
|
invAccountOp.setProfit(entry.getKey());
|
|
|
+ invAccountOp.setAccountOperateId(operateId);
|
|
|
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);
|
|
|
}
|
|
|
@@ -105,6 +109,7 @@ public class TransferUtils {
|
|
|
operate.setEnterCardNum(insAccountExcel.getEnterCardNum());
|
|
|
return operate;
|
|
|
}
|
|
|
+
|
|
|
private static InvAccountOperate operate(InvAccountExcel invAccountExcel, InvAccountOperate invAccountOperate) {
|
|
|
invAccountOperate.setApplicant(invAccountExcel.getApplicant());
|
|
|
invAccountOperate.setApplySector(invAccountExcel.getApplySector());
|
|
|
@@ -121,7 +126,6 @@ public class TransferUtils {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 判断各余额是否足够
|
|
|
*
|
|
|
@@ -207,11 +211,12 @@ public class TransferUtils {
|
|
|
|
|
|
/**
|
|
|
* 判断归属是否分配完毕
|
|
|
+ *
|
|
|
* @param outProfit
|
|
|
* @param entProfit
|
|
|
* @return
|
|
|
*/
|
|
|
- public static Boolean isProfitFull (JSONObject outProfit,JSONObject entProfit) {
|
|
|
+ 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()) {
|
|
|
@@ -325,7 +330,7 @@ public class TransferUtils {
|
|
|
*
|
|
|
* @return
|
|
|
*/
|
|
|
- private static InvAccountCard enterAccountUtils(InvAccountCard enterAccountCard, String invAccountExcelApplyAmount) {
|
|
|
+ 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());
|
|
|
}
|
|
|
@@ -336,29 +341,32 @@ public class TransferUtils {
|
|
|
/**
|
|
|
* 撤销发票方法
|
|
|
*/
|
|
|
- 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());
|
|
|
+ public static List<InvAccountCard> quashOutsideTransfer(InvAccountCard outAccountCard, InvAccountCard enterAccountCard, BigDecimal applyAmount) {
|
|
|
List<InvAccountCard> list = new ArrayList<>();
|
|
|
- list.add(enterAccountBreakUtils(enterAccountCard, applyAmount));
|
|
|
- list.add(outAccountBreakUtils(outAccountCard, applyAmount));
|
|
|
+ list.add(enterAccountBreakUtils(enterAccountCard, outAccountCard, applyAmount));
|
|
|
+ InvAccountCard invAccountCard = outAccountBreakUtils(outAccountCard, enterAccountCard, applyAmount);
|
|
|
+ if (invAccountCard != null) {
|
|
|
+ list.add(invAccountCard);
|
|
|
+ }
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
/**
|
|
|
* 收入方回滚利润方法
|
|
|
*
|
|
|
* @return
|
|
|
*/
|
|
|
- private static InvAccountCard enterAccountBreakUtils(InvAccountCard enterAccountCard, BigDecimal invAccountExcelApplyAmount) {
|
|
|
- enterAccountCard.setBalance(new BigDecimal(enterAccountCard.getBalance()).subtract(invAccountExcelApplyAmount).toString());
|
|
|
+ private static InvAccountCard enterAccountBreakUtils(InvAccountCard enterAccountCard, InvAccountCard outAccountCard, BigDecimal invAccountExcelApplyAmount) {
|
|
|
+
|
|
|
+ if (enterAccountCard != null) {
|
|
|
+ if (outAccountCard != null){
|
|
|
+ if (enterAccountCard.getBalance().equals("0")) {
|
|
|
+ throw new SystemException("账户余额不足");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ enterAccountCard.setBalance(new BigDecimal(enterAccountCard.getBalance()).subtract(invAccountExcelApplyAmount).toString());
|
|
|
+ }
|
|
|
return enterAccountCard;
|
|
|
}
|
|
|
|
|
|
@@ -367,11 +375,33 @@ public class TransferUtils {
|
|
|
*
|
|
|
* @return
|
|
|
*/
|
|
|
- private static InvAccountCard outAccountBreakUtils(InvAccountCard enterAccountCard, BigDecimal invAccountExcelApplyAmount) {
|
|
|
- if (enterAccountCard.getBalance() != null && !enterAccountCard.getBalance().isEmpty()) {
|
|
|
- enterAccountCard.setBalance(new BigDecimal(enterAccountCard.getBalance()).add(invAccountExcelApplyAmount).toString());
|
|
|
+
|
|
|
+ private static InvAccountCard outAccountBreakUtils(InvAccountCard outAccountCard, InvAccountCard enterAccountCard, BigDecimal invAccountExcelApplyAmount) {
|
|
|
+ if (outAccountCard != null) {
|
|
|
+ if (outAccountCard.getBalance() != null && !outAccountCard.getBalance().isEmpty()) {
|
|
|
+ outAccountCard.setBalance(new BigDecimal(outAccountCard.getBalance()).add(invAccountExcelApplyAmount).toString());
|
|
|
+ outAccountCard.setSpend(new BigDecimal(outAccountCard.getSpend()).subtract(invAccountExcelApplyAmount).toString());
|
|
|
+ if (outAccountCard.getDayStrokeNumExcess() != null && !outAccountCard.getDayStrokeNumExcess().isEmpty()) {
|
|
|
+ outAccountCard.setDayStrokeNumExcess(new BigDecimal(outAccountCard.getDayStrokeNumExcess()).add(new BigDecimal("1")).toString());
|
|
|
+ }
|
|
|
+ if (enterAccountCard.getAccountQuality().equals("0")) {
|
|
|
+ if (outAccountCard.getPubDayLinesExcess() != null && !outAccountCard.getPubDayLinesExcess().isEmpty()) {
|
|
|
+ outAccountCard.setPubDayLinesExcess(new BigDecimal(outAccountCard.getPubDayLinesExcess()).add(invAccountExcelApplyAmount).toString());
|
|
|
+ }
|
|
|
+ if (outAccountCard.getPubYearExcess() != null && !outAccountCard.getPubYearExcess().isEmpty()) {
|
|
|
+ outAccountCard.setPubYearExcess(new BigDecimal(outAccountCard.getPubYearExcess()).add(invAccountExcelApplyAmount).toString());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (outAccountCard.getPriDayLinesExcess() != null && !outAccountCard.getPriDayLinesExcess().isEmpty()) {
|
|
|
+ outAccountCard.setPriDayLinesExcess(new BigDecimal(outAccountCard.getPriDayLinesExcess()).add(invAccountExcelApplyAmount).toString());
|
|
|
+ }
|
|
|
+ if (outAccountCard.getPriYearExcess() != null && !outAccountCard.getPriYearExcess().isEmpty()) {
|
|
|
+ outAccountCard.setPriYearExcess(new BigDecimal(outAccountCard.getPriYearExcess()).add(invAccountExcelApplyAmount).toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- return enterAccountCard;
|
|
|
+ return outAccountCard;
|
|
|
}
|
|
|
|
|
|
}
|