谷粒商城-个人笔记(基础篇二)

目录

1.4、商品维护

1.4.1、spu管理

01)、获取spu规格

02)、修改商品规格

1.4.2、发布商品

1)、获取所有会员等级

2)、获取分类关联的品牌

3)、获取分类下所有分组&关联属性

4)、新增商品

5)、spu检索

6)、sku检索

 3、库存系统

 3.1、仓库维护

1)、仓库列表

 3.3、商品库存

1)、查询商品库存

3.4、采购单维护

3.4.1、采购单需求 

1)、查询采购需求

2)、查询未领取的采购单

3)、合并采购需求

4)、领取采购单

3.4.2、采购单 

1)、完成采购


1.4、商品维护

1.4.1、spu管理

01)、获取spu规格

GET     /product/attr/base/listforspu/{spuId}

响应数据

{
    "msg": "success",
    "code": 0,
    "data": [{
    "id": 43,
    "spuId": 11,
    "attrId": 7,
    "attrName": "入网型号",
    "attrValue": "LIO-AL00",
    "attrSort": null,
    "quickShow": 1
    }]

修改“com.atguigu.gulimall.product.controller.AttrController”类,代码如下:

 @GetMapping("/base/listforspu/{spuId}")
    public R baseAttrListForSpu(@PathVariable("spuId") Long spuId){
        List entities = productAttrValueService.baseAttrListForSpu(spuId);
        return R.ok().put("data",entities);

    }

修改“com.atguigu.gulimall.product.service.ProductAttrValueService”类,代码如下:

List baseAttrListForSpu(Long spuId);

修改“com.atguigu.gulimall.product.service.impl.ProductAttrValueServiceImpl”类,代码如下:

 @Override
    public List baseAttrListForSpu(Long spuId) {
        List entities = this.baseMapper.selectList(new QueryWrapper().eq("spu_id", spuId));
        return entities;
    }

02)、修改商品规格

POST    /product/attr/update/{spuId}

请求参数

[{
        "attrId": 7,
                "attrName": "入网型号",
                "attrValue": "LIO-AL00",
                "quickShow": 1
    }, {
        "attrId": 14,
                "attrName": "机身材质工艺",
                "attrValue": "玻璃",
                "quickShow": 0
    }, {
        "attrId": 16,
                "attrName": "CPU型号",
                "attrValue": "HUAWEI Kirin 980",
                "quickShow": 1
}]

响应数据

{
    "msg": "success",
    "code": 0
}

修改“com.atguigu.gulimall.product.controller.AttrController”类,代码如下:

    @PostMapping("/update/{spuId}")
    public R updateSpuAttr(@PathVariable("spuId") Long spuId,
                           @RequestBody List entities){
        productAttrValueService.updateSpuAttr(spuId,entities);
        return R.ok();

    }

修改“com.atguigu.gulimall.product.controller.AttrController”类,代码如下:

void updateSpuAttr(Long spuId, List entities);

修改“com.atguigu.gulimall.product.controller.AttrController”类,代码如下:

    @Transactional
    @Override
    public void updateSpuAttr(Long spuId, List entities) {
        //1、删除spu之前对应的所有属性
        this.baseMapper.delete(new QueryWrapper().eq("spu_id",spuId));
        List collect = entities.stream().map(item -> {
            item.setSpuId(spuId);
            return item;
        }).collect(Collectors.toList());
        this.saveBatch(collect);
   }

1.4.2、发布商品

商品管理需要会员等级,先把资料前端文件夹里的modules里的文件导入vsCode里重新运行,添加几个会员

1)、获取所有会员等级

POST     /member/memberlevel/list

请求参数

{
   page: 1,//当前页码
   limit: 10,//每页记录数
   sidx: 'id',//排序字段
   order: 'asc/desc',//排序方式
   key: '华为'//检索关键字
}

分页数据

响应数据

{
    "msg": "success",
    "code": 0,
    "page": {
        "totalCount": 0,
        "pageSize": 10,
        "totalPage": 0,
        "currPage": 1,
        "list": [{
            "id": 1,
            "name": "aaa",
            "growthPoint": null,
            "defaultStatus": null,
            "freeFreightPoint": null,
            "commentGrowthPoint": null,
            "priviledgeFreeFreight": null,
            "priviledgeMemberPrice": null,
            "priviledgeBirthday": null,
            "note": null
        }]
    }
}

修改“com.atguigu.gulimall.member.controller.MemberLevelController”类,代码如下:

@RequestMapping("/list")
    public R list(@RequestParam Map params){
        PageUtils page = memberLevelService.queryPage(params);

        return R.ok().put("page", page);
    }

修改“com.atguigu.gulimall.member.service.MemberLevelService”类,代码如下: 

 PageUtils queryPage(Map params);

 修改“com.atguigu.gulimall.member.service.impl.MemberLevelServiceImpl”类,代码如下: 

@Override
    public PageUtils queryPage(Map params) {
        IPage page = this.page(
                new Query().getPage(params),
                new QueryWrapper()
        );

        return new PageUtils(page);
    }

2)、获取分类关联的品牌

GET       /product/categorybrandrelation/brands/list

请求参数

参数名

参数类型 描述
catId long 分类id

响应数据

{
    "msg": "success",
    "code": 0,
    "data": [{
        "brandId": 0,
        "brandName": "string",
    }]
}

修改“com.atguigu.gulimall.product.controller.CategoryBrandRelationController”类,代码如下: 

/**
     * 获取三级分类下的所有品牌
     * /product/categorybrandrelation/brands/list
     *
     * 1、Controller: 处理请求,接收和校验数据
     * 2、service接收controller数据,进行业务处理
     * 3、Controller接收Service处理完的数据,封装页面指定的vo
     */
    @GetMapping("brands/list")
    public R relationBrandList(@RequestParam(value = "catId", required = true) Long catId){
        List list = categoryBrandRelationService.getBrandsByCatId(catId);
        List collect = list.stream().map(item -> {
            BrandVo brandVo = new BrandVo();
            brandVo.setBrandId(item.getBrandId());
            brandVo.setBrandName(item.getName());
            return brandVo;
        }).collect(Collectors.toList());
        return R.ok().put("data",collect);
    }

修改“com.atguigu.gulimall.product.service.CategoryBrandRelationService”类,代码如下:

List getBrandsByCatId(Long catId);

