代码对价格处理可能存在跨店铺计算问题处理
This commit is contained in:
parent
65f6cf3b54
commit
5eded10d19
@ -11,6 +11,7 @@ import lombok.NoArgsConstructor;
|
|||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -99,4 +100,17 @@ public class CartVO extends CartBase implements Serializable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 过滤购物车中已选择的sku
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public List<CartSkuVO> getCheckedSkuList() {
|
||||||
|
if (skuList != null && !skuList.isEmpty()) {
|
||||||
|
return skuList.stream().filter(CartSkuVO::getChecked).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
return skuList;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -59,10 +59,8 @@ public class CartPriceRender implements CartRenderStep {
|
|||||||
|
|
||||||
cartVOS.forEach(cartVO -> {
|
cartVOS.forEach(cartVO -> {
|
||||||
|
|
||||||
List<PriceDetailDTO> skuPrices = cartVO.getSkuList().stream().filter(CartSkuVO::getChecked)
|
|
||||||
.map(CartSkuVO::getPriceDetailDTO).collect(Collectors.toList());
|
|
||||||
cartVO.getPriceDetailDTO().accumulationPriceDTO(
|
cartVO.getPriceDetailDTO().accumulationPriceDTO(
|
||||||
cartVO.getSkuList().stream().filter(CartSkuVO::getChecked)
|
cartVO.getCheckedSkuList().stream().filter(CartSkuVO::getChecked)
|
||||||
.map(CartSkuVO::getPriceDetailDTO).collect(Collectors.toList())
|
.map(CartSkuVO::getPriceDetailDTO).collect(Collectors.toList())
|
||||||
);
|
);
|
||||||
List<Integer> skuNum = cartVO.getSkuList().stream().filter(CartSkuVO::getChecked)
|
List<Integer> skuNum = cartVO.getSkuList().stream().filter(CartSkuVO::getChecked)
|
||||||
|
@ -36,7 +36,7 @@ public class CheckedFilterRender implements CartRenderStep {
|
|||||||
//循环购物车信息
|
//循环购物车信息
|
||||||
for (CartVO cartVO : tradeDTO.getCartList()) {
|
for (CartVO cartVO : tradeDTO.getCartList()) {
|
||||||
//如果商品选中,则加入到对应购物车
|
//如果商品选中,则加入到对应购物车
|
||||||
cartVO.setSkuList(cartVO.getSkuList().stream().filter(j -> Boolean.TRUE.equals(j.getChecked())).collect(Collectors.toList()));
|
cartVO.setSkuList(cartVO.getCheckedSkuList());
|
||||||
cartVOList.add(cartVO);
|
cartVOList.add(cartVO);
|
||||||
}
|
}
|
||||||
tradeDTO.setCartList(cartVOList);
|
tradeDTO.setCartList(cartVOList);
|
||||||
|
@ -66,7 +66,7 @@ public class CommissionRender implements CartRenderStep {
|
|||||||
//计算购物车价格
|
//计算购物车价格
|
||||||
for (CartVO cart : cartVOS) {
|
for (CartVO cart : cartVOS) {
|
||||||
//累加价格
|
//累加价格
|
||||||
for (CartSkuVO cartSkuVO : cart.getSkuList()) {
|
for (CartSkuVO cartSkuVO : cart.getCheckedSkuList()) {
|
||||||
|
|
||||||
PriceDetailDTO priceDetailDTO = cartSkuVO.getPriceDetailDTO();
|
PriceDetailDTO priceDetailDTO = cartSkuVO.getPriceDetailDTO();
|
||||||
//平台佣金根据分类计算
|
//平台佣金根据分类计算
|
||||||
|
@ -58,14 +58,14 @@ public class DistributionPriceRender implements CartRenderStep {
|
|||||||
//循环订单商品列表,如果是分销商品则计算商品佣金
|
//循环订单商品列表,如果是分销商品则计算商品佣金
|
||||||
tradeDTO.setDistributionId(distributionId);
|
tradeDTO.setDistributionId(distributionId);
|
||||||
|
|
||||||
List<String> skuIds = tradeDTO.getSkuList().stream().map(cartSkuVO -> {
|
List<String> skuIds = tradeDTO.getCheckedSkuList().stream().map(cartSkuVO -> {
|
||||||
return cartSkuVO.getGoodsSku().getId();
|
return cartSkuVO.getGoodsSku().getId();
|
||||||
}).collect(Collectors.toList());
|
}).collect(Collectors.toList());
|
||||||
//是否包含分销商品
|
//是否包含分销商品
|
||||||
List<DistributionGoods> distributionGoods = distributionGoodsService.distributionGoods(skuIds);
|
List<DistributionGoods> distributionGoods = distributionGoodsService.distributionGoods(skuIds);
|
||||||
if (distributionGoods != null && distributionGoods.size() > 0) {
|
if (distributionGoods != null && distributionGoods.size() > 0) {
|
||||||
distributionGoods.forEach(dg -> {
|
distributionGoods.forEach(dg -> {
|
||||||
tradeDTO.getSkuList().forEach(cartSkuVO -> {
|
tradeDTO.getCheckedSkuList().forEach(cartSkuVO -> {
|
||||||
if (cartSkuVO.getGoodsSku().getId().equals(dg.getSkuId())) {
|
if (cartSkuVO.getGoodsSku().getId().equals(dg.getSkuId())) {
|
||||||
cartSkuVO.setDistributionGoods(dg);
|
cartSkuVO.setDistributionGoods(dg);
|
||||||
}
|
}
|
||||||
@ -73,7 +73,7 @@ public class DistributionPriceRender implements CartRenderStep {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
for (CartSkuVO cartSkuVO : tradeDTO.getSkuList()) {
|
for (CartSkuVO cartSkuVO : tradeDTO.getCheckedSkuList()) {
|
||||||
if (cartSkuVO.getDistributionGoods() != null) {
|
if (cartSkuVO.getDistributionGoods() != null) {
|
||||||
cartSkuVO.getPriceDetailDTO().setDistributionCommission(CurrencyUtil.mul(cartSkuVO.getNum(), cartSkuVO.getDistributionGoods().getCommission()));
|
cartSkuVO.getPriceDetailDTO().setDistributionCommission(CurrencyUtil.mul(cartSkuVO.getNum(), cartSkuVO.getDistributionGoods().getCommission()));
|
||||||
}
|
}
|
||||||
|
@ -46,8 +46,6 @@ public class FullDiscountRender implements CartRenderStep {
|
|||||||
@Override
|
@Override
|
||||||
public void render(TradeDTO tradeDTO) {
|
public void render(TradeDTO tradeDTO) {
|
||||||
|
|
||||||
//获取购物车中所有的商品
|
|
||||||
List<CartSkuVO> cartSkuList = tradeDTO.getSkuList();
|
|
||||||
|
|
||||||
//店铺集合
|
//店铺集合
|
||||||
List<CartVO> cartList = tradeDTO.getCartList();
|
List<CartVO> cartList = tradeDTO.getCartList();
|
||||||
@ -80,7 +78,7 @@ public class FullDiscountRender implements CartRenderStep {
|
|||||||
cart.setFullDiscount(fullDiscount);
|
cart.setFullDiscount(fullDiscount);
|
||||||
Map<String, Double> skuPriceDetail;
|
Map<String, Double> skuPriceDetail;
|
||||||
//参与活动的sku判定
|
//参与活动的sku判定
|
||||||
skuPriceDetail = initFullDiscountGoods(fullDiscount, cartSkuList);
|
skuPriceDetail = initFullDiscountGoods(fullDiscount, cart.getCheckedSkuList());
|
||||||
//记录参与满减活动的sku
|
//记录参与满减活动的sku
|
||||||
cart.setFullDiscountSkuIds(new ArrayList<>(skuPriceDetail.keySet()));
|
cart.setFullDiscountSkuIds(new ArrayList<>(skuPriceDetail.keySet()));
|
||||||
|
|
||||||
@ -115,7 +113,7 @@ public class FullDiscountRender implements CartRenderStep {
|
|||||||
*/
|
*/
|
||||||
private void renderFullRate(CartVO cart, Map<String, Double> skuPriceDetail, Double rate) {
|
private void renderFullRate(CartVO cart, Map<String, Double> skuPriceDetail, Double rate) {
|
||||||
|
|
||||||
List<CartSkuVO> cartSkuVOS = cart.getSkuList().stream().filter(cartSkuVO -> {
|
List<CartSkuVO> cartSkuVOS = cart.getCheckedSkuList().stream().filter(cartSkuVO -> {
|
||||||
return skuPriceDetail.containsKey(cartSkuVO.getGoodsSku().getId());
|
return skuPriceDetail.containsKey(cartSkuVO.getGoodsSku().getId());
|
||||||
}).collect(Collectors.toList());
|
}).collect(Collectors.toList());
|
||||||
|
|
||||||
@ -186,7 +184,7 @@ public class FullDiscountRender implements CartRenderStep {
|
|||||||
}
|
}
|
||||||
//如果满足,判定是否免邮,免邮的话需要渲染一边sku
|
//如果满足,判定是否免邮,免邮的话需要渲染一边sku
|
||||||
if (fullDiscount.getIsFreeFreight()) {
|
if (fullDiscount.getIsFreeFreight()) {
|
||||||
for (CartSkuVO skuVO : cartVO.getSkuList()) {
|
for (CartSkuVO skuVO : cartVO.getCheckedSkuList()) {
|
||||||
skuVO.setIsFreeFreight(true);
|
skuVO.setIsFreeFreight(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ public class SkuFreightRender implements CartRenderStep {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(TradeDTO tradeDTO) {
|
public void render(TradeDTO tradeDTO) {
|
||||||
List<CartSkuVO> cartSkuVOS = tradeDTO.getSkuList();
|
List<CartSkuVO> cartSkuVOS = tradeDTO.getCheckedSkuList();
|
||||||
//会员收货地址问题处理
|
//会员收货地址问题处理
|
||||||
MemberAddress memberAddress = tradeDTO.getMemberAddress();
|
MemberAddress memberAddress = tradeDTO.getMemberAddress();
|
||||||
//如果收货地址为空,则抛出异常
|
//如果收货地址为空,则抛出异常
|
||||||
|
@ -59,7 +59,7 @@ public class SkuPromotionRender implements CartRenderStep {
|
|||||||
*/
|
*/
|
||||||
private void renderBasePrice(TradeDTO tradeDTO) {
|
private void renderBasePrice(TradeDTO tradeDTO) {
|
||||||
tradeDTO.getCartList().forEach(
|
tradeDTO.getCartList().forEach(
|
||||||
cartVO -> cartVO.getSkuList().forEach(cartSkuVO -> {
|
cartVO -> cartVO.getCheckedSkuList().forEach(cartSkuVO -> {
|
||||||
PriceDetailDTO priceDetailDTO = cartSkuVO.getPriceDetailDTO();
|
PriceDetailDTO priceDetailDTO = cartSkuVO.getPriceDetailDTO();
|
||||||
priceDetailDTO.setGoodsPrice(cartSkuVO.getSubTotal());
|
priceDetailDTO.setGoodsPrice(cartSkuVO.getSubTotal());
|
||||||
priceDetailDTO.setDiscountPrice(CurrencyUtil.sub(priceDetailDTO.getOriginalPrice(), cartSkuVO.getSubTotal()));
|
priceDetailDTO.setDiscountPrice(CurrencyUtil.sub(priceDetailDTO.getOriginalPrice(), cartSkuVO.getSubTotal()));
|
||||||
@ -82,7 +82,7 @@ public class SkuPromotionRender implements CartRenderStep {
|
|||||||
case POINTS:
|
case POINTS:
|
||||||
//处理积分商品购买
|
//处理积分商品购买
|
||||||
for (CartVO cartVO : tradeDTO.getCartList()) {
|
for (CartVO cartVO : tradeDTO.getCartList()) {
|
||||||
for (CartSkuVO cartSkuVO : cartVO.getSkuList()) {
|
for (CartSkuVO cartSkuVO : cartVO.getCheckedSkuList()) {
|
||||||
cartSkuVO.getPriceDetailDTO().setPayPoint(cartSkuVO.getPoint());
|
cartSkuVO.getPriceDetailDTO().setPayPoint(cartSkuVO.getPoint());
|
||||||
PromotionSkuVO promotionSkuVO = new PromotionSkuVO(PromotionTypeEnum.POINTS_GOODS.name(), cartSkuVO.getPointsId());
|
PromotionSkuVO promotionSkuVO = new PromotionSkuVO(PromotionTypeEnum.POINTS_GOODS.name(), cartSkuVO.getPointsId());
|
||||||
cartSkuVO.getPriceDetailDTO().getJoinPromotion().add(promotionSkuVO);
|
cartSkuVO.getPriceDetailDTO().getJoinPromotion().add(promotionSkuVO);
|
||||||
@ -91,7 +91,7 @@ public class SkuPromotionRender implements CartRenderStep {
|
|||||||
return;
|
return;
|
||||||
case KANJIA:
|
case KANJIA:
|
||||||
for (CartVO cartVO : tradeDTO.getCartList()) {
|
for (CartVO cartVO : tradeDTO.getCartList()) {
|
||||||
for (CartSkuVO cartSkuVO : cartVO.getSkuList()) {
|
for (CartSkuVO cartSkuVO : cartVO.getCheckedSkuList()) {
|
||||||
KanjiaActivitySearchParams kanjiaActivitySearchParams = new KanjiaActivitySearchParams();
|
KanjiaActivitySearchParams kanjiaActivitySearchParams = new KanjiaActivitySearchParams();
|
||||||
kanjiaActivitySearchParams.setGoodsSkuId(cartSkuVO.getGoodsSku().getId());
|
kanjiaActivitySearchParams.setGoodsSkuId(cartSkuVO.getGoodsSku().getId());
|
||||||
kanjiaActivitySearchParams.setMemberId(UserContext.getCurrentUser().getId());
|
kanjiaActivitySearchParams.setMemberId(UserContext.getCurrentUser().getId());
|
||||||
@ -112,7 +112,7 @@ public class SkuPromotionRender implements CartRenderStep {
|
|||||||
return;
|
return;
|
||||||
case PINTUAN:
|
case PINTUAN:
|
||||||
for (CartVO cartVO : tradeDTO.getCartList()) {
|
for (CartVO cartVO : tradeDTO.getCartList()) {
|
||||||
for (CartSkuVO cartSkuVO : cartVO.getSkuList()) {
|
for (CartSkuVO cartSkuVO : cartVO.getCheckedSkuList()) {
|
||||||
PromotionSkuVO promotionSkuVO = new PromotionSkuVO(PromotionTypeEnum.PINTUAN.name(), cartSkuVO.getPintuanId());
|
PromotionSkuVO promotionSkuVO = new PromotionSkuVO(PromotionTypeEnum.PINTUAN.name(), cartSkuVO.getPintuanId());
|
||||||
cartSkuVO.getPriceDetailDTO().getJoinPromotion().add(promotionSkuVO);
|
cartSkuVO.getPriceDetailDTO().getJoinPromotion().add(promotionSkuVO);
|
||||||
}
|
}
|
||||||
@ -125,7 +125,7 @@ public class SkuPromotionRender implements CartRenderStep {
|
|||||||
//循环购物车
|
//循环购物车
|
||||||
for (CartVO cartVO : tradeDTO.getCartList()) {
|
for (CartVO cartVO : tradeDTO.getCartList()) {
|
||||||
//循环sku
|
//循环sku
|
||||||
for (CartSkuVO cartSkuVO : cartVO.getSkuList()) {
|
for (CartSkuVO cartSkuVO : cartVO.getCheckedSkuList()) {
|
||||||
//更新商品促销
|
//更新商品促销
|
||||||
promotionGoodsService.updatePromotion(cartSkuVO);
|
promotionGoodsService.updatePromotion(cartSkuVO);
|
||||||
//赋予商品促销信息
|
//赋予商品促销信息
|
||||||
|
@ -264,7 +264,7 @@ public class Order extends BaseEntity {
|
|||||||
this.setOrderType(OrderTypeEnum.VIRTUAL.name());
|
this.setOrderType(OrderTypeEnum.VIRTUAL.name());
|
||||||
} else {
|
} else {
|
||||||
//促销订单(拼团、积分)-判断购买的是虚拟商品还是实物商品
|
//促销订单(拼团、积分)-判断购买的是虚拟商品还是实物商品
|
||||||
String goodsType = cartVO.getSkuList().get(0).getGoodsSku().getGoodsType();
|
String goodsType = cartVO.getCheckedSkuList().get(0).getGoodsSku().getGoodsType();
|
||||||
if (StrUtil.isEmpty(goodsType) || goodsType.equals(GoodsTypeEnum.PHYSICAL_GOODS.name())) {
|
if (StrUtil.isEmpty(goodsType) || goodsType.equals(GoodsTypeEnum.PHYSICAL_GOODS.name())) {
|
||||||
this.setOrderType(OrderTypeEnum.NORMAL.name());
|
this.setOrderType(OrderTypeEnum.NORMAL.name());
|
||||||
} else {
|
} else {
|
||||||
@ -275,7 +275,7 @@ public class Order extends BaseEntity {
|
|||||||
|
|
||||||
//判断是否为拼团订单,如果为拼团订单获取拼团ID,判断是否为主订单
|
//判断是否为拼团订单,如果为拼团订单获取拼团ID,判断是否为主订单
|
||||||
if (tradeDTO.getCartTypeEnum().name().equals(PromotionTypeEnum.PINTUAN.name())) {
|
if (tradeDTO.getCartTypeEnum().name().equals(PromotionTypeEnum.PINTUAN.name())) {
|
||||||
Optional<String> pintuanId = cartVO.getSkuList().get(0).getPromotions().stream()
|
Optional<String> pintuanId = cartVO.getCheckedSkuList().get(0).getPromotions().stream()
|
||||||
.filter(i -> i.getPromotionType().equals(PromotionTypeEnum.PINTUAN.name())).map(PromotionGoods::getPromotionId).findFirst();
|
.filter(i -> i.getPromotionType().equals(PromotionTypeEnum.PINTUAN.name())).map(PromotionGoods::getPromotionId).findFirst();
|
||||||
promotionId = pintuanId.get();
|
promotionId = pintuanId.get();
|
||||||
}
|
}
|
||||||
|
@ -168,7 +168,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|||||||
String message = "订单[" + item.getSn() + "]创建";
|
String message = "订单[" + item.getSn() + "]创建";
|
||||||
//记录日志
|
//记录日志
|
||||||
orderLogs.add(new OrderLog(item.getSn(), UserContext.getCurrentUser().getId(), UserContext.getCurrentUser().getRole().getRole(), UserContext.getCurrentUser().getUsername(), message));
|
orderLogs.add(new OrderLog(item.getSn(), UserContext.getCurrentUser().getId(), UserContext.getCurrentUser().getRole().getRole(), UserContext.getCurrentUser().getUsername(), message));
|
||||||
item.getSkuList().forEach(
|
item.getCheckedSkuList().forEach(
|
||||||
sku -> orderItems.add(new OrderItem(sku, item, tradeDTO))
|
sku -> orderItems.add(new OrderItem(sku, item, tradeDTO))
|
||||||
);
|
);
|
||||||
//写入子订单信息
|
//写入子订单信息
|
||||||
|
Loading…
x
Reference in New Issue
Block a user