From 8127f851f2b8e653bbf7f4aecd13df8d7423f1de Mon Sep 17 00:00:00 2001 From: wangxiaowei Date: Mon, 18 Nov 2024 14:46:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=AF=94=E4=BE=8B=E5=AD=97?= =?UTF-8?q?=E7=AC=A6=E6=A0=BC=E5=BC=8F=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/model/goods/GoodsSubsidy.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/common/model/goods/GoodsSubsidy.php b/app/common/model/goods/GoodsSubsidy.php index f5f59b86..670648d3 100644 --- a/app/common/model/goods/GoodsSubsidy.php +++ b/app/common/model/goods/GoodsSubsidy.php @@ -15,12 +15,10 @@ class GoodsSubsidy extends Models 'list_rows'=> $get['limit'], 'page'=> $get['page'], ]); - foreach ($lists as &$v) { $v['profit'] = self::formatStr($v['profit']); $v['subsidy'] = self::formatStr($v['subsidy']); } - return ['count' => $lists->total(), 'lists' => $lists->getCollection()]; } @@ -34,7 +32,10 @@ class GoodsSubsidy extends Models public static function formatStr($str) { - $s = explode('.', $str); - return $s[1] > 0 ? $s . '%' : intval($str) . '%'; + $s = explode('.', strval($str)); + if (count($s) > 1 && $s[1] > 0) { + return $str . '%'; + } + return intval($s[0]) . '%'; } } \ No newline at end of file