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

This commit is contained in:
zhenxianyimeng 2019-06-22 11:48:06 +08:00
commit b9047e497a
7 changed files with 129 additions and 19 deletions

View File

@ -159,6 +159,65 @@ CREATE TABLE `order_recipient` (
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=186 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Table structure for order_comment
-- ----------------------------
DROP TABLE IF EXISTS `order_comment`;
CREATE TABLE `order_comment` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
`order_id` int(11) NOT NULL COMMENT '订单id',
`order_no` varchar(50) NOT NULL COMMENT '订单编号',
`product_spu_id` int(11) NOT NULL COMMENT '商品SPU',
`product_spu_name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '商品SPU名称 SPU这两个字段待考量是否加入',
`product_sku_id` int(11) NOT NULL COMMENT '商品的sku',
`product_sku_attrs` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '商品规格属性',
`product_sku_price` int(11) NOT NULL COMMENT '商品价格,单位:分',
`product_sku_pic_url` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '商品的图片地址',
`user_id` int(11) NOT NULL COMMENT '用户id',
`user_avatar` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '用户头像',
`user_nick_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '用户昵称',
`star` int(3) DEFAULT '5' COMMENT '评价星数:0->5',
`product_description_star` int(3) DEFAULT '5' COMMENT '商品描述:0->5',
`logistics_star` int(3) DEFAULT '5' COMMENT '物流星数:0->5',
`merchant_star` int(3) DEFAULT '5' COMMENT '商家星数:0->5',
`replay_count` int(11) DEFAULT '0' COMMENT '回复的条数',
`like_count` int(11) DEFAULT '0' COMMENT '点赞的个数',
`comment_content` varchar(1000) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '评论的内容',
`comment_pics` varchar(1000) DEFAULT NULL COMMENT '评论的图片地址 按照,分割',
`comment_state` int(3) DEFAULT '0' COMMENT '评论的状态 0待评论 1已评论',
`create_time` datetime NOT NULL COMMENT '创建时间',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Table structure for order_comment_replay
-- ----------------------------
DROP TABLE IF EXISTS `order_comment_replay`;
CREATE TABLE `order_comment_replay` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'id自增',
`comment_id` int(11) NOT NULL COMMENT '评论id',
`reply_type` int(1) NOT NULL COMMENT '回复的类型:0基于评论的回复1基于回复的回复',
`parent_id` int(11) NOT NULL COMMENT '父id: parent_id=comment_id 基于评论的回复,否则基于回复的回复',
`parent_user_id` varchar(11) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '回复目标用户id',
`parent_user_nick_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '回复目标用户的真实姓名',
`parent_user_avatar` varchar(255) DEFAULT NULL COMMENT '回复目标的头像',
`reply_content` varchar(255) DEFAULT NULL COMMENT '回复的内容',
`reply_user_id` int(11) NOT NULL COMMENT '回复用户id',
`reply_user_nick_name` varchar(255) NOT NULL COMMENT '回复用户昵称',
`reply_user_avatar` varchar(255) NOT NULL COMMENT '回复用户头像',
`user_type` int(3) DEFAULT '0' COMMENT '回复用户的身份:0普通用户,1商家',
`reply_like_count` int(11) NOT NULL DEFAULT '0' COMMENT '回复的点赞数量',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '回复创建时间',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '回复更新时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Table structure for order_return
-- ----------------------------

View File

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

View File

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

View File

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

View File

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

View File

@ -74,6 +74,8 @@
<foreach collection="commentIds" item="commentId" separator="," open="(" close=")">
#{commentId}
</foreach>
AND
user_type = #{userType}
</select>
</mapper>

View File

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