提交 1f2b28f2 作者: xiaowang

后台:产品管理、商品管理、行业管理、品牌管理新增

上级 aa69692c
......@@ -17,7 +17,7 @@ import org.springframework.web.bind.annotation.RestController;
*/
@RestController
@RequestMapping("/brand")
@Api(tags = {"品牌管理-相关接口"})
@Api(tags = {"后台-品牌管理-相关接口"})
public class BackstageBrandManageController {
@Autowired
......@@ -37,12 +37,12 @@ public class BackstageBrandManageController {
return ResultBody.success(brandManageService.listBrandInfo(pageNo, pageSize));
}
// @ApiOperation(value = "删除品牌")
// @GetMapping("deleteBrandInfo")
// @ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)})
// public ResultBody deleteBrandInfo(Integer id) {
// return brandManageService.deleteBrandInfo(id);
// }
@ApiOperation(value = "删除品牌")
@GetMapping("deleteBrandInfo")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)})
public ResultBody deleteBrandInfo(Integer id) {
return brandManageService.deleteBrandInfo(id);
}
@ApiOperation(value = "编辑品牌")
@GetMapping("editBrandInfo")
......
......@@ -21,7 +21,7 @@ import javax.annotation.Resource;
*/
@RestController
@RequestMapping("/goods")
@Api(tags = {"商品管理-相关接口"})
@Api(tags = {"后台-商品管理-相关接口"})
public class BackstageGoodsManageController {
@Resource
private GoodsInfoService goodsInfoService;
......
package com.mmc.pms.controller;
import com.mmc.pms.common.ResultBody;
import com.mmc.pms.model.dto.*;
import com.mmc.pms.model.qo.IndustrySkuQO;
import com.mmc.pms.model.vo.Create;
import com.mmc.pms.model.vo.IndustrySkuVO;
import com.mmc.pms.model.vo.IndustrySpecVO;
import com.mmc.pms.model.vo.Update;
import com.mmc.pms.service.IndustrySpecService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
/**
* @Author LW
* @date 2022/10/8 10:57
* 概要:
*/
@RestController
@RequestMapping("/industry/spec/")
@Api(tags = {"后台-行业管理-相关接口"})
public class BackstageIndustrySpecController {
@Autowired
IndustrySpecService industrySpecService;
@ApiOperation(value = "新增行业sku")
@PostMapping("addIndustrySku")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)})
public ResultBody addIndustrySku(@Validated(Create.class) @ApiParam("行业skuVO") @RequestBody IndustrySkuVO param) {
return industrySpecService.addIndustrySku(param);
}
@ApiOperation(value = "行业sku详情")
@GetMapping("getIndustrySkuDetail")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = IndustrySkuVO.class)})
public ResultBody getIndustrySkuDetail(@ApiParam("id") @RequestParam(value = "id") Integer id) {
return industrySpecService.getIndustrySkuDetail(id);
}
@ApiOperation(value = "行业sku管理---编辑行业sku")
@PostMapping("editIndustrySku")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)})
public ResultBody editIndustrySku(@Validated(Update.class) @ApiParam("行业skuVO") @RequestBody IndustrySkuVO param) {
return industrySpecService.editIndustrySku(param);
}
@ApiOperation(value = "行业sku管理---分页列表")
@PostMapping("listPageIndustrySku")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = IndustrySkuDTO.class)})
public ResultBody listPageIndustrySku(@ApiParam("条件参数") @RequestBody IndustrySkuQO param) {
return industrySpecService.listPageIndustrySku(param);
}
@ApiOperation(value = "新增方案规格")
@PostMapping("addIndustrySpec")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)})
public ResultBody addIndustrySpec(@Validated(Create.class) @ApiParam("条件参数") @RequestBody IndustrySpecVO param) {
return industrySpecService.addIndustrySpec(param);
}
@ApiOperation(value = "方案规格回显")
@GetMapping("getIndustrySpecDetail")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = IndustrySpecDTO.class)})
public ResultBody getIndustrySpecDetail(@ApiParam("行业规格id") @RequestParam(value = "industrySpecId") Integer industrySpecId) {
return industrySpecService.getIndustrySpecDetail(industrySpecId);
}
@ApiOperation(value = "编辑方案规格")
@PostMapping("editIndustrySpec")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)})
public ResultBody editIndustrySpec(@Validated(Update.class) @ApiParam("行业skuVO") @RequestBody IndustrySpecVO param) {
return industrySpecService.editIndustrySpec(param);
}
@ApiOperation(value = "行业sku管理---方案规格管理---分页列表")
@GetMapping("listPageIndustrySpec")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = IndustrySpecDTO.class)})
public ResultBody listPageIndustrySpec(@ApiParam(value = "页码") @RequestParam(value = "pageNo") Integer pageNo,
@ApiParam(value = "每页显示数") @RequestParam(value = "pageSize") Integer pageSize,
@ApiParam(value = "产品skuId") @RequestParam(value = "productSkuId") Integer industrySkuId,
@ApiParam(value = "关键字") @RequestParam(value = "keyword", required = false) String keyword) {
return industrySpecService.listPageIndustrySpec(pageNo, pageSize, industrySkuId, keyword);
}
@ApiOperation(value = "行业方案规格-价格配置")
@PostMapping("industrySpecCPQ")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)})
public ResultBody industrySpecCPQ(@RequestBody IndustrySpecCPQVO industrySpecCPQQ) {
return industrySpecService.industrySpecCPQ(industrySpecCPQQ);
}
@ApiOperation(value = "行业方案规格管理-价格配置信息的修改")
@PostMapping("updateIndustrySpecCPQ")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)})
public ResultBody updateIndustrySpecCPQ(@RequestBody IndustrySpecCPQVO industrySpecCPQQ) {
return industrySpecService.updateIndustrySpecCPQ(industrySpecCPQQ);
}
@ApiOperation(value = "行业sku管理---方案规格管理---获取价格配置信息")
@PostMapping("getIndustrySpecCPQ")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = IndustrySpecPriceDTO.class)})
public ResultBody getIndustrySpecCPQ(@RequestBody IndustrySpecCPQVO industrySpecCPQQ) {
return industrySpecService.getIndustrySpecCPQ(industrySpecCPQQ);
}
@ApiOperation(value = "行业sku管理---删除行业sku")
@GetMapping("removeIndustrySku")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)})
public ResultBody removeIndustrySku(@ApiParam("id") @RequestParam(value = "id") Integer id) {
return industrySpecService.removeIndustrySku(id);
}
@ApiOperation(value = "行业sku管理---方案规格管理---删除行业规格")
@GetMapping("removeIndustrySpec")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = RemoveSkuDTO.class)})
public ResultBody removeIndustrySpec(@ApiParam("id") @RequestParam(value = "id") Integer id) {
return industrySpecService.removeIndustrySpec(id);
}
}
\ No newline at end of file
......@@ -52,13 +52,13 @@ public class BackstageProductSpecController {
return productSkuService.listPageProductSku(productSkuQO);
}
// @ApiOperation(value = "产品sku管理---删除产品sku")
// @GetMapping("removeProductSku")
// @ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)})
// public ResultBody removeProductSku(@ApiParam("id") @RequestParam(value = "id") Integer id) {
// return productSpecService.removeProductSku(id);
// }
//
@ApiOperation(value = "删除产品sku")
@GetMapping("removeProductSku")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)})
public ResultBody removeProductSku(@ApiParam("id") @RequestParam(value = "id") Integer id) {
return productSkuService.removeProductSku(id);
}
@ApiOperation(value = "新增or修改产品规格")
@PostMapping("addOrEditProductSpec")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = ResultBody.class)})
......@@ -112,12 +112,12 @@ public class BackstageProductSpecController {
// return productSpecService.getDefaultSettings(productSpecId);
// }
//
// @ApiOperation(value = "产品规格管理---删除规格")
// @GetMapping("removeProductSpec")
// @ApiResponses({@ApiResponse(code = 200, message = "OK", response = RemoveSkuDTO.class)})
// public ResultBody removeProductSpec(@ApiParam("id") @RequestParam(value = "id") Integer id) {
// return productSpecService.removeProductSpec(id);
// }
@ApiOperation(value = "产品规格管理---删除规格")
@GetMapping("removeProductSpec")
@ApiResponses({@ApiResponse(code = 200, message = "OK", response = RemoveSkuDTO.class)})
public ResultBody removeProductSpec(@ApiParam("id") @RequestParam(value = "id") Integer id) {
return productSkuService.removeProductSpec(id);
}
//
// @ApiOperation(value = "feign根据渠道等级获取单价信息")
// @GetMapping("feignGetUnitPriceByTag")
......
......@@ -42,6 +42,18 @@ public interface GoodsInfoDao {
void deleteGoodsVideoById(Integer id);
void deleteGoodsServiceByGoodsId(Integer id);
void insertMallIndustrySkuInfo(MallIndustrySkuInfoDO mallIndustrySkuInfoDO);
void insertMallIndustrySkuInfoSpec(MallIndustrySkuInfoSpecDO mallIndustrySkuInfoSpecDO);
List<MallProdInfoDO> getMallProSkuInfo(Integer id);
void batchUpdateMallProductSku(List<Integer> delIds);
void batchUpdateMallProdSkuInfo(List<MallProdInfoDO> mallProdSkuInfoList);
List<MallIndustrySkuInfoDO> getMallIndustrySkuInfo(Integer id);
}
......
package com.mmc.pms.dao;
import com.mmc.pms.entity.*;
import com.mmc.pms.model.dto.IndustrySpecCPQVO;
import com.mmc.pms.model.qo.IndustrySkuQO;
import com.mmc.pms.model.vo.IndustrySkuVO;
import com.mmc.pms.model.vo.IndustrySpecVO;
import com.mmc.pms.service.Impl.IndustryProductInventoryDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Set;
/**
* @Author LW
* @date 2022/10/8 10:58
* 概要:
*/
@Mapper
public interface IndustrySpecDao {
int countSkuName(IndustrySkuVO param);
int insertIndustrySku(IndustrySku industrySku);
int countIndustrySkuById(Integer id);
IndustrySku getIndustrySkuById(Integer id);
int updateIndustrySku(IndustrySku industrySku);
int countListPageIndustrySku(IndustrySkuQO param);
List<IndustrySku> listPageIndustrySku(IndustrySkuQO param);
int countSpecName(IndustrySpecVO param);
int insertIndustrySpec(IndustrySpecDO industrySpecDO);
void insertIndustryProductInventory(IndustryProductInventoryDO industryProductInventoryDO);
void insertInventorySpec(InventorySpecDO inventorySpecDO);
int countIndustrySpec(Integer industrySpecId);
IndustrySpecDO getIndustrySpecById(Integer industrySpecId);
List<IndustryProductInventoryDO> getIndustryProductInventory(Integer industrySpecId);
int updateIndustrySpec(IndustrySpecDO industrySpecDO);
void batchDeleteInventorySpec(List<Integer> industryProductInventoryIds);
void deleteIndustryProductInventory(Integer id);
int countListPageIndustrySpec(Integer industrySkuId, String keyword);
List<IndustrySpecDO> listPageIndustrySpec(int i, Integer pageSize, Integer industrySkuId, String keyword);
int batchInsertSpecPrice(List<IndustrySpecPriceDO> list);
void removeIndustrySpecCPQ(IndustrySpecCPQVO industrySpecCPQQ);
void batchInsertLeaseSpecPrice(List<IndustrySpecPriceDO> list);
List<IndustrySpecPriceDO> getIndustrySpecCPQ(IndustrySpecCPQVO industrySpecCPQQ);
void batchUpdateMallIndustrySpec(@Param("list") List<Integer> list, @Param("id") Integer id);
void batchUpdateMallIndustrySku(@Param("list") List<Integer> list);
void batchUpdateMallIndustrySkuInfo(List<MallIndustrySkuInfoDO> mallIndustrySkuInfoList);
List<MallIndustrySkuInfoSpecDO> listMallIndustrySpecInfo(List<Integer> mallSkuIds);
void batchUpdateMallIndustSpec(@Param("list") List<Integer> list, @Param("id") Integer id);
List<IndustryProductInventoryDO> listIndustryProdInventory(Set<Integer> inventoryIds);
List<IndustrySpecDO> listIndustrySpec(Set<Integer> industrySpecIds);
int countIndustrySpecBySkuId(Integer id);
void removeIndustrySku(Integer id);
List<MallIndustrySkuInfoSpecDO> listMallIndustrySpec(Integer id);
void removeIndustryProductInventory(List<Integer> collect);
List<InventorySpecDO> listInventorySpec(List<Integer> ids);
void removeInventorySpec(List<Integer> ids);
void removeIndustrySpec(Integer id);
}
......@@ -12,37 +12,37 @@ import java.util.List;
*/
@Mapper
public interface MiniProgramProductMallDao {
GoodsInfoDO getGoodsInfoByGoodsId(Integer goodsId);
GoodsInfoDO getGoodsInfoByGoodsId(Integer goodsId);
List<GoodsImgDO> listGoodsInfoByGoodsId(Integer goodsId);
List<GoodsImgDO> listGoodsInfoByGoodsId(Integer goodsId);
GoodsDetailDO getGoodsDetailByGoodsId(Integer goodsId);
GoodsDetailDO getGoodsDetailByGoodsId(Integer goodsId);
List<GoodsQaDO> listGoodsQaInfoByGoodsId(Integer goodsId);
List<GoodsQaDO> listGoodsQaInfoByGoodsId(Integer goodsId);
List<GoodsServiceDO> listGoodsServiceByGoodsId(Integer goodsId);
List<GoodsServiceDO> listGoodsServiceByGoodsId(Integer goodsId);
List<MallProdSkuInfoDO> getMallProdInfoByGoodsId(Integer goodsId);
List<MallProdInfoDO> getMallProdInfoByGoodsId(Integer goodsId);
List<MallProdSkuInfoSpecDO> listMallProdSkuInfoSpec(Integer goodsId);
List<MallProdSkuInfoSpecDO> listMallProdSkuInfoSpec(Integer goodsId);
List<ProductSpecDO> listProductSpecInfo(List<Integer> collect);
List<ProductSpecDO> listProductSpecInfo(List<Integer> collect);
List<MallIndustrySkuInfoDO> getMallIndustrySkuInfo(Integer goodsInfoId);
List<MallIndustrySkuInfoDO> getMallIndustrySkuInfo(Integer goodsInfoId);
List<MallIndustrySkuInfoSpecDO> getIndustrySkuInfoSpec(Integer goodsInfoId);
List<MallIndustrySkuInfoSpecDO> getIndustrySkuInfoSpec(Integer goodsInfoId);
int countListGoodsByQO(GoodsInfoQO param);
int countListGoodsByQO(GoodsInfoQO param);
List<GoodsInfoDO> listGoodsByQO(GoodsInfoQO param);
List<GoodsInfoDO> listGoodsByQO(GoodsInfoQO param);
List<GoodsTypeDO> listIndustryIdBySort();
List<GoodsTypeDO> listIndustryIdBySort();
List<IndustryProductInventoryDO> getIndustryProductInventory(Integer industrySpecId);
List<IndustryProductInventoryDO> getIndustryProductInventory(Integer industrySpecId);
List<InventorySpecDO> listInventorySpec(List<Integer> collect);
List<InventorySpecDO> listInventorySpec(List<Integer> collect);
ProductSpecDO getProductSpecDetail(Integer productSpecId);
ProductSpecDO getProductSpecDetail(Integer productSpecId);
ProductSkuDO getProductSkuDetail(Integer productSkuId);
ProductSkuDO getProductSkuDetail(Integer productSkuId);
}
package com.mmc.pms.dao;
import com.mmc.pms.entity.MallProdSkuInfoDO;
import com.mmc.pms.entity.ProductSkuDO;
import com.mmc.pms.entity.ProductSpecDO;
import com.mmc.pms.entity.ProductSpecPriceDO;
import com.mmc.pms.entity.*;
import com.mmc.pms.model.dto.ProductSkuVO;
import com.mmc.pms.model.dto.ProductSpecVO;
import com.mmc.pms.model.qo.ProductSkuQO;
import com.mmc.pms.model.vo.ProductSpecCPQVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Set;
/**
* @author 23214
......@@ -19,7 +18,7 @@ import java.util.List;
* @Entity com.mmc.pms.entity.ProductSku
*/
@Mapper
public interface ProductSkuDao {
public interface ProductDao {
int countSkuName(ProductSkuVO param);
......@@ -58,7 +57,31 @@ public interface ProductSkuDao {
List<ProductSpecPriceDO> getProductSpecPrice(ProductSpecCPQVO productSpecCPQVO);
void insertMallProdSkuInfo(MallProdSkuInfoDO mallProdSkuInfoDO);
void insertMallProdSkuInfo(MallProdInfoDO mallProdInfoDO);
List<ProductSpecDO> listProductSpec(Integer id);
List<ProductSkuDO> listProductSkuDO(List<Integer> productSkuId);
List<InventorySpecDO> listInventorySpecInfo(List<Integer> industryProductInventoryIds);
List<ProductSpecDO> listProductSpecInfo(List<Integer> productSpecIds);
void batchUpdateMallProdSpec(List<Integer> delProductSpecId);
int countProductSpecByBrandId(Integer id);
int countSpecByProdSkuId(Integer id);
void removeProductSku(Integer id);
List<MallProdInfoDO> listMallProdInfo(String id);
void removeProductSpec(Integer id);
List<IndustrySpecDO> listIndustrySpec(@Param("industrySpecIds") Set<Integer> industrySpecIds);
List<InventorySpecDO> listInventorySpec(Integer id);
}
......
......@@ -60,4 +60,8 @@ public class GoodsInfo implements Serializable {
this.ecoLabel = goodsAddVO.getTag();
this.goodsType = goodsAddVO.getGoodsType();
}
public GoodsInfo(Integer id) {
this.id = id;
}
}
\ No newline at end of file
package com.mmc.pms.entity;
import com.mmc.pms.model.dto.IndustrySkuDTO;
import com.mmc.pms.model.vo.IndustrySkuVO;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.Date;
/**
* 行业sku表(IndustrySku)实体类
*
* @author makejava
* @since 2023-05-30 15:01:54
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class IndustrySku implements Serializable {
private static final long serialVersionUID = 165189738203335092L;
private Integer id;
private String solutionName;
private Integer categoriesId;
private String description;
private Date createTime;
private Date updateTime;
private Integer deleted;
private String typeName;
public IndustrySku(IndustrySkuVO param) {
this.id = param.getId();
this.solutionName = param.getSolutionName();
this.categoriesId = param.getCategoryId();
this.description = param.getDescription();
}
public IndustrySkuVO buildIndustrySku() {
return IndustrySkuVO.builder().id(this.id).description(this.description)
.categoryId(this.categoriesId).solutionName(this.solutionName).build();
}
public IndustrySkuDTO buildIndustrySkuDTO() {
return IndustrySkuDTO.builder().id(this.id).description(this.description)
.createTime(this.createTime).categoryId(this.categoriesId)
.categoryName(this.typeName).solutionName(this.solutionName).build();
}
}
package com.mmc.pms.entity;
import java.io.Serializable;
import java.util.Date;
/**
* 行业规格表
* (IndustrySpec)实体类
*
* @author makejava
* @since 2023-05-30 15:02:08
*/
public class IndustrySpec implements Serializable {
private static final long serialVersionUID = -87945230737895634L;
private Integer id;
/**
* 行业sku id
*/
private Integer industrySkuId;
/**
* 规格名称
*/
private String specName;
/**
* 规格图片
*/
private String specImage;
private Date createTime;
private Date updateTime;
private Integer isDeleted;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Integer getIndustrySkuId() {
return industrySkuId;
}
public void setIndustrySkuId(Integer industrySkuId) {
this.industrySkuId = industrySkuId;
}
public String getSpecName() {
return specName;
}
public void setSpecName(String specName) {
this.specName = specName;
}
public String getSpecImage() {
return specImage;
}
public void setSpecImage(String specImage) {
this.specImage = specImage;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public Integer getIsDeleted() {
return isDeleted;
}
public void setIsDeleted(Integer isDeleted) {
this.isDeleted = isDeleted;
}
}
package com.mmc.pms.entity;
import com.mmc.pms.model.dto.IndustrySpecDTO;
import com.mmc.pms.model.dto.MallIndustrySpecDTO;
import com.mmc.pms.model.vo.IndustrySpecVO;
import lombok.AllArgsConstructor;
......@@ -16,40 +17,40 @@ import java.util.Date;
@NoArgsConstructor
@AllArgsConstructor
public class IndustrySpecDO implements Serializable {
private static final long serialVersionUID = 8701065950780976397L;
private Integer id;
private Integer industrySkuId;
private String specName;
private String specImage;
private Date createTime;
private Date updateTime;
private Integer deleted;
private static final long serialVersionUID = 8701065950780976397L;
private Integer id;
private Integer industrySkuId;
private String specName;
private String specImage;
private Date createTime;
private Date updateTime;
private Integer deleted;
private String solutionName;
private String solutionName;
public IndustrySpecDO(IndustrySpecVO param) {
this.id = param.getId();
this.industrySkuId = param.getIndustrySkuId();
this.specName = param.getSpecName();
this.specImage = param.getSpecImage();
}
public IndustrySpecDO(IndustrySpecVO param) {
this.id = param.getId();
this.industrySkuId = param.getIndustrySkuId();
this.specName = param.getSpecName();
this.specImage = param.getSpecImage();
}
/* public IndustrySpecDTO buildIndustrySpecDTO() {
return IndustrySpecDTO.builder()
.id(this.id)
.industrySkuId(this.industrySkuId)
.specImage(this.specImage)
.specName(this.specName)
.createTime(this.createTime)
.build();
}*/
public IndustrySpecDTO buildIndustrySpecDTO() {
return IndustrySpecDTO.builder()
.id(this.id)
.industrySkuId(this.industrySkuId)
.specImage(this.specImage)
.specName(this.specName)
.createTime(this.createTime)
.build();
}
public MallIndustrySpecDTO buildMallIndustrySpecDTO() {
return MallIndustrySpecDTO.builder()
.industrySpecId(this.id)
.industrySkuId(this.industrySkuId)
.specImage(this.specImage)
.specName(this.specName)
.build();
}
public MallIndustrySpecDTO buildMallIndustrySpecDTO() {
return MallIndustrySpecDTO.builder()
.industrySpecId(this.id)
.industrySkuId(this.industrySkuId)
.specImage(this.specImage)
.specName(this.specName)
.build();
}
}
package com.mmc.pms.entity;
import com.mmc.pms.model.dto.IndustrySpecPriceDTO;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
/**
* @Author LW
* @date 2022/10/13 16:10
* 概要:
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class IndustrySpecPriceDO implements Serializable {
private static final long serialVersionUID = -6424007941913778680L;
private Integer id;
private Integer industrySpecId;
private Integer cooperationTag;
private BigDecimal price;
private Date createTime;
private Date updateTime;
private Integer deleted;
private Integer type;
private Integer leaseTerm;
public IndustrySpecPriceDTO buildIndustrySpecPriceDTO() {
return IndustrySpecPriceDTO.builder().id(this.id).industrySpecId(this.industrySpecId)
.cooperationTag(this.cooperationTag).leaseTerm(leaseTerm).price(this.price).createTime(this.createTime).build();
}
}
package com.mmc.pms.entity;
import com.mmc.pms.model.dto.GoodsSpecDTO;
import com.mmc.pms.model.vo.GoodsSpecVO;
import com.mmc.pms.model.vo.GoodsProdSpecVO;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
......@@ -18,47 +18,51 @@ import java.util.Date;
@AllArgsConstructor
@Accessors(chain = true)
public class MallIndustrySkuInfoDO implements Serializable {
private static final long serialVersionUID = 1492322282696261487L;
private Integer id;
private Integer goodsInfoId;
private Integer industrySkuId;
private String industrySkuSpecName;
private Integer goodsTypeId;
private Integer chooseType;
private Integer must;
private Integer skuUnitId;
private Integer deleted;
private Date createTime;
private Date updateTime;
private static final long serialVersionUID = 1492322282696261487L;
private Integer id;
private Integer goodsInfoId;
private Integer industrySkuId;
private String industrySkuSpecName;
private Integer categoriesId;
private Integer chooseType;
private Integer must;
private Integer skuUnitId;
private Integer deleted;
private Date createTime;
private Date updateTime;
/** 辅助字段start */
private String typeName;
/**
* 辅助字段start
*/
private String typeName;
private String unitName;
private String industrySkuName;
private String unitName;
private String industrySkuName;
/** 辅助字段end */
public MallIndustrySkuInfoDO(GoodsSpecVO goodsSpecVO) {
this.industrySkuId = goodsSpecVO.getSkuId();
this.chooseType = goodsSpecVO.getChooseType();
this.industrySkuSpecName = goodsSpecVO.getGoodsSpecName();
this.skuUnitId = goodsSpecVO.getSkuUnitId();
this.goodsTypeId = goodsSpecVO.getGoodsTypeId();
this.must = goodsSpecVO.getMust();
}
/**
* 辅助字段end
*/
public MallIndustrySkuInfoDO(GoodsProdSpecVO goodsSpecVO) {
this.industrySkuId = goodsSpecVO.getSkuId();
this.chooseType = goodsSpecVO.getChooseType();
this.industrySkuSpecName = goodsSpecVO.getGoodsSpecName();
this.skuUnitId = goodsSpecVO.getSkuUnitId();
this.categoriesId = goodsSpecVO.getCategoryId();
this.must = goodsSpecVO.getMust();
}
public GoodsSpecDTO buildGoodsSpecDTO() {
return GoodsSpecDTO.builder()
.id(this.id)
.goodsSpecName(this.industrySkuSpecName)
.goodsTypeId(this.goodsTypeId)
.chooseType(this.chooseType)
.skuUnitId(skuUnitId)
.unitName(this.unitName)
.skuId(this.industrySkuId)
.typeName(this.typeName)
.skuName(this.industrySkuName)
.must(must)
.build();
}
public GoodsSpecDTO buildGoodsSpecDTO() {
return GoodsSpecDTO.builder()
.id(this.id)
.goodsSpecName(this.industrySkuSpecName)
.goodsTypeId(this.categoriesId)
.chooseType(this.chooseType)
.skuUnitId(skuUnitId)
.unitName(this.unitName)
.skuId(this.industrySkuId)
.typeName(this.typeName)
.skuName(this.industrySkuName)
.must(must)
.build();
}
}
package com.mmc.pms.entity;
import com.mmc.pms.model.dto.GoodsSpecDTO;
import com.mmc.pms.model.vo.GoodsSpecVO;
import com.mmc.pms.model.vo.GoodsProdSpecVO;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
......@@ -17,13 +17,13 @@ import java.util.Date;
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public class MallProdSkuInfoDO implements Serializable {
public class MallProdInfoDO implements Serializable {
private static final long serialVersionUID = 3667714765929443857L;
private Integer id;
private Integer goodsInfoId;
private Integer prodSkuId;
private String prodSkuSpecName;
private Integer categoryId;
private Integer categoriesId;
private Integer chooseType;
private Integer must;
private Integer skuUnitId;
......@@ -37,7 +37,7 @@ public class MallProdSkuInfoDO implements Serializable {
* 辅助字段 start
*/
private String typeName;
private String goodsName;
private String unitName;
private String productSkuName;
private Integer brandInfoId;
......@@ -45,8 +45,8 @@ public class MallProdSkuInfoDO implements Serializable {
/**
* 辅助字段 end
*/
public MallProdSkuInfoDO(GoodsSpecVO goodsSpecVO) {
this.categoryId = goodsSpecVO.getGoodsTypeId();
public MallProdInfoDO(GoodsProdSpecVO goodsSpecVO) {
this.categoriesId = goodsSpecVO.getCategoryId();
this.prodSkuSpecName = goodsSpecVO.getGoodsSpecName();
this.chooseType = goodsSpecVO.getChooseType();
this.skuUnitId = goodsSpecVO.getSkuUnitId();
......@@ -58,7 +58,7 @@ public class MallProdSkuInfoDO implements Serializable {
return GoodsSpecDTO.builder()
.id(this.id)
.goodsSpecName(this.prodSkuSpecName)
.goodsTypeId(this.categoryId)
.goodsTypeId(this.categoriesId)
.chooseType(this.chooseType)
.skuUnitId(skuUnitId)
.unitName(this.unitName)
......
package com.mmc.pms.model.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.Date;
/**
* @Author LW
* @date 2022/10/9 10:29
* 概要:
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class IndustrySkuDTO implements Serializable {
private static final long serialVersionUID = 6371755036627825948L;
@ApiModelProperty(value = "id")
private Integer id;
@ApiModelProperty(value = "方案名称")
private String solutionName;
@ApiModelProperty(value = "所属行业id")
private Integer categoryId;
@ApiModelProperty(value = "行业名称")
private String categoryName;
@ApiModelProperty(value = "描述")
private String description;
@ApiModelProperty(value = "创建时间")
private Date createTime;
}
package com.mmc.pms.model.dto;
import com.mmc.pms.model.vo.SpecPriceVO;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.List;
/**
* @Author LW
* @date 2022/9/29 17:51
* 概要:
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class IndustrySpecCPQVO implements Serializable {
private static final long serialVersionUID = -1184938705010745010L;
@ApiModelProperty(value = "行业规格id")
private Integer industrySpecId;
@ApiModelProperty(value = "销售:0 租赁:1")
private Integer type;
@ApiModelProperty(value = "租赁时限:(输入0:1-7天、输入1:8-15天、输入2:16-30天、输入3:30天以上)")
private Integer leaseTerm;
@ApiModelProperty(value = "规格价格配置VO")
private List<SpecPriceVO> specPrice;
}
package com.mmc.pms.model.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
* @Author LW
* @date 2022/10/11 14:29
* 概要:
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class IndustrySpecDTO implements Serializable {
private static final long serialVersionUID = 5476956071052692714L;
@ApiModelProperty(value = "id")
private Integer id;
@ApiModelProperty(value = "行业skuId")
private Integer industrySkuId;
@ApiModelProperty(value = "规格名称")
private String specName;
@ApiModelProperty(value = "规格图片")
private String specImage;
@ApiModelProperty(value = "产品清单")
private List<ProductInventoryVO> productInventoryList;
@ApiModelProperty(value = "创建时间")
private Date createTime;
}
package com.mmc.pms.model.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
/**
* @Author LW
* @date 2022/10/8 10:22
* 概要:
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class IndustrySpecPriceDTO implements Serializable {
private static final long serialVersionUID = 2319479581071699519L;
@ApiModelProperty(value = "id")
private Integer id;
@ApiModelProperty(value = "规格id")
private Integer industrySpecId;
@ApiModelProperty(value = "等级标签id")
private Integer cooperationTag;
@ApiModelProperty(value = "价格")
private BigDecimal price;
@ApiModelProperty(value = "租赁期限 (0:1-7天,1:8-15天,2:16-30天,3:30天以上)")
private Integer leaseTerm;
@ApiModelProperty(value = "创建时间")
private Date createTime;
}
package com.mmc.pms.model.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.List;
/**
* 删除sku dto
*
* @Author LW
* @date 2022/10/28 15:18
* 概要:
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class RemoveSkuDTO implements Serializable {
private static final long serialVersionUID = 6122488544731063648L;
@ApiModelProperty(value = "关联的商品名称数组")
private List<String> goodsName;
@ApiModelProperty(value = "关联的行业sku名称数组")
private List<SkuAndSpecDTO> industrySkuName;
}
package com.mmc.pms.model.dto;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import java.io.Serializable;
/**
* @Author LW
* @date 2022/12/6 17:09
* 概要:
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
@Accessors(chain = true)
public class SkuAndSpecDTO implements Serializable {
private static final long serialVersionUID = -7551846102488434733L;
private String industrySkuName;
private String industrySpecNames;
}
package com.mmc.pms.model.qo;
import com.mmc.pms.model.vo.Freeze;
import com.mmc.pms.page.Page;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
/**
* @Author LW
* @date 2022/9/26 11:13
* 概要:
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class IndustrySkuQO implements Serializable {
private static final long serialVersionUID = -3016233395499711687L;
@ApiModelProperty(value = "方案名称")
private String solutionName;
@ApiModelProperty(value = "行业类型id")
private Integer categoryId;
@ApiModelProperty(value = "页码", required = true)
@NotNull(message = "页码不能为空", groups = {Page.class, Freeze.class})
@Min(value = 1, groups = Page.class)
private Integer pageNo;
@ApiModelProperty(value = "每页显示数", required = true)
@NotNull(message = "每页显示数不能为空", groups = {Page.class, Freeze.class})
@Min(value = 1, groups = Page.class)
private Integer pageSize;
public void buildCurrentPage() {
this.pageNo = (pageNo - 1) * pageSize;
}
}
package com.mmc.pms.model.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
/**
* @Author LW
* @date 2022/10/8 14:41
* 概要:
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class IndustrySkuVO implements Serializable {
private static final long serialVersionUID = 6388977489810960843L;
@ApiModelProperty(value = "id")
@NotNull(message = "id不能为空", groups = {Update.class})
private Integer id;
@ApiModelProperty(value = "方案名称")
@NotNull(message = "方案名称不能为空", groups = {Create.class, Update.class})
private String solutionName;
@NotNull(message = "行业分类id不能为空", groups = {Create.class, Update.class})
@ApiModelProperty(value = "所属行业分类id")
private Integer categoryId;
@ApiModelProperty(value = "描述")
private String description;
}
......@@ -17,33 +17,33 @@ import java.util.List;
@NoArgsConstructor
@AllArgsConstructor
public class IndustrySpecVO implements Serializable {
private static final long serialVersionUID = 5939041792432691119L;
@ApiModelProperty(value = "id")
@NotNull(message = "修改时id不能为空", groups = Update.class)
private Integer id;
@NotNull(
message = "行业sku的id不能为空",
groups = {Update.class, Create.class})
@ApiModelProperty(value = "行业sku的id")
private Integer industrySkuId;
@NotNull(
message = "规格名称不能为空",
groups = {Update.class, Create.class})
@ApiModelProperty(value = "规格名称")
private String specName;
@NotNull(
message = "规格图片不能为空",
groups = {Update.class, Create.class})
@ApiModelProperty(value = "规格图片")
private String specImage;
@NotNull(
message = "产品清单不能为空",
groups = {Update.class, Create.class})
@ApiModelProperty(value = "产品清单")
private List<ProductInventoryVO> productInventoryList;
private static final long serialVersionUID = 5939041792432691119L;
@ApiModelProperty(value = "id")
@NotNull(message = "修改时id不能为空", groups = Update.class)
private Integer id;
@NotNull(
message = "行业sku的id不能为空",
groups = {Update.class, Create.class})
@ApiModelProperty(value = "行业sku的id")
private Integer industrySkuId;
@NotNull(
message = "规格名称不能为空",
groups = {Update.class, Create.class})
@ApiModelProperty(value = "规格名称")
private String specName;
@NotNull(
message = "规格图片不能为空",
groups = {Update.class, Create.class})
@ApiModelProperty(value = "规格图片")
private String specImage;
@NotNull(
message = "产品清单不能为空",
groups = {Update.class, Create.class})
@ApiModelProperty(value = "产品清单")
private List<ProductInventoryVO> productInventoryList;
}
......@@ -44,4 +44,6 @@ public interface BrandManageService {
* @return {@link ResultBody}
*/
ResultBody editBrandInfo(Integer id, String name);
ResultBody deleteBrandInfo(Integer id);
}
......@@ -3,6 +3,7 @@ package com.mmc.pms.service.Impl;
import com.mmc.pms.common.ResultBody;
import com.mmc.pms.common.ResultEnum;
import com.mmc.pms.dao.BrandManageDao;
import com.mmc.pms.dao.ProductDao;
import com.mmc.pms.entity.BrandInfoDO;
import com.mmc.pms.model.dto.BrandInfoDTO;
import com.mmc.pms.page.PageResult;
......@@ -10,6 +11,7 @@ import com.mmc.pms.service.BrandManageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;
......@@ -23,6 +25,8 @@ public class BrandManageServiceImpl implements BrandManageService {
@Autowired
private BrandManageDao brandManageDao;
@Resource
private ProductDao productDao;
/**
......@@ -62,22 +66,22 @@ public class BrandManageServiceImpl implements BrandManageService {
return PageResult.buildPage(pageNo, pageSize, count, brandInfoList);
}
// /**
// * 删除品牌信息
// *
// * @param id id
// * @return {@link ResultBody}
// */
// @Override
// public ResultBody deleteBrandInfo(Integer id) {
// // 判断该品牌是否绑定产品信息
// int count = productSpecDao.countProductSpecByBrandId(id);
// if (count > 0) {
// return ResultBody.error(ResultEnum.BRAND_DELETE_FAIL);
// }
// brandManageDao.removeBrandInfoById(id);
// return ResultBody.success();
// }
/**
* 删除品牌信息
*
* @param id id
* @return {@link ResultBody}
*/
@Override
public ResultBody deleteBrandInfo(Integer id) {
// 判断该品牌是否绑定产品信息
int count = productDao.countProductSpecByBrandId(id);
if (count > 0) {
return ResultBody.error(ResultEnum.BRAND_DELETE_FAIL);
}
brandManageDao.removeBrandInfoById(id);
return ResultBody.success();
}
@Override
public ResultBody editBrandInfo(Integer id, String brandName) {
......
......@@ -3,8 +3,10 @@ package com.mmc.pms.service.Impl;
import com.mmc.pms.common.ResultBody;
import com.mmc.pms.common.ResultEnum;
import com.mmc.pms.dao.GoodsInfoDao;
import com.mmc.pms.dao.ProductSkuDao;
import com.mmc.pms.dao.IndustrySpecDao;
import com.mmc.pms.dao.ProductDao;
import com.mmc.pms.entity.*;
import com.mmc.pms.model.dto.ProductSpecVO;
import com.mmc.pms.model.vo.*;
import com.mmc.pms.service.GoodsInfoService;
import com.mmc.pms.util.CodeUtil;
......@@ -14,10 +16,8 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
......@@ -32,10 +32,13 @@ public class GoodsInfoServiceImpl implements GoodsInfoService {
private GoodsInfoDao goodsInfoDao;
@Resource
private ProductSkuDao productSkuDao;
private ProductDao productDao;
@Resource
private ProductSkuServiceImpl productSkuService;
private ProductServiceImpl productSkuService;
@Resource
private IndustrySpecDao industrySpecDao;
@Override
@Transactional(rollbackFor = Exception.class)
......@@ -69,13 +72,36 @@ public class GoodsInfoServiceImpl implements GoodsInfoService {
if (!goodsAddVO.getDirectoryId().equals(2)) {
// 添加产品规格信息
productSkuSpecOperation(goodsInfo, goodsAddVO.getProductSpec());
} else {
industrySkuSpecOperation(goodsInfo, goodsAddVO.getProductSpec());
}
return ResultBody.success();
}
/**
* 插入行业sku及规格信息
*/
@Transactional(rollbackFor = Exception.class)
public void industrySkuSpecOperation(GoodsInfo goodsInfo, List<GoodsProdSpecVO> productSpec) {
for (GoodsProdSpecVO goodsSpecVO : productSpec) {
MallIndustrySkuInfoDO mallIndustrySkuInfoDO = new MallIndustrySkuInfoDO(goodsSpecVO).setGoodsInfoId(goodsInfo.getId());
// 插入数据库商品对应的sku信息
goodsInfoDao.insertMallIndustrySkuInfo(mallIndustrySkuInfoDO);
for (Integer industrySpecId : goodsSpecVO.getSpecIds()) {
// 构建商品对应的规格信息
MallIndustrySkuInfoSpecDO mallIndustrySkuInfoSpecDO = new MallIndustrySkuInfoSpecDO()
.setIndustrySpecId(industrySpecId)
.setMallIndustrySkuInfoId(mallIndustrySkuInfoDO.getId())
.setGoodsInfoId(goodsInfo.getId());
// 插入数据库商品对应的规格信息
goodsInfoDao.insertMallIndustrySkuInfoSpec(mallIndustrySkuInfoSpecDO);
}
}
}
@Transactional(rollbackFor = Exception.class)
public void productSkuSpecOperation(GoodsInfo goodsInfo, List<GoodsProdSpecVO> productSpec) {
// 遍历规格信息,获取其中自定义的规格信息
// 遍历规格信息,获取其中自定义的规格信息
List<GoodsProdSpecVO> customGoodsSpecList = productSpec.stream().filter(spec -> spec.getFlag().equals(1)).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(customGoodsSpecList)) {
addCustomization(goodsInfo, customGoodsSpecList);
......@@ -83,25 +109,25 @@ public class GoodsInfoServiceImpl implements GoodsInfoService {
// 遍历规格信息,获取其中非自定义的规格信息
List<GoodsProdSpecVO> goodsSpecList = productSpec.stream().filter(spec -> spec.getFlag().equals(0)).collect(Collectors.toList());
for (GoodsProdSpecVO goodsSpec : goodsSpecList) {
MallProdSkuInfoDO mallProdSkuInfoDO = buildMallProdSkuInfo(goodsInfo, goodsSpec, goodsSpec.getSkuId());
mallProdSkuInfoDO.setProductSpecIdList(goodsSpec.getSpecIds().stream().map(String::valueOf).collect(Collectors.joining(",")));
MallProdInfoDO mallProdInfoDO = buildMallProdSkuInfo(goodsInfo, goodsSpec, goodsSpec.getSkuId());
mallProdInfoDO.setProductSpecIdList(goodsSpec.getSpecIds().stream().map(String::valueOf).collect(Collectors.joining(",")));
// 插入数据库商品对应的sku信息
productSkuDao.insertMallProdSkuInfo(mallProdSkuInfoDO);
productDao.insertMallProdSkuInfo(mallProdInfoDO);
}
}
@Transactional(rollbackFor = Exception.class)
public MallProdSkuInfoDO buildMallProdSkuInfo(GoodsInfo goodsInfo, GoodsProdSpecVO goodsSpec, Integer id) {
MallProdSkuInfoDO mallProdSkuInfoDO = new MallProdSkuInfoDO();
mallProdSkuInfoDO.setGoodsInfoId(goodsInfo.getId());
mallProdSkuInfoDO.setProdSkuId(id);
mallProdSkuInfoDO.setProdSkuSpecName(goodsSpec.getGoodsSpecName());
mallProdSkuInfoDO.setCategoryId(goodsSpec.getCategoryId());
mallProdSkuInfoDO.setChooseType(goodsSpec.getChooseType());
mallProdSkuInfoDO.setMust(goodsSpec.getMust());
mallProdSkuInfoDO.setFlag(goodsSpec.getFlag());
mallProdSkuInfoDO.setSkuUnitId(goodsSpec.getSkuUnitId());
return mallProdSkuInfoDO;
public MallProdInfoDO buildMallProdSkuInfo(GoodsInfo goodsInfo, GoodsProdSpecVO goodsSpec, Integer id) {
MallProdInfoDO mallProdInfoDO = new MallProdInfoDO();
mallProdInfoDO.setGoodsInfoId(goodsInfo.getId());
mallProdInfoDO.setProdSkuId(id);
mallProdInfoDO.setProdSkuSpecName(goodsSpec.getGoodsSpecName());
mallProdInfoDO.setCategoriesId(goodsSpec.getCategoryId());
mallProdInfoDO.setChooseType(goodsSpec.getChooseType());
mallProdInfoDO.setMust(goodsSpec.getMust());
mallProdInfoDO.setFlag(goodsSpec.getFlag());
mallProdInfoDO.setSkuUnitId(goodsSpec.getSkuUnitId());
return mallProdInfoDO;
}
@Transactional(rollbackFor = Exception.class)
......@@ -113,14 +139,14 @@ public class GoodsInfoServiceImpl implements GoodsInfoService {
.setProductName(productSpec.getProductName()).setCustomize(1)
.setDirectoryId(goodsInfo.getDirectoryId());
// 插入产品sku信息
productSkuDao.insertProductSku(productSkuDO);
productDao.insertProductSku(productSkuDO);
// 先将自定的信息存储到数据库中
List<ProductSpecDO> customizeSpec = productSpec.getCustomizeInfo().stream().map(param -> {
ProductSpecDO productSpecDO = new ProductSpecDO().setProductSkuId(productSkuDO.getId())
.setVersionDesc("自定义").setSpecImage(param.getSpecImage())
.setSpecName(param.getSpecName()).setPartNo(param.getPartNo());
// 新增产品sku
productSkuDao.insertProductSpec(productSpecDO);
productDao.insertProductSpec(productSpecDO);
// 批量配置价格信息
ProductSpecCPQVO productSpecCPQVO = param.getProductSpecCPQVO();
if (productSpecCPQVO != null) {
......@@ -130,10 +156,10 @@ public class GoodsInfoServiceImpl implements GoodsInfoService {
return productSpecDO;
}).collect(Collectors.toList());
List<Integer> ids = customizeSpec.stream().map(ProductSpecDO::getId).collect(Collectors.toList());
MallProdSkuInfoDO mallProdSkuInfoDO = buildMallProdSkuInfo(goodsInfo, productSpec, productSkuDO.getId());
mallProdSkuInfoDO.setProductSpecIdList(ids.stream().map(String::valueOf).collect(Collectors.joining(",")));
MallProdInfoDO mallProdInfoDO = buildMallProdSkuInfo(goodsInfo, productSpec, productSkuDO.getId());
mallProdInfoDO.setProductSpecIdList(ids.stream().map(String::valueOf).collect(Collectors.joining(",")));
// 插入数据库商品对应的sku信息
productSkuDao.insertMallProdSkuInfo(mallProdSkuInfoDO);
productDao.insertMallProdSkuInfo(mallProdInfoDO);
}
}
......@@ -198,11 +224,100 @@ public class GoodsInfoServiceImpl implements GoodsInfoService {
updateImageInfo(goodsAddVO);
// 修改其他服务信息
updateOtherService(goodsAddVO);
// 修改规格信息
if (!goodsAddVO.getDirectoryId().equals(2)) {
updateMallProductSkuSpec(goodsAddVO);
} else {
updateMallIndustrySkuSpec(goodsAddVO);
}
return null;
}
private void updateOtherService(GoodsAddVO goodsAddVO) {
@Transactional(rollbackFor = Exception.class)
public void updateMallIndustrySkuSpec(GoodsAddVO goodsAddVO) {
// 从数据库获取该商品对应绑定的skuId的集合
List<MallIndustrySkuInfoDO> mallIndusSkuInfoList = goodsInfoDao.getMallIndustrySkuInfo(goodsAddVO.getId());
List<Integer> skuIds = mallIndusSkuInfoList.stream().map(MallIndustrySkuInfoDO::getId).collect(Collectors.toList());
// 先删除所有商品绑定sku及spec信息
industrySpecDao.batchUpdateMallIndustrySpec(skuIds, goodsAddVO.getId());
industrySpecDao.batchUpdateMallIndustrySku(skuIds);
List<GoodsProdSpecVO> list = goodsAddVO.getProductSpec().stream().collect(Collectors.toList());
industrySkuSpecOperation(new GoodsInfo(goodsAddVO.getId()), list);
}
@Transactional(rollbackFor = Exception.class)
public void updateMallProductSkuSpec(GoodsAddVO goodsAddVO) {
// 1、普通的sku修改逻辑
List<GoodsProdSpecVO> specInfo = goodsAddVO.getProductSpec().stream().filter(spec -> !spec.getFlag().equals(1)).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(specInfo)) {
// 1.1先获取用户输入的商品绑定sku的id集合
List<GoodsProdSpecVO> updateGoodsSpec = specInfo.stream().filter(d -> d.getId() != null).collect(Collectors.toList());
List<Integer> inputMallSkuIds = updateGoodsSpec.stream().map(GoodsProdSpecVO::getId).collect(Collectors.toList());
// 1.2从数据库获取该商品对应绑定的skuId的集合
List<MallProdInfoDO> mallProSkuInfoList = goodsInfoDao.getMallProSkuInfo(goodsAddVO.getId());
List<Integer> dbMallSkuIds = mallProSkuInfoList.stream().map(MallProdInfoDO::getId).collect(Collectors.toList());
// 对比数据库id如果不在就删除
List<Integer> delIds = dbMallSkuIds.stream().filter(id -> !inputMallSkuIds.contains(id)).collect(Collectors.toList());
if (delIds.size() != 0) {
goodsInfoDao.batchUpdateMallProductSku(delIds);
}
// 用途:修改商品规格前选项来源保留一份快照
Map<Integer, MallProdInfoDO> mallProSkuInfoMap = mallProSkuInfoList.stream().collect(Collectors.toMap(MallProdInfoDO::getId, Function.identity()));
// 修改商品绑定的sku信息
List<MallProdInfoDO> mallProdSkuInfoList = updateGoodsSpec.stream().map(d -> {
MallProdInfoDO mallProdSkuInfoById = mallProSkuInfoMap.get(d.getId());
MallProdInfoDO mallProdInfoDO = new MallProdInfoDO();
mallProdInfoDO.setId(d.getId()).setProdSkuId(d.getSkuId())
.setCategoriesId(d.getCategoryId()).setProdSkuSpecName(d.getGoodsSpecName())
.setChooseType(d.getChooseType()).setSkuUnitId(d.getSkuUnitId()).setMust(d.getMust())
.setProductSpecIdList(d.getSpecIds().stream().map(String::valueOf).collect(Collectors.joining(",")))
.setBeforeUpdateSpec(mallProdSkuInfoById.getProductSpecIdList());
return mallProdInfoDO;
}).collect(Collectors.toList());
// 1.3批量修改sku的信息
goodsInfoDao.batchUpdateMallProdSkuInfo(mallProdSkuInfoList);
// 1.4对新的sku进行操作
List<GoodsProdSpecVO> list = specInfo.stream().filter(d -> d.getId() == null).collect(Collectors.toList());
productSkuSpecOperation(new GoodsInfo(goodsAddVO.getId()), list);
// 2、对自定义的sku进行操作
List<GoodsProdSpecVO> zdySpecInfo = goodsAddVO.getProductSpec().stream().filter(spec -> spec.getFlag().equals(1)).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(zdySpecInfo)) {
updateCustomize(zdySpecInfo, goodsAddVO.getId());
}
}
}
@Transactional(rollbackFor = Exception.class)
public void updateCustomize(List<GoodsProdSpecVO> zdySpecInfo, Integer id) {
// 2.1先获取自定义的sku及规格(原来有的)
List<GoodsProdSpecVO> zdySpec = zdySpecInfo.stream().filter(d -> d.getId() != null).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(zdySpec)) {
// 根据获取到的自定义sku及规格进行操作
List<MallProdInfoDO> zdySpecList = zdySpec.stream().map(d -> {
// 构建商品对应的sku信息
ProductSkuDO productSkuDO = new ProductSkuDO().setCategoriesId(d.getCategoryId())
.setProductName(d.getProductName()).setCustomize(1);
productDao.updateProductSku(productSkuDO);
if (CollectionUtils.isNotEmpty(d.getDelProductSpecId())) {
// 2.2删除这个sku下的spec
productDao.batchUpdateMallProdSpec(d.getDelProductSpecId());
}
List<Integer> zdySpecIds = d.getCustomizeInfo().stream().map(ProductSpecVO::getId).collect(Collectors.toList());
return new MallProdInfoDO(d).setId(d.getId()).setProdSkuId(d.getSkuId())
.setProductSpecIdList(zdySpecIds.stream().map(String::valueOf).collect(Collectors.joining(",")));
}).collect(Collectors.toList());
// 批量修改sku的信息
goodsInfoDao.batchUpdateMallProdSkuInfo(zdySpecList);
}
// 2.2 新增新的自定义规格信息
List<GoodsProdSpecVO> newZdySpec = zdySpecInfo.stream().filter(d -> d.getId() == null).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(newZdySpec)) {
productSkuSpecOperation(new GoodsInfo(id), newZdySpec);
}
}
@Transactional(rollbackFor = Exception.class)
public void updateOtherService(GoodsAddVO goodsAddVO) {
// 删除其他服务
goodsInfoDao.deleteGoodsServiceByGoodsId(goodsAddVO.getId());
// 插入其他服务
......
package com.mmc.pms.service.Impl;
import com.mmc.pms.common.ResultBody;
import com.mmc.pms.common.ResultEnum;
import com.mmc.pms.dao.BrandManageDao;
import com.mmc.pms.dao.IndustrySpecDao;
import com.mmc.pms.dao.ProductDao;
import com.mmc.pms.entity.*;
import com.mmc.pms.model.dto.*;
import com.mmc.pms.model.qo.IndustrySkuQO;
import com.mmc.pms.model.vo.GoodsProductSkuVO;
import com.mmc.pms.model.vo.IndustrySkuVO;
import com.mmc.pms.model.vo.IndustrySpecVO;
import com.mmc.pms.page.PageResult;
import com.mmc.pms.service.IndustrySpecService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
/**
* @Author LW
* @date 2022/10/8 10:58
* 概要:
*/
@Service
public class IndustrySpecServiceImpl implements IndustrySpecService {
@Autowired
IndustrySpecDao industrySpecDao;
@Autowired
ProductDao productDao;
@Autowired
private BrandManageDao brandManageDao;
@Override
public ResultBody addIndustrySku(IndustrySkuVO param) {
// 获取名称判断此前是否已经存在
int count = industrySpecDao.countSkuName(param);
if (count > 0) {
return ResultBody.error(ResultEnum.GOODS_CATEGORY_NAME_EXIST_ERROR);
}
IndustrySku industrySku = new IndustrySku(param);
// 新增产品sku
int status = industrySpecDao.insertIndustrySku(industrySku);
if (status <= 0) {
return ResultBody.error(ResultEnum.FAILED_TO_ADD_DATA);
}
return ResultBody.success();
}
@Override
public ResultBody getIndustrySkuDetail(Integer id) {
// 判断此sku是否还存在
int count = industrySpecDao.countIndustrySkuById(id);
if (count <= 0) {
return ResultBody.error(ResultEnum.SKU_DOES_NOT_EXIST_OR_HAS_BEEN_DELETED);
}
IndustrySku IndustrySku = industrySpecDao.getIndustrySkuById(id);
return ResultBody.success(IndustrySku.buildIndustrySku());
}
@Override
public ResultBody editIndustrySku(IndustrySkuVO param) {
// 判断此sku是否还存在
int count = industrySpecDao.countIndustrySkuById(param.getId());
if (count <= 0) {
return ResultBody.error(ResultEnum.SKU_DOES_NOT_EXIST_OR_HAS_BEEN_DELETED);
}
// 获取名称判断此前是否已经存在
int skuNameCount = industrySpecDao.countSkuName(param);
if (skuNameCount > 0) {
return ResultBody.error(ResultEnum.GOODS_CATEGORY_NAME_EXIST_ERROR);
}
IndustrySku IndustrySku = new IndustrySku(param);
// 新增产品sku
int status = industrySpecDao.updateIndustrySku(IndustrySku);
if (status <= 0) {
return ResultBody.error(ResultEnum.FAILED_TO_EDIT_DATA);
}
return ResultBody.success();
}
@Override
public ResultBody listPageIndustrySku(IndustrySkuQO param) {
int count = industrySpecDao.countListPageIndustrySku(param);
if (count == 0) {
return ResultBody.success(PageResult.buildPage(param.getPageNo(), param.getPageSize(), count));
}
Integer pageNo = param.getPageNo();
param.buildCurrentPage();
List<IndustrySku> industrySkuList = industrySpecDao.listPageIndustrySku(param);
return ResultBody.success(PageResult.buildPage(pageNo, param.getPageSize(), count,
industrySkuList.stream()
.map(IndustrySku::buildIndustrySkuDTO)
.collect(Collectors.toList())));
}
/**
* 新增方案规格
*
* @param param
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class)
public ResultBody addIndustrySpec(IndustrySpecVO param) {
// 获取名称判断此前是否已经存在
int count = industrySpecDao.countSpecName(param);
if (count > 0) {
return ResultBody.error(ResultEnum.GOODS_CATEGORY_NAME_EXIST_ERROR);
}
// 新增规格表信息
IndustrySpecDO industrySpecDO = new IndustrySpecDO(param);
int status = industrySpecDao.insertIndustrySpec(industrySpecDO);
if (status <= 0) {
return ResultBody.error(ResultEnum.FAILED_TO_ADD_DATA);
}
// 新增规格绑定产品sku表信息
addInventorySpec(param, industrySpecDO);
return ResultBody.success();
}
private void addInventorySpec(IndustrySpecVO param, IndustrySpecDO industrySpecDO) {
for (ProductInventoryVO d : param.getProductInventoryList()) {
IndustryProductInventoryDO industryProductInventoryDO = new IndustryProductInventoryDO(d);
industryProductInventoryDO.setIndustrySpecId(industrySpecDO.getId());
industrySpecDao.insertIndustryProductInventory(industryProductInventoryDO);
// 新增清单绑定的产品规格信息
// 判断该sku是否指定产品规格 0:未指定 1:指定
if (d.getSelect().equals(0)) {
// 如果是表示不指定则要添加所有对sku下的所有产品规格
// 先查出该sku下的所有规格信息
List<ProductSpecDO> productSpecList = productDao.listProductSpec(d.getProductSku().getId());
// 批量插入
for (ProductSpecDO productSpecDO : productSpecList) {
InventorySpecDO inventorySpecDO = new InventorySpecDO();
inventorySpecDO.setIndustryProductInventoryId(industryProductInventoryDO.getId());
inventorySpecDO.setProductSpecId(productSpecDO.getId());
inventorySpecDO.setProductSkuId(productSpecDO.getProductSkuId());
industrySpecDao.insertInventorySpec(inventorySpecDO);
}
} else {
// 指定的直接拿指定的数据
for (ProductSpecVO productSpecVO : d.getProductSpecList()) {
InventorySpecDO inventorySpecDO = new InventorySpecDO();
inventorySpecDO.setIndustryProductInventoryId(industryProductInventoryDO.getId());
inventorySpecDO.setProductSpecId(productSpecVO.getId());
inventorySpecDO.setProductSkuId(productSpecVO.getProductSkuId());
industrySpecDao.insertInventorySpec(inventorySpecDO);
}
}
}
}
/**
* 获取行业规格信息
*
* @param industrySpecId
* @return
*/
@Override
public ResultBody getIndustrySpecDetail(Integer industrySpecId) {
// 查询当前行业规格是否存在
int count = industrySpecDao.countIndustrySpec(industrySpecId);
if (count <= 0) {
return ResultBody.error(ResultEnum.SPEC_DOES_NOT_EXIST_OR_HAS_BEEN_DELETED);
}
// 初始化行业规格DTO
IndustrySpecDTO industrySpecDTO;
// 获取行业规格的基本信息
IndustrySpecDO industrySpec = industrySpecDao.getIndustrySpecById(industrySpecId);
industrySpecDTO = industrySpec.buildIndustrySpecDTO();
// 获取这个规格下的产品sku信息
List<IndustryProductInventoryDO> industryProductInventory = industrySpecDao.getIndustryProductInventory(industrySpecId);
// 获取产品skuId
List<Integer> productSkuId = industryProductInventory.stream().map(IndustryProductInventoryDO::getProductSkuId).collect(Collectors.toList());
// 分别查出产品sku的详细信息
List<ProductSkuDO> productSkuList = productDao.listProductSkuDO(productSkuId);
// 查出产品sku对应的品牌的信息
Set<Integer> brandInfoIds = productSkuList.stream().map(ProductSkuDO::getBrandInfoId).collect(Collectors.toSet());
List<BrandInfoDO> brandInfoList = brandManageDao.listBrandInfoByIds(brandInfoIds);
// 拿到行业产品清单id的集合
List<Integer> industryProductInventoryIds = industryProductInventory.stream().map(IndustryProductInventoryDO::getId).collect(Collectors.toList());
// 再分别查出产品规格id
List<InventorySpecDO> inventorySpecList = productDao.listInventorySpecInfo(industryProductInventoryIds);
if (inventorySpecList.size() != 0) {
// 获取所有产品规格id
List<Integer> productSpecIds = inventorySpecList.stream().map(InventorySpecDO::getProductSpecId).collect(Collectors.toList());
// 根据这些规格id查询规格信息
List<ProductSpecDO> productSpecInfoList = productDao.listProductSpecInfo(productSpecIds);
// 构建产品规格信息
List<ProductSpecVO> productSpecList = productSpecInfoList.stream().map(d -> {
ProductSpecVO productSpecVO = new ProductSpecVO();
productSpecVO.setSpecImage(d.getSpecImage());
productSpecVO.setProductSkuId(d.getProductSkuId());
productSpecVO.setSpecName(d.getSpecName());
productSpecVO.setId(d.getId());
productSpecVO.setPartNo(d.getPartNo());
productSpecVO.setVersionDesc(d.getVersionDesc());
return productSpecVO;
}).collect(Collectors.toList());
// 根据产品skuId分组
Map<Integer, List<ProductSpecVO>> maps = productSpecList.stream().collect(Collectors.groupingBy(ProductSpecVO::getProductSkuId));
// 构建其余产品清单的信息
List<ProductInventoryVO> list = new ArrayList<>();
for (IndustryProductInventoryDO d : industryProductInventory) {
for (ProductSkuDO e : productSkuList) {
GoodsProductSkuVO goodsProductSkuVO = new GoodsProductSkuVO();
goodsProductSkuVO.setId(d.getId());
goodsProductSkuVO.setProductName(e.getProductName());
for (BrandInfoDO b : brandInfoList) {
if (e.getBrandInfoId().equals(b.getId())) {
goodsProductSkuVO.setProductBrand(b.getBrandName());
break;
}
}
goodsProductSkuVO.setGoodsTypeId(e.getCategoriesId());
goodsProductSkuVO.setModel(e.getModel());
ProductInventoryVO productInventoryVO = new ProductInventoryVO();
productInventoryVO.setProductSku(goodsProductSkuVO);
if (d.getProductSkuId().equals(e.getId())) {
// 匹配分组之后id相等的数据构建到ProductInventoryVO对象中
List<ProductSpecVO> productSpecVOS = maps.get(e.getId());
productInventoryVO.setProductSpecList(productSpecVOS);
productInventoryVO.setSelect(d.getSelected());
productInventoryVO.setProductSkuId(d.getProductSkuId());
list.add(productInventoryVO);
}
}
}
// 组装产品清单
industrySpecDTO.setProductInventoryList(list);
}
return ResultBody.success(industrySpecDTO);
}
/**
* 编辑行业规格信息
*
* @param param
* @return
*/
@Override
public ResultBody editIndustrySpec(IndustrySpecVO param) {
int count = industrySpecDao.countIndustrySpec(param.getId());
if (count <= 0) {
return ResultBody.error(ResultEnum.SPEC_DOES_NOT_EXIST_OR_HAS_BEEN_DELETED);
}
// 获取名称判断此前是否已经存在
int countName = industrySpecDao.countSpecName(param);
if (countName > 0) {
return ResultBody.error(ResultEnum.GOODS_CATEGORY_NAME_EXIST_ERROR);
}
// 修改行业规格基本信息
IndustrySpecDO industrySpecDO = new IndustrySpecDO(param);
int status = industrySpecDao.updateIndustrySpec(industrySpecDO);
if (status <= 0) {
return ResultBody.error(ResultEnum.FAILED_TO_EDIT_DATA);
}
// 先获取绑定的的产品skuId
List<IndustryProductInventoryDO> industryProductInventory = industrySpecDao.getIndustryProductInventory(param.getId());
List<Integer> industryProductInventoryIds = industryProductInventory.stream().map(IndustryProductInventoryDO::getId).collect(Collectors.toList());
// 批量删除原来绑定的产品规格信息
if (industryProductInventoryIds.size() != 0) {
industrySpecDao.batchDeleteInventorySpec(industryProductInventoryIds);
}
// 批量删除绑定的产品sku信息
industrySpecDao.deleteIndustryProductInventory(param.getId());
// 新增规格绑定产品sku表信息
addInventorySpec(param, industrySpecDO);
return ResultBody.success();
}
/**
* 列表页面行业规范
*
* @param pageNo 页面没有
* @param pageSize 页面大小
* @param industrySkuId 行业sku id
* @param keyword 关键字
* @return {@link ResultBody}
*/
@Override
public ResultBody listPageIndustrySpec(Integer pageNo, Integer pageSize, Integer industrySkuId, String keyword) {
int count = industrySpecDao.countListPageIndustrySpec(industrySkuId, keyword);
if (count == 0) {
return ResultBody.success(PageResult.buildPage(pageNo, pageSize, count));
}
List<IndustrySpecDO> industrySpecList = industrySpecDao.listPageIndustrySpec((pageNo - 1) * pageSize, pageSize, industrySkuId, keyword);
List<IndustrySpecDTO> list = industrySpecList.stream().map(IndustrySpecDO::buildIndustrySpecDTO).collect(Collectors.toList());
return ResultBody.success(PageResult.buildPage(pageNo, pageSize, count, list));
}
/**
* 行业规格价格配置
*
* @param industrySpecCPQQ
* @return
*/
@Override
public ResultBody industrySpecCPQ(IndustrySpecCPQVO industrySpecCPQQ) {
// 判断该规格是否存在
int count = industrySpecDao.countIndustrySpec(industrySpecCPQQ.getIndustrySpecId());
if (count <= 0) {
return ResultBody.error(ResultEnum.SPEC_DOES_NOT_EXIST_OR_HAS_BEEN_DELETED);
}
// 批量插入规格价格
insertSpecPrice(industrySpecCPQQ);
return ResultBody.success();
}
private List<IndustrySpecPriceDO> getIndustrySpecPriceDOS(IndustrySpecCPQVO industrySpecCPQQ) {
// 批量插入规格价格
return industrySpecCPQQ.getSpecPrice().stream().map(d -> {
IndustrySpecPriceDO industrySpecPriceDO = new IndustrySpecPriceDO();
industrySpecPriceDO.setCooperationTag(d.getCooperationTag());
industrySpecPriceDO.setType(industrySpecCPQQ.getType());
industrySpecPriceDO.setPrice(d.getPrice());
if (industrySpecCPQQ.getType().equals(1)) {
industrySpecPriceDO.setLeaseTerm(industrySpecCPQQ.getLeaseTerm());
}
industrySpecPriceDO.setIndustrySpecId(industrySpecCPQQ.getIndustrySpecId());
return industrySpecPriceDO;
}).collect(Collectors.toList());
}
/**
* 行业规格价格配置修改
*
* @param industrySpecCPQQ
* @return
*/
@Override
public ResultBody updateIndustrySpecCPQ(IndustrySpecCPQVO industrySpecCPQQ) {
// 先删除原来该规格下的所有价格配置信息
industrySpecDao.removeIndustrySpecCPQ(industrySpecCPQQ);
// 批量插入规格价格
insertSpecPrice(industrySpecCPQQ);
return ResultBody.success();
}
public ResultBody insertSpecPrice(IndustrySpecCPQVO industrySpecCPQQ) {
List<IndustrySpecPriceDO> list = getIndustrySpecPriceDOS(industrySpecCPQQ);
// 批量插入规格价格
if (industrySpecCPQQ.getType().equals(0)) {
int status = industrySpecDao.batchInsertSpecPrice(list);
if (status <= 0) {
return ResultBody.error(ResultEnum.FAILED_TO_ADD_DATA);
}
} else {
// 批量插入租赁价格
industrySpecDao.batchInsertLeaseSpecPrice(list);
}
return ResultBody.success();
}
/**
* 获取配置价格信息
*
* @param industrySpecCPQQ 行业规范
* @return {@link ResultBody}
*/
@Override
public ResultBody getIndustrySpecCPQ(IndustrySpecCPQVO industrySpecCPQQ) {
if (industrySpecCPQQ.getType().equals(1) && industrySpecCPQQ.getLeaseTerm() == null) {
return ResultBody.error("租赁期限不能为空!");
}
List<IndustrySpecPriceDO> industrySpecPriceList = industrySpecDao.getIndustrySpecCPQ(industrySpecCPQQ);
List<IndustrySpecPriceDTO> list = industrySpecPriceList.stream()
.map(IndustrySpecPriceDO::buildIndustrySpecPriceDTO).collect(Collectors.toList());
return ResultBody.success(list);
}
@Override
public ResultBody removeIndustrySku(Integer id) {
// 查询该sku下是否有行业规格存在
int specCount = industrySpecDao.countIndustrySpecBySkuId(id);
if (specCount <= 0) {
// 删除
industrySpecDao.removeIndustrySku(id);
return ResultBody.success();
} else {
return ResultBody.error(ResultEnum.SPEC_EXIST_UNDER_THE_SKU);
}
}
/**
* 删除行业规格
*
* @param id id
* @return {@link ResultBody}
*/
@Override
public ResultBody removeIndustrySpec(Integer id) {
// 判断该规格是否存在
int count = industrySpecDao.countIndustrySpec(id);
if (count <= 0) {
return ResultBody.error(ResultEnum.SPEC_DOES_NOT_EXIST_OR_HAS_BEEN_DELETED);
}
// 获取该规格下绑定的商品的信息
RemoveSkuDTO removeSkuDTO = new RemoveSkuDTO();
List<MallIndustrySkuInfoSpecDO> mallIndustrySkuInfoSpecList = industrySpecDao.listMallIndustrySpec(id);
if (mallIndustrySkuInfoSpecList.size() != 0) {
List<String> goodsName = new ArrayList<>();
mallIndustrySkuInfoSpecList.forEach(d -> goodsName.add(d.getGoodsName()));
removeSkuDTO.setGoodsName(goodsName);
return ResultBody.success(removeSkuDTO);
} else {
// 根据规格id获取规格清单绑定的信息
List<IndustryProductInventoryDO> industryProductInventory = industrySpecDao.getIndustryProductInventory(id);
if (industryProductInventory.size() != 0) {
// 删除行业绑定的清单
industrySpecDao.removeIndustryProductInventory(industryProductInventory.stream().map(IndustryProductInventoryDO::getId).collect(Collectors.toList()));
List<Integer> ids = industryProductInventory.stream().map(IndustryProductInventoryDO::getId).collect(Collectors.toList());
List<InventorySpecDO> inventorySpecList = industrySpecDao.listInventorySpec(ids);
// 删除
industrySpecDao.removeInventorySpec(inventorySpecList.stream().map(InventorySpecDO::getId).collect(Collectors.toList()));
}
industrySpecDao.removeIndustrySpec(id);
return ResultBody.success();
}
}
//
// @Override
// public List<IndustrySpecPriceDTO> listAppGoodsPriceByTagId(Integer goodsInfoId, Integer tagInfoId) {
// List<IndustrySpecPriceDO> industrySpecPriceDOS = industrySpecDao.listAppGoodsPriceByTagId(goodsInfoId, tagInfoId);
// if (CollectionUtils.isEmpty(industrySpecPriceDOS)) {
// return null;
// }
// List<IndustrySpecPriceDTO> collect = industrySpecPriceDOS.stream().map(IndustrySpecPriceDO::buildIndustrySpecPriceDTO).collect(Collectors.toList());
// return collect;
// }
}
......@@ -72,7 +72,7 @@ public class MiniProgramProductMallServiceImpl implements MiniProgramProductMall
// 判断商品是什么类型
if (!goodsInfoDO.getSortTypeId().equals(2)) {
// 获取该商品绑定的sku信息
List<MallProdSkuInfoDO> mallProdSkuInfo = goodsInfoDao.getMallProdInfoByGoodsId(goodsId);
List<MallProdInfoDO> mallProdSkuInfo = goodsInfoDao.getMallProdInfoByGoodsId(goodsId);
// 获取该商品绑定的规格信息
List<MallProdSkuInfoSpecDO> mallProdSkuInfoSpecList =
goodsInfoDao.listMallProdSkuInfoSpec(goodsId);
......@@ -114,7 +114,7 @@ public class MiniProgramProductMallServiceImpl implements MiniProgramProductMall
.setGoodsSpecName(d.getProdSkuSpecName())
.setSkuName(d.getProductSkuName())
.setBrandInfoId(d.getBrandInfoId())
.setGoodsTypeId(d.getCategoryId())
.setGoodsTypeId(d.getCategoriesId())
.setTypeName(d.getTypeName())
.setChooseType(d.getChooseType())
.setSkuUnitId(d.getSkuUnitId())
......
......@@ -2,10 +2,9 @@ package com.mmc.pms.service.Impl;
import com.mmc.pms.common.ResultBody;
import com.mmc.pms.common.ResultEnum;
import com.mmc.pms.dao.ProductSkuDao;
import com.mmc.pms.entity.ProductSkuDO;
import com.mmc.pms.entity.ProductSpecDO;
import com.mmc.pms.entity.ProductSpecPriceDO;
import com.mmc.pms.dao.IndustrySpecDao;
import com.mmc.pms.dao.ProductDao;
import com.mmc.pms.entity.*;
import com.mmc.pms.model.dto.*;
import com.mmc.pms.model.qo.ProductSkuQO;
import com.mmc.pms.model.vo.ProductSpecCPQVO;
......@@ -15,7 +14,9 @@ import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
/**
......@@ -24,20 +25,22 @@ import java.util.stream.Collectors;
* @createDate 2023-05-25 14:55:56
*/
@Service
public class ProductSkuServiceImpl implements ProductSkuService {
public class ProductServiceImpl implements ProductSkuService {
@Autowired
private ProductSkuDao productSkuDao;
private ProductDao productDao;
@Autowired
private IndustrySpecDao industrySpecDao;
@Override
public ResultBody addProductSku(ProductSkuVO param) {
// 获取名称判断此前是否已经存在
int count = productSkuDao.countSkuName(param);
int count = productDao.countSkuName(param);
if (count > 0) {
return ResultBody.error(ResultEnum.GOODS_CATEGORY_NAME_EXIST_ERROR);
}
ProductSkuDO productSkuDO = new ProductSkuDO(param);
// 新增产品sku
int status = productSkuDao.insertProductSku(productSkuDO);
int status = productDao.insertProductSku(productSkuDO);
if (status <= 0) {
return ResultBody.error(ResultEnum.FAILED_TO_ADD_DATA);
}
......@@ -47,23 +50,23 @@ public class ProductSkuServiceImpl implements ProductSkuService {
@Override
public ResultBody getProductSkuDetail(Integer id) {
// 校验此sku是否还存在或已删除
int count = productSkuDao.countSkuIsExist(id);
int count = productDao.countSkuIsExist(id);
if (count <= 0) {
return ResultBody.error(ResultEnum.SKU_DOES_NOT_EXIST_OR_HAS_BEEN_DELETED);
}
ProductSkuDO productSkuDO = productSkuDao.getProductSkuDetail(id);
ProductSkuDO productSkuDO = productDao.getProductSkuDetail(id);
return ResultBody.success(productSkuDO.buildProductSkuDTO());
}
@Override
public ResultBody editProductSku(ProductSkuVO param) {
// 获取名称判断此前是否已经存在
int count = productSkuDao.countSkuName(param);
int count = productDao.countSkuName(param);
if (count > 0) {
return ResultBody.error(ResultEnum.GOODS_CATEGORY_NAME_EXIST_ERROR);
}
ProductSkuDO productSkuDO = new ProductSkuDO(param);
int status = productSkuDao.updateProductSku(productSkuDO);
int status = productDao.updateProductSku(productSkuDO);
if (status <= 0) {
return ResultBody.error(ResultEnum.FAILED_TO_EDIT_DATA);
}
......@@ -72,13 +75,13 @@ public class ProductSkuServiceImpl implements ProductSkuService {
@Override
public ResultBody listPageProductSku(ProductSkuQO productSkuQO) {
int count = productSkuDao.countListPageProductSku(productSkuQO);
int count = productDao.countListPageProductSku(productSkuQO);
if (count == 0) {
return ResultBody.success(PageResult.buildPage(productSkuQO.getPageNo(), productSkuQO.getPageSize(), count));
}
Integer pageNo = productSkuQO.getPageNo();
productSkuQO.buildCurrentPage();
List<ProductSkuDO> productSkuList = productSkuDao.listPageProductSku(productSkuQO);
List<ProductSkuDO> productSkuList = productDao.listPageProductSku(productSkuQO);
List<ProductSkuDTO> list = productSkuList.stream().map(ProductSkuDO::buildProductSkuDTO).collect(Collectors.toList());
return ResultBody.success(PageResult.buildPage(pageNo, productSkuQO.getPageSize(), count, list));
}
......@@ -86,20 +89,20 @@ public class ProductSkuServiceImpl implements ProductSkuService {
@Override
public ResultBody addOrEditProductSpec(ProductSpecVO param) {
// 获取名称判断此前是否已经存在
int count = productSkuDao.countSpecName(param);
int count = productDao.countSpecName(param);
if (count > 0) {
return ResultBody.error(ResultEnum.GOODS_CATEGORY_NAME_EXIST_ERROR);
}
if (param.getId() == null) {
ProductSpecDO productSpecDO = new ProductSpecDO(param);
// 新增产品sku
int status = productSkuDao.insertProductSpec(productSpecDO);
int status = productDao.insertProductSpec(productSpecDO);
if (status <= 0) {
return ResultBody.error(ResultEnum.FAILED_TO_ADD_DATA);
}
} else {
ProductSpecDO productSpecDO = new ProductSpecDO(param);
int status = productSkuDao.updateProductSpec(productSpecDO);
int status = productDao.updateProductSpec(productSpecDO);
if (status <= 0) {
return ResultBody.error(ResultEnum.FAILED_TO_EDIT_DATA);
}
......@@ -110,21 +113,21 @@ public class ProductSkuServiceImpl implements ProductSkuService {
@Override
public ResultBody getProductSpecDetail(Integer id) {
// 校验此sku是否还存在或已删除
int count = productSkuDao.countSpecIsExist(id);
int count = productDao.countSpecIsExist(id);
if (count <= 0) {
return ResultBody.error(ResultEnum.SPEC_DOES_NOT_EXIST_OR_HAS_BEEN_DELETED);
}
ProductSpecDO productSpecDO = productSkuDao.getProductSpecDetail(id);
ProductSpecDO productSpecDO = productDao.getProductSpecDetail(id);
return ResultBody.success(productSpecDO.buildProductSpecDTO());
}
@Override
public ResultBody listPageProductSpec(Integer pageNo, Integer pageSize, Integer productSkuId) {
int count = productSkuDao.countListPageProductSpec(productSkuId);
int count = productDao.countListPageProductSpec(productSkuId);
if (count == 0) {
return ResultBody.success(PageResult.buildPage(pageNo, pageSize, count));
}
List<ProductSpecDO> productSpecList = productSkuDao.listPageProductSpec((pageNo - 1) * pageSize, pageSize, productSkuId);
List<ProductSpecDO> productSpecList = productDao.listPageProductSpec((pageNo - 1) * pageSize, pageSize, productSkuId);
List<ProductSpecDTO> list = productSpecList.stream().map(ProductSpecDO::buildProductSpecDTO).collect(Collectors.toList());
return ResultBody.success(PageResult.buildPage(pageNo, pageSize, count, list));
}
......@@ -132,7 +135,7 @@ public class ProductSkuServiceImpl implements ProductSkuService {
@Override
public ResultBody productSpecCPQ(ProductSpecCPQVO productSpecCPQVO) {
// 判断该规格是否存在
int count = productSkuDao.countSpecIsExist(productSpecCPQVO.getProductSpecId());
int count = productDao.countSpecIsExist(productSpecCPQVO.getProductSpecId());
if (count <= 0) {
return ResultBody.error(ResultEnum.SPEC_DOES_NOT_EXIST_OR_HAS_BEEN_DELETED);
}
......@@ -159,7 +162,7 @@ public class ProductSkuServiceImpl implements ProductSkuService {
@Override
public ResultBody updateProductSpecCPQ(ProductSpecCPQVO productSpecCPQVO) {
// 先删除原来该规格下的所有价格配置信息
productSkuDao.removeProductSpecCPQ(productSpecCPQVO);
productDao.removeProductSpecCPQ(productSpecCPQVO);
// 批量插入规格销售或租赁价格
return insertSpecPrice(productSpecCPQVO);
}
......@@ -169,13 +172,13 @@ public class ProductSkuServiceImpl implements ProductSkuService {
List<ProductSpecPriceDO> list = getProductSpecPriceDOS(productSpecCPQVO);
// 批量插入规格销售价格
if (productSpecCPQVO.getType().equals(0)) {
int status = productSkuDao.batchInsertSpecPrice(list);
int status = productDao.batchInsertSpecPrice(list);
if (status <= 0) {
return ResultBody.error(ResultEnum.FAILED_TO_ADD_DATA);
}
} else {
// 批量插入租赁价格
productSkuDao.batchInsertLeaseSpecPrice(list);
productDao.batchInsertLeaseSpecPrice(list);
}
return ResultBody.success();
}
......@@ -186,11 +189,62 @@ public class ProductSkuServiceImpl implements ProductSkuService {
if (productSpecCPQVO.getType().equals(1) && productSpecCPQVO.getLeaseTerm() == null) {
return ResultBody.error("租赁期限不能为空!");
}
List<ProductSpecPriceDO> productSpecPriceList = productSkuDao.getProductSpecPrice(productSpecCPQVO);
List<ProductSpecPriceDO> productSpecPriceList = productDao.getProductSpecPrice(productSpecCPQVO);
List<ProductSpecPriceDTO> list = productSpecPriceList.stream()
.map(ProductSpecPriceDO::buildProductSpecPriceDTO).collect(Collectors.toList());
return ResultBody.success(list);
}
@Override
public ResultBody removeProductSku(Integer id) {
// 判断该sku下是否有规格,没有则删除,有则不能删除
int specCount = productDao.countSpecByProdSkuId(id);
if (specCount <= 0) {
// 删除
productDao.removeProductSku(id);
return ResultBody.success();
} else {
return ResultBody.error(ResultEnum.SPEC_EXIST_UNDER_THE_SKU);
}
}
@Override
public ResultBody removeProductSpec(Integer id) {
// 根据规格id查询绑定的商品或者行业的sku
RemoveSkuDTO removeSkuDTO = new RemoveSkuDTO();
List<MallProdInfoDO> mallProdSkuInfoSpecList = productDao.listMallProdInfo(id.toString());
// 拿到清单的id
List<InventorySpecDO> inventorySpecList = productDao.listInventorySpec(id);
if (mallProdSkuInfoSpecList.size() != 0 || inventorySpecList.size() != 0) {
if (inventorySpecList.size() != 0) {
// 根据清单id 获取行业规格id
Set<Integer> inventoryIds = inventorySpecList.stream().map(InventorySpecDO::getIndustryProductInventoryId).collect(Collectors.toSet());
List<IndustryProductInventoryDO> industryProductInventoryList = industrySpecDao.listIndustryProdInventory(inventoryIds);
// 获取行业规格id
Set<Integer> industrySpecIds = industryProductInventoryList.stream().map(IndustryProductInventoryDO::getIndustrySpecId).collect(Collectors.toSet());
// 分别获取规格对应的sku信息
List<IndustrySpecDO> industrySpecList = productDao.listIndustrySpec(industrySpecIds);
List<SkuAndSpecDTO> industrySkuNameList = new ArrayList<>();
industrySpecList.stream().peek(d -> {
SkuAndSpecDTO skuAndSpecDTO = new SkuAndSpecDTO();
skuAndSpecDTO.setIndustrySkuName(d.getSolutionName());
skuAndSpecDTO.setIndustrySpecNames(d.getSpecName());
industrySkuNameList.add(skuAndSpecDTO);
}).collect(Collectors.toList());
removeSkuDTO.setIndustrySkuName(industrySkuNameList);
}
if (mallProdSkuInfoSpecList.size() != 0) {
// 获取商品名称
List<String> goodsNameList = new ArrayList<>();
mallProdSkuInfoSpecList.forEach(d -> goodsNameList.add(d.getGoodsName()));
removeSkuDTO.setGoodsName(goodsNameList);
}
return ResultBody.success(removeSkuDTO);
} else {
productDao.removeProductSpec(id);
return ResultBody.success();
}
}
}
......
package com.mmc.pms.service;
import com.mmc.pms.common.ResultBody;
import com.mmc.pms.model.dto.IndustrySpecCPQVO;
import com.mmc.pms.model.qo.IndustrySkuQO;
import com.mmc.pms.model.vo.IndustrySkuVO;
import com.mmc.pms.model.vo.IndustrySpecVO;
/**
* @Author LW
* @date 2022/10/8 10:58
* 概要:
*/
public interface IndustrySpecService {
ResultBody addIndustrySku(IndustrySkuVO param);
ResultBody getIndustrySkuDetail(Integer id);
ResultBody editIndustrySku(IndustrySkuVO param);
ResultBody listPageIndustrySku(IndustrySkuQO param);
ResultBody addIndustrySpec(IndustrySpecVO param);
ResultBody getIndustrySpecDetail(Integer industrySpecId);
ResultBody editIndustrySpec(IndustrySpecVO param);
ResultBody listPageIndustrySpec(Integer pageNo, Integer pageSize, Integer industrySkuId, String keyword);
ResultBody industrySpecCPQ(IndustrySpecCPQVO industrySpecCPQQ);
ResultBody updateIndustrySpecCPQ(IndustrySpecCPQVO industrySpecCPQQ);
ResultBody getIndustrySpecCPQ(IndustrySpecCPQVO industrySpecCPQQ);
ResultBody removeIndustrySku(Integer id);
ResultBody removeIndustrySpec(Integer id);
// /**
// * 行业sku分页列表
// *
// * @param param
// * @return
// */
// ResultBody listPageIndustrySku(IndustrySkuQO param);
//
// /**
// * 新增方案规格
// *
// * @param param
// * @return
// */
// ResultBody addIndustrySpec(IndustrySpecVO param);
//
// /**
// * 获取行业规格信息
// *
// * @param industrySpecId
// * @return
// */
// ResultBody getIndustrySpecDetail(Integer industrySpecId);
//
// /**
// * 编辑行业规格信息
// *
// * @param param
// * @return
// */
// ResultBody editIndustrySpec(IndustrySpecVO param);
//
//
// /**
// * 列表页面行业规范
// *
// * @param pageNo 页面没有
// * @param pageSize 页面大小
// * @param industrySkuId 行业sku id
// * @param keyword 关键字
// * @return {@link ResultBody}
// */
// ResultBody listPageIndustrySpec(Integer pageNo, Integer pageSize, Integer industrySkuId, String keyword);
//
// /**
// * 行业规格价格配置
// *
// * @param industrySpecCPQQ
// * @return
// */
// ResultBody industrySpecCPQ(IndustrySpecCPQVO industrySpecCPQQ);
//
// /**
// * 行业规格价格配置修改
// *
// * @param industrySpecCPQQ
// * @return
// */
// ResultBody updateIndustrySpecCPQ(IndustrySpecCPQVO industrySpecCPQQ);
//
// /**
// * 获取配置价格信息
// *
// * @param industrySpecId
// * @return
// */
// ResultBody getIndustrySpecCPQ(Integer industrySpecId);
//
//
// /**
// * 删除行业sku
// *
// * @param id id
// * @return {@link ResultBody}
// */
// ResultBody removeIndustrySku(Integer id);
//
// /**
// * 删除行业规范
// *
// * @param id id
// * @return {@link ResultBody}
// */
// ResultBody removeIndustrySpec(Integer id);
//
// /**
// * 根据商品id和渠道id查询商品价格
// *
// * @param goodsInfoId
// * @param tagInfoId
// * @return
// */
// List<IndustrySpecPriceDTO> listAppGoodsPriceByTagId(Integer goodsInfoId, Integer tagInfoId);
}
......@@ -38,4 +38,7 @@ public interface ProductSkuService {
ResultBody getProductSpecCPQ(ProductSpecCPQVO productSpecCPQVO);
ResultBody removeProductSku(Integer id);
ResultBody removeProductSpec(Integer id);
}
......@@ -2,7 +2,7 @@ spring:
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://rm-wz9dd796t4j1giz6t2o.mysql.rds.aliyuncs.com:3306/iuav_pms?characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
url: jdbc:mysql://rm-wz9dd796t4j1giz6t2o.mysql.rds.aliyuncs.com:3306/iuav_pms_dev?characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
username: tmj
password: MMC@2022&MYSQL
redis:
......
......@@ -52,6 +52,17 @@
)
</foreach>
</insert>
<insert id="insertMallIndustrySkuInfo" useGeneratedKeys="true"
keyProperty="id" parameterType="com.mmc.pms.entity.MallIndustrySkuInfoDO">
insert into mall_industry_sku_info(goods_info_id, industry_sku_id, industry_sku_spec_name, choose_type,
sku_unit_id, categories_id, is_must)
values (#{goodsInfoId}, #{industrySkuId}, #{industrySkuSpecName}, #{chooseType}, #{skuUnitId}, #{categoriesId},
#{must})
</insert>
<insert id="insertMallIndustrySkuInfoSpec">
insert into mall_industry_sku_info_spec(mall_industry_sku_info_id, industry_spec_id, goods_info_id)
values (#{mallIndustrySkuInfoId}, #{industrySpecId}, #{goodsInfoId})
</insert>
<update id="updateGoodsInfo">
update goods_info
......@@ -80,6 +91,32 @@
set is_deleted = 1
where goods_info_id = #{goodsId}
</update>
<update id="batchUpdateMallProductSku">
<foreach collection="list" item="d" separator=";">
update mall_prod_info
set is_deleted = 1
where id = #{d}
and is_deleted = 0
</foreach>
</update>
<update id="batchUpdateMallProdSkuInfo">
<foreach collection="list" item="d" separator=";">
update mall_prod_info
<set>
prod_sku_id = #{d.prodSkuId},
categories_id = #{d.categoriesId},
prod_spec_name = #{d.prodSkuSpecName},
choose_type = #{d.chooseType},
sku_unit_id = #{d.skuUnitId},
is_must = #{d.must},
product_spec_id_list = #{d.productSpecIdList},
before_update_spec = #{d.beforeUpdateSpec}
</set>
<where>
id = #{d.id}
</where>
</foreach>
</update>
<delete id="deleteGoodsServiceByGoodsId">
delete
from goods_service
......@@ -113,4 +150,46 @@
WHERE is_deleted = 0
AND goods_info_id = #{id}
</select>
<select id="getMallProSkuInfo" resultType="com.mmc.pms.entity.MallProdInfoDO">
SELECT mi.id,
mi.goods_info_id,
mi.prod_sku_id,
mi.prod_spec_name,
mi.categories_id,
mi.choose_type,
mi.sku_unit_id,
mi.is_must,
mi.product_spec_id_list,
mi.before_update_spec,
mi.flag,
mi.create_time createTime,
c.type_name typeName,
su.id skuUnitId,
su.unit_name unitName,
ps.product_name productSkuName
FROM mall_prod_info mi
INNER JOIN categories c ON c.id = mi.categories_id
INNER JOIN sku_unit su ON mi.sku_unit_id = su.id
INNER JOIN product ps ON ps.id = mi.prod_sku_id
WHERE mi.goods_info_id = #{id}
AND mi.is_deleted = 0
</select>
<select id="getMallIndustrySkuInfo" resultType="com.mmc.pms.entity.MallIndustrySkuInfoDO">
SELECT mi.id,
mi.industry_sku_id industrySkuId,
mi.industry_sku_spec_name industrySkuSpecName,
mi.choose_type chooseType,
mi.sku_unit_id skuUnitId,
mi.categories_id categoriesId,
mi.is_must must,
gt.type_name typeName,
su.unit_name unitName,
ins.solution_name industrySkuName
FROM mall_industry_sku_info mi
INNER JOIN categories gt ON gt.id = mi.categories_id
INNER JOIN sku_unit su ON su.id = mi.sku_unit_id
INNER JOIN industry_sku ins ON mi.industry_sku_id = ins.id
WHERE mi.goods_info_id = #{id}
AND mi.is_deleted = 0
</select>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.mmc.pms.dao.IndustrySpecDao">
<insert id="insertIndustrySku">
insert into industry_sku (solution_name, categories_id, description)
values (#{solutionName}, #{categoriesId}, #{description})
</insert>
<insert id="insertIndustrySpec">
insert into industry_spec (industry_sku_id, spec_name, spec_image)
values (#{industrySkuId}, #{specName}, #{specImage})
</insert>
<insert id="insertIndustryProductInventory">
insert into industry_product_inventory (industry_spec_id, product_id, is_selected)
values (#{industrySpecId}, #{productSkuId}, #{selected})
</insert>
<insert id="insertInventorySpec">
insert into inventory_spec (industry_product_inventory_id, product_spec_id, product_id)
values (#{industryProductInventoryId}, #{productSpecId}, #{productSkuId})
</insert>
<insert id="batchInsertSpecPrice">
insert into industry_spec_price (industry_spec_id,tag_info_id,price,`type`)
values
<foreach collection="list" item="item" separator=",">
(#{item.industrySpecId},#{item.tagInfoId},#{item.price},#{item.type})
</foreach>
</insert>
<insert id="batchInsertLeaseSpecPrice">
insert into industry_spec_price (industry_spec_id,tag_info_id,price,`type`,lease_term)
values
<foreach collection="list" item="item" separator=",">
(#{item.industrySpecId},#{item.tagInfoId},#{item.price},#{item.type},#{item.leaseTerm})
</foreach>
</insert>
<update id="updateIndustrySku">
update industry_sku
set solution_name = #{solutionName},
categories_id = #{categoriesId},
description = #{description}
where id = #{id}
</update>
<update id="updateIndustrySpec">
update industry_spec
set spec_name = #{specName},
spec_image = #{specImage}
where id = #{id}
</update>
<update id="batchUpdateMallIndustrySpec">
<foreach collection="list" separator=";" item="d">
update mall_industry_sku_info_spec
set is_deleted = 1
where mall_industry_sku_info_id = #{d}
and goods_info_id =#{id}
and is_deleted = 0
</foreach>
</update>
<update id="batchUpdateMallIndustrySku">
<foreach collection="list" item="d" separator=";">
update mall_industry_sku_info
set is_deleted = 1
where id = #{d}
and is_deleted = 0
</foreach>
</update>
<update id="batchUpdateMallIndustrySkuInfo">
<foreach collection="list" item="d" separator=";">
update mall_industry_sku_info
<set>
industry_sku_id = #{d.industrySkuId},
categories_id = #{d.categoriesId},
industry_sku_spec_name = #{d.industrySkuSpecName},
choose_type = #{d.chooseType},
sku_unit_id = #{d.skuUnitId},
is_must = #{d.must}
</set>
<where>
id = #{d.id}
</where>
</foreach>
</update>
<update id="batchUpdateMallIndustSpec">
<foreach collection="list" item="d" separator=";">
update mall_industry_sku_info_spec
set is_deleted = 1
where id = #{d} and goods_info_id = #{id}
and is_deleted = 0
</foreach>
</update>
<update id="removeIndustrySku">
update industry_sku
set is_deleted = 1
where id = #{id}
</update>
<update id="removeIndustryProductInventory">
<foreach collection="list" item="item" index="index" open="" close="" separator=";">
update industry_product_inventory
set is_deleted = 1
where id = #{item}
</foreach>
</update>
<update id="removeInventorySpec">
<foreach collection="list" item="item" index="index" open="" close="" separator=";">
update inventory_spec
set is_deleted = 1
where id = #{item}
</foreach>
</update>
<update id="removeIndustrySpec">
update industry_spec
set is_deleted = 1
where id = #{id}
</update>
<delete id="batchDeleteInventorySpec">
delete from inventory_spec where industry_product_inventory_id in
<foreach collection="list" item="id" separator="," open="(" close=")">
#{id}
</foreach>
</delete>
<delete id="deleteIndustryProductInventory">
delete
from industry_product_inventory
where industry_spec_id = #{id}
</delete>
<delete id="removeIndustrySpecCPQ">
DELETE
FROM industry_spec_price
WHERE industry_spec_id = #{id}
and `type` = #{type}
</delete>
<select id="countSkuName" resultType="java.lang.Integer">
select count(*) from industry_sku
where solution_name = #{solutionName} and is_deleted = 0
<if test="id !=null and id !=''">
and id <![CDATA[<>]]> #{id}
</if>
</select>
<select id="countIndustrySkuById" resultType="java.lang.Integer">
select count(*)
from industry_sku
where id = #{id}
and is_deleted = 0
</select>
<select id="getIndustrySkuById" resultType="com.mmc.pms.entity.IndustrySku">
SELECT id,
solution_name,
categories_id,
description,
create_time
FROM industry_sku
WHERE id = #{id}
</select>
<select id="countListPageIndustrySku" resultType="java.lang.Integer">
select count(*) from industry_sku
<where>
is_deleted = 0
<if test="solutionName != null and solutionName != ''">
and solution_name like CONCAT('%',#{solutionName},'%')
</if>
<if test="goodsTypeId != null">
and categories_id like CONCAT('%',#{categoryId},'%')
</if>
</where>
</select>
<select id="listPageIndustrySku" resultType="com.mmc.pms.entity.IndustrySku">
SELECT
ps.id,
ps.solution_name,
ps.categories_id,
ps.description,
ps.create_time,
c.type_name typeName
FROM
industry_sku ps
INNER JOIN categories c ON ps.categories_id = c.id
<where>
ps.is_deleted = 0
<if test="solutionName != null and solutionName != ''">
and ps.solution_name like CONCAT('%',#{solutionName},'%')
</if>
<if test="goodsTypeId != null">
and ps.goods_type_id like CONCAT('%',#{categoryId},'%')
</if>
</where>
order by ps.create_time desc
limit #{pageNo},#{pageSize}
</select>
<select id="countSpecName" resultType="java.lang.Integer">
select count(*) from industry_spec
where spec_name = #{specName} and is_deleted = 0
<if test="id !=null and id !=''">
and id <![CDATA[<>]]> #{id}
</if>
<if test="industrySkuId !=null and industrySkuId !=''">
and industry_sku_id = #{industrySkuId}
</if>
</select>
<select id="countIndustrySpec" resultType="java.lang.Integer">
select count(*)
from industry_spec
where id = #{industrySpecId}
and is_deleted = 0
</select>
<select id="getIndustrySpecById" resultType="com.mmc.pms.entity.IndustrySpecDO">
SELECT id,
industry_sku_id industrySkuId,
spec_name specName,
spec_image specImage,
create_time createTime
FROM industry_spec
WHERE id = #{id}
AND is_deleted = 0
</select>
<select id="getIndustryProductInventory" resultType="com.mmc.pms.service.Impl.IndustryProductInventoryDO">
SELECT id,
industry_spec_id industrySpecId,
product_id productSkuId,
is_selected selected
FROM industry_product_inventory
WHERE industry_spec_id = #{id}
AND is_deleted = 0
</select>
<select id="countListPageIndustrySpec" resultType="java.lang.Integer">
select count(*)
from industry_spec
<where>
is_deleted = 0
and industry_sku_id = #{id}
<if test="keyword != null and keyword !=''">
and spec_name like CONCAT('%',#{keyword},'%')
</if>
</where>
</select>
<select id="listPageIndustrySpec" resultType="com.mmc.pms.entity.IndustrySpecDO">
select id,
industry_sku_id industrySkuId,
spec_name specName,
spec_image specImage,
create_time createTime
from industry_spec
<where>
is_deleted = 0
and industry_sku_id = #{industrySkuId}
<if test="keyword != null and keyword !=''">
and spec_name like CONCAT('%',#{keyword},'%')
</if>
</where>
order by create_time desc
limit #{pageNo}, #{pageSize}
</select>
<select id="getIndustrySpecCPQ" resultType="com.mmc.pms.entity.IndustrySpecPriceDO">
select id,
industry_spec_id industrySpecId,
cooperation_tag cooperationTag,
price,
create_time createTime,
lease_term
from industry_spec_price
<where>
industry_spec_id = #{industrySpecId}
and `type` =#{type}
<if test="leaseTerm != null">
and lease_term = #{leaseTerm}
</if>
</where>
</select>
<select id="listMallIndustrySpecInfo" resultType="com.mmc.pms.entity.MallIndustrySkuInfoSpecDO">
select id, goods_info_id goodsInfoId, mall_industry_sku_info_id mallIndustrySkuInfoId, industry_spec_id
industrySpecId
from mall_industry_sku_info_spec
where mall_industry_sku_info_id in
<foreach collection="list" separator="," item="d" open="(" close=")" index="index">
#{d}
</foreach>
</select>
<select id="listInventorySpec" resultType="com.mmc.pms.entity.InventorySpecDO">
select id, industry_product_inventory_id industryProductInventoryId, product_spec_id productSpecId
from inventory_spec
where industry_product_inventory_id in (
<foreach collection="list" separator="," index="index" item="d">
#{d}
</foreach>)
</select>
<select id="listIndustryProdInventory" resultType="com.mmc.pms.service.Impl.IndustryProductInventoryDO">
SELECT
id,
industry_spec_id industrySpecId,
product_id productSkuId
FROM
industry_product_inventory
WHERE
id IN (
<foreach collection="inventoryIds" index="index" item="id" separator=",">
#{id}
</foreach>
)
AND is_deleted = 0
</select>
<select id="listIndustrySpec" resultType="com.mmc.pms.entity.IndustrySpecDO">
SELECT
ins.id,
ins.industry_sku_id industrySkuId,
ins.spec_image specImage,
ins.spec_name specName,
inds.solution_name solutionName
FROM
industry_spec ins
INNER JOIN industry_sku inds ON ins.industry_sku_id = inds.id
WHERE
ins.id IN (
<foreach collection="industrySpecIds" separator="," item="id" index="index">
#{id}
</foreach>
)
AND ins.is_deleted = 0
</select>
<select id="countIndustrySpecBySkuId" resultType="java.lang.Integer">
select count(*)
from industry_spec
where industry_sku_id = #{id}
and is_deleted = 0
</select>
<select id="listMallIndustrySpec" resultType="com.mmc.pms.entity.MallIndustrySkuInfoSpecDO">
SELECT mi.id,
mi.goods_info_id goodsInfoId,
gi.goods_name goodsName
FROM mall_industry_sku_info_spec mi
INNER JOIN goods_info gi ON mi.goods_info_id = gi.id
WHERE mi.industry_spec_id = #{id}
AND mi.is_deleted = 0
AND gi.is_deleted = 0
</select>
</mapper>
\ No newline at end of file
......@@ -121,21 +121,21 @@
AND is_deleted = 0
</select>
<select id="getMallProdInfoByGoodsId" resultType="com.mmc.pms.entity.MallProdSkuInfoDO">
<select id="getMallProdInfoByGoodsId" resultType="com.mmc.pms.entity.MallProdInfoDO">
SELECT mp.id,
mp.prod_sku_id prodSkuId,
mp.prod_sku_spec_name prodSkuSpecName,
mp.goods_type_id goodsTypeId,
mp.choose_type chooseType,
mp.is_must must,
mp.sku_unit_id skuUnitId,
su.unit_name unitName,
ps.product_name productSkuName,
ps.brand_info_id brandInfoId,
gt.type_name typeName
FROM mall_prod_sku_info mp
mp.prod_sku_id prodSkuId,
mp.prod_spec_name prodSkuSpecName,
mp.goods_type_id goodsTypeId,
mp.choose_type chooseType,
mp.is_must must,
mp.sku_unit_id skuUnitId,
su.unit_name unitName,
ps.product_name productSkuName,
ps.brand_info_id brandInfoId,
gt.type_name typeName
FROM mall_prod_info mp
INNER JOIN sku_unit su ON su.id = mp.sku_unit_id
INNER JOIN product_sku ps ON ps.id = mp.prod_sku_id
INNER JOIN product ps ON ps.id = mp.prod_sku_id
LEFT JOIN goods_type gt ON mp.goods_type_id = gt.id
WHERE mp.goods_info_id = #{goodsId}
AND mp.is_deleted = 0
......@@ -153,7 +153,7 @@
<select id="listProductSpecInfo" resultType="com.mmc.pms.entity.ProductSpecDO">
SELECT
id,
product_sku_id productSkuId,
product_id productSkuId,
spec_name specName,
spec_image specImage,
part_no partNo,
......@@ -318,7 +318,7 @@
<select id="getIndustryProductInventory" resultType="com.mmc.pms.service.Impl.IndustryProductInventoryDO">
SELECT id,
industry_spec_id industrySpecId,
product_sku_id productSkuId,
product_id productSkuId,
is_selected selected
FROM industry_product_inventory
WHERE industry_spec_id = #{industrySpecId}
......@@ -336,12 +336,12 @@
<select id="getProductSpecDetail" resultType="com.mmc.pms.entity.ProductSpecDO">
select id,
product_sku_id productSkuId,
spec_name specName,
spec_image specImage,
part_no partNo,
version_desc versionDesc,
create_time createTime
product_id productSkuId,
spec_name specName,
spec_image specImage,
part_no partNo,
version_desc versionDesc,
create_time createTime
from product_spec
where id = #{id}
</select>
......@@ -356,7 +356,7 @@
bi.brand_name productBrand,
ps.sort_type_id sortTypeId,
st.sort_name sortName
FROM product_sku ps
FROM product ps
INNER JOIN goods_type gt ON ps.goods_type_id = gt.id
LEFT JOIN brand_info bi ON bi.id = ps.brand_info_id
LEFT JOIN sort_type st ON ps.goods_type_id = st.id
......
......@@ -2,15 +2,15 @@
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.mmc.pms.dao.ProductSkuDao">
<mapper namespace="com.mmc.pms.dao.ProductDao">
<insert id="insertProductSku" parameterType="com.mmc.pms.entity.ProductSkuDO"
useGeneratedKeys="true" keyProperty="id">
insert into product_sku (product_name, categories_id, model, brand_info_id, directory_id)
insert into product (product_name, categories_id, model, brand_info_id, directory_id)
values (#{productName}, #{categoriesId}, #{model}, #{brandInfoId}, #{directoryId})
</insert>
<insert id="insertProductSpec" keyProperty="id" useGeneratedKeys="true"
parameterType="com.mmc.pms.entity.ProductSpecDO">
insert into product_spec (product_sku_id, spec_name, spec_image, part_no, version_desc)
insert into product_spec (product_id, spec_name, spec_image, part_no, version_desc)
values (#{productSkuId}, #{specName}, #{specImage}, #{partNo}, #{versionDesc})
</insert>
<insert id="batchInsertSpecPrice" useGeneratedKeys="true"
......@@ -29,13 +29,13 @@
</foreach>
</insert>
<insert id="insertMallProdSkuInfo">
insert into mall_prod_sku_info (goods_info_id, prod_sku_id, prod_sku_spec_name, category_id, choose_type,
sku_unit_id, is_must, product_spec_id_list, flag)
insert into mall_prod_info (goods_info_id, prod_sku_id, prod_spec_name, category_id, choose_type,
sku_unit_id, is_must, product_spec_id_list, flag)
values (#{goodsInfoId}, #{prodSkuId}, #{prodSkuSpecName}, #{categoryId}, #{chooseType}, #{skuUnitId}, #{must},
#{productSpecIdList}, #{flag})
</insert>
<update id="updateProductSku">
update product_sku
update product
set product_name = #{productName},
categories_id = #{categoriesId},
model = #{model},
......@@ -44,13 +44,29 @@
</update>
<update id="updateProductSpec">
update product_spec
set spec_name = #{specName},
spec_image = #{specImage},
part_no = #{partNo},
version_desc = #{versionDesc},
product_sku_id = #{productSkuId}
set spec_name = #{specName},
spec_image = #{specImage},
part_no = #{partNo},
version_desc = #{versionDesc},
product_id = #{productSkuId}
where id = #{id}
</update>
<update id="removeProductSku">
update product
set is_deleted = 1
where id = #{id}
</update>
<update id="removeProductSpec">
update product_spec
set is_deleted = 1
where id = #{id}
</update>
<delete id="batchUpdateMallProdSpec">
<foreach collection="list" item="d" separator=";">
delete from product_spec
where id = #{d}
</foreach>
</delete>
<delete id="removeProductSpecCPQ">
DELETE
FROM product_spec_price
......@@ -59,7 +75,7 @@
</delete>
<select id="countSkuName" resultType="java.lang.Integer">
select count(*) from product_sku
select count(*) from product
where product_name = #{productName} and is_deleted = 0
<if test="id !=null and id !=''">
and id <![CDATA[<>]]> #{id}
......@@ -67,7 +83,7 @@
</select>
<select id="countSkuIsExist" resultType="java.lang.Integer">
select count(*)
from product_sku
from product
where id = #{id}
and is_deleted = 0
</select>
......@@ -79,14 +95,14 @@
c.`name` categoryName,
d.directory_name directoryName,
bi.brand_name brandName
FROM product_sku ps
FROM product ps
INNER JOIN categories c ON ps.categories_id = c.id
INNER JOIN `directory` d ON ps.directory_id = d.id
LEFT JOIN brand_info bi ON ps.brand_info_id = bi.id
WHERE ps.id = #{id}
</select>
<select id="countListPageProductSku" resultType="java.lang.Integer">
select count(*) from product_sku
select count(*) from product
<where>
is_deleted = 0
and customize <![CDATA[<>]]> 1
......@@ -115,7 +131,7 @@
d.directory_name directoryName,
bi.brand_name brandName
FROM
product_sku ps
product ps
INNER JOIN categories c ON ps.categories_id = c.id
INNER JOIN `directory` d ON ps.directory_id = d.id
LEFT JOIN brand_info bi ON ps.brand_info_id = bi.id
......@@ -137,7 +153,7 @@
</select>
<select id="countSpecName" resultType="java.lang.Integer">
select count(*) from product_spec
where spec_name = #{specName} and is_deleted = 0 and product_sku_id = #{productSkuId}
where spec_name = #{specName} and is_deleted = 0 and product_id = #{productSkuId}
<if test="id !=null and id !=''">
and id <![CDATA[<>]]> #{id}
</if>
......@@ -150,12 +166,12 @@
</select>
<select id="getProductSpecDetail" resultType="com.mmc.pms.entity.ProductSpecDO">
select id,
product_sku_id productSkuId,
spec_name specName,
spec_image specImage,
part_no partNo,
version_desc versionDesc,
create_time createTime
product_id productSkuId,
spec_name specName,
spec_image specImage,
part_no partNo,
version_desc versionDesc,
create_time createTime
from product_spec
where id = #{id}
</select>
......@@ -163,19 +179,19 @@
select count(*)
from product_spec
where is_deleted = 0
and product_sku_id = #{id}
and product_id = #{id}
</select>
<select id="listPageProductSpec" resultType="com.mmc.pms.entity.ProductSpecDO">
select id,
product_sku_id productSkuId,
spec_name specName,
spec_image specImage,
part_no partNo,
version_desc versionDesc,
create_time createTime
product_id productSkuId,
spec_name specName,
spec_image specImage,
part_no partNo,
version_desc versionDesc,
create_time createTime
from product_spec
where is_deleted = 0
and product_sku_id = #{productSkuId}
and product_id = #{productSkuId}
order by create_time desc
limit #{pageNo}, #{pageSize}
</select>
......@@ -195,4 +211,111 @@
</if>
</where>
</select>
<select id="listProductSpec" resultType="com.mmc.pms.entity.ProductSpecDO">
select id,
product_id,
spec_name,
spec_image,
part_no,
version_desc,
create_time
from product_spec
where is_deleted = 0
and product_id = #{productSkuId}
</select>
<select id="listProductSkuDO" resultType="com.mmc.pms.entity.ProductSkuDO">
SELECT ps.id,
ps.product_name productName,
ps.model,
ps.product_brand productBrand,
ps.brand_info_id brandInfoId,
ps.create_time createTime,
c.id categoriesId,
c.type_name categoryName
FROM product ps
INNER JOIN categories c ON ps.goods_type_id = c.id
where ps.id in
<foreach collection="list" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</select>
<select id="listInventorySpecInfo" resultType="com.mmc.pms.entity.InventorySpecDO">
SELECT
id,
industry_product_inventory_id industryProductInventoryId,
product_spec_id productSpecId,
product_id productSkuId
FROM
inventory_spec
WHERE
industry_product_inventory_id IN
<foreach collection="list" separator="," open="(" close=")" item="item">
#{item}
</foreach>
AND is_deleted = 0
</select>
<select id="listProductSpecInfo" resultType="com.mmc.pms.entity.ProductSpecDO">
SELECT
id,
product_id productSkuId,
spec_name specName,
spec_image specImage,
part_no partNo,
version_desc versionDesc
FROM
product_spec
WHERE
id in
<foreach collection="list" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</select>
<select id="countProductSpecByBrandId" resultType="java.lang.Integer">
select count(*)
from product
where brand_info_id = #{id}
and is_deleted = 0
</select>
<select id="countSpecByProdSkuId" resultType="java.lang.Integer">
</select>
<select id="listMallProdInfo" resultType="com.mmc.pms.entity.MallProdInfoDO">
SELECT mp.id,
mp.goods_info_id,
mp.product_id,
mp.prod_spec_name,
gi.goods_name goodsName
FROM mall_prod_info mp
INNER JOIN goods_info gi ON mp.goods_info_id = gi.id
WHERE mp.product_spec_id_list LIKE CONCAT('%', #{id}, '%')
</select>
<select id="listIndustrySpec" resultType="com.mmc.pms.entity.IndustrySpecDO">
SELECT
ins.id,
ins.industry_sku_id industrySkuId,
ins.spec_image specImage,
ins.spec_name specName,
inds.solution_name solutionName
FROM
industry_spec ins
INNER JOIN industry_sku inds ON ins.industry_sku_id = inds.id
WHERE
ins.id IN (
<foreach collection="industrySpecIds" separator="," item="id" index="index">
#{id}
</foreach>
)
AND ins.is_deleted = 0
</select>
<select id="listInventorySpec" resultType="com.mmc.pms.entity.InventorySpecDO">
SELECT mp.id,
mp.goods_info_id goodsInfoId,
mp.mall_prod_info_id mallProdSkuInfoId,
gi.goods_name goodsName
FROM mall_prod_sku_info_spec mp
INNER JOIN goods_info gi ON gi.id = mp.goods_info_id
WHERE mp.product_spec_id = #{id}
AND mp.is_deleted = 0
AND gi.is_deleted = 0
</select>
</mapper>
......@@ -166,8 +166,8 @@
<select id="findProduct" resultType="java.lang.Integer">
SELECT count(1)
FROM goods_info gi
INNER JOIN mall_prod_sku_info mpsi ON mpsi.goods_info_id = gi.id
INNER JOIN product_sku ps ON mpsi.prod_sku_id = ps.id
INNER JOIN mall_prod_info mpsi ON mpsi.goods_info_id = gi.id
INNER JOIN product ps ON mpsi.prod_sku_id = ps.id
AND ps.is_deleted = 0
INNER JOIN brand_info bi ON ps.brand_info_id = bi.id
AND bi.is_delete = 0
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论