mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2025-04-06 03:58:04 +08:00
修改用户等级计数规则
This commit is contained in:
parent
5e9bd833df
commit
009d62d6dd
@ -11,7 +11,7 @@
|
||||
Target Server Version : 80018
|
||||
File Encoding : 65001
|
||||
|
||||
Date: 07/04/2021 14:40:56
|
||||
Date: 08/04/2021 10:07:25
|
||||
*/
|
||||
|
||||
SET NAMES utf8mb4;
|
||||
@ -152,6 +152,7 @@ CREATE TABLE `base_user_upgrade` (
|
||||
`number` tinyint(2) NULL DEFAULT 0 COMMENT '用户级别序号',
|
||||
`rebate_rule` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '用户奖利规则',
|
||||
`upgrade_type` tinyint(1) NULL DEFAULT 0 COMMENT '会员升级规则(0单个,1同时)',
|
||||
`upgrade_team` tinyint(1) NULL DEFAULT 1 COMMENT '团队人数统计(0不计,1累计)',
|
||||
`goods_vip_status` tinyint(1) NULL DEFAULT 0 COMMENT '入会礼包状态',
|
||||
`order_amount_status` tinyint(1) NULL DEFAULT 0 COMMENT '订单金额状态',
|
||||
`order_amount_number` decimal(20, 2) NULL DEFAULT 0.00 COMMENT '订单金额累计',
|
||||
|
@ -74,13 +74,16 @@ class UserUpgradeService extends Service
|
||||
$user = $this->app->db->name('DataUser')->where(['id' => $uid])->find();
|
||||
if (empty($user)) return true;
|
||||
// 开始处理等级
|
||||
[$vipName, $vipCode] = ['普通用户', 0];
|
||||
// 统计历史数据
|
||||
$query = $this->app->db->name('BaseUserUpgrade')->where(['number' => 0]);
|
||||
[$vipName, $vipCode] = [$query->value('name') ?: '普通用户', 0];
|
||||
// 统计个人订单金额
|
||||
$orderAmount = $this->app->db->name('ShopOrder')->where("uid={$uid} and status>=4")->sum('amount_total');
|
||||
$teamsDirect = $this->app->db->name('DataUser')->where(['pid1' => $uid])->whereRaw('vip_code>0')->count();
|
||||
$teamsIndirect = $this->app->db->name('DataUser')->where(['pid2' => $uid])->whereRaw('vip_code>0')->count();
|
||||
$teamsUsers = $this->app->db->name('DataUser')->where(['pid1|pid2' => $uid])->whereRaw('vip_code>0')->count();
|
||||
// 计算用户等级
|
||||
// 统计下属团队人数
|
||||
$vips = $this->app->db->name('BaseUserUpgrade')->where(['status' => 1, 'upgrade_team' => 1])->column('number');
|
||||
$teamsDirect = $this->app->db->name('DataUser')->where(['pid1' => $uid])->whereIn('vip_code', $vips)->count();
|
||||
$teamsIndirect = $this->app->db->name('DataUser')->where(['pid2' => $uid])->whereIn('vip_code', $vips)->count();
|
||||
$teamsUsers = $this->app->db->name('DataUser')->where(['pid1|pid2' => $uid])->whereIn('vip_code', $vips)->count();
|
||||
// 动态计算用户等级
|
||||
foreach ($this->app->db->name('BaseUserUpgrade')->where(['status' => 1])->order('number desc')->cursor() as $item) {
|
||||
$l1 = empty($item['goods_vip_status']) || $user['buy_vip_entry'] > 0;
|
||||
$l2 = empty($item['teams_users_status']) || $item['teams_users_number'] <= $teamsUsers;
|
||||
|
@ -5,7 +5,7 @@
|
||||
<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">
|
||||
<span class="color-green label-required-prev">等级序号</span><span class="margin-left-5 color-desc">Number</span>
|
||||
<b class="color-green label-required-prev">等级序号</b><span class="margin-left-5 color-desc">Serial</span>
|
||||
<select class="layui-select" name="number">
|
||||
{for start="0" end="10" name="i"}{if isset($vo.number) and $vo.number eq $i}
|
||||
<option selected value="{$i}">当前 VIP {$vo.number} 等级</option>
|
||||
@ -15,24 +15,42 @@
|
||||
</select>
|
||||
</div>
|
||||
<label class="layui-col-xs9 block relative">
|
||||
<span class="color-green label-required-prev">等级名称</span><span class="margin-left-5 color-desc">Name</span>
|
||||
<b class="color-green label-required-prev">等级名称</b><span class="margin-left-5 color-desc">Name</span>
|
||||
<input class="layui-input" name="name" placeholder="请输入等级名称" required value="{$vo.name|default=''}">
|
||||
</label>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<fieldset class="layui-form-item">
|
||||
<legend><span class="layui-badge layui-bg-cyan">升级规则</span></legend>
|
||||
<div class="layui-form-item">
|
||||
{php}$vo['upgrade_type'] = $vo['upgrade_type'] ?? 1;{/php}
|
||||
{foreach [1=>'达成所有条件',0=>'达成任何条件'] as $k => $v}
|
||||
{if isset($vo.upgrade_type) and $vo.upgrade_type eq $k}
|
||||
<label class="think-radio"><input checked lay-ignore name="upgrade_type" type="radio" value="{$k}"> {$v}</label>
|
||||
{else}
|
||||
<label class="think-radio"><input lay-ignore name="upgrade_type" type="radio" value="{$k}"> {$v}</label>
|
||||
{/if}{/foreach}
|
||||
<div class="layui-row layui-col-space15">
|
||||
<div class="layui-col-xs6">
|
||||
<fieldset class="layui-form-item">
|
||||
<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}
|
||||
{foreach [1=>'达成所有升级条件',0=>'达成任何升级条件'] as $k => $v}
|
||||
{if isset($vo.upgrade_type) and $vo.upgrade_type eq $k}
|
||||
<label class="think-radio"><input checked lay-ignore name="upgrade_type" type="radio" value="{$k}"> {$v}</label>
|
||||
{else}
|
||||
<label class="think-radio"><input lay-ignore name="upgrade_type" type="radio" value="{$k}"> {$v}</label>
|
||||
{/if}{/foreach}
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
</fieldset>
|
||||
<div class="layui-col-xs6">
|
||||
<fieldset class="layui-form-item">
|
||||
<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}
|
||||
{foreach [1=>'参与团队人数统计',0=>'不参与团队人数统计'] as $k => $v}
|
||||
{if isset($vo.upgrade_team) and $vo.upgrade_team eq $k}
|
||||
<label class="think-radio"><input checked lay-ignore name="upgrade_team" type="radio" value="{$k}"> {$v}</label>
|
||||
{else}
|
||||
<label class="think-radio"><input lay-ignore name="upgrade_team" type="radio" value="{$k}"> {$v}</label>
|
||||
{/if}{/foreach}
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<fieldset class="layui-form-item">
|
||||
<legend><span class="layui-badge layui-bg-cyan">升级条件</span></legend>
|
||||
|
@ -26,6 +26,7 @@
|
||||
<th class="text-left nowrap">用户等级</th>
|
||||
<th class="text-left nowrap">升级规则</th>
|
||||
<th class="text-center nowrap">入会礼包</th>
|
||||
<th class="text-center nowrap">团队计数</th>
|
||||
<th class="text-center nowrap">团队总数</th>
|
||||
<th class="text-center nowrap">直属团队</th>
|
||||
<th class="text-center nowrap">间接团队</th>
|
||||
@ -45,6 +46,7 @@
|
||||
<td class="text-left nowrap"> [ <span class="color-blue">{$vo.number}</span> ] {$vo.name|default=''}</td>
|
||||
<td class="text-left nowrap">{if $vo.upgrade_type eq 1}<span class="color-green">全部完成</span>{else}<span class="color-blue">任何条件</span>{/if}</td>
|
||||
<td class="text-center nowrap">{if $vo.goods_vip_status>0}<b class="layui-icon layui-icon-ok-circle color-green"></b> {else} - {/if}</td>
|
||||
<td class="text-center nowrap">{if $vo.upgrade_team>0}<b class="layui-icon layui-icon-ok-circle color-green"></b> {else} - {/if}</td>
|
||||
<td class="text-center nowrap">{if $vo.teams_users_status>0} <b class="color-green">{$vo.teams_users_number}</b> 人 {else} - {/if}</td>
|
||||
<td class="text-center nowrap">{if $vo.teams_direct_status>0} <b class="color-green">{$vo.teams_direct_number}</b> 人 {else} - {/if}</td>
|
||||
<td class="text-center nowrap">{if $vo.teams_indirect_status>0} <b class="color-green">{$vo.teams_indirect_number}</b> 人 {else} - {/if}</td>
|
||||
|
@ -49,9 +49,9 @@
|
||||
<select class="layui-select" lay-filter="upgrade" name="upgrade">
|
||||
<option value="0">-- 不升级 --</option>
|
||||
{foreach $upgrades as $upgrade}{if isset($vo.upgrade) and $vo.upgrade eq $upgrade.number}
|
||||
<option selected value="{$upgrade.number|default=0}">升级到 [ {$upgrade.number|default='0'} ] {$upgrade.name|default=''}</option>
|
||||
<option selected value="{$upgrade.number|default=0}">升级到 [ VIP{$upgrade.number|default='0'} ] {$upgrade.name|default=''}</option>
|
||||
{else}
|
||||
<option value="{$upgrade.number|default=0}">升级到 [ {$upgrade.number|default='0'} ] {$upgrade.name|default=''}</option>
|
||||
<option value="{$upgrade.number|default=0}">升级到 [ VIP{$upgrade.number|default='0'} ] {$upgrade.name|default=''}</option>
|
||||
{/if}{/foreach}
|
||||
</select>
|
||||
<span class="help-block">请选择目标升级等级,当用户低于当前等级时会进行用户升级操作</span>
|
||||
|
2
vendor/services.php
vendored
2
vendor/services.php
vendored
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
// This file is automatically generated at:2021-04-07 15:26:53
|
||||
// This file is automatically generated at:2021-04-08 10:10:24
|
||||
declare (strict_types = 1);
|
||||
return array (
|
||||
0 => 'think\\admin\\Library',
|
||||
|
Loading…
x
Reference in New Issue
Block a user