diff --git a/app/data/controller/base/Upgrade.php b/app/data/controller/base/Upgrade.php index ff8dc356e..39268e2e0 100644 --- a/app/data/controller/base/Upgrade.php +++ b/app/data/controller/base/Upgrade.php @@ -30,6 +30,8 @@ class Upgrade extends Controller /** * 添加用户等级 * @auth true + * @return void + * @throws \think\db\exception\DbException */ public function add() { @@ -40,6 +42,8 @@ class Upgrade extends Controller /** * 编辑用户等级 * @auth true + * @return void + * @throws \think\db\exception\DbException */ public function edit() { @@ -50,6 +54,7 @@ class Upgrade extends Controller /** * 表单数据处理 * @param array $vo + * @throws \think\db\exception\DbException */ protected function _form_filter(array &$vo) { @@ -91,11 +96,8 @@ class Upgrade extends Controller public function _form_result(bool $state) { if ($state) { - if (input('old_number', 100) <= input('number', 0)) { - $order = 'number asc,utime asc'; - } else { - $order = 'number asc,utime desc'; - } + $isasc = input('old_number', 0) <= input('number', 0); + $order = $isasc ? 'number asc,utime asc' : 'number asc,utime desc'; foreach (BaseUserUpgrade::mk()->order($order)->select() as $number => $upgrade) { $upgrade->save(['number' => $number]); } diff --git a/app/data/model/BaseUserUpgrade.php b/app/data/model/BaseUserUpgrade.php index c3545ada3..3c431009d 100644 --- a/app/data/model/BaseUserUpgrade.php +++ b/app/data/model/BaseUserUpgrade.php @@ -25,11 +25,13 @@ class BaseUserUpgrade extends Model /** * 获取最大级别数 - * @return int + * @return integer + * @throws \think\db\exception\DbException */ public static function maxNumber(): int { - return static::mk()->max('number', 0) + 1; + if (static::mk()->count() < 1) return 0; + return static::mk()->max('number') + 1; } /** diff --git a/app/data/view/base/upgrade/form.html b/app/data/view/base/upgrade/form.html index e4db149a2..5962ae3f6 100644 --- a/app/data/view/base/upgrade/form.html +++ b/app/data/view/base/upgrade/form.html @@ -27,7 +27,7 @@
-
+
用户等级
@@ -49,7 +49,7 @@
-
+
升级规则
{php}$vo['upgrade_type'] = $vo['upgrade_type'] ?? 1;{/php} @@ -63,7 +63,7 @@
-
+
团队计数
{php}$vo['upgrade_team'] = $vo['upgrade_team'] ?? 1;{/php} @@ -78,7 +78,7 @@
-
+
升级条件
@@ -143,7 +143,7 @@
-
+
奖利规则
{foreach $prizes as $prize}{if isset($vo.rebate_rule) && is_array($vo.rebate_rule) && isset($vo.rebate_rule[$prize.code])}