wanggang 1 year ago
parent
commit
f2798c592d
  1. 8
      code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/BBAC_CAN_SA_DTO.cs
  2. 7
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/BASE_SERVICE.cs
  3. 9
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/BA_SERVICE.cs
  4. 14
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/CAN_SA_SERVICE.cs
  5. 4
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/PD_SERVICE.cs
  6. 2
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_BA_SERVICE.cs
  7. 192
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_CAN_SA_SERVICE.cs
  8. 4
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_PD_SERVICE.cs
  9. 2
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_BA_SERVICE.cs
  10. 5
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_CAN_SA_SERVICE.cs
  11. 1
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_NOT_SA_SERVICE.cs
  12. 4
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_PD_SERVICE.cs
  13. 2
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/INVOICE_SERVICE.cs
  14. 2
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_BA_SERVICE.cs
  15. 5
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_CAN_SA_SERVICE.cs
  16. 4
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_PD_SERVICE.cs
  17. 12
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/INVOICE_GRP.cs
  18. 7
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/INVOICE_WAIT_DETAIL.cs
  19. 92
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/CAN_SA_MNG.cs
  20. 255
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/INV_MNG.cs
  21. 44
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/PD_MNG.cs

8
code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/BBAC_CAN_SA_DTO.cs

@ -1,4 +1,4 @@
using Magicodes.ExporterAndImporter.Core; using Magicodes.ExporterAndImporter.Core;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
@ -94,6 +94,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
/// 结算分组号 /// 结算分组号
/// </summary> /// </summary>
public string GroupNum { get; set; } public string GroupNum { get; set; }
/// <summary>
/// 金额
/// </summary>
public decimal Amt { get; set; }
} }
public class BBAC_CAN_SA_DETAIL_EXP_DTO public class BBAC_CAN_SA_DETAIL_EXP_DTO
@ -191,6 +195,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
public string SettleBillNum { get; set; } public string SettleBillNum { get; set; }
[Display(Name = "状态")] [Display(Name = "状态")]
public string State { get; set; } public string State { get; set; }
[Display(Name = "发票分组号")]
public string InvGroupNum { get; set; }
} }
public class BBAC_CAN_SA_DETAIL_REQ_DTO : RequestInputBase public class BBAC_CAN_SA_DETAIL_REQ_DTO : RequestInputBase

7
code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/BASE_SERVICE.cs

@ -83,12 +83,5 @@ namespace Win.Sfs.SettleAccount.Bases
); );
return fileName; return fileName;
} }
} }
} }

9
code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/BA_SERVICE.cs

