2 Commits 478f4ea80b ... ca0f4ec81e

Author SHA1 Message Date
  liutao ca0f4ec81e Merge remote-tracking branch 'origin/smb' into smb 1 month ago
  liutao d0505503b4 fix(苏商银行):字典类 1 month ago

+ 43 - 0
src/main/java/com/sunxung/factoring/component/enums/SmbCreditStatusEnum.java

@@ -0,0 +1,43 @@
+package com.sunxung.factoring.component.enums;
+
+public enum SmbCreditStatusEnum {
+
+
+    STATUS_01("smb_01","待审批"),
+
+    STATUS_02("smb_02","审批中"),
+
+    STATUS_03("smb_03","审批通过"),
+
+    STATUS_04("smb_04","审批拒绝"),
+
+    STATUS_06("smb_06","已归档"),
+    STATUS_07("smb_07","处理中"),
+    STATUS_11("smb_11","运营岗审核"),
+    STATUS_12("smb_12","已过期");
+    String code;
+
+    String desc;
+
+    SmbCreditStatusEnum(String code, String desc){
+        this.code = code;
+        this.desc = desc;
+    }
+
+    public static SmbCreditStatusEnum getByCode(String code){
+        for(SmbCreditStatusEnum ft:values()){
+            if(ft.code.equals(code)){
+                return ft;
+            }
+        }
+        return null;
+    }
+
+    public String getCode() {
+        return code;
+    }
+
+    public String getDesc() {
+        return desc;
+    }
+}

+ 34 - 0
src/main/java/com/sunxung/factoring/component/enums/SmbLimitStatusEnum.java

@@ -0,0 +1,34 @@
+package com.sunxung.factoring.component.enums;
+
+public enum SmbLimitStatusEnum {
+
+    LIMIT_STATUS_001("smb_limit_001","未激活"),
+    LIMIT_STATUS_002("smb_limit_002","生效"),
+    LIMIT_STATUS_004("smb_limit_004","冻结"),
+    LIMIT_STATUS_005("smb_limit_005","失效");
+    String code;
+
+    String desc;
+
+    SmbLimitStatusEnum(String code, String desc){
+        this.code = code;
+        this.desc = desc;
+    }
+
+    public static SmbLimitStatusEnum getByCode(String code){
+        for(SmbLimitStatusEnum ft:values()){
+            if(ft.code.equals(code)){
+                return ft;
+            }
+        }
+        return null;
+    }
+
+    public String getCode() {
+        return code;
+    }
+
+    public String getDesc() {
+        return desc;
+    }
+}

+ 33 - 0
src/main/java/com/sunxung/factoring/job/impl/SmbTaskJob.java

@@ -0,0 +1,33 @@
+package com.sunxung.factoring.job.impl;
+
+import com.sunxung.factoring.service.smb.IFinancingFromInvestorsService;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.EnableScheduling;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+/**
+ * @deprecated 苏商定时任务
+ * @author liutao
+ * @date 2024-09-14
+ */
+@Component
+@EnableScheduling
+public class SmbTaskJob {
+
+    private static Logger log = LogManager.getLogger(SmbTaskJob.class);
+
+    @Autowired
+    private IFinancingFromInvestorsService financingFromInvestorsService;
+
+
+    @Scheduled(cron = "0 0/30 * * * ?")
+    public void process() {
+        log.info("苏商定时任务任务执行开始...");
+        financingFromInvestorsService.updateStatus();
+        log.info("苏商定时任务任务执行结束...");
+    }
+
+}

+ 5 - 0
src/main/java/com/sunxung/factoring/service/smb/IFinancingFromInvestorsService.java

@@ -65,4 +65,9 @@ public interface IFinancingFromInvestorsService extends IService<FinancingFromIn
      * @return
      */
     FinancingFromInvestorsNotice findCreditDetail(Long id);
+
+    /**
+     * 定时任务 刷新状态
+     */
+    void updateStatus();
 }

+ 47 - 25
src/main/java/com/sunxung/factoring/service/smb/impl/FinancingFromInvestorsServiceImpl.java

@@ -9,6 +9,8 @@ import com.snb.fsos.bean.AccountInfoQuery;
 import com.snb.fsos.bean.ProductCreditApplyV2;
 import com.snb.fsos.bean.SMBFileUpload;
 import com.sunxung.factoring.component.enums.CreditInvestigationTypeEnums;
+import com.sunxung.factoring.component.enums.SmbCreditStatusEnum;
+import com.sunxung.factoring.component.enums.SmbLimitStatusEnum;
 import com.sunxung.factoring.component.enums.SupplierStatusEnums;
 import com.sunxung.factoring.component.exception.BusinessException;
 import com.sunxung.factoring.component.exception.ValidatorException;
