前端转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.

ContractManager.ts 15KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. import { reactive } from 'vue'
  2. import type { PageBase } from "@/views/front/develop/Constract/ContractBase/PageBase"
  3. import Message from "@/views/front/develop/Communication/Message";
  4. import type { PrintContainer } from './PrintContainer'
  5. import type { EvaluationRecord } from './EvaluationRecord'
  6. import type { PaymentFeeArguments } from './PaymentFeeArguments'
  7. import { PlatformLogger, TradeHandle } from './LogSystem'
  8. import { ExamSystem } from './ExamSystem'
  9. import { LoginUserInfo } from './UserInfo'
  10. /**
  11. * 契约执行流程定义
  12. */
  13. export class ContractManager {
  14. /**
  15. * 触发提交流程
  16. */
  17. public static RaiseSubmit(page: PageBase): boolean {
  18. if (page.isSubmitContract) {
  19. const authdata = new AuthDataHelper(page)
  20. authdata.ClearAuthData()
  21. const contract = page as ISubmitContract
  22. if (!contract || !contract.SubmitEntry) return false
  23. if (contract.SubmitEntry.Submitted) {
  24. TradeHandle.WriteTraceLog("ContractManager.RaiseSubmit:阻断错误的重复提交!", contract.SubmitEntry.MessageData.Fd16)
  25. return false
  26. }
  27. let message: Message | null = null
  28. if (!contract.PreviewSubmitting(out message)) return false
  29. if (!message || message.Fd16 !== page.TradeInfo.MainCode) {
  30. PlatformLogger.TradeErrorInfo("提交通讯错误:", new Error("提交报文与主交易码不一致,请检查..."))
  31. }
  32. const entry = contract.SubmitEntry
  33. if (!entry || !entry.LoadData(page, message)) return false
  34. if (!this.RaiseRecheck(page, message)) return false
  35. if (!this.RaiseAuthorize(page, message)) return false
  36. if (!this.RaisePaymentFee(page, message)) return false
  37. if (!entry.RaiseSubmit()) return false
  38. }
  39. return true
  40. }
  41. /**
  42. * 触发授权流程
  43. */
  44. public static RaiseAuthorize(page: PageBase, message: Message, powerCode = "0"): boolean {
  45. if (page.isAuthorizeContract) {
  46. const contract = page as IAuthorizeContract
  47. if (!contract) return false
  48. if (ExamSystem.Instance.InExamMode) return true
  49. if (page.TradeAPIs.GetTradeMetadata("isAuth") !== "true") return true
  50. if (!contract.AuthorizeEntries || contract.AuthorizeEntries.length === 0) return false
  51. const entry = contract.AuthorizeEntries.find(x => x.PowerCode === powerCode)
  52. if (!entry) return false
  53. entry.LoadData(page, message)
  54. return entry.RaiseAuthorize()
  55. }
  56. return true
  57. }
  58. /**
  59. * 触发复核流程
  60. */
  61. public static RaiseRecheck(page: PageBase, message: Message, powerCode = "0"): boolean {
  62. if (page.isRecheckContract) {
  63. const contract = page as IRecheckContract
  64. if (!contract) return false
  65. if (ExamSystem.Instance.InExamMode) return true
  66. if (page.TradeAPIs.GetTradeMetadata("isRecheck") !== "true") return true
  67. if (!contract.RecheckEntries || contract.RecheckEntries.length === 0) return false
  68. const entry = contract.RecheckEntries.find(x => x.PowerCode === powerCode)
  69. if (!entry) return false
  70. entry.LoadData(page, message)
  71. return entry.RaiseRecheck()
  72. }
  73. return true
  74. }
  75. /**
  76. * 触发收费流程
  77. */
  78. public static RaisePaymentFee(page: PageBase, message: Message): boolean {
  79. if (page.isPaymentFeeContract) {
  80. const contract = page as IPaymentFeeContract
  81. if (!contract) return false
  82. if (page.TradeAPIs.GetTradeMetadata("isPaymentFee") !== "true") return true
  83. if (message.TransitNode === TransitType.CallGateway2CBS) {
  84. PlatformLogger.CommunicationInfo("核心前置通讯不支持收费(TransitType.CallGateway2CBS)")
  85. return true
  86. }
  87. const FLAG = TradeManagerHandle.TT_SYSCONFIG_GetConfigValueByConfigID("2ea3a7e6cfa04f89a335bf1e363295de")
  88. const filedata = message.FileData
  89. let isPaymentFee = false
  90. const args = new PaymentFeeArguments(message)
  91. if (!contract.CheckFee(args, out isPaymentFee)) return false
  92. if (isPaymentFee && !contract.RaisePaymentFee(args)) return false
  93. message.FileData = filedata
  94. }
  95. return true
  96. }
  97. /**
  98. * 触发评价流程
  99. */
  100. public static RaiseEvaluation(page: PageBase): void {
  101. const contract = page as IEvaluationContract
  102. if (!contract) return
  103. if (page.TradeAPIs.GetTradeMetadata("isEvaluation") !== "true") return
  104. const record = new EvaluationRecord()
  105. if (!contract.PreviewEvaluation(record)) {
  106. const list_accno = page.PositioningUI(["账/卡号", "账号", "卡 号", "账 号", "结算账号", "账/卡号", "贷款账号", "还款账号", "贷方账号", "记贷付款账号", "借据展示号", "记账账号", "收款人账号", "付款人账号", "签约账号", "账/卡 号", "本行账号", "申请人账号"])
  107. .filter(x => x[1] instanceof HTMLInputElement)
  108. .map(x => (x[1] as HTMLInputElement).value)
  109. .filter((value, index, self) => self.indexOf(value) === index)
  110. .reduce((acc, curr) => (acc[curr] = curr, acc), {} as Record<string, string>)
  111. const list_idno = page.PositioningUI(["证件号码"])
  112. .filter(x => x[1] instanceof HTMLInputElement)
  113. .map(x => (x[1] as HTMLInputElement).value)
  114. .filter((value, index, self) => self.indexOf(value) === index)
  115. .reduce((acc, curr) => (acc[curr] = curr, acc), {} as Record<string, string>)
  116. const list_name = page.PositioningUI(["户 名", "户  名", "客户名称"])
  117. .filter(x => x[1] instanceof HTMLInputElement)
  118. .map(x => (x[1] as HTMLInputElement).value)
  119. .filter((value, index, self) => self.indexOf(value) === index)
  120. .reduce((acc, curr) => (acc[curr] = curr, acc), {} as Record<string, string>)
  121. const list_amt = page.PositioningUI(["交易金额", "开户金额", "支取金额"])
  122. .filter(x => x[1] instanceof HTMLInputElement)
  123. .map(x => (x[1] as HTMLInputElement).value)
  124. .filter((value, index, self) => self.indexOf(value) === index)
  125. .reduce((acc, curr) => (acc[curr] = curr, acc), {} as Record<string, string>)
  126. record.AccNo = Object.keys(list_accno).length === 1 ? list_accno[Object.keys(list_accno)[0]] : ''
  127. record.IdNo = Object.keys(list_idno).length === 1 ? list_idno[Object.keys(list_idno)[0]] : ''
  128. record.Name = Object.keys(list_name).length === 1 ? list_name[Object.keys(list_name)[0]] : ''
  129. record.Amt = Object.keys(list_amt).length === 1 ? list_amt[Object.keys(list_amt)[0]] : ''
  130. const gen = (title: string, dict: Record<string, string>): HTMLElement => {
  131. const line = document.createElement('div')
  132. line.style.display = 'flex'
  133. const titleEl = document.createElement('span')
  134. titleEl.textContent = title
  135. titleEl.style.width = '120px'
  136. line.appendChild(titleEl)
  137. const comboBox = document.createElement('select')
  138. comboBox.style.width = '300px'
  139. Object.keys(dict).forEach(key => {
  140. const option = document.createElement('option')
  141. option.value = key
  142. option.textContent = dict[key]
  143. comboBox.appendChild(option)
  144. })
  145. comboBox.addEventListener('change', () => {
  146. if (dict === list_accno) record.AccNo = comboBox.value
  147. else if (dict === list_idno) record.IdNo = comboBox.value
  148. else if (dict === list_name) record.Name = comboBox.value
  149. else if (dict === list_amt) record.Amt = comboBox.value
  150. })
  151. line.appendChild(comboBox)
  152. return line
  153. }
  154. do {
  155. if (Object.keys(list_accno).length >= 1 || Object.keys(list_idno).length >= 1) {
  156. const content = document.createElement('div')
  157. if (Object.keys(list_accno).length > 0) content.appendChild(gen("银行账号", list_accno))
  158. if (Object.keys(list_idno).length > 0) content.appendChild(gen("身份证号", list_idno))
  159. if (Object.keys(list_name).length > 0) content.appendChild(gen("客户姓名", list_name))
  160. if (Object.keys(list_amt).length > 0) content.appendChild(gen("发生金额", list_amt))
  161. if (confirm('请确认当前客户信息:')) {
  162. if (Object.keys(list_accno).length > 0) record.AccNo = (content.querySelector('select') as HTMLSelectElement).value
  163. if (Object.keys(list_idno).length > 0) record.IdNo = (content.querySelectorAll('select')[1] as HTMLSelectElement).value
  164. if (Object.keys(list_name).length > 0) record.Name = (content.querySelectorAll('select')[2] as HTMLSelectElement).value
  165. if (Object.keys(list_amt).length > 0) record.Amt = (content.querySelectorAll('select')[3] as HTMLSelectElement).value
  166. break
  167. }
  168. } else {
  169. return
  170. }
  171. } while (true)
  172. }
  173. PlatformLogger.SystemInfo("RaiseEvaluation:数据=>" + record.toString())
  174. if (!record.IdNo.trim() && record.AccNo.trim()) {
  175. const ac = page.TradeAPIs.TF_Customer_QueryCustomerInformation({
  176. ZH: record.AccNo.trim()
  177. })
  178. if (!ac.IsFailed && ac.ZJHM.trim()) {
  179. record.IdNo = ac.ZJHM.trim()
  180. }
  181. }
  182. if (!record.Name) {
  183. if (record.IdNo.trim()) {
  184. const khInfo = page.TradeAPIs.TF_Customer_QueryCustomerInformation({
  185. ZJLX: "1",
  186. ZJHM: record.IdNo.trim(),
  187. })
  188. if (!khInfo.IsFailed && khInfo.HM.trim()) {
  189. record.Name = khInfo.HM.trim()
  190. } else if (record.AccNo.trim()) {
  191. const khInfo1 = page.TradeAPIs.TF_Customer_QueryCustomerInformation({
  192. ZH: record.AccNo.trim()
  193. })
  194. if (!khInfo1.IsFailed && khInfo1.HM.trim()) {
  195. record.Name = khInfo1.HM.trim()
  196. } else {
  197. page.TradeAPIs.ShowInfoMessageBox("户名抓取失败,微信评价推送失败!")
  198. return
  199. }
  200. } else {
  201. page.TradeAPIs.ShowInfoMessageBox("户名抓取失败,微信评价推送失败!")
  202. return
  203. }
  204. } else if (record.AccNo.trim()) {
  205. const khInfo1 = page.TradeAPIs.TF_Customer_QueryCustomerInformation({
  206. ZH: record.AccNo.trim()
  207. })
  208. if (!khInfo1.IsFailed && khInfo1.HM.trim()) {
  209. record.Name = khInfo1.HM.trim()
  210. } else {
  211. page.TradeAPIs.ShowInfoMessageBox("户名抓取失败,微信评价推送失败!")
  212. return
  213. }
  214. } else {
  215. page.TradeAPIs.ShowInfoMessageBox("户名抓取失败,微信评价推送失败!")
  216. return
  217. }
  218. }
  219. const msg1 = new Message(Message.BitMap.Agn)
  220. page.InitFd(msg1)
  221. page.CommSend(msg1)
  222. msg1.Fd16 = "2021"
  223. msg1.Fd20 = record.AccNo ? "2" : record.IdNo ? "1" : ""
  224. msg1.Fd30 = record.IdNo
  225. msg1.Fd31 = record.AccNo
  226. msg1.Fd28 = LoginUserInfo.TellerNo
  227. msg1.Fd32 = LoginUserInfo.TellerName
  228. msg1.Fd23 = "3"
  229. const ServerTime = TradeHandle.GetServerTime().replace(/-|:| /g, "")
  230. msg1.Fd33 = ServerTime
  231. msg1.Fd29 = LoginUserInfo.KinbrNo
  232. msg1.Fd25 = `${page.TradeModel.Name}(${page.TradeModel.Code})`
  233. msg1.Fd37 = record.Amt || "0.00"
  234. msg1.Fd26 = record.Name
  235. msg1.Fd24 = "1"
  236. msg1.Fd38 = page.TradeInfo.SerialNumber
  237. msg1.Fd27 = LoginUserInfo.KinbrName.includes("银行")
  238. ? LoginUserInfo.KinbrName.split("银行")[1]
  239. : LoginUserInfo.KinbrName
  240. page.CallAgn(msg1)
  241. if (msg1.Fd12 !== "0000") {
  242. page.TradeAPIs.ShowInfoMessageBox(`${page.GetError(msg1)}\n,微信评价推送失败!`)
  243. } else {
  244. page.TradeAPIs.ShowInfoMessageBox("微信评价推送成功!")
  245. }
  246. }
  247. /**
  248. * 触发通用的打印流程,包含检查和预处理
  249. */
  250. public static RaisePrint(page: PageBase, message: Message, printList: PrintContainer[]): boolean {
  251. if (!page || !message || !printList) return false
  252. const pl: PrintContainer[] = []
  253. const printAttr = page.GetPrintAttributes()
  254. if (message.Fd4) {
  255. printAttr.SerialNumber = page.CreateTellerSerialNumber(printAttr.SystemSerialNumber)
  256. printAttr.BusinessTransaction = message.Fd4
  257. if (printAttr.BusinessTransaction === "000000000" && message.CustomizeTransitEntry?.SerialNo) {
  258. printAttr.BusinessTransaction = message.CustomizeTransitEntry.SerialNo
  259. }
  260. }
  261. for (const item of printList) {
  262. PrintContainerExt.SetPrintElement(item, printAttr)
  263. const printfee = item as IPrintFeeContract
  264. const print = item as IPrintContract
  265. if (!print || !print.PrintData) {
  266. pl.push(item)
  267. } else {
  268. print.PrintData.LoadData(page, message)
  269. try {
  270. if (item.DocumentId === "TellerSystem.Controls.Ext.PrintsHelper.Print_Fee") {
  271. const msg = new Message()
  272. page.TradeAPIs.CommSend(msg)
  273. msg.Fd16 = "9550"
  274. msg.Fd4 = message.Fd4
  275. page.TradeAPIs.CallServer(msg)
  276. printfee.LoadPrint(msg.FileData)
  277. } else {
  278. print.LoadPrintData()
  279. }
  280. } catch (ex) {
  281. PlatformLogger.SystemErrorInfo("RaisePrintflow:调用LoadPrintData方法发生异常!", ex)
  282. }
  283. if (print.PrintData.IsBatchPrint) {
  284. print.PrintData.BatchList.forEach(x => PrintContainerExt.SetPrintElement(x, printAttr))
  285. pl.push(...print.PrintData.BatchList)
  286. } else {
  287. pl.push(item)
  288. }
  289. }
  290. }
  291. const list = page.TradeAPIs.DoPrintLimit(page.TradeModel.Code, pl)
  292. page.PrintCertificate(list)
  293. return true
  294. }
  295. }
  296. // Vue组件封装
  297. export const useContractManager = () => {
  298. return reactive({
  299. RaiseSubmit: ContractManager.RaiseSubmit,
  300. RaiseAuthorize: ContractManager.RaiseAuthorize,
  301. RaiseRecheck: ContractManager.RaiseRecheck,
  302. RaisePaymentFee: ContractManager.RaisePaymentFee,
  303. RaiseEvaluation: ContractManager.RaiseEvaluation,
  304. RaisePrint: ContractManager.RaisePrint
  305. })
  306. }