Commit 01661807 by chongfu.liang

加料支持多份

parent b5639e26
......@@ -3,6 +3,7 @@ package cn.freemud.demo.adapter.manager;
import cn.freemud.demo.entities.bo.product.ProductStockBO;
import cn.freemud.demo.entities.bo.goods.ValiadShopProductBO;
import cn.freemud.demo.entities.bo.goods.ProductBO;
import cn.freemud.entities.dto.GetMenuResponseDto;
import cn.freemud.entities.dto.GetProductStockResponseDto;
import cn.freemud.utils.BeanUtil;
import com.freemud.application.sdk.api.productcenter.domain.ProductBeanDTO;
......@@ -19,7 +20,7 @@ public class ProductDTO2BOAdapter {
@Resource
private MapperFacade mapperFacade;
public ProductBO convert2ProductBO(ProductBeanDTO productBeanDTO) {
public ProductBO convert2ProductBO(GetMenuResponseDto.DataBean.RootNodeBean.ChildrenBeanFirst.ChildrenBeanSecond.ProductBean productBeanDTO) {
ProductBO productBO = BeanUtil.convertBean(productBeanDTO, ProductBO::new);
productBO.setGoodsId(productBeanDTO.getPid());
......
......@@ -206,7 +206,7 @@ public class CalculationSharingAdapter {
GetCalculationDiscountBO.CalculationDiscountGoods.Material material = new GetCalculationDiscountBO.CalculationDiscountGoods.Material();
material.setType(1);
material.setGoodsId(materialGoods.getSpuId());
material.setGoodsQuantity(1);
material.setGoodsQuantity(materialGoods.getQty());
material.setOriginalPrice(materialGoods.getFinalPrice());
materials.add(material);
}
......
......@@ -39,6 +39,10 @@ public class ProductBO {
* 数量
*/
private Integer qty;
/**
* 加料最大限购
*/
private Integer maxNum;
private String category;
/**
* 分类名
......
......@@ -12,10 +12,7 @@ import cn.freemud.demo.entities.bo.product.GetProductBySkuIdBO;
import cn.freemud.demo.entities.bo.product.GetProductStock;
import cn.freemud.demo.entities.bo.product.GetRequiredProductListBO;
import cn.freemud.demo.entities.bo.product.ProductStockBO;
import cn.freemud.entities.dto.GetProductStockRequestDto;
import cn.freemud.entities.dto.GetProductStockResponseDto;
import cn.freemud.entities.dto.ProductBaseResponse;
import cn.freemud.entities.dto.RequiredProductRequest;
import cn.freemud.entities.dto.*;
import cn.freemud.enums.ResponseResult;
import cn.freemud.interceptor.ServiceException;
import cn.freemud.service.ItemService;
......@@ -67,11 +64,11 @@ public class KgdProductServiceImpl implements ProductService {
public List<ProductBO> getProductInfo(GetProductBO getProductBO) {
// 获取添加商品的详细信息
List<ProductBeanDTO> productBeanListSpuClass = assortmentSdkService.getProductsInfoSdk(getProductBO.getPartnerId(),
List<GetMenuResponseDto.DataBean.RootNodeBean.ChildrenBeanFirst.ChildrenBeanSecond.ProductBean> productBeanListSpuClass = assortmentSdkService.getProductsInfo(getProductBO.getPartnerId(),
getProductBO.getStoreId(), getProductBO.getGoodsId(), getProductBO.getMenuType(), shoppingCartBaseService);
List<ProductBO> productList = new ArrayList<>();
for (ProductBeanDTO dto : productBeanListSpuClass){
for (GetMenuResponseDto.DataBean.RootNodeBean.ChildrenBeanFirst.ChildrenBeanSecond.ProductBean dto : productBeanListSpuClass){
ProductBO platformProductBO = productDTO2BOAdapter.convert2ProductBO(dto);
productList.add(platformProductBO);
}
......
......@@ -360,6 +360,10 @@ public abstract class AbstractAddGoodsService implements AddGoodsService {
this.checkStocks(baseRequestDTO, checkBussinessRulesBO);
// 校验套餐
this.checkMeal(checkBussinessRulesBO.getCartGoods(), baseRequestDTO.getAddGoods());
// 检查商品小料数量
this.checkMaterialQty(addGoods,checkBussinessRulesBO.getProduct());
// 检查校验购物车商品(是否合法,上下架,点餐方式,是否在当前菜单中...),并移除非法商品
ShoppingCartContext cartContext = convert2ShopingCartContext(baseRequestDTO);
......@@ -378,6 +382,25 @@ public abstract class AbstractAddGoodsService implements AddGoodsService {
return bo;
}
private void checkMaterialQty(CartGoods addGoods, ProductBO product){
Integer materialMaxQty = product.getMaxNum();
Integer addProductqty = 0;
if(CollectionUtils.isNotEmpty(addGoods.getProductMaterialList())){
for(CartGoods.MaterialGoods materialRequestVo : addGoods.getProductMaterialList()){
addProductqty = addProductqty + (materialRequestVo.getQty() == null ? 0 : materialRequestVo.getQty());
}
}
if(materialMaxQty == null || ObjectUtils.equals(materialMaxQty,0) || addProductqty == null || ObjectUtils.equals(addProductqty,0)){
return ;
}
if(materialMaxQty.intValue() < addProductqty.intValue()){
return ;
}
throw new ServiceException(ResponseResult.SHOPPING_CART_MATERIA_QTY_LIMIT_ERR);
};
private DiscountResultBO commAddGoodsToShoppingCart(BaseAddGoodsBO baseRequestDTO, AddGoodsToShoppingCartBO addGoodsToShoppingCartBO) {
DiscountResultBO calCostBO = new DiscountResultBO();
List<CartGoods> cartGoods = shoppingBaseService.updateAndGetShoppingCart(addGoodsToShoppingCartBO.getCartGoods(), baseRequestDTO.getAddGoods(), addGoodsToShoppingCartBO.getShoppingCartContext());
......
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