商品修改 发送通知
This commit is contained in:
@@ -202,6 +202,18 @@ public class ProductController {
|
||||
return CzgResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品-标记售罄
|
||||
*/
|
||||
@PostMapping("markIsAutoSoldOut")
|
||||
//@SaStaffCheckPermission("yun_xu_shou_qing_shang_pin")
|
||||
//@SaAdminCheckPermission("product:markIsSoldOut")
|
||||
public CzgResult<Void> markIsAutoSoldOut(@RequestBody @Validated({DefaultGroup.class}) ProductIsAutoSaleParam param) {
|
||||
productService.markProductIsAutoSoldOut(StpKit.USER.getShopId(), param);
|
||||
ThreadUtil.execAsync(() -> rabbitPublisher.sendProductInfoChangeMsg(Convert.toStr(StpKit.USER.getShopId())));
|
||||
return CzgResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品-绑定耗材
|
||||
*/
|
||||
@@ -211,6 +223,7 @@ public class ProductController {
|
||||
public CzgResult<Void> bindCons(@RequestBody @Validated({DefaultGroup.class}) ProdConsBindDTO param) {
|
||||
AssertUtil.isNull(param.getId(), "商品Id不能为空");
|
||||
prodConsRelationService.saveProdConsRelation(param);
|
||||
ThreadUtil.execAsync(() -> rabbitPublisher.sendProductInfoChangeMsg(Convert.toStr(StpKit.USER.getShopId())));
|
||||
asyncConsProToShop(param.getId());
|
||||
return CzgResult.success();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.czg.product.param;
|
||||
|
||||
import com.czg.validator.group.DefaultGroup;
|
||||
import jakarta.validation.constraints.Max;
|
||||
import jakarta.validation.constraints.Min;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 商品上下架参数
|
||||
*
|
||||
* @author tankaikai
|
||||
* @since 2025-02-18 17:46
|
||||
*/
|
||||
@Data
|
||||
public class ProductIsAutoSaleParam implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
/**
|
||||
* 商品id
|
||||
*/
|
||||
@NotNull(message = "商品id能为空", groups = DefaultGroup.class)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 是否上下架 1-上架,0-下架
|
||||
*/
|
||||
@NotNull(message = "自动售罄不能为空", groups = DefaultGroup.class)
|
||||
@Min(value = 0, message = "自动售罄必须是0或1", groups = DefaultGroup.class)
|
||||
@Max(value = 1, message = "自动售罄必须是0或1", groups = DefaultGroup.class)
|
||||
private Integer isAutoSoldStock;
|
||||
|
||||
|
||||
}
|
||||
@@ -97,6 +97,13 @@ public interface ProductService extends IService<Product> {
|
||||
*/
|
||||
void markProductIsSoldOut(ProductIsSoldOutParam param);
|
||||
|
||||
/**
|
||||
* 标记商品自动售罄
|
||||
*
|
||||
* @param param 入参
|
||||
*/
|
||||
void markProductIsAutoSoldOut(Long shopId, ProductIsAutoSaleParam param);
|
||||
|
||||
/**
|
||||
* 退货到库存
|
||||
*
|
||||
|
||||
@@ -700,6 +700,18 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
|
||||
Product old = getById(prodId);
|
||||
Long categoryId = old.getCategoryId();
|
||||
clearProductCache(categoryId);
|
||||
ThreadUtil.execAsync(() -> rabbitPublisher.sendConsInfoChangeMsg(Convert.toStr(shopId)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markProductIsAutoSoldOut(Long shopId, ProductIsAutoSaleParam param) {
|
||||
Product entity = super.getOne(query().eq(Product::getId, param.getId()).eq(Product::getShopId, shopId));
|
||||
if (entity == null) {
|
||||
throw new CzgException("商品不存在");
|
||||
}
|
||||
Product update = new Product();
|
||||
update.setIsAutoSoldStock(param.getIsAutoSoldStock());
|
||||
update(update, query().eq(Product::getId, param.getId()).eq(Product::getShopId, shopId));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user