Commit 0732b50b by ping.wu

Merge branches 'feature/20211220_购物车活动互斥提示_wuping' and 'qa' of…

Merge branches 'feature/20211220_购物车活动互斥提示_wuping' and 'qa' of http://gitlab.freemud.com/order-group-application/order-group into qa

# Conflicts:
#	shopping-cart-application-service/src/main/java/cn/freemud/factory/AbstractShoppingCartImpl.java
#	shopping-cart-application-service/src/main/java/cn/freemud/service/impl/ShoppingCartMallServiceImpl.java
#	shopping-cart-application-service/src/main/java/cn/freemud/service/impl/ShoppingCartNewServiceImpl.java
#	shopping-cart-application-service/src/main/java/cn/freemud/service/impl/calculate/CalculationSharingCartService.java
parents 50b5943d e434b10d
...@@ -104,9 +104,6 @@ public abstract class CheckOrderUniversal { ...@@ -104,9 +104,6 @@ public abstract class CheckOrderUniversal {
@Autowired @Autowired
private ItemServiceImpl itemService; private ItemServiceImpl itemService;
// 配送费逻辑是否使用旧的
@Value("${store.delivery.use.old}")
private boolean storeDeliveryUseOld;
@Value("${coco.partnerId}") @Value("${coco.partnerId}")
private String cocoPartnerId; private String cocoPartnerId;
...@@ -447,11 +444,7 @@ public abstract class CheckOrderUniversal { ...@@ -447,11 +444,7 @@ public abstract class CheckOrderUniversal {
} }
//获取门店配送信息 //获取门店配送信息
StoreDeliveryInfoDto storeDeliveryInfoDto; StoreDeliveryInfoDto storeDeliveryInfoDto;
if (storeDeliveryUseOld) {
storeDeliveryInfoDto = getStoreDeliveryInfo(storeResponseDto, config, appId);
} else {
storeDeliveryInfoDto = getNewStoreDeliveryInfo(storeResponseDto, config, appId, LogThreadLocal.getTrackingNo()); storeDeliveryInfoDto = getNewStoreDeliveryInfo(storeResponseDto, config, appId, LogThreadLocal.getTrackingNo());
}
//coco自配送提前45分钟,禁止下单 //coco自配送提前45分钟,禁止下单
if (cocoPartnerId.equals(createOrderVo.getPartnerId()) && if (cocoPartnerId.equals(createOrderVo.getPartnerId()) &&
CreateOrderType.TAKE_OUT.getCode().equals(createOrderVo.getOrderType()) && CreateOrderType.TAKE_OUT.getCode().equals(createOrderVo.getOrderType()) &&
......
...@@ -49,9 +49,6 @@ public class DeliveryServiceImpl { ...@@ -49,9 +49,6 @@ public class DeliveryServiceImpl {
@Autowired @Autowired
private DeliveryFeiginClient deliveryFeiginClient; private DeliveryFeiginClient deliveryFeiginClient;
// 配送费逻辑是否使用旧的
@Value("${store.delivery.use.old:true}")
private boolean storeDeliveryUseOld;
public Long calculateDeliveryAmount(String receiveId, String partnerId, String storeId, Integer orderType, ManagerServiceBO managerServiceBO) { public Long calculateDeliveryAmount(String receiveId, String partnerId, String storeId, Integer orderType, ManagerServiceBO managerServiceBO) {
Long deliveryAmount = 0L; Long deliveryAmount = 0L;
...@@ -60,11 +57,7 @@ public class DeliveryServiceImpl { ...@@ -60,11 +57,7 @@ public class DeliveryServiceImpl {
if (StringUtils.isBlank(receiveId) && !Objects.equals(orderType, CreateOrderType.TAKE_OUT.getCode())) { if (StringUtils.isBlank(receiveId) && !Objects.equals(orderType, CreateOrderType.TAKE_OUT.getCode())) {
return deliveryAmount; return deliveryAmount;
} }
if (storeDeliveryUseOld) { deliveryAmount = getNewDeliveryAmount(receiveId, partnerId, storeId, orderType);
deliveryAmount = Long.parseLong(getDeliveryAmount(receiveId, partnerId, storeId, managerServiceBO).toString());
} else {
deliveryAmount = getNewDeliveryAmount(receiveId, partnerId, storeId, orderType);
}
return deliveryAmount; return deliveryAmount;
} }
......
package cn.freemud.entities.dto.calculate;
import lombok.Data;
import java.util.List;
@Data
public class BlockRow {
private Integer discountAmount;
private List<BlockRowDiscount> discounts;
private String goodsId;
private Integer goodsQuantity;
private Integer originalPrice;
private Integer realAmount;
private Integer type;
}
package cn.freemud.entities.dto.calculate;
import lombok.Data;
@Data
public class BlockRowDiscount {
private String activityCode;
private String activityDesc;
private String activityName;
private Integer actualGoodsNumber;
private Long discount;
private String goodsId;
private Integer type;
}
...@@ -101,7 +101,7 @@ public class CalculationDiscountResult { ...@@ -101,7 +101,7 @@ public class CalculationDiscountResult {
*/ */
private Long payCardFee; private Long payCardFee;
/** /**
* 月享卡2.0优惠 * 麦咖啡,月享卡2.0优惠
*/ */
private MonthCardDiscount monthlyEnjoyCardDiscount; private MonthCardDiscount monthlyEnjoyCardDiscount;
...@@ -113,4 +113,9 @@ public class CalculationDiscountResult { ...@@ -113,4 +113,9 @@ public class CalculationDiscountResult {
//是否是v3版本算价 //是否是v3版本算价
private Boolean v3Promotion = false; private Boolean v3Promotion = false;
/**
* 被互斥掉的活动集合
*/
private List<ExclusiveActivity> exclusiveActivityList;
} }
...@@ -18,4 +18,7 @@ public class CouponResults { ...@@ -18,4 +18,7 @@ public class CouponResults {
private String activityName; private String activityName;
//是否与促销活动共享 0不同享 1同享
private Integer promotionSharing;
} }
...@@ -70,4 +70,7 @@ public class Discount { ...@@ -70,4 +70,7 @@ public class Discount {
*/ */
private Integer priority; private Integer priority;
//是否与促销活动共享 0不同享 1同享
private Integer promotionSharing;
} }
package cn.freemud.entities.dto.calculate;
import cn.freemud.entities.dto.UserLoginInfoDto;
import cn.freemud.entities.dto.activity.ActivityQueryDto;
import cn.freemud.entities.vo.CartGoods;
import cn.freemud.entities.vo.CouponPromotionVO;
import cn.freemud.entities.vo.ShoppingCartGoodsResponseVo;
import cn.freemud.entities.vo.ShoppingCartInfoRequestVo;
import lombok.Data;
import java.util.List;
@Data
public class DistributeBo {
private CalculationDiscountResult discountResult;
private List<CartGoods> cartGoodsList;
private ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo;
private ShoppingCartInfoRequestVo shoppingCartInfoRequestVo;
private UserLoginInfoDto userLoginInfoDto;
private CouponPromotionVO couponPromotionVO;
private ActivityQueryDto activityQueryDto;
private String menuType;
private Long deliveryAmount;
private String opt;
private String partnerId;
private Integer flag;
private String userId;
private String storeId;
private Boolean hasCoupon = false;
public DistributeBo() {
}
public DistributeBo(CalculationDiscountResult discountResult, List<CartGoods> cartGoodsList, ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo, ShoppingCartInfoRequestVo shoppingCartInfoRequestVo, UserLoginInfoDto userLoginInfoDto, CouponPromotionVO couponPromotionVO, ActivityQueryDto activityQueryDto, String menuType, Long deliveryAmount, String opt, String partnerId, Integer flag, String userId, String storeId) {
this.discountResult = discountResult;
this.cartGoodsList = cartGoodsList;
this.shoppingCartGoodsResponseVo = shoppingCartGoodsResponseVo;
this.shoppingCartInfoRequestVo = shoppingCartInfoRequestVo;
this.userLoginInfoDto = userLoginInfoDto;
this.couponPromotionVO = couponPromotionVO;
this.activityQueryDto = activityQueryDto;
this.menuType = menuType;
this.deliveryAmount = deliveryAmount;
this.opt = opt;
this.partnerId = partnerId;
this.flag = flag;
this.userId = userId;
this.storeId = storeId;
}
}
package cn.freemud.entities.dto.calculate;
import lombok.Data;
@Data
public class ExclusiveActivity {
private Integer activityType;
private String activityCode;
private String activityName;
private String activityTypeName;
}
package cn.freemud.entities.dto.shoppingCart;
import lombok.Data;
@Data
public class ActivityMutexConfig {
//活动互斥 1=开启 0=关闭
private String activityMutex;
//优惠券与活动互斥 1=开启 0=关闭
// private String couponactivityMutex;
}
...@@ -13,6 +13,7 @@ package cn.freemud.enums; ...@@ -13,6 +13,7 @@ package cn.freemud.enums;
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目 * 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/ */
public enum ActivityTypeEnum { public enum ActivityTypeEnum {
TYPE_0(0, "其他"),
TYPE_1(1, "整单满减"), TYPE_1(1, "整单满减"),
TYPE_11(11, "每满减"), TYPE_11(11, "每满减"),
TYPE_12(12, "阶梯满减"), TYPE_12(12, "阶梯满减"),
...@@ -97,4 +98,14 @@ public enum ActivityTypeEnum { ...@@ -97,4 +98,14 @@ public enum ActivityTypeEnum {
public void setDesc(String desc) { public void setDesc(String desc) {
this.desc = desc; this.desc = desc;
} }
public static ActivityTypeEnum getByCode(Integer code) {
for (ActivityTypeEnum type : values()) {
if (type.getCode().equals(code)) {
return type;
}
}
return ActivityTypeEnum.TYPE_0;
}
} }
...@@ -102,9 +102,6 @@ public abstract class AbstractShoppingCartImpl implements ShoppingCartNewService ...@@ -102,9 +102,6 @@ public abstract class AbstractShoppingCartImpl implements ShoppingCartNewService
private AssortmentSdkService assortmentSdkService; private AssortmentSdkService assortmentSdkService;
@Autowired @Autowired
private AssortmentCustomerInfoManager customerInfoManager; private AssortmentCustomerInfoManager customerInfoManager;
// 配送费逻辑是否使用旧的
@Value("${store.delivery.use.old:true}")
private boolean storeDeliveryUseOld;
/** /**
* 根据sessionId获取用户信息 * 根据sessionId获取用户信息
...@@ -211,12 +208,7 @@ public abstract class AbstractShoppingCartImpl implements ShoppingCartNewService ...@@ -211,12 +208,7 @@ public abstract class AbstractShoppingCartImpl implements ShoppingCartNewService
if (StringUtils.isBlank(receiveId)) { if (StringUtils.isBlank(receiveId)) {
return deliveryAmount; return deliveryAmount;
} }
if (storeDeliveryUseOld) {
deliveryAmount = Long.parseLong(getDeliveryAmount(receiveId, partnerId, storeId).toString());
shoppingCartGoodsResponseVo.setDeliveryFeeZeroReason(0);
} else {
deliveryAmount = getNewDeliveryAmount(receiveId, partnerId, storeId, shoppingCartGoodsResponseVo); deliveryAmount = getNewDeliveryAmount(receiveId, partnerId, storeId, shoppingCartGoodsResponseVo);
}
return deliveryAmount; return deliveryAmount;
} }
...@@ -338,16 +330,11 @@ public abstract class AbstractShoppingCartImpl implements ShoppingCartNewService ...@@ -338,16 +330,11 @@ public abstract class AbstractShoppingCartImpl implements ShoppingCartNewService
, List<CartGoods> cartGoodsList, List<ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon> coupons , List<CartGoods> cartGoodsList, List<ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon> coupons
, List<ShoppingCartInfoRequestVo.SendGoods> sendGoodsList, String receiveId, Long deliveryAmount, long nightDistributionFee){ , List<ShoppingCartInfoRequestVo.SendGoods> sendGoodsList, String receiveId, Long deliveryAmount, long nightDistributionFee){
// 获取优惠信息 // 获取优惠信息
CalculationDiscountResult calculationDiscountResult=null; if(!BusinessTypeEnum.SAAS_DELIVERY.getCode().equals(menuType)){
//外卖场景下 查询门店配送信息 deliveryAmount = null;
if(BusinessTypeEnum.SAAS_DELIVERY.getCode().equals(menuType)){ nightDistributionFee = 0;
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,0L);
} }
return this.getActivityCalculationDiscountResponse(partnerId, storeId, userId, appId, orderType,isMember, cartGoodsList, coupons, sendGoodsList,BusinessTypeEnum.getByType(menuType).getCode(),deliveryAmount,null, null, nightDistributionFee);
return calculationDiscountResult;
} }
......
...@@ -26,6 +26,7 @@ import cn.freemud.entities.dto.activity.ActivityQueryDto; ...@@ -26,6 +26,7 @@ import cn.freemud.entities.dto.activity.ActivityQueryDto;
import cn.freemud.entities.dto.activity.DiscountSharingDto; import cn.freemud.entities.dto.activity.DiscountSharingDto;
import cn.freemud.entities.dto.calculate.ActivityCalculationDiscountRequestDto; import cn.freemud.entities.dto.calculate.ActivityCalculationDiscountRequestDto;
import cn.freemud.entities.dto.calculate.CalculationDiscountResult; import cn.freemud.entities.dto.calculate.CalculationDiscountResult;
import cn.freemud.entities.dto.calculate.DistributeBo;
import cn.freemud.entities.dto.delivery.DeliveryFeeInfo; import cn.freemud.entities.dto.delivery.DeliveryFeeInfo;
import cn.freemud.entities.dto.product.CheckCartRequest; import cn.freemud.entities.dto.product.CheckCartRequest;
import cn.freemud.entities.dto.shoppingCart.ShoppingCartGoodsDto; import cn.freemud.entities.dto.shoppingCart.ShoppingCartGoodsDto;
...@@ -196,7 +197,9 @@ public class ShoppingCartMallServiceImpl implements ShoppingCartNewService { ...@@ -196,7 +197,9 @@ public class ShoppingCartMallServiceImpl implements ShoppingCartNewService {
CalculationDiscountResult discountResult = null; CalculationDiscountResult discountResult = null;
discountResult = sharingDiscountService.getCalculationSharingDiscountResult(menuType, partnerId, storeId, userId, appId, orderType, assortmentCustomerInfoVo.isMemberPaid(), allCartGoodsList, new ArrayList<>(), null, deliveryAmount, null,null, accountType,new DiscountSharingDto(),0L); 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);
DistributeBo distributeBo = new DistributeBo(discountResult, allCartGoodsList, shoppingCartGoodsResponseVo, null, null, null, activityQueryDto, menuType, deliveryAmount, ShoppingCartConstant.ADD_AND_UPDATE, partnerId, null, userId, storeId,0L);
sharingCartService.distribute(distributeBo);
buildShoppingCartGoodsResponse(shoppingCartGoodsResponseVo,discountResult,null,partnerId); buildShoppingCartGoodsResponse(shoppingCartGoodsResponseVo,discountResult,null,partnerId);
...@@ -292,7 +295,7 @@ public class ShoppingCartMallServiceImpl implements ShoppingCartNewService { ...@@ -292,7 +295,7 @@ public class ShoppingCartMallServiceImpl implements ShoppingCartNewService {
, deliveryAmount , deliveryAmount
, null,null, accountFlag,new DiscountSharingDto(),0L); , null,null, accountFlag,new DiscountSharingDto(),0L);
sharingCartService.distribute(discountResult DistributeBo distributeBo = new DistributeBo(discountResult
, cartGoodsList , cartGoodsList
, shoppingCartGoodsResponseVo , shoppingCartGoodsResponseVo
, null //入参 , null //入参
...@@ -307,6 +310,8 @@ public class ShoppingCartMallServiceImpl implements ShoppingCartNewService { ...@@ -307,6 +310,8 @@ public class ShoppingCartMallServiceImpl implements ShoppingCartNewService {
, userId , userId
, storeId,0L); , storeId,0L);
sharingCartService.distribute(distributeBo);
buildShoppingCartGoodsResponse(shoppingCartGoodsResponseVo,discountResult,null,partnerId); buildShoppingCartGoodsResponse(shoppingCartGoodsResponseVo,discountResult,null,partnerId);
return ResponseUtil.success(shoppingCartGoodsResponseVo); return ResponseUtil.success(shoppingCartGoodsResponseVo);
...@@ -450,7 +455,8 @@ public class ShoppingCartMallServiceImpl implements ShoppingCartNewService { ...@@ -450,7 +455,8 @@ public class ShoppingCartMallServiceImpl implements ShoppingCartNewService {
, sendGoods , sendGoods
, deliveryAmount , deliveryAmount
, null,null, accountFlag,new DiscountSharingDto(),0L); , null,null, accountFlag,new DiscountSharingDto(),0L);
sharingCartService.distribute(calculationSharingDiscountResult
DistributeBo distributeBo = new DistributeBo(calculationSharingDiscountResult
, cartGoodsList , cartGoodsList
, shoppingCartGoodsResponseVo , shoppingCartGoodsResponseVo
, shoppingCartInfoRequestVo , shoppingCartInfoRequestVo
...@@ -464,6 +470,7 @@ public class ShoppingCartMallServiceImpl implements ShoppingCartNewService { ...@@ -464,6 +470,7 @@ public class ShoppingCartMallServiceImpl implements ShoppingCartNewService {
,shoppingCartInfoRequestVo.getFlag() ,shoppingCartInfoRequestVo.getFlag()
, userId , userId
, storeId,0L); , storeId,0L);
sharingCartService.distribute(distributeBo);
buildShoppingCartGoodsResponse(shoppingCartGoodsResponseVo,calculationSharingDiscountResult,shoppingCartInfoRequestVo.getFlag(),partnerId); buildShoppingCartGoodsResponse(shoppingCartGoodsResponseVo,calculationSharingDiscountResult,shoppingCartInfoRequestVo.getFlag(),partnerId);
......
...@@ -34,6 +34,8 @@ import cn.freemud.entities.dto.order.PackAmountConfig; ...@@ -34,6 +34,8 @@ import cn.freemud.entities.dto.order.PackAmountConfig;
import cn.freemud.entities.dto.other.ValidCouponBo; import cn.freemud.entities.dto.other.ValidCouponBo;
import cn.freemud.entities.dto.pay.*; import cn.freemud.entities.dto.pay.*;
import cn.freemud.entities.dto.product.CheckCartRequest; import cn.freemud.entities.dto.product.CheckCartRequest;
import cn.freemud.entities.dto.shoppingCart.ActivityMutexConfig;
import cn.freemud.entities.dto.shoppingCart.PromotionResultVO;
import cn.freemud.entities.dto.product.info.ProductBean; import cn.freemud.entities.dto.product.info.ProductBean;
import cn.freemud.entities.dto.product.info.SkuProductBean; import cn.freemud.entities.dto.product.info.SkuProductBean;
import cn.freemud.entities.dto.shoppingCart.PromotionResultVO; import cn.freemud.entities.dto.shoppingCart.PromotionResultVO;
...@@ -193,6 +195,8 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -193,6 +195,8 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
private StoreItemAdapter storeItemAdapter; private StoreItemAdapter storeItemAdapter;
private static final String limitCartKey = "ecology:kgd:wxappconfig:open_platform_partner_wxapp_config:appkey_"; private static final String limitCartKey = "ecology:kgd:wxappconfig:open_platform_partner_wxapp_config:appkey_";
private static final String activityMutexKey = "kgd:order_activity_mutex_";
// @Value("${saas.cart.sharing}") // @Value("${saas.cart.sharing}")
// private String sharing; // private String sharing;
...@@ -203,13 +207,6 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -203,13 +207,6 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
@Value("${saas.cart.new.shopping.cart}") @Value("${saas.cart.new.shopping.cart}")
private String newShoppingCart; private String newShoppingCart;
// 配送费逻辑是否使用旧的
@Value("${store.delivery.use.old:true}")
private boolean storeDeliveryUseOld;
@Value("${goods.cache.second}")
private long goodsCacheSeconds;
@Autowired @Autowired
private CommonFunctionHandle commonFunctionHandle; private CommonFunctionHandle commonFunctionHandle;
...@@ -389,9 +386,13 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -389,9 +386,13 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
, deliveryAmount, null,bizType, accountFlag,new DiscountSharingDto(),this.getNightDistributionFee(shoppingCartGoodsResponseVo.getDeliveryAmountList())); , deliveryAmount, null,bizType, accountFlag,new DiscountSharingDto(),this.getNightDistributionFee(shoppingCartGoodsResponseVo.getDeliveryAmountList()));
//更新购物车券状态 //更新购物车券状态
newCalculationUpdateCouponStatus(userId, partnerId, storeId, bizType, cartGoods, allCartGoodsList, discountResult); newCalculationUpdateCouponStatus(userId, partnerId, storeId, bizType, cartGoods, allCartGoodsList, discountResult);
sharingCartService.distribute(discountResult, allCartGoodsList, shoppingCartGoodsResponseVo, null
DistributeBo distributeBo = new DistributeBo(discountResult, allCartGoodsList, shoppingCartGoodsResponseVo, null
, userLoginInfoDto, null, activityQueryDto, menuType, deliveryAmount , userLoginInfoDto, null, activityQueryDto, menuType, deliveryAmount
, ShoppingCartConstant.ADD_AND_UPDATE, partnerId, null, userId, storeId,this.getNightDistributionFee(shoppingCartGoodsResponseVo.getDeliveryAmountList())); , ShoppingCartConstant.ADD_AND_UPDATE, partnerId, SubmitPageEnum.NO.getCode(), userId, storeId,,this.getNightDistributionFee(shoppingCartGoodsResponseVo.getDeliveryAmountList()));
distributeBo.setHasCoupon(StringUtils.isNotBlank(couponCode));
sharingCartService.distribute(distributeBo);
buildShoppingCartGoodsResponse(shoppingCartGoodsResponseVo, discountResult, null, partnerId); buildShoppingCartGoodsResponse(shoppingCartGoodsResponseVo, discountResult, null, partnerId);
// //
...@@ -413,10 +414,9 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -413,10 +414,9 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
clearMsg(shoppingCartGoodsResponseVo, cartGoods.getCartGoodsUid()); clearMsg(shoppingCartGoodsResponseVo, cartGoods.getCartGoodsUid());
//设置更新响应信息 //设置更新响应信息
setAddAndUpdateResponse(shoppingCartGoodsResponseVo, calculationDiscountResult, allCartGoodsList, null, partnerId, storeId, userId, ShoppingCartConstant.ADD_AND_UPDATE, null); setAddAndUpdateResponse(shoppingCartGoodsResponseVo, calculationDiscountResult, allCartGoodsList, null, partnerId, SubmitPageEnum.NO.getCode(), appId, ShoppingCartConstant.ADD_AND_UPDATE, StringUtils.isEmpty(addShoppingCartGoodsRequestVo.getCouponCode()),null);
} }
//埋点添加购物车行为 //埋点添加购物车行为
this.buriedPointShoppingCart(addShoppingCartGoodsRequestVo, spuId, productName);
this.shoppingCartAddOrListCommonResponseHandle(shoppingCartGoodsResponseVo); this.shoppingCartAddOrListCommonResponseHandle(shoppingCartGoodsResponseVo);
return ResponseUtil.success(shoppingCartGoodsResponseVo); return ResponseUtil.success(shoppingCartGoodsResponseVo);
} }
...@@ -442,31 +442,6 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -442,31 +442,6 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
} }
} }
/**
* 埋点添加购物车行为
*
* @param addShoppingCartGoodsRequestVo
* @param spuId
* @param productName
*/
private void buriedPointShoppingCart(AddShoppingCartGoodsRequestVo addShoppingCartGoodsRequestVo, String spuId, String productName) {
if (StringUtils.isEmpty(productName)) {
return;
}
List<ShoppingCartSkuAddRequestVo.ShoppingCartSkuProductVo> productVos = Lists.newArrayList();
ShoppingCartSkuAddRequestVo.ShoppingCartSkuProductVo productVo = new ShoppingCartSkuAddRequestVo.ShoppingCartSkuProductVo();
productVo.setProductName(productName);
productVo.setProductId(spuId);
productVo.setSpuId(spuId);
productVos.add(productVo);
BuriedPointShoppingCartRequestDto shoppingCartRequestDto = BuriedPointShoppingCartRequestDto.builder()
.sessionId(addShoppingCartGoodsRequestVo.getSessionId()).partnerId(addShoppingCartGoodsRequestVo.getPartnerId())
.storeId(addShoppingCartGoodsRequestVo.getShopId()).build();
// buriedPointService.buriedPointAddShoppingCart(productVos, shoppingCartRequestDto);
}
/** /**
* 更新商品数量 * 更新商品数量
* *
...@@ -477,7 +452,6 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -477,7 +452,6 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
public BaseResponse updateGoodsQty(UpdateShoppingCartGoodsQtyRequestVo updateShoppingCartGoodsQtyRequestVo) { public BaseResponse updateGoodsQty(UpdateShoppingCartGoodsQtyRequestVo updateShoppingCartGoodsQtyRequestVo) {
if (StringUtils.isEmpty(updateShoppingCartGoodsQtyRequestVo.getShopId())) { if (StringUtils.isEmpty(updateShoppingCartGoodsQtyRequestVo.getShopId())) {
return ResponseUtil.error(ResponseResult.SHOPPING_CART_SHOP_ID_NOT_EMPTY); return ResponseUtil.error(ResponseResult.SHOPPING_CART_SHOP_ID_NOT_EMPTY);
// throw new ServiceException(ResponseResult.SHOPPING_CART_SHOP_ID_NOT_EMPTY);
} }
ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo = new ShoppingCartGoodsResponseVo(); ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo = new ShoppingCartGoodsResponseVo();
CustomerInfoVo assortmentCustomerInfoVo = getCustomerInfoVo(updateShoppingCartGoodsQtyRequestVo.getSessionId()); CustomerInfoVo assortmentCustomerInfoVo = getCustomerInfoVo(updateShoppingCartGoodsQtyRequestVo.getSessionId());
...@@ -499,7 +473,6 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -499,7 +473,6 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
CartGoods cartGoods = assortmentSdkService.getCartGoodsBySdk(partnerId, userId, storeId, cartGoodsUid, "", shoppingCartBaseService,bizType); CartGoods cartGoods = assortmentSdkService.getCartGoodsBySdk(partnerId, userId, storeId, cartGoodsUid, "", shoppingCartBaseService,bizType);
if (cartGoods == null) { if (cartGoods == null) {
return ResponseUtil.error(ResponseResult.SHOPPING_CART_UPDATE_ERROR); return ResponseUtil.error(ResponseResult.SHOPPING_CART_UPDATE_ERROR);
// throw new ServiceException(ResponseResult.SHOPPING_CART_UPDATE_ERROR);
} }
// 检查购物车商品库存数量 // 检查购物车商品库存数量
checkUpdateStock(updateShoppingCartGoodsQtyRequestVo, cartGoods); checkUpdateStock(updateShoppingCartGoodsQtyRequestVo, cartGoods);
...@@ -542,7 +515,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -542,7 +515,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
} }
newCalculationUpdateCouponStatus(userId, partnerId, storeId, bizType, cartGoods, cartGoodsList, discountResult); newCalculationUpdateCouponStatus(userId, partnerId, storeId, bizType, cartGoods, cartGoodsList, discountResult);
sharingCartService.distribute(discountResult DistributeBo distributeBo = new DistributeBo(discountResult
, cartGoodsList , cartGoodsList
, shoppingCartGoodsResponseVo , shoppingCartGoodsResponseVo
, null //入参 , null //入参
...@@ -558,6 +531,8 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -558,6 +531,8 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
, storeId , storeId
,this.getNightDistributionFee(shoppingCartGoodsResponseVo.getDeliveryAmountList())); ,this.getNightDistributionFee(shoppingCartGoodsResponseVo.getDeliveryAmountList()));
sharingCartService.distribute(distributeBo);
buildShoppingCartGoodsResponse(shoppingCartGoodsResponseVo, discountResult, null, partnerId); buildShoppingCartGoodsResponse(shoppingCartGoodsResponseVo, discountResult, null, partnerId);
} else { } else {
// 获取优惠信息 // 获取优惠信息
...@@ -574,7 +549,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -574,7 +549,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
updateShoppingCartGoodsDiscount(null, activityQueryDto, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo, null, userLoginInfoDto, updateShoppingCartGoodsQtyRequestVo.getMenuType(), deliveryAmount, this.getNightDistributionFee(shoppingCartGoodsResponseVo.getDeliveryAmountList())); updateShoppingCartGoodsDiscount(null, activityQueryDto, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo, null, userLoginInfoDto, updateShoppingCartGoodsQtyRequestVo.getMenuType(), deliveryAmount, this.getNightDistributionFee(shoppingCartGoodsResponseVo.getDeliveryAmountList()));
clearMsg(shoppingCartGoodsResponseVo, cartGoodsUid); clearMsg(shoppingCartGoodsResponseVo, cartGoodsUid);
//设置更新响应信息 //设置更新响应信息
setAddAndUpdateResponse(shoppingCartGoodsResponseVo, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo.getToastMsg(), partnerId, storeId, userId, ShoppingCartConstant.ADD_AND_UPDATE, null); setAddAndUpdateResponse(shoppingCartGoodsResponseVo, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo.getToastMsg(), partnerId, SubmitPageEnum.NO.getCode(), appId, ShoppingCartConstant.ADD_AND_UPDATE, false,null);
} }
this.shoppingCartAddOrListCommonResponseHandle(shoppingCartGoodsResponseVo); this.shoppingCartAddOrListCommonResponseHandle(shoppingCartGoodsResponseVo);
...@@ -662,7 +637,6 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -662,7 +637,6 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
public BaseResponse getGoodsList(ShoppingCartInfoRequestVo shoppingCartInfoRequestVo) { public BaseResponse getGoodsList(ShoppingCartInfoRequestVo shoppingCartInfoRequestVo) {
if (StringUtils.isEmpty(shoppingCartInfoRequestVo.getShopId())) { if (StringUtils.isEmpty(shoppingCartInfoRequestVo.getShopId())) {
return ResponseUtil.error(ResponseResult.SHOPPING_CART_SHOP_ID_NOT_EMPTY); return ResponseUtil.error(ResponseResult.SHOPPING_CART_SHOP_ID_NOT_EMPTY);
// throw new ServiceException(ResponseResult.SHOPPING_CART_SHOP_ID_NOT_EMPTY);
} }
if (StringUtils.isEmpty(shoppingCartInfoRequestVo.getVersion())) { if (StringUtils.isEmpty(shoppingCartInfoRequestVo.getVersion())) {
shoppingCartInfoRequestVo.setVersion(""); shoppingCartInfoRequestVo.setVersion("");
...@@ -793,7 +767,8 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -793,7 +767,8 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
, deliveryAmount , deliveryAmount
, null , null
,bizType, accountFlag,new DiscountSharingDto(), this.getNightDistributionFee(shoppingCartGoodsResponseVo.getDeliveryAmountList())); ,bizType, accountFlag,new DiscountSharingDto(), this.getNightDistributionFee(shoppingCartGoodsResponseVo.getDeliveryAmountList()));
sharingCartService.distribute(calculationSharingDiscountResult
DistributeBo distributeBo = new DistributeBo(calculationSharingDiscountResult
, cartGoodsList , cartGoodsList
, shoppingCartGoodsResponseVo , shoppingCartGoodsResponseVo
, shoppingCartInfoRequestVo , shoppingCartInfoRequestVo
...@@ -806,7 +781,10 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -806,7 +781,10 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
, partnerId , partnerId
, shoppingCartInfoRequestVo.getFlag() , shoppingCartInfoRequestVo.getFlag()
, userId , userId
, storeId,this.getNightDistributionFee(shoppingCartGoodsResponseVo.getDeliveryAmountList())); , storeId, this.getNightDistributionFee(shoppingCartGoodsResponseVo.getDeliveryAmountList()));
distributeBo.setHasCoupon(CollectionUtils.isEmpty(coupons));
sharingCartService.distribute(distributeBo);
buildShoppingCartGoodsResponse(shoppingCartGoodsResponseVo, calculationSharingDiscountResult, shoppingCartInfoRequestVo.getFlag(), partnerId); buildShoppingCartGoodsResponse(shoppingCartGoodsResponseVo, calculationSharingDiscountResult, shoppingCartInfoRequestVo.getFlag(), partnerId);
} else { } else {
List<ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon> coupons = new ArrayList<>(); List<ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon> coupons = new ArrayList<>();
...@@ -841,7 +819,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -841,7 +819,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
// 促销活动的优惠金额计算 // 促销活动的优惠金额计算
this.updateShoppingCartGoodsDiscount(couponPromotionVO, activityQueryDto, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo, shoppingCartInfoRequestVo, userLoginInfoDto, shoppingCartInfoRequestVo.getMenuType(), deliveryAmount, nightDistributionFee); this.updateShoppingCartGoodsDiscount(couponPromotionVO, activityQueryDto, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo, shoppingCartInfoRequestVo, userLoginInfoDto, shoppingCartInfoRequestVo.getMenuType(), deliveryAmount, nightDistributionFee);
//设置更新响应信息 //设置更新响应信息
setAddAndUpdateResponse(shoppingCartGoodsResponseVo, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo.getToastMsg(), partnerId, storeId, userId, ShoppingCartConstant.QUERY_INFO, shoppingCartInfoRequestVo); setAddAndUpdateResponse(shoppingCartGoodsResponseVo, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo.getToastMsg(), partnerId, SubmitPageEnum.YES.getCode(), appId, ShoppingCartConstant.QUERY_INFO,CollectionUtils.isEmpty(coupons), shoppingCartInfoRequestVo);
// 在原价、现价、折扣价上增加第一次使用会员卡的费用 // 在原价、现价、折扣价上增加第一次使用会员卡的费用
this.addNeedCardAmount(shoppingCartInfoRequestVo, shoppingCartGoodsResponseVo); this.addNeedCardAmount(shoppingCartInfoRequestVo, shoppingCartGoodsResponseVo);
} }
...@@ -861,7 +839,6 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -861,7 +839,6 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
request.setOrderType(shoppingCartInfoRequestVo.getOrderType()); request.setOrderType(shoppingCartInfoRequestVo.getOrderType());
request.setSessionId(shoppingCartInfoRequestVo.getSessionId()); request.setSessionId(shoppingCartInfoRequestVo.getSessionId());
request.setShopId(shoppingCartInfoRequestVo.getShopId()); request.setShopId(shoppingCartInfoRequestVo.getShopId());
// request.setVersion(shoppingCartInfoRequestVo.getVersion());
if (CollectionUtils.isNotEmpty(shoppingCartInfoRequestVo.getCouponCodes())) { if (CollectionUtils.isNotEmpty(shoppingCartInfoRequestVo.getCouponCodes())) {
List<PremiumExchangeRequestVo.couponCode> list = new ArrayList<>(); List<PremiumExchangeRequestVo.couponCode> list = new ArrayList<>();
shoppingCartInfoRequestVo.getCouponCodes().forEach(code -> { shoppingCartInfoRequestVo.getCouponCodes().forEach(code -> {
...@@ -1173,7 +1150,6 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -1173,7 +1150,6 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
*/ */
if (productService.hasRequiredProducts(partnerId, storeId, cartGoodsList, BusinessTypeEnum.getByType(shoppingCartInfoRequestVo.getMenuType()).getCode())) { if (productService.hasRequiredProducts(partnerId, storeId, cartGoodsList, BusinessTypeEnum.getByType(shoppingCartInfoRequestVo.getMenuType()).getCode())) {
return ResponseUtil.error(ResponseResult.SHOPPING_CART_REQUIRED_PRODUCT_NOT_EXIST); return ResponseUtil.error(ResponseResult.SHOPPING_CART_REQUIRED_PRODUCT_NOT_EXIST);
// throw new ServiceException(ResponseResult.SHOPPING_CART_REQUIRED_PRODUCT_NOT_EXIST);
} }
// check购物车中所有商品(商品是否存在,价格变动,券是否支持当前点餐方式) // check购物车中所有商品(商品是否存在,价格变动,券是否支持当前点餐方式)
...@@ -1194,8 +1170,6 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -1194,8 +1170,6 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
shoppingCartGoodsResponseVo.setToastMsg(cartGoodsResponseVo.getToastMsg()); shoppingCartGoodsResponseVo.setToastMsg(cartGoodsResponseVo.getToastMsg());
} }
cartGoodsList = JSONArray.parseArray(JSONObject.toJSONString(checkCartRequest.getCartGoodsList()), CartGoods.class); cartGoodsList = JSONArray.parseArray(JSONObject.toJSONString(checkCartRequest.getCartGoodsList()), CartGoods.class);
// 多规格的sku商品计算包装费
//this.checkSkuOnVersion(cartGoodsList, partnerId, storeId, shoppingCartGoodsResponseVo);
// 重新存储最新购物车 // 重新存储最新购物车
assortmentSdkService.setShoppingCart(partnerId, storeId, userId, cartGoodsList, assortmentCustomerInfoVo.getSessionId(), tableNumber, this.shoppingCartBaseService,bizType); assortmentSdkService.setShoppingCart(partnerId, storeId, userId, cartGoodsList, assortmentCustomerInfoVo.getSessionId(), tableNumber, this.shoppingCartBaseService,bizType);
...@@ -1296,7 +1270,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -1296,7 +1270,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
updateShoppingCartGoodsDiscount(couponPromotionVO, activityQueryDto, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo, shoppingCartInfoRequestVo, userLoginInfoDto, shoppingCartInfoRequestVo.getMenuType(), deliveryAmount, this.getNightDistributionFee(shoppingCartGoodsResponseVo.getDeliveryAmountList())); updateShoppingCartGoodsDiscount(couponPromotionVO, activityQueryDto, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo, shoppingCartInfoRequestVo, userLoginInfoDto, shoppingCartInfoRequestVo.getMenuType(), deliveryAmount, this.getNightDistributionFee(shoppingCartGoodsResponseVo.getDeliveryAmountList()));
//设置更新响应信息 //设置更新响应信息
setAddAndUpdateResponse(shoppingCartGoodsResponseVo, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo.getToastMsg(), partnerId, storeId, userId, ShoppingCartConstant.QUERY_INFO, shoppingCartInfoRequestVo); setAddAndUpdateResponse(shoppingCartGoodsResponseVo, calculationDiscountResult, cartGoodsList, shoppingCartGoodsResponseVo.getToastMsg(), partnerId, SubmitPageEnum.YES.getCode(), appId, ShoppingCartConstant.QUERY_INFO, CollectionUtils.isEmpty(coupons),shoppingCartInfoRequestVo);
//设置均摊信息 //设置均摊信息
updateShoppingCartGoodsApportion(shoppingCartGoodsResponseVo, calculationDiscountResult, shoppingCartGoodsDto, premiumExchangeActivity, shoppingCartInfoRequestVo); updateShoppingCartGoodsApportion(shoppingCartGoodsResponseVo, calculationDiscountResult, shoppingCartGoodsDto, premiumExchangeActivity, shoppingCartInfoRequestVo);
...@@ -1633,11 +1607,6 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -1633,11 +1607,6 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
cartGoods.setSpuName(checkSpqInfoResponseDto.getCouponName()); cartGoods.setSpuName(checkSpqInfoResponseDto.getCouponName());
} }
cartGoods.setStockLimit(checkSpqInfoResponseDto.isStockLimit()); cartGoods.setStockLimit(checkSpqInfoResponseDto.isStockLimit());
//逻辑同 viewProductName
// if (GoodsTypeEnum.BUY_M_SEND_N_COUPON.getGoodsType().equals(cartGoods.getGoodsType())) {
// cartGoods.setName(checkSpqInfoResponseDto.getSkuName());
// cartGoods.setSpuName(checkSpqInfoResponseDto.getSpuName());
// }
//添加请求的优惠券信息 买M赠N券,不重复加促销券集合字段 //添加请求的优惠券信息 买M赠N券,不重复加促销券集合字段
String finalCouponCode = couponCode; String finalCouponCode = couponCode;
List<ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon> collect = coupons.stream().filter(calculationDiscountCoupon -> Objects.equals(calculationDiscountCoupon.getCode(), finalCouponCode)).collect(toList()); List<ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon> collect = coupons.stream().filter(calculationDiscountCoupon -> Objects.equals(calculationDiscountCoupon.getCode(), finalCouponCode)).collect(toList());
...@@ -1750,25 +1719,6 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -1750,25 +1719,6 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
} }
/**
* 将calculationDiscountGoods 封装后加入 calculationDiscountGoodsList
*
* @param calculationDiscountGoodsList
* @param goodsId
* @param goodsQuantity
* @param originalPrice
*/
// private void addCalculationDiscountGoods(List<ActivityCalculationDiscountRequestDto.CalculationDiscountGoods> calculationDiscountGoodsList,
// String goodsId, Integer goodsQuantity, Long originalPrice, Integer memberDiscount, String cartGoodsUid) {
// ActivityCalculationDiscountRequestDto.CalculationDiscountGoods calculationDiscountGoods = new ActivityCalculationDiscountRequestDto.CalculationDiscountGoods();
// calculationDiscountGoods.setGoodsId(goodsId);
// calculationDiscountGoods.setCartGoodsUid(cartGoodsUid);
// calculationDiscountGoods.setGoodsQuantity(goodsQuantity);
// calculationDiscountGoods.setOriginalPrice(originalPrice);
// calculationDiscountGoods.setMemberDiscount(memberDiscount);
// this.addCalculationDiscountGoods(calculationDiscountGoodsList, calculationDiscountGoods);
// }
private void addCalculationDiscountGoods(List<ActivityCalculationDiscountRequestDto.CalculationDiscountGoods> calculationDiscountGoodsList private void addCalculationDiscountGoods(List<ActivityCalculationDiscountRequestDto.CalculationDiscountGoods> calculationDiscountGoodsList
, String goodsId , String goodsId
, Integer goodsQuantity , Integer goodsQuantity
...@@ -2377,17 +2327,9 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -2377,17 +2327,9 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
* 组装添加商品和更新商品和查询的响应信息 * 组装添加商品和更新商品和查询的响应信息
* <p> * <p>
* 查询购物车计算包装费 * 查询购物车计算包装费
*
* @param shoppingCartGoodsResponseVo
* @param calculationDiscountResult
* @param cartGoodsList
* @param toastMsg
* @param userId
* @param opt
* @param shoppingCartInfoRequestVo
*/ */
private void setAddAndUpdateResponse(ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo, CalculationDiscountResult calculationDiscountResult private void setAddAndUpdateResponse(ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo, CalculationDiscountResult calculationDiscountResult
, List<CartGoods> cartGoodsList, String toastMsg, String partnerId, String storeId, String userId, String opt, ShoppingCartInfoRequestVo shoppingCartInfoRequestVo) { , List<CartGoods> cartGoodsList, String toastMsg, String partnerId, Integer flag, String appId, String opt, boolean hasCoupon,ShoppingCartInfoRequestVo shoppingCartInfoRequestVo) {
shoppingCartGoodsResponseVo.setProducts(cartGoodsList); shoppingCartGoodsResponseVo.setProducts(cartGoodsList);
shoppingCartGoodsResponseVo.setProductsCount(cartGoodsList.size()); shoppingCartGoodsResponseVo.setProductsCount(cartGoodsList.size());
if (StringUtils.isNotEmpty(toastMsg)) { if (StringUtils.isNotEmpty(toastMsg)) {
...@@ -2400,8 +2342,14 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -2400,8 +2342,14 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
} }
} }
// 更新和添加商品时不需要包装费 boolean addOrUpdate = false;
if (ShoppingCartConstant.ADD_AND_UPDATE.equals(opt)) { if (ShoppingCartConstant.ADD_AND_UPDATE.equals(opt)) {
addOrUpdate = true;
}
//活动互斥提示
setActivityMutexToastMsg(calculationDiscountResult,flag,partnerId,appId,hasCoupon,addOrUpdate,shoppingCartGoodsResponseVo);
// 更新和添加商品时不需要包装费
if (addOrUpdate) {
shoppingCartGoodsResponseVo.setNewPackAmount(null); shoppingCartGoodsResponseVo.setNewPackAmount(null);
return; return;
} }
...@@ -2498,7 +2446,6 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -2498,7 +2446,6 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
return; return;
} }
Integer orderAmount = shoppingCartGoodsResponseVo.getTotalAmount().intValue(); Integer orderAmount = shoppingCartGoodsResponseVo.getTotalAmount().intValue();
String trackingNo = LogThreadLocal.getTrackingNo();
SVCCardAmountRequest request = new SVCCardAmountRequest(); SVCCardAmountRequest request = new SVCCardAmountRequest();
request.setPartnerId(partnerId); request.setPartnerId(partnerId);
request.setCardCodes(Arrays.asList(cardCode)); request.setCardCodes(Arrays.asList(cardCode));
...@@ -2523,7 +2470,6 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -2523,7 +2470,6 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
Integer deliveryAmount = 0; Integer deliveryAmount = 0;
Integer svcPayAmount = 0; Integer svcPayAmount = 0;
if (StringUtils.isNotBlank(receiveId) && shoppingCartGoodsResponseVo.getDiscountDeliveryAmount() != null) { if (StringUtils.isNotBlank(receiveId) && shoppingCartGoodsResponseVo.getDiscountDeliveryAmount() != null) {
//Integer deliveryAmount = getDeliveryAmount(receiveId, partnerId, storeId);
deliveryAmount = shoppingCartGoodsResponseVo.getDiscountDeliveryAmount().intValue(); deliveryAmount = shoppingCartGoodsResponseVo.getDiscountDeliveryAmount().intValue();
orderAmount += deliveryAmount; orderAmount += deliveryAmount;
} }
...@@ -2567,7 +2513,6 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -2567,7 +2513,6 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
return; return;
} }
Integer orderAmount = shoppingCartGoodsResponseVo.getTotalAmount().intValue(); Integer orderAmount = shoppingCartGoodsResponseVo.getTotalAmount().intValue();
String trackingNo = LogThreadLocal.getTrackingNo();
SVCCardAmountRequest request = new SVCCardAmountRequest(); SVCCardAmountRequest request = new SVCCardAmountRequest();
request.setPartnerId(partnerId); request.setPartnerId(partnerId);
request.setCardCodes(Arrays.asList(cardCode)); request.setCardCodes(Arrays.asList(cardCode));
...@@ -2624,63 +2569,6 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -2624,63 +2569,6 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
} }
} }
/**
* 储值卡支付查询配送费
*
* @return
*/
private Integer getDeliveryAmount(String receiveId, String partnerId, String storeId) {
String trackingNo = LogThreadLocal.getTrackingNo();
Integer amount = 0;
if (StringUtils.isBlank(receiveId)) {
return amount;
}
QueryReceiveAddressRequest queryReceive = new QueryReceiveAddressRequest(receiveId, partnerId);
//查询会员后货地址经纬度
com.freemud.application.sdk.api.base.BaseResponse<QueryReceiveAddressResponse> queryReceiveAddressResponse = memberCenterService.queryReceiveAddressById(queryReceive, trackingNo);
if (!ResponseResult.SUCCESS.getCode().equals(queryReceiveAddressResponse.getCode()) || queryReceiveAddressResponse.getData() == null) {
throw new ServiceException(ResponseResult.USER_GETRECEIVEADDRESS_ERROR);
}
StoreInfoRequest request = new StoreInfoRequest();
request.setPartnerId(partnerId);
request.setStoreCode(storeId);
//查询门店信息,获取门店经纬度
StoreResponse storeResponse = storeCenterService.getStoreInfo(request, trackingNo);
if (storeResponse == null || storeResponse.getStatusCode() != 100 || storeResponse.getBizVO() == null) {
throw new ServiceException(ResponseResult.STORE_NOT_FOUND);
}
//查询门店外卖配送配置
AssortmentOpenPlatformPartnerStoreDeliveryConfig deliveryConfig = deliveryConfigManager.findByPartnerIdAndStoreCode(partnerId, storeId);
if (deliveryConfig == null) {
throw new ServiceException(ResponseResult.STORE_ITEM_NOT_DELIVERY);
}
StoreDeliveryInfoDto storeDeliveryInfoDto = new StoreDeliveryInfoDto();
storeDeliveryInfoDto.setPartnerId(partnerId);
storeDeliveryInfoDto.setStoreId(storeId);
storeDeliveryInfoDto.setStoreName(storeResponse.getBizVO().getStoreName());
storeDeliveryInfoDto.setDeliveryLimitAmount(deliveryConfig == null ? 0 : deliveryConfig.getDeliveryLimitAmount());
storeDeliveryInfoDto.setDeliveryAmount(deliveryConfig == null ? 0 : deliveryConfig.getDeliveryAmount());
storeDeliveryInfoDto.setDefaultDeliveryRange(deliveryConfig == null ? 0L : deliveryConfig.getDefaultDeliveryRange());
storeDeliveryInfoDto.setAddRangeAmount(deliveryConfig == null ? 0L : deliveryConfig.getAddRangeAmount());
storeDeliveryInfoDto.setAddRangeCount(deliveryConfig == null ? 0L : deliveryConfig.getAddRangeCount());
storeDeliveryInfoDto.setPoint2DList(getDeliveryPoint2DList(storeResponse.getBizVO().getDistributionScope()));
storeDeliveryInfoDto.setDeliveryHoursDay(storeResponse.getBizVO().getDeliveryHoursDay());
storeDeliveryInfoDto.setLongitude(storeResponse.getBizVO().getLongitude());
storeDeliveryInfoDto.setLatitude(storeResponse.getBizVO().getLatitude());
storeDeliveryInfoDto.setScopeConfig(storeResponse.getBizVO().getScopeConfig());
if (StringUtils.isNotEmpty(storeResponse.getBizVO().getDeliveryRadius())) {
storeDeliveryInfoDto.setDeliveryRadius(Integer.valueOf(storeResponse.getBizVO().getDeliveryRadius()));
} else {
storeDeliveryInfoDto.setDeliveryRadius(0);
}
storeDeliveryInfoDto.setEnableTakeaway(true);
String userLongitude = queryReceiveAddressResponse.getData().getLongitude();
String userLatitude = queryReceiveAddressResponse.getData().getLatitude();
amount = storeService.getUserRealDeliveryAmount(storeDeliveryInfoDto, userLongitude, userLatitude).intValue();
return amount;
}
private Long getNewDeliveryAmount(String receiveId, String partnerId, String storeId, ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo, Integer orderType) { private Long getNewDeliveryAmount(String receiveId, String partnerId, String storeId, ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo, Integer orderType) {
//String trackingNo = LogThreadLocal.getTrackingNo(); //String trackingNo = LogThreadLocal.getTrackingNo();
Long amount = 0L; Long amount = 0L;
...@@ -2697,30 +2585,6 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -2697,30 +2585,6 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
} }
/** /**
* 获取配送范围内集合
*/
public List<Point2D.Double> getDeliveryPoint2DList(String distributionScope) {
if (StringUtils.isBlank(distributionScope)) {
return Collections.emptyList();
}
/**
* 如果点不为整数,返回空
*/
String[] points = distributionScope.split(",");
if (points.length % 2 != 0) {
return Collections.emptyList();
}
List<String> pointList = Arrays.asList(points);
List<Point2D.Double> point2DList = Lists.newArrayList();
for (int i = 0; i < pointList.size(); i++) {
Double pointX = Double.parseDouble(pointList.get(i));
Double pointY = Double.parseDouble(pointList.get(++i));
point2DList.add(new Point2D.Double(pointX, pointY));
}
return point2DList;
}
/**
* 获取优惠 * 获取优惠
*/ */
private CalculationDiscountResult getCalculationDiscountResult(String menuType private CalculationDiscountResult getCalculationDiscountResult(String menuType
...@@ -2728,16 +2592,11 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -2728,16 +2592,11 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
, List<CartGoods> cartGoodsList, List<ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon> coupons , List<CartGoods> cartGoodsList, List<ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon> coupons
, List<ShoppingCartInfoRequestVo.SendGoods> sendGoodsList, String receiveId, Long deliveryAmount,Integer bizType, Integer accountFlag, long nightDistributionFee) { , List<ShoppingCartInfoRequestVo.SendGoods> sendGoodsList, String receiveId, Long deliveryAmount,Integer bizType, Integer accountFlag, long nightDistributionFee) {
// 获取优惠信息 // 获取优惠信息
CalculationDiscountResult calculationDiscountResult = null; if (!BusinessTypeEnum.SAAS_DELIVERY.getCode().equals(menuType)) {
//外卖场景下 查询门店配送信息 deliveryAmount = null;
if (BusinessTypeEnum.SAAS_DELIVERY.getCode().equals(menuType)) { nightDistributionFee= 0L;
calculationDiscountResult = this.getActivityCalculationDiscountResponse(partnerId, storeId, userId, appId, orderType, isMember, cartGoodsList, coupons, sendGoodsList, BusinessTypeEnum.getByType(menuType).getCode(), deliveryAmount,bizType, accountFlag, nightDistributionFee);
} else {
calculationDiscountResult = this.getActivityCalculationDiscountResponse(partnerId, storeId, userId, appId, orderType, isMember, cartGoodsList, coupons, sendGoodsList, BusinessTypeEnum.getByType(menuType).getCode(), null,bizType, accountFlag, 0L);
} }
return this.getActivityCalculationDiscountResponse(partnerId, storeId, userId, appId, orderType, isMember, cartGoodsList, coupons, sendGoodsList, BusinessTypeEnum.getByType(menuType).getCode(), deliveryAmount,bizType, accountFlag, nightDistributionFee);
return calculationDiscountResult;
} }
public Long calculateDeliveryAmount(String receiveId, String partnerId, String storeId, String wxappid, ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo, Integer orderType) { public Long calculateDeliveryAmount(String receiveId, String partnerId, String storeId, String wxappid, ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo, Integer orderType) {
...@@ -2747,12 +2606,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -2747,12 +2606,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
if (StringUtils.isBlank(receiveId) && !Objects.equals(orderType, CreateOrderType.TAKE_OUT.getCode())) { if (StringUtils.isBlank(receiveId) && !Objects.equals(orderType, CreateOrderType.TAKE_OUT.getCode())) {
return deliveryAmount; return deliveryAmount;
} }
if (storeDeliveryUseOld) {
deliveryAmount = Long.parseLong(getDeliveryAmount(receiveId, partnerId, storeId).toString());
shoppingCartGoodsResponseVo.setDeliveryFeeZeroReason(0);
} else {
deliveryAmount = getNewDeliveryAmount(receiveId, partnerId, storeId, shoppingCartGoodsResponseVo, orderType); deliveryAmount = getNewDeliveryAmount(receiveId, partnerId, storeId, shoppingCartGoodsResponseVo, orderType);
}
return deliveryAmount; return deliveryAmount;
} }
...@@ -2814,7 +2668,6 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -2814,7 +2668,6 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
if (StringUtils.isBlank(newSharing)) return true; if (StringUtils.isBlank(newSharing)) return true;
CalculateCenter center = JSON.parseObject(newSharing, CalculateCenter.class); CalculateCenter center = JSON.parseObject(newSharing, CalculateCenter.class);
Boolean enable = true; Boolean enable = true;
// if (!center.getEnable()) return false;
switch (center.getType()) { switch (center.getType()) {
case 2: case 2:
enable = true; enable = true;
...@@ -2831,9 +2684,6 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -2831,9 +2684,6 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
} }
} }
} }
// if (center.getEnable() && enable) {
// enable = true;
// }
ApiLog.infoMessage("判断是否进入新算价 " +DateUtil.convert2String(new Date(), "yyyy-MM-dd HH:mm:ss")+" " +newSharing ApiLog.infoMessage("判断是否进入新算价 " +DateUtil.convert2String(new Date(), "yyyy-MM-dd HH:mm:ss")+" " +newSharing
+" "+partnerId+" "+storeId+" "+enable); +" "+partnerId+" "+storeId+" "+enable);
...@@ -2907,41 +2757,6 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -2907,41 +2757,6 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
if (StringUtils.isNotBlank(value)) { if (StringUtils.isNotBlank(value)) {
return Integer.parseInt(value); return Integer.parseInt(value);
} }
// String redisKey = limitCartKey + appid;
// //生态缓存获取慢
// Object value = redisCache.hashGet(redisKey, "2");
// if (value == null) {
// return qty;
// } else {
// boolean bool = value.getClass().getName().equals("java.lang.String");
// if (bool) {
// return qty;
// }
// JSONArray jsonArray = (JSONArray) value;
// int cartLimitFlag = 0;
// int cartLimitCount = 0;
// for (Object object : jsonArray) {
// JSONObject jsonObject = (JSONObject) object;
// HashMap hashMap = JSONObject.parseObject(jsonObject.toJSONString(), HashMap.class);
// if ("cartLimitFlag".equals(hashMap.get("appKey"))) {
// if (StringUtils.isBlank((String) hashMap.get("appValue"))) {
// return qty;
// }
// cartLimitFlag = Integer.parseInt((String) hashMap.get("appValue"));
// if (cartLimitFlag != 1) {
// return qty;
// }
// }
// if ("cartLimitCount".equals(hashMap.get("appKey"))) {
// if (StringUtils.isBlank((String) hashMap.get("appValue"))) {
// return qty;
// }
// cartLimitCount = Integer.parseInt((String) hashMap.get("appValue"));
// return cartLimitCount;
// }
// }
// }
return limitCount; return limitCount;
} }
...@@ -3393,7 +3208,6 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -3393,7 +3208,6 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
if (StringUtils.isEmpty(replaceGoodsRequestVo.getShopId()) if (StringUtils.isEmpty(replaceGoodsRequestVo.getShopId())
|| StringUtils.isEmpty(replaceGoodsRequestVo.getOldShopId())) { || StringUtils.isEmpty(replaceGoodsRequestVo.getOldShopId())) {
return ResponseUtil.error(ResponseResult.SHOPPING_CART_SHOP_ID_NOT_EMPTY); return ResponseUtil.error(ResponseResult.SHOPPING_CART_SHOP_ID_NOT_EMPTY);
// throw new ServiceException(ResponseResult.SHOPPING_CART_SHOP_ID_NOT_EMPTY);
} }
if (replaceGoodsRequestVo.getShopId().equals(replaceGoodsRequestVo.getOldShopId())) { if (replaceGoodsRequestVo.getShopId().equals(replaceGoodsRequestVo.getOldShopId())) {
return ResponseUtil.success(); return ResponseUtil.success();
...@@ -3476,38 +3290,38 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -3476,38 +3290,38 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
return ret; return ret;
} }
private void queryManyGoodsStocks(String menuType, String partnerId, String shopId, List<Long> productIds, List<ProductBean> productBeanListSpuClass, String skuId, Integer qty) { // private void queryManyGoodsStocks(String menuType, String partnerId, String shopId, List<Long> productIds, List<ProductBean> productBeanListSpuClass, String skuId, Integer qty) {
GetProductStockRequestDto requestDto = new GetProductStockRequestDto(); // GetProductStockRequestDto requestDto = new GetProductStockRequestDto();
requestDto.setChannel(BusinessTypeEnum.getByType(menuType).getCode()); // requestDto.setChannel(BusinessTypeEnum.getByType(menuType).getCode());
requestDto.setPartnerId(partnerId); // requestDto.setPartnerId(partnerId);
requestDto.setStoreId(shopId); // requestDto.setStoreId(shopId);
requestDto.setProductIds(productIds); // requestDto.setProductIds(productIds);
//
GetProductStockResponseDto availableStocks = null; // GetProductStockResponseDto availableStocks = null;
if (productBeanListSpuClass.get(0).getType() == ProductType.NOSPEC.getCode() // if (productBeanListSpuClass.get(0).getType() == ProductType.NOSPEC.getCode()
&& productBeanListSpuClass.get(0).getStockLimit() == 1) { // && productBeanListSpuClass.get(0).getStockLimit() == 1) {
availableStocks = stockClient.getAvailableStocks(requestDto); // availableStocks = stockClient.getAvailableStocks(requestDto);
} else { // } else {
for (SkuProductBean skuProductBean : productBeanListSpuClass.get(0).getSkuList()) { // for (SkuProductBean skuProductBean : productBeanListSpuClass.get(0).getSkuList()) {
if (skuId.equals(skuProductBean.getSkuId()) && skuProductBean.getStockLimit() == 1) { // if (skuId.equals(skuProductBean.getSkuId()) && skuProductBean.getStockLimit() == 1) {
availableStocks = stockClient.getAvailableStocks(requestDto); // availableStocks = stockClient.getAvailableStocks(requestDto);
break; // break;
} // }
} // }
} // }
if (availableStocks != null && !ResponseCodeConstant.RESPONSE_SUCCESS_STR.equals(availableStocks.getCode())) { // if (availableStocks != null && !ResponseCodeConstant.RESPONSE_SUCCESS_STR.equals(availableStocks.getCode())) {
throw new ServiceException(ResponseResult.SHOPPING_CART_STOCK_NOT_HAVE); // throw new ServiceException(ResponseResult.SHOPPING_CART_STOCK_NOT_HAVE);
} // }
if (availableStocks != null && ResponseCodeConstant.RESPONSE_SUCCESS_STR.equals(availableStocks.getCode()) && // if (availableStocks != null && ResponseCodeConstant.RESPONSE_SUCCESS_STR.equals(availableStocks.getCode()) &&
(CollectionUtils.isEmpty(availableStocks.getResult()) || availableStocks.getResult().get(0).getQty() == null // (CollectionUtils.isEmpty(availableStocks.getResult()) || availableStocks.getResult().get(0).getQty() == null
|| availableStocks.getResult().get(0).getQty() < qty)) { // || availableStocks.getResult().get(0).getQty() < qty)) {
Integer stock = 0; // Integer stock = 0;
if (!CollectionUtils.isEmpty(availableStocks.getResult()) && (stock = availableStocks.getResult().get(0).getQty()) > 0) { // if (!CollectionUtils.isEmpty(availableStocks.getResult()) && (stock = availableStocks.getResult().get(0).getQty()) > 0) {
throw new BizServiceException(ResponseResult.SHOPPING_CART_STOCK_NOT_HAVE, "仅剩" + stock + "件库存了"); // throw new BizServiceException(ResponseResult.SHOPPING_CART_STOCK_NOT_HAVE, "仅剩" + stock + "件库存了");
} // }
throw new ServiceException(ResponseResult.SHOPPING_CART_STOCK_NOT_HAVE); // throw new ServiceException(ResponseResult.SHOPPING_CART_STOCK_NOT_HAVE);
} // }
} // }
private boolean updateCartGoodsLegal(List<CartGoods> excludeGoods, String userId, ShopGoodsReplaceVo replaceGoodsRequestVo, ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo, boolean fullReplace) { private boolean updateCartGoodsLegal(List<CartGoods> excludeGoods, String userId, ShopGoodsReplaceVo replaceGoodsRequestVo, ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo, boolean fullReplace) {
...@@ -3609,4 +3423,60 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -3609,4 +3423,60 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
return false; return false;
} }
/**
* 活动互斥提示
*/
public void setActivityMutexToastMsg(CalculationDiscountResult calculationDiscountResult,Integer flag,String partnerId,String appid,
boolean hasCoupon,boolean addOrUpdate,ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo){
String toastMsg = "";
if(calculationDiscountResult == null || CollectionUtils.isEmpty(calculationDiscountResult.getExclusiveActivityList())){
return;
}
//优惠互斥提示开关
String redisKey = RedisUtil.activityMutexKey + partnerId + "_" + appid;
//购物车内部缓存
String value = redisCache.hashGet(redisKey, "activityMutexType");
if (StringUtils.isNotBlank(value)) {
return;
}
ActivityMutexConfig config = JSONObject.parseObject(value,ActivityMutexConfig.class);
if("0".equals(config.getActivityMutex())){
return;
}
//点餐页 添加购物车/更新购物车,(活动与活动互斥,活动与优惠券互斥)
if(ObjectUtils.equals(SubmitPageEnum.NO.getCode(), flag) && addOrUpdate && "1".equals(config.getActivityMutex())){
if(CollectionUtils.isNotEmpty(calculationDiscountResult.getCouponDiscounts())
&& calculationDiscountResult.getCouponDiscounts().get(0).getPromotionSharing() == 1){//是否与促销活动共享 0不同享 1同享
if(calculationDiscountResult.getExclusiveActivityList().size() >1 ){
toastMsg = "多个促销活动不同享 活动商品优惠发生变化";
}else {
toastMsg = "优惠券与其他促销活动不同享 活动商品优惠发生变化";
}
}
if(CollectionUtils.isNotEmpty(calculationDiscountResult.getDiscounts())){
if(calculationDiscountResult.getExclusiveActivityList().size() >1 ){
toastMsg = "多个促销活动不同享 活动商品优惠发生变化";
}else {
String activityName = calculationDiscountResult.getExclusiveActivityList().get(0).getActivityTypeName();
Integer type = calculationDiscountResult.getDiscounts().get(0).getType();
String name = ActivityTypeEnum.getByCode(type).getDesc();
toastMsg = name +"与"+ activityName + "活动不同享 活动商品优惠发生变化";
}
}
}
//结算页查询购物车 带优惠券 (优惠券与活动互斥)
// if(ObjectUtils.equals(SubmitPageEnum.YES.getCode(), flag) && hasCoupon && "1".equals(config.getCouponactivityMutex())){
// toastMsg = "优惠券与其他促销活动不同享 活动商品优惠发生变化";
// }
if(StringUtils.isNotEmpty(toastMsg) && StringUtils.isEmpty(shoppingCartGoodsResponseVo.getToastMsg())){
shoppingCartGoodsResponseVo.setToastMsg(toastMsg);
}
}
} }
...@@ -9,16 +9,18 @@ import cn.freemud.entities.dto.GetPaidRuleResponseDto; ...@@ -9,16 +9,18 @@ import cn.freemud.entities.dto.GetPaidRuleResponseDto;
import cn.freemud.entities.dto.activity.ActivityDiscountsDto; import cn.freemud.entities.dto.activity.ActivityDiscountsDto;
import cn.freemud.entities.dto.calculate.*; import cn.freemud.entities.dto.calculate.*;
import cn.freemud.entities.dto.order.PackAmountConfig; import cn.freemud.entities.dto.order.PackAmountConfig;
import cn.freemud.entities.dto.shoppingCart.ActivityMutexConfig;
import cn.freemud.entities.dto.shoppingCart.ShoppingCartGoodsDto; import cn.freemud.entities.dto.shoppingCart.ShoppingCartGoodsDto;
import cn.freemud.entities.vo.CartGoods; import cn.freemud.entities.vo.CartGoods;
import cn.freemud.entities.vo.ShoppingCartGoodsResponseVo; import cn.freemud.entities.vo.ShoppingCartGoodsResponseVo;
import cn.freemud.entities.vo.ShoppingCartInfoRequestVo; import cn.freemud.entities.vo.ShoppingCartInfoRequestVo;
import cn.freemud.enums.*; import cn.freemud.enums.*;
import cn.freemud.handle.CommonFunctionHandle; import cn.freemud.handle.CommonFunctionHandle;
import cn.freemud.redis.RedisCache;
import cn.freemud.service.thirdparty.CustomerApplicationClient; import cn.freemud.service.thirdparty.CustomerApplicationClient;
import cn.freemud.utils.BeanUtil; import cn.freemud.utils.BeanUtil;
import lombok.Data; import cn.freemud.utils.RedisUtil;
import lombok.NoArgsConstructor; import com.alibaba.fastjson.JSONObject;
import ma.glasnost.orika.MapperFacade; import ma.glasnost.orika.MapperFacade;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang.ObjectUtils; import org.apache.commons.lang.ObjectUtils;
...@@ -63,6 +65,9 @@ public class CalculationCommonService { ...@@ -63,6 +65,9 @@ public class CalculationCommonService {
@Autowired @Autowired
private CommonFunctionHandle commonFunctionHandle; private CommonFunctionHandle commonFunctionHandle;
@Autowired
private RedisCache redisCache;
/** /**
* 初始化价格 新算价走了 * 初始化价格 新算价走了
*/ */
...@@ -291,6 +296,9 @@ public class CalculationCommonService { ...@@ -291,6 +296,9 @@ public class CalculationCommonService {
shoppingCartGoodsResponseVo.setToastMsg(CollectionUtils.isEmpty(cartGoodsList) ? toastMsg : ""); shoppingCartGoodsResponseVo.setToastMsg(CollectionUtils.isEmpty(cartGoodsList) ? toastMsg : "");
} }
} }
// 更新和添加商品时不需要包装费 // 更新和添加商品时不需要包装费
if (ShoppingCartConstant.ADD_AND_UPDATE.equals(opt)) { if (ShoppingCartConstant.ADD_AND_UPDATE.equals(opt)) {
shoppingCartGoodsResponseVo.setNewPackAmount(null); shoppingCartGoodsResponseVo.setNewPackAmount(null);
...@@ -619,10 +627,10 @@ public class CalculationCommonService { ...@@ -619,10 +627,10 @@ public class CalculationCommonService {
* @param discounts * @param discounts
* @return * @return
*/ */
private List<ActivityDiscountsDto> drawSmallDiscount(List<Discounts> discounts) { private List<ActivityDiscountsDto> drawSmallDiscount(List<BlockRowDiscount> discounts) {
List<ActivityDiscountsDto> activityDiscountsDto = new ArrayList<>(); List<ActivityDiscountsDto> activityDiscountsDto = new ArrayList<>();
if (CollectionUtils.isEmpty(discounts)) return activityDiscountsDto; if (CollectionUtils.isEmpty(discounts)) return activityDiscountsDto;
for (Discounts discount : discounts) { for (BlockRowDiscount discount : discounts) {
ActivityDiscountsDto dto = new ActivityDiscountsDto(); ActivityDiscountsDto dto = new ActivityDiscountsDto();
dto.setActivityName(discount.getActivityName()); dto.setActivityName(discount.getActivityName());
dto.setActivityType(discount.getType()); dto.setActivityType(discount.getType());
...@@ -658,10 +666,10 @@ public class CalculationCommonService { ...@@ -658,10 +666,10 @@ public class CalculationCommonService {
blockRow.setGoodsQuantity(gx.getGoodsQuantity()); blockRow.setGoodsQuantity(gx.getGoodsQuantity());
blockRow.setOriginalPrice(gx.getOriginalPrice()); blockRow.setOriginalPrice(gx.getOriginalPrice());
blockRow.setRealAmount(gx.getRealAmount()); blockRow.setRealAmount(gx.getRealAmount());
List<Discounts> discounts = new ArrayList<>(); List<BlockRowDiscount> discounts = new ArrayList<>();
if (CollectionUtils.isNotEmpty(gx.getDiscounts())) { if (CollectionUtils.isNotEmpty(gx.getDiscounts())) {
for (GoodsDiscount ds : gx.getDiscounts()) { for (GoodsDiscount ds : gx.getDiscounts()) {
Discounts discount = new Discounts(); BlockRowDiscount discount = new BlockRowDiscount();
discount.setActivityCode(ds.getActivityCode()); discount.setActivityCode(ds.getActivityCode());
discount.setActivityDesc(ds.getActivityDesc()); discount.setActivityDesc(ds.getActivityDesc());
discount.setActivityName(ds.getActivityName()); discount.setActivityName(ds.getActivityName());
...@@ -689,10 +697,10 @@ public class CalculationCommonService { ...@@ -689,10 +697,10 @@ public class CalculationCommonService {
blockRow.setGoodsQuantity(sm.getGoodsQuantity()); blockRow.setGoodsQuantity(sm.getGoodsQuantity());
blockRow.setOriginalPrice(sm.getOriginalPrice()); blockRow.setOriginalPrice(sm.getOriginalPrice());
blockRow.setRealAmount(sm.getRealAmount()); blockRow.setRealAmount(sm.getRealAmount());
List<Discounts> discounts = new ArrayList<>(); List<BlockRowDiscount> discounts = new ArrayList<>();
if (CollectionUtils.isNotEmpty(sm.getDiscounts())) { if (CollectionUtils.isNotEmpty(sm.getDiscounts())) {
for (GoodsDiscount ds : sm.getDiscounts()) { for (GoodsDiscount ds : sm.getDiscounts()) {
Discounts discount = new Discounts(); BlockRowDiscount discount = new BlockRowDiscount();
discount.setActivityCode(ds.getActivityCode()); discount.setActivityCode(ds.getActivityCode());
discount.setActivityDesc(ds.getActivityDesc()); discount.setActivityDesc(ds.getActivityDesc());
discount.setActivityName(ds.getActivityName()); discount.setActivityName(ds.getActivityName());
...@@ -775,27 +783,62 @@ public class CalculationCommonService { ...@@ -775,27 +783,62 @@ public class CalculationCommonService {
return code; return code;
} }
@Data
@NoArgsConstructor
public static class BlockRow {
private Integer discountAmount;
private List<Discounts> discounts;
private String goodsId;
private Integer goodsQuantity;
private Integer originalPrice;
private Integer realAmount;
private Integer type;
}
@Data /**
@NoArgsConstructor * 活动互斥提示
public static class Discounts { */
private String activityCode; public void setActivityMutexToastMsg(CalculationDiscountResult calculationDiscountResult,Integer flag,String partnerId,String appid,
private String activityDesc; boolean hasCoupon,boolean addOrUpdate,ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo){
private String activityName;
private Integer actualGoodsNumber; String toastMsg = "";
private Long discount; if(calculationDiscountResult == null || CollectionUtils.isEmpty(calculationDiscountResult.getExclusiveActivityList())){
private String goodsId; return;
private Integer type; }
//优惠互斥提示开关
String redisKey = RedisUtil.activityMutexKey + partnerId + "_" + appid;
//购物车内部缓存
String value = redisCache.hashGet(redisKey, "activityMutexType");
if (StringUtils.isNotBlank(value)) {
return;
}
ActivityMutexConfig config = JSONObject.parseObject(value,ActivityMutexConfig.class);
if("0".equals(config.getActivityMutex())){
return;
}
//点餐页 添加购物车/更新购物车,(活动与活动互斥,活动与优惠券互斥)
if(ObjectUtils.equals(SubmitPageEnum.NO.getCode(), flag) && addOrUpdate && "1".equals(config.getActivityMutex())){
if(CollectionUtils.isNotEmpty(calculationDiscountResult.getCouponDiscounts())
&& calculationDiscountResult.getCouponDiscounts().get(0).getPromotionSharing() == 1){//是否与促销活动共享 0不同享 1同享
if(calculationDiscountResult.getExclusiveActivityList().size() >1 ){
toastMsg = "多个促销活动不同享 活动商品优惠发生变化";
}else {
toastMsg = "优惠券与其他促销活动不同享 活动商品优惠发生变化";
}
}
if(CollectionUtils.isNotEmpty(calculationDiscountResult.getDiscounts())){
if(calculationDiscountResult.getExclusiveActivityList().size() >1 ){
toastMsg = "多个促销活动不同享 活动商品优惠发生变化";
}else {
String activityName = calculationDiscountResult.getExclusiveActivityList().get(0).getActivityTypeName();
Integer type = calculationDiscountResult.getDiscounts().get(0).getType();
String name = ActivityTypeEnum.getByCode(type).getDesc();
toastMsg = name +"与"+ activityName + "活动不同享 活动商品优惠发生变化";
}
}
}
//结算页查询购物车 带优惠券 (优惠券与活动互斥)
// if(ObjectUtils.equals(SubmitPageEnum.YES.getCode(), flag) && hasCoupon && "1".equals(config.getCouponactivityMutex())){
// toastMsg = "优惠券与其他促销活动不同享 活动商品优惠发生变化";
// }
if(StringUtils.isNotEmpty(toastMsg) && StringUtils.isEmpty(shoppingCartGoodsResponseVo.getToastMsg())){
shoppingCartGoodsResponseVo.setToastMsg(toastMsg);
}
} }
} }
\ No newline at end of file
...@@ -4,6 +4,7 @@ import cn.freemud.constant.ShoppingCartConstant; ...@@ -4,6 +4,7 @@ import cn.freemud.constant.ShoppingCartConstant;
import cn.freemud.entities.dto.UserLoginInfoDto; import cn.freemud.entities.dto.UserLoginInfoDto;
import cn.freemud.entities.dto.activity.ActivityQueryDto; import cn.freemud.entities.dto.activity.ActivityQueryDto;
import cn.freemud.entities.dto.calculate.CalculationDiscountResult; import cn.freemud.entities.dto.calculate.CalculationDiscountResult;
import cn.freemud.entities.dto.calculate.DistributeBo;
import cn.freemud.entities.vo.CartGoods; import cn.freemud.entities.vo.CartGoods;
import cn.freemud.entities.vo.CouponPromotionVO; import cn.freemud.entities.vo.CouponPromotionVO;
import cn.freemud.entities.vo.ShoppingCartGoodsResponseVo; import cn.freemud.entities.vo.ShoppingCartGoodsResponseVo;
...@@ -55,20 +56,24 @@ public class CalculationSharingCartService { ...@@ -55,20 +56,24 @@ public class CalculationSharingCartService {
/** /**
* 响应购物车价格计算依赖促销 * 响应购物车价格计算依赖促销
*/ */
public void distribute(CalculationDiscountResult discountResult public void distribute(DistributeBo distributeBo) {
, List<CartGoods> cartGoodsList
, ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo CalculationDiscountResult discountResult = distributeBo.getDiscountResult();
, ShoppingCartInfoRequestVo shoppingCartInfoRequestVo List<CartGoods> cartGoodsList = distributeBo.getCartGoodsList();
, UserLoginInfoDto userLoginInfoDto ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo = distributeBo.getShoppingCartGoodsResponseVo();
, CouponPromotionVO couponPromotionVO ShoppingCartInfoRequestVo shoppingCartInfoRequestVo = distributeBo.getShoppingCartInfoRequestVo();
, ActivityQueryDto activityQueryDto UserLoginInfoDto userLoginInfoDto = distributeBo.getUserLoginInfoDto();
, String menuType CouponPromotionVO couponPromotionVO = distributeBo.getCouponPromotionVO();
, Long deliveryAmount ActivityQueryDto activityQueryDto = distributeBo.getActivityQueryDto();
, String opt String menuType = distributeBo.getMenuType();
, String partnerId Long deliveryAmount = distributeBo.getDeliveryAmount();
, Integer flag String opt = distributeBo.getOpt();
, String userId String partnerId = distributeBo.getPartnerId();
, String storeId, long nightDistributionFee) { Integer flag = distributeBo.getFlag();
String userId = distributeBo.getUserId();
String storeId = distributeBo.getStoreId();
long nightDistributionFee =distributeBo.getNightDistributionFee();
boolean hasCoupon = distributeBo.getHasCoupon();
/** /**
* 用促销价格初始化购物车行记录成交价 * 用促销价格初始化购物车行记录成交价
...@@ -109,22 +114,28 @@ public class CalculationSharingCartService { ...@@ -109,22 +114,28 @@ public class CalculationSharingCartService {
deliverySharingService.deliveryResponse(discountResult, activityQueryDto, shoppingCartGoodsResponseVo, deliveryAmount, nightDistributionFee); deliverySharingService.deliveryResponse(discountResult, activityQueryDto, shoppingCartGoodsResponseVo, deliveryAmount, nightDistributionFee);
} }
// if (ShoppingCartConstant.ADD_AND_UPDATE.equals(opt)) {
// calculationCommonService.setAddAndUpdateResponse(cartGoodsList, shoppingCartGoodsResponseVo, shoppingCartInfoRequestVo, ShoppingCartConstant.ADD_AND_UPDATE);
// } else if (ShoppingCartConstant.QUERY_INFO.equals(opt)) {
// calculationCommonService.setAddAndUpdateResponse(cartGoodsList, shoppingCartGoodsResponseVo, shoppingCartInfoRequestVo, ShoppingCartConstant.QUERY_INFO);
// calculationCommonService.addNeedCardAmount(shoppingCartInfoRequestVo, shoppingCartGoodsResponseVo);
// }
/** /**
* 特价类型超出部分提示 * 买一赠一寄杯(coco)
*/ */
buyOneGiveOneSendService.giftResponse(discountResult, cartGoodsList, shoppingCartInfoRequestVo, activityQueryDto,shoppingCartGoodsResponseVo);
/** ---------------------------------------- 上面为活动处理 ------------------------------------------ **/
//特价类型超出部分提示
calculationCommonService.drawSurpassDiscountInfo(discountResult, shoppingCartGoodsResponseVo); calculationCommonService.drawSurpassDiscountInfo(discountResult, shoppingCartGoodsResponseVo);
if (ShoppingCartConstant.ADD_AND_UPDATE.equals(opt)) {
calculationCommonService.setAddAndUpdateResponse(cartGoodsList, shoppingCartGoodsResponseVo, shoppingCartInfoRequestVo, ShoppingCartConstant.ADD_AND_UPDATE);
} else if (ShoppingCartConstant.QUERY_INFO.equals(opt)) {
calculationCommonService.setAddAndUpdateResponse(cartGoodsList, shoppingCartGoodsResponseVo, shoppingCartInfoRequestVo, ShoppingCartConstant.QUERY_INFO);
calculationCommonService.addNeedCardAmount(shoppingCartInfoRequestVo, shoppingCartGoodsResponseVo);
}
/** calculationCommonService.setAddAndUpdateResponse(cartGoodsList, shoppingCartGoodsResponseVo, shoppingCartInfoRequestVo, opt);
* 买一赠一寄杯
*/
buyOneGiveOneSendService.giftResponse(discountResult, cartGoodsList, shoppingCartInfoRequestVo, activityQueryDto,shoppingCartGoodsResponseVo);
//活动互斥提示
calculationCommonService.setActivityMutexToastMsg(discountResult, flag, partnerId, userLoginInfoDto.getWxAppid(),
hasCoupon, ShoppingCartConstant.ADD_AND_UPDATE.equals(opt), shoppingCartGoodsResponseVo);
} }
} }
...@@ -152,7 +152,7 @@ public class CalculationSharingEquallyService { ...@@ -152,7 +152,7 @@ public class CalculationSharingEquallyService {
} }
calculationCommonService.setAddAndUpdateResponse(cartGoodsList, shoppingCartGoodsResponseVo, shoppingCartInfoRequestVo, ShoppingCartConstant.QUERY_INFO); calculationCommonService.setAddAndUpdateResponse(cartGoodsList, shoppingCartGoodsResponseVo, shoppingCartInfoRequestVo, ShoppingCartConstant.QUERY_INFO);
calculationCommonService.addNeedCardAmount(shoppingCartInfoRequestVo, shoppingCartGoodsResponseVo); // calculationCommonService.addNeedCardAmount(shoppingCartInfoRequestVo, shoppingCartGoodsResponseVo);
if (discountResult!=null && discountResult.getSendPointVo()!=null) { if (discountResult!=null && discountResult.getSendPointVo()!=null) {
shoppingCartGoodsDto.setSendPoint(discountResult.getSendPointVo()); shoppingCartGoodsDto.setSendPoint(discountResult.getSendPointVo());
} }
......
...@@ -163,7 +163,7 @@ public class CalculationServiceImpl { ...@@ -163,7 +163,7 @@ public class CalculationServiceImpl {
// fix npe 麦咖啡加车没有orderType,这里判断一下orderType // fix npe 麦咖啡加车没有orderType,这里判断一下orderType
discountRequest.setProductChannel((null != orderType && orderType == 1) ? "saasdelivery" : "saas"); discountRequest.setProductChannel((null != orderType && orderType == 1) ? "saasdelivery" : "saas");
// try { // try {
ActivityCalculationDiscountResponseDto activityCalculationDiscountResponseDto = activityClient.calculationDiscountSharing(discountRequest); ActivityCalculationDiscountResponseDto activityCalculationDiscountResponseDto = activityClient.MCoffeeCalculationDiscountSharing(discountRequest);
// } catch (Exception ex) { // } catch (Exception ex) {
// throw new ServiceException(ResponseResult.OPERATE_TOO_OFTEN); // throw new ServiceException(ResponseResult.OPERATE_TOO_OFTEN);
// } // }
......
...@@ -60,13 +60,14 @@ public interface ActivityClient { ...@@ -60,13 +60,14 @@ public interface ActivityClient {
ActivityCalculationDiscountResponseDto calculationDiscount(ActivityCalculationDiscountRequestDto activityCalculationDiscountRequestDto); ActivityCalculationDiscountResponseDto calculationDiscount(ActivityCalculationDiscountRequestDto activityCalculationDiscountRequestDto);
/** /**
* 新版优惠均摊计算 * 麦咖啡 优惠均摊计算接口(商户不合作,废弃)
* @param activityCalculationDiscountRequestDto * @param activityCalculationDiscountRequestDto
* @return * @return
*/ */
@Deprecated
@PostMapping("/calculation/discount/sharing") @PostMapping("/calculation/discount/sharing")
@IgnoreFeignLogAnnotation(logMessage = "calculationDiscountSharing",excludeStatusCodes = {ResponseCodeConstant.RESPONSE_SUCCESS_STR},statusCodeFieldName= ResponseCodeKeyConstant.STATUS_CODE,messageFieldName=ResponseCodeKeyConstant.MSG) @IgnoreFeignLogAnnotation(logMessage = "calculationDiscountSharing",excludeStatusCodes = {ResponseCodeConstant.RESPONSE_SUCCESS_STR},statusCodeFieldName= ResponseCodeKeyConstant.STATUS_CODE,messageFieldName=ResponseCodeKeyConstant.MSG)
ActivityCalculationDiscountResponseDto calculationDiscountSharing(ActivityCalculationDiscountRequestDto activityCalculationDiscountRequestDto); ActivityCalculationDiscountResponseDto MCoffeeCalculationDiscountSharing(ActivityCalculationDiscountRequestDto activityCalculationDiscountRequestDto);
/** /**
......
...@@ -7,6 +7,7 @@ public class RedisUtil { ...@@ -7,6 +7,7 @@ public class RedisUtil {
private final static String COUPON_APP_SECRET = "coupon:app_secret_"; private final static String COUPON_APP_SECRET = "coupon:app_secret_";
public static String limitCart = "kgd:open_store_cart_limit_"; public static String limitCart = "kgd:open_store_cart_limit_";
public static String packAmountConfig = "kgd:order_pack_config_"; public static String packAmountConfig = "kgd:order_pack_config_";
public static String activityMutexKey = "kgd:order_activity_mutex_";
public static String getEnterShopKey(String userId) { public static String getEnterShopKey(String userId) {
return ENTER_SHOP_KEY + userId; return ENTER_SHOP_KEY + userId;
......
...@@ -272,7 +272,6 @@ order.download.baseUrl = http://shared-order-es-shared-order-service-env-dev.api ...@@ -272,7 +272,6 @@ order.download.baseUrl = http://shared-order-es-shared-order-service-env-dev.api
order.download.appName = orderCenter order.download.appName = orderCenter
order.download.connectTimeOut = 10000 order.download.connectTimeOut = 10000
saas.order.invoice.report.partnerIds = 2399 saas.order.invoice.report.partnerIds = 2399
store.delivery.use.old = false
#rocketmq.producer.config #rocketmq.producer.config
......
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