Commit fe98c8cb by 胡博文

解决买M件N券到算页不自动选最优券的问题

parent cadf9167
......@@ -96,6 +96,12 @@ public class CartGoods {
* 商品券code
*/
private String couponCode;
/**
* 0 可用 1 不可用 (结算页识别是否需要传买M赠N券code)
* 默认不可用,经过算价后进行更新。
*/
private Integer canUseCoupon = 1;
/**
* 商品券门槛金额
*/
......
......@@ -36,6 +36,8 @@ public class CartParamDto {
private String cartGoodsUid;
private Integer canUseCoupon;
private Integer qty;
private MealClearOperationEnum operationType;
......
......@@ -940,6 +940,16 @@ public interface ShoppingCartBaseService {
BaseResponse<List<CartGoods>> updateGoodsQty(CartParamDto cartParamDto, String trackingNo);
/**
* 更新券状态
*
* @param cartParamDto
* @param trackingNo
* @return
*/
BaseResponse updateGoodsCouponStatus(CartParamDto cartParamDto, String trackingNo);
/**
* 查询组织机构
* @param partnerId
* @param storeId
......
......@@ -194,6 +194,11 @@ public class CollageCartBaseServiceImpl implements ShoppingCartBaseService {
}
}
@Override
public BaseResponse updateGoodsCouponStatus(CartParamDto cartParamDto, String trackingNo) {
return null;
}
/**
* 获取当前购物车版本
* 默认0
......
......@@ -442,6 +442,11 @@ public class MealCartBaseServiceImpl implements ShoppingCartBaseService {
}
@Override
public BaseResponse updateGoodsCouponStatus(CartParamDto cartParamDto, String trackingNo) {
return null;
}
@Override
public void checkNoProductExistMenu(CheckCartRequest checkCartRequest, Set<String> keySet) {
// 当商品不存在于菜单中且不是商品券时,需置空移除
List<String> removeList = new ArrayList<>();
......
......@@ -248,6 +248,32 @@ public class ShoppingCartBaseServiceImpl implements ShoppingCartBaseService {
}
}
/**
* 更新购物车券状态
*
* @param cartParamDto
* @param trackingNo
* @return
*/
@Override
public BaseResponse updateGoodsCouponStatus(CartParamDto cartParamDto, String trackingNo) {
try {
String redisKey = getShoppingCartGoodsKey(cartParamDto);
BoundHashOperations<String, String, CartGoods> operations = redisTemplate.boundHashOps(redisKey);
CartGoods cartGoods = operations.get(cartParamDto.getCartGoodsUid());
if (cartGoods != null) {
// 更新券状态
cartGoods.setCanUseCoupon(cartParamDto.getCanUseCoupon());
operations.put(cartParamDto.getCartGoodsUid(), cartGoods);
}
//return this.getCartGoodsList(cartParamDto, trackingNo);
} catch (Exception e) {
ShoppingSdkLogUtil.printErrorLog("assortment-shoppingcart-sdk", trackingNo, e.getMessage(), "updateGoodsCouponStatus", cartParamDto, e, Level.ERROR);
}
return CartResponseUtil.success();
}
@Override
public BaseResponse clear(CartParamDto cartParamDto, String trackingNo) {
try {
......
......@@ -128,6 +128,11 @@ public class ShoppingCartMallBaseServiceImpl implements ShoppingCartBaseService
}
@Override
public BaseResponse updateGoodsCouponStatus(CartParamDto cartParamDto, String trackingNo) {
return null;
}
@Override
public BaseResponse clear(CartParamDto cartParamDto, String trackingNo) {
try {
redisTemplate.delete(this.getShoppingCartGoodsKey(cartParamDto));
......
......@@ -13,6 +13,7 @@
package cn.freemud.entities.vo;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.freemud.sdk.api.assortment.shoppingcart.constant.CommonsConstant;
import lombok.Data;
import lombok.NoArgsConstructor;
......@@ -85,6 +86,12 @@ public class CartGoods {
* 商品券code
*/
private String couponCode;
/**
* 0 可用 1 不可用 (结算页识别是否需要传买M赠N券code)
*/
@JsonIgnore
private Integer canUseCoupon = 1;
/**
* 商品券名称
*/
......
......@@ -340,9 +340,9 @@ public abstract class AbstractShoppingCartImpl implements ShoppingCartNewService
//外卖场景下 查询门店配送信息
if(BusinessTypeEnum.SAAS_DELIVERY.getCode().equals(menuType)){
calculationDiscountResult = this.getActivityCalculationDiscountResponse(partnerId, storeId, userId, appId, orderType,isMember, cartGoodsList, coupons, sendGoodsList,BusinessTypeEnum.getByType(menuType).getCode(),deliveryAmount,null);
calculationDiscountResult = this.getActivityCalculationDiscountResponse(partnerId, storeId, userId, appId, orderType,isMember, cartGoodsList, coupons, sendGoodsList,BusinessTypeEnum.getByType(menuType).getCode(),deliveryAmount,null, null);
}else{
calculationDiscountResult = this.getActivityCalculationDiscountResponse(partnerId, storeId, userId, appId, orderType,isMember, cartGoodsList, coupons, sendGoodsList,BusinessTypeEnum.getByType(menuType).getCode(),null,null);
calculationDiscountResult = this.getActivityCalculationDiscountResponse(partnerId, storeId, userId, appId, orderType,isMember, cartGoodsList, coupons, sendGoodsList,BusinessTypeEnum.getByType(menuType).getCode(),null,null, null);
}
return calculationDiscountResult;
......
......@@ -97,7 +97,7 @@ public interface ShoppingCartNewService {
boolean isMember,
List<CartGoods> cartGoodsList,
List<ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon> coupons,
List<ShoppingCartInfoRequestVo.SendGoods> sendGoodsList,String menuType,Long distributionFee,Integer bizType);
List<ShoppingCartInfoRequestVo.SendGoods> sendGoodsList,String menuType,Long distributionFee,Integer bizType, Integer accountFlag);
List<CartGoods> updateCartGoodsLegal(CartGoods cartGoods, String userId, ShoppingCartGoodsBaseResponseVo shoppingCartGoodsResponseVo, AddShoppingCartGoodsRequestVo addShoppingCartGoodsRequestVo, List<CartGoods> oldAllCartGoodsList);
......
......@@ -20,7 +20,9 @@ import com.freemud.application.sdk.api.base.SDKCommonBaseContextWare;
import com.freemud.application.sdk.api.log.LogThreadLocal;
import com.freemud.application.sdk.api.productcenter.domain.ProductBeanDTO;
import com.freemud.sdk.api.assortment.shoppingcart.constant.CommonsConstant;
import com.freemud.sdk.api.assortment.shoppingcart.constant.RedisKeyConstant;
import com.freemud.sdk.api.assortment.shoppingcart.constant.ShoppingCartConstant;
import com.freemud.sdk.api.assortment.shoppingcart.enums.BizTypeEnum;
import com.freemud.sdk.api.assortment.shoppingcart.enums.BusinessTypeEnum;
import com.freemud.sdk.api.assortment.shoppingcart.request.CheckCartRequest;
import com.freemud.sdk.api.assortment.shoppingcart.request.GetProductInfoRequest;
......@@ -37,6 +39,7 @@ import cn.freemud.entities.dto.GetMenuResponseDto.DataBean.RootNodeBean.Children
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
......@@ -101,6 +104,37 @@ public class AssortmentSdkService {
return updateNowBuyGoodsQtyBySdk(buyType,partnerId, userId, storeId, cartGoodsUid, qty, tableNumber, shoppingCartService,bizType);
}
/**
* 更新购物车 买M赠N券商品状态
*
* @param partnerId 商户号
* @param userId 用户id
* @param storeId 门店id
* @return
*/
public void updateGoodsCouponStatus(String partnerId, String userId, String storeId, List<CartGoods> cartGoods,ShoppingCartBaseService shoppingCartService,Integer bizType) {
com.freemud.sdk.api.assortment.shoppingcart.domain.CartParamDto cartParamDto = getCartParamDto(partnerId, storeId, userId);
for (CartGoods cartGood : cartGoods) {
int buyType = 0 ;
cartParamDto.setCartGoodsUid(cartGood.getCartGoodsUid());
// 0 表示券可用 1 表示不可用
cartParamDto.setCanUseCoupon(0);
// cartParamDto.setTableNumber(tableNumber);
cartParamDto.setUserId(userId);
cartParamDto.setBizType(bizType);
//立即购买==1 ,设置新的缓存key
if(buyType == ShoppingCartConstant.NOW_BUY_TYPE) {
cartParamDto.setBuyType(buyType);
}
shoppingCartService.updateGoodsCouponStatus(cartParamDto, LogThreadLocal.getTrackingNo());
}
}
/**
* 调用聚合sdk获取缓存中购物车信息
*
......
......@@ -789,7 +789,7 @@ public class ShoppingCartCollageServiceImpl extends AbstractShoppingCartImpl imp
}
@Override
public ActivityCalculationDiscountResponseDto.CalculationDiscountResult getActivityCalculationDiscountResponse(String partnerId, String storeId, String userId, String appId, Integer orderType, boolean isMember, List<CartGoods> cartGoodsList, List<ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon> coupons, List<ShoppingCartInfoRequestVo.SendGoods> sendGoodsList, String menuType, Long distributionFee,Integer bizType) {
public ActivityCalculationDiscountResponseDto.CalculationDiscountResult getActivityCalculationDiscountResponse(String partnerId, String storeId, String userId, String appId, Integer orderType, boolean isMember, List<CartGoods> cartGoodsList, List<ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon> coupons, List<ShoppingCartInfoRequestVo.SendGoods> sendGoodsList, String menuType, Long distributionFee,Integer bizType, Integer accoutFlag) {
ActivityCalculationDiscountRequestDto activityCalculationDiscountRequestDto = getActivityCalculationDiscountRequestDto(partnerId, storeId, userId, appId, orderType);
List<ActivityCalculationDiscountRequestDto.CalculationDiscountGoods> calculationDiscountGoodsList = new ArrayList<>();
// 校验后有效的商品券map
......
......@@ -54,6 +54,7 @@ import com.freemud.sdk.api.assortment.shoppingcart.request.CheckCartRequest;
import com.freemud.sdk.api.assortment.shoppingcart.service.ShoppingCartBaseService;
import com.freemud.sdk.api.assortment.shoppingcart.service.impl.ShoppingCartMallBaseServiceImpl;
import com.google.common.collect.Lists;
import io.swagger.models.auth.In;
import lombok.Data;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang.ObjectUtils;
......@@ -138,6 +139,7 @@ public class ShoppingCartMallServiceImpl implements ShoppingCartNewService {
String menuType = addShoppingCartGoodsRequestVo.getMenuType();
Integer orderType = addShoppingCartGoodsRequestVo.getOrderType();
addShoppingCartGoodsRequestVo.setShopId(storeId);
Integer accountType = 0; //非结算页
//清空临时购物车
// 构造请求参数,进行清空购物车
if(ShoppingCartConstant.NOW_BUY_TYPE == addShoppingCartGoodsRequestVo.getBuyType()) {
......@@ -189,7 +191,7 @@ public class ShoppingCartMallServiceImpl implements ShoppingCartNewService {
ActivityQueryDto activityQueryDto = activityAdapter.getActivityQueryDto(partnerId, storeId, userId, appId, addShoppingCartGoodsRequestVo.getOrderType());
CalculationSharingDiscountResponseDto.CalculationDiscountResult discountResult = null;
discountResult = sharingDiscountService.getCalculationSharingDiscountResult(menuType, partnerId, storeId, userId, appId, orderType, assortmentCustomerInfoVo.isMemberPaid(), allCartGoodsList, new ArrayList<>(), null, deliveryAmount, null,null);
discountResult = sharingDiscountService.getCalculationSharingDiscountResult(menuType, partnerId, storeId, userId, appId, orderType, assortmentCustomerInfoVo.isMemberPaid(), allCartGoodsList, new ArrayList<>(), null, deliveryAmount, null,null, accountType);
sharingCartService.distribute(discountResult, allCartGoodsList, shoppingCartGoodsResponseVo, null, null, null, activityQueryDto, menuType, deliveryAmount, ShoppingCartConstant.ADD_AND_UPDATE, partnerId, null, userId, storeId);
buildShoppingCartGoodsResponse(shoppingCartGoodsResponseVo,discountResult,null,partnerId);
......@@ -245,6 +247,7 @@ public class ShoppingCartMallServiceImpl implements ShoppingCartNewService {
String receiveId = updateShoppingCartGoodsQtyRequestVo.getReceiveId();
String menuType = updateShoppingCartGoodsQtyRequestVo.getMenuType();
Integer orderType=updateShoppingCartGoodsQtyRequestVo.getOrderType();
Integer accountFlag = 0;// 非结算页
// 先验证商品是否存在
CartGoods cartGoods = assortmentSdkService.getCartGoodsBySdk(partnerId, userId, storeId, cartGoodsUid, "", shoppingCartBaseService,null);
......@@ -283,7 +286,7 @@ public class ShoppingCartMallServiceImpl implements ShoppingCartNewService {
, new ArrayList() //券
, null //加价购商品
, deliveryAmount
, null,null);
, null,null, accountFlag);
sharingCartService.distribute(discountResult
, cartGoodsList
......@@ -364,6 +367,7 @@ public class ShoppingCartMallServiceImpl implements ShoppingCartNewService {
String couponCode = shoppingCartInfoRequestVo.getCouponCode();
String activityCode = shoppingCartInfoRequestVo.getActivityCode();
List<ChooseCouponVo> couponCodes = shoppingCartInfoRequestVo.getCouponCodes();
Integer accountFlag = shoppingCartInfoRequestVo.getFlag();
// 兼容老版本
if (CollectionUtils.isNotEmpty(couponCodes) && StringUtils.isEmpty(couponCode)) {
ChooseCouponVo otherCouponCode = couponCodes.stream()
......@@ -441,7 +445,7 @@ public class ShoppingCartMallServiceImpl implements ShoppingCartNewService {
, coupons
, sendGoods
, deliveryAmount
, null,null);
, null,null, accountFlag);
sharingCartService.distribute(calculationSharingDiscountResult
, cartGoodsList
, shoppingCartGoodsResponseVo
......@@ -529,6 +533,7 @@ public class ShoppingCartMallServiceImpl implements ShoppingCartNewService {
String storeId = shoppingCartInfoRequestVo.getShopId();
String couponCode = shoppingCartInfoRequestVo.getCouponCode();
String activityCode = shoppingCartInfoRequestVo.getActivityCode();
Integer accountFlag = shoppingCartInfoRequestVo.getFlag();
List<ChooseCouponVo> couponCodes = shoppingCartInfoRequestVo.getCouponCodes();
if (Objects.isNull(couponCode) && CollectionUtils.isNotEmpty(couponCodes)) {
ChooseCouponVo otherCouponCode = couponCodes.stream()
......@@ -598,7 +603,7 @@ public class ShoppingCartMallServiceImpl implements ShoppingCartNewService {
, coupons
, shoppingCartInfoRequestVo.getSendGoods()
, deliveryAmount
, shoppingCartInfoRequestVo,null);
, shoppingCartInfoRequestVo,null, accountFlag);
// 活动校验
calculationSharingValidatorService.validator(discountResult
......@@ -630,8 +635,8 @@ public class ShoppingCartMallServiceImpl implements ShoppingCartNewService {
@Override
public ActivityCalculationDiscountResponseDto.CalculationDiscountResult getActivityCalculationDiscountResponse(
String partnerId, String storeId, String userId, String appId, Integer orderType,boolean isMember, List<CartGoods> cartGoodsList,
List<ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon> coupons, List<ShoppingCartInfoRequestVo.SendGoods> sendGoodsList,String menuType,Long distributionFee,Integer bizType) {
String partnerId, String storeId, String userId, String appId, Integer orderType, boolean isMember, List<CartGoods> cartGoodsList,
List<ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon> coupons, List<ShoppingCartInfoRequestVo.SendGoods> sendGoodsList, String menuType, Long distributionFee, Integer bizType, Integer accountFlag) {
return null;
}
......
......@@ -427,7 +427,7 @@ public class ShoppingCartMealServiceImpl implements ShoppingCartNewService {
if (CollectionUtils.isEmpty(cartGoodsList)) {
return;
}
ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscountResult = this.getActivityCalculationDiscountResponse(partnerId, storeId, userId, appId, orderType, isMember, cartGoodsList, new ArrayList<>(), new ArrayList<>(), BusinessTypeEnum.SAAS_MALL.getCode(), 0L,null);
ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscountResult = this.getActivityCalculationDiscountResponse(partnerId, storeId, userId, appId, orderType, isMember, cartGoodsList, new ArrayList<>(), new ArrayList<>(), BusinessTypeEnum.SAAS_MALL.getCode(), 0L,null, null);
if(calculationDiscountResult == null) {
return;
}
......@@ -556,7 +556,7 @@ public class ShoppingCartMealServiceImpl implements ShoppingCartNewService {
@Override
public ActivityCalculationDiscountResponseDto.CalculationDiscountResult getActivityCalculationDiscountResponse(String partnerId, String storeId, String userId, String appId, Integer orderType, boolean isMember,
List<CartGoods> cartGoodsList, List<ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon> coupons, List<ShoppingCartInfoRequestVo.SendGoods> sendGoodsList,String menuType,Long distributionFee,Integer bizType) {
List<CartGoods> cartGoodsList, List<ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon> coupons, List<ShoppingCartInfoRequestVo.SendGoods> sendGoodsList,String menuType,Long distributionFee,Integer bizType, Integer accountFlag) {
ActivityCalculationDiscountRequestDto activityCalculationDiscountRequestDto = getActivityCalculationDiscountRequestDto(partnerId, storeId, userId, appId, orderType);
List<ActivityCalculationDiscountRequestDto.CalculationDiscountGoods> calculationDiscountGoodsList = new ArrayList<>();
cartGoodsList = cartGoodsList.stream().filter(t -> !isWeightProduct(t)).collect(Collectors.toList());
......
......@@ -299,6 +299,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
String tableNumber = addShoppingCartGoodsRequestVo.getTableNumber();
String couponCode = addShoppingCartGoodsRequestVo.getCouponCode(); // 商品券和换购券券号
Integer bizType = addShoppingCartGoodsRequestVo.getBizType(); // 7-爱马哥预定单
Integer accountFlag = 0; //非结算页
if (spuId.startsWith(CommonsConstant.COUPON_PREFIX)) { // 兼容老版本
couponCode = spuId.substring(CommonsConstant.COUPON_PREFIX.length());
}
......@@ -381,8 +382,25 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
, new ArrayList<>() //券
, null //加价购商品
, deliveryAmount
, null,bizType);
, null,bizType, accountFlag);
//更新购物车
List<CalculationSharingDiscountResponseDto.CalculationDiscountResult.Discount> discounts = discountResult.getDiscounts();
List<CalculationSharingDiscountResponseDto.CalculationDiscountResult.Discount> mnCouponDiscount = null;
if (CollectionUtils.isNotEmpty(discounts)) {
mnCouponDiscount = discounts.stream().filter(discount -> ActivityTypeEnum.TYPE_330.getCode().equals(discount.getType())).collect(toList());
}
String mnCouponCode = null;
if (CollectionUtils.isNotEmpty(mnCouponDiscount)) {
CalculationSharingDiscountResponseDto.CalculationDiscountResult.Discount discount = mnCouponDiscount.get(0);
mnCouponCode = discount.getActivityCode();
}
if (StringUtils.isNotBlank(mnCouponCode)) {
String finalMnCouponCode = mnCouponCode;
List<CartGoods> couponCartGoods = allCartGoodsList.stream().filter(good -> finalMnCouponCode.equals(good.getCouponCode())).collect(toList());
//更新购物车状态
assortmentSdkService.updateGoodsCouponStatus(partnerId, userId, storeId,couponCartGoods, shoppingCartBaseService,bizType);
}
sharingCartService.distribute(discountResult
, allCartGoodsList
, shoppingCartGoodsResponseVo
......@@ -402,11 +420,29 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
//
} else {
// 获取优惠信息
ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscountResult
= getCalculationDiscountResult(menuType, partnerId, storeId, userId, appId, userLoginInfoDto.getWxAppid(), orderType, assortmentCustomerInfoVo.isMemberPaid(), allCartGoodsList, new ArrayList(), new ArrayList<>(), null, deliveryAmount,bizType);
if (calculationDiscountResult != null && CollectionUtils.isNotEmpty(calculationDiscountResult.getSendGoods())) {
ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscountResult = getCalculationDiscountResult(menuType, partnerId, storeId, userId, appId, userLoginInfoDto.getWxAppid(), orderType, assortmentCustomerInfoVo.isMemberPaid(), allCartGoodsList, new ArrayList(), new ArrayList<>(), null, deliveryAmount,bizType, accountFlag);
if (calculationDiscountResult != null && CollectionUtils.isNotEmpty(calculationDiscountResult.getSendGoods())){
sendGoodsQtyCheck(productsCount, appId, partnerId, userId, storeId, tableNumber, oldCartGoodsList, shoppingCartBaseService, calculationDiscountResult.getSendGoods(),bizType);
}
//校验
if (calculationDiscountResult != null && CollectionUtils.isNotEmpty(calculationDiscountResult.getDiscounts())) {
String activityCouponCode = null;
List<ActivityCalculationDiscountResponseDto.CalculationDiscountResult.CouponResults> couponDiscounts = calculationDiscountResult.getCouponDiscounts();
List<ActivityCalculationDiscountResponseDto.CalculationDiscountResult.CouponResults> couponResults = null;
if (CollectionUtils.isNotEmpty(couponDiscounts)) {
couponResults = couponDiscounts.stream().filter(discount -> ActivityTypeEnum.TYPE_330.getCode().equals(discount.getActivityType())).collect(toList());
}
if (CollectionUtils.isNotEmpty(couponResults)) {
ActivityCalculationDiscountResponseDto.CalculationDiscountResult.CouponResults coupon = couponDiscounts.get(0);
activityCouponCode = coupon.getCouponCode();
}
if (StringUtils.isNotBlank(activityCouponCode)) {
String finalActivityCouponCode = activityCouponCode;
List<CartGoods> couponCartGoods = allCartGoodsList.stream().filter(good -> finalActivityCouponCode.equals(good.getCouponCode())).collect(toList());
//更新购物车状态
assortmentSdkService.updateGoodsCouponStatus(partnerId, userId, storeId,couponCartGoods, shoppingCartBaseService,bizType);
}
}
// 当商品数量被设为0时
if (Objects.equals(cartGoods.getQty(), 0)) {
......@@ -474,6 +510,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
Integer orderType = updateShoppingCartGoodsQtyRequestVo.getOrderType();
String receiveId = updateShoppingCartGoodsQtyRequestVo.getReceiveId();
Integer bizType = updateShoppingCartGoodsQtyRequestVo.getBizType();
Integer accountFlag = 0; //非结算页
// 先验证商品是否存在
......@@ -516,7 +553,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
, new ArrayList() //券
, null //加价购商品
, deliveryAmount
, null,bizType);
, null,bizType, accountFlag);
sharingCartService.distribute(discountResult
, cartGoodsList
......@@ -537,7 +574,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
} else {
// 获取优惠信息
ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscountResult
= getCalculationDiscountResult(menuType, partnerId, storeId, userId, appId, userLoginInfoDto.getWxAppid(), orderType, assortmentCustomerInfoVo.isMemberPaid(), cartGoodsList, new ArrayList(), new ArrayList<>(), null, deliveryAmount,bizType);
= getCalculationDiscountResult(menuType, partnerId, storeId, userId, appId, userLoginInfoDto.getWxAppid(), orderType, assortmentCustomerInfoVo.isMemberPaid(), cartGoodsList, new ArrayList(), new ArrayList<>(), null, deliveryAmount,bizType, accountFlag);
if (calculationDiscountResult == null) {
shoppingCartGoodsResponseVo.setProducts(cartGoodsList);
}
......@@ -628,6 +665,8 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
String activityCode = shoppingCartInfoRequestVo.getActivityCode();
List<ChooseCouponVo> couponCodes = shoppingCartInfoRequestVo.getCouponCodes();
Integer bizType = shoppingCartInfoRequestVo.getBizType();
// 1 为结算页
Integer accountFlag = shoppingCartInfoRequestVo.getFlag();
// 兼容老版本
if (CollectionUtils.isNotEmpty(couponCodes) && StringUtils.isEmpty(couponCode)) {
......@@ -724,7 +763,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
, sendGoods
, deliveryAmount
, null
,bizType);
,bizType, accountFlag);
sharingCartService.distribute(calculationSharingDiscountResult
, cartGoodsList
, shoppingCartGoodsResponseVo
......@@ -765,7 +804,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
// 获取优惠信息 调用促销
ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscountResult = getCalculationDiscountResult(menuType, partnerId, storeId, userId, appId,
userLoginInfoDto.getWxAppid(), orderType, assortmentCustomerInfoVo.isMemberPaid(),
cartGoodsList, coupons, null, shoppingCartInfoRequestVo.getReceiveId(), deliveryAmount,bizType);
cartGoodsList, coupons, null, shoppingCartInfoRequestVo.getReceiveId(), deliveryAmount,bizType, accountFlag);
if (calculationDiscountResult == null) {
shoppingCartGoodsResponseVo.setProducts(cartGoodsList);
}
......@@ -1002,6 +1041,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
String activityCode = shoppingCartInfoRequestVo.getActivityCode();
List<ChooseCouponVo> couponCodes = shoppingCartInfoRequestVo.getCouponCodes();
Integer bizType = shoppingCartInfoRequestVo.getBizType();
Integer accountFlag = shoppingCartInfoRequestVo.getFlag();
if (Objects.isNull(couponCode) && CollectionUtils.isNotEmpty(couponCodes)) {
// fisherman 这里可能会有问题 如果只有配送券的情况下 这里 过滤掉了 得检查后面的逻辑 是否用了list去做事情
......@@ -1103,7 +1143,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
, coupons
, shoppingCartInfoRequestVo.getSendGoods()
, deliveryAmount
, shoppingCartInfoRequestVo,bizType);
, shoppingCartInfoRequestVo,bizType, accountFlag);
// 活动校验
calculationSharingValidatorService.validator(discountResult
......@@ -1150,7 +1190,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
}
// 获取优惠信息
ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscountResult = getCalculationDiscountResult(menuType, partnerId, storeId, userId, appId, userLoginInfoDto.getWxAppid(), orderType, assortmentCustomerInfoVo.isMemberPaid(), cartGoodsList, coupons, sendGoodsList, shoppingCartInfoRequestVo.getReceiveId(), deliveryAmount,bizType);
ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscountResult = getCalculationDiscountResult(menuType, partnerId, storeId, userId, appId, userLoginInfoDto.getWxAppid(), orderType, assortmentCustomerInfoVo.isMemberPaid(), cartGoodsList, coupons, sendGoodsList, shoppingCartInfoRequestVo.getReceiveId(), deliveryAmount,bizType, accountFlag);
//临时方案
packgeAdditional(shoppingCartInfoRequestVo, premiumExchangeActivity);
// 促销活动的优惠金额计算
......@@ -1401,9 +1441,19 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
*/
@Override
public ActivityCalculationDiscountResponseDto.CalculationDiscountResult getActivityCalculationDiscountResponse(
String partnerId, String storeId, String userId, String appId, Integer orderType, boolean isMember, List<CartGoods> cartGoodsList,
String partnerId,
String storeId,
String userId,
String appId,
Integer orderType,
boolean isMember,
List<CartGoods> cartGoodsList,
List<ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon> coupons,
List<ShoppingCartInfoRequestVo.SendGoods> sendGoodsList, String menuType, Long distributionFee,Integer bizType) {
List<ShoppingCartInfoRequestVo.SendGoods> sendGoodsList, String menuType,
Long distributionFee,
Integer bizType,
Integer accountFlag
) {
ActivityCalculationDiscountRequestDto activityCalculationDiscountRequestDto = getActivityCalculationDiscountRequestDto(partnerId, storeId, userId, appId, orderType);
List<ActivityCalculationDiscountRequestDto.CalculationDiscountGoods> calculationDiscountGoodsList = new ArrayList<>();
......@@ -1472,13 +1522,23 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
//添加请求的优惠券信息 买M赠N券,不重复加促销券集合字段
String finalCouponCode = couponCode;
List<ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon> collect = coupons.stream().filter(calculationDiscountCoupon -> Objects.equals(calculationDiscountCoupon.getCode(), finalCouponCode)).collect(toList());
if(CollectionUtils.isEmpty(collect)){
// canUseCoupon 0 表示可用
if (CollectionUtils.isEmpty(collect)) {
if (GoodsTypeEnum.BUY_M_SEND_N_COUPON.getGoodsType().equals(cartGoods.getGoodsType()) && accountFlag == 1 )
{
if (cartGoods.getCanUseCoupon() == 0) {
ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon coupon = new ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon();
coupon.setCode(checkSpqInfoResponseDto.getCouponCode());
coupon.setActivityCode(checkSpqInfoResponseDto.getActiveCode());
coupons.add(coupon);
}
} else {
ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon coupon = new ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon();
coupon.setCode(checkSpqInfoResponseDto.getCouponCode());
coupon.setActivityCode(checkSpqInfoResponseDto.getActiveCode());
coupons.add(coupon);
}
}
// 添加商品券代表的商品
// 换购券传给促销要带code
String goodsId = StringUtils.isEmpty(checkSpqInfoResponseDto.getSkuId()) ? checkSpqInfoResponseDto.getSpuId() : checkSpqInfoResponseDto.getSkuId();
......@@ -2502,15 +2562,15 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
private ActivityCalculationDiscountResponseDto.CalculationDiscountResult getCalculationDiscountResult(String menuType
, String partnerId, String storeId, String userId, String appId, String wxappid, Integer orderType, boolean isMember
, List<CartGoods> cartGoodsList, List<ActivityCalculationDiscountRequestDto.CalculationDiscountCoupon> coupons
, List<ShoppingCartInfoRequestVo.SendGoods> sendGoodsList, String receiveId, Long deliveryAmount,Integer bizType) {
, List<ShoppingCartInfoRequestVo.SendGoods> sendGoodsList, String receiveId, Long deliveryAmount,Integer bizType, Integer accountFlag) {
// 获取优惠信息
ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscountResult = null;
//外卖场景下 查询门店配送信息
if (BusinessTypeEnum.SAAS_DELIVERY.getCode().equals(menuType)) {
calculationDiscountResult = this.getActivityCalculationDiscountResponse(partnerId, storeId, userId, appId, orderType, isMember, cartGoodsList, coupons, sendGoodsList, BusinessTypeEnum.getByType(menuType).getCode(), deliveryAmount,bizType);
calculationDiscountResult = this.getActivityCalculationDiscountResponse(partnerId, storeId, userId, appId, orderType, isMember, cartGoodsList, coupons, sendGoodsList, BusinessTypeEnum.getByType(menuType).getCode(), deliveryAmount,bizType, accountFlag);
} else {
calculationDiscountResult = this.getActivityCalculationDiscountResponse(partnerId, storeId, userId, appId, orderType, isMember, cartGoodsList, coupons, sendGoodsList, BusinessTypeEnum.getByType(menuType).getCode(), null,bizType);
calculationDiscountResult = this.getActivityCalculationDiscountResponse(partnerId, storeId, userId, appId, orderType, isMember, cartGoodsList, coupons, sendGoodsList, BusinessTypeEnum.getByType(menuType).getCode(), null,bizType, accountFlag);
}
return calculationDiscountResult;
......@@ -2912,6 +2972,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
String menuType = request.getMenuType();
Integer orderType = request.getOrderType();
Integer bizType = request.getBizType();
Integer accountFlag = 0;//不关心是否为结算页 设置为非结算页
// 返回构造对象
PremiumExchangeResponseVo premiumExchangeResponseVo = new PremiumExchangeResponseVo();
......@@ -2949,7 +3010,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
, coupons //券
, null //加价购商品
, 0L
, null,bizType);
, null,bizType, accountFlag);
premiumExchangeResponseVo = activityAdapter.convert2PremiumExchangeSharing(discountResult);
} else {
......@@ -2973,7 +3034,8 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
});
}
// 获取优惠信息
ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscountResult = getCalculationDiscountResult(menuType, partnerId, storeId, userId, appId, assortmentCustomerInfoVo.getWxAppId(), orderType, assortmentCustomerInfoVo.isMemberPaid(), cartGoodsList, coupons, null, null, 0L,bizType);
ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscountResult = getCalculationDiscountResult(menuType, partnerId, storeId, userId, appId, assortmentCustomerInfoVo.getWxAppId(), orderType, assortmentCustomerInfoVo.isMemberPaid(), cartGoodsList, coupons, null, null, 0L,bizType
, accountFlag);
premiumExchangeResponseVo = activityAdapter.convert2PremiumExchange(calculationDiscountResult);
}
......@@ -3095,6 +3157,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
String menuType = requestVo.getMenuType();
Integer orderType = requestVo.getOrderType();
Integer bizType = requestVo.getBizType();
Integer accountFlag = 0; //非结算页
CouponAvailableCartInfo couponAvailableCartInfo;
List<String> orgCodes = commonService.getOrgIdsForCoupon(partnerId, storeId);
......@@ -3113,12 +3176,12 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
, new ArrayList<>() //券
, null //加价购商品
, deliveryAmount
, null,bizType);
, null,bizType, accountFlag);
couponAvailableCartInfo = activityAdapter.convert2CouponAvailableCartInfoSharing(partnerId, storeId, discountResult, orgCodes);
} else {
// 获取优惠信息
ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscountResult = getCalculationDiscountResult(menuType, partnerId, storeId, userId, appId, assortmentCustomerInfoVo.getWxAppId(), orderType, assortmentCustomerInfoVo.isMemberPaid(), cartGoodsList, new ArrayList<>(), null, null, deliveryAmount,bizType);
ActivityCalculationDiscountResponseDto.CalculationDiscountResult calculationDiscountResult = getCalculationDiscountResult(menuType, partnerId, storeId, userId, appId, assortmentCustomerInfoVo.getWxAppId(), orderType, assortmentCustomerInfoVo.isMemberPaid(), cartGoodsList, new ArrayList<>(), null, null, deliveryAmount,bizType, accountFlag);
couponAvailableCartInfo = activityAdapter.convert2CouponAvailableCartInfo(partnerId, storeId, calculationDiscountResult, orgCodes);
}
return ResponseUtil.success(couponAvailableCartInfo);
......
......@@ -3,6 +3,7 @@ package cn.freemud.service.impl.calculate;
import cn.freemud.base.util.JsonUtil;
import cn.freemud.constant.ApplicationConstant;
import cn.freemud.constant.ResponseCodeConstant;
import cn.freemud.entities.dto.ActivityCalculationDiscountRequestDto;
import cn.freemud.entities.dto.CheckSpqInfoRequestDto;
import cn.freemud.entities.dto.CheckSpqInfoResponseDto;
import cn.freemud.entities.dto.calculate.CalculationSharingDiscountRequestDto;
......@@ -85,7 +86,7 @@ public class CalculationSharingDiscountService {
, List<CalculationSharingDiscountRequestDto.CalculationDiscountCoupon> coupons
, List<ShoppingCartInfoRequestVo.SendGoods> sendGoodsList
, Long deliveryAmount
, ShoppingCartInfoRequestVo shoppingCartInfoRequestVo,Integer bizType) {
, ShoppingCartInfoRequestVo shoppingCartInfoRequestVo,Integer bizType, Integer accountFlag) {
CalculationSharingDiscountRequestDto calculationSharingDiscountRequestDto = this.commonSharingDto(partnerId, storeId, userId, appId, orderType);
......@@ -157,9 +158,16 @@ public class CalculationSharingDiscountService {
coupon.setCode(checkSpqInfo.getCouponCode());
coupon.setActivityCode(checkSpqInfo.getActiveCode());
CalculationSharingDiscountRequestDto.CalculationDiscountCoupon calculationDiscountCoupon = coupons.stream().filter(p -> coupon.getActivityCode().equals(p.getActivityCode()) && coupon.getCode().equals(p.getCode())).findFirst().orElse(null);
//避免不满足使用券的商品 再才传给促销算价(目前只促销只支持单张券的算价)
if (calculationDiscountCoupon == null) {
if (GoodsTypeEnum.BUY_M_SEND_N_COUPON.getGoodsType().equals(cartGoods.getGoodsType()) && accountFlag == 1 ){
if (cartGoods.getCanUseCoupon() == 0) {
coupons.add(coupon);
}
} else {
coupons.add(coupon);
}
}
// 添加商品券代表的商品放入促销
String goodsId = StringUtils.isNotBlank(checkSpqInfo.getSkuId()) ? checkSpqInfo.getSkuId() : checkSpqInfo.getSpuId();
this.setSpqDiscountGoods(calculationDiscountGoodsList, cartGoods, goodsId, checkSpqInfo.getPrice(), couponCode);
......
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