Browse Source

开票

master
wxd 24 hours ago
parent
commit
3d63e164c2
  1. 86
      src/Shentun.Peis.Application.Contracts/InvoiceApplys/CreateInvoiceApplyInputDto.cs
  2. 32
      src/Shentun.Peis.Application.Contracts/InvoiceApplys/GetInvoiceApplyListInputDto.cs
  3. 97
      src/Shentun.Peis.Application.Contracts/InvoiceApplys/InvoiceApplyDto.cs
  4. 11
      src/Shentun.Peis.Application.Contracts/InvoiceApplys/InvoiceApplyIdInputDto.cs
  5. 86
      src/Shentun.Peis.Application.Contracts/InvoiceApplys/UpdateInvoiceApplyInputDto.cs
  6. 37
      src/Shentun.Peis.Application.Contracts/InvoiceRecords/CreateInvoiceRecordInputDto.cs
  7. 44
      src/Shentun.Peis.Application.Contracts/InvoiceRecords/GetInvoiceRecordListInputDto.cs
  8. 35
      src/Shentun.Peis.Application.Contracts/InvoiceRecords/InvoiceRecordDto.cs
  9. 11
      src/Shentun.Peis.Application.Contracts/InvoiceRecords/InvoiceRecordIdInputDto.cs
  10. 37
      src/Shentun.Peis.Application.Contracts/InvoiceRecords/UpdateInvoiceRecordInputDto.cs
  11. 61
      src/Shentun.Peis.Application.Contracts/PaymentRecords/CreatePaymentRecordInputDto.cs
  12. 60
      src/Shentun.Peis.Application.Contracts/PaymentRecords/GetPaymentRecordListInputDto.cs
  13. 61
      src/Shentun.Peis.Application.Contracts/PaymentRecords/PaymentRecordDto.cs
  14. 11
      src/Shentun.Peis.Application.Contracts/PaymentRecords/PaymentRecordIdInputDto.cs
  15. 60
      src/Shentun.Peis.Application.Contracts/PaymentRecords/UpdatePaymentRecordInputDto.cs
  16. 205
      src/Shentun.Peis.Application/InvoiceApplys/InvoiceApplyAppService.cs
  17. 146
      src/Shentun.Peis.Application/InvoiceRecords/InvoiceRecordAppService.cs
  18. 164
      src/Shentun.Peis.Application/PaymentRecords/PaymentRecordAppService.cs

86
src/Shentun.Peis.Application.Contracts/InvoiceApplys/CreateInvoiceApplyInputDto.cs

@ -0,0 +1,86 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text;
namespace Shentun.Peis.InvoiceApplys
{
public class CreateInvoiceApplyInputDto
{
/// <summary>
/// 单位编号
/// </summary>
public Guid CustomerOrgId { get; set; }
/// <summary>
///客户单位登记ID 体检次数
/// </summary>
public Guid CustomerOrgRegisterId { get; set; }
/// <summary>
/// 业务员
/// </summary>
public string SalesPerson { get; set; }
/// <summary>
/// 申请时间
/// </summary>
public string ApplyTime { get; set; }
/// <summary>
/// 申请金额
/// </summary>
public decimal ApplyAmount { get; set; }
/// <summary>
/// 开票名称
/// </summary>
public string InvoiceName { get; set; }
/// <summary>
/// 国家组织机构代码 税号
/// </summary>
public string CountryOrgCode { get; set; }
/// <summary>
/// 业务银行
/// </summary>
public string Bank { get; set; }
/// <summary>
/// 银行帐号
/// </summary>
public string Accounts { get; set; }
/// <summary>
/// 联系人
/// </summary>
public string Contact { get; set; }
/// <summary>
/// 联系电话
/// </summary>
public string ContactPhone { get; set; }
/// <summary>
/// 是否完成开票
/// </summary>
public char IsCompleteInvoicing { get; set; } = 'N';
/// <summary>
/// 是否完成收款
/// </summary>
public char IsCompletePayment { get; set; } = 'N';
/// <summary>
/// 备注
/// </summary>
public string Remark { get; set; }
}
}

32
src/Shentun.Peis.Application.Contracts/InvoiceApplys/GetInvoiceApplyListInputDto.cs

@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Shentun.Peis.InvoiceApplys
{
public class GetInvoiceApplyListInputDto
{
public string SalesPerson { get; set; }
/// <summary>
/// 发票申请开始时间
/// </summary>
public string StartDate { get; set; }
/// <summary>
/// 发票申请结束时间
/// </summary>
public string EndDate { get; set; }
/// <summary>
/// 是否完成开票
/// </summary>
public char? IsCompleteInvoicing { get; set; }
/// <summary>
/// 是否完成收款
/// </summary>
public char? IsCompletePayment { get; set; }
}
}

