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.

1080 lines
42 KiB

10 months ago
  1. ��USE [FastMoneyPro_Remit]
  2. GO
  3. /****** Object: StoredProcedure [dbo].[JsonRx_Proc_UserRegistration] Script Date: 11/18/2023 10:42:18 PM ******/
  4. SET ANSI_NULLS ON
  5. GO
  6. SET QUOTED_IDENTIFIER ON
  7. GO
  8. ALTER PROCEDURE [dbo].[JsonRx_Proc_UserRegistration] (
  9. @language VARCHAR(100) = 'en'
  10. ,@customerId VARCHAR(100) = NULL
  11. ,@username VARCHAR(100) = NULL
  12. ,@flag VARCHAR(100) = NULL
  13. ,@password VARCHAR(100) = NULL
  14. ,@clientId VARCHAR(100) = NULL
  15. ,@IMEI VARCHAR(100) = NULL
  16. ,@appVersion VARCHAR(100) = NULL
  17. ,@phoneBrand VARCHAR(100) = NULL
  18. ,@phoneOs VARCHAR(100) = NULL
  19. ,@osVersion VARCHAR(100) = NULL
  20. ,@deviceId VARCHAR(100) = NULL
  21. ,@dob VARCHAR(100) = NULL
  22. ,@mobile VARCHAR(100) = NULL
  23. ,@nativeCountry VARCHAR(5) = NULL
  24. ,@referenceId BIGINT = NULL
  25. ,@randomPassword VARCHAR(20) = NULL
  26. ,@user VARCHAR(20) = NULL
  27. ,@registrationType VARCHAR(30) = NULL
  28. )
  29. AS
  30. -----------------------------------------------------------------
  31. --#101 Mobile app changes -> isForcedPwdChange=1 @flag='pwd-reset'
  32. --#387 Mobile app changes -> Added new flag = 'pwd-reset-core' , 'pin-reset-core' , Reset pin & Password From Core
  33. --#101 Push notificaiton for New Customer Register
  34. -- #1030 , @flag = 'agree' , added isAgreeDate
  35. -----------------------------------------------------------------
  36. BEGIN TRY
  37. DECLARE @dobDB VARCHAR(200)
  38. ,@code VARCHAR(100)
  39. ,@_errorMsg VARCHAR(300)
  40. ,@verifiedDate DATETIME
  41. ,@customerIdNo VARCHAR(50)
  42. IF @flag = 'sign-up'
  43. BEGIN
  44. --user already registered
  45. IF EXISTS (
  46. SELECT 'x'
  47. FROM dbo.customerMaster AS CM(NOLOCK)
  48. WHERE CM.email = @username
  49. )
  50. BEGIN
  51. SELECT 1 ErrorCode
  52. ,dbo.GetMessage(@language, '1002') Msg
  53. ,NULL Id
  54. RETURN
  55. END
  56. --user already registered
  57. IF EXISTS (
  58. SELECT 'x'
  59. FROM dbo.customerMasterTemp AS CM(NOLOCK)
  60. WHERE username = @username
  61. )
  62. BEGIN
  63. SELECT 1 ErrorCode
  64. ,dbo.GetMessage(@language, '1002') Msg
  65. ,NULL Id
  66. RETURN
  67. END
  68. --Username already taken
  69. IF EXISTS (
  70. SELECT 'x'
  71. FROM dbo.mobile_userRegistration(NOLOCK) AS MUR
  72. WHERE username = @username
  73. )
  74. BEGIN
  75. SELECT 1 ErrorCode
  76. ,dbo.GetMessage(@language, '1001') Msg
  77. ,NULL Id
  78. RETURN
  79. END
  80. BEGIN TRAN
  81. INSERT INTO dbo.CustomerMasterTemp (
  82. username
  83. ,customerPassword
  84. ,createdBy
  85. ,createdDate
  86. ,dob
  87. ,email
  88. ,mobile
  89. ,isActive
  90. )
  91. SELECT @username
  92. ,dbo.FNAEncryptString(@password)
  93. ,@username
  94. ,GETDATE()
  95. ,@dob
  96. ,@username
  97. ,CASE
  98. WHEN ISNUMERIC(@username) = 1
  99. THEN @username
  100. ELSE ''
  101. END
  102. ,'Y'
  103. SET @customerId = SCOPE_IDENTITY()
  104. INSERT INTO dbo.mobile_userRegistration (
  105. clientId
  106. ,username
  107. ,createdDate
  108. ,IMEI
  109. ,appVersion
  110. ,phoneBrand
  111. ,phoneOs
  112. ,osVersion
  113. ,deviceId
  114. ,customerId
  115. )
  116. SELECT @clientId
  117. ,@username
  118. ,GETDATE()
  119. ,@IMEI
  120. ,@appVersion
  121. ,@phoneBrand
  122. ,@phoneOs
  123. ,@osVersion
  124. ,@deviceId
  125. ,@customerId
  126. COMMIT TRAN
  127. IF @@TRANCOUNT = 0
  128. BEGIN
  129. --successful registered
  130. SELECT 0 ErrorCode
  131. ,dbo.GetMessage(@language, '1000') Msg
  132. ,NULL Id
  133. ,rowId
  134. ,PdfName
  135. ,AgreePdfPath
  136. FROM customerAgreeDocumentTbl
  137. WHERE targetObj = 'UAT'
  138. RETURN
  139. END
  140. END
  141. ELSE IF @flag = 'sign-up-V2'
  142. BEGIN
  143. --user already registered
  144. IF EXISTS (
  145. SELECT 'x'
  146. FROM dbo.customerMaster AS CM(NOLOCK)
  147. WHERE CM.email = @username
  148. )
  149. BEGIN
  150. SELECT 1 ErrorCode
  151. ,dbo.GetMessage(@language, '1002') Msg
  152. ,NULL Id
  153. RETURN
  154. END
  155. --DECLARE @MOBILE_OTP VARCHAR(30) = NULL
  156. --SELECT @MOBILE_OTP = MOBILE_NUMBER
  157. --FROM TBL_MOBILE_OTP_REQUEST (NOLOCK)
  158. --WHERE ROW_ID = @referenceId
  159. --IF @MOBILE_OTP IS NULL
  160. --BEGIN
  161. -- SELECT 1 ErrorCode,dbo.GetMessage(@language,'1003') Msg, NULL Id
  162. -- RETURN
  163. --END
  164. --IF @MOBILE_OTP <> @mobile
  165. --BEGIN
  166. -- SELECT 1 ErrorCode,dbo.GetMessage(@language,'1004') Msg, NULL Id
  167. -- RETURN
  168. --END
  169. --user already registered
  170. IF EXISTS (
  171. SELECT 'x'
  172. FROM dbo.customerMasterTemp AS CM(NOLOCK)
  173. WHERE username = @username
  174. )
  175. BEGIN
  176. SELECT 1 ErrorCode
  177. ,dbo.GetMessage(@language, '1002') Msg
  178. ,NULL Id
  179. RETURN
  180. END
  181. --Username already taken
  182. IF EXISTS (
  183. SELECT 'x'
  184. FROM dbo.mobile_userRegistration(NOLOCK) AS MUR
  185. WHERE username = @username
  186. )
  187. BEGIN
  188. SELECT 1 ErrorCode
  189. ,dbo.GetMessage(@language, '1001') Msg
  190. ,NULL Id
  191. RETURN
  192. END
  193. BEGIN TRAN
  194. INSERT INTO dbo.CustomerMasterTemp (
  195. username
  196. ,customerPassword
  197. ,createdBy
  198. ,createdDate
  199. ,email
  200. ,mobile
  201. ,nativeCountry
  202. ,isActive
  203. )
  204. SELECT @username
  205. ,dbo.FNAEncryptString(@password)
  206. ,@username
  207. ,GETDATE()
  208. ,@username
  209. ,@mobile
  210. ,@nativeCountry
  211. ,'Y'
  212. SET @customerId = SCOPE_IDENTITY()
  213. INSERT INTO dbo.mobile_userRegistration (
  214. clientId
  215. ,username
  216. ,createdDate
  217. ,IMEI
  218. ,appVersion
  219. ,phoneBrand
  220. ,phoneOs
  221. ,osVersion
  222. ,deviceId
  223. ,customerId
  224. )
  225. SELECT @clientId
  226. ,@username
  227. ,GETDATE()
  228. ,@IMEI
  229. ,@appVersion
  230. ,@phoneBrand
  231. ,@phoneOs
  232. ,@osVersion
  233. ,@deviceId
  234. ,@customerId
  235. COMMIT TRAN
  236. IF @@TRANCOUNT = 0
  237. BEGIN
  238. --successful registered
  239. SELECT 0 ErrorCode
  240. ,dbo.GetMessage(@language, '1000') Msg
  241. ,NULL Id
  242. ,rowId
  243. ,PdfName
  244. ,AgreePdfPath
  245. FROM customerAgreeDocumentTbl
  246. WHERE targetObj = 'STAGING'
  247. RETURN
  248. END
  249. END
  250. ELSE IF @flag = 'pwd-reset'
  251. BEGIN
  252. DECLARE @isExist BIT = 0
  253. IF (@userName IS NULL OR @userName='')
  254. BEGIN
  255. SELECT @_errorMsg = 'Email address is required.'
  256. SELECT '3' ErrorCode
  257. ,@_errorMsg Msg
  258. ,NULL ID
  259. ,@username Extra
  260. RETURN
  261. END
  262. IF EXISTS (
  263. SELECT 'x'
  264. FROM dbo.CustomerMasterTemp(NOLOCK) cm
  265. WHERE (cm.username = @userName)
  266. AND ISNULL(cm.isDeleted, 'N') = 'N'
  267. )
  268. BEGIN
  269. SET @isExist = 1;
  270. IF NOT EXISTS (
  271. SELECT 'x'
  272. FROM dbo.CustomerMasterTemp(NOLOCK) cm
  273. WHERE (cm.username = @userName)
  274. AND (cm.dob = @dob)
  275. AND ISNULL(cm.isDeleted, 'N') = 'N'
  276. )
  277. BEGIN
  278. SELECT '1' ErrorCode
  279. ,'Dob is invalid.'
  280. ,NULL ID
  281. RETURN;
  282. END
  283. END
  284. IF EXISTS (
  285. SELECT 'x'
  286. FROM dbo.customerMaster(NOLOCK) cm
  287. WHERE cm.email = @userName
  288. AND ISNULL(cm.isDeleted, 'N') = 'N'
  289. )
  290. BEGIN
  291. SET @isExist = 1;
  292. IF NOT EXISTS (
  293. SELECT 'x'
  294. FROM dbo.CustomerMaster(NOLOCK) cm
  295. WHERE (cm.username = @userName)
  296. AND (cm.dob = @dob)
  297. AND ISNULL(cm.isDeleted, 'N') = 'N'
  298. )
  299. BEGIN
  300. SELECT '1' ErrorCode
  301. ,'Dob is invalid.'
  302. ,NULL ID
  303. RETURN;
  304. END
  305. END
  306. IF @isExist = 0
  307. BEGIN
  308. SELECT @_errorMsg = 'User with contact Info ' + @username + ' does not exists. If you are a new user, then sign up and proceed further.'
  309. SELECT '3' ErrorCode
  310. ,@_errorMsg Msg
  311. ,NULL ID
  312. ,@username Extra
  313. RETURN
  314. END
  315. SELECT @dobDB = dob
  316. ,@mobile = mobile
  317. ,@customerId = customerId
  318. ,@verifiedDate = verifiedDate
  319. ,@customerIdNo = idNumber
  320. ,@mobile = mobile
  321. ,@_errorMsg= fullname
  322. FROM customerMaster WITH (NOLOCK)
  323. WHERE email = @userName
  324. --AND dob = @dob
  325. SET @code = @randomPassword
  326. BEGIN TRAN
  327. UPDATE dbo.customerMaster
  328. SET customerPassword = dbo.FNAEncryptString(@code)
  329. WHERE email = @username
  330. AND dob = @dob
  331. UPDATE dbo.mobile_userRegistration
  332. SET isForcePassChange = 1
  333. WHERE username = @username
  334. DECLARE @smsMsg VARCHAR(100) = 'Your new password is ' + @code
  335. --IF ISNUMERIC(@username) = 1
  336. --BEGIN
  337. -- PRINT 'a'
  338. -- --exec proc_CallToSendSMS @FLAG = 'I',@SMSBody=@smsMsg,@MobileNo=@mobile
  339. --END
  340. COMMIT TRAN
  341. IF @@TRANCOUNT = 0
  342. BEGIN
  343. SELECT '0' ErrorCode
  344. ,'Sucess' Msg
  345. ,'' Id
  346. ,@code Extra
  347. ,@_errorMsg Extra2
  348. ,@mobile Extra3
  349. RETURN
  350. END
  351. ELSE
  352. BEGIN
  353. SELECT '2' ErrorCode
  354. ,'Could not reset the password. Please contact IME head office.'
  355. ,NULL
  356. RETURN
  357. END
  358. END
  359. ELSE IF @flag = 'pwd-reset-core'
  360. BEGIN
  361. DECLARE @email NVARCHAR(50)
  362. ,@customerName NVARCHAR(50)
  363. ,@oldpassword NVARCHAR(50)
  364. ,@amendmentId NVARCHAR(MAX)
  365. SELECT @email = email
  366. FROM customerMaster(NOLOCK)
  367. WHERE customerId = @customerId;
  368. SELECT @customerName = fullName
  369. FROM customerMaster(NOLOCK)
  370. WHERE customerId = @customerId;
  371. SELECT @oldpassword = customerPassword
  372. FROM customerMaster
  373. WHERE customerId = @customerId;
  374. DECLARE @isExistCore BIT = 0
  375. IF EXISTS (
  376. SELECT 'x'
  377. FROM dbo.CustomerMasterTemp(NOLOCK) cm
  378. WHERE (cm.username = @email)
  379. AND ISNULL(cm.isDeleted, 'N') = 'N'
  380. )
  381. BEGIN
  382. SET @isExistCore = 1;
  383. END
  384. IF EXISTS (
  385. SELECT 'x'
  386. FROM dbo.customerMaster(NOLOCK) cm
  387. WHERE cm.email = @email
  388. AND ISNULL(cm.isDeleted, 'N') = 'N'
  389. )
  390. BEGIN
  391. SET @isExistCore = 1;
  392. END
  393. IF @isExistCore = 0
  394. BEGIN
  395. SELECT @_errorMsg = 'User with contact Info ' + @email + ' does not exists. If you are a new user, then sign up and proceed further.'
  396. SELECT '1' ErrorCode
  397. ,@_errorMsg Msg
  398. ,@email ID
  399. RETURN
  400. END
  401. SET @code = @randomPassword
  402. SET @amendmentId = NEWID()
  403. BEGIN TRAN
  404. INSERT INTO TBLCUSTOMERMODIFYLOGS (
  405. customerId
  406. ,columnName
  407. ,oldValue
  408. ,modifiedBy
  409. ,modifiedDate
  410. ,newValue
  411. ,amendmentId
  412. ,agentId
  413. )
  414. SELECT @customerId
  415. ,'customerPassword'
  416. ,@oldpassword
  417. ,@user
  418. ,GETDATE()
  419. ,dbo.FNAEncryptString(@code)
  420. ,@amendmentId
  421. ,'0'
  422. UPDATE dbo.customerMaster
  423. SET customerPassword = dbo.FNAEncryptString(@code)
  424. WHERE email = @email -- AND dob = @dob
  425. UPDATE dbo.mobile_userRegistration
  426. SET isForcePassChange = 1
  427. WHERE username = @email
  428. COMMIT TRAN
  429. IF @@TRANCOUNT = 0
  430. BEGIN
  431. SELECT '0' ErrorCode
  432. ,'Success' Msg
  433. ,@email Id
  434. ,@code Extra
  435. ,@customerName Extra2
  436. RETURN
  437. END
  438. ELSE
  439. BEGIN
  440. SELECT '1' ErrorCode
  441. ,'Could not reset the password. Please contact JME head office.'
  442. ,NULL
  443. RETURN
  444. END
  445. END
  446. ELSE IF @flag = 'pin-reset-core'
  447. BEGIN
  448. DECLARE @randompin INT
  449. ,@customeremail NVARCHAR(50)
  450. ,@customer NVARCHAR(50)
  451. ,@amendmentIdPin NVARCHAR(MAX)
  452. ,@oldpin NVARCHAR(8)
  453. SELECT @oldpin = dbo.FNAEncryptString(txnpin)
  454. FROM customerMaster
  455. WHERE customerid = @customerId
  456. SET @randompin = DBO.FNAGetRandomTransactionPinNo(6)
  457. SET @amendmentIdPin = NEWID()
  458. SELECT @customeremail = email
  459. FROM customerMaster(NOLOCK)
  460. WHERE customerId = @customerId;
  461. SELECT @customer = fullName
  462. FROM customerMaster(NOLOCK)
  463. WHERE customerId = @customerId;
  464. DECLARE @isExistPin BIT = 0
  465. IF EXISTS (
  466. SELECT 'x'
  467. FROM dbo.CustomerMasterTemp(NOLOCK) cm
  468. WHERE (cm.username = @customeremail)
  469. AND ISNULL(cm.isDeleted, 'N') = 'N'
  470. )
  471. BEGIN
  472. SET @isExistPin = 1;
  473. END
  474. IF EXISTS (
  475. SELECT 'x'
  476. FROM dbo.customerMaster(NOLOCK) cm
  477. WHERE cm.email = @customeremail
  478. AND ISNULL(cm.isDeleted, 'N') = 'N'
  479. )
  480. BEGIN
  481. SET @isExistPin = 1;
  482. END
  483. IF @isExistPin = 0
  484. BEGIN
  485. SELECT @_errorMsg = 'User with contact Info ' + @customeremail + ' does not exists. If you are a new user, then sign up and proceed further.'
  486. SELECT '1' ErrorCode
  487. ,@_errorMsg Msg
  488. ,@email ID
  489. RETURN
  490. END
  491. BEGIN TRAN
  492. INSERT INTO TBLCUSTOMERMODIFYLOGS (
  493. customerId
  494. ,columnName
  495. ,oldValue
  496. ,modifiedBy
  497. ,modifiedDate
  498. ,newValue
  499. ,amendmentId
  500. ,agentId
  501. )
  502. SELECT @customerId
  503. ,'txpin'
  504. ,@oldpin
  505. ,@user
  506. ,GETDATE()
  507. ,dbo.FnaencryptString(@randompin)
  508. ,@amendmentIdPin
  509. ,'0'
  510. UPDATE dbo.customerMaster
  511. SET txnpin = @randompin
  512. WHERE email = @customeremail
  513. UPDATE dbo.mobile_userRegistration
  514. SET isForcePinChange = 1
  515. WHERE username = @customeremail
  516. COMMIT TRAN
  517. IF @@TRANCOUNT = 0
  518. BEGIN
  519. SELECT '0' ErrorCode
  520. ,'Success' Msg
  521. ,@customeremail Id
  522. ,@randompin Extra
  523. ,@customer Extra2
  524. RETURN
  525. END
  526. ELSE
  527. BEGIN
  528. SELECT '1' ErrorCode
  529. ,'Could not reset the pin. Please contact JME head office.'
  530. ,NULL
  531. RETURN
  532. END
  533. END
  534. END TRY
  535. BEGIN CATCH
  536. IF @@TRANCOUNT <> 0
  537. ROLLBACK TRAN
  538. --Execption
  539. SELECT 1 ErrorCode
  540. ,dbo.GetMessage(@language, '9999') + CONVERT(VARCHAR, ERROR_LINE()) + ERROR_MESSAGE() Msg
  541. ,NULL Id
  542. RETURN
  543. END CATCH
  544. -- tǩƐ� ��� ٳX� U�x� � ��� Info Agree Insert
  545. IF @flag = 'agree'
  546. BEGIN
  547. DECLARE @fcmid VARCHAR(250)
  548. ,@fullname VARCHAR(100)
  549. ,@Trusdocid VARCHAR(50)
  550. ,@regType VARCHAR(20)
  551. SELECT @fcmid = deviceid
  552. ,@customerId = customerId
  553. FROM mobile_userRegistration
  554. WHERE username = @username;
  555. IF EXISTS (
  556. SELECT 'X'
  557. FROM CustomerMasterTemp(NOLOCK)
  558. WHERE username = @username
  559. )
  560. BEGIN
  561. SELECT @dobDB = CONVERT(VARCHAR(10), dob, 121)
  562. ,@fullname = fullName
  563. FROM customerMasterTemp WITH (NOLOCK)
  564. WHERE email = @username
  565. UPDATE customerMasterTemp
  566. SET agreeYn = '1'
  567. ,isAgreeDate = GETDATE()
  568. ,mobileverifieddate = GETDATE()
  569. ,mobileverifiedby = @username
  570. ,mobileVerificationType = 'verified'
  571. WHERE username = @username
  572. UPDATE customerMaster
  573. SET RegistrationType = @registrationType
  574. ,mobileverifieddate = GETDATE()
  575. ,mobileverifiedby = @username
  576. ,mobileVerificationType = 'verified'
  577. WHERE username = @userName
  578. AND customerId = @customerId;
  579. SELECT 0 ErrorCode
  580. ,@fullname Msg
  581. ,@customerId Id
  582. ,@fcmid Extra
  583. ,@dobDB Extra2
  584. ,@Trusdocid Extra3
  585. RETURN
  586. END
  587. ELSE IF EXISTS (
  588. SELECT 'X'
  589. FROM CustomerMaster(NOLOCK)
  590. WHERE username = @username
  591. )
  592. BEGIN
  593. SELECT @dobDB = CONVERT(VARCHAR(10), dob, 121)
  594. ,@fullname = fullName
  595. ,@Trusdocid = ''
  596. ,@regType = RegistrationType
  597. FROM customerMaster WITH (NOLOCK)
  598. WHERE email = @username
  599. UPDATE customerMaster
  600. SET agreeYn = '1'
  601. ,isAgreeDate = GETDATE()
  602. ,mobileverifieddate = GETDATE()
  603. ,mobileverifiedby = @username
  604. ,mobileVerificationType = 'verified'
  605. WHERE username = @username
  606. INSERT INTO pushNotificationHistroy (
  607. customerId
  608. ,body
  609. ,title
  610. ,createDate
  611. ,imageURL
  612. ,sentId
  613. ,Type
  614. ,isReservation
  615. ,isRead
  616. ,isSend
  617. ,category
  618. ,isClickable
  619. )
  620. SELECT @customerId
  621. ,'Thank you for completing your profile. You can now start sending transactions'
  622. ,'IME LONDON Registration'
  623. ,getdate()
  624. ,''
  625. ,@customerId
  626. ,0
  627. ,0
  628. ,0
  629. ,0
  630. ,'INFO'
  631. ,'N'
  632. SELECT 0 ErrorCode
  633. ,@fullname Msg
  634. ,@customerId Id
  635. ,@fcmid Extra
  636. ,@dobDB Extra2
  637. ,@Trusdocid Extra3
  638. RETURN
  639. END
  640. ELSE
  641. BEGIN
  642. SELECT 1 ErrorCode
  643. ,'Failed' Msg
  644. ,NULL Id
  645. END
  646. END
  647. IF @flag = 'agree-manual'
  648. BEGIN
  649. DECLARE @RegistrationTypeold VARCHAR(20);
  650. DECLARE @isAgreeDate DATETIME;
  651. IF EXISTS (
  652. SELECT 'X'
  653. FROM CustomerMaster(NOLOCK)
  654. WHERE username = @username
  655. )
  656. BEGIN
  657. SELECT @RegistrationTypeold = RegistrationType
  658. ,@customerId = customerid
  659. ,@isAgreeDate = isAgreeDate
  660. FROM CustomerMaster(NOLOCK)
  661. WHERE username = @username
  662. --UPDATE customerMaster
  663. --SET RegistrationType = 'MKYC'
  664. -- ,modifiedDate = GETDATE()
  665. -- ,modifiedBy = @username
  666. -- ,isAgreeDate=null
  667. -- ,agreeYn=0
  668. -- ,HasDeclare=0
  669. --WHERE username = @username
  670. INSERT INTO TBLCUSTOMERMODIFYLOGS (
  671. customerId
  672. ,columnName
  673. ,oldValue
  674. ,modifiedBy
  675. ,modifiedDate
  676. ,newValue
  677. ,amendmentId
  678. ,agentId
  679. )
  680. SELECT @customerId
  681. ,'RegistrationType'
  682. ,@RegistrationTypeold + '|' + CAST(@isAgreeDate AS VARCHAR)
  683. ,@userName
  684. ,GETDATE()
  685. ,'MYKC'
  686. ,''
  687. ,''
  688. SELECT 0 ErrorCode
  689. ,'Success' Msg
  690. ,NULL Id
  691. ,@fcmid Extra
  692. RETURN
  693. END
  694. ELSE
  695. BEGIN
  696. SELECT 1 ErrorCode
  697. ,'Failed' Msg
  698. ,NULL Id
  699. END
  700. END
  701. IF @flag = 'save-kyc-option'
  702. BEGIN
  703. DECLARE @KYCOptionold VARCHAR(30);
  704. IF EXISTS (
  705. SELECT 'X'
  706. FROM CustomerMaster(NOLOCK)
  707. WHERE username = @username
  708. )
  709. BEGIN
  710. SELECT @customerId = customerid
  711. FROM CustomerMaster(NOLOCK)
  712. WHERE username = @username
  713. SELECT TOP 1 @KYCOptionold = isnull(newValue, oldValue)
  714. FROM TBLCUSTOMERMODIFYLOGS
  715. WHERE columnName = 'KYCOption'
  716. AND customerId = @customerId
  717. ORDER BY customerId DESC
  718. INSERT INTO TBLCUSTOMERMODIFYLOGS (
  719. customerId
  720. ,columnName
  721. ,oldValue
  722. ,modifiedBy
  723. ,modifiedDate
  724. ,newValue
  725. )
  726. SELECT @customerId
  727. ,'KYCOption'
  728. ,ISNULL(@KYCOptionold, '') + '|' + @RegistrationTypeold
  729. ,@userName
  730. ,GETDATE()
  731. ,@clientid
  732. IF @clientid = 'KYC_LATER'
  733. BEGIN
  734. UPDATE customerMaster
  735. SET RegistrationType = @registrationType
  736. ,mobileverifieddate = GETDATE()
  737. ,mobileverifiedby = @username
  738. ,mobileVerificationType = 'verified'
  739. ,HasDeclare = 1
  740. ,agreeYn = 1
  741. ,LawsonCardNo='KYC_LATER'
  742. WHERE customerId = @customerId;
  743. END
  744. ELSE
  745. BEGIN
  746. UPDATE customerMaster SET LawsonCardNo='KYC_NOW' WHERE customerId = @customerId;
  747. END
  748. SELECT 0 ErrorCode
  749. ,'Success' Msg
  750. ,NULL Id
  751. RETURN
  752. END
  753. ELSE IF EXISTS (
  754. SELECT 'X'
  755. FROM CustomerMastertemp(NOLOCK)
  756. WHERE username = @username
  757. )
  758. BEGIN
  759. PRINT 'CustomerMastertemp'
  760. SELECT @customerId = customerid
  761. FROM CustomerMastertemp(NOLOCK)
  762. WHERE username = @username
  763. INSERT INTO TBLCUSTOMERMODIFYLOGS (
  764. customerId
  765. ,columnName
  766. ,oldValue
  767. ,modifiedBy
  768. ,modifiedDate
  769. ,newValue
  770. ,amendmentId
  771. ,agentId
  772. )
  773. SELECT @customerId
  774. ,'KYCOption'
  775. ,''
  776. ,@userName
  777. ,GETDATE()
  778. ,@clientid + + '|' + @registrationType
  779. ,''
  780. ,''
  781. IF @clientid = 'KYC_LATER'
  782. BEGIN
  783. INSERT INTO dbo.customerMaster (
  784. fullName
  785. ,firstName
  786. ,middleName
  787. ,lastName1
  788. ,mobile
  789. ,gender
  790. ,dob
  791. ,occupation
  792. ,nativeCountry
  793. ,country
  794. ,bankName
  795. ,bankAccountNo
  796. ,idType
  797. ,idNumber
  798. ,homePhone
  799. ,idIssueDate
  800. ,idExpiryDate
  801. ,verifyDoc1
  802. ,verifyDoc2
  803. ,verifyDoc3
  804. ,SelfieDoc
  805. ,referelCode
  806. ,createdBy
  807. ,createdDate
  808. ,isActive
  809. ,onlineUser
  810. ,customerPassword
  811. ,[address]
  812. ,city
  813. ,state2
  814. ,customerType
  815. ,ADDITIONALADDRESS
  816. ,monthlyIncome
  817. ,organizationType
  818. ,username
  819. ,anotherIdType
  820. ,employeeBusinessType
  821. ,documentType
  822. ,remittanceallowed
  823. ,txnPin
  824. ,nameOfEmployeer
  825. ,isExistingCustomer
  826. ,HasDeclare
  827. ,createdFrom
  828. ,email
  829. ,customerEmail
  830. ,isEmailVerified
  831. ,mobileUser
  832. ,RegistrationType
  833. ,lawsoncardno
  834. ,zipCode
  835. )
  836. SELECT fullName
  837. ,CMT.firstName
  838. ,CMT.middleName
  839. ,cmt.lastName1
  840. ,mobile
  841. ,gender
  842. ,CASE ISDATE(dob)
  843. WHEN 1
  844. THEN dob
  845. ELSE ''
  846. END
  847. ,CMT.occupation
  848. ,nativeCountry
  849. ,233
  850. ,bankName
  851. ,bankAccountNo
  852. ,idType
  853. ,idNumber
  854. ,CMT.homePhone
  855. ,CMT.idIssueDate
  856. ,idExpiryDate
  857. ,verifyDoc1
  858. ,verifyDoc2
  859. ,verifyDoc3
  860. ,CMT.selfie
  861. ,CMT.referelCode
  862. ,CMT.createdBy
  863. ,createdDate
  864. ,'Y'
  865. ,'Y'
  866. ,customerPassword
  867. ,[address]
  868. ,city
  869. ,state2
  870. ,4700
  871. ,ADDITIONALADDRESS
  872. ,monthlyIncome
  873. ,organizationType
  874. ,username
  875. ,anotherIdType
  876. ,employeeBusinessType
  877. ,documentType
  878. ,1
  879. ,NULL
  880. ,nameOfEmployeer
  881. ,0
  882. ,0
  883. ,'M'
  884. ,email
  885. ,customerEmail
  886. ,isEmailVerified
  887. ,mobileUser
  888. ,RegistrationType
  889. ,@clientid
  890. --,CASE @clientid WHEN 'KYC_LATER' THEN GETDATE() ELSE NULL END
  891. --,CASE @clientid WHEN 'KYC_LATER' THEN 'verified' ELSE NULL END
  892. --,@username
  893. ,zipCode
  894. FROM dbo.CustomerMasterTemp AS CMT(NOLOCK)
  895. WHERE CMT.username = @userName
  896. SET @customerId = @@IDENTITY
  897. UPDATE dbo.mobile_userRegistration
  898. SET customerId = @customerId
  899. WHERE username = @userName
  900. DELETE
  901. FROM customerMasterTemp
  902. WHERE username = @userName
  903. DECLARE @MEMBESHIP_ID VARCHAR(50) = NULL
  904. EXEC PROC_GENERATE_MEMBERSHIP_ID @CUSTOMERID = 0
  905. ,@USER = 'mobile'
  906. ,@loginBranchId = 0
  907. ,@MEMBESHIP_ID = @MEMBESHIP_ID OUT
  908. UPDATE dbo.customerMaster
  909. SET MEMBERSHIPID = @MEMBESHIP_ID
  910. ,mobileverifieddate = GETDATE()
  911. ,mobileverifiedby = @username
  912. ,mobileVerificationType = 'verified'
  913. ,HasDeclare = 1
  914. ,agreeYn = 1
  915. --,LawsonCardNo = ISNULL(@clientid, '')
  916. WHERE customerId = @customerId
  917. INSERT INTO pushNotificationHistroy (
  918. customerId
  919. ,body
  920. ,title
  921. ,createDate
  922. ,imageURL
  923. ,sentId
  924. ,Type
  925. ,isReservation
  926. ,isRead
  927. ,isSend
  928. ,category
  929. ,isClickable
  930. )
  931. SELECT @customerId
  932. ,'Congratulations, You are now ready to send money from IME London Mobile App'
  933. ,'IME LONDON Registration'
  934. ,getdate()
  935. ,''
  936. ,@customerId
  937. ,0
  938. ,0
  939. ,0
  940. ,0
  941. ,'INFO'
  942. ,'N'
  943. END
  944. ELSE
  945. BEGIN
  946. UPDATE CustomerMasterTemp SET RegistrationType='KYC_NOW' WHERE customerId = @customerId;
  947. END
  948. SELECT 0 ErrorCode
  949. ,'Success' Msg
  950. ,NULL Id
  951. END
  952. ELSE
  953. BEGIN
  954. SELECT 1 ErrorCode
  955. ,'Failed' Msg
  956. ,NULL Id
  957. END
  958. END