Commit b7465d0f by 姜海波

调整配送费 逻辑

parent 1ba8a361
......@@ -72,4 +72,9 @@ public class AddShoppingCartGoodsRequestVo extends BaseRequestVo{
*/
private String menuType ;
/**
* 收货地址ID、svc卡支付外卖订单必传
*/
private String receiveId;
}
......@@ -48,4 +48,9 @@ public class UpdateShoppingCartGoodsQtyRequestVo extends BaseRequestVo {
*/
private String menuType ;
/**
* 收货地址ID、svc卡支付外卖订单必传
*/
private String receiveId;
}
......@@ -218,6 +218,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
String goodsId = StringUtils.isEmpty(skuId) ? spuId : skuId;
String menuType = addShoppingCartGoodsRequestVo.getMenuType();
Integer orderType = addShoppingCartGoodsRequestVo.getOrderType();
String receiveId = addShoppingCartGoodsRequestVo.getReceiveId();
CartGoods cartGoods = ShoppingCartConvertAdapter.convent2CartGoods(addShoppingCartGoodsRequestVo);
List<Long> productIds = new ArrayList<>();
......@@ -256,9 +257,11 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
spuId, allCartGoodsList, productBeanListSpuClass);
}
Long deliveryAmount = calculateDeliveryAmount(receiveId,partnerId,storeId,userLoginInfoDto.getWxAppid());
// 获取优惠信息
ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscountResult
=getCalculationDiscountResult(menuType,partnerId,storeId,userId,appId,userLoginInfoDto.getWxAppid(),orderType,allCartGoodsList,new ArrayList(),new ArrayList<>(),null);
=getCalculationDiscountResult(menuType,partnerId,storeId,userId,appId,userLoginInfoDto.getWxAppid(),orderType,allCartGoodsList,new ArrayList(),new ArrayList<>(),null,deliveryAmount);
// 当商品数量被设为0时
......@@ -269,7 +272,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
ActivityQueryDto activityQueryDto = activityAdapter.getActivityQueryDto(partnerId, storeId, userId, appId, addShoppingCartGoodsRequestVo.getOrderType());
// 促销活动的优惠金额计算
updateShoppingCartGoodsDiscount(null, activityQueryDto, calculationDiscountResult, allCartGoodsList, shoppingCartGoodsResponseVo, null, userLoginInfoDto,addShoppingCartGoodsRequestVo.getMenuType());
updateShoppingCartGoodsDiscount(null, activityQueryDto, calculationDiscountResult, allCartGoodsList, shoppingCartGoodsResponseVo, null, userLoginInfoDto,addShoppingCartGoodsRequestVo.getMenuType(),deliveryAmount);
//设置更新响应信息
setAddAndUpdateResponse(shoppingCartGoodsResponseVo, calculationDiscountResult, allCartGoodsList, null, partnerId, storeId, userId, ShoppingCartConstant.ADD_AND_UPDATE, null);
......@@ -323,6 +326,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
Integer qty = updateShoppingCartGoodsQtyRequestVo.getQty();
String menuType = updateShoppingCartGoodsQtyRequestVo.getMenuType();
Integer orderType=updateShoppingCartGoodsQtyRequestVo.getOrderType();
String receiveId = updateShoppingCartGoodsQtyRequestVo.getReceiveId();
// 先验证商品是否存在
CartGoods cartGoods = assortmentSdkService.getCartGoodsBySdk(partnerId, userId, storeId, cartGoodsUid, "", shoppingCartBaseService);
......@@ -345,9 +349,11 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
// 重新存储最新购物车
assortmentSdkService.setShoppingCart(partnerId, storeId, userId, cartGoodsList, updateShoppingCartGoodsQtyRequestVo.getSessionId(), "", shoppingCartBaseService);
Long deliveryAmount = calculateDeliveryAmount(receiveId,partnerId,storeId,userLoginInfoDto.getWxAppid());
// 获取优惠信息
ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscountResult
=getCalculationDiscountResult(menuType,partnerId,storeId,userId,appId,userLoginInfoDto.getWxAppid(),orderType,cartGoodsList,new ArrayList(),new ArrayList<>(),null);
=getCalculationDiscountResult(menuType,partnerId,storeId,userId,appId,userLoginInfoDto.getWxAppid(),orderType,cartGoodsList,new ArrayList(),new ArrayList<>(),null,deliveryAmount);
if (calculationDiscountResult == null) {
shoppingCartGoodsResponseVo.setProducts(cartGoodsList);
// return shoppingCartGoodsResponseVo;
......@@ -356,7 +362,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
ActivityQueryDto activityQueryDto = activityAdapter.getActivityQueryDto(partnerId, storeId, userId, appId, updateShoppingCartGoodsQtyRequestVo.getOrderType());
// 促销活动的优惠金额计算
updateShoppingCartGoodsDiscount(null, activityQueryDto, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo, null, userLoginInfoDto,updateShoppingCartGoodsQtyRequestVo.getMenuType());
updateShoppingCartGoodsDiscount(null, activityQueryDto, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo, null, userLoginInfoDto,updateShoppingCartGoodsQtyRequestVo.getMenuType(),deliveryAmount);
//设置更新响应信息
setAddAndUpdateResponse(shoppingCartGoodsResponseVo, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo.getToastMsg(), partnerId, storeId, userId, ShoppingCartConstant.ADD_AND_UPDATE, null);
......@@ -422,6 +428,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
String activityCode = shoppingCartInfoRequestVo.getActivityCode();
String menuType = shoppingCartInfoRequestVo.getMenuType();
Integer orderType = shoppingCartInfoRequestVo.getOrderType();
String receiveId = shoppingCartInfoRequestVo.getReceiveId();
// 获取购物车商品
List<CartGoods> cartGoodsList = assortmentSdkService.getShoppingCart(partnerId, storeId, userId, null, "", shoppingCartBaseService);
......@@ -444,9 +451,10 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
coupon.setActivityCode(activityCode);
coupons.add(coupon);
}
Long deliveryAmount = calculateDeliveryAmount(receiveId,partnerId,storeId,userLoginInfoDto.getWxAppid());
// 获取优惠信息
ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscountResult = getCalculationDiscountResult(menuType,partnerId,storeId,userId,appId,userLoginInfoDto.getWxAppid(),orderType,cartGoodsList,coupons,null,shoppingCartInfoRequestVo.getReceiveId());
ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscountResult = getCalculationDiscountResult(menuType,partnerId,storeId,userId,appId,userLoginInfoDto.getWxAppid(),orderType,cartGoodsList,coupons,null,shoppingCartInfoRequestVo.getReceiveId(),deliveryAmount);
if (calculationDiscountResult == null) {
shoppingCartGoodsResponseVo.setProducts(cartGoodsList);
......@@ -456,7 +464,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
CouponPromotionVO couponPromotionVO = couponAdapter.getCouponPromotionVO(shoppingCartInfoRequestVo, userLoginInfoDto);
// 促销活动的优惠金额计算
this.updateShoppingCartGoodsDiscount(couponPromotionVO, activityQueryDto, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo, shoppingCartInfoRequestVo, userLoginInfoDto,shoppingCartInfoRequestVo.getMenuType());
this.updateShoppingCartGoodsDiscount(couponPromotionVO, activityQueryDto, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo, shoppingCartInfoRequestVo, userLoginInfoDto,shoppingCartInfoRequestVo.getMenuType(),deliveryAmount);
//设置更新响应信息
setAddAndUpdateResponse(shoppingCartGoodsResponseVo, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo.getToastMsg(), partnerId, storeId, userId, ShoppingCartConstant.QUERY_INFO, shoppingCartInfoRequestVo);
// 在原价、现价、折扣价上增加第一次使用会员卡的费用
......@@ -547,6 +555,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
String tableNumber = assortmentCustomerInfoVo.getTableNumber();
String menuType = shoppingCartInfoRequestVo.getMenuType();
Integer orderType = shoppingCartInfoRequestVo.getOrderType();
String receiveId = shoppingCartInfoRequestVo.getReceiveId();
List<ShoppingCartInfoRequestVo.SendGoods> sendGoodsList = shoppingCartInfoRequestVo.getSendGoods();
......@@ -607,8 +616,10 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
shoppingCartInfoRequestVo.setSendGoods(sendGoods);
}
}
Long deliveryAmount = calculateDeliveryAmount(receiveId,partnerId,storeId,userLoginInfoDto.getWxAppid());
// 获取优惠信息
ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscountResult = getCalculationDiscountResult(menuType,partnerId,storeId,userId,appId,userLoginInfoDto.getWxAppid(),orderType,cartGoodsList,coupons,sendGoodsList,shoppingCartInfoRequestVo.getReceiveId());
ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscountResult = getCalculationDiscountResult(menuType,partnerId,storeId,userId,appId,userLoginInfoDto.getWxAppid(),orderType,cartGoodsList,coupons,sendGoodsList,shoppingCartInfoRequestVo.getReceiveId(),deliveryAmount);
ActivityQueryDto activityQueryDto = activityAdapter.getActivityQueryDto(partnerId, storeId, userId, appId, shoppingCartInfoRequestVo.getOrderType());
......@@ -616,7 +627,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
//临时方案
packgeAdditional(shoppingCartInfoRequestVo, premiumExchangeActivity);
// 促销活动的优惠金额计算
updateShoppingCartGoodsDiscount(couponPromotionVO, activityQueryDto, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo, shoppingCartInfoRequestVo, userLoginInfoDto,shoppingCartInfoRequestVo.getMenuType());
updateShoppingCartGoodsDiscount(couponPromotionVO, activityQueryDto, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo, shoppingCartInfoRequestVo, userLoginInfoDto,shoppingCartInfoRequestVo.getMenuType(),deliveryAmount);
//设置更新响应信息
setAddAndUpdateResponse(shoppingCartGoodsResponseVo, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo.getToastMsg(), partnerId, storeId, userId, ShoppingCartConstant.QUERY_INFO, shoppingCartInfoRequestVo);
......@@ -915,7 +926,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
* @param cartGoodsList
* @param shoppingCartGoodsResponseVo
*/
private void updateShoppingCartGoodsDiscount(CouponPromotionVO couponPromotionVO, ActivityQueryDto activityQueryDto, ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscountResult, List<CartGoods> cartGoodsList, ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo, ShoppingCartInfoRequestVo shoppingCartInfoRequestVo, UserLoginInfoDto userLoginInfoDto,String menuType) {
private void updateShoppingCartGoodsDiscount(CouponPromotionVO couponPromotionVO, ActivityQueryDto activityQueryDto, ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscountResult, List<CartGoods> cartGoodsList, ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo, ShoppingCartInfoRequestVo shoppingCartInfoRequestVo, UserLoginInfoDto userLoginInfoDto,String menuType,Long deliveryAmount) {
//默认计算优惠
DefaultPromotionService defaultPromotionService = (DefaultPromotionService) PromotionFactory.getPromotionService(ShoppingCartPromotionEnum.DEFAULT_PROMOTION);
defaultPromotionService.updateShoppingCartGoodsDiscount(couponPromotionVO, activityQueryDto, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo, userLoginInfoDto, shoppingCartInfoRequestVo);
......@@ -1023,9 +1034,9 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
}
} else {
String desc = DELIVERY_DISCOUNT_DESC3;
shoppingCartGoodsResponseVo.setDeliveryDiscountDesc(String.format(desc, calculationDiscountResult.getDeliveryAmount() / 100));
shoppingCartGoodsResponseVo.setDeliveryAmount(calculationDiscountResult.getDeliveryAmount());
shoppingCartGoodsResponseVo.setDiscountDeliveryAmount(calculationDiscountResult.getDeliveryAmount());
shoppingCartGoodsResponseVo.setDeliveryDiscountDesc(String.format(desc, deliveryAmount / 100));
shoppingCartGoodsResponseVo.setDeliveryAmount(deliveryAmount);
shoppingCartGoodsResponseVo.setDiscountDeliveryAmount(deliveryAmount);
shoppingCartGoodsResponseVo.setIsDiscountDelivery(false);
}
}
......@@ -1436,12 +1447,21 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
private ActivityCalculationDiscountResponseDto.CalculationDiscountResult getCalculationDiscountResult(String menuType
,String partnerId,String storeId,String userId,String appId,String wxappid,Integer orderType
,List<CartGoods> cartGoodsList,List<ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon> coupons
,List<ShoppingCartInfoRequestVo.SendGoods> sendGoodsList,String receiveId){
,List<ShoppingCartInfoRequestVo.SendGoods> sendGoodsList,String receiveId,Long deliveryAmount){
// 获取优惠信息
ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscountResult=null;
//外卖场景下 查询门店配送信息
if(BusinessTypeEnum.SAAS_DELIVERY.getCode().equals(menuType)){
calculationDiscountResult = this.getActivityCalculationDiscountResponse(partnerId, storeId, userId, appId, orderType, cartGoodsList, coupons, sendGoodsList,BusinessTypeEnum.getByType(menuType).getCode(),deliveryAmount);
}else{
calculationDiscountResult = this.getActivityCalculationDiscountResponse(partnerId, storeId, userId, appId, orderType, cartGoodsList, coupons, sendGoodsList,BusinessTypeEnum.getByType(menuType).getCode(),null);
}
return calculationDiscountResult;
}
private Long calculateDeliveryAmount(String receiveId,String partnerId,String storeId,String wxappid){
Long deliveryAmount=0l;
if(receiveId==null) {
//TODO 查询门店信息
......@@ -1453,13 +1473,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
}else{
deliveryAmount = Long.parseLong(getDeliveryAmount(receiveId,partnerId,storeId).toString());
}
calculationDiscountResult = this.getActivityCalculationDiscountResponse(partnerId, storeId, userId, appId, orderType, cartGoodsList, coupons, sendGoodsList,BusinessTypeEnum.getByType(menuType).getCode(),deliveryAmount);
}else{
calculationDiscountResult = this.getActivityCalculationDiscountResponse(partnerId, storeId, userId, appId, orderType, cartGoodsList, coupons, sendGoodsList,BusinessTypeEnum.getByType(menuType).getCode(),null);
}
return calculationDiscountResult;
return deliveryAmount;
}
}
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