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.

174 lines
8.3 KiB

  1. USE [FastMoneyPro_Remit]
  2. GO
  3. /****** Object: StoredProcedure [dbo].[proc_getNotifyInfo] Script Date: 10/19/2023 2:23:18 PM ******/
  4. SET ANSI_NULLS ON
  5. GO
  6. SET QUOTED_IDENTIFIER ON
  7. GO
  8. -- =============================================
  9. -- Author: <Author,,Name>
  10. -- Create date: <Create Date,,>
  11. -- Description: <Description,,>
  12. -- =============================================
  13. ALTER PROCEDURE [dbo].[proc_getNotifyInfo]
  14. -- Add the parameters for the stored procedure here
  15. @rowId BIGINT = NULL
  16. ,@title VARCHAR(100) = NULL
  17. ,@createDate DATETIME = NULL
  18. ,@isRead INT = NULL
  19. ,@Type INT = NULL
  20. ,@sentId BIGINT = NULL
  21. ,@customerId BIGINT = NULL
  22. ,@flag VARCHAR(50) = NULL
  23. AS
  24. --EXEC proc_getNotifyInfo @flag = 'notification',@customerId='57729'
  25. ------------------------------------------------------------------------------------------------------------
  26. -- #1135 added new flags (@flag = 'notification' and @flag = 'notification-detail') for new notification icon
  27. ------------------------------------------------------------------------------------------------------------
  28. IF @flag = 'notice'
  29. BEGIN
  30. SET NOCOUNT ON;
  31. SELECT rowId
  32. ,title
  33. ,createDate
  34. ,isRead
  35. ,Type
  36. ,sentId
  37. FROM pushNotificationHistroy
  38. WHERE type = '1'
  39. AND rowId > 0
  40. AND CAST(createDate AS DATE) >= DATEADD(day, - 7, CAST(GETDATE() AS DATE))
  41. AND customerId = @customerId
  42. --UNION ALL
  43. --SELECT rowId
  44. -- ,title
  45. -- ,createDate
  46. -- ,isRead
  47. -- ,Type
  48. -- ,sentId
  49. --FROM pushNotificationHistroy
  50. --WHERE type = '0'
  51. -- AND rowId > 0
  52. -- AND CAST(createDate AS DATE) >= DATEADD(day, - 3, CAST(GETDATE() AS DATE))
  53. -- AND customerId = @customerId
  54. ORDER BY rowid DESC
  55. END
  56. ELSE IF @flag = 'notification'
  57. BEGIN
  58. SELECT rowId
  59. ,customerId
  60. ,title
  61. ,body
  62. ,createDate
  63. ,isRead
  64. ,Type
  65. ,sentId
  66. ,ISNULL(category,'INFO') AS category
  67. ,url
  68. ,isClickable = CASE
  69. WHEN ISNULL(url, 'N') = 'N'
  70. THEN 'N'
  71. ELSE 'Y'
  72. END
  73. FROM pushNotificationHistroy
  74. WHERE type = '0'
  75. AND customerId = @customerId
  76. --AND isRead=0
  77. --AND CAST(createDate as date) >= DATEADD(day,-7, CAST(GETDATE() as date))
  78. ORDER BY rowid desc
  79. END
  80. ELSE IF @flag = 'notification-detail'
  81. BEGIN
  82. UPDATE pushNotificationHistroy
  83. SET isRead = '1',
  84. modifiedDate= GETDATE(),
  85. modifiedBy='JsonRx'
  86. WHERE isRead = '0'
  87. AND rowid = @rowId
  88. SELECT rowId
  89. ,customerId
  90. ,title
  91. ,body
  92. ,createDate
  93. ,isRead
  94. ,Type
  95. ,sentId
  96. ,category
  97. ,url
  98. FROM pushNotificationHistroy
  99. WHERE rowId = @rowId --AND CAST(createDate as date) >= DATEADD(day,-3, CAST(GETDATE() as date))
  100. END
  101. ELSE IF @flag = 'notification-portal'
  102. BEGIN
  103. SELECT top 3 rowId
  104. ,customerId
  105. ,title
  106. ,body
  107. ,createDate
  108. ,isRead
  109. ,Type
  110. ,sentId
  111. ,ISNULL(category,'INFO') AS category
  112. ,url
  113. ,isClickable = CASE
  114. WHEN ISNULL(url, 'N') = 'N'
  115. THEN 'N'
  116. ELSE 'Y'
  117. END
  118. , '0' as errorCode
  119. ,'Success' as msg
  120. ,(SELECT COUNT(*)
  121. FROM pushNotificationHistroy
  122. WHERE type = '0'
  123. AND customerId = @customerId
  124. AND isRead = 0) notificationCount
  125. FROM pushNotificationHistroy
  126. WHERE type = '0'
  127. AND customerId = @customerId
  128. --AND isRead=0
  129. --AND CAST(createDate as date) >= DATEADD(day,-7, CAST(GETDATE() as date))
  130. ORDER BY rowId desc
  131. DECLARE @rewardPoints INT = 0;
  132. SET @rewardPoints = CAST(DBO.FNA_GET_AVAILABLE_BALANCE_POINTS(@customerId) AS INT);
  133. SELECT @rewardPoints
  134. END
  135. ELSE IF @flag = 'notificationDetail-portal'
  136. BEGIN
  137. SELECT rowId
  138. ,customerId
  139. ,title
  140. ,body
  141. ,createDate
  142. ,isRead
  143. ,Type
  144. ,sentId
  145. ,ISNULL(category,'INFO') AS category
  146. ,url
  147. ,isClickable = CASE
  148. WHEN ISNULL(url, 'N') = 'N'
  149. THEN 'N'
  150. ELSE 'Y'
  151. END
  152. , '0' as errorCode
  153. ,'Success' as msg
  154. ,(SELECT COUNT(*)
  155. FROM pushNotificationHistroy
  156. WHERE type = '0'
  157. AND customerId = @customerId
  158. AND isRead = 0) notificationCount
  159. FROM pushNotificationHistroy
  160. WHERE type = '0'
  161. AND customerId = @customerId
  162. --AND isRead=0
  163. --AND CAST(createDate as date) >= DATEADD(day,-7, CAST(GETDATE() as date))
  164. ORDER BY rowId desc
  165. END