Commit c710e3c9 by ping.wu

Merge branches 'develop' and 'feature/20200721_麦咖啡购物车_wuping' of…

Merge branches 'develop' and 'feature/20200721_麦咖啡购物车_wuping' of http://gitlab.freemud.com/order-group-application/order-group into develop
parents f8e762a0 5b7daa2b
...@@ -167,7 +167,7 @@ public class GetMenuResponseDto { ...@@ -167,7 +167,7 @@ public class GetMenuResponseDto {
private int updateStatus; private int updateStatus;
private boolean valid; private boolean valid;
private int version; private int version;
private List<ProductLabelNameListBean> labelNames; private List<ProductLabelNameBean> labelNames;
private List<ProductAttributeGroupListBean> productAttributeGroupList; private List<ProductAttributeGroupListBean> productAttributeGroupList;
private List<ProductPictureListBean> productPictureList; private List<ProductPictureListBean> productPictureList;
private List<?> productSpecification; private List<?> productSpecification;
...@@ -239,7 +239,7 @@ public class GetMenuResponseDto { ...@@ -239,7 +239,7 @@ public class GetMenuResponseDto {
@NoArgsConstructor @NoArgsConstructor
@Data @Data
public static class ProductLabelNameListBean { public static class ProductLabelNameBean {
private String id; private String id;
private String name; private String name;
private String partnerId; private String partnerId;
......
...@@ -66,6 +66,15 @@ public class MCoffeeShoppingCartController { ...@@ -66,6 +66,15 @@ public class MCoffeeShoppingCartController {
} }
/** /**
* 查询购物车可使用优惠券
*/
@ApiAnnotation(logMessage = "availableCoupon")
@PostMapping(value = "/availableCoupon")
public BaseResponse availableCoupon(@Validated @LogParams @RequestBody ShoppingCartInfoRequestVo request) {
return shoppingCartMCoffeeService.availableCoupon(request);
}
/**
* 清空购物车 * 清空购物车
*/ */
@ApiAnnotation(logMessage = "clearCartGoods") @ApiAnnotation(logMessage = "clearCartGoods")
......
...@@ -86,6 +86,10 @@ public class ActivityCalculationDiscountRequestDto { ...@@ -86,6 +86,10 @@ public class ActivityCalculationDiscountRequestDto {
/** /**
* 商品ID * 商品ID
*/ */
private String goodsCode;
/**
* 商品ID
*/
private String goodsId; private String goodsId;
/** /**
* 购物车行uid * 购物车行uid
......
...@@ -80,4 +80,14 @@ public class AddShoppingCartGoodsRequestVo extends BaseRequestVo{ ...@@ -80,4 +80,14 @@ public class AddShoppingCartGoodsRequestVo extends BaseRequestVo{
*/ */
private String receiveId; private String receiveId;
/**
* 操作类型 1= 添加商品券 2=加价购
*/
private Integer operationType;
/**
* 优惠券号
*/
private String couponCode;
} }
...@@ -261,6 +261,37 @@ public class ShoppingCartMCoffeeServiceImpl { ...@@ -261,6 +261,37 @@ public class ShoppingCartMCoffeeServiceImpl {
return ResponseUtil.success(shoppingCartGoodsResponseVo); return ResponseUtil.success(shoppingCartGoodsResponseVo);
} }
/**
* 查询购物车可用券
*/
public BaseResponse availableCoupon(ShoppingCartInfoRequestVo shoppingCartInfoRequestVo) {
if (StringUtils.isEmpty(shoppingCartInfoRequestVo.getShopId())) {
throw new ServiceException(ResponseResult.SHOPPING_CART_SHOP_ID_NOT_EMPTY);
}
ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo = new ShoppingCartGoodsResponseVo();
ActivityClassifyCouponBean availableCoupon = new ActivityClassifyCouponBean();
// 获取用户信息
CustomerInfoVo assortmentCustomerInfoVo = getCustomerInfoVo(shoppingCartInfoRequestVo.getSessionId());
String userId = assortmentCustomerInfoVo.getMemberId();
String partnerId = shoppingCartInfoRequestVo.getPartnerId();
String storeId = shoppingCartInfoRequestVo.getShopId();
String appId = shoppingCartInfoRequestVo.getAppId();
String couponCode = shoppingCartInfoRequestVo.getCouponCode();
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);
// 促销计算-查询用户券-券码校验可用券
availableCoupon = calculationService.availableCoupon(partnerId, storeId, userId, appId, orderType, assortmentCustomerInfoVo.isMemberPaid(), menuType, receiveId,null,
cartGoodsList, new ArrayList<>(), new ArrayList<>(), shoppingCartGoodsResponseVo);
return ResponseUtil.success(availableCoupon);
}
/** /**
* 清空购物车 * 清空购物车
* *
......
...@@ -87,8 +87,12 @@ public class CalculationServiceImpl { ...@@ -87,8 +87,12 @@ public class CalculationServiceImpl {
List<CartGoods> cartGoodsList, List<ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon> coupons, List<CartGoods> cartGoodsList, List<ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon> coupons,
List<ShoppingCartInfoRequestVo.SendGoods> sendGoodsList, ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo) { List<ShoppingCartInfoRequestVo.SendGoods> sendGoodsList, ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo) {
Long deliveryAmount = calculateDeliveryAmount(receiveId, partnerId, storeId, appId, shoppingCartGoodsResponseVo); Long deliveryAmount = 0L;
QueryDeliverDetailResponse response = calculateDeliveryAmount(receiveId, partnerId, storeId, appId);
if(response != null){
shoppingCartGoodsResponseVo.setDeliveryFeeZeroReason(response.getDeliveryFeeZeroReason() != null ? response.getDeliveryFeeZeroReason() : 0);
deliveryAmount = response.getDeliveryAmount();
}
ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscount = getCalculationDiscount(partnerId, storeId, userId, appId, orderType, isMember, ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscount = getCalculationDiscount(partnerId, storeId, userId, appId, orderType, isMember,
menuType, deliveryAmount, cartGoodsList, coupons, sendGoodsList); menuType, deliveryAmount, cartGoodsList, coupons, sendGoodsList);
...@@ -117,7 +121,7 @@ public class CalculationServiceImpl { ...@@ -117,7 +121,7 @@ public class CalculationServiceImpl {
List<ActivityCalculationDiscountRequestDto.CalculationDiscountGoods> calculationDiscountGoodsList = new ArrayList<>(); List<ActivityCalculationDiscountRequestDto.CalculationDiscountGoods> calculationDiscountGoodsList = new ArrayList<>();
for (CartGoods cartGoods : cartGoodsList) { for (CartGoods cartGoods : cartGoodsList) {
addCalculationDiscountGoods(calculationDiscountGoodsList, cartGoods.getGoodsId(), cartGoods.getQty(), cartGoods.getFinalPrice(), cartGoods.getMemberDiscount()); addCalculationDiscountGoods(calculationDiscountGoodsList, cartGoods.getCustomerCode(),cartGoods.getGoodsId(), cartGoods.getQty(), cartGoods.getFinalPrice(), cartGoods.getMemberDiscount());
} }
if (BusinessTypeEnum.SAAS_DELIVERY.getCode().equals(menuType)) { if (BusinessTypeEnum.SAAS_DELIVERY.getCode().equals(menuType)) {
...@@ -126,7 +130,7 @@ public class CalculationServiceImpl { ...@@ -126,7 +130,7 @@ public class CalculationServiceImpl {
// 当加价购商品不为空时 // 当加价购商品不为空时
if (CollectionUtils.isNotEmpty(sendGoodsList)) { if (CollectionUtils.isNotEmpty(sendGoodsList)) {
for (ShoppingCartInfoRequestVo.SendGoods sendGoods : sendGoodsList) { for (ShoppingCartInfoRequestVo.SendGoods sendGoods : sendGoodsList) {
this.addCalculationDiscountGoods(calculationDiscountGoodsList, sendGoods.getGoodsId(), sendGoods.getQty(), sendGoods.getOriginalPrice(), 100); this.addCalculationDiscountGoods(calculationDiscountGoodsList, sendGoods.getGoodsId(), sendGoods.getGoodsId(), sendGoods.getQty(), sendGoods.getOriginalPrice(), 100);
} }
} }
calculationDiscountGoodsList.removeIf(calculationDiscountGoods -> (calculationDiscountGoods.getGoodsQuantity().equals(0))); calculationDiscountGoodsList.removeIf(calculationDiscountGoods -> (calculationDiscountGoods.getGoodsQuantity().equals(0)));
...@@ -276,10 +280,10 @@ public class CalculationServiceImpl { ...@@ -276,10 +280,10 @@ public class CalculationServiceImpl {
/** /**
* 配送金额 * 配送金额
*/ */
private Long calculateDeliveryAmount(String receiveId, String partnerId, String storeId, String wxappid, ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo) { private QueryDeliverDetailResponse calculateDeliveryAmount(String receiveId, String partnerId, String storeId, String wxappid) {
Long deliveryAmount = 0L;
if (StringUtils.isBlank(receiveId)) { if (StringUtils.isBlank(receiveId)) {
return deliveryAmount; return null;
} }
String trackingNo = LogThreadLocal.getTrackingNo(); String trackingNo = LogThreadLocal.getTrackingNo();
...@@ -302,10 +306,8 @@ public class CalculationServiceImpl { ...@@ -302,10 +306,8 @@ public class CalculationServiceImpl {
if (queryDeliverDetailResponse.getData().getDeliveryAmount() == null) { if (queryDeliverDetailResponse.getData().getDeliveryAmount() == null) {
throw new ServiceException(ResponseResult.STORE_DELIVERY_AMOUNT_ERROR); throw new ServiceException(ResponseResult.STORE_DELIVERY_AMOUNT_ERROR);
} }
shoppingCartGoodsResponseVo.setDeliveryFeeZeroReason(queryDeliverDetailResponse.getData().getDeliveryFeeZeroReason() != null ? queryDeliverDetailResponse.getData().getDeliveryFeeZeroReason() : 0);
deliveryAmount = queryDeliverDetailResponse.getData().getDeliveryAmount();
return deliveryAmount; return queryDeliverDetailResponse.getData();
} }
...@@ -343,8 +345,9 @@ public class CalculationServiceImpl { ...@@ -343,8 +345,9 @@ public class CalculationServiceImpl {
* @param originalPrice * @param originalPrice
*/ */
private void addCalculationDiscountGoods(List<ActivityCalculationDiscountRequestDto.CalculationDiscountGoods> calculationDiscountGoodsList, private void addCalculationDiscountGoods(List<ActivityCalculationDiscountRequestDto.CalculationDiscountGoods> calculationDiscountGoodsList,
String goodsId, Integer goodsQuantity, Long originalPrice, Integer memberDiscount) { String goodsCode,String goodsId, Integer goodsQuantity, Long originalPrice, Integer memberDiscount) {
ActivityCalculationDiscountRequestDto.CalculationDiscountGoods calculationDiscountGoods = new ActivityCalculationDiscountRequestDto.CalculationDiscountGoods(); ActivityCalculationDiscountRequestDto.CalculationDiscountGoods calculationDiscountGoods = new ActivityCalculationDiscountRequestDto.CalculationDiscountGoods();
calculationDiscountGoods.setGoodsCode(goodsCode);
calculationDiscountGoods.setGoodsId(goodsId); calculationDiscountGoods.setGoodsId(goodsId);
calculationDiscountGoods.setGoodsQuantity(goodsQuantity); calculationDiscountGoods.setGoodsQuantity(goodsQuantity);
calculationDiscountGoods.setOriginalPrice(originalPrice); calculationDiscountGoods.setOriginalPrice(originalPrice);
...@@ -385,4 +388,30 @@ public class CalculationServiceImpl { ...@@ -385,4 +388,30 @@ public class CalculationServiceImpl {
} }
/**
* 可选优惠券
*/
public ActivityClassifyCouponBean availableCoupon(String partnerId, String storeId, String userId, String appId, Integer orderType,
boolean isMember, String menuType, String receiveId,String couponCode,
List<CartGoods> cartGoodsList, List<ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon> coupons,
List<ShoppingCartInfoRequestVo.SendGoods> sendGoodsList, ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo){
Long deliveryAmount = 0L;
QueryDeliverDetailResponse response = calculateDeliveryAmount(receiveId, partnerId, storeId, appId);
if(response != null){
shoppingCartGoodsResponseVo.setDeliveryFeeZeroReason(response.getDeliveryFeeZeroReason() != null ? response.getDeliveryFeeZeroReason() : 0);
deliveryAmount = response.getDeliveryAmount();
}
ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscount = getCalculationDiscount(partnerId, storeId, userId, appId, orderType, isMember,
menuType, deliveryAmount, cartGoodsList, coupons, sendGoodsList);
//优惠券
CouponPromotionVO couponPromotionVO = couponDiscountCalculation.getCouponPromotionVO(partnerId, storeId, userId, couponCode, orderType);
couponDiscountCalculation.updateShoppingCartGoodsDiscount(couponPromotionVO,calculationDiscount,cartGoodsList, shoppingCartGoodsResponseVo);
return shoppingCartGoodsResponseVo.getAvailableCoupon();
}
} }
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