商品接口完善
This commit is contained in:
parent
8e48c839ff
commit
c9e591ca64
@ -2,6 +2,7 @@ package com.macro.mall.controller;
|
||||
|
||||
import com.macro.mall.dto.CommonResult;
|
||||
import com.macro.mall.dto.PmsProductCategoryParam;
|
||||
import com.macro.mall.dto.PmsProductCategoryWithChildrenItem;
|
||||
import com.macro.mall.model.PmsProductCategory;
|
||||
import com.macro.mall.service.PmsProductCategoryService;
|
||||
import io.swagger.annotations.Api;
|
||||
@ -108,4 +109,12 @@ public class PmsProductCategoryController {
|
||||
return new CommonResult().failed();
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation("查询所有一级分类及子分类")
|
||||
@RequestMapping(value = "/list/withChildren", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public Object listWithChildren() {
|
||||
List<PmsProductCategoryWithChildrenItem> list = productCategoryService.listWithChildren();
|
||||
return new CommonResult().success(list);
|
||||
}
|
||||
}
|
||||
|
@ -82,4 +82,56 @@ public class PmsProductController {
|
||||
return new CommonResult().failed();
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation("批量上下架")
|
||||
@RequestMapping(value = "/update/publishStatus",method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public Object updatePublishStatus(@RequestParam("ids") List<Long> ids,
|
||||
@RequestParam("publishStatus") Integer publishStatus) {
|
||||
int count = productService.updatePublishStatus(ids, publishStatus);
|
||||
if (count > 0) {
|
||||
return new CommonResult().success(count);
|
||||
} else {
|
||||
return new CommonResult().failed();
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation("批量推荐商品")
|
||||
@RequestMapping(value = "/update/recommendStatus",method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public Object updateRecommendStatus(@RequestParam("ids") List<Long> ids,
|
||||
@RequestParam("recommendStatus") Integer recommendStatus) {
|
||||
int count = productService.updateRecommendStatus(ids, recommendStatus);
|
||||
if (count > 0) {
|
||||
return new CommonResult().success(count);
|
||||
} else {
|
||||
return new CommonResult().failed();
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation("批量设为新品")
|
||||
@RequestMapping(value = "/update/newStatus",method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public Object updateNewStatus(@RequestParam("ids") List<Long> ids,
|
||||
@RequestParam("newStatus") Integer newStatus) {
|
||||
int count = productService.updateNewStatus(ids, newStatus);
|
||||
if (count > 0) {
|
||||
return new CommonResult().success(count);
|
||||
} else {
|
||||
return new CommonResult().failed();
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation("批量修改删除状态")
|
||||
@RequestMapping(value = "/update/deleteStatus",method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public Object updateDeleteStatus(@RequestParam("ids") List<Long> ids,
|
||||
@RequestParam("deleteStatus") Integer deleteStatus) {
|
||||
int count = productService.updateDeleteStatus(ids, deleteStatus);
|
||||
if (count > 0) {
|
||||
return new CommonResult().success(count);
|
||||
} else {
|
||||
return new CommonResult().failed();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,13 @@
|
||||
package com.macro.mall.dao;
|
||||
|
||||
import com.macro.mall.dto.PmsProductCategoryWithChildrenItem;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品分类自定义Dao
|
||||
* Created by macro on 2018/5/25.
|
||||
*/
|
||||
public interface PmsProductCategoryDao {
|
||||
List<PmsProductCategoryWithChildrenItem> listWithChildren();
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package com.macro.mall.dto;
|
||||
|
||||
import com.macro.mall.model.PmsProductCategory;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by macro on 2018/5/25.
|
||||
*/
|
||||
public class PmsProductCategoryWithChildrenItem extends PmsProductCategory {
|
||||
private List<PmsProductCategory> children;
|
||||
|
||||
public List<PmsProductCategory> getChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
public void setChildren(List<PmsProductCategory> children) {
|
||||
this.children = children;
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
package com.macro.mall.service;
|
||||
|
||||
import com.macro.mall.dto.PmsProductCategoryParam;
|
||||
import com.macro.mall.dto.PmsProductCategoryWithChildrenItem;
|
||||
import com.macro.mall.model.PmsProductCategory;
|
||||
import org.springframework.transaction.annotation.Isolation;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
@ -28,4 +29,6 @@ public interface PmsProductCategoryService {
|
||||
int updateNavStatus(List<Long> ids, Integer navStatus);
|
||||
|
||||
int updateShowStatus(List<Long> ids, Integer showStatus);
|
||||
|
||||
List<PmsProductCategoryWithChildrenItem> listWithChildren();
|
||||
}
|
||||
|
@ -45,4 +45,12 @@ public interface PmsProductService {
|
||||
*/
|
||||
@Transactional
|
||||
int updateVerifyStatus(List<Long> ids, Integer verifyStatus, String detail);
|
||||
|
||||
int updatePublishStatus(List<Long> ids, Integer publishStatus);
|
||||
|
||||
int updateRecommendStatus(List<Long> ids, Integer recommendStatus);
|
||||
|
||||
int updateNewStatus(List<Long> ids, Integer newStatus);
|
||||
|
||||
int updateDeleteStatus(List<Long> ids, Integer deleteStatus);
|
||||
}
|
||||
|
@ -2,7 +2,9 @@ package com.macro.mall.service.impl;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.macro.mall.dao.PmsProductCategoryAttributeRelationDao;
|
||||
import com.macro.mall.dao.PmsProductCategoryDao;
|
||||
import com.macro.mall.dto.PmsProductCategoryParam;
|
||||
import com.macro.mall.dto.PmsProductCategoryWithChildrenItem;
|
||||
import com.macro.mall.mapper.PmsProductCategoryAttributeRelationMapper;
|
||||
import com.macro.mall.mapper.PmsProductCategoryMapper;
|
||||
import com.macro.mall.mapper.PmsProductMapper;
|
||||
@ -30,6 +32,8 @@ public class PmsProductCategoryServiceImpl implements PmsProductCategoryService
|
||||
private PmsProductCategoryAttributeRelationDao productCategoryAttributeRelationDao;
|
||||
@Autowired
|
||||
private PmsProductCategoryAttributeRelationMapper productCategoryAttributeRelationMapper;
|
||||
@Autowired
|
||||
private PmsProductCategoryDao productCategoryDao;
|
||||
@Override
|
||||
public int create(PmsProductCategoryParam pmsProductCategoryParam) {
|
||||
PmsProductCategory productCategory = new PmsProductCategory();
|
||||
@ -125,6 +129,11 @@ public class PmsProductCategoryServiceImpl implements PmsProductCategoryService
|
||||
return productCategoryMapper.updateByExampleSelective(productCategory, example);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PmsProductCategoryWithChildrenItem> listWithChildren() {
|
||||
return productCategoryDao.listWithChildren();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据分类的parentId设置分类的level
|
||||
*/
|
||||
|
@ -73,9 +73,9 @@ public class PmsProductServiceImpl implements PmsProductService {
|
||||
//根据促销类型设置价格:、阶梯价格、满减价格
|
||||
Long productId = product.getId();
|
||||
//会员价格
|
||||
relateAndInsertList(memberPriceDao,productParam.getMemberPriceList(),productId);
|
||||
relateAndInsertList(memberPriceDao, productParam.getMemberPriceList(), productId);
|
||||
//阶梯价格
|
||||
relateAndInsertList(productLadderDao,productParam.getProductLadderList(),productId);
|
||||
relateAndInsertList(productLadderDao, productParam.getProductLadderList(), productId);
|
||||
//满减价格
|
||||
relateAndInsertList(productFullReductionDao, productParam.getProductFullReductionList(), productId);
|
||||
//添加sku库存信息
|
||||
@ -106,12 +106,12 @@ public class PmsProductServiceImpl implements PmsProductService {
|
||||
PmsMemberPriceExample pmsMemberPriceExample = new PmsMemberPriceExample();
|
||||
pmsMemberPriceExample.createCriteria().andProductIdEqualTo(id);
|
||||
memberPriceMapper.deleteByExample(pmsMemberPriceExample);
|
||||
relateAndInsertList(memberPriceDao,productParam.getMemberPriceList(),id);
|
||||
relateAndInsertList(memberPriceDao, productParam.getMemberPriceList(), id);
|
||||
//阶梯价格
|
||||
PmsProductLadderExample ladderExample = new PmsProductLadderExample();
|
||||
ladderExample.createCriteria().andProductIdEqualTo(id);
|
||||
productLadderMapper.deleteByExample(ladderExample);
|
||||
relateAndInsertList(productLadderDao,productParam.getProductLadderList(),id);
|
||||
relateAndInsertList(productLadderDao, productParam.getProductLadderList(), id);
|
||||
//满减价格
|
||||
PmsProductFullReductionExample fullReductionExample = new PmsProductFullReductionExample();
|
||||
fullReductionExample.createCriteria().andProductIdEqualTo(id);
|
||||
@ -137,32 +137,32 @@ public class PmsProductServiceImpl implements PmsProductService {
|
||||
prefrenceAreaExample.createCriteria().andProductIdEqualTo(id);
|
||||
prefrenceAreaProductRelationMapper.deleteByExample(prefrenceAreaExample);
|
||||
relateAndInsertList(prefrenceAreaProductRelationDao, productParam.getPrefrenceAreaProductRelationList(), id);
|
||||
count=1;
|
||||
count = 1;
|
||||
return count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PmsProduct> list(PmsProductQueryParam productQueryParam, Integer pageSize, Integer pageNum) {
|
||||
PageHelper.startPage(pageNum,pageSize);
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
PmsProductExample productExample = new PmsProductExample();
|
||||
PmsProductExample.Criteria criteria = productExample.createCriteria();
|
||||
criteria.andDeleteStatusEqualTo(0);
|
||||
if(productQueryParam.getPublishStatus()!=null){
|
||||
if (productQueryParam.getPublishStatus() != null) {
|
||||
criteria.andPublishStatusEqualTo(productQueryParam.getPublishStatus());
|
||||
}
|
||||
if(productQueryParam.getVerifyStatus()!=null){
|
||||
if (productQueryParam.getVerifyStatus() != null) {
|
||||
criteria.andVerifyStatusEqualTo(productQueryParam.getVerifyStatus());
|
||||
}
|
||||
if(!StringUtils.isEmpty(productQueryParam.getKeyword())){
|
||||
criteria.andNameLike("%"+productQueryParam.getKeyword()+"%");
|
||||
if (!StringUtils.isEmpty(productQueryParam.getKeyword())) {
|
||||
criteria.andNameLike("%" + productQueryParam.getKeyword() + "%");
|
||||
}
|
||||
if(!StringUtils.isEmpty(productQueryParam.getProductSn())){
|
||||
if (!StringUtils.isEmpty(productQueryParam.getProductSn())) {
|
||||
criteria.andProductSnEqualTo(productQueryParam.getProductSn());
|
||||
}
|
||||
if(productQueryParam.getBrandId()!=null){
|
||||
if (productQueryParam.getBrandId() != null) {
|
||||
criteria.andBrandIdEqualTo(productQueryParam.getBrandId());
|
||||
}
|
||||
if(productQueryParam.getProductCategoryId()!=null){
|
||||
if (productQueryParam.getProductCategoryId() != null) {
|
||||
criteria.andProductCategoryIdEqualTo(productQueryParam.getProductCategoryId());
|
||||
}
|
||||
return productMapper.selectByExample(productExample);
|
||||
@ -175,7 +175,7 @@ public class PmsProductServiceImpl implements PmsProductService {
|
||||
PmsProductExample example = new PmsProductExample();
|
||||
example.createCriteria().andIdIn(ids);
|
||||
List<PmsProductVertifyRecord> list = new ArrayList<>();
|
||||
int count = productMapper.updateByExampleSelective(product,example);
|
||||
int count = productMapper.updateByExampleSelective(product, example);
|
||||
//修改完审核状态后插入审核记录
|
||||
for (Long id : ids) {
|
||||
PmsProductVertifyRecord record = new PmsProductVertifyRecord();
|
||||
@ -190,9 +190,44 @@ public class PmsProductServiceImpl implements PmsProductService {
|
||||
return count;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updatePublishStatus(List<Long> ids, Integer publishStatus) {
|
||||
PmsProduct record = new PmsProduct();
|
||||
record.setPublishStatus(publishStatus);
|
||||
PmsProductExample example = new PmsProductExample();
|
||||
example.createCriteria().andIdIn(ids);
|
||||
return productMapper.updateByExampleSelective(record, example);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateRecommendStatus(List<Long> ids, Integer recommendStatus) {
|
||||
PmsProduct record = new PmsProduct();
|
||||
record.setRecommandStatus(recommendStatus);
|
||||
PmsProductExample example = new PmsProductExample();
|
||||
example.createCriteria().andIdIn(ids);
|
||||
return productMapper.updateByExampleSelective(record, example);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateNewStatus(List<Long> ids, Integer newStatus) {
|
||||
PmsProduct record = new PmsProduct();
|
||||
record.setNewStatus(newStatus);
|
||||
PmsProductExample example = new PmsProductExample();
|
||||
example.createCriteria().andIdIn(ids);
|
||||
return productMapper.updateByExampleSelective(record, example);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateDeleteStatus(List<Long> ids, Integer deleteStatus) {
|
||||
PmsProduct record = new PmsProduct();
|
||||
record.setDeleteStatus(deleteStatus);
|
||||
PmsProductExample example = new PmsProductExample();
|
||||
example.createCriteria().andIdIn(ids);
|
||||
return productMapper.updateByExampleSelective(record, example);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* 旧版创建
|
||||
* @deprecated 旧版创建
|
||||
*/
|
||||
public int createOld(PmsProductParam productParam) {
|
||||
int count;
|
||||
@ -231,7 +266,7 @@ public class PmsProductServiceImpl implements PmsProductService {
|
||||
}
|
||||
//添加sku库存信息
|
||||
List<PmsSkuStock> skuStockList = productParam.getSkuStockList();
|
||||
if(!CollectionUtils.isEmpty(skuStockList)){
|
||||
if (!CollectionUtils.isEmpty(skuStockList)) {
|
||||
for (PmsSkuStock skuStock : skuStockList) {
|
||||
skuStock.setId(null);
|
||||
skuStock.setProductId(productId);
|
||||
@ -240,7 +275,7 @@ public class PmsProductServiceImpl implements PmsProductService {
|
||||
}
|
||||
//添加商品参数,添加自定义商品规格
|
||||
List<PmsProductAttributeValue> productAttributeValueList = productParam.getProductAttributeValueList();
|
||||
if(!CollectionUtils.isEmpty(productAttributeValueList)){
|
||||
if (!CollectionUtils.isEmpty(productAttributeValueList)) {
|
||||
for (PmsProductAttributeValue productAttributeValue : productAttributeValueList) {
|
||||
productAttributeValue.setId(null);
|
||||
productAttributeValue.setProductId(productId);
|
||||
@ -274,7 +309,7 @@ public class PmsProductServiceImpl implements PmsProductService {
|
||||
Method insertList = dao.getClass().getMethod("insertList", List.class);
|
||||
insertList.invoke(dao, dataList);
|
||||
} catch (Exception e) {
|
||||
LOGGER.warn("创建产品出错:{}",e.getMessage());
|
||||
LOGGER.warn("创建产品出错:{}", e.getMessage());
|
||||
throw new RuntimeException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
18
mall-admin/src/main/resources/dao/PmsProductCategoryDao.xml
Normal file
18
mall-admin/src/main/resources/dao/PmsProductCategoryDao.xml
Normal file
@ -0,0 +1,18 @@
|
||||
<?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.PmsProductCategoryDao">
|
||||
<resultMap id="listWithChildrenMap" type="com.macro.mall.dto.PmsProductCategoryWithChildrenItem"
|
||||
extends="com.macro.mall.mapper.PmsProductCategoryMapper.BaseResultMap">
|
||||
<collection property="children" resultMap="com.macro.mall.mapper.PmsProductCategoryMapper.BaseResultMap"
|
||||
columnPrefix="child_"></collection>
|
||||
</resultMap>
|
||||
<select id="listWithChildren" resultMap="listWithChildrenMap">
|
||||
select
|
||||
c1.id,
|
||||
c1.name,
|
||||
c2.id child_id,
|
||||
c2.name child_name
|
||||
from pms_product_category c1 left join pms_product_category c2 on c1.id = c2.parent_id
|
||||
where c1.parent_id = 0
|
||||
</select>
|
||||
</mapper>
|
Loading…
x
Reference in New Issue
Block a user