Browse Source

借支列表新增部门筛选与条件

anderx 2 years ago
parent
commit
8b1a963ece

+ 17 - 6
src/main/java/com/goafanti/common/mapper/ExpenseAccountMapper.xml

@@ -24,11 +24,12 @@
     <result column="duration" jdbcType="DOUBLE" property="duration" />
     <result column="examine_name" jdbcType="VARCHAR" property="examineName" />
     <result column="settlement_amount" jdbcType="DECIMAL" property="settlementAmount" />
+    <result column="debit_id" jdbcType="INTEGER" property="debitId" />
   </resultMap>
   <sql id="Base_Column_List">
     id, prid, order_no, aid, aname, `type`, type_other, `status`, process_status, total_amount,
     attachment_url, apply_dep, pay_dep, eaaid, create_time, district_name, user_names,
-    release_start, release_end, duration, examine_name, settlement_amount
+    release_start, release_end, duration, examine_name, settlement_amount, debit_id
   </sql>
   <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
     select
@@ -47,16 +48,16 @@
       attachment_url, apply_dep, pay_dep,
       eaaid, create_time, district_name,
       user_names, release_start, release_end,
-      duration, examine_name, settlement_amount
-      )
+      duration, examine_name, settlement_amount,
+      debit_id)
     values (#{prid,jdbcType=INTEGER}, #{orderNo,jdbcType=VARCHAR}, #{aid,jdbcType=VARCHAR},
       #{aname,jdbcType=VARCHAR}, #{type,jdbcType=INTEGER}, #{typeOther,jdbcType=VARCHAR},
       #{status,jdbcType=INTEGER}, #{processStatus,jdbcType=INTEGER}, #{totalAmount,jdbcType=DECIMAL},
       #{attachmentUrl,jdbcType=VARCHAR}, #{applyDep,jdbcType=VARCHAR}, #{payDep,jdbcType=VARCHAR},
       #{eaaid,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{districtName,jdbcType=VARCHAR},
       #{userNames,jdbcType=VARCHAR}, #{releaseStart,jdbcType=TIMESTAMP}, #{releaseEnd,jdbcType=TIMESTAMP},
-      #{duration,jdbcType=DOUBLE}, #{examineName,jdbcType=VARCHAR}, #{settlementAmount,jdbcType=DECIMAL}
-      )
+      #{duration,jdbcType=DOUBLE}, #{examineName,jdbcType=VARCHAR}, #{settlementAmount,jdbcType=DECIMAL},
+      #{debitId,jdbcType=INTEGER})
   </insert>
   <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.ExpenseAccount" useGeneratedKeys="true">
     insert into expense_account
@@ -124,6 +125,9 @@
       <if test="settlementAmount != null">
         settlement_amount,
       </if>
+      <if test="debitId != null">
+        debit_id,
+      </if>
     </trim>
     <trim prefix="values (" suffix=")" suffixOverrides=",">
       <if test="prid != null">
@@ -189,6 +193,9 @@
       <if test="settlementAmount != null">
         #{settlementAmount,jdbcType=DECIMAL},
       </if>
+      <if test="debitId != null">
+        #{debitId,jdbcType=INTEGER},
+      </if>
     </trim>
   </insert>
   <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.ExpenseAccount">
@@ -257,6 +264,9 @@
       <if test="settlementAmount != null">
         settlement_amount = #{settlementAmount,jdbcType=DECIMAL},
       </if>
+      <if test="debitId != null">
+        debit_id = #{debitId,jdbcType=INTEGER},
+      </if>
     </set>
     where id = #{id,jdbcType=INTEGER}
   </update>
@@ -282,7 +292,8 @@
       release_end = #{releaseEnd,jdbcType=TIMESTAMP},
       duration = #{duration,jdbcType=DOUBLE},
       examine_name = #{examineName,jdbcType=VARCHAR},
-      settlement_amount = #{settlementAmount,jdbcType=DECIMAL}
+      settlement_amount = #{settlementAmount,jdbcType=DECIMAL},
+      debit_id = #{debitId,jdbcType=INTEGER}
     where id = #{id,jdbcType=INTEGER}
   </update>
 

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

@@ -116,6 +116,11 @@ public class ExpenseAccount implements Serializable {
      */
     private BigDecimal settlementAmount;
 
+    /**
+     * 抵扣编号
+     */
+    private Integer debitId;
+
     private static final long serialVersionUID = 1L;
 
     public Integer getId() {
@@ -293,4 +298,12 @@ public class ExpenseAccount implements Serializable {
     public void setSettlementAmount(BigDecimal settlementAmount) {
         this.settlementAmount = settlementAmount;
     }
+
+    public Integer getDebitId() {
+        return debitId;
+    }
+
+    public void setDebitId(Integer debitId) {
+        this.debitId = debitId;
+    }
 }

+ 15 - 2
src/main/java/com/goafanti/expenseAccount/service/impl/ExpenseAccountServiceImpl.java

@@ -21,6 +21,7 @@ import com.goafanti.expenseAccount.service.ExpenseAccountService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.math.BigDecimal;
 import java.util.*;
 
 @Service
@@ -162,12 +163,24 @@ public class ExpenseAccountServiceImpl extends BaseMybatisDao<ExpenseAccountMapp
         //完成申请
         if (in.getStatus()==2){
             //如果是借支则订单新增
-
             if (in.getType()==4){
 
             }else {
                 //不然就看是否挂载借支订单进行抵扣
-
+                if (useEa.getDebitId()!=null){
+                    ExpenseAccount useDebit=expenseAccountMapper.selectByPrimaryKey(useEa.getDebitId());
+                    ExpenseAccount debit=new ExpenseAccount();
+                    debit.setId(useEa.getDebitId());
+                    BigDecimal settlementAmount = useDebit.getSettlementAmount();
+                    settlementAmount=settlementAmount.add(useEa.getTotalAmount());
+                    //如果不大于金额
+                    if (settlementAmount.compareTo(useDebit.getTotalAmount())<1){
+                        //计算抵扣后的已付
+                        debit.setSettlementAmount(settlementAmount);
+                        //设置当前报销已付
+
+                    }
+                }
             }
         }
         expenseAccountMapper.updateByPrimaryKeySelective(newEa);