import { ref } from 'vue' import { message } from 'ant-design-vue' import ServiceManager from "@/views/front/platfrom/serviceproxy/ServiceHelper/TradeHandle"; import { TransitEntity, AttachFile } from './ServiceEntitys' import CommonFunction from "@/views/front/platfrom/serviceproxy/CommonFunction"; import { ServiceSettings } from "@/views/front/develop/ServiceProxy.Ext/ServiceSettings" import FilesHandle from '@/views/front/platfrom/serviceproxy/ServiceHelper/FilesHandle'; import { CheckInfo } from '@/views/front/develop/ServiceProxy.Ext/ServiceEntitys/CheckInfo'; import { CheckResult } from '@/views/front/develop/ServiceProxy.Ext/ServiceEntitys/CheckResult'; import { AuthResult } from '@/views/front/develop/ServiceProxy.Ext/ServiceEntitys/AuthResult'; export enum Transit { CallServer = 'CallServer', CallAgn = 'CallAgn', CallTips = 'CallTips', CallAgnPay = 'CallAgnPay', CallAgnTIPS = 'CallAgnTIPS', CallAgnSecdistruct = 'CallAgnSecdistruct', CallAgnMobileBanking = 'CallAgnMobileBanking' } export default class TradeHandle { /** * 获取8583域定义 */ static async GetFdItemMap(type: string): Promise { const table = { Code: '', Type: '', Length: '', DotLength: '', Description: '', FieldType: '', MaxLength: '' } const entity = new TransitEntity() entity.ServiceName = 'TradeService' entity.FuncName = 'GetFdItemMap' entity.Parameters = { '1': type } const tmpresult = await ServiceManager.GetInstance().Commit(entity) let data = null if (tmpresult && tmpresult.length === 1) { data = tmpresult[0].AttachValue as string } if (data) { const lines = data.split('\n') return lines.map(line => { const rows = line.split('|') return { ...table, Code: rows[0], Type: rows[1], Length: rows[2], DotLength: rows[3], Description: rows[4], FieldType: rows[5], MaxLength: rows[6] } }) } return [] } /** * 按照参数指示与外端进行通讯交互 */ static async DoTrade( transit: string, integrateData: Uint8Array, kinBrno: string, fileName: string, fileData: Uint8Array, args: any[], serialNo: string ): Promise { const result: Uint8Array[] = [] try { const entity = new TransitEntity() entity.ServiceName = 'TradeService' entity.FuncName = 'DoTradeByTransit' entity.Parameters = { '1': transit, '3': kinBrno, '4': fileName, '6': '', '7': serialNo } const data = new AttachFile() data.AttachIndex = '2' data.AttachType = 'ByteType' data.AttachValue = integrateData entity.AttachFiles.push(data) const data1 = new AttachFile() data1.AttachIndex = '5' data1.AttachType = 'ByteType' data1.AttachValue = fileData entity.AttachFiles.push(data1) const tmpresult = await ServiceManager.GetInstance().Commit(entity) if (tmpresult) { tmpresult.forEach(attachFile => { result.push(attachFile.AttachValue as Uint8Array) }) } } catch (e) { throw e } return result } /** * 获取交易返回的附件信息数据 */ static async GetTradeFile(fileName: string): Promise { const filePath = ServiceSettings.TempFilePath + fileName + 'dhcc' return FilesHandle.GetFileData(filePath) } /** * 清空交易附件信息 */ static async ClearvFile(fileName: string): Promise { let result = false try { const entity = new TransitEntity() entity.ServiceName = 'UtilService' entity.FuncName = 'SaveFile' entity.Parameters = { '1': fileName, '3': 'false' } const data = new AttachFile() data.AttachIndex = '2' data.AttachType = 'ByteType' data.AttachValue = new Uint8Array(0) entity.AttachFiles.push(data) const tmpresult = await ServiceManager.GetInstance().Commit(entity) if (tmpresult && tmpresult.length === 1) { result = tmpresult[0].AttachValue as boolean } } catch (e) { throw e } return result } /** * 检查交易 */ static async Check(inf: CheckInfo): Promise { let result: CheckResult | null = null try { const entity = new TransitEntity() entity.ServiceName = 'TradeService' entity.FuncName = 'Check' const data = new AttachFile() data.AttachIndex = '1' data.AttachType = 'TableType' data.AttachValue = CommonFunction.ChangeEntityToTable([inf]) entity.AttachFiles.push(data) const tmpresult = await ServiceManager.GetInstance().Commit(entity) if (tmpresult && tmpresult.length === 1) { const rmpresult = CommonFunction.ChangeTableToEntitys( tmpresult[0].AttachValue ) if (rmpresult.length > 0) { result = rmpresult[0] } } } catch (e) { throw e } return result } /** * 复核操作 */ static async Super( serialId: string, SuperId: string, taskid: string, stat: number, TellerNo: string, tradedata: Record, pagedata: Uint8Array, refuseReason: string ): Promise { let result = false try { const entity = new TransitEntity() entity.ServiceName = 'TradeService' entity.FuncName = 'Super' entity.Parameters = { '1': serialId, '2': SuperId, '3': taskid, '4': stat.toString(), '5': TellerNo, '6': CommonFunction.ChangeDicToStr(tradedata), '8': refuseReason } const data = new AttachFile() data.AttachIndex = '7' data.AttachType = 'ByteType' data.AttachValue = pagedata entity.AttachFiles.push(data) const tmpresult = await ServiceManager.GetInstance().Commit(entity) if (tmpresult && tmpresult.length === 1) { result = tmpresult[0].AttachValue as boolean } } catch (e) { throw e } return result } /** * 授权验证操作 */ static async DoAuth(auth: string, pwd: string, lvl: string | null): Promise { let result: AuthResult | null = null try { const entity = new TransitEntity() entity.ServiceName = 'TradeService' entity.FuncName = 'DoAuth' entity.Parameters = { '1': auth, '2': pwd, '3': lvl || '' } const tmpresult = await ServiceManager.GetInstance().Commit(entity) if (tmpresult && tmpresult.length === 1) { const rmpresult = CommonFunction.ChangeTableToEntitys( tmpresult[0].AttachValue ) if (rmpresult.length > 0) { result = rmpresult[0] } } } catch (e) { throw e } return result } WriteImportantLog } interface AskSuperInfo { // ... 申请复核信息字段 } interface AskAuthInfo { // ... 申请授权信息字段 } interface PageData { datas: Uint8Array dataslength: number // ... 其他字段 } interface AuthTransRecords { // ... 授权交易记录字段 }