创建采购订单接口
This commit is contained in:
@@ -215,7 +215,7 @@
|
|||||||
<param name="ids"></param>
|
<param name="ids"></param>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</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>
|
||||||
分页查
|
分页查
|
||||||
</summary>
|
</summary>
|
||||||
@@ -227,14 +227,14 @@
|
|||||||
</summary>
|
</summary>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</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>
|
||||||
增
|
增
|
||||||
</summary>
|
</summary>
|
||||||
<param name="input"></param>
|
<param name="input"></param>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</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>
|
||||||
更
|
更
|
||||||
</summary>
|
</summary>
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers.ERP
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpGet]
|
[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);
|
var result = await _purchaseService.PageListAsync(input, page);
|
||||||
return Result.Success().SetData(result);
|
return Result.Success().SetData(result);
|
||||||
@@ -46,7 +46,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers.ERP
|
|||||||
/// <param name="input"></param>
|
/// <param name="input"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task<Result> Create(PurchaseCreateUpdateInput input)
|
public async Task<Result> Create(PurchaseCreateInput input)
|
||||||
{
|
{
|
||||||
var result = await _purchaseService.CreateAsync(input);
|
var result = await _purchaseService.CreateAsync(input);
|
||||||
return Result.Success().SetData(result);
|
return Result.Success().SetData(result);
|
||||||
@@ -60,7 +60,7 @@ namespace Yi.Framework.ApiMicroservice.Controllers.ERP
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPut]
|
[HttpPut]
|
||||||
[Route("{id}")]
|
[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);
|
var result = await _purchaseService.UpdateAsync(id, input);
|
||||||
return Result.Success().SetData(result);
|
return Result.Success().SetData(result);
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ namespace Yi.Framework.DtoModel.ERP.Purchase.MapperConfig
|
|||||||
{
|
{
|
||||||
public SuppliERProfile()
|
public SuppliERProfile()
|
||||||
{
|
{
|
||||||
CreateMap<PurchaseCreateUpdateInput, PurchaseEntity>();
|
CreateMap<PurchaseCreateInput, PurchaseEntity>();
|
||||||
CreateMap<PurchaseEntity, PurchaseGetListOutput>();
|
CreateMap<PurchaseEntity, PurchaseGetListOutput>();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<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
|
namespace Yi.Framework.DtoModel.ERP.Purchase
|
||||||
{
|
{
|
||||||
public class PurchaseCreateUpdateInput : EntityDto<long>
|
public class PurchaseUpdateInput : EntityDto<long>
|
||||||
{
|
{
|
||||||
public string Code { get; set; }
|
public string Code { get; set; }
|
||||||
public DateTime NeedTime { get; set; }
|
public DateTime NeedTime { get; set; }
|
||||||
@@ -17,5 +17,7 @@ namespace Yi.Framework.Interface.Base.Crud
|
|||||||
, in TCreateInputDto> : IApplicationService
|
, in TCreateInputDto> : IApplicationService
|
||||||
{
|
{
|
||||||
Task<TCreateResultOutputDto> CreateAsync(TCreateInputDto dto);
|
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
|
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>
|
||||||
/// 总共金额
|
/// 总共金额
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public long TotalMoney { get; set; }
|
public float TotalMoney { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 已支付金额
|
/// 已支付金额
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public long PaidMoney { get; set; }
|
public float PaidMoney { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 采购状态
|
/// 采购状态
|
||||||
|
|||||||
@@ -75,6 +75,18 @@ namespace Yi.Framework.Service.Base.Crud
|
|||||||
return entitydto;
|
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>
|
||||||
/// 删除
|
/// 删除
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -126,6 +138,19 @@ namespace Yi.Framework.Service.Base.Crud
|
|||||||
MapToEntity(updateInput, entity);
|
MapToEntity(updateInput, entity);
|
||||||
return Task.CompletedTask;
|
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>
|
/// <summary>
|
||||||
/// 将 更新输入dto转化为实体的同步方法
|
/// 将 更新输入dto转化为实体的同步方法
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -136,6 +161,17 @@ namespace Yi.Framework.Service.Base.Crud
|
|||||||
ObjectMapper.Map(updateInput, entity);
|
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>
|
/// <summary>
|
||||||
/// 创建dto 给 实体的转换的异步方法
|
/// 创建dto 给 实体的转换的异步方法
|
||||||
/// </summary>
|
/// </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>
|
/// <summary>
|
||||||
/// 判断租户id的属性是否为空
|
/// 判断租户id的属性是否为空
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -14,12 +14,17 @@ using Yi.Framework.Service.Base.Crud;
|
|||||||
|
|
||||||
namespace Yi.Framework.Service.ERP
|
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;
|
RefAsync<int> totalNumber = 0;
|
||||||
var data = await Repository._DbQueryable
|
var data = await Repository._DbQueryable
|
||||||
@@ -28,5 +33,23 @@ namespace Yi.Framework.Service.ERP
|
|||||||
.ToPageListAsync(page.PageNum, page.PageSize, totalNumber);
|
.ToPageListAsync(page.PageNum, page.PageSize, totalNumber);
|
||||||
return new PageModel<List<PurchaseGetListOutput>> { Total = totalNumber.Value, Data = await MapToGetListOutputDtosAsync(data) };
|
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() {
|
function reset() {
|
||||||
form.value = {
|
|
||||||
id: undefined,
|
|
||||||
title: undefined,
|
|
||||||
isDeleted: false,
|
|
||||||
remark: undefined,
|
|
||||||
};
|
|
||||||
proxy.resetForm("dataRef");
|
proxy.resetForm("dataRef");
|
||||||
}
|
}
|
||||||
/** 搜索按钮操作 */
|
/** 搜索按钮操作 */
|
||||||
|
|||||||
Reference in New Issue
Block a user