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.

2359 lines
145 KiB

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