package IIffdf54f1494b3bf443f066e7a818a029::mod_top_aff_num_comm; use strict; use base qw/II720d6e18aa34327713eb014408fc9144/; use IIbbd7c6cf33a8b724d5937c621b455d05; sub search { my ($class, $qh) = @_; my $limit = ($qh->{limit} + 0) || 10; my @sea; push @sea, made_after => $qh->{date_after} if $qh->{date_after}; push @sea, made_until => $qh->{date_before} if $qh->{date_before}; push @sea, packs => $qh->{packs} if $qh->{packs}; push @sea, prods => $qh->{prods} if $qh->{prods}; push @sea, recur_no => 1 if $qh->{no_recur}; my $data = IIb39071a48a82a07eeb9256f406abebc5::IIlIlIlIIllllIIl($II8dae0e141ee45f5daba6a74e4a7c3b6f::lIlllIlIlIlIlIll{$II982446f8950cc3dc59e487adba22df54::lIIlIlIIIIIIllII},121,$II8dae0e141ee45f5daba6a74e4a7c3b6f::lIlllIlIlIlIlIll{$II8dae0e141ee45f5daba6a74e4a7c3b6f::IllIllIlllllllII})->getRecords( "jin_commission.ben_user_id as id,jin_user.name,count(jin_commission.amount) as num", JOIN => "left join jin_user on jin_user.id=jin_commission.ben_user_id", @sea, paid_only => 1, cancelled => 0, GROUP => "jin_commission.ben_user_id", ORDER => "num desc", NUM => $limit, ); my $total = IIb39071a48a82a07eeb9256f406abebc5::llllIIIIllllllIl($II8dae0e141ee45f5daba6a74e4a7c3b6f::IlIIlIIIIIIlIIII{$II8dae0e141ee45f5daba6a74e4a7c3b6f::IIIIlIIlIIIIIIIl},121,$II8dae0e141ee45f5daba6a74e4a7c3b6f::IlIIlIIIIIIlIIII{$II982446f8950cc3dc59e487adba22df54::lIIlllIlIllllIIl})->getValue( "count(jin_commission.amount)", @sea, paid_only => 1, cancelled => 0, ); my $topNum = scalar(@$data) ? $data->[0]{num} : 0; for my $d (@$data) { $d->{percent} = $total ? ($d->{num} / $total * 100) : 0; $d->{grad} = $topNum ? ($d->{num} / $topNum * 100) : 0; } $data; } 1; 