feat tickets
This commit is contained in:
@@ -47,6 +47,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dlhis.Jip.Api", "Src\Dlhis.
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dlhis.Dh.Api", "Src\Dlhis.Dh.Api\Dlhis.Dh.Api.csproj", "{E673CA04-3567-4E03-9A86-994F50291ACC}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dlhis.Constants", "Src\Dlhis.Constants\Dlhis.Constants.csproj", "{F98329D8-F8CA-4794-B1BF-8659112119F7}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dlhis.Canteen.Api", "Src\Dlhis.Canteen.Api\Dlhis.Canteen.Api.csproj", "{7934BE46-9409-4D28-8B35-82A0F900DD01}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@@ -117,6 +121,14 @@ Global
|
||||
{E673CA04-3567-4E03-9A86-994F50291ACC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{E673CA04-3567-4E03-9A86-994F50291ACC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E673CA04-3567-4E03-9A86-994F50291ACC}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{F98329D8-F8CA-4794-B1BF-8659112119F7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{F98329D8-F8CA-4794-B1BF-8659112119F7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F98329D8-F8CA-4794-B1BF-8659112119F7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{F98329D8-F8CA-4794-B1BF-8659112119F7}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{7934BE46-9409-4D28-8B35-82A0F900DD01}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{7934BE46-9409-4D28-8B35-82A0F900DD01}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{7934BE46-9409-4D28-8B35-82A0F900DD01}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{7934BE46-9409-4D28-8B35-82A0F900DD01}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
@@ -134,6 +146,7 @@ Global
|
||||
{A501D16E-638F-4156-989C-2BACCC2FAC2B} = {4EBCE46B-CE3A-4A47-9432-82A1854CA58A}
|
||||
{841B7B43-5394-413F-9D68-A07EBDD6D4CD} = {4EBCE46B-CE3A-4A47-9432-82A1854CA58A}
|
||||
{E673CA04-3567-4E03-9A86-994F50291ACC} = {4EBCE46B-CE3A-4A47-9432-82A1854CA58A}
|
||||
{7934BE46-9409-4D28-8B35-82A0F900DD01} = {3D8A98C1-83C9-4375-AEAB-4F72AFAF365B}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {7439494A-E2FD-4FEA-8ABF-74AE57A4A5A0}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Dlhis.Basic.Dishes.Request;
|
||||
using Dlhis.Basic.Dishes.Response;
|
||||
using Dlhis.Basic.Places.Services;
|
||||
using Dlhis.Constants;
|
||||
using Dlhis.Entity.Basic.Entity;
|
||||
using Dlhis.Entity.Canteen.Entities;
|
||||
using Dlhis.Entity.Canteen.Enums;
|
||||
@@ -45,7 +46,7 @@ public class DishesService : IDishesService
|
||||
.ToPageListAsync(request);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task SaveDishesAsync(DishesSaveRequest request)
|
||||
{
|
||||
if (!request.Id.HasValue)
|
||||
@@ -68,7 +69,7 @@ public class DishesService : IDishesService
|
||||
{
|
||||
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 jinkoCode = _currentUser.GetUserClaim(UserClaimConstants.JinkoCode) ?? string.Empty;
|
||||
if (jinkoCode.IsPresent())
|
||||
{
|
||||
gainfo = await _dbContext.Queryable<GainfoEntity>().Where(x => x.Code == jinkoCode).FirstAsync();
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Dlhis.Constants\Dlhis.Constants.csproj" />
|
||||
<ProjectReference Include="..\Dlhis.Dh.Api\Dlhis.Dh.Api.csproj" />
|
||||
<ProjectReference Include="..\Dlhis.Entity\Dlhis.Entity.csproj" />
|
||||
<ProjectReference Include="..\Dlhis.InfoCheck.Api\Dlhis.InfoCheck.Api.csproj" />
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Text;
|
||||
using Dlhis.Constants;
|
||||
using Dlhis.Entity.Basic.Entity;
|
||||
using Kurisu.AspNetCore.Authentication.Abstractions;
|
||||
using Kurisu.AspNetCore.DataAccess.SqlSugar.Services;
|
||||
@@ -21,7 +22,7 @@ public class GainfoQrCodeService : IGainfoQrCodeService
|
||||
|
||||
public async Task<string> GetMyQrCodeAsync(bool isNeedRefresh = false)
|
||||
{
|
||||
var jinkoCode = _currentUser.GetUserClaim("jinko-code");
|
||||
var jinkoCode = _currentUser.GetUserClaim(UserClaimConstants.JinkoCode);
|
||||
if (jinkoCode.IsEmpty())
|
||||
{
|
||||
return null;
|
||||
@@ -63,11 +64,12 @@ public class GainfoQrCodeService : IGainfoQrCodeService
|
||||
var ts = DateTimeOffset.Now.ToUnixTimeMilliseconds();
|
||||
var qrCode = string.Concat("consumer", ":", code, ":");
|
||||
|
||||
return "01" + qrCode.ToArray().Select(x =>
|
||||
return QrCodeConstants.User + qrCode.ToArray().Select(x =>
|
||||
{
|
||||
var b = Encoding.ASCII.GetBytes(x.ToString());
|
||||
int i = b[0];
|
||||
return Convert.ToString(i);
|
||||
|
||||
}).Join(string.Empty) + ts;
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
using Dlhis.Basic.Device.Services;
|
||||
using Dlhis.Basic.Organization.Request;
|
||||
using Dlhis.Basic.Organization.Response;
|
||||
using Dlhis.Constants;
|
||||
using Dlhis.Entity.Basic.Entity;
|
||||
using Dlhis.Entity.Basic.Enums;
|
||||
using Dlhis.Entity.Device.Entities;
|
||||
@@ -195,7 +196,7 @@ public class GainfoService : IGainfoService
|
||||
|
||||
public async Task<GainfoCurrentResponse> CurrentUserInfoAsync()
|
||||
{
|
||||
var code = _currentUser.GetUserClaim("jinko-code");
|
||||
var code = _currentUser.GetUserClaim(UserClaimConstants.JinkoCode);
|
||||
if (code.IsEmpty())
|
||||
{
|
||||
_logger.LogWarning("工号为空尝试获取人员信息");
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using Dlhis.Constants;
|
||||
using Dlhis.Entity.Sys.Entities;
|
||||
using Kurisu.AspNetCore.DataAccess.SqlSugar.Services;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
@@ -41,7 +42,7 @@ public class IdentityUserSyncService : IIdentityUserSyncService
|
||||
|
||||
var id = (int)await _identityDbContext.InsertReturnIdentityAsync(user);
|
||||
user.Id = id;
|
||||
await AddUserClaim(_identityDbContext, id, "jinko-code", userName);
|
||||
await AddUserClaim(_identityDbContext, id, UserClaimConstants.JinkoCode, userName);
|
||||
await AddUserClaim(_identityDbContext, id, "name", name);
|
||||
}
|
||||
|
||||
|
||||
13
Src/Dlhis.Canteen.Api/Dlhis.Canteen.Api.csproj
Normal file
13
Src/Dlhis.Canteen.Api/Dlhis.Canteen.Api.csproj
Normal file
@@ -0,0 +1,13 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>disable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Kurisu.RemoteCall" Version="0.4.8" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
16
Src/Dlhis.Canteen.Api/ITicketApi.cs
Normal file
16
Src/Dlhis.Canteen.Api/ITicketApi.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using Kurisu.RemoteCall.Attributes;
|
||||
|
||||
namespace Dlhis.Canteen.Api;
|
||||
|
||||
[RequestResultHandler]
|
||||
[EnableRemoteClient(Name = "canteen-service", BaseUrl = "${InternalRequest:CanteenRequestUrl}")]
|
||||
public interface ITicketApi
|
||||
{
|
||||
/// <summary>
|
||||
/// 创建券
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
/// <returns></returns>
|
||||
[Post("/api/tickets/{type}/create")]
|
||||
Task CreateAsync(string type);
|
||||
}
|
||||
@@ -22,6 +22,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Dlhis.Basic.Api\Dlhis.Basic.Api.csproj" />
|
||||
<ProjectReference Include="..\Dlhis.Constants\Dlhis.Constants.csproj" />
|
||||
<ProjectReference Include="..\Dlhis.Entity\Dlhis.Entity.csproj" />
|
||||
<ProjectReference Include="..\Dlhis.Sys.Api\Dlhis.Sys.Api.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -3,6 +3,7 @@ using Dlhis.Canteen.EMealVoucher.Request;
|
||||
using Dlhis.Canteen.EMealVoucher.Response;
|
||||
using Dlhis.Canteen.Order.Request;
|
||||
using Dlhis.Canteen.Order.Response;
|
||||
using Dlhis.Constants;
|
||||
using Dlhis.Entity.Basic.Entity;
|
||||
using Dlhis.Entity.Canteen.Entities;
|
||||
using Dlhis.Entity.Canteen.Enums;
|
||||
@@ -65,7 +66,7 @@ public class EMealVoucherService : IEMealVoucherService
|
||||
|
||||
public async Task<Pagination<EMealVoucherMyPageResponse>> GetMyEMealVoucherPageAsync(EMealVoucherPageRequest request)
|
||||
{
|
||||
var code = _currentUser.GetUserClaim("jinko-code");
|
||||
var code = _currentUser.GetUserClaim(UserClaimConstants.JinkoCode);
|
||||
|
||||
return await _dbContext.Queryable<EMealVoucherEntity>()
|
||||
.Where(x => x.Code == code)
|
||||
@@ -126,7 +127,7 @@ public class EMealVoucherService : IEMealVoucherService
|
||||
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 qrCode = QrCodeConstants.EMealVoucher + originData.ToArray().Select(x =>
|
||||
{
|
||||
var b = Encoding.ASCII.GetBytes(x.ToString());
|
||||
int i = b[0];
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Dlhis.Canteen.MealSupplementRecord.Request;
|
||||
using Dlhis.Canteen.MealSupplementRecord.Response;
|
||||
using Dlhis.Constants;
|
||||
using Dlhis.Entity.Basic.Entity;
|
||||
using Dlhis.Entity.Canteen.Entities;
|
||||
using Dlhis.Entity.Canteen.Enums;
|
||||
@@ -93,7 +94,7 @@ public class MealSupplementRecordService : IMealSupplementRecordService
|
||||
|
||||
public async Task<MealSupplementRecordMyResponse> GetMyMealSupplementRecords(MealSupplementRecordMyRequest request)
|
||||
{
|
||||
var code = _currentUser.GetUserClaim("jinko-code") ?? string.Empty;
|
||||
var code = _currentUser.GetUserClaim(UserClaimConstants.JinkoCode) ?? string.Empty;
|
||||
|
||||
var data = await _dbContext.Queryable<BalanceRecordEntity>()
|
||||
.Where(x => x.CostDateTime >= request.SearchDateTimePeriod.Start && x.CostDateTime <= request.SearchDateTimePeriod.End)
|
||||
|
||||
@@ -3,6 +3,7 @@ using Dlhis.Canteen.Order.Repository;
|
||||
using Dlhis.Canteen.Order.Request;
|
||||
using Dlhis.Canteen.Order.Response;
|
||||
using Dlhis.Canteen.Setting.Services;
|
||||
using Dlhis.Constants;
|
||||
using Dlhis.Entity.Basic.Entity;
|
||||
using Dlhis.Entity.Canteen.Entities;
|
||||
using Dlhis.Entity.Canteen.Enums;
|
||||
@@ -332,7 +333,7 @@ public class BalanceService : IBalanceService
|
||||
|
||||
public async Task<BalanceRecordUserResultResponse> GetPageByUserAsync(BalanceRecordUserPageRequest request)
|
||||
{
|
||||
var userCode = _currentUser.GetUserClaim("jinko-code") ?? string.Empty;
|
||||
var userCode = _currentUser.GetUserClaim(UserClaimConstants.JinkoCode) ?? string.Empty;
|
||||
|
||||
var factory = await _dbContext.Queryable<WalletEntity>().Where(x => x.Code == request.WalletCode).Select(x => x.Factory).FirstAsync();
|
||||
var factories = await _balanceRepository.GetWalletFactoriesAsync(factory);
|
||||
|
||||
@@ -21,6 +21,7 @@ using Kurisu.AspNetCore.DataAccess.Dto;
|
||||
using Kurisu.AspNetCore.DataAccess.SqlSugar.Extensions;
|
||||
using Kurisu.AspNetCore.DataAccess.SqlSugar.Services;
|
||||
using Kurisu.AspNetCore.UnifyResultAndValidation;
|
||||
using Dlhis.Constants;
|
||||
|
||||
namespace Dlhis.Canteen.Order.Services.Implements;
|
||||
|
||||
@@ -88,7 +89,7 @@ public class OrderService : IOrderService
|
||||
{
|
||||
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 jinkoCode = _currentUser.GetUserClaim(UserClaimConstants.JinkoCode) ?? string.Empty;
|
||||
if (jinkoCode.IsPresent())
|
||||
{
|
||||
gainfo = await _dbContext.Queryable<GainfoEntity>().Where(x => x.Code == jinkoCode).SingleAsync();
|
||||
@@ -153,12 +154,12 @@ public class OrderService : IOrderService
|
||||
|
||||
if (request.Source == BalanceRecordSourceEnumType.QrCode)
|
||||
{
|
||||
if (request.UserUniqueNo.StartsWith("01"))
|
||||
if (request.UserUniqueNo.StartsWith(QrCodeConstants.User))
|
||||
{
|
||||
gainfo = await GetUserByQrCodeAsync(request.UserUniqueNo);
|
||||
await CheckPermissionAsync(gainfo.Code, request.DeviceUniqueNo);
|
||||
}
|
||||
else if (request.UserUniqueNo.StartsWith("02"))
|
||||
else if (request.UserUniqueNo.StartsWith(QrCodeConstants.EMealVoucher))
|
||||
{
|
||||
request.Source = BalanceRecordSourceEnumType.EMealVoucher;
|
||||
var eMealVoucherQrCode = await _dbContext.Queryable<EMealVoucherDetailQrCodeEntity>().Where(x => x.QrCode == request.UserUniqueNo).SingleAsync();
|
||||
@@ -166,6 +167,12 @@ public class OrderService : IOrderService
|
||||
var code = eMealVoucherQrCode.OriginData.Split(':')[2];
|
||||
gainfo = await _dbContext.Queryable<GainfoEntity>().Where(x => x.Code == code).SingleAsync();
|
||||
}
|
||||
else if (request.UserUniqueNo.StartsWith(QrCodeConstants.Birthday))
|
||||
{
|
||||
var ticket = await _dbContext.Queryable<TicketEntity>().Where(x => x.Type == TicketEnumType.Birthday).Where(x => x.QrCode == request.UserUniqueNo).SingleAsync();
|
||||
ticket.ThrowIfNull("无法识别");
|
||||
gainfo = await _dbContext.Queryable<GainfoEntity>().Where(x => x.Code == ticket.UserCode).SingleAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new UserFriendlyException($"无法识别{request.UserUniqueNo}");
|
||||
@@ -276,7 +283,9 @@ public class OrderService : IOrderService
|
||||
.Where(x => x.DeviceUniqueNo == request.DeviceUniqueNo && x.BusinessPlaceCode.HasValue)
|
||||
.Select((x, b, bs) => new
|
||||
{
|
||||
b.Code, bs.ShiftCode, Factory = x.TenantId
|
||||
b.Code,
|
||||
bs.ShiftCode,
|
||||
Factory = x.TenantId
|
||||
})
|
||||
.SingleAsync();
|
||||
|
||||
@@ -615,7 +624,9 @@ public class OrderService : IOrderService
|
||||
.Where(x => x.DeviceUniqueNo == deviceUniqueNo && x.BusinessPlaceCode.HasValue)
|
||||
.Select((x, b, bs) => new
|
||||
{
|
||||
b.Code, bs.ShiftCode, Factory = x.TenantId
|
||||
b.Code,
|
||||
bs.ShiftCode,
|
||||
Factory = x.TenantId
|
||||
})
|
||||
.SingleAsync();
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Dlhis.Canteen.Order.Repository;
|
||||
using Dlhis.Canteen.Setting.Response;
|
||||
using Dlhis.Constants;
|
||||
using Dlhis.Entity.Canteen.Entities;
|
||||
using Kurisu.AspNetCore.Authentication.Abstractions;
|
||||
using Kurisu.AspNetCore.DataAccess.SqlSugar.Services;
|
||||
@@ -37,7 +38,7 @@ public class WalletService : IWalletService
|
||||
/// <inheritdoc />
|
||||
public async Task<decimal> GetBalanceAsync(string walletCode)
|
||||
{
|
||||
var userCode = _currentUser.GetUserClaim("jinko-code");
|
||||
var userCode = _currentUser.GetUserClaim(UserClaimConstants.JinkoCode);
|
||||
|
||||
if (!await _dbContext.Queryable<UserBalanceEntity>().Where(x => x.UserCode == userCode).AnyAsync())
|
||||
{
|
||||
|
||||
50
Src/Dlhis.Canteen/Tickets/Controllers/TicketsController.cs
Normal file
50
Src/Dlhis.Canteen/Tickets/Controllers/TicketsController.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
using Dlhis.Canteen.Tickets.Request;
|
||||
using Dlhis.Canteen.Tickets.Response;
|
||||
using Dlhis.Canteen.Tickets.Services;
|
||||
using Kurisu.AspNetCore.DataAccess.Dto;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Dlhis.Canteen.Tickets.Controllers;
|
||||
|
||||
/// <summary>
|
||||
/// 券
|
||||
/// </summary>
|
||||
[Authorize]
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class TicketsController : ControllerBase
|
||||
{
|
||||
private readonly INamedResolver _namedResolver;
|
||||
|
||||
public TicketsController(INamedResolver namedResolver)
|
||||
{
|
||||
_namedResolver = namedResolver;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取分页数据(按券类型)
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("page")]
|
||||
public async Task<Pagination<TicketPageResponse>> GetPageAsync(TicketPageRequest request)
|
||||
{
|
||||
return await _namedResolver.GetService<ITicketService>(request.Type.ToString()).GetPageAsync(request);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建券
|
||||
/// </summary>
|
||||
/// <param name="type">券类型,需要后端支持</param>
|
||||
[AllowAnonymous]
|
||||
[HttpPost("{type:required}/create")]
|
||||
public async Task CreateAsync(string type)
|
||||
{
|
||||
var srv = _namedResolver.GetService<ITicketService>(type);
|
||||
srv.ThrowIfNull("不支持的券类型");
|
||||
|
||||
await srv.CreateAsync();
|
||||
}
|
||||
}
|
||||
19
Src/Dlhis.Canteen/Tickets/Request/TicketPageRequest.cs
Normal file
19
Src/Dlhis.Canteen/Tickets/Request/TicketPageRequest.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Dlhis.Entity.Canteen.Enums;
|
||||
using Kurisu.AspNetCore.DataAccess.Dto;
|
||||
|
||||
namespace Dlhis.Canteen.Tickets.Request;
|
||||
|
||||
public class TicketPageRequest : PageDto
|
||||
{
|
||||
/// <summary>
|
||||
/// 类型
|
||||
/// </summary>
|
||||
[EnumDataType(typeof(TicketEnumType))]
|
||||
public TicketEnumType Type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 工号
|
||||
/// </summary>
|
||||
public string UserCode { get; set; }
|
||||
}
|
||||
41
Src/Dlhis.Canteen/Tickets/Response/TicketPageResponse.cs
Normal file
41
Src/Dlhis.Canteen/Tickets/Response/TicketPageResponse.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using Dlhis.Entity.Canteen.Enums;
|
||||
|
||||
namespace Dlhis.Canteen.Tickets.Response;
|
||||
|
||||
public class TicketPageResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// 券类型
|
||||
/// </summary>
|
||||
public TicketEnumType Type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 工号
|
||||
/// </summary>
|
||||
public string UserCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 用户名称
|
||||
/// </summary>
|
||||
public string UserName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 初始余额
|
||||
/// </summary>
|
||||
public decimal OriginalAmount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 当前余额
|
||||
/// </summary>
|
||||
public decimal Amount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 消费码
|
||||
/// </summary>
|
||||
public string QrCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 备注
|
||||
/// </summary>
|
||||
public string Remark { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace Dlhis.Canteen.Tickets.Services;
|
||||
|
||||
public interface IBirthdayTicketService : ITicketService
|
||||
{
|
||||
|
||||
}
|
||||
24
Src/Dlhis.Canteen/Tickets/Services/ITicketService.cs
Normal file
24
Src/Dlhis.Canteen/Tickets/Services/ITicketService.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using Dlhis.Canteen.Tickets.Request;
|
||||
using Dlhis.Canteen.Tickets.Response;
|
||||
using Kurisu.AspNetCore.DataAccess.Dto;
|
||||
|
||||
namespace Dlhis.Canteen.Tickets.Services;
|
||||
|
||||
/// <summary>
|
||||
/// 券
|
||||
/// </summary>
|
||||
public interface ITicketService : IScopeDependency
|
||||
{
|
||||
/// <summary>
|
||||
/// 分页数据
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
Task<Pagination<TicketPageResponse>> GetPageAsync(TicketPageRequest request);
|
||||
|
||||
/// <summary>
|
||||
/// 创建
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task CreateAsync();
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
using System.Text;
|
||||
using Dlhis.Constants;
|
||||
using Dlhis.Entity.Basic.Entity;
|
||||
using Dlhis.Entity.Canteen.Entities;
|
||||
using Dlhis.Entity.Canteen.Enums;
|
||||
using Kurisu.AspNetCore.DataAccess.Entity;
|
||||
using Kurisu.AspNetCore.DataAccess.SqlSugar.Services;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Dlhis.Canteen.Tickets.Services.Implements;
|
||||
|
||||
[Service(nameof(TicketEnumType.Birthday))]
|
||||
public class BirthdayTicketService : BaseTicketService, IBirthdayTicketService
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public BirthdayTicketService(IDbContext dbContext) : base(dbContext)
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override async Task CreateAsync()
|
||||
{
|
||||
await DbContext.IgnoreAsync<ITenantId>(async () =>
|
||||
{
|
||||
var today = DateTime.Today;
|
||||
var userCodes = await DbContext.Queryable<GainfoEntity>()
|
||||
.Where(x => SqlFunc.DateIsSame(SqlFunc.ToDate(x.Birthday), today, DateType.Day))
|
||||
.Select(x => new { x.Code, x.Factory })
|
||||
.ToListAsync();
|
||||
|
||||
const decimal amount = 30;
|
||||
var todayStr = today.ToString("yyyy-MM-dd");
|
||||
foreach (var item in userCodes)
|
||||
{
|
||||
var qrCode = GetQrCode(item.Code + todayStr);
|
||||
if (!await DbContext.Queryable<TicketEntity>().Where(x => x.Type == TicketEnumType.Birthday && x.UserCode == item.Code && x.QrCode == qrCode).AnyAsync())
|
||||
{
|
||||
await DbContext.InsertAsync(new TicketEntity
|
||||
{
|
||||
Type = TicketEnumType.Birthday,
|
||||
UserCode = item.Code,
|
||||
OriginalAmount = amount,
|
||||
Amount = amount,
|
||||
QrCode = qrCode,
|
||||
Remark = todayStr + "生日券",
|
||||
TenantId = item.Factory
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static string GetQrCode(string data)
|
||||
{
|
||||
var qrCode = QrCodeConstants.Birthday + data.ToArray().Select(x =>
|
||||
{
|
||||
var b = Encoding.ASCII.GetBytes(x.ToString());
|
||||
int i = b[0];
|
||||
return Convert.ToString(i);
|
||||
}).Join(string.Empty);
|
||||
|
||||
return qrCode;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
using Dlhis.Canteen.Tickets.Request;
|
||||
using Dlhis.Canteen.Tickets.Response;
|
||||
using Dlhis.Entity.Basic.Entity;
|
||||
using Dlhis.Entity.Canteen.Entities;
|
||||
using Kurisu.AspNetCore.DataAccess.Dto;
|
||||
using Kurisu.AspNetCore.DataAccess.SqlSugar.Extensions;
|
||||
using Kurisu.AspNetCore.DataAccess.SqlSugar.Services;
|
||||
using Kurisu.AspNetCore.Utils.Extensions;
|
||||
|
||||
namespace Dlhis.Canteen.Tickets.Services.Implements;
|
||||
|
||||
public abstract class BaseTicketService : ITicketService
|
||||
{
|
||||
protected IDbContext DbContext { get; set; }
|
||||
|
||||
protected BaseTicketService(IDbContext dbContext)
|
||||
{
|
||||
DbContext = dbContext;
|
||||
}
|
||||
|
||||
public async Task<Pagination<TicketPageResponse>> GetPageAsync(TicketPageRequest request)
|
||||
{
|
||||
return await DbContext.Queryable<TicketEntity>()
|
||||
.LeftJoin<GainfoEntity>((x, ga) => x.UserCode == ga.Code)
|
||||
.Where(x => x.Type == request.Type)
|
||||
.WhereIF(request.UserCode.IsPresent(), x => x.UserCode == request.UserCode)
|
||||
.Select((x, ga) => new TicketPageResponse { UserName = ga.Name }, true)
|
||||
.ToPageListAsync(request);
|
||||
}
|
||||
|
||||
public abstract Task CreateAsync();
|
||||
}
|
||||
9
Src/Dlhis.Constants/Dlhis.Constants.csproj
Normal file
9
Src/Dlhis.Constants/Dlhis.Constants.csproj
Normal file
@@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
19
Src/Dlhis.Constants/QrCodeConstants.cs
Normal file
19
Src/Dlhis.Constants/QrCodeConstants.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
namespace Dlhis.Constants;
|
||||
|
||||
public class QrCodeConstants
|
||||
{
|
||||
/// <summary>
|
||||
/// 个人码
|
||||
/// </summary>
|
||||
public const string User = "01";
|
||||
|
||||
/// <summary>
|
||||
/// 电子餐券
|
||||
/// </summary>
|
||||
public const string EMealVoucher = "02";
|
||||
|
||||
/// <summary>
|
||||
/// 生日券
|
||||
/// </summary>
|
||||
public const string Birthday = "03";
|
||||
}
|
||||
6
Src/Dlhis.Constants/TickConstants.cs
Normal file
6
Src/Dlhis.Constants/TickConstants.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
// namespace Dlhis.Constants;
|
||||
//
|
||||
// public class TickConstants
|
||||
// {
|
||||
// public const string { get; set; }
|
||||
// }
|
||||
9
Src/Dlhis.Constants/UserClaimConstants.cs
Normal file
9
Src/Dlhis.Constants/UserClaimConstants.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace Dlhis.Constants;
|
||||
|
||||
public class UserClaimConstants
|
||||
{
|
||||
/// <summary>
|
||||
/// 晶科工号
|
||||
/// </summary>
|
||||
public const string JinkoCode = "jinko-code";
|
||||
}
|
||||
52
Src/Dlhis.Entity/Canteen/Entities/TicketEntity.cs
Normal file
52
Src/Dlhis.Entity/Canteen/Entities/TicketEntity.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using Dlhis.Entity.Canteen.Enums;
|
||||
using Kurisu.AspNetCore.DataAccess.Entity;
|
||||
using Kurisu.AspNetCore.DataAccess.SqlSugar;
|
||||
using SqlSugar;
|
||||
using SqlSugar.DbConvert;
|
||||
|
||||
namespace Dlhis.Entity.Canteen.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// 券
|
||||
/// </summary>
|
||||
[SugarTable("Tickets", TableDescription = "券")]
|
||||
public class TicketEntity : SugarBaseEntity, ITenantId
|
||||
{
|
||||
/// <summary>
|
||||
/// 类型
|
||||
/// </summary>
|
||||
[SugarColumn(IsNullable = false, ColumnDataType = "varchar(50)", ColumnDescription = "券类型", SqlParameterDbType = typeof(EnumToStringConvert))]
|
||||
public TicketEnumType Type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 工号
|
||||
/// </summary>
|
||||
[SugarColumn(IsNullable = false, ColumnDescription = "工号")]
|
||||
public string UserCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 初始余额
|
||||
/// </summary>
|
||||
[SugarColumn(IsNullable = false, ColumnDescription = "初始余额")]
|
||||
public decimal OriginalAmount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 当前余额
|
||||
/// </summary>
|
||||
[SugarColumn(IsNullable = false, ColumnDescription = "当前余额")]
|
||||
public decimal Amount { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 消费码
|
||||
/// </summary>
|
||||
[SugarColumn(IsNullable = false, ColumnDescription = "消费码")]
|
||||
public string QrCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 备注
|
||||
/// </summary>
|
||||
[SugarColumn(IsNullable = true, ColumnDescription = "备注")]
|
||||
public string Remark { get; set; }
|
||||
|
||||
public string TenantId { get; set; }
|
||||
}
|
||||
16
Src/Dlhis.Entity/Canteen/Enums/TicketEnumType.cs
Normal file
16
Src/Dlhis.Entity/Canteen/Enums/TicketEnumType.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Dlhis.Entity.Canteen.Enums;
|
||||
|
||||
/// <summary>
|
||||
/// 券类型
|
||||
/// </summary>
|
||||
[Description("券类型")]
|
||||
public enum TicketEnumType
|
||||
{
|
||||
/// <summary>
|
||||
/// 生日券
|
||||
/// </summary>
|
||||
[Description("生日券")]
|
||||
Birthday = 1
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using Dlhis.Entity.Basic.Entity;
|
||||
using Dlhis.Constants;
|
||||
using Dlhis.Entity.Basic.Entity;
|
||||
using Dlhis.Entity.Basic.Enums;
|
||||
using Dlhis.Entity.Device.Entities;
|
||||
using Dlhis.Entity.Device.Enums;
|
||||
@@ -95,7 +96,7 @@ public class DeviceUploadLogService : IDeviceUploadLogService
|
||||
|
||||
public async Task<List<DeviceUploadLogResponse>> GetMyRecordsAsync(DeviceUploadLogMyRecordRequest request)
|
||||
{
|
||||
var jinkoCode = _currentUser.GetUserClaim("jinko-code") ?? string.Empty;
|
||||
var jinkoCode = _currentUser.GetUserClaim(UserClaimConstants.JinkoCode) ?? string.Empty;
|
||||
|
||||
return await _dbContext.Queryable<DeviceUploadLogEntity>()
|
||||
.LeftJoin<DeviceEntity>((log, d) => log.DeviceUniqueNo == d.UniqueNo)
|
||||
|
||||
@@ -20,10 +20,13 @@
|
||||
<PackageReference Include="Hangfire.AspNetCore" Version="1.8.7" />
|
||||
<PackageReference Include="Hangfire.Dashboard.BasicAuthorization" Version="1.0.2" />
|
||||
<PackageReference Include="Hangfire.Redis.StackExchange" Version="1.9.3" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.21.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Dlhis.Basic.Api\Dlhis.Basic.Api.csproj" />
|
||||
<ProjectReference Include="..\Dlhis.Canteen.Api\Dlhis.Canteen.Api.csproj" />
|
||||
<ProjectReference Include="..\Dlhis.Constants\Dlhis.Constants.csproj" />
|
||||
<ProjectReference Include="..\Dlhis.Entity\Dlhis.Entity.csproj" />
|
||||
<ProjectReference Include="..\Dlhis.Jip.Api\Dlhis.Jip.Api.csproj" />
|
||||
<ProjectReference Include="..\Dlhis.Sys.Api\Dlhis.Sys.Api.csproj" />
|
||||
|
||||
@@ -1,25 +1,34 @@
|
||||
#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.
|
||||
# 请参阅 https://aka.ms/customizecontainer 以了解如何自定义调试容器,以及 Visual Studio 如何使用此 Dockerfile 生成映像以更快地进行调试。
|
||||
|
||||
# 此阶段用于在快速模式(默认为调试配置)下从 VS 运行时
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
|
||||
WORKDIR /app
|
||||
EXPOSE 80
|
||||
|
||||
|
||||
# 此阶段用于生成服务项目
|
||||
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
|
||||
ARG BUILD_CONFIGURATION=Release
|
||||
WORKDIR /src
|
||||
COPY ["Src/Dlhis.ScheduledTask/Dlhis.ScheduledTask.csproj", "Src/Dlhis.ScheduledTask/"]
|
||||
COPY ["Src/Dlhis.Basic.Api/Dlhis.Basic.Api.csproj", "Src/Dlhis.Basic.Api/"]
|
||||
COPY ["Src/Dlhis.Canteen.Api/Dlhis.Canteen.Api.csproj", "Src/Dlhis.Canteen.Api/"]
|
||||
COPY ["Src/Dlhis.Constants/Dlhis.Constants.csproj", "Src/Dlhis.Constants/"]
|
||||
COPY ["Src/Dlhis.Entity/Dlhis.Entity.csproj", "Src/Dlhis.Entity/"]
|
||||
COPY ["Src/Dlhis.DataPermission.Model/Dlhis.DataPermission.Model.csproj", "Src/Dlhis.DataPermission.Model/"]
|
||||
COPY ["Src/Dlhis.Jip.Api/Dlhis.Jip.Api.csproj", "Src/Dlhis.Jip.Api/"]
|
||||
COPY ["Src/Dlhis.Sys.Api/Dlhis.Sys.Api.csproj", "Src/Dlhis.Sys.Api/"]
|
||||
RUN dotnet restore "./Src/Dlhis.ScheduledTask/./Dlhis.ScheduledTask.csproj"
|
||||
RUN dotnet restore "./Src/Dlhis.ScheduledTask/Dlhis.ScheduledTask.csproj"
|
||||
COPY . .
|
||||
WORKDIR "/src/Src/Dlhis.ScheduledTask"
|
||||
RUN dotnet build "./Dlhis.ScheduledTask.csproj" -c $BUILD_CONFIGURATION -o /app/build
|
||||
|
||||
# 此阶段用于发布要复制到最终阶段的服务项目
|
||||
FROM build AS publish
|
||||
ARG BUILD_CONFIGURATION=Release
|
||||
RUN dotnet publish "./Dlhis.ScheduledTask.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
|
||||
|
||||
# 此阶段在生产中使用,或在常规模式下从 VS 运行时使用(在不使用调试配置时为默认值)
|
||||
FROM base AS final
|
||||
WORKDIR /app
|
||||
COPY --from=publish /app/publish .
|
||||
|
||||
22
Src/Dlhis.ScheduledTask/Jobs/CreateBirthdayTicketJob.cs
Normal file
22
Src/Dlhis.ScheduledTask/Jobs/CreateBirthdayTicketJob.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using Dlhis.Canteen.Api;
|
||||
using Dlhis.Entity.Canteen.Enums;
|
||||
using Dlhis.ScheduledTask.Attributes;
|
||||
|
||||
namespace Dlhis.ScheduledTask.Jobs;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[RecurringJob(nameof(CreateBirthdayTicketJob), "0 0 1 * * ?", Name = "生日券发放")]
|
||||
public class CreateBirthdayTicketJob : BaseJob
|
||||
{
|
||||
public CreateBirthdayTicketJob(IServiceProvider serviceProvider) : base(serviceProvider)
|
||||
{
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override async Task RunAsync(IServiceProvider serviceProvider)
|
||||
{
|
||||
await serviceProvider.GetService<ITicketApi>().CreateAsync(TicketEnumType.Birthday.ToString());
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,8 @@
|
||||
},
|
||||
"InternalRequest": {
|
||||
"SysRequestUrl": "http://localhost:5003",
|
||||
"BasicRequestUrl": "http://localhost:5002"
|
||||
"BasicRequestUrl": "http://localhost:5002",
|
||||
"CanteenRequestUrl": "http://localhost:5008"
|
||||
},
|
||||
"FaceUrlOptions": {
|
||||
"Url": "http://192.168.199.115:5002/api/gainfos/face?token=",
|
||||
@@ -36,18 +37,18 @@
|
||||
"ClientSecret": "123456"
|
||||
}
|
||||
},
|
||||
// "JinkoOptions": {
|
||||
// "Jip": {
|
||||
// "BaseUrl": "http://172.16.202.34:8000",
|
||||
// "Key": "FACE-7409WIBX",
|
||||
// "Secret": "be0a4b88-cd80-4509-b9b9-865205d0d3d8"
|
||||
// }
|
||||
// },
|
||||
// "JinkoOptions": {
|
||||
// "Jip": {
|
||||
// "BaseUrl": "http://172.16.202.34:8000",
|
||||
// "Key": "FACE-7409WIBX",
|
||||
// "Secret": "be0a4b88-cd80-4509-b9b9-865205d0d3d8"
|
||||
// }
|
||||
// },
|
||||
"JinkoOptions": {
|
||||
"Jip": {
|
||||
"BaseUrl": "http://jip.jinkosolar.com",
|
||||
"Key": "FACE-CUOJG9N7",
|
||||
"Secret": "130c2f2d-03a0-4720-8e25-538ffac7a7cb"
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
},
|
||||
"InternalRequest": {
|
||||
"SysRequestUrl": "http://sys",
|
||||
"BasicRequestUrl": "http://basic"
|
||||
"BasicRequestUrl": "http://basic",
|
||||
"CanteenRequestUrl": "http://canteen"
|
||||
},
|
||||
"DataProtectionOptions": {
|
||||
"Enable": true,
|
||||
|
||||
Reference in New Issue
Block a user