From c9e591ca64f3eeba022916d774c9d8570d4b1a89 Mon Sep 17 00:00:00 2001 From: zhh Date: Fri, 25 May 2018 15:36:34 +0800 Subject: [PATCH] =?UTF-8?q?=E5=95=86=E5=93=81=E6=8E=A5=E5=8F=A3=E5=AE=8C?= =?UTF-8?q?=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PmsProductCategoryController.java | 9 +++ .../mall/controller/PmsProductController.java | 52 +++++++++++++ .../macro/mall/dao/PmsProductCategoryDao.java | 13 ++++ .../PmsProductCategoryWithChildrenItem.java | 20 +++++ .../service/PmsProductCategoryService.java | 3 + .../macro/mall/service/PmsProductService.java | 8 ++ .../impl/PmsProductCategoryServiceImpl.java | 9 +++ .../service/impl/PmsProductServiceImpl.java | 73 ++++++++++++++----- .../resources/dao/PmsProductCategoryDao.xml | 18 +++++ 9 files changed, 186 insertions(+), 19 deletions(-) create mode 100644 mall-admin/src/main/java/com/macro/mall/dao/PmsProductCategoryDao.java create mode 100644 mall-admin/src/main/java/com/macro/mall/dto/PmsProductCategoryWithChildrenItem.java create mode 100644 mall-admin/src/main/resources/dao/PmsProductCategoryDao.xml diff --git a/mall-admin/src/main/java/com/macro/mall/controller/PmsProductCategoryController.java b/mall-admin/src/main/java/com/macro/mall/controller/PmsProductCategoryController.java index a378e8c..f3a10a0 100644 --- a/mall-admin/src/main/java/com/macro/mall/controller/PmsProductCategoryController.java +++ b/mall-admin/src/main/java/com/macro/mall/controller/PmsProductCategoryController.java @@ -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 list = productCategoryService.listWithChildren(); + return new CommonResult().success(list); + } } diff --git a/mall-admin/src/main/java/com/macro/mall/controller/PmsProductController.java b/mall-admin/src/main/java/com/macro/mall/controller/PmsProductController.java index 66e9a7b..53e306e 100644 --- a/mall-admin/src/main/java/com/macro/mall/controller/PmsProductController.java +++ b/mall-admin/src/main/java/com/macro/mall/controller/PmsProductController.java @@ -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 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 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 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 ids, + @RequestParam("deleteStatus") Integer deleteStatus) { + int count = productService.updateDeleteStatus(ids, deleteStatus); + if (count > 0) { + return new CommonResult().success(count); + } else { + return new CommonResult().failed(); + } + } } diff --git a/mall-admin/src/main/java/com/macro/mall/dao/PmsProductCategoryDao.java b/mall-admin/src/main/java/com/macro/mall/dao/PmsProductCategoryDao.java new file mode 100644 index 0000000..4224dee --- /dev/null +++ b/mall-admin/src/main/java/com/macro/mall/dao/PmsProductCategoryDao.java @@ -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 listWithChildren(); +} diff --git a/mall-admin/src/main/java/com/macro/mall/dto/PmsProductCategoryWithChildrenItem.java b/mall-admin/src/main/java/com/macro/mall/dto/PmsProductCategoryWithChildrenItem.java new file mode 100644 index 0000000..7d5a990 --- /dev/null +++ b/mall-admin/src/main/java/com/macro/mall/dto/PmsProductCategoryWithChildrenItem.java @@ -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 children; + + public List getChildren() { + return children; + } + + public void setChildren(List children) { + this.children = children; + } +} diff --git a/mall-admin/src/main/java/com/macro/mall/service/PmsProductCategoryService.java b/mall-admin/src/main/java/com/macro/mall/service/PmsProductCategoryService.java index 25f6767..9ea67c7 100644 --- a/mall-admin/src/main/java/com/macro/mall/service/PmsProductCategoryService.java +++ b/mall-admin/src/main/java/com/macro/mall/service/PmsProductCategoryService.java @@ -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 ids, Integer navStatus); int updateShowStatus(List ids, Integer showStatus); + + List listWithChildren(); } diff --git a/mall-admin/src/main/java/com/macro/mall/service/PmsProductService.java b/mall-admin/src/main/java/com/macro/mall/service/PmsProductService.java index 4845d4f..d2d66ce 100644 --- a/mall-admin/src/main/java/com/macro/mall/service/PmsProductService.java +++ b/mall-admin/src/main/java/com/macro/mall/service/PmsProductService.java @@ -45,4 +45,12 @@ public interface PmsProductService { */ @Transactional int updateVerifyStatus(List ids, Integer verifyStatus, String detail); + + int updatePublishStatus(List ids, Integer publishStatus); + + int updateRecommendStatus(List ids, Integer recommendStatus); + + int updateNewStatus(List ids, Integer newStatus); + + int updateDeleteStatus(List ids, Integer deleteStatus); } diff --git a/mall-admin/src/main/java/com/macro/mall/service/impl/PmsProductCategoryServiceImpl.java b/mall-admin/src/main/java/com/macro/mall/service/impl/PmsProductCategoryServiceImpl.java index b34435e..ed2d34f 100644 --- a/mall-admin/src/main/java/com/macro/mall/service/impl/PmsProductCategoryServiceImpl.java +++ b/mall-admin/src/main/java/com/macro/mall/service/impl/PmsProductCategoryServiceImpl.java @@ -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 listWithChildren() { + return productCategoryDao.listWithChildren(); + } + /** * 根据分类的parentId设置分类的level */ diff --git a/mall-admin/src/main/java/com/macro/mall/service/impl/PmsProductServiceImpl.java b/mall-admin/src/main/java/com/macro/mall/service/impl/PmsProductServiceImpl.java index b93768d..48c08cb 100644 --- a/mall-admin/src/main/java/com/macro/mall/service/impl/PmsProductServiceImpl.java +++ b/mall-admin/src/main/java/com/macro/mall/service/impl/PmsProductServiceImpl.java @@ -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 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 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 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 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 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 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 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 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()); } } diff --git a/mall-admin/src/main/resources/dao/PmsProductCategoryDao.xml b/mall-admin/src/main/resources/dao/PmsProductCategoryDao.xml new file mode 100644 index 0000000..33be6e1 --- /dev/null +++ b/mall-admin/src/main/resources/dao/PmsProductCategoryDao.xml @@ -0,0 +1,18 @@ + + + + + + + + \ No newline at end of file