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

dev
cjy 4 weeks ago
parent 5189da36bc
commit 9534ac328e

@ -1,6 +1,7 @@
using DS.Module.Core; using DS.Module.Core;
using DS.WMS.Core.Info.Entity; using DS.WMS.Core.Info.Entity;
using FluentValidation; using FluentValidation;
using SqlSugar;
namespace DS.WMS.Core.Info.Dtos; namespace DS.WMS.Core.Info.Dtos;
@ -99,11 +100,30 @@ public class ClientBankReq
/// 备注 /// 备注
/// </summary> /// </summary>
public string? Note { get; set; } public string? Note { get; set; }
/// <summary> /// <summary>
/// 发票抬头 /// 发票抬头
/// </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> /// <summary>

@ -105,8 +105,28 @@ public class ClientBankRes
/// </summary> /// </summary>
public DateTime CreateTime { get; set; } public DateTime CreateTime { get; set; }
///// <summary>
///// 发票抬头
///// </summary>
//public List<InvoiceHeader> InvoiceHeaders { get; set; } = [];
/// <summary> /// <summary>
/// 发票抬头 /// 发票抬头
/// </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>
/// 发票抬头 /// 发票抬头
/// </summary> /// </summary>
[Navigate(NavigateType.OneToMany, nameof(InvoiceHeader.RelativeId))] [SugarColumn(ColumnDescription = "发票抬头", Length = 200, IsNullable = false)]
public List<InvoiceHeader>? InvoiceHeaders { get; set; } 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; }
} }

@ -35,17 +35,6 @@ public class ClientBankService : ServiceBase, IClientBankService
var result = TenantDb.Queryable<InfoClientBank>() var result = TenantDb.Queryable<InfoClientBank>()
.Where(whereList) .Where(whereList)
.Select<ClientBankRes>().ToQueryPage(request.PageCondition); .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);
}
}
return result; return result;
} }
@ -62,7 +51,7 @@ public class ClientBankService : ServiceBase, IClientBankService
return DataResult.Failed("银行信息已存在!", MultiLanguageConst.ClientBankExist); return DataResult.Failed("银行信息已存在!", MultiLanguageConst.ClientBankExist);
var data = req.Adapt<InfoClientBank>(); 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); return DataResult.Successed("添加成功!", entity.Id, MultiLanguageConst.DataCreateSuccess);
} }
else else
@ -76,10 +65,6 @@ public class ClientBankService : ServiceBase, IClientBankService
info = req.Adapt(info); info = req.Adapt(info);
await TenantDb.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync(); 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); return DataResult.Successed("更新成功!", MultiLanguageConst.DataUpdateSuccess);
} }
} }
@ -95,10 +80,6 @@ public class ClientBankService : ServiceBase, IClientBankService
.Where(a => a.Id == id) .Where(a => a.Id == id)
.Select<ClientBankRes>() .Select<ClientBankRes>()
.FirstAsync(); .FirstAsync();
if (data != null)
data.InvoiceHeaders = await TenantDb.Queryable<InvoiceHeader>().Where(x => x.RelativeId == data.Id).ToListAsync();
return DataResult<ClientBankRes>.Success(data, MultiLanguageConst.DataQuerySuccess); return DataResult<ClientBankRes>.Success(data, MultiLanguageConst.DataQuerySuccess);
} }
@ -163,7 +144,6 @@ public class ClientBankService : ServiceBase, IClientBankService
CreateBy = userId, CreateBy = userId,
CreateUserName = User.UserName, CreateUserName = User.UserName,
CreateTime = dtNow, CreateTime = dtNow,
InvoiceHeaders = []
}; };
if (bank.CodeName.Length > 50) if (bank.CodeName.Length > 50)
@ -174,11 +154,6 @@ public class ClientBankService : ServiceBase, IClientBankService
else if (model.Currency == "美元") else if (model.Currency == "美元")
bank.Currency = FeeCurrency.USD_CODE; bank.Currency = FeeCurrency.USD_CODE;
bank.InvoiceHeaders.Add(new InvoiceHeader
{
Header = model.InvoiceHeader,
AddressTel = model.InvoiceAddress + " " + model.InvoiceTel
});
banks.Add(bank); banks.Add(bank);
} }
@ -201,16 +176,6 @@ public class ClientBankService : ServiceBase, IClientBankService
var batchList = banks.Skip(i * PAGE_SIZE).Take(PAGE_SIZE).ToList(); var batchList = banks.Skip(i * PAGE_SIZE).Take(PAGE_SIZE).ToList();
await TenantDb.Insertable(batchList).ExecuteCommandAsync(); 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(); await TenantDb.Ado.CommitTranAsync();
return DataResult.Success; return DataResult.Success;
} }

Loading…
Cancel
Save