From b9f8ef2c4737b6e6be4b12fc8f7bafb033bfcfe5 Mon Sep 17 00:00:00 2001
From: admin <2780501319@qq.com>
Date: 星期日, 22 九月 2019 16:47:33 +0800
Subject: [PATCH] 金币BUG修改
---
fanli/src/main/java/com/yeshi/fanli/util/taobao/TaoBaoUtil.java | 223 +++++++++++++++++++++++++++++++++++++------------------
1 files changed, 148 insertions(+), 75 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 fe21a3b..f320f20 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
@@ -28,6 +28,7 @@
import org.springframework.stereotype.Component;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.NodeList;
+import org.yeshi.utils.BigDecimalUtil;
import org.yeshi.utils.HttpUtil;
import org.yeshi.utils.NumberUtil;
import org.yeshi.utils.entity.ProxyIP;
@@ -52,18 +53,19 @@
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.entity.taobao.dataoke.DaTaoKeDetailV2;
import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.service.inter.goods.TaoBaoLinkService;
-import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
+import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
import com.yeshi.fanli.tag.PageEntity;
import com.yeshi.fanli.util.AESUtil;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.MoneyBigDecimalUtil;
import com.yeshi.fanli.util.StringUtil;
+import com.yeshi.fanli.util.TaoBaoConstant;
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;
@@ -703,8 +705,13 @@
tg.setReservePrice(tb.getReservePrice());
tg.setUserType(tb.getUserType());
tg.setShopTitle(tb.getShopTitle());
+ tg.setTkRate(tb.getTkRate());
+ tg.setSellerId(tb.getSellerId());
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();
@@ -715,7 +722,7 @@
quanInfo.setCouponLeftCount(tb.getCouponLeftCount());
quanInfo.setCouponLink(
TaoBaoCouponUtil.getCoupleUrl(tb.getCouponActivityId(), pid, tb.getAuctionId() + ""));
- quanInfo.setCouponPrice(tb.getZkPrice().subtract(tb.getTkCommFee()));
+ quanInfo.setCouponPrice(MoneyBigDecimalUtil.sub(tg.getZkPrice(), tb.getCouponAmount()));
quanInfo.setCouponStartFee(tb.getCouponStartFee());
quanInfo.setCouponTotalCount(tb.getCouponTotalCount());
tg.setTaoBaoQuanInfo(quanInfo);
@@ -758,15 +765,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("鏍囩娴嬭瘯鍐呭", "#FF0000"));
- labels.add(new ClientTextStyleVO("鏍囩娴嬭瘯鍐呭", "#00FF00"));
- tg.setLabels(labels);
-
+ // tg.setSalesType(Math.random() > 0.5 ? tg.getSalesType() : 3);
+ // if(Constant.IS_TEST)
+ // {
+ // List<ClientTextStyleVO> labels = new ArrayList<>();
+ // labels.add(new ClientTextStyleVO("鏍囩鍐呭", "#F14242"));
+ // labels.add(new ClientTextStyleVO("鏍囩鍐呭", "#00FF00"));
+ // tg.setLabels(labels);
+ // }
return tg;
}
@@ -1010,14 +1019,16 @@
}
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("鏍囩娴嬭瘯鍐呭", "#FF0000"));
- labels.add(new ClientTextStyleVO("鏍囩娴嬭瘯鍐呭", "#00FF00"));
- tg.setLabels(labels);
+ // 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;
}
@@ -1345,9 +1356,11 @@
* @return
*/
public static BigDecimal getGoodsHongBaoMoney(TaoBaoGoodsBrief goodsBrief, BigDecimal rate) {
+ BigDecimal money = null;
+
if (StringUtil.isNullOrEmpty(goodsBrief.getCouponInfo())
|| goodsBrief.getCouponInfo().trim().equalsIgnoreCase("鏃�")) {
- return MoneyBigDecimalUtil.mul(
+ money = MoneyBigDecimalUtil.mul(
MoneyBigDecimalUtil.mul(MoneyBigDecimalUtil.mul(goodsBrief.getZkPrice(), goodsBrief.getTkRate()),
new BigDecimal("0.01")),
MoneyBigDecimalUtil.div(rate, new BigDecimal(100)));
@@ -1359,16 +1372,17 @@
if (startFee.compareTo(goodsBrief.getZkPrice()) <= 0
&& goodsBrief.getZkPrice().compareTo(couponAccount) > 0) {
BigDecimal finalPrice = goodsBrief.getZkPrice().subtract(couponAccount);
- return MoneyBigDecimalUtil.mul(MoneyBigDecimalUtil
+ money = MoneyBigDecimalUtil.mul(MoneyBigDecimalUtil
.mul(MoneyBigDecimalUtil.mul(finalPrice, goodsBrief.getTkRate()), new BigDecimal("0.01")),
MoneyBigDecimalUtil.div(rate, new BigDecimal(100)));
} else {// 涓嶈兘鐢ㄥ埜
- return MoneyBigDecimalUtil.mul(MoneyBigDecimalUtil.mul(
+ money = MoneyBigDecimalUtil.mul(MoneyBigDecimalUtil.mul(
MoneyBigDecimalUtil.mul(goodsBrief.getZkPrice(), goodsBrief.getTkRate()),
new BigDecimal("0.01")), MoneyBigDecimalUtil.div(rate, new BigDecimal(100)));
}
}
+ return BigDecimalUtil.getWithNoZera(money);
}
// }
@@ -1402,30 +1416,7 @@
*/
public static BigDecimal getShareGoodsHongBaoInfo(TaoBaoGoodsBrief goodsBrief, BigDecimal rate) {
-
- // 璁$畻杩斿埄
- // 鏃犲埜
- if (StringUtil.isNullOrEmpty(goodsBrief.getCouponInfo()) || goodsBrief.getCouponInfo().contains("鏃�")) {
- return goodsBrief.getZkPrice().multiply(goodsBrief.getTkRate()).divide(new BigDecimal(10000)).multiply(rate)
- .setScale(2, BigDecimal.ROUND_DOWN);
-
- } else// 鏈夊埜
- {
- List<BigDecimal> list = TaoBaoCouponUtil.getCouponInfo(goodsBrief.getCouponInfo());
- BigDecimal startFee = list.get(0);
- BigDecimal couponAccount = list.get(1);
- 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);
-
- } else {// 涓嶈兘鐢ㄥ埜
- return goodsBrief.getZkPrice().multiply(goodsBrief.getTkRate()).divide(new BigDecimal(10000))
- .multiply(rate).setScale(2, BigDecimal.ROUND_DOWN);
- }
-
- }
+ return getGoodsHongBaoMoney(goodsBrief, rate);
}
/**
@@ -1699,7 +1690,8 @@
MoneyBigDecimalUtil.getWithNoZera(detail.getQuanPrice())));
taoBaoGoods.setCouponLeftCount(detail.getQuanSurplus());
taoBaoGoods.setCouponStartFee(new BigDecimal(detail.getQuanCondition()));
- taoBaoGoods.setCouponTotalCount(detail.getQuanSurplus());
+ if (detail.getQuanReceive() != null)
+ taoBaoGoods.setCouponTotalCount(detail.getQuanSurplus() + detail.getQuanReceive());
taoBaoGoods.setPictUrl(detail.getPic());
taoBaoGoods.setPictUrlWhite(detail.getPic());
taoBaoGoods.setSellerId(detail.getSellerId());
@@ -1708,6 +1700,38 @@
taoBaoGoods.setUserType(detail.getIsTmall());
taoBaoGoods.setZkPrice(detail.getOrgPrice());
taoBaoGoods.setTkRate(detail.getCommission());
+ taoBaoGoods.setTkCommFee(new BigDecimal("0"));
+ taoBaoGoods.setState(0);
+ return taoBaoGoods;
+ }
+
+ public static TaoBaoGoodsBrief convert(DaTaoKeDetailV2 detail) {
+ TaoBaoGoodsBrief taoBaoGoods = new TaoBaoGoodsBrief();
+ taoBaoGoods.setAuctionId(detail.getGoodsId());
+ taoBaoGoods.setBiz30day(detail.getMonthSales());
+ taoBaoGoods.setCouponAmount(detail.getCouponPrice());
+ taoBaoGoods.setCouponInfo(String.format("婊�%s鍏冨噺%s鍏�", detail.getCouponConditions(),
+ MoneyBigDecimalUtil.getWithNoZera(detail.getCouponPrice())));
+ if (detail.getCouponTotalNum() != null && detail.getCouponReceiveNum() != null)
+ taoBaoGoods.setCouponLeftCount(detail.getCouponTotalNum() - detail.getCouponReceiveNum());
+ else
+ taoBaoGoods.setCouponLeftCount(0);
+ taoBaoGoods.setCouponStartFee(detail.getOriginalPrice());
+ taoBaoGoods.setCouponTotalCount(detail.getCouponTotalNum());
+ taoBaoGoods.setPictUrl(detail.getMainPic());
+ taoBaoGoods.setPictUrlWhite(detail.getMainPic());
+ if (taoBaoGoods.getPictUrl() != null && !taoBaoGoods.getPictUrl().startsWith("http"))
+ taoBaoGoods.setPictUrl("https:" + taoBaoGoods.getPictUrl());
+
+ if (taoBaoGoods.getPictUrlWhite() != null && !taoBaoGoods.getPictUrlWhite().startsWith("http"))
+ taoBaoGoods.setPictUrlWhite("https:" + taoBaoGoods.getPictUrlWhite());
+
+ taoBaoGoods.setSellerId(detail.getSellerId());
+ taoBaoGoods.setShopTitle(detail.getShopName());
+ taoBaoGoods.setTitle(detail.getDtitle());
+ taoBaoGoods.setUserType(detail.getShopType());
+ taoBaoGoods.setZkPrice(detail.getOriginalPrice());
+ taoBaoGoods.setTkRate(detail.getCommissionRate());
taoBaoGoods.setTkCommFee(new BigDecimal("0"));
taoBaoGoods.setState(0);
return taoBaoGoods;
@@ -1799,38 +1823,68 @@
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()));
+ try {
+ JSONObject resultJson = JSONObject.fromObject(result);
+ JSONObject dataJson = resultJson.optJSONObject("data");
+ JSONObject sellerJson = dataJson.optJSONObject("seller");
+
+ shop.setGoodRatePercentage(new BigDecimal(sellerJson.optString("goodRatePercentage").replace("%", "")));
+
+ LogHelper.test("鍗栧淇℃伅:" + result);
+ 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()));
+ } catch (Exception e) {
+ // if (1 > 0)
+ // return null;
+ try {
+ TaoBaoGoodsBrief goods = TaoKeApiUtil.getSimpleGoodsInfo(auctionId);
+ shop.setId(goods.getSellerId());
+ shop.setShopName(goods.getShopTitle());
+ shop.setUserType(goods.getUserType());
+ } catch (Exception e1) {
+ shop.setId(1L);
+ shop.setShopName("");
+ shop.setUserType(0);
+ }
+
+ shop.setGoodRatePercentage(new BigDecimal(100));
+ shop.setScoreGoods(new BigDecimal("4.9"));
+ shop.setScoreGoodsD(new BigDecimal("0"));
+ shop.setScoreSeller(new BigDecimal("4.9"));
+ shop.setScoreSellerD(new BigDecimal("0"));
+ shop.setScoreLogistics(new BigDecimal("4.9"));
+ shop.setScoreLogisticsD(new BigDecimal("0"));
+ shop.setSellerNick("");
+ shop.setShopIcon("https:");
+ shop.setShopLink(TaoBaoUtil.getShopLink(shop.getId()));
}
-
- 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;
}
@@ -1845,6 +1899,25 @@
return "http://store.taobao.com/shop/view_shop.htm?user_number_id=" + sellerId;
}
+ /**
+ * 鏄惁鍙互鍔犲叆娣樼ぜ閲戠殑棰勯�夊晢鍝佸簱
+ *
+ * @param v2
+ * @return
+ */
+ public static boolean canAddToTLJBuyGoods(TaoBaoGoodsBrief goods) {
+ BigDecimal tljMoney = getShareGoodsHongBaoInfo(goods, TaoBaoConstant.OWN_BUY_WITHOUT_FANLI_RATE);
+ // 涓嶈兘灏忎簬1鍧�
+ if (tljMoney.compareTo(new BigDecimal(1)) < 0 || tljMoney.compareTo(new BigDecimal(10)) > 0)
+ return false;
+
+ // 鍒稿悗浠蜂笉鑳藉ぇ浜�150
+ if (getAfterUseCouplePrice(goods).compareTo(new BigDecimal(150)) > 0)
+ return false;
+
+ return true;
+ }
+
public static void main(String[] args) {
String s = channelMap.get("3");
System.out.println(s);
--
Gitblit v1.8.0