菜品,菜品分类

This commit is contained in:
seesaw
2024-10-21 14:41:06 +08:00
parent 669887e3b1
commit 8591f6b0f0
6 changed files with 46 additions and 17 deletions

View File

@ -177,6 +177,7 @@ public interface ErrorCodeConstants {
ErrorCode DISHES_EXISTS = new ErrorCode(1_002_030_003, "菜品名重复"); ErrorCode DISHES_EXISTS = new ErrorCode(1_002_030_003, "菜品名重复");
// ========== 菜品关联门店 1-002-032-000 ========== // ========== 菜品关联门店 1-002-032-000 ==========
ErrorCode DISHES_TYPE_NOT_EXISTS = new ErrorCode(1_002_032_002, "当前菜品类型不存在"); ErrorCode DISHES_TYPE_NOT_EXISTS = new ErrorCode(1_002_032_002, "当前菜品类型不存在");
ErrorCode DISHES_TYPE_NAME_REPEAT = new ErrorCode(1_002_032_003, "当前菜品名称重复");
// ========== 门店 流水 1_002_033_002 ========== // ========== 门店 流水 1_002_033_002 ==========
ErrorCode CARTEEN_MONEY_NOT_EXISTS = new ErrorCode(1_002_033_002, "门店流水不存在"); ErrorCode CARTEEN_MONEY_NOT_EXISTS = new ErrorCode(1_002_033_002, "门店流水不存在");
// ========== 门店 流水 1_002_034_002 ========== // ========== 门店 流水 1_002_034_002 ==========

View File

@ -31,4 +31,7 @@ public class AppSaveVO {
@Schema(description = "时段", example = "") @Schema(description = "时段", example = "")
private String timeSlot; private String timeSlot;
@Schema(description = "时段", example = "")
private Long carteenId;
} }

View File

@ -32,4 +32,7 @@ public class AppUpdateVO {
@Schema(description = "时段", example = "") @Schema(description = "时段", example = "")
private String timeSlot; private String timeSlot;
@Schema(description = "门店", example = "")
private Long carteenId;
} }

View File

@ -37,20 +37,18 @@ public class DishesTypeAppController {
@Resource @Resource
private DishesTypeService dishesTypeService; private DishesTypeService dishesTypeService;
// @PostMapping("/create") @PostMapping("/create")
// @Operation(summary = "创建菜品分类") @Operation(summary = "创建菜品分类")
// @PreAuthorize("@ss.hasPermission('t:dishes-type:create')") public CommonResult<Long> createDishesType(@Valid @RequestBody DishesTypeSaveReqVO createReqVO) {
// public CommonResult<Long> createDishesType(@Valid @RequestBody DishesTypeSaveReqVO createReqVO) { return success(dishesTypeService.createDishesType(createReqVO));
// return success(dishesTypeService.createDishesType(createReqVO)); }
// }
// @PutMapping("/update")
// @PutMapping("/update") @Operation(summary = "更新菜品分类")
// @Operation(summary = "更新菜品分类") public CommonResult<Boolean> updateDishesType(@Valid @RequestBody DishesTypeSaveReqVO updateReqVO) {
// @PreAuthorize("@ss.hasPermission('t:dishes-type:update')") dishesTypeService.updateDishesType(updateReqVO);
// public CommonResult<Boolean> updateDishesType(@Valid @RequestBody DishesTypeSaveReqVO updateReqVO) { return success(true);
// dishesTypeService.updateDishesType(updateReqVO); }
// return success(true);
// }
// //
// @DeleteMapping("/delete") // @DeleteMapping("/delete")
// @Operation(summary = "删除菜品分类") // @Operation(summary = "删除菜品分类")
@ -92,4 +90,6 @@ public class DishesTypeAppController {
// BeanUtils.toBean(list, DishesTypeRespVO.class)); // BeanUtils.toBean(list, DishesTypeRespVO.class));
// } // }
} }

View File

