Commit 44103311 by xiaoer.li

Merge remote-tracking branch 'remotes/origin/feature/2.05-商品券支持多商品'

# Conflicts:
#	shopping-cart-application-service/src/main/java/cn/freemud/enums/ResponseResult.java
parents ebcef393 6b1ec6e2
......@@ -32,5 +32,9 @@ public class CheckSpqInfoResponseDto {
private String picture;
private String defaultSpecId;
private String defaultSpecName;
/**
* 券商品类型 : 0 -> 商品券,4,换购券
*/
private Integer couponType;
private List<CartGoods.CartGoodsExtra> extras;
}
package cn.freemud.entities.dto;
import lombok.Data;
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @Title: cn.freemud.entities.dto CouponProductDto
* @Description: TDO 描述....
* @author: 铁牌灵魂工程师
* @date: 2020/10/30
* @Copyright: www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目
*/
@Data
public class CouponProductDto {
/**
* 商品对应的券类型
*/
private Integer type;
}
......@@ -4,7 +4,8 @@ public enum CouponTypeEnum {
//0:未启用 1:已启用 2:作废
TYPE_0(0, "商品券"),
TYPE_1(1, "代金券"),
TYPE_3(3,"折扣券");
TYPE_3(3, "折扣券"),
TYPE_4(4, "换购券");
private Integer code;
......
......@@ -97,10 +97,10 @@ public enum ResponseResult {
SHOPPING_CART_GOODS_CHECK_ERROR("44028", "当前餐盘中没有可用券的饮品"),
SHOPPING_CART_NO_MEAL("44029", "请至少选择一个可选商品"),
SHOPPING_CART_COUPON_NOT_USE("44030", "优惠券不可用"),
SHOPPING_CART_REQUEST_NOT_EMPTY("44031", "购物车查询条件不能为空"),
SHOPPING_CART_BUY_ONE_SEND_GOODS_NOT_EMPTY("44032", "未查询到寄件活动商品"),
SHOPPING_CART_BUY_ONE_SEND_GOODS_ERR("44033", "寄件活动商品错误"),
SHOPPING_CART_COUPON_MIX_NOT_EXIST("44034", "券商品不存在"),
/**
* 订单状态码
......
......@@ -116,7 +116,8 @@ public interface ShoppingCartNewService {
, String storeId
, String spuId
, List<Long> productIds
, String menuType) {
, String menuType
, CouponProductDto couponProductDto) {
String spuId2;
CheckSpqInfoRequestDto checkSpqInfoRequestDto = new CheckSpqInfoRequestDto(partnerId, storeId, spuId.substring(CommonsConstant.COUPON_PREFIX.length()), menuType);
CouponService couponService = SDKCommonBaseContextWare.getBean(CouponService.class);
......@@ -124,6 +125,9 @@ public interface ShoppingCartNewService {
if (checkSpqInfoResponseDto == null) {
throw new ServiceException(ResponseResult.SHOPPING_CART_COUPON_NOT_EXIST);
}
if (couponProductDto != null) {
couponProductDto.setType(checkSpqInfoResponseDto.getCouponType());
}
productIds.add(Long.parseLong(checkSpqInfoResponseDto.getSkuId()));
spuId2 = checkSpqInfoResponseDto.getSkuId();
return spuId2;
......@@ -145,15 +149,17 @@ public interface ShoppingCartNewService {
, String spuId
, List<Long> productIds
, String menuType
, String goodsId) {
, String goodsId
, CouponProductDto couponProductDto) {
String spuId2;
CheckSpqInfoRequestDto checkSpqInfoRequestDto = new CheckSpqInfoRequestDto(partnerId, storeId, spuId.substring(CommonsConstant.COUPON_PREFIX.length()), menuType);
CouponService couponService = SDKCommonBaseContextWare.getBean(CouponService.class);
CheckSpqInfoResponseDto checkSpqInfoResponseDto = couponService.checkSpqInfo(checkSpqInfoRequestDto, goodsId);
if (checkSpqInfoResponseDto == null) {
throw new ServiceException(ResponseResult.SHOPPING_CART_HG_COUPON_NOT_EXIST);
throw new ServiceException(ResponseResult.SHOPPING_CART_COUPON_MIX_NOT_EXIST);
}
productIds.add(Long.parseLong(checkSpqInfoResponseDto.getSkuId()));
couponProductDto.setType(checkSpqInfoResponseDto.getCouponType());
spuId2 = checkSpqInfoResponseDto.getSkuId();
return spuId2;
}
......
......@@ -726,6 +726,7 @@ public class CouponServiceImpl implements CouponService {
dto.setSkuId(productsVo.getSkuId());
dto.setSkuName(StringUtils.isNotBlank(productsVo.getSkuName()) ? productsVo.getSkuName() : productsVo.getSpuName());
dto.setPicture(productsVo.getSpuPicture());
dto.setCouponType(0);
log.info("dto***" + dto);
return dto;
}
......@@ -758,6 +759,7 @@ public class CouponServiceImpl implements CouponService {
/**
* 换购券
* 商品券支持多商品
*
* @param requestDto
* @param goodsId
......@@ -783,6 +785,7 @@ public class CouponServiceImpl implements CouponService {
return null;
}
boolean productValid = false;
Integer couponType = 0;
GetCouponDetailResponseDto.Details couponActivityDetail = null;
for (GetCouponDetailResponseDto.Details detail : couponDetailResponseDto.getDetails()) {
if (productValid) break;
......@@ -791,6 +794,7 @@ public class CouponServiceImpl implements CouponService {
if (goodsId.equals(activeProduct.getProductIdPartner())) {
productValid = true;
couponActivityDetail = detail;
couponType = detail.getType();
break;
}
}
......@@ -843,6 +847,7 @@ public class CouponServiceImpl implements CouponService {
dto.setDefaultSpecId(productsVo.getDefaultSpecId());
dto.setStockLimit(ObjectUtils.equals(1, productsVo.getStockLimit()));
dto.setExtras(productsVo.getExtra());
dto.setCouponType(couponType);
log.info("dto***" + dto);
return dto;
}
......
......@@ -121,7 +121,7 @@ public class ShoppingCartMealServiceImpl implements ShoppingCartNewService {
productIds.add(Long.parseLong(goodsId));
} else {
//校验券是否有效
spuId2 = validCoupon(partnerId, storeId, spuId, productIds,BusinessTypeEnum.getByType(requestVo.getMenuType()).getCode());
spuId2 = validCoupon(partnerId, storeId, spuId, productIds, BusinessTypeEnum.getByType(requestVo.getMenuType()).getCode(), null);
}
// 获取商品信息
List<ProductBeanDTO> productBeanListSpuClass =
......
......@@ -294,15 +294,17 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
List<Long> productIds = new ArrayList<>();
//商品skuId或者商品券的商品id
String spuId2 = spuId;
CouponProductDto couponProductDto = new CouponProductDto();
if (!spuId.startsWith(CommonsConstant.COUPON_PREFIX)) {
productIds.add(Long.parseLong(goodsId));
} else {
//校验券是否有效
//校验券是否有效 这里是新的商品券支持多商品及换购券
if (StringUtils.isNotBlank(skuId)) {
spuId2 = validCoupon(partnerId, storeId, spuId, productIds, BusinessTypeEnum.getByType(addShoppingCartGoodsRequestVo.getMenuType()).getCode(), skuId);
spuId2 = validCoupon(partnerId, storeId, spuId, productIds, BusinessTypeEnum.getByType(addShoppingCartGoodsRequestVo.getMenuType()).getCode(), skuId, couponProductDto);
cartGoods.setGoodsId(spuId);
} else {
spuId2 = validCoupon(partnerId, storeId, spuId, productIds, BusinessTypeEnum.getByType(addShoppingCartGoodsRequestVo.getMenuType()).getCode());
// 老版本商品券
spuId2 = validCoupon(partnerId, storeId, spuId, productIds, BusinessTypeEnum.getByType(addShoppingCartGoodsRequestVo.getMenuType()).getCode(), couponProductDto);
}
}
// 获取商品详细信息
......@@ -333,7 +335,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
} else {
// 当商品是商品券,里面会判断如果购物车中已有商品券,会将cartGoods的CartGoodsUid设为null
this.addProductGoods(addShoppingCartGoodsRequestVo, cartGoods, spuId2, userId, shoppingCartGoodsResponseVo,
spuId, allCartGoodsList, productBeanListSpuClass, StringUtils.isNotBlank(skuId) ? true : false);
spuId, allCartGoodsList, productBeanListSpuClass, couponProductDto);
}
Long deliveryAmount = calculateDeliveryAmount(receiveId, partnerId, storeId, userLoginInfoDto.getWxAppid(), shoppingCartGoodsResponseVo,addShoppingCartGoodsRequestVo.getOrderType());
......@@ -1173,11 +1175,6 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
if (checkSpqInfoResponseDto == null) {
cartGoodsList.remove(i);
assortmentSdkService.setShoppingCart(partnerId, storeId, userId, cartGoodsList, null, null, this.shoppingCartBaseService);
//if (GoodsTypeEnum.HG_COUPON_GOODS.getGoodsType().equals(cartGoods.getGoodsType())) {
// throw new ServiceException(ResponseResult.SHOPPING_CART_HG_COUPON_NOT_EXIST);
//} else {
// throw new ServiceException(ResponseResult.SHOPPING_CART_COUPON_NOT_EXIST);
//}
} else {
validCouponMap.put(spqId, checkSpqInfoResponseDto);
cartGoods.setName(checkSpqInfoResponseDto.getCouponName());
......@@ -1189,6 +1186,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
coupon.setActivityCode(checkSpqInfoResponseDto.getActiveCode());
coupons.add(coupon);
// 添加商品券代表的商品
// 换购券传给促销要带code
String goodsId = StringUtils.isEmpty(checkSpqInfoResponseDto.getSkuId()) ? checkSpqInfoResponseDto.getSpuId() : checkSpqInfoResponseDto.getSkuId();
if (GoodsTypeEnum.HG_COUPON_GOODS.getGoodsType().equals(cartGoods.getGoodsType())) {
this.addCalculationDiscountGoods(calculationDiscountGoodsList, goodsId, 1, checkSpqInfoResponseDto.getPrice(), 100, cartGoodsUid, cartGoods.getSpuId());
......@@ -1695,7 +1693,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
*/
private void addProductGoods(AddShoppingCartGoodsRequestVo addShoppingCartGoodsRequestVo
, CartGoods cartGoods, String spuId2, String userId, ShoppingCartGoodsResponseVo shoppingCartGoodsResponseVo, String spuId
, List<CartGoods> allCartGoodsList, List<ProductBeanDTO> productBeanListSpuClass, boolean isHg) {
, List<CartGoods> allCartGoodsList, List<ProductBeanDTO> productBeanListSpuClass, CouponProductDto couponProductDto) {
// 商品券商品list
List<CartGoods> tmpCartGoods = allCartGoodsList.parallelStream().filter(k -> k.getCartGoodsUid().startsWith(CommonsConstant.COUPON_PREFIX)).collect(Collectors.toList());
// 当已有商品券时,不得添加(暂时的限制)
......@@ -1705,7 +1703,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
} else {
cartGoods.setCartGoodsUid(spuId);
// 设置商品类型为商品券
if (isHg) {
if (CouponTypeEnum.TYPE_4.getCode().equals(couponProductDto.getType())) {
cartGoods.setGoodsType(GoodsTypeEnum.HG_COUPON_GOODS.getGoodsType());
} else {
cartGoods.setGoodsType(GoodsTypeEnum.COUPON_GOODS.getGoodsType());
......
......@@ -101,12 +101,7 @@ public class CalculationSharingDiscountService {
if (null == checkSpqInfo) {
cartGoodsList.remove(i);
assortmentSdkService.setShoppingCart(partnerId, storeId, userId, cartGoodsList, null, null, this.shoppingCartBaseService);
////跑业务异常 商品券不存
//if (GoodsTypeEnum.HG_COUPON_GOODS.getGoodsType().equals(cartGoods.getGoodsType())) {
// throw new ServiceException(ResponseResult.SHOPPING_CART_HG_COUPON_NOT_EXIST);
//} else {
// throw new ServiceException(ResponseResult.SHOPPING_CART_COUPON_NOT_EXIST);
//}
//跑业务异常 商品券不存
} else {
validCouponMap.put(spqId, checkSpqInfo);
cartGoods.setName(checkSpqInfo.getCouponName());
......
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