package IIffdf54f1494b3bf443f066e7a818a029::mod_top_prod_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, recur_opt => 0 if $qh->{no_recur}; my $data = II720d6e18aa34327713eb014408fc9144::llllllIIIlIIlIlI($II8dae0e141ee45f5daba6a74e4a7c3b6f::IllIlIIllllIIIlI{$II8dae0e141ee45f5daba6a74e4a7c3b6f::IlIllIIlIllIlIIl},100,$II8dae0e141ee45f5daba6a74e4a7c3b6f::IllIlIIllllIIIlI{$II720d6e18aa34327713eb014408fc9144::IlIIllIlllllIIll})->getRecords( "jin_sale.prod_id as id,jin_product.title as name,sum(jin_sale.amount) as sum", JOIN => "left join jin_product on jin_product.id=jin_sale.prod_id", @sea, paid => 1, refunded => 0, WHERE => "jin_sale.prod_id!=0", GROUP => "jin_sale.prod_id", ORDER => "sum desc,prod_id desc", NUM => $limit, ); my $total = II8dae0e141ee45f5daba6a74e4a7c3b6f::llIIlIIlIIIIlIlI($II720d6e18aa34327713eb014408fc9144::lIIIIIllIIIlllll{$II720d6e18aa34327713eb014408fc9144::IlIlIllIIIIIllll},100,$II720d6e18aa34327713eb014408fc9144::lIIIIIllIIIlllll{$IIb39071a48a82a07eeb9256f406abebc5::llIIIllIIlIIIIIl})->getValue( "sum(jin_sale.amount)", @sea, paid => 1, refunded => 0, WHERE => "jin_sale.prod_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; 