商品模块代码提交
This commit is contained in:
@@ -2,6 +2,7 @@ package com.czg.controller.admin;
|
||||
|
||||
import com.czg.log.annotation.OperationLog;
|
||||
import com.czg.product.dto.ProductDTO;
|
||||
import com.czg.product.param.ProductIsSaleParam;
|
||||
import com.czg.product.service.ProductService;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.czg.utils.AssertUtil;
|
||||
@@ -80,4 +81,15 @@ public class ProductController {
|
||||
return CzgResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品-上下架
|
||||
*/
|
||||
@PostMapping("/on-off")
|
||||
@OperationLog("商品-上下架")
|
||||
//@SaAdminCheckPermission("product:on-off")
|
||||
public CzgResult<Void> onOffProduct(@RequestBody @Validated({DefaultGroup.class}) ProductIsSaleParam param) {
|
||||
productService.onOffProduct(param);
|
||||
return CzgResult.success();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package com.czg.product.service;
|
||||
|
||||
import com.czg.product.dto.ProductDTO;
|
||||
import com.czg.product.entity.Product;
|
||||
import com.czg.product.param.ProductIsSaleParam;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
|
||||
@@ -21,9 +22,10 @@ public interface ProductService extends IService<Product> {
|
||||
ProductDTO getProductById(Long id);
|
||||
|
||||
boolean addProduct(ProductDTO dto);
|
||||
|
||||
boolean deleteProduct(Long id);
|
||||
|
||||
boolean updateProduct(ProductDTO dto);
|
||||
|
||||
boolean deleteProduct(Long id);
|
||||
|
||||
boolean onOffProduct(ProductIsSaleParam param);
|
||||
}
|
||||
@@ -63,6 +63,18 @@ public class MiniAppHomeProductInfoVo implements Serializable {
|
||||
* 会员最低售价
|
||||
*/
|
||||
private BigDecimal lowMemberPrice;
|
||||
/**
|
||||
* 是否售罄
|
||||
*/
|
||||
private Integer isSoldStock;
|
||||
/**
|
||||
* 商品库存
|
||||
*/
|
||||
private Integer stockNumber;
|
||||
/**
|
||||
* 是否上架 0-未上架,1-已上架
|
||||
*/
|
||||
private Integer isSale;
|
||||
/**
|
||||
* 商品SKU列表
|
||||
*/
|
||||
|
||||
@@ -13,7 +13,9 @@ import com.czg.product.dto.ProdSkuDTO;
|
||||
import com.czg.product.dto.ProductDTO;
|
||||
import com.czg.product.entity.ProdSku;
|
||||
import com.czg.product.entity.Product;
|
||||
import com.czg.product.enums.ProductIsSaleTypeEnum;
|
||||
import com.czg.product.enums.ProductTypeEnum;
|
||||
import com.czg.product.param.ProductIsSaleParam;
|
||||
import com.czg.product.service.ProductService;
|
||||
import com.czg.sa.StpKit;
|
||||
import com.czg.service.product.mapper.ProdSkuMapper;
|
||||
@@ -233,4 +235,30 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
|
||||
.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean onOffProduct(ProductIsSaleParam param) {
|
||||
Long shopId = StpKit.USER.getLoginIdAsLong();
|
||||
String type = param.getType();
|
||||
Long id = param.getId();
|
||||
Integer isSale = param.getIsSale();
|
||||
if (ProductIsSaleTypeEnum.PRODUCT.value().equals(type)) {
|
||||
UpdateChain.of(Product.class)
|
||||
.set(Product::getIsSale, isSale)
|
||||
.eq(Product::getId, id)
|
||||
.eq(Product::getShopId, shopId)
|
||||
.update();
|
||||
UpdateChain.of(ProdSku.class)
|
||||
.set(ProdSku::getIsGrounding, isSale)
|
||||
.eq(ProdSku::getProductId, id)
|
||||
.update();
|
||||
} else if (ProductIsSaleTypeEnum.SKU.value().equals(type)) {
|
||||
UpdateChain.of(ProdSku.class)
|
||||
.set(ProdSku::getIsGrounding, isSale)
|
||||
.eq(ProdSku::getId, id)
|
||||
.update();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -95,7 +95,11 @@ public class UProductServiceImpl extends ServiceImpl<ProductMapper, Product> imp
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<Long> prodIdList = dtoList.stream().map(ProductDTO::getId).distinct().toList();
|
||||
List<ProdSkuDTO> skuList = prodSkuMapper.selectListByQueryAs(query().in(ProdSku::getProductId, prodIdList).eq(ProdSku::getIsDel, DeleteEnum.NORMAL.value()), ProdSkuDTO.class);
|
||||
List<ProdSkuDTO> skuList = prodSkuMapper.selectListByQueryAs(query()
|
||||
.in(ProdSku::getProductId, prodIdList)
|
||||
.eq(ProdSku::getIsDel, DeleteEnum.NORMAL.value())
|
||||
.eq(ProdSku::getIsGrounding, YesNoEnum.YES.value())
|
||||
, ProdSkuDTO.class);
|
||||
Map<Long, List<ProdSkuDTO>> collect = skuList.stream().collect(Collectors.groupingBy(ProdSkuDTO::getProductId));
|
||||
List<MiniAppHomeProductInfoVo> products = new ArrayList<>();
|
||||
for (ProductDTO dto : dtoList) {
|
||||
@@ -109,6 +113,9 @@ public class UProductServiceImpl extends ServiceImpl<ProductMapper, Product> imp
|
||||
prod.setType(dto.getType());
|
||||
prod.setGroupType(dto.getGroupType());
|
||||
prod.setSelectSpecInfo(dto.getSelectSpecInfo());
|
||||
prod.setIsSoldStock(dto.getIsSoldStock());
|
||||
prod.setStockNumber(dto.getStockNumber());
|
||||
prod.setIsSale(dto.getIsSale());
|
||||
|
||||
List<ProdSkuDTO> list = collect.getOrDefault(dto.getId(), Collections.emptyList());
|
||||
Optional<BigDecimal> lowPriceIsPresent = list.stream().map(ProdSkuDTO::getSalePrice).min(BigDecimal::compareTo);
|
||||
|
||||
Reference in New Issue
Block a user