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