feat 设备操作相关image记录

This commit is contained in:
2024-06-24 17:45:23 +08:00
parent 9c705075bd
commit 0d08600ef4
4 changed files with 37 additions and 8 deletions

View File

@@ -1,8 +1,8 @@
using Dlhis.Entity.Canteen.Enums; using Dlhis.Entity.Canteen.Enums;
namespace Dlhis.Canteen.Dishes.Request; namespace Dlhis.Canteen.Order.Request;
public class ConsumeRequest public class ConsumeRequest
{ {
/// <summary> /// <summary>
/// 是否离线数据 /// 是否离线数据
@@ -38,4 +38,7 @@ public class ConsumeRequest
/// 产生时间 /// 产生时间
/// </summary> /// </summary>
public DateTime CostDateTime { get; set; } public DateTime CostDateTime { get; set; }
public string Image { get; set; }
} }

View File

@@ -45,6 +45,9 @@ public class OrderAddRequest : IValidatableObject
public DateTime? CostDateTime { get; set; } public DateTime? CostDateTime { get; set; }
public string Image { get; set; }
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext) public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{ {
//处理金额 //处理金额

View File

@@ -1,6 +1,5 @@
using System.Data; using System.Data;
using Dlhis.Basic.Api; using Dlhis.Basic.Api;
using Dlhis.Canteen.Dishes.Request;
using Dlhis.Canteen.Setting.Services; using Dlhis.Canteen.Setting.Services;
using Dlhis.Entity.Basic.Entity; using Dlhis.Entity.Basic.Entity;
using Dlhis.Entity.Canteen.Entities; using Dlhis.Entity.Canteen.Entities;
@@ -12,6 +11,7 @@ using Mapster;
using SqlSugar; using SqlSugar;
using Dlhis.Canteen.Order.Response; using Dlhis.Canteen.Order.Response;
using Dlhis.Canteen.Order.Request; using Dlhis.Canteen.Order.Request;
using Dlhis.Entity.Device;
using Kurisu.AspNetCore.Authentication.Abstractions; using Kurisu.AspNetCore.Authentication.Abstractions;
using Kurisu.AspNetCore.CustomClass; using Kurisu.AspNetCore.CustomClass;
using Kurisu.AspNetCore.DataAccess.Dto; using Kurisu.AspNetCore.DataAccess.Dto;
@@ -223,7 +223,7 @@ public class OrderService : BaseOrderService, IOrderService
}; };
var orderId = await DbContext.InsertReturnIdentityAsync(order); await DbContext.InsertReturnIdentityAsync(order);
var allowNoBalance = await GetSettingAsync<bool>(businessPlaceInfo.TenantId, CanteenSettingItemEnumType.AllowNoBalance); var allowNoBalance = await GetSettingAsync<bool>(businessPlaceInfo.TenantId, CanteenSettingItemEnumType.AllowNoBalance);
@@ -354,6 +354,15 @@ public class OrderService : BaseOrderService, IOrderService
try try
{ {
await GenerateConsumeRecordAsync(orderId); await GenerateConsumeRecordAsync(orderId);
if (request.Image.IsPresent())
{
await DbContext.InsertAsync(new ImageRecordEntity
{
No = order.No,
TableName = "B",
Image = request.Image
});
}
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -659,15 +668,15 @@ public class OrderService : BaseOrderService, IOrderService
{ {
await CommonHelper.RetryAsync(async () => await CommonHelper.RetryAsync(async () =>
{ {
var gainfoMeal = await DbContext.Queryable<GainfoMealEntity>().Where(x => x.UserNo == order.UserNo).FirstAsync(); var currentGainfoMeal = await DbContext.Queryable<GainfoMealEntity>().Where(x => x.UserNo == order.UserNo).FirstAsync();
//金额+- //金额+-
gainfoMeal.Balance += order.Amount; currentGainfoMeal.Balance += order.Amount;
await DbContext.Updateable<GainfoMealEntity>() await DbContext.Updateable<GainfoMealEntity>()
.SetColumns(x => x.Balance == gainfoMeal.Balance) .SetColumns(x => x.Balance == currentGainfoMeal.Balance)
.SetColumns(x => x.Version == x.Version + 1) .SetColumns(x => x.Version == x.Version + 1)
.SetColumns(x => x.ModifiedTime == DateTime.Now) .SetColumns(x => x.ModifiedTime == DateTime.Now)
.Where(x => x.UserNo == order.UserNo && x.Version == gainfoMeal.Version) //必须与查询时的version一致 .Where(x => x.UserNo == order.UserNo && x.Version == currentGainfoMeal.Version) //必须与查询时的version一致
.ExecuteCommandThrowVersionAsync(); .ExecuteCommandThrowVersionAsync();
//写入记录 //写入记录
var balanceRecord = order.Adapt<BalanceRecordEntity>(); var balanceRecord = order.Adapt<BalanceRecordEntity>();

View File

@@ -0,0 +1,14 @@
using Kurisu.AspNetCore.DataAccess.SqlSugar;
using SqlSugar;
namespace Dlhis.Entity.Device;
[SugarTable(TableName = "ImageRecords")]
public class ImageRecordEntity : SugarBaseEntity
{
public string No { get; set; }
public string TableName { get; set; }
public string Image { get; set; }
}