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.

539 lines
18 KiB

1 year ago
  1. USE [FastMoneyPro_Remit]
  2. GO
  3. /****** Object: StoredProcedure [dbo].[proc_payTranHoAPI_v2] Script Date: 7/4/2019 11:35:48 AM ******/
  4. DROP PROCEDURE [dbo].[proc_payTranHoAPI_v2]
  5. GO
  6. /****** Object: StoredProcedure [dbo].[proc_payTranHoAPI_v2] Script Date: 7/4/2019 11:35:48 AM ******/
  7. SET ANSI_NULLS ON
  8. GO
  9. SET QUOTED_IDENTIFIER ON
  10. GO
  11. CREATE PROC [dbo].[proc_payTranHoAPI_v2] (
  12. @flag VARCHAR(50)
  13. ,@controlNo VARCHAR(20) = NULL
  14. ,@user VARCHAR(30) = NULL
  15. ,@agentRefId VARCHAR(20) = NULL
  16. ,@payTokenId VARCHAR(20) = NULL
  17. ,@tranId INT = NULL
  18. ,@sBranchCode VARCHAR(10) = NULL
  19. ,@sAgentCode VARCHAR(10) = NULL
  20. ,@sAgentName VARCHAR(200) = NULL
  21. ,@sBranchName VARCHAR(200) = NULL
  22. ,@txnDate DATETIME = NULL
  23. ,@sFirstName VARCHAR(30) = NULL
  24. ,@sMiddleName VARCHAR(30) = NULL
  25. ,@sLastName1 VARCHAR(30) = NULL
  26. ,@sLastName2 VARCHAR(30) = NULL
  27. ,@sMemId VARCHAR(30) = NULL
  28. ,@sId BIGINT = NULL
  29. ,@sCountry VARCHAR(50) = NULL
  30. ,@sAddress VARCHAR(100) = NULL
  31. ,@sCity VARCHAR(50) = NULL
  32. ,@sMobile VARCHAR(20) = NULL
  33. ,@sIdType VARCHAR(30) = NULL
  34. ,@sIdNo VARCHAR(30) = NULL
  35. ,@sIdValidDate VARCHAR(50) = NULL
  36. ,@sAddress1 VARCHAR(100) = NULL
  37. ,@sAddress2 VARCHAR(100) = NULL
  38. ,@sTranId VARCHAR(50) = NULL
  39. ,@rFirstName VARCHAR(30) = NULL
  40. ,@rMiddleName VARCHAR(30) = NULL
  41. ,@rLastName1 VARCHAR(30) = NULL
  42. ,@rLastName2 VARCHAR(30) = NULL
  43. ,@rMemId VARCHAR(30) = NULL
  44. ,@rId BIGINT = NULL
  45. ,@rCountry VARCHAR(50) = NULL
  46. ,@rAddress VARCHAR(100) = NULL
  47. ,@rCity VARCHAR(50) = NULL
  48. ,@rMobile VARCHAR(30) = NULL
  49. ,@rContactNo VARCHAR(50) = NULL
  50. ,@tAmt MONEY = NULL
  51. ,@cAmt MONEY = NULL
  52. ,@collCurr VARCHAR(3) = NULL
  53. ,@serviceCharge MONEY = NULL
  54. ,@custRate MONEY = NULL
  55. ,@sAgentComm MONEY = NULL
  56. ,@payoutAmt MONEY = NULL
  57. ,@payoutCurr VARCHAR(3) = NULL
  58. ,@paymentType VARCHAR(30) = NULL
  59. ,@sLocation INT = NULL
  60. ,@pLocation INT = NULL
  61. ,@sendUser VARCHAR(50) = NULL
  62. ,@rIdType VARCHAR(30) = NULL
  63. ,@rIdNumber VARCHAR(30) = NULL
  64. ,@rPlaceOfIssue VARCHAR(50) = NULL
  65. ,@rIssuedDate DATETIME = NULL
  66. ,@rValidDate DATETIME = NULL
  67. ,@rRelationType VARCHAR(50) = NULL
  68. ,@rRelativeName VARCHAR(100) = NULL
  69. ,@msgType CHAR(1) = NULL
  70. ,@sql VARCHAR(MAX) = NULL
  71. ,@pBranch INT = NULL
  72. ,@pBranchName VARCHAR(100) = NULL
  73. ,@pAgent INT = NULL
  74. ,@pAgentName VARCHAR(100) = NULL
  75. ,@pSuperAgent INT = NULL
  76. ,@pSuperAgentName VARCHAR(100) = NULL
  77. ,@settlingAgent INT = NULL
  78. ,@mapCode VARCHAR(8) = NULL
  79. ,@mapCodeDom VARCHAR(8) = NULL
  80. ,@customerId INT = NULL
  81. ,@fromPayTrnTime VARCHAR(20) = NULL
  82. ,@toPayTrnTime VARCHAR(20) = NULL
  83. ,@extCustomerId VARCHAR(50) = NULL
  84. )
  85. AS
  86. SET NOCOUNT ON
  87. SET XACT_ABORT ON
  88. --CREATE TABLE #tempTicket(postedBy VARCHAR(50), postedDate DATETIME, comment VARCHAR(200))
  89. DECLARE @tempTicket TABLE(postedBy VARCHAR(50), postedDate DATETIME, comment VARCHAR(200))
  90. DECLARE
  91. @code VARCHAR(50)
  92. ,@userName VARCHAR(50)
  93. ,@password VARCHAR(50)
  94. EXEC proc_GetAPI @user OUTPUT,@code OUTPUT, @userName OUTPUT, @password OUTPUT
  95. DECLARE
  96. @sBranch INT
  97. ,@sAgent INT
  98. ,@sSuperAgent INT
  99. ,@sSuperAgentName VARCHAR(100)
  100. ,@pCountry VARCHAR(100)
  101. ,@pState VARCHAR(100)
  102. ,@pDistrict VARCHAR(100)
  103. ,@pLocationBranch INT
  104. ,@deliveryMethod VARCHAR(100)
  105. ,@pAmt MONEY
  106. ,@pAgentComm MONEY
  107. ,@pAgentCommCurrency VARCHAR(3)
  108. ,@pSuperAgentComm MONEY
  109. ,@pSuperAgentCommCurrency VARCHAR(3)
  110. ,@pHubComm MONEY
  111. ,@pHubCommCurrency VARCHAR(3)
  112. ,@collMode INT
  113. ,@sendingCustType INT
  114. ,@receivingCurrency INT
  115. ,@senderId INT
  116. ,@agentType INT
  117. ,@actAsBranchFlag CHAR(1)
  118. ,@tokenId BIGINT
  119. ,@controlNoEncrypted VARCHAR(20)
  120. ,@commCheck MONEY
  121. ,@tranType CHAR(1)
  122. DECLARE @pDistrictApi INT, @pDistrictBranch INT
  123. DECLARE
  124. @pCountryId INT = NULL
  125. ,@deliveryMethodId INT = NULL
  126. ,@sCountryId INT = NULL
  127. DECLARE @pAgentCommI MONEY
  128. DECLARE @tranStatus VARCHAR(20) = NULL
  129. SELECT @controlNo = UPPER(LTRIM(RTRIM(@controlNo)))
  130. SELECT @controlNoEncrypted = dbo.FNAEncryptString(@controlNo)
  131. IF @flag = 'payDom' --Domestic Pay For API
  132. BEGIN
  133. --Parameters Necessary: @pBranch, @sBranchCode, @controlNo, @agentRefId, @paymentType, @sCountry, @rIdType, @rIdNumber, @rPlaceOfIssue, @rRelativeName, @rMobile, @cAmt, @payoutAmt, @serviceCharge
  134. DECLARE @lockedBy VARCHAR(50)
  135. IF @user IS NULL
  136. BEGIN
  137. EXEC proc_errorHandler 1, 'Your session has expired. Please relogin to the system.', @controlNo
  138. RETURN
  139. END
  140. SELECT
  141. @tranId = id
  142. ,@deliveryMethod = paymentMethod
  143. ,@sCountry = sCountry
  144. ,@sBranch = sBranch
  145. ,@payoutAmt = pAmt
  146. ,@pLocation = pLocation
  147. ,@tranStatus = tranStatus
  148. ,@lockedBy = lockedBy
  149. FROM remitTran WITH(NOLOCK) WHERE controlNo = @controlNoEncrypted
  150. SELECT @pLocationBranch = agentLocation FROM agentMaster WITH(NOLOCK) WHERE agentId = @pBranch
  151. IF @tranStatus IS NULL
  152. BEGIN
  153. EXEC proc_errorHandler 1, 'Cannot post transaction for invalid transaction number', NULL
  154. RETURN
  155. END
  156. IF EXISTS(SELECT 'X' FROM remitTran WITH(NOLOCK) WHERE controlNo = @controlNoEncrypted AND sBranch = @pBranch)
  157. BEGIN
  158. EXEC proc_errorHandler 1, 'Cannot process for same POS', @controlNoEncrypted
  159. RETURN
  160. END
  161. IF (@tranStatus = 'CancelRequest')
  162. BEGIN
  163. EXEC proc_errorHandler 1, 'Transaction has been requested for cancel', @controlNoEncrypted
  164. RETURN
  165. END
  166. IF (@tranStatus = 'Block')
  167. BEGIN
  168. EXEC proc_errorHandler 1, 'Transaction is blocked. Please Contact HO', @controlNoEncrypted
  169. RETURN
  170. END
  171. IF (@tranStatus = 'Paid')
  172. BEGIN
  173. EXEC proc_errorHandler 1, 'Transaction has already been paid', @controlNoEncrypted
  174. RETURN
  175. END
  176. IF (@tranStatus = 'Hold')
  177. BEGIN
  178. EXEC proc_errorHandler 1, 'Transaction is hold', @controlNoEncrypted
  179. RETURN
  180. END
  181. IF (@tranStatus = 'Cancel')
  182. BEGIN
  183. EXEC proc_errorHandler 1, 'Transaction is cancelled', @controlNoEncrypted
  184. RETURN
  185. END
  186. IF @tranStatus <> 'Lock'
  187. BEGIN
  188. EXEC proc_errorHandler 1, 'Your time for paying this transaction has expired. Please try again after a while.', @controlNoEncrypted
  189. RETURN
  190. END
  191. IF @lockedBy <> @user
  192. BEGIN
  193. EXEC proc_errorHandler 1, 'You are not authorised to pay this transaction at this time. Please try again after a while', @controlNoEncrypted
  194. RETURN
  195. END
  196. --Location Verfication---------------------------------------------------------------------------------------
  197. SELECT @pDistrictApi = districtId FROM apiLocationMapping WITH(NOLOCK) WHERE apiDistrictCode = @pLocation
  198. SELECT @pDistrictBranch = districtId FROM apiLocationMapping WITH(NOLOCK) WHERE apiDistrictCode = @pLocationBranch
  199. IF @pDistrictApi IS NULL
  200. BEGIN
  201. EXEC proc_errorHandler 1, 'Location not found. Please Contact HO', @controlNo
  202. RETURN
  203. END
  204. IF @pDistrictBranch IS NULL
  205. BEGIN
  206. EXEC proc_errorHandler 1, 'Location not found. Please Contact HO', @controlNo
  207. RETURN
  208. END
  209. IF @pDistrictApi <> @pDistrictBranch
  210. BEGIN
  211. EXEC proc_errorHandler 1, 'You are not allowed to pay this TXN. It is not within your district.', @controlNo
  212. RETURN
  213. END
  214. --End of Location Verification
  215. DECLARE @userId INT, @payPerTxn MONEY, @payPerDay MONEY, @payTodays MONEY
  216. SELECT @userId = userId FROM applicationUsers WITH(NOLOCK) WHERE userName = @user AND ISNULL(isDeleted, 'N') = 'N'
  217. SELECT @payPerDay = payPerDay, @payPerTxn = payPerTxn, @payTodays = ISNULL(payTodays, 0) FROM userWiseTxnLimit WITH(NOLOCK) WHERE userId = @userId AND ISNULL(isDeleted, 'N') = 'N'
  218. IF(@payoutAmt > @payPerTxn)
  219. BEGIN
  220. EXEC proc_errorHandler 1, 'Transfer Amount exceeds user per Pay Transaction Limit.', @controlNoEncrypted
  221. RETURN
  222. END
  223. IF(@payTodays > @payPerDay)
  224. BEGIN
  225. EXEC proc_errorHandler 1, 'User Per Day Pay Transaction Limit exceeded.', @controlNoEncrypted
  226. RETURN
  227. END
  228. --Payout
  229. SELECT
  230. @agentType = agentType, @pAgent = parentId, @pBranchName = agentName
  231. ,@pState = agentState, @pDistrict = agentDistrict
  232. ,@mapCode = mapCodeInt, @mapCodeDom = mapCodeDom
  233. FROM agentMaster WITH(NOLOCK) WHERE agentId = @pBranch
  234. --Check for branch or agent acting as branch
  235. IF @agentType = 2903 --Agent
  236. BEGIN
  237. SET @pAgent = @pBranch
  238. END
  239. SELECT @pSuperAgent = parentId, @pAgentName = agentName FROM agentMaster WITH(NOLOCK) WHERE agentId = @pAgent
  240. SELECT @pSuperAgentName = agentName FROM agentMaster WITH(NOLOCK) WHERE agentId = @pSuperAgent
  241. --Commission Calculation Start
  242. SELECT @deliveryMethodId = serviceTypeId FROM serviceTypeMaster WITH(NOLOCK) WHERE typeTitle = @deliveryMethod AND ISNULL(isDeleted, 'N') = 'N'
  243. SELECT @pCountryId = 151
  244. SELECT @sCountryId = 151
  245. SELECT
  246. @pAgentComm = ISNULL(pAgentComm, 0)
  247. ,@pAgentCommI = ISNULL(pAgentComm, 0)
  248. ,@pSuperAgentComm = ISNULL(psAgentComm, 0)
  249. ,@commCheck = pAgentComm
  250. FROM dbo.FNAGetDomesticPayComm(@sBranch, @pBranch, @deliveryMethodId, @payoutAmt)
  251. SELECT @pAgentCommCurrency = 'NPR', @pSuperAgentCommCurrency = 'NPR'
  252. IF @commCheck IS NULL
  253. BEGIN
  254. EXEC proc_errorHandler 1, 'Commission not defined. Please contact HO', @controlNo
  255. RETURN
  256. END
  257. BEGIN TRANSACTION
  258. ------Update Transaction Record
  259. UPDATE remitTran SET
  260. pAgentComm = @pAgentComm
  261. ,pAgentCommCurrency = @pAgentCommCurrency
  262. ,pSuperAgentComm = @pSuperAgentComm
  263. ,pSuperAgentCommCurrency = @pSuperAgentCommCurrency
  264. ,pHubComm = @pHubComm
  265. ,pHubCommCurrency = @pHubCommCurrency
  266. ,pBranch = @pBranch
  267. ,pBranchName = @pBranchName
  268. ,pAgent = @pAgent
  269. ,pAgentName = @pAgentName
  270. ,pSuperAgent = @pSuperAgent
  271. ,pSuperAgentName = @pSuperAgentName
  272. ,pCountry = @pCountry
  273. ,pState = @pState
  274. ,pLocation = @pLocation
  275. ,pDistrict = @pDistrict
  276. ,tranStatus = 'Paid'
  277. ,payStatus = 'Paid'
  278. ,paidDate = dbo.FNAGetDateInNepalTZ()
  279. ,paidDateLocal = dbo.FNAGetDateInNepalTZ()
  280. ,paidBy = @user
  281. WHERE controlNo = @controlNoEncrypted
  282. --6.Update receiver identification details--------------------------------------------------------------
  283. SELECT @tranId = id FROM remitTran WITH(NOLOCK) WHERE controlNo = @controlNoEncrypted
  284. UPDATE tranReceivers SET
  285. idType2 = @rIdType
  286. ,idNumber2 = @rIdNumber
  287. ,issuedDate2 = @rIssuedDate
  288. ,validDate2 = @rValidDate
  289. ,idPlaceOfIssue2 = @rPlaceOfIssue
  290. ,mobile = @rMobile
  291. ,homePhone = @rContactNo
  292. ,relationType = @rRelationType
  293. ,relativeName = @rRelativeName
  294. WHERE tranId = @tranId
  295. EXEC FastMoneyPro_account.dbo.PROC_REMIT_DATA_UPDATE
  296. @flag = 'p'
  297. ,@mapCode = @mapCodeDom
  298. ,@user = @user
  299. ,@pAgentComm = @pAgentComm
  300. ,@controlNo = @controlNo
  301. --INSERT INTO domesticPayQueueList(controlNo, controlNoSwiftEnc, controlNoInficareEnc)
  302. --SELECT @controlNo, @controlNoEncrypted, dbo.encryptDbLocal(@controlNo)
  303. IF @@TRANCOUNT > 0
  304. COMMIT TRANSACTION
  305. EXEC [proc_errorHandler] 0, 'Transaction has been paid successfully', @controlNo
  306. END
  307. ELSE IF @flag = 'paySearchDom' --Domestic API call For Pay
  308. BEGIN
  309. --Necessary Parameters: @pBranch, @user
  310. IF @pBranch IS NULL
  311. BEGIN
  312. EXEC proc_errorHandler 1, 'Please Choose Agent', NULL
  313. RETURN
  314. END
  315. SELECT @mapCodeDom = mapCodeDom FROM agentMaster WITH(NOLOCK) WHERE agentId = @pBranch
  316. IF (@mapCodeDom IS NULL OR @mapCodeDom = '' OR @mapCodeDom = 0)
  317. BEGIN
  318. EXEC proc_errorHandler 1, 'Invalid Map Code', NULL
  319. RETURN
  320. END
  321. SELECT @tranStatus = tranStatus, @tranId = id FROM remitTran WITH(NOLOCK) WHERE controlNo = @controlNoEncrypted
  322. IF @tranStatus IS NULL
  323. BEGIN
  324. EXEC proc_errorHandler 1000, 'Transaction not found', NULL
  325. RETURN
  326. END
  327. SELECT @agentType = agentType, @pLocation = agentLocation FROM agentMaster WITH(NOLOCK) WHERE agentId = @pBranch
  328. IF @agentType = 2903 --Agent
  329. BEGIN
  330. SET @pAgent = @pBranch
  331. END
  332. IF @tranStatus IS NOT NULL
  333. BEGIN
  334. INSERT INTO tranViewHistory(
  335. controlNumber
  336. ,tranViewType
  337. ,agentId
  338. ,createdBy
  339. ,createdDate
  340. ,tranId
  341. )
  342. SELECT
  343. @controlNoEncrypted
  344. ,'PAY'
  345. ,@pBranch
  346. ,@user
  347. ,GETDATE()
  348. ,@tranId
  349. SET @payTokenId = SCOPE_IDENTITY()
  350. IF EXISTS(SELECT 'X' FROM remitTran WITH(NOLOCK) WHERE controlNo = @controlNoEncrypted AND paymentMethod = 'Bank Deposit')
  351. BEGIN
  352. EXEC proc_errorHandler 1, 'Cannot process payment for Payment Type Bank Deposit', NULL
  353. RETURN
  354. END
  355. IF EXISTS(SELECT 'X' FROM remitTran WHERE controlNo = @controlNoEncrypted AND sBranch = @pBranch)
  356. BEGIN
  357. EXEC proc_errorHandler 1, 'Cannot process payment for same POS', @tranId
  358. RETURN
  359. END
  360. IF (@tranStatus = 'CancelRequest')
  361. BEGIN
  362. EXEC proc_errorHandler 1, 'Transaction has been requested for cancel', @controlNoEncrypted
  363. RETURN
  364. END
  365. IF (@tranStatus = 'Lock' )
  366. BEGIN
  367. EXEC proc_errorHandler 1, 'Transaction is locked', @controlNoEncrypted
  368. RETURN
  369. END
  370. IF (@tranStatus = 'Block')
  371. BEGIN
  372. EXEC proc_errorHandler 1, 'Transaction is blocked. Please Contact HO', @controlNoEncrypted
  373. RETURN
  374. END
  375. IF (@tranStatus = 'Paid')
  376. BEGIN
  377. EXEC proc_errorHandler 1, 'Transaction has already been paid', @controlNoEncrypted
  378. RETURN
  379. END
  380. IF (@tranStatus = 'Hold')
  381. BEGIN
  382. EXEC proc_errorHandler 1, 'Transaction is hold', @controlNoEncrypted
  383. RETURN
  384. END
  385. IF (@tranStatus = 'Cancel')
  386. BEGIN
  387. EXEC proc_errorHandler 1, 'Transaction is cancelled', @controlNoEncrypted
  388. RETURN
  389. END
  390. DECLARE @tranDistrictId INT, @payAgentDistrictId INT
  391. SELECT @payAgentDistrictId = districtId FROM apiLocationMapping WHERE apiDistrictCode = @pLocation
  392. SELECT @tranDistrictId = districtId FROM apiLocationMapping WHERE apiDistrictCode = (SELECT pLocation FROM remitTran WITH(NOLOCK) WHERE controlNo = @controlNoEncrypted)
  393. IF @payAgentDistrictId IS NULL
  394. BEGIN
  395. EXEC proc_errorHandler 1, 'Location not found. Please Contact HO', @controlNo
  396. RETURN
  397. END
  398. IF @tranDistrictId IS NULL
  399. BEGIN
  400. EXEC proc_errorHandler 1, 'Location not found. Please Contact HO', @controlNo
  401. RETURN
  402. END
  403. IF(@tranDistrictId <> @payAgentDistrictId)
  404. BEGIN
  405. EXEC proc_errorHandler 1, 'You are not allowed to pay this TXN. It is not within your district.', @controlNoEncrypted
  406. RETURN
  407. END
  408. EXEC proc_errorHandler 0, 'Transaction Verification Successful', @tranId
  409. --End of Validation--------------------------------------------------------------------------------------------------
  410. --Select payout details----------------------------------------------------------------------------------------------
  411. SELECT
  412. trn.id
  413. ,controlNo = dbo.FNADecryptString(trn.controlNo)
  414. ,sMemId = sen.membershipId
  415. ,sCustomerId = sen.customerId
  416. ,senderName = sen.firstName + ISNULL( ' ' + sen.middleName, '') + ISNULL( ' ' + sen.lastName1, '') + ISNULL( ' ' + sen.lastName2, '')
  417. ,sCountryName = sen.country
  418. ,sStateName = sen.state
  419. ,sDistrict = sen.district
  420. ,sCity = sen.city
  421. ,sAddress = sen.address
  422. ,sContactNo = COALESCE(sen.mobile, sen.homephone, sen.workphone)
  423. ,sIdType = sen.idType
  424. ,sIdNo = sen.idNumber
  425. ,sValidDate = sen.validDate
  426. ,sEmail = sen.email
  427. ,rMemId = rec.membershipId
  428. ,rCustomerId = rec.customerId
  429. ,receiverName = rec.firstName + ISNULL( ' ' + rec.middleName, '') + ISNULL( ' ' + rec.lastName1, '') + ISNULL( ' ' + rec.lastName2, '')
  430. ,rCountryName = rec.country
  431. ,rStateName = rec.state
  432. ,rDistrict = rec.district
  433. ,rCity = rec.city
  434. ,rAddress = rec.address
  435. ,rContactNo = COALESCE(rec.mobile, rec.homephone, rec.workphone)
  436. ,rIdType = rec.idType
  437. ,rIdNo = rec.idNumber
  438. ,sAgent = trn.sBranchName
  439. ,sAgentCountry = sa.agentCountry
  440. ,pBranchName = ISNULL(trn.pBranchName, 'Any')
  441. ,pCountryName = trn.pCountry
  442. ,pStateName = trn.pState
  443. ,pDistrictName = trn.pDistrict
  444. ,pLocationName = pLoc.districtName
  445. ,pAddress = pa.agentAddress
  446. ,trn.tAmt
  447. ,trn.serviceCharge
  448. ,handlingFee = ISNULL(trn.handlingFee, 0)
  449. ,trn.cAmt
  450. ,trn.pAmt
  451. ,relationship = ISNULL(trn.relWithSender, '-')
  452. ,purpose = ISNULL(trn.purposeOfRemit, '-')
  453. ,sourceOfFund = ISNULL(trn.sourceOfFund, '-')
  454. ,trn.pAmt
  455. ,collMode = trn.collMode
  456. ,paymentMethod = trn.paymentMethod
  457. ,trn.payoutCurr
  458. ,trn.tranStatus
  459. ,trn.payStatus
  460. ,payoutMsg = ISNULL(trn.pMessage, '-')
  461. ,send_agent = COALESCE(trn.sBranchName, trn.sAgentName)
  462. ,txn_date = trn.createdDateLocal
  463. ,payTokenId = @payTokenId
  464. ,tSetFlag = ''
  465. ,eSetFlag = ''
  466. FROM remitTran trn WITH(NOLOCK)
  467. LEFT JOIN tranSenders sen WITH(NOLOCK) ON trn.id = sen.tranId
  468. LEFT JOIN tranReceivers rec WITH(NOLOCK) ON trn.id = rec.tranId
  469. LEFT JOIN agentMaster sa WITH(NOLOCK) ON trn.sBranch = sa.agentId
  470. LEFT JOIN agentMaster pa WITH(NOLOCK) ON trn.pBranch = pa.agentId
  471. LEFT JOIN api_districtList pLoc WITH(NOLOCK) ON trn.pLocation = pLoc.districtCode
  472. WHERE trn.controlNo = @controlNoEncrypted
  473. --End of Select payout details--------------------------------------------------------------------------------------
  474. --Lock Transaction--------------------------------------------------------------------------------------------------
  475. UPDATE remitTran SET
  476. payTokenId = @payTokenId
  477. ,tranStatus = 'Lock'
  478. ,lockedBy = @user
  479. ,lockedDate = GETDATE()
  480. ,lockedDateLocal = GETDATE()
  481. WHERE controlNo = @controlNoEncrypted
  482. --End of Lock Transaction--------------------------------------------------------------------------------------------
  483. --Log Details-------------------------------------------------------------------------------------------------------
  484. SELECT
  485. [message]
  486. --,createdBy = au.firstName + ISNULL( ' ' + au.middleName, '') + ISNULL( ' ' + au.lastName, '')
  487. ,trn.createdBy
  488. ,trn.createdDate
  489. FROM tranModifyLog trn WITH(NOLOCK)
  490. WHERE trn.tranId = @tranId OR ISNULL(trn.controlNo,'') = ISNULL(@controlNoEncrypted, '')
  491. ORDER BY trn.createdDate DESC
  492. --End of Log Details------------------------------------------------------------------------------------------------
  493. END
  494. END
  495. GO