coupon bug
This commit is contained in:
@@ -81,6 +81,8 @@ export class CouponController {
|
||||
return this.couponService.remove(id);
|
||||
}
|
||||
|
||||
@UseGuards(AdminAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
@Get('admin/coupons/generate-code')
|
||||
@ApiOperation({ summary: 'generate a coupon code' })
|
||||
generateCouponCode(@RestId() restId: string) {
|
||||
|
||||
@@ -1,7 +1,17 @@
|
||||
import { IsNotEmpty, IsString, IsEnum, IsNumber, IsOptional, IsBoolean, IsDateString, Min, IsArray } from 'class-validator';
|
||||
import {
|
||||
IsNotEmpty,
|
||||
IsString,
|
||||
IsEnum,
|
||||
IsNumber,
|
||||
IsOptional,
|
||||
IsBoolean,
|
||||
IsDateString,
|
||||
Min,
|
||||
IsArray,
|
||||
} from 'class-validator';
|
||||
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
||||
import { Type } from 'class-transformer';
|
||||
import { CouponType } from '../entities/coupon.entity';
|
||||
import { CouponType } from '../interface/coupon';
|
||||
|
||||
export class CreateCouponDto {
|
||||
@IsNotEmpty()
|
||||
@@ -78,29 +88,28 @@ export class CreateCouponDto {
|
||||
@IsOptional()
|
||||
@IsArray()
|
||||
@IsString({ each: true })
|
||||
@ApiPropertyOptional({
|
||||
example: ['category-id-1', 'category-id-2'],
|
||||
@ApiPropertyOptional({
|
||||
example: ['category-id-1', 'category-id-2'],
|
||||
description: 'Array of food category IDs. If empty, coupon applies to all categories.',
|
||||
type: [String]
|
||||
type: [String],
|
||||
})
|
||||
foodCategories?: string[];
|
||||
|
||||
@IsOptional()
|
||||
@IsArray()
|
||||
@IsString({ each: true })
|
||||
@ApiPropertyOptional({
|
||||
example: ['food-id-1', 'food-id-2'],
|
||||
@ApiPropertyOptional({
|
||||
example: ['food-id-1', 'food-id-2'],
|
||||
description: 'Array of food IDs. If empty, coupon applies to all foods.',
|
||||
type: [String]
|
||||
type: [String],
|
||||
})
|
||||
foods?: string[];
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@ApiPropertyOptional({
|
||||
example: '09123456789',
|
||||
@ApiPropertyOptional({
|
||||
example: '09123456789',
|
||||
description: 'Phone number of the user who can use this coupon. If empty, coupon can be used by any user.',
|
||||
})
|
||||
userPhone?: string;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { IsOptional, IsString, IsBoolean, IsNumber, IsEnum } from 'class-validator';
|
||||
import { ApiPropertyOptional } from '@nestjs/swagger';
|
||||
import { Type } from 'class-transformer';
|
||||
import { CouponType } from '../entities/coupon.entity';
|
||||
import { CouponType } from '../interface/coupon';
|
||||
|
||||
export class FindCouponsDto {
|
||||
@IsOptional()
|
||||
|
||||
@@ -2,11 +2,7 @@ import { Entity, ManyToOne, Property, Enum, Unique } from '@mikro-orm/core';
|
||||
import { BaseEntity } from '../../../common/entities/base.entity';
|
||||
import { Restaurant } from '../../restaurants/entities/restaurant.entity';
|
||||
import { normalizePhone } from '../../utils/phone.util';
|
||||
|
||||
export enum CouponType {
|
||||
PERCENTAGE = 'PERCENTAGE',
|
||||
FIXED = 'FIXED',
|
||||
}
|
||||
import { CouponType } from '../interface/coupon';
|
||||
|
||||
@Entity({ tableName: 'coupons' })
|
||||
@Unique({ properties: ['code', 'restaurant'] })
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
export enum CouponType {
|
||||
PERCENTAGE = 'PERCENTAGE',
|
||||
FIXED = 'FIXED',
|
||||
}
|
||||
@@ -6,7 +6,8 @@ import { CouponRepository } from '../repositories/coupon.repository';
|
||||
import { RestRepository } from '../../restaurants/repositories/rest.repository';
|
||||
import { EntityManager } from '@mikro-orm/postgresql';
|
||||
import { RequiredEntityData } from '@mikro-orm/core';
|
||||
import { Coupon, CouponType } from '../entities/coupon.entity';
|
||||
import { Coupon } from '../entities/coupon.entity';
|
||||
import { CouponType } from '../interface/coupon';
|
||||
import { CouponMessage, RestMessage } from 'src/common/enums/message.enum';
|
||||
import { randomBytes } from 'node:crypto';
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { EntityManager, EntityRepository } from '@mikro-orm/postgresql';
|
||||
import { FilterQuery } from '@mikro-orm/core';
|
||||
import { Coupon, CouponType } from '../entities/coupon.entity';
|
||||
import { Coupon } from '../entities/coupon.entity';
|
||||
import { CouponType } from '../interface/coupon';
|
||||
import { PaginatedResult } from 'src/common/interfaces/pagination.interface';
|
||||
|
||||
type FindCouponsOpts = {
|
||||
|
||||
Reference in New Issue
Block a user