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.

1116 lines
45 KiB

6 months ago
6 months ago
6 months ago
6 months ago
  1. USE [FastMoneyPro_Remit]
  2. GO
  3. /****** Object: StoredProcedure [dbo].[JsonRx_Proc_UserRegistration] Script Date: 4/3/2024 5:21:26 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 invalid1.'
  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), @referralId VARCHAR(200), @ruleType CHAR(1);
  705. IF EXISTS (
  706. SELECT 'X'
  707. FROM CustomerMaster(NOLOCK)
  708. WHERE username = @username
  709. )
  710. BEGIN
  711. SELECT @customerId = customerid, @referralId = referelCode
  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. IF (LEFT(@referralId, 3) NOT IN ('MOB', 'ADM', 'CRP', 'ONL'))
  745. BEGIN
  746. SELECT @ruleType = CASE
  747. WHEN RULE_TYPE = 1 THEN 'Y'
  748. WHEN RULE_TYPE IS NULL THEN 'N'
  749. ELSE 'N'
  750. END
  751. FROM REFERRAL_AGENT_WISE
  752. WHERE REFERRAL_CODE = @referralId
  753. IF (@ruleType = 'Y')
  754. BEGIN
  755. EXEC proc_InsertReferralRewardPoints @Flag = 'REGISTER', @CustomerId = @customerId, @ReferralId = @referralId
  756. END
  757. END
  758. END
  759. ELSE
  760. BEGIN
  761. UPDATE customerMaster SET LawsonCardNo='KYC_NOW' WHERE customerId = @customerId;
  762. END
  763. SELECT 0 ErrorCode
  764. ,'Success' Msg
  765. ,NULL Id
  766. RETURN
  767. END
  768. ELSE IF EXISTS (
  769. SELECT 'X'
  770. FROM CustomerMastertemp(NOLOCK)
  771. WHERE username = @username
  772. )
  773. BEGIN
  774. PRINT 'CustomerMastertemp'
  775. SELECT @customerId = customerid, @referralId = referelCode
  776. FROM CustomerMastertemp(NOLOCK)
  777. WHERE username = @username
  778. INSERT INTO TBLCUSTOMERMODIFYLOGS (
  779. customerId
  780. ,columnName
  781. ,oldValue
  782. ,modifiedBy
  783. ,modifiedDate
  784. ,newValue
  785. ,amendmentId
  786. ,agentId
  787. )
  788. SELECT @customerId
  789. ,'KYCOption'
  790. ,''
  791. ,@userName
  792. ,GETDATE()
  793. ,@clientid + + '|' + @registrationType
  794. ,''
  795. ,''
  796. IF @clientid = 'KYC_LATER'
  797. BEGIN
  798. set dateformat dmy;
  799. INSERT INTO dbo.customerMaster (
  800. fullName
  801. ,firstName
  802. ,middleName
  803. ,lastName1
  804. ,mobile
  805. ,gender
  806. ,dob
  807. ,occupation
  808. ,nativeCountry
  809. ,country
  810. ,bankName
  811. ,bankAccountNo
  812. ,idType
  813. ,idNumber
  814. ,homePhone
  815. ,idIssueDate
  816. ,idExpiryDate
  817. ,verifyDoc1
  818. ,verifyDoc2
  819. ,verifyDoc3
  820. ,SelfieDoc
  821. ,referelCode
  822. ,createdBy
  823. ,createdDate
  824. ,isActive
  825. ,onlineUser
  826. ,customerPassword
  827. ,[address]
  828. ,city
  829. ,state2
  830. ,customerType
  831. ,ADDITIONALADDRESS
  832. ,monthlyIncome
  833. ,organizationType
  834. ,username
  835. ,anotherIdType
  836. ,employeeBusinessType
  837. ,documentType
  838. ,remittanceallowed
  839. ,txnPin
  840. ,nameOfEmployeer
  841. ,isExistingCustomer
  842. ,HasDeclare
  843. ,createdFrom
  844. ,email
  845. ,customerEmail
  846. ,isEmailVerified
  847. ,mobileUser
  848. ,RegistrationType
  849. ,lawsoncardno
  850. ,zipCode
  851. ,membershipId
  852. )
  853. SELECT fullName
  854. ,CMT.firstName
  855. ,CMT.middleName
  856. ,cmt.lastName1
  857. ,mobile
  858. ,gender
  859. ,CASE ISDATE(dob)
  860. WHEN 1
  861. THEN CONVERT(date,dob,103)
  862. ELSE ''
  863. END
  864. ,CMT.occupation
  865. ,nativeCountry
  866. ,233
  867. ,bankName
  868. ,bankAccountNo
  869. ,idType
  870. ,idNumber
  871. ,CMT.homePhone
  872. ,CMT.idIssueDate
  873. ,idExpiryDate
  874. ,verifyDoc1
  875. ,verifyDoc2
  876. ,verifyDoc3
  877. ,CMT.selfie
  878. ,CMT.referelCode
  879. ,CMT.createdBy
  880. ,createdDate
  881. ,'Y'
  882. ,'Y'
  883. ,customerPassword
  884. ,[address]
  885. ,city
  886. ,state2
  887. ,4700
  888. ,ADDITIONALADDRESS
  889. ,monthlyIncome
  890. ,organizationType
  891. ,username
  892. ,anotherIdType
  893. ,employeeBusinessType
  894. ,documentType
  895. ,1
  896. ,NULL
  897. ,nameOfEmployeer
  898. ,0
  899. ,0
  900. ,'M'
  901. ,email
  902. ,customerEmail
  903. ,isEmailVerified
  904. ,mobileUser
  905. ,RegistrationType
  906. ,@clientid
  907. --,CASE @clientid WHEN 'KYC_LATER' THEN GETDATE() ELSE NULL END
  908. --,CASE @clientid WHEN 'KYC_LATER' THEN 'verified' ELSE NULL END
  909. --,@username
  910. ,zipCode
  911. ,membershipId
  912. FROM dbo.CustomerMasterTemp AS CMT(NOLOCK)
  913. WHERE CMT.username = @userName
  914. SET @customerId = @@IDENTITY
  915. UPDATE dbo.mobile_userRegistration
  916. SET customerId = @customerId
  917. WHERE username = @userName
  918. DELETE
  919. FROM customerMasterTemp
  920. WHERE username = @userName
  921. DECLARE @MEMBESHIP_ID VARCHAR(50) = NULL
  922. EXEC PROC_GENERATE_MEMBERSHIP_ID @CUSTOMERID = 0
  923. ,@USER = 'mobile'
  924. ,@loginBranchId = 0
  925. ,@MEMBESHIP_ID = @MEMBESHIP_ID OUT
  926. UPDATE dbo.customerMaster
  927. SET MEMBERSHIPID = ISNULL(MEMBERSHIPID, @MEMBESHIP_ID)
  928. ,mobileverifieddate = GETDATE()
  929. ,mobileverifiedby = @username
  930. ,mobileVerificationType = 'verified'
  931. ,HasDeclare = 1
  932. ,agreeYn = 1
  933. --,LawsonCardNo = ISNULL(@clientid, '')
  934. WHERE customerId = @customerId
  935. IF (LEFT(@referralId, 3) NOT IN ('MOB', 'ADM', 'CRP', 'ONL'))
  936. BEGIN
  937. SELECT @ruleType = CASE
  938. WHEN RULE_TYPE = 1 THEN 'Y'
  939. WHEN RULE_TYPE IS NULL THEN 'N'
  940. ELSE 'N'
  941. END
  942. FROM REFERRAL_AGENT_WISE
  943. WHERE REFERRAL_CODE = @referralId
  944. IF (@ruleType = 'Y')
  945. BEGIN
  946. EXEC proc_InsertReferralRewardPoints @Flag = 'REGISTER', @CustomerId = @customerId, @ReferralId = @referralId
  947. END
  948. END
  949. INSERT INTO pushNotificationHistroy (
  950. customerId
  951. ,body
  952. ,title
  953. ,createDate
  954. ,imageURL
  955. ,sentId
  956. ,Type
  957. ,isReservation
  958. ,isRead
  959. ,isSend
  960. ,category
  961. ,isClickable
  962. )
  963. SELECT @customerId
  964. ,'Congratulations, You are now ready to send money from IME London Mobile App'
  965. ,'IME LONDON Registration'
  966. ,getdate()
  967. ,''
  968. ,@customerId
  969. ,0
  970. ,0
  971. ,0
  972. ,0
  973. ,'INFO'
  974. ,'N'
  975. END
  976. ELSE
  977. BEGIN
  978. UPDATE CustomerMasterTemp SET RegistrationType='KYC_NOW' WHERE customerId = @customerId;
  979. END
  980. SELECT 0 ErrorCode
  981. ,'Success' Msg
  982. ,NULL Id
  983. END
  984. ELSE
  985. BEGIN
  986. SELECT 1 ErrorCode
  987. ,'Failed' Msg
  988. ,NULL Id
  989. END
  990. END