Browse Source

资金模块-付款单/收款单审核反审核业务逻辑

huangx 7 years ago
parent
commit
f8e41cfec9

+ 209 - 0
applications/document/document-dto/src/main/java/com/usoftchina/saas/document/entities/Customer.java

@@ -58,4 +58,213 @@ public class Customer extends CommonBaseEntity implements Serializable {
 
     private Double cu_recamount;
 
+    private Double cu_preamount;
+
+    public String getCu_code() {
+        return cu_code;
+    }
+
+    public void setCu_code(String cu_code) {
+        this.cu_code = cu_code;
+    }
+
+    public String getCu_name() {
+        return cu_name;
+    }
+
+    public void setCu_name(String cu_name) {
+        this.cu_name = cu_name;
+    }
+
+    public String getCu_uu() {
+        return cu_uu;
+    }
+
+    public void setCu_uu(String cu_uu) {
+        this.cu_uu = cu_uu;
+    }
+
+    public String getCu_type() {
+        return cu_type;
+    }
+
+    public void setCu_type(String cu_type) {
+        this.cu_type = cu_type;
+    }
+
+    public Date getCu_begindate() {
+        return cu_begindate;
+    }
+
+    public void setCu_begindate(Date cu_begindate) {
+        this.cu_begindate = cu_begindate;
+    }
+
+    public Double getCu_beginaramount() {
+        return cu_beginaramount;
+    }
+
+    public void setCu_beginaramount(Double cu_beginaramount) {
+        this.cu_beginaramount = cu_beginaramount;
+    }
+
+    public Double getCu_beginprerecamount() {
+        return cu_beginprerecamount;
+    }
+
+    public void setCu_beginprerecamount(Double cu_beginprerecamount) {
+        this.cu_beginprerecamount = cu_beginprerecamount;
+    }
+
+    public Double getCu_promisedays() {
+        return cu_promisedays;
+    }
+
+    public void setCu_promisedays(Double cu_promisedays) {
+        this.cu_promisedays = cu_promisedays;
+    }
+
+    public Double getCu_taxrate() {
+        return cu_taxrate;
+    }
+
+    public void setCu_taxrate(Double cu_taxrate) {
+        this.cu_taxrate = cu_taxrate;
+    }
+
+    public Integer getCu_sellerid() {
+        return cu_sellerid;
+    }
+
+    public void setCu_sellerid(Integer cu_sellerid) {
+        this.cu_sellerid = cu_sellerid;
+    }
+
+    public String getCu_sellercode() {
+        return cu_sellercode;
+    }
+
+    public void setCu_sellercode(String cu_sellercode) {
+        this.cu_sellercode = cu_sellercode;
+    }
+
+    public String getCu_sellername() {
+        return cu_sellername;
+    }
+
+    public void setCu_sellername(String cu_sellername) {
+        this.cu_sellername = cu_sellername;
+    }
+
+    public Double getCu_credit() {
+        return cu_credit;
+    }
+
+    public void setCu_credit(Double cu_credit) {
+        this.cu_credit = cu_credit;
+    }
+
+    public String getCu_status() {
+        return cu_status;
+    }
+
+    public void setCu_status(String cu_status) {
+        this.cu_status = cu_status;
+    }
+
+    public String getCu_statuscode() {
+        return cu_statuscode;
+    }
+
+    public void setCu_statuscode(String cu_statuscode) {
+        this.cu_statuscode = cu_statuscode;
+    }
+
+    public Integer getCu_recordmanid() {
+        return cu_recordmanid;
+    }
+
+    public void setCu_recordmanid(Integer cu_recordmanid) {
+        this.cu_recordmanid = cu_recordmanid;
+    }
+
+    public String getCu_recordman() {
+        return cu_recordman;
+    }
+
+    public void setCu_recordman(String cu_recordman) {
+        this.cu_recordman = cu_recordman;
+    }
+
+    public Date getCu_recorddate() {
+        return cu_recorddate;
+    }
+
+    public void setCu_recorddate(Date cu_recorddate) {
+        this.cu_recorddate = cu_recorddate;
+    }
+
+    public String getCu_text1() {
+        return cu_text1;
+    }
+
+    public void setCu_text1(String cu_text1) {
+        this.cu_text1 = cu_text1;
+    }
+
+    public String getCu_text2() {
+        return cu_text2;
+    }
+
+    public void setCu_text2(String cu_text2) {
+        this.cu_text2 = cu_text2;
+    }
+
+    public String getCu_text3() {
+        return cu_text3;
+    }
+
+    public void setCu_text3(String cu_text3) {
+        this.cu_text3 = cu_text3;
+    }
+
+    public String getCu_text4() {
+        return cu_text4;
+    }
+
+    public void setCu_text4(String cu_text4) {
+        this.cu_text4 = cu_text4;
+    }
+
+    public String getCu_text5() {
+        return cu_text5;
+    }
+
+    public void setCu_text5(String cu_text5) {
+        this.cu_text5 = cu_text5;
+    }
+
+    public Double getCu_leftamount() {
+        return cu_leftamount;
+    }
+
+    public void setCu_leftamount(Double cu_leftamount) {
+        this.cu_leftamount = cu_leftamount;
+    }
+
+    public Double getCu_recamount() {
+        return cu_recamount;
+    }
+
+    public void setCu_recamount(Double cu_recamount) {
+        this.cu_recamount = cu_recamount;
+    }
+
+    public Double getCu_preamount() {
+        return cu_preamount;
+    }
+
+    public void setCu_preamount(Double cu_preamount) {
+        this.cu_preamount = cu_preamount;
+    }
 }

