教育训练处考试制证系统后端
“djh”
2025-01-24 5a88c770debe086dd82ab5ce8a4c957a3debdae7
煤矿缴费修改
已修改11个文件
已添加1个文件
201 ■■■■ 文件已修改
exam-system/src/main/java/com/gkhy/exam/pay/controller/CoalPayController.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
exam-system/src/main/java/com/gkhy/exam/pay/dto/req/CoalTeamPayReq.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
exam-system/src/main/java/com/gkhy/exam/pay/entity/CoalPay.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
exam-system/src/main/java/com/gkhy/exam/pay/mapper/CoalPayStudentMapper.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
exam-system/src/main/java/com/gkhy/exam/pay/service/CoalPayService.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
exam-system/src/main/java/com/gkhy/exam/pay/service/CoalPayStudentService.java 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
exam-system/src/main/java/com/gkhy/exam/pay/service/impl/CoalPayServiceImpl.java 89 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
exam-system/src/main/java/com/gkhy/exam/pay/service/impl/CoalPayStudentServiceImpl.java 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
exam-system/src/main/java/com/gkhy/exam/pay/utils/PayUtils.java 40 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
exam-system/src/main/resources/mapper/pay/CoalPayStudentMapper.xml 17 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/resources/application-dev.yml 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/resources/application-pro.yml 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
exam-system/src/main/java/com/gkhy/exam/pay/controller/CoalPayController.java
@@ -2,10 +2,7 @@
import com.gkhy.exam.pay.dto.rep.CoalPayRepDto;
import com.gkhy.exam.pay.dto.rep.CoalPayStudentRep;
import com.gkhy.exam.pay.dto.req.CoalPayDto;
import com.gkhy.exam.pay.dto.req.CoalPayReq;
import com.gkhy.exam.pay.dto.req.CoalPayStudentReq;
import com.gkhy.exam.pay.dto.req.CoalPayTypeReq;
import com.gkhy.exam.pay.dto.req.*;
import com.gkhy.exam.pay.entity.CoalPayStudent;
import com.gkhy.exam.pay.service.CoalPayService;
import com.ruoyi.common.annotation.Anonymous;
@@ -97,13 +94,20 @@
        return success(coalPayStudentReps);
    }
    @PostMapping("/personPay")
    @GetMapping("/personPay")
    @ApiOperation(value = "个人缴费接口")
    @Anonymous
    public AjaxResult payMoney(@RequestParam("coalPayId") Long coalPayId,@RequestParam("studentId") Long studentId){
        return success(coalPayService.personPayMoney(coalPayId,studentId));
    }
    @PostMapping("/teamPay")
    @Anonymous
    @ApiOperation(value = "批量缴费")
    public AjaxResult teamMoney(@RequestBody CoalTeamPayReq coalTeamPayReq){
        return success(coalPayService.teamPayMoney(coalTeamPayReq));
    }
