|
|
@@ -52,15 +52,16 @@ public class AmbInvestServiceImpl extends BaseMybatisDao<AmbInvestMapper> implem
|
|
|
myAmb= ambSystemMapper.selectByPrimaryKey(1l);
|
|
|
}else {
|
|
|
myAmb=ambSystemMapper.selectByPrimaryKey(in.getMyAmbId());
|
|
|
- ambInvest.setCountAmount(chekAmount(in, myAmb));
|
|
|
+ chekAmount(in, myAmb);
|
|
|
}
|
|
|
- AmbSystem other=ambSystemMapper.selectByPrimaryKey(in.getOtherAmbId());
|
|
|
ambInvest.setInitiateAmbId(myAmb.getId());
|
|
|
ambInvest.setAcceptAmbId(in.getOtherAmbId());
|
|
|
ambInvest.setAmount(in.getAmount());
|
|
|
ambInvest.setStatus(in.getStatus());
|
|
|
ambInvest.setOperator(TokenManager.getAdminId());
|
|
|
ambInvest.setComment(in.getComment());
|
|
|
+ AmbSystem other=ambSystemMapper.selectByPrimaryKey(in.getOtherAmbId());
|
|
|
+ //计算累计金额
|
|
|
sumCountAmount(other.getId(), ambInvest);
|
|
|
ambInvestMapper.insertSelective(ambInvest);
|
|
|
addAmbInvestLog(in, ambInvest);
|
|
|
@@ -73,7 +74,7 @@ public class AmbInvestServiceImpl extends BaseMybatisDao<AmbInvestMapper> implem
|
|
|
* @param in 当前数据
|
|
|
* @param myAmb 发起方
|
|
|
*/
|
|
|
- private BigDecimal chekAmount(InputAmbInvest in, AmbSystem myAmb) {
|
|
|
+ private void chekAmount(InputAmbInvest in, AmbSystem myAmb) {
|
|
|
BigDecimal count = new BigDecimal(0);
|
|
|
List<OutInvestList> outInvestLists = ambInvestMapper.selectAmbInvestDtailsList(in.getMyAmbId(), 0);
|
|
|
for (OutInvestList out : outInvestLists) {
|
|
|
@@ -87,17 +88,10 @@ public class AmbInvestServiceImpl extends BaseMybatisDao<AmbInvestMapper> implem
|
|
|
throw new BusinessException("发起投资金额不可大于剩余投资金额!(注意:包含审核中投资金额)");
|
|
|
}
|
|
|
}
|
|
|
- //计算累计金额
|
|
|
- count=new BigDecimal(0);
|
|
|
- for (OutInvestList out : outInvestLists) {
|
|
|
- if (out.getAcceptAmbId().equals(in.getOtherAmbId())&&
|
|
|
- out.getStatus()==2){
|
|
|
- count=count.add(out.getAmount());
|
|
|
- }
|
|
|
- }
|
|
|
- return count;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
private void sumCountAmount(Long id, AmbInvest ambInvest) {
|
|
|
Integer x=ambInvestMapper.selectCountAmountById(id);
|
|
|
if (x==null)x=0;
|
|
|
@@ -210,6 +204,7 @@ public class AmbInvestServiceImpl extends BaseMybatisDao<AmbInvestMapper> implem
|
|
|
newOther.setSurplus(other.getSurplus().add(ambInvest.getAmount()));
|
|
|
newOther.setTotalAmount(other.getTotalAmount().add(ambInvest.getAmount()));
|
|
|
ambSystemMapper.updateByPrimaryKeySelective(newOther);
|
|
|
+ //计算累计金额
|
|
|
sumCountAmount(newOther.getId(), newAmbInvest);
|
|
|
}
|
|
|
ambInvestMapper.updateByPrimaryKeySelective(newAmbInvest);
|
|
|
@@ -219,7 +214,6 @@ public class AmbInvestServiceImpl extends BaseMybatisDao<AmbInvestMapper> implem
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
private void addAmbInvestLog(InputAmbInvest in, AmbInvest ambInvest) {
|
|
|
AmbInvestLog log = new AmbInvestLog();
|
|
|
log.setAmbInvestId(ambInvest.getId());
|