diff --git a/Src/Dlhis.Canteen/MealSupplementRecord/Request/MealSupplementInitImportRequest.cs b/Src/Dlhis.Canteen/MealSupplementRecord/Request/MealSupplementInitImportRequest.cs
index 919fb03c..f0a3cad7 100644
--- a/Src/Dlhis.Canteen/MealSupplementRecord/Request/MealSupplementInitImportRequest.cs
+++ b/Src/Dlhis.Canteen/MealSupplementRecord/Request/MealSupplementInitImportRequest.cs
@@ -25,10 +25,5 @@ public class MealSupplementInitImportRequest : IValidatableObject
{
yield return new ValidationResult($"工号{Code}姓名不能为空", new[] { nameof(Name) });
}
-
- if (Balance <= 0)
- {
- yield return new ValidationResult($"工号{Code}余额有误", new[] { nameof(Balance) });
- }
}
}
\ No newline at end of file
diff --git a/Src/Dlhis.Canteen/Order/Request/BalanceRecordPageByDeviceUniqueNoRequest.cs b/Src/Dlhis.Canteen/Order/Request/BalanceRecordPageByDeviceUniqueNoRequest.cs
index 3983bb7b..3dae6579 100644
--- a/Src/Dlhis.Canteen/Order/Request/BalanceRecordPageByDeviceUniqueNoRequest.cs
+++ b/Src/Dlhis.Canteen/Order/Request/BalanceRecordPageByDeviceUniqueNoRequest.cs
@@ -25,4 +25,9 @@ public class BalanceRecordPageByDeviceUniqueNoRequest : PageDto
/// 查询时间段(结束)
///
public DateTime? End { get; set; }
+
+ ///
+ /// 工号
+ ///
+ public string UserCode { get; set; }
}
\ No newline at end of file
diff --git a/Src/Dlhis.Canteen/Order/Response/BalanceRecordDeviceResponse.cs b/Src/Dlhis.Canteen/Order/Response/BalanceRecordDeviceResponse.cs
index 9f8d423b..3e62b22c 100644
--- a/Src/Dlhis.Canteen/Order/Response/BalanceRecordDeviceResponse.cs
+++ b/Src/Dlhis.Canteen/Order/Response/BalanceRecordDeviceResponse.cs
@@ -101,4 +101,9 @@ public class BalanceRecordDeviceResponse
/// 厂区名称
///
public string TenantName { get; set; }
+
+ ///
+ /// image
+ ///
+ public string Image { get; set; }
}
diff --git a/Src/Dlhis.Canteen/Order/Services/Implements/BalanceService.cs b/Src/Dlhis.Canteen/Order/Services/Implements/BalanceService.cs
index e1ba18f4..51db85c6 100644
--- a/Src/Dlhis.Canteen/Order/Services/Implements/BalanceService.cs
+++ b/Src/Dlhis.Canteen/Order/Services/Implements/BalanceService.cs
@@ -5,6 +5,7 @@ using Dlhis.Canteen.Setting.Services;
using Dlhis.Entity.Basic.Entity;
using Dlhis.Entity.Canteen.Entities;
using Dlhis.Entity.Canteen.Enums;
+using Dlhis.Entity.Device;
using Dlhis.Entity.Device.Entities;
using Dlhis.Entity.Device.Enums;
using Dlhis.Sys.Api;
@@ -137,11 +138,13 @@ 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, imageRecord) => imageRecord.No == record.No)
+ .WhereIF(request.UserCode.IsPresent(), record => record.UserCode == request.UserCode)
.Where(record => record.CostDate >= request.Start && record.CostDate <= request.End)
.Where(record => record.DeviceUniqueNo == device.UniqueNo || record.DeviceUniqueNo == device.Code.ToString())
.Where(record => record.Type == BalanceRecordTypeEnumType.Out && record.Status == BalanceRecordStatusEnumType.Valid)
.OrderBy(record => record.CreateTime, OrderByType.Desc)
- .Select((record, ga, department, bPlace) => new BalanceRecordDeviceResponse
+ .Select((record, ga, department, bPlace, imageRecord) => new BalanceRecordDeviceResponse
{
Id = record.Id,
Amount = SqlFunc.Abs(record.Amount),
@@ -159,6 +162,7 @@ public class BalanceService : IBalanceService
ShiftType = record.ShiftType,
CostDateTime = record.CostDateTime,
TenantId = record.TenantId,
+ Image = imageRecord.Image
})
.ToPageListAsync(request);
@@ -225,6 +229,7 @@ public class BalanceService : IBalanceService
}
catch (Exception)
{
+ //ignore
}
@@ -631,7 +636,7 @@ public class BalanceService : IBalanceService
})
.ToListAsync();
- var OnlineDevices = deviceRegistries
+ var onlineDevices = deviceRegistries
.Where(x =>
{
if (x.HeartbeatInterval <= 0)
@@ -647,7 +652,7 @@ public class BalanceService : IBalanceService
})
.ToList();
var onlineUniqueNos = new List();
- OnlineDevices.ForEach(x => onlineUniqueNos.Add(x.UniqueNo));
+ onlineDevices.ForEach(x => onlineUniqueNos.Add(x.UniqueNo));
var offUniqueNos = deviceUniqueNos.Except(onlineUniqueNos).ToList();
var list = devices.Where(x => offUniqueNos.Contains(x.UniqueNo)).ToList();
diff --git a/Src/Dlhis.Canteen/Order/Services/Implements/OrderService.cs b/Src/Dlhis.Canteen/Order/Services/Implements/OrderService.cs
index 016a8c50..a02be9e0 100644
--- a/Src/Dlhis.Canteen/Order/Services/Implements/OrderService.cs
+++ b/Src/Dlhis.Canteen/Order/Services/Implements/OrderService.cs
@@ -1,5 +1,4 @@
-using System.Data;
-using Dlhis.Basic.Api;
+using Dlhis.Basic.Api;
using Dlhis.Canteen.Setting.Services;
using Dlhis.Entity.Basic.Entity;
using Dlhis.Entity.Canteen.Entities;
@@ -600,40 +599,40 @@ public class OrderService : BaseOrderService, IOrderService
var allowNoBalance = await GetSettingAsync(order.TenantId, CanteenSettingItemEnumType.AllowNoBalance);
- //降级到读已提交
- await DbContext.Client.Ado.BeginTranAsync(IsolationLevel.ReadCommitted);
- try
+ ////降级到读已提交
+ // await DbContext.Client.Ado.BeginTranAsync(IsolationLevel.ReadCommitted);
+ // try
+ // {
+ await CommonHelper.RetryAsync(async () =>
{
- await CommonHelper.RetryAsync(async () =>
+ if (!allowNoBalance)
{
- if (!allowNoBalance)
- {
- var gainfoMeal = await DbContext.Queryable().Where(x => x.UserNo == order.UserNo).SingleAsync();
- //金额+-
- gainfoMeal.Balance += order.Amount;
+ var gainfoMeal = await DbContext.Queryable().Where(x => x.UserNo == order.UserNo).SingleAsync();
+ //金额+-
+ gainfoMeal.Balance += order.Amount;
- (gainfoMeal.Balance < 0).ThrowIfTrue("余额不足,无法消费");
+ (gainfoMeal.Balance < 0).ThrowIfTrue("余额不足,无法消费");
- await DbContext.Updateable()
- .SetColumns(x => x.Balance == gainfoMeal.Balance)
- .SetColumns(x => x.Version == x.Version + 1)
- .SetColumns(x => x.ModifiedTime == DateTime.Now)
- .Where(x => x.UserNo == order.UserNo && x.Version == gainfoMeal.Version) //必须与查询时的version一致
- .ExecuteCommandThrowVersionAsync();
- }
+ await DbContext.Updateable()
+ .SetColumns(x => x.Balance == gainfoMeal.Balance)
+ .SetColumns(x => x.Version == x.Version + 1)
+ .SetColumns(x => x.ModifiedTime == DateTime.Now)
+ .Where(x => x.UserNo == order.UserNo && x.Version == gainfoMeal.Version) //必须与查询时的version一致
+ .ExecuteCommandThrowVersionAsync();
+ }
- //写入记录
- var balanceRecord = order.Adapt();
- await DbContext.InsertAsync(balanceRecord);
- }, 5);
+ //写入记录
+ var balanceRecord = order.Adapt();
+ await DbContext.InsertAsync(balanceRecord);
+ }, 5);
- await DbContext.Client.Ado.CommitTranAsync();
- }
- catch (Exception)
- {
- await DbContext.Client.Ado.RollbackTranAsync();
- throw;
- }
+ // await DbContext.Client.Ado.CommitTranAsync();
+ // }
+ // catch (Exception)
+ // {
+ // await DbContext.Client.Ado.RollbackTranAsync();
+ // throw;
+ // }
}
public async Task ReCalcOfflineAsync(ReCalcOfflineRequest request)