Explorar o código

新增每次通过后计算累计

anderx %!s(int64=3) %!d(string=hai) anos
pai
achega
0e3432995d

+ 4 - 0
src/main/java/com/goafanti/ambSystem/service/Impl/AmbInvestServiceImpl.java

@@ -22,6 +22,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.print.attribute.standard.MediaSize;
+import java.math.BigDecimal;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -147,7 +148,10 @@ public class AmbInvestServiceImpl extends BaseMybatisDao<AmbInvestMapper> implem
             newOther.setTotalAmount(other.getTotalAmount().add(ambInvest.getAmount()));
             ambSystemMapper.updateByPrimaryKeySelective(newMy);
             ambSystemMapper.updateByPrimaryKeySelective(newOther);
+            Integer x=ambInvestMapper.selectCountAmountById(newOther.getId());
+            if (x!=null)newAmbInvest.setCountAmount(new BigDecimal(x));
         }
+
         ambInvestMapper.updateByPrimaryKeySelective(newAmbInvest);
         addAmbInvestLog(in, ambInvest);
         addNoticAndEmail(in.getStatus(),myAmb,other);

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

@@ -14,4 +14,6 @@ public interface AmbInvestMapper {
     int updateByPrimaryKeySelective(AmbInvest record);
 
     int updateByPrimaryKey(AmbInvest record);
-}
+
+    Integer selectCountAmountById(Long id);
+}

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

@@ -10,9 +10,11 @@
     <result column="operator" jdbcType="VARCHAR" property="operator" />
     <result column="comment" jdbcType="VARCHAR" property="comment" />
     <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
+    <result column="count_amount" jdbcType="DECIMAL" property="countAmount" />
   </resultMap>
   <sql id="Base_Column_List">
-    id, initiate_amb_id, accept_amb_id, amount, `status`, `operator`, `comment`, create_time
+    id, initiate_amb_id, accept_amb_id, amount, `status`, `operator`, `comment`, create_time,
+    count_amount
   </sql>
   <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
     select
@@ -27,10 +29,10 @@
   <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.AmbInvest" useGeneratedKeys="true">
     insert into amb_invest (initiate_amb_id, accept_amb_id, amount,
       `status`, `operator`, `comment`,
-      create_time)
+      create_time, count_amount)
     values (#{initiateAmbId,jdbcType=BIGINT}, #{acceptAmbId,jdbcType=BIGINT}, #{amount,jdbcType=DECIMAL},
       #{status,jdbcType=INTEGER}, #{operator,jdbcType=VARCHAR}, #{comment,jdbcType=VARCHAR},
-      #{createTime,jdbcType=TIMESTAMP})
+      #{createTime,jdbcType=TIMESTAMP}, #{countAmount,jdbcType=DECIMAL})
   </insert>
   <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.AmbInvest" useGeneratedKeys="true">
     insert into amb_invest
@@ -56,6 +58,9 @@
       <if test="createTime != null">
         create_time,
       </if>
+      <if test="countAmount != null">
+        count_amount,
+      </if>
     </trim>
     <trim prefix="values (" suffix=")" suffixOverrides=",">
       <if test="initiateAmbId != null">
@@ -79,6 +84,9 @@
       <if test="createTime != null">
         #{createTime,jdbcType=TIMESTAMP},
       </if>
+      <if test="countAmount != null">
+        #{countAmount,jdbcType=DECIMAL},
+      </if>
     </trim>
   </insert>
   <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.AmbInvest">
@@ -105,6 +113,9 @@
       <if test="createTime != null">
         create_time = #{createTime,jdbcType=TIMESTAMP},
       </if>
+      <if test="countAmount != null">
+        count_amount = #{countAmount,jdbcType=DECIMAL},
+      </if>
     </set>
     where id = #{id,jdbcType=BIGINT}
   </update>
@@ -116,7 +127,8 @@
       `status` = #{status,jdbcType=INTEGER},
       `operator` = #{operator,jdbcType=VARCHAR},
       `comment` = #{comment,jdbcType=VARCHAR},
-      create_time = #{createTime,jdbcType=TIMESTAMP}
+      create_time = #{createTime,jdbcType=TIMESTAMP},
+      count_amount = #{countAmount,jdbcType=DECIMAL}
     where id = #{id,jdbcType=BIGINT}
   </update>
 
@@ -144,4 +156,9 @@
       and a.status in (1,2,3)
     </if>
   </select>
+  <select id="selectCountAmountById" resultType="java.lang.Integer">
+    select sum(amount)amount
+    from amb_invest
+    where accept_amb_id = #{id}
+  </select>
 </mapper>

+ 13 - 0
src/main/java/com/goafanti/common/model/AmbInvest.java

@@ -46,6 +46,11 @@ public class AmbInvest implements Serializable {
      */
     private Date createTime;
 
+    /**
+     * 累计金额
+     */
+    private BigDecimal countAmount;
+
     private static final long serialVersionUID = 1L;
 
     public Long getId() {
@@ -111,4 +116,12 @@ public class AmbInvest implements Serializable {
     public void setCreateTime(Date createTime) {
         this.createTime = createTime;
     }
+
+    public BigDecimal getCountAmount() {
+        return countAmount;
+    }
+
+    public void setCountAmount(BigDecimal countAmount) {
+        this.countAmount = countAmount;
+    }
 }