|
|
@@ -42,6 +42,8 @@ public class FundtransferServiceImpl extends CommonBaseServiceImpl<FundtransferM
|
|
|
private PaybalanceMapper paybalanceMapper;
|
|
|
@Autowired
|
|
|
private MessageLogService messageLogService;
|
|
|
+ @Autowired
|
|
|
+ private BankinformationMapper bankinformationMapper;
|
|
|
|
|
|
@Override
|
|
|
public DocBaseDTO insert(Fundtran fundtran) {
|
|
|
@@ -96,7 +98,6 @@ public class FundtransferServiceImpl extends CommonBaseServiceImpl<FundtransferM
|
|
|
this.changBankUntil(fundtran);
|
|
|
DocBaseDTO docBaseDTO = this.insert(fundtran);
|
|
|
Long id = docBaseDTO.getId();
|
|
|
- String ft_code = docBaseDTO.getCode();
|
|
|
|
|
|
//取从表金额更新中间表、资金账号表
|
|
|
List<Fundtransferdetail> fundtransferdetailList = fundtran.getItems();
|
|
|
@@ -115,15 +116,28 @@ public class FundtransferServiceImpl extends CommonBaseServiceImpl<FundtransferM
|
|
|
//资金账号表
|
|
|
int bk_id = fundtransferdetail.getFtd_bankid();
|
|
|
int bk_inid = fundtransferdetail.getFtd_inbankid();
|
|
|
- Double bk_amount = paybalanceMapper.selectThisamount(bk_id) == null ? new Double(0) : paybalanceMapper.selectThisamount(bk_id);
|
|
|
- Double bk_inamount = paybalanceMapper.selectThisamount(bk_inid) == null ? new Double(0) : paybalanceMapper.selectThisamount(bk_inid);
|
|
|
|
|
|
- Double thisamount = bk_amount - fundtransferdetail.getFtd_nowbalance();
|
|
|
- if (thisamount < 0){
|
|
|
- throw new BizException(500, BizExceptionCode.BANK_AMOUNT_NOTENOUGH.getMessage());
|
|
|
- }
|
|
|
- paybalanceMapper.updateBankAmount(thisamount, bk_id);
|
|
|
- paybalanceMapper.updateBankAmount(bk_inamount + fundtransferdetail.getFtd_nowbalance(), bk_inid);
|
|
|
+ Double bk_amount = fundtransferdetail.getFtd_nowbalance();
|
|
|
+ //付款方
|
|
|
+ Bankinformation bankinformation = bankinformationMapper.selectByPrimaryKey(bk_id);
|
|
|
+ Double beginamount = bankinformation.getBk_beginamount();
|
|
|
+ Double spending = bankinformation.getBk_spending() == null ? new Double(0) : bankinformation.getBk_spending();
|
|
|
+ Double incomme = bankinformation.getBk_income() == null ? new Double(0) : bankinformation.getBk_income();
|
|
|
+ bankinformation.setBk_thisamount(beginamount + incomme - spending - bk_amount);
|
|
|
+ bankinformation.setBk_income(incomme);
|
|
|
+ bankinformation.setBk_spending(spending + bk_amount);
|
|
|
+
|
|
|
+ //收款方
|
|
|
+ Bankinformation inbankinformation = bankinformationMapper.selectByPrimaryKey(bk_inid);
|
|
|
+ Double inbeginamount = inbankinformation.getBk_beginamount();
|
|
|
+ Double inspending = inbankinformation.getBk_spending() == null ? new Double(0) : inbankinformation.getBk_spending();
|
|
|
+ Double inincomme = inbankinformation.getBk_income() == null ? new Double(0) : inbankinformation.getBk_income();
|
|
|
+ inbankinformation.setBk_thisamount(inbeginamount + inincomme - inspending + bk_amount);
|
|
|
+ inbankinformation.setBk_income(inincomme + bk_amount);
|
|
|
+ inbankinformation.setBk_spending(inspending);
|
|
|
+
|
|
|
+ bankinformationMapper.updateByPrimaryKeySelective(bankinformation);
|
|
|
+ bankinformationMapper.updateByPrimaryKeySelective(inbankinformation);
|
|
|
}
|
|
|
DocBaseDTO baseDTO = getBaseDTOById(id);
|
|
|
//日志记录
|
|
|
@@ -159,10 +173,28 @@ public class FundtransferServiceImpl extends CommonBaseServiceImpl<FundtransferM
|
|
|
//资金账号表
|
|
|
int bk_id = fundtransferdetail.getFtd_bankid();
|
|
|
int bk_inid = fundtransferdetail.getFtd_inbankid();
|
|
|
- Double bk_amount = paybalanceMapper.selectThisamount(bk_id) == null ? new Double(0) : paybalanceMapper.selectThisamount(bk_id);
|
|
|
- Double bk_inamount = paybalanceMapper.selectThisamount(bk_inid) == null ? new Double(0) : paybalanceMapper.selectThisamount(bk_inid);
|
|
|
- paybalanceMapper.updateBankAmount(bk_amount + fundtransferdetail.getFtd_nowbalance(), bk_id);
|
|
|
- paybalanceMapper.updateBankAmount(bk_inamount - fundtransferdetail.getFtd_nowbalance(), bk_inid);
|
|
|
+
|
|
|
+ Double bk_amount = fundtransferdetail.getFtd_nowbalance();
|
|
|
+ //付款方
|
|
|
+ Bankinformation bankinformation = bankinformationMapper.selectByPrimaryKey(bk_id);
|
|
|
+ Double beginamount = bankinformation.getBk_beginamount();
|
|
|
+ Double spending = bankinformation.getBk_spending() == null ? new Double(0) : bankinformation.getBk_spending();
|
|
|
+ Double incomme = bankinformation.getBk_income() == null ? new Double(0) : bankinformation.getBk_income();
|
|
|
+ bankinformation.setBk_thisamount(beginamount + incomme - spending + bk_amount);
|
|
|
+ bankinformation.setBk_income(incomme);
|
|
|
+ bankinformation.setBk_spending(spending - bk_amount);
|
|
|
+
|
|
|
+ //收款方
|
|
|
+ Bankinformation inbankinformation = bankinformationMapper.selectByPrimaryKey(bk_inid);
|
|
|
+ Double inbeginamount = inbankinformation.getBk_beginamount();
|
|
|
+ Double inspending = inbankinformation.getBk_spending() == null ? new Double(0) : inbankinformation.getBk_spending();
|
|
|
+ Double inincomme = inbankinformation.getBk_income() == null ? new Double(0) : inbankinformation.getBk_income();
|
|
|
+ inbankinformation.setBk_thisamount(inbeginamount + inincomme - inspending - bk_amount);
|
|
|
+ inbankinformation.setBk_income(inincomme - bk_amount);
|
|
|
+ inbankinformation.setBk_spending(inspending);
|
|
|
+
|
|
|
+ bankinformationMapper.updateByPrimaryKeySelective(bankinformation);
|
|
|
+ bankinformationMapper.updateByPrimaryKeySelective(inbankinformation);
|
|
|
}
|
|
|
|
|
|
DocBaseDTO baseDTO = getBaseDTOById(Long.valueOf(id));
|