+ 2 - 0
applications/document/document-dto/src/main/java/com/usoftchina/saas/document/entities/CustomerList.java

@@ -62,6 +62,8 @@ public class CustomerList extends CommonBaseEntity{
     private Double cu_leftamount;
 
     private Double cu_recamount;
+
+    private Double cu_preamount;
 //customeraddress
 
     private Long ca_cuid;

+ 16 - 6
applications/document/document-dto/src/main/java/com/usoftchina/saas/document/entities/Vendor.java

@@ -35,11 +35,11 @@ public class Vendor extends CommonBaseEntity implements Serializable{
     /**
      * 期初应付
      */
-    private Long ve_beginapamount;
+    private double ve_beginapamount;
     /**
      * 期初预付
      */
-    private Long ve_beginprepayamount;
+    private double ve_beginprepayamount;
     /**
      * 承付天数
      */
@@ -107,6 +107,8 @@ public class Vendor extends CommonBaseEntity implements Serializable{
 
     private Integer ve_beginym;
 
+    private Double ve_preamount;
+
     public Double getVe_payamount() {
         return ve_payamount;
     }
@@ -171,19 +173,19 @@ public class Vendor extends CommonBaseEntity implements Serializable{
         this.ve_begindate = ve_begindate;
     }
 
-    public Long getVe_beginapamount() {
+    public double getVe_beginapamount() {
         return ve_beginapamount;
     }
 
-    public void setVe_beginapamount(Long ve_beginapamount) {
+    public void setVe_beginapamount(double ve_beginapamount) {
         this.ve_beginapamount = ve_beginapamount;
     }
 
-    public Long getVe_beginprepayamount() {
+    public double getVe_beginprepayamount() {
         return ve_beginprepayamount;
     }
 
-    public void setVe_beginprepayamount(Long ve_beginprepayamount) {
+    public void setVe_beginprepayamount(double ve_beginprepayamount) {
         this.ve_beginprepayamount = ve_beginprepayamount;
     }
 
@@ -306,4 +308,12 @@ public class Vendor extends CommonBaseEntity implements Serializable{
     public void setVe_text5(String ve_text5) {
         this.ve_text5 = ve_text5;
     }
+
+    public Double getVe_preamount() {
+        return ve_preamount;
+    }
+
+    public void setVe_preamount(Double ve_preamount) {
+        this.ve_preamount = ve_preamount;
+    }
 }

+ 2 - 2
applications/document/document-dto/src/main/java/com/usoftchina/saas/document/entities/VendorList.java

@@ -33,11 +33,11 @@ public class VendorList implements Serializable {
     /**
      * 期初应付
      */
-    private long ve_beginapamount;
+    private double ve_beginapamount;
     /**
      * 期初预付
      */
-    private long ve_beginprepayamount;
+    private double ve_beginprepayamount;
     /**
      * 承付天数
      */

+ 1 - 0
applications/document/document-server/src/main/resources/mapper/CustomerListMapper.xml

@@ -23,6 +23,7 @@
     <result column="cu_recorddate" jdbcType="TIMESTAMP" property="cu_recorddate" />
     <result column="cu_leftamount" jdbcType="DOUBLE" property="cu_leftamount" />
     <result column="cu_recamount" jdbcType="DOUBLE" property="cu_recamount" />
+    <result column="cu_preamount" jdbcType="DOUBLE" property="cu_preamount" />
     <result column="ca_cuid" jdbcType="INTEGER" property="ca_cuid" />
     <result column="ca_detno" jdbcType="INTEGER" property="ca_detno" />
     <result column="ca_person" jdbcType="VARCHAR" property="ca_person" />

+ 12 - 2
applications/document/document-server/src/main/resources/mapper/CustomerMapper.xml

@@ -37,7 +37,7 @@
     cu_promisedays, cu_taxrate, cu_sellerid, cu_sellercode, cu_sellername, cu_credit, 
     cu_status, cu_statuscode, cu_recordmanid, cu_recordman, cu_recorddate, companyid, 
     updaterid, updatetime, cu_text1, cu_text2, cu_text3, cu_text4, cu_text5, cu_leftamount, 
-    cu_recamount
+    cu_recamount,cu_preamount
   </sql>
   <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
     select 
@@ -140,6 +140,9 @@
       <if test="cu_recamount != null">
         cu_recamount,
       </if>
+      <if test="cu_preamount != null">
+        cu_preamount,
+      </if>
     </trim>
     <trim prefix="values (" suffix=")" suffixOverrides=",">
 
@@ -227,6 +230,9 @@
       <if test="cu_recamount != null">
         #{cu_recamount,jdbcType=DOUBLE},
       </if>
+      <if test="cu_preamount != null">
+        #{cu_preamount,jdbcType=DOUBLE},
+      </if>
     </trim>
   </insert>
   <update id="updateByPrimaryKeySelective" parameterType="com.usoftchina.saas.document.entities.Customer">
@@ -316,6 +322,9 @@
       <if test="cu_recamount != null">
         cu_recamount = #{cu_recamount,jdbcType=DOUBLE},
       </if>
+      <if test="cu_preamount != null">
+        cu_preamount = #{cu_preamount,jdbcType=DOUBLE},
+      </if>
     </set>
     where cu_id = #{id,jdbcType=INTEGER}
   </update>
@@ -348,7 +357,8 @@
       cu_text4 = #{cu_text4,jdbcType=VARCHAR},
       cu_text5 = #{cu_text5,jdbcType=VARCHAR},
       cu_leftamount = #{cu_leftamount,jdbcType=DOUBLE},
-      cu_recamount = #{cu_recamount,jdbcType=DOUBLE}
+      cu_recamount = #{cu_recamount,jdbcType=DOUBLE},
+      cu_preamount = #{cu_preamount,jdbcType=DOUBLE}
     where cu_id = #{id,jdbcType=INTEGER}
   </update>
 

+ 27 - 15
applications/document/document-server/src/main/resources/mapper/VendorMapper.xml

@@ -8,8 +8,8 @@
         <result column="ve_name" property="ve_name" jdbcType="VARCHAR" />
         <result column="ve_type" property="ve_type" jdbcType="VARCHAR" />
         <result column="ve_begindate" property="ve_begindate" jdbcType="TIMESTAMP" />
-        <result column="ve_beginapamount" property="ve_beginapamount" jdbcType="INTEGER" />
-        <result column="ve_beginprepayamount" property="ve_beginprepayamount" jdbcType="INTEGER" />
+        <result column="ve_beginapamount" property="ve_beginapamount" jdbcType="DOUBLE" />
+        <result column="ve_beginprepayamount" property="ve_beginprepayamount" jdbcType="DOUBLE" />
         <result column="ve_promisedays" property="ve_promisedays" jdbcType="INTEGER" />
         <result column="ve_taxrate" property="ve_taxrate" jdbcType="DOUBLE" />
         <result column="ve_nsrzh" property="ve_nsrzh" jdbcType="VARCHAR" />
@@ -31,6 +31,7 @@
         <result column="ve_payamount" property="ve_payamount" jdbcType="DOUBLE" />
         <result column="ve_leftamount" property="ve_leftamount" jdbcType="DOUBLE" />
         <result column="ve_beginym" property="ve_beginym" jdbcType="INTEGER" />
+        <result column="ve_preamount" property="ve_preamount" jdbcType="DOUBLE" />
     </resultMap>
     <resultMap id="VendorDTOResultMapper" type="com.usoftchina.saas.document.dto.VendorDTO">
         <id column="ve_id" property="id" jdbcType="INTEGER" />
@@ -60,8 +61,8 @@
         <result column="ve_name" property="ve_name" jdbcType="VARCHAR" />
         <result column="ve_type" property="ve_type" jdbcType="VARCHAR" />
         <result column="ve_begindate" property="ve_begindate" jdbcType="TIMESTAMP" />
-        <result column="ve_beginapamount" property="ve_beginapamount" jdbcType="INTEGER" />
-        <result column="ve_beginprepayamount" property="ve_beginprepayamount" jdbcType="INTEGER" />
+        <result column="ve_beginapamount" property="ve_beginapamount" jdbcType="DOUBLE" />
+        <result column="ve_beginprepayamount" property="ve_beginprepayamount" jdbcType="DOUBLE" />
         <result column="ve_promisedays" property="ve_promisedays" jdbcType="INTEGER" />
         <result column="ve_taxrate" property="ve_taxrate" jdbcType="DOUBLE" />
         <result column="ve_nsrzh" property="ve_nsrzh" jdbcType="VARCHAR" />
@@ -107,7 +108,7 @@
         ve_id, ve_code, ve_name, ve_uu, ve_type, ve_begindate, ve_beginapamount, ve_beginprepayamount,
         ve_promisedays, ve_taxrate, ve_nsrzh, ve_bankaccount, ve_bankcode, ve_status, ve_statuscode,
         ve_recordid, ve_recordname, ve_initdate, companyId, updaterId, updateTime, ve_text1,
-        ve_text2, ve_text3, ve_text4, ve_text5, ve_payamount, ve_leftamount, ve_beginym
+        ve_text2, ve_text3, ve_text4, ve_text5, ve_payamount, ve_leftamount, ve_beginym, ve_preamount
     </sql>
     <select id="selectByPrimaryKey" resultMap="VendorResultMapper" parameterType="java.lang.Long" >
         select
@@ -129,18 +130,19 @@
         ve_initdate, companyId, updaterId,
         updateTime, ve_text1, ve_text2,
         ve_text3, ve_text4, ve_text5,
-        ve_payamount, ve_leftamount, ve_beginym
+        ve_payamount, ve_leftamount, ve_beginym ,ve_preamount
         )
         values (#{ve_code,jdbcType=VARCHAR}, #{ve_name,jdbcType=VARCHAR},
         #{ve_uu,jdbcType=VARCHAR}, #{ve_type,jdbcType=VARCHAR}, #{ve_begindate,jdbcType=TIMESTAMP},
-        #{ve_beginapamount,jdbcType=DECIMAL}, #{ve_beginprepayamount,jdbcType=DECIMAL},
+        #{ve_beginapamount,jdbcType=DOUBLE}, #{ve_beginprepayamount,jdbcType=DOUBLE},
         #{ve_promisedays,jdbcType=DECIMAL}, #{ve_taxrate,jdbcType=DOUBLE}, #{ve_nsrzh,jdbcType=VARCHAR},
         #{ve_bankaccount,jdbcType=VARCHAR}, #{ve_bankcode,jdbcType=VARCHAR}, #{ve_status,jdbcType=VARCHAR},
         #{ve_statuscode,jdbcType=VARCHAR}, #{ve_recordid,jdbcType=DECIMAL}, #{ve_recordname,jdbcType=VARCHAR},
         #{ve_initdate,jdbcType=TIMESTAMP}, #{companyId,jdbcType=DECIMAL}, #{updaterId,jdbcType=DECIMAL},
         #{updateTime,jdbcType=TIMESTAMP}, #{ve_text1,jdbcType=VARCHAR}, #{ve_text2,jdbcType=VARCHAR},
         #{ve_text3,jdbcType=VARCHAR}, #{ve_text4,jdbcType=VARCHAR}, #{ve_text5,jdbcType=VARCHAR},
-        #{ve_payamount,jdbcType=DOUBLE}, #{ve_leftamount,jdbcType=DOUBLE}, #{ve_beginym,jdbcType=INTEGER}
+        #{ve_payamount,jdbcType=DOUBLE}, #{ve_leftamount,jdbcType=DOUBLE}, #{ve_beginym,jdbcType=INTEGER},
+        #{ve_preamount,jdbcTyp=DOUBLE}
         )
     </insert>
     <insert id="insertSelective" parameterType="com.usoftchina.saas.document.entities.Vendor" >
@@ -233,6 +235,9 @@
             <if test="ve_beginym != null" >
                 ve_beginym,
             </if>
+            <if test="ve_preamount !=null" >
+                ve_preamount,
+            </if>
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides="," >
             <if test="ve_code != null" >
@@ -251,10 +256,10 @@
                 #{ve_begindate,jdbcType=TIMESTAMP},
             </if>
             <if test="ve_beginapamount != null" >
-                #{ve_beginapamount,jdbcType=DECIMAL},
+                #{ve_beginapamount,jdbcType=DOUBLE},
             </if>
             <if test="ve_beginprepayamount != null" >
-                #{ve_beginprepayamount,jdbcType=DECIMAL},
+                #{ve_beginprepayamount,jdbcType=DOUBLE},
             </if>
             <if test="ve_promisedays != null" >
                 #{ve_promisedays,jdbcType=DECIMAL},
@@ -319,6 +324,9 @@
             <if test="ve_beginym != null" >
                 #{ve_beginym,jdbcType=INTEGER},
             </if>
+            <if test="ve_preamount !=null" >
+                #{ve_preamount,jdbcType=DOUBLE},
+            </if>
         </trim>
     </insert>
     <update id="updateByPrimaryKeySelective" parameterType="com.usoftchina.saas.document.entities.Vendor" >
@@ -340,10 +348,10 @@
                 ve_begindate = #{ve_begindate,jdbcType=TIMESTAMP},
             </if>
             <if test="ve_beginapamount != null" >
-                ve_beginapamount = #{ve_beginapamount,jdbcType=DECIMAL},
+                ve_beginapamount = #{ve_beginapamount,jdbcType=DOUBLE},
             </if>
             <if test="ve_beginprepayamount != null" >
-                ve_beginprepayamount = #{ve_beginprepayamount,jdbcType=DECIMAL},
+                ve_beginprepayamount = #{ve_beginprepayamount,jdbcType=DOUBLE},
             </if>
             <if test="ve_promisedays != null" >
                 ve_promisedays = #{ve_promisedays,jdbcType=DECIMAL},
@@ -408,6 +416,9 @@
             <if test="ve_beginym != null" >
                 ve_beginym = #{ve_beginym,jdbcType=INTEGER},
             </if>
+            <if test="ve_preamount !=null" >
+                #{ve_preamount,jdbcType=DOUBLE},
+            </if>
         </set>
         where ve_id = #{id}
     </update>
@@ -418,8 +429,8 @@
         ve_uu = #{ve_uu,jdbcType=VARCHAR},
         ve_type = #{ve_type,jdbcType=VARCHAR},
         ve_begindate = #{ve_begindate,jdbcType=TIMESTAMP},
-        ve_beginapamount = #{ve_beginapamount,jdbcType=DECIMAL},
-        ve_beginprepayamount = #{ve_beginprepayamount,jdbcType=DECIMAL},
+        ve_beginapamount = #{ve_beginapamount,jdbcType=DOUBLE},
+        ve_beginprepayamount = #{ve_beginprepayamount,jdbcType=DOUBLE},
         ve_promisedays = #{ve_promisedays,jdbcType=DECIMAL},
         ve_taxrate = #{ve_taxrate,jdbcType=DOUBLE},
         ve_nsrzh = #{ve_nsrzh,jdbcType=VARCHAR},
@@ -440,7 +451,8 @@
         ve_text5 = #{ve_text5,jdbcType=VARCHAR},
         ve_payamount = #{ve_payamount,jdbcType=DOUBLE},
         ve_leftamount = #{ve_leftamount,jdbcType=DOUBLE},
-        ve_beginym = #{ve_beginym,jdbcType=INTEGER}
+        ve_beginym = #{ve_beginym,jdbcType=INTEGER},
+        ve_preamount =#{ve_preamount,jdbcType=DOUBLE}
         where ve_id = #{id}
     </update>
 

+ 10 - 0
applications/money/money-server/pom.xml

@@ -97,6 +97,16 @@
             <version>1.0.0-SNAPSHOT</version>
             <scope>compile</scope>
         </dependency>
+        <dependency>
+            <groupId>com.usoftchina.saas</groupId>
+            <artifactId>document-dto</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.usoftchina.saas</groupId>
+            <artifactId>document-server</artifactId>
+            <version>1.0.0-SNAPSHOT</version>
+            <scope>compile</scope>
+        </dependency>
     </dependencies>
 
     <build>

+ 69 - 7
applications/money/money-server/src/main/java/com/usoftchina/saas/money/service/impl/PaybalanceServiceImpl.java

@@ -10,6 +10,10 @@ import com.usoftchina.saas.commons.exception.BizExceptionCode;
 import com.usoftchina.saas.commons.po.BillCodeSeq;
 import com.usoftchina.saas.commons.po.Status;
 import com.usoftchina.saas.context.BaseContextHolder;
+import com.usoftchina.saas.document.entities.Bankinformation;
+import com.usoftchina.saas.document.entities.Vendor;
+import com.usoftchina.saas.document.mapper.BankinformationMapper;
+import com.usoftchina.saas.document.mapper.VendorMapper;
 import com.usoftchina.saas.exception.BizException;
 import com.usoftchina.saas.money.mapper.*;
 import com.usoftchina.saas.money.po.*;
@@ -42,6 +46,10 @@ public class PaybalanceServiceImpl implements PaybalanceService {
     private SubledgerMapper subledgerMapper;
     @Autowired
     private BanksubledgerMapper banksubledgerMapper;
+    @Autowired
+    private VendorMapper vendorMapper;
+    @Autowired
+    private BankinformationMapper bankinformationMapper;
 
     public DocBaseDTO insert(Pay pay) {
         Paybalance paybalance = pay.getMain();
@@ -184,15 +192,74 @@ public class PaybalanceServiceImpl implements PaybalanceService {
         Double amountTotal = new Double(0);
         for (Paybalancedet det: paybalancedet) {
             amountTotal = amountTotal + det.getPd_amount();
+            //更新账户资料金额
+            Bankinformation bankinformation = new Bankinformation();
+            Bankinformation nowBankInformation = bankinformationMapper.selectByPrimaryKey(det.getPd_bankid());
+            bankinformation.setBk_thisamount(nowBankInformation.getBk_thisamount()+det.getPd_amount());
+            bankinformationMapper.updateByPrimaryKeySelective(bankinformation);
+        }
+        //更新主表pb_pbdamount=从表二金额合计
+        Double amountTotal2 = new Double(0);
+        for (Paybalancedetail detail : paybalancedetail){
+            amountTotal2 = amountTotal2 + detail.getPbd_amount();
         }
         updatePay.setId(pay.getMain().getId());
         updatePay.setPb_pdamount(amountTotal);
+        updatePay.setPb_pbdamount(amountTotal2);
+        paybalanceMapper.updateByPrimaryKeySelective(updatePay);
         //updateByPrimaryKeySelective
-
+        /**
+         * ve_preamount=nvl(ve_preamount,0)+pb_preamount,
+         * ve_payamount=nvl(ve_payamount,0)-pb_pbdamount,
+         * ve_leftamount=ve_beginapamount-ve_beginprepayamount+ve_payamount-ve_preamount;
+         */
+        Vendor vendorData = vendorMapper.selectByPrimaryKey(Long.valueOf(String.valueOf(paybalance.getPb_vendid())));
+        Double preamount = vendorData.getVe_preamount();
+        Double beginapamount = vendorData.getVe_beginapamount();
+        Double beginprepayamount= vendorData.getVe_beginprepayamount();
+        Double payamount = vendorData.getVe_payamount();
+
+        Vendor vendor = new Vendor();
+        vendor.setId(Long.valueOf(String.valueOf(paybalance.getPb_vendid())));
+        vendor.setVe_preamount(preamount+amountTotal);
+        vendor.setVe_payamount(payamount-amountTotal2);
+        vendor.setVe_leftamount(beginapamount-beginprepayamount+payamount-amountTotal2-preamount-amountTotal);
+        vendorMapper.updateByPrimaryKeySelective(vendor);
     }
 
     @Override
     public void unAudit(int id) {
+        //更新供应商资料
+        /**
+         * ve_preamount=nvl(ve_preamount,0)-pb_preamount,
+         * ve_payamount=nvl(ve_payamount,0)+pb_pbdamount,
+         * ve_leftamount=ve_beginapamount-ve_beginprepayamount+ve_payamount-ve_preamount;
+         */
+        Paybalance pay = paybalanceMapper.selectByPrimaryKey(Long.valueOf(id));
+        Double pay_preamount = pay.getPb_preamount();
+        Double pay_pbdamount = pay.getPb_pbdamount();
+        Vendor vendorData = vendorMapper.selectByPrimaryKey(Long.valueOf(String.valueOf(pay.getPb_vendid())));
+        Double preamount = vendorData.getVe_preamount();
+        Double beginapamount = vendorData.getVe_beginapamount();
+        Double beginprepayamount= vendorData.getVe_beginprepayamount();
+        Double payamount = vendorData.getVe_payamount();
+        Vendor vendor = new Vendor();
+        vendor.setId(Long.valueOf(String.valueOf(pay.getPb_vendid())));
+        vendor.setVe_preamount(preamount-pay_preamount);
+        vendor.setVe_payamount(payamount+pay_pbdamount);
+        vendor.setVe_leftamount(beginapamount-beginprepayamount+payamount+pay_pbdamount-preamount+pay_preamount);
+        vendorMapper.updateByPrimaryKeySelective(vendor);
+
+        //更新账户资料金额
+        List<Paybalancedet> paybalancedet = paybalancedetMapper.selectByPrimaryKey(id);
+        for (Paybalancedet det:paybalancedet) {
+            Bankinformation bankinformation = new Bankinformation();
+            Bankinformation nowBankInformation = bankinformationMapper.selectByPrimaryKey(det.getPd_bankid());
+            bankinformation.setBk_thisamount(nowBankInformation.getBk_thisamount()-det.getPd_amount());
+            bankinformationMapper.updateByPrimaryKeySelective(bankinformation);
+        }
+
+
         Paybalance paybalance = new Paybalance();
         paybalance.setId(Long.valueOf(id));
         paybalance.setPb_status(com.usoftchina.saas.commons.po.Status.UNAUDITED.getDisplay());
@@ -204,12 +271,7 @@ public class PaybalanceServiceImpl implements PaybalanceService {
         subledgerMapper.deleteByPrimaryKey(paybalance.getPb_code(), paybalance.getPb_kind());
         banksubledgerMapper.deleteByPrimaryKey(paybalance.getPb_code(), paybalance.getPb_kind());
 
-        //更新供应商资料
-        /**
-         * ve_preamount=nvl(ve_preamount,0)-pb_preamount,
-         * ve_payamount=nvl(ve_payamount,0)+pb_pbdamount,
-         * ve_leftamount=ve_beginapamount-e_beginprepayamount+ve_payamount-ve_preamount;
-         */
+
     }
 
 

+ 76 - 5
applications/money/money-server/src/main/java/com/usoftchina/saas/money/service/impl/RecbalanceServiceImpl.java

@@ -10,11 +10,18 @@ import com.usoftchina.saas.commons.exception.BizExceptionCode;
 import com.usoftchina.saas.commons.po.BillCodeSeq;
 import com.usoftchina.saas.commons.po.Status;
 import com.usoftchina.saas.context.BaseContextHolder;
+import com.usoftchina.saas.document.entities.Bankinformation;
+import com.usoftchina.saas.document.entities.Customer;
+import com.usoftchina.saas.document.entities.Vendor;
+import com.usoftchina.saas.document.mapper.BankinformationMapper;
+import com.usoftchina.saas.document.mapper.CustomerMapper;
+import com.usoftchina.saas.document.mapper.VendorMapper;
 import com.usoftchina.saas.exception.BizException;
 import com.usoftchina.saas.money.mapper.*;
 import com.usoftchina.saas.money.po.*;
 import com.usoftchina.saas.money.service.RecbalanceService;
 import com.usoftchina.saas.page.PageRequest;
+import io.netty.util.internal.MathUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.util.StringUtils;
@@ -40,6 +47,10 @@ public class RecbalanceServiceImpl implements RecbalanceService {
     private BanksubledgerMapper banksubledgerMapper;
     @Autowired
     private SubledgerMapper subledgerMapper;
+    @Autowired
+    private CustomerMapper customerMapper;
+    @Autowired
+    private BankinformationMapper bankinformationMapper;
 
     @Override
     public DocBaseDTO insert(Rec rec) {
@@ -203,21 +214,81 @@ public class RecbalanceServiceImpl implements RecbalanceService {
             recbalanceMapper.updateByPrimaryKeySelective(recbalance);
         }
 
-        Recbalance updatePay = new Recbalance();
+        Recbalance updateRay = new Recbalance();
         List<Recbalancedet> recbalancedet = rec.getItems1();
         List<Recbalancedetail> recbalancedetail = rec.getItems2();
-        //更新主表付款金额:pb_pdamount=从表一金额合计
+        //更新主表付款金额:rb_rdamount=从表一金额合计
         Double amountTotal = new Double(0);
         for (Recbalancedet det: recbalancedet) {
             amountTotal = amountTotal + det.getRd_amount();
+            //更新账户资料金额
+            Bankinformation bankinformation = new Bankinformation();
+            Bankinformation nowBankInformation = bankinformationMapper.selectByPrimaryKey(det.getRd_bankid());
+            bankinformation.setBk_thisamount(nowBankInformation.getBk_thisamount()+det.getRd_amount());
+            bankinformationMapper.updateByPrimaryKeySelective(bankinformation);
+        }
+        //更新主表pb_pbdamount=从表二金额合计
+        Double amountTotal2 = new Double(0);
+        for (Recbalancedetail detail : recbalancedetail){
+            amountTotal2 = amountTotal2 + detail.getRbd_amount();
         }
-        updatePay.setId(rec.getMain().getId());
-        updatePay.setRb_rdamount(amountTotal);
-        //updateByPrimaryKeySelective
+        updateRay.setId(rec.getMain().getId());
+        updateRay.setRb_rdamount(amountTotal);
+        updateRay.setRb_rbdamount(amountTotal2);
+        recbalanceMapper.updateByPrimaryKeySelective(updateRay);
+        /**
+         * 更新客户资料
+         * cu_preamount=nvl(cu_preamount,0)+rb_preamount,
+         * cu_recamount=nvl(cu_recamount,0)-rb_rbdamount,
+         * cu_leftamount=cu_beginaramount-cu_beginprerecamount+cu_recamount-cu_preamount;
+         */
+        Customer customerData = customerMapper.selectByPrimaryKey(Long.valueOf(String.valueOf(recbalance.getRb_custid())));
+        Double preamount = customerData.getCu_preamount();
+        Double beginapamount = customerData.getCu_beginaramount();
+        Double beginprepayamount= customerData.getCu_beginprerecamount();
+        Double recamount = customerData.getCu_recamount();
+
+        Customer customer = new Customer();
+        customer.setId(Long.valueOf(String.valueOf(recbalance.getRb_custid())));
+        customer.setCu_preamount(preamount+amountTotal);
+        customer.setCu_recamount(recamount-amountTotal2);
+        customer.setCu_leftamount(beginapamount-beginprepayamount+recamount-amountTotal2-preamount-amountTotal);
+        customerMapper.updateByPrimaryKeySelective(customer);
     }
 
     @Override
     public void unAudit(Long id) {
+        //更新供应商资料
+        /**
+         * ve_preamount=nvl(ve_preamount,0)-pb_preamount,
+         * ve_payamount=nvl(ve_payamount,0)+pb_pbdamount,
+         * ve_leftamount=ve_beginapamount-ve_beginprepayamount+ve_payamount-ve_preamount;
+         */
+        Recbalance rec = recbalanceMapper.selectByPrimaryKey(Long.valueOf(id));
+        Double pay_preamount = rec.getRb_preamount();
+        Double pay_pbdamount = rec.getRb_rbdamount();
+        Customer customerData = customerMapper.selectByPrimaryKey(Long.valueOf(String.valueOf(rec.getRb_custid())));
+        Double preamount = customerData.getCu_preamount();
+        Double beginapamount = customerData.getCu_beginaramount();
+        Double beginprepayamount= customerData.getCu_beginprerecamount();
+        Double recamount = customerData.getCu_recamount();
+        Customer customer = new Customer();
+        customer.setId(Long.valueOf(String.valueOf(rec.getRb_custid())));
+        customer.setCu_preamount(preamount-pay_preamount);
+        customer.setCu_recamount(recamount+pay_pbdamount);
+        customer.setCu_leftamount(beginapamount-beginprepayamount+recamount+pay_pbdamount-preamount+pay_preamount);
+        customerMapper.updateByPrimaryKeySelective(customer);
+
+        //更新账户资料金额
+        List<Recbalancedet> recbalancedet = recbalancedetMapper.selectByPrimaryKey(Math.toIntExact(id));
+        for (Recbalancedet det:recbalancedet) {
+            Bankinformation bankinformation = new Bankinformation();
+            Bankinformation nowBankInformation = bankinformationMapper.selectByPrimaryKey(det.getRd_bankid());
+            bankinformation.setBk_thisamount(nowBankInformation.getBk_thisamount()-det.getRd_amount());
+            bankinformationMapper.updateByPrimaryKeySelective(bankinformation);
+        }
+
+
         Recbalance recbalance = new Recbalance();
         recbalance.setId(id);
         recbalance.setRb_status(Status.UNAUDITED.getDisplay());