每日菜谱增加新增套餐自动带入单品,自动合计单品价格
This commit is contained in:
1 parent
069f2f4b09
commit
a79f99f7f7
3 files changed
+92
No files matched your search
+27
@@ -0,0 +1,27 @@
|
||||
package com.bsd.pjcloud.canteen.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 菜品列表:批量修改上架状态
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "批量修改菜品上架状态")
|
||||
public class CanteenSpuBatchStatusDTO {
|
||||
|
||||
@NotEmpty
|
||||
@Schema(description = "菜品 SPU ID 列表")
|
||||
private List<Long> ids;
|
||||
|
||||
/**
|
||||
* 0=上架,1=下架(与 spu_status 字典一致;不含回收 -1)
|
||||
*/
|
||||
@NotNull
|
||||
@Schema(description = "目标状态:0上架 1下架")
|
||||
private Integer status;
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package com.bsd.pjcloud.canteen.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 仅更新菜品价格(不走 updateDeep,避免清空套餐组成)
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "更新菜品价格")
|
||||
public class CanteenSpuPriceDTO {
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "菜品 SPU ID")
|
||||
private Long id;
|
||||
|
||||
@NotNull
|
||||
@Schema(description = "价格(分)")
|
||||
private Integer price;
|
||||
}
|
||||
+44
@@ -10,6 +10,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.bsd.pjcloud.canteen.constant.StockTypeEnum;
|
||||
import com.bsd.pjcloud.canteen.dto.CanteenDailySpuDTO;
|
||||
import com.bsd.pjcloud.canteen.dto.CanteenSpuBatchPicDTO;
|
||||
import com.bsd.pjcloud.canteen.dto.CanteenSpuBatchStatusDTO;
|
||||
import com.bsd.pjcloud.canteen.dto.CanteenSpuPriceDTO;
|
||||
import com.bsd.pjcloud.canteen.dto.CanteenSpuExportQuery;
|
||||
import com.bsd.pjcloud.canteen.dto.CanteenSpuImportExcel;
|
||||
import com.bsd.pjcloud.canteen.dto.CanteenSpuUpdateStockReqDTO;
|
||||
@@ -233,6 +235,48 @@ public class CanteenSpuController {
|
||||
return ok ? R.ok(null, "已更新 " + dto.getIds().size() + " 道菜封面") : R.failed("更新失败");
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量修改上架状态(0上架 / 1下架)
|
||||
*/
|
||||
@Operation(summary = "批量修改菜品上架状态", description = "批量上架或下架")
|
||||
@SysLog("批量修改菜品上架状态")
|
||||
@PutMapping("/batchStatus")
|
||||
@PreAuthorize("@pms.hasPermission('canteen_canteenSpu_edit')")
|
||||
public R batchStatus(@RequestBody CanteenSpuBatchStatusDTO dto) {
|
||||
if (CollUtil.isEmpty(dto.getIds())) {
|
||||
return R.failed("请选择菜品");
|
||||
}
|
||||
Integer status = dto.getStatus();
|
||||
if (status == null || (status != 0 && status != 1)) {
|
||||
return R.failed("状态只能为上架(0)或下架(1)");
|
||||
}
|
||||
boolean ok = canteenSpuService.update(Wrappers.<CanteenSpuEntity>lambdaUpdate()
|
||||
.set(CanteenSpuEntity::getStatus, status)
|
||||
.in(CanteenSpuEntity::getId, dto.getIds()));
|
||||
String label = status == 0 ? "上架" : "下架";
|
||||
return ok ? R.ok(null, "已" + label + " " + dto.getIds().size() + " 道菜") : R.failed("更新失败");
|
||||
}
|
||||
|
||||
/**
|
||||
* 仅更新价格,不触碰套餐组成(供每日菜谱「按单品合计」等场景)
|
||||
*/
|
||||
@Operation(summary = "更新菜品价格", description = "仅更新价格字段")
|
||||
@SysLog("更新菜品价格")
|
||||
@PutMapping("/updatePrice")
|
||||
@PreAuthorize("@pms.hasPermission('canteen_canteenSpu_edit')")
|
||||
public R updatePrice(@RequestBody CanteenSpuPriceDTO dto) {
|
||||
if (dto.getId() == null) {
|
||||
return R.failed("菜品ID不能为空");
|
||||
}
|
||||
if (dto.getPrice() == null || dto.getPrice() < 0) {
|
||||
return R.failed("价格无效");
|
||||
}
|
||||
boolean ok = canteenSpuService.update(Wrappers.<CanteenSpuEntity>lambdaUpdate()
|
||||
.set(CanteenSpuEntity::getPrice, dto.getPrice())
|
||||
.eq(CanteenSpuEntity::getId, dto.getId()));
|
||||
return ok ? R.ok(Boolean.TRUE, "价格已更新") : R.failed("更新失败");
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改菜品spu
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user