商品模块代码提交
This commit is contained in:
parent
6312eff400
commit
1f3954df60
|
|
@ -4,6 +4,7 @@ import com.czg.log.annotation.OperationLog;
|
|||
import com.czg.product.dto.ProdSkuDTO;
|
||||
import com.czg.product.dto.ProductDTO;
|
||||
import com.czg.product.param.ProductIsSaleParam;
|
||||
import com.czg.product.param.ProductIsSoldOutParam;
|
||||
import com.czg.product.service.ProductService;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.czg.utils.AssertUtil;
|
||||
|
|
@ -97,4 +98,15 @@ public class ProductController {
|
|||
return CzgResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品-标记售罄
|
||||
*/
|
||||
@PostMapping("/markIsSoldOut")
|
||||
@OperationLog("商品-标记售罄")
|
||||
//@SaAdminCheckPermission("product:markIsSoldOut")
|
||||
public CzgResult<Void> markIsSoldOutProduct(@RequestBody @Validated({DefaultGroup.class}) ProductIsSoldOutParam param) {
|
||||
productService.markProductIsSoldOut(param);
|
||||
return CzgResult.success();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -3,6 +3,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.czg.product.param.ProductIsSoldOutParam;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
|
||||
|
|
@ -28,4 +29,6 @@ public interface ProductService extends IService<Product> {
|
|||
boolean deleteProduct(Long id);
|
||||
|
||||
boolean onOffProduct(ProductIsSaleParam param);
|
||||
|
||||
boolean markProductIsSoldOut(ProductIsSoldOutParam param);
|
||||
}
|
||||
|
|
@ -16,6 +16,7 @@ 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.param.ProductIsSoldOutParam;
|
||||
import com.czg.product.service.ProductService;
|
||||
import com.czg.sa.StpKit;
|
||||
import com.czg.service.product.mapper.ProdSkuMapper;
|
||||
|
|
@ -256,23 +257,38 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
|
|||
String type = param.getType();
|
||||
Long id = param.getId();
|
||||
Integer isSale = param.getIsSale();
|
||||
UpdateChain.of(ProdSku.class)
|
||||
.set(ProdSku::getIsGrounding, isSale)
|
||||
.eq(ProdSku::getId, id)
|
||||
.update();
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean markProductIsSoldOut(ProductIsSoldOutParam param) {
|
||||
Long shopId = StpKit.USER.getLoginIdAsLong();
|
||||
String type = param.getType();
|
||||
Long id = param.getId();
|
||||
Integer isSoldOut = param.getIsSoldOut();
|
||||
UpdateChain.of(ProdSku.class)
|
||||
.set(ProdSku::getIsPauseSale, isSoldOut)
|
||||
.eq(ProdSku::getProductId, id)
|
||||
.update();
|
||||
if (ProductIsSaleTypeEnum.PRODUCT.value().equals(type)) {
|
||||
UpdateChain.of(Product.class)
|
||||
.set(Product::getIsSoldStock, isSoldOut)
|
||||
.eq(Product::getId, id)
|
||||
.eq(Product::getShopId, shopId)
|
||||
.update();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue