mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2025-04-06 03:58:04 +08:00
修改等级模型调用
This commit is contained in:
parent
57fa2645dc
commit
4435dcf61a
@ -3,6 +3,7 @@
|
||||
namespace app\data\controller\api\auth;
|
||||
|
||||
use app\data\controller\api\Auth;
|
||||
use app\data\model\BaseUserUpgrade;
|
||||
use app\data\model\DataUser;
|
||||
use app\data\service\RebateService;
|
||||
use app\data\service\UserAdminService;
|
||||
@ -102,13 +103,7 @@ class Center extends Auth
|
||||
*/
|
||||
public function levels()
|
||||
{
|
||||
$levels = UserUpgradeService::instance()->levels();
|
||||
foreach ($levels as &$level) {
|
||||
$level['prizes'] = [];
|
||||
foreach (str2arr($level['rebate_rule']) as $code) {
|
||||
$level['prizes'][$code] = RebateService::instance()->name($code);
|
||||
}
|
||||
}
|
||||
$levels = BaseUserUpgrade::items();
|
||||
$this->success('获取用户等级', array_values($levels));
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
namespace app\data\controller\base;
|
||||
|
||||
use app\data\model\BaseUserDiscount;
|
||||
use app\data\model\BaseUserUpgrade;
|
||||
use app\data\service\UserUpgradeService;
|
||||
use think\admin\Controller;
|
||||
use think\admin\helper\QueryHelper;
|
||||
@ -64,7 +65,7 @@ class Discount extends Controller
|
||||
}
|
||||
$vo['items'] = json_encode($rule, JSON_UNESCAPED_UNICODE);
|
||||
} else {
|
||||
$this->levels = UserUpgradeService::levels();
|
||||
$this->levels = BaseUserUpgrade::items();
|
||||
if (empty($this->levels)) $this->error('未配置用户等级!');
|
||||
foreach ($vo['items'] ?? [] as $item) {
|
||||
$vo["_level_{$item['level']}"] = $item['discount'];
|
||||
|
@ -4,6 +4,7 @@ namespace app\data\controller\shop;
|
||||
|
||||
use app\data\model\BaseUserDiscount;
|
||||
use app\data\model\BaseUserPayment;
|
||||
use app\data\model\BaseUserUpgrade;
|
||||
use app\data\model\ShopGoods;
|
||||
use app\data\model\ShopGoodsCate;
|
||||
use app\data\model\ShopGoodsItem;
|
||||
@ -138,7 +139,7 @@ class Goods extends Controller
|
||||
$this->marks = ShopGoodsMark::items();
|
||||
$this->cates = ShopGoodsCate::treeTable(true);
|
||||
$this->trucks = ExpressService::instance()->templates();
|
||||
$this->upgrades = UserUpgradeService::instance()->levels();
|
||||
$this->upgrades = BaseUserUpgrade::items();
|
||||
$this->payments = BaseUserPayment::mk()->where(['status' => 1, 'deleted' => 0])->order('sort desc,id desc')->column('type,code,name', 'code');
|
||||
$this->discounts = BaseUserDiscount::mk()->where(['status' => 1, 'deleted' => 0])->order('sort desc,id desc')->column('id,name,items', 'id');
|
||||
// 商品规格处理
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace app\data\controller\user;
|
||||
|
||||
use app\data\model\BaseUserUpgrade;
|
||||
use app\data\model\DataUser;
|
||||
use app\data\service\UserAdminService;
|
||||
use app\data\service\UserUpgradeService;
|
||||
@ -25,7 +26,7 @@ class Admin extends Controller
|
||||
public function index()
|
||||
{
|
||||
// 用户等级分组
|
||||
[$ts, $ls] = [[], UserUpgradeService::instance()->levels()];
|
||||
[$ts, $ls] = [[], BaseUserUpgrade::items()];
|
||||
$ts['ta'] = ['vip' => '', 'name' => '全部用户', 'count' => 0];
|
||||
foreach ($ls as $k => $v) $ts["t{$k}"] = ['vip' => $k, 'name' => $v['name'], 'count' => 0,];
|
||||
$ts['to'] = ['vip' => '', 'name' => '其他用户', 'count' => 0];
|
||||
@ -62,7 +63,7 @@ class Admin extends Controller
|
||||
*/
|
||||
protected function _page_filter(array &$data)
|
||||
{
|
||||
$this->upgrades = UserUpgradeService::instance()->levels();
|
||||
$this->upgrades = BaseUserUpgrade::items();
|
||||
UserAdminService::instance()->buildByUid($data, 'pid1', 'from');
|
||||
}
|
||||
|
||||
@ -139,7 +140,7 @@ class Admin extends Controller
|
||||
public function parent()
|
||||
{
|
||||
if ($this->request->isGet()) {
|
||||
$this->upgrades = UserUpgradeService::instance()->levels();
|
||||
$this->upgrades = BaseUserUpgrade::items();
|
||||
$data = $this->_vali(['uuid.require' => '待操作UID不能为空!']);
|
||||
|
||||
// 排除下级用户
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace app\data\controller\user;
|
||||
|
||||
use app\data\model\BaseUserUpgrade;
|
||||
use app\data\model\DataUser;
|
||||
use app\data\model\DataUserBalance;
|
||||
use app\data\service\UserAdminService;
|
||||
@ -52,7 +53,7 @@ class Balance extends Controller
|
||||
UserAdminService::instance()->buildByUid($data);
|
||||
$uids = array_unique(array_column($data, 'create_by'));
|
||||
$users = SystemUser::mk()->whereIn('id', $uids)->column('username', 'id');
|
||||
$this->upgrades = UserUpgradeService::instance()->levels();
|
||||
$this->upgrades = BaseUserUpgrade::items();
|
||||
foreach ($data as &$vo) {
|
||||
$vo['upgradeinfo'] = $this->upgrades[$vo['upgrade']] ?? [];
|
||||
$vo['create_byname'] = $users[$vo['create_by']] ?? '';
|
||||
@ -84,7 +85,7 @@ class Balance extends Controller
|
||||
$data['code'] = CodeExtend::uniqidDate('20', 'B');
|
||||
}
|
||||
if ($this->request->isGet()) {
|
||||
$this->upgrades = UserUpgradeService::instance()->levels();
|
||||
$this->upgrades = BaseUserUpgrade::items();
|
||||
}
|
||||
if ($this->request->isPost()) {
|
||||
$data['create_by'] = AdminService::instance()->getUserId();
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace app\data\controller\user;
|
||||
|
||||
use app\data\model\BaseUserUpgrade;
|
||||
use app\data\model\DataUser;
|
||||
use app\data\model\DataUserRebate;
|
||||
use app\data\model\ShopOrderItem;
|
||||
@ -83,7 +84,7 @@ class Rebate extends Controller
|
||||
$this->title = '用户返利配置';
|
||||
if ($this->request->isGet()) {
|
||||
$this->data = sysdata($this->skey);
|
||||
$this->levels = UserUpgradeService::instance()->levels();
|
||||
$this->levels = BaseUserUpgrade::items();
|
||||
$this->fetch();
|
||||
} else {
|
||||
sysdata($this->skey, $this->request->post());
|
||||
|
@ -15,15 +15,12 @@ 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();
|
||||
->order('number asc')->column('*', 'number');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -17,16 +17,6 @@ use think\admin\Service;
|
||||
class UserUpgradeService extends Service
|
||||
{
|
||||
|
||||
/**
|
||||
* 获取用户等级数据
|
||||
* @return array
|
||||
*/
|
||||
public static function levels(): array
|
||||
{
|
||||
$model = BaseUserUpgrade::mk()->where(['status' => 1]);
|
||||
return $model->order('number asc')->column('*', 'number');
|
||||
}
|
||||
|
||||
/**
|
||||
* 尝试绑定上级代理
|
||||
* @param integer $uuid 用户UID
|
||||
@ -86,7 +76,7 @@ class UserUpgradeService extends Service
|
||||
$user = DataUser::mk()->where(['id' => $uuid])->find();
|
||||
if (empty($user)) return true;
|
||||
// 初始化等级参数
|
||||
$levels = $this->levels();
|
||||
$levels = BaseUserUpgrade::items();
|
||||
[$vipName, $vipCode, $vipTeam] = [$levels[0]['name'] ?? '普通用户', 0, []];
|
||||
// 统计用户数据
|
||||
foreach ($levels as $key => $level) if ($level['upgrade_team'] === 1) $vipTeam[] = $key;
|
||||
|
Loading…
x
Reference in New Issue
Block a user