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.

1081 lines
42 KiB

10 months ago
11 months ago
1 year ago
1 year ago
  1. USE [FastMoneyPro_Remit]
  2. GO
  3. /****** Object: StoredProcedure [dbo].[JsonRx_Proc_UserRegistration] Script Date: 11/10/2023 9:51:30 AM ******/
  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. ,@customerId 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 London 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 Ux  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. ,verificationCode='PROCESSING'
  606. WHERE username = @username
  607. INSERT INTO pushNotificationHistroy (
  608. customerId
  609. ,body
  610. ,title
  611. ,createDate
  612. ,imageURL
  613. ,sentId
  614. ,Type
  615. ,isReservation
  616. ,isRead
  617. ,isSend
  618. ,category
  619. ,isClickable
  620. )
  621. SELECT @customerId
  622. ,'Thank you for completing your profile. You can now start sending transactions'
  623. ,'IME LONDON Registration'
  624. ,getdate()
  625. ,''
  626. ,@customerId
  627. ,0
  628. ,0
  629. ,0
  630. ,0
  631. ,'INFO'
  632. ,'N'
  633. SELECT 0 ErrorCode
  634. ,@fullname Msg
  635. ,@customerId Id
  636. ,@fcmid Extra
  637. ,@dobDB Extra2
  638. ,@Trusdocid Extra3
  639. RETURN
  640. END
  641. ELSE
  642. BEGIN
  643. SELECT 1 ErrorCode
  644. ,'Failed' Msg
  645. ,NULL Id
  646. END
  647. END
  648. IF @flag = 'agree-manual'
  649. BEGIN
  650. DECLARE @RegistrationTypeold VARCHAR(20);
  651. DECLARE @isAgreeDate DATETIME;
  652. IF EXISTS (
  653. SELECT 'X'
  654. FROM CustomerMaster(NOLOCK)
  655. WHERE username = @username
  656. )
  657. BEGIN
  658. SELECT @RegistrationTypeold = RegistrationType
  659. ,@customerId = customerid
  660. ,@isAgreeDate = isAgreeDate
  661. FROM CustomerMaster(NOLOCK)
  662. WHERE username = @username
  663. --UPDATE customerMaster
  664. --SET RegistrationType = 'MKYC'
  665. -- ,modifiedDate = GETDATE()
  666. -- ,modifiedBy = @username
  667. -- ,isAgreeDate=null
  668. -- ,agreeYn=0
  669. -- ,HasDeclare=0
  670. --WHERE username = @username
  671. INSERT INTO TBLCUSTOMERMODIFYLOGS (
  672. customerId
  673. ,columnName
  674. ,oldValue
  675. ,modifiedBy
  676. ,modifiedDate
  677. ,newValue
  678. ,amendmentId
  679. ,agentId
  680. )
  681. SELECT @customerId
  682. ,'RegistrationType'
  683. ,@RegistrationTypeold + '|' + CAST(@isAgreeDate AS VARCHAR)
  684. ,@userName
  685. ,GETDATE()
  686. ,'MYKC'
  687. ,''
  688. ,''
  689. SELECT 0 ErrorCode
  690. ,'Success' Msg
  691. ,NULL Id
  692. ,@fcmid Extra
  693. RETURN
  694. END
  695. ELSE
  696. BEGIN
  697. SELECT 1 ErrorCode
  698. ,'Failed' Msg
  699. ,NULL Id
  700. END
  701. END
  702. IF @flag = 'save-kyc-option'
  703. BEGIN
  704. DECLARE @KYCOptionold VARCHAR(30);
  705. IF EXISTS (
  706. SELECT 'X'
  707. FROM CustomerMaster(NOLOCK)
  708. WHERE username = @username
  709. )
  710. BEGIN
  711. SELECT @customerId = customerid
  712. FROM CustomerMaster(NOLOCK)
  713. WHERE username = @username
  714. SELECT TOP 1 @KYCOptionold = isnull(newValue, oldValue)
  715. FROM TBLCUSTOMERMODIFYLOGS
  716. WHERE columnName = 'KYCOption'
  717. AND customerId = @customerId
  718. ORDER BY customerId DESC
  719. INSERT INTO TBLCUSTOMERMODIFYLOGS (
  720. customerId
  721. ,columnName
  722. ,oldValue
  723. ,modifiedBy
  724. ,modifiedDate
  725. ,newValue
  726. )
  727. SELECT @customerId
  728. ,'KYCOption'
  729. ,ISNULL(@KYCOptionold, '') + '|' + @RegistrationTypeold
  730. ,@userName
  731. ,GETDATE()
  732. ,@clientid
  733. IF @clientid = 'KYC_LATER'
  734. BEGIN
  735. UPDATE customerMaster
  736. SET RegistrationType = @registrationType
  737. ,mobileverifieddate = GETDATE()
  738. ,mobileverifiedby = @username
  739. ,mobileVerificationType = 'verified'
  740. ,HasDeclare = 1
  741. ,agreeYn = 1
  742. ,LawsonCardNo='KYC_LATER'
  743. WHERE customerId = @customerId;
  744. END
  745. ELSE
  746. BEGIN
  747. UPDATE customerMaster SET LawsonCardNo='KYC_NOW' WHERE customerId = @customerId;
  748. END
  749. SELECT 0 ErrorCode
  750. ,'Success' Msg
  751. ,NULL Id
  752. RETURN
  753. END
  754. ELSE IF EXISTS (
  755. SELECT 'X'
  756. FROM CustomerMastertemp(NOLOCK)
  757. WHERE username = @username
  758. )
  759. BEGIN
  760. PRINT 'CustomerMastertemp'
  761. SELECT @customerId = customerid
  762. FROM CustomerMastertemp(NOLOCK)
  763. WHERE username = @username
  764. INSERT INTO TBLCUSTOMERMODIFYLOGS (
  765. customerId
  766. ,columnName
  767. ,oldValue
  768. ,modifiedBy
  769. ,modifiedDate
  770. ,newValue
  771. ,amendmentId
  772. ,agentId
  773. )
  774. SELECT @customerId
  775. ,'KYCOption'
  776. ,''
  777. ,@userName
  778. ,GETDATE()
  779. ,@clientid + + '|' + @registrationType
  780. ,''
  781. ,''
  782. IF @clientid = 'KYC_LATER'
  783. BEGIN
  784. INSERT INTO dbo.customerMaster (
  785. fullName
  786. ,firstName
  787. ,middleName
  788. ,lastName1
  789. ,mobile
  790. ,gender
  791. ,dob
  792. ,occupation
  793. ,nativeCountry
  794. ,country
  795. ,bankName
  796. ,bankAccountNo
  797. ,idType
  798. ,idNumber
  799. ,homePhone
  800. ,idIssueDate
  801. ,idExpiryDate
  802. ,verifyDoc1
  803. ,verifyDoc2
  804. ,verifyDoc3
  805. ,SelfieDoc
  806. ,referelCode
  807. ,createdBy
  808. ,createdDate
  809. ,isActive
  810. ,onlineUser
  811. ,customerPassword
  812. ,[address]
  813. ,city
  814. ,state2
  815. ,customerType
  816. ,ADDITIONALADDRESS
  817. ,monthlyIncome
  818. ,organizationType
  819. ,username
  820. ,anotherIdType
  821. ,employeeBusinessType
  822. ,documentType
  823. ,remittanceallowed
  824. ,txnPin
  825. ,nameOfEmployeer
  826. ,isExistingCustomer
  827. ,HasDeclare
  828. ,createdFrom
  829. ,email
  830. ,customerEmail
  831. ,isEmailVerified
  832. ,mobileUser
  833. ,RegistrationType
  834. ,lawsoncardno
  835. ,zipCode
  836. )
  837. SELECT fullName
  838. ,CMT.firstName
  839. ,CMT.middleName
  840. ,cmt.lastName1
  841. ,mobile
  842. ,gender
  843. ,CASE ISDATE(dob)
  844. WHEN 1
  845. THEN dob
  846. ELSE ''
  847. END
  848. ,CMT.occupation
  849. ,nativeCountry
  850. ,233
  851. ,bankName
  852. ,bankAccountNo
  853. ,idType
  854. ,idNumber
  855. ,CMT.homePhone
  856. ,CMT.idIssueDate
  857. ,idExpiryDate
  858. ,verifyDoc1
  859. ,verifyDoc2
  860. ,verifyDoc3
  861. ,CMT.selfie
  862. ,CMT.referelCode
  863. ,CMT.createdBy
  864. ,createdDate
  865. ,'Y'
  866. ,'Y'
  867. ,customerPassword
  868. ,[address]
  869. ,city
  870. ,state2
  871. ,4700
  872. ,ADDITIONALADDRESS
  873. ,monthlyIncome
  874. ,organizationType
  875. ,username
  876. ,anotherIdType
  877. ,employeeBusinessType
  878. ,documentType
  879. ,1
  880. ,NULL
  881. ,nameOfEmployeer
  882. ,0
  883. ,0
  884. ,'M'
  885. ,email
  886. ,customerEmail
  887. ,isEmailVerified
  888. ,mobileUser
  889. ,RegistrationType
  890. ,@clientid
  891. --,CASE @clientid WHEN 'KYC_LATER' THEN GETDATE() ELSE NULL END
  892. --,CASE @clientid WHEN 'KYC_LATER' THEN 'verified' ELSE NULL END
  893. --,@username
  894. ,zipCode
  895. FROM dbo.CustomerMasterTemp AS CMT(NOLOCK)
  896. WHERE CMT.username = @userName
  897. SET @customerId = @@IDENTITY
  898. UPDATE dbo.mobile_userRegistration
  899. SET customerId = @customerId
  900. WHERE username = @userName
  901. DELETE
  902. FROM customerMasterTemp
  903. WHERE username = @userName
  904. DECLARE @MEMBESHIP_ID VARCHAR(50) = NULL
  905. EXEC PROC_GENERATE_MEMBERSHIP_ID @CUSTOMERID = 0
  906. ,@USER = 'mobile'
  907. ,@loginBranchId = 0
  908. ,@MEMBESHIP_ID = @MEMBESHIP_ID OUT
  909. UPDATE dbo.customerMaster
  910. SET MEMBERSHIPID = @MEMBESHIP_ID
  911. ,mobileverifieddate = GETDATE()
  912. ,mobileverifiedby = @username
  913. ,mobileVerificationType = 'verified'
  914. ,HasDeclare = 1
  915. ,agreeYn = 1
  916. --,LawsonCardNo = ISNULL(@clientid, '')
  917. WHERE customerId = @customerId
  918. INSERT INTO pushNotificationHistroy (
  919. customerId
  920. ,body
  921. ,title
  922. ,createDate
  923. ,imageURL
  924. ,sentId
  925. ,Type
  926. ,isReservation
  927. ,isRead
  928. ,isSend
  929. ,category
  930. ,isClickable
  931. )
  932. SELECT @customerId
  933. ,'Congratulations, You are now ready to send money from IME London Mobile App'
  934. ,'IME LONDON Registration'
  935. ,getdate()
  936. ,''
  937. ,@customerId
  938. ,0
  939. ,0
  940. ,0
  941. ,0
  942. ,'INFO'
  943. ,'N'
  944. END
  945. ELSE
  946. BEGIN
  947. UPDATE CustomerMasterTemp SET RegistrationType='KYC_NOW' WHERE customerId = @customerId;
  948. END
  949. SELECT 0 ErrorCode
  950. ,'Success' Msg
  951. ,NULL Id
  952. END
  953. ELSE
  954. BEGIN
  955. SELECT 1 ErrorCode
  956. ,'Failed' Msg
  957. ,NULL Id
  958. END
  959. END