From b8c242ec24dddbefaed8c0acbd738b90244953ea Mon Sep 17 00:00:00 2001
From: heheng <heheng@123456>
Date: 星期二, 18 二月 2025 16:44:27 +0800
Subject: [PATCH] merge

---
 exam-system/src/main/java/com/gkhy/exam/pay/service/impl/CoalPayServiceImpl.java |   67 +++++++++++++++++----------------
 1 files changed, 34 insertions(+), 33 deletions(-)

diff --git a/exam-system/src/main/java/com/gkhy/exam/pay/service/impl/CoalPayServiceImpl.java b/exam-system/src/main/java/com/gkhy/exam/pay/service/impl/CoalPayServiceImpl.java
index d4116a9..17cb91a 100644
--- a/exam-system/src/main/java/com/gkhy/exam/pay/service/impl/CoalPayServiceImpl.java
+++ b/exam-system/src/main/java/com/gkhy/exam/pay/service/impl/CoalPayServiceImpl.java
@@ -1,6 +1,5 @@
 package com.gkhy.exam.pay.service.impl;
 
-import cn.com.jit.new_vstk.Bean.EnvelopResult;
 import cn.com.jit.new_vstk.Bean.SignResult;
 import cn.com.jit.new_vstk.Bean.VerifyResult;
 import com.alibaba.fastjson2.JSONObject;
@@ -24,7 +23,6 @@
 import com.ruoyi.common.exception.BusinessException;
 import com.ruoyi.common.utils.RandomUtil;
 import com.ruoyi.common.utils.SecurityUtils;
-import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.system.mapper.SysDeptMapper;
 import lombok.extern.slf4j.Slf4j;
 import org.dom4j.Document;
@@ -42,7 +40,10 @@
 import java.io.IOException;
 import java.math.BigDecimal;
 import java.nio.charset.StandardCharsets;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Base64;
+import java.util.Date;
+import java.util.List;
 import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 
@@ -91,7 +92,7 @@
             //学员数据
             List<CoalPayStudent> coalPayStudents = coalPayStudentService.selectByCoalPayId(pay.getId());
             List<CoalPayStudent> havePay = coalPayStudents.stream()
-                    .filter(stu -> stu.getPayStatus() != null && stu.getPayStatus()==1)
+                    .filter(stu -> stu.getPayStatus() != null && stu.getPayStatus() == 1)
                     .collect(Collectors.toList());
             coalPayRepDto.setTotalNum(coalPayStudents.size());
             coalPayRepDto.setHavePayNum(havePay.size());
@@ -227,7 +228,7 @@
             throw new BusinessException(this.getClass(), ResultConstants.BUSINESS_ERROR, "已为团体缴费,不可更改");
         }
         int i = coalPayMapper.updateByPayId(coalPayTypeReq);
