exam-system/src/main/java/com/gkhy/exam/pay/controller/PaymentApiController.java
@@ -55,7 +55,6 @@ @GetMapping({"/confirm"}) @ApiOperation("回调确认") @Anonymous public void notifyConfirm(String orderNo) { try { paymentService.notifyConfirm(orderNo); exam-system/src/main/java/com/gkhy/exam/pay/dto/rep/NonCoalStuRep.java
@@ -51,4 +51,7 @@ @ApiModelProperty("财政订单状态0未生成1生成中2已生成") private Long govPayStatus; @ApiModelProperty("财政缴款码") private String payCode; } exam-system/src/main/java/com/gkhy/exam/pay/dto/req/NonCoalPayStuImport.java
@@ -27,7 +27,7 @@ /** * 0男 1女 2未知 */ @Excel(name = "性别") @ApiModelProperty("性别 0男1女2未知") private String sex; @Excel(name = "培训机构(填机构名称 非必填)") @ApiModelProperty("培训机构(填机构名称 非必填)") private String train; } exam-system/src/main/java/com/gkhy/exam/pay/entity/NonCoalPayStudent.java
@@ -106,6 +106,9 @@ */ @ApiModelProperty("财政订单状态0未生成1生成中2已生成") private Integer govPayStatus; @ApiModelProperty("培训机构") private String train; /** * 删除标志(0代表存在2代表删除) */ @@ -249,4 +252,12 @@ public void setGovPayStatus(Integer govPayStatus) { this.govPayStatus = govPayStatus; } public String getTrain() { return train; } public void setTrain(String train) { this.train = train; } } exam-system/src/main/java/com/gkhy/exam/pay/service/impl/NonCoalPayStudentServiceImpl.java
@@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.gkhy.exam.institutionalaccess.enums.StudentSex; import com.gkhy.exam.pay.dto.rep.NonCoalCateRep; import com.gkhy.exam.pay.dto.rep.NonCoalPayOrder; import com.gkhy.exam.pay.dto.rep.NonCoalStuRep; @@ -16,8 +15,10 @@ import com.gkhy.exam.pay.mapper.NonCoalPayMapper; import com.gkhy.exam.pay.mapper.NonCoalPayStudentMapper; import com.gkhy.exam.pay.service.NonCoalPayStudentService; import com.gkhy.exam.pay.utils.CaiZhengConstans; import com.gkhy.exam.pay.utils.PayUtils; import com.gkhy.exam.pay.utils.ResultVo; import com.gkhy.exam.pay.utils.SexUtils; import com.ruoyi.common.constant.ResultConstants; import com.ruoyi.common.exception.BusinessException; import com.ruoyi.common.exception.ServiceException; @@ -54,18 +55,16 @@ @Autowired private RedisLock redisLock; private static final String NON_COAL_PAY_STUDENT_LOCK = "NON_COAL_PAY_STUDENT_LOCK_"; @Override public String sendOrder(Long dataId, String payType) { String lockKey = NON_COAL_PAY_STUDENT_LOCK + dataId + "_PAY_TYPE_" + payType; String lockKey = CaiZhengConstans.NON_COAL_PAY_STUDENT_LOCK + dataId + CaiZhengConstans.UN_COAL_ORDER_KEY_1 + payType; Boolean b = redisLock.tryLock(lockKey, 30, 40, TimeUnit.SECONDS); if (b) { String orderNo = RandomUtil.generateOrderNumber(dataId, "NC"); String orderNo = RandomUtil.generateOrderNumber(dataId, CaiZhengConstans.UN_COAL_ORDER_PERFIX); List<NonCoalPayOrder> nonCoalPayOrders = nonCoalPayMapper.selectNonCoalPayOrderByParam(dataId, Long.valueOf(payType), 1L); if (StringUtils.isEmpty(nonCoalPayOrders)) { throw new BusinessException(this.getClass(), ResultConstants.BUSINESS_ERROR, "未找到相关缴费信息"); @@ -117,7 +116,7 @@ try { ResultVo resultVo = payUtils.faqiV2(payReqData); log.info("调用接口返回结果:" + resultVo); if (resultVo.getRespcode().equals("BUS0000")) { if (resultVo.getRespcode().equals(CaiZhengConstans.CAI_ZHENG_SUCCESS)) { String orderId = resultVo.getRespdata().getOrderId(); String billNo = resultVo.getRespdata().getBillNo(); if (StringUtils.isNotEmpty(orderId)) { @@ -183,7 +182,7 @@ JSONObject result = payUtils.query(nonCoalStuRep.getOrderNo()); log.info("查询财政订单返回结果:" + result); String respcode = result.getString("respcode"); if ("BUS0000".equals(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() @@ -191,6 +190,8 @@ .set(NonCoalPayStudent::getPayTime, respdata.getDate("payTime")) .eq(NonCoalPayStudent::getOrderNo, nonCoalStuRep.getOrderNo()).eq(NonCoalPayStudent::getDelFlag, 0) .eq(NonCoalPayStudent::getPayStatus, 0)); // 回调确认支付 payUtils.affirmPost(nonCoalStuRep.getOrderNo()); } else { log.error("查询财政订单失败:" + result.getString("respmsg") + ",错误编码:" + result.getString("respcode")); } @@ -410,7 +411,7 @@ StringBuilder failureMsg = new StringBuilder(); for (NonCoalPayStuImport stu : nonCoalPayStudents) { try { if (StringUtils.isEmpty(stu.getIdCard()) || StringUtils.isEmpty(stu.getName()) || StringUtils.isEmpty(stu.getPhone()) || stu.getSex() == null) { if (StringUtils.isEmpty(stu.getIdCard()) || StringUtils.isEmpty(stu.getName()) || StringUtils.isEmpty(stu.getPhone())) { failureMsg.append("<br/>" + failureNum + "、导入数据为空: " + stu.getIdCard() + " 数据错误"); } else if (idCardToNameMap.get(stu.getIdCard().trim()) != null) { failureMsg.append("<br/>" + failureNum + "、身份证号: " + stu.getIdCard() + " 数据已存在"); @@ -423,9 +424,10 @@ stu1.setName(stu.getName()); stu1.setIdCard(stu.getIdCard()); stu1.setPhone(stu.getPhone()); // stu1.setOrderNo(RandomUtil.generateOrderNumber()); stu1.setSex(StudentSex.BOY.getDesc().equals(stu.getSex().trim()) ? 0L : 1L); if (StringUtils.isNotEmpty(stu.getTrain())) { stu1.setTrain(stu.getTrain()); } stu1.setSex(SexUtils.sexType(stu.getIdCard())); nonCoalPayStudentMapper.insertNonCoalPayStudent(stu1); successNum++; successMsg.append("<br/>" + successNum + "、身份证号 " + stu.getIdCard() + " 导入成功"); exam-system/src/main/java/com/gkhy/exam/pay/utils/CaiZhengConstans.java
对比新文件 @@ -0,0 +1,9 @@ package com.gkhy.exam.pay.utils; public class CaiZhengConstans { public static final String UN_COAL_ORDER_PERFIX = "NC"; public static final String NON_COAL_PAY_STUDENT_LOCK = "NON_COAL_PAY_STUDENT_LOCK_"; public static final String UN_COAL_ORDER_KEY_1 = "_PAY_TYPE_"; public static final String CAI_ZHENG_SUCCESS = "BUS0000"; } exam-system/src/main/java/com/gkhy/exam/pay/utils/PayUtils.java
@@ -311,7 +311,7 @@ String stringContent = execute.getStringContent(); ResultVo resultVo = JSONObject.parseObject(stringContent, ResultVo.class); log.info("请求结果为:" + resultVo); if (resultVo.getRespcode().equals("BUS0000")) { if (resultVo.getRespcode().equals(CaiZhengConstans.CAI_ZHENG_SUCCESS)) { return "success"; } return "fail"; @@ -598,7 +598,7 @@ BillClient billClient = ClientFactory.getBillClient(); ResponseDataVo<UploadXmlReponseDataVo> dataRes = billClient.uploadXml(signatureFile); if (!dataRes.getRespcode().equals("BUS0000")) { if (!dataRes.getRespcode().equals(CaiZhengConstans.CAI_ZHENG_SUCCESS)) { log.info("上传验签失败:" + dataRes); return false; } exam-system/src/main/java/com/gkhy/exam/pay/utils/SexUtils.java
对比新文件 @@ -0,0 +1,11 @@ package com.gkhy.exam.pay.utils; public class SexUtils { public static Long sexType(String idCard) { //如果身份证号的倒数第二位是偶数,则性别为女(1L) //如果身份证号的倒数第二位是奇数,则性别为男(0L) idCard = idCard.trim(); return (idCard.charAt(idCard.length() - 2) - '0') % 2 == 0 ? 1L : 0L; } } exam-system/src/main/resources/mapper/pay/NonCoalPayMapper.xml
@@ -239,6 +239,7 @@ <result property="orderId" column="order_id"/> <result property="orderNo" column="order_no"/> <result property="govPayStatus" column="gov_pay_status"/> <result property="payCode" column="pay_code"/> </resultMap> @@ -267,7 +268,8 @@ t.pay_status, t.order_id, t.gov_pay_status, t.order_no t.order_no, t.pay_code from non_coal_pay a inner join non_coal_pay_student t on t.non_coal_pay_id = a.id and t.del_flag = 0 <if test="isPay != null and isPay == 1 ">and t.pay_status = 0</if> exam-system/src/main/resources/mapper/pay/NonCoalPayStudentMapper.xml
@@ -24,6 +24,7 @@ <result property="fileData" column="file_data"/> <result property="payTime" column="pay_time"/> <result property="govPayStatus" column="gov_pay_status"/> <result property="train" column="train"/> </resultMap> <sql id="selectNonCoalPayStudentVo"> @@ -45,7 +46,8 @@ order_id, file_data, pay_time, gov_pay_status gov_pay_status, train from non_coal_pay_student </sql> @@ -83,6 +85,7 @@ <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> @@ -101,6 +104,7 @@ <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> @@ -126,7 +130,8 @@ <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="orderId != null and orderId != ''">order_id = #{orderId},</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>