add: Order
This commit is contained in:
		| @ -1,4 +1,6 @@ | ||||
| using AutoMapper; | ||||
| using KonSoft.Admin.Dtos; | ||||
| using KonSoft.Admin.Entities; | ||||
|  | ||||
| namespace KonSoft.Admin; | ||||
|  | ||||
| @ -9,5 +11,9 @@ public class AdminApplicationAutoMapperProfile : Profile | ||||
|         /* You can configure your AutoMapper mapping configuration here. | ||||
|          * Alternatively, you can split your mapping configurations | ||||
|          * into multiple profile classes for a better organization. */ | ||||
|  | ||||
|         CreateMap<Order, OrderDto>(); | ||||
|         //CreateMap<CreateOrderDto, Order>(); | ||||
|         CreateMap<AddressDto, AddressInfo>(); | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -0,0 +1,115 @@ | ||||
| using KonSoft.Admin.Dtos; | ||||
| using KonSoft.Admin.Entities; | ||||
| using KonSoft.Admin.IApplicationServices; | ||||
| using KonSoft.Admin.Repositories; | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.Linq; | ||||
| using System.Text; | ||||
| using System.Threading.Tasks; | ||||
| using Volo.Abp.Application.Services; | ||||
| using Volo.Abp.ObjectMapping; | ||||
|  | ||||
| namespace KonSoft.Admin.ApplicationServices | ||||
| { | ||||
|     public class OrderAppService : ApplicationService, IOrderAppService | ||||
|     { | ||||
|         private readonly IOrderRepository _orderRepository; | ||||
|  | ||||
|         public OrderAppService(IOrderRepository orderRepository) | ||||
|         { | ||||
|             _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> | ||||
|         /// 取消订单 | ||||
|         /// </summary> | ||||
|         /// <param name="orderId"></param> | ||||
|         /// <param name="reason"></param> | ||||
|         /// <returns></returns> | ||||
|         /// <exception cref="NotImplementedException"></exception> | ||||
|         public async Task CancelAsync(Guid orderId, string reason) | ||||
|         { | ||||
|             var order = await _orderRepository.GetAsync(o => o.Id == orderId); | ||||
|             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> | ||||
|         /// 创建订单 | ||||
|         /// </summary> | ||||
|         /// <param name="input"></param> | ||||
|         /// <returns></returns> | ||||
|         /// <exception cref="NotImplementedException"></exception> | ||||
|         public async Task<OrderDto> CreateAsync(CreateOrderDto input) | ||||
|         { | ||||
|             // 生成订单号 TODO | ||||
|             var orderSN = "SN001"; | ||||
|             var address = ObjectMapper.Map<AddressDto, AddressInfo>(input.Address); | ||||
|             var order = new Order(Guid.NewGuid(), orderSN, input.CustomerId, input.ServiceId, input.ServiceTime, input.Amount, address, input.Remark); | ||||
|  | ||||
|             await _orderRepository.InsertAsync(order); | ||||
|             return ObjectMapper.Map<Order, OrderDto>(order); | ||||
|         } | ||||
|         /// <summary> | ||||
|         /// 支付 | ||||
|         /// </summary> | ||||
|         /// <param name="orderId"></param> | ||||
|         /// <param name="input"></param> | ||||
|         /// <returns></returns> | ||||
|         /// <exception cref="NotImplementedException"></exception> | ||||
|         public Task<OrderDto> PayAsync(Guid orderId, PayOrderDto input) | ||||
|         { | ||||
|             throw new NotImplementedException(); | ||||
|         } | ||||
|         /// <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(); | ||||
|         } | ||||
|  | ||||
|         public async Task<OrderDto> GetAsync(Guid id) | ||||
|         { | ||||
|             var order = await _orderRepository.GetAsync(o => o.Id == id); | ||||
|             return ObjectMapper.Map<Order, OrderDto>(order); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @ -6,8 +6,8 @@ | ||||
|     <RootNamespace>KonSoft.Admin</RootNamespace> | ||||
|   </PropertyGroup> | ||||
|   <ItemGroup> | ||||
|     <ProjectReference Include="..\KonSoft.Admin.Domain\KonSoft.Admin.Domain.csproj"/> | ||||
|     <ProjectReference Include="..\KonSoft.Admin.Application.Contracts\KonSoft.Admin.Application.Contracts.csproj"/> | ||||
|     <ProjectReference Include="..\KonSoft.Admin.Domain\KonSoft.Admin.Domain.csproj" /> | ||||
|     <ProjectReference Include="..\KonSoft.Admin.Application.Contracts\KonSoft.Admin.Application.Contracts.csproj" /> | ||||
|   </ItemGroup> | ||||
|   <ItemGroup> | ||||
|     <PackageReference Include="Volo.Abp.Account.Application" Version="8.3.4" /> | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 于鹏
					于鹏