Skip to content

Commit

Permalink
feature:EF-189 update count order analytics (#74)
Browse files Browse the repository at this point in the history
  • Loading branch information
MinhhTien authored Mar 10, 2024
1 parent 084d75d commit 01285f3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
7 changes: 6 additions & 1 deletion src/analytic/services/analytic.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ export class AnalyticService {
$in: [OrderStatus.PENDING, OrderStatus.CONFIRMED, OrderStatus.DELIVERING, OrderStatus.COMPLETED]
},
transactionStatus: {
$in: [TransactionStatus.CAPTURED, TransactionStatus.DRAFT, TransactionStatus.ERROR]
$in: [
TransactionStatus.CAPTURED,
TransactionStatus.ERROR,
TransactionStatus.CANCELED,
TransactionStatus.REFUNDED
]
}
}
const [total, previousTotal] = await Promise.all([
Expand Down
18 changes: 14 additions & 4 deletions src/order/services/order.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@ export class OrderService {
{
...filter,
transactionStatus: {
$ne: TransactionStatus.DRAFT
$in: [
TransactionStatus.CAPTURED,
TransactionStatus.ERROR,
TransactionStatus.CANCELED,
TransactionStatus.REFUNDED
]
},
status: {
$ne: OrderStatus.DELETED
Expand All @@ -53,7 +58,12 @@ export class OrderService {
conditions: {
...filter,
transactionStatus: {
$ne: TransactionStatus.DRAFT
$in: [
TransactionStatus.CAPTURED,
TransactionStatus.ERROR,
TransactionStatus.CANCELED,
TransactionStatus.REFUNDED
]
},
status: {
$ne: OrderStatus.DELETED
Expand Down Expand Up @@ -285,8 +295,8 @@ export class OrderService {
const order = await this.orderRepository.findOneAndUpdate(
{
_id: orderId,
orderStatus: OrderStatus.DELIVERING
// transactionStatus: TransactionStatus.CAPTURED
orderStatus: OrderStatus.DELIVERING,
transactionStatus: TransactionStatus.CAPTURED
},
{
$set: { orderStatus: OrderStatus.COMPLETED, completeDate: new Date() },
Expand Down

0 comments on commit 01285f3

Please sign in to comment.