前端转vue
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

TradeHandle.ts 8.0KB

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