
--商品分类标准系统预设
IF NOT EXISTS ( SELECT 1 FROM T_BD_CLASSSTANDARD WHERE  FID = 1 )
INSERT INTO T_BD_CLASSSTANDARD (FID, FMASTERID, FNUMBER, FADMINORGID, FCREATEORGID, FORGID, FCTRLSTRATEGY, FENABLE, FISPRESET, FCREATORID, FCREATETIME, FMODIFIERID, FMODIFYTIME, FDISABLERID, FDISABLEDATE, FSTATUS)
VALUES (1, 1, '1', 0, 100000, 100000, '5', '1', '1', 1, {ts'2019-11-21'}, 1, {ts'2019-11-21'}, 0, null, 'C');

IF NOT EXISTS ( SELECT 1 FROM T_BD_CLASSSTANDARD_L WHERE  FID = 1 AND FLOCALEID='zh_CN' )
INSERT INTO T_BD_CLASSSTANDARD_L (FPKID, FID, FLOCALEID, FNAME,FDESCRIPTION) VALUES ('0CVWRL4HW4=O', 1, 'zh_CN', '商品基本分类标准','商品基本分类标准');

--商品类型系统预设
DELETE FROM T_BD_ITEMTYPE WHERE FID = 870945989739982848;
INSERT INTO T_BD_ITEMTYPE(FID,FCREATETIME,FENABLE,FMODIFIERID,FISPRESET,FMODIFYTIME,FDISABLEDATE,FMASTERID,FSTATUS,FCREATORID,FNUMBER,FDISABLERID) VALUES (870945989739982848,{ts'2020-04-16  16:14:09'},'1',13466739,'1',{ts'2020-04-16  16:14:17'},null,870945989739982848,'C',13466739,'3',0); 
DELETE FROM T_BD_ITEMTYPE WHERE FID = 870946146481079296;
INSERT INTO T_BD_ITEMTYPE(FID,FCREATETIME,FENABLE,FMODIFIERID,FISPRESET,FMODIFYTIME,FDISABLEDATE,FMASTERID,FSTATUS,FCREATORID,FNUMBER,FDISABLERID) VALUES (870946146481079296,{ts'2020-04-16  16:14:27'},'1',13466739,'1',{ts'2020-04-16  16:14:36'},null,870946146481079296,'C',13466739,'4',0); 
DELETE FROM T_BD_ITEMTYPE WHERE FID = 870946271932711936;
INSERT INTO T_BD_ITEMTYPE(FID,FCREATETIME,FENABLE,FMODIFIERID,FISPRESET,FMODIFYTIME,FDISABLEDATE,FMASTERID,FSTATUS,FCREATORID,FNUMBER,FDISABLERID) VALUES (870946271932711936,{ts'2020-04-16  16:14:38'},'1',13466739,'1',{ts'2020-04-16  16:14:46'},null,870946271932711936,'C',13466739,'5',0); 
DELETE FROM T_BD_ITEMTYPE WHERE FID = 870946349007286272;
INSERT INTO T_BD_ITEMTYPE(FID,FCREATETIME,FENABLE,FMODIFIERID,FISPRESET,FMODIFYTIME,FDISABLEDATE,FMASTERID,FSTATUS,FCREATORID,FNUMBER,FDISABLERID) VALUES (870946349007286272,{ts'2020-04-16  16:14:47'},'1',13466739,'1',{ts'2020-04-16  16:14:55'},null,870946349007286272,'C',13466739,'6',0); 
DELETE FROM T_BD_ITEMTYPE WHERE FID = 870946434386494464;
INSERT INTO T_BD_ITEMTYPE(FID,FCREATETIME,FENABLE,FMODIFIERID,FISPRESET,FMODIFYTIME,FDISABLEDATE,FMASTERID,FSTATUS,FCREATORID,FNUMBER,FDISABLERID) VALUES (870946434386494464,{ts'2020-04-16  16:15:00'},'1',13466739,'1',{ts'2020-04-16  16:15:05'},null,870946434386494464,'C',13466739,'7',0); 
DELETE FROM T_BD_ITEMTYPE WHERE FID = 870945645681225728;
INSERT INTO T_BD_ITEMTYPE(FID,FCREATETIME,FENABLE,FMODIFIERID,FISPRESET,FMODIFYTIME,FDISABLEDATE,FMASTERID,FSTATUS,FCREATORID,FNUMBER,FDISABLERID) VALUES (870945645681225728,{ts'2020-04-16  16:13:10'},'1',13466739,'1',{ts'2020-04-16  16:13:31'},null,870945645681225728,'C',13466739,'1',0); 
DELETE FROM T_BD_ITEMTYPE WHERE FID = 870945697287898112;
INSERT INTO T_BD_ITEMTYPE(FID,FCREATETIME,FENABLE,FMODIFIERID,FISPRESET,FMODIFYTIME,FDISABLEDATE,FMASTERID,FSTATUS,FCREATORID,FNUMBER,FDISABLERID) VALUES (870945697287898112,{ts'2020-04-16  16:13:33'},'1',13466739,'1',{ts'2020-04-16  16:13:37'},null,870945697287898112,'C',13466739,'2',0); 

DELETE FROM T_BD_ITEMTYPE_L WHERE FPKID = '0PZLHI1=M2J3';
INSERT INTO T_BD_ITEMTYPE_L(FID,FPKID,FLOCALEID,FDESCRIPTION,FNAME) VALUES (870945989739982848,'0PZLHI1=M2J3','zh_CN',' ','组装商品'); 

