This commit is contained in:
aozhiwei 2022-12-12 11:32:28 +08:00
parent c85790d1d7
commit a4b4c32e17

View File

@ -545,20 +545,28 @@ class MarketController extends BaseController {
private function getNftListByAccountAndType($account, $type, $order_method, $order_asc)
{
$sortByLevel = function ($a, $b) use ($order_asc) {
return ($order_asc == 1 ? 1 : -1) * ($b['detail']['hero_lv'] - $a['detail']['hero_lv']);
};
$sortByGunLv = function ($a, $b) use($order_asc) {
return ($order_asc == 1 ? 1 : -1) * ($b['detail']['gun_lv'] - $a['detail']['gun_lv']);
};
$sortByTili = function ($a, $b) use($order_asc) {
return ($order_asc == 1 ? 1 : -1) * ($b['detail']['hero_tili'] - $a['detail']['hero_tili']);
};
$sortByStar = function ($a, $b) use($order_asc) {
return ($order_asc == 1 ? 1 : -1) * ($b['detail']['quality'] - $a['detail']['quality']);
};
$sortByDurability = function ($a, $b) use($order_asc) {
return ($order_asc == 1 ? 1 : -1) * ($b['detail']['durability_max'] - $a['detail']['durability_max']);
};
$sortByPower = function ($a, $b) use($order_asc) {
return ($order_asc == 1 ? 1 : -1) * ($b['detail']['strength'] - $a['detail']['strength']);
};
$sortByGrade = function ($a, $b) use($order_asc) {
return ($order_asc == 1 ? 1 : -1) * ($b['detail']['chip_grade'] - $a['detail']['chip_grade']);
};
$sortByTokenId = function ($a, $b) use ($order_asc) {
if ($order_asc == 1) {
return $b['token_id'] - $a['token_id'];
} else {
return $a['token_id'] - $b['token_id'];
}
return ($order_asc == 1 ? 1 : -1) * ($b['token_id'] - $a['token_id']);
};
$nfts = array();
switch ($type) {
@ -574,7 +582,7 @@ class MarketController extends BaseController {
usort($rows, $sortByLevel);
break;
case 2:
usort($rows, $sortByPower);
usort($rows, $sortByTili);
break;
case 3:
usort($rows, $sortByStar);
@ -591,10 +599,10 @@ class MarketController extends BaseController {
}
switch ($order_method) {
case 1:
usort($rows, $sortByLevel);
usort($rows, $sortByGunLv);
break;
case 2:
usort($rows, $sortByPower);
usort($rows, $sortByDurability);
break;
case 3:
usort($rows, $sortByStar);
@ -609,7 +617,7 @@ class MarketController extends BaseController {
}
switch ($order_method) {
case 1:
usort($rows, $sortByLevel);
usort($rows, $sortByGrade);
break;
case 2:
usort($rows, $sortByPower);
@ -718,7 +726,7 @@ class MarketController extends BaseController {
$lv_filter = getReqVal('lv_filter', 15);
$account = '0x9a4d9dd2bfcad659975f0f5a480625c7929e9385';
$rows = $this->getNftListByAccountAndType($account, $type);
$rows = $this->getNftListByAccountAndType($account, $type, $order_method, $order_asc);
$total = count($rows);
$page_end = $start + $page_size;