Merge branch 'refs/heads/master' into 支付优化测试
# Conflicts: # yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/app/dishes/vo/AppSaveVO.java
This commit is contained in:
		| @ -177,6 +177,7 @@ public interface ErrorCodeConstants { | ||||
|     ErrorCode DISHES_EXISTS = new ErrorCode(1_002_030_003, "菜品名重复"); | ||||
|     // ========== 菜品关联门店 1-002-032-000 ========== | ||||
|     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 ========== | ||||
|     ErrorCode CARTEEN_MONEY_NOT_EXISTS = new ErrorCode(1_002_033_002, "门店流水不存在"); | ||||
|     // ========== 门店 流水 1_002_034_002 ========== | ||||
|  | ||||
| @ -32,4 +32,7 @@ public class AppUpdateVO { | ||||
|  | ||||
|     @Schema(description = "时段", example = "早") | ||||
|     private String timeSlot; | ||||
|  | ||||
|     @Schema(description = "门店", example = "早") | ||||
|     private Long carteenId; | ||||
| } | ||||
|  | ||||
| @ -37,20 +37,18 @@ public class DishesTypeAppController { | ||||
|     @Resource | ||||
|     private DishesTypeService dishesTypeService; | ||||
|  | ||||
| //    @PostMapping("/create") | ||||
| //    @Operation(summary = "创建菜品分类") | ||||
| //    @PreAuthorize("@ss.hasPermission('t:dishes-type:create')") | ||||
| //    public CommonResult<Long> createDishesType(@Valid @RequestBody DishesTypeSaveReqVO createReqVO) { | ||||
| //        return success(dishesTypeService.createDishesType(createReqVO)); | ||||
| //    } | ||||
| // | ||||
| //    @PutMapping("/update") | ||||
| //    @Operation(summary = "更新菜品分类") | ||||
| //    @PreAuthorize("@ss.hasPermission('t:dishes-type:update')") | ||||
| //    public CommonResult<Boolean> updateDishesType(@Valid @RequestBody DishesTypeSaveReqVO updateReqVO) { | ||||
| //        dishesTypeService.updateDishesType(updateReqVO); | ||||
| //        return success(true); | ||||
| //    } | ||||
|     @PostMapping("/create") | ||||
|     @Operation(summary = "创建菜品分类") | ||||
|     public CommonResult<Long> createDishesType(@Valid @RequestBody DishesTypeSaveReqVO createReqVO) { | ||||
|         return success(dishesTypeService.createDishesType(createReqVO)); | ||||
|     } | ||||
|  | ||||
|     @PutMapping("/update") | ||||
|     @Operation(summary = "更新菜品分类") | ||||
|     public CommonResult<Boolean> updateDishesType(@Valid @RequestBody DishesTypeSaveReqVO updateReqVO) { | ||||
|         dishesTypeService.updateDishesType(updateReqVO); | ||||
|         return success(true); | ||||
|     } | ||||
| // | ||||
| //    @DeleteMapping("/delete") | ||||
| //    @Operation(summary = "删除菜品分类") | ||||
| @ -92,4 +90,6 @@ public class DishesTypeAppController { | ||||
| //                        BeanUtils.toBean(list, DishesTypeRespVO.class)); | ||||
| //    } | ||||
|  | ||||
|  | ||||
|  | ||||
| } | ||||
| @ -113,8 +113,10 @@ public class DishesServiceImpl implements DishesService { | ||||
|         DishesDO dishes = BeanUtils.toBean(vo, DishesDO.class); | ||||
|         dishes.setDeleted(Boolean.FALSE); | ||||
|  | ||||
|         Long carteenId = deviceInfoService.getCarteen(getHearder()); | ||||
|         dishes.setCarteenId(carteenId); | ||||
|         if(vo.getCarteenId() == null ){ | ||||
|             vo.setCarteenId(deviceInfoService.getCarteen(getHearder())) ; | ||||
|         } | ||||
|         dishes.setCarteenId(vo.getCarteenId()); | ||||
|         dishes.setDishesNumber(new BigDecimal("50")); | ||||
|  | ||||
|         checkDishes(dishes.getDishesName(),dishes.getCarteenId(),null); | ||||
| @ -178,7 +180,11 @@ public class DishesServiceImpl implements DishesService { | ||||
|         DishesDO dishesDO = validateDishesExists(vo.getId()); | ||||
|         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多少钱 | ||||
|         BigDecimal dishesSumPrice = updateObj.getDishesSumPrice(); | ||||
|  | ||||
| @ -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.TimePeriodEnum; | ||||
| 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.validation.annotation.Validated; | ||||
|  | ||||
| @ -50,6 +51,7 @@ public class DishesTypeServiceImpl implements DishesTypeService { | ||||
|         // 插入 | ||||
|         DishesTypeDO dishesType = BeanUtils.toBean(createReqVO, DishesTypeDO.class); | ||||
|         dishesType.setDeleted(Boolean.FALSE); | ||||
|         validateDishesTypeRepeat(dishesType.getCarteenId(),dishesType.getDishesTypeName(),null); | ||||
|         dishesTypeMapper.insert(dishesType); | ||||
|         // 返回 | ||||
|         return dishesType.getId(); | ||||
| @ -59,6 +61,7 @@ public class DishesTypeServiceImpl implements DishesTypeService { | ||||
|     public void updateDishesType(DishesTypeSaveReqVO updateReqVO) { | ||||
|         // 校验存在 | ||||
|         validateDishesTypeExists(updateReqVO.getId()); | ||||
|         validateDishesTypeRepeat(updateReqVO.getCarteenId(),updateReqVO.getDishesTypeName(),updateReqVO.getId()); | ||||
|         // 更新 | ||||
|         DishesTypeDO updateObj = BeanUtils.toBean(updateReqVO, DishesTypeDO.class); | ||||
|         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 | ||||
|     public DishesTypeDO getDishesType(Long id) { | ||||
|         return dishesTypeMapper.selectById(id); | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 seesaw
					seesaw