会员积分设置,会员下单赠送积分(非积分订单),订单售后扣除积分

This commit is contained in:
lifenlong
2021-05-17 09:04:10 +08:00
parent 9fae7ac565
commit c8a43573fd
5 changed files with 115 additions and 15 deletions

View File

@@ -56,6 +56,24 @@ public final class CurrencyUtil {
return b1.multiply(b2).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
}
/**
* 提供精确的乘法运算。
*
* @param v1 被乘数
* @param v2 乘数
* @param scale 表示表示需要精确到小数点以后几位。
* @return 两个参数的积
*/
public static Double mul(double v1, double v2, int scale) {
if (scale < 0) {
throw new IllegalArgumentException(
"The scale must be a positive integer or zero");
}
BigDecimal b1 = new BigDecimal(Double.toString(v1));
BigDecimal b2 = new BigDecimal(Double.toString(v2));
return b1.multiply(b2).setScale(scale, BigDecimal.ROUND_HALF_UP).doubleValue();
}
/**
* 提供(相对)精确的除法运算,当发生除不尽的情况时, 精确到小数点以后10位以后的数字四舍五入。
*

View File

@@ -201,35 +201,46 @@ public class Order extends BaseEntity {
public Order(CartVO cartVO, TradeDTO tradeDTO) {
String oldId = this.getId();
if (tradeDTO.getMemberAddress() != null) {
BeanUtil.copyProperties(tradeDTO.getMemberAddress(), this);
}
BeanUtil.copyProperties(tradeDTO, this);
BeanUtil.copyProperties(cartVO.getPriceDetailDTO(), this);
BeanUtil.copyProperties(cartVO, this);
this.setId(oldId);
this.setOrderType(OrderTypeEnum.NORMAL.name());
//循环购物车列表判断是否为促销订单
if (cartVO.getSkuList().get(0).getPromotions() != null) {
//判断是否为拼团订单
Optional<String> pintuanId = cartVO.getSkuList().get(0).getPromotions().stream().filter(i -> i.getPromotionType().equals(PromotionTypeEnum.PINTUAN.name())).map(PromotionGoods::getPromotionId).findFirst();
if (pintuanId.isPresent()) {
promotionId = pintuanId.get();
this.setOrderType(OrderTypeEnum.PINTUAN.name());
if (tradeDTO.getParentOrderSn() == null) {
this.setParentOrderSn("");
}
}
//判断是否为积分订单
Optional<String> pointGoodsId = cartVO.getSkuList().get(0).getPromotions().stream().filter(i -> i.getPromotionType().equals(PromotionTypeEnum.POINTS_GOODS.name())).map(PromotionGoods::getPromotionId).findFirst();
if (pointGoodsId.isPresent()) {
this.setOrderType(OrderTypeEnum.POINT.name());
if (tradeDTO.getParentOrderSn() == null) {
this.setParentOrderSn("");
}
}
}else{
this.setOrderType(OrderTypeEnum.NORMAL.name());
}
//设定订单默认状态
this.setOrderStatus(OrderStatusEnum.UNPAID.name());
this.setPayStatus(PayStatusEnum.UNPAID.name());
this.setDeliverStatus(DeliverStatusEnum.UNDELIVERED.name());
//填充订单收件人信息
this.setConsigneeAddressIdPath(tradeDTO.getMemberAddress().getConsigneeAddressIdPath());
this.setConsigneeAddressPath(tradeDTO.getMemberAddress().getConsigneeAddressPath());
this.setConsigneeDetail(tradeDTO.getMemberAddress().getDetail());
this.setConsigneeMobile(tradeDTO.getMemberAddress().getMobile());
this.setConsigneeName(tradeDTO.getMemberAddress().getName());
//判断是否使用平台优惠券
if (tradeDTO.getPlatformCoupon() != null) {
this.setUsePlatformMemberCouponId(tradeDTO.getPlatformCoupon().getMemberCoupon().getId());
}
//判断是否使用店铺优惠券
if (tradeDTO.getStoreCoupons() != null && !tradeDTO.getStoreCoupons().isEmpty()) {
StringBuilder storeCouponIds = new StringBuilder();
for (String s : tradeDTO.getStoreCoupons().keySet()) {

View File

@@ -25,6 +25,10 @@ public enum OrderTypeEnum {
/**
* 拼团订单
*/
PINTUAN
PINTUAN,
/**
* 积分订单
*/
POINT
}

View File

@@ -20,7 +20,7 @@ public class PointSetting implements Serializable {
@ApiModelProperty(value = "注册")
private Integer register;
@ApiModelProperty(value = "1积分等于多少元")
@ApiModelProperty(value = "1元等级*积分")
private Integer money;
@ApiModelProperty(value = "每日签到积分")