test 9 月之前
父節點
當前提交
07cf9f0269
共有 2 個文件被更改,包括 11 次插入1 次删除
  1. 1 1
      src/modules/dj/service/withdraw.ts
  2. 10 0
      src/modules/dj/service/withdrawState.ts

+ 1 - 1
src/modules/dj/service/withdraw.ts

@@ -73,7 +73,7 @@ export class WithdrawService extends BaseService {
     const sql = `SELECT 
     SUM(IF(a.status = 8, a.amount, 0)) as num1,
     SUM(IF(a.status = 8, a.charge, 0)) as num2,
-    SUM(IF(a.status = 8, 1, 0)) as num3,
+    SUM(IF(a.status = 8, 1, 0)) as num3
     ${this.utils.isMerchant(roleIds)
         ? ''
         : ',SUM(IF(a.status = 8, a.channelCharge, 0)) as num4'

+ 10 - 0
src/modules/dj/service/withdrawState.ts

@@ -7,6 +7,7 @@ import { ILogger } from '@midwayjs/logger';
 import { WalletService } from './wallet';
 import { DispatchService } from './channels/dispatch';
 import { WithdrawNotifyService } from './withdrawNotify';
+import { WithdrawChannelService } from './withdrawChannel';
 
 @Provide()
 export class WithdrawStateService extends BaseService {
@@ -22,6 +23,9 @@ export class WithdrawStateService extends BaseService {
     @Inject()
     dispatchService: DispatchService;
 
+    @Inject()
+    withdrawChannelService: WithdrawChannelService;
+
     @Logger()
     logger: ILogger;
 
@@ -146,6 +150,12 @@ export class WithdrawStateService extends BaseService {
     // 发起代付:已受理=》银行处理中
     async acceptToProcessiong(withdraw) {
         try {
+            const channel = await this.withdrawChannelService.queryByCode(withdraw.code);
+            let channelCharge = (+withdraw.amount * +channel.rate) / 100 + +channel.basicFee;
+            if (channelCharge < channel.feeMin) {
+                channelCharge = channel.feeMin;
+            }
+            withdraw.channelCharge = channelCharge;
             const { traceNo } = await this.dispatchService.withdraw(withdraw);
             withdraw.traceNo = traceNo;
         } catch (err) {