Browse Source

1.添加期间单据计算

heqinwei 7 years ago
parent
commit
ac483f02e0
20 changed files with 384 additions and 17 deletions
  1. 3 0
      applications/commons/commons-dto/src/main/java/com/usoftchina/saas/commons/exception/BizExceptionCode.java
  2. 2 0
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/mapper/OthreceiptsdetailMapper.java
  3. 1 0
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/mapper/OthspendingsdetailMapper.java
  4. 4 0
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/mapper/PaybalanceMapper.java
  5. 1 0
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/mapper/PaybalancedetMapper.java
  6. 1 0
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/mapper/RecbalancedetMapper.java
  7. 14 0
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/mapper/StatsinfoMapper.java
  8. 71 0
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/po/Statsinfo.java
  9. 27 4
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/service/impl/FundtransferServiceImpl.java
  10. 33 4
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/service/impl/OthreceiptsServiceImpl.java
  11. 34 4
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/service/impl/OthspendingsServiceImpl.java
  12. 30 1
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/service/impl/PaybalanceServiceImpl.java
  13. 32 0
      applications/money/money-server/src/main/java/com/usoftchina/saas/money/service/impl/RecbalanceServiceImpl.java
  14. 2 2
      applications/money/money-server/src/main/resources/mapper/OthreceiptsMapper.xml
  15. 4 0
      applications/money/money-server/src/main/resources/mapper/OthreceiptsdetailMapper.xml
  16. 4 0
      applications/money/money-server/src/main/resources/mapper/OthspendingsdetailMapper.xml
  17. 11 2
      applications/money/money-server/src/main/resources/mapper/PaybalanceMapper.xml
  18. 4 0
      applications/money/money-server/src/main/resources/mapper/PaybalancedetMapper.xml
  19. 3 0
      applications/money/money-server/src/main/resources/mapper/RecbalancedetMapper.xml
  20. 103 0
      applications/money/money-server/src/main/resources/mapper/StatsinfoMapper.xml

+ 3 - 0
applications/commons/commons-dto/src/main/java/com/usoftchina/saas/commons/exception/BizExceptionCode.java

