教育训练处考试制证系统后端
“djh”
2025-01-23 75b742855cba8106732b561a015a87bd711963ed
煤矿缴费个人缴费
已修改8个文件
128 ■■■■■ 文件已修改
exam-system/src/main/java/com/gkhy/exam/pay/controller/CoalPayController.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
exam-system/src/main/java/com/gkhy/exam/pay/mapper/CoalPayStudentMapper.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
exam-system/src/main/java/com/gkhy/exam/pay/service/CoalPayStudentService.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
exam-system/src/main/java/com/gkhy/exam/pay/service/impl/CoalPayServiceImpl.java 93 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
exam-system/src/main/java/com/gkhy/exam/pay/service/impl/CoalPayStudentServiceImpl.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
exam-system/src/main/java/com/gkhy/exam/pay/utils/PayUtils.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
exam-system/src/main/resources/mapper/pay/CoalPayStudentMapper.xml 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-common/src/main/java/com/ruoyi/common/utils/RandomUtil.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
exam-system/src/main/java/com/gkhy/exam/pay/controller/CoalPayController.java
@@ -77,13 +77,6 @@
        return toAjax(coalPayService.updateCoalPayType(coalPayTypeReq));
    }
//    /**
//     * 修改煤矿缴费
//     */
//    @PostMapping("/updatePayCompany")
//    public AjaxResult updatePay(@RequestBody ){
//        return toAjax(coalPayService.updatePay());
//    }
    /**
     * 删除煤矿缴费管理
     */
@@ -106,6 +99,7 @@
    @PostMapping("/personPay")
    @ApiOperation(value = "个人缴费接口")
    @Anonymous
    public AjaxResult payMoney(@RequestParam("coalPayId") Long coalPayId,@RequestParam("studentId") Long studentId){
        return success(coalPayService.personPayMoney(coalPayId,studentId));
    }
