添加商品查询、添加、修改功能

This commit is contained in:
zhh 2018-04-27 17:21:44 +08:00
parent edc71542ae
commit 17e6a32d02
25 changed files with 2764 additions and 1965 deletions

View File

@ -33,7 +33,7 @@ SpringAOP通用验证失败结果返回 | ✔
CommonResult对通用返回结果进行封装 | ✔
SpringSecurity登录改为Restful形式 | ✔
JWT登录、注册、获取token | ✔
JTA事务处理 |
JTA事务处理 |
集成单元测试 | ✔
### 功能完善
@ -65,7 +65,7 @@ JTA事务处理 |
##### 商品管理
###### 添加商品
###### 添加商品(完成)
- 选择商品分类根据商品分类id查找分类
- 选择品牌:查询全部品牌
- 选择运费模版:查询全部运费模版
@ -81,6 +81,23 @@ JTA事务处理 |
- 关联专题:参数传入List<CmsSubjectProductRelation>关系
- 关联优选:参数传入List<CmsPrefrenceAreaProductRelation>关系
###### 修改商品(完成)
- 根据商品id查询商品信息
- 查询商品基本信息:商品分类名称、品牌名称、运费模版名称
- 查询商品促销信息:商品的会员价格、阶梯价格、满减价格
- 查询商品属性信息商品属性类别名称、sku库存信息、属性分类对应规格和参数值
- 查询商品关联信息:商品关联专题和关联优选
- 修改商品信息商品属性分类及规格不可修改只支持单个sku的修改、删除、新增商品属性分类及规格可以修改修改后同时显示原sku库存及属性分类
###### 商品分页查询
- 商品的状态:全部商品、已上架、未上架、待审核、未通过 (publishStatus verifyStatus)
- 商品名称(%name%)
- 商品货号(productSn)
- 商品分类id(productCategoryId)
- 商品品牌id(brandId)
- 批量操作:上下架、推荐、新品、转移分类、放入回收站、审核
- 查看记录:审核记录,操作日志
- sku:根据产品及sku编号获取sku信息批量修改sku信息
#### 促销管理
#### 内容管理

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -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;

View File

@ -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();
}
}
}

View File

@ -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);
}
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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);

View File

@ -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);

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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());
}
}
}

View File

@ -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);
}
}

View File

@ -0,0 +1,52 @@
<?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.macro.mall.dao.PmsProductDao">
<resultMap id="updateInfoMap" type="com.macro.mall.dto.PmsProductResult" extends="com.macro.mall.mapper.PmsProductMapper.BaseResultMap">
<collection property="productLadderList" columnPrefix="ladder_" resultMap="com.macro.mall.mapper.PmsProductLadderMapper.BaseResultMap">
</collection>
<collection property="productFullReductionList" columnPrefix="full_" resultMap="com.macro.mall.mapper.PmsProductFullReductionMapper.BaseResultMap">
</collection>
<collection property="memberPriceList" columnPrefix="member_" resultMap="com.macro.mall.mapper.PmsMemberPriceMapper.BaseResultMap">
</collection>
<collection property="skuStockList" columnPrefix="sku_" resultMap="com.macro.mall.mapper.PmsSkuStockMapper.BaseResultMap">
</collection>
<collection property="productAttributeValueList" columnPrefix="attribute_" resultMap="com.macro.mall.mapper.PmsProductAttributeValueMapper.BaseResultMap">
</collection>
<collection property="subjectList" column="{productId=id}" select="selectSubjectByProductId">
</collection>
<collection property="prefrenceAreaList" column="{productId=id}" select="selectPrefrenceAreaByProductId">
</collection>
</resultMap>
<select id="getUpdateInfo" resultMap="updateInfoMap">
SELECT *,
f.name feightTemplateName,
ac.name productAttributeCategoryName,
l.id ladder_id,l.discount ladder_discount,l.count ladder_count,l.price ladder_price,
pf.id full_id,pf.full_price full_full_price,pf.reduce_price full_reduce_price,
m.id member_id,m.member_level_id member_member_level_id,m.member_price member_member_price,
s.id sku_id,s.price sku_price,s.low_stock sku_low_stock,s.pic sku_pic,s.sale sku_sale,s.sku_code sku_sku_code,s.sp1 sku_sp1,s.sp2 sku_sp2,s.sp3 sku_sp3,s.stock sku_stock,
a.id attribute_id,a.product_attribute_id attribute_product_attribute_id,a.value attribute_value
FROM pms_product p
LEFT JOIN pms_feight_template f ON p.feight_template_id = f.id
LEFT JOIN pms_product_attribute_category ac ON p.product_attribute_category_id= ac.id
LEFT JOIN pms_product_ladder l ON p.id = l.product_id
LEFT JOIN pms_product_full_reduction pf ON pf.product_id=p.id
LEFT JOIN pms_member_price m ON m.product_id = p.id
LEFT JOIN pms_sku_stock s ON s.product_id = p.id
LEFT JOIN pms_product_attribute_value a ON a.product_id=p.id
WHERE p.id=#{id};
</select>
<select id="selectSubjectByProductId" resultMap="com.macro.mall.mapper.CmsSubjectMapper.BaseResultMap">
SELECT s.*
FROM cms_subject_product_relation spr
LEFT JOIN cms_subject s ON spr.subject_id = s.id
WHERE spr.product_id = #{productId}
</select>
<select id="selectPrefrenceAreaByProductId" resultMap="com.macro.mall.mapper.CmsPrefrenceAreaMapper.BaseResultMap">
SELECT p.*
FROM cms_prefrence_area_product_relation ppr
LEFT JOIN cms_prefrence_area p ON ppr.prefrence_area_id=p.id
WHERE ppr.product_id=#{productId}
</select>
</mapper>

