Merge branch 'development' of https://git.dlhis.com/liguoyang/jinko.yikatong into development
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 Dlhis.Canteen.Order.Services;
|
||||
using Kurisu.AspNetCore.DataAccess.SqlSugar.Aop;
|
||||
@@ -6,7 +7,7 @@ using Kurisu.Core.DataAccess.Dto;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Dlhis.Canteen.Order.Controllers;
|
||||
namespace Dlhis.Canteen.Dishes.Controllers;
|
||||
|
||||
/// <summary>
|
||||
/// 充值/消费
|
||||
|
||||
@@ -1,81 +0,0 @@
|
||||
using Dlhis.Canteen.Order.Request;
|
||||
using Dlhis.Canteen.Order.Response;
|
||||
using Dlhis.Canteen.Order.Services;
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Dlhis.Canteen.Order.Controllers;
|
||||
|
||||
/// <summary>
|
||||
/// 菜单菜品控制器
|
||||
/// </summary>
|
||||
[Authorize]
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class MenuDishesController : ControllerBase
|
||||
{
|
||||
private readonly IMenuDishesService _menuDishesService;
|
||||
|
||||
public MenuDishesController(IMenuDishesService menuDishesService)
|
||||
{
|
||||
_menuDishesService = menuDishesService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 菜单分页
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("pageMenu")]
|
||||
public async Task<Pagination<GetMenuResponse>> GetMenuAsync([FromQuery]GetMenuRequest request)
|
||||
{
|
||||
return await _menuDishesService.GetMenuAsync(request);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 菜单保存/更改
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("saveMenu")]
|
||||
public async Task SaveMenuAsync(SaveMenuRequest request)
|
||||
{
|
||||
await _menuDishesService.SaveMenuAsync(request);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 菜品分页
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("pageDishes")]
|
||||
public async Task<Pagination<GetDishesResponse>> GetDishesAsync([FromQuery] GetDishesRequest request)
|
||||
{
|
||||
return await _menuDishesService.GetDishesAsync(request);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 菜品保存/更改
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("saveDishes")]
|
||||
public async Task SaveDishesAsync(SaveDishesRequest request)
|
||||
{
|
||||
await _menuDishesService.SaveDishesAsync(request);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 配置每日菜单菜品及限售
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("disposition")]
|
||||
public async Task DispositionDishesAsync(DispositionDishesRequest request)
|
||||
{
|
||||
await _menuDishesService.DispositionDishesAsync(request);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
using Dlhis.Canteen.Order.Request;
|
||||
using Dlhis.Canteen.Order.Response;
|
||||
using Dlhis.Canteen.Order.Services;
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Dlhis.Canteen.Order.Controllers;
|
||||
|
||||
/// <summary>
|
||||
///订单/明细控制器
|
||||
/// </summary>
|
||||
[Authorize]
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class MiniProgramOrderDetailController : ControllerBase
|
||||
{
|
||||
private readonly IMiniProgramOrderDetailService _miniProgramOrderDetailService;
|
||||
|
||||
public MiniProgramOrderDetailController(IMiniProgramOrderDetailService miniProgramOrderDetailService)
|
||||
{
|
||||
_miniProgramOrderDetailService = miniProgramOrderDetailService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 订单分页
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("pageOrder")]
|
||||
public async Task<Pagination<GetMiniProgramOrderResponse>> GetMiniProgramOrderAsync([FromQuery]GetMiniProgramOrderRequest request)
|
||||
{
|
||||
return await _miniProgramOrderDetailService.GetMiniProgramOrderAsync(request);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 明细保存
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("saveDetail")]
|
||||
public async Task SaveDetailAsync(SaveDetailRequest request)
|
||||
{
|
||||
await _miniProgramOrderDetailService.SaveDetailAsync(request);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 明细分页
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("pageDetail")]
|
||||
public async Task<Pagination<GetDetailResponse>> GetDetailAsync([FromQuery] GetDetailRequest request)
|
||||
{
|
||||
return await _miniProgramOrderDetailService.GetDetailAsync(request);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 下单
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost("order")]
|
||||
public async Task OrderAsync(OrderRequest request)
|
||||
{
|
||||
await _miniProgramOrderDetailService.OrderAsync(request);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,13 @@
|
||||
using Dlhis.Canteen.Order.Request;
|
||||
using Dlhis.Canteen.Dishes.Request;
|
||||
using Dlhis.Canteen.Order.Request;
|
||||
using Dlhis.Canteen.Order.Response;
|
||||
using Dlhis.Canteen.Order.Services;
|
||||
using Kurisu.AspNetCore.DataAccess.SqlSugar.Aop;
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Dlhis.Canteen.Order.Controllers;
|
||||
namespace Dlhis.Canteen.Dishes.Controllers;
|
||||
|
||||
/// <summary>
|
||||
/// 订单
|
||||
@@ -44,4 +46,38 @@ public class OrdersController : ControllerBase
|
||||
{
|
||||
return await _orderService.AddAsync(request);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设备发起订单
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("device")]
|
||||
[IgnoreTenant]
|
||||
public async Task<OrderResultResponse> DeviceConsume(OrderAddRequest request)
|
||||
{
|
||||
return await _orderService.AddAsync(request);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 订餐
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[IgnoreTenant]
|
||||
[HttpPost("booking")]
|
||||
public async Task Booking(BookingMealRequest request)
|
||||
{
|
||||
await _orderService.Booking(request);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 充值
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost("recharge")]
|
||||
public async Task ReCharge()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
//using Microsoft.AspNetCore.Mvc.Filters;
|
||||
|
||||
//namespace Dlhis.Canteen.Order.Filters;
|
||||
|
||||
///// <summary>
|
||||
///// 检查用户设备消费
|
||||
///// </summary>
|
||||
//public class CheckUserDeviceConsumeAttribute : IAsyncActionFilter
|
||||
//{
|
||||
// public Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
|
||||
// {
|
||||
|
||||
// }
|
||||
//}
|
||||
@@ -1,5 +1,4 @@
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Dlhis.Canteen.Order.Request
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Dlhis.Canteen.Order.Request;
|
||||
namespace Dlhis.Canteen.Dishes.Request;
|
||||
|
||||
public class BalanceRecordObsoluteRequest
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Dlhis.Canteen.Order.Request
|
||||
namespace Dlhis.Canteen.Dishes.Request
|
||||
{
|
||||
public class BalanceRecordPageByCostIdRequest :PageDto
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
|
||||
namespace Dlhis.Canteen.Order.Request;
|
||||
namespace Dlhis.Canteen.Dishes.Request;
|
||||
|
||||
public class BalanceRecordPageByDeviceUniqueNoRequest : PageDto
|
||||
{
|
||||
|
||||
@@ -4,7 +4,7 @@ using SqlSugar;
|
||||
using SqlSugar.DbConvert;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Dlhis.Canteen.Order.Request
|
||||
namespace Dlhis.Canteen.Dishes.Request
|
||||
{
|
||||
public class BalanceRecordPageDetailsRequest : PageDto
|
||||
{
|
||||
|
||||
@@ -2,10 +2,8 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
using Kurisu.Core.CustomClass;
|
||||
using SqlSugar.DbConvert;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Dlhis.Canteen.Order.Request;
|
||||
namespace Dlhis.Canteen.Dishes.Request;
|
||||
|
||||
public class BalanceRecordPageRequest : PageDto, IValidatableObject
|
||||
{
|
||||
@@ -17,7 +15,7 @@ public class BalanceRecordPageRequest : PageDto, IValidatableObject
|
||||
/// <summary>
|
||||
/// 餐次
|
||||
/// </summary>
|
||||
public List<string> ShiftTypes { get; set; }
|
||||
public List<ShiftEnumType?> ShiftTypes { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 充值/消费
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Dlhis.Canteen.Order.Request
|
||||
namespace Dlhis.Canteen.Dishes.Request
|
||||
{
|
||||
public class BalanceRecordSummaryRequest : PageDto
|
||||
{
|
||||
|
||||
@@ -3,7 +3,7 @@ using Kurisu.Core.CustomClass;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
|
||||
namespace Dlhis.Canteen.Order.Request
|
||||
namespace Dlhis.Canteen.Dishes.Request
|
||||
{
|
||||
public class BalanceRecordUserPageRequest : PageDto, IValidatableObject
|
||||
{
|
||||
|
||||
46
Src/Dlhis.Canteen/Order/Request/BookingMealRequest.cs
Normal file
46
Src/Dlhis.Canteen/Order/Request/BookingMealRequest.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Dlhis.Entity.Canteen.Enums;
|
||||
|
||||
namespace Dlhis.Canteen.Dishes.Request;
|
||||
|
||||
/// <summary>
|
||||
/// 订餐请求
|
||||
/// </summary>
|
||||
public class BookingMealRequest : IValidatableObject
|
||||
{
|
||||
/// <summary>
|
||||
/// 订餐的日期
|
||||
/// </summary>
|
||||
public DateTime BookingDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 营业点/消费地点
|
||||
/// </summary>
|
||||
public Guid BusinessPlaceCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 餐次
|
||||
/// </summary>
|
||||
[EnumDataType(typeof(ShiftEnumType))]
|
||||
public ShiftEnumType ShiftType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 菜品编码
|
||||
/// </summary>
|
||||
[Required(ErrorMessage = "选菜不能为空")]
|
||||
public string DishesCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 消费来源
|
||||
/// </summary>
|
||||
[EnumDataType(typeof(BalanceRecordSourceEnumType))]
|
||||
public BalanceRecordSourceEnumType Source { get; set; }
|
||||
|
||||
|
||||
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
||||
{
|
||||
BookingDate = BookingDate.Date;
|
||||
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
using Dlhis.Entity.Canteen.Enums;
|
||||
|
||||
namespace Dlhis.Canteen.Order.Request;
|
||||
namespace Dlhis.Canteen.Dishes.Request;
|
||||
|
||||
public class ConsumeRequest
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using Dlhis.Entity.Canteen.Enums;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Dlhis.Canteen.Order.Request
|
||||
namespace Dlhis.Canteen.Dishes.Request
|
||||
{
|
||||
public class ConsumptionTrendRequest
|
||||
{
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
namespace Dlhis.Canteen.Order.Request
|
||||
{
|
||||
public class DispositionDeviceRequest
|
||||
{
|
||||
public string PlaceCode { get; set; }
|
||||
|
||||
public List<string> UniqueNos { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
namespace Dlhis.Canteen.Order.Request
|
||||
{
|
||||
public class DispositionDishesDto
|
||||
{
|
||||
public string DisherCode { get; set; }
|
||||
|
||||
public int RestrictedNum { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
namespace Dlhis.Canteen.Order.Request
|
||||
{
|
||||
public class DispositionDishesRequest
|
||||
{
|
||||
public Guid MenudCode { get; set; }
|
||||
|
||||
public List<DispositionDishesDto> DishersDtos { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,8 @@
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
|
||||
namespace Dlhis.Canteen.Order.Request
|
||||
namespace Dlhis.Canteen.Dishes.Request;
|
||||
|
||||
public class GetConsumeDeviceRequest : PageDto
|
||||
{
|
||||
public class GetConsumeDeviceRequest : PageDto
|
||||
{
|
||||
public bool IsOff { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
|
||||
namespace Dlhis.Canteen.Order.Request
|
||||
{
|
||||
public class GetDetailRequest : PageDto
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
|
||||
namespace Dlhis.Canteen.Order.Request
|
||||
{
|
||||
public class GetDishesRequest : PageDto
|
||||
{
|
||||
public Guid? MenuCode { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
|
||||
namespace Dlhis.Canteen.Order.Request
|
||||
{
|
||||
public class GetMenuRequest : PageDto
|
||||
{
|
||||
public Guid? PlaceCode { get; set; }
|
||||
|
||||
public string Factory { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
|
||||
namespace Dlhis.Canteen.Order.Request
|
||||
{
|
||||
public class GetMiniProgramOrderRequest : PageDto
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
|
||||
namespace Dlhis.Canteen.Order.Request
|
||||
namespace Dlhis.Canteen.Dishes.Request
|
||||
{
|
||||
public class OaEMealVoucherDetailRequest : PageDto
|
||||
{
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Dlhis.Canteen.Order.Request
|
||||
namespace Dlhis.Canteen.Dishes.Request
|
||||
{
|
||||
public class OaEMealVoucherRequest : PageDto
|
||||
{
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
using Dlhis.Entity.Canteen.Enums;
|
||||
using SqlSugar.DbConvert;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Dlhis.Canteen.Order.Request
|
||||
{
|
||||
public class OrderRequest
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 订餐人
|
||||
/// </summary>
|
||||
public string UserCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 食堂
|
||||
/// </summary>
|
||||
public Guid PlaceCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 餐次
|
||||
/// </summary>
|
||||
public ShiftEnumType ShiftType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 配送地址
|
||||
/// </summary>
|
||||
public string Address { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 菜单
|
||||
/// </summary>
|
||||
public Guid MenuCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 菜品
|
||||
/// </summary>
|
||||
public string DishesCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 数量
|
||||
/// </summary>
|
||||
public int DishesNum { get; set; } = 1;
|
||||
|
||||
/// <summary>
|
||||
/// 支付方式
|
||||
/// </summary>
|
||||
public BalanceRecordSourceEnumType PayType { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
using Dlhis.Entity.Canteen.Enums;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Dlhis.Canteen.Order.Request;
|
||||
namespace Dlhis.Canteen.Dishes.Request;
|
||||
|
||||
public class RechargeRequest
|
||||
{
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Dlhis.Canteen.Order.Request;
|
||||
|
||||
public class SaveDishesRequest
|
||||
{
|
||||
public long? Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 大类
|
||||
/// </summary>
|
||||
public string PCategory { get; set; }
|
||||
|
||||
/// <summary>`
|
||||
/// 小类
|
||||
/// </summary>
|
||||
[Required]
|
||||
public string Category { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 菜品名称
|
||||
/// </summary>
|
||||
[Required]
|
||||
public string Name { get; set; }
|
||||
|
||||
|
||||
[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>
|
||||
public bool Enable { get; set; }
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
using Dlhis.Entity.Canteen.Enums;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Dlhis.Canteen.Order.Request;
|
||||
|
||||
public class SaveMenuRequest : IValidatableObject
|
||||
{
|
||||
/// <summary>
|
||||
/// 所属营业点
|
||||
/// </summary>
|
||||
public Guid PlaceCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 菜单名称
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 营业日期,不能小于等于当天
|
||||
/// </summary>
|
||||
public DateTime Date { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 餐次段
|
||||
/// </summary>
|
||||
public ShiftEnumType ShiftType { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Dlhis.Canteen.Order.Request
|
||||
{
|
||||
public class SpendingDetailRequest:PageDto
|
||||
public class SpendingDetailRequest : PageDto
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
namespace Dlhis.Canteen.Order.Response
|
||||
namespace Dlhis.Canteen.Order.Response;
|
||||
|
||||
public class AverageDailyResponse
|
||||
{
|
||||
public class AverageDailyResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// 档案号/QRCode
|
||||
/// </summary>
|
||||
@@ -21,5 +21,4 @@
|
||||
/// 日消费均额
|
||||
/// </summary>
|
||||
public int AverageAmount { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
using SqlSugar;
|
||||
|
||||
namespace Dlhis.Canteen.Order.Response
|
||||
namespace Dlhis.Canteen.Order.Response
|
||||
{
|
||||
public class BalanceRecordAnalysisRespones
|
||||
{
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
using Dlhis.Entity.Canteen.Enums;
|
||||
using SqlSugar.DbConvert;
|
||||
using SqlSugar;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
|
||||
namespace Dlhis.Canteen.Order.Response
|
||||
namespace Dlhis.Canteen.Order.Response;
|
||||
|
||||
public class GetDetailResponse
|
||||
{
|
||||
public class GetDetailResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// 订单号
|
||||
/// </summary>
|
||||
@@ -66,6 +64,4 @@ namespace Dlhis.Canteen.Order.Response
|
||||
/// 订单明细状态CN
|
||||
/// </summary>
|
||||
public string OrderStatusCN => OrderStatus.GetDescription();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
using Dlhis.Entity.Canteen.Enums;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
|
||||
namespace Dlhis.Canteen.Order.Response
|
||||
{
|
||||
public class GetDishesResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// 大类
|
||||
/// </summary>
|
||||
public string Categories { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 小类
|
||||
/// </summary>
|
||||
public string SubCategories { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 菜品编码
|
||||
/// </summary>
|
||||
public string Code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 菜品名称
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 菜品类型
|
||||
/// </summary>
|
||||
public CanteenMenuEnumType Type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 菜品类型描述
|
||||
/// </summary>
|
||||
public string TypeDescription => Type.GetDescription();
|
||||
|
||||
/// <summary>
|
||||
/// 描述
|
||||
/// </summary>
|
||||
public string Description { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 单价
|
||||
/// </summary>
|
||||
public decimal Amount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 单位
|
||||
/// </summary>
|
||||
public string Unit { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 图片
|
||||
/// </summary>
|
||||
public string Image { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否启用
|
||||
/// </summary>
|
||||
public bool Enable { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 限售份数
|
||||
/// </summary>
|
||||
public int? RestrictedNum { get; set; } = null;
|
||||
}
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
using Dlhis.Entity.Canteen.Enums;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
|
||||
namespace Dlhis.Canteen.Order.Response
|
||||
{
|
||||
public class GetMenuResponse
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 菜单编码
|
||||
/// </summary>
|
||||
public Guid Code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 菜单名称
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 所属营业点
|
||||
/// </summary>
|
||||
public Guid PlaceCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 所属营业点名称
|
||||
/// </summary>
|
||||
public string PlaceName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 厂区
|
||||
/// </summary>
|
||||
public string Factory { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 营业日期
|
||||
/// </summary>
|
||||
public DateOnly StartDate { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 餐次段
|
||||
/// </summary>
|
||||
public List<ShiftEnumType> ShiftTypes
|
||||
{
|
||||
get
|
||||
{
|
||||
if (ShiftTypesSrt.IsEmpty()) ShiftTypesSrt = "[]";
|
||||
|
||||
return ShiftTypesSrt.ToObject<List<ShiftEnumType>>();
|
||||
}
|
||||
}
|
||||
|
||||
public string ShiftTypesSrt { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否启用
|
||||
/// </summary>
|
||||
public bool Enable { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,10 @@
|
||||
using Dlhis.Entity.Canteen.Enums;
|
||||
using SqlSugar.DbConvert;
|
||||
using SqlSugar;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
|
||||
namespace Dlhis.Canteen.Order.Response
|
||||
namespace Dlhis.Canteen.Order.Response;
|
||||
|
||||
public class GetMiniProgramOrderResponse
|
||||
{
|
||||
public class GetMiniProgramOrderResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// 订单号
|
||||
/// </summary>
|
||||
@@ -133,4 +131,3 @@ namespace Dlhis.Canteen.Order.Response
|
||||
public decimal TotalAmount { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
using SqlSugar;
|
||||
namespace Dlhis.Canteen.Order.Response;
|
||||
|
||||
namespace Dlhis.Canteen.Order.Response
|
||||
public class OaEMealVoucherResponse
|
||||
{
|
||||
public class OaEMealVoucherResponse
|
||||
{
|
||||
public long Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
@@ -96,5 +94,4 @@ namespace Dlhis.Canteen.Order.Response
|
||||
/// 数据创建时间
|
||||
/// </summary>
|
||||
public DateTime CreateTime { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
using SqlSugar;
|
||||
namespace Dlhis.Canteen.Order.Response;
|
||||
|
||||
namespace Dlhis.Canteen.Order.Response
|
||||
public class SpendingDetailResponse
|
||||
{
|
||||
public class SpendingDetailResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// 档案号/QRCode
|
||||
/// </summary>
|
||||
@@ -34,5 +32,4 @@ namespace Dlhis.Canteen.Order.Response
|
||||
/// </summary>
|
||||
public string OriginTenantId { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,17 +0,0 @@
|
||||
using Dlhis.Canteen.Order.Request;
|
||||
using Dlhis.Canteen.Order.Response;
|
||||
using Kurisu.Core.DataAccess.Dto;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -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,10 +410,10 @@ 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();
|
||||
|
||||
@@ -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);
|
||||
//当日消费人数
|
||||
@@ -696,7 +682,7 @@ public class BalanceService : IBalanceService
|
||||
{
|
||||
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,74 +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.PlaceCode.HasValue, x => request.PlaceCode == x.PlaceCode)
|
||||
.WhereIF(!request.Search.IsEmpty(), x => x.Name.Contains(request.Search))
|
||||
.Select((x, place) => new GetMenuResponse
|
||||
{
|
||||
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}:该营业点不存在!");
|
||||
|
||||
|
||||
}
|
||||
|
||||
public async Task<Pagination<GetDishesResponse>> GetDishesAsync(GetDishesRequest request)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public async Task SaveDishesAsync(SaveDishesRequest request)
|
||||
{
|
||||
if (!request.Id.HasValue)
|
||||
{
|
||||
var dishers = request.Adapt<CanteenDishesEntity>();
|
||||
//todo 检验重复
|
||||
dishers.CustomCode = request.CustomCode;
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,177 +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.CustomCode)
|
||||
.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, 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.CustomCode == 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.Price,
|
||||
Unit = dishes.Unit,
|
||||
Number = request.DishesNum,
|
||||
Amount = request.DishesNum * dishes.Price,
|
||||
Status = OrderDetailsStatusEnumType.I,
|
||||
};
|
||||
order.Amount = 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,117 @@ public class OrderService : IOrderService
|
||||
uniqueNos.Contains(deviceUniqueNo).ThrowIfFalse("无消费权限");
|
||||
}
|
||||
|
||||
public async Task Booking(BookingMealRequest request)
|
||||
{
|
||||
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,
|
||||
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;
|
||||
if (canteenUser.Balance < 0)
|
||||
{
|
||||
throw new UserFriendlyException("余额不足,无法消费");
|
||||
}
|
||||
|
||||
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 +183,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);
|
||||
|
||||
@@ -194,14 +314,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 +384,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 +399,7 @@ public class OrderService : IOrderService
|
||||
CostDateTime = request.CostDateTime,
|
||||
|
||||
//标识当前消费的基地
|
||||
TenantId = gainfo.Werks,
|
||||
TenantId = gainfo.Factory,
|
||||
};
|
||||
|
||||
var orderId = await _dbContext.InsertReturnIdentityAsync(order);
|
||||
@@ -305,8 +425,6 @@ public class OrderService : IOrderService
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//******************************************************* help methods ************************************************************/
|
||||
|
||||
|
||||
@@ -355,7 +473,6 @@ public class OrderService : IOrderService
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
if (int.TryParse(v, out var n))
|
||||
{
|
||||
return n.Adapt<T>();
|
||||
@@ -526,5 +643,4 @@ public class OrderService : IOrderService
|
||||
|
||||
}, 5);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using Kurisu.Core.CustomClass;
|
||||
|
||||
namespace Dlhis.Canteen.Order;
|
||||
namespace Dlhis.Canteen.Dishes;
|
||||
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -23,6 +23,16 @@ public class Startup : DefaultStartup
|
||||
public override void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
base.ConfigureServices(services);
|
||||
//protected static string Obfuscate(string value)
|
||||
//{
|
||||
// var last4Chars = "****";
|
||||
// if (value.IsPresent() && value.Length > 4)
|
||||
// {
|
||||
// last4Chars = value.Substring(value.Length - 4);
|
||||
// }
|
||||
|
||||
// return "****" + last4Chars;
|
||||
//}
|
||||
|
||||
services.AddRedis();
|
||||
}
|
||||
|
||||
@@ -70,35 +70,7 @@ public class CanteenSettingService : ICanteenSettingService
|
||||
}
|
||||
}
|
||||
|
||||
private void Inspection(CanteenSettingSaveRequest request)
|
||||
{
|
||||
var value = request.Value;
|
||||
|
||||
var result = request.Item switch
|
||||
{
|
||||
//TimeOnly
|
||||
CanteenSettingItemEnumType.BusinessSwitchTime => IsValidFormat<TimeOnly>(value, request.Item),
|
||||
|
||||
//int
|
||||
CanteenSettingItemEnumType.DayEVoucherUseCountMax => IsValidFormat<int>(value),
|
||||
|
||||
//decimal
|
||||
CanteenSettingItemEnumType.OnceCostMax => IsValidFormat<decimal>(value),
|
||||
CanteenSettingItemEnumType.DayCostMax => IsValidFormat<decimal>(value),
|
||||
CanteenSettingItemEnumType.DayMarketCostMax => IsValidFormat<decimal>(value),
|
||||
CanteenSettingItemEnumType.Subsidies => IsValidFormat<decimal>(value),
|
||||
CanteenSettingItemEnumType.InitBalance => IsValidFormat<decimal>(value),
|
||||
|
||||
//bool
|
||||
CanteenSettingItemEnumType.AllowNoBalance => IsValidFormat<bool>(value, request.Item),
|
||||
CanteenSettingItemEnumType.AllowSendAtMeal => IsValidFormat<bool>(value, request.Item),
|
||||
CanteenSettingItemEnumType.AllowRepeatInOneShift => IsValidFormat<bool>(value, request.Item),
|
||||
CanteenSettingItemEnumType.AllowCrossTenant => IsValidFormat<bool>(value, request.Item),
|
||||
_ => throw new NotImplementedException(),
|
||||
};
|
||||
|
||||
result.ThrowIfFalse($"{request.Item.GetDescription()},参数值为[{value}],格式错误");
|
||||
}
|
||||
|
||||
public async Task SetEnableAsync(CanteenSettingSetEnableRequest request)
|
||||
{
|
||||
@@ -112,15 +84,15 @@ public class CanteenSettingService : ICanteenSettingService
|
||||
|
||||
public async Task<Dictionary<CanteenSettingItemEnumType, string>> GetUserSettingAsync(string userNo)
|
||||
{
|
||||
var setting = await _context.Queryable<CanteenSettingEntity>()
|
||||
.Where(x => x.UniqueType == CanteenSettingUnqiueEnumType.Person && (x.UniqueValue == userNo) || x.UniqueType == CanteenSettingUnqiueEnumType.Tenant)
|
||||
var settings = await _context.Queryable<CanteenSettingEntity>()
|
||||
.Where(x => (x.UniqueType == CanteenSettingUnqiueEnumType.Person && x.UniqueValue == userNo) || x.UniqueType == CanteenSettingUnqiueEnumType.Tenant)
|
||||
.ToListAsync();
|
||||
|
||||
//从基地 -> 个人,确保下面循环做到覆盖,并且以个人配置为主
|
||||
setting = setting.OrderBy(x => x.UniqueType).ToList();
|
||||
settings = settings.OrderBy(x => x.UniqueType).ToList();
|
||||
|
||||
var result = new Dictionary<CanteenSettingItemEnumType, string>();
|
||||
setting.ForEach(x =>
|
||||
settings.ForEach(x =>
|
||||
{
|
||||
if (result.ContainsKey(x.Item))
|
||||
{
|
||||
@@ -197,4 +169,35 @@ public class CanteenSettingService : ICanteenSettingService
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private static void Inspection(CanteenSettingSaveRequest request)
|
||||
{
|
||||
var value = request.Value;
|
||||
|
||||
var result = request.Item switch
|
||||
{
|
||||
//TimeOnly
|
||||
CanteenSettingItemEnumType.BusinessSwitchTime => IsValidFormat<TimeOnly>(value, request.Item),
|
||||
CanteenSettingItemEnumType.BookingDeadline => IsValidFormat<TimeOnly>(value, request.Item),
|
||||
|
||||
//int
|
||||
CanteenSettingItemEnumType.DayEVoucherUseCountMax => IsValidFormat<int>(value),
|
||||
|
||||
//decimal
|
||||
CanteenSettingItemEnumType.OnceCostMax => IsValidFormat<decimal>(value),
|
||||
CanteenSettingItemEnumType.DayCostMax => IsValidFormat<decimal>(value),
|
||||
CanteenSettingItemEnumType.DayMarketCostMax => IsValidFormat<decimal>(value),
|
||||
CanteenSettingItemEnumType.Subsidies => IsValidFormat<decimal>(value),
|
||||
CanteenSettingItemEnumType.InitBalance => IsValidFormat<decimal>(value),
|
||||
|
||||
//bool
|
||||
CanteenSettingItemEnumType.AllowNoBalance => IsValidFormat<bool>(value, request.Item),
|
||||
CanteenSettingItemEnumType.AllowSendAtMeal => IsValidFormat<bool>(value, request.Item),
|
||||
CanteenSettingItemEnumType.AllowRepeatInOneShift => IsValidFormat<bool>(value, request.Item),
|
||||
CanteenSettingItemEnumType.AllowCrossTenant => IsValidFormat<bool>(value, request.Item),
|
||||
_ => throw new NotImplementedException(),
|
||||
};
|
||||
|
||||
result.ThrowIfFalse($"{request.Item.GetDescription()},参数值为[{value}],格式错误");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
using Kurisu.AspNetCore.Startup;
|
||||
using Kurisu.Core.DataAccess.Entity;
|
||||
using Kurisu.SqlSugar.Extensions;
|
||||
using Kurisu.SqlSugar.Services;
|
||||
using Microsoft.AspNetCore.Mvc.Filters;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Dlhis.Canteen;
|
||||
|
||||
@@ -16,101 +12,3 @@ public class SqlSugarPack : BaseAppPack
|
||||
services.AddSqlSugar();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 日志
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Method)]
|
||||
public class LogAttribute : Attribute, IAsyncActionFilter
|
||||
{
|
||||
public LogAttribute(string title)
|
||||
{
|
||||
Title = title;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string Title { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否处理差异
|
||||
/// </summary>
|
||||
public bool Diff { get; set; }
|
||||
|
||||
|
||||
public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
|
||||
{
|
||||
PreSetting(context.HttpContext);
|
||||
await next();
|
||||
}
|
||||
|
||||
private void PreSetting(HttpContext httpContext)
|
||||
{
|
||||
var options = httpContext.RequestServices.GetService<ISqlSugarOptionsService>();
|
||||
|
||||
options.Title = Title;
|
||||
options.Diff = Diff;
|
||||
options.BatchNo = Guid.NewGuid();
|
||||
options.RoutePath = httpContext.Request.Path.Value;
|
||||
options.RaiseTime = DateTime.Now;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 事务
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Method)]
|
||||
public class TransactionalAttribute : Attribute, IAsyncActionFilter
|
||||
{
|
||||
public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
|
||||
{
|
||||
var dbContext = context.HttpContext.RequestServices.GetRequiredService<ISqlSugarClient>();
|
||||
await dbContext.Ado.BeginTranAsync();
|
||||
try
|
||||
{
|
||||
var result = await next();
|
||||
if (result.Exception != null)
|
||||
{
|
||||
throw result.Exception;
|
||||
}
|
||||
else
|
||||
{
|
||||
await dbContext.Ado.CommitTranAsync();
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
await dbContext.Ado.RollbackTranAsync();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 忽略租户
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Method)]
|
||||
public class IgnoreTenantAttribute : Attribute, IAsyncActionFilter
|
||||
{
|
||||
public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
|
||||
{
|
||||
var dbContext = context.HttpContext.RequestServices.GetRequiredService<ISqlSugarClient>();
|
||||
var options = context.HttpContext!.RequestServices.GetService<ISqlSugarOptionsService>();
|
||||
try
|
||||
{
|
||||
dbContext.QueryFilter.ClearAndBackup<ITenantId>();
|
||||
options.IgnoreTenant = true;
|
||||
await next();
|
||||
}
|
||||
finally
|
||||
{
|
||||
options.IgnoreTenant = false;
|
||||
dbContext.QueryFilter.Restore();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,114 +0,0 @@
|
||||
using Dlhis.Entity.Canteen.Enums;
|
||||
using Kurisu.Core.DataAccess.Entity;
|
||||
using Kurisu.SqlSugar;
|
||||
using SqlSugar;
|
||||
using SqlSugar.DbConvert;
|
||||
|
||||
namespace Dlhis.Entity.Canteen.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// 小程序订单表
|
||||
/// </summary>
|
||||
[SugarTable(TableName = "MiniProgramOrder", TableDescription = "小程序订单表")]
|
||||
public class MiniProgramOrderEntity : SugarBaseEntity, ITenantId
|
||||
{
|
||||
/// <summary>
|
||||
/// 订单号
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "订单号")]
|
||||
public string No { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 姓名
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "姓名")]
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 工号
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "工号")]
|
||||
public string Code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 人事范围
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "人事范围")]
|
||||
public string Werks { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 部门编码
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "部门编码")]
|
||||
public string DepartmentNo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 成本中心
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "成本中心")]
|
||||
public string CostId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 工作地
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "工作地")]
|
||||
public string Workplace { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 厂区
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "厂区")]
|
||||
public string Factory { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 营业点
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "营业点")]
|
||||
public Guid PlaceCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 餐次
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType = "varchar(50)", SqlParameterDbType = typeof(EnumToStringConvert), ColumnDescription = "餐次")]
|
||||
public ShiftEnumType ShiftType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 手机号码
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "手机号码")]
|
||||
public string Phone { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 用餐日期
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "用餐日期", IsNullable = true)]
|
||||
public DateTime UseDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 支付方式
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "支付方式", ColumnDataType = "varchar(50)", SqlParameterDbType = typeof(EnumToStringConvert))]
|
||||
public BalanceRecordSourceEnumType PayType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 订单状态
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType = "varchar(50)", SqlParameterDbType = typeof(EnumToStringConvert), ColumnDescription = "订单状态")]
|
||||
public MiniProgramOrderStatusEnumType OrderStatus { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 订单类型
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType = "varchar(50)", SqlParameterDbType = typeof(EnumToStringConvert), ColumnDescription = "订单类型")]
|
||||
public CanteenMenuEnumType OrderType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 总金额
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "金额")]
|
||||
public decimal Amount { get; set; }
|
||||
|
||||
|
||||
public string TenantId { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -9,8 +9,8 @@ namespace Dlhis.Entity.Canteen.Entities;
|
||||
/// <summary>
|
||||
/// 订餐明细表
|
||||
/// </summary>
|
||||
[SugarTable(TableName = "OrderDetails", TableDescription = "订餐明细表")]
|
||||
public class OrderDetailsEntity : SugarBaseEntity, ITenantId
|
||||
[SugarTable(TableName = "OrderDetail", TableDescription = "订单明细表")]
|
||||
public class OrderDetailEntity : SugarBaseEntity, ITenantId
|
||||
{
|
||||
/// <summary>
|
||||
/// 订单号
|
||||
@@ -46,8 +46,9 @@ public class OrderDetailsEntity : SugarBaseEntity, ITenantId
|
||||
/// <summary>
|
||||
/// 订单明细状态
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType = "varchar(50)", SqlParameterDbType = typeof(EnumToStringConvert), ColumnDescription = "订单明细状态")]
|
||||
[SugarColumn(ColumnDataType = "varchar(50)", SqlParameterDbType = typeof(EnumToStringConvert), ColumnDescription = "状态")]
|
||||
public OrderDetailsStatusEnumType Status { get; set; }
|
||||
|
||||
|
||||
public string TenantId { get; set; }
|
||||
}
|
||||
@@ -1,14 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Dlhis.Entity.Canteen.Enums
|
||||
{
|
||||
/// <summary>
|
||||
/// 订单明细状态
|
||||
/// 订单明细状态 OrderDetailsStatusEnumType
|
||||
/// </summary>
|
||||
[Description("订单明细状态")]
|
||||
public enum OrderDetailsStatusEnumType
|
||||
|
||||
Reference in New Issue
Block a user