创建采购订单接口
This commit is contained in:
@@ -215,7 +215,7 @@
|
||||
<param name="ids"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.ERP.PurchaseController.PageList(Yi.Framework.DtoModel.ERP.Purchase.PurchaseCreateUpdateInput,Yi.Framework.Common.Models.PageParModel)">
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.ERP.PurchaseController.PageList(Yi.Framework.DtoModel.ERP.Purchase.PurchaseGetListInput,Yi.Framework.Common.Models.PageParModel)">
|
||||
<summary>
|
||||
分页查
|
||||
</summary>
|
||||
@@ -227,14 +227,14 @@
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.ERP.PurchaseController.Create(Yi.Framework.DtoModel.ERP.Purchase.PurchaseCreateUpdateInput)">
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.ERP.PurchaseController.Create(Yi.Framework.DtoModel.ERP.Purchase.PurchaseCreateInput)">
|
||||
<summary>
|
||||
增
|
||||
</summary>
|
||||
<param name="input"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.ERP.PurchaseController.Update(System.Int64,Yi.Framework.DtoModel.ERP.Purchase.PurchaseCreateUpdateInput)">
|
||||
<member name="M:Yi.Framework.ApiMicroservice.Controllers.ERP.PurchaseController.Update(System.Int64,Yi.Framework.DtoModel.ERP.Purchase.PurchaseUpdateInput)">
|
||||
<summary>
|
||||
更
|
||||
</summary>
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers.ERP
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public async Task<Result> PageList([FromQuery] PurchaseCreateUpdateInput input, [FromQuery] PageParModel page)
|
||||
public async Task<Result> PageList([FromQuery] PurchaseGetListInput input, [FromQuery] PageParModel page)
|
||||
{
|
||||
var result = await _purchaseService.PageListAsync(input, page);
|
||||
return Result.Success().SetData(result);
|
||||
@@ -46,7 +46,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers.ERP
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<Result> Create(PurchaseCreateUpdateInput input)
|
||||
public async Task<Result> Create(PurchaseCreateInput input)
|
||||
{
|
||||
var result = await _purchaseService.CreateAsync(input);
|
||||
return Result.Success().SetData(result);
|
||||
@@ -60,7 +60,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers.ERP
|
||||
/// <returns></returns>
|
||||
[HttpPut]
|
||||
[Route("{id}")]
|
||||
public async Task<Result> Update(long id, PurchaseCreateUpdateInput input)
|
||||
public async Task<Result> Update(long id, PurchaseUpdateInput input)
|
||||
{
|
||||
var result = await _purchaseService.UpdateAsync(id, input);
|
||||
return Result.Success().SetData(result);
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace Yi.Framework.DtoModel.ERP.Purchase.MapperConfig
|
||||
{
|
||||
public SuppliERProfile()
|
||||
{
|
||||
CreateMap<PurchaseCreateUpdateInput, PurchaseEntity>();
|
||||
CreateMap<PurchaseCreateInput, PurchaseEntity>();
|
||||
CreateMap<PurchaseEntity, PurchaseGetListOutput>();
|
||||
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.DtoModel.ERP.PurchaseDetails;
|
||||
using Yi.Framework.Model.Base;
|
||||
using Yi.Framework.Model.ERP.Entitys;
|
||||
|
||||
namespace Yi.Framework.DtoModel.ERP.Purchase
|
||||
{
|
||||
public class PurchaseCreateInput
|
||||
{
|
||||
public string Code { get; set; } = string.Empty;
|
||||
public DateTime? NeedTime { get; set; }
|
||||
public string Buyer { get; set; } = string.Empty;
|
||||
|
||||
public List<PurchaseDetailsCreateUpdateInput>? PurchaseDetails { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Yi.Framework.Model.Base;
|
||||
using Yi.Framework.Model.ERP.Entitys;
|
||||
|
||||
namespace Yi.Framework.DtoModel.ERP.Purchase
|
||||
{
|
||||
public class PurchaseGetListInput
|
||||
{
|
||||
public string? Code { get; set; }
|
||||
public DateTime? NeedTime { get; set; }
|
||||
public string? Buyer { get; set; }
|
||||
public PurchaseStateEnum? PurchaseState { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@ using Yi.Framework.Model.ERP.Entitys;
|
||||
|
||||
namespace Yi.Framework.DtoModel.ERP.Purchase
|
||||
{
|
||||
public class PurchaseCreateUpdateInput : EntityDto<long>
|
||||
public class PurchaseUpdateInput : EntityDto<long>
|
||||
{
|
||||
public string Code { get; set; }
|
||||
public DateTime NeedTime { get; set; }
|
||||
@@ -17,5 +17,7 @@ namespace Yi.Framework.Interface.Base.Crud
|
||||
, in TCreateInputDto> : IApplicationService
|
||||
{
|
||||
Task<TCreateResultOutputDto> CreateAsync(TCreateInputDto dto);
|
||||
|
||||
Task CreateAsync(IEnumerable<TCreateInputDto> dtos);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@ using Yi.Framework.Interface.Base.Crud;
|
||||
|
||||
namespace Yi.Framework.Interface.ERP
|
||||
{
|
||||
public interface IPurchaseService : ICrudAppService<PurchaseGetListOutput, long, PurchaseCreateUpdateInput>
|
||||
public interface IPurchaseService : ICrudAppService<PurchaseGetListOutput, long, PurchaseCreateInput, PurchaseUpdateInput>
|
||||
{
|
||||
Task<PageModel<List<PurchaseGetListOutput>>> PageListAsync(PurchaseCreateUpdateInput input, PageParModel page);
|
||||
Task<PageModel<List<PurchaseGetListOutput>>> PageListAsync(PurchaseGetListInput input, PageParModel page);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,12 +45,12 @@ namespace Yi.Framework.Model.ERP.Entitys
|
||||
/// <summary>
|
||||
/// 总共金额
|
||||
/// </summary>
|
||||
public long TotalMoney { get; set; }
|
||||
public float TotalMoney { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 已支付金额
|
||||
/// </summary>
|
||||
public long PaidMoney { get; set; }
|
||||
public float PaidMoney { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 采购状态
|
||||
|
||||
@@ -75,6 +75,18 @@ namespace Yi.Framework.Service.Base.Crud
|
||||
return entitydto;
|
||||
}
|
||||
|
||||
|
||||
public async virtual Task CreateAsync(IEnumerable<TCreateInput> dtos)
|
||||
{
|
||||
|
||||
var entity = await MapToEntitysAsync(dtos);
|
||||
|
||||
TryToSetTenantId(entity);
|
||||
|
||||
//这边需要进行判断,实体是什么guid还是雪花id
|
||||
await Repository.InsertReturnSnowflakeIdAsync(entity);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除
|
||||
/// </summary>
|
||||
@@ -126,6 +138,19 @@ namespace Yi.Framework.Service.Base.Crud
|
||||
MapToEntity(updateInput, entity);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 将 批量更新输入dto转化为实体的异步
|
||||
/// </summary>
|
||||
/// <param name="updateInput"></param>
|
||||
/// <param name="entity"></param>
|
||||
protected virtual async Task<List<TEntity>> MapToEntitysAsync(IEnumerable<TCreateInput> updateInput)
|
||||
{
|
||||
List<TEntity> entitys = MapToEntitys(updateInput);
|
||||
|
||||
return await Task.FromResult(entitys);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 将 更新输入dto转化为实体的同步方法
|
||||
/// </summary>
|
||||
@@ -136,6 +161,17 @@ namespace Yi.Framework.Service.Base.Crud
|
||||
ObjectMapper.Map(updateInput, entity);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 将 批量更新输入dto转化为实体的同步方法
|
||||
/// </summary>
|
||||
/// <param name="updateInput"></param>
|
||||
/// <returns></returns>
|
||||
protected virtual List<TEntity> MapToEntitys(IEnumerable<TCreateInput> updateInput)
|
||||
{
|
||||
return ObjectMapper.Map<List<TEntity>>(updateInput);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 创建dto 给 实体的转换的异步方法
|
||||
/// </summary>
|
||||
@@ -203,6 +239,16 @@ namespace Yi.Framework.Service.Base.Crud
|
||||
//}
|
||||
}
|
||||
|
||||
protected virtual void TryToSetTenantId(IEnumerable<TEntity> entitys)
|
||||
{
|
||||
foreach (var entity in entitys)
|
||||
{
|
||||
TryToSetTenantId(entity);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 判断租户id的属性是否为空
|
||||
/// </summary>
|
||||
|
||||
@@ -14,12 +14,17 @@ using Yi.Framework.Service.Base.Crud;
|
||||
|
||||
namespace Yi.Framework.Service.ERP
|
||||
{
|
||||
public class PurchaseService : CrudAppService<PurchaseEntity, PurchaseGetListOutput, long, PurchaseCreateUpdateInput>, IPurchaseService
|
||||
public class PurchaseService : CrudAppService<PurchaseEntity, PurchaseGetListOutput, long, PurchaseCreateInput, PurchaseUpdateInput>, IPurchaseService
|
||||
{
|
||||
public PurchaseService(IRepository<PurchaseEntity> repository, IMapper mapper) : base(repository, mapper)
|
||||
private readonly ISugarUnitOfWork<UnitOfWork> _unitOfWork;
|
||||
private readonly IPurchaseDetailsService _purchaseDetailsService;
|
||||
public PurchaseService(IRepository<PurchaseEntity> repository, IMapper mapper, ISugarUnitOfWork<UnitOfWork> unitOfWork,
|
||||
IPurchaseDetailsService purchaseDetailsService) : base(repository, mapper)
|
||||
{
|
||||
_unitOfWork = unitOfWork;
|
||||
_purchaseDetailsService = purchaseDetailsService;
|
||||
}
|
||||
public async Task<PageModel<List<PurchaseGetListOutput>>> PageListAsync(PurchaseCreateUpdateInput input, PageParModel page)
|
||||
public async Task<PageModel<List<PurchaseGetListOutput>>> PageListAsync(PurchaseGetListInput input, PageParModel page)
|
||||
{
|
||||
RefAsync<int> totalNumber = 0;
|
||||
var data = await Repository._DbQueryable
|
||||
@@ -28,5 +33,23 @@ namespace Yi.Framework.Service.ERP
|
||||
.ToPageListAsync(page.PageNum, page.PageSize, totalNumber);
|
||||
return new PageModel<List<PurchaseGetListOutput>> { Total = totalNumber.Value, Data = await MapToGetListOutputDtosAsync(data) };
|
||||
}
|
||||
|
||||
public override async Task<PurchaseGetListOutput> CreateAsync(PurchaseCreateInput input)
|
||||
{
|
||||
|
||||
using (var uow = _unitOfWork.CreateContext())
|
||||
{
|
||||
var entity = await MapToEntityAsync(input);
|
||||
entity.PaidMoney = 0;
|
||||
entity.TotalMoney = input.PurchaseDetails.Sum(u => u.UnitPrice * u.TotalNumber);
|
||||
entity.PurchaseState = PurchaseStateEnum.Build;
|
||||
TryToSetTenantId(entity);
|
||||
var purchaseId = await Repository.InsertReturnSnowflakeIdAsync(entity);
|
||||
|
||||
await _purchaseDetailsService.CreateAsync(input.PurchaseDetails);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -314,12 +314,6 @@
|
||||
|
||||
/** 表单重置 */
|
||||
function reset() {
|
||||
form.value = {
|
||||
id: undefined,
|
||||
title: undefined,
|
||||
isDeleted: false,
|
||||
remark: undefined,
|
||||
};
|
||||
proxy.resetForm("dataRef");
|
||||
}
|
||||
/** 搜索按钮操作 */
|
||||
|
||||
Reference in New Issue
Block a user