99 lines
2.7 KiB
PHP
99 lines
2.7 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @author Any
|
|
* @description KISS
|
|
* @date 2021年6月30日
|
|
* @version 1.0.0
|
|
*
|
|
* _____LOG_____
|
|
*
|
|
*/
|
|
namespace app\modules\admin\controllers;
|
|
|
|
use app\components\EncryptHelper;
|
|
use app\models\User;
|
|
use app\modules\admin\behaviors\LoginBehavior;
|
|
use app\modules\admin\models\UserActionForm;
|
|
use app\modules\admin\models\UserListForm;
|
|
|
|
class DistributionController 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();
|
|
$data = $form->distribution_list();
|
|
return $this->responseHandler($data);
|
|
}
|
|
return $this->render('index');
|
|
}
|
|
|
|
public function actionTeam($id)
|
|
{
|
|
$model = User::find()
|
|
->select('id,nickname,avatar_url,mobile_phone,created_at,parent_id')
|
|
->where(['is_delete' => 0])
|
|
->andWhere(['id' => $id])
|
|
->one();
|
|
$model_parent = null;
|
|
if(!empty($model->parent_id)){
|
|
$model_parent = User::find()
|
|
->select('id,nickname,avatar_url,mobile_phone,created_at,parent_id')
|
|
->where(['is_delete' => 0])
|
|
->andWhere(['id' => $model->parent_id])
|
|
->one();
|
|
$model_parent->created_at = date('Y-m-d H:i:s',$model_parent->created_at);
|
|
}
|
|
$model->created_at = date('Y-m-d H:i:s',$model->created_at);
|
|
$data = User::getDistrbutionTeam($model->id);
|
|
return $this->render('team',[
|
|
'model' => $model,
|
|
'model_parent' => $model_parent,
|
|
'down' => $data['down'],
|
|
'down_count' => $data['down_count'],
|
|
]);
|
|
|
|
|
|
}
|
|
|
|
public function actionBatchDel()
|
|
{
|
|
if(!\Yii::$app->request->isPost){
|
|
$data = $this->invaildRequest();
|
|
return $this->responseHandler($data);
|
|
}
|
|
$form = new UserActionForm();
|
|
$form->attributes = \Yii::$app->request->post();
|
|
$data = $form->batch_del();
|
|
return $this->responseHandler($data);
|
|
|
|
}
|
|
|
|
/**
|
|
* 更改上级
|
|
*/
|
|
public function actionUpdateParent()
|
|
{
|
|
if(!\Yii::$app->request->isPost){
|
|
$data = $this->invaildRequest();
|
|
return $this->responseHandler($data);
|
|
}
|
|
$form = new UserActionForm();
|
|
$form->attributes = \Yii::$app->request->post();
|
|
$data = $form->update_parent();
|
|
return $this->responseHandler($data);
|
|
}
|
|
|
|
|
|
} |