更新发票号码

dev
嵇文龙 4 weeks ago
parent 41e95fa6c5
commit e28c3e739a

@ -18,9 +18,9 @@ namespace DS.WMS.Core.Invoice.Interface
/// <summary>
/// 更新发票号码
/// </summary>
/// <param name="sn">开票流水号</param>
/// <param name="id"></param>
/// <returns></returns>
Task<DataResult> UpdateInvoiceNumberAsync(string sn);
Task<DataResult> UpdateInvoiceNumberAsync(long id);
/// <summary>
/// 发票冲红

@ -21,7 +21,7 @@ namespace DS.WMS.Core.Invoice.Method
{
//readonly InvoiceApiFox api;
static readonly ApiFox api;
static InvoiceIssuanceService()
{
api = new ApiFox();
@ -34,7 +34,7 @@ namespace DS.WMS.Core.Invoice.Method
public InvoiceIssuanceService(IServiceProvider provider) : base(provider)
{
var config = provider.GetRequiredService<IConfiguration>();
}
/// <summary>
@ -134,9 +134,9 @@ namespace DS.WMS.Core.Invoice.Method
var invoices = ids.Select(x => new Entity.Invoice { Id = x, SN = sn, ApiType = InvoiceApiType.Default }).ToList();
await TenantDb.Updateable(invoices).UpdateColumns(x => new { x.SN, x.ApiType }).ExecuteCommandAsync();
UpdateInvoiceNumberAsync(sn);
await UpdateInvoiceNumberAsync(sn);
return DataResult.Success;
return DataResult.Successed("开票已提交", data: sn);
}
else
{
@ -175,9 +175,9 @@ namespace DS.WMS.Core.Invoice.Method
if (queryResult == null || !queryResult.Success)
return DataResult.Failed(queryResult?.Message);
List<Entity.Invoice> invoices = [];
if (queryResult.Data.Order?.Count > 0)
{
List<Entity.Invoice> invoices = [];
foreach (var item in queryResult.Data.Order)
{
var inv = new Entity.Invoice
@ -218,7 +218,24 @@ namespace DS.WMS.Core.Invoice.Method
}).ExecuteCommandAsync();
}
return DataResult.Success;
var result2 = DataResult.Success;
result2.Data = invoices;
return result2;
}
/// <summary>
/// 更新发票号码
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public async Task<DataResult> UpdateInvoiceNumberAsync(long id)
{
var model = await TenantDb.Queryable<Entity.Invoice>().Where(x => x.Id == id)
.Select(x => new { x.Id, x.SN, x.SaleDeptId, x.ApiType }).FirstAsync();
if (model == null)
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.EmptyData));
return await UpdateInvoiceNumberAsync(model.SN);
}
/// <summary>
@ -242,7 +259,7 @@ namespace DS.WMS.Core.Invoice.Method
api.DefaultHeaders.Add("USER_KEY", orgauthinfo.Key);
api.DefaultHeaders.Add("USER_SECRET", orgauthinfo.Secret);
var result = await api.PostAsync<InvoiceResult<string>>(AppSetting.app(new string[] { "InvoiceApi", "BaseUrl" }) + "/api/Invoice/RedInvoicing", req);
if (!result.Succeeded)
return DataResult.Failed(result.Message, result.MultiCode);

@ -146,6 +146,18 @@ namespace DS.WMS.FeeApi.Controllers
return await _service.SetLockAsync(isLocked, model.Ids);
}
/// <summary>
/// 请求开票API查询发票状态
/// </summary>
/// <param name="issuanceService"></param>
/// <param name="id"></param>
/// <returns></returns>
[HttpPost, Route("ApiQuery")]
public async Task<DataResult> ApiQueryAsync([FromServices] IInvoiceIssuanceService issuanceService, long id)
{
return await issuanceService.UpdateInvoiceNumberAsync(id);
}
/// <summary>
/// 发起开票请求
/// </summary>

Loading…
Cancel
Save