| | |
| | | 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; |
| | |
| | | } |
| | | |
| | | @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; |
| | |
| | | |
| | | 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(); |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | listNew.add(evaluateNew); |
| | | } |
| | | |
| | | return list; |
| | | List<GoodsEvaluate> listOBJ = list; |
| | | // 更新商品信息 |
| | | executor.execute(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | updateGoodInfo(listOBJ); |
| | | } |
| | | }); |
| | | |
| | | return listNew; |
| | | } |
| | | |
| | | @Override |