diff --git a/Admin.NET/Admin.NET.Application/GlobalUsings.cs b/Admin.NET/Admin.NET.Application/GlobalUsings.cs
index 7dd67391..240076ed 100644
--- a/Admin.NET/Admin.NET.Application/GlobalUsings.cs
+++ b/Admin.NET/Admin.NET.Application/GlobalUsings.cs
@@ -5,6 +5,7 @@
// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任!
global using Admin.NET.Core;
+global using Admin.NET.Core.Utils;
global using Furion;
global using Furion.DependencyInjection;
global using Furion.DynamicApiController;
diff --git a/Admin.NET/Admin.NET.Core/Entity/SysWechatPay.cs b/Admin.NET/Admin.NET.Core/Entity/SysWechatPay.cs
index 5e07a4af..46286bf1 100644
--- a/Admin.NET/Admin.NET.Core/Entity/SysWechatPay.cs
+++ b/Admin.NET/Admin.NET.Core/Entity/SysWechatPay.cs
@@ -94,13 +94,13 @@ public partial class SysWechatPay : EntityBase
/// 支付完成时间
///
[SugarColumn(ColumnDescription = "支付完成时间")]
- public DateTimeOffset? SuccessTime { get; set; }
+ public DateTime? SuccessTime { get; set; }
///
/// 交易结束时间
///
[SugarColumn(ColumnDescription = "交易结束时间")]
- public DateTimeOffset? ExpireTime { get; set; }
+ public DateTime? ExpireTime { get; set; }
///
/// 商品描述
diff --git a/Admin.NET/Admin.NET.Core/GlobalUsings.cs b/Admin.NET/Admin.NET.Core/GlobalUsings.cs
index 29633ba0..6e454d65 100644
--- a/Admin.NET/Admin.NET.Core/GlobalUsings.cs
+++ b/Admin.NET/Admin.NET.Core/GlobalUsings.cs
@@ -5,6 +5,7 @@
// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任!
global using Admin.NET.Core.Service;
+global using Admin.NET.Core.Utils;
global using Furion;
global using Furion.ConfigurableOptions;
global using Furion.DatabaseAccessor;
diff --git a/Admin.NET/Admin.NET.Core/Service/Wechat/Dto/WechatPayOutput.cs b/Admin.NET/Admin.NET.Core/Service/Wechat/Dto/WechatPayOutput.cs
index 108d75d2..5e2bc2e2 100644
--- a/Admin.NET/Admin.NET.Core/Service/Wechat/Dto/WechatPayOutput.cs
+++ b/Admin.NET/Admin.NET.Core/Service/Wechat/Dto/WechatPayOutput.cs
@@ -46,12 +46,12 @@ public class WechatPayOutput
///
/// 支付发起时间
///
- public DateTimeOffset CreateTime { get; set; }
+ public DateTime CreateTime { get; set; }
///
/// 支付完成时间
///
- public DateTimeOffset SuccessTime { get; set; }
+ public DateTime SuccessTime { get; set; }
///
/// 交易状态(支付成功后,微信返回)
diff --git a/Admin.NET/Admin.NET.Core/Service/Wechat/SysWechatPayService.cs b/Admin.NET/Admin.NET.Core/Service/Wechat/SysWechatPayService.cs
index 095abdf7..a7a4fcb5 100644
--- a/Admin.NET/Admin.NET.Core/Service/Wechat/SysWechatPayService.cs
+++ b/Admin.NET/Admin.NET.Core/Service/Wechat/SysWechatPayService.cs
@@ -304,7 +304,7 @@ public class SysWechatPayService : IDynamicApiController, ITransient
if (wechatPayOld == null || wechatPayOld.TradeState != wechatPayNew.TradeState)
{
// 没必要等所有回调事件处理完再返回给微信,开一个Task执行
- Task.Run(async () =>
+ _ = Task.Run(async () =>
{
foreach (var eh in wechatPayEventHandlers)
{
@@ -318,7 +318,7 @@ public class SysWechatPayService : IDynamicApiController, ITransient
$"GetPayInfoFromWechat 中执行微信支付回调{eh.GetType().Name}出错".LogError(ex);
}
}
- }).Start();
+ });
}
// 下面这里创建一个新的对象,是因为不想把全部字段都返回
wechatPayNew = new SysWechatPay()
@@ -372,13 +372,13 @@ public class SysWechatPayService : IDynamicApiController, ITransient
wechatPayNew.BankType = callbackResource.BankType; // 付款银行类型
wechatPayNew.Total = callbackResource.Amount.Total; // 订单总金额
wechatPayNew.PayerTotal = callbackResource.Amount.PayerTotal; // 用户支付金额
- wechatPayNew.SuccessTime = callbackResource.SuccessTime; // 支付完成时间
+ wechatPayNew.SuccessTime = callbackResource.SuccessTime.DateTime; // 支付完成时间
await _sysWechatPayRep.AsUpdateable(wechatPayNew).IgnoreColumns(true).ExecuteCommandAsync();
// 因为这个是回调给微信的,所以这里没必要等所有回调事件处理完再返回给微信,开一个Task执行
if (wechatPayOld.TradeState != wechatPayNew.TradeState)
{
- Task.Run(async () =>
+ _ = Task.Run(async () =>
{
foreach (var eh in wechatPayEventHandlers)
{
@@ -392,7 +392,7 @@ public class SysWechatPayService : IDynamicApiController, ITransient
$"PayCallBack 中执行微信支付回调{eh.GetType().Name}出错".LogError(ex);
}
}
- }).Start();
+ });
}
return new WechatPayOutput()
{
@@ -484,13 +484,13 @@ public class SysWechatPayService : IDynamicApiController, ITransient
wechatPayNew.BankType = callbackResource.BankType; // 付款银行类型
wechatPayNew.Total = callbackResource.Amount.Total; // 订单总金额
wechatPayNew.PayerTotal = callbackResource.Amount.PayerTotal; // 用户支付金额
- wechatPayNew.SuccessTime = callbackResource.SuccessTime; // 支付完成时间
+ wechatPayNew.SuccessTime = callbackResource.SuccessTime.DateTime; // 支付完成时间
await _sysWechatPayRep.AsUpdateable(wechatPayNew).IgnoreColumns(true).ExecuteCommandAsync();
// 因为这个是回调给微信的,所以这里没必要等所有回调事件处理完再返回给微信,开一个Task执行
if (wechatPayOld.TradeState != wechatPayNew.TradeState)
{
- Task.Run(async () =>
+ _ = Task.Run(async () =>
{
foreach (var eh in wechatPayEventHandlers)
{
@@ -504,7 +504,7 @@ public class SysWechatPayService : IDynamicApiController, ITransient
$"PayPartnerCallBack 中执行微信支付回调{eh.GetType().Name}出错".LogError(ex);
}
}
- }).Start();
+ });
}
}
}
@@ -544,7 +544,7 @@ public class SysWechatPayService : IDynamicApiController, ITransient
{
await this.GetPayInfoFromWechat(input.OutTradeNumber);
}
- catch (Exception ex) { }
+ catch { }
throw Oops.Oh($"JSAPI 退款申请失败(状态码:{response.GetRawStatus()},错误代码:{response.ErrorCode},错误描述:{response.ErrorMessage})");
}
@@ -628,7 +628,7 @@ public class SysWechatPayService : IDynamicApiController, ITransient
wechatPay.OpenId = response.Payer?.OpenId;// 付款用户OpenId
wechatPay.BankType = response.BankType; // 付款银行类型
wechatPay.PayerTotal = response.Amount?.PayerTotal; // 用户支付金额
- wechatPay.SuccessTime = response.SuccessTime; // 支付完成时间
+ wechatPay.SuccessTime = response.SuccessTime?.DateTime; // 支付完成时间
await _sysWechatPayRep.AsUpdateable(wechatPay).IgnoreColumns(true).ExecuteCommandAsync();
return wechatPay.Adapt();
}
@@ -671,7 +671,7 @@ public class SysWechatPayService : IDynamicApiController, ITransient
wechatPay.OpenId = response.Payer?.OpenId;// 付款用户OpenId
wechatPay.BankType = response.BankType; // 付款银行类型
wechatPay.PayerTotal = response.Amount?.PayerTotal; // 用户支付金额
- wechatPay.SuccessTime = response.SuccessTime; // 支付完成时间
+ wechatPay.SuccessTime = response.SuccessTime?.DateTime; // 支付完成时间
await _sysWechatPayRep.AsUpdateable(wechatPay).IgnoreColumns(true).ExecuteCommandAsync();
return wechatPay.Adapt();
}
@@ -720,7 +720,7 @@ public class SysWechatPayService : IDynamicApiController, ITransient
/// 根据支付Id获取退款信息列表 🔖
///
///
- /// <
+ ///
///
[DisplayName("根据支付Id获取退款信息列表")]
public async Task> GetRefundList([FromQuery] string transactionId, [FromQuery] string outTradeNumber)
diff --git a/Admin.NET/Admin.NET.Core/Utils/AggregationBuilder.cs b/Admin.NET/Admin.NET.Core/Utils/AggregationBuilder.cs
index 235346ac..87bfda5f 100644
--- a/Admin.NET/Admin.NET.Core/Utils/AggregationBuilder.cs
+++ b/Admin.NET/Admin.NET.Core/Utils/AggregationBuilder.cs
@@ -91,7 +91,7 @@ public class AggregationBuilder
///
/// 验证字段有效性
///
- public static List ValidateFields(string[] fields, Type targetType)
+ public static List ValidateFields(string[] fields, Type targetType)
{
if (fields == null || fields.Length == 0) return new List();
@@ -99,7 +99,7 @@ public class AggregationBuilder
.Where(f => !string.IsNullOrWhiteSpace(f))
.Select(f => f.Trim())
.Where(f => targetType.GetProperty(
- targetType == typeof(UsagetokenOutput) ?
+ targetType == typeof(T) ?
$"{f}Sum" : f) != null)
.ToList();
}
diff --git a/Admin.NET/Admin.NET.Web.Entry/wwwroot/template/service_Service.cs.vm b/Admin.NET/Admin.NET.Web.Entry/wwwroot/template/service_Service.cs.vm
index 22a284d8..084ab550 100644
--- a/Admin.NET/Admin.NET.Web.Entry/wwwroot/template/service_Service.cs.vm
+++ b/Admin.NET/Admin.NET.Web.Entry/wwwroot/template/service_Service.cs.vm
@@ -26,7 +26,6 @@ using OfficeOpenXml.FormulaParsing.Excel.Functions.Text;
}
}
}
-using @(@Model.NameSpace).Entity;
namespace @Model.NameSpace;
@@ -36,18 +35,28 @@ namespace @Model.NameSpace;
[ApiDescriptionSettings(@(@Model.ProjectLastName)Const.GroupName, Name = "@(@Model.LowerClassName)", Order = 100)]
public partial class @(@Model.ClassName)Service : IDynamicApiController, ITransient
{
+ private readonly SysCacheService _sysCacheService;//默认CacheService
+ private readonly UserManager _userManager;//默认用户管理
+ private readonly IEventPublisher _eventPublisher;//默认事件总线
private readonly SqlSugarRepository<@(@Model.ClassName)> _@(@Model.LowerClassName)Rep;
@foreach (var column in Model.TableField){
if(@column.EffectType == "ForeignKey"||@column.EffectType == "ApiTreeSelector"){
+ if(@column.FkEntityName != @Model.ClassName){
@:private readonly SqlSugarRepository<@(@column.FkEntityName)> _@(@column.LowerFkEntityName)Rep;
+ }
}
}
private TypeAdapterConfig _typeAdapterConfig = TypeAdapterConfig.GlobalSettings;
public @(@Model.ClassName)Service(SqlSugarRepository<@(@Model.ClassName)> @(@Model.LowerClassName)Rep
+ ,SysCacheService sysCacheService
+ , UserManager userManager
+ ,IEventPublisher eventPublisher
@foreach (var column in Model.TableField){
if(@column.EffectType == "ForeignKey"||@column.EffectType == "ApiTreeSelector"){
+ if(@column.FkEntityName != @Model.ClassName){
@:,SqlSugarRepository<@(@column.FkEntityName)> @(@column.LowerFkEntityName)Rep
+ }
}
}
@@ -56,10 +65,15 @@ public partial class @(@Model.ClassName)Service : IDynamicApiController, ITransi
_@(@Model.LowerClassName)Rep = @(@Model.LowerClassName)Rep;
@foreach (var column in Model.TableField){
if(@column.EffectType == "ForeignKey"||@column.EffectType == "ApiTreeSelector"){
+ if(@column.FkEntityName != @Model.ClassName){
@:_@(@column.LowerFkEntityName)Rep = @(@column.LowerFkEntityName)Rep;
+ }
}
}
_typeAdapterConfig.ForType().IgnoreNullValues(true);
+ _sysCacheService = sysCacheService;
+ _eventPublisher = eventPublisher;
+ _userManager = userManager;
}
///
@@ -168,28 +182,28 @@ if (@column.ColumnKey == "True"){
return await @(@Model.ClassName)Mid.GetQuery(_@(@Model.LowerClassName)Rep, input).OrderBuilder(input).ToListAsync();
}
-@if(@Model.TableField.Any(x=>x.Statistical == "Y")){
- @:///
- @:/// 获取@(@Model.BusName)
- @:///
- @:///
- @:///
- @:[ApiDescriptionSettings(Name = "GetTotalSum", Description = "获取@(@Model.BusName)统计", Order = 960), HttpPost]
- @:[DisplayName("获取@(@Model.BusName)统计")]
- @:public async Task> GetTotalSum(Page@(@Model.ClassName)Input input)
- @:{
- @:// 单次查询同时获取统计值
- @:var querystats = @(@Model.ClassName)Mid.GetQuery(_@(@Model.LowerClassName)Rep, input)
+ ///
+ /// 获取@(@Model.BusName)
+ ///
+ ///
+ ///
+ [ApiDescriptionSettings(Name = "GetTotalSum", Description = "获取@(@Model.BusName)统计", Order = 960), HttpPost]
+ [DisplayName("获取@(@Model.BusName)统计")]
+ public async Task> GetTotalSum(Page@(@Model.ClassName)Input input)
+ {
+ // 单次查询同时获取统计值
+ var querystats = @(@Model.ClassName)Mid.GetQuery(_@(@Model.LowerClassName)Rep, input)
+ @if(@Model.TableField.Any(x=>x.IsGroupBy == "Y")){
@foreach (var column in Model.TableField){
if (@column.IsGroupBy == "Y"){
@: .GroupByIF(input.GroupBy.Contains("@column.PropertyName"), u => u.@column.PropertyName)
}
}
@: //.Having(it => SqlFunc.AggregateCount(it.Id) > 0)//聚合函数过滤
- @: .Select(it => new @(@Model.ClassName)Output
- @: {
- @: count = SqlFunc.AggregateCount(it.Id),
-
+ }
+ .Select(it => new @(@Model.ClassName)Output
+ {
+ count = SqlFunc.AggregateCount(it.Id),
@foreach (var column in Model.TableField){
if (@column.IsGroupBy == "Y"){
@: @(@column.PropertyName) = it.@(@column.PropertyName),
@@ -198,10 +212,9 @@ if (@column.ColumnKey == "True"){
@: @(@column.PropertyName) = SqlFunc.AggregateSum(it.@(@column.PropertyName)) ?? 0,
}
}
- @: });
- @:return await querystats.ToListAsync();
- @:}
-}
+ });
+ return await querystats.ToListAsync();
+ }
///
/// 根据输入参数获取@(@Model.BusName)统计
@@ -220,7 +233,7 @@ if (@column.ColumnKey == "True"){
public async Task> GetAggregTotalSum(Page@(@Model.ClassName)Input input)
{
- @:var query = @(@Model.ClassName)Mid.GetQuery(_@(@Model.LowerClassName)Rep, input)
+ var query = @(@Model.ClassName)Mid.GetQuery(_@(@Model.LowerClassName)Rep, input);
// 输入参数示例
//input = new Page@(@Model.ClassName)Input
//{
@@ -253,7 +266,7 @@ if (@column.ColumnKey == "True"){
// HAVING(SUM(cost) > 10000) AND(AVG(CAST(response_time AS FLOAT)) < 500)
// 处理分组字段
- var groupFields = AggregationBuilder.ValidateFields(input.GroupBy, typeof(@(@Model.ClassName)Output));
+ var groupFields = AggregationBuilder.ValidateFields<@(@Model.ClassName)Output>(input.GroupBy, typeof(@(@Model.ClassName)Output));
if (groupFields.Count > 0)
{
query = query.GroupBy(string.Join(",", groupFields));
diff --git a/Admin.NET/Admin.NET.Web.Entry/wwwroot/template/web_views_List.vue.vm b/Admin.NET/Admin.NET.Web.Entry/wwwroot/template/web_views_List.vue.vm
index db8effb6..4e25d530 100644
--- a/Admin.NET/Admin.NET.Web.Entry/wwwroot/template/web_views_List.vue.vm
+++ b/Admin.NET/Admin.NET.Web.Entry/wwwroot/template/web_views_List.vue.vm
@@ -401,7 +401,6 @@ const handleQuery = async (reset = false) => {
@if(@Model.TableField.Any(x=>x.Statistical == "Y")){
@if (@Model.IsApiService) {
@:state.totalSum =getAPI(@(@Model.ClassName)Api).api@(@Model.ClassName)GetTotalSumPost(params).data.result;
- }
} else {
@:state.totalSum =(await get@(@Model.ClassName)TotalSum(state.queryParams)).data.result;
}