@Transactional
@Override
public void saveSpuInfo(SpuSaveVo vo) {
//1.保存spu基本信息 pms_spu_info
//2.保存spu的描述图片 pms_spu_info_desc
//3.保存spu的图片集 pms_spu_images
//4.保存spu的规格参数 pms_product_attr_value
//5.保存spu的积分信息 gmall_sms >> sms_spu_bounds
//6.保存当前spu对应的所有sku信息
//6.1保存sku的基本信息 pms_sku_info
//6.2保存sku的图片信息 pms_sku_images
//6.3保存sku的销售属性信息 pms_sku_sale_attr_value
//6.4保存sku的优惠、满减等信息 gmall_sms
//sku的打折信息 gmall_sms >> sms_sku_ladder
//sku的满减信息 gmall_sms >> sms_sku_full_reduction
//会员价格信息 gmall_sms >> sms_member_price
//1.保存spu基本信息 pms_spu_info
SpuInfoEntity spuInfoEntity = new SpuInfoEntity();
BeanUtils.copyProperties(vo,spuInfoEntity);
spuInfoEntity.setCreateTime(new Date());
spuInfoEntity.setUpdateTime(new Date());
this.saveBaseSpuInfo(spuInfoEntity);
//2.保存spu的描述图片 pms_spu_info_desc
List<String> decript = vo.getDecript();
SpuInfoDescEntity spuInfoDescEntity = new SpuInfoDescEntity();
spuInfoDescEntity.setSpuId(spuInfoEntity.getId());
spuInfoDescEntity.setDecript(String.join(",",decript));//把字符串数组拼成一个长串,用,隔开
spuInfoDescService.saveSpuInfoDesc(spuInfoDescEntity);
//3.保存spu的图片集 pms_spu_images
List<String> images = vo.getImages();
spuImagesService.saveImages(spuInfoEntity.getId(),images);
//4.保存spu的规格参数 pms_product_attr_value
List<BaseAttrs> baseAttrs = vo.getBaseAttrs();
List<ProductAttrValueEntity> collect = baseAttrs.stream().map((item) -> {
ProductAttrValueEntity productAttrValueEntity = new ProductAttrValueEntity();
productAttrValueEntity.setAttrId(item.getAttrId());
AttrEntity attrEntity = attrService.getById(item.getAttrId());
productAttrValueEntity.setAttrName(attrEntity.getAttrName());
productAttrValueEntity.setAttrValue(item.getAttrValues());
productAttrValueEntity.setQuickShow(item.getShowDesc());
productAttrValueEntity.setSpuId(spuInfoEntity.getId());
return productAttrValueEntity;
}).collect(Collectors.toList());
productAttrValueService.saveProductAttr(collect);
}
@Override
public void saveBaseSpuInfo(SpuInfoEntity spuInfoEntity) {
this.baseMapper.insert(spuInfoEntity);
}
谷粒商城P88【商品系统】-> 【商品维护】->【发布商品】~ 保存spu基本信息
最新推荐文章于 2024-09-04 15:29:36 发布