admin
2019-03-13 c7458d62739ce287e9fdb071a41dc5c00bb4374f
增加淘宝商品是否参与推广的链接
1个文件已修改
47 ■■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/controller/client/GoodsController.java 47 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/GoodsController.java
@@ -180,4 +180,51 @@
    }
    /**
     * 是否在参与推广
     */
    /**
     * 是否在参与推广
     *
     * @param goodsId
     *            -商品ID
     * @param goodsType
     *            -TB/JD
     * @param out
     */
    @RequestMapping(value = "isGoodsExtend")
    public void isGoodsExtend(String goodsId, String goodsType, PrintWriter out) {
        if (StringUtil.isNullOrEmpty(goodsId)) {
            out.print(JsonUtil.loadFalseResult(1, "未参与推广"));
            return;
        }
        if (StringUtil.isNullOrEmpty(goodsType)) {
            out.print(JsonUtil.loadFalseResult(2, "缺少goodsType"));
            return;
        }
        if ("TB".equalsIgnoreCase(goodsType)) {
            TaoBaoGoodsBrief goods = null;
            try {
                goods = TaoKeApiUtil.getSimpleGoodsInfo(Long.parseLong(goodsId));
            } catch (NumberFormatException e) {
                e.printStackTrace();
            } catch (TaobaoGoodsDownException e) {
                e.printStackTrace();
            }
            JSONObject data = new JSONObject();
            if (goods == null) {
                data.put("extend", false);
                data.put("url", "https://h5.m.taobao.com/awp/core/detail.htm?id=" + goodsId);
            } else {
                data.put("extend", true);
            }
            out.print(JsonUtil.loadTrueResult(data));
        } else {
            out.print(JsonUtil.loadFalseResult(3, "暂不支持其他商品类型"));
        }
    }
}