Commit a32b9aac by 姜海波

Merge remote-tracking branch 'remotes/origin/feature-2020/2/10-1.9.15-免配送费二期-海波' into develop

# Conflicts:
#	order-application-service/src/main/java/cn/freemud/adapter/OrderAdapter.java
#	order-application-service/src/main/java/cn/freemud/entities/vo/ShoppingCartInfoRequestVo.java
#	order-management/order-management.iml
#	shopping-cart-application-service/src/main/java/cn/freemud/service/impl/ShoppingCartNewServiceImpl.java
parents 4afe8621 cfb77202
......@@ -119,7 +119,6 @@ public class OrderAdapter {
public BaseCreateOrderRequest convent2CreateOrderDto(CreateOrderVo createOrderVo, ShoppingCartGoodsDto shoppingCartGoodsDto,StoreResponse.BizVO storeResponseDto) {
UserDeliveryInfoDto deliveryInfoDto = createOrderVo.getUserDeliveryInfoDto();
BaseCreateOrderRequest createOrderDto = getCreateOrderDto(createOrderVo);
ArrayList<CreateOrderAccountRequest> orderAccountDtos = new ArrayList<>();
OrderTaskReq orderTask = null;
if(StringUtils.isNotEmpty(createOrderVo.getTakeMealTime())){
Integer orderType = 0;
......@@ -132,20 +131,14 @@ public class OrderAdapter {
if(orderTask != null){
createOrderDto.setOrderTask(orderTask);
}
ArrayList<CreateOrderAccountRequest> orderAccountDtos = new ArrayList<>();
long deliveryAmount = 0;
long discountDeliveryAmount = 0;
if (deliveryInfoDto != null) {
deliveryAmount = getUserRealDeliveryAmount(deliveryInfoDto.getStoreDeliveryInfoDto(), deliveryInfoDto.getUserLongitude(), deliveryInfoDto.getUserLatitude());
deliveryAmount = shoppingCartGoodsDto.getDeliveryAmount();
discountDeliveryAmount = shoppingCartGoodsDto.getDeliveryAmount();
if(shoppingCartGoodsDto.getIsDiscountDelivery() && deliveryAmount>shoppingCartGoodsDto.getDiscountDeliveryAmount()){
discountDeliveryAmount = shoppingCartGoodsDto.getDiscountDeliveryAmount();
CreateOrderAccountRequest createOrderAccountDto = CreateOrderAccountRequest.builder()
.name(OldOrderAccountType.FULL_DISTRIBUTION_FEE.getDesc())
.price(deliveryAmount-discountDeliveryAmount)
.accountType(QueryOrderAccountType.FULL_DISTRIBUTION_FEE)
.build();
orderAccountDtos.add(createOrderAccountDto);
}
}
Long packageAmount = shoppingCartGoodsDto.getPackageAmount() == null ? 0L : shoppingCartGoodsDto.getPackageAmount();
......@@ -604,18 +597,10 @@ public class OrderAdapter {
long deliveryAmount = 0;
long discountDeliveryAmount = 0;
if (userDeliveryInfoDto != null) {
deliveryAmount = getUserRealDeliveryAmount(userDeliveryInfoDto.getStoreDeliveryInfoDto(), userDeliveryInfoDto.getUserLongitude(), userDeliveryInfoDto.getUserLatitude());
deliveryAmount = shoppingCartGoodsDto.getDeliveryAmount();
discountDeliveryAmount = shoppingCartGoodsDto.getDeliveryAmount();
if(shoppingCartGoodsDto.getIsDiscountDelivery() && deliveryAmount>shoppingCartGoodsDto.getDiscountDeliveryAmount()){
discountDeliveryAmount = shoppingCartGoodsDto.getDiscountDeliveryAmount();
CreateOrderAccountRequest createOrderAccountDto = CreateOrderAccountRequest.builder()
.name(OldOrderAccountType.FULL_DISTRIBUTION_FEE.getDesc())
.price(deliveryAmount-discountDeliveryAmount)
.accountType(QueryOrderAccountType.FULL_DISTRIBUTION_FEE)
.build();
orderAccountDtos.add(createOrderAccountDto);
}
}
......
......@@ -89,6 +89,12 @@ public class ShoppingCartGoodsDto {
@Builder.Default
private Boolean isDiscountDelivery = false;
/**
* 配送费活动号
*
*/
private String discountDeliveryActivityCode;
@Data
public static class CartGoodsDetailDto {
/**
......
......@@ -94,6 +94,8 @@ public class ShoppingCartInfoRequestVo {
private String menuType;
private String receiveId;
@Data
public final static class SendGoods {
/**
......
......@@ -17,6 +17,7 @@ public enum ActivityTypeEnum {
TYPE_11(11, "每满减"),
TYPE_12(12, "阶梯满减"),
TYPE_13(13, "新用户立减"),
TYPE_14(14, "满减配送费"),
TYPE_104(104,"x件y折"),
/**
* 限时特价
......
......@@ -317,6 +317,7 @@ public class CheckOrder {
.orderType(createOrderVo.getOrderType())
.reachStoreType(createOrderVo.getReachStoreType())
.flag(CouponFlag.NO.getCode())
.receiveId(createOrderVo.getReceiveId())
.useCustomerScore(createOrderVo.getUseCustomerScore())
.buyMemberCard(buyMemberCard)
.menuType(createOrderVo.getMenuType())
......
......@@ -20,10 +20,6 @@
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="PROVIDED" name="Maven: cn.freemud:assortment-ordercenter-sdk:1.1.5.RELEASE" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: cn.freemud:ordercenter-sdk:1.1.2.RELEASE" level="project" />
<orderEntry type="library" name="Maven: com.freemud.application.service.sdk:takeawaycenter-sdk:1.2.3-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.freemud.sdk.api.assortment:assortment-messagepush-sdk:2.6.3.RELEASE" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.freemud.application.service.sdk:deliverycenter-sdk:1.5.RELEASE" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-starter-test:1.5.3.RELEASE" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-test:1.5.3.RELEASE" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-test-autoconfigure:1.5.3.RELEASE" level="project" />
......@@ -145,7 +141,7 @@
<orderEntry type="library" name="Maven: com.thoughtworks.xstream:xstream:1.4.10" level="project" />
<orderEntry type="library" name="Maven: xmlpull:xmlpull:1.1.3.1" level="project" />
<orderEntry type="library" name="Maven: xpp3:xpp3_min:1.1.4c" level="project" />
<orderEntry type="module" module-name="assortment-ordercenter-sdk" />
<orderEntry type="library" name="Maven: cn.freemud:assortment-ordercenter-sdk:1.3.0-SNAPSHOT" level="project" />
<orderEntry type="module" module-name="ordercenter-sdk" />
<orderEntry type="library" name="Maven: com.google.code.gson:gson:2.8.0" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-collections4:4.1" level="project" />
......
......@@ -17,4 +17,8 @@ public class ApplicationConstant {
public final static String CURRENT_VERSION = "1.5.2";
public final static String BURYINGPOINT = "POINT";
public final static String DELIVERY_DISCOUNT_DESC1="订单满%d元 减%d配送费";
public final static String DELIVERY_DISCOUNT_DESC2="订单满%d元 免配送费";
public final static String DELIVERY_DISCOUNT_DESC3="另需配送费%d元";
}
......@@ -20,4 +20,9 @@ public class BenefitBeanDto {
* 优惠等级(用于阶梯满减)
*/
private Integer benefitSeq;
private Integer benefitType;
}
\ No newline at end of file
......@@ -23,4 +23,6 @@ public class ActivityQueryDto {
*/
private Integer orderType;
private ActivityQueryResponseDto activityQueryResponseDto;
}
......@@ -115,6 +115,12 @@ public class ShoppingCartGoodsDto {
@Builder.Default
private Boolean isDiscountDelivery = false;
/**
* 配送费活动号
*
*/
private String discountDeliveryActivityCode;
@Data
public static class CartGoodsDetailDto {
......
......@@ -72,4 +72,9 @@ public class AddShoppingCartGoodsRequestVo extends BaseRequestVo{
*/
private String menuType ;
/**
* 收货地址ID、svc卡支付外卖订单必传
*/
private String receiveId;
}
......@@ -114,7 +114,15 @@ public class ShoppingCartGoodsResponseVo extends ShoppingCartGoodsBaseResponseV
@Builder.Default
private Boolean isDiscountDelivery = false;
/**
* 满额减配送费描述
*/
private String deliveryDiscountDesc;
/**
* 减免后配送费
*/
private String discountDeliveryActivityCode;
}
......@@ -48,4 +48,9 @@ public class UpdateShoppingCartGoodsQtyRequestVo extends BaseRequestVo {
*/
private String menuType ;
/**
* 收货地址ID、svc卡支付外卖订单必传
*/
private String receiveId;
}
......@@ -21,6 +21,7 @@ import cn.freemud.constant.ResponseCodeConstant;
import cn.freemud.constant.ShoppingCartConstant;
import cn.freemud.entities.dto.*;
import cn.freemud.entities.dto.activity.ActivityQueryDto;
import cn.freemud.entities.dto.activity.ActivityQueryResponseDto;
import cn.freemud.entities.dto.activity.ShareDiscountActivityDto;
import cn.freemud.entities.dto.openplatform.WeixinProductRequestDto;
import cn.freemud.entities.dto.openplatform.WeixinProductResponseDto;
......@@ -72,6 +73,9 @@ import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import static cn.freemud.constant.ApplicationConstant.DELIVERY_DISCOUNT_DESC1;
import static cn.freemud.constant.ApplicationConstant.DELIVERY_DISCOUNT_DESC2;
import static cn.freemud.constant.ApplicationConstant.DELIVERY_DISCOUNT_DESC3;
import static cn.freemud.constant.ShoppingCartConstant.SHOPPING_CART_EMPTY_GOODS_LIST;
import static cn.freemud.constant.ShoppingCartConstant.SHOPPING_CART_INVALIAD_GOODS;
import static java.util.stream.Collectors.toList;
......@@ -133,6 +137,8 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
@Autowired
private ProductService productService;
@Autowired
private ActivityService activityService;
/**
* 从微信卡券向购物车中添加商品
......@@ -217,6 +223,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<>();
......@@ -255,9 +262,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<>());
=getCalculationDiscountResult(menuType,partnerId,storeId,userId,appId,userLoginInfoDto.getWxAppid(),orderType,allCartGoodsList,new ArrayList(),new ArrayList<>(),null,deliveryAmount);
// 当商品数量被设为0时
......@@ -268,7 +277,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
ActivityQueryDto activityQueryDto = activityAdapter.getActivityQueryDto(partnerId, storeId, userId, appId, addShoppingCartGoodsRequestVo.getOrderType());
// 促销活动的优惠金额计算
updateShoppingCartGoodsDiscount(null, activityQueryDto, calculationDiscountResult, allCartGoodsList, shoppingCartGoodsResponseVo, null, userLoginInfoDto);
updateShoppingCartGoodsDiscount(null, activityQueryDto, calculationDiscountResult, allCartGoodsList, shoppingCartGoodsResponseVo, null, userLoginInfoDto,addShoppingCartGoodsRequestVo.getMenuType(),deliveryAmount);
//设置更新响应信息
setAddAndUpdateResponse(shoppingCartGoodsResponseVo, calculationDiscountResult, allCartGoodsList, null, partnerId, storeId, userId, ShoppingCartConstant.ADD_AND_UPDATE, null);
......@@ -322,6 +331,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);
......@@ -344,9 +354,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<>());
=getCalculationDiscountResult(menuType,partnerId,storeId,userId,appId,userLoginInfoDto.getWxAppid(),orderType,cartGoodsList,new ArrayList(),new ArrayList<>(),null,deliveryAmount);
if (calculationDiscountResult == null) {
shoppingCartGoodsResponseVo.setProducts(cartGoodsList);
// return shoppingCartGoodsResponseVo;
......@@ -355,7 +367,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
ActivityQueryDto activityQueryDto = activityAdapter.getActivityQueryDto(partnerId, storeId, userId, appId, updateShoppingCartGoodsQtyRequestVo.getOrderType());
// 促销活动的优惠金额计算
updateShoppingCartGoodsDiscount(null, activityQueryDto, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo, null, userLoginInfoDto);
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);
......@@ -421,6 +433,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);
......@@ -443,9 +456,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);
ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscountResult = getCalculationDiscountResult(menuType,partnerId,storeId,userId,appId,userLoginInfoDto.getWxAppid(),orderType,cartGoodsList,coupons,null,shoppingCartInfoRequestVo.getReceiveId(),deliveryAmount);
if (calculationDiscountResult == null) {
shoppingCartGoodsResponseVo.setProducts(cartGoodsList);
......@@ -455,7 +469,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
CouponPromotionVO couponPromotionVO = couponAdapter.getCouponPromotionVO(shoppingCartInfoRequestVo, userLoginInfoDto);
// 促销活动的优惠金额计算
this.updateShoppingCartGoodsDiscount(couponPromotionVO, activityQueryDto, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo, shoppingCartInfoRequestVo, userLoginInfoDto);
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);
// 在原价、现价、折扣价上增加第一次使用会员卡的费用
......@@ -546,6 +560,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();
......@@ -606,8 +621,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);
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());
......@@ -615,7 +632,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
//临时方案
packgeAdditional(shoppingCartInfoRequestVo, premiumExchangeActivity);
// 促销活动的优惠金额计算
updateShoppingCartGoodsDiscount(couponPromotionVO, activityQueryDto, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo, shoppingCartInfoRequestVo, userLoginInfoDto);
updateShoppingCartGoodsDiscount(couponPromotionVO, activityQueryDto, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo, shoppingCartInfoRequestVo, userLoginInfoDto,shoppingCartInfoRequestVo.getMenuType(),deliveryAmount);
//设置更新响应信息
setAddAndUpdateResponse(shoppingCartGoodsResponseVo, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo.getToastMsg(), partnerId, storeId, userId, ShoppingCartConstant.QUERY_INFO, shoppingCartInfoRequestVo);
......@@ -623,14 +640,11 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
updateShoppingCartGoodsApportion(shoppingCartGoodsResponseVo, calculationDiscountResult, shoppingCartGoodsDto, premiumExchangeActivity, shoppingCartInfoRequestVo);
getNeedCardAmount(shoppingCartInfoRequestVo, shoppingCartGoodsDto);
/*Long packAmount = shoppingCartGoodsResponseVo.getPackAmount() == null ? 0 : shoppingCartGoodsResponseVo.getPackAmount();
shoppingCartGoodsDto.setTotalAmount(shoppingCartGoodsDto.getTotalAmount() - packAmount);
shoppingCartGoodsDto.setOriginalTotalAmount(shoppingCartGoodsDto.getOriginalTotalAmount() - packAmount);
shoppingCartGoodsDto.setPackageAmount(packAmount);*/
shoppingCartGoodsDto.setDeliveryAmount(shoppingCartGoodsResponseVo.getDeliveryAmount());
shoppingCartGoodsDto.setDiscountDeliveryAmount(shoppingCartGoodsResponseVo.getDiscountDeliveryAmount());
shoppingCartGoodsDto.setThresholdAmount(shoppingCartGoodsResponseVo.getThresholdAmount());
shoppingCartGoodsDto.setIsDiscountDelivery(shoppingCartGoodsResponseVo.getIsDiscountDelivery());
shoppingCartGoodsDto.setDiscountDeliveryActivityCode(shoppingCartGoodsResponseVo.getDiscountDeliveryActivityCode());
return ResponseUtil.success(shoppingCartGoodsDto);
}
......@@ -914,7 +928,8 @@ 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) {
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);
......@@ -986,23 +1001,71 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
BuyAndGiftsPromotionService buyAndGiftsPromotionService =(BuyAndGiftsPromotionService) PromotionFactory.getPromotionService(ShoppingCartPromotionEnum.BUY_GIFTS);
buyAndGiftsPromotionService.updateShoppingCartGoodsDiscount(couponPromotionVO, activityQueryDto, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo, userLoginInfoDto, shoppingCartInfoRequestVo);
// /**
// * 满额减配送费
// */
// if (calculationDiscountResult != null && CollectionUtils.isNotEmpty(calculationDiscountResult.getDiscounts())) {
//
// ActivityCalculationDiscountResponseDto.CalculationDiscountResult.Discount discount
// = calculationDiscountResult.getDiscounts().stream()
// .filter(discount1 -> { return discount1.getType().equals(ActivityTypeEnum.TYPE_14.getCode());})
// .findFirst().get();
//
// if (discount != null) {
// shoppingCartGoodsResponseVo.setDeliveryAmount(calculationDiscountResult.getDeliveryAmount());
// shoppingCartGoodsResponseVo.setDiscountDeliveryAmount(calculationDiscountResult.getDistributionFee());
// shoppingCartGoodsResponseVo.setThresholdAmount(discount.getThresholdAmount());
// shoppingCartGoodsResponseVo.setIsDiscountDelivery(true);
// }
// }
/**
* 满额减配送费
*/
if(BusinessTypeEnum.SAAS_DELIVERY.getCode().equals(menuType)) {
List<ActivityTypeEnum> activityTypeEnums = new LinkedList<>();
activityTypeEnums.add(ActivityTypeEnum.TYPE_14);
ActivityQueryResponseDto activityQueryResponseDto = activityService.queryActivityByType(activityQueryDto, activityTypeEnums, null);
ActivityResponseDto activityResponse =null;
BenefitBeanDto beanDto=null;
if (activityQueryResponseDto != null &&activityQueryResponseDto.getResult()!=null && activityQueryResponseDto.getResult().size()>0) {
activityResponse = activityQueryResponseDto.getResult().get(0);
shoppingCartGoodsResponseVo.setDiscountDeliveryActivityCode(activityResponse.getActivityCode());
beanDto=activityResponse.getBenefits().get(0);
}
ActivityCalculationDiscountResponseDto.CalculationDiscountResult.Discount discount=null;
if (calculationDiscountResult != null && CollectionUtils.isNotEmpty(calculationDiscountResult.getDiscounts())) {
Optional<ActivityCalculationDiscountResponseDto.CalculationDiscountResult.Discount> discountop
= calculationDiscountResult.getDiscounts().stream()
.filter(discount1 -> {
return ActivityTypeEnum.TYPE_14.getCode().equals(discount1.getType());
})
.findFirst();
discount=discountop.orElseGet(() -> {return null ;});
}
if(discount!=null){
if(beanDto.getBenefitType() == 1){
String desc = DELIVERY_DISCOUNT_DESC2;
shoppingCartGoodsResponseVo.setDeliveryDiscountDesc(String.format(desc, beanDto.getThresholdAmount() /100 ));
}else{
String desc = DELIVERY_DISCOUNT_DESC1;
shoppingCartGoodsResponseVo.setDeliveryDiscountDesc(String.format(desc, beanDto.getThresholdAmount() /100 ,beanDto.getDiscountAmount() / 100));
}
shoppingCartGoodsResponseVo.setDeliveryAmount(calculationDiscountResult.getDeliveryAmount());
shoppingCartGoodsResponseVo.setDiscountDeliveryAmount(calculationDiscountResult.getDistributionFee());
shoppingCartGoodsResponseVo.setThresholdAmount(discount.getThresholdAmount());
shoppingCartGoodsResponseVo.setIsDiscountDelivery(true);
}else{
if (activityResponse!=null) {
if(beanDto.getBenefitType() == 1){
String desc = DELIVERY_DISCOUNT_DESC2;
shoppingCartGoodsResponseVo.setDeliveryDiscountDesc(String.format(desc, beanDto.getThresholdAmount() /100 ));
}else{
String desc = DELIVERY_DISCOUNT_DESC1;
shoppingCartGoodsResponseVo.setDeliveryDiscountDesc(String.format(desc, beanDto.getThresholdAmount() /100 ,beanDto.getDiscountAmount() / 100));
}
shoppingCartGoodsResponseVo.setDeliveryAmount(deliveryAmount);
shoppingCartGoodsResponseVo.setDiscountDeliveryAmount(deliveryAmount);
shoppingCartGoodsResponseVo.setIsDiscountDelivery(false);
}else{
String desc = DELIVERY_DISCOUNT_DESC3;
shoppingCartGoodsResponseVo.setDeliveryDiscountDesc(String.format(desc, deliveryAmount.doubleValue() / 100));
shoppingCartGoodsResponseVo.setDeliveryAmount(deliveryAmount);
shoppingCartGoodsResponseVo.setDiscountDeliveryAmount(deliveryAmount);
shoppingCartGoodsResponseVo.setIsDiscountDelivery(false);
}
}
}
}
......@@ -1331,8 +1394,10 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
if (response.getData() == null || response.getData().getData() == null || response.getData().getData().getCardSimpleInfos().size() > 1) {
throw new ServiceException(ResponseResult.USER_SVC_CARD_ERROR);
}
//获取实际配送费
if (StringUtils.isNotBlank(receiveId)) {
Integer deliveryAmount = getDeliveryAmount(receiveId, partnerId, storeId);
// Integer deliveryAmount = getDeliveryAmount(receiveId, partnerId, storeId);
Integer deliveryAmount = shoppingCartGoodsResponseVo.getDiscountDeliveryAmount().intValue();
orderAmount += deliveryAmount;
}
Integer amount1 = response.getData().getData().getCardSimpleInfos().get(0).getAmount();
......@@ -1432,23 +1497,33 @@ 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){
,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 查询门店信息
StoreResponseDto storeResponseDto = storeService.getStoreInfo(partnerId, storeId);
//TODO 查询门店外卖信息
StoreDeliveryInfoDto storeDeliveryInfoDto = storeService.getStoreDeliveryInfo(storeResponseDto, wxappid);
calculationDiscountResult = this.getActivityCalculationDiscountResponse(partnerId, storeId, userId, appId, orderType, cartGoodsList, coupons, sendGoodsList,BusinessTypeEnum.getByType(menuType).getCode(),storeDeliveryInfoDto.getDeliveryAmount());
deliveryAmount = storeDeliveryInfoDto.getDeliveryAmount();
}else{
calculationDiscountResult = this.getActivityCalculationDiscountResponse(partnerId, storeId, userId, appId, orderType, cartGoodsList, coupons, sendGoodsList,BusinessTypeEnum.getByType(menuType).getCode(),null);
deliveryAmount = Long.parseLong(getDeliveryAmount(receiveId,partnerId,storeId).toString());
}
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