@@ -367,17 +369,17 @@ public class FinancingFromInvestorsServiceImpl extends ServiceImpl<FinancingFrom
             log.info("苏商银行授信请求結果:" + creditApplyResp.toString());
             // 状态 01 待审批;02 审批中;03 审批通过;04 审批拒绝;06 已归档;07 处理中
             if (creditApplyResp.getStatus().equals("01")) {
-                financingFromInvestors.setCreditStatus("待审批");
+                financingFromInvestors.setCreditStatus(SmbCreditStatusEnum.STATUS_01.getCode());
             } else if (creditApplyResp.getStatus().equals("02")) {
-                financingFromInvestors.setCreditStatus("审批中");
+                financingFromInvestors.setCreditStatus(SmbCreditStatusEnum.STATUS_02.getCode());
             } else if (creditApplyResp.getStatus().equals("03")) {
-                financingFromInvestors.setCreditStatus("审批通过");
+                financingFromInvestors.setCreditStatus(SmbCreditStatusEnum.STATUS_03.getCode());
             } else if (creditApplyResp.getStatus().equals("04")) {
-                financingFromInvestors.setCreditStatus("审批拒绝");
+                financingFromInvestors.setCreditStatus(SmbCreditStatusEnum.STATUS_04.getCode());
             } else if (creditApplyResp.getStatus().equals("06")) {
-                financingFromInvestors.setCreditStatus("已归档");
+                financingFromInvestors.setCreditStatus(SmbCreditStatusEnum.STATUS_06.getCode());
             } else if (creditApplyResp.getStatus().equals("07")) {
-                financingFromInvestors.setCreditStatus("处理中");
+                financingFromInvestors.setCreditStatus(SmbCreditStatusEnum.STATUS_07.getCode());
             }
             financingFromInvestors.setOpenId(creditApplyResp.getOpenId());
             //保存历史
@@ -689,11 +691,12 @@ public class FinancingFromInvestorsServiceImpl extends ServiceImpl<FinancingFrom
                 FinancingFromInvestorsHistory financingFromInvestorsHistory = financingFromInvestorsHistories.get(0);
                 FinancingFromInvestorsNotice financingFromInvestorsNotice = financingFromInvestorsNoticeService.lambdaQuery().eq(FinancingFromInvestorsNotice::getFinancingFromInvestorsHistoryId, financingFromInvestorsHistory.getId()).one();
                 if (financingFromInvestorsNotice != null && financingFromInvestorsNotice.getExpiringDate().compareTo(new Date()) < 1) {
-                    financingFromInvestors.setCreditStatus("授信过期");
+                    financingFromInvestors.setCreditStatus(SmbCreditStatusEnum.STATUS_12.getCode());
                     this.updateById(financingFromInvestors);
                 }
                 financingFromInvestors.setFinancingFromInvestorsNotice(financingFromInvestorsNotice);
             }
+
         }
         return new GridPage<>(financingFromInvestorsSearchVo.getRows(), financingFromInvestorsSearchVo.getPage(), page.getTotal(), list);
     }
