| | |
| | | package com.yeshi.fanli.service.impl.goods;
|
| | |
|
| | | import java.util.ArrayList;
|
| | | import java.util.HashMap;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
|
| | | import org.springframework.cache.annotation.Cacheable;
|
| | |
| | |
|
| | | import com.yeshi.fanli.dto.common.JDCommonContentTypeEnum;
|
| | | import com.yeshi.fanli.dto.jd.JDSearchResult;
|
| | | import com.yeshi.fanli.entity.jd.JDGoods;
|
| | | import com.yeshi.fanli.service.inter.goods.JDCommonTemplateContentService;
|
| | | import com.yeshi.fanli.tag.PageEntity;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | |
| | | public class JDCommonTemplateContentServiceImpl implements JDCommonTemplateContentService {
|
| | |
|
| | | private Map<String, Long> countMap = new HashMap<String, Long>();
|
| | | |
| | |
|
| | | @Cacheable(value = "jdCommonContentCache", key = "#type+'-'+#cid+'-'+#page+'-'+#pageSize")
|
| | | @Override
|
| | |
| | | return null;
|
| | | }
|
| | |
|
| | | |
| | | private JDSearchResult get9K9Content(String cid, int page, int pageSize) {
|
| | | int[] arrayId = {10, 17};
|
| | | return getJingFenGoods(page, pageSize, "9k9-", arrayId);
|
| | | int[] arrayId = { 10, 17 };
|
| | | JDSearchResult result = getJingFenGoods(page, pageSize, "9k9-", arrayId);
|
| | |
|
| | | return filterGoods(result);
|
| | | }
|
| | | |
| | |
|
| | | private JDSearchResult filterGoods(JDSearchResult result) {
|
| | | List<Long> skuIds = new ArrayList<>();
|
| | | if (result != null && result.getGoodsList() != null && result.getGoodsList().size() > 0) {
|
| | | for (JDGoods goods : result.getGoodsList()) {
|
| | | skuIds.add(goods.getSkuId());
|
| | | }
|
| | | List<JDGoods> goodsList = JDApiUtil.listGoodsDetail(skuIds);
|
| | | result.setGoodsList(goodsList);
|
| | | }
|
| | | return result;
|
| | | }
|
| | |
|
| | | private JDSearchResult getJDPeiSongContent(String cid, int page, int pageSize) {
|
| | | int[] arrayId = {15, 18};
|
| | | return getJingFenGoods(page, pageSize, "peisong-", arrayId);
|
| | | int[] arrayId = { 15, 18 };
|
| | | JDSearchResult result = getJingFenGoods(page, pageSize, "peisong-", arrayId);
|
| | | return filterGoods(result);
|
| | | }
|
| | | |
| | |
|
| | | private JDSearchResult getJiaDianContent(String cid, int page, int pageSize) {
|
| | | int[] arrayId = {5, 2};
|
| | | return getJingFenGoods(page, pageSize, "jiadian-", arrayId);
|
| | | int[] arrayId = { 5, 2 };
|
| | | JDSearchResult result = getJingFenGoods(page, pageSize, "jiadian-", arrayId);
|
| | | return filterGoods(result);
|
| | | }
|
| | | |
| | |
|
| | | private JDSearchResult getBaiHuoContent(String cid, int page, int pageSize) {
|
| | | int[] arrayId = {6, 3};
|
| | | return getJingFenGoods(page, pageSize, "baihuo-", arrayId);
|
| | | int[] arrayId = { 6, 3 };
|
| | | JDSearchResult result = getJingFenGoods(page, pageSize, "baihuo-", arrayId);
|
| | | return filterGoods(result);
|
| | | }
|
| | | |
| | |
|
| | | private JDSearchResult getJuJiaContent(String cid, int page, int pageSize) {
|
| | | int[] arrayId = {7, 4};
|
| | | return getJingFenGoods(page, pageSize, "jujia-", arrayId);
|
| | | int[] arrayId = { 7, 4 };
|
| | | JDSearchResult result = getJingFenGoods(page, pageSize, "jujia-", arrayId);
|
| | | return filterGoods(result);
|
| | | }
|
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 9快9包邮
|
| | | *
|
| | |
| | | if (count != null) {
|
| | | addCount += count;
|
| | | }
|
| | | |
| | |
|
| | | if (count != null && totalCount > addCount) {
|
| | | pageTemp = (int)(addCount / Constant.PAGE_SIZE);
|
| | | pageTemp = (int) (addCount / Constant.PAGE_SIZE);
|
| | | continue; // 当前分类商品不足
|
| | | } else {
|
| | | page = page - pageTemp; |
| | | page = page - pageTemp;
|
| | | categoryId = arrayId[i];
|
| | | break;
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | if (categoryId == null) {
|
| | | return null;
|
| | | }
|
| | | |
| | |
|
| | | JDSearchResult result = JDApiUtil.getJingFenGoods(page, categoryId);
|
| | | long count = 0;
|
| | | if (result != null) {
|
| | |
| | | count = pageEntity.getTotalCount();
|
| | | }
|
| | | }
|
| | | |
| | | long mcount = (count/Constant.PAGE_SIZE) * Constant.PAGE_SIZE;
|
| | |
|
| | | long mcount = (count / Constant.PAGE_SIZE) * Constant.PAGE_SIZE;
|
| | | if (mcount == 0) {
|
| | | mcount = 20;
|
| | | }
|