97
src/Shentun.Peis.Application.Contracts/InvoiceApplys/InvoiceApplyDto.cs

@ -0,0 +1,97 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Shentun.Peis.InvoiceApplys
{
public class InvoiceApplyDto : AuditedEntityDtoName
{
/// <summary>
/// 单位编号
/// </summary>
public Guid CustomerOrgId { get; set; }
/// <summary>
/// 单位名称
/// </summary>
public string CustomerOrgName { get; set; }
/// <summary>
/// 部门名称
/// </summary>
public string DepartmentName { get; set; }
/// <summary>
///客户单位登记ID 体检次数
/// </summary>
public Guid CustomerOrgRegisterId { get; set; }
/// <summary>
///客户单位登记ID 体检次数
/// </summary>
public short MedicalTimes { get; set; }
/// <summary>
/// 业务员
/// </summary>
public string SalesPerson { get; set; }
/// <summary>
/// 申请时间
/// </summary>
public string ApplyTime { get; set; }
/// <summary>
/// 申请金额
/// </summary>
public decimal ApplyAmount { get; set; }
/// <summary>
/// 开票名称
/// </summary>
public string InvoiceName { get; set; }
/// <summary>
/// 国家组织机构代码 税号
/// </summary>
public string CountryOrgCode { get; set; }
/// <summary>
/// 业务银行
/// </summary>
public string Bank { get; set; }
/// <summary>
/// 银行帐号
/// </summary>
public string Accounts { get; set; }
/// <summary>
/// 联系人
/// </summary>
public string Contact { get; set; }
/// <summary>
/// 联系电话
/// </summary>
public string ContactPhone { get; set; }
/// <summary>
/// 是否完成开票
/// </summary>
public char IsCompleteInvoicing { get; set; } = 'N';
/// <summary>
/// 是否完成收款
/// </summary>
public char IsCompletePayment { get; set; } = 'N';
/// <summary>
/// 备注
/// </summary>
public string Remark { get; set; }
}
}

11
src/Shentun.Peis.Application.Contracts/InvoiceApplys/InvoiceApplyIdInputDto.cs

@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Shentun.Peis.InvoiceApplys
{
public class InvoiceApplyIdInputDto
{
public Guid InvoiceApplyId { get; set; }
}
}

86
src/Shentun.Peis.Application.Contracts/InvoiceApplys/UpdateInvoiceApplyInputDto.cs

@ -0,0 +1,86 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Shentun.Peis.InvoiceApplys
{
public class UpdateInvoiceApplyInputDto
{
public Guid Id { get; set; }
/// <summary>
/// 单位编号
/// </summary>
public Guid CustomerOrgId { get; set; }
/// <summary>
///客户单位登记ID 体检次数
/// </summary>
public Guid CustomerOrgRegisterId { get; set; }
/// <summary>
/// 业务员
/// </summary>
public string SalesPerson { get; set; }
/// <summary>
/// 申请时间
/// </summary>
public string ApplyTime { get; set; }
/// <summary>
/// 申请金额
/// </summary>
public decimal ApplyAmount { get; set; }
/// <summary>
/// 开票名称
/// </summary>
public string InvoiceName { get; set; }
/// <summary>
/// 国家组织机构代码 税号
/// </summary>
public string CountryOrgCode { get; set; }
/// <summary>
/// 业务银行
/// </summary>
public string Bank { get; set; }
/// <summary>
/// 银行帐号
/// </summary>
public string Accounts { get; set; }
/// <summary>
/// 联系人
/// </summary>
public string Contact { get; set; }
/// <summary>
/// 联系电话
/// </summary>
public string ContactPhone { get; set; }
/// <summary>
/// 是否完成开票
/// </summary>
public char IsCompleteInvoicing { get; set; } = 'N';
/// <summary>
/// 是否完成收款
/// </summary>
public char IsCompletePayment { get; set; } = 'N';
/// <summary>
/// 备注
/// </summary>
public string Remark { get; set; }
}
}

37
src/Shentun.Peis.Application.Contracts/InvoiceRecords/CreateInvoiceRecordInputDto.cs

@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text;
namespace Shentun.Peis.InvoiceRecords
{
public class CreateInvoiceRecordInputDto
{
/// <summary>
///发票申请表id
/// </summary>
public Guid InvoiceApplyId { get; set; }
/// <summary>
/// 开票人
/// </summary>
public string InvoicePerson { get; set; }
/// <summary>
/// 开票时间
/// </summary>
public string InvoiceTime { get; set; }
/// <summary>
/// 开票金额
/// </summary>
public decimal InvoiceAmount { get; set; }
/// <summary>
/// 备注
/// </summary>
public string Remark { get; set; }
}
}

