|
|
@@ -1,11 +1,14 @@
|
|
|
<?php
|
|
|
+
|
|
|
namespace app\admin\controller\user;
|
|
|
|
|
|
//use app\admin\model\ActiveLog;
|
|
|
//use app\admin\model\ActiveSet;
|
|
|
//use app\admin\model\CoinLog;
|
|
|
+use app\admin\logic\UserLogic;
|
|
|
use app\common\model\MoneyLog;
|
|
|
use app\common\model\ScoreLog;
|
|
|
+
|
|
|
//use app\admin\model\UpgradeLog;
|
|
|
use app\common\model\ScoreLogModel;
|
|
|
use app\common\model\User as UserModel;
|
|
|
@@ -25,7 +28,7 @@ use think\facade\Db;
|
|
|
class User extends AdminController
|
|
|
{
|
|
|
|
|
|
- public function __construct (App $app)
|
|
|
+ public function __construct(App $app)
|
|
|
{
|
|
|
parent::__construct($app);
|
|
|
$this->model = new UserModel();
|
|
|
@@ -40,7 +43,7 @@ class User extends AdminController
|
|
|
* @throws \think\db\exception\DbException
|
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
|
*/
|
|
|
- public function index ()
|
|
|
+ public function index()
|
|
|
{
|
|
|
if ($this->request->isAjax()) {
|
|
|
if (input('selectFields')) {
|
|
|
@@ -51,27 +54,9 @@ class User extends AdminController
|
|
|
if (($pid = $this->request->param('pid')) !== false && $pid)
|
|
|
$where[] = ['pid', '=', $this->request->param('pid', '')];
|
|
|
|
|
|
-
|
|
|
- $count = $this->model
|
|
|
- ->withJoin('userData', 'INNER')
|
|
|
- ->where($where)
|
|
|
- ->where($this->user_map)
|
|
|
- ->count();
|
|
|
- $list = $this->model
|
|
|
- ->withJoin('userData', 'INNER')
|
|
|
- ->where($where)
|
|
|
- ->where($this->user_map)
|
|
|
- ->page($page, $limit)
|
|
|
- ->order($this->sort)
|
|
|
- ->select();
|
|
|
-
|
|
|
- $data = [
|
|
|
- 'code' => 0,
|
|
|
- 'msg' => Db::getLastSql(),
|
|
|
- 'count' => $count,
|
|
|
- 'data' => $list,
|
|
|
- ];
|
|
|
- return json($data);
|
|
|
+ $userLogic = new UserLogic();
|
|
|
+ $data = $userLogic->getList($page, $limit, $where, $this->sort, $this->user_map);
|
|
|
+ return $data;
|
|
|
}
|
|
|
return $this->fetch();
|
|
|
}
|
|
|
@@ -80,7 +65,7 @@ class User extends AdminController
|
|
|
* 禁用用户
|
|
|
* @param $id
|
|
|
*/
|
|
|
- public function forbid ($id)
|
|
|
+ public function forbid($id)
|
|
|
{
|
|
|
$user = $this->model->findOrEmpty($id);
|
|
|
empty($user) && $this->error('数据不存在');
|
|
|
@@ -95,7 +80,7 @@ class User extends AdminController
|
|
|
* 启用用户
|
|
|
* @param $id
|
|
|
*/
|
|
|
- public function enable ($id)
|
|
|
+ public function enable($id)
|
|
|
{
|
|
|
$user = $this->model->findOrEmpty($id);
|
|
|
empty($user) && $this->error('数据不存在');
|
|
|
@@ -115,9 +100,9 @@ class User extends AdminController
|
|
|
* @throws \think\db\exception\DbException
|
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
|
*/
|
|
|
- public function details (Request $request)
|
|
|
+ public function details(Request $request)
|
|
|
{
|
|
|
- $id = $request->param('id');
|
|
|
+ $id = $request->param('id');
|
|
|
$info = $this->model
|
|
|
->withJoin('userData', 'INNER')
|
|
|
->where('id', $id)
|
|
|
@@ -130,32 +115,29 @@ class User extends AdminController
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
/**
|
|
|
* 添加用户
|
|
|
* @return mixed
|
|
|
*/
|
|
|
- public function add ()
|
|
|
+ public function add()
|
|
|
{
|
|
|
if ($this->request->isAjax()) {
|
|
|
- $post = $this->request->post();
|
|
|
+ $post = $this->request->post();
|
|
|
$mobile = $this->model->where('mobile', $post['mobile'])->value('id');
|
|
|
$mobile && $this->error('该手机号码已被注册');
|
|
|
$invite = $this->model->where('code|px_code', $post['code'])->value('id');
|
|
|
!$invite && $this->error('邀请人不存在');
|
|
|
$this->model->startTrans();
|
|
|
try {
|
|
|
- $insert['mobile'] = $post['mobile'];
|
|
|
- $insert['reg_ip'] = $this->request->ip();
|
|
|
- $insert['avatar'] = 'http://images.yxj.hongyun63.com/user/default_avatar.jpg';
|
|
|
- $insert['code'] = create_invite_code();
|
|
|
- $insert['px_code'] = create_invite_code();
|
|
|
+ $insert['mobile'] = $post['mobile'];
|
|
|
+ $insert['reg_ip'] = $this->request->ip();
|
|
|
+ $insert['avatar'] = 'http://images.yxj.hongyun63.com/user/default_avatar.jpg';
|
|
|
+ $insert['code'] = create_invite_code();
|
|
|
+ $insert['px_code'] = create_invite_code();
|
|
|
$insert['user_type'] = 2;
|
|
|
- $rz_money = 1.5 + rand(0, 30) / 100;
|
|
|
+ $rz_money = 1.5 + rand(0, 30) / 100;
|
|
|
$this->model->save($insert);
|
|
|
- $uid = $this->model->id;
|
|
|
+ $uid = $this->model->id;
|
|
|
$user_data = new UserData();
|
|
|
$user_data->save(['uid' => $uid, 'rz_money' => $rz_money]); // 保存用户关联信息
|
|
|
$this->bindRelation($post['code'], $uid); // 绑定关系
|
|
|
@@ -173,7 +155,7 @@ class User extends AdminController
|
|
|
* 邀请页面
|
|
|
* @return mixed
|
|
|
*/
|
|
|
- public function invite ()
|
|
|
+ public function invite()
|
|
|
{
|
|
|
$admin = session('admin');
|
|
|
!$admin['user_id'] && $this->error('没有该权限');
|
|
|
@@ -187,7 +169,7 @@ class User extends AdminController
|
|
|
* 兜底
|
|
|
* @return mixed
|
|
|
*/
|
|
|
- public function doudi ()
|
|
|
+ public function doudi()
|
|
|
{
|
|
|
return 22;
|
|
|
if ($this->request->isAjax()) {
|
|
|
@@ -195,16 +177,16 @@ class User extends AdminController
|
|
|
$user = $this->model->findOrEmpty(['id' => $post['uid']]);
|
|
|
empty($user) && $this->error('用户不存在');
|
|
|
$post['active'] <= 0 && $this->error('参数错误');
|
|
|
- $path = trim_string($user['path'] . ',' . $user['id']);
|
|
|
+ $path = trim_string($user['path'] . ',' . $user['id']);
|
|
|
$path_explode = explode(',', $path);
|
|
|
- $insert = [];
|
|
|
+ $insert = [];
|
|
|
foreach ($path_explode as $value) {
|
|
|
$insert[] = [
|
|
|
- 'active' => $post['active'],
|
|
|
- 'uid' => $value,
|
|
|
- 'ip' => $this->request->ip(),
|
|
|
+ 'active' => $post['active'],
|
|
|
+ 'uid' => $value,
|
|
|
+ 'ip' => $this->request->ip(),
|
|
|
'user_admin' => session('?admin.username') ? session('admin.username') : '',
|
|
|
- 'from_uid' => $post['uid'],
|
|
|
+ 'from_uid' => $post['uid'],
|
|
|
'failure_at' => date('Y-m-d H:i:s', time() + 86400 * 30),
|
|
|
];
|
|
|
}
|
|
|
@@ -226,28 +208,28 @@ class User extends AdminController
|
|
|
* 增加余额
|
|
|
* @return mixed
|
|
|
*/
|
|
|
- public function editmoney ()
|
|
|
+ public function editmoney()
|
|
|
{
|
|
|
if ($this->request->isPost()) {
|
|
|
|
|
|
- $post = $this->request->post();
|
|
|
- $user = $this->model->findOrEmpty(['id' => $post['uid']]);
|
|
|
+ $post = $this->request->post();
|
|
|
+ $user = $this->model->findOrEmpty(['id' => $post['uid']]);
|
|
|
$money = $post['money'];
|
|
|
- $type = $post['type'];
|
|
|
+ $type = $post['type'];
|
|
|
empty($user) && $this->error('用户不存在');
|
|
|
|
|
|
$this->model->startTrans();
|
|
|
try {
|
|
|
- if ($type == 'more'){
|
|
|
+ if ($type == 'more') {
|
|
|
edit_user_money(7, $post['uid'], $money);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
edit_user_money(8, $post['uid'], $money);
|
|
|
}
|
|
|
|
|
|
$this->model->commit();
|
|
|
} catch (\Exception $e) {
|
|
|
$this->model->rollback();
|
|
|
- $this->error('失败'.$e->getMessage());
|
|
|
+ $this->error('失败' . $e->getMessage());
|
|
|
}
|
|
|
$this->success('成功');
|
|
|
}
|
|
|
@@ -259,14 +241,14 @@ class User extends AdminController
|
|
|
* 等级设置
|
|
|
* @return mixed
|
|
|
*/
|
|
|
- public function levelset ()
|
|
|
+ public function levelset()
|
|
|
{
|
|
|
|
|
|
if ($this->request->isPost()) {
|
|
|
|
|
|
- $post = $this->request->post();
|
|
|
+ $post = $this->request->post();
|
|
|
$level = $post['level'];
|
|
|
- if ($level > 4){
|
|
|
+ if ($level > 4) {
|
|
|
$this->error('最高等级4级');
|
|
|
}
|
|
|
|
|
|
@@ -275,16 +257,16 @@ class User extends AdminController
|
|
|
empty($user) && $this->error('用户不存在');
|
|
|
|
|
|
$level_type = 1;
|
|
|
- if ($level > $user['level']){
|
|
|
+ if ($level > $user['level']) {
|
|
|
$level_type = 2;
|
|
|
}
|
|
|
$this->model->startTrans();
|
|
|
try {
|
|
|
- $this->model->where('id', $post['id'])->save(['level'=>$level, 'level_type'=>$level_type]);
|
|
|
+ $this->model->where('id', $post['id'])->save(['level' => $level, 'level_type' => $level_type]);
|
|
|
$this->model->commit();
|
|
|
} catch (\Exception $e) {
|
|
|
$this->model->rollback();
|
|
|
- $this->error('失败'.$e->getMessage());
|
|
|
+ $this->error('失败' . $e->getMessage());
|
|
|
}
|
|
|
$this->success('成功');
|
|
|
}
|
|
|
@@ -301,7 +283,7 @@ class User extends AdminController
|
|
|
* 末尾奖励
|
|
|
* @return mixed
|
|
|
*/
|
|
|
- public function moweiscore ()
|
|
|
+ public function moweiscore()
|
|
|
{
|
|
|
if ($this->request->isPost()) {
|
|
|
$post = $this->request->post();
|
|
|
@@ -316,7 +298,7 @@ class User extends AdminController
|
|
|
$this->model->commit();
|
|
|
} catch (\Exception $e) {
|
|
|
$this->model->rollback();
|
|
|
- $this->error('失败'.$e->getMessage());
|
|
|
+ $this->error('失败' . $e->getMessage());
|
|
|
}
|
|
|
$this->success('成功');
|
|
|
}
|
|
|
@@ -325,7 +307,6 @@ class User extends AdminController
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 余额明细
|
|
|
* @param MoneyLog $model
|
|
|
@@ -334,19 +315,19 @@ class User extends AdminController
|
|
|
* @throws \think\db\exception\DbException
|
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
|
*/
|
|
|
- public function moneyLog (UserMoneyModel $model)
|
|
|
+ public function moneyLog(UserMoneyModel $model)
|
|
|
{
|
|
|
if ($this->request->isAjax()) {
|
|
|
if (input('selectFields')) {
|
|
|
return $this->selectList();
|
|
|
}
|
|
|
list($page, $limit, $where) = $this->buildTableParames();
|
|
|
- $where[] = ['uid', '=', $this->request->param('id', '')];
|
|
|
- $count = $model
|
|
|
+ $where[] = ['uid', '=', $this->request->param('id', '')];
|
|
|
+ $count = $model
|
|
|
->where($where)
|
|
|
->count();
|
|
|
$type_conf = config('type.money');
|
|
|
- $list = $model
|
|
|
+ $list = $model
|
|
|
->where($where)
|
|
|
->withAttr('type', function ($value, $data) use ($type_conf) {
|
|
|
return $type_conf[$value];
|
|
|
@@ -359,11 +340,11 @@ class User extends AdminController
|
|
|
->page($page, $limit)
|
|
|
->order($this->sort)
|
|
|
->select();
|
|
|
- $data = [
|
|
|
- 'code' => 0,
|
|
|
- 'msg' => '',
|
|
|
+ $data = [
|
|
|
+ 'code' => 0,
|
|
|
+ 'msg' => '',
|
|
|
'count' => $count,
|
|
|
- 'data' => $list,
|
|
|
+ 'data' => $list,
|
|
|
];
|
|
|
return json($data);
|
|
|
}
|
|
|
@@ -380,19 +361,19 @@ class User extends AdminController
|
|
|
* @throws \think\db\exception\DbException
|
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
|
*/
|
|
|
- public function lookpidlevel (Request $request)
|
|
|
+ public function lookpidlevel(Request $request)
|
|
|
{
|
|
|
if ($this->request->isAjax()) {
|
|
|
|
|
|
// if (($pid = $this->request->param('pid')) !== false && $pid)
|
|
|
// $where[] = ['pid', '=', $this->request->param('pid', '')];
|
|
|
- $id = $this->request->param('id');
|
|
|
+ $id = $this->request->param('id');
|
|
|
$path = Db::name('user')->where('id', $id)->value('path');
|
|
|
- $arr = explode(',', $path);
|
|
|
+ $arr = explode(',', $path);
|
|
|
|
|
|
- $ids = $arr;
|
|
|
- $ids = implode(',',$ids);
|
|
|
- $order= 'field(id,'.$ids.')';
|
|
|
+ $ids = $arr;
|
|
|
+ $ids = implode(',', $ids);
|
|
|
+ $order = 'field(id,' . $ids . ')';
|
|
|
// return User::whereIn('id',$ids)->order(Db::raw($order))->select();
|
|
|
|
|
|
$where = array();
|
|
|
@@ -403,17 +384,17 @@ class User extends AdminController
|
|
|
->withJoin('userData', 'INNER')
|
|
|
->where($where)
|
|
|
->count();
|
|
|
- $list = $this->model
|
|
|
+ $list = $this->model
|
|
|
->withJoin('userData', 'INNER')
|
|
|
->where($where)
|
|
|
->order(Db::raw($order))
|
|
|
->select();
|
|
|
|
|
|
$data = [
|
|
|
- 'code' => 0,
|
|
|
- 'msg' => '成功',
|
|
|
+ 'code' => 0,
|
|
|
+ 'msg' => '成功',
|
|
|
'count' => $count,
|
|
|
- 'data' => $list,
|
|
|
+ 'data' => $list,
|
|
|
];
|
|
|
return json($data);
|
|
|
}
|
|
|
@@ -428,19 +409,19 @@ class User extends AdminController
|
|
|
* @throws \think\db\exception\DbException
|
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
|
*/
|
|
|
- public function coinLog (CoinLog $model)
|
|
|
+ public function coinLog(CoinLog $model)
|
|
|
{
|
|
|
if ($this->request->isAjax()) {
|
|
|
if (input('selectFields')) {
|
|
|
return $this->selectList();
|
|
|
}
|
|
|
list($page, $limit, $where) = $this->buildTableParames();
|
|
|
- $where[] = ['uid', '=', $this->request->param('id', '')];
|
|
|
- $count = $model
|
|
|
+ $where[] = ['uid', '=', $this->request->param('id', '')];
|
|
|
+ $count = $model
|
|
|
->where($where)
|
|
|
->count();
|
|
|
$type_conf = config('type.coin');
|
|
|
- $list = $model
|
|
|
+ $list = $model
|
|
|
->where($where)
|
|
|
->withAttr('type', function ($value, $data) use ($type_conf) {
|
|
|
return $type_conf[$value];
|
|
|
@@ -453,11 +434,11 @@ class User extends AdminController
|
|
|
->page($page, $limit)
|
|
|
->order($this->sort)
|
|
|
->select();
|
|
|
- $data = [
|
|
|
- 'code' => 0,
|
|
|
- 'msg' => '',
|
|
|
+ $data = [
|
|
|
+ 'code' => 0,
|
|
|
+ 'msg' => '',
|
|
|
'count' => $count,
|
|
|
- 'data' => $list,
|
|
|
+ 'data' => $list,
|
|
|
];
|
|
|
return json($data);
|
|
|
}
|
|
|
@@ -472,19 +453,19 @@ class User extends AdminController
|
|
|
* @throws \think\db\exception\DbException
|
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
|
*/
|
|
|
- public function scoreLog (ScoreLogModel $model)
|
|
|
+ public function scoreLog(ScoreLogModel $model)
|
|
|
{
|
|
|
if ($this->request->isAjax()) {
|
|
|
if (input('selectFields')) {
|
|
|
return $this->selectList();
|
|
|
}
|
|
|
list($page, $limit, $where) = $this->buildTableParames();
|
|
|
- $where[] = ['uid', '=', $this->request->param('id', '')];
|
|
|
- $count = $model
|
|
|
+ $where[] = ['uid', '=', $this->request->param('id', '')];
|
|
|
+ $count = $model
|
|
|
->where($where)
|
|
|
->count();
|
|
|
$type_conf = config('type.score');
|
|
|
- $list = $model
|
|
|
+ $list = $model
|
|
|
->where($where)
|
|
|
->withAttr('type', function ($value, $data) use ($type_conf) {
|
|
|
return $type_conf[$value];
|
|
|
@@ -497,11 +478,11 @@ class User extends AdminController
|
|
|
->page($page, $limit)
|
|
|
->order($this->sort)
|
|
|
->select();
|
|
|
- $data = [
|
|
|
- 'code' => 0,
|
|
|
- 'msg' => '',
|
|
|
+ $data = [
|
|
|
+ 'code' => 0,
|
|
|
+ 'msg' => '',
|
|
|
'count' => $count,
|
|
|
- 'data' => $list,
|
|
|
+ 'data' => $list,
|
|
|
];
|
|
|
return json($data);
|
|
|
}
|
|
|
@@ -516,19 +497,19 @@ class User extends AdminController
|
|
|
* @throws \think\db\exception\DbException
|
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
|
*/
|
|
|
- public function activeLog (ActiveLog $model)
|
|
|
+ public function activeLog(ActiveLog $model)
|
|
|
{
|
|
|
if ($this->request->isAjax()) {
|
|
|
if (input('selectFields')) {
|
|
|
return $this->selectList();
|
|
|
}
|
|
|
list($page, $limit, $where) = $this->buildTableParames();
|
|
|
- $where[] = ['uid', '=', $this->request->param('id', '')];
|
|
|
- $count = $model
|
|
|
+ $where[] = ['uid', '=', $this->request->param('id', '')];
|
|
|
+ $count = $model
|
|
|
->where($where)
|
|
|
->count();
|
|
|
$type_conf = config('type.active');
|
|
|
- $list = $model
|
|
|
+ $list = $model
|
|
|
->where($where)
|
|
|
->withAttr('type', function ($value, $data) use ($type_conf) {
|
|
|
return $type_conf[$value];
|
|
|
@@ -541,11 +522,11 @@ class User extends AdminController
|
|
|
->page($page, $limit)
|
|
|
->order($this->sort)
|
|
|
->select();
|
|
|
- $data = [
|
|
|
- 'code' => 0,
|
|
|
- 'msg' => '',
|
|
|
+ $data = [
|
|
|
+ 'code' => 0,
|
|
|
+ 'msg' => '',
|
|
|
'count' => $count,
|
|
|
- 'data' => $list,
|
|
|
+ 'data' => $list,
|
|
|
];
|
|
|
return json($data);
|
|
|
}
|
|
|
@@ -555,21 +536,21 @@ class User extends AdminController
|
|
|
/**
|
|
|
* @NodeAnotation(title="导出")
|
|
|
*/
|
|
|
- public function export ()
|
|
|
+ public function export()
|
|
|
{
|
|
|
list($page, $limit, $where) = $this->buildTableParames();
|
|
|
$tableName = $this->model->getName();
|
|
|
$tableName = CommonTool::humpToLine(lcfirst($tableName));
|
|
|
- $prefix = config('database.connections.mysql.prefix');
|
|
|
- $dbList = Db::query("show full columns from {$prefix}{$tableName}");
|
|
|
- $header = [];
|
|
|
+ $prefix = config('database.connections.mysql.prefix');
|
|
|
+ $dbList = Db::query("show full columns from {$prefix}{$tableName}");
|
|
|
+ $header = [];
|
|
|
foreach ($dbList as $vo) {
|
|
|
$comment = !empty($vo['Comment']) ? $vo['Comment'] : $vo['Field'];
|
|
|
if (!in_array($vo['Field'], $this->noExportFields)) {
|
|
|
$header[] = [$comment, $vo['Field']];
|
|
|
}
|
|
|
}
|
|
|
- $list = $this->model
|
|
|
+ $list = $this->model
|
|
|
->where($where)
|
|
|
->withJoin('userData', 'INNER')
|
|
|
->where($where)
|
|
|
@@ -582,7 +563,7 @@ class User extends AdminController
|
|
|
}
|
|
|
|
|
|
|
|
|
- public function teamincome (Request $request)
|
|
|
+ public function teamincome(Request $request)
|
|
|
{
|
|
|
if ($this->request->isAjax()) {
|
|
|
|
|
|
@@ -590,14 +571,14 @@ class User extends AdminController
|
|
|
// $where[] = ['pid', '=', $this->request->param('pid', '')];
|
|
|
$id = $this->request->param('id');
|
|
|
// $path = Db::name('user')->where('id', $id)->value('path');
|
|
|
- $where = array();
|
|
|
+ $where = array();
|
|
|
$where[] = ['team_id', '=', $id];
|
|
|
$where[] = ['type', '=', 5];
|
|
|
- $count = Db::name('userteam_log')
|
|
|
+ $count = Db::name('userteam_log')
|
|
|
// ->withJoin('user', 'INNER')
|
|
|
->where($where)
|
|
|
->count();
|
|
|
- $list = Db::name('userteam_log')
|
|
|
+ $list = Db::name('userteam_log')
|
|
|
// ->withJoin('user', 'INNER')
|
|
|
->where($where)
|
|
|
->order($this->sort)
|
|
|
@@ -605,10 +586,10 @@ class User extends AdminController
|
|
|
|
|
|
|
|
|
$data = [
|
|
|
- 'code' => 0,
|
|
|
- 'msg' => '成功',
|
|
|
+ 'code' => 0,
|
|
|
+ 'msg' => '成功',
|
|
|
'count' => $count,
|
|
|
- 'data' => $list,
|
|
|
+ 'data' => $list,
|
|
|
];
|
|
|
return json($data);
|
|
|
}
|