前端转vue
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

TradeHandle.ts 8.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. import { ref } from 'vue'
  2. import { message } from 'ant-design-vue'
  3. import ServiceManager from "@/views/front/platfrom/serviceproxy/ServiceHelper/TradeHandle";
  4. import { TransitEntity, AttachFile } from './ServiceEntitys'
  5. import CommonFunction from "@/views/front/platfrom/serviceproxy/CommonFunction";
  6. import { ServiceSettings } from "@/views/front/develop/ServiceProxy.Ext/ServiceSettings"
  7. import FilesHandle from '@/views/front/platfrom/serviceproxy/ServiceHelper/FilesHandle';
  8. import { CheckInfo } from '@/views/front/develop/ServiceProxy.Ext/ServiceEntitys/CheckInfo';
  9. import { CheckResult } from '@/views/front/develop/ServiceProxy.Ext/ServiceEntitys/CheckResult';
  10. import { AuthResult } from '@/views/front/develop/ServiceProxy.Ext/ServiceEntitys/AuthResult';
  11. export enum Transit {
  12. CallServer = 'CallServer',
  13. CallAgn = 'CallAgn',
  14. CallTips = 'CallTips',
  15. CallAgnPay = 'CallAgnPay',
  16. CallAgnTIPS = 'CallAgnTIPS',
  17. CallAgnSecdistruct = 'CallAgnSecdistruct',
  18. CallAgnMobileBanking = 'CallAgnMobileBanking'
  19. }
  20. export default class TradeHandle {
  21. /**
  22. * 获取8583域定义
  23. */
  24. static async GetFdItemMap(type: string): Promise<any> {
  25. const table = {
  26. Code: '',
  27. Type: '',
  28. Length: '',
  29. DotLength: '',
  30. Description: '',
  31. FieldType: '',
  32. MaxLength: ''
  33. }
  34. const entity = new TransitEntity()
  35. entity.ServiceName = 'TradeService'
  36. entity.FuncName = 'GetFdItemMap'
  37. entity.Parameters = { '1': type }
  38. const tmpresult = await ServiceManager.GetInstance().Commit(entity)
  39. let data = null
  40. if (tmpresult && tmpresult.length === 1) {
  41. data = tmpresult[0].AttachValue as string
  42. }
  43. if (data) {
  44. const lines = data.split('\n')
  45. return lines.map(line => {
  46. const rows = line.split('|')
  47. return {
  48. ...table,
  49. Code: rows[0],
  50. Type: rows[1],
  51. Length: rows[2],
  52. DotLength: rows[3],
  53. Description: rows[4],
  54. FieldType: rows[5],
  55. MaxLength: rows[6]
  56. }
  57. })
  58. }
  59. return []
  60. }
  61. /**
  62. * 按照参数指示与外端进行通讯交互
  63. */
  64. static async DoTrade(
  65. transit: string,
  66. integrateData: Uint8Array,
  67. kinBrno: string,
  68. fileName: string,
  69. fileData: Uint8Array,
  70. args: any[],
  71. serialNo: string
  72. ): Promise<Uint8Array[]> {
  73. const result: Uint8Array[] = []
  74. try {
  75. const entity = new TransitEntity()
  76. entity.ServiceName = 'TradeService'
  77. entity.FuncName = 'DoTradeByTransit'
  78. entity.Parameters = {
  79. '1': transit,
  80. '3': kinBrno,
  81. '4': fileName,
  82. '6': '',
  83. '7': serialNo
  84. }
  85. const data = new AttachFile()
  86. data.AttachIndex = '2'
  87. data.AttachType = 'ByteType'
  88. data.AttachValue = integrateData
  89. entity.AttachFiles.push(data)
  90. const data1 = new AttachFile()
  91. data1.AttachIndex = '5'
  92. data1.AttachType = 'ByteType'
  93. data1.AttachValue = fileData
  94. entity.AttachFiles.push(data1)
  95. const tmpresult = await ServiceManager.GetInstance().Commit(entity)
  96. if (tmpresult) {
  97. tmpresult.forEach(attachFile => {
  98. result.push(attachFile.AttachValue as Uint8Array)
  99. })
  100. }
  101. } catch (e) {
  102. throw e
  103. }
  104. return result
  105. }
  106. /**
  107. * 获取交易返回的附件信息数据
  108. */
  109. static async GetTradeFile(fileName: string): Promise<Uint8Array> {
  110. const filePath = ServiceSettings.TempFilePath + fileName + 'dhcc'
  111. return FilesHandle.GetFileData(filePath)
  112. }
  113. /**
  114. * 清空交易附件信息
  115. */
  116. static async ClearvFile(fileName: string): Promise<boolean> {
  117. let result = false
  118. try {
  119. const entity = new TransitEntity()
  120. entity.ServiceName = 'UtilService'
  121. entity.FuncName = 'SaveFile'
  122. entity.Parameters = {
  123. '1': fileName,
  124. '3': 'false'
  125. }
  126. const data = new AttachFile()
  127. data.AttachIndex = '2'
  128. data.AttachType = 'ByteType'
  129. data.AttachValue = new Uint8Array(0)
  130. entity.AttachFiles.push(data)
  131. const tmpresult = await ServiceManager.GetInstance().Commit(entity)
  132. if (tmpresult && tmpresult.length === 1) {
  133. result = tmpresult[0].AttachValue as boolean
  134. }
  135. } catch (e) {
  136. throw e
  137. }
  138. return result
  139. }
  140. /**
  141. * 检查交易
  142. */
  143. static async Check(inf: CheckInfo): Promise<CheckResult | null> {
  144. let result: CheckResult | null = null
  145. try {
  146. const entity = new TransitEntity()
  147. entity.ServiceName = 'TradeService'
  148. entity.FuncName = 'Check'
  149. const data = new AttachFile()
  150. data.AttachIndex = '1'
  151. data.AttachType = 'TableType'
  152. data.AttachValue = CommonFunction.ChangeEntityToTable([inf])
  153. entity.AttachFiles.push(data)
  154. const tmpresult = await ServiceManager.GetInstance().Commit(entity)
  155. if (tmpresult && tmpresult.length === 1) {
  156. const rmpresult = CommonFunction.ChangeTableToEntitys<CheckResult>(
  157. tmpresult[0].AttachValue
  158. )
  159. if (rmpresult.length > 0) {
  160. result = rmpresult[0]
  161. }
  162. }
  163. } catch (e) {
  164. throw e
  165. }
  166. return result
  167. }
  168. /**
  169. * 复核操作
  170. */
  171. static async Super(
  172. serialId: string,
  173. SuperId: string,
  174. taskid: string,
  175. stat: number,
  176. TellerNo: string,
  177. tradedata: Record<string, string>,
  178. pagedata: Uint8Array,
  179. refuseReason: string
  180. ): Promise<boolean> {
  181. let result = false
  182. try {
  183. const entity = new TransitEntity()
  184. entity.ServiceName = 'TradeService'
  185. entity.FuncName = 'Super'
  186. entity.Parameters = {
  187. '1': serialId,
  188. '2': SuperId,
  189. '3': taskid,
  190. '4': stat.toString(),
  191. '5': TellerNo,
  192. '6': CommonFunction.ChangeDicToStr(tradedata),
  193. '8': refuseReason
  194. }
  195. const data = new AttachFile()
  196. data.AttachIndex = '7'
  197. data.AttachType = 'ByteType'
  198. data.AttachValue = pagedata
  199. entity.AttachFiles.push(data)
  200. const tmpresult = await ServiceManager.GetInstance().Commit(entity)
  201. if (tmpresult && tmpresult.length === 1) {
  202. result = tmpresult[0].AttachValue as boolean
  203. }
  204. } catch (e) {
  205. throw e
  206. }
  207. return result
  208. }
  209. /**
  210. * 授权验证操作
  211. */
  212. static async DoAuth(auth: string, pwd: string, lvl: string | null): Promise<AuthResult | null> {
  213. let result: AuthResult | null = null
  214. try {
  215. const entity = new TransitEntity()
  216. entity.ServiceName = 'TradeService'
  217. entity.FuncName = 'DoAuth'
  218. entity.Parameters = {
  219. '1': auth,
  220. '2': pwd,
  221. '3': lvl || ''
  222. }
  223. const tmpresult = await ServiceManager.GetInstance().Commit(entity)
  224. if (tmpresult && tmpresult.length === 1) {
  225. const rmpresult = CommonFunction.ChangeTableToEntitys<AuthResult>(
  226. tmpresult[0].AttachValue
  227. )
  228. if (rmpresult.length > 0) {
  229. result = rmpresult[0]
  230. }
  231. }
  232. } catch (e) {
  233. throw e
  234. }
  235. return result
  236. }
  237. WriteImportantLog
  238. }
  239. interface AskSuperInfo {
  240. // ... 申请复核信息字段
  241. }
  242. interface AskAuthInfo {
  243. // ... 申请授权信息字段
  244. }
  245. interface PageData {
  246. datas: Uint8Array
  247. dataslength: number
  248. // ... 其他字段
  249. }
  250. interface AuthTransRecords {
  251. // ... 授权交易记录字段
  252. }