-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
10 changed files
with
395 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
import { CouponCreatorType, CouponFilterType, CouponType } from 'src/enum'; | ||
import { | ||
Column, | ||
Entity, | ||
PrimaryGeneratedColumn, | ||
CreateDateColumn, | ||
OneToMany, | ||
} from 'typeorm'; | ||
import { Restaurant_Coupon } from './restaurant-coupon.entity'; | ||
import { SkusCoupon } from './skus-coupon.entity'; | ||
import { SysCategoryCoupon } from './sys-category-coupon.entity'; | ||
|
||
@Entity('Coupon') | ||
export class Coupon { | ||
@PrimaryGeneratedColumn() | ||
public coupon_id: number; | ||
|
||
@Column({ type: 'varchar', length: 255, nullable: false, unique: false }) | ||
public name: string; | ||
|
||
@Column({ type: 'text', nullable: true, unique: false }) | ||
public description: string; | ||
|
||
@Column({ | ||
type: 'enum', | ||
enum: CouponCreatorType, | ||
nullable: false, | ||
unique: false, | ||
}) | ||
public creator_type: CouponCreatorType; | ||
|
||
@Column({ type: 'int', nullable: false, unique: false }) | ||
public creator_id: number; | ||
|
||
@Column({ type: 'varchar', length: 10, nullable: false, unique: false }) | ||
public coupon_code: string; | ||
|
||
@Column({ type: 'int', nullable: false, unique: false }) | ||
public discount_value: number; | ||
|
||
@Column({ type: 'int', nullable: false, unique: false }) | ||
public discount_unit: number; | ||
|
||
@Column({ type: 'tinyint', nullable: false, unique: false }) | ||
public is_active: number; | ||
|
||
@Column({ type: 'bigint', nullable: false, unique: false }) | ||
public valid_from: number; | ||
|
||
@Column({ type: 'bigint', nullable: false, unique: false }) | ||
public valid_until: number; | ||
|
||
@Column({ type: 'int', nullable: true, unique: false }) | ||
public budget: number; | ||
|
||
@Column({ type: 'int', nullable: true, unique: false }) | ||
public mininum_order_value: number; | ||
|
||
@Column({ type: 'int', nullable: true, unique: false }) | ||
public maximum_discount_amount: number; | ||
|
||
@Column({ type: 'tinyint', nullable: false, unique: false }) | ||
public platform_sponsor_ratio_percentage: number; | ||
|
||
@Column({ type: 'bigint', nullable: true, unique: false }) | ||
public out_of_budget: number; | ||
|
||
@Column({ | ||
type: 'enum', | ||
enum: CouponType, | ||
nullable: false, | ||
unique: false, | ||
}) | ||
public coupon_type: CouponType; | ||
|
||
@Column({ | ||
type: 'enum', | ||
enum: CouponFilterType, | ||
nullable: false, | ||
unique: false, | ||
}) | ||
public filter_type: CouponFilterType; | ||
|
||
@CreateDateColumn({ | ||
type: 'datetime', | ||
nullable: false, | ||
unique: false, | ||
default: () => 'CURRENT_TIMESTAMP', | ||
}) | ||
public created_at: Date; | ||
|
||
//Relationship | ||
|
||
@OneToMany(() => Restaurant_Coupon, (resCoup) => resCoup.coupon_obj) | ||
public restaurant_coupon_obj: Restaurant_Coupon[]; | ||
|
||
@OneToMany(() => SkusCoupon, (coup) => coup.coupon_obj) | ||
public skus_coupon_obj: SkusCoupon[]; | ||
|
||
@OneToMany(() => SysCategoryCoupon, (coup) => coup.coupon_obj) | ||
public sys_cat_coupon_obj: SysCategoryCoupon[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { | ||
Entity, | ||
PrimaryColumn, | ||
CreateDateColumn, | ||
ManyToOne, | ||
JoinColumn, | ||
} from 'typeorm'; | ||
import { Coupon } from './coupon.entity'; | ||
|
||
@Entity('Restaurant_Coupon') | ||
export class Restaurant_Coupon { | ||
@PrimaryColumn() | ||
public coupon_id: number; | ||
@PrimaryColumn() | ||
public restaurant_id: number; | ||
@CreateDateColumn({ | ||
type: 'datetime', | ||
nullable: false, | ||
unique: false, | ||
default: () => 'CURRENT_TIMESTAMP', | ||
}) | ||
public created_at: Date; | ||
|
||
//Relationship | ||
@ManyToOne(() => Coupon, (coupon) => coupon.restaurant_coupon_obj) | ||
@JoinColumn({ | ||
name: 'coupon_id', | ||
referencedColumnName: 'coupon_id', | ||
}) | ||
public coupon_obj: Coupon; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { | ||
Entity, | ||
PrimaryColumn, | ||
CreateDateColumn, | ||
ManyToOne, | ||
JoinColumn, | ||
} from 'typeorm'; | ||
import { Coupon } from './coupon.entity'; | ||
|
||
@Entity('SKUs_coupon') | ||
export class SkusCoupon { | ||
@PrimaryColumn() | ||
public coupon_id: number; | ||
@PrimaryColumn() | ||
public sku_id: number; | ||
@CreateDateColumn({ | ||
type: 'datetime', | ||
nullable: false, | ||
unique: false, | ||
default: () => 'CURRENT_TIMESTAMP', | ||
}) | ||
public created_at: Date; | ||
|
||
//Relationship | ||
@ManyToOne(() => Coupon, (coupon) => coupon.skus_coupon_obj) | ||
@JoinColumn({ | ||
name: 'coupon_id', | ||
referencedColumnName: 'coupon_id', | ||
}) | ||
public coupon_obj: Coupon; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { | ||
Entity, | ||
PrimaryColumn, | ||
CreateDateColumn, | ||
ManyToOne, | ||
JoinColumn, | ||
} from 'typeorm'; | ||
import { Coupon } from './coupon.entity'; | ||
|
||
@Entity('Sys_Category_Coupon') | ||
export class SysCategoryCoupon { | ||
@PrimaryColumn() | ||
public coupon_id: number; | ||
@PrimaryColumn() | ||
public sys_category_id: number; | ||
@CreateDateColumn({ | ||
type: 'datetime', | ||
nullable: false, | ||
unique: false, | ||
default: () => 'CURRENT_TIMESTAMP', | ||
}) | ||
public created_at: Date; | ||
|
||
//Relationship | ||
@ManyToOne(() => Coupon, (coupon) => coupon.sys_cat_coupon_obj) | ||
@JoinColumn({ | ||
name: 'coupon_id', | ||
referencedColumnName: 'coupon_id', | ||
}) | ||
public coupon_obj: Coupon; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export class GetCouponInfoRequest { | ||
restaurant_id: number; //Required | ||
sku_ids: number[]; //Required | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export class GetCouponInfoResponse { | ||
coupons: CouponInfo[]; | ||
} | ||
|
||
interface CouponInfo { | ||
coupon_code: string; | ||
name: string; | ||
description: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.