| | |
| | | package com.yeshi.fanli.util.vipshop;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | |
|
| | | import org.yeshi.utils.BigDecimalUtil;
|
| | |
|
| | | import com.yeshi.fanli.dto.vip.goods.VIPGoodsInfo;
|
| | | import com.yeshi.fanli.util.MoneyBigDecimalUtil;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | |
|
| | | public class VipShopUtil {
|
| | |
|
| | | private static String getBase64Str(String str) {
|
| | | try {
|
| | | return StringUtil.getBase64String(str);
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | return null;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 获取分享的渠道标识
|
| | | * @Title: getShareChanTag
|
| | | * @Description: |
| | | * @param uid
|
| | | * @return |
| | | * String 返回类型
|
| | | * @throws
|
| | | */
|
| | | public static String getShareChanTag(Long uid) {
|
| | | return getBase64Str("share#" + uid);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 获取自购的渠道标识
|
| | | * @Title: getBuyChanTag
|
| | | * @Description: |
| | | * @param uid
|
| | | * @return |
| | | * String 返回类型
|
| | | * @throws
|
| | | */
|
| | | public static String getBuyChanTag(Long uid) {
|
| | | return getBase64Str("buy#" + uid);
|
| | |
|
| | | }
|
| | |
|
| | | public static String getUidFromChanTag(String tag) {
|
| | | String decodeTag = StringUtil.getFromBase64(tag);
|
| | | return decodeTag.split("#")[1];
|
| | | }
|
| | |
|
| | | public static String getTypeFromChanTag(String tag) {
|
| | | String decodeTag = StringUtil.getFromBase64(tag);
|
| | | return decodeTag.split("#")[0];
|
| | | }
|
| | |
|
| | | public static BigDecimal getGoodsFanLiMoney(VIPGoodsInfo goods, BigDecimal rate) {
|
| | | BigDecimal money = null;
|
| | | BigDecimal hundred = new BigDecimal(100);
|
| | | rate = MoneyBigDecimalUtil.div(rate, hundred);
|
| | | money = MoneyBigDecimalUtil.mul(new BigDecimal(goods.getCommission()), rate);
|
| | | return BigDecimalUtil.getWithNoZera(money).setScale(2);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 获取订单详情的唯一标识
|
| | | * @Title: getOrderDetailIdentifyCode
|
| | | * @Description: |
| | | * @param orderSn
|
| | | * @param goodsId
|
| | | * @param sizeId
|
| | | * @return |
| | | * String 返回类型
|
| | | * @throws
|
| | | */
|
| | | public static String getOrderDetailIdentifyCode(String orderSn, String goodsId, String sizeId) {
|
| | |
|
| | | return StringUtil.Md5(orderSn + "#" + goodsId + "#" + sizeId);
|
| | | }
|
| | | }
|
| | | package com.yeshi.fanli.util.vipshop; |
| | | |
| | | import java.math.BigDecimal; |
| | | |
| | | import org.yeshi.utils.BigDecimalUtil; |
| | | import org.yeshi.utils.NumberUtil; |
| | | |
| | | import com.yeshi.fanli.dto.vip.goods.VIPGoodsInfo; |
| | | import org.yeshi.utils.MoneyBigDecimalUtil; |
| | | import com.yeshi.fanli.util.StringUtil; |
| | | |
| | | public class VipShopUtil { |
| | | |
| | | private static String getBase64Str(String str) { |
| | | try { |
| | | return StringUtil.getBase64String(str); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 获取分享的渠道标识 |
| | | * @Title: getShareChanTag |
| | | * @Description: |
| | | * @param uid |
| | | * @return |
| | | * String 返回类型 |
| | | * @throws |
| | | */ |
| | | public static String getShareChanTag(Long uid) { |
| | | return getBase64Str("share#" + uid); |
| | | } |
| | | |
| | | /** |
| | | * 获取自购的渠道标识 |
| | | * @Title: getBuyChanTag |
| | | * @Description: |
| | | * @param uid |
| | | * @return |
| | | * String 返回类型 |
| | | * @throws |
| | | */ |
| | | public static String getBuyChanTag(Long uid) { |
| | | return getBase64Str("buy#" + uid); |
| | | |
| | | } |
| | | |
| | | public static String getCouponChanTag() { |
| | | return getBase64Str("coupon"); |
| | | |
| | | } |
| | | |
| | | public static String getUidFromChanTag(String tag) { |
| | | String decodeTag = StringUtil.getFromBase64(tag); |
| | | return decodeTag.split("#")[1]; |
| | | } |
| | | |
| | | public static String getTypeFromChanTag(String tag) { |
| | | String decodeTag = StringUtil.getFromBase64(tag); |
| | | return decodeTag.split("#")[0]; |
| | | } |
| | | |
| | | public static BigDecimal getGoodsFanLiMoney(VIPGoodsInfo goods, BigDecimal rate) { |
| | | BigDecimal money = null; |
| | | BigDecimal hundred = new BigDecimal(100); |
| | | rate = MoneyBigDecimalUtil.div(rate, hundred); |
| | | money = MoneyBigDecimalUtil.mul(new BigDecimal(goods.getCommission()), rate); |
| | | return BigDecimalUtil.getWithNoZera(money).setScale(2); |
| | | } |
| | | |
| | | /** |
| | | * 获取订单详情的唯一标识 |
| | | * @Title: getOrderDetailIdentifyCode |
| | | * @Description: |
| | | * @param orderSn |
| | | * @param goodsId |
| | | * @param sizeId |
| | | * @return |
| | | * String 返回类型 |
| | | * @throws |
| | | */ |
| | | public static String getOrderDetailIdentifyCode(String orderSn, String goodsId, String sizeId) { |
| | | |
| | | return StringUtil.Md5(orderSn + "#" + goodsId + "#" + sizeId); |
| | | } |
| | | |
| | | public static String parseGoodsIdByUrl(String url) { |
| | | try { |
| | | if (url.contains(".vip.com/") && (url.contains("detail-") || url.contains("product-"))) { |
| | | String preUrl = url.split("\\?")[0]; |
| | | String goodsId = preUrl.split("-")[preUrl.split("-").length - 1].replace(".html", "").replace(".htm", |
| | | ""); |
| | | if (NumberUtil.isNumeric(goodsId)) |
| | | return goodsId; |
| | | } |
| | | } catch (Exception e) { |
| | | } |
| | | return null; |
| | | } |
| | | } |