207 lines
6.6 KiB
PHP
207 lines
6.6 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @author Any
|
|
* @description KISS
|
|
* @date 2020-11-5
|
|
* @version 1.0.0
|
|
*
|
|
* _____LOG_____
|
|
*
|
|
*/
|
|
namespace app\modules\admin\controllers;
|
|
use app\models\Coach;
|
|
use app\models\CoachReview;
|
|
use app\models\Store;
|
|
use app\modules\admin\behaviors\LoginBehavior;
|
|
use app\modules\admin\models\coach\CoachActionForm;
|
|
use app\modules\admin\models\coach\CoachEditForm;
|
|
use app\modules\admin\models\coach\CoachListForm;
|
|
use app\modules\admin\models\coach\CoachReviewEditForm;
|
|
use app\modules\admin\models\coach\CoachReviewListForm;
|
|
class CoachController extends Controller
|
|
{
|
|
public function behaviors()
|
|
{
|
|
return array_merge(parent::behaviors(), [
|
|
'login' => [
|
|
'class' => LoginBehavior::className(),
|
|
],
|
|
]);
|
|
}
|
|
|
|
//教练列表
|
|
public function actionIndex()
|
|
{
|
|
if(\Yii::$app->request->isAjax){
|
|
$form = new CoachListForm();
|
|
$form->attributes = \Yii::$app->request->get();
|
|
if(\Yii::$app->admin->identity->user->store){
|
|
$form->store_id = \Yii::$app->admin->identity->user->store->id;
|
|
}
|
|
$data = $form->search();
|
|
return $this->responseHandler($data);
|
|
}
|
|
$store = Store::find()->select('id,name')->where(['is_delete' => 0])->asArray()->all();
|
|
return $this->render('index',[
|
|
'store' => $store
|
|
]);
|
|
|
|
|
|
}
|
|
|
|
//教练添加、编辑
|
|
public function actionEdit($id = 0)
|
|
{
|
|
$is_store = \Yii::$app->admin->identity->user->store;
|
|
$model = Coach::findOne([
|
|
'id' => $id,
|
|
'is_delete' => 0
|
|
]);
|
|
if($model == null)
|
|
$model = new Coach();
|
|
if(\Yii::$app->request->isPost){
|
|
$form = new CoachEditForm();
|
|
$form->attributes = \Yii::$app->request->post();
|
|
if($is_store){
|
|
$form->store_id = \Yii::$app->admin->identity->user->store->id;
|
|
}
|
|
$form->model = $model;
|
|
$data = $form->edit();
|
|
return $this->responseHandler($data);
|
|
}
|
|
$store = Store::find()->select('id,name')->where(['is_delete' => 0])->asArray()->all();
|
|
$return_url = \Yii::$app->request->referrer;
|
|
$view = $is_store ? 'store_edit' : 'edit';
|
|
return $this->render($view,[
|
|
'model' => $model,
|
|
'return_url' => $return_url,
|
|
'store' => $store,
|
|
]);
|
|
|
|
}
|
|
|
|
//教练删除
|
|
public function actionDelete()
|
|
{
|
|
if(!\Yii::$app->request->isPost){
|
|
$data = $this->invaildRequest();
|
|
return $this->responseHandler($data);
|
|
}
|
|
$form = new CoachActionForm();
|
|
$form->attributes = \Yii::$app->request->post();
|
|
$data = $form->delete();
|
|
return $this->responseHandler($data);
|
|
}
|
|
|
|
public function actionUntie()
|
|
{
|
|
if(!\Yii::$app->request->isPost){
|
|
$data = $this->invaildRequest();
|
|
return $this->responseHandler($data);
|
|
}
|
|
$form = new CoachActionForm();
|
|
$form->attributes = \Yii::$app->request->post();
|
|
$data = $form->untie();
|
|
return $this->responseHandler($data);
|
|
}
|
|
|
|
//审核列表
|
|
public function actionReview()
|
|
{
|
|
if(\Yii::$app->request->isAjax){
|
|
$form = new CoachReviewListForm();
|
|
$form->attributes = \Yii::$app->request->get();
|
|
if(\Yii::$app->admin->identity->user->store){
|
|
$form->store_id = \Yii::$app->admin->identity->user->store->id;
|
|
}
|
|
$data = $form->search();
|
|
return $this->responseHandler($data);
|
|
}
|
|
$store = Store::find()->select('id,name')->where(['is_delete' => 0])->asArray()->all();
|
|
return $this->render('review',[
|
|
'store' => $store
|
|
]);
|
|
}
|
|
|
|
//创建审核
|
|
public function actionReviewEdit($id = 0)
|
|
{
|
|
if(!\Yii::$app->admin->identity->user->store){
|
|
$data = ['code' => 1,'msg' => '您不是门店管理员未获得此权限'];
|
|
return $this->responseHandler($data);
|
|
}
|
|
$model = CoachReview::findOne([
|
|
'id' => $id,
|
|
'is_delete' => 0,
|
|
'status_review'=> [0,3]
|
|
]);
|
|
if($model == null)
|
|
$model = new CoachReview();
|
|
if(\Yii::$app->request->isPost){
|
|
$form = new CoachReviewEditForm();
|
|
$form->attributes = \Yii::$app->request->post();
|
|
$form->store_id = \Yii::$app->admin->identity->user->store->id;
|
|
$form->model = $model;
|
|
$data = $form->edit();
|
|
return $this->responseHandler($data);
|
|
}
|
|
$return_url = \Yii::$app->request->referrer;
|
|
return $this->render('store_edit',[
|
|
'model' => $model,
|
|
'return_url' => $return_url,
|
|
]);
|
|
}
|
|
|
|
//提交至总部审核
|
|
public function actionReviewSubmit()
|
|
{
|
|
if(!\Yii::$app->request->isPost){
|
|
$data = $this->invaildRequest();
|
|
return $this->responseHandler($data);
|
|
}
|
|
$form = new CoachActionForm();
|
|
$form->attributes = \Yii::$app->request->post();
|
|
$data = $form->review_status();
|
|
return $this->responseHandler($data);
|
|
}
|
|
|
|
//通过审核
|
|
public function actionReviewYes()
|
|
{
|
|
if(!\Yii::$app->request->isPost){
|
|
$data = $this->invaildRequest();
|
|
return $this->responseHandler($data);
|
|
}
|
|
$form = new CoachActionForm();
|
|
$form->attributes = \Yii::$app->request->post();
|
|
$data = $form->review_yes();
|
|
return $this->responseHandler($data);
|
|
}
|
|
|
|
//驳回审核
|
|
public function actionReviewNo()
|
|
{
|
|
if(!\Yii::$app->request->isPost){
|
|
$data = $this->invaildRequest();
|
|
return $this->responseHandler($data);
|
|
}
|
|
$form = new CoachActionForm();
|
|
$form->attributes = \Yii::$app->request->post();
|
|
$data = $form->review_no();
|
|
return $this->responseHandler($data);
|
|
}
|
|
|
|
//教练申请删除
|
|
public function actionReviewDelete()
|
|
{
|
|
if(!\Yii::$app->request->isPost){
|
|
$data = $this->invaildRequest();
|
|
return $this->responseHandler($data);
|
|
}
|
|
$form = new CoachActionForm();
|
|
$form->attributes = \Yii::$app->request->post();
|
|
$data = $form->review_delete();
|
|
return $this->responseHandler($data);
|
|
}
|
|
} |