-- ============================================= -- Author: -- Create date: -- Description: -- ============================================= -- EXEC [dbo].[procedure_test] @CUSTOMERID = '110959' CREATE PROCEDURE [dbo].[proc_SendNotifyCation] -- 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