mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2025-04-06 03:58:04 +08:00
修改等级管理
This commit is contained in:
parent
584bae4826
commit
a94f864982
@ -47,6 +47,7 @@ class Upgrade extends Controller
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$this->max = BaseUserUpgrade::maxNumber() + 1;
|
||||
BaseUserUpgrade::mForm('form');
|
||||
}
|
||||
|
||||
@ -56,6 +57,7 @@ class Upgrade extends Controller
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$this->max = BaseUserUpgrade::maxNumber();
|
||||
BaseUserUpgrade::mForm('form');
|
||||
}
|
||||
|
||||
@ -67,9 +69,7 @@ class Upgrade extends Controller
|
||||
{
|
||||
if ($this->request->isGet()) {
|
||||
$this->prizes = RebateService::PRIZES;
|
||||
if (!isset($vo['number'])) {
|
||||
$vo['number'] = BaseUserUpgrade::mk()->order('number desc')->value('number', -1) + 1;
|
||||
}
|
||||
$vo['number'] = $vo['number'] ?? BaseUserUpgrade::maxNumber();
|
||||
$vo['rebate_rule'] = str2arr($vo['rebate_rule'] ?? '');
|
||||
} else {
|
||||
$vo['utime'] = time();
|
||||
@ -108,7 +108,7 @@ class Upgrade extends Controller
|
||||
$order = 'number asc,utime desc';
|
||||
}
|
||||
foreach (BaseUserUpgrade::mk()->order($order)->select() as $number => $upgrade) {
|
||||
$upgrade->save(['number' => $number]);
|
||||
$upgrade->save(['number' => $number + 1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,5 +11,36 @@ use think\admin\Model;
|
||||
*/
|
||||
class BaseUserUpgrade extends Model
|
||||
{
|
||||
/**
|
||||
* 获取用户等级
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
*/
|
||||
public static function items(): array
|
||||
{
|
||||
return static::mk()->where(['status' => 1])
|
||||
->hidden(['id', 'utime', 'status', 'create_at'])
|
||||
->order('number asc')->select()->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取最大级别数
|
||||
* @return int
|
||||
*/
|
||||
public static function maxNumber(): int
|
||||
{
|
||||
return static::mk()->max('number', 0) + 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化创建时间
|
||||
* @param string $value
|
||||
* @return string
|
||||
*/
|
||||
public function getCreateAtAttr(string $value): string
|
||||
{
|
||||
return format_datetime($value);
|
||||
}
|
||||
}
|
@ -23,7 +23,7 @@
|
||||
<div class="layui-col-xs3 block relative">
|
||||
<b class="color-green label-required-prev">等级序号</b><span class="margin-left-5 color-desc">Serial</span>
|
||||
<select class="layui-select" name="number" lay-filter="number">
|
||||
{for start="0" end="10" name="i"}{if isset($vo.number) and $vo.number eq $i}
|
||||
{for start="1" end="$max" name="i"}{if isset($vo.number) and $vo.number eq $i}
|
||||
<option selected value="{$i}">当前 VIP {$vo.number} 等级</option>
|
||||
{else}
|
||||
<option value="{$i}">设置 VIP {$i} 等级</option>
|
||||
|
Loading…
x
Reference in New Issue
Block a user