fix 减少冗余字段,兼容userId
This commit is contained in:
@@ -44,8 +44,6 @@ public class MealUserService : IMealUserService
|
|||||||
{
|
{
|
||||||
UserNo = request.UserNo,
|
UserNo = request.UserNo,
|
||||||
UserType = request.UserType,
|
UserType = request.UserType,
|
||||||
UserCode = gainfoEntity.Code,
|
|
||||||
CardNo = gainfoEntity.CardNo,
|
|
||||||
Balance = 0,
|
Balance = 0,
|
||||||
BalanceOfRecharge = 0,
|
BalanceOfRecharge = 0,
|
||||||
BalanceOfSubsidies = 0,
|
BalanceOfSubsidies = 0,
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ using Dlhis.Basic.Organization.Response;
|
|||||||
using Dlhis.Entity.Basic.Entity;
|
using Dlhis.Entity.Basic.Entity;
|
||||||
using Dlhis.Entity.Basic.Enums;
|
using Dlhis.Entity.Basic.Enums;
|
||||||
using Dlhis.Entity.Device.Enums;
|
using Dlhis.Entity.Device.Enums;
|
||||||
using Dm.filter.rw;
|
|
||||||
using Kurisu.AspNetCore.Scope;
|
using Kurisu.AspNetCore.Scope;
|
||||||
using Kurisu.AspNetCore.UnifyResultAndValidation;
|
using Kurisu.AspNetCore.UnifyResultAndValidation;
|
||||||
using Kurisu.AspNetCore.Utils.Extensions;
|
using Kurisu.AspNetCore.Utils.Extensions;
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
using Dlhis.Canteen.Order.Response;
|
using Dlhis.Canteen.Order.Response;
|
||||||
using Dlhis.Canteen.Order.Services;
|
using Dlhis.Canteen.Order.Services;
|
||||||
using Kurisu.Core.DataAccess.Dto;
|
using Kurisu.Core.DataAccess.Dto;
|
||||||
using Kurisu.RemoteCall.Attributes;
|
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ public class OrderAddRequest : IValidatableObject
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 档案号/QrCode/学工号
|
/// 档案号/QrCode/学工号
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Required(ErrorMessage = "人员档案号/QrCode/学工号不能为空")]
|
[Required(ErrorMessage = "人员档案号/QrCode/学工号不能为空/userId")]
|
||||||
public string UserUniqueNo { get; set; }
|
public string UserUniqueNo { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
using Dlhis.Canteen.Order.Request;
|
using Dlhis.Canteen.Order.Request;
|
||||||
using Dlhis.Canteen.Order.Response;
|
using Dlhis.Canteen.Order.Response;
|
||||||
using Kurisu.Core.DataAccess.Dto;
|
using Kurisu.Core.DataAccess.Dto;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
|
|
||||||
namespace Dlhis.Canteen.Order.Services;
|
namespace Dlhis.Canteen.Order.Services;
|
||||||
|
|
||||||
|
|||||||
@@ -10,11 +10,7 @@ using Kurisu.Core.User.Abstractions;
|
|||||||
using Kurisu.SqlSugar.Attributes;
|
using Kurisu.SqlSugar.Attributes;
|
||||||
using Kurisu.SqlSugar.Extensions;
|
using Kurisu.SqlSugar.Extensions;
|
||||||
using Kurisu.SqlSugar.Services;
|
using Kurisu.SqlSugar.Services;
|
||||||
using Mapster;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
using System.Linq;
|
|
||||||
using System.Numerics;
|
|
||||||
|
|
||||||
namespace Dlhis.Canteen.Order.Services.Implements;
|
namespace Dlhis.Canteen.Order.Services.Implements;
|
||||||
|
|
||||||
|
|||||||
@@ -45,17 +45,20 @@ public class OrderService : IOrderService
|
|||||||
[IgnoreTenant]
|
[IgnoreTenant]
|
||||||
public async Task<OrderResultResponse> AddAsync(OrderAddRequest request)
|
public async Task<OrderResultResponse> AddAsync(OrderAddRequest request)
|
||||||
{
|
{
|
||||||
//根据档案号
|
//尝试匹配userId
|
||||||
var canteenUserExists = await _dbContext.Queryable<CanteenUserEntity>()
|
_ = long.TryParse(request.UserUniqueNo, out var userId);
|
||||||
.Where(x => x.UserNo == request.UserUniqueNo || x.UserCode == request.UserUniqueNo)
|
|
||||||
.AnyAsync();
|
|
||||||
canteenUserExists.ThrowIfFalse($"就餐用户{request.UserUniqueNo}不存在,无法操作");
|
|
||||||
|
|
||||||
|
//根据档案号
|
||||||
var gainfo = await _dbContext.Queryable<GainfoEntity>()
|
var gainfo = await _dbContext.Queryable<GainfoEntity>()
|
||||||
.Where(x => x.No == request.UserUniqueNo || x.Code == request.UserUniqueNo)
|
.Where(x => x.No == request.UserUniqueNo || x.Code == request.UserUniqueNo || x.Id == userId)
|
||||||
.FirstAsync();
|
.FirstAsync();
|
||||||
gainfo.ThrowIfNull($"用户{request.UserUniqueNo}不存在,无法操作");
|
gainfo.ThrowIfNull($"用户{request.UserUniqueNo}不存在,无法操作");
|
||||||
|
|
||||||
|
var canteenUserExists = await _dbContext.Queryable<CanteenUserEntity>()
|
||||||
|
.Where(x => x.UserNo == gainfo.No)
|
||||||
|
.AnyAsync();
|
||||||
|
canteenUserExists.ThrowIfFalse($"就餐用户{request.UserUniqueNo}不存在,无法操作");
|
||||||
|
|
||||||
//消费
|
//消费
|
||||||
if (request.Type == BalanceRecordTypeEnumType.Out)
|
if (request.Type == BalanceRecordTypeEnumType.Out)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -15,45 +15,27 @@ public class CanteenUserEntity : SugarBaseEntity, IVersion, ITenantId
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 档案号
|
/// 档案号
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[SugarColumn(IsNullable = false, ColumnDescription = "档案号")]
|
[SugarColumn(IsNullable = false, ColumnDescription = "档案号", UniqueGroupNameList = new[] { "idx_CanteenUser_UserNo" })]
|
||||||
public string UserNo { get; set; }
|
public string UserNo { get; set; }
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 学工号
|
|
||||||
/// </summary>
|
|
||||||
[SugarColumn(IsNullable = false, ColumnDescription = "学工号")]
|
|
||||||
public string UserCode { get; set; }
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 消费人员类型
|
/// 消费人员类型
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[SugarColumn(ColumnDataType = "varchar(50)", SqlParameterDbType = typeof(EnumToStringConvert), ColumnDescription = "消费人员类型")]
|
[SugarColumn(ColumnDataType = "varchar(50)", SqlParameterDbType = typeof(EnumToStringConvert), ColumnDescription = "消费人员类型")]
|
||||||
public CanteenUserEnumType UserType { get; set; }
|
public CanteenUserEnumType UserType { get; set; }
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 卡号
|
|
||||||
/// </summary>
|
|
||||||
[SugarColumn(ColumnDescription = "卡号")]
|
|
||||||
public string CardNo { get; set; }
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 余额
|
/// 余额
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[SugarColumn(ColumnDescription = "余额")]
|
[SugarColumn(ColumnDescription = "余额")]
|
||||||
public decimal Balance { get; set; }
|
public decimal Balance { get; set; }
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 余额(充值)
|
/// 余额(充值)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[SugarColumn(ColumnDescription = "余额(充值)")]
|
[SugarColumn(ColumnDescription = "余额(充值)")]
|
||||||
public decimal BalanceOfRecharge { get; set; }
|
public decimal BalanceOfRecharge { get; set; }
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 余额(餐补)
|
/// 余额(餐补)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -67,5 +49,6 @@ public class CanteenUserEntity : SugarBaseEntity, IVersion, ITenantId
|
|||||||
public int Version { get; set; }
|
public int Version { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
[SugarColumn(IndexGroupNameList = new[] { "idx_CanteenUser_TenantId" })]
|
||||||
public string TenantId { get; set; }
|
public string TenantId { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ public class GainfoFaceEntity : SugarBaseEntity
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 学工号
|
/// 学工号
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[SugarColumn(IsNullable = false)]
|
[SugarColumn(IsNullable = false, UniqueGroupNameList = new[] { "idx_GainfoFace_UserCode" })]
|
||||||
public string UserCode { get; set; }
|
public string UserCode { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user