From 4114e871bcb3dce771b6aed64a1027d0bbb95ca6 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期四, 16 五月 2019 15:28:37 +0800
Subject: [PATCH] 增加动态用户

---
 fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoBaoUtil.java |  141 +++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 129 insertions(+), 12 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoBaoUtil.java b/fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoBaoUtil.java
index 304b648..9c3dcde 100644
--- a/fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoBaoUtil.java
+++ b/fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoBaoUtil.java
@@ -1,7 +1,6 @@
 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;
@@ -50,7 +49,9 @@
 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.entity.taobao.dataoke.DaTaoKeDetail;
 import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
 import com.yeshi.fanli.log.LogHelper;
 import com.yeshi.fanli.service.inter.goods.TaoBaoLinkService;
@@ -62,6 +63,7 @@
 import com.yeshi.fanli.util.StringUtil;
 import com.yeshi.fanli.util.TaoBaoHttpUtil;
 import com.yeshi.fanli.util.TimeUtil;
+import com.yeshi.fanli.vo.msg.ClientTextStyleVO;
 
 import net.sf.json.JSONArray;
 import net.sf.json.JSONObject;
@@ -702,7 +704,10 @@
 		tg.setUserType(tb.getUserType());
 		tg.setShopTitle(tb.getShopTitle());
 		tg.setState(tb.getState()); // 鐘舵�侊細2018-12-03
-		if (tb.getCouponAmount().compareTo(BigDecimal.valueOf(0)) == 1) {
+		if (tb.getCouponAmount().compareTo(BigDecimal.valueOf(0)) > 0) {
+			
+			tg.setCoupon(true);// 鏈夊埜 
+			
 			TaoBaoQuanInfo quanInfo = new TaoBaoQuanInfo();
 			quanInfo.setCouponAmount(tb.getCouponAmount());
 			String couponEffectiveEndTime = tb.getCouponEffectiveEndTime();
@@ -756,6 +761,14 @@
 
 		tg.setTaoBaoHongBaoInfo(hongBaoInfo);
 
+		tg.setMoneyType(1);
+		tg.setSalesType(1);
+		// 娴嬭瘯浣跨敤
+		// tg.setSalesType(Math.random() > 0.5 ? tg.getSalesType() : 3);
+		 List<ClientTextStyleVO> labels = new ArrayList<>();
+		 labels.add(new ClientTextStyleVO("鏍囩鍐呭", "#F14242"));
+		 labels.add(new ClientTextStyleVO("鏍囩鍐呭", "#00FF00"));
+		 tg.setLabels(labels);
 		return tg;
 	}
 
@@ -998,6 +1011,17 @@
 			}
 		}
 		tg.setTaoBaoHongBaoInfo(hongBaoInfo);
+
+		tg.setMoneyType(1);
+		tg.setSalesType(1);
+		// 娴嬭瘯浣跨敤
+		// tg.setMoneyType(Math.random() > 0.5 ? 1 : 2);
+		// tg.setSalesType(Math.random() > 0.5 ? 1 : 2);
+		// tg.setSalesType(Math.random() > 0.5 ? tg.getSalesType() : 3);
+		 List<ClientTextStyleVO> labels = new ArrayList<>();
+		 labels.add(new ClientTextStyleVO("鏍囩鍐呭", "#F14242"));
+		 labels.add(new ClientTextStyleVO("鏍囩鍐呭", "#000000"));
+		 tg.setLabels(labels);
 
 		return tg;
 	}
@@ -1310,10 +1334,11 @@
 	 * @return
 	 */
 	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();
