Browse Source

no message

FengChaoYu 8 months ago
parent
commit
430ff54164

+ 32 - 24
mall-server-api/src/main/java/com/gree/mall/manager/logic/settle/repair/DailyTransferLogic.java

@@ -1,5 +1,6 @@
 package com.gree.mall.manager.logic.settle.repair;
 
+import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.thread.ThreadUtil;
 import com.gree.mall.manager.bean.admin.AdminUserCom;
@@ -17,7 +18,6 @@ import com.gree.mall.manager.plus.entity.*;
 import com.gree.mall.manager.plus.service.*;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -52,16 +52,16 @@ public class DailyTransferLogic {
 
         //任务发发放表
         List<SettleDailyIssueTask> list = new ArrayList<>();
-        if (summaryNumberList == null || summaryNumberList.size() == 0) {
+        if (CollectionUtil.isEmpty(summaryNumberList)) {
             summaryNumberList = new ArrayList<>();
-            List<Map<String, Object>> summaryMap = new ArrayList<>();
+            List<Map<String, Object>> summaryMap;
             if (isMonth) {
                 summaryMap = dailyMapper.querySummaryMonthNumber(summaryBatchNo, adminUser.getAdminCompanyWechat().getCompanyWechatId());
             } else {
                 summaryMap = dailyMapper.querySummaryNumber(summaryBatchNo, adminUser.getAdminCompanyWechat().getCompanyWechatId());
             }
 
-            if (summaryMap.size() == 0) {
+            if (CollectionUtil.isEmpty(summaryMap)) {
                 throw new RemoteServiceException("没有找到可执行结算单位。");
             }
             for (Map item : summaryMap) {
@@ -69,7 +69,7 @@ public class DailyTransferLogic {
             }
         }
 
-        if (summaryNumberList == null || summaryNumberList.size() == 0) {
+        if (CollectionUtil.isEmpty(summaryNumberList)) {
             throw new RemoteServiceException("没有可结算的单位");
         }
 
@@ -226,7 +226,8 @@ public class DailyTransferLogic {
             settleDailyIssueSummaryMonthRecordService.updateBatchById(issueSummaryRecords, 500);
             //等待10S 查询转账转态
             //Thread.sleep(1000 * 10);
-            Integer issueStatus = queryMonthTransferResult(issueSummaryRecords, bankList, reqnbr, queryDate, summaryNumber, adminUser);
+            Integer issueStatus = queryMonthTransferResult(issueSummaryRecords, bankList, reqnbr, queryDate, summaryNumber,
+                    adminUser.getCompanyWechatId(), adminUser.getCompanyName());
             //记录单次记录
             saveCallApiRecord(issueBatchNo, totalIssueCost, issueStatus, opName, reqnbr, adminUser);
             settleDailyIssueTaskService.lambdaUpdate()
@@ -249,7 +250,7 @@ public class DailyTransferLogic {
         try {
             //查询结算单位对应银行授权账号
             SettleDailyBankCardBalance authBankCard = settleDailyBankCardBalanceService.lambdaQuery()
-                    .eq(SettleDailyBankCardBalance::getCompanyWechatId, adminUser.getAdminUserId())
+                    .eq(SettleDailyBankCardBalance::getCompanyWechatId, adminUser.getCompanyWechatId())
                     .eq(SettleDailyBankCardBalance::getSummaryNumber, summaryNumber)
                     .one();
             if (authBankCard == null) {
@@ -301,7 +302,7 @@ public class DailyTransferLogic {
 
             String issueBatchNo = commonLogic.generateNo("FF", "issueBatchNo", 15);
             // 金额大于0才发放
-            if (bankList != null && bankList.size() > 0) {
+            if (CollectionUtil.isNotEmpty(bankList)) {
                 payItem.setTtlamt(totalIssueCost.toString());
                 payItem.setTtlcnt(bankList.size() + "");
                 payItem.setCuramt(totalIssueCost.toString());
@@ -379,7 +380,9 @@ public class DailyTransferLogic {
             settleDailyIssueSummaryRecordService.updateBatchById(issueSummaryRecords, 500);
             //等待10S 查询转账转态
             //Thread.sleep(1000 * 10);
-            Integer issueStatus = queryTransferResult(issueSummaryRecords, bankList, reqnbr, queryDate, summaryNumber, adminUser);
+            Integer issueStatus = queryTransferResult(issueSummaryRecords, bankList, reqnbr, queryDate, summaryNumber,
+                    adminUser.getAdminCompanyWechat().getCompanyWechatId(), adminUser.getAdminCompanyWechat().getCompanyName());
+
             //记录单次记录
             saveCallApiRecord(issueBatchNo, totalIssueCost, issueStatus, opName, reqnbr, adminUser);
             settleDailyIssueTaskService.lambdaUpdate()
@@ -406,7 +409,9 @@ public class DailyTransferLogic {
     }
 
     @Transactional
-    public Integer queryMonthTransferResult(List<SettleDailyIssueSummaryMonthRecord> issueSummaryRecords, List<DailyWokerBankCardMonthBean> bankList, String reqnbr, String queryDate, String summaryNumber, AdminUserCom adminUser) throws Exception {
+    public Integer queryMonthTransferResult(List<SettleDailyIssueSummaryMonthRecord> issueSummaryRecords,
+                                            List<DailyWokerBankCardMonthBean> bankList, String reqnbr, String queryDate,
+                                            String summaryNumber, String companyId, String companyName) throws Exception {
         Map<String, Object> payResultMap = cmcBankLogic.insteadResult(reqnbr, summaryNumber);
         Integer issueStaus = DailyConstant.ISSUE_STATUS_BANK_DO;
         if (DailyConstant.CMC_RESPONSE_SUCCESS_CODE.equals(payResultMap.get("code").toString())) {
@@ -418,8 +423,8 @@ public class DailyTransferLogic {
                 String transferResult = map.get("trssts").toString();
                 for (SettleDailyIssueSummaryMonthRecord issueSummaryRecord : issueSummaryRecords) {
                     if (map.get("trsseq").toString().equals(issueSummaryRecord.getRequestNo())) {
-                        issueSummaryRecord.setCompanyWechatId(adminUser.getAdminCompanyWechat().getCompanyWechatId());
-                        issueSummaryRecord.setCompanyWechatName(adminUser.getAdminCompanyWechat().getCompanyName());
+                        issueSummaryRecord.setCompanyWechatId(companyId);
+                        issueSummaryRecord.setCompanyWechatName(companyName);
                         //转账成功的记录
                         if (Arrays.asList(DailyConstant.TRANSFER_RESP_SUCCESS).contains(transferResult)) {
                             issueSummaryRecord.setStatus(DailyConstant.ISSUE_STATUS_SUCCESS);
@@ -480,7 +485,9 @@ public class DailyTransferLogic {
     }
 
     @Transactional
-    public Integer queryTransferResult(List<SettleDailyIssueSummaryRecord> issueSummaryRecords, List<DailyWorkerBankCardBean> bankList, String reqnbr, String queryDate, String summaryNumber, AdminUserCom adminUser) throws Exception {
+    public Integer queryTransferResult(List<SettleDailyIssueSummaryRecord> issueSummaryRecords,
+                                       List<DailyWorkerBankCardBean> bankList, String reqnbr, String queryDate,
+                                       String summaryNumber, String companyId, String companyName) throws Exception {
         Map<String, Object> payResultMap = cmcBankLogic.insteadResult(reqnbr, summaryNumber);
         Integer issueStaus = DailyConstant.ISSUE_STATUS_BANK_DO;
         if (DailyConstant.CMC_RESPONSE_SUCCESS_CODE.equals(payResultMap.get("code").toString())) {
@@ -492,8 +499,8 @@ public class DailyTransferLogic {
                 String transferResult = map.get("trssts").toString();
                 for (SettleDailyIssueSummaryRecord issueSummaryRecord : issueSummaryRecords) {
                     if (map.get("trsseq").toString().equals(issueSummaryRecord.getRequestNo())) {
-                        issueSummaryRecord.setCompanyWechatId(adminUser.getAdminCompanyWechat().getCompanyWechatId());
-                        issueSummaryRecord.setCompanyWechatId(adminUser.getAdminCompanyWechat().getCompanyName());
+                        issueSummaryRecord.setCompanyWechatId(companyId);
+                        issueSummaryRecord.setCompanyWechatId(companyName);
                         //转账成功的记录
                         if (Arrays.asList(DailyConstant.TRANSFER_RESP_SUCCESS).contains(transferResult)) {
                             issueSummaryRecord.setStatus(DailyConstant.ISSUE_STATUS_SUCCESS);
@@ -534,10 +541,8 @@ public class DailyTransferLogic {
     }
 
     public void excute() {
-        AdminUserCom adminUser = commonLogic.getAdminUser();
         try {
             List<SettleDailyIssueTask> tasks = settleDailyIssueTaskService.lambdaQuery()
-                    .eq(StringUtils.isNotBlank(adminUser.getCompanyWechatId()), SettleDailyIssueTask::getCompanyWechatId, adminUser.getCompanyWechatId())
                     .eq(SettleDailyIssueTask::getTaskStatus, 2)
                     .list();
             if (tasks.size() == 0) {
@@ -549,7 +554,7 @@ public class DailyTransferLogic {
                 if (task.getIsMonth()) {
                     log.info("【月结查询】");
                     List<SettleDailyIssueSummaryMonthRecord> items = settleDailyIssueSummaryMonthRecordService.lambdaQuery()
-                            .eq(SettleDailyIssueSummaryMonthRecord::getCompanyWechatId, adminUser.getAdminCompanyWechat().getCompanyWechatId())
+                            .eq(SettleDailyIssueSummaryMonthRecord::getCompanyWechatId, task.getCompanyWechatId())
                             .eq(SettleDailyIssueSummaryMonthRecord::getSummaryBatchNo, task.getSummaryBatchNo())
                             .eq(SettleDailyIssueSummaryMonthRecord::getSummaryNumber, task.getSummaryNumber())
                             .eq(SettleDailyIssueSummaryMonthRecord::getStatus, DailyConstant.ISSUE_STATUS_BANK_DO).list();
@@ -562,13 +567,14 @@ public class DailyTransferLogic {
                     }
                     String queryDateEnd = DateUtil.format(new Date(), "yyyyMMdd");
                     List<DailyWokerBankCardMonthBean> bankList = dailyMapper.queryIssueSalaryMonthBankCardInfo(task.getSummaryBatchNo(),
-                            task.getSummaryNumber(), DailyConstant.ISSUE_STATUS_BANK_DO, adminUser.getAdminCompanyWechat().getCompanyWechatId());
-                    this.queryMonthTransferResult(items, bankList, task.getRequestNo(), queryDateEnd,task.getSummaryNumber(), adminUser);
+                            task.getSummaryNumber(), DailyConstant.ISSUE_STATUS_BANK_DO, task.getCompanyWechatId());
+                    this.queryMonthTransferResult(items, bankList, task.getRequestNo(), queryDateEnd,task.getSummaryNumber(),
+                            task.getCompanyWechatId(), task.getCompanyWechatName());
 
                 } else {
                     log.info("【日结查询】");
                     List<SettleDailyIssueSummaryRecord> items = settleDailyIssueSummaryRecordService.lambdaQuery()
-                            .eq(SettleDailyIssueSummaryRecord::getCompanyWechatId, adminUser.getAdminCompanyWechat().getCompanyWechatId())
+                            .eq(SettleDailyIssueSummaryRecord::getCompanyWechatId, task.getCompanyWechatId())
                             .eq(SettleDailyIssueSummaryRecord::getSummaryBatchNo, task.getSummaryBatchNo())
                             .eq(SettleDailyIssueSummaryRecord::getSummaryNumber, task.getSummaryNumber())
                             .eq(SettleDailyIssueSummaryRecord::getStatus, DailyConstant.ISSUE_STATUS_BANK_DO).list();
@@ -581,11 +587,13 @@ public class DailyTransferLogic {
                     String queryDateEnd = DateUtil.format(new Date(), "yyyyMMdd");
 
                     List<DailyWorkerBankCardBean> bankList = dailyMapper.queryIssueSalaryAndBankCardInfo(task.getSummaryBatchNo(),
-                            task.getSummaryNumber(), DailyConstant.ISSUE_STATUS_BANK_DO, adminUser.getAdminCompanyWechat().getCompanyWechatId());
-                    Integer status = this.queryTransferResult(items, bankList, task.getRequestNo(), queryDateEnd,task.getSummaryNumber(), adminUser);
+                            task.getSummaryNumber(), DailyConstant.ISSUE_STATUS_BANK_DO, task.getCompanyWechatId());
+                    Integer status = this.queryTransferResult(items, bankList, task.getRequestNo(), queryDateEnd,task.getSummaryNumber(),
+                            task.getCompanyWechatId(), task.getCompanyWechatName());
+
                     settleDailyBankTransferRecordService.lambdaUpdate()
                             .set(SettleDailyBankTransferRecord::getIssueStatus,status)
-                            .eq(SettleDailyBankTransferRecord::getCompanyWechatId, adminUser.getAdminCompanyWechat().getCompanyWechatId())
+                            .eq(SettleDailyBankTransferRecord::getCompanyWechatId, task.getCompanyWechatId())
                             .eq(SettleDailyBankTransferRecord::getReqNo,task.getRequestNo())
                             .update();
                 }

+ 63 - 0
mall-server-api/src/main/java/com/gree/mall/manager/logic/settle/repair/RepairSettleAccountLogic.java

@@ -55,6 +55,7 @@ public class RepairSettleAccountLogic {
     private final SettleDailyBankCardBalanceService settleDailyBankCardBalanceService;
     private final RedisUtil redisUtil;
     private final CmcBankLogic cmcBankLogic;
+    private final DailyWithholdLogic dailyWithholdLogic;
 
     public IPage<DailyBankAccountVO> page(ZfireParamBean zfireParamBean) {
         AdminUserCom adminUser = commonLogic.getAdminUser();
@@ -333,4 +334,66 @@ public class RepairSettleAccountLogic {
         return bankCardBalance;
     }
 
+    /**
+     * 查询银行卡余额
+     */
+//    public void warnBalanceExcute() throws Exception {
+//        List<SettleDailyBankCardBalance> bankList = settleDailyBankCardBalanceService.lambdaQuery()
+//                .list();
+//        if (bankList.size() == 0) {
+//            log.info("warnBalanceExcute :公司信息不存在。");
+//            throw new RemoteServiceException("公司信息不存在。");
+//        }
+//        //获取余额预警值
+//        List<SysDictCompany> warnDict = dailyWithholdLogic.getConfig(DictCodeEnum.BANLANCE_WARN_VALUE.toString());
+//        if (warnDict.size() == 0) {
+//            log.info("warnBalanceExcute :余额预警值未配置。");
+//            throw new RemoteServiceException("余额预警值未配置。");
+//        }
+//        BigDecimal warnvalue = new BigDecimal(warnDict.get(0).getDictValue());
+//
+//        for (SettleDailyBankCardBalance cardBalance : bankList) {
+//            //组装请求参数
+//            List<BankCardInfoBean> list = new ArrayList<>();
+//            BankCardInfoBean bankCardInfoBean = new BankCardInfoBean();
+//            bankCardInfoBean.setAuthType("1");
+//            bankCardInfoBean.setBankAccount(cardBalance.getBankCardId());
+//            bankCardInfoBean.setBankOrgCode(cardBalance.getOpenBankOrgId());
+//            list.add(bankCardInfoBean);
+//            //查询余额
+//            Map<String, Object> response = cmcBankLogic.getAccountBalance(list, cardBalance.getSummaryNumber());
+//
+//            JSONObject head = JSONObject.parseObject(response.get("head").toString());
+//            if (head != null && head.get("resultcode").equals("SUC0000")) {
+//                Map<String, Map<String, Object>> body = (Map<String, Map<String, Object>>) response.get("body");
+//                List<Map<String, Object>> ntqadinfz = (List<Map<String, Object>>) body.get("ntqadinfz");
+//                BigDecimal balance = new BigDecimal(ntqadinfz.get(0).get("avlblv").toString());
+//                if (balance.doubleValue() < warnvalue.doubleValue()) {
+//                    log.info("向 {} 发送余额预警短信 余额为: {}",cardBalance.getAccountName(),balance);
+//                    sendWarnMsg(cardBalance.getCompanyWechatName());
+//                }
+//
+//            } else {
+//                log.warn("warnBalanceExcute :查询失败" + response.get("errtxt"));
+//                // throw new RemoteServiceException("查询失败" + response.get("errtxt"));
+//            }
+//        }
+//
+//    }
+
+//    public void sendWarnMsg(String companyName) throws Exception {
+//
+//        String dayFmt = DateUtil.format(new Date(), "yyyy年MM月dd日");
+//        List<Dict> list = dailyWithholdLogic.getConfig(DictCodeEnum.SELECT_BANLANCE.toString());
+//        for (Dict dict : list) {
+//            if (dict.getDescription().contains(companyName)) {
+//                HashMap<String,String> params = new HashMap<>();
+//                params.put("date",dayFmt);
+//                params.put("accountName",companyName);
+//                smsLogic.send(dict.getDictValue(), DailyConstant.WARN_TEMPLEATE, params);
+//            }
+//        }
+//
+//    }
+
 }

+ 21 - 0
mall-server-api/src/main/java/com/gree/mall/manager/schedule/daily/BalanceWarnSchedule.java

@@ -0,0 +1,21 @@
+package com.gree.mall.manager.schedule.daily;
+
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Component;
+
+@Slf4j
+@Component
+public class BalanceWarnSchedule {
+
+//    @Autowired
+//    RepairSettleAccountLogic repairSettleAccountLogic;
+
+//    @Scheduled(cron = " 0 0 8 * * ? ")
+//    public void task() throws Exception{
+//        log.info("【余额查询开始】{}", DateUtils.formatDate(new Date()));
+//        repairSettleAccountLogic.warnBalanceExcute();
+//        log.info("【余额查询结束】{}",DateUtils.formatDate(new Date()));
+//    }
+
+
+}

+ 29 - 0
mall-server-api/src/main/java/com/gree/mall/manager/schedule/daily/TransferRetrySchedule.java

@@ -0,0 +1,29 @@
+package com.gree.mall.manager.schedule.daily;
+
+import com.gree.mall.manager.logic.settle.repair.DailyTransferLogic;
+import com.gree.mall.manager.utils.DateUtils;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+import java.util.Date;
+
+/**
+ * @author Administrator
+ */
+@Slf4j
+@Component
+public class TransferRetrySchedule {
+
+    @Autowired
+    DailyTransferLogic dailyTransferLogic;
+
+    @Scheduled(cron = "0 0/2 * * * ? ")
+    public void task() {
+        log.info("【联动支付转账结果查询】{}", DateUtils.formatDate(new Date()));
+        dailyTransferLogic.excute();
+        log.info("【联动支付结果查询】{}",DateUtils.formatDate(new Date()));
+    }
+
+}