Commit 071a6b22 by 孙昱

Merge branch 'feature/20210302_麦咖啡优惠券互斥功能_yu.sun'

parents 77507b07 4b747a6c
...@@ -9,6 +9,7 @@ public class ResponseCodeConstant { ...@@ -9,6 +9,7 @@ public class ResponseCodeConstant {
public final static String RESPONSE_SUCCESS_STR = "100"; public final static String RESPONSE_SUCCESS_STR = "100";
public final static String RESPONSE_CONFLICTS_STR = "105";
// coco券校验异常的错误 // coco券校验异常的错误
public final static String COCO_RESPONSE_COUPON_ERR_STR = "700"; public final static String COCO_RESPONSE_COUPON_ERR_STR = "700";
...@@ -25,6 +26,7 @@ public class ResponseCodeConstant { ...@@ -25,6 +26,7 @@ public class ResponseCodeConstant {
successResponseCodeSet.add(RESPONSE_SUCCESS_OK); successResponseCodeSet.add(RESPONSE_SUCCESS_OK);
successResponseCodeSet.add(RESPONSE_SUCCESS_1); successResponseCodeSet.add(RESPONSE_SUCCESS_1);
successResponseCodeSet.add(RESPONSE_SUCCESS_0_STR); successResponseCodeSet.add(RESPONSE_SUCCESS_0_STR);
successResponseCodeSet.add(RESPONSE_CONFLICTS_STR);
} }
public static boolean isSuccessRespinseCode(Object o) { public static boolean isSuccessRespinseCode(Object o) {
......
...@@ -39,7 +39,6 @@ public class BatchOperateCartGoodsRequestVo extends BaseRequestVo{ ...@@ -39,7 +39,6 @@ public class BatchOperateCartGoodsRequestVo extends BaseRequestVo{
/** /**
* 商品信息 * 商品信息
*/ */
@NotEmpty(message = "商品信息不可为空")
private List<BatchGoodsInfoVo> goodsInfos; private List<BatchGoodsInfoVo> goodsInfos;
} }
\ No newline at end of file
...@@ -145,6 +145,7 @@ public enum ResponseResult { ...@@ -145,6 +145,7 @@ public enum ResponseResult {
COUPON_SHOP_NOTSUPPORT("46010", "优惠券在当前门店不可用"), COUPON_SHOP_NOTSUPPORT("46010", "优惠券在当前门店不可用"),
COUPON_ORDER_WAY_ERROR("46011", "您选择得优惠券不适用该点餐方式"), COUPON_ORDER_WAY_ERROR("46011", "您选择得优惠券不适用该点餐方式"),
COUPON_VERIFICATION_FAIL("46012", "优惠券核销失败"), COUPON_VERIFICATION_FAIL("46012", "优惠券核销失败"),
COUPON_CONFLICTS_ERROR("46013","当前使用的券列表存在互斥"),
/** /**
* 加价购商品 * 加价购商品
......
...@@ -223,12 +223,12 @@ public class ShoppingCartMCoffeeServiceImpl { ...@@ -223,12 +223,12 @@ public class ShoppingCartMCoffeeServiceImpl {
// 购物车数据更新(保存商品原价) // 购物车数据更新(保存商品原价)
List<CartGoods> newCartGoods = updateCartGoodsLegal(partnerId, storeId, orderType, tableNumber, menuType, userId, addCartGoods, shoppingCartGoodsResponseVo, oldCartGoodsList); List<CartGoods> newCartGoods = updateCartGoodsLegal(partnerId, storeId, orderType, tableNumber, menuType, userId, addCartGoods, shoppingCartGoodsResponseVo, oldCartGoodsList);
// 促销活动等价格计算 // 促销活动等价格计算
calculationService.updateShoppingCartGoodsDiscount(partnerId, storeId, userId, appId, orderType, assortmentCustomerInfoVo.isMemberPaid(), menuType, receiveId, null, calculationService.updateShoppingCartGoodsDiscount(partnerId, storeId, userId, appId, orderType, assortmentCustomerInfoVo.isMemberPaid(), menuType, receiveId, null,
newCartGoods, coupons, new ArrayList<>(), shoppingCartGoodsResponseVo, null); newCartGoods, coupons, new ArrayList<>(), shoppingCartGoodsResponseVo, null);
// 重新保存购物车数据
updateCartGoodsLegal(partnerId, storeId, orderType, tableNumber, menuType, userId, addCartGoods, shoppingCartGoodsResponseVo, oldCartGoodsList); // 购物车信息到缓存中
assortmentSdkService.setShoppingCart(partnerId, storeId, userId, newCartGoods, null, tableNumber, this.shoppingCartBaseService);
// 返回购物车数据 // 返回购物车数据
setAddAndUpdateResponse(shoppingCartGoodsResponseVo, newCartGoods, null, ShoppingCartConstant.ADD_AND_UPDATE, null); setAddAndUpdateResponse(shoppingCartGoodsResponseVo, newCartGoods, null, ShoppingCartConstant.ADD_AND_UPDATE, null);
} }
...@@ -358,46 +358,46 @@ public class ShoppingCartMCoffeeServiceImpl { ...@@ -358,46 +358,46 @@ public class ShoppingCartMCoffeeServiceImpl {
if (StringUtils.isEmpty(requestVo.getShopId())) { if (StringUtils.isEmpty(requestVo.getShopId())) {
throw new ServiceException(ResponseResult.SHOPPING_CART_SHOP_ID_NOT_EMPTY); throw new ServiceException(ResponseResult.SHOPPING_CART_SHOP_ID_NOT_EMPTY);
} }
if (CollectionUtils.isEmpty(requestVo.getGoodsInfos())) { if (CollectionUtils.isEmpty(requestVo.getGoodsInfos()) && CollectionUtils.isEmpty(requestVo.getQtyInfoList())) {
return ResponseUtil.error(ResponseResult.SHOPPING_CART_ADD_INVAILD); return ResponseUtil.error(ResponseResult.SHOPPING_CART_ADD_INVAILD);
} }
if (CollectionUtils.isEmpty(requestVo.getQtyInfoList())){ BaseResponse baseResponse = null;
return ResponseUtil.error(ResponseResult.SHOPPING_CART_UPDATE_ERROR); if (CollectionUtils.isNotEmpty(requestVo.getQtyInfoList())) {
BatchUpdateGoodsQtyRequestVo updateGoodsQtyRequestVo = new BatchUpdateGoodsQtyRequestVo();
updateGoodsQtyRequestVo.setAppId(requestVo.getAppId());
updateGoodsQtyRequestVo.setChannelType(requestVo.getChannelType());
updateGoodsQtyRequestVo.setCarVer(requestVo.getCarVer());
updateGoodsQtyRequestVo.setMenuType(requestVo.getMenuType());
updateGoodsQtyRequestVo.setReceiveId(requestVo.getReceiveId());
updateGoodsQtyRequestVo.setSessionId(requestVo.getSessionId());
updateGoodsQtyRequestVo.setVersion(requestVo.getVersion());
updateGoodsQtyRequestVo.setShopId(requestVo.getShopId());
updateGoodsQtyRequestVo.setPartnerId(requestVo.getPartnerId());
updateGoodsQtyRequestVo.setQtyInfoList(requestVo.getQtyInfoList());
baseResponse = this.batchUpdateGoodsQty(updateGoodsQtyRequestVo);
//批量更新失败,直接返回错误
if (!Objects.equals(ResponseResult.SUCCESS.getCode(), baseResponse.getCode())) {
return baseResponse;
}
} }
BaseResponse baseResponse; if (CollectionUtils.isNotEmpty(requestVo.getGoodsInfos())) {
BatchUpdateGoodsQtyRequestVo updateGoodsQtyRequestVo = new BatchUpdateGoodsQtyRequestVo(); MCoffeeBatchAddGoodsRequestVo addGoodsRequestVo = new MCoffeeBatchAddGoodsRequestVo();
updateGoodsQtyRequestVo.setAppId(requestVo.getAppId()); addGoodsRequestVo.setAppId(requestVo.getAppId());
updateGoodsQtyRequestVo.setChannelType(requestVo.getChannelType()); addGoodsRequestVo.setChannelType(requestVo.getChannelType());
updateGoodsQtyRequestVo.setCarVer(requestVo.getCarVer()); addGoodsRequestVo.setMenuType(requestVo.getMenuType());
updateGoodsQtyRequestVo.setMenuType(requestVo.getMenuType()); addGoodsRequestVo.setReceiveId(requestVo.getReceiveId());
updateGoodsQtyRequestVo.setReceiveId(requestVo.getReceiveId()); addGoodsRequestVo.setSessionId(requestVo.getSessionId());
updateGoodsQtyRequestVo.setSessionId(requestVo.getSessionId()); addGoodsRequestVo.setGoodsInfos(requestVo.getGoodsInfos());
updateGoodsQtyRequestVo.setVersion(requestVo.getVersion()); addGoodsRequestVo.setShopId(requestVo.getShopId());
updateGoodsQtyRequestVo.setShopId(requestVo.getShopId()); addGoodsRequestVo.setOrderType(requestVo.getOrderType());
updateGoodsQtyRequestVo.setPartnerId(requestVo.getPartnerId()); addGoodsRequestVo.setPartnerId(requestVo.getPartnerId());
updateGoodsQtyRequestVo.setQtyInfoList(requestVo.getQtyInfoList()); addGoodsRequestVo.setGoodsInfos(requestVo.getGoodsInfos());
baseResponse = this.batchUpdateGoodsQty(updateGoodsQtyRequestVo); baseResponse = this.addBatchGoods(addGoodsRequestVo);
//批量更新失败,直接返回错误 //批量新增失败,直接返回错误
if (!Objects.equals(ResponseResult.SUCCESS.getCode(),baseResponse.getCode())){ if (!Objects.equals(ResponseResult.SUCCESS.getCode(), baseResponse.getCode())) {
return baseResponse; return baseResponse;
} }
MCoffeeBatchAddGoodsRequestVo addGoodsRequestVo = new MCoffeeBatchAddGoodsRequestVo();
addGoodsRequestVo.setAppId(requestVo.getAppId());
addGoodsRequestVo.setChannelType(requestVo.getChannelType());
addGoodsRequestVo.setMenuType(requestVo.getMenuType());
addGoodsRequestVo.setReceiveId(requestVo.getReceiveId());
addGoodsRequestVo.setSessionId(requestVo.getSessionId());
addGoodsRequestVo.setGoodsInfos(requestVo.getGoodsInfos());
addGoodsRequestVo.setShopId(requestVo.getShopId());
addGoodsRequestVo.setOrderType(requestVo.getOrderType());
addGoodsRequestVo.setPartnerId(requestVo.getPartnerId());
addGoodsRequestVo.setGoodsInfos(requestVo.getGoodsInfos());
baseResponse = this.addBatchGoods(addGoodsRequestVo);
//批量新增失败,直接返回错误
if (!Objects.equals(ResponseResult.SUCCESS.getCode(),baseResponse.getCode())){
return baseResponse;
} }
return baseResponse; return baseResponse;
} }
...@@ -633,28 +633,20 @@ public class ShoppingCartMCoffeeServiceImpl { ...@@ -633,28 +633,20 @@ public class ShoppingCartMCoffeeServiceImpl {
assortmentSdkService.setShoppingCart(partnerId, storeId, userId, cartGoodsList, sessionId, "", shoppingCartBaseService); assortmentSdkService.setShoppingCart(partnerId, storeId, userId, cartGoodsList, sessionId, "", shoppingCartBaseService);
} }
/** // 门店列表页面无法获取到购物车行id导致前端需求,不管券信息是否为空,都更新到缓存
* 如果couponCode为空,则从缓存里尝试获取 //兼容前端逻辑,前端传递的券信息为空 或者 为 remove 时,清空购物车券,否则更新
* 如果couponCode不为空,则设置到缓存里 if(StringUtils.isEmpty(couponCode) || "remove".equals(couponCode)) {
*/ assortmentSdkService.setShoppingCartCouponCode(partnerId, storeId, userId, "",shoppingCartBaseService, SaveCouponType.COUPON.getCode());
if(StringUtils.isEmpty(couponCode)) {
couponCode = assortmentSdkService.getShoppingCartCoupon(partnerId, storeId, userId, shoppingCartBaseService, SaveCouponType.COUPON.getCode());
} else { } else {
if("remove".equals(couponCode)) {
couponCode = "";
}
assortmentSdkService.setShoppingCartCouponCode(partnerId, storeId, userId, couponCode, shoppingCartBaseService, SaveCouponType.COUPON.getCode()); assortmentSdkService.setShoppingCartCouponCode(partnerId, storeId, userId, couponCode, shoppingCartBaseService, SaveCouponType.COUPON.getCode());
} }
if(StringUtils.isEmpty(freightCouponCode) || "remove".equals(freightCouponCode)) {
if(StringUtils.isEmpty(freightCouponCode)) { assortmentSdkService.setShoppingCartCouponCode(partnerId, storeId, userId, "",shoppingCartBaseService, SaveCouponType.FREIGHT_COUPON.getCode());
freightCouponCode = assortmentSdkService.getShoppingCartCoupon(partnerId, storeId, userId, shoppingCartBaseService, SaveCouponType.FREIGHT_COUPON.getCode());
} else { } else {
if("remove".equals(freightCouponCode)) {
freightCouponCode = "";
}
assortmentSdkService.setShoppingCartCouponCode(partnerId, storeId, userId, freightCouponCode, shoppingCartBaseService, SaveCouponType.FREIGHT_COUPON.getCode()); assortmentSdkService.setShoppingCartCouponCode(partnerId, storeId, userId, freightCouponCode, shoppingCartBaseService, SaveCouponType.FREIGHT_COUPON.getCode());
} }
//放到参数里 //放到参数里
if(StringUtils.isNotEmpty(couponCode) ) { if(StringUtils.isNotEmpty(couponCode) ) {
shoppingCartInfoRequestVo.setCouponCode(couponCode); shoppingCartInfoRequestVo.setCouponCode(couponCode);
...@@ -1364,8 +1356,6 @@ public class ShoppingCartMCoffeeServiceImpl { ...@@ -1364,8 +1356,6 @@ public class ShoppingCartMCoffeeServiceImpl {
} }
}); });
} }
// 重新set购物车信息到缓存中
assortmentSdkService.setShoppingCart(partnerId, storeId, userId, nowCartGoodsList, null, tableNumber, this.shoppingCartBaseService);
return nowCartGoodsList; return nowCartGoodsList;
} }
......
...@@ -159,6 +159,10 @@ public class CalculationServiceImpl { ...@@ -159,6 +159,10 @@ public class CalculationServiceImpl {
ErrorLog.printErrorLog("calculation_discount_error", "/calculation/discount/sharding", discountRequest, ex); ErrorLog.printErrorLog("calculation_discount_error", "/calculation/discount/sharding", discountRequest, ex);
throw new ServiceException(ResponseResult.OPERATE_TOO_OFTEN); throw new ServiceException(ResponseResult.OPERATE_TOO_OFTEN);
} }
//优惠券互斥
if (null != activityCalculationDiscountResponseDto && StringUtils.equals(activityCalculationDiscountResponseDto.getStatusCode(),ResponseCodeConstant.RESPONSE_CONFLICTS_STR)){
throw new ServiceException(ResponseResult.COUPON_CONFLICTS_ERROR);
}
// 返回成功 // 返回成功
if (activityCalculationDiscountResponseDto == null || !StringUtils.equals(activityCalculationDiscountResponseDto.getStatusCode(), ResponseCodeConstant.RESPONSE_SUCCESS_STR)) { if (activityCalculationDiscountResponseDto == null || !StringUtils.equals(activityCalculationDiscountResponseDto.getStatusCode(), ResponseCodeConstant.RESPONSE_SUCCESS_STR)) {
throw new ServiceException(ResponseResult.OPERATE_TOO_OFTEN); throw new ServiceException(ResponseResult.OPERATE_TOO_OFTEN);
......
...@@ -60,6 +60,5 @@ public class MCoffeeBatchAddGoodsRequestVo { ...@@ -60,6 +60,5 @@ public class MCoffeeBatchAddGoodsRequestVo {
/** /**
* 商品信息 * 商品信息
*/ */
@NotEmpty(message = "商品信息不可为空")
private List<BatchGoodsInfoVo> goodsInfos; private List<BatchGoodsInfoVo> goodsInfos;
} }
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