-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 查询
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 待审核
+
+
+ 审核通过
+
+
+ 审核驳回
+
+
+
+
+
+
+
+
+ 未转账
+
+
+ 已转账
+
+
+ 转账失败
+
+
+
+
+
+ 查询
重置
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
{{ statsData.pendingCount || 0 }}
+
待审核
+
+
+
+
+
+
+
+
+
+
+
+
{{ statsData.approvedCount || 0 }}
+
审核通过
+
+
+
+
+
+
+
+
+
+
+
+
{{ statsData.transferredCount || 0 }}
+
已转账
+
+
+
+
+
+
+
+
+
+
+
+
¥{{ statsData.totalAmount || 0 }}
+
总金额
+
+
+
+
+
-
-
新增
+
+
提现申请管理
@@ -33,51 +124,116 @@
-
-
-
-
-
-
-
-
- 编辑
- 删除
+
+
+
+ {{ scope.row.walletNo }}
+
+
+
+
+ ¥{{ scope.row.amount }}
+
+
+
+
+
+ {{ formatBankCard(scope.row.bankAccountNumber) }}
+
+
+
+
+
+ {{ formatDateTime(scope.row.applyTime) }}
+ -
+
+
+
+
+
+ 待审核
+
+
+ 审核通过
+
+
+ 审核驳回
+
+ 未知
+
+
+
+
+
+ 未转账
+
+
+ 已转账
+
+
+ 转账失败
+
+ 未知
+
+
+
+
+ {{ formatDateTime(scope.row.transferTime) }}
+ -
+
+
+
+
+ 详情
+ 审核
+ 处理
-
+
+
\ No newline at end of file
+
+
+
\ No newline at end of file
diff --git a/netcore/src/.DS_Store b/netcore/src/.DS_Store
index 9f75ce5..17ffdf9 100644
--- a/netcore/src/.DS_Store
+++ b/netcore/src/.DS_Store
diff --git a/netcore/src/Application/.DS_Store b/netcore/src/Application/.DS_Store
index b83c3eb..5d08f80 100644
--- a/netcore/src/Application/.DS_Store
+++ b/netcore/src/Application/.DS_Store
diff --git a/netcore/src/Application/NCC.API/.DS_Store b/netcore/src/Application/NCC.API/.DS_Store
index 785875a..18b3f1c 100644
--- a/netcore/src/Application/NCC.API/.DS_Store
+++ b/netcore/src/Application/NCC.API/.DS_Store
diff --git a/netcore/src/Modularity/Extend/NCC.Extend.Entitys/uavSite/Dto/UavSiteListOutput.cs b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/uavSite/Dto/UavSiteListOutput.cs
index 469163d..176e54e 100644
--- a/netcore/src/Modularity/Extend/NCC.Extend.Entitys/uavSite/Dto/UavSiteListOutput.cs
+++ b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/uavSite/Dto/UavSiteListOutput.cs
@@ -42,5 +42,15 @@ namespace NCC.Extend.Entitys.Dto.UavSite
///
public string creatorId { get; set; }
+ ///
+ /// 创建用户名称
+ ///
+ public string creatorName { get; set; }
+
+ ///
+ /// 绑定的机柜数量
+ ///
+ public int deviceCount { get; set; }
+
}
}
diff --git a/netcore/src/Modularity/Extend/NCC.Extend.Entitys/uavWalletWithdrawApply/Dto/UavWalletWithdrawApplyAuditDetailOutput.cs b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/uavWalletWithdrawApply/Dto/UavWalletWithdrawApplyAuditDetailOutput.cs
new file mode 100644
index 0000000..22e541d
--- /dev/null
+++ b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/uavWalletWithdrawApply/Dto/UavWalletWithdrawApplyAuditDetailOutput.cs
@@ -0,0 +1,91 @@
+using System;
+using System.Collections.Generic;
+
+namespace NCC.Extend.Entitys.Dto.UavWalletWithdrawApply
+{
+ ///
+ /// 提现申请审核详情输出参数
+ ///
+ public class UavWalletWithdrawApplyAuditDetailOutput
+ {
+ ///
+ /// 主键ID
+ ///
+ public string id { get; set; }
+
+ ///
+ /// 申请人用户ID
+ ///
+ public string userId { get; set; }
+
+ ///
+ /// 提现金额
+ ///
+ public decimal amount { get; set; }
+
+ ///
+ /// 申请时间
+ ///
+ public DateTime? applyTime { get; set; }
+
+ ///
+ /// 审核状态(0待审核,1通过,2驳回)
+ ///
+ public int? auditStatus { get; set; }
+
+ ///
+ /// 审核时间
+ ///
+ public DateTime? auditTime { get; set; }
+
+ ///
+ /// 审核人用户ID
+ ///
+ public string auditUserId { get; set; }
+
+ ///
+ /// 驳回原因
+ ///
+ public string rejectReason { get; set; }
+
+ ///
+ /// 转账状态(0未转账,1已转账,2失败)
+ ///
+ public int? transferStatus { get; set; }
+
+ ///
+ /// 转账时间
+ ///
+ public DateTime? transferTime { get; set; }
+
+ ///
+ /// 转账备注或失败原因
+ ///
+ public string transferRemark { get; set; }
+
+ ///
+ /// 收款账户户名
+ ///
+ public string bankAccountName { get; set; }
+
+ ///
+ /// 收款账户卡号
+ ///
+ public string bankAccountNumber { get; set; }
+
+ ///
+ /// 收款银行名称
+ ///
+ public string bankName { get; set; }
+
+ ///
+ /// 提现申请号
+ ///
+ public string walletNo { get; set; }
+
+ ///
+ /// 用户当前余额
+ ///
+ public decimal userBalance { get; set; }
+ }
+}
diff --git a/netcore/src/Modularity/Extend/NCC.Extend.Entitys/uavWalletWithdrawApply/Dto/UavWalletWithdrawApplyAuditInput.cs b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/uavWalletWithdrawApply/Dto/UavWalletWithdrawApplyAuditInput.cs
new file mode 100644
index 0000000..6023008
--- /dev/null
+++ b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/uavWalletWithdrawApply/Dto/UavWalletWithdrawApplyAuditInput.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+
+namespace NCC.Extend.Entitys.Dto.UavWalletWithdrawApply
+{
+ ///
+ /// 提现申请审核输入参数
+ ///
+ public class UavWalletWithdrawApplyAuditInput
+ {
+ ///
+ /// 审核状态(1通过,2驳回)
+ ///
+ public int auditStatus { get; set; }
+
+ ///
+ /// 驳回原因(驳回时必填)
+ ///
+ public string rejectReason { get; set; }
+ }
+}
diff --git a/netcore/src/Modularity/Extend/NCC.Extend.Entitys/uavWalletWithdrawApply/Dto/UavWalletWithdrawApplyListOutput.cs b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/uavWalletWithdrawApply/Dto/UavWalletWithdrawApplyListOutput.cs
index fad3e86..efce075 100644
--- a/netcore/src/Modularity/Extend/NCC.Extend.Entitys/uavWalletWithdrawApply/Dto/UavWalletWithdrawApplyListOutput.cs
+++ b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/uavWalletWithdrawApply/Dto/UavWalletWithdrawApplyListOutput.cs
@@ -37,5 +37,30 @@ namespace NCC.Extend.Entitys.Dto.UavWalletWithdrawApply
///
public string walletNo { get; set; }
+ ///
+ /// 申请时间
+ ///
+ public DateTime? applyTime { get; set; }
+
+ ///
+ /// 审核状态(0待审核,1通过,2驳回)
+ ///
+ public int? auditStatus { get; set; }
+
+ ///
+ /// 审核时间
+ ///
+ public DateTime? auditTime { get; set; }
+
+ ///
+ /// 转账状态(0未转账,1已转账,2失败)
+ ///
+ public int? transferStatus { get; set; }
+
+ ///
+ /// 转账时间
+ ///
+ public DateTime? transferTime { get; set; }
+
}
}
diff --git a/netcore/src/Modularity/Extend/NCC.Extend.Entitys/uavWalletWithdrawApply/Dto/UavWalletWithdrawApplyListQueryInput.cs b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/uavWalletWithdrawApply/Dto/UavWalletWithdrawApplyListQueryInput.cs
index 39f8108..00e17b4 100644
--- a/netcore/src/Modularity/Extend/NCC.Extend.Entitys/uavWalletWithdrawApply/Dto/UavWalletWithdrawApplyListQueryInput.cs
+++ b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/uavWalletWithdrawApply/Dto/UavWalletWithdrawApplyListQueryInput.cs
@@ -29,5 +29,15 @@ namespace NCC.Extend.Entitys.Dto.UavWalletWithdrawApply
///
public string walletNo { get; set; }
+ ///
+ /// 审核状态筛选(0待审核,1通过,2驳回)
+ ///
+ public int? auditStatus { get; set; }
+
+ ///
+ /// 转账状态筛选(0未转账,1已转账,2失败)
+ ///
+ public int? transferStatus { get; set; }
+
}
}
diff --git a/netcore/src/Modularity/Extend/NCC.Extend.Entitys/uavWalletWithdrawApply/Dto/UavWalletWithdrawApplyProcessInput.cs b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/uavWalletWithdrawApply/Dto/UavWalletWithdrawApplyProcessInput.cs
new file mode 100644
index 0000000..8be74b5
--- /dev/null
+++ b/netcore/src/Modularity/Extend/NCC.Extend.Entitys/uavWalletWithdrawApply/Dto/UavWalletWithdrawApplyProcessInput.cs
@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+
+namespace NCC.Extend.Entitys.Dto.UavWalletWithdrawApply
+{
+ ///
+ /// 提现申请处理输入参数
+ ///
+ public class UavWalletWithdrawApplyProcessInput
+ {
+ ///
+ /// 转账状态(1已转账,2失败)
+ ///
+ public int transferStatus { get; set; }
+
+ ///
+ /// 转账时间
+ ///
+ public DateTime? transferTime { get; set; }
+
+ ///
+ /// 转账备注或失败原因
+ ///
+ public string transferRemark { get; set; }
+ }
+}
diff --git a/netcore/src/Modularity/Extend/NCC.Extend/MqttPublisherService.cs b/netcore/src/Modularity/Extend/NCC.Extend/MqttPublisherService.cs
index f2c00f7..c5b6f79 100644
--- a/netcore/src/Modularity/Extend/NCC.Extend/MqttPublisherService.cs
+++ b/netcore/src/Modularity/Extend/NCC.Extend/MqttPublisherService.cs
@@ -65,7 +65,7 @@ public class MqttPublisherService : IMqttPublisherService, ITransient, IDisposab
///
private readonly IMqttClientOptions _mqttOptions;
private readonly IServiceProvider _serviceProvider;
- private readonly ISqlSugarClient _db;
+ private ISqlSugarClient _db => _serviceProvider.GetRequiredService
();
private readonly Dictionary _onlineStatusCache = new Dictionary();
private readonly object _cacheLock = new object();
private readonly Timer _healthCheckTimer; // 健康检查定时器
@@ -114,10 +114,10 @@ public class MqttPublisherService : IMqttPublisherService, ITransient, IDisposab
///
/// 构造函数:初始化客户端和配置、注册事件
///
- public MqttPublisherService(IServiceProvider serviceProvider, ISqlSugarClient db)
+ public MqttPublisherService(IServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider;
- _db = db;
+ // 延迟获取 ISqlSugarClient,避免在构造函数中从根提供者获取 Scoped 服务
// 创建 MQTT 客户端实例
var factory = new MqttFactory();
_mqttClient = factory.CreateMqttClient();
@@ -385,11 +385,13 @@ public class MqttPublisherService : IMqttPublisherService, ITransient, IDisposab
bool lastLog = false;
try
{
- lastLog = await _db.Queryable()
+ // 使用ToListAsync()然后检查Count来避免DataReader冲突
+ var existingLogs = await _db.Queryable()
.Where(p => p.DeviceId == messageInfo.DeviceId &&
p.Payload == messageInfo.Payload &&
p.CreatedAt >= twoSecondsAgo)
- .AnyAsync();
+ .ToListAsync();
+ lastLog = existingLogs.Any();
}
catch (Exception dbEx)
{
diff --git a/netcore/src/Modularity/Extend/NCC.Extend/NCC.Extend.xml b/netcore/src/Modularity/Extend/NCC.Extend/NCC.Extend.xml
index 4de97eb..80890af 100644
--- a/netcore/src/Modularity/Extend/NCC.Extend/NCC.Extend.xml
+++ b/netcore/src/Modularity/Extend/NCC.Extend/NCC.Extend.xml
@@ -163,7 +163,7 @@
客户端ID
-
+
构造函数:初始化客户端和配置、注册事件
@@ -1764,17 +1764,32 @@
参数
-
+
- 更新提现申请
+ 获取提现申请审核详情(包含用户余额)
+
+ 参数
+
+
+
+
+ 审核提现申请
+
+ 主键
+ 参数
+
+
+
+
+ 处理提现申请(转账)
主键
参数
-
+
- 删除提现申请
+ 获取提现申请统计数据
diff --git a/netcore/src/Modularity/Extend/NCC.Extend/UavSiteService.cs b/netcore/src/Modularity/Extend/NCC.Extend/UavSiteService.cs
index af0981d..ae62e81 100644
--- a/netcore/src/Modularity/Extend/NCC.Extend/UavSiteService.cs
+++ b/netcore/src/Modularity/Extend/NCC.Extend/UavSiteService.cs
@@ -18,6 +18,7 @@ using NCC.Extend.Entitys.Dto.UavSite;
using Yitter.IdGenerator;
using NCC.Common.Helper;
using NCC.JsonSerialization;
+using NCC.System.Entitys.Permission;
namespace NCC.Extend.UavSite
{
@@ -68,7 +69,9 @@ namespace NCC.Extend.UavSite
public async Task GetList([FromQuery] UavSiteListQueryInput input)
{
var sidx = input.sidx == null ? "id" : input.sidx;
- var data = await _db.Queryable()
+
+ // 第一步:获取基础场地数据
+ var siteData = await _db.Queryable()
.WhereIF(!string.IsNullOrEmpty(input.siteName), p => p.SiteName.Contains(input.siteName))
.WhereIF(!string.IsNullOrEmpty(input.creatorId), p => p.CreatorId.Equals(input.creatorId))
.Select(it => new UavSiteListOutput
@@ -80,8 +83,42 @@ namespace NCC.Extend.UavSite
lat = it.Lat,
remark = it.Remark,
creatorId = it.CreatorId,
- }).MergeTable().OrderBy(sidx + " " + input.sort).ToPagedListAsync(input.currentPage, input.pageSize);
- return PageResult.SqlSugarPageResult(data);
+ creatorName = "", // 先设为空,后面单独查询
+ deviceCount = SqlFunc.Subqueryable()
+ .Where(device => device.SiteId == it.Id)
+ .Count()
+ }).OrderBy(sidx + " " + input.sort).ToPagedListAsync(input.currentPage, input.pageSize);
+
+ // 第二步:单独查询用户名称
+ if (siteData.list?.Any() == true)
+ {
+ var creatorIds = siteData.list.Where(x => !string.IsNullOrEmpty(x.creatorId))
+ .Select(x => x.creatorId).Distinct().ToList();
+
+ if (creatorIds.Any())
+ {
+ var users = await _db.Queryable()
+ .Where(u => creatorIds.Contains(u.Id))
+ .Select(u => new { u.Id, u.RealName, u.Account })
+ .ToListAsync();
+
+ // 更新用户名称
+ foreach (var site in siteData.list)
+ {
+ if (!string.IsNullOrEmpty(site.creatorId))
+ {
+ var user = users.FirstOrDefault(u => u.Id == site.creatorId);
+ site.creatorName = user != null ? $"{user.RealName}/{user.Account}" : site.creatorId;
+ }
+ else
+ {
+ site.creatorName = "-";
+ }
+ }
+ }
+ }
+
+ return PageResult.SqlSugarPageResult(siteData);
}
#endregion
diff --git a/netcore/src/Modularity/Extend/NCC.Extend/UavWalletWithdrawApplyService.cs b/netcore/src/Modularity/Extend/NCC.Extend/UavWalletWithdrawApplyService.cs
index cfbd21f..ebc9c44 100644
--- a/netcore/src/Modularity/Extend/NCC.Extend/UavWalletWithdrawApplyService.cs
+++ b/netcore/src/Modularity/Extend/NCC.Extend/UavWalletWithdrawApplyService.cs
@@ -58,11 +58,11 @@ namespace NCC.Extend.UavWalletWithdrawApply
return output;
}
- ///
- /// 获取提现申请列表
- ///
- /// 请求参数
- ///
+ ///
+ /// 获取提现申请列表
+ ///
+ /// 请求参数
+ ///
[HttpGet("")]
public async Task GetList([FromQuery] UavWalletWithdrawApplyListQueryInput input)
{
@@ -70,6 +70,8 @@ namespace NCC.Extend.UavWalletWithdrawApply
var data = await _db.Queryable()
.WhereIF(!string.IsNullOrEmpty(input.bankAccountNumber), p => p.BankAccountNumber.Contains(input.bankAccountNumber))
.WhereIF(!string.IsNullOrEmpty(input.walletNo), p => p.WalletNo.Contains(input.walletNo))
+ .WhereIF(input.auditStatus.HasValue, p => p.AuditStatus == input.auditStatus.Value)
+ .WhereIF(input.transferStatus.HasValue, p => p.TransferStatus == input.transferStatus.Value)
.Select(it => new UavWalletWithdrawApplyListOutput
{
id = it.Id,
@@ -78,6 +80,11 @@ namespace NCC.Extend.UavWalletWithdrawApply
bankAccountNumber = it.BankAccountNumber,
bankName = it.BankName,
walletNo = it.WalletNo,
+ applyTime = it.ApplyTime,
+ auditStatus = it.AuditStatus,
+ auditTime = it.AuditTime,
+ transferStatus = it.TransferStatus,
+ transferTime = it.TransferTime,
}).MergeTable().OrderBy(sidx + " " + input.sort).ToPagedListAsync(input.currentPage, input.pageSize);
return PageResult.SqlSugarPageResult(data);
}
@@ -106,30 +113,131 @@ namespace NCC.Extend.UavWalletWithdrawApply
}
///
- /// 更新提现申请
+ /// 获取提现申请审核详情(包含用户余额)
+ ///
+ /// 参数
+ ///
+ [HttpGet("{id}/AuditDetail")]
+ public async Task GetAuditDetail(string id)
+ {
+ var entity = await _db.Queryable().FirstAsync(p => p.Id == id);
+ _ = entity ?? throw NCCException.Oh(ErrorCode.COM1005);
+
+ // 获取用户当前余额
+ var userBalance = await _db.Queryable()
+ .Where(x => x.UserId == entity.UserId)
+ .SumAsync(x => x.Amount);
+
+ var output = entity.Adapt();
+ output.userBalance = userBalance;
+ return output;
+ }
+
+ ///
+ /// 审核提现申请
///
/// 主键
/// 参数
///
- [HttpPut("{id}")]
- public async Task Update(string id, [FromBody] UavWalletWithdrawApplyUpInput input)
+ [HttpPut("{id}/Audit")]
+ public async Task Audit(string id, [FromBody] UavWalletWithdrawApplyAuditInput input)
{
- var entity = input.Adapt();
- var isOk = await _db.Updateable(entity).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
+ var entity = await _db.Queryable().FirstAsync(p => p.Id == id);
+ _ = entity ?? throw NCCException.Oh(ErrorCode.COM1005);
+
+ // 只有待审核状态才能审核
+ if (entity.AuditStatus != AuditStatusEnum.待审核.GetHashCode())
+ {
+ throw NCCException.Oh(ErrorCode.COM1003, "该申请已审核,无法重复审核");
+ }
+
+ // 驳回时必须填写驳回原因
+ if (input.auditStatus == AuditStatusEnum.审核驳回.GetHashCode() && string.IsNullOrEmpty(input.rejectReason))
+ {
+ throw NCCException.Oh(ErrorCode.COM1003, "驳回时必须填写驳回原因");
+ }
+
+ entity.AuditStatus = input.auditStatus;
+ entity.AuditTime = DateTime.Now;
+ entity.AuditUserId = _userManager.UserId;
+ entity.RejectReason = input.rejectReason;
+ entity.UpdateTime = DateTime.Now;
+ entity.UpdateUser = _userManager.UserId;
+
+ var isOk = await _db.Updateable(entity).ExecuteCommandAsync();
if (!(isOk > 0)) throw NCCException.Oh(ErrorCode.COM1001);
}
///
- /// 删除提现申请
+ /// 处理提现申请(转账)
///
+ /// 主键
+ /// 参数
///
- [HttpDelete("{id}")]
- public async Task Delete(string id)
+ [HttpPut("{id}/Process")]
+ public async Task Process(string id, [FromBody] UavWalletWithdrawApplyProcessInput input)
{
var entity = await _db.Queryable().FirstAsync(p => p.Id == id);
_ = entity ?? throw NCCException.Oh(ErrorCode.COM1005);
- var isOk = await _db.Deleteable().Where(d => d.Id == id).ExecuteCommandAsync();
- if (!(isOk > 0)) throw NCCException.Oh(ErrorCode.COM1002);
+
+ // 只有审核通过的才能处理
+ if (entity.AuditStatus != AuditStatusEnum.审核通过.GetHashCode())
+ {
+ throw NCCException.Oh(ErrorCode.COM1003, "只有审核通过的申请才能处理");
+ }
+
+ // 只有未转账的才能处理
+ if (entity.TransferStatus != TransferStatusEnum.未转账.GetHashCode())
+ {
+ throw NCCException.Oh(ErrorCode.COM1003, "该申请已处理,无法重复处理");
+ }
+
+ entity.TransferStatus = input.transferStatus;
+ entity.TransferTime = input.transferTime ?? DateTime.Now;
+ entity.TransferRemark = input.transferRemark;
+ entity.UpdateTime = DateTime.Now;
+ entity.UpdateUser = _userManager.UserId;
+
+ var isOk = await _db.Updateable(entity).ExecuteCommandAsync();
+ if (!(isOk > 0)) throw NCCException.Oh(ErrorCode.COM1001);
+ }
+
+ ///
+ /// 获取提现申请统计数据
+ ///
+ ///
+ [HttpGet("Statistics")]
+ public async Task GetStatistics()
+ {
+ // 分别查询各个统计数据
+ var pendingCount = await _db.Queryable()
+ .Where(p => p.AuditStatus == AuditStatusEnum.待审核.GetHashCode())
+ .CountAsync();
+
+ var approvedCount = await _db.Queryable()
+ .Where(p => p.AuditStatus == AuditStatusEnum.审核通过.GetHashCode())
+ .CountAsync();
+
+ var transferredCount = await _db.Queryable()
+ .Where(p => p.TransferStatus == TransferStatusEnum.已转账.GetHashCode())
+ .CountAsync();
+
+ // 查询所有金额数据,然后在内存中处理
+ var amounts = await _db.Queryable()
+ .Select(p => p.Amount)
+ .ToListAsync();
+
+ var totalAmount = amounts.Sum(amount => amount < 0 ? -amount : amount);
+
+ var stats = new
+ {
+ pendingCount = pendingCount,
+ approvedCount = approvedCount,
+ transferredCount = transferredCount,
+ totalAmount = totalAmount
+ };
+
+ return stats;
}
}
}