@ -31,7 +31,7 @@ namespace Win.Sfs.SettleAccount.Bases
{ {
public abstract class BA_SERVICE: BASE_SERVICE public abstract class BA_SERVICE: BASE_SERVICE
{ {
private readonly INormalEfCoreRepository<INVOICE_GRP, Guid> _repository; protected readonly INormalEfCoreRepository<INVOICE_GRP, Guid> _repository;
private readonly INormalEfCoreRepository<INVOICE_WAIT_DETAIL, Guid> _wRepository; private readonly INormalEfCoreRepository<INVOICE_WAIT_DETAIL, Guid> _wRepository;
private readonly INormalEfCoreRepository<INVOICE_NOT_SETTLE, Guid> _sRepository; private readonly INormalEfCoreRepository<INVOICE_NOT_SETTLE, Guid> _sRepository;
private readonly INormalEfCoreRepository<INVOICE_MAP_GROUP, Guid> _mRepository; private readonly INormalEfCoreRepository<INVOICE_MAP_GROUP, Guid> _mRepository;
@ -77,8 +77,13 @@ namespace Win.Sfs.SettleAccount.Bases
/// </summary> /// </summary>
/// <param name="input"></param> /// <param name="input"></param>
/// <returns></returns> /// <returns></returns>
public virtual async Task<string> GenerateInvoice(INVOICE_GRP_REQ_DTO input) public virtual async Task<string> GenerateInvoice(INVOICE_GRP_REQ_DTO input)
{ {
await _invMng.SetForwardState(input.InvGroupNum, SettleBillState.);
return ApplicationConsts.SuccessStr; return ApplicationConsts.SuccessStr;
} }
@ -183,7 +188,7 @@ namespace Win.Sfs.SettleAccount.Bases
bool flag = await _invMng.ReceivedAsync(entity.InvGroupNum); bool flag = await _invMng.ReceivedAsync(entity.InvGroupNum);
if (flag == true) if (flag == true)
{ {
await _invMng.SetForwardState(entity, InvoiceBillState.); await _invMng.SetForwardState(entity,SettleBillState.);
} }
} }

14
code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/CAN_SA_SERVICE.cs

@ -22,6 +22,7 @@ using Win.Sfs.BaseData.ImportExcelCommon;
using Win.Sfs.SettleAccount.Constant; using Win.Sfs.SettleAccount.Constant;
using Win.Sfs.SettleAccount.Entities.BQ; using Win.Sfs.SettleAccount.Entities.BQ;
using Win.Sfs.SettleAccount.Entities.BQ.Dtos; using Win.Sfs.SettleAccount.Entities.BQ.Dtos;
using Win.Sfs.SettleAccount.Entities.BQ.Managers;
using Win.Sfs.SettleAccount.ExcelImporter; using Win.Sfs.SettleAccount.ExcelImporter;
using Win.Sfs.SettleAccount.ExportReports; using Win.Sfs.SettleAccount.ExportReports;
using Win.Sfs.Shared.RepositoryBase; using Win.Sfs.Shared.RepositoryBase;
@ -37,19 +38,20 @@ namespace Win.Sfs.SettleAccount.Bases
where TRequestDetailInput : RequestInputBase where TRequestDetailInput : RequestInputBase
where TEntityDetailExportDto : class, new() where TEntityDetailExportDto : class, new()
{ {
private readonly INormalEfCoreRepository<TEntity, Guid> _repository; protected readonly INormalEfCoreRepository<TEntity, Guid> _repository;
private readonly INormalEfCoreRepository<TEntityDetail, Guid> _detailRepository; protected readonly INormalEfCoreRepository<TEntityDetail, Guid> _detailRepository;
private readonly IExcelImportAppService _excelImportService; private readonly IExcelImportAppService _excelImportService;
protected readonly INV_MNG _invmng;
protected CAN_SA_SERVICE( protected CAN_SA_SERVICE(
INormalEfCoreRepository<TEntity, Guid> repository, INormalEfCoreRepository<TEntity, Guid> repository,
IExcelImportAppService excelImportService, IExcelImportAppService excelImportService,
INormalEfCoreRepository<TEntityDetail, Guid> detailRepository INormalEfCoreRepository<TEntityDetail, Guid> detailRepository,
INV_MNG invmng
) )
{ {
_invmng= invmng;
_excelImportService = excelImportService; _excelImportService = excelImportService;
_repository = repository; _repository = repository;
_detailRepository = detailRepository; _detailRepository = detailRepository;

4
code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/PD_SERVICE.cs

@ -142,12 +142,12 @@ namespace Win.Sfs.SettleAccount.Bases
return ApplicationConsts.SuccessStr; return ApplicationConsts.SuccessStr;
} }
public virtual async Task<TEntity> GetMainByBillNum(string billNum) public virtual async Task<TEntity> GetMainAsync(string billNum)
{ {
return await _repository.Where(p=>p.InvGroupNum == billNum).FirstOrDefaultAsync(); return await _repository.Where(p=>p.InvGroupNum == billNum).FirstOrDefaultAsync();
} }
public virtual async Task<List<TEntityDetail>> GetDetailByBillNum(string billNum) public virtual async Task<List<TEntityDetail>> GetDetailAsync(string billNum)
{ {
return await _detailRepository.Where(p => p.InvGroupNum == billNum).ToListAsync(); return await _detailRepository.Where(p => p.InvGroupNum == billNum).ToListAsync();
} }

2
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_BA_SERVICE.cs

@ -18,7 +18,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
/// BBAC业务商务审核 /// BBAC业务商务审核
/// </summary> /// </summary>
[AllowAnonymous] [AllowAnonymous]
[Route("api/settleaccount/bbac_ba_service")] [Route("api/settleaccount/[controller]/[action]")]
public class BBAC_BA_SERVICE : BA_SERVICE public class BBAC_BA_SERVICE : BA_SERVICE
{ {
public BBAC_BA_SERVICE(INormalEfCoreRepository<INVOICE_GRP, Guid> repository, INormalEfCoreRepository<INVOICE_WAIT_DETAIL, Guid> wRepository, INormalEfCoreRepository<INVOICE_NOT_SETTLE, Guid> sRepository, INormalEfCoreRepository<INVOICE_MAP_GROUP, Guid> mRepository, IExcelImportAppService excelImportService, CAN_SA_MNG<PUB_CAN_SA, PUB_CAN_SA_DETAIL> pubMng, CAN_SA_MNG<BBAC_CAN_SA, BBAC_CAN_SA_DETAIL> bbacMng, CAN_SA_MNG<HBPO_CAN_SA, HBPO_CAN_SA_DETAIL> hbpoMng, INV_MNG invMng) : base(repository, wRepository, sRepository, mRepository, excelImportService, pubMng, bbacMng, hbpoMng, invMng) public BBAC_BA_SERVICE(INormalEfCoreRepository<INVOICE_GRP, Guid> repository, INormalEfCoreRepository<INVOICE_WAIT_DETAIL, Guid> wRepository, INormalEfCoreRepository<INVOICE_NOT_SETTLE, Guid> sRepository, INormalEfCoreRepository<INVOICE_MAP_GROUP, Guid> mRepository, IExcelImportAppService excelImportService, CAN_SA_MNG<PUB_CAN_SA, PUB_CAN_SA_DETAIL> pubMng, CAN_SA_MNG<BBAC_CAN_SA, BBAC_CAN_SA_DETAIL> bbacMng, CAN_SA_MNG<HBPO_CAN_SA, HBPO_CAN_SA_DETAIL> hbpoMng, INV_MNG invMng) : base(repository, wRepository, sRepository, mRepository, excelImportService, pubMng, bbacMng, hbpoMng, invMng)

192
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_CAN_SA_SERVICE.cs

@ -1,4 +1,4 @@
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using NPOI.SS.Formula.Functions; using NPOI.SS.Formula.Functions;
@ -10,10 +10,12 @@ using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services; using Volo.Abp.Application.Services;
using Volo.Abp.ObjectMapping;
using Win.Sfs.BaseData.ImportExcelCommon; using Win.Sfs.BaseData.ImportExcelCommon;
using Win.Sfs.SettleAccount.Bases; using Win.Sfs.SettleAccount.Bases;
using Win.Sfs.SettleAccount.Constant; using Win.Sfs.SettleAccount.Constant;
using Win.Sfs.SettleAccount.Entities.BQ.Dtos; using Win.Sfs.SettleAccount.Entities.BQ.Dtos;
using Win.Sfs.SettleAccount.Entities.BQ.Managers;
using Win.Sfs.Shared.RepositoryBase; using Win.Sfs.Shared.RepositoryBase;
namespace Win.Sfs.SettleAccount.Entities.BQ namespace Win.Sfs.SettleAccount.Entities.BQ
@ -35,57 +37,189 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
BBAC_CAN_SA_DETAIL_EXP_DTO BBAC_CAN_SA_DETAIL_EXP_DTO
> >
{ {
protected BBAC_CAN_SA_SERVICE(INormalEfCoreRepository<BBAC_CAN_SA, Guid> repository, IExcelImportAppService excelImportService, INormalEfCoreRepository<BBAC_CAN_SA_DETAIL, Guid> detailRepository) : base(repository, excelImportService, detailRepository) private readonly INormalEfCoreRepository<BBAC_NOT_SA_DETAIL, Guid> _notRepository;
public BBAC_CAN_SA_SERVICE(
INormalEfCoreRepository<BBAC_CAN_SA, Guid> repository,
IExcelImportAppService excelImportService,
INormalEfCoreRepository<BBAC_CAN_SA_DETAIL, Guid> detailRepository,
INormalEfCoreRepository<BBAC_NOT_SA_DETAIL, Guid> notRepository,
INV_MNG invmng) : base(repository, excelImportService, detailRepository, invmng)
{ {
_notRepository = notRepository;
} }
/// <summary>
/// 生成发票
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost] [HttpPost]
//[Route("generateinvoice")] //[Route("generateinvoice")]
public async override Task<string> GenerateInvoice(BBAC_CAN_SA_REQ_DTO input) public async override Task<string> GenerateInvoice(BBAC_CAN_SA_REQ_DTO input)
{ {
List<BBAC_CAN_SA_DETAIL_DTO> _ls = new List<BBAC_CAN_SA_DETAIL_DTO>();
var _query= _ls.GroupBy(p => new { p.GroupNum }).Select(p =>new {GroupNum=p.Key.GroupNum, Qty=p.Sum(itm=>itm.Price)}); var main=_repository.Where(p => p.InvGroupNum == input.Filters.Where(p => p.Column == "BillNum").FirstOrDefault().Value).FirstOrDefault();
Dictionary<string, decimal> _dic = new Dictionary<string, decimal>(); var entitys = await _detailRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, input.SkipCount);//可结算
Dictionary<string, decimal> _dic1 = new Dictionary<string, decimal>();
var groupNumList= entitys.Select(p=>p.GroupNum).Distinct().ToList();
var notList =_notRepository.Where(p => groupNumList.Contains(p.InvGroupNum)).ToList();//不能结算
var dtos = ObjectMapper.Map<List<BBAC_CAN_SA_DETAIL>, List<BBAC_CAN_SA_DETAIL_DTO>>(entitys);
dtos.ForEach(dto =>
{
dto.Amt = Math.Round(dto.Price * dto.Qty, 2);
});
var _query= dtos.GroupBy(p => new { p.GroupNum }).Select(p =>new {GroupNum=p.Key.GroupNum, Amt=p.Sum(itm=>itm.Amt)});
Dictionary<string, decimal> dic = new Dictionary<string, decimal>();//原本
Dictionary<string, decimal> copyDic = new Dictionary<string, decimal>();//变换数组副本
foreach (var itm in _query.ToList()) foreach (var itm in _query.ToList())
{ {
_dic.Add(itm.GroupNum, itm.Qty); dic.Add(itm.GroupNum, itm.Amt);
_dic1.Add(itm.GroupNum, itm.Qty); copyDic.Add(itm.GroupNum, itm.Amt);
} }
Dictionary<string, List<string>> _invoice=new Dictionary<string,List<string>>(); Dictionary<string, List<string>> invoiceMap=new Dictionary<string,List<string>>();
foreach (var _itm in _dic) foreach (var itm in dic)
{ {
string invoiceBillNum = Guid.NewGuid().ToString(); string invoiceBillNum = OrderNumberGenerator.GenerateOrderNumber("INV");
List<string> invoiceGroupNumList = new List<string>(); List<string> invoiceGroupNumList = new List<string>();//每个发票对应的结算分组号
List<string> List = new List<string>(); List<string> List = new List<string>();
decimal sum = _itm.Value;//初始价格 decimal sum = itm.Value;//初始分组合计金额
List<string> luList= _ls.Where(p => p.GroupNum == _itm.Key).Select(p => p.LU).Distinct().ToList(); //初始LU种类 List<string> luList= dtos.Where(p => p.GroupNum == itm.Key).Select(p => p.LU).Distinct().ToList(); //初始LU种类
foreach (var _itm1 in _dic1)
if (copyDic.ContainsKey(itm.Key)==true)//是否存在分组
{ {
if (_itm.Key == _itm1.Key) foreach (var _itm1 in copyDic)
{ {
continue; if (itm.Key == _itm1.Key)//相同结算分组项不计算,已初始化
{
invoiceGroupNumList.Add(itm.Key);
continue;
}
var grouplist = dtos.Where(p => p.GroupNum == _itm1.Key).Select(p => p.LU).Distinct().ToList();//每项LU种类
luList.AddRange(grouplist);
luList = luList.Distinct().ToList();
if (luList.Count > 20)//累加零件不超过20种
{
continue;
}
if (sum > 10000000)
{
break;
}
sum += _itm1.Value;
invoiceGroupNumList.Add(_itm1.Key);//所有条件都满足添加发票和结算分组对应关系
} }
var grouplist=_ls.Where(p => p.GroupNum == _itm1.Key).Select(p => p.LU).Distinct().ToList();//每项LU种类
luList.AddRange(grouplist); invoiceMap.Add(invoiceBillNum, invoiceGroupNumList);//记录发票对应关系
luList = luList.Distinct().ToList(); foreach (var rem in invoiceGroupNumList)//移除
if (luList.Count > 20)//累加零件不超过20种 {
copyDic.Remove(rem);
}
}
}
if(invoiceMap.Keys.Count > 0) {
var inv=new INVOICE_GRP();
var groupList = new List<INVOICE_MAP_GROUP>();
var notDetialList=new List<INVOICE_NOT_SETTLE>();
var detailList= new List<INVOICE_WAIT_DETAIL>();
foreach (var itm in invoiceMap)
{
var key = itm.Key;//发票票号
var ls = itm.Value;//结算分组号列表
var detailDtos= dtos.Where(p => ls.Contains(p.GroupNum)).GroupBy(p=>new {p.InvGroupNum, p.LU,p.Price })
.Select(itm=>new { InvGroupNum=itm.Key.InvGroupNum,
LU=itm.Key.LU,
Price=itm.Key.Price,Amt=Math.Round(itm.Sum(k=>k.Qty)*itm.Key.Price,2) ,
Qty= itm.Sum(k => k.Qty) })
.ToList();
var invbill=new INVOICE_GRP();
foreach (var obj in detailDtos)
{ {
continue; new INVOICE_WAIT_DETAIL(
guid: GuidGenerator.Create(),
version:main.Version,
invbillNum: key,
invGroupNum: obj.InvGroupNum,
lU: obj.LU,
qty: obj.Qty,
bussiessType: EnumBusinessType.BBAC,
amt: obj.Amt,
pRICE:obj.Price,
extend1: string.Empty, extend2: string.Empty, extend3: string.Empty, extend4: string.Empty
);
} }
sum += _itm1.Value;
if (sum > 10000000)
foreach (var groupnum in ls)
{ {
continue;
} }
invoiceGroupNumList.Add(_itm1.Key);//所有条件都满足添加发票和结算分组对应关系
} }
} }
return ApplicationConsts.SuccessStr;
// return true;
return ApplicationConsts.SuccessStr;
} }
//private Dictionary<string, decimal> GenerateInvoice(Dictionary<string, decimal> p_dic)
//{
// string invoiceBillNum = OrderNumberGenerator.GenerateOrderNumber("INV");
// List<string> invoiceGroupNumList = new List<string>();//每个发票对应的结算分组号
// List<string> List = new List<string>();
// decimal sum = p_dic.Value;//初始分组合计金额
// List<string> luList = dtos.Where(p => p.GroupNum == itm.Key).Select(p => p.LU).Distinct().ToList(); //初始LU种类
// foreach (var _itm1 in copyDic)
// {
// if (itm.Key == _itm1.Key)//相同结算分组项不计算
// {
// invoiceGroupNumList.Add(itm.Key);
// continue;
// }
// var grouplist = dtos.Where(p => p.GroupNum == _itm1.Key).Select(p => p.LU).Distinct().ToList();//每项LU种类
// luList.AddRange(grouplist);
// luList = luList.Distinct().ToList();
// if (luList.Count > 20)//累加零件不超过20种
// {
// continue;
// }
// if (sum > 10000000)
// {
// break;
// }
// sum += _itm1.Value;
// invoiceGroupNumList.Add(_itm1.Key);//所有条件都满足添加发票和结算分组对应关系
// }
// foreach (var rem in invoiceGroupNumList)//移除
// {
// copyDic.Remove(rem);
// }
// return
//}
} }
} }

4
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_PD_SERVICE.cs

@ -1,4 +1,4 @@
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
using SettleAccount.Domain.BQ; using SettleAccount.Domain.BQ;
using System; using System;
@ -18,7 +18,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
/// BBAC寄售库库存扣减审批 /// BBAC寄售库库存扣减审批
/// </summary> /// </summary>
[AllowAnonymous] [AllowAnonymous]
[Route("api/settleaccount/bbac_pd_service")] [Route("api/settleaccount/[controller]/[action]")]
public class BBAC_PD_SERVICE : PD_SERVICE<BBAC_PD, BBAC_PD_DTO, public class BBAC_PD_SERVICE : PD_SERVICE<BBAC_PD, BBAC_PD_DTO,
BBAC_PD_DETAIL, BBAC_PD_DETAIL_DTO, BBAC_PD_REQ_DTO, BBAC_PD_DETAIL, BBAC_PD_DETAIL_DTO, BBAC_PD_REQ_DTO,
BBAC_PD_DETAIL_REQ_DTO, BBAC_PD_DETAIL_EXP_DTO> BBAC_PD_DETAIL_REQ_DTO, BBAC_PD_DETAIL_EXP_DTO>

2
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_BA_SERVICE.cs

@ -15,7 +15,7 @@ using Win.Sfs.Shared.RepositoryBase;
namespace Win.Sfs.SettleAccount.Entities.BQ namespace Win.Sfs.SettleAccount.Entities.BQ
{ {
[AllowAnonymous] [AllowAnonymous]
[Route("api/settleaccount/hbpo_ba_service")] [Route("api/settleaccount/[controller]/[action]")]
public class HBPO_BA_SERVICE : BA_SERVICE public class HBPO_BA_SERVICE : BA_SERVICE
{ {
public HBPO_BA_SERVICE(INormalEfCoreRepository<INVOICE_GRP, Guid> repository, INormalEfCoreRepository<INVOICE_WAIT_DETAIL, Guid> wRepository, INormalEfCoreRepository<INVOICE_NOT_SETTLE, Guid> sRepository, INormalEfCoreRepository<INVOICE_MAP_GROUP, Guid> mRepository, IExcelImportAppService excelImportService, CAN_SA_MNG<PUB_CAN_SA, PUB_CAN_SA_DETAIL> pubMng, CAN_SA_MNG<BBAC_CAN_SA, BBAC_CAN_SA_DETAIL> bbacMng, CAN_SA_MNG<HBPO_CAN_SA, HBPO_CAN_SA_DETAIL> hbpoMng, INV_MNG invMng) : base(repository, wRepository, sRepository, mRepository, excelImportService, pubMng, bbacMng, hbpoMng, invMng) public HBPO_BA_SERVICE(INormalEfCoreRepository<INVOICE_GRP, Guid> repository, INormalEfCoreRepository<INVOICE_WAIT_DETAIL, Guid> wRepository, INormalEfCoreRepository<INVOICE_NOT_SETTLE, Guid> sRepository, INormalEfCoreRepository<INVOICE_MAP_GROUP, Guid> mRepository, IExcelImportAppService excelImportService, CAN_SA_MNG<PUB_CAN_SA, PUB_CAN_SA_DETAIL> pubMng, CAN_SA_MNG<BBAC_CAN_SA, BBAC_CAN_SA_DETAIL> bbacMng, CAN_SA_MNG<HBPO_CAN_SA, HBPO_CAN_SA_DETAIL> hbpoMng, INV_MNG invMng) : base(repository, wRepository, sRepository, mRepository, excelImportService, pubMng, bbacMng, hbpoMng, invMng)

5
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_CAN_SA_SERVICE.cs

@ -1,4 +1,4 @@
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using SettleAccount.Domain.BQ; using SettleAccount.Domain.BQ;
@ -12,6 +12,7 @@ using Volo.Abp.Application.Services;
using Win.Sfs.BaseData.ImportExcelCommon; using Win.Sfs.BaseData.ImportExcelCommon;
using Win.Sfs.SettleAccount.Bases; using Win.Sfs.SettleAccount.Bases;
using Win.Sfs.SettleAccount.Entities.BQ.Dtos; using Win.Sfs.SettleAccount.Entities.BQ.Dtos;
using Win.Sfs.SettleAccount.Entities.BQ.Managers;
using Win.Sfs.Shared.RepositoryBase; using Win.Sfs.Shared.RepositoryBase;
namespace Win.Sfs.SettleAccount.Entities.BQ namespace Win.Sfs.SettleAccount.Entities.BQ
@ -33,7 +34,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
HBPO_CAN_SA_DETAIL_EXP_DTO HBPO_CAN_SA_DETAIL_EXP_DTO
> >
{ {
protected HBPO_CAN_SA_SERVICE(INormalEfCoreRepository<HBPO_CAN_SA, Guid> repository, IExcelImportAppService excelImportService, INormalEfCoreRepository<HBPO_CAN_SA_DETAIL, Guid> detailRepository) : base(repository, excelImportService, detailRepository) public HBPO_CAN_SA_SERVICE(INormalEfCoreRepository<HBPO_CAN_SA, Guid> repository, IExcelImportAppService excelImportService, INormalEfCoreRepository<HBPO_CAN_SA_DETAIL, Guid> detailRepository, INV_MNG invmng) : base(repository, excelImportService, detailRepository, invmng)
{ {
} }
} }

1
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_NOT_SA_SERVICE.cs

@ -44,6 +44,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
state: SettleBillState., state: SettleBillState.,
invGroupNum: billNum, invGroupNum: billNum,
site:entitys.FirstOrDefault().Site site:entitys.FirstOrDefault().Site
); );
List<HBPO_CAN_SA_DETAIL> ls = new List<HBPO_CAN_SA_DETAIL>(); List<HBPO_CAN_SA_DETAIL> ls = new List<HBPO_CAN_SA_DETAIL>();

4
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_PD_SERVICE.cs

@ -1,4 +1,4 @@
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
using SettleAccount.Domain.BQ; using SettleAccount.Domain.BQ;
using System; using System;
@ -16,7 +16,7 @@ using Win.Sfs.Shared.RepositoryBase;
namespace Win.Sfs.SettleAccount.Entities.BQ namespace Win.Sfs.SettleAccount.Entities.BQ
{ {
[AllowAnonymous] [AllowAnonymous]
[Route("api/settleaccount/hbpo_pd_service")] [Route("api/settleaccount/[controller]/[action]")]
public class HBPO_PD_SERVICE : PD_SERVICE<HBPO_PD, HBPO_PD_DTO, public class HBPO_PD_SERVICE : PD_SERVICE<HBPO_PD, HBPO_PD_DTO,
HBPO_PD_DETAIL, HBPO_PD_DETAIL_DTO, HBPO_PD_REQ_DTO, HBPO_PD_DETAIL, HBPO_PD_DETAIL_DTO, HBPO_PD_REQ_DTO,
HBPO_PD_DETAIL_REQ_DTO, HBPO_PD_DETAIL_EXP_DTO> HBPO_PD_DETAIL_REQ_DTO, HBPO_PD_DETAIL_EXP_DTO>

2
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/INVOICE_SERVICE.cs

@ -68,7 +68,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
await _invMng.SetForwardState(inv, InvoiceBillState.); await _invMng.SetForwardState(inv, SettleBillState.);

2
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_BA_SERVICE.cs

@ -15,7 +15,7 @@ using Win.Sfs.Shared.RepositoryBase;
namespace Win.Sfs.SettleAccount.Entities.BQ namespace Win.Sfs.SettleAccount.Entities.BQ
{ {
[AllowAnonymous] [AllowAnonymous]
[Route("api/settleaccount/pub_ba_service")] [Route("api/settleaccount/[controller]/[action]")]
public class PUB_BA_SERVICE : BA_SERVICE public class PUB_BA_SERVICE : BA_SERVICE
{ {
public PUB_BA_SERVICE(INormalEfCoreRepository<INVOICE_GRP, Guid> repository, INormalEfCoreRepository<INVOICE_WAIT_DETAIL, Guid> wRepository, INormalEfCoreRepository<INVOICE_NOT_SETTLE, Guid> sRepository, INormalEfCoreRepository<INVOICE_MAP_GROUP, Guid> mRepository, IExcelImportAppService excelImportService, CAN_SA_MNG<PUB_CAN_SA, PUB_CAN_SA_DETAIL> pubMng, CAN_SA_MNG<BBAC_CAN_SA, BBAC_CAN_SA_DETAIL> bbacMng, CAN_SA_MNG<HBPO_CAN_SA, HBPO_CAN_SA_DETAIL> hbpoMng, INV_MNG invMng) : base(repository, wRepository, sRepository, mRepository, excelImportService, pubMng, bbacMng, hbpoMng, invMng) public PUB_BA_SERVICE(INormalEfCoreRepository<INVOICE_GRP, Guid> repository, INormalEfCoreRepository<INVOICE_WAIT_DETAIL, Guid> wRepository, INormalEfCoreRepository<INVOICE_NOT_SETTLE, Guid> sRepository, INormalEfCoreRepository<INVOICE_MAP_GROUP, Guid> mRepository, IExcelImportAppService excelImportService, CAN_SA_MNG<PUB_CAN_SA, PUB_CAN_SA_DETAIL> pubMng, CAN_SA_MNG<BBAC_CAN_SA, BBAC_CAN_SA_DETAIL> bbacMng, CAN_SA_MNG<HBPO_CAN_SA, HBPO_CAN_SA_DETAIL> hbpoMng, INV_MNG invMng) : base(repository, wRepository, sRepository, mRepository, excelImportService, pubMng, bbacMng, hbpoMng, invMng)

5
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_CAN_SA_SERVICE.cs

@ -1,4 +1,4 @@
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using SettleAccount.Domain.BQ; using SettleAccount.Domain.BQ;
@ -12,6 +12,7 @@ using Volo.Abp.Application.Services;
using Win.Sfs.BaseData.ImportExcelCommon; using Win.Sfs.BaseData.ImportExcelCommon;
using Win.Sfs.SettleAccount.Bases; using Win.Sfs.SettleAccount.Bases;
using Win.Sfs.SettleAccount.Entities.BQ.Dtos; using Win.Sfs.SettleAccount.Entities.BQ.Dtos;
using Win.Sfs.SettleAccount.Entities.BQ.Managers;
using Win.Sfs.Shared.RepositoryBase; using Win.Sfs.Shared.RepositoryBase;
namespace Win.Sfs.SettleAccount.Entities.BQ namespace Win.Sfs.SettleAccount.Entities.BQ
@ -33,7 +34,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
PUB_CAN_SA_DETAIL_EXP_DTO PUB_CAN_SA_DETAIL_EXP_DTO
> >
{ {
protected PUB_CAN_SA_SERVICE(INormalEfCoreRepository<PUB_CAN_SA, Guid> repository, IExcelImportAppService excelImportService, INormalEfCoreRepository<PUB_CAN_SA_DETAIL, Guid> detailRepository) : base(repository, excelImportService, detailRepository) public PUB_CAN_SA_SERVICE(INormalEfCoreRepository<PUB_CAN_SA, Guid> repository, IExcelImportAppService excelImportService, INormalEfCoreRepository<PUB_CAN_SA_DETAIL, Guid> detailRepository, INV_MNG invmng) : base(repository, excelImportService, detailRepository, invmng)
{ {
} }
} }

4
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_PD_SERVICE.cs

@ -1,4 +1,4 @@
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
using SettleAccount.Domain.BQ; using SettleAccount.Domain.BQ;
using System; using System;
@ -16,7 +16,7 @@ using Win.Sfs.Shared.RepositoryBase;
namespace Win.Sfs.SettleAccount.Entities.BQ namespace Win.Sfs.SettleAccount.Entities.BQ
{ {
[AllowAnonymous] [AllowAnonymous]
[Route("api/settleaccount/pub_pd_service")] [Route("api/settleaccount/[controller]/[action]")]
public class PUB_PD_SERVICE : PD_SERVICE<PUB_PD, PUB_PD_DTO, public class PUB_PD_SERVICE : PD_SERVICE<PUB_PD, PUB_PD_DTO,
PUB_PD_DETAIL, PUB_PD_DETAIL_DTO, PUB_PD_REQ_DTO, PUB_PD_DETAIL, PUB_PD_DETAIL_DTO, PUB_PD_REQ_DTO,
PUB_PD_DETAIL_REQ_DTO, PUB_PD_DETAIL_EXP_DTO> PUB_PD_DETAIL_REQ_DTO, PUB_PD_DETAIL_EXP_DTO>

12
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/INVOICE_GRP.cs

@ -1,4 +1,4 @@
using System; using System;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using Volo.Abp.Domain.Entities.Auditing; using Volo.Abp.Domain.Entities.Auditing;
using Win.Sfs.SettleAccount; using Win.Sfs.SettleAccount;
@ -33,9 +33,14 @@ public class INVOICE_GRP : FullAuditedAggregateRoot<Guid>
[Display(Name = "状态")] [Display(Name = "状态")]
public InvoiceBillState State { get; set; } public SettleBillState State { get; set; }
public INVOICE_GRP(Guid guid, string realnvBillNum, string invbillNum, decimal amt, decimal taxAmt, string invGroupNum, string fileName, EnumBusinessType businessType, InvoiceBillState state) [Display(Name = "发票状态")]
public InvoiceBillState InvoiceState { get; set; }
public INVOICE_GRP(Guid guid, string realnvBillNum, string invbillNum, decimal amt, decimal taxAmt, string invGroupNum, string fileName, EnumBusinessType businessType, SettleBillState state,InvoiceBillState invoiceBillState)
{ {
Id= guid; Id= guid;
RealnvBillNum = realnvBillNum; RealnvBillNum = realnvBillNum;
@ -46,6 +51,7 @@ public class INVOICE_GRP : FullAuditedAggregateRoot<Guid>
FileName = fileName; FileName = fileName;
BusinessType = businessType; BusinessType = businessType;
State = state; State = state;
InvoiceState = invoiceBillState;
} }

7
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/INVOICE_WAIT_DETAIL.cs

@ -1,6 +1,7 @@
using System; using System;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using Volo.Abp.Domain.Entities.Auditing; using Volo.Abp.Domain.Entities.Auditing;
using Win.Sfs.SettleAccount;
namespace SettleAccount.Domain.BQ; namespace SettleAccount.Domain.BQ;
@ -32,7 +33,7 @@ public class INVOICE_WAIT_DETAIL :FullAuditedAggregateRoot<Guid>
/// 1、BBAC-JIS 2、HBPO-JIS 3、JIT 4、备件 5、印度件 /// 1、BBAC-JIS 2、HBPO-JIS 3、JIT 4、备件 5、印度件
/// </summary> /// </summary>
[Display(Name = "业务分类")] [Display(Name = "业务分类")]
public string BussiessType { get; set; } = null!; public EnumBusinessType BussiessType { get; set; }
[Display(Name = "扩展字段1")] [Display(Name = "扩展字段1")]
public string Extend1 { get; set; } = null!; public string Extend1 { get; set; } = null!;
@ -46,7 +47,7 @@ public class INVOICE_WAIT_DETAIL :FullAuditedAggregateRoot<Guid>
[Display(Name = "扩展字段4")] [Display(Name = "扩展字段4")]
public string Extend4 { get; set; } = null!; public string Extend4 { get; set; } = null!;
public INVOICE_WAIT_DETAIL(Guid guid, int version, string invbillNum, string invGroupNum, string lU, decimal pRICE, decimal qty, decimal amt, string bussiessType, string extend1, string extend2, string extend3, string extend4) public INVOICE_WAIT_DETAIL(Guid guid, int version, string invbillNum, string invGroupNum, string lU, decimal pRICE, decimal qty, decimal amt, EnumBusinessType bussiessType, string extend1, string extend2, string extend3, string extend4)
{ {
Id = guid; Id = guid;
Version = version; Version = version;

92
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/CAN_SA_MNG.cs

@ -45,15 +45,23 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
} }
/// <summary>
/// 向前流程
/// </summary>
/// <param name="p_billNum"></param>
/// <param name="state"></param>
/// <returns></returns>
/// <exception cref="BusinessException"></exception>
public virtual async Task<bool> SetForwardState(string p_billNum, SettleBillState state) public virtual async Task<bool> SetForwardState(string p_billNum, SettleBillState state)
{ {
var ls = _repository.Where(p => p.InvGroupNum == p_billNum).ToList(); var ls = _repository.Where(p => p.InvGroupNum == p_billNum).ToList();
if (ls != null && ls.Count > 0)
{
throw new BusinessException("8989", string.Format("不存在编号为{0}",p_billNum));
}
foreach (TEntity p_entiy in ls) foreach (TEntity p_entiy in ls)
{ {
switch (p_entiy.State) switch (p_entiy.State)
{ {
case SettleBillState.: case SettleBillState.:
@ -108,11 +116,85 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
break; break;
} }
await _repository.UpdateAsync(p_entiy); await _repository.UpdateAsync(p_entiy);
return true;
} }
return false;
}
/// <summary>
/// 向后流程
/// </summary>
/// <param name="p_billNum"></param>
/// <param name="state"></param>
/// <returns></returns>
/// <exception cref="BusinessException"></exception>
public virtual async Task<bool> SetBackwardState(string p_billNum, SettleBillState state)
{
var ls = _repository.Where(p => p.InvGroupNum == p_billNum).ToList();
if (ls != null && ls.Count > 0)
{
throw new BusinessException("8989", string.Format("不存在发票分组号为{0}的可结算单", p_billNum));
}
foreach (TEntity p_entiy in ls)
{
return true; switch (p_entiy.State)
{
case SettleBillState.:
if (state == SettleBillState.)
{
p_entiy.State = state;
}
else
{
throw new BusinessException("8989", "当前状态不是【财务已审核】,无法设置成【商务已审核】状态");
}
break;
case SettleBillState.:
if (state == SettleBillState.)
{
p_entiy.State = state;
}
else
{
throw new BusinessException("8989", "当前状态不是【商务已审核】状态,无法设置成【已开票】");
}
break;
case SettleBillState.:
if (state == SettleBillState.)
{
p_entiy.State = state;
}
else
{
throw new BusinessException("8989", "当前状态不是【已开票】状态,无法设置成【未结状态】");
}
break;
case SettleBillState.:
if (state == SettleBillState.)
{
p_entiy.State = state;
}
else
{
throw new BusinessException("8989", "当前状态不是[财务已审核],无法设置成【财务已审核客户收票】状态");
}
break;
case SettleBillState.:
if (state == SettleBillState.)
{
p_entiy.State = state;
}
else
{
throw new BusinessException("8989", "当前状态不是[客户已收票],无法设置成【财务已审核】状态");
}
break;
}
await _repository.UpdateAsync(p_entiy);
return true;
}
return false;
} }

255
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/INV_MNG.cs

@ -11,6 +11,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp; using Volo.Abp;
using Volo.Abp.Auditing;
using Volo.Abp.Domain.Repositories; using Volo.Abp.Domain.Repositories;
using Volo.Abp.Domain.Services; using Volo.Abp.Domain.Services;
using Win.Sfs.Shared.RepositoryBase; using Win.Sfs.Shared.RepositoryBase;
@ -55,7 +56,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
_hbpoMng = hbpoMng; _hbpoMng = hbpoMng;
} }
public virtual async Task<bool> SetForwardState(string p_groupBillnum , InvoiceBillState p_State) public virtual async Task<bool> SetForwardState(string p_groupBillnum , SettleBillState p_State)
{ {
var _first=_repository.Where(p => p.InvbillNum == p_groupBillnum).FirstOrDefault(); var _first=_repository.Where(p => p.InvbillNum == p_groupBillnum).FirstOrDefault();
if (_first != null) if (_first != null)
@ -65,15 +66,178 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
return false; return false;
} }
private async Task<bool> SetSettleState(INVOICE_GRP p_entiy, SettleBillState p_State,bool IsForward=true)
{
if (p_entiy.BusinessType == EnumBusinessType.BeiJian ||
p_entiy.BusinessType == EnumBusinessType.YingDuJian ||
p_entiy.BusinessType == EnumBusinessType.MaiDanJian ||
p_entiy.BusinessType == EnumBusinessType.ZhiGongJian
)
{
bool isSucc = false;
if (IsForward == true)
{
isSucc = await _pubMng.SetForwardState(p_entiy.InvGroupNum, p_State);
}
else
{
isSucc = await _pubMng.SetBackwardState(p_entiy.InvGroupNum, p_State);
}
return isSucc;
}
else if (p_entiy.BusinessType == EnumBusinessType.BBAC)
{
bool isSucc = false;
if (IsForward == true)
{
isSucc = await _bbacMng.SetForwardState(p_entiy.InvGroupNum, p_State);
}
else
{
isSucc = await _bbacMng.SetBackwardState(p_entiy.InvGroupNum, p_State);
}
//switch ((int)p_State)
//{
// case (int)SettleBillState.财务已审核:
// if (IsForward == true)
// {
// isSucc = await _bbacMng.SetForwardState(p_entiy.InvGroupNum, SettleBillState.财务已审核);
// }
// else
// {
// isSucc = await _bbacMng.SetBackwardState(p_entiy.InvGroupNum, SettleBillState.财务已审核);
// }
// break;
// case (int)SettleBillState.商务已审核:
// if (IsForward == true)
// {
// isSucc = await _bbacMng.SetForwardState(p_entiy.InvGroupNum, SettleBillState.商务已审核);
// }
// else
// {
// isSucc = await _bbacMng.SetBackwardState(p_entiy.InvGroupNum, SettleBillState.商务已审核);
// }
// break;
// case (int)SettleBillState.已开票:
// if (IsForward == true)
// {
// isSucc = await _bbacMng.SetForwardState(p_entiy.InvGroupNum, SettleBillState.已开票);
// }
// else
// {
// isSucc = await _bbacMng.SetForwardState(p_entiy.InvGroupNum, SettleBillState.已开票);
// }
// break;
// case (int)SettleBillState.客户已收票:
// if (IsForward == true)
// {
// isSucc = await _bbacMng.SetForwardState(p_entiy.InvGroupNum, SettleBillState.客户已收票);
// }
// else
// {
// isSucc = await _bbacMng.SetBackwardState(p_entiy.InvGroupNum, SettleBillState.客户已收票);
// }
// break;
// case (int)SettleBillState.已扣减:
// if (IsForward == true)
// {
// isSucc = await _bbacMng.SetForwardState(p_entiy.InvGroupNum, SettleBillState.已扣减);
// }
// else
// {
// isSucc = await _bbacMng.SetBackwardState(p_entiy.InvGroupNum, SettleBillState.已扣减);
// }
// break;
//}
return isSucc;
}
else if (p_entiy.BusinessType == EnumBusinessType.HBPO)
{
bool isSucc = false;
public virtual async Task<bool> SetForwardState(INVOICE_GRP p_entiy, InvoiceBillState p_State) if (IsForward == true)
{
isSucc = await _hbpoMng.SetForwardState(p_entiy.InvGroupNum, p_State);
}
else
{
isSucc = await _hbpoMng.SetBackwardState(p_entiy.InvGroupNum, p_State);
}
//switch ((int)p_State)
//{
// case (int)SettleBillState.财务已审核:
// if (IsForward == true)
// {
// isSucc = await _hbpoMng.SetForwardState(p_entiy.InvGroupNum, SettleBillState.财务已审核);
// }
// else
// {
// isSucc = await _hbpoMng.SetBackwardState(p_entiy.InvGroupNum, SettleBillState.财务已审核);
// }
// break;
// case (int)SettleBillState.商务已审核:
// if (IsForward == true)
// {
// isSucc = await _hbpoMng.SetForwardState(p_entiy.InvGroupNum, SettleBillState.商务已审核);
// }
// else
// {
// isSucc = await _hbpoMng.SetBackwardState(p_entiy.InvGroupNum, SettleBillState.商务已审核);
// }
// break;
// case (int)SettleBillState.已开票:
// if (IsForward == true)
// {
// isSucc = await _hbpoMng.SetForwardState(p_entiy.InvGroupNum, SettleBillState.已开票);
// }
// else
// {
// isSucc = await _hbpoMng.SetForwardState(p_entiy.InvGroupNum, SettleBillState.已开票);
// }
// break;
// case (int)SettleBillState.客户已收票:
// if (IsForward == true)
// {
// isSucc = await _hbpoMng.SetForwardState(p_entiy.InvGroupNum, SettleBillState.客户已收票);
// }
// else
// {
// isSucc = await _hbpoMng.SetBackwardState(p_entiy.InvGroupNum, SettleBillState.客户已收票);
// }
// break;
// case (int)SettleBillState.已扣减:
// if (IsForward == true)
// {
// isSucc = await _hbpoMng.SetForwardState(p_entiy.InvGroupNum, SettleBillState.已扣减);
// }
// else
// {
// isSucc = await _hbpoMng.SetBackwardState(p_entiy.InvGroupNum, SettleBillState.已扣减);
// }
// break;
//}
return isSucc;
}
return false;
}
/// <summary>
/// 向前流程
/// </summary>
/// <param name="p_entiy"></param>
/// <param name="p_State"></param>
/// <returns></returns>
/// <exception cref="BusinessException"></exception>
public virtual async Task<bool> SetForwardState(INVOICE_GRP p_entiy, SettleBillState p_State)
{ {
var state = p_State; var state = p_State;
switch (p_entiy.State) switch (p_entiy.State)
{ {
case InvoiceBillState.: case SettleBillState.:
if (state == InvoiceBillState.) if (state == SettleBillState.)
{ {
p_entiy.State = state; p_entiy.State = state;
} }
@ -82,8 +246,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
throw new BusinessException("8989", "当前状态不是【商务已审核】,无法设置成【财务已审核】状态"); throw new BusinessException("8989", "当前状态不是【商务已审核】,无法设置成【财务已审核】状态");
} }
break; break;
case InvoiceBillState.: case SettleBillState.:
if (state == InvoiceBillState.) if (state == SettleBillState.)
{ {
p_entiy.State = state; p_entiy.State = state;
} }
@ -92,8 +256,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
throw new BusinessException("8989", "当前状态不是【已开票】状态,无法设置成【商务已审核】"); throw new BusinessException("8989", "当前状态不是【已开票】状态,无法设置成【商务已审核】");
} }
break; break;
case InvoiceBillState.: case SettleBillState.:
if (state == InvoiceBillState.) if (state == SettleBillState.)
{ {
p_entiy.State = state; p_entiy.State = state;
} }
@ -103,12 +267,79 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
} }
break; break;
} }
var flag= await SetSettleState(p_entiy, p_State,true);
if (flag == true)
{
await _repository.UpdateAsync(p_entiy);
return false;
}
return false;
}
/// <summary>
/// 向后流程
/// </summary>
/// <param name="p_entiy"></param>
/// <param name="p_State"></param>
/// <returns></returns>
/// <exception cref="BusinessException"></exception>
public virtual async Task<bool> SetBackwardState(INVOICE_GRP p_entiy, SettleBillState p_State)
{
var state = p_State;
switch (p_entiy.State)
{
case SettleBillState.:
if (state == SettleBillState.)
{
p_entiy.State = state;
}
else
{
throw new BusinessException("8989", "当前状态不是【财务已审核】,无法设置成【商务已审核】状态");
}
break;
case SettleBillState.:
if (state == SettleBillState.)
{
p_entiy.State = state;
}
else
{
throw new BusinessException("8989", "当前状态不是【商务已审核】状态,无法设置成【已开票】");
}
break;
case SettleBillState.:
if (state == SettleBillState.)
{
p_entiy.State = state;
}
else
{
throw new BusinessException("8989", "当前状态不是【已扣减】状态,无法设置成【客户已收票】状态");
}
break;
}
var flag = await SetSettleState(p_entiy, p_State,false);
if (flag == false)
{
return false;
}
await _repository.UpdateAsync(p_entiy); await _repository.UpdateAsync(p_entiy);
return true; return true;
} }
/// <summary> /// <summary>
/// 获得发票主表 /// 获得发票主表
/// </summary> /// </summary>
@ -304,8 +535,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
{ {
foreach (var p_entity in _ls) foreach (var p_entity in _ls)
{ {
if (p_entity.State == InvoiceBillState. if (p_entity.State == SettleBillState.
|| p_entity.State == InvoiceBillState. || p_entity.State == InvoiceBillState.) || p_entity.State == SettleBillState. || p_entity.State == SettleBillState.)
{ {
var entList = _repository.Where(p => p.InvGroupNum == p_entity.InvGroupNum).ToList(); var entList = _repository.Where(p => p.InvGroupNum == p_entity.InvGroupNum).ToList();
var groupList = _groupRepository.Where(p => p.InvGroupNum == p_entity.InvGroupNum).ToList(); var groupList = _groupRepository.Where(p => p.InvGroupNum == p_entity.InvGroupNum).ToList();
@ -325,7 +556,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
} }
if (p_entity.State == InvoiceBillState.) if (p_entity.State == SettleBillState.)
{ {
} }
@ -349,7 +580,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
/// </summary> /// </summary>
/// <param name="billNum"></param> /// <param name="billNum"></param>
/// <returns></returns> /// <returns></returns>
public virtual async Task<bool> Back(string billNum) public virtual async Task<bool> BackAsync(string billNum)
{ {
var _ls = await _repository.Where(p => p.InvGroupNum == billNum).ToListAsync(); var _ls = await _repository.Where(p => p.InvGroupNum == billNum).ToListAsync();

44
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/PD_MNG.cs

@ -3,8 +3,50 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using SettleAccount.Bases;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.Domain.Services;
using Win.Sfs.Shared.RepositoryBase;
namespace Win.Sfs.SettleAccount.Entities.BQ.Managers; namespace Win.Sfs.SettleAccount.Entities.BQ.Managers;
public class PD_MNG public class PD_MNG<TEntity,TEntityDetail>:DomainService
where TEntity : PD_BASE_MAIN
where TEntityDetail : PD_BASE
{ {
private readonly INormalEfCoreRepository<TEntity, Guid> _repository;
private readonly INormalEfCoreRepository<TEntityDetail, Guid> _detailRepository;
protected PD_MNG(
INormalEfCoreRepository<TEntity, Guid> repository,
INormalEfCoreRepository<TEntityDetail, Guid> detailRepository
)
{
_repository = repository;
_detailRepository = detailRepository;
}
public virtual async Task<TEntity> GetMainAsync(string billNum)
{
return await _repository.Where(p => p.InvGroupNum == billNum).FirstOrDefaultAsync();
}
public virtual async Task<List<TEntityDetail>> GetDetailAsync(string billNum)
{
return await _detailRepository.Where(p => p.InvGroupNum == billNum).ToListAsync();
}
} }

Loading…
Cancel
Save