提交 a3d5f7a8 作者: xiaowang

后台:商品管理

上级 1f2b28f2
package com.mmc.pms.controller;
import com.mmc.pms.common.ResultBody;
import com.mmc.pms.model.dto.MallGoodsDetailDTO;
import com.mmc.pms.model.dto.SkuUnitDTO;
import com.mmc.pms.model.vo.Create;
import com.mmc.pms.model.vo.GoodsAddVO;
import com.mmc.pms.model.vo.Update;
import com.mmc.pms.service.GoodsInfoService;
import io.swagger.annotations.*;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
......@@ -39,4 +38,18 @@ public class BackstageGoodsManageController {
public ResultBody editGoodsInfo(@ApiParam("商品信息VO") @Validated(Update.class) @RequestBody GoodsAddVO goodsAddVO) {
return goodsInfoService.editGoodsInfo(goodsAddVO);
}
@ApiOperation(value = "PC端-商品详情")
@GetMapping("getGoodsInfoDetail")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = MallGoodsDetailDTO.class)})
public ResultBody getGoodsInfoDetail(@ApiParam("商品id") @RequestParam Integer goodsInfoId) {
return goodsInfoService.getGoodsInfoDetail(goodsInfoId);
}
@ApiOperation(value = "单位信息")
@GetMapping("getSkuUnit")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = SkuUnitDTO.class)})
public ResultBody getSkuUnit() {
return goodsInfoService.getSkuUnit();
}
}
......@@ -4,6 +4,7 @@ import com.mmc.pms.common.ResultBody;
import com.mmc.pms.model.dto.*;
import com.mmc.pms.model.qo.ProductSkuQO;
import com.mmc.pms.model.vo.Create;
import com.mmc.pms.model.vo.PriceAcquisition;
import com.mmc.pms.model.vo.ProductSpecCPQVO;
import com.mmc.pms.model.vo.Update;
import com.mmc.pms.service.ProductSkuService;
......@@ -11,6 +12,9 @@ import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import java.math.BigDecimal;
/**
* @Author LW
......@@ -127,4 +131,12 @@ public class BackstageProductSpecController {
// @RequestParam(value = "tagId")Integer tagId) {
// return productSpecService.feignGetUnitPriceByTag(specId,tagId);
// }
@ApiOperation(value = "feign根据渠道等级获取单价信息")
@GetMapping("feignGetSpecLeaseUnitPrice")
@ApiIgnore
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)})
public BigDecimal feignGetUnitPriceByTag(@RequestBody PriceAcquisition priceAcquisition) {
return productSkuService.feignGetUnitPriceByTag(priceAcquisition);
}
}
......@@ -54,6 +54,15 @@ public interface GoodsInfoDao {
void batchUpdateMallProdSkuInfo(List<MallProdInfoDO> mallProdSkuInfoList);
List<MallIndustrySkuInfoDO> getMallIndustrySkuInfo(Integer id);
GoodsInfo getGoodsSimpleInfo(Integer goodsInfoId);
GoodsDetailDO getGoodsDetailByGoodsId(Integer goodsInfoId);
List<GoodsServiceDO> listGoodsServiceByGoodsId(Integer goodsInfoId);
List<SkuUnitDO> getSkuUnit();
}
......
......@@ -93,4 +93,6 @@ public interface IndustrySpecDao {
void removeInventorySpec(List<Integer> ids);
void removeIndustrySpec(Integer id);
List<MallIndustrySkuInfoSpecDO> getIndustrySkuInfoSpec(Integer goodsInfoId);
}
......@@ -4,10 +4,12 @@ import com.mmc.pms.entity.*;
import com.mmc.pms.model.dto.ProductSkuVO;
import com.mmc.pms.model.dto.ProductSpecVO;
import com.mmc.pms.model.qo.ProductSkuQO;
import com.mmc.pms.model.vo.PriceAcquisition;
import com.mmc.pms.model.vo.ProductSpecCPQVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.math.BigDecimal;
import java.util.List;
import java.util.Set;
......@@ -82,6 +84,9 @@ public interface ProductDao {
List<IndustrySpecDO> listIndustrySpec(@Param("industrySpecIds") Set<Integer> industrySpecIds);
List<InventorySpecDO> listInventorySpec(Integer id);
BigDecimal feignGetUnitPriceByTag(PriceAcquisition priceAcquisition);
}
......
......@@ -48,6 +48,10 @@ public class GoodsInfo implements Serializable {
private Integer deleted;
private Integer goodsVideoId;
private String videoUrl;
private static final long serialVersionUID = 1L;
public GoodsInfo(GoodsAddVO goodsAddVO) {
......
......@@ -58,7 +58,7 @@ public class MallProdInfoDO implements Serializable {
return GoodsSpecDTO.builder()
.id(this.id)
.goodsSpecName(this.prodSkuSpecName)
.goodsTypeId(this.categoriesId)
.categoryId(this.categoriesId)
.chooseType(this.chooseType)
.skuUnitId(skuUnitId)
.unitName(this.unitName)
......
package com.mmc.pms.entity;
import com.mmc.pms.model.dto.SkuUnitDTO;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.Date;
/**
* @Author LW
* @date 2022/10/27 16:00
* 概要:
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class SkuUnitDO implements Serializable {
private static final long serialVersionUID = 4353340603217315101L;
private Integer id;
private String unitName;
private Integer deleted;
private Date createTime;
private Date updateTime;
public SkuUnitDTO buildSkuUnitDTO() {
return SkuUnitDTO.builder().id(this.id).unitName(this.unitName).createTime(this.createTime).build();
}
}
......@@ -19,47 +19,47 @@ import java.util.List;
@Builder
@Accessors(chain = true)
public class GoodsSpecDTO implements Serializable {
private static final long serialVersionUID = -8681372139970849591L;
private static final long serialVersionUID = -8681372139970849591L;
@ApiModelProperty(value = "id")
private Integer id;
@ApiModelProperty(value = "id")
private Integer id;
@ApiModelProperty(value = "规格名称")
private String goodsSpecName;
@ApiModelProperty(value = "规格名称")
private String goodsSpecName;
@ApiModelProperty(value = "产品或行业类型")
private Integer goodsTypeId;
@ApiModelProperty(value = "产品或行业类型")
private Integer categoryId;
@ApiModelProperty(value = "产品或行业类型名称")
private String typeName;
@ApiModelProperty(value = "产品或行业类型名称")
private String typeName;
@ApiModelProperty(value = "产品或行业skuId")
private Integer skuId;
@ApiModelProperty(value = "产品或行业skuId")
private Integer skuId;
@ApiModelProperty(value = "品牌id")
private Integer brandInfoId;
@ApiModelProperty(value = "品牌id")
private Integer brandInfoId;
@ApiModelProperty(value = "产品或行业sku名称")
private String skuName;
@ApiModelProperty(value = "产品或行业sku名称")
private String skuName;
@ApiModelProperty(value = "产品规格信息")
private List<MallProductSpecDTO> productSpecList;
@ApiModelProperty(value = "产品规格信息")
private List<MallProductSpecDTO> productSpecList;
@ApiModelProperty(value = "行业规格信息")
private List<MallIndustrySpecDTO> industrySpecList;
@ApiModelProperty(value = "行业规格信息")
private List<MallIndustrySpecDTO> industrySpecList;
@ApiModelProperty(value = "选择方式")
private Integer chooseType;
@ApiModelProperty(value = "选择方式")
private Integer chooseType;
@ApiModelProperty(value = "规格单位")
private Integer skuUnitId;
@ApiModelProperty(value = "规格单位")
private Integer skuUnitId;
@ApiModelProperty(value = "单位名称")
private String unitName;
@ApiModelProperty(value = "单位名称")
private String unitName;
@ApiModelProperty(value = "是否必选")
private Integer must;
@ApiModelProperty(value = "是否必选")
private Integer must;
@ApiModelProperty(value = "规格来源 0获取 1自定义")
private Integer flag;
@ApiModelProperty(value = "规格来源 0获取 1自定义")
private Integer flag;
}
package com.mmc.pms.model.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.List;
/**
* @Author LW
* @date 2022/10/14 11:30
* 概要:
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public class MallGoodsDetailDTO implements Serializable {
private static final long serialVersionUID = 7041502536618388167L;
@ApiModelProperty(value = "id")
private Integer id;
@ApiModelProperty(value = "商品图片")
private List<GoodsImgDTO> images;
@ApiModelProperty(value = "商品视频")
private String goodsVideo;
@ApiModelProperty(value = "商品视频id")
private Integer goodsVideoId;
@ApiModelProperty(value = "商品名称")
private String goodsName;
@ApiModelProperty(value = "商品详情")
private GoodsDetailInfoDTO goodsDetail;
@ApiModelProperty(value = "所属目录")
private Integer directoryId;
@ApiModelProperty(value = "一级分类id")
private Integer categoryByOne;
@ApiModelProperty(value = "二级分类id")
private Integer categoryByTwo;
@ApiModelProperty(value = "商品标签")
private String tag;
@ApiModelProperty(value = "商品状态 0:下架 1:上架")
private Integer shelfStatus;
@ApiModelProperty(value = "规格信息")
private List<GoodsSpecDTO> goodsSpec;
@ApiModelProperty(value = "其他服务: 1:免费配送,2:专业飞手培训2日, 3:半年保修, 4:一年保修 ")
private List<GoodsOtherServiceDTO> otherService;
}
package com.mmc.pms.model.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* sku单位dto
*
* @author 23214
* @date 2022/10/27
*/
@Data
@AllArgsConstructor
@Builder
public class SkuUnitDTO implements Serializable {
private static final long serialVersionUID = -141631308183969739L;
@ApiModelProperty(value = "id")
private Integer id;
@ApiModelProperty(value = "单位名称")
private String unitName;
@ApiModelProperty(value = "创建时间")
private Date createTime;
}
package com.mmc.pms.model.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author 23214
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class PriceAcquisition {
@ApiModelProperty(value = "用户id")
private Integer userId;
@ApiModelProperty(value = "规格id")
private Integer specsId;
@ApiModelProperty(value = "天数")
private Integer day;
@ApiModelProperty(value = "渠道等级id")
private Integer channelLevelId;
}
\ No newline at end of file
......@@ -13,4 +13,9 @@ public interface GoodsInfoService {
ResultBody addGoods(GoodsAddVO goodsAddVO);
ResultBody editGoodsInfo(GoodsAddVO goodsAddVO);
ResultBody getGoodsInfoDetail(Integer goodsInfoId);
ResultBody getSkuUnit();
}
......@@ -6,7 +6,7 @@ import com.mmc.pms.dao.GoodsInfoDao;
import com.mmc.pms.dao.IndustrySpecDao;
import com.mmc.pms.dao.ProductDao;
import com.mmc.pms.entity.*;
import com.mmc.pms.model.dto.ProductSpecVO;
import com.mmc.pms.model.dto.*;
import com.mmc.pms.model.vo.*;
import com.mmc.pms.service.GoodsInfoService;
import com.mmc.pms.util.CodeUtil;
......@@ -368,6 +368,107 @@ public class GoodsInfoServiceImpl implements GoodsInfoService {
// 商品详情修改
goodsInfoDao.updateGoodsDetail(goodsDetailDO);
}
@Override
public ResultBody getGoodsInfoDetail(Integer goodsInfoId) {
// 判断此商品是否还存在
int count = goodsInfoDao.countGoodsInfoById(goodsInfoId);
if (count <= 0) {
return ResultBody.error(ResultEnum.GOODS_NOT_EXIST_OR_ALREADY_DOWN_SHELF);
}
// 初始化商品返回信息的对象
MallGoodsDetailDTO mallGoodsDetail = new MallGoodsDetailDTO();
// 获取商品基本信息
GoodsInfo goodsInfo = goodsInfoDao.getGoodsSimpleInfo(goodsInfoId);
mallGoodsDetail.setId(goodsInfo.getId()).setGoodsName(goodsInfo.getGoodsName())
.setCategoryByOne(goodsInfo.getCategoryByOne()).setGoodsVideo(goodsInfo.getVideoUrl())
.setDirectoryId(goodsInfo.getDirectoryId()).setCategoryByTwo(goodsInfo.getCategoryByTwo())
.setTag(goodsInfo.getEcoLabel()).setShelfStatus(goodsInfo.getShelfStatus())
.setGoodsVideoId(goodsInfo.getGoodsVideoId());
// 获取商品图片信息
mallGoodsDetail.setImages(getGoodsImageInfo(goodsInfoId));
// 获取商品详细信息
mallGoodsDetail.setGoodsDetail(getGoodsDetail(goodsInfoId));
// 获取其他服务信息
mallGoodsDetail.setOtherService(getOtherServiceInfo(goodsInfoId));
// 获取规格信息
if (!goodsInfo.getDirectoryId().equals(2)) {
// 获取产品规格信息
mallGoodsDetail.setGoodsSpec(getProductSpecInfo(goodsInfoId));
} else {
// 获取行业规格信息
mallGoodsDetail.setGoodsSpec(getIndustrySpecInfo(goodsInfoId));
}
return ResultBody.success(mallGoodsDetail);
}
private List<GoodsSpecDTO> getIndustrySpecInfo(Integer goodsInfoId) {
// 获取商品对应绑定的行业sku信息
List<MallIndustrySkuInfoDO> mallIndustrySkuInfoList = goodsInfoDao.getMallIndustrySkuInfo(goodsInfoId);
List<GoodsSpecDTO> list = mallIndustrySkuInfoList.stream().map(MallIndustrySkuInfoDO::buildGoodsSpecDTO).collect(Collectors.toList());
// 根据商品id查出该商品下绑定的规格信息
List<MallIndustrySkuInfoSpecDO> mallIndustrySkuInfoSpec = industrySpecDao.getIndustrySkuInfoSpec(goodsInfoId);
list = list.stream().peek(d -> {
List<MallIndustrySpecDTO> industrySpec = new ArrayList<>();
for (MallIndustrySkuInfoSpecDO e : mallIndustrySkuInfoSpec) {
if (d.getId().equals(e.getMallIndustrySkuInfoId())) {
IndustrySpecDO industrySpecDO = e.getIndustrySpecDO();
MallIndustrySpecDTO industrySpecDTO = industrySpecDO.buildMallIndustrySpecDTO();
industrySpecDTO.setId(e.getId());
industrySpecDTO.setIndustrySpecId(e.getIndustrySpecId());
industrySpecDTO.setIndustrySkuId(d.getSkuId());
industrySpec.add(industrySpecDTO);
}
}
d.setIndustrySpecList(industrySpec);
}).collect(Collectors.toList());
return list;
}
private List<GoodsSpecDTO> getProductSpecInfo(Integer goodsInfoId) {
// 获取商品对应绑定sku的信息
List<MallProdInfoDO> mallProSkuInfo = goodsInfoDao.getMallProSkuInfo(goodsInfoId);
// 获取该产品下的规格id
Map<Integer, String> specIdsMap = mallProSkuInfo.stream().collect(Collectors.toMap(MallProdInfoDO::getId, MallProdInfoDO::getProductSpecIdList));
List<GoodsSpecDTO> list = mallProSkuInfo.stream().map(MallProdInfoDO::buildGoodsSpecDTO).collect(Collectors.toList());
for (GoodsSpecDTO goodsSpecDTO : list) {
String specIds = specIdsMap.get(goodsSpecDTO.getId());
String[] ids = specIds.split(",");
List<Integer> idList = new ArrayList<>();
for (String id : ids) {
idList.add(Integer.parseInt(id));
}
// 根据specIds集合找出spec的信息
List<ProductSpecDO> productSpecDOS = productDao.listProductSpecInfo(idList);
List<MallProductSpecDTO> mallProductSpecList = productSpecDOS.stream().map(ProductSpecDO::buildMallProductSpecDTO).collect(Collectors.toList());
goodsSpecDTO.setProductSpecList(mallProductSpecList);
}
return list;
}
private List<GoodsOtherServiceDTO> getOtherServiceInfo(Integer goodsInfoId) {
List<GoodsServiceDO> goodsServiceDO = goodsInfoDao.listGoodsServiceByGoodsId(goodsInfoId);
return goodsServiceDO.stream().map(GoodsServiceDO::buildGoodsOtherServiceDTO).collect(Collectors.toList());
}
private GoodsDetailInfoDTO getGoodsDetail(Integer goodsInfoId) {
GoodsDetailDO goodsDetail = goodsInfoDao.getGoodsDetailByGoodsId(goodsInfoId);
return goodsDetail.buildGoodsDetailInfoDTO();
}
private List<GoodsImgDTO> getGoodsImageInfo(Integer goodsInfoId) {
List<GoodsImgDO> goodsImgList = goodsInfoDao.listGoodsInfoByGoodsId(goodsInfoId);
return goodsImgList.stream().map(GoodsImgDO::buildGoodsImgDTO).collect(Collectors.toList());
}
@Override
public ResultBody getSkuUnit() {
List<SkuUnitDO> skuUnitList = goodsInfoDao.getSkuUnit();
List<SkuUnitDTO> list = skuUnitList.stream().map(SkuUnitDO::buildSkuUnitDTO).collect(Collectors.toList());
return ResultBody.success(list);
}
}
......
......@@ -7,6 +7,7 @@ import com.mmc.pms.dao.ProductDao;
import com.mmc.pms.entity.*;
import com.mmc.pms.model.dto.*;
import com.mmc.pms.model.qo.ProductSkuQO;
import com.mmc.pms.model.vo.PriceAcquisition;
import com.mmc.pms.model.vo.ProductSpecCPQVO;
import com.mmc.pms.page.PageResult;
import com.mmc.pms.service.ProductSkuService;
......@@ -14,6 +15,7 @@ import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
......@@ -245,6 +247,12 @@ public class ProductServiceImpl implements ProductSkuService {
return ResultBody.success();
}
}
@Override
public BigDecimal feignGetUnitPriceByTag(PriceAcquisition priceAcquisition) {
BigDecimal price = productDao.feignGetUnitPriceByTag(priceAcquisition);
return price == null ? null : price;
}
}
......
......@@ -5,8 +5,10 @@ import com.mmc.pms.entity.ProductSpecPriceDO;
import com.mmc.pms.model.dto.ProductSkuVO;
import com.mmc.pms.model.dto.ProductSpecVO;
import com.mmc.pms.model.qo.ProductSkuQO;
import com.mmc.pms.model.vo.PriceAcquisition;
import com.mmc.pms.model.vo.ProductSpecCPQVO;
import java.math.BigDecimal;
import java.util.List;
/**
......@@ -41,4 +43,7 @@ public interface ProductSkuService {
ResultBody removeProductSku(Integer id);
ResultBody removeProductSpec(Integer id);
BigDecimal feignGetUnitPriceByTag(PriceAcquisition priceAcquisition);
}
......@@ -192,4 +192,41 @@
WHERE mi.goods_info_id = #{id}
AND mi.is_deleted = 0
</select>
<select id="getGoodsSimpleInfo" resultType="com.mmc.pms.entity.GoodsInfo">
SELECT gi.id,
gi.goods_no,
gi.goods_name,
gi.eco_label,
gi.directory_id,
gi.category_by_one,
gi.category_by_two,
gi.shelf_status,
gi.create_time,
gv.id goodsVideoId,
gv.video_url videoUrl
FROM goods_info gi
LEFT JOIN goods_video gv ON gi.id = gv.goods_info_id
AND gv.is_deleted = 0
WHERE gi.id = #{goodsInfoId}
</select>
<select id="getGoodsDetailByGoodsId" resultType="com.mmc.pms.entity.GoodsDetailDO">
select id, goods_desc goodsDesc, content, remark
from goods_detail
where goods_info_id = #{goodsInfoId}
</select>
<select id="listGoodsServiceByGoodsId" resultType="com.mmc.pms.entity.GoodsServiceDO">
SELECT gc.id,
gc.sale_service_id,
ss.service_name
FROM goods_service gc
LEFT JOIN sale_service ss ON gc.sale_service_id = ss.id
WHERE gc.goods_info_id = #{goodsInfoId}
</select>
<select id="getSkuUnit" resultType="com.mmc.pms.entity.SkuUnitDO">
SELECT id,
unit_name unitName,
create_time createTime
FROM sku_unit
WHERE is_deleted = 0
</select>
</mapper>
......@@ -330,4 +330,15 @@
AND mi.is_deleted = 0
AND gi.is_deleted = 0
</select>
<select id="getIndustrySkuInfoSpec" resultType="com.mmc.pms.entity.MallIndustrySkuInfoSpecDO">
SELECT mi.id,
mi.mall_industry_sku_info_id,
mi.industry_spec_id,
ins.industry_sku_id,
ins.spec_image,
ins.spec_name
FROM mall_industry_sku_info_spec mi
INNER JOIN industry_spec ins ON ins.id = mi.industry_spec_id and mi.is_deleted = 0
WHERE goods_info_id = #{id}
</select>
</mapper>
\ No newline at end of file
......@@ -318,4 +318,10 @@
AND mp.is_deleted = 0
AND gi.is_deleted = 0
</select>
<select id="feignGetUnitPriceByTag" resultType="java.math.BigDecimal">
select price
from product_spec_price
where product_spec_id = #{specsId}
and cooperation_tag = #{channelLevelId}
</select>
</mapper>
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论