[Lilishop Mall] No3-6. Detailed design of modules, detailed design of product modules-2 (commodities and strongly related affiliated products sku, wholesale, albums, etc.)

   Only the backend is involved, see the top column for all directories, codes, documents, and interface paths are:

[Lilishop Mall] Record the study notes of the B2B2C mall system~


The whole article will combine the business introduction to focus on the design logic, including the interface class and business class. The specific combination of source code analysis is not complicated to read~

Caution: Some comments in the source code are wrong, some comments have completely opposite meanings, and some comments are not correct. I updated them during the reading process and added new comments where I did not know. So be careful when reading the source code!

Table of contents

A1. Commodity information

B1.S terminal (belongs to explicit operation) 

Remarks (business logic, can be skipped):

B2.M terminal (belongs to explicit operation)

A2. Commodity template information

B1.S terminal (belongs to explicit operation)


Play the picture again, this article focuses on the products on the right and their strong related information~

A1. Commodity information

First of all, product information needs to be managed on a separate page, and the information in the product, such as albums, wholesale information, and SKU information, all exist with the product. After deleting the product, these will also be deleted, and they will not be configured separately. The page ~ is different from product categories, brands, etc.

Therefore, only the product has a separate operation page, and its auxiliary information is edited on the new and edit pages~ so there is no separate controller interface~ it is only operated at the business layer.

B1.S terminal (belongs to explicit operation) 

Let’s talk about the S side of the store first, because the products are added by the store, let’s start with the added side~

These are the data that need to be obtained for adding and editing, let’s explain it here~~~

  • Merchant freight template list (see No3-5- store side, specification interface)
  • Query the parameter information bound under a certain category (see No3-5- store end, specification interface)
  • Obtain the brand information associated with the selected category (see No3-5- Store side, commodity category interface)
  • Obtain classification specifications according to categoryId (see No3-5- store side, specification interface)
  • Obtain the unit of measurement of the product by page (see No3-5- store side, unit interface)
  • Get the current store product category list (see No3-5- store side, store category interface)

The interface of the commodity module

  • Get the product list by pagination, get by id
  • Add new products, modify products, remove products, put products on shelves, delete products
  • Set product shipping templates in batches, obtain product Sku list by page, and modify product inventory

 

Remarks (business logic, can be skipped):

To put it simply, when adding a product, add parameters in the product business layer, add product sku, add Gallery pictures, and then add batch sales information in the product sku~

//添加商品时,在商品业务层里面添加参数、添加商品sku、添加Gallery图片
@Service
public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements GoodsService {

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void addGoods(GoodsOperationDTO goodsOperationDTO) {
        Goods goods = new Goods(goodsOperationDTO);
        //检查商品
        this.checkGoods(goods);
        //向goods加入图片
        if (goodsOperationDTO.getGoodsGalleryList().size() > 0 ) {
            this.setGoodsGalleryParam(goodsOperationDTO.getGoodsGalleryList().get(0), goods);
        }
        //添加商品参数
        if (goodsOperationDTO.getGoodsParamsDTOList() != null && !goodsOperationDTO.getGoodsParamsDTOList().isEmpty()) {
            //给商品参数填充值
            goods.setParams(JSONUtil.toJsonStr(goodsOperationDTO.getGoodsParamsDTOList()));
        }
        //添加商品
        this.save(goods);
        //添加商品sku信息
        this.goodsSkuService.add(goods, goodsOperationDTO);
        //添加相册
        if (goodsOperationDTO.getGoodsGalleryList() != null && !goodsOperationDTO.getGoodsGalleryList().isEmpty()) {
            this.goodsGalleryService.add(goodsOperationDTO.getGoodsGalleryList(), goods.getId());
        }
        this.generateEs(goods);
    }

}


//在商品sku里面添加批量销售信息~
@Service
public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> implements GoodsSkuService {

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void add(Goods goods, GoodsOperationDTO goodsOperationDTO) {
        // 是否存在规格
        if (goodsOperationDTO.getSkuList() == null || goodsOperationDTO.getSkuList().isEmpty()) {
            throw new ServiceException(ResultCode.MUST_HAVE_GOODS_SKU);
        }
        // 检查是否需要生成索引
        List<GoodsSku> goodsSkus = GoodsSkuBuilder.buildBatch(goods, goodsOperationDTO.getSkuList());
        //渲染商品sku
        this.renderGoodsSkuList(goodsSkus, goodsOperationDTO);

        if (!goodsSkus.isEmpty()) {
            this.saveOrUpdateBatch(goodsSkus);
            this.updateStock(goodsSkus);
        }
    }

    /**
     * 批量渲染商品sku
     *
     * @param goodsSkuList      sku集合
     * @param goodsOperationDTO 商品操作DTO
     */
    @Override
    public void renderGoodsSkuList(List<GoodsSku> goodsSkuList, GoodsOperationDTO goodsOperationDTO) {
        // 商品销售模式渲染器
        salesModelRenders.stream()
                .filter(i -> i.getSalesMode().equals(goodsOperationDTO.getSalesModel()))
                .findFirst()
                .ifPresent(i -> i.renderBatch(goodsSkuList, goodsOperationDTO));
        for (GoodsSku goodsSku : goodsSkuList) {
            extendOldSkuValue(goodsSku);
            this.renderImages(goodsSku);
        }
    }

}

B2.M terminal (belongs to explicit operation)

The operation M terminal can manage all products on the platform, and the shop system divides product management into product management and product review

  • Obtain products by page, obtain product sku list by page, obtain products to be reviewed by page, obtain product details by id, review products by administrators, remove products by administrators, and put products on shelves by administrators

 

A2. Commodity template information

Commodity templates have nothing to do with the main business, but are just for the convenience of store users.

Users can save product templates, and then select product templates when adding new products~~~

A product template can be understood as a product draft, which is a product for release. In other systems, a draft status is added to the product table, but here a new product template table is used, see the specific use~

Therefore, only the S side of the store will use the product template.

B1.S terminal (belongs to explicit operation)

  • Get the list of draft products by page, get draft products by ID, save draft products, add or modify, delete draft products

 

 

Guess you like

Origin blog.csdn.net/vaevaevae233/article/details/128283034