Browse Source

科德系统投资列表修改

anderx 3 years ago
parent
commit
9991e5e91e

+ 5 - 6
src/main/java/com/goafanti/ambSystem/service/Impl/AmbInvestServiceImpl.java

@@ -62,7 +62,7 @@ public class AmbInvestServiceImpl extends BaseMybatisDao<AmbInvestMapper> implem
         ambInvest.setComment(in.getComment());
         AmbSystem other=ambSystemMapper.selectByPrimaryKey(in.getOtherAmbId());
         //计算累计金额
-        sumCountAmount(other.getId(), ambInvest);
+        ambInvest.setCountAmount(sumCountAmount( ambInvest));
         ambInvestMapper.insertSelective(ambInvest);
         addAmbInvestLog(in, ambInvest);
         if (in.getStatus()==1)addNoticAndEmail(1,myAmb,other);
@@ -92,10 +92,9 @@ public class AmbInvestServiceImpl extends BaseMybatisDao<AmbInvestMapper> implem
 
 
 
-    private void sumCountAmount(Long id, AmbInvest ambInvest) {
-        Integer x=ambInvestMapper.selectCountAmountById(id);
-        if (x==null)x=0;
-        ambInvest.setCountAmount(ambInvest.getAmount().add(new BigDecimal(x)));
+    private BigDecimal sumCountAmount( AmbInvest ambInvest) {
+        BigDecimal count=ambInvestMapper.selectCountAmountById(ambInvest.getInitiateAmbId(),ambInvest.getAcceptAmbId());
+        return count!=null?count:new BigDecimal(0);
     }
 
     private void addNoticAndEmail(Integer i,AmbSystem myAmb,AmbSystem other) {
@@ -205,7 +204,7 @@ public class AmbInvestServiceImpl extends BaseMybatisDao<AmbInvestMapper> implem
             newOther.setTotalAmount(other.getTotalAmount().add(ambInvest.getAmount()));
             ambSystemMapper.updateByPrimaryKeySelective(newOther);
             //计算累计金额
-            sumCountAmount(newOther.getId(), newAmbInvest);
+            newAmbInvest.setCountAmount(sumCountAmount(ambInvest));
         }
         ambInvestMapper.updateByPrimaryKeySelective(newAmbInvest);
         addAmbInvestLog(in, ambInvest);

+ 2 - 1
src/main/java/com/goafanti/common/dao/AmbInvestMapper.java

@@ -4,6 +4,7 @@ import com.goafanti.ambSystem.bo.OutInvestList;
 import com.goafanti.common.model.AmbInvest;
 import org.apache.ibatis.annotations.Param;
 
+import java.math.BigDecimal;
 import java.util.List;
 
 public interface AmbInvestMapper {
@@ -19,7 +20,7 @@ public interface AmbInvestMapper {
 
     int updateByPrimaryKey(AmbInvest record);
 
-    Integer selectCountAmountById(Long id);
+    BigDecimal selectCountAmountById(@Param("initiateAmbId")Long initiateAmbId, @Param("acceptAmbId")Long acceptAmbId);
 
     List<OutInvestList> selectAmbInvestDtailsList(@Param("id") Long id, @Param("type")Integer type);
 

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

@@ -193,10 +193,10 @@
       and a.status= #{status}
     </if>
   </select>
-  <select id="selectCountAmountById" resultType="java.lang.Integer">
+  <select id="selectCountAmountById" resultType="java.math.BigDecimal">
     select sum(amount)amount
     from amb_invest
-    where status=2 and  accept_amb_id = #{id}
+    where status=2 and  accept_amb_id = #{acceptAmbId} and initiate_amb_id= #{initiateAmbId}
   </select>
   <select id="selectAmbInvestDtailsList" resultType="com.goafanti.ambSystem.bo.OutInvestList">
     select a.id,a.initiate_amb_id initiateAmbId ,a.accept_amb_id acceptAmbId,a.amount ,a.status ,