admin
2019-06-24 831a3cefdb2bdfe0980e60479074a0c9ec5d7ef9
增加母婴
2个文件已修改
155 ■■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/dto/common/CommonContentTypeEnum.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/goods/CommonTemplateContentServiceImpl.java 151 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dto/common/CommonContentTypeEnum.java
@@ -3,8 +3,8 @@
public enum CommonContentTypeEnum {
    _9k9("9块9"), haoQuan("高额好券"), chaoSheng("超级省钱"), muYin("母婴精选"), reMai("潮品热卖"), meiShi("优选美食"), juJia(
            "居家生活"), chuanYiDaPei("穿衣搭配"), meiZhuangGehu("美妆个护"), jingPinXieBao(
                    "精品鞋包"), chaoNanReMai("潮男热卖"), shuMaShouJi("数码手机"), yunDongKuXie("运动酷鞋"), qiCheHuWai("汽车户外");
            "居家生活"), chuanYiDaPei("穿衣搭配"), meiZhuangGehu("美妆个护"), jingPinXieBao("精品鞋包"), chaoNanReMai(
                    "潮男热卖"), shuMaShouJi("数码手机"), yunDongKuXie("运动酷鞋"), qiCheHuWai("汽车户外"), chaoPinReMai("潮品热卖");
    private final String desc;
    private CommonContentTypeEnum(String desc) {
fanli/src/main/java/com/yeshi/fanli/service/impl/goods/CommonTemplateContentServiceImpl.java
@@ -16,8 +16,11 @@
import com.yeshi.fanli.dto.dataoke.DaTaoKeGoodsResult;
import com.yeshi.fanli.entity.bus.clazz.GoodsClass;
import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
import com.yeshi.fanli.entity.taobao.TaobaoMeterial;
import com.yeshi.fanli.entity.taobao.dataoke.DaTaoKeDetailV2;
import com.yeshi.fanli.service.inter.goods.CommonTemplateContentService;
import com.yeshi.fanli.service.inter.lable.TaoKeGoodsService;
import com.yeshi.fanli.service.inter.taobao.TaobaoMeterialService;
import com.yeshi.fanli.service.inter.taobao.dataoke.DaTaoKeGoodsDetailService;
import com.yeshi.fanli.util.dataoke.DaTaoKeApiUtil;
import com.yeshi.fanli.util.taobao.DaTaoKeUtil;
@@ -28,6 +31,12 @@
    @Resource
    private DaTaoKeGoodsDetailService daTaoKeGoodsDetailService;
    @Resource
    private TaobaoMeterialService taobaoMeterialService;
    @Resource
    private TaoKeGoodsService taoKeGoodsService;
    private static List<CommonContentNav> getCommonNav() {
        List<CommonContentNav> navList = new ArrayList<>();
@@ -81,12 +90,12 @@
            navList = getCommonNav();
        } else if (type == CommonContentTypeEnum.muYin) {
            navList.add(new CommonContentNav("1", "精选"));
            navList.add(new CommonContentNav("2", "备孕"));
            navList.add(new CommonContentNav("3", "0~6月"));
            navList.add(new CommonContentNav("4", "7~12月"));
            navList.add(new CommonContentNav("5", "1~3岁"));
            navList.add(new CommonContentNav("6", "4~6岁"));
            navList.add(new CommonContentNav("7", "7~12岁"));
            navList.add(new CommonContentNav("备孕", "备孕"));
            navList.add(new CommonContentNav("0至6个月", "0~6月"));
            navList.add(new CommonContentNav("7至12个月", "7~12月"));
            navList.add(new CommonContentNav("1至3岁", "1~3岁"));
            navList.add(new CommonContentNav("4至6岁", "4~6岁"));
            navList.add(new CommonContentNav("7至12岁", "7~12岁"));
        } else if (type == CommonContentTypeEnum.reMai) {
            navList = getCommonNav();
        } else if (type == CommonContentTypeEnum.chuanYiDaPei) {
@@ -113,6 +122,12 @@
    public CommonContentResult getContentList(CommonContentTypeEnum type, String cid, int page, int pageSize) {
        if (type == CommonContentTypeEnum._9k9) {
            return get9K9Content(cid, page, pageSize);
        } else if (type == CommonContentTypeEnum.juJia) {
            return getJuJiaShengHuoContent(cid, page, pageSize);
        } else if (type == CommonContentTypeEnum.muYin) {
            return getMuYinJingXuanContent(cid, page, pageSize);
        } else if (type == CommonContentTypeEnum.meiShi) {
            return getYouXuanMeiShiContent(cid, page, pageSize);
        } else if (type == CommonContentTypeEnum.chuanYiDaPei) {
            return getChuanYiDaPeiContent(cid, page, pageSize);
        } else if (type == CommonContentTypeEnum.meiZhuangGehu) {
@@ -127,6 +142,8 @@
            return getYunDongKuXieContent(cid, page, pageSize);
        } else if (type == CommonContentTypeEnum.qiCheHuWai) {
            return getQiCheHuWaiContent(cid, page, pageSize);
        } else if (type == CommonContentTypeEnum.chaoPinReMai) {
            return getChaoPinReMaiContent(cid, page, pageSize);
        }
        return null;
    }
@@ -159,6 +176,128 @@
    }
    /**
     * 居家生活
     *
     * @param cid
     * @param page
     * @param pageSize
     * @return
     */
    private CommonContentResult getJuJiaShengHuoContent(String cid, int page, int pageSize) {
        DaTaoKeGoodsResult result = null;
        List<Integer> cidList = new ArrayList<>();
        cidList.add(4);// 居家生活
        int sort = getCommonSort(cid);
        result = DaTaoKeApiUtil.search("", cidList, null, null, page, pageSize, sort);
        List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
        long count = 0;
        if (result != null) {
            count = result.getTotalCount();
            if (result.getGoodsList() != null)
                for (DaTaoKeDetailV2 detail : result.getGoodsList())
                    goodsList.add(TaoBaoUtil.convert(detail));
        }
        return new CommonContentResult(goodsList, count);
    }
    /**
     * 优选美食
     *
     * @param cid
     * @param page
     * @param pageSize
     * @return
     */
    private CommonContentResult getYouXuanMeiShiContent(String cid, int page, int pageSize) {
        DaTaoKeGoodsResult result = null;
        List<Integer> cidList = new ArrayList<>();
        cidList.add(6);// 美食
        int sort = getCommonSort(cid);
        result = DaTaoKeApiUtil.search("", cidList, null, null, page, pageSize, sort);
        List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
        long count = 0;
        if (result != null) {
            count = result.getTotalCount();
            if (result.getGoodsList() != null)
                for (DaTaoKeDetailV2 detail : result.getGoodsList())
                    goodsList.add(TaoBaoUtil.convert(detail));
        }
        return new CommonContentResult(goodsList, count);
    }
    /**
     * 潮品热卖
     *
     * @param cid
     * @param page
     * @param pageSize
     * @return
     */
    private CommonContentResult getChaoPinReMaiContent(String cid, int page, int pageSize) {
        DaTaoKeGoodsResult result = null;
        int sort = getCommonSort(cid);
        result = DaTaoKeApiUtil.search("潮", null, null, null, page, pageSize, sort);
        List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
        long count = 0;
        if (result != null) {
            count = result.getTotalCount();
            if (result.getGoodsList() != null)
                for (DaTaoKeDetailV2 detail : result.getGoodsList())
                    goodsList.add(TaoBaoUtil.convert(detail));
        }
        return new CommonContentResult(goodsList, count);
    }
    /**
     * 获取母婴精选
     *
     * @param cid
     * @param page
     * @param pageSize
     * @return
     */
    private CommonContentResult getMuYinJingXuanContent(String cid, int page, int pageSize) {
        DaTaoKeGoodsResult result = null;
        if ("1".equalsIgnoreCase(cid)) {// 大淘客数据
            List<Integer> cidList = new ArrayList<>();
            cidList.add(2);// 母婴
            result = DaTaoKeApiUtil.search("", null, null, null, page, pageSize, DaTaoKeApiUtil.SORT_DEFAULT);
            List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
            long count = 0;
            if (result != null) {
                count = result.getTotalCount();
                if (result.getGoodsList() != null)
                    for (DaTaoKeDetailV2 detail : result.getGoodsList())
                        goodsList.add(TaoBaoUtil.convert(detail));
            }
            return new CommonContentResult(goodsList, count);
        } else {//
            List<TaobaoMeterial> taobaoMeterials = taobaoMeterialService.selectByClassNameAndSuperNameCache("母婴_" + cid,
                    "母婴主题");
            if (taobaoMeterials == null || taobaoMeterials.size() == 0) {
                return null;
            }
            TaobaoMeterial meterial = taobaoMeterials.get(0);
            Integer materialId = meterial.getMaterialId();
            if (materialId != null) {
                List<TaoBaoGoodsBrief> listBrands = new ArrayList<>();
                try {
                    listBrands = taoKeGoodsService.listByMaterial(materialId, page, pageSize);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                return new CommonContentResult(listBrands, 1000);
            }
            return new CommonContentResult(new ArrayList<>(), 0);
        }
    }
    /**
     * 穿衣搭配
     * 
     * @param cid