Commit 0c207dca by 周晓航

Merge branch 'feature_夜间配送ID1040499_zxh20211208'

# Conflicts:
#	shopping-cart-application-service/src/main/java/cn/freemud/service/delivery/impl/GradDeliveryServiceImpl.java
#	shopping-cart-application-service/src/main/java/cn/freemud/service/impl/ShoppingCartNewServiceImpl.java
parents 8866fd31 73d78e90
package cn.freemud.entities;
import lombok.Data;
/**
* @author : xh.Z
* @email : fisherman0510@163.com
* @Date : 2021/12/8 下午5:08
* @description :
*/
@Data
public class ExtraDeliveryDto {
/**
* 原有配送费类型
*/
public static int TYPE_DEFAULT = -1;
/**
* 晚间时段 附加配送费类型
*/
public static int TYPE_EXTRA_NIGHT = 1;
/**
* 早间时段 附加配送费类型
*/
public static int TYPE_EXTRA_MORNING = 0;
/**
* 费用类型
*/
private int type;
/**
* 费用
*/
private Long deliveryAmount;
private ExtraDeliveryDto() {
}
public ExtraDeliveryDto(int type, Long deliveryAmount) {
this.type = type;
this.deliveryAmount = deliveryAmount;
}
}
......@@ -76,6 +76,11 @@ public class ActivityCalculationDiscountRequestDto {
private Long distributionFee;
/**
* 是否有夜间配送费, 白天配送费 综合, 该字段依据门店是否设置 为依据
*/
private Long nightDistributionFee = 0L;
/**
* 购买月卡费用(分)
*/
private Long payCardFee;
......
......@@ -82,6 +82,11 @@ public class CalculationDiscountResult {
*/
private Long distributionFee;
/**
* 优惠后 夜间配送费
*/
private Long nightDistributionFee = 0L;
//积分商品活动购物车商品所需总积分")
private Integer totalScore;
......
......@@ -71,4 +71,17 @@ public class DeliveryInfoDTO {
*/
private Integer scopeConfig;
/**
* 门店计算好的 最终配送费价格, 包含阶梯算价之后 (单位分)
*/
private Integer finalDeliveryAmount;
/**
* 额外拓展属性 json
* @see cn.freemud.entities.dto.console.DeliveryInfoExpandFieldDTO
*/
private DeliveryInfoExpandFieldDTO expandFields;
}
package cn.freemud.entities.dto.console;
import lombok.Data;
import java.util.List;
/**
* @author : xh.Z
* @email : fisherman0510@163.com
* @Date : 2021/12/10 上午11:04
* @description :
*/
@Data
public class DeliveryInfoExpandFieldDTO {
/**
* 夜间 早间 额外配送费配置
*/
private List<NightDeliveryuInfo> nightDeliveryInfo;
}
package cn.freemud.entities.dto.console;
import lombok.Data;
/**
* @author : xh.Z
* @email : fisherman0510@163.com
* @Date : 2021/12/10 上午11:05
* @description :
*/
@Data
public class NightDeliveryuInfo {
public static int COMMON_STATUS_CLOSE = 0;
public static int COMMON_STATUS_OPEN = 1;
/**
* 类型 0早间 1晚间
*/
private int type;
/**
* 开始时间
*/
private String startTime;
/**
* 结束时间
*/
private String endTime;
/**
* 是否开启 1开启 0关闭
*/
private int status;
/**
* 加的价格
*/
private Long price;
}
package cn.freemud.entities.vo;
import cn.freemud.entities.ExtraDeliveryDto;
import lombok.Data;
import java.util.List;
import java.util.Objects;
/**
* @author : xh.Z
* @email : fisherman0510@163.com
* @Date : 2021/12/8 下午5:03
* @description :
*/
@Data
public class DeliveryDto {
/**
* 总配送费
*/
public Long deliveryAmount;
/**
* 配送费为零的原因:0:正常,1:超出配送范围
*/
public Integer deliveryFeeZeroReason;
/**
* 附加配送费详细数据 上面的金额 已经加上 这里的金额了
*/
public List<ExtraDeliveryDto> deliveryAmountList;
private DeliveryDto() {
}
public DeliveryDto(Long deliveryAmount, Integer deliveryFeeZeroReason, List<ExtraDeliveryDto> deliveryAmountList) {
this.deliveryAmount = deliveryAmount;
this.deliveryFeeZeroReason = deliveryFeeZeroReason;
Objects.requireNonNull(deliveryAmountList);
this.deliveryAmountList = deliveryAmountList;
}
}
......@@ -12,16 +12,22 @@
*/
package cn.freemud.entities.vo;
import cn.freemud.entities.ExtraDeliveryDto;
import cn.freemud.entities.dto.calculate.Discount;
import cn.freemud.entities.dto.calculate.Goods;
import com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoodsStates;
import lombok.Builder;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
@Data
public class ShoppingCartGoodsResponseVo extends ShoppingCartGoodsBaseResponseVo{
/**
* 配送费的清单 包含 普通配送费 额外夜间配送费 额外白天配送费 下面的 deliveryAmount 是总的配送费
*/
List<ExtraDeliveryDto> deliveryAmountList = new ArrayList<>();
/**
* 商品额外的属性
......
......@@ -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,8 @@ 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) {
deliveryAmount = Objects.isNull(deliveryAmount) ? 0L : deliveryAmount;
//默认计算优惠
DefaultPromotionService defaultPromotionService = (DefaultPromotionService) PromotionFactory.getPromotionService(ShoppingCartPromotionEnum.DEFAULT_PROMOTION);
defaultPromotionService.updateShoppingCartGoodsDiscount(couponPromotionVO, activityQueryDto, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo, userLoginInfoDto, shoppingCartInfoRequestVo);
......@@ -476,7 +477,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){
......@@ -487,15 +489,15 @@ public abstract class AbstractShoppingCartImpl 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);
} else {
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.setIsDiscountDelivery(false);
}
}
......
......@@ -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();
}
}
......@@ -13,12 +13,27 @@
package cn.freemud.service.delivery;
import cn.freemud.base.util.DateUtil;
import cn.freemud.entities.ExtraDeliveryDto;
import cn.freemud.entities.dto.console.DeliveryInfoExpandFieldDTO;
import cn.freemud.entities.dto.console.NightDeliveryuInfo;
import cn.freemud.entities.vo.ShoppingCartGoodsResponseVo;
import cn.freemud.utils.DateTimeUtil;
import lombok.SneakyThrows;
import org.apache.commons.collections4.CollectionUtils;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;
public interface DeliveryService {
/**
* 计算运费
*
* @param receiveId
* @param partnerId
* @param storeId
......@@ -28,4 +43,43 @@ public interface DeliveryService {
Long calculateDeliveryAmount(String receiveId, String partnerId, String storeId, ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo);
Long calculateDeliveryAmount(String receiveId, String partnerId, String storeId);
/**
* 处理 额外配送费逻辑
*
* @param amount 原始配送费价格
* @param expandFields 门店反馈的额外配送费配置
*/
@SneakyThrows
default List<ExtraDeliveryDto> nightDeliveryAmountHandle(long amount, DeliveryInfoExpandFieldDTO expandFields) {
List<ExtraDeliveryDto> list = new ArrayList<>();
if (amount > 0) {
ExtraDeliveryDto defaultAmount = new ExtraDeliveryDto(ExtraDeliveryDto.TYPE_DEFAULT, amount);
list.add(defaultAmount);
}
if (Objects.nonNull(expandFields) && CollectionUtils.isNotEmpty(expandFields.getNightDeliveryInfo())) {
for (NightDeliveryuInfo info : expandFields.getNightDeliveryInfo()) {
if (info.getStatus() == NightDeliveryuInfo.COMMON_STATUS_OPEN) {
// 当前时间在区间内
try {
Date nowTime = new SimpleDateFormat(DateUtil.FORMAT_time).parse(DateTimeUtil.getCurrentTimeStr());
Date startTime = new SimpleDateFormat(DateUtil.FORMAT_time).parse(info.getStartTime());
Date endTime = new SimpleDateFormat(DateUtil.FORMAT_time).parse(info.getEndTime());
if (DateTimeUtil.isEffectiveDate(nowTime, startTime, endTime)) {
ExtraDeliveryDto extraDeliveryDto = new ExtraDeliveryDto(info.getType(), info.getPrice());
list.add(extraDeliveryDto);
// 金额 增加, 原来配送费金额不变
// amount += info.getPrice();
}
} catch (ParseException e) {
// 报错表示 时间格式设置错误, 默认当做不计算
e.printStackTrace();
}
}
}
}
return list;
}
}
......@@ -13,24 +13,21 @@
package cn.freemud.service.delivery.impl;
import cn.freemud.entities.ExtraDeliveryDto;
import cn.freemud.entities.dto.console.*;
import cn.freemud.entities.vo.ShoppingCartGoodsResponseVo;
import cn.freemud.enums.CreateOrderType;
import cn.freemud.enums.ResponseResult;
import cn.freemud.interceptor.ServiceException;
import cn.freemud.service.delivery.DeliveryService;
import cn.freemud.utils.ResponseUtil;
import cn.freemud.service.thirdparty.ConsoleApiClient;
import com.freemud.application.sdk.api.log.LogThreadLocal;
import com.freemud.application.sdk.api.membercenter.request.QueryReceiveAddressRequest;
import com.freemud.application.sdk.api.membercenter.response.QueryReceiveAddressResponse;
import com.freemud.application.sdk.api.storecenter.request.QueryDeliveryRequest;
import com.freemud.application.sdk.api.storecenter.request.StoreInfoRequest;
import com.freemud.application.sdk.api.storecenter.response.QueryDeliverDetailResponse;
import com.freemud.application.sdk.api.storecenter.response.StoreResponse;
import com.freemud.application.sdk.api.storecenter.service.StoreCenterService;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Objects;
@Service("fixDeliveryService")
......@@ -39,20 +36,28 @@ public class FixDeliveryServiceImpl extends AbstractDeliveryServiceImpl implemen
@Autowired
private StoreCenterService storeCenterService;
@Autowired
private ConsoleApiClient consoleApiClient;
@Override
public Long calculateDeliveryAmount(String receiveId, String partnerId, String storeId, ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo) {
String trackingNo = LogThreadLocal.getTrackingNo();
// 获取门店信息,查询基础配送费用
StoreInfoRequest storeInfoRequest = new StoreInfoRequest(partnerId, storeId,null);
StoreResponse storeResponse = storeCenterService.getStoreInfo(storeInfoRequest, trackingNo);
if (storeResponse == null || storeResponse.getBizVO() == null) {
throw new ServiceException (ResponseResult.STORE_NOT_FOUND);
// 获取门店信息,查询基础配送费用 移除sdk使用, 使用feign
GetStoreMixRequest query = GetStoreMixRequest.builder()
.partnerId(partnerId)
.storeCode(storeId)
.query(QueryFlag.builder().queryDeliveryInfo(true).build())
.build();
ConsoleResponseDTO<BizDTO> responseDto = consoleApiClient.getStoreMix(query);
DeliveryInfoDTO deliveryInfo = responseDto.getBizVO().getDeliveryInfo();
// fisherman 处理 额外配送费
long amount = Objects.isNull(deliveryInfo.getFinalDeliveryAmount()) ? 0L : deliveryInfo.getFinalDeliveryAmount();
List<ExtraDeliveryDto> deliveryAmountList = super.nightDeliveryAmountHandle(amount, deliveryInfo.getExpandFields());
if (Objects.nonNull(shoppingCartGoodsResponseVo)) {
shoppingCartGoodsResponseVo.setDeliveryFeeZeroReason(0);
shoppingCartGoodsResponseVo.setDeliveryAmountList(deliveryAmountList);
}
shoppingCartGoodsResponseVo.setDeliveryFeeZeroReason(0);
return new Double(storeResponse.getBizVO().getDeliveryPrice() * 100).longValue();
return amount;
}
@Override
......
......@@ -13,7 +13,9 @@
package cn.freemud.service.delivery.impl;
import cn.freemud.entities.ExtraDeliveryDto;
import cn.freemud.entities.dto.console.*;
import cn.freemud.entities.vo.DeliveryDto;
import cn.freemud.entities.vo.QueryDeliveryDistanceRequest;
import cn.freemud.entities.vo.QueryDeliveryDistanceResponseVo;
import cn.freemud.entities.vo.ShoppingCartGoodsResponseVo;
......@@ -32,6 +34,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@Service("gradDeliveryService")
......@@ -58,8 +62,13 @@ public class GradDeliveryServiceImpl extends AbstractDeliveryServiceImpl impleme
queryReceiveAddressResponse.getData().getLongitude(),
partnerId,
storeId);
if (null != shoppingCartGoodsResponseVo) shoppingCartGoodsResponseVo.setDeliveryFeeZeroReason(deliveryDataMsg.deliveryFeeZeroReason);
return deliveryDataMsg.deliveryAmount;
if (Objects.nonNull(shoppingCartGoodsResponseVo)) {
shoppingCartGoodsResponseVo.setDeliveryFeeZeroReason(deliveryDataMsg.getDeliveryFeeZeroReason());
List<ExtraDeliveryDto> deliveryAmountList = deliveryDataMsg.getDeliveryAmountList();
shoppingCartGoodsResponseVo.setDeliveryAmountList(deliveryAmountList);
}
return deliveryDataMsg.getDeliveryAmount();
}
@Override
......@@ -68,21 +77,6 @@ public class GradDeliveryServiceImpl extends AbstractDeliveryServiceImpl impleme
}
class DeliveryDto {
/**
* 配送费
*/
Long deliveryAmount;
/**
* 配送费为零的原因:0:正常,1:超出配送范围
*/
Integer deliveryFeeZeroReason;
DeliveryDto(Long amount, Integer reason) {
deliveryAmount = amount;
deliveryFeeZeroReason = reason;
}
}
/**
* 获取 配送费 及预计送达时间接口
* @param userLat 用户纬度
......@@ -122,9 +116,12 @@ public class GradDeliveryServiceImpl extends AbstractDeliveryServiceImpl impleme
}
Long amount = calcDeliveryAmount(storeInfo, deliveryInfo, userLong, userLat);
if (amount < 0) {
return new DeliveryDto(0L, 1);
return new DeliveryDto(0L, 1, new ArrayList<>());
} else {
return new DeliveryDto(amount, 0);
// 标准配送费
// fisherman 处理 额外配送费
List<ExtraDeliveryDto> list = super.nightDeliveryAmountHandle(amount, deliveryInfo.getExpandFields());
return new DeliveryDto(amount, 0, list);
}
}
......@@ -202,7 +199,7 @@ public class GradDeliveryServiceImpl extends AbstractDeliveryServiceImpl impleme
if (new BigDecimal(riderDistance).compareTo(new BigDecimal(defaultDeliveryRange)) <= 0) {
return deliveryAmount;
} else {
//计算实际配送费
//计算实际配送费 (总距离-基础配送距离)/每公里增加基数*每公里配送加钱 + 基础配送费
BigDecimal extraAmount = (new BigDecimal(riderDistance).subtract(new BigDecimal(defaultDeliveryRange)))
.divide(new BigDecimal(addRangeCount), 0, BigDecimal.ROUND_UP)
.multiply(new BigDecimal(addRangeAmount));
......
......@@ -37,7 +37,10 @@ import cn.freemud.interceptor.ServiceException;
import cn.freemud.service.BuriedPointService;
import cn.freemud.service.ItemService;
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.ShoppingCartRelationService;
import cn.freemud.service.thirdparty.CustomerApplicationClient;
......@@ -63,7 +66,6 @@ import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang.ObjectUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.*;
......@@ -193,8 +195,8 @@ public class ShoppingCartMallServiceImpl implements ShoppingCartNewService {
ActivityQueryDto activityQueryDto = activityAdapter.getActivityQueryDto(partnerId, storeId, userId, appId, addShoppingCartGoodsRequestVo.getOrderType());
CalculationDiscountResult discountResult = null;
discountResult = sharingDiscountService.getCalculationSharingDiscountResult(menuType, partnerId, storeId, userId, appId, orderType, assortmentCustomerInfoVo.isMemberPaid(), allCartGoodsList, new ArrayList<>(), null, deliveryAmount, null,null, accountType,new DiscountSharingDto());
sharingCartService.distribute(discountResult, allCartGoodsList, shoppingCartGoodsResponseVo, null, null, null, activityQueryDto, menuType, deliveryAmount, ShoppingCartConstant.ADD_AND_UPDATE, partnerId, null, userId, storeId);
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,0L);
buildShoppingCartGoodsResponse(shoppingCartGoodsResponseVo,discountResult,null,partnerId);
......@@ -288,7 +290,7 @@ public class ShoppingCartMallServiceImpl implements ShoppingCartNewService {
, new ArrayList() //券
, null //加价购商品
, deliveryAmount
, null,null, accountFlag,new DiscountSharingDto());
, null,null, accountFlag,new DiscountSharingDto(),0L);
sharingCartService.distribute(discountResult
, cartGoodsList
......@@ -303,7 +305,7 @@ public class ShoppingCartMallServiceImpl implements ShoppingCartNewService {
, partnerId
, null
, userId
, storeId);
, storeId,0L);
buildShoppingCartGoodsResponse(shoppingCartGoodsResponseVo,discountResult,null,partnerId);
......@@ -447,7 +449,7 @@ public class ShoppingCartMallServiceImpl implements ShoppingCartNewService {
, coupons
, sendGoods
, deliveryAmount
, null,null, accountFlag,new DiscountSharingDto());
, null,null, accountFlag,new DiscountSharingDto(),0L);
sharingCartService.distribute(calculationSharingDiscountResult
, cartGoodsList
, shoppingCartGoodsResponseVo
......@@ -461,7 +463,7 @@ public class ShoppingCartMallServiceImpl implements ShoppingCartNewService {
, partnerId
,shoppingCartInfoRequestVo.getFlag()
, userId
, storeId);
, storeId,0L);
buildShoppingCartGoodsResponse(shoppingCartGoodsResponseVo,calculationSharingDiscountResult,shoppingCartInfoRequestVo.getFlag(),partnerId);
......@@ -605,7 +607,7 @@ public class ShoppingCartMallServiceImpl implements ShoppingCartNewService {
, coupons
, shoppingCartInfoRequestVo.getSendGoods()
, deliveryAmount
, shoppingCartInfoRequestVo,null, accountFlag,new DiscountSharingDto());
, shoppingCartInfoRequestVo,null, accountFlag,new DiscountSharingDto(), 0L);
// 活动校验
calculationSharingValidatorService.validator(discountResult
......@@ -630,7 +632,7 @@ public class ShoppingCartMallServiceImpl implements ShoppingCartNewService {
, menuType
, deliveryAmount
, shoppingCartGoodsDto
, premiumExchangeActivity);
, premiumExchangeActivity,0L);
return ResponseUtil.success(shoppingCartGoodsDto);
}
......@@ -638,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 {
......
......@@ -68,7 +68,7 @@ public class CalculationSharingCartService {
, String partnerId
, Integer flag
, String userId
, String storeId) {
, String storeId, long nightDistributionFee) {
/**
* 用促销价格初始化购物车行记录成交价
......@@ -106,7 +106,7 @@ public class CalculationSharingCartService {
*/
scoreSharingService.scoreResponse(discountResult, shoppingCartGoodsResponseVo, userLoginInfoDto, shoppingCartInfoRequestVo);
if(BusinessTypeEnum.SAAS_DELIVERY.getCode().equals(menuType)){
deliverySharingService.deliveryResponse(discountResult, activityQueryDto, shoppingCartGoodsResponseVo, deliveryAmount);
deliverySharingService.deliveryResponse(discountResult, activityQueryDto, shoppingCartGoodsResponseVo, deliveryAmount, nightDistributionFee);
}
......
......@@ -3,6 +3,7 @@ package cn.freemud.service.impl.calculate;
import cn.freemud.constant.ResponseCodeConstant;
import cn.freemud.entities.dto.CheckSpqInfoRequestDto;
import cn.freemud.entities.dto.CheckSpqInfoResponseDto;
import cn.freemud.entities.dto.activity.DiscountSharingDto;
import cn.freemud.entities.dto.calculate.*;
import cn.freemud.entities.dto.shoppingCart.SendPoint;
import cn.freemud.entities.vo.CartGoods;
......@@ -20,7 +21,6 @@ import cn.freemud.service.active.ActiveService;
import cn.freemud.service.impl.AssortmentSdkService;
import cn.freemud.service.thirdparty.ActivityClient;
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.enums.BusinessTypeEnum;
import com.freemud.sdk.api.assortment.shoppingcart.service.impl.ShoppingCartBaseServiceImpl;
......@@ -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
, String partnerId, String storeId, String userId, String appId, Integer orderType, boolean isMember
, List<CartGoods> cartGoodsList, List<ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon> coupons
, List<ShoppingCartInfoRequestVo.SendGoods> sendGoodsList, Long deliveryAmount
, ShoppingCartInfoRequestVo shoppingCartInfoRequestVo, Integer bizType, Integer accountFlag, DiscountSharingDto sharingDto) {
, ShoppingCartInfoRequestVo shoppingCartInfoRequestVo, Integer bizType, Integer accountFlag, DiscountSharingDto sharingDto, long nightDistributionFee) {
deliveryAmount = Objects.isNull(deliveryAmount) ? 0L : deliveryAmount;
ActivityCalculationDiscountRequestDto calculationSharingDiscountRequestDto = this.commonSharingDto(partnerId, storeId, userId, appId, orderType);
// 是否有夜间配送费 设置
calculationSharingDiscountRequestDto.setNightDistributionFee(nightDistributionFee);
// 校验后有效的商品券map
HashMap<String, CheckSpqInfoResponseDto> validCouponMap = new HashMap<>(16);
......@@ -229,8 +251,8 @@ public class CalculationSharingDiscountService {
result.setValidCouponMap(validCouponMap);
result.setSpqIdToCartUuid(spqIdToCartUuid);
// fisherman 这里传递过来的 配送费 是否要计算一下 配送券的逻辑
result.setDeliveryAmount(deliveryAmount);
result.setDistributionFee(result.getDistributionFee());
result.setDeliveryAmount(deliveryAmount + nightDistributionFee);
result.setDistributionFee(result.getDistributionFee() + result.getNightDistributionFee());
return result;
}
......
......@@ -77,7 +77,7 @@ public class CalculationSharingEquallyService {
, String menuType
, Long deliveryAmount
, ShoppingCartGoodsDto shoppingCartGoodsDto
, CreateOrderVo.PremiumExchangeActivity premiumExchangeActivity) {
, CreateOrderVo.PremiumExchangeActivity premiumExchangeActivity, long nightDistributionFee) {
calculationCommonService.initShoppingCart(discountResult,
cartGoodsList,
......@@ -148,7 +148,7 @@ public class CalculationSharingEquallyService {
calculationCommonService.getNeedCardAmount(shoppingCartInfoRequestVo, shoppingCartGoodsDto);
if(BusinessTypeEnum.SAAS_DELIVERY.getCode().equals(menuType)){
deliverySharingService.deliveryResponse(discountResult, activityQueryDto, shoppingCartGoodsResponseVo, deliveryAmount);
deliverySharingService.deliveryResponse(discountResult, activityQueryDto, shoppingCartGoodsResponseVo, deliveryAmount, nightDistributionFee);
}
calculationCommonService.setAddAndUpdateResponse(cartGoodsList, shoppingCartGoodsResponseVo, shoppingCartInfoRequestVo, ShoppingCartConstant.QUERY_INFO);
......
......@@ -47,7 +47,7 @@ public class DeliverySharingService {
public void deliveryResponse(CalculationDiscountResult discountResult
, ActivityQueryDto activityQueryDto
, ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo
, Long deliveryAmount) {
, Long deliveryAmount, long nightDistributionFee) {
DecimalFormat df = new DecimalFormat("###.##");
List<ActivityTypeEnum> activityTypeEnums = new LinkedList<>();
......@@ -90,6 +90,7 @@ public class DeliverySharingService {
shoppingCartGoodsResponseVo.setIsDiscountDelivery(true);
}
else {
Long deliverAmountNew = deliveryAmount + nightDistributionFee;
if (activityResponse!=null) {
// 这里表示有活动, 但是没有参加上
if(beanDto.getBenefitType() == 1) {
......@@ -101,8 +102,8 @@ public class DeliverySharingService {
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(discountResult);
......@@ -115,9 +116,9 @@ public class DeliverySharingService {
} else {
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.setIsDiscountDelivery(false);
// fisherman 确认是否 使用了优惠券
boolean isType34 = verifyActivity(discountResult);
......
......@@ -6,6 +6,7 @@ import java.time.format.DateTimeParseException;
import java.time.temporal.ChronoUnit;
import java.time.temporal.Temporal;
import java.time.temporal.TemporalAdjusters;
import java.util.Calendar;
import java.util.Date;
/**
......@@ -281,4 +282,32 @@ public class DateTimeUtil {
return getCurrentLocalDate().plus(2, ChronoUnit.DECADES).format(DATE_FORMATTER);
}
/**
* 是否在这个时间范围内
* @param nowTime
* @param startTime
* @param endTime
* @return
*/
public static boolean isEffectiveDate(Date nowTime, Date startTime, Date endTime) {
if (nowTime.getTime() == startTime.getTime()
|| nowTime.getTime() == endTime.getTime()) {
return true;
}
Calendar date = Calendar.getInstance();
date.setTime(nowTime);
Calendar begin = Calendar.getInstance();
begin.setTime(startTime);
Calendar end = Calendar.getInstance();
end.setTime(endTime);
if (date.after(begin) && date.before(end)) {
return true;
} else {
return false;
}
}
}
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