exam-system/src/main/java/com/gkhy/exam/pay/mapper/CoalPayStudentMapper.java
@@ -22,4 +22,7 @@
    int updateCoalPayStudentById(CoalPayStudent coalPayStudent);
    int insertCoalPayStudent(CoalPayStudent coalPayStudent);
    void updateByCoalPayId(CoalPayStudent coalPayStudent);
}
exam-system/src/main/java/com/gkhy/exam/pay/service/CoalPayStudentService.java
@@ -28,4 +28,6 @@
    List<CoalPayStudent> selectbyIdcard(CoalPayStudentReq coalPayStudent);
    CoalPayStudent selectbyId(Long studentId);
    void updateByCoalPayId(CoalPayStudent coalPayStudent);
}
exam-system/src/main/java/com/gkhy/exam/pay/service/impl/CoalPayServiceImpl.java
@@ -214,18 +214,65 @@
        if (coalPayTypeReq.getPayPersonType() != null && byId.getPayPersonType() == 2) {
            throw new BusinessException(this.getClass(), ResultConstants.BUSINESS_ERROR, "已为团体缴费,不可更改");
        }
        return coalPayMapper.updateByPayId(coalPayTypeReq);
        int i = coalPayMapper.updateByPayId(coalPayTypeReq);
        if (i>0){
            CoalPayStudent coalPayStudent = new CoalPayStudent();
            coalPayStudent.setCoalPayId(coalPayTypeReq.getCoalPayId());
            coalPayStudent.setPayType(2);
            coalPayStudentService.updateByCoalPayId(coalPayStudent);
        }
        return i;
    }
    @Override
    public String personPayMoney(Long coalPayId, Long studentId) {
        CoalPayStudent coalPayStudent = coalPayStudentService.selectbyId(studentId);
        CoalPay coalPay = coalPayMapper.selectById(coalPayId);
        List<CoalCategory> coalCategories = coalCategoryMapper.selectByCoalPayId(coalPayId);
        CoalTicket coalTicket = coalCategoryMapper.selectCoalTicket();
        CoalPayStudent payStudent = new CoalPayStudent();
        RLock lock = redissonClient.getLock("SWSPKMAS_PAY_PERSON_" + coalPayId);
        try {
            lock.lock(10, TimeUnit.SECONDS);
            CoalPayStudent coalPayStudent = coalPayStudentService.selectbyId(studentId);
            CoalPay coalPay = coalPayMapper.selectById(coalPayId);
            List<CoalCategory> coalCategories = coalCategoryMapper.selectByCoalPayId(coalPayId);
            CoalTicket coalTicket = coalCategoryMapper.selectCoalTicket();
            if (coalPayStudent==null){
                throw new BusinessException(this.getClass(),ResultConstants.BUSINESS_ERROR,"缴费学员不存在");
            }
            if (coalPay==null){
                throw new BusinessException(this.getClass(),ResultConstants.BUSINESS_ERROR,"未找到相关缴费信息");
            }
            if (coalPayStudent.getPayStatus()==1){
                throw new BusinessException(this.getClass(),ResultConstants.BUSINESS_ERROR,"请勿重新缴费");
            }
            PayReqData payReqData = fillData(coalPayStudent,coalPay,coalCategories,coalTicket);
            ResultVo resultVo = payUtils.sendApiPost(payReqData);
            if (resultVo.getRespcode().equals("BUS0000")) {
                payStudent.setId(studentId);
                payStudent.setOrderId(resultVo.getRespdata().getOrderNo());
                payStudent.setGovPayStatus(1);
                payStudent.setPayCode(resultVo.getRespdata().getBillNo());
                coalPayStudentService.updateByCoalPayStudent(payStudent);
                return resultVo.getRespdata().getOrderId();
            } else {
                throw new BusinessException(this.getClass(), ResultConstants.BUSINESS_ERROR, "发起支付失败,请稍后重试");
            }
        } catch (BusinessException e) {
            throw new RuntimeException(e);
        } catch (IOException e) {
            throw new RuntimeException(e);
        } finally {
            if (lock.isLocked()) {
                lock.unlock();
            }
        }
    }
    private PayReqData fillData(CoalPayStudent coalPayStudent, CoalPay coalPay, List<CoalCategory> coalCategories, CoalTicket coalTicket) {
        PayReqData payReqData = new PayReqData();
        payReqData.setOrderNo(RandomUtil.generateOrderNumber(coalPayId, "CO"));
        payReqData.setOrderNo(RandomUtil.generateOrderNumber(coalPay.getId(), "CO"));
        payReqData.setMoney(coalPay.getAmount());
        payReqData.setAmount(1);
        payReqData.setPayerName(coalPayStudent.getName());
@@ -246,39 +293,7 @@
            feedatas.add(feedata);
        }
        payReqData.setFeeDatas(feedatas);
        return payReqData;
        CoalPayStudent payStudent = new CoalPayStudent();
        RLock lock = redissonClient.getLock("SWSPKMAS_PAY_PERSON_" + coalPayId);
        try {
            lock.lock(10, TimeUnit.SECONDS);
            if (coalPayStudent.getGovPayStatus() != 0) {
                throw new BusinessException(this.getClass(), ResultConstants.BUSINESS_ERROR, "请勿重复发起支付");
            }
            if (StringUtils.isEmpty(coalPayStudent.getPayCode())) {
            }
            ResultVo resultVo = payUtils.sendApiPost(payReqData);
            if (resultVo.getRespcode().equals("BUS0000")) {
                payStudent.setId(studentId);
                payStudent.setOrderId(resultVo.getRespdata().getOrderNo());
                payStudent.setGovPayStatus(1);
                payStudent.setPayCode(resultVo.getRespdata().getBillNo());
                coalPayStudentService.updateByCoalPayStudent(payStudent);
                return resultVo.getRespdata().getBillNo();
            } else {
                throw new BusinessException(this.getClass(), ResultConstants.BUSINESS_ERROR, "发起支付失败,请稍后重试");
            }
        } catch (BusinessException e) {
            throw new BusinessException(this.getClass(), ResultConstants.BUSINESS_ERROR, "请稍后重试");
        } catch (IOException e) {
            throw new RuntimeException(e);
        } finally {
            if (lock.isLocked()) {
                lock.unlock();
            }
        }
    }
}
exam-system/src/main/java/com/gkhy/exam/pay/service/impl/CoalPayStudentServiceImpl.java
@@ -146,4 +146,9 @@
    public CoalPayStudent selectbyId(Long studentId) {
        return coalPayStudentMapper.selectById(studentId);
    }
    @Override
    public void updateByCoalPayId(CoalPayStudent coalPayStudent) {
        coalPayStudentMapper.updateByCoalPayId(coalPayStudent);
    }
}
exam-system/src/main/java/com/gkhy/exam/pay/utils/PayUtils.java
@@ -65,11 +65,6 @@
    public ResultVo sendApiPost(PayReqData payReqData) throws IOException {
        //正式
        String proUrl = "http://finpt.xjcz.gov.cn/fs-service/fs-pay/invoice.do";
        //测试
        String testUrl = "http://finpt.xjcz.gov.cn/fs-service-test/fs-pay/invoice.do";
        Map<String, String> param = new HashMap<>();
        HttpPost httpPost = new HttpPost(orderUrl);
@@ -282,9 +277,6 @@
    //缴费结果查询
    public JSONObject query(String orderNo) throws IOException {
        String proUrl = "http://finpt.xjcz.gov.cn/fs-service/fs-pay/query.do";
        String testUrl = "http://finpt.xjcz.gov.cn/fs-service-test/fs-pay/query.do";
        HashMap<String, String> param = new HashMap<>();
        JSONObject jsonObject = new JSONObject();
exam-system/src/main/resources/mapper/pay/CoalPayStudentMapper.xml
@@ -76,6 +76,13 @@
        </trim>
        where id = #{id}
    </update>
    <update id="updateByCoalPayId">
        update coal_pay_student
        <trim prefix="SET" suffixOverrides=",">
            <if test="payType != null">pay_type = #{payType},</if>
        </trim>
        where coal_pay_id = #{coalPayId} and pay_status = 0
    </update>
    <select id="selectByCoalPayId" resultType="com.gkhy.exam.pay.entity.CoalPayStudent">
        <include refid="selectCoalPayStudentVo"></include>
ruoyi-common/src/main/java/com/ruoyi/common/utils/RandomUtil.java
@@ -48,7 +48,7 @@
        String datePart = new SimpleDateFormat("yyyyMMddhhmm").format(new Date());
        int randomPart = RANDOM.nextInt(90000) + 10000; // 生成5位随机数
        return ORDER_PER + datePart + String.format("%05d", randomPart) + dataId;
        return orderType + datePart + String.format("%05d", randomPart) + dataId;
    }
}