CREATE DEFINER=`root`@`localhost` FUNCTION `补填推广人信息`(invite_id INT(10), invitee_id INT(10)) RETURNS int(10)
BEGIN
IF (SELECT COUNT(F01) FROM S61.T6111 WHERE F01=invitee_id AND F03 IS NULL AND F04 IS NULL AND F05 IS NULL AND F06 IS NULL)>0
THEN
UPDATE S61.T6111 aa,S61.T6110 bb,S61.T6111 cc SET aa.F03=cc.F02,aa.F04=bb.F04,aa.F05=bb.F02,aa.F06=bb.F01 WHERE bb.F01=invite_id AND aa.F01=invitee_id AND bb.F01=cc.F01;
UPDATE S63.T6310 SET F02=F02+1 WHERE F01=invite_id;
INSERT INTO S63.T6311(F02,F03) VALUES (invite_id,invitee_id);
END IF;
RETURN(invite_id);
END