创建商品功能完善

This commit is contained in:
zhh
2018-04-25 17:22:32 +08:00
parent bc3c569616
commit a41633a9b7
19 changed files with 17839 additions and 6 deletions

View File

@@ -8,7 +8,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
* 应用启动入口
*/
@SpringBootApplication
@MapperScan("com.macro.mall.mapper")
@MapperScan({"com.macro.mall.mapper","com.macro.mall.dao"})
public class MallAdminApplication {
public static void main(String[] args) {
SpringApplication.run(MallAdminApplication.class, args);

View File

@@ -1,14 +1,37 @@
package com.macro.mall.controller;
import com.macro.mall.dto.CommonResult;
import com.macro.mall.dto.PmsProductParam;
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;
/**
* 商品管理Controller
*/
@Controller
@Api(tags = "PmsProductController",description = "商品管理")
@Api(tags = "PmsProductController", description = "商品管理")
@RequestMapping("/product")
public class PmsProductController {
@Autowired
private PmsProductService productService;
@ApiOperation("创建商品")
@RequestMapping(value = "/create", method = RequestMethod.POST)
@ResponseBody
public Object create(@RequestBody PmsProductParam productParam, BindingResult bindingResult) {
int count = productService.create(productParam);
if (count > 0) {
return new CommonResult().success(count);
} else {
return new CommonResult().failed();
}
}
}

View File

@@ -0,0 +1,33 @@
package com.macro.mall.controller;
import com.macro.mall.dto.CommonResult;
import com.macro.mall.model.UmsMemberLevel;
import com.macro.mall.service.UmsMemberLevelService;
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.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
/**
* 会员等级管理Controller
*/
@Controller
@Api(tags = "UmsMemberLevelController",description = "会员等级管理")
@RequestMapping("/memberLevel")
public class UmsMemberLevelController {
@Autowired
private UmsMemberLevelService memberLevelService;
@RequestMapping(value = "/list",method = RequestMethod.GET)
@ApiOperation("查询所有会员等级")
@ResponseBody
public Object list(@RequestParam("defaultStatus") Integer defaultStatus){
List<UmsMemberLevel> memberLevelList = memberLevelService.list(defaultStatus);
return new CommonResult().success(memberLevelList);
}
}

View File

@@ -0,0 +1,13 @@
package com.macro.mall.dao;
import com.macro.mall.model.PmsMemberPrice;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 自定义会员价格Dao
*/
public interface PmsMemberPriceDao {
int insertList(@Param("list") List<PmsMemberPrice> memberPriceList);
}

View File

@@ -0,0 +1,13 @@
package com.macro.mall.dao;
import com.macro.mall.model.PmsProductFullReduction;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 商品自定义满减
*/
public interface PmsProductFullReductionDao {
int insertList(@Param("list") List<PmsProductFullReduction> productFullReductionList);
}

View File

@@ -0,0 +1,13 @@
package com.macro.mall.dao;
import com.macro.mall.model.PmsProductLadder;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 自定义会员阶梯价格Dao
*/
public interface PmsProductLadderDao {
int insertList(@Param("list") List<PmsProductLadder> productLadderList);
}

View File

@@ -0,0 +1,94 @@
package com.macro.mall.dto;
import com.macro.mall.model.*;
import io.swagger.annotations.ApiModelProperty;
import javax.validation.constraints.NotNull;
import java.util.List;
/**
* 创建和修改商品时使用的参数
*/
public class PmsProductParam {
@ApiModelProperty("商品信息")
@NotNull(message = "商品信息不能为空")
private PmsProduct product;
@ApiModelProperty("商品阶梯价格设置")
private List<PmsProductLadder> productLadderList;
@ApiModelProperty("商品满减价格设置")
private List<PmsProductFullReduction> pmsProductFullReductionList;
@ApiModelProperty("商品会员价格设置")
private List<PmsMemberPrice> pmsMemberPriceList;
@ApiModelProperty("商品的sku库存信息")
private List<PmsSkuStock> skuStockList;
@ApiModelProperty("商品参数及自定义规格属性")
private List<PmsProductAttributeValue> pmsProductAttributeValueList;
@ApiModelProperty("专题和商品关系")
private List<CmsSubjectProductRelation> subjectProductRelationList;
@ApiModelProperty("优选专区和商品的关系")
private List<CmsPrefrenceAreaProductRelation> prefrenceAreaProductRelationList;
public PmsProduct getProduct() {
return product;
}
public void setProduct(PmsProduct product) {
this.product = product;
}
public List<PmsProductLadder> getProductLadderList() {
return productLadderList;
}
public void setProductLadderList(List<PmsProductLadder> productLadderList) {
this.productLadderList = productLadderList;
}
public List<PmsProductFullReduction> getPmsProductFullReductionList() {
return pmsProductFullReductionList;
}
public void setPmsProductFullReductionList(List<PmsProductFullReduction> pmsProductFullReductionList) {
this.pmsProductFullReductionList = pmsProductFullReductionList;
}
public List<PmsMemberPrice> getPmsMemberPriceList() {
return pmsMemberPriceList;
}
public void setPmsMemberPriceList(List<PmsMemberPrice> pmsMemberPriceList) {
this.pmsMemberPriceList = pmsMemberPriceList;
}
public List<PmsSkuStock> getSkuStockList() {
return skuStockList;
}
public void setSkuStockList(List<PmsSkuStock> skuStockList) {
this.skuStockList = skuStockList;
}
public List<PmsProductAttributeValue> getPmsProductAttributeValueList() {
return pmsProductAttributeValueList;
}
public void setPmsProductAttributeValueList(List<PmsProductAttributeValue> pmsProductAttributeValueList) {
this.pmsProductAttributeValueList = pmsProductAttributeValueList;
}
public List<CmsSubjectProductRelation> getSubjectProductRelationList() {
return subjectProductRelationList;
}
public void setSubjectProductRelationList(List<CmsSubjectProductRelation> subjectProductRelationList) {
this.subjectProductRelationList = subjectProductRelationList;
}
public List<CmsPrefrenceAreaProductRelation> getPrefrenceAreaProductRelationList() {
return prefrenceAreaProductRelationList;
}
public void setPrefrenceAreaProductRelationList(List<CmsPrefrenceAreaProductRelation> prefrenceAreaProductRelationList) {
this.prefrenceAreaProductRelationList = prefrenceAreaProductRelationList;
}
}

View File

@@ -0,0 +1,13 @@
package com.macro.mall.service;
import com.macro.mall.dto.PmsProductParam;
/**
* 商品管理Service
*/
public interface PmsProductService {
/**
* 创建商品
*/
int create(PmsProductParam productParam);
}

View File

@@ -0,0 +1,16 @@
package com.macro.mall.service;
import com.macro.mall.model.UmsMemberLevel;
import java.util.List;
/**
* 会员等级管理Service
*/
public interface UmsMemberLevelService {
/**
* 获取所有会员登录
* @param defaultStatus 是否为默认会员
*/
List<UmsMemberLevel> list(Integer defaultStatus);
}

View File

@@ -0,0 +1,80 @@
package com.macro.mall.service.impl;
import com.macro.mall.dao.PmsMemberPriceDao;
import com.macro.mall.dao.PmsProductFullReductionDao;
import com.macro.mall.dao.PmsProductLadderDao;
import com.macro.mall.dto.PmsProductParam;
import com.macro.mall.mapper.PmsProductMapper;
import com.macro.mall.model.PmsMemberPrice;
import com.macro.mall.model.PmsProduct;
import com.macro.mall.model.PmsProductFullReduction;
import com.macro.mall.model.PmsProductLadder;
import com.macro.mall.service.PmsProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.List;
/**
* 商品管理Service实现类
*/
@Service
public class PmsProductServiceImpl implements PmsProductService{
@Autowired
private PmsProductMapper productMapper;
@Autowired
private PmsMemberPriceDao memberPriceDao;
@Autowired
private PmsProductLadderDao productLadderDao;
@Autowired
private PmsProductFullReductionDao productFullReductionDao;
@Override
public int create(PmsProductParam productParam) {
int count;
//创建商品
PmsProduct product = productParam.getProduct();
product.setId(null);
productMapper.insertSelective(product);
//根据促销类型设置价格:、阶梯价格、满减价格
Long productId = product.getId();
if(product.getPromotionType()==2){
//会员价格
List<PmsMemberPrice> memberPriceList = productParam.getPmsMemberPriceList();
if(!CollectionUtils.isEmpty(memberPriceList)){
for(PmsMemberPrice pmsMemberPrice: memberPriceList){
pmsMemberPrice.setId(null);
pmsMemberPrice.setProductId(productId);
}
memberPriceDao.insertList(memberPriceList);
}
}else if(product.getPromotionType()==3){
//阶梯价格
List<PmsProductLadder> productLadderList = productParam.getProductLadderList();
if(!CollectionUtils.isEmpty(productLadderList)){
for(PmsProductLadder productLadder:productLadderList){
productLadder.setId(null);
productLadder.setProductId(productId);
}
productLadderDao.insertList(productLadderList);
}
}else if(product.getPromotionType()==4){
//满减价格
List<PmsProductFullReduction> productFullReductionList = productParam.getPmsProductFullReductionList();
if(!CollectionUtils.isEmpty(productFullReductionList)){
for (PmsProductFullReduction productFullReduction: productFullReductionList) {
productFullReduction.setId(null);
productFullReduction.setProductId(productId);
}
productFullReductionDao.insertList(productFullReductionList);
}
}
//添加sku库存信息
//添加商品参数
//添加自定义商品规格
//关联专题
//关联优选
count=1;
return count;
}
}

View File

@@ -0,0 +1,25 @@
package com.macro.mall.service.impl;
import com.macro.mall.mapper.UmsMemberLevelMapper;
import com.macro.mall.model.UmsMemberLevel;
import com.macro.mall.model.UmsMemberLevelExample;
import com.macro.mall.service.UmsMemberLevelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 会员等级管理Service实现类
*/
@Service
public class UmsMemberLevelServiceImpl implements UmsMemberLevelService{
@Autowired
private UmsMemberLevelMapper memberLevelMapper;
@Override
public List<UmsMemberLevel> list(Integer defaultStatus) {
UmsMemberLevelExample example = new UmsMemberLevelExample();
example.createCriteria().andDefaultStatusEqualTo(defaultStatus);
return memberLevelMapper.selectByExample(example);
}
}