package IIffdf54f1494b3bf443f066e7a818a029::mod_top_aff_amo_sale; use strict; use base qw/II720d6e18aa34327713eb014408fc9144/; use IIc006e1d88f66a3969ffd0192be9acb1b; 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_opt => 0 if $qh->{no_recur}; my $data = II720d6e18aa34327713eb014408fc9144::IlllIllllIllIIIl($II8dae0e141ee45f5daba6a74e4a7c3b6f::IIllllIllllllIll{$II720d6e18aa34327713eb014408fc9144::lIIIlllIlllIIllI},100,$II8dae0e141ee45f5daba6a74e4a7c3b6f::IIllllIllllllIll{$II982446f8950cc3dc59e487adba22df54::IlllIIIIllIIlIII})->getRecords( "jin_sale.aff_user_id as id,jin_user.name,sum(jin_sale.amount) as sum", JOIN => "left join jin_user on jin_user.id=jin_sale.aff_user_id", @sea, paid => 1, refunded => 0, WHERE => "jin_sale.aff_user_id != 0", WHERE => "jin_sale.aff_user_id != jin_sale.user_id", GROUP => "jin_sale.aff_user_id", ORDER => "sum desc", NUM => $limit, ); my $total = IIb39071a48a82a07eeb9256f406abebc5::IIIIllIllIlIIIlI($II8dae0e141ee45f5daba6a74e4a7c3b6f::IIllllIllllllIll{$II982446f8950cc3dc59e487adba22df54::IIIllIlIlIIIllII},100,$II8dae0e141ee45f5daba6a74e4a7c3b6f::IIllllIllllllIll{$II720d6e18aa34327713eb014408fc9144::llIlIIIIIIlIIIIl})->getValue( "sum(jin_sale.amount)", @sea, paid => 1, refunded => 0, WHERE => "jin_sale.aff_user_id != 0", ); my $topSum = scalar(@$data) ? $data->[0]{sum} : 0; for my $d (@$data) { $d->{percent} = $total ? ($d->{sum} / $total * 100) : 0; $d->{grad} = $topSum ? ($d->{sum} / $topSum * 100) : 0; } $data; } 1; 