holyandrew (holyandrew) wrote in changelog,
holyandrew
holyandrew
changelog

[ljcom] r11473: LJSUP-10941: Need a page to display cert...

Committer: akanashin
LJSUP-10941: Need a page to display certain figures from the LiveJournal Shop
U   trunk/htdocs/admin/profit.bml
Modified: trunk/htdocs/admin/profit.bml
===================================================================
--- trunk/htdocs/admin/profit.bml	2012-02-14 08:29:11 UTC (rev 11472)
+++ trunk/htdocs/admin/profit.bml	2012-02-14 09:21:21 UTC (rev 11473)
@@ -5,7 +5,31 @@
 use LJ::Pay::SelfPromo;
 my $dbh = LJ::get_db_writer;
 my $info = LJ::Pay::SelfPromo->current_promo_info;
-my ($selfpromo) = $dbh->selectrow_array("select sum(payitemprop.propval) from payments inner join payitems using(payid) inner join payitemprop on payitems.piid=payitemprop.piid and payitemprop.propname='selfpromo_profit' where payments.daterecv > '2012-01-01' and used != 'C' and method = 'wallet' and payitems.item='selfpromo';");
-return int($dbh->selectrow_array("select sum(amount) from payments where daterecv > '2012-01-01' and used != 'C' and method != 'wallet';")) . "," . int($selfpromo/LJ::Pay::Wallet::EXCHANGE_RATE) . "," . int($info ? $info->cost/LJ::Pay::Wallet::EXCHANGE_RATE : 0);
+#my ($selfpromo) = $dbh->selectrow_array("select sum(payitemprop.propval) from payments inner join payitems using(payid) inner join payitemprop on payitems.piid=payitemprop.piid and payitemprop.propname='selfpromo_profit' where payments.daterecv > '2012-01-01' and used != 'C' and method = 'wallet' and payitems.item='selfpromo';");
+
+my $select_payments_sql = "SELECT * FROM payments WHERE used = 'Y' AND method = 'wallet' AND year(daterecv) = year(now()) AND month(daterecv) = month(now())";
+my $sth = $dbh->prepare($select_payments_sql);
+$sth->execute;
+
+my $payments_ref;
+my @users;
+while (my $row = $sth->fetchrow_hashref) {
+    $payments_ref->{$row->{payid}} = $row;
+    push @users, $row->{userid} if $users ne 'all' and $users ne 'anon';
 }
+  
+my $us = LJ::load_userids(@users);
+    
+foreach my $payid (keys %{$payments_ref}) {
+    my $userid = $payments_ref->{$payid}->{userid};
+    delete $payments_ref->{$payid} if not $us->{$userid} or $users eq 'cyr' and not LJ::SUP->is_sup_enabled($us->{$userid});
+}
+
+my $selfpromo;
+$selfpromo+=$payments_ref->{$_}->{amount} foreach (keys %$payments_ref);
+     
+return int($dbh->selectrow_array("select sum(amount) from payments where daterecv > '2012-01-01' and used != 'C' and method != 'wallet';")) . "," . 
+int($selfpromo*LJ::Pay::Wallet::EXCHANGE_RATE) . "," . 
+int($info ? $info->cost : 0);
+}
 _code?>

Tags: akanashin, bml, holyandrew, ljcom
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments