package com.yeshi.fanli.util.suning;
|
|
import java.math.BigDecimal;
|
|
import org.yeshi.utils.BigDecimalUtil;
|
|
import com.yeshi.fanli.dto.suning.SuningGoodsInfo;
|
import com.yeshi.fanli.util.MoneyBigDecimalUtil;
|
import com.yeshi.fanli.util.StringUtil;
|
|
public class SuningUtil {
|
public static BigDecimal getGoodsFanLiMoney(SuningGoodsInfo goods, BigDecimal rate) {
|
|
BigDecimal hundred = new BigDecimal(100);
|
rate = MoneyBigDecimalUtil.div(rate, hundred);
|
|
BigDecimal afterUseCouponPrice = new BigDecimal(goods.getCommodityInfo().getCommodityPrice());
|
if (goods.getCouponInfo() != null && !StringUtil.isNullOrEmpty(goods.getCouponInfo().getCouponUrl())) {
|
// 有券
|
BigDecimal startPrice = new BigDecimal(goods.getCouponInfo().getBounsLimit());
|
if (afterUseCouponPrice.compareTo(startPrice) >= 0) {
|
afterUseCouponPrice = afterUseCouponPrice.subtract(startPrice);
|
}
|
}
|
|
BigDecimal money = MoneyBigDecimalUtil.mul(afterUseCouponPrice, rate);
|
return BigDecimalUtil.getWithNoZera(money).setScale(2);
|
}
|
|
/**
|
* 获取拼接的商品ID
|
* @Title: getConcatGoodsIId
|
* @Description:
|
* @param supplierCode
|
* @param goodsId
|
* @return
|
* String 返回类型
|
* @throws
|
*/
|
public static String getConcatGoodsIId(String supplierCode, String goodsId) {
|
|
return supplierCode + "-" + goodsId;
|
}
|
|
public static String getFullSupplierCode(String supplierCode){
|
for (int i = 0; i < 10; i++) {
|
if (supplierCode.length() < 10)
|
supplierCode = "0" + supplierCode;
|
}
|
|
return supplierCode;
|
}
|
|
/**
|
* 通过拼接的商品ID解析出来正确的商品ID
|
* @Title: getGoodsIdDetail
|
* @Description:
|
* @param concatGoodsId
|
* @return
|
* String[] 返回类型
|
* @throws
|
*/
|
public static String[] getGoodsIdDetail(String concatGoodsId) {
|
String[] sts = concatGoodsId.split("-");
|
String supplierCode = sts[0];
|
for (int i = 0; i < 10; i++) {
|
if (supplierCode.length() < 10)
|
supplierCode = "0" + supplierCode;
|
}
|
return new String[] { supplierCode, sts[1] };
|
}
|
|
public static String getProductUrl(String supplierCode, String goodsId) {
|
|
return String.format("https://product.suning.com/%s/%s.html", supplierCode, goodsId);
|
}
|
|
}
|