|
|
@@ -1,6 +1,7 @@
|
|
|
package com.ydtech.modules.inv.service.impl;
|
|
|
|
|
|
|
|
|
+import com.alibaba.excel.EasyExcel;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
@@ -18,7 +19,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.io.File;
|
|
|
+import java.io.*;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
@@ -115,26 +117,25 @@ public class InvAccountExcelServiceImpl extends ServiceImpl<InvAccountExcelMappe
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public HttpResult updateTransferFlag(String excelAccountOperateId) {
|
|
|
+ public HttpResult updateTransferFlag(String excelAccountOperateId, String payOutAmount) {
|
|
|
InvAccountExcel invAccountExcel = insAccountExcelMapper.selectById(excelAccountOperateId);
|
|
|
if (invAccountExcel == null) {
|
|
|
- throw new RuntimeException("该记录不存在");
|
|
|
+ HttpResult.error("该记录不存在");
|
|
|
+ }
|
|
|
+ if ((payOutAmount + invAccountExcel.getPayoutAmount()).compareTo(invAccountExcel.getApplyAmount()) > 0) {
|
|
|
+ HttpResult.error("已转金额不能大于申请金额");
|
|
|
}
|
|
|
|
|
|
InvAccountCard outAccountCard = invAccountCardService.getById(invAccountExcel.getOutCardNum());
|
|
|
InvAccountCard enterAccountCard = invAccountCardService.getById(invAccountExcel.getEnterCardNum());
|
|
|
InvAccount outAccount = insAccountService.getById(outAccountCard.getAccountId());
|
|
|
InvAccount enterAccount = insAccountService.getById(enterAccountCard.getAccountId());
|
|
|
- //操作金额
|
|
|
- String applyAmount = invAccountExcel.getApplyAmount();
|
|
|
|
|
|
- //修改转账状态
|
|
|
- invAccountExcel.setTransferFlag("0");
|
|
|
|
|
|
//判断是转账给内部还是外部
|
|
|
if (invAccountExcel.getOutFlag().equals("0")) {
|
|
|
//如果转账失败就返回错误
|
|
|
- List<InvAccountCard> insAccountCards = insideTransfer(outAccountCard, outAccount, enterAccountCard, enterAccount, applyAmount);
|
|
|
+ List<InvAccountCard> insAccountCards = insideTransfer(outAccountCard, outAccount, enterAccountCard, enterAccount, payOutAmount);
|
|
|
if (insAccountCards.isEmpty()) {
|
|
|
throw new RuntimeException("转账失败");
|
|
|
}
|
|
|
@@ -173,9 +174,17 @@ public class InvAccountExcelServiceImpl extends ServiceImpl<InvAccountExcelMappe
|
|
|
outJsonUtil(outProfit, outAccount, outAccountCard,invAccountOperate.getAccountOperateId());
|
|
|
entJsonUtil(entProfit, enterAccount, enterAccountCard, invAccountOperate1.getAccountOperateId());
|
|
|
|
|
|
+ if (invAccountExcel.getApplyAmount().equals(payOutAmount)) {
|
|
|
+ invAccountExcel.setTransferFlag("0");
|
|
|
+ invAccountExcel.setPayoutAmount(String.valueOf(Integer.parseInt(payOutAmount) + Integer.parseInt(invAccountExcel.getPayoutAmount())));
|
|
|
+ } else {
|
|
|
+ invAccountExcel.setTransferFlag("1");
|
|
|
+ invAccountExcel.setPayoutAmount(String.valueOf(Integer.parseInt(payOutAmount) + Integer.parseInt(invAccountExcel.getPayoutAmount())));
|
|
|
+ }
|
|
|
+
|
|
|
} else {
|
|
|
//内转外部转账
|
|
|
- List<InvAccountCard> invAccounts = enterDeTransfer(outAccountCard, outAccount, enterAccountCard, enterAccount, applyAmount);
|
|
|
+ List<InvAccountCard> invAccounts = enterDeTransfer(outAccountCard, outAccount, enterAccountCard, enterAccount, payOutAmount);
|
|
|
if (!invAccountCardService.saveBatch(invAccounts)) {
|
|
|
throw new RuntimeException("添加转账信息失败");
|
|
|
}
|
|
|
@@ -185,6 +194,14 @@ public class InvAccountExcelServiceImpl extends ServiceImpl<InvAccountExcelMappe
|
|
|
insAccountOperateService.save(invAccountOperate);
|
|
|
JSONObject outProfit = invAccountExcel.getOutProfit();
|
|
|
outJsonUtil(outProfit, outAccount, outAccountCard,invAccountOperate.getAccountOperateId());
|
|
|
+
|
|
|
+ if (invAccountExcel.getApplyAmount().equals(payOutAmount)) {
|
|
|
+ invAccountExcel.setTransferFlag("0");
|
|
|
+ invAccountExcel.setPayoutAmount(String.valueOf(Integer.parseInt(payOutAmount) + Integer.parseInt(invAccountExcel.getPayoutAmount())));
|
|
|
+ } else {
|
|
|
+ invAccountExcel.setTransferFlag("1");
|
|
|
+ invAccountExcel.setPayoutAmount(String.valueOf(Integer.parseInt(payOutAmount) + Integer.parseInt(invAccountExcel.getPayoutAmount())));
|
|
|
+ }
|
|
|
}
|
|
|
return HttpResult.ok("", insAccountExcelMapper.updateById(invAccountExcel));
|
|
|
}
|