|
@@ -23,9 +23,10 @@ import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
-import java.util.ArrayList;
|
|
|
|
-import java.util.List;
|
|
|
|
-import java.util.Map;
|
|
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
|
+import java.time.LocalDateTime;
|
|
|
|
+import java.time.temporal.ChronoUnit;
|
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
/**
|
|
* Description
|
|
* Description
|
|
@@ -109,7 +110,7 @@ public class SearchIndexServiceImpl implements SearchIndexService {
|
|
// 获取最大文档ID
|
|
// 获取最大文档ID
|
|
Integer mainId = searchQueryService.getIdByDocId("", null);
|
|
Integer mainId = searchQueryService.getIdByDocId("", null);
|
|
mainId = mainId == -1 ? 0 : mainId;
|
|
mainId = mainId == -1 ? 0 : mainId;
|
|
- // 获取推送记录数
|
|
|
|
|
|
+ // 设置商品文档 并返回推送记录数
|
|
Integer productRecord = setAllProductData(mainId, productCount, false);
|
|
Integer productRecord = setAllProductData(mainId, productCount, false);
|
|
if (productCount > productRecord) {
|
|
if (productCount > productRecord) {
|
|
log.warn("批量添加商品文档异常,部分商品未添加。");
|
|
log.warn("批量添加商品文档异常,部分商品未添加。");
|
|
@@ -1131,12 +1132,22 @@ public class SearchIndexServiceImpl implements SearchIndexService {
|
|
product.setP_all(1);
|
|
product.setP_all(1);
|
|
// 价格等级
|
|
// 价格等级
|
|
product.setP_price_grade(priceUtilService.getPriceGrade(product.getP_price().doubleValue()));
|
|
product.setP_price_grade(priceUtilService.getPriceGrade(product.getP_price().doubleValue()));
|
|
- DocumentDTO<ProductDO> productDoc = new DocumentDTO<>();
|
|
|
|
|
|
+ // 统计月销量与月访问量
|
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
|
+ calendar.setTime(new Date());
|
|
|
|
+ calendar.add(Calendar.DAY_OF_MONTH, -30);
|
|
|
|
+ String dateStr = new SimpleDateFormat("yyyy-MM-dd").format(calendar.getTime());
|
|
|
|
+ int views = searchMapper.countViewsByDate(product.getP_id(), dateStr);
|
|
|
|
+ int sales = searchMapper.countSalesByDate(product.getP_id(), dateStr);
|
|
|
|
+ product.setP_sales(sales);
|
|
|
|
+ product.setP_favorite(views);
|
|
// 设促销id
|
|
// 设促销id
|
|
List<Integer> promotionIds = searchMapper.findPromotionId(product.getP_id());
|
|
List<Integer> promotionIds = searchMapper.findPromotionId(product.getP_id());
|
|
if (promotionIds != null && promotionIds.size() > 0) {
|
|
if (promotionIds != null && promotionIds.size() > 0) {
|
|
product.setP_promotions_id(promotionIds.get(0));
|
|
product.setP_promotions_id(promotionIds.get(0));
|
|
}
|
|
}
|
|
|
|
+ // 文档设值
|
|
|
|
+ DocumentDTO<ProductDO> productDoc = new DocumentDTO<>();
|
|
productDoc.setCmd("add");
|
|
productDoc.setCmd("add");
|
|
productDoc.setFields(product);
|
|
productDoc.setFields(product);
|
|
productList.add(productDoc);
|
|
productList.add(productDoc);
|