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.

993 lines
40 KiB

  1. USE [FastMoneyPro_Remit]
  2. GO
  3. /****** Object: StoredProcedure [dbo].[JsonRx_Proc_UserRegistration] Script Date: 9/5/2023 11:27:22 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 EXISTS (
  254. SELECT 'x'
  255. FROM dbo.CustomerMasterTemp(NOLOCK) cm
  256. WHERE (cm.username = @userName)
  257. AND ISNULL(cm.isDeleted, 'N') = 'N'
  258. )
  259. BEGIN
  260. SET @isExist = 1;
  261. IF NOT EXISTS (
  262. SELECT 'x'
  263. FROM dbo.CustomerMasterTemp(NOLOCK) cm
  264. WHERE (cm.username = @userName)
  265. AND (cm.dob = @dob)
  266. AND ISNULL(cm.isDeleted, 'N') = 'N'
  267. )
  268. BEGIN
  269. SELECT '1' ErrorCode
  270. ,'Dob is invalid.'
  271. ,NULL ID
  272. RETURN;
  273. END
  274. END
  275. IF EXISTS (
  276. SELECT 'x'
  277. FROM dbo.customerMaster(NOLOCK) cm
  278. WHERE cm.email = @userName
  279. AND ISNULL(cm.isDeleted, 'N') = 'N'
  280. )
  281. BEGIN
  282. SET @isExist = 1;
  283. IF NOT EXISTS (
  284. SELECT 'x'
  285. FROM dbo.CustomerMaster(NOLOCK) cm
  286. WHERE (cm.username = @userName)
  287. AND (cm.dob = @dob)
  288. AND ISNULL(cm.isDeleted, 'N') = 'N'
  289. )
  290. BEGIN
  291. SELECT '1' ErrorCode
  292. ,'Dob is invalid.'
  293. ,NULL ID
  294. RETURN;
  295. END
  296. END
  297. IF @isExist = 0
  298. BEGIN
  299. SELECT @_errorMsg = 'User with contact Info ' + @username + ' does not exists. If you are a new user, then sign up and proceed further.'
  300. SELECT '3' ErrorCode
  301. ,@_errorMsg Msg
  302. ,NULL ID
  303. ,@username Extra
  304. RETURN
  305. END
  306. SELECT @dobDB = dob
  307. ,@mobile = mobile
  308. ,@customerId = customerId
  309. ,@verifiedDate = verifiedDate
  310. ,@customerIdNo = idNumber
  311. ,@mobile = mobile
  312. FROM customerMaster WITH (NOLOCK)
  313. WHERE email = @userName
  314. --AND dob = @dob
  315. SET @code = @randomPassword
  316. BEGIN TRAN
  317. UPDATE dbo.customerMaster
  318. SET customerPassword = dbo.FNAEncryptString(@code)
  319. WHERE email = @username
  320. AND dob = @dob
  321. UPDATE dbo.mobile_userRegistration
  322. SET isForcePassChange = 1
  323. WHERE username = @username
  324. DECLARE @smsMsg VARCHAR(100) = 'Your new password is ' + @code
  325. --IF ISNUMERIC(@username) = 1
  326. --BEGIN
  327. -- PRINT 'a'
  328. -- --exec proc_CallToSendSMS @FLAG = 'I',@SMSBody=@smsMsg,@MobileNo=@mobile
  329. --END
  330. COMMIT TRAN
  331. IF @@TRANCOUNT = 0
  332. BEGIN
  333. SELECT '0' ErrorCode
  334. ,'Sucess' Msg
  335. ,NULL Id
  336. ,@code Extra
  337. RETURN
  338. END
  339. ELSE
  340. BEGIN
  341. SELECT '2' ErrorCode
  342. ,'Could not reset the password. Please contact JME head office.'
  343. ,NULL
  344. RETURN
  345. END
  346. END
  347. ELSE IF @flag = 'pwd-reset-core'
  348. BEGIN
  349. DECLARE @email NVARCHAR(50)
  350. ,@customerName NVARCHAR(50)
  351. ,@oldpassword NVARCHAR(50)
  352. ,@amendmentId NVARCHAR(MAX)
  353. SELECT @email = email
  354. FROM customerMaster(NOLOCK)
  355. WHERE customerId = @customerId;
  356. SELECT @customerName = fullName
  357. FROM customerMaster(NOLOCK)
  358. WHERE customerId = @customerId;
  359. SELECT @oldpassword = customerPassword
  360. FROM customerMaster
  361. WHERE customerId = @customerId;
  362. DECLARE @isExistCore BIT = 0
  363. IF EXISTS (
  364. SELECT 'x'
  365. FROM dbo.CustomerMasterTemp(NOLOCK) cm
  366. WHERE (cm.username = @email)
  367. AND ISNULL(cm.isDeleted, 'N') = 'N'
  368. )
  369. BEGIN
  370. SET @isExistCore = 1;
  371. END
  372. IF EXISTS (
  373. SELECT 'x'
  374. FROM dbo.customerMaster(NOLOCK) cm
  375. WHERE cm.email = @email
  376. AND ISNULL(cm.isDeleted, 'N') = 'N'
  377. )
  378. BEGIN
  379. SET @isExistCore = 1;
  380. END
  381. IF @isExistCore = 0
  382. BEGIN
  383. SELECT @_errorMsg = 'User with contact Info ' + @email + ' does not exists. If you are a new user, then sign up and proceed further.'
  384. SELECT '1' ErrorCode
  385. ,@_errorMsg Msg
  386. ,@email ID
  387. RETURN
  388. END
  389. SET @code = @randomPassword
  390. SET @amendmentId = NEWID()
  391. BEGIN TRAN
  392. INSERT INTO TBLCUSTOMERMODIFYLOGS (
  393. customerId
  394. ,columnName
  395. ,oldValue
  396. ,modifiedBy
  397. ,modifiedDate
  398. ,newValue
  399. ,amendmentId
  400. ,agentId
  401. )
  402. SELECT @customerId
  403. ,'customerPassword'
  404. ,@oldpassword
  405. ,@user
  406. ,GETDATE()
  407. ,dbo.FNAEncryptString(@code)
  408. ,@amendmentId
  409. ,'0'
  410. UPDATE dbo.customerMaster
  411. SET customerPassword = dbo.FNAEncryptString(@code)
  412. WHERE email = @email -- AND dob = @dob
  413. UPDATE dbo.mobile_userRegistration
  414. SET isForcePassChange = 1
  415. WHERE username = @email
  416. COMMIT TRAN
  417. IF @@TRANCOUNT = 0
  418. BEGIN
  419. SELECT '0' ErrorCode
  420. ,'Success' Msg
  421. ,@email Id
  422. ,@code Extra
  423. ,@customerName Extra2
  424. RETURN
  425. END
  426. ELSE
  427. BEGIN
  428. SELECT '1' ErrorCode
  429. ,'Could not reset the password. Please contact JME head office.'
  430. ,NULL
  431. RETURN
  432. END
  433. END
  434. ELSE IF @flag = 'pin-reset-core'
  435. BEGIN
  436. DECLARE @randompin INT
  437. ,@customeremail NVARCHAR(50)
  438. ,@customer NVARCHAR(50)
  439. ,@amendmentIdPin NVARCHAR(MAX)
  440. ,@oldpin NVARCHAR(8)
  441. SELECT @oldpin = dbo.FNAEncryptString(txnpin)
  442. FROM customerMaster
  443. WHERE customerid = @customerId
  444. SET @randompin = DBO.FNAGetRandomTransactionPinNo(6)
  445. SET @amendmentIdPin = NEWID()
  446. SELECT @customeremail = email
  447. FROM customerMaster(NOLOCK)
  448. WHERE customerId = @customerId;
  449. SELECT @customer = fullName
  450. FROM customerMaster(NOLOCK)
  451. WHERE customerId = @customerId;
  452. DECLARE @isExistPin BIT = 0
  453. IF EXISTS (
  454. SELECT 'x'
  455. FROM dbo.CustomerMasterTemp(NOLOCK) cm
  456. WHERE (cm.username = @customeremail)
  457. AND ISNULL(cm.isDeleted, 'N') = 'N'
  458. )
  459. BEGIN
  460. SET @isExistPin = 1;
  461. END
  462. IF EXISTS (
  463. SELECT 'x'
  464. FROM dbo.customerMaster(NOLOCK) cm
  465. WHERE cm.email = @customeremail
  466. AND ISNULL(cm.isDeleted, 'N') = 'N'
  467. )
  468. BEGIN
  469. SET @isExistPin = 1;
  470. END
  471. IF @isExistPin = 0
  472. BEGIN
  473. SELECT @_errorMsg = 'User with contact Info ' + @customeremail + ' does not exists. If you are a new user, then sign up and proceed further.'
  474. SELECT '1' ErrorCode
  475. ,@_errorMsg Msg
  476. ,@email ID
  477. RETURN
  478. END
  479. BEGIN TRAN
  480. INSERT INTO TBLCUSTOMERMODIFYLOGS (
  481. customerId
  482. ,columnName
  483. ,oldValue
  484. ,modifiedBy
  485. ,modifiedDate
  486. ,newValue
  487. ,amendmentId
  488. ,agentId
  489. )
  490. SELECT @customerId
  491. ,'txpin'
  492. ,@oldpin
  493. ,@user
  494. ,GETDATE()
  495. ,dbo.FnaencryptString(@randompin)
  496. ,@amendmentIdPin
  497. ,'0'
  498. UPDATE dbo.customerMaster
  499. SET txnpin = @randompin
  500. WHERE email = @customeremail
  501. UPDATE dbo.mobile_userRegistration
  502. SET isForcePinChange = 1
  503. WHERE username = @customeremail
  504. COMMIT TRAN
  505. IF @@TRANCOUNT = 0
  506. BEGIN
  507. SELECT '0' ErrorCode
  508. ,'Success' Msg
  509. ,@customeremail Id
  510. ,@randompin Extra
  511. ,@customer Extra2
  512. RETURN
  513. END
  514. ELSE
  515. BEGIN
  516. SELECT '1' ErrorCode
  517. ,'Could not reset the pin. Please contact JME head office.'
  518. ,NULL
  519. RETURN
  520. END
  521. END
  522. END TRY
  523. BEGIN CATCH
  524. IF @@TRANCOUNT <> 0
  525. ROLLBACK TRAN
  526. --Execption
  527. SELECT 1 ErrorCode
  528. ,dbo.GetMessage(@language, '9999') + CONVERT(VARCHAR, ERROR_LINE()) + ERROR_MESSAGE() Msg
  529. ,NULL Id
  530. RETURN
  531. END CATCH
  532. -- tǩƐ  ٳX Ux  Info Agree Insert
  533. IF @flag = 'agree'
  534. BEGIN
  535. DECLARE @fcmid VARCHAR(250)
  536. ,@fullname VARCHAR(100)
  537. ,@Trusdocid VARCHAR(50)
  538. ,@regType VARCHAR(20)
  539. SELECT @fcmid = deviceid
  540. ,@customerId = customerId
  541. FROM mobile_userRegistration
  542. WHERE username = @username;
  543. IF EXISTS (
  544. SELECT 'X'
  545. FROM CustomerMasterTemp(NOLOCK)
  546. WHERE username = @username
  547. )
  548. BEGIN
  549. SELECT @dobDB = CONVERT(VARCHAR(10), dob, 121)
  550. ,@fullname = fullName
  551. FROM customerMasterTemp WITH (NOLOCK)
  552. WHERE email = @username
  553. UPDATE customerMasterTemp
  554. SET agreeYn = '1'
  555. ,isAgreeDate = GETDATE()
  556. WHERE username = @username
  557. SELECT 0 ErrorCode
  558. ,@fullname Msg
  559. ,@customerId Id
  560. ,@fcmid Extra
  561. ,@dobDB Extra2
  562. ,@Trusdocid Extra3
  563. RETURN
  564. END
  565. ELSE IF EXISTS (
  566. SELECT 'X'
  567. FROM CustomerMaster(NOLOCK)
  568. WHERE username = @username
  569. )
  570. BEGIN
  571. SELECT @dobDB = CONVERT(VARCHAR(10), dob, 121)
  572. ,@fullname = fullName
  573. ,@Trusdocid = ''
  574. ,@regType = RegistrationType
  575. FROM customerMaster WITH (NOLOCK)
  576. WHERE email = @username
  577. UPDATE customerMaster
  578. SET agreeYn = '1'
  579. ,isAgreeDate = GETDATE()
  580. WHERE username = @username
  581. INSERT INTO pushNotificationHistroy(customerId,body,title,createDate,imageURL,sentId,Type,isReservation,isRead,isSend,category, isClickable)
  582. SELECT @customerId, 'Thank you for completing your profile. You can now start sending transactions','IME LONDON Registration',getdate(),'',@customerId,0,0,0,0,'INFO', 'N'
  583. SELECT 0 ErrorCode
  584. ,@fullname Msg
  585. ,@customerId Id
  586. ,@fcmid Extra
  587. ,@dobDB Extra2
  588. ,@Trusdocid Extra3
  589. RETURN
  590. END
  591. ELSE
  592. BEGIN
  593. SELECT 1 ErrorCode
  594. ,'Failed' Msg
  595. ,NULL Id
  596. END
  597. END
  598. IF @flag = 'agree-manual'
  599. BEGIN
  600. DECLARE @RegistrationTypeold VARCHAR(20);
  601. DECLARE @isAgreeDate datetime;
  602. IF EXISTS (
  603. SELECT 'X'
  604. FROM CustomerMaster(NOLOCK)
  605. WHERE username = @username
  606. )
  607. BEGIN
  608. SELECT @RegistrationTypeold = RegistrationType
  609. ,@customerId = customerid,@isAgreeDate=isAgreeDate
  610. FROM CustomerMaster(NOLOCK)
  611. WHERE username = @username
  612. --UPDATE customerMaster
  613. --SET RegistrationType = 'MKYC'
  614. -- ,modifiedDate = GETDATE()
  615. -- ,modifiedBy = @username
  616. -- ,isAgreeDate=null
  617. -- ,agreeYn=0
  618. -- ,HasDeclare=0
  619. --WHERE username = @username
  620. INSERT INTO TBLCUSTOMERMODIFYLOGS (
  621. customerId
  622. ,columnName
  623. ,oldValue
  624. ,modifiedBy
  625. ,modifiedDate
  626. ,newValue
  627. ,amendmentId
  628. ,agentId
  629. )
  630. SELECT @customerId
  631. ,'RegistrationType'
  632. ,@RegistrationTypeold+ '|' + CAST(@isAgreeDate AS varchar)
  633. ,@userName
  634. ,GETDATE()
  635. ,'MYKC'
  636. ,''
  637. ,''
  638. SELECT 0 ErrorCode
  639. ,'Success' Msg
  640. ,NULL Id
  641. ,@fcmid Extra
  642. RETURN
  643. END
  644. ELSE
  645. BEGIN
  646. SELECT 1 ErrorCode
  647. ,'Failed' Msg
  648. ,NULL Id
  649. END
  650. END
  651. IF @flag = 'save-kyc-option'
  652. BEGIN
  653. DECLARE @KYCOptionold VARCHAR(30);
  654. IF EXISTS (
  655. SELECT 'X'
  656. FROM CustomerMaster(NOLOCK)
  657. WHERE username = @username
  658. )
  659. BEGIN
  660. SELECT
  661. @customerId = customerid
  662. FROM CustomerMaster(NOLOCK)
  663. WHERE username = @username
  664. select top 1 @KYCOptionold= isnull(newValue,oldValue) FROM TBLCUSTOMERMODIFYLOGS where columnName='KYCOption' and customerId=@customerId order by customerId desc
  665. --UPDATE customerMaster
  666. --SET RegistrationType = 'MKYC'
  667. -- ,modifiedDate = GETDATE()
  668. -- ,modifiedBy = @username
  669. -- ,isAgreeDate=null
  670. -- ,agreeYn=0
  671. -- ,HasDeclare=0
  672. --WHERE username = @username
  673. INSERT INTO TBLCUSTOMERMODIFYLOGS (
  674. customerId
  675. ,columnName
  676. ,oldValue
  677. ,modifiedBy
  678. ,modifiedDate
  679. ,newValue
  680. )
  681. SELECT @customerId
  682. ,'KYCOption'
  683. ,ISNULL(@KYCOptionold,'')+ '|' + @RegistrationTypeold
  684. ,@userName
  685. ,GETDATE()
  686. ,@clientid
  687. UPDATE customerMaster SET RegistrationType= @registrationType, mobileverifieddate = GETDATE(), mobileverifiedby = @username, mobileVerificationType='verified'
  688. WHERE username=@userName and customerId=@customerId;
  689. SELECT 0 ErrorCode
  690. ,'Success' Msg
  691. ,NULL Id
  692. RETURN
  693. END
  694. ELSE IF EXISTS (
  695. SELECT 'X'
  696. FROM CustomerMastertemp(NOLOCK)
  697. WHERE username = @username
  698. )
  699. BEGIN
  700. PRINT 'CustomerMastertemp'
  701. SELECT
  702. @customerId = customerid
  703. FROM CustomerMastertemp(NOLOCK)
  704. WHERE username = @username
  705. INSERT INTO TBLCUSTOMERMODIFYLOGS (
  706. customerId
  707. ,columnName
  708. ,oldValue
  709. ,modifiedBy
  710. ,modifiedDate
  711. ,newValue
  712. ,amendmentId
  713. ,agentId
  714. )
  715. SELECT @customerId
  716. ,'KYCOption'
  717. ,''
  718. ,@userName
  719. ,GETDATE()
  720. ,@clientid + + '|' + @registrationType
  721. ,''
  722. ,''
  723. UPDATE customerMastertemp SET RegistrationType= @registrationType, mobileverifieddate = GETDATE(), mobileverifiedby = @username, mobileVerificationType='verified'
  724. WHERE username=@userName and customerId=@customerId;
  725. INSERT INTO dbo.customerMaster (
  726. fullName
  727. ,firstName
  728. ,middleName
  729. ,lastName1
  730. ,mobile
  731. ,gender
  732. ,dob
  733. ,occupation
  734. ,nativeCountry
  735. ,country
  736. ,bankName
  737. ,bankAccountNo
  738. ,idType
  739. ,idNumber
  740. ,homePhone
  741. ,idIssueDate
  742. ,idExpiryDate
  743. ,verifyDoc1
  744. ,verifyDoc2
  745. ,verifyDoc3
  746. ,SelfieDoc
  747. ,referelCode
  748. ,createdBy
  749. ,createdDate
  750. ,isActive
  751. ,onlineUser
  752. ,customerPassword
  753. ,[address]
  754. ,city
  755. ,state2
  756. ,customerType
  757. ,ADDITIONALADDRESS
  758. ,monthlyIncome
  759. ,organizationType
  760. ,username
  761. ,anotherIdType
  762. ,employeeBusinessType
  763. ,documentType
  764. ,remittanceallowed
  765. ,txnPin
  766. ,nameOfEmployeer
  767. ,isExistingCustomer
  768. ,HasDeclare
  769. ,createdFrom
  770. ,email
  771. ,customerEmail
  772. ,isEmailVerified
  773. ,mobileUser
  774. ,RegistrationType
  775. ,lawsoncardno
  776. ,mobileVerifiedDate
  777. ,mobileVerificationType
  778. ,mobileverifiedby
  779. )
  780. SELECT fullName
  781. ,CMT.firstName
  782. ,CMT.middleName
  783. ,cmt.lastName1
  784. ,mobile
  785. ,gender
  786. ,CASE ISDATE(dob) WHEN 1 THEN dob ELSE '' END
  787. ,CMT.occupation
  788. ,nativeCountry
  789. ,233
  790. ,bankName
  791. ,bankAccountNo
  792. ,idType
  793. ,idNumber
  794. ,CMT.homePhone
  795. ,CMT.idIssueDate
  796. ,idExpiryDate
  797. ,verifyDoc1
  798. ,verifyDoc2
  799. ,verifyDoc3
  800. ,CMT.selfie
  801. ,CMT.referelCode
  802. ,CMT.createdBy
  803. ,createdDate
  804. ,'Y'
  805. ,'Y'
  806. ,customerPassword
  807. ,[address]
  808. ,city
  809. ,state2
  810. ,4700
  811. ,ADDITIONALADDRESS
  812. ,monthlyIncome
  813. ,organizationType
  814. ,username
  815. ,anotherIdType
  816. ,employeeBusinessType
  817. ,documentType
  818. ,1
  819. ,NULL
  820. ,nameOfEmployeer
  821. ,0
  822. ,0
  823. ,'M'
  824. ,email
  825. ,customerEmail
  826. ,isEmailVerified
  827. ,mobileUser
  828. ,RegistrationType
  829. ,@clientid
  830. ,CASE @clientid WHEN 'KYC_LATER' THEN GETDATE() ELSE NULL END
  831. ,CASE @clientid WHEN 'KYC_LATER' THEN 'verified' ELSE NULL END
  832. ,@username
  833. FROM dbo.CustomerMasterTemp AS CMT(NOLOCK)
  834. WHERE CMT.username = @userName
  835. SET @customerId = @@IDENTITY
  836. UPDATE dbo.mobile_userRegistration
  837. SET customerId = @customerId
  838. WHERE username = @userName
  839. DELETE
  840. FROM customerMasterTemp
  841. WHERE username = @userName
  842. DECLARE @MEMBESHIP_ID VARCHAR(50) = NULL
  843. EXEC PROC_GENERATE_MEMBERSHIP_ID @CUSTOMERID = 0
  844. ,@USER = 'mobile'
  845. ,@loginBranchId = 0
  846. ,@MEMBESHIP_ID = @MEMBESHIP_ID OUT
  847. UPDATE dbo.customerMaster
  848. SET MEMBERSHIPID = @MEMBESHIP_ID
  849. WHERE customerId = @customerId
  850. INSERT INTO pushNotificationHistroy(customerId,body,title,createDate,imageURL,sentId,Type,isReservation,isRead,isSend,category, isClickable)
  851. SELECT @customerId, 'Congratulations, You are now ready to send money from IME London Mobile App','IME LONDON Registration',getdate(),'',@customerId,0,0,0,0,'INFO', 'N'
  852. SELECT 0 ErrorCode
  853. ,'Success' Msg
  854. ,NULL Id
  855. END
  856. ELSE
  857. BEGIN
  858. SELECT 1 ErrorCode
  859. ,'Failed' Msg
  860. ,NULL Id
  861. END
  862. END