Skip to content

Commit

Permalink
add payment info to order history by restaurant (#100)
Browse files Browse the repository at this point in the history
Co-authored-by: NHT <[email protected]>
  • Loading branch information
nfesta2023 and hoangtuan910 authored Apr 1, 2024
1 parent 76b4f9e commit 750a60f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export interface HistoricalOrderByRestaurant {
order_items: OrderItem[];
order_total: number;
order_score: number;
payment_method: Payment;
}

interface OrderStatusLog {
Expand Down Expand Up @@ -53,3 +54,7 @@ interface OptionSelection {
interface BasicTasteSelection {
no_adding_id: string;
}
interface Payment {
id: number;
name: string;
}
12 changes: 11 additions & 1 deletion src/feature/order/order.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2110,7 +2110,13 @@ export class OrderService {
await this.getFoodRatingsWithOrderSkuIds(
orderItems.map((i) => i.order_sku_id),
);
this.logger.log(foodRatings);

//Get invoice
const invoice = await this.entityManager
.createQueryBuilder(Invoice, 'invoice')
.leftJoinAndSelect('invoice.payment_option_obj', 'paymentOption')
.where('invoice.order_id = :order_id', { order_id: order.order_id })
.getOne();

//Build output
const historicalOrderInfo: HistoricalOrderByRestaurant = {
Expand All @@ -2123,6 +2129,10 @@ export class OrderService {
foodRatings
.map((i) => i.score)
.reduce((sum, val) => (sum += val), 0) / foodRatings.length,
payment_method: {
id: invoice?.payment_option_obj.option_id,
name: invoice?.payment_option_obj.name,
},
};

order.order_status_log.forEach((log) => {
Expand Down

0 comments on commit 750a60f

Please sign in to comment.