1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 08:52:39 +01:00

Show a very basic purchase history in Phortune

Summary: Ref T2787. This is very basic and just helps me know that the data is inserting correctly.

Test Plan: {F187765}

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T2787

Differential Revision: https://secure.phabricator.com/D10205
This commit is contained in:
epriestley 2014-08-11 12:10:09 -07:00
parent d38e89ef6b
commit 7513c70e2c
2 changed files with 77 additions and 2 deletions

View file

@ -157,13 +157,62 @@ final class PhortuneAccountViewController extends PhortuneController {
private function buildPurchaseHistorySection(PhortuneAccount $account) {
$request = $this->getRequest();
$user = $request->getUser();
$viewer = $request->getUser();
$carts = id(new PhortuneCartQuery())
->setViewer($viewer)
->withAccountPHIDs(array($account->getPHID()))
->needPurchases(true)
->withStatuses(
array(
PhortuneCart::STATUS_PURCHASING,
PhortuneCart::STATUS_PURCHASED,
))
->execute();
$rows = array();
$rowc = array();
foreach ($carts as $cart) {
$rowc[] = 'highlighted';
$rows[] = array(
$cart->getPHID(),
'',
'',
);
foreach ($cart->getPurchases() as $purchase) {
$price = $purchase->getTotalPriceInCents();
$price = PhortuneCurrency::newFromUSDCents($price)->formatForDisplay();
$rowc[] = '';
$rows[] = array(
'',
$purchase->getPHID(),
$price,
);
}
}
$table = id(new AphrontTableView($rows))
->setRowClasses($rowc)
->setHeaders(
array(
pht('Cart'),
pht('Purchase'),
pht('Amount'),
))
->setColumnClasses(
array(
'',
'wide',
'right',
));
$header = id(new PHUIHeaderView())
->setHeader(pht('Purchase History'));
return id(new PHUIObjectBoxView())
->setHeader($header);
->setHeader($header)
->appendChild($table);
}
private function buildChargeHistorySection(PhortuneAccount $account) {

View file

@ -5,6 +5,8 @@ final class PhortuneCartQuery
private $ids;
private $phids;
private $accountPHIDs;
private $statuses;
private $needPurchases;
@ -18,6 +20,16 @@ final class PhortuneCartQuery
return $this;
}
public function withAccountPHIDs(array $account_phids) {
$this->accountPHIDs = $account_phids;
return $this;
}
public function withStatuses(array $statuses) {
$this->statuses = $statuses;
return $this;
}
public function needPurchases($need_purchases) {
$this->needPurchases = $need_purchases;
return $this;
@ -93,6 +105,20 @@ final class PhortuneCartQuery
$this->phids);
}
if ($this->accountPHIDs !== null) {
$where[] = qsprintf(
$conn,
'cart.accountPHID IN (%Ls)',
$this->accountPHIDs);
}
if ($this->statuses !== null) {
$where[] = qsprintf(
$conn,
'cart.status IN (%Ls)',
$this->statuses);
}
return $this->formatWhereClause($where);
}