Commit 61b4e475 by xiaoer.li

Merge remote-tracking branch 'remotes/origin/feature/1.9.32_商品加料' into qa

# Conflicts:
#	shopping-cart-application-service/pom.xml
parents 2478d951 8b79abd5
......@@ -333,7 +333,7 @@ public class ShoppingCartAdapter {
}
/**
* 单独处理加料
* 单独处理加料及标识小料信息是否有变化
*
* @param cartGoods
* @param spuProduct
......@@ -343,16 +343,24 @@ public class ShoppingCartAdapter {
if (CollectionUtils.isEmpty(cartGoods.getProductMaterialList())) return;
//加料信息为空
if (CollectionUtils.isEmpty(spuProduct.getAdditionalGroupList())) {
cartGoods.setGoodsType(GoodsTypeEnum.EXCEPTION_GOODS.getGoodsType());
cartGoods.setProductMaterialList(new ArrayList<>());
return;
}
//提取加料信息
List<String> materialSpu = new ArrayList<>();
List<ProductBeanDTO.ProductGroupType.GroupDetailType> groupDetail = spuProduct.getAdditionalGroupList().get(0).getGroupDetail();
HashMap<String, ProductBeanDTO.ProductGroupType.GroupDetailType> materialHash = new HashMap<>();
for (ProductBeanDTO.ProductGroupType.GroupDetailType groupDetailType : groupDetail) {
materialHash.put(groupDetailType.getProductId(), groupDetailType);
materialSpu.add(groupDetailType.getProductId());
}
//加车小料和商品小料没有交集则提示商品信息有异常
if(CollectionUtils.isEmpty(cartGoods.getProductMaterialList().stream().filter(e->materialSpu.contains(e.getSpuId())).collect(Collectors.toList()))) {
cartGoods.setGoodsType(GoodsTypeEnum.EXCEPTION_GOODS.getGoodsType());
cartGoods.setProductMaterialList(new ArrayList<>());
return;
}
ArrayList<CartGoods.MaterialGoods> materialGoodsList = new ArrayList<>();
Long materialAmount = 0L;
Long originalMaterAmount = 0L;
......
......@@ -19,7 +19,8 @@ public enum GoodsTypeEnum {
COUPON_GOODS(2, "商品券"),
SET_MEAL_GOODS(3,"套餐商品"),
SKU_GOODS(4, "sku商品"),
SPU_GOODS(5, "spu商品");
SPU_GOODS(5, "spu商品"),
EXCEPTION_GOODS(99, "异常商品:商品菜单变化导致和购物车不商品匹配");
private Integer goodsType;
private String desc;
......
......@@ -181,7 +181,6 @@ public class GetMenuResponseDto {
private List<SpecificationGroupBean> specificationGroupList;
//Sku 规格 如果 当前是sku 则有值
private List<SkuProductBean.SkuSpecValue> skuSpecValues;
private List<ProductGroupType> additionalGroupList;
@NoArgsConstructor
@Data
public static class SkuProductBean {
......@@ -312,104 +311,6 @@ public class GetMenuResponseDto {
private String url;
}
@NoArgsConstructor
@Data
public static class ProductGroupType {
//商品组ID
private String pgid;
//商户ID
private String linkId;
//商品组编号,跟groupId一样确认商品组唯一的字段
private String groupCode;
//扩展字段
private String options;
//商品组名")
private String name;
//商品组规则-是否必选
private Integer must;
//商品组规则-是否允许重复选
private Integer allowRepeat;
//商品组规则-选择的最小数量
private Integer minNumber;
//商品组规则-选择的最大数量
private Integer maxNumber;
//商品组备注
private String remark;
//商品组下子商品总数量
private Integer total;
/**
* 商品组详情
*/
private List<GroupDetailType> groupDetail;
@NoArgsConstructor
@Data
public static class GroupDetailType {
/**
* 商品ID
*/
private String productId;
/**
* 商品名称
*/
private String productName;
/**
* 第三方商品编码
*/
private String customerCode;
/**
* 标准售价
*/
private Integer productPrice;
/**
* 最终售价
*/
protected Integer productFinalPrice;
/**
* 最终售价
*/
protected Integer markUpPrice;
/**
* 商品默认图片
*/
private String picture;
/**
* 是否设置库存
*/
private Integer stockLimit;
/**
* 单位
*/
protected String unit;
/**
* 商品Code
*/
protected String productCode;
}
}
}
}
}
......
......@@ -45,5 +45,4 @@ public class GetProductsVo {
* 分类名称
*/
private String categoryName;
private List<String> materialSpuIds;
}
\ No newline at end of file
......@@ -20,8 +20,8 @@ public enum GoodsTypeEnum {
SET_MEAL_GOODS(3, "套餐商品"),
SKU_GOODS(4, "sku商品"),
SPU_GOODS(5, "spu商品"),
MATERIAL(88, "有加料的商品");
MATERIAL(88, "有加料的商品"),
EXCEPTION_GOODS(99, "异常商品:商品菜单变化导致和购物车不商品匹配");
private Integer goodsType;
private String desc;
......
......@@ -547,12 +547,13 @@ public class CouponServiceImpl implements CouponService {
}
totalAmount = totalAmount + product.getAmount() * cartGood.getQty();
if (CollectionUtils.isNotEmpty(cartGood.getProductMaterialList())) {
for (CartGoods.MaterialGoods materialGoods : cartGood.getProductMaterialList()) {
product.setAmount(product.getAmount() + Integer.valueOf(materialGoods.getOriginalPrice() + ""));
totalAmount = totalAmount + materialGoods.getOriginalPrice() * cartGood.getQty();
}
}
// todo :小料价格累加到主商品上
//if (CollectionUtils.isNotEmpty(cartGood.getProductMaterialList())) {
// for (CartGoods.MaterialGoods materialGoods : cartGood.getProductMaterialList()) {
// product.setAmount(product.getAmount() + Integer.valueOf(materialGoods.getOriginalPrice() + ""));
// totalAmount = totalAmount + materialGoods.getOriginalPrice() * cartGood.getQty();
// }
//}
// 数量
product.setQuantity(cartGood.getQty());
productList.add(product);
......
......@@ -173,16 +173,6 @@ public class ItemServiceImpl implements ItemService {
getProductsVo.setCustomerCode(productBean.getCustomerCode());
getProductsVo.setCategory(productBean.getCategory());
getProductsVo.setCategoryName(productBean.getCategoryName());
if (CollectionUtils.isNotEmpty(productBean.getAdditionalGroupList())) {
ArrayList<String> spuIds = new ArrayList<>();
List<ProductBean.ProductGroupType> additionalGroupList = productBean.getAdditionalGroupList();
for (ProductBean.ProductGroupType productGroupType : additionalGroupList) {
for (ProductBean.ProductGroupType.GroupDetailType groupDetailType : productGroupType.getGroupDetail()) {
spuIds.add(groupDetailType.getProductId());
}
}
getProductsVo.setMaterialSpuIds(spuIds);
}
resultMap.put(productBean.getPid(), getProductsVo);
getProductsVo.setType(1);
// 规格ID 剔除单品
......
......@@ -86,16 +86,19 @@ public class MaterialPromotionService implements IPromotionService {
pk = shoppingCartConvertAdapter.jointPk(product.getCartGoodsUid(), materialGoods.getSpuId());
MaterialApportion material = map.get(pk);
if (material != null && material.getApportionAmount().intValue() == 0) continue;
List<ActivityDiscountsDto> activityDiscountsDtos = materialGoods.getActivityDiscountsDtos();
if (CollectionUtils.isEmpty(activityDiscountsDtos)) {
activityDiscountsDtos = new ArrayList<>();
}
//设置行记录参加的活动及总优惠
ActivityDiscountsDto activityDiscountsDto = new ActivityDiscountsDto();
List<ActivityDiscountsDto> activityDiscountsDtoList = new ArrayList<>();
activityDiscountsDto.setActivityCode(material.getDetails().activityCode);
activityDiscountsDto.setActivityName(material.getDetails().activityName);
activityDiscountsDto.setActivityType(material.getDetails().activityType);
activityDiscountsDto.setDiscountAmount(material.getApportionAmount());
activityDiscountsDtoList.add(activityDiscountsDto);
activityDiscountsDtos.add(activityDiscountsDto);
materialGoods.setActivityDiscountsDtos(activityDiscountsDtoList);
materialGoods.setActivityDiscountsDtos(activityDiscountsDtos);
//materialGoods.setTotalDiscountAmount((materialGoods.getOriginalPrice().intValue() - materialGoods.getSalePrice().intValue()) * product.getQty());
materialGoods.setTotalDiscountAmount(material.getTotalDiscountAmount());
product.setProductType(GoodsTypeEnum.MATERIAL.getGoodsType());
......
......@@ -254,11 +254,8 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
allCartGoodsList.get(allCartGoodsList.indexOf(cartGoods)).getQty() + cartGoods.getQty() : cartGoods.getQty();
*/
Integer checkQty = this.checkSkuQty(allCartGoodsList, cartGoods);
//查询多个商品库存信息
queryManyGoodsStocks(addShoppingCartGoodsRequestVo, productIds, productBeanListSpuClass, skuId, checkQty);
this.checkMaterial(productBeanListSpuClass, cartGoods);
//ShoppingCartConvertAdapter.setClassification(cartGoods, productBeanListSpuClass);
String productName = null;
// 当添加的商品不是商品券时
if (!spuId.startsWith(CommonsConstant.COUPON_PREFIX)) {
......@@ -269,7 +266,8 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
this.addProductGoods(addShoppingCartGoodsRequestVo, cartGoods, spuId2, userId, shoppingCartGoodsResponseVo,
spuId, allCartGoodsList, productBeanListSpuClass);
}
//todo 加料校验
this.checkMaterial(allCartGoodsList);
Long deliveryAmount = calculateDeliveryAmount(receiveId, partnerId, storeId, userLoginInfoDto.getWxAppid(), shoppingCartGoodsResponseVo);
// 获取优惠信息
......@@ -362,6 +360,9 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
shoppingCartGoodsResponseVo.setToastMsg(checkCartRequest.getShoppingCartGoodsResponseVo().getToastMsg());
}
cartGoodsList = JSONArray.parseArray(JSONObject.toJSONString(checkCartRequest.getCartGoodsList()), CartGoods.class);
this.checkMaterial(cartGoodsList);
// 重新存储最新购物车
assortmentSdkService.setShoppingCart(partnerId, storeId, userId, cartGoodsList, updateShoppingCartGoodsQtyRequestVo.getSessionId(), "", shoppingCartBaseService);
......@@ -405,29 +406,13 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
List<String> pids = new ArrayList<>();
pids.add(cartGoods.getGoodsId());
Map<String, GetProductsVo> products = itemService.getProducts(pids, partnerId, storeId, BusinessTypeEnum.getByType(updateShoppingCartGoodsQtyRequestVo.getMenuType()).getCode());
//if (CollectionUtils.isEmpty(cartGoods.getProductMaterialList())) return;
//if (CollectionUtils.isEmpty(products.getAdditionalGroupList())) {
// throw new ServiceException(ResponseResult.SHOPPING_CART_VERSION_ERROR);
//}
GetProductsVo getProductsVo = products.get(cartGoods.getGoodsId());
// 商品没有库存限制
if (getProductsVo == null) {
if (getProductsVo == null || getProductsVo.getStockLimit() != 1) {
return;
}
//Todo 增加小料商品是否变化
/*
if (CollectionUtils.isNotEmpty(cartGoods.getProductMaterialList())) {
if (CollectionUtils.isEmpty(getProductsVo.getMaterialSpuIds())) {
throw new ServiceException(ResponseResult.SHOPPING_CART_VERSION_ERROR);
}
for (CartGoods.MaterialGoods materialGoods : cartGoods.getProductMaterialList()) {
if (!getProductsVo.getMaterialSpuIds().contains(materialGoods.getSpuId())) {
throw new ServiceException(ResponseResult.SHOPPING_CART_VERSION_ERROR);
}
}
}
*/
if (getProductsVo.getStockLimit() != 1) return;
ShoppingCartConvertAdapter.setClassification(cartGoods, getProductsVo);
GetProductStockRequestDto requestDto = new GetProductStockRequestDto();
requestDto.setChannel(BusinessTypeEnum.getByType(updateShoppingCartGoodsQtyRequestVo.getMenuType()).getCode());
......@@ -483,6 +468,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
shoppingCartGoodsResponseVo.setToastMsg(checkCartRequest.getShoppingCartGoodsResponseVo().getToastMsg());
}
cartGoodsList = JSONArray.parseArray(JSONObject.toJSONString(checkCartRequest.getCartGoodsList()), CartGoods.class);
this.checkMaterial(cartGoodsList);
// 重新存储最新购物车
assortmentSdkService.setShoppingCart(partnerId, storeId, userId, cartGoodsList, assortmentCustomerInfoVo.getSessionId(), "", this.shoppingCartBaseService);
}
......@@ -637,7 +623,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
shoppingCartGoodsResponseVo.setToastMsg(cartGoodsResponseVo.getToastMsg());
}
cartGoodsList = JSONArray.parseArray(JSONObject.toJSONString(checkCartRequest.getCartGoodsList()), CartGoods.class);
this.checkMaterial(cartGoodsList);
// 多规格的sku商品计算包装费
//this.checkSkuOnVersion(cartGoodsList, partnerId, storeId, shoppingCartGoodsResponseVo);
// 重新存储最新购物车
......@@ -1647,22 +1633,14 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
}
}
public void checkMaterial(List<ProductBeanDTO> productBeanListSpuClass, CartGoods cartGoods) {
if (CollectionUtils.isEmpty(cartGoods.getProductMaterialList())) return;
if (CollectionUtils.isEmpty(productBeanListSpuClass.get(0).getAdditionalGroupList())) {
/**
*用商品行信息来识别加料信息是否有效
* @param allCartGoodsList
*/
public void checkMaterial(List<CartGoods> allCartGoodsList) {
if (CollectionUtils.isEmpty(allCartGoodsList)) return;
if(allCartGoodsList.stream().filter(e->e.getGoodsType().equals(GoodsTypeEnum.EXCEPTION_GOODS.getGoodsType())).count()>0) {
throw new ServiceException(ResponseResult.SHOPPING_CART_MATERIAL_ERROR);
}
Boolean tips = false;
for (CartGoods.MaterialGoods materialGoods : cartGoods.getProductMaterialList()) {
for (ProductBeanDTO.ProductGroupType productGroupType : productBeanListSpuClass.get(0).getAdditionalGroupList()) {
long l = productGroupType.getGroupDetail().stream().filter(e -> e.getProductId().equals(materialGoods.getSpuId())).count();
if (l == 0) {
tips = true;
break;
}
}
if (tips) break;
}
if (tips) throw new ServiceException(ResponseResult.SHOPPING_CART_MATERIAL_ERROR);
}
}
......@@ -79,7 +79,10 @@ public class XyDiscountServiceImpl implements IPromotionService {
for (ApportionGoodsDetail detail : apportionGoodsDetail) {
if (detail.getCartGoodsUid().equals(product.getCartGoodsUid())) {
product.setTotalDiscountAmount(product.getTotalDiscountAmount() + detail.getActivityApportionAmount().intValue());
List<ActivityDiscountsDto> activityDiscountsDtoList = new ArrayList<>();
List<ActivityDiscountsDto> activityDiscountsDtoList = product.getActivityDiscountsDtos();
if (CollectionUtils.isEmpty(activityDiscountsDtoList)) {
activityDiscountsDtoList = new ArrayList<>();
}
ActivityDiscountsDto activityDiscountsDto = new ActivityDiscountsDto();
activityDiscountsDto.setActivityCode(detail.getActivityCode());
activityDiscountsDto.setActivityName(detail.getActivityName());
......@@ -87,6 +90,7 @@ public class XyDiscountServiceImpl implements IPromotionService {
activityDiscountsDto.setDiscountAmount(detail.getActivityApportionAmount().intValue());
activityDiscountsDtoList.add(activityDiscountsDto);
product.setActivityDiscountsDtos(activityDiscountsDtoList);
}
}
}
......
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