yujian
2019-05-24 fc0cc7e808f9228b39b1e6b9d29c5417f41dbcc4
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;
@@ -63,6 +64,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;
@@ -703,7 +705,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();
@@ -714,7 +719,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);
@@ -762,8 +767,8 @@
      // 测试使用
      // tg.setSalesType(Math.random() > 0.5 ? tg.getSalesType() : 3);
      // List<ClientTextStyleVO> labels = new ArrayList<>();
      // labels.add(new ClientTextStyleVO("标签测试内容", "#FF0000"));
      // labels.add(new ClientTextStyleVO("标签测试内容", "#00FF00"));
      // labels.add(new ClientTextStyleVO("标签内容", "#F14242"));
      // labels.add(new ClientTextStyleVO("标签内容", "#00FF00"));
      // tg.setLabels(labels);
      return tg;
   }
@@ -1015,8 +1020,8 @@
      // 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"));
      // labels.add(new ClientTextStyleVO("标签内容", "#F14242"));
      // labels.add(new ClientTextStyleVO("标签内容", "#000000"));
      // tg.setLabels(labels);
      return tg;
@@ -1345,9 +1350,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 +1366,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 +1410,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);
   }
   /**