| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532 |
- import { ref, reactive, shallowRef, computed } from 'vue'
- import { useAccountStore, useUserStore, useLoginStore } from '@/stores'
- import {
- t2bBankWithdraw,
- queryBankAccountSign,
- t2bBankDeposit,
- queryCusBankSignBank,
- t2bBankSign,
- t2bBankCancelSign,
- accountFundInfoReq,
- queryBankCusBankExtendConfigs,
- t2bSMSVerificationCode,
- YJF_GetWithholdSignInSMSVCode,
- YJF_WithholdInApply,
- YJF_WithholdSignInSMS,
- YJF_WithholdSignOut
- } from '@/services/api/bank'
- import { SignStatus } from '@/constants/bank'
- import { decryptAES } from '@/services/websocket/package/crypto'
- import moment from "moment"
- import { v4 } from 'uuid'
- const accountStore = useAccountStore()
- const loginStore = useLoginStore()
- const useStore = useUserStore()
- const { getSystemParamValue } = useUserStore()
- // 出金请求
- export function useDoWithdraw() {
- const loading = shallowRef(false)
- /// 获取当前是否已签约
- const bankAccountSign = shallowRef<Model.BankAccountSignRsp[]>([])
- const sign = computed<Partial<Model.BankAccountSignRsp>>(() => {
- if (bankAccountSign.value.length) {
- return bankAccountSign.value[0]
- }
- return {}
- })
- const formData = reactive<Partial<Proto.t2bBankWithdrawReq>>({
- AccountType: useStore.userInfo?.userinfotype,
- AppDateTime: moment(new Date()).format('YYYY-MM-DD HH:mm:ss')
- })
- /// 查询签约信息
- const request = queryBankAccountSign().then((res) => {
- if (res.data.length) {
- bankAccountSign.value = res.data
- const data = res.data[0]
- formData.Currency = data.currency
- formData.CusBankID = data.cusbankid
- formData.BankAccoutName = data.bankaccountname
- formData.OpenCardBankId = data.bankid
- formData.AccountCode = data.accountcode
- formData.BranchBankName = data.branchbankname
- formData.BankAccoutName = data.bankaccountname2
- formData.BankAccoutNum = data.bankaccountno2
- }
- })
- const onSubmit = async () => {
- await request
- loading.value = true
- return t2bBankWithdraw({
- data: {
- ...formData,
- ExtOperatorID: new Date().getTime()
- }
- }).finally(() => {
- loading.value = false
- })
- }
- return {
- loading,
- onSubmit,
- formData,
- sign
- }
- }
- // 充值请求
- export function useDoDeposit(userid?: number) {
- const loading = shallowRef(false)
- /// 获取当前是否已签约
- const sign = shallowRef<Model.BankAccountSignRsp[]>([])
- /// formData
- const formData = reactive<Partial<Proto.t2bBankDepositReq>>({})
- const request = queryBankAccountSign({
- data: {
- userid: userid ?? loginStore.userId
- }
- }).then((res) => {
- if (res.data.length) {
- sign.value = res.data
- const data = res.data[0]
- formData.Currency = data.currency
- formData.CusBankID = data.cusbankid
- formData.BankAccoutName = data.bankaccountname2
- formData.OpenCardBankId = data.bankid
- 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 useDoBankSign() {
- const { userInfo } = useUserStore()
- const loading = shallowRef(false)
- const bankInfo = shallowRef<Model.BankAccountSignRsp>()
- /// 托管银行信息
- const cusSignBank = shallowRef<Model.CusBankSignBankRsp>()
- /// 查询签约银行信息
- const request = queryCusBankSignBank().then((res) => {
- if (res.data.length) {
- const data = res.data[0]
- cusSignBank.value = data
- formData.Currency = data.currency
- formData.CusBankID = data.cusbankid
- formData.TradeDate = data.tradedate
- }
- })
- /// 银行列表
- const banklist = computed(() => {
- return (cusSignBank.value?.Banklst ?? []).filter(e => e.status == 0)
- })
- /// 判断是否有签约信息 有就做修改
- queryBankAccountSign().then((res) => {
- bankInfo.value = res.data.filter(obj => {
- return ![SignStatus.Rescinded].includes(obj.signstatus)
- })[0]
- if (bankInfo.value) {
- ({
- currency: formData.Currency,
- cusbankid: formData.CusBankID,
- accountcode: formData.AccountCode,
- branchbankname: formData.OpenBankName,
- bankaccountno: formData.BankAccountNo,
- bankid: formData.OpenBankAccId,
- } = bankInfo.value)
- }
- })
- /// 数据
- const formData = reactive<Partial<Proto.t2bBankSignReq>>({
- AccountType: useStore.userInfo?.userinfotype,
- IsForce: 0,
- AgentCertType: 0,
- BankCardType: 0,
- BankAccountType: useStore.userInfo?.userinfotype,
- AccountCode: accountStore.currentAccountId.toString(),
- CertID: decryptAES(userInfo?.cardnum ?? ''),
- CertType: userInfo?.cardtypeid.toString(),
- BankAccountName: userInfo?.customername,
- MobilePhone: userInfo?.mobile2,
- BankAccountNo: decryptAES(userInfo.bankaccount),
- AccountName: userInfo?.customername,
- OpenBankAccId: userInfo.bankid
- })
- const onSubmit = async () => {
- await request
- loading.value = true
- // 默认未签约状态
- const { signstatus = SignStatus.Unsigned } = bankInfo.value ?? {}
- return t2bBankSign({
- data: {
- ...formData,
- OperateType: signstatus === SignStatus.Unsigned ? 1 : 2,
- ExtOperatorID: new Date().getTime(),
- AccountName: userInfo?.customername,
- ExBankName: banklist.value.find(obj => obj.bankid === formData.OpenBankAccId)?.bankname
- }
- }).finally(() => {
- loading.value = false
- })
- }
- return {
- loading,
- formData,
- banklist,
- onSubmit,
- bankInfo
- }
- }
- /// 银行解约请求
- export function useDoCancelBankSign() {
- /// 获取UserId
- const loading = shallowRef(false)
- const isloaded = shallowRef(false)
- const bankInfo = shallowRef<Model.BankAccountSignRsp>()
- /// 表单信息
- const formData = reactive<Partial<Proto.t2bBankCancelSignReq>>({
- IsForce: 0,
- })
- /// 获取当前是否已签约
- const sign = shallowRef<Model.BankAccountSignRsp[]>([])
- const formRefresh = () => {
- queryBankAccountSign().then((res) => {
- bankInfo.value = res.data[0];
- ({
- currency: formData.Currency,
- cusbankid: formData.CusBankID,
- accountcode: formData.AccountCode,
- } = bankInfo.value ?? {})
- }).finally(() => {
- isloaded.value = true
- })
- }
- const cancelSubmit = async () => {
- loading.value = true
- /// 发起请求
- return t2bBankCancelSign({
- data: {
- ...formData,
- ExtOperatorID: new Date().getTime(),
- }
- }).finally(() => {
- loading.value = false
- })
- }
- return {
- loading,
- isloaded,
- cancelSubmit,
- formData,
- sign,
- bankInfo,
- formRefresh
- }
- }
- /// 账户资金信息请求
- export function useAccountFundInfo() {
- /// 数据
- const fund = shallowRef<Partial<Proto.AccountFundInfoRsp>>({})
- /// 账户资金信息
- accountFundInfoReq({
- data: {
- QueryBitMask: 2,
- OrderId: new Date().getTime(),
- AccountId: accountStore.currentAccountId,
- }
- }).then((res) => {
- fund.value = res
- })
- return {
- fund
- }
- }
- /// 查询托管银行扩展配置信息
- export function useDoCusBankExtendConfigs(extendbiztype?: number) {
- /// 托管银行拓展信息
- const configs = ref<(Model.BankCusBankExtendConfigRsp & { value: string })[]>([])
- /// 托管银行信息
- const cusBank = shallowRef<Partial<Model.CusBankSignBankRsp>>({})
- const end = shallowRef<string>('')
- /// 查询签约银行信息
- queryCusBankSignBank().then((res) => {
- if (res.data.length) {
- const data = res.data[0]
- cusBank.value = data
- /// 不为空 入金取 318 出金取 319
- const msg = getSystemParamValue(extendbiztype === 2 ? '318' : '319') ?? ''
- const msg_013 = getSystemParamValue('013') ?? ''
- end.value = msg != '' ? msg : msg_013
- /// 查询配置信息
- queryBankCusBankExtendConfigs({
- data: {
- cusbankid: data?.cusbankid,
- extendbiztype: extendbiztype
- },
- }).then((res) => {
- if (res.data.length != 0) {
- configs.value = res.data.map(obj => ({
- ...obj,
- value: obj.fieldcode === 'legal_name' ? (useStore.userInfo?.legalpersonname ?? '') : ''
- }))
- }
- })
- }
- })
- return {
- configs,
- end,
- cusBank
- }
- }
- /// 查询托管银行信息
- export function useQueryCusBankSignBank() {
- /// 数据
- const cusBank = shallowRef<Partial<Model.CusBankSignBankRsp>>({})
- /// 查询签约银行信息
- const request = queryCusBankSignBank().then((res) => {
- if (res.data.length) {
- const data = res.data[0]
- cusBank.value = data
- }
- })
- /// 银行列表
- const banklist = computed(() => {
- return (cusBank.value?.Banklst ?? []).filter(e => e.status == 0)
- })
- return { cusBank, banklist, request }
- }
- /// 银行获取手机验证码请求
- export function useT2bSMSVerificationCode() {
- const loading = shallowRef(false)
- /// 查询签约银行信息
- const request = queryCusBankSignBank().then((res) => {
- if (res.data.length) {
- const data = res.data[0]
- swsFormData.CusBankID = data.cusbankid
- swsFormData.TradeDate = data.tradedate
- }
- })
- /// 数据
- const swsFormData = reactive<Partial<Proto.t2bSWSVerificationCodeReq>>({
- Mobile: useStore.userInfo?.mobile2,
- AccountCode: accountStore.currentAccountId.toString(),
- extend_info: JSON.stringify({ "sex": 1 })
- })
- const smsVerificationCode = async () => {
- await request
- loading.value = true
- return t2bSMSVerificationCode({
- data: {
- ExtOperatorID: new Date().getTime(),
- ...swsFormData,
- }
- }).finally(() => {
- loading.value = false
- })
- }
- return {
- loading,
- swsFormData,
- smsVerificationCode
- }
- }
- /// 云缴费代扣解约请求
- export function useDoYJF_WithholdSignOut() {
- /// 获取UserId
- const loading = shallowRef(false)
- /// 表单信息
- const formData = reactive<Partial<Proto.YJF_WithholdSignOutReq>>({
- AccountID: accountStore.currentAccountId,
- UserID: useStore.userInfo.userid,
- LoginID: loginStore.loginId,
- ClientSerialNo: v4()
- })
- const onSubmit = async () => {
- loading.value = true
- /// 发起请求
- return YJF_WithholdSignOut({
- data: {
- ...formData,
- }
- }).finally(() => {
- loading.value = false
- })
- }
- return {
- loading,
- onSubmit,
- formData
- }
- }
- /// 云缴费代扣入金申请
- export function useDoYJF_WithholdInApply() {
- /// 获取UserId
- const loading = shallowRef(false)
- /// 判断是否有签约信息
- const bankaccountno = shallowRef('')
- /// 表单信息
- const formData = reactive<Partial<Proto.YJF_WithholdInApplyReq>>({
- AccountID: accountStore.currentAccountId,
- UserID: useStore.userInfo.userid,
- LoginID: loginStore.loginId,
- ClientSerialNo: v4(),
- BillAmount: "0.0"
- })
- /// 判断是否有签约信息
- queryBankAccountSign().then((res) => {
- bankaccountno.value = res.data.filter(obj => { return [SignStatus.Signed].includes(obj.signstatus) })[0].bankaccountno
- })
- const onSubmit = async () => {
- loading.value = true
- /// 发起请求
- return YJF_WithholdInApply({
- data: {
- ...formData,
- }
- }).finally(() => {
- loading.value = false
- })
- }
- return {
- loading,
- onSubmit,
- formData,
- bankaccountno
- }
- }
- /// 云缴费代扣签约申请
- export function useDoYJF_WithholdSignInSMS() {
- /// 获取UserId
- const loading = shallowRef(false)
- /// 表单信息
- const formData = reactive<Partial<Proto.YJF_WithholdSignInSMSReq>>({
- AccountID: accountStore.currentAccountId,
- UserID: useStore.userInfo.userid,
- LoginID: loginStore.loginId,
- ClientSerialNo: v4()
- })
- const onSubmit = async () => {
- loading.value = true
- /// 发起请求
- return YJF_WithholdSignInSMS({
- data: {
- ...formData,
- }
- }).finally(() => {
- loading.value = false
- })
- }
- return {
- loading,
- onSubmit,
- formData
- }
- }
- /// 云缴费获取代扣签约短信验证码
- export function useDoYJFGetWithholdSignInSMSVCode() {
- /// 获取UserId
- const loading = shallowRef(false)
- /// 判断是否有签约信息
- const bankaccountno = shallowRef('')
- /// 表单信息
- const formData = reactive<Partial<Proto.YJF_GetWithholdSignInSMSVCodeReq>>({
- AccountID: accountStore.currentAccountId,
- UserID: useStore.userInfo.userid,
- LoginID: loginStore.loginId,
- ClientSerialNo: v4(),
- Yckfxe: '500000.00',
- Kkzqnkfxe: '0.00',
- Kkzqnxzbs: '0',
- Kksjbc: '99',
- Kksjdw: '1'
- })
- /// 判断是否有签约信息
- queryBankAccountSign().then((res) => {
- bankaccountno.value = res.data.filter(obj => { return [SignStatus.Signed].includes(obj.signstatus) })[0].bankaccountno
- })
- const onSubmit = async () => {
- loading.value = true
- /// 发起请求
- return YJF_GetWithholdSignInSMSVCode({
- data: {
- ...formData,
- }
- }).finally(() => {
- loading.value = false
- })
- }
- return {
- loading,
- onSubmit,
- formData,
- bankaccountno
- }
- }
|