Skip to content

Commit

Permalink
FES-78-apply-new-cut-off-time-concept (#65)
Browse files Browse the repository at this point in the history
* update logic, entities and dtos 
Co-authored-by: NHT <[email protected]>
  • Loading branch information
nfesta2023 authored Mar 9, 2024
1 parent 715db0f commit 78b4f95
Show file tree
Hide file tree
Showing 24 changed files with 289 additions and 79 deletions.
3 changes: 2 additions & 1 deletion src/dto/food-detail.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ export class FoodDetailDTO {
review_number: number;
promotion: string;
packaging_info: PackagingInfo[];
cutoff_time: string;
cutoff_time_m: number;
ingredients: Ingredient[];
description: TextByLang[];
portion_customization: Option[];
taste_customization: Option[];
other_customizaton: BasicCustomization[];
reviews: Review[];
is_advanced_customizable: boolean;
}

class Ingredient {
Expand Down
2 changes: 1 addition & 1 deletion src/dto/food.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ export class FoodDTO {
price: number;
price_after_discount: number;
promotion: string;
cutoff_time: string;
preparing_time_s: number;
cooking_time_s: number;
quantity_available: number;
is_vegetarian: boolean;
cooking_schedule: string;
units_sold: number;
is_advanced_customizable: boolean;
}
3 changes: 2 additions & 1 deletion src/dto/restaurant-detail.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ export class RestaurantDetailDTO {
specialty: TextByLang[];
introduction: TextByLang[];
review_total_count: number;
cutoff_time: string[];
cutoff_time_m: number;
having_vegeterian_food: boolean;
unit: string;
menu: FoodDTO[];
distance_km: number;
delivery_time_s: number;
is_advanced_customizable: boolean;
}
2 changes: 1 addition & 1 deletion src/dto/restaurant.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ export class RestaurantDTO {
specialty: TextByLang[];
top_food: string;
promotion: string;
cutoff_time: string[];
having_vegeterian_food: boolean;
max_price: number;
min_price: number;
unit: string;
is_advanced_customizable: boolean;
}
19 changes: 19 additions & 0 deletions src/entity/manual-cutoff-time.entity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';

@Entity('Manual_Cutoff_Time')
export class ManualCutoffTime {
@PrimaryGeneratedColumn()
public manual_id: number;

@Column({ type: 'date', nullable: false, unique: false })
public date: Date;

@Column({ type: 'int', nullable: false, unique: false })
public cutoff_time_m: number;

@Column({ type: 'int', nullable: false, unique: false })
public restaurant_id: number;

@Column({ type: 'bigint', nullable: false, unique: false })
public logged_at: number;
}
2 changes: 0 additions & 2 deletions src/entity/menu-item-attribute-value.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ import {
Column,
ManyToOne,
JoinColumn,
OneToMany,
} from 'typeorm';
import { MenuItemAttribute } from './menu-item-attribute.entity';
import { Unit } from './unit.entity';
import { TasteValueExt } from './taste-value-ext.entity';
import { TasteValue } from './taste-value.entity';

@Entity('Menu_Item_Attribute_Value')
Expand Down
10 changes: 10 additions & 0 deletions src/entity/menu-item-attribute.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ import {
PrimaryGeneratedColumn,
Column,
OneToMany,
ManyToOne,
JoinColumn,
} from 'typeorm';
import { MenuItemAttributeExt } from './menu-item-attribute-ext.entity';
import { MenuItemAttributeValue } from './menu-item-attribute-value.entity';
import { TasteExt } from './taste-ext.entity';
import { MenuItem } from './menu-item.entity';

@Entity('Menu_Item_Attribute')
export class MenuItemAttribute {
Expand Down Expand Up @@ -40,4 +43,11 @@ export class MenuItemAttribute {

@OneToMany(() => TasteExt, (tasteExt) => tasteExt.taste)
public taste_ext: TasteExt[];

@ManyToOne(() => MenuItem, (menuItem) => menuItem.attribute_obj)
@JoinColumn({
name: 'menu_item_id',
referencedColumnName: 'menu_item_id',
})
public menu_item_obj: MenuItem;
}
11 changes: 6 additions & 5 deletions src/entity/menu-item.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { SKU } from './sku.entity';
import { Media } from './media.entity';
import { Recipe } from './recipe.entity';
import { MenuItemPackaging } from './menuitem-packaging.entity';
import { MenuItemAttribute } from './menu-item-attribute.entity';

@Entity('Menu_Item')
export class MenuItem {
Expand All @@ -28,8 +29,8 @@ export class MenuItem {
@Column({ type: 'int', nullable: true, unique: false })
public cooking_time_s: number;

@Column({ type: 'time', nullable: true, unique: false })
public cutoff_time: string;
// @Column({ type: 'time', nullable: true, unique: false })
// public cutoff_time: string;

@Column({ type: 'int', nullable: true, unique: false })
public quantity_available: number;
Expand Down Expand Up @@ -113,12 +114,12 @@ export class MenuItem {
@OneToMany(() => Recipe, (recipe) => recipe.menu_item)
public recipe: Promise<Recipe[]>;

// @OneToMany(() => Packaging, (packaging) => packaging.menu_item_obj)
// public packaging_obj: Packaging[];

@OneToMany(
() => MenuItemPackaging,
(menuItemPackaging) => menuItemPackaging.menu_item_obj,
)
public menuItemPackaging_obj: MenuItemPackaging[];

@OneToMany(() => MenuItemAttribute, (att) => att.menu_item_obj)
public attribute_obj: MenuItemAttribute[];
}
3 changes: 3 additions & 0 deletions src/entity/restaurant.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ export class Restaurant {
})
public utc_time_zone: number;

@Column({ type: 'int', nullable: false, unique: false, default: 0 })
public cutoff_time_m: number;

@CreateDateColumn({
type: 'datetime',
nullable: false,
Expand Down
12 changes: 6 additions & 6 deletions src/fake_data/hot-food.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@
"price": 95000,
"price_after_discount": 65000,
"promotion": "Ưu đãi đến 50k",
"cutoff_time": "09:00:00",
"preparing_time_s": 600,
"cooking_time_s": 1200,
"quantity_available": 5,
"is_vegetarian": false,
"cooking_schedule": "[{\"dayId\":1,\"dayName\":\"Sun\",\"from\":\"06:00:00\",\"to\":\"13:59:59\",\"isAvailable\":false},{\"dayId\":1,\"dayName\":\"Sun\",\"from\":\"14:00:00\",\"to\":\"21:59:59\",\"isAvailable\":false},{\"dayId\":1,\"dayName\":\"Sun\",\"from\":\"22:00:00\",\"to\":\"05:59:59\",\"isAvailable\":false},{\"dayId\":2,\"dayName\":\"Mon\",\"from\":\"06:00:00\",\"to\":\"13:59:59\",\"isAvailable\":true},{\"dayId\":2,\"dayName\":\"Mon\",\"from\":\"14:00:00\",\"to\":\"21:59:59\",\"isAvailable\":false},{\"dayId\":2,\"dayName\":\"Mon\",\"from\":\"22:00:00\",\"to\":\"05:59:59\",\"isAvailable\":false},{\"dayId\":3,\"dayName\":\"Tue\",\"from\":\"06:00:00\",\"to\":\"13:59:59\",\"isAvailable\":false},{\"dayId\":3,\"dayName\":\"Tue\",\"from\":\"14:00:00\",\"to\":\"21:59:59\",\"isAvailable\":false},{\"dayId\":3,\"dayName\":\"Tue\",\"from\":\"22:00:00\",\"to\":\"05:59:59\",\"isAvailable\":false},{\"dayId\":4,\"dayName\":\"Wed\",\"from\":\"06:00:00\",\"to\":\"13:59:59\",\"isAvailable\":false},{\"dayId\":4,\"dayName\":\"Wed\",\"from\":\"14:00:00\",\"to\":\"21:59:59\",\"isAvailable\":true},{\"dayId\":4,\"dayName\":\"Wed\",\"from\":\"22:00:00\",\"to\":\"05:59:59\",\"isAvailable\":false},{\"dayId\":5,\"dayName\":\"Thu\",\"from\":\"06:00:00\",\"to\":\"13:59:59\",\"isAvailable\":false},{\"dayId\":5,\"dayName\":\"Thu\",\"from\":\"14:00:00\",\"to\":\"21:59:59\",\"isAvailable\":false},{\"dayId\":5,\"dayName\":\"Thu\",\"from\":\"22:00:00\",\"to\":\"05:59:59\",\"isAvailable\":false},{\"dayId\":6,\"dayName\":\"Fri\",\"from\":\"06:00:00\",\"to\":\"13:59:59\",\"isAvailable\":true},{\"dayId\":6,\"dayName\":\"Fri\",\"from\":\"14:00:00\",\"to\":\"21:59:59\",\"isAvailable\":false},{\"dayId\":6,\"dayName\":\"Fri\",\"from\":\"22:00:00\",\"to\":\"05:59:59\",\"isAvailable\":false},{\"dayId\":7,\"dayName\":\"Sat\",\"from\":\"06:00:00\",\"to\":\"13:59:59\",\"isAvailable\":false},{\"dayId\":7,\"dayName\":\"Sat\",\"from\":\"14:00:00\",\"to\":\"21:59:59\",\"isAvailable\":false},{\"dayId\":7,\"dayName\":\"Sat\",\"from\":\"22:00:00\",\"to\":\"05:59:59\",\"isAvailable\":false}]",
"units_sold": 0
"units_sold": 0,
"is_advanced_customizable": false
},
{
"id": 1,
Expand Down Expand Up @@ -73,13 +73,13 @@
"price": 95000,
"price_after_discount": 65000,
"promotion": "Ưu đãi đến 50k",
"cutoff_time": "09:00:00",
"preparing_time_s": 600,
"cooking_time_s": 1200,
"quantity_available": 5,
"is_vegetarian": false,
"cooking_schedule": "[{\"dayId\":1,\"dayName\":\"Sun\",\"from\":\"06:00:00\",\"to\":\"13:59:59\",\"isAvailable\":false},{\"dayId\":1,\"dayName\":\"Sun\",\"from\":\"14:00:00\",\"to\":\"21:59:59\",\"isAvailable\":false},{\"dayId\":1,\"dayName\":\"Sun\",\"from\":\"22:00:00\",\"to\":\"05:59:59\",\"isAvailable\":false},{\"dayId\":2,\"dayName\":\"Mon\",\"from\":\"06:00:00\",\"to\":\"13:59:59\",\"isAvailable\":true},{\"dayId\":2,\"dayName\":\"Mon\",\"from\":\"14:00:00\",\"to\":\"21:59:59\",\"isAvailable\":false},{\"dayId\":2,\"dayName\":\"Mon\",\"from\":\"22:00:00\",\"to\":\"05:59:59\",\"isAvailable\":false},{\"dayId\":3,\"dayName\":\"Tue\",\"from\":\"06:00:00\",\"to\":\"13:59:59\",\"isAvailable\":false},{\"dayId\":3,\"dayName\":\"Tue\",\"from\":\"14:00:00\",\"to\":\"21:59:59\",\"isAvailable\":false},{\"dayId\":3,\"dayName\":\"Tue\",\"from\":\"22:00:00\",\"to\":\"05:59:59\",\"isAvailable\":false},{\"dayId\":4,\"dayName\":\"Wed\",\"from\":\"06:00:00\",\"to\":\"13:59:59\",\"isAvailable\":false},{\"dayId\":4,\"dayName\":\"Wed\",\"from\":\"14:00:00\",\"to\":\"21:59:59\",\"isAvailable\":true},{\"dayId\":4,\"dayName\":\"Wed\",\"from\":\"22:00:00\",\"to\":\"05:59:59\",\"isAvailable\":false},{\"dayId\":5,\"dayName\":\"Thu\",\"from\":\"06:00:00\",\"to\":\"13:59:59\",\"isAvailable\":false},{\"dayId\":5,\"dayName\":\"Thu\",\"from\":\"14:00:00\",\"to\":\"21:59:59\",\"isAvailable\":false},{\"dayId\":5,\"dayName\":\"Thu\",\"from\":\"22:00:00\",\"to\":\"05:59:59\",\"isAvailable\":false},{\"dayId\":6,\"dayName\":\"Fri\",\"from\":\"06:00:00\",\"to\":\"13:59:59\",\"isAvailable\":true},{\"dayId\":6,\"dayName\":\"Fri\",\"from\":\"14:00:00\",\"to\":\"21:59:59\",\"isAvailable\":false},{\"dayId\":6,\"dayName\":\"Fri\",\"from\":\"22:00:00\",\"to\":\"05:59:59\",\"isAvailable\":false},{\"dayId\":7,\"dayName\":\"Sat\",\"from\":\"06:00:00\",\"to\":\"13:59:59\",\"isAvailable\":false},{\"dayId\":7,\"dayName\":\"Sat\",\"from\":\"14:00:00\",\"to\":\"21:59:59\",\"isAvailable\":false},{\"dayId\":7,\"dayName\":\"Sat\",\"from\":\"22:00:00\",\"to\":\"05:59:59\",\"isAvailable\":false}]",
"units_sold": 0
"units_sold": 0,
"is_advanced_customizable": true
},
{
"id": 1,
Expand Down Expand Up @@ -114,12 +114,12 @@
"price": 95000,
"price_after_discount": 65000,
"promotion": "Ưu đãi đến 50k",
"cutoff_time": "09:00:00",
"preparing_time_s": 600,
"cooking_time_s": 1200,
"quantity_available": 5,
"is_vegetarian": false,
"cooking_schedule": "[{\"dayId\":1,\"dayName\":\"Sun\",\"from\":\"06:00:00\",\"to\":\"13:59:59\",\"isAvailable\":false},{\"dayId\":1,\"dayName\":\"Sun\",\"from\":\"14:00:00\",\"to\":\"21:59:59\",\"isAvailable\":false},{\"dayId\":1,\"dayName\":\"Sun\",\"from\":\"22:00:00\",\"to\":\"05:59:59\",\"isAvailable\":false},{\"dayId\":2,\"dayName\":\"Mon\",\"from\":\"06:00:00\",\"to\":\"13:59:59\",\"isAvailable\":true},{\"dayId\":2,\"dayName\":\"Mon\",\"from\":\"14:00:00\",\"to\":\"21:59:59\",\"isAvailable\":false},{\"dayId\":2,\"dayName\":\"Mon\",\"from\":\"22:00:00\",\"to\":\"05:59:59\",\"isAvailable\":false},{\"dayId\":3,\"dayName\":\"Tue\",\"from\":\"06:00:00\",\"to\":\"13:59:59\",\"isAvailable\":false},{\"dayId\":3,\"dayName\":\"Tue\",\"from\":\"14:00:00\",\"to\":\"21:59:59\",\"isAvailable\":false},{\"dayId\":3,\"dayName\":\"Tue\",\"from\":\"22:00:00\",\"to\":\"05:59:59\",\"isAvailable\":false},{\"dayId\":4,\"dayName\":\"Wed\",\"from\":\"06:00:00\",\"to\":\"13:59:59\",\"isAvailable\":false},{\"dayId\":4,\"dayName\":\"Wed\",\"from\":\"14:00:00\",\"to\":\"21:59:59\",\"isAvailable\":true},{\"dayId\":4,\"dayName\":\"Wed\",\"from\":\"22:00:00\",\"to\":\"05:59:59\",\"isAvailable\":false},{\"dayId\":5,\"dayName\":\"Thu\",\"from\":\"06:00:00\",\"to\":\"13:59:59\",\"isAvailable\":false},{\"dayId\":5,\"dayName\":\"Thu\",\"from\":\"14:00:00\",\"to\":\"21:59:59\",\"isAvailable\":false},{\"dayId\":5,\"dayName\":\"Thu\",\"from\":\"22:00:00\",\"to\":\"05:59:59\",\"isAvailable\":false},{\"dayId\":6,\"dayName\":\"Fri\",\"from\":\"06:00:00\",\"to\":\"13:59:59\",\"isAvailable\":true},{\"dayId\":6,\"dayName\":\"Fri\",\"from\":\"14:00:00\",\"to\":\"21:59:59\",\"isAvailable\":false},{\"dayId\":6,\"dayName\":\"Fri\",\"from\":\"22:00:00\",\"to\":\"05:59:59\",\"isAvailable\":false},{\"dayId\":7,\"dayName\":\"Sat\",\"from\":\"06:00:00\",\"to\":\"13:59:59\",\"isAvailable\":false},{\"dayId\":7,\"dayName\":\"Sat\",\"from\":\"14:00:00\",\"to\":\"21:59:59\",\"isAvailable\":false},{\"dayId\":7,\"dayName\":\"Sat\",\"from\":\"22:00:00\",\"to\":\"05:59:59\",\"isAvailable\":false}]",
"units_sold": 0
"units_sold": 0,
"is_advanced_customizable": true
}
]
10 changes: 9 additions & 1 deletion src/feature/cart/cart.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,14 @@ export class CartController {
data: GetAvailableDeliveryTimeRequest,
): Promise<GetAvailableDeliveryTimeResponse> {
const res = new GetAvailableDeliveryTimeResponse(200, '');
const { menu_item_ids, now, long, lat, utc_offset } = data;
const {
menu_item_ids,
now,
long,
lat,
utc_offset,
having_advanced_customization,
} = data;

try {
const timeSlots: TimeSlot[] =
Expand All @@ -319,6 +326,7 @@ export class CartController {
long,
lat,
utc_offset,
having_advanced_customization,
);
if (timeSlots.length > 0) {
res.statusCode = 200;
Expand Down
Loading

0 comments on commit 78b4f95

Please sign in to comment.