|
|
@ -12,6 +12,7 @@ using EntrustSettle.Model.Models.DJY;
|
|
|
|
using EntrustSettle.Model.Validator;
|
|
|
|
using EntrustSettle.Model.Validator;
|
|
|
|
using EntrustSettle.Repository.UnitOfWorks;
|
|
|
|
using EntrustSettle.Repository.UnitOfWorks;
|
|
|
|
using FluentValidation;
|
|
|
|
using FluentValidation;
|
|
|
|
|
|
|
|
using Mapster;
|
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
using Newtonsoft.Json;
|
|
|
@ -916,7 +917,8 @@ namespace EntrustSettle.Api.Controllers
|
|
|
|
var noStatusOrderList = orderList.Where(x => x.Status != 3 && x.Status != 4);
|
|
|
|
var noStatusOrderList = orderList.Where(x => x.Status != 3 && x.Status != 4);
|
|
|
|
if (noStatusOrderList.Any())
|
|
|
|
if (noStatusOrderList.Any())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
throw new Exception("需要在订单具有【已缴费】或【已完结】状态时才能进行发票申请,下列订单状态不符合条件,请重新选择:" + string.Join("、", noStatusOrderList.Select(x => x.Mblno)));
|
|
|
|
//throw new Exception("需要在订单具有【已缴费】或【已完结】状态时才能进行发票申请,下列订单状态不符合条件,请重新选择:" + string.Join("、", noStatusOrderList.Select(x => x.Mblno)));
|
|
|
|
|
|
|
|
throw new Exception("业务尚未缴费,请先缴费");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 判断是否存在申请中的发票
|
|
|
|
// 判断是否存在申请中的发票
|
|
|
@ -926,11 +928,11 @@ namespace EntrustSettle.Api.Controllers
|
|
|
|
throw new Exception("下列订单正在申请开票中,无法重复申请,请重新选择:" + string.Join("、", applyingOrderList.Select(x => x.Mblno)));
|
|
|
|
throw new Exception("下列订单正在申请开票中,无法重复申请,请重新选择:" + string.Join("、", applyingOrderList.Select(x => x.Mblno)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// 判断是否存在已开票的发票
|
|
|
|
// 判断是否存在已开票的发票
|
|
|
|
var existsInvoiceOrderIdList = orderAnnexService.AsQueryable()
|
|
|
|
var existsInvoiceOrderIdList = await orderAnnexService.AsQueryable()
|
|
|
|
.LeftJoin<Annex>((o, a) => o.AnnexId == a.Id)
|
|
|
|
.LeftJoin<Annex>((o, a) => o.AnnexId == a.Id)
|
|
|
|
.Where((o, a) => input.OrderIdList.Contains(o.OrderId) && a.Type == (int)FileTypeEnum.发票)
|
|
|
|
.Where((o, a) => input.OrderIdList.Contains(o.OrderId) && a.Type == (int)FileTypeEnum.发票)
|
|
|
|
.Select((o, a) => o.OrderId)
|
|
|
|
.Select((o, a) => o.OrderId)
|
|
|
|
.ToList();
|
|
|
|
.ToListAsync();
|
|
|
|
if (existsInvoiceOrderIdList.Count > 0)
|
|
|
|
if (existsInvoiceOrderIdList.Count > 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
throw new Exception("下列订单已存在发票,无法重复申请,请重新选择:" +
|
|
|
|
throw new Exception("下列订单已存在发票,无法重复申请,请重新选择:" +
|
|
|
@ -974,11 +976,14 @@ namespace EntrustSettle.Api.Controllers
|
|
|
|
long bsno = await hydService.Submit(submitDto);
|
|
|
|
long bsno = await hydService.Submit(submitDto);
|
|
|
|
|
|
|
|
|
|
|
|
// 记录发票申请(用于接收到发票回推后,可以查询到关联的订单)
|
|
|
|
// 记录发票申请(用于接收到发票回推后,可以查询到关联的订单)
|
|
|
|
var invoiceApplyModelList = orderList.Select(x => new InvoiceApply()
|
|
|
|
var invoiceApplyModelList = orderList.Select(x =>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
OrderId = x.Id,
|
|
|
|
var applyInfo = input.Adapt<InvoiceApply>();
|
|
|
|
Bsno = bsno,
|
|
|
|
applyInfo.OrderId = x.Id;
|
|
|
|
Remark = remark,
|
|
|
|
applyInfo.Bsno = bsno;
|
|
|
|
|
|
|
|
applyInfo.Remark = input.Remark;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return applyInfo;
|
|
|
|
}).ToList();
|
|
|
|
}).ToList();
|
|
|
|
await invoiceApplyService.Add(invoiceApplyModelList);
|
|
|
|
await invoiceApplyService.Add(invoiceApplyModelList);
|
|
|
|
|
|
|
|
|
|
|
@ -1017,15 +1022,30 @@ namespace EntrustSettle.Api.Controllers
|
|
|
|
x.Id,
|
|
|
|
x.Id,
|
|
|
|
x.Mblno,
|
|
|
|
x.Mblno,
|
|
|
|
x.Bsno,
|
|
|
|
x.Bsno,
|
|
|
|
x.Status
|
|
|
|
x.Status,
|
|
|
|
|
|
|
|
x.IsApplyBill
|
|
|
|
}).FirstAsync();
|
|
|
|
}).FirstAsync();
|
|
|
|
if (order == null)
|
|
|
|
if (order == null)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
throw new Exception("待申请账单的数据可能已删除,请重新查询后重新申请");
|
|
|
|
throw new Exception("待申请账单的数据可能已删除,请重新查询后重新申请");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (order.Status != 4)
|
|
|
|
if (order.Status != 4 && order.Status != 2 && order.Status != 3)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw new Exception("业务尚未完结,无法出具账单");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (order.IsApplyBill)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
throw new Exception("该订单正在申请账单中,请耐心等待");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 判断是否存账单
|
|
|
|
|
|
|
|
var existsBill = await orderAnnexService.AsQueryable()
|
|
|
|
|
|
|
|
.LeftJoin<Annex>((o, a) => o.AnnexId == a.Id)
|
|
|
|
|
|
|
|
.Where((o, a) => order.Id == o.OrderId && a.Type == (int)FileTypeEnum.账单)
|
|
|
|
|
|
|
|
.AnyAsync();
|
|
|
|
|
|
|
|
if (existsBill)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
throw new Exception("需要在订单具有【已完结】状态时才能进行账单申请");
|
|
|
|
throw new Exception("该订单已存在账单,无法重复申请");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
HydFeedbackDto feedbackDto = new()
|
|
|
|
HydFeedbackDto feedbackDto = new()
|
|
|
|