Merge remote-tracking branch 'upstream/v2' into v2
This commit is contained in:
commit
b34515bfec
@ -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;
|
||||
|
||||
@ -94,13 +94,13 @@ public partial class SysWechatPay : EntityBase
|
||||
/// 支付完成时间
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "支付完成时间")]
|
||||
public DateTimeOffset? SuccessTime { get; set; }
|
||||
public DateTime? SuccessTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 交易结束时间
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "交易结束时间")]
|
||||
public DateTimeOffset? ExpireTime { get; set; }
|
||||
public DateTime? ExpireTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 商品描述
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -46,12 +46,12 @@ public class WechatPayOutput
|
||||
/// <summary>
|
||||
/// 支付发起时间
|
||||
/// </summary>
|
||||
public DateTimeOffset CreateTime { get; set; }
|
||||
public DateTime CreateTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 支付完成时间
|
||||
/// </summary>
|
||||
public DateTimeOffset SuccessTime { get; set; }
|
||||
public DateTime SuccessTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 交易状态(支付成功后,微信返回)
|
||||
|
||||
@ -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<Exception>($"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<WechatPayOutput>();
|
||||
}
|
||||
@ -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<WechatPayOutput>();
|
||||
}
|
||||
@ -720,7 +720,7 @@ public class SysWechatPayService : IDynamicApiController, ITransient
|
||||
/// 根据支付Id获取退款信息列表 🔖
|
||||
/// </summary>
|
||||
/// <param name="transactionId"></param>
|
||||
/// <param name="outTradeNumber"><</param>
|
||||
/// <param name="outTradeNumber"></param>
|
||||
/// <returns></returns>
|
||||
[DisplayName("根据支付Id获取退款信息列表")]
|
||||
public async Task<List<SysWechatRefund>> GetRefundList([FromQuery] string transactionId, [FromQuery] string outTradeNumber)
|
||||
|
||||
@ -91,7 +91,7 @@ public class AggregationBuilder
|
||||
/// <summary>
|
||||
/// 验证字段有效性
|
||||
/// </summary>
|
||||
public static List<string> ValidateFields(string[] fields, Type targetType)
|
||||
public static List<string> ValidateFields<T>(string[] fields, Type targetType)
|
||||
{
|
||||
if (fields == null || fields.Length == 0) return new List<string>();
|
||||
|
||||
@ -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();
|
||||
}
|
||||
|
||||
@ -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<T, @(@Model.ClassName)>().IgnoreNullValues(true);
|
||||
_sysCacheService = sysCacheService;
|
||||
_eventPublisher = eventPublisher;
|
||||
_userManager = userManager;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -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")){
|
||||
@:/// <summary>
|
||||
@:/// 获取@(@Model.BusName)
|
||||
@:/// </summary>
|
||||
@:/// <param name="input"></param>
|
||||
@:/// <returns></returns>
|
||||
@:[ApiDescriptionSettings(Name = "GetTotalSum", Description = "获取@(@Model.BusName)统计", Order = 960), HttpPost]
|
||||
@:[DisplayName("获取@(@Model.BusName)统计")]
|
||||
@:public async Task<List<@(@Model.ClassName)Output>> GetTotalSum(Page@(@Model.ClassName)Input input)
|
||||
@:{
|
||||
@:// 单次查询同时获取统计值
|
||||
@:var querystats = @(@Model.ClassName)Mid.GetQuery(_@(@Model.LowerClassName)Rep, input)
|
||||
/// <summary>
|
||||
/// 获取@(@Model.BusName)
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[ApiDescriptionSettings(Name = "GetTotalSum", Description = "获取@(@Model.BusName)统计", Order = 960), HttpPost]
|
||||
[DisplayName("获取@(@Model.BusName)统计")]
|
||||
public async Task<List<@(@Model.ClassName)Output>> 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();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据输入参数获取@(@Model.BusName)统计
|
||||
@ -220,7 +233,7 @@ if (@column.ColumnKey == "True"){
|
||||
public async Task<List<@(@Model.ClassName)Output>> 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));
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user