@@ -37,6 +37,7 @@ public enum BizExceptionCode implements BaseExceptionCode {
     ILLEGAL_ID(79999, "id不正确"),
     PRODUCT_HAS_WAREHOUSE(79502, "存在物料默认仓库资料为该仓库资料,无法删除"),
     PRODUCTWH_HAS_WAREHOUSE(79503, "该仓库资料存在库存,无法删除"),
+    ACCOUNT_EXISTS(79503, "账号已存在"),
 
 
 
@@ -61,6 +62,8 @@ public enum BizExceptionCode implements BaseExceptionCode {
 
     RECALANCE_OUTNOWBALANCE(74003,"本次核销金额不能大于未核销金额"),
 
+    BANK_AMOUNT_NOTENOUGH(74004, "资金账号不足"),
+
 
 
     //库存

+ 2 - 0
applications/money/money-server/src/main/java/com/usoftchina/saas/money/mapper/OthreceiptsdetailMapper.java

@@ -17,4 +17,6 @@ public interface OthreceiptsdetailMapper {
     int updateByPrimaryKeySelective(Othreceiptsdetail record);
 
     int updateByPrimaryKey(Othreceiptsdetail record);
+
+    List<Integer> selectYm(Integer id);
 }

+ 1 - 0
applications/money/money-server/src/main/java/com/usoftchina/saas/money/mapper/OthspendingsdetailMapper.java

@@ -17,4 +17,5 @@ public interface OthspendingsdetailMapper {
     int updateByPrimaryKeySelective(Othspendingsdetail record);
 
     int updateByPrimaryKey(Othspendingsdetail record);
+    List<Integer> selectYm(Integer id);
 }

+ 4 - 0
applications/money/money-server/src/main/java/com/usoftchina/saas/money/mapper/PaybalanceMapper.java

@@ -38,4 +38,8 @@ public interface PaybalanceMapper extends CommonBaseMapper<Paybalance> {
     Vendor selectVendorByPrimaryKey(Integer bkId);
 
     int updateVendorByPrimaryKeySelective(Vendor record);
+
+    Double selectThisamount(Integer id);
+
+    void updateBankAmount(@Param("bk_thisamount") Double bk_thisamount, @Param("id") Integer id);
 }

+ 1 - 0
applications/money/money-server/src/main/java/com/usoftchina/saas/money/mapper/PaybalancedetMapper.java

@@ -19,5 +19,6 @@ public interface PaybalancedetMapper {
     int updateByPrimaryKeySelective(Paybalancedet record);
 
     int updateByPrimaryKey(Paybalancedet record);
+    List<Integer> selectYm(Integer id);
 
 }

+ 1 - 0
applications/money/money-server/src/main/java/com/usoftchina/saas/money/mapper/RecbalancedetMapper.java

@@ -23,4 +23,5 @@ public interface RecbalancedetMapper extends CommonBaseMapper<Recbalancedet> {
     int updateByPrimaryKeySelective(Recbalancedet record);
 
     int updateByPrimaryKey(Recbalancedet record);
+    List<Integer> selectYm(Integer id);
 }

+ 14 - 0
applications/money/money-server/src/main/java/com/usoftchina/saas/money/mapper/StatsinfoMapper.java

@@ -0,0 +1,14 @@
+package com.usoftchina.saas.money.mapper;
+
+import com.usoftchina.saas.money.po.Statsinfo;
+import org.apache.ibatis.annotations.Param;
+
+/**
+ * @author heqw
+ * @date 2018/11/14 16:13
+ **/
+public interface StatsinfoMapper {
+    Integer select(@Param("si_yearmonth") Integer si_yearmonth, @Param("companyid") Long companyid);
+    void update(Statsinfo statsinfo);
+    void insert(Statsinfo statsinfo);
+}

+ 71 - 0
applications/money/money-server/src/main/java/com/usoftchina/saas/money/po/Statsinfo.java

@@ -0,0 +1,71 @@
+package com.usoftchina.saas.money.po;
+
+/**
+ * @author heqw
+ * @date 2018/11/14 16:02
+ **/
+public class Statsinfo {
+    private Double si_yearmonth;
+    private Double si_amount_pay;
+    private Double si_amount_otherpay;
+    private Double si_amount_rec;
+    private Double si_amount_otherrec;
+    private Long companyid;
+    private String si_type;
+
+    public Double getSi_yearmonth() {
+        return si_yearmonth;
+    }
+
+    public void setSi_yearmonth(Double si_yearmonth) {
+        this.si_yearmonth = si_yearmonth;
+    }
+
+    public Double getSi_amount_pay() {
+        return si_amount_pay;
+    }
+
+    public void setSi_amount_pay(Double si_amount_pay) {
+        this.si_amount_pay = si_amount_pay;
+    }
+
+    public Double getSi_amount_otherpay() {
+        return si_amount_otherpay;
+    }
+
+    public void setSi_amount_otherpay(Double si_amount_otherpay) {
+        this.si_amount_otherpay = si_amount_otherpay;
+    }
+
+    public Double getSi_amount_rec() {
+        return si_amount_rec;
+    }
+
+    public void setSi_amount_rec(Double si_amount_rec) {
+        this.si_amount_rec = si_amount_rec;
+    }
+
+    public Double getSi_amount_otherrec() {
+        return si_amount_otherrec;
+    }
+
+    public void setSi_amount_otherrec(Double si_amount_otherrec) {
+        this.si_amount_otherrec = si_amount_otherrec;
+    }
+
+    public Long getCompanyid() {
+        return companyid;
+    }
+
+    public void setCompanyid(Long companyid) {
+        this.companyid = companyid;
+    }
+
+    public String getSi_type() {
+        return si_type;
+    }
+
+    public void setSi_type(String si_type) {
+        this.si_type = si_type;
+    }
+}

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

@@ -11,9 +11,7 @@ import com.usoftchina.saas.commons.po.BillCodeSeq;
 import com.usoftchina.saas.commons.po.Status;
 import com.usoftchina.saas.context.BaseContextHolder;
 import com.usoftchina.saas.exception.BizException;
-import com.usoftchina.saas.money.mapper.BanksubledgerMapper;
-import com.usoftchina.saas.money.mapper.FundtransferMapper;
-import com.usoftchina.saas.money.mapper.FundtransferdetailMapper;
+import com.usoftchina.saas.money.mapper.*;
 import com.usoftchina.saas.money.po.*;
 import com.usoftchina.saas.money.service.FundtransferService;
 import com.usoftchina.saas.page.PageRequest;
@@ -38,6 +36,8 @@ public class FundtransferServiceImpl implements FundtransferService {
     private MaxnumberService maxnumberService;
     @Autowired
     private BanksubledgerMapper banksubledgerMapper;
+    @Autowired
+    private PaybalanceMapper paybalanceMapper;
 
     @Override
     public DocBaseDTO insert(Fundtran fundtran) {
@@ -101,17 +101,32 @@ public class FundtransferServiceImpl implements FundtransferService {
             }
         }
 
-        //取从表金额
+        //取从表金额更新中间表、资金账号表
         List<Fundtransferdetail> fundtransferdetailList = fundtran.getItems();
         Iterator isList = fundtransferdetailList.iterator();
         while (isList.hasNext()){
             Fundtransferdetail fundtransferdetail = (Fundtransferdetail) isList.next();
             Double amount = banksubledgerMapper.selectThisamount(fundtransferdetail.getFtd_bankcode());
             Double inamount = banksubledgerMapper.selectThisamount(fundtransferdetail.getFtd_inbankcode());
+
+            //中间表
             banksubledgerMapper.updateBankcode(amount, fundtransferdetail.getFtd_nowbalance(),
                     fundtransferdetail.getFtd_bankcode(), "-");
             banksubledgerMapper.updateBankcode(inamount, fundtransferdetail.getFtd_nowbalance(),
                     fundtransferdetail.getFtd_bankcode(), "+");
+
+            //资金账号表
+            int bk_id = fundtransferdetail.getFtd_bankid();
+            int bk_inid = fundtransferdetail.getFtd_inbankid();
+            Double bk_amount = paybalanceMapper.selectThisamount(bk_id) == null ? new Double(0) : paybalanceMapper.selectThisamount(bk_id);
+            Double bk_inamount = paybalanceMapper.selectThisamount(bk_inid) == null ? new Double(0) : paybalanceMapper.selectThisamount(bk_inid);
+
+            Double thisamount = bk_amount - fundtransferdetail.getFtd_nowbalance();
+            if (thisamount < 0){
+                throw new BizException(500, BizExceptionCode.BANK_AMOUNT_NOTENOUGH.getMessage());
+            }
+            paybalanceMapper.updateBankAmount(thisamount, bk_id);
+            paybalanceMapper.updateBankAmount(bk_inamount + fundtransferdetail.getFtd_nowbalance(), bk_inid);
         }
     }
 
@@ -139,6 +154,14 @@ public class FundtransferServiceImpl implements FundtransferService {
                     fundtransferdetail.getFtd_bankcode(), "+");
             banksubledgerMapper.updateBankcode(inamount, fundtransferdetail.getFtd_nowbalance(),
                     fundtransferdetail.getFtd_bankcode(), "-");
+
+            //资金账号表
+            int bk_id = fundtransferdetail.getFtd_bankid();
+            int bk_inid = fundtransferdetail.getFtd_inbankid();
+            Double bk_amount = paybalanceMapper.selectThisamount(bk_id) == null ? new Double(0) : paybalanceMapper.selectThisamount(bk_id);
+            Double bk_inamount = paybalanceMapper.selectThisamount(bk_inid) == null ? new Double(0) : paybalanceMapper.selectThisamount(bk_inid);
+            paybalanceMapper.updateBankAmount(bk_amount + fundtransferdetail.getFtd_nowbalance(), bk_id);
+            paybalanceMapper.updateBankAmount(bk_inamount - fundtransferdetail.getFtd_nowbalance(), bk_inid);
         }
     }
 

