Commit b13bbc6d by 周晓航

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

Signed-off-by: 周晓航 <xiaohang.zhou@freemud.com>
parent f70fb10b
...@@ -76,6 +76,11 @@ public class ActivityCalculationDiscountRequestDto { ...@@ -76,6 +76,11 @@ public class ActivityCalculationDiscountRequestDto {
private Long distributionFee; private Long distributionFee;
/** /**
* 是否有夜间配送费, 白天配送费 综合, 该字段依据门店是否设置 为依据
*/
private Long nightDistributionFee = 0L;
/**
* 购买月卡费用(分) * 购买月卡费用(分)
*/ */
private Long payCardFee; private Long payCardFee;
......
...@@ -66,8 +66,8 @@ public interface DeliveryService { ...@@ -66,8 +66,8 @@ public interface DeliveryService {
if (DateTimeUtil.isEffectiveDate(nowTime, startTime, endTime)) { if (DateTimeUtil.isEffectiveDate(nowTime, startTime, endTime)) {
ExtraDeliveryDto extraDeliveryDto = new ExtraDeliveryDto(info.getType(), amount); ExtraDeliveryDto extraDeliveryDto = new ExtraDeliveryDto(info.getType(), amount);
list.add(extraDeliveryDto); list.add(extraDeliveryDto);
// 金额 增加 // 金额 增加, 原来配送费金额不变
amount += info.getPrice(); // amount += info.getPrice();
} }
} catch (ParseException e) { } catch (ParseException e) {
// 报错表示 时间格式设置错误, 默认当做不计算 // 报错表示 时间格式设置错误, 默认当做不计算
......
...@@ -37,7 +37,10 @@ import cn.freemud.interceptor.ServiceException; ...@@ -37,7 +37,10 @@ import cn.freemud.interceptor.ServiceException;
import cn.freemud.service.BuriedPointService; import cn.freemud.service.BuriedPointService;
import cn.freemud.service.ItemService; import cn.freemud.service.ItemService;
import cn.freemud.service.ShoppingCartNewService; import cn.freemud.service.ShoppingCartNewService;
import cn.freemud.service.impl.calculate.*; import cn.freemud.service.impl.calculate.CalculationSharingCartService;
import cn.freemud.service.impl.calculate.CalculationSharingDiscountService;
import cn.freemud.service.impl.calculate.CalculationSharingEquallyService;
import cn.freemud.service.impl.calculate.CalculationSharingValidatorService;
import cn.freemud.service.shoppingCart.ShoppingCartRelationFactory; import cn.freemud.service.shoppingCart.ShoppingCartRelationFactory;
import cn.freemud.service.shoppingCart.ShoppingCartRelationService; import cn.freemud.service.shoppingCart.ShoppingCartRelationService;
import cn.freemud.service.thirdparty.CustomerApplicationClient; import cn.freemud.service.thirdparty.CustomerApplicationClient;
...@@ -63,7 +66,6 @@ import org.apache.commons.collections4.CollectionUtils; ...@@ -63,7 +66,6 @@ import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang.ObjectUtils; import org.apache.commons.lang.ObjectUtils;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.*; import java.util.*;
...@@ -193,7 +195,7 @@ public class ShoppingCartMallServiceImpl implements ShoppingCartNewService { ...@@ -193,7 +195,7 @@ public class ShoppingCartMallServiceImpl implements ShoppingCartNewService {
ActivityQueryDto activityQueryDto = activityAdapter.getActivityQueryDto(partnerId, storeId, userId, appId, addShoppingCartGoodsRequestVo.getOrderType()); ActivityQueryDto activityQueryDto = activityAdapter.getActivityQueryDto(partnerId, storeId, userId, appId, addShoppingCartGoodsRequestVo.getOrderType());
CalculationDiscountResult discountResult = null; CalculationDiscountResult discountResult = null;
discountResult = sharingDiscountService.getCalculationSharingDiscountResult(menuType, partnerId, storeId, userId, appId, orderType, assortmentCustomerInfoVo.isMemberPaid(), allCartGoodsList, new ArrayList<>(), null, deliveryAmount, null,null, accountType,new DiscountSharingDto()); discountResult = sharingDiscountService.getCalculationSharingDiscountResult(menuType, partnerId, storeId, userId, appId, orderType, assortmentCustomerInfoVo.isMemberPaid(), allCartGoodsList, new ArrayList<>(), null, deliveryAmount, null,null, accountType,new DiscountSharingDto(),0L);
sharingCartService.distribute(discountResult, allCartGoodsList, shoppingCartGoodsResponseVo, null, null, null, activityQueryDto, menuType, deliveryAmount, ShoppingCartConstant.ADD_AND_UPDATE, partnerId, null, userId, storeId); sharingCartService.distribute(discountResult, allCartGoodsList, shoppingCartGoodsResponseVo, null, null, null, activityQueryDto, menuType, deliveryAmount, ShoppingCartConstant.ADD_AND_UPDATE, partnerId, null, userId, storeId);
buildShoppingCartGoodsResponse(shoppingCartGoodsResponseVo,discountResult,null,partnerId); buildShoppingCartGoodsResponse(shoppingCartGoodsResponseVo,discountResult,null,partnerId);
...@@ -288,7 +290,7 @@ public class ShoppingCartMallServiceImpl implements ShoppingCartNewService { ...@@ -288,7 +290,7 @@ public class ShoppingCartMallServiceImpl implements ShoppingCartNewService {
, new ArrayList() //券 , new ArrayList() //券
, null //加价购商品 , null //加价购商品
, deliveryAmount , deliveryAmount
, null,null, accountFlag,new DiscountSharingDto()); , null,null, accountFlag,new DiscountSharingDto(),0L);
sharingCartService.distribute(discountResult sharingCartService.distribute(discountResult
, cartGoodsList , cartGoodsList
...@@ -447,7 +449,7 @@ public class ShoppingCartMallServiceImpl implements ShoppingCartNewService { ...@@ -447,7 +449,7 @@ public class ShoppingCartMallServiceImpl implements ShoppingCartNewService {
, coupons , coupons
, sendGoods , sendGoods
, deliveryAmount , deliveryAmount
, null,null, accountFlag,new DiscountSharingDto()); , null,null, accountFlag,new DiscountSharingDto(),0L);
sharingCartService.distribute(calculationSharingDiscountResult sharingCartService.distribute(calculationSharingDiscountResult
, cartGoodsList , cartGoodsList
, shoppingCartGoodsResponseVo , shoppingCartGoodsResponseVo
...@@ -605,7 +607,7 @@ public class ShoppingCartMallServiceImpl implements ShoppingCartNewService { ...@@ -605,7 +607,7 @@ public class ShoppingCartMallServiceImpl implements ShoppingCartNewService {
, coupons , coupons
, shoppingCartInfoRequestVo.getSendGoods() , shoppingCartInfoRequestVo.getSendGoods()
, deliveryAmount , deliveryAmount
, shoppingCartInfoRequestVo,null, accountFlag,new DiscountSharingDto()); , shoppingCartInfoRequestVo,null, accountFlag,new DiscountSharingDto(), 0L);
// 活动校验 // 活动校验
calculationSharingValidatorService.validator(discountResult calculationSharingValidatorService.validator(discountResult
......
...@@ -22,6 +22,7 @@ import cn.freemud.constant.ResponseCodeConstant; ...@@ -22,6 +22,7 @@ import cn.freemud.constant.ResponseCodeConstant;
import cn.freemud.constant.ShoppingCartConstant; import cn.freemud.constant.ShoppingCartConstant;
import cn.freemud.demo.controller.ShoppingCartDemoController; import cn.freemud.demo.controller.ShoppingCartDemoController;
import cn.freemud.demo.entities.dto.goods.add.list.BaseListCartGoodsVO; 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.*;
import cn.freemud.entities.dto.activity.ActivityDiscountsDto; import cn.freemud.entities.dto.activity.ActivityDiscountsDto;
import cn.freemud.entities.dto.activity.ActivityQueryDto; import cn.freemud.entities.dto.activity.ActivityQueryDto;
...@@ -34,9 +35,9 @@ import cn.freemud.entities.dto.order.PackAmountConfig; ...@@ -34,9 +35,9 @@ import cn.freemud.entities.dto.order.PackAmountConfig;
import cn.freemud.entities.dto.other.ValidCouponBo; import cn.freemud.entities.dto.other.ValidCouponBo;
import cn.freemud.entities.dto.pay.*; import cn.freemud.entities.dto.pay.*;
import cn.freemud.entities.dto.product.CheckCartRequest; import cn.freemud.entities.dto.product.CheckCartRequest;
import cn.freemud.entities.dto.shoppingCart.PromotionResultVO;
import cn.freemud.entities.dto.product.info.ProductBean; import cn.freemud.entities.dto.product.info.ProductBean;
import cn.freemud.entities.dto.product.info.SkuProductBean; import cn.freemud.entities.dto.product.info.SkuProductBean;
import cn.freemud.entities.dto.shoppingCart.PromotionResultVO;
import cn.freemud.entities.dto.shoppingCart.SendPoint; import cn.freemud.entities.dto.shoppingCart.SendPoint;
import cn.freemud.entities.dto.shoppingCart.ShoppingCartGoodsDto; import cn.freemud.entities.dto.shoppingCart.ShoppingCartGoodsDto;
import cn.freemud.entities.dto.user.GetUserScoreUseDetailRequest; import cn.freemud.entities.dto.user.GetUserScoreUseDetailRequest;
...@@ -384,7 +385,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -384,7 +385,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
, appId, orderType, assortmentCustomerInfoVo.isMemberPaid(), allCartGoodsList , appId, orderType, assortmentCustomerInfoVo.isMemberPaid(), allCartGoodsList
, new ArrayList<>() //结算页选中的代金券 , new ArrayList<>() //结算页选中的代金券
, null //加价购商品 , null //加价购商品
, deliveryAmount, null,bizType, accountFlag,new DiscountSharingDto()); , deliveryAmount, null,bizType, accountFlag,new DiscountSharingDto(),this.getNightDistributionFee(shoppingCartGoodsResponseVo.getDeliveryAmountList()));
//更新购物车券状态 //更新购物车券状态
newCalculationUpdateCouponStatus(userId, partnerId, storeId, bizType, cartGoods, allCartGoodsList, discountResult); newCalculationUpdateCouponStatus(userId, partnerId, storeId, bizType, cartGoods, allCartGoodsList, discountResult);
sharingCartService.distribute(discountResult, allCartGoodsList, shoppingCartGoodsResponseVo, null sharingCartService.distribute(discountResult, allCartGoodsList, shoppingCartGoodsResponseVo, null
...@@ -533,7 +534,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -533,7 +534,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
, new ArrayList() //券 , new ArrayList() //券
, null //加价购商品 , null //加价购商品
, deliveryAmount , deliveryAmount
, null,bizType, accountFlag,new DiscountSharingDto()); , null,bizType, accountFlag,new DiscountSharingDto(), this.getNightDistributionFee(shoppingCartGoodsResponseVo.getDeliveryAmountList()));
//校验加购数量 //校验加购数量
if (discountResult != null) { if (discountResult != null) {
sendGoodsQtyCheckForUpdate(cartGoodsList, oldQty, appId, partnerId, userId, storeId, cartGoodsUid, "", shoppingCartBaseService, discountResult.getSendGoods(),bizType); sendGoodsQtyCheckForUpdate(cartGoodsList, oldQty, appId, partnerId, userId, storeId, cartGoodsUid, "", shoppingCartBaseService, discountResult.getSendGoods(),bizType);
...@@ -736,6 +737,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -736,6 +737,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
assortmentSdkService.setShoppingCart(partnerId, storeId, userId, cartGoodsList, assortmentCustomerInfoVo.getSessionId(), "", this.shoppingCartBaseService,bizType); assortmentSdkService.setShoppingCart(partnerId, storeId, userId, cartGoodsList, assortmentCustomerInfoVo.getSessionId(), "", this.shoppingCartBaseService,bizType);
} }
// 获取基础运费,并且 组装 deliveryAmountList字段: 额外配送费 如夜间配送费等
Long deliveryAmount = calculateDeliveryAmount(receiveId, partnerId, storeId, userLoginInfoDto.getWxAppid(), shoppingCartGoodsResponseVo, shoppingCartInfoRequestVo.getOrderType()); Long deliveryAmount = calculateDeliveryAmount(receiveId, partnerId, storeId, userLoginInfoDto.getWxAppid(), shoppingCartGoodsResponseVo, shoppingCartInfoRequestVo.getOrderType());
ActivityQueryDto activityQueryDto = activityAdapter.getActivityQueryDto(partnerId, storeId, userId, appId, shoppingCartInfoRequestVo.getOrderType()); ActivityQueryDto activityQueryDto = activityAdapter.getActivityQueryDto(partnerId, storeId, userId, appId, shoppingCartInfoRequestVo.getOrderType());
...@@ -778,7 +780,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -778,7 +780,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
, sendGoods , sendGoods
, deliveryAmount , deliveryAmount
, null , null
,bizType, accountFlag,new DiscountSharingDto()); ,bizType, accountFlag,new DiscountSharingDto(), this.getNightDistributionFee(shoppingCartGoodsResponseVo.getDeliveryAmountList()));
sharingCartService.distribute(calculationSharingDiscountResult sharingCartService.distribute(calculationSharingDiscountResult
, cartGoodsList , cartGoodsList
, shoppingCartGoodsResponseVo , shoppingCartGoodsResponseVo
...@@ -1210,7 +1212,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -1210,7 +1212,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
, coupons , coupons
, shoppingCartInfoRequestVo.getSendGoods() , shoppingCartInfoRequestVo.getSendGoods()
, deliveryAmount , deliveryAmount
, shoppingCartInfoRequestVo,bizType, accountFlag,new DiscountSharingDto()); , shoppingCartInfoRequestVo,bizType, accountFlag,new DiscountSharingDto(), this.getNightDistributionFee(shoppingCartGoodsResponseVo.getDeliveryAmountList()));
// 活动校验 // 活动校验
calculationSharingValidatorService.validator(discountResult calculationSharingValidatorService.validator(discountResult
...@@ -3125,7 +3127,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -3125,7 +3127,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
, coupons //券 , coupons //券
, null //加价购商品 , null //加价购商品
, 0L , 0L
, null,bizType, accountFlag,new DiscountSharingDto()); , null,bizType, accountFlag,new DiscountSharingDto(), 0L);
premiumExchangeResponseVo = activityAdapter.convert2PremiumExchangeSharing(discountResult); premiumExchangeResponseVo = activityAdapter.convert2PremiumExchangeSharing(discountResult);
} else { } else {
...@@ -3295,7 +3297,8 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -3295,7 +3297,8 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
CouponAvailableCartInfo couponAvailableCartInfo; CouponAvailableCartInfo couponAvailableCartInfo;
List<String> orgCodes = commonService.getOrgIdsForCoupon(partnerId, storeId); List<String> orgCodes = commonService.getOrgIdsForCoupon(partnerId, storeId);
Long deliveryAmount = calculateDeliveryAmount(requestVo.getReceiveId(), partnerId, storeId, assortmentCustomerInfoVo.getWxAppId(), new ShoppingCartGoodsResponseVo(), requestVo.getOrderType()); ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo = new ShoppingCartGoodsResponseVo();
Long deliveryAmount = calculateDeliveryAmount(requestVo.getReceiveId(), partnerId, storeId, assortmentCustomerInfoVo.getWxAppId(), shoppingCartGoodsResponseVo, requestVo.getOrderType());
// 获取购物车商品 // 获取购物车商品
List<CartGoods> cartGoodsList = assortmentSdkService.getShoppingCartForCoupon(partnerId, requestVo.getStoreId(), userId, "", shoppingCartBaseService,bizType); List<CartGoods> cartGoodsList = assortmentSdkService.getShoppingCartForCoupon(partnerId, requestVo.getStoreId(), userId, "", shoppingCartBaseService,bizType);
if (grayPush(partnerId, storeId, "2")) { if (grayPush(partnerId, storeId, "2")) {
...@@ -3313,7 +3316,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -3313,7 +3316,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
, new ArrayList<>() //券 , new ArrayList<>() //券
, null //加价购商品 , null //加价购商品
, deliveryAmount , deliveryAmount
, null,bizType, accountFlag,sharingDto); , null,bizType, accountFlag,sharingDto, this.getNightDistributionFee(shoppingCartGoodsResponseVo.getDeliveryAmountList()));
couponAvailableCartInfo = activityAdapter.convert2CouponAvailableCartInfoSharing(partnerId, storeId, discountResult, orgCodes); couponAvailableCartInfo = activityAdapter.convert2CouponAvailableCartInfoSharing(partnerId, storeId, discountResult, orgCodes);
} else { } else {
...@@ -3525,4 +3528,13 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -3525,4 +3528,13 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
return fullReplace; 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();
}
} }
...@@ -3,6 +3,7 @@ package cn.freemud.service.impl.calculate; ...@@ -3,6 +3,7 @@ package cn.freemud.service.impl.calculate;
import cn.freemud.constant.ResponseCodeConstant; import cn.freemud.constant.ResponseCodeConstant;
import cn.freemud.entities.dto.CheckSpqInfoRequestDto; import cn.freemud.entities.dto.CheckSpqInfoRequestDto;
import cn.freemud.entities.dto.CheckSpqInfoResponseDto; import cn.freemud.entities.dto.CheckSpqInfoResponseDto;
import cn.freemud.entities.dto.activity.DiscountSharingDto;
import cn.freemud.entities.dto.calculate.*; import cn.freemud.entities.dto.calculate.*;
import cn.freemud.entities.dto.shoppingCart.SendPoint; import cn.freemud.entities.dto.shoppingCart.SendPoint;
import cn.freemud.entities.vo.CartGoods; import cn.freemud.entities.vo.CartGoods;
...@@ -20,7 +21,6 @@ import cn.freemud.service.active.ActiveService; ...@@ -20,7 +21,6 @@ import cn.freemud.service.active.ActiveService;
import cn.freemud.service.impl.AssortmentSdkService; import cn.freemud.service.impl.AssortmentSdkService;
import cn.freemud.service.thirdparty.ActivityClient; import cn.freemud.service.thirdparty.ActivityClient;
import cn.freemud.utils.PropertyConvertUtil; import cn.freemud.utils.PropertyConvertUtil;
import cn.freemud.entities.dto.activity.DiscountSharingDto;
import com.freemud.sdk.api.assortment.shoppingcart.constant.CommonsConstant; import com.freemud.sdk.api.assortment.shoppingcart.constant.CommonsConstant;
import com.freemud.sdk.api.assortment.shoppingcart.enums.BusinessTypeEnum; import com.freemud.sdk.api.assortment.shoppingcart.enums.BusinessTypeEnum;
import com.freemud.sdk.api.assortment.shoppingcart.service.impl.ShoppingCartBaseServiceImpl; import com.freemud.sdk.api.assortment.shoppingcart.service.impl.ShoppingCartBaseServiceImpl;
...@@ -69,14 +69,36 @@ public class CalculationSharingDiscountService { ...@@ -69,14 +69,36 @@ public class CalculationSharingDiscountService {
} }
// 新算价
/**
* 新算价
* @param menuType
* @param partnerId
* @param storeId
* @param userId
* @param appId
* @param orderType
* @param isMember
* @param cartGoodsList
* @param coupons
* @param sendGoodsList
* @param deliveryAmount
* @param shoppingCartInfoRequestVo
* @param bizType
* @param accountFlag
* @param sharingDto
* @param nightDistributionFee 是否有夜间配送费设置 不参与的需求 可以传递 0L
* @return
*/
public CalculationDiscountResult getCalculationSharingDiscountResult(String menuType public CalculationDiscountResult getCalculationSharingDiscountResult(String menuType
, String partnerId, String storeId, String userId, String appId, Integer orderType, boolean isMember , String partnerId, String storeId, String userId, String appId, Integer orderType, boolean isMember
, List<CartGoods> cartGoodsList, List<ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon> coupons , List<CartGoods> cartGoodsList, List<ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon> coupons
, List<ShoppingCartInfoRequestVo.SendGoods> sendGoodsList, Long deliveryAmount , List<ShoppingCartInfoRequestVo.SendGoods> sendGoodsList, Long deliveryAmount
, ShoppingCartInfoRequestVo shoppingCartInfoRequestVo, Integer bizType, Integer accountFlag, DiscountSharingDto sharingDto) { , ShoppingCartInfoRequestVo shoppingCartInfoRequestVo, Integer bizType, Integer accountFlag, DiscountSharingDto sharingDto, long nightDistributionFee) {
ActivityCalculationDiscountRequestDto calculationSharingDiscountRequestDto = this.commonSharingDto(partnerId, storeId, userId, appId, orderType); ActivityCalculationDiscountRequestDto calculationSharingDiscountRequestDto = this.commonSharingDto(partnerId, storeId, userId, appId, orderType);
// 是否有夜间配送费 设置
calculationSharingDiscountRequestDto.setNightDistributionFee(nightDistributionFee);
// 校验后有效的商品券map // 校验后有效的商品券map
HashMap<String, CheckSpqInfoResponseDto> validCouponMap = new HashMap<>(16); HashMap<String, CheckSpqInfoResponseDto> validCouponMap = new HashMap<>(16);
......
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