Browse Source

商户分配通道

test 10 months ago
parent
commit
60afacc7d9

+ 3 - 10
src/modules/dj/controller/admin/channel.ts

@@ -1,8 +1,7 @@
 import { ChannelEntity } from '../../entity/channel';
-import { Provide, Post, Inject, Body, ALL } from '@midwayjs/decorator';
+import { Provide } from '@midwayjs/decorator';
 import { CoolController, BaseController } from '@cool-midway/core';
 import { ChannelService } from '../../service/channel';
-import { DispatchService } from '../../service/channels/dispatch';
 
 @Provide()
 @CoolController({
@@ -10,14 +9,8 @@ import { DispatchService } from '../../service/channels/dispatch';
   entity: ChannelEntity,
   service: ChannelService,
   pageQueryOp: {
-    keyWordLikeFields: ['name', 'code'],
+    keyWordLikeFields: ['name', 'code', 'payType'],
   },
 })
-export class OrdertController extends BaseController {
-  @Inject()
-  channelService: ChannelService;
-
-  @Inject()
-  dispatchService: DispatchService;
-
+export class ChannelController extends BaseController {
 }

+ 11 - 2
src/modules/dj/controller/admin/comm.ts

@@ -5,6 +5,7 @@ import { BaseSysConfService } from '../../../base/service/sys/conf';
 import { CurrencyService } from '../../service/currency';
 import { MerchantService } from '../../service/merchant';
 import { PayTypeService } from '../../service/payType';
+import { ChannelService } from '../../service/channel';
 
 @Provide()
 @CoolController()
@@ -20,6 +21,9 @@ export class OrdertController extends BaseController {
   
   @Inject()
   payTypeService: PayTypeService;
+    
+  @Inject()
+  channelService: ChannelService;
 
   @Inject()
   baseSysConfService: BaseSysConfService;
@@ -46,7 +50,12 @@ export class OrdertController extends BaseController {
   }
 
   @Post('/getPayTypes', { summary: '支付类型列表' })
-  async getPayTypes() {
-    return this.ok(await this.payTypeService.getPayTypeList());
+  async getPayTypes(@Body('type') type) {
+    return this.ok(await this.payTypeService.getPayTypeList(type));
+  }
+
+  @Post('/getChannels', { summary: '支付通道列表' })
+  async getChannels() {
+    return this.ok(await this.channelService.getChannelList());
   }
 }

+ 13 - 0
src/modules/dj/controller/admin/mchChannel.ts

@@ -0,0 +1,13 @@
+import { Provide } from '@midwayjs/decorator';
+import { CoolController, BaseController } from '@cool-midway/core';
+import { MchChannelService } from '../../service/mchChannel';
+import { MchChannelEntity } from '../../entity/mchChannel';
+
+@Provide()
+@CoolController({
+  api: ['add', 'delete', 'update', 'list', 'info', 'page'],
+  entity: MchChannelEntity,
+  service: MchChannelService
+})
+export class MchChannelController extends BaseController {
+}

+ 11 - 2
src/modules/dj/entity/channel.ts

@@ -13,11 +13,20 @@ export class ChannelEntity extends BaseEntity {
   @Column({ comment: '通道编码' })
   code: string;
 
+  @Column({ comment: '支付方式' })
+  payType: string;
+
   @Column({ comment: '代码服务' })
   service: string;
 
-  @Column({ comment: '费率' })
-  rate: string;
+  @Column({ comment: '费率', type: 'decimal', precision: 10, scale: 2 })
+  rate: number;
+
+  @Column({ comment: '单笔固定费用', type: 'decimal', precision: 10, scale: 2 })
+  basicFee: number;
+
+  @Column({ comment: '单笔最低费用', type: 'decimal', precision: 10, scale: 2 })
+  feeMin: number;
 
   @Column({ comment: '单笔最大', type: 'decimal', precision: 10, scale: 2 })
   max: number;

+ 21 - 0
src/modules/dj/entity/mchChannel.ts

@@ -0,0 +1,21 @@
+import { BaseEntity } from '@cool-midway/core';
+import { Column, Entity, Index } from 'typeorm';
+
+/**
+ * 字典信息
+ */
+@Entity('dj_mch_channel')
+export class MchChannelEntity extends BaseEntity {
+  @Column({ comment: '商户号' })
+  mchId: string;
+  @Index({ unique: true })
+
+  @Column({ comment: '支付方式' })
+  payType: string;
+
+  @Column({ comment: '通道编码' })
+  code: string;
+
+  @Column({ comment: '状态 0-未启用 1 启用', type: 'tinyint', default: 1 })
+  status: number;
+}

+ 9 - 0
src/modules/dj/service/channel.ts

@@ -10,6 +10,15 @@ export class ChannelService extends BaseService {
   @InjectEntityModel(ChannelEntity)
   channelEntity: Repository<ChannelEntity>;
 
+  async getChannelList() {
+    return await this.channelEntity.find({
+      where: {
+        status: 1
+      },
+      select: ['name', 'code', 'payType']
+    })
+  }
+
   async getOne(code) {
     return await this.channelEntity.findOneBy({
       status: 1,

+ 12 - 0
src/modules/dj/service/mchChannel.ts

@@ -0,0 +1,12 @@
+import { Provide } from '@midwayjs/decorator';
+import { BaseService } from '@cool-midway/core';
+import { InjectEntityModel } from '@midwayjs/typeorm';
+import { Repository } from 'typeorm';
+import * as _ from 'lodash';
+import { MchChannelEntity } from '../entity/mchChannel';
+
+@Provide()
+export class MchChannelService extends BaseService {
+  @InjectEntityModel(MchChannelEntity)
+  mchChannelEntity: Repository<MchChannelEntity>;
+}

+ 10 - 1
src/modules/dj/service/payType.ts

@@ -10,8 +10,17 @@ export class PayTypeService extends BaseService {
   @InjectEntityModel(PayTypeEntity)
   payTypeEntity: Repository<PayTypeEntity>;
 
-  async getPayTypeList() {
+  async getPayTypeList(type) {
+    let where;;
+    if (type) {
+      where = {
+        type
+      }
+    } else {
+      where = {};
+    }
     return await this.payTypeEntity.find({
+      where,
       select: ['payType', 'type', 'currencies']
     })
   }