yujian
2019-07-30 c6f32fd5fd0cf1cf0758765a697c9e9ad5bbba13
分享bug
7个文件已修改
147 ■■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/CommonContentControllerV2.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dto/common/PDDCommonContentTypeEnum.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/goods/PDDCommonTemplateContentServiceImpl.java 49 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserGoodsStorageServiceImpl.java 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/goods/PDDCommonTemplateContentService.java 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/jd/JDApiUtil.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/pinduoduo/PinDuoDuoApiUtil.java 66 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/v2/CommonContentControllerV2.java
@@ -82,7 +82,7 @@
        } else if (type == Constant.SOURCE_TYPE_JD) {
            // 暂无分类
        } else if (type == Constant.SOURCE_TYPE_PDD) {
            // 暂无分类
            list = pddCommonTemplateContentService.getNavList(PDDCommonContentTypeEnum.valueOf(key));
        }
        
        if (list == null) {
fanli/src/main/java/com/yeshi/fanli/dto/common/PDDCommonContentTypeEnum.java
@@ -2,7 +2,7 @@
public enum PDDCommonContentTypeEnum {
    _1k9("1.9包邮", "0"), todayTop("今日爆款", "1"), brandClear("品牌清仓", "2");
    _1k9("1.9包邮", "0"), todayTop("今日爆款", "1"), brandClear("品牌清仓", "2"), brandGoods("品牌好货", null);
    private final String desc;
    private final String content;
    
fanli/src/main/java/com/yeshi/fanli/service/impl/goods/PDDCommonTemplateContentServiceImpl.java
@@ -1,10 +1,15 @@
package com.yeshi.fanli.service.impl.goods;
import java.util.ArrayList;
import java.util.List;
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.PDDGoodsResult;
import com.yeshi.fanli.dto.pdd.PDDSearchFilter;
import com.yeshi.fanli.service.inter.goods.PDDCommonTemplateContentService;
import com.yeshi.fanli.util.pinduoduo.PinDuoDuoApiUtil;
@@ -17,7 +22,49 @@
        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);
            }
            return PinDuoDuoApiUtil.searchGoods(pddfilter);
        }
        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", "医药"));
        }
        return navList;
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserGoodsStorageServiceImpl.java
@@ -425,8 +425,11 @@
            CommonGoods commonGoods = userGoodsStorage.getCommonGoods();
            BigDecimal money = CommonGoodsUtil.getCommission(commonGoods, rate);
            totalMoney = MoneyBigDecimalUtil.add(totalMoney, money);
            listCommonGoods.add(commonGoods);
            if (goodsType == null) {
                goodsType = commonGoods.getGoodsType();
            }
        }
        
        ShareGoodsRecordDTO shareRecord = userShareGoodsRecordService.addRecordGoodsStorageV2(uid, listCommonGoods, listStorageID);
fanli/src/main/java/com/yeshi/fanli/service/inter/goods/PDDCommonTemplateContentService.java
@@ -1,5 +1,8 @@
package com.yeshi.fanli.service.inter.goods;
import java.util.List;
import com.yeshi.fanli.dto.common.CommonContentNav;
import com.yeshi.fanli.dto.common.PDDCommonContentTypeEnum;
import com.yeshi.fanli.dto.pdd.PDDGoodsResult;
@@ -11,6 +14,21 @@
 */
public interface PDDCommonTemplateContentService {
    /**
     * 商品信息
     * @param type
     * @param cid
     * @param page
     * @param pageSize
     * @return
     */
    public PDDGoodsResult getContentList(PDDCommonContentTypeEnum type, String cid, int page, int pageSize);
    /**
     * 分类
     * @param type
     * @return
     */
    public List<CommonContentNav> getNavList(PDDCommonContentTypeEnum type);
    
}
fanli/src/main/java/com/yeshi/fanli/util/jd/JDApiUtil.java
@@ -169,8 +169,13 @@
        root.put("promotionCodeReq", json);
        String result = baseRequest("jd.union.open.promotion.common.get", null, root);
        JSONObject resultJson = JSONObject.fromObject(result);
        result = resultJson.optJSONObject("jd_union_open_promotion_common_get_response").optString("result");
        if (result == null) {
            return null;
        }
        resultJson = JSONObject.fromObject(result);
        return resultJson.optJSONObject("data").optString("clickURL");
    }
