Commit ba3ae383 by Arthur.liang

重构

parent 23b82cf7
package cn.freemud.demo.adapter.manager; package cn.freemud.demo.adapter.manager;
import cn.freemud.demo.entities.bo.goods.PlatformProductBO; import cn.freemud.demo.entities.bo.goods.PlatformProductBO;
import cn.freemud.demo.entities.bo.goods.ProductBO;
import com.freemud.application.sdk.api.productcenter.domain.ProductBeanDTO; import com.freemud.application.sdk.api.productcenter.domain.ProductBeanDTO;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@Component @Component
public class ProductDTO2BOAdapter { public class ProductDTO2BOAdapter {
public PlatformProductBO convert2ProductBO(ProductBeanDTO productBeanDTO) { public ProductBO convert2ProductBO(ProductBeanDTO productBeanDTO) {
return null; return null;
} }
......
package cn.freemud.demo.entities; package cn.freemud.demo.entities;
import cn.freemud.demo.entities.bo.goods.GetProductBO;
import cn.freemud.demo.entities.bo.goods.ProductBO;
import lombok.Data;
@Data
public class CheckBussinessRulesBO { public class CheckBussinessRulesBO {
private String userId;
private ProductBO product;
} }
package cn.freemud.demo.entities.bo.goods;
import lombok.Data;
import java.util.List;
@Data
public class ComboxGoodsBO {
/**
* 麦咖啡多规格商品spuid
*/
private String spuId;
private String skuId;
private Integer qty;
private String goodsId;
/**
* 商品组Id
*/
private Long productGroupId;
/**
* 第三方商品编号
*/
private String customerCode;
/**
* 购物车一行商品的名称
*/
private String name;
/**
* 商品的spuName
*/
private String spuName;
/**
* 商品的skuName
*/
private String skuName;
/**
* 购物车一行商品的现单价
*/
private Long finalPrice;
/**
* 购物车一行商品的原单机
*/
private Long originalPrice;
/**
* 购物车一行商品的原价
*/
private Long originalAmount;
/**
* 购物车一行商品的现价
*/
private Long amount;
/**
* 麦咖啡空键位
*/
private String emptyKey;
/**
* 商品额外的属性
*/
List<CartGoodsExtra> extra;
/**
* 商品额外的属性
*/
List<CartGoodsExtra> specialExtra;
/**
* 麦咖啡多规格商品加料
*/
private List<McoffeeMaterialBO> productMaterialList;
}
package cn.freemud.demo.entities.bo.goods;
import lombok.Data;
@Data
public class MaterialBO {
/**
* 加料商品ID
*/
private String spuId;
/**
* 加料商品组ID
*/
private String groupId;
/**
* 麦咖啡入机键位
*/
private String customerCode;
}
package cn.freemud.demo.entities.bo.goods;
import lombok.Data;
import java.util.List;
@Data
public class ProductBO {
private String spuId;
private String skuId;
private String goodsId;
private String nodeId;
private Integer goodsType;
/**
* 数量
*/
private Integer qty;
/**
* 分类名
*/
private String categoryName;
/**
* 商品额外的属性
*/
private List<CartGoodsExtra> extra;
/**
* 商品额外的属性
*/
List<CartGoodsExtra> specialExtra;;
/**
* 套餐固定商品
*/
private List<McoffeeComboxGoodsBO> productComboList;
/**
* 套餐可选商品
*/
private List<McoffeeComboxGoodsBO> productGroupList;
/**
* 加料
*/
private List<McoffeeMaterialBO> productMaterialList;
}
...@@ -3,6 +3,7 @@ package cn.freemud.demo.manager.product; ...@@ -3,6 +3,7 @@ package cn.freemud.demo.manager.product;
import cn.freemud.demo.adapter.manager.ProductDTO2BOAdapter; import cn.freemud.demo.adapter.manager.ProductDTO2BOAdapter;
import cn.freemud.demo.entities.bo.goods.GetProductBO; import cn.freemud.demo.entities.bo.goods.GetProductBO;
import cn.freemud.demo.entities.bo.goods.PlatformProductBO; import cn.freemud.demo.entities.bo.goods.PlatformProductBO;
import cn.freemud.demo.entities.bo.goods.ProductBO;
import cn.freemud.service.impl.AssortmentSdkService; import cn.freemud.service.impl.AssortmentSdkService;
import com.freemud.application.sdk.api.productcenter.domain.ProductBeanDTO; import com.freemud.application.sdk.api.productcenter.domain.ProductBeanDTO;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -22,13 +23,13 @@ public class KgdProductServiceImpl implements ProductService { ...@@ -22,13 +23,13 @@ public class KgdProductServiceImpl implements ProductService {
private ProductDTO2BOAdapter productDTO2BOAdapter; private ProductDTO2BOAdapter productDTO2BOAdapter;
@Override @Override
public PlatformProductBO getProductInfo(GetProductBO getProductBO) { public ProductBO getProductInfo(GetProductBO getProductBO) {
// 获取添加商品的详细信息 // 获取添加商品的详细信息
List< ProductBeanDTO> productBeanListSpuClass = assortmentSdkService.getProductsInfoSdk(getProductBO.getPartnerId(), List< ProductBeanDTO> productBeanListSpuClass = assortmentSdkService.getProductsInfoSdk(getProductBO.getPartnerId(),
getProductBO.getStoreId(), Collections.singletonList(getProductBO.getSkuid()), getProductBO.getMenuType(), null); getProductBO.getStoreId(), Collections.singletonList(getProductBO.getSkuid()), getProductBO.getMenuType(), null);
ProductBeanDTO productBeanDTO = productBeanListSpuClass.get(0); ProductBeanDTO productBeanDTO = productBeanListSpuClass.get(0);
PlatformProductBO platformProductBO = productDTO2BOAdapter.convert2ProductBO(productBeanDTO); ProductBO platformProductBO = productDTO2BOAdapter.convert2ProductBO(productBeanDTO);
return platformProductBO; return platformProductBO;
} }
......
...@@ -2,6 +2,7 @@ package cn.freemud.demo.manager.product; ...@@ -2,6 +2,7 @@ package cn.freemud.demo.manager.product;
import cn.freemud.demo.entities.bo.goods.GetProductBO; import cn.freemud.demo.entities.bo.goods.GetProductBO;
import cn.freemud.demo.entities.bo.goods.PlatformProductBO; import cn.freemud.demo.entities.bo.goods.PlatformProductBO;
import cn.freemud.demo.entities.bo.goods.ProductBO;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@Service @Service
...@@ -11,9 +12,9 @@ public class ProductManager { ...@@ -11,9 +12,9 @@ public class ProductManager {
* *
* @return * @return
*/ */
public PlatformProductBO getProductsInfo(GetProductBO getProductBO, ProductService productService){ public ProductBO getProductsInfo(GetProductBO getProductBO, ProductService productService){
PlatformProductBO productInfo = productService.getProductInfo(getProductBO); ProductBO productInfo = productService.getProductInfo(getProductBO);
return productInfo; return productInfo;
......
...@@ -2,9 +2,10 @@ package cn.freemud.demo.manager.product; ...@@ -2,9 +2,10 @@ package cn.freemud.demo.manager.product;
import cn.freemud.demo.entities.bo.goods.GetProductBO; import cn.freemud.demo.entities.bo.goods.GetProductBO;
import cn.freemud.demo.entities.bo.goods.PlatformProductBO; import cn.freemud.demo.entities.bo.goods.PlatformProductBO;
import cn.freemud.demo.entities.bo.goods.ProductBO;
public interface ProductService { public interface ProductService {
PlatformProductBO getProductInfo(GetProductBO getProductBO); ProductBO getProductInfo(GetProductBO getProductBO);
} }
...@@ -4,6 +4,8 @@ import cn.freemud.base.entity.BaseResponse; ...@@ -4,6 +4,8 @@ import cn.freemud.base.entity.BaseResponse;
import cn.freemud.demo.constant.ResponseConstant; import cn.freemud.demo.constant.ResponseConstant;
import cn.freemud.demo.entities.*; import cn.freemud.demo.entities.*;
import cn.freemud.demo.entities.bo.goods.GetProductBO; import cn.freemud.demo.entities.bo.goods.GetProductBO;
import cn.freemud.demo.entities.bo.goods.PlatformProductBO;
import cn.freemud.demo.entities.bo.goods.ProductBO;
import cn.freemud.demo.entities.bo.goods.add.BaseAddGoodsBO; import cn.freemud.demo.entities.bo.goods.add.BaseAddGoodsBO;
import cn.freemud.demo.manager.product.ProductManager; import cn.freemud.demo.manager.product.ProductManager;
import cn.freemud.demo.manager.customer.CustomerManager; import cn.freemud.demo.manager.customer.CustomerManager;
...@@ -100,15 +102,12 @@ public abstract class AbstractAddGoodsService implements AddGoodsService { ...@@ -100,15 +102,12 @@ public abstract class AbstractAddGoodsService implements AddGoodsService {
public final CheckBussinessRulesBO getShoppingCartInfo(BaseAddGoodsBO baseRequestBO) { public final CheckBussinessRulesBO getShoppingCartInfo(BaseAddGoodsBO baseRequestBO) {
CheckBussinessRulesBO bo = new CheckBussinessRulesBO(); CheckBussinessRulesBO bo = new CheckBussinessRulesBO();
String userId = customerManager.getUserId(baseRequestBO.getSessionId(), baseRequestBO.getManagerService().getCustomerService()); String userId = customerManager.getUserId(baseRequestBO.getSessionId(), baseRequestBO.getManagerService().getCustomerService());
baseRequestBO.setUserId(userId); bo.setUserId(userId);
GetProductBO getProductBO = convert2ProductBO(baseRequestBO); GetProductBO getProductBO = convert2ProductBO(baseRequestBO);
productManager.getProductsInfo(getProductBO, baseRequestBO.getManagerService().getProductService()); ProductBO productsInfo = productManager.getProductsInfo(getProductBO, baseRequestBO.getManagerService().getProductService());
bo.setProduct(productsInfo);
return bo; return bo;
} }
......
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