feat 电子餐券
This commit is contained in:
@@ -17,10 +17,12 @@ namespace Dlhis.Basic.Device.Services.Implements;
|
|||||||
public class DeviceConnectService : IDeviceConnectService
|
public class DeviceConnectService : IDeviceConnectService
|
||||||
{
|
{
|
||||||
private readonly IDbContext _dbContext;
|
private readonly IDbContext _dbContext;
|
||||||
|
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||||
|
|
||||||
public DeviceConnectService(IDbContext dbContext)
|
public DeviceConnectService(IDbContext dbContext, IHttpContextAccessor httpContextAccessor)
|
||||||
{
|
{
|
||||||
_dbContext = dbContext;
|
_dbContext = dbContext;
|
||||||
|
_httpContextAccessor = httpContextAccessor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -96,7 +96,6 @@ public class GainfoMealService : IGainfoMealService
|
|||||||
ShiftType = null,
|
ShiftType = null,
|
||||||
CostDate = now.Date,
|
CostDate = now.Date,
|
||||||
DeviceUniqueNo = null,
|
DeviceUniqueNo = null,
|
||||||
SubsidiesFromMonth = now.ToString("yyyyMM"),
|
|
||||||
IP = null,
|
IP = null,
|
||||||
CostId = gainfoLeave.CostId,
|
CostId = gainfoLeave.CostId,
|
||||||
OriginTenantId = gainfoLeave.Factory,
|
OriginTenantId = gainfoLeave.Factory,
|
||||||
@@ -141,7 +140,6 @@ public class GainfoMealService : IGainfoMealService
|
|||||||
ShiftType = null,
|
ShiftType = null,
|
||||||
CostDate = now.Date,
|
CostDate = now.Date,
|
||||||
DeviceUniqueNo = null,
|
DeviceUniqueNo = null,
|
||||||
SubsidiesFromMonth = now.ToString("yyyyMM"),
|
|
||||||
IP = null,
|
IP = null,
|
||||||
CostId = gainfo.CostId,
|
CostId = gainfo.CostId,
|
||||||
OriginTenantId = gainfo.Factory,
|
OriginTenantId = gainfo.Factory,
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ public class Startup : DefaultStartup
|
|||||||
public override void ConfigureServices(IServiceCollection services)
|
public override void ConfigureServices(IServiceCollection services)
|
||||||
{
|
{
|
||||||
base.ConfigureServices(services);
|
base.ConfigureServices(services);
|
||||||
|
services.AddHttpContextAccessor();
|
||||||
services.AddRedis();
|
services.AddRedis();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -28,10 +28,4 @@
|
|||||||
</Content>
|
</Content>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Folder Include="EMealVoucher\Request\" />
|
|
||||||
<Folder Include="EMealVoucher\Response\" />
|
|
||||||
<Folder Include="EMealVoucher\Services\Implements\" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -1,3 +1,7 @@
|
|||||||
|
using Dlhis.Canteen.EMealVoucher.Request;
|
||||||
|
using Dlhis.Canteen.EMealVoucher.Response;
|
||||||
|
using Dlhis.Canteen.EMealVoucher.Services;
|
||||||
|
using Kurisu.AspNetCore.DataAccess.Dto;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
@@ -8,4 +12,65 @@ namespace Dlhis.Canteen.EMealVoucher.Controllers;
|
|||||||
[ApiController]
|
[ApiController]
|
||||||
public class EMealVoucherController : ControllerBase
|
public class EMealVoucherController : ControllerBase
|
||||||
{
|
{
|
||||||
|
private readonly IEMealVoucherService _eMealVoucherService;
|
||||||
|
|
||||||
|
public EMealVoucherController(IEMealVoucherService eMealVoucherService)
|
||||||
|
{
|
||||||
|
_eMealVoucherService = eMealVoucherService;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取我的电子餐券申请
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="request"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("my")]
|
||||||
|
public async Task<Pagination<EMealVoucherPageResponse>> GetMyEMealVoucherPageAsync([FromQuery] EMealVoucherPageRequest request)
|
||||||
|
{
|
||||||
|
return await _eMealVoucherService.GetMyEMealVoucherPageAsync(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查看电子餐券
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="no"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("no")]
|
||||||
|
public async Task<List<EMealVoucherDetailResponse>> GetDetailsByNoAsync(string no)
|
||||||
|
{
|
||||||
|
return await _eMealVoucherService.GetDetailsByNoAsync(no);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取url签名
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="detailId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("signature")]
|
||||||
|
public async Task<string> GetQrCodeSignatureAsync(long detailId)
|
||||||
|
{
|
||||||
|
return await _eMealVoucherService.GetQrCodeSignatureAsync(detailId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 刷新url签名
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="detailId"></param>
|
||||||
|
[HttpPost("signature/refresh")]
|
||||||
|
public async Task RefreshSignatureAsync(long detailId)
|
||||||
|
{
|
||||||
|
await _eMealVoucherService.RefreshSignatureAsync(detailId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取二维码
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="signature"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[AllowAnonymous]
|
||||||
|
[HttpGet("qrcode")]
|
||||||
|
public async Task<string> GetQrCodeAsync(string signature)
|
||||||
|
{
|
||||||
|
return await _eMealVoucherService.GetQrCodeAsync(signature);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
using Kurisu.AspNetCore.DataAccess.Dto;
|
||||||
|
|
||||||
|
namespace Dlhis.Canteen.EMealVoucher.Request;
|
||||||
|
|
||||||
|
public class EMealVoucherPageRequest : PageDto
|
||||||
|
{
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
namespace Dlhis.Canteen.EMealVoucher.Response;
|
||||||
|
|
||||||
|
public class EMealVoucherDetailResponse
|
||||||
|
{
|
||||||
|
public long Id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 用餐人
|
||||||
|
/// </summary>
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 手机号
|
||||||
|
/// </summary>
|
||||||
|
public string Phone { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 就餐开始
|
||||||
|
/// </summary>
|
||||||
|
public DateTime Start { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 就餐结束
|
||||||
|
/// </summary>
|
||||||
|
public DateTime End { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 金额
|
||||||
|
/// </summary>
|
||||||
|
public decimal Balance { get; set; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
namespace Dlhis.Canteen.EMealVoucher.Response;
|
||||||
|
|
||||||
|
public class EMealVoucherPageResponse
|
||||||
|
{
|
||||||
|
public long Id { get; set; }
|
||||||
|
|
||||||
|
public string No { get; set; }
|
||||||
|
|
||||||
|
public string Title { get; set; }
|
||||||
|
|
||||||
|
public DateTime Date { get; set; }
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
using Dlhis.Canteen.EMealVoucher.Request;
|
||||||
|
using Dlhis.Canteen.EMealVoucher.Response;
|
||||||
|
using Kurisu.AspNetCore.DataAccess.Dto;
|
||||||
|
|
||||||
|
namespace Dlhis.Canteen.EMealVoucher.Services;
|
||||||
|
|
||||||
|
public interface IEMealVoucherService : IScopeDependency
|
||||||
|
{
|
||||||
|
Task<Pagination<EMealVoucherPageResponse>> GetMyEMealVoucherPageAsync(EMealVoucherPageRequest request);
|
||||||
|
|
||||||
|
Task<List<EMealVoucherDetailResponse>> GetDetailsByNoAsync(string no);
|
||||||
|
|
||||||
|
Task<string> GetQrCodeSignatureAsync(long detailId);
|
||||||
|
|
||||||
|
Task RefreshSignatureAsync(long detailId);
|
||||||
|
|
||||||
|
Task<string> GetQrCodeAsync(string signature);
|
||||||
|
}
|
||||||
@@ -0,0 +1,106 @@
|
|||||||
|
using System.Text;
|
||||||
|
using Dlhis.Canteen.EMealVoucher.Request;
|
||||||
|
using Dlhis.Canteen.EMealVoucher.Response;
|
||||||
|
using Dlhis.Entity.Canteen.Entities;
|
||||||
|
using Kurisu.AspNetCore.Authentication.Abstractions;
|
||||||
|
using Kurisu.AspNetCore.DataAccess.Dto;
|
||||||
|
using Kurisu.AspNetCore.DataAccess.SqlSugar.Extensions;
|
||||||
|
using Kurisu.AspNetCore.DataAccess.SqlSugar.Services;
|
||||||
|
using Kurisu.AspNetCore.Utils.Extensions;
|
||||||
|
using SqlSugar;
|
||||||
|
|
||||||
|
namespace Dlhis.Canteen.EMealVoucher.Services.Implements;
|
||||||
|
|
||||||
|
public class EMealVoucherService : IEMealVoucherService
|
||||||
|
{
|
||||||
|
private readonly IDbContext _dbContext;
|
||||||
|
private readonly ICurrentUser _currentUser;
|
||||||
|
|
||||||
|
public EMealVoucherService(IDbContext dbContext, ICurrentUser currentUser)
|
||||||
|
{
|
||||||
|
_dbContext = dbContext;
|
||||||
|
_currentUser = currentUser;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public async Task<Pagination<EMealVoucherPageResponse>> GetMyEMealVoucherPageAsync(EMealVoucherPageRequest request)
|
||||||
|
{
|
||||||
|
var code = _currentUser.GetUserClaim("jinko-code");
|
||||||
|
code = "0123456";
|
||||||
|
return await _dbContext.Queryable<EMealVoucherEntity>()
|
||||||
|
.Where(x => x.Code == code)
|
||||||
|
.OrderBy(x => x.Id, OrderByType.Desc)
|
||||||
|
.Select<EMealVoucherPageResponse>()
|
||||||
|
.ToPageListAsync(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public async Task<List<EMealVoucherDetailResponse>> GetDetailsByNoAsync(string no)
|
||||||
|
{
|
||||||
|
return await _dbContext.Queryable<EMealVoucherDetailEntity>()
|
||||||
|
.Where(x => x.No == no)
|
||||||
|
.Select<EMealVoucherDetailResponse>()
|
||||||
|
.ToListAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public async Task<string> GetQrCodeSignatureAsync(long detailId)
|
||||||
|
{
|
||||||
|
return await GenerateSignatureAsync(detailId, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task RefreshSignatureAsync(long detailId)
|
||||||
|
{
|
||||||
|
await GenerateSignatureAsync(detailId, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task<string> GenerateSignatureAsync(long detailId, bool isRefresh)
|
||||||
|
{
|
||||||
|
var eMealVoucherDetail = await _dbContext.Queryable<EMealVoucherDetailEntity>().Where(x => x.Id == detailId).SingleAsync();
|
||||||
|
eMealVoucherDetail.ThrowIfNull("数据不存在");
|
||||||
|
if (eMealVoucherDetail.Signature.IsPresent())
|
||||||
|
{
|
||||||
|
if (isRefresh)
|
||||||
|
{
|
||||||
|
await _dbContext.Deleteable<EMealVoucherDetailQrCodeEntity>().Where(x => x.Signature == eMealVoucherDetail.Signature).ExecuteCommandAsync();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return eMealVoucherDetail.Signature;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
eMealVoucherDetail.Signature = Guid.NewGuid().ToString().Replace("-", "") + DateTimeOffset.Now.ToUnixTimeMilliseconds();
|
||||||
|
await _dbContext.UpdateAsync(eMealVoucherDetail);
|
||||||
|
|
||||||
|
return eMealVoucherDetail.Signature;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public async Task<string> GetQrCodeAsync(string signature)
|
||||||
|
{
|
||||||
|
var eMealVoucherDetail = await _dbContext.Queryable<EMealVoucherDetailEntity>().Where(x => x.Signature == signature).SingleAsync();
|
||||||
|
eMealVoucherDetail.ThrowIfNull("无效地址");
|
||||||
|
var eMealVoucher = await _dbContext.Queryable<EMealVoucherEntity>().Where(x => x.No == eMealVoucherDetail.No).SingleAsync();
|
||||||
|
|
||||||
|
var ts = DateTimeOffset.Now.ToUnixTimeMilliseconds().ToString().Reverse().Join(string.Empty);
|
||||||
|
var originData = string.Concat(eMealVoucher.No, ":", ts, ":", eMealVoucher.Code, ":", eMealVoucherDetail.IdNo);
|
||||||
|
|
||||||
|
var qrCode = "02" + originData.ToArray().Select(x =>
|
||||||
|
{
|
||||||
|
var b = Encoding.ASCII.GetBytes(x.ToString());
|
||||||
|
int i = b[0];
|
||||||
|
return Convert.ToString(i);
|
||||||
|
}).Join(string.Empty);
|
||||||
|
|
||||||
|
|
||||||
|
await _dbContext.InsertAsync(new EMealVoucherDetailQrCodeEntity
|
||||||
|
{
|
||||||
|
Signature = signature,
|
||||||
|
OriginData = originData,
|
||||||
|
QrCode = qrCode
|
||||||
|
});
|
||||||
|
|
||||||
|
return qrCode;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -174,7 +174,6 @@ public class MealSupplementRecordService : IMealSupplementRecordService
|
|||||||
Source = BalanceRecordSourceEnumType.LocalTenantSubsidies,
|
Source = BalanceRecordSourceEnumType.LocalTenantSubsidies,
|
||||||
Remark = "期初导入",
|
Remark = "期初导入",
|
||||||
CostId = gainfo.CostId,
|
CostId = gainfo.CostId,
|
||||||
SubsidiesFromMonth = today.ToString("yyyyMM"),
|
|
||||||
OriginTenantId = gainfo.Factory,
|
OriginTenantId = gainfo.Factory,
|
||||||
Werks = gainfo.Werks,
|
Werks = gainfo.Werks,
|
||||||
Name = gainfo.Name,
|
Name = gainfo.Name,
|
||||||
|
|||||||
16
Src/Dlhis.Canteen/Order/Dto/OrderPreCheckDto.cs
Normal file
16
Src/Dlhis.Canteen/Order/Dto/OrderPreCheckDto.cs
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
using Dlhis.Entity.Basic.Entity;
|
||||||
|
|
||||||
|
namespace Dlhis.Canteen.Order.Dto
|
||||||
|
{
|
||||||
|
public class OrderPreCheckDto
|
||||||
|
{
|
||||||
|
public DateTime CostDate { get; set; }
|
||||||
|
public BusinessShiftMealRelationshipEntity Shift { get; set; }
|
||||||
|
|
||||||
|
public string BusinessPlaceTenantId { get; set; }
|
||||||
|
|
||||||
|
public Guid BusinessPlaceCode { get; set; }
|
||||||
|
|
||||||
|
public Guid BusinessShiftCode { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -482,7 +482,6 @@ public class BalanceService : IBalanceService
|
|||||||
ShiftType = null,
|
ShiftType = null,
|
||||||
CostDate = DateTime.Now.Date,
|
CostDate = DateTime.Now.Date,
|
||||||
DeviceUniqueNo = null,
|
DeviceUniqueNo = null,
|
||||||
SubsidiesFromMonth = DateTime.Now.ToString("yyyyMM"),
|
|
||||||
IP = null,
|
IP = null,
|
||||||
CostId = gainfo.CostId,
|
CostId = gainfo.CostId,
|
||||||
OriginTenantId = gainfo.Factory,
|
OriginTenantId = gainfo.Factory,
|
||||||
|
|||||||
@@ -71,7 +71,6 @@ public class BookingOrderService : BaseOrderService, IBookingOrderService
|
|||||||
DeliveryAddress = request.DeliveryAddress,
|
DeliveryAddress = request.DeliveryAddress,
|
||||||
|
|
||||||
No = SnowFlakeHelper.Instance.NextId().ToString(),
|
No = SnowFlakeHelper.Instance.NextId().ToString(),
|
||||||
SubsidiesFromMonth = now.ToString("yyyyMM"),
|
|
||||||
IsOffline = false,
|
IsOffline = false,
|
||||||
IsCostCrossTenant = await GetSettingAsync<bool>(gainfo.No, businessPlace.TenantId, CanteenSettingItemEnumType.AllowCrossTenant),
|
IsCostCrossTenant = await GetSettingAsync<bool>(gainfo.No, businessPlace.TenantId, CanteenSettingItemEnumType.AllowCrossTenant),
|
||||||
|
|
||||||
|
|||||||
@@ -75,7 +75,6 @@ public class HainingBalanceService : IHainingBalanceService
|
|||||||
Source = request.Source,
|
Source = request.Source,
|
||||||
Remark = request.Remark,
|
Remark = request.Remark,
|
||||||
CostId = gainfo.CostId,
|
CostId = gainfo.CostId,
|
||||||
SubsidiesFromMonth = request.CostDate.ToString("yyyyMM"),
|
|
||||||
TenantId = businessPlaceInfo?.TenantId ?? request.Factory,
|
TenantId = businessPlaceInfo?.TenantId ?? request.Factory,
|
||||||
OriginTenantId = gainfo.Factory,
|
OriginTenantId = gainfo.Factory,
|
||||||
Werks = gainfo.Werks,
|
Werks = gainfo.Werks,
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using Dlhis.Canteen.Order.Dto;
|
||||||
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;
|
||||||
@@ -161,7 +162,11 @@ public class OrderService : BaseOrderService, IOrderService
|
|||||||
}
|
}
|
||||||
else if (request.UserUniqueNo.StartsWith("02"))
|
else if (request.UserUniqueNo.StartsWith("02"))
|
||||||
{
|
{
|
||||||
request.Source = BalanceRecordSourceEnumType.EVoucher;
|
request.Source = BalanceRecordSourceEnumType.EMealVoucher;
|
||||||
|
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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -180,8 +185,7 @@ public class OrderService : BaseOrderService, IOrderService
|
|||||||
{
|
{
|
||||||
gainfo.ThrowIfNull("无法识别,无权消费");
|
gainfo.ThrowIfNull("无法识别,无权消费");
|
||||||
}
|
}
|
||||||
|
else
|
||||||
if (request.IsOffline)
|
|
||||||
{
|
{
|
||||||
//兼容hpt尚未删除人员后产生的消费数据
|
//兼容hpt尚未删除人员后产生的消费数据
|
||||||
gainfo ??= await DbContext.Queryable<GainfoEntity>().AS("GainfoLeave")
|
gainfo ??= await DbContext.Queryable<GainfoEntity>().AS("GainfoLeave")
|
||||||
@@ -305,7 +309,6 @@ public class OrderService : BaseOrderService, IOrderService
|
|||||||
_logs.Add("消费请求校验:" + _sw.ElapsedMilliseconds);
|
_logs.Add("消费请求校验:" + _sw.ElapsedMilliseconds);
|
||||||
_sw.Restart();
|
_sw.Restart();
|
||||||
|
|
||||||
|
|
||||||
await CommonHelper.RetryAsync(async () =>
|
await CommonHelper.RetryAsync(async () =>
|
||||||
{
|
{
|
||||||
var gainfoMeal = await DbContext.Queryable<GainfoMealEntity>().Where(x => x.UserNo == order.UserNo).SingleAsync();
|
var gainfoMeal = await DbContext.Queryable<GainfoMealEntity>().Where(x => x.UserNo == order.UserNo).SingleAsync();
|
||||||
@@ -329,42 +332,6 @@ public class OrderService : BaseOrderService, IOrderService
|
|||||||
_sw.Restart();
|
_sw.Restart();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 根据二维码获取消费用户
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="qrCode"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
private async Task<GainfoEntity> GetUserByQrCodeAsync(string qrCode)
|
|
||||||
{
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 检查是否可以离线消费
|
|
||||||
/// </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)
|
|
||||||
.FirstAsync();
|
|
||||||
|
|
||||||
if (order == null)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
//存在在线order数据,但是状态未成功
|
|
||||||
return !order.IsOffline && order.OrderStatus != CanteenOrderStatusEnumType.Success;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 离线消费处理
|
/// 离线消费处理
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -418,7 +385,6 @@ public class OrderService : BaseOrderService, IOrderService
|
|||||||
DeviceUniqueNo = request.DeviceUniqueNo,
|
DeviceUniqueNo = request.DeviceUniqueNo,
|
||||||
|
|
||||||
No = SnowFlakeHelper.Instance.NextId().ToString(),
|
No = SnowFlakeHelper.Instance.NextId().ToString(),
|
||||||
SubsidiesFromMonth = request.CostDateTime.ToString("yyyyMM"),
|
|
||||||
IsOffline = request.IsOffline,
|
IsOffline = request.IsOffline,
|
||||||
IsCostCrossTenant = businessPlaceInfo!.TenantId != gainfo.Factory,
|
IsCostCrossTenant = businessPlaceInfo!.TenantId != gainfo.Factory,
|
||||||
|
|
||||||
@@ -492,8 +458,6 @@ public class OrderService : BaseOrderService, IOrderService
|
|||||||
device.ThrowIfNull("设备尚未登记");
|
device.ThrowIfNull("设备尚未登记");
|
||||||
device.Enable.ThrowIfFalse("设备已被停用");
|
device.Enable.ThrowIfFalse("设备已被停用");
|
||||||
|
|
||||||
(request.Source == BalanceRecordSourceEnumType.QrCode && device.TenantId != gainfo.Factory).ThrowIfTrue("二维码在此设备禁止消费");
|
|
||||||
|
|
||||||
var businessPlaceInfo = await DbContext.Queryable<BusinessPlaceEntity>()
|
var businessPlaceInfo = await DbContext.Queryable<BusinessPlaceEntity>()
|
||||||
.LeftJoin<BusinessPlaceShiftRelationshipEntity>((x, sr) => x.Code == sr.PlaceCode)
|
.LeftJoin<BusinessPlaceShiftRelationshipEntity>((x, sr) => x.Code == sr.PlaceCode)
|
||||||
.Where(x => x.Code == registry.BusinessPlaceCode)
|
.Where(x => x.Code == registry.BusinessPlaceCode)
|
||||||
@@ -523,6 +487,8 @@ public class OrderService : BaseOrderService, IOrderService
|
|||||||
|
|
||||||
var costDate = await GetCostDateAsync(shift, request.CostDateTime);
|
var costDate = await GetCostDateAsync(shift, request.CostDateTime);
|
||||||
|
|
||||||
|
(request.Source == BalanceRecordSourceEnumType.QrCode && businessPlaceInfo.TenantId != gainfo.Factory).ThrowIfTrue("禁止跨厂区消费");
|
||||||
|
|
||||||
var order = new CanteenOrderEntity
|
var order = new CanteenOrderEntity
|
||||||
{
|
{
|
||||||
RequestJson = request.ToJson(),
|
RequestJson = request.ToJson(),
|
||||||
@@ -543,9 +509,8 @@ public class OrderService : BaseOrderService, IOrderService
|
|||||||
DeviceUniqueNo = request.DeviceUniqueNo,
|
DeviceUniqueNo = request.DeviceUniqueNo,
|
||||||
|
|
||||||
No = SnowFlakeHelper.Instance.NextId().ToString(),
|
No = SnowFlakeHelper.Instance.NextId().ToString(),
|
||||||
SubsidiesFromMonth = request.CostDateTime.ToString("yyyyMM"),
|
|
||||||
IsOffline = request.IsOffline,
|
IsOffline = request.IsOffline,
|
||||||
IsCostCrossTenant = await GetSettingAsync<bool>(gainfo.No, businessPlaceInfo!.TenantId, CanteenSettingItemEnumType.AllowCrossTenant),
|
IsCostCrossTenant = gainfo.Factory != businessPlaceInfo!.TenantId,
|
||||||
|
|
||||||
OriginTenantId = gainfo.Factory,
|
OriginTenantId = gainfo.Factory,
|
||||||
Werks = gainfo.Werks,
|
Werks = gainfo.Werks,
|
||||||
@@ -610,17 +575,29 @@ public class OrderService : BaseOrderService, IOrderService
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private async Task<string> ToDoAsync(OrderAddRequest request, GainfoEntity gainfo)
|
private async Task<string> ToDoAsync(OrderAddRequest request, GainfoEntity gainfo)
|
||||||
{
|
{
|
||||||
var message = "";
|
var message = string.Empty;
|
||||||
if (request.IsOffline)
|
|
||||||
{
|
|
||||||
if (request.ThirdNo.IsPresent())
|
|
||||||
{
|
|
||||||
var redisCache = _serviceProvider.GetService<RedisCache>();
|
|
||||||
|
|
||||||
await using var handler = await redisCache.LockAsync($"consume:device:{request.ThirdNo}");
|
if (request.Source == BalanceRecordSourceEnumType.EMealVoucher)
|
||||||
if (handler.Acquired)
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await EMealVoucherConsumeAsync(request.Adapt<ConsumeRequest>(), gainfo);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
message = ex.Message;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (request.IsOffline)
|
||||||
|
{
|
||||||
|
if (request.ThirdNo.IsPresent())
|
||||||
{
|
{
|
||||||
if (await ToCheckAbleOfflineConsumeAsync(request.ThirdNo))
|
var redisCache = _serviceProvider.GetService<RedisCache>();
|
||||||
|
|
||||||
|
await using var handler = await redisCache.LockAsync($"consume:device:{request.ThirdNo}");
|
||||||
|
if (handler.Acquired && await ToCheckAbleOfflineConsumeAsync(request.ThirdNo))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -632,32 +609,219 @@ public class OrderService : BaseOrderService, IOrderService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await HandleOfflineAsync(request.Adapt<ConsumeRequest>(), gainfo);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.LogError(ex, "离线入库错误: 订单号:{no} .{message}", request.ThirdNo, ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await HandleOfflineAsync(request.Adapt<ConsumeRequest>(), gainfo);
|
(await DbContext.Queryable<GainfoMealEntity>().Where(x => x.UserCode == gainfo.Code).AnyAsync()).ThrowIfFalse("就餐余额不足");
|
||||||
|
await ConsumeAsync(request.Adapt<ConsumeRequest>(), gainfo);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Logger.LogError(ex, "离线入库错误: 订单号:{no} .{message}", request.ThirdNo, ex.Message);
|
message = 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return message;
|
return 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 根据二维码获取消费用户
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="qrCode"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private async Task<GainfoEntity> GetUserByQrCodeAsync(string qrCode)
|
||||||
|
{
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private async Task EMealVoucherConsumeAsync(ConsumeRequest request, GainfoEntity gainfo)
|
||||||
|
{
|
||||||
|
var eMealVoucherQrCode = await DbContext.Queryable<EMealVoucherDetailQrCodeEntity>().Where(x => x.QrCode == request.UserUniqueNo).SingleAsync();
|
||||||
|
var originData = eMealVoucherQrCode.OriginData.Split(':');
|
||||||
|
|
||||||
|
var no = originData[0];
|
||||||
|
var idNo = originData[3];
|
||||||
|
var nowDate = DateTime.Now.Date;
|
||||||
|
var current = await DbContext.Queryable<EMealVoucherDetailEntity>()
|
||||||
|
.Where(x => x.No == no && x.IdNo == idNo).SingleAsync();
|
||||||
|
(nowDate >= current.Start && nowDate <= current.End).ThrowIfFalse("餐券已过期");
|
||||||
|
|
||||||
|
var time = DateTimeOffset.FromUnixTimeMilliseconds(Convert.ToInt64(originData[1].Reverse().Join(string.Empty))).ToLocalTime().DateTime;
|
||||||
|
(time.AddMinutes(60) >= DateTime.Now).ThrowIfFalse("二维码已过期");
|
||||||
|
|
||||||
|
var eMealVoucher = await DbContext.Queryable<EMealVoucherEntity>().Where(x => x.No == no).SingleAsync();
|
||||||
|
|
||||||
|
var checkData = await PreCheckAsync(request.DeviceUniqueNo, request.CostDateTime);
|
||||||
|
eMealVoucher.Factories.Contains(checkData.BusinessPlaceTenantId).ThrowIfFalse("禁止在当前厂区消费");
|
||||||
|
|
||||||
|
_logs.Add("检验设备和营业点参数:" + _sw.ElapsedMilliseconds);
|
||||||
|
_sw.Restart();
|
||||||
|
|
||||||
|
var order = new CanteenOrderEntity
|
||||||
|
{
|
||||||
|
RequestJson = request.ToJson(),
|
||||||
|
ThirdNo = request.ThirdNo,
|
||||||
|
Type = BalanceRecordTypeEnumType.Out,
|
||||||
|
ApplicationType = CanteenApplicationTypeEnumType.Device,
|
||||||
|
Name = gainfo.Name,
|
||||||
|
Source = request.Source,
|
||||||
|
UserNo = eMealVoucherQrCode.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,
|
||||||
|
|
||||||
|
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);
|
||||||
|
_logs.Add("临时order写入:" + _sw.ElapsedMilliseconds);
|
||||||
|
_sw.Restart();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await CommonHelper.RetryAsync(async () =>
|
||||||
|
{
|
||||||
|
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>()
|
||||||
|
.SetColumns(x => x.Balance == detail.Balance)
|
||||||
|
.SetColumns(x => x.Version == x.Version + 1)
|
||||||
|
.SetColumns(x => x.ModifiedTime == DateTime.Now)
|
||||||
|
.Where(x => x.No == no && x.IdNo == idNo && x.Version == detail.Version) //必须与查询时的version一致
|
||||||
|
.ExecuteCommandThrowVersionAsync();
|
||||||
|
|
||||||
|
//写入记录
|
||||||
|
var balanceRecord = order.Adapt<BalanceRecordEntity>();
|
||||||
|
await DbContext.InsertAsync(balanceRecord);
|
||||||
|
}, 5);
|
||||||
|
|
||||||
|
_logs.Add("消费写入:" + _sw.ElapsedMilliseconds);
|
||||||
|
_sw.Restart();
|
||||||
|
|
||||||
|
await DbContext.Updateable<CanteenOrderEntity>()
|
||||||
|
.SetColumns(x => x.OrderStatus == CanteenOrderStatusEnumType.Success)
|
||||||
|
.SetColumns(x => x.ModifiedTime == DateTime.Now)
|
||||||
|
.Where(x => x.Id == orderId)
|
||||||
|
.ExecuteCommandAsync();
|
||||||
|
|
||||||
|
_logs.Add("更新image和订单信息:" + _sw.ElapsedMilliseconds);
|
||||||
|
_sw.Restart();
|
||||||
|
}
|
||||||
|
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>
|
||||||
|
/// 消费前预检
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="deviceUniqueNo"></param>
|
||||||
|
/// <param name="costDateTime"></param>
|
||||||
|
/// <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();
|
||||||
|
device.ThrowIfNull("设备尚未登记");
|
||||||
|
device.Enable.ThrowIfFalse("设备已被停用");
|
||||||
|
|
||||||
|
var businessPlaceInfo = await DbContext.Queryable<BusinessPlaceEntity>()
|
||||||
|
.LeftJoin<BusinessPlaceShiftRelationshipEntity>((x, sr) => x.Code == sr.PlaceCode)
|
||||||
|
.Where(x => x.Code == registry.BusinessPlaceCode)
|
||||||
|
.Select((x, sr) => new
|
||||||
|
{
|
||||||
|
x.Code,
|
||||||
|
sr.ShiftCode,
|
||||||
|
x.TenantId
|
||||||
|
})
|
||||||
|
.SingleAsync();
|
||||||
|
|
||||||
|
businessPlaceInfo.ThrowIfNull("设备尚未登记营业点");
|
||||||
|
|
||||||
|
//获取当前消费餐次
|
||||||
|
var shifts = await DbContext.Queryable<BusinessShiftMealRelationshipEntity>().Where(x => x.ShiftCode == businessPlaceInfo.ShiftCode).ToListAsync();
|
||||||
|
shifts.ThrowIfEmpty("营业点餐次尚未设置");
|
||||||
|
|
||||||
|
var shift = shifts.FirstOrDefault(x => new TimePeriod
|
||||||
|
{
|
||||||
|
Start = x.Start,
|
||||||
|
End = x.End
|
||||||
|
}.IsPresent(costDateTime));
|
||||||
|
shift.ThrowIfNull("非就餐时间,无法消费");
|
||||||
|
|
||||||
|
var costDate = await GetCostDateAsync(shift, costDateTime);
|
||||||
|
|
||||||
|
return new OrderPreCheckDto
|
||||||
|
{
|
||||||
|
CostDate = costDate,
|
||||||
|
Shift = shift,
|
||||||
|
BusinessPlaceTenantId = businessPlaceInfo.TenantId,
|
||||||
|
BusinessPlaceCode = businessPlaceInfo.Code,
|
||||||
|
BusinessShiftCode = businessPlaceInfo.ShiftCode
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -91,12 +91,6 @@ public class BalanceRecordEntity : SugarBaseEntity, ISoftDeleted, ITenantId
|
|||||||
[SugarColumn(ColumnDescription = "消费机器唯一信息", IsNullable = true)]
|
[SugarColumn(ColumnDescription = "消费机器唯一信息", IsNullable = true)]
|
||||||
public string DeviceUniqueNo { get; set; }
|
public string DeviceUniqueNo { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 餐补月份
|
|
||||||
/// </summary>
|
|
||||||
[SugarColumn(ColumnDescription = "餐补月份")]
|
|
||||||
public string SubsidiesFromMonth { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Ip
|
/// Ip
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Kurisu.AspNetCore.DataAccess.SqlSugar;
|
using Kurisu.AspNetCore.DataAccess.Entity;
|
||||||
|
using Kurisu.AspNetCore.DataAccess.SqlSugar;
|
||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
|
|
||||||
namespace Dlhis.Entity.Canteen.Entities;
|
namespace Dlhis.Entity.Canteen.Entities;
|
||||||
@@ -7,7 +8,7 @@ namespace Dlhis.Entity.Canteen.Entities;
|
|||||||
/// 电子餐券明细
|
/// 电子餐券明细
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[SugarTable(TableName = "EMealVoucherDetail", TableDescription = "电子餐券明细")]
|
[SugarTable(TableName = "EMealVoucherDetail", TableDescription = "电子餐券明细")]
|
||||||
public class EMealVoucherDetailEntity : SugarBaseEntity
|
public class EMealVoucherDetailEntity : SugarBaseEntity, IVersion
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 主表id
|
/// 主表id
|
||||||
@@ -18,7 +19,7 @@ public class EMealVoucherDetailEntity : SugarBaseEntity
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 流水号
|
/// 流水号
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[SugarColumn(ColumnDescription = "流水号")]
|
[SugarColumn(ColumnDescription = "流水号", UniqueGroupNameList = new[] { "idx_EMealVoucherDetail_no_idno" })]
|
||||||
public string No { get; set; }
|
public string No { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -30,7 +31,7 @@ public class EMealVoucherDetailEntity : SugarBaseEntity
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 身份证
|
/// 身份证
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[SugarColumn(ColumnDescription = "序号")]
|
[SugarColumn(ColumnDescription = "证件号", UniqueGroupNameList = new[] { "idx_EMealVoucherDetail_no_idno" })]
|
||||||
public string IdNo { get; set; }
|
public string IdNo { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -60,6 +61,16 @@ public class EMealVoucherDetailEntity : SugarBaseEntity
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 金额
|
/// 金额
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[SugarColumn(ColumnDescription = "金额", ColumnDataType = "decimal(16,2)")]
|
[SugarColumn(ColumnDescription = "余额", ColumnDataType = "decimal(16,2)")]
|
||||||
public decimal Amount { get; set; }
|
public decimal Balance { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 版本
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(ColumnDescription = "版本")]
|
||||||
|
public int Version { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
[SugarColumn(ColumnDataType = "varchar(255)")]
|
||||||
|
public string Signature { get; set; }
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
using Kurisu.AspNetCore.DataAccess.SqlSugar;
|
||||||
|
using SqlSugar;
|
||||||
|
|
||||||
|
namespace Dlhis.Entity.Canteen.Entities;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 电子餐券明细QrCode
|
||||||
|
/// </summary>
|
||||||
|
[SugarTable(TableName = "EMealVoucherDetailQrCode", TableDescription = "电子餐券明细QrCode")]
|
||||||
|
public class EMealVoucherDetailQrCodeEntity : SugarBaseEntity
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// url签名
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(ColumnDataType = "varchar(255)", IndexGroupNameList = new[] { "idx_EMealVoucherDetailQrCode_signature" })]
|
||||||
|
public string Signature { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 原始数据
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(ColumnDescription = "原始数据")]
|
||||||
|
public string OriginData { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 二维码
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(ColumnDescription = "二维码", UniqueGroupNameList = new[] { "idx_EMealVoucherDetailQrCode_qrcode" })]
|
||||||
|
public string QrCode { get; set; }
|
||||||
|
}
|
||||||
@@ -36,7 +36,7 @@ public enum BalanceRecordSourceEnumType
|
|||||||
/// 电子餐券
|
/// 电子餐券
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Description("电子餐券")]
|
[Description("电子餐券")]
|
||||||
EVoucher,
|
EMealVoucher,
|
||||||
//*********************************************************************************************************
|
//*********************************************************************************************************
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -82,6 +82,11 @@ public class EMealVoucherReceiveRequest : IValidatableObject
|
|||||||
{
|
{
|
||||||
yield return new ValidationResult("来宾数量不匹配", new[] { nameof(Number) });
|
yield return new ValidationResult("来宾数量不匹配", new[] { nameof(Number) });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Details.DistinctBy(x => x.IdNo).Count() != Details.Count)
|
||||||
|
{
|
||||||
|
yield return new ValidationResult("证件信息重复", new[] { "IdNo" });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ public class EMealVoucherService : IEMealVoucherService
|
|||||||
Phone = x.Phone,
|
Phone = x.Phone,
|
||||||
Start = x.Start,
|
Start = x.Start,
|
||||||
End = x.End,
|
End = x.End,
|
||||||
Amount = x.Amount
|
Balance = x.Amount
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
|
||||||
var id = await _dbContext.InsertReturnIdentityAsync(voucher);
|
var id = await _dbContext.InsertReturnIdentityAsync(voucher);
|
||||||
|
|||||||
@@ -171,7 +171,6 @@ public class OrderService : IOrderService
|
|||||||
DeviceUniqueNo = request.DeviceUniqueNo,
|
DeviceUniqueNo = request.DeviceUniqueNo,
|
||||||
|
|
||||||
No = _factory + "-" + SnowFlakeHelper.Instance.NextId(),
|
No = _factory + "-" + SnowFlakeHelper.Instance.NextId(),
|
||||||
SubsidiesFromMonth = request.CostDateTime.ToString("yyyyMM"),
|
|
||||||
// IsOffline = request.IsOffline,
|
// IsOffline = request.IsOffline,
|
||||||
IsCostCrossTenant = await GetSettingAsync<bool>(businessPlaceInfo!.TenantId, CanteenSettingItemEnumType.AllowCrossTenant),
|
IsCostCrossTenant = await GetSettingAsync<bool>(businessPlaceInfo!.TenantId, CanteenSettingItemEnumType.AllowCrossTenant),
|
||||||
|
|
||||||
|
|||||||
@@ -156,7 +156,6 @@ public class MealSupplementHandlerJob : BaseJob
|
|||||||
Source = BalanceRecordSourceEnumType.LocalTenantSubsidies,
|
Source = BalanceRecordSourceEnumType.LocalTenantSubsidies,
|
||||||
Remark = mealSupplement.UniqueId + ":" + mealSupplement.Remark,
|
Remark = mealSupplement.UniqueId + ":" + mealSupplement.Remark,
|
||||||
CostId = gainfo.CostId,
|
CostId = gainfo.CostId,
|
||||||
SubsidiesFromMonth = mealSupplement.Date.ToString("yyyyMM"),
|
|
||||||
OriginTenantId = gainfo.Factory,
|
OriginTenantId = gainfo.Factory,
|
||||||
Werks = gainfo.Werks,
|
Werks = gainfo.Werks,
|
||||||
Name = gainfo.Name,
|
Name = gainfo.Name,
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
using Gateway;
|
using Gateway;
|
||||||
|
|
||||||
public class Program
|
public class Program
|
||||||
@@ -8,13 +7,14 @@ public class Program
|
|||||||
Host.CreateDefaultBuilder(args)
|
Host.CreateDefaultBuilder(args)
|
||||||
.ConfigureAppConfiguration((context, builder) =>
|
.ConfigureAppConfiguration((context, builder) =>
|
||||||
{
|
{
|
||||||
builder.AddJsonFile("ocelot.json", true, true);
|
if (context.HostingEnvironment.IsProduction())
|
||||||
|
{
|
||||||
|
builder.AddJsonFile("ocelot.json", true, true);
|
||||||
|
}
|
||||||
|
|
||||||
builder.AddJsonFile($"ocelot.{context.HostingEnvironment.EnvironmentName}.json", true, true);
|
builder.AddJsonFile($"ocelot.{context.HostingEnvironment.EnvironmentName}.json", true, true);
|
||||||
})
|
})
|
||||||
.ConfigureWebHostDefaults(webBuilder =>
|
.ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup<Startup>(); })
|
||||||
{
|
|
||||||
webBuilder.UseStartup<Startup>();
|
|
||||||
})
|
|
||||||
.Build().Run();
|
.Build().Run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -11,7 +11,6 @@
|
|||||||
"Common",
|
"Common",
|
||||||
"Canteen",
|
"Canteen",
|
||||||
"Scheduled",
|
"Scheduled",
|
||||||
"User",
|
|
||||||
"Sys",
|
"Sys",
|
||||||
"Visitor",
|
"Visitor",
|
||||||
"Message"
|
"Message"
|
||||||
|
|||||||
@@ -72,7 +72,7 @@
|
|||||||
"DownstreamScheme": "http",
|
"DownstreamScheme": "http",
|
||||||
"DownstreamHostAndPorts": [
|
"DownstreamHostAndPorts": [
|
||||||
{
|
{
|
||||||
"Host": "localhost",
|
"Host": "192.168.199.115",
|
||||||
"Port": 6000
|
"Port": 6000
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user