View File

@ -0,0 +1,15 @@
<?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.macro.mall.dao.PmsProductVertifyRecordDao">
<!--批量新增回写主键支持-->
<insert id="insertList">
insert into pms_product_vertify_record (product_id, create_time, vertify_man,status, detail) values
<foreach collection="list" separator="," item="item" index="index">
(#{item.productId,jdbcType=BIGINT},
#{item.createTime,jdbcType=TIMESTAMP},
#{item.vertifyMan,jdbcType=VARCHAR},
#{item.status,jdbcType=INTEGER},
#{item.detail,jdbcType=VARCHAR})
</foreach>
</insert>
</mapper>

View File

@ -2,13 +2,21 @@ package com.macro.mall;
import com.macro.mall.dao.PmsMemberPriceDao;
import com.macro.mall.dao.PmsProductDao;
import com.macro.mall.dto.PmsProductResult;
import com.macro.mall.model.PmsMemberPrice;
import com.macro.mall.util.JsonUtil;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
@ -18,7 +26,12 @@ import java.util.List;
public class PmsDaoTests {
@Autowired
private PmsMemberPriceDao memberPriceDao;
@Autowired
private PmsProductDao productDao;
private static final Logger LOGGER = LoggerFactory.getLogger(PmsDaoTests.class);
@Test
@Transactional
@Rollback
public void testInsertBatch(){
List<PmsMemberPrice> list = new ArrayList<>();
for(int i=0;i<5;i++){
@ -31,4 +44,11 @@ public class PmsDaoTests {
int count = memberPriceDao.insertList(list);
Assert.assertEquals(5,count);
}
@Test
public void testGetProductUpdateInfo(){
PmsProductResult productResult = productDao.getUpdateInfo(7L);
String json = JsonUtil.objectToJson(productResult);
LOGGER.info(json);
}
}

View File

@ -223,6 +223,20 @@ public class PmsProduct implements Serializable {
*/
private Integer promotionType;
/**
* 品牌名称
*
* @mbggenerated
*/
private String brandName;
/**
* 商品分类名称
*
* @mbggenerated
*/
private String productCategoryName;
/**
* 商品描述
*
@ -560,6 +574,22 @@ public class PmsProduct implements Serializable {
this.promotionType = promotionType;
}
public String getBrandName() {
return brandName;
}
public void setBrandName(String brandName) {
this.brandName = brandName;
}
public String getProductCategoryName() {
return productCategoryName;
}
public void setProductCategoryName(String productCategoryName) {
this.productCategoryName = productCategoryName;
}
public String getDescription() {
return description;
}
@ -637,6 +667,8 @@ public class PmsProduct implements Serializable {
sb.append(", promotionEndTime=").append(promotionEndTime);
sb.append(", promotionPerLimit=").append(promotionPerLimit);
sb.append(", promotionType=").append(promotionType);
sb.append(", brandName=").append(brandName);
sb.append(", productCategoryName=").append(productCategoryName);
sb.append(", description=").append(description);
sb.append(", detailDesc=").append(detailDesc);
sb.append(", detailHtml=").append(detailHtml);

View File

@ -2545,6 +2545,146 @@ public class PmsProductExample {
addCriterion("promotion_type not between", value1, value2, "promotionType");
return (Criteria) this;
}
public Criteria andBrandNameIsNull() {
addCriterion("brand_name is null");
return (Criteria) this;
}
public Criteria andBrandNameIsNotNull() {
addCriterion("brand_name is not null");
return (Criteria) this;
}
public Criteria andBrandNameEqualTo(String value) {
addCriterion("brand_name =", value, "brandName");
return (Criteria) this;
}
public Criteria andBrandNameNotEqualTo(String value) {
addCriterion("brand_name <>", value, "brandName");
return (Criteria) this;
}
public Criteria andBrandNameGreaterThan(String value) {
addCriterion("brand_name >", value, "brandName");
return (Criteria) this;
}
public Criteria andBrandNameGreaterThanOrEqualTo(String value) {
addCriterion("brand_name >=", value, "brandName");
return (Criteria) this;
}
public Criteria andBrandNameLessThan(String value) {
addCriterion("brand_name <", value, "brandName");
return (Criteria) this;
}
public Criteria andBrandNameLessThanOrEqualTo(String value) {
addCriterion("brand_name <=", value, "brandName");
return (Criteria) this;
}
public Criteria andBrandNameLike(String value) {
addCriterion("brand_name like", value, "brandName");
return (Criteria) this;
}
public Criteria andBrandNameNotLike(String value) {
addCriterion("brand_name not like", value, "brandName");
return (Criteria) this;
}
public Criteria andBrandNameIn(List<String> values) {
addCriterion("brand_name in", values, "brandName");
return (Criteria) this;
}
public Criteria andBrandNameNotIn(List<String> values) {
addCriterion("brand_name not in", values, "brandName");
return (Criteria) this;
}
public Criteria andBrandNameBetween(String value1, String value2) {
addCriterion("brand_name between", value1, value2, "brandName");
return (Criteria) this;
}
public Criteria andBrandNameNotBetween(String value1, String value2) {
addCriterion("brand_name not between", value1, value2, "brandName");
return (Criteria) this;
}
public Criteria andProductCategoryNameIsNull() {
addCriterion("product_category_name is null");
return (Criteria) this;
}
public Criteria andProductCategoryNameIsNotNull() {
addCriterion("product_category_name is not null");
return (Criteria) this;
}
public Criteria andProductCategoryNameEqualTo(String value) {
addCriterion("product_category_name =", value, "productCategoryName");
return (Criteria) this;
}
public Criteria andProductCategoryNameNotEqualTo(String value) {
addCriterion("product_category_name <>", value, "productCategoryName");
return (Criteria) this;
}
public Criteria andProductCategoryNameGreaterThan(String value) {
addCriterion("product_category_name >", value, "productCategoryName");
return (Criteria) this;
}
public Criteria andProductCategoryNameGreaterThanOrEqualTo(String value) {
addCriterion("product_category_name >=", value, "productCategoryName");
return (Criteria) this;
}
public Criteria andProductCategoryNameLessThan(String value) {
addCriterion("product_category_name <", value, "productCategoryName");
return (Criteria) this;
}
public Criteria andProductCategoryNameLessThanOrEqualTo(String value) {
addCriterion("product_category_name <=", value, "productCategoryName");
return (Criteria) this;
}
public Criteria andProductCategoryNameLike(String value) {
addCriterion("product_category_name like", value, "productCategoryName");
return (Criteria) this;
}
public Criteria andProductCategoryNameNotLike(String value) {
addCriterion("product_category_name not like", value, "productCategoryName");
return (Criteria) this;
}
public Criteria andProductCategoryNameIn(List<String> values) {
addCriterion("product_category_name in", values, "productCategoryName");
return (Criteria) this;
}
public Criteria andProductCategoryNameNotIn(List<String> values) {
addCriterion("product_category_name not in", values, "productCategoryName");
return (Criteria) this;
}
public Criteria andProductCategoryNameBetween(String value1, String value2) {
addCriterion("product_category_name between", value1, value2, "productCategoryName");
return (Criteria) this;
}
public Criteria andProductCategoryNameNotBetween(String value1, String value2) {
addCriterion("product_category_name not between", value1, value2, "productCategoryName");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {

View File

@ -41,6 +41,8 @@
<result column="promotion_end_time" jdbcType="TIMESTAMP" property="promotionEndTime" />
<result column="promotion_per_limit" jdbcType="INTEGER" property="promotionPerLimit" />
<result column="promotion_type" jdbcType="INTEGER" property="promotionType" />
<result column="brand_name" jdbcType="VARCHAR" property="brandName" />
<result column="product_category_name" jdbcType="VARCHAR" property="productCategoryName" />
</resultMap>
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.macro.mall.model.PmsProduct">
<result column="description" jdbcType="LONGVARCHAR" property="description" />
@ -113,7 +115,7 @@
use_point_limit, sub_title, original_price, stock, low_stock, unit, weight, preview_status,
service_ids, keywords, note, album_pics, detail_title, flash_promotion_price, flash_promotion_count,
flash_promotion_sort, promotion_start_time, promotion_end_time, promotion_per_limit,
promotion_type
promotion_type, brand_name, product_category_name
</sql>
<sql id="Blob_Column_List">
description, detail_desc, detail_html, detail_mobile_html
@ -183,9 +185,9 @@
album_pics, detail_title, flash_promotion_price,
flash_promotion_count, flash_promotion_sort,
promotion_start_time, promotion_end_time,
promotion_per_limit, promotion_type, description,
detail_desc, detail_html, detail_mobile_html
)
promotion_per_limit, promotion_type, brand_name,
product_category_name, description, detail_desc,
detail_html, detail_mobile_html)
values (#{brandId,jdbcType=BIGINT}, #{productCategoryId,jdbcType=BIGINT}, #{feightTemplateId,jdbcType=BIGINT},
#{productAttributeCategoryId,jdbcType=BIGINT}, #{flashPromotionId,jdbcType=INTEGER},
#{name,jdbcType=VARCHAR}, #{pic,jdbcType=VARCHAR}, #{productSn,jdbcType=VARCHAR},
@ -199,9 +201,9 @@
#{albumPics,jdbcType=VARCHAR}, #{detailTitle,jdbcType=VARCHAR}, #{flashPromotionPrice,jdbcType=DECIMAL},
#{flashPromotionCount,jdbcType=INTEGER}, #{flashPromotionSort,jdbcType=INTEGER},
#{promotionStartTime,jdbcType=TIMESTAMP}, #{promotionEndTime,jdbcType=TIMESTAMP},
#{promotionPerLimit,jdbcType=INTEGER}, #{promotionType,jdbcType=INTEGER}, #{description,jdbcType=LONGVARCHAR},
#{detailDesc,jdbcType=LONGVARCHAR}, #{detailHtml,jdbcType=LONGVARCHAR}, #{detailMobileHtml,jdbcType=LONGVARCHAR}
)
#{promotionPerLimit,jdbcType=INTEGER}, #{promotionType,jdbcType=INTEGER}, #{brandName,jdbcType=VARCHAR},
#{productCategoryName,jdbcType=VARCHAR}, #{description,jdbcType=LONGVARCHAR}, #{detailDesc,jdbcType=LONGVARCHAR},
#{detailHtml,jdbcType=LONGVARCHAR}, #{detailMobileHtml,jdbcType=LONGVARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.macro.mall.model.PmsProduct">
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
@ -323,6 +325,12 @@
<if test="promotionType != null">
promotion_type,
</if>
<if test="brandName != null">
brand_name,
</if>
<if test="productCategoryName != null">
product_category_name,
</if>
<if test="description != null">
description,
</if>
@ -451,6 +459,12 @@
<if test="promotionType != null">
#{promotionType,jdbcType=INTEGER},
</if>
<if test="brandName != null">
#{brandName,jdbcType=VARCHAR},
</if>
<if test="productCategoryName != null">
#{productCategoryName,jdbcType=VARCHAR},
</if>
<if test="description != null">
#{description,jdbcType=LONGVARCHAR},
</if>
@ -591,6 +605,12 @@
<if test="record.promotionType != null">
promotion_type = #{record.promotionType,jdbcType=INTEGER},
</if>
<if test="record.brandName != null">
brand_name = #{record.brandName,jdbcType=VARCHAR},
</if>
<if test="record.productCategoryName != null">
product_category_name = #{record.productCategoryName,jdbcType=VARCHAR},
</if>
<if test="record.description != null">
description = #{record.description,jdbcType=LONGVARCHAR},
</if>
@ -649,6 +669,8 @@
promotion_end_time = #{record.promotionEndTime,jdbcType=TIMESTAMP},
promotion_per_limit = #{record.promotionPerLimit,jdbcType=INTEGER},
promotion_type = #{record.promotionType,jdbcType=INTEGER},
brand_name = #{record.brandName,jdbcType=VARCHAR},
product_category_name = #{record.productCategoryName,jdbcType=VARCHAR},
description = #{record.description,jdbcType=LONGVARCHAR},
detail_desc = #{record.detailDesc,jdbcType=LONGVARCHAR},
detail_html = #{record.detailHtml,jdbcType=LONGVARCHAR},
@ -697,7 +719,9 @@
promotion_start_time = #{record.promotionStartTime,jdbcType=TIMESTAMP},
promotion_end_time = #{record.promotionEndTime,jdbcType=TIMESTAMP},
promotion_per_limit = #{record.promotionPerLimit,jdbcType=INTEGER},
promotion_type = #{record.promotionType,jdbcType=INTEGER}
promotion_type = #{record.promotionType,jdbcType=INTEGER},
brand_name = #{record.brandName,jdbcType=VARCHAR},
product_category_name = #{record.productCategoryName,jdbcType=VARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
@ -819,6 +843,12 @@
<if test="promotionType != null">
promotion_type = #{promotionType,jdbcType=INTEGER},
</if>
<if test="brandName != null">
brand_name = #{brandName,jdbcType=VARCHAR},
</if>
<if test="productCategoryName != null">
product_category_name = #{productCategoryName,jdbcType=VARCHAR},
</if>
<if test="description != null">
description = #{description,jdbcType=LONGVARCHAR},
</if>
@ -874,6 +904,8 @@
promotion_end_time = #{promotionEndTime,jdbcType=TIMESTAMP},
promotion_per_limit = #{promotionPerLimit,jdbcType=INTEGER},
promotion_type = #{promotionType,jdbcType=INTEGER},
brand_name = #{brandName,jdbcType=VARCHAR},
product_category_name = #{productCategoryName,jdbcType=VARCHAR},
description = #{description,jdbcType=LONGVARCHAR},
detail_desc = #{detailDesc,jdbcType=LONGVARCHAR},
detail_html = #{detailHtml,jdbcType=LONGVARCHAR},
@ -919,7 +951,9 @@
promotion_start_time = #{promotionStartTime,jdbcType=TIMESTAMP},
promotion_end_time = #{promotionEndTime,jdbcType=TIMESTAMP},
promotion_per_limit = #{promotionPerLimit,jdbcType=INTEGER},
promotion_type = #{promotionType,jdbcType=INTEGER}
promotion_type = #{promotionType,jdbcType=INTEGER},
brand_name = #{brandName,jdbcType=VARCHAR},
product_category_name = #{productCategoryName,jdbcType=VARCHAR}
where id = #{id,jdbcType=BIGINT}
</update>
</mapper>