BEGIN
DECLARE COUNTFLAG INT;
/*SET COUNTFLAG = 0;*/
DECLARE LOGINTIME DATETIME;
DECLARE COLLALREADYNUM NUMERIC(10);
DECLARE COLLCANNUM NUMERIC(10);
DECLARE HUNTALREADYNUM NUMERIC(10);
DECLARE HUNTCANNUM NUMERIC(10);
DECLARE DETALPIC VARCHAR(200);
DECLARE USERLEVEL NUMERIC(10);
DECLARE ISEXIST NUMERIC(10);
SET ISFIRST='n';
SET @dt = now();
SELECT COUNT(1) INTO COUNTFLAG FROM USER_BASE_INFO WHERE XIAONEI_ID=XIAONEIID;
IF COUNTFLAG=0 THEN
INSERT INTO USER_BASE_INFO(USER_NAME,REG_TIME,XIAONEI_ID,USER_ICON,SESSION_KEY) VALUES(USERNAME,now(),XIAONEIID,HEADURL,SESSIONKEY);
INSERT INTO USER_DETAILS_INF(USER_NICK_NAME,USER_PIC,USER_SEX,USER_ADDR,USER_SCHOOL,XIAONEI_ID,ISVIP,LOGIN_TIME) VALUES(USERNAME,HEADURL,SEX,ADDR,SHOOL,XIAONEIID,ZIDOU,now());
INSERT INTO USER_PLANT_EARTH(XIAONEI_ID) VALUES(XIAONEIID);
INSERT INTO USER_ANIMAL_CAGE(XIAONEI_ID) VALUES(XIAONEIID);
INSERT INTO USER_PACKAGE(XIAONEI_ID,ITEM_ID,ITEM_COUNT) VALUES(XIAONEIID,'1190',1);
INSERT INTO USER_PACKAGE(XIAONEI_ID,ITEM_ID,ITEM_COUNT) VALUES(XIAONEIID,'1028',1);
INSERT INTO USER_PACKAGE(XIAONEI_ID,ITEM_ID,ITEM_COUNT) VALUES(XIAONEIID,'1029',1);
INSERT INTO USER_PACKAGE(XIAONEI_ID,ITEM_ID,ITEM_COUNT) VALUES(XIAONEIID,'1030',1);
INSERT INTO USER_PACKAGE(XIAONEI_ID,ITEM_ID,ITEM_COUNT) VALUES(XIAONEIID,'1035',1);
INSERT INTO USER_PACKAGE(XIAONEI_ID,ITEM_ID,ITEM_COUNT) VALUES(XIAONEIID,'1036',1);
INSERT INTO USER_PACKAGE(XIAONEI_ID,ITEM_ID,ITEM_COUNT) VALUES(XIAONEIID,'560',2);
INSERT INTO USER_PACKAGE(XIAONEI_ID,ITEM_ID,ITEM_COUNT) VALUES(XIAONEIID,'651',1);
INSERT INTO USER_PACKAGE(XIAONEI_ID,ITEM_ID,ITEM_COUNT) VALUES(XIAONEIID,'557',1);
INSERT INTO USER_PACKAGE(XIAONEI_ID,ITEM_ID,ITEM_COUNT) VALUES(XIAONEIID,'450',1);
INSERT INTO USER_DEPOT(XIAONEI_ID,ITEM_ID,ITEM_COUNT,ITEM_STEP) VALUES(XIAONEIID,'561',24,'0');
INSERT INTO USER_ITEM_PLANT(XIAONEI_ID,PLANT_ID,PLANT_TOTAL_STAGE,EARTH_INDEX,PLANT_START_TIME,PLANT_POSITION) VALUES(XIAONEIID,'606',1,'t0',(date_sub(@dt,interval 960 minute)),'553.75,314.65');
INSERT INTO USER_ITEM_PLANT(XIAONEI_ID,PLANT_ID,PLANT_TOTAL_STAGE,EARTH_INDEX,PLANT_START_TIME,PLANT_POSITION) VALUES(XIAONEIID,'606',1,'t1',(date_sub(@dt,interval 900 minute)),'487,383');
INSERT INTO USER_ITEM_PLANT(XIAONEI_ID,PLANT_ID,PLANT_TOTAL_STAGE,EARTH_INDEX,PLANT_START_TIME,PLANT_STATUS,PLANT_POSITION) VALUES(XIAONEIID,'606',1,'t2',(date_sub(@dt,interval round(960/5*3)minute)),'2','402.25,441.35');
INSERT INTO USER_ITEM_PLANT(XIAONEI_ID,PLANT_ID,PLANT_TOTAL_STAGE,EARTH_INDEX,PLANT_START_TIME,PLANT_STATUS,PLANT_POSITION) VALUES(XIAONEIID,'560',1,'0',(date_sub(@dt,interval round(720/5*4)minute)),'2,2','365.4,556.9');
INSERT INTO USER_ITEM_PLANT(XIAONEI_ID,PLANT_ID,PLANT_TOTAL_STAGE,EARTH_INDEX,PLANT_START_TIME,PLANT_STATUS,PLANT_POSITION) VALUES(XIAONEIID,'560',1,'1',(date_sub(@dt,interval 600 minute)),'0','398.15,624.3');
INSERT INTO USER_ITEM_PLANT(XIAONEI_ID,PLANT_ID,PLANT_TOTAL_STAGE,EARTH_INDEX,PLANT_START_TIME,PLANT_STATUS,PLANT_POSITION) VALUES(XIAONEIID,'564',1,'2',now(),'1','334.625,701');
INSERT INTO USER_ITEM_PLANT(XIAONEI_ID,PLANT_ID,PLANT_TOTAL_STAGE,EARTH_INDEX,PLANT_START_TIME,PLANT_STATUS,PLANT_POSITION) VALUES(XIAONEIID,'564',1,'3',(date_sub(@dt,interval 840 minute)),'0','492.75,553');
INSERT INTO USER_ITEM_PLANT(XIAONEI_ID,PLANT_ID,PLANT_TOTAL_STAGE,EARTH_INDEX,PLANT_START_TIME,PLANT_STATUS,PLANT_POSITION) VALUES(XIAONEIID,'557',1,'4',(date_sub(@dt,interval round(600/5*3)minute)),'0','543.8,626.3');
INSERT INTO USER_ITEM_PLANT(XIAONEI_ID,PLANT_ID,PLANT_TOTAL_STAGE,EARTH_INDEX,PLANT_START_TIME,PLANT_STATUS,PLANT_POSITION) VALUES(XIAONEIID,'557',1,'5',(date_sub(@dt,interval 600 minute)),'0','473.25,704.3');
SET ISFIRST='y';
COMMIT;
END IF;
SELECT A.USER_EXP,C.EXP_LEVEL,A.PROPULAR_ID,A.USER_MONEY,A.USER_MARRIAGE,
A.USER_OMONEY,A.ITEM_BIG_PIC,A.IMG_HOUSE,A.IMG_ENCLOSURE,A.USER_PIC,
A.IMG_BELIEF_BG,A.USER_WELLKNOW,A.USER_OMONEY,A.HAVE_CREATE,A.ISVIP,
A.MANOR_NAME,A.USER_SCHOOL,A.USER_ADDR,A.USER_NICK_NAME, A.USER_EXP,
C.EXPERIENCE,D.PROPULAR_NAME,D.PROPULAR_NEED,A.IMG_PLANT_BG,A.IMG_ANIMAL_BG,
NEWTASK_ISCOMPLE,A.PROPULAR_ID,A.COLLECTION_ALREADY_NUM,A.COLLECTION_CAN,
A.HUNT_ALREADY_NUM,A.HUNT_CAN INTO `EXP`,LEVELS,TITLE,MONEYS,MARRIAGE,COIN,
DOGNEST,HOUSE,NET,USERPIC,MAINBG,WELLKNOW,OMONEY,CREATENUM,VIP,MANORNAME,
SCHOOL,CITY,USERNICKNAME,USEREXP,NEEDEXP,PROPUNAME,PROPUNEED,IMGPLANTBG,
IMGANIMALBG,TASKCOMPLE,USERTITLE,COLLECTNUM,COLLECTCAN,HUNTNUM,HUNTCAN
FROM (SELECT A.*,B.ITEM_BIG_PIC FROM USER_DETAILS_INF A
LEFT JOIN ITEM_INF B ON A.IMG_DOG=B.ITEM_ID WHERE A.XIAONEI_ID=XIAONEIID) A ,
EXP_INF C,PROPULAR_INF D WHERE A.EXP_ID=C.EXP_ID AND A.PROPULAR_ID=D.PROPULAR_ID;
SET YES='yes';
END