教育训练处考试制证系统后端
heheng
2025-05-19 c0895bccd7e54f867bbdf0f32d2fd04e97d0c223
修改
已修改7个文件
371 ■■■■ 文件已修改
exam-system/src/main/java/com/gkhy/exam/pay/controller/PaymentApiController.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
exam-system/src/main/java/com/gkhy/exam/pay/mapper/NonCoalPayStudentMapper.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
exam-system/src/main/java/com/gkhy/exam/pay/service/PaymentService.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
exam-system/src/main/java/com/gkhy/exam/pay/service/impl/PaymentServiceImpl.java 79 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
exam-system/src/main/java/com/gkhy/exam/pay/utils/SignDto.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
exam-system/src/main/resources/mapper/pay/NonCoalPayStudentMapper.xml 255 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/RuoYiApplication.java 13 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
exam-system/src/main/java/com/gkhy/exam/pay/controller/PaymentApiController.java
@@ -6,6 +6,7 @@
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@@ -55,6 +56,7 @@
    @GetMapping({"/confirm"})
    @ApiOperation("回调确认")
    @Anonymous
    public void notifyConfirm(String orderNo) {
        try {
            paymentService.notifyConfirm(orderNo);
@@ -62,4 +64,11 @@
            e.printStackTrace();
        }
    }
    @Scheduled(cron = "0 23 10 * * ? ")
    // @Scheduled(cron = "0 37 17 * * ?")
    public void checkWarning() {
        paymentService.schedulePayment();
    }
}
exam-system/src/main/java/com/gkhy/exam/pay/mapper/NonCoalPayStudentMapper.java
@@ -63,4 +63,7 @@
     * @return 结果
     */
    public int deleteNonCoalPayStudentByIds(Long[] ids);
    List<NonCoalPayStudent> getsch();
}
exam-system/src/main/java/com/gkhy/exam/pay/service/PaymentService.java
@@ -10,4 +10,7 @@
    void notifyConfirm(String orderNo);
    void paySuccess(String orderNo, Date payTime);
    void schedulePayment();
}
exam-system/src/main/java/com/gkhy/exam/pay/service/impl/PaymentServiceImpl.java
@@ -1,18 +1,27 @@
package com.gkhy.exam.pay.service.impl;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.gkhy.exam.pay.entity.CoalPayStudent;
import com.gkhy.exam.pay.entity.NonCoalPayStudent;
import com.gkhy.exam.pay.mapper.CoalPayStudentMapper;
import com.gkhy.exam.pay.mapper.NonCoalPayStudentMapper;
import com.gkhy.exam.pay.service.PaymentService;
import com.gkhy.exam.pay.utils.CaiZhengConstans;
import com.gkhy.exam.pay.utils.PayUtils;
import jar.org.apache.commons.codec.binary.Base64;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Date;
import java.util.List;
import static com.ruoyi.common.utils.Threads.sleep;
@Service
@Slf4j
@@ -33,6 +42,38 @@
            e.printStackTrace();
        }
        String reqdatastr1 = "{\"orderNo\": \"" + orderNo + "\"}";
        String mac1 = getMD5("A1749891493E4CDDBFE4506357B1F0AB||" + getBase64(reqdatastr1));
        JSONObject jsonObject1 = new JSONObject();
        jsonObject1.put("appid", "A1749891493E4CDDBFE4506357B1F0AB");
        jsonObject1.put("mac", mac1);
        jsonObject1.put("reqdata", getBase64(reqdatastr1));
        String resultStr1 = HttpUtil.post("http://finpt.xjcz.gov.cn/fs-service/fs-pay/notifyConfirm.do", jsonObject1);
        System.out.println("通知确定入参===" + jsonObject1);
        JSONObject result1 = JSONObject.parseObject(resultStr1);
        System.out.println("通知确定回参===" + result1);
    }
    public String getMD5(String input) {
        try {
            MessageDigest md = MessageDigest.getInstance("MD5");
            byte[] messageDigest = md.digest(input.getBytes());
            StringBuilder hexString = new StringBuilder();
            for (byte b : messageDigest) {
                hexString.append(String.format("%02x", new Object[]{Byte.valueOf(b)}));
            }
            return hexString.toString();
        } catch (NoSuchAlgorithmException e) {
            throw new RuntimeException(e);
        }
    }
    public String getBase64(String str) {
        String encodedStr = Base64.encodeBase64String(str.getBytes());
        return encodedStr;
    }
    @Override