44
src/Shentun.Peis.Application.Contracts/InvoiceRecords/GetInvoiceRecordListInputDto.cs

@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text;
namespace Shentun.Peis.InvoiceRecords
{
public class GetInvoiceRecordListInputDto
{
/// <summary>
///发票申请表id
/// </summary>
public Guid? InvoiceApplyId { get; set; }
/// <summary>
/// 开票人
/// </summary>
public string InvoicePerson { get; set; }
/// <summary>
/// 开票时间开始时间
/// </summary>
public string StartDate { get; set; }
/// <summary>
/// 开票时间结束时间
/// </summary>
public string EndDate { get; set; }
/// <summary>
/// 开票金额开始金额
/// </summary>
public decimal? StartAmount { get; set; }
/// <summary>
/// 开票金额结束金额
/// </summary>
public decimal? EndAmount { get; set; }
}
}

35
src/Shentun.Peis.Application.Contracts/InvoiceRecords/InvoiceRecordDto.cs

@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Shentun.Peis.InvoiceRecords
{
public class InvoiceRecordDto : AuditedEntityDtoName
{
/// <summary>
///发票申请表id
/// </summary>
public Guid InvoiceApplyId { get; set; }
/// <summary>
/// 开票人
/// </summary>
public string InvoicePerson { get; set; }
/// <summary>
/// 开票时间
/// </summary>
public string InvoiceTime { get; set; }
/// <summary>
/// 开票金额
/// </summary>
public decimal InvoiceAmount { get; set; }
/// <summary>
/// 备注
/// </summary>
public string Remark { get; set; }
}
}

11
src/Shentun.Peis.Application.Contracts/InvoiceRecords/InvoiceRecordIdInputDto.cs

@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Shentun.Peis.InvoiceRecords
{
public class InvoiceRecordIdInputDto
{
public Guid InvoiceRecordId { get; set; }
}
}

37
src/Shentun.Peis.Application.Contracts/InvoiceRecords/UpdateInvoiceRecordInputDto.cs

@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Shentun.Peis.InvoiceRecords
{
public class UpdateInvoiceRecordInputDto
{
public Guid Id { get; set; }
/// <summary>
///发票申请表id
/// </summary>
public Guid InvoiceApplyId { get; set; }
/// <summary>
/// 开票人
/// </summary>
public string InvoicePerson { get; set; }
/// <summary>
/// 开票时间
/// </summary>
public string InvoiceTime { get; set; }
/// <summary>
/// 开票金额
/// </summary>
public decimal InvoiceAmount { get; set; }
/// <summary>
/// 备注
/// </summary>
public string Remark { get; set; }
}
}

61
src/Shentun.Peis.Application.Contracts/PaymentRecords/CreatePaymentRecordInputDto.cs

@ -0,0 +1,61 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text;
namespace Shentun.Peis.PaymentRecords
{
public class CreatePaymentRecordInputDto
{
/// <summary>
///发票申请表id
/// </summary>
public Guid InvoiceApplyId { get; set; }
/// <summary>
/// 付款账户
/// </summary>
public string PaymentAccount { get; set; }
/// <summary>
/// 付款银行
/// </summary>
public string PaymentBank { get; set; }
/// <summary>
/// 付款金额
/// </summary>
public decimal PaymentAmount { get; set; }
/// <summary>
/// 付款时间
/// </summary>
public string PaymentTime { get; set; }
/// <summary>
/// 收款账户
/// </summary>
public string CollectionAccount { get; set; }
/// <summary>
/// 收款银行
/// </summary>
public string CollectionBank { get; set; }
/// <summary>
/// 交易流水号
/// </summary>
public string TransactionId { get; set; }
/// <summary>
/// 备注
/// </summary>
public string Remark { get; set; }
}
}

60
src/Shentun.Peis.Application.Contracts/PaymentRecords/GetPaymentRecordListInputDto.cs

@ -0,0 +1,60 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text;
namespace Shentun.Peis.PaymentRecords
{
public class GetPaymentRecordListInputDto
{
/// <summary>
///发票申请表id
/// </summary>
public Guid? InvoiceApplyId { get; set; }
/// <summary>
/// 付款账户
/// </summary>
public string PaymentAccount { get; set; }
/// <summary>
/// 付款时间开始时间
/// </summary>
public string StartDate { get; set; }
/// <summary>
/// 付款时间结束时间
/// </summary>
public string EndDate { get; set; }
/// <summary>
/// 付款金额开始金额
/// </summary>
public decimal? StartAmount { get; set; }
/// <summary>
/// 付款金额结束金额
/// </summary>
public decimal? EndAmount { get; set; }
/// <summary>
/// 收款账户
/// </summary>
public string CollectionAccount { get; set; }
/// <summary>
/// 交易流水号
/// </summary>
public string TransactionId { get; set; }
}
}

