|
@@ -1,5 +1,5 @@
|
|
import { Inject, Provide } from '@midwayjs/decorator';
|
|
import { Inject, Provide } from '@midwayjs/decorator';
|
|
-import { BaseService } from '@cool-midway/core';
|
|
|
|
|
|
+import { BaseService, CoolCommException } from '@cool-midway/core';
|
|
import { InjectEntityModel } from '@midwayjs/typeorm';
|
|
import { InjectEntityModel } from '@midwayjs/typeorm';
|
|
import { Repository } from 'typeorm';
|
|
import { Repository } from 'typeorm';
|
|
import { RateEntity } from '../entity/rate';
|
|
import { RateEntity } from '../entity/rate';
|
|
@@ -38,7 +38,6 @@ export class RateService extends BaseService {
|
|
});
|
|
});
|
|
}
|
|
}
|
|
async addRate(params) {
|
|
async addRate(params) {
|
|
- /* { merchantId: 'testd', channelId: 'SUNPAY', currency: 'EUR', DEPOSIT_rate: 2, DEPOSIT_method: 66, WITHDRAWAL_rate: 3, WITHDRAWAL_method: 67, status: 1, remark: '启用' } */
|
|
|
|
const commonParams = {
|
|
const commonParams = {
|
|
merchantId: params.merchantId,
|
|
merchantId: params.merchantId,
|
|
channelId: params.channelId,
|
|
channelId: params.channelId,
|
|
@@ -46,6 +45,17 @@ export class RateService extends BaseService {
|
|
status: params.status,
|
|
status: params.status,
|
|
remark: params.remark
|
|
remark: params.remark
|
|
}
|
|
}
|
|
|
|
+ // 查找
|
|
|
|
+ let rateList = await this.rateEntity.find({
|
|
|
|
+ where: {
|
|
|
|
+ currency: params.currency,
|
|
|
|
+ channelId: params.channelId,
|
|
|
|
+ merchantId: params.merchantId,
|
|
|
|
+ },
|
|
|
|
+ });
|
|
|
|
+ if(rateList.length) {
|
|
|
|
+ throw new CoolCommException('当前币种已设置费率');
|
|
|
|
+ }
|
|
// 入金
|
|
// 入金
|
|
const depositInfo = {
|
|
const depositInfo = {
|
|
rate: params.DEPOSIT_rate,
|
|
rate: params.DEPOSIT_rate,
|
|
@@ -58,7 +68,7 @@ export class RateService extends BaseService {
|
|
rate: params.WITHDRAWAL_rate,
|
|
rate: params.WITHDRAWAL_rate,
|
|
type: 'WITHDRAWAL',
|
|
type: 'WITHDRAWAL',
|
|
method: params.WITHDRAWAL_method,
|
|
method: params.WITHDRAWAL_method,
|
|
- }
|
|
|
|
|
|
+ }
|
|
const addRes = await Promise.allSettled([
|
|
const addRes = await Promise.allSettled([
|
|
await this.rateEntity.insert({
|
|
await this.rateEntity.insert({
|
|
...commonParams,
|
|
...commonParams,
|