|
@@ -1,4 +1,4 @@
|
|
|
-import { Init, Inject, Provide } from '@midwayjs/decorator';
|
|
|
+import { Inject, Provide } from '@midwayjs/decorator';
|
|
|
import { BaseService } from '@cool-midway/core';
|
|
|
import { InjectEntityModel } from '@midwayjs/typeorm';
|
|
|
import { Repository } from 'typeorm';
|
|
@@ -37,4 +37,38 @@ export class RateService extends BaseService {
|
|
|
select: ['method'],
|
|
|
});
|
|
|
}
|
|
|
+ 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 = {
|
|
|
+ merchantId: params.merchantId,
|
|
|
+ channelId: params.channelId,
|
|
|
+ currency: params.currency,
|
|
|
+ status: params.status,
|
|
|
+ remark: params.remark
|
|
|
+ }
|
|
|
+ // 入金
|
|
|
+ const depositInfo = {
|
|
|
+ rate: params.DEPOSIT_rate,
|
|
|
+ type: 'DEPOSIT',
|
|
|
+ method: params.DEPOSIT_method,
|
|
|
+ }
|
|
|
+
|
|
|
+ // 出金
|
|
|
+ const withdrawalInfo = {
|
|
|
+ rate: params.WITHDRAWAL_rate,
|
|
|
+ type: 'WITHDRAWAL',
|
|
|
+ method: params.WITHDRAWAL_method,
|
|
|
+ }
|
|
|
+ const addRes = await Promise.allSettled([
|
|
|
+ await this.rateEntity.insert({
|
|
|
+ ...commonParams,
|
|
|
+ ...depositInfo
|
|
|
+ }),
|
|
|
+ await this.rateEntity.insert({
|
|
|
+ ...commonParams,
|
|
|
+ ...withdrawalInfo
|
|
|
+ })
|
|
|
+ ])
|
|
|
+ return addRes
|
|
|
+ }
|
|
|
}
|