|
|
@ -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,52 +27,59 @@ 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
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
invoiceType = ((int)x.Type).ToString(),
|
|
|
|
order = await TenantDb.Queryable<Entity.Invoice>().Where(x => ids.Contains(x.Id)).Select(x => new InvoiceInfo
|
|
|
|
orderNo = x.BillNO,
|
|
|
|
|
|
|
|
email = x.Email,
|
|
|
|
|
|
|
|
buyerTaxNum = x.TaxID,
|
|
|
|
|
|
|
|
buyerName = x.InvoiceHeader,
|
|
|
|
|
|
|
|
buyerAddress = x.CustomerAddress,
|
|
|
|
|
|
|
|
buyerTel = x.CustomerPhone,
|
|
|
|
|
|
|
|
gmfkhh = x.CustomerBankName,
|
|
|
|
|
|
|
|
gmfzh = x.CustomerAccount,
|
|
|
|
|
|
|
|
skyhmc = x.BankName,
|
|
|
|
|
|
|
|
skyhzh = x.Account,
|
|
|
|
|
|
|
|
checker = x.Checker,
|
|
|
|
|
|
|
|
payee = x.Payee,
|
|
|
|
|
|
|
|
//---------金额项---------
|
|
|
|
|
|
|
|
hjse = x.InvoiceAmount * x.TaxRate,
|
|
|
|
|
|
|
|
hjje = x.InvoiceAmount - x.InvoiceAmount * x.TaxRate,
|
|
|
|
|
|
|
|
jshj = x.InvoiceAmount,
|
|
|
|
|
|
|
|
clerk = x.CreateUserName, //开票人
|
|
|
|
|
|
|
|
kprzjhm = "", //证件号
|
|
|
|
|
|
|
|
kprzjlx = "201", //身份证,
|
|
|
|
|
|
|
|
//---------发票明细---------
|
|
|
|
|
|
|
|
invoiceDetail = x.InvoiceDetails.Select(y => new InvoiceDetailInfo
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
mxxh = x.InvoiceDetails.IndexOf(y) + 1,
|
|
|
|
invoiceType = ((int)x.Type).ToString(),
|
|
|
|
xmmc = y.Name,
|
|
|
|
orderNo = x.BillNO,
|
|
|
|
spfwjc = string.Empty,
|
|
|
|
email = x.Email,
|
|
|
|
specType = y.Specification,
|
|
|
|
buyerTaxNum = x.TaxID,
|
|
|
|
unit = y.Unit,
|
|
|
|
buyerName = x.InvoiceHeader,
|
|
|
|
num = y.Quantity.ToString(),
|
|
|
|
buyerAddress = x.CustomerAddress,
|
|
|
|
taxExcludedAmount = y.UnitPrice,
|
|
|
|
buyerTel = x.CustomerPhone,
|
|
|
|
taxRate = y.TaxRate.ToString(),
|
|
|
|
gmfkhh = x.CustomerBankName,
|
|
|
|
tax = y.TaxAmount,
|
|
|
|
gmfzh = x.CustomerAccount,
|
|
|
|
taxIncludedAmount = y.TaxUnitPrice,
|
|
|
|
skyhmc = x.BankName,
|
|
|
|
goodsCode = "", //商品和服务税收分类合并编码
|
|
|
|
skyhzh = x.Account,
|
|
|
|
invoiceLineProperty = "00"
|
|
|
|
checker = x.Checker,
|
|
|
|
}).ToList()
|
|
|
|
payee = x.Payee,
|
|
|
|
|
|
|
|
//---------金额项---------
|
|
|
|
|
|
|
|
hjse = x.InvoiceAmount * x.TaxRate,
|
|
|
|
|
|
|
|
hjje = x.InvoiceAmount - x.InvoiceAmount * x.TaxRate,
|
|
|
|
|
|
|
|
jshj = x.InvoiceAmount,
|
|
|
|
|
|
|
|
clerk = x.CreateUserName, //开票人
|
|
|
|
|
|
|
|
kprzjhm = "", //证件号
|
|
|
|
|
|
|
|
kprzjlx = "201", //身份证,
|
|
|
|
|
|
|
|
//---------发票明细---------
|
|
|
|
|
|
|
|
invoiceDetail = x.InvoiceDetails.Select(y => new InvoiceDetailInfo
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
mxxh = SqlFunc.RowNumber(y.Id), //x.InvoiceDetails.IndexOf(y) + 1,
|
|
|
|
|
|
|
|
xmmc = y.Name,
|
|
|
|
|
|
|
|
spfwjc = string.Empty,
|
|
|
|
|
|
|
|
specType = y.Specification,
|
|
|
|
|
|
|
|
unit = y.Unit,
|
|
|
|
|
|
|
|
num = y.Quantity.ToString(),
|
|
|
|
|
|
|
|
taxExcludedAmount = y.UnitPrice,
|
|
|
|
|
|
|
|
taxRate = y.TaxRate.ToString(),
|
|
|
|
|
|
|
|
tax = y.TaxAmount,
|
|
|
|
|
|
|
|
taxIncludedAmount = y.TaxUnitPrice,
|
|
|
|
|
|
|
|
goodsCode = "", //商品和服务税收分类合并编码
|
|
|
|
|
|
|
|
invoiceLineProperty = "00"
|
|
|
|
|
|
|
|
}).ToList()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}).ToListAsync()
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
}).ToList();
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|