119 lines
3.5 KiB
PHP
119 lines
3.5 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @author Any
|
|
* @description KISS
|
|
* @date 2021年9月28日
|
|
* @version 1.0.0
|
|
*
|
|
* _____LOG_____
|
|
*
|
|
*/
|
|
namespace app\modules\admin\controllers\msg;
|
|
|
|
use yii\helpers\VarDumper;
|
|
use app\modules\admin\controllers\Controller;
|
|
use app\modules\admin\behaviors\LoginBehavior;
|
|
use app\models\common\msg\CommonSysMsgActionForm;
|
|
use app\models\common\msg\CommonSysMsgEditForm;
|
|
use app\models\common\msg\CommonSysMsgListForm;
|
|
use app\models\msg\SysMsg;
|
|
|
|
|
|
|
|
class SysMsgController extends Controller
|
|
{
|
|
public function behaviors()
|
|
{
|
|
return array_merge(parent::behaviors(), [
|
|
'login' => [
|
|
'class' => LoginBehavior::className(),
|
|
],
|
|
]);
|
|
}
|
|
|
|
public function actionIndex()
|
|
{
|
|
if(\Yii::$app->request->isAjax){
|
|
$form = new CommonSysMsgListForm();
|
|
$form->attributes = \Yii::$app->request->get();
|
|
$form->cx_mch_id = $this->cx_mch_id;
|
|
$form->to_user_id = 0;
|
|
$data = $form->search();
|
|
return $this->responseHandler($data);
|
|
}
|
|
return $this->render('index');
|
|
}
|
|
|
|
public function actionEdit($id = 0)
|
|
{
|
|
$model = SysMsg::findOne([
|
|
'cx_mch_id' => $this->cx_mch_id,
|
|
'type' => SysMsg::TYPE_DEFAULT_SYS_MSG,
|
|
'is_delete' => 0,
|
|
'id' => $id,
|
|
]);
|
|
if($model == null)
|
|
$model = new SysMsg();
|
|
if(\Yii::$app->request->isPost){
|
|
$form = new CommonSysMsgEditForm();
|
|
$form->attributes = \Yii::$app->request->post();
|
|
$form->cx_mch_id = $this->cx_mch_id;
|
|
$form->type = SysMsg::TYPE_DEFAULT_SYS_MSG;
|
|
$form->to_user_id = 0;
|
|
$form->order_id = 0;
|
|
$form->model = $model;
|
|
$data = $form->save();
|
|
return $this->responseHandler($data);
|
|
}
|
|
$return_url = \Yii::$app->request->referrer;
|
|
return $this->render('edit', [
|
|
'model' => $model,
|
|
'return_url' => $return_url,
|
|
]);
|
|
}
|
|
|
|
public function actionDelete()
|
|
{
|
|
if(!\Yii::$app->request->isPost){
|
|
$data = $this->invaildRequest();
|
|
return $this->responseHandler($data);
|
|
}
|
|
$form = new CommonSysMsgActionForm();
|
|
$form->attributes = \Yii::$app->request->post();
|
|
$form->cx_mch_id = $this->cx_mch_id;
|
|
$form->to_user_id = 0;
|
|
$data = $form->delete();
|
|
return $this->responseHandler($data);
|
|
}
|
|
|
|
public function actionPublish()
|
|
{
|
|
if(!\Yii::$app->request->isPost){
|
|
$data = $this->invaildRequest();
|
|
return $this->responseHandler($data);
|
|
}
|
|
$form = new CommonSysMsgActionForm();
|
|
$form->attributes = \Yii::$app->request->post();
|
|
$form->cx_mch_id = $this->cx_mch_id;
|
|
$form->to_user_id = 0;
|
|
$data = $form->publish();
|
|
return $this->responseHandler($data);
|
|
}
|
|
|
|
public function actionWithdraw()
|
|
{
|
|
if(!\Yii::$app->request->isPost){
|
|
$data = $this->invaildRequest();
|
|
return $this->responseHandler($data);
|
|
}
|
|
$form = new CommonSysMsgActionForm();
|
|
$form->attributes = \Yii::$app->request->post();
|
|
$form->cx_mch_id = $this->cx_mch_id;
|
|
$form->to_user_id = 0;
|
|
$data = $form->withdraw();
|
|
return $this->responseHandler($data);
|
|
}
|
|
}
|
|
|