|
|
|
@ -18,6 +18,7 @@ using StackExchange.Profiling.Internal;
|
|
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
|
using static NPOI.HSSF.Util.HSSFColor;
|
|
|
|
|
using TinyPinyin;
|
|
|
|
|
using Myshipping.Core.Const;
|
|
|
|
|
|
|
|
|
|
namespace Myshipping.Core.Service
|
|
|
|
|
{
|
|
|
|
@ -30,17 +31,26 @@ namespace Myshipping.Core.Service
|
|
|
|
|
private readonly SqlSugarRepository<DjyCustomer> _rep;
|
|
|
|
|
private readonly SqlSugarRepository<DjyCustomerContact> _repContact;
|
|
|
|
|
private readonly SqlSugarRepository<DjyCustomerAddr> _repAddr;
|
|
|
|
|
private readonly ISysCacheService _cache;
|
|
|
|
|
private readonly ISysDataUserMenu _sysDataUserMenuService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private readonly ILogger<DjyCustomerService> _logger;
|
|
|
|
|
|
|
|
|
|
public DjyCustomerService(SqlSugarRepository<DjyCustomer> rep, SqlSugarRepository<DjyCustomerContact> repContact, ILogger<DjyCustomerService> logger, SqlSugarRepository<DjyCustomerAddr> addrRepContact)
|
|
|
|
|
public DjyCustomerService(SqlSugarRepository<DjyCustomer> rep,
|
|
|
|
|
SqlSugarRepository<DjyCustomerContact> repContact,
|
|
|
|
|
ILogger<DjyCustomerService> logger,
|
|
|
|
|
SqlSugarRepository<DjyCustomerAddr> addrRepContact,
|
|
|
|
|
ISysCacheService cache,
|
|
|
|
|
ISysDataUserMenu sysDataUserMenuService)
|
|
|
|
|
{
|
|
|
|
|
_rep = rep;
|
|
|
|
|
_repContact = repContact;
|
|
|
|
|
|
|
|
|
|
_logger = logger;
|
|
|
|
|
_repAddr = addrRepContact;
|
|
|
|
|
_cache = cache;
|
|
|
|
|
_sysDataUserMenuService = sysDataUserMenuService;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -51,7 +61,28 @@ namespace Myshipping.Core.Service
|
|
|
|
|
[HttpGet("/DjyCustomer/page")]
|
|
|
|
|
public async Task<dynamic> Page([FromQuery] QueryDjyCustomerInput input)
|
|
|
|
|
{
|
|
|
|
|
var entities = await _rep.AsQueryable().Filter(null, true)
|
|
|
|
|
var queryable = _rep.AsQueryable().Filter(null, true);
|
|
|
|
|
|
|
|
|
|
// 判断是否启用了委托单位查看控制权限
|
|
|
|
|
var tenantParamList = await _cache.GetAllTenantParam();
|
|
|
|
|
var isEnableCustomerAuthority = tenantParamList.FirstOrDefault(x => x.TenantId == UserManager.TENANT_ID
|
|
|
|
|
&& x.ParaCode == TenantParamCode.IS_ENABLE_CUSTOMER_AUTHORITY)?.ItemCode;
|
|
|
|
|
if (isEnableCustomerAuthority == "YES")
|
|
|
|
|
{
|
|
|
|
|
List<long> userList = await _sysDataUserMenuService.GetDataScopeList(MenuConst.MenuDjyCustomer);
|
|
|
|
|
if (userList?.Any() == true)
|
|
|
|
|
{
|
|
|
|
|
List<string> userListStr = userList.Select(x => x.ToString()).ToList();
|
|
|
|
|
queryable.Where(u => userList.Contains((long)u.CreatedUserId)
|
|
|
|
|
|| userListStr.Contains(u.OPID)
|
|
|
|
|
|| userListStr.Contains(u.SALEID)
|
|
|
|
|
|| userListStr.Contains(u.DOCID)
|
|
|
|
|
|| userListStr.Contains(u.CUSTSERVICEID));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var entities = await queryable
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.CodeName), u => u.CodeName.Contains(input.CodeName.Trim()))
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.ShortName), u => u.ShortName.Contains(input.ShortName.Trim()))
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(input.FullName), u => u.FullName.Contains(input.FullName.Trim()))
|
|
|
|
@ -269,8 +300,27 @@ namespace Myshipping.Core.Service
|
|
|
|
|
[HttpGet("/DjyCustomer/Suggest")]
|
|
|
|
|
public async Task<dynamic> Suggest(string keyword, string type)
|
|
|
|
|
{
|
|
|
|
|
//List<long> userlist = await DataFilterExtensions.GetDataScopeIdList();
|
|
|
|
|
var entities = await _rep.AsQueryable().Filter(null, true)
|
|
|
|
|
var queryable = _rep.AsQueryable().Filter(null, true);
|
|
|
|
|
|
|
|
|
|
// 判断是否启用了委托单位查看控制权限
|
|
|
|
|
var tenantParamList = await _cache.GetAllTenantParam();
|
|
|
|
|
var isEnableCustomerAuthority = tenantParamList.FirstOrDefault(x => x.TenantId == UserManager.TENANT_ID
|
|
|
|
|
&& x.ParaCode == TenantParamCode.IS_ENABLE_CUSTOMER_AUTHORITY)?.ItemCode;
|
|
|
|
|
if (isEnableCustomerAuthority == "YES")
|
|
|
|
|
{
|
|
|
|
|
List<long> userList = await _sysDataUserMenuService.GetDataScopeList(MenuConst.MenuDjyCustomer);
|
|
|
|
|
if (userList?.Any() == true)
|
|
|
|
|
{
|
|
|
|
|
List<string> userListStr = userList.Select(x => x.ToString()).ToList();
|
|
|
|
|
queryable.Where(u => userList.Contains((long)u.CreatedUserId)
|
|
|
|
|
|| userListStr.Contains(u.OPID)
|
|
|
|
|
|| userListStr.Contains(u.SALEID)
|
|
|
|
|
|| userListStr.Contains(u.DOCID)
|
|
|
|
|
|| userListStr.Contains(u.CUSTSERVICEID));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var entities = await queryable
|
|
|
|
|
.Where(x => x.TenantId == UserManager.TENANT_ID)
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(type), u => u.PropString.Contains(type))
|
|
|
|
|
.WhereIF(!string.IsNullOrWhiteSpace(keyword), u => u.CodeName.Contains(keyword) || u.ShortName.Contains(keyword))
|
|
|
|
@ -375,6 +425,43 @@ namespace Myshipping.Core.Service
|
|
|
|
|
return entityList.Select(x => new ValueTuple<string, string>(x.code, x.name)).ToList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 批量更新客户信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
[HttpPost("/DjyCustomer/BatchUpdate")]
|
|
|
|
|
public async Task BatchUpdate(BatchUpdateInput input)
|
|
|
|
|
{
|
|
|
|
|
if (input.CustomnerIdList == null || input.CustomnerIdList.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
throw Oops.Oh("客户列表为空");
|
|
|
|
|
}
|
|
|
|
|
var updateable = _rep.Context.Updateable<DjyCustomer>();
|
|
|
|
|
if (input.IsSetCUSTSERVICE)
|
|
|
|
|
{
|
|
|
|
|
updateable.SetColumns(x => x.CUSTSERVICE == input.CUSTSERVICE);
|
|
|
|
|
updateable.SetColumns(x => x.CUSTSERVICEID == input.CUSTSERVICEID);
|
|
|
|
|
}
|
|
|
|
|
if (input.IsSetSALE)
|
|
|
|
|
{
|
|
|
|
|
updateable.SetColumns(x => x.SALE == input.SALE);
|
|
|
|
|
updateable.SetColumns(x => x.SALEID == input.SALEID);
|
|
|
|
|
}
|
|
|
|
|
if (input.IsSetOP)
|
|
|
|
|
{
|
|
|
|
|
updateable.SetColumns(x => x.OP == input.OP);
|
|
|
|
|
updateable.SetColumns(x => x.OPID == input.OPID);
|
|
|
|
|
}
|
|
|
|
|
if (input.IsSetDOC)
|
|
|
|
|
{
|
|
|
|
|
updateable.SetColumns(x => x.DOC == input.DOC);
|
|
|
|
|
updateable.SetColumns(x => x.DOCID == input.DOCID);
|
|
|
|
|
}
|
|
|
|
|
if (input.IsSetCUSTSERVICE || input.IsSetSALE || input.IsSetOP || input.IsSetDOC)
|
|
|
|
|
{
|
|
|
|
|
await updateable.Where(x => input.CustomnerIdList.Contains(x.Id)).ExecuteCommandAsync();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#region 接收客户端租户、用户的数据到运营端委托单位
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|