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.

2165 lines
134 KiB

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