|
|
package com.yoho.search.service.recall.beans.requests;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.yoho.search.dal.model.CsRecallConfigSortPrice;
|
|
|
import com.yoho.search.models.recall.PagePersonalFactor;
|
|
|
import com.yoho.search.models.recall.RecallRequest;
|
|
|
import com.yoho.search.models.recall.UserRecallRequest;
|
|
|
import com.yoho.search.service.recall.beans.RecallConfigService;
|
|
|
import com.yoho.search.service.recall.helper.RecallConfigConstants;
|
|
|
import com.yoho.search.service.recall.strategy.IStrategy;
|
|
|
import com.yoho.search.service.recall.strategy.StrategyEnum;
|
|
|
import com.yoho.search.service.recall.strategy.impls.DirectTrainSortPriceStrategy;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Collections;
|
|
|
import java.util.List;
|
|
|
|
|
|
@Component
|
|
|
public class DirectTrainSortPriceRequestsBuilder {
|
|
|
|
|
|
private static final Logger RECALL_NEW_LOGGER = LoggerFactory.getLogger("RECALL");
|
|
|
|
|
|
@Autowired
|
|
|
private RecallConfigService recallConfigService;
|
|
|
|
|
|
/**
|
|
|
* 构造直通车-[品类价格带]的召回请求
|
|
|
*
|
|
|
* @param userRecallRequest
|
|
|
* @return
|
|
|
*/
|
|
|
public List<RecallRequest> buildDirectTrainSortPriceRequests(UserRecallRequest userRecallRequest, PagePersonalFactor pageFactor) {
|
|
|
int size = recallConfigService.queryStrategyConfigSize(userRecallRequest, StrategyEnum.DIRECT_TRAIN_SORT_PRICE, 0);
|
|
|
if (size == 0) {
|
|
|
return Collections.emptyList();
|
|
|
}
|
|
|
List<CsRecallConfigSortPrice> directTrainSortPriceList = recallConfigService.randomSortPrice(pageFactor, size);
|
|
|
if (CollectionUtils.isEmpty(directTrainSortPriceList)) {
|
|
|
return Collections.emptyList();
|
|
|
}
|
|
|
RECALL_NEW_LOGGER.info("randomSortPrice is[{}]", JSON.toJSONString(directTrainSortPriceList));
|
|
|
List<RecallRequest> requests = new ArrayList<>();
|
|
|
int productSize = RecallConfigConstants.DEFAULT_DIRECT_TRAIN_PRODUCT_SIZE;
|
|
|
for (CsRecallConfigSortPrice sortPrice : directTrainSortPriceList) {
|
|
|
IStrategy strategy = new DirectTrainSortPriceStrategy(sortPrice.getSortId(), sortPrice.getMinPrice().doubleValue(), sortPrice.getMaxPrice().doubleValue(), productSize);
|
|
|
requests.add(new RecallRequest(userRecallRequest.getParamQueryFilter(), strategy));
|
|
|
}
|
|
|
return requests;
|
|
|
}
|
|
|
} |
...
|
...
|
|