|
|
|
@ -3,6 +3,7 @@ using DS.WMS.Core.Application.Method;
|
|
|
|
|
using DS.WMS.Core.Invoice.Dtos;
|
|
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using SqlSugar;
|
|
|
|
|
|
|
|
|
|
namespace DS.WMS.Core.Invoice.Method
|
|
|
|
|
{
|
|
|
|
@ -26,13 +27,16 @@ namespace DS.WMS.Core.Invoice.Method
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 发起开票请求
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="invoices">开票的发票信息</param>
|
|
|
|
|
/// <param name="ids">开票的发票ID</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<DataResult<string>> InitiateAsync(params Entity.Invoice[] invoices)
|
|
|
|
|
public async Task<DataResult<string>> InitiateAsync(params long[] ids)
|
|
|
|
|
{
|
|
|
|
|
ArgumentNullException.ThrowIfNull(ids, nameof(ids));
|
|
|
|
|
|
|
|
|
|
//请求参数设置
|
|
|
|
|
InvoiceIssuanceRequest request = new();
|
|
|
|
|
request.order = invoices.Select(x => new InvoiceInfo
|
|
|
|
|
InvoiceIssuanceRequest request = new()
|
|
|
|
|
{
|
|
|
|
|
order = await TenantDb.Queryable<Entity.Invoice>().Where(x => ids.Contains(x.Id)).Select(x => new InvoiceInfo
|
|
|
|
|
{
|
|
|
|
|
invoiceType = ((int)x.Type).ToString(),
|
|
|
|
|
orderNo = x.BillNO,
|
|
|
|
@ -57,7 +61,7 @@ namespace DS.WMS.Core.Invoice.Method
|
|
|
|
|
//---------发票明细---------
|
|
|
|
|
invoiceDetail = x.InvoiceDetails.Select(y => new InvoiceDetailInfo
|
|
|
|
|
{
|
|
|
|
|
mxxh = x.InvoiceDetails.IndexOf(y) + 1,
|
|
|
|
|
mxxh = SqlFunc.RowNumber(y.Id), //x.InvoiceDetails.IndexOf(y) + 1,
|
|
|
|
|
xmmc = y.Name,
|
|
|
|
|
spfwjc = string.Empty,
|
|
|
|
|
specType = y.Specification,
|
|
|
|
@ -71,7 +75,11 @@ namespace DS.WMS.Core.Invoice.Method
|
|
|
|
|
invoiceLineProperty = "00"
|
|
|
|
|
}).ToList()
|
|
|
|
|
|
|
|
|
|
}).ToList();
|
|
|
|
|
}).ToListAsync()
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (request.order.Count == 0 || request.order.Any(x => x.invoiceDetail.Count == 0))
|
|
|
|
|
return DataResult<string>.FailedWithDesc(MultiLanguageConst.InvoiceIncomplete);
|
|
|
|
|
|
|
|
|
|
var result = await api.PostAsync<InvoiceIssuanceResult<string>>("/api/Invoice/services", request);
|
|
|
|
|
if (!result.Succeeded)
|
|
|
|
@ -80,14 +88,12 @@ namespace DS.WMS.Core.Invoice.Method
|
|
|
|
|
var invResult = result.Data;
|
|
|
|
|
if (invResult.Success)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return DataResult<string>.Success(invResult.Data);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (invResult.Code == 1)
|
|
|
|
|
return await InitiateAsync(invoices);
|
|
|
|
|
return await InitiateAsync(ids);
|
|
|
|
|
|
|
|
|
|
return DataResult<string>.Failed(invResult.Message);
|
|
|
|
|
}
|
|
|
|
|