@ -113,8 +113,10 @@ public class DishesServiceImpl implements DishesService {
DishesDO dishes = BeanUtils.toBean(vo, DishesDO.class); DishesDO dishes = BeanUtils.toBean(vo, DishesDO.class);
dishes.setDeleted(Boolean.FALSE); dishes.setDeleted(Boolean.FALSE);
Long carteenId = deviceInfoService.getCarteen(getHearder()); if(vo.getCarteenId() == null ){
dishes.setCarteenId(carteenId); vo.setCarteenId(deviceInfoService.getCarteen(getHearder())) ;
}
dishes.setCarteenId(vo.getCarteenId());
dishes.setDishesNumber(new BigDecimal("50")); dishes.setDishesNumber(new BigDecimal("50"));
checkDishes(dishes.getDishesName(),dishes.getCarteenId(),null); checkDishes(dishes.getDishesName(),dishes.getCarteenId(),null);
@ -178,7 +180,11 @@ public class DishesServiceImpl implements DishesService {
DishesDO dishesDO = validateDishesExists(vo.getId()); DishesDO dishesDO = validateDishesExists(vo.getId());
DishesDO updateObj = BeanUtils.toBean(vo, DishesDO.class); DishesDO updateObj = BeanUtils.toBean(vo, DishesDO.class);
checkDishes(updateObj.getDishesName(),dishesDO.getCarteenId(),vo.getId()); if(updateObj.getCarteenId() == null ){
updateObj.setCarteenId(dishesDO.getCarteenId()) ;
}
checkDishes(updateObj.getDishesName(),updateObj.getCarteenId(),vo.getId());
//计算每g多少钱 //计算每g多少钱
BigDecimal dishesSumPrice = updateObj.getDishesSumPrice(); BigDecimal dishesSumPrice = updateObj.getDishesSumPrice();

View File

@ -17,6 +17,7 @@ import cn.iocoder.yudao.module.system.dal.mysql.dishestype.DishesTypeMapper;
import cn.iocoder.yudao.module.system.enums.ErrorCodeConstants; import cn.iocoder.yudao.module.system.enums.ErrorCodeConstants;
import cn.iocoder.yudao.module.system.enums.TimePeriodEnum; import cn.iocoder.yudao.module.system.enums.TimePeriodEnum;
import cn.iocoder.yudao.module.system.service.dishes.DishesService; import cn.iocoder.yudao.module.system.service.dishes.DishesService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
@ -50,6 +51,7 @@ public class DishesTypeServiceImpl implements DishesTypeService {
// 插入 // 插入
DishesTypeDO dishesType = BeanUtils.toBean(createReqVO, DishesTypeDO.class); DishesTypeDO dishesType = BeanUtils.toBean(createReqVO, DishesTypeDO.class);
dishesType.setDeleted(Boolean.FALSE); dishesType.setDeleted(Boolean.FALSE);
validateDishesTypeRepeat(dishesType.getCarteenId(),dishesType.getDishesTypeName(),null);
dishesTypeMapper.insert(dishesType); dishesTypeMapper.insert(dishesType);
// 返回 // 返回
return dishesType.getId(); return dishesType.getId();
@ -59,6 +61,7 @@ public class DishesTypeServiceImpl implements DishesTypeService {
public void updateDishesType(DishesTypeSaveReqVO updateReqVO) { public void updateDishesType(DishesTypeSaveReqVO updateReqVO) {
// 校验存在 // 校验存在
validateDishesTypeExists(updateReqVO.getId()); validateDishesTypeExists(updateReqVO.getId());
validateDishesTypeRepeat(updateReqVO.getCarteenId(),updateReqVO.getDishesTypeName(),updateReqVO.getId());
// 更新 // 更新
DishesTypeDO updateObj = BeanUtils.toBean(updateReqVO, DishesTypeDO.class); DishesTypeDO updateObj = BeanUtils.toBean(updateReqVO, DishesTypeDO.class);
dishesTypeMapper.updateById(updateObj); dishesTypeMapper.updateById(updateObj);
@ -78,6 +81,19 @@ public class DishesTypeServiceImpl implements DishesTypeService {
} }
} }
private void validateDishesTypeRepeat(Long carteenId,String dishesTypeName,Long id) {
LambdaQueryWrapper<DishesTypeDO> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(DishesTypeDO::getCarteenId,carteenId);
wrapper.eq(DishesTypeDO::getDishesTypeName,dishesTypeName);
wrapper.ne(id!=null,DishesTypeDO::getId,id);
List<DishesTypeDO> dishesTypeDOS = dishesTypeMapper.selectList(wrapper);
if (CollectionUtil.isNotEmpty(dishesTypeDOS)) {
throw exception(ErrorCodeConstants.DISHES_TYPE_NAME_REPEAT);
}
}
@Override @Override
public DishesTypeDO getDishesType(Long id) { public DishesTypeDO getDishesType(Long id) {
return dishesTypeMapper.selectById(id); return dishesTypeMapper.selectById(id);