241 lines
7.0 KiB
PHP
241 lines
7.0 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @author Any
|
|
* @description KISS
|
|
* @date 2020-11-5
|
|
* @version 1.0.0
|
|
*
|
|
* _____LOG_____
|
|
*
|
|
*/
|
|
namespace app\modules\admin\controllers;
|
|
|
|
use app\models\common\CommonUserEditForm;
|
|
use app\models\Level;
|
|
use app\models\User;
|
|
use app\modules\admin\behaviors\LoginBehavior;
|
|
use app\modules\admin\models\UserListForm;
|
|
use app\modules\admin\models\UserActionForm;
|
|
use app\components\EncryptHelper;
|
|
|
|
|
|
class UserController extends Controller
|
|
{
|
|
public function behaviors()
|
|
{
|
|
return array_merge(parent::behaviors(), [
|
|
'login' => [
|
|
'class' => LoginBehavior::className(),
|
|
],
|
|
]);
|
|
}
|
|
|
|
public function actionIndex()
|
|
{
|
|
if(\Yii::$app->request->isAjax){
|
|
$form = new UserListForm();
|
|
$form->attributes = \Yii::$app->request->get();
|
|
$form->is_admin = 0;
|
|
$data = $form->search();
|
|
return $this->responseHandler($data);
|
|
}
|
|
return $this->render('index');
|
|
}
|
|
|
|
public function actionAdmin()
|
|
{
|
|
if(\Yii::$app->request->isAjax){
|
|
$form = new UserListForm();
|
|
$form->attributes = \Yii::$app->request->get();
|
|
$form->is_admin = 1;
|
|
$data = $form->search();
|
|
return $this->responseHandler($data);
|
|
}
|
|
return $this->render('admin');
|
|
}
|
|
|
|
public function actionForbidden()
|
|
{
|
|
if(!\Yii::$app->request->isPost){
|
|
$data = $this->invaildRequest();
|
|
return $this->responseHandler($data);
|
|
}
|
|
$form = new UserActionForm();
|
|
$form->attributes = \Yii::$app->request->post();
|
|
$data = $form->forbidden();
|
|
return $this->responseHandler($data);
|
|
}
|
|
|
|
public function actionCancelForbidden()
|
|
{
|
|
if(!\Yii::$app->request->isPost){
|
|
$data = $this->invaildRequest();
|
|
return $this->responseHandler($data);
|
|
}
|
|
$form = new UserActionForm();
|
|
$form->attributes = \Yii::$app->request->post();
|
|
$data = $form->cancel_forbidden();
|
|
return $this->responseHandler($data);
|
|
}
|
|
|
|
public function actionHangup()
|
|
{
|
|
if(!\Yii::$app->request->isPost){
|
|
$data = $this->invaildRequest();
|
|
return $this->responseHandler($data);
|
|
}
|
|
$form = new UserActionForm();
|
|
$form->attributes = \Yii::$app->request->post();
|
|
$data = $form->hangup();
|
|
return $this->responseHandler($data);
|
|
}
|
|
|
|
public function actionCancelHangup()
|
|
{
|
|
if(!\Yii::$app->request->isPost){
|
|
$data = $this->invaildRequest();
|
|
return $this->responseHandler($data);
|
|
}
|
|
$form = new UserActionForm();
|
|
$form->attributes = \Yii::$app->request->post();
|
|
$data = $form->cancel_hangup();
|
|
return $this->responseHandler($data);
|
|
}
|
|
|
|
public function actionAccountLogout()
|
|
{
|
|
if(!\Yii::$app->request->isPost){
|
|
$data = $this->invaildRequest();
|
|
return $this->responseHandler($data);
|
|
}
|
|
$form = new UserActionForm();
|
|
$form->attributes = \Yii::$app->request->post();
|
|
$data = $form->account_logout();
|
|
return $this->responseHandler($data);
|
|
}
|
|
|
|
public function actionLogoutReview()
|
|
{
|
|
if(\Yii::$app->request->isAjax){
|
|
$form = new UserListForm();
|
|
$form->attributes = \Yii::$app->request->get();
|
|
$form->is_admin = 0;
|
|
$data = $form->logout_review();
|
|
return $this->responseHandler($data);
|
|
}
|
|
return $this->render('logout');
|
|
}
|
|
|
|
//记录方式注销
|
|
public function actionLogout()
|
|
{
|
|
if(!\Yii::$app->request->isPost){
|
|
$data = $this->invaildRequest();
|
|
return $this->responseHandler($data);
|
|
}
|
|
$form = new UserActionForm();
|
|
$form->attributes = \Yii::$app->request->post();
|
|
$data = $form->logout();
|
|
return $this->responseHandler($data);
|
|
}
|
|
|
|
//驳回
|
|
public function actionAccountLogoutReview()
|
|
{
|
|
if(!\Yii::$app->request->isPost){
|
|
$data = $this->invaildRequest();
|
|
return $this->responseHandler($data);
|
|
}
|
|
$form = new UserActionForm();
|
|
$form->attributes = \Yii::$app->request->post();
|
|
$data = $form->account_logout_review();
|
|
return $this->responseHandler($data);
|
|
}
|
|
|
|
// 变更为为观看视频
|
|
public function actionEditIsView(){
|
|
$form = new UserActionForm();
|
|
$form->attributes = \Yii::$app->request->post();
|
|
$data = $form->actionEditIsView();
|
|
return $this->responseHandler($data);
|
|
}
|
|
|
|
public function actionEdit($id = 0)
|
|
{
|
|
$model = User::find()
|
|
->select('id,username,password,nickname,avatar_url,mobile_phone,gender,birthday,level_id,parent_id')
|
|
->where(['id' => $id])
|
|
->one();
|
|
if($model == null)
|
|
$model = new User();
|
|
if(\Yii::$app->request->isPost){
|
|
$model = User::findOne(['id' => \Yii::$app->request->post('id')]);
|
|
$form = new CommonUserEditForm();
|
|
$form->scenario = 'admin_edit';
|
|
$form->attributes = \Yii::$app->request->post();
|
|
$form->model = $model;
|
|
$form->cx_mch_id = $this->cx_mch_id;
|
|
$data = $form->save();
|
|
return $this->responseHandler($data);
|
|
}
|
|
$level = Level::find()->select('id,name')->asArray()->all();
|
|
$parent = '';
|
|
if(!empty($model->parent_id)){
|
|
$find = User::findOne([
|
|
'id' => $model->parent_id,
|
|
]);
|
|
$parent = $find->nickname.":".$find->mobile_phone;
|
|
}
|
|
|
|
$data = User::getDistrbutionTeam($id);
|
|
return $this->render('edit',[
|
|
'level' => $level,
|
|
'model' => $model,
|
|
'return_url' => '',
|
|
'down' => $data['down'],
|
|
'parent' => $parent,
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* 查询分销上级
|
|
* 搜索用户(用户名、真实姓名、手机号)
|
|
*/
|
|
public function actionSearchParent()
|
|
{
|
|
$content = \Yii::$app->request->get('content');
|
|
if(empty($content)){
|
|
return $this->responseHandler(['code' => 1,'msg' => '请输入用户名、真实姓名、手机号']);
|
|
}
|
|
$data = User::getParentUser($content);
|
|
if(empty($data)){
|
|
return $this->responseHandler(['code' => 1,'msg' => '查询不到用户']);
|
|
}
|
|
return $this->responseHandler(['code' => 0,'msg' => 'ok','data' => $data]);
|
|
}
|
|
|
|
/**
|
|
* 绑定会员
|
|
*/
|
|
public function actionBindParent()
|
|
{
|
|
$form = new UserListForm();
|
|
$form->attributes = \Yii::$app->request->post();
|
|
$data = $form->actionBindParent();
|
|
return $this->responseHandler($data);
|
|
}
|
|
|
|
public function actionUserExport()
|
|
{
|
|
$form = new UserListForm();
|
|
$form->attributes = \Yii::$app->request->get();
|
|
$form->is_admin = 0;
|
|
$data = $form->user_export();
|
|
return $this->responseHandler($data);
|
|
}
|
|
|
|
|
|
|
|
|
|
} |