修改“com.atguigu.gulimall.product.service.impl.CategoryBrandRelationServiceImpl”类,代码如下:

 @Override
    public List getBrandsByCatId(Long catId) {
        List catelogId = categoryBrandRelationDao.selectList(new QueryWrapper().eq("catelog_id", catId));
        List collect = catelogId.stream().map(item -> {
            Long brandId = item.getBrandId();
            BrandEntity byId = brandService.getById(brandId);
            return byId;
        }).collect(Collectors.toList());
        return collect;
    }

3)、获取分类下所有分组&关联属性

GET     /product/attrgroup/{catelogId}/withattr

响应数据

{
    "msg": "success",
    "code": 0,
    "data": [{
        "attrGroupId": 1,
        "attrGroupName": "主体",
        "sort": 0,
        "descript": "主体",
        "icon": "dd",
        "catelogId": 225,
        "attrs": [{
            "attrId": 7,
            "attrName": "入网型号",
            "searchType": 1,
            "valueType": 0,
            "icon": "xxx",
            "valueSelect": "aaa;bb",
            "attrType": 1,
            "enable": 1,
            "catelogId": 225,
            "showDesc": 1,
            "attrGroupId": null
            }, {
            "attrId": 8,
            "attrName": "上市年份",
            "searchType": 0,
            "valueType": 0,
            "icon": "xxx",
            "valueSelect": "2018;2019",
            "attrType": 1,
            "enable": 1,
            "catelogId": 225,
            "showDesc": 0,
            "attrGroupId": null
            }]
        },
        {
        "attrGroupId": 2,
        "attrGroupName": "基本信息",
        "sort": 0,
        "descript": "基本信息",
        "icon": "xx",
        "catelogId": 225,
        "attrs": [{
            "attrId": 11,
            "attrName": "机身颜色",
            "searchType": 0,
            "valueType": 0,
            "icon": "xxx",
            "valueSelect": "黑色;白色",
            "attrType": 1,
            "enable": 1,
            "catelogId": 225,
            "showDesc": 1,
            "attrGroupId": null
        }]
    }]
}

修改“com.atguigu.gulimall.product.controller.AttrGroupController”类,代码如下:

@GetMapping("/{catelogId}/withattr")
    public R getAttrGroupWithAttrs(@PathVariable("catelogId") Long catelogId){
        //1、查出当前分类下的所有分组

        //2、查出每个分组下的所有属性
        List list = attrGroupService.getAttrGroupWithAttrsByCatelogId(catelogId);
        return R.ok().put("data",list);
    }

修改“com.atguigu.gulimall.product.service.AttrGroupService”类,代码如下:

    List getAttrGroupWithAttrsByCatelogId(Long catelogId);

修改“com.atguigu.gulimall.product.service.impl.AttrGroupServiceImpl”类,代码如下:

/**
     * 根据分类id查出所有的分组以及这些组里面的属性
     * @param catelogId
     * @return
     */
    @Override
    public List getAttrGroupWithAttrsByCatelogId(Long catelogId) {
        //1、查询分组信息
        List attrGroupEntities = this.list(new QueryWrapper().eq("catelog_id", catelogId));
        //2、查询所有属性
        List collect = attrGroupEntities.stream().map(item -> {
            AttrGroupWithAttrsVo attrsVo = new AttrGroupWithAttrsVo();
            BeanUtils.copyProperties(item, attrsVo);
            List attrs = attrService.getRelationAttr(attrsVo.getAttrGroupId());
            attrsVo.setAttrs(attrs);
            return attrsVo;
        }).collect(Collectors.toList());
        return collect;
    }

4)、新增商品

POST   /product/spuinfo/save

请求参数

{
    "spuName": "Apple XR",
    "spuDescription": "Apple XR",
    "catalogId": 225,
    "brandId": 12,
    "weight": 0.048,
    "publishStatus": 0,
    "decript": ["https://gulimall-hello.oss-cn-beijing.aliyuncs.com/2019-11-22//66d30b3f-e02f-48b1-8574-e18fdf454a32_f205d9c99a2b4b01.jpg"],
    "images": ["https://gulimall-hello.oss-cn-beijing.aliyuncs.com/2019-11-22//dcfcaec3-06d8-459b-8759-dbefc247845e_5b5e74d0978360a1.jpg", "https://gulimall-hello.oss-cn-beijing.aliyuncs.com/2019-11-22//5b15e90a-a161-44ff-8e1c-9e2e09929803_749d8efdff062fb0.jpg"],
    "bounds": {
        "buyBounds": 500,
        "growBounds": 6000
    },
    "baseAttrs": [{
        "attrId": 7,
        "attrValues": "aaa;bb",
        "showDesc": 1
    }, {
        "attrId": 8,
        "attrValues": "2019",
        "showDesc": 0
    }],
    "skus": [{
        "attr": [{
            "attrId": 9,
            "attrName": "颜色",
            "attrValue": "黑色"
        }, {
            "attrId": 10,
            "attrName": "内存",
            "attrValue": "6GB"
        }],
        "skuName": "Apple XR 黑色 6GB",
        "price": "1999",
        "skuTitle": "Apple XR 黑色 6GB",
        "skuSubtitle": "Apple XR 黑色 6GB",
        "images": [{
            "imgUrl": "https://gulimall-hello.oss-cn-beijing.aliyuncs.com/2019-11-22//dcfcaec3-06d8-459b-8759-dbefc247845e_5b5e74d0978360a1.jpg",
            "defaultImg": 1
            }, {
            "imgUrl": "https://gulimall-hello.oss-cn-beijing.aliyuncs.com/2019-11-22//5b15e90a-a161-44ff-8e1c-9e2e09929803_749d8efdff062fb0.jpg",
            "defaultImg": 0
        }],
        "descar": ["黑色", "6GB"],
        "fullCount": 5,
        "discount": 0.98,
        "countStatus": 1,
        "fullPrice": 1000,
        "reducePrice": 10,
        "priceStatus": 0,
        "memberPrice": [{
            "id": 1,
            "name": "aaa",
            "price": 1998.99
        }]
        }, {
        "attr": [{
            "attrId": 9,
            "attrName": "颜色",
            "attrValue": "黑色"
        }, {
            "attrId": 10,
            "attrName": "内存",
            "attrValue": "12GB"
        }],
        "skuName": "Apple XR 黑色 12GB",
        "price": "2999",
        "skuTitle": "Apple XR 黑色 12GB",
        "skuSubtitle": "Apple XR 黑色 6GB",
        "images": [{
            "imgUrl": "",
            "defaultImg": 0
        }, {
            "imgUrl": "",
            "defaultImg": 0
        }],
        "descar": ["黑色", "12GB"],
        "fullCount": 0,
        "discount": 0,
        "countStatus": 0,
        "fullPrice": 0,
        "reducePrice": 0,
        "priceStatus": 0,
        "memberPrice": [{
            "id": 1,
            "name": "aaa",
            "price": 1998.99
        }]
    }, {
        "attr": [{
            "attrId": 9,
            "attrName": "颜色",
            "attrValue": "白色"
        }, {
            "attrId": 10,
            "attrName": "内存",
            "attrValue": "6GB"
        }],
        "skuName": "Apple XR 白色 6GB",
        "price": "1998",
        "skuTitle": "Apple XR 白色 6GB",
        "skuSubtitle": "Apple XR 黑色 6GB",
        "images": [{
            "imgUrl": "",
            "defaultImg": 0
        }, {
            "imgUrl": "",
            "defaultImg": 0
        }],
        "descar": ["白色", "6GB"],
        "fullCount": 0,
        "discount": 0,
        "countStatus": 0,
        "fullPrice": 0,
        "reducePrice": 0,
        "priceStatus": 0,
        "memberPrice": [{
            "id": 1,
            "name": "aaa",
            "price": 1998.99
        }]
    }, {
        "attr": [{
            "attrId": 9,
            "attrName": "颜色",
            "attrValue": "白色"
        }, {
            "attrId": 10,
            "attrName": "内存",
            "attrValue": "12GB"
        }],
        "skuName": "Apple XR 白色 12GB",
        "price": "2998",
        "skuTitle": "Apple XR 白色 12GB",
        "skuSubtitle": "Apple XR 黑色 6GB",
        "images": [{
            "imgUrl": "",
            "defaultImg": 0
        }, {
            "imgUrl": "",
            "defaultImg": 0
        }],
        "descar": ["白色", "12GB"],
        "fullCount": 0,
        "discount": 0,
        "countStatus": 0,
        "fullPrice": 0,
        "reducePrice": 0,
        "priceStatus": 0,
        "memberPrice": [{
            "id": 1,
            "name": "aaa",
            "price": 1998.99
        }]
    }]
}