@@ -872,26 +875,26 @@ public class FinancingFromInvestorsServiceImpl extends ServiceImpl<FinancingFrom
         financingFromInvestorsNotice.setApplyDate(DateUtil.parseDate(creditProcessQueryResp.getApplyDate()));
         // 状态 01 待审批 02 审批中 03 审批通过 04审批拒绝 06 已归档 07 处理中 11 运营岗审核
         if (creditProcessQueryResp.getApplyStatus().equals("01")) {
-            financingFromInvestorsNotice.setApplyStatus("待审批");
-            financingFromInvestors.setCreditStatus("待审批");
+            financingFromInvestorsNotice.setApplyStatus(SmbCreditStatusEnum.STATUS_01.getCode());
+            financingFromInvestors.setCreditStatus(SmbCreditStatusEnum.STATUS_01.getCode());
         } else if (creditProcessQueryResp.getApplyStatus().equals("02")) {
-            financingFromInvestorsNotice.setApplyStatus("审批中");
-            financingFromInvestors.setCreditStatus("审批中");
+            financingFromInvestorsNotice.setApplyStatus(SmbCreditStatusEnum.STATUS_02.getCode());
+            financingFromInvestors.setCreditStatus(SmbCreditStatusEnum.STATUS_02.getCode());
         } else if (creditProcessQueryResp.getApplyStatus().equals("03")) {
-            financingFromInvestorsNotice.setApplyStatus("审批通过");
-            financingFromInvestors.setCreditStatus("审批通过");
+            financingFromInvestorsNotice.setApplyStatus(SmbCreditStatusEnum.STATUS_03.getCode());
+            financingFromInvestors.setCreditStatus(SmbCreditStatusEnum.STATUS_03.getCode());
         } else if (creditProcessQueryResp.getApplyStatus().equals("04")) {
-            financingFromInvestorsNotice.setApplyStatus("审批拒绝");
-            financingFromInvestors.setCreditStatus("审批拒绝");
+            financingFromInvestorsNotice.setApplyStatus(SmbCreditStatusEnum.STATUS_04.getCode());
+            financingFromInvestors.setCreditStatus(SmbCreditStatusEnum.STATUS_04.getCode());
         } else if (creditProcessQueryResp.getApplyStatus().equals("06")) {
-            financingFromInvestorsNotice.setApplyStatus("已归档");
-            financingFromInvestors.setCreditStatus("已归档");
+            financingFromInvestorsNotice.setApplyStatus(SmbCreditStatusEnum.STATUS_06.getCode());
+            financingFromInvestors.setCreditStatus(SmbCreditStatusEnum.STATUS_06.getCode());
         } else if (creditProcessQueryResp.getApplyStatus().equals("07")) {
-            financingFromInvestorsNotice.setApplyStatus("处理中");
-            financingFromInvestors.setCreditStatus("处理中");
+            financingFromInvestorsNotice.setApplyStatus(SmbCreditStatusEnum.STATUS_07.getCode());
+            financingFromInvestors.setCreditStatus(SmbCreditStatusEnum.STATUS_07.getCode());
         } else if (creditProcessQueryResp.getApplyStatus().equals("11")) {
-            financingFromInvestorsNotice.setApplyStatus("运营岗审核");
-            financingFromInvestors.setCreditStatus("运营岗审核");
+            financingFromInvestorsNotice.setApplyStatus(SmbCreditStatusEnum.STATUS_11.getCode());
+            financingFromInvestors.setCreditStatus(SmbCreditStatusEnum.STATUS_11.getCode());
         }
         this.updateById(financingFromInvestors);
         if(StringUtil.isNotEmpty(creditProcessQueryResp.getNextApplyTime())){
@@ -900,13 +903,13 @@ public class FinancingFromInvestorsServiceImpl extends ServiceImpl<FinancingFrom
         financingFromInvestorsNotice.setRejectReason(creditProcessQueryResp.getReasonMsg());
         // 额度状态 001-未激活;002-生效;004-冻结;005-失效
         if (creditProcessQueryResp.getLimitStatus().equals("001")) {
-            financingFromInvestorsNotice.setLimitStatus("未激活");
+            financingFromInvestorsNotice.setLimitStatus(SmbLimitStatusEnum.LIMIT_STATUS_001.getCode());
         } else if (creditProcessQueryResp.getLimitStatus().equals("002")) {
-            financingFromInvestorsNotice.setLimitStatus("生效");
+            financingFromInvestorsNotice.setLimitStatus(SmbLimitStatusEnum.LIMIT_STATUS_002.getCode());
         } else if (creditProcessQueryResp.getLimitStatus().equals("004")) {
-            financingFromInvestorsNotice.setLimitStatus("冻结");
+            financingFromInvestorsNotice.setLimitStatus(SmbLimitStatusEnum.LIMIT_STATUS_004.getCode());
         } else if (creditProcessQueryResp.getLimitStatus().equals("005")) {
-            financingFromInvestorsNotice.setLimitStatus("失效");
+            financingFromInvestorsNotice.setLimitStatus(SmbLimitStatusEnum.LIMIT_STATUS_005.getCode());
         }
         financingFromInvestorsNotice.setValidityPeriod(DateUtil.parseDate(creditProcessQueryResp.getAuthEndDate()));
         if(creditProcessQueryResp.getCycleType().equals("0")){
@@ -948,6 +951,25 @@ public class FinancingFromInvestorsServiceImpl extends ServiceImpl<FinancingFrom
         return financingFromInvestorsNotice;
     }
 
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void updateStatus() {
+        Date date = new Date();
+        List<FinancingFromInvestorsNotice> list = financingFromInvestorsNoticeService.lambdaQuery().lt(FinancingFromInvestorsNotice::getExpiringDate, date).list();
+        for (FinancingFromInvestorsNotice financingFromInvestorsNotice : list) {
+            FinancingFromInvestorsHistory financingFromInvestorsHistory = financingFromInvestorsHistoryService.lambdaQuery().eq(FinancingFromInvestorsHistory::getId, financingFromInvestorsNotice.getFinancingFromInvestorsHistoryId()).one();
+            FinancingFromInvestors financingFromInvestors = this.getById(financingFromInvestorsHistory.getFinancingFromInvestorsId());
+            financingFromInvestors.setCreditStatus(SmbCreditStatusEnum.STATUS_12.getCode());
+            this.updateById(financingFromInvestors);
+        }
+
+        List<FinancingFromInvestors> financingFromInvestorsList = this.lambdaQuery().in(FinancingFromInvestors::getCreditStatus, SmbCreditStatusEnum.STATUS_01.getCode(), SmbCreditStatusEnum.STATUS_02.getCode(), SmbCreditStatusEnum.STATUS_03.getCode(), SmbCreditStatusEnum.STATUS_11.getCode()).list();
+        for (FinancingFromInvestors financingFromInvestors : financingFromInvestorsList) {
+            findCreditDetail(financingFromInvestors.getId());
+        }
+
+    }
+
 
     private FileStorage downloadFile(String remoteFilePath){