diff --git a/src/Oms.Application/Dtos/Customers/CustomerPaginatedInput.cs b/src/Oms.Application/Dtos/Customers/CustomerPaginatedInput.cs
index 301170e..6749647 100644
--- a/src/Oms.Application/Dtos/Customers/CustomerPaginatedInput.cs
+++ b/src/Oms.Application/Dtos/Customers/CustomerPaginatedInput.cs
@@ -45,6 +45,12 @@ public class CustomerPaginatedInput
/// 按绑定代理 Id 筛选。
public int? AgentId { get; set; }
+ ///
+ /// 监控页客户 KPI 下钻口径:total / newToday / online / inactive7d。
+ /// 与 /monitor/overview 客户统计一致;传入时默认仅 Normal 客户。
+ ///
+ public string? MonitorScope { get; set; }
+
///
/// 排序字段:createTime / updateTime / customerCode / customerName / balance。
///
diff --git a/src/Oms.Application/Dtos/System/PaymentReceiveQrOutput.cs b/src/Oms.Application/Dtos/System/PaymentReceiveQrOutput.cs
new file mode 100644
index 0000000..c88e44c
--- /dev/null
+++ b/src/Oms.Application/Dtos/System/PaymentReceiveQrOutput.cs
@@ -0,0 +1,17 @@
+namespace Oms.Application.Dtos.System;
+
+///
+/// 充值收款码展示输出。
+///
+public class PaymentReceiveQrOutput
+{
+ ///
+ /// 支付宝收款码可访问 URL;未配置时为空。
+ ///
+ public string AlipayUrl { get; set; } = string.Empty;
+
+ ///
+ /// 微信收款码可访问 URL;未配置时为空。
+ ///
+ public string WechatUrl { get; set; } = string.Empty;
+}
diff --git a/src/Oms.Application/Dtos/System/PaymentReceiveQrUploadInput.cs b/src/Oms.Application/Dtos/System/PaymentReceiveQrUploadInput.cs
new file mode 100644
index 0000000..ff0b9d0
--- /dev/null
+++ b/src/Oms.Application/Dtos/System/PaymentReceiveQrUploadInput.cs
@@ -0,0 +1,19 @@
+using Microsoft.AspNetCore.Http;
+
+namespace Oms.Application.Dtos.System;
+
+///
+/// 上传充值收款码入参(multipart/form-data:channel + file)。
+///
+public class PaymentReceiveQrUploadInput
+{
+ ///
+ /// 渠道:alipay / wechat。
+ ///
+ public string Channel { get; set; } = string.Empty;
+
+ ///
+ /// 收款码图片。
+ ///
+ public IFormFile File { get; set; } = null!;
+}
diff --git a/src/Oms.Application/Services/Customers/CustomerService.cs b/src/Oms.Application/Services/Customers/CustomerService.cs
index 009bedc..605c8bf 100644
--- a/src/Oms.Application/Services/Customers/CustomerService.cs
+++ b/src/Oms.Application/Services/Customers/CustomerService.cs
@@ -518,6 +518,13 @@ public class CustomerService : ApplicationService
var customerGroupValue = input.CustomerGroup.GetValueOrDefault();
var hasAgentFilter = input.AgentId is > 0;
var agentId = input.AgentId.GetValueOrDefault();
+ var monitorScope = NormalizeMonitorScope(input.MonitorScope);
+ var hasMonitorScope = !string.IsNullOrEmpty(monitorScope);
+ // 与 /monitor/overview 客户 KPI 同一时间口径
+ var today = DateTime.Today;
+ var tomorrow = today.AddDays(1);
+ var inactive7dThreshold = today.AddDays(-7);
+ var onlineSince = DateTime.Now.AddMinutes(-30);
return customer =>
(string.IsNullOrWhiteSpace(keyword) ||
@@ -526,10 +533,32 @@ public class CustomerService : ApplicationService
(customer.Phone ?? string.Empty).Contains(keyword) ||
(customer.Email ?? string.Empty).Contains(keyword)) &&
(!hasStatusFilter || customer.Status == statusValue) &&
+ (!hasMonitorScope || customer.Status == CustomerStatus.Normal) &&
(!hasCustomerGroupFilter || customer.CustomerGroup == customerGroupValue) &&
(string.IsNullOrWhiteSpace(salesman) || customer.Salesman == salesman) &&
(string.IsNullOrWhiteSpace(customerService) || customer.CustomerService == customerService) &&
- (!hasAgentFilter || customer.AgentId == agentId);
+ (!hasAgentFilter || customer.AgentId == agentId) &&
+ (monitorScope != "newToday" || (customer.CreateTime >= today && customer.CreateTime < tomorrow)) &&
+ (monitorScope != "online" ||
+ (customer.LastLoginTime != null && customer.LastLoginTime >= onlineSince)) &&
+ (monitorScope != "inactive7d" ||
+ (customer.LastLoginTime == null || customer.LastLoginTime < inactive7dThreshold));
+ }
+
+ ///
+ /// 规范化监控下钻口径;非法值视为无筛选。
+ ///
+ private static string? NormalizeMonitorScope(string? scope)
+ {
+ var value = (scope ?? string.Empty).Trim().ToLowerInvariant();
+ return value switch
+ {
+ "total" => "total",
+ "newtoday" => "newToday",
+ "online" => "online",
+ "inactive7d" => "inactive7d",
+ _ => null,
+ };
}
private async Task> ResolveAgentDisplayMapAsync(
diff --git a/src/Oms.Application/Services/System/SystemOtherConfigService.cs b/src/Oms.Application/Services/System/SystemOtherConfigService.cs
index 7c52138..e8654b9 100644
--- a/src/Oms.Application/Services/System/SystemOtherConfigService.cs
+++ b/src/Oms.Application/Services/System/SystemOtherConfigService.cs
@@ -1,9 +1,11 @@
using System.Linq.Expressions;
using Fake.Application;
+using Fake.ObjectStorage;
using Microsoft.AspNetCore.Mvc;
using Oms.Application.Dtos.Shared;
using Oms.Application.Dtos.System;
using Oms.Application.Shared;
+using Oms.Application.Storage;
using Oms.Domain.SystemAggregate.Consts;
using Oms.Domain.SystemAggregate.Entities;
using Oms.Domain.SystemAggregate.Repositories;
@@ -17,10 +19,14 @@ namespace Oms.Application.Services.System;
public class SystemOtherConfigService : ApplicationService
{
private const string SecretMask = "******";
+ private const string PaymentQrChannelAlipay = "alipay";
+ private const string PaymentQrChannelWechat = "wechat";
private ISystemOtherConfigRepository SystemOtherConfigRepository =>
LazyServiceProvider.GetRequiredService();
+ private IObjectStorage FileStorage => LazyServiceProvider.GetRequiredService();
+
///
/// 查询系统其他配置列表。
///
@@ -140,13 +146,92 @@ public class SystemOtherConfigService : ApplicationService
await SystemOtherConfigRepository.DeleteAsync(entity);
}
+ ///
+ /// 获取客户充值用支付宝/微信收款码图片地址。未配置时对应 URL 为空(前端可回退本地默认图)。
+ ///
+ [HttpGet("/system/other-config/payment-qr")]
+ public async Task GetPaymentReceiveQrAsync()
+ {
+ var entity = await SystemOtherConfigRepository.GetByConfigCodeAsync(SystemOtherConfigCodes.PaymentReceiveQr);
+ return new PaymentReceiveQrOutput
+ {
+ AlipayUrl = FileStorage.GetPublicUrl(entity?.AppKey),
+ WechatUrl = FileStorage.GetPublicUrl(entity?.Remark)
+ };
+ }
+
+ ///
+ /// 上传并替换充值收款码图片。Channel=alipay|wechat;返回最新支付宝/微信可访问 URL。
+ ///
+ /// 入参:渠道 + 图片文件。
+ [HttpPost("/system/other-config/payment-qr/upload")]
+ [Consumes("multipart/form-data")]
+ public async Task UploadPaymentReceiveQrAsync([FromForm] PaymentReceiveQrUploadInput input)
+ {
+ var channel = (input.Channel ?? string.Empty).Trim().ToLowerInvariant();
+ if (channel is not (PaymentQrChannelAlipay or PaymentQrChannelWechat))
+ {
+ throw new BusinessException("渠道仅支持 alipay 或 wechat");
+ }
+
+ var key = await OmsFileUploadHelper.SavePaymentReceiveQrAsync(input.File, FileStorage);
+ var entity = await EnsurePaymentReceiveQrConfigAsync();
+ if (channel == PaymentQrChannelAlipay)
+ {
+ entity.AppKey = key;
+ }
+ else
+ {
+ entity.Remark = key;
+ }
+
+ await SystemOtherConfigRepository.UpdateAsync(entity);
+ return new PaymentReceiveQrOutput
+ {
+ AlipayUrl = FileStorage.GetPublicUrl(entity.AppKey),
+ WechatUrl = FileStorage.GetPublicUrl(entity.Remark)
+ };
+ }
+
+ private async Task EnsurePaymentReceiveQrConfigAsync()
+ {
+ var entity = await SystemOtherConfigRepository.GetByConfigCodeAsync(SystemOtherConfigCodes.PaymentReceiveQr);
+ if (entity != null)
+ {
+ return entity;
+ }
+
+ var deleted = await SystemOtherConfigRepository.GetByConfigCodeIncludingDeletedAsync(
+ SystemOtherConfigCodes.PaymentReceiveQr);
+ if (deleted != null)
+ {
+ deleted.IsDeleted = false;
+ deleted.ConfigName = "充值收款码";
+ deleted.Enabled = true;
+ deleted.TimeoutSeconds = 30;
+ deleted.BaseUrl = null;
+ deleted.AppSecret = null;
+ await SystemOtherConfigRepository.UpdateAsync(deleted);
+ return deleted;
+ }
+
+ return await SystemOtherConfigRepository.InsertAsync(new SystemOtherConfig
+ {
+ ConfigCode = SystemOtherConfigCodes.PaymentReceiveQr,
+ ConfigName = "充值收款码",
+ Enabled = true,
+ TimeoutSeconds = 30
+ });
+ }
+
private static Expression> BuildListPredicate(SystemOtherConfigListInput input)
{
var keyword = input.Keyword?.Trim();
return x =>
- string.IsNullOrWhiteSpace(keyword) ||
- x.ConfigCode.Contains(keyword) ||
- x.ConfigName.Contains(keyword);
+ x.ConfigCode != SystemOtherConfigCodes.PaymentReceiveQr
+ && (string.IsNullOrWhiteSpace(keyword)
+ || x.ConfigCode.Contains(keyword)
+ || x.ConfigName.Contains(keyword));
}
private async Task GetConfigOrThrowAsync(int id)
diff --git a/src/Oms.Application/Shared/OmsFileUploadHelper.cs b/src/Oms.Application/Shared/OmsFileUploadHelper.cs
index 157cec9..4889596 100644
--- a/src/Oms.Application/Shared/OmsFileUploadHelper.cs
+++ b/src/Oms.Application/Shared/OmsFileUploadHelper.cs
@@ -26,6 +26,9 @@ public static class OmsFileUploadHelper
public static Task SaveWarehouseParcelImageAsync(IFormFile file, IObjectStorage storage) =>
SaveImageAsync(file, storage, "parcel", "包裹商品图片");
+ public static Task SavePaymentReceiveQrAsync(IFormFile file, IObjectStorage storage) =>
+ SaveImageAsync(file, storage, "payment-qr", "收款码图片");
+
private static async Task SaveImageAsync(
IFormFile? file,
IObjectStorage storage,
diff --git a/src/Oms.Domain/SystemAggregate/Consts/SystemOtherConfigCodes.cs b/src/Oms.Domain/SystemAggregate/Consts/SystemOtherConfigCodes.cs
index 02f0bd1..7bc9f93 100644
--- a/src/Oms.Domain/SystemAggregate/Consts/SystemOtherConfigCodes.cs
+++ b/src/Oms.Domain/SystemAggregate/Consts/SystemOtherConfigCodes.cs
@@ -59,4 +59,9 @@ public static class SystemOtherConfigCodes
/// 国内揽收服务商推送件重尺/费用(历史配置;鉴权已改由 itfx 上游应用完成,OMS 不再校验 AppKey)。
///
public const string PickupOpenApi = "pickup_open_api";
+
+ ///
+ /// 客户充值收款码(AppKey=支付宝收款码 object key,Remark=微信收款码 object key)。
+ ///
+ public const string PaymentReceiveQr = "payment_receive_qr";
}