分页数据

响应数据

{
    "msg": "success",
    "code": 0
}

修改“com.atguigu.gulimall.product.controller.SpuInfoController”类,代码如下:

     /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody SpuSaveVo vo){
		//spuInfoService.save(spuInfo);
        spuInfoService.save(vo);

        return R.ok();
    }

修改“com.atguigu.gulimall.product.service.SpuInfoService”类,代码如下:

void save(SpuSaveVo vo);

void saveBaseSpuInfo(SpuInfoEntity infoEntity);

修改“com.atguigu.gulimall.product.service.impl.SpuInfoServiceImpl”类,代码如下:

/**
     * //TODO 高级部分完善
     * @param vo
     */
    @Transactional
    @Override
    public void save(SpuSaveVo vo) {

        //1、保存spu基本信息    pms_spu_info
        SpuInfoEntity infoEntity = new SpuInfoEntity();
        BeanUtils.copyProperties(vo,infoEntity);
        infoEntity.setCreateTime(new Date());
        infoEntity.setUpdateTime(new Date());
        this.saveBaseSpuInfo(infoEntity);

        //2、保存spu的描述图片  pms_spu_info_desc
        List decript = vo.getDecript();
        SpuInfoDescEntity descEntity = new SpuInfoDescEntity();
        descEntity.setSpuId(infoEntity.getId());
        //将所有图片描述拼接起来,用逗号隔开
        descEntity.setDecript(String.join(",",decript));
        spuInfoDescService.saveSpuInfoDesc(descEntity);

        //3、保存spu的图片集    pms_spu_images
        List images = vo.getImages();
        spuImagesService.saveImages(infoEntity.getId(),images);

        //4、保存spu的规格参数  pms_product_attr_value
        List baseAttrs = vo.getBaseAttrs();
        List collect = baseAttrs.stream().map(attr -> {
            ProductAttrValueEntity valueEntity = new ProductAttrValueEntity();
            valueEntity.setAttrId(attr.getAttrId());
            AttrEntity byId = attrService.getById(attr.getAttrId());
            valueEntity.setAttrName(byId.getAttrName());
            valueEntity.setAttrValue(attr.getAttrValues());
            valueEntity.setQuickShow(attr.getShowDesc());
            valueEntity.setSpuId(infoEntity.getId());
            return valueEntity;
        }).collect(Collectors.toList());
        productAttrValueService.saveProductAttr(collect);

        //5、保存spu的积分信息  gulimall_sms -> sms_spu_bounds
        Bounds bounds = vo.getBounds();
        SpuBoundTo spuBoundTo = new SpuBoundTo();
        BeanUtils.copyProperties(bounds,spuBoundTo);
        spuBoundTo.setSpuId(infoEntity.getId());
        R r = couponFeignService.saveSpuBounds(spuBoundTo);
        if (r.getCode() != 0){
            log.error("远程保存spu积分信息失败");
        }


        //6、保存当前spu对应的所有sku信息
        //6.1)、sku的基本信息  pms_sku_info
        List skus = vo.getSkus();
        if (skus != null && skus.size() >0){
            skus.forEach(item->{
                String defaultImg = "";
                for (Images image : item.getImages()) {
                    if (image.getDefaultImg() == 1){
                        defaultImg = image.getImgUrl();
                    }
                }
                SkuInfoEntity skuInfoEntity = new SkuInfoEntity();
                BeanUtils.copyProperties(item,skuInfoEntity);
                skuInfoEntity.setBrandId(infoEntity.getBrandId());
                skuInfoEntity.setCatalogId(infoEntity.getCatalogId());
                skuInfoEntity.setSaleCount(0L);
                skuInfoEntity.setSpuId(infoEntity.getId());
                skuInfoEntity.setSkuDefaultImg(defaultImg);
                skuInfoService.saveSkuInfo(skuInfoEntity);

                //6.2)、sku的图片信息  pms_sku_images
                Long skuId = skuInfoEntity.getSkuId();
                List imagesEntities = item.getImages().stream().map(img -> {
                    SkuImagesEntity imagesEntity = new SkuImagesEntity();
                    imagesEntity.setSkuId(skuId);
                    imagesEntity.setImgUrl(img.getImgUrl());
                    imagesEntity.setDefaultImg(img.getDefaultImg());
                    return imagesEntity;
                }).filter(entity->{
                    //返回true就是需要,返回false就是剔除
                    return !StringUtils.isEmpty(entity.getImgUrl());
                }).collect(Collectors.toList());
                // TODO 没有图片;路径的无需保存
                skuImagesService.saveBatch(imagesEntities);

                //6.3)、sku的销售属性信息   pms_sku_sale_attr_value
                List attr = item.getAttr();
                List skuSaleAttrValueEntities = attr.stream().map(a -> {
                    SkuSaleAttrValueEntity saleAttrValueEntity = new SkuSaleAttrValueEntity();
                    BeanUtils.copyProperties(a, saleAttrValueEntity);
                    saleAttrValueEntity.setSkuId(skuId);
                    return saleAttrValueEntity;
                }).collect(Collectors.toList());
                skuSaleAttrValueService.saveBatch(skuSaleAttrValueEntities);

                //6.4)、sku的优惠、满减等信息   gulimall_sms -> sms_sku_ladder/sms_sku_full_reduction/sms_member_price
                SkuReductionTo skuReductionTo = new SkuReductionTo();
                BeanUtils.copyProperties(item,skuReductionTo);
                skuReductionTo.setSkuId(skuId);
                if (skuReductionTo.getFullCount() > 0 || skuReductionTo.getFullPrice().compareTo(new BigDecimal("0")) == 1){
                    R r1 = couponFeignService.saveSkuReduction(skuReductionTo);
                    if (r1.getCode() != 0){
                        log.error("远程保存sku优惠信息失败");
                    }
                }

            });
        }

    }

