From 6614d9f16c1012b8a9f2ba94b8a15bd1356e8adb Mon Sep 17 00:00:00 2001
From: qwj <qwjzorro@163.com>
Date: 星期四, 24 八月 2023 10:42:12 +0800
Subject: [PATCH] Merge branch 'master' of http://47.108.235.38:8080/r/DocumentService
---
ZcPayCore/Model/OderInfo.cs | 55 +++
DocumentServiceAPI.Application/UserAndLogin/ViewMode/UserInfo.cs | 6
DocumentServiceAPI.Web.Entry/appsettings.json | 10
.gitignore | 2
DocumentServiceAPI.Application/UserAndLogin/LogInController.cs | 236 +++++++++------
ZcPayCore/ZcPayCore.csproj | 20 +
DocumentServiceAPI.Model/UserInfoModel/TenantInfo.cs | 7
DocumentServiceApi.InitQMessage/INITQMessageDefine.cs | 24 +
DocumentServiceAPI.Application/applicationsettings.json | 15
DocumentServiceAPI.Application/UserAndLogin/Services/TokenService.cs | 66 +++
DocumentServiceAPI.sln | 12
DocumentServiceAPI.Model/Permissions/TenantPermissions.cs | 46 +++
DocumentServiceAPI.Application/DocumentServiceAPI.Application.xml | 14
DocumentServiceApi.InitQMessage/DocumentServiceApi.InitQMessage.csproj | 18 +
DocumentServiceApi.InitQMessage/MessageReceive.cs | 181 ++++++++++++
DocumentServiceAPI.Model/Oder/Oder.cs | 50 +++
DocumentServiceApi.InitQMessage/TenantOderInfo.cs | 60 ++++
DocumentServiceAPI.Web.Entry/AuthorizeHandler.cs | 4
DocumentServiceApi.InitQMessage/INITQSetups.cs | 48 +++
19 files changed, 760 insertions(+), 114 deletions(-)
diff --git a/.gitignore b/.gitignore
index 34fae7d..6456eb0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -29,3 +29,5 @@
/DocumentFile.Service/obj
/DocumentServiceAPI.Services/bin
/DocumentServiceAPI.Services/obj
+ZcPayCore/obj/
+DocumentServiceApi.InitQMessage/obj/
diff --git a/DocumentServiceAPI.Application/DocumentServiceAPI.Application.xml b/DocumentServiceAPI.Application/DocumentServiceAPI.Application.xml
index 96b03e8..1f3f55f 100644
--- a/DocumentServiceAPI.Application/DocumentServiceAPI.Application.xml
+++ b/DocumentServiceAPI.Application/DocumentServiceAPI.Application.xml
@@ -970,6 +970,7 @@
<member name="M:DocumentServiceAPI.Application.UserAndLogin.LogInController.LogoIn(DocumentServiceAPI.Application.UserAndLogin.ViewMode.LoginPsWordIN)">
<summary>
鐧诲綍 1 杈撳叆鍛樺伐璐︽埛鎴栬�呯鎴疯处鎴凤紝2 閫夋嫨绉熸埛璐︽埛锛�3 閫夋嫨鍏徃
+ 褰撳瘑鐮佷负绌烘椂锛屽甫鍏ョ敤鎴蜂腑蹇僼oken鍗冲彲瀹炵幇鐧诲綍
</summary>
<returns>鐧诲綍淇℃伅</returns>
</member>
@@ -999,6 +1000,15 @@
<summary>
鏂板缓涓�涓猅Oken
</summary>
+ <returns></returns>
+ </member>
+ <member name="M:DocumentServiceAPI.Application.UserAndLogin.Services.TokenService.CheckJwt(System.String,Microsoft.IdentityModel.Tokens.SecurityToken@)">
+ <summary>
+ 鏍¢獙token 鐨勬湁鏁堟��
+ </summary>
+ <param name="Token"> Token鏍¢獙</param>
+ <param name="validationParameters"></param>
+ <param name="securityToken"></param>
<returns></returns>
</member>
<member name="M:DocumentServiceAPI.Application.UserAndLogin.Services.TokenService.CheckToken">
@@ -1339,8 +1349,8 @@
</member>
<member name="P:DocumentServiceAPI.Application.UserAndLogin.ViewMode.EmployeeInfoVM.UserName">
<summary>
- 鐢ㄦ埛鍚�
- </summary>
+ 鐢ㄦ埛鍚� 鎵嬫満鍙烽獙璇� 蹇呭~
+ </summary>
</member>
<member name="P:DocumentServiceAPI.Application.UserAndLogin.ViewMode.EmployeeInfoVM.UserPassWord">
<summary>
diff --git a/DocumentServiceAPI.Application/UserAndLogin/LogInController.cs b/DocumentServiceAPI.Application/UserAndLogin/LogInController.cs
index 3478ee1..2eed030 100644
--- a/DocumentServiceAPI.Application/UserAndLogin/LogInController.cs
+++ b/DocumentServiceAPI.Application/UserAndLogin/LogInController.cs
@@ -3,9 +3,14 @@
using DocumentServiceAPI.Utility;
using Furion.DynamicApiController;
using Furion.JsonSerialization;
+using Microsoft.AspNetCore.Http;
+using Microsoft.IdentityModel.Tokens;
+using NetTaste;
+using Newtonsoft.Json.Linq;
using Swashbuckle.AspNetCore.Annotations;
using System;
using System.Collections.Generic;
+using System.IdentityModel.Tokens.Jwt;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -28,133 +33,172 @@
}
/// <summary>
/// 鐧诲綍 1 杈撳叆鍛樺伐璐︽埛鎴栬�呯鎴疯处鎴凤紝2 閫夋嫨绉熸埛璐︽埛锛�3 閫夋嫨鍏徃
+ /// 褰撳瘑鐮佷负绌烘椂锛屽甫鍏ョ敤鎴蜂腑蹇僼oken鍗冲彲瀹炵幇鐧诲綍
/// </summary>
/// <returns>鐧诲綍淇℃伅</returns>
[HttpPost("LogoIn")]
- public async Task<RetLoginVM> LogoIn (LoginPsWordIN Parma)
+ public async Task<RetLoginVM> LogoIn ( LoginPsWordIN Parma)
{
- bool needtoken=false;
- if (Parma.TenantId==null)
+ //zctok鏍¢獙鎴愬姛鏄惁鏍囧織
+ bool IsTokenPass=false;
+
+ if(string.IsNullOrEmpty(Parma.PassWord))
{
- //濡傛灉杩樻病纭畾绉熸埛ID 闇�瑕佸厛纭畾绉熸埛ID
- List<TenderVM>Tender = await _userService.GetUserTenderList(Parma.ITCode);
-
- switch (Tender.Count)
+
+ var Request = App.HttpContext.Request;
+ string stoken = Request.Headers["Authorization"];
+ if (stoken == null)
+ throw Oops.Oh("娌℃湁杈撳叆瀵嗙爜");
+ stoken = stoken.Replace("Bearer ", "");
+
+ var isvale = _tokenService.CheckJwt(stoken, out SecurityToken securityToken);
+ JwtSecurityToken jwtToken = securityToken as JwtSecurityToken;
+ string itcode = jwtToken.Claims.FirstOrDefault(claim => claim.Type == "sub")?.Value;
+ if (isvale == false)
+ throw Oops.Oh("鐧诲綍淇℃伅鍑洪敊");
+ if(Parma.ITCode!= itcode)
+ throw Oops.Oh("鐢ㄦ埛鍚嶉敊璇�");
+ IsTokenPass=true;
+
+ }
+
+ bool needtoken = false;
+
+ if (Parma.TenantId == null)
{
- case 0:
- throw Oops.Oh($"璐︽埛鎴栬�呭瘑鐮侀敊璇�");
- case 1:
- needtoken = await _userService.CheckPsw(Tender[0].TenderId, Tender[0].EmployeeID,Parma.PassWord);
-
- if(!needtoken)
+ //濡傛灉杩樻病纭畾绉熸埛ID 闇�瑕佸厛纭畾绉熸埛ID
+ List<TenderVM> Tender = await _userService.GetUserTenderList(Parma.ITCode);
+
+ switch (Tender.Count)
+ {
+ case 0:
throw Oops.Oh($"璐︽埛鎴栬�呭瘑鐮侀敊璇�");
-
- Parma.TenantId = Tender[0].TenderId;
- Parma.employeeID = Tender[0].EmployeeID;
- if (Parma.UnitID == null)
+ case 1:
+ if (!needtoken)
{
-
- List<UnitVM> Units = await _userService.GetUserUnitList(Parma.TenantId ?? 0);
- if (Units.Count == 0)
- {
- //娌℃湁鍏徃
- needtoken = true;
- }
- else if (Units.Count == 1)
- {
- Parma.UnitID = Units[0].UnitID;
- needtoken = true;
- }
- else
- {
- //鍏朵粬闇�瑕佺敤鎴烽�夋嫨绉熸埛
- return new RetLoginVM
- {
- NeedNext = true,
- Units = Units,
+ needtoken = await _userService.CheckPsw(Tender[0].TenderId, Tender[0].EmployeeID, Parma.PassWord);
- };
- }
+ if (!needtoken)
+ throw Oops.Oh($"璐︽埛鎴栬�呭瘑鐮侀敊璇�");
}
-
- break;
-
- default:
+
+
+ Parma.TenantId = Tender[0].TenderId;
+ Parma.employeeID = Tender[0].EmployeeID;
+ if (Parma.UnitID == null)
+ {
+
+ List<UnitVM> Units = await _userService.GetUserUnitList(Parma.TenantId ?? 0);
+ if (Units.Count == 0)
+ {
+ //娌℃湁鍏徃
+ needtoken = true;
+ }
+ else if (Units.Count == 1)
+ {
+ Parma.UnitID = Units[0].UnitID;
+ needtoken = true;
+ }
+ else
+ {
+ //鍏朵粬闇�瑕佺敤鎴烽�夋嫨绉熸埛
+ return new RetLoginVM
+ {
+ NeedNext = true,
+ Units = Units,
+
+ };
+ }
+ }
+
+ break;
+
+ default:
+ //鍏朵粬闇�瑕佺敤鎴烽�夋嫨绉熸埛
+ return new RetLoginVM
+ {
+ NeedNext = true,
+ Tenants = Tender,
+
+ };
+
+
+ }
+
+
+
+
+
+ }
+ else if (Parma.UnitID == null)
+ {
+
+ var Units = await _userService.GetUserUnitList(Parma.TenantId ?? 0);
+ if (Units.Count == 0)
+ {
+ //娌℃湁鍏徃
+ needtoken = true;
+ }
+ else if (Units.Count == 1) {
+ Parma.UnitID = Units[0].UnitID;
+ needtoken = true;
+ }
+ else
+ {
//鍏朵粬闇�瑕佺敤鎴烽�夋嫨绉熸埛
return new RetLoginVM
{
NeedNext = true,
- Tenants = Tender,
+ Units = Units,
};
+ }
-
}
-
-
-
-
- }
- else if(Parma.UnitID==null)
- {
-
- var Units = await _userService.GetUserUnitList(Parma.TenantId??0);
- if(Units.Count==0)
+ if (needtoken || Parma.UnitID != null)
{
- //娌℃湁鍏徃
- needtoken = true;
- }
- else if (Units.Count==1) {
- Parma.UnitID= Units[0].UnitID;
- needtoken = true;
- }
- else
+
+ TenderVM Tender = (await _userService.GetUserTenderList(Parma.ITCode)).Where(x => x.TenderId == Parma.TenantId && x.EmployeeID == Parma.employeeID).SingleOrDefault();
+ if (Tender == null)
+ {
+ throw Oops.Oh($"璐︽埛瀵嗙爜鎴栬�呯鎴烽�夋嫨閿欒");
+ }
+ if (!IsTokenPass)
{
- //鍏朵粬闇�瑕佺敤鎴烽�夋嫨绉熸埛
+ needtoken = await _userService.CheckPsw(Tender.TenderId, Tender.EmployeeID, Parma.PassWord);
+
+ if (!needtoken)
+ throw Oops.Oh($"璐︽埛鎴栬�呭瘑鐮侀敊璇�");
+ }
+ var token = _tokenService.CreateToken(new Model.JwtInfo
+ {
+ EID = Tender.EmployeeID,
+ LogInSource = Parma.Form,
+ TEID = Tender.TenderId,
+ UID = Parma.UnitID,
+ });
return new RetLoginVM
{
- NeedNext = true,
- Units = Units,
+ NeedNext = false,
+ Token = token,
};
}
-
- }
-
- if(needtoken|| Parma.UnitID!=null)
- {
-
- TenderVM Tender = (await _userService.GetUserTenderList(Parma.ITCode)).Where(x=>x.TenderId==Parma.TenantId&&x.EmployeeID==Parma.employeeID).SingleOrDefault();
- if(Tender==null)
- {
- throw Oops.Oh($"璐︽埛瀵嗙爜鎴栬�呯鎴烽�夋嫨閿欒");
- }
- needtoken = await _userService.CheckPsw(Tender. TenderId, Tender.EmployeeID, Parma.PassWord);
-
- if (!needtoken)
- throw Oops.Oh($"璐︽埛鎴栬�呭瘑鐮侀敊璇�");
- var token= _tokenService.CreateToken(new Model.JwtInfo
- {
- EID = Tender.EmployeeID,
- LogInSource = Parma.Form,
- TEID = Tender.TenderId,
- UID = Parma.UnitID,
- });
- return new RetLoginVM
- {
- NeedNext = false,
- Token = token,
-
- };
- }
- throw Oops.Oh($"鍙傛暟閿欒");
+ throw Oops.Oh($"鍙傛暟閿欒");
+
+
+
}
-
+
+
+
+
+
/// <summary>
/// 鑾峰彇鍏徃鍒楄〃
diff --git a/DocumentServiceAPI.Application/UserAndLogin/Services/TokenService.cs b/DocumentServiceAPI.Application/UserAndLogin/Services/TokenService.cs
index 8988879..ce8b762 100644
--- a/DocumentServiceAPI.Application/UserAndLogin/Services/TokenService.cs
+++ b/DocumentServiceAPI.Application/UserAndLogin/Services/TokenService.cs
@@ -3,10 +3,13 @@
using Furion.Authorization;
using Furion.DistributedIDGenerator;
using Furion.JsonSerialization;
+using Furion.Logging.Extensions;
+using Microsoft.IdentityModel.Tokens;
using NetTaste;
using SqlSugar.Extensions;
using System;
using System.Collections.Generic;
+using System.IdentityModel.Tokens.Jwt;
using System.Linq;
using System.Reflection;
using System.Security.Claims;
@@ -18,7 +21,7 @@
/// <summary>
/// token鏈嶅姟绫�
/// </summary>
- public class TokenService: IScoped
+ public class TokenService : IScoped
{
/// <summary>
/// Token鏄暐
@@ -27,7 +30,7 @@
private ISqlSugarClient _db;
private UserService _UserService;
private IRedisCacheService _RedisCase;
- public TokenService(ISqlSugarClient db, UserService UserInfoService, IRedisCacheService RedisCase ) {
+ public TokenService(ISqlSugarClient db, UserService UserInfoService, IRedisCacheService RedisCase) {
_db = db;
_UserService = UserInfoService;
_RedisCase = RedisCase;
@@ -36,9 +39,9 @@
/// 鏂板缓涓�涓猅Oken
/// </summary>
/// <returns></returns>
- public string CreateToken(JwtInfo jwt)
+ public string CreateToken(JwtInfo jwt)
{
- string TokenKey=TokenKeys+ getTokenKey(jwt);
+ string TokenKey = TokenKeys + getTokenKey(jwt);
IDictionary<string, object> propertyDictionary = new Dictionary<string, object>();
PropertyInfo[] properties = jwt.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance);
@@ -51,14 +54,57 @@
propertyDictionary.Add(propertyName.ToLower(), propertyValue);
}
var ID = IDGen.NextID();
- jwt.JID = ID;
- var token= JWTEncryption.Encrypt(propertyDictionary, App.GetConfig<JWTSettingsOptions>("JWTSettings").ExpiredTime ?? 3600);
- if(jwt.LogInSource==LogInFrom.PC)
- _RedisCase.Add<string>(TokenKey, ID.ToString(), expireSeconds: (int )(App.GetConfig<JWTSettingsOptions>("JWTSettings").ExpiredTime??3600));
+ jwt.JID = ID;
+ var token = JWTEncryption.Encrypt(propertyDictionary, App.GetConfig<JWTSettingsOptions>("JWTSettings").ExpiredTime ?? 3600);
+ if (jwt.LogInSource == LogInFrom.PC)
+ _RedisCase.Add<string>(TokenKey, ID.ToString(), expireSeconds: (int)(App.GetConfig<JWTSettingsOptions>("JWTSettings").ExpiredTime ?? 3600));
return token;
}
+ /// <summary>
+ /// 鏍¢獙token 鐨勬湁鏁堟��
+ /// </summary>
+ /// <param name="Token"> Token鏍¢獙</param>
+ /// <param name="validationParameters"></param>
+ /// <param name="securityToken"></param>
+ /// <returns></returns>
+ public bool CheckJwt(string Token, out SecurityToken? securityToken)
+ {
+ var configuration = App.Configuration;
+ // var value = configuration["xxx:xxx"];
+
+ string secretKey = configuration["ZCUserInfoJwtOP:SecurityKey"];
+ if (secretKey == null)
+ {
+ "娌℃湁閰嶇疆鐢ㄦ埛涓績鐨勫畨鍏ㄧ閽� ZCUserInfoJwtOP:SecurityKey 鎵句笉鍒�".LogInformation<TokenService>();
+ throw Oops.Oh("閰嶇疆閿欒锛岃仈绯荤鐞嗗憳");
+ }
+ JwtSecurityTokenHandler tokenHandler = new JwtSecurityTokenHandler();
+ //JwtSecurityToken jwt = tokenHandler.ReadJwtToken(Token);
+
+ // 楠岃瘉 JWT 绛惧悕骞舵鏌ユ湁鏁堟湡
+ TokenValidationParameters validationParameters = new TokenValidationParameters
+ {
+ ValidateIssuerSigningKey = true,
+ IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(secretKey)),
+ ValidateIssuer = false,
+ ValidateAudience = false,
+ ClockSkew = TimeSpan.Zero // 绂佺敤鏃堕棿鍋忕Щ閲�
+ };
+ try
+ {
+ ClaimsPrincipal claimsPrincipal = tokenHandler.ValidateToken(Token, validationParameters, out SecurityToken validatedToken);
+
+ securityToken = validatedToken;
+ return true;
+ }
+ catch (SecurityTokenException)
+ {
+ securityToken=null;
+ return false;
+ }
+ }
/// <summary>
@@ -91,6 +137,10 @@
string TokenKey = TokenKeys + jwt.EID?.ToString() + jwt.UID?.ToString() + jwt.TEID?.ToString();
return TokenKey;
}
+
+
+
+
}
}
diff --git a/DocumentServiceAPI.Application/UserAndLogin/ViewMode/UserInfo.cs b/DocumentServiceAPI.Application/UserAndLogin/ViewMode/UserInfo.cs
index 7494f98..2ec9abe 100644
--- a/DocumentServiceAPI.Application/UserAndLogin/ViewMode/UserInfo.cs
+++ b/DocumentServiceAPI.Application/UserAndLogin/ViewMode/UserInfo.cs
@@ -130,8 +130,10 @@
/// </summary>
public string LastUpdateName { get; set; }
/// <summary>
- /// 鐢ㄦ埛鍚�
- /// </summary>
+ /// 鐢ㄦ埛鍚� 鎵嬫満鍙烽獙璇� 蹇呭~
+ /// </summary>
+ [Required]
+ [RegularExpression("/^(?:(?:\\+|00)86)?1\\d{10}$/")]
public string UserName { get; set; }
/// <summary>
/// 鐢ㄦ埛瀵嗙爜
diff --git a/DocumentServiceAPI.Application/applicationsettings.json b/DocumentServiceAPI.Application/applicationsettings.json
index 9ba3089..fadfbf6 100644
--- a/DocumentServiceAPI.Application/applicationsettings.json
+++ b/DocumentServiceAPI.Application/applicationsettings.json
@@ -46,12 +46,25 @@
"KeepVerb": true,//淇濇寔鐗堟湰鍙蜂竴鑷�
"LowercaseRoute": false
},
-
+
"CorsAccessorSettings": {
"WithExposedHeaders": [
"access-token",
"x-access-token",
"environment"
]
+ },
+ "ZCUserInfoJwtOP": { //zc鐢ㄦ埛涓績jwt閰嶇疆 鐢ㄤ簬瑙f瀽zc鐨則oken
+
+ "Issuer": "http://zc",
+ "Audience": "http://zc",
+ "Expires": 86400,
+ "weixinExpires": 1296000, // 86400,
+ "SecurityKey": "superSecretKey@345",
+ "RefreshTokenExpires": 86400,
+ "LoginPath": "/_Framework/Redirect401"
+
}
+
+
}
\ No newline at end of file
diff --git a/DocumentServiceAPI.Model/Oder/Oder.cs b/DocumentServiceAPI.Model/Oder/Oder.cs
index 214e718..818f1a7 100644
--- a/DocumentServiceAPI.Model/Oder/Oder.cs
+++ b/DocumentServiceAPI.Model/Oder/Oder.cs
@@ -1,6 +1,8 @@
锘縰sing DocumentServiceAPI.Enum;
+using SqlSugar;
using System;
using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -12,6 +14,54 @@
/// </summary>
public class Oder:BaseModel
{
+ /// <summary>
+ /// OderID
+ /// </summary>
+ [SugarColumn( IsPrimaryKey =true,IsIdentity =true)]
+ public int Id { get; set; }
+ /// <summary>
+ /// 鏈堜唤
+ /// </summary>
+ [Display(Name = "鏈堜唤")]
+ public int? MonthCount { get; set; }
+
+ /// <summary>
+ /// 鍗曚綅涓暟
+ /// </summary>
+ [Display(Name = "鍗曚綅涓暟")]
+ public int? UnitCount { get; set; }
+
+ /// <summary>
+ /// 鍛樺伐
+ /// </summary>
+ [Display(Name = "鍛樺伐涓暟")]
+ public int? EmployeeCount { get; set; }
+ /// <summary>
+ /// 鍗曚环
+ /// </summary>
+ [Display(Name = "閲戦")]
+ public decimal Amount { get; set; }
+ /// <summary>
+ /// 鏀粯鏂瑰紡
+ /// </summary>
+ public string? PayType { get; set; }
+ /// <summary>
+ /// 鏀粯鏃堕棿
+ /// </summary>
+ public DateTime? PayTime { get; set; }
+ /// <summary>
+ /// 鎻忚堪
+ /// </summary>
+ public string? Description { get; set; }
+
+ /// <summary>
+ /// 鎵嬫満鍙风爜
+ /// </summary>
+ public string ITCode { get; set; }
+ /// <summary>
+ /// 鏀块噰鐢ㄦ埛涓績ID
+ /// </summary>
+ public Guid? ZcUserID { get; set; }
}
diff --git a/DocumentServiceAPI.Model/Permissions/TenantPermissions.cs b/DocumentServiceAPI.Model/Permissions/TenantPermissions.cs
index bdb4a9c..d5b331b 100644
--- a/DocumentServiceAPI.Model/Permissions/TenantPermissions.cs
+++ b/DocumentServiceAPI.Model/Permissions/TenantPermissions.cs
@@ -1,6 +1,8 @@
锘縰sing DocumentServiceAPI.Enum;
+using SqlSugar;
using System;
using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -10,8 +12,50 @@
/// <summary>
/// 绉熸埛鏉冮檺
/// </summary>
- public class TenantPermissions
+ public class TenantPermissions: BaseModel
{
+ /// <summary>
+ /// id
+ /// </summary>
+ [Display(Name = "id ")]
+ [SugarColumn(ColumnDescription = "id " ,IsPrimaryKey =true,IsIdentity =true)]
+ public int Id { get; set; }
+ /// <summary>
+ /// 绉熸埛ID
+ /// </summary>
+ [Display(Name = "绉熸埛ID ")]
+ [SugarColumn(ColumnDescription = "绉熸埛ID ")]
+ public int TenantId { get; set; }
+
+
+ /// <summary>
+ /// 鏈�澶т紒涓氫釜鏁�
+ /// </summary>
+ [Display(Name = "鏈�澶т紒涓氫釜鏁� ")]
+ [SugarColumn(ColumnDescription = "鏈�澶т紒涓氫釜鏁� ")]
+ public int UnitMaxCount { get; set; }
+
+ /// <summary>
+ /// 鏈�澶у憳宸ユ暟閲�
+ /// </summary>
+ [Display(Name = "鏈�澶у憳宸ユ暟閲� ")]
+ [SugarColumn(ColumnDescription = "鏈�澶у憳宸ユ暟閲� ")]
+ public int EmployeeMaxCount { get; set; }
+
+
+ /// <summary>
+ /// 鍒版湡鏃堕棿
+ /// </summary>
+ [Display(Name = "鍒版湡鏃堕棿 ")]
+ [SugarColumn(ColumnDescription = "鍒版湡鏃堕棿 ")]
+ public DateTime OverTime { get; set; }
+
+ /// <summary>
+ /// 鎻忚堪
+ /// </summary>
+ [Display(Name = "鎻忚堪 ")]
+ [SugarColumn(ColumnDescription = "鎻忚堪 ")]
+ public string? Description { get; set; }
}
}
diff --git a/DocumentServiceAPI.Model/UserInfoModel/TenantInfo.cs b/DocumentServiceAPI.Model/UserInfoModel/TenantInfo.cs
index 2773ab1..d84de91 100644
--- a/DocumentServiceAPI.Model/UserInfoModel/TenantInfo.cs
+++ b/DocumentServiceAPI.Model/UserInfoModel/TenantInfo.cs
@@ -68,7 +68,12 @@
/// 瀵嗙爜
/// </summary>
[SugarColumn(Length =30)]
- public string? PsW { get; set; }
+ public string? PsW { get; set; }
+
+ /// <summary>
+ /// 鏀块噰鐢ㄦ埛涓績ID
+ /// </summary>
+ public Guid? ZcUserID { get; set; }
}
diff --git a/DocumentServiceAPI.Web.Entry/AuthorizeHandler.cs b/DocumentServiceAPI.Web.Entry/AuthorizeHandler.cs
index ad89288..dc0d05c 100644
--- a/DocumentServiceAPI.Web.Entry/AuthorizeHandler.cs
+++ b/DocumentServiceAPI.Web.Entry/AuthorizeHandler.cs
@@ -1,4 +1,5 @@
锘縰sing Furion.Authorization;
+using Furion.DataEncryption;
using Microsoft.AspNetCore.Authorization;
namespace DocumentServiceAPI.Web.Entry
@@ -8,6 +9,7 @@
/// </summary>
public class AuthorizeHandler:AppAuthorizeHandler
{
+
/// <summary>
/// 璇锋眰绠¢亾
/// </summary>
@@ -17,7 +19,7 @@
public override Task<bool> PipelineAsync(AuthorizationHandlerContext context, DefaultHttpContext httpContext)
{
// 姝ゅ宸茬粡鑷姩楠岃瘉 Jwt token鐨勬湁鏁堟�т簡锛屾棤闇�鎵嬪姩楠岃瘉
-
+
// 妫�鏌ユ潈闄愶紝濡傛灉鏂规硶鏄紓姝ョ殑灏变笉鐢� Task.FromResult 鍖呰9锛岀洿鎺ヤ娇鐢� async/await 鍗冲彲
return Task.FromResult(CheckAuthorzie(httpContext));
}
diff --git a/DocumentServiceAPI.Web.Entry/appsettings.json b/DocumentServiceAPI.Web.Entry/appsettings.json
index 550e6de..749ed0e 100644
--- a/DocumentServiceAPI.Web.Entry/appsettings.json
+++ b/DocumentServiceAPI.Web.Entry/appsettings.json
@@ -12,7 +12,8 @@
{
"ConfigId": "default", //澶氬簱閰嶇疆ID
- "ConnectionString": "Server=.;Database=doc_new;User ID=sa;Password=123456;",
+ //"ConnectionString": "Server=.;Database=doc_new;User ID=sa;Password=123456;",
+ "ConnectionString": "Server=localhost\\SQLEXPRESS;Database=CY_DocumentSystemOnline;User ID=sa;Password=123456;",
"DbType": "SqlServer",
"IsAutoCloseConnection": true
@@ -20,7 +21,7 @@
}
],
- "isCodeFirst": false, //鏄惁鎵цcodefirst 娉ㄦ剰杩欎釜鍦ㄨ縼寰欏畬鎴愬悗搴旇璁剧疆涓篺alse 闃叉鏇存敼鏁版嵁搴�
+ "isCodeFirst": true, //鏄惁鎵цcodefirst 娉ㄦ剰杩欎釜鍦ㄨ縼寰欏畬鎴愬悗搴旇璁剧疆涓篺alse 闃叉鏇存敼鏁版嵁搴�
//璇蜂繚鎸乺edis涓烘甯稿彲鐢�
"RedisConfig": {
// 濡傛灉閲囩敤瀹瑰櫒鍖栭儴缃睸ervice 瑕佸啓鎴恟edis鐨勬湇鍔″悕锛屽惁鍒欏啓鍦板潃
@@ -28,7 +29,12 @@
},
+ //娑堟伅闃熷垪閰嶇疆 涓轰簡鐙珛閮ㄧ讲锛岃繖閲屽崟鐙厤缃�
+ "InitQRedisConfig": {
+ // 濡傛灉閲囩敤瀹瑰櫒鍖栭儴缃睸ervice 瑕佸啓鎴恟edis鐨勬湇鍔″悕锛屽惁鍒欏啓鍦板潃
+ "ConnectionString": "127.0.0.1:6379,password=,connectTimeout=30000,responseTimeout=30000,abortConnect=false,connectRetry=1,syncTimeout=10000,DefaultDatabase=10" //redis鏁版嵁搴撹繛鎺ュ瓧绗︿覆
+ },
"JWTSettings": {
diff --git a/DocumentServiceAPI.sln b/DocumentServiceAPI.sln
index e632510..cf65739 100644
--- a/DocumentServiceAPI.sln
+++ b/DocumentServiceAPI.sln
@@ -21,6 +21,10 @@
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DocumentServiceAPI.Services", "DocumentServiceAPI.Services\DocumentServiceAPI.Services.csproj", "{3369F102-ABB2-42A4-B216-58D530AEE8BE}"
EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ZcPayCore", "ZcPayCore\ZcPayCore.csproj", "{76BFAB65-B7AC-4534-A595-363551111129}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DocumentServiceApi.InitQMessage", "DocumentServiceApi.InitQMessage\DocumentServiceApi.InitQMessage.csproj", "{0A75ECEE-91C9-4A87-8573-4298DF0B6CDE}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -62,6 +66,14 @@
{3369F102-ABB2-42A4-B216-58D530AEE8BE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3369F102-ABB2-42A4-B216-58D530AEE8BE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3369F102-ABB2-42A4-B216-58D530AEE8BE}.Release|Any CPU.Build.0 = Release|Any CPU
+ {76BFAB65-B7AC-4534-A595-363551111129}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {76BFAB65-B7AC-4534-A595-363551111129}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {76BFAB65-B7AC-4534-A595-363551111129}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {76BFAB65-B7AC-4534-A595-363551111129}.Release|Any CPU.Build.0 = Release|Any CPU
+ {0A75ECEE-91C9-4A87-8573-4298DF0B6CDE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {0A75ECEE-91C9-4A87-8573-4298DF0B6CDE}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {0A75ECEE-91C9-4A87-8573-4298DF0B6CDE}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {0A75ECEE-91C9-4A87-8573-4298DF0B6CDE}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/DocumentServiceApi.InitQMessage/DocumentServiceApi.InitQMessage.csproj b/DocumentServiceApi.InitQMessage/DocumentServiceApi.InitQMessage.csproj
new file mode 100644
index 0000000..cd7176f
--- /dev/null
+++ b/DocumentServiceApi.InitQMessage/DocumentServiceApi.InitQMessage.csproj
@@ -0,0 +1,18 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+ <PropertyGroup>
+ <TargetFramework>net6.0</TargetFramework>
+ <ImplicitUsings>enable</ImplicitUsings>
+ <Nullable>enable</Nullable>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <PackageReference Include="InitQ" Version="1.0.0.15" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <ProjectReference Include="..\DocumentServiceAPI.Core\DocumentServiceAPI.Core.csproj" />
+ <ProjectReference Include="..\DocumentServiceAPI.Model\DocumentServiceAPI.Model.csproj" />
+ </ItemGroup>
+
+</Project>
diff --git a/DocumentServiceApi.InitQMessage/INITQMessageDefine.cs b/DocumentServiceApi.InitQMessage/INITQMessageDefine.cs
new file mode 100644
index 0000000..a95de16
--- /dev/null
+++ b/DocumentServiceApi.InitQMessage/INITQMessageDefine.cs
@@ -0,0 +1,24 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DocumentServiceApi.InitQMessage
+{
+ /// <summary>
+ /// 娑堟伅缁撴瀯瀹氫箟
+ /// </summary>
+ public static class INITQMessageDefine
+ {
+ /// <summary>
+ /// 璐叆Oder娑堟伅
+ /// </summary>
+ public const string InitTenantOder = "DocumentServiceAPI_OderINIT";
+
+ /// <summary>
+ /// 鎾ゅ崟
+ /// </summary>
+ public const string DecTenantOder = "DocumentServiceAPI_DecOderINIT";
+ }
+}
diff --git a/DocumentServiceApi.InitQMessage/INITQSetups.cs b/DocumentServiceApi.InitQMessage/INITQSetups.cs
new file mode 100644
index 0000000..bd9ce74
--- /dev/null
+++ b/DocumentServiceApi.InitQMessage/INITQSetups.cs
@@ -0,0 +1,48 @@
+锘縰sing CSRedis;
+using Furion;
+using InitQ;
+using Mapster;
+using Microsoft.AspNetCore.Builder;
+using Microsoft.AspNetCore.Hosting;
+using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.DependencyInjection;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DocumentServiceApi.InitQMessage
+{
+ /// <summary>
+ /// 娉ㄥ唽 INITQ
+ /// </summary>
+ public class DocServiceApiStartup : AppStartup
+ {
+ public void ConfigureServices(IServiceCollection services) {
+
+
+ var readisconnectionstring = App.Configuration["InitQRedisConfig:ConnectionString"];
+ if (readisconnectionstring != null)
+ //鍒濆鍖杛edi閰嶇疆
+ {
+ services.AddInitQ((op) =>
+ {
+ op.SuspendTime = 500;
+ op.IntervalTime = 500;
+ op.ConnectionString = readisconnectionstring;
+ op.ListSubscribe = new List<Type>() { typeof(MessageReceive) };
+ op.ShowLog = false;
+ });
+ }
+
+ }
+
+ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
+ {
+
+
+ }
+ }
+}
diff --git a/DocumentServiceApi.InitQMessage/MessageReceive.cs b/DocumentServiceApi.InitQMessage/MessageReceive.cs
new file mode 100644
index 0000000..39221e6
--- /dev/null
+++ b/DocumentServiceApi.InitQMessage/MessageReceive.cs
@@ -0,0 +1,181 @@
+锘縰sing DocumentServiceAPI.Model.Oder;
+using DocumentServiceAPI.Model.Permissions;
+using DocumentServiceAPI.Model.UserInfoModel;
+using Furion;
+using Furion.JsonSerialization;
+using Furion.Logging.Extensions;
+using InitQ.Abstractions;
+using InitQ.Attributes;
+using Microsoft.Extensions.Options;
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DocumentServiceApi.InitQMessage
+{
+ /// <summary>
+ /// 娑堟伅鎺ユ敹澶勭悊鍑芥暟
+ /// </summary>
+ public class MessageReceive: IRedisSubscribe
+ {
+
+
+ /// <summary>
+ /// 鍒濆鍖栬鍗曞鐞�
+ /// </summary>
+ /// <param name="msg"></param>
+ /// <returns></returns>
+ [Subscribe(INITQMessageDefine.InitTenantOder)]
+ private async Task InitTenantOder(string msg)
+ {
+ TenantOderInfo? obj = JSON.Deserialize<TenantOderInfo>(msg);
+ if(obj==null)
+ {
+ $"InitTenantOder 鍒濆鍖� msg 瀵硅薄閿欒 ,msg涓簕msg}".LogInformation<MessageReceive>();
+ return;
+ }
+ var _db= App.GetService<ISqlSugarClient>();
+
+
+ Oder oder = new Oder()
+ {
+ Amount = obj.Amount,
+ CreatBy = "娑堟伅闃熷垪 InitTenantOder",
+ CreatTime = DateTime.Now,
+ Description = obj.Description,
+ EmployeeCount = obj.EmployeeCount,
+ MonthCount = obj.MonthCount,
+ UnitCount = obj.UnitCount,
+ PayType = obj.PayType,
+ PayTime = obj.PayTime,
+ ZcUserID = obj.ZcUserID,
+ ITCode = obj.ITCode,
+ };
+ TenantInfo? Tinfo = await _db.Queryable<TenantInfo>().Where(x=>x.ZcUserID==obj.ZcUserID).SingleAsync();
+ if(Tinfo==null)
+ {
+ Tinfo = new TenantInfo
+ {
+ ZcUserID = obj.ZcUserID,
+ ItCode = obj.ITCode,
+ CreatBy = "娑堟伅闃熷垪 InitTenantOder",
+ CreatTime = DateTime.Now,
+ Description = obj.Description,
+ Name = obj.ITCode,
+ PsW = obj.ITCode.Substring(obj.ITCode.Length - 4),
+
+
+ };
+ TenantPermissions permissions = new TenantPermissions()
+ {
+ CreatBy = "娑堟伅闃熷垪 InitTenantOder",
+ CreatTime = DateTime.Now,
+ Description = obj.Description,
+ EmployeeMaxCount = obj.EmployeeCount ?? 0,
+ UnitMaxCount = obj.UnitCount ?? 0,
+ OverTime = DateTime.Now.AddMonths(obj.MonthCount ?? 0),
+
+
+
+ };
+ try
+ {
+ await _db.AsTenant().BeginTranAsync();
+
+ var id= await _db.Insertable(Tinfo).ExecuteReturnIdentityAsync();
+ permissions.TenantId = id;
+ await _db.Insertable(permissions).ExecuteCommandAsync ();
+ await _db.Insertable(oder).ExecuteCommandAsync();
+ await _db.AsTenant().CommitTranAsync();
+ }
+ catch (Exception e)
+ {
+ await _db.AsTenant().RollbackTranAsync();
+ $"鏂板缓绉熸埛澶勭悊澶辫触 msg:{msg},e:{e.ToString()} BY锛氭秷鎭槦鍒� InitTenantOder".LogInformation<MessageReceive>();
+ return;
+ }
+
+
+ }
+ else
+ {
+ Tinfo.ItCode = obj.ITCode;
+ Tinfo.UpdataBy = "娑堟伅闃熷垪 InitTenantOder";
+ Tinfo.UpdataTime = DateTime.Now;
+ Tinfo.IsDel = false;
+ Tinfo.IsEn = true;
+ var tp= await _db.Queryable<TenantPermissions>().Where(x=>x.TenantId==Tinfo.Id).FirstAsync();
+
+ try
+ {
+ await _db.AsTenant().BeginTranAsync();
+ if (Tinfo.ItCode != obj.ITCode)
+ {
+
+ await _db.Updateable(Tinfo).ExecuteCommandAsync();
+ };
+ if (tp == null)
+ {
+ tp = new TenantPermissions()
+ {
+ CreatBy = "娑堟伅闃熷垪 InitTenantOder",
+ CreatTime = DateTime.Now,
+ IsDel = false,
+ IsEn = true,
+ EmployeeMaxCount=obj.EmployeeCount??0,
+ UnitMaxCount=obj.UnitCount??0,
+ OverTime=DateTime.Now.AddMinutes(obj.MonthCount??0),
+ TenantId= Tinfo.Id,
+
+ };
+ await _db.Insertable(tp).ExecuteCommandAsync();
+
+
+ }
+ else
+ {
+ tp.IsDel = false;
+ tp.IsEn = true;
+ tp.UnitMaxCount = obj.UnitCount ?? tp.UnitMaxCount;
+ tp.EmployeeMaxCount = obj.EmployeeCount ?? tp.EmployeeMaxCount;
+ tp.OverTime = tp.OverTime.AddMonths(obj.MonthCount??0);
+ tp.UpdataBy = "娑堟伅闃熷垪 InitTenantOder";
+ tp.UpdataTime = DateTime.Now;
+
+ await _db.Updateable(tp).ExecuteCommandAsync();
+
+ }
+ await _db.Insertable(oder).ExecuteCommandAsync();
+ await _db.AsTenant().CommitTranAsync();
+
+
+
+
+
+ }
+ catch (Exception e)
+ {
+
+ await _db.AsTenant().RollbackTranAsync();
+ $"淇敼绉熸埛鏉冮檺澶辫触 msg:{msg},e:{e.ToString()} By锛氭秷鎭槦鍒� InitTenantOder".LogInformation<MessageReceive>();
+ return;
+ }
+
+ }
+
+
+
+
+
+
+
+
+
+
+ }
+
+ }
+}
diff --git a/DocumentServiceApi.InitQMessage/TenantOderInfo.cs b/DocumentServiceApi.InitQMessage/TenantOderInfo.cs
new file mode 100644
index 0000000..26eac2c
--- /dev/null
+++ b/DocumentServiceApi.InitQMessage/TenantOderInfo.cs
@@ -0,0 +1,60 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DocumentServiceApi.InitQMessage
+{
+ /// <summary>
+ /// 璁㈠崟娑堟伅妯″瀷璇︽儏
+ /// </summary>
+ internal class TenantOderInfo
+ {
+ /// <summary>
+ /// 鎵嬫満鍙风爜
+ /// </summary>
+ public string ITCode { get; set; }
+ /// <summary>
+ /// 鏀块噰鐢ㄦ埛涓績ID
+ /// </summary>
+ public Guid? ZcUserID { get; set; }
+ /// <summary>
+ /// 鏈堜唤
+ /// </summary>
+ [Display(Name = "鏈堜唤")]
+ public int? MonthCount { get; set; }
+
+ /// <summary>
+ /// 鍗曚綅涓暟
+ /// </summary>
+ [Display(Name = "鍗曚綅涓暟")]
+ public int? UnitCount { get; set; }
+
+ /// <summary>
+ /// 鍛樺伐
+ /// </summary>
+ [Display(Name = "鍛樺伐涓暟")]
+ public int? EmployeeCount { get; set; }
+ /// <summary>
+ /// 鍗曚环
+ /// </summary>
+ [Display(Name = "閲戦")]
+ public decimal Amount { get; set; }
+ /// <summary>
+ /// 鏀粯鏂瑰紡
+ /// </summary>
+ public string? PayType { get; set; }
+ /// <summary>
+ /// 鏀粯鏃堕棿
+ /// </summary>
+ public DateTime? PayTime { get; set; }
+ /// <summary>
+ /// 鎻忚堪
+ /// </summary>
+ public string? Description { get; set; }
+
+
+ }
+}
diff --git a/ZcPayCore/Model/OderInfo.cs b/ZcPayCore/Model/OderInfo.cs
new file mode 100644
index 0000000..094f2f9
--- /dev/null
+++ b/ZcPayCore/Model/OderInfo.cs
@@ -0,0 +1,55 @@
+锘縰sing DocumentServiceAPI.Enum;
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ZcPayCore.Model
+{
+ /// <summary>
+ /// 閫氱敤璁㈠崟绫�
+ /// </summary>
+ [Display(Name = "閫氱敤璁㈠崟绫� ")]
+ [SugarTable(TableName = "Oder", TableDescription = "閫氱敤璁㈠崟绫�")]
+ public class Oder : BaseModel
+ {
+ /// <summary>
+ /// Id
+ /// </summary>
+ [Display(Name = "Id ")]
+ [SugarColumn(ColumnDescription = "Id ",IsIdentity =true,IsPrimaryKey =true)]
+ public int Id { get; set; }
+
+ /// <summary>
+ /// 鐢ㄦ埛ID 涔熷彲鑳芥槸绉熸埛ID
+ /// </summary>
+ [Display(Name = "鐢ㄦ埛ID 涔熷彲鑳芥槸绉熸埛ID ")]
+ [SugarColumn(ColumnDescription = "鐢ㄦ埛ID 涔熷彲鑳芥槸绉熸埛ID ")]
+ public int UserID { get; set; }
+
+ /// <summary>
+ /// 璁㈠崟璇︽儏鎻忚堪
+ /// </summary>
+ [Display(Name = "璁㈠崟璇︽儏鎻忚堪 ")]
+ [SugarColumn(ColumnDescription = "璁㈠崟璇︽儏鎻忚堪 ")]
+ public string? Description { get; set; }
+
+ /// <summary>
+ /// 鍏朵粬鍙傛暟
+ /// </summary>
+ [Display(Name = "鍏朵粬鍙傛暟 ")]
+ [SugarColumn(ColumnDescription = "鍏朵粬鍙傛暟 ")]
+ public string? Param { get; set; }
+
+ /// <summary>
+ /// PropertyDecName
+ /// </summary>
+ [Display(Name = "PropertyDecName ")]
+ [SugarColumn(ColumnDescription = "PropertyDecName ")]
+ public int Property { get; set; }
+
+ }
+}
diff --git a/ZcPayCore/ZcPayCore.csproj b/ZcPayCore/ZcPayCore.csproj
new file mode 100644
index 0000000..0f64f88
--- /dev/null
+++ b/ZcPayCore/ZcPayCore.csproj
@@ -0,0 +1,20 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+ <PropertyGroup>
+ <TargetFramework>net6.0</TargetFramework>
+ <ImplicitUsings>enable</ImplicitUsings>
+ <Nullable>enable</Nullable>
+ </PropertyGroup>
+
+ <ItemGroup>
+ <PackageReference Include="Essensoft.Paylink.Alipay" Version="4.1.2" />
+ <PackageReference Include="Essensoft.Paylink.Security" Version="4.1.2" />
+ <PackageReference Include="Essensoft.Paylink.WeChatPay" Version="4.1.2" />
+ <PackageReference Include="SqlSugarCore" Version="5.1.4.99" />
+ </ItemGroup>
+
+ <ItemGroup>
+ <ProjectReference Include="..\DocumentServiceAPI.Enum\DocumentServiceAPI.Enum.csproj" />
+ </ItemGroup>
+
+</Project>
--
Gitblit v1.9.1