Browse Source

发起投资累计金额修改

anderx 3 years ago
parent
commit
fd77d0aa06

+ 18 - 8
src/main/java/com/goafanti/ambSystem/service/Impl/AmbInvestServiceImpl.java

@@ -46,14 +46,15 @@ public class AmbInvestServiceImpl extends BaseMybatisDao<AmbInvestMapper> implem
     @Transactional
     public int pushInvestTransfer(InputAmbInvest in) {
         AmbSystem myAmb =null;
+        AmbInvest ambInvest=new AmbInvest();
+
         if (in.getRoleType()==1){
             myAmb= ambSystemMapper.selectByPrimaryKey(1l);
         }else {
             myAmb=ambSystemMapper.selectByPrimaryKey(in.getMyAmbId());
-            chekAmount(in, myAmb);
+             ambInvest.setCountAmount(chekAmount(in, myAmb));
         }
         AmbSystem other=ambSystemMapper.selectByPrimaryKey(in.getOtherAmbId());
-        AmbInvest ambInvest=new AmbInvest();
         ambInvest.setInitiateAmbId(myAmb.getId());
         ambInvest.setAcceptAmbId(in.getOtherAmbId());
         ambInvest.setAmount(in.getAmount());
@@ -72,20 +73,29 @@ public class AmbInvestServiceImpl extends BaseMybatisDao<AmbInvestMapper> implem
      * @param in 当前数据
      * @param myAmb 发起方
      */
-    private void chekAmount(InputAmbInvest in, AmbSystem myAmb) {
-        if (myAmb.getLvl()!=1){
-            List<OutInvestList> outInvestLists = ambInvestMapper.selectAmbInvestDtailsList(in.getMyAmbId(), 0);
+    private BigDecimal chekAmount(InputAmbInvest in, AmbSystem myAmb) {
             BigDecimal count = new BigDecimal(0);
-            for (OutInvestList outInvestList : outInvestLists) {
-                if (in.getId()!=null&&!in.getId().equals(outInvestList.getId())){
-                    count=count.add(outInvestList.getAmount());
+            List<OutInvestList> outInvestLists = ambInvestMapper.selectAmbInvestDtailsList(in.getMyAmbId(), 0);
+            for (OutInvestList out : outInvestLists) {
+                if (in.getId()!=null&&!in.getId().equals(out.getId())){
+                    count=count.add(out.getAmount());
                 }
             }
             count=count.add(in.getAmount());
+        if (myAmb.getLvl()!=1){
             if (count.compareTo(myAmb.getSurplus())>0){
                 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) {