exam-system/src/main/java/com/gkhy/exam/pay/dto/req/CoalTeamPayReq.java
对比新文件
@@ -0,0 +1,12 @@
package com.gkhy.exam.pay.dto.req;
import lombok.Data;
@Data
public class CoalTeamPayReq {
    private Long coalPayId;
    private Integer payPersonType;
    private String payCompanyName;
    private String payCompanyCard;
}
exam-system/src/main/java/com/gkhy/exam/pay/entity/CoalPay.java
@@ -83,7 +83,7 @@
     * 缴款单位名称
     */
    @Excel(name = "缴款单位名称")
    @ApiModelProperty("缴款单位证件号")
    @ApiModelProperty("缴款单位名称")
    private String payCompanyName;
    /**
exam-system/src/main/java/com/gkhy/exam/pay/mapper/CoalPayStudentMapper.java
@@ -25,4 +25,5 @@
    void updateByCoalPayId(CoalPayStudent coalPayStudent);
    void updateByCoalPayIdAndStatus(CoalPayStudent payStudent);
}
exam-system/src/main/java/com/gkhy/exam/pay/service/CoalPayService.java
@@ -3,10 +3,7 @@
import com.baomidou.mybatisplus.extension.service.IService;
import com.gkhy.exam.pay.dto.rep.CoalPayRepDto;
import com.gkhy.exam.pay.dto.rep.CoalPayStudentRep;
import com.gkhy.exam.pay.dto.req.CoalPayDto;
import com.gkhy.exam.pay.dto.req.CoalPayReq;
import com.gkhy.exam.pay.dto.req.CoalPayStudentReq;
import com.gkhy.exam.pay.dto.req.CoalPayTypeReq;
import com.gkhy.exam.pay.dto.req.*;
import com.gkhy.exam.pay.entity.CoalPay;
import com.gkhy.exam.pay.entity.CoalPayStudent;
import com.ruoyi.common.core.domain.AjaxResult;
@@ -29,4 +26,6 @@
    int updateCoalPayType(CoalPayTypeReq coalPayDto);
    String personPayMoney(Long coalPayId, Long studentId);
    String teamPayMoney(CoalTeamPayReq coalTeamPayReq);
}
exam-system/src/main/java/com/gkhy/exam/pay/service/CoalPayStudentService.java
@@ -27,7 +27,9 @@
    List<CoalPayStudent> selectbyIdcard(CoalPayStudentReq coalPayStudent);
    CoalPayStudent selectbyId(Long studentId);
    List<CoalPayStudent> selectbyId(Long studentId);
    void updateByCoalPayId(CoalPayStudent coalPayStudent);
    void updateByCoalPayIdAndStatus(CoalPayStudent payStudent);
}
exam-system/src/main/java/com/gkhy/exam/pay/service/impl/CoalPayServiceImpl.java
@@ -3,10 +3,7 @@
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gkhy.exam.pay.dto.rep.CoalPayRepDto;
import com.gkhy.exam.pay.dto.rep.CoalPayStudentRep;
import com.gkhy.exam.pay.dto.req.CoalPayDto;
import com.gkhy.exam.pay.dto.req.CoalPayReq;
import com.gkhy.exam.pay.dto.req.CoalPayStudentReq;
import com.gkhy.exam.pay.dto.req.CoalPayTypeReq;
import com.gkhy.exam.pay.dto.req.*;
import com.gkhy.exam.pay.entity.*;
import com.gkhy.exam.pay.mapper.CoalCategoryMapper;
import com.gkhy.exam.pay.mapper.CoalPayCategoryMapper;
@@ -32,6 +29,7 @@
import javax.annotation.Resource;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@@ -228,25 +226,26 @@
    public String personPayMoney(Long coalPayId, Long studentId) {
        CoalPayStudent payStudent = new CoalPayStudent();
        RLock lock = redissonClient.getLock("SWSPKMAS_PAY_PERSON_" + coalPayId);
        RLock lock = redissonClient.getLock("SWSPKMAS_PAY_PERSON_" + studentId);
        try {
            lock.lock(10, TimeUnit.SECONDS);
            CoalPayStudent coalPayStudent = coalPayStudentService.selectbyId(studentId);
            List<CoalPayStudent> coalPayStudent = coalPayStudentService.selectbyId(studentId);
            CoalPayStudent student = coalPayStudent.get(0);
            CoalPay coalPay = coalPayMapper.selectById(coalPayId);
            List<CoalCategory> coalCategories = coalCategoryMapper.selectByCoalPayId(coalPayId);
            CoalTicket coalTicket = coalCategoryMapper.selectCoalTicket();
            if (coalPayStudent==null){
            if (CollectionUtils.isEmpty(coalPayStudent)){
                throw new BusinessException(this.getClass(),ResultConstants.BUSINESS_ERROR,"缴费学员不存在");
            }
            if (coalPay==null){
                throw new BusinessException(this.getClass(),ResultConstants.BUSINESS_ERROR,"未找到相关缴费信息");
            }
            if (coalPayStudent.getPayStatus()==1){
            if (student.getPayStatus()==1){
                throw new BusinessException(this.getClass(),ResultConstants.BUSINESS_ERROR,"请勿重新缴费");
            }
            PayReqData payReqData = fillData(coalPayStudent,coalPay,coalCategories,coalTicket);
            PayReqData payReqData = fillData(coalPayStudent,coalPay,coalCategories,coalTicket,1,null);
            ResultVo resultVo = payUtils.sendApiPost(payReqData);
            if (resultVo.getRespcode().equals("BUS0000")) {
@@ -257,7 +256,7 @@
                coalPayStudentService.updateByCoalPayStudent(payStudent);
                return resultVo.getRespdata().getOrderId();
            } else {
                throw new BusinessException(this.getClass(), ResultConstants.BUSINESS_ERROR, "发起支付失败,请稍后重试");
                throw new BusinessException(this.getClass(), ResultConstants.BUSINESS_ERROR, resultVo.getRespmsg());
            }
        } catch (BusinessException e) {
            throw new RuntimeException(e);
@@ -270,29 +269,77 @@
        }
    }
    private PayReqData fillData(CoalPayStudent coalPayStudent, CoalPay coalPay, List<CoalCategory> coalCategories, CoalTicket coalTicket) {
    @Override
    public String teamPayMoney(CoalTeamPayReq coalTeamPayReq) {
        RLock lock = redissonClient.getLock("SWSPKMAS_TEAM_PAY_" + coalTeamPayReq.getCoalPayId());
        try {
            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 (coalPay==null){
                throw new BusinessException(this.getClass(),ResultConstants.BUSINESS_ERROR,"未找到相关缴费信息");
            }
            CoalPayStudent payStudent = new CoalPayStudent();
            PayReqData payReqData = fillData(coalPayStudents, coalPay, coalCategories, coalTicket,2,coalTeamPayReq);
            ResultVo resultVo = payUtils.sendApiPost(payReqData);
            if (resultVo.getRespcode().equals("BUS0000")) {
                payStudent.setCoalPayId(coalPay.getId());
                payStudent.setOrderId(resultVo.getRespdata().getOrderNo());
                payStudent.setGovPayStatus(1);
                payStudent.setPayCode(resultVo.getRespdata().getBillNo());
                coalPayStudentService.updateByCoalPayIdAndStatus(payStudent);
                return resultVo.getRespdata().getOrderId();
            } else {
                throw new BusinessException(this.getClass(), ResultConstants.BUSINESS_ERROR, "发起支付失败,请稍后重试");
            }
        }catch (Exception e){
            throw new RuntimeException(e);
        }finally {
            if (lock.isLocked()) {
                lock.unlock();
            }
        }
    }
    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());
        payReqData.setAmount(1);
        payReqData.setPayerName(coalPayStudent.getName());
        payReqData.setCertNo(coalPayStudent.getIdCard());
        payReqData.setPayerType(1);
        payReqData.setMoney(coalPay.getAmount().multiply(BigDecimal.valueOf(coalPayStudent.size())));
        payReqData.setAmount(coalCategories.size()*coalPayStudent.size());
        payReqData.setInvoiceSocialCode(coalTicket.getTicketCompanyCode());
        payReqData.setHandlingPerson(coalTicket.getDrawer());
        payReqData.setChecker(coalTicket.getCheck());
        payReqData.setEnterCode(coalTicket.getCompanyCode());
        payReqData.setDesc(coalPay.getBatchName());
        PayReqData.Feedata feedata = new PayReqData.Feedata();
        List<PayReqData.Feedata> feedatas = new ArrayList<>();
        for (CoalCategory coalCategory : coalCategories) {
            feedata.setAmount(1);
            feedata.setPrice(coalCategory.getAmount());
            feedata.setBusCode(coalCategory.getBusinessCode());
            feedatas.add(feedata);
            for (CoalPayStudent payStudent : coalPayStudent) {
                PayReqData.Feedata feedata = new PayReqData.Feedata();
                feedata.setAmount(1);
                feedata.setPrice(coalCategory.getAmount());
                feedata.setBusCode(coalCategory.getBusinessCode());
                feedatas.add(feedata);
            }
        }
        payReqData.setFeeDatas(feedatas);
        if (1==payType){
            payReqData.setPayerName(coalPayStudent.get(0).getName());
            payReqData.setCertNo(coalPayStudent.get(0).getIdCard());
            payReqData.setPayerType(1);
        }else if (2==payType){
            payReqData.setPayerName(coalTeamPayReq.getPayCompanyName());
            payReqData.setCertNo(coalTeamPayReq.getPayCompanyCard());
            payReqData.setPayerType(2);
        }
        return payReqData;
    }
exam-system/src/main/java/com/gkhy/exam/pay/service/impl/CoalPayStudentServiceImpl.java
@@ -143,12 +143,19 @@
    }
    @Override
    public CoalPayStudent selectbyId(Long studentId) {
        return coalPayStudentMapper.selectById(studentId);
    public List<CoalPayStudent> selectbyId(Long studentId) {
        List<Long> longs = new ArrayList<>();
        longs.add(studentId);
        return coalPayStudentMapper.selectBatchIds(longs);
    }
    @Override
    public void updateByCoalPayId(CoalPayStudent coalPayStudent) {
        coalPayStudentMapper.updateByCoalPayId(coalPayStudent);
    }
    @Override
    public void updateByCoalPayIdAndStatus(CoalPayStudent payStudent) {
        coalPayStudentMapper.updateByCoalPayIdAndStatus(payStudent);
    }
}
exam-system/src/main/java/com/gkhy/exam/pay/utils/PayUtils.java
@@ -30,6 +30,7 @@
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import javax.net.ssl.SSLContext;
@@ -63,6 +64,15 @@
    @Value("${finance.apiId}")
    private String appId;
    @Value("${finance.queryUrl}")
    private String queryUrl;
    /**
     * 请求开票,发起支付
     * @param payReqData
     * @return
     * @throws IOException
     */
    public ResultVo sendApiPost(PayReqData payReqData) throws IOException {
        Map<String, String> param = new HashMap<>();
@@ -85,6 +95,7 @@
        return resultVo;
    }
    //组装请求体
    private static UrlEncodedFormEntity assemblyFormEntity(Map<String, String> parameters, String charset) {
        List<NameValuePair> formParameters = assemblyParameter(parameters);
        UrlEncodedFormEntity formEntity = null;
@@ -120,6 +131,7 @@
    }
    //在调用SSL之前需要重写验证方法,取消检测SSL 创建ConnectionManager,添加Connection配置信息
    private static HttpClient sslClient() {
        try {
            // 在调用SSL之前需要重写验证方法,取消检测SSL
@@ -162,6 +174,7 @@
    }
    //获取响应结果处理器,将响应结果封装为HttpResult对象
    private static ResponseHandler<HttpResultVo> getResponseHandler() {
        ResponseHandler<HttpResultVo> responseHandler = new ResponseHandler<HttpResultVo>() {
            @Override
@@ -202,6 +215,7 @@
        return responseHandler;
    }
    //判断相应内容是否为文本类型
    private static boolean isTextType(ContentType contentType) {
        if (contentType == null) {
            throw new RuntimeException("ContentType is null");
@@ -297,4 +311,30 @@
        log.info("请求结果json为:" + result);
        return result;
    }
    //票据查询
    public ResponseEntity<String> findBill(String billNO) throws IOException {
        Map<String, String> params = new HashMap<>();
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("billNo",billNO);
        String reqdata = Base64.getEncoder().encodeToString(jsonObject.toJSONString().getBytes());
        String mac = appId+"||"+reqdata;
        mac = DigestUtils.md5Hex(mac.getBytes());
        params.put("appid",appId);
        params.put("reqdata",reqdata);
        params.put("mac",mac);
        HttpPost httpPost = new HttpPost(queryUrl);
        httpPost.setEntity(assemblyFormEntity(params,"utf-8"));
        HttpClient httpClient = getHttpClient(queryUrl);
        HttpResultVo execute = httpClient.execute(httpPost, getResponseHandler());
        String stringContent = execute.getStringContent();
        JSONObject jsonObject1 = JSONObject.parseObject(stringContent);
        log.info("请求结果转json后为:"+jsonObject1);
        String result = (String) jsonObject1.get("reqdata");
        return ResponseEntity.ok(result);
    }
}
exam-system/src/main/resources/mapper/pay/CoalPayStudentMapper.xml
@@ -83,6 +83,13 @@
        </trim>
        where coal_pay_id = #{coalPayId} and pay_status = 0
    </update>
    <update id="updateByCoalPayIdAndStatus">
        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>
@@ -92,8 +99,14 @@
    <select id="selectByCoalPayIdAndPayStatus" resultType="com.gkhy.exam.pay.entity.CoalPayStudent">
        <include refid="selectCoalPayStudentVo"></include>
        where coal_pay_id = #{id} and pay_status = #{status}
            and del_flag =0
        <where>
            <if test="status == 0">
                and pay_type = 2
            </if>
                and coal_pay_id = #{id}
                and pay_status = #{status}
                and del_flag =0
        </where>
    </select>
    <select id="selectByIds" resultType="com.gkhy.exam.pay.entity.CoalPayStudent">
ruoyi-admin/src/main/resources/application-dev.yml
@@ -137,3 +137,4 @@
  orderUrl: http://finpt.xjcz.gov.cn/fs-service-test/fs-pay/invoice.do
  payNotifyUrl: http://finpt.xjcz.gov.cn/fs-service-test/fs-pay/notifyConfirm.do
  payQueryUrl: http://finpt.xjcz.gov.cn/fs-service/fs-pay/query.do
  queryUrl: http://finpt.xjcz.gov.cn/fs-service-test/fs-pay/queryFile.do
ruoyi-admin/src/main/resources/application-pro.yml
@@ -135,4 +135,5 @@
  apiId: ED76A5F1703540BE977D34780B371FEB
  orderUrl: http://finpt.xjcz.gov.cn/fs-service/fs-pay/invoice.do
  payNotifyUrl: http://finpt.xjcz.gov.cn/fs-service/fs-pay/notifyConfirm.do
  payQueryUrl: http://finpt.xjcz.gov.cn/fs-service-test/fs-pay/query.do
  payQueryUrl: http://finpt.xjcz.gov.cn/fs-service-test/fs-pay/query.do
  queryUrl: http://finpt.xjcz.gov.cn/fs-service/fs-pay/queryFile.do