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.

2334 lines
144 KiB

9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
10 months ago
10 months ago
9 months ago
10 months ago
9 months ago
  1. USE [FastMoneyPro_Remit]
  2. GO
  3. /****** Object: StoredProcedure [dbo].[proc_online_approve_Customer] Script Date: 4/5/2024 9:54:01 AM ******/
  4. SET ANSI_NULLS ON
  5. GO
  6. SET QUOTED_IDENTIFIER ON
  7. GO
  8. ALTER PROC [dbo].[proc_online_approve_Customer] @flag VARCHAR(50) = NULL
  9. ,@user VARCHAR(30) = NULL
  10. ,@customerId VARCHAR(30) = NULL
  11. ,@searchCriteria VARCHAR(30) = NULL
  12. ,@searchValue VARCHAR(50) = NULL
  13. ,@fromDate DATETIME = NULL
  14. ,@toDate DATETIME = NULL
  15. ,@cusType VARCHAR(50) = NULL
  16. ,@accountNumber VARCHAR(100) = NULL
  17. ,@agentId BIGINT = NULL
  18. ,@CustomerBankName NVARCHAR(100) = NULL
  19. ,@obpId VARCHAR(50) = NULL
  20. --grid parameters
  21. ,@pageSize VARCHAR(50) = NULL
  22. ,@pageNumber VARCHAR(50) = NULL
  23. ,@sortBy VARCHAR(50) = NULL
  24. ,@sortOrder VARCHAR(50) = NULL
  25. ,@virtualAccountNo VARCHAR(50) = NULL
  26. ,@primaryAccountNo VARCHAR(50) = NULL
  27. ,@password VARCHAR(50) = NULL
  28. ,@action CHAR(20) = NULL
  29. ,@referral VARCHAR(50) = NULL
  30. ,@verifyType VARCHAR(50) = NULL
  31. ,@customerPassword NVARCHAR(50) = NULL
  32. ,@HasDeclare VARCHAR(50) = NULL
  33. ,@agreeYn VARCHAR(50) = NULL
  34. ,@isForcedPwdChange VARCHAR(50) = NULL
  35. ,@isEmailVerified VARCHAR(50) = NULL
  36. ,@createdFrom1 VARCHAR(50) = NULL
  37. ,@mobileUser VARCHAR(50) = NULL
  38. ,@referelCode VARCHAR(50) = NULL
  39. ,@customerStatus1 VARCHAR(50) = NULL
  40. ,@mobileverifiedby VARCHAR(50) = NULL
  41. ,@mobileverifieddate VARCHAR(50) = NULL
  42. ,@mobileapprovedby VARCHAR(50) = NULL
  43. ,@mobileapproveddate VARCHAR(50) = NULL
  44. ,@mobileverificationType VARCHAR(50) = NULL
  45. ,@modifiedDate VARCHAR(50) = NULL
  46. ,@modifiedBy VARCHAR(100) = NULL
  47. ,@newData VARCHAR(300) = NULL
  48. ,@oldData VARCHAR(300) = NULL
  49. ,@isValidatedCustomer VARCHAR(5) = NULL
  50. ,@isAgreeDate DATETIME = NULL
  51. ,@verifyRemarks NVARCHAR(800) = NULL
  52. ,@ofacRemarks NVARCHAR(800) = NULL
  53. ,@status VARCHAR(500) = NULL
  54. AS
  55. SET NOCOUNT ON;
  56. SET XACT_ABORT ON;
  57. --------------------------------------------------------------------------------------
  58. -- #494 -> Added others value in approve customer screen by Leeza
  59. -- #101 -> Mobile changes - @serviceUsedFor
  60. -- #438 - added createdFrom
  61. -- #660 -> Add referral code in customer detail screen for activating mobile
  62. --Bug #681 ->Non KYC customer are appearing approve customer list
  63. -- #675 Divide the approval customer into 2 step process
  64. --#698 Create new screen to activate mobile service
  65. -- cm.agreeYn,0)= 1 for verify Customer
  66. -- Support #741 assign approve date during active mobile
  67. -- #779 added log for activate mobile @flag = 'mobile-activate-log'
  68. -- set MobileOTP expiry in case of activate mobile
  69. -- Delete mobile-user-registration if exist
  70. -- #958 - Add Asc/Desc sorting in Verify/Approve Customer From Mobile
  71. -- #1008 - Allow saving filled customer data in verify Customer from mobile
  72. -- #1030 - @flag='create-mobile-login', update isAgreeDate
  73. -- #1094 - verify pending remarks , @flag = 'approve-pending-mobile' , 'verify-mobile-user'
  74. -- #1104 - @flag = 'approve-pending' , add ofacRemarks, changes in @flag = 'approve-pending-mobile' and @flag = 'verify-mobile-user'
  75. -- added logs for delete
  76. -- #1195 changes in @flag = 'searchCriteria', @flag = 'unApprovedCustomerFromMobile', @flag = 'al' to add lawson card no in search field
  77. -- #11751 - add registered Type
  78. -- selected the customers created from agent portal as well in @flag = 'vl'
  79. -- change in @flag = 'searchCriteria' to add filterlist
  80. --------------------------------------------------------------------------------------
  81. BEGIN TRY
  82. DECLARE @table VARCHAR(MAX)
  83. ,@select_field_list VARCHAR(MAX)
  84. ,@extra_field_list VARCHAR(MAX)
  85. ,@sql_filter VARCHAR(MAX)
  86. DECLARE @email VARCHAR(200)
  87. ,@username VARCHAR(50)
  88. ,@pwd VARCHAR(50)
  89. ,@channel VARCHAR(20) = NULL
  90. DECLARE @customerStatus NVARCHAR(100)
  91. ,@createdFrom VARCHAR(5) , @bonusPoint MONEY , @rewardValue MONEY , @sourceCustomerId INT
  92. SET @toDate = @toDate + ' 23:59:59'
  93. IF @flag = 'vl' --verified list/approve pending list
  94. BEGIN
  95. SET @sortBy = 'createdDate'
  96. SET @sortOrder = 'desc'
  97. SET @table =
  98. '(
  99. SELECT SN=ROW_NUMBER() over(ORDER BY cm.customerId asc)
  100. ,customerId=cm.customerId
  101. ,email=cm.email
  102. ,fullName= REPLACE(ISNULL(cm.firstName, '''') + ISNULL('' '' + cm.middleName, '''') + ISNULL('' '' + cm.lastName1, ''''), '' '', '' '')
  103. ,dob=CONVERT(VARCHAR,cm.dob,101)
  104. ,address=cm.[address]
  105. ,nativeCountry=com.countryName
  106. ,idtype=case when cm.idtype = ''11402'' then cm.otherIdNumber else sdv.detailTitle end
  107. ,idNumber= cm.idNumber
  108. ,createdDate=CAST(cm.createdDate AS DATE)
  109. ,createdBy=cm.createdBy
  110. ,verifiedBy=cm.verifiedBy
  111. ,branchName=''''
  112. ,verifiedDate=CAST(cm.verifiedDate AS DATE)
  113. ,ipAddress=cm.ipAddress
  114. ,mobile=cm.mobile
  115. ,bankAccountNo
  116. ,bankName=bl.bankName
  117. ,case when ISNULL(cm.createdFrom, ''C'') = ''C'' THEN ''COUNTER'' WHEN cm.createdFrom = ''M'' THEN ''MOBILE'' ELSE cm.createdFrom END createdFrom
  118. ,Introducer=''
  119. FROM customerMaster cm(NOLOCK)
  120. LEFT JOIN APPLICATIONUSERS AU(NOLOCK) ON AU.USERNAME = CM.CREATEDBY
  121. LEFT JOIN countryMaster com(NOLOCK) ON cm.nativeCountry=com.countryId
  122. INNER JOIN staticDataValue sdv (NOLOCK) ON sdv.valueId=cm.idType AND sdv.typeID=1300
  123. LEFT JOIN vwBankLists bl (NOLOCK) ON cm.bankName = bl.rowId
  124. WHERE cm.approvedDate IS NULL
  125. --AND ISNULL(CM.CREATEDFROM, ''C'') = ''C''
  126. AND CM.CREATEDFROM IN (''C'',''O'')
  127. --AND ISNULL(CM.isVerifiedByCustomer, 0) = 1
  128. and cm.isActive = ''Y'''
  129. IF ISNULL(@fromDate, '') <> ''
  130. AND ISNULL(@toDate, '') <> ''
  131. SET @table = @table + ' AND cm.createdDate BETWEEN ''' + CAST(@fromDate AS VARCHAR) + ''' AND ''' + CAST(@toDate AS VARCHAR) + ''''
  132. SET @table = @table + ')x'
  133. SET @sql_filter = ''
  134. IF ISNULL(@searchCriteria, '') <> ''
  135. AND ISNULL(@searchValue, '') <> ''
  136. BEGIN
  137. IF @searchCriteria = 'idNumber'
  138. BEGIN
  139. --IF ISNUMERIC(@searchValue)<>1
  140. -- SET @searchValue='-1' --to ignore string value for datatype integer/customerID
  141. --SET @sql_Filter=@sql_Filter + ' AND customerId = ''' +@searchValue+''''
  142. SET @sql_Filter = @sql_Filter + ' AND REPLACE(idNumber, ''-'', '''') = ''' + REPLACE(@searchValue, '-', '') + ''''
  143. END
  144. ELSE IF @searchCriteria = 'emailId'
  145. SET @sql_Filter = @sql_Filter + ' AND email like ''' + @searchValue + '%'''
  146. ELSE IF @searchCriteria = 'customerName'
  147. SET @sql_Filter = @sql_Filter + ' AND fullName like ''' + @searchValue + '%'''
  148. ELSE IF @searchCriteria = 'mobile'
  149. SET @sql_Filter = @sql_Filter + ' AND mobile = ''' + @searchValue + ''''
  150. ELSE IF @searchCriteria = 'membershipId'
  151. SET @sql_Filter = @sql_Filter + ' AND membershipId = ''' + @searchValue + ''''
  152. ELSE IF @searchCriteria = 'nativeCountry'
  153. SET @sql_Filter = @sql_Filter + ' AND nativeCountry = ''' + @searchValue + ''''
  154. END
  155. SET @select_field_list = '
  156. SN,customerId,email,fullName,dob,address,nativeCountry,idtype,idNumber
  157. ,createdDate,createdBy,verifiedBy,branchName,verifiedDate,bankAccountNo,bankName,createdFrom,Introducer
  158. '
  159. EXEC dbo.proc_paging @table
  160. ,@sql_filter
  161. ,@select_field_list
  162. ,@extra_field_list
  163. ,@sortBy
  164. ,@sortOrder
  165. ,@pageSize
  166. ,@pageNumber
  167. RETURN
  168. END
  169. ELSE IF @flag = 'al' --approved list
  170. BEGIN
  171. IF @sortBy IS NULL
  172. SET @sortBy = 'customerId'
  173. IF @sortOrder IS NULL
  174. SET @sortOrder = 'ASC'
  175. SET @table =
  176. '(
  177. SELECT SN=ROW_NUMBER() over(ORDER BY cm.customerId asc)
  178. ,customerId=cm.customerId
  179. ,email=cm.email
  180. ,fullName= cm.fullName
  181. ,idtype=sdv.detailTitle
  182. ,idNumber=cm.idNumber
  183. ,mobile=cm.mobile
  184. ,bankName=bl.bankName
  185. ,cm.bankAccountNo
  186. ,CM.walletAccountNo
  187. ,cm.availableBalance
  188. ,cm.dob,cm.address
  189. ,country = ''South Korea''
  190. ,nativeCountry = com.CountryName
  191. ,cm.createdDate
  192. ,approvedBy=cm.approvedBy
  193. ,approvedDate=CAST(cm.approvedDate AS DATE)
  194. ,case when ISNULL(cm.createdFrom, ''C'') = ''C'' THEN ''COUNTER'' WHEN cm.createdFrom = ''M'' THEN ''MOBILE'' ELSE cm.createdFrom END createdFrom
  195. ,cm.LawsonCardNo
  196. FROM customerMaster cm(NOLOCK)
  197. INNER JOIN staticDataValue sdv (NOLOCK) ON sdv.valueId=cm.idType
  198. LEFT JOIN countryMaster com(NOLOCK) ON cm.nativeCountry=com.countryId
  199. LEFT JOIN KoreanBankList bl (NOLOCK) ON cm.bankName = bl.rowId
  200. WHERE cm.approvedDate is not null '
  201. IF ISNULL(@fromDate, '') <> ''
  202. AND ISNULL(@toDate, '') <> ''
  203. SET @table = @table + ' AND cm.approvedDate BETWEEN ''' + CAST(CAST(@fromDate AS DATE) AS VARCHAR) + ''' AND ''' + CAST(CAST(@toDate AS DATE) AS VARCHAR) + ' 23:59:59' + ''''
  204. SET @table = @table + ')x'
  205. SET @sql_filter = ''
  206. IF ISNULL(@searchCriteria, '') <> ''
  207. AND ISNULL(@searchValue, '') <> ''
  208. BEGIN
  209. IF @searchCriteria = 'idNumber'
  210. BEGIN
  211. --IF ISNUMERIC(@searchValue)<>1
  212. -- SET @searchValue='-1' --to ignore string value for datatype integer/customerID
  213. --SET @sql_Filter=@sql_Filter + ' AND customerId = ''' +@searchValue+''''
  214. SET @sql_Filter = @sql_Filter + ' AND REPLACE(idNumber, ''-'', '''') = ''' + REPLACE(@searchValue, '-', '') + ''''
  215. END
  216. ELSE IF @searchCriteria = 'emailId'
  217. SET @sql_Filter = @sql_Filter + ' AND email like ''' + @searchValue + '%'''
  218. ELSE IF @searchCriteria = 'customerName'
  219. SET @sql_Filter = @sql_Filter + ' AND fullName like ''' + @searchValue + '%'''
  220. ELSE IF @searchCriteria = 'mobile'
  221. SET @sql_Filter = @sql_Filter + ' AND mobile = ''' + @searchValue + ''''
  222. ELSE IF @searchCriteria = 'mobile'
  223. SET @sql_Filter = @sql_Filter + ' AND mobile = ''' + @searchValue + ''''
  224. ELSE IF @searchCriteria = 'membershipId'
  225. SET @sql_Filter = @sql_Filter + ' AND membershipId = ''' + @searchValue + ''''
  226. ELSE IF @searchCriteria = 'nativeCountry'
  227. SET @sql_Filter = @sql_Filter + ' AND nativeCountry = ''' + @searchValue + ''''
  228. END
  229. SET @select_field_list = '
  230. SN,customerId,email,fullName,idtype,idNumber,mobile,bankName,bankAccountNo,walletAccountNo,availableBalance
  231. ,dob,address,country,nativeCountry,createdDate,approvedDate,approvedBy,createdFrom,LawsonCardNo'
  232. EXEC dbo.proc_paging @table
  233. ,@sql_filter
  234. ,@select_field_list
  235. ,@extra_field_list
  236. ,@sortBy
  237. ,@sortOrder
  238. ,@pageSize
  239. ,@pageNumber
  240. RETURN
  241. END
  242. ELSE IF @flag = 'p' --pending list
  243. BEGIN
  244. IF @sortBy IS NULL
  245. SET @sortBy = 'customerId'
  246. IF @sortOrder IS NULL
  247. SET @sortOrder = 'ASC'
  248. SET @table =
  249. '(
  250. SELECT SN=ROW_NUMBER() over(ORDER BY cm.customerId asc)
  251. ,customerId=cm.customerId
  252. ,email=cm.email
  253. ,fullName= REPLACE(ISNULL(cm.firstName, '''') + ISNULL('' '' + cm.middleName, '''') + ISNULL('' '' + cm.lastName1, ''''), '' '', '' '')
  254. ,dob=CONVERT(VARCHAR,cm.dob,101)
  255. ,address=cm.[address]
  256. ,country=c.countryName
  257. ,ipAddress=isnull(cm.ipAddress,'''')
  258. ,nativeCountry=com.countryName
  259. ,idtype=sdv.detailTitle
  260. ,idNumber=cm.idNumber
  261. ,telNo=isnull(cm.telNo,'''')
  262. ,mobile=cm.mobile
  263. ,createdDate=CAST(cm.createdDate AS DATE)
  264. ,bankName=bl.bankName
  265. ,cm.bankAccountNo
  266. FROM customerMaster cm(NOLOCK)
  267. LEFT JOIN countryMaster com(NOLOCK) ON cm.nativeCountry=com.countryId
  268. LEFT JOIN countryMaster c(NOLOCK) ON cm.country=c.countryId
  269. INNER JOIN staticDataValue sdv (NOLOCK) ON sdv.valueId=cm.idType AND sdv.typeID=1300
  270. LEFT JOIN vwBankLists bl (NOLOCK) ON cm.bankName = bl.rowId
  271. WHERE cm.verifiedDate IS NULL'
  272. IF ISNULL(@fromDate, '') <> ''
  273. AND ISNULL(@toDate, '') <> ''
  274. SET @table = @table + ' AND cm.createdDate BETWEEN ''' + CAST(@fromDate AS VARCHAR) + ''' AND ''' + CAST(@toDate AS VARCHAR) + ''''
  275. SET @table = @table + ')x'
  276. SET @sql_filter = ''
  277. IF ISNULL(@searchCriteria, '') <> ''
  278. AND ISNULL(@searchValue, '') <> ''
  279. BEGIN
  280. IF @searchCriteria = 'idNumber'
  281. BEGIN
  282. SET @sql_Filter = @sql_Filter + ' AND REPLACE(idNumber, ''-'', '''') = ''' + REPLACE(@searchValue, '-', '') + ''''
  283. END
  284. ELSE IF @searchCriteria = 'emailId'
  285. SET @sql_Filter = @sql_Filter + ' AND email like ''' + @searchValue + '%'''
  286. ELSE IF @searchCriteria = 'customerName'
  287. SET @sql_Filter = @sql_Filter + ' AND fullName like ''' + @searchValue + '%'''
  288. ELSE IF @searchCriteria = 'mobile'
  289. SET @sql_Filter = @sql_Filter + ' AND mobile = ''' + @searchValue + ''''
  290. ELSE IF @searchCriteria = 'membershipId'
  291. SET @sql_Filter = @sql_Filter + ' AND membershipId = ''' + @searchValue + ''''
  292. ELSE IF @searchCriteria = 'bankAccountNo'
  293. SET @sql_Filter = @sql_Filter + ' AND bankAccountNo = ''' + @searchValue + ''''
  294. ELSE IF @searchCriteria = 'nativeCountry'
  295. SET @sql_Filter = @sql_Filter + ' AND nativeCountry = ''' + @searchValue + ''''
  296. END
  297. SET @select_field_list = '
  298. SN
  299. ,customerId
  300. ,email
  301. ,fullName
  302. ,dob
  303. ,address
  304. ,country
  305. --,ipAddress
  306. ,nativeCountry
  307. ,idtype
  308. ,idNumber
  309. --,telNo
  310. ,mobile
  311. ,createdDate
  312. ,bankName
  313. ,bankAccountNo
  314. '
  315. EXEC dbo.proc_paging @table
  316. ,@sql_filter
  317. ,@select_field_list
  318. ,@extra_field_list
  319. ,@sortBy
  320. ,@sortOrder
  321. ,@pageSize
  322. ,@pageNumber
  323. RETURN
  324. END
  325. ELSE IF @flag = 'searchCriteria'
  326. BEGIN
  327. SELECT '' value
  328. ,'Select' [text]
  329. UNION ALL
  330. SELECT 'emailId'
  331. ,'Email ID'
  332. UNION ALL
  333. SELECT 'IdNumber'
  334. ,'ID - Number'
  335. UNION ALL
  336. SELECT 'nativeCountry'
  337. ,'Native Country'
  338. UNION ALL
  339. SELECT 'customerName'
  340. ,'Customer Name'
  341. UNION ALL
  342. SELECT 'mobile'
  343. ,'Mobile No'
  344. UNION ALL
  345. SELECT 'membershipId'
  346. ,'Membership ID'
  347. UNION ALL
  348. SELECT 'verificationCode'
  349. ,'KYC Status'
  350. UNION ALL
  351. SELECT 'idType'
  352. ,'ID Type'
  353. RETURN
  354. END
  355. ELSE IF @flag = 'ddlCustomerType'
  356. BEGIN
  357. SELECT '' value
  358. ,'Select' [text]
  359. UNION ALL
  360. SELECT 'n'
  361. ,'Newly Registered'
  362. UNION ALL
  363. SELECT 'y'
  364. ,'Existing'
  365. RETURN
  366. END
  367. ELSE IF @flag = 'verify-pending'
  368. BEGIN
  369. UPDATE dbo.customerMaster
  370. SET verifiedDate = GETDATE()
  371. ,verifiedBy = @user
  372. WHERE customerId = @customerId
  373. SELECT '0' ErrorCode
  374. ,'Customer verified successfully.' Msg
  375. ,@customerId id
  376. RETURN
  377. END
  378. ELSE IF @flag = 'create-mobile-login'
  379. BEGIN
  380. DECLARE @serviceUsedFor VARCHAR(10)
  381. ,@existingemailagent VARCHAR(50)
  382. SELECT @existingemailagent = email
  383. FROM customerMaster(NOLOCK)
  384. WHERE customerid = @customerId
  385. IF EXISTS (
  386. SELECT *
  387. FROM customerMaster(NOLOCK)
  388. WHERE CUSTOMERID = @customerId
  389. AND APPROVEDDATE IS NULL
  390. )
  391. BEGIN
  392. SELECT '1' ErrorCode
  393. ,'Customer is not approved yet, approve customer first!' Msg
  394. ,NULL
  395. RETURN
  396. END
  397. IF EXISTS (
  398. SELECT *
  399. FROM customerMaster(NOLOCK)
  400. WHERE email = @existingemailagent
  401. AND mobileApprovedDate IS NOT NULL and customerid<>@customerId
  402. )
  403. BEGIN
  404. SELECT '1' ErrorCode
  405. ,'Customer with same email already exists! Please try again with a different email.' Msg
  406. ,NULL
  407. RETURN
  408. END
  409. SELECT @email = EMAIL
  410. ,@customerId = customerId
  411. FROM CUSTOMERMASTER(NOLOCK)
  412. WHERE CUSTOMERID = @customerId
  413. AND APPROVEDDATE IS NOT NULL
  414. IF @customerId IS NULL
  415. BEGIN
  416. SELECT '1' ErrorCode
  417. ,'Customer is not approved yet, approve customer first!' Msg
  418. ,NULL
  419. RETURN
  420. END
  421. IF @email IS NULL
  422. BEGIN
  423. SELECT '1' ErrorCode
  424. ,'Email ID field is empty, please update email first!' Msg
  425. ,NULL
  426. RETURN
  427. END
  428. IF @serviceUsedFor LIKE '%M%'
  429. BEGIN
  430. SELECT '1' ErrorCode
  431. ,'Mobile user already created!' Msg
  432. ,NULL
  433. RETURN
  434. END
  435. IF EXISTS (
  436. SELECT *
  437. FROM mobile_userRegistration
  438. WHERE username = @existingemailagent
  439. AND customerId <> @customerId
  440. )
  441. BEGIN
  442. DELETE
  443. FROM mobile_userRegistration
  444. WHERE username = @existingemailagent
  445. END
  446. SELECT @username = username
  447. ,@serviceUsedFor = serviceUsedFor
  448. ,@mobileUser = mobileUser
  449. ,@referelCode = referelCode
  450. ,@customerStatus = customerstatus
  451. ,@isAgreeDate = isAgreeDate
  452. FROM customerMaster
  453. WHERE customerId = @customerId
  454. UPDATE dbo.customerMaster
  455. SET username = ISNULL(username, email)
  456. ,customerPassword = dbo.FNAEncryptString(@password)
  457. ,HasDeclare = 1
  458. ,agreeYn = 1
  459. ,isAgreeDate = GETDATE()
  460. --,isForcedPwdChange = 1
  461. --,isEmailVerified = 0
  462. --,createdFrom = 'C'
  463. ,mobileUser = 'Y'
  464. --,referelCode = @referral
  465. --,customerStatus = 'OTC'
  466. ,mobileverifiedby = @user
  467. ,mobileverifieddate = GETDATE()
  468. --,mobileverificationType = 'verified'
  469. ,mobileapprovedby = @user
  470. ,mobileapproveddate = GETDATE()
  471. ,mobileverificationType = 'approved'
  472. --,modifiedDate = GETDATE()
  473. --,modifiedBy = @user
  474. WHERE customerId = @customerId
  475. UPDATE TBL_MOBILE_OTP_REQUEST
  476. SET IS_SUCCESS = '0'
  477. ,IS_EXPIRED = '1'
  478. ,MODIFIED_DATE = GETDATE()
  479. WHERE REQUEST_FOR = 'REGISTER'
  480. AND user_id = @email
  481. SELECT '0' ErrorCode
  482. ,'Mobile login created successfully.' Msg
  483. ,@customerId id
  484. ,'Y' extra
  485. EXEC PROC_CUSTOMERMODIFYLOG @flag = 'mobile-activate-log'
  486. ,@user = @user
  487. ,@customerId = @customerId
  488. ,@username = @username
  489. ,@mobileUser = @mobileUser
  490. ,@referelCode = @referelCode
  491. ,@mobileverifiedby = @user
  492. ,@mobileverifieddate = @mobileverifieddate
  493. ,@mobileapprovedby = @user
  494. ,@mobileverificationType = @mobileverificationType
  495. ,@serviceUsedFor = @serviceUsedFor
  496. ,@customerStatus = @customerStatus
  497. ,@isAgreeDate = @isAgreeDate
  498. --SELECT '0' ErrorCode
  499. -- ,'Mobile login created successfully, please check mobile customer approve menu.' Msg
  500. -- ,@customerId id
  501. --,'approved' EXTRA2
  502. RETURN
  503. END
  504. ELSE IF @flag = 'approve-pending'
  505. BEGIN
  506. DECLARE @custIdNumber VARCHAR(50)
  507. ,@WALLET_ACC_NO VARCHAR(30)
  508. ,@fullName VARCHAR(100)
  509. DECLARE @isOfac CHAR(1)
  510. DECLARE @referalid INT;
  511. SELECT @custIdNumber = idNumber
  512. ,@fullName = ISNULL(fullName, firstName),@createdFrom = createdFrom, @referelCode = referelCode
  513. FROM dbo.customerMaster(NOLOCK)
  514. WHERE customerId = @customerId
  515. SET @isOfac = CASE
  516. WHEN ISNULL(@ofacRemarks, '') = ''
  517. THEN 'N'
  518. ELSE 'Y'
  519. END
  520. IF NOT EXISTS (
  521. SELECT *
  522. FROM CUSTOMERMASTER(NOLOCK)
  523. WHERE CUSTOMERID = @customerId
  524. AND APPROVEDDATE IS NULL
  525. )
  526. BEGIN
  527. SELECT '1' ErrorCode
  528. ,'Customer already approved or does not exists!' Msg
  529. ,NULL
  530. RETURN
  531. END
  532. SELECT @custIdNumber = idNumber
  533. ,@fullName = ISNULL(fullName, firstName),@createdFrom = createdFrom, @referelCode = ISNULL(referralId, referelCode)
  534. FROM dbo.customerMaster(NOLOCK)
  535. WHERE customerId = @customerId
  536. IF EXISTS (
  537. SELECT 'X'
  538. FROM dbo.customerMaster(NOLOCK)
  539. WHERE replace(idNumber, '-', '') = replace(@custIdNumber, '-', '')
  540. GROUP BY replace(idNumber, '-', '')
  541. HAVING count(1) > 1
  542. )
  543. BEGIN
  544. SELECT '1' ErrorCode
  545. ,'Duplicate id number found for customer' Msg
  546. ,NULL
  547. RETURN
  548. END
  549. IF EXISTS (
  550. SELECT 'X'
  551. FROM dbo.customerMaster(NOLOCK)
  552. WHERE replace(idNumber, '-', '') = replace(@custIdNumber, '-', '')
  553. AND approvedBy IS NOT NULL
  554. )
  555. BEGIN
  556. SELECT '1' ErrorCode
  557. ,'Customer with same id number already approved.' Msg
  558. ,NULL
  559. RETURN
  560. END
  561. EXEC PROC_CREATE_CUSTOMER_WALLET @CUSTOMER_ID = @customerId
  562. ,@USER = @USER
  563. -- DECLARE @isOfac CHAR(1)
  564. SET @isOfac = CASE
  565. WHEN ISNULL(@ofacRemarks, '') = ''
  566. THEN 'N'
  567. ELSE 'Y'
  568. END
  569. SELECT @status = ISNULL(verificationCode,'NOT_COMPLETED') FROM customerMaster WHERE customerId = @customerId
  570. print @status
  571. --return
  572. IF(@status = 'NOT_COMPLETED')
  573. BEGIN
  574. UPDATE dbo.customerMaster
  575. SET verifiedDate = CASE WHEN verifiedDate IS NULL THEN GETDATE() ELSE verifiedDate END
  576. ,mobileverifiedby = CASE
  577. WHEN @createdFrom IN ('O','M')
  578. THEN @user
  579. ELSE NULL
  580. END
  581. ,mobileverifieddate = CASE
  582. WHEN @createdFrom IN ('O','M')
  583. THEN GETDATE()
  584. ELSE NULL
  585. END
  586. ,verifiedBy = @user
  587. ,verificationCode = 'PROCESSING'
  588. WHERE customerId = @customerId
  589. SELECT '0' ErrorCode
  590. ,'Customer verification status has been updated. Proceed to approve customer!' Msg
  591. ,@customerId id
  592. RETURN
  593. END
  594. ELSE IF(@status = 'PROCESSING')
  595. BEGIN
  596. UPDATE dbo.customerMaster
  597. SET approvedBy = @user
  598. ,approvedDate = GETDATE()
  599. ,username = email
  600. ,mobileApprovedDate = CASE
  601. WHEN @createdFrom IN ('O','M')
  602. THEN GETDATE()
  603. ELSE NULL
  604. END
  605. ,mobileApprovedBy = CASE
  606. WHEN @createdFrom IN ('O','M')
  607. THEN @user
  608. ELSE NULL
  609. END
  610. ,ofacRemarks = @ofacRemarks
  611. ,isOfac = @isOfac
  612. ,lawsonCardNo = CASE WHEN ISNULL(lawsonCardNo,'')='' THEN 'KYC_NOW' ELSE lawsonCardNo END
  613. ,isVerifiedByCustomer=1
  614. ,verificationCode = 'COMPLETED'
  615. WHERE customerId = @customerId
  616. IF NOT EXISTS (
  617. SELECT 1
  618. FROM dbo.TBL_CUSTOMER_KYC
  619. WHERE customerId = @customerId AND kycStatus = '11044'
  620. AND isDeleted <> '1' )
  621. BEGIN
  622. INSERT INTO TBL_CUSTOMER_KYC (
  623. customerId
  624. ,kycmethod
  625. ,kycStatus
  626. ,remarks
  627. ,createdBy
  628. ,createdDate
  629. ,trackingNo
  630. ,KYC_DATE
  631. )
  632. VALUES (
  633. @customerId
  634. ,CASE WHEN @createdFrom = 'C' THEN '11048' --counter visit
  635. WHEN @createdFrom = 'M' THEN '11051' --mobile app
  636. WHEN @createdFrom = 'O' THEN '11444' --web online
  637. ELSE ''
  638. END
  639. ,'11044'
  640. ,'KYC has been completed'
  641. ,@user
  642. ,GETDATE()
  643. ,''
  644. ,GETDATE()
  645. );
  646. END
  647. IF(@referelCode IS NOT NULL)
  648. BEGIN
  649. DECLARE @referalid INT;
  650. IF (LEFT(@referelCode, 3) IN ('MOB', 'ADM', 'CRP', 'ONL'))
  651. BEGIN
  652. SELECT @referalid=customerId FROM customerMaster WHERE membershipId = @referelCode;
  653. IF NOT EXISTS(select 'X' FROM Customer_Promotion where sourceCustomerid= @referalid and destinationcustomerid=@customerId
  654. AND CodeType='REGISTRATION')
  655. BEGIN
  656. EXEC proc_InsertRewardPoints @Flag = 'REGISTER', @CustomerId = @customerId, @ReferralId = @referalid
  657. END
  658. END
  659. ELSE
  660. BEGIN
  661. --print 'ref'
  662. --print @referelCode
  663. --print 'sada'
  664. --return
  665. DECLARE @refRowId BIGINT
  666. SELECT @refRowId = ROW_ID FROM REFERRAL_AGENT_WISE WHERE REFERRAL_CODE = @referelCode
  667. IF NOT EXISTS(SELECT 'X' FROM REFERRAL_INCENTIVE_TRANSACTION_WISE WHERE CUSTOMER_ID = @customerId)
  668. BEGIN
  669. EXEC proc_InsertReferralRewardPoints @Flag = 'REGISTER', @CustomerId = @customerId, @ReferralId = @referelCode
  670. END
  671. EXEC proc_InsertRewardPoints @Flag = 'REGISTER', @CustomerId = @refRowId, @ReferralId = @customerId
  672. END
  673. END
  674. --IF(@referelCode IS NOT NULL)
  675. -- BEGIN
  676. -- DECLARE @referalid INT;
  677. -- SELECT @referalid=customerId FROM customerMaster WHERE membershipId = @referelCode;
  678. -- IF NOT EXISTS(select 'X' FROM Customer_Promotion where sourceCustomerid= @referalid and destinationcustomerid=@customerId
  679. -- AND CodeType='REGISTRATION')
  680. -- BEGIN
  681. -- EXEC proc_InsertRewardPoints @Flag = 'REGISTER', @CustomerId = @customerId, @ReferralId = @referalid
  682. -- END
  683. -- END
  684. END
  685. ELSE IF(@status = 'COMPLETED' AND @createdFrom='C')
  686. BEGIN
  687. PRINT @createdFrom
  688. UPDATE dbo.customerMaster
  689. SET approvedBy = @user
  690. ,approvedDate = GETDATE()
  691. ,username = email
  692. ,ofacRemarks = @ofacRemarks
  693. ,isOfac = @isOfac
  694. ,lawsonCardNo = CASE WHEN ISNULL(lawsonCardNo,'')='' THEN 'KYC_NOW' ELSE lawsonCardNo END
  695. ,isVerifiedByCustomer=1
  696. WHERE customerId = @customerId
  697. END
  698. SELECT '0' ErrorCode
  699. ,'Customer approved successfully.' Msg
  700. ,@customerId id
  701. SELECT username = ISNULL(cm.userName, '')
  702. ,[password] = dbo.FNADecryptString(cm.customerPassword)
  703. ,[channel] = 'registration'
  704. ,[account] = ISNULL(cm.membershipId, '')
  705. ,fullName
  706. ,CustomerBankName
  707. ,cm.idType
  708. ,cm.createdFrom
  709. ,cm.ofacRemarks
  710. ,REPLACE(cm.idNumber, ' ', '') AS [idNumber]
  711. ,CONVERT(VARCHAR, cm.dob, 111) AS [dob]
  712. ,printLetter = CASE
  713. WHEN ISNULL(serviceUsedFor, 'C') LIKE '%M%'
  714. THEN 'Y'
  715. ELSE 'N'
  716. END
  717. ,email
  718. FROM dbo.customerMaster cm(NOLOCK)
  719. WHERE cm.customerId = @customerId
  720. RETURN
  721. END
  722. ELSE IF @flag = 'verify-mobile-user'
  723. BEGIN
  724. IF NOT EXISTS (
  725. SELECT *
  726. FROM CUSTOMERMASTER(NOLOCK)
  727. WHERE CUSTOMERID = @customerId
  728. AND mobileapproveddate IS NULL
  729. )
  730. BEGIN
  731. SELECT '1' ErrorCode
  732. ,'Customer already approved or does not exists!' Msg
  733. ,NULL
  734. RETURN
  735. END
  736. SELECT @customerStatus = customerStatus
  737. ,@createdFrom = createdFrom
  738. FROM customerMaster
  739. WHERE customerId = @customerId
  740. IF @verifyType = 'verify'
  741. BEGIN
  742. IF @isValidatedCustomer = 'Y'
  743. AND @verifyRemarks IS NULL
  744. BEGIN
  745. UPDATE CUSTOMERMASTER
  746. SET mobileVerifiedby = @user
  747. ,mobileVerifiedDate = Getdate()
  748. ,mobileVerificationType = 'verified'
  749. WHERE customerId = @customerId
  750. END
  751. SELECT @newData = CONCAT (
  752. ISNULL(@user, '')
  753. ,'|'
  754. ,ISNULL(CAST(Getdate() AS VARCHAR), '')
  755. ,'|'
  756. ,'Verified'
  757. ,'|'
  758. ,ISNULL(@verifyType, '')
  759. )
  760. --EXEC proc_applicationLogs @flag = 'i'
  761. -- ,@logType = 'verify-mobile-user'
  762. -- ,@tableName ='CustomerMaster'
  763. -- ,@dataId = @customerId
  764. -- ,@oldData =
  765. -- ,@newData = @newData
  766. -- ,@module = '22'
  767. -- ,@user = @user
  768. INSERT INTO applicationLogs (
  769. logType
  770. ,tableName
  771. ,dataId
  772. ,oldData
  773. ,newData
  774. ,module
  775. ,createdBy
  776. ,createdDate
  777. )
  778. VALUES (
  779. 'verify-mobile-user-existing'
  780. ,'CustomerMaster'
  781. ,@customerId
  782. ,'verify-existing'
  783. ,@newData
  784. ,'22'
  785. ,@user
  786. ,GETDATE()
  787. )
  788. SELECT '0' ErrorCode
  789. -- ,'Customer Verified Successfully.' Msg
  790. ,CASE
  791. WHEN @isValidatedCustomer = 'Y' AND @verifyRemarks IS NULL
  792. THEN 'Y'
  793. WHEN @isValidatedCustomer = 'Y' AND @verifyRemarks IS NOT NULL
  794. THEN 'R'
  795. ELSE 'N'
  796. END Msg
  797. ,@customerId id
  798. ,'Y' extra
  799. ,'verified' EXTRA2
  800. END
  801. IF @verifyType = 'approve'
  802. SET @isOfac = CASE
  803. WHEN ISNULL(@ofacRemarks, '') = ''
  804. THEN 'N'
  805. ELSE 'Y'
  806. END
  807. BEGIN
  808. UPDATE CUSTOMERMASTER
  809. SET mobileApprovedBy = @user
  810. ,mobileApprovedDate = Getdate()
  811. ,mobileVerificationType = 'approved'
  812. ,serviceUsedFor = 'CM'
  813. --,HasDeclare = 1
  814. --,agreeYn = 1
  815. -- ,isForcedPwdChange = 1
  816. --,isEmailVerified = 0
  817. ,createdFrom = 'C'
  818. ,mobileUser = 'Y'
  819. ,ofacRemarks = @ofacRemarks
  820. ,isOfac = @isOfac
  821. --,referelCode = ISNULL(@referral,referelCode)
  822. --,customerStatus = 'OTC'
  823. -- ,customerPassword= dbo.FNAEncryptString(@password)
  824. WHERE customerId = @customerId
  825. SELECT @newData = CONCAT (
  826. ISNULL(@user, '')
  827. ,'|'
  828. ,ISNULL(CAST(Getdate() AS VARCHAR), '')
  829. ,'|'
  830. ,'approved|CM'
  831. ,'|'
  832. ,ISNULL(@verifyType, '')
  833. )
  834. INSERT INTO applicationLogs (
  835. logType
  836. ,tableName
  837. ,dataId
  838. ,oldData
  839. ,newData
  840. ,module
  841. ,createdBy
  842. ,createdDate
  843. )
  844. VALUES (
  845. 'approve-mobile-user-existing'
  846. ,'CustomerMaster'
  847. ,@customerId
  848. ,'approve-existing'
  849. ,@newData
  850. ,'23'
  851. ,@user
  852. ,GETDATE()
  853. )
  854. SELECT '0' ErrorCode
  855. ,'Customer approved successfully.' Msg
  856. ,@customerId id
  857. ,CASE
  858. WHEN @customerStatus = 'OTC'
  859. THEN 'N'
  860. WHEN @createdFrom = 'M'
  861. THEN 'N'
  862. ELSE 'Y'
  863. END extra
  864. ,'approved' EXTRA2
  865. END
  866. SELECT username = ISNULL(cm.userName, '')
  867. ,[password] = dbo.FNADecryptString(cm.customerPassword)
  868. ,[channel] = 'registration'
  869. ,[account] = ISNULL(cm.membershipId, '')
  870. ,fullName
  871. ,CustomerBankName
  872. ,cm.idType
  873. ,cm.ofacRemarks
  874. ,REPLACE(cm.idNumber, ' ', '') AS [idNumber]
  875. ,CONVERT(VARCHAR, cm.dob, 111) AS [dob]
  876. FROM dbo.customerMaster cm(NOLOCK)
  877. WHERE cm.customerId = @customerId
  878. RETURN
  879. END
  880. ELSE IF @flag = 'approve-pending-mobile'
  881. BEGIN
  882. DECLARE @isExistingCustomer BIT
  883. ,@existingemail VARCHAR(50)
  884. DECLARE @customerStatusmobile NVARCHAR(100)
  885. ,@createdFromMobile VARCHAR(5)
  886. ,@trustDocId UNIQUEIDENTIFIER = NULL
  887. ,@fcmid VARCHAR(300)
  888. ,@deviceType VARCHAR(100)
  889. --SELECT @customerStatusmobile = customerStatus
  890. --FROM customerMaster
  891. --WHERE customerId = @customerId
  892. --SELECT @createdFromMobile = createdFrom
  893. --FROM customerMaster
  894. --WHERE customerId = @customerId
  895. SELECT @custIdNumber = idNumber
  896. ,@fullName = ISNULL(fullName, firstName)
  897. ,@isExistingCustomer = ISNULL(isExistingCustomer, 0)
  898. ,@existingemail = email
  899. ,@customerStatusmobile = customerStatus
  900. ,@createdFromMobile = createdFrom
  901. ,@trustDocId=TrustDocId
  902. ,@referelCode=ISNULL(referralId,referelCode)
  903. FROM dbo.customerMaster(NOLOCK)
  904. WHERE customerId = @customerId
  905. IF ISNULL(@isExistingCustomer, 0) = 1
  906. BEGIN
  907. IF NOT EXISTS (
  908. SELECT *
  909. FROM CUSTOMERMASTER(NOLOCK)
  910. WHERE CUSTOMERID = @customerId
  911. AND mobileapprovedDate IS NULL
  912. )
  913. BEGIN
  914. SELECT '1' ErrorCode
  915. ,'Customer already approved or does not exists!' Msg
  916. ,NULL
  917. RETURN
  918. END
  919. IF EXISTS (
  920. SELECT *
  921. FROM CUSTOMERMASTER(NOLOCK)
  922. WHERE email = @existingemail
  923. AND mobileApprovedDate IS NOT NULL
  924. )
  925. BEGIN
  926. SELECT '1' ErrorCode
  927. ,'Customer with same email already exists! Please try again with a different email.' Msg
  928. ,NULL
  929. RETURN
  930. END
  931. IF @verifyType = 'verify'
  932. BEGIN
  933. IF @isValidatedCustomer = 'Y'
  934. AND @verifyRemarks IS NULL
  935. BEGIN
  936. UPDATE CUSTOMERMASTER
  937. SET mobileVerifiedby = @user
  938. ,mobileVerifiedDate = Getdate()
  939. ,mobileVerificationType = 'verified'
  940. WHERE customerId = @customerId
  941. END
  942. PRINT 'A';
  943. SELECT @newData = CONCAT (
  944. ISNULL(@user, '')
  945. ,'|'
  946. ,ISNULL(CAST(Getdate() AS VARCHAR), '')
  947. ,'|'
  948. ,'verified'
  949. ,'|'
  950. ,ISNULL(@verifyType, '')
  951. )
  952. INSERT INTO applicationLogs (
  953. logType
  954. ,tableName
  955. ,dataId
  956. ,oldData
  957. ,newData
  958. ,module
  959. ,createdBy
  960. ,createdDate
  961. )
  962. VALUES (
  963. 'approve-mobile-user-verify'
  964. ,'CustomerMaster'
  965. ,@customerId
  966. ,'verify-new-user'
  967. ,@newData
  968. ,'24'
  969. ,@user
  970. ,GETDATE()
  971. )
  972. SELECT '0' ErrorCode
  973. --,'Customer verified successfully.' Msg
  974. ,CASE
  975. WHEN @isValidatedCustomer = 'Y' AND @verifyRemarks IS NULL
  976. THEN 'Y'
  977. WHEN @isValidatedCustomer = 'Y' AND @verifyRemarks IS NOT NULL
  978. THEN 'R'
  979. ELSE 'N'
  980. END Msg
  981. ,@customerId id
  982. ,'Y' extra
  983. ,'verified' EXTRA2
  984. END
  985. IF @verifyType = 'approve'
  986. BEGIN
  987. SET @isOfac = CASE
  988. WHEN ISNULL(@ofacRemarks, '') = ''
  989. THEN 'N'
  990. ELSE 'Y'
  991. END
  992. UPDATE CUSTOMERMASTER
  993. SET mobileApprovedBy = @user
  994. ,mobileApprovedDate = Getdate()
  995. ,mobileVerificationType = 'approved'
  996. ,serviceUsedFor = 'CM'
  997. ,referelCode = ISNULL(@referelCode, referelCode)
  998. ,HasDeclare = 1
  999. ,agreeYn = 1
  1000. ,username = ISNULL(username, email)
  1001. ,ofacRemarks = @ofacRemarks
  1002. ,isOfac = @isOfac
  1003. WHERE customerId = @customerId
  1004. IF @trustDocId IS NOT NULL
  1005. BEGIN
  1006. UPDATE trustDocCustomer SET verifiedDate=GETDATE() , verified=1 WHERE id=@trustDocId and customerId= @customerId;
  1007. END
  1008. SELECT @newData = CONCAT (
  1009. ISNULL(@user, '')
  1010. ,'|'
  1011. ,ISNULL(CAST(Getdate() AS VARCHAR), '')
  1012. ,'|'
  1013. ,'approved|CM'
  1014. ,'|'
  1015. ,ISNULL(@verifyType, '')
  1016. )
  1017. INSERT INTO applicationLogs (
  1018. logType
  1019. ,tableName
  1020. ,dataId
  1021. ,oldData
  1022. ,newData
  1023. ,module
  1024. ,createdBy
  1025. ,createdDate
  1026. )
  1027. VALUES (
  1028. 'approve-mobile-user'
  1029. ,'CustomerMaster'
  1030. ,@customerId
  1031. ,'approve-new-user'
  1032. ,@newData
  1033. ,'25'
  1034. ,@user
  1035. ,GETDATE()
  1036. )
  1037. IF(@referelCode IS NOT NULL)
  1038. BEGIN
  1039. DECLARE @custId INT;
  1040. IF (LEFT(@referelCode, 3) IN ('MOB', 'ADM', 'CRP', 'ONL'))
  1041. BEGIN
  1042. SELECT @custId=customerId FROM customerMaster WHERE membershipId = @referelCode;
  1043. IF NOT EXISTS(select 'X' FROM Customer_Promotion where sourceCustomerid= @custId and destinationcustomerid=@customerId
  1044. AND CodeType='REGISTRATION')
  1045. BEGIN
  1046. EXEC proc_InsertRewardPoints @Flag = 'REGISTER', @CustomerId = @customerId, @ReferralId = @custId
  1047. END
  1048. END
  1049. ELSE
  1050. BEGIN
  1051. SELECT @refRowId = ROW_ID FROM REFERRAL_AGENT_WISE WHERE REFERRAL_CODE = @referelCode
  1052. IF NOT EXISTS(SELECT 'X' FROM REFERRAL_INCENTIVE_TRANSACTION_WISE WHERE CUSTOMER_ID = @customerId)
  1053. BEGIN
  1054. EXEC proc_InsertReferralRewardPoints @Flag = 'REGISTER', @CustomerId = @customerId, @ReferralId = @referelCode
  1055. END
  1056. EXEC proc_InsertRewardPoints @Flag = 'REGISTER', @CustomerId = @refRowId, @ReferralId = @customerId
  1057. END
  1058. END
  1059. SELECT '0' ErrorCode
  1060. ,'Customer approved successfully.' Msg
  1061. ,@customerId id
  1062. ,CASE
  1063. WHEN @customerStatusmobile = 'OTC'
  1064. THEN 'N'
  1065. WHEN @createdFromMobile = 'M'
  1066. THEN 'N'
  1067. ELSE 'Y'
  1068. END extra
  1069. ,'approved' EXTRA2
  1070. END
  1071. SELECT username = ISNULL(cm.userName, '')
  1072. ,[password] = dbo.FNADecryptString(cm.customerPassword)
  1073. ,[channel] = 'registration'
  1074. ,[account] = ISNULL(cm.membershipId, '')
  1075. ,fullName
  1076. ,CustomerBankName
  1077. ,cm.idType
  1078. ,cm.ofacRemarks
  1079. ,REPLACE(cm.idNumber, ' ', '') AS [idNumber]
  1080. ,CONVERT(VARCHAR, cm.dob, 111) AS [dob]
  1081. FROM dbo.customerMaster cm(NOLOCK)
  1082. WHERE cm.customerId = @customerId
  1083. RETURN
  1084. END
  1085. IF NOT EXISTS (
  1086. SELECT *
  1087. FROM CUSTOMERMASTER(NOLOCK)
  1088. WHERE CUSTOMERID = @customerId
  1089. AND mobileapprovedDate IS NULL
  1090. )
  1091. BEGIN
  1092. SELECT '1' ErrorCode
  1093. ,'Customer already approved or does not exists!' Msg
  1094. ,NULL
  1095. RETURN
  1096. END
  1097. IF EXISTS (
  1098. SELECT 'X'
  1099. FROM dbo.customerMaster(NOLOCK)
  1100. WHERE replace(idNumber, '-', '') = replace(@custIdNumber, '-', '')
  1101. GROUP BY replace(idNumber, '-', '')
  1102. HAVING count(1) > 1
  1103. )
  1104. BEGIN
  1105. SELECT '1' ErrorCode
  1106. ,'Duplicate id number found for customer' Msg
  1107. ,NULL
  1108. RETURN
  1109. END
  1110. IF EXISTS (
  1111. SELECT 'X'
  1112. FROM dbo.customerMaster(NOLOCK)
  1113. WHERE replace(idNumber, '-', '') = replace(@custIdNumber, '-', '')
  1114. AND mobileapprovedDate IS NOT NULL
  1115. AND ISNULL(@isExistingCustomer, 1) = 0
  1116. )
  1117. BEGIN
  1118. SELECT '1' ErrorCode
  1119. ,'Customer with same id number already approved.' Msg
  1120. ,NULL
  1121. RETURN
  1122. END
  1123. EXEC PROC_CREATE_CUSTOMER_WALLET @CUSTOMER_ID = @customerId
  1124. ,@USER = @USER
  1125. IF @verifyType = 'verify'
  1126. BEGIN
  1127. IF @isValidatedCustomer = 'Y' AND (@verifyRemarks IS NULL OR @verifyRemarks='')
  1128. BEGIN
  1129. UPDATE CUSTOMERMASTER
  1130. SET mobileVerifiedby = @user
  1131. ,mobileVerifiedDate = Getdate()
  1132. ,mobileVerificationType = 'verified'
  1133. --,serviceUsedFor = 'CM'
  1134. WHERE customerId = @customerId
  1135. END
  1136. INSERT INTO applicationLogs (
  1137. logType
  1138. ,tableName
  1139. ,dataId
  1140. ,oldData
  1141. ,newData
  1142. ,module
  1143. ,createdBy
  1144. ,createdDate
  1145. )
  1146. VALUES (
  1147. 'approve-mobile-user-verify'
  1148. ,'CustomerMaster'
  1149. ,@customerId
  1150. ,'verify-new-user'
  1151. ,@verifyRemarks
  1152. ,'24'
  1153. ,@user
  1154. ,GETDATE()
  1155. )
  1156. SELECT '0' ErrorCode
  1157. --,'Customer verified successfully.' Msg
  1158. ,CASE
  1159. WHEN @isValidatedCustomer = 'Y' AND @verifyRemarks IS NULL
  1160. THEN 'Y'
  1161. WHEN @isValidatedCustomer = 'Y' AND @verifyRemarks IS NOT NULL
  1162. THEN 'R'
  1163. ELSE 'N'
  1164. END Msg
  1165. ,@customerId id
  1166. ,'Y' extra
  1167. ,'verified' EXTRA2
  1168. END
  1169. IF @verifyType = 'approve'
  1170. BEGIN
  1171. SET @isOfac = CASE
  1172. WHEN ISNULL(@ofacRemarks, '') = ''
  1173. THEN 'N'
  1174. ELSE 'Y'
  1175. END
  1176. UPDATE CUSTOMERMASTER
  1177. SET mobileApprovedBy = @user
  1178. ,mobileApprovedDate = Getdate()
  1179. ,mobileVerificationType = 'approved'
  1180. ,serviceUsedFor = 'CM'
  1181. ,approvedBy = @user
  1182. ,approvedDate = GETDATE()
  1183. ,mobileUser = 'Y'
  1184. ,ofacRemarks = @ofacRemarks
  1185. ,isOfac = @isOfac
  1186. ,verificationCode = 'COMPLETED'
  1187. WHERE customerId = @customerId
  1188. IF(@referelCode IS NOT NULL)
  1189. BEGIN
  1190. IF (LEFT(@referelCode, 3) IN ('MOB', 'ADM', 'CRP', 'ONL'))
  1191. BEGIN
  1192. SELECT @custId=customerId FROM customerMaster WHERE membershipId = @referelCode;
  1193. IF NOT EXISTS(select 'X' FROM Customer_Promotion where sourceCustomerid= @custId and destinationcustomerid=@customerId
  1194. AND CodeType='REGISTRATION')
  1195. BEGIN
  1196. EXEC proc_InsertRewardPoints @Flag = 'REGISTER', @CustomerId = @customerId, @ReferralId = @custId
  1197. END
  1198. END
  1199. ELSE
  1200. BEGIN
  1201. SELECT @refRowId = ROW_ID FROM REFERRAL_AGENT_WISE WHERE REFERRAL_CODE = @referelCode
  1202. IF NOT EXISTS(SELECT 'X' FROM REFERRAL_INCENTIVE_TRANSACTION_WISE WHERE CUSTOMER_ID = @customerId)
  1203. BEGIN
  1204. EXEC proc_InsertReferralRewardPoints @Flag = 'REGISTER', @CustomerId = @customerId, @ReferralId = @referelCode
  1205. END
  1206. EXEC proc_InsertRewardPoints @Flag = 'REGISTER', @CustomerId = @refRowId, @ReferralId = @customerId
  1207. END
  1208. END
  1209. IF @trustDocId IS NOT NULL
  1210. BEGIN
  1211. UPDATE trustDocCustomer SET verifiedDate=GETDATE() , verified=1 WHERE id=@trustDocId and customerId= @customerId;
  1212. --DECLARE @body varchar(150), @pinNo INT= DBO.FNAGetRandomTransactionPinNo(6);
  1213. -- update customerMaster set txnPin = @pinNo where customerId = @customerId and RegistrationType='EKYC';
  1214. --SET @body='Your Transaction PIN is '+ CAST( @pinNo AS varchar) +', please click notification at the top of dashboard to change it.';
  1215. -- INSERT INTO pushNotificationHistroy(customerId,body,title,createDate,imageURL,sentId,Type,isReservation,isRead,isSend,category)
  1216. -- SELECT @customerid,@body,'Txn Pin',getdate(),'',@customerId,0,0,0,0,'INFO'
  1217. END
  1218. SELECT @status = verificationCode FROM customerMaster WHERE customerId = @customerId
  1219. print @status
  1220. --return
  1221. IF(@status = 'NOT_COMPLETED')
  1222. BEGIN
  1223. UPDATE dbo.customerMaster
  1224. SET verifiedDate = GETDATE()
  1225. ,mobileverifiedby = CASE
  1226. WHEN @createdFrom IN ('O','M')
  1227. THEN @user
  1228. ELSE NULL
  1229. END
  1230. ,mobileverifieddate = CASE
  1231. WHEN @createdFrom IN ('O','M')
  1232. THEN GETDATE()
  1233. ELSE NULL
  1234. END
  1235. ,verifiedBy = @user
  1236. ,verificationCode = 'PROCESSING'
  1237. WHERE customerId = @customerId
  1238. SELECT '0' ErrorCode
  1239. ,'Customer status has been updated. Proceed to approve customer!' Msg
  1240. ,@customerId id
  1241. RETURN
  1242. END
  1243. SELECT @fcmid = deviceId, @deviceType = DeviceType FROM mobile_userRegistration WHERE customerId = @customerId
  1244. SELECT '0' ErrorCode
  1245. ,'Customer approved successfully.' Msg
  1246. ,@customerId id
  1247. ,@fcmid extra
  1248. ,@deviceType Extra2
  1249. ,'approved' Extra3
  1250. END
  1251. SELECT username = ISNULL(cm.userName, '')
  1252. ,[password] = dbo.FNADecryptString(cm.customerPassword)
  1253. ,[channel] = 'registration'
  1254. ,[account] = ISNULL(cm.membershipId, '')
  1255. ,fullName
  1256. ,CustomerBankName
  1257. ,cm.idType
  1258. ,REPLACE(cm.idNumber, ' ', '') AS [idNumber]
  1259. ,CONVERT(VARCHAR, cm.dob, 111) AS [dob]
  1260. FROM dbo.customerMaster cm(NOLOCK)
  1261. WHERE cm.customerId = @customerId
  1262. --For mobile broadcast notification
  1263. --EXEC ProcBroadCastMobile @Flag = 'customer-approve'
  1264. -- ,@RowId = @customerId
  1265. -- ,@ControlNo = @customerId
  1266. -- ,@CustomerId = @customerId
  1267. RETURN
  1268. END
  1269. ELSE IF @flag = 'update-obpId'
  1270. BEGIN
  1271. BEGIN TRAN
  1272. UPDATE dbo.customerMaster
  1273. SET obpId = @obpId
  1274. ,approvedDate = GETDATE()
  1275. ,approvedBy = @user
  1276. ,customerStatus = 'V'
  1277. ,verifiedBy = CASE
  1278. WHEN verifiedBy IS NULL
  1279. THEN @user
  1280. ELSE verifiedBy
  1281. END
  1282. ,verifiedDate = CASE
  1283. WHEN verifiedDate IS NULL
  1284. THEN GETDATE()
  1285. ELSE verifiedDate
  1286. END
  1287. WHERE customerId = @customerId
  1288. DECLARE @Mobile VARCHAR(20)
  1289. SELECT @virtualAccountNo = walletAccountNo
  1290. ,@CustomerBankName = firstName + '- Principle'
  1291. ,@Mobile = mobile
  1292. FROM customerMaster(NOLOCK)
  1293. WHERE customerId = @customerId
  1294. ----#### SEND NOTIFICATION TO CUSTOMER
  1295. DECLARE @SMSBody VARCHAR(90) = 'Dear ' + LEFT(@CustomerBankName, 14) + ' You are successfully registered with GME.Thank you for choosing GME.'
  1296. EXEC FastMoneyPro_Remit.dbo.proc_CallToSendSMS @FLAG = 'I'
  1297. ,@SMSBody = @SMSBody
  1298. ,@MobileNo = @Mobile
  1299. IF NOT EXISTS (
  1300. SELECT 'A'
  1301. FROM FastMoneyPro_Account.dbo.ac_master(NOLOCK)
  1302. WHERE acct_num = @virtualAccountNo
  1303. )
  1304. BEGIN
  1305. DECLARE @GL INT = 79
  1306. INSERT INTO FastMoneyPro_Account.dbo.ac_master (
  1307. acct_num
  1308. ,acct_name
  1309. ,gl_code
  1310. ,branch_id
  1311. ,acct_ownership
  1312. ,acct_rpt_code
  1313. ,acct_opn_date
  1314. ,clr_bal_amt
  1315. ,system_reserved_amt
  1316. ,lien_amt
  1317. ,utilised_amt
  1318. ,available_amt
  1319. ,created_date
  1320. ,created_by
  1321. ,company_id
  1322. )
  1323. SELECT @virtualAccountNo
  1324. ,@CustomerBankName
  1325. ,@GL
  1326. ,@customerId
  1327. ,'c'
  1328. ,'CP'
  1329. ,getdate()
  1330. ,0
  1331. ,0
  1332. ,0
  1333. ,0
  1334. ,0
  1335. ,getdate()
  1336. ,@user
  1337. ,1
  1338. END
  1339. COMMIT TRAN
  1340. SELECT '0' ErrorCode
  1341. ,'Customer Partern service account registered successfully.' Msg
  1342. ,@customerId id
  1343. END
  1344. ELSE IF @flag = 'checkVirtualNo'
  1345. BEGIN
  1346. IF NOT EXISTS (
  1347. SELECT 'X'
  1348. FROM dbo.customerMaster
  1349. WHERE walletAccountNo = @virtualAccountNo
  1350. )
  1351. SELECT '1' ErrorCode
  1352. ,'Invalid Virtual AccountNo' Msg
  1353. ,NULL id
  1354. RETURN;
  1355. END
  1356. ELSE IF @flag = 'checkPrimaryAccountNo'
  1357. BEGIN
  1358. IF NOT EXISTS (
  1359. SELECT 'X'
  1360. FROM dbo.customerMaster
  1361. WHERE bankAccountNo = @primaryAccountNo
  1362. )
  1363. SELECT '1' ErrorCode
  1364. ,'Invalid Primary AccountNo' Msg
  1365. ,NULL id
  1366. END
  1367. ELSE IF @flag = 'AuditList' --AUDITED DOC LIST
  1368. BEGIN
  1369. SET @sortBy = 'createdDate'
  1370. SET @sortOrder = 'desc'
  1371. SET @table =
  1372. '(
  1373. SELECT SN=ROW_NUMBER() over(ORDER BY cm.customerId asc)
  1374. ,customerId=cm.customerId
  1375. ,email=cm.email
  1376. ,fullName= REPLACE(ISNULL(cm.firstName, '''') + ISNULL('' '' + cm.middleName, '''') + ISNULL('' '' + cm.lastName1, ''''), '' '', '' '')
  1377. ,dob=CONVERT(VARCHAR,cm.dob,101)
  1378. ,address=cm.[address]
  1379. ,nativeCountry=com.countryName
  1380. ,idtype=sdv.detailTitle
  1381. ,idNumber=cm.idNumber
  1382. ,createdDate=CAST(cm.createdDate AS DATE)
  1383. ,verifiedBy=cm.verifiedBy
  1384. ,branchName=''''
  1385. ,verifiedDate=CAST(cm.verifiedDate AS DATE)
  1386. ,ipAddress=cm.ipAddress
  1387. ,mobile=cm.mobile
  1388. ,bankAccountNo
  1389. ,bankName=bl.bankName
  1390. ,cm.AuditBy,cm.AuditDate
  1391. FROM customerMaster cm(NOLOCK)
  1392. LEFT JOIN countryMaster com(NOLOCK) ON cm.nativeCountry=com.countryId
  1393. INNER JOIN staticDataValue sdv (NOLOCK) ON sdv.valueId=cm.idType AND sdv.typeID=1300
  1394. LEFT JOIN vwBankLists bl (NOLOCK) ON cm.bankName = bl.rowId
  1395. WHERE cm.verifiedDate IS NOT NULL AND cm.AuditDate IS NOT NULL'
  1396. IF ISNULL(@fromDate, '') <> ''
  1397. AND ISNULL(@toDate, '') <> ''
  1398. SET @table = @table + ' AND cm.createdDate BETWEEN ''' + CAST(@fromDate AS VARCHAR) + ''' AND ''' + CAST(@toDate AS VARCHAR) + ''''
  1399. SET @table = @table + ')x'
  1400. SET @sql_filter = ''
  1401. IF ISNULL(@searchCriteria, '') <> ''
  1402. AND ISNULL(@searchValue, '') <> ''
  1403. BEGIN
  1404. IF @searchCriteria = 'idNumber'
  1405. BEGIN
  1406. --IF ISNUMERIC(@searchValue)<>1
  1407. -- SET @searchValue='-1' --to ignore string value for datatype integer/customerID
  1408. --SET @sql_Filter=@sql_Filter + ' AND customerId = ''' +@searchValue+''''
  1409. SET @sql_Filter = @sql_Filter + ' AND REPLACE(idNumber, ''-'', '''') = ''' + REPLACE(@searchValue, '-', '') + ''''
  1410. END
  1411. ELSE IF @searchCriteria = 'emailId'
  1412. SET @sql_Filter = @sql_Filter + ' AND email like ''' + @searchValue + '%'''
  1413. ELSE IF @searchCriteria = 'customerName'
  1414. SET @sql_Filter = @sql_Filter + ' AND fullName like ''' + @searchValue + '%'''
  1415. ELSE IF @searchCriteria = 'mobile'
  1416. SET @sql_Filter = @sql_Filter + ' AND mobile = ''' + @searchValue + ''''
  1417. ELSE IF @searchCriteria = 'walletAccountNo'
  1418. SET @sql_Filter = @sql_Filter + ' AND walletAccountNo = ''' + @searchValue + ''''
  1419. ELSE IF @searchCriteria = 'bankAccountNo'
  1420. SET @sql_Filter = @sql_Filter + ' AND bankAccountNo = ''' + @searchValue + ''''
  1421. ELSE IF @searchCriteria = 'nativeCountry'
  1422. SET @sql_Filter = @sql_Filter + ' AND nativeCountry = ''' + @searchValue + ''''
  1423. END
  1424. SET @select_field_list = '
  1425. SN,customerId,email,fullName,dob,address,nativeCountry,idtype,idNumber
  1426. ,createdDate,verifiedBy,branchName,verifiedDate,bankAccountNo,bankName,AuditBy,AuditDate
  1427. '
  1428. EXEC dbo.proc_paging @table
  1429. ,@sql_filter
  1430. ,@select_field_list
  1431. ,@extra_field_list
  1432. ,@sortBy
  1433. ,@sortOrder
  1434. ,@pageSize
  1435. ,@pageNumber
  1436. RETURN
  1437. END
  1438. ELSE IF @flag = 's-customereditedata'
  1439. BEGIN
  1440. IF @sortBy IS NULL
  1441. SET @sortBy = 'createdDate'
  1442. IF @sortOrder IS NULL
  1443. SET @sortOrder = 'DESC'
  1444. SET @table = '(
  1445. SELECT fullName
  1446. ,customerId
  1447. ,membershipId
  1448. ,mobile
  1449. ,city
  1450. ,rowId
  1451. ,createdDate
  1452. ,hasChanged = CASE WHEN approvedBy IS NULL THEN ''Y'' ELSE ''N'' END
  1453. ,modifiedBy = CASE WHEN approvedBy IS NULL THEN createdBy ELSE createdBy END
  1454. from customerMasterEditedDataMod
  1455. )x'
  1456. SET @sql_filter = ''
  1457. SET @select_field_list = 'fullName,customerId,membershipId,mobile,city,rowId,createdDate,hasChanged,modifiedBy'
  1458. EXEC dbo.proc_paging @table
  1459. ,@sql_filter
  1460. ,@select_field_list
  1461. ,@extra_field_list
  1462. ,@sortBy
  1463. ,@sortOrder
  1464. ,@pageSize
  1465. ,@pageNumber
  1466. END
  1467. ELSE IF @flag = 's-customereditedata-new'
  1468. BEGIN
  1469. IF @sortBy IS NULL
  1470. SET @sortBy = 'createdDate'
  1471. IF @sortOrder IS NULL
  1472. SET @sortOrder = 'DESC'
  1473. SET @table = '(
  1474. SELECT cm.fullName
  1475. ,cm.customerId
  1476. ,cm.membershipId
  1477. ,cm.mobile
  1478. ,cm.city
  1479. ,cmMode.rowId
  1480. ,cm.createdDate
  1481. ,hasChanged = CASE WHEN cmMode.approvedBy IS NULL THEN ''Y'' ELSE ''N'' END
  1482. ,modifiedBy = CASE WHEN cmMode.approvedBy IS NULL THEN cmMode.createdBy ELSE cmMode.createdBy END
  1483. ,case when ISNULL(cm.createdFrom, ''C'') = ''C'' THEN ''COUNTER'' WHEN cm.createdFrom = ''M'' THEN ''MOBILE'' ELSE cm.createdFrom END createdFrom
  1484. from customerMasterEditedDataMod cmMode (nolock)
  1485. INNER JOIN CUSTOMERMASTER CM (NOLOCK) ON CM.CUSTOMERID = cmMode.customerId
  1486. )x'
  1487. SET @sql_filter = ''
  1488. SET @select_field_list = 'fullName,customerId,membershipId,mobile,city,rowId,createdDate,hasChanged,modifiedBy'
  1489. EXEC dbo.proc_paging @table
  1490. ,@sql_filter
  1491. ,@select_field_list
  1492. ,@extra_field_list
  1493. ,@sortBy
  1494. ,@sortOrder
  1495. ,@pageSize
  1496. ,@pageNumber
  1497. END
  1498. ELSE IF @flag = 'approve'
  1499. BEGIN
  1500. DECLARE @firstName VARCHAR(30) = NULL
  1501. ,@middleName VARCHAR(30) = NULL
  1502. ,@lastName1 VARCHAR(100) = NULL
  1503. ,@onlineUser VARCHAR(50) = NULL
  1504. ,@customerType VARCHAR(30) = NULL
  1505. ,@country VARCHAR(30) = NULL
  1506. ,@zipCode VARCHAR(30) = NULL
  1507. ,@state VARCHAR(30) = NULL
  1508. ,@street VARCHAR(80) = NULL
  1509. ,@custCity VARCHAR(100) = NULL
  1510. ,@cityUnicode NVARCHAR(100) = NULL
  1511. ,@streetUnicode NVARCHAR(100) = NULL
  1512. ,@custGender VARCHAR(30) = NULL
  1513. ,@custNativecountry VARCHAR(30) = NULL
  1514. ,@custDOB VARCHAR(30) = NULL
  1515. ,@custEmail VARCHAR(50) = NULL
  1516. ,@custTelNo VARCHAR(30) = NULL
  1517. ,@custMobile VARCHAR(30) = NULL
  1518. ,@dob DATETIME = NULL
  1519. ,@visaStatus INT = NULL
  1520. ,@employeeBusinessType INT = NULL
  1521. ,@nameOfEmployeer VARCHAR(80) = NULL
  1522. ,@SSNNO VARCHAR(20) = NULL
  1523. ,@occupation VARCHAR(30) = NULL
  1524. ,@sourceOfFound VARCHAR(100) = NULL
  1525. ,@monthlyIncome VARCHAR(50) = NULL
  1526. ,@customerIdType VARCHAR(30) = NULL
  1527. ,@customerIdNo VARCHAR(50) = NULL
  1528. ,@custIdissueDate VARCHAR(30) = NULL
  1529. ,@custIdValidDate VARCHAR(30) = NULL
  1530. ,@remittanceAllowed BIT = NULL
  1531. ,@remarks VARCHAR(1000) = NULL
  1532. ,@companyName VARCHAR(100) = NULL
  1533. ,@registerationNo VARCHAR(30) = NULL
  1534. ,@organizationType INT = NULL
  1535. ,@dateofIncorporation DATETIME = NULL
  1536. ,@natureOfCompany INT = NULL
  1537. ,@nameOfAuthorizedPerson VARCHAR(80) = NULL
  1538. ,@position INT = NULL
  1539. SELECT @customerId = customerId
  1540. ,@customerType = customerType
  1541. ,@fullName = fullName
  1542. ,@firstName = firstName
  1543. ,@middleName = middleName
  1544. ,@lastName1 = lastName1
  1545. ,@country = country
  1546. ,@zipCode = zipCode
  1547. ,@state = STATE
  1548. ,@street = street
  1549. ,@custCity = city
  1550. ,@cityUnicode = cityUnicode
  1551. ,@streetUnicode = streetUnicode
  1552. ,@custGender = gender
  1553. ,@custNativecountry = nativeCountry
  1554. ,@custDOB = CONVERT(VARCHAR, dob, 111)
  1555. ,@custEmail = email
  1556. ,@custTelNo = telNo
  1557. ,@custMobile = mobile
  1558. ,@visaStatus = visaStatus
  1559. ,@employeeBusinessType = employeeBusinessType
  1560. ,@nameOfEmployeer = nameOfEmployeer
  1561. ,@SSNNO = SSNNO
  1562. ,@occupation = occupation
  1563. ,@sourceOfFound = sourceOfFund
  1564. ,@monthlyIncome = monthlyIncome
  1565. ,@customerIdType = idType
  1566. ,@customerIdNo = idNumber
  1567. ,@custIdissueDate = CONVERT(VARCHAR, idIssueDate, 111)
  1568. ,@custIdValidDate = CONVERT(VARCHAR, idExpiryDate, 111)
  1569. ,@remittanceAllowed = remittanceAllowed
  1570. ,@onlineUser = onlineUser
  1571. ,@remarks = remarks
  1572. ,@companyName = companyName
  1573. ,@registerationNo = registerationNo
  1574. ,@organizationType = organizationType
  1575. ,@dateofIncorporation = CONVERT(VARCHAR, dateofIncorporation, 111)
  1576. ,@natureOfCompany = natureOfCompany
  1577. ,@nameOfAuthorizedPerson = nameOfAuthorizedPerson
  1578. ,@position = position
  1579. FROM dbo.customerMasterEditedDataMod
  1580. WHERE customerId = @customerId
  1581. --LOG FOR CUSTOMER UPDATE
  1582. --SET @fullName=ISNULL(@firstName, '') + ISNULL(' '
  1583. -- + @firstName,
  1584. -- '') + ISNULL(' '
  1585. -- + @lastName1, '');
  1586. SET @onlineUser = CASE
  1587. WHEN @onlineUser = 'Y'
  1588. THEN 'True'
  1589. ELSE 'False'
  1590. END
  1591. EXEC PROC_CUSTOMERMODIFYLOG @flag = 'i-new'
  1592. ,@user = @user
  1593. ,@customerId = @customerId
  1594. ,@customerType = @customerType
  1595. ,@fullName = @fullName
  1596. ,@firstName = @firstName
  1597. ,@middleName = @middleName
  1598. ,@lastName1 = @lastName1
  1599. ,@country = @country
  1600. ,@zipCode = @zipCode
  1601. ,@state = @state
  1602. ,@street = @street
  1603. ,@custCity = @custCity
  1604. ,@cityUnicode = @cityUnicode
  1605. ,@streetUnicode = @streetUnicode
  1606. ,@custGender = @custGender
  1607. ,@custNativecountry = @custNativecountry
  1608. ,@dob = @custDOB
  1609. ,@email = @custEmail
  1610. ,@custTelNo = @custTelNo
  1611. ,@mobileNumber = @custMobile
  1612. ,@visaStatus = @visaStatus
  1613. ,@employeeBusinessType = @employeeBusinessType
  1614. ,@nameOfEmployeer = @nameOfEmployeer
  1615. ,@SSNNO = @SSNNO
  1616. ,@occupation = @occupation
  1617. ,@sourceOfFound = @sourceOfFound
  1618. ,@monthlyIncome = @monthlyIncome
  1619. ,@idType = @customerIdType
  1620. ,@idNumber = @customerIdNo
  1621. ,@issueDate = @custIdissueDate
  1622. ,@expiryDate = @custIdValidDate
  1623. ,@remittanceAllowed = @remittanceAllowed
  1624. ,@onlineUser = @onlineUser
  1625. ,@remarks = @remarks
  1626. ,
  1627. --used for customer type organisation
  1628. @companyName = @companyName
  1629. ,@registerationNo = @registerationNo
  1630. ,@organizationType = @organizationType
  1631. ,@dateofIncorporation = @dateofIncorporation
  1632. ,@natureOfCompany = @natureOfCompany
  1633. ,@nameOfAuthorizedPerson = @nameOfAuthorizedPerson
  1634. ,@position = @position
  1635. UPDATE cm
  1636. SET cm.firstName = cmm.firstName
  1637. ,cm.middleName = cmm.middleName
  1638. ,cm.lastName1 = cmm.lastName1
  1639. ,cm.country = cmm.country
  1640. ,cm.STATE = cmm.STATE
  1641. ,cm.zipCode = cmm.zipCode
  1642. ,cm.city = cmm.city
  1643. ,cm.street = cmm.street
  1644. ,cm.fullName = ISNULL(cmm.firstName, '') + ISNULL(' ' + cmm.middleName, '') + ISNULL(' ' + cmm.lastName1, '')
  1645. ,cm.email = cmm.email
  1646. ,cm.cityUnicode = cmm.cityUnicode
  1647. ,cm.streetUnicode = cmm.streetUnicode
  1648. ,cm.homePhone = cmm.homePhone
  1649. ,cm.mobile = cmm.mobile
  1650. ,cm.nativeCountry = cmm.nativeCountry
  1651. ,cm.dob = cmm.dob
  1652. ,cm.nameOfEmployeer = cmm.nameOfEmployeer
  1653. ,cm.SSNNO = cmm.SSNNO
  1654. ,cm.occupation = cmm.occupation
  1655. ,cm.idExpiryDate = cmm.idExpiryDate
  1656. ,cm.idType = cmm.idType
  1657. ,cm.idNumber = cmm.idNumber
  1658. ,cm.telNo = cmm.telNo
  1659. ,cm.gender = cmm.gender
  1660. ,cm.idIssueDate = cmm.idIssueDate
  1661. ,cm.onlineUser = cmm.onlineUser
  1662. ,cm.sourceOfFund = cmm.sourceOfFund
  1663. ,cm.visaStatus = cmm.visaStatus
  1664. ,cm.employeeBusinessType = cmm.employeeBusinessType
  1665. ,cm.remittanceAllowed = cmm.remittanceAllowed
  1666. ,cm.remarks = cmm.remarks
  1667. ,cm.organizationType = cmm.organizationType
  1668. ,cm.dateofIncorporation = cmm.dateofIncorporation
  1669. ,cm.natureOfCompany = cmm.natureOfCompany
  1670. ,cm.nameOfAuthorizedPerson = cmm.nameOfAuthorizedPerson
  1671. ,cm.monthlyIncome = cmm.monthlyIncome
  1672. ,cm.registerationNo = cmm.registerationNo
  1673. ,cm.modifiedBy = @user
  1674. ,cm.modifiedDate = GETDATE()
  1675. FROM dbo.customerMaster cm(NOLOCK)
  1676. INNER JOIN dbo.customerMasterEditedDataMod cmm(NOLOCK) ON cmm.customerId = cm.customerId
  1677. WHERE cm.customerId = @customerId
  1678. DELETE
  1679. FROM dbo.customerMasterEditedDataMod
  1680. WHERE customerId = @customerId
  1681. EXEC proc_errorHandler 0
  1682. ,'Customer Edited Data Approved Successfully'
  1683. ,@customerId
  1684. END
  1685. ELSE IF @flag = 'reject'
  1686. BEGIN
  1687. DELETE
  1688. FROM dbo.customerMasterEditedDataMod
  1689. WHERE customerId = @customerId
  1690. EXEC dbo.proc_errorHandler @errorCode = '0'
  1691. ,-- varchar(10)
  1692. @msg = 'Changes rejected successfully'
  1693. ,-- varchar(max)
  1694. @id = @customerid -- varchar(50)
  1695. END
  1696. IF @flag = 'vl-forAgent' --verified list/approve pending list
  1697. BEGIN
  1698. --DECLARE @agentid VARCHAR(10)
  1699. --SELECT @agentid = agentid FROM applicationusers WHERE username = @user
  1700. --DECLARE @branchcode VARCHAR(10)
  1701. --SELECT @branchcode = branchcode FROM agentmaster WHERE agentid = @agentid
  1702. SET @sortBy = 'createdDate'
  1703. SET @sortOrder = 'desc'
  1704. SET @table =
  1705. '(
  1706. SELECT customerId=cm.customerId
  1707. ,CM.membershipid
  1708. ,email=cm.email
  1709. ,fullName= REPLACE(ISNULL(cm.firstName, '''') + ISNULL('' '' + cm.middleName, '''') + ISNULL('' '' + cm.lastName1, ''''), '' '', '' '')
  1710. ,dob=CONVERT(VARCHAR,cm.dob,101)
  1711. ,address=cm.[address]
  1712. ,nativeCountry=com.countryName
  1713. ,idtype=case when cm.idtype = ''11402'' then cm.otherIdNumber else sdv.detailTitle end
  1714. ,idNumber= cm.idNumber
  1715. ,createdDate=CAST(cm.createdDate AS DATE)
  1716. ,createdBy=cm.createdBy
  1717. ,verifiedBy=cm.verifiedBy
  1718. ,branchName=''''
  1719. ,verifiedDate=CAST(cm.verifiedDate AS DATE)
  1720. ,ipAddress=cm.ipAddress
  1721. ,mobile=cm.mobile
  1722. ,bankAccountNo
  1723. ,bankName=bl.bankName
  1724. ,cm.agentId
  1725. FROM customerMaster cm(NOLOCK)
  1726. INNER JOIN APPLICATIONUSERS AU(NOLOCK) ON AU.USERNAME = CM.CREATEDBY
  1727. LEFT JOIN countryMaster com(NOLOCK) ON cm.nativeCountry=com.countryId
  1728. INNER JOIN staticDataValue sdv (NOLOCK) ON sdv.valueId=cm.idType AND sdv.typeID=1300
  1729. LEFT JOIN vwBankLists bl (NOLOCK) ON cm.bankName = bl.rowId
  1730. WHERE 1=1
  1731. --AND ISNULL(CM.isVerifiedByCustomer, 0) = 1
  1732. AND au.username <> '''
  1733. + @user + '''
  1734. AND cm.approvedDate IS NULL
  1735. AND CM.ISACTIVE = ''Y'''
  1736. IF ISNULL(@fromDate, '') <> ''
  1737. AND ISNULL(@toDate, '') <> ''
  1738. SET @table = @table + ' AND cm.createdDate BETWEEN ''' + CAST(@fromDate AS VARCHAR) + ''' AND ''' + CAST(@toDate AS VARCHAR) + ''''
  1739. SET @table = @table + ')x'
  1740. SET @sql_filter = ''
  1741. --SET @sql_Filter=@sql_Filter + ' AND substring(membershipid,1,3) = '''+@branchcode+''''
  1742. SET @sql_Filter = @sql_Filter + ' AND agentId = ' + cast(@agentId AS VARCHAR) + ''
  1743. IF ISNULL(@searchCriteria, '') <> ''
  1744. AND ISNULL(@searchValue, '') <> ''
  1745. BEGIN
  1746. IF @searchCriteria = 'idNumber'
  1747. BEGIN
  1748. --IF ISNUMERIC(@searchValue)<>1
  1749. -- SET @searchValue='-1' --to ignore string value for datatype integer/customerID
  1750. --SET @sql_Filter=@sql_Filter + ' AND customerId = ''' +@searchValue+''''
  1751. SET @sql_Filter = @sql_Filter + ' AND REPLACE(idNumber, ''-'', '''') = ''' + REPLACE(@searchValue, '-', '') + ''''
  1752. END
  1753. ELSE IF @searchCriteria = 'emailId'
  1754. SET @sql_Filter = @sql_Filter + ' AND email like ''' + @searchValue + '%'''
  1755. ELSE IF @searchCriteria = 'customerName'
  1756. SET @sql_Filter = @sql_Filter + ' AND fullName like ''' + @searchValue + '%'''
  1757. ELSE IF @searchCriteria = 'mobile'
  1758. SET @sql_Filter = @sql_Filter + ' AND mobile = ''' + @searchValue + ''''
  1759. ELSE IF @searchCriteria = 'walletAccountNo'
  1760. SET @sql_Filter = @sql_Filter + ' AND walletAccountNo = ''' + @searchValue + ''''
  1761. ELSE IF @searchCriteria = 'bankAccountNo'
  1762. SET @sql_Filter = @sql_Filter + ' AND bankAccountNo = ''' + @searchValue + ''''
  1763. ELSE IF @searchCriteria = 'nativeCountry'
  1764. SET @sql_Filter = @sql_Filter + ' AND nativeCountry = ''' + @searchValue + ''''
  1765. END
  1766. SET @select_field_list = '
  1767. customerId,membershipid,email,fullName,dob,address,nativeCountry,idtype,idNumber
  1768. ,createdDate,createdBy,verifiedBy,branchName,verifiedDate,bankAccountNo,bankName
  1769. '
  1770. EXEC dbo.proc_paging @table
  1771. ,@sql_filter
  1772. ,@select_field_list
  1773. ,@extra_field_list
  1774. ,@sortBy
  1775. ,@sortOrder
  1776. ,@pageSize
  1777. ,@pageNumber
  1778. RETURN
  1779. END
  1780. IF @flag = 'unVerifiedCustomerFromMobile' -- unverified list/verify pending list
  1781. BEGIN
  1782. IF @sortBy IS NULL
  1783. SET @sortBy = 'createdDate'
  1784. IF @sortOrder IS NULL
  1785. SET @sortOrder = 'DESC'
  1786. SET @table =
  1787. '(
  1788. SELECT customerId=cm.customerId
  1789. ,CM.membershipid
  1790. ,cm.userName
  1791. ,email=cm.email
  1792. ,fullName= REPLACE(ISNULL(cm.firstName, '''') + ISNULL('' '' + cm.middleName, '''') + ISNULL('' '' + cm.lastName1, ''''), '' '', '' '')
  1793. ,dob=CONVERT(VARCHAR,cm.dob,101)
  1794. ,address=cm.[address]
  1795. ,nativeCountry=com.countryName
  1796. ,idtype= case when cm.idtype=''11402'' then ISNULL(sdv.detailTitle, '''') + (''-'') + ISNULL('' '' + cm.otherIdNumber, '''') else sdv.detailTitle end
  1797. ,idNumber=cm.idNumber
  1798. ,createdDate=CAST(cm.createdDate AS DATE)
  1799. ,createdBy=cm.createdBy
  1800. ,verifiedBy=cm.verifiedBy
  1801. ,branchName=''''
  1802. ,verifiedDate=CAST(cm.verifiedDate AS DATE)
  1803. ,ipAddress=cm.ipAddress
  1804. ,mobile=cm.mobile
  1805. ,bankAccountNo
  1806. ,cm.agentId
  1807. ,case when isnull(cm.isExistingCustomer,1) = 1 then ''Yes'' ELSE ''No'' End isExistingCustomer
  1808. ,createdUserFrom = ''mobile''
  1809. ,ISNULL(verifyRemarks,'''') VerifyRemarks
  1810. ,[RegistrationType] = CASE WHEN cm.RegistrationType IS NULL THEN ''MANUAL'' WHEN cm.registrationtype=''MKYC'' THEN ''MANUAL'' ELSE cm.RegistrationType END
  1811. ,[TructDocState]= dbo.FNAGetTrustDocStatus(cm.trustdocid)
  1812. FROM customerMaster cm(NOLOCK)
  1813. LEFT JOIN countryMaster com(NOLOCK) ON cm.nativeCountry=com.countryId
  1814. INNER JOIN staticDataValue sdv (NOLOCK) ON sdv.valueId=cm.idType AND sdv.typeID=1300
  1815. AND CM.ISACTIVE = ''Y''
  1816. AND USERNAME IS NOT NULL
  1817. AND cm.MOBILEVERIFIEDDATE IS NULL
  1818. and cm.membershipId is not null
  1819. and ISNULL(cm.serviceUsedFor, ''C'') NOT LIKE ''%M%''
  1820. and ISNULL(cm.isEmailVerified, 0) = 1
  1821. and ISNULL(cm.agreeYn,0)= 1
  1822. UNION ALL
  1823. SELECT customerId=cm.customerId
  1824. ,CM.membershipid
  1825. ,cm.userName
  1826. ,email=cm.email
  1827. ,fullName= REPLACE(ISNULL(cm.firstName, '''') + ISNULL('' '' + cm.middleName, '''') + ISNULL('' '' + cm.lastName1, ''''), '' '', '' '')
  1828. ,dob=CONVERT(VARCHAR,cm.dob,101)
  1829. ,address=cm.[address]
  1830. ,nativeCountry=com.countryName
  1831. ,idtype=sdv.detailTitle
  1832. ,idNumber=cm.idNumber
  1833. ,createdDate=CAST(cm.createdDate AS DATE)
  1834. ,createdBy=cm.createdBy
  1835. ,verifiedBy=cm.verifiedBy
  1836. ,branchName=''''
  1837. ,verifiedDate=CAST(cm.verifiedDate AS DATE)
  1838. ,ipAddress=cm.ipAddress
  1839. ,mobile=cm.mobile
  1840. ,bankAccountNo
  1841. ,cm.agentId
  1842. ,case when isnull(cm.isExistingCustomer,1) = 1 then ''Yes'' ELSE ''No'' End isExistingCustomer
  1843. ,createdUserFrom = ''core''
  1844. ,ISNULL(verifyRemarks,'''') VerifyRemarks
  1845. ,[RegistrationType] = CASE WHEN cm.RegistrationType IS NULL THEN ''MANUAL'' WHEN cm.registrationtype=''MKYC'' THEN ''MANUAL'' ELSE cm.RegistrationType END
  1846. ,[TructDocState]= dbo.FNAGetTrustDocStatus(cm.trustdocid)
  1847. FROM customerMaster cm(NOLOCK)
  1848. LEFT JOIN countryMaster com(NOLOCK) ON cm.nativeCountry=com.countryId
  1849. INNER JOIN staticDataValue sdv (NOLOCK) ON sdv.valueId=cm.idType AND sdv.typeID=1300
  1850. AND CM.ISACTIVE = ''Y''
  1851. AND USERNAME IS NOT NULL
  1852. AND cm.MOBILEVERIFIEDDATE IS NULL
  1853. and cm.membershipId is not null
  1854. and cm.serviceUsedFor LIKE ''%M%''
  1855. and ISNULL(cm.isEmailVerified, 0) = 0
  1856. and cm.approvedDate IS NOT NULL
  1857. '
  1858. IF ISNULL(@fromDate, '') <> ''
  1859. AND ISNULL(@toDate, '') <> ''
  1860. SET @table = @table + ' AND cm.createdDate BETWEEN ''' + CAST(@fromDate AS VARCHAR) + ''' AND ''' + CAST(@toDate AS VARCHAR) + ''''
  1861. SET @table = @table + ')x'
  1862. SET @sql_filter = ''
  1863. IF ISNULL(@searchCriteria, '') <> ''
  1864. AND ISNULL(@searchValue, '') <> ''
  1865. BEGIN
  1866. IF @searchCriteria = 'idNumber'
  1867. BEGIN
  1868. SET @sql_Filter = @sql_Filter + ' AND REPLACE(idNumber, ''-'', '''') = ''' + REPLACE(@searchValue, '-', '') + ''''
  1869. END
  1870. ELSE IF @searchCriteria = 'emailId'
  1871. SET @sql_Filter = @sql_Filter + ' AND email like ''' + @searchValue + '%'''
  1872. ELSE IF @searchCriteria = 'customerName'
  1873. SET @sql_Filter = @sql_Filter + ' AND fullName like ''' + @searchValue + '%'''
  1874. ELSE IF @searchCriteria = 'mobile'
  1875. SET @sql_Filter = @sql_Filter + ' AND mobile = ''' + @searchValue + ''''
  1876. ELSE IF @searchCriteria = 'walletAccountNo'
  1877. SET @sql_Filter = @sql_Filter + ' AND walletAccountNo = ''' + @searchValue + ''''
  1878. ELSE IF @searchCriteria = 'bankAccountNo'
  1879. SET @sql_Filter = @sql_Filter + ' AND bankAccountNo = ''' + @searchValue + ''''
  1880. ELSE IF @searchCriteria = 'nativeCountry'
  1881. SET @sql_Filter = @sql_Filter + ' AND nativeCountry = ''' + @searchValue + ''''
  1882. END
  1883. SET @select_field_list = '
  1884. customerId,userName,isExistingCustomer,membershipid,email,fullName,dob,address,nativeCountry,idtype,idNumber
  1885. ,createdDate,createdBy,verifiedBy,branchName,verifiedDate,bankAccountNo,createdUserFrom,VerifyRemarks,RegistrationType,TructDocState
  1886. '
  1887. EXEC dbo.proc_paging @table
  1888. ,@sql_filter
  1889. ,@select_field_list
  1890. ,@extra_field_list
  1891. ,@sortBy
  1892. ,@sortOrder
  1893. ,@pageSize
  1894. ,@pageNumber
  1895. RETURN
  1896. END
  1897. IF @flag = 'unApprovedCustomerFromAgent' --verified list/approve pending list
  1898. BEGIN
  1899. SET @sortBy = 'createdDate'
  1900. SET @sortOrder = 'desc'
  1901. SET @table =
  1902. '(
  1903. SELECT customerId=cm.customerId
  1904. ,CM.membershipid
  1905. ,email=cm.email
  1906. ,fullName= REPLACE(ISNULL(cm.firstName, '''') + ISNULL('' '' + cm.middleName, '''') + ISNULL('' '' + cm.lastName1, ''''), '' '', '' '')
  1907. ,dob=CONVERT(VARCHAR,cm.dob,101)
  1908. ,address=cm.[address]
  1909. ,nativeCountry=com.countryName
  1910. ,idtype=sdv.detailTitle
  1911. ,idNumber=cm.idNumber
  1912. ,createdDate=CAST(cm.createdDate AS DATE)
  1913. ,createdBy=cm.createdBy
  1914. ,verifiedBy=cm.verifiedBy
  1915. ,branchName=''''
  1916. ,verifiedDate=CAST(cm.verifiedDate AS DATE)
  1917. ,ipAddress=cm.ipAddress
  1918. ,mobile=cm.mobile
  1919. ,bankAccountNo
  1920. ,bankName=bl.bankName
  1921. ,cm.agentId
  1922. FROM customerMaster cm(NOLOCK)
  1923. LEFT JOIN countryMaster com(NOLOCK) ON cm.nativeCountry=com.countryId
  1924. INNER JOIN staticDataValue sdv (NOLOCK) ON sdv.valueId=cm.idType AND sdv.typeID=1300
  1925. LEFT JOIN vwBankLists bl (NOLOCK) ON cm.bankName = bl.rowId
  1926. where cm.approvedDate IS NULL
  1927. AND CM.ISACTIVE = ''Y''
  1928. AND MEMBERSHIPID LIKE ''%AGT%''
  1929. AND CREATEDFROM = ''A''
  1930. '
  1931. IF ISNULL(@fromDate, '') <> ''
  1932. AND ISNULL(@toDate, '') <> ''
  1933. SET @table = @table + ' AND cm.createdDate BETWEEN ''' + CAST(@fromDate AS VARCHAR) + ''' AND ''' + ISNULL(CAST(@toDate AS VARCHAR), '') + ''''
  1934. SET @table = @table + ')x'
  1935. SET @sql_filter = ''
  1936. IF ISNULL(@searchCriteria, '') <> ''
  1937. AND ISNULL(@searchValue, '') <> ''
  1938. BEGIN
  1939. IF @searchCriteria = 'idNumber'
  1940. BEGIN
  1941. --IF ISNUMERIC(@searchValue)<>1
  1942. -- SET @searchValue='-1' --to ignore string value for datatype integer/customerID
  1943. --SET @sql_Filter=@sql_Filter + ' AND customerId = ''' +@searchValue+''''
  1944. SET @sql_Filter = @sql_Filter + ' AND REPLACE(idNumber, ''-'', '''') = ''' + REPLACE(@searchValue, '-', '') + ''''
  1945. END
  1946. ELSE IF @searchCriteria = 'emailId'
  1947. SET @sql_Filter = @sql_Filter + ' AND email like ''' + @searchValue + '%'''
  1948. ELSE IF @searchCriteria = 'customerName'
  1949. SET @sql_Filter = @sql_Filter + ' AND fullName like ''' + @searchValue + '%'''
  1950. ELSE IF @searchCriteria = 'mobile'
  1951. SET @sql_Filter = @sql_Filter + ' AND mobile = ''' + @searchValue + ''''
  1952. ELSE IF @searchCriteria = 'walletAccountNo'
  1953. SET @sql_Filter = @sql_Filter + ' AND walletAccountNo = ''' + @searchValue + ''''
  1954. ELSE IF @searchCriteria = 'bankAccountNo'
  1955. SET @sql_Filter = @sql_Filter + ' AND bankAccountNo = ''' + @searchValue + ''''
  1956. ELSE IF @searchCriteria = 'nativeCountry'
  1957. SET @sql_Filter = @sql_Filter + ' AND nativeCountry = ''' + @searchValue + ''''
  1958. END
  1959. SET @select_field_list = '
  1960. customerId,membershipid,email,fullName,dob,address,nativeCountry,idtype,idNumber
  1961. ,createdDate,createdBy,verifiedBy,branchName,verifiedDate,bankAccountNo,bankName
  1962. '
  1963. EXEC dbo.proc_paging @table
  1964. ,@sql_filter
  1965. ,@select_field_list
  1966. ,@extra_field_list
  1967. ,@sortBy
  1968. ,@sortOrder
  1969. ,@pageSize
  1970. ,@pageNumber
  1971. RETURN
  1972. END
  1973. IF @flag = 'unApprovedCustomerFromMobile' --verified list/approve pending list
  1974. BEGIN
  1975. IF @sortBy IS NULL
  1976. SET @sortBy = 'createdDate'
  1977. IF @sortOrder IS NULL
  1978. SET @sortOrder = 'DESC'
  1979. SET @table =
  1980. '(
  1981. SELECT customerId=cm.customerId
  1982. ,MEMBERSHIPID = ''<a href="/Remit/Administration/CustomerSetup/CustomerDetails.aspx?customerId=''+ CAST(CM.CUSTOMERID AS VARCHAR) + ''">'' + CM.membershipId +''</a>''
  1983. --,CM.membershipid ''<a href="' + dbo.FNAGetURL() + 'Remit/Administration/CustomerSetup/CustomerDetails.aspx?customerId='' + CAST(CM.customerId AS VARCHAR(50)) + ''">''
  1984. -- + CM.membershipId + ''</a>''
  1985. ,cm.userName
  1986. ,email=cm.email
  1987. ,fullName= REPLACE(ISNULL(cm.firstName, '''') + ISNULL('' '' + cm.middleName, '''') + ISNULL('' '' + cm.lastName1, ''''), '' '', '' '')
  1988. ,dob=CONVERT(VARCHAR,cm.dob,101)
  1989. ,address=cm.[address]
  1990. ,nativeCountry=com.countryName
  1991. ,idtype= case when cm.idtype=''11402'' then ISNULL(sdv.detailTitle, '''') + (''-'') + ISNULL('' '' + cm.otherIdNumber, '''') else sdv.detailTitle end
  1992. ,idNumber=cm.idNumber
  1993. ,createdDate=CAST(cm.createdDate AS DATE)
  1994. ,createdBy=cm.createdBy
  1995. ,verifiedBy=cm.verifiedBy
  1996. ,branchName=''''
  1997. ,verifiedDate=CAST(cm.verifiedDate AS DATE)
  1998. ,ipAddress=cm.ipAddress
  1999. ,mobile=cm.mobile
  2000. ,bankAccountNo
  2001. ,cm.agentId
  2002. ,case when isnull(cm.isExistingCustomer,1) = 1 then ''Yes'' ELSE ''No'' End isExistingCustomer
  2003. ,createdUserFrom = ''mobile''
  2004. ,LawsonCardNo = cm.LawsonCardNo
  2005. ,[RegistrationType] = CASE WHEN cm.LawsonCardNo IS NULL THEN '''' ELSE cm.LawsonCardNo END
  2006. ,ISNULL(verificationCode,''NOT_COMPLETED'') verificationCode
  2007. FROM customerMaster cm(NOLOCK)
  2008. LEFT JOIN countryMaster com(NOLOCK) ON cm.nativeCountry=com.countryId
  2009. INNER JOIN staticDataValue sdv (NOLOCK) ON sdv.valueId=cm.idType AND sdv.typeID=1300
  2010. AND CM.ISACTIVE = ''Y''
  2011. AND USERNAME IS NOT NULL
  2012. AND cm.MOBILEVERIFIEDDATE IS not NULL
  2013. and cm.membershipId is not null
  2014. -- and cm.serviceUsedFor LIKE ''%M%''
  2015. and ISNULL(cm.serviceUsedFor, ''C'') NOT LIKE ''%M%''
  2016. and ISNULL(cm.isEmailVerified, 0) = 1
  2017. and cm.mobileVerificationType = ''verified''
  2018. and ISNULL(cm.agreeYn,0)= 1
  2019. and cm.hasDeclare = ''1''
  2020. and cm.agreeYn = ''1''
  2021. UNION ALL
  2022. SELECT customerId=cm.customerId
  2023. ,MEMBERSHIPID = ''<a href="/Remit/Administration/CustomerSetup/CustomerDetails.aspx?customerId=''+ CAST(CM.CUSTOMERID AS VARCHAR) + ''">'' + CM.membershipId +''</a>''
  2024. ,cm.userName
  2025. ,email=cm.email
  2026. ,fullName= REPLACE(ISNULL(cm.firstName, '''') + ISNULL('' '' + cm.middleName, '''') + ISNULL('' '' + cm.lastName1, ''''), '' '', '' '')
  2027. ,dob=CONVERT(VARCHAR,cm.dob,101)
  2028. ,address=cm.[address]
  2029. ,nativeCountry=com.countryName
  2030. ,idtype=sdv.detailTitle
  2031. ,idNumber=cm.idNumber
  2032. ,createdDate=CAST(cm.createdDate AS DATE)
  2033. ,createdBy=cm.createdBy
  2034. ,verifiedBy=cm.verifiedBy
  2035. ,branchName=''''
  2036. ,verifiedDate=CAST(cm.verifiedDate AS DATE)
  2037. ,ipAddress=cm.ipAddress
  2038. ,mobile=cm.mobile
  2039. ,bankAccountNo
  2040. ,cm.agentId
  2041. ,case when isnull(cm.isExistingCustomer,1) = 1 then ''Yes'' ELSE ''No'' End isExistingCustomer
  2042. ,createdUserFrom = ''core''
  2043. ,LawsonCardNo = cm.LawsonCardNo
  2044. ,[RegistrationType] = CASE WHEN cm.RegistrationType IS NULL THEN ''Manual'' ELSE cm.RegistrationType END
  2045. ,ISNULL(verificationCode,''NOT_COMPLETED'') verificationCode
  2046. FROM customerMaster cm(NOLOCK)
  2047. LEFT JOIN countryMaster com(NOLOCK) ON cm.nativeCountry=com.countryId
  2048. INNER JOIN staticDataValue sdv (NOLOCK) ON sdv.valueId=cm.idType AND sdv.typeID=1300
  2049. AND CM.ISACTIVE = ''Y''
  2050. AND USERNAME IS NOT NULL
  2051. AND cm.MOBILEVERIFIEDDATE IS NOT NULL
  2052. and cm.membershipId is not null
  2053. and cm.serviceUsedFor LIKE ''%M%''
  2054. --and ISNULL(cm.serviceUsedFor, ''C'') NOT LIKE ''%M%''
  2055. and ISNULL(cm.isEmailVerified, 0) = 0
  2056. and cm.approvedDate IS NOT NULL
  2057. and cm.mobileVerificationType = ''verified''
  2058. and ISNULL(cm.agreeYn,0)= 1'
  2059. IF ISNULL(@fromDate, '') <> ''
  2060. AND ISNULL(@toDate, '') <> ''
  2061. SET @table = @table + ' AND cm.createdDate BETWEEN ''' + CAST(@fromDate AS VARCHAR) + ''' AND ''' + CAST(@toDate AS VARCHAR) + ''''
  2062. SET @table = @table + ')x'
  2063. SET @sql_filter = ''
  2064. IF ISNULL(@searchCriteria, '') <> ''
  2065. AND ISNULL(@searchValue, '') <> ''
  2066. BEGIN
  2067. IF @searchCriteria = 'idNumber'
  2068. BEGIN
  2069. --IF ISNUMERIC(@searchValue)<>1
  2070. -- SET @searchValue='-1' --to ignore string value for datatype integer/customerID
  2071. --SET @sql_Filter=@sql_Filter + ' AND customerId = ''' +@searchValue+''''
  2072. SET @sql_Filter = @sql_Filter + ' AND REPLACE(idNumber, ''-'', '''') = ''' + REPLACE(@searchValue, '-', '') + ''''
  2073. END
  2074. ELSE IF @searchCriteria = 'emailId'
  2075. SET @sql_Filter = @sql_Filter + ' AND email like ''' + @searchValue + '%'''
  2076. ELSE IF @searchCriteria = 'customerName'
  2077. SET @sql_Filter = @sql_Filter + ' AND fullName like ''' + @searchValue + '%'''
  2078. ELSE IF @searchCriteria = 'mobile'
  2079. SET @sql_Filter = @sql_Filter + ' AND mobile = ''' + @searchValue + ''''
  2080. ELSE IF @searchCriteria = 'walletAccountNo'
  2081. SET @sql_Filter = @sql_Filter + ' AND walletAccountNo = ''' + @searchValue + ''''
  2082. ELSE IF @searchCriteria = 'bankAccountNo'
  2083. SET @sql_Filter = @sql_Filter + ' AND bankAccountNo = ''' + @searchValue + ''''
  2084. ELSE IF @searchCriteria = 'nativeCountry'
  2085. SET @sql_Filter = @sql_Filter + ' AND nativeCountry = ''' + @searchValue + ''''
  2086. ELSE IF @searchCriteria = 'LawsonCardNo'
  2087. SET @sql_Filter = @sql_Filter + ' AND LawsonCardNo = ''' + @searchValue + ''''
  2088. END
  2089. SET @select_field_list = '
  2090. customerId,userName,isExistingCustomer,membershipid,email,fullName,dob,address,nativeCountry,idtype,idNumber
  2091. ,createdDate,createdBy,verifiedBy,branchName,verifiedDate,bankAccountNo,createdUserFrom,LawsonCardNo,[RegistrationType],verificationCode
  2092. '
  2093. EXEC dbo.proc_paging @table
  2094. ,@sql_filter
  2095. ,@select_field_list
  2096. ,@extra_field_list
  2097. ,@sortBy
  2098. ,@sortOrder
  2099. ,@pageSize
  2100. ,@pageNumber
  2101. --,@action
  2102. RETURN
  2103. END
  2104. END TRY
  2105. BEGIN CATCH
  2106. IF @@TRANCOUNT > 0
  2107. ROLLBACK TRANSACTION
  2108. DECLARE @errorMessage VARCHAR(MAX)
  2109. SET @errorMessage = ERROR_MESSAGE()
  2110. EXEC proc_errorHandler 1
  2111. ,@errorMessage
  2112. ,NULL
  2113. END CATCH