yj
2020-03-06 ff34faee79dfdbb2a72839b97b1e748551549b08
发圈
1个文件已修改
1个文件已添加
66 ■■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/entity/dynamic/ListComment.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/dynamic/GoodsEvaluateServiceImpl.java 51 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/dynamic/ListComment.java
New file
@@ -0,0 +1,15 @@
package com.yeshi.fanli.entity.dynamic;
import java.util.List;
public class ListComment {
    private List<CommentInfo> comment;
    public List<CommentInfo> getComment() {
        return comment;
    }
    public void setComment(List<CommentInfo> comment) {
        this.comment = comment;
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/dynamic/GoodsEvaluateServiceImpl.java
@@ -16,6 +16,7 @@
import javax.annotation.Resource;
import javax.imageio.ImageIO;
import org.apache.commons.beanutils.PropertyUtils;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.core.task.TaskExecutor;
import org.springframework.stereotype.Service;
@@ -1444,38 +1445,37 @@
    }
    @Override
    @Cacheable(value = "dynamicCache", key = "'queryMaterialsCache-'+#start+'-'+#type")
//    @Cacheable(value = "dynamicCache", key = "'queryMaterialsCache-'+#start+'-'+#type")
    public List<GoodsEvaluate> queryMaterialsCache(int start, int count, int type) throws Exception {
        List<GoodsEvaluate> list = goodsEvaluateDao.queryValid(start, count, type);
        List<GoodsEvaluate> listOBJ = list;
        // 更新商品信息
        executor.execute(new Runnable() {
            @Override
            public void run() {
                updateGoodInfo(listOBJ);
            }
        });
        if (list == null) {
            list = new ArrayList<>();
        }
        Date now = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        List<GoodsEvaluate> listNew = new ArrayList<>();
        for (GoodsEvaluate goodsEvaluate : list) {
            GoodsEvaluate evaluateNew = new GoodsEvaluate();
            try {
                PropertyUtils.copyProperties(evaluateNew, goodsEvaluate);
            } catch (Exception e) {
                e.printStackTrace();
                continue;
            }
            int comment = 0;
            List<CommentInfo> comments = goodsEvaluate.getComments();
            List<CommentInfo> comments = evaluateNew.getComments();
            if (comments != null && comments.size() > 0) {
                EvaluateEnum typeEnum = goodsEvaluate.getType();
                EvaluateEnum typeEnum = evaluateNew.getType();
                List<CommentInfo> commentNew = new ArrayList<>();
                for (CommentInfo commentInfo : comments) {
                    comment++;
                    CommentInfoEnum typeComment = commentInfo.getTypeEnum();
                    if (typeComment != null && typeComment == CommentInfoEnum.goodsCoupon) {
                        GoodsDetailVO goods = goodsEvaluate.getGoods();
                        GoodsDetailVO goods = evaluateNew.getGoods();
                        if (goods.isHasCoupon()) {
                            commentNew.add(commentInfo);
                            continue;
@@ -1505,17 +1505,17 @@
                    commentNew.add(commentInfo);
                }
                goodsEvaluate.setComments(commentNew);
                evaluateNew.setComments(commentNew);
                if (typeEnum != null && typeEnum == EvaluateEnum.single) {
                    if (comment > 0 && commentNew.size() == 0) { // 所有券评论下架
                        GoodsDetailVO goods = goodsEvaluate.getGoods();
                        GoodsDetailVO goods = evaluateNew.getGoods();
                        if (goods != null) {
                            goods.setState(1); // 评论不存在 下架
                            LogHelper.test("获取列表商品下架1");
                        }
                        List<ImgInfo> imgList = goodsEvaluate.getImgList();
                        List<ImgInfo> imgList = evaluateNew.getImgList();
                        if (imgList != null) {
                            for (ImgInfo imgInfo : imgList) {
                                SimpleGoods simpleGoods = imgInfo.getGoods();
@@ -1529,9 +1529,20 @@
                    }
                }
            }
            listNew.add(evaluateNew);
        }
        return list;
        List<GoodsEvaluate> listOBJ = list;
        // 更新商品信息
        executor.execute(new Runnable() {
            @Override
            public void run() {
                updateGoodInfo(listOBJ);
            }
        });
        return listNew;
    }
    @Override