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.

248 lines
18 KiB

12 months ago
10 months ago
12 months ago
11 months ago
12 months ago
11 months ago
12 months ago
11 months ago
12 months ago
11 months ago
12 months ago
11 months ago
12 months ago
11 months ago
12 months ago
10 months ago
12 months ago
11 months ago
12 months ago
11 months ago
12 months ago
11 months ago
12 months ago
10 months ago
12 months ago
10 months ago
12 months ago
11 months ago
11 months ago
10 months ago
11 months ago
12 months ago
11 months ago
11 months ago
12 months ago
11 months ago
12 months ago
11 months ago
10 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
10 months ago
11 months ago
12 months ago
10 months ago
12 months ago
11 months ago
12 months ago
  1. USE [FastMoneyPro_Remit]
  2. GO
  3. /****** Object: StoredProcedure [dbo].[mobile_proc_TranHistory] Script Date: 11/24/2023 11:59:29 AM ******/
  4. SET ANSI_NULLS ON
  5. GO
  6. SET QUOTED_IDENTIFIER ON
  7. GO
  8. --Exec [mobile_proc_TranHistory] @flag='tran-history-v2', @userId='kamal@imelondon.co.uk'
  9. /****** Object: StoredProcedure [dbo].[mobile_proc_paidTranHistory] Script Date: 9/6/2018 11:41:36 AM ******/
  10. ALTER PROCEDURE [dbo].[mobile_proc_TranHistory] (@flag VARCHAR(50) = NULL
  11. , @customerId INT = NULL
  12. , @userId VARCHAR(100) = NULL
  13. , @fromDate VARCHAR(50) = NULL
  14. , @toDate VARCHAR(50) = NULL
  15. , @pageSize VARCHAR(50) = 25 --NULL -- add default 5
  16. , @pageNumber VARCHAR(50) = NULL
  17. , @sortBy VARCHAR(50) = NULL
  18. , @sortOrder VARCHAR(50) = NULL)
  19. AS
  20. --#101 mobile changes
  21. -- #710 - Change Paystatus to Transtatus in Transaction Report
  22. -- 713 Show Pending Txn in Transaction Report with Status *PENDING*
  23. -- Direct cancellation for PENDING Status
  24. -- #808 changes for reject transaction
  25. -- #10903 - tran report not showing
  26. -- #12605 - pagination for transaction history
  27. SET NOCOUNT ON;
  28. SET XACT_ABORT ON;
  29. BEGIN TRY
  30. DECLARE @email VARCHAR(100)
  31. ,@mobile VARCHAR(25)
  32. --,@customerId BIGINT
  33. ,@sql VARCHAR(MAX)
  34. ,@table VARCHAR(MAX)
  35. ,@select_field_list VARCHAR(MAX) = ''
  36. ,@extra_field_list VARCHAR(MAX) = ''
  37. ,@sql_filter VARCHAR(MAX) = ''
  38. BEGIN
  39. IF @flag = 'tran-history'
  40. BEGIN
  41. IF EXISTS (
  42. SELECT TOP 1 1
  43. FROM customerMaster(NOLOCK)
  44. WHERE customerId = @customerId
  45. )
  46. BEGIN
  47. SELECT @email = cm.email
  48. ,@mobile = cm.mobile
  49. FROM dbo.customerMaster(NOLOCK) cm
  50. WHERE cm.customerId = @userId
  51. END
  52. ELSE
  53. BEGIN
  54. SELECT @email = cm.email
  55. ,@mobile = cm.mobile
  56. ,@customerId = cm.customerId
  57. FROM dbo.customerMaster(NOLOCK) cm
  58. WHERE cm.username = @userId
  59. OR cm.email = @userId
  60. END
  61. IF @fromDate IS NULL
  62. AND @toDate IS NULL
  63. SET @sql = 'SELECT TOP 7 * FROM (';
  64. ELSE
  65. SET @sql = 'SELECT * FROM (';
  66. -- END
  67. SET @sql = @sql +
  68. 'SELECT
  69. errorCode = ''0''
  70. ,ReceiverName=ReceiverName
  71. ,userId = ReceiverName
  72. ,tranId = rt.id
  73. ,controlNo = dbo.FNADecryptString(rt.controlNo)
  74. ,collAmount = Cast(rt.cAmt as decimal)
  75. ,TranAmount = Cast(rt.tAmt as decimal)
  76. ,collCurr = rt.collCurr
  77. ,payoutAmt = rt.pAmt
  78. ,pCurr = rt.payoutCurr
  79. ,payStatus = CASE WHEN rt.tranStatus=''Cancel'' then ''CANCELLED''
  80. WHEN rt.tranStatus=''Payment'' AND rt.payStatus=''Unpaid'' AND rt.paymentMethod=''Bank Deposit'' THEN ''PENDING''
  81. WHEN rt.tranStatus=''Payment'' AND rt.payStatus=''Unpaid'' AND rt.paymentMethod=''Cash Payment'' THEN ''READY TO COLLECT''
  82. WHEN rt.tranStatus=''Payment'' AND rt.payStatus=''Post'' AND rt.paymentMethod=''Cash Payment'' THEN ''READY TO COLLECT''
  83. WHEN rt.tranStatus=''Payment'' AND rt.payStatus=''Post'' AND rt.paymentMethod=''Bank Deposit'' THEN ''PROCESSING''
  84. else UPPER(rt.tranStatus) end
  85. ,payoutMode = rt.paymentMethod
  86. ,sendDate = CONVERT(varchar(10), rt.createdDate, 120)
  87. ,paidDate = CONVERT(varchar(10), rt.paidDate, 120)
  88. ,PayoutAgent = rt.pBankName
  89. ,PayoutCountry = rt.pcountry
  90. ,DisplayActions = CASE WHEN rt.tranStatus=''Payment'' THEN ''CANCEL''+'',''+''AMEND'' ELSE '''' END
  91. FROM dbo.remitTran(NOLOCK) rt
  92. INNER JOIN dbo.tranSenders s(NOLOCK) on s.tranid = rt.id
  93. WHERE s.customerId=''' + CAST((ISNULL(@customerId,@userId)) AS VARCHAR) + ''''
  94. IF ISNULL(@fromDate, '') <> ''
  95. AND ISNULL(@toDate, '') <> ''
  96. BEGIN
  97. SET @sql = @sql + ' AND rt.createdDate BETWEEN ''' + @fromDate + ''' AND ''' + @toDate + ' 23:59:59'''
  98. END
  99. SET @sql = @sql + ')x ORDER BY x.sendDate desc'
  100. PRINT @userId
  101. PRINT(@sql)
  102. EXEC (@sql)
  103. END
  104. ELSE IF @flag = 'tran-history-v2'
  105. BEGIN
  106. IF EXISTS (SELECT TOP 1
  107. 1
  108. FROM customerMaster(NOLOCK)
  109. WHERE customerId = @customerId)
  110. BEGIN
  111. SELECT
  112. @email = cm.email
  113. ,@mobile = cm.mobile
  114. FROM dbo.customerMaster(NOLOCK) cm
  115. WHERE cm.customerId = @userId
  116. END
  117. ELSE
  118. BEGIN
  119. SELECT
  120. @email = cm.email
  121. ,@mobile = cm.mobile
  122. ,@customerId = cm.customerId
  123. FROM dbo.customerMaster(NOLOCK) cm
  124. WHERE cm.username = @userId
  125. OR cm.email = @userId
  126. END
  127. --IF @fromDate IS NULL
  128. -- AND @toDate IS NULL
  129. -- SET @table = 'SELECT TOP 7 * FROM (';
  130. --ELSE
  131. -- SET @table = 'SELECT * FROM (';
  132. -- END
  133. SET @sortBy = 'createdDate'
  134. SET @sortOrder = 'DESC'
  135. SET @table =
  136. '( SELECT
  137. errorCode = ''0''
  138. ,userId = ReceiverName
  139. ,tranId = rtt.id
  140. ,controlNo = dbo.FNADecryptString(rtt.controlNo)
  141. ,collAmount = Cast(rtt.cAmt as decimal)
  142. ,collCurr = rtt.collCurr
  143. ,TranAmount = Cast(rtt.tAmt as decimal)
  144. ,payoutAmt = rtt.pAmt
  145. ,pCurr = rtt.payoutCurr
  146. ,payStatus = CASE WHEN rtt.tranStatus=''Reject'' then ''DECLINED''
  147. WHEN rtt.tranStatus=''Cancel'' then ''CANCELLED''
  148. WHEN depositType =''ONLINE'' AND rtt.verifiedDate IS NULL THEN ''PENDING''
  149. WHEN depositType in(''ONLINE'',''DEBIT_CARD'') AND rtt.verifiedDate IS NOT NULL THEN ''PROCESSING''
  150. else UPPER(payStatus) end
  151. ,payoutMode = rtt.paymentMethod
  152. ,sendDate = CONVERT(varchar(10), rtt.createdDate, 120)
  153. ,paidDate = CONVERT(varchar(10), rtt.paidDate, 120)
  154. ,PayoutAgent = rtt.pBankName
  155. ,rtt.createdDate
  156. ,DisplayActions = CASE WHEN rtt.tranStatus=''Reject'' THEN '''' WHEN rtt.verifiedDate IS NULL THEN '''' WHEN rtt.approvedDate IS NOT NULL THEN ''CANCEL''+'',''+''AMEND'' ELSE '''' END
  157. FROM dbo.remitTranTemp(NOLOCK) rtt
  158. INNER JOIN dbo.tranSendersTemp ts(NOLOCK) on ts.tranid = rtt.id
  159. WHERE ts.customerId=''' + CAST(@customerId AS VARCHAR) + ''''
  160. IF ISNULL(@fromDate, '') <> ''
  161. AND ISNULL(@toDate, '') <> ''
  162. BEGIN
  163. SET @table = @table + ' AND rtt.createdDate BETWEEN ''' + @fromDate + ''' AND ''' + @toDate + ' 23:59:59'''
  164. END
  165. SET @table = @table + ' UNION ALL ';
  166. SET @table = @table + 'SELECT
  167. errorCode = ''0''
  168. ,userId = ReceiverName
  169. ,tranId = rt.id
  170. ,controlNo = dbo.FNADecryptString(rt.controlNo)
  171. ,collAmount = Cast(rt.cAmt as decimal)
  172. ,collCurr = rt.collCurr
  173. ,TranAmount = Cast(rt.tAmt as decimal)
  174. ,payoutAmt = rt.pAmt
  175. ,pCurr = rt.payoutCurr
  176. ,payStatus = CASE WHEN rt.tranStatus=''Reject'' then ''DECLINED''
  177. WHEN rt.tranStatus=''Cancel'' then ''CANCELLED''
  178. WHEN rt.tranStatus=''paid'' then ''PAID''
  179. WHEN depositType = ''ONLINE'' AND rt.verifiedDate IS NULL THEN ''PENDING''
  180. WHEN depositType in(''ONLINE'',''DEBIT_CARD'') AND rt.verifiedDate IS NOT NULL THEN ''PROCESSING''
  181. else UPPER(payStatus) end
  182. ,payoutMode = rt.paymentMethod
  183. ,sendDate = CONVERT(varchar(10), rt.createdDate, 120)
  184. ,paidDate = CONVERT(varchar(10), rt.paidDate, 120)
  185. ,PayoutAgent = rt.pBankName
  186. ,rt.createdDate
  187. ,DisplayActions = CASE WHEN rt.tranStatus=''Cancel'' THEN ''''
  188. WHEN rt.tranStatus=''paid'' THEN ''''
  189. WHEN rt.approvedDate IS NOT NULL THEN ''CANCEL''+'',''+''AMEND''
  190. ELSE '''' END
  191. FROM dbo.remitTran(NOLOCK) rt
  192. INNER JOIN dbo.tranSenders s(NOLOCK) on s.tranid = rt.id
  193. WHERE s.customerId= s.customerId'
  194. --WHERE s.customerId=''' + CAST(@customerId AS VARCHAR) + ''''
  195. IF ISNULL(@fromDate, '') <> ''
  196. AND ISNULL(@toDate, '') <> ''
  197. BEGIN
  198. SET @table = @table + ' AND rt.createdDate BETWEEN ''' + @fromDate + ''' AND ''' + @toDate + ' 23:59:59'''
  199. END
  200. SET @table = @table + ')x'
  201. SET @sql_filter = ''
  202. SET @select_field_list = 'errorCode,userId,tranId,controlNo,collAmount,collCurr,TranAmount,payoutAmt,pCurr,payStatus,payoutMode,
  203. sendDate, paidDate, PayoutAgent, DisplayActions'
  204. --PRINT (@table)
  205. EXEC dbo.proc_paging @table
  206. ,@sql_filter
  207. ,@select_field_list
  208. ,@extra_field_list
  209. ,@sortBy
  210. ,@sortOrder
  211. ,@pageSize
  212. ,@pageNumber
  213. RETURN
  214. END
  215. END
  216. END TRY
  217. BEGIN CATCH
  218. IF @@trancount > 0
  219. ROLLBACK TRANSACTION
  220. DECLARE @errorMessage VARCHAR(MAX)
  221. SET @errorMessage = ERROR_MESSAGE();
  222. SELECT
  223. '1' ErrorCode
  224. ,@errorMessage Msg
  225. ,NULL ID
  226. END CATCH