提交 de246e24 作者: xiaowang

新增:租赁设备详情及其他服务接口

上级 f20a6ca6
......@@ -13,85 +13,95 @@ import com.mmc.pms.service.GoodsInfoService;
import io.swagger.annotations.*;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import javax.annotation.Resource;
import java.util.List;
/**
* @Author LW
* @date 2023/3/14 13:22
* 概要:
*
* @date 2023/3/14 13:22 概要:
*/
@RestController
@RequestMapping("/goods")
@Api(tags = {"后台-商品管理-相关接口"})
public class BackstageGoodsManageController {
@Resource
private GoodsInfoService goodsInfoService;
@Resource private GoodsInfoService goodsInfoService;
@ApiOperation(value = "新增(租赁/销售)商品")
@PostMapping("addGoodsInfo")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)})
public ResultBody addGoods(@ApiParam("商品信息VO") @Validated(Create.class) @RequestBody GoodsAddVO goodsAddVO) {
return goodsInfoService.addGoods(goodsAddVO);
}
@ApiOperation(value = "新增(租赁/销售)商品")
@PostMapping("addGoodsInfo")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)})
public ResultBody addGoods(
@ApiParam("商品信息VO") @Validated(Create.class) @RequestBody GoodsAddVO goodsAddVO) {
return goodsInfoService.addGoods(goodsAddVO);
}
@ApiOperation(value = "修改(租赁/销售)商品")
@PostMapping("editGoodsInfo")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)})
public ResultBody editGoodsInfo(@ApiParam("商品信息VO") @Validated(Update.class) @RequestBody GoodsAddVO goodsAddVO) {
return goodsInfoService.editGoodsInfo(goodsAddVO);
}
@ApiOperation(value = "修改(租赁/销售)商品")
@PostMapping("editGoodsInfo")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)})
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 = "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();
}
@ApiOperation(value = "单位信息")
@GetMapping("getSkuUnit")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = SkuUnitDTO.class)})
public ResultBody getSkuUnit() {
return goodsInfoService.getSkuUnit();
}
@ApiOperation(value = "feign根据购物车信息填充未知信息", hidden = true)
@PostMapping("fillGoodsInfo")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = MallGoodsShopCarDTO.class)})
public List<MallGoodsShopCarDTO> fillGoodsInfo(@RequestBody List<MallGoodsShopCarDTO> param) {
return goodsInfoService.fillGoodsInfo(param);
}
@ApiOperation(value = "PC端-其他服务-列表")
@GetMapping("listOtherService")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = SaleServiceDTO.class)})
public ResultBody listOtherService() {
return goodsInfoService.getSaleServiceInfoToList();
}
@ApiOperation(value = "feign根据渠道等级和产品规格id获取对应价格", hidden = true)
@PostMapping("feignListProductSpecPrice")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)})
public List<MallProductSpecPriceDTO> feignListProductSpecPrice(@RequestBody ProductSpecPriceQO productSpecPriceQO) {
return goodsInfoService.feignListProductSpecPrice(productSpecPriceQO);
}
@ApiOperation(value = "feign根据购物车信息填充未知信息", hidden = true)
@PostMapping("fillGoodsInfo")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = MallGoodsShopCarDTO.class)})
public List<MallGoodsShopCarDTO> fillGoodsInfo(@RequestBody List<MallGoodsShopCarDTO> param) {
return goodsInfoService.fillGoodsInfo(param);
}
@ApiOperation(value = "feign根据渠道等级获取单价信息", hidden = true)
@GetMapping("feignGetUnitPriceByTag")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ProductSpecPriceDTO.class)})
public ProductSpecPriceDTO feignGetUnitPriceByTag(@RequestParam(value = "specId") Integer specId,
@RequestParam(value = "tagId") Integer tagId) {
return goodsInfoService.feignGetUnitPriceByTag(specId, tagId);
}
@ApiOperation(value = "feign根据渠道等级和产品规格id获取对应价格", hidden = true)
@PostMapping("feignListProductSpecPrice")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)})
public List<MallProductSpecPriceDTO> feignListProductSpecPrice(
@RequestBody ProductSpecPriceQO productSpecPriceQO) {
return goodsInfoService.feignListProductSpecPrice(productSpecPriceQO);
}
@ApiOperation(value = "feign根据商品的产品规格id查询商品信息", hidden = true)
@PostMapping("feignListProdGoodsSkuInfo")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = OrderGoodsProdDTO.class)})
public List<OrderGoodsProdDTO> feignListProdGoodsSkuInfo(@RequestBody MallOrderGoodsInfoQO mallOrderGoodsInfoQO) {
return goodsInfoService.feignListProdGoodsSkuInfo(mallOrderGoodsInfoQO);
}
@ApiOperation(value = "feign根据渠道等级获取单价信息", hidden = true)
@GetMapping("feignGetUnitPriceByTag")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ProductSpecPriceDTO.class)})
public ProductSpecPriceDTO feignGetUnitPriceByTag(
@RequestParam(value = "specId") Integer specId,
@RequestParam(value = "tagId") Integer tagId) {
return goodsInfoService.feignGetUnitPriceByTag(specId, tagId);
}
@ApiOperation(value = "feign根据商品的行业规格id查询商品清单信息", hidden = true)
@PostMapping("feignListIndstGoodsSkuInfo")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = OrderGoodsProdDTO.class)})
public List<OrderGoodsIndstDTO> feignListIndstGoodsSkuInfo(@RequestBody MallOrderGoodsInfoQO mallOrderGoodsInfoQO) {
return goodsInfoService.feignListIndstGoodsSkuInfo(mallOrderGoodsInfoQO);
}
@ApiOperation(value = "feign根据商品的产品规格id查询商品信息", hidden = true)
@PostMapping("feignListProdGoodsSkuInfo")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = OrderGoodsProdDTO.class)})
public List<OrderGoodsProdDTO> feignListProdGoodsSkuInfo(
@RequestBody MallOrderGoodsInfoQO mallOrderGoodsInfoQO) {
return goodsInfoService.feignListProdGoodsSkuInfo(mallOrderGoodsInfoQO);
}
@ApiOperation(value = "feign根据商品的行业规格id查询商品清单信息", hidden = true)
@PostMapping("feignListIndstGoodsSkuInfo")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = OrderGoodsProdDTO.class)})
public List<OrderGoodsIndstDTO> feignListIndstGoodsSkuInfo(
@RequestBody MallOrderGoodsInfoQO mallOrderGoodsInfoQO) {
return goodsInfoService.feignListIndstGoodsSkuInfo(mallOrderGoodsInfoQO);
}
}
......@@ -6,6 +6,7 @@ import com.mmc.pms.constant.TokenConstant;
import com.mmc.pms.controller.BaseController;
import com.mmc.pms.model.lease.dto.LeaseGoodsInfoDTO;
import com.mmc.pms.model.qo.WareInfoQO;
import com.mmc.pms.model.sale.dto.MallGoodsDetailDTO;
import com.mmc.pms.service.WebDeviceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
......@@ -13,10 +14,7 @@ import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
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.servlet.http.HttpServletRequest;
......@@ -42,4 +40,15 @@ public class LeaseGoodsController extends BaseController {
return webDeviceService.listWareInfoPage(
param, request, this.getUserLoginInfoFromRedis(request).getUserAccountId());
}
@ApiOperation(value = "设备设备详情")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = MallGoodsDetailDTO.class)})
@GetMapping("/getLeaseGoodsDetail")
public ResultBody listLeaseGoodsDetail(Integer goodsId, HttpServletRequest request) {
if (request.getHeader(TokenConstant.TOKEN) == null) {
return webDeviceService.listLeaseGoodsDetail(goodsId, null, null);
}
return webDeviceService.listLeaseGoodsDetail(
goodsId, this.getUserLoginInfoFromRedis(request).getUserAccountId(), request);
}
}
......@@ -11,91 +11,89 @@ import java.util.Set;
/**
* @author 23214
* @description 针对表【goods_info(商品基本信息)】的数据库操作Mapper
* @createDate 2023-05-27 14:08:45
* @Entity com.mmc.pms.entity.GoodsInfo
* @createDate 2023-05-27 14:08:45 @Entity com.mmc.pms.entity.GoodsInfo
*/
@Mapper
public interface GoodsInfoDao {
int countGoodsInfoByName(GoodsAddVO goodsAddVO);
int countGoodsInfoByName(GoodsAddVO goodsAddVO);
void insertGoodsInfo(GoodsInfo goodsInfo);
void insertGoodsInfo(GoodsInfo goodsInfo);
int countGoodsInfo();
int countGoodsInfo();
void insertGoodsImgInfo(List<GoodsImgDO> list);
void insertGoodsImgInfo(List<GoodsImgDO> list);
void insertVideoInfo(GoodsVideoDO goodsVideoDO);
void insertVideoInfo(GoodsVideoDO goodsVideoDO);
void insertGoodsDetail(GoodsDetailDO goodsDetailDO);
void insertGoodsDetail(GoodsDetailDO goodsDetailDO);
void insertGoodsService(List<GoodsServiceDO> otherList);
void insertGoodsService(List<GoodsServiceDO> otherList);
int countGoodsInfoById(Integer id);
int countGoodsInfoById(Integer id);
void updateGoodsInfo(GoodsInfo goodsInfo);
void updateGoodsInfo(GoodsInfo goodsInfo);
void updateGoodsDetail(GoodsDetailDO goodsDetailDO);
void updateGoodsDetail(GoodsDetailDO goodsDetailDO);
List<GoodsImgDO> listGoodsInfoByGoodsId(Integer id);
List<GoodsImgDO> listGoodsInfoByGoodsId(Integer id);
void deleteImgByIds(List<Integer> deleteIds);
void deleteImgByIds(List<Integer> deleteIds);
void deleteGoodsVideoById(Integer id);
void deleteGoodsVideoById(Integer id);
void deleteGoodsServiceByGoodsId(Integer id);
void deleteGoodsServiceByGoodsId(Integer id);
void insertMallIndustrySkuInfo(MallIndustrySkuInfoDO mallIndustrySkuInfoDO);
void insertMallIndustrySkuInfo(MallIndustrySkuInfoDO mallIndustrySkuInfoDO);
void insertMallIndustrySkuInfoSpec(MallIndustrySkuInfoSpecDO mallIndustrySkuInfoSpecDO);
void insertMallIndustrySkuInfoSpec(MallIndustrySkuInfoSpecDO mallIndustrySkuInfoSpecDO);
List<MallProdInfoDO> getMallProSkuInfo(Integer id);
List<MallProdInfoDO> getMallProSkuInfo(Integer id);
void batchUpdateMallProductSku(List<Integer> delIds);
void batchUpdateMallProductSku(List<Integer> delIds);
void batchUpdateMallProdSkuInfo(List<MallProdInfoDO> mallProdSkuInfoList);
void batchUpdateMallProdSkuInfo(List<MallProdInfoDO> mallProdSkuInfoList);
List<MallIndustrySkuInfoDO> getMallIndustrySkuInfo(Integer id);
List<MallIndustrySkuInfoDO> getMallIndustrySkuInfo(Integer id);
GoodsInfo getGoodsSimpleInfo(Integer goodsInfoId);
GoodsInfo getGoodsSimpleInfo(Integer goodsInfoId);
GoodsDetailDO getGoodsDetailByGoodsId(Integer goodsInfoId);
GoodsDetailDO getGoodsDetailByGoodsId(Integer goodsInfoId);
List<GoodsServiceDO> listGoodsServiceByGoodsId(Integer goodsInfoId);
List<GoodsServiceDO> listGoodsServiceByGoodsId(Integer goodsInfoId);
List<SkuUnitDO> getSkuUnit();
List<SkuUnitDO> getSkuUnit();
List<GoodsInfo> listSimpleGoodsInfoByIds(@Param("ids") Set<Integer> ids);
List<GoodsInfo> listSimpleGoodsInfoByIds(@Param("ids") Set<Integer> ids);
void insertMallProdSkuInfo(MallProdInfoDO mallProdSkuInfoDO);
void insertMallProdSkuInfo(MallProdInfoDO mallProdSkuInfoDO);
void insertMallProdSkuInfoSpec(MallProdSkuInfoSpecDO mallProdSkuInfoSpecDO);
void insertMallProdSkuInfoSpec(MallProdSkuInfoSpecDO mallProdSkuInfoSpecDO);
void batchUpdateMallProSpec(@Param("list") List<Integer> list, @Param("id") Integer id);
void batchUpdateMallProSpec(@Param("list") List<Integer> list, @Param("id") Integer id);
List<MallProdSkuInfoSpecDO> listMallProdSpecInfo(List<Integer> mallSkuIds);
List<MallProdSkuInfoSpecDO> listMallProdSpecInfo(List<Integer> mallSkuIds);
void batchUpdateMallProdSpec(List<Integer> delSpecId);
void batchUpdateMallProdSpec(List<Integer> delSpecId);
List<MallGoodsSpecInfoDO> listProdSpecInfo(@Param("prodIds") Set<Integer> prodIds);
List<MallGoodsSpecInfoDO> listProdSpecInfo(@Param("prodIds") Set<Integer> prodIds);
List<MallGoodsSpecInfoDO> listIndstSpecInfo(@Param("indstIds") Set<Integer> indstIds);
List<MallGoodsSpecInfoDO> listIndstSpecInfo(@Param("indstIds") Set<Integer> indstIds);
List<GoodsServiceDO> listGoodsService(List<Integer> goodsIds);
List<GoodsServiceDO> listGoodsService(List<Integer> goodsIds);
List<MallGoodsInfoSimpleDO> listMallGoodsIndstSimpleInfo(@Param("indstSkuSpecIds") Set<Integer> indstSkuSpecIds);
List<MallGoodsInfoSimpleDO> listMallGoodsIndstSimpleInfo(
@Param("indstSkuSpecIds") Set<Integer> indstSkuSpecIds);
List<Integer> listIndustrySpecIds(Set<Integer> mallIndstSkuSpecIds);
List<Integer> listIndustrySpecIds(Set<Integer> mallIndstSkuSpecIds);
List<MallGoodsProductDO> listIndustryProductList(List<Integer> industrySpecIds);
List<GoodsInfo> ListGoodsInfoByCategoryId(Integer id);
List<MallProdSkuInfoSpecDO> getMallProSkuInfoSpec(Integer goodsInfoId);
List<MallProdSkuInfoSpecDO> listMallprodSpecById(List<Integer> goodsIds);
}
List<MallGoodsProductDO> listIndustryProductList(List<Integer> industrySpecIds);
List<GoodsInfo> ListGoodsInfoByCategoryId(Integer id);
List<MallProdSkuInfoSpecDO> getMallProSkuInfoSpec(Integer goodsInfoId);
List<MallProdSkuInfoSpecDO> listMallprodSpecById(List<Integer> goodsIds);
List<SaleServiceDO> listSaleServiceInfo();
}
......@@ -116,4 +116,6 @@ public interface ProductDao {
List<MallProdSkuInfoSpecDO> listMallProductSpec(Integer id);
List<ProductSpecPriceDO> getProductSpecPriceList(List<Integer> specIds);
ProductSpecPriceDO getProductSpecPriceById(Integer id);
}
......@@ -18,56 +18,51 @@ import java.util.Date;
@AllArgsConstructor
@Accessors(chain = true)
public class MallProdInfoDO implements Serializable {
private static final long serialVersionUID = 3667714765929443857L;
private Integer id;
private Integer goodsInfoId;
private Integer prodSkuId;
private String prodSkuSpecName;
private Integer categoriesId;
private Integer chooseType;
private Integer must;
private Integer skuUnitId;
private Integer deleted;
private Date createTime;
private Date updateTime;
private Integer flag;
private String productSpecIdList;
private String beforeUpdateSpec;
/**
* 辅助字段 start
*/
private String typeName;
private String goodsName;
private String unitName;
private String productSkuName;
private Integer brandInfoId;
private static final long serialVersionUID = 3667714765929443857L;
private Integer id;
private Integer goodsInfoId;
private Integer prodSkuId;
private String prodSkuSpecName;
private Integer categoriesId;
private Integer chooseType;
private Integer must;
private Integer skuUnitId;
private Integer deleted;
private Date createTime;
private Date updateTime;
private Integer flag;
/** 辅助字段 start */
private String typeName;
/**
* 辅助字段 end
*/
public MallProdInfoDO(GoodsProdSpecVO goodsSpecVO) {
this.categoriesId = goodsSpecVO.getCategoryId();
this.prodSkuSpecName = goodsSpecVO.getGoodsSpecName();
this.chooseType = goodsSpecVO.getChooseType();
this.skuUnitId = goodsSpecVO.getSkuUnitId();
this.must = goodsSpecVO.getMust();
this.flag = goodsSpecVO.getFlag();
}
private String goodsName;
private String unitName;
private String productSkuName;
private Integer brandInfoId;
public GoodsSpecDTO buildGoodsSpecDTO() {
return GoodsSpecDTO.builder()
.id(this.id)
.goodsSpecName(this.prodSkuSpecName)
.categoryId(this.categoriesId)
.chooseType(this.chooseType)
.skuUnitId(skuUnitId)
.unitName(this.unitName)
.skuId(this.prodSkuId)
.typeName(this.typeName)
.must(must)
.skuName(this.productSkuName)
.brandInfoId(brandInfoId)
.flag(flag)
.build();
}
/** 辅助字段 end */
public MallProdInfoDO(GoodsProdSpecVO goodsSpecVO) {
this.categoriesId = goodsSpecVO.getCategoryId();
this.prodSkuSpecName = goodsSpecVO.getGoodsSpecName();
this.chooseType = goodsSpecVO.getChooseType();
this.skuUnitId = goodsSpecVO.getSkuUnitId();
this.must = goodsSpecVO.getMust();
this.flag = goodsSpecVO.getFlag();
}
public GoodsSpecDTO buildGoodsSpecDTO() {
return GoodsSpecDTO.builder()
.id(this.id)
.goodsSpecName(this.prodSkuSpecName)
.categoryId(this.categoriesId)
.chooseType(this.chooseType)
.skuUnitId(skuUnitId)
.unitName(this.unitName)
.skuId(this.prodSkuId)
.typeName(this.typeName)
.must(must)
.skuName(this.productSkuName)
.brandInfoId(brandInfoId)
.flag(flag)
.build();
}
}
package com.mmc.pms.entity;
import com.mmc.pms.model.sale.dto.SaleServiceDTO;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.Date;
/**
* @Author LW
*
* @date 2022/3/28 10:24 概要:
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class SaleServiceDO implements Serializable {
private Integer id;
private String serviceName;
private String remark;
private Integer deleted;
private Date updateTime;
private Date createTime;
public SaleServiceDTO buildSaleServiceDTO() {
return SaleServiceDTO.builder().id(this.id).saleServiceName(this.serviceName).build();
}
}
package com.mmc.pms.model.lease.dto;
import com.mmc.pms.model.sale.dto.GoodsDetailInfoDTO;
import com.mmc.pms.model.sale.dto.GoodsImgDTO;
import com.mmc.pms.model.sale.dto.GoodsOtherServiceDTO;
import com.mmc.pms.model.sale.dto.GoodsSpecDTO;
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/11/8 15:57 概要:
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
public class LeaseGoodsDetailDTO implements Serializable {
@ApiModelProperty(value = "id")
private Integer id;
@ApiModelProperty(value = "pid")
private Integer pid;
@ApiModelProperty(value = "商品名称")
private String goodsName;
@ApiModelProperty(value = "云享飞服务id")
private Integer shareFlyServiceId;
@ApiModelProperty(value = "云仓配件id")
private Integer repoId;
@ApiModelProperty(value = "规格信息")
private List<GoodsSpecDTO> goodsSpec;
@ApiModelProperty(value = "商品图片")
private List<GoodsImgDTO> images;
@ApiModelProperty(value = "商品视频")
private String goodsVideo;
@ApiModelProperty(value = "商品视频id")
private Integer goodsVideoId;
@ApiModelProperty(value = "商品详情")
private GoodsDetailInfoDTO goodsDetail;
@ApiModelProperty(value = "所属目录")
private Integer sortTypeId;
@ApiModelProperty(value = "一级分类id")
private Integer categoryByOne;
@ApiModelProperty(value = "二级分类id")
private Integer categoryByTwo;
@ApiModelProperty(value = "商品标签")
private String tag;
@ApiModelProperty(value = "其他服务: 1:免费配送,2:专业飞手培训2日, 3:半年保修, 4:一年保修 ")
private List<GoodsOtherServiceDTO> otherService;
}
......@@ -7,43 +7,60 @@ import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;
/**
* @Author LW
* @date 2022/10/14 11:30
* 概要:
*
* @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;
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;
@ApiModelProperty(value = "price(用于租赁商品)")
private BigDecimal price;
}
package com.mmc.pms.model.sale.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Author LW
* @date 2022/3/28 10:48
* 概要:
*/
@Builder
@Data
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "com.mmc.csf.mall.dto.SaleServiceDTO", description = "其他服务信息DTO")
public class SaleServiceDTO {
@ApiModelProperty(value = "id")
private Integer id;
@ApiModelProperty(value = "其他服务名称")
private String saleServiceName;
}
package com.mmc.pms.service;
import com.mmc.pms.common.ResultBody;
import com.mmc.pms.model.sale.dto.ProductSpecPriceDTO;
import com.mmc.pms.model.order.dto.OrderGoodsIndstDTO;
import com.mmc.pms.model.order.dto.OrderGoodsProdDTO;
import com.mmc.pms.model.qo.MallOrderGoodsInfoQO;
import com.mmc.pms.model.qo.ProductSpecPriceQO;
import com.mmc.pms.model.sale.dto.MallGoodsShopCarDTO;
import com.mmc.pms.model.sale.dto.MallProductSpecPriceDTO;
import com.mmc.pms.model.sale.dto.ProductSpecPriceDTO;
import com.mmc.pms.model.sale.vo.GoodsAddVO;
import java.util.List;
......@@ -19,21 +19,23 @@ import java.util.List;
*/
public interface GoodsInfoService {
ResultBody addGoods(GoodsAddVO goodsAddVO);
ResultBody addGoods(GoodsAddVO goodsAddVO);
ResultBody editGoodsInfo(GoodsAddVO goodsAddVO);
ResultBody editGoodsInfo(GoodsAddVO goodsAddVO);
ResultBody getGoodsInfoDetail(Integer goodsInfoId);
ResultBody getGoodsInfoDetail(Integer goodsInfoId);
ResultBody getSkuUnit();
ResultBody getSkuUnit();
ResultBody getSaleServiceInfoToList();
List<MallGoodsShopCarDTO> fillGoodsInfo(List<MallGoodsShopCarDTO> param);
List<MallGoodsShopCarDTO> fillGoodsInfo(List<MallGoodsShopCarDTO> param);
List<MallProductSpecPriceDTO> feignListProductSpecPrice(ProductSpecPriceQO productSpecPriceQO);
List<MallProductSpecPriceDTO> feignListProductSpecPrice(ProductSpecPriceQO productSpecPriceQO);
ProductSpecPriceDTO feignGetUnitPriceByTag(Integer specId, Integer tagId);
ProductSpecPriceDTO feignGetUnitPriceByTag(Integer specId, Integer tagId);
List<OrderGoodsProdDTO> feignListProdGoodsSkuInfo(MallOrderGoodsInfoQO mallOrderGoodsInfoQO);
List<OrderGoodsProdDTO> feignListProdGoodsSkuInfo(MallOrderGoodsInfoQO mallOrderGoodsInfoQO);
List<OrderGoodsIndstDTO> feignListIndstGoodsSkuInfo(MallOrderGoodsInfoQO mallOrderGoodsInfoQO);
List<OrderGoodsIndstDTO> feignListIndstGoodsSkuInfo(MallOrderGoodsInfoQO mallOrderGoodsInfoQO);
}
......@@ -32,828 +32,1074 @@ import java.util.stream.Collectors;
@Service
public class GoodsInfoServiceImpl implements GoodsInfoService {
@Resource
private GoodsInfoDao goodsInfoDao;
@Resource private GoodsInfoDao goodsInfoDao;
@Resource
private ProductDao productDao;
@Resource private ProductDao productDao;
@Resource
private ProductServiceImpl productSkuService;
@Resource private ProductServiceImpl productSkuService;
@Resource
private IndustrySpecDao industrySpecDao;
@Resource private IndustrySpecDao industrySpecDao;
@Override
@Transactional(rollbackFor = Exception.class)
public ResultBody addGoods(GoodsAddVO goodsAddVO) {
// 判断商品名称是否存在
if (goodsInfoDao.countGoodsInfoByName(goodsAddVO) > 0) {
return ResultBody.error(ResultEnum.GOODS_CATEGORY_NAME_EXIST_ERROR);
}
// 判断商品详情中描述是否为空
if (goodsAddVO.getGoodsDetailVO().getGoodsDesc() == null) {
return ResultBody.error(ResultEnum.GOODS_DESC_IS_NOT_NULL);
}
String YYYY_MM_DD_HH_MM_SS = "yyyyMMddHHmmss";
// 初始化商品对象,并构建对象
GoodsInfo goodsInfo = new GoodsInfo(goodsAddVO);
goodsInfo.setGoodsNo("IUAV" + TDateUtil.getDateStr(new Date(), YYYY_MM_DD_HH_MM_SS) + CodeUtil.getRandomNum(4));
// 暂未接入用户默认传1
goodsInfo.setAddGoodsUserId(1);
goodsInfo.setSort(goodsInfoDao.countGoodsInfo() + 1);
// 插入商品基本信息
goodsInfoDao.insertGoodsInfo(goodsInfo);
// 调用图片视频插入信息方法
addGoodsImageInfo(goodsInfo.getId(), goodsAddVO);
// 调用商品详情信息方法
addGoodsDetail(goodsInfo.getId(), goodsAddVO.getGoodsDetailVO());
// 判断其他服务是否为空,不为空则插入
if (!CollectionUtils.isEmpty(goodsAddVO.getOtherService())) {
addOtherService(goodsAddVO.getOtherService(), goodsInfo.getId());
}
// 调用产品规格的新增方法
if (!goodsAddVO.getDirectoryId().equals(2)) {
// 添加产品规格信息
productSkuSpecOperation(goodsInfo, goodsAddVO.getProductSpec());
} else {
industrySkuSpecOperation(goodsInfo, goodsAddVO.getProductSpec());
}
return ResultBody.success();
}
/**
* 插入行业sku及规格信息
*/
@Transactional(rollbackFor = Exception.class)
public void industrySkuSpecOperation(GoodsInfo goodsInfo, List<GoodsProdSpecVO> productSpec) {
for (GoodsProdSpecVO goodsSpecVO : productSpec) {
MallIndustrySkuInfoDO mallIndustrySkuInfoDO = new MallIndustrySkuInfoDO(goodsSpecVO).setGoodsInfoId(goodsInfo.getId());
// 插入数据库商品对应的sku信息
goodsInfoDao.insertMallIndustrySkuInfo(mallIndustrySkuInfoDO);
for (MallProductSpecVO mallProductSpecVO : goodsSpecVO.getSpecIds()) {
// 构建商品对应的规格信息
MallIndustrySkuInfoSpecDO mallIndustrySkuInfoSpecDO = new MallIndustrySkuInfoSpecDO()
.setIndustrySpecId(mallProductSpecVO.getMallSpecId())
.setMallIndustrySkuInfoId(mallIndustrySkuInfoDO.getId())
.setGoodsInfoId(goodsInfo.getId());
// 插入数据库商品对应的规格信息
goodsInfoDao.insertMallIndustrySkuInfoSpec(mallIndustrySkuInfoSpecDO);
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public ResultBody addGoods(GoodsAddVO goodsAddVO) {
// 判断商品名称是否存在
if (goodsInfoDao.countGoodsInfoByName(goodsAddVO) > 0) {
return ResultBody.error(ResultEnum.GOODS_CATEGORY_NAME_EXIST_ERROR);
}
// 判断商品详情中描述是否为空
if (goodsAddVO.getGoodsDetailVO().getGoodsDesc() == null) {
return ResultBody.error(ResultEnum.GOODS_DESC_IS_NOT_NULL);
}
String YYYY_MM_DD_HH_MM_SS = "yyyyMMddHHmmss";
// 初始化商品对象,并构建对象
GoodsInfo goodsInfo = new GoodsInfo(goodsAddVO);
goodsInfo.setGoodsNo(
"IUAV" + TDateUtil.getDateStr(new Date(), YYYY_MM_DD_HH_MM_SS) + CodeUtil.getRandomNum(4));
// 暂未接入用户默认传1
goodsInfo.setAddGoodsUserId(1);
goodsInfo.setSort(goodsInfoDao.countGoodsInfo() + 1);
// 插入商品基本信息
goodsInfoDao.insertGoodsInfo(goodsInfo);
// 调用图片视频插入信息方法
addGoodsImageInfo(goodsInfo.getId(), goodsAddVO);
// 调用商品详情信息方法
addGoodsDetail(goodsInfo.getId(), goodsAddVO.getGoodsDetailVO());
// 判断其他服务是否为空,不为空则插入
if (!CollectionUtils.isEmpty(goodsAddVO.getOtherService())) {
addOtherService(goodsAddVO.getOtherService(), goodsInfo.getId());
}
// 调用产品规格的新增方法
if (!goodsAddVO.getDirectoryId().equals(2)) {
// 添加产品规格信息
productSkuSpecOperation(goodsInfo, goodsAddVO.getProductSpec());
} else {
industrySkuSpecOperation(goodsInfo, goodsAddVO.getProductSpec());
}
return ResultBody.success();
}
@Transactional(rollbackFor = Exception.class)
public void productSkuSpecOperation(GoodsInfo goodsInfo, List<GoodsProdSpecVO> productSpec) {
// 遍历规格信息,获取其中自定义的规格信息
List<GoodsProdSpecVO> customGoodsSpecList = productSpec.stream().filter(spec -> spec.getFlag().equals(1)).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(customGoodsSpecList)) {
addCustomization(goodsInfo, customGoodsSpecList);
}
// 遍历规格信息,获取其中非自定义的规格信息
List<GoodsProdSpecVO> goodsSpecList = productSpec.stream().filter(spec -> spec.getFlag().equals(0)).collect(Collectors.toList());
for (GoodsProdSpecVO goodsSpecVO : goodsSpecList) {
MallProdInfoDO mallProdSkuInfoDO = new MallProdInfoDO(goodsSpecVO)
.setProdSkuId(goodsSpecVO.getSkuId()).setGoodsInfoId(goodsInfo.getId());
// 插入数据库商品对应的sku信息
goodsInfoDao.insertMallProdSkuInfo(mallProdSkuInfoDO);
for (MallProductSpecVO mallProductSpecVO : goodsSpecVO.getSpecIds()) {
// 构建商品对应的规格信息
MallProdSkuInfoSpecDO mallProdSkuInfoSpecDO = new MallProdSkuInfoSpecDO()
.setProductSpecId(mallProductSpecVO.getMallSpecId())
.setMallProdSkuInfoId(mallProdSkuInfoDO.getId())
.setGoodsInfoId(goodsInfo.getId());
// 插入数据库商品对应的规格信息
goodsInfoDao.insertMallProdSkuInfoSpec(mallProdSkuInfoSpecDO);
}
}
/** 插入行业sku及规格信息 */
@Transactional(rollbackFor = Exception.class)
public void industrySkuSpecOperation(GoodsInfo goodsInfo, List<GoodsProdSpecVO> productSpec) {
for (GoodsProdSpecVO goodsSpecVO : productSpec) {
MallIndustrySkuInfoDO mallIndustrySkuInfoDO =
new MallIndustrySkuInfoDO(goodsSpecVO).setGoodsInfoId(goodsInfo.getId());
// 插入数据库商品对应的sku信息
goodsInfoDao.insertMallIndustrySkuInfo(mallIndustrySkuInfoDO);
for (MallProductSpecVO mallProductSpecVO : goodsSpecVO.getSpecIds()) {
// 构建商品对应的规格信息
MallIndustrySkuInfoSpecDO mallIndustrySkuInfoSpecDO =
new MallIndustrySkuInfoSpecDO()
.setIndustrySpecId(mallProductSpecVO.getMallSpecId())
.setMallIndustrySkuInfoId(mallIndustrySkuInfoDO.getId())
.setGoodsInfoId(goodsInfo.getId());
// 插入数据库商品对应的规格信息
goodsInfoDao.insertMallIndustrySkuInfoSpec(mallIndustrySkuInfoSpecDO);
}
}
}
@Transactional(rollbackFor = Exception.class)
public void productSkuSpecOperation(GoodsInfo goodsInfo, List<GoodsProdSpecVO> productSpec) {
// 遍历规格信息,获取其中自定义的规格信息
List<GoodsProdSpecVO> customGoodsSpecList =
productSpec.stream().filter(spec -> spec.getFlag().equals(1)).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(customGoodsSpecList)) {
addCustomization(goodsInfo, customGoodsSpecList);
}
// 遍历规格信息,获取其中非自定义的规格信息
List<GoodsProdSpecVO> goodsSpecList =
productSpec.stream().filter(spec -> spec.getFlag().equals(0)).collect(Collectors.toList());
for (GoodsProdSpecVO goodsSpecVO : goodsSpecList) {
MallProdInfoDO mallProdSkuInfoDO =
new MallProdInfoDO(goodsSpecVO)
.setProdSkuId(goodsSpecVO.getSkuId())
.setGoodsInfoId(goodsInfo.getId());
// 插入数据库商品对应的sku信息
goodsInfoDao.insertMallProdSkuInfo(mallProdSkuInfoDO);
for (MallProductSpecVO mallProductSpecVO : goodsSpecVO.getSpecIds()) {
// 构建商品对应的规格信息
MallProdSkuInfoSpecDO mallProdSkuInfoSpecDO =
new MallProdSkuInfoSpecDO()
.setProductSpecId(mallProductSpecVO.getMallSpecId())
.setMallProdSkuInfoId(mallProdSkuInfoDO.getId())
.setGoodsInfoId(goodsInfo.getId());
// 插入数据库商品对应的规格信息
goodsInfoDao.insertMallProdSkuInfoSpec(mallProdSkuInfoSpecDO);
}
}
}
@Transactional(rollbackFor = Exception.class)
public MallProdInfoDO buildMallProdSkuInfo(GoodsInfo goodsInfo, GoodsProdSpecVO goodsSpec, Integer id) {
MallProdInfoDO mallProdInfoDO = new MallProdInfoDO();
mallProdInfoDO.setGoodsInfoId(goodsInfo.getId());
mallProdInfoDO.setProdSkuId(id);
mallProdInfoDO.setProdSkuSpecName(goodsSpec.getGoodsSpecName());
mallProdInfoDO.setCategoriesId(goodsSpec.getCategoryId());
mallProdInfoDO.setChooseType(goodsSpec.getChooseType());
mallProdInfoDO.setMust(goodsSpec.getMust());
mallProdInfoDO.setFlag(goodsSpec.getFlag());
mallProdInfoDO.setSkuUnitId(goodsSpec.getSkuUnitId());
return mallProdInfoDO;
}
@Transactional(rollbackFor = Exception.class)
public void addCustomization(GoodsInfo goodsInfo, List<GoodsProdSpecVO> customGoodsSpecList) {
// 遍历自定义规格信息
for (GoodsProdSpecVO productSpec : customGoodsSpecList) {
// 构建商品对应的sku信息
ProductSkuDO productSkuDO = new ProductSkuDO().setCategoriesId(productSpec.getCategoryId())
.setProductName(productSpec.getProductName()).setCustomize(1)
.setDirectoryId(goodsInfo.getDirectoryId());
// 插入产品sku信息
productDao.insertProductSku(productSkuDO);
MallProdInfoDO mallProdInfoDO = buildMallProdSkuInfo(goodsInfo, productSpec, productSkuDO.getId());
// 插入数据库商品对应的sku信息
productDao.insertMallProdSkuInfo(mallProdInfoDO);
// 先将自定的信息存储到数据库中
productSpec.getCustomizeInfo().stream().peek(param -> {
ProductSpecDO productSpecDO = new ProductSpecDO().setProductSkuId(productSkuDO.getId())
.setVersionDesc("自定义").setSpecImage(param.getSpecImage())
.setSpecName(param.getSpecName()).setPartNo(param.getPartNo());
@Transactional(rollbackFor = Exception.class)
public MallProdInfoDO buildMallProdSkuInfo(
GoodsInfo goodsInfo, GoodsProdSpecVO goodsSpec, Integer id) {
MallProdInfoDO mallProdInfoDO = new MallProdInfoDO();
mallProdInfoDO.setGoodsInfoId(goodsInfo.getId());
mallProdInfoDO.setProdSkuId(id);
mallProdInfoDO.setProdSkuSpecName(goodsSpec.getGoodsSpecName());
mallProdInfoDO.setCategoriesId(goodsSpec.getCategoryId());
mallProdInfoDO.setChooseType(goodsSpec.getChooseType());
mallProdInfoDO.setMust(goodsSpec.getMust());
mallProdInfoDO.setFlag(goodsSpec.getFlag());
mallProdInfoDO.setSkuUnitId(goodsSpec.getSkuUnitId());
return mallProdInfoDO;
}
@Transactional(rollbackFor = Exception.class)
public void addCustomization(GoodsInfo goodsInfo, List<GoodsProdSpecVO> customGoodsSpecList) {
// 遍历自定义规格信息
for (GoodsProdSpecVO productSpec : customGoodsSpecList) {
// 构建商品对应的sku信息
ProductSkuDO productSkuDO =
new ProductSkuDO()
.setCategoriesId(productSpec.getCategoryId())
.setProductName(productSpec.getProductName())
.setCustomize(1)
.setDirectoryId(goodsInfo.getDirectoryId());
// 插入产品sku信息
productDao.insertProductSku(productSkuDO);
MallProdInfoDO mallProdInfoDO =
buildMallProdSkuInfo(goodsInfo, productSpec, productSkuDO.getId());
// 插入数据库商品对应的sku信息
productDao.insertMallProdSkuInfo(mallProdInfoDO);
// 先将自定的信息存储到数据库中
productSpec.getCustomizeInfo().stream()
.peek(
param -> {
ProductSpecDO productSpecDO =
new ProductSpecDO()
.setProductSkuId(productSkuDO.getId())
.setVersionDesc("自定义")
.setSpecImage(param.getSpecImage())
.setSpecName(param.getSpecName())
.setPartNo(param.getPartNo());
// 新增产品sku
productDao.insertProductSpec(productSpecDO);
// 批量配置价格信息
ProductSpecCPQVO productSpecCPQVO = param.getProductSpecCPQVO();
if (productSpecCPQVO != null) {
productSpecCPQVO.setProductSpecId(productSpecDO.getId());
productSkuService.insertSpecPrice(productSpecCPQVO);
productSpecCPQVO.setProductSpecId(productSpecDO.getId());
productSkuService.insertSpecPrice(productSpecCPQVO);
}
// 构建商品对应的规格信息
MallProdSkuInfoSpecDO mallProdSkuInfoSpecDO = new MallProdSkuInfoSpecDO()
MallProdSkuInfoSpecDO mallProdSkuInfoSpecDO =
new MallProdSkuInfoSpecDO()
.setProductSpecId(productSpecDO.getId())
.setMallProdSkuInfoId(mallProdInfoDO.getId())
.setGoodsInfoId(goodsInfo.getId());
// 插入数据库商品对应的规格信息
goodsInfoDao.insertMallProdSkuInfoSpec(mallProdSkuInfoSpecDO);
}).collect(Collectors.toList());
}
})
.collect(Collectors.toList());
}
}
@Transactional(rollbackFor = Exception.class)
public void addOtherService(List<Integer> otherService, Integer goodsId) {
// 插入其他服务
List<GoodsServiceDO> otherList = otherService.stream().map(d -> {
GoodsServiceDO goodsServiceDO = new GoodsServiceDO();
goodsServiceDO.setGoodsInfoId(goodsId);
goodsServiceDO.setSaleServiceId(d);
return goodsServiceDO;
}).collect(Collectors.toList());
goodsInfoDao.insertGoodsService(otherList);
}
@Transactional(rollbackFor = Exception.class)
public void addGoodsDetail(Integer goodsId, GoodsDetailVO goodsDetailVO) {
GoodsDetailDO goodsDetailDO = new GoodsDetailDO(goodsDetailVO);
goodsDetailDO.setGoodsInfoId(goodsId);
goodsInfoDao.insertGoodsDetail(goodsDetailDO);
}
@Transactional(rollbackFor = Exception.class)
public void addGoodsImageInfo(Integer goodsId, GoodsAddVO goodsAddVO) {
List<GoodsImgDO> list = goodsAddVO.getImages().stream().map(d -> {
GoodsImgDO goodsImgDO = new GoodsImgDO(d);
goodsImgDO.setGoodsInfoId(goodsId);
return goodsImgDO;
}).collect(Collectors.toList());
// 插入图片信息
goodsInfoDao.insertGoodsImgInfo(list);
// 插入商品视频信息
if (goodsAddVO.getGoodsVideo() != null) {
GoodsVideoDO goodsVideoDO = new GoodsVideoDO().setGoodsInfoId(goodsId).setVideoUrl(goodsAddVO.getGoodsVideo());
goodsInfoDao.insertVideoInfo(goodsVideoDO);
}
@Transactional(rollbackFor = Exception.class)
public void addOtherService(List<Integer> otherService, Integer goodsId) {
// 插入其他服务
List<GoodsServiceDO> otherList =
otherService.stream()
.map(
d -> {
GoodsServiceDO goodsServiceDO = new GoodsServiceDO();
goodsServiceDO.setGoodsInfoId(goodsId);
goodsServiceDO.setSaleServiceId(d);
return goodsServiceDO;
})
.collect(Collectors.toList());
goodsInfoDao.insertGoodsService(otherList);
}
@Transactional(rollbackFor = Exception.class)
public void addGoodsDetail(Integer goodsId, GoodsDetailVO goodsDetailVO) {
GoodsDetailDO goodsDetailDO = new GoodsDetailDO(goodsDetailVO);
goodsDetailDO.setGoodsInfoId(goodsId);
goodsInfoDao.insertGoodsDetail(goodsDetailDO);
}
@Transactional(rollbackFor = Exception.class)
public void addGoodsImageInfo(Integer goodsId, GoodsAddVO goodsAddVO) {
List<GoodsImgDO> list =
goodsAddVO.getImages().stream()
.map(
d -> {
GoodsImgDO goodsImgDO = new GoodsImgDO(d);
goodsImgDO.setGoodsInfoId(goodsId);
return goodsImgDO;
})
.collect(Collectors.toList());
// 插入图片信息
goodsInfoDao.insertGoodsImgInfo(list);
// 插入商品视频信息
if (goodsAddVO.getGoodsVideo() != null) {
GoodsVideoDO goodsVideoDO =
new GoodsVideoDO().setGoodsInfoId(goodsId).setVideoUrl(goodsAddVO.getGoodsVideo());
goodsInfoDao.insertVideoInfo(goodsVideoDO);
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public ResultBody editGoodsInfo(GoodsAddVO goodsAddVO) {
// 判断商品是否还存在
int count = goodsInfoDao.countGoodsInfoById(goodsAddVO.getId());
if (count <= 0) {
return ResultBody.error(ResultEnum.GOODS_NOT_EXIST_OR_ALREADY_DOWN_SHELF);
}
// 判断商品名称是否存在
if (goodsInfoDao.countGoodsInfoByName(goodsAddVO) > 0) {
return ResultBody.error(ResultEnum.GOODS_CATEGORY_NAME_EXIST_ERROR);
}
// 判断商品详情中描述是否为空
if (goodsAddVO.getGoodsDetailVO().getGoodsDesc() == null) {
return ResultBody.error(ResultEnum.GOODS_DESC_IS_NOT_NULL);
}
// 初始化商品对象,并构建对象
GoodsInfo goodsInfo = new GoodsInfo(goodsAddVO);
// 插入商品基本信息
goodsInfoDao.updateGoodsInfo(goodsInfo);
// 修改商品详情信息
updateGoodsDetail(goodsAddVO);
// 修改商品图片及视频信息
updateImageInfo(goodsAddVO);
// 修改其他服务信息
updateOtherService(goodsAddVO);
// 修改规格信息
if (!goodsAddVO.getDirectoryId().equals(2)) {
updateMallProductSkuSpec(goodsAddVO);
} else {
updateMallIndustrySkuSpec(goodsAddVO);
}
return null;
}
@Transactional(rollbackFor = Exception.class)
public void updateMallIndustrySkuSpec(GoodsAddVO goodsAddVO) {
// 先获取用户输入的商品绑定sku的id集合
Set<Integer> inputMallSkuIds = goodsAddVO.getProductSpec().stream().map(GoodsProdSpecVO::getId).filter(Objects::nonNull).collect(Collectors.toSet());
// 从数据库获取该商品对应绑定的skuId的集合
List<MallIndustrySkuInfoDO> mallIndusSkuInfoList = goodsInfoDao.getMallIndustrySkuInfo(goodsAddVO.getId());
List<Integer> dbMallSkuIds = mallIndusSkuInfoList.stream().map(MallIndustrySkuInfoDO::getId).collect(Collectors.toList());
// 对比数据库id如果不在就删除
List<Integer> delIds = dbMallSkuIds.stream().filter(id -> !inputMallSkuIds.contains(id)).collect(Collectors.toList());
if (delIds.size() != 0) {
// 先删除商品绑定sku下的spec信息
industrySpecDao.batchUpdateMallIndustrySpec(delIds, goodsAddVO.getId());
industrySpecDao.batchUpdateMallIndustrySku(delIds);
@Override
@Transactional(rollbackFor = Exception.class)
public ResultBody editGoodsInfo(GoodsAddVO goodsAddVO) {
// 判断商品是否还存在
int count = goodsInfoDao.countGoodsInfoById(goodsAddVO.getId());
if (count <= 0) {
return ResultBody.error(ResultEnum.GOODS_NOT_EXIST_OR_ALREADY_DOWN_SHELF);
}
// 判断商品名称是否存在
if (goodsInfoDao.countGoodsInfoByName(goodsAddVO) > 0) {
return ResultBody.error(ResultEnum.GOODS_CATEGORY_NAME_EXIST_ERROR);
}
// 判断商品详情中描述是否为空
if (goodsAddVO.getGoodsDetailVO().getGoodsDesc() == null) {
return ResultBody.error(ResultEnum.GOODS_DESC_IS_NOT_NULL);
}
// 初始化商品对象,并构建对象
GoodsInfo goodsInfo = new GoodsInfo(goodsAddVO);
// 插入商品基本信息
goodsInfoDao.updateGoodsInfo(goodsInfo);
// 修改商品详情信息
updateGoodsDetail(goodsAddVO);
// 修改商品图片及视频信息
updateImageInfo(goodsAddVO);
// 修改其他服务信息
updateOtherService(goodsAddVO);
// 修改规格信息
if (!goodsAddVO.getDirectoryId().equals(2)) {
updateMallProductSkuSpec(goodsAddVO);
} else {
updateMallIndustrySkuSpec(goodsAddVO);
}
return null;
}
@Transactional(rollbackFor = Exception.class)
public void updateMallIndustrySkuSpec(GoodsAddVO goodsAddVO) {
// 先获取用户输入的商品绑定sku的id集合
Set<Integer> inputMallSkuIds =
goodsAddVO.getProductSpec().stream()
.map(GoodsProdSpecVO::getId)
.filter(Objects::nonNull)
.collect(Collectors.toSet());
// 从数据库获取该商品对应绑定的skuId的集合
List<MallIndustrySkuInfoDO> mallIndusSkuInfoList =
goodsInfoDao.getMallIndustrySkuInfo(goodsAddVO.getId());
List<Integer> dbMallSkuIds =
mallIndusSkuInfoList.stream()
.map(MallIndustrySkuInfoDO::getId)
.collect(Collectors.toList());
// 对比数据库id如果不在就删除
List<Integer> delIds =
dbMallSkuIds.stream()
.filter(id -> !inputMallSkuIds.contains(id))
.collect(Collectors.toList());
if (delIds.size() != 0) {
// 先删除商品绑定sku下的spec信息
industrySpecDao.batchUpdateMallIndustrySpec(delIds, goodsAddVO.getId());
industrySpecDao.batchUpdateMallIndustrySku(delIds);
}
// 修改商品绑定的sku信息
List<GoodsProdSpecVO> updateGoodsSpec =
goodsAddVO.getProductSpec().stream().filter(Objects::nonNull).collect(Collectors.toList());
List<MallIndustrySkuInfoDO> mallIndustrySkuInfoList =
updateGoodsSpec.stream()
.map(
d -> {
MallIndustrySkuInfoDO mallIndustrySkuInfoDO = new MallIndustrySkuInfoDO();
mallIndustrySkuInfoDO
.setId(d.getId())
.setIndustrySkuId(d.getSkuId())
.setCategoriesId(d.getCategoryId())
.setIndustrySkuSpecName(d.getGoodsSpecName())
.setChooseType(d.getChooseType())
.setSkuUnitId(d.getSkuUnitId())
.setMust(d.getMust());
return mallIndustrySkuInfoDO;
})
.collect(Collectors.toList());
// 批量修改sku的信息
industrySpecDao.batchUpdateMallIndustrySkuInfo(mallIndustrySkuInfoList);
// 获取新的sku信息
List<GoodsProdSpecVO> list =
goodsAddVO.getProductSpec().stream()
.filter(d -> d.getId() == null)
.collect(Collectors.toList());
industrySkuSpecOperation(new GoodsInfo(goodsAddVO.getId()), list);
// 获取商品对应的skuId
List<Integer> mallSkuIds =
goodsAddVO.getProductSpec().stream()
.map(GoodsProdSpecVO::getId)
.filter(Objects::nonNull)
.collect(Collectors.toList());
// 根据这些id查出下面对应的规格信息
List<MallIndustrySkuInfoSpecDO> mallIndustrySkuInfoSpecList =
industrySpecDao.listMallIndustrySpecInfo(mallSkuIds);
// 分组
Map<Integer, List<MallIndustrySkuInfoSpecDO>> dbSpecMap =
mallIndustrySkuInfoSpecList.stream()
.collect(Collectors.groupingBy(MallIndustrySkuInfoSpecDO::getMallIndustrySkuInfoId));
List<GoodsProdSpecVO> goodsSpecList =
goodsAddVO.getProductSpec().stream()
.filter(d -> d.getId() != null)
.collect(Collectors.toList());
for (GoodsProdSpecVO goodsSpecVO : goodsSpecList) {
// 分组后的每一条商品绑定的规格信息
List<MallIndustrySkuInfoSpecDO> dbMallIndustrySkuSpecList =
dbSpecMap.get(goodsSpecVO.getId());
Set<Integer> inputMallSpecIds =
goodsSpecVO.getSpecIds().stream()
.map(MallProductSpecVO::getId)
.filter(Objects::nonNull)
.collect(Collectors.toSet());
List<Integer> delSpecId =
dbMallIndustrySkuSpecList.stream()
.map(MallIndustrySkuInfoSpecDO::getId)
.filter(id -> !inputMallSpecIds.contains(id))
.collect(Collectors.toList());
if (delSpecId.size() != 0) {
// 删除多余的spec信息
industrySpecDao.batchUpdateMallIndustSpec(delSpecId, goodsAddVO.getId());
}
// 新增spec的信息
for (MallProductSpecVO mallProductSpecVO : goodsSpecVO.getSpecIds()) {
if (mallProductSpecVO.getId() == null) {
MallIndustrySkuInfoSpecDO mallIndustrySkuInfoSpecDO =
new MallIndustrySkuInfoSpecDO()
.setIndustrySpecId(mallProductSpecVO.getMallSpecId())
.setMallIndustrySkuInfoId(goodsSpecVO.getId())
.setGoodsInfoId(goodsAddVO.getId());
// 插入数据库商品对应的规格信息
goodsInfoDao.insertMallIndustrySkuInfoSpec(mallIndustrySkuInfoSpecDO);
}
// 修改商品绑定的sku信息
List<GoodsProdSpecVO> updateGoodsSpec = goodsAddVO.getProductSpec().stream().filter(Objects::nonNull).collect(Collectors.toList());
List<MallIndustrySkuInfoDO> mallIndustrySkuInfoList = updateGoodsSpec.stream().map(d -> {
MallIndustrySkuInfoDO mallIndustrySkuInfoDO = new MallIndustrySkuInfoDO();
mallIndustrySkuInfoDO.setId(d.getId()).setIndustrySkuId(d.getSkuId())
.setCategoriesId(d.getCategoryId()).setIndustrySkuSpecName(d.getGoodsSpecName())
.setChooseType(d.getChooseType()).setSkuUnitId(d.getSkuUnitId()).setMust(d.getMust());
return mallIndustrySkuInfoDO;
}).collect(Collectors.toList());
// 批量修改sku的信息
industrySpecDao.batchUpdateMallIndustrySkuInfo(mallIndustrySkuInfoList);
// 获取新的sku信息
List<GoodsProdSpecVO> list = goodsAddVO.getProductSpec().stream().filter(d -> d.getId() == null).collect(Collectors.toList());
industrySkuSpecOperation(new GoodsInfo(goodsAddVO.getId()), list);
// 获取商品对应的skuId
List<Integer> mallSkuIds = goodsAddVO.getProductSpec().stream().map(GoodsProdSpecVO::getId).filter(Objects::nonNull).collect(Collectors.toList());
}
}
}
@Transactional(rollbackFor = Exception.class)
public void updateMallProductSkuSpec(GoodsAddVO goodsAddVO) {
// 1、普通的sku修改逻辑
List<GoodsProdSpecVO> specInfo =
goodsAddVO.getProductSpec().stream()
.filter(spec -> !spec.getFlag().equals(1))
.collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(specInfo)) {
// 1.1先获取用户输入的商品绑定sku的id集合
List<GoodsProdSpecVO> updateGoodsSpec =
specInfo.stream().filter(d -> d.getId() != null).collect(Collectors.toList());
List<Integer> inputMallSkuIds =
updateGoodsSpec.stream().map(GoodsProdSpecVO::getId).collect(Collectors.toList());
// 1.2从数据库获取该商品对应绑定的skuId的集合
List<MallProdInfoDO> mallProSkuInfoList = goodsInfoDao.getMallProSkuInfo(goodsAddVO.getId());
List<Integer> dbMallSkuIds =
mallProSkuInfoList.stream().map(MallProdInfoDO::getId).collect(Collectors.toList());
// 对比数据库id如果不在就删除
List<Integer> delIds =
dbMallSkuIds.stream()
.filter(id -> !inputMallSkuIds.contains(id))
.collect(Collectors.toList());
if (delIds.size() != 0) {
// 先删除商品绑定sku下的spec信息
goodsInfoDao.batchUpdateMallProSpec(delIds, goodsAddVO.getId());
goodsInfoDao.batchUpdateMallProductSku(delIds);
}
// 修改商品绑定的sku信息
List<MallProdInfoDO> mallProdSkuInfoList =
updateGoodsSpec.stream()
.map(
d -> {
MallProdInfoDO mallProdInfoDO = new MallProdInfoDO();
mallProdInfoDO
.setId(d.getId())
.setProdSkuId(d.getSkuId())
.setCategoriesId(d.getCategoryId())
.setProdSkuSpecName(d.getGoodsSpecName())
.setChooseType(d.getChooseType())
.setSkuUnitId(d.getSkuUnitId())
.setMust(d.getMust());
return mallProdInfoDO;
})
.collect(Collectors.toList());
// 1.3批量修改sku的信息
goodsInfoDao.batchUpdateMallProdSkuInfo(mallProdSkuInfoList);
// 1.4对新的sku进行操作
List<GoodsProdSpecVO> list =
specInfo.stream().filter(d -> d.getId() == null).collect(Collectors.toList());
productSkuSpecOperation(new GoodsInfo(goodsAddVO.getId()), list);
// 获取商品对应的skuId
List<Integer> mallSkuIds =
goodsAddVO.getProductSpec().stream()
.filter(d -> d.getId() != null)
.map(GoodsProdSpecVO::getId)
.collect(Collectors.toList());
if (mallSkuIds.size() > 0) {
// 根据这些id查出下面对应的规格信息
List<MallIndustrySkuInfoSpecDO> mallIndustrySkuInfoSpecList = industrySpecDao.listMallIndustrySpecInfo(mallSkuIds);
List<MallProdSkuInfoSpecDO> mallProdSkuInfoSpecList =
goodsInfoDao.listMallProdSpecInfo(mallSkuIds);
// 分组
Map<Integer, List<MallIndustrySkuInfoSpecDO>> dbSpecMap = mallIndustrySkuInfoSpecList.stream().collect(Collectors.groupingBy(MallIndustrySkuInfoSpecDO::getMallIndustrySkuInfoId));
List<GoodsProdSpecVO> goodsSpecList = goodsAddVO.getProductSpec().stream().filter(d -> d.getId() != null).collect(Collectors.toList());
for (GoodsProdSpecVO goodsSpecVO : goodsSpecList) {
// 分组后的每一条商品绑定的规格信息
List<MallIndustrySkuInfoSpecDO> dbMallIndustrySkuSpecList = dbSpecMap.get(goodsSpecVO.getId());
Set<Integer> inputMallSpecIds = goodsSpecVO.getSpecIds().stream().map(MallProductSpecVO::getId).filter(Objects::nonNull).collect(Collectors.toSet());
List<Integer> delSpecId = dbMallIndustrySkuSpecList.stream().map(MallIndustrySkuInfoSpecDO::getId).filter(id -> !inputMallSpecIds.contains(id)).collect(Collectors.toList());
if (delSpecId.size() != 0) {
// 删除多余的spec信息
industrySpecDao.batchUpdateMallIndustSpec(delSpecId, goodsAddVO.getId());
}
// 新增spec的信息
for (MallProductSpecVO mallProductSpecVO : goodsSpecVO.getSpecIds()) {
if (mallProductSpecVO.getId() == null) {
MallIndustrySkuInfoSpecDO mallIndustrySkuInfoSpecDO = new MallIndustrySkuInfoSpecDO()
.setIndustrySpecId(mallProductSpecVO.getMallSpecId())
.setMallIndustrySkuInfoId(goodsSpecVO.getId())
.setGoodsInfoId(goodsAddVO.getId());
// 插入数据库商品对应的规格信息
goodsInfoDao.insertMallIndustrySkuInfoSpec(mallIndustrySkuInfoSpecDO);
}
Map<Integer, List<MallProdSkuInfoSpecDO>> dbSpecMap =
mallProdSkuInfoSpecList.stream()
.collect(Collectors.groupingBy(MallProdSkuInfoSpecDO::getMallProdSkuInfoId));
for (GoodsProdSpecVO goodsSpecVO : updateGoodsSpec) {
// 分组后的每一条商品绑定的规格信息
List<MallProdSkuInfoSpecDO> dbMallProdSkuSpecList = dbSpecMap.get(goodsSpecVO.getId());
Set<Integer> inputMallSpecIds =
goodsSpecVO.getSpecIds().stream()
.map(MallProductSpecVO::getId)
.filter(Objects::nonNull)
.collect(Collectors.toSet());
List<Integer> delSpecId =
dbMallProdSkuSpecList.stream()
.map(MallProdSkuInfoSpecDO::getId)
.filter(id -> !inputMallSpecIds.contains(id))
.collect(Collectors.toList());
if (delSpecId.size() != 0) {
// 删除多余的spec信息
goodsInfoDao.batchUpdateMallProdSpec(delSpecId);
}
// 新增spec的信息
for (MallProductSpecVO mallProductSpecVO : goodsSpecVO.getSpecIds()) {
if (mallProductSpecVO.getId() == null) {
MallProdSkuInfoSpecDO mallProdSkuInfoSpecDO =
new MallProdSkuInfoSpecDO()
.setProductSpecId(mallProductSpecVO.getMallSpecId())
.setMallProdSkuInfoId(goodsSpecVO.getId())
.setGoodsInfoId(goodsAddVO.getId());
// 插入数据库商品对应的规格信息
goodsInfoDao.insertMallProdSkuInfoSpec(mallProdSkuInfoSpecDO);
}
}
}
}
// 2、对自定义的sku进行操作
List<GoodsProdSpecVO> zdySpecInfo =
goodsAddVO.getProductSpec().stream()
.filter(spec -> spec.getFlag().equals(1))
.collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(zdySpecInfo)) {
updateCustomize(zdySpecInfo, goodsAddVO.getId());
}
}
}
@Transactional(rollbackFor = Exception.class)
public void updateMallProductSkuSpec(GoodsAddVO goodsAddVO) {
// 1、普通的sku修改逻辑
List<GoodsProdSpecVO> specInfo = goodsAddVO.getProductSpec().stream().filter(spec -> !spec.getFlag().equals(1)).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(specInfo)) {
// 1.1先获取用户输入的商品绑定sku的id集合
List<GoodsProdSpecVO> updateGoodsSpec = specInfo.stream().filter(d -> d.getId() != null).collect(Collectors.toList());
List<Integer> inputMallSkuIds = updateGoodsSpec.stream().map(GoodsProdSpecVO::getId).collect(Collectors.toList());
// 1.2从数据库获取该商品对应绑定的skuId的集合
List<MallProdInfoDO> mallProSkuInfoList = goodsInfoDao.getMallProSkuInfo(goodsAddVO.getId());
List<Integer> dbMallSkuIds = mallProSkuInfoList.stream().map(MallProdInfoDO::getId).collect(Collectors.toList());
// 对比数据库id如果不在就删除
List<Integer> delIds = dbMallSkuIds.stream().filter(id -> !inputMallSkuIds.contains(id)).collect(Collectors.toList());
if (delIds.size() != 0) {
// 先删除商品绑定sku下的spec信息
goodsInfoDao.batchUpdateMallProSpec(delIds, goodsAddVO.getId());
goodsInfoDao.batchUpdateMallProductSku(delIds);
}
// 修改商品绑定的sku信息
List<MallProdInfoDO> mallProdSkuInfoList = updateGoodsSpec.stream().map(d -> {
MallProdInfoDO mallProdInfoDO = new MallProdInfoDO();
mallProdInfoDO.setId(d.getId()).setProdSkuId(d.getSkuId())
.setCategoriesId(d.getCategoryId()).setProdSkuSpecName(d.getGoodsSpecName())
.setChooseType(d.getChooseType()).setSkuUnitId(d.getSkuUnitId()).setMust(d.getMust());
return mallProdInfoDO;
}).collect(Collectors.toList());
// 1.3批量修改sku的信息
goodsInfoDao.batchUpdateMallProdSkuInfo(mallProdSkuInfoList);
// 1.4对新的sku进行操作
List<GoodsProdSpecVO> list = specInfo.stream().filter(d -> d.getId() == null).collect(Collectors.toList());
productSkuSpecOperation(new GoodsInfo(goodsAddVO.getId()), list);
// 获取商品对应的skuId
List<Integer> mallSkuIds = goodsAddVO.getProductSpec().stream().filter(d -> d.getId() != null).map(GoodsProdSpecVO::getId).collect(Collectors.toList());
if (mallSkuIds.size() > 0) {
// 根据这些id查出下面对应的规格信息
List<MallProdSkuInfoSpecDO> mallProdSkuInfoSpecList = goodsInfoDao.listMallProdSpecInfo(mallSkuIds);
// 分组
Map<Integer, List<MallProdSkuInfoSpecDO>> dbSpecMap = mallProdSkuInfoSpecList.stream().collect(Collectors.groupingBy(MallProdSkuInfoSpecDO::getMallProdSkuInfoId));
for (GoodsProdSpecVO goodsSpecVO : updateGoodsSpec) {
// 分组后的每一条商品绑定的规格信息
List<MallProdSkuInfoSpecDO> dbMallProdSkuSpecList = dbSpecMap.get(goodsSpecVO.getId());
Set<Integer> inputMallSpecIds = goodsSpecVO.getSpecIds().stream().map(MallProductSpecVO::getId).filter(Objects::nonNull).collect(Collectors.toSet());
List<Integer> delSpecId = dbMallProdSkuSpecList.stream().map(MallProdSkuInfoSpecDO::getId).filter(id -> !inputMallSpecIds.contains(id)).collect(Collectors.toList());
if (delSpecId.size() != 0) {
// 删除多余的spec信息
goodsInfoDao.batchUpdateMallProdSpec(delSpecId);
}
// 新增spec的信息
for (MallProductSpecVO mallProductSpecVO : goodsSpecVO.getSpecIds()) {
if (mallProductSpecVO.getId() == null) {
MallProdSkuInfoSpecDO mallProdSkuInfoSpecDO = new MallProdSkuInfoSpecDO()
.setProductSpecId(mallProductSpecVO.getMallSpecId())
.setMallProdSkuInfoId(goodsSpecVO.getId())
.setGoodsInfoId(goodsAddVO.getId());
// 插入数据库商品对应的规格信息
goodsInfoDao.insertMallProdSkuInfoSpec(mallProdSkuInfoSpecDO);
}
}
}
}
// 2、对自定义的sku进行操作
List<GoodsProdSpecVO> zdySpecInfo = goodsAddVO.getProductSpec().stream().filter(spec -> spec.getFlag().equals(1)).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(zdySpecInfo)) {
updateCustomize(zdySpecInfo, goodsAddVO.getId());
}
}
}
@Transactional(rollbackFor = Exception.class)
public void updateCustomize(List<GoodsProdSpecVO> zdySpecInfo, Integer id) {
@Transactional(rollbackFor = Exception.class)
public void updateCustomize(List<GoodsProdSpecVO> zdySpecInfo, Integer id) {
// 先获取自定义的sku及规格(原来有的)
List<GoodsProdSpecVO> zdySpec = zdySpecInfo.stream().filter(d -> d.getId() != null).collect(Collectors.toList());
if (!CollectionUtils.isEmpty(zdySpec)) {
// 根据获取到的自定义sku及规格进行操作
List<MallProdInfoDO> zdySpecList = zdySpec.stream().map(d -> {
// 构建商品对应的sku信息
ProductSkuDO productSkuDO = new ProductSkuDO().setId(d.getSkuId()).setCategoriesId(d.getCategoryId()).setProductName(d.getProductName());
productDao.updateProductSku(productSkuDO);
return new MallProdInfoDO(d).setId(d.getId()).setProdSkuId(d.getSkuId());
}).collect(Collectors.toList());
// 批量修改sku的信息
goodsInfoDao.batchUpdateMallProdSkuInfo(zdySpecList);
}
for (GoodsProdSpecVO goodsSpecVO : zdySpec) {
// 【1】获取输入的自定义规格信息// id不为空则修改
List<ProductSpecVO> customizeInfoList = goodsSpecVO.getCustomizeInfo().stream().filter(d -> d.getId() != null).collect(Collectors.toList());
for (ProductSpecVO d : customizeInfoList) {
// ①修改价格配置
ProductSpecCPQVO productSpecCPQVO = d.getProductSpecCPQVO();
// 删除所有的随后在新增
productDao.removeProductSpecCPQ(productSpecCPQVO);
productSkuService.insertSpecPrice(productSpecCPQVO);
// ②在修改自定义的数据
productDao.updateProductSpec(new ProductSpecDO(d));
}
// 【2】删除多余的自定义规格
if (!CollectionUtils.isEmpty(goodsSpecVO.getDelProductSpecId())) {
// 批量查出spec的数据
List<MallProdSkuInfoSpecDO> prodSkuInfoSpecList = productDao.getProductSpecByIds(goodsSpecVO.getDelProductSpecId());
for (MallProdSkuInfoSpecDO mallProdSkuInfoSpecDO : prodSkuInfoSpecList) {
productDao.removeProductSpec(mallProdSkuInfoSpecDO.getProductSpecId());
}
goodsInfoDao.batchUpdateMallProdSpec(goodsSpecVO.getDelProductSpecId());
}
// 【3】新增最新的自定义规格
List<ProductSpecVO> collect = goodsSpecVO.getCustomizeInfo().stream().filter(d -> d.getId() == null).collect(Collectors.toList());
for (ProductSpecVO param : collect) {
ProductSpecDO productSpecDO = new ProductSpecDO(param);
// 新增产品sku
productDao.insertProductSpec(productSpecDO);
// 批量配置价格信息
ProductSpecCPQVO productSpecCPQVO = param.getProductSpecCPQVO();
productSpecCPQVO.setProductSpecId(productSpecDO.getId());
productSkuService.insertSpecPrice(productSpecCPQVO);
// 构建商品对应的规格信息
MallProdSkuInfoSpecDO mallProdSkuInfoSpecDO = new MallProdSkuInfoSpecDO()
.setProductSpecId(productSpecDO.getId())
.setMallProdSkuInfoId(goodsSpecVO.getId())
.setGoodsInfoId(id);
// 插入数据库商品对应的规格信息
goodsInfoDao.insertMallProdSkuInfoSpec(mallProdSkuInfoSpecDO);
}
}
// 2.2 新增新的自定义规格信息
List<GoodsProdSpecVO> newZdySpec = zdySpecInfo.stream().filter(d -> d.getId() == null).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(newZdySpec)) {
productSkuSpecOperation(new GoodsInfo(id), newZdySpec);
// 先获取自定义的sku及规格(原来有的)
List<GoodsProdSpecVO> zdySpec =
zdySpecInfo.stream().filter(d -> d.getId() != null).collect(Collectors.toList());
if (!CollectionUtils.isEmpty(zdySpec)) {
// 根据获取到的自定义sku及规格进行操作
List<MallProdInfoDO> zdySpecList =
zdySpec.stream()
.map(
d -> {
// 构建商品对应的sku信息
ProductSkuDO productSkuDO =
new ProductSkuDO()
.setId(d.getSkuId())
.setCategoriesId(d.getCategoryId())
.setProductName(d.getProductName());
productDao.updateProductSku(productSkuDO);
return new MallProdInfoDO(d).setId(d.getId()).setProdSkuId(d.getSkuId());
})
.collect(Collectors.toList());
// 批量修改sku的信息
goodsInfoDao.batchUpdateMallProdSkuInfo(zdySpecList);
}
for (GoodsProdSpecVO goodsSpecVO : zdySpec) {
// 【1】获取输入的自定义规格信息// id不为空则修改
List<ProductSpecVO> customizeInfoList =
goodsSpecVO.getCustomizeInfo().stream()
.filter(d -> d.getId() != null)
.collect(Collectors.toList());
for (ProductSpecVO d : customizeInfoList) {
// ①修改价格配置
ProductSpecCPQVO productSpecCPQVO = d.getProductSpecCPQVO();
// 删除所有的随后在新增
productDao.removeProductSpecCPQ(productSpecCPQVO);
productSkuService.insertSpecPrice(productSpecCPQVO);
// ②在修改自定义的数据
productDao.updateProductSpec(new ProductSpecDO(d));
}
// 【2】删除多余的自定义规格
if (!CollectionUtils.isEmpty(goodsSpecVO.getDelProductSpecId())) {
// 批量查出spec的数据
List<MallProdSkuInfoSpecDO> prodSkuInfoSpecList =
productDao.getProductSpecByIds(goodsSpecVO.getDelProductSpecId());
for (MallProdSkuInfoSpecDO mallProdSkuInfoSpecDO : prodSkuInfoSpecList) {
productDao.removeProductSpec(mallProdSkuInfoSpecDO.getProductSpecId());
}
goodsInfoDao.batchUpdateMallProdSpec(goodsSpecVO.getDelProductSpecId());
}
// 【3】新增最新的自定义规格
List<ProductSpecVO> collect =
goodsSpecVO.getCustomizeInfo().stream()
.filter(d -> d.getId() == null)
.collect(Collectors.toList());
for (ProductSpecVO param : collect) {
ProductSpecDO productSpecDO = new ProductSpecDO(param);
// 新增产品sku
productDao.insertProductSpec(productSpecDO);
// 批量配置价格信息
ProductSpecCPQVO productSpecCPQVO = param.getProductSpecCPQVO();
productSpecCPQVO.setProductSpecId(productSpecDO.getId());
productSkuService.insertSpecPrice(productSpecCPQVO);
// 构建商品对应的规格信息
MallProdSkuInfoSpecDO mallProdSkuInfoSpecDO =
new MallProdSkuInfoSpecDO()
.setProductSpecId(productSpecDO.getId())
.setMallProdSkuInfoId(goodsSpecVO.getId())
.setGoodsInfoId(id);
// 插入数据库商品对应的规格信息
goodsInfoDao.insertMallProdSkuInfoSpec(mallProdSkuInfoSpecDO);
}
}
// 2.2 新增新的自定义规格信息
List<GoodsProdSpecVO> newZdySpec =
zdySpecInfo.stream().filter(d -> d.getId() == null).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(newZdySpec)) {
productSkuSpecOperation(new GoodsInfo(id), newZdySpec);
}
}
@Transactional(rollbackFor = Exception.class)
public void updateOtherService(GoodsAddVO goodsAddVO) {
// 删除其他服务
goodsInfoDao.deleteGoodsServiceByGoodsId(goodsAddVO.getId());
// 插入其他服务
if (!CollectionUtils.isEmpty(goodsAddVO.getOtherService())) {
List<Integer> other = goodsAddVO.getOtherService();
List<GoodsServiceDO> otherList = other.stream().map(d -> {
GoodsServiceDO goodsServiceDO = new GoodsServiceDO();
goodsServiceDO.setGoodsInfoId(goodsAddVO.getId());
goodsServiceDO.setSaleServiceId(d);
return goodsServiceDO;
}).collect(Collectors.toList());
goodsInfoDao.insertGoodsService(otherList);
}
@Transactional(rollbackFor = Exception.class)
public void updateOtherService(GoodsAddVO goodsAddVO) {
// 删除其他服务
goodsInfoDao.deleteGoodsServiceByGoodsId(goodsAddVO.getId());
// 插入其他服务
if (!CollectionUtils.isEmpty(goodsAddVO.getOtherService())) {
List<Integer> other = goodsAddVO.getOtherService();
List<GoodsServiceDO> otherList =
other.stream()
.map(
d -> {
GoodsServiceDO goodsServiceDO = new GoodsServiceDO();
goodsServiceDO.setGoodsInfoId(goodsAddVO.getId());
goodsServiceDO.setSaleServiceId(d);
return goodsServiceDO;
})
.collect(Collectors.toList());
goodsInfoDao.insertGoodsService(otherList);
}
}
@Transactional(rollbackFor = Exception.class)
public void updateImageInfo(GoodsAddVO goodsAddVO) {
Set<Integer> imgIds = goodsAddVO.getImages().stream().map(GoodsImgVO::getId).filter(Objects::nonNull).collect(Collectors.toSet());
List<GoodsImgDO> dbImgList = goodsInfoDao.listGoodsInfoByGoodsId(goodsAddVO.getId());
List<Integer> deleteIds = dbImgList.stream().map(GoodsImgDO::getId).filter(id -> !imgIds.contains(id)).collect(Collectors.toList());
if (deleteIds.size() != 0) {
// 删除多余的图片
goodsInfoDao.deleteImgByIds(deleteIds);
}
// 新增图片
List<GoodsImgDO> imgDOList = goodsAddVO.getImages().stream().filter(d -> d.getId() == null).map(d -> {
GoodsImgDO goodsImgDO = new GoodsImgDO(d);
goodsImgDO.setGoodsInfoId(goodsAddVO.getId());
return goodsImgDO;
}).collect(Collectors.toList());
if (imgDOList.size() != 0) {
goodsInfoDao.insertGoodsImgInfo(imgDOList);
}
// 删除视频
goodsInfoDao.deleteGoodsVideoById(goodsAddVO.getId());
// 插入视频
if (goodsAddVO.getGoodsVideo() != null) {
GoodsVideoDO goodsVideoDO = new GoodsVideoDO();
goodsVideoDO.setGoodsInfoId(goodsAddVO.getId());
goodsVideoDO.setVideoUrl(goodsAddVO.getGoodsVideo());
goodsInfoDao.insertVideoInfo(goodsVideoDO);
}
@Transactional(rollbackFor = Exception.class)
public void updateImageInfo(GoodsAddVO goodsAddVO) {
Set<Integer> imgIds =
goodsAddVO.getImages().stream()
.map(GoodsImgVO::getId)
.filter(Objects::nonNull)
.collect(Collectors.toSet());
List<GoodsImgDO> dbImgList = goodsInfoDao.listGoodsInfoByGoodsId(goodsAddVO.getId());
List<Integer> deleteIds =
dbImgList.stream()
.map(GoodsImgDO::getId)
.filter(id -> !imgIds.contains(id))
.collect(Collectors.toList());
if (deleteIds.size() != 0) {
// 删除多余的图片
goodsInfoDao.deleteImgByIds(deleteIds);
}
// 新增图片
List<GoodsImgDO> imgDOList =
goodsAddVO.getImages().stream()
.filter(d -> d.getId() == null)
.map(
d -> {
GoodsImgDO goodsImgDO = new GoodsImgDO(d);
goodsImgDO.setGoodsInfoId(goodsAddVO.getId());
return goodsImgDO;
})
.collect(Collectors.toList());
if (imgDOList.size() != 0) {
goodsInfoDao.insertGoodsImgInfo(imgDOList);
}
// 删除视频
goodsInfoDao.deleteGoodsVideoById(goodsAddVO.getId());
// 插入视频
if (goodsAddVO.getGoodsVideo() != null) {
GoodsVideoDO goodsVideoDO = new GoodsVideoDO();
goodsVideoDO.setGoodsInfoId(goodsAddVO.getId());
goodsVideoDO.setVideoUrl(goodsAddVO.getGoodsVideo());
goodsInfoDao.insertVideoInfo(goodsVideoDO);
}
}
@Transactional(rollbackFor = Exception.class)
public void updateGoodsDetail(GoodsAddVO goodsAddVO) {
GoodsDetailDO goodsDetailDO =
new GoodsDetailDO(goodsAddVO.getGoodsDetailVO()).setGoodsInfoId(goodsAddVO.getId());
// 商品详情修改
goodsInfoDao.updateGoodsDetail(goodsDetailDO);
}
@Transactional(rollbackFor = Exception.class)
public void updateGoodsDetail(GoodsAddVO goodsAddVO) {
GoodsDetailDO goodsDetailDO = new GoodsDetailDO(goodsAddVO.getGoodsDetailVO()).setGoodsInfoId(goodsAddVO.getId());
// 商品详情修改
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;
}
@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> mallProdSkuInfoList = goodsInfoDao.getMallProSkuInfo(goodsInfoId);
List<GoodsSpecDTO> list = mallProdSkuInfoList.stream().map(MallProdInfoDO::buildGoodsSpecDTO).collect(Collectors.toList());
// 获取规格来源详细信息
List<MallProdSkuInfoSpecDO> mallProdSkuInfoSpec = goodsInfoDao.getMallProSkuInfoSpec(goodsInfoId);
// 根据id查询出规格的具体信息
list = list.stream().peek(d -> {
List<MallProductSpecDTO> specList = new ArrayList<>();
for (MallProdSkuInfoSpecDO e : mallProdSkuInfoSpec) {
if (d.getId().equals(e.getMallProdSkuInfoId())) {
// 构建规格对象
ProductSpecDO productSpecDO = e.getProductSpecDO();
MallProductSpecDTO productSpecDTO = productSpecDO.buildMallProductSpecDTO();
productSpecDTO.setProductSkuId(d.getSkuId());
productSpecDTO.setId(e.getId());
productSpecDTO.setProductSpec(e.getProductSpecId());
if (d.getFlag().equals(1)) {
private List<GoodsSpecDTO> getProductSpecInfo(Integer goodsInfoId) {
// 获取商品对应绑定sku的信息
List<MallProdInfoDO> mallProdSkuInfoList = goodsInfoDao.getMallProSkuInfo(goodsInfoId);
List<GoodsSpecDTO> list =
mallProdSkuInfoList.stream()
.map(MallProdInfoDO::buildGoodsSpecDTO)
.collect(Collectors.toList());
// 获取规格来源详细信息
List<MallProdSkuInfoSpecDO> mallProdSkuInfoSpec =
goodsInfoDao.getMallProSkuInfoSpec(goodsInfoId);
// 根据id查询出规格的具体信息
list =
list.stream()
.peek(
d -> {
List<MallProductSpecDTO> specList = new ArrayList<>();
for (MallProdSkuInfoSpecDO e : mallProdSkuInfoSpec) {
if (d.getId().equals(e.getMallProdSkuInfoId())) {
// 构建规格对象
ProductSpecDO productSpecDO = e.getProductSpecDO();
MallProductSpecDTO productSpecDTO = productSpecDO.buildMallProductSpecDTO();
productSpecDTO.setProductSkuId(d.getSkuId());
productSpecDTO.setId(e.getId());
productSpecDTO.setProductSpec(e.getProductSpecId());
if (d.getFlag().equals(1)) {
// 获取自定义sku下规格的价格配置信息
ProductSpecCPQVO productSpecCPQVO = new ProductSpecCPQVO();
productSpecCPQVO.setProductSpecId(e.getProductSpecId());
List<ProductSpecPriceDO> productSpecPrice = productDao.getProductSpecPrice(productSpecCPQVO);
List<SpecPriceVO> collect = productSpecPrice.stream().map(m -> {
SpecPriceVO specPriceVO = new SpecPriceVO();
specPriceVO.setId(m.getId());
specPriceVO.setPrice(m.getPrice());
specPriceVO.setCooperationTag(m.getCooperationTag());
return specPriceVO;
}).collect(Collectors.toList());
List<ProductSpecPriceDO> productSpecPrice =
productDao.getProductSpecPrice(productSpecCPQVO);
List<SpecPriceVO> collect =
productSpecPrice.stream()
.map(
m -> {
SpecPriceVO specPriceVO = new SpecPriceVO();
specPriceVO.setId(m.getId());
specPriceVO.setPrice(m.getPrice());
specPriceVO.setCooperationTag(m.getCooperationTag());
return specPriceVO;
})
.collect(Collectors.toList());
productSpecCPQVO.setSpecPrice(collect);
productSpecDTO.setProductSpecCPQVO(productSpecCPQVO);
}
specList.add(productSpecDTO);
}
specList.add(productSpecDTO);
}
}
d.setProductSpecList(specList);
}).collect(Collectors.toList());
return list;
}
}
d.setProductSpecList(specList);
})
.collect(Collectors.toList());
return list;
}
private List<GoodsOtherServiceDTO> getOtherServiceInfo(Integer goodsInfoId) {
List<GoodsServiceDO> goodsServiceDO = goodsInfoDao.listGoodsServiceByGoodsId(goodsInfoId);
return goodsServiceDO.stream().map(GoodsServiceDO::buildGoodsOtherServiceDTO).collect(Collectors.toList());
}
public 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();
}
public 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());
}
public List<GoodsImgDTO> getGoodsImageInfo(Integer goodsInfoId) {
List<GoodsImgDO> goodsImgList = goodsInfoDao.listGoodsInfoByGoodsId(goodsInfoId);
return goodsImgList.stream().map(GoodsImgDO::buildGoodsImgDTO).collect(Collectors.toList());
}
@Override
public ResultBody getSaleServiceInfoToList() {
List<SaleServiceDO> list = goodsInfoDao.listSaleServiceInfo();
List<SaleServiceDTO> serviceDTOList =
list.stream().map(d -> d.buildSaleServiceDTO()).collect(Collectors.toList());
return ResultBody.success(serviceDTOList);
}
@Override
public ResultBody getSkuUnit() {
List<SkuUnitDO> skuUnitList = goodsInfoDao.getSkuUnit();
List<SkuUnitDTO> list = skuUnitList.stream().map(SkuUnitDO::buildSkuUnitDTO).collect(Collectors.toList());
return ResultBody.success(list);
}
@Override
public ResultBody getSkuUnit() {
List<SkuUnitDO> skuUnitList = goodsInfoDao.getSkuUnit();
List<SkuUnitDTO> list =
skuUnitList.stream().map(SkuUnitDO::buildSkuUnitDTO).collect(Collectors.toList());
return ResultBody.success(list);
}
/**
* 根据商品id,商品规格id查询并填充相关信息
*
* @param param
* @return
*/
@Override
public List<MallGoodsShopCarDTO> fillGoodsInfo(List<MallGoodsShopCarDTO> param) {
Set<Integer> goodsIds = new HashSet<>();
//获取商品id
for (MallGoodsShopCarDTO mallGoodsShopCarDTO : param) {
goodsIds.add(mallGoodsShopCarDTO.getGoodsInfoId());
}
//查询出商品信息后进行填充
List<GoodsInfo> goodsInfoDOList = goodsInfoDao.listSimpleGoodsInfoByIds(goodsIds);
for (MallGoodsShopCarDTO mallGoodsShopCarDTO : param) {
for (GoodsInfo goodsInfo : goodsInfoDOList) {
if (mallGoodsShopCarDTO.getGoodsInfoId().toString().equals(goodsInfo.getId().toString())) {
mallGoodsShopCarDTO.setDirectoryId(goodsInfo.getDirectoryId());
mallGoodsShopCarDTO.setShelfStatus(goodsInfo.getShelfStatus());
mallGoodsShopCarDTO.setGoodsName(goodsInfo.getGoodsName());
mallGoodsShopCarDTO.setMainImg(goodsInfo.getMainImg());
break;
}
}
/**
* 根据商品id,商品规格id查询并填充相关信息
*
* @param param
* @return
*/
@Override
public List<MallGoodsShopCarDTO> fillGoodsInfo(List<MallGoodsShopCarDTO> param) {
Set<Integer> goodsIds = new HashSet<>();
// 获取商品id
for (MallGoodsShopCarDTO mallGoodsShopCarDTO : param) {
goodsIds.add(mallGoodsShopCarDTO.getGoodsInfoId());
}
// 查询出商品信息后进行填充
List<GoodsInfo> goodsInfoDOList = goodsInfoDao.listSimpleGoodsInfoByIds(goodsIds);
for (MallGoodsShopCarDTO mallGoodsShopCarDTO : param) {
for (GoodsInfo goodsInfo : goodsInfoDOList) {
if (mallGoodsShopCarDTO.getGoodsInfoId().toString().equals(goodsInfo.getId().toString())) {
mallGoodsShopCarDTO.setDirectoryId(goodsInfo.getDirectoryId());
mallGoodsShopCarDTO.setShelfStatus(goodsInfo.getShelfStatus());
mallGoodsShopCarDTO.setGoodsName(goodsInfo.getGoodsName());
mallGoodsShopCarDTO.setMainImg(goodsInfo.getMainImg());
break;
}
}
}
//对产品和行业的规格id进行分类
Set<Integer> prodIds = new HashSet<>();
Set<Integer> indstIds = new HashSet<>();
for (MallGoodsShopCarDTO mallGoodsShopCarDTO : param) {
if (mallGoodsShopCarDTO.getDirectoryId().equals(1)) {
for (MallSkuInfoSpecDTO mallSkuInfoSpecDTO : mallGoodsShopCarDTO.getSkuList()) {
prodIds.add(mallSkuInfoSpecDTO.getMallSkuInfoSpecId());
}
} else if (mallGoodsShopCarDTO.getDirectoryId().equals(2)) {
for (MallSkuInfoSpecDTO mallSkuInfoSpecDTO : mallGoodsShopCarDTO.getSkuList()) {
indstIds.add(mallSkuInfoSpecDTO.getMallSkuInfoSpecId());
}
}
}
//根据规格id查找规格信息
List<MallGoodsSpecInfoDO> goodsSpecInfoDOList = new ArrayList<>();
if (!CollectionUtils.isEmpty(prodIds)) {
List<MallGoodsSpecInfoDO> goodsProdSpecInfoDOList = goodsInfoDao.listProdSpecInfo(prodIds);
goodsSpecInfoDOList.addAll(goodsProdSpecInfoDOList);
// 对产品和行业的规格id进行分类
Set<Integer> prodIds = new HashSet<>();
Set<Integer> indstIds = new HashSet<>();
for (MallGoodsShopCarDTO mallGoodsShopCarDTO : param) {
if (mallGoodsShopCarDTO.getDirectoryId().equals(1)) {
for (MallSkuInfoSpecDTO mallSkuInfoSpecDTO : mallGoodsShopCarDTO.getSkuList()) {
prodIds.add(mallSkuInfoSpecDTO.getMallSkuInfoSpecId());
}
if (!CollectionUtils.isEmpty(indstIds)) {
List<MallGoodsSpecInfoDO> goodsIndstSpecInfoDOList = goodsInfoDao.listIndstSpecInfo(indstIds);
goodsSpecInfoDOList.addAll(goodsIndstSpecInfoDOList);
} else if (mallGoodsShopCarDTO.getDirectoryId().equals(2)) {
for (MallSkuInfoSpecDTO mallSkuInfoSpecDTO : mallGoodsShopCarDTO.getSkuList()) {
indstIds.add(mallSkuInfoSpecDTO.getMallSkuInfoSpecId());
}
//根据查出来的sku,填充到MallGoodsShopCarDTO里面
for (MallGoodsShopCarDTO mallGoodsShopCarDTO : param) {
for (MallGoodsSpecInfoDO mallGoodsSpecInfoDO : goodsSpecInfoDOList) {
//找到对应商品
if (mallGoodsShopCarDTO.getGoodsInfoId().toString().equals(mallGoodsSpecInfoDO.getId().toString())
&& mallGoodsShopCarDTO.getDirectoryId().toString().equals(mallGoodsSpecInfoDO.getDirectoryId().toString())) {
for (SkuSpecDO skuSpecDO : mallGoodsSpecInfoDO.getSkuSpecDOList()) {
for (MallSkuInfoSpecDTO mallSkuInfoSpecDTO : mallGoodsShopCarDTO.getSkuList()) {
//根据对应规格进行填充
if (skuSpecDO.getId().toString().equals(mallSkuInfoSpecDTO.getMallSkuInfoSpecId().toString())) {
mallSkuInfoSpecDTO.setSpecName(skuSpecDO.getSpecName());
mallSkuInfoSpecDTO.setDeleted(skuSpecDO.getSkuSpecDeleted());
mallSkuInfoSpecDTO.setValid(skuSpecDO.getSkuSpecDeleted() == 0 && skuSpecDO.getSpecDeleted() == 0);
break;
}
}
}
break;
}
}
}
// 根据规格id查找规格信息
List<MallGoodsSpecInfoDO> goodsSpecInfoDOList = new ArrayList<>();
if (!CollectionUtils.isEmpty(prodIds)) {
List<MallGoodsSpecInfoDO> goodsProdSpecInfoDOList = goodsInfoDao.listProdSpecInfo(prodIds);
goodsSpecInfoDOList.addAll(goodsProdSpecInfoDOList);
}
if (!CollectionUtils.isEmpty(indstIds)) {
List<MallGoodsSpecInfoDO> goodsIndstSpecInfoDOList = goodsInfoDao.listIndstSpecInfo(indstIds);
goodsSpecInfoDOList.addAll(goodsIndstSpecInfoDOList);
}
// 根据查出来的sku,填充到MallGoodsShopCarDTO里面
for (MallGoodsShopCarDTO mallGoodsShopCarDTO : param) {
for (MallGoodsSpecInfoDO mallGoodsSpecInfoDO : goodsSpecInfoDOList) {
// 找到对应商品
if (mallGoodsShopCarDTO
.getGoodsInfoId()
.toString()
.equals(mallGoodsSpecInfoDO.getId().toString())
&& mallGoodsShopCarDTO
.getDirectoryId()
.toString()
.equals(mallGoodsSpecInfoDO.getDirectoryId().toString())) {
for (SkuSpecDO skuSpecDO : mallGoodsSpecInfoDO.getSkuSpecDOList()) {
for (MallSkuInfoSpecDTO mallSkuInfoSpecDTO : mallGoodsShopCarDTO.getSkuList()) {
// 根据对应规格进行填充
if (skuSpecDO
.getId()
.toString()
.equals(mallSkuInfoSpecDTO.getMallSkuInfoSpecId().toString())) {
mallSkuInfoSpecDTO.setSpecName(skuSpecDO.getSpecName());
mallSkuInfoSpecDTO.setDeleted(skuSpecDO.getSkuSpecDeleted());
mallSkuInfoSpecDTO.setValid(
skuSpecDO.getSkuSpecDeleted() == 0 && skuSpecDO.getSpecDeleted() == 0);
break;
}
}
}
break;
}
return param;
}
@Override
public List<MallProductSpecPriceDTO> feignListProductSpecPrice(ProductSpecPriceQO productSpecPriceQO) {
Set<Integer> ids = new HashSet<>(productSpecPriceQO.getProductSpecIds());
List<MallProductSpecPriceDTO> mallProductSpecPriceDTOS = productSpecPriceQO.getProductSpecIds().stream().map(d -> {
MallProductSpecPriceDTO mallProductSpecPriceDTO = new MallProductSpecPriceDTO();
mallProductSpecPriceDTO.setProductSpecId(d);
return mallProductSpecPriceDTO;
}).collect(Collectors.toList());
//分别找出渠道价格和市场价格
List<ProductSpecPriceDO> productSpecPriceDOS = productDao.listProductSpecPrice(productSpecPriceQO.getChannelClass(), ids);
List<ProductSpecPriceDO> productSpecPriceDOS1 = productDao.listProductSpecPrice(0, ids);
//设置合作价格
for (ProductSpecPriceDO productSpecPriceDO : productSpecPriceDOS) {
for (MallProductSpecPriceDTO mallProductSpecPriceDTO : mallProductSpecPriceDTOS) {
if (mallProductSpecPriceDTO.getProductSpecId().equals(productSpecPriceDO.getProductSpecId())) {
mallProductSpecPriceDTO.setOpPrice(productSpecPriceDO.getPrice());
break;
}
}
}
}
return param;
}
@Override
public List<MallProductSpecPriceDTO> feignListProductSpecPrice(
ProductSpecPriceQO productSpecPriceQO) {
Set<Integer> ids = new HashSet<>(productSpecPriceQO.getProductSpecIds());
List<MallProductSpecPriceDTO> mallProductSpecPriceDTOS =
productSpecPriceQO.getProductSpecIds().stream()
.map(
d -> {
MallProductSpecPriceDTO mallProductSpecPriceDTO = new MallProductSpecPriceDTO();
mallProductSpecPriceDTO.setProductSpecId(d);
return mallProductSpecPriceDTO;
})
.collect(Collectors.toList());
// 分别找出渠道价格和市场价格
List<ProductSpecPriceDO> productSpecPriceDOS =
productDao.listProductSpecPrice(productSpecPriceQO.getChannelClass(), ids);
List<ProductSpecPriceDO> productSpecPriceDOS1 = productDao.listProductSpecPrice(0, ids);
// 设置合作价格
for (ProductSpecPriceDO productSpecPriceDO : productSpecPriceDOS) {
for (MallProductSpecPriceDTO mallProductSpecPriceDTO : mallProductSpecPriceDTOS) {
if (mallProductSpecPriceDTO
.getProductSpecId()
.equals(productSpecPriceDO.getProductSpecId())) {
mallProductSpecPriceDTO.setOpPrice(productSpecPriceDO.getPrice());
break;
}
//设置市场价格
for (ProductSpecPriceDO productSpecPriceDO : productSpecPriceDOS1) {
for (MallProductSpecPriceDTO mallProductSpecPriceDTO : mallProductSpecPriceDTOS) {
if (mallProductSpecPriceDTO.getProductSpecId().equals(productSpecPriceDO.getProductSpecId())) {
mallProductSpecPriceDTO.setMkPrice(productSpecPriceDO.getPrice());
break;
}
}
}
}
// 设置市场价格
for (ProductSpecPriceDO productSpecPriceDO : productSpecPriceDOS1) {
for (MallProductSpecPriceDTO mallProductSpecPriceDTO : mallProductSpecPriceDTOS) {
if (mallProductSpecPriceDTO
.getProductSpecId()
.equals(productSpecPriceDO.getProductSpecId())) {
mallProductSpecPriceDTO.setMkPrice(productSpecPriceDO.getPrice());
break;
}
return mallProductSpecPriceDTOS;
}
}
return mallProductSpecPriceDTOS;
}
@Override
public ProductSpecPriceDTO feignGetUnitPriceByTag(Integer id, Integer tagId) {
ProductSpecPriceDTO price = productDao.feignGetUnitPrice(id, tagId);
return price;
@Override
public ProductSpecPriceDTO feignGetUnitPriceByTag(Integer id, Integer tagId) {
ProductSpecPriceDTO price = productDao.feignGetUnitPrice(id, tagId);
return price;
}
@Override
public List<OrderGoodsProdDTO> feignListProdGoodsSkuInfo(
MallOrderGoodsInfoQO mallOrderGoodsInfoQO) {
// 查询渠道等级对应的商品价格
Set<Integer> prodSkuSpecIds =
productDao.listProductSpecIds(mallOrderGoodsInfoQO.getMallProdSkuSpecIds());
List<ProductSpecPriceDO> productSpecPriceDOS =
productDao.listProductSpecPrice(mallOrderGoodsInfoQO.getCooperationTagId(), prodSkuSpecIds);
// 查询商品信息
List<OrderGoodsProdDTO> orderGoodsProdDTOList =
productDao.listProdGoodsSkuInfo(mallOrderGoodsInfoQO);
if (!CollectionUtils.isEmpty(productSpecPriceDOS)) {
// 填充渠道价格
this.fillOrderGoodsProdPrice(orderGoodsProdDTOList, productSpecPriceDOS, prodSkuSpecIds);
}
// 商品没有设置渠道价格的,按照市场价设置
if (!CollectionUtils.isEmpty(prodSkuSpecIds)) {
// 查询市场价格,tagInfoId为0
List<ProductSpecPriceDO> prodMarketPrice = productDao.listProductSpecPrice(0, prodSkuSpecIds);
// 填充市场价格
this.fillOrderGoodsProdPrice(orderGoodsProdDTOList, prodMarketPrice, prodSkuSpecIds);
}
// 还需配置商品规格金额, 单个商品skuSpecAmount, 全部小sku金额
List<Integer> goodsIds =
orderGoodsProdDTOList.stream()
.map(OrderGoodsProdDTO::getGoodsInfoId)
.collect(Collectors.toList());
// 拼装商品服务
List<GoodsServiceDTO> services =
goodsInfoDao.listGoodsService(goodsIds).stream()
.map(d -> d.buildGoodsServiceDTO())
.collect(Collectors.toList());
Map<Integer, List<GoodsServiceDTO>> mapGoodsService =
org.springframework.util.CollectionUtils.isEmpty(services)
? null
: services.stream().collect(Collectors.groupingBy(GoodsServiceDTO::getGoodsInfoId));
List<OrderGoodsProdDTO> collect =
orderGoodsProdDTOList.stream()
.map(
d -> {
OrderGoodsProdDTO orderGoodsProdDTO = d;
if (mapGoodsService != null && mapGoodsService.containsKey(d.getGoodsInfoId())) {
orderGoodsProdDTO.setServices(mapGoodsService.get(d.getGoodsInfoId()));
}
return orderGoodsProdDTO;
})
.collect(Collectors.toList());
return collect;
}
@Override
public List<OrderGoodsProdDTO> feignListProdGoodsSkuInfo(MallOrderGoodsInfoQO mallOrderGoodsInfoQO) {
//查询渠道等级对应的商品价格
Set<Integer> prodSkuSpecIds = productDao.listProductSpecIds(mallOrderGoodsInfoQO.getMallProdSkuSpecIds());
List<ProductSpecPriceDO> productSpecPriceDOS = productDao.listProductSpecPrice(mallOrderGoodsInfoQO.getCooperationTagId(), prodSkuSpecIds);
//查询商品信息
List<OrderGoodsProdDTO> orderGoodsProdDTOList = productDao.listProdGoodsSkuInfo(mallOrderGoodsInfoQO);
if (!CollectionUtils.isEmpty(productSpecPriceDOS)) {
//填充渠道价格
this.fillOrderGoodsProdPrice(orderGoodsProdDTOList, productSpecPriceDOS, prodSkuSpecIds);
}
//商品没有设置渠道价格的,按照市场价设置
if (!CollectionUtils.isEmpty(prodSkuSpecIds)) {
//查询市场价格,tagInfoId为0
List<ProductSpecPriceDO> prodMarketPrice = productDao.listProductSpecPrice(0, prodSkuSpecIds);
//填充市场价格
this.fillOrderGoodsProdPrice(orderGoodsProdDTOList, prodMarketPrice, prodSkuSpecIds);
}
//还需配置商品规格金额, 单个商品skuSpecAmount, 全部小sku金额
List<Integer> goodsIds = orderGoodsProdDTOList.stream().map(OrderGoodsProdDTO::getGoodsInfoId).collect(Collectors.toList());
// 拼装商品服务
List<GoodsServiceDTO> services = goodsInfoDao.listGoodsService(goodsIds).stream().map(d -> d.buildGoodsServiceDTO()).collect(Collectors.toList());
Map<Integer, List<GoodsServiceDTO>> mapGoodsService = org.springframework.util.CollectionUtils.isEmpty(services) ? null
: services.stream()
.collect(Collectors.groupingBy(GoodsServiceDTO::getGoodsInfoId));
List<OrderGoodsProdDTO> collect = orderGoodsProdDTOList.stream().map(d -> {
OrderGoodsProdDTO orderGoodsProdDTO = d;
if (mapGoodsService != null && mapGoodsService.containsKey(d.getGoodsInfoId())) {
orderGoodsProdDTO.setServices(mapGoodsService.get(d.getGoodsInfoId()));
}
return orderGoodsProdDTO;
}).collect(Collectors.toList());
return collect;
}
/**
* 填充产品规格价格
*
* @param orderGoodsProdDTOList
* @param productSpecPriceDOS
* @param prodSkuSpecIds
* @return
*/
private List<OrderGoodsProdDTO> fillOrderGoodsProdPrice(List<OrderGoodsProdDTO> orderGoodsProdDTOList, List<ProductSpecPriceDO> productSpecPriceDOS, Set<Integer> prodSkuSpecIds) {
for (OrderGoodsProdDTO orderGoodsProdDTO : orderGoodsProdDTOList) {
for (OrderGoodsProdDetailDTO orderGoodsProdDetailDTO : orderGoodsProdDTO.getOrderGoodsProdDetailDTOS()) {
//配置价格
for (ProductSpecPriceDO productSpecPriceDO : productSpecPriceDOS) {
//找到规格对应的价格
if (productSpecPriceDO.getProductSpecId().toString().equals(orderGoodsProdDetailDTO.getProductSpecId().toString())) {
orderGoodsProdDetailDTO.setUnitPrice(productSpecPriceDO.getPrice());
//配置价格后移除,剩余没有配置的
prodSkuSpecIds.removeIf(d -> d.toString().equals(orderGoodsProdDetailDTO.getProductSpecId().toString()));
break;
}
}
}
}
return orderGoodsProdDTOList;
}
@Override
public List<OrderGoodsIndstDTO> feignListIndstGoodsSkuInfo(MallOrderGoodsInfoQO mallOrderGoodsInfoQO) {
//查询商品信息
List<MallGoodsInfoSimpleDO> mallGoodsInfoSimpleDOS = goodsInfoDao.listMallGoodsIndstSimpleInfo(mallOrderGoodsInfoQO.getMallIndstSkuSpecIds());
List<Integer> industrySpecIds = goodsInfoDao.listIndustrySpecIds(mallOrderGoodsInfoQO.getMallIndstSkuSpecIds());
//查询商品价格
List<IndustrySpecPriceDO> industrySpecPriceDOS = industrySpecDao.listIndustrySpecPrice(mallOrderGoodsInfoQO.getCooperationTagId(), industrySpecIds);
//查询商品行业规格对应的产品清单
List<MallGoodsProductDO> mallGoodsProductDOS = goodsInfoDao.listIndustryProductList(industrySpecIds);
//配置商品行业规格价格
this.fillOrderGoodsIndstPrice(mallGoodsInfoSimpleDOS, industrySpecPriceDOS, industrySpecIds);
if (!CollectionUtils.isEmpty(industrySpecIds)) {
//查询商品价格,找出市场价
List<IndustrySpecPriceDO> industryMarketPrice = industrySpecDao.listIndustrySpecPrice(0, industrySpecIds);
this.fillOrderGoodsIndstPrice(mallGoodsInfoSimpleDOS, industryMarketPrice, industrySpecIds);
/**
* 填充产品规格价格
*
* @param orderGoodsProdDTOList
* @param productSpecPriceDOS
* @param prodSkuSpecIds
* @return
*/
private List<OrderGoodsProdDTO> fillOrderGoodsProdPrice(
List<OrderGoodsProdDTO> orderGoodsProdDTOList,
List<ProductSpecPriceDO> productSpecPriceDOS,
Set<Integer> prodSkuSpecIds) {
for (OrderGoodsProdDTO orderGoodsProdDTO : orderGoodsProdDTOList) {
for (OrderGoodsProdDetailDTO orderGoodsProdDetailDTO :
orderGoodsProdDTO.getOrderGoodsProdDetailDTOS()) {
// 配置价格
for (ProductSpecPriceDO productSpecPriceDO : productSpecPriceDOS) {
// 找到规格对应的价格
if (productSpecPriceDO
.getProductSpecId()
.toString()
.equals(orderGoodsProdDetailDTO.getProductSpecId().toString())) {
orderGoodsProdDetailDTO.setUnitPrice(productSpecPriceDO.getPrice());
// 配置价格后移除,剩余没有配置的
prodSkuSpecIds.removeIf(
d -> d.toString().equals(orderGoodsProdDetailDTO.getProductSpecId().toString()));
break;
}
}
//配置产品清单
for (MallGoodsInfoSimpleDO mallGoodsInfoSimpleDO : mallGoodsInfoSimpleDOS) {
for (MallGoodsSpecSimpleDO mallGoodsSpecSimpleDO : mallGoodsInfoSimpleDO.getMallGoodsSpecSimpleDOS()) {
mallGoodsSpecSimpleDO.setMallGoodsProductDOS(new ArrayList<MallGoodsProductDO>());
//从产品清单中拿出对应的方案规格里面
for (MallGoodsProductDO mallGoodsProductDO : mallGoodsProductDOS) {
if (mallGoodsProductDO.getIndustrySpecId().toString().equals(mallGoodsSpecSimpleDO.getIndustrySpecId().toString())) {
mallGoodsSpecSimpleDO.getMallGoodsProductDOS().add(mallGoodsProductDO);
}
}
}
}
}
return orderGoodsProdDTOList;
}
@Override
public List<OrderGoodsIndstDTO> feignListIndstGoodsSkuInfo(
MallOrderGoodsInfoQO mallOrderGoodsInfoQO) {
// 查询商品信息
List<MallGoodsInfoSimpleDO> mallGoodsInfoSimpleDOS =
goodsInfoDao.listMallGoodsIndstSimpleInfo(mallOrderGoodsInfoQO.getMallIndstSkuSpecIds());
List<Integer> industrySpecIds =
goodsInfoDao.listIndustrySpecIds(mallOrderGoodsInfoQO.getMallIndstSkuSpecIds());
// 查询商品价格
List<IndustrySpecPriceDO> industrySpecPriceDOS =
industrySpecDao.listIndustrySpecPrice(
mallOrderGoodsInfoQO.getCooperationTagId(), industrySpecIds);
// 查询商品行业规格对应的产品清单
List<MallGoodsProductDO> mallGoodsProductDOS =
goodsInfoDao.listIndustryProductList(industrySpecIds);
// 配置商品行业规格价格
this.fillOrderGoodsIndstPrice(mallGoodsInfoSimpleDOS, industrySpecPriceDOS, industrySpecIds);
if (!CollectionUtils.isEmpty(industrySpecIds)) {
// 查询商品价格,找出市场价
List<IndustrySpecPriceDO> industryMarketPrice =
industrySpecDao.listIndustrySpecPrice(0, industrySpecIds);
this.fillOrderGoodsIndstPrice(mallGoodsInfoSimpleDOS, industryMarketPrice, industrySpecIds);
}
// 配置产品清单
for (MallGoodsInfoSimpleDO mallGoodsInfoSimpleDO : mallGoodsInfoSimpleDOS) {
for (MallGoodsSpecSimpleDO mallGoodsSpecSimpleDO :
mallGoodsInfoSimpleDO.getMallGoodsSpecSimpleDOS()) {
mallGoodsSpecSimpleDO.setMallGoodsProductDOS(new ArrayList<MallGoodsProductDO>());
// 从产品清单中拿出对应的方案规格里面
for (MallGoodsProductDO mallGoodsProductDO : mallGoodsProductDOS) {
if (mallGoodsProductDO
.getIndustrySpecId()
.toString()
.equals(mallGoodsSpecSimpleDO.getIndustrySpecId().toString())) {
mallGoodsSpecSimpleDO.getMallGoodsProductDOS().add(mallGoodsProductDO);
}
}
//转换对象
List<OrderGoodsIndstDTO> collect = mallGoodsInfoSimpleDOS.stream().map(d -> d.buildOrderGoodsIndstDTO()).collect(Collectors.toList());
// 拼装商品服务
List<Integer> goodsIds = collect.stream().map(OrderGoodsIndstDTO::getGoodsInfoId).collect(Collectors.toList());
List<GoodsServiceDTO> services = goodsInfoDao.listGoodsService(goodsIds).stream().map(d -> d.buildGoodsServiceDTO()).collect(Collectors.toList());
Map<Integer, List<GoodsServiceDTO>> mapGoodsService = org.springframework.util.CollectionUtils.isEmpty(services) ? null
: services.stream()
.collect(Collectors.groupingBy(GoodsServiceDTO::getGoodsInfoId));
List<OrderGoodsIndstDTO> resultList = collect.stream().map(d -> {
OrderGoodsIndstDTO orderGoodsIndstDTO = d;
if (mapGoodsService != null && mapGoodsService.containsKey(d.getGoodsInfoId())) {
orderGoodsIndstDTO.setServices(mapGoodsService.get(d.getGoodsInfoId()));
}
return orderGoodsIndstDTO;
}).collect(Collectors.toList());
return resultList;
}
private List<MallGoodsInfoSimpleDO> fillOrderGoodsIndstPrice(List<MallGoodsInfoSimpleDO> mallGoodsInfoSimpleDOS, List<IndustrySpecPriceDO> industrySpecPriceDOS, List<Integer> industrySpecIds) {
//配置商品行业规格价格
for (MallGoodsInfoSimpleDO mallGoodsInfoSimpleDO : mallGoodsInfoSimpleDOS) {
for (MallGoodsSpecSimpleDO mallGoodsSpecSimpleDO : mallGoodsInfoSimpleDO.getMallGoodsSpecSimpleDOS()) {
//查询规格进行配置
for (IndustrySpecPriceDO industrySpecPriceDO : industrySpecPriceDOS) {
if (mallGoodsSpecSimpleDO.getIndustrySpecId().toString().equals(industrySpecPriceDO.getIndustrySpecId().toString())) {
mallGoodsSpecSimpleDO.setUnitPrice(industrySpecPriceDO.getPrice());
industrySpecIds.removeIf(d -> d.toString().equals(industrySpecPriceDO.getIndustrySpecId().toString()));
break;
}
}
}
}
}
// 转换对象
List<OrderGoodsIndstDTO> collect =
mallGoodsInfoSimpleDOS.stream()
.map(d -> d.buildOrderGoodsIndstDTO())
.collect(Collectors.toList());
// 拼装商品服务
List<Integer> goodsIds =
collect.stream().map(OrderGoodsIndstDTO::getGoodsInfoId).collect(Collectors.toList());
List<GoodsServiceDTO> services =
goodsInfoDao.listGoodsService(goodsIds).stream()
.map(d -> d.buildGoodsServiceDTO())
.collect(Collectors.toList());
Map<Integer, List<GoodsServiceDTO>> mapGoodsService =
org.springframework.util.CollectionUtils.isEmpty(services)
? null
: services.stream().collect(Collectors.groupingBy(GoodsServiceDTO::getGoodsInfoId));
List<OrderGoodsIndstDTO> resultList =
collect.stream()
.map(
d -> {
OrderGoodsIndstDTO orderGoodsIndstDTO = d;
if (mapGoodsService != null && mapGoodsService.containsKey(d.getGoodsInfoId())) {
orderGoodsIndstDTO.setServices(mapGoodsService.get(d.getGoodsInfoId()));
}
return orderGoodsIndstDTO;
})
.collect(Collectors.toList());
return resultList;
}
private List<MallGoodsInfoSimpleDO> fillOrderGoodsIndstPrice(
List<MallGoodsInfoSimpleDO> mallGoodsInfoSimpleDOS,
List<IndustrySpecPriceDO> industrySpecPriceDOS,
List<Integer> industrySpecIds) {
// 配置商品行业规格价格
for (MallGoodsInfoSimpleDO mallGoodsInfoSimpleDO : mallGoodsInfoSimpleDOS) {
for (MallGoodsSpecSimpleDO mallGoodsSpecSimpleDO :
mallGoodsInfoSimpleDO.getMallGoodsSpecSimpleDOS()) {
// 查询规格进行配置
for (IndustrySpecPriceDO industrySpecPriceDO : industrySpecPriceDOS) {
if (mallGoodsSpecSimpleDO
.getIndustrySpecId()
.toString()
.equals(industrySpecPriceDO.getIndustrySpecId().toString())) {
mallGoodsSpecSimpleDO.setUnitPrice(industrySpecPriceDO.getPrice());
industrySpecIds.removeIf(
d -> d.toString().equals(industrySpecPriceDO.getIndustrySpecId().toString()));
break;
}
}
return mallGoodsInfoSimpleDOS;
}
}
return mallGoodsInfoSimpleDOS;
}
}
......@@ -15,6 +15,7 @@ import com.mmc.pms.model.other.dto.AdDTO;
import com.mmc.pms.model.other.dto.DistrictInfoDTO;
import com.mmc.pms.model.other.dto.ModelDTO;
import com.mmc.pms.model.qo.WareInfoQO;
import com.mmc.pms.model.sale.dto.MallGoodsDetailDTO;
import com.mmc.pms.model.sale.dto.SkuInfoDTO;
import com.mmc.pms.page.PageResult;
import com.mmc.pms.service.WebDeviceService;
......@@ -40,6 +41,7 @@ public class WebDeviceServiceImpl implements WebDeviceService {
@Autowired ProductDao productDao;
@Autowired GoodsInfoDao goodsInfoDao;
@Autowired GoodsInfoServiceImpl goodsInfoService;
@Override
public ResultBody listSecondDistrict() {
......@@ -214,6 +216,30 @@ public class WebDeviceServiceImpl implements WebDeviceService {
}
@Override
public ResultBody listLeaseGoodsDetail(
Integer goodsInfoId, Integer userAccountId, HttpServletRequest request) {
int count = goodsInfoDao.countGoodsInfoById(goodsInfoId);
if (count <= 0) {
return ResultBody.error(ResultEnum.GOODS_NOT_EXIST_OR_ALREADY_DOWN_SHELF);
}
// 初始化商品返回信息的对象
ResultBody goodsInfoDetail = goodsInfoService.getGoodsInfoDetail(goodsInfoId);
MallGoodsDetailDTO result = (MallGoodsDetailDTO) goodsInfoDetail.getResult();
if (userAccountId != null) {
UserAccountSimpleDTO userAccountSimpleDTO =
userAppApi.feignGetUserSimpleInfo(userAccountId, request.getHeader(TokenConstant.TOKEN));
if (userAccountSimpleDTO.getCooperationTagId() != null) {
if (!result.getDirectoryId().equals(2)) {
Integer id = result.getGoodsSpec().get(0).getProductSpecList().get(0).getProductSpec();
ProductSpecPriceDO price = productDao.getProductSpecPriceById(id);
result.setPrice(price.getPrice());
}
}
}
return ResultBody.success(result);
}
@Override
public WareInfoDTO getWareInfoById(Integer id) {
WareInfoDO wareInfoDO = webDeviceDao.getWareInfoById(id);
WareDetailDO wareDetailDO = webDeviceDao.getWareDetailById(id);
......
......@@ -14,29 +14,32 @@ import java.util.List;
* @Author small @Date 2023/5/15 14:28 @Version 1.0
*/
public interface WebDeviceService {
ResultBody listSecondDistrict();
ResultBody listSecondDistrict();
ResultBody category();
ResultBody category();
ResultBody brand();
ResultBody brand();
ResultBody deviceBrand();
ResultBody deviceBrand();
ResultBody model();
ResultBody model();
ResultBody deviceModel();
ResultBody deviceModel();
ResultBody deviceList(Integer districtId, Integer categoryId, Integer brandId, Integer modelId);
ResultBody deviceList(Integer districtId, Integer categoryId, Integer brandId, Integer modelId);
ResultBody update(LeaseVo param);
ResultBody update(LeaseVo param);
ResultBody detail(Integer id);
ResultBody detail(Integer id);
ResultBody listWareInfoPage(WareInfoQO param, HttpServletRequest request, Integer userAccountId);
ResultBody listWareInfoPage(WareInfoQO param, HttpServletRequest request, Integer userAccountId);
WareInfoDTO getWareInfoById(Integer id);
WareInfoDTO getWareInfoById(Integer id);
ResultBody<AdDTO> ad();
ResultBody<AdDTO> ad();
List<SkuInfoDTO> listWareSkuById(Integer id);
List<SkuInfoDTO> listWareSkuById(Integer id);
ResultBody listLeaseGoodsDetail(
Integer goodsId, Integer userAccountId, HttpServletRequest request);
}
......@@ -65,10 +65,10 @@
</insert>
<insert id="insertMallProdSkuInfo" parameterType="com.mmc.pms.entity.MallProdInfoDO" useGeneratedKeys="true"
keyProperty="id">
insert into mall_prod_sku_info (goods_info_id, product_id, prod_sku_spec_name, categories_id, choose_type,
sku_unit_id, is_must, flag)
insert into mall_prod_info (goods_info_id, product_id, prod_spec_name, categories_id, choose_type,
sku_unit_id, is_must, flag)
values (#{goodsInfoId}, #{prodSkuId}, #{prodSkuSpecName}, #{categoriesId}, #{chooseType}, #{skuUnitId}, #{must},
#{flag}) >
#{flag})
</insert>
<insert id="insertMallProdSkuInfoSpec">
insert into mall_prod_info_spec (goods_info_id, mall_prod_info_id, product_spec_id)
......@@ -179,24 +179,22 @@
<select id="getMallProSkuInfo" resultType="com.mmc.pms.entity.MallProdInfoDO">
SELECT mi.id,
mi.goods_info_id,
mi.prod_sku_id,
mi.prod_spec_name,
mi.categories_id,
mi.choose_type,
mi.sku_unit_id,
mi.is_must,
mi.product_spec_id_list,
mi.before_update_spec,
mi.flag,
mi.create_time createTime,
c.type_name typeName,
su.id skuUnitId,
su.unit_name unitName,
ps.product_name productSkuName
mi.product_id prodSkuId,
mi.prod_spec_name prodSkuSpecName,
mi.categories_id categoriesId,
mi.choose_type chooseType,
mi.sku_unit_id skuUnitId,
mi.is_must must,
mi.flag flag,
mi.create_time createTime,
c.name typeName,
su.id skuUnitId,
su.unit_name unitName,
ps.product_name productSkuName
FROM mall_prod_info mi
INNER JOIN categories c ON c.id = mi.categories_id
INNER JOIN sku_unit su ON mi.sku_unit_id = su.id
INNER JOIN product ps ON ps.id = mi.prod_sku_id
INNER JOIN product ps ON ps.id = mi.product_id
WHERE mi.goods_info_id = #{id}
AND mi.is_deleted = 0
</select>
......@@ -440,7 +438,19 @@
AND im.img_type = 0
WHERE gi.category_by_one = #{id}
</select>
<select id="getMallProSkuInfoSpec" resultType="com.mmc.pms.entity.MallProdSkuInfoSpecDO">
<resultMap id="resultMallProdSkuInfoSpecMap" type="com.mmc.pms.entity.MallProdSkuInfoSpecDO">
<id property="id" column="id"/>
<result property="mallProdSkuInfoId" column="mall_prod_info_id"/>
<result property="productSpecId" column="product_spec_id"/>
<association property="productSpecDO" resultMap="resultProductSpecMap"/>
</resultMap>
<resultMap id="resultProductSpecMap" type="com.mmc.pms.entity.ProductSpecDO">
<result property="specImage" column="spec_image"/>
<result property="partNo" column="part_no"/>
<result property="specName" column="spec_name"/>
<result property="versionDesc" column="version_desc"/>
</resultMap>
<select id="getMallProSkuInfoSpec" resultMap="resultMallProdSkuInfoSpecMap">
SELECT mp.id,
mp.mall_prod_info_id,
mp.product_spec_id,
......@@ -464,6 +474,7 @@
LEFT JOIN product_spec_price psp ON mp.product_spec_id = psp.product_spec_id
AND psp.cooperation_tag = 0
AND psp.type = 0
and psp.lease_term = 0
<where>
mp.is_deleted = 0
<foreach collection="list" separator="," open=" and mp.goods_info_id in (" close=")" index="index" item="d">
......@@ -471,4 +482,9 @@
</foreach>
</where>
</select>
<select id="listSaleServiceInfo" resultType="com.mmc.pms.entity.SaleServiceDO">
SELECT id, service_name
FROM sale_service
WHERE is_deleted = 0
</select>
</mapper>
......@@ -180,7 +180,7 @@
from product_spec
<where>
is_deleted = 0
and product_sku_id = #{id}
and product_id = #{id}
<if test="keyword != null and keyword != ''">
and spec_name like CONCAT('%',#{keyword},'%')
</if>
......@@ -502,4 +502,14 @@
#{d}
</foreach>)
</select>
<select id="getProductSpecPriceById" resultType="com.mmc.pms.entity.ProductSpecPriceDO">
SELECT product_spec_id,
cooperation_tag,
price
FROM product_spec_price
WHERE product_spec_id = #{id}
AND cooperation_tag = 0
AND type = 1
and lease_term = 0
</select>
</mapper>
......@@ -157,7 +157,7 @@
FROM goods_info gi
INNER JOIN goods_img img ON gi.id = img.goods_info_id
<where>
gi.is_deleted = 0 and gi.shelf_status = 0
gi.is_deleted = 0 and gi.shelf_status = 0 and gi.goods_type = 1
<if test="categoryIds != null and categoryIds.size != 0">
<foreach collection="categoryIds" item="item" index="index" open="and gi.category_by_one IN (" close=")"
separator=",">
......@@ -180,7 +180,7 @@
goods_info gi
INNER JOIN goods_img img ON gi.id = img.goods_info_id and img.img_type = 0
<where>
gi.is_deleted = 0 and gi.shelf_status = 0
gi.is_deleted = 0 and gi.shelf_status = 0 and gi.goods_type = 1
<if test="categoryIds != null">
<foreach collection="categoryIds" item="item" index="index" open="and gi.category_by_one IN (" close=")"
separator=",">
......
......@@ -9,3 +9,4 @@ data-filter:
- /pms/product/spec/feignGetSpecLeaseUnitPrice
- /pms//lease/goods/deviceList
- /pms/classify/queryCategoryInfoByType
- /pms/lease/goods/getLeaseGoodsDetail
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论