61
src/Shentun.Peis.Application.Contracts/PaymentRecords/PaymentRecordDto.cs

@ -0,0 +1,61 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text;
namespace Shentun.Peis.PaymentRecords
{
public class PaymentRecordDto : AuditedEntityDtoName
{
/// <summary>
///发票申请表id
/// </summary>
public Guid InvoiceApplyId { get; set; }
/// <summary>
/// 付款账户
/// </summary>
public string PaymentAccount { get; set; }
/// <summary>
/// 付款银行
/// </summary>
public string PaymentBank { get; set; }
/// <summary>
/// 付款金额
/// </summary>
public decimal PaymentAmount { get; set; }
/// <summary>
/// 付款时间
/// </summary>
public string PaymentTime { get; set; }
/// <summary>
/// 收款账户
/// </summary>
public string CollectionAccount { get; set; }
/// <summary>
/// 收款银行
/// </summary>
public string CollectionBank { get; set; }
/// <summary>
/// 交易流水号
/// </summary>
public string TransactionId { get; set; }
/// <summary>
/// 备注
/// </summary>
public string Remark { get; set; }
}
}

11
src/Shentun.Peis.Application.Contracts/PaymentRecords/PaymentRecordIdInputDto.cs

@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Shentun.Peis.PaymentRecords
{
public class PaymentRecordIdInputDto
{
public Guid PaymentRecordId { get; set; }
}
}

60
src/Shentun.Peis.Application.Contracts/PaymentRecords/UpdatePaymentRecordInputDto.cs

@ -0,0 +1,60 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Shentun.Peis.PaymentRecords
{
public class UpdatePaymentRecordInputDto
{
public Guid Id { get; set; }
/// <summary>
///发票申请表id
/// </summary>
public Guid InvoiceApplyId { get; set; }
/// <summary>
/// 付款账户
/// </summary>
public string PaymentAccount { get; set; }
/// <summary>
/// 付款银行
/// </summary>
public string PaymentBank { get; set; }
/// <summary>
/// 付款金额
/// </summary>
public decimal PaymentAmount { get; set; }
/// <summary>
/// 付款时间
/// </summary>
public string PaymentTime { get; set; }
/// <summary>
/// 收款账户
/// </summary>
public string CollectionAccount { get; set; }
/// <summary>
/// 收款银行
/// </summary>
public string CollectionBank { get; set; }
/// <summary>
/// 交易流水号
/// </summary>
public string TransactionId { get; set; }
/// <summary>
/// 备注
/// </summary>
public string Remark { get; set; }
}
}

205
src/Shentun.Peis.Application/InvoiceApplys/InvoiceApplyAppService.cs