+		// if (goodsBrief != null && goodsBrief.getMaterialLibType() != null &&
+		// goodsBrief.getMaterialLibType() == 0)
+		// return "楼0.00";
+		// else
+		return "楼" + getGoodsHongBaoMoney(goodsBrief, rate).toString();
 	}
 
 	/**
@@ -1326,8 +1351,10 @@
 	public static BigDecimal getGoodsHongBaoMoney(TaoBaoGoodsBrief goodsBrief, BigDecimal rate) {
 		if (StringUtil.isNullOrEmpty(goodsBrief.getCouponInfo())
 				|| goodsBrief.getCouponInfo().trim().equalsIgnoreCase("鏃�")) {
-			return goodsBrief.getZkPrice().multiply(goodsBrief.getTkRate()).divide(new BigDecimal(10000)).multiply(rate)
-					.setScale(2, BigDecimal.ROUND_DOWN);
+			return MoneyBigDecimalUtil.mul(
+					MoneyBigDecimalUtil.mul(MoneyBigDecimalUtil.mul(goodsBrief.getZkPrice(), goodsBrief.getTkRate()),
+							new BigDecimal("0.01")),
+					MoneyBigDecimalUtil.div(rate, new BigDecimal(100)));
 		} else// 鏈夊埜
 		{
 			List<BigDecimal> list = TaoBaoCouponUtil.getCouponInfo(goodsBrief.getCouponInfo());
@@ -1336,11 +1363,14 @@
 			if (startFee.compareTo(goodsBrief.getZkPrice()) <= 0
 					&& goodsBrief.getZkPrice().compareTo(couponAccount) > 0) {
 				BigDecimal finalPrice = goodsBrief.getZkPrice().subtract(couponAccount);
-				return finalPrice.multiply(goodsBrief.getTkRate()).divide(new BigDecimal(10000)).multiply(rate)
-						.setScale(2, BigDecimal.ROUND_DOWN);
+				return MoneyBigDecimalUtil.mul(MoneyBigDecimalUtil
+						.mul(MoneyBigDecimalUtil.mul(finalPrice, goodsBrief.getTkRate()), new BigDecimal("0.01")),
+						MoneyBigDecimalUtil.div(rate, new BigDecimal(100)));
+
 			} else {// 涓嶈兘鐢ㄥ埜
-				return goodsBrief.getZkPrice().multiply(goodsBrief.getTkRate()).divide(new BigDecimal(10000))
-						.multiply(rate).setScale(2, BigDecimal.ROUND_DOWN);
+				return MoneyBigDecimalUtil.mul(MoneyBigDecimalUtil.mul(
+						MoneyBigDecimalUtil.mul(goodsBrief.getZkPrice(), goodsBrief.getTkRate()),
+						new BigDecimal("0.01")), MoneyBigDecimalUtil.div(rate, new BigDecimal(100)));
 			}
 		}
 	}
@@ -1664,6 +1694,29 @@
 		return taoBaoGoods;
 	}
 
+	public static TaoBaoGoodsBrief convert(DaTaoKeDetail detail) {
+		TaoBaoGoodsBrief taoBaoGoods = new TaoBaoGoodsBrief();
+		taoBaoGoods.setAuctionId(detail.getGoodsId());
+		taoBaoGoods.setBiz30day(detail.getSalesNum());
+		taoBaoGoods.setCouponAmount(detail.getQuanPrice());
+		taoBaoGoods.setCouponInfo(String.format("婊�%s鍏冨噺%s鍏�", detail.getQuanCondition(),
+				MoneyBigDecimalUtil.getWithNoZera(detail.getQuanPrice())));
+		taoBaoGoods.setCouponLeftCount(detail.getQuanSurplus());
+		taoBaoGoods.setCouponStartFee(new BigDecimal(detail.getQuanCondition()));
+		taoBaoGoods.setCouponTotalCount(detail.getQuanSurplus());
+		taoBaoGoods.setPictUrl(detail.getPic());
+		taoBaoGoods.setPictUrlWhite(detail.getPic());
+		taoBaoGoods.setSellerId(detail.getSellerId());
+		taoBaoGoods.setShopTitle("");
+		taoBaoGoods.setTitle(detail.getdTitle());
+		taoBaoGoods.setUserType(detail.getIsTmall());
+		taoBaoGoods.setZkPrice(detail.getOrgPrice());
+		taoBaoGoods.setTkRate(detail.getCommission());
+		taoBaoGoods.setTkCommFee(new BigDecimal("0"));
+		taoBaoGoods.setState(0);
+		return taoBaoGoods;
+	}
+
 	/**
 	 * 鑾峰彇娣樺疂鑱旂洘鐨勬巿鏉冮摼鎺�
 	 * 
@@ -1732,6 +1785,70 @@
 		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").trim())) {
+				shop.setScoreGoods(new BigDecimal(item.optString("score").trim()));
+				shop.setScoreGoodsD(new BigDecimal(item.optString("level").trim()));
+			} else if ("鍗栧鏈嶅姟".equalsIgnoreCase(item.optString("title").trim())) {
+				shop.setScoreSeller(new BigDecimal(item.optString("score").trim()));
+				shop.setScoreSellerD(new BigDecimal(item.optString("level").trim()));
+			} else if ("鐗╂祦鏈嶅姟".equalsIgnoreCase(item.optString("title").trim())) {
+				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);
+
+		shop.setShopLink(TaoBaoUtil.getShopLink(shop.getId()));
+
+		return shop;
+	}
+
+	/**
+	 * 鏍规嵁鍗栧id鑾峰彇搴楅摵閾炬帴
+	 * 
+	 * @param sellerId
+	 * @return
+	 */
+	public static String getShopLink(Long sellerId) {
+		return "http://store.taobao.com/shop/view_shop.htm?user_number_id=" + sellerId;
+	}
+
 	public static void main(String[] args) {
 		String s = channelMap.get("3");
 		System.out.println(s);

--
Gitblit v1.8.0