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:
@@ -1,4 +1,5 @@
|
||||
using Dlhis.Canteen.Order.Request;
|
||||
using Dlhis.Canteen.Dishes.Request;
|
||||
using Dlhis.Canteen.Order.Request;
|
||||
using Dlhis.Canteen.Order.Response;
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
using Dlhis.Canteen.Order.Request;
|
||||
using Dlhis.Canteen.Order.Response;
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Dlhis.Canteen.Order.Services
|
||||
{
|
||||
public interface IMenuDishesService :IScopeDependency
|
||||
{
|
||||
Task<Pagination<GetMenuResponse>> GetMenuAsync(GetMenuRequest request);
|
||||
|
||||
Task SaveMenuAsync(SaveMenuRequest request);
|
||||
|
||||
Task<Pagination<GetDishesResponse>> GetDishesAsync(GetDishesRequest request);
|
||||
|
||||
Task SaveDishesAsync(SaveDishesRequest request);
|
||||
|
||||
Task DispositionDishesAsync(DispositionDishesRequest request);
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
using Dlhis.Canteen.Order.Request;
|
||||
using Dlhis.Canteen.Order.Response;
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Dlhis.Canteen.Order.Services
|
||||
{
|
||||
public interface IMiniProgramOrderDetailService : IScopeDependency
|
||||
{
|
||||
Task<Pagination<GetMiniProgramOrderResponse>> GetMiniProgramOrderAsync(GetMiniProgramOrderRequest request);
|
||||
|
||||
Task SaveDetailAsync(SaveDetailRequest request);
|
||||
|
||||
Task<Pagination<GetDetailResponse>> GetDetailAsync( GetDetailRequest request);
|
||||
|
||||
Task OrderAsync(OrderRequest request);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using Dlhis.Canteen.Order.Request;
|
||||
using Dlhis.Canteen.Dishes.Request;
|
||||
using Dlhis.Canteen.Order.Request;
|
||||
using Dlhis.Canteen.Order.Response;
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
|
||||
@@ -10,4 +11,17 @@ public interface IOrderService : IScopeDependency
|
||||
|
||||
Task<OrderResultResponse> AddAsync(OrderAddRequest request);
|
||||
|
||||
/// <summary>
|
||||
/// 设备消费
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
Task<OrderResultResponse> DeviceConsume(OrderAddRequest request);
|
||||
|
||||
/// <summary>
|
||||
/// 订餐
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
Task Booking(BookingMealRequest request);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Dlhis.Canteen.Order.Request;
|
||||
using Dlhis.Canteen.Dishes.Request;
|
||||
using Dlhis.Canteen.Order.Request;
|
||||
using Dlhis.Canteen.Order.Response;
|
||||
using Dlhis.Entity.Basic.Entity;
|
||||
using Dlhis.Entity.Canteen.Entities;
|
||||
@@ -9,12 +10,10 @@ using Dlhis.Sys.Api;
|
||||
using Kurisu.AspNetCore.UnifyResultAndValidation;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
using Kurisu.Core.DataAccess.Entity;
|
||||
using Kurisu.Core.User.Abstractions;
|
||||
using Kurisu.SqlSugar.Extensions;
|
||||
using Kurisu.SqlSugar.Services;
|
||||
using Mapster;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Dlhis.Canteen.Order.Services.Implements;
|
||||
@@ -26,7 +25,7 @@ public class BalanceService : IBalanceService
|
||||
private readonly ILogger<BalanceService> _logger;
|
||||
private readonly ITenantApi _tenantApi;
|
||||
|
||||
public BalanceService(IDbContext dbContext, ICurrentUser currentUser, ILogger<BalanceService> logger ,ITenantApi tenantApi)
|
||||
public BalanceService(IDbContext dbContext, ICurrentUser currentUser, ILogger<BalanceService> logger, ITenantApi tenantApi)
|
||||
{
|
||||
_dbContext = dbContext;
|
||||
_currentUser = currentUser;
|
||||
@@ -41,18 +40,17 @@ public class BalanceService : IBalanceService
|
||||
.LeftJoin<DepartmentEntity>((record, ga, department) => ga.DepartmentNo == department.No)
|
||||
.LeftJoin<BusinessPlaceEntity>((record, ga, department, bplace) => record.BusinessPlaceCode == bplace.Code)
|
||||
.LeftJoin<BusinessShiftEntity>((record, ga, department, bplace, bshift) => record.BusinessShiftCode == bshift.Code)
|
||||
.LeftJoin<BasicTypeEntity>((record, ga, department, bplace, bshift, type) => record.ShiftType == type.Code && type.Type == "mealshift")
|
||||
.WhereIF(request.SearchDateTimePeriod?.Start.HasValue == true, record => record.CostDate >= request.SearchDateTimePeriod.Start)
|
||||
.WhereIF(request.SearchDateTimePeriod?.End.HasValue == true, record => record.CostDate <= request.SearchDateTimePeriod.End)
|
||||
.WhereIF(request.BusinessplaceCodes.IsPresent(), record => request.BusinessplaceCodes.Contains(record.BusinessPlaceCode))
|
||||
.WhereIF(request.ShiftTypes.IsPresent(), record => request.ShiftTypes.Contains(record.ShiftType))
|
||||
.WhereIF(request.Type.HasValue,record => record.Type == request.Type)
|
||||
.WhereIF(request.Type.HasValue, record => record.Type == request.Type)
|
||||
.WhereIF(request.Search.IsPresent(), (record, ga) =>
|
||||
ga.Name.Contains(request.Search)
|
||||
|| ga.Code.Contains(request.Search)
|
||||
)
|
||||
.OrderBy(record => record.CreateTime, OrderByType.Desc)
|
||||
.Select((record, ga, department, bplace, bshift, type) => new BalanceRecordResponse
|
||||
.Select((record, ga, department, bplace, bshift) => new BalanceRecordResponse
|
||||
{
|
||||
Id = record.Id,
|
||||
Amount = record.Amount,
|
||||
@@ -61,7 +59,7 @@ public class BalanceService : IBalanceService
|
||||
CostDate = record.CostDate,
|
||||
CostId = record.CostId,
|
||||
DepartmentNo = record.DepartmentNo,
|
||||
DeviceInfo = record.DeviceInfo,
|
||||
DeviceInfo = record.DeviceUniqueNo,
|
||||
IP = record.IP,
|
||||
UserNo = record.UserNo,
|
||||
UserCode = record.UserCode,
|
||||
@@ -75,7 +73,7 @@ public class BalanceService : IBalanceService
|
||||
Name = record.Name,
|
||||
DepartmentName = department.Name,
|
||||
BusinessPlaceName = bplace.Name,
|
||||
BusinessShiftName = type.Display,
|
||||
BusinessShiftName = bshift.Name,
|
||||
CostDateTime = record.CostDateTime,
|
||||
TenantId = record.TenantId,
|
||||
})
|
||||
@@ -109,8 +107,6 @@ public class BalanceService : IBalanceService
|
||||
/// <returns></returns>
|
||||
public async Task<Pagination<BalanceRecordCostIdResponse>> RecordByCostIdAsync(BalanceRecordPageByCostIdRequest request)
|
||||
{
|
||||
var shiftCodeDict = await GetShiftCode();
|
||||
|
||||
var paeginfos = await _dbContext.Queryable<BalanceRecordEntity>()
|
||||
.WhereIF(!request.UserCode.IsEmpty(), record => record.UserCode == request.UserCode)
|
||||
.WhereIF(!request.DepartmentNo.IsEmpty(), record => record.DepartmentNo == request.DepartmentNo)
|
||||
@@ -132,24 +128,24 @@ public class BalanceService : IBalanceService
|
||||
};
|
||||
|
||||
// 所有人次
|
||||
var BreakfastNumberOfPeople = costIdGroup.Count(x => x.ShiftType == shiftCodeDict["Breakfast"]);
|
||||
var BreakfastNumberOfPeople = costIdGroup.Count(x => x.ShiftType == ShiftEnumType.Breakfast);
|
||||
|
||||
var LunchNumberOfPeople = costIdGroup.Count(x => x.ShiftType == shiftCodeDict["Lunch"]);
|
||||
var LunchNumberOfPeople = costIdGroup.Count(x => x.ShiftType == ShiftEnumType.Lunch);
|
||||
|
||||
var DinnerNumberOfPeople = costIdGroup.Count(x => x.ShiftType == shiftCodeDict["Dinner"]);
|
||||
var DinnerNumberOfPeople = costIdGroup.Count(x => x.ShiftType == ShiftEnumType.Dinner);
|
||||
|
||||
var LateNightNumberOfPeople = costIdGroup.Count(x => x.ShiftType == shiftCodeDict["LateNight"]);
|
||||
var LateNightNumberOfPeople = costIdGroup.Count(x => x.ShiftType == ShiftEnumType.Nightsnack);
|
||||
// 每个餐次人数
|
||||
obj.BreakfastNumberOfPeople = costIdGroup.Where(x => x.ShiftType == shiftCodeDict["Breakfast"]).Select(x => x.UserNo).Distinct().Count();
|
||||
obj.LunchNumberOfPeople = costIdGroup.Where(x => x.ShiftType == shiftCodeDict["Lunch"]).Select(x => x.UserNo).Distinct().Count();
|
||||
obj.DinnerNumberOfPeople = costIdGroup.Where(x => x.ShiftType == shiftCodeDict["Dinner"]).Select(x => x.UserNo).Distinct().Count();
|
||||
obj.LateNightNumberOfPeople = costIdGroup.Where(x => x.ShiftType == shiftCodeDict["LateNight"]).Select(x => x.UserNo).Distinct().Count();
|
||||
obj.BreakfastNumberOfPeople = costIdGroup.Where(x => x.ShiftType == ShiftEnumType.Breakfast).Select(x => x.UserNo).Distinct().Count();
|
||||
obj.LunchNumberOfPeople = costIdGroup.Where(x => x.ShiftType == ShiftEnumType.Lunch).Select(x => x.UserNo).Distinct().Count();
|
||||
obj.DinnerNumberOfPeople = costIdGroup.Where(x => x.ShiftType == ShiftEnumType.Dinner).Select(x => x.UserNo).Distinct().Count();
|
||||
obj.LateNightNumberOfPeople = costIdGroup.Where(x => x.ShiftType == ShiftEnumType.Nightsnack).Select(x => x.UserNo).Distinct().Count();
|
||||
|
||||
//餐次金额
|
||||
obj.BreakfastAmount = Math.Abs(costIdGroup.Where(x => x.ShiftType == shiftCodeDict["Breakfast"]).Sum(x => x.Amount));
|
||||
obj.LunchAmount = Math.Abs(costIdGroup.Where(x => x.ShiftType == shiftCodeDict["Lunch"]).Sum(x => x.Amount));
|
||||
obj.DinnerAmount = Math.Abs(costIdGroup.Where(x => x.ShiftType == shiftCodeDict["Dinner"]).Sum(x => x.Amount));
|
||||
obj.LateNightAmount = Math.Abs(costIdGroup.Where(x => x.ShiftType == shiftCodeDict["LateNight"]).Sum(x => x.Amount));
|
||||
obj.BreakfastAmount = Math.Abs(costIdGroup.Where(x => x.ShiftType == ShiftEnumType.Breakfast).Sum(x => x.Amount));
|
||||
obj.LunchAmount = Math.Abs(costIdGroup.Where(x => x.ShiftType == ShiftEnumType.Lunch).Sum(x => x.Amount));
|
||||
obj.DinnerAmount = Math.Abs(costIdGroup.Where(x => x.ShiftType == ShiftEnumType.Dinner).Sum(x => x.Amount));
|
||||
obj.LateNightAmount = Math.Abs(costIdGroup.Where(x => x.ShiftType == ShiftEnumType.Nightsnack).Sum(x => x.Amount));
|
||||
|
||||
|
||||
// 每个餐次单价
|
||||
@@ -210,7 +206,7 @@ public class BalanceService : IBalanceService
|
||||
CostDate = record.CostDate,
|
||||
CostId = record.CostId,
|
||||
DepartmentNo = record.DepartmentNo,
|
||||
DeviceInfo = record.DeviceInfo,
|
||||
DeviceInfo = record.DeviceUniqueNo,
|
||||
IP = record.IP,
|
||||
UserNo = record.UserNo,
|
||||
UserCode = record.UserCode,
|
||||
@@ -242,8 +238,6 @@ public class BalanceService : IBalanceService
|
||||
/// <returns></returns>
|
||||
public async Task<Pagination<BalanceRecordSummaryRespones>> BalanceRecordSummaryByNoAsync(BalanceRecordSummaryRequest request)
|
||||
{
|
||||
var shiftCodeDict = await GetShiftCode();
|
||||
|
||||
var paeginfos = await _dbContext.Queryable<BalanceRecordEntity>()
|
||||
.WhereIF(!request.DepartmentNo.IsEmpty(), record => record.DepartmentNo == request.DepartmentNo)
|
||||
.WhereIF(!request.UserCode.IsEmpty(), record => record.UserCode == request.UserCode)
|
||||
@@ -267,24 +261,24 @@ public class BalanceService : IBalanceService
|
||||
OriginTenantId = ""
|
||||
};
|
||||
// 所有人次
|
||||
var BreakfastNumberOfPeople = departmentGroup.Count(x => x.ShiftType == shiftCodeDict["Breakfast"]);
|
||||
var BreakfastNumberOfPeople = departmentGroup.Count(x => x.ShiftType == ShiftEnumType.Breakfast);
|
||||
|
||||
var LunchNumberOfPeople = departmentGroup.Count(x => x.ShiftType == shiftCodeDict["Lunch"]);
|
||||
var LunchNumberOfPeople = departmentGroup.Count(x => x.ShiftType == ShiftEnumType.Lunch);
|
||||
|
||||
var DinnerNumberOfPeople = departmentGroup.Count(x => x.ShiftType == shiftCodeDict["Dinner"]);
|
||||
var DinnerNumberOfPeople = departmentGroup.Count(x => x.ShiftType == ShiftEnumType.Dinner);
|
||||
|
||||
var LateNightNumberOfPeople = departmentGroup.Count(x => x.ShiftType == shiftCodeDict["LateNight"]);
|
||||
var LateNightNumberOfPeople = departmentGroup.Count(x => x.ShiftType == ShiftEnumType.Nightsnack);
|
||||
//每个餐次人数
|
||||
obj.BreakfastNumberOfPeople = departmentGroup.Where(x => x.ShiftType == shiftCodeDict["Breakfast"]).Select(x => x.UserNo).Distinct().Count();
|
||||
obj.LunchNumberOfPeople = departmentGroup.Where(x => x.ShiftType == shiftCodeDict["Lunch"]).Select(x => x.UserNo).Distinct().Count();
|
||||
obj.DinnerNumberOfPeople = departmentGroup.Where(x => x.ShiftType == shiftCodeDict["Dinner"]).Select(x => x.UserNo).Distinct().Count();
|
||||
obj.LateNightNumberOfPeople = departmentGroup.Where(x => x.ShiftType == shiftCodeDict["LateNight"]).Select(x => x.UserNo).Distinct().Count();
|
||||
obj.BreakfastNumberOfPeople = departmentGroup.Where(x => x.ShiftType == ShiftEnumType.Breakfast).Select(x => x.UserNo).Distinct().Count();
|
||||
obj.LunchNumberOfPeople = departmentGroup.Where(x => x.ShiftType == ShiftEnumType.Lunch).Select(x => x.UserNo).Distinct().Count();
|
||||
obj.DinnerNumberOfPeople = departmentGroup.Where(x => x.ShiftType == ShiftEnumType.Dinner).Select(x => x.UserNo).Distinct().Count();
|
||||
obj.LateNightNumberOfPeople = departmentGroup.Where(x => x.ShiftType == ShiftEnumType.Nightsnack).Select(x => x.UserNo).Distinct().Count();
|
||||
|
||||
//餐次金额
|
||||
obj.BreakfastAmount = Math.Abs(departmentGroup.Where(x => x.ShiftType == shiftCodeDict["Breakfast"]).Sum(x => x.Amount));
|
||||
obj.LunchAmount = Math.Abs(departmentGroup.Where(x => x.ShiftType == shiftCodeDict["Lunch"]).Sum(x => x.Amount));
|
||||
obj.DinnerAmount = Math.Abs(departmentGroup.Where(x => x.ShiftType == shiftCodeDict["Dinner"]).Sum(x => x.Amount));
|
||||
obj.LateNightAmount = Math.Abs(departmentGroup.Where(x => x.ShiftType == shiftCodeDict["LateNight"]).Sum(x => x.Amount));
|
||||
obj.BreakfastAmount = Math.Abs(departmentGroup.Where(x => x.ShiftType == ShiftEnumType.Breakfast).Sum(x => x.Amount));
|
||||
obj.LunchAmount = Math.Abs(departmentGroup.Where(x => x.ShiftType == ShiftEnumType.Lunch).Sum(x => x.Amount));
|
||||
obj.DinnerAmount = Math.Abs(departmentGroup.Where(x => x.ShiftType == ShiftEnumType.Dinner).Sum(x => x.Amount));
|
||||
obj.LateNightAmount = Math.Abs(departmentGroup.Where(x => x.ShiftType == ShiftEnumType.Nightsnack).Sum(x => x.Amount));
|
||||
|
||||
// 每个餐次单价
|
||||
obj.BreakfastPrice = BreakfastNumberOfPeople == 0 ? 0 : Math.Round(obj.BreakfastAmount / BreakfastNumberOfPeople, 2);
|
||||
@@ -326,8 +320,6 @@ public class BalanceService : IBalanceService
|
||||
/// <returns></returns>
|
||||
public async Task<Pagination<BalanceRecordSummaryRespones>> BalanceRecordSummaryByTidAsync(BalanceRecordSummaryRequest request)
|
||||
{
|
||||
var shiftCodeDict = await GetShiftCode();
|
||||
|
||||
var paeginfos = await _dbContext.Queryable<BalanceRecordEntity>()
|
||||
.WhereIF(!request.DepartmentNo.IsEmpty(), record => record.DepartmentNo == request.DepartmentNo)
|
||||
.WhereIF(!request.UserCode.IsEmpty(), record => record.UserCode == request.UserCode)
|
||||
@@ -352,24 +344,21 @@ public class BalanceService : IBalanceService
|
||||
};
|
||||
|
||||
// 所有人次
|
||||
var BreakfastNumberOfPeople = originTenantIdGroup.Count(x => x.ShiftType == shiftCodeDict["Breakfast"]);
|
||||
|
||||
var LunchNumberOfPeople = originTenantIdGroup.Count(x => x.ShiftType == shiftCodeDict["Lunch"]);
|
||||
|
||||
var DinnerNumberOfPeople = originTenantIdGroup.Count(x => x.ShiftType == shiftCodeDict["Dinner"]);
|
||||
|
||||
var LateNightNumberOfPeople = originTenantIdGroup.Count(x => x.ShiftType == shiftCodeDict["LateNight"]);
|
||||
var BreakfastNumberOfPeople = originTenantIdGroup.Count(x => x.ShiftType == ShiftEnumType.Breakfast);
|
||||
var LunchNumberOfPeople = originTenantIdGroup.Count(x => x.ShiftType == ShiftEnumType.Lunch);
|
||||
var DinnerNumberOfPeople = originTenantIdGroup.Count(x => x.ShiftType == ShiftEnumType.Dinner);
|
||||
var LateNightNumberOfPeople = originTenantIdGroup.Count(x => x.ShiftType == ShiftEnumType.Nightsnack);
|
||||
//每个餐次人数
|
||||
obj.BreakfastNumberOfPeople = originTenantIdGroup.Where(x => x.ShiftType == shiftCodeDict["Breakfast"]).Select(x => x.UserNo).Distinct().Count();
|
||||
obj.LunchNumberOfPeople = originTenantIdGroup.Where(x => x.ShiftType == shiftCodeDict["Lunch"]).Select(x => x.UserNo).Distinct().Count();
|
||||
obj.DinnerNumberOfPeople = originTenantIdGroup.Where(x => x.ShiftType == shiftCodeDict["Dinner"]).Select(x => x.UserNo).Distinct().Count();
|
||||
obj.LateNightNumberOfPeople = originTenantIdGroup.Where(x => x.ShiftType == shiftCodeDict["LateNight"]).Select(x => x.UserNo).Distinct().Count();
|
||||
obj.BreakfastNumberOfPeople = originTenantIdGroup.Where(x => x.ShiftType == ShiftEnumType.Breakfast).Select(x => x.UserNo).Distinct().Count();
|
||||
obj.LunchNumberOfPeople = originTenantIdGroup.Where(x => x.ShiftType == ShiftEnumType.Lunch).Select(x => x.UserNo).Distinct().Count();
|
||||
obj.DinnerNumberOfPeople = originTenantIdGroup.Where(x => x.ShiftType == ShiftEnumType.Dinner).Select(x => x.UserNo).Distinct().Count();
|
||||
obj.LateNightNumberOfPeople = originTenantIdGroup.Where(x => x.ShiftType == ShiftEnumType.Nightsnack).Select(x => x.UserNo).Distinct().Count();
|
||||
|
||||
//餐次金额
|
||||
obj.BreakfastAmount = Math.Abs(originTenantIdGroup.Where(x => x.ShiftType == shiftCodeDict["Breakfast"]).Sum(x => x.Amount));
|
||||
obj.LunchAmount = Math.Abs(originTenantIdGroup.Where(x => x.ShiftType == shiftCodeDict["Lunch"]).Sum(x => x.Amount));
|
||||
obj.DinnerAmount = Math.Abs(originTenantIdGroup.Where(x => x.ShiftType == shiftCodeDict["Dinner"]).Sum(x => x.Amount));
|
||||
obj.LateNightAmount = Math.Abs(originTenantIdGroup.Where(x => x.ShiftType == shiftCodeDict["LateNight"]).Sum(x => x.Amount));
|
||||
obj.BreakfastAmount = Math.Abs(originTenantIdGroup.Where(x => x.ShiftType == ShiftEnumType.Breakfast).Sum(x => x.Amount));
|
||||
obj.LunchAmount = Math.Abs(originTenantIdGroup.Where(x => x.ShiftType == ShiftEnumType.Lunch).Sum(x => x.Amount));
|
||||
obj.DinnerAmount = Math.Abs(originTenantIdGroup.Where(x => x.ShiftType == ShiftEnumType.Dinner).Sum(x => x.Amount));
|
||||
obj.LateNightAmount = Math.Abs(originTenantIdGroup.Where(x => x.ShiftType == ShiftEnumType.Nightsnack).Sum(x => x.Amount));
|
||||
|
||||
|
||||
// 每个餐次单价
|
||||
@@ -405,9 +394,6 @@ public class BalanceService : IBalanceService
|
||||
/// <returns></returns>
|
||||
public async Task<Pagination<BalanceRecordAnalysisRespones>> BalanceRecordAnalysisAsync(BalanceRecordAnalysisRequest request)
|
||||
{
|
||||
var shiftCodeDict = await GetShiftCode();
|
||||
|
||||
|
||||
var pageinfo = await _dbContext.Queryable<BalanceRecordEntity>()
|
||||
.WhereIF(request.StartDatetime.HasValue, record => record.CostDateTime >= request.StartDatetime)
|
||||
.WhereIF(request.EndDatetime.HasValue, record => record.CostDateTime <= request.EndDatetime)
|
||||
@@ -424,13 +410,13 @@ public class BalanceService : IBalanceService
|
||||
};
|
||||
|
||||
//每个餐次人数
|
||||
obj.BreakfastNumberOfPeople = first.Where(x => x.ShiftType == shiftCodeDict["Breakfast"]).Select(x => x.UserNo).Distinct().Count();
|
||||
obj.LunchNumberOfPeople = first.Where(x => x.ShiftType == shiftCodeDict["Lunch"]).Select(x => x.UserNo).Distinct().Count();
|
||||
obj.DinnerNumberOfPeople = first.Where(x => x.ShiftType == shiftCodeDict["Dinner"]).Select(x => x.UserNo).Distinct().Count();
|
||||
obj.LateNightNumberOfPeople = first.Where(x => x.ShiftType == shiftCodeDict["LateNight"]).Select(x => x.UserNo).Distinct().Count();
|
||||
obj.BreakfastNumberOfPeople = first.Where(x => x.ShiftType == ShiftEnumType.Breakfast).Select(x => x.UserNo).Distinct().Count();
|
||||
obj.LunchNumberOfPeople = first.Where(x => x.ShiftType == ShiftEnumType.Lunch).Select(x => x.UserNo).Distinct().Count();
|
||||
obj.DinnerNumberOfPeople = first.Where(x => x.ShiftType == ShiftEnumType.Lunch).Select(x => x.UserNo).Distinct().Count();
|
||||
obj.LateNightNumberOfPeople = first.Where(x => x.ShiftType == ShiftEnumType.Nightsnack).Select(x => x.UserNo).Distinct().Count();
|
||||
|
||||
obj.TotalNumberOfPeople = first.Where(x => x.CostDate.ToString("yyyy-MM-dd") == first.Key).Select(x => x.UserNo).Distinct().Count();
|
||||
|
||||
|
||||
lst.Add(obj);
|
||||
}
|
||||
// 分页操作
|
||||
@@ -483,7 +469,7 @@ public class BalanceService : IBalanceService
|
||||
.LeftJoin<BasicTypeEntity>((record, ga, department, bplace, bshift, type) => record.BusinessShiftCode.ToString() == type.Code)
|
||||
.WhereIF(request.SearchDate.HasValue, record => record.CostDate >= start)
|
||||
.WhereIF(request.SearchDate.HasValue, record => record.CostDate <= end)
|
||||
.Where(record => record.TenantId == device.TenantId && (record.DeviceInfo == device.Code.ToString() || record.DeviceInfo == device.UniqueNo))
|
||||
.Where(record => record.TenantId == device.TenantId && (record.DeviceUniqueNo == device.Code.ToString() || record.DeviceUniqueNo == device.UniqueNo))
|
||||
.Where(record => record.Type == BalanceRecordTypeEnumType.Out && record.Status == BalanceRecordStatusEnumType.Valid)
|
||||
.OrderBy(record => record.CreateTime, OrderByType.Desc)
|
||||
.Select((record, ga, department, bplace, bshift, type) => new BalanceRecordResponse
|
||||
@@ -495,7 +481,7 @@ public class BalanceService : IBalanceService
|
||||
CostDate = record.CostDate,
|
||||
CostId = record.CostId,
|
||||
DepartmentNo = record.DepartmentNo,
|
||||
DeviceInfo = record.DeviceInfo,
|
||||
DeviceInfo = record.DeviceUniqueNo,
|
||||
IP = record.IP,
|
||||
UserNo = record.UserNo,
|
||||
UserCode = record.UserCode,
|
||||
@@ -517,7 +503,7 @@ public class BalanceService : IBalanceService
|
||||
var sum = await _dbContext.Queryable<BalanceRecordEntity>()
|
||||
.WhereIF(request.SearchDate.HasValue, record => record.CostDate >= start)
|
||||
.WhereIF(request.SearchDate.HasValue, record => record.CostDate <= end)
|
||||
.Where(record => record.TenantId == device.TenantId || (record.DeviceInfo == device.Code.ToString() || record.DeviceInfo == device.UniqueNo))
|
||||
.Where(record => record.TenantId == device.TenantId || record.DeviceUniqueNo == device.Code.ToString() || record.DeviceUniqueNo == device.UniqueNo)
|
||||
.Where(record => record.Type == BalanceRecordTypeEnumType.Out && record.Status == BalanceRecordStatusEnumType.Valid)
|
||||
.SumAsync(record => SqlFunc.Abs(SqlFunc.IsNull(record.Amount, 0)));
|
||||
|
||||
@@ -610,7 +596,7 @@ public class BalanceService : IBalanceService
|
||||
//可消费人数
|
||||
var consumerable = bs.Select(x => x.UserCode).Distinct().Count();
|
||||
|
||||
var dailyNumber = SameDay(bs,"");
|
||||
var dailyNumber = SameDay(bs, "");
|
||||
|
||||
|
||||
//消费走势
|
||||
@@ -636,14 +622,14 @@ public class BalanceService : IBalanceService
|
||||
/// <param name="bs"></param>
|
||||
/// <param name="userCode"></param>
|
||||
/// <returns></returns>
|
||||
private int SameDay(List<BalanceRecordEntity> bs,string userCode)
|
||||
private int SameDay(List<BalanceRecordEntity> bs, string userCode)
|
||||
{
|
||||
var time = DateTime.Now.ToString("yyyy-MM-dd");
|
||||
var b = userCode.IsEmpty();
|
||||
//当日消费数据
|
||||
var monthbs = bs
|
||||
.Where(x => x.CostDateTime.ToString("yyyy-MM-dd") == time)
|
||||
.WhereIF(!userCode.IsEmpty(),x => x.UserCode == userCode);
|
||||
.WhereIF(!userCode.IsEmpty(), x => x.UserCode == userCode);
|
||||
//当日消费额
|
||||
var monthlySpending = monthbs.Sum(x => x.Amount);
|
||||
//当日消费人数
|
||||
@@ -694,9 +680,9 @@ public class BalanceService : IBalanceService
|
||||
var lst = new List<AverageDailyResponse>();
|
||||
foreach (var code in codes)
|
||||
{
|
||||
var br = brs.Where(x => x.UserCode == code).FirstOrDefault();
|
||||
var br = brs.Where(x => x.UserCode == code).FirstOrDefault();
|
||||
var res = br.Adapt<AverageDailyResponse>();
|
||||
var dailyNumber = SameDay(brs,code);
|
||||
var dailyNumber = SameDay(brs, code);
|
||||
res.AverageAmount = dailyNumber;
|
||||
lst.Add(res);
|
||||
}
|
||||
@@ -773,7 +759,7 @@ public class BalanceService : IBalanceService
|
||||
.Where(x => deviceUniqueNos.Contains(x.DeviceUniqueNo))
|
||||
.Select((x, d) => new
|
||||
{
|
||||
UniqueNo = d.UniqueNo,
|
||||
d.UniqueNo,
|
||||
d.HeartbeatInterval,
|
||||
x.LastHeartbeatTime
|
||||
})
|
||||
@@ -792,7 +778,7 @@ public class BalanceService : IBalanceService
|
||||
})
|
||||
.Select(x => new
|
||||
{
|
||||
UniqueNo = x.UniqueNo,
|
||||
x.UniqueNo,
|
||||
})
|
||||
.ToList();
|
||||
var onlineUniqueNos = new List<string>();
|
||||
@@ -940,41 +926,4 @@ public class BalanceService : IBalanceService
|
||||
|
||||
throw new UserFriendlyException("操作失败,请重试");
|
||||
}
|
||||
|
||||
public async Task<Dictionary<string, string>> GetShiftCode()
|
||||
{
|
||||
_dbContext.Client.QueryFilter.ClearAndBackup<ITenantId>();
|
||||
try
|
||||
{
|
||||
var shiftCodeDict = new Dictionary<string, string>();
|
||||
|
||||
var typs = await _dbContext.Queryable<BasicTypeEntity>()
|
||||
.Where(x => x.Type == "mealshift")
|
||||
.ToListAsync();
|
||||
|
||||
var codeBreakfast = typs.Where(x => x.Display == "早餐").Select(x => x.Code).First();
|
||||
var codeLunch = typs.Where(x => x.Display == "午餐").Select(x => x.Code).First();
|
||||
var codeDinner = typs.Where(x => x.Display == "晚餐").Select(x => x.Code).First();
|
||||
var codeNightsnack = typs.Where(x => x.Display == "宵夜").Select(x => x.Code).First();
|
||||
var codeMidnightsnack = typs.Where(x => x.Display == "凌晨餐").Select(x => x.Code).First();
|
||||
|
||||
shiftCodeDict.Add("Breakfast", codeBreakfast);
|
||||
shiftCodeDict.Add("Lunch", codeLunch);
|
||||
shiftCodeDict.Add("Dinner", codeDinner);
|
||||
shiftCodeDict.Add("LateNight", codeNightsnack);
|
||||
shiftCodeDict.Add("Midnightsnack", codeMidnightsnack);
|
||||
|
||||
return shiftCodeDict;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, $"生成{DeviceTaskEnumType.UploadRecord.GetDescription()}任务失败:" + ex.Message);
|
||||
return null;
|
||||
}
|
||||
finally
|
||||
{
|
||||
_dbContext.Client.QueryFilter.Restore();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,118 +0,0 @@
|
||||
using Dlhis.Canteen.Order.Request;
|
||||
using Dlhis.Canteen.Order.Response;
|
||||
using Dlhis.Entity.Basic.Entity;
|
||||
using Dlhis.Entity.Canteen.Entities;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
using Kurisu.Core.User.Abstractions;
|
||||
using Kurisu.SqlSugar.Extensions;
|
||||
using Kurisu.SqlSugar.Services;
|
||||
using Mapster;
|
||||
|
||||
namespace Dlhis.Canteen.Order.Services.Implements
|
||||
{
|
||||
public class MenuDishesService : IMenuDishesService
|
||||
{
|
||||
private readonly IDbContext _dbContext;
|
||||
private readonly ICurrentUser _currentUser;
|
||||
|
||||
public MenuDishesService(IDbContext dbContext, ICurrentUser currentUser)
|
||||
{
|
||||
_dbContext = dbContext;
|
||||
_currentUser = currentUser;
|
||||
}
|
||||
|
||||
public async Task<Pagination<GetMenuResponse>> GetMenuAsync(GetMenuRequest request)
|
||||
{
|
||||
var page = await _dbContext.Queryable<CanteenMenuEntity>()
|
||||
.LeftJoin<BusinessPlaceEntity>((x,place) => x.PlaceCode == place.Code)
|
||||
.WhereIF(!request.Factory.IsEmpty(),x => x.Factory == request.Factory)
|
||||
.WhereIF(request.PlaceCode.HasValue, x => request.PlaceCode == x.PlaceCode)
|
||||
.WhereIF(!request.Search.IsEmpty(),x => x.Name.Contains(request.Search))
|
||||
.Select((x,place) => new GetMenuResponse
|
||||
{
|
||||
ShiftTypesSrt = x.ShiftTypes.ToString(),
|
||||
//ShiftTypesSrt = string.Join(", ", x.ShiftTypes.Select(enumValue => enumValue.GetDescription())),
|
||||
PlaceName = place.Name,
|
||||
},true)
|
||||
.ToPageListAsync(request);
|
||||
return page;
|
||||
}
|
||||
|
||||
public async Task SaveMenuAsync(SaveMenuRequest request)
|
||||
{
|
||||
var place = await _dbContext.Queryable<BusinessPlaceEntity>()
|
||||
.FirstAsync(x => x.Code == request.PlaceCode);
|
||||
place.ThrowIfNull($"{request.PlaceCode}:该营业点不存在!");
|
||||
|
||||
if (!request.Id.HasValue)
|
||||
{
|
||||
var entity = request.Adapt<CanteenMenuEntity>();
|
||||
entity.Code = Guid.NewGuid();
|
||||
await _dbContext.InsertAsync(entity);
|
||||
}
|
||||
else
|
||||
{
|
||||
var entity = await _dbContext.Queryable<CanteenMenuEntity>()
|
||||
.Where(x => x.Id == request.Id).FirstAsync();
|
||||
request.Adapt(entity);
|
||||
await _dbContext.UpdateAsync(entity);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<Pagination<GetDishesResponse>> GetDishesAsync(GetDishesRequest request)
|
||||
{
|
||||
if (!request.MenuCode.HasValue)
|
||||
{
|
||||
return await _dbContext.Queryable<CanteenDishesEntity>()
|
||||
.Select<GetDishesResponse>()
|
||||
.ToPageListAsync(request);
|
||||
}
|
||||
else
|
||||
{
|
||||
var disCodes = await _dbContext.Queryable<CanteenMenuDishersRelationshipEntity>()
|
||||
.Where(x => x.MenuCode == request.MenuCode)
|
||||
.Select(x => x.DishersCode)
|
||||
.ToListAsync();
|
||||
return await _dbContext.Queryable<CanteenDishesEntity>()
|
||||
.Where(x => disCodes.Contains(x.Code))
|
||||
.Select<GetDishesResponse>()
|
||||
.ToPageListAsync(request);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task SaveDishesAsync(SaveDishesRequest request)
|
||||
{
|
||||
if (!request.Id.HasValue)
|
||||
{
|
||||
var dishers = request.Adapt<CanteenDishesEntity>();
|
||||
dishers.Code = Guid.NewGuid();
|
||||
await _dbContext.InsertAsync(dishers);
|
||||
}
|
||||
else
|
||||
{
|
||||
var entity = await _dbContext.Queryable<CanteenDishesEntity>()
|
||||
.Where(x => x.Id == request.Id).FirstAsync();
|
||||
request.Adapt(entity);
|
||||
await _dbContext.UpdateAsync(entity);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task DispositionDishesAsync(DispositionDishesRequest request)
|
||||
{
|
||||
var lst = new List<CanteenMenuDishersRelationshipEntity>();
|
||||
|
||||
foreach (var dto in request.DishersDtos)
|
||||
{
|
||||
var entity = new CanteenMenuDishersRelationshipEntity
|
||||
{
|
||||
MenuCode = request.MenudCode,
|
||||
DishersCode = dto.DisherCode,
|
||||
RestrictedNum = dto.RestrictedNum,
|
||||
};
|
||||
lst.Add(entity);
|
||||
}
|
||||
await _dbContext.InsertAsync(lst);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,176 +0,0 @@
|
||||
using Dlhis.Canteen.Order.Request;
|
||||
using Dlhis.Canteen.Order.Response;
|
||||
using Dlhis.Entity.Basic.Entity;
|
||||
using Dlhis.Entity.Canteen.Entities;
|
||||
using Dlhis.Entity.Canteen.Enums;
|
||||
using Dlhis.Sys.Api;
|
||||
using Kurisu.AspNetCore.Utils;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
using Kurisu.SqlSugar.Extensions;
|
||||
using Kurisu.SqlSugar.Services;
|
||||
using Mapster;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Dlhis.Canteen.Order.Services.Implements;
|
||||
|
||||
public class MiniProgramOrderDetailService : IMiniProgramOrderDetailService
|
||||
{
|
||||
private readonly IDbContext _dbContext;
|
||||
private readonly ITenantApi _tenantApi;
|
||||
public MiniProgramOrderDetailService(IDbContext dbContext, ITenantApi tenantApi)
|
||||
{
|
||||
_dbContext = dbContext;
|
||||
_tenantApi = tenantApi;
|
||||
}
|
||||
|
||||
public async Task<Pagination<GetMiniProgramOrderResponse>> GetMiniProgramOrderAsync(GetMiniProgramOrderRequest request)
|
||||
{
|
||||
var page = await _dbContext.Queryable<MiniProgramOrderEntity>()
|
||||
.LeftJoin<BusinessPlaceEntity>((order,place) => order.PlaceCode == place.Code)
|
||||
.LeftJoin<CanteenDishesEntity>((order, place,dishers) => order.DishesCode == dishers.Code)
|
||||
.LeftJoin<DepartmentEntity>((order, place, dishers,depart) => order.DepartmentNo == depart.No)
|
||||
.WhereIF(!request.Search.IsEmpty(), order => order.Name == request.Search || order.Code == request.Search)
|
||||
.WhereIF(request.SysDate.HasValue,order=>order.SysDate == request.SysDate)
|
||||
.OrderBy(order => order.CostDate,SqlSugar.OrderByType.Desc)
|
||||
.Select((order, place, dishers, depart) => new GetMiniProgramOrderResponse
|
||||
{
|
||||
PlaceName = place.Name,
|
||||
DepartmentName = depart.Name,
|
||||
DishesName = dishers.Name,
|
||||
},true)
|
||||
.ToPageListAsync(request);
|
||||
return page;
|
||||
}
|
||||
|
||||
public async Task SaveDetailAsync(SaveDetailRequest request)
|
||||
{
|
||||
if (!request.Id.HasValue)
|
||||
{
|
||||
var entity = request.Adapt<OrderDetailsEntity>();
|
||||
await _dbContext.InsertAsync(entity);
|
||||
}
|
||||
else
|
||||
{
|
||||
var entity = await _dbContext.Queryable<OrderDetailsEntity>()
|
||||
.Where(x => x.Id == request.Id)
|
||||
.FirstAsync();
|
||||
request.Adapt(entity);
|
||||
await _dbContext.UpdateAsync(entity);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<Pagination<GetDetailResponse>> GetDetailAsync(GetDetailRequest request)
|
||||
{
|
||||
var page = await _dbContext.Queryable<OrderDetailsEntity>()
|
||||
.WhereIF(!request.Search.IsEmpty(),x => x.ThirdNo == request.Search)
|
||||
.Select<GetDetailResponse>()
|
||||
.ToPageListAsync(request);
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
public async Task OrderAsync(OrderRequest request)
|
||||
{
|
||||
//判断时间
|
||||
DateTime currentTime = DateTime.Now;
|
||||
TimeSpan ninePM = new TimeSpan(20, 30, 0);
|
||||
if (currentTime.TimeOfDay > ninePM)
|
||||
{
|
||||
true.ThrowIfTrue("20:30之后无法订餐!");
|
||||
}
|
||||
//判断营业日
|
||||
var dishes = await _dbContext.Queryable<CanteenDishesEntity>().Where(x => x.Code == request.DishesCode).FirstAsync();
|
||||
dishes.Enable.ThrowIfFalse($"{dishes.Name}没启用!");
|
||||
|
||||
var menu = await _dbContext.Queryable<CanteenMenuEntity>().Where(x => x.Code == request.MenuCode).FirstAsync();
|
||||
menu.Enable.ThrowIfFalse($"{dishes.Name}没启用!");
|
||||
|
||||
// 获取用餐日期
|
||||
DateOnly tomorrow = DateOnly.FromDateTime(DateTime.Today.AddDays(1));
|
||||
if (tomorrow != menu.StartDate)
|
||||
{
|
||||
true.ThrowIfTrue($"菜品:{dishes.Name}对应的菜单:{menu.Name}不在营业日!");
|
||||
}
|
||||
|
||||
var restricted= await _dbContext.Queryable< CanteenMenuDishersRelationshipEntity>()
|
||||
.Where(x => x.MenuCode == request.MenuCode && x.DishersCode == request.DishesCode).FirstAsync();
|
||||
restricted.ThrowIfNull($"每日菜单:{menu.Name} 还没有配置菜品:{dishes.Name} 的限售数量!");
|
||||
if (restricted.RestrictedNum < 0)
|
||||
{
|
||||
true.ThrowIfTrue($"菜品:{dishes.Name}已售罄!");
|
||||
}
|
||||
|
||||
var gainfo = await _dbContext.Queryable<GainfoEntity>()
|
||||
.Where(x => x.Code == request.UserCode)
|
||||
.FirstAsync();
|
||||
gainfo.ThrowIfNull($"用户{request.UserCode}无档案信息,无法订餐!");
|
||||
|
||||
//判断是否订过餐
|
||||
var flag = await _dbContext.Queryable<MiniProgramOrderEntity>()
|
||||
.Where(x => x.SysDate == tomorrow && x.ShiftType == request.ShiftType && x.Code == request.UserCode && x.OrderStatus == MiniProgramOrderStatusEnumType.I)
|
||||
.AnyAsync();
|
||||
flag.ThrowIfTrue($"工号:{request.UserCode} 姓名:{gainfo.Name} 已经定过{tomorrow}的{request.ShiftType.GetDescription()}!");
|
||||
|
||||
//支付方式
|
||||
/* var result = await _tenantApi.GetTenantTreeAsync();
|
||||
var tree = result.Data;
|
||||
var shanxi = tree.Where(x => x.Name == "山西基地").FirstOrDefault();
|
||||
var codes = shanxi.Next.Select(x => x.Code).ToList();
|
||||
if (!codes.Contains(gainfo.Factory))
|
||||
{
|
||||
if (request.PayType == CanteenPayEnumType.Repair)
|
||||
{
|
||||
true.ThrowIfTrue($"非山西,支付方式不能为{request.PayType.GetDescription()}");
|
||||
}
|
||||
}*/
|
||||
|
||||
//生成订单
|
||||
var order = new MiniProgramOrderEntity
|
||||
{
|
||||
No = "O" + SnowFlakeHelper.Instance.NextId(),
|
||||
Name = gainfo.Name,
|
||||
Code = gainfo.Code,
|
||||
Werks = gainfo.Werks,
|
||||
DepartmentNo = gainfo.DepartmentNo,
|
||||
CostId = gainfo.CostId,
|
||||
Workplace = gainfo.Workplace,
|
||||
Factory = gainfo.Factory,
|
||||
PlaceCode = request.PlaceCode,
|
||||
ShiftType = request.ShiftType,
|
||||
DishesCode = request.DishesCode,
|
||||
Phone = gainfo.Phone,
|
||||
SysDate = tomorrow,
|
||||
CostDate = DateTime.Now,
|
||||
PayType = request.PayType,
|
||||
OrderStatus = MiniProgramOrderStatusEnumType.I,
|
||||
OrderType = dishes.Type,
|
||||
};
|
||||
//生成订单明细
|
||||
var detail = new OrderDetailsEntity
|
||||
{
|
||||
ThirdNo = order.No,
|
||||
SysDate = tomorrow,
|
||||
ShiftType= request.ShiftType,
|
||||
DishesCode= request.DishesCode,
|
||||
DishesName = dishes.Name,
|
||||
Price = dishes.Amount,
|
||||
Unit = dishes.Unit,
|
||||
Num = request.DishesNum,
|
||||
Amount = request.DishesNum * dishes.Amount,
|
||||
OrderStatus = OrderDetailsStatusEnumType.I,
|
||||
};
|
||||
order.TotalAmount = detail.Amount;
|
||||
await _dbContext.InsertAsync(order);
|
||||
await _dbContext.InsertAsync(detail);
|
||||
//扣减份数
|
||||
var effect = await _dbContext.Updateable<CanteenMenuDishersRelationshipEntity>()
|
||||
.SetColumns(x => x.RestrictedNum == restricted.RestrictedNum - request.DishesNum)
|
||||
.SetColumns(x => x.Version == x.Version + 1)
|
||||
.Where(x => x.MenuCode == request.MenuCode && x.DishersCode == request.DishesCode && x.Version == restricted.Version)
|
||||
.ExecuteCommandAsync();
|
||||
|
||||
if (effect <= 0) throw new VersionExceptions("更新版本冲突");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
using Dlhis.Basic.Api;
|
||||
using Dlhis.Canteen.Order.Request;
|
||||
using Dlhis.Canteen.Order.Response;
|
||||
using Dlhis.Canteen.Dishes.Request;
|
||||
using Dlhis.Canteen.Setting.Services;
|
||||
using Dlhis.Entity.Basic.Entity;
|
||||
using Dlhis.Entity.Canteen.Entities;
|
||||
@@ -11,10 +10,14 @@ using Kurisu.AspNetCore.Utils;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
using Kurisu.Core.CustomClass;
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
using Kurisu.Core.User.Abstractions;
|
||||
using Kurisu.SqlSugar.Extensions;
|
||||
using Kurisu.SqlSugar.Services;
|
||||
using Mapster;
|
||||
using SqlSugar;
|
||||
using Dlhis.Canteen.Order.Response;
|
||||
using Dlhis.Canteen.Dishes;
|
||||
using Dlhis.Canteen.Order.Request;
|
||||
|
||||
namespace Dlhis.Canteen.Order.Services.Implements;
|
||||
|
||||
@@ -23,16 +26,22 @@ public class OrderService : IOrderService
|
||||
private readonly IDbContext _dbContext;
|
||||
private readonly ICanteenSettingService _canteenSettingService;
|
||||
private readonly IDevicePermissionApi _devicePermissionApi;
|
||||
private readonly ICurrentUser _currentUser;
|
||||
private readonly IDisheMenuApi _disheMenuApi;
|
||||
private readonly ILogger<OrderService> _logger;
|
||||
|
||||
public OrderService(IDbContext dbContext,
|
||||
ICanteenSettingService canteenSettingService,
|
||||
IDevicePermissionApi devicePermissionApi,
|
||||
ICurrentUser currentUser,
|
||||
IDisheMenuApi disheMenuApi,
|
||||
ILogger<OrderService> logger)
|
||||
{
|
||||
_dbContext = dbContext;
|
||||
_canteenSettingService = canteenSettingService;
|
||||
_devicePermissionApi = devicePermissionApi;
|
||||
_currentUser = currentUser;
|
||||
_disheMenuApi = disheMenuApi;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
@@ -53,6 +62,118 @@ public class OrderService : IOrderService
|
||||
uniqueNos.Contains(deviceUniqueNo).ThrowIfFalse("无消费权限");
|
||||
}
|
||||
|
||||
public async Task Booking(BookingMealRequest request)
|
||||
{
|
||||
await CheckExistsMyBookingsAsync(request.BookingDate);
|
||||
|
||||
var jinkoCode = _currentUser.GetUserClaim("jinko-code");
|
||||
var gainfo = await _dbContext.Queryable<GainfoEntity>().Where(x => x.Code == jinkoCode).FirstAsync();
|
||||
|
||||
var businessPlace = await _dbContext.Queryable<BusinessPlaceEntity>().Where(x => x.Code == request.BusinessPlaceCode).FirstAsync();
|
||||
|
||||
//预定时间
|
||||
var now = DateTime.Now;
|
||||
|
||||
var settings = await _canteenSettingService.GetUserSettingAsync(gainfo.Code);
|
||||
var bookingDeadline = GetSetting<TimeOnly?>(settings, CanteenSettingItemEnumType.BookingDeadline) ?? new TimeOnly(20, 30, 00);
|
||||
var dealLine = DateTime.Today.Add(bookingDeadline.ToTimeSpan());
|
||||
(now >= dealLine).ThrowIfTrue("超出订餐时间");
|
||||
|
||||
//菜单存在
|
||||
var menuDetailResult = await _disheMenuApi.GetBookingDishesDetailAsync(request.BookingDate, request.BusinessPlaceCode, (int)request.ShiftType, request.DishesCode);
|
||||
var menuDetail = menuDetailResult.Data;
|
||||
menuDetail.ThrowIfNull("预定失败,菜品已经下架");
|
||||
|
||||
var order = new CanteenOrderEntity
|
||||
{
|
||||
RequestJson = request.ToJson(),
|
||||
ThirdNo = string.Empty,
|
||||
Type = BalanceRecordTypeEnumType.Out,
|
||||
ApplicationType = CanteenApplicaitonTypeEnumType.Booking,
|
||||
Name = gainfo.Name,
|
||||
Source = request.Source,
|
||||
UserNo = gainfo.No,
|
||||
UserCode = gainfo.Code,
|
||||
Amount = -Math.Abs(menuDetail.Price),
|
||||
BusinessPlaceCode = request.BusinessPlaceCode,
|
||||
BusinessShiftCode = null,
|
||||
ShiftType = request.ShiftType,
|
||||
CostDate = now.Date,
|
||||
CostId = gainfo.CostId,
|
||||
DepartmentNo = gainfo.DepartmentNo,
|
||||
DeviceUniqueNo = string.Empty,
|
||||
|
||||
No = SnowFlakeHelper.Instance.NextId().ToString(),
|
||||
SubsidiesFromMonth = now.ToString("yyyyMM"),
|
||||
IsOffline = false,
|
||||
IsCostCrossTenant = GetSetting<bool>(settings, CanteenSettingItemEnumType.AllowCrossTenant),
|
||||
|
||||
OriginTenantId = gainfo.Factory,//人员可能跨基地消费
|
||||
|
||||
Status = BalanceRecordStatusEnumType.Valid,
|
||||
OrderStatus = CanteenOrderStatusEnumType.Successful,
|
||||
|
||||
CostDateTime = now,
|
||||
|
||||
//标识当前消费的基地
|
||||
TenantId = businessPlace.TenantId,
|
||||
};
|
||||
|
||||
var orderId = await _dbContext.InsertReturnIdentityAsync(order);
|
||||
await ContinueUpdateAsync(async () =>
|
||||
{
|
||||
await _disheMenuApi.GetBookingDishesDetailAsync(request.BookingDate, request.BusinessPlaceCode, (int)request.ShiftType, request.DishesCode);
|
||||
var menuDetail = menuDetailResult.Data;
|
||||
menuDetail.ThrowIfNull("预定失败,菜品已经下架");
|
||||
menuDetail.Number -= 1;
|
||||
|
||||
(menuDetail.Number < 0).ThrowIfTrue($"{menuDetail.DishesName}已售罄");
|
||||
|
||||
var canteenUser = await _dbContext.Queryable<CanteenUserEntity>().Where(x => x.UserNo == order.UserNo).FirstAsync();
|
||||
//金额+-
|
||||
canteenUser.Balance += order.Amount;
|
||||
(canteenUser.Balance < 0).ThrowIfTrue("余额不足,无法消费");
|
||||
|
||||
var effect = await _dbContext.Updateable<CanteenUserEntity>()
|
||||
.SetColumns(x => x.Balance == canteenUser.Balance)
|
||||
.SetColumns(x => x.Version == x.Version + 1)
|
||||
.Where(x => x.UserNo == order.UserNo && x.Version == canteenUser.Version)//必须与查询时的version一致
|
||||
.ExecuteCommandAsync();
|
||||
|
||||
if (effect <= 0) throw new VersionExceptions("更新版本冲突");
|
||||
|
||||
effect = await _dbContext.Updateable<DishesMenuEntity>()
|
||||
.SetColumns(x => x.Number == menuDetail.Number)
|
||||
.SetColumns(x => x.Version == x.Version + 1)
|
||||
.SetColumns(x => x.ModifiedTime == now)
|
||||
.Where(x => x.Date == menuDetail.Date && x.ShiftType == request.ShiftType && x.BusinessPlaceCode == request.BusinessPlaceCode && x.Version == menuDetail.Version)
|
||||
.ExecuteCommandAsync();
|
||||
|
||||
if (effect <= 0) throw new VersionExceptions("更新版本冲突");
|
||||
|
||||
//写入记录
|
||||
var balanceRecord = order.Adapt<BalanceRecordEntity>();
|
||||
await _dbContext.InsertAsync(balanceRecord);
|
||||
|
||||
await _dbContext.InsertAsync(new OrderDetailEntity
|
||||
{
|
||||
OrderNo = order.No,
|
||||
DishesCode = request.DishesCode,
|
||||
Price = menuDetail.Price,
|
||||
Status = OrderDetailsStatusEnumType.I,
|
||||
//Unit
|
||||
Number = 1,
|
||||
});
|
||||
|
||||
}, 10);
|
||||
}
|
||||
|
||||
|
||||
public async Task<OrderResultResponse> DeviceConsume(OrderAddRequest request)
|
||||
{
|
||||
return await AddAsync(request);
|
||||
}
|
||||
|
||||
public async Task<OrderResultResponse> AddAsync(OrderAddRequest request)
|
||||
{
|
||||
//尝试匹配userId
|
||||
@@ -63,7 +184,7 @@ public class OrderService : IOrderService
|
||||
.Where(x => x.No == request.UserUniqueNo || x.Code == request.UserUniqueNo || x.Id == userId || x.CardNo == request.UserUniqueNo)
|
||||
.FirstAsync();
|
||||
|
||||
gainfo.ThrowIfNull($"用户{request.UserUniqueNo}不存在,无法操作");
|
||||
gainfo.ThrowIfNull($"无消费权限");
|
||||
//消费权限控制
|
||||
await CheckPAsync(gainfo.No, request.DeviceUniqueNo);
|
||||
|
||||
@@ -183,6 +304,7 @@ public class OrderService : IOrderService
|
||||
RequestJson = request.ToJson(),
|
||||
ThirdNo = request.ThirdNo,
|
||||
Type = BalanceRecordTypeEnumType.Out,
|
||||
ApplicationType = CanteenApplicaitonTypeEnumType.Device,
|
||||
Name = gainfo.Name,
|
||||
Source = request.Source,
|
||||
UserNo = gainfo.No,
|
||||
@@ -194,14 +316,14 @@ public class OrderService : IOrderService
|
||||
CostDate = costDate.Date,
|
||||
CostId = gainfo.CostId,
|
||||
DepartmentNo = gainfo.DepartmentNo,
|
||||
DeviceInfo = request.DeviceUniqueNo,
|
||||
DeviceUniqueNo = request.DeviceUniqueNo,
|
||||
|
||||
No = "O" + SnowFlakeHelper.Instance.NextId(),
|
||||
No = SnowFlakeHelper.Instance.NextId().ToString(),
|
||||
SubsidiesFromMonth = request.CostDateTime.ToString("yyyyMM"),
|
||||
IsOffline = request.IsOffline,
|
||||
IsCostCrossTenant = GetSetting<bool>(settings, CanteenSettingItemEnumType.AllowCrossTenant),
|
||||
|
||||
OriginTenantId = gainfo.Werks,//人员可能跨基地消费
|
||||
OriginTenantId = gainfo.Factory,//人员可能跨基地消费
|
||||
|
||||
//餐别异常处理
|
||||
Status = shift == null ? BalanceRecordStatusEnumType.Doubtful : BalanceRecordStatusEnumType.Valid,
|
||||
@@ -264,13 +386,13 @@ public class OrderService : IOrderService
|
||||
CostDate = DateTime.Now.Date,
|
||||
CostId = gainfo.CostId,
|
||||
DepartmentNo = gainfo.DepartmentNo,
|
||||
DeviceInfo = string.Empty,
|
||||
DeviceUniqueNo = string.Empty,
|
||||
|
||||
No = "O" + SnowFlakeHelper.Instance.NextId(),
|
||||
No = SnowFlakeHelper.Instance.NextId().ToString(),
|
||||
SubsidiesFromMonth = request.CostDateTime.ToString("yyyyMM"),
|
||||
IsCostCrossTenant = GetSetting<bool>(settings, CanteenSettingItemEnumType.AllowCrossTenant),
|
||||
|
||||
OriginTenantId = gainfo.Werks,//人员可能跨基地消费
|
||||
OriginTenantId = gainfo.Factory,//人员可能跨基地消费
|
||||
|
||||
Status = BalanceRecordStatusEnumType.Valid,
|
||||
|
||||
@@ -279,7 +401,7 @@ public class OrderService : IOrderService
|
||||
CostDateTime = request.CostDateTime,
|
||||
|
||||
//标识当前消费的基地
|
||||
TenantId = gainfo.Werks,
|
||||
TenantId = gainfo.Factory,
|
||||
};
|
||||
|
||||
var orderId = await _dbContext.InsertReturnIdentityAsync(order);
|
||||
@@ -305,8 +427,6 @@ public class OrderService : IOrderService
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//******************************************************* help methods ************************************************************/
|
||||
|
||||
|
||||
@@ -355,7 +475,6 @@ public class OrderService : IOrderService
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
if (int.TryParse(v, out var n))
|
||||
{
|
||||
return n.Adapt<T>();
|
||||
@@ -527,4 +646,24 @@ public class OrderService : IOrderService
|
||||
}, 5);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检查我的订餐是否存在,存在抛出异常
|
||||
/// </summary>
|
||||
/// <param name="bookingDate"></param>
|
||||
/// <returns></returns>
|
||||
private async Task CheckExistsMyBookingsAsync(DateTime bookingDate)
|
||||
{
|
||||
var jinkoCode = _currentUser.GetUserClaim("jinko-code");
|
||||
var gainfo = await _dbContext.Queryable<GainfoEntity>().Where(x => x.Code == jinkoCode).FirstAsync();
|
||||
|
||||
var start = bookingDate.Date;
|
||||
var end = start.AddDays(1).AddSeconds(-1);
|
||||
|
||||
var exists = await _dbContext.Queryable<CanteenOrderEntity>().Where(x => x.ApplicationType == CanteenApplicaitonTypeEnumType.Booking)
|
||||
.Where(x => x.UserNo == gainfo.No)
|
||||
.Where(x => x.CreateTime >= start && x.CreateTime <= end)
|
||||
.AnyAsync();
|
||||
|
||||
exists.ThrowIfTrue("不可重复订餐");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user