->field("FROM_UNIXTIME(pay_time,'%Y-%m') as my_time,sum(pay_amount) as pay_amount,game_id,game_name,SUBSTRING_INDEX(`game_name`,\"(\",1) as game_names,promote_id,promote_account,company_relation,company_belong,CASE WHEN SUBSTRING_INDEX(SUBSTRING_INDEX(`chain`,\"/\",2),\"/\",-1)='' THEN promote_id ELSE SUBSTRING_INDEX(SUBSTRING_INDEX(`chain`,\"/\",2),\"/\",-1) END as root_id ")
->join("left join tab_promote on promote_id = tab_promote.id")
->where(['pay_status'=>1])
->group("my_time,game_names,root_id")
->order("my_time Desc")
->select(false);
$count = M()->table('('.$data.') as a')
->field("my_time,pay_amount,game_id,game_names,promote_id,promote_account,a.company_relation,a.company_belong,CASE WHEN root_id is null THEN 0 ELSE root_id END as root_id,CASE WHEN account is null THEN '官方渠道' ELSE account END as account")
->join("left join tab_promote on root_id = tab_promote.id")
->group("my_time,game_names,root_id")
->where($map)
->order("my_time Desc")
->select(false);
//关联表获取会长账号名
$data = M()->table('('.$data.') as a')
->field("my_time,pay_amount,game_id,game_name,game_names,promote_id,promote_account,a.company_relation,a.company_belong,CASE WHEN root_id is null THEN 0 ELSE root_id END as root_id,CASE WHEN account is null THEN '官方渠道' ELSE account END as account")
->join("left join tab_promote on root_id = tab_promote.id")
->page($page,$row)
->where($map)
->group("my_time,game_names,root_id")
->order("my_time Desc")
->select();
$pagecount = M()->table('('.$count.') as a')->count();