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