1
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
package cn.van.business.controller.jd;
|
package cn.van.business.controller.jd;
|
||||||
|
|
||||||
|
import cn.van.business.model.pl.TaobaoComment;
|
||||||
|
import cn.van.business.repository.TaobaoCommentRepository;
|
||||||
import cn.van.business.util.JDProductService;
|
import cn.van.business.util.JDProductService;
|
||||||
import cn.van.business.util.JDUtil;
|
import cn.van.business.util.JDUtil;
|
||||||
import cn.van.business.repository.CommentRepository;
|
import cn.van.business.repository.CommentRepository;
|
||||||
@@ -31,12 +33,14 @@ public class JDInnerController {
|
|||||||
private final JDProductService jdProductService;
|
private final JDProductService jdProductService;
|
||||||
private final JDUtil jdUtil;
|
private final JDUtil jdUtil;
|
||||||
private final CommentRepository commentRepository;
|
private final CommentRepository commentRepository;
|
||||||
|
private final TaobaoCommentRepository taobaoCommentRepository;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public JDInnerController(JDProductService jdProductService, JDUtil jdUtil, CommentRepository commentRepository) {
|
public JDInnerController(JDProductService jdProductService, JDUtil jdUtil, CommentRepository commentRepository, TaobaoCommentRepository taobaoCommentRepository) {
|
||||||
this.jdProductService = jdProductService;
|
this.jdProductService = jdProductService;
|
||||||
this.jdUtil = jdUtil;
|
this.jdUtil = jdUtil;
|
||||||
this.commentRepository = commentRepository;
|
this.commentRepository = commentRepository;
|
||||||
|
this.taobaoCommentRepository = taobaoCommentRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/generatePromotionContent")
|
@PostMapping("/generatePromotionContent")
|
||||||
@@ -116,7 +120,7 @@ public class JDInnerController {
|
|||||||
// 获取本地可用的京东评论并统计
|
// 获取本地可用的京东评论并统计
|
||||||
List<Comment> available = commentRepository.findByProductIdAndIsUseNotAndPictureUrlsIsNotNull(productId, 1);
|
List<Comment> available = commentRepository.findByProductIdAndIsUseNotAndPictureUrlsIsNotNull(productId, 1);
|
||||||
List<Comment> used = commentRepository.findByProductIdAndIsUseNotAndPictureUrlsIsNotNull(productId, 0);
|
List<Comment> used = commentRepository.findByProductIdAndIsUseNotAndPictureUrlsIsNotNull(productId, 0);
|
||||||
|
|
||||||
canUseCommentCount = available.size();
|
canUseCommentCount = available.size();
|
||||||
usedCommentCount = used.size();
|
usedCommentCount = used.size();
|
||||||
allCommentCount = canUseCommentCount + usedCommentCount;
|
allCommentCount = canUseCommentCount + usedCommentCount;
|
||||||
@@ -125,11 +129,11 @@ public class JDInnerController {
|
|||||||
HashMap<String, String> tbMap = jdUtil.getProductTypeMapForTB();
|
HashMap<String, String> tbMap = jdUtil.getProductTypeMapForTB();
|
||||||
String taobaoProductId = tbMap.getOrDefault(productId, productId);
|
String taobaoProductId = tbMap.getOrDefault(productId, productId);
|
||||||
// 注意:这里需要注入TaobaoCommentRepository,暂时注释掉淘宝统计部分
|
// 注意:这里需要注入TaobaoCommentRepository,暂时注释掉淘宝统计部分
|
||||||
// List<TaobaoComment> availableTbComments = taobaoCommentRepository.findByProductIdAndIsUseNotAndPictureUrlsIsNotNull(taobaoProductId, 1);
|
List<TaobaoComment> availableTbComments = taobaoCommentRepository.findByProductIdAndIsUseNotAndPictureUrlsIsNotNull(taobaoProductId, 1);
|
||||||
// List<TaobaoComment> usedTbComments = taobaoCommentRepository.findByProductIdAndIsUseNotAndPictureUrlsIsNotNull(taobaoProductId, 0);
|
List<TaobaoComment> usedTbComments = taobaoCommentRepository.findByProductIdAndIsUseNotAndPictureUrlsIsNotNull(taobaoProductId, 0);
|
||||||
// canUseTbCommentCount = availableTbComments.size();
|
canUseTbCommentCount = availableTbComments.size();
|
||||||
// usedTbCommentCount = usedTbComments.size();
|
usedTbCommentCount = usedTbComments.size();
|
||||||
// allTbCommentCount = canUseTbCommentCount + usedTbCommentCount;
|
allTbCommentCount = canUseTbCommentCount + usedTbCommentCount;
|
||||||
|
|
||||||
List<Comment> candidates = !available.isEmpty() ? available : used;
|
List<Comment> candidates = !available.isEmpty() ? available : used;
|
||||||
if (candidates.isEmpty()) {
|
if (candidates.isEmpty()) {
|
||||||
@@ -157,7 +161,7 @@ public class JDInnerController {
|
|||||||
stats.put("used", usedCommentCount);
|
stats.put("used", usedCommentCount);
|
||||||
stats.put("available", canUseCommentCount);
|
stats.put("available", canUseCommentCount);
|
||||||
stats.put("total", allCommentCount);
|
stats.put("total", allCommentCount);
|
||||||
stats.put("statisticsText",
|
stats.put("statisticsText",
|
||||||
"京东评论统计:\n" +
|
"京东评论统计:\n" +
|
||||||
"型号 " + productType + "\n" +
|
"型号 " + productType + "\n" +
|
||||||
"新增:" + addCommentCount + "\n" +
|
"新增:" + addCommentCount + "\n" +
|
||||||
|
|||||||
Reference in New Issue
Block a user