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.
317 lines
8.1 KiB
317 lines
8.1 KiB
USE [FastMoneyPro_Remit]
|
|
GO
|
|
/****** Object: StoredProcedure [dbo].[proc_online_receiverSetup] Script Date: 7/4/2019 11:35:48 AM ******/
|
|
DROP PROCEDURE [dbo].[proc_online_receiverSetup]
|
|
GO
|
|
/****** Object: StoredProcedure [dbo].[proc_online_receiverSetup] Script Date: 7/4/2019 11:35:48 AM ******/
|
|
SET ANSI_NULLS ON
|
|
GO
|
|
SET QUOTED_IDENTIFIER ON
|
|
GO
|
|
CREATE PROCEDURE [dbo].[proc_online_receiverSetup](
|
|
@flag VARCHAR (50) =NULL
|
|
,@user VARCHAR (30) =NULL
|
|
,@receiverId VARCHAR (50) =NULL
|
|
,@customerId VARCHAR (50) =NULL
|
|
,@membershipId VARCHAR(50) =NULL
|
|
,@firstName VARCHAR(100) =NULL
|
|
,@middleName VARCHAR(100) =NULL
|
|
,@lastName1 VARCHAR(100) =NULL
|
|
,@lastName2 VARCHAR(100) =NULL
|
|
,@country VARCHAR(200) =NULL
|
|
,@address VARCHAR(500) =NULL
|
|
,@state VARCHAR(200) =NULL
|
|
,@zipCode VARCHAR(50) =NULL
|
|
,@city VARCHAR(100) =NULL
|
|
,@email VARCHAR(150) =NULL
|
|
,@homePhone VARCHAR(100) =NULL
|
|
,@workPhone VARCHAR(100) =NULL
|
|
,@mobile VARCHAR(100) =NULL
|
|
,@relationship VARCHAR(100) =NULL
|
|
,@sortBy VARCHAR(50) = NULL
|
|
,@sortOrder VARCHAR(5) = NULL
|
|
,@pageSize INT = NULL
|
|
,@pageNumber INT = NULL
|
|
)
|
|
AS
|
|
BEGIN
|
|
DECLARE
|
|
@table VARCHAR(MAX)
|
|
,@select_field_list VARCHAR(MAX)
|
|
,@extra_field_list VARCHAR(MAX)
|
|
,@sql_filter VARCHAR(MAX)
|
|
--,@customerId1 VARCHAR(50)
|
|
|
|
IF @flag='i'
|
|
BEGIN
|
|
|
|
IF EXISTS(SELECT 'X' FROM receiverInformation WITH(NOLOCK) WHERE mobile=@mobile and customerId=@customerId)
|
|
BEGIN
|
|
SELECT '1' errorCode,'The receiver with this Mobile Number already exists.' msg,null id
|
|
RETURN
|
|
END
|
|
insert into receiverInformation
|
|
(
|
|
membershipId
|
|
,customerId
|
|
,firstName
|
|
,middleName
|
|
,lastName1
|
|
,lastName2
|
|
,country
|
|
,address
|
|
,state
|
|
,zipCode
|
|
,city
|
|
,email
|
|
,homePhone
|
|
,workPhone
|
|
,mobile
|
|
,relationship
|
|
,isActive
|
|
)select
|
|
@membershipId
|
|
,@customerId
|
|
,@firstName
|
|
,@middleName
|
|
,@lastName1
|
|
,@lastName2
|
|
,@country
|
|
,@address
|
|
,@state
|
|
,@zipCode
|
|
,@city
|
|
,@email
|
|
,@homePhone
|
|
,@workPhone
|
|
,@mobile
|
|
,@relationship
|
|
,1
|
|
|
|
Select '0' errorCode,'Receiver Successfully added.' msg,id=@receiverId
|
|
return
|
|
END
|
|
|
|
IF @flag='u'
|
|
BEGIN
|
|
|
|
--IF EXISTS(SELECT 'X' FROM receiverInformation WITH(NOLOCK) WHERE mobile=@mobile and receiverId =@receiverId)
|
|
--BEGIN
|
|
-- SELECT '1' errorCode,'The receiver with this Mobile Number already exists.' msg,null id
|
|
-- RETURN
|
|
--END
|
|
|
|
UPDATE receiverInformation SET
|
|
firstName =@firstName
|
|
,middleName =@middleName
|
|
,lastName1 =@lastName1
|
|
,lastName2 =@lastName2
|
|
,country =@country
|
|
,address =@address
|
|
,state =@state
|
|
,zipCode =@zipCode
|
|
,city =@city
|
|
,email =@email
|
|
,homePhone =@homePhone
|
|
,workPhone =@workPhone
|
|
,mobile =@mobile
|
|
,relationship =@relationship
|
|
|
|
WHERE receiverId =@receiverId
|
|
select '0' errorCode,'Receiver Information has been updated' msg,id=null
|
|
END
|
|
|
|
IF @flag='d'
|
|
BEGIN
|
|
UPDATE receiverInformation SET isActive='0' WHERE receiverId=@receiverId
|
|
|
|
select '0' errorCode,'Receiver Deleted Successfully.' msg,id=@receiverId
|
|
|
|
END
|
|
|
|
IF @flag='s'
|
|
BEGIN
|
|
IF @sortBy IS NULL
|
|
SET @sortBy = 'firstName'
|
|
IF @sortOrder IS NULL
|
|
SET @sortOrder = 'ASC'
|
|
SET @table='
|
|
(
|
|
SELECT
|
|
ri.receiverId
|
|
,ri.firstName , ISNULL('' '' + ri.middleName,'''') middleName, ISNULL('' '' + ri.lastName1,'''') lastName1, ISNULL('' '' + ri.lastName2,'''') lastName2
|
|
,ri.firstName + ISNULL('' '' + ri.middleName,'''') + ISNULL('' '' + ri.lastName1,'''') + ISNULL('' '' + ri.lastName2,'''') FullName
|
|
,ri.customerId
|
|
,country
|
|
,ri.address
|
|
,ri.state
|
|
,ri.zipCode
|
|
,ri.city
|
|
,ri.email
|
|
,ri.homePhone
|
|
,ri.workPhone
|
|
,(Select coalesce(ri.mobile,ri.homePhone)) as Mobile
|
|
,relationship
|
|
|
|
FROM receiverInformation ri WITH (NOLOCK)
|
|
WHERE ISNULL(rec.isActive,1) = 1 AND customerId = ''' + @customerId + ''''
|
|
|
|
SET @sql_filter = ''
|
|
|
|
IF @country IS NOT NULL
|
|
SET @table = @table + ' and country='''+@country+''''
|
|
|
|
IF @address IS NOT NULL
|
|
SET @table = @table + ' AND address like '''+@address+'%'' or city like '''+@city+ '%'''-- or id Like '''+@agentAddress+ '%'''
|
|
|
|
SET @table = @table + ' )x'
|
|
|
|
PRINT @table
|
|
|
|
SET @select_field_list ='
|
|
receiverId
|
|
,customerId
|
|
,FullName=firstName + middleName + lastName1 + lastName2
|
|
,firstName
|
|
,middleName
|
|
,lastName1
|
|
,lastName2
|
|
,country
|
|
,address
|
|
,state
|
|
,zipCode
|
|
,city
|
|
,email
|
|
,homePhone
|
|
,workPhone
|
|
,Mobile
|
|
,relationship
|
|
'
|
|
EXEC dbo.proc_paging
|
|
@table
|
|
,@sql_filter
|
|
,@select_field_list
|
|
,@extra_field_list
|
|
,@sortBy
|
|
,@sortOrder
|
|
,@pageSize
|
|
,@pageNumber
|
|
|
|
END
|
|
|
|
IF @flag='a'
|
|
BEGIN
|
|
SELECT [receiverId]
|
|
,[customerId]
|
|
,[membershipId]
|
|
,[firstName]
|
|
,[middleName]
|
|
,[lastName1]
|
|
,[lastName2]
|
|
,[country]
|
|
,[address]
|
|
,[state]
|
|
,[zipCode]
|
|
,[city]
|
|
,[email]
|
|
,[homePhone]
|
|
,[workPhone]
|
|
,[mobile]
|
|
,[relationship]
|
|
from receiverInformation WITH (NOLOCK)
|
|
where receiverId=@receiverId AND isnull(isActive,1) = 1
|
|
END
|
|
|
|
|
|
IF @flag='sDetail'
|
|
BEGIN
|
|
|
|
|
|
--select * from receiverInformation
|
|
|
|
SELECT
|
|
ri.receiverId
|
|
,ri.customerId
|
|
,ri.firstName
|
|
,ri.middleName
|
|
,ri.lastName1
|
|
,ri.lastName2
|
|
,ri.country
|
|
,ri.address
|
|
,ri.state
|
|
,ri.zipCode
|
|
,cm.countryId
|
|
,ri.city
|
|
,ri.email
|
|
,ri.homePhone
|
|
,ri.workPhone
|
|
,ri.mobile
|
|
,ri.relationship
|
|
FROM receiverInformation ri WITH (NOLOCK)
|
|
inner join countryMaster cm WITH (NOLOCK) on ri.country=cm.countryName
|
|
WHERE customerId =@customerId and receiverId=@receiverId
|
|
AND isnull(ri.isActive,1) = 1
|
|
|
|
END
|
|
|
|
|
|
|
|
IF @flag='getTtranDetail'
|
|
BEGIN
|
|
|
|
--select * from receiverInformation
|
|
|
|
SELECT
|
|
ri.receiverId
|
|
,ri.customerId
|
|
,receiverName=ISNULL(ri.firstName,'') + ' '
|
|
+ ISNULL(ri.middleName,'')+ ' ' + ISNULL(ri.lastName1,'') + ' ' + ISNULL(ri.lastName2,'')
|
|
--,ri.middleName
|
|
--,ri.lastName1
|
|
--,ri.lastName2
|
|
,countryId=ri.country
|
|
,ri.address
|
|
,ri.state
|
|
,ri.zipCode
|
|
,ri.city
|
|
,ri.email
|
|
,phone=ri.homePhone
|
|
,ri.workPhone
|
|
,ri.mobile
|
|
,ri.relationship
|
|
FROM receiverInformation ri WITH (NOLOCK)
|
|
INNER JOIN countryMaster cm WITH(NOLOCK) ON ri.country= cm.countryName
|
|
WHERE customerId = @customerId and receiverId=@receiverId
|
|
AND isnull(ri.isActive,1) = 1
|
|
|
|
END
|
|
|
|
IF @flag='recProfile'
|
|
BEGIN
|
|
|
|
select distinct ISNULL(TS.tranid,'') from receiverInformation ri with(nolock)
|
|
LEFT JOIN
|
|
(SELECT tranid=rt.id,TS.customerId FROM tranSenders tS
|
|
INNER JOIN remitTran rt with(nolock) ON tS.tranId = rt.id AND tS.customerId =@customerId ) TS ON ri.customerId=tS.customerId
|
|
INNER JOIN tranReceivers tR with(nolock) ON tR.fullName=ISNULL(ri.firstName,'') + ''
|
|
+ ISNULL(ri.middleName,'')+ '' + ISNULL(ri.lastName1,'') + '' + ISNULL(ri.lastName2,'') AND tR.mobile=ri.mobile
|
|
WHERE ri.receiverId = @receiverId AND ri.customerId =@customerId
|
|
|
|
|
|
--SELECT tranId=tR.tranId,* FROM receiverInformation ri
|
|
-- LEFT JOIN tranReceivers tR ON ri.customerId=tR.customerId
|
|
-- AND tR.fullName=ISNULL(ri.firstName,'') + '' + ISNULL(ri.middleName,'')+ ''
|
|
-- + ISNULL(ri.lastName1,'') + '' + ISNULL(ri.lastName2,'') AND tR.mobile=ri.mobile
|
|
-- WHERE ri.receiverId = @receiverId AND ri.customerId =@customerId
|
|
END
|
|
END
|
|
|
|
|
|
--INNER JOIN (
|
|
-- SELECT
|
|
-- receiverId = MAX(receiverId)
|
|
-- ,fullName= ri.firstName + ISNULL('' '' + ri.middleName,'''') + ISNULL('' '' + ri.lastName1,'''') + ISNULL('' '' + ri.lastName2,'''')
|
|
-- FROM receiverInformation ri WITH (NOLOCK)
|
|
-- GROUP BY ri.firstName + ISNULL('' '' + ri.middleName,'''') + ISNULL('' '' + ri.lastName1,'''') + ISNULL('' '' + ri.lastName2,'''')
|
|
--) x ON ri.receiverId = x.receiverId
|
|
GO
|