+ 33 - 4
applications/money/money-server/src/main/java/com/usoftchina/saas/money/service/impl/OthreceiptsServiceImpl.java

@@ -14,10 +14,8 @@ import com.usoftchina.saas.exception.BizException;
 import com.usoftchina.saas.money.mapper.BanksubledgerMapper;
 import com.usoftchina.saas.money.mapper.OthreceiptsMapper;
 import com.usoftchina.saas.money.mapper.OthreceiptsdetailMapper;
-import com.usoftchina.saas.money.po.Banksubledger;
-import com.usoftchina.saas.money.po.Othreceipts;
-import com.usoftchina.saas.money.po.Othreceiptsdetail;
-import com.usoftchina.saas.money.po.Othte;
+import com.usoftchina.saas.money.mapper.StatsinfoMapper;
+import com.usoftchina.saas.money.po.*;
 import com.usoftchina.saas.money.service.OthreceiptsService;
 import com.usoftchina.saas.page.PageRequest;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -42,6 +40,8 @@ public class OthreceiptsServiceImpl implements OthreceiptsService {
     private MaxnumberService maxnumberService;
     @Autowired
     private BanksubledgerMapper banksubledgerMapper;
+    @Autowired
+    private StatsinfoMapper statsinfoMapper;
 
     @Override
     public DocBaseDTO insert(Othte othte) {
@@ -114,6 +114,21 @@ public class OthreceiptsServiceImpl implements OthreceiptsService {
             banksubledgerMapper.updateBankcode(amount, othreceiptsdetail.getOrd_nowbalance(),
                     othreceipts.getOr_bankcode(), "+");
         }
+
+        //计算期间金额
+        Statsinfo statsinfo = new Statsinfo();
+        List<Integer> ymList = othreceiptsdetailMapper.selectYm(id);
+        Integer ym = ymList.indexOf(0);
+        System.out.println("ym:"+ym);
+        statsinfo.setCompanyid(BaseContextHolder.getCompanyId());
+        Integer yms = statsinfoMapper.select(ym, BaseContextHolder.getCompanyId());
+        statsinfo.setSi_yearmonth(Double.valueOf(ym));
+        statsinfo.setSi_amount_otherrec(othreceipts.getOr_amount());
+        if (yms == null){
+            statsinfoMapper.insert(statsinfo);
+        }else {
+            statsinfoMapper.update(statsinfo);
+        }
     }
 
     @Override
@@ -138,6 +153,20 @@ public class OthreceiptsServiceImpl implements OthreceiptsService {
                     othreceipts.getOr_bankcode(), "-");
         }
 
