优化比例字符格式化
This commit is contained in:
parent
e11ddbe18a
commit
8127f851f2
@ -15,12 +15,10 @@ class GoodsSubsidy extends Models
|
|||||||
'list_rows'=> $get['limit'],
|
'list_rows'=> $get['limit'],
|
||||||
'page'=> $get['page'],
|
'page'=> $get['page'],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
foreach ($lists as &$v) {
|
foreach ($lists as &$v) {
|
||||||
$v['profit'] = self::formatStr($v['profit']);
|
$v['profit'] = self::formatStr($v['profit']);
|
||||||
$v['subsidy'] = self::formatStr($v['subsidy']);
|
$v['subsidy'] = self::formatStr($v['subsidy']);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ['count' => $lists->total(), 'lists' => $lists->getCollection()];
|
return ['count' => $lists->total(), 'lists' => $lists->getCollection()];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,7 +32,10 @@ class GoodsSubsidy extends Models
|
|||||||
|
|
||||||
public static function formatStr($str)
|
public static function formatStr($str)
|
||||||
{
|
{
|
||||||
$s = explode('.', $str);
|
$s = explode('.', strval($str));
|
||||||
return $s[1] > 0 ? $s . '%' : intval($str) . '%';
|
if (count($s) > 1 && $s[1] > 0) {
|
||||||
|
return $str . '%';
|
||||||
|
}
|
||||||
|
return intval($s[0]) . '%';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user