|
|
@ -1,8 +1,8 @@ |
|
|
using System; |
|
|
using EShopOnAbp.PaymentService.PaymentRequests; |
|
|
|
|
|
using JetBrains.Annotations; |
|
|
|
|
|
using System; |
|
|
using System.Collections.Generic; |
|
|
using System.Collections.Generic; |
|
|
using System.Linq; |
|
|
using System.Linq; |
|
|
using EShopOnAbp.PaymentService.PaymentRequests; |
|
|
|
|
|
using JetBrains.Annotations; |
|
|
|
|
|
using Volo.Abp; |
|
|
using Volo.Abp; |
|
|
using Volo.Abp.Domain.Entities; |
|
|
using Volo.Abp.Domain.Entities; |
|
|
|
|
|
|
|
|
@ -25,7 +25,7 @@ public class Order : AggregateRoot<Guid> |
|
|
{ |
|
|
{ |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
internal Order(Guid id, Buyer buyer, Address address, [NotNull]string paymentMethod, Guid? paymentRequestId = null) : base(id) |
|
|
internal Order(Guid id, Buyer buyer, Address address, [NotNull] string paymentMethod, Guid? paymentRequestId = null) : base(id) |
|
|
{ |
|
|
{ |
|
|
_orderStatusId = OrderStatus.Placed.Id; |
|
|
_orderStatusId = OrderStatus.Placed.Id; |
|
|
OrderDate = DateTime.UtcNow; |
|
|
OrderDate = DateTime.UtcNow; |
|
|
@ -33,7 +33,7 @@ public class Order : AggregateRoot<Guid> |
|
|
Buyer = buyer; |
|
|
Buyer = buyer; |
|
|
Address = address; |
|
|
Address = address; |
|
|
PaymentRequestId = paymentRequestId; |
|
|
PaymentRequestId = paymentRequestId; |
|
|
PaymentMethod = Check.NotNullOrEmpty(paymentMethod,nameof(paymentMethod),maxLength:OrderConstants.OrderPaymentMethodNameMaxLength); |
|
|
PaymentMethod = Check.NotNullOrEmpty(paymentMethod, nameof(paymentMethod), maxLength: OrderConstants.OrderPaymentMethodNameMaxLength); |
|
|
PaymentStatus = PaymentRequestState.Waiting.ToString(); // From PaymentService.Domain.Shared
|
|
|
PaymentStatus = PaymentRequestState.Waiting.ToString(); // From PaymentService.Domain.Shared
|
|
|
OrderItems = new List<OrderItem>(); |
|
|
OrderItems = new List<OrderItem>(); |
|
|
} |
|
|
} |
|
|
@ -87,4 +87,15 @@ public class Order : AggregateRoot<Guid> |
|
|
{ |
|
|
{ |
|
|
return OrderItems.Sum(o => o.Units * o.UnitPrice); |
|
|
return OrderItems.Sum(o => o.Units * o.UnitPrice); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public Order SetOrder(int orderStatus) |
|
|
|
|
|
{ |
|
|
|
|
|
if (orderStatus == OrderStatus.Cancelled.Id) |
|
|
|
|
|
{ |
|
|
|
|
|
return this; |
|
|
|
|
|
} |
|
|
|
|
|
//TODO no enough to update the object.
|
|
|
|
|
|
_orderStatusId = orderStatus; |
|
|
|
|
|
return this; |
|
|
|
|
|
} |
|
|
} |
|
|
} |