//1、保存spu基本信息 pms_spu_info  

修改“com.atguigu.gulimall.product.service.impl.SpuInfoServiceImpl”类,代码如下: 

 @Override
    public void saveBaseSpuInfo(SpuInfoEntity infoEntity) {
        this.baseMapper.insert(infoEntity);
    }

//2、保存spu的描述图片  pms_spu_info_desc 

修改“com.atguigu.gulimall.product.service.SpuInfoDescService”类,代码如下: 

void saveSpuInfoDesc(SpuInfoDescEntity descEntity);

修改“com.atguigu.gulimall.product.service.impl.SpuInfoDescServiceImpl”类,代码如下:

@Override
    public void saveSpuInfoDesc(SpuInfoDescEntity descEntity) {
        this.baseMapper.insert(descEntity);
    }

//3、保存spu的图片集    pms_spu_images 
修改“com.atguigu.gulimall.product.service.SpuImagesService”类,代码如下:

void saveImages(Long id, List images);

修改“com.atguigu.gulimall.product.service.impl.SpuImagesServiceImpl”类,代码如下:

@Override
    public void saveImages(Long id, List images) {
        if (images == null || images.size() == 0){

        }else{
            List collect = images.stream().map(img -> {
                SpuImagesEntity entity = new SpuImagesEntity();
                entity.setSpuId(id);
                entity.setImgUrl(img);
                return entity;
            }).collect(Collectors.toList());
            this.saveBatch(collect);
        }
    }

//4、保存spu的规格参数  pms_product_attr_value 

修改“com.atguigu.gulimall.product.service.ProductAttrValueService”类,代码如下:

void saveProductAttr(List collect);

修改“com.atguigu.gulimall.product.service.impl.ProductAttrValueServiceImpl”类,代码如下:

 @Override
    public void saveProductAttr(List collect) {
        this.saveBatch(collect);
    }

//5、保存spu的积分信息 gulimall_sms --> sms_spu_bounds
注意:

重点:需要远程调用第三方服务
1、创建openFeign配置(前提第三方服务已经注册和配置到注册中心了)

2、在主程序类中加上@EnableFeignClients(basePackages = "com.atguigu.gulimall.product.feign")

@EnableFeignClients(basePackages = "com.atguigu.gulimall.product.feign")
@EnableDiscoveryClient
@MapperScan("com.atguigu.gulimall.product.dao")
@SpringBootApplication
public class GulimallProductApplication {

    public static void main(String[] args) {
        SpringApplication.run(GulimallProductApplication.class, args);
    }

}

3、在gulimall-common添加服务与服务之间调用的to类“com.atguigu.common.to.SpuBoundTo”类,代码如下:

@Data
public class SpuBoundTo {
    private Long SpuId;
    private BigDecimal buyBounds;
    private BigDecimal growBounds;
}

修改“com.atguigu.gulimall.product.feign.CouponFeignService”类,代码如下:

package com.atguigu.gulimall.product.feign;

import com.atguigu.common.to.SpuBoundTo;
import com.atguigu.common.utils.R;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author WangTianShun
 * @date 2020/10/16 8:54
 */
@FeignClient("gulimall-coupon")
public interface CouponFeignService {
    /**
     * 1、couponFeignService.saveSpuBounds(spuBoundTo)
     *      1)、@RequestBody将这个对象转为json
     *      2)、找到gulimall-coupon服务,给/coupon/spubounds/save发送请求。将上一步转的json放在请求体的位置发送请求
     *      3)、对方服务收到请求请求体有json数据。
     *      (@RequestBody SpuBoundsEntity spuBoundTo)将请求体里的json转为SpuBoundsEntity
     * 只要json数据模型是兼容的。对方服务无需使用同一个to
     * @param spuBoundTo
     * @return
     */
    @PostMapping("/coupon/spubounds/save")
    R saveSpuBounds(@RequestBody SpuBoundTo spuBoundTo);
}

4、第三方服务接口

    /**
     * 保存
     */
    @PostMapping("/save")
    public R save(@RequestBody SpuBoundsEntity spuBounds){
		spuBoundsService.save(spuBounds);

        return R.ok();
    }

//6、保存当前spu对应的所有sku信息
//6.1)、sku的基本信息  pms_sku_info

修改“com.atguigu.gulimall.product.service.SkuInfoServicel”类,代码如下:

 void saveSkuInfo(SkuInfoEntity skuInfoEntity);

修改“com.atguigu.gulimall.product.service.impl.SkuInfoServiceImpl”类,代码如下:

