PHP Code:
USE [SRO_VT_SHARD]
GO
/****** Object: StoredProcedure [dbo].[_Any_2_Shop] Script Date: 1/14/2014 4:49:16 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[_Any_2_Shop]
@ITEM varchar (64) [MENTION=373843]shop[/MENTION]_TAB varchar (64),@ITEM_PLUS INT,
@Payment_method_1 INT,@Payment_method_2 INT,@Payment_method_3 INT,@Payment_method_4 INT,@Payment_method_5 INT,@Payment_method_6 INT,
@Payment_method_7 INT,@Payment_method_8 INT,
[MENTION=828510]price[/MENTION]_1 INT [MENTION=828510]price[/MENTION]_2 INT [MENTION=828510]price[/MENTION]_3 INT [MENTION=828510]price[/MENTION]_4 INT [MENTION=828510]price[/MENTION]_5 INT [MENTION=828510]price[/MENTION]_6 INT [MENTION=828510]price[/MENTION]_7 INT [MENTION=828510]price[/MENTION]_8 INT
AS
--//ITEM CHECK//---
IF NOT EXISTS (SELECT CodeName128 FROM _RefObjCommon WHERE CodeName128 = @ITEM)
BEGIN
raiserror('This item %s is not exist!',11,1,@ITEM);
RETURN;
END
--//TAB CHECK//---
IF NOT EXISTS (SELECT CodeName128 FROM _RefShopTab WHERE CodeName128 = [MENTION=373843]shop[/MENTION]_TAB)
BEGIN
raiserror('This TAB %s is not exist!',11,1 [MENTION=373843]shop[/MENTION]_TAB);
RETURN;
END
--//PACKAGE ITEM NAME CHECK//---
IF EXISTS (SELECT CodeName128 FROM _RefPackageItem WHERE CodeName128 = 'PACKAGE_'+@ITEM)
BEGIN
raiserror('This packageitem name %s is already exist!.Try to rename it',11,1,@ITEM);
RETURN;
END
Declare [MENTION=751524]pack[/MENTION]ID int SET [MENTION=751524]pack[/MENTION]ID = (SELECT MAX (ID) FROM _RefPackageItem)+1
Declare [MENTION=1333447910]Icon[/MENTION] Varchar (MAX) SET [MENTION=1333447910]Icon[/MENTION] = (select AssocFileIcon128 from _RefObjCommon where CodeName128 = @ITEM)
Declare @SN varchar(MAX) SET @SN = (SELECT NameStrID128 FROM _RefObjCommon WHERE CodeName128 = @ITEM)
Declare [MENTION=275999]des[/MENTION]C_ITEM varchar(MAX) SET [MENTION=275999]des[/MENTION]C_ITEM = (SELECT DescStrID128 FROM _RefObjCommon WHERE CodeName128 = @ITEM)
--//Add Packageitem//---
SET IDENTITY_INSERT _RefPackageItem ON
INSERT INTO _RefPackageItem (Service,Country,ID,CodeName128,SaleTag,ExpandTerm,NameStrID,DescStrID,AssocFileIcon,Param1,Param1_Desc128,Param2,Param2_Desc128,Param3,Param3_Desc128,Param4,Param4_Desc128) VALUES
(1,15 [MENTION=751524]pack[/MENTION]ID,'PACKAGE_'+@ITEM,0,'EXPAND_TERM_ALL',@SN [MENTION=275999]des[/MENTION]C_ITEM [MENTION=1333447910]Icon[/MENTION],-1,'xxx',-1,'xxx',-1,'xxx',-1,'xxx')
SET IDENTITY_INSERT _RefPackageItem OFF
print ''
print 'Add the following line @ refpackageitem.txt'
print '1 15 '+CONVERT(varchar(max) [MENTION=751524]pack[/MENTION]ID)+' PACKAGE_'+@ITEM+' 0 EXPAND_TERM_ALL '+@SN+' ' [MENTION=275999]des[/MENTION]C_ITEM+' ' [MENTION=1333447910]Icon[/MENTION]+' -1 xxx -1 xxx -1 xxx -1 xxx'
print ''
DECLARE [MENTION=1333459381]Index[/MENTION] INT = (SELECT MAX ([INDEX]) FROM _RefScrapOfPackageItem)+1
DECLARE [MENTION=1333359883]data[/MENTION] INT
IF @ITEM LIKE '%RING%' OR @ITEM LIKE '%EARRING%' OR @ITEM LIKE '%NECKLACE%' OR @ITEM LIKE '%ARCHEMY_MAGICSTONE%' OR @ITEM LIKE '%ARCHEMY_ATTRSTONE%' BEGIN
SET [MENTION=1333359883]data[/MENTION] = 1
END
ELSE BEGIN
SET [MENTION=1333359883]data[/MENTION] = (SELECT Dur_L from _RefObjItem where ID = (select Link from _RefObjCommon where CodeName128 = @ITEM))
END
--//Add Scrap//---
SET IDENTITY_INSERT _RefScrapOfPackageItem ON
INSERT INTO _RefScrapOfPackageItem (Service,Country,RefPackageItemCodeName,RefItemCodeName,OptLevel,Variance,Data,MagParamNum,MagParam1,MagParam2,MagParam3,MagParam4,MagParam5,MagParam6,MagParam7,MagParam8,MagParam9,MagParam10,MagParam11,MagParam12,Param1,Param1_Desc128,Param2,Param2_Desc128,Param3,Param3_Desc128,Param4,Param4_Desc128,[Index]) VALUES
(1,15,'PACKAGE_'+@ITEM,@ITEM,@ITEM_PLUS,0 [MENTION=1333359883]data[/MENTION],0,0,0,0,0,0,0,0,0,0,0,0,0,-1,'xxx',-1,'xxx',-1,'xxx',-1,'xxx' [MENTION=1333459381]Index[/MENTION])
SET IDENTITY_INSERT _RefScrapOfPackageItem OFF
print ''
print 'Add the following line @ refscrapofpackageitem.txt'
print '1 15 '+'PACKAGE_'+@ITEM+' '+@ITEM+' '+CONVERT(varchar(max),@ITEM_PLUS)+' 0 '+CONVERT(varchar(max) [MENTION=1333359883]data[/MENTION])+' 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 xxx -1 xxx -1 xxx -1 xxx '+CONVERT(varchar(max) [MENTION=1333459381]Index[/MENTION])
print ''
IF EXISTS (SELECT RefTabCodeName from _RefShopGoods where RefTabCodeName = [MENTION=373843]shop[/MENTION]_TAB) BEGIN
DECLARE [MENTION=558012]slot[/MENTION] INT = (SELECT MAX (SlotIndex) FROM _RefShopGoods where RefTabCodeName = [MENTION=373843]shop[/MENTION]_TAB)+1
END
ELSE BEGIN
SET [MENTION=558012]slot[/MENTION] = 0
END
--//Add SHOP//---
INSERT INTO _RefShopGoods (Service,Country,RefTabCodeName,RefPackageItemCodeName,SlotIndex,Param1,Param1_Desc128,Param2,Param2_Desc128,Param3,Param3_Desc128,Param4,Param4_Desc128) VALUES
(1,15 [MENTION=373843]shop[/MENTION]_TAB,'PACKAGE_'+@ITEM [MENTION=558012]slot[/MENTION],-1,'xxx',-1,'xxx',-1,'xxx',-1,'xxx')
print ''
print 'Add the following line @ RefShopGoods.txt'
print '1 15 ' [MENTION=373843]shop[/MENTION]_TAB+' '+'PACKAGE_'+@ITEM+' '+CONVERT(varchar(max) [MENTION=558012]slot[/MENTION])+' -1 xxx -1 xxx -1 xxx -1 xxx'
print ''
--//Add Prices//---
IF @Payment_method_1 = 1 BEGIN
INSERT INTO _RefPricePolicyOfItem(Service,Country,RefPackageItemCodeName,PaymentDevice,PreviousCost,Cost,Param1,Param1_Desc128,Param2,Param2_Desc128,Param3,Param3_Desc128,Param4,Param4_Desc128) VALUES
(1,15,'PACKAGE_'+@ITEM,1,0 [MENTION=828510]price[/MENTION]_1,-1,'xxx',-1,'xxx',-1,'xxx',-1,'xxx')
print ''
print 'Add the following line @ RefPricePolicyOfItem.txt'
print '1 15 PACKAGE_'+@ITEM+' 1 0 '+CONVERT(varchar(max) [MENTION=828510]price[/MENTION]_1)+' -1 xxx -1 xxx -1 xxx -1 xxx'
print ''
END
IF @Payment_method_2 = 2 BEGIN
INSERT INTO _RefPricePolicyOfItem(Service,Country,RefPackageItemCodeName,PaymentDevice,PreviousCost,Cost,Param1,Param1_Desc128,Param2,Param2_Desc128,Param3,Param3_Desc128,Param4,Param4_Desc128) VALUES
(1,15,'PACKAGE_'+@ITEM,2,0 [MENTION=828510]price[/MENTION]_2,-1,'xxx',-1,'xxx',-1,'xxx',-1,'xxx')
INSERT INTO _RefPricePolicyOfItem(Service,Country,RefPackageItemCodeName,PaymentDevice,PreviousCost,Cost,Param1,Param1_Desc128,Param2,Param2_Desc128,Param3,Param3_Desc128,Param4,Param4_Desc128) VALUES
(1,15,'PACKAGE_'+@ITEM,4,0,0,-1,'xxx',-1,'xxx',-1,'xxx',-1,'xxx')
INSERT INTO _RefPricePolicyOfItem(Service,Country,RefPackageItemCodeName,PaymentDevice,PreviousCost,Cost,Param1,Param1_Desc128,Param2,Param2_Desc128,Param3,Param3_Desc128,Param4,Param4_Desc128) VALUES
(1,15,'PACKAGE_'+@ITEM,16,0,0,-1,'xxx',-1,'xxx',-1,'xxx',-1,'xxx')
print ''
print 'Add the following line @ RefPricePolicyOfItem.txt'
print '1 15 PACKAGE_'+@ITEM+' 2 0 '+CONVERT(varchar(max) [MENTION=828510]price[/MENTION]_2)+' -1 xxx -1 xxx -1 xxx -1 xxx'
print '1 15 PACKAGE_'+@ITEM+' 4 0 0 -1 xxx -1 xxx -1 xxx -1 xxx'
print '1 15 PACKAGE_'+@ITEM+' 16 0 0 -1 xxx -1 xxx -1 xxx -1 xxx'
print ''
END
IF @Payment_method_3 = 32 BEGIN
INSERT INTO _RefPricePolicyOfItem(Service,Country,RefPackageItemCodeName,PaymentDevice,PreviousCost,Cost,Param1,Param1_Desc128,Param2,Param2_Desc128,Param3,Param3_Desc128,Param4,Param4_Desc128) VALUES
(1,15,'PACKAGE_'+@ITEM,32,0 [MENTION=828510]price[/MENTION]_3,-1,'xxx',-1,'xxx',-1,'xxx',-1,'xxx')
print ''
print 'Add the following line @ RefPricePolicyOfItem.txt'
print '1 15 PACKAGE_'+@ITEM+' 32 0 '+CONVERT(varchar(max) [MENTION=828510]price[/MENTION]_3)+' -1 xxx -1 xxx -1 xxx -1 xxx'
print ''
END
IF @Payment_method_4 = 64 BEGIN
INSERT INTO _RefPricePolicyOfItem(Service,Country,RefPackageItemCodeName,PaymentDevice,PreviousCost,Cost,Param1,Param1_Desc128,Param2,Param2_Desc128,Param3,Param3_Desc128,Param4,Param4_Desc128) VALUES
(1,15,'PACKAGE_'+@ITEM,64,0 [MENTION=828510]price[/MENTION]_4,-1,'xxx',-1,'xxx',-1,'xxx',-1,'xxx')
print ''
print 'Add the following line @ RefPricePolicyOfItem.txt'
print '1 15 PACKAGE_'+@ITEM+' 64 0 '+CONVERT(varchar(max) [MENTION=828510]price[/MENTION]_4)+' -1 xxx -1 xxx -1 xxx -1 xxx'
print ''
END
IF @Payment_method_5 = 128 BEGIN
INSERT INTO _RefPricePolicyOfItem(Service,Country,RefPackageItemCodeName,PaymentDevice,PreviousCost,Cost,Param1,Param1_Desc128,Param2,Param2_Desc128,Param3,Param3_Desc128,Param4,Param4_Desc128) VALUES
(1,15,'PACKAGE_'+@ITEM,128,0 [MENTION=828510]price[/MENTION]_5,-1,'xxx',-1,'xxx',-1,'xxx',-1,'xxx')
print ''
print 'Add the following line @ RefPricePolicyOfItem.txt'
print '1 15 PACKAGE_'+@ITEM+' 128 0 '+CONVERT(varchar(max) [MENTION=828510]price[/MENTION]_5)+' -1 xxx -1 xxx -1 xxx -1 xxx'
print ''
END
IF @Payment_method_6 = 256 BEGIN
INSERT INTO _RefPricePolicyOfItem(Service,Country,RefPackageItemCodeName,PaymentDevice,PreviousCost,Cost,Param1,Param1_Desc128,Param2,Param2_Desc128,Param3,Param3_Desc128,Param4,Param4_Desc128) VALUES
(1,15,'PACKAGE_'+@ITEM,256,0 [MENTION=828510]price[/MENTION]_6,-1,'xxx',-1,'xxx',-1,'xxx',-1,'xxx')
print ''
print 'Add the following line @ RefPricePolicyOfItem.txt'
print '1 15 PACKAGE_'+@ITEM+' 256 0 '+CONVERT(varchar(max) [MENTION=828510]price[/MENTION]_6)+' -1 xxx -1 xxx -1 xxx -1 xxx'
print ''
END
IF @Payment_method_7 = 512 BEGIN
INSERT INTO _RefPricePolicyOfItem(Service,Country,RefPackageItemCodeName,PaymentDevice,PreviousCost,Cost,Param1,Param1_Desc128,Param2,Param2_Desc128,Param3,Param3_Desc128,Param4,Param4_Desc128) VALUES
(1,15,'PACKAGE_'+@ITEM,512,0 [MENTION=828510]price[/MENTION]_7,-1,'xxx',-1,'xxx',-1,'xxx',-1,'xxx')
print ''
print 'Add the following line @ RefPricePolicyOfItem.txt'
print '1 15 PACKAGE_'+@ITEM+' 512 0 '+CONVERT(varchar(max) [MENTION=828510]price[/MENTION]_7)+' -1 xxx -1 xxx -1 xxx -1 xxx'
print ''
END
IF @Payment_method_8 = 1024 BEGIN
INSERT INTO _RefPricePolicyOfItem(Service,Country,RefPackageItemCodeName,PaymentDevice,PreviousCost,Cost,Param1,Param1_Desc128,Param2,Param2_Desc128,Param3,Param3_Desc128,Param4,Param4_Desc128) VALUES
(1,15,'PACKAGE_'+@ITEM,1024,0 [MENTION=828510]price[/MENTION]_8,-1,'xxx',-1,'xxx',-1,'xxx',-1,'xxx')
print ''
print 'Add the following line @ RefPricePolicyOfItem.txt'
print '1 15 PACKAGE_'+@ITEM+' 1024 0 '+CONVERT(varchar(max) [MENTION=828510]price[/MENTION]_8)+' -1 xxx -1 xxx -1 xxx -1 xxx'
print ''
END
IF @Payment_method_1 = 0 OR @Payment_method_2 = 0 OR @Payment_method_3 = 0 OR @Payment_method_4 = 0 OR @Payment_method_5 = 0 OR @Payment_method_6 = 0 OR @Payment_method_7 = 0 OR @Payment_method_8 = 0 BEGIN
RETURN
END
--//Written by Arabianfox//---
replace