|
|
@@ -50,6 +50,7 @@ public class AmbInvestServiceImpl extends BaseMybatisDao<AmbInvestMapper> implem
|
|
|
myAmb= ambSystemMapper.selectByPrimaryKey(1l);
|
|
|
}else {
|
|
|
myAmb=ambSystemMapper.selectByPrimaryKey(in.getMyAmbId());
|
|
|
+ chekAmount(in, myAmb);
|
|
|
}
|
|
|
AmbSystem other=ambSystemMapper.selectByPrimaryKey(in.getOtherAmbId());
|
|
|
AmbInvest ambInvest=new AmbInvest();
|
|
|
@@ -66,6 +67,20 @@ public class AmbInvestServiceImpl extends BaseMybatisDao<AmbInvestMapper> implem
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
|
+ private void chekAmount(InputAmbInvest in, AmbSystem myAmb) {
|
|
|
+ if (myAmb.getLvl()!=1){
|
|
|
+ List<OutInvestList> outInvestLists = ambInvestMapper.selectAmbInvestDtailsList(in.getMyAmbId(), 0);
|
|
|
+ BigDecimal count = new BigDecimal(0);
|
|
|
+ for (OutInvestList outInvestList : outInvestLists) {
|
|
|
+ count=count.add(outInvestList.getAmount());
|
|
|
+ }
|
|
|
+ count=count.add(in.getAmount());
|
|
|
+ if (count.compareTo(myAmb.getSurplus())>0){
|
|
|
+ throw new BusinessException("对外投资金额加上本次投资金额不可大于收到的投资金额!(注意已发起的投资金额)");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private void sumCountAmount(Long id, AmbInvest ambInvest) {
|
|
|
Integer x=ambInvestMapper.selectCountAmountById(id);
|
|
|
if (x==null)x=0;
|
|
|
@@ -130,6 +145,7 @@ public class AmbInvestServiceImpl extends BaseMybatisDao<AmbInvestMapper> implem
|
|
|
@Override
|
|
|
public int updateInvestTransfer(InputAmbInvest in) {
|
|
|
AmbSystem myAmb = ambSystemMapper.selectByPrimaryKey(in.getMyAmbId());
|
|
|
+ chekAmount(in, myAmb);
|
|
|
AmbSystem other=ambSystemMapper.selectByPrimaryKey(in.getOtherAmbId());
|
|
|
AmbInvest ambInvest=new AmbInvest();
|
|
|
ambInvest.setId(in.getId());
|
|
|
@@ -158,14 +174,15 @@ public class AmbInvestServiceImpl extends BaseMybatisDao<AmbInvestMapper> implem
|
|
|
newAmbInvest.setStatus(in.getStatus());
|
|
|
newAmbInvest.setAmount(ambInvest.getAmount());
|
|
|
if (in.getStatus()==2){
|
|
|
- if (!(myAmb.getId()==1L)){
|
|
|
AmbSystem newMy=new AmbSystem();
|
|
|
newMy.setId(myAmb.getId());
|
|
|
+ if (!(myAmb.getId()==1L)){
|
|
|
+ newMy.setForeign(myAmb.getForeign().add(ambInvest.getAmount()));
|
|
|
+ }else {
|
|
|
newMy.setTotalAmount(myAmb.getTotalAmount().subtract(ambInvest.getAmount()));
|
|
|
newMy.setSurplus(myAmb.getSurplus().subtract(ambInvest.getAmount()));
|
|
|
- newMy.setForeign(myAmb.getForeign().add(ambInvest.getAmount()));
|
|
|
- ambSystemMapper.updateByPrimaryKeySelective(newMy);
|
|
|
}
|
|
|
+ ambSystemMapper.updateByPrimaryKeySelective(newMy);
|
|
|
AmbSystem newOther=new AmbSystem();
|
|
|
newOther.setId(other.getId());
|
|
|
newOther.setReceived(other.getReceived().add(ambInvest.getAmount()));
|