@Override
    public void saveSkuInfo(SkuInfoEntity skuInfoEntity) {
        this.baseMapper.insert(skuInfoEntity);
    }
//6.4)、sku的优惠、满减等信息   gulimall_sms -> sms_sku_ladder/sms_sku_full_reduction/sms_member_price

 在gulimall-common添加服务与服务之间调用的to类“com.atguigu.common.to.MemberPrice”,“com.atguigu.common.to.SkuReductionTo”类,代码如下:

/**
  * Copyright 2019 bejson.com 
  */
package com.atguigu.common.to;

import lombok.Data;

import java.math.BigDecimal;

/**
 * Auto-generated: 2019-11-26 10:50:34
 *
 * @author bejson.com ([email protected])
 * @website http://www.bejson.com/java2pojo/
 */
@Data
public class MemberPrice {

    private Long id;
    private String name;
    private BigDecimal price;

}

package com.atguigu.common.to;

import lombok.Data;

import java.math.BigDecimal;
import java.util.List;

/**
 * @author WangTianShun
 * @date 2020/10/16 9:53
 */
@Data
public class SkuReductionTo {
    private Long skuId;
    private int fullCount;
    private BigDecimal discount;
    private int countStatus;
    private BigDecimal fullPrice;
    private BigDecimal reducePrice;
    private int priceStatus;
    private List memberPrice;
}

 修改“com.atguigu.gulimall.coupon.controller.SkuFullReductionController”类,代码如下:

    /**
     * 保存
     */
    @RequestMapping("/saveInfo")
    public R saveInfo(@RequestBody SkuReductionTo skuReductionTo){
        skuFullReductionService.saveReduction(skuReductionTo);

        return R.ok();
    }

 修改“com.atguigu.gulimall.coupon.service.SkuFullReductionService”类,代码如下:

 void saveReduction(SkuReductionTo skuReductionTo);

 修改“com.atguigu.gulimall.coupon.service.impl.SkuFullReductionServiceImpl”类,代码如下:

@Override
    public void saveReduction(SkuReductionTo reductionTo) {
        //1、sku的优惠、满减等信息   gulimall_sms -> sms_sku_ladder/sms_sku_full_reduction/sms_member_price
        //sms_sku_ladder
        SkuLadderEntity skuLadderEntity = new SkuLadderEntity();
        skuLadderEntity.setSkuId(reductionTo.getSkuId());
        skuLadderEntity.setFullCount(reductionTo.getFullCount());
        skuLadderEntity.setDiscount(reductionTo.getDiscount());
        skuLadderEntity.setAddOther(reductionTo.getCountStatus());
        if(reductionTo.getFullCount() > 0){
            skuLadderService.save(skuLadderEntity);
        }

        //2、ms_sku_full_reduction
        SkuFullReductionEntity reductionEntity = new SkuFullReductionEntity();
        BeanUtils.copyProperties(reductionTo,reductionEntity);
        if (reductionEntity.getFullPrice().compareTo(new BigDecimal("0")) == 1 ){
            this.save(reductionEntity);
        }

5)、spu检索

GET      /product/spuinfo/list

请求参数

{
    page: 1,//当前页码
            limit: 10,//每页记录数
        sidx: 'id',//排序字段
        order: 'asc/desc',//排序方式
        key: '华为',//检索关键字
        catelogId: 6,//三级分类id
        brandId: 1,//品牌id 
        status: 0,//商品状态
}

分页数据

响应数据

{
    "msg": "success",
        "code": 0,
        "page": {
    "totalCount": 0,
            "pageSize": 10,
            "totalPage": 0,
            "currPage": 1,
            "list": [{

        "brandId": 0, //品牌id
                "brandName": "品牌名字",
                "catalogId": 0, //分类id
                "catalogName": "分类名字",
                "createTime": "2019-11-13T16:07:32.877Z", //创建时间
                "id": 0, //商品id
                "publishStatus": 0, //发布状态
                "spuDescription": "string", //商品描述
                "spuName": "string", //商品名字
                "updateTime": "2019-11-13T16:07:32.877Z", //更新时间
                "weight": 0 //重量

    }]
}
}

修改“com.atguigu.gulimall.product.controller.SpuInfoController”类,代码如下:

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map params){
        PageUtils page = spuInfoService.queryPageByCondition(params);

        return R.ok().put("page", page);
    }

修改“com.atguigu.gulimall.product.service.SpuInfoService”类,代码如下:

PageUtils queryPageByCondition(Map params);

修改“com.atguigu.gulimall.product.service.impl.SpuInfoServiceImpl”类,代码如下:

@Override
    public PageUtils queryPageByCondition(Map params) {

        QueryWrapper wrapper = new QueryWrapper<>();

        String key = (String) params.get("key");
        if(!StringUtils.isEmpty(key)){
            wrapper.and((w)->{w.eq("id",key).or().like("spu_name",key);});
        }
        // status=1 and (id=1 or spu_name like xxx)
        String status = (String) params.get("status");
        if(!StringUtils.isEmpty(status)){
            wrapper.eq("publish_status",status);
        }

        String brandId = (String) params.get("brandId");
        if(!StringUtils.isEmpty(brandId)&&!"0".equalsIgnoreCase(brandId)){
            wrapper.eq("brand_id",brandId);
        }

        String catelogId = (String) params.get("catelogId");
        if(!StringUtils.isEmpty(catelogId)&&!"0".equalsIgnoreCase(catelogId)){
            wrapper.eq("catalog_id",catelogId);
        }

        /**
         * status: 2
         * key:
         * brandId: 9
         * catelogId: 225
         */

        IPage page = this.page(
                new Query().getPage(params),
                wrapper
        );

        return new PageUtils(page);
    }

6)、sku检索

GET   /product/skuinfo/list

请求参数

{
        page: 1,//当前页码
        limit: 10,//每页记录数
        sidx: 'id',//排序字段
        order: 'asc/desc',//排序方式
        key: '华为',//检索关键字
        catelogId: 0,
        brandId: 0,
        min: 0,
        max: 0
}

分页数据

响应数据

