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.

288 lines
8.1 KiB

  1. ALTER PROC PROC_DYNAMIC_TABLE
  2. (
  3. @Flag VARCHAR(20)
  4. ,@UserEmail VARCHAR(150) = NULL
  5. ,@User VARCHAR(150) = NULL
  6. ,@ShowAll VARCHAR(5) = NULL
  7. ,@selectedValue1 VARCHAR(20) = NULL
  8. ,@CountryId INT = NULL
  9. ,@PaymentMethod INT = NULL
  10. ,@Password VARCHAR(40) = NULL
  11. ,@ConfirmPassword VARCHAR(40) = NULL
  12. ,@ipAddress VARCHAR(20) = NULL
  13. ,@id BIGINT = NULL
  14. ,@SchemeId VARCHAR(30) = NULL
  15. )
  16. AS;
  17. SET NOCOUNT ON;
  18. SET XACT_ABORT ON;
  19. BEGIN TRY
  20. DECLARE @ErrorMsg VARCHAR(MAX)
  21. DECLARE @agentid INT = 394395
  22. IF @Flag = 'CustomerTxn'
  23. BEGIN
  24. SELECT TOP 3 Id
  25. , Amount = pAmt
  26. , Status = CASE WHEN payStatus = 'Paid' THEN 'Paid' WHEN tranStatus = 'Cancel' OR payStatus = 'Cancel' THEN 'Cancel' ELSE 'Processing' END
  27. , TransactionDay = DATEPART(DAY, createdDate)
  28. , TransactionMonth = DATENAME(MONTH, createdDate)
  29. , PaymentMethod
  30. , PBankName
  31. , PCurrency = payoutCurr
  32. , errorCode = 0
  33. , msg = 'Success'
  34. FROM remitTranTemp (NOLOCK)
  35. END
  36. ELSE IF @Flag = 'ForceChange'
  37. BEGIN
  38. DECLARE @OldPassword VARCHAR(40) = NULL
  39. SELECT @OldPassword = DBO.DECRYPTDB(customerPassword)
  40. FROM CUSTOMERMASTER (NOLOCK)
  41. WHERE EMAIL = @UserEmail
  42. AND isForcedPwdChange = 1
  43. IF ISNULL(@OldPassword, '') = ''
  44. BEGIN
  45. SELECT errorCode = 1, msg = 'Invalid customer!', id = NULL
  46. RETURN;
  47. END
  48. IF @OldPassword = @Password
  49. BEGIN
  50. SELECT errorCode = 1, msg = 'Old password and new password can not be same!', id = NULL
  51. RETURN;
  52. END
  53. UPDATE CUSTOMERMASTER
  54. SET isForcedPwdChange = 0
  55. , customerPassword = dbo.fnaencryptstring(@Password)
  56. WHERE EMAIL = @UserEmail
  57. SELECT errorCode = 0, msg = 'Password changed successfully!', id = NULL
  58. RETURN;
  59. END
  60. ELSE IF @Flag = 'PayoutMethod'
  61. BEGIN
  62. DECLARE @PayoutCurrency VARCHAR(5), @tpExRate MONEY
  63. SELECT @tpExRate = detailDesc
  64. FROM staticDataValue (NOLOCK)
  65. WHERE typeId = '8109'
  66. AND detailTitle = @SchemeId
  67. SELECT @PayoutCurrency = CM.currencyCode
  68. FROM countryCurrency CC(NOLOCK)
  69. INNER JOIN currencyMaster CM(NOLOCK) ON CM.currencyId = CC.currencyId
  70. WHERE CC.countryId = @CountryId
  71. AND ISNULL(CC.isActive, 'Y') = 'Y'
  72. AND CC.isDefault = 'Y'
  73. IF @PaymentMethod IS NULL
  74. BEGIN
  75. SELECT agentId
  76. ,isRealTime
  77. ,exRateCalByPartner
  78. ,CM.COUNTRYCODE
  79. ,CM.CountryName
  80. ,AgentId
  81. ,PayoutCurrency = @PayoutCurrency
  82. ,tpExRate = @tpExRate
  83. FROM TblPartnerwiseCountry P(NOLOCK)
  84. INNER JOIN COUNTRYMASTER CM(NOLOCK) ON CM.COUNTRYID = P.COUNTRYID
  85. WHERE P.countryId = @CountryId
  86. AND (
  87. PaymentMethod IS NULL
  88. OR PaymentMethod IS NOT NULL
  89. )
  90. AND P.IsActive = 1
  91. END
  92. ELSE
  93. BEGIN
  94. SELECT agentId
  95. ,isRealTime
  96. ,exRateCalByPartner
  97. ,CM.COUNTRYCODE
  98. ,CM.CountryName
  99. ,AgentId
  100. ,PayoutCurrency = @PayoutCurrency
  101. ,tpExRate = @tpExRate
  102. FROM TblPartnerwiseCountry P(NOLOCK)
  103. INNER JOIN COUNTRYMASTER CM(NOLOCK) ON CM.COUNTRYID = P.COUNTRYID
  104. WHERE P.countryId = @CountryId
  105. AND ISNULL(PaymentMethod, @PaymentMethod) = @PaymentMethod
  106. AND P.IsActive = 1
  107. END
  108. END
  109. ELSE IF @Flag = 'CustomerReceiver'
  110. BEGIN
  111. SELECT TOP 3 Id = receiverId
  112. , Name = FULLNAME
  113. , Country = country
  114. , Mobile
  115. , TransactionType = SM.typeTitle
  116. , errorCode = 0
  117. , msg = 'Success'
  118. FROM receiverInformation RI(NOLOCK)
  119. INNER JOIN serviceTypeMaster SM(NOLOCK) ON SM.serviceTypeId = RI.paymentMode
  120. END
  121. ELSE IF @Flag = 'receiverList'
  122. BEGIN
  123. SELECT Id = receiverId
  124. , Text = FULLNAME
  125. , errorCode = 0
  126. , msg = 'Success'
  127. FROM receiverInformation RI(NOLOCK)
  128. INNER JOIN countryMaster CM(NOLOCK) ON CM.countryName = RI.country
  129. WHERE CM.countryId = @selectedValue1
  130. END
  131. ELSE IF @Flag = 'purpose'
  132. BEGIN
  133. SELECT Id = valueId
  134. , Text = detailTitle
  135. , errorCode = 0
  136. , msg = 'Success'
  137. FROM staticdatavalue (NOLOCK)
  138. WHERE typeid=3800
  139. AND ISNULL(ISActive, 'Y') = 'Y'
  140. AND ISNULL(IS_DELETE, 'N') = 'N'
  141. ORDER BY detailTitle ASC
  142. END
  143. ELSE IF @Flag = 'howToPay'
  144. BEGIN
  145. SELECT Id = 'ONLINE', Text = 'Online Banking(Best Rate)', extra = 0, errorCode = 0, msg = 'Success' UNION ALL
  146. SELECT Id = 'EBANKING', Text = 'E-Banking/ (Good rate)', extra = 0, errorCode = 0, msg = 'Success' UNION ALL
  147. SELECT Id = 'DEBIT_CARD', Text = 'DEBIT CARD', extra = 0.15, errorCode = 0, msg = 'Success'
  148. END
  149. ELSE IF @Flag = 'pCountry'
  150. BEGIN
  151. SET @countryId = 233
  152. SELECT Id = countryId
  153. , Text = UPPER(countryName)
  154. , errorCode = 0
  155. , msg = 'Success'
  156. FROM countryMaster CM WITH (NOLOCK)
  157. INNER JOIN (
  158. SELECT receivingCountry
  159. ,min(maxLimitAmt) maxLimitAmt
  160. FROM (
  161. SELECT receivingCountry
  162. ,max(maxLimitAmt) maxLimitAmt
  163. FROM sendTranLimit SL WITH (NOLOCK)
  164. WHERE --countryId = @countryId
  165. --AND
  166. ISNULL(isActive, 'N') = 'Y'
  167. AND ISNULL(isDeleted, 'N') = 'N'
  168. AND ISNULL(agentId, ISNULL(@agentid, 0)) = ISNULL(@agentid, 0)
  169. GROUP BY receivingCountry
  170. UNION ALL
  171. SELECT receivingCountry
  172. ,max(maxLimitAmt) maxLimitAmt
  173. FROM sendTranLimit SL WITH (NOLOCK)
  174. WHERE agentId = @agentid
  175. AND ISNULL(isActive, 'N') = 'Y'
  176. AND ISNULL(isDeleted, 'N') = 'N'
  177. GROUP BY receivingCountry
  178. ) x
  179. GROUP BY receivingCountry
  180. ) Y ON Y.receivingCountry = CM.countryId
  181. WHERE ISNULL(isOperativeCountry, '') = 'Y'
  182. AND Y.maxLimitAmt > 0
  183. ORDER BY countryName ASC
  184. END
  185. ELSE IF @Flag = 'pMode'
  186. BEGIN
  187. SET @countryId = 233
  188. SELECT Id = serviceTypeId
  189. , Text = UPPER(typeTitle)
  190. , errorCode = 0
  191. , msg = 'Success'
  192. FROM serviceTypeMaster stm WITH (NOLOCK)
  193. INNER JOIN (
  194. SELECT receivingMode
  195. ,maxLimitAmt
  196. FROM countryReceivingMode crm WITH (NOLOCK)
  197. INNER JOIN sendTranLimit SL WITH (NOLOCK) ON crm.countryId = SL.receivingCountry
  198. WHERE SL.countryId = @countryId
  199. AND SL.receivingCountry = @selectedValue1
  200. AND SL.agentId IS NULL
  201. AND SL.tranType IS NULL
  202. AND receivingAgent IS NULL
  203. UNION ALL
  204. SELECT receivingMode
  205. ,maxLimitAmt
  206. FROM countryReceivingMode crm WITH (NOLOCK)
  207. INNER JOIN sendTranLimit SL WITH (NOLOCK) ON crm.countryId = SL.receivingCountry
  208. AND SL.receivingCountry = @selectedValue1
  209. AND SL.countryId = @countryId
  210. WHERE agentId = @agentId
  211. AND SL.tranType IS NULL
  212. AND receivingAgent IS NULL
  213. AND ISNULL(isActive, 'N') = 'Y'
  214. AND ISNULL(isDeleted, 'N') = 'N'
  215. UNION ALL
  216. SELECT tranType
  217. ,MAX(maxLimitAmt) maxLimitAmt
  218. FROM sendTranLimit SL WITH (NOLOCK)
  219. WHERE countryId = @countryId
  220. AND SL.receivingCountry = @selectedValue1
  221. AND ISNULL(isActive, 'N') = 'Y'
  222. AND ISNULL(isDeleted, 'N') = 'N'
  223. AND SL.agentId IS NULL
  224. AND SL.tranType IS NOT NULL
  225. AND SL.receivingAgent IS NULL
  226. GROUP BY tranType
  227. UNION ALL
  228. SELECT tranType
  229. ,MAX(maxLimitAmt) maxLimitAmt
  230. FROM sendTranLimit SL WITH (NOLOCK)
  231. WHERE countryId = @countryId
  232. AND SL.receivingCountry = @selectedValue1
  233. AND SL.agentId = @agentid
  234. AND ISNULL(isActive, 'N') = 'Y'
  235. AND ISNULL(isDeleted, 'N') = 'N'
  236. AND receivingAgent IS NULL
  237. AND SL.tranType IS NOT NULL
  238. AND SL.receivingAgent IS NULL
  239. GROUP BY tranType
  240. ) X ON X.receivingMode = stm.serviceTypeId
  241. WHERE ISNULL(STM.isActive, 'N') = 'Y'
  242. AND ISNULL(STM.isDeleted, 'N') = 'N'
  243. AND (STM.serviceTypeId NOT IN (5))
  244. --AND (STM.serviceTypeId NOT IN (3,5))
  245. GROUP BY serviceTypeId
  246. ,typetitle
  247. HAVING MIN(X.maxLimitAmt) > 0
  248. ORDER BY serviceTypeId ASC
  249. END
  250. ELSE IF @Flag = 'Txn-Detail'
  251. BEGIN
  252. SELECT ControlNo = dbo.decryptdb(rt.controlNo), rt.receivername, rt.camt, rt.id, rt.collCurr, tr.address, rt.createdDate, rt.paymentMethod
  253. , collMode = rt.depositType, rt.pbankname, rt.pbankBranchName, rt.accountNo, rt.purposeofremit
  254. , status = CASE WHEN payStatus = 'Paid' THEN 'Paid' WHEN tranStatus = 'Cancel' OR payStatus = 'Cancel' THEN 'Cancel' ELSE 'Processing' END
  255. , rt.pamt, rt.payoutCurr, rt.customerRate
  256. , PromotionPremiumRate = 0
  257. , rt.tamt, rt.collCurr, rt.servicecharge
  258. , PromotionDiscount = 0
  259. , rt.camt, rt.pCountry
  260. FROM remitTranTemp rt(NOLOCK)
  261. INNER JOIN tranReceiversTemp tr(NOLOCK) on tr.tranid = rt.id
  262. WHERE rt.id = @id
  263. END
  264. END TRY
  265. BEGIN CATCH
  266. SET @ErrorMsg = 'Internal Server Error: ' + ERROR_MESSAGE()
  267. SELECT errorCode = 1, msg = @ErrorMsg, id = NULL
  268. END CATCH