Commit 8331e3f2 by 缪晖

重新计算购物车行优惠信息

parent 31690b06
...@@ -95,27 +95,27 @@ public class CollageOrderServiceImpl implements CollageOrderService { ...@@ -95,27 +95,27 @@ public class CollageOrderServiceImpl implements CollageOrderService {
BaseResponse orderCreateResponse = this.orderService.createOrderNew(createOrderVo); BaseResponse orderCreateResponse = this.orderService.createOrderNew(createOrderVo);
if (null != orderCreateResponse && null != orderCreateResponse.getResult()) { // if (null != orderCreateResponse && null != orderCreateResponse.getResult()) {
Object result = orderCreateResponse.getResult(); // Object result = orderCreateResponse.getResult();
//
String oid = null; // String oid = null;
//
if (result instanceof CreateOrderOperateDto) { // if (result instanceof CreateOrderOperateDto) {
oid = ((CreateOrderOperateDto) result).getFatherOrderBean().getOid(); // oid = ((CreateOrderOperateDto) result).getFatherOrderBean().getOid();
} else if (result instanceof CreateOrderResponseVo) { // } else if (result instanceof CreateOrderResponseVo) {
oid = ((CreateOrderResponseVo) result).getOid(); // oid = ((CreateOrderResponseVo) result).getOid();
} // }
//
// 清空拼单购物车 // // 清空拼单购物车
collageOrderDto = new CollageOrderDto(); // collageOrderDto = new CollageOrderDto();
collageOrderDto.setSessionId(StringUtils.isBlank(createOrderVo.getSessionId()) ? oid : createOrderVo.getSessionId()); // collageOrderDto.setSessionId(StringUtils.isBlank(createOrderVo.getSessionId()) ? oid : createOrderVo.getSessionId());
collageOrderDto.setPartnerId(createOrderVo.getPartnerId()); // collageOrderDto.setPartnerId(createOrderVo.getPartnerId());
collageOrderDto.setShopId(createOrderVo.getShopId()); // collageOrderDto.setShopId(createOrderVo.getShopId());
collageOrderDto.setCreateCollageUserId(createOrderVo.getUserId()); // collageOrderDto.setCreateCollageUserId(createOrderVo.getUserId());
collageOrderDto.setOrderCode(oid); // collageOrderDto.setOrderCode(oid);
collageOrderDto.setStatus(3);//支付中 // collageOrderDto.setStatus(3);//支付中
shoppingCartClient.updateCollageOrder(collageOrderDto); // shoppingCartClient.updateCollageOrder(collageOrderDto);
} // }
return orderCreateResponse; return orderCreateResponse;
} }
......
...@@ -7,6 +7,7 @@ import cn.freemud.base.entity.BaseResponse; ...@@ -7,6 +7,7 @@ import cn.freemud.base.entity.BaseResponse;
import cn.freemud.constant.ResponseCodeConstant; import cn.freemud.constant.ResponseCodeConstant;
import cn.freemud.constant.ShoppingCartConstant; import cn.freemud.constant.ShoppingCartConstant;
import cn.freemud.entities.dto.*; import cn.freemud.entities.dto.*;
import cn.freemud.entities.dto.activity.ActivityDiscountsDto;
import cn.freemud.entities.dto.activity.ActivityQueryDto; import cn.freemud.entities.dto.activity.ActivityQueryDto;
import cn.freemud.entities.dto.shoppingCart.ShoppingCartGoodsDto; import cn.freemud.entities.dto.shoppingCart.ShoppingCartGoodsDto;
import cn.freemud.entities.vo.*; import cn.freemud.entities.vo.*;
...@@ -706,6 +707,9 @@ public class ShoppingCartCollageServiceImpl extends AbstractShoppingCartImpl imp ...@@ -706,6 +707,9 @@ public class ShoppingCartCollageServiceImpl extends AbstractShoppingCartImpl imp
// 购物车购买人包装费计算 // 购物车购买人包装费计算
updatePackPrice(shoppingCartGoodsResponseVo, shoppingCartGoodsDto); updatePackPrice(shoppingCartGoodsResponseVo, shoppingCartGoodsDto);
// 重新计算购物车行折扣总金额
updateTotalDiscountAmount(shoppingCartGoodsDto);
return ResponseUtil.success(shoppingCartGoodsDto); return ResponseUtil.success(shoppingCartGoodsDto);
} }
...@@ -726,6 +730,20 @@ public class ShoppingCartCollageServiceImpl extends AbstractShoppingCartImpl imp ...@@ -726,6 +730,20 @@ public class ShoppingCartCollageServiceImpl extends AbstractShoppingCartImpl imp
} }
} }
/**
* 重新计算拼单购物车行总折扣金额
*/
private void updateTotalDiscountAmount(ShoppingCartGoodsDto shoppingCartGoodsDto) {
if (null != shoppingCartGoodsDto && null != shoppingCartGoodsDto.getProducts()) {
shoppingCartGoodsDto.getProducts().stream().forEach(product -> {
List<ActivityDiscountsDto> activityDiscountsDtos = product.getActivityDiscountsDtos();
if (null != activityDiscountsDtos && !activityDiscountsDtos.isEmpty()) {
product.setTotalDiscountAmount(activityDiscountsDtos.stream().mapToInt(ActivityDiscountsDto::getDiscountAmount).sum());
}
});
}
}
@Override @Override
public ActivityCalculationDiscountResponseDto.CalculationDiscountResult getActivityCalculationDiscountResponse(String partnerId, String storeId, String userId, String appId, Integer orderType, boolean isMember, List<CartGoods> cartGoodsList, List<ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon> coupons, List<ShoppingCartInfoRequestVo.SendGoods> sendGoodsList, String menuType, Long distributionFee) { public ActivityCalculationDiscountResponseDto.CalculationDiscountResult getActivityCalculationDiscountResponse(String partnerId, String storeId, String userId, String appId, Integer orderType, boolean isMember, List<CartGoods> cartGoodsList, List<ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon> coupons, List<ShoppingCartInfoRequestVo.SendGoods> sendGoodsList, String menuType, Long distributionFee) {
ActivityCalculationDiscountRequestDto activityCalculationDiscountRequestDto = getActivityCalculationDiscountRequestDto(partnerId, storeId, userId, appId, orderType); ActivityCalculationDiscountRequestDto activityCalculationDiscountRequestDto = getActivityCalculationDiscountRequestDto(partnerId, storeId, userId, appId, orderType);
...@@ -1265,49 +1283,21 @@ public class ShoppingCartCollageServiceImpl extends AbstractShoppingCartImpl imp ...@@ -1265,49 +1283,21 @@ public class ShoppingCartCollageServiceImpl extends AbstractShoppingCartImpl imp
if (response.getData() == null || response.getData().getData() == null || response.getData().getData().getCardSimpleInfos().size() > 1) { if (response.getData() == null || response.getData().getData() == null || response.getData().getData().getCardSimpleInfos().size() > 1) {
throw new ServiceException(ResponseResult.USER_SVC_CARD_ERROR); throw new ServiceException(ResponseResult.USER_SVC_CARD_ERROR);
} }
boolean check = this.checkSvcComPay(partnerId, storeId); //获取实际配送费
if (check) { if (StringUtils.isNotBlank(receiveId) && shoppingCartGoodsResponseVo.getDiscountDeliveryAmount() != null) {
//混合支付无需校验svc卡余额,但是配送和包装费不计算在svc卡支付 // Integer deliveryAmount = getDeliveryAmount(receiveId, partnerId, storeId);
Integer amount1 = response.getData().getData().getCardSimpleInfos().get(0).getAmount(); Integer deliveryAmount = shoppingCartGoodsResponseVo.getDiscountDeliveryAmount().intValue();
Integer vamount = response.getData().getData().getCardSimpleInfos().get(0).getVamount(); orderAmount += deliveryAmount;
Integer svcTotalAmount = amount1+vamount; }
//获取实际配送费 Integer amount1 = response.getData().getData().getCardSimpleInfos().get(0).getAmount();
Integer deliveryAmount = 0; Integer vamount = response.getData().getData().getCardSimpleInfos().get(0).getVamount();
Integer svcPayAmount = 0; if (orderAmount > amount1 + vamount) {
if (StringUtils.isNotBlank(receiveId) && shoppingCartGoodsResponseVo.getDiscountDeliveryAmount() != null) { throw new ServiceException(ResponseResult.USER_SVC_CARD_AMOUNT_DEFICIENCY);
//Integer deliveryAmount = getDeliveryAmount(receiveId, partnerId, storeId); }
deliveryAmount = shoppingCartGoodsResponseVo.getDiscountDeliveryAmount().intValue(); BigDecimal bigDecimal = new BigDecimal(orderAmount);
orderAmount += deliveryAmount; String amountStr = bigDecimal.divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP).toString();
} shoppingCartGoodsResponseVo.setTotalAmount(0L);
if (svcTotalAmount>0 && svcTotalAmount>orderAmount) { shoppingCartGoodsResponseVo.setSvcDiscountDesc("储值卡支付¥" + amountStr);
svcPayAmount = orderAmount;
shoppingCartGoodsResponseVo.setTotalAmount(0L);
}
else if (svcTotalAmount>0 && svcTotalAmount<=orderAmount) {
svcPayAmount = svcTotalAmount;
shoppingCartGoodsResponseVo.setTotalAmount((orderAmount.longValue()-svcPayAmount.longValue()));
}
BigDecimal bigDecimal = new BigDecimal(svcPayAmount);
String amountStr = bigDecimal.divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP).toString();
shoppingCartGoodsResponseVo.setSvcPayAmount(amountStr);
shoppingCartGoodsResponseVo.setSvcDiscountDesc("储值卡支付¥" + amountStr);
}
else {
//获取实际配送费
if (StringUtils.isNotBlank(receiveId) && shoppingCartGoodsResponseVo.getDiscountDeliveryAmount() != null) {
Integer deliveryAmount = shoppingCartGoodsResponseVo.getDiscountDeliveryAmount().intValue();
orderAmount += deliveryAmount;
}
Integer amount1 = response.getData().getData().getCardSimpleInfos().get(0).getAmount();
Integer vamount = response.getData().getData().getCardSimpleInfos().get(0).getVamount();
if (orderAmount > amount1 + vamount) {
throw new ServiceException(ResponseResult.USER_SVC_CARD_AMOUNT_DEFICIENCY);
}
BigDecimal bigDecimal = new BigDecimal(orderAmount);
String amountStr = bigDecimal.divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP).toString();
shoppingCartGoodsResponseVo.setTotalAmount(0L);
shoppingCartGoodsResponseVo.setSvcDiscountDesc("储值卡支付¥" + amountStr);
}
} }
/** /**
......
...@@ -116,7 +116,7 @@ public class TimeSalePromotionService implements IPromotionService { ...@@ -116,7 +116,7 @@ public class TimeSalePromotionService implements IPromotionService {
} }
Integer actualGoodsNumber = numberMap.get(cartGoods.getSkuId()); Integer actualGoodsNumber = numberMap.get(cartGoods.getSkuId());
if (actualGoodsNumber > 0) { if (actualGoodsNumber > 0) {
Long totalDiscountAmount = cartGoods.getQty() > actualGoodsNumber ? goods.getDiscountAmount() * actualGoodsNumber / goods.getActualGoodsNumber() : goods.getDiscountAmount() * cartGoods.getQty() / goods.getActualGoodsNumber(); Long totalDiscountAmount = cartGoods.getQty() > actualGoodsNumber ? goodsDiscount.getDiscount() * actualGoodsNumber / goodsDiscount.getActualGoodsNumber() : goodsDiscount.getDiscount() * cartGoods.getQty() / goodsDiscount.getActualGoodsNumber();
ActivityDiscountsDto activityDiscountsDto = new ActivityDiscountsDto(); ActivityDiscountsDto activityDiscountsDto = new ActivityDiscountsDto();
activityDiscountsDto.setActivityCode(goodsDiscount.getActivityCode()); activityDiscountsDto.setActivityCode(goodsDiscount.getActivityCode());
activityDiscountsDto.setActivityName(goodsDiscount.getActivityName()); activityDiscountsDto.setActivityName(goodsDiscount.getActivityName());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment