订单评论超时自动评论
This commit is contained in:
parent
e7c9464804
commit
ffd83cc787
|
@ -1,12 +1,13 @@
|
|||
package cn.iocoder.mall.order.api;
|
||||
|
||||
import cn.iocoder.mall.order.api.bo.OrderCommentCreateBO;
|
||||
import cn.iocoder.mall.order.api.bo.OrderCommentInfoBO;
|
||||
import cn.iocoder.mall.order.api.bo.OrderCommentPageBO;
|
||||
import cn.iocoder.mall.order.api.bo.OrderCommentStateInfoPageBO;
|
||||
import cn.iocoder.mall.order.api.bo.*;
|
||||
import cn.iocoder.mall.order.api.dto.OrderCommentCreateDTO;
|
||||
import cn.iocoder.mall.order.api.dto.OrderCommentPageDTO;
|
||||
import cn.iocoder.mall.order.api.dto.OrderCommentStateInfoPageDTO;
|
||||
import cn.iocoder.mall.order.api.dto.OrderCommentTimeOutPageDTO;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 订单评论模块
|
||||
|
@ -49,11 +50,18 @@ public interface OrderCommentService {
|
|||
OrderCommentStateInfoPageBO getOrderCommentStateInfoPage(OrderCommentStateInfoPageDTO orderCommentStateInfoPageDTO);
|
||||
|
||||
/**
|
||||
* 订单评价超时自动好评
|
||||
* 采用任务的形式执行
|
||||
* 获取订单评论超时分页
|
||||
* @param orderCommentTimeOutPageDTO
|
||||
* @return
|
||||
*/
|
||||
Boolean OrderCommentTimeOutProductCommentTask();
|
||||
List<OrderCommentTimeOutBO> getOrderCommentTimeOutPage(OrderCommentTimeOutPageDTO orderCommentTimeOutPageDTO);
|
||||
|
||||
|
||||
/**
|
||||
* 批量更新订单评论状态
|
||||
* @param orderCommentTimeOutBOList
|
||||
*/
|
||||
void updateBatchOrderCommentState(List<OrderCommentTimeOutBO> orderCommentTimeOutBOList);
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
package cn.iocoder.mall.order.api.bo;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
/**
|
||||
* 订单评论超时
|
||||
*
|
||||
* @author wtz
|
||||
* @time 2019-06-15 13:52
|
||||
*/
|
||||
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;
|
||||
}
|
|
@ -3,6 +3,7 @@ package cn.iocoder.mall.order.biz.convert;
|
|||
import cn.iocoder.mall.order.api.bo.OrderCommentCreateBO;
|
||||
import cn.iocoder.mall.order.api.bo.OrderCommentInfoBO;
|
||||
import cn.iocoder.mall.order.api.bo.OrderCommentStateInfoPageBO;
|
||||
import cn.iocoder.mall.order.api.bo.OrderCommentTimeOutBO;
|
||||
import cn.iocoder.mall.order.api.dto.OrderCommentCreateDTO;
|
||||
import cn.iocoder.mall.order.biz.dataobject.OrderCommentDO;
|
||||
import org.mapstruct.Mapper;
|
||||
|
@ -38,6 +39,12 @@ public interface OrderCommentConvert {
|
|||
@Mappings({})
|
||||
OrderCommentInfoBO convertOrderCommentInfoBO(OrderCommentDO orderCommentDO);
|
||||
|
||||
@Mappings({})
|
||||
OrderCommentTimeOutBO convertOrderCommentTimeOutBO(OrderCommentTimeOutBO orderCommentTimeOutBO);
|
||||
|
||||
@Mappings({})
|
||||
List<OrderCommentTimeOutBO> convertOrderCommentTimeOutBOList(List<OrderCommentDO> orderCommentDOList);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
package cn.iocoder.mall.order.biz.dao;
|
||||
|
||||
import cn.iocoder.mall.order.api.bo.OrderCommentTimeOutBO;
|
||||
import cn.iocoder.mall.order.api.dto.OrderCommentPageDTO;
|
||||
import cn.iocoder.mall.order.api.dto.OrderCommentStateInfoPageDTO;
|
||||
import cn.iocoder.mall.order.api.dto.OrderCommentTimeOutPageDTO;
|
||||
import cn.iocoder.mall.order.biz.dataobject.OrderCommentDO;
|
||||
import cn.iocoder.mall.order.biz.dataobject.OrderItemDO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
|
@ -68,5 +71,21 @@ public interface OrderCommentMapper{
|
|||
@Param("commentState") Integer commentState);
|
||||
|
||||
|
||||
/**
|
||||
* 订单评论超时分页
|
||||
* @param orderCommentTimeOutPageDTO
|
||||
* @return
|
||||
*/
|
||||
List<OrderCommentDO> selectOrderCommentTimeOutPage(OrderCommentTimeOutPageDTO orderCommentTimeOutPageDTO);
|
||||
|
||||
/**
|
||||
* 批量更新订单评论状态
|
||||
* @param orderCommentTimeOutBOList
|
||||
* @param commentState
|
||||
*/
|
||||
void updateBatchOrderCommentState(@Param("list") List<OrderCommentTimeOutBO> orderCommentTimeOutBOList,
|
||||
@Param("commentState") Integer commentState);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -60,7 +60,6 @@ public class OrderCommentReplyServiceImpl implements OrderCommentReplyService {
|
|||
public OrderCommentReplyCreateBO createOrderCommentReply(OrderCommentReplyCreateDTO orderCommentReplyCreateDTO) {
|
||||
OrderCommentReplyDO orderCommentReplyDO=OrderCommentReplyConvert.INSTANCE.convert(orderCommentReplyCreateDTO);
|
||||
orderCommentReplyDO.setCreateTime(new Date());
|
||||
orderCommentReplyDO.setUpdateTime(new Date());
|
||||
|
||||
Integer replyType=orderCommentReplyCreateDTO.getCommentId()==orderCommentReplyCreateDTO.getParentId()?
|
||||
OrderCommentRelpyTypeEnum.COMMENT_REPLY.getValue():OrderCommentRelpyTypeEnum.REPLY_REPLY.getValue();
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
package cn.iocoder.mall.order.biz.service;
|
||||
|
||||
import cn.iocoder.mall.order.api.OrderCommentService;
|
||||
import cn.iocoder.mall.order.api.bo.OrderCommentCreateBO;
|
||||
import cn.iocoder.mall.order.api.bo.OrderCommentInfoBO;
|
||||
import cn.iocoder.mall.order.api.bo.OrderCommentPageBO;
|
||||
import cn.iocoder.mall.order.api.bo.OrderCommentStateInfoPageBO;
|
||||
import cn.iocoder.mall.order.api.bo.*;
|
||||
import cn.iocoder.mall.order.api.constant.OrderCommentStatusEnum;
|
||||
import cn.iocoder.mall.order.api.constant.OrderReplyUserTypeEnum;
|
||||
import cn.iocoder.mall.order.api.dto.OrderCommentCreateDTO;
|
||||
import cn.iocoder.mall.order.api.dto.OrderCommentPageDTO;
|
||||
import cn.iocoder.mall.order.api.dto.OrderCommentStateInfoPageDTO;
|
||||
import cn.iocoder.mall.order.api.dto.OrderCommentTimeOutPageDTO;
|
||||
import cn.iocoder.mall.order.biz.convert.OrderCommentConvert;
|
||||
import cn.iocoder.mall.order.biz.dao.OrderCommentMapper;
|
||||
import cn.iocoder.mall.order.biz.dao.OrderCommentReplayMapper;
|
||||
|
@ -16,6 +15,7 @@ import cn.iocoder.mall.order.biz.dataobject.OrderCommentDO;
|
|||
import cn.iocoder.mall.order.biz.dataobject.OrderCommentReplyDO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
@ -43,7 +43,6 @@ public class OrderCommentServiceImpl implements OrderCommentService {
|
|||
public OrderCommentCreateBO createOrderComment(OrderCommentCreateDTO orderCommentCreateDTO) {
|
||||
OrderCommentDO orderCommentDO=OrderCommentConvert.INSTANCE.convertOrderCommentDO(orderCommentCreateDTO);
|
||||
orderCommentDO.setCreateTime(new Date());
|
||||
orderCommentDO.setUpdateTime(new Date());
|
||||
orderCommentMapper.insert(orderCommentDO);
|
||||
return OrderCommentConvert.INSTANCE.convertOrderCommentCreateBO(orderCommentDO);
|
||||
}
|
||||
|
@ -97,7 +96,14 @@ public class OrderCommentServiceImpl implements OrderCommentService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Boolean OrderCommentTimeOutProductCommentTask() {
|
||||
return null;
|
||||
public List<OrderCommentTimeOutBO> getOrderCommentTimeOutPage(OrderCommentTimeOutPageDTO orderCommentTimeOutPageDTO) {
|
||||
List<OrderCommentDO> orderCommentDOList=orderCommentMapper.selectOrderCommentTimeOutPage(orderCommentTimeOutPageDTO);
|
||||
return OrderCommentConvert.INSTANCE.convertOrderCommentTimeOutBOList(orderCommentDOList);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public void updateBatchOrderCommentState(List<OrderCommentTimeOutBO> orderCommentTimeOutBOList) {
|
||||
orderCommentMapper.updateBatchOrderCommentState(orderCommentTimeOutBOList,OrderCommentStatusEnum.SUCCESS_COMMENT.getValue());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,4 +72,30 @@
|
|||
comment_state = #{commentState}
|
||||
</select>
|
||||
|
||||
<!--订单评论超时分页-->
|
||||
<select id="selectOrderCommentTimeOutPage" resultType="cn.iocoder.mall.order.biz.dataobject.OrderCommentDO">
|
||||
SELECT
|
||||
<include refid="FIELDS" />
|
||||
FROM order_comment
|
||||
WHERE
|
||||
comment_state = #{commentState}
|
||||
having
|
||||
TIMESTAMPDIFF(DAY,create_time,NOW()) > #{orverDay}
|
||||
LIMIT ${pageNo*pageSize},${pageSize}
|
||||
</select>
|
||||
|
||||
<!--批量更新订单评论-->
|
||||
<update id="updateBatchOrderCommentState" parameterType="java.util.List">
|
||||
UPDATE order_comment
|
||||
SET
|
||||
comment_state = #{commentState}
|
||||
WHERE
|
||||
id IN
|
||||
<foreach collection="list" item="item" index="index" open="" close="" separator=";">
|
||||
#{item.id}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
|
||||
|
||||
</mapper>
|
Loading…
Reference in New Issue