修改用户等级

This commit is contained in:
邹景立 2021-03-29 17:26:12 +08:00
parent 80e9146e1d
commit 05735e2cac
2 changed files with 7 additions and 9 deletions

View File

@ -78,10 +78,8 @@ class Upgrade extends Controller
{
if ($this->request->isGet()) {
$this->prizes = RebateService::PRIZES;
$vo['number'] = $vo['number'] ?? $this->app->db->name($this->table)->max('number') + 1;
$vo['rebate_rule'] = str2arr($vo['rebate_rule'] ?? '');
if (empty($vo['number'])) {
$vo['number'] = $this->app->db->name($this->table)->max('number') + 1;
}
} else {
$vo['utime'] = time();
$vo['rebate_rule'] = arr2str($vo['rebate_rule'] ?? []);
@ -99,7 +97,7 @@ class Upgrade extends Controller
// 检查升级条件配置
$count = 0;
foreach ($vo as $k => $v) if (is_numeric(stripos($k, '_status'))) $count += $v;
if (empty($count)) $this->error('升级条件不能为空!');
if (empty($count) && $vo['number'] > 0) $this->error('升级条件不能为空!');
}
}
@ -112,9 +110,9 @@ class Upgrade extends Controller
{
if ($state) {
$order = 'number asc,utime desc';
if (input('old_number', 100) < input('number', '0')) $order = 'number asc,utime asc';
if (input('old_number', 100) <= input('number', 0)) $order = 'number asc,utime asc';
foreach ($this->app->db->name($this->table)->order($order)->cursor() as $k => $vo) {
$this->app->db->name($this->table)->where(['id' => $vo['id']])->update(['number' => $k + 1]);
$this->app->db->name($this->table)->where(['id' => $vo['id']])->update(['number' => $k]);
}
}
}

View File

@ -7,7 +7,7 @@
<div class="layui-col-xs3 block relative">
<span class="color-green label-required-prev">等级序号</span><span class="margin-left-5 color-desc">Number</span>
<select class="layui-select" name="number">
{for start="1" end="10" name="i"}{if isset($vo.number) and $vo.number eq $i}
{for start="0" end="10" 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>
@ -111,8 +111,8 @@
</fieldset>
<div class="hr-line-dashed"></div>
{notempty name='vo.id'}<input name='id' type='hidden' value='{$vo.id}'>{/notempty}
{notempty name='vo.number'}<input name='old_number' type='hidden' value='{$vo.number}'>{/notempty}
{if isset($vo.id)}<input name='id' type='hidden' value='{$vo.id}'>{/if}
{if isset($vo.number)}<input name='old_number' type='hidden' value='{$vo.number}'>{/if}
<div class="layui-form-item text-center">
<button class="layui-btn" type='submit'>保存数据</button>