@@ -56,5 +97,43 @@
    }
    @Override
    public void schedulePayment() {
        List<NonCoalPayStudent> nonCoalPayStudents = nonCoalPayStudentMapper.getsch();
        if (nonCoalPayStudents != null) {
            for (NonCoalPayStudent nonCoalPayStudent : nonCoalPayStudents) {
                sleep(5000);
                if (nonCoalPayStudent.getGovPayStatus() == 2 && nonCoalPayStudent.getPayStatus() == 0) {
                    try {
                        JSONObject result = payUtils.query(nonCoalPayStudent.getOrderNo());
                        log.info("查询财政订单返回结果:" + result);
                        String respcode = result.getString("respcode");
                        if (CaiZhengConstans.CAI_ZHENG_SUCCESS.equals(respcode)) {
                            JSONObject respdata = result.getJSONObject("respdata");
                            if (respdata != null && "1".equals(respdata.getString("status"))) {
                                nonCoalPayStudentMapper.update(null, Wrappers.<NonCoalPayStudent>lambdaUpdate()
                                        .set(NonCoalPayStudent::getPayStatus, 1)
                                        .set(NonCoalPayStudent::getPayTime, respdata.getDate("payTime"))
                                        .eq(NonCoalPayStudent::getOrderNo, nonCoalPayStudent.getOrderNo()).eq(NonCoalPayStudent::getDelFlag, 0)
                                        .eq(NonCoalPayStudent::getPayStatus, 0));
                                // 回调确认支付
                                nonCoalPayStudent.setPayStatus(1L);
                                payUtils.affirmPost(nonCoalPayStudent.getOrderNo());
                            } else {
                                log.error("查询财政订单失败:" + result.getString("respmsg") + ",错误编码:" + result.getString("respcode"));
                            }
                        }
                    } catch (Exception e) {
                        log.error("查询财政订单失败:" + e.getMessage());
                    }
                }
            }
        }
    }
}
exam-system/src/main/java/com/gkhy/exam/pay/utils/SignDto.java
@@ -2,6 +2,7 @@
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
public class SignDto {
@@ -14,13 +15,9 @@
    private static final String UTC_DATE_TIME = "dd MMM yyyy HH:mm:ss z";
    public static String formatWithTimeZone(Date date) {
        /* 48 */
        SimpleDateFormat sdf = new SimpleDateFormat();
        /* 49 */
        SimpleDateFormat sdf = new SimpleDateFormat("dd MMM yyyy HH:mm:ss z", Locale.CHINA);
        sdf.setTimeZone(TimeZone.getTimeZone("GMT+8"));
        /* 50 */
        sdf.applyPattern("dd MMM yyyy HH:mm:ss z");
        /* 51 */
        //  sdf.applyPattern("dd MMM yyyy HH:mm:ss z", Locale.CHINA);
        return sdf.format(date);
    }
exam-system/src/main/resources/mapper/pay/NonCoalPayStudentMapper.xml
@@ -3,7 +3,6 @@
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.gkhy.exam.pay.mapper.NonCoalPayStudentMapper">
    <resultMap type="NonCoalPayStudent" id="NonCoalPayStudentResult">
        <result property="id" column="id"/>
        <result property="nonCoalPayId" column="non_coal_pay_id"/>
@@ -55,14 +54,30 @@
        <include refid="selectNonCoalPayStudentVo"/>
        <where>
            and del_flag = 0
            <if test="nonCoalPayId != null ">and non_coal_pay_id = #{nonCoalPayId}</if>
            <if test="name != null  and name != ''">and name like concat('%', #{name}, '%')</if>
            <if test="idCard != null  and idCard != ''">and id_card = #{idCard}</if>
            <if test="phone != null  and phone != ''">and phone = #{phone}</if>
            <if test="sex != null ">and sex = #{sex}</if>
            <if test="payCode != null  and payCode != ''">and pay_code = #{payCode}</if>
            <if test="payStatus != null ">and pay_status = #{payStatus}</if>
            <if test="payType != null ">and pay_type = #{payType}</if>
            <if test="nonCoalPayId != null ">
                and non_coal_pay_id = #{nonCoalPayId}
            </if>
            <if test="name != null  and name != ''">
                and name like concat('%', #{name}, '%')
            </if>
            <if test="idCard != null  and idCard != ''">
                and id_card = #{idCard}
            </if>
            <if test="phone != null  and phone != ''">
                and phone = #{phone}
            </if>
            <if test="sex != null ">
                and sex = #{sex}
            </if>
            <if test="payCode != null  and payCode != ''">
                and pay_code = #{payCode}
            </if>
            <if test="payStatus != null ">
                and pay_status = #{payStatus}
            </if>
            <if test="payType != null ">
                and pay_type = #{payType}
            </if>
        </where>
        order by create_time desc
    </select>
@@ -75,42 +90,110 @@
    <insert id="insertNonCoalPayStudent" parameterType="NonCoalPayStudent">
        insert into non_coal_pay_student
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="nonCoalPayId != null">non_coal_pay_id,</if>
            <if test="name != null and name != ''">name,</if>
            <if test="idCard != null and idCard != ''">id_card,</if>
            <if test="phone != null and phone != ''">phone,</if>
            <if test="sex != null">sex,</if>
            <if test="govPayStatus!=null">gov_pay_status,</if>
            <if test="payCode != null">pay_code,</if>
            <if test="payType != null">pay_type,</if>
            <if test="orderNo != null and orderNo != '' ">order_no,</if>
            <if test="train != null and train != '' ">train,</if>
            <if test="payStatus != null">pay_status,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="id != null">
                id,
            </if>
            <if test="nonCoalPayId != null">
                non_coal_pay_id,
            </if>
            <if test="name != null and name != ''">
                name,
            </if>
            <if test="idCard != null and idCard != ''">
                id_card,
            </if>
            <if test="phone != null and phone != ''">
                phone,
            </if>
            <if test="sex != null">
                sex,
            </if>
            <if test="govPayStatus!=null">
                gov_pay_status,
            </if>
            <if test="payCode != null">
                pay_code,
            </if>
            <if test="payType != null">
                pay_type,
            </if>
            <if test="orderNo != null and orderNo != '' ">
                order_no,
            </if>
            <if test="train != null and train != '' ">
                train,
            </if>
            <if test="payStatus != null">
                pay_status,
            </if>
            <if test="updateBy != null">
                update_by,
            </if>
            <if test="updateTime != null">
                update_time,
            </if>
            <if test="createBy != null">
                create_by,
            </if>
            <if test="createTime != null">
                create_time,
            </if>
            <if test="delFlag != null">
                del_flag,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="nonCoalPayId != null">#{nonCoalPayId},</if>
            <if test="name != null and name != ''">#{name},</if>
            <if test="idCard != null and idCard != ''">#{idCard},</if>
            <if test="phone != null and phone != ''">#{phone},</if>
            <if test="sex != null">#{sex},</if>
            <if test="govPayStatus!=null">#{govPayStatus},</if>
            <if test="payCode != null">#{payCode},</if>
            <if test="payType != null">#{payType},</if>
            <if test="orderNo != null and orderNo != '' ">#{orderNo},</if>
            <if test="train != null and train != '' ">#{train},</if>
            <if test="payStatus != null">#{payStatus},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="id != null">
                #{id},
            </if>
            <if test="nonCoalPayId != null">
                #{nonCoalPayId},
            </if>
            <if test="name != null and name != ''">
                #{name},
            </if>
            <if test="idCard != null and idCard != ''">
                #{idCard},
            </if>
            <if test="phone != null and phone != ''">
                #{phone},
            </if>
            <if test="sex != null">
                #{sex},
            </if>
            <if test="govPayStatus!=null">
                #{govPayStatus},
            </if>
            <if test="payCode != null">
                #{payCode},
            </if>
            <if test="payType != null">
                #{payType},
            </if>
            <if test="orderNo != null and orderNo != '' ">
                #{orderNo},
            </if>
            <if test="train != null and train != '' ">
                #{train},
            </if>
            <if test="payStatus != null">
                #{payStatus},
            </if>
            <if test="updateBy != null">
                #{updateBy},
            </if>
            <if test="updateTime != null">
                #{updateTime},
            </if>
            <if test="createBy != null">
                #{createBy},
            </if>
            <if test="createTime != null">
                #{createTime},
            </if>
            <if test="delFlag != null">
                #{delFlag},
            </if>
        </trim>
    </insert>
@@ -122,28 +205,76 @@
          and pay_status = 0
          and order_no is null
    </update>
    <select id="getsch" resultMap="NonCoalPayStudentResult">
        select *
        from non_coal_pay_student
        where order_no is not null
          and pay_status = 0
          and pay_type = 1
          and update_time between '2025-02-28 00:00:00' and '2025-03-04 14:29:59'
    </select>
    <update id="updateNonCoalPayStudent" parameterType="NonCoalPayStudent">
        update non_coal_pay_student
        <trim prefix="SET" suffixOverrides=",">
            <if test="nonCoalPayId != null">non_coal_pay_id = #{nonCoalPayId},</if>
            <if test="name != null and name != ''">name = #{name},</if>
            <if test="idCard != null and idCard != ''">id_card = #{idCard},</if>
            <if test="phone != null and phone != ''">phone = #{phone},</if>
            <if test="sex != null">sex = #{sex},</if>
            <if test="orderNo != null and orderNo != ''">order_no = #{orderNo},</if>
            <if test="orderNo != null and orderNo != ''">order_no = #{orderNo},</if>
            <if test="train != null and train != ''">train = #{train},</if>
            <if test="govPayStatus!=null">gov_pay_status=#{govPayStatus},</if>
            <if test="fileData != null and fileData != ''">file_data = #{fileData},</if>
            <if test="payTime != null">pay_time = #{payTime},</if>
            <if test="payType != null">pay_type = #{payType},</if>
            <if test="payCode != null">pay_code = #{payCode},</if>
            <if test="payStatus != null">pay_status = #{payStatus},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="nonCoalPayId != null">
                non_coal_pay_id = #{nonCoalPayId},
            </if>
            <if test="name != null and name != ''">
                name = #{name},
            </if>
            <if test="idCard != null and idCard != ''">
                id_card = #{idCard},
            </if>
            <if test="phone != null and phone != ''">
                phone = #{phone},
            </if>
            <if test="sex != null">
                sex = #{sex},
            </if>
            <if test="orderNo != null and orderNo != ''">
                order_no = #{orderNo},
            </if>
            <if test="orderNo != null and orderNo != ''">
                order_no = #{orderNo},
            </if>
            <if test="train != null and train != ''">
                train = #{train},
            </if>
            <if test="govPayStatus!=null">
                gov_pay_status=#{govPayStatus},
            </if>
            <if test="fileData != null and fileData != ''">
                file_data = #{fileData},
            </if>
            <if test="payTime != null">
                pay_time = #{payTime},
            </if>
            <if test="payType != null">
                pay_type = #{payType},
            </if>
            <if test="payCode != null">
                pay_code = #{payCode},
            </if>
            <if test="payStatus != null">
                pay_status = #{payStatus},
            </if>
            <if test="updateBy != null">
                update_by = #{updateBy},
            </if>
            <if test="updateTime != null">
                update_time = #{updateTime},
            </if>
            <if test="createBy != null">
                create_by = #{createBy},
            </if>
            <if test="createTime != null">
                create_time = #{createTime},
            </if>
            <if test="delFlag != null">
                del_flag = #{delFlag},
            </if>
        </trim>
        where id = #{id}
    </update>
ruoyi-admin/src/main/java/com/ruoyi/RuoYiApplication.java
@@ -1,20 +1,19 @@
package com.ruoyi;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.scheduling.annotation.EnableScheduling;
/**
 * 启动程序
 *
 *
 * @author ruoyi
 */
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class },scanBasePackages = {"com.gkhy","com.ruoyi"})
public class RuoYiApplication
{
    public static void main(String[] args)
    {
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class}, scanBasePackages = {"com.gkhy", "com.ruoyi"})
@EnableScheduling
public class RuoYiApplication {
    public static void main(String[] args) {
        // System.setProperty("spring.devtools.restart.enabled", "false");
        SpringApplication.run(RuoYiApplication.class, args);
        System.out.println("(♥◠‿◠)ノ゙  若依启动成功   ლ(´ڡ`ლ)゙  \n" +