Implement referral, points, coupons, commission, member levels, and order integration with migration SQL and background jobs. Co-authored-by: Cursor <cursoragent@cursor.com>
67 lines
1.7 KiB
C#
67 lines
1.7 KiB
C#
using Fake.Application;
|
|
using Fake.Domain.Exceptions;
|
|
using Fake.Users;
|
|
using Oms.Domain.CustomersAggregate.Entities;
|
|
using Oms.Domain.CustomersAggregate.Repositories;
|
|
|
|
namespace Oms.Application.Shared;
|
|
|
|
/// <summary>
|
|
/// 营销门户会话解析。
|
|
/// </summary>
|
|
public static class MarketingPortalSessionHelper
|
|
{
|
|
public static void EnsureCustomerLogin(ICurrentUser currentUser)
|
|
{
|
|
if (!OmsSessionHelper.IsCustomerLogin(currentUser))
|
|
{
|
|
throw new BusinessException("仅客户门户可访问");
|
|
}
|
|
}
|
|
|
|
public static async Task<Customer> ResolveMainCustomerAsync(
|
|
ICustomerRepository customerRepository,
|
|
ICurrentUser currentUser,
|
|
CancellationToken cancellationToken = default)
|
|
{
|
|
EnsureCustomerLogin(currentUser);
|
|
var sessionCustomer = await OmsSessionHelper.ResolveSessionCustomerAsync(
|
|
customerRepository,
|
|
currentUser);
|
|
return await MarketingCustomerHelper.ResolveMarketingMainCustomerAsync(
|
|
customerRepository,
|
|
sessionCustomer,
|
|
cancellationToken);
|
|
}
|
|
|
|
public static string MaskPhone(string? phone)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(phone) || phone.Length < 7)
|
|
{
|
|
return phone ?? string.Empty;
|
|
}
|
|
|
|
return phone[..3] + "****" + phone[^4..];
|
|
}
|
|
|
|
public static string MaskName(string? name)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(name))
|
|
{
|
|
return string.Empty;
|
|
}
|
|
|
|
if (name.Length == 1)
|
|
{
|
|
return "*";
|
|
}
|
|
|
|
if (name.Length == 2)
|
|
{
|
|
return name[0] + "*";
|
|
}
|
|
|
|
return name[0] + new string('*', name.Length - 2) + name[^1];
|
|
}
|
|
}
|