diff --git a/Src/Dlhis.Canteen/Order/Controllers/OrdersController.cs b/Src/Dlhis.Canteen/Order/Controllers/OrdersController.cs
index 7fb5f092..fc1ee44e 100644
--- a/Src/Dlhis.Canteen/Order/Controllers/OrdersController.cs
+++ b/Src/Dlhis.Canteen/Order/Controllers/OrdersController.cs
@@ -6,6 +6,7 @@ using Kurisu.AspNetCore.DataAccess.SqlSugar.Aop;
using Kurisu.Core.DataAccess.Dto;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
+using Org.BouncyCastle.Asn1.Ocsp;
namespace Dlhis.Canteen.Dishes.Controllers;
@@ -68,9 +69,20 @@ public class OrdersController : ControllerBase
[Transactional]
public async Task Booking(BookingMealRequest request)
{
- await _orderService.Booking(request);
+ await _orderService.BookingAsync(request);
}
+ /////
+ ///// 获取详情
+ /////
+ /////
+ /////
+ //[HttpGet("details")]
+ //public async Task> GetDetailsAsync(string no)
+ //{
+ // return await _orderService.GetDetailsAsync(no);
+ //}
+
///
/// 充值
///
@@ -80,4 +92,14 @@ public class OrdersController : ControllerBase
{
}
+
+ ///
+ /// 订单聚合数据
+ ///
+ ///
+ [HttpGet("aggregation")]
+ public async Task> GetOrdersAggregationAsync([FromQuery] PageDto page)
+ {
+ return await _orderService.GetOrdersAggregationAsync(page);
+ }
}
diff --git a/Src/Dlhis.Canteen/Order/Request/BalanceRecordUserPageRequest.cs b/Src/Dlhis.Canteen/Order/Request/BalanceRecordUserPageRequest.cs
index 719f7e3f..8e544b15 100644
--- a/Src/Dlhis.Canteen/Order/Request/BalanceRecordUserPageRequest.cs
+++ b/Src/Dlhis.Canteen/Order/Request/BalanceRecordUserPageRequest.cs
@@ -3,7 +3,7 @@ using Kurisu.Core.CustomClass;
using System.ComponentModel.DataAnnotations;
using Kurisu.Core.DataAccess.Dto;
-namespace Dlhis.Canteen.Dishes.Request
+namespace Dlhis.Canteen.Order.Request
{
public class BalanceRecordUserPageRequest : PageDto, IValidatableObject
{
@@ -13,11 +13,17 @@ namespace Dlhis.Canteen.Dishes.Request
[EnumDataType(typeof(DateTimeSearchEnumType))]
public DateTimeSearchEnumType? SearchDateTimeDimension { get; set; }
+ ///
+ /// 消费应用类型
+ ///
+ public CanteenApplicaitonTypeEnumType? ApplicationType { get; set; }
+
///
/// 日期范围查询
///
public DateTimePeriod SearchDateTimePeriod { get; set; }
+
public IEnumerable Validate(ValidationContext validationContext)
{
var now = DateTime.Now;
@@ -43,8 +49,8 @@ namespace Dlhis.Canteen.Dishes.Request
}
else if (SearchDateTimeDimension == DateTimeSearchEnumType.Season)
{
- SearchDateTimePeriod.Start = now.AddMonths(0 - ((now.Month - 1) % 3));
- SearchDateTimePeriod.End = now.AddMonths(3 - ((now.Month - 1) % 3)).AddMonths(1).AddDays(-1);
+ SearchDateTimePeriod.Start = now.AddMonths(0 - (now.Month - 1) % 3);
+ SearchDateTimePeriod.End = now.AddMonths(3 - (now.Month - 1) % 3).AddMonths(1).AddDays(-1);
}
else if (SearchDateTimeDimension == DateTimeSearchEnumType.HalfOfYear)
{
diff --git a/Src/Dlhis.Canteen/Order/Request/SaveDetailRequest.cs b/Src/Dlhis.Canteen/Order/Request/SaveDetailRequest.cs
deleted file mode 100644
index a7ed3d5d..00000000
--- a/Src/Dlhis.Canteen/Order/Request/SaveDetailRequest.cs
+++ /dev/null
@@ -1,61 +0,0 @@
-using Dlhis.Entity.Canteen.Enums;
-using SqlSugar.DbConvert;
-using SqlSugar;
-
-namespace Dlhis.Canteen.Order.Request
-{
- public class SaveDetailRequest
- {
- public long? Id { get; set; }
-
- ///
- /// 订单号
- ///
- public string ThirdNo { get; set; }
-
- ///
- /// 营业日
- ///
- public DateOnly BusinessDate { get; set; }
-
- ///
- /// 餐次
- ///
- public ShiftEnumType ShiftType { get; set; }
-
- ///
- /// 菜品编码
- ///
- public Guid DishesCode { get; set; }
-
- ///
- /// 菜品名称
- ///
- public Guid DishesName { get; set; }
-
- ///
- /// 单价
- ///
- public decimal Price { get; set; }
-
- ///
- /// 单位
- ///
- public string Unit { get; set; }
-
- ///
- /// 数量
- ///
- public int Num { get; set; }
-
- ///
- /// 金额
- ///
- public decimal Amount { get; set; }
-
- ///
- /// 订单明细状态
- ///
- public OrderDetailsStatusEnumType OrderStatus { get; set; }
- }
-}
diff --git a/Src/Dlhis.Canteen/Order/Response/BalanceRecordUserResponse.cs b/Src/Dlhis.Canteen/Order/Response/BalanceRecordUserResponse.cs
index 1ab529aa..9ad32164 100644
--- a/Src/Dlhis.Canteen/Order/Response/BalanceRecordUserResponse.cs
+++ b/Src/Dlhis.Canteen/Order/Response/BalanceRecordUserResponse.cs
@@ -49,4 +49,15 @@ public class BalanceRecordUserResponse
/// 记录产生日期
///
public DateTime CostDateTime { get; set; }
+
+
+ ///
+ /// 消费应用类型
+ ///
+ public CanteenApplicaitonTypeEnumType ApplicationType { get; set; }
+
+ ///
+ /// 消费应用类型
+ ///
+ public string ApplicationTypeDesc => ApplicationType.GetDescription();
}
diff --git a/Src/Dlhis.Canteen/Order/Response/DishesDto.cs b/Src/Dlhis.Canteen/Order/Response/DishesDto.cs
new file mode 100644
index 00000000..5ce96c19
--- /dev/null
+++ b/Src/Dlhis.Canteen/Order/Response/DishesDto.cs
@@ -0,0 +1,34 @@
+using Newtonsoft.Json;
+
+namespace Dlhis.Canteen.Order.Response;
+
+public class DishesDto
+{
+ [JsonIgnore]
+ public string No { get; set; }
+
+ ///
+ /// 菜品编码
+ ///
+ public string DishesCode { get; set; }
+
+ ///
+ /// 菜品名称
+ ///
+ public string Name { get; set; }
+
+ ///
+ /// 购买单价
+ ///
+ public decimal Price { get; set; }
+
+ ///
+ /// 购买数量
+ ///
+ public int Number { get; set; }
+
+ ///
+ /// 图片
+ ///
+ public string ImageUrl { get; set; }
+}
diff --git a/Src/Dlhis.Canteen/Order/Response/OrderAggregationResponse.cs b/Src/Dlhis.Canteen/Order/Response/OrderAggregationResponse.cs
new file mode 100644
index 00000000..a1cb257b
--- /dev/null
+++ b/Src/Dlhis.Canteen/Order/Response/OrderAggregationResponse.cs
@@ -0,0 +1,51 @@
+using Kurisu.AspNetCore.Utils.Extensions;
+
+namespace Dlhis.Canteen.Order.Response;
+
+public class OrderAggregationResponse
+{
+ public string No { get; set; }
+
+ ///
+ /// 营业点
+ ///
+ public string BusinessPlaceName { get; set; }
+
+ ///
+ /// 购买菜品
+ ///
+ public List Dishes { get; set; }
+
+
+ ///
+ /// 金额
+ ///
+ public decimal Amount
+ {
+ get
+ {
+ if (Dishes.IsPresent())
+ {
+ return Dishes.Sum(x => x.Number * x.Price);
+ }
+
+ return 0;
+ }
+ }
+
+ ///
+ /// 共计数量
+ ///
+ public int Count
+ {
+ get
+ {
+ if (Dishes.IsPresent())
+ {
+ return Dishes.Count;
+ }
+
+ return 0;
+ }
+ }
+}
diff --git a/Src/Dlhis.Canteen/Order/Response/OrderDetailResponse.cs b/Src/Dlhis.Canteen/Order/Response/OrderDetailResponse.cs
new file mode 100644
index 00000000..f0af992a
--- /dev/null
+++ b/Src/Dlhis.Canteen/Order/Response/OrderDetailResponse.cs
@@ -0,0 +1,34 @@
+//namespace Dlhis.Canteen.Order.Response;
+
+//public class OrderDetailResponse
+//{
+// ///
+// /// 菜品编码
+// ///
+// public string DishesCode { get; set; }
+
+// ///
+// /// 菜品名称
+// ///
+// public string Name { get; set; }
+
+// ///
+// /// 单价
+// ///
+// public decimal Price { get; set; }
+
+// ///
+// /// 数量
+// ///
+// public int Number { get; set; }
+
+// ///
+// /// 单位
+// ///
+// public string Unit { get; set; }
+
+// ///
+// /// 图片
+// ///
+// public string ImageUrl { get; set; }
+//}
diff --git a/Src/Dlhis.Canteen/Order/Services/IOrderService.cs b/Src/Dlhis.Canteen/Order/Services/IOrderService.cs
index f78863cb..28c772df 100644
--- a/Src/Dlhis.Canteen/Order/Services/IOrderService.cs
+++ b/Src/Dlhis.Canteen/Order/Services/IOrderService.cs
@@ -9,6 +9,7 @@ public interface IOrderService : IScopeDependency
{
Task> GetPageAsync(OrderPageRequest request);
+
Task AddAsync(OrderAddRequest request);
///
@@ -23,5 +24,15 @@ public interface IOrderService : IScopeDependency
///
///
///
- Task Booking(BookingMealRequest request);
+ Task BookingAsync(BookingMealRequest request);
+
+
+ /////
+ ///// 获取订单详情
+ /////
+ /////
+ /////
+ //Task> GetDetailsAsync(string no);
+
+ Task> GetOrdersAggregationAsync(PageDto page);
}
diff --git a/Src/Dlhis.Canteen/Order/Services/Implements/BalanceService.cs b/Src/Dlhis.Canteen/Order/Services/Implements/BalanceService.cs
index 6c38604d..5bbe6c48 100644
--- a/Src/Dlhis.Canteen/Order/Services/Implements/BalanceService.cs
+++ b/Src/Dlhis.Canteen/Order/Services/Implements/BalanceService.cs
@@ -521,13 +521,14 @@ public class BalanceService : IBalanceService
.LeftJoin((record, ga) => record.UserNo == ga.No)
.LeftJoin((record, ga, department) => ga.DepartmentNo == department.No)
.LeftJoin((record, ga, department, bplace) => record.BusinessPlaceCode == bplace.Code)
- .LeftJoin((record, ga, department, bplace, bshift) => record.BusinessShiftCode == bshift.Code)
- .LeftJoin((record, ga, department, bplace, bshift, type) => record.BusinessShiftCode.ToString() == type.Code)
+ .LeftJoin((record, ga, department, bplace, bshiftR) => bplace.Code == bshiftR.PlaceCode)
+ .LeftJoin((record, ga, department, bplace, bshiftR, shift) => shift.Code == bshiftR.ShiftCode)
.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.ApplicationType.HasValue, record => record.ApplicationType == request.ApplicationType)
.Where((record, ga) => ga.IdentityUserId == userId)
.OrderBy(record => record.CreateTime, OrderByType.Desc)
- .Select((record, ga, department, bplace, bshift, type) => new BalanceRecordUserResponse
+ .Select((record, ga, department, bplace, bshiftR, shift) => new BalanceRecordUserResponse
{
Id = record.Id,
Amount = record.Amount,
@@ -536,8 +537,9 @@ public class BalanceService : IBalanceService
Source = record.Source,
No = record.No,
BusinessPlaceName = bplace.Name,
- BusinessShiftName = type.Display,
- CostDateTime = record.CostDateTime
+ BusinessShiftName = shift.Name,
+ CostDateTime = record.CostDateTime,
+ ApplicationType = record.ApplicationType,
})
.ToPageListAsync(request);
diff --git a/Src/Dlhis.Canteen/Order/Services/Implements/OrderService.cs b/Src/Dlhis.Canteen/Order/Services/Implements/OrderService.cs
index 040f13b7..87bf6d86 100644
--- a/Src/Dlhis.Canteen/Order/Services/Implements/OrderService.cs
+++ b/Src/Dlhis.Canteen/Order/Services/Implements/OrderService.cs
@@ -18,6 +18,8 @@ using SqlSugar;
using Dlhis.Canteen.Order.Response;
using Dlhis.Canteen.Dishes;
using Dlhis.Canteen.Order.Request;
+using System.Numerics;
+using MySqlX.XDevAPI.Relational;
namespace Dlhis.Canteen.Order.Services.Implements;
@@ -62,7 +64,7 @@ public class OrderService : IOrderService
uniqueNos.Contains(deviceUniqueNo).ThrowIfFalse("无消费权限");
}
- public async Task Booking(BookingMealRequest request)
+ public async Task BookingAsync(BookingMealRequest request)
{
var gainfo = await CheckExistsMyBookingsAsync(request.BookingDate, request.ShiftType);
@@ -177,7 +179,6 @@ public class OrderService : IOrderService
OrderNo = order.No,
DishesCode = request.DishesCode,
Price = menuDetail.Price,
- Status = OrderDetailsStatusEnumType.I,
//Unit
Number = 1,
});
@@ -186,6 +187,24 @@ public class OrderService : IOrderService
}
+ //public async Task> GetDetailsAsync(string no)
+ //{
+ // return await _dbContext.Queryable()
+ // .LeftJoin((x, d) => x.DishesCode == d.CustomCode)
+ // .Where(x => x.OrderNo == no)
+ // .Select((x, d) => new OrderDetailResponse
+ // {
+ // DishesCode = x.DishesCode,
+ // Price = x.Price,
+ // Name = d.Name,
+ // Number = x.Number,
+ // Unit = x.Unit,
+ // ImageUrl = d.ImageUrl,
+ // })
+ // .ToListAsync();
+ //}
+
+
public async Task DeviceConsume(OrderAddRequest request)
{
return await AddAsync(request);
@@ -443,6 +462,53 @@ public class OrderService : IOrderService
}
+ public async Task> GetOrdersAggregationAsync(PageDto page)
+ {
+ var subjectId = _currentUser.GetIntSubjectId();
+ var gainfo = await _dbContext.Queryable().Where(x => x.IdentityUserId == subjectId).FirstAsync();
+ var jinkoCode = _currentUser.GetUserClaim("jinko-code") ?? string.Empty;
+ if (jinkoCode.IsPresent())
+ {
+ gainfo = await _dbContext.Queryable().Where(x => x.Code == jinkoCode).FirstAsync();
+ }
+
+ var pageResult = await _dbContext.Queryable().Where(x => x.UserNo == gainfo.No)
+ .LeftJoin((x, bplace) => x.BusinessPlaceCode == bplace.Code)
+ .Where(x => x.ApplicationType == CanteenApplicaitonTypeEnumType.Booking)
+ .Select((x, bplace) => new OrderAggregationResponse
+ {
+ No = x.No,
+ BusinessPlaceName = bplace.Name,
+ })
+ .ToPageListAsync(page);
+
+ //.LeftJoin((x, bplace, detail) => x.No == detail.OrderNo)
+
+ var nos = pageResult.Data.Select(x => x.No).ToList();
+ var dtos = await _dbContext.Queryable()
+ .LeftJoin((x, d) => x.DishesCode == d.CustomCode)
+ .Where(x => nos.Contains(x.OrderNo))
+ .Select((x, d) => new DishesDto
+ {
+ No = x.OrderNo,
+ DishesCode = x.DishesCode,
+ Name = d.Name,
+ ImageUrl = d.ImageUrl,
+ Number = x.Number,
+ Price = x.Price
+ })
+ .ToListAsync();
+
+
+ pageResult.Data.ForEach(item =>
+ {
+ item.Dishes = dtos.Where(x => x.No == item.No).ToList();
+ });
+
+ return pageResult;
+ }
+
+
//******************************************************* help methods ************************************************************/
diff --git a/Src/Dlhis.Canteen/appsettings.Development.json b/Src/Dlhis.Canteen/appsettings.Development.json
index 74bdd380..f67d9370 100644
--- a/Src/Dlhis.Canteen/appsettings.Development.json
+++ b/Src/Dlhis.Canteen/appsettings.Development.json
@@ -15,7 +15,7 @@
"SlaveConnectionString": [],
"Timeout": 30,
"SlowSqlTime": 1,
- "EnableSqlLog": false
+ "EnableSqlLog": true
},
"SwaggerOptions": {
"Enable": true,
diff --git a/Src/Dlhis.Entity/Basic/Entity/BusinessPlaceShiftRelationshipEntity.cs b/Src/Dlhis.Entity/Basic/Entity/BusinessPlaceShiftRelationshipEntity.cs
index b4419ca8..e96e4a78 100644
--- a/Src/Dlhis.Entity/Basic/Entity/BusinessPlaceShiftRelationshipEntity.cs
+++ b/Src/Dlhis.Entity/Basic/Entity/BusinessPlaceShiftRelationshipEntity.cs
@@ -4,14 +4,14 @@ using SqlSugar;
namespace Dlhis.Entity.Basic.Entity;
-[SugarTable(TableName = "BusinessPlaceShiftRelationship", TableDescription = "营业点餐次关系")]
+[SugarTable(TableName = "BusinessPlaceShiftRelationship", TableDescription = "营业点餐别关系")]
public class BusinessPlaceShiftRelationshipEntity : SugarBaseEntity, ITenantId
{
[SugarColumn(ColumnDescription = "营业点code")]
public Guid PlaceCode { get; set; }
- [SugarColumn(ColumnDescription = "餐次code")]
+ [SugarColumn(ColumnDescription = "餐别code")]
public Guid ShiftCode { get; set; }
public string TenantId { get; set; }