| | |
| | | import java.util.ArrayList;
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.cache.annotation.Cacheable;
|
| | | import org.springframework.stereotype.Service;
|
| | |
|
| | | import com.yeshi.fanli.dto.common.CommonContentNav;
|
| | | import com.yeshi.fanli.dto.common.PDDCommonContentTypeEnum;
|
| | | import com.yeshi.fanli.dto.pdd.PDDGoodsDetail;
|
| | | import com.yeshi.fanli.dto.pdd.PDDGoodsResult;
|
| | | import com.yeshi.fanli.dto.pdd.PDDSearchFilter;
|
| | | import com.yeshi.fanli.service.inter.goods.PDDCommonTemplateContentService;
|
| | | import com.yeshi.fanli.service.inter.pdd.PDDGoodsService;
|
| | | import com.yeshi.fanli.util.pinduoduo.PinDuoDuoApiUtil;
|
| | |
|
| | | @Service
|
| | | public class PDDCommonTemplateContentServiceImpl implements PDDCommonTemplateContentService {
|
| | |
|
| | | @Resource
|
| | | private PDDGoodsService pddGoodsService;
|
| | | |
| | | |
| | | @Cacheable(value = "pddCommonContentCache", key = "#type+'-'+#cid+'-'+#page+'-'+#pageSize")
|
| | | @Override
|
| | | public PDDGoodsResult getContentList(PDDCommonContentTypeEnum type, String cid, int page, int pageSize) {
|
| | | if (type == PDDCommonContentTypeEnum._1k9 || type == PDDCommonContentTypeEnum.todayTop
|
| | | || type == PDDCommonContentTypeEnum.brandClear) {
|
| | | return PinDuoDuoApiUtil.searchByChannelType(page - 1, pageSize, type.getContent());
|
| | | } else if (type == PDDCommonContentTypeEnum.brandGoods) {
|
| | | PDDSearchFilter pddfilter = new PDDSearchFilter();
|
| | | pddfilter.setPage(page);
|
| | | pddfilter.setPageSize(pageSize);
|
| | | pddfilter.setSortType(22);
|
| | | if ("-1".equalsIgnoreCase(cid)) {
|
| | | pddfilter.setOptId(-1L);
|
| | | } else {
|
| | | long catId = Long.parseLong(cid);
|
| | | pddfilter.setCatId(catId);
|
| | | pddfilter.setOptId(catId);
|
| | | } else if (type == PDDCommonContentTypeEnum.hotSaleGoods) {
|
| | | return pddGoodsService.getTopGoodsList(page, 2); // 热卖好货
|
| | | } else if (type == PDDCommonContentTypeEnum.todaySaleGoods) { // 热销榜单
|
| | | int count = 0;
|
| | | List<PDDGoodsDetail> list = new ArrayList<PDDGoodsDetail>(); |
| | | PDDGoodsResult pddGoodsResult = pddGoodsService.getTodaySaleGoodsList();
|
| | | if (pddGoodsResult != null) {
|
| | | List<PDDGoodsDetail> goodsList = pddGoodsResult.getGoodsList();
|
| | | if (goodsList != null) {
|
| | | if (goodsList.size() >= (page * pageSize)) {
|
| | | list.addAll(goodsList.subList((page-1)* pageSize, page * pageSize));
|
| | | }
|
| | | count = goodsList.size();
|
| | | }
|
| | | }
|
| | | return PinDuoDuoApiUtil.searchGoods(pddfilter);
|
| | | PDDGoodsResult pddResult = new PDDGoodsResult();
|
| | | pddResult.setGoodsList(list);
|
| | | pddResult.setTotalCount(count);
|
| | | |
| | | return pddResult; |
| | | }
|
| | | return null;
|
| | | }
|
| | |
| | | @Override
|
| | | public List<CommonContentNav> getNavList(PDDCommonContentTypeEnum type) {
|
| | | List<CommonContentNav> navList = new ArrayList<>();
|
| | | if (type == PDDCommonContentTypeEnum.brandGoods) {
|
| | | navList.add(new CommonContentNav("-1", "精选"));
|
| | | //navList.add(new CommonContentNav("-11", "清仓"));
|
| | | navList.add(new CommonContentNav("15", "百货 "));
|
| | | navList.add(new CommonContentNav("4", "母婴"));
|
| | | navList.add(new CommonContentNav("1", "食品"));
|
| | | navList.add(new CommonContentNav("14", "女装"));
|
| | | navList.add(new CommonContentNav("18", "电器"));
|
| | | navList.add(new CommonContentNav("1281", "鞋包"));
|
| | | navList.add(new CommonContentNav("1282", "内衣"));
|
| | | navList.add(new CommonContentNav("16", "美妆"));
|
| | | navList.add(new CommonContentNav("743", "男装"));
|
| | | navList.add(new CommonContentNav("13", "水果"));
|
| | | navList.add(new CommonContentNav("818", "家纺"));
|
| | | navList.add(new CommonContentNav("2478", "文具"));
|
| | | navList.add(new CommonContentNav("1451", "运动"));
|
| | | navList.add(new CommonContentNav("590", "虚拟"));
|
| | | navList.add(new CommonContentNav("2048", "汽车"));
|
| | | navList.add(new CommonContentNav("1917", "家装"));
|
| | | navList.add(new CommonContentNav("2974", "家具"));
|
| | | navList.add(new CommonContentNav("3279", "医药"));
|
| | | if (type == PDDCommonContentTypeEnum.hotSaleGoods) {
|
| | | |
| | | }
|
| | | return navList;
|
| | | }
|