DELETE FROM T_BD_ITEMTYPE_L WHERE FPKID = '0PZLINLFDBPO';
INSERT INTO T_BD_ITEMTYPE_L(FID,FPKID,FLOCALEID,FDESCRIPTION,FNAME) VALUES (870946146481079296,'0PZLINLFDBPO','zh_CN',' ','套餐商品'); 

DELETE FROM T_BD_ITEMTYPE_L WHERE FPKID = '0PZLJK91YEZY';
INSERT INTO T_BD_ITEMTYPE_L(FID,FPKID,FLOCALEID,FDESCRIPTION,FNAME) VALUES (870946271932711936,'0PZLJK91YEZY','zh_CN',' ','称重商品'); 

DELETE FROM T_BD_ITEMTYPE_L WHERE FPKID = '0PZLK454MOKO';
INSERT INTO T_BD_ITEMTYPE_L(FID,FPKID,FLOCALEID,FDESCRIPTION,FNAME) VALUES (870946349007286272,'0PZLK454MOKO','zh_CN',' ','金额商品'); 

DELETE FROM T_BD_ITEMTYPE_L WHERE FPKID = '0PZLKREJ/PCP';
INSERT INTO T_BD_ITEMTYPE_L(FID,FPKID,FLOCALEID,FDESCRIPTION,FNAME) VALUES (870946434386494464,'0PZLKREJ/PCP','zh_CN',' ','服务商品'); 

DELETE FROM T_BD_ITEMTYPE_L WHERE FPKID = '0PZLF/9UBEC9';
INSERT INTO T_BD_ITEMTYPE_L(FID,FPKID,FLOCALEID,FDESCRIPTION,FNAME) VALUES (870945645681225728,'0PZLF/9UBEC9','zh_CN',' ','普通商品'); 

DELETE FROM T_BD_ITEMTYPE_L WHERE FPKID = '0PZLFCYTPFE5';
INSERT INTO T_BD_ITEMTYPE_L(FID,FPKID,FLOCALEID,FDESCRIPTION,FNAME) VALUES (870945697287898112,'0PZLFCYTPFE5','zh_CN',' ','组合商品'); 



--商品信息中的库存单位、零售单位、分销订货单位取销售单位 
UPDATE T_MDR_ITEM_C T SET FSTOCKUNITID = (SELECT FSALEUNIT FROM T_MDR_ITEM TT WHERE TT.FID=T.FID) WHERE FSTOCKUNITID=0;
UPDATE T_MDR_ITEM_C T SET FORDERUNITID = (SELECT FSALEUNIT FROM T_MDR_ITEM TT WHERE TT.FID=T.FID) WHERE FORDERUNITID=0;
UPDATE T_MDR_ITEM_C T SET FRETAILUNITID = (SELECT FSALEUNIT FROM T_MDR_ITEM TT WHERE TT.FID=T.FID) WHERE FRETAILUNITID=0;

--更新下架状态的商品为禁用状态
UPDATE T_MDR_ITEM T SET FENABLE = '0' WHERE FID IN (SELECT FID FROM  T_MDR_ITEM_S WHERE FISONSELL='0');

--删除商品信息的预置查询方案
DELETE FROM T_BAS_FILTERSCHEME WHERE FFORMID='mdr_item_info' AND FISFIXED = '1';

--删除渠道云基础资料首页的上架商品
DELETE FROM T_BAS_MAINPAGELAYOUT WHERE FID = 612135428983707648;
INSERT INTO T_BAS_MAINPAGELAYOUT(FID,FCUSTOMABLE,FTYPE,FNUMBER,FDISABLETIME,FLAYOUT,FCREATETIME,FENABLE,FMODIFIERID,FISPRESET,FBIZAPPID,FMODIFYTIME,FSCHEMETYPE,FCREATORID,FUSERID,FDISABLERID) VALUES (612135428983707648,'1','app','612,135,428,983,707,648',NULL,'[{"w":12,"h":1,"x":0,"y":0,"i":"544061960124200960","moved":false,"static":false},{"w":4,"h":1,"x":0,"y":1,"i":"544076209693227008","moved":false,"static":false},{"w":4,"h":1,"x":4,"y":1,"i":"544078404153079808","moved":false,"static":false},{"w":2,"h":1,"x":0,"y":2,"i":"549808703256168448","moved":false,"static":false}]',NULL,'1',13466739,'1','/8G3I79R/3ZL',{ts'2020-04-30  15:58:38'},'1',0,1,0); 


--受控基础资料预设：商品品牌--主数据控制视图
--错误数据修复
DELETE FROM T_BD_DEFAULTCTRLSTRATEGY WHERE FID = 802862231782976512;

DELETE FROM T_BD_DEFAULTCTRLSTRATEGY WHERE FID = 878839308562657280;
INSERT INTO T_BD_DEFAULTCTRLSTRATEGY(FID,FCTRLVIEW,FDEFAULTMANAGESTRATEGY,FDATATYPE,FDISABLEDATE,FMASTERID,FSTATUS,FAPPSYSTEMID,FNUMBER,FDEFAULTCTRLSTRATEGY,FBASEDATAID,FCREATETIME,FENABLE,FMODIFIERID,FPLUGIN,FMODIFYTIME,FCREATORID,FISSYSTEM,FDISABLERID) VALUES (878839308562657280,16,'1','2',NULL,878839308562657280,'A','0QHL+F3BZ8MO',' ','5','mdr_item_brand',{ts'2020-04-27  13:36:06'},'1',13466739,' ',{ts'2020-04-27  13:36:49'},13466739,'0',0); 
