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.

97 lines
5.8 KiB

1 year ago
  1. USE [FastMoneyPro_Remit]
  2. GO
  3. /****** Object: StoredProcedure [dbo].[PROC_SCHEDULER_PUSH_TXN_VCBR] Script Date: 9/27/2019 1:30:14 PM ******/
  4. SET ANSI_NULLS ON
  5. GO
  6. SET QUOTED_IDENTIFIER ON
  7. GO
  8. CREATE PROCEDURE [dbo].[PROC_SCHEDULER_PUSH_TXN_VCBR](
  9. @flag VARCHAR(100) = NULL
  10. ,@id VARCHAR(100)= NULL
  11. ,@ControlNo VARCHAR(100)=NULL
  12. )AS
  13. BEGIN
  14. declare @pAgent int = 393229
  15. IF @flag='push-list-Vcbr'
  16. BEGIN
  17. SELECT TOP 30
  18. SendTime=Rt.approvedDate
  19. ,TxId=Rt.id
  20. ,TxPin= dbo.FNADecryptString(Rt.controlNo)
  21. ,SenderName=Rt.senderName
  22. ,SenderPhoneNumber=TS.mobile
  23. ,SenderAddress=TS.address
  24. ,ReceiverName=RT.receivername
  25. ,ReceiverDateOfBirth=TR.dob
  26. ,ReceiverAddress=TR.address
  27. ,ReceiveDistrict=Tr.district
  28. ,ReceiveProvince=tr.state
  29. ,ReceiverPhoneNumber=TR.mobile
  30. ,SendAmount=RT.tAmt
  31. ,SendCurrency='WON'
  32. ,ExchangeRate=Rt.sCurrCostRate
  33. ,ReceiveAmount=RT.pAmt
  34. ,ReceiveCurrency=Rt.payoutCurr
  35. ,ReceiveAmountText=NULL--'one lakh'
  36. ,FeeAmount= ROUND(pagentcomm / (sCurrCostRate+sCurrHoMargin),2)
  37. ,IdentificationType=TR.idType
  38. ,IdentificationNumber=TR.idNumber
  39. ,IdentificationIssuedDate=TR.issuedDate
  40. ,IdentificationIssuedAddress=Tr.idPlaceOfIssue
  41. ,ReceiverAccountNumber=RT.accountNo
  42. ,ReceiveBank=Rt.pBankName
  43. ,ReceiveBranch=Rt.pBankBranch
  44. ,TxType=CASE WHEN RT.paymentMethod='BANK DEPOSIT' THEN 'AD' ELSE 'CP' END
  45. ,BrachAddress=AM.agentAddress
  46. ,MessageFromSender=NULL
  47. ,MessageForAgent=NULL
  48. ,AgentCode=NULL
  49. ,TxIdByAgent=NULL
  50. ,SendCountry='Korea'
  51. ,ReceiveCountry=RT.pCountry
  52. FROM dbo.remitTran AS RT(NOLOCK)
  53. INNER JOIN tranSenders TS (NOLOCK) ON TS.tranId = RT.id
  54. INNER JOIN tranReceivers TR (NOLOCK) ON TR.tranId = RT.id
  55. LEFT JOIN agentMaster AM (NOLOCK) ON AM.agentId = RT.pBank
  56. WHERE RT.approvedBy IS NOT NULL AND RT.payStatus ='Unpaid'
  57. AND RT.tranStatus = 'payment'
  58. AND RT.pAgent = @pAgent
  59. END
  60. ELSE IF @flag='sync-list-Vcbr'
  61. BEGIN
  62. SELECT RT.id AS TranId,dbo.FNADecryptString(Rt.controlNo) AS controlNo FROM dbo.remitTran AS RT(NOLOCK)
  63. WHERE RT.pAgent = @pAgent
  64. and RT.tranStatus='Payment' and RT.payStatus='Post'
  65. END
  66. ELSE IF @flag='mark-paid-Vcbr'
  67. BEGIN
  68. UPDATE remitTran
  69. SET payStatus='Paid', tranStatus='Paid'
  70. ,paidDate = getdate()
  71. ,paidDateLocal = GETUTCDATE()
  72. ,paidBy='Scheduler'
  73. WHERE id = @id AND payStatus ='Post'
  74. AND tranStatus = 'payment' AND pAgent = @pAgent
  75. SELECT '0' ErrorCode,'Update success' Msg, NULL Id
  76. END
  77. ELSE IF @flag='mark-post-Vcbr'
  78. BEGIN
  79. UPDATE remitTran SET
  80. payStatus = 'Post'
  81. ,postedBy = 'system'
  82. ,postedDate =GETDATE()
  83. ,postedDateLocal=GETUTCDATE()
  84. ,controlNo2=Dbo.FNAEncryptString(@ControlNo)
  85. ,ContNo = @ControlNo
  86. WHERE id = @id AND payStatus ='Unpaid'
  87. AND tranStatus = 'payment' AND pAgent = @pAgent
  88. SELECT '0' ErrorCode,'Update success' Msg, NULL Id
  89. END
  90. END
  91. GO