diff --git a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/dao/OrderCommentMapper.java b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/dao/OrderCommentMapper.java index 89c18cb0a..2f0b21475 100644 --- a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/dao/OrderCommentMapper.java +++ b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/dao/OrderCommentMapper.java @@ -9,6 +9,7 @@ import cn.iocoder.mall.order.biz.dataobject.OrderItemDO; import org.apache.ibatis.annotations.Param; import org.springframework.stereotype.Repository; +import java.util.Collection; import java.util.List; /** @@ -76,15 +77,15 @@ public interface OrderCommentMapper{ * @param orderCommentTimeOutPageDTO * @return */ - List selectOrderCommentTimeOutPage(OrderCommentTimeOutPageDTO orderCommentTimeOutPageDTO); + List selectOrderCommentTimeOutPage(@Param("commentTimeOut") OrderCommentTimeOutPageDTO orderCommentTimeOutPageDTO); /** * 批量更新订单评论状态 * @param orderCommentTimeOutBOList * @param commentState */ - void updateBatchOrderCommentState(@Param("list") List orderCommentTimeOutBOList, - @Param("commentState") Integer commentState); + void updateBatchOrderCommentState(@Param("commentState") Integer commentState, + @Param("list") List orderCommentTimeOutBOList); diff --git a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/job/AutomaticCommentJob.java b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/job/AutomaticCommentJob.java index 107f23c27..7f203ac68 100644 --- a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/job/AutomaticCommentJob.java +++ b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/job/AutomaticCommentJob.java @@ -12,6 +12,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.util.List; +import java.util.stream.Collectors; /** * 超时以后自动生成评论 @@ -59,10 +60,8 @@ public class AutomaticCommentJob extends IJobHandler { orderCommentService.updateBatchOrderCommentState(orderCommentTimeOutBOList); } - - - - return null; } + + } diff --git a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/service/OrderCommentServiceImpl.java b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/service/OrderCommentServiceImpl.java index 970cf813c..cf40e05ed 100644 --- a/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/service/OrderCommentServiceImpl.java +++ b/order/order-service-impl/src/main/java/cn/iocoder/mall/order/biz/service/OrderCommentServiceImpl.java @@ -18,7 +18,9 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.Date; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.stream.Collectors; /** @@ -101,9 +103,8 @@ public class OrderCommentServiceImpl implements OrderCommentService { return OrderCommentConvert.INSTANCE.convertOrderCommentTimeOutBOList(orderCommentDOList); } - @Transactional @Override public void updateBatchOrderCommentState(List orderCommentTimeOutBOList) { - orderCommentMapper.updateBatchOrderCommentState(orderCommentTimeOutBOList,OrderCommentStatusEnum.SUCCESS_COMMENT.getValue()); + orderCommentMapper.updateBatchOrderCommentState(OrderCommentStatusEnum.SUCCESS_COMMENT.getValue(),orderCommentTimeOutBOList); } } diff --git a/order/order-service-impl/src/main/resources/mapper/OrderCommentMapper.xml b/order/order-service-impl/src/main/resources/mapper/OrderCommentMapper.xml index dfa83c96b..d0694320b 100644 --- a/order/order-service-impl/src/main/resources/mapper/OrderCommentMapper.xml +++ b/order/order-service-impl/src/main/resources/mapper/OrderCommentMapper.xml @@ -73,27 +73,30 @@ - SELECT FROM order_comment WHERE - comment_state = #{commentState} - having - TIMESTAMPDIFF(DAY,create_time,NOW()) > #{orverDay} - LIMIT ${pageNo*pageSize},${pageSize} + comment_state = #{commentTimeOut.commentState} + HAVING + TIMESTAMPDIFF(DAY,create_time,NOW()) > #{commentTimeOut.overDay} + LIMIT ${commentTimeOut.pageNo*commentTimeOut.pageSize},${commentTimeOut.pageSize} - + UPDATE order_comment SET comment_state = #{commentState} WHERE - id IN - - #{item.id} - + id + IN + + + #{item.id} + + diff --git a/order/order-service-impl/src/main/resources/mapper/OrderCommentReplayMapper.xml b/order/order-service-impl/src/main/resources/mapper/OrderCommentReplayMapper.xml index f84cabe3c..8b6731865 100644 --- a/order/order-service-impl/src/main/resources/mapper/OrderCommentReplayMapper.xml +++ b/order/order-service-impl/src/main/resources/mapper/OrderCommentReplayMapper.xml @@ -74,6 +74,8 @@ #{commentId} + AND + user_type = #{userType} diff --git a/order/order-service-impl/src/test/java/cn/iocoder/mall/order/biz/service/OrderCommentJobTest.java b/order/order-service-impl/src/test/java/cn/iocoder/mall/order/biz/service/OrderCommentJobTest.java new file mode 100644 index 000000000..cca14c8b1 --- /dev/null +++ b/order/order-service-impl/src/test/java/cn/iocoder/mall/order/biz/service/OrderCommentJobTest.java @@ -0,0 +1,45 @@ +package cn.iocoder.mall.order.biz.service; + +import cn.iocoder.mall.order.api.OrderCommentService; +import cn.iocoder.mall.order.api.bo.OrderCommentTimeOutBO; +import cn.iocoder.mall.order.api.dto.OrderCommentTimeOutPageDTO; +import cn.iocoder.mall.order.biz.OrderApplicationTest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.junit4.SpringRunner; + +import java.util.List; +import java.util.stream.Collectors; + +/** + * 订单评论自动好评任务测试 + * + * @author wtz + * @time 2019-06-17 19:09 + */ +@RunWith(SpringRunner.class) +@SpringBootTest(classes = OrderApplicationTest.class) +@ActiveProfiles("dev") +public class OrderCommentJobTest { + + @Autowired + private OrderCommentService orderCommentService; + + @Test + public void createOrderCommentJob(){ + OrderCommentTimeOutPageDTO orderCommentTimeOutPageDTO=new OrderCommentTimeOutPageDTO(); + orderCommentTimeOutPageDTO.setCommentState(0); + orderCommentTimeOutPageDTO.setPageNo(0); + orderCommentTimeOutPageDTO.setPageSize(10); + orderCommentTimeOutPageDTO.setOverDay(7); + List orderCommentTimeOutBOList = orderCommentService.getOrderCommentTimeOutPage(orderCommentTimeOutPageDTO); + + + orderCommentService.updateBatchOrderCommentState(orderCommentTimeOutBOList); + + } + +}