|
|
@@ -2,26 +2,14 @@
|
|
|
|
|
|
namespace app\admin\controller\user;
|
|
|
|
|
|
-//use app\admin\model\ActiveLog;
|
|
|
-//use app\admin\model\ActiveSet;
|
|
|
-//use app\admin\model\CoinLog;
|
|
|
use app\admin\logic\MoneyLogLogic;
|
|
|
use app\admin\logic\ScoreLogLogic;
|
|
|
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;
|
|
|
-use app\common\model\UserData;
|
|
|
use app\admin\traits\Curd;
|
|
|
-use app\common\constants\AdminConstant;
|
|
|
use app\common\controller\AdminController;
|
|
|
use app\common\model\UserMoneyModel;
|
|
|
-use app\common\model\UserteamLogModel;
|
|
|
use app\Request;
|
|
|
-use app\validate\admin\mall\shopOrder\EditStatus;
|
|
|
use app\validate\admin\user\user\ModifyMoney;
|
|
|
use app\validate\admin\user\user\ModifyScore;
|
|
|
use app\validate\admin\user\user\ModifyPid;
|
|
|
@@ -30,7 +18,9 @@ use EasyAdmin\tool\CommonTool;
|
|
|
use jianyan\excel\Excel;
|
|
|
use think\App;
|
|
|
use think\exception\ValidateException;
|
|
|
+use think\facade\Cache;
|
|
|
use think\facade\Db;
|
|
|
+use app\admin\model\dao\User as UserDao;
|
|
|
|
|
|
|
|
|
class User extends AdminController
|
|
|
@@ -59,6 +49,8 @@ class User extends AdminController
|
|
|
}
|
|
|
list($page, $limit, $where) = $this->buildTableParames();
|
|
|
|
|
|
+ Cache::set("USER_EXPORT", ['page' => $page, 'limit' => $limit, 'where' => $where]);
|
|
|
+
|
|
|
if (($pid = $this->request->param('pid')) !== false && $pid)
|
|
|
$where[] = ['pid', '=', $this->request->param('pid', '')];
|
|
|
|
|
|
@@ -75,13 +67,11 @@ class User extends AdminController
|
|
|
*/
|
|
|
public function forbid($id)
|
|
|
{
|
|
|
- $user = $this->model->findOrEmpty($id);
|
|
|
- empty($user) && $this->error('数据不存在');
|
|
|
- $user['status'] == 0 && $this->error('该用户已被禁用');
|
|
|
- if ($this->model->where('id', $id)->save(['status' => 0]))
|
|
|
- $this->success('禁用成功');
|
|
|
- else
|
|
|
- $this->error('禁用失败');
|
|
|
+ list($result, $msg) = UserLogic::forbid($id);
|
|
|
+ if ($result !== true) {
|
|
|
+ $this->error($msg);
|
|
|
+ }
|
|
|
+ $this->success($msg);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -90,44 +80,33 @@ class User extends AdminController
|
|
|
*/
|
|
|
public function enable($id)
|
|
|
{
|
|
|
- $user = $this->model->findOrEmpty($id);
|
|
|
- empty($user) && $this->error('数据不存在');
|
|
|
- $user['status'] == 1 && $this->error('该用户已启用');
|
|
|
- if ($this->model->where('id', $id)->save(['status' => 1]))
|
|
|
- $this->success('启用成功');
|
|
|
- else
|
|
|
- $this->error('启用失败');
|
|
|
+ list($result, $msg) = UserLogic::enable($id);
|
|
|
+ if ($result !== true) {
|
|
|
+ $this->error($msg);
|
|
|
+ }
|
|
|
+ $this->success($msg);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 会员详情
|
|
|
* @param Request $request
|
|
|
- * @param UpgradeLog $upgradeLog
|
|
|
* @return mixed
|
|
|
- * @throws \think\db\exception\DataNotFoundException
|
|
|
- * @throws \think\db\exception\DbException
|
|
|
- * @throws \think\db\exception\ModelNotFoundException
|
|
|
*/
|
|
|
public function details(Request $request)
|
|
|
{
|
|
|
$id = $request->param('id');
|
|
|
- $info = $this->model
|
|
|
- ->withJoin('userData', 'INNER')
|
|
|
- ->where('id', $id)
|
|
|
- ->find()
|
|
|
- ->toArray();
|
|
|
-// $upgrade_log = $upgradeLog->where('uid', $id)->order('create_at', 'desc')->select();
|
|
|
-// $this->assign('upgrade_log', $upgrade_log);
|
|
|
+ $info = UserLogic::getUserDetail($id);
|
|
|
$this->assign('info', $info);
|
|
|
return $this->fetch();
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
- * 添加用户
|
|
|
+ * 添加用户(功能不存在)
|
|
|
* @return mixed
|
|
|
*/
|
|
|
- public function add()
|
|
|
+ /*public function add()
|
|
|
{
|
|
|
if ($this->request->isAjax()) {
|
|
|
$post = $this->request->post();
|
|
|
@@ -157,7 +136,7 @@ class User extends AdminController
|
|
|
$this->success('添加成功');
|
|
|
}
|
|
|
return $this->fetch();
|
|
|
- }
|
|
|
+ }*/
|
|
|
|
|
|
/**
|
|
|
* 邀请页面
|
|
|
@@ -167,7 +146,8 @@ class User extends AdminController
|
|
|
{
|
|
|
$admin = session('admin');
|
|
|
!$admin['user_id'] && $this->error('没有该权限');
|
|
|
- $user = $this->model->findOrEmpty(['id' => $admin['user_id']]);
|
|
|
+ $user = UserDao::getUserOrEmptyById($admin['user_id']);
|
|
|
+
|
|
|
empty($user) && $this->error('用户信息不存在');
|
|
|
$this->assign('user_id', encode($admin['user_id']));
|
|
|
return $this->fetch();
|
|
|
@@ -213,10 +193,10 @@ class User extends AdminController
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 增加余额
|
|
|
+ * 增加余额(功能已屏蔽)
|
|
|
* @return mixed
|
|
|
*/
|
|
|
- public function editmoney()
|
|
|
+ /*public function editmoney()
|
|
|
{
|
|
|
if ($this->request->isPost()) {
|
|
|
|
|
|
@@ -243,10 +223,10 @@ class User extends AdminController
|
|
|
}
|
|
|
|
|
|
return $this->fetch();
|
|
|
- }
|
|
|
+ }*/
|
|
|
|
|
|
/**
|
|
|
- * 增加余额
|
|
|
+ * 修改手机号码
|
|
|
* @return mixed
|
|
|
*/
|
|
|
public function phoneset()
|
|
|
@@ -261,20 +241,15 @@ class User extends AdminController
|
|
|
$this->error($e->getMessage());
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- $user = $this->model->findOrEmpty(['id' => $post['id']]);
|
|
|
- $phone = $post['phone'];
|
|
|
- empty($user) && $this->error('用户不存在');
|
|
|
-
|
|
|
$userLogic = new UserLogic();
|
|
|
- $result = $userLogic->modifyPhone($post['id'], $phone);
|
|
|
+ $result = $userLogic->modifyPhone($post['id'], $post['phone']);
|
|
|
if ($result !== true) {
|
|
|
$this->error($result);
|
|
|
}
|
|
|
|
|
|
$this->success('成功');
|
|
|
}
|
|
|
- $user = $this->model->findOrEmpty(['id' => $this->request['id']]);
|
|
|
+ $user = UserDao::getUserOrEmptyById($this->request['id']);
|
|
|
$this->assign('info', $user);
|
|
|
return $this->fetch('phoneset');
|
|
|
}
|
|
|
@@ -288,29 +263,21 @@ class User extends AdminController
|
|
|
if ($this->request->isPost()) {
|
|
|
|
|
|
$post = $this->request->post();
|
|
|
-
|
|
|
try {
|
|
|
-
|
|
|
validate(ModifyPid::class)->check($post);
|
|
|
} catch (ValidateException $e) {
|
|
|
$this->error($e->getMessage());
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- $pid = $post['pid'];
|
|
|
- $uid = $post['id'];
|
|
|
- $user = $this->model->findOrEmpty(['id' => $uid]);
|
|
|
- empty($user) && $this->error('用户不存在');
|
|
|
-
|
|
|
$userLogic = new UserLogic();
|
|
|
- $result = $userLogic->modifypid($uid, $pid);
|
|
|
+ $result = $userLogic->modifypid($post['id'], $post['pid']);
|
|
|
if ($result !== true) {
|
|
|
$this->error($result);
|
|
|
}
|
|
|
|
|
|
$this->success('成功');
|
|
|
}
|
|
|
- $user = $this->model->findOrEmpty(['id' => $this->request['id']]);
|
|
|
+ $user = UserDao::getUserOrEmptyById($this->request['id']);
|
|
|
$this->assign('info', $user);
|
|
|
|
|
|
return $this->fetch();
|
|
|
@@ -325,44 +292,26 @@ class User extends AdminController
|
|
|
|
|
|
if ($this->request->isPost()) {
|
|
|
|
|
|
- $post = $this->request->post();
|
|
|
- $level = $post['level'];
|
|
|
- if ($level > 4) {
|
|
|
- $this->error('最高等级4级');
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- $user = $this->model->findOrEmpty(['id' => $post['id']]);
|
|
|
- empty($user) && $this->error('用户不存在');
|
|
|
+ $post = $this->request->post();
|
|
|
|
|
|
- $level_type = 1;
|
|
|
- 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->commit();
|
|
|
- } catch (\Exception $e) {
|
|
|
- $this->model->rollback();
|
|
|
- $this->error('失败' . $e->getMessage());
|
|
|
+ $result = UserLogic::levelset($post);
|
|
|
+ if ($result !== true) {
|
|
|
+ $this->error($result);
|
|
|
}
|
|
|
$this->success('成功');
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- $user = $this->model->findOrEmpty(['id' => $this->request['id']]);
|
|
|
-// $user_info = Db::name('user', $id)->find();
|
|
|
+ $user = UserDao::getUserOrEmptyById($this->request['id']);
|
|
|
$this->assign('info', $user);
|
|
|
|
|
|
return $this->fetch();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 末尾奖励
|
|
|
+ * 末尾奖励(功能已注释)
|
|
|
* @return mixed
|
|
|
*/
|
|
|
- public function moweiscore()
|
|
|
+ /*public function moweiscore()
|
|
|
{
|
|
|
if ($this->request->isPost()) {
|
|
|
$post = $this->request->post();
|
|
|
@@ -383,43 +332,27 @@ class User extends AdminController
|
|
|
}
|
|
|
|
|
|
return $this->fetch();
|
|
|
- }
|
|
|
+ }*/
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 余额明细
|
|
|
- * @param MoneyLog $model
|
|
|
+ * @param UserMoneyModel $model
|
|
|
* @return mixed|\think\response\Json
|
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
|
* @throws \think\db\exception\DbException
|
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
|
*/
|
|
|
- public function moneyLog(UserMoneyModel $model)
|
|
|
+ public function moneyLog()
|
|
|
{
|
|
|
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($where)
|
|
|
- ->count();
|
|
|
- $type_conf = config('type.money');
|
|
|
- $list = $model
|
|
|
- ->where($where)
|
|
|
- ->withAttr('type', function ($value, $data) use ($type_conf) {
|
|
|
- return $type_conf[$value];
|
|
|
- })
|
|
|
- ->withAttr('money', function ($value, $data) {
|
|
|
- if ($data['state'] == 2)
|
|
|
- $value = '-' . $value;
|
|
|
- return $value;
|
|
|
- })
|
|
|
- ->page($page, $limit)
|
|
|
- ->order($this->sort)
|
|
|
- ->select();
|
|
|
- $data = [
|
|
|
+ $where[] = ['uid', '=', $this->request->param('id', '')];
|
|
|
+ list($count, $list) = MoneyLogLogic::getMoneyLog($page, $limit, $where, $this->sort);
|
|
|
+ $data = [
|
|
|
'code' => 0,
|
|
|
'msg' => '',
|
|
|
'count' => $count,
|
|
|
@@ -433,41 +366,15 @@ class User extends AdminController
|
|
|
|
|
|
/**
|
|
|
* 查看上级
|
|
|
- * @param Request $request
|
|
|
- * @param UpgradeLog $upgradeLog
|
|
|
- * @return mixed
|
|
|
- * @throws \think\db\exception\DataNotFoundException
|
|
|
- * @throws \think\db\exception\DbException
|
|
|
- * @throws \think\db\exception\ModelNotFoundException
|
|
|
+ * @return mixed|\think\response\Json
|
|
|
*/
|
|
|
- public function lookpidlevel(Request $request)
|
|
|
+ public function lookpidlevel()
|
|
|
{
|
|
|
if ($this->request->isAjax()) {
|
|
|
|
|
|
-// if (($pid = $this->request->param('pid')) !== false && $pid)
|
|
|
-// $where[] = ['pid', '=', $this->request->param('pid', '')];
|
|
|
- $id = $this->request->param('id');
|
|
|
- $path = Db::name('user')->where('id', $id)->value('path');
|
|
|
- $arr = explode(',', $path);
|
|
|
-
|
|
|
- $ids = $arr;
|
|
|
- $ids = implode(',', $ids);
|
|
|
- $order = 'field(id,' . $ids . ')';
|
|
|
-// return User::whereIn('id',$ids)->order(Db::raw($order))->select();
|
|
|
-
|
|
|
- $where = array();
|
|
|
+ $id = $this->request->param('id');
|
|
|
|
|
|
- $where[] = ['uid', 'in', $arr];
|
|
|
- sr_log($where);
|
|
|
- $count = $this->model
|
|
|
- ->withJoin('userData', 'INNER')
|
|
|
- ->where($where)
|
|
|
- ->count();
|
|
|
- $list = $this->model
|
|
|
- ->withJoin('userData', 'INNER')
|
|
|
- ->where($where)
|
|
|
- ->order(Db::raw($order))
|
|
|
- ->select();
|
|
|
+ list($count, $list) = UserLogic::lookpidlevel($id);
|
|
|
|
|
|
$data = [
|
|
|
'code' => 0,
|
|
|
@@ -481,14 +388,14 @@ class User extends AdminController
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 元宝明细
|
|
|
+ * 元宝明细(功能已失效)
|
|
|
* @param CoinLog $model
|
|
|
* @return mixed|\think\response\Json
|
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
|
* @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')) {
|
|
|
@@ -522,42 +429,24 @@ class User extends AdminController
|
|
|
return json($data);
|
|
|
}
|
|
|
return $this->fetch();
|
|
|
- }
|
|
|
+ }*/
|
|
|
|
|
|
/**
|
|
|
* 积分明细
|
|
|
- * @param ScoreLog $model
|
|
|
* @return mixed|\think\response\Json
|
|
|
- * @throws \think\db\exception\DataNotFoundException
|
|
|
- * @throws \think\db\exception\DbException
|
|
|
- * @throws \think\db\exception\ModelNotFoundException
|
|
|
*/
|
|
|
- public function scoreLog(ScoreLogModel $model)
|
|
|
+ public function scoreLog()
|
|
|
{
|
|
|
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($where)
|
|
|
- ->count();
|
|
|
- $type_conf = config('type.score');
|
|
|
- $list = $model
|
|
|
- ->where($where)
|
|
|
- ->withAttr('type', function ($value, $data) use ($type_conf) {
|
|
|
- return $type_conf[$value];
|
|
|
- })
|
|
|
- ->withAttr('score', function ($value, $data) {
|
|
|
- if ($data['state'] == 2)
|
|
|
- $value = '-' . $value;
|
|
|
- return $value;
|
|
|
- })
|
|
|
- ->page($page, $limit)
|
|
|
- ->order($this->sort)
|
|
|
- ->select();
|
|
|
- $data = [
|
|
|
+ $where[] = ['uid', '=', $this->request->param('id', '')];
|
|
|
+
|
|
|
+ list($count, $list) = ScoreLogLogic::scoreLog($page, $limit, $where, $this->sort);
|
|
|
+
|
|
|
+ $data = [
|
|
|
'code' => 0,
|
|
|
'msg' => '',
|
|
|
'count' => $count,
|
|
|
@@ -569,14 +458,14 @@ class User extends AdminController
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 积分明细
|
|
|
+ * 活跃明细(功能已失效)
|
|
|
* @param ActiveLog $model
|
|
|
* @return mixed|\think\response\Json
|
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
|
* @throws \think\db\exception\DbException
|
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
|
*/
|
|
|
- public function activeLog(ActiveLog $model)
|
|
|
+ /*public function activeLog(ActiveLogModel $model)
|
|
|
{
|
|
|
if ($this->request->isAjax()) {
|
|
|
if (input('selectFields')) {
|
|
|
@@ -610,7 +499,7 @@ class User extends AdminController
|
|
|
return json($data);
|
|
|
}
|
|
|
return $this->fetch();
|
|
|
- }
|
|
|
+ }*/
|
|
|
|
|
|
/**
|
|
|
* @NodeAnotation(title="导出")
|
|
|
@@ -618,31 +507,27 @@ class User extends AdminController
|
|
|
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 = [];
|
|
|
- foreach ($dbList as $vo) {
|
|
|
- $comment = !empty($vo['Comment']) ? $vo['Comment'] : $vo['Field'];
|
|
|
- if (!in_array($vo['Field'], $this->noExportFields)) {
|
|
|
- $header[] = [$comment, $vo['Field']];
|
|
|
- }
|
|
|
+
|
|
|
+ if (empty($where)) {
|
|
|
+ $search = Cache::get("USER_EXPORT");
|
|
|
+ $page = $search['page'];
|
|
|
+ $limit = $search['limit'];
|
|
|
+ $where = $search['where'];
|
|
|
}
|
|
|
- $list = $this->model
|
|
|
- ->where($where)
|
|
|
- ->withJoin('userData', 'INNER')
|
|
|
- ->where($where)
|
|
|
- ->limit(100000)
|
|
|
- ->order('id', 'desc')
|
|
|
- ->select()
|
|
|
- ->toArray();
|
|
|
+
|
|
|
+ $header = getExportHeader($this->model->getName(), $this->noExportFields);
|
|
|
+
|
|
|
+ $list = UserLogic::getExportList($where, $page, $limit);
|
|
|
$fileName = time();
|
|
|
return Excel::exportData($list, $header, $fileName, 'xlsx');
|
|
|
}
|
|
|
|
|
|
|
|
|
- public function teamincome(Request $request)
|
|
|
+ /**
|
|
|
+ * 团队充值(已失效)
|
|
|
+ * @return mixed
|
|
|
+ */
|
|
|
+ /*public function teamincome(Request $request)
|
|
|
{
|
|
|
if ($this->request->isAjax()) {
|
|
|
|
|
|
@@ -673,7 +558,7 @@ class User extends AdminController
|
|
|
return json($data);
|
|
|
}
|
|
|
return $this->fetch();
|
|
|
- }
|
|
|
+ }*/
|
|
|
|
|
|
/*
|
|
|
* 修改积分
|
|
|
@@ -699,7 +584,7 @@ class User extends AdminController
|
|
|
|
|
|
$this->success('成功');
|
|
|
}
|
|
|
- $user = $this->model->findOrEmpty(['id' => $this->request['id']]);
|
|
|
+ $user = UserDao::getUserOrEmptyById($this->request['id']);
|
|
|
$user['type_map'] = ScoreLogLogic::getTypeMap();
|
|
|
$user['state_map'] = ScoreLogLogic::getStateMap();
|
|
|
$this->assign('info', $user);
|
|
|
@@ -731,7 +616,7 @@ class User extends AdminController
|
|
|
|
|
|
$this->success('成功');
|
|
|
}
|
|
|
- $user = $this->model->findOrEmpty(['id' => $this->request['id']]);
|
|
|
+ $user = UserDao::getUserOrEmptyById($this->request['id']);
|
|
|
$user['type_map'] = MoneyLogLogic::getTypeMap();
|
|
|
$user['state_map'] = MoneyLogLogic::getStateMap();
|
|
|
$this->assign('info', $user);
|