@ -0,0 +1,205 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore.Metadata.Internal;
using Npgsql.Internal.TypeHandlers.DateTimeHandlers;
using NPOI.Util;
using Shentun.Peis.Migrations;
using Shentun.Peis.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Application.Services;
using Volo.Abp.Domain.Repositories;
namespace Shentun.Peis.InvoiceApplys
{
/// <summary>
/// 发票申请
/// </summary>
[ApiExplorerSettings(GroupName = "Work")]
[Authorize]
public class InvoiceApplyAppService : ApplicationService
{
private readonly IRepository<InvoiceApply, Guid> _invoiceApplyRepository;
private readonly IRepository<InvoiceRecord, Guid> _invoiceRecordRepository;
private readonly IRepository<PaymentRecord, Guid> _paymentRecordRepository;
private readonly IRepository<CustomerOrgRegister, Guid> _customerOrgRegisterRepository;
private readonly CacheService _cacheService;
public InvoiceApplyAppService(
IRepository<InvoiceApply, Guid> invoiceApplyRepository,
IRepository<InvoiceRecord, Guid> invoiceRecordRepository,
IRepository<PaymentRecord, Guid> paymentRecordRepository,
IRepository<CustomerOrgRegister, Guid> customerOrgRegisterRepository,
CacheService cacheService)
{
_invoiceApplyRepository = invoiceApplyRepository;
_invoiceRecordRepository = invoiceRecordRepository;
_paymentRecordRepository = paymentRecordRepository;
_customerOrgRegisterRepository = customerOrgRegisterRepository;
_cacheService = cacheService;
}
/// <summary>
/// 发票申请列表
/// </summary>
/// <returns></returns>
[HttpPost("api/app/InvoiceApply/GetInvoiceApplyList")]
public async Task<List<InvoiceApplyDto>> GetInvoiceApplyListAsync(GetInvoiceApplyListInputDto input)
{
var query = from invoiceApply in await _invoiceApplyRepository.GetQueryableAsync()
join customerOrgRegister in await _customerOrgRegisterRepository.GetQueryableAsync() on invoiceApply.CustomerOrgRegisterId equals customerOrgRegister.Id
select new
{
invoiceApply,
customerOrgRegister
};
if (!string.IsNullOrWhiteSpace(input.SalesPerson))
{
query = query.Where(m => m.invoiceApply.SalesPerson == input.SalesPerson);
}
if (input.IsCompleteInvoicing != null)
{
query = query.Where(m => m.invoiceApply.IsCompleteInvoicing == input.IsCompleteInvoicing);
}
if (input.IsCompletePayment != null)
{
query = query.Where(m => m.invoiceApply.IsCompletePayment == input.IsCompletePayment);
}
if (!string.IsNullOrWhiteSpace(input.StartDate) && !string.IsNullOrWhiteSpace(input.EndDate))
{
query = query.Where(m => m.invoiceApply.ApplyTime >= Convert.ToDateTime(input.StartDate) &&
m.invoiceApply.ApplyTime.Value < Convert.ToDateTime(input.EndDate).AddDays(1));
}
var entListDto = query.ToList().Select(s => new InvoiceApplyDto
{
Accounts = s.invoiceApply.Accounts,
ApplyAmount = s.invoiceApply.ApplyAmount,
ApplyTime = DataHelper.ConversionDateShortToString(s.invoiceApply.ApplyTime),
Bank = s.invoiceApply.Bank,
Contact = s.invoiceApply.Contact,
ContactPhone = s.invoiceApply.ContactPhone,
CountryOrgCode = s.invoiceApply.CountryOrgCode,
CreationTime = s.invoiceApply.CreationTime,
CreatorId = s.invoiceApply.CreatorId,
CreatorName = _cacheService.GetSurnameAsync(s.invoiceApply.CreatorId).GetAwaiter().GetResult(),
CustomerOrgId = s.invoiceApply.CustomerOrgId,
CustomerOrgName = _cacheService.GetTopCustomerOrgNameAsync(s.invoiceApply.CustomerOrgId).GetAwaiter().GetResult(),
DepartmentName = _cacheService.GetCustomerOrgNameAsync(s.invoiceApply.CustomerOrgId).GetAwaiter().GetResult(),
CustomerOrgRegisterId = s.invoiceApply.CustomerOrgRegisterId,
Id = s.invoiceApply.Id,
InvoiceName = s.invoiceApply.InvoiceName,
IsCompleteInvoicing = s.invoiceApply.IsCompleteInvoicing,
IsCompletePayment = s.invoiceApply.IsCompletePayment,
LastModificationTime = s.invoiceApply.LastModificationTime,
LastModifierId = s.invoiceApply.LastModifierId,
Remark = s.invoiceApply.Remark,
SalesPerson = s.invoiceApply.SalesPerson,
LastModifierName = _cacheService.GetSurnameAsync(s.invoiceApply.LastModifierId).GetAwaiter().GetResult(),
MedicalTimes = s.customerOrgRegister.MedicalTimes
}).ToList();
return entListDto;
}
/// <summary>
/// 创建发票申请
/// </summary>
/// <returns></returns>
[HttpPost("api/app/InvoiceApply/CreateInvoiceApply")]
public async Task CreateInvoiceApplyAsync(CreateInvoiceApplyInputDto input)
{
Guid invoiceApplyId = GuidGenerator.Create();
var invoiceApplyEntity = new InvoiceApply(invoiceApplyId)
{
Accounts = input.Accounts,
ApplyAmount = input.ApplyAmount,
ApplyTime = !string.IsNullOrWhiteSpace(input.ApplyTime) ? DateTime.Parse(input.ApplyTime) : DateTime.Now,
Bank = input.Bank,
Contact = input.Contact,
ContactPhone = input.ContactPhone,
CountryOrgCode = input.CountryOrgCode,
CustomerOrgId = input.CustomerOrgId,
CustomerOrgRegisterId = input.CustomerOrgRegisterId,
InvoiceName = input.InvoiceName,
IsCompleteInvoicing = input.IsCompleteInvoicing,
IsCompletePayment = input.IsCompletePayment,
Remark = input.Remark,
SalesPerson = input.SalesPerson
};
await _invoiceApplyRepository.InsertAsync(invoiceApplyEntity);
}
/// <summary>
/// 修改发票申请
/// </summary>
/// <returns></returns>
[HttpPost("api/app/InvoiceApply/UpdateInvoiceApply")]
public async Task UpdateInvoiceApplyAsync(UpdateInvoiceApplyInputDto input)
{
var invoiceApplyEntity = await _invoiceApplyRepository.FirstOrDefaultAsync(f => f.Id == input.Id);
if (invoiceApplyEntity == null)
{
throw new UserFriendlyException("申请不存在");
}
invoiceApplyEntity.Accounts = input.Accounts;
invoiceApplyEntity.ApplyAmount = input.ApplyAmount;
invoiceApplyEntity.ApplyTime = DateTime.Parse(input.ApplyTime);
invoiceApplyEntity.Bank = input.Bank;
invoiceApplyEntity.Contact = input.Contact;
invoiceApplyEntity.ContactPhone = input.ContactPhone;
invoiceApplyEntity.CountryOrgCode = input.CountryOrgCode;
invoiceApplyEntity.CustomerOrgId = input.CustomerOrgId;
invoiceApplyEntity.CustomerOrgRegisterId = input.CustomerOrgRegisterId;
invoiceApplyEntity.InvoiceName = input.InvoiceName;
invoiceApplyEntity.IsCompleteInvoicing = input.IsCompleteInvoicing;
invoiceApplyEntity.IsCompletePayment = input.IsCompletePayment;
invoiceApplyEntity.Remark = input.Remark;
invoiceApplyEntity.SalesPerson = input.SalesPerson;
await _invoiceApplyRepository.UpdateAsync(invoiceApplyEntity);
}
/// <summary>
/// 删除发票申请
/// </summary>
/// <returns></returns>
[HttpPost("api/app/InvoiceApply/DeleteInvoiceApply")]
public async Task DeleteInvoiceApplyAsync(InvoiceApplyIdInputDto input)
{
var invoiceApplyEntity = await _invoiceApplyRepository.FirstOrDefaultAsync(f => f.Id == input.InvoiceApplyId);
if (invoiceApplyEntity == null)
{
throw new UserFriendlyException("申请不存在");
}
var invoiceRecordEntity = await _invoiceRecordRepository.FirstOrDefaultAsync(f => f.InvoiceApplyId == input.InvoiceApplyId);
if (invoiceRecordEntity != null)
{
throw new UserFriendlyException("该发票申请已有开票记录,不能删除");
}
var paymentRecordEntity = await _paymentRecordRepository.FirstOrDefaultAsync(f => f.InvoiceApplyId == input.InvoiceApplyId);
if (paymentRecordEntity != null)
{
throw new UserFriendlyException("该发票申请已有付款记录,不能删除");
}
await _invoiceApplyRepository.DeleteAsync(invoiceApplyEntity);
}
}
}

