Commit 48162bcf by 周晓航

新增夜间配送参数nightDistributionFee,调用促销算价处理

Signed-off-by: 周晓航 <xiaohang.zhou@freemud.com>
parent b13bbc6d
......@@ -336,15 +336,15 @@ public abstract class AbstractShoppingCartImpl implements ShoppingCartNewService
public CalculationDiscountResult getCalculationDiscountResult(String menuType
, String partnerId, String storeId, String userId, String appId, String wxappid, Integer orderType, boolean isMember
, List<CartGoods> cartGoodsList, List<ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon> coupons
, List<ShoppingCartInfoRequestVo.SendGoods> sendGoodsList, String receiveId, Long deliveryAmount){
, List<ShoppingCartInfoRequestVo.SendGoods> sendGoodsList, String receiveId, Long deliveryAmount, long nightDistributionFee){
// 获取优惠信息
CalculationDiscountResult calculationDiscountResult=null;
//外卖场景下 查询门店配送信息
if(BusinessTypeEnum.SAAS_DELIVERY.getCode().equals(menuType)){
calculationDiscountResult = this.getActivityCalculationDiscountResponse(partnerId, storeId, userId, appId, orderType,isMember, cartGoodsList, coupons, sendGoodsList,BusinessTypeEnum.getByType(menuType).getCode(),deliveryAmount,null, null);
calculationDiscountResult = this.getActivityCalculationDiscountResponse(partnerId, storeId, userId, appId, orderType,isMember, cartGoodsList, coupons, sendGoodsList,BusinessTypeEnum.getByType(menuType).getCode(),deliveryAmount,null, null, nightDistributionFee);
}else{
calculationDiscountResult = this.getActivityCalculationDiscountResponse(partnerId, storeId, userId, appId, orderType,isMember, cartGoodsList, coupons, sendGoodsList,BusinessTypeEnum.getByType(menuType).getCode(),null,null, null);
calculationDiscountResult = this.getActivityCalculationDiscountResponse(partnerId, storeId, userId, appId, orderType,isMember, cartGoodsList, coupons, sendGoodsList,BusinessTypeEnum.getByType(menuType).getCode(),null,null, null,0L);
}
return calculationDiscountResult;
......@@ -359,7 +359,7 @@ public abstract class AbstractShoppingCartImpl implements ShoppingCartNewService
* @param shoppingCartGoodsResponseVo
*/
public void updateShoppingCartGoodsDiscount(CouponPromotionVO couponPromotionVO, ActivityQueryDto activityQueryDto, CalculationDiscountResult calculationDiscountResult, List<CartGoods> cartGoodsList
, ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo, ShoppingCartInfoRequestVo shoppingCartInfoRequestVo, UserLoginInfoDto userLoginInfoDto,String menuType,Long deliveryAmount) {
, ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo, ShoppingCartInfoRequestVo shoppingCartInfoRequestVo, UserLoginInfoDto userLoginInfoDto,String menuType,Long deliveryAmount,long nightDistributionFee) {
//默认计算优惠
DefaultPromotionService defaultPromotionService = (DefaultPromotionService) PromotionFactory.getPromotionService(ShoppingCartPromotionEnum.DEFAULT_PROMOTION);
defaultPromotionService.updateShoppingCartGoodsDiscount(couponPromotionVO, activityQueryDto, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo, userLoginInfoDto, shoppingCartInfoRequestVo);
......@@ -476,7 +476,8 @@ public abstract class AbstractShoppingCartImpl implements ShoppingCartNewService
shoppingCartGoodsResponseVo.setThresholdAmount(discount.getThresholdAmount());
shoppingCartGoodsResponseVo.setIsDiscountDelivery(true);
}else{
// fisherman 老算价, deliverAmount 不包含 nightDistributionFee 但是页面需要展示总价 所以 这里相加一下 做处理
Long deliverAmountNew = deliveryAmount + nightDistributionFee;
if (activityResponse!=null) {
if(beanDto.getBenefitType() == 1){
......
......@@ -3,6 +3,7 @@ package cn.freemud.service;
import cn.freemud.adapter.ActivityAdapter;
import cn.freemud.base.entity.BaseResponse;
import cn.freemud.constant.ShoppingCartConstant;
import cn.freemud.entities.ExtraDeliveryDto;
import cn.freemud.entities.dto.ActivityResponseDto;
import cn.freemud.entities.dto.GetMemberInfoRequestDto;
import cn.freemud.entities.dto.GetMemberInfoResponseVo;
......@@ -97,7 +98,8 @@ public interface ShoppingCartNewService {
boolean isMember,
List<CartGoods> cartGoodsList,
List<ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon> coupons,
List<ShoppingCartInfoRequestVo.SendGoods> sendGoodsList, String menuType, Long distributionFee, Integer bizType, Integer accountFlag);
List<ShoppingCartInfoRequestVo.SendGoods> sendGoodsList, String menuType, Long distributionFee, Integer bizType, Integer accountFlag,
long nightDistributionFee);
List<CartGoods> updateCartGoodsLegal(CartGoods cartGoods, String userId, ShoppingCartGoodsBaseResponseVo shoppingCartGoodsResponseVo, AddShoppingCartGoodsRequestVo addShoppingCartGoodsRequestVo, List<CartGoods> oldAllCartGoodsList);
......@@ -317,4 +319,14 @@ public interface ShoppingCartNewService {
};
BaseResponse getV3Promotion(BaseRequestVo request);
default long getNightDistributionFee(List<ExtraDeliveryDto> deliveryAmountList){
if (CollectionUtils.isEmpty(deliveryAmountList)) {
return 0L;
}
return deliveryAmountList.stream()
.filter(s -> s.getType() != ExtraDeliveryDto.TYPE_DEFAULT)
.mapToLong(ExtraDeliveryDto::getDeliveryAmount)
.sum();
}
}
......@@ -200,12 +200,12 @@ public class ShoppingCartCollageServiceImpl extends AbstractShoppingCartImpl imp
// 获取优惠信息
CalculationDiscountResult calculationDiscountResult
=getCalculationDiscountResult(menuType,partnerId,storeId,currentUserId,appId,userLoginInfoDto.getWxAppid(),orderType,currentUserInfoVo.isMemberPaid(), allCartGoodsList,new ArrayList(),new ArrayList<>(),null,deliveryAmount);
=getCalculationDiscountResult(menuType,partnerId,storeId,currentUserId,appId,userLoginInfoDto.getWxAppid(),orderType,currentUserInfoVo.isMemberPaid(), allCartGoodsList,new ArrayList(),new ArrayList<>(),null,deliveryAmount, this.getNightDistributionFee(shoppingCartGoodsResponseVo.getDeliveryAmountList()));
ActivityQueryDto activityQueryDto = activityAdapter.getActivityQueryDto(partnerId, storeId, currentUserId, appId, addShoppingCartGoodsRequestVo.getOrderType());
// 促销活动的优惠金额计算
updateShoppingCartGoodsDiscount(null, activityQueryDto, calculationDiscountResult, allCartGoodsList, shoppingCartGoodsResponseVo, null, userLoginInfoDto, addShoppingCartGoodsRequestVo.getMenuType(), deliveryAmount);
updateShoppingCartGoodsDiscount(null, activityQueryDto, calculationDiscountResult, allCartGoodsList, shoppingCartGoodsResponseVo, null, userLoginInfoDto, addShoppingCartGoodsRequestVo.getMenuType(), deliveryAmount, this.getNightDistributionFee(shoppingCartGoodsResponseVo.getDeliveryAmountList()));
clearMsg(shoppingCartGoodsResponseVo, cartGoods.getCartGoodsUid());
//设置更新响应信息
setAddAndUpdateResponse(shoppingCartGoodsResponseVo, calculationDiscountResult, allCartGoodsList, null, partnerId, storeId, currentUserId, ShoppingCartConstant.ADD_AND_UPDATE, null);
......@@ -392,7 +392,7 @@ public class ShoppingCartCollageServiceImpl extends AbstractShoppingCartImpl imp
Long deliveryAmount = calculateDeliveryAmount(receiveId, partnerId, storeId, userLoginInfoDto.getWxAppid(), shoppingCartGoodsResponseVo);
// 获取优惠信息
CalculationDiscountResult calculationDiscountResult
=getCalculationDiscountResult(menuType,partnerId,storeId,crateUserId,appId,userLoginInfoDto.getWxAppid(),orderType,currentUserInfoVo.isMemberPaid(),cartGoodsList,new ArrayList(),new ArrayList<>(),null,deliveryAmount);
=getCalculationDiscountResult(menuType,partnerId,storeId,crateUserId,appId,userLoginInfoDto.getWxAppid(),orderType,currentUserInfoVo.isMemberPaid(),cartGoodsList,new ArrayList(),new ArrayList<>(),null,deliveryAmount, this.getNightDistributionFee(shoppingCartGoodsResponseVo.getDeliveryAmountList()));
if (calculationDiscountResult == null) {
shoppingCartGoodsResponseVo.setProducts(cartGoodsList);
}
......@@ -400,7 +400,7 @@ public class ShoppingCartCollageServiceImpl extends AbstractShoppingCartImpl imp
ActivityQueryDto activityQueryDto = activityAdapter.getActivityQueryDto(partnerId, storeId, crateUserId, appId, updateShoppingCartGoodsQtyRequestVo.getOrderType());
// 促销活动的优惠金额计算
updateShoppingCartGoodsDiscount(null, activityQueryDto, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo, null, userLoginInfoDto, updateShoppingCartGoodsQtyRequestVo.getMenuType(), deliveryAmount);
updateShoppingCartGoodsDiscount(null, activityQueryDto, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo, null, userLoginInfoDto, updateShoppingCartGoodsQtyRequestVo.getMenuType(), deliveryAmount, this.getNightDistributionFee(shoppingCartGoodsResponseVo.getDeliveryAmountList()));
clearMsg(shoppingCartGoodsResponseVo, cartGoodsUid);
//设置更新响应信息
......@@ -523,7 +523,7 @@ public class ShoppingCartCollageServiceImpl extends AbstractShoppingCartImpl imp
Long deliveryAmount = calculateDeliveryAmount(receiveId, partnerId, storeId, userLoginInfoDto.getWxAppid(), shoppingCartGoodsResponseVo);
// 获取优惠信息
CalculationDiscountResult calculationDiscountResult = getCalculationDiscountResult(menuType,partnerId,storeId,crateUserId,appId,userLoginInfoDto.getWxAppid(),orderType,currentUserInfoVo.isMemberPaid(),cartGoodsList,coupons,null,shoppingCartInfoRequestVo.getReceiveId(),deliveryAmount);
CalculationDiscountResult calculationDiscountResult = getCalculationDiscountResult(menuType,partnerId,storeId,crateUserId,appId,userLoginInfoDto.getWxAppid(),orderType,currentUserInfoVo.isMemberPaid(),cartGoodsList,coupons,null,shoppingCartInfoRequestVo.getReceiveId(),deliveryAmount, this.getNightDistributionFee(shoppingCartGoodsResponseVo.getDeliveryAmountList()));
if (calculationDiscountResult == null) {
shoppingCartGoodsResponseVo.setProducts(cartGoodsList);
......@@ -533,7 +533,7 @@ public class ShoppingCartCollageServiceImpl extends AbstractShoppingCartImpl imp
CouponPromotionVO couponPromotionVO = couponAdapter.getCouponPromotionVO(shoppingCartInfoRequestVo, userLoginInfoDto);
// 促销活动的优惠金额计算
this.updateShoppingCartGoodsDiscount(couponPromotionVO, activityQueryDto, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo, shoppingCartInfoRequestVo, userLoginInfoDto,shoppingCartInfoRequestVo.getMenuType(),deliveryAmount);
this.updateShoppingCartGoodsDiscount(couponPromotionVO, activityQueryDto, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo, shoppingCartInfoRequestVo, userLoginInfoDto,shoppingCartInfoRequestVo.getMenuType(),deliveryAmount, this.getNightDistributionFee(shoppingCartGoodsResponseVo.getDeliveryAmountList()));
//设置更新响应信息
setAddAndUpdateResponse(shoppingCartGoodsResponseVo, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo.getToastMsg(), partnerId, storeId, crateUserId, ShoppingCartConstant.QUERY_INFO, shoppingCartInfoRequestVo);
// 在原价、现价、折扣价上增加第一次使用会员卡的费用
......@@ -737,7 +737,7 @@ public class ShoppingCartCollageServiceImpl extends AbstractShoppingCartImpl imp
Long deliveryAmount = calculateDeliveryAmount(receiveId, partnerId, storeId, userLoginInfoDto.getWxAppid(), shoppingCartGoodsResponseVo);
// 获取优惠信息
CalculationDiscountResult calculationDiscountResult = getCalculationDiscountResult(menuType,partnerId,storeId,userId,appId,userLoginInfoDto.getWxAppid(),orderType,assortmentCustomerInfoVo.isMemberPaid(),cartGoodsList,coupons,sendGoodsList,shoppingCartInfoRequestVo.getReceiveId(),deliveryAmount);
CalculationDiscountResult calculationDiscountResult = getCalculationDiscountResult(menuType,partnerId,storeId,userId,appId,userLoginInfoDto.getWxAppid(),orderType,assortmentCustomerInfoVo.isMemberPaid(),cartGoodsList,coupons,sendGoodsList,shoppingCartInfoRequestVo.getReceiveId(),deliveryAmount, this.getNightDistributionFee(shoppingCartGoodsResponseVo.getDeliveryAmountList()));
ActivityQueryDto activityQueryDto = activityAdapter.getActivityQueryDto(partnerId, storeId, userId, appId, shoppingCartInfoRequestVo.getOrderType());
......@@ -745,7 +745,7 @@ public class ShoppingCartCollageServiceImpl extends AbstractShoppingCartImpl imp
// 临时方案
packgeAdditional(shoppingCartInfoRequestVo, premiumExchangeActivity);
// 促销活动的优惠金额计算
updateShoppingCartGoodsDiscount(couponPromotionVO, activityQueryDto, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo, shoppingCartInfoRequestVo, userLoginInfoDto,shoppingCartInfoRequestVo.getMenuType(),deliveryAmount);
updateShoppingCartGoodsDiscount(couponPromotionVO, activityQueryDto, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo, shoppingCartInfoRequestVo, userLoginInfoDto,shoppingCartInfoRequestVo.getMenuType(),deliveryAmount, this.getNightDistributionFee(shoppingCartGoodsResponseVo.getDeliveryAmountList()));
//设置更新响应信息
setAddAndUpdateResponse(shoppingCartGoodsResponseVo, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo.getToastMsg(), partnerId, storeId, userId, ShoppingCartConstant.QUERY_INFO, shoppingCartInfoRequestVo);
......@@ -791,7 +791,7 @@ public class ShoppingCartCollageServiceImpl extends AbstractShoppingCartImpl imp
}
@Override
public 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,Integer bizType, Integer accoutFlag) {
public 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,Integer bizType, Integer accoutFlag,long nightDistributionFee) {
ActivityCalculationDiscountRequestDto activityCalculationDiscountRequestDto = getActivityCalculationDiscountRequestDto(partnerId, storeId, userId, appId, orderType);
List<ActivityCalculationDiscountRequestDto.CalculationDiscountGoods> calculationDiscountGoodsList = new ArrayList<>();
// 校验后有效的商品券map
......@@ -852,6 +852,7 @@ public class ShoppingCartCollageServiceImpl extends AbstractShoppingCartImpl imp
activityCalculationDiscountRequestDto.setCoupons(coupons);
activityCalculationDiscountRequestDto.setOrgIds(commonService.getOrgIdsForCoupon(partnerId, storeId));
activityCalculationDiscountRequestDto.setDistributionFee(distributionFee);
activityCalculationDiscountRequestDto.setNightDistributionFee(nightDistributionFee);
activityCalculationDiscountRequestDto.setIsMember(isMember);
ActivityCalculationDiscountResponseDto activityCalculationDiscountResponseDto = activityClient.calculationDiscount(activityCalculationDiscountRequestDto);
// try {
......@@ -1264,7 +1265,7 @@ public class ShoppingCartCollageServiceImpl extends AbstractShoppingCartImpl imp
Long deliveryAmount = calculateDeliveryAmount(receiveId, partnerId, storeId, userLoginInfoDto.getWxAppid(), shoppingCartGoodsResponseVo);
// 获取优惠信息
CalculationDiscountResult calculationDiscountResult
=getCalculationDiscountResult(menuType,partnerId,storeId,crateUserId,appId,userLoginInfoDto.getWxAppid(),orderType,currentUserInfoVo.isMemberPaid(),cartGoodsList,new ArrayList(),new ArrayList<>(),null,deliveryAmount);
=getCalculationDiscountResult(menuType,partnerId,storeId,crateUserId,appId,userLoginInfoDto.getWxAppid(),orderType,currentUserInfoVo.isMemberPaid(),cartGoodsList,new ArrayList(),new ArrayList<>(),null,deliveryAmount, this.getNightDistributionFee(shoppingCartGoodsResponseVo.getDeliveryAmountList()));
if (calculationDiscountResult == null) {
shoppingCartGoodsResponseVo.setProducts(cartGoodsList);
}
......@@ -1272,7 +1273,7 @@ public class ShoppingCartCollageServiceImpl extends AbstractShoppingCartImpl imp
ActivityQueryDto activityQueryDto = activityAdapter.getActivityQueryDto(partnerId, storeId, crateUserId, appId, shoppingCartCollageClearRequestVo.getOrderType());
// 促销活动的优惠金额计算
updateShoppingCartGoodsDiscount(null, activityQueryDto, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo, null, userLoginInfoDto, shoppingCartCollageClearRequestVo.getMenuType(), deliveryAmount);
updateShoppingCartGoodsDiscount(null, activityQueryDto, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo, null, userLoginInfoDto, shoppingCartCollageClearRequestVo.getMenuType(), deliveryAmount, this.getNightDistributionFee(shoppingCartGoodsResponseVo.getDeliveryAmountList()));
//设置更新响应信息
setAddAndUpdateResponse(shoppingCartGoodsResponseVo, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo.getToastMsg(), partnerId, storeId, crateUserId, ShoppingCartConstant.ADD_AND_UPDATE, null);
......
......@@ -640,7 +640,7 @@ public class ShoppingCartMallServiceImpl implements ShoppingCartNewService {
@Override
public 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, Integer bizType, Integer accountFlag) {
List<ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon> coupons, List<ShoppingCartInfoRequestVo.SendGoods> sendGoodsList, String menuType, Long distributionFee, Integer bizType, Integer accountFlag,long nightDistributionFee) {
return null;
}
......
......@@ -434,7 +434,7 @@ public class ShoppingCartMealServiceImpl implements ShoppingCartNewService {
if (CollectionUtils.isEmpty(cartGoodsList)) {
return;
}
CalculationDiscountResult calculationDiscountResult = this.getActivityCalculationDiscountResponse(partnerId, storeId, userId, appId, orderType, isMember, cartGoodsList, new ArrayList<>(), new ArrayList<>(), BusinessTypeEnum.SAAS_MALL.getCode(), 0L,null, null);
CalculationDiscountResult calculationDiscountResult = this.getActivityCalculationDiscountResponse(partnerId, storeId, userId, appId, orderType, isMember, cartGoodsList, new ArrayList<>(), new ArrayList<>(), BusinessTypeEnum.SAAS_MALL.getCode(), 0L,null, null,0L);
if(calculationDiscountResult == null) {
return;
}
......@@ -563,7 +563,7 @@ public class ShoppingCartMealServiceImpl implements ShoppingCartNewService {
@Override
public 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,Integer bizType, Integer accountFlag) {
List<CartGoods> cartGoodsList, List<ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon> coupons, List<ShoppingCartInfoRequestVo.SendGoods> sendGoodsList,String menuType,Long distributionFee,Integer bizType, Integer accountFlag,long nightDistributionFee) {
ActivityCalculationDiscountRequestDto activityCalculationDiscountRequestDto = getActivityCalculationDiscountRequestDto(partnerId, storeId, userId, appId, orderType);
List<ActivityCalculationDiscountRequestDto.CalculationDiscountGoods> calculationDiscountGoodsList = new ArrayList<>();
cartGoodsList = cartGoodsList.stream().filter(t -> !isWeightProduct(t)).collect(Collectors.toList());
......@@ -579,6 +579,7 @@ public class ShoppingCartMealServiceImpl implements ShoppingCartNewService {
activityCalculationDiscountRequestDto.setCoupons(coupons);
activityCalculationDiscountRequestDto.setOrgIds(commonService.getOrgIdsForCoupon(partnerId, storeId));
activityCalculationDiscountRequestDto.setDistributionFee(distributionFee);
activityCalculationDiscountRequestDto.setNightDistributionFee(nightDistributionFee);
activityCalculationDiscountRequestDto.setIsMember(isMember);
ActivityCalculationDiscountResponseDto activityCalculationDiscountResponseDto = activityClient.calculationDiscount(activityCalculationDiscountRequestDto);
// try {
......
......@@ -22,7 +22,6 @@ import cn.freemud.constant.ResponseCodeConstant;
import cn.freemud.constant.ShoppingCartConstant;
import cn.freemud.demo.controller.ShoppingCartDemoController;
import cn.freemud.demo.entities.dto.goods.add.list.BaseListCartGoodsVO;
import cn.freemud.entities.ExtraDeliveryDto;
import cn.freemud.entities.dto.*;
import cn.freemud.entities.dto.activity.ActivityDiscountsDto;
import cn.freemud.entities.dto.activity.ActivityQueryDto;
......@@ -396,7 +395,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
//
} else {
// 获取优惠信息
CalculationDiscountResult calculationDiscountResult = getCalculationDiscountResult(menuType, partnerId, storeId, userId, appId, userLoginInfoDto.getWxAppid(), orderType, assortmentCustomerInfoVo.isMemberPaid(), allCartGoodsList, new ArrayList(), new ArrayList<>(), null, deliveryAmount,bizType, accountFlag);
CalculationDiscountResult calculationDiscountResult = getCalculationDiscountResult(menuType, partnerId, storeId, userId, appId, userLoginInfoDto.getWxAppid(), orderType, assortmentCustomerInfoVo.isMemberPaid(), allCartGoodsList, new ArrayList(), new ArrayList<>(), null, deliveryAmount,bizType, accountFlag, this.getNightDistributionFee(shoppingCartGoodsResponseVo.getDeliveryAmountList()));
if (calculationDiscountResult != null && CollectionUtils.isNotEmpty(calculationDiscountResult.getSendGoods())){
sendGoodsQtyCheck(productsCount, appId, partnerId, userId, storeId, tableNumber, oldCartGoodsList, shoppingCartBaseService, calculationDiscountResult.getSendGoods(),bizType);
}
......@@ -408,7 +407,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
assortmentSdkService.updateGoodsQtyBySdk(partnerId, userId, storeId, cartGoods.getCartGoodsUid(), 0, "", shoppingCartBaseService,bizType);
}
// 促销活动的优惠金额计算
updateShoppingCartGoodsDiscount(null, activityQueryDto, calculationDiscountResult, allCartGoodsList, shoppingCartGoodsResponseVo, null, userLoginInfoDto, addShoppingCartGoodsRequestVo.getMenuType(), deliveryAmount);
updateShoppingCartGoodsDiscount(null, activityQueryDto, calculationDiscountResult, allCartGoodsList, shoppingCartGoodsResponseVo, null, userLoginInfoDto, addShoppingCartGoodsRequestVo.getMenuType(), deliveryAmount, this.getNightDistributionFee(shoppingCartGoodsResponseVo.getDeliveryAmountList()));
clearMsg(shoppingCartGoodsResponseVo, cartGoods.getCartGoodsUid());
//设置更新响应信息
......@@ -559,7 +558,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
buildShoppingCartGoodsResponse(shoppingCartGoodsResponseVo, discountResult, null, partnerId);
} else {
// 获取优惠信息
CalculationDiscountResult calculationDiscountResult = getCalculationDiscountResult(menuType, partnerId, storeId, userId, appId, userLoginInfoDto.getWxAppid(), orderType, assortmentCustomerInfoVo.isMemberPaid(), cartGoodsList, new ArrayList(), new ArrayList<>(), null, deliveryAmount,bizType, accountFlag);
CalculationDiscountResult calculationDiscountResult = getCalculationDiscountResult(menuType, partnerId, storeId, userId, appId, userLoginInfoDto.getWxAppid(), orderType, assortmentCustomerInfoVo.isMemberPaid(), cartGoodsList, new ArrayList(), new ArrayList<>(), null, deliveryAmount,bizType, accountFlag, this.getNightDistributionFee(shoppingCartGoodsResponseVo.getDeliveryAmountList()));
if (calculationDiscountResult == null) {
shoppingCartGoodsResponseVo.setProducts(cartGoodsList);
}
......@@ -569,7 +568,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
//校验
calculationUpdateCouponStatus(userId, partnerId, storeId, bizType, cartGoodsList, calculationDiscountResult);
// 促销活动的优惠金额计算
updateShoppingCartGoodsDiscount(null, activityQueryDto, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo, null, userLoginInfoDto, updateShoppingCartGoodsQtyRequestVo.getMenuType(), deliveryAmount);
updateShoppingCartGoodsDiscount(null, activityQueryDto, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo, null, userLoginInfoDto, updateShoppingCartGoodsQtyRequestVo.getMenuType(), deliveryAmount, this.getNightDistributionFee(shoppingCartGoodsResponseVo.getDeliveryAmountList()));
clearMsg(shoppingCartGoodsResponseVo, cartGoodsUid);
//设置更新响应信息
setAddAndUpdateResponse(shoppingCartGoodsResponseVo, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo.getToastMsg(), partnerId, storeId, userId, ShoppingCartConstant.ADD_AND_UPDATE, null);
......@@ -817,16 +816,17 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
}
});
}
long nightDistributionFee = this.getNightDistributionFee(shoppingCartGoodsResponseVo.getDeliveryAmountList());
// 获取优惠信息 调用促销
CalculationDiscountResult calculationDiscountResult = getCalculationDiscountResult(menuType, partnerId, storeId, userId, appId,
userLoginInfoDto.getWxAppid(), orderType, assortmentCustomerInfoVo.isMemberPaid(),
cartGoodsList, coupons, null, shoppingCartInfoRequestVo.getReceiveId(), deliveryAmount,bizType, accountFlag);
cartGoodsList, coupons, null, shoppingCartInfoRequestVo.getReceiveId(), deliveryAmount,bizType, accountFlag, nightDistributionFee);
if (calculationDiscountResult == null) {
shoppingCartGoodsResponseVo.setProducts(cartGoodsList);
}
// 促销活动的优惠金额计算
this.updateShoppingCartGoodsDiscount(couponPromotionVO, activityQueryDto, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo, shoppingCartInfoRequestVo, userLoginInfoDto, shoppingCartInfoRequestVo.getMenuType(), deliveryAmount);
this.updateShoppingCartGoodsDiscount(couponPromotionVO, activityQueryDto, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo, shoppingCartInfoRequestVo, userLoginInfoDto, shoppingCartInfoRequestVo.getMenuType(), deliveryAmount, nightDistributionFee);
//设置更新响应信息
setAddAndUpdateResponse(shoppingCartGoodsResponseVo, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo.getToastMsg(), partnerId, storeId, userId, ShoppingCartConstant.QUERY_INFO, shoppingCartInfoRequestVo);
// 在原价、现价、折扣价上增加第一次使用会员卡的费用
......@@ -1259,11 +1259,11 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
}
// 获取优惠信息
CalculationDiscountResult calculationDiscountResult = getCalculationDiscountResult(menuType, partnerId, storeId, userId, appId, userLoginInfoDto.getWxAppid(), orderType, assortmentCustomerInfoVo.isMemberPaid(), cartGoodsList, coupons, sendGoodsList, shoppingCartInfoRequestVo.getReceiveId(), deliveryAmount,bizType, accountFlag);
CalculationDiscountResult calculationDiscountResult = getCalculationDiscountResult(menuType, partnerId, storeId, userId, appId, userLoginInfoDto.getWxAppid(), orderType, assortmentCustomerInfoVo.isMemberPaid(), cartGoodsList, coupons, sendGoodsList, shoppingCartInfoRequestVo.getReceiveId(), deliveryAmount,bizType, accountFlag, this.getNightDistributionFee(shoppingCartGoodsResponseVo.getDeliveryAmountList()));
//临时方案
packgeAdditional(shoppingCartInfoRequestVo, premiumExchangeActivity);
// 促销活动的优惠金额计算
updateShoppingCartGoodsDiscount(couponPromotionVO, activityQueryDto, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo, shoppingCartInfoRequestVo, userLoginInfoDto, shoppingCartInfoRequestVo.getMenuType(), deliveryAmount);
updateShoppingCartGoodsDiscount(couponPromotionVO, activityQueryDto, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo, shoppingCartInfoRequestVo, userLoginInfoDto, shoppingCartInfoRequestVo.getMenuType(), deliveryAmount, this.getNightDistributionFee(shoppingCartGoodsResponseVo.getDeliveryAmountList()));
//设置更新响应信息
setAddAndUpdateResponse(shoppingCartGoodsResponseVo, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo.getToastMsg(), partnerId, storeId, userId, ShoppingCartConstant.QUERY_INFO, shoppingCartInfoRequestVo);
......@@ -1528,7 +1528,8 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
List<ShoppingCartInfoRequestVo.SendGoods> sendGoodsList, String menuType,
Long distributionFee,
Integer bizType,
Integer accountFlag
Integer accountFlag,
long nightDistributionFee
) {
ActivityCalculationDiscountRequestDto activityCalculationDiscountRequestDto = getActivityCalculationDiscountRequestDto(partnerId, storeId, userId, appId, orderType);
......@@ -1648,6 +1649,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
activityCalculationDiscountRequestDto.setCoupons(coupons);
activityCalculationDiscountRequestDto.setOrgIds(commonService.getOrgIdsForCoupon(partnerId, storeId));
activityCalculationDiscountRequestDto.setDistributionFee(distributionFee);
activityCalculationDiscountRequestDto.setNightDistributionFee(nightDistributionFee);
activityCalculationDiscountRequestDto.setIsMember(isMember);
//todo def是什么?
activityCalculationDiscountRequestDto.setProductChannel("def");
......@@ -1873,7 +1875,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
* @param shoppingCartGoodsResponseVo
*/
private void updateShoppingCartGoodsDiscount(CouponPromotionVO couponPromotionVO, ActivityQueryDto activityQueryDto, CalculationDiscountResult calculationDiscountResult, List<CartGoods> cartGoodsList
, ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo, ShoppingCartInfoRequestVo shoppingCartInfoRequestVo, UserLoginInfoDto userLoginInfoDto, String menuType, Long deliveryAmount) {
, ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo, ShoppingCartInfoRequestVo shoppingCartInfoRequestVo, UserLoginInfoDto userLoginInfoDto, String menuType, Long deliveryAmount, long nightDistributionFee) {
//默认计算优惠
DefaultPromotionService defaultPromotionService = (DefaultPromotionService) PromotionFactory.getPromotionService(ShoppingCartPromotionEnum.DEFAULT_PROMOTION);
defaultPromotionService.updateShoppingCartGoodsDiscount(couponPromotionVO, activityQueryDto, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo, userLoginInfoDto, shoppingCartInfoRequestVo);
......@@ -2011,7 +2013,8 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
// fisherman 促销优惠先 剩余的 配送费 怎么处理的? 需要沟通问一下
} else {
// fisherman 老算价, deliverAmount 不包含 nightDistributionFee 但是页面需要展示总价 所以 这里相加一下 做处理
Long deliverAmountNew = deliveryAmount + nightDistributionFee;
if (activityResponse != null) {
if (beanDto.getBenefitType() == 1) {
......@@ -2022,8 +2025,8 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
shoppingCartGoodsResponseVo.setDeliveryDiscountDesc(String.format(desc, df.format(beanDto.getThresholdAmount().doubleValue() / 100), df.format(beanDto.getDiscountAmount().doubleValue() / 100)));
}
shoppingCartGoodsResponseVo.setDeliveryAmount(deliveryAmount);
shoppingCartGoodsResponseVo.setDiscountDeliveryAmount(deliveryAmount);
shoppingCartGoodsResponseVo.setDeliveryAmount(deliverAmountNew);
shoppingCartGoodsResponseVo.setDiscountDeliveryAmount(deliverAmountNew);
shoppingCartGoodsResponseVo.setIsDiscountDelivery(false);
// fisherman 有活动 并且使用了优惠券
boolean isType34 = verifyActivity(calculationDiscountResult);
......@@ -2037,11 +2040,11 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
} else {
// 这里需要看看 选择了 配送券 calculationDiscountResult.getDistributionFee() 这个值是多少
String desc = DELIVERY_DISCOUNT_DESC3;
shoppingCartGoodsResponseVo.setDeliveryDiscountDesc(String.format(desc, df.format(deliveryAmount.doubleValue() / 100)));
shoppingCartGoodsResponseVo.setDeliveryAmount(deliveryAmount);
shoppingCartGoodsResponseVo.setDiscountDeliveryAmount(deliveryAmount);
shoppingCartGoodsResponseVo.setDeliveryDiscountDesc(String.format(desc, df.format(deliverAmountNew.doubleValue() / 100)));
shoppingCartGoodsResponseVo.setDeliveryAmount(deliverAmountNew);
shoppingCartGoodsResponseVo.setDiscountDeliveryAmount(deliverAmountNew);
// 增加配送券之后的逻辑
// shoppingCartGoodsResponseVo.setDiscountDeliveryAmount(calculationDiscountResult==null?deliveryAmount:calculationDiscountResult.getDistributionFee());
// shoppingCartGoodsResponseVo.setDiscountDeliveryAmount(calculationDiscountResult==null?deliverAmountNew:calculationDiscountResult.getDistributionFee());
shoppingCartGoodsResponseVo.setIsDiscountDelivery(false);
// fisherman 确认是否 使用了优惠券
boolean isType34 = verifyActivity(calculationDiscountResult);
......@@ -2679,15 +2682,15 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
private CalculationDiscountResult getCalculationDiscountResult(String menuType
, String partnerId, String storeId, String userId, String appId, String wxappid, Integer orderType, boolean isMember
, List<CartGoods> cartGoodsList, List<ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon> coupons
, List<ShoppingCartInfoRequestVo.SendGoods> sendGoodsList, String receiveId, Long deliveryAmount,Integer bizType, Integer accountFlag) {
, List<ShoppingCartInfoRequestVo.SendGoods> sendGoodsList, String receiveId, Long deliveryAmount,Integer bizType, Integer accountFlag, long nightDistributionFee) {
// 获取优惠信息
CalculationDiscountResult calculationDiscountResult = null;
//外卖场景下 查询门店配送信息
if (BusinessTypeEnum.SAAS_DELIVERY.getCode().equals(menuType)) {
calculationDiscountResult = this.getActivityCalculationDiscountResponse(partnerId, storeId, userId, appId, orderType, isMember, cartGoodsList, coupons, sendGoodsList, BusinessTypeEnum.getByType(menuType).getCode(), deliveryAmount,bizType, accountFlag);
calculationDiscountResult = this.getActivityCalculationDiscountResponse(partnerId, storeId, userId, appId, orderType, isMember, cartGoodsList, coupons, sendGoodsList, BusinessTypeEnum.getByType(menuType).getCode(), deliveryAmount,bizType, accountFlag, nightDistributionFee);
} else {
calculationDiscountResult = this.getActivityCalculationDiscountResponse(partnerId, storeId, userId, appId, orderType, isMember, cartGoodsList, coupons, sendGoodsList, BusinessTypeEnum.getByType(menuType).getCode(), null,bizType, accountFlag);
calculationDiscountResult = this.getActivityCalculationDiscountResponse(partnerId, storeId, userId, appId, orderType, isMember, cartGoodsList, coupons, sendGoodsList, BusinessTypeEnum.getByType(menuType).getCode(), null,bizType, accountFlag, 0L);
}
return calculationDiscountResult;
......@@ -3152,7 +3155,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
}
// 获取优惠信息
CalculationDiscountResult calculationDiscountResult = getCalculationDiscountResult(menuType, partnerId, storeId, userId, appId, assortmentCustomerInfoVo.getWxAppId(), orderType, assortmentCustomerInfoVo.isMemberPaid(), cartGoodsList, coupons, null, null, 0L,bizType
, accountFlag);
, accountFlag, 0L);
premiumExchangeResponseVo = activityAdapter.convert2PremiumExchange(calculationDiscountResult);
}
......@@ -3321,7 +3324,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
couponAvailableCartInfo = activityAdapter.convert2CouponAvailableCartInfoSharing(partnerId, storeId, discountResult, orgCodes);
} else {
// 获取优惠信息
CalculationDiscountResult calculationDiscountResult = getCalculationDiscountResult(menuType, partnerId, storeId, userId, appId, assortmentCustomerInfoVo.getWxAppId(), orderType, assortmentCustomerInfoVo.isMemberPaid(), cartGoodsList, new ArrayList<>(), null, null, deliveryAmount,bizType, accountFlag);
CalculationDiscountResult calculationDiscountResult = getCalculationDiscountResult(menuType, partnerId, storeId, userId, appId, assortmentCustomerInfoVo.getWxAppId(), orderType, assortmentCustomerInfoVo.isMemberPaid(), cartGoodsList, new ArrayList<>(), null, null, deliveryAmount,bizType, accountFlag, this.getNightDistributionFee(shoppingCartGoodsResponseVo.getDeliveryAmountList()));
couponAvailableCartInfo = activityAdapter.convert2CouponAvailableCartInfo(partnerId, storeId, calculationDiscountResult, orgCodes);
}
return ResponseUtil.success(couponAvailableCartInfo);
......@@ -3528,13 +3531,4 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
return fullReplace;
}
private long getNightDistributionFee(List<ExtraDeliveryDto> deliveryAmountList ){
if (CollectionUtils.isEmpty(deliveryAmountList)) {
return 0L;
}
return deliveryAmountList.stream()
.filter(s -> s.getType() != ExtraDeliveryDto.TYPE_DEFAULT)
.mapToLong(ExtraDeliveryDto::getDeliveryAmount)
.sum();
}
}
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