-        if (i>0){
+        if (i > 0) {
             CoalPayStudent coalPayStudent = new CoalPayStudent();
             coalPayStudent.setCoalPayId(coalPayTypeReq.getCoalPayId());
             coalPayStudent.setPayType(2);
@@ -249,17 +250,17 @@
             CoalPay coalPay = coalPayMapper.selectById(coalPayId);
             List<CoalCategory> coalCategories = coalCategoryMapper.selectByCoalPayId(coalPayId);
             CoalTicket coalTicket = coalCategoryMapper.selectCoalTicket();
-            if (CollectionUtils.isEmpty(coalPayStudent)){
-                throw new BusinessException(this.getClass(),ResultConstants.BUSINESS_ERROR,"缴费学员不存在");
+            if (CollectionUtils.isEmpty(coalPayStudent)) {
+                throw new BusinessException(this.getClass(), ResultConstants.BUSINESS_ERROR, "缴费学员不存在");
             }
-            if (coalPay==null){
-                throw new BusinessException(this.getClass(),ResultConstants.BUSINESS_ERROR,"未找到相关缴费信息");
+            if (coalPay == null) {
+                throw new BusinessException(this.getClass(), ResultConstants.BUSINESS_ERROR, "未找到相关缴费信息");
             }
-            if (student.getPayStatus()==1){
-                throw new BusinessException(this.getClass(),ResultConstants.BUSINESS_ERROR,"请勿重新缴费");
+            if (student.getPayStatus() == 1) {
+                throw new BusinessException(this.getClass(), ResultConstants.BUSINESS_ERROR, "请勿重新缴费");
             }
 
-            PayReqData payReqData = fillData(coalPayStudent,coalPay,coalCategories,coalTicket,1,null);
+            PayReqData payReqData = fillData(coalPayStudent, coalPay, coalCategories, coalTicket, 1, null);
 
             ResultVo resultVo = payUtils.sendApiPost(payReqData);
             if (resultVo.getRespcode().equals("BUS0000")) {
@@ -292,20 +293,20 @@
     public String teamPayMoney(CoalTeamPayReq coalTeamPayReq) {
         RLock lock = redissonClient.getLock("SWSPKMAS_TEAM_PAY_" + coalTeamPayReq.getCoalPayId());
         try {
-            lock.lock(10,TimeUnit.SECONDS);
+            lock.lock(10, TimeUnit.SECONDS);
             List<CoalPayStudent> coalPayStudents = coalPayStudentService.selectByCoalPayIdAndPayStatus(coalTeamPayReq.getCoalPayId(), 0);
             CoalPay coalPay = coalPayMapper.selectById(coalTeamPayReq.getCoalPayId());
             List<CoalCategory> coalCategories = coalCategoryMapper.selectByCoalPayId(coalTeamPayReq.getCoalPayId());
             CoalTicket coalTicket = coalCategoryMapper.selectCoalTicket();
-            if (CollectionUtils.isEmpty(coalPayStudents)){
-                throw new BusinessException(this.getClass(),ResultConstants.BUSINESS_ERROR,"缴费学员不存在");
+            if (CollectionUtils.isEmpty(coalPayStudents)) {
+                throw new BusinessException(this.getClass(), ResultConstants.BUSINESS_ERROR, "缴费学员不存在");
             }
-            if (coalPay==null){
-                throw new BusinessException(this.getClass(),ResultConstants.BUSINESS_ERROR,"未找到相关缴费信息");
+            if (coalPay == null) {
+                throw new BusinessException(this.getClass(), ResultConstants.BUSINESS_ERROR, "未找到相关缴费信息");
             }
 
             CoalPayStudent payStudent = new CoalPayStudent();
-            PayReqData payReqData = fillData(coalPayStudents, coalPay, coalCategories, coalTicket,2,coalTeamPayReq);
+            PayReqData payReqData = fillData(coalPayStudents, coalPay, coalCategories, coalTicket, 2, coalTeamPayReq);
             ResultVo resultVo = payUtils.sendApiPost(payReqData);
             if (resultVo.getRespcode().equals("BUS0000")) {
                 payStudent.setCoalPayId(coalPay.getId());
@@ -317,9 +318,9 @@
             } else {
                 throw new BusinessException(this.getClass(), ResultConstants.BUSINESS_ERROR, "发起支付失败,请稍后重试");
             }
-        }catch (Exception e){
+        } catch (Exception e) {
             throw new RuntimeException(e);
-        }finally {
+        } finally {
             if (lock.isLocked()) {
                 lock.unlock();
             }
@@ -369,14 +370,14 @@
 //        feedatas1.add(feedatas);
         feedatas1.add(feedata);
         payReqData.setFeeDatas(feedatas1);
-        log.info("请求参数:"+ JSONObject.toJSONString(payReqData));
+        log.info("请求参数:" + JSONObject.toJSONString(payReqData));
 
 
         PayUtils payUtils = new PayUtils();
         ResultVo resultVo = payUtils.sendApiPost(payReqData);
         String fileData = resultVo.getRespdata().getFileData();
         //票据原文转为byte字节文件
-        byte[] decode =  Base64.getDecoder().decode(fileData);
+        byte[] decode = Base64.getDecoder().decode(fileData);
         //byte字节文件转为xml字符串
         String xmlString = new String(decode, StandardCharsets.UTF_8);
         Document document = null;
@@ -385,25 +386,25 @@
         } catch (DocumentException e) {
             throw new RuntimeException(e);
         }
-        log.info("票据原文为:"+document.asXML());
+        log.info("票据原文为:" + document.asXML());
         Element rootElement = document.getRootElement();
-        SignResult sign = payUtils.sign(decode);
-        VerifyResult verify = payUtils.verify(decode,sign.getSignData());
-        SignDto signDto = new SignDto("SM3", "DETACH", new Date(), verify.getSubjectdn(), verify.getSn(), verify.getIssure());
-        log.info("拼接对象为:"+JSONObject.toJSONString(signDto));
+        SignResult sign = payUtils.sign(fileData);
+        VerifyResult verify = payUtils.verify(sign.getSignData(), fileData);
+        SignDto signDto = new SignDto(new Date(), verify.getSubjectdn(), verify.getSn(), verify.getIssure());
+        log.info("拼接对象为:" + JSONObject.toJSONString(signDto));
         Sign sign1 = new Sign();
         Document signature = sign1.getSignature(signDto);
 //        Element rootElement1 = signature.getRootElement();
-        log.info("拼接结果为:"+signature.asXML());
+        log.info("拼接结果为:" + signature.asXML());
         rootElement.add(signature.getRootElement());
 //        EnvelopResult envelopResult = payUtils.encryptEnvelop(document.asXML().getBytes());
 //        log.info("制作数字信封为:"+ Arrays.toString(envelopResult.getEnvelopData()));
-        log.info("签名后票据为:"+document.asXML());
-        ResultVo resultVo1 = payUtils.uploadXml(resultVo.getRespdata().getOrderNo(), document.asXML().getBytes());
+        log.info("签名后票据为:" + document.asXML());
+        ResultVo resultVo1 = payUtils.uploadXml(resultVo.getRespdata().getOrderNo(), document.asXML());
         return resultVo1;
     }
 
-    private PayReqData fillData(List<CoalPayStudent>  coalPayStudent, CoalPay coalPay, List<CoalCategory> coalCategories, CoalTicket coalTicket,Integer payType,CoalTeamPayReq coalTeamPayReq) {
+    private PayReqData fillData(List<CoalPayStudent> coalPayStudent, CoalPay coalPay, List<CoalCategory> coalCategories, CoalTicket coalTicket, Integer payType, CoalTeamPayReq coalTeamPayReq) {
         PayReqData payReqData = new PayReqData();
         payReqData.setOrderNo(RandomUtil.generateOrderNumber(coalPay.getId(), "CO"));
         payReqData.setMoney(coalPay.getAmount().multiply(BigDecimal.valueOf(coalPayStudent.size())));
@@ -425,11 +426,11 @@
         }
         payReqData.setFeeDatas(feedatas);
 
-        if (1==payType){
+        if (1 == payType) {
             payReqData.setPayerName(coalPayStudent.get(0).getName());
             payReqData.setCertNo(coalPayStudent.get(0).getIdCard());
             payReqData.setPayerType(1);
-        }else if (2==payType){
+        } else if (2 == payType) {
             payReqData.setPayerName(coalTeamPayReq.getPayCompanyName());
             payReqData.setCertNo(coalTeamPayReq.getPayCompanyCard());
             payReqData.setPayerType(2);

--
Gitblit v1.9.2