订单超时自动好评Job测试
							parent
							
								
									b3322bf217
								
							
						
					
					
						commit
						498f7ed53a
					
				|  | @ -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<OrderCommentDO> selectOrderCommentTimeOutPage(OrderCommentTimeOutPageDTO orderCommentTimeOutPageDTO); | ||||
|     List<OrderCommentDO> selectOrderCommentTimeOutPage(@Param("commentTimeOut") OrderCommentTimeOutPageDTO orderCommentTimeOutPageDTO); | ||||
| 
 | ||||
|     /** | ||||
|      * 批量更新订单评论状态 | ||||
|      * @param orderCommentTimeOutBOList | ||||
|      * @param commentState | ||||
|      */ | ||||
|     void updateBatchOrderCommentState(@Param("list") List<OrderCommentTimeOutBO> orderCommentTimeOutBOList, | ||||
|                                       @Param("commentState") Integer commentState); | ||||
|     void updateBatchOrderCommentState(@Param("commentState") Integer commentState, | ||||
|             @Param("list") List<OrderCommentTimeOutBO> orderCommentTimeOutBOList); | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|  |  | |||
|  | @ -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; | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
| } | ||||
|  |  | |||
|  | @ -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<OrderCommentTimeOutBO> orderCommentTimeOutBOList) { | ||||
|         orderCommentMapper.updateBatchOrderCommentState(orderCommentTimeOutBOList,OrderCommentStatusEnum.SUCCESS_COMMENT.getValue()); | ||||
|         orderCommentMapper.updateBatchOrderCommentState(OrderCommentStatusEnum.SUCCESS_COMMENT.getValue(),orderCommentTimeOutBOList); | ||||
|     } | ||||
| } | ||||
|  |  | |||
|  | @ -73,27 +73,30 @@ | |||
|     </select> | ||||
| 
 | ||||
|     <!--订单评论超时分页--> | ||||
|     <select id="selectOrderCommentTimeOutPage" resultType="cn.iocoder.mall.order.biz.dataobject.OrderCommentDO"> | ||||
|     <select id="selectOrderCommentTimeOutPage" parameterType="cn.iocoder.mall.order.api.dto.OrderCommentTimeOutPageDTO"  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} | ||||
|         comment_state = #{commentTimeOut.commentState} | ||||
|         HAVING | ||||
|         TIMESTAMPDIFF(DAY,create_time,NOW()) > #{commentTimeOut.overDay} | ||||
|         LIMIT ${commentTimeOut.pageNo*commentTimeOut.pageSize},${commentTimeOut.pageSize} | ||||
|     </select> | ||||
| 
 | ||||
|     <!--批量更新订单评论--> | ||||
|     <update id="updateBatchOrderCommentState" parameterType="java.util.List"> | ||||
|     <update id="updateBatchOrderCommentState"> | ||||
|         UPDATE order_comment | ||||
|         SET | ||||
|         comment_state = #{commentState} | ||||
|         WHERE | ||||
|         id IN | ||||
|         <foreach collection="list" item="item" index="index" open="" close="" separator=";"> | ||||
|             #{item.id} | ||||
|         </foreach> | ||||
|         id | ||||
|         IN | ||||
|         <if test="list !=null"> | ||||
|             <foreach collection="list"  index="index" item="item" open="(" separator="," close=")"> | ||||
|                 #{item.id} | ||||
|             </foreach> | ||||
|         </if> | ||||
|     </update> | ||||
| 
 | ||||
| 
 | ||||
|  |  | |||
|  | @ -74,6 +74,8 @@ | |||
|         <foreach collection="commentIds" item="commentId" separator="," open="(" close=")"> | ||||
|             #{commentId} | ||||
|         </foreach> | ||||
|         AND | ||||
|         user_type = #{userType} | ||||
|     </select> | ||||
| 
 | ||||
| </mapper> | ||||
|  |  | |||
|  | @ -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<OrderCommentTimeOutBO> orderCommentTimeOutBOList = orderCommentService.getOrderCommentTimeOutPage(orderCommentTimeOutPageDTO); | ||||
| 
 | ||||
| 
 | ||||
|         orderCommentService.updateBatchOrderCommentState(orderCommentTimeOutBOList); | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
| } | ||||
		Loading…
	
		Reference in New Issue
	
	 wangtongzhou
						wangtongzhou