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.

499 lines
19 KiB

1 year ago
  1. SET QUOTED_IDENTIFIER ON
  2. SET ANSI_NULLS ON
  3. GO
  4. /**
  5. exec PROC_REPROCESS_HOLD_TXN @flag= 'list'
  6. exec PROC_REPROCESS_HOLD_TXN @flag= 'check_reprocess_req_type', @Agent = '393227', @controlNo = '80579837605'
  7. SELECT * FROM Application_Log.dbo.vwTpApilogs(NOLOCK) WHERE controlNo like '%80551679985%'
  8. */
  9. ALTER PROCEDURE [dbo].[PROC_REPROCESS_HOLD_TXN](
  10. @flag VARCHAR(50) = NULL
  11. ,@User VARCHAR(50) = NULL
  12. ,@controlNo VARCHAR(50) = NULL
  13. ,@controlNo2 VARCHAR(50) = NULL
  14. ,@Agent VARCHAR(50) = NULL
  15. ,@Country VARCHAR(50) = NULL
  16. ,@tranId VARCHAR(50) = NULL
  17. ,@ApproveTxnRequried CHAR(1) = NULL
  18. ,@partnerPin VARCHAR(100) = NULL
  19. ,@PartnerTranId VARCHAR(100) = NULL
  20. )AS
  21. BEGIN
  22. DECLARE @EncryptedControlNo VARCHAR(100)
  23. SET @EncryptedControlNo = dbo.FNAEncryptString(@controlNo)
  24. DECLARE @temptable TABLE ( [ControlNo] varchar(500), [id] bigint, [branch] varchar(500), [country] varchar(500), [senderId] Bigint, [sender] varchar(500), [receiverId] bigint, [receiver] varchar(1000), [amt] Money, [txnDate] datetime, [tranType] varchar(10), [txncreatedBy] varchar(500), [isThirdPartyTran] Bigint, [pAgentName] varchar(500), [Partner] Bigint )
  25. IF @flag = 'list'
  26. BEGIN
  27. INSERT INTO @temptable(
  28. ControlNo,id,branch,country,senderId,sender,receiverId,receiver,amt,txnDate,tranType,txncreatedBy,isThirdPartyTran,pAgentName,Partner
  29. )
  30. SELECT DISTINCT
  31. ControlNo = dbo.fnaDecryptstring(trn.controlNo)
  32. ,trn.id
  33. ,branch = am.agentName
  34. ,country = trn.pCountry
  35. ,senderId = sen.customerId
  36. ,sender = sen.firstName + ISNULL( ' ' + sen.middleName, '') + ISNULL( ' ' + sen.lastName1, '') + ISNULL( ' ' + sen.lastName2, '')
  37. ,receiverId = rec.customerId
  38. ,receiver = rec.firstName + ISNULL( ' ' + rec.middleName, '') + ISNULL( ' ' + rec.lastName1, '') + ISNULL( ' ' + rec.lastName2, '')
  39. ,amt = CAST(trn.cAmt AS DECIMAL(18, 2))
  40. ,txnDate = CAST(trn.createdDate AS DATE)
  41. ,tranType = CASE WHEN sRouteId='w' THEN 'WALLET' WHEN sRouteId='a' THEN 'AUTO-DEBIT' ELSE '-' END
  42. ,txncreatedBy = trn.createdBy
  43. ,CASE WHEN trn.pAgent=1100 OR trn.pAgent = 1043 THEN 1 ELSE 0 END isThirdPartyTran
  44. ,trn.pSuperAgentName AS pAgentName
  45. ,trn.pSuperAgent AS [Partner]
  46. FROM remitTranTemp trn WITH(NOLOCK)
  47. INNER JOIN agentMaster am WITH(NOLOCK) ON trn.sBranch = am.agentId
  48. INNER JOIN tranSendersTemp sen WITH(NOLOCK) ON trn.id = sen.tranId
  49. INNER JOIN tranReceiversTemp rec WITH(NOLOCK) ON trn.id = rec.tranId
  50. WHERE trn.tranStatus IN ('Hold','Compliance Hold','OFAC Hold','OFAC/Compliance Hold') AND
  51. trn.payStatus = 'Unpaid' AND
  52. trn.approvedBy IS NULL
  53. UNION ALL
  54. SELECT DISTINCT
  55. ControlNo = dbo.fnaDecryptstring(trn.controlNo)
  56. ,trn.id
  57. ,branch = am.agentName
  58. ,country = trn.pCountry
  59. ,senderId = sen.customerId
  60. ,sender = sen.firstName + ISNULL( ' ' + sen.middleName, '') + ISNULL( ' ' + sen.lastName1, '') + ISNULL( ' ' + sen.lastName2, '')
  61. ,receiverId = rec.customerId
  62. ,receiver = rec.firstName + ISNULL( ' ' + rec.middleName, '') + ISNULL( ' ' + rec.lastName1, '') + ISNULL( ' ' + rec.lastName2, '')
  63. ,amt = CAST(trn.cAmt AS DECIMAL(18, 2))
  64. ,txnDate = CAST(trn.createdDate AS DATE)
  65. ,tranType = CASE WHEN sRouteId='w' THEN 'WALLET' WHEN sRouteId='a' THEN 'AUTO-DEBIT' ELSE '-' END
  66. ,txncreatedBy = trn.createdBy
  67. ,CASE WHEN trn.pAgent=1100 OR trn.pAgent = 1043 THEN 1 ELSE 0 END isThirdPartyTran
  68. ,trn.pAgentName
  69. ,trn.pSuperAgent AS [Partner]
  70. FROM remitTran trn WITH(NOLOCK)
  71. INNER JOIN agentMaster am WITH(NOLOCK) ON trn.sBranch = am.agentId
  72. INNER JOIN tranSenders sen WITH(NOLOCK) ON trn.id = sen.tranId
  73. INNER JOIN tranReceivers rec WITH(NOLOCK) ON trn.id = rec.tranId
  74. WHERE trn.tranStatus IN ('Hold','Compliance Hold','OFAC Hold','OFAC/Compliance Hold') AND
  75. trn.payStatus = 'Unpaid' AND
  76. trn.approvedBy IS NOT NULL
  77. --601360,392226,
  78. SELECT * FROM @temptable WHERE country = ISNULL(@Country,country) AND [Partner] = ISNULL(@Agent,[Partner]) AND [Partner] IN (393227,590853)
  79. END
  80. IF @flag ='check_reprocess_req_type'
  81. BEGIN
  82. --DECLARE @PartnerTranId VARCHAR(100), @PartnerPin VARCHAR(100)
  83. IF @Agent = '601360' --Exim
  84. BEGIN
  85. DECLARE @EximResponse NVARCHAR(MAX) = NULL, @EximResponseXml XML = NULL
  86. SELECT TOP(1) @EximResponse = responseXml FROM Application_log.dbo.vwTpApiLogs(NOLOCK) WHERE controlNo = @controlNo AND providerName = 'eximBank' ORDER BY rowId DESC
  87. SET @EximResponse = REPLACE(@EximResponse,'<?xml version="1.0" encoding="UTF-8"?>','')
  88. SET @EximResponseXml = @EximResponse
  89. --No sendTxn, only account valadition method called
  90. IF @EximResponse IS NULL
  91. BEGIN
  92. SELECT @Agent AS Agent,'local' AS ReprocessType,NULL AS NextMethod, '' AS PartnerPin, '' AS PartnerTranId, '' AS TranId, @Agent AS payOutPartnerId, @EncryptedControlNo AS EncryptControlNo, 'N' AS ApproveTxnRequried
  93. RETURN
  94. END
  95. --Send Method is called and some error has occured.
  96. IF @EximResponse IS NOT NULL AND @EximResponseXml IS NOT NULL
  97. BEGIN
  98. DECLARE @eximerrTbl TABLE(ErrorCode VARCHAR(100), Msg NVARCHAR(300))
  99. INSERT INTO @eximerrTbl(ErrorCode,Msg)
  100. SELECT MAX(CASE WHEN sn=1 THEN xx.Error ELSE '' END) ErrorCode ,MAX(CASE WHEN sn= 2 THEN xx.Error ELSE '' END ) Msg FROM (
  101. SELECT ROW_NUMBER() OVER (ORDER BY x.error ASC) sn, Error FROM(
  102. SELECT
  103. Error = T.c.value('(.)[1]', 'varchar(MAX)')
  104. FROM @EximResponseXml.nodes('/ResponseMessage/Error/*') T(c)
  105. )x
  106. )xx
  107. IF EXISTS(SELECT 'x' FROM @eximerrTbl WHERE ErrorCode NOT IN ('00','0'))
  108. BEGIN
  109. SELECT @Agent AS Agent,'local' AS ReprocessType,NULL AS NextMethod, '' AS PartnerPin, '' AS PartnerTranId, '' AS TranId, @Agent AS payOutPartnerId, @EncryptedControlNo AS EncryptControlNo, 'N' AS ApproveTxnRequried
  110. RETURN
  111. END
  112. END
  113. --txn already post success at exim bank
  114. SELECT @Agent AS Agent,'none' AS ReprocessType,NULL AS NextMethod, '' AS PartnerPin, '' AS PartnerTranId, '' AS TranId, @Agent AS payOutPartnerId, @EncryptedControlNo AS EncryptControlNo, 'N' AS ApproveTxnRequried
  115. RETURN
  116. END
  117. IF @Agent = '392226' --bni
  118. BEGIN
  119. DECLARE @bniResponse NVARCHAR(MAX) = NULL, @bniResponseXml XML = NULL
  120. SELECT TOP(1) @bniResponse = responseXml FROM Application_log.dbo.vwTpApiLogs(NOLOCK)
  121. WHERE controlNo = @controlNo AND providerName = 'BNI' AND methodName = 'processPO' ORDER BY rowId DESC
  122. SET @bniResponse = REPLACE(@bniResponse,'<?xml version="1.0" encoding="UTF-8"?>','')
  123. SET @bniResponseXml = @bniResponse
  124. --No sendTxn api called
  125. IF @bniResponse IS NULL
  126. BEGIN
  127. SELECT @Agent AS Agent,'local' AS ReprocessType,NULL AS NextMethod, '' AS PartnerPin, '' AS PartnerTranId, '' AS TranId, @Agent AS payOutPartnerId, @EncryptedControlNo AS EncryptControlNo, 'N' AS ApproveTxnRequried
  128. RETURN
  129. END
  130. --Send Method is called and some error has occured.
  131. IF @bniResponse IS NOT NULL AND @bniResponseXml IS NOT NULL
  132. BEGIN
  133. DECLARE @bnierrTbl TABLE(ErrorCode VARCHAR(100), Msg NVARCHAR(300))
  134. INSERT INTO @bnierrTbl(ErrorCode,Msg)
  135. SELECT MAX(CASE WHEN sn=1 THEN xx.Error ELSE '' END) ErrorCode ,MAX(CASE WHEN sn= 2 THEN xx.Error ELSE '' END ) Msg FROM (
  136. SELECT ROW_NUMBER() OVER (ORDER BY x.error ASC) sn, Error FROM(
  137. SELECT
  138. Error = T.c.value('(.)[1]', 'varchar(MAX)')
  139. FROM @bniResponseXml.nodes('/DbResponse/*') T(c)
  140. )x WHERE x.Error <> ''
  141. )xx
  142. IF EXISTS(SELECT 'x' FROM @bnierrTbl)
  143. BEGIN
  144. SELECT @Agent AS Agent,'local' AS ReprocessType,NULL AS NextMethod, '' AS PartnerPin, '' AS PartnerTranId, '' AS TranId, @Agent AS payOutPartnerId, @EncryptedControlNo AS EncryptControlNo, 'N' AS ApproveTxnRequried
  145. RETURN
  146. END
  147. END
  148. SELECT @Agent AS Agent,'none' AS ReprocessType,NULL AS NextMethod, '' AS PartnerPin, '' AS PartnerTranId, '' AS TranId, @Agent AS payOutPartnerId, @EncryptedControlNo AS EncryptControlNo, 'N' AS ApproveTxnRequried
  149. RETURN
  150. END
  151. IF @Agent = '393227' --contact
  152. BEGIN
  153. DECLARE @newOutGoingResponse NVARCHAR(MAX), @payOutGoingResponse NVARCHAR(MAX)
  154. DECLARE @newOutGoingResponseXml XML, @payOutGoingResponseXml XML
  155. SELECT
  156. TOP (1) @newOutGoingResponse = responseXml
  157. FROM Application_Log.dbo.vwTpApilogs(NOLOCK)
  158. WHERE controlNo = @controlNo AND methodName = 'NewOutgoing' ORDER BY rowId DESC
  159. SET @newOutGoingResponseXml = @newOutGoingResponse
  160. SELECT
  161. TOP(1) @payOutGoingResponse = responseXml
  162. FROM Application_Log.dbo.vwTpApilogs(NOLOCK)
  163. WHERE controlNo = @controlNo AND methodName = 'PayOutgoing' ORDER BY rowId DESC
  164. SET @payOutGoingResponseXml = @payOutGoingResponse
  165. DECLARE @NewOutGoingErr VARCHAR(MAX) = NULL, @NewGoingErrCode VARCHAR(200) = NULL
  166. SELECT @PartnerPin = DocId, @PartnerTranId = DocId, @NewOutGoingErr= x.Error, @NewGoingErrCode = x.ErrorCode FROM (
  167. SELECT
  168. T.c.value('@ERR_TEXT', 'varchar(MAX)') AS Error
  169. ,T.c.value('@RE', 'varchar(MAX)') AS ErrorCode
  170. ,T.c.value('@ID', 'varchar(MAX)') AS DocId
  171. ,T.c.value('@trnReference', 'varchar(MAX)') AS ControlNo
  172. FROM @newOutGoingResponseXml.nodes('/RESPONSE') T(c)
  173. )x --WHERE x.ControlNo = @controlNo
  174. --Remote call for reprocess when payoutgoing is called
  175. PRINT 'Remote call for reprocess when payoutgoing is called'
  176. IF @payOutGoingResponse IS NOT NULL AND @newOutGoingResponse IS NOT NULL
  177. BEGIN
  178. DECLARE @PayOutGoingErr VARCHAR(MAX) = NULL, @PayoutGoingErrCode VARCHAR(200) = NULL
  179. --Get payoutgoing error
  180. SELECT
  181. @PayOutGoingErr = T.c.value('@ERR_TEXT', 'varchar(MAX)')
  182. ,@PayoutGoingErrCode= T.c.value('@RE', 'varchar(MAX)')
  183. FROM @payOutGoingResponseXml.nodes('/RESPONSE') T(c)
  184. --If Error is null ie. No valid xml in PayoutGoing response
  185. PRINT 'If Error is null ie. No valid xml in PayoutGoing response'
  186. IF @PayOutGoingErr IS NULL AND @PayoutGoingErrCode IS NULL
  187. BEGIN
  188. --Can reporcess the txn
  189. PRINT 'Can reporcess the txn'
  190. IF @PartnerPin IS NOT NULL
  191. BEGIN
  192. SELECT
  193. @Agent AS Agent
  194. ,'remote' AS ReprocessType
  195. ,'reprocess' AS NextMethod
  196. ,@PartnerPin AS PartnerPin
  197. ,@PartnerTranId AS PartnerTranId
  198. ,id AS TranId
  199. ,@Agent AS payOutPartnerId
  200. ,'Contact' AS [Partner]
  201. , @EncryptedControlNo AS EncryptControlNo
  202. , 'N' AS ApproveTxnRequried
  203. ,'http://contact.gmeremit.com.kr:7006/Contact' AS BaseUrl, '0D9FB8DC-DCA6-44D5-A1C0-01F4531936B2' AS [Authorization],@controlNo AS ControlNo
  204. FROM dbo.remitTran(NOLOCK) WHERE controlNo = @EncryptedControlNo --AND id = @TranId
  205. RETURN
  206. END
  207. END
  208. --Ther is error and valid xml response in payOutGoing response
  209. PRINT 'Ther is error and valid xml response in payOutGoing response'
  210. IF @PayOutGoingErr IS NOT NULL AND (@PayoutGoingErrCode IS NOT NULL AND @PayoutGoingErrCode <> '0')
  211. BEGIN
  212. IF @PartnerPin IS NOT NULL
  213. BEGIN
  214. SELECT
  215. @Agent AS Agent
  216. ,'remote' AS ReprocessType
  217. ,'reprocess' AS NextMethod
  218. ,@PartnerPin AS PartnerPin
  219. ,@PartnerTranId AS PartnerTranId
  220. ,id AS TranId
  221. ,@Agent AS payOutPartnerId
  222. ,'Contact' AS [Partner]
  223. , @EncryptedControlNo AS EncryptControlNo
  224. , 'N' AS ApproveTxnRequried
  225. ,'http://contact.gmeremit.com.kr:7006/Contact' AS BaseUrl, '0D9FB8DC-DCA6-44D5-A1C0-01F4531936B2' AS [Authorization],@controlNo AS ControlNo
  226. FROM dbo.remitTran(NOLOCK) WHERE controlNo = @EncryptedControlNo --AND id = @TranId
  227. RETURN
  228. END
  229. END
  230. END
  231. --Remote call for reprocess when newOutGoing only is called
  232. PRINT 'Remote call for reprocess when newOutGoing only is called'
  233. IF @payOutGoingResponse IS NULL AND @newOutGoingResponse IS NOT NULL
  234. BEGIN
  235. --DocId is available go reprocess the txn
  236. PRINT 'DocId is available go reprocess the txn'
  237. IF @PartnerPin IS NOT NULL
  238. BEGIN
  239. SELECT
  240. @Agent AS Agent
  241. ,'remote' AS ReprocessType
  242. ,'reprocess' AS NextMethod
  243. ,@PartnerPin AS PartnerPin
  244. ,@PartnerTranId AS PartnerTranId
  245. ,id AS TranId
  246. ,@Agent AS payOutPartnerId
  247. ,'Contact' AS [Partner]
  248. ,@EncryptedControlNo AS EncryptControlNo
  249. , 'N' AS ApproveTxnRequried
  250. ,'http://contact.gmeremit.com.kr:7006/Contact' AS BaseUrl, '0D9FB8DC-DCA6-44D5-A1C0-01F4531936B2' AS [Authorization],@controlNo AS ControlNo
  251. FROM dbo.remitTran(NOLOCK) WHERE controlNo = @EncryptedControlNo --AND id = @TranId
  252. RETURN
  253. END
  254. PRINT @NewGoingErrCode
  255. PRINT @TranId
  256. PRINT @EncryptedControlNo
  257. IF @PartnerPin IS NULL AND @NewGoingErrCode IN ('-6121')
  258. BEGIN
  259. SELECT
  260. @Agent AS Agent
  261. ,'local' AS ReprocessType
  262. ,'cancelLocal' AS NextMethod
  263. ,'' AS PartnerPin
  264. ,'' AS PartnerTranId
  265. ,id AS TranId
  266. ,@Agent AS payOutPartnerId
  267. ,'Contact' AS [Partner]
  268. ,@EncryptedControlNo AS EncryptControlNo
  269. , 'N' AS ApproveTxnRequried
  270. ,'' AS BaseUrl, '' AS [Authorization],@controlNo AS ControlNo
  271. FROM dbo.remitTran(NOLOCK) WHERE controlNo = @EncryptedControlNo --AND id = @TranId
  272. RETURN
  273. END
  274. ---Only new out going has been called with error on response
  275. IF @PartnerPin IS NULL
  276. BEGIN
  277. PRINT 'Only new out going has been called with error on response'
  278. SELECT
  279. @Agent AS Agent
  280. ,'local' AS ReprocessType
  281. ,'sendTransaction' AS NextMethod
  282. ,'' AS PartnerPin
  283. ,'' AS PartnerTranId
  284. ,id AS TranId
  285. ,@Agent AS payOutPartnerId
  286. ,'Contact' AS [Partner]
  287. ,@EncryptedControlNo AS EncryptControlNo
  288. , 'N' AS ApproveTxnRequried,'' AS BaseUrl, '' AS [Authorization],@controlNo AS ControlNo
  289. FROM dbo.remitTran(NOLOCK) WHERE controlNo = @EncryptedControlNo --AND id = @TranId
  290. RETURN
  291. END
  292. END
  293. IF @newOutGoingResponse IS NULL AND @payOutGoingResponse IS NULL
  294. BEGIN
  295. SELECT
  296. @Agent AS Agent
  297. ,'local' AS ReprocessType
  298. ,'SendTransaction' AS NextMethod
  299. ,@PartnerPin AS PartnerPin
  300. ,@PartnerTranId AS PartnerTranId
  301. ,id AS TranId
  302. ,@Agent AS payOutPartnerId
  303. ,'Contact' AS [Partner]
  304. ,@EncryptedControlNo AS EncryptControlNo
  305. , 'N' AS ApproveTxnRequried ,'' AS BaseUrl, '' AS [Authorization],@controlNo AS ControlNo
  306. FROM dbo.remitTran(NOLOCK) WHERE controlNo = @EncryptedControlNo
  307. RETURN
  308. END
  309. SELECT
  310. @Agent AS Agent
  311. ,'none' AS ReprocessType
  312. ,'sendTransaction' AS NextMethod
  313. ,'' AS PartnerPin
  314. ,'' AS PartnerTranId
  315. ,'' AS TranId
  316. ,@Agent AS payOutPartnerId
  317. ,'Contact' AS [Partner]
  318. ,@EncryptedControlNo AS EncryptControlNo
  319. , 'N' AS ApproveTxnRequried ,'' AS BaseUrl, '' AS [Authorization],@controlNo AS ControlNo
  320. RETURN
  321. END
  322. IF @Agent = '590853' --lyhour
  323. BEGIN
  324. DECLARE @LyhourResponse NVARCHAR(MAX) = NULL, @LyhourResponseJson NVARCHAR(MAX) = NULL
  325. SELECT TOP(1) @LyhourResponse = responseXml FROM Application_log.dbo.vwTpApiLogs(NOLOCK) WHERE controlNo = @controlNo AND providerName = 'Lyhour' ORDER BY rowId DESC
  326. IF @LyhourResponse IS NOT NULL AND @LyhourResponse = 'Null response from Api during placing send money'
  327. BEGIN
  328. SELECT @Agent AS Agent,'remote' AS ReprocessType,'SendTransaction' AS NextMethod, '' AS PartnerPin, '' AS PartnerTranId, '' AS TranId, @Agent AS payOutPartnerId, @EncryptedControlNo AS EncryptControlNo, 'Y' AS ApproveTxnRequried, 'http://lyhour.gmeremit.com.kr:3443/lyhour' AS BaseUrl, '122F15BE-030D-4FA2-98B9-E9FCB581AAA6' AS [Authorization]
  329. RETURN
  330. END
  331. SET @LyhourResponseJson = @LyhourResponse
  332. -- PRINT (@LyhourResponse)
  333. --No sendTxn, process to send to partner via api call
  334. IF @LyhourResponse IS NULL
  335. BEGIN
  336. SELECT @Agent AS Agent,'remote' AS ReprocessType,'SendTransaction' AS NextMethod, '' AS PartnerPin, '' AS PartnerTranId, '' AS TranId, @Agent AS payOutPartnerId, @EncryptedControlNo AS EncryptControlNo, 'Y' AS ApproveTxnRequried, 'http://lyhour.gmeremit.com.kr:3443/lyhour' AS BaseUrl, '122F15BE-030D-4FA2-98B9-E9FCB581AAA6' AS [Authorization]
  337. RETURN
  338. END
  339. IF @LyhourResponse IS NOT NULL
  340. BEGIN
  341. DECLARE @lyErrTbl TABLE(httpStatusCode VARCHAR(100),source VARCHAR(100), [message] VARCHAR(200), innerException VARCHAR(200))
  342. INSERT INTO @lyErrTbl(httpStatusCode,source, [message], innerException)
  343. SELECT
  344. JSON_VALUE(@LyhourResponseJson,'$.httpStatusCode') AS httpStatusCode
  345. ,JSON_VALUE(@LyhourResponseJson,'$.source') AS source
  346. ,JSON_VALUE(@LyhourResponseJson,'$.message[0]') AS [message]
  347. ,JSON_VALUE(@LyhourResponseJson,'$.innerException[0]') AS innerException
  348. IF EXISTS(SELECT 'x' FROM @lyErrTbl WHERE httpStatusCode IS NOT NULL)
  349. BEGIN
  350. SELECT @Agent AS Agent,'remote' AS ReprocessType,'SendTransaction' AS NextMethod, '' AS PartnerPin, '' AS PartnerTranId, '' AS TranId, @Agent AS payOutPartnerId, @EncryptedControlNo AS EncryptControlNo, 'Y' AS ApproveTxnRequried, 'http://lyhour.gmeremit.com.kr:3443/lyhour' AS BaseUrl, '122F15BE-030D-4FA2-98B9-E9FCB581AAA6' AS [Authorization]
  351. RETURN
  352. END
  353. END
  354. END
  355. END
  356. IF @flag = 'reprocess-local'
  357. BEGIN
  358. BEGIN TRAN
  359. UPDATE Application_Log.dbo.ApplicationLogger SET controlNo = controlNo + 'A' WHERE controlNo = @controlNo
  360. UPDATE dbo.remitTran SET tranStatus = 'Payment' WHERE controlNo = @EncryptedControlNo
  361. COMMIT TRAN
  362. IF @@TRANCOUNT = 0
  363. BEGIN
  364. SELECT '0' ErrorCode, 'Reprocessed completed. Please monitor the transaction.' Msg, NULL Id
  365. RETURN
  366. END
  367. SELECT '1' ErrorCode, 'Reprocessed failed.' Msg, NULL Id
  368. RETURN
  369. END
  370. IF @flag = 'reprocess-remote'
  371. BEGIN
  372. IF @ApproveTxnRequried IS NOT NULL AND @ApproveTxnRequried = 'Y'
  373. BEGIN
  374. BEGIN TRAN
  375. DECLARE @holdTranId BIGINT
  376. SELECT @holdTranId = id FROM remitTranTemp(nolock) WHERE controlNo = @EncryptedControlNo
  377. --Put approve logic here
  378. exec [proc_ApproveHoldedTXN] @flag='approve',@user='admin',@id = @holdTranId
  379. UPDATE dbo.remitTran SET
  380. tranStatus = 'Payment',
  381. payStatus='Post',
  382. controlNo2 = dbo.FNAEncryptString(@controlNo),
  383. controlNo = dbo.FNAEncryptString(@partnerPin),
  384. ContNo = @PartnerTranId
  385. WHERE holdTranId = @holdTranId
  386. COMMIT TRAN
  387. IF @@TRANCOUNT = 0
  388. BEGIN
  389. SELECT '0' ErrorCode, 'Reprocessed completed. Please monitor the transaction.' Msg, NULL Id
  390. RETURN
  391. END
  392. END
  393. ELSE
  394. BEGIN
  395. BEGIN TRAN
  396. UPDATE dbo.remitTran SET
  397. tranStatus = 'Payment',
  398. payStatus='Post',
  399. postedBy=@User,
  400. postedDate= GETDATE(),
  401. postedDateLocal=GETDATE(),
  402. ContNo = ISNULL(@PartnerTranId,'')
  403. WHERE controlNo = @EncryptedControlNo
  404. COMMIT TRAN
  405. IF @@TRANCOUNT = 0
  406. BEGIN
  407. SELECT '0' ErrorCode, 'Reprocessed completed. Please monitor the transaction.' Msg, NULL Id
  408. RETURN
  409. END
  410. END
  411. END
  412. IF @flag = 'country'
  413. BEGIN
  414. SELECT countryId,countryName,* FROM dbo.countryMaster(NOLOCK) WHERE isOperativeCountry= 'Y' AND ISNULL(isActive,'Y') = 'Y'
  415. END
  416. IF @flag = 'partner'
  417. BEGIN
  418. SELECT agentId,agentName FROM dbo.agentMaster(NOLOCK) WHERE parentId= '0' AND isActive = 'Y' AND agentId NOT IN (1001,1008,1009)
  419. END
  420. END
  421. GO