提交 de246e24 作者: xiaowang

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

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