From f5e3323be3ce83280c48cd1856bea88c6aed8ffa Mon Sep 17 00:00:00 2001
From: “djh” <“3298565835@qq.com”>
Date: 星期四, 06 三月 2025 13:40:47 +0800
Subject: [PATCH] 统计修改

---
 exam-system/src/main/java/com/gkhy/exam/pay/service/impl/CoalPayServiceImpl.java |   54 +++++++++++++++++++++++++++++++++---------------------
 1 files changed, 33 insertions(+), 21 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 77a968e..6964111 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
@@ -69,27 +69,27 @@
      */
     @Override
     public List<CoalPayRepDto> selectCoalPayList(CoalPayReq coalPay) {
-        List<CoalPayRepDto> coalPayRepDtos = new ArrayList<>();
-        List<CoalPay> coalPays = coalPayMapper.selectCoalPayList(coalPay);
-        for (CoalPay pay : coalPays) {
-            CoalPayRepDto coalPayRepDto = new CoalPayRepDto();
-            BeanUtils.copyProperties(pay, coalPayRepDto);
+//        List<CoalPayRepDto> coalPayRepDtos = new ArrayList<>();
+        List<CoalPayRepDto> coalPays = coalPayMapper.selectCoalPayList(coalPay);
+        for (CoalPayRepDto pay : coalPays) {
+//            CoalPayRepDto coalPayRepDto = new CoalPayRepDto();
+//            BeanUtils.copyProperties(pay, coalPayRepDto);
             //部门数据
             SysDept sysDept = sysDeptMapper.selectDeptById(pay.getDeptId());
-            coalPayRepDto.setDeptName(sysDept.getDeptName());
+            pay.setDeptName(sysDept.getDeptName());
             //工种数据
             List<CoalCategory> coalCategories = coalCategoryMapper.selectByCoalPayId(pay.getId());
-            coalPayRepDto.setCoalCategoryList(coalCategories);
+            pay.setCoalCategoryList(coalCategories);
             //学员数据
             List<CoalPayStudent> coalPayStudents = coalPayStudentService.selectByCoalPayId(pay.getId());
             List<CoalPayStudent> havePay = coalPayStudents.stream()
                     .filter(stu -> stu.getPayStatus() != null && stu.getPayStatus() == 1)
                     .collect(Collectors.toList());
-            coalPayRepDto.setTotalNum(coalPayStudents.size());
-            coalPayRepDto.setHavePayNum(havePay.size());
-            coalPayRepDtos.add(coalPayRepDto);
+            pay.setTotalNum(coalPayStudents.size());
+            pay.setHavePayNum(havePay.size());
+//            coalPayRepDtos.add(coalPayRepDto);
         }
-        return coalPayRepDtos;
+        return coalPays;
     }
 
     @Override
@@ -163,7 +163,7 @@
     @Override
     public AjaxResult deleteCoalPayByIds(Long[] ids) {
         for (Long id : ids) {
-            List<CoalPayStudent> coalPayStudents = coalPayStudentService.selectByCoalPayIdAndPayStatus(id, 1);
+            List<CoalPayStudent> coalPayStudents = coalPayStudentService.selectByCoalPayId(id);
             if (!CollectionUtils.isEmpty(coalPayStudents)) {
                 throw new BusinessException(this.getClass(), ResultConstants.BUSINESS_ERROR, "已有学员完成缴费,请勿删除");
             }
@@ -223,6 +223,7 @@
             CoalPayStudent coalPayStudent = new CoalPayStudent();
             coalPayStudent.setCoalPayId(coalPayTypeReq.getCoalPayId());
             coalPayStudent.setPayType(2);
+            coalPayStudent.setGovPayStatus(0);
             coalPayStudentService.updateByCoalPayId(coalPayStudent);
         }
         return i;
@@ -250,10 +251,13 @@
             if (student.getPayStatus() == 1) {
                 throw new BusinessException(this.getClass(), ResultConstants.BUSINESS_ERROR, "请勿重新缴费");
             }
+            if (student.getGovPayStatus() == 2){
+                return student.getOrderId();
+            }
 
             PayReqData payReqData = fillData(coalPayStudent, coalPay, coalCategories, coalTicket, 1, null);
 
-            ResultVo resultVo = payUtils.sendApiPost(payReqData);
+            ResultVo resultVo = payUtils.faqiV2(payReqData);
             if (resultVo.getRespcode().equals("BUS0000")) {
                 //进行票据签名并校验
 //                ResultVo resultVo1 = payUtils.uploadXml(resultVo.getRespdata().getOrderNo(), resultVo.getRespdata().getFileData());
@@ -261,17 +265,16 @@
 //                  throw new BusinessException(this.getClass(), ResultConstants.BUSINESS_ERROR, "签名验证错误");
 //              }
                 payStudent.setId(studentId);
-                payStudent.setOrderId(resultVo.getRespdata().getOrderNo());
-                payStudent.setGovPayStatus(1);
+                payStudent.setOrderNo(resultVo.getRespdata().getOrderNo());
+                payStudent.setOrderId(resultVo.getRespdata().getOrderId());
+                payStudent.setGovPayStatus(2);
                 payStudent.setPayCode(resultVo.getRespdata().getBillNo());
-                coalPayStudentService.updateByCoalPayStudent(payStudent);
+                coalPayStudentService.updateByIdAndPayType(payStudent);
                 return resultVo.getRespdata().getOrderId();
             } else {
                 throw new BusinessException(this.getClass(), ResultConstants.BUSINESS_ERROR, resultVo.getRespmsg());
             }
         } catch (BusinessException e) {
-            throw new RuntimeException(e);
-        } catch (IOException e) {
             throw new RuntimeException(e);
         } finally {
             if (lock.isLocked()) {
@@ -295,14 +298,18 @@
             if (coalPay == null) {
                 throw new BusinessException(this.getClass(), ResultConstants.BUSINESS_ERROR, "未找到相关缴费信息");
             }
+            if (coalPayStudents.get(0).getGovPayStatus() == 2){
+                return coalPayStudents.get(0).getOrderId();
+            }
 
             CoalPayStudent payStudent = new CoalPayStudent();
             PayReqData payReqData = fillData(coalPayStudents, coalPay, coalCategories, coalTicket, 2, coalTeamPayReq);
-            ResultVo resultVo = payUtils.sendApiPost(payReqData);
+            ResultVo resultVo = payUtils.faqiV2(payReqData);
             if (resultVo.getRespcode().equals("BUS0000")) {
                 payStudent.setCoalPayId(coalPay.getId());
-                payStudent.setOrderId(resultVo.getRespdata().getOrderNo());
-                payStudent.setGovPayStatus(1);
+                payStudent.setOrderId(resultVo.getRespdata().getOrderId());
+                payStudent.setOrderNo(resultVo.getRespdata().getOrderNo());
+                payStudent.setGovPayStatus(2);
                 payStudent.setPayCode(resultVo.getRespdata().getBillNo());
                 coalPayStudentService.updateByCoalPayIdAndStatus(payStudent);
                 return resultVo.getRespdata().getOrderId();
@@ -366,6 +373,11 @@
 
         PayUtils payUtils = new PayUtils();
         ResultVo resultVo = payUtils.faqiV2(payReqData);
+        if (!resultVo.getRespcode().equals("BUS0000")) {
+            throw new BusinessException(this.getClass(), ResultConstants.BUSINESS_ERROR, "签名验证错误");
+        } else {
+            //todo 业务处理
+        }
         log.info("请求结果:" + JSONObject.toJSONString(resultVo));
 //        String fileData = resultVo.getRespdata().getFileData();
 //        //票据原文转为byte字节文件

--
Gitblit v1.9.2