bug
This commit is contained in:
@@ -17,7 +17,7 @@ export class CouponService {
|
|||||||
private readonly couponRepository: CouponRepository,
|
private readonly couponRepository: CouponRepository,
|
||||||
private readonly restRepository: RestRepository,
|
private readonly restRepository: RestRepository,
|
||||||
private readonly em: EntityManager,
|
private readonly em: EntityManager,
|
||||||
) {}
|
) { }
|
||||||
|
|
||||||
async create(restId: string, createCouponDto: CreateCouponDto): Promise<Coupon> {
|
async create(restId: string, createCouponDto: CreateCouponDto): Promise<Coupon> {
|
||||||
const restaurant = await this.restRepository.findOne({ id: restId });
|
const restaurant = await this.restRepository.findOne({ id: restId });
|
||||||
@@ -257,7 +257,7 @@ export class CouponService {
|
|||||||
return prefix + '-' + result;
|
return prefix + '-' + result;
|
||||||
}
|
}
|
||||||
|
|
||||||
async generateCouponCode(restId: string){
|
async generateCouponCode(restId: string): Promise<{ code: string }> {
|
||||||
const restaurant = await this.restRepository.findOne({ id: restId });
|
const restaurant = await this.restRepository.findOne({ id: restId });
|
||||||
if (!restaurant) {
|
if (!restaurant) {
|
||||||
throw new NotFoundException(RestMessage.NOT_FOUND);
|
throw new NotFoundException(RestMessage.NOT_FOUND);
|
||||||
@@ -266,6 +266,6 @@ export class CouponService {
|
|||||||
const existing = await this.couponRepository.findOne({ code, restaurant: { id: restId } });
|
const existing = await this.couponRepository.findOne({ code, restaurant: { id: restId } });
|
||||||
|
|
||||||
if (existing) return this.generateCouponCode(restId);
|
if (existing) return this.generateCouponCode(restId);
|
||||||
return {code};
|
return { code };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user