| | |
| | | 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;
|
| | |
| | | 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.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;
|
| | |
| | | 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();
|
| | |
| | | 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);
|
| | |
| | |
|
| | | 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;
|
| | | }
|
| | |
|
| | |
| | | }
|
| | | 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;
|
| | | }
|
| | |
| | | * @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)));
|
| | |
| | | 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);
|
| | | }
|
| | |
|
| | | // }
|
| | |
| | | */
|
| | |
|
| | | 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);
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | 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());
|
| | |
| | | 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;
|
| | |
| | | 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;
|
| | | }
|
| | |
| | | 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);
|