+        //计算期间金额
+        Statsinfo statsinfo = new Statsinfo();
+        List<Integer> ymList = othreceiptsdetailMapper.selectYm(id);
+        Integer ym = ymList.indexOf(0);
+        statsinfo.setCompanyid(BaseContextHolder.getCompanyId());
+        Integer yms = statsinfoMapper.select(ym, BaseContextHolder.getCompanyId());
+        statsinfo.setSi_yearmonth(Double.valueOf(ym));
+        statsinfo.setSi_amount_otherrec(othreceipts.getOr_amount());
+        if (yms == null){
+            statsinfoMapper.insert(statsinfo);
+        }else {
+            statsinfoMapper.update(statsinfo);
+        }
+
     }
 
 

+ 34 - 4
applications/money/money-server/src/main/java/com/usoftchina/saas/money/service/impl/OthspendingsServiceImpl.java

@@ -14,10 +14,8 @@ import com.usoftchina.saas.exception.BizException;
 import com.usoftchina.saas.money.mapper.BanksubledgerMapper;
 import com.usoftchina.saas.money.mapper.OthspendingsMapper;
 import com.usoftchina.saas.money.mapper.OthspendingsdetailMapper;
-import com.usoftchina.saas.money.po.Banksubledger;
-import com.usoftchina.saas.money.po.Othsp;
-import com.usoftchina.saas.money.po.Othspendings;
-import com.usoftchina.saas.money.po.Othspendingsdetail;
+import com.usoftchina.saas.money.mapper.StatsinfoMapper;
+import com.usoftchina.saas.money.po.*;
 import com.usoftchina.saas.money.service.OthspendingsService;
 import com.usoftchina.saas.page.PageRequest;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -41,6 +39,8 @@ public class OthspendingsServiceImpl implements OthspendingsService {
     private MaxnumberService maxnumberService;
     @Autowired
     private BanksubledgerMapper banksubledgerMapper;
+    @Autowired
+    private StatsinfoMapper statsinfoMapper;
 
     @Override
     public DocBaseDTO insert(Othsp othsp) {
@@ -146,6 +146,21 @@ public class OthspendingsServiceImpl implements OthspendingsService {
             banksubledgerMapper.updateBankcode(amount, othspendingsdetail.getOsd_nowbalance(),
                     othspendings.getOs_bankcode(), "+");
         }
+
+        //计算期间金额
+        Statsinfo statsinfo = new Statsinfo();
+        List<Integer> ymList = othspendingsdetailMapper.selectYm(id);
+        Integer ym = ymList.indexOf(0);
+        System.out.println("ym:"+ym);
+        statsinfo.setCompanyid(BaseContextHolder.getCompanyId());
+        Integer yms = statsinfoMapper.select(ym, BaseContextHolder.getCompanyId());
+        statsinfo.setSi_yearmonth(Double.valueOf(ym));
+        statsinfo.setSi_amount_otherpay(othspendings.getOs_amount());
+        if (yms == null){
+            statsinfoMapper.insert(statsinfo);
+        }else {
+            statsinfoMapper.update(statsinfo);
+        }
     }
 
     @Override
@@ -170,6 +185,21 @@ public class OthspendingsServiceImpl implements OthspendingsService {
             banksubledgerMapper.updateBankcode(amount, othspendingsdetail.getOsd_nowbalance(),
                     othspendings.getOs_bankcode(), "-");
         }
+
+        //计算期间金额
+        Statsinfo statsinfo = new Statsinfo();
+        List<Integer> ymList = othspendingsdetailMapper.selectYm(id);
+        Integer ym = ymList.indexOf(0);
+        System.out.println("ym:"+ym);
+        statsinfo.setCompanyid(BaseContextHolder.getCompanyId());
+        Integer yms = statsinfoMapper.select(ym, BaseContextHolder.getCompanyId());
+        statsinfo.setSi_yearmonth(Double.valueOf(ym));
+        statsinfo.setSi_amount_otherpay(othspendings.getOs_amount());
+        if (yms == null){
+            statsinfoMapper.insert(statsinfo);
+        }else {
+            statsinfoMapper.update(statsinfo);
+        }
     }
 
     @Override

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

