| | |
| | | System.out.println(result);
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * 搜索网页
|
| | | * |
| | | * @param searchFilter
|
| | | * @return
|
| | | */
|
| | |
| | | params.put("pageNo", searchFilter.getPageNo());
|
| | | params.put("pageSize", searchFilter.getPageSize());
|
| | | params.put("searchUUID", StringUtil.Md5(System.currentTimeMillis() + ""));
|
| | | |
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("lock", "0");
|
| | | data.put("deliveryType", searchFilter.getDeliveryType());
|
| | |
| | | data.put("isPinGou", searchFilter.getIsPinGou());
|
| | | data.put("isZY", searchFilter.getIsZY());
|
| | | data.put("orientationFlag", searchFilter.getOrientationFlag());
|
| | | |
| | |
|
| | | // 分类
|
| | | data.put("categoryId", searchFilter.getCategoryId());
|
| | | data.put("cat2Id", searchFilter.getCat2Id());
|
| | | data.put("cat3Id", searchFilter.getCat3Id());
|
| | | |
| | |
|
| | | data.put("fromCommissionRatio", searchFilter.getFromCommissionRatio());
|
| | | data.put("toCommissionRatio", searchFilter.getToCommissionRatio());
|
| | | data.put("fromPrice", searchFilter.getFromPrice());
|
| | | data.put("toPrice", searchFilter.getToPrice());
|
| | | |
| | |
|
| | | String key = searchFilter.getKey();
|
| | | if (StringUtil.isNullOrEmpty(key)) {
|
| | | data.put("key", "");
|
| | |
| | | data.put("keywordType", "kt1");
|
| | | data.put("searchType", "st3");
|
| | | }
|
| | | |
| | |
|
| | | String sortName = searchFilter.getSortName();
|
| | | if (StringUtil.isNullOrEmpty(sortName)) {
|
| | | data.put("sort", null);
|
| | |
| | | String sort = searchFilter.getSort();
|
| | | if (StringUtil.isNullOrEmpty(sort)) {
|
| | | sort = JDSearchFilter.SORT_DESC;
|
| | | } |
| | | }
|
| | | data.put("sort", sort);
|
| | | }
|
| | | params.put("data", data);
|
| | | |
| | |
|
| | | System.out.println(params.toString());
|
| | | |
| | |
|
| | | HttpClient client = new HttpClient();
|
| | | PostMethod pm = new PostMethod("https://union.jd.com/api/goods/search");
|
| | | pm.setRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko");
|
| | |
| | | searchResult.setGoodsList(goodsList);
|
| | | return searchResult;
|
| | | }
|
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 搜索网页
|
| | | * |
| | | * @param searchFilter
|
| | | * @return
|
| | | */
|
| | |
| | | params.put("pageNo", 1);
|
| | | params.put("pageSize", 60);
|
| | | params.put("searchUUID", StringUtil.Md5(System.currentTimeMillis() + ""));
|
| | | |
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("lock", "0");
|
| | | data.put("deliveryType", 0);
|
| | | data.put("hasCoupon",0);
|
| | | data.put("hasCoupon", 0);
|
| | | data.put("isCare", 0);
|
| | | data.put("isPinGou", 0);
|
| | | data.put("isZY", 0);
|
| | | data.put("orientationFlag", 0);
|
| | | |
| | |
|
| | | data.put("key", skuId);
|
| | | data.put("keywordType", "kt0");
|
| | | data.put("searchType", "st2");
|
| | | params.put("data", data);
|
| | | |
| | |
|
| | | HttpClient client = new HttpClient();
|
| | | PostMethod pm = new PostMethod("https://union.jd.com/api/goods/search");
|
| | | pm.setRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko");
|
| | |
| | | return null;
|
| | | }
|
| | |
|
| | | |
| | | private static JDGoods parseGoods(String data) {
|
| | | JDGoods goods = new JDGoods();
|
| | | JSONObject json = JSONObject.fromObject(data);
|
| | | |
| | |
|
| | | BigDecimal wlCommissionRatio = new BigDecimal(json.optString("wlCommissionRatio"));
|
| | | if (wlCommissionRatio.compareTo(new BigDecimal(0)) > 0) {
|
| | | JDCommissionInfo commission = new JDCommissionInfo();
|
| | |
| | | } else {
|
| | | return null; // 过滤无返利商品
|
| | | }
|
| | | |
| | |
|
| | | goods.setSkuId(json.optLong("skuId"));
|
| | | goods.setSkuName(json.optString("skuName"));
|
| | | |
| | |
|
| | | JDShopInfo shopInfo = new JDShopInfo();
|
| | | shopInfo.setShopId(json.optInt("shopId"));
|
| | | shopInfo.setShopName(json.optString("shopName"));
|
| | | goods.setShopInfo(shopInfo);
|
| | | goods.setPrice(new BigDecimal(json.optString("wlPrice")));
|
| | | |
| | |
|
| | | goods.setInOrderCount30Days(json.optLong("inOrderCount30Days"));
|
| | | |
| | |
|
| | | if (json.optInt("isZY") == 1)
|
| | | goods.setOwner("g");
|
| | | else
|
| | | goods.setOwner("p");
|
| | | |
| | | goods.setMaterialUrl("https://item.jd.com/"+ json.optLong("skuId") +".html");
|
| | |
|
| | | goods.setMaterialUrl("https://item.jd.com/" + json.optLong("skuId") + ".html");
|
| | | goods.setPicUrl("http://img14.360buyimg.com/n1/" + json.optString("materialUrl"));
|
| | | |
| | |
|
| | | goods.setGoodCommentsShare(new BigDecimal(json.optString("goodCommentsShare")));
|
| | |
|
| | | // 团购信息
|
| | |
| | | jdPinGouInfo.setPingouPrice(new BigDecimal(json.optString("pingouPrice")));
|
| | | jdPinGouInfo.setPingouTmCount(json.optLong("pingouTmCount"));
|
| | | goods.setPinGouInfo(jdPinGouInfo);
|
| | | } |
| | | |
| | | |
| | | }
|
| | |
|
| | | String finalPrice = json.optString("finalPrice");
|
| | | if (!StringUtil.isNullOrEmpty(finalPrice)) {
|
| | | // 券信息
|
| | |
| | | coupon.setQuota(new BigDecimal(json.optString("couponQuota")));
|
| | | coupon.setLink("https:" + json.optString("couponLink"));
|
| | | goods.setCouponInfo(coupon);
|
| | | } |
| | | }
|
| | | }
|
| | | |
| | | |
| | |
|
| | | return goods;
|
| | | }
|
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 商品佣金计算
|
| | | * |
| | | * @param goods
|
| | | * @param rate
|
| | | * @return
|
| | | */
|
| | | public static BigDecimal getGoodsFanLiMoney(JDGoods goods, BigDecimal rate) {
|
| | | BigDecimal money = null;
|
| | | |
| | |
|
| | | JDCommissionInfo commissionInfo = goods.getCommissionInfo();
|
| | | if (commissionInfo == null) {
|
| | | return money;
|
| | | }
|
| | | |
| | |
|
| | | BigDecimal price = null;
|
| | | JDPingouInfo pinGouInfo = goods.getPinGouInfo();
|
| | | if (pinGouInfo == null) {
|
| | | price = goods.getPrice();
|
| | | price = goods.getPrice();
|
| | | } else {
|
| | | price = pinGouInfo.getPingouPrice();
|
| | | price = pinGouInfo.getPingouPrice();
|
| | | }
|
| | | |
| | |
|
| | | JDCouponInfo couponInfo = goods.getCouponInfo();
|
| | | if (couponInfo == null) {
|
| | | money = MoneyBigDecimalUtil.mul(MoneyBigDecimalUtil.mul(
|
| | | MoneyBigDecimalUtil.mul(price,commissionInfo.getCommissionShare()),
|
| | | new BigDecimal("0.01")), MoneyBigDecimalUtil.div(rate, new BigDecimal(100)));
|
| | | money = MoneyBigDecimalUtil.mul(MoneyBigDecimalUtil
|
| | | .mul(MoneyBigDecimalUtil.mul(price, commissionInfo.getCommissionShare()), new BigDecimal("0.01")),
|
| | | MoneyBigDecimalUtil.div(rate, new BigDecimal(100)));
|
| | | } else {
|
| | | BigDecimal quota = couponInfo.getQuota();
|
| | | BigDecimal discount = couponInfo.getDiscount();
|
| | | if (quota.compareTo(price) <= 0 && price.compareTo(discount) > 0) {
|
| | | |
| | |
|
| | | BigDecimal finalPrice = price.subtract(discount);
|
| | | money = MoneyBigDecimalUtil.mul(MoneyBigDecimalUtil
|
| | | .mul(MoneyBigDecimalUtil.mul(finalPrice, commissionInfo.getCommissionShare()), new BigDecimal("0.01")),
|
| | | MoneyBigDecimalUtil.div(rate, new BigDecimal(100)));
|
| | | money = MoneyBigDecimalUtil.mul(MoneyBigDecimalUtil.mul(
|
| | | MoneyBigDecimalUtil.mul(finalPrice, commissionInfo.getCommissionShare()),
|
| | | new BigDecimal("0.01")), MoneyBigDecimalUtil.div(rate, new BigDecimal(100)));
|
| | |
|
| | | } else {// 不能用券
|
| | | money = MoneyBigDecimalUtil.mul(MoneyBigDecimalUtil.mul(
|
| | | MoneyBigDecimalUtil.mul(price,commissionInfo.getCommissionShare()),
|
| | | new BigDecimal("0.01")), MoneyBigDecimalUtil.div(rate, new BigDecimal(100)));
|
| | | money = MoneyBigDecimalUtil.mul(
|
| | | MoneyBigDecimalUtil.mul(MoneyBigDecimalUtil.mul(price, commissionInfo.getCommissionShare()),
|
| | | new BigDecimal("0.01")),
|
| | | MoneyBigDecimalUtil.div(rate, new BigDecimal(100)));
|
| | | }
|
| | | |
| | |
|
| | | }
|
| | | return BigDecimalUtil.getWithNoZera(money);
|
| | | }
|
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 计算商品券后价,没有券则返回原价
|
| | | *
|
| | |
| | | JDCouponInfo couponInfo = jdGoods.getCouponInfo();
|
| | | if (couponInfo == null) {
|
| | | return jdGoods.getPrice();
|
| | | } |
| | | |
| | | }
|
| | |
|
| | | BigDecimal discount = couponInfo.getDiscount();
|
| | | BigDecimal price = null;
|
| | | JDPingouInfo pinGouInfo = jdGoods.getPinGouInfo();
|
| | | if (pinGouInfo == null) {
|
| | | price = jdGoods.getPrice();
|
| | | price = jdGoods.getPrice();
|
| | | } else {
|
| | | price = pinGouInfo.getPingouPrice();
|
| | | price = pinGouInfo.getPingouPrice();
|
| | | }
|
| | | // 计算券后价
|
| | | BigDecimal sub = price.subtract(couponInfo.getQuota());
|
| | |
| | | return jdGoods.getPrice();
|
| | | }
|
| | | }
|
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 销量处理
|
| | | * |
| | | * @param count
|
| | | * @return
|
| | | */
|
| | |
| | | }
|
| | | return salesCountMidea;
|
| | | }
|
| | | |
| | | /** |
| | |
|
| | | /**
|
| | | * 搜索候选词
|
| | | * |
| | | * @param key
|
| | | * @return
|
| | | */
|
| | |
| | | return list;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 根据链接提取商品ID
|
| | | * @param url
|
| | | * @return
|
| | | */
|
| | | public static String parseJDSkuIdByUrl(String url) {
|
| | | try {
|
| | | if (url.startsWith("https://item.m.jd.com/product/") || url.startsWith("http://item.m.jd.com/product/")
|
| | | || url.startsWith("https://item.jd.com/") || url.startsWith("http://item.jd.com/")) {
|
| | | String preUrl = url.split("\\?")[0];
|
| | | String index = preUrl.split("/")[preUrl.split("/").length - 1];
|
| | | index = index.split("\\.")[0];
|
| | | return index.trim();
|
| | | }
|
| | | } catch (Exception e) {
|
| | | }
|
| | | return null;
|
| | | }
|
| | |
|
| | | }
|