146
src/Shentun.Peis.Application/InvoiceRecords/InvoiceRecordAppService.cs

@ -0,0 +1,146 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Shentun.Peis.InvoiceApplys;
using Shentun.Peis.Models;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Application.Services;
using Volo.Abp.Domain.Repositories;
namespace Shentun.Peis.InvoiceRecords
{
/// <summary>
/// 开票记录
/// </summary>
[ApiExplorerSettings(GroupName = "Work")]
[Authorize]
public class InvoiceRecordAppService : ApplicationService
{
private readonly IRepository<InvoiceRecord, Guid> _invoiceRecordRepository;
private readonly CacheService _cacheService;
public InvoiceRecordAppService(
IRepository<InvoiceRecord, Guid> invoiceRecordRepository,
CacheService cacheService)
{
_invoiceRecordRepository = invoiceRecordRepository;
_cacheService = cacheService;
}
/// <summary>
/// 开票记录列表
/// </summary>
/// <returns></returns>
[HttpPost("api/app/InvoiceRecord/GetInvoiceRecordList")]
public async Task<List<InvoiceRecordDto>> GetInvoiceRecordListAsync(GetInvoiceRecordListInputDto input)
{
var query = await _invoiceRecordRepository.GetQueryableAsync();
if (input.InvoiceApplyId != null)
{
query = query.Where(m => m.InvoiceApplyId == input.InvoiceApplyId);
}
if (!string.IsNullOrWhiteSpace(input.InvoicePerson))
{
query = query.Where(m => m.InvoicePerson == input.InvoicePerson);
}
if (input.StartAmount != null && input.EndAmount != null)
{
query = query.Where(m => m.InvoiceAmount >= input.StartAmount &&
m.InvoiceAmount < input.EndAmount);
}
if (!string.IsNullOrWhiteSpace(input.StartDate) && !string.IsNullOrWhiteSpace(input.EndDate))
{
query = query.Where(m => m.InvoiceTime >= Convert.ToDateTime(input.StartDate) &&
m.InvoiceTime < Convert.ToDateTime(input.EndDate).AddDays(1));
}
var entListDto = query.ToList().Select(s => new InvoiceRecordDto
{
CreationTime = s.CreationTime,
CreatorId = s.CreatorId,
CreatorName = _cacheService.GetSurnameAsync(s.CreatorId).GetAwaiter().GetResult(),
Id = s.Id,
LastModificationTime = s.LastModificationTime,
LastModifierId = s.LastModifierId,
Remark = s.Remark,
LastModifierName = _cacheService.GetSurnameAsync(s.LastModifierId).GetAwaiter().GetResult(),
InvoiceAmount = s.InvoiceAmount,
InvoiceTime = DataHelper.ConversionDateToString(s.LastModificationTime),
InvoiceApplyId = s.InvoiceApplyId,
InvoicePerson = s.InvoicePerson
}).ToList();
return entListDto;
}
/// <summary>
/// 添加开票记录
/// </summary>
/// <returns></returns>
[HttpPost("api/app/InvoiceRecord/CreateInvoiceRecord")]
public async Task CreateInvoiceRecordAsync(CreateInvoiceRecordInputDto input)
{
Guid invoiceRecordId = GuidGenerator.Create();
var invoiceRecordEntity = new InvoiceRecord(invoiceRecordId)
{
InvoiceAmount = input.InvoiceAmount,
InvoiceApplyId = input.InvoiceApplyId,
InvoicePerson = input.InvoicePerson,
InvoiceTime = !string.IsNullOrWhiteSpace(input.InvoiceTime) ? DateTime.Parse(input.InvoiceTime) : DateTime.Now,
Remark = input.Remark
};
await _invoiceRecordRepository.InsertAsync(invoiceRecordEntity);
}
/// <summary>
/// 修改开票记录
/// </summary>
/// <returns></returns>
[HttpPost("api/app/InvoiceRecord/UpdateInvoiceRecord")]
public async Task UpdateInvoiceRecordAsync(UpdateInvoiceRecordInputDto input)
{
var invoiceRecordEntity = await _invoiceRecordRepository.FirstOrDefaultAsync(f => f.Id == input.Id);
if (invoiceRecordEntity == null)
{
throw new UserFriendlyException("记录不存在");
}
invoiceRecordEntity.InvoiceTime = DateTime.Parse(input.InvoiceTime);
invoiceRecordEntity.InvoiceAmount = input.InvoiceAmount;
invoiceRecordEntity.InvoiceApplyId = input.InvoiceApplyId;
invoiceRecordEntity.InvoicePerson = input.Remark;
invoiceRecordEntity.Remark = input.Remark;
await _invoiceRecordRepository.UpdateAsync(invoiceRecordEntity);
}
/// <summary>
/// 删除开票记录
/// </summary>
/// <returns></returns>
[HttpPost("api/app/InvoiceRecord/DeleteInvoiceRecord")]
public async Task DeleteInvoiceApplyAsync(InvoiceRecordIdInputDto input)
{
var invoiceRecordEntity = await _invoiceRecordRepository.FirstOrDefaultAsync(f => f.Id == input.InvoiceRecordId);
if (invoiceRecordEntity == null)
{
throw new UserFriendlyException("记录不存在");
}
await _invoiceRecordRepository.DeleteAsync(invoiceRecordEntity);
}
}
}

