考试预约到期状态修改
This commit is contained in:
parent
f92a088959
commit
039b29a8cf
@ -58,10 +58,10 @@ public class AppletExamRegistrationController extends BaseController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 模拟考试列表,查询所有的模拟考试,返回是否已购买标识
|
||||
* 模拟考试列表
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "模拟考试列表,查询所有的模拟考试,返回是否已购买标识")
|
||||
@ApiOperation(value = "模拟考试列表")
|
||||
@RequestMapping(value = "/getMockExamList", method = { RequestMethod.POST})
|
||||
public ApiRest getMockExamList(@RequestBody PagingReqDTO<ExamRegistrationDTO> reqDTO) {
|
||||
//分页查询并转换
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.yf.exam.modules.exam.dto;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.yf.exam.modules.exam.entity.UserAttachment;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
@ -101,6 +102,12 @@ public class ExamRegistrationDTO extends UserAttachment implements Serializable
|
||||
*/
|
||||
private BigDecimal examFee;
|
||||
|
||||
/**
|
||||
* 模拟考试有效期
|
||||
*/
|
||||
@TableField("expiration_date")
|
||||
private BigDecimal expirationDate;
|
||||
|
||||
/**
|
||||
* 交费开始时间
|
||||
* */
|
||||
|
||||
@ -71,6 +71,9 @@ public class ExamRegistrationVO {
|
||||
@ApiModelProperty(value = "交费时间", required=true)
|
||||
private Date paymentDate;
|
||||
|
||||
@ApiModelProperty(value = "到期状态,true:到期,false:未到期", required=true)
|
||||
private Boolean expirationState;
|
||||
|
||||
@ApiModelProperty(value = "考试主键", required=true)
|
||||
private String examId;
|
||||
|
||||
|
||||
@ -85,7 +85,19 @@ public class ExamRegistration extends UserAttachment {
|
||||
private BigDecimal examFee;
|
||||
|
||||
/**
|
||||
* 交费状态,待付款:WAIT_PAY,已付款:PAY,已取消:CANCEL,待收货:WAIT_RECEIVED_GOODS,已收货:RECEIVED_GOODS,退款中:WAIT_REFUND,已退款:REFUNDED,待退货:WAIT_RETURNED_GOODS,已退货:RETURNED_GOODS
|
||||
* 模拟考试有效期
|
||||
*/
|
||||
@TableField("expiration_date")
|
||||
private BigDecimal expirationDate;
|
||||
|
||||
/**
|
||||
* 到期状态,true:到期,false:未到期
|
||||
*/
|
||||
@TableField("expiration_state")
|
||||
private Boolean expirationState;
|
||||
|
||||
/**
|
||||
* 交费状态,待付款:WAIT_PAY,已付款:PAY,已取消:CANCEL,退款中:WAIT_REFUND,已退款:REFUNDED
|
||||
*/
|
||||
private String paymentState;
|
||||
|
||||
|
||||
@ -50,4 +50,5 @@ public interface ExamRegistrationMapper extends BaseMapper<ExamRegistration> {
|
||||
* @return 更新数量
|
||||
*/
|
||||
int updateBatchPaymentState(@Param("ids") List<String> ids, @Param("paymentState") String paymentState);
|
||||
|
||||
}
|
||||
|
||||
@ -65,6 +65,7 @@ public class ExamRegistrationServiceImpl extends ServiceImpl<ExamRegistrationMap
|
||||
entity.setOrderTime(LocalDateTime.now());
|
||||
entity.setPaymentState(GooodsOrderStatusEnum.WAIT_PAY.getInfo());
|
||||
entity.setFinishState(ExamFinishState.UNFINISH);
|
||||
entity.setExpirationState(true);
|
||||
if (reqDTO.getExamType() == 1) {
|
||||
entity.setRegTime(LocalDate.now());
|
||||
}
|
||||
|
||||
@ -0,0 +1,15 @@
|
||||
package com.yf.exam.modules.quartz.controller;
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @description: 修改考试有效状态定时任务
|
||||
* @author: haown
|
||||
* @create: 2025-08-26 16:22
|
||||
**/
|
||||
@RestController
|
||||
@RequestMapping("/monitor/payTask")
|
||||
public class ExamRegistrationTaskController {
|
||||
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
package com.yf.exam.modules.quartz.service;
|
||||
/**
|
||||
* @description 考试预约定时任务业务层
|
||||
* @Author haown
|
||||
* @Date 2025-8-26 16:30
|
||||
*/
|
||||
public interface ExamRegistrationTaskService {
|
||||
|
||||
/**
|
||||
* 自动修改考试预约到期状态
|
||||
*
|
||||
*/
|
||||
void updateExpirationState();
|
||||
}
|
||||
@ -0,0 +1,46 @@
|
||||
package com.yf.exam.modules.quartz.service.impl;
|
||||
|
||||
import com.yf.exam.core.enums.GooodsOrderStatusEnum;
|
||||
import com.yf.exam.modules.exam.dto.ExamRegistrationDTO;
|
||||
import com.yf.exam.modules.exam.dto.response.ExamRegistrationVO;
|
||||
import com.yf.exam.modules.exam.entity.ExamRegistration;
|
||||
import com.yf.exam.modules.exam.mapper.ExamRegistrationMapper;
|
||||
import com.yf.exam.modules.quartz.service.ExamRegistrationTaskService;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @description: 考试预约定时任务实现类
|
||||
* @author: haown
|
||||
* @create: 2025-08-26 16:31
|
||||
**/
|
||||
public class ExamRegistrationTaskServiceImpl implements ExamRegistrationTaskService {
|
||||
|
||||
@Resource
|
||||
private ExamRegistrationMapper examRegistrationMapper;
|
||||
|
||||
@Override
|
||||
public void updateExpirationState() {
|
||||
// 查询已经预约成功的模拟考试列表
|
||||
ExamRegistrationDTO examRegistrationDTO = new ExamRegistrationDTO();
|
||||
examRegistrationDTO.setPaymentStates(GooodsOrderStatusEnum.PAY.getInfo()+ "," + GooodsOrderStatusEnum.WAIT_REFUND.getInfo());
|
||||
examRegistrationDTO.setExamType(1);
|
||||
List<ExamRegistrationVO> goodsOrderList = examRegistrationMapper.getRegExamList(examRegistrationDTO);
|
||||
// 计算是否到期
|
||||
goodsOrderList.forEach(order -> {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(order.getPaymentDate());
|
||||
calendar.add(Calendar.DAY_OF_MONTH, order.getExpirationDate().intValue());
|
||||
Date expirationEndDate = calendar.getTime();
|
||||
if (expirationEndDate.before(new Date())) {
|
||||
// 有效期截至日期在当天之前
|
||||
ExamRegistration examRegistration = new ExamRegistration();
|
||||
examRegistration.setId(order.getId());
|
||||
examRegistration.setExpirationState(true);
|
||||
examRegistrationMapper.updateById(examRegistration);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -1,15 +1,33 @@
|
||||
package com.yf.exam.modules.quartz.task;
|
||||
|
||||
import com.yf.exam.modules.quartz.service.ExamRegistrationTaskService;
|
||||
import javax.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @description: 考试报名定时任务,模拟考试到期后,自动关闭订单
|
||||
* @author: haown
|
||||
* @create: 2025-08-25 10:25
|
||||
**/
|
||||
* @Description 考试有效期到期后,自动修改有效状态
|
||||
* @Author haown
|
||||
* @Date 2022-10-21 14:34:36
|
||||
* @Version 1.0
|
||||
*/
|
||||
@Slf4j
|
||||
@Component("examRegistrationTask")
|
||||
public class ExamRegistrationTask {
|
||||
|
||||
@Resource
|
||||
private ExamRegistrationTaskService examRegistrationTaskService;
|
||||
|
||||
/**
|
||||
* 考试有效期到期后,自动修改到期状态,每天晚上12点执行
|
||||
*
|
||||
*/
|
||||
@Scheduled(cron = "0 30 0 * * ?")
|
||||
public void updateExpirationStateTask() {
|
||||
log.info("开始执行自动修改到期状态定时任务......");
|
||||
examRegistrationTaskService.updateExpirationState();
|
||||
log.info("完成自动修改到期状态定时任务......");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -44,7 +44,7 @@
|
||||
|
||||
|
||||
<select id="getRegExamList" resultType="com.yf.exam.modules.exam.dto.response.ExamRegistrationVO">
|
||||
SELECT reg.id, reg.user_id as userId, reg.reg_time, reg.payment_state, reg.payment_date, reg.finish_state, ex.id as examId, ex.title, ex.content
|
||||
SELECT reg.id, reg.user_id as userId, reg.reg_time, reg.payment_state, reg.payment_date, reg.finish_state,reg.expiration_state, ex.id as examId, ex.title, ex.content
|
||||
, ex.exam_type, ex.start_date, ex.end_date, ex.start_time, ex.end_time
|
||||
,ex.total_score, ex.total_time, ex.qualify_score, ex.exam_fee, DATEDIFF(ex.start_date, now()) >= 2 as daysAllow, ex.expiration_date
|
||||
FROM el_exam_registration reg
|
||||
@ -173,7 +173,7 @@
|
||||
,ex.total_score, ex.total_time, ex.qualify_score, ex.exam_fee,ex.expiration_date,
|
||||
reg.id as id, reg.user_id as userId, reg.user_name, reg.real_name, reg.phone, reg.payment_state, reg.finish_state
|
||||
FROM el_exam ex
|
||||
left join (select * from el_exam_registration where user_id = #{query.userId} and (payment_state = 'PAY' or payment_state = 'WAIT_REFUND')) reg on reg.exam_id = ex.id
|
||||
left join (select * from el_exam_registration where user_id = #{query.userId} and (payment_state = 'PAY' or payment_state = 'WAIT_REFUND') and expiration_state = false) reg on reg.exam_id = ex.id
|
||||
WHERE ex.state=0
|
||||
<if test="query!=null">
|
||||
<if test="query.title!=null and query.title!=''">
|
||||
|
||||
Loading…
Reference in New Issue
Block a user