@@ -310,15 +310,7 @@ class CartRepository extends BaseRepository<ICart> {
|
||||
},
|
||||
total_discount: {
|
||||
$sum: {
|
||||
$add: [
|
||||
{
|
||||
$subtract: [
|
||||
{ $multiply: ["$items.quantity", "$variantDetails.price.retailPrice"] },
|
||||
{ $multiply: ["$items.quantity", "$variantDetails.price.selling_price"] },
|
||||
],
|
||||
},
|
||||
{ $divide: ["$coupon_discount", { $literal: 1 }] }, // safely adds coupon_discount
|
||||
],
|
||||
$multiply: ["$items.quantity", { $subtract: ["$variantDetails.price.retailPrice", "$variantDetails.price.selling_price"] }],
|
||||
},
|
||||
},
|
||||
coupon_discount: { $first: "$coupon_discount" },
|
||||
@@ -339,7 +331,9 @@ class CartRepository extends BaseRepository<ICart> {
|
||||
items_count: 1,
|
||||
payable_price: { $subtract: ["$payable_price", { $ifNull: ["$coupon_discount", 0] }] },
|
||||
retail_price: 1,
|
||||
total_discount: 1,
|
||||
total_discount: {
|
||||
$add: ["$total_discount", { $ifNull: ["$coupon_discount", 0] }],
|
||||
},
|
||||
coupon_discount: 1,
|
||||
items: 1,
|
||||
isWholeSale: 1,
|
||||
|
||||
@@ -282,6 +282,9 @@ export class ReturnOrderRepo extends BaseRepository<IReturnOrder> {
|
||||
createdAt: { $first: "$createdAt" },
|
||||
updatedAt: { $first: "$updatedAt" },
|
||||
returnOrderItems: { $push: "$returnOrderItems" },
|
||||
refundReceipt: { $first: "$refundReceipt" },
|
||||
refundComment: { $first: "$refundComment" },
|
||||
refundDate: { $first: "$refundDate" },
|
||||
},
|
||||
},
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user