{
        "msg": "success",
        "code": 0,
        "page": {
        "totalCount": 26,
        "pageSize": 10,
        "totalPage": 3,
        "currPage": 1,
        "list": [{
        "skuId": 1,
        "spuId": 11,
        "skuName": "华为 HUAWEI Mate 30 Pro 星河银 8GB+256GB",
        "skuDesc": null,
        "catalogId": 225,
        "brandId": 9,
        "skuDefaultImg": "https://gulimall-hello.oss-cn-beijing.aliyuncs.com/2019-11-26/60e65a44-f943-4ed5-87c8-8cf90f403018_d511faab82abb34b.jpg",
        "skuTitle": "华为 HUAWEI Mate 30 Pro 星河银 8GB+256GB麒麟990旗舰芯片OLED环幕屏双4000万徕卡电影四摄4G全网通手机",
        "skuSubtitle": "【现货抢购!享白条12期免息!】麒麟990,OLED环幕屏双4000万徕卡电影四摄;Mate30系列享12期免息》",
        "price": 6299.0000,
        "saleCount": 0
        }]
        }
}

修改“com.atguigu.gulimall.product.controller.SkuInfoController”类,代码如下:

 @RequestMapping("/list")
    public R list(@RequestParam Map params){
        PageUtils page = skuInfoService.queryPageByCondition(params);

        return R.ok().put("page", page);
    }

修改“com.atguigu.gulimall.product.service.SkuInfoService”类,代码如下:

PageUtils queryPageByCondition(Map params);

修改“com.atguigu.gulimall.product.service.impl.SkuInfoServiceImpl”类,代码如下:

@Override
    public PageUtils queryPageByCondition(Map params) {
        QueryWrapper queryWrapper = new QueryWrapper<>();
        
        String key = (String) params.get("key");
        if (!StringUtils.isEmpty(key)){
            queryWrapper.and((w)->{
                w.eq("sku_id",key).or().like("sku_name",key);
            });
        }

        String catelogId = (String) params.get("catelogId");
        if (!StringUtils.isEmpty(catelogId) && !"0".equalsIgnoreCase(catelogId)){
            queryWrapper.eq("catalog_id",catelogId);
        }

        String brandId = (String) params.get("brandId");
        if (!StringUtils.isEmpty(brandId) && !"0".equalsIgnoreCase(brandId)){
            queryWrapper.eq("brand_id",brandId);
        }

        String min = (String) params.get("min");
        if (!StringUtils.isEmpty(min)){
            queryWrapper.ge("price",min);
        }

        String max = (String) params.get("max");
        if (!StringUtils.isEmpty(max)){
            try{
                BigDecimal bigDecimal = new BigDecimal(max);
                if (bigDecimal.compareTo(new BigDecimal("0"))==1){
                    queryWrapper.le("price",max);
                }
            }catch (Exception e){

            }
        }

        IPage page = this.page(
                new Query().getPage(params),
                queryWrapper
        );
        return new PageUtils(page);
    }


 3、库存系统


 3.1、仓库维护

1)、仓库列表

GET   /ware/wareinfo/list

请求参数

{
    page: 1,//当前页码
            limit: 10,//每页记录数
        sidx: 'id',//排序字段
        order: 'asc/desc',//排序方式
        key: '华为'//检索关键字

分页数据

响应数据

{
    "msg": "success",
        "code": 0,
        "page": {
            "totalCount": 0,
            "pageSize": 10,
            "totalPage": 0,
            "currPage": 1,
            "list": [{
                "id": 2,
                "name": "aa",
                "address": "bbb",
                "areacode": "124"
                    }]
                 }
}

修改“com.atguigu.gulimall.ware.controller.WareSkuController”类,代码如下:

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map params){
        PageUtils page = wareSkuService.queryPage(params);

        return R.ok().put("page", page);
    }

修改“com.atguigu.gulimall.ware.service.WareInfoService”类,代码如下:

PageUtils queryPage(Map params);

修改“com.atguigu.gulimall.ware.service.impl.WareInfoServiceImpl”类,代码如下:

@Override
    public PageUtils queryPage(Map params) {
        QueryWrapper queryWrapper = new QueryWrapper<>();
        String key = (String) params.get("key");
        if (!StringUtils.isEmpty(key)){
            queryWrapper.eq("id",key)
                    .or().like("name",key)
                    .or().like("address",key)
                    .or().like("areacode",key);
        }

        IPage page = this.page(
                new Query().getPage(params),
                queryWrapper
        );

        return new PageUtils(page);
    }

 3.3、商品库存

1)、查询商品库存

GET   /ware/waresku/list

请求参数

{
  page: 1,//当前页码
  limit: 10,//每页记录数
  sidx: 'id',//排序字段
  order: 'asc/desc',//排序方式
  wareId: 123,//仓库id
  skuId: 123//商品id

分页数据

响应数据

{
  "msg": "success",
  "code": 0,
  "page": {
    "totalCount": 0,
    "pageSize": 10,
    "totalPage": 0,
    "currPage": 1,
    "list": [{
               "id": 1,
               "skuId": 1,
               "wareId": 1,
               "stock": 1,
               "skuName": "dd",
               "stockLocked": 1
             }]
  }
}  

 修改“com.atguigu.gulimall.ware.controller.WareSkuController”类,代码如下:

@RequestMapping("/list")
    public R list(@RequestParam Map params){
        PageUtils page = wareSkuService.queryPage(params);

        return R.ok().put("page", page);
    }

 修改“com.atguigu.gulimall.ware.service.impl.WareSkuServiceImpl”类,代码如下:

PageUtils queryPage(Map params);

修改“com.atguigu.gulimall.ware.service.impl.WareSkuServiceImpl”类,代码如下:

@Override
    public PageUtils queryPage(Map params) {
        QueryWrapper queryWapper = new QueryWrapper<>();
        String  skuId = (String) params.get("skuId");
        if (!StringUtils.isEmpty(skuId)){
            queryWapper.eq("sku_id",skuId);
        }

        String  wareId = (String) params.get("wareId");
        if (!StringUtils.isEmpty(wareId)){
            queryWapper.eq("ware_id",wareId);
        }
        IPage page = this.page(
                new Query().getPage(params),
                queryWapper
        );

        return new PageUtils(page);
    }

3.4、采购单维护

3.4.1、采购单需求 

1)、查询采购需求

GET     /ware/purchasedetail/list

请求参数

