修改User模块,同步原始代码
This commit is contained in:
1 parent
4a5fada435
commit
78b0c2bb2e
47 files changed
+2939
-193
No files matched your search
@@ -1,50 +1,31 @@
|
||||
using FreeSql;
|
||||
using FreeSql;
|
||||
using MAX.Core.DependencyInjection;
|
||||
using Store.Users.Contracts.Dtos;
|
||||
using Store.Users.Entities;
|
||||
using Store.Users.Mappers;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
namespace Store.Users.Repositories;
|
||||
|
||||
namespace Store.Users.Repositories
|
||||
public interface IUserRepository : IBaseRepository<UserEntity>
|
||||
{
|
||||
public interface IUserRepository : IBaseRepository<UserEntity>
|
||||
{
|
||||
Task<UserEntity> GetUser(string userName);
|
||||
}
|
||||
internal class UserRepository : BaseRepository<UserEntity>, IUserRepository, ITransientDependency
|
||||
{
|
||||
private readonly IFreeSql _freeSql;
|
||||
Task<UserEntity> GetUser(string userName);
|
||||
}
|
||||
|
||||
public UserRepository(IFreeSql freeSql) : base(freeSql)
|
||||
{
|
||||
_freeSql = freeSql;
|
||||
}
|
||||
|
||||
public async Task<UserEntity> GetUser(string userName)
|
||||
{
|
||||
var sql = Where(a => a.UserName == userName).ToSql();
|
||||
var user = await Where(a => a.UserName == userName).FirstAsync();
|
||||
if (user != null)
|
||||
{
|
||||
if (user.IsMainUser == false)
|
||||
{
|
||||
var mainUser = await Where(a => a.UserName == user.ParentUserName).FirstAsync();
|
||||
if (mainUser != null)
|
||||
{
|
||||
user.OemId = mainUser.OemId;
|
||||
user.PostagePerOrder = mainUser.PostagePerOrder;
|
||||
user.RefundPostagePerOrder = mainUser.RefundPostagePerOrder;
|
||||
user.GiftOemAmountPerOrder = mainUser.GiftOemAmountPerOrder;
|
||||
user.SyncLogisticsPerOrder = mainUser.SyncLogisticsPerOrder;
|
||||
}
|
||||
}
|
||||
}
|
||||
return user;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// <summary>集中处理旧系统主子账号的有效计费配置和积分权限继承。</summary>
|
||||
internal class UserRepository(IFreeSql freeSql) : BaseRepository<UserEntity>(freeSql), IUserRepository, ITransientDependency
|
||||
{
|
||||
public async Task<UserEntity> GetUser(string userName)
|
||||
{
|
||||
var user = await Where(u => u.UserName == userName).FirstAsync();
|
||||
if (user == null || user.IsMainUser) return user;
|
||||
var parent = await Where(u => u.UserName == user.ParentUserName).FirstAsync();
|
||||
if (parent == null) throw new MAX.Framework.Commons.AppException("主账号不存在,请联系管理员");
|
||||
user.OemId = parent.OemId;
|
||||
user.PostagePerOrder = Math.Max(2.2m, parent.PostagePerOrder ?? 0);
|
||||
user.RefundPostagePerOrder = Math.Max(2.5m, parent.RefundPostagePerOrder ?? 0);
|
||||
user.GiftOemAmountPerOrder = Math.Max(0, parent.GiftOemAmountPerOrder ?? 0);
|
||||
user.SyncLogisticsPerOrder = parent.SyncLogisticsPerOrder;
|
||||
var authority = (user.Authority ?? "").Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries).ToHashSet();
|
||||
var parentAuthority = (parent.Authority ?? "").Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
|
||||
if (parentAuthority.Contains("积分用户")) authority.Add("积分用户"); else authority.Remove("积分用户");
|
||||
user.Authority = string.Join(",", authority);
|
||||
return user;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user