commit
238a5968fe
@ -0,0 +1,25 @@
|
||||
package cn.iocoder.mall.order.api.bo;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
/**
|
||||
* 订单评论超时
|
||||
*
|
||||
* @author wtz
|
||||
* @time 2019-06-15 13:52
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class OrderCommentTimeOutBO implements Serializable {
|
||||
|
||||
/**
|
||||
* 评论 id
|
||||
*/
|
||||
private Integer id;
|
||||
|
||||
}
|
||||
@ -0,0 +1,34 @@
|
||||
package cn.iocoder.mall.order.api.constant;
|
||||
|
||||
/**
|
||||
* 订单评论状态
|
||||
*
|
||||
* @author wtz
|
||||
* @time 2019-06-15 14:26
|
||||
*/
|
||||
public enum OrderCommentStatusEnum {
|
||||
|
||||
WAIT_COMMENT(0, "待评论"),
|
||||
SUCCESS_COMMENT(1, "评论成功");
|
||||
/**
|
||||
* 状态值
|
||||
*/
|
||||
private Integer value;
|
||||
/**
|
||||
* 状态名
|
||||
*/
|
||||
private String name;
|
||||
|
||||
OrderCommentStatusEnum(Integer value, String name) {
|
||||
this.value = value;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Integer getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,36 @@
|
||||
package cn.iocoder.mall.order.api.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 订单评论超时
|
||||
*
|
||||
* @author wtz
|
||||
* @time 2019-06-15 10:59
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class OrderCommentTimeOutPageDTO implements Serializable {
|
||||
/**
|
||||
* 超过的天数
|
||||
*/
|
||||
private Integer overDay;
|
||||
|
||||
/**
|
||||
* 评论的状态
|
||||
*/
|
||||
private Integer commentState;
|
||||
|
||||
/**
|
||||
* 页码
|
||||
*/
|
||||
private Integer pageNo;
|
||||
|
||||
/**
|
||||
* 每页条数
|
||||
*/
|
||||
private Integer pageSize;
|
||||
}
|
||||
@ -0,0 +1,68 @@
|
||||
package cn.iocoder.mall.order.biz.job;
|
||||
|
||||
import cn.iocoder.mall.order.api.OrderCommentService;
|
||||
import cn.iocoder.mall.order.api.bo.OrderCommentTimeOutBO;
|
||||
import cn.iocoder.mall.order.api.constant.OrderCommentStatusEnum;
|
||||
import cn.iocoder.mall.order.api.dto.OrderCommentTimeOutPageDTO;
|
||||
import cn.iocoder.mall.order.biz.dao.OrderCommentMapper;
|
||||
import com.xxl.job.core.biz.model.ReturnT;
|
||||
import com.xxl.job.core.handler.IJobHandler;
|
||||
import com.xxl.job.core.handler.annotation.JobHandler;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 超时以后自动生成评论
|
||||
*
|
||||
* @author wtz
|
||||
* @time 2019-06-15 10:26
|
||||
*/
|
||||
@Component
|
||||
@JobHandler("automaticCommentJob")
|
||||
public class AutomaticCommentJob extends IJobHandler {
|
||||
|
||||
/**
|
||||
* 默认生成订单7天以后的自动生成订单评论
|
||||
*/
|
||||
private static final Integer OVERDAYCOUNT=7;
|
||||
|
||||
private static final Integer PAGESIZE=1000;
|
||||
|
||||
@Autowired
|
||||
private OrderCommentService orderCommentService;
|
||||
|
||||
@Override
|
||||
public ReturnT<String> execute(String param) throws Exception {
|
||||
Integer overDayCount=OVERDAYCOUNT;
|
||||
|
||||
if (param.isEmpty()){
|
||||
overDayCount=Integer.parseInt(param);
|
||||
}
|
||||
|
||||
for (int i=0;;i++){
|
||||
|
||||
OrderCommentTimeOutPageDTO orderCommentTimeOutPageDTO=new OrderCommentTimeOutPageDTO();
|
||||
orderCommentTimeOutPageDTO.setOverDay(overDayCount);
|
||||
orderCommentTimeOutPageDTO.setCommentState(OrderCommentStatusEnum.WAIT_COMMENT.getValue());
|
||||
orderCommentTimeOutPageDTO.setPageNo(i);
|
||||
orderCommentTimeOutPageDTO.setPageSize(PAGESIZE);
|
||||
|
||||
List<OrderCommentTimeOutBO> orderCommentTimeOutBOList=orderCommentService.getOrderCommentTimeOutPage(orderCommentTimeOutPageDTO);
|
||||
|
||||
//为空时候跳出循环
|
||||
if (orderCommentTimeOutBOList.isEmpty()){
|
||||
break;
|
||||
}
|
||||
//批量更新
|
||||
orderCommentService.updateBatchOrderCommentState(orderCommentTimeOutBOList);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in new issue