| | |
| | | package com.yeshi.fanli.util.pinduoduo;
|
| | |
|
| | | import java.io.IOException;
|
| | | import java.io.UnsupportedEncodingException;
|
| | | import java.math.BigDecimal;
|
| | | import java.net.URLEncoder;
|
| | | import java.util.ArrayList;
|
| | | import java.util.List;
|
| | |
| | | import org.jsoup.Jsoup;
|
| | | import org.jsoup.nodes.Document;
|
| | | import org.jsoup.select.Elements;
|
| | | import org.yeshi.utils.BigDecimalUtil;
|
| | | import org.yeshi.utils.HttpUtil;
|
| | |
|
| | | import com.yeshi.fanli.dto.pdd.PDDGoodsDetail;
|
| | | import com.yeshi.fanli.util.MoneyBigDecimalUtil;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | |
|
| | | import net.sf.json.JSONArray;
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | |
|
| | | public class PinDuoDuoUtil {
|
| | |
|
| | | |
| | | /**
|
| | | * 商品佣金计算
|
| | | * @param goods
|
| | | * @param rate
|
| | | * @return
|
| | | */
|
| | | public static BigDecimal getGoodsFanLiMoney(PDDGoodsDetail goods, BigDecimal rate) {
|
| | | BigDecimal money = null;
|
| | | BigDecimal price = new BigDecimal(goods.getMinNormalPrice());
|
| | | BigDecimal promotionRate = new BigDecimal(goods.getPromotionRate());
|
| | | |
| | | Boolean hasCoupon = goods.getHasCoupon();
|
| | | if (hasCoupon == null || !hasCoupon) {
|
| | | money = MoneyBigDecimalUtil.mul(MoneyBigDecimalUtil.mul(
|
| | | MoneyBigDecimalUtil.mul(price, promotionRate),new BigDecimal("0.001")),
|
| | | MoneyBigDecimalUtil.div(rate, new BigDecimal(100)));
|
| | | } else {
|
| | | BigDecimal amount = new BigDecimal(goods.getCouponDiscount());
|
| | | BigDecimal startFree = new BigDecimal(goods.getCouponMinOrderAmount()); |
| | | if (startFree.compareTo(price) <= 0 && price.compareTo(amount) > 0) {
|
| | | BigDecimal finalPrice = price.subtract(amount);
|
| | | money = MoneyBigDecimalUtil.mul(MoneyBigDecimalUtil
|
| | | .mul(MoneyBigDecimalUtil.mul(finalPrice, promotionRate), new BigDecimal("0.001")),
|
| | | MoneyBigDecimalUtil.div(rate, new BigDecimal(100)));
|
| | |
|
| | | } else {// 不能用券
|
| | | money = MoneyBigDecimalUtil.mul(MoneyBigDecimalUtil.mul(
|
| | | MoneyBigDecimalUtil.mul(price,promotionRate), new BigDecimal("0.001")), |
| | | MoneyBigDecimalUtil.div(rate, new BigDecimal(100)));
|
| | | }
|
| | | }
|
| | | return BigDecimalUtil.getWithNoZera(money);
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * 计算商品券后价,没有券则返回原价
|
| | | * |
| | | * @param goodsBrief
|
| | | * @return
|
| | | */
|
| | | public static BigDecimal getQuanPrice(PDDGoodsDetail goods) {
|
| | | BigDecimal price = new BigDecimal(goods.getMinNormalPrice());
|
| | | Boolean hasCoupon = goods.getHasCoupon();
|
| | | if (hasCoupon == null || !hasCoupon) {
|
| | | return price;
|
| | | }
|
| | | |
| | | BigDecimal amount = new BigDecimal(goods.getCouponDiscount());
|
| | | BigDecimal startFree = new BigDecimal(goods.getCouponMinOrderAmount());
|
| | | if (startFree.compareTo(price) <= 0) {
|
| | | BigDecimal quanPrice = MoneyBigDecimalUtil.sub(price, amount);
|
| | | return quanPrice;
|
| | | } else {
|
| | | return price;
|
| | | }
|
| | | }
|
| | | |
| | | public static String getSaleCount(long count) {
|
| | | String salesCountMidea = null;
|
| | | if (count < 10000) {
|
| | | salesCountMidea = count + "";
|
| | | } else {
|
| | | double sales = count;
|
| | | salesCountMidea = String.format("%.1f", sales / 10000);
|
| | | salesCountMidea = salesCountMidea + "万";
|
| | | }
|
| | | return salesCountMidea;
|
| | | }
|
| | | |
| | |
|
| | |
|
| | |
|
| | |
|
| | | public static List<String> getDetailImages(Long id) {
|
| | | List<String> imgList = new ArrayList<>();
|
| | | try {
|