|
|
|
@ -1,36 +1,24 @@
|
|
|
|
|
using DS.Module.Core;
|
|
|
|
|
using DS.Module.Core.Data;
|
|
|
|
|
using DS.Module.Core.Extensions;
|
|
|
|
|
using DS.Module.SqlSugar;
|
|
|
|
|
using DS.Module.UserModule;
|
|
|
|
|
using DS.WMS.Core.Info.Dtos;
|
|
|
|
|
using DS.WMS.Core.Info.Entity;
|
|
|
|
|
using DS.WMS.Core.Info.Interface;
|
|
|
|
|
using Mapster;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using SqlSugar;
|
|
|
|
|
|
|
|
|
|
namespace DS.WMS.Core.Info.Method;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 客服银行服务
|
|
|
|
|
/// 往来单位银行
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class ClientBankService : IClientBankService
|
|
|
|
|
public class ClientBankService : ServiceBase, IClientBankService
|
|
|
|
|
{
|
|
|
|
|
private readonly IServiceProvider _serviceProvider;
|
|
|
|
|
private readonly ISqlSugarClient db;
|
|
|
|
|
private readonly IUser user;
|
|
|
|
|
private readonly ISaasDbService saasService;
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="serviceProvider"></param>
|
|
|
|
|
public ClientBankService(IServiceProvider serviceProvider)
|
|
|
|
|
public ClientBankService(IServiceProvider serviceProvider) : base(serviceProvider)
|
|
|
|
|
{
|
|
|
|
|
_serviceProvider = serviceProvider;
|
|
|
|
|
db = _serviceProvider.GetRequiredService<ISqlSugarClient>();
|
|
|
|
|
user = _serviceProvider.GetRequiredService<IUser>();
|
|
|
|
|
saasService = _serviceProvider.GetRequiredService<ISaasDbService>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
@ -40,46 +28,53 @@ public class ClientBankService : IClientBankService
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public DataResult<List<ClientBankRes>> GetListByPage(PageRequest request)
|
|
|
|
|
{
|
|
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
|
|
//序列化查询条件
|
|
|
|
|
var whereList = request.GetConditionalModels(db);
|
|
|
|
|
var data = tenantDb.Queryable<InfoClientBank>()
|
|
|
|
|
var whereList = request.GetConditionalModels(Db);
|
|
|
|
|
var data = TenantDb.Queryable<InfoClientBank>()
|
|
|
|
|
.Where(whereList)
|
|
|
|
|
.Select<ClientBankRes>().ToQueryPage(request.PageCondition);
|
|
|
|
|
return data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 编辑
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="req"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public DataResult EditClientBank(ClientBankReq req)
|
|
|
|
|
public async Task<DataResult> EditClientBankAsync(ClientBankReq req)
|
|
|
|
|
{
|
|
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
|
|
if (req.Id == 0)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (tenantDb.Queryable<InfoClientBank>().Where(x=>x.CodeName == req.CodeName).Any())
|
|
|
|
|
{
|
|
|
|
|
if (await TenantDb.Queryable<InfoClientBank>().Where(x => x.CodeName == req.CodeName).AnyAsync())
|
|
|
|
|
return DataResult.Failed("客户银行信息已存在!", MultiLanguageConst.ClientBankExist);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var data = req.Adapt<InfoClientBank>();
|
|
|
|
|
|
|
|
|
|
var entity = tenantDb.Insertable(data).ExecuteReturnEntity();
|
|
|
|
|
|
|
|
|
|
var entity = await TenantDb.Insertable(data).ExecuteReturnEntityAsync();
|
|
|
|
|
if (req.InvoiceHeaders?.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
await TenantDb.Insertable(req.InvoiceHeaders).ExecuteCommandAsync();
|
|
|
|
|
}
|
|
|
|
|
return DataResult.Successed("添加成功!", entity.Id, MultiLanguageConst.DataCreateSuccess);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var info = tenantDb.Queryable<InfoClientBank>().Where(x => x.Id == req.Id).First();
|
|
|
|
|
var info = await TenantDb.Queryable<InfoClientBank>().Where(x => x.Id == req.Id).FirstAsync();
|
|
|
|
|
if (info == null)
|
|
|
|
|
{
|
|
|
|
|
return DataResult.FailedWithDesc(MultiLanguageConst.EmptyData);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
info = req.Adapt(info);
|
|
|
|
|
await TenantDb.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
|
|
|
|
|
|
|
|
|
|
//创建或更新发票抬头
|
|
|
|
|
if (req.InvoiceHeaders?.Count > 0)
|
|
|
|
|
await TenantDb.Storageable(req.InvoiceHeaders).DefaultAddElseUpdate().ExecuteCommandAsync();
|
|
|
|
|
|
|
|
|
|
tenantDb.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
|
|
|
|
|
return DataResult.Successed("更新成功!", MultiLanguageConst.DataUpdateSuccess);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 详情
|
|
|
|
|
/// </summary>
|
|
|
|
@ -87,8 +82,7 @@ public class ClientBankService : IClientBankService
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public DataResult<ClientBankRes> GetClientBankInfo(string id)
|
|
|
|
|
{
|
|
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
|
|
var data = tenantDb.Queryable<InfoClientBank>()
|
|
|
|
|
var data = TenantDb.Queryable<InfoClientBank>()
|
|
|
|
|
.Where(a => a.Id == long.Parse(id))
|
|
|
|
|
.Select<ClientBankRes>()
|
|
|
|
|
.First();
|
|
|
|
@ -102,9 +96,8 @@ public class ClientBankService : IClientBankService
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<DataResult> DeleteAsync(IdModel req)
|
|
|
|
|
{
|
|
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
|
|
//删除客户信息
|
|
|
|
|
int rows = await tenantDb.Deleteable<InfoClientBank>().Where(x => req.Ids.Contains(x.Id)).ExecuteCommandAsync();
|
|
|
|
|
int rows = await TenantDb.Deleteable<InfoClientBank>().Where(x => req.Ids.Contains(x.Id)).ExecuteCommandAsync();
|
|
|
|
|
return rows > 0 ? DataResult.Success : DataResult.FailedWithDesc(nameof(MultiLanguageConst.Operation_Failed));
|
|
|
|
|
}
|
|
|
|
|
}
|