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.

2238 lines
138 KiB

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