Merge branch 'master' of gitee.com:zhijiantianya/onemall

pull/1/head
chixiao 2019-06-15 23:15:55 +08:00
commit 238a5968fe
10 changed files with 243 additions and 15 deletions

View File

@ -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);

View File

@ -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;
}

View File

@ -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;
}
}

View File

@ -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;
}

View File

@ -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(OrderCommentDO orderCommentDO);
@Mappings({})
List<OrderCommentTimeOutBO> convertOrderCommentTimeOutBOList(List<OrderCommentDO> orderCommentDOList);
}

View File

@ -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);
}

View File

@ -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;
}
}

View File

@ -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();

View File

@ -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());
}
}

View File

@ -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>