Page MenuHomePhabricator

D10205.id24594.diff
No OneTemporary

D10205.id24594.diff

diff --git a/src/applications/phortune/controller/PhortuneAccountViewController.php b/src/applications/phortune/controller/PhortuneAccountViewController.php
--- a/src/applications/phortune/controller/PhortuneAccountViewController.php
+++ b/src/applications/phortune/controller/PhortuneAccountViewController.php
@@ -157,13 +157,62 @@
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) {
diff --git a/src/applications/phortune/query/PhortuneCartQuery.php b/src/applications/phortune/query/PhortuneCartQuery.php
--- a/src/applications/phortune/query/PhortuneCartQuery.php
+++ b/src/applications/phortune/query/PhortuneCartQuery.php
@@ -5,6 +5,8 @@
private $ids;
private $phids;
+ private $accountPHIDs;
+ private $statuses;
private $needPurchases;
@@ -18,6 +20,16 @@
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 @@
$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);
}

File Metadata

Mime Type
text/plain
Expires
Oct 19 2024, 2:24 AM (4 w, 3 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6729847
Default Alt Text
D10205.id24594.diff (3 KB)

Event Timeline