Squashed commit of the following:
commitee0ee9b167Merge:e78ab0bcd4888dAuthor: liguoyang <Ligy.97@foxmail.com> Date: Tue Mar 19 12:07:22 2024 +0800 Merge branch 'development' of https://git.dlhis.com/liguoyang/jinko.yikatong into development commite78ab0baeaAuthor: liguoyang <Ligy.97@foxmail.com> Date: Tue Mar 19 12:06:13 2024 +0800 fix 增加权限控制 commit793a3325f2Author: liguoyang <Ligy.97@foxmail.com> Date: Tue Mar 19 10:24:41 2024 +0800 Squashed commit of the following: commit d4ab7d407a141b80024f85eeaab0062bea016051 Author: liguoyang <Ligy.97@foxmail.com> Date: Tue Mar 19 10:23:30 2024 +0800 merge error commit 6204fa4ed15e0be303f7eb62307476725b8e7e36 Merge: 7290f0b aaeacf4 Author: liguoyang <Ligy.97@foxmail.com> Date: Tue Mar 19 10:19:41 2024 +0800 Merge branch 'feat-PlacePermission' of https://git.dlhis.com/liguoyang/jinko.yikatong into feat-PlacePermission commit 7290f0bd822c0e2bd957908fd58f6e99f22ad46b Author: cheche <717840555@qq.com> Date: Tue Mar 12 15:05:28 2024 +0800 fix 获取用户权限设备 优化 commit 41b94fa3a9596a38cda1b4bf4f345ce13fe5677a Author: cheche <717840555@qq.com> Date: Tue Mar 12 13:13:23 2024 +0800 fix 第一 commit aaeacf4ffa778eb6a6104e2349357644d038151b Author: cheche <717840555@qq.com> Date: Tue Mar 12 15:05:28 2024 +0800 fix 获取用户权限设备 优化 commit 9e6099c52d0318cba35e7c082cb4d3085b46b0fa Author: cheche <717840555@qq.com> Date: Tue Mar 12 14:00:53 2024 +0800 fix 营业点配置权限 commit b4565e34f48da0e5ef1d3dffa59d0ccf0d950920 Author: cheche <717840555@qq.com> Date: Tue Mar 12 13:13:23 2024 +0800 fix 第一 commit153f0ecd2aAuthor: cheche <717840555@qq.com> Date: Tue Mar 19 09:58:31 2024 +0800 fix 返回支付方式中文描述 commite548c780b8Author: liguoyang <Ligy.97@foxmail.com> Date: Mon Mar 18 16:59:45 2024 +0800 fix 优化送餐 commitfa376f7671Author: liguoyang <Ligy.97@foxmail.com> Date: Mon Mar 18 16:11:45 2024 +0800 fix 参数结构调整 commit1b58ca69bfAuthor: liguoyang <Ligy.97@foxmail.com> Date: Mon Mar 18 15:57:18 2024 +0800 fix 餐次数据补充 commite8a98c614cAuthor: liguoyang <Ligy.97@foxmail.com> Date: Mon Mar 18 15:11:56 2024 +0800 add 补充实体变更 commit4651adedc3Author: liguoyang <Ligy.97@foxmail.com> Date: Mon Mar 18 15:11:38 2024 +0800 fix 优化查询,增加详情接口 commitad48e37273Author: liguoyang <Ligy.97@foxmail.com> Date: Mon Mar 18 15:09:16 2024 +0800 fix 枚举code过滤 commitabf2e2ed29Author: cheche <717840555@qq.com> Date: Mon Mar 18 14:44:15 2024 +0800 fix 获取订餐最晚时间 commit00869111dfAuthor: cheche <717840555@qq.com> Date: Mon Mar 18 14:21:19 2024 +0800 fix 检验权限修改 commit7b83014119Author: liguoyang <Ligy.97@foxmail.com> Date: Mon Mar 18 13:42:35 2024 +0800 fix 优化菜品保存和分页 commitfefc785b66Author: cheche <717840555@qq.com> Date: Mon Mar 18 14:17:19 2024 +0800 fix 修改营业点返回体 commit3b7874a2a0Author: cheche <717840555@qq.com> Date: Mon Mar 18 12:14:06 2024 +0800 fix currentUser commitc825531fdaAuthor: liguoyang <Ligy.97@foxmail.com> Date: Mon Mar 18 11:03:43 2024 +0800 fix 提交可编译版本 commit8f430bccd3Author: cheche <717840555@qq.com> Date: Mon Mar 18 11:48:38 2024 +0800 fix GetDishesMenusBookingResponse修改字段 commit69c60dc459Author: liguoyang <Ligy.97@foxmail.com> Date: Mon Mar 18 10:59:52 2024 +0800 fix 增加日期返回 commitfadee3861aAuthor: cheche <717840555@qq.com> Date: Mon Mar 18 11:01:31 2024 +0800 fix GetDishesMenusBookingSetting返回体修改 commit058b989eadAuthor: cheche <717840555@qq.com> Date: Mon Mar 18 10:54:28 2024 +0800 fix 获取营业点下面餐次 commita82e7ff798Author: liguoyang <Ligy.97@foxmail.com> Date: Mon Mar 18 10:28:56 2024 +0800 fix 命名空间调整 commit9acdab4e01Author: liguoyang <Ligy.97@foxmail.com> Date: Mon Mar 18 10:27:46 2024 +0800 fix 更新控制器名称 commit3005443392Author: liguoyang <Ligy.97@foxmail.com> Date: Mon Mar 18 10:01:03 2024 +0800 feat 菜品/菜单配置 commita59404711cAuthor: liguoyang <Ligy.97@foxmail.com> Date: Sun Mar 17 21:26:16 2024 +0800 feat 获取服务时间 commitba0fe3e67fAuthor: liguoyang <Ligy.97@foxmail.com> Date: Sun Mar 17 20:58:11 2024 +0800 fix 处理next空数组 commit97fb157c9fAuthor: liguoyang <Ligy.97@foxmail.com> Date: Fri Mar 15 20:49:44 2024 +0800 fix 营业点权限调整 commit70420b9668Author: cheche <717840555@qq.com> Date: Fri Mar 15 18:54:15 2024 +0800 fix 修改IBusinessPlacePermissionsService commit6f2383c663Author: cheche <717840555@qq.com> Date: Fri Mar 15 18:47:33 2024 +0800 fix api commit99e1c8f125Author: liguoyang <Ligy.97@foxmail.com> Date: Fri Mar 15 18:03:09 2024 +0800 fix 实体变更 commitd327e9e3aaAuthor: liguoyang <Ligy.97@foxmail.com> Date: Fri Mar 15 16:06:17 2024 +0800 fix 临时修改送餐代码 commit4825648e41Author: liguoyang <Ligy.97@foxmail.com> Date: Fri Mar 15 15:13:53 2024 +0800 fix 按基地分配获取值错误 commit8ed8addbf3Author: cheche <717840555@qq.com> Date: Fri Mar 15 15:10:55 2024 +0800 fix 表增加ITenantid commitcd4888d900Author: liguoyang <Ligy.97@foxmail.com> Date: Tue Mar 19 12:06:13 2024 +0800 fix 增加权限控制 commit1cd9b2467eAuthor: liguoyang <Ligy.97@foxmail.com> Date: Tue Mar 19 10:24:41 2024 +0800 Squashed commit of the following: commit d4ab7d407a141b80024f85eeaab0062bea016051 Author: liguoyang <Ligy.97@foxmail.com> Date: Tue Mar 19 10:23:30 2024 +0800 merge error commit 6204fa4ed15e0be303f7eb62307476725b8e7e36 Merge: 7290f0b aaeacf4 Author: liguoyang <Ligy.97@foxmail.com> Date: Tue Mar 19 10:19:41 2024 +0800 Merge branch 'feat-PlacePermission' of https://git.dlhis.com/liguoyang/jinko.yikatong into feat-PlacePermission commit 7290f0bd822c0e2bd957908fd58f6e99f22ad46b Author: cheche <717840555@qq.com> Date: Tue Mar 12 15:05:28 2024 +0800 fix 获取用户权限设备 优化 commit 41b94fa3a9596a38cda1b4bf4f345ce13fe5677a Author: cheche <717840555@qq.com> Date: Tue Mar 12 13:13:23 2024 +0800 fix 第一 commit aaeacf4ffa778eb6a6104e2349357644d038151b Author: cheche <717840555@qq.com> Date: Tue Mar 12 15:05:28 2024 +0800 fix 获取用户权限设备 优化 commit 9e6099c52d0318cba35e7c082cb4d3085b46b0fa Author: cheche <717840555@qq.com> Date: Tue Mar 12 14:00:53 2024 +0800 fix 营业点配置权限 commit b4565e34f48da0e5ef1d3dffa59d0ccf0d950920 Author: cheche <717840555@qq.com> Date: Tue Mar 12 13:13:23 2024 +0800 fix 第一 commited25ab626aAuthor: cheche <717840555@qq.com> Date: Tue Mar 19 09:58:31 2024 +0800 fix 返回支付方式中文描述 commitc4b48131d2Author: liguoyang <Ligy.97@foxmail.com> Date: Mon Mar 18 16:59:45 2024 +0800 fix 优化送餐 commit8f26e7e84bAuthor: liguoyang <Ligy.97@foxmail.com> Date: Mon Mar 18 16:11:45 2024 +0800 fix 参数结构调整 commit8307d1d941Author: liguoyang <Ligy.97@foxmail.com> Date: Mon Mar 18 15:57:18 2024 +0800 fix 餐次数据补充 commit068a5b9507Author: liguoyang <Ligy.97@foxmail.com> Date: Mon Mar 18 15:11:56 2024 +0800 add 补充实体变更 commit805f0f83d1Author: liguoyang <Ligy.97@foxmail.com> Date: Mon Mar 18 15:11:38 2024 +0800 fix 优化查询,增加详情接口 commit9ef57fba55Author: liguoyang <Ligy.97@foxmail.com> Date: Mon Mar 18 15:09:16 2024 +0800 fix 枚举code过滤 commit0124fa4bc9Author: cheche <717840555@qq.com> Date: Mon Mar 18 14:44:15 2024 +0800 fix 获取订餐最晚时间 commitfd4a925b4aAuthor: cheche <717840555@qq.com> Date: Mon Mar 18 14:21:19 2024 +0800 fix 检验权限修改 commite6dee2d504Merge:2cbf894b3b9962Author: cheche <717840555@qq.com> Date: Mon Mar 18 14:18:15 2024 +0800 fix 解决dishersservice冲突 commit2cbf894ea8Author: cheche <717840555@qq.com> Date: Mon Mar 18 14:17:19 2024 +0800 fix 修改营业点返回体 commitb3b99623e3Author: liguoyang <Ligy.97@foxmail.com> Date: Mon Mar 18 13:42:35 2024 +0800 fix 优化菜品保存和分页 commitfcc1f134edAuthor: cheche <717840555@qq.com> Date: Mon Mar 18 12:14:06 2024 +0800 fix currentUser commit253caf26c1Merge:c743d2d63ded81Author: cheche <717840555@qq.com> Date: Mon Mar 18 11:48:41 2024 +0800 Merge branch 'development' of https://git.dlhis.com/liguoyang/jinko.yikatong into development commitc743d2d1c5Author: cheche <717840555@qq.com> Date: Mon Mar 18 11:48:38 2024 +0800 fix GetDishesMenusBookingResponse修改字段 commit63ded819c5Merge:5fe41043b46ac2Author: liguoyang <Ligy.97@foxmail.com> Date: Mon Mar 18 11:03:45 2024 +0800 Merge branch 'development' of https://git.dlhis.com/liguoyang/jinko.yikatong into development commit5fe4104ff6Author: liguoyang <Ligy.97@foxmail.com> Date: Mon Mar 18 11:03:43 2024 +0800 fix 提交可编译版本 commit3b46ac25a7Merge:11a3a0aa2eca2cAuthor: cheche <717840555@qq.com> Date: Mon Mar 18 11:01:33 2024 +0800 Merge branch 'development' of https://git.dlhis.com/liguoyang/jinko.yikatong into development commit11a3a0adedAuthor: cheche <717840555@qq.com> Date: Mon Mar 18 11:01:31 2024 +0800 fix GetDishesMenusBookingSetting返回体修改 commita2eca2cdebAuthor: liguoyang <Ligy.97@foxmail.com> Date: Mon Mar 18 10:59:52 2024 +0800 fix 增加日期返回 commit0bed0bc97bAuthor: cheche <717840555@qq.com> Date: Mon Mar 18 10:54:28 2024 +0800 fix 获取营业点下面餐次 commitc1d84ae1c6Author: liguoyang <Ligy.97@foxmail.com> Date: Mon Mar 18 10:28:56 2024 +0800 fix 命名空间调整 commite2cc31003fAuthor: liguoyang <Ligy.97@foxmail.com> Date: Mon Mar 18 10:27:46 2024 +0800 fix 更新控制器名称 commitab406adecfAuthor: liguoyang <Ligy.97@foxmail.com> Date: Mon Mar 18 10:01:03 2024 +0800 feat 菜品/菜单配置 commit6ba2d7d6a2Author: liguoyang <Ligy.97@foxmail.com> Date: Sun Mar 17 21:26:16 2024 +0800 feat 获取服务时间 commit6872518b65Author: liguoyang <Ligy.97@foxmail.com> Date: Sun Mar 17 20:58:11 2024 +0800 fix 处理next空数组 commit423d90bf3dAuthor: liguoyang <Ligy.97@foxmail.com> Date: Fri Mar 15 20:49:44 2024 +0800 fix 营业点权限调整 commit220ff2d963Author: cheche <717840555@qq.com> Date: Fri Mar 15 18:54:15 2024 +0800 fix 修改IBusinessPlacePermissionsService commit72f93a59a6Author: cheche <717840555@qq.com> Date: Fri Mar 15 18:47:33 2024 +0800 fix api commit149660ca0fAuthor: liguoyang <Ligy.97@foxmail.com> Date: Fri Mar 15 18:03:09 2024 +0800 fix 实体变更 commit9a84143315Author: liguoyang <Ligy.97@foxmail.com> Date: Fri Mar 15 16:06:17 2024 +0800 fix 临时修改送餐代码 commit328ef5f42cAuthor: liguoyang <Ligy.97@foxmail.com> Date: Fri Mar 15 15:13:53 2024 +0800 fix 按基地分配获取值错误 commitea4a15c44bMerge:a3112eb255f4b4Author: liguoyang <Ligy.97@foxmail.com> Date: Fri Mar 15 15:13:37 2024 +0800 Merge branch 'development' of https://git.dlhis.com/liguoyang/jinko.yikatong into development commit255f4b4a13Author: cheche <717840555@qq.com> Date: Fri Mar 15 15:10:55 2024 +0800 fix 表增加ITenantid
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
using Dlhis.Basic.Dishes.Request;
|
||||
using Dlhis.Basic.Dishes.Response;
|
||||
using Dlhis.Basic.Dishes.Services;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Dlhis.Basic.Dishes.Controller;
|
||||
|
||||
/// <summary>
|
||||
/// 菜品分类
|
||||
/// </summary>
|
||||
[Authorize]
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class DishesCategoriesController : ControllerBase
|
||||
{
|
||||
private readonly IDishesCategoryService _dishesCategoryService;
|
||||
|
||||
public DishesCategoriesController(IDishesCategoryService dishesCategoryService)
|
||||
{
|
||||
_dishesCategoryService = dishesCategoryService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取分类树
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("tree")]
|
||||
public async Task<List<DishesCategoryTreeResponse>> TreeAsync()
|
||||
{
|
||||
return await _dishesCategoryService.TreeAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存分类
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("save")]
|
||||
public async Task SaveAsync(DishesCategorySaveRequest request)
|
||||
{
|
||||
await _dishesCategoryService.SaveAsync(request);
|
||||
}
|
||||
}
|
||||
111
Src/Dlhis.Basic/Dishes/Controller/DishesMenusController.cs
Normal file
111
Src/Dlhis.Basic/Dishes/Controller/DishesMenusController.cs
Normal file
@@ -0,0 +1,111 @@
|
||||
using Dlhis.Basic.Dishes.Dto;
|
||||
using Dlhis.Basic.Dishes.Request;
|
||||
using Dlhis.Basic.Dishes.Response;
|
||||
using Dlhis.Basic.Dishes.Services;
|
||||
using Dlhis.Entity.Canteen.Enums;
|
||||
using Kurisu.AspNetCore.DataAccess.SqlSugar.Aop;
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Dlhis.Basic.Dishes.Controller;
|
||||
|
||||
/// <summary>
|
||||
/// 菜单菜品控制器
|
||||
/// </summary>
|
||||
[Authorize]
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class DishesMenusController : ControllerBase
|
||||
{
|
||||
private readonly IDishesMenuService _dishesMenuService;
|
||||
private readonly IDishesService _dishesService;
|
||||
|
||||
public DishesMenusController(IDishesMenuService dishesMenuService, IDishesService dishesService)
|
||||
{
|
||||
_dishesMenuService = dishesMenuService;
|
||||
_dishesService = dishesService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 菜单分页
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("page")]
|
||||
public async Task<Pagination<DishesMenuPageResponse>> GetDishesMenuPageAsync([FromQuery] DisheMenuPageRequest request)
|
||||
{
|
||||
return await _dishesMenuService.GetDishesMenuPageAsync(request);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 菜单保存/更改
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("save")]
|
||||
[Transactional]
|
||||
public async Task SaveDishesMenuAsync(DishesMenuSaveRequest request)
|
||||
{
|
||||
await _dishesMenuService.SaveDishesMenuAsync(request);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 菜单明细
|
||||
/// </summary>
|
||||
/// <param name="date"></param>
|
||||
/// <param name="businessPlaceCode"></param>
|
||||
/// <param name="shiftType"></param>
|
||||
/// <param name="dishesCode"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("detail")]
|
||||
public async Task<DishesMenuDetailDto> GetBookingDishesDetailAsync(DateTime date, Guid businessPlaceCode, ShiftEnumType shiftType, string dishesCode)
|
||||
{
|
||||
return await _dishesMenuService.GetBookingDishesDetailAsync(date, businessPlaceCode, shiftType, dishesCode);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 菜品分页
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("dishes/page")]
|
||||
public async Task<Pagination<DishesResponse>> GetDishesAsync([FromQuery] DishesPageRequest request)
|
||||
{
|
||||
return await _dishesService.GetDishesPageAsync(request);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 菜品保存/更改
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("dishes/save")]
|
||||
public async Task SaveDishesAsync(DishesSaveRequest request)
|
||||
{
|
||||
await _dishesService.SaveDishesAsync(request);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据id获取菜品详情
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("dishes/detail/{id}")]
|
||||
public async Task<DishesDetailResponse> GetDishesDetailByIdAsync(long id)
|
||||
{
|
||||
return await _dishesService.GetDishesDetailByIdAsync(id);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取预定送餐配置
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("setting")]
|
||||
public async Task<GetDishesMenusBookingResponse> GetDishesMenusBookingSetting([FromQuery] GetDishesMenusBookingRequest request)
|
||||
{
|
||||
return await _dishesService.GetDishesMenusBookingSetting(request);
|
||||
}
|
||||
}
|
||||
|
||||
20
Src/Dlhis.Basic/Dishes/Dto/DishesMenuDetailDto.cs
Normal file
20
Src/Dlhis.Basic/Dishes/Dto/DishesMenuDetailDto.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
namespace Dlhis.Basic.Dishes.Dto;
|
||||
|
||||
public class DishesMenuDetailDto
|
||||
{
|
||||
public DateTime Date { get; set; }
|
||||
|
||||
public long MenuId { get; set; }
|
||||
|
||||
public long DishesId { get; set; }
|
||||
|
||||
public string DishesCode { get; set; }
|
||||
|
||||
public string DishesName { get; set; }
|
||||
|
||||
public decimal Price { get; set; }
|
||||
|
||||
public int Number { get; set; }
|
||||
|
||||
public int Version { get; set; }
|
||||
}
|
||||
22
Src/Dlhis.Basic/Dishes/Request/DisheMenuPageRequest.cs
Normal file
22
Src/Dlhis.Basic/Dishes/Request/DisheMenuPageRequest.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using Dlhis.Entity.Canteen.Enums;
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
|
||||
namespace Dlhis.Basic.Dishes.Request;
|
||||
|
||||
public class DisheMenuPageRequest : PageDto
|
||||
{
|
||||
/// <summary>
|
||||
/// 营业点code
|
||||
/// </summary>
|
||||
public Guid BusinessPlaceCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 餐次
|
||||
/// </summary>
|
||||
public List<ShiftEnumType> ShiftTypes { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 分类
|
||||
/// </summary>
|
||||
public Guid? CategoryCode { get; set; }
|
||||
}
|
||||
24
Src/Dlhis.Basic/Dishes/Request/DishesCategorySaveRequest.cs
Normal file
24
Src/Dlhis.Basic/Dishes/Request/DishesCategorySaveRequest.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Dlhis.Basic.Dishes.Request;
|
||||
|
||||
public class DishesCategorySaveRequest
|
||||
{
|
||||
public long? Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// PCode
|
||||
/// </summary>
|
||||
public Guid? PCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 分类名称
|
||||
/// </summary>
|
||||
[Required]
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 序号
|
||||
/// </summary>
|
||||
public int Sequence { get; set; } = 100;
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
|
||||
namespace Dlhis.Basic.Dishes.Request;
|
||||
|
||||
public class DishesMenuNameDateSaveRequest : IValidatableObject
|
||||
{
|
||||
/// <summary>
|
||||
/// 菜单编码
|
||||
/// </summary>
|
||||
public string CustomCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 菜单日期
|
||||
/// </summary>
|
||||
public DateTime Date { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 餐次数据
|
||||
/// </summary>
|
||||
public List<DishesMenuShiftTypeSaveRequest> ShiftTypes { get; set; }
|
||||
|
||||
|
||||
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
||||
{
|
||||
if (Date < DateTime.Today)
|
||||
{
|
||||
yield return new ValidationResult("菜单日期不能小于当天");
|
||||
}
|
||||
|
||||
//格式化
|
||||
Date = Date.Date;
|
||||
|
||||
if (CustomCode.IsEmpty())
|
||||
{
|
||||
CustomCode = Date.ToString("yyyy-MM-dd");
|
||||
}
|
||||
}
|
||||
}
|
||||
18
Src/Dlhis.Basic/Dishes/Request/DishesMenuSaveRequest.cs
Normal file
18
Src/Dlhis.Basic/Dishes/Request/DishesMenuSaveRequest.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Dlhis.Basic.Dishes.Request;
|
||||
|
||||
public class DishesMenuSaveRequest : IValidatableObject
|
||||
{
|
||||
/// <summary>
|
||||
/// 营业点code
|
||||
/// </summary>
|
||||
public Guid BusinessPlaceCode { get; set; }
|
||||
|
||||
public List<DishesMenuNameDateSaveRequest> Items { get; set; }
|
||||
|
||||
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Dlhis.Entity.Canteen.Enums;
|
||||
|
||||
namespace Dlhis.Basic.Dishes.Request;
|
||||
|
||||
public class DishesMenuShiftTypeSaveRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// 餐次段
|
||||
/// </summary>
|
||||
[EnumDataType(typeof(ShiftEnumType))]
|
||||
public ShiftEnumType ShiftType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 菜品
|
||||
/// </summary>
|
||||
public List<MenuDishesSaveRequest> Dishes { get; set; }
|
||||
}
|
||||
11
Src/Dlhis.Basic/Dishes/Request/DishesPageRequest.cs
Normal file
11
Src/Dlhis.Basic/Dishes/Request/DishesPageRequest.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
|
||||
namespace Dlhis.Basic.Dishes.Request;
|
||||
|
||||
public class DishesPageRequest : PageDto
|
||||
{
|
||||
/// <summary>
|
||||
/// 营业点
|
||||
/// </summary>
|
||||
public List<Guid> BusinessPlaceCodes { get; set; }
|
||||
}
|
||||
59
Src/Dlhis.Basic/Dishes/Request/DishesSaveRequest.cs
Normal file
59
Src/Dlhis.Basic/Dishes/Request/DishesSaveRequest.cs
Normal file
@@ -0,0 +1,59 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Dlhis.Basic.Dishes.Request;
|
||||
|
||||
public class DishesSaveRequest
|
||||
{
|
||||
public long? Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 分类
|
||||
/// </summary>
|
||||
[Required]
|
||||
public Guid CategoryCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 营业点
|
||||
/// </summary>
|
||||
[Required]
|
||||
public Guid BusinessPlaceCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 菜品名称
|
||||
/// </summary>
|
||||
[Required]
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 菜单编码
|
||||
/// </summary>
|
||||
[Required]
|
||||
public string CustomCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 描述
|
||||
/// </summary>
|
||||
public string Description { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 单价
|
||||
/// </summary>
|
||||
[Range(0, 10000)]
|
||||
public decimal Price { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 图片
|
||||
/// </summary>
|
||||
public string ImageUrl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 单位
|
||||
/// </summary>
|
||||
[MinLength(1)]
|
||||
public List<string> Units { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否启用
|
||||
/// </summary>
|
||||
public bool Enable { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace Dlhis.Basic.Dishes.Request
|
||||
{
|
||||
public class GetDishesMenusBookingRequest
|
||||
{
|
||||
public Guid PlaceCode { get; set; }
|
||||
|
||||
public string Factory { get; set; }
|
||||
}
|
||||
}
|
||||
24
Src/Dlhis.Basic/Dishes/Request/MenuDishesSaveRequest.cs
Normal file
24
Src/Dlhis.Basic/Dishes/Request/MenuDishesSaveRequest.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Dlhis.Basic.Dishes.Request;
|
||||
|
||||
public class MenuDishesSaveRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// 菜品编码
|
||||
/// </summary>
|
||||
[Required]
|
||||
public string DishesCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 菜单价
|
||||
/// </summary>
|
||||
[Range(0, double.MaxValue)]
|
||||
public decimal? Price { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 售额
|
||||
/// </summary>
|
||||
[Range(0, int.MaxValue)]
|
||||
public int Number { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
using Dlhis.Entity.Canteen.Enums;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
|
||||
namespace Dlhis.Basic.Dishes.Response
|
||||
{
|
||||
public class BalanceRecordSourceEnumDto
|
||||
{
|
||||
public BalanceRecordSourceEnumType Type { get; set; }
|
||||
public string TypeCN => Type.GetDescription();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using Dlhis.Entity.Canteen.Enums;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
|
||||
namespace Dlhis.Basic.Dishes.Response
|
||||
{
|
||||
public class BusinessShiftMealRelationshipResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// 餐别Code
|
||||
/// </summary>
|
||||
public Guid ShiftCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 餐别手工号
|
||||
/// </summary>
|
||||
public string ShiftCustomCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 餐次
|
||||
/// </summary>
|
||||
public ShiftEnumType ShiftType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 餐次CN
|
||||
/// </summary>
|
||||
public string ShiftTypeCN => ShiftType.GetDescription();
|
||||
|
||||
}
|
||||
}
|
||||
15
Src/Dlhis.Basic/Dishes/Response/DishesCategoryResponse.cs
Normal file
15
Src/Dlhis.Basic/Dishes/Response/DishesCategoryResponse.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
namespace Dlhis.Basic.Dishes.Response;
|
||||
|
||||
public class DishesCategoryTreeResponse
|
||||
{
|
||||
public Guid? PCode { get; set; }
|
||||
|
||||
public Guid Code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 分类名称
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
public List<DishesCategoryTreeResponse> Next { get; set; }
|
||||
}
|
||||
51
Src/Dlhis.Basic/Dishes/Response/DishesDetailResponse.cs
Normal file
51
Src/Dlhis.Basic/Dishes/Response/DishesDetailResponse.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
namespace Dlhis.Basic.Dishes.Response;
|
||||
|
||||
public class DishesDetailResponse
|
||||
{
|
||||
public long Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 分类
|
||||
/// </summary>
|
||||
public Guid CategoryCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 营业点
|
||||
/// </summary>
|
||||
public Guid BusinessPlaceCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 菜品编码
|
||||
/// </summary>
|
||||
public string CustomCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 菜品名称
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 描述
|
||||
/// </summary>
|
||||
public string Description { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 单价
|
||||
/// </summary>
|
||||
public decimal Price { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 单位
|
||||
/// </summary>
|
||||
public List<string> Units { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 图片
|
||||
/// </summary>
|
||||
public string ImageUrl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否启用
|
||||
/// </summary>
|
||||
public bool Enable { get; set; }
|
||||
}
|
||||
51
Src/Dlhis.Basic/Dishes/Response/DishesMenuPageResponse.cs
Normal file
51
Src/Dlhis.Basic/Dishes/Response/DishesMenuPageResponse.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using Dlhis.Entity.Canteen.Enums;
|
||||
|
||||
namespace Dlhis.Basic.Dishes.Response;
|
||||
|
||||
public class DishesMenuPageResponse
|
||||
{
|
||||
public long? Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 菜单编码
|
||||
/// </summary>
|
||||
public string CustomCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 所属营业点
|
||||
/// </summary>
|
||||
public Guid BusinessPlaceCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 营业日期
|
||||
/// </summary>
|
||||
public DateTime Date { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 餐次
|
||||
/// </summary>
|
||||
public ShiftEnumType ShiftType { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 菜品编码
|
||||
/// </summary>
|
||||
public string DishesCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 剩余数量
|
||||
/// </summary>
|
||||
public int Number { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 单价
|
||||
/// </summary>
|
||||
public decimal? Price { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否启用
|
||||
/// </summary>
|
||||
public bool Enable { get; set; }
|
||||
}
|
||||
60
Src/Dlhis.Basic/Dishes/Response/DishesResponse.cs
Normal file
60
Src/Dlhis.Basic/Dishes/Response/DishesResponse.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Dlhis.Basic.Dishes.Response;
|
||||
|
||||
public class DishesResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// 分类
|
||||
/// </summary>
|
||||
public Guid CategoryCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 分类
|
||||
/// </summary>
|
||||
public string CategoryName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 营业点
|
||||
/// </summary>
|
||||
public Guid BusinessPlaceCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 菜品编码
|
||||
/// </summary>
|
||||
public string CustomCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 菜品名称
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 描述
|
||||
/// </summary>
|
||||
public string Description { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 单价
|
||||
/// </summary>
|
||||
public decimal Price { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 单位
|
||||
/// </summary>
|
||||
public List<string> Units => CurrnetUnits.ToObject<List<string>>();
|
||||
|
||||
[JsonIgnore]
|
||||
public string CurrnetUnits { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 图片
|
||||
/// </summary>
|
||||
public string ImageUrl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否启用
|
||||
/// </summary>
|
||||
public bool Enable { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using Dlhis.Entity.Canteen.Enums;
|
||||
using SqlSugar.DbConvert;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Dlhis.Basic.Dishes.Response
|
||||
{
|
||||
public class GetDishesMenusBookingResponse
|
||||
{
|
||||
public List<BusinessShiftMealRelationshipResponse> BusinessShiftMealRelationships { get; set; }
|
||||
|
||||
public DateTime ServiceTime { get; set; }
|
||||
|
||||
public List<BalanceRecordSourceEnumDto> PayTypes { get; set; }
|
||||
}
|
||||
}
|
||||
11
Src/Dlhis.Basic/Dishes/Services/IDishesCategoryService.cs
Normal file
11
Src/Dlhis.Basic/Dishes/Services/IDishesCategoryService.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using Dlhis.Basic.Dishes.Request;
|
||||
using Dlhis.Basic.Dishes.Response;
|
||||
|
||||
namespace Dlhis.Basic.Dishes.Services;
|
||||
|
||||
public interface IDishesCategoryService : IScopeDependency
|
||||
{
|
||||
Task<List<DishesCategoryTreeResponse>> TreeAsync();
|
||||
|
||||
Task SaveAsync(DishesCategorySaveRequest request);
|
||||
}
|
||||
16
Src/Dlhis.Basic/Dishes/Services/IDishesMenuService.cs
Normal file
16
Src/Dlhis.Basic/Dishes/Services/IDishesMenuService.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using Dlhis.Entity.Canteen.Enums;
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
using Dlhis.Basic.Dishes.Request;
|
||||
using Dlhis.Basic.Dishes.Dto;
|
||||
using Dlhis.Basic.Dishes.Response;
|
||||
|
||||
namespace Dlhis.Basic.Dishes.Services;
|
||||
|
||||
public interface IDishesMenuService : IScopeDependency
|
||||
{
|
||||
Task<Pagination<DishesMenuPageResponse>> GetDishesMenuPageAsync(DisheMenuPageRequest request);
|
||||
|
||||
Task SaveDishesMenuAsync(DishesMenuSaveRequest request);
|
||||
|
||||
Task<DishesMenuDetailDto> GetBookingDishesDetailAsync(DateTime date, Guid businessPlaceCode, ShiftEnumType shiftType, string dishesCode);
|
||||
}
|
||||
17
Src/Dlhis.Basic/Dishes/Services/IDishesService.cs
Normal file
17
Src/Dlhis.Basic/Dishes/Services/IDishesService.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using Dlhis.Basic.Dishes.Request;
|
||||
using Dlhis.Basic.Dishes.Response;
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
|
||||
namespace Dlhis.Basic.Dishes.Services;
|
||||
|
||||
public interface IDishesService : IScopeDependency
|
||||
{
|
||||
Task<Pagination<DishesResponse>> GetDishesPageAsync(DishesPageRequest request);
|
||||
|
||||
Task SaveDishesAsync(DishesSaveRequest request);
|
||||
|
||||
Task<DishesDetailResponse> GetDishesDetailByIdAsync(long id);
|
||||
|
||||
Task<GetDishesMenusBookingResponse> GetDishesMenusBookingSetting(GetDishesMenusBookingRequest request);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
using Dlhis.Basic.Dishes.Request;
|
||||
using Dlhis.Basic.Dishes.Response;
|
||||
using Dlhis.Entity.Canteen.Entities;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
using Kurisu.SqlSugar.Services;
|
||||
using Mapster;
|
||||
|
||||
namespace Dlhis.Basic.Dishes.Services.Implements;
|
||||
|
||||
public class DishesCategoryService : IDishesCategoryService
|
||||
{
|
||||
private readonly IDbContext _dbContext;
|
||||
|
||||
public DishesCategoryService(IDbContext dbContext)
|
||||
{
|
||||
_dbContext = dbContext;
|
||||
}
|
||||
|
||||
public async Task<List<DishesCategoryTreeResponse>> TreeAsync()
|
||||
{
|
||||
var categories = await _dbContext.Queryable<DishesCategoryEntity>().Select<DishesCategoryTreeResponse>().ToListAsync();
|
||||
var tops = categories.Where(x => !x.PCode.HasValue).ToList();
|
||||
|
||||
tops.ForEach(x =>
|
||||
{
|
||||
RecursionGetNext(x, categories);
|
||||
});
|
||||
|
||||
return tops;
|
||||
}
|
||||
|
||||
public async Task SaveAsync(DishesCategorySaveRequest request)
|
||||
{
|
||||
if (!request.Id.HasValue)
|
||||
{
|
||||
var entity = request.Adapt<DishesCategoryEntity>();
|
||||
entity.Code = Guid.NewGuid();
|
||||
await _dbContext.InsertAsync(entity);
|
||||
}
|
||||
else
|
||||
{
|
||||
var entity = await _dbContext.Queryable<DishesCategoryEntity>().Where(x => x.Id == request.Id).FirstAsync();
|
||||
entity.ThrowIfNull("分类不存在,无法更新");
|
||||
request.Adapt(entity);
|
||||
|
||||
await _dbContext.UpdateAsync(entity);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//************************************************************************************************************************
|
||||
|
||||
private static void RecursionGetNext(DishesCategoryTreeResponse current, List<DishesCategoryTreeResponse> data)
|
||||
{
|
||||
var next = data.Where(x => x.PCode == current.Code).ToList();
|
||||
if (next.Any())
|
||||
{
|
||||
current.Next = next;
|
||||
foreach (var item in next)
|
||||
{
|
||||
RecursionGetNext(item, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
134
Src/Dlhis.Basic/Dishes/Services/Implements/DishesMenuService.cs
Normal file
134
Src/Dlhis.Basic/Dishes/Services/Implements/DishesMenuService.cs
Normal file
@@ -0,0 +1,134 @@
|
||||
using Dlhis.Entity.Canteen.Entities;
|
||||
using Dlhis.Entity.Canteen.Enums;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
using Kurisu.SqlSugar.Extensions;
|
||||
using Kurisu.SqlSugar.Services;
|
||||
using SqlSugar;
|
||||
using Dlhis.Basic.Dishes.Request;
|
||||
using Dlhis.Basic.Dishes.Response;
|
||||
using Dlhis.Basic.BusinessPlace.Services;
|
||||
using Dlhis.Basic.Dishes.Dto;
|
||||
|
||||
namespace Dlhis.Basic.Dishes.Services.Implements;
|
||||
|
||||
public class DishesMenuService : IDishesMenuService
|
||||
{
|
||||
private readonly IDbContext _dbContext;
|
||||
private readonly IBusinessPlacePermissionsService _businessPlacePermissionsService;
|
||||
|
||||
public DishesMenuService(IDbContext dbContext, IBusinessPlacePermissionsService businessPlacePermissionsService)
|
||||
{
|
||||
_dbContext = dbContext;
|
||||
_businessPlacePermissionsService = businessPlacePermissionsService;
|
||||
}
|
||||
|
||||
public async Task<Pagination<DishesMenuPageResponse>> GetDishesMenuPageAsync(DisheMenuPageRequest request)
|
||||
{
|
||||
return await _dbContext.Queryable<DishesMenuEntity>()
|
||||
.Select<DishesMenuPageResponse>()
|
||||
.ToPageListAsync(request);
|
||||
}
|
||||
|
||||
public async Task SaveDishesMenuAsync(DishesMenuSaveRequest request)
|
||||
{
|
||||
//检验数据
|
||||
CheckDuplicateData(request);
|
||||
|
||||
//检验权限
|
||||
var res = await _businessPlacePermissionsService.GetMyAsync();
|
||||
var myBps = res.dtos.Select(x => x.Code).ToList();
|
||||
|
||||
myBps.Contains(request.BusinessPlaceCode).ThrowIfFalse("非经营营业点,无法保存菜单");
|
||||
|
||||
var entities = request.Items.SelectMany(item =>
|
||||
{
|
||||
var customCode = item.CustomCode;
|
||||
var date = item.Date;
|
||||
|
||||
return item.ShiftTypes.SelectMany(shiftTypeItem =>
|
||||
{
|
||||
var shiftType = shiftTypeItem.ShiftType;
|
||||
|
||||
return shiftTypeItem.Dishes.Select(dishesItem =>
|
||||
{
|
||||
var dishesCode = dishesItem.DishesCode;
|
||||
var number = dishesItem.Number;
|
||||
var price = dishesItem.Price;
|
||||
|
||||
return new DishesMenuEntity
|
||||
{
|
||||
BusinessPlaceCode = request.BusinessPlaceCode,
|
||||
CustomCode = customCode,
|
||||
Date = date,
|
||||
ShiftType = shiftType,
|
||||
DishesCode = dishesCode,
|
||||
Number = number,
|
||||
Price = price,
|
||||
|
||||
Type = CanteenApplicaitonTypeEnumType.Booking,
|
||||
Version = 0,
|
||||
Enable = true,
|
||||
};
|
||||
});
|
||||
});
|
||||
}).ToList();
|
||||
|
||||
var keys = entities.DistinctBy(x => new { x.Date, x.ShiftType }).Select(x => new { x.Date, x.ShiftType }).ToList();
|
||||
var where = LinqExpressionExtension.False<DishesMenuEntity>();
|
||||
keys.ForEach(x =>
|
||||
{
|
||||
where = where.Or(item => item.Date == x.Date && item.ShiftType == x.ShiftType);
|
||||
});
|
||||
|
||||
await _dbContext.Client.Deleteable<DishesMenuEntity>().Where(where).ExecuteCommandAsync();
|
||||
await _dbContext.InsertAsync(entities);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task<DishesMenuDetailDto> GetBookingDishesDetailAsync(DateTime date, Guid businessPlaceCode, ShiftEnumType shiftType, string dishesCode)
|
||||
{
|
||||
var detail = await _dbContext.Queryable<DishesMenuEntity>()
|
||||
.LeftJoin<DishesEntity>((x, d) => x.DishesCode == d.CustomCode)
|
||||
.Where(x => x.Date == date)
|
||||
.Where(x => x.BusinessPlaceCode == businessPlaceCode)
|
||||
.Where(x => x.ShiftType == shiftType)
|
||||
.Where(x => x.DishesCode == dishesCode)
|
||||
.Where((x, d) => d.Enable)
|
||||
.Select((x, d) => new DishesMenuDetailDto
|
||||
{
|
||||
Date = x.Date,
|
||||
MenuId = x.Id,
|
||||
DishesId = d.Id,
|
||||
DishesCode = d.CustomCode,
|
||||
DishesName = d.Name,
|
||||
Price = x.Price == null || x.Price == 0 ? d.Price : x.Price.Value,
|
||||
Number = x.Number,
|
||||
Version = x.Version,
|
||||
})
|
||||
.SingleAsync();
|
||||
|
||||
return detail;
|
||||
}
|
||||
|
||||
//*********************************************************help methods**********************************************************************
|
||||
|
||||
private static void CheckDuplicateData(DishesMenuSaveRequest request)
|
||||
{
|
||||
(request.Items.DistinctBy(x => new { x.CustomCode, x.Date }).Count() != request.Items.Count).ThrowIfTrue("菜单不可重复");
|
||||
|
||||
foreach (var item in request.Items)
|
||||
{
|
||||
var u = item.Date.ToString("yyyy-MM-dd") + "-" + item.CustomCode;
|
||||
|
||||
(item.ShiftTypes.DistinctBy(x => x.ShiftType).Count() != item.ShiftTypes.Count).ThrowIfTrue($"{u}的餐次不可重复添加");
|
||||
|
||||
foreach (var shiftTypeItem in item.ShiftTypes)
|
||||
{
|
||||
(shiftTypeItem.Dishes.DistinctBy(x => x.DishesCode).Count() != shiftTypeItem.Dishes.Count)
|
||||
.ThrowIfTrue($"{u}的{shiftTypeItem.ShiftType.GetDescription()}下菜品不可重复");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
121
Src/Dlhis.Basic/Dishes/Services/Implements/DishesService.cs
Normal file
121
Src/Dlhis.Basic/Dishes/Services/Implements/DishesService.cs
Normal file
@@ -0,0 +1,121 @@
|
||||
using Dlhis.Basic.Dishes.Request;
|
||||
using Dlhis.Basic.Dishes.Response;
|
||||
using Dlhis.Entity.Basic.Entity;
|
||||
using Dlhis.Entity.Canteen.Entities;
|
||||
using Dlhis.Entity.Canteen.Enums;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
using Kurisu.SqlSugar.Extensions;
|
||||
using Kurisu.SqlSugar.Services;
|
||||
using Mapster;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
|
||||
namespace Dlhis.Basic.Dishes.Services.Implements;
|
||||
|
||||
public class DishesService : IDishesService
|
||||
{
|
||||
private readonly IDbContext _dbContext;
|
||||
private readonly IConfiguration _configuration;
|
||||
|
||||
public DishesService(IDbContext dbContext, IConfiguration configuration)
|
||||
{
|
||||
_dbContext = dbContext;
|
||||
_configuration = configuration;
|
||||
}
|
||||
|
||||
public async Task<Pagination<DishesResponse>> GetDishesPageAsync(DishesPageRequest request)
|
||||
{
|
||||
//todo 营业点权限
|
||||
|
||||
return await _dbContext.Queryable<DishesEntity>()
|
||||
.LeftJoin<DishesCategoryEntity>((x, category) => x.CategoryCode == category.Code)
|
||||
.WhereIF(request.Search.IsPresent(), x => x.CustomCode == request.Search || x.Name.Contains(request.Search))
|
||||
.WhereIF(request.BusinessPlaceCodes.IsPresent(), x => request.BusinessPlaceCodes.Contains(x.BusinessPlaceCode))
|
||||
.OrderBy(x => x.CreateTime, SqlSugar.OrderByType.Desc)
|
||||
.Select((x, category) => new DishesResponse
|
||||
{
|
||||
CurrnetUnits = x.Units.ToString(),
|
||||
CategoryName = category.Name,
|
||||
|
||||
}, true)
|
||||
.ToPageListAsync(request);
|
||||
}
|
||||
|
||||
|
||||
public async Task SaveDishesAsync(DishesSaveRequest request)
|
||||
{
|
||||
if (!request.Id.HasValue)
|
||||
{
|
||||
var dishers = request.Adapt<DishesEntity>();
|
||||
dishers.CustomCode = request.CustomCode;
|
||||
await _dbContext.InsertAsync(dishers);
|
||||
}
|
||||
else
|
||||
{
|
||||
var entity = await _dbContext.Queryable<DishesEntity>().Where(x => x.Id == request.Id).FirstAsync();
|
||||
entity.ThrowIfNull("菜品不存在,无法更新");
|
||||
|
||||
request.Adapt(entity);
|
||||
await _dbContext.UpdateAsync(entity);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<GetDishesMenusBookingResponse> GetDishesMenusBookingSetting(GetDishesMenusBookingRequest request)
|
||||
{
|
||||
// 读取最晚订餐的时间
|
||||
var strDatetime = await _dbContext.Queryable<CanteenSettingEntity>()
|
||||
.Where(x => x.UniqueType == CanteenSettingUnqiueEnumType.Tenant && x.Item == CanteenSettingItemEnumType.BookingDeadline && x.Enable)
|
||||
.Select(x => x.Value)
|
||||
.FirstAsync();
|
||||
|
||||
DateTime dateTime;
|
||||
DateTime.TryParseExact(strDatetime, "HH:mm:ss", null, System.Globalization.DateTimeStyles.None, out dateTime);
|
||||
|
||||
var res = new GetDishesMenusBookingResponse
|
||||
{
|
||||
ServiceTime = dateTime,
|
||||
};
|
||||
|
||||
var shift = await _dbContext.Queryable<BusinessPlaceShiftRelationshipEntity>()
|
||||
.Where(x => x.PlaceCode == request.PlaceCode)
|
||||
.FirstAsync();
|
||||
|
||||
var payTypes = new List<BalanceRecordSourceEnumDto>();
|
||||
var dto1 = new BalanceRecordSourceEnumDto
|
||||
{
|
||||
Type = BalanceRecordSourceEnumType.Cash
|
||||
};
|
||||
payTypes.Add(dto1);
|
||||
|
||||
if (shift != null)
|
||||
{
|
||||
var businessShiftMealRelationships = await _dbContext.Queryable<BusinessShiftMealRelationshipEntity>()
|
||||
.Where(x => x.ShiftCode == shift.ShiftCode)
|
||||
.Select<BusinessShiftMealRelationshipResponse>()
|
||||
.ToListAsync();
|
||||
res.BusinessShiftMealRelationships = businessShiftMealRelationships;
|
||||
|
||||
if (shift.TenantId == request.Factory)
|
||||
{
|
||||
var dto2 = new BalanceRecordSourceEnumDto
|
||||
{
|
||||
Type = BalanceRecordSourceEnumType.LocalTenantSubsidies
|
||||
};
|
||||
payTypes.Add(dto2);
|
||||
}
|
||||
|
||||
}
|
||||
res.PayTypes = payTypes;
|
||||
return res;
|
||||
}
|
||||
|
||||
public async Task<DishesDetailResponse> GetDishesDetailByIdAsync(long id)
|
||||
{
|
||||
return await _dbContext.Queryable<DishesEntity>()
|
||||
.Where(x => x.Id == id)
|
||||
.Select<DishesDetailResponse>()
|
||||
.SingleAsync();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user