|
|
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
-- EXEC [dbo].[procedure_test] @CUSTOMERID = '110959'
CREATE PROCEDURE [dbo].[proc_SendPushNotification] -- Add the parameters for the stored procedure here
@Flag VARCHAR(50) = null, @country VARCHAR(100) = null, @gender VARCHAR(10) = null, @registerToDate VARCHAR(30) = null, @registerFromDate VARCHAR(30) = null, @remitToDate VARCHAR(30) = null, @remitFromDate VARCHAR(30) = null, @toAmount MONEY =null, @fromAmount MONEY = null, @body NVARCHAR(MAX) = null, @title NVARCHAR(MAX) = null, @walletNo VARCHAR(100) = null, @customerId BIGINT =null , @imageURL VARCHAR(MAX) = null AS SET NOCOUNT ON; IF @flag = 'RemittSendNotify' -- �۱��� �����鿡 ���� Notify ����
BEGIN CREATE TABLE #TempTable
( deviceId NVARCHAR(MAX), customerId BIGINT, tranAmount MONEY )
INSERT INTO #TempTable
SELECT mu.deviceId AS deviceId, cm.customerId as customerId, SUM(rm.tAmt) AS tranAmount FROM customerMaster cm INNER JOIN remitTran rm ON rm.senderName = cm.firstName INNER JOIN mobile_userRegistration mu ON mu.customerId = cm.customerId AND mu.username = cm.email WHERE cm.createdDate BETWEEN @registerFromDate AND @registerToDate + ' 23:59:59' AND rm.createdDate BETWEEN @remitFromDate AND @remitToDate + ' 23:59:59' AND rm.payStatus = 'Paid' AND cm.nativeCountry = ISNULL(@country, cm.nativeCountry) AND cm.gender = ISNULL(ISNULL(@gender,cm.gender), '') GROUP BY cm.customerId, mu.deviceId
SELECT deviceId, customerId FROM #TempTable
WHERE tranAmount BETWEEN @fromAmount AND @toAmount + 1
RETURN END IF @flag ='RemittHistory' -- �۱��� ������ ���� Notify ���� ����
BEGIN
CREATE TABLE #TempSearch
( customerId BIGINT, tranAmount MONEY )
INSERT INTO #TempSearch
SELECT mu.customerId AS customerId , SUM(rm.tAmt) AS tranAmount FROM customerMaster cm INNER JOIN remitTran rm ON rm.senderName = cm.firstName INNER JOIN mobile_userRegistration mu ON mu.customerId = cm.customerId AND mu.username = cm.email WHERE cm.createdDate BETWEEN @registerFromDate AND @registerToDate + ' 23:59:59' AND rm.createdDate BETWEEN @remitFromDate AND @remitToDate + ' 23:59:59' AND rm.payStatus = 'Paid' AND cm.nativeCountry = ISNULL(@country,cm.nativeCountry) AND cm.gender = ISNULL(ISNULL(@gender,cm.gender), '') GROUP BY mu.customerId, mu.deviceId
INSERT INTO pushNotificationHistroy (customerId, body, title, imageURL) SELECT customerId , body = @body , title = @title, imageURL = ISNULL(@imageURL,'') FROM #TempSearch
WHERE tranAmount BETWEEN @fromAmount AND @toAmount + 1
SELECT ph.customerId, body , title, imageURL FROM pushNotificationHistroy ph INNER JOIN #TempSearch ts
ON ph.customerId = ts.customerId WHERE body = @body AND title = @title AND imageURL = ISNULL(@imageURL,'') END IF @Flag ='notifyByWalletNo'-- Wallet No �� ���� �ش� �������� Notify ������ ����
BEGIN SELECT mu.customerId AS customerId, mu.deviceId FROM customerMaster cm INNER JOIN mobile_userRegistration mu ON mu.customerId = cm.customerId AND mu.username = cm.email WHERE walletAccountNo = @walletNo RETURN END IF @Flag = 'SendNotify' -- ������ �������� Notify ������ ����
BEGIN
SELECT mu.deviceId AS deviceId, cm.customerId AS customerId FROM customerMaster cm INNER JOIN mobile_userRegistration mu ON mu.customerId = cm.customerId and mu.username = cm.email WHERE cm.createdDate BETWEEN @registerFromDate AND @registerToDate + ' 23:59:59' AND cm.nativeCountry = ISNULL(@country, cm.nativeCountry) GROUP BY cm.customerId, mu.deviceId RETURN END IF @Flag = 'SendNotifyHistory' -- ������ �������� Notify ���� ����
BEGIN INSERT INTO pushNotificationHistroy(customerId,title,body,imageURL) SELECT cm.customerId, title=@title, body=@body, imageURL=ISNULL(@imageURL,'') FROM customerMaster cm INNER JOIN mobile_userRegistration mu ON mu.customerId = cm.customerId AND mu.username = cm.email WHERE cm.createdDate BETWEEN @registerFromDate AND @registerToDate + ' 23:59:59' AND cm.nativeCountry = ISNULL(@country,cm.nativeCountry)
SELECT cm.customerId, title=@title, body=@body, imageURL=ISNULL(@imageURL,'') FROM customerMaster cm INNER JOIN mobile_userRegistration mu ON mu.customerId = cm.customerId AND mu.username = cm.email WHERE cm.createdDate BETWEEN @registerFromDate AND @registerToDate + ' 23:59:59' AND cm.nativeCountry = ISNULL(@country,cm.nativeCountry) RETURN END IF @Flag = 'SendNotifyHistoryByWalletno' -- Wallet No ���� Notify ���� ����
BEGIN INSERT INTO pushNotificationHistroy(customerId,title,body,imageURL) VALUES (@customerId,@title,@body,ISNULL(@imageURL,'')) END
|