处理积分

This commit is contained in:
朱耘稷
2020-12-21 21:20:26 +08:00
committed by xuwenbo
parent a467f4d32f
commit 84d33c1c0c
3 changed files with 41 additions and 6 deletions

View File

@ -29,4 +29,6 @@ public class PriceGroupDto {
@JsonSerialize(using = BigDecimalSerializer.class) @JsonSerialize(using = BigDecimalSerializer.class)
private BigDecimal vipPrice; private BigDecimal vipPrice;
@JsonSerialize(using = BigDecimalSerializer.class)
private BigDecimal payIntegral;
} }

View File

@ -408,6 +408,7 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<StoreOrderMapper, Y
.couponPrice(couponPrice) .couponPrice(couponPrice)
.deductionPrice(deductionPrice) .deductionPrice(deductionPrice)
.usedIntegral(usedIntegral) .usedIntegral(usedIntegral)
.payIntegral(cacheDTO.getPriceGroup().getPayIntegral())
.build(); .build();
} }
@ -459,6 +460,9 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<StoreOrderMapper, Y
Long seckillId = 0L; Long seckillId = 0L;
Long bargainId = 0L; Long bargainId = 0L;
Boolean isIntegral=false;
BigDecimal integral=BigDecimal.ZERO;
CacheDto cacheDTO = this.getCacheOrderInfo(uid,key); CacheDto cacheDTO = this.getCacheOrderInfo(uid,key);
List<YxStoreCartQueryVo> cartInfo = cacheDTO.getCartInfo(); List<YxStoreCartQueryVo> cartInfo = cacheDTO.getCartInfo();
@ -474,12 +478,19 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<StoreOrderMapper, Y
cartIds.add(cart.getId().toString()); cartIds.add(cart.getId().toString());
totalNum += cart.getCartNum(); totalNum += cart.getCartNum();
if(cart.getProductInfo().getIsIntegral()==1){
integral = NumberUtil.add(integral,
NumberUtil.mul(cart.getCartNum(),cart.getProductInfo().getAttrInfo().getIntegral()));
}
} }
//计算奖励积分 //计算奖励积分
BigDecimal gainIntegral = this.getGainIntegral(cartInfo); BigDecimal gainIntegral = this.getGainIntegral(cartInfo);
if(PayTypeEnum.INTEGRAL.getValue().equals(param.getPayType())){
gainIntegral=BigDecimal.ZERO;
isIntegral=true;
}
//生成分布式唯一值 //生成分布式唯一值
String orderSn = IdUtil.getSnowflake(0,0).nextIdStr(); String orderSn = IdUtil.getSnowflake(0,0).nextIdStr();
//组合数据 //组合数据
@ -501,6 +512,9 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<StoreOrderMapper, Y
storeOrder.setDeductionPrice(computeVo.getDeductionPrice()); storeOrder.setDeductionPrice(computeVo.getDeductionPrice());
storeOrder.setPaid(OrderInfoEnum.PAY_STATUS_0.getValue()); storeOrder.setPaid(OrderInfoEnum.PAY_STATUS_0.getValue());
storeOrder.setPayType(param.getPayType()); storeOrder.setPayType(param.getPayType());
if(isIntegral){
storeOrder.setPayIntegral(integral);
}
storeOrder.setUseIntegral(BigDecimal.valueOf(computeVo.getUsedIntegral())); storeOrder.setUseIntegral(BigDecimal.valueOf(computeVo.getUsedIntegral()));
storeOrder.setBackIntegral(BigDecimal.ZERO); storeOrder.setBackIntegral(BigDecimal.ZERO);
storeOrder.setGainIntegral(gainIntegral); storeOrder.setGainIntegral(gainIntegral);
@ -695,6 +709,13 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<StoreOrderMapper, Y
NumberUtil.add(price,userQueryVo.getNowMoney()).doubleValue(), NumberUtil.add(price,userQueryVo.getNowMoney()).doubleValue(),
"订单退款到余额"+price+"",orderQueryVo.getId().toString()); "订单退款到余额"+price+"",orderQueryVo.getId().toString());
this.retrunStock(orderQueryVo.getOrderId()); this.retrunStock(orderQueryVo.getOrderId());
}else if(PayTypeEnum.INTEGRAL.getValue().equals(orderQueryVo.getPayType())){
storeOrder.setRefundStatus(OrderInfoEnum.REFUND_STATUS_2.getValue());
storeOrder.setRefundPrice(price);
yxStoreOrderMapper.updateById(storeOrder);
orderStatusService.create(orderQueryVo.getId(),"order_edit","退款给用户:"+orderQueryVo.getPayIntegral() +"");
this.retrunStock(orderQueryVo.getOrderId());
} }
orderStatusService.create(orderQueryVo.getId(),OrderLogEnum.REFUND_ORDER_SUCCESS.getValue(),"退款给用户:"+price +""); orderStatusService.create(orderQueryVo.getId(),OrderLogEnum.REFUND_ORDER_SUCCESS.getValue(),"退款给用户:"+price +"");
@ -1445,7 +1466,7 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<StoreOrderMapper, Y
}else if(PayTypeEnum.YUE.getValue().equals(order.getPayType())){ }else if(PayTypeEnum.YUE.getValue().equals(order.getPayType())){
statusDTO.set_payType("余额支付"); statusDTO.set_payType("余额支付");
}else{ }else{
statusDTO.set_payType("积分兑换"); statusDTO.set_payType("积分支付");
} }
order.set_status(statusDTO); order.set_status(statusDTO);
@ -1774,7 +1795,9 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<StoreOrderMapper, Y
|| OrderStatusEnum.STATUS_MINUS_2.getValue().equals(order.getStatus())){ || OrderStatusEnum.STATUS_MINUS_2.getValue().equals(order.getStatus())){
return; return;
} }
if(order.getPayIntegral().compareTo(BigDecimal.ZERO)>0){
order.setUseIntegral(order.getPayIntegral());
}
if(order.getUseIntegral().compareTo(BigDecimal.ZERO) <= 0) { if(order.getUseIntegral().compareTo(BigDecimal.ZERO) <= 0) {
return; return;
} }
@ -1870,13 +1893,15 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<StoreOrderMapper, Y
BigDecimal totalPrice = this.getOrderSumPrice(cartInfo, "truePrice");//获取订单总金额 BigDecimal totalPrice = this.getOrderSumPrice(cartInfo, "truePrice");//获取订单总金额
BigDecimal costPrice = this.getOrderSumPrice(cartInfo, "costPrice");//获取订单成本价 BigDecimal costPrice = this.getOrderSumPrice(cartInfo, "costPrice");//获取订单成本价
BigDecimal vipPrice = this.getOrderSumPrice(cartInfo, "vipTruePrice");//获取订单会员优惠金额 BigDecimal vipPrice = this.getOrderSumPrice(cartInfo, "vipTruePrice");//获取订单会员优惠金额
BigDecimal payIntegral = this.getOrderSumPrice(cartInfo, "payIntegral");//获取订单需要的积分
//如果设置满包邮0 表示全局包邮如果设置大于0表示满这价格包邮否则走运费模板算法 //如果设置满包邮0 表示全局包邮如果设置大于0表示满这价格包邮否则走运费模板算法
if(storeFreePostage.compareTo(BigDecimal.ZERO) != 0 && totalPrice.compareTo(storeFreePostage) <= 0){ if(storeFreePostage.compareTo(BigDecimal.ZERO) != 0 && totalPrice.compareTo(storeFreePostage) <= 0){
storePostage = this.handlePostage(cartInfo,userAddress); storePostage = this.handlePostage(cartInfo,userAddress);
} }
if(cartInfo.size()==1&&cartInfo.get(0).getProductInfo().getIsIntegral()==1){
totalPrice=BigDecimal.ZERO;
}
PriceGroupDto priceGroupDTO = new PriceGroupDto(); PriceGroupDto priceGroupDTO = new PriceGroupDto();
priceGroupDTO.setStorePostage(storePostage); priceGroupDTO.setStorePostage(storePostage);
@ -1884,7 +1909,7 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<StoreOrderMapper, Y
priceGroupDTO.setTotalPrice(totalPrice); priceGroupDTO.setTotalPrice(totalPrice);
priceGroupDTO.setCostPrice(costPrice); priceGroupDTO.setCostPrice(costPrice);
priceGroupDTO.setVipPrice(vipPrice); priceGroupDTO.setVipPrice(vipPrice);
priceGroupDTO.setPayIntegral(payIntegral);
return priceGroupDTO; return priceGroupDTO;
} }
@ -2077,6 +2102,11 @@ public class YxStoreOrderServiceImpl extends BaseServiceImpl<StoreOrderMapper, Y
sumPrice = NumberUtil.add(sumPrice, sumPrice = NumberUtil.add(sumPrice,
NumberUtil.mul(storeCart.getCartNum(),storeCart.getVipTruePrice())); NumberUtil.mul(storeCart.getCartNum(),storeCart.getVipTruePrice()));
} }
}else if("payIntegral".equals(key)){
for (YxStoreCartQueryVo storeCart : cartInfo) {
sumPrice = NumberUtil.add(sumPrice,
NumberUtil.mul(storeCart.getCartNum(), storeCart.getProductInfo().getAttrInfo().getIntegral()));
}
} }
return sumPrice; return sumPrice;

View File

@ -37,4 +37,7 @@ public class ComputeVo implements Serializable {
private BigDecimal totalPrice; private BigDecimal totalPrice;
private Double usedIntegral; //使用了多少积分 private Double usedIntegral; //使用了多少积分
@JsonSerialize(using = BigDecimalSerializer.class)
private BigDecimal payIntegral;
} }