|
@@ -82,7 +82,7 @@ export class KycService extends BaseService {
|
|
throw new CoolCommException('Order does not exist');
|
|
throw new CoolCommException('Order does not exist');
|
|
}
|
|
}
|
|
const kyc = await this.kycEntity.findOneBy({ email: payload.customerEmail });
|
|
const kyc = await this.kycEntity.findOneBy({ email: payload.customerEmail });
|
|
- if(kyc) {
|
|
|
|
|
|
+ if (kyc) {
|
|
throw new CoolCommException('This email has already been used');
|
|
throw new CoolCommException('This email has already been used');
|
|
}
|
|
}
|
|
const { customerId } = await this.sunPayService.createBasic(payload);
|
|
const { customerId } = await this.sunPayService.createBasic(payload);
|
|
@@ -133,19 +133,19 @@ export class KycService extends BaseService {
|
|
data.payUrl = await this.validAndGetPayUrl(orderNo, data);
|
|
data.payUrl = await this.validAndGetPayUrl(orderNo, data);
|
|
return data;
|
|
return data;
|
|
}
|
|
}
|
|
- const dailyLevel = this.getAmountLevel(order.amount);
|
|
|
|
|
|
+ const dailyLevel = this.getAmountLevel(order.amount, order.currency);
|
|
if (dailyLevel === 3) {
|
|
if (dailyLevel === 3) {
|
|
data.levelEnd = dailyLevel;
|
|
data.levelEnd = dailyLevel;
|
|
data.payUrl = await this.validAndGetPayUrl(orderNo, data);
|
|
data.payUrl = await this.validAndGetPayUrl(orderNo, data);
|
|
return data;
|
|
return data;
|
|
}
|
|
}
|
|
- const weekly = await this.getWeekLyLevel(order);
|
|
|
|
|
|
+ const weekly = await this.getWeekLyLevel(order, order.currency);
|
|
if (weekly === 3) {
|
|
if (weekly === 3) {
|
|
data.levelEnd = dailyLevel;
|
|
data.levelEnd = dailyLevel;
|
|
data.payUrl = await this.validAndGetPayUrl(orderNo, data);
|
|
data.payUrl = await this.validAndGetPayUrl(orderNo, data);
|
|
return data;
|
|
return data;
|
|
}
|
|
}
|
|
- const monthly = await this.getMonthlyLevel(order);
|
|
|
|
|
|
+ const monthly = await this.getMonthlyLevel(order, order.currency);
|
|
data.levelEnd = Math.max(dailyLevel, weekly, monthly);
|
|
data.levelEnd = Math.max(dailyLevel, weekly, monthly);
|
|
data.payUrl = await this.validAndGetPayUrl(orderNo, data);
|
|
data.payUrl = await this.validAndGetPayUrl(orderNo, data);
|
|
return data;
|
|
return data;
|
|
@@ -166,32 +166,44 @@ export class KycService extends BaseService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- async getMonthlyLevel(order) {
|
|
|
|
|
|
+ async getMonthlyLevel(order, currency) {
|
|
const month = await this.orderService.getMonthlyAmount(order.mchId, order.userId, order.code);
|
|
const month = await this.orderService.getMonthlyAmount(order.mchId, order.userId, order.code);
|
|
let amount = 0;
|
|
let amount = 0;
|
|
if (month && month[0]) {
|
|
if (month && month[0]) {
|
|
amount = +month[0].total;
|
|
amount = +month[0].total;
|
|
}
|
|
}
|
|
- return this.getAmountLevel(amount + +order.amount);
|
|
|
|
|
|
+ return this.getAmountLevel(amount + +order.amount, currency);
|
|
}
|
|
}
|
|
|
|
|
|
- async getWeekLyLevel(order) {
|
|
|
|
|
|
+ async getWeekLyLevel(order, currency) {
|
|
const weekly = await this.orderService.getWeeklyAmount(order.mchId, order.userId, order.code);
|
|
const weekly = await this.orderService.getWeeklyAmount(order.mchId, order.userId, order.code);
|
|
let amount = 0;
|
|
let amount = 0;
|
|
if (weekly && weekly[0]) {
|
|
if (weekly && weekly[0]) {
|
|
amount = +weekly[0].total;
|
|
amount = +weekly[0].total;
|
|
}
|
|
}
|
|
- return this.getAmountLevel(amount + +order.amount);
|
|
|
|
|
|
+ return this.getAmountLevel(amount + +order.amount, currency);
|
|
}
|
|
}
|
|
|
|
|
|
- getAmountLevel(amount: number) {
|
|
|
|
- if (amount <= 1000) {
|
|
|
|
|
|
+ getAmountLevel(amount: number, currency) {
|
|
|
|
+ const eur = this.toEur(amount, currency)
|
|
|
|
+ console.log('-----------------------', eur)
|
|
|
|
+ if (eur <= 1000) {
|
|
return 1;
|
|
return 1;
|
|
- } else if (amount <= 5000) {
|
|
|
|
|
|
+ } else if (eur <= 5000) {
|
|
return 2;
|
|
return 2;
|
|
} else {
|
|
} else {
|
|
return 3;
|
|
return 3;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ toEur(amount, currency) {
|
|
|
|
+ switch (currency) {
|
|
|
|
+ case "USD": return +((+amount / 1.0439).toFixed(2))
|
|
|
|
+ case "AUD": return +((+amount / 1.6743).toFixed(2))
|
|
|
|
+ case "MYR": return +((+amount / 4.6608).toFixed(2))
|
|
|
|
+ case "JPY": return +((+amount / 164.69).toFixed(2))
|
|
|
|
+ default: return amount
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|