Handy_Cao 9 maanden geleden
bovenliggende
commit
77e22aa8c2

+ 65 - 108
src/business/bank/index.ts

@@ -33,15 +33,6 @@ export function useDoWithdraw() {
     const loading = shallowRef(false)
     /// 获取当前是否已签约
     const bankAccountSign = shallowRef<Model.BankAccountSignRsp[]>([])
-
-    const hybrids = shallowRef<Model.PaymentCenterHybridConfigs[]>([])
-    const method_types = shallowRef<string[]>([])
-    const channel_banks = shallowRef<Model.HybridBank[]>([])
-
-    const channel_code = shallowRef('')
-    const method_type = shallowRef('')
-    const bank_code  = shallowRef('')
-
     const sign = computed<Partial<Model.BankAccountSignRsp>>(() => {
         if (bankAccountSign.value.length) {
             return bankAccountSign.value[0]
@@ -70,27 +61,6 @@ export function useDoWithdraw() {
         }
     })
 
-    // 获取支付中心混合支付渠道配置信息列表 泰商所采用
-    getHybridConfigs().then((res) => {
-        if (res.data.length) {
-            hybrids.value = res.data.filter(e => e.can_amt_out === 1)
-            if (hybrids.value.length) {
-                // 默认选中第一个银行的 code
-                channel_code.value = hybrids.value[0].channel_code ?? ''
-                // 默认选中第一个下面的银行类型
-                method_types.value = getMethodTypeKeys(hybrids.value[0].out_bank_infos)
-                if (method_types.value.length != 0) {
-                    method_type.value = method_types.value[0]
-
-                    channel_banks.value = hybrids.value[0].out_bank_infos[method_type.value]
-                    if (channel_banks.value.length != 0) {
-                        bank_code.value = channel_banks.value[0].bank_code
-                    }
-                }
-            }
-        }
-    }) 
-
     const onSubmit = async () => {
         await request,
         loading.value = true
@@ -109,13 +79,7 @@ export function useDoWithdraw() {
         loading,
         onSubmit,
         formData,
-        sign,
-        hybrids,
-        bank_code,
-        method_types,
-        method_type,
-        channel_banks,
-        channel_code
+        sign
     }
 }
 
@@ -125,14 +89,6 @@ export function useDoDeposit(userid?: number) {
     /// 获取当前是否已签约
     const bankAccountSign = shallowRef<Model.BankAccountSignRsp[]>([])
 
-    const hybrids = shallowRef<Model.PaymentCenterHybridConfigs[]>([])
-    const method_types = shallowRef<string[]>([])
-    const channel_banks = shallowRef<Model.HybridBank[]>([])
-
-    const channel_code = shallowRef('')
-    const method_type = shallowRef('')
-    const bank_code  = shallowRef('')
-
     const sign = computed<Partial<Model.BankAccountSignRsp>>(() => {
         if (bankAccountSign.value.length) {
             return bankAccountSign.value[0]
@@ -157,47 +113,61 @@ export function useDoDeposit(userid?: number) {
             formData.AccountCode = data.accountcode
             formData.BankAccoutNum = data.bankaccountno2
         }
-    })
+    }) 
+
+    const onSubmit = async () => {
+        await request
+        loading.value = true
+        return t2bBankDeposit({
+            data: {
+                ...formData,
+                ExtOperatorID: new Date().getTime(),
+            }
+        }).finally(() => {
+            loading.value = false
+        })
+    }
+
+    return {
+        loading,
+        onSubmit,
+        formData,
+        sign
+    }
+}
+
+// 获取对应的混合支付渠道信息
+export function useHybridConfigs(in_out_type: number) {
+    const hybrids = shallowRef<Model.PaymentCenterHybridConfigs[]>([])
+    const method_types = shallowRef<string[]>([])
+    const channel_banks = shallowRef<Model.HybridBank[]>([])
+
+    const channel_code = shallowRef('')
+    const method_type = shallowRef('')
+    const bank_code  = shallowRef('')
 
     // 获取支付中心混合支付渠道配置信息列表 泰商所采用
     getHybridConfigs().then((res) => {
         if (res.data.length) {
-            hybrids.value = res.data.filter(e => e.can_amt_in === 1)
+            hybrids.value = res.data.filter(e => in_out_type === 0 ? e.can_amt_in === 1 : e.can_amt_out === 1)
             if (hybrids.value.length) {
                 // 默认选中第一个银行的 code
                 channel_code.value = hybrids.value[0].channel_code ?? ''
                 // 默认选中第一个下面的银行类型
-                method_types.value = getMethodTypeKeys(hybrids.value[0].in_bank_infos)
+                method_types.value = getMethodTypeKeys( in_out_type === 0 ? hybrids.value[0].in_bank_infos : hybrids.value[0].out_bank_infos)
                 if (method_types.value.length != 0) {
                     method_type.value = method_types.value[0]
 
-                    channel_banks.value = hybrids.value[0].in_bank_infos[method_type.value]
+                    channel_banks.value = in_out_type === 0 ? hybrids.value[0].in_bank_infos[method_type.value] : hybrids.value[0].out_bank_infos[method_type.value]
                     if (channel_banks.value.length != 0) {
                         bank_code.value = channel_banks.value[0].bank_code
                     }
                 }
             }
         }
-    })    
-
-    const onSubmit = async () => {
-        await request
-        loading.value = true
-        return t2bBankDeposit({
-            data: {
-                ...formData,
-                ExtOperatorID: new Date().getTime(),
-            }
-        }).finally(() => {
-            loading.value = false
-        })
-    }
+    }) 
 
     return {
-        loading,
-        onSubmit,
-        formData,
-        sign,
         hybrids,
         bank_code,
         method_types,
@@ -258,52 +228,39 @@ export function useDoBankSign() {
     /// 查询签约银行信息 任务 #6605
     const request = system_1016.value === '1' ?  queryMemberCusBankInfo().then((res) => {
         if (res.data.length) {
-            // 默认选择第一个
-            selectCusBank.value = res.data[0]
-            cusBanks.value = res.data ?? []
-            banklist.value = selectCusBank.value.Banklst.filter(e => e.status == 0)
-
-            swsFormData.CusBankID = selectCusBank.value.cusbankid
-            swsFormData.TradeDate = selectCusBank.value.tradedate
-
-            formData.Currency = selectCusBank.value.currency
-            formData.CusBankID = selectCusBank.value.cusbankid
-            formData.TradeDate = selectCusBank.value.tradedate
-
-            // 查找银行是否存在
-            const bankItem = banklist.value.find(obj => obj.bankid === formData.OpenBankAccId)
-            if (bankItem) {
-                formData.ExBankName = bankItem.bankname
-            } else {
-                formData.OpenBankAccId = ''
-                formData.ExBankName = ''
-            }
+            // 设置信息
+            setCusBankInfo(res.data ?? [])
         }
     }) : queryCusBankSignBank().then((res) => {
         if (res.data.length) {
-            // 默认选择第一个
-            selectCusBank.value = res.data[0]
-            cusBanks.value = res.data ?? []
-            banklist.value = selectCusBank.value.Banklst.filter(e => e.status == 0)
-
-            swsFormData.CusBankID = selectCusBank.value.cusbankid
-            swsFormData.TradeDate = selectCusBank.value.tradedate
-
-            formData.Currency = selectCusBank.value.currency
-            formData.CusBankID = selectCusBank.value.cusbankid
-            formData.TradeDate = selectCusBank.value.tradedate
-
-            // 查找银行是否存在
-            const bankItem = banklist.value.find(obj => obj.bankid === formData.OpenBankAccId)
-            if (bankItem) {
-                formData.ExBankName = bankItem.bankname
-            } else {
-                formData.OpenBankAccId = ''
-                formData.ExBankName = ''
-            }
+            // 设置信息
+            setCusBankInfo(res.data ?? [])
         }
     })
 
+    const setCusBankInfo = (infos: Model.CusBankSignBankRsp[]) => {
+        // 默认选择第一个
+        selectCusBank.value = infos[0]
+        cusBanks.value = infos
+        banklist.value = selectCusBank.value.Banklst.filter(e => e.status == 0)
+
+        swsFormData.CusBankID = selectCusBank.value.cusbankid
+        swsFormData.TradeDate = selectCusBank.value.tradedate
+
+        formData.Currency = selectCusBank.value.currency
+        formData.CusBankID = selectCusBank.value.cusbankid
+        formData.TradeDate = selectCusBank.value.tradedate
+
+        // 查找银行是否存在
+        const bankItem = banklist.value.find(obj => obj.bankid === formData.OpenBankAccId)
+        if (bankItem) {
+            formData.ExBankName = bankItem.bankname
+        } else {
+            formData.OpenBankAccId = ''
+            formData.ExBankName = ''
+        }
+    }
+
     /// 判断是否有签约信息 有就做修改
     queryBankAccountSign().then((res) => {
         bankInfo.value = res.data.filter(obj => {
@@ -685,4 +642,4 @@ export function useDoYJFGetWithholdSignInSMSVCode() {
         formData,
         bankaccountno
     }
-}
+}

+ 3 - 2
src/packages/tss/views/bank/wallet/components/deposit/Index.vue

@@ -95,7 +95,7 @@
 import { shallowRef, ref, defineAsyncComponent, onMounted, computed } from 'vue'
 import { Form, Field, Cell, CellGroup, Button, FieldRule, FormInstance, RadioGroup, Radio, showToast, showFailToast } from 'vant'
 import { fullloading, dialog } from '@/utils/vant'
-import { useDoDeposit, useDoCusBankExtendConfigs, getMethodTypeKeys } from '@/business/bank'
+import { useDoDeposit, useDoCusBankExtendConfigs, getMethodTypeKeys, useHybridConfigs } from '@/business/bank'
 import { getServerTime } from '@/services/api/common'
 import { useUserStore, useAccountStore, i18n } from '@/stores'
 import { useComponent } from '@/hooks/component'
@@ -105,7 +105,8 @@ import AppSelect from '@mobile/components/base/select/index.vue'
 import moment from 'moment'
 
 const formRef = shallowRef<FormInstance>()
-const { formData, onSubmit, sign, hybrids, channel_code, bank_code, method_type, method_types, channel_banks } = useDoDeposit()
+const { formData, onSubmit, sign } = useDoDeposit()
+const {  hybrids, channel_code, bank_code, method_type, method_types, channel_banks } = useHybridConfigs(0)
 const { getSystemParamValue } = useUserStore()
 const { configs, cusBank, startTime, endTime } = useDoCusBankExtendConfigs(2)
 const certificate_photo_url = ref('')

+ 3 - 2
src/packages/tss/views/bank/wallet/components/withdraw/Index.vue

@@ -80,7 +80,7 @@
 import { reactive, shallowRef, defineAsyncComponent, computed } from 'vue'
 import { Form, Field, Cell, CellGroup, FormInstance, Button, FieldRule } from 'vant'
 import { fullloading, dialog, } from '@/utils/vant'
-import { useDoWithdraw, useAccountFundInfo, useDoCusBankExtendConfigs, getMethodTypeKeys } from '@/business/bank'
+import { useDoWithdraw, useAccountFundInfo, useDoCusBankExtendConfigs, getMethodTypeKeys, useHybridConfigs } from '@/business/bank'
 import { getServerTime } from '@/services/api/common'
 import { useNavigation } from '@mobile/router/navigation'
 import { useUserStore, i18n } from '@/stores'
@@ -88,7 +88,8 @@ import { handleNoneValue } from '@/filters'
 import moment from 'moment'
 import AppSelect from '@mobile/components/base/select/index.vue'
 
-const { formData, onSubmit, sign, hybrids, channel_code, bank_code, method_type, method_types, channel_banks } = useDoWithdraw()
+const { formData, onSubmit, sign } = useDoWithdraw()
+const {  hybrids, channel_code, bank_code, method_type, method_types, channel_banks } = useHybridConfigs(1)
 const { configs, cusBank, startTime, endTime } = useDoCusBankExtendConfigs(3)
 
 /// 资金账户信息

+ 18 - 18
src/types/model/bank.d.ts

@@ -570,12 +570,12 @@ declare namespace Model {
     }
 
     interface PaymentCenterHybridConfigs {
-        in_bank_infos: MethodType // 入金银行
+        in_bank_infos: MethodType  // 入金银行
         out_bank_infos: MethodType // 出金银行
-        can_amt_in: number   // 入金是否可用 0-不可用 1-可用
-        can_amt_out: number  // 出金是否可用 0-不可用 1-可用
-        channel_code: string // 渠道代码
-        channel_name: string // 渠道名称
+        can_amt_in: number         // 入金是否可用 0-不可用 1-可用
+        can_amt_out: number        // 出金是否可用 0-不可用 1-可用
+        channel_code: string       // 渠道代码
+        channel_name: string       // 渠道名称
     }
 
     interface MethodType {
@@ -586,22 +586,22 @@ declare namespace Model {
         bank_code: string    // 银行代码
         bank_name: string    // 银行名称
         channel_code: string // 渠道代码
-        is_enabled: number  // 是否可用 0-未可用 1-可用
-        method_type: string // 方式类型
-        out_in_flag: number // 出入金标志 0-出金 1-入金
-        remark: string // 备注
+        is_enabled: number   // 是否可用 0-未可用 1-可用
+        method_type: string  // 方式类型
+        out_in_flag: number  // 出入金标志 0-出金 1-入金
+        remark: string       // 备注
     }
 
     interface HybridReceiverOnboard {
-        accountid: string    // 资金账户ID
+        accountid: string       // 资金账户ID
         bank_account: string    // 银行卡号
-        bank_code: string // 银行代码
-        bank_name: string  // 银行名称
-        cert_no: string // 证件号码
-        channel_code: string // 渠道代码
-        name: string // 名称 / 企业名称
-        phone_number?: string // 电话号码
-        method_type: string // 方式类型
-        receiver_type: string // 接收者类型 // 个人-Individual 企业-Organization
+        bank_code: string       // 银行代码
+        bank_name: string       // 银行名称
+        cert_no: string         // 证件号码
+        channel_code: string    // 渠道代码
+        name: string            // 名称 / 企业名称
+        phone_number?: string   // 电话号码
+        method_type: string     // 方式类型
+        receiver_type: string   // 接收者类型 // 个人-Individual 企业-Organization
     }
 }