提交 de246e24 作者: xiaowang

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

上级 f20a6ca6
...@@ -13,34 +13,34 @@ import com.mmc.pms.service.GoodsInfoService; ...@@ -13,34 +13,34 @@ 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(
@ApiParam("商品信息VO") @Validated(Create.class) @RequestBody GoodsAddVO goodsAddVO) {
return goodsInfoService.addGoods(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(
@ApiParam("商品信息VO") @Validated(Update.class) @RequestBody GoodsAddVO goodsAddVO) {
return goodsInfoService.editGoodsInfo(goodsAddVO); return goodsInfoService.editGoodsInfo(goodsAddVO);
} }
...@@ -58,6 +58,13 @@ public class BackstageGoodsManageController { ...@@ -58,6 +58,13 @@ public class BackstageGoodsManageController {
return goodsInfoService.getSkuUnit(); return goodsInfoService.getSkuUnit();
} }
@ApiOperation(value = "PC端-其他服务-列表")
@GetMapping("listOtherService")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = SaleServiceDTO.class)})
public ResultBody listOtherService() {
return goodsInfoService.getSaleServiceInfoToList();
}
@ApiOperation(value = "feign根据购物车信息填充未知信息", hidden = true) @ApiOperation(value = "feign根据购物车信息填充未知信息", hidden = true)
@PostMapping("fillGoodsInfo") @PostMapping("fillGoodsInfo")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = MallGoodsShopCarDTO.class)}) @ApiResponses({@ApiResponse(code = 200, message = "OK", response = MallGoodsShopCarDTO.class)})
...@@ -68,14 +75,16 @@ public class BackstageGoodsManageController { ...@@ -68,14 +75,16 @@ public class BackstageGoodsManageController {
@ApiOperation(value = "feign根据渠道等级和产品规格id获取对应价格", hidden = true) @ApiOperation(value = "feign根据渠道等级和产品规格id获取对应价格", hidden = true)
@PostMapping("feignListProductSpecPrice") @PostMapping("feignListProductSpecPrice")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)}) @ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)})
public List<MallProductSpecPriceDTO> feignListProductSpecPrice(@RequestBody ProductSpecPriceQO productSpecPriceQO) { public List<MallProductSpecPriceDTO> feignListProductSpecPrice(
@RequestBody ProductSpecPriceQO productSpecPriceQO) {
return goodsInfoService.feignListProductSpecPrice(productSpecPriceQO); return goodsInfoService.feignListProductSpecPrice(productSpecPriceQO);
} }
@ApiOperation(value = "feign根据渠道等级获取单价信息", hidden = true) @ApiOperation(value = "feign根据渠道等级获取单价信息", hidden = true)
@GetMapping("feignGetUnitPriceByTag") @GetMapping("feignGetUnitPriceByTag")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ProductSpecPriceDTO.class)}) @ApiResponses({@ApiResponse(code = 200, message = "OK", response = ProductSpecPriceDTO.class)})
public ProductSpecPriceDTO feignGetUnitPriceByTag(@RequestParam(value = "specId") Integer specId, public ProductSpecPriceDTO feignGetUnitPriceByTag(
@RequestParam(value = "specId") Integer specId,
@RequestParam(value = "tagId") Integer tagId) { @RequestParam(value = "tagId") Integer tagId) {
return goodsInfoService.feignGetUnitPriceByTag(specId, tagId); return goodsInfoService.feignGetUnitPriceByTag(specId, tagId);
} }
...@@ -83,15 +92,16 @@ public class BackstageGoodsManageController { ...@@ -83,15 +92,16 @@ public class BackstageGoodsManageController {
@ApiOperation(value = "feign根据商品的产品规格id查询商品信息", hidden = true) @ApiOperation(value = "feign根据商品的产品规格id查询商品信息", hidden = true)
@PostMapping("feignListProdGoodsSkuInfo") @PostMapping("feignListProdGoodsSkuInfo")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = OrderGoodsProdDTO.class)}) @ApiResponses({@ApiResponse(code = 200, message = "OK", response = OrderGoodsProdDTO.class)})
public List<OrderGoodsProdDTO> feignListProdGoodsSkuInfo(@RequestBody MallOrderGoodsInfoQO mallOrderGoodsInfoQO) { public List<OrderGoodsProdDTO> feignListProdGoodsSkuInfo(
@RequestBody MallOrderGoodsInfoQO mallOrderGoodsInfoQO) {
return goodsInfoService.feignListProdGoodsSkuInfo(mallOrderGoodsInfoQO); return goodsInfoService.feignListProdGoodsSkuInfo(mallOrderGoodsInfoQO);
} }
@ApiOperation(value = "feign根据商品的行业规格id查询商品清单信息", hidden = true) @ApiOperation(value = "feign根据商品的行业规格id查询商品清单信息", hidden = true)
@PostMapping("feignListIndstGoodsSkuInfo") @PostMapping("feignListIndstGoodsSkuInfo")
@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<OrderGoodsIndstDTO> feignListIndstGoodsSkuInfo(
@RequestBody MallOrderGoodsInfoQO mallOrderGoodsInfoQO) {
return goodsInfoService.feignListIndstGoodsSkuInfo(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,8 +11,7 @@ import java.util.Set; ...@@ -11,8 +11,7 @@ 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 {
...@@ -83,7 +82,8 @@ public interface GoodsInfoDao { ...@@ -83,7 +82,8 @@ public interface GoodsInfoDao {
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);
...@@ -94,8 +94,6 @@ public interface GoodsInfoDao { ...@@ -94,8 +94,6 @@ public interface GoodsInfoDao {
List<MallProdSkuInfoSpecDO> getMallProSkuInfoSpec(Integer goodsInfoId); List<MallProdSkuInfoSpecDO> getMallProSkuInfoSpec(Integer goodsInfoId);
List<MallProdSkuInfoSpecDO> listMallprodSpecById(List<Integer> goodsIds); 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);
} }
...@@ -31,20 +31,15 @@ public class MallProdInfoDO implements Serializable { ...@@ -31,20 +31,15 @@ public class MallProdInfoDO implements Serializable {
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;
/**
* 辅助字段 start
*/
private String typeName; private String typeName;
private String goodsName; private String goodsName;
private String unitName; private String unitName;
private String productSkuName; private String productSkuName;
private Integer brandInfoId; private Integer brandInfoId;
/** /** 辅助字段 end */
* 辅助字段 end
*/
public MallProdInfoDO(GoodsProdSpecVO goodsSpecVO) { public MallProdInfoDO(GoodsProdSpecVO goodsSpecVO) {
this.categoriesId = goodsSpecVO.getCategoryId(); this.categoriesId = goodsSpecVO.getCategoryId();
this.prodSkuSpecName = goodsSpecVO.getGoodsSpecName(); this.prodSkuSpecName = goodsSpecVO.getGoodsSpecName();
......
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,12 +7,13 @@ import lombok.NoArgsConstructor; ...@@ -7,12 +7,13 @@ 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
...@@ -20,30 +21,46 @@ import java.util.List; ...@@ -20,30 +21,46 @@ import java.util.List;
@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") @ApiModelProperty(value = "id")
private Integer id; private Integer id;
@ApiModelProperty(value = "商品图片") @ApiModelProperty(value = "商品图片")
private List<GoodsImgDTO> images; private List<GoodsImgDTO> images;
@ApiModelProperty(value = "商品视频") @ApiModelProperty(value = "商品视频")
private String goodsVideo; private String goodsVideo;
@ApiModelProperty(value = "商品视频id") @ApiModelProperty(value = "商品视频id")
private Integer goodsVideoId; private Integer goodsVideoId;
@ApiModelProperty(value = "商品名称") @ApiModelProperty(value = "商品名称")
private String goodsName; private String goodsName;
@ApiModelProperty(value = "商品详情") @ApiModelProperty(value = "商品详情")
private GoodsDetailInfoDTO goodsDetail; private GoodsDetailInfoDTO goodsDetail;
@ApiModelProperty(value = "所属目录") @ApiModelProperty(value = "所属目录")
private Integer directoryId; private Integer directoryId;
@ApiModelProperty(value = "一级分类id") @ApiModelProperty(value = "一级分类id")
private Integer categoryByOne; private Integer categoryByOne;
@ApiModelProperty(value = "二级分类id") @ApiModelProperty(value = "二级分类id")
private Integer categoryByTwo; private Integer categoryByTwo;
@ApiModelProperty(value = "商品标签") @ApiModelProperty(value = "商品标签")
private String tag; private String tag;
@ApiModelProperty(value = "商品状态 0:下架 1:上架") @ApiModelProperty(value = "商品状态 0:下架 1:上架")
private Integer shelfStatus; private Integer shelfStatus;
@ApiModelProperty(value = "规格信息") @ApiModelProperty(value = "规格信息")
private List<GoodsSpecDTO> goodsSpec; private List<GoodsSpecDTO> goodsSpec;
@ApiModelProperty(value = "其他服务: 1:免费配送,2:专业飞手培训2日, 3:半年保修, 4:一年保修 ") @ApiModelProperty(value = "其他服务: 1:免费配送,2:专业飞手培训2日, 3:半年保修, 4:一年保修 ")
private List<GoodsOtherServiceDTO> otherService; 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;
...@@ -27,6 +27,8 @@ public interface GoodsInfoService { ...@@ -27,6 +27,8 @@ public interface GoodsInfoService {
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);
......
...@@ -32,17 +32,13 @@ import java.util.stream.Collectors; ...@@ -32,17 +32,13 @@ 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)
...@@ -58,7 +54,8 @@ public class GoodsInfoServiceImpl implements GoodsInfoService { ...@@ -58,7 +54,8 @@ public class GoodsInfoServiceImpl implements GoodsInfoService {
String YYYY_MM_DD_HH_MM_SS = "yyyyMMddHHmmss"; String YYYY_MM_DD_HH_MM_SS = "yyyyMMddHHmmss";
// 初始化商品对象,并构建对象 // 初始化商品对象,并构建对象
GoodsInfo goodsInfo = new GoodsInfo(goodsAddVO); GoodsInfo goodsInfo = new GoodsInfo(goodsAddVO);
goodsInfo.setGoodsNo("IUAV" + TDateUtil.getDateStr(new Date(), YYYY_MM_DD_HH_MM_SS) + CodeUtil.getRandomNum(4)); goodsInfo.setGoodsNo(
"IUAV" + TDateUtil.getDateStr(new Date(), YYYY_MM_DD_HH_MM_SS) + CodeUtil.getRandomNum(4));
// 暂未接入用户默认传1 // 暂未接入用户默认传1
goodsInfo.setAddGoodsUserId(1); goodsInfo.setAddGoodsUserId(1);
goodsInfo.setSort(goodsInfoDao.countGoodsInfo() + 1); goodsInfo.setSort(goodsInfoDao.countGoodsInfo() + 1);
...@@ -82,18 +79,18 @@ public class GoodsInfoServiceImpl implements GoodsInfoService { ...@@ -82,18 +79,18 @@ public class GoodsInfoServiceImpl implements GoodsInfoService {
return ResultBody.success(); return ResultBody.success();
} }
/** /** 插入行业sku及规格信息 */
* 插入行业sku及规格信息
*/
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void industrySkuSpecOperation(GoodsInfo goodsInfo, List<GoodsProdSpecVO> productSpec) { public void industrySkuSpecOperation(GoodsInfo goodsInfo, List<GoodsProdSpecVO> productSpec) {
for (GoodsProdSpecVO goodsSpecVO : productSpec) { for (GoodsProdSpecVO goodsSpecVO : productSpec) {
MallIndustrySkuInfoDO mallIndustrySkuInfoDO = new MallIndustrySkuInfoDO(goodsSpecVO).setGoodsInfoId(goodsInfo.getId()); MallIndustrySkuInfoDO mallIndustrySkuInfoDO =
new MallIndustrySkuInfoDO(goodsSpecVO).setGoodsInfoId(goodsInfo.getId());
// 插入数据库商品对应的sku信息 // 插入数据库商品对应的sku信息
goodsInfoDao.insertMallIndustrySkuInfo(mallIndustrySkuInfoDO); goodsInfoDao.insertMallIndustrySkuInfo(mallIndustrySkuInfoDO);
for (MallProductSpecVO mallProductSpecVO : goodsSpecVO.getSpecIds()) { for (MallProductSpecVO mallProductSpecVO : goodsSpecVO.getSpecIds()) {
// 构建商品对应的规格信息 // 构建商品对应的规格信息
MallIndustrySkuInfoSpecDO mallIndustrySkuInfoSpecDO = new MallIndustrySkuInfoSpecDO() MallIndustrySkuInfoSpecDO mallIndustrySkuInfoSpecDO =
new MallIndustrySkuInfoSpecDO()
.setIndustrySpecId(mallProductSpecVO.getMallSpecId()) .setIndustrySpecId(mallProductSpecVO.getMallSpecId())
.setMallIndustrySkuInfoId(mallIndustrySkuInfoDO.getId()) .setMallIndustrySkuInfoId(mallIndustrySkuInfoDO.getId())
.setGoodsInfoId(goodsInfo.getId()); .setGoodsInfoId(goodsInfo.getId());
...@@ -106,20 +103,25 @@ public class GoodsInfoServiceImpl implements GoodsInfoService { ...@@ -106,20 +103,25 @@ public class GoodsInfoServiceImpl implements GoodsInfoService {
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void productSkuSpecOperation(GoodsInfo goodsInfo, List<GoodsProdSpecVO> productSpec) { public void productSkuSpecOperation(GoodsInfo goodsInfo, List<GoodsProdSpecVO> productSpec) {
// 遍历规格信息,获取其中自定义的规格信息 // 遍历规格信息,获取其中自定义的规格信息
List<GoodsProdSpecVO> customGoodsSpecList = productSpec.stream().filter(spec -> spec.getFlag().equals(1)).collect(Collectors.toList()); List<GoodsProdSpecVO> customGoodsSpecList =
productSpec.stream().filter(spec -> spec.getFlag().equals(1)).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(customGoodsSpecList)) { if (CollectionUtils.isNotEmpty(customGoodsSpecList)) {
addCustomization(goodsInfo, customGoodsSpecList); addCustomization(goodsInfo, customGoodsSpecList);
} }
// 遍历规格信息,获取其中非自定义的规格信息 // 遍历规格信息,获取其中非自定义的规格信息
List<GoodsProdSpecVO> goodsSpecList = productSpec.stream().filter(spec -> spec.getFlag().equals(0)).collect(Collectors.toList()); List<GoodsProdSpecVO> goodsSpecList =
productSpec.stream().filter(spec -> spec.getFlag().equals(0)).collect(Collectors.toList());
for (GoodsProdSpecVO goodsSpecVO : goodsSpecList) { for (GoodsProdSpecVO goodsSpecVO : goodsSpecList) {
MallProdInfoDO mallProdSkuInfoDO = new MallProdInfoDO(goodsSpecVO) MallProdInfoDO mallProdSkuInfoDO =
.setProdSkuId(goodsSpecVO.getSkuId()).setGoodsInfoId(goodsInfo.getId()); new MallProdInfoDO(goodsSpecVO)
.setProdSkuId(goodsSpecVO.getSkuId())
.setGoodsInfoId(goodsInfo.getId());
// 插入数据库商品对应的sku信息 // 插入数据库商品对应的sku信息
goodsInfoDao.insertMallProdSkuInfo(mallProdSkuInfoDO); goodsInfoDao.insertMallProdSkuInfo(mallProdSkuInfoDO);
for (MallProductSpecVO mallProductSpecVO : goodsSpecVO.getSpecIds()) { for (MallProductSpecVO mallProductSpecVO : goodsSpecVO.getSpecIds()) {
// 构建商品对应的规格信息 // 构建商品对应的规格信息
MallProdSkuInfoSpecDO mallProdSkuInfoSpecDO = new MallProdSkuInfoSpecDO() MallProdSkuInfoSpecDO mallProdSkuInfoSpecDO =
new MallProdSkuInfoSpecDO()
.setProductSpecId(mallProductSpecVO.getMallSpecId()) .setProductSpecId(mallProductSpecVO.getMallSpecId())
.setMallProdSkuInfoId(mallProdSkuInfoDO.getId()) .setMallProdSkuInfoId(mallProdSkuInfoDO.getId())
.setGoodsInfoId(goodsInfo.getId()); .setGoodsInfoId(goodsInfo.getId());
...@@ -130,7 +132,8 @@ public class GoodsInfoServiceImpl implements GoodsInfoService { ...@@ -130,7 +132,8 @@ public class GoodsInfoServiceImpl implements GoodsInfoService {
} }
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public MallProdInfoDO buildMallProdSkuInfo(GoodsInfo goodsInfo, GoodsProdSpecVO goodsSpec, Integer id) { public MallProdInfoDO buildMallProdSkuInfo(
GoodsInfo goodsInfo, GoodsProdSpecVO goodsSpec, Integer id) {
MallProdInfoDO mallProdInfoDO = new MallProdInfoDO(); MallProdInfoDO mallProdInfoDO = new MallProdInfoDO();
mallProdInfoDO.setGoodsInfoId(goodsInfo.getId()); mallProdInfoDO.setGoodsInfoId(goodsInfo.getId());
mallProdInfoDO.setProdSkuId(id); mallProdInfoDO.setProdSkuId(id);
...@@ -148,19 +151,29 @@ public class GoodsInfoServiceImpl implements GoodsInfoService { ...@@ -148,19 +151,29 @@ public class GoodsInfoServiceImpl implements GoodsInfoService {
// 遍历自定义规格信息 // 遍历自定义规格信息
for (GoodsProdSpecVO productSpec : customGoodsSpecList) { for (GoodsProdSpecVO productSpec : customGoodsSpecList) {
// 构建商品对应的sku信息 // 构建商品对应的sku信息
ProductSkuDO productSkuDO = new ProductSkuDO().setCategoriesId(productSpec.getCategoryId()) ProductSkuDO productSkuDO =
.setProductName(productSpec.getProductName()).setCustomize(1) new ProductSkuDO()
.setCategoriesId(productSpec.getCategoryId())
.setProductName(productSpec.getProductName())
.setCustomize(1)
.setDirectoryId(goodsInfo.getDirectoryId()); .setDirectoryId(goodsInfo.getDirectoryId());
// 插入产品sku信息 // 插入产品sku信息
productDao.insertProductSku(productSkuDO); productDao.insertProductSku(productSkuDO);
MallProdInfoDO mallProdInfoDO = buildMallProdSkuInfo(goodsInfo, productSpec, productSkuDO.getId()); MallProdInfoDO mallProdInfoDO =
buildMallProdSkuInfo(goodsInfo, productSpec, productSkuDO.getId());
// 插入数据库商品对应的sku信息 // 插入数据库商品对应的sku信息
productDao.insertMallProdSkuInfo(mallProdInfoDO); productDao.insertMallProdSkuInfo(mallProdInfoDO);
// 先将自定的信息存储到数据库中 // 先将自定的信息存储到数据库中
productSpec.getCustomizeInfo().stream().peek(param -> { productSpec.getCustomizeInfo().stream()
ProductSpecDO productSpecDO = new ProductSpecDO().setProductSkuId(productSkuDO.getId()) .peek(
.setVersionDesc("自定义").setSpecImage(param.getSpecImage()) param -> {
.setSpecName(param.getSpecName()).setPartNo(param.getPartNo()); 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);
// 批量配置价格信息 // 批量配置价格信息
...@@ -170,25 +183,31 @@ public class GoodsInfoServiceImpl implements GoodsInfoService { ...@@ -170,25 +183,31 @@ public class GoodsInfoServiceImpl implements GoodsInfoService {
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 =
otherService.stream()
.map(
d -> {
GoodsServiceDO goodsServiceDO = new GoodsServiceDO(); GoodsServiceDO goodsServiceDO = new GoodsServiceDO();
goodsServiceDO.setGoodsInfoId(goodsId); goodsServiceDO.setGoodsInfoId(goodsId);
goodsServiceDO.setSaleServiceId(d); goodsServiceDO.setSaleServiceId(d);
return goodsServiceDO; return goodsServiceDO;
}).collect(Collectors.toList()); })
.collect(Collectors.toList());
goodsInfoDao.insertGoodsService(otherList); goodsInfoDao.insertGoodsService(otherList);
} }
...@@ -201,16 +220,21 @@ public class GoodsInfoServiceImpl implements GoodsInfoService { ...@@ -201,16 +220,21 @@ public class GoodsInfoServiceImpl implements GoodsInfoService {
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void addGoodsImageInfo(Integer goodsId, GoodsAddVO goodsAddVO) { public void addGoodsImageInfo(Integer goodsId, GoodsAddVO goodsAddVO) {
List<GoodsImgDO> list = goodsAddVO.getImages().stream().map(d -> { List<GoodsImgDO> list =
goodsAddVO.getImages().stream()
.map(
d -> {
GoodsImgDO goodsImgDO = new GoodsImgDO(d); GoodsImgDO goodsImgDO = new GoodsImgDO(d);
goodsImgDO.setGoodsInfoId(goodsId); goodsImgDO.setGoodsInfoId(goodsId);
return goodsImgDO; return goodsImgDO;
}).collect(Collectors.toList()); })
.collect(Collectors.toList());
// 插入图片信息 // 插入图片信息
goodsInfoDao.insertGoodsImgInfo(list); goodsInfoDao.insertGoodsImgInfo(list);
// 插入商品视频信息 // 插入商品视频信息
if (goodsAddVO.getGoodsVideo() != null) { if (goodsAddVO.getGoodsVideo() != null) {
GoodsVideoDO goodsVideoDO = new GoodsVideoDO().setGoodsInfoId(goodsId).setVideoUrl(goodsAddVO.getGoodsVideo()); GoodsVideoDO goodsVideoDO =
new GoodsVideoDO().setGoodsInfoId(goodsId).setVideoUrl(goodsAddVO.getGoodsVideo());
goodsInfoDao.insertVideoInfo(goodsVideoDO); goodsInfoDao.insertVideoInfo(goodsVideoDO);
} }
} }
...@@ -253,43 +277,86 @@ public class GoodsInfoServiceImpl implements GoodsInfoService { ...@@ -253,43 +277,86 @@ public class GoodsInfoServiceImpl implements GoodsInfoService {
@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 =
goodsAddVO.getProductSpec().stream()
.map(GoodsProdSpecVO::getId)
.filter(Objects::nonNull)
.collect(Collectors.toSet());
// 从数据库获取该商品对应绑定的skuId的集合 // 从数据库获取该商品对应绑定的skuId的集合
List<MallIndustrySkuInfoDO> mallIndusSkuInfoList = goodsInfoDao.getMallIndustrySkuInfo(goodsAddVO.getId()); List<MallIndustrySkuInfoDO> mallIndusSkuInfoList =
List<Integer> dbMallSkuIds = mallIndusSkuInfoList.stream().map(MallIndustrySkuInfoDO::getId).collect(Collectors.toList()); goodsInfoDao.getMallIndustrySkuInfo(goodsAddVO.getId());
List<Integer> dbMallSkuIds =
mallIndusSkuInfoList.stream()
.map(MallIndustrySkuInfoDO::getId)
.collect(Collectors.toList());
// 对比数据库id如果不在就删除 // 对比数据库id如果不在就删除
List<Integer> delIds = dbMallSkuIds.stream().filter(id -> !inputMallSkuIds.contains(id)).collect(Collectors.toList()); List<Integer> delIds =
dbMallSkuIds.stream()
.filter(id -> !inputMallSkuIds.contains(id))
.collect(Collectors.toList());
if (delIds.size() != 0) { if (delIds.size() != 0) {
// 先删除商品绑定sku下的spec信息 // 先删除商品绑定sku下的spec信息
industrySpecDao.batchUpdateMallIndustrySpec(delIds, goodsAddVO.getId()); industrySpecDao.batchUpdateMallIndustrySpec(delIds, goodsAddVO.getId());
industrySpecDao.batchUpdateMallIndustrySku(delIds); industrySpecDao.batchUpdateMallIndustrySku(delIds);
} }
// 修改商品绑定的sku信息 // 修改商品绑定的sku信息
List<GoodsProdSpecVO> updateGoodsSpec = goodsAddVO.getProductSpec().stream().filter(Objects::nonNull).collect(Collectors.toList()); List<GoodsProdSpecVO> updateGoodsSpec =
List<MallIndustrySkuInfoDO> mallIndustrySkuInfoList = updateGoodsSpec.stream().map(d -> { goodsAddVO.getProductSpec().stream().filter(Objects::nonNull).collect(Collectors.toList());
List<MallIndustrySkuInfoDO> mallIndustrySkuInfoList =
updateGoodsSpec.stream()
.map(
d -> {
MallIndustrySkuInfoDO mallIndustrySkuInfoDO = new MallIndustrySkuInfoDO(); MallIndustrySkuInfoDO mallIndustrySkuInfoDO = new MallIndustrySkuInfoDO();
mallIndustrySkuInfoDO.setId(d.getId()).setIndustrySkuId(d.getSkuId()) mallIndustrySkuInfoDO
.setCategoriesId(d.getCategoryId()).setIndustrySkuSpecName(d.getGoodsSpecName()) .setId(d.getId())
.setChooseType(d.getChooseType()).setSkuUnitId(d.getSkuUnitId()).setMust(d.getMust()); .setIndustrySkuId(d.getSkuId())
.setCategoriesId(d.getCategoryId())
.setIndustrySkuSpecName(d.getGoodsSpecName())
.setChooseType(d.getChooseType())
.setSkuUnitId(d.getSkuUnitId())
.setMust(d.getMust());
return mallIndustrySkuInfoDO; return mallIndustrySkuInfoDO;
}).collect(Collectors.toList()); })
.collect(Collectors.toList());
// 批量修改sku的信息 // 批量修改sku的信息
industrySpecDao.batchUpdateMallIndustrySkuInfo(mallIndustrySkuInfoList); industrySpecDao.batchUpdateMallIndustrySkuInfo(mallIndustrySkuInfoList);
// 获取新的sku信息 // 获取新的sku信息
List<GoodsProdSpecVO> list = goodsAddVO.getProductSpec().stream().filter(d -> d.getId() == null).collect(Collectors.toList()); List<GoodsProdSpecVO> list =
goodsAddVO.getProductSpec().stream()
.filter(d -> d.getId() == null)
.collect(Collectors.toList());
industrySkuSpecOperation(new GoodsInfo(goodsAddVO.getId()), list); industrySkuSpecOperation(new GoodsInfo(goodsAddVO.getId()), list);
// 获取商品对应的skuId // 获取商品对应的skuId
List<Integer> mallSkuIds = goodsAddVO.getProductSpec().stream().map(GoodsProdSpecVO::getId).filter(Objects::nonNull).collect(Collectors.toList()); List<Integer> mallSkuIds =
goodsAddVO.getProductSpec().stream()
.map(GoodsProdSpecVO::getId)
.filter(Objects::nonNull)
.collect(Collectors.toList());
// 根据这些id查出下面对应的规格信息 // 根据这些id查出下面对应的规格信息
List<MallIndustrySkuInfoSpecDO> mallIndustrySkuInfoSpecList = industrySpecDao.listMallIndustrySpecInfo(mallSkuIds); List<MallIndustrySkuInfoSpecDO> mallIndustrySkuInfoSpecList =
industrySpecDao.listMallIndustrySpecInfo(mallSkuIds);
// 分组 // 分组
Map<Integer, List<MallIndustrySkuInfoSpecDO>> dbSpecMap = mallIndustrySkuInfoSpecList.stream().collect(Collectors.groupingBy(MallIndustrySkuInfoSpecDO::getMallIndustrySkuInfoId)); Map<Integer, List<MallIndustrySkuInfoSpecDO>> dbSpecMap =
List<GoodsProdSpecVO> goodsSpecList = goodsAddVO.getProductSpec().stream().filter(d -> d.getId() != null).collect(Collectors.toList()); 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) { for (GoodsProdSpecVO goodsSpecVO : goodsSpecList) {
// 分组后的每一条商品绑定的规格信息 // 分组后的每一条商品绑定的规格信息
List<MallIndustrySkuInfoSpecDO> dbMallIndustrySkuSpecList = dbSpecMap.get(goodsSpecVO.getId()); List<MallIndustrySkuInfoSpecDO> dbMallIndustrySkuSpecList =
Set<Integer> inputMallSpecIds = goodsSpecVO.getSpecIds().stream().map(MallProductSpecVO::getId).filter(Objects::nonNull).collect(Collectors.toSet()); dbSpecMap.get(goodsSpecVO.getId());
List<Integer> delSpecId = dbMallIndustrySkuSpecList.stream().map(MallIndustrySkuInfoSpecDO::getId).filter(id -> !inputMallSpecIds.contains(id)).collect(Collectors.toList()); 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) { if (delSpecId.size() != 0) {
// 删除多余的spec信息 // 删除多余的spec信息
industrySpecDao.batchUpdateMallIndustSpec(delSpecId, goodsAddVO.getId()); industrySpecDao.batchUpdateMallIndustSpec(delSpecId, goodsAddVO.getId());
...@@ -297,7 +364,8 @@ public class GoodsInfoServiceImpl implements GoodsInfoService { ...@@ -297,7 +364,8 @@ public class GoodsInfoServiceImpl implements GoodsInfoService {
// 新增spec的信息 // 新增spec的信息
for (MallProductSpecVO mallProductSpecVO : goodsSpecVO.getSpecIds()) { for (MallProductSpecVO mallProductSpecVO : goodsSpecVO.getSpecIds()) {
if (mallProductSpecVO.getId() == null) { if (mallProductSpecVO.getId() == null) {
MallIndustrySkuInfoSpecDO mallIndustrySkuInfoSpecDO = new MallIndustrySkuInfoSpecDO() MallIndustrySkuInfoSpecDO mallIndustrySkuInfoSpecDO =
new MallIndustrySkuInfoSpecDO()
.setIndustrySpecId(mallProductSpecVO.getMallSpecId()) .setIndustrySpecId(mallProductSpecVO.getMallSpecId())
.setMallIndustrySkuInfoId(goodsSpecVO.getId()) .setMallIndustrySkuInfoId(goodsSpecVO.getId())
.setGoodsInfoId(goodsAddVO.getId()); .setGoodsInfoId(goodsAddVO.getId());
...@@ -311,46 +379,80 @@ public class GoodsInfoServiceImpl implements GoodsInfoService { ...@@ -311,46 +379,80 @@ public class GoodsInfoServiceImpl implements GoodsInfoService {
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void updateMallProductSkuSpec(GoodsAddVO goodsAddVO) { public void updateMallProductSkuSpec(GoodsAddVO goodsAddVO) {
// 1、普通的sku修改逻辑 // 1、普通的sku修改逻辑
List<GoodsProdSpecVO> specInfo = goodsAddVO.getProductSpec().stream().filter(spec -> !spec.getFlag().equals(1)).collect(Collectors.toList()); List<GoodsProdSpecVO> specInfo =
goodsAddVO.getProductSpec().stream()
.filter(spec -> !spec.getFlag().equals(1))
.collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(specInfo)) { if (CollectionUtils.isNotEmpty(specInfo)) {
// 1.1先获取用户输入的商品绑定sku的id集合 // 1.1先获取用户输入的商品绑定sku的id集合
List<GoodsProdSpecVO> updateGoodsSpec = specInfo.stream().filter(d -> d.getId() != null).collect(Collectors.toList()); List<GoodsProdSpecVO> updateGoodsSpec =
List<Integer> inputMallSkuIds = updateGoodsSpec.stream().map(GoodsProdSpecVO::getId).collect(Collectors.toList()); specInfo.stream().filter(d -> d.getId() != null).collect(Collectors.toList());
List<Integer> inputMallSkuIds =
updateGoodsSpec.stream().map(GoodsProdSpecVO::getId).collect(Collectors.toList());
// 1.2从数据库获取该商品对应绑定的skuId的集合 // 1.2从数据库获取该商品对应绑定的skuId的集合
List<MallProdInfoDO> mallProSkuInfoList = goodsInfoDao.getMallProSkuInfo(goodsAddVO.getId()); List<MallProdInfoDO> mallProSkuInfoList = goodsInfoDao.getMallProSkuInfo(goodsAddVO.getId());
List<Integer> dbMallSkuIds = mallProSkuInfoList.stream().map(MallProdInfoDO::getId).collect(Collectors.toList()); List<Integer> dbMallSkuIds =
mallProSkuInfoList.stream().map(MallProdInfoDO::getId).collect(Collectors.toList());
// 对比数据库id如果不在就删除 // 对比数据库id如果不在就删除
List<Integer> delIds = dbMallSkuIds.stream().filter(id -> !inputMallSkuIds.contains(id)).collect(Collectors.toList()); List<Integer> delIds =
dbMallSkuIds.stream()
.filter(id -> !inputMallSkuIds.contains(id))
.collect(Collectors.toList());
if (delIds.size() != 0) { if (delIds.size() != 0) {
// 先删除商品绑定sku下的spec信息 // 先删除商品绑定sku下的spec信息
goodsInfoDao.batchUpdateMallProSpec(delIds, goodsAddVO.getId()); goodsInfoDao.batchUpdateMallProSpec(delIds, goodsAddVO.getId());
goodsInfoDao.batchUpdateMallProductSku(delIds); goodsInfoDao.batchUpdateMallProductSku(delIds);
} }
// 修改商品绑定的sku信息 // 修改商品绑定的sku信息
List<MallProdInfoDO> mallProdSkuInfoList = updateGoodsSpec.stream().map(d -> { List<MallProdInfoDO> mallProdSkuInfoList =
updateGoodsSpec.stream()
.map(
d -> {
MallProdInfoDO mallProdInfoDO = new MallProdInfoDO(); MallProdInfoDO mallProdInfoDO = new MallProdInfoDO();
mallProdInfoDO.setId(d.getId()).setProdSkuId(d.getSkuId()) mallProdInfoDO
.setCategoriesId(d.getCategoryId()).setProdSkuSpecName(d.getGoodsSpecName()) .setId(d.getId())
.setChooseType(d.getChooseType()).setSkuUnitId(d.getSkuUnitId()).setMust(d.getMust()); .setProdSkuId(d.getSkuId())
.setCategoriesId(d.getCategoryId())
.setProdSkuSpecName(d.getGoodsSpecName())
.setChooseType(d.getChooseType())
.setSkuUnitId(d.getSkuUnitId())
.setMust(d.getMust());
return mallProdInfoDO; return mallProdInfoDO;
}).collect(Collectors.toList()); })
.collect(Collectors.toList());
// 1.3批量修改sku的信息 // 1.3批量修改sku的信息
goodsInfoDao.batchUpdateMallProdSkuInfo(mallProdSkuInfoList); goodsInfoDao.batchUpdateMallProdSkuInfo(mallProdSkuInfoList);
// 1.4对新的sku进行操作 // 1.4对新的sku进行操作
List<GoodsProdSpecVO> list = specInfo.stream().filter(d -> d.getId() == null).collect(Collectors.toList()); List<GoodsProdSpecVO> list =
specInfo.stream().filter(d -> d.getId() == null).collect(Collectors.toList());
productSkuSpecOperation(new GoodsInfo(goodsAddVO.getId()), list); productSkuSpecOperation(new GoodsInfo(goodsAddVO.getId()), list);
// 获取商品对应的skuId // 获取商品对应的skuId
List<Integer> mallSkuIds = goodsAddVO.getProductSpec().stream().filter(d -> d.getId() != null).map(GoodsProdSpecVO::getId).collect(Collectors.toList()); List<Integer> mallSkuIds =
goodsAddVO.getProductSpec().stream()
.filter(d -> d.getId() != null)
.map(GoodsProdSpecVO::getId)
.collect(Collectors.toList());
if (mallSkuIds.size() > 0) { if (mallSkuIds.size() > 0) {
// 根据这些id查出下面对应的规格信息 // 根据这些id查出下面对应的规格信息
List<MallProdSkuInfoSpecDO> mallProdSkuInfoSpecList = goodsInfoDao.listMallProdSpecInfo(mallSkuIds); List<MallProdSkuInfoSpecDO> mallProdSkuInfoSpecList =
goodsInfoDao.listMallProdSpecInfo(mallSkuIds);
// 分组 // 分组
Map<Integer, List<MallProdSkuInfoSpecDO>> dbSpecMap = mallProdSkuInfoSpecList.stream().collect(Collectors.groupingBy(MallProdSkuInfoSpecDO::getMallProdSkuInfoId)); Map<Integer, List<MallProdSkuInfoSpecDO>> dbSpecMap =
mallProdSkuInfoSpecList.stream()
.collect(Collectors.groupingBy(MallProdSkuInfoSpecDO::getMallProdSkuInfoId));
for (GoodsProdSpecVO goodsSpecVO : updateGoodsSpec) { for (GoodsProdSpecVO goodsSpecVO : updateGoodsSpec) {
// 分组后的每一条商品绑定的规格信息 // 分组后的每一条商品绑定的规格信息
List<MallProdSkuInfoSpecDO> dbMallProdSkuSpecList = dbSpecMap.get(goodsSpecVO.getId()); List<MallProdSkuInfoSpecDO> dbMallProdSkuSpecList = dbSpecMap.get(goodsSpecVO.getId());
Set<Integer> inputMallSpecIds = goodsSpecVO.getSpecIds().stream().map(MallProductSpecVO::getId).filter(Objects::nonNull).collect(Collectors.toSet()); Set<Integer> inputMallSpecIds =
List<Integer> delSpecId = dbMallProdSkuSpecList.stream().map(MallProdSkuInfoSpecDO::getId).filter(id -> !inputMallSpecIds.contains(id)).collect(Collectors.toList()); 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) { if (delSpecId.size() != 0) {
// 删除多余的spec信息 // 删除多余的spec信息
goodsInfoDao.batchUpdateMallProdSpec(delSpecId); goodsInfoDao.batchUpdateMallProdSpec(delSpecId);
...@@ -358,7 +460,8 @@ public class GoodsInfoServiceImpl implements GoodsInfoService { ...@@ -358,7 +460,8 @@ public class GoodsInfoServiceImpl implements GoodsInfoService {
// 新增spec的信息 // 新增spec的信息
for (MallProductSpecVO mallProductSpecVO : goodsSpecVO.getSpecIds()) { for (MallProductSpecVO mallProductSpecVO : goodsSpecVO.getSpecIds()) {
if (mallProductSpecVO.getId() == null) { if (mallProductSpecVO.getId() == null) {
MallProdSkuInfoSpecDO mallProdSkuInfoSpecDO = new MallProdSkuInfoSpecDO() MallProdSkuInfoSpecDO mallProdSkuInfoSpecDO =
new MallProdSkuInfoSpecDO()
.setProductSpecId(mallProductSpecVO.getMallSpecId()) .setProductSpecId(mallProductSpecVO.getMallSpecId())
.setMallProdSkuInfoId(goodsSpecVO.getId()) .setMallProdSkuInfoId(goodsSpecVO.getId())
.setGoodsInfoId(goodsAddVO.getId()); .setGoodsInfoId(goodsAddVO.getId());
...@@ -369,7 +472,10 @@ public class GoodsInfoServiceImpl implements GoodsInfoService { ...@@ -369,7 +472,10 @@ public class GoodsInfoServiceImpl implements GoodsInfoService {
} }
} }
// 2、对自定义的sku进行操作 // 2、对自定义的sku进行操作
List<GoodsProdSpecVO> zdySpecInfo = goodsAddVO.getProductSpec().stream().filter(spec -> spec.getFlag().equals(1)).collect(Collectors.toList()); List<GoodsProdSpecVO> zdySpecInfo =
goodsAddVO.getProductSpec().stream()
.filter(spec -> spec.getFlag().equals(1))
.collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(zdySpecInfo)) { if (CollectionUtils.isNotEmpty(zdySpecInfo)) {
updateCustomize(zdySpecInfo, goodsAddVO.getId()); updateCustomize(zdySpecInfo, goodsAddVO.getId());
} }
...@@ -380,21 +486,33 @@ public class GoodsInfoServiceImpl implements GoodsInfoService { ...@@ -380,21 +486,33 @@ public class GoodsInfoServiceImpl implements GoodsInfoService {
public void updateCustomize(List<GoodsProdSpecVO> zdySpecInfo, Integer id) { public void updateCustomize(List<GoodsProdSpecVO> zdySpecInfo, Integer id) {
// 先获取自定义的sku及规格(原来有的) // 先获取自定义的sku及规格(原来有的)
List<GoodsProdSpecVO> zdySpec = zdySpecInfo.stream().filter(d -> d.getId() != null).collect(Collectors.toList()); List<GoodsProdSpecVO> zdySpec =
zdySpecInfo.stream().filter(d -> d.getId() != null).collect(Collectors.toList());
if (!CollectionUtils.isEmpty(zdySpec)) { if (!CollectionUtils.isEmpty(zdySpec)) {
// 根据获取到的自定义sku及规格进行操作 // 根据获取到的自定义sku及规格进行操作
List<MallProdInfoDO> zdySpecList = zdySpec.stream().map(d -> { List<MallProdInfoDO> zdySpecList =
zdySpec.stream()
.map(
d -> {
// 构建商品对应的sku信息 // 构建商品对应的sku信息
ProductSkuDO productSkuDO = new ProductSkuDO().setId(d.getSkuId()).setCategoriesId(d.getCategoryId()).setProductName(d.getProductName()); ProductSkuDO productSkuDO =
new ProductSkuDO()
.setId(d.getSkuId())
.setCategoriesId(d.getCategoryId())
.setProductName(d.getProductName());
productDao.updateProductSku(productSkuDO); productDao.updateProductSku(productSkuDO);
return new MallProdInfoDO(d).setId(d.getId()).setProdSkuId(d.getSkuId()); return new MallProdInfoDO(d).setId(d.getId()).setProdSkuId(d.getSkuId());
}).collect(Collectors.toList()); })
.collect(Collectors.toList());
// 批量修改sku的信息 // 批量修改sku的信息
goodsInfoDao.batchUpdateMallProdSkuInfo(zdySpecList); goodsInfoDao.batchUpdateMallProdSkuInfo(zdySpecList);
} }
for (GoodsProdSpecVO goodsSpecVO : zdySpec) { for (GoodsProdSpecVO goodsSpecVO : zdySpec) {
// 【1】获取输入的自定义规格信息// id不为空则修改 // 【1】获取输入的自定义规格信息// id不为空则修改
List<ProductSpecVO> customizeInfoList = goodsSpecVO.getCustomizeInfo().stream().filter(d -> d.getId() != null).collect(Collectors.toList()); List<ProductSpecVO> customizeInfoList =
goodsSpecVO.getCustomizeInfo().stream()
.filter(d -> d.getId() != null)
.collect(Collectors.toList());
for (ProductSpecVO d : customizeInfoList) { for (ProductSpecVO d : customizeInfoList) {
// ①修改价格配置 // ①修改价格配置
ProductSpecCPQVO productSpecCPQVO = d.getProductSpecCPQVO(); ProductSpecCPQVO productSpecCPQVO = d.getProductSpecCPQVO();
...@@ -407,14 +525,18 @@ public class GoodsInfoServiceImpl implements GoodsInfoService { ...@@ -407,14 +525,18 @@ public class GoodsInfoServiceImpl implements GoodsInfoService {
// 【2】删除多余的自定义规格 // 【2】删除多余的自定义规格
if (!CollectionUtils.isEmpty(goodsSpecVO.getDelProductSpecId())) { if (!CollectionUtils.isEmpty(goodsSpecVO.getDelProductSpecId())) {
// 批量查出spec的数据 // 批量查出spec的数据
List<MallProdSkuInfoSpecDO> prodSkuInfoSpecList = productDao.getProductSpecByIds(goodsSpecVO.getDelProductSpecId()); List<MallProdSkuInfoSpecDO> prodSkuInfoSpecList =
productDao.getProductSpecByIds(goodsSpecVO.getDelProductSpecId());
for (MallProdSkuInfoSpecDO mallProdSkuInfoSpecDO : prodSkuInfoSpecList) { for (MallProdSkuInfoSpecDO mallProdSkuInfoSpecDO : prodSkuInfoSpecList) {
productDao.removeProductSpec(mallProdSkuInfoSpecDO.getProductSpecId()); productDao.removeProductSpec(mallProdSkuInfoSpecDO.getProductSpecId());
} }
goodsInfoDao.batchUpdateMallProdSpec(goodsSpecVO.getDelProductSpecId()); goodsInfoDao.batchUpdateMallProdSpec(goodsSpecVO.getDelProductSpecId());
} }
// 【3】新增最新的自定义规格 // 【3】新增最新的自定义规格
List<ProductSpecVO> collect = goodsSpecVO.getCustomizeInfo().stream().filter(d -> d.getId() == null).collect(Collectors.toList()); List<ProductSpecVO> collect =
goodsSpecVO.getCustomizeInfo().stream()
.filter(d -> d.getId() == null)
.collect(Collectors.toList());
for (ProductSpecVO param : collect) { for (ProductSpecVO param : collect) {
ProductSpecDO productSpecDO = new ProductSpecDO(param); ProductSpecDO productSpecDO = new ProductSpecDO(param);
// 新增产品sku // 新增产品sku
...@@ -424,7 +546,8 @@ public class GoodsInfoServiceImpl implements GoodsInfoService { ...@@ -424,7 +546,8 @@ public class GoodsInfoServiceImpl implements GoodsInfoService {
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(goodsSpecVO.getId()) .setMallProdSkuInfoId(goodsSpecVO.getId())
.setGoodsInfoId(id); .setGoodsInfoId(id);
...@@ -433,7 +556,8 @@ public class GoodsInfoServiceImpl implements GoodsInfoService { ...@@ -433,7 +556,8 @@ public class GoodsInfoServiceImpl implements GoodsInfoService {
} }
} }
// 2.2 新增新的自定义规格信息 // 2.2 新增新的自定义规格信息
List<GoodsProdSpecVO> newZdySpec = zdySpecInfo.stream().filter(d -> d.getId() == null).collect(Collectors.toList()); List<GoodsProdSpecVO> newZdySpec =
zdySpecInfo.stream().filter(d -> d.getId() == null).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(newZdySpec)) { if (CollectionUtils.isNotEmpty(newZdySpec)) {
productSkuSpecOperation(new GoodsInfo(id), newZdySpec); productSkuSpecOperation(new GoodsInfo(id), newZdySpec);
} }
...@@ -446,31 +570,48 @@ public class GoodsInfoServiceImpl implements GoodsInfoService { ...@@ -446,31 +570,48 @@ public class GoodsInfoServiceImpl implements GoodsInfoService {
// 插入其他服务 // 插入其他服务
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 =
other.stream()
.map(
d -> {
GoodsServiceDO goodsServiceDO = new GoodsServiceDO(); GoodsServiceDO goodsServiceDO = new GoodsServiceDO();
goodsServiceDO.setGoodsInfoId(goodsAddVO.getId()); goodsServiceDO.setGoodsInfoId(goodsAddVO.getId());
goodsServiceDO.setSaleServiceId(d); goodsServiceDO.setSaleServiceId(d);
return goodsServiceDO; return goodsServiceDO;
}).collect(Collectors.toList()); })
.collect(Collectors.toList());
goodsInfoDao.insertGoodsService(otherList); 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 =
goodsAddVO.getImages().stream()
.map(GoodsImgVO::getId)
.filter(Objects::nonNull)
.collect(Collectors.toSet());
List<GoodsImgDO> dbImgList = goodsInfoDao.listGoodsInfoByGoodsId(goodsAddVO.getId()); List<GoodsImgDO> dbImgList = goodsInfoDao.listGoodsInfoByGoodsId(goodsAddVO.getId());
List<Integer> deleteIds = dbImgList.stream().map(GoodsImgDO::getId).filter(id -> !imgIds.contains(id)).collect(Collectors.toList()); List<Integer> deleteIds =
dbImgList.stream()
.map(GoodsImgDO::getId)
.filter(id -> !imgIds.contains(id))
.collect(Collectors.toList());
if (deleteIds.size() != 0) { if (deleteIds.size() != 0) {
// 删除多余的图片 // 删除多余的图片
goodsInfoDao.deleteImgByIds(deleteIds); goodsInfoDao.deleteImgByIds(deleteIds);
} }
// 新增图片 // 新增图片
List<GoodsImgDO> imgDOList = goodsAddVO.getImages().stream().filter(d -> d.getId() == null).map(d -> { List<GoodsImgDO> imgDOList =
goodsAddVO.getImages().stream()
.filter(d -> d.getId() == null)
.map(
d -> {
GoodsImgDO goodsImgDO = new GoodsImgDO(d); GoodsImgDO goodsImgDO = new GoodsImgDO(d);
goodsImgDO.setGoodsInfoId(goodsAddVO.getId()); goodsImgDO.setGoodsInfoId(goodsAddVO.getId());
return goodsImgDO; return goodsImgDO;
}).collect(Collectors.toList()); })
.collect(Collectors.toList());
if (imgDOList.size() != 0) { if (imgDOList.size() != 0) {
goodsInfoDao.insertGoodsImgInfo(imgDOList); goodsInfoDao.insertGoodsImgInfo(imgDOList);
} }
...@@ -487,12 +628,12 @@ public class GoodsInfoServiceImpl implements GoodsInfoService { ...@@ -487,12 +628,12 @@ public class GoodsInfoServiceImpl implements GoodsInfoService {
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void updateGoodsDetail(GoodsAddVO goodsAddVO) { public void updateGoodsDetail(GoodsAddVO goodsAddVO) {
GoodsDetailDO goodsDetailDO = new GoodsDetailDO(goodsAddVO.getGoodsDetailVO()).setGoodsInfoId(goodsAddVO.getId()); GoodsDetailDO goodsDetailDO =
new GoodsDetailDO(goodsAddVO.getGoodsDetailVO()).setGoodsInfoId(goodsAddVO.getId());
// 商品详情修改 // 商品详情修改
goodsInfoDao.updateGoodsDetail(goodsDetailDO); goodsInfoDao.updateGoodsDetail(goodsDetailDO);
} }
@Override @Override
public ResultBody getGoodsInfoDetail(Integer goodsInfoId) { public ResultBody getGoodsInfoDetail(Integer goodsInfoId) {
// 判断此商品是否还存在 // 判断此商品是否还存在
...@@ -504,10 +645,15 @@ public class GoodsInfoServiceImpl implements GoodsInfoService { ...@@ -504,10 +645,15 @@ public class GoodsInfoServiceImpl implements GoodsInfoService {
MallGoodsDetailDTO mallGoodsDetail = new MallGoodsDetailDTO(); MallGoodsDetailDTO mallGoodsDetail = new MallGoodsDetailDTO();
// 获取商品基本信息 // 获取商品基本信息
GoodsInfo goodsInfo = goodsInfoDao.getGoodsSimpleInfo(goodsInfoId); GoodsInfo goodsInfo = goodsInfoDao.getGoodsSimpleInfo(goodsInfoId);
mallGoodsDetail.setId(goodsInfo.getId()).setGoodsName(goodsInfo.getGoodsName()) mallGoodsDetail
.setCategoryByOne(goodsInfo.getCategoryByOne()).setGoodsVideo(goodsInfo.getVideoUrl()) .setId(goodsInfo.getId())
.setDirectoryId(goodsInfo.getDirectoryId()).setCategoryByTwo(goodsInfo.getCategoryByTwo()) .setGoodsName(goodsInfo.getGoodsName())
.setTag(goodsInfo.getEcoLabel()).setShelfStatus(goodsInfo.getShelfStatus()) .setCategoryByOne(goodsInfo.getCategoryByOne())
.setGoodsVideo(goodsInfo.getVideoUrl())
.setDirectoryId(goodsInfo.getDirectoryId())
.setCategoryByTwo(goodsInfo.getCategoryByTwo())
.setTag(goodsInfo.getEcoLabel())
.setShelfStatus(goodsInfo.getShelfStatus())
.setGoodsVideoId(goodsInfo.getGoodsVideoId()); .setGoodsVideoId(goodsInfo.getGoodsVideoId());
// 获取商品图片信息 // 获取商品图片信息
mallGoodsDetail.setImages(getGoodsImageInfo(goodsInfoId)); mallGoodsDetail.setImages(getGoodsImageInfo(goodsInfoId));
...@@ -528,16 +674,25 @@ public class GoodsInfoServiceImpl implements GoodsInfoService { ...@@ -528,16 +674,25 @@ public class GoodsInfoServiceImpl implements GoodsInfoService {
private List<GoodsSpecDTO> getIndustrySpecInfo(Integer goodsInfoId) { private List<GoodsSpecDTO> getIndustrySpecInfo(Integer goodsInfoId) {
// 获取商品对应绑定的行业sku信息 // 获取商品对应绑定的行业sku信息
List<MallIndustrySkuInfoDO> mallIndustrySkuInfoList = goodsInfoDao.getMallIndustrySkuInfo(goodsInfoId); List<MallIndustrySkuInfoDO> mallIndustrySkuInfoList =
List<GoodsSpecDTO> list = mallIndustrySkuInfoList.stream().map(MallIndustrySkuInfoDO::buildGoodsSpecDTO).collect(Collectors.toList()); goodsInfoDao.getMallIndustrySkuInfo(goodsInfoId);
List<GoodsSpecDTO> list =
mallIndustrySkuInfoList.stream()
.map(MallIndustrySkuInfoDO::buildGoodsSpecDTO)
.collect(Collectors.toList());
// 根据商品id查出该商品下绑定的规格信息 // 根据商品id查出该商品下绑定的规格信息
List<MallIndustrySkuInfoSpecDO> mallIndustrySkuInfoSpec = industrySpecDao.getIndustrySkuInfoSpec(goodsInfoId); List<MallIndustrySkuInfoSpecDO> mallIndustrySkuInfoSpec =
list = list.stream().peek(d -> { industrySpecDao.getIndustrySkuInfoSpec(goodsInfoId);
list =
list.stream()
.peek(
d -> {
List<MallIndustrySpecDTO> industrySpec = new ArrayList<>(); List<MallIndustrySpecDTO> industrySpec = new ArrayList<>();
for (MallIndustrySkuInfoSpecDO e : mallIndustrySkuInfoSpec) { for (MallIndustrySkuInfoSpecDO e : mallIndustrySkuInfoSpec) {
if (d.getId().equals(e.getMallIndustrySkuInfoId())) { if (d.getId().equals(e.getMallIndustrySkuInfoId())) {
IndustrySpecDO industrySpecDO = e.getIndustrySpecDO(); IndustrySpecDO industrySpecDO = e.getIndustrySpecDO();
MallIndustrySpecDTO industrySpecDTO = industrySpecDO.buildMallIndustrySpecDTO(); MallIndustrySpecDTO industrySpecDTO =
industrySpecDO.buildMallIndustrySpecDTO();
industrySpecDTO.setId(e.getId()); industrySpecDTO.setId(e.getId());
industrySpecDTO.setIndustrySpecId(e.getIndustrySpecId()); industrySpecDTO.setIndustrySpecId(e.getIndustrySpecId());
industrySpecDTO.setIndustrySkuId(d.getSkuId()); industrySpecDTO.setIndustrySkuId(d.getSkuId());
...@@ -545,18 +700,26 @@ public class GoodsInfoServiceImpl implements GoodsInfoService { ...@@ -545,18 +700,26 @@ public class GoodsInfoServiceImpl implements GoodsInfoService {
} }
} }
d.setIndustrySpecList(industrySpec); d.setIndustrySpecList(industrySpec);
}).collect(Collectors.toList()); })
.collect(Collectors.toList());
return list; return list;
} }
private List<GoodsSpecDTO> getProductSpecInfo(Integer goodsInfoId) { private List<GoodsSpecDTO> getProductSpecInfo(Integer goodsInfoId) {
// 获取商品对应绑定sku的信息 // 获取商品对应绑定sku的信息
List<MallProdInfoDO> mallProdSkuInfoList = goodsInfoDao.getMallProSkuInfo(goodsInfoId); List<MallProdInfoDO> mallProdSkuInfoList = goodsInfoDao.getMallProSkuInfo(goodsInfoId);
List<GoodsSpecDTO> list = mallProdSkuInfoList.stream().map(MallProdInfoDO::buildGoodsSpecDTO).collect(Collectors.toList()); List<GoodsSpecDTO> list =
mallProdSkuInfoList.stream()
.map(MallProdInfoDO::buildGoodsSpecDTO)
.collect(Collectors.toList());
// 获取规格来源详细信息 // 获取规格来源详细信息
List<MallProdSkuInfoSpecDO> mallProdSkuInfoSpec = goodsInfoDao.getMallProSkuInfoSpec(goodsInfoId); List<MallProdSkuInfoSpecDO> mallProdSkuInfoSpec =
goodsInfoDao.getMallProSkuInfoSpec(goodsInfoId);
// 根据id查询出规格的具体信息 // 根据id查询出规格的具体信息
list = list.stream().peek(d -> { list =
list.stream()
.peek(
d -> {
List<MallProductSpecDTO> specList = new ArrayList<>(); List<MallProductSpecDTO> specList = new ArrayList<>();
for (MallProdSkuInfoSpecDO e : mallProdSkuInfoSpec) { for (MallProdSkuInfoSpecDO e : mallProdSkuInfoSpec) {
if (d.getId().equals(e.getMallProdSkuInfoId())) { if (d.getId().equals(e.getMallProdSkuInfoId())) {
...@@ -570,14 +733,19 @@ public class GoodsInfoServiceImpl implements GoodsInfoService { ...@@ -570,14 +733,19 @@ public class GoodsInfoServiceImpl implements GoodsInfoService {
// 获取自定义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);
List<SpecPriceVO> collect =
productSpecPrice.stream()
.map(
m -> {
SpecPriceVO specPriceVO = new SpecPriceVO(); SpecPriceVO specPriceVO = new SpecPriceVO();
specPriceVO.setId(m.getId()); specPriceVO.setId(m.getId());
specPriceVO.setPrice(m.getPrice()); specPriceVO.setPrice(m.getPrice());
specPriceVO.setCooperationTag(m.getCooperationTag()); specPriceVO.setCooperationTag(m.getCooperationTag());
return specPriceVO; return specPriceVO;
}).collect(Collectors.toList()); })
.collect(Collectors.toList());
productSpecCPQVO.setSpecPrice(collect); productSpecCPQVO.setSpecPrice(collect);
productSpecDTO.setProductSpecCPQVO(productSpecCPQVO); productSpecDTO.setProductSpecCPQVO(productSpecCPQVO);
} }
...@@ -585,30 +753,41 @@ public class GoodsInfoServiceImpl implements GoodsInfoService { ...@@ -585,30 +753,41 @@ public class GoodsInfoServiceImpl implements GoodsInfoService {
} }
} }
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 =
skuUnitList.stream().map(SkuUnitDO::buildSkuUnitDTO).collect(Collectors.toList());
return ResultBody.success(list); return ResultBody.success(list);
} }
...@@ -621,11 +800,11 @@ public class GoodsInfoServiceImpl implements GoodsInfoService { ...@@ -621,11 +800,11 @@ public class GoodsInfoServiceImpl implements GoodsInfoService {
@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) {
...@@ -639,7 +818,7 @@ public class GoodsInfoServiceImpl implements GoodsInfoService { ...@@ -639,7 +818,7 @@ public class GoodsInfoServiceImpl implements GoodsInfoService {
} }
} }
//对产品和行业的规格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) {
...@@ -653,7 +832,7 @@ public class GoodsInfoServiceImpl implements GoodsInfoService { ...@@ -653,7 +832,7 @@ public class GoodsInfoServiceImpl implements GoodsInfoService {
} }
} }
} }
//根据规格id查找规格信息 // 根据规格id查找规格信息
List<MallGoodsSpecInfoDO> goodsSpecInfoDOList = new ArrayList<>(); List<MallGoodsSpecInfoDO> goodsSpecInfoDOList = new ArrayList<>();
if (!CollectionUtils.isEmpty(prodIds)) { if (!CollectionUtils.isEmpty(prodIds)) {
List<MallGoodsSpecInfoDO> goodsProdSpecInfoDOList = goodsInfoDao.listProdSpecInfo(prodIds); List<MallGoodsSpecInfoDO> goodsProdSpecInfoDOList = goodsInfoDao.listProdSpecInfo(prodIds);
...@@ -663,19 +842,29 @@ public class GoodsInfoServiceImpl implements GoodsInfoService { ...@@ -663,19 +842,29 @@ public class GoodsInfoServiceImpl implements GoodsInfoService {
List<MallGoodsSpecInfoDO> goodsIndstSpecInfoDOList = goodsInfoDao.listIndstSpecInfo(indstIds); List<MallGoodsSpecInfoDO> goodsIndstSpecInfoDOList = goodsInfoDao.listIndstSpecInfo(indstIds);
goodsSpecInfoDOList.addAll(goodsIndstSpecInfoDOList); goodsSpecInfoDOList.addAll(goodsIndstSpecInfoDOList);
} }
//根据查出来的sku,填充到MallGoodsShopCarDTO里面 // 根据查出来的sku,填充到MallGoodsShopCarDTO里面
for (MallGoodsShopCarDTO mallGoodsShopCarDTO : param) { for (MallGoodsShopCarDTO mallGoodsShopCarDTO : param) {
for (MallGoodsSpecInfoDO mallGoodsSpecInfoDO : goodsSpecInfoDOList) { for (MallGoodsSpecInfoDO mallGoodsSpecInfoDO : goodsSpecInfoDOList) {
//找到对应商品 // 找到对应商品
if (mallGoodsShopCarDTO.getGoodsInfoId().toString().equals(mallGoodsSpecInfoDO.getId().toString()) if (mallGoodsShopCarDTO
&& mallGoodsShopCarDTO.getDirectoryId().toString().equals(mallGoodsSpecInfoDO.getDirectoryId().toString())) { .getGoodsInfoId()
.toString()
.equals(mallGoodsSpecInfoDO.getId().toString())
&& mallGoodsShopCarDTO
.getDirectoryId()
.toString()
.equals(mallGoodsSpecInfoDO.getDirectoryId().toString())) {
for (SkuSpecDO skuSpecDO : mallGoodsSpecInfoDO.getSkuSpecDOList()) { for (SkuSpecDO skuSpecDO : mallGoodsSpecInfoDO.getSkuSpecDOList()) {
for (MallSkuInfoSpecDTO mallSkuInfoSpecDTO : mallGoodsShopCarDTO.getSkuList()) { for (MallSkuInfoSpecDTO mallSkuInfoSpecDTO : mallGoodsShopCarDTO.getSkuList()) {
//根据对应规格进行填充 // 根据对应规格进行填充
if (skuSpecDO.getId().toString().equals(mallSkuInfoSpecDTO.getMallSkuInfoSpecId().toString())) { if (skuSpecDO
.getId()
.toString()
.equals(mallSkuInfoSpecDTO.getMallSkuInfoSpecId().toString())) {
mallSkuInfoSpecDTO.setSpecName(skuSpecDO.getSpecName()); mallSkuInfoSpecDTO.setSpecName(skuSpecDO.getSpecName());
mallSkuInfoSpecDTO.setDeleted(skuSpecDO.getSkuSpecDeleted()); mallSkuInfoSpecDTO.setDeleted(skuSpecDO.getSkuSpecDeleted());
mallSkuInfoSpecDTO.setValid(skuSpecDO.getSkuSpecDeleted() == 0 && skuSpecDO.getSpecDeleted() == 0); mallSkuInfoSpecDTO.setValid(
skuSpecDO.getSkuSpecDeleted() == 0 && skuSpecDO.getSpecDeleted() == 0);
break; break;
} }
} }
...@@ -688,29 +877,39 @@ public class GoodsInfoServiceImpl implements GoodsInfoService { ...@@ -688,29 +877,39 @@ public class GoodsInfoServiceImpl implements GoodsInfoService {
} }
@Override @Override
public List<MallProductSpecPriceDTO> feignListProductSpecPrice(ProductSpecPriceQO productSpecPriceQO) { public List<MallProductSpecPriceDTO> feignListProductSpecPrice(
ProductSpecPriceQO productSpecPriceQO) {
Set<Integer> ids = new HashSet<>(productSpecPriceQO.getProductSpecIds()); Set<Integer> ids = new HashSet<>(productSpecPriceQO.getProductSpecIds());
List<MallProductSpecPriceDTO> mallProductSpecPriceDTOS = productSpecPriceQO.getProductSpecIds().stream().map(d -> { List<MallProductSpecPriceDTO> mallProductSpecPriceDTOS =
productSpecPriceQO.getProductSpecIds().stream()
.map(
d -> {
MallProductSpecPriceDTO mallProductSpecPriceDTO = new MallProductSpecPriceDTO(); MallProductSpecPriceDTO mallProductSpecPriceDTO = new MallProductSpecPriceDTO();
mallProductSpecPriceDTO.setProductSpecId(d); mallProductSpecPriceDTO.setProductSpecId(d);
return mallProductSpecPriceDTO; return mallProductSpecPriceDTO;
}).collect(Collectors.toList()); })
//分别找出渠道价格和市场价格 .collect(Collectors.toList());
List<ProductSpecPriceDO> productSpecPriceDOS = productDao.listProductSpecPrice(productSpecPriceQO.getChannelClass(), ids); // 分别找出渠道价格和市场价格
List<ProductSpecPriceDO> productSpecPriceDOS =
productDao.listProductSpecPrice(productSpecPriceQO.getChannelClass(), ids);
List<ProductSpecPriceDO> productSpecPriceDOS1 = productDao.listProductSpecPrice(0, ids); List<ProductSpecPriceDO> productSpecPriceDOS1 = productDao.listProductSpecPrice(0, ids);
//设置合作价格 // 设置合作价格
for (ProductSpecPriceDO productSpecPriceDO : productSpecPriceDOS) { for (ProductSpecPriceDO productSpecPriceDO : productSpecPriceDOS) {
for (MallProductSpecPriceDTO mallProductSpecPriceDTO : mallProductSpecPriceDTOS) { for (MallProductSpecPriceDTO mallProductSpecPriceDTO : mallProductSpecPriceDTOS) {
if (mallProductSpecPriceDTO.getProductSpecId().equals(productSpecPriceDO.getProductSpecId())) { if (mallProductSpecPriceDTO
.getProductSpecId()
.equals(productSpecPriceDO.getProductSpecId())) {
mallProductSpecPriceDTO.setOpPrice(productSpecPriceDO.getPrice()); mallProductSpecPriceDTO.setOpPrice(productSpecPriceDO.getPrice());
break; break;
} }
} }
} }
//设置市场价格 // 设置市场价格
for (ProductSpecPriceDO productSpecPriceDO : productSpecPriceDOS1) { for (ProductSpecPriceDO productSpecPriceDO : productSpecPriceDOS1) {
for (MallProductSpecPriceDTO mallProductSpecPriceDTO : mallProductSpecPriceDTOS) { for (MallProductSpecPriceDTO mallProductSpecPriceDTO : mallProductSpecPriceDTOS) {
if (mallProductSpecPriceDTO.getProductSpecId().equals(productSpecPriceDO.getProductSpecId())) { if (mallProductSpecPriceDTO
.getProductSpecId()
.equals(productSpecPriceDO.getProductSpecId())) {
mallProductSpecPriceDTO.setMkPrice(productSpecPriceDO.getPrice()); mallProductSpecPriceDTO.setMkPrice(productSpecPriceDO.getPrice());
break; break;
} }
...@@ -725,44 +924,57 @@ public class GoodsInfoServiceImpl implements GoodsInfoService { ...@@ -725,44 +924,57 @@ public class GoodsInfoServiceImpl implements GoodsInfoService {
return price; return price;
} }
@Override @Override
public List<OrderGoodsProdDTO> feignListProdGoodsSkuInfo(MallOrderGoodsInfoQO mallOrderGoodsInfoQO) { public List<OrderGoodsProdDTO> feignListProdGoodsSkuInfo(
//查询渠道等级对应的商品价格 MallOrderGoodsInfoQO mallOrderGoodsInfoQO) {
Set<Integer> prodSkuSpecIds = productDao.listProductSpecIds(mallOrderGoodsInfoQO.getMallProdSkuSpecIds()); // 查询渠道等级对应的商品价格
List<ProductSpecPriceDO> productSpecPriceDOS = productDao.listProductSpecPrice(mallOrderGoodsInfoQO.getCooperationTagId(), prodSkuSpecIds); Set<Integer> prodSkuSpecIds =
//查询商品信息 productDao.listProductSpecIds(mallOrderGoodsInfoQO.getMallProdSkuSpecIds());
List<OrderGoodsProdDTO> orderGoodsProdDTOList = productDao.listProdGoodsSkuInfo(mallOrderGoodsInfoQO); List<ProductSpecPriceDO> productSpecPriceDOS =
productDao.listProductSpecPrice(mallOrderGoodsInfoQO.getCooperationTagId(), prodSkuSpecIds);
// 查询商品信息
List<OrderGoodsProdDTO> orderGoodsProdDTOList =
productDao.listProdGoodsSkuInfo(mallOrderGoodsInfoQO);
if (!CollectionUtils.isEmpty(productSpecPriceDOS)) { if (!CollectionUtils.isEmpty(productSpecPriceDOS)) {
//填充渠道价格 // 填充渠道价格
this.fillOrderGoodsProdPrice(orderGoodsProdDTOList, productSpecPriceDOS, prodSkuSpecIds); this.fillOrderGoodsProdPrice(orderGoodsProdDTOList, productSpecPriceDOS, prodSkuSpecIds);
} }
//商品没有设置渠道价格的,按照市场价设置 // 商品没有设置渠道价格的,按照市场价设置
if (!CollectionUtils.isEmpty(prodSkuSpecIds)) { if (!CollectionUtils.isEmpty(prodSkuSpecIds)) {
//查询市场价格,tagInfoId为0 // 查询市场价格,tagInfoId为0
List<ProductSpecPriceDO> prodMarketPrice = productDao.listProductSpecPrice(0, prodSkuSpecIds); List<ProductSpecPriceDO> prodMarketPrice = productDao.listProductSpecPrice(0, prodSkuSpecIds);
//填充市场价格 // 填充市场价格
this.fillOrderGoodsProdPrice(orderGoodsProdDTOList, prodMarketPrice, prodSkuSpecIds); this.fillOrderGoodsProdPrice(orderGoodsProdDTOList, prodMarketPrice, prodSkuSpecIds);
} }
//还需配置商品规格金额, 单个商品skuSpecAmount, 全部小sku金额 // 还需配置商品规格金额, 单个商品skuSpecAmount, 全部小sku金额
List<Integer> goodsIds = orderGoodsProdDTOList.stream().map(OrderGoodsProdDTO::getGoodsInfoId).collect(Collectors.toList()); 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()); List<GoodsServiceDTO> services =
Map<Integer, List<GoodsServiceDTO>> mapGoodsService = org.springframework.util.CollectionUtils.isEmpty(services) ? null goodsInfoDao.listGoodsService(goodsIds).stream()
: services.stream() .map(d -> d.buildGoodsServiceDTO())
.collect(Collectors.groupingBy(GoodsServiceDTO::getGoodsInfoId)); .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 -> { List<OrderGoodsProdDTO> collect =
orderGoodsProdDTOList.stream()
.map(
d -> {
OrderGoodsProdDTO orderGoodsProdDTO = d; OrderGoodsProdDTO orderGoodsProdDTO = d;
if (mapGoodsService != null && mapGoodsService.containsKey(d.getGoodsInfoId())) { if (mapGoodsService != null && mapGoodsService.containsKey(d.getGoodsInfoId())) {
orderGoodsProdDTO.setServices(mapGoodsService.get(d.getGoodsInfoId())); orderGoodsProdDTO.setServices(mapGoodsService.get(d.getGoodsInfoId()));
} }
return orderGoodsProdDTO; return orderGoodsProdDTO;
}).collect(Collectors.toList()); })
.collect(Collectors.toList());
return collect; return collect;
} }
/** /**
* 填充产品规格价格 * 填充产品规格价格
* *
...@@ -771,16 +983,24 @@ public class GoodsInfoServiceImpl implements GoodsInfoService { ...@@ -771,16 +983,24 @@ public class GoodsInfoServiceImpl implements GoodsInfoService {
* @param prodSkuSpecIds * @param prodSkuSpecIds
* @return * @return
*/ */
private List<OrderGoodsProdDTO> fillOrderGoodsProdPrice(List<OrderGoodsProdDTO> orderGoodsProdDTOList, List<ProductSpecPriceDO> productSpecPriceDOS, Set<Integer> prodSkuSpecIds) { private List<OrderGoodsProdDTO> fillOrderGoodsProdPrice(
List<OrderGoodsProdDTO> orderGoodsProdDTOList,
List<ProductSpecPriceDO> productSpecPriceDOS,
Set<Integer> prodSkuSpecIds) {
for (OrderGoodsProdDTO orderGoodsProdDTO : orderGoodsProdDTOList) { for (OrderGoodsProdDTO orderGoodsProdDTO : orderGoodsProdDTOList) {
for (OrderGoodsProdDetailDTO orderGoodsProdDetailDTO : orderGoodsProdDTO.getOrderGoodsProdDetailDTOS()) { for (OrderGoodsProdDetailDTO orderGoodsProdDetailDTO :
//配置价格 orderGoodsProdDTO.getOrderGoodsProdDetailDTOS()) {
// 配置价格
for (ProductSpecPriceDO productSpecPriceDO : productSpecPriceDOS) { for (ProductSpecPriceDO productSpecPriceDO : productSpecPriceDOS) {
//找到规格对应的价格 // 找到规格对应的价格
if (productSpecPriceDO.getProductSpecId().toString().equals(orderGoodsProdDetailDTO.getProductSpecId().toString())) { if (productSpecPriceDO
.getProductSpecId()
.toString()
.equals(orderGoodsProdDetailDTO.getProductSpecId().toString())) {
orderGoodsProdDetailDTO.setUnitPrice(productSpecPriceDO.getPrice()); orderGoodsProdDetailDTO.setUnitPrice(productSpecPriceDO.getPrice());
//配置价格后移除,剩余没有配置的 // 配置价格后移除,剩余没有配置的
prodSkuSpecIds.removeIf(d -> d.toString().equals(orderGoodsProdDetailDTO.getProductSpecId().toString())); prodSkuSpecIds.removeIf(
d -> d.toString().equals(orderGoodsProdDetailDTO.getProductSpecId().toString()));
break; break;
} }
} }
...@@ -789,62 +1009,92 @@ public class GoodsInfoServiceImpl implements GoodsInfoService { ...@@ -789,62 +1009,92 @@ public class GoodsInfoServiceImpl implements GoodsInfoService {
return orderGoodsProdDTOList; return orderGoodsProdDTOList;
} }
@Override @Override
public List<OrderGoodsIndstDTO> feignListIndstGoodsSkuInfo(MallOrderGoodsInfoQO mallOrderGoodsInfoQO) { public List<OrderGoodsIndstDTO> feignListIndstGoodsSkuInfo(
//查询商品信息 MallOrderGoodsInfoQO mallOrderGoodsInfoQO) {
List<MallGoodsInfoSimpleDO> mallGoodsInfoSimpleDOS = goodsInfoDao.listMallGoodsIndstSimpleInfo(mallOrderGoodsInfoQO.getMallIndstSkuSpecIds()); // 查询商品信息
List<Integer> industrySpecIds = goodsInfoDao.listIndustrySpecIds(mallOrderGoodsInfoQO.getMallIndstSkuSpecIds()); List<MallGoodsInfoSimpleDO> mallGoodsInfoSimpleDOS =
//查询商品价格 goodsInfoDao.listMallGoodsIndstSimpleInfo(mallOrderGoodsInfoQO.getMallIndstSkuSpecIds());
List<IndustrySpecPriceDO> industrySpecPriceDOS = industrySpecDao.listIndustrySpecPrice(mallOrderGoodsInfoQO.getCooperationTagId(), industrySpecIds); List<Integer> industrySpecIds =
//查询商品行业规格对应的产品清单 goodsInfoDao.listIndustrySpecIds(mallOrderGoodsInfoQO.getMallIndstSkuSpecIds());
List<MallGoodsProductDO> mallGoodsProductDOS = goodsInfoDao.listIndustryProductList(industrySpecIds); // 查询商品价格
//配置商品行业规格价格 List<IndustrySpecPriceDO> industrySpecPriceDOS =
industrySpecDao.listIndustrySpecPrice(
mallOrderGoodsInfoQO.getCooperationTagId(), industrySpecIds);
// 查询商品行业规格对应的产品清单
List<MallGoodsProductDO> mallGoodsProductDOS =
goodsInfoDao.listIndustryProductList(industrySpecIds);
// 配置商品行业规格价格
this.fillOrderGoodsIndstPrice(mallGoodsInfoSimpleDOS, industrySpecPriceDOS, industrySpecIds); this.fillOrderGoodsIndstPrice(mallGoodsInfoSimpleDOS, industrySpecPriceDOS, industrySpecIds);
if (!CollectionUtils.isEmpty(industrySpecIds)) { if (!CollectionUtils.isEmpty(industrySpecIds)) {
//查询商品价格,找出市场价 // 查询商品价格,找出市场价
List<IndustrySpecPriceDO> industryMarketPrice = industrySpecDao.listIndustrySpecPrice(0, industrySpecIds); List<IndustrySpecPriceDO> industryMarketPrice =
industrySpecDao.listIndustrySpecPrice(0, industrySpecIds);
this.fillOrderGoodsIndstPrice(mallGoodsInfoSimpleDOS, industryMarketPrice, industrySpecIds); this.fillOrderGoodsIndstPrice(mallGoodsInfoSimpleDOS, industryMarketPrice, industrySpecIds);
} }
//配置产品清单 // 配置产品清单
for (MallGoodsInfoSimpleDO mallGoodsInfoSimpleDO : mallGoodsInfoSimpleDOS) { for (MallGoodsInfoSimpleDO mallGoodsInfoSimpleDO : mallGoodsInfoSimpleDOS) {
for (MallGoodsSpecSimpleDO mallGoodsSpecSimpleDO : mallGoodsInfoSimpleDO.getMallGoodsSpecSimpleDOS()) { for (MallGoodsSpecSimpleDO mallGoodsSpecSimpleDO :
mallGoodsInfoSimpleDO.getMallGoodsSpecSimpleDOS()) {
mallGoodsSpecSimpleDO.setMallGoodsProductDOS(new ArrayList<MallGoodsProductDO>()); mallGoodsSpecSimpleDO.setMallGoodsProductDOS(new ArrayList<MallGoodsProductDO>());
//从产品清单中拿出对应的方案规格里面 // 从产品清单中拿出对应的方案规格里面
for (MallGoodsProductDO mallGoodsProductDO : mallGoodsProductDOS) { for (MallGoodsProductDO mallGoodsProductDO : mallGoodsProductDOS) {
if (mallGoodsProductDO.getIndustrySpecId().toString().equals(mallGoodsSpecSimpleDO.getIndustrySpecId().toString())) { if (mallGoodsProductDO
.getIndustrySpecId()
.toString()
.equals(mallGoodsSpecSimpleDO.getIndustrySpecId().toString())) {
mallGoodsSpecSimpleDO.getMallGoodsProductDOS().add(mallGoodsProductDO); mallGoodsSpecSimpleDO.getMallGoodsProductDOS().add(mallGoodsProductDO);
} }
} }
} }
} }
//转换对象 // 转换对象
List<OrderGoodsIndstDTO> collect = mallGoodsInfoSimpleDOS.stream().map(d -> d.buildOrderGoodsIndstDTO()).collect(Collectors.toList()); List<OrderGoodsIndstDTO> collect =
mallGoodsInfoSimpleDOS.stream()
.map(d -> d.buildOrderGoodsIndstDTO())
.collect(Collectors.toList());
// 拼装商品服务 // 拼装商品服务
List<Integer> goodsIds = collect.stream().map(OrderGoodsIndstDTO::getGoodsInfoId).collect(Collectors.toList()); List<Integer> goodsIds =
List<GoodsServiceDTO> services = goodsInfoDao.listGoodsService(goodsIds).stream().map(d -> d.buildGoodsServiceDTO()).collect(Collectors.toList()); collect.stream().map(OrderGoodsIndstDTO::getGoodsInfoId).collect(Collectors.toList());
Map<Integer, List<GoodsServiceDTO>> mapGoodsService = org.springframework.util.CollectionUtils.isEmpty(services) ? null List<GoodsServiceDTO> services =
: services.stream() goodsInfoDao.listGoodsService(goodsIds).stream()
.collect(Collectors.groupingBy(GoodsServiceDTO::getGoodsInfoId)); .map(d -> d.buildGoodsServiceDTO())
List<OrderGoodsIndstDTO> resultList = collect.stream().map(d -> { .collect(Collectors.toList());
Map<Integer, List<GoodsServiceDTO>> mapGoodsService =
org.springframework.util.CollectionUtils.isEmpty(services)
? null
: services.stream().collect(Collectors.groupingBy(GoodsServiceDTO::getGoodsInfoId));
List<OrderGoodsIndstDTO> resultList =
collect.stream()
.map(
d -> {
OrderGoodsIndstDTO orderGoodsIndstDTO = d; OrderGoodsIndstDTO orderGoodsIndstDTO = d;
if (mapGoodsService != null && mapGoodsService.containsKey(d.getGoodsInfoId())) { if (mapGoodsService != null && mapGoodsService.containsKey(d.getGoodsInfoId())) {
orderGoodsIndstDTO.setServices(mapGoodsService.get(d.getGoodsInfoId())); orderGoodsIndstDTO.setServices(mapGoodsService.get(d.getGoodsInfoId()));
} }
return orderGoodsIndstDTO; return orderGoodsIndstDTO;
}).collect(Collectors.toList()); })
.collect(Collectors.toList());
return resultList; return resultList;
} }
private List<MallGoodsInfoSimpleDO> fillOrderGoodsIndstPrice(List<MallGoodsInfoSimpleDO> mallGoodsInfoSimpleDOS, List<IndustrySpecPriceDO> industrySpecPriceDOS, List<Integer> industrySpecIds) { private List<MallGoodsInfoSimpleDO> fillOrderGoodsIndstPrice(
//配置商品行业规格价格 List<MallGoodsInfoSimpleDO> mallGoodsInfoSimpleDOS,
List<IndustrySpecPriceDO> industrySpecPriceDOS,
List<Integer> industrySpecIds) {
// 配置商品行业规格价格
for (MallGoodsInfoSimpleDO mallGoodsInfoSimpleDO : mallGoodsInfoSimpleDOS) { for (MallGoodsInfoSimpleDO mallGoodsInfoSimpleDO : mallGoodsInfoSimpleDOS) {
for (MallGoodsSpecSimpleDO mallGoodsSpecSimpleDO : mallGoodsInfoSimpleDO.getMallGoodsSpecSimpleDOS()) { for (MallGoodsSpecSimpleDO mallGoodsSpecSimpleDO :
//查询规格进行配置 mallGoodsInfoSimpleDO.getMallGoodsSpecSimpleDOS()) {
// 查询规格进行配置
for (IndustrySpecPriceDO industrySpecPriceDO : industrySpecPriceDOS) { for (IndustrySpecPriceDO industrySpecPriceDO : industrySpecPriceDOS) {
if (mallGoodsSpecSimpleDO.getIndustrySpecId().toString().equals(industrySpecPriceDO.getIndustrySpecId().toString())) { if (mallGoodsSpecSimpleDO
.getIndustrySpecId()
.toString()
.equals(industrySpecPriceDO.getIndustrySpecId().toString())) {
mallGoodsSpecSimpleDO.setUnitPrice(industrySpecPriceDO.getPrice()); mallGoodsSpecSimpleDO.setUnitPrice(industrySpecPriceDO.getPrice());
industrySpecIds.removeIf(d -> d.toString().equals(industrySpecPriceDO.getIndustrySpecId().toString())); industrySpecIds.removeIf(
d -> d.toString().equals(industrySpecPriceDO.getIndustrySpecId().toString()));
break; break;
} }
} }
...@@ -853,7 +1103,3 @@ public class GoodsInfoServiceImpl implements GoodsInfoService { ...@@ -853,7 +1103,3 @@ public class GoodsInfoServiceImpl implements GoodsInfoService {
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);
......
...@@ -39,4 +39,7 @@ public interface WebDeviceService { ...@@ -39,4 +39,7 @@ public interface WebDeviceService {
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.flag,
mi.create_time createTime, mi.create_time createTime,
c.type_name typeName, c.name typeName,
su.id skuUnitId, su.id skuUnitId,
su.unit_name unitName, su.unit_name unitName,
ps.product_name productSkuName 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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论