164
src/Shentun.Peis.Application/PaymentRecords/PaymentRecordAppService.cs

@ -0,0 +1,164 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Shentun.Peis.Models;
using Shentun.Peis.PaymentRecords;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Application.Services;
using Volo.Abp.Domain.Repositories;
namespace Shentun.Peis.PaymentRecords
{
/// <summary>
/// 付款记录
/// </summary>
[ApiExplorerSettings(GroupName = "Work")]
[Authorize]
public class PaymentRecordAppService : ApplicationService
{
private readonly IRepository<PaymentRecord, Guid> _paymentRecordRepository;
private readonly CacheService _cacheService;
public PaymentRecordAppService(
IRepository<PaymentRecord, Guid> paymentRecordRepository,
CacheService cacheService)
{
_paymentRecordRepository = paymentRecordRepository;
_cacheService = cacheService;
}
/// <summary>
/// 付款记录列表
/// </summary>
/// <returns></returns>
[HttpPost("api/app/PaymentRecord/GetPaymentRecordList")]
public async Task<List<PaymentRecordDto>> GetPaymentRecordListAsync(GetPaymentRecordListInputDto input)
{
var query = await _paymentRecordRepository.GetQueryableAsync();
if (!string.IsNullOrWhiteSpace(input.PaymentAccount))
{
query = query.Where(m => m.PaymentAccount == input.PaymentAccount);
}
if (!string.IsNullOrWhiteSpace(input.CollectionAccount))
{
query = query.Where(m => m.CollectionAccount == input.CollectionAccount);
}
if (!string.IsNullOrWhiteSpace(input.TransactionId))
{
query = query.Where(m => m.TransactionId == input.TransactionId);
}
if (input.StartAmount != null && input.EndAmount != null)
{
query = query.Where(m => m.PaymentAmount >= input.StartAmount &&
m.PaymentAmount < input.EndAmount);
}
if (!string.IsNullOrWhiteSpace(input.StartDate) && !string.IsNullOrWhiteSpace(input.EndDate))
{
query = query.Where(m => m.PaymentTime >= Convert.ToDateTime(input.StartDate) &&
m.PaymentTime < Convert.ToDateTime(input.EndDate).AddDays(1));
}
var entListDto = query.ToList().Select(s => new PaymentRecordDto
{
CreationTime = s.CreationTime,
CreatorId = s.CreatorId,
CreatorName = _cacheService.GetSurnameAsync(s.CreatorId).GetAwaiter().GetResult(),
Id = s.Id,
LastModificationTime = s.LastModificationTime,
LastModifierId = s.LastModifierId,
CollectionAccount = s.CollectionAccount,
CollectionBank = s.CollectionBank,
PaymentAccount = s.PaymentAccount,
PaymentAmount = s.PaymentAmount,
PaymentBank = s.PaymentBank,
Remark = s.Remark,
TransactionId = s.TransactionId,
LastModifierName = _cacheService.GetSurnameAsync(s.LastModifierId).GetAwaiter().GetResult(),
InvoiceApplyId = s.InvoiceApplyId,
PaymentTime = DataHelper.ConversionDateToString(s.PaymentTime)
}).ToList();
return entListDto;
}
/// <summary>
/// 添加付款记录
/// </summary>
/// <returns></returns>
[HttpPost("api/app/PaymentRecord/CreatePaymentRecord")]
public async Task CreatePaymentRecordAsync(CreatePaymentRecordInputDto input)
{
Guid paymentRecordId = GuidGenerator.Create();
var paymentRecordEntity = new PaymentRecord(paymentRecordId)
{
CollectionAccount = input.CollectionAccount,
CollectionBank = input.CollectionBank,
PaymentAccount = input.PaymentAccount,
PaymentAmount = input.PaymentAmount,
PaymentBank = input.PaymentBank,
PaymentTime = string.IsNullOrWhiteSpace(input.PaymentTime) ? null : DateTime.Parse(input.PaymentTime),
TransactionId = input.TransactionId,
InvoiceApplyId = input.InvoiceApplyId,
Remark = input.Remark
};
await _paymentRecordRepository.InsertAsync(paymentRecordEntity);
}
/// <summary>
/// 修改付款记录
/// </summary>
/// <returns></returns>
[HttpPost("api/app/PaymentRecord/UpdatePaymentRecord")]
public async Task UpdatePaymentRecordAsync(UpdatePaymentRecordInputDto input)
{
var paymentRecordEntity = await _paymentRecordRepository.FirstOrDefaultAsync(f => f.Id == input.Id);
if (paymentRecordEntity == null)
{
throw new UserFriendlyException("记录不存在");
}
paymentRecordEntity.CollectionAccount = input.CollectionAccount;
paymentRecordEntity.CollectionBank = input.CollectionBank;
paymentRecordEntity.PaymentAccount = input.PaymentAccount;
paymentRecordEntity.PaymentAmount = input.PaymentAmount;
paymentRecordEntity.PaymentBank = input.PaymentBank;
paymentRecordEntity.PaymentTime = string.IsNullOrWhiteSpace(input.PaymentTime) ? null : DateTime.Parse(input.PaymentTime);
paymentRecordEntity.TransactionId = input.TransactionId;
paymentRecordEntity.InvoiceApplyId = input.InvoiceApplyId;
paymentRecordEntity.Remark = input.Remark;
await _paymentRecordRepository.UpdateAsync(paymentRecordEntity);
}
/// <summary>
/// 删除付款记录
/// </summary>
/// <returns></returns>
[HttpPost("api/app/PaymentRecord/DeletePaymentRecord")]
public async Task DeleteInvoiceApplyAsync(PaymentRecordIdInputDto input)
{
var paymentRecordEntity = await _paymentRecordRepository.FirstOrDefaultAsync(f => f.Id == input.PaymentRecordId);
if (paymentRecordEntity == null)
{
throw new UserFriendlyException("记录不存在");
}
await _paymentRecordRepository.DeleteAsync(paymentRecordEntity);
}
}
}
Loading…
Cancel
Save