package IIffdf54f1494b3bf443f066e7a818a029::mod_top_cust_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 = II8dae0e141ee45f5daba6a74e4a7c3b6f::lllIllIIIllIllII($II8dae0e141ee45f5daba6a74e4a7c3b6f::IllIlIIllllIIIlI{$II8dae0e141ee45f5daba6a74e4a7c3b6f::IIIIlIIlIIIIIIIl},100,$II8dae0e141ee45f5daba6a74e4a7c3b6f::IllIlIIllllIIIlI{$II982446f8950cc3dc59e487adba22df54::lIIlIIIIIlIlIllI})->getRecords( "jin_sale.user_id as id,jin_user.*,sum(jin_sale.amount) as sum", JOIN => "left join jin_user on jin_user.id=jin_sale.user_id", @sea, paid => 1, refunded => 0, GROUP => "jin_sale.user_id", ORDER => "sum desc", NUM => $limit, ); my $total = II720d6e18aa34327713eb014408fc9144::IIllIllIIlIIIlll($IIb39071a48a82a07eeb9256f406abebc5::llIllIlIllIIIIlI{$IIb39071a48a82a07eeb9256f406abebc5::IIlllIIIIlIlllII},100,$IIb39071a48a82a07eeb9256f406abebc5::llIllIlIllIIIIlI{$II8dae0e141ee45f5daba6a74e4a7c3b6f::IllIlllllllIlIll})->getValue( "sum(jin_sale.amount)", @sea, paid => 1, refunded => 0, ); my $topSum = scalar(@$data) ? $data->[0]{sum} : 0; my $countries = Zen::Config->get('lists::countries')->{main}; my $states = Zen::Config->get('lists::states')->{main}; for my $d (@$data) { $d->{percent} = $total ? ($d->{sum} / $total * 100) : 0; $d->{grad} = $topSum ? ($d->{sum} / $topSum * 100) : 0; $d->{country} = $countries->{$d->{country}} if $d->{country}; $d->{state} = $states->{$d->{state}} if $d->{state}; } $data; } 1; 