| | |
| | | package com.yeshi.fanli.util.taobao;
|
| | |
|
| | | import java.io.UnsupportedEncodingException;
|
| | | import java.lang.reflect.Field;
|
| | | import java.lang.reflect.Type;
|
| | | import java.math.BigDecimal;
|
| | | import java.net.URLEncoder;
|
| | |
| | | import com.yeshi.fanli.entity.taobao.TaoBaoQuanInfo;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoSearchNav;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoSearchResult;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoShop;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoUnionConfig;
|
| | | import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | |
| | | * 用户再次分成比例(0-100)
|
| | | * @return
|
| | | */
|
| | | public static String getGoodsHongBaoInfo(TaoBaoGoodsBrief goodsBrief, BigDecimal rate) { |
| | | public static String getGoodsHongBaoInfo(TaoBaoGoodsBrief goodsBrief, BigDecimal rate) {
|
| | | if (goodsBrief != null && goodsBrief.getMaterialLibType() != null && goodsBrief.getMaterialLibType() == 0)
|
| | | return "¥0.00";
|
| | | else |
| | | return "¥" + getGoodsHongBaoMoney(goodsBrief, rate).toString(); |
| | | else
|
| | | return "¥" + getGoodsHongBaoMoney(goodsBrief, rate).toString();
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | return null;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 根据商品ID获取店铺详情
|
| | | * |
| | | * @param auctionId
|
| | | * @return
|
| | | */
|
| | | public static TaoBaoShop getTaoBaoShopDetailByAuctionId(Long auctionId) {
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("itemNumId", auctionId + "");
|
| | |
|
| | | String url = "";
|
| | | try {
|
| | | url = String.format("https://acs.m.taobao.com/h5/mtop.taobao.detail.getdetail/6.0/?data=%s",
|
| | | URLEncoder.encode(data.toString(), "UTF-8"));
|
| | | } catch (UnsupportedEncodingException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | String result = HttpUtil.get(url);
|
| | | JSONObject resultJson = JSONObject.fromObject(result);
|
| | | JSONObject dataJson = resultJson.optJSONObject("data");
|
| | | JSONObject sellerJson = dataJson.optJSONObject("seller");
|
| | | TaoBaoShop shop = new TaoBaoShop();
|
| | | shop.setGoodRatePercentage(new BigDecimal(sellerJson.optString("goodRatePercentage").replace("%", "")));
|
| | | shop.setId(sellerJson.optLong("userId"));
|
| | |
|
| | | JSONArray array = sellerJson.optJSONArray("evaluates");
|
| | | for (int i = 0; i < array.size(); i++) {
|
| | | JSONObject item = array.optJSONObject(i);
|
| | | if ("宝贝描述".equalsIgnoreCase(item.optString("title"))) {
|
| | | shop.setScoreGoods(new BigDecimal(item.optString("score").trim()));
|
| | | shop.setScoreGoodsD(new BigDecimal(item.optString("level").trim()));
|
| | | } else if ("卖家服务".equalsIgnoreCase(item.optString("title"))) {
|
| | | shop.setScoreSeller(new BigDecimal(item.optString("score").trim()));
|
| | | shop.setScoreSellerD(new BigDecimal(item.optString("level").trim()));
|
| | | } else if ("物流服务".equalsIgnoreCase(item.optString("title"))) {
|
| | | shop.setScoreLogistics(new BigDecimal(item.optString("score").trim()));
|
| | | shop.setScoreLogisticsD(new BigDecimal(item.optString("level").trim()));
|
| | | }
|
| | | }
|
| | |
|
| | | shop.setSellerNick(sellerJson.optString("sellerNick"));
|
| | | shop.setShopIcon("https:" + sellerJson.optString("shopIcon"));
|
| | | shop.setShopId(sellerJson.optLong("shopId"));
|
| | | shop.setShopName(sellerJson.optString("shopName"));
|
| | | if ("B".equalsIgnoreCase(sellerJson.optString("sellerType")))
|
| | | shop.setUserType(1);
|
| | | else
|
| | | shop.setUserType(0);
|
| | |
|
| | | return shop;
|
| | | }
|
| | |
|
| | | public static void main(String[] args) {
|
| | | String s = channelMap.get("3");
|
| | | System.out.println(s);
|