Browse Source

科德系统投资列表修改

anderx 3 years ago
parent
commit
68eb9efd17

+ 9 - 0
src/main/java/com/goafanti/ambSystem/bo/OutInvestList.java

@@ -9,11 +9,20 @@ public class OutInvestList {
     private String initiateName;
     private String acceptName;
     private BigDecimal amount;
+    private BigDecimal countAmount;
     private Integer status;
     private String operator;
     private String comment;
     private String createTimes;
 
+    public BigDecimal getCountAmount() {
+        return countAmount;
+    }
+
+    public void setCountAmount(BigDecimal countAmount) {
+        this.countAmount = countAmount;
+    }
+
     public Long getInitiateAmbId() {
         return initiateAmbId;
     }

+ 7 - 13
src/main/java/com/goafanti/ambSystem/service/Impl/AmbInvestServiceImpl.java

@@ -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());

+ 1 - 1
src/main/java/com/goafanti/common/mapper/AmbInvestMapper.xml

@@ -134,7 +134,7 @@
 
   <select id="selectInvestList" resultType="com.goafanti.ambSystem.bo.OutInvestList">
     select a.id,a.initiate_amb_id initiateAmbId,b.name initiateName,a.accept_amb_id acceptAmbId,
-    c.name acceptName,a.amount ,a.status ,d.name operator,a.comment ,
+    c.name acceptName,a.amount ,a.status ,d.name operator,a.comment ,a.count_amount countAmount,
     date_format(a.create_time,'%Y-%m-%d %H:%i:%S') createTimes
     from amb_invest a  left join amb_system b on a.initiate_amb_id =b.id
     left join amb_system c on a.accept_amb_id =c.id