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.

85 lines
2.5 KiB

1 year ago
  1. SET QUOTED_IDENTIFIER ON
  2. SET ANSI_NULLS ON
  3. GO
  4. IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[mobile_proc_TranHistory]') AND type in (N'P', N'PC'))
  5. DROP PROCEDURE [dbo].[mobile_proc_TranHistory]
  6. GO
  7. --Exec [mobile_proc_TranHistory] @flag='tran-history', @userId='PRALHADS@GMEREMIT.com'
  8. /****** Object: StoredProcedure [dbo].[mobile_proc_paidTranHistory] Script Date: 9/6/2018 11:41:36 AM ******/
  9. Create PROCEDURE [dbo].[mobile_proc_TranHistory](
  10. @flag VARCHAR(50) = NULL
  11. ,@userId VARCHAR(100) = NULL
  12. ,@fromDate VARCHAR(50) = NULL
  13. ,@toDate VARCHAR(50) = NULL
  14. )
  15. AS
  16. --#101 mobile changes
  17. SET NOCOUNT ON;
  18. SET XACT_ABORT ON;
  19. BEGIN TRY
  20. DECLARE
  21. @email VARCHAR(100)
  22. ,@mobile VARCHAR(25)
  23. ,@customerId BIGINT
  24. ,@sql VARCHAR(MAX)
  25. BEGIN
  26. IF @flag='tran-history'
  27. BEGIN
  28. SELECT
  29. @email=cm.email
  30. ,@mobile=cm.mobile
  31. ,@customerId = cm.customerId
  32. FROM dbo.customerMaster(NOLOCK) cm
  33. WHERE cm.mobile=@userId OR cm.email=@userId
  34. SET @sql=
  35. 'SELECT
  36. errorCode = ''0''
  37. ,userId = ReceiverName
  38. ,tranId = rt.id
  39. ,controlNo = dbo.FNADecryptString(rt.controlNo)
  40. ,collAmount = Cast(rt.cAmt as decimal)
  41. ,collCurr = rt.collCurr
  42. ,payoutAmt = rt.pAmt
  43. ,pCurr = rt.payoutCurr
  44. ,payStatus = CASE WHEN rt.tranStatus=''Cancel'' then ''Cancelled''
  45. WHEN rt.tranStatus=''Payment'' AND rt.payStatus=''Post'' AND rt.paymentMethod=''Cash Payment'' THEN ''Ready To Collect''
  46. WHEN rt.tranStatus=''Payment'' AND rt.payStatus=''Post'' AND rt.paymentMethod=''Bank Deposit'' THEN ''Processing''
  47. else rt.payStatus end
  48. ,payoutMode = rt.paymentMethod
  49. ,sendDate = CONVERT(varchar(10), rt.createdDate, 120)
  50. ,paidDate = CONVERT(varchar(10), rt.paidDate, 120)
  51. ,PayoutAgent = rt.pBankName
  52. FROM dbo.remitTran(NOLOCK) rt
  53. INNER JOIN dbo.tranSenders s(NOLOCK) on s.tranid = rt.id
  54. WHERE s.customerId='''+CAST(@customerId AS VARCHAR)+''''
  55. IF ISNULL(@fromDate,'') <> '' AND ISNULL(@toDate,'') <> ''
  56. BEGIN
  57. SET @sql=@sql + ' AND rt.createdDate BETWEEN '''+@fromDate+''' AND '''+ @toDate+' 23:59:59'''
  58. END
  59. ELSE
  60. BEGIN
  61. SET @sql = REPLACE(@sql,'SELECT','SELECT TOP 7 ') + ' ORDER BY rt.createdDate DESC'
  62. END
  63. PRINT(@sql)
  64. EXEC(@sql)
  65. END
  66. END
  67. END TRY
  68. BEGIN CATCH
  69. IF @@TRANCOUNT > 0
  70. ROLLBACK TRANSACTION
  71. DECLARE @errorMessage VARCHAR(MAX)
  72. SET @errorMessage=ERROR_MESSAGE();
  73. SELECT '1' ErrorCode, @errorMessage Msg ,NULL ID
  74. END CATCH
  75. GO