|
|
|
@ -6,6 +6,8 @@ using DS.WMS.Core.Invoice.Dtos;
|
|
|
|
|
using DS.WMS.Core.Sys.Entity;
|
|
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
|
using Org.BouncyCastle.Crypto;
|
|
|
|
|
using SqlSugar;
|
|
|
|
|
|
|
|
|
|
namespace DS.WMS.Core.Invoice.Method
|
|
|
|
@ -30,9 +32,9 @@ namespace DS.WMS.Core.Invoice.Method
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 发起开票请求
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="ids">开票的发票ID</param>
|
|
|
|
|
/// <param name="ids">发票ID</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<DataResult<string>> InitiateAsync(params long[] ids)
|
|
|
|
|
public async Task<DataResult<JObject>> InitiateAsync(params long[] ids)
|
|
|
|
|
{
|
|
|
|
|
ArgumentNullException.ThrowIfNull(ids, nameof(ids));
|
|
|
|
|
|
|
|
|
@ -44,7 +46,7 @@ namespace DS.WMS.Core.Invoice.Method
|
|
|
|
|
}).FirstAsync();
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(userInfo.IdCardNo))
|
|
|
|
|
return DataResult<string>.FailedWithDesc(MultiLanguageConst.DrawerIDNumberIsNull);
|
|
|
|
|
return DataResult<JObject>.FailedWithDesc(MultiLanguageConst.DrawerIDNumberIsNull);
|
|
|
|
|
|
|
|
|
|
//请求参数设置
|
|
|
|
|
InvoiceIssuanceRequest request = new()
|
|
|
|
@ -94,23 +96,52 @@ namespace DS.WMS.Core.Invoice.Method
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (request.order.Count == 0 || request.order.Any(x => x.invoiceDetail.Count == 0))
|
|
|
|
|
return DataResult<string>.FailedWithDesc(MultiLanguageConst.InvoiceIncomplete);
|
|
|
|
|
return DataResult<JObject>.FailedWithDesc(MultiLanguageConst.InvoiceIncomplete);
|
|
|
|
|
|
|
|
|
|
var result = await api.PostAsync<InvoiceIssuanceResult<string>>("/api/Invoice/services", request);
|
|
|
|
|
var result = await api.PostAsync<InvoiceResult<string>>("/api/Invoice/services", request);
|
|
|
|
|
if (!result.Succeeded)
|
|
|
|
|
return DataResult<string>.Failed(result.Message, result.MultiCode);
|
|
|
|
|
return DataResult<JObject>.Failed(result.Message, result.MultiCode);
|
|
|
|
|
|
|
|
|
|
var invResult = result.Data;
|
|
|
|
|
JObject? jObj = JObject.Parse(invResult.Data);
|
|
|
|
|
if (invResult.Success)
|
|
|
|
|
{
|
|
|
|
|
return DataResult<string>.Success(invResult.Data);
|
|
|
|
|
return DataResult<JObject>.Success(jObj);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (invResult.Code == 1)
|
|
|
|
|
return await InitiateAsync(ids);
|
|
|
|
|
|
|
|
|
|
return DataResult<string>.Failed(invResult.Message);
|
|
|
|
|
return DataResult<JObject>.FailedData(jObj, invResult.Message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 发票冲红
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="id">发票ID</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<DataResult<JObject>> ReverseAsync(long id)
|
|
|
|
|
{
|
|
|
|
|
var invoice = await TenantDb.Queryable<Entity.Invoice>().FirstAsync(x => x.Id == id);
|
|
|
|
|
if (invoice == null)
|
|
|
|
|
return DataResult<JObject>.FailedWithDesc(MultiLanguageConst.EmptyData);
|
|
|
|
|
|
|
|
|
|
var req = new InvoiceReversalRequest { orderNo = invoice.BillNO };
|
|
|
|
|
var result = await api.PostAsync<InvoiceResult<string>>("/api/Invoice/RedInvoicing", req);
|
|
|
|
|
if (!result.Succeeded)
|
|
|
|
|
return DataResult<JObject>.Failed(result.Message, result.MultiCode);
|
|
|
|
|
|
|
|
|
|
var invResult = result.Data;
|
|
|
|
|
JObject? jObj = JObject.Parse(invResult.Data);
|
|
|
|
|
if (invResult.Success)
|
|
|
|
|
{
|
|
|
|
|
return DataResult<JObject>.Success(jObj);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return DataResult<JObject>.FailedData(jObj, invResult.Message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|