@@ -40,6 +40,8 @@ public class PaybalanceServiceImpl implements PaybalanceService {
     private SubledgerMapper subledgerMapper;
     @Autowired
     private BanksubledgerMapper banksubledgerMapper;
+    @Autowired
+    private StatsinfoMapper statsinfoMapper;
 
     public DocBaseDTO insert(Pay pay) {
         Paybalance paybalance = pay.getMain();
@@ -243,6 +245,20 @@ public class PaybalanceServiceImpl implements PaybalanceService {
             subledgerMapper.updateByPrimaryKeySelective(subledger1);
         }
 
+        //计算期间金额
+        Statsinfo statsinfo = new Statsinfo();
+        List<Integer> ymList = paybalancedetMapper.selectYm(id);
+        Integer ym = ymList.indexOf(0);
+        System.out.println("ym:"+ym);
+        statsinfo.setCompanyid(BaseContextHolder.getCompanyId());
+        Integer yms = statsinfoMapper.select(ym, BaseContextHolder.getCompanyId());
+        statsinfo.setSi_yearmonth(Double.valueOf(ym));
+        statsinfo.setSi_amount_pay(100.0);
+        if (yms == null){
+            statsinfoMapper.insert(statsinfo);
+        }else {
+            statsinfoMapper.update(statsinfo);
+        }
     }
 
     @Override
@@ -308,7 +324,20 @@ public class PaybalanceServiceImpl implements PaybalanceService {
         subledgerMapper.deleteByPrimaryKey(paybalance.getPb_code(), paybalance.getPb_kind());
         banksubledgerMapper.deleteByPrimaryKey(paybalance.getPb_code(), paybalance.getPb_kind());
 
-
+        //计算期间金额
+        Statsinfo statsinfo = new Statsinfo();
+        List<Integer> ymList = paybalancedetMapper.selectYm(id);
+        Integer ym = ymList.indexOf(0);
+        System.out.println("ym:"+ym);
+        statsinfo.setCompanyid(BaseContextHolder.getCompanyId());
+        Integer yms = statsinfoMapper.select(ym, BaseContextHolder.getCompanyId());
+        statsinfo.setSi_yearmonth(Double.valueOf(ym));
+        statsinfo.setSi_amount_pay(100.0);
+        if (yms == null){
+            statsinfoMapper.insert(statsinfo);
+        }else {
+            statsinfoMapper.update(statsinfo);
+        }
     }
 
 

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

@@ -40,6 +40,8 @@ public class RecbalanceServiceImpl implements RecbalanceService {
     private BanksubledgerMapper banksubledgerMapper;
     @Autowired
     private SubledgerMapper subledgerMapper;
+    @Autowired
+    private StatsinfoMapper statsinfoMapper;
 
     @Override
     public DocBaseDTO insert(Rec rec) {
@@ -269,6 +271,21 @@ public class RecbalanceServiceImpl implements RecbalanceService {
             subledger1.setSl_namount(namount-nowBalance);//未核销
             subledgerMapper.updateByPrimaryKeySelective(subledger1);
         }
+
+        //计算期间金额
+        Statsinfo statsinfo = new Statsinfo();
+        List<Integer> ymList = recbalancedetMapper.selectYm(id);
+        Integer ym = ymList.indexOf(0);
+        System.out.println("ym:"+ym);
+        statsinfo.setCompanyid(BaseContextHolder.getCompanyId());
+        Integer yms = statsinfoMapper.select(ym, BaseContextHolder.getCompanyId());
+        statsinfo.setSi_yearmonth(Double.valueOf(ym));
+        statsinfo.setSi_amount_rec(100.0);
+        if (yms == null){
+            statsinfoMapper.insert(statsinfo);
+        }else {
+            statsinfoMapper.update(statsinfo);
+        }
     }
 
     @Override
@@ -334,6 +351,21 @@ public class RecbalanceServiceImpl implements RecbalanceService {
             subledger1.setSl_namount(namount+nowBalance);//未核销
             subledgerMapper.updateByPrimaryKeySelective(subledger1);
         }
+
+        //计算期间金额
+        Statsinfo statsinfo = new Statsinfo();
+        List<Integer> ymList = recbalancedetMapper.selectYm(Math.toIntExact(id));
+        Integer ym = ymList.indexOf(0);
+        System.out.println("ym:"+ym);
+        statsinfo.setCompanyid(BaseContextHolder.getCompanyId());
+        Integer yms = statsinfoMapper.select(ym, BaseContextHolder.getCompanyId());
+        statsinfo.setSi_yearmonth(Double.valueOf(ym));
+        statsinfo.setSi_amount_rec(100.0);
+        if (yms == null){
+            statsinfoMapper.insert(statsinfo);
+        }else {
+            statsinfoMapper.update(statsinfo);
+        }
     }
 
     public PageInfo<Recbalance> selectList(PageRequest page, ListReqDTO reqDTO) {

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

@@ -324,7 +324,7 @@
         ${con}
       </if>
       <if test="companyId != null">
-        and   othreceipts.companyId = #{companyId}
+        and   othreceipts.companyId = #{companyId, jdbcType=INTEGER}
       </if>
     </where>  order by or_date desc
   </select>
@@ -339,7 +339,7 @@
         ${con}
       </if>
       <if test="companyId != null">
-        and   othreceipts.companyId = #{companyId}
+        and   othreceipts.companyId = #{companyId, jdbcType=INTEGER}
       </if>
     </where>  order by or_date desc
   </select>

+ 4 - 0
applications/money/money-server/src/main/resources/mapper/OthreceiptsdetailMapper.xml

@@ -207,4 +207,8 @@
       ord_text5 = #{ordText5,jdbcType=VARCHAR}
     where ord_id = #{ordId,jdbcType=INTEGER}
   </update>
+
+  <select id="selectYm" parameterType="java.lang.Integer" resultType="java.lang.Integer">
+    select ord_ym from othreceiptsdetail where ord_orid = #{id,jdbcType=INTEGER}
+  </select>
 </mapper>

+ 4 - 0
applications/money/money-server/src/main/resources/mapper/OthspendingsdetailMapper.xml

@@ -213,4 +213,8 @@
       osd_text5 = #{osdText5,jdbcType=VARCHAR}
     where osd_id = #{osdId,jdbcType=INTEGER}
   </update>
+
+  <select id="selectYm" parameterType="java.lang.Integer" resultType="java.lang.Integer">
+    select osd_ym from othspendingsdetail where osd_orid = #{id,jdbcType=INTEGER}
+  </select>
 </mapper>

+ 11 - 2
applications/money/money-server/src/main/resources/mapper/PaybalanceMapper.xml

@@ -428,7 +428,7 @@
       <if test="companyId != null">
         and   paybalance.companyId = #{companyId}
       </if>
-    </where>  order by pb_id
+    </where>  order by pb_date desc, order by pb_code
   </select>
 
   <select id="selectPaybalanceListByCondition" resultMap="BaseResultMap">
@@ -443,7 +443,7 @@
       <if test="companyId != null">
         and   paybalance.companyId = #{companyId}
       </if>
-    </where>  order by pb_id
+    </where>  order by pb_date desc, order by pb_code
   </select>
 
   <select id="validateCodeWhenInsert" resultType="int">
@@ -576,6 +576,15 @@
     where bk_id = #{id,jdbcType=INTEGER}
   </update>
 
+  <update id="updateBankAmount" >
+    update bankinformation set bk_thisamount = #{bk_thisamount,jdbcType=DOUBLE}
+     where bk_id = #{id,jdbcType=INTEGER}
+  </update>
+
+<select id="selectThisamount" parameterType="java.lang.Integer" resultType="java.lang.Double">
+  select bk_thisamount from bankinformation where bk_id = #{id,jdbcType=INTEGER}
+</select>
+
 <!-- 供应商-->
   <resultMap id="VendorResultMapper" type="com.usoftchina.saas.money.po.Vendor">
     <id column="ve_id" property="id" jdbcType="INTEGER" />

+ 4 - 0
applications/money/money-server/src/main/resources/mapper/PaybalancedetMapper.xml

@@ -287,4 +287,8 @@
       </if>
     </where>  order by pb_id
   </select>
+
+  <select id="selectYm" parameterType="java.lang.Integer" resultType="java.lang.Integer">
+    select pd_ym from paybalancedet where pd_pbid = #{id,jdbcType=INTEGER}
+  </select>
 </mapper>

+ 3 - 0
applications/money/money-server/src/main/resources/mapper/RecbalancedetMapper.xml

@@ -294,4 +294,7 @@
     where rd_id = #{id,jdbcType=INTEGER}
   </update>
 
+  <select id="selectYm" parameterType="java.lang.Integer" resultType="java.lang.Integer">
+    select rd_ym from recbalancedet where rd_rbid = #{id,jdbcType=INTEGER}
+  </select>
 </mapper>

+ 103 - 0
applications/money/money-server/src/main/resources/mapper/StatsinfoMapper.xml

@@ -0,0 +1,103 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
+<mapper namespace="com.usoftchina.saas.money.mapper.StatsinfoMapper" >
+    <resultMap id="BaseResultMap" type="com.usoftchina.saas.money.po.Statsinfo">
+        <result column="si_yearmonth" jdbcType="DOUBLE" property="si_yearmonth" />
+        <result column="si_amount_pay" jdbcType="DOUBLE" property="si_amount_pay" />
+        <result column="si_amount_otherpay" jdbcType="DOUBLE" property="si_amount_otherpay" />
+        <result column="si_amount_rec" jdbcType="DOUBLE" property="si_amount_rec" />
+        <result column="si_amount_otherrec" jdbcType="DOUBLE" property="si_amount_otherrec" />
+        <result column="companyid" jdbcType="INTEGER" property="companyid" />
+        <result column="si_type" jdbcType="VARCHAR" property="si_type" />
+    </resultMap>
+
+    <insert id="insert" parameterType="com.usoftchina.saas.money.po.Statsinfo">
+        insert into statsinfo
+        <trim prefix="(" suffix=")" suffixOverrides="," >
+        <if test="si_yearmonth != null" >
+            si_yearmonth,
+        </if>
+        <if test="si_amount_pay != null" >
+            si_amount_pay,
+        </if>
+        <if test="si_amount_otherpay != null" >
+            si_amount_otherpay,
+        </if>
+        <if test="si_amount_rec != null" >
+            si_amount_rec,
+        </if>
+        <if test="si_amount_otherrec != null" >
+            si_amount_otherrec,
+        </if>
+        <if test="companyid != null" >
+            companyid,
+        </if>
+            si_type,
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides="," >
+            <if test="si_yearmonth != null" >
+                #{si_yearmonth,jdbcType=INTEGER},
+            </if>
+            <if test="si_amount_pay != null" >
+                select sum(pd_amount) from paybalancedet left join paybalance on pd_pbid=pb_id
+                where paybalance.companyId= #{companyid,jdbcType=INTEGER}
+                and pd_ym=#{si_yearmonth,jdbcType=INTEGER} and pb_statuscode='AUDITED',
+            </if>
+            <if test="si_amount_otherpay != null" >
+                (select sum(os_amount) from othspendings RIGHT JOIN othspendingsdetail on os_id = osd_orid
+                where othspendingsdetail.companyId=#{companyid,jdbcType=INTEGER}
+                and osd_ym=#{si_yearmonth,jdbcType=INTEGER} and os_statuscode='AUDITED'),
+            </if>
+            <if test="si_amount_rec != null" >
+                (select sum(rd_amount) from recbalancedet left join recbalance on rd_rbid=rb_id
+                where recbalancedet.companyId=#{companyid,jdbcType=INTEGER}
+                and rd_ym=#{si_yearmonth,jdbcType=INTEGER} and rb_statuscode='AUDITED'),
+            </if>
+            <if test="si_amount_otherrec != null" >
+                (select  sum(or_amount) from othreceipts RIGHT JOIN othreceiptsdetail on or_id = ord_orid
+                where othreceiptsdetail.companyId=#{companyid,jdbcType=INTEGER}
+                and ord_ym=#{si_yearmonth,jdbcType=INTEGER} and or_statuscode='AUDITED'),
+            </if>
+            <if test="companyid != null" >
+                #{companyid,jdbcType=INTEGER},
+            </if>
+                'FUND',
+        </trim>
+    </insert>
+
+    <update id="update" parameterType="com.usoftchina.saas.money.po.Statsinfo" >
+        update statsinfo
+        <set >
+            <if test="si_amount_pay != null" >
+                si_amount_pay =
+                (select sum(pd_amount) from paybalancedet left join paybalance on pd_pbid=pb_id
+                where paybalance.companyId= #{companyid,jdbcType=INTEGER}
+                and pd_ym=#{si_yearmonth,jdbcType=INTEGER} and pb_statuscode='AUDITED'),
+            </if>
+            <if test="si_amount_otherpay != null" >
+                si_amount_otherpay =
+                (select sum(os_amount) from othspendings RIGHT JOIN othspendingsdetail on os_id = osd_orid
+                where othspendingsdetail.companyId=#{companyid,jdbcType=INTEGER}
+                and osd_ym=#{si_yearmonth,jdbcType=INTEGER} and os_statuscode='AUDITED'),
+            </if>
+            <if test="si_amount_rec != null" >
+                si_amount_rec =
+                (select sum(rd_amount) from recbalancedet left join recbalance on rd_rbid=rb_id
+                where recbalancedet.companyId=#{companyid,jdbcType=INTEGER}
+                and rd_ym=#{si_yearmonth,jdbcType=INTEGER} and rb_statuscode='AUDITED'),
+            </if>
+            <if test="si_amount_otherrec != null" >
+                si_amount_otherrec =
+                (select  sum(or_amount) from othreceipts RIGHT JOIN othreceiptsdetail on or_id = ord_orid
+                where othreceiptsdetail.companyId=#{companyid,jdbcType=INTEGER}
+                and ord_ym=#{si_yearmonth,jdbcType=INTEGER} and or_statuscode='AUDITED'),
+            </if>
+        </set>
+        where si_yearmonth = #{si_yearmonth,jdbcType=INTEGER} and companyid = #{companyid,jdbcType=INTEGER}
+        and si_type = 'FUND'
+    </update>
+
+    <select id="select" resultType="java.lang.Integer">
+        select DISTINCT si_yearmonth from statsinfo where si_yearmonth =#{si_yearmonth,jdbcType=INTEGER} and companyid = #{companyid,jdbcType=INTEGER}
+    </select>
+</mapper>