fanli/src/main/java/com/yeshi/fanli/util/pinduoduo/PinDuoDuoApiUtil.java
@@ -98,10 +98,17 @@
        
        map.put("pid", PID_FANLI);
        String result = baseRequest(map);
        JSONObject json = JSONObject.fromObject(result);
        JSONObject root = json.optJSONObject("goods_search_response");
        if (root == null) {
            return null;
        }
        JSONArray array = root.optJSONArray("goods_list");
        if (array == null) {
            return null;
        }
        Type type = new TypeToken<List<PDDGoodsDetail>>() {
        }.getType();
        
@@ -133,7 +140,14 @@
        
        JSONObject json = JSONObject.fromObject(result);
        JSONObject root = json.optJSONObject("goods_basic_detail_response");
        if (root == null) {
            return null;
        }
        JSONArray array = root.optJSONArray("list");
        if (array == null) {
            return null;
        }
        Type type = new TypeToken<List<PDDGoodsDetail>>() {
        }.getType();
        
@@ -152,6 +166,28 @@
        JSONObject json = JSONObject.fromObject(result);
        JSONObject root = json.optJSONObject("goods_cats_get_response");
        JSONArray array = root.optJSONArray("goods_cats_list");
    }
    public static void getThemes(Integer page, Integer pageSize) {
        Map<String, String> map = new HashMap<>();
        map.put("type", "pdd.ddk.theme.list.get");
        map.put("page", page + "");
        map.put("page_size", pageSize  + "");
        String result = baseRequest(map);
        JSONObject json = JSONObject.fromObject(result);
        JSONObject root = json.optJSONObject("theme_list_get_response");
        JSONArray array = root.optJSONArray("theme_list");
        for (int i = 0; i < array.size(); i++) {
            System.out.println(array.optJSONObject(i).optString("id"));
            System.out.println(array.optJSONObject(i).optString("name"));
            System.out.println(array.optJSONObject(i).optString("image_url"));
            System.out.println(array.optJSONObject(i).optString("goods_num"));
            System.out.println("-------------------------------------------");
        }
        System.out.println(root.optLong("total"));
    }
    
    
@@ -190,7 +226,14 @@
        String result = baseRequest(map);
        JSONObject json = JSONObject.fromObject(result);
        JSONObject root = json.optJSONObject("top_goods_list_get_response");
        if (root == null) {
            return null;
        }
        JSONArray array = root.optJSONArray("list");
        if (array == null) {
            return null;
        }
        Type type = new TypeToken<List<PDDGoodsDetail>>() {}.getType();
        
        Gson gson = new GsonBuilder().disableHtmlEscaping().create();
@@ -226,9 +269,12 @@
        String result = baseRequest(map);
        JSONObject root = JSONObject.fromObject(result);
        JSONObject json = root.optJSONObject("goods_promotion_url_generate_response");
        array = json.optJSONArray("goods_promotion_url_list");
        if (array != null && array.size() > 0)
            return array.optJSONObject(0).optString("short_url");
        if (json == null) {
            return null;
        }
        JSONArray resultArray = json.optJSONArray("goods_promotion_url_list");
        if (resultArray != null && resultArray.size() > 0)
            return resultArray.optJSONObject(0).optString("short_url");
        return null;
    }
@@ -291,10 +337,18 @@
        String result = baseRequest(map);
        JSONObject resultJson = JSONObject.fromObject(result);
        JSONObject root = resultJson.optJSONObject("goods_detail_response");
        array = root.optJSONArray("goods_details");
        if (root == null) {
            return null;
        }
        JSONArray resultArray = root.optJSONArray("goods_details");
        if (resultArray == null) {
            return null;
        }
        Type type = new TypeToken<List<PDDGoodsDetail>>() {
        }.getType();
        List<PDDGoodsDetail> goodsList = new Gson().fromJson(array.toString(), type);
        List<PDDGoodsDetail> goodsList = new Gson().fromJson(resultArray.toString(), type);
        if (goodsList != null && goodsList.size() > 0)
            return goodsList.get(0);
        return null;