holyandrew (holyandrew) wrote in changelog,
holyandrew
holyandrew
changelog

[ljcom] r11486: 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-16 17:59:19 UTC (rev 11485)
+++ trunk/htdocs/admin/profit.bml	2012-02-17 08:20:17 UTC (rev 11486)
@@ -3,11 +3,26 @@
 BML::finish();
 use LJ::Pay::Wallet;
 use LJ::Pay::SelfPromo;
+my $total_sum = 0;
+my $selfpromo_month = 0;
+my $selfpromo_day = 0;
 my $dbh = LJ::get_db_writer;
-my ($total) = $dbh->selectrow_array("select sum(amount) from payments where daterecv > '2012-01-01' and used != 'C' and method != 'wallet';");
-my ($selfpromo_month) = $dbh->selectrow_array("select sum(amount)-sum(propval)/100 from payments,payitems,payitemprop where payments.payid=payitems.payid and year(payments.daterecv)=year(now()) and month(payments.daterecv)=month(now()) and payitems.piid=payitemprop.piid and payments.method='wallet' and payitems.status='done' and payments.used!='C' and payitemprop.propname='selfpromo_refund';");
-my ($selfpromo_day) = $dbh->selectrow_array("select sum(amount)-sum(propval)/100 from payments,payitems,payitemprop where payments.payid=payitems.payid and year(payments.daterecv)=year(now()) and month(payments.daterecv)=month(now()) and day(payments.daterecv)=day(now()) and payitems.piid=payitemprop.piid and payments.method='wallet' and payitems.status='done' and payments.used!='C' and payitemprop.propname='selfpromo_refund';");
-return int($total) . "," . 
+my $sth = $dbh->prepare("select userid,amount from payments where daterecv > '2012-01-01' and used != 'C' and method != 'wallet';");
+$sth->execute();
+while (my $row = $sth->fetchrow_hashref) {
+    $total_sum += $row->{amount} unless LJ::SUP->is_sup_enabled(LJ::load_userid($row->{userid}));
+}
+$sth = $dbh->prepare("select userid,amount,propval from payments,payitems,payitemprop where payments.payid=payitems.payid and year(payments.daterecv)=year(now()) and month(payments.daterecv)=month(now()) and payitems.piid=payitemprop.piid and payments.method='wallet' and payitems.status='done' and payments.used!='C' and payitemprop.propname='selfpromo_refund';");
+$sth->execute();
+while (my $row = $sth->fetchrow_hashref) {
+    $selfpromo_month += $row->{amount}-$row->{propval}/100 unless LJ::SUP->is_sup_enabled(LJ::load_userid($row->{userid}));
+}
+$sth = $dbh->prepare("select userid,amount,propval from payments,payitems,payitemprop where payments.payid=payitems.payid and year(payments.daterecv)=year(now()) and month(payments.daterecv)=month(now()) and day(payments.daterecv)=day(now()) and payitems.piid=payitemprop.piid and payments.method='wallet' and payitems.status='done' and payments.used!='C' and payitemprop.propname='selfpromo_refund';");
+$sth->execute();
+while (my $row = $sth->fetchrow_hashref) {
+    $selfpromo_day += $row->{amount}-$row->{propval}/100 unless LJ::SUP->is_sup_enabled(LJ::load_userid($row->{userid}));
+}
+return int($total_sum) . "," . 
 int($selfpromo_month*LJ::Pay::Wallet::EXCHANGE_RATE) . "," . 
 int($selfpromo_day*LJ::Pay::Wallet::EXCHANGE_RATE);
 }

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