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.

177 lines
8.5 KiB

10 months ago
10 months ago
10 months ago
  1. USE [FastMoneyPro_Remit]
  2. GO
  3. /****** Object: StoredProcedure [dbo].[proc_getNotifyInfo] Script Date: 11/20/2023 4:56:14 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. DECLARE @profle varchar(500);
  133. SET @rewardPoints = CAST(DBO.FNA_GET_AVAILABLE_BALANCE_POINTS(@customerId) AS INT);
  134. SELECT @profle = selfieDoc From customerMaster where customerid=@customerId;
  135. SELECT @rewardPoints AS RewardAmount,@profle as SelfieDoc;
  136. END
  137. ELSE IF @flag = 'notificationDetail-portal'
  138. BEGIN
  139. SELECT rowId
  140. ,customerId
  141. ,title
  142. ,body
  143. ,createDate
  144. ,isRead
  145. ,Type
  146. ,sentId
  147. ,ISNULL(category,'INFO') AS category
  148. ,url
  149. ,isClickable = CASE
  150. WHEN ISNULL(url, 'N') = 'N'
  151. THEN 'N'
  152. ELSE 'Y'
  153. END
  154. , '0' as errorCode
  155. ,'Success' as msg
  156. ,(SELECT COUNT(*)
  157. FROM pushNotificationHistroy
  158. WHERE type = '0'
  159. AND customerId = @customerId
  160. AND isRead = 0) notificationCount
  161. FROM pushNotificationHistroy
  162. WHERE type = '0'
  163. AND customerId = @customerId
  164. --AND isRead=0
  165. --AND CAST(createDate as date) >= DATEADD(day,-7, CAST(GETDATE() as date))
  166. ORDER BY rowId desc
  167. END