添加商品查询、添加、修改功能
This commit is contained in:
@@ -51,7 +51,7 @@ public class PmsBrandController {
|
||||
@ApiOperation(value = "更新品牌")
|
||||
@RequestMapping(value = "/update/{id}", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public Object updateBrand(@PathVariable("id") Long id,
|
||||
public Object update(@PathVariable("id") Long id,
|
||||
@Validated @RequestBody PmsBrandParam pmsBrandParam,
|
||||
BindingResult result) {
|
||||
CommonResult commonResult;
|
||||
|
||||
@@ -2,16 +2,19 @@ package com.macro.mall.controller;
|
||||
|
||||
import com.macro.mall.dto.CommonResult;
|
||||
import com.macro.mall.dto.PmsProductParam;
|
||||
import com.macro.mall.dto.PmsProductQueryParam;
|
||||
import com.macro.mall.dto.PmsProductResult;
|
||||
import com.macro.mall.model.PmsProduct;
|
||||
import com.macro.mall.model.PmsProductVertifyRecord;
|
||||
import com.macro.mall.service.PmsProductService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品管理Controller
|
||||
@@ -35,4 +38,48 @@ public class PmsProductController {
|
||||
return new CommonResult().failed();
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation("根据商品id获取商品编辑信息")
|
||||
@RequestMapping(value = "/updateInfo/{id}", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public Object getUpdateInfo(@PathVariable Long id) {
|
||||
PmsProductResult productResult = productService.getUpdateInfo(id);
|
||||
return new CommonResult().success(productResult);
|
||||
}
|
||||
|
||||
@ApiOperation("更新商品")
|
||||
@RequestMapping(value = "/update/{id}", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public Object update(@PathVariable Long id, @RequestBody PmsProductParam productParam, BindingResult bindingResult) {
|
||||
int count = productService.update(id, productParam);
|
||||
if (count > 0) {
|
||||
return new CommonResult().success(count);
|
||||
} else {
|
||||
return new CommonResult().failed();
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation("查询商品")
|
||||
@RequestMapping(value = "list", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public Object getList(PmsProductQueryParam productQueryParam,
|
||||
@RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
|
||||
@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum) {
|
||||
List<PmsProduct> productList = productService.list(productQueryParam, pageSize, pageNum);
|
||||
return new CommonResult().pageSuccess(productList);
|
||||
}
|
||||
|
||||
@ApiOperation("批量修改审核状态")
|
||||
@RequestMapping(value = "/update/verifyStatus",method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public Object updateVerifyStatus(@RequestParam("ids") List<Long> ids,
|
||||
@RequestParam("verifyStatus") Integer verifyStatus,
|
||||
@RequestParam("detail") String detail) {
|
||||
int count = productService.updateVerifyStatus(ids, verifyStatus, detail);
|
||||
if (count > 0) {
|
||||
return new CommonResult().success(count);
|
||||
} else {
|
||||
return new CommonResult().failed();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.macro.mall.controller;
|
||||
|
||||
import com.macro.mall.dto.CommonResult;
|
||||
import com.macro.mall.model.PmsSkuStock;
|
||||
import com.macro.mall.service.PmsSkuStockService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* sku库存Controller
|
||||
* Created by macro on 2018/4/27.
|
||||
*/
|
||||
@Api("sku商品库存管理")
|
||||
@Controller
|
||||
@RequestMapping("/sku")
|
||||
public class PmsSkuStockController {
|
||||
@Autowired
|
||||
private PmsSkuStockService skuStockService;
|
||||
@ApiOperation("根据商品编号及编号模糊搜索sku库存")
|
||||
@RequestMapping("/{id}")
|
||||
@ResponseBody
|
||||
public Object getList(@PathVariable Long id, @RequestParam("keyword") String keyword){
|
||||
List<PmsSkuStock> skuStockList = skuStockService.getList(id,keyword);
|
||||
return new CommonResult().success(skuStockList);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.macro.mall.dao;
|
||||
|
||||
import com.macro.mall.dto.PmsProductResult;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
|
||||
/**
|
||||
* 商品自定义Dao
|
||||
* Created by macro on 2018/4/26.
|
||||
*/
|
||||
public interface PmsProductDao {
|
||||
/**
|
||||
* 获取商品编辑信息
|
||||
*/
|
||||
PmsProductResult getUpdateInfo(@Param("id") Long id);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.macro.mall.dao;
|
||||
|
||||
import com.macro.mall.model.PmsProductVertifyRecord;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品审核日志自定义dao
|
||||
* Created by macro on 2018/4/27.
|
||||
*/
|
||||
public interface PmsProductVertifyRecordDao {
|
||||
int insertList(@Param("list") List<PmsProductVertifyRecord> list);
|
||||
}
|
||||
@@ -3,17 +3,13 @@ package com.macro.mall.dto;
|
||||
import com.macro.mall.model.*;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 创建和修改商品时使用的参数
|
||||
* Created by macro on 2018/4/26.
|
||||
*/
|
||||
public class PmsProductParam {
|
||||
@ApiModelProperty("商品信息")
|
||||
@NotNull(message = "商品信息不能为空")
|
||||
private PmsProduct product;
|
||||
public class PmsProductParam extends PmsProduct{
|
||||
@ApiModelProperty("商品阶梯价格设置")
|
||||
private List<PmsProductLadder> productLadderList;
|
||||
@ApiModelProperty("商品满减价格设置")
|
||||
@@ -29,14 +25,6 @@ public class PmsProductParam {
|
||||
@ApiModelProperty("优选专区和商品的关系")
|
||||
private List<CmsPrefrenceAreaProductRelation> prefrenceAreaProductRelationList;
|
||||
|
||||
public PmsProduct getProduct() {
|
||||
return product;
|
||||
}
|
||||
|
||||
public void setProduct(PmsProduct product) {
|
||||
this.product = product;
|
||||
}
|
||||
|
||||
public List<PmsProductLadder> getProductLadderList() {
|
||||
return productLadderList;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.macro.mall.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* 产品查询参数
|
||||
* Created by macro on 2018/4/27.
|
||||
*/
|
||||
public class PmsProductQueryParam {
|
||||
@ApiModelProperty("上架状态")
|
||||
private Integer publishStatus;
|
||||
@ApiModelProperty("审核状态")
|
||||
private Integer verifyStatus;
|
||||
@ApiModelProperty("商品名称模糊关键字")
|
||||
private String keyword;
|
||||
@ApiModelProperty("商品货号")
|
||||
private String productSn;
|
||||
@ApiModelProperty("商品分类编号")
|
||||
private Long productCategoryId;
|
||||
@ApiModelProperty("商品品牌编号")
|
||||
private Long brandId;
|
||||
|
||||
public Integer getPublishStatus() {
|
||||
return publishStatus;
|
||||
}
|
||||
|
||||
public void setPublishStatus(Integer publishStatus) {
|
||||
this.publishStatus = publishStatus;
|
||||
}
|
||||
|
||||
public Integer getVerifyStatus() {
|
||||
return verifyStatus;
|
||||
}
|
||||
|
||||
public void setVerifyStatus(Integer verifyStatus) {
|
||||
this.verifyStatus = verifyStatus;
|
||||
}
|
||||
|
||||
public String getKeyword() {
|
||||
return keyword;
|
||||
}
|
||||
|
||||
public void setKeyword(String keyword) {
|
||||
this.keyword = keyword;
|
||||
}
|
||||
|
||||
public String getProductSn() {
|
||||
return productSn;
|
||||
}
|
||||
|
||||
public void setProductSn(String productSn) {
|
||||
this.productSn = productSn;
|
||||
}
|
||||
|
||||
public Long getProductCategoryId() {
|
||||
return productCategoryId;
|
||||
}
|
||||
|
||||
public void setProductCategoryId(Long productCategoryId) {
|
||||
this.productCategoryId = productCategoryId;
|
||||
}
|
||||
|
||||
public Long getBrandId() {
|
||||
return brandId;
|
||||
}
|
||||
|
||||
public void setBrandId(Long brandId) {
|
||||
this.brandId = brandId;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.macro.mall.dto;
|
||||
|
||||
import com.macro.mall.model.CmsPrefrenceArea;
|
||||
import com.macro.mall.model.CmsSubject;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 查询单个产品进行修改时返回的结果
|
||||
* Created by macro on 2018/4/26.
|
||||
*/
|
||||
public class PmsProductResult extends PmsProductParam{
|
||||
private String feightTemplateName;
|
||||
private String productAttributeCategoryName;
|
||||
private List<CmsSubject> subjectList;
|
||||
private List<CmsPrefrenceArea> prefrenceAreaList;
|
||||
|
||||
public String getFeightTemplateName() {
|
||||
return feightTemplateName;
|
||||
}
|
||||
|
||||
public void setFeightTemplateName(String feightTemplateName) {
|
||||
this.feightTemplateName = feightTemplateName;
|
||||
}
|
||||
|
||||
public String getProductAttributeCategoryName() {
|
||||
return productAttributeCategoryName;
|
||||
}
|
||||
|
||||
public void setProductAttributeCategoryName(String productAttributeCategoryName) {
|
||||
this.productAttributeCategoryName = productAttributeCategoryName;
|
||||
}
|
||||
|
||||
public List<CmsSubject> getSubjectList() {
|
||||
return subjectList;
|
||||
}
|
||||
|
||||
public void setSubjectList(List<CmsSubject> subjectList) {
|
||||
this.subjectList = subjectList;
|
||||
}
|
||||
|
||||
public List<CmsPrefrenceArea> getPrefrenceAreaList() {
|
||||
return prefrenceAreaList;
|
||||
}
|
||||
|
||||
public void setPrefrenceAreaList(List<CmsPrefrenceArea> prefrenceAreaList) {
|
||||
this.prefrenceAreaList = prefrenceAreaList;
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package com.macro.mall.service;
|
||||
|
||||
import com.macro.mall.dto.PmsBrandParam;
|
||||
import com.macro.mall.model.PmsBrand;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -13,7 +14,7 @@ public interface PmsBrandService {
|
||||
List<PmsBrand> listAllBrand();
|
||||
|
||||
int createBrand(PmsBrandParam pmsBrandParam);
|
||||
|
||||
@Transactional
|
||||
int updateBrand(Long id, PmsBrandParam pmsBrandParam);
|
||||
|
||||
int deleteBrand(Long id);
|
||||
|
||||
@@ -14,7 +14,7 @@ import java.util.List;
|
||||
*/
|
||||
public interface PmsProductCategoryService {
|
||||
int create(PmsProductCategoryParam pmsProductCategoryParam);
|
||||
|
||||
@Transactional
|
||||
int update(Long id, PmsProductCategoryParam pmsProductCategoryParam);
|
||||
|
||||
List<PmsProductCategory> getList(Long parentId, Integer pageSize, Integer pageNum);
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
package com.macro.mall.service;
|
||||
|
||||
import com.macro.mall.dto.PmsProductParam;
|
||||
import com.macro.mall.dto.PmsProductQueryParam;
|
||||
import com.macro.mall.dto.PmsProductResult;
|
||||
import com.macro.mall.model.PmsProduct;
|
||||
import org.springframework.transaction.annotation.Isolation;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品管理Service
|
||||
* Created by macro on 2018/4/26.
|
||||
@@ -15,4 +20,29 @@ public interface PmsProductService {
|
||||
*/
|
||||
@Transactional(isolation = Isolation.DEFAULT,propagation = Propagation.REQUIRED)
|
||||
int create(PmsProductParam productParam);
|
||||
|
||||
/**
|
||||
* 根据商品编号获取更新信息
|
||||
*/
|
||||
PmsProductResult getUpdateInfo(Long id);
|
||||
|
||||
/**
|
||||
* 更新商品
|
||||
*/
|
||||
@Transactional
|
||||
int update(Long id, PmsProductParam productParam);
|
||||
|
||||
/**
|
||||
* 分页查询商品
|
||||
*/
|
||||
List<PmsProduct> list(PmsProductQueryParam productQueryParam, Integer pageSize, Integer pageNum);
|
||||
|
||||
/**
|
||||
* 批量修改审核状态
|
||||
* @param ids 产品id
|
||||
* @param verifyStatus 审核状态
|
||||
* @param detail 审核详情
|
||||
*/
|
||||
@Transactional
|
||||
int updateVerifyStatus(List<Long> ids, Integer verifyStatus, String detail);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.macro.mall.service;
|
||||
|
||||
import com.macro.mall.model.PmsSkuStock;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* sku商品库存管理Service
|
||||
* Created by macro on 2018/4/27.
|
||||
*/
|
||||
public interface PmsSkuStockService {
|
||||
/**
|
||||
* 根据产品id和skuCode模糊搜索
|
||||
*/
|
||||
List<PmsSkuStock> getList(Long pid, String keyword);
|
||||
}
|
||||
@@ -3,8 +3,11 @@ package com.macro.mall.service.impl;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.macro.mall.dto.PmsBrandParam;
|
||||
import com.macro.mall.mapper.PmsBrandMapper;
|
||||
import com.macro.mall.mapper.PmsProductMapper;
|
||||
import com.macro.mall.model.PmsBrand;
|
||||
import com.macro.mall.model.PmsBrandExample;
|
||||
import com.macro.mall.model.PmsProduct;
|
||||
import com.macro.mall.model.PmsProductExample;
|
||||
import com.macro.mall.service.PmsBrandService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -21,6 +24,8 @@ import java.util.List;
|
||||
public class PmsBrandServiceImpl implements PmsBrandService {
|
||||
@Autowired
|
||||
private PmsBrandMapper brandMapper;
|
||||
@Autowired
|
||||
private PmsProductMapper productMapper;
|
||||
|
||||
@Override
|
||||
public List<PmsBrand> listAllBrand() {
|
||||
@@ -47,6 +52,12 @@ public class PmsBrandServiceImpl implements PmsBrandService {
|
||||
if (StringUtils.isEmpty(pmsBrand.getFirstLetter())) {
|
||||
pmsBrand.setFirstLetter(pmsBrand.getName().substring(0, 1));
|
||||
}
|
||||
//更新品牌时要更新商品中的品牌名称
|
||||
PmsProduct product = new PmsProduct();
|
||||
product.setBrandName(pmsBrand.getName());
|
||||
PmsProductExample example = new PmsProductExample();
|
||||
example.createCriteria().andBrandIdEqualTo(id);
|
||||
productMapper.updateByExampleSelective(product,example);
|
||||
return brandMapper.updateByPrimaryKeySelective(pmsBrand);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,8 +3,11 @@ package com.macro.mall.service.impl;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.macro.mall.dto.PmsProductCategoryParam;
|
||||
import com.macro.mall.mapper.PmsProductCategoryMapper;
|
||||
import com.macro.mall.mapper.PmsProductMapper;
|
||||
import com.macro.mall.model.PmsProduct;
|
||||
import com.macro.mall.model.PmsProductCategory;
|
||||
import com.macro.mall.model.PmsProductCategoryExample;
|
||||
import com.macro.mall.model.PmsProductExample;
|
||||
import com.macro.mall.service.PmsProductCategoryService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -20,6 +23,8 @@ import java.util.List;
|
||||
public class PmsProductCategoryServiceImpl implements PmsProductCategoryService {
|
||||
@Autowired
|
||||
private PmsProductCategoryMapper productCategoryMapper;
|
||||
@Autowired
|
||||
private PmsProductMapper productMapper;
|
||||
|
||||
@Override
|
||||
public int create(PmsProductCategoryParam pmsProductCategoryParam) {
|
||||
@@ -36,6 +41,12 @@ public class PmsProductCategoryServiceImpl implements PmsProductCategoryService
|
||||
productCategory.setId(id);
|
||||
BeanUtils.copyProperties(pmsProductCategoryParam, productCategory);
|
||||
setCategoryLevel(productCategory);
|
||||
//更新商品分类时要更新商品中的名称
|
||||
PmsProduct product = new PmsProduct();
|
||||
product.setProductCategoryName(productCategory.getName());
|
||||
PmsProductExample example = new PmsProductExample();
|
||||
example.createCriteria().andProductCategoryIdEqualTo(id);
|
||||
productMapper.updateByExampleSelective(product,example);
|
||||
return productCategoryMapper.updateByPrimaryKeySelective(productCategory);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,17 +1,24 @@
|
||||
package com.macro.mall.service.impl;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.macro.mall.dao.*;
|
||||
import com.macro.mall.dto.PmsProductParam;
|
||||
import com.macro.mall.mapper.PmsProductMapper;
|
||||
import com.macro.mall.dto.PmsProductQueryParam;
|
||||
import com.macro.mall.dto.PmsProductResult;
|
||||
import com.macro.mall.mapper.*;
|
||||
import com.macro.mall.model.*;
|
||||
import com.macro.mall.service.PmsProductService;
|
||||
import io.swagger.annotations.Example;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -26,23 +33,41 @@ public class PmsProductServiceImpl implements PmsProductService {
|
||||
@Autowired
|
||||
private PmsMemberPriceDao memberPriceDao;
|
||||
@Autowired
|
||||
private PmsMemberPriceMapper memberPriceMapper;
|
||||
@Autowired
|
||||
private PmsProductLadderDao productLadderDao;
|
||||
@Autowired
|
||||
private PmsProductLadderMapper productLadderMapper;
|
||||
@Autowired
|
||||
private PmsProductFullReductionDao productFullReductionDao;
|
||||
@Autowired
|
||||
private PmsProductFullReductionMapper productFullReductionMapper;
|
||||
@Autowired
|
||||
private PmsSkuStockDao skuStockDao;
|
||||
@Autowired
|
||||
private PmsSkuStockMapper skuStockMapper;
|
||||
@Autowired
|
||||
private PmsProductAttributeValueDao productAttributeValueDao;
|
||||
@Autowired
|
||||
private PmsProductAttributeValueMapper productAttributeValueMapper;
|
||||
@Autowired
|
||||
private CmsSubjectProductRelationDao subjectProductRelationDao;
|
||||
@Autowired
|
||||
private CmsSubjectProductRelationMapper subjectProductRelationMapper;
|
||||
@Autowired
|
||||
private CmsPrefrenceAreaProductRelationDao prefrenceAreaProductRelationDao;
|
||||
@Autowired
|
||||
private CmsPrefrenceAreaProductRelationMapper prefrenceAreaProductRelationMapper;
|
||||
@Autowired
|
||||
private PmsProductDao productDao;
|
||||
@Autowired
|
||||
private PmsProductVertifyRecordDao productVertifyRecordDao;
|
||||
|
||||
@Override
|
||||
public int create(PmsProductParam productParam) {
|
||||
int count;
|
||||
//创建商品
|
||||
PmsProduct product = productParam.getProduct();
|
||||
PmsProduct product = productParam;
|
||||
product.setId(null);
|
||||
productMapper.insertSelective(product);
|
||||
//根据促销类型设置价格:、阶梯价格、满减价格
|
||||
@@ -65,6 +90,106 @@ public class PmsProductServiceImpl implements PmsProductService {
|
||||
return count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PmsProductResult getUpdateInfo(Long id) {
|
||||
return productDao.getUpdateInfo(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(Long id, PmsProductParam productParam) {
|
||||
int count;
|
||||
//更新商品信息
|
||||
PmsProduct product = productParam;
|
||||
product.setId(id);
|
||||
productMapper.updateByPrimaryKeySelective(product);
|
||||
//会员价格
|
||||
PmsMemberPriceExample pmsMemberPriceExample = new PmsMemberPriceExample();
|
||||
pmsMemberPriceExample.createCriteria().andProductIdEqualTo(id);
|
||||
memberPriceMapper.deleteByExample(pmsMemberPriceExample);
|
||||
relateAndInsertList(memberPriceDao,productParam.getMemberPriceList(),id);
|
||||
//阶梯价格
|
||||
PmsProductLadderExample ladderExample = new PmsProductLadderExample();
|
||||
ladderExample.createCriteria().andProductIdEqualTo(id);
|
||||
productLadderMapper.deleteByExample(ladderExample);
|
||||
relateAndInsertList(productLadderDao,productParam.getProductLadderList(),id);
|
||||
//满减价格
|
||||
PmsProductFullReductionExample fullReductionExample = new PmsProductFullReductionExample();
|
||||
fullReductionExample.createCriteria().andProductIdEqualTo(id);
|
||||
productFullReductionMapper.deleteByExample(fullReductionExample);
|
||||
relateAndInsertList(productFullReductionDao, productParam.getProductFullReductionList(), id);
|
||||
//修改sku库存信息
|
||||
PmsSkuStockExample skuStockExample = new PmsSkuStockExample();
|
||||
skuStockExample.createCriteria().andProductIdEqualTo(id);
|
||||
skuStockMapper.deleteByExample(skuStockExample);
|
||||
relateAndInsertList(skuStockDao, productParam.getSkuStockList(), id);
|
||||
//修改商品参数,添加自定义商品规格
|
||||
PmsProductAttributeValueExample productAttributeValueExample = new PmsProductAttributeValueExample();
|
||||
productAttributeValueExample.createCriteria().andProductIdEqualTo(id);
|
||||
productAttributeValueMapper.deleteByExample(productAttributeValueExample);
|
||||
relateAndInsertList(productAttributeValueDao, productParam.getProductAttributeValueList(), id);
|
||||
//关联专题
|
||||
CmsSubjectProductRelationExample subjectProductRelationExample = new CmsSubjectProductRelationExample();
|
||||
subjectProductRelationExample.createCriteria().andProductIdEqualTo(id);
|
||||
subjectProductRelationMapper.deleteByExample(subjectProductRelationExample);
|
||||
relateAndInsertList(subjectProductRelationDao, productParam.getSubjectProductRelationList(), id);
|
||||
//关联优选
|
||||
CmsPrefrenceAreaProductRelationExample prefrenceAreaExample = new CmsPrefrenceAreaProductRelationExample();
|
||||
prefrenceAreaExample.createCriteria().andProductIdEqualTo(id);
|
||||
prefrenceAreaProductRelationMapper.deleteByExample(prefrenceAreaExample);
|
||||
relateAndInsertList(prefrenceAreaProductRelationDao, productParam.getPrefrenceAreaProductRelationList(), id);
|
||||
count=1;
|
||||
return count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PmsProduct> list(PmsProductQueryParam productQueryParam, Integer pageSize, Integer pageNum) {
|
||||
PageHelper.startPage(pageNum,pageSize);
|
||||
PmsProductExample productExample = new PmsProductExample();
|
||||
PmsProductExample.Criteria criteria = productExample.createCriteria();
|
||||
criteria.andDeleteStatusEqualTo(0);
|
||||
if(productQueryParam.getPublishStatus()!=null){
|
||||
criteria.andPublishStatusEqualTo(productQueryParam.getPublishStatus());
|
||||
}
|
||||
if(productQueryParam.getVerifyStatus()!=null){
|
||||
criteria.andVerifyStatusEqualTo(productQueryParam.getVerifyStatus());
|
||||
}
|
||||
if(!StringUtils.isEmpty(productQueryParam.getKeyword())){
|
||||
criteria.andNameLike("%"+productQueryParam.getKeyword()+"%");
|
||||
}
|
||||
if(!StringUtils.isEmpty(productQueryParam.getProductSn())){
|
||||
criteria.andProductSnEqualTo(productQueryParam.getProductSn());
|
||||
}
|
||||
if(productQueryParam.getBrandId()!=null){
|
||||
criteria.andBrandIdEqualTo(productQueryParam.getBrandId());
|
||||
}
|
||||
if(productQueryParam.getProductCategoryId()!=null){
|
||||
criteria.andProductCategoryIdEqualTo(productQueryParam.getProductCategoryId());
|
||||
}
|
||||
return productMapper.selectByExample(productExample);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateVerifyStatus(List<Long> ids, Integer verifyStatus, String detail) {
|
||||
PmsProduct product = new PmsProduct();
|
||||
product.setVerifyStatus(verifyStatus);
|
||||
PmsProductExample example = new PmsProductExample();
|
||||
example.createCriteria().andIdIn(ids);
|
||||
List<PmsProductVertifyRecord> list = new ArrayList<>();
|
||||
int count = productMapper.updateByExampleSelective(product,example);
|
||||
//修改完审核状态后插入审核记录
|
||||
for (Long id : ids) {
|
||||
PmsProductVertifyRecord record = new PmsProductVertifyRecord();
|
||||
record.setProductId(id);
|
||||
record.setCreateTime(new Date());
|
||||
record.setDetail(detail);
|
||||
record.setStatus(verifyStatus);
|
||||
record.setVertifyMan("test");
|
||||
list.add(record);
|
||||
}
|
||||
productVertifyRecordDao.insertList(list);
|
||||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* 旧版创建
|
||||
@@ -72,7 +197,7 @@ public class PmsProductServiceImpl implements PmsProductService {
|
||||
public int createOld(PmsProductParam productParam) {
|
||||
int count;
|
||||
//创建商品
|
||||
PmsProduct product = productParam.getProduct();
|
||||
PmsProduct product = productParam;
|
||||
product.setId(null);
|
||||
productMapper.insertSelective(product);
|
||||
//根据促销类型设置价格:、阶梯价格、满减价格
|
||||
@@ -153,4 +278,5 @@ public class PmsProductServiceImpl implements PmsProductService {
|
||||
throw new RuntimeException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.macro.mall.service.impl;
|
||||
|
||||
import com.macro.mall.mapper.PmsSkuStockMapper;
|
||||
import com.macro.mall.model.PmsSkuStock;
|
||||
import com.macro.mall.model.PmsSkuStockExample;
|
||||
import com.macro.mall.service.PmsSkuStockService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品sku库存管理Service实现类
|
||||
* Created by macro on 2018/4/27.
|
||||
*/
|
||||
@Service
|
||||
public class PmsSkuStockServiceImpl implements PmsSkuStockService {
|
||||
@Autowired
|
||||
private PmsSkuStockMapper skuStockMapper;
|
||||
|
||||
@Override
|
||||
public List<PmsSkuStock> getList(Long pid, String keyword) {
|
||||
PmsSkuStockExample example = new PmsSkuStockExample();
|
||||
example.createCriteria().andProductIdEqualTo(pid).andSkuCodeLike("%" + keyword + "%")
|
||||
return skuStockMapper.selectByExample(example);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user