客户模块中发票银行信息修改:发票抬头i和银行 应该是一对一的关系,是一条数据就可以不用另外加子表。注意美金户、人民币户。

dev
cjy 3 weeks ago
parent 5189da36bc
commit 9534ac328e

@ -1,6 +1,7 @@
using DS.Module.Core;
using DS.WMS.Core.Info.Entity;
using FluentValidation;
using SqlSugar;
namespace DS.WMS.Core.Info.Dtos;
@ -99,11 +100,30 @@ public class ClientBankReq
/// 备注
/// </summary>
public string? Note { get; set; }
/// <summary>
/// 发票抬头
/// </summary>
public List<InvoiceHeader> InvoiceHeaders { get; set; } = [];
public string InvoiceHeader { get; set; } = string.Empty;
/// <summary>
/// 开票税号
/// </summary>
public string? InvoiceTaxNo { get; set; }
/// <summary>
/// 开票地址
/// </summary>
public string? InvoiceAddress { get; set; }
/// <summary>
/// 开票电话
/// </summary>
public string? InvoiceTel { get; set; }
/// <summary>
/// 寄发票地址
/// </summary>
public string? SendInvoiceAddress { get; set; }
///// <summary>
///// 发票抬头
///// </summary>
//public List<InvoiceHeader> InvoiceHeaders { get; set; } = [];
}
/// <summary>

@ -105,8 +105,28 @@ public class ClientBankRes
/// </summary>
public DateTime CreateTime { get; set; }
///// <summary>
///// 发票抬头
///// </summary>
//public List<InvoiceHeader> InvoiceHeaders { get; set; } = [];
/// <summary>
/// 发票抬头
/// </summary>
public List<InvoiceHeader> InvoiceHeaders { get; set; } = [];
public string InvoiceHeader { get; set; } = string.Empty;
/// <summary>
/// 开票税号
/// </summary>
public string? InvoiceTaxNo { get; set; }
/// <summary>
/// 开票地址
/// </summary>
public string? InvoiceAddress { get; set; }
/// <summary>
/// 开票电话
/// </summary>
public string? InvoiceTel { get; set; }
/// <summary>
/// 寄发票地址
/// </summary>
public string? SendInvoiceAddress { get; set; }
}

@ -115,6 +115,31 @@ public class InfoClientBank : BaseModelV2<long>
/// <summary>
/// 发票抬头
/// </summary>
[Navigate(NavigateType.OneToMany, nameof(InvoiceHeader.RelativeId))]
public List<InvoiceHeader>? InvoiceHeaders { get; set; }
[SugarColumn(ColumnDescription = "发票抬头", Length = 200, IsNullable = false)]
public string InvoiceHeader { get; set; } = string.Empty;
/// <summary>
/// 开票税号
/// </summary>
[SugarColumn(ColumnDescription = "开票税号", Length = 200, IsNullable = true)]
public string? InvoiceTaxNo { get; set; }
/// <summary>
/// 开票地址
/// </summary>
[SugarColumn(ColumnDescription = "开票地址", Length = 200, IsNullable = true)]
public string? InvoiceAddress { get; set; }
/// <summary>
/// 开票电话
/// </summary>
[SugarColumn(ColumnDescription = "开票电话", Length = 200, IsNullable = true)]
public string? InvoiceTel { get; set; }
/// <summary>
/// 寄发票地址
/// </summary>
[SugarColumn(ColumnDescription = "寄发票地址", Length = 200, IsNullable = true)]
public string? SendInvoiceAddress { get; set; }
///// <summary>
///// 发票抬头
///// </summary>
//[Navigate(NavigateType.OneToMany, nameof(InvoiceHeader.RelativeId))]
//public List<InvoiceHeader>? InvoiceHeaders { get; set; }
}

@ -34,18 +34,7 @@ public class ClientBankService : ServiceBase, IClientBankService
var whereList = request.GetConditionalModels(Db);
var result = TenantDb.Queryable<InfoClientBank>()
.Where(whereList)
.Select<ClientBankRes>().ToQueryPage(request.PageCondition);
if (result.Data?.Count > 0)
{
var ids = result.Data.Select(x => x.Id);
var list = TenantDb.Queryable<InvoiceHeader>().Where(x => ids.Contains(x.RelativeId)).ToList();
foreach (var item in result.Data)
{
item.InvoiceHeaders = list.FindAll(x => x.RelativeId == item.Id);
}
}
.Select<ClientBankRes>().ToQueryPage(request.PageCondition);
return result;
}
@ -62,7 +51,7 @@ public class ClientBankService : ServiceBase, IClientBankService
return DataResult.Failed("银行信息已存在!", MultiLanguageConst.ClientBankExist);
var data = req.Adapt<InfoClientBank>();
var entity = await TenantDb.InsertNav(data).Include(x => x.InvoiceHeaders).ExecuteReturnEntityAsync();
var entity = await TenantDb.Insertable(data).ExecuteReturnEntityAsync();
return DataResult.Successed("添加成功!", entity.Id, MultiLanguageConst.DataCreateSuccess);
}
else
@ -75,11 +64,7 @@ public class ClientBankService : ServiceBase, IClientBankService
info = req.Adapt(info);
await TenantDb.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
//创建或更新发票抬头
if (req.InvoiceHeaders?.Count > 0)
await TenantDb.Storageable(req.InvoiceHeaders).DefaultAddElseUpdate().ExecuteCommandAsync();
return DataResult.Successed("更新成功!", MultiLanguageConst.DataUpdateSuccess);
}
}
@ -94,11 +79,7 @@ public class ClientBankService : ServiceBase, IClientBankService
var data = await TenantDb.Queryable<InfoClientBank>()
.Where(a => a.Id == id)
.Select<ClientBankRes>()
.FirstAsync();
if (data != null)
data.InvoiceHeaders = await TenantDb.Queryable<InvoiceHeader>().Where(x => x.RelativeId == data.Id).ToListAsync();
.FirstAsync();
return DataResult<ClientBankRes>.Success(data, MultiLanguageConst.DataQuerySuccess);
}
@ -163,7 +144,6 @@ public class ClientBankService : ServiceBase, IClientBankService
CreateBy = userId,
CreateUserName = User.UserName,
CreateTime = dtNow,
InvoiceHeaders = []
};
if (bank.CodeName.Length > 50)
@ -173,12 +153,7 @@ public class ClientBankService : ServiceBase, IClientBankService
bank.Currency = FeeCurrency.RMB_CODE;
else if (model.Currency == "美元")
bank.Currency = FeeCurrency.USD_CODE;
bank.InvoiceHeaders.Add(new InvoiceHeader
{
Header = model.InvoiceHeader,
AddressTel = model.InvoiceAddress + " " + model.InvoiceTel
});
banks.Add(bank);
}
@ -200,17 +175,7 @@ public class ClientBankService : ServiceBase, IClientBankService
{
var batchList = banks.Skip(i * PAGE_SIZE).Take(PAGE_SIZE).ToList();
await TenantDb.Insertable(batchList).ExecuteCommandAsync();
}
foreach (var bank in banks)
{
foreach (var item in bank.InvoiceHeaders)
item.RelativeId = bank.Id;
}
var invoiceHeaders = banks.SelectMany(x => x.InvoiceHeaders).ToList();
await TenantDb.Fastest<InvoiceHeader>().BulkMergeAsync(invoiceHeaders);
}
await TenantDb.Ado.CommitTranAsync();
return DataResult.Success;
}

Loading…
Cancel
Save