{
    page: 1,//当前页码
            limit: 10,//每页记录数
        sidx: 'id',//排序字段
        order: 'asc/desc',//排序方式
        key: '华为',//检索关键字
        status: 0,//状态    
        wareId: 1,//仓库id

分页数据

响应数据

{
    "msg": "success",
    "code": 0,
    "page": {
        "totalCount": 0,
        "pageSize": 10,
        "totalPage": 0,
        "currPage": 1,
        "list": [{
            "id": 2,
            "purchaseId": 1,
            "skuId": 1,
            "skuNum": 2,
            "skuPrice": 22.0000,
            "wareId": 1,
            "status": 1
        }]
    }
}

修改“com.atguigu.gulimall.ware.controller.PurchaseDetailController”类,代码如下:

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map params){
        PageUtils page = purchaseDetailService.queryPage(params);

        return R.ok().put("page", page);
    }

修改“com.atguigu.gulimall.ware.service.impl.PurchaseDetailServiceImpl”类,代码如下:

@Override
    public PageUtils queryPage(Map params) {
        /**
         * status: 0,//状态
         *    wareId: 1,//仓库id
         */

        QueryWrapper queryWrapper = new QueryWrapper();

        String key = (String) params.get("key");
        if(!StringUtils.isEmpty(key)){
            //purchase_id  sku_id
            queryWrapper.and(w->{
                w.eq("purchase_id",key).or().eq("sku_id",key);
            });
        }

        String status = (String) params.get("status");
        if(!StringUtils.isEmpty(status)){
            //purchase_id  sku_id
            queryWrapper.eq("status",status);
        }

        String wareId = (String) params.get("wareId");
        if(!StringUtils.isEmpty(wareId)){
            //purchase_id  sku_id
            queryWrapper.eq("ware_id",wareId);
        }

        IPage page = this.page(
                new Query().getPage(params),
                queryWrapper
        );

        return new PageUtils(page);
    }

2)、查询未领取的采购单

GET   /ware/purchase/unreceive/list

请求参数

 响应数据

 {
    "msg": "success",
    "code": 0,
    "page": {
        "totalCount": 0,
        "pageSize": 10,
        "totalPage": 0,
        "currPage": 1,
        "list": [{
            "id": 1,
            "assigneeId": 1,
            "assigneeName": "aa",
            "phone": "123",
            "priority": 1,
            "status": 1,
            "wareId": 1,
            "amount": 22.0000,
            "createTime": "2019-12-12",
            "updateTime": "2019-12-12"
        }]
    }
}

 修改“com.atguigu.gulimall.ware.controller.PurchaseController”类,代码如下:

//  /ware/purchase/unreceive/list
    @RequestMapping("/unreceive/list")
    public R unreceiveList(@RequestParam Map params){
        PageUtils page = purchaseService.queryPageUnreceive(params);

        return R.ok().put("page", page);
    }

 修改“com.atguigu.gulimall.ware.service.PurchaseService”类,代码如下:

PageUtils queryPageUnreceive(Map params);

 修改“com.atguigu.gulimall.ware.service.impl.PurchaseServiceImpl”类,代码如下:

    @Override
    public PageUtils queryPageUnreceive(Map params) {
        QueryWrapper queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("status",0).or().eq("status",1);
        IPage page = this.page(
                new Query().getPage(params),
                queryWrapper
        );

        return new PageUtils(page);
    }

3)、合并采购需求

POST  /ware/purchase/merge

请求参数

{
    purchaseId: 1, //整单id
    items:[1,2,3,4] //合并项集合
}

分页数据

响应数据

{
    "msg": "success",
    "code": 0

 修改“com.atguigu.gulimall.ware.controller.PurchaseController”类,代码如下:

    @PostMapping("/merge")
    public R merge(@RequestBody MergeVo mergeVo){
        purchaseService.mergePurchase(mergeVo);
        return R.ok();
    }

修改“com.atguigu.gulimall.ware.service.PurchaseService”类,代码如下:

void mergePurchase(MergeVo mergeVo);

 修改“com.atguigu.gulimall.ware.service.impl.PurchaseServiceImpl”类,代码如下:

@Transactional
    @Override
    public void mergePurchase(MergeVo mergeVo) {
        Long purchaseId = mergeVo.getPurchaseId();
        if(purchaseId == null){
            //1、新建一个
            PurchaseEntity purchaseEntity = new PurchaseEntity();
            purchaseEntity.setStatus(WareConstant.PurchaseStatusEnum.CREATED.getCode());
            purchaseEntity.setCreateTime(new Date());
            purchaseEntity.setUpdateTime(new Date());
            this.save(purchaseEntity);
            purchaseId = purchaseEntity.getId();
        }

        //TODO 确认采购单状态是0,1才可以合并
        List items = mergeVo.getItems();
        Long finalPurchaseId = purchaseId;
        if (!CollectionUtils.isEmpty(items)){

        }
        List collect = items.stream().map(i -> {
            PurchaseDetailEntity detailEntity = new PurchaseDetailEntity();
            detailEntity.setId(i);
            detailEntity.setPurchaseId(finalPurchaseId);
            detailEntity.setStatus(WareConstant.PurchaseDetailStatusEnum.ASSIGNED.getCode());
            return detailEntity;
        }).collect(Collectors.toList());
        purchaseDetailService.updateBatchById(collect);
        
        PurchaseEntity purchaseEntity = new PurchaseEntity();
        purchaseEntity.setId(purchaseId);
        purchaseEntity.setUpdateTime(new Date());
        this.updateById(purchaseEntity);
    }

4)、领取采购单

POST   /ware/purchase/received

请求参数

[1,2,3,4]//采购单id

分页数据

响应数据

