Browse Source

Merge branch 'dev' of ssh://10.10.100.21/source/saas-platform into dev

zhuth 7 years ago
parent
commit
9f1ef711c4

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

@@ -94,6 +94,9 @@ public enum BizExceptionCode implements BaseExceptionCode {
     DOCUMENTS_UNAUDITED(74010,"存在未审核单据:%S"),
     BANK_AMOUNT_NOTENOUGHS(74011, "资金账号不足:%S"),
 
+    //反结账
+    EARLY_USERING(74012, "期初余额被使用,无法反结账"),
+
 
 
     //库存

+ 4 - 0
applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/mapper/EndProductMapper.java

@@ -17,4 +17,8 @@ public interface EndProductMapper {
     List<MessagelogDTO> getListData(@Param("condition") String condition, @Param("companyId") Long companyId);
 
     void updatePeriodStatus(@Param("status") Long status,@Param("period") String period, @Param("companyId") Long companyId);
+
+    int checkPay(Long companyId);
+    int checkRec(Long companyId);
+    void deleteSub(Long companyId);
 }

+ 8 - 0
applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/service/impl/EndProductServiceImpl.java

@@ -58,6 +58,7 @@ public class EndProductServiceImpl implements EndProductService {
     @Override
     public String endAccount() {
         String period = endProductMapper.selectPeriod(BaseContextHolder.getCompanyId());
+
         Map<String, Object> map = new HashMap<String, Object>();
         map.put("yearMonth", period);
         map.put("companyId", BaseContextHolder.getCompanyId());
@@ -71,6 +72,13 @@ public class EndProductServiceImpl implements EndProductService {
 
     @Override
     public void unEndAccount() {
+        int payc = endProductMapper.checkPay(BaseContextHolder.getCompanyId());
+        int recc = endProductMapper.checkRec(BaseContextHolder.getCompanyId());
+        if(payc !=0 || recc != 0){
+            throw new BizException(500, BizExceptionCode.EARLY_USERING.getMessage());
+        }
+        endProductMapper.deleteSub(BaseContextHolder.getCompanyId());
+
         String period = endProductMapper.selectUnPeriod(BaseContextHolder.getCompanyId());
         if (StringUtils.isEmpty(period)){
             throw new BizException(BizExceptionCode.BIZ_UNENDPRODUCT);

+ 86 - 0
applications/commons/commons-server/src/main/resources/mapper/EndProductMapper.xml

@@ -31,4 +31,90 @@
     <update id="updatePeriodStatus" >
         update periodsdetail set pd_status=#{status} where pd_detno=#{period} and companyId=#{companyId}
     </update>
+
+    <select id="checkPay" parameterType="java.lang.Long" resultType="java.lang.Integer">
+        select count(1) from vendor where (ve_id,companyid) in (select pb_vendid,companyid from (
+        select pbd_ym,pb_vendid,paybalance.companyid from paybalance,paybalancedetail where pb_id=pbd_pbid and pbd_slkind='期初余额'
+        union all select vd_ym,vc_vendid,verification.companyid from verification,verificationdet where vc_id=vd_vcid and vd_slkind='期初余额'
+        and ifnull(vc_vendid,0)!=0
+        union all select vcd_ym,vc_vendid,verification.companyid from verification,verificationdetail where vc_id=vcd_vcid and vcd_slkind='期初余额' and ifnull(vc_vendid,0)!=0
+        union all select vd_ym,vc_turnvendid,verification.companyid from verification,verificationdet where vc_id=vd_vcid and vd_slkind='期初余额' and ifnull(vc_turnvendid,0)!=0
+        )a where a.pbd_ym =(select min(pd_detno) from periodsdetail where pd_status=0 and companyId = #{companyId} )) ;
+    </select>
+
+    <select id="checkRec" parameterType="java.lang.Long" resultType="java.lang.Integer">
+        SELECT
+        count(1)
+        FROM
+        customer
+        WHERE
+        (cu_id, companyid) IN (
+        SELECT
+        rb_custid,
+        companyid
+        FROM
+        (
+        SELECT
+        rbd_ym,
+        rb_custid,
+        recbalance.companyid
+        FROM
+        recbalance,
+        recbalancedetail
+        WHERE
+        rb_id = rbd_rbid
+        AND rbd_slkind = '期初余额'
+        UNION ALL
+        SELECT
+        vd_ym,
+        vc_custid,
+        verification.companyid
+        FROM
+        verification,
+        verificationdet
+        WHERE
+        vc_id = vd_vcid
+        AND vd_slkind = '期初余额'
+        AND ifnull(vc_custid, 0) != 0
+        UNION ALL
+        SELECT
+        vcd_ym,
+        vc_custid,
+        verification.companyid
+        FROM
+        verification,
+        verificationdetail
+        WHERE
+        vc_id = vcd_vcid
+        AND vcd_slkind = '期初余额'
+        AND ifnull(vc_custid, 0) != 0
+        UNION ALL
+        SELECT
+        vd_ym,
+        vc_turncustid,
+        verification.companyid
+        FROM
+        verification,
+        verificationdet
+        WHERE
+        vc_id = vd_vcid
+        AND vd_slkind = '期初余额'
+        AND ifnull(vc_turncustid, 0) != 0
+        ) a
+        WHERE
+        a.rbd_ym = (
+        SELECT
+        min(pd_detno)
+        FROM
+        periodsdetail
+        WHERE
+        pd_status = 0 and companyid = #{companyId}
+        )
+        )
+    </select>
+
+    <delete id="deleteSub" parameterType="java.lang.Long" >
+    DELETE from subledger where sl_ym =
+    (select min(pd_detno) from periodsdetail where pd_status=0 and companyid=#{companyId}) and companyid = #{companyId}
+  </delete>
 </mapper>

+ 3 - 0
applications/money/money-server/src/main/resources/application.yml

@@ -69,5 +69,8 @@ info:
 mybatis:
   type-aliases-package: com.usoftchina.saas.money.po
   mapper-locations: classpath:mapper/*.xml
+logging:
+  level:
+     com.usoftchina.saas.money.mapper : debug
 auth:
   public-key: auth/pub.key