Merge branch 'master' of https://git.konsoft.top/konsoft/KonSoft.Clean
This commit is contained in:
@ -7,19 +7,16 @@ 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 Volo.Abp;
|
||||||
using Volo.Abp.Application.Services;
|
using Volo.Abp.Application.Services;
|
||||||
using Volo.Abp.ObjectMapping;
|
using Volo.Abp.ObjectMapping;
|
||||||
|
|
||||||
namespace KonSoft.Admin.ApplicationServices
|
namespace KonSoft.Admin.ApplicationServices
|
||||||
{
|
{
|
||||||
public class OrderAppService : ApplicationService, IOrderAppService
|
public class OrderAppService(IOrderRepository orderRepository) : ApplicationService, IOrderAppService
|
||||||
{
|
{
|
||||||
private readonly IOrderRepository _orderRepository;
|
private readonly IOrderRepository _orderRepository = orderRepository;
|
||||||
|
|
||||||
public OrderAppService(IOrderRepository orderRepository)
|
|
||||||
{
|
|
||||||
_orderRepository = orderRepository;
|
|
||||||
}
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 分配师傅
|
/// 分配师傅
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -27,7 +24,7 @@ namespace KonSoft.Admin.ApplicationServices
|
|||||||
/// <param name="workerId"></param>
|
/// <param name="workerId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
/// <exception cref="NotImplementedException"></exception>
|
/// <exception cref="NotImplementedException"></exception>
|
||||||
public async Task AssignAsync(Guid orderId, Guid workerId)
|
public async Task AssignAsync(Guid orderId, Guid workerId)
|
||||||
{
|
{
|
||||||
var order = await _orderRepository.GetAsync(o => o.Id == orderId);
|
var order = await _orderRepository.GetAsync(o => o.Id == orderId);
|
||||||
order.AssignWorker(workerId);
|
order.AssignWorker(workerId);
|
||||||
@ -45,6 +42,7 @@ namespace KonSoft.Admin.ApplicationServices
|
|||||||
var order = await _orderRepository.GetAsync(o => o.Id == orderId);
|
var order = await _orderRepository.GetAsync(o => o.Id == orderId);
|
||||||
order.Cancel(reason);
|
order.Cancel(reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 完成订单
|
/// 完成订单
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -56,6 +54,7 @@ namespace KonSoft.Admin.ApplicationServices
|
|||||||
var order = await _orderRepository.GetAsync(o => o.Id == orderId);
|
var order = await _orderRepository.GetAsync(o => o.Id == orderId);
|
||||||
order.CompleteService();
|
order.CompleteService();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 确认订单
|
/// 确认订单
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -67,6 +66,7 @@ namespace KonSoft.Admin.ApplicationServices
|
|||||||
var order = await _orderRepository.GetAsync(o => o.Id == orderId);
|
var order = await _orderRepository.GetAsync(o => o.Id == orderId);
|
||||||
order.ConfirmCompletion();
|
order.ConfirmCompletion();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 创建订单
|
/// 创建订单
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -83,6 +83,34 @@ namespace KonSoft.Admin.ApplicationServices
|
|||||||
await _orderRepository.InsertAsync(order);
|
await _orderRepository.InsertAsync(order);
|
||||||
return ObjectMapper.Map<Order, OrderDto>(order);
|
return ObjectMapper.Map<Order, OrderDto>(order);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 根据订单ID删除订单
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id">订单ID</param>
|
||||||
|
public async Task DeleteAsync(Guid id)
|
||||||
|
{
|
||||||
|
// 根据ID删除订单
|
||||||
|
await _orderRepository.DeleteAsync(x => x.Id == id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 修改订单信息
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="input">订单DTO对象</param>s
|
||||||
|
public async Task EditAsync(OrderDto input)
|
||||||
|
{
|
||||||
|
// 根据ID查询订单,如果不存在则抛出异常【修改前端必然看到了,数据若查不到提示自定义异常信息】
|
||||||
|
var order = await _orderRepository.FindAsync(o => o.Id == input.Id) ??
|
||||||
|
throw new BusinessException("订单找不到").WithData("Id", input.Id);
|
||||||
|
|
||||||
|
// 将输入的DTO字段映射到订单实体
|
||||||
|
ObjectMapper.Map(input, order);
|
||||||
|
|
||||||
|
// 更新订单
|
||||||
|
await _orderRepository.UpdateAsync(order);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 支付
|
/// 支付
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -94,6 +122,7 @@ namespace KonSoft.Admin.ApplicationServices
|
|||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 开始订单
|
/// 开始订单
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -106,10 +135,28 @@ namespace KonSoft.Admin.ApplicationServices
|
|||||||
order.StartService();
|
order.StartService();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 根据订单ID获取单个订单
|
||||||
|
/// </summary>
|
||||||
public async Task<OrderDto> GetAsync(Guid id)
|
public async Task<OrderDto> GetAsync(Guid id)
|
||||||
{
|
{
|
||||||
|
// 根据ID从数据库查询订单
|
||||||
var order = await _orderRepository.GetAsync(o => o.Id == id);
|
var order = await _orderRepository.GetAsync(o => o.Id == id);
|
||||||
|
|
||||||
|
// 转换为OrderDto返回
|
||||||
return ObjectMapper.Map<Order, OrderDto>(order);
|
return ObjectMapper.Map<Order, OrderDto>(order);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取所有订单列表
|
||||||
|
/// </summary>
|
||||||
|
public async Task<List<OrderDto>> GetListAsync()
|
||||||
|
{
|
||||||
|
// 查询所有订单
|
||||||
|
var orders = await _orderRepository.GetListAsync();
|
||||||
|
|
||||||
|
// 转换为OrderDto列表返回
|
||||||
|
return ObjectMapper.Map<List<Order>, List<OrderDto>>(orders);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user