{
    "msg": "success", 
    "code": 0

  修改“com.atguigu.gulimall.ware.controller.PurchaseController”类,代码如下:

    /**
     * 领取采购单
     * @param ids
     * @return
     */
    @PostMapping("/received")
    public R received(@RequestBody List ids){
        purchaseService.received(ids);
        return R.ok();
    }

修改“com.atguigu.gulimall.ware.service.PurchaseService”类,代码如下:

void received(List ids);

修改“com.atguigu.gulimall.ware.service.impl.PurchaseServiceImpl”类,代码如下:

/**
     * @param ids 采购单id
     */
    @Override
    public void received(List ids) {
        //1、确认当前采购单是新建或者已分配状态
        List collect = ids.stream().map(id -> {
            PurchaseEntity purchaseEntity = this.getById(id);
            return purchaseEntity;
        }).filter(item -> {
            if (item.getStatus() == WareConstant.PurchaseStatusEnum.CREATED.getCode() ||
                    item.getStatus() == WareConstant.PurchaseStatusEnum.ASSIIGNED.getCode()) {
                return true;
            }
            return false;
        }).map(item -> {
            item.setStatus(WareConstant.PurchaseStatusEnum.RECEIVE.getCode());
            item.setUpdateTime(new Date());
            return item;
        }).collect(Collectors.toList());
        //2、改变采购单的状态
        this.updateBatchById(collect);

        //3、改变采购单采购项的状态
        collect.forEach((item)->{
            List detailEntities = purchaseDetailService.listDetailByPurchaseId(item.getId());
            List entities = detailEntities.stream().map(entity -> {
                PurchaseDetailEntity detailEntity = new PurchaseDetailEntity();
                detailEntity.setId(entity.getId());
                detailEntity.setStatus(WareConstant.PurchaseDetailStatusEnum.BUYING.getCode());
                return detailEntity;
            }).collect(Collectors.toList());
            purchaseDetailService.updateBatchById(entities);
        });
    }

3.4.2、采购单 

1)、完成采购

POST    /ware/purchase/done

请求参数

{
    id: 123,//采购单id
    items: [{itemId:1,status:4,reason:""}]//完成/失败的需求详情

响应数据

{
    "msg": "success",
    "code": 0
}  

修改“com.atguigu.gulimall.ware.controller.PurchaseController”类,代码如下:

    @PostMapping("/done")
    public R finish(@RequestBody PurchaseDoneVo doneVo){
        purchaseService.done(doneVo);
        return R.ok();
    }

修改“com.atguigu.gulimall.ware.controller.PurchaseController”类,代码如下:

 void done(PurchaseDoneVo doneVo);

修改“com.atguigu.gulimall.ware.service.impl.PurchaseServiceImpl”类,代码如下:

@Transactional
    @Override
    public void done(PurchaseDoneVo doneVo) {

        Long id = doneVo.getId();
        //2、改变采购项的状态
        Boolean flag = true;
        List items = doneVo.getItems();
        List updates = new ArrayList<>();
        for (PurchaseItemDoneVo item : items) {
            PurchaseDetailEntity detailEntity = new PurchaseDetailEntity();
            if (item.getStatus() == WareConstant.PurchaseDetailStatusEnum.HASERROR.getCode()){
                flag = false;
                detailEntity.setStatus(item.getStatus());
            }else {
                detailEntity.setStatus(WareConstant.PurchaseDetailStatusEnum.FINISH.getCode());
                //3、将成功采购的进行入库
                PurchaseDetailEntity entity = purchaseDetailService.getById(item.getItemId());
                wareSkuService.addStock(entity.getSkuId(),entity.getWareId(),entity.getSkuNum());
            }
            detailEntity.setId(item.getItemId());
            updates.add(detailEntity);
        }
        purchaseDetailService.updateBatchById(updates);

        //1、改变采购单状态
        PurchaseEntity purchaseEntity = new PurchaseEntity();
        purchaseEntity.setId(id);
        purchaseEntity.setStatus(flag?WareConstant.PurchaseStatusEnum.FINISH.getCode():WareConstant.PurchaseStatusEnum.HASERROR.getCode());
        purchaseEntity.setUpdateTime(new Date());
        this.updateById(purchaseEntity);

    }

//3、将成功采购的进行入库 

修改“com.atguigu.gulimall.ware.service.WareSkuService”类,代码如下:

void addStock(Long skuId, Long wareId, Integer skuNum);

 修改“com.atguigu.gulimall.ware.service.impl.WareSkuServiceImpl”类,代码如下:

 @Override
    public void addStock(Long skuId, Long wareId, Integer skuNum) {
        //1、判断如果还没有库存记录新增
        List entities = wareSkuDao.selectList(new QueryWrapper().eq("sku_id", skuId).eq("ware_id", wareId));
        if (entities == null || entities.size() ==0 ){
            WareSkuEntity wareSkuEntity = new WareSkuEntity();
            wareSkuEntity.setId(skuId);
            wareSkuEntity.setStock(skuNum);
            wareSkuEntity.setWareId(wareId);
            wareSkuEntity.setStockLocked(0);
            //TODO 远程查询sku的名字  如果失败,整个事务不需要回滚

            // 1、自己catch异常
            //2、TODO 还可以用什么办法让异常出现以后不回滚?高级
            try{
                R info = productFeignService.info(skuId);
                if (info.getCode() == 0){
                    Map data = (Map) info.get("skuInfo");
                    wareSkuEntity.setSkuName((String) data.get("skuName"));
                }
            }catch (Exception e){

            }
            wareSkuDao.insert(wareSkuEntity);
        }else {
            wareSkuDao.addStock(skuId, wareId, skuNum);
        }

    }

//TODO 远程查询sku的名字  如果失败,整个事务不需要回滚 

修改“com.atguigu.gulimall.ware.feign.ProductFeignService”类,代码如下:

package com.atguigu.gulimall.ware.feign;

import com.atguigu.common.utils.R;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @author WangTianShun
 * @date 2020/10/17 14:20
 */
@FeignClient("gulimall-product")
public interface ProductFeignService {

    /**
     *     1)、让所有请求过网关
     *     1、@FeignClient("gulimall-gateway"),给gulimall-gateway所在的机器发送请求
     *     2、/api/product/skuinfo/info/{skuId}
     *     2)、直接让后台指定服务处理
     *          1、@FeignClient("gulimall-product")
     *          2、/product/skuinfo/info/{skuId}
     * @param skuId
     * @return
     */
    @RequestMapping("/product/skuinfo/info/{skuId}")
    public R info(@PathVariable("skuId") Long skuId);
}

谷粒商城-个人笔记(基础篇二)_第1张图片

修改“com.atguigu.gulimall.ware.dao.WareSkuDao”类,代码如下:

void addStock(@Param("skuId") Long skuId, @Param("wareId") Long wareId, @Param("skuNum") Integer skuNum);

修改“com.atguigu.gulimall.ware.dao.WareSkuDao”类,代码如下:


         update wms_ware_sku set stock = stock + #{skuNum} where sku_id = #{skuId} and ware_id = #{wareId}

未完,请看下一篇

谷粒商城-个人笔记(高级篇一):https://blog.csdn.net/wts563540/article/details/109254851


 

 

你可能感兴趣的:(实战项目专题,1024程序员节)