upd: 修改订单与家政人员接口
This commit is contained in:
		| @ -0,0 +1,126 @@ | ||||
| using KonSoft.Admin.Dtos; | ||||
| using KonSoft.Admin.Entities; | ||||
| using KonSoft.Admin.IApplicationServices; | ||||
| using KonSoft.Admin.IRepositories; | ||||
| 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; | ||||
| using Volo.Abp.ObjectMapping; | ||||
|  | ||||
| namespace KonSoft.Admin.ApplicationServices | ||||
| { | ||||
|     public class HouseholdWorkerAppService : ApplicationService, IHouseholdWorkerAppService | ||||
|     { | ||||
|         public IOrderRepository _orderRepository { get; set; } | ||||
|  | ||||
|         public HouseholdWorkerAppService(IOrderRepository orderRepository) | ||||
|         { | ||||
|             _orderRepository = orderRepository; | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// 家政人员接单 | ||||
|         /// </summary> | ||||
|         /// <param name="orderId"></param> | ||||
|         /// <returns></returns> | ||||
|         /// <exception cref="NotImplementedException"></exception> | ||||
|         public async Task AcceptOrderAsync(Guid orderId) | ||||
|         { | ||||
|             var order = await _orderRepository.FirstOrDefaultAsync(o => o.Id == orderId); | ||||
|             if (order == null) throw new BusinessException("未找到订单"); | ||||
|  | ||||
|             order.AssignWorker(CurrentUser.Id!.Value); | ||||
|  | ||||
|         } | ||||
|  | ||||
|  | ||||
|  | ||||
|         /// <summary> | ||||
|         /// 获取已接单任务 | ||||
|         /// </summary> | ||||
|         /// <returns></returns> | ||||
|         /// <exception cref="NotImplementedException"></exception> | ||||
|         public async Task<List<OrderDto>> GetAssignedOrdersAsync(OrderPagedResultRequestDto requestDto) | ||||
|         { | ||||
|             //TODO 默认根据角色筛选对应订单,整合到一个接口中 | ||||
|             var query =  await _orderRepository.GetQueryableAsync(); | ||||
|            var orders = query.Where(o => o.HouseholdWorkerId == CurrentUser.Id) | ||||
|                 .PageBy(requestDto).ToList(); ; | ||||
|  | ||||
|             return ObjectMapper.Map<List<Order>, List<OrderDto>>(orders); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// 获取待接单任务 | ||||
|         /// </summary> | ||||
|         /// <param name="requestDto"></param> | ||||
|         /// <returns></returns> | ||||
|         public async Task<List<OrderDto>> GetCreatedOrdersAsync(OrderPagedResultRequestDto requestDto) | ||||
|         {        | ||||
|            //TODO 默认根据角色筛选对应订单,整合到一个接口中 | ||||
|             var query = await _orderRepository.GetQueryableAsync(); | ||||
|             var orders = query.Where(o => o.Status == Enums.OrderStatus.Created) | ||||
|                  .PageBy(requestDto).ToList(); ; | ||||
|  | ||||
|             return ObjectMapper.Map<List<Order>, List<OrderDto>>(orders); | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// 家政人员注册 | ||||
|         /// </summary> | ||||
|         /// <param name="input"></param> | ||||
|         /// <returns></returns> | ||||
|         /// <exception cref="NotImplementedException"></exception> | ||||
|         public Task RegisterAsync(WorkerRegisterDto input) | ||||
|         { | ||||
|             throw new NotImplementedException(); | ||||
|         } | ||||
|         /// <summary> | ||||
|         /// 退单 | ||||
|         /// </summary> | ||||
|         /// <param name="orderId"></param> | ||||
|         /// <returns></returns> | ||||
|         /// <exasception cref="NotImplementedException"></exception> | ||||
|         public async Task RejectOrderAsync(Guid orderId) | ||||
|         { | ||||
|             var order = await _orderRepository.FirstOrDefaultAsync(o => o.Id == orderId); | ||||
|             if (order == null) throw new BusinessException("未找到订单"); | ||||
|  | ||||
|             order.RejectOrder(CurrentUser.Id!.Value); | ||||
|         } | ||||
|         /// <summary> | ||||
|         /// 开始服务 | ||||
|         /// </summary> | ||||
|         /// <param name="orderId"></param> | ||||
|         /// <returns></returns> | ||||
|         /// <exception cref="NotImplementedException"></exception> | ||||
|         public async Task StartServiceAsync(Guid orderId) | ||||
|         { | ||||
|             var order = await _orderRepository.FirstOrDefaultAsync(o => o.Id == orderId); | ||||
|             if (order == null) throw new BusinessException("未找到订单"); | ||||
|  | ||||
|             order.StartService(); | ||||
|  | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// 服务完成 | ||||
|         /// </summary> | ||||
|         /// <param name="orderId"></param> | ||||
|         /// <returns></returns> | ||||
|         /// <exception cref="NotImplementedException"></exception> | ||||
|         public async Task CompleteServiceAsync(Guid orderId) | ||||
|         { | ||||
|             var order = await _orderRepository.FirstOrDefaultAsync(o => o.Id == orderId); | ||||
|             if (order == null) throw new BusinessException("未找到订单"); | ||||
|  | ||||
|             order.CompleteService(); | ||||
|  | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @ -18,18 +18,6 @@ public class OrderAppService(IOrderRepository orderRepository) : ApplicationServ | ||||
| { | ||||
|     private readonly IOrderRepository _orderRepository = orderRepository; | ||||
|  | ||||
|     /// <summary> | ||||
|     ///     分配师傅 | ||||
|     /// </summary> | ||||
|     /// <param name="orderId"></param> | ||||
|     /// <param name="workerId"></param> | ||||
|     /// <returns></returns> | ||||
|     /// <exception cref="NotImplementedException"></exception> | ||||
|     public async Task AssignAsync(Guid orderId, Guid workerId) | ||||
|     { | ||||
|         var order = await _orderRepository.GetAsync(o => o.Id == orderId); | ||||
|         order.AssignWorker(workerId); | ||||
|     } | ||||
|  | ||||
|     /// <summary> | ||||
|     ///     取消订单 | ||||
| @ -44,29 +32,6 @@ public class OrderAppService(IOrderRepository orderRepository) : ApplicationServ | ||||
|         order.Cancel(reason); | ||||
|     } | ||||
|  | ||||
|     /// <summary> | ||||
|     ///     完成订单 | ||||
|     /// </summary> | ||||
|     /// <param name="orderId"></param> | ||||
|     /// <returns></returns> | ||||
|     /// <exception cref="NotImplementedException"></exception> | ||||
|     public async Task CompleteServiceAsync(Guid orderId) | ||||
|     { | ||||
|         var order = await _orderRepository.GetAsync(o => o.Id == orderId); | ||||
|         order.CompleteService(); | ||||
|     } | ||||
|  | ||||
|     /// <summary> | ||||
|     ///     确认订单 | ||||
|     /// </summary> | ||||
|     /// <param name="orderId"></param> | ||||
|     /// <returns></returns> | ||||
|     /// <exception cref="NotImplementedException"></exception> | ||||
|     public async Task ConfirmAsync(Guid orderId) | ||||
|     { | ||||
|         var order = await _orderRepository.GetAsync(o => o.Id == orderId); | ||||
|         order.ConfirmCompletion(); | ||||
|     } | ||||
|  | ||||
|     /// <summary> | ||||
|     ///     创建订单 | ||||
| @ -97,10 +62,9 @@ public class OrderAppService(IOrderRepository orderRepository) : ApplicationServ | ||||
|     } | ||||
|  | ||||
|     /// <summary> | ||||
|     ///     修改订单信息 | ||||
|     /// 修改订单信息 | ||||
|     /// </summary> | ||||
|     /// <param name="input">订单DTO对象</param> | ||||
|     /// s | ||||
|     public async Task EditAsync(OrderDto input) | ||||
|     { | ||||
|         // 根据ID查询订单,如果不存在则抛出异常【修改前端必然看到了,数据若查不到提示自定义异常信息】 | ||||
| @ -111,35 +75,37 @@ public class OrderAppService(IOrderRepository orderRepository) : ApplicationServ | ||||
|         ObjectMapper.Map(input, order); | ||||
|  | ||||
|         // 更新订单 | ||||
|         await _orderRepository.UpdateAsync(order); | ||||
|         //await _orderRepository.UpdateAsync(order); | ||||
|     } | ||||
|  | ||||
|     public async Task PayServiceCallFeeAsync(Guid orderId, PayOrderDto input) | ||||
|     { | ||||
|         var order = await _orderRepository.FirstOrDefaultAsync(o => o.Id == orderId); | ||||
|         if (order == null) throw new BusinessException("未找到订单"); | ||||
|  | ||||
|         order.PayServiceCallFee(); | ||||
|  | ||||
|     } | ||||
|  | ||||
|  | ||||
|     /// <summary> | ||||
|     ///     支付 | ||||
|     /// 支付 | ||||
|     /// </summary> | ||||
|     /// <param name="orderId"></param> | ||||
|     /// <param name="input"></param> | ||||
|     /// <returns></returns> | ||||
|     /// <exception cref="NotImplementedException"></exception> | ||||
|     public Task<OrderDto> PayAsync(Guid orderId, PayOrderDto input) | ||||
|     public async Task PayAsync(Guid orderId, PayOrderDto input) | ||||
|     { | ||||
|         throw new NotImplementedException(); | ||||
|         var order = await _orderRepository.FirstOrDefaultAsync(o => o.Id == orderId); | ||||
|         if (order == null) throw new BusinessException("未找到订单"); | ||||
|  | ||||
|         order.Pay(); | ||||
|     } | ||||
|  | ||||
|     /// <summary> | ||||
|     ///     开始订单 | ||||
|     /// </summary> | ||||
|     /// <param name="orderId"></param> | ||||
|     /// <returns></returns> | ||||
|     /// <exception cref="NotImplementedException"></exception> | ||||
|     public async Task StartServiceAsync(Guid orderId) | ||||
|     { | ||||
|         var order = await _orderRepository.GetAsync(o => o.Id == orderId); | ||||
|         order.StartService(); | ||||
|     } | ||||
|  | ||||
|     /// <summary> | ||||
|     ///     根据订单ID获取单个订单 | ||||
|     /// 根据订单ID获取单个订单 | ||||
|     /// </summary> | ||||
|     public async Task<OrderDto> GetAsync(Guid id) | ||||
|     { | ||||
| @ -151,12 +117,13 @@ public class OrderAppService(IOrderRepository orderRepository) : ApplicationServ | ||||
|     } | ||||
|  | ||||
|     /// <summary> | ||||
|     ///     获取所有订单列表 | ||||
|     /// 获取订单列表 | ||||
|     /// </summary> | ||||
|     public async Task<PagedResultDto<OrderDto>> GetListAsync(PagedResultRequestDto input) | ||||
|     public async Task<PagedResultDto<OrderDto>> GetListAsync(OrderPagedResultRequestDto input) | ||||
|     { | ||||
|         // 查询所有订单 | ||||
|         var orders = await _orderRepository.GetPagedListAsync(input.SkipCount, input.MaxResultCount, "Id"); | ||||
|         //TODO 默认根据角色筛选对应订单,整合到一个接口中 | ||||
|         var query = await _orderRepository.GetQueryableAsync(); | ||||
|         var orders = query.PageBy(input).OrderBy(o => o.Id).ToList(); | ||||
|  | ||||
|         var totalCount = await _orderRepository.CountAsync(); | ||||
|  | ||||
| @ -164,4 +131,8 @@ public class OrderAppService(IOrderRepository orderRepository) : ApplicationServ | ||||
|  | ||||
|         return new PagedResultDto<OrderDto>(totalCount, orderDtos); | ||||
|     } | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| } | ||||
		Reference in New Issue
	
	Block a user
	 于鹏
					于鹏