修改用户等级管理

This commit is contained in:
邹景立 2022-08-11 15:06:36 +08:00
parent decae548a2
commit f0b41ba380
3 changed files with 16 additions and 12 deletions

View File

@ -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]);
}

View File

@ -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;
}
/**

View File

@ -27,7 +27,7 @@
<form action="{:sysuri()}" class="layui-form layui-card" data-auto="true" method="post">
<div class="layui-card-body padding-left-40">
<fieldset class="layui-form-item">
<fieldset class="layui-form-item layui-bg-gray">
<legend><span class="layui-badge layui-bg-cyan">用户等级</span></legend>
<div class="layui-form-item layui-row layui-col-space15">
<div class="layui-col-xs3 block relative">
@ -49,7 +49,7 @@
<div class="layui-row layui-col-space15">
<div class="layui-col-xs6">
<fieldset class="layui-form-item">
<fieldset class="layui-form-item layui-bg-gray">
<legend><span class="layui-badge layui-bg-cyan">升级规则</span></legend>
<div class="layui-form-item notselect">
{php}$vo['upgrade_type'] = $vo['upgrade_type'] ?? 1;{/php}
@ -63,7 +63,7 @@
</fieldset>
</div>
<div class="layui-col-xs6">
<fieldset class="layui-form-item">
<fieldset class="layui-form-item layui-bg-gray">
<legend><span class="layui-badge layui-bg-cyan">团队计数</span></legend>
<div class="layui-form-item notselect">
{php}$vo['upgrade_team'] = $vo['upgrade_team'] ?? 1;{/php}
@ -78,7 +78,7 @@
</div>
</div>
<fieldset class="layui-form-item">
<fieldset class="layui-form-item layui-bg-gray">
<legend><span class="layui-badge layui-bg-cyan">升级条件</span></legend>
<div class="font-s13 relative">
<div>
@ -143,7 +143,7 @@
</div>
</fieldset>
<fieldset class="layui-form-item">
<fieldset class="layui-form-item layui-bg-gray">
<legend><span class="layui-badge layui-bg-cyan">奖利规则</span></legend>
<div class="notselect relative">
{foreach $prizes as $prize}{if isset($vo.rebate_rule) && is_array($vo.rebate_rule) && isset($vo.rebate_rule[$prize.code])}