admin
2025-02-25 30d8e227e8d823b6c38c3b9c90ac2df03b63befe
fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoKeScApiUtil.java
@@ -59,7 +59,7 @@
                JSONObject item = array.optJSONObject(i);
                TaoBaoGoodsBrief goods = new TaoBaoGoodsBrief();
                goods.setPictUrl(item.optString("pict_url"));
                goods.setAuctionId(item.optLong("num_iid"));
                goods.setAuctionId(item.optString("num_iid"));
                goods.setAuctionUrl(item.optString("item_url"));
                goods.setBiz30day(item.optInt("volume"));
                goods.setCouponInfo(item.optString("coupon_info"));
@@ -148,7 +148,7 @@
    private static TaoBaoGoodsBrief parseSimpleGoodsInfo(JSONObject item) {
        TaoBaoGoodsBrief goods = new TaoBaoGoodsBrief();
        goods.setAuctionId(item.optLong("num_iid"));
        goods.setAuctionId(item.optString("num_iid"));
        goods.setAuctionUrl(item.optString("item_url"));
        goods.setBiz30day(item.optInt("volume"));
        if (item.optJSONObject("small_images") != null) {
@@ -260,7 +260,7 @@
    /**
     * 获取商品详情,简版
     *
     * @param id
     * @param ids
     * @return
     */
    public static List<TaoBaoGoodsBrief> getBatchGoodsInfos(String ids) throws TaobaoGoodsDownException {
@@ -312,8 +312,8 @@
        if (result != null && result.getTaoBaoGoodsBriefs() != null)
            for (TaoBaoGoodsBrief g : result.getTaoBaoGoodsBriefs()) {
                System.out.println(goods.getAuctionId() + ":" + g.getAuctionId());
                if (goods.getAuctionId().longValue() == g.getAuctionId()) {
                    g.setId(goods.getAuctionId());
                if (TaoBaoUtil.isEqual( goods.getAuctionId(), g.getAuctionId())) {
                    g.setAuctionId(goods.getAuctionId());
                    g.setCreatetime(new Date());
                    g.setMaterialLibType(goods.getMaterialLibType());
                    g.setProvcity(goods.getProvcity());
@@ -324,7 +324,7 @@
        // 从转链搜索
        TaoBaoGoodsBrief newGoods = specialConvertCoupon(goods.getAuctionId(),
                new TaoKeAppInfo(TaoBaoConstant.TAOBAO_AUTH_APPKEY, TaoBaoConstant.TAOBAO_AUTH_APPSECRET,
                        TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT));
                        TaoBaoConstant.TAOBAO_PID_DEFAULT));
        if (newGoods != null) {
            goods.setTkRate(newGoods.getTkRate());
@@ -373,8 +373,8 @@
                goods.getUserType(), app);
        if (result != null && result.getTaoBaoGoodsBriefs() != null)
            for (TaoBaoGoodsBrief g : result.getTaoBaoGoodsBriefs()) {
                if (goods.getAuctionId().longValue() == g.getAuctionId()) {
                    g.setId(goods.getAuctionId());
                if (TaoBaoUtil.isEqual(goods.getAuctionId(), g.getAuctionId())) {
                    g.setAuctionId(goods.getAuctionId());
                    // 判断是否有优惠券
                    if (!StringUtil.isNullOrEmpty(g.getCouponActivityId())) {
                        // 获取优惠券详情
@@ -401,7 +401,7 @@
        // 从转链搜索
        TaoBaoGoodsBrief newGoods = specialConvertCoupon(goods.getAuctionId(),
                new TaoKeAppInfo(TaoBaoConstant.TAOBAO_AUTH_APPKEY, TaoBaoConstant.TAOBAO_AUTH_APPSECRET,
                        TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT));
                        TaoBaoConstant.TAOBAO_PID_DEFAULT));
        if (newGoods != null) {
            goods.setTkRate(newGoods.getTkRate());
@@ -451,8 +451,8 @@
                goods.getUserType(), app);
        if (result != null && result.getTaoBaoGoodsBriefs() != null)
            for (TaoBaoGoodsBrief g : result.getTaoBaoGoodsBriefs()) {
                if (goods.getAuctionId().longValue() == g.getAuctionId()) {
                    g.setId(goods.getAuctionId());
                if (TaoBaoUtil.isEqual( goods.getAuctionId(), g.getAuctionId())) {
                    g.setAuctionId(goods.getAuctionId());
                    g.setCreatetime(new Date());
                    return g;
                }
@@ -492,8 +492,8 @@
                    goods.getUserType());
            if (result != null && result.getTaoBaoGoodsBriefs() != null)
                for (TaoBaoGoodsBrief g : result.getTaoBaoGoodsBriefs()) {
                    if (goods.getAuctionId().longValue() == g.getAuctionId()) {
                        g.setId(goods.getAuctionId());
                    if ( TaoBaoUtil.isEqual(goods.getAuctionId(), g.getAuctionId())) {
                        g.setAuctionId(goods.getAuctionId());
                        g.setAuctionUrl(goods.getAuctionUrl());
                        g.setShopTitle(goods.getShopTitle());
@@ -529,9 +529,9 @@
            if (searchResult != null && searchResult.getTaoBaoGoodsBriefs() != null
                    && searchResult.getTaoBaoGoodsBriefs().size() > 0) {
                for (TaoBaoGoodsBrief g : searchResult.getTaoBaoGoodsBriefs()) {
                    if (g.getAuctionId().longValue() == goods.getAuctionId()) {
                    if (TaoBaoUtil.isEqual(g.getAuctionId() , goods.getAuctionId())) {
                        g.setImgList(goods.getImgList());
                        g.setId(goods.getAuctionId());
                        g.setAuctionId(goods.getAuctionId());
                        g.setAuctionUrl(goods.getAuctionUrl());
                        g.setShopTitle(goods.getShopTitle());
@@ -694,7 +694,7 @@
            e.printStackTrace();
        }
        System.out.println(data);
        System.out.println(data.toString());
        if (data.optJSONObject("tbk_dg_material_optional_response") != null
                && data.optJSONObject("tbk_dg_material_optional_response").optJSONObject("result_list") != null) {
@@ -780,7 +780,6 @@
    /**
     * 商品物料搜索
     *
     * @param filter
     * @return
     */
    public static TaoBaoSearchResult searchWuLiaoForDetail(String title, BigDecimal zkPrice, String provcity,
@@ -831,7 +830,6 @@
    /**
     * 商品物料搜索
     *
     * @param filter
     * @return
     */
    public static TaoBaoSearchResult searchWuLiaoForDetail(String title, BigDecimal zkPrice, String provcity,
@@ -887,7 +885,7 @@
            goods.setPictUrlWhite(item.optString("white_image"));
        }
        goods.setAuctionId(item.optLong("num_iid"));
        goods.setAuctionId(item.optString("num_iid"));
        goods.setAuctionUrl("https:" + item.optString("url"));
        goods.setBiz30day(item.optInt("volume"));
        goods.setCouponInfo(item.optString("coupon_info"));
@@ -1007,7 +1005,7 @@
     * @param activityId
     * @return
     */
    public static TaoKeApiUtil.QuanInfo getQuanInfo(Long auctionId, String activityId) {
    public static TaoKeApiUtil.QuanInfo getQuanInfo(String auctionId, String activityId) {
        TaoKeApiUtil.QuanInfo info = new TaoKeApiUtil.QuanInfo();
        Map<String, String> map = new HashMap<>();
        map.put("method", "taobao.tbk.coupon.get");
@@ -1209,8 +1207,6 @@
    /**
     * 店铺搜索
     *
     * @param key  -店铺名称
     * @param page -页码
     * @return
     */
    public static List<TaoBaoShopInfo> searchShop(SearchShopFilter filter) {
@@ -1275,7 +1271,7 @@
        System.out.println(resultStr);
    }
    public static void getTAEGoodsDetail(Long auctionId) {
    public static void getTAEGoodsDetail(String auctionId) {
        Map<String, String> map = new HashMap<>();
        map.put("method", "taobao.tae.items.list");
        map.put("fields", "title,nick,pic_url,location,cid,price,post_fee,promoted_service,ju,shop_name");
@@ -1446,32 +1442,6 @@
        return result;
    }
    /**
     * 从淘宝链接中解析商品ID(高级接口)
     *
     * @param link
     * @return
     */
    public static String parseAuctionIdFromLink(String link) {
        Map<String, String> map = new HashMap<>();
        map.put("method", "taobao.tbk.item.click.extract");
        map.put("click_url", link + "");
        TaoKeAppInfo app = new TaoKeAppInfo(TaoBaoConstant.TAOBAO_AUTH_APPKEY, TaoBaoConstant.TAOBAO_AUTH_APPSECRET,
                TaoBaoConstant.TAOBAO_RELATION_AS_SPECIAL_PID);
        JSONObject resultJSON = null;
        try {
            resultJSON = TaoKeBaseUtil.baseRequest(map, app);
            System.out.println(resultJSON);
        } catch (TaoKeApiException e) {
            e.printStackTrace();
        }
        if (resultJSON == null)
            return null;
        return null;
    }
    public static String getAccessToken(String code, String appKey, String appSecret) {
        Map<String, String> map = new HashMap<>();
@@ -1634,7 +1604,7 @@
        return null;
    }
    public static void specialConvertItem(Long auctionId, TaoKeAppInfo app) {
    public static void specialConvertItem(String auctionId, TaoKeAppInfo app) {
        String pid = app.getPid();
        String[] sts = pid.split("_");
        Map<String, String> map = new HashMap<>();
@@ -1651,7 +1621,7 @@
        }
    }
    public static TaoBaoGoodsBrief specialConvertCoupon(Long auctionId, TaoKeAppInfo app) {
    public static TaoBaoGoodsBrief specialConvertCoupon(String auctionId, TaoKeAppInfo app) {
        String pid = app.getPid();
        String[] sts = pid.split("_");
        Map<String, String> map = new HashMap<>();
@@ -1716,44 +1686,6 @@
    }
    public static void taoKeContent() {
        Map<String, String> map = new HashMap<>();
        map.put("method", "taobao.tbk.content.get");
        map.put("adzone_id", TaoBaoConstant.TAOBAO_RELATION_PID_DEFAULT.split("_")[3]);
        map.put("type", "1");
        map.put("count", "100");
        TaoKeAppInfo app = new TaoKeAppInfo();
        app.setAppKey(TaoBaoConstant.TAOBAO_AUTH_APPKEY);
        app.setAppSecret(TaoBaoConstant.TAOBAO_AUTH_APPSECRET);
        try {
            JSONObject json = TaoKeBaseUtil.baseRequest(map, app);
            System.out.println(json);
        } catch (TaoKeApiException e) {
            e.printStackTrace();
        }
    }
    public static void taoKeContentSource(String contentId, String source) {
        Map<String, String> map = new HashMap<>();
        map.put("method", "taobao.tbk.dg.optimus.material");
        map.put("adzone_id", TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT.split("_")[3]);
        map.put("page_size", "10");
        map.put("page_no", "1");
        map.put("content_id", contentId);
        map.put("content_source", source);
        map.put("material_id", "1");
        TaoKeAppInfo app = new TaoKeAppInfo();
        app.setAppKey(TaoBaoConstant.TAOBAO_AUTH_APPKEY);
        app.setAppSecret(TaoBaoConstant.TAOBAO_AUTH_APPSECRET);
        try {
            JSONObject json = TaoKeBaseUtil.baseRequest(map, app);
            System.out.println(json);
        } catch (TaoKeApiException e) {
            e.printStackTrace();
        }
    }
    // AA5ISJ
@@ -1761,7 +1693,7 @@
        TaoBaoGoodsBrief goods = new TaoBaoGoodsBrief();
        // 设置成320*320的图片尺寸
        goods.setPictUrl(TbImgUtil.getTBSize320Img("https:" + item.optString("pict_url")));
        goods.setAuctionId(item.optLong("item_id"));
        goods.setAuctionId(item.optString("item_id"));
        goods.setAuctionUrl("https://item.taobao.com/item.htm?id=" + goods.getAuctionId());
        goods.setBiz30day(item.optInt("volume"));
        if (!StringUtil.isNullOrEmpty(item.optString("coupon_amount"))) {
@@ -1866,44 +1798,6 @@
        }
    }
    public static void getTaoKeContentEffective() {
        Map<String, String> map = new HashMap<>();
        map.put("method", "taobao.tbk.dg.optimus.material");
        map.put("adzone_id", TaoBaoConstant.TAOBAO_RELATION_AS_SPECIAL_PID.split("_")[3]);
        map.put("page_no", "1");
        map.put("page_size", "20");
        map.put("content_id", "8872035");
        TaoKeAppInfo app = new TaoKeAppInfo();
        app.setAppKey(TaoBaoConstant.TAOBAO_AUTH_APPKEY);
        app.setAppSecret(TaoBaoConstant.TAOBAO_AUTH_APPSECRET);
        try {
            JSONObject json = TaoKeBaseUtil.baseRequest(map, app);
            System.out.println(json);
        } catch (TaoKeApiException e) {
            e.printStackTrace();
        }
    }
    public static void getTaoKeContent() {
        Map<String, String> map = new HashMap<>();
        map.put("method", "taobao.tbk.content.get");
        map.put("adzone_id", TaoBaoConstant.TAOBAO_RELATION_AS_SPECIAL_PID.split("_")[3]);
        map.put("type", "1");
        TaoKeAppInfo app = new TaoKeAppInfo();
        app.setAppKey(TaoBaoConstant.TAOBAO_AUTH_APPKEY);
        app.setAppSecret(TaoBaoConstant.TAOBAO_AUTH_APPSECRET);
        try {
            JSONObject json = TaoKeBaseUtil.baseRequest(map, app);
            System.out.println(json);
        } catch (TaoKeApiException e) {
            e.printStackTrace();
        }
    }
    /**
     * 淘口令转商品ID
     *
@@ -1914,7 +1808,7 @@
        Map<String, String> map = new HashMap<>();
        map.put("method", "taobao.tbk.tpwd.convert");
        map.put("password_content", token);
        map.put("adzone_id", TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT.split("_")[3]);
        map.put("adzone_id", TaoBaoConstant.TAOBAO_PID_DEFAULT.split("_")[3]);
        TaoKeAppInfo app = new TaoKeAppInfo();
        app.setAppKey(TaoBaoConstant.TAOBAO_AUTH_APPKEY);
        app.setAppSecret(TaoBaoConstant.TAOBAO_AUTH_APPSECRET);
@@ -1943,7 +1837,7 @@
    }
    // 淘礼金创建
    public static TaoLiJinDTO createTaoLiJin(Long auctionId, String name, BigDecimal perface, int totalNum,
    public static TaoLiJinDTO createTaoLiJin(String auctionId, String name, BigDecimal perface, int totalNum,
                                             Date sendStartTime, Date sendEndTime, Date useStartTime, Date useEndTime, TaoKeAppInfo app)
            throws TaoLiJinCreateException, TaoKeApiException {
        Map<String, String> map = new HashMap<>();
@@ -2007,10 +1901,11 @@
    }
    // 淘礼金报告
    public static UserTaoLiJinReport getTaoLiJinEffective(String rightsId) {
    public static UserTaoLiJinReport getTaoLiJinEffective(String rightsId, String pid) {
        Map<String, String> map = new HashMap<>();
        map.put("method", "taobao.tbk.dg.vegas.tlj.instance.report");
        map.put("method", "taobao.tbk.dg.vegas.tlj.report(");
        map.put("rights_id", rightsId);
        map.put("adzone_id", pid.split("_")[3]);
        TaoKeAppInfo app = new TaoKeAppInfo();
        app.setAppKey(TaoBaoConstant.TAOBAO_AUTH_APPKEY);
@@ -2021,27 +1916,24 @@
            JSONObject json = JSONObject.fromObject(result);
            System.out.println(json);
            JSONObject root = json.optJSONObject("tbk_dg_vegas_tlj_instance_report_response");
            JSONObject root = json.optJSONObject("tbk_dg_vegas_tlj_report_response");
            if (root != null && root.optJSONObject("result") != null) {
                if (root.optJSONObject("result").optBoolean("success")) {
                    JSONObject modelJson = root.optJSONObject("result").optJSONObject("model");
                    if (modelJson != null && modelJson.size() > 0) {
                        UserTaoLiJinReport report = new UserTaoLiJinReport();
                        report.setId(rightsId);
                        report.setUnfreezeAmount(new BigDecimal(modelJson.optString("unfreeze_amount")));
                        report.setUnfreezeNum(modelJson.optInt("unfreeze_num"));
                        report.setRefundAmount(new BigDecimal(modelJson.optString("refund_amount")));
                        report.setRefundNum(modelJson.optInt("refund_num"));
                        report.setAlipayAmount(new BigDecimal(modelJson.optString("alipay_amount")));
                        report.setUseAmount(new BigDecimal(modelJson.optString("use_amount")));
                        report.setUseNum(modelJson.optInt("use_num"));
                        report.setWinAmount(new BigDecimal(modelJson.optString("win_amount")));
                        report.setWinNum(modelJson.optInt("win_num"));
                        report.setPreCommissionAmount(new BigDecimal(modelJson.optString("pre_commission_amount")));
                        return report;
                    }
            if (root != null && root.optBoolean("result_success")) {
                JSONObject modelJson = root.optJSONObject("model").optJSONObject("extra");
                if (modelJson != null && modelJson.size() > 0) {
                    UserTaoLiJinReport report = new UserTaoLiJinReport();
                    report.setId(rightsId);
                    report.setWinAmount(new BigDecimal(modelJson.optString("win_sum_amt")));
                    report.setWinNum(modelJson.optInt("win_pv"));
                    report.setRefundAmount(new BigDecimal(modelJson.optString("refund_sum_amt")));
                    report.setRefundNum(modelJson.optInt("refund_num"));
                    report.setAlipayAmount(new BigDecimal(modelJson.optString("alipay_amt")));
                    report.setUseAmount(new BigDecimal(modelJson.optString("use_sum_amt")));
                    report.setUseNum(modelJson.optInt("use_num"));
                    report.setUnfreezeAmount(new BigDecimal(modelJson.optString("remaining_amt")));
                    report.setUnfreezeNum(modelJson.optInt("remaining_num"));
                    report.setPreCommissionAmount(new BigDecimal(modelJson.optString("pre_pub_share_fee_for_disp")));
                    return report;
                }
            }
        } catch (Exception e) {
@@ -2050,11 +1942,11 @@
        return null;
    }
    public static void getCouponByAuctionId(Long auctionId) {
    public static void getCouponByAuctionId(String auctionId) {
        Map<String, String> map = new HashMap<>();
        map.put("method", "taobao.tbk.itemid.coupon.get");
        map.put("platform", 2 + "");
        map.put("pid", TaoBaoConstant.TAOBAO_RELATION_AS_SPECIAL_PID);
        map.put("pid", TaoBaoConstant.TAOBAO_PID_DEFAULT);
        map.put("num_iids", auctionId + "");
        TaoKeAppInfo app = new TaoKeAppInfo();
        app.setAppKey(TaoBaoConstant.TAOBAO_AUTH_APPKEY);
@@ -2068,7 +1960,7 @@
    }
    /**
     * 获取淘宝系统时间
     * 获取淘宝系统时间(收费API,谨慎调用)
     *
     * @return
     */
@@ -2121,7 +2013,7 @@
        return null;
    }
    public static List<TaoBaoGoodsBrief> guessLikeByAuctionId(Long auctionId, int count) {
    public static List<TaoBaoGoodsBrief> guessLikeByAuctionId(String auctionId, int count) {
        Map<String, String> map = new HashMap<>();
        map.put("method", "taobao.tbk.dg.optimus.material");
        map.put("item_id", auctionId + "");
@@ -2154,18 +2046,18 @@
        return goodsList;
    }
    public static List<TaoBaoGoodsBrief> getCouponListByItemId(Long auctionId) {
    public static List<TaoBaoGoodsBrief> getCouponListByItemId(String auctionId) {
        Map<String, String> map = new HashMap<>();
        map.put("method", "taobao.tbk.itemid.coupon.get");
        map.put("platform", auctionId + "");
        map.put("num_iids", auctionId + "");
        map.put("pid", TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT);
        map.put("pid", TaoBaoConstant.TAOBAO_PID_DEFAULT);
        List<TaoBaoGoodsBrief> goodsList = new ArrayList<>();
        JSONObject resultJSON = null;
        try {
            resultJSON = TaoKeBaseUtil.baseRequest(map, new TaoKeAppInfo(TaoBaoConstant.TAOBAO_AUTH_APPKEY,
                    TaoBaoConstant.TAOBAO_AUTH_APPSECRET, TaoBaoConstant.TAOBAO_SPECIAL_PID_DEFAULT));
                    TaoBaoConstant.TAOBAO_AUTH_APPSECRET, TaoBaoConstant.TAOBAO_PID_DEFAULT));
            JSONObject response = resultJSON.optJSONObject("tbk_dg_optimus_material_response");
            if (response != null && response.optJSONObject("result_list") != null) {