admin
2020-05-20 98b1a0affd69bbe63223c21fdd2c404e8bedfccb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package com.yeshi.fanli.service.impl.goods;
 
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.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.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();
                }
            }
            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.hotSaleGoods) {
            
        }
        return navList;
    }
}