68 lines
2.2 KiB
C#
68 lines
2.2 KiB
C#
using Dlhis.Canteen.Order.Dto;
|
|
using Dlhis.Canteen.Order.Request;
|
|
using Dlhis.Entity.Basic.Entity;
|
|
using Dlhis.Entity.Canteen.Entities;
|
|
using Dlhis.Entity.Canteen.Enums;
|
|
using Kurisu.AspNetCore.DataAccess.SqlSugar.Services;
|
|
using Kurisu.AspNetCore.Utils;
|
|
using Kurisu.AspNetCore.Utils.Extensions;
|
|
|
|
namespace Dlhis.Canteen.Order.Repository.Implements;
|
|
|
|
public class OrderRepository : IOrderRepository
|
|
{
|
|
private readonly IDbContext _dbContext;
|
|
|
|
public OrderRepository(IDbContext dbContext)
|
|
{
|
|
_dbContext = dbContext;
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public async Task<CanteenOrderEntity> CreateDeviceConsumeOrderAsync(OrderCheckResultDto checkData, ConsumeRequest request, GainfoEntity gainfo)
|
|
{
|
|
var order = new CanteenOrderEntity
|
|
{
|
|
RequestJson = request.ToJson(),
|
|
IsOffline = request.IsOffline,
|
|
No = SnowFlakeHelper.Instance.NextId().ToString(),
|
|
ThirdNo = request.ThirdNo,
|
|
Type = BalanceRecordTypeEnumType.Out,
|
|
ApplicationType = CanteenApplicationTypeEnumType.Device,
|
|
Name = gainfo.Name,
|
|
Source = request.Source,
|
|
UserNo = gainfo.No,
|
|
UserCode = gainfo.Code,
|
|
Amount = request.Amount,
|
|
BusinessPlaceCode = checkData.BusinessPlaceCode,
|
|
BusinessShiftCode = checkData.BusinessShiftCode,
|
|
ShiftType = checkData.ShiftType,
|
|
CostDate = checkData.CostDate,
|
|
CostDateTime = request.CostDateTime,
|
|
CostId = gainfo.CostId,
|
|
DepartmentNo = gainfo.DepartmentNo,
|
|
DeviceUniqueNo = request.DeviceUniqueNo,
|
|
|
|
Remark = null,
|
|
DeliveryAddress = null,
|
|
Result = null,
|
|
IP = null,
|
|
|
|
IsCostCrossTenant = gainfo.Factory != checkData.Factory,
|
|
|
|
Werks = gainfo.Werks,
|
|
OriginTenantId = gainfo.Factory,
|
|
//标识当前消费的基地
|
|
TenantId = checkData.Factory,
|
|
|
|
Status = BalanceRecordStatusEnumType.Valid,
|
|
OrderStatus = CanteenOrderStatusEnumType.Wait,
|
|
|
|
IsDeleted = false,
|
|
};
|
|
|
|
var orderId = await _dbContext.InsertReturnIdentityAsync(order);
|
|
order.Id = orderId;
|
|
return order;
|
|
}
|
|
} |