add 消费处理完成
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Dlhis.Canteen.Order.Dto;
|
||||
using Dlhis.Canteen.Order.Repository;
|
||||
using Dlhis.Canteen.Setting.Services;
|
||||
using Dlhis.Entity.Basic.Entity;
|
||||
using Dlhis.Entity.Canteen.Entities;
|
||||
@@ -11,6 +12,7 @@ using SqlSugar;
|
||||
using Dlhis.Canteen.Order.Response;
|
||||
using Dlhis.Canteen.Order.Request;
|
||||
using Dlhis.Entity.Device;
|
||||
using Dlhis.Entity.Device.Enums;
|
||||
using Kurisu.AspNetCore.Authentication.Abstractions;
|
||||
using Kurisu.AspNetCore.CustomClass;
|
||||
using Kurisu.AspNetCore.DataAccess.Dto;
|
||||
@@ -20,23 +22,34 @@ using Kurisu.AspNetCore.UnifyResultAndValidation;
|
||||
|
||||
namespace Dlhis.Canteen.Order.Services.Implements;
|
||||
|
||||
public class OrderService : BaseOrderService, IOrderService
|
||||
public class OrderService : IOrderService
|
||||
{
|
||||
private readonly ICanteenSettingService _canteenSettingService;
|
||||
private readonly IServiceProvider _serviceProvider;
|
||||
private readonly IDbContext _dbContext;
|
||||
private readonly ICurrentUser _currentUser;
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
private readonly IBalanceRepository _balanceRepository;
|
||||
private readonly IOrderRepository _orderRepository;
|
||||
private readonly RedisCache _redisCache;
|
||||
private readonly ILogger<OrderService> _logger;
|
||||
|
||||
public OrderService(ICanteenSettingService canteenSettingService,
|
||||
IDbContext dbContext,
|
||||
ICurrentUser currentUser,
|
||||
IServiceProvider serviceProvider,
|
||||
IHttpContextAccessor httpContextAccessor,
|
||||
IBalanceRepository balanceRepository,
|
||||
IOrderRepository orderRepository,
|
||||
RedisCache redisCache,
|
||||
ILogger<OrderService> logger)
|
||||
: base(canteenSettingService, dbContext, currentUser, logger)
|
||||
{
|
||||
_canteenSettingService = canteenSettingService;
|
||||
_serviceProvider = serviceProvider;
|
||||
_dbContext = dbContext;
|
||||
_currentUser = currentUser;
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
_balanceRepository = balanceRepository;
|
||||
_orderRepository = orderRepository;
|
||||
_redisCache = redisCache;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -56,28 +69,12 @@ public class OrderService : BaseOrderService, IOrderService
|
||||
/// <returns></returns>
|
||||
public async Task<OrderResultResponseWithLogs> AddAsync(OrderAddRequest request)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (_httpContextAccessor.HttpContext!.Request.Headers.TryGetValue("X-Requested-DeviceIp", out var ip))
|
||||
{
|
||||
var device = await DbContext.Queryable<DeviceEntity>().Where(x => x.UniqueNo == request.DeviceUniqueNo).SingleAsync();
|
||||
device.ConnectionInfo = new
|
||||
{
|
||||
ip = ip.ToString()
|
||||
}.ToJson();
|
||||
await SetDeviceIpInfoAsync(request.DeviceUniqueNo);
|
||||
|
||||
await DbContext.UpdateAsync(device);
|
||||
}
|
||||
|
||||
Logger.LogInformation("设备IP获取:{deviceNo} {ip}", request.DeviceUniqueNo, ip);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//ignore
|
||||
}
|
||||
await using var handler = await _redisCache.LockAsync($"consume:device:{request.UserUniqueNo}");
|
||||
handler.Acquired.ThrowIfFalse("请勿频繁消费");
|
||||
|
||||
var gainfo = await GetUserAsync(request);
|
||||
|
||||
return new OrderResultResponseWithLogs
|
||||
{
|
||||
Response = await ToDoAsync(request, gainfo)
|
||||
@@ -87,15 +84,15 @@ public class OrderService : BaseOrderService, IOrderService
|
||||
|
||||
public async Task<Pagination<OrderAggregationResponse>> GetOrdersAggregationAsync(PageDto page)
|
||||
{
|
||||
var subjectId = CurrentUser.GetIntSubjectId();
|
||||
var gainfo = await DbContext.Queryable<GainfoEntity>().Where(x => x.IdentityUserId == subjectId).FirstAsync();
|
||||
var jinkoCode = CurrentUser.GetUserClaim("jinko-code") ?? string.Empty;
|
||||
var subjectId = _currentUser.GetIntSubjectId();
|
||||
var gainfo = await _dbContext.Queryable<GainfoEntity>().Where(x => x.IdentityUserId == subjectId).FirstAsync();
|
||||
var jinkoCode = _currentUser.GetUserClaim("jinko-code") ?? string.Empty;
|
||||
if (jinkoCode.IsPresent())
|
||||
{
|
||||
gainfo = await DbContext.Queryable<GainfoEntity>().Where(x => x.Code == jinkoCode).FirstAsync();
|
||||
gainfo = await _dbContext.Queryable<GainfoEntity>().Where(x => x.Code == jinkoCode).FirstAsync();
|
||||
}
|
||||
|
||||
var pageResult = await DbContext.Queryable<CanteenOrderEntity>().Where(x => x.UserNo == gainfo.No)
|
||||
var pageResult = await _dbContext.Queryable<CanteenOrderEntity>().Where(x => x.UserNo == gainfo.No)
|
||||
.LeftJoin<BusinessPlaceEntity>((x, bPlace) => x.BusinessPlaceCode == bPlace.Code)
|
||||
.Where(x => x.ApplicationType == CanteenApplicationTypeEnumType.Booking)
|
||||
.OrderBy(x => x.CreateTime, OrderByType.Desc)
|
||||
@@ -110,7 +107,7 @@ public class OrderService : BaseOrderService, IOrderService
|
||||
.ToPageListAsync(page);
|
||||
|
||||
var nos = pageResult.Data.Select(x => x.No).ToList();
|
||||
var dtos = await DbContext.Queryable<CanteenOrderDetailEntity>()
|
||||
var dtos = await _dbContext.Queryable<CanteenOrderDetailEntity>()
|
||||
.LeftJoin<DishesEntity>((x, d) => x.DishesCode == d.CustomCode)
|
||||
.Where(x => nos.Contains(x.OrderNo))
|
||||
.Select((x, d) => new DishesDto
|
||||
@@ -152,10 +149,10 @@ public class OrderService : BaseOrderService, IOrderService
|
||||
else if (request.UserUniqueNo.StartsWith("02"))
|
||||
{
|
||||
request.Source = BalanceRecordSourceEnumType.EMealVoucher;
|
||||
var eMealVoucherQrCode = await DbContext.Queryable<EMealVoucherDetailQrCodeEntity>().Where(x => x.QrCode == request.UserUniqueNo).SingleAsync();
|
||||
var eMealVoucherQrCode = await _dbContext.Queryable<EMealVoucherDetailQrCodeEntity>().Where(x => x.QrCode == request.UserUniqueNo).SingleAsync();
|
||||
eMealVoucherQrCode.ThrowIfNull("无法识别");
|
||||
var code = eMealVoucherQrCode.OriginData.Split(':')[2];
|
||||
gainfo = await DbContext.Queryable<GainfoEntity>().Where(x => x.Code == code).SingleAsync();
|
||||
gainfo = await _dbContext.Queryable<GainfoEntity>().Where(x => x.Code == code).SingleAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -165,7 +162,7 @@ public class OrderService : BaseOrderService, IOrderService
|
||||
else
|
||||
{
|
||||
//根据档案号
|
||||
gainfo = await DbContext.Queryable<GainfoEntity>()
|
||||
gainfo = await _dbContext.Queryable<GainfoEntity>()
|
||||
.WhereIF(request.Source == BalanceRecordSourceEnumType.Card, x => x.CardNo == request.UserUniqueNo)
|
||||
.WhereIF(request.Source != BalanceRecordSourceEnumType.Card && !request.IsUserId, x => x.Code == request.UserUniqueNo)
|
||||
.WhereIF(request.Source != BalanceRecordSourceEnumType.Card && request.IsUserId && s, x => x.Id == userId)
|
||||
@@ -181,7 +178,7 @@ public class OrderService : BaseOrderService, IOrderService
|
||||
else
|
||||
{
|
||||
//兼容hpt尚未删除人员后产生的消费数据
|
||||
gainfo ??= await DbContext.Queryable<GainfoEntity>().AS("GainfoLeave")
|
||||
gainfo ??= await _dbContext.Queryable<GainfoEntity>().AS("GainfoLeave")
|
||||
.WhereIF(request.Source == BalanceRecordSourceEnumType.Card, x => x.CardNo == request.UserUniqueNo)
|
||||
.WhereIF(request.Source != BalanceRecordSourceEnumType.Card && !request.IsUserId, x => x.Code == request.UserUniqueNo)
|
||||
.WhereIF(request.Source != BalanceRecordSourceEnumType.Card && request.IsUserId && s, x => x.IdentityUserId == userId)
|
||||
@@ -192,33 +189,6 @@ public class OrderService : BaseOrderService, IOrderService
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取成本日期
|
||||
/// </summary>
|
||||
/// <param name="shift"></param>
|
||||
/// <param name="costDateTime"></param>
|
||||
/// <returns></returns>
|
||||
private async Task<DateTime> GetCostDateAsync(BusinessShiftMealRelationshipEntity shift, DateTime costDateTime)
|
||||
{
|
||||
var switchTime = await _canteenSettingService.GetSettingAsync<TimeOnly?>(CanteenSettingItemEnumType.BusinessSwitchTime, shift.TenantId, string.Empty);
|
||||
|
||||
var costDate = costDateTime.Date;
|
||||
|
||||
if (!switchTime.HasValue)
|
||||
{
|
||||
return costDate;
|
||||
}
|
||||
|
||||
var beginOfDay = costDateTime.Date;
|
||||
|
||||
var setTime = beginOfDay.Add(switchTime.Value.ToTimeSpan());
|
||||
if (costDateTime < setTime)
|
||||
costDate = costDateTime.Date.AddDays(-1);
|
||||
|
||||
return costDate;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 验证参数
|
||||
/// </summary>
|
||||
@@ -231,15 +201,10 @@ public class OrderService : BaseOrderService, IOrderService
|
||||
var endOfDay = beginOfDay.AddDays(1).AddSeconds(-1);
|
||||
|
||||
//今天所有消费记录
|
||||
var todayAllBalanceRecords = await DbContext.Queryable<BalanceRecordEntity>()
|
||||
.Where(x => x.UserNo == order.UserNo)
|
||||
.Where(x => x.Type == BalanceRecordTypeEnumType.Out)
|
||||
.Where(x => x.Status == BalanceRecordStatusEnumType.Valid)
|
||||
.Where(x => x.CreateTime >= beginOfDay && x.CreateTime <= endOfDay)
|
||||
.ToListAsync();
|
||||
var todayAllBalanceRecords = await _balanceRepository.GetBalanceRecordsAsync(order.UserCode, order.TenantId, beginOfDay, endOfDay);
|
||||
|
||||
//超市营业点
|
||||
var supermarketCodes = await DbContext.Queryable<BusinessPlaceEntity>()
|
||||
var supermarketCodes = await _dbContext.Queryable<BusinessPlaceEntity>()
|
||||
.Where(x => x.Catalog == CanteenBusinessPlaceCatalogEnumType.Supermarket)
|
||||
.Select(x => x.Code)
|
||||
.ToListAsync();
|
||||
@@ -286,40 +251,6 @@ public class OrderService : BaseOrderService, IOrderService
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 生成充值记录
|
||||
/// </summary>
|
||||
/// <param name="orderId"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="UserFriendlyException"></exception>
|
||||
/// <exception cref="VersionExceptions"></exception>
|
||||
private async Task GenerateConsumeRecordAsync(long orderId)
|
||||
{
|
||||
var order = await DbContext.Queryable<CanteenOrderEntity>().Where(x => x.Id == orderId).SingleAsync();
|
||||
//校验
|
||||
await Verify(order);
|
||||
|
||||
await CommonHelper.RetryAsync(async () =>
|
||||
{
|
||||
var gainfoMeal = await DbContext.Queryable<GainfoMealEntity>().Where(x => x.UserCode == order.UserCode).SingleAsync();
|
||||
//金额+-
|
||||
gainfoMeal.Balance += order.Amount;
|
||||
(gainfoMeal.Balance < 0).ThrowIfTrue("余额不足,无法消费");
|
||||
|
||||
await DbContext.Updateable<GainfoMealEntity>()
|
||||
.SetColumns(x => x.Balance == gainfoMeal.Balance)
|
||||
.SetColumns(x => x.Version == x.Version + 1)
|
||||
.SetColumns(x => x.ModifiedTime == DateTime.Now)
|
||||
.Where(x => x.UserCode == order.UserCode && x.Version == gainfoMeal.Version) //必须与查询时的version一致
|
||||
.ExecuteCommandThrowVersionAsync();
|
||||
|
||||
//写入记录
|
||||
var balanceRecord = order.Adapt<BalanceRecordEntity>();
|
||||
await DbContext.InsertAsync(balanceRecord);
|
||||
}, 5);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 离线消费处理
|
||||
/// </summary>
|
||||
@@ -327,36 +258,35 @@ public class OrderService : BaseOrderService, IOrderService
|
||||
/// <param name="gainfo"></param>
|
||||
private async Task HandleOfflineAsync(ConsumeRequest request, GainfoEntity gainfo)
|
||||
{
|
||||
var registry = await DbContext.Queryable<DeviceRegistryEntity>()
|
||||
.Where(x => x.DeviceUniqueNo == request.DeviceUniqueNo)
|
||||
.FirstAsync();
|
||||
|
||||
var businessPlaceInfo = await DbContext.Queryable<BusinessPlaceEntity>()
|
||||
.LeftJoin<BusinessPlaceShiftRelationshipEntity>((x, sr) => x.Code == sr.PlaceCode)
|
||||
.Where(x => x.Code == registry.BusinessPlaceCode)
|
||||
.Select((x, sr) => new
|
||||
var bindingInfo = await _dbContext.Queryable<DeviceRegistryEntity>()
|
||||
.LeftJoin<BusinessPlaceEntity>((x, b) => x.BusinessPlaceCode == b.Code)
|
||||
.LeftJoin<BusinessPlaceShiftRelationshipEntity>((x, b, bs) => bs.PlaceCode == b.Code)
|
||||
.Where(x => x.DeviceUniqueNo == request.DeviceUniqueNo && x.BusinessPlaceCode.HasValue)
|
||||
.Select((x, b, bs) => new
|
||||
{
|
||||
x.Code,
|
||||
sr.ShiftCode,
|
||||
x.TenantId
|
||||
b.Code, bs.ShiftCode, Factory = x.TenantId
|
||||
})
|
||||
.FirstAsync();
|
||||
.SingleAsync();
|
||||
|
||||
|
||||
//获取当前消费餐次
|
||||
var shifts = await DbContext.Queryable<BusinessShiftMealRelationshipEntity>().Where(x => x.ShiftCode == businessPlaceInfo.ShiftCode).ToListAsync();
|
||||
var shifts = await _dbContext.Queryable<BusinessShiftMealRelationshipEntity>()
|
||||
.Where(x => x.ShiftCode == bindingInfo.ShiftCode).ToListAsync();
|
||||
|
||||
var shift = shifts.FirstOrDefault(x => new TimePeriod()
|
||||
var shift = shifts.FirstOrDefault(x => new TimePeriod
|
||||
{
|
||||
Start = x.Start,
|
||||
End = x.End
|
||||
}.IsPresent(request.CostDateTime));
|
||||
|
||||
var costDate = await GetCostDateAsync(shift, request.CostDateTime);
|
||||
var costDate = await _canteenSettingService.GetCostDateAsync(bindingInfo.Factory, request.CostDateTime);
|
||||
|
||||
var order = new CanteenOrderEntity
|
||||
{
|
||||
RequestJson = request.ToJson(),
|
||||
No = SnowFlakeHelper.Instance.NextId().ToString(),
|
||||
ThirdNo = request.ThirdNo,
|
||||
IsOffline = request.IsOffline,
|
||||
Type = BalanceRecordTypeEnumType.Out,
|
||||
ApplicationType = CanteenApplicationTypeEnumType.Device,
|
||||
Name = gainfo.Name,
|
||||
@@ -364,7 +294,7 @@ public class OrderService : BaseOrderService, IOrderService
|
||||
UserNo = gainfo.No,
|
||||
UserCode = gainfo.Code,
|
||||
Amount = request.Amount,
|
||||
BusinessPlaceCode = businessPlaceInfo?.Code,
|
||||
BusinessPlaceCode = bindingInfo.Code,
|
||||
BusinessShiftCode = shift?.ShiftCode,
|
||||
ShiftType = shift?.ShiftType,
|
||||
CostDate = costDate.Date,
|
||||
@@ -372,9 +302,7 @@ public class OrderService : BaseOrderService, IOrderService
|
||||
DepartmentNo = gainfo.DepartmentNo,
|
||||
DeviceUniqueNo = request.DeviceUniqueNo,
|
||||
|
||||
No = SnowFlakeHelper.Instance.NextId().ToString(),
|
||||
IsOffline = request.IsOffline,
|
||||
IsCostCrossTenant = businessPlaceInfo!.TenantId != gainfo.Factory,
|
||||
IsCostCrossTenant = bindingInfo.Factory != gainfo.Factory,
|
||||
|
||||
OriginTenantId = gainfo.Factory,
|
||||
Werks = gainfo.Werks,
|
||||
@@ -386,48 +314,12 @@ public class OrderService : BaseOrderService, IOrderService
|
||||
CostDateTime = request.CostDateTime,
|
||||
|
||||
//标识当前消费的基地
|
||||
TenantId = businessPlaceInfo!.TenantId,
|
||||
TenantId = bindingInfo.Factory,
|
||||
};
|
||||
|
||||
|
||||
await DbContext.InsertReturnIdentityAsync(order);
|
||||
|
||||
await CommonHelper.RetryAsync(async () =>
|
||||
{
|
||||
var redisCache = _serviceProvider.GetService<RedisCache>();
|
||||
await using var handler = await redisCache.LockAsync($"gainfo:meal:{order.UserNo}", retryInterval: TimeSpan.FromSeconds(1));
|
||||
if (handler.Acquired)
|
||||
{
|
||||
var gainfoMeal = await DbContext.Queryable<GainfoMealEntity>().Where(x => x.UserCode == order.UserCode).FirstAsync();
|
||||
if (gainfoMeal == null)
|
||||
{
|
||||
gainfoMeal = new GainfoMealEntity
|
||||
{
|
||||
Balance = 0,
|
||||
BalanceOfRecharge = 0,
|
||||
BalanceOfSubsidies = 0,
|
||||
Version = 0,
|
||||
UserCode = order.UserCode,
|
||||
};
|
||||
|
||||
await DbContext.InsertAsync(gainfoMeal);
|
||||
}
|
||||
|
||||
//金额+-
|
||||
gainfoMeal.Balance += order.Amount;
|
||||
|
||||
await DbContext.Updateable<GainfoMealEntity>()
|
||||
.SetColumns(x => x.Balance == gainfoMeal.Balance)
|
||||
.SetColumns(x => x.Version == x.Version + 1)
|
||||
.SetColumns(x => x.ModifiedTime == DateTime.Now)
|
||||
.Where(x => x.UserCode == order.UserCode && x.Version == gainfoMeal.Version) //必须与查询时的version一致
|
||||
.ExecuteCommandThrowVersionAsync();
|
||||
|
||||
//写入记录
|
||||
var balanceRecord = order.Adapt<BalanceRecordEntity>();
|
||||
await DbContext.InsertAsync(balanceRecord);
|
||||
}
|
||||
}, 5);
|
||||
await _dbContext.InsertReturnIdentityAsync(order);
|
||||
var balanceRecord = order.Adapt<BalanceRecordEntity>();
|
||||
await _dbContext.InsertAsync(balanceRecord);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -439,79 +331,83 @@ public class OrderService : BaseOrderService, IOrderService
|
||||
private async Task ConsumeAsync(ConsumeRequest request, GainfoEntity gainfo)
|
||||
{
|
||||
var checkData = await PreCheckAsync(request.DeviceUniqueNo, request.CostDateTime);
|
||||
var order = await _orderRepository.CreateDeviceConsumeOrderAsync(checkData, request, gainfo);
|
||||
|
||||
//(request.Source == BalanceRecordSourceEnumType.QrCode && checkData.BusinessPlaceTenantId != gainfo.Factory).ThrowIfTrue("禁止跨厂区消费");
|
||||
|
||||
var order = new CanteenOrderEntity
|
||||
if (request.Image.IsPresent())
|
||||
{
|
||||
RequestJson = request.ToJson(),
|
||||
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.Shift.ShiftType,
|
||||
CostDate = checkData.CostDate,
|
||||
CostId = gainfo.CostId,
|
||||
DepartmentNo = gainfo.DepartmentNo,
|
||||
DeviceUniqueNo = request.DeviceUniqueNo,
|
||||
await _dbContext.InsertAsync(new ImageRecordEntity
|
||||
{
|
||||
No = order.No,
|
||||
TableName = "B",
|
||||
Image = request.Image
|
||||
});
|
||||
}
|
||||
|
||||
No = SnowFlakeHelper.Instance.NextId().ToString(),
|
||||
IsOffline = request.IsOffline,
|
||||
IsCostCrossTenant = gainfo.Factory != checkData.BusinessPlaceTenantId,
|
||||
await TryConsumeAsync(order.Id, async () =>
|
||||
{
|
||||
//校验
|
||||
await Verify(order);
|
||||
|
||||
OriginTenantId = gainfo.Factory,
|
||||
Werks = gainfo.Werks,
|
||||
Status = BalanceRecordStatusEnumType.Valid,
|
||||
await _balanceRepository.CheckConsumableAsync(order.UserCode, order.TenantId, order.Amount);
|
||||
|
||||
OrderStatus = CanteenOrderStatusEnumType.Wait,
|
||||
//写入记录
|
||||
var balanceRecord = order.Adapt<BalanceRecordEntity>();
|
||||
await _dbContext.InsertAsync(balanceRecord);
|
||||
});
|
||||
}
|
||||
|
||||
CostDateTime = request.CostDateTime,
|
||||
private async Task<DefaultApiResult<OrderResultResponse>> EMealVoucherConsumeAsync(OrderAddRequest request, GainfoEntity gainfo)
|
||||
{
|
||||
var msg = string.Empty;
|
||||
var originData = await _dbContext.Queryable<EMealVoucherDetailQrCodeEntity>()
|
||||
.Where(x => x.QrCode == request.UserUniqueNo)
|
||||
.Select(x => x.OriginData)
|
||||
.SingleAsync();
|
||||
|
||||
//标识当前消费的基地
|
||||
TenantId = checkData.BusinessPlaceTenantId
|
||||
};
|
||||
if (originData.IsEmpty())
|
||||
{
|
||||
msg = "无法识别";
|
||||
return new DefaultApiResult<OrderResultResponse>
|
||||
{
|
||||
Code = ApiStateCode.Error,
|
||||
Data = null,
|
||||
Msg = msg
|
||||
};
|
||||
}
|
||||
|
||||
var orderId = await DbContext.InsertReturnIdentityAsync(order);
|
||||
var originDataItems = originData.Split(":");
|
||||
var no = originDataItems[0];
|
||||
var idNo = originDataItems[3];
|
||||
|
||||
try
|
||||
{
|
||||
await GenerateConsumeRecordAsync(orderId);
|
||||
|
||||
if (request.Image.IsPresent())
|
||||
{
|
||||
await DbContext.InsertAsync(new ImageRecordEntity
|
||||
{
|
||||
No = order.No,
|
||||
TableName = "B",
|
||||
Image = request.Image
|
||||
});
|
||||
}
|
||||
|
||||
await DbContext.Updateable<CanteenOrderEntity>()
|
||||
.SetColumns(x => x.OrderStatus == CanteenOrderStatusEnumType.Success)
|
||||
.SetColumns(x => x.ModifiedTime == DateTime.Now)
|
||||
.Where(x => x.Id == orderId)
|
||||
.ExecuteCommandAsync();
|
||||
await EMealVoucherConsumeAsync(request.Adapt<ConsumeRequest>(), gainfo, originData, no, idNo);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await DbContext.Updateable<CanteenOrderEntity>()
|
||||
.SetColumns(x => x.OrderStatus == CanteenOrderStatusEnumType.Failure)
|
||||
.SetColumns(x => x.Result == ex.Message)
|
||||
.SetColumns(x => x.ModifiedTime == DateTime.Now)
|
||||
.Where(x => x.Id == orderId)
|
||||
.ExecuteCommandAsync();
|
||||
|
||||
throw;
|
||||
msg = ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
//获取餐券余额
|
||||
var data = await _dbContext.Queryable<EMealVoucherEntity>()
|
||||
.LeftJoin<EMealVoucherDetailEntity>((x, d) => x.No == d.No)
|
||||
.LeftJoin<GainfoEntity>((x, d, u) => u.IdNo == d.IdNo)
|
||||
.Where((x, d) => x.No == no && d.IdNo == idNo)
|
||||
.Select((x, d, u) => new OrderResultResponse
|
||||
{
|
||||
UserCode = u.Code,
|
||||
UserName = u.Name,
|
||||
CurrentBalance = d.Balance
|
||||
})
|
||||
.SingleAsync();
|
||||
|
||||
return new DefaultApiResult<OrderResultResponse>
|
||||
{
|
||||
Code = msg.IsPresent() ? ApiStateCode.Error : ApiStateCode.Success,
|
||||
Data = data,
|
||||
Msg = msg
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 分支处理在线/离线消费
|
||||
@@ -524,26 +420,35 @@ public class OrderService : BaseOrderService, IOrderService
|
||||
var message = string.Empty;
|
||||
|
||||
if (request.Source == BalanceRecordSourceEnumType.EMealVoucher)
|
||||
return await EMealVoucherConsumeAsync(request, gainfo);
|
||||
|
||||
if (request.IsOffline)
|
||||
{
|
||||
var eMealVoucherQrCode = await DbContext.Queryable<EMealVoucherDetailQrCodeEntity>().Where(x => x.QrCode == request.UserUniqueNo).SingleAsync();
|
||||
if (eMealVoucherQrCode == null)
|
||||
{
|
||||
message = "无法识别";
|
||||
return new DefaultApiResult<OrderResultResponse>
|
||||
{
|
||||
Code = ApiStateCode.Error,
|
||||
Data = null,
|
||||
Msg = message
|
||||
};
|
||||
}
|
||||
|
||||
var originData = eMealVoucherQrCode.OriginData.Split(':');
|
||||
var no = originData[0];
|
||||
var idNo = originData[3];
|
||||
|
||||
try
|
||||
{
|
||||
await EMealVoucherConsumeAsync(request.Adapt<ConsumeRequest>(), gainfo, eMealVoucherQrCode.OriginData, no, idNo);
|
||||
if (request.ThirdNo.IsPresent() && await ToCheckAbleOfflineConsumeAsync(request.ThirdNo))
|
||||
{
|
||||
await using var handler = await _redisCache.LockAsync($"consume:device-offline:{request.ThirdNo}");
|
||||
if (handler.Acquired)
|
||||
{
|
||||
await HandleOfflineAsync(request.Adapt<ConsumeRequest>(), gainfo);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
await HandleOfflineAsync(request.Adapt<ConsumeRequest>(), gainfo);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "离线入库错误: 订单号:{no} .{message}", request.ThirdNo, ex.Message);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
await ConsumeAsync(request.Adapt<ConsumeRequest>(), gainfo);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -590,92 +495,33 @@ public class OrderService : BaseOrderService, IOrderService
|
||||
Msg = message
|
||||
};
|
||||
}
|
||||
else
|
||||
|
||||
var currentFactory = await _dbContext.Queryable<DeviceEntity>().Where(x => x.UniqueNo == request.DeviceUniqueNo).Select(x => x.TenantId).SingleAsync();
|
||||
var balance = await _balanceRepository.GetBalanceAsync(gainfo.Code, currentFactory);
|
||||
|
||||
//获取人员余额
|
||||
var data = await _dbContext.Queryable<GainfoEntity>()
|
||||
.LeftJoin<DepartmentEntity>((x, department) => x.DepartmentNo == department.No)
|
||||
.Where(x => x.Code == gainfo.Code)
|
||||
.Select((x, department) => new OrderResultResponse
|
||||
{
|
||||
UserCode = x.Code,
|
||||
UserName = x.Name,
|
||||
DepartmentNo = x.DepartmentNo,
|
||||
DepartmentName = department.Name,
|
||||
CurrentBalance = balance
|
||||
})
|
||||
.SingleAsync();
|
||||
|
||||
return new DefaultApiResult<OrderResultResponse>
|
||||
{
|
||||
if (request.IsOffline)
|
||||
{
|
||||
if (request.ThirdNo.IsPresent())
|
||||
{
|
||||
var redisCache = _serviceProvider.GetService<RedisCache>();
|
||||
|
||||
await using var handler = await redisCache.LockAsync($"consume:device:{request.ThirdNo}");
|
||||
if (handler.Acquired && await ToCheckAbleOfflineConsumeAsync(request.ThirdNo))
|
||||
{
|
||||
try
|
||||
{
|
||||
await HandleOfflineAsync(request.Adapt<ConsumeRequest>(), gainfo);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogError(ex, "离线入库错误: 订单号:{no} .{message}", request.ThirdNo, ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
await HandleOfflineAsync(request.Adapt<ConsumeRequest>(), gainfo);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogError(ex, "离线入库错误: 订单号:{no} .{message}", request.ThirdNo, ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
(await DbContext.Queryable<GainfoMealEntity>().Where(x => x.UserCode == gainfo.Code).AnyAsync()).ThrowIfFalse("就餐余额不足");
|
||||
await ConsumeAsync(request.Adapt<ConsumeRequest>(), gainfo);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
message = ex.Message;
|
||||
}
|
||||
}
|
||||
|
||||
//获取人员余额
|
||||
var data = await DbContext.Queryable<GainfoMealEntity>()
|
||||
.LeftJoin<GainfoEntity>((x, ga) => x.UserCode == ga.Code)
|
||||
.LeftJoin<DepartmentEntity>((x, ga, department) => ga.DepartmentNo == department.No)
|
||||
.Where(x => x.UserCode == gainfo.Code)
|
||||
.Select((x, ga, department) => new OrderResultResponse
|
||||
{
|
||||
UserCode = ga.Code,
|
||||
UserName = ga.Name,
|
||||
DepartmentNo = ga.DepartmentNo,
|
||||
DepartmentName = department.Name,
|
||||
CurrentBalance = x.Balance
|
||||
})
|
||||
.SingleAsync();
|
||||
|
||||
return new DefaultApiResult<OrderResultResponse>
|
||||
{
|
||||
Code = message.IsPresent() ? ApiStateCode.Error : ApiStateCode.Success,
|
||||
Data = data,
|
||||
Msg = message
|
||||
};
|
||||
}
|
||||
|
||||
async Task<bool> ToCheckAbleOfflineConsumeAsync(string thirdNo)
|
||||
{
|
||||
var order = await DbContext.Queryable<CanteenOrderEntity>()
|
||||
.Where(x => x.ThirdNo == thirdNo)
|
||||
.OrderBy(x => x.CreateTime, OrderByType.Desc)
|
||||
.FirstAsync();
|
||||
|
||||
if (order == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//存在在线order数据,但是状态未成功
|
||||
return !order.IsOffline && order.OrderStatus != CanteenOrderStatusEnumType.Success;
|
||||
}
|
||||
Code = message.IsPresent() ? ApiStateCode.Error : ApiStateCode.Success,
|
||||
Data = data,
|
||||
Msg = message
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 根据二维码获取消费用户
|
||||
/// </summary>
|
||||
@@ -683,74 +529,57 @@ public class OrderService : BaseOrderService, IOrderService
|
||||
/// <returns></returns>
|
||||
private async Task<GainfoEntity> GetUserByQrCodeAsync(string qrCode)
|
||||
{
|
||||
var gainfoQrCode = await DbContext.Queryable<GainfoQrCodeEntity>().Where(x => x.QrCode == qrCode).SingleAsync();
|
||||
var gainfoQrCode = await _dbContext.Queryable<GainfoQrCodeEntity>().Where(x => x.QrCode == qrCode).SingleAsync();
|
||||
gainfoQrCode.ThrowIfNull("消费码已过期");
|
||||
(gainfoQrCode.ModifiedTime.AddMinutes(60) < DateTime.Now).ThrowIfTrue("消费码已过期");
|
||||
|
||||
return await DbContext.Queryable<GainfoEntity>().Where(x => x.Code == gainfoQrCode.UserCode).SingleAsync();
|
||||
return await _dbContext.Queryable<GainfoEntity>().Where(x => x.Code == gainfoQrCode.UserCode).SingleAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 电子餐券消费
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <param name="gainfo"></param>
|
||||
/// <param name="originData"></param>
|
||||
/// <param name="no"></param>
|
||||
/// <param name="idNo"></param>
|
||||
private async Task EMealVoucherConsumeAsync(ConsumeRequest request, GainfoEntity gainfo, string originData, string no, string idNo)
|
||||
{
|
||||
var now = DateTime.Now;
|
||||
var current = await DbContext.Queryable<EMealVoucherDetailEntity>()
|
||||
.Where(x => x.No == no && x.IdNo == idNo).SingleAsync();
|
||||
(now >= current.Start && now <= current.End).ThrowIfFalse("餐券已过期");
|
||||
var nowDate = DateTime.Now.Date;
|
||||
|
||||
var eMealVoucher = await DbContext.Queryable<EMealVoucherEntity>().Where(x => x.No == no).SingleAsync();
|
||||
var current = await _dbContext.Queryable<EMealVoucherDetailEntity>()
|
||||
.Where(x => x.No == no && x.IdNo == idNo)
|
||||
.Select(x => new { x.Start, x.End })
|
||||
.SingleAsync();
|
||||
|
||||
(nowDate >= current.Start && nowDate <= current.End).ThrowIfFalse("餐券已过期");
|
||||
|
||||
|
||||
var eMealVoucher = await _dbContext.Queryable<EMealVoucherEntity>().Where(x => x.No == no).SingleAsync();
|
||||
|
||||
var checkData = await PreCheckAsync(request.DeviceUniqueNo, request.CostDateTime);
|
||||
var isSupermarket = await DbContext.Queryable<BusinessPlaceEntity>().Where(x => x.Code == checkData.BusinessPlaceCode)
|
||||
var isSupermarket = await _dbContext.Queryable<BusinessPlaceEntity>().Where(x => x.Code == checkData.BusinessPlaceCode)
|
||||
.Select(x => x.Catalog == CanteenBusinessPlaceCatalogEnumType.Supermarket)
|
||||
.SingleAsync();
|
||||
|
||||
isSupermarket.ThrowIfTrue("禁止在超市消费");
|
||||
|
||||
eMealVoucher.Factories.Contains(checkData.BusinessPlaceTenantId).ThrowIfFalse("禁止在当前厂区消费");
|
||||
eMealVoucher.Factories.Contains(checkData.Factory).ThrowIfFalse("禁止在当前厂区消费");
|
||||
|
||||
var order = new CanteenOrderEntity
|
||||
{
|
||||
RequestJson = request.ToJson(),
|
||||
ThirdNo = request.ThirdNo,
|
||||
Type = BalanceRecordTypeEnumType.Out,
|
||||
ApplicationType = CanteenApplicationTypeEnumType.Device,
|
||||
Name = gainfo.Name,
|
||||
Source = request.Source,
|
||||
UserNo = originData, //记录为当前消费券
|
||||
UserCode = gainfo.Code,
|
||||
Amount = request.Amount,
|
||||
BusinessPlaceCode = checkData.BusinessPlaceCode,
|
||||
BusinessShiftCode = checkData.BusinessShiftCode,
|
||||
ShiftType = checkData.Shift.ShiftType,
|
||||
CostDate = checkData.CostDate,
|
||||
CostId = gainfo.CostId,
|
||||
DepartmentNo = gainfo.DepartmentNo,
|
||||
DeviceUniqueNo = request.DeviceUniqueNo,
|
||||
gainfo.No = originData;
|
||||
var order = await _orderRepository.CreateDeviceConsumeOrderAsync(checkData, request, gainfo);
|
||||
|
||||
No = SnowFlakeHelper.Instance.NextId().ToString(),
|
||||
IsOffline = false,
|
||||
IsCostCrossTenant = gainfo.Factory != checkData.BusinessPlaceTenantId,
|
||||
|
||||
OriginTenantId = gainfo.Factory,
|
||||
Werks = gainfo.Werks,
|
||||
Status = BalanceRecordStatusEnumType.Valid,
|
||||
OrderStatus = CanteenOrderStatusEnumType.Wait,
|
||||
CostDateTime = request.CostDateTime,
|
||||
//标识当前消费的基地
|
||||
TenantId = checkData.BusinessPlaceTenantId,
|
||||
};
|
||||
|
||||
var orderId = await DbContext.InsertReturnIdentityAsync(order);
|
||||
|
||||
try
|
||||
await TryConsumeAsync(order.Id, async () =>
|
||||
{
|
||||
await CommonHelper.RetryAsync(async () =>
|
||||
{
|
||||
var detail = await DbContext.Queryable<EMealVoucherDetailEntity>().Where(x => x.No == no && x.IdNo == idNo).SingleAsync();
|
||||
var detail = await _dbContext.Queryable<EMealVoucherDetailEntity>().Where(x => x.No == no && x.IdNo == idNo).SingleAsync();
|
||||
//金额+-
|
||||
detail.Balance += order.Amount;
|
||||
(detail.Balance < 0).ThrowIfTrue("余额不足,无法消费");
|
||||
|
||||
await DbContext.Updateable<EMealVoucherDetailEntity>()
|
||||
await _dbContext.Updateable<EMealVoucherDetailEntity>()
|
||||
.SetColumns(x => x.Balance == detail.Balance)
|
||||
.SetColumns(x => x.Version == x.Version + 1)
|
||||
.SetColumns(x => x.ModifiedTime == DateTime.Now)
|
||||
@@ -759,26 +588,9 @@ public class OrderService : BaseOrderService, IOrderService
|
||||
|
||||
//写入记录
|
||||
var balanceRecord = order.Adapt<BalanceRecordEntity>();
|
||||
await DbContext.InsertAsync(balanceRecord);
|
||||
await _dbContext.InsertAsync(balanceRecord);
|
||||
}, 5);
|
||||
|
||||
await DbContext.Updateable<CanteenOrderEntity>()
|
||||
.SetColumns(x => x.OrderStatus == CanteenOrderStatusEnumType.Success)
|
||||
.SetColumns(x => x.ModifiedTime == DateTime.Now)
|
||||
.Where(x => x.Id == orderId)
|
||||
.ExecuteCommandAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await DbContext.Updateable<CanteenOrderEntity>()
|
||||
.SetColumns(x => x.OrderStatus == CanteenOrderStatusEnumType.Failure)
|
||||
.SetColumns(x => x.Result == ex.Message)
|
||||
.SetColumns(x => x.ModifiedTime == DateTime.Now)
|
||||
.Where(x => x.Id == orderId)
|
||||
.ExecuteCommandAsync();
|
||||
|
||||
throw;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -789,28 +601,28 @@ public class OrderService : BaseOrderService, IOrderService
|
||||
/// <returns></returns>
|
||||
private async Task<OrderPreCheckDto> PreCheckAsync(string deviceUniqueNo, DateTime costDateTime)
|
||||
{
|
||||
var registry = await DbContext.Queryable<DeviceRegistryEntity>().Where(x => x.DeviceUniqueNo == deviceUniqueNo).SingleAsync();
|
||||
registry.ThrowIfNull("设备尚未登记");
|
||||
|
||||
var device = await DbContext.Queryable<DeviceEntity>().Where(x => x.UniqueNo == deviceUniqueNo).SingleAsync();
|
||||
var device = await _dbContext.Queryable<DeviceEntity>().Where(x => x.UniqueNo == deviceUniqueNo).SingleAsync();
|
||||
device.ThrowIfNull("设备尚未登记");
|
||||
device.Enable.ThrowIfFalse("设备已被停用");
|
||||
(device.Type != DeviceTypeEnumType.Meal).ThrowIfTrue("设备类型有误");
|
||||
|
||||
var businessPlaceInfo = await DbContext.Queryable<BusinessPlaceEntity>()
|
||||
.LeftJoin<BusinessPlaceShiftRelationshipEntity>((x, sr) => x.Code == sr.PlaceCode)
|
||||
.Where(x => x.Code == registry.BusinessPlaceCode)
|
||||
.Select((x, sr) => new
|
||||
var bindingInfo = await _dbContext.Queryable<DeviceRegistryEntity>()
|
||||
.LeftJoin<BusinessPlaceEntity>((x, b) => x.BusinessPlaceCode == b.Code)
|
||||
.LeftJoin<BusinessPlaceShiftRelationshipEntity>((x, b, bs) => bs.PlaceCode == b.Code)
|
||||
.Where(x => x.DeviceUniqueNo == deviceUniqueNo && x.BusinessPlaceCode.HasValue)
|
||||
.Select((x, b, bs) => new
|
||||
{
|
||||
x.Code,
|
||||
sr.ShiftCode,
|
||||
x.TenantId
|
||||
b.Code, bs.ShiftCode, Factory = x.TenantId
|
||||
})
|
||||
.SingleAsync();
|
||||
|
||||
businessPlaceInfo.ThrowIfNull("设备尚未登记营业点");
|
||||
bindingInfo.ThrowIfNull("设备尚未登记营业点");
|
||||
|
||||
//获取当前消费餐次
|
||||
var shifts = await DbContext.Queryable<BusinessShiftMealRelationshipEntity>().Where(x => x.ShiftCode == businessPlaceInfo.ShiftCode).ToListAsync();
|
||||
var shifts = await _dbContext.Queryable<BusinessShiftMealRelationshipEntity>()
|
||||
.Where(x => x.ShiftCode == bindingInfo.ShiftCode)
|
||||
.Select(x => new { x.ShiftType, x.Start, x.End })
|
||||
.ToListAsync();
|
||||
shifts.ThrowIfEmpty("营业点餐次尚未设置");
|
||||
|
||||
var shift = shifts.FirstOrDefault(x => new TimePeriod
|
||||
@@ -818,17 +630,88 @@ public class OrderService : BaseOrderService, IOrderService
|
||||
Start = x.Start,
|
||||
End = x.End
|
||||
}.IsPresent(costDateTime));
|
||||
shift.ThrowIfNull("非就餐时间,无法消费");
|
||||
shift.ThrowIfNull("非就餐时间");
|
||||
|
||||
var costDate = await GetCostDateAsync(shift, costDateTime);
|
||||
var costDate = await _canteenSettingService.GetCostDateAsync(bindingInfo.Factory, costDateTime);
|
||||
|
||||
return new OrderPreCheckDto
|
||||
{
|
||||
Factory = bindingInfo.Factory,
|
||||
CostDate = costDate,
|
||||
Shift = shift,
|
||||
BusinessPlaceTenantId = businessPlaceInfo.TenantId,
|
||||
BusinessPlaceCode = businessPlaceInfo.Code,
|
||||
BusinessShiftCode = businessPlaceInfo.ShiftCode
|
||||
ShiftType = shift!.ShiftType,
|
||||
BusinessPlaceCode = bindingInfo.Code,
|
||||
BusinessShiftCode = bindingInfo.ShiftCode
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置设备ip
|
||||
/// </summary>
|
||||
/// <param name="deviceNo"></param>
|
||||
private async Task SetDeviceIpInfoAsync(string deviceNo)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (_httpContextAccessor.HttpContext!.Request.Headers.TryGetValue("X-Requested-DeviceIp", out var ip))
|
||||
{
|
||||
var device = await _dbContext.Queryable<DeviceEntity>().Where(x => x.UniqueNo == deviceNo).SingleAsync();
|
||||
device.ConnectionInfo = new
|
||||
{
|
||||
ip = ip.ToString()
|
||||
}.ToJson();
|
||||
|
||||
await _dbContext.UpdateAsync(device);
|
||||
}
|
||||
|
||||
_logger.LogInformation("设备ip获取:{deviceNo} {ip}", deviceNo, ip);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//ignore
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检查是否能够进行离线消费,处理hpt重复提交
|
||||
/// </summary>
|
||||
/// <param name="thirdNo"></param>
|
||||
/// <returns></returns>
|
||||
private async Task<bool> ToCheckAbleOfflineConsumeAsync(string thirdNo)
|
||||
{
|
||||
var order = await _dbContext.Queryable<CanteenOrderEntity>()
|
||||
.Where(x => x.ThirdNo == thirdNo)
|
||||
.OrderBy(x => x.CreateTime, OrderByType.Desc)
|
||||
.SingleAsync();
|
||||
|
||||
if (order == null)
|
||||
return true;
|
||||
|
||||
//存在在线order数据,但是状态未成功
|
||||
return !order.IsOffline && order.OrderStatus != CanteenOrderStatusEnumType.Success;
|
||||
}
|
||||
|
||||
private async Task TryConsumeAsync(long orderId, Func<Task> action)
|
||||
{
|
||||
try
|
||||
{
|
||||
await action();
|
||||
|
||||
await _dbContext.Updateable<CanteenOrderEntity>()
|
||||
.SetColumns(x => x.OrderStatus == CanteenOrderStatusEnumType.Success)
|
||||
.SetColumns(x => x.ModifiedTime == DateTime.Now)
|
||||
.Where(x => x.Id == orderId)
|
||||
.ExecuteCommandAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await _dbContext.Updateable<CanteenOrderEntity>()
|
||||
.SetColumns(x => x.OrderStatus == CanteenOrderStatusEnumType.Failure)
|
||||
.SetColumns(x => x.ModifiedTime == DateTime.Now)
|
||||
.SetColumns(x => x.Result == ex.Message)
|
||||
.Where(x => x.Id == orderId)
|
||||
.ExecuteCommandAsync();
|
||||
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user