Explorar el Código

1.资金转账算法问题

heqinwei hace 7 años
padre
commit
dee2ec4cd1

+ 2 - 1
applications/money/money-server/src/main/java/com/usoftchina/saas/money/mapper/FundtransferdetailMapper.java

@@ -1,6 +1,7 @@
 package com.usoftchina.saas.money.mapper;
 
 import com.usoftchina.saas.money.po.Fundtransferdetail;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
@@ -12,7 +13,7 @@ public interface FundtransferdetailMapper {
 
     int insertSelective(Fundtransferdetail record);
 
-    List<Fundtransferdetail> selectByPrimaryKey(Integer ftdId);
+    List<Fundtransferdetail> selectByPrimaryKey(@Param("id") Integer ftdId, @Param("companyId") Integer companyId);
 
     int updateByPrimaryKeySelective(Fundtransferdetail record);
 

+ 41 - 0
applications/money/money-server/src/main/java/com/usoftchina/saas/money/po/Fundtransfer.java

@@ -45,6 +45,47 @@ public class Fundtransfer extends CommonBaseEntity implements Serializable {
 
     private String ftd_paycode;
 
+    private String ft_auditman;
+
+    private Date ft_auditdate;
+
+    private Date creatorTime;
+    private String creatorName;
+
+    public Date getCreatorTime() {
+        return creatorTime;
+    }
+
+    public void setCreatorTime(Date creatorTime) {
+        this.creatorTime = creatorTime;
+    }
+
+    @Override
+    public String getCreatorName() {
+        return creatorName;
+    }
+
+    @Override
+    public void setCreatorName(String creatorName) {
+        this.creatorName = creatorName;
+    }
+
+    public String getFt_auditman() {
+        return ft_auditman;
+    }
+
+    public void setFt_auditman(String ft_auditman) {
+        this.ft_auditman = ft_auditman;
+    }
+
+    public Date getFt_auditdate() {
+        return ft_auditdate;
+    }
+
+    public void setFt_auditdate(Date ft_auditdate) {
+        this.ft_auditdate = ft_auditdate;
+    }
+
     public String getFt_code() {
         return ft_code;
     }

+ 44 - 0
applications/money/money-server/src/main/java/com/usoftchina/saas/money/po/Othreceipts.java

@@ -55,6 +55,50 @@ public class Othreceipts extends CommonBaseEntity implements Serializable {
 
     private String ord_remark;
 
+    private String or_auditman;
+
+    private Date or_auditdate;
+
+    private String creatorName;
+
+    private String updaterName;
+
+    @Override
+    public String getUpdaterName() {
+        return updaterName;
+    }
+
+    @Override
+    public void setUpdaterName(String updaterName) {
+        this.updaterName = updaterName;
+    }
+
+    public String getOr_auditman() {
+        return or_auditman;
+    }
+
+    public void setOr_auditman(String or_auditman) {
+        this.or_auditman = or_auditman;
+    }
+
+    public Date getOr_auditdate() {
+        return or_auditdate;
+    }
+
+    public void setOr_auditdate(Date or_auditdate) {
+        this.or_auditdate = or_auditdate;
+    }
+
+    @Override
+    public String getCreatorName() {
+        return creatorName;
+    }
+
+    @Override
+    public void setCreatorName(String creatorName) {
+        this.creatorName = creatorName;
+    }
+
     public String getOr_code() {
         return or_code;
     }

+ 31 - 19
applications/money/money-server/src/main/java/com/usoftchina/saas/money/service/impl/FundtransferServiceImpl.java

@@ -151,21 +151,27 @@ public class FundtransferServiceImpl extends CommonBaseServiceImpl<FundtransferM
 //            }
             Double spending = bankinformation.getBk_spending() == null ? new Double(0) : bankinformation.getBk_spending();
             Double incomme = bankinformation.getBk_income() == null ? new Double(0) : bankinformation.getBk_income();
-            bankinformation.setBk_thisamount(beginamount + incomme - spending - bk_amount);
-            bankinformation.setBk_income(incomme);
-            bankinformation.setBk_spending(spending + bk_amount);
+            Bankinformation newbankinformation = new Bankinformation();
+            newbankinformation.setBk_thisamount(beginamount + incomme - (spending + bk_amount));
+            newbankinformation.setBk_income(incomme);
+            newbankinformation.setBk_spending(spending + bk_amount);
+            newbankinformation.setId(bankinformation.getId());
+            newbankinformation.setCompanyId(BaseContextHolder.getCompanyId());
+            bankinformationMapper.updateByPrimaryKeySelective(newbankinformation);
 
             //收款方
             Bankinformation inbankinformation = bankinformationMapper.selectByPrimaryKey(bk_inid);
             Double inbeginamount = inbankinformation.getBk_beginamount()== null ? new Double(0) : inbankinformation.getBk_beginamount();
             Double inspending = inbankinformation.getBk_spending() == null ? new Double(0) : inbankinformation.getBk_spending();
             Double inincomme = inbankinformation.getBk_income() == null ? new Double(0) : inbankinformation.getBk_income();
-            inbankinformation.setBk_thisamount(inbeginamount + inincomme - inspending + bk_amount);
-            inbankinformation.setBk_income(inincomme + bk_amount);
-            inbankinformation.setBk_spending(inspending);
+            Bankinformation newinbankinformation = new Bankinformation();
+            newinbankinformation.setBk_thisamount(inbeginamount + (inincomme + bk_amount) - inspending );
+            newinbankinformation.setBk_income(inincomme + bk_amount);
+            newinbankinformation.setBk_spending(inspending);
+            newinbankinformation.setId(inbankinformation.getId());
+            newinbankinformation.setCompanyId(BaseContextHolder.getCompanyId());
+            bankinformationMapper.updateByPrimaryKeySelective(newinbankinformation);
 
-            bankinformationMapper.updateByPrimaryKeySelective(bankinformation);
-            bankinformationMapper.updateByPrimaryKeySelective(inbankinformation);
         }
         DocBaseDTO baseDTO = getBaseDTOById(id);
         //日志记录
@@ -187,7 +193,7 @@ public class FundtransferServiceImpl extends CommonBaseServiceImpl<FundtransferM
 
         //资金
         //取从表金额
-        List<Fundtransferdetail> fundtransferdetailList = fundtransferdetailMapper.selectByPrimaryKey(id);
+        List<Fundtransferdetail> fundtransferdetailList = fundtransferdetailMapper.selectByPrimaryKey(id, Math.toIntExact(BaseContextHolder.getCompanyId()));
         Iterator isList = fundtransferdetailList.iterator();
         while (isList.hasNext()){
             Fundtransferdetail fundtransferdetail = (Fundtransferdetail) isList.next();
@@ -208,21 +214,27 @@ public class FundtransferServiceImpl extends CommonBaseServiceImpl<FundtransferM
             Double beginamount = bankinformation.getBk_beginamount()== null ? new Double(0) : bankinformation.getBk_beginamount();
             Double spending = bankinformation.getBk_spending() == null ? new Double(0) : bankinformation.getBk_spending();
             Double incomme = bankinformation.getBk_income() == null ? new Double(0) : bankinformation.getBk_income();
-            bankinformation.setBk_thisamount(beginamount + incomme - spending + bk_amount);
-            bankinformation.setBk_income(incomme);
-            bankinformation.setBk_spending(spending - bk_amount);
+            Bankinformation newbankinformation = new Bankinformation();
+            newbankinformation.setBk_thisamount(beginamount + incomme - (spending - bk_amount));
+            newbankinformation.setBk_income(incomme);
+            newbankinformation.setBk_spending(spending - bk_amount);
+            newbankinformation.setId(Long.valueOf(bk_id));
+            newbankinformation.setCompanyId(BaseContextHolder.getCompanyId());
 
             //收款方
             Bankinformation inbankinformation = bankinformationMapper.selectByPrimaryKey(bk_inid);
             Double inbeginamount = inbankinformation.getBk_beginamount()== null ? new Double(0) : inbankinformation.getBk_beginamount();
             Double inspending = inbankinformation.getBk_spending() == null ? new Double(0) : inbankinformation.getBk_spending();
             Double inincomme = inbankinformation.getBk_income() == null ? new Double(0) : inbankinformation.getBk_income();
-            inbankinformation.setBk_thisamount(inbeginamount + inincomme - inspending - bk_amount);
-            inbankinformation.setBk_income(inincomme - bk_amount);
-            inbankinformation.setBk_spending(inspending);
-
-            bankinformationMapper.updateByPrimaryKeySelective(bankinformation);
-            bankinformationMapper.updateByPrimaryKeySelective(inbankinformation);
+            Bankinformation newinbankinformation = new Bankinformation();
+            newinbankinformation.setBk_thisamount(inbeginamount + (inincomme-bk_amount) - inspending );
+            newinbankinformation.setBk_income(inincomme-bk_amount);
+            newinbankinformation.setBk_spending(inspending);
+            newinbankinformation.setId(Long.valueOf(bk_inid));
+            newinbankinformation.setCompanyId(BaseContextHolder.getCompanyId());
+
+            bankinformationMapper.updateByPrimaryKeySelective(newbankinformation);
+            bankinformationMapper.updateByPrimaryKeySelective(newinbankinformation);
         }
 
         DocBaseDTO baseDTO = getBaseDTOById(Long.valueOf(id));
@@ -286,7 +298,7 @@ public class FundtransferServiceImpl extends CommonBaseServiceImpl<FundtransferM
     public Fundtran select(int id) {
         Fundtran fundtran = new Fundtran();
         fundtran.setMain(fundtransferMapper.selectByPrimaryKey(id));
-        fundtran.setItems(fundtransferdetailMapper.selectByPrimaryKey(id));
+        fundtran.setItems(fundtransferdetailMapper.selectByPrimaryKey(id, Math.toIntExact(BaseContextHolder.getCompanyId())));
         return fundtran;
     }
 

+ 1 - 1
applications/money/money-server/src/main/resources/mapper/BankinformationMapper.xml

@@ -33,7 +33,7 @@
   <sql id="Base_Column_List" >
     bk_id, bk_bankcode, bk_bankname, bk_date, bk_type, bk_beginamount, bk_thisamount, 
     bk_status, bk_statuscode, bk_recorderid, bk_recorder, bk_recorddate, bk_ym, companyid, 
-    updaterId, updateTime, bk_text1, bk_text2, bk_text3, bk_text4, bk_text5, bk_remark
+    updaterId, updateTime, bk_text1, bk_text2, bk_text3, bk_text4, bk_text5, bk_spending, bk_income
   </sql>
   <sql id="Blob_Column_List" >
     bk_remark

+ 18 - 1
applications/money/money-server/src/main/resources/mapper/FundtransferMapper.xml

@@ -24,11 +24,16 @@
     <result column="ftd_nowbalance" property="ftd_nowbalance" jdbcType="DOUBLE" />
     <result column="ftd_paymethod" property="ftd_paymethod" jdbcType="VARCHAR" />
     <result column="ftd_paycode" property="ftd_paycode" jdbcType="VARCHAR" />
+    <result column="creatorName" property="creatorName" jdbcType="VARCHAR" />
+    <result column="updaterName" property="updaterName" jdbcType="VARCHAR" />
+    <result column="ft_auditman" property="ft_auditman" jdbcType="VARCHAR" />
+    <result column="ft_auditdate" property="ft_auditdate" jdbcType="TIMESTAMP" />
+    <result column="createTime" property="createTime" jdbcType="TIMESTAMP" />
   </resultMap>
   <sql id="Base_Column_List" >
     ft_id, ft_code, ft_date, ft_recorderid, ft_recorder, ft_recorddate, ft_status, ft_statuscode, 
     ft_remark, fundtransfer.companyId, fundtransfer.updaterId, fundtransfer.updatedate,
-    ft_text1, ft_text2, ft_text3, ft_text4, ft_text5
+    ft_text1, ft_text2, ft_text3, ft_text4, ft_text5, creatorName, createTime, ft_auditman, ft_auditdate
   </sql>
   <sql id="Detail_Column_List" >
     ftd_bankname,ftd_inbankname,ftd_nowbalance,ftd_paymethod,ftd_paycode
@@ -109,6 +114,12 @@
       <if test="ft_text5 != null" >
         ft_text5,
       </if>
+      <if test="creatorName != null" >
+        creatorName,
+      </if>
+      <if test="creatorTime != null" >
+        creatorTime,
+      </if>
     </trim>
     <trim prefix="values (" suffix=")" suffixOverrides="," >
       <if test="ft_code != null" >
@@ -154,6 +165,12 @@
       <if test="ft_text5 != null" >
         #{ft_text5,jdbcType=VARCHAR},
       </if>
+      <if test="creatorName != null" >
+        #{creatorName,jdbcType=VARCHAR},
+      </if>
+      <if test="creatorTime != null" >
+        #{creatorTime,jdbcType=TIMESTAMP},
+      </if>
     </trim>
     <selectKey resultType="Long" keyProperty="id" order="AFTER">
       SELECT LAST_INSERT_ID()

+ 1 - 1
applications/money/money-server/src/main/resources/mapper/FundtransferdetailMapper.xml

@@ -35,7 +35,7 @@
     select 
     <include refid="Base_Column_List" />
     from fundtransferdetail
-    where ftd_ftid = #{id,jdbcType=INTEGER}
+    where ftd_ftid = #{id,jdbcType=INTEGER} and companyId = #{companyId}
   </select>
 
   <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >

+ 18 - 1
applications/money/money-server/src/main/resources/mapper/OthreceiptsMapper.xml

@@ -29,12 +29,17 @@
     <result column="ord_type" property="ord_type" jdbcType="VARCHAR" />
     <result column="ord_nowbalance" property="ord_nowbalance" jdbcType="DOUBLE" />
     <result column="ord_remark" property="ord_remark" jdbcType="VARCHAR" />
+    <result column="creatorName" property="creatorName" jdbcType="VARCHAR" />
+    <result column="updaterName" property="updaterName" jdbcType="VARCHAR" />
+    <result column="or_auditman" property="or_auditman" jdbcType="VARCHAR" />
+    <result column="or_auditdate" property="or_auditdate" jdbcType="TIMESTAMP" />
+    <result column="createTime" property="createTime" jdbcType="TIMESTAMP" />
   </resultMap>
   <sql id="Base_Column_List" >
     or_id, or_code, or_date, or_custid, or_custcode, or_custname, or_bankcode, or_bankid, 
     or_bankname, or_amount, or_recorderid, or_recorder, or_recorddate, or_status, or_statuscode, 
     or_remark, Othreceipts.companyId, Othreceipts.updaterId, Othreceipts.updatedate, or_text1,
-    or_text2, or_text3, or_text4, or_text5
+    or_text2, or_text3, or_text4, or_text5, creatorName, createTime, or_auditman, or_auditdate
   </sql>
   <sql id="Detail_Column_List" >
     ord_type,ord_nowbalance,ord_remark
@@ -143,6 +148,12 @@
       <if test="or_text5 != null" >
         or_text5,
       </if>
+      <if test="creatorName != null" >
+        creatorName,
+      </if>
+      <if test="creatorTime != null" >
+        creatorTime,
+      </if>
     </trim>
     <trim prefix="values (" suffix=")" suffixOverrides="," >
       <if test="or_code != null" >
@@ -209,6 +220,12 @@
       <if test="or_text5 != null" >
         #{or_text5,jdbcType=VARCHAR},
       </if>
+      <if test="creatorName != null" >
+        #{creatorName,jdbcType=VARCHAR},
+      </if>
+      <if test="creatorTime != null" >
+        #{creatorTime,jdbcType=TIMESTAMP},
+      </if>
     </trim>
     <selectKey resultType="Long" keyProperty="id" order="AFTER">
       SELECT LAST_INSERT_ID()