select sum(amount) into cur from ssc_member_recharge where state!=0 and isDelete=0 and uid=_uid and actionTime BETWEEN UNIX_TIMESTAMP(DATE(NOW())) and UNIX_TIMESTAMP(NOW());
select `value` into _rechargeCommissionAmount from ssc_params where name='rechargeCommissionAmount' limit 1;
select rechargeCommisioned into _commisioned from ssc_member_bet where uid=_uid and date=date_format(now(),'%Y%m%d');
if cur is not null and cur >=_rechargeCommissionAmount and _commisioned=0 THEN
select `value` into _rechargeCommission from ssc_params where name='rechargeCommission' limit 1;
select `value` into _rechargeCommission2 from ssc_params where name='rechargeCommission2' limit 1;
select `parentId` into parentId1 from ssc_members where uid=_uid;
if parentId1 is not null and _rechargeCommission>0 THEN
declare dateTime int default unix_timestamp(curdate());
declare cur cursor for
select b.uid, b.username, sum(b.`mode` * b.actionNum * b.beiShu) _tjAmount from ssc_bets b where b.kjTime>=dateTime and b.uid not in(select distinct l.extfield0 from ssc_coin_log l where l.liqType=53 and l.actionTime>=dateTime and l.extfield2=parentLevel) group by b.uid having _tjAmount>=baseAmount;
declare continue HANDLER for not found set done=1;
select distinct u.uid from ssc_members u, ssc_member_session s where u.uid=s.uid and (u.coin+u.fcoin)<_coin and s.accessTime<_date and not exists(select u1.`uid` from ssc_members u1 where u1.parentId=u.`uid`)
union
select distinct u2.uid from ssc_members u2 where (u2.coin+u2.fcoin)<_coin and u2.regTime<_date and not exists (select s1.uid from ssc_member_session s1 where s1.uid=u2.uid);
declare continue HANDLER for not found set done = 1;