Skip to content

Commit

Permalink
add comment
Browse files Browse the repository at this point in the history
  • Loading branch information
d0riven committed Sep 8, 2019
1 parent aa52868 commit 020bf61
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions php/src/App/Service.php
Expand Up @@ -155,6 +155,7 @@ private function getCategoryByID($id)
if ($category === false) {
return false;
}
// 親カテゴリを再帰的に取得
if ((int) $category['parent_id'] !== 0) {
$parent = $this->getCategoryByID($category['parent_id']);
if ($parent === false) {
Expand Down Expand Up @@ -532,6 +533,10 @@ public function transactions(Request $request, Response $response, array $args)

if ($itemId !== 0 && $createdAt > 0) {
// paging

// 自分が売り手 or 買い手 の商品を取得
// 2ページ目以降はitemIdやcreatedAtが指定される?
// memo: ITEM_STATUSが指定されているがこれ全部のステータスが指定されているのでいらないのでは?
$sth = $this->dbh->prepare('SELECT * FROM `items` WHERE '.
'(`seller_id` = ? OR `buyer_id` = ?) AND `status` IN (?,?,?,?,?) AND (`created_at` < ? OR (`created_at` <=? AND `id` < ?)) '.
'ORDER BY `created_at` DESC, `id` DESC LIMIT ?');
Expand All @@ -553,6 +558,8 @@ public function transactions(Request $request, Response $response, array $args)
}
} else {
// 1st page
// 自分が売り手 or 買い手 の商品を取得
// 商品IDが指定されている もしくは Itemの追加時間があればこちらを使う
$sth = $this->dbh->prepare('SELECT * FROM `items` WHERE ' .
'(`seller_id` = ? OR `buyer_id` = ?) AND `status` IN (?,?,?,?,?) ' .
'ORDER BY `created_at` DESC, `id` DESC LIMIT ?');
Expand Down Expand Up @@ -598,6 +605,7 @@ public function transactions(Request $request, Response $response, array $args)
'created_at' => (new \DateTime($item['created_at']))->getTimestamp(),
];

// 購入者が存在するなら購入者のユーザ情報を付与
if ((int) $item['buyer_id'] !== 0) {
$buyer = $this->getUserSimpleByID($item['buyer_id']);
if ($buyer === false) {
Expand All @@ -608,6 +616,7 @@ public function transactions(Request $request, Response $response, array $args)
$detail['buyer'] = $buyer;
}

// memo: transaction_evidences is 何?
$sth = $this->dbh->prepare('SELECT * FROM `transaction_evidences` WHERE `item_id` = ?');
$r = $sth->execute([$item['id']]);
if ($r === false) {
Expand All @@ -628,6 +637,7 @@ public function transactions(Request $request, Response $response, array $args)
return $response->withStatus(StatusCode::HTTP_NOT_FOUND)->withJson(['error' => 'shipping not found']);
}

// too slow external service
$client = new Client();
$host = $this->getShipmentServiceURL();
try {
Expand Down

0 comments on commit 020bf61

Please sign in to comment.