Files
addons
app_download_files
extend
hyhproject
admin
app
common
conf
controller
Alipays.php
Appport.php
Areas.php
Articles.php
Auth.php
Base.php
Brands.php
Carts.php
Cashconfigs.php
Cashdraws.php
Chain3.php
Chain3base.php
Ect.php
Ectwallets.php
Error.php
Favorites.php
Goods.php
Goodsappraises.php
Goodscats.php
Goodsconsult.php
Index.php
Invoices.php
Juhui.php
Logmoneys.php
Messages.php
News.php
Note.php
Ordercomplains.php
Orderrefunds.php
Orders.php
Position.php
Qlgpay.php
Shoporders.php
Shopping.php
Shops.php
Switchs.php
Tag.php
Tags.php
Tmp.php
TradeRule.php
Unionpays.php
UserLevel.php
Useraddress.php
Users.php
Userscores.php
Uservouchers.php
Wallets.php
Weixinpays.php
model
validate
common
home
home2
mobile2
wechat2
.htaccess
command.php
mobile
oss
static
thinkphp
upload
vendor
wxtmp
.gitignore
.htaccess
.user.ini
404.html
H5436787D.wgt
admin.php
app-release.apk
app_download.html
cash.lock
demo.php
get_version.php
get_version_new.php
index.html
index.php
reg.lock
robots.txt
qlg.tsgz.moe/hyhproject/app/controller/UserLevel.php
2020-12-06 22:57:39 +08:00

99 lines
3.0 KiB
PHP
Executable File

<?php
namespace wstmart\app\controller;
use think\Db;
use wstmart\app\model\Users;
use wstmart\common\model\UserLevel as UL;
use wstmart\common\model\UserTrees as UT;
use think\Collection;
/**
* ============================================================================
* 用户控制器
*/
class UserLevel extends Base
{
protected $beforeActionList = [
'checkAuth' => ['except'=>'']// 访问这些except下的方法不需要执行前置操作
];
/**
* index
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @author 倪苍华 <canghua.cc@gmail.com>
* Date 2019/9/10 10:37
*/
public function index()
{
$userId = get_my_id();
$User = UT::realGetMyChildren($userId, [$userId]);
return $User;
}
public function stats()
{
$userId = get_my_id();
$goodsType = 3;
$sm = Model('common/SysSummary');
$sysData= $sm->getInfo('toPaySlow');
$helpSaleNum = Db::name('orders')->where(compact('userId','goodsType'))->where('payable', '>',0)->sum('payable');
$zgTimes = Db::name('orders')->where(compact('userId','goodsType'))->count();
$zgTimes += 1;
$helpSaleNum += 1;
$helpSaleNum = number_format($helpSaleNum, 2, '.', '');
return [
'zgTimes'=>$zgTimes,
'myZgA'=>$helpSaleNum,
'zgAmounts'=>$sysData['toPaySlow'],
];
}
public function stats2()
{
$userId = get_my_id();
$goodsType = 3;
return [
'zgAmounts'=>Db::name('orders')->where(compact('userId','goodsType'))->sum('helpGetCount'),
];
}
/**
* TreeList
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* @author 倪苍华 <canghua.cc@gmail.com>
* Date 2019/9/10 11:18
*/
public function TreeList()
{
$userId = get_my_id();
$treeArr = [];
$goodsType = 3;
$max = Db::name('orders')->where(compact('userId','goodsType'))->max('helpUserLevel');
$newLevel = 0;
do {
$newLevel++;
$userId = UT::getUpperId($userId);// 找到我的层级
if ($userId == null) $userId = 1;// 上级uid
if (UT::checkUserCanDisplay($userId)) {// 如果有,则使用上级信息
if($newLevel>10){
$treeArr[$newLevel]['level'] = "".$newLevel."";
}else{
$treeArr[$newLevel]['level'] = UT::$level[$newLevel];
}
$treeArr[$newLevel]['level_id'] = $newLevel;
$treeArr[$newLevel]['userId'] = $userId;
$treeArr[$newLevel]['userName'] = '';
}else{$newLevel--;}
} while (($newLevel <= $max) && ($newLevel <= (int)dataConf("helpSaleMaxLevel")));
// pd($treeArr);
return $treeArr;
}
}