Initial commit,修正
This commit is contained in:
Executable
+1
@@ -0,0 +1 @@
|
||||
|
||||
Executable
+26
@@ -0,0 +1,26 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
|
||||
<title>404</title>
|
||||
<style>
|
||||
body{
|
||||
background-color:#444;
|
||||
font-size:14px;
|
||||
}
|
||||
h3{
|
||||
font-size:60px;
|
||||
color:#eee;
|
||||
text-align:center;
|
||||
padding-top:30px;
|
||||
font-weight:normal;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h3>404,您请求的文件不存在!</h3>
|
||||
</body>
|
||||
</html>
|
||||
Executable
Executable
+25
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace backend\assets;
|
||||
|
||||
use yii\web\AssetBundle;
|
||||
|
||||
/**
|
||||
* Main backend application asset bundle.
|
||||
*/
|
||||
class AppAsset extends AssetBundle
|
||||
{
|
||||
public $basePath = '@webroot';
|
||||
public $baseUrl = '@web';
|
||||
public $css = [
|
||||
'css/site.css',
|
||||
'css/login.min.css',
|
||||
];
|
||||
public $js = [
|
||||
'js/hplus.min.js',
|
||||
];
|
||||
public $depends = [
|
||||
'yii\web\YiiAsset',
|
||||
'yii\bootstrap\BootstrapAsset',
|
||||
];
|
||||
}
|
||||
Executable
+24
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
/**
|
||||
* User: Administrator
|
||||
* Date: 2016-7-5
|
||||
* Time: 16:10
|
||||
* Description:
|
||||
*/
|
||||
|
||||
namespace backend\components;
|
||||
|
||||
|
||||
use Yii;
|
||||
use yii\rbac\Rule;
|
||||
|
||||
|
||||
class ArticleRule extends Rule
|
||||
{
|
||||
public $name = 'article';
|
||||
public function execute($user, $item, $params)
|
||||
{
|
||||
// 这里先设置为false,逻辑上后面再完善
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Executable
+32
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/**
|
||||
* User: lzkong1029
|
||||
* Date: 2016-7-6
|
||||
* Time: 15:10
|
||||
* Description:静态公共函数类库
|
||||
*/
|
||||
|
||||
namespace backend\components;
|
||||
use backend\models\Log;
|
||||
use Yii;
|
||||
|
||||
class Helper {
|
||||
|
||||
public static function hello(){
|
||||
echo 'hello';
|
||||
}
|
||||
|
||||
//历史访客数
|
||||
public static function getHistoryVisNum(){
|
||||
$res = Log::find()->count();
|
||||
return $res;
|
||||
}
|
||||
|
||||
//最近一个月访问量
|
||||
public static function getMonthHistoryVisNum(){
|
||||
$LastMonth = strtotime("-1 month");
|
||||
$res = Log::find()->where(['>','create_time',$LastMonth])->count();
|
||||
return $res;
|
||||
}
|
||||
|
||||
}
|
||||
Executable
+3
@@ -0,0 +1,3 @@
|
||||
main-local.php
|
||||
params-local.php
|
||||
test-local.php
|
||||
Executable
+4
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
global $_HI;
|
||||
global $_FM;
|
||||
Yii::setAlias('@backend', dirname(__DIR__));
|
||||
Executable
+21
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @Author: fm453
|
||||
* @Date: 2018-11-22 10:19:29
|
||||
* @Last Modified by: fm453
|
||||
* @Last Modified time: 2019-09-21 01:52:04
|
||||
* @Email: fm453@lukegzs.com
|
||||
*/
|
||||
|
||||
$citys=[];
|
||||
$i=0;
|
||||
|
||||
$i++;
|
||||
$citys[$i] = ['id'=>$i,'name'=>'三亚'];
|
||||
$i++;
|
||||
$citys[$i] = ['id'=>$i,'name'=>'海口'];
|
||||
|
||||
return [
|
||||
'citys'=>$citys
|
||||
];
|
||||
Executable
+24
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
$config = [
|
||||
'components' => [
|
||||
'db' => [
|
||||
'class' => 'yii\db\Connection',
|
||||
'dsn' => 'mysql:host=120.79.11.71;dbname=dacms_dev',
|
||||
'username' => 'dacms_dev',
|
||||
'password' => 'HS8wRyTT2sKeLdAJ',
|
||||
'charset' => 'utf8',
|
||||
'tablePrefix' => '',
|
||||
],
|
||||
'lvju' => [
|
||||
'class' => 'yii\db\Connection',
|
||||
'dsn' => 'mysql:host=120.79.11.71;dbname=lvju_dev',
|
||||
'username' => 'lvju_dev',
|
||||
'password' => 'F5XF4h28L37MGG5m',
|
||||
'charset' => 'utf8',
|
||||
'tablePrefix' => '',
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
return $config;
|
||||
Executable
+30
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
# @Author: 嗨噜客科技(www.hiluker.cn) <Fm453>
|
||||
# @Date: 1970-01-01T08:00:00+08:00
|
||||
# @Email: fm453@hiluker.com
|
||||
# @Last modified by: Fm453
|
||||
# @Last modified time: 2021-09-15T00:21:13+08:00
|
||||
|
||||
|
||||
$config = [
|
||||
'components' => [
|
||||
'db' => [
|
||||
'class' => 'yii\db\Connection',
|
||||
'dsn' => 'mysql:host=127.0.0.1;dbname=dacms',
|
||||
'username' => 'dacms',
|
||||
'password' => 'eydnsidc',
|
||||
'charset' => 'utf8',
|
||||
'tablePrefix' => '',
|
||||
],
|
||||
'lvju' => [
|
||||
'class' => 'yii\db\Connection',
|
||||
'dsn' => 'mysql:host=127.0.0.1;dbname=lvju',
|
||||
'username' => 'lvju',
|
||||
'password' => 'f3MnRe7eRRmCtZAz',
|
||||
'charset' => 'utf8',
|
||||
'tablePrefix' => '',
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
return $config;
|
||||
Executable
+118
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
# @Author: 嗨噜客科技(www.hiluker.cn) <Fm453>
|
||||
# @Date: 1970-01-01T08:00:00+08:00
|
||||
# @Email: fm453@hiluker.com
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2021-09-15T16:55:29+08:00
|
||||
|
||||
$params = array_merge(
|
||||
require(__DIR__ . '/../../common/config/params.php'),
|
||||
require(__DIR__ . '/params.php'),
|
||||
require(__DIR__ . '/citys.php'),
|
||||
require(__DIR__ . '/params-area.php'),
|
||||
require(__DIR__ . '/params-channel.php')
|
||||
);
|
||||
|
||||
$config = [
|
||||
'id' => 'app-backend',
|
||||
'basePath' => dirname(__DIR__),
|
||||
'controllerNamespace' => 'backend\controllers',
|
||||
'defaultRoute' => 'site', //默认路由
|
||||
'bootstrap' => ['log'],
|
||||
'modules' => [
|
||||
"admin" => [
|
||||
"class" => 'mdm\admin\Module',
|
||||
],
|
||||
],
|
||||
'aliases' => [
|
||||
"@mdm/admin" => "@vendor/mdmsoft/yii2-admin",
|
||||
],
|
||||
'as access' => [
|
||||
//加了才会自动验证是否有权限
|
||||
'class' => 'mdm\admin\components\AccessControl',
|
||||
'allowActions' => [
|
||||
//允许访问的action
|
||||
//controller/action
|
||||
'*', //开发环境配置完成后务必抹掉此项
|
||||
'site/*',
|
||||
'index/*'
|
||||
]
|
||||
],
|
||||
//'layout' => 'main',//布局文件 优先级: 控制器>配置文件>系统默认
|
||||
'language' => 'zh-CN', //目标语言
|
||||
//组件
|
||||
'components' => [
|
||||
'request' => [
|
||||
'csrfParam' => '_csrf-backend',
|
||||
// !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
|
||||
'cookieValidationKey' => 'CU5iSYmIp6kbjKKuh541KsA_oaYvTuNh',
|
||||
],
|
||||
//身份认证类
|
||||
'user' => [
|
||||
'identityClass' => 'backend\models\Adminer',
|
||||
'enableAutoLogin' => true,
|
||||
'identityCookie' => ['name' => '_identity-backend', 'httpOnly' => true],
|
||||
//'loginUrl' => ['site/login'], //配置登录url
|
||||
],
|
||||
'session' => [
|
||||
// this is the name of the session cookie used for login on the backend
|
||||
'name' => 'advanced-backend',
|
||||
],
|
||||
//Rbac权限控制
|
||||
'authManager' => [
|
||||
'class' => 'yii\rbac\DbManager',
|
||||
// 'itemTable' => 'auth_item',
|
||||
// 'assignmentTable' => 'auth_assignment',
|
||||
// 'itemChildTable' => 'auth_item_child',
|
||||
],
|
||||
'log' => [
|
||||
'traceLevel' => YII_DEBUG ? 3 : 0,
|
||||
'targets' => [
|
||||
[
|
||||
'class' => 'yii\log\FileTarget',
|
||||
'levels' => ['error', 'warning'],
|
||||
],
|
||||
],
|
||||
],
|
||||
'errorHandler' => [
|
||||
'errorAction' => 'site/error',
|
||||
],
|
||||
|
||||
/**
|
||||
* 语言包配置扩展(归于components下),
|
||||
* 将"源语言"翻译成"目标语言". 注意"源语言"默认配置为 'sourceLanguage' => 'en-US'
|
||||
* 使用: \Yii::t('common', 'title'); 将common/messages下的common.php中的title转为对应的中文
|
||||
*/
|
||||
'i18n' => [
|
||||
'translations' => [
|
||||
'common' => [ //有多套语言包要使用时,此处的*号可换成更具体的前缀,如pms
|
||||
'class' => 'yii\i18n\PhpMessageSource',
|
||||
'basePath' => '@backend/lang',
|
||||
//'sourceLanguage' => 'en-US',
|
||||
'fileMap' => [
|
||||
'common' => 'common.php',
|
||||
],
|
||||
],
|
||||
'backend' => [ //有多套语言包要使用时,此处的*号可换成更具体的前缀,如pms
|
||||
'class' => 'yii\i18n\PhpMessageSource',
|
||||
'basePath' => '@backend/lang',
|
||||
//'sourceLanguage' => 'en-US',
|
||||
'fileMap' => [
|
||||
'backend' => 'backend.php',
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
|
||||
'urlManager' => [
|
||||
'enablePrettyUrl' => true,
|
||||
'showScriptName' => true,
|
||||
'suffix' => '.hi', //后缀
|
||||
'rules' => [
|
||||
],
|
||||
],
|
||||
|
||||
],
|
||||
'params' => $params,
|
||||
];
|
||||
return $config;
|
||||
Executable
+41
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
$areas=[];
|
||||
$areas['110000'] = "北京";
|
||||
$areas['120000'] = "天津";
|
||||
$areas['130000'] = "河北省";
|
||||
$areas['140000'] = "山西省";
|
||||
$areas['150000'] = "内蒙古自治区";
|
||||
$areas['210000'] = "辽宁省";
|
||||
$areas['220000'] = "吉林省";
|
||||
$areas['230000'] = "黑龙江省";
|
||||
$areas['310000'] = "上海";
|
||||
$areas['320000'] = "江苏省";
|
||||
$areas['330000'] = "浙江省";
|
||||
$areas['340000'] = "安徽省";
|
||||
$areas['350000'] = "福建省";
|
||||
$areas['360000'] = "江西省";
|
||||
$areas['370000'] = "山东省";
|
||||
$areas['410000'] = "河南省";
|
||||
$areas['420000'] = "湖北省";
|
||||
$areas['430000'] = "湖南省";
|
||||
$areas['440000'] = "广东省";
|
||||
$areas['450000'] = "广西壮族自治区";
|
||||
$areas['460000'] = "海南省";
|
||||
$areas['500000'] = "重庆";
|
||||
$areas['510000'] = "四川省";
|
||||
$areas['520000'] = "贵州省";
|
||||
$areas['530000'] = "云南省";
|
||||
$areas['540000'] = "西藏自治区";
|
||||
$areas['610000'] = "陕西省";
|
||||
$areas['620000'] = "甘肃省";
|
||||
$areas['630000'] = "青海省";
|
||||
$areas['640000'] = "宁夏回族自治区";
|
||||
$areas['650000'] = "新疆维吾尔自治区";
|
||||
$areas['710000'] = "台湾省";
|
||||
$areas['810000'] = "香港特别行政区";
|
||||
$areas['820000'] = "澳门特别行政区";
|
||||
$areas['990000'] = "海外";
|
||||
return [
|
||||
'regionAreas' => $areas
|
||||
];
|
||||
Executable
+22
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
$channels=[];
|
||||
$channels['0'] = "未设置";
|
||||
$channels['ota'] = "其他OTA";
|
||||
$channels['100'] = "官方直营";
|
||||
$channels['200'] = "飞猪";
|
||||
$channels['300'] = "同行";
|
||||
$channels['400'] = "分销带客";
|
||||
$channels['1000'] = "携程";
|
||||
$channels['500'] = "途家";
|
||||
$channels['600'] = "去哪儿";
|
||||
$channels['700'] = "马蜂窝";
|
||||
$channels['800'] = "爱彼迎";
|
||||
$channels['900'] = "美团";
|
||||
$channels['1100'] = "小猪短租";
|
||||
$channels['1200'] = "木鸟短租";
|
||||
$channels['1300'] = "榛果民宿";
|
||||
|
||||
return [
|
||||
'saleChannels' => $channels
|
||||
];
|
||||
Executable
+22
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
# @Author: 嗨噜客科技(www.hiluker.cn) <Fm453>
|
||||
# @Date: 1970-01-01T08:00:00+08:00
|
||||
# @Email: fm453@hiluker.com
|
||||
# @Last modified by: Fm453
|
||||
# @Last modified time: 2021-09-15T00:28:32+08:00
|
||||
|
||||
return [
|
||||
'adminEmail' => 'fm453@lukegzs.com',
|
||||
'developerWx' => '18608981880',
|
||||
//默认值组
|
||||
'defaultAdminPassword' => 'Hi12345678', //默认的管理员密码
|
||||
'defaultAdminAvatar' => '@web/img/profile_small.png', //默认管理员头像
|
||||
'defaultUserPassword' => '12345678', //默认的用户密码
|
||||
'defaultUserAvatar' => '@web/img/profile_small.png', //默认管理员头像
|
||||
'defaultAttributeValue' => '(未设置)', //空值默认
|
||||
'defaultActionColumnButtonOption' => ['class' => 'btn btn-white btn-xs'], //列表页操作按钮选项
|
||||
//平台ID
|
||||
'siteId'=>90, //每个站点ID对应一套数据集
|
||||
'attachSrc'=>'//dacms.hiluker.com', //附件远程地址
|
||||
'attachDir'=>'/upload', //附件远程目录
|
||||
];
|
||||
Executable
+9
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
return [
|
||||
'id' => 'app-backend-tests',
|
||||
'components' => [
|
||||
'assetManager' => [
|
||||
'basePath' => __DIR__ . '/../web/assets',
|
||||
],
|
||||
],
|
||||
];
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
+63
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @Author: fm453
|
||||
* @Date: 2018-08-17 19:39:41
|
||||
* @Last Modified by: fm453
|
||||
* @Last Modified time: 2021-04-28 17:21:02
|
||||
* @Email: fm453@lukegzs.com
|
||||
*/
|
||||
namespace backend\controllers;
|
||||
|
||||
use Yii;
|
||||
use yii\data\Pagination;
|
||||
use yii\helpers\Url;
|
||||
|
||||
class AssetController extends \yii\web\Controller
|
||||
{
|
||||
//替代常规的_construct 析构函数;其他方法调用前执行
|
||||
public function init()
|
||||
{
|
||||
parent::init();
|
||||
$session = Yii::$app->session;
|
||||
if(isset($_GET['pid']) && (int)$_GET['pid']>0){
|
||||
$session->set('pid',(int)$_GET['pid']);
|
||||
}
|
||||
$pid = $session->get('pid');
|
||||
if(!$pid){
|
||||
$url = Url::toRoute('/index/index');
|
||||
return $this->redirect($url);
|
||||
}
|
||||
}
|
||||
//主界面
|
||||
public function actionIndex()
|
||||
{
|
||||
return $this->render('../layouts/dev',[]);
|
||||
}
|
||||
|
||||
public function actionList()
|
||||
{
|
||||
return $this->render('../layouts/dev',[]);
|
||||
}
|
||||
|
||||
public function actionRoom()
|
||||
{
|
||||
return $this->render('../layouts/dev',[]);
|
||||
}
|
||||
|
||||
public function actionIncidental()
|
||||
{
|
||||
return $this->render('../layouts/dev',[]);
|
||||
}
|
||||
|
||||
public function actionSale()
|
||||
{
|
||||
return $this->render('../layouts/dev',[]);
|
||||
}
|
||||
|
||||
public function actionOther()
|
||||
{
|
||||
return $this->render('../layouts/dev',[]);
|
||||
}
|
||||
|
||||
}
|
||||
Executable
+57
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @Author: fm453
|
||||
* @Date: 2018-08-17 19:39:41
|
||||
* @Last Modified by: fm453
|
||||
* @Last Modified time: 2019-01-12 12:13:35
|
||||
* @Email: fm453@lukegzs.com
|
||||
*/
|
||||
namespace backend\controllers;
|
||||
|
||||
use Yii;
|
||||
use yii\data\Pagination;
|
||||
use yii\helpers\Url;
|
||||
|
||||
class AttachController extends \yii\web\Controller
|
||||
{
|
||||
public $enableCsrfValidation = false; //取消csrf令牌验证;
|
||||
//主界面
|
||||
public function actionIndex()
|
||||
{
|
||||
$request = Yii::$app->request;
|
||||
$get = $request->get();
|
||||
$img = Urldecode($get['img']);
|
||||
$file = Yii::getAlias("@upload").$img;
|
||||
$img = file_get_contents($file);
|
||||
$this->showImg($file);
|
||||
}
|
||||
|
||||
/*
|
||||
* php 页面直接输出图片
|
||||
*/
|
||||
function showImg($img){
|
||||
$info = getimagesize($img);
|
||||
$imgExt = image_type_to_extension($info[2], false); //获取文件后缀
|
||||
$fun = "imagecreatefrom{$imgExt}";
|
||||
$imgInfo = $fun($img); //1.由文件或 URL 创建一个新图象。如:imagecreatefrompng ( string $filename )
|
||||
$mime = $info['mime'];
|
||||
header('Content-Type:'.$mime);
|
||||
$quality = 100;
|
||||
if($imgExt == 'png') $quality = 9; //输出质量,JPEG格式(0-100),PNG格式(0-9)
|
||||
$getImgInfo = "image{$imgExt}";
|
||||
$getImgInfo($imgInfo, null, $quality); //2.将图像输出到浏览器或文件。如: imagepng ( resource $image )
|
||||
//TBD: PNG图片会显示其被修改前的原始文件,与直接用SRC引用的方法有所不同
|
||||
imagedestroy($imgInfo);
|
||||
}
|
||||
|
||||
/*图片转换为 base64格式编码*/
|
||||
function base64EncodeImage ($image_file) {
|
||||
$base64_image = '';
|
||||
$image_info = getimagesize($image_file);
|
||||
$image_data = fread(fopen($image_file, 'r'), filesize($image_file));
|
||||
$base64_image = 'data:' . $image_info['mime'] . ';base64,' . chunk_split(base64_encode($image_data));
|
||||
return $base64_image;
|
||||
}
|
||||
|
||||
}
|
||||
Executable
+54
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @Author: fm453
|
||||
* @Date: 2018-08-17 19:39:41
|
||||
* @Last Modified by: fm453
|
||||
* @Last Modified time: 2021-04-28 17:20:59
|
||||
* @Email: fm453@lukegzs.com
|
||||
*/
|
||||
namespace backend\controllers;
|
||||
|
||||
use Yii;
|
||||
use yii\data\Pagination;
|
||||
use yii\helpers\Url;
|
||||
// use backend\models\Citys;
|
||||
|
||||
class CityController extends \yii\web\Controller
|
||||
{
|
||||
//替代常规的_construct 析构函数;其他方法调用前执行
|
||||
public function init()
|
||||
{
|
||||
parent::init();
|
||||
$session = Yii::$app->session;
|
||||
if(isset($_GET['pid']) && (int)$_GET['pid']>0){
|
||||
$session->set('pid',(int)$_GET['pid']);
|
||||
}
|
||||
$pid = $session->get('pid');
|
||||
if(!$pid){
|
||||
$url = Url::toRoute('/index/index');
|
||||
return $this->redirect($url);
|
||||
}
|
||||
}
|
||||
|
||||
//主界面
|
||||
public function actionIndex()
|
||||
{
|
||||
return $this->render('../layouts/dev',[]);
|
||||
}
|
||||
|
||||
public function actionSelect()
|
||||
{
|
||||
$citys = Yii::$app->params['citys'];
|
||||
$pager = new Pagination(['totalCount' =>count($citys), 'pageSize' => '20']);
|
||||
$callback = isset($_GET['callback']) ? $_GET['callback'] : 'city';
|
||||
$search=[];
|
||||
return $this->render('select',[
|
||||
'citys'=>$citys,
|
||||
'pager' => $pager,
|
||||
'search'=>$search,
|
||||
'callback'=>$callback
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
Executable
+712
@@ -0,0 +1,712 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @Author: fm453
|
||||
* @Date: 2018-11-22 03:40:46
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2021-09-15T15:22:35+08:00
|
||||
* @Email: fm453@lukegzs.com
|
||||
*/
|
||||
namespace backend\controllers;
|
||||
|
||||
use Yii;
|
||||
use yii\data\Pagination;
|
||||
use yii\helpers\Url;
|
||||
use common\models\Fans;
|
||||
use backend\models\FmContract as Contract;
|
||||
use backend\models\FmRoomOwner as RoomOver;
|
||||
use backend\models\FmUserExt as UserExt;
|
||||
|
||||
class ContractController extends \yii\web\Controller
|
||||
{
|
||||
//替代常规的_construct 析构函数;其他方法调用前执行
|
||||
public function init()
|
||||
{
|
||||
parent::init();
|
||||
$session = Yii::$app->session;
|
||||
if(isset($_GET['pid']) && (int)$_GET['pid']>0){
|
||||
$session->set('pid',(int)$_GET['pid']);
|
||||
}
|
||||
$pid = $session->get('pid');
|
||||
if(!$pid){
|
||||
$url = Url::toRoute('/index/index');
|
||||
return $this->redirect($url);
|
||||
}
|
||||
}
|
||||
|
||||
//主界面
|
||||
public function actionIndex()
|
||||
{
|
||||
global $_HI,$_FM;
|
||||
return $this->render('../layouts/dev',[]);
|
||||
|
||||
}
|
||||
|
||||
//客户列表
|
||||
public function actionList()
|
||||
{
|
||||
return $this->render('../layouts/dev',[]);
|
||||
global $_HI,$_FM;
|
||||
$pid = Yii::$app->session->get('pid');
|
||||
$model = new AcCustomer();
|
||||
$where = $where2 = [];
|
||||
$where2[]='and';
|
||||
$where['pid'] = $pid;
|
||||
$post = Yii::$app->request->post();
|
||||
$search = isset($post['search']) ? $post['search'] : [];
|
||||
$page = isset($_GET['page']) ? (int)$_GET['page'] : 0;
|
||||
$session = Yii::$app->session;
|
||||
if($page==0){
|
||||
$session->set('Guest:List:'.$pid,$search);
|
||||
}else{
|
||||
$search = $search ? $search : $session->get('Guest:List:'.$pid);
|
||||
}
|
||||
|
||||
$search['title'] = isset($search['title']) ? trim(htmlspecialchars_decode($search['title'])) : '';
|
||||
if(!empty($search['title'])){
|
||||
$where2[] = ['LIKE','name',$search['title']];
|
||||
}
|
||||
|
||||
$selectMid = false;
|
||||
$mids = [];
|
||||
$search['nickname'] = isset($search['nickname']) ? trim(htmlspecialchars_decode($search['nickname'])) : '';
|
||||
if(!empty($search['nickname'])){
|
||||
$_mids = [];
|
||||
$_exts = LvUserExt::find()->where(['pid'=>$pid,'deleted'=>0,'key'=>'nickname'])->andwhere(['OR',['LIKE','value',$search['nickname']]])->indexBy('id')->groupBy('mid')->all();
|
||||
foreach($_exts as $mid=>$ext){
|
||||
$_mids[$ext['mid']] = $ext['mid'];
|
||||
}
|
||||
$selectMid = true;
|
||||
$mids[] = $_mids;
|
||||
}
|
||||
|
||||
$search['phone'] = isset($search['phone']) ? trim(htmlspecialchars_decode($search['phone'])) : '';
|
||||
if(!empty($search['phone'])){
|
||||
$where2[] = ['LIKE','mobile',$search['phone']];
|
||||
}
|
||||
|
||||
$search['hotel'] = isset($search['hotel']) ? (int)$search['hotel'] : 0;
|
||||
if(!empty($search['hotel'])){
|
||||
$where2[] = ['=','hotel_id',$search['hotel']];
|
||||
$hotel = AcHotel::find()->where(['id'=>$search['hotel']])->one();
|
||||
$search['hotel_title'] = $hotel['title'];
|
||||
}
|
||||
|
||||
$search['employee'] = isset($search['employee']) ? (int)$search['employee'] : 0;
|
||||
if(!empty($search['employee'])){
|
||||
$where2[] = ['=','employee_id',$search['employee']];
|
||||
$employee = AcEmployee::find()->where(['id'=>$search['employee']])->one();
|
||||
$search['employee_title'] = $employee['name'];
|
||||
}
|
||||
|
||||
$search['channel'] = isset($search['channel']) ? (int)$search['channel'] : 0;
|
||||
$channels= Yii::$app->params['saleChannels'];
|
||||
if(!empty($search['channel'])){
|
||||
$where2[] = ['=','channel',$search['channel']];
|
||||
}
|
||||
|
||||
//入住时间筛选
|
||||
$search['checkin_m'] = isset($search['checkin_m']) ? $search['checkin_m'] : '';
|
||||
$search['checkin_after'] = isset($search['checkin_after']) ? $search['checkin_after'] : '';
|
||||
$search['checkin_before'] = isset($search['checkin_before']) ? $search['checkin_before'] : '';
|
||||
//按月份筛选
|
||||
if(!empty($search['checkin_m'])){
|
||||
$start = strtotime($search['checkin_m']);
|
||||
$s = date("Y-m-d H:i:s", $start);
|
||||
$ldm = strtotime("last day of ".$s);
|
||||
$m = date("Y-m-d",$ldm)." 23:59:59";
|
||||
$end = strtotime($m);
|
||||
$where2[] = ['between','last_checkin',$start,$end];
|
||||
}
|
||||
//按指定时段筛选
|
||||
elseif(!empty($search['checkin_after']) && !empty($search['checkin_before'])){
|
||||
$start = strtotime($search['checkin_after']);
|
||||
$end = strtotime($search['checkin_before']);
|
||||
$where2[] = ['between','last_checkin',$start,$end];
|
||||
}
|
||||
//按指定时间临界点筛选(以不早于为优先筛选条件)
|
||||
elseif(!empty($search['checkin_after'])){
|
||||
$start = strtotime($search['checkin_after']);
|
||||
$where2[] = ['>=','last_checkin',$start];
|
||||
}elseif(!empty($search['checkin_before'])){
|
||||
$end = strtotime($search['checkin_before']);
|
||||
$where2[] = ['<=','last_checkin',$end];
|
||||
}
|
||||
|
||||
//生日筛选
|
||||
$mids2 = [];
|
||||
$search['birthday_m'] = isset($search['birthday_m']) ? $search['birthday_m'] : '';
|
||||
$search['birthday_after'] = isset($search['birthday_after']) ? $search['birthday_after'] : '';
|
||||
$search['birthday_before'] = isset($search['birthday_before']) ? $search['birthday_before'] : '';
|
||||
//按月份筛选
|
||||
if(!empty($search['birthday_m'])){
|
||||
$start = strtotime($search['birthday_m']);
|
||||
$s = date("Y-m-d H:i:s", $start);
|
||||
$ldm = strtotime("last day of ".$s);
|
||||
$m = date("Y-m-d",$ldm)." 23:59:59";
|
||||
$end = strtotime($m);
|
||||
|
||||
$_mids = [];
|
||||
$_exts = LvUserExt::find()->where(['pid'=>$pid,'deleted'=>0,'key'=>'birthday'])->andwhere(['OR',['between','value',$start,$end]])->indexBy('id')->groupBy('mid')->all();
|
||||
foreach($_exts as $mid=>$ext){
|
||||
$_mids[$ext['mid']] = $ext['mid'];
|
||||
}
|
||||
$selectMid = true;
|
||||
$mids[] = $_mids;
|
||||
}
|
||||
//按指定时段筛选
|
||||
elseif(!empty($search['birthday_after']) && !empty($search['birthday_before'])){
|
||||
$start = strtotime($search['birthday_after']);
|
||||
$end = strtotime($search['birthday_before']);
|
||||
$_mids = [];
|
||||
$_exts = LvUserExt::find()->where(['pid'=>$pid,'deleted'=>0,'key'=>'birthday'])->andwhere(['OR',['between','value',$start,$end]])->indexBy('id')->groupBy('mid')->all();
|
||||
foreach($_exts as $mid=>$ext){
|
||||
$_mids[$ext['mid']] = $ext['mid'];
|
||||
}
|
||||
$selectMid = true;
|
||||
$mids[] = $_mids;
|
||||
}
|
||||
//按指定时间临界点筛选(以不早于为优先筛选条件)
|
||||
elseif(!empty($search['birthday_after'])){
|
||||
$start = strtotime($search['birthday_after']);
|
||||
$_mids = [];
|
||||
$_exts = LvUserExt::find()->where(['pid'=>$pid,'deleted'=>0,'key'=>'birthday'])->andwhere(['OR',['>=','value',$start]])->indexBy('id')->groupBy('mid')->all();
|
||||
foreach($_exts as $mid=>$ext){
|
||||
$_mids[$ext['mid']] = $ext['mid'];
|
||||
}
|
||||
$selectMid = true;
|
||||
$mids[] = $_mids;
|
||||
}elseif(!empty($search['birthday_before'])){
|
||||
$end = strtotime($search['birthday_before']);
|
||||
$_mids = [];
|
||||
$_exts = LvUserExt::find()->where(['pid'=>$pid,'deleted'=>0,'key'=>'birthday'])->andwhere(['OR',['<=','value',$end]])->indexBy('id')->groupBy('mid')->all();
|
||||
foreach($_exts as $mid=>$ext){
|
||||
$_mids[$ext['mid']] = $ext['mid'];
|
||||
}
|
||||
$selectMid = true;
|
||||
$mids[] = $_mids;
|
||||
}
|
||||
|
||||
if($selectMid){
|
||||
$mids2 = $mids[0];
|
||||
foreach($mids as $_mids){
|
||||
if($_mids){
|
||||
foreach($_mids as $mid){
|
||||
if(!in_array($mid,$mids2)){
|
||||
unset($_mids[$mid]);
|
||||
};
|
||||
$mids2 = $_mids;
|
||||
}
|
||||
}
|
||||
}
|
||||
$where2[] = ['IN','mid',$mids2];
|
||||
}
|
||||
|
||||
$where['deleted'] = 0;
|
||||
$data = $model->find()->where($where)->andwhere(['AND',$where2]);
|
||||
|
||||
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
|
||||
$res = $data->orderBy('id DESC')->offset($pages->offset)->limit($pages->limit)->indexBy('mid')->all();
|
||||
|
||||
$status = ['0'=>'隐藏','1'=>'显示'];
|
||||
$gender = ['0'=>'未设置','1'=>'男','2'=>'女'];
|
||||
|
||||
$model = new AcHotel();
|
||||
$where = [];
|
||||
$where['pid'] = Yii::$app->session->get('pid');
|
||||
$_hotels = $model->find()->where($where)->all();
|
||||
$hotels = [];
|
||||
foreach($_hotels as $s){
|
||||
$hotels[$s->id] = $s->toArray();
|
||||
}
|
||||
|
||||
$eids = $mids = [];
|
||||
foreach($res as $r){
|
||||
$r = $r->toArray();
|
||||
$eids[$r['employee_id']] = $r['employee_id'];
|
||||
$mids[$r['mid']] = $r['mid'];
|
||||
}
|
||||
|
||||
$model = new AcEmployee();
|
||||
$employees = [];
|
||||
$_employees = $model->find()->where(['in','id',$eids])->indexBy('id')->all();
|
||||
foreach($_employees as $s){
|
||||
$employees[$s->id] = $s->toArray();
|
||||
}
|
||||
|
||||
$model = new LvUserExt();
|
||||
$exts = [];
|
||||
$_exts = $model->find()->where(['in','mid',$mids])->andwhere(['pid'=>$pid,'deleted'=>0])->indexBy('id')->all();
|
||||
foreach($_exts as $ext){
|
||||
$ext = $ext->toArray();
|
||||
$exts[$ext['mid']][$ext['key']] = $ext['value'];
|
||||
}
|
||||
|
||||
$guests = [];
|
||||
foreach($res as $s){
|
||||
$s = $s->toArray();
|
||||
foreach($exts[$s['mid']] as $col=>$val){
|
||||
$s[$col] = $val;
|
||||
}
|
||||
$guests[] = $s;
|
||||
}
|
||||
|
||||
$model = new User();
|
||||
$users = [];
|
||||
$_users = $model->find()->where(['IN','id',$mids])->all();
|
||||
foreach($_users as $s){
|
||||
$s = $s->toArray();
|
||||
$users[$s['id']] = $s;
|
||||
}
|
||||
|
||||
return $this->render('list',[
|
||||
'guests' => $guests,
|
||||
'pager' => $pages,
|
||||
'employees'=>$employees,
|
||||
'hotels'=>$hotels,
|
||||
'exts'=>$exts,
|
||||
'users'=>$users,
|
||||
'status'=>$status,
|
||||
'gender'=>$gender,
|
||||
'search'=>$search,
|
||||
'total'=>$data->count(),
|
||||
]);
|
||||
}
|
||||
|
||||
//客户列表选择
|
||||
public function actionSelect()
|
||||
{
|
||||
return $this->render('../layouts/dev',[]);
|
||||
global $_HI,$_FM;
|
||||
$pid = Yii::$app->session->get('pid');
|
||||
$model = new AcCustomer();
|
||||
$where = $where2 = [];
|
||||
$where2[]='and';
|
||||
$where['pid'] = $pid;
|
||||
$post = Yii::$app->request->post();
|
||||
$search = [];
|
||||
$search['title'] = isset($post['title']) ? trim(htmlspecialchars_decode($post['title'])) : '';
|
||||
if(!empty($search['title'])){
|
||||
$where2[] = ['LIKE','name',$search['title']];
|
||||
}
|
||||
$where['deleted'] = 0;
|
||||
$data = $model->find()->where($where);
|
||||
if($search['title']){
|
||||
$data = $data->andwhere($where2);
|
||||
}
|
||||
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
|
||||
$res = $data->offset($pages->offset)->limit($pages->limit)->indexBy('mid')->all();
|
||||
$status = ['0'=>'隐藏','1'=>'显示'];
|
||||
$gender = ['0'=>'未设置','1'=>'男','2'=>'女'];
|
||||
|
||||
$model = new AcHotel();
|
||||
$where = [];
|
||||
$where['pid'] = Yii::$app->session->get('pid');
|
||||
$_hotels = $model->find()->where($where)->all();
|
||||
$hotels = [];
|
||||
foreach($_hotels as $s){
|
||||
$hotels[$s->id] = $s->toArray();
|
||||
}
|
||||
|
||||
$eids = $mids = [];
|
||||
foreach($res as $r){
|
||||
$eids[$r['employee_id']] = $r['employee_id'];
|
||||
$mids[$r['mid']] = $r['mid'];
|
||||
}
|
||||
|
||||
$model = new AcEmployee();
|
||||
$employees = [];
|
||||
$_employees = $model->find()->where(['in','id',$eids])->indexBy('id')->all();
|
||||
foreach($_employees as $s){
|
||||
$employees[$s->id] = $s->toArray();
|
||||
}
|
||||
|
||||
$model = new LvUserExt();
|
||||
$exts = [];
|
||||
$_exts = $model->find()->where(['in','mid',$mids])->andwhere(['pid'=>$pid,'deleted'=>0])->indexBy('id')->all();
|
||||
foreach($_exts as $ext){
|
||||
$ext = $ext->toArray();
|
||||
$exts[$ext['mid']][$ext['key']] = $ext['value'];
|
||||
}
|
||||
|
||||
$guests = [];
|
||||
foreach($res as $s){
|
||||
$s = $s->toArray();
|
||||
foreach($exts[$s['mid']] as $col=>$val){
|
||||
$s[$col] = $val;
|
||||
}
|
||||
$guests[$s['id']] = $s;
|
||||
}
|
||||
|
||||
$model = new User();
|
||||
$users = [];
|
||||
$_users = $model->find()->where(['in','id',$mids])->all();
|
||||
foreach($_users as $s){
|
||||
$s = $s->toArray();
|
||||
$users[$s['id']] = $s;
|
||||
}
|
||||
|
||||
$callback = !empty(Yii::$app->session->get('callback')) ? Yii::$app->session->get('callback') : 'carowner';
|
||||
return $this->render('select',[
|
||||
'guests' => $guests,
|
||||
'pager' => $pages,
|
||||
'employees'=>$employees,
|
||||
'hotels'=>$hotels,
|
||||
'exts'=>$exts,
|
||||
'users'=>$users,
|
||||
'status'=>$status,
|
||||
'gender'=>$gender,
|
||||
'search'=>$search,
|
||||
'callback'=>$callback
|
||||
]);
|
||||
}
|
||||
|
||||
//新增车主
|
||||
public function actionNew()
|
||||
{
|
||||
global $_HI,$_FM;
|
||||
return $this->render('modify',[]);
|
||||
}
|
||||
|
||||
//更新车主
|
||||
public function actionEdit()
|
||||
{
|
||||
global $_HI,$_FM;
|
||||
$model = new AcCustomer();
|
||||
$id = Yii::$app->request->get('id');
|
||||
$pid = Yii::$app->session->get('pid');
|
||||
$res = $model->find()->where(['id' => $id])->one();
|
||||
if($res){
|
||||
$res = $res->toArray();
|
||||
$res['last_checkin'] = $res['last_checkin'] ? date('Y-m-d',$res['last_checkin']) : '';
|
||||
$res['last_contact'] = $res['last_contact'] ? date('Y-m-d',$res['last_contact']) : '';
|
||||
$res['realname'] = $res['name'];
|
||||
}else{
|
||||
$res = [];
|
||||
}
|
||||
|
||||
//查询对应的系统用户
|
||||
$userModel = new User();
|
||||
$user = User::find()->where(['id'=>$res['mid']])->one();
|
||||
if($user){
|
||||
$res['mobile'] = $user->mobile;
|
||||
}
|
||||
|
||||
$hotel = AcHotel::find()->where(['id' => $res['hotel_id']])->one();
|
||||
if($hotel){
|
||||
$res['hotel_title'] = $hotel->title;
|
||||
}
|
||||
|
||||
$employee = AcEmployee::find()->where(['id' => $res['employee_id']])->one();
|
||||
if($employee){
|
||||
$res['employee_title'] = $employee->name;
|
||||
}
|
||||
|
||||
$exts = LvUserExt::find()->where(['mid' => $res['mid'],'pid'=>$pid,'deleted'=>0])->all();
|
||||
if($exts){
|
||||
foreach($exts as $ext){
|
||||
$res[$ext['key']] = $ext['value'];
|
||||
}
|
||||
}
|
||||
|
||||
return $this->render('modify',[
|
||||
'detail'=>$res,
|
||||
'id'=>$id,
|
||||
]);
|
||||
}
|
||||
|
||||
//保存车主资料
|
||||
public function actionSave()
|
||||
{
|
||||
$post = Yii::$app->request->post();
|
||||
$id = (int)$post['id'];
|
||||
$pid = Yii::$app->session->get('pid');
|
||||
if(!$post['mobile']){
|
||||
\Yii::$app->getSession()->setFlash('warning', '请输入主手机号码!');
|
||||
$url = Url::toRoute(['guest/edit','id'=>$id]);
|
||||
return $this->redirect(['new','id'=>$id]);
|
||||
}
|
||||
|
||||
$mobile = $post['mobile'];
|
||||
|
||||
//查询对应的系统用户
|
||||
$userModel = new User();
|
||||
$user = User::find()->where(['mobile'=>$mobile])->one();
|
||||
if(!$user){
|
||||
$pwd = isset($post['password']) ? trim($post['password']) : Yii::$app->params['defaultUserPassword'];
|
||||
$userModel->mobile = $mobile;
|
||||
$userModel->username = $mobile;
|
||||
$userModel->email = $mobile.'@hiluker.com';
|
||||
$userModel->setPassword($pwd);
|
||||
$userModel->generateAuthKey();
|
||||
$userModel->avatar = Yii::$app->params['defaultUserAvatar'];
|
||||
$userModel->created_at = time();
|
||||
$userModel->status = 1;
|
||||
$res = $userModel->save();
|
||||
// $res = $userModel->getErrors();
|
||||
$user_id = $userModel->attributes['id']; //获取插入后id
|
||||
}else{
|
||||
$user_id = $user->id;
|
||||
$pwd = isset($post['password']) ? trim($post['password']) : '';
|
||||
if($pwd){
|
||||
$user->setPassword($pwd);
|
||||
$user->generateAuthKey();
|
||||
$user->updated_at = time();
|
||||
$res = $user->save();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//格式化数据
|
||||
$data = [];
|
||||
//目标键=》POST键
|
||||
$cols = ['name'=>'realname','mobile'=>'mobile','idcard'=>'idcard','passport'=>'passport','country'=>'country','province'=>'province','channel'=>'channel','thumb'=>'thumb'];
|
||||
foreach($cols as $col=>$key){
|
||||
$data[$col] = isset($post[$key]) ? trim($post[$key]) : '';
|
||||
}
|
||||
|
||||
$cols = ['gender'=>'gender','total_fee'=>'total_fee','money'=>'money','jifen'=>'jifen','score'=>'score','hotel_id'=>'hotel','employee_id'=>'employee','status_code'=>'status_code','deleted'=>'deleted'];
|
||||
foreach($cols as $col=>$key){
|
||||
$data[$col] = isset($post[$key]) ? (int)$post[$key] : 0;
|
||||
}
|
||||
|
||||
$cols = ['last_checkin'=>'last_checkin','last_contact'=>'last_contact'];
|
||||
foreach($cols as $col=>$key){
|
||||
$data[$col] = isset($post[$key]) ? strtotime($post[$key]) : 0;
|
||||
}
|
||||
|
||||
$cols = ['remark'=>'editor'];
|
||||
foreach($cols as $col=>$key){
|
||||
$data[$col] = isset($post[$key]) ? htmlspecialchars($post[$key]) : '';
|
||||
}
|
||||
|
||||
$birthday = isset($post['ext']['birthday']) ? strtotime($post['ext']['birthday']) : 0;
|
||||
if($birthday){
|
||||
$data['birth_y'] = date('Y',$birthday);
|
||||
$data['birth_m'] = date('m',$birthday);
|
||||
$data['birth_d'] = date('d',$birthday);
|
||||
}
|
||||
|
||||
$data['create_at'] = time();
|
||||
$data['update_at'] = $data['create_at'];
|
||||
$data['pid'] = $pid;
|
||||
$data['mid'] = $user_id;
|
||||
|
||||
//格式化车主资料
|
||||
$AcCustomer = new AcCustomer();
|
||||
foreach($data as $key=>$val){
|
||||
$AcCustomer->$key = $val;
|
||||
}
|
||||
|
||||
//查询该客户是否在库
|
||||
$customer = AcCustomer::find()->where(['pid'=>$data['pid'],'mid'=>$data['mid']])->one();
|
||||
if($customer){
|
||||
$id = $customer->id;
|
||||
}
|
||||
|
||||
//客户资料入库
|
||||
if($id){
|
||||
$AcCustomer->id = $id;
|
||||
unset($data['create_at']);
|
||||
$res = $AcCustomer->updateAll($data,['id'=>$id]);
|
||||
}else{
|
||||
$res = $AcCustomer->save();
|
||||
$id = $AcCustomer->attributes['id']; //获取插入后id
|
||||
}
|
||||
|
||||
//保存扩展资料
|
||||
$LvUserExt = new LvUserExt();
|
||||
//批量软删
|
||||
$LvUserExt->updateAll(['deleted'=>1],['deleted'=>0,'pid'=>$pid,'mid'=>$user_id]);
|
||||
|
||||
$datas = [];
|
||||
$data = [];
|
||||
$exts = $post['ext'];
|
||||
foreach($exts as $col=>$val){
|
||||
$data['pid'] = $pid;
|
||||
$data['mid'] = $user_id;
|
||||
$data['key'] = $col;
|
||||
$data['mobile'] = $mobile;
|
||||
$data['value'] = trim($val);
|
||||
$datas[] = $data;
|
||||
}
|
||||
|
||||
//批量插入
|
||||
$model = clone $LvUserExt;
|
||||
foreach($datas as $attributes)
|
||||
{
|
||||
$model->isNewRecord = true;
|
||||
$model->setAttributes($attributes,false);
|
||||
$model->save() && $model->id=0;
|
||||
}
|
||||
|
||||
if($res){
|
||||
\Yii::$app->getSession()->setFlash('success', '用户资料保存成功!');
|
||||
return $this->redirect(['edit','id'=>$id]);
|
||||
}else{
|
||||
\Yii::$app->getSession()->setFlash('warning', '用户资料保存失败!');
|
||||
return $this->goBack();
|
||||
}
|
||||
}
|
||||
|
||||
//删除用户
|
||||
public function actionDelete($id)
|
||||
{
|
||||
global $_HI,$_FM;
|
||||
$get = Yii::$app->request->get();
|
||||
$post = Yii::$app->request->post();
|
||||
$id = (int)$get['id'];
|
||||
$data = $where = [];
|
||||
$where['pid'] = Yii::$app->session->get('pid');
|
||||
$where['id'] = $id;
|
||||
$data['update_at'] = time();
|
||||
$data['deleted'] = 1;
|
||||
|
||||
$model = new AcCustomer();
|
||||
foreach($data as $key=>$val){
|
||||
$model->$key = $val;
|
||||
}
|
||||
|
||||
$model->id = $id;
|
||||
$res = $model->updateAll($data,$where);
|
||||
|
||||
$return = [];
|
||||
$return['url'] = Url::toRoute('guest/list');
|
||||
// $return['url'] = Url::previous();
|
||||
$return['timeout'] = 3; //3秒后自动跳转
|
||||
$return['status'] = 0;
|
||||
if($res){
|
||||
$return['msg'] = '删除成功';
|
||||
$return['errorcode'] = 200;
|
||||
$return['data'] = $id;
|
||||
}else{
|
||||
$return['msg'] = '删除失败';
|
||||
$return['errorcode'] = 0;
|
||||
}
|
||||
exit(json_encode($return));
|
||||
}
|
||||
|
||||
//更新车主
|
||||
public function actionMsg()
|
||||
{
|
||||
global $_HI,$_FM;
|
||||
$model = new AcCustomer();
|
||||
$id = Yii::$app->request->get('id');
|
||||
$pid = Yii::$app->session->get('pid');
|
||||
$res = $model->find()->where(['id' => $id])->one();
|
||||
if($res){
|
||||
$res = $res->toArray();
|
||||
$res['last_checkin'] = $res['last_checkin'] ? date('Y-m-d',$res['last_checkin']) : '';
|
||||
$res['last_contact'] = $res['last_contact'] ? date('Y-m-d',$res['last_contact']) : '';
|
||||
$res['realname'] = $res['name'];
|
||||
}else{
|
||||
$res = [];
|
||||
}
|
||||
|
||||
//查询对应的系统用户
|
||||
$userModel = new User();
|
||||
$user = User::find()->where(['id'=>$res['mid']])->one();
|
||||
if($user){
|
||||
$res['mobile'] = $user->mobile;
|
||||
}
|
||||
|
||||
return $this->render('../layouts/dev',[]);
|
||||
|
||||
$hotel = AcHotel::find()->where(['id' => $res['hotel_id']])->one();
|
||||
if($hotel){
|
||||
$res['hotel_title'] = $hotel->title;
|
||||
}
|
||||
|
||||
$employee = AcEmployee::find()->where(['id' => $res['employee_id']])->one();
|
||||
if($employee){
|
||||
$res['employee_title'] = $employee->name;
|
||||
}
|
||||
|
||||
$exts = LvUserExt::find()->where(['mid' => $res['mid'],'pid'=>$pid,'deleted'=>0])->all();
|
||||
if($exts){
|
||||
foreach($exts as $ext){
|
||||
$res[$ext['key']] = $ext['value'];
|
||||
}
|
||||
}
|
||||
|
||||
return $this->render('modify',[
|
||||
'detail'=>$res,
|
||||
'id'=>$id,
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionAjax()
|
||||
{
|
||||
$get = Yii::$app->request->get();
|
||||
$post = Yii::$app->request->post();
|
||||
$id = (int)$get['id'];
|
||||
$data = $where = [];
|
||||
$where['pid'] = Yii::$app->session->get('pid');
|
||||
$where['id'] = $id;
|
||||
$data['update_at'] = time();
|
||||
|
||||
$model = new AcCustomer();
|
||||
$res = $model->find()->where(['id' => $id])->one();
|
||||
$return = [];
|
||||
$return['timeout'] = 1; //3秒后自动跳转
|
||||
$return['status_code'] = 0;
|
||||
$return['ajax'] = 1;
|
||||
if($res){
|
||||
$res = $res->toArray();
|
||||
}else{
|
||||
$return['msg'] = '客户数据不存在';
|
||||
$return['errorcode'] = 404;
|
||||
exit(json_encode($return));
|
||||
}
|
||||
|
||||
switch($get['do'])
|
||||
{
|
||||
case 'hide':
|
||||
$data['status_code'] = 0;
|
||||
$model->id = $id;
|
||||
$res = $model->updateAll($data,$where);
|
||||
if($res){
|
||||
$return['msg'] = '客户隐藏标记成功';
|
||||
$return['errorcode'] = 200;
|
||||
$return['data'] = ['css'=>'info'];
|
||||
}else{
|
||||
$return['msg'] = '客户隐藏标记失败';
|
||||
$return['errorcode'] = 0;
|
||||
}
|
||||
break;
|
||||
case 'show':
|
||||
$data['status_code'] = 1;
|
||||
$model->id = $id;
|
||||
$res = $model->updateAll($data,$where);
|
||||
if($res){
|
||||
$return['msg'] = '客户显示标记成功';
|
||||
$return['errorcode'] = 200;
|
||||
$return['data'] = ['css'=>'default'];
|
||||
}else{
|
||||
$return['msg'] = '客户显示标记失败';
|
||||
$return['errorcode'] = 0;
|
||||
}
|
||||
break;
|
||||
case 'contact':
|
||||
$data['last_contact'] = time();
|
||||
$model->id = $id;
|
||||
$res = $model->updateAll($data,$where);
|
||||
if($res){
|
||||
$return['msg'] = '标记成功';
|
||||
$return['errorcode'] = 200;
|
||||
$return['data'] = ['css'=>'default'];
|
||||
}else{
|
||||
$return['msg'] = '标记失败';
|
||||
$return['errorcode'] = 0;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$return['msg'] = '无效的操作';
|
||||
$return['errorcode'] = 200;
|
||||
$return['data'] = ['css'=>'info'];
|
||||
break;
|
||||
}
|
||||
exit(json_encode($return));
|
||||
}
|
||||
|
||||
}
|
||||
Executable
+334
@@ -0,0 +1,334 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @Author: fm453
|
||||
* @Date: 2018-12-02 11:40:44
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2021-09-15T15:53:42+08:00
|
||||
* @Email: fm453@lukegzs.com
|
||||
*/
|
||||
|
||||
namespace backend\controllers;
|
||||
|
||||
use Yii;
|
||||
use yii\data\Pagination;
|
||||
use yii\helpers\Url;
|
||||
use common\models\Member;
|
||||
use backend\models\FmUserExt as UserExt;
|
||||
use backend\models\FmEmployee as Employee;
|
||||
use backend\models\FmHotel as Hotel;
|
||||
use backend\models\FmStore as Store;
|
||||
|
||||
class EmployeeController extends \yii\web\Controller
|
||||
{
|
||||
//替代常规的_construct 析构函数;其他方法调用前执行
|
||||
public function init()
|
||||
{
|
||||
parent::init();
|
||||
$session = Yii::$app->session;
|
||||
if(isset($_GET['pid']) && (int)$_GET['pid']>0){
|
||||
$session->set('pid',(int)$_GET['pid']);
|
||||
}
|
||||
$pid = $session->get('pid');
|
||||
if(!$pid){
|
||||
$url = Url::toRoute('/index/index');
|
||||
return $this->redirect($url);
|
||||
}
|
||||
}
|
||||
|
||||
public function actionIndex()
|
||||
{
|
||||
return $this->render('index');
|
||||
}
|
||||
|
||||
//用户列表
|
||||
public function actionList()
|
||||
{
|
||||
$model = new Employee();
|
||||
$where = $where2 = [];
|
||||
$where2[]='and';
|
||||
$where['pid'] = Yii::$app->session->get('pid');
|
||||
$post = Yii::$app->request->post();
|
||||
$search = [];
|
||||
$search['title'] = isset($post['title']) ? trim(htmlspecialchars_decode($post['title'])) : '';
|
||||
if(!empty($search['title'])){
|
||||
$where2[] = ['LIKE','name',$search['title']];
|
||||
}
|
||||
$where['deleted'] = 0;
|
||||
$data = $model->find()->where($where);
|
||||
if($search['title']){
|
||||
$data = $data->andwhere($where2);
|
||||
}
|
||||
|
||||
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
|
||||
$res = $data->offset($pages->offset)->limit($pages->limit)->all();
|
||||
$status = ['0'=>'离职','1'=>'在职'];
|
||||
$gender = ['0'=>'未设置','1'=>'男','2'=>'女'];
|
||||
|
||||
$model = new Hotel();
|
||||
$where = [];
|
||||
$where['pid'] = Yii::$app->session->get('pid');
|
||||
$_hotels = $model->find()->where($where)->all();
|
||||
$hotels = [];
|
||||
foreach($_hotels as $s){
|
||||
$hotels[$s->id] = $s->toArray();
|
||||
}
|
||||
return $this->render('list',[
|
||||
'employees'=>$res,
|
||||
'pager' => $pages,
|
||||
'hotels'=>$hotels,
|
||||
'status'=>$status,
|
||||
'gender'=>$gender,
|
||||
'search'=>$search
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionSelect()
|
||||
{
|
||||
$model = new Employee();
|
||||
$where = $where2 = [];
|
||||
$where2[]='and';
|
||||
$where['pid'] = Yii::$app->session->get('pid');
|
||||
$post = Yii::$app->request->post();
|
||||
$search = [];
|
||||
$search['title'] = isset($post['title']) ? trim(htmlspecialchars_decode($post['title'])) : '';
|
||||
if(!empty($search['title'])){
|
||||
$where2[] = ['LIKE','name',$search['title']];
|
||||
}
|
||||
$where['deleted'] = 0;
|
||||
$data = $model->find()->where($where);
|
||||
if($search['title']){
|
||||
$data = $data->andwhere($where2);
|
||||
}
|
||||
|
||||
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
|
||||
$res = $data->offset($pages->offset)->limit($pages->limit)->all();
|
||||
$status = ['0'=>'离职','1'=>'在职'];
|
||||
$gender = ['0'=>'未设置','1'=>'男','2'=>'女'];
|
||||
$model = new AcHotel();
|
||||
$where = [];
|
||||
$where['pid'] = Yii::$app->session->get('pid');
|
||||
$_hotels = $model->find()->where($where)->all();
|
||||
$hotels = [];
|
||||
foreach($_hotels as $s){
|
||||
$hotels[$s->id] = $s->toArray();
|
||||
}
|
||||
$callback = !empty(Yii::$app->session->get('callback')) ? Yii::$app->session->get('callback') : 'employee';
|
||||
return $this->render('select',[
|
||||
'employees'=>$res,
|
||||
'pager' => $pages,
|
||||
'hotels'=>$hotels,
|
||||
'status'=>$status,
|
||||
'gender'=>$gender,
|
||||
'search'=>$search,
|
||||
'callback'=>$callback
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionNew()
|
||||
{
|
||||
return $this->render('modify',[]);
|
||||
}
|
||||
|
||||
//编辑员工资料
|
||||
public function actionEdit()
|
||||
{
|
||||
$model = new Employee();
|
||||
$id = Yii::$app->request->get('id');
|
||||
$res = $model->find()->where(['id' => $id])->one();
|
||||
if($res){
|
||||
$res = $res->toArray();
|
||||
}
|
||||
|
||||
$store = Store::find()->where(['id' => $res['store_id']])->one();
|
||||
if($store){
|
||||
$res['store_title'] = $store->title;
|
||||
}
|
||||
return $this->render('modify',['detail'=>$res]);
|
||||
}
|
||||
|
||||
//保存员工资料
|
||||
public function actionSave()
|
||||
{
|
||||
$post = Yii::$app->request->post();
|
||||
$id = (int)$post['id'];
|
||||
$pid = Yii::$app->session->get('pid');
|
||||
//格式化数据
|
||||
//目标键=》POST键
|
||||
$cols = ['name'=>'name','mobile'=>'mobile'];
|
||||
foreach($cols as $col=>$key){
|
||||
$data[$col] = isset($post[$key]) ? trim($post[$key]) : '';
|
||||
}
|
||||
$cols = ['gender'=>'gender','status'=>'status','store_id'=>'store','deleted'=>'deleted'];
|
||||
foreach($cols as $col=>$key){
|
||||
$data[$col] = isset($post[$key]) ? (int)$post[$key] : 0;
|
||||
}
|
||||
$cols = ['remark'=>'editor'];
|
||||
foreach($cols as $col=>$key){
|
||||
$data[$col] = isset($post[$key]) ? htmlspecialchars($post[$key]) : '';
|
||||
}
|
||||
$data['create_at'] = time();
|
||||
$data['update_at'] = $data['create_at'];
|
||||
$data['status_code'] = 1;
|
||||
$data['pid'] = $pid;
|
||||
|
||||
//保存员工资料
|
||||
$AcEmployee = new Employee();
|
||||
foreach($data as $key=>$val){
|
||||
$AcEmployee->$key = $val;
|
||||
}
|
||||
|
||||
//查询员工手机号是否在库
|
||||
$employee = Employee::find()->where(['mobile'=>$data['mobile']])->one();
|
||||
if($employee){
|
||||
$id = $employee->id;
|
||||
}
|
||||
|
||||
if($id){
|
||||
$AcEmployee->id = $id;
|
||||
unset($data['create_at']);
|
||||
$res = $AcEmployee->updateAll($data,['id'=>$id]);
|
||||
}else{
|
||||
$res = $AcEmployee->save();
|
||||
$id = $AcEmployee->attributes['id']; //获取插入后id
|
||||
}
|
||||
|
||||
//查询员工对应的系统用户
|
||||
$MemberModel = new Member();
|
||||
$user = $MemberModel->find()->where(['mobile'=>$data['mobile']])->one();
|
||||
if(empty($user)){
|
||||
$MemberModel->username = !$data['name'] ? $data['mobile'] : $data['name'];
|
||||
$MemberModel->mobile = $data['mobile'];
|
||||
$MemberModel->email = $data['mobile'].'@hiluker.com';
|
||||
$MemberModel->setPassword(Yii::$app->params['defaultUserPassword']);
|
||||
$MemberModel->generateAuthKey();
|
||||
$MemberModel->avatar = Yii::$app->params['defaultUserAvatar'];
|
||||
$MemberModel->created_at = time();
|
||||
$MemberModel->status = 1;
|
||||
$MemberModel->save();
|
||||
$user_id = $MemberModel->attributes['id']; //获取插入后id
|
||||
if($user_id)
|
||||
{
|
||||
\Yii::$app->getSession()->setFlash('info', '已成功注册该账号!');
|
||||
}
|
||||
}
|
||||
|
||||
$return = [];
|
||||
if($res){
|
||||
$return['msg'] = '员工信息保存成功';
|
||||
$return['errorcode'] = 200;
|
||||
$return['url'] = Url::toRoute(['employee/edit','id'=>$id]);
|
||||
$return['buttons'] = [
|
||||
['title'=>'好的,我知道了','class'=>'primary','url'=>$return['url']]
|
||||
];
|
||||
}else{
|
||||
$return['msg'] = '员工信息保存失败';
|
||||
$return['errorcode'] = 0;
|
||||
$return['url'] = Url::toRoute(['employee/new',$post]);
|
||||
$return['buttons'] = [
|
||||
['title'=>'好的,我知道了','class'=>'info','url'=>$return['url']]
|
||||
];
|
||||
}
|
||||
|
||||
$classes = ['0'=>'warning','200'=>'success'];
|
||||
$return['content'] = $return['msg'];
|
||||
$return['class'] = $classes[$return['errorcode']];
|
||||
|
||||
Yii::$app->request->setBodyParams($return);
|
||||
return Yii::$app->runAction('index/msg');
|
||||
}
|
||||
|
||||
//删除员工
|
||||
public function actionDelete()
|
||||
{
|
||||
$get = Yii::$app->request->get();
|
||||
$post = Yii::$app->request->post();
|
||||
$id = (int)$get['id'];
|
||||
$data = $where = [];
|
||||
$where['pid'] = Yii::$app->session->get('pid');
|
||||
$where['id'] = $id;
|
||||
$data['update_at'] = time();
|
||||
$data['deleted'] = 1;
|
||||
|
||||
$model = new Employee();
|
||||
foreach($data as $key=>$val){
|
||||
$model->$key = $val;
|
||||
}
|
||||
|
||||
$model->id = $id;
|
||||
$res = $model->updateAll($data,$where);
|
||||
|
||||
$return = [];
|
||||
$return['url'] = Url::toRoute('employee/list');
|
||||
$return['timeout'] = 3; //3秒后自动跳转
|
||||
$return['status'] = 0;
|
||||
if($res){
|
||||
$return['msg'] = '员工删除成功';
|
||||
$return['errorcode'] = 200;
|
||||
$return['data'] = $id;
|
||||
}else{
|
||||
$return['msg'] = '员工删除失败';
|
||||
$return['errorcode'] = 0;
|
||||
}
|
||||
exit(json_encode($return));
|
||||
}
|
||||
|
||||
public function actionAjax()
|
||||
{
|
||||
$get = Yii::$app->request->get();
|
||||
$post = Yii::$app->request->post();
|
||||
$id = (int)$get['id'];
|
||||
$data = $where = [];
|
||||
$where['pid'] = Yii::$app->session->get('pid');
|
||||
$where['id'] = $id;
|
||||
$data['update_at'] = time();
|
||||
|
||||
$model = new Employee();
|
||||
$res = $model->find()->where(['id' => $id])->one();
|
||||
$return = [];
|
||||
$return['timeout'] = 1; //3秒后自动跳转
|
||||
$return['status'] = 0;
|
||||
$return['ajax'] = 1;
|
||||
if($res){
|
||||
$res = $res->toArray();
|
||||
}else{
|
||||
$return['msg'] = '员工数据不存在';
|
||||
$return['errorcode'] = 404;
|
||||
exit(json_encode($return));
|
||||
}
|
||||
|
||||
switch($get['do'])
|
||||
{
|
||||
case 'out':
|
||||
$data['status'] = 0;
|
||||
$model->id = $id;
|
||||
$res = $model->updateAll($data,$where);
|
||||
if($res){
|
||||
$return['msg'] = '员工离职标记成功';
|
||||
$return['errorcode'] = 200;
|
||||
$return['data'] = ['css'=>'info'];
|
||||
}else{
|
||||
$return['msg'] = '员工离职标记失败';
|
||||
$return['errorcode'] = 0;
|
||||
}
|
||||
break;
|
||||
case 'in':
|
||||
$data['status'] = 1;
|
||||
$model->id = $id;
|
||||
$res = $model->updateAll($data,$where);
|
||||
if($res){
|
||||
$return['msg'] = '员工在职标记成功';
|
||||
$return['errorcode'] = 200;
|
||||
$return['data'] = ['css'=>'default'];
|
||||
}else{
|
||||
$return['msg'] = '员工在职标记失败';
|
||||
$return['errorcode'] = 0;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
exit(json_encode($return));
|
||||
}
|
||||
|
||||
}
|
||||
Executable
+77
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @Author: fm453
|
||||
* @Date: 2018-08-17 19:39:41
|
||||
* @Last Modified by: fm453
|
||||
* @Last Modified time: 2018-10-09 04:42:25
|
||||
* @Email: fm453@lukegzs.com
|
||||
*/
|
||||
namespace backend\controllers;
|
||||
|
||||
use Yii;
|
||||
use yii\data\Pagination;
|
||||
use yii\helpers\Url;
|
||||
|
||||
class ErrorController extends \yii\web\Controller
|
||||
{
|
||||
public $enableCsrfValidation = false; //取消csrf令牌验证;
|
||||
//主界面
|
||||
public function actionIndex()
|
||||
{
|
||||
return $this->render('../layouts/dev',[]);
|
||||
}
|
||||
|
||||
public function actionReport()
|
||||
{
|
||||
$request = Yii::$app->request;
|
||||
$get = $request->get();
|
||||
$url = Urldecode($get['url']);
|
||||
$code = 0;
|
||||
if($request->isPost){
|
||||
$code = getMillisecond().'_'.rand(0,999);
|
||||
$filename = $code.'.php';
|
||||
$post = $request->post();
|
||||
$code = $post['code']!=0 ? $post['code'] : $code;
|
||||
$post['time'] = time();
|
||||
fm_load()->fm_func('error');
|
||||
fmFunc_error_write($filename,$post);
|
||||
|
||||
$msg = [];
|
||||
$msg['title'] = '报错提交通知';
|
||||
$msg['content'] = '感谢反馈,工程师将尽快处理!您本次的反馈工单号为<code>'.$code.'</code>';
|
||||
$msg['class'] = 'success';
|
||||
$btn = [];
|
||||
$btn['title'] = '返回';
|
||||
// $btn['url'] = Url::current();
|
||||
$btn['url'] = $url;
|
||||
$btn['class'] = 'primary';
|
||||
$msg['buttons'][] = $btn;
|
||||
$btn = [];
|
||||
$btn['title'] = '查看工单';
|
||||
$btn['url'] = Url::toRoute(['error/order','code'=>$code]);
|
||||
$btn['class'] = 'warning';
|
||||
$msg['buttons'][] = $btn;
|
||||
$btn = [];
|
||||
$btn['title'] = '回到首页';
|
||||
$btn['url'] = Url::home();
|
||||
$btn['class'] = 'info';
|
||||
$msg['buttons'][] = $btn;
|
||||
return $this->render('../layouts/msg',$msg);
|
||||
}
|
||||
return $this->render('report',['url'=>$url]);
|
||||
}
|
||||
|
||||
public function actionOrder()
|
||||
{
|
||||
$request = Yii::$app->request;
|
||||
$get = $request->get();
|
||||
$code = Urldecode($get['code']);
|
||||
$filename = $code.'.php';
|
||||
fm_load()->fm_func('error');
|
||||
$data = [];
|
||||
$file = fmFunc_error_get($code);
|
||||
include $file;
|
||||
return $this->render('report',['code'=>$code,'data'=>$data,'url'=>$data['url']]);
|
||||
}
|
||||
}
|
||||
Executable
+63
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @Author: fm453
|
||||
* @Date: 2018-08-17 19:39:41
|
||||
* @Last Modified by: fm453
|
||||
* @Last Modified time: 2021-04-28 17:28:29
|
||||
* @Email: fm453@lukegzs.com
|
||||
*/
|
||||
namespace backend\controllers;
|
||||
|
||||
use Yii;
|
||||
use yii\data\Pagination;
|
||||
use yii\helpers\Url;
|
||||
|
||||
class FeeController extends \yii\web\Controller
|
||||
{
|
||||
//替代常规的_construct 析构函数;其他方法调用前执行
|
||||
public function init()
|
||||
{
|
||||
parent::init();
|
||||
$session = Yii::$app->session;
|
||||
if(isset($_GET['pid']) && (int)$_GET['pid']>0){
|
||||
$session->set('pid',(int)$_GET['pid']);
|
||||
}
|
||||
$pid = $session->get('pid');
|
||||
if(!$pid){
|
||||
$url = Url::toRoute('/index/index');
|
||||
return $this->redirect($url);
|
||||
}
|
||||
}
|
||||
//主界面
|
||||
public function actionIndex()
|
||||
{
|
||||
return $this->render('../layouts/dev',[]);
|
||||
}
|
||||
|
||||
public function actionOrder()
|
||||
{
|
||||
return $this->render('../layouts/dev',[]);
|
||||
}
|
||||
|
||||
public function actionRoom()
|
||||
{
|
||||
return $this->render('../layouts/dev',[]);
|
||||
}
|
||||
|
||||
public function actionIncidental()
|
||||
{
|
||||
return $this->render('../layouts/dev',[]);
|
||||
}
|
||||
|
||||
public function actionSale()
|
||||
{
|
||||
return $this->render('../layouts/dev',[]);
|
||||
}
|
||||
|
||||
public function actionOther()
|
||||
{
|
||||
return $this->render('../layouts/dev',[]);
|
||||
}
|
||||
|
||||
}
|
||||
Executable
+711
@@ -0,0 +1,711 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @Author: fm453
|
||||
* @Date: 2018-11-22 03:40:46
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2021-09-15T16:37:16+08:00
|
||||
* @Email: fm453@lukegzs.com
|
||||
*/
|
||||
namespace backend\controllers;
|
||||
|
||||
use Yii;
|
||||
use yii\data\Pagination;
|
||||
use yii\helpers\Url;
|
||||
use common\models\Fans;
|
||||
use backend\models\FmCustomer as Customer;
|
||||
use backend\models\FmUserExt as UserExt;
|
||||
use backend\models\FmHotel as Hotel;
|
||||
use backend\models\FmRoom as Room;
|
||||
use backend\models\FmEmployee as Employee;
|
||||
|
||||
class GuestController extends \yii\web\Controller
|
||||
{
|
||||
//替代常规的_construct 析构函数;其他方法调用前执行
|
||||
public function init()
|
||||
{
|
||||
parent::init();
|
||||
$session = Yii::$app->session;
|
||||
if(isset($_GET['pid']) && (int)$_GET['pid']>0){
|
||||
$session->set('pid',(int)$_GET['pid']);
|
||||
}
|
||||
$pid = $session->get('pid');
|
||||
if(!$pid){
|
||||
$url = Url::toRoute('/index/index');
|
||||
return $this->redirect($url);
|
||||
}
|
||||
}
|
||||
|
||||
//主界面
|
||||
public function actionIndex()
|
||||
{
|
||||
global $_HI,$_FM;
|
||||
return $this->render('../layouts/dev',[]);
|
||||
|
||||
}
|
||||
|
||||
//客户列表
|
||||
public function actionList()
|
||||
{
|
||||
global $_HI,$_FM;
|
||||
$pid = Yii::$app->session->get('pid');
|
||||
$model = new Customer();
|
||||
$where = $where2 = [];
|
||||
$where2[]='and';
|
||||
$where['pid'] = $pid;
|
||||
$post = Yii::$app->request->post();
|
||||
$search = isset($post['search']) ? $post['search'] : [];
|
||||
$page = isset($_GET['page']) ? (int)$_GET['page'] : 0;
|
||||
$session = Yii::$app->session;
|
||||
if($page==0){
|
||||
$session->set('Guest:List:'.$pid,$search);
|
||||
}else{
|
||||
$search = $search ? $search : $session->get('Guest:List:'.$pid);
|
||||
}
|
||||
|
||||
$search['title'] = isset($search['title']) ? trim(htmlspecialchars_decode($search['title'])) : '';
|
||||
if(!empty($search['title'])){
|
||||
$where2[] = ['LIKE','name',$search['title']];
|
||||
}
|
||||
|
||||
$selectMid = false;
|
||||
$mids = [];
|
||||
$search['nickname'] = isset($search['nickname']) ? trim(htmlspecialchars_decode($search['nickname'])) : '';
|
||||
if(!empty($search['nickname'])){
|
||||
$_mids = [];
|
||||
$_exts = UserExt::find()->where(['pid'=>$pid,'deleted'=>0,'key'=>'nickname'])->andwhere(['OR',['LIKE','value',$search['nickname']]])->indexBy('id')->groupBy('mid')->all();
|
||||
foreach($_exts as $mid=>$ext){
|
||||
$_mids[$ext['mid']] = $ext['mid'];
|
||||
}
|
||||
$selectMid = true;
|
||||
$mids[] = $_mids;
|
||||
}
|
||||
|
||||
$search['phone'] = isset($search['phone']) ? trim(htmlspecialchars_decode($search['phone'])) : '';
|
||||
if(!empty($search['phone'])){
|
||||
$where2[] = ['LIKE','mobile',$search['phone']];
|
||||
}
|
||||
|
||||
$search['hotel'] = isset($search['hotel']) ? (int)$search['hotel'] : 0;
|
||||
if(!empty($search['hotel'])){
|
||||
$where2[] = ['=','hotel_id',$search['hotel']];
|
||||
$hotel = AcHotel::find()->where(['id'=>$search['hotel']])->one();
|
||||
$search['hotel_title'] = $hotel['title'];
|
||||
}
|
||||
|
||||
$search['employee'] = isset($search['employee']) ? (int)$search['employee'] : 0;
|
||||
if(!empty($search['employee'])){
|
||||
$where2[] = ['=','employee_id',$search['employee']];
|
||||
$employee = Employee::find()->where(['id'=>$search['employee']])->one();
|
||||
$search['employee_title'] = $employee['name'];
|
||||
}
|
||||
|
||||
$search['channel'] = isset($search['channel']) ? (int)$search['channel'] : 0;
|
||||
$channels= Yii::$app->params['saleChannels'];
|
||||
if(!empty($search['channel'])){
|
||||
$where2[] = ['=','channel',$search['channel']];
|
||||
}
|
||||
|
||||
//入住时间筛选
|
||||
$search['checkin_m'] = isset($search['checkin_m']) ? $search['checkin_m'] : '';
|
||||
$search['checkin_after'] = isset($search['checkin_after']) ? $search['checkin_after'] : '';
|
||||
$search['checkin_before'] = isset($search['checkin_before']) ? $search['checkin_before'] : '';
|
||||
//按月份筛选
|
||||
if(!empty($search['checkin_m'])){
|
||||
$start = strtotime($search['checkin_m']);
|
||||
$s = date("Y-m-d H:i:s", $start);
|
||||
$ldm = strtotime("last day of ".$s);
|
||||
$m = date("Y-m-d",$ldm)." 23:59:59";
|
||||
$end = strtotime($m);
|
||||
$where2[] = ['between','last_checkin',$start,$end];
|
||||
}
|
||||
//按指定时段筛选
|
||||
elseif(!empty($search['checkin_after']) && !empty($search['checkin_before'])){
|
||||
$start = strtotime($search['checkin_after']);
|
||||
$end = strtotime($search['checkin_before']);
|
||||
$where2[] = ['between','last_checkin',$start,$end];
|
||||
}
|
||||
//按指定时间临界点筛选(以不早于为优先筛选条件)
|
||||
elseif(!empty($search['checkin_after'])){
|
||||
$start = strtotime($search['checkin_after']);
|
||||
$where2[] = ['>=','last_checkin',$start];
|
||||
}elseif(!empty($search['checkin_before'])){
|
||||
$end = strtotime($search['checkin_before']);
|
||||
$where2[] = ['<=','last_checkin',$end];
|
||||
}
|
||||
|
||||
//生日筛选
|
||||
$mids2 = [];
|
||||
$search['birthday_m'] = isset($search['birthday_m']) ? $search['birthday_m'] : '';
|
||||
$search['birthday_after'] = isset($search['birthday_after']) ? $search['birthday_after'] : '';
|
||||
$search['birthday_before'] = isset($search['birthday_before']) ? $search['birthday_before'] : '';
|
||||
//按月份筛选
|
||||
if(!empty($search['birthday_m'])){
|
||||
$start = strtotime($search['birthday_m']);
|
||||
$s = date("Y-m-d H:i:s", $start);
|
||||
$ldm = strtotime("last day of ".$s);
|
||||
$m = date("Y-m-d",$ldm)." 23:59:59";
|
||||
$end = strtotime($m);
|
||||
|
||||
$_mids = [];
|
||||
$_exts = UserExt::find()->where(['pid'=>$pid,'deleted'=>0,'key'=>'birthday'])->andwhere(['OR',['between','value',$start,$end]])->indexBy('id')->groupBy('mid')->all();
|
||||
foreach($_exts as $mid=>$ext){
|
||||
$_mids[$ext['mid']] = $ext['mid'];
|
||||
}
|
||||
$selectMid = true;
|
||||
$mids[] = $_mids;
|
||||
}
|
||||
//按指定时段筛选
|
||||
elseif(!empty($search['birthday_after']) && !empty($search['birthday_before'])){
|
||||
$start = strtotime($search['birthday_after']);
|
||||
$end = strtotime($search['birthday_before']);
|
||||
$_mids = [];
|
||||
$_exts = UserExt::find()->where(['pid'=>$pid,'deleted'=>0,'key'=>'birthday'])->andwhere(['OR',['between','value',$start,$end]])->indexBy('id')->groupBy('mid')->all();
|
||||
foreach($_exts as $mid=>$ext){
|
||||
$_mids[$ext['mid']] = $ext['mid'];
|
||||
}
|
||||
$selectMid = true;
|
||||
$mids[] = $_mids;
|
||||
}
|
||||
//按指定时间临界点筛选(以不早于为优先筛选条件)
|
||||
elseif(!empty($search['birthday_after'])){
|
||||
$start = strtotime($search['birthday_after']);
|
||||
$_mids = [];
|
||||
$_exts = AcUserExt::find()->where(['pid'=>$pid,'deleted'=>0,'key'=>'birthday'])->andwhere(['OR',['>=','value',$start]])->indexBy('id')->groupBy('mid')->all();
|
||||
foreach($_exts as $mid=>$ext){
|
||||
$_mids[$ext['mid']] = $ext['mid'];
|
||||
}
|
||||
$selectMid = true;
|
||||
$mids[] = $_mids;
|
||||
}elseif(!empty($search['birthday_before'])){
|
||||
$end = strtotime($search['birthday_before']);
|
||||
$_mids = [];
|
||||
$_exts = UserExt::find()->where(['pid'=>$pid,'deleted'=>0,'key'=>'birthday'])->andwhere(['OR',['<=','value',$end]])->indexBy('id')->groupBy('mid')->all();
|
||||
foreach($_exts as $mid=>$ext){
|
||||
$_mids[$ext['mid']] = $ext['mid'];
|
||||
}
|
||||
$selectMid = true;
|
||||
$mids[] = $_mids;
|
||||
}
|
||||
|
||||
if($selectMid){
|
||||
$mids2 = $mids[0];
|
||||
foreach($mids as $_mids){
|
||||
if($_mids){
|
||||
foreach($_mids as $mid){
|
||||
if(!in_array($mid,$mids2)){
|
||||
unset($_mids[$mid]);
|
||||
};
|
||||
$mids2 = $_mids;
|
||||
}
|
||||
}
|
||||
}
|
||||
$where2[] = ['IN','mid',$mids2];
|
||||
}
|
||||
|
||||
$where['deleted'] = 0;
|
||||
$data = $model->find()->where($where)->andwhere(['AND',$where2]);
|
||||
|
||||
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
|
||||
$res = $data->orderBy('id DESC')->offset($pages->offset)->limit($pages->limit)->indexBy('mid')->all();
|
||||
|
||||
$status = ['0'=>'隐藏','1'=>'显示'];
|
||||
$gender = ['0'=>'未设置','1'=>'男','2'=>'女'];
|
||||
|
||||
$model = new Hotel();
|
||||
$where = [];
|
||||
$where['pid'] = Yii::$app->session->get('pid');
|
||||
$_hotels = $model->find()->where($where)->all();
|
||||
$hotels = [];
|
||||
foreach($_hotels as $s){
|
||||
$hotels[$s->id] = $s->toArray();
|
||||
}
|
||||
|
||||
$eids = $mids = [];
|
||||
foreach($res as $r){
|
||||
$r = $r->toArray();
|
||||
$eids[$r['employee_id']] = $r['employee_id'];
|
||||
$mids[$r['mid']] = $r['mid'];
|
||||
}
|
||||
|
||||
$model = new Employee();
|
||||
$employees = [];
|
||||
$_employees = $model->find()->where(['in','id',$eids])->indexBy('id')->all();
|
||||
foreach($_employees as $s){
|
||||
$employees[$s->id] = $s->toArray();
|
||||
}
|
||||
|
||||
$model = new UserExt();
|
||||
$exts = [];
|
||||
$_exts = $model->find()->where(['in','mid',$mids])->andwhere(['pid'=>$pid,'deleted'=>0])->indexBy('id')->all();
|
||||
foreach($_exts as $ext){
|
||||
$ext = $ext->toArray();
|
||||
$exts[$ext['mid']][$ext['key']] = $ext['value'];
|
||||
}
|
||||
|
||||
$guests = [];
|
||||
foreach($res as $s){
|
||||
$s = $s->toArray();
|
||||
foreach($exts[$s['mid']] as $col=>$val){
|
||||
$s[$col] = $val;
|
||||
}
|
||||
$guests[] = $s;
|
||||
}
|
||||
|
||||
$model = new Fans();
|
||||
$users = [];
|
||||
$_users = $model->find()->where(['IN','id',$mids])->all();
|
||||
foreach($_users as $s){
|
||||
$s = $s->toArray();
|
||||
$users[$s['id']] = $s;
|
||||
}
|
||||
|
||||
return $this->render('list',[
|
||||
'guests' => $guests,
|
||||
'pager' => $pages,
|
||||
'employees'=>$employees,
|
||||
'hotels'=>$hotels,
|
||||
'exts'=>$exts,
|
||||
'users'=>$users,
|
||||
'status'=>$status,
|
||||
'gender'=>$gender,
|
||||
'search'=>$search,
|
||||
'total'=>$data->count(),
|
||||
]);
|
||||
}
|
||||
|
||||
//客户列表选择
|
||||
public function actionSelect()
|
||||
{
|
||||
global $_HI,$_FM;
|
||||
$pid = Yii::$app->session->get('pid');
|
||||
$model = new Customer();
|
||||
$where = $where2 = [];
|
||||
$where2[]='and';
|
||||
$where['pid'] = $pid;
|
||||
$post = Yii::$app->request->post();
|
||||
$search = [];
|
||||
$search['title'] = isset($post['title']) ? trim(htmlspecialchars_decode($post['title'])) : '';
|
||||
if(!empty($search['title'])){
|
||||
$where2[] = ['LIKE','name',$search['title']];
|
||||
}
|
||||
$where['deleted'] = 0;
|
||||
$data = $model->find()->where($where);
|
||||
if($search['title']){
|
||||
$data = $data->andwhere($where2);
|
||||
}
|
||||
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
|
||||
$res = $data->offset($pages->offset)->limit($pages->limit)->indexBy('mid')->all();
|
||||
$status = ['0'=>'隐藏','1'=>'显示'];
|
||||
$gender = ['0'=>'未设置','1'=>'男','2'=>'女'];
|
||||
|
||||
$model = new Hotel();
|
||||
$where = [];
|
||||
$where['pid'] = Yii::$app->session->get('pid');
|
||||
$_hotels = $model->find()->where($where)->all();
|
||||
$hotels = [];
|
||||
foreach($_hotels as $s){
|
||||
$hotels[$s->id] = $s->toArray();
|
||||
}
|
||||
|
||||
$eids = $mids = [];
|
||||
foreach($res as $r){
|
||||
$eids[$r['employee_id']] = $r['employee_id'];
|
||||
$mids[$r['mid']] = $r['mid'];
|
||||
}
|
||||
|
||||
$model = new Employee();
|
||||
$employees = [];
|
||||
$_employees = $model->find()->where(['in','id',$eids])->indexBy('id')->all();
|
||||
foreach($_employees as $s){
|
||||
$employees[$s->id] = $s->toArray();
|
||||
}
|
||||
|
||||
$model = new UserExt();
|
||||
$exts = [];
|
||||
$_exts = $model->find()->where(['in','mid',$mids])->andwhere(['pid'=>$pid,'deleted'=>0])->indexBy('id')->all();
|
||||
foreach($_exts as $ext){
|
||||
$ext = $ext->toArray();
|
||||
$exts[$ext['mid']][$ext['key']] = $ext['value'];
|
||||
}
|
||||
|
||||
$guests = [];
|
||||
foreach($res as $s){
|
||||
$s = $s->toArray();
|
||||
foreach($exts[$s['mid']] as $col=>$val){
|
||||
$s[$col] = $val;
|
||||
}
|
||||
$guests[$s['id']] = $s;
|
||||
}
|
||||
|
||||
$model = new Fans();
|
||||
$users = [];
|
||||
$_users = $model->find()->where(['in','id',$mids])->all();
|
||||
foreach($_users as $s){
|
||||
$s = $s->toArray();
|
||||
$users[$s['id']] = $s;
|
||||
}
|
||||
|
||||
$callback = !empty(Yii::$app->session->get('callback')) ? Yii::$app->session->get('callback') : 'guest';
|
||||
return $this->render('select',[
|
||||
'guests' => $guests,
|
||||
'pager' => $pages,
|
||||
'employees'=>$employees,
|
||||
'hotels'=>$hotels,
|
||||
'exts'=>$exts,
|
||||
'users'=>$users,
|
||||
'status'=>$status,
|
||||
'gender'=>$gender,
|
||||
'search'=>$search,
|
||||
'callback'=>$callback
|
||||
]);
|
||||
}
|
||||
|
||||
//新增客户
|
||||
public function actionNew()
|
||||
{
|
||||
global $_HI,$_FM;
|
||||
return $this->render('modify',[]);
|
||||
}
|
||||
|
||||
//更新客户
|
||||
public function actionEdit()
|
||||
{
|
||||
global $_HI,$_FM;
|
||||
$model = new Customer();
|
||||
$id = Yii::$app->request->get('id');
|
||||
$pid = Yii::$app->session->get('pid');
|
||||
$res = $model->find()->where(['id' => $id])->one();
|
||||
if($res){
|
||||
$res = $res->toArray();
|
||||
$res['last_checkin'] = $res['last_checkin'] ? date('Y-m-d',$res['last_checkin']) : '';
|
||||
$res['last_contact'] = $res['last_contact'] ? date('Y-m-d',$res['last_contact']) : '';
|
||||
$res['realname'] = $res['name'];
|
||||
}else{
|
||||
$res = [];
|
||||
}
|
||||
|
||||
//查询对应的系统用户
|
||||
$userModel = new Fans();
|
||||
$user = Fans::find()->where(['id'=>$res['mid']])->one();
|
||||
if($user){
|
||||
$res['mobile'] = $user->mobile;
|
||||
}
|
||||
|
||||
$hotel = Hotel::find()->where(['id' => $res['hotel_id']])->one();
|
||||
if($hotel){
|
||||
$res['hotel_title'] = $hotel->title;
|
||||
}
|
||||
|
||||
$employee = Employee::find()->where(['id' => $res['employee_id']])->one();
|
||||
if($employee){
|
||||
$res['employee_title'] = $employee->name;
|
||||
}
|
||||
|
||||
$exts = UserExt::find()->where(['mid' => $res['mid'],'pid'=>$pid,'deleted'=>0])->all();
|
||||
if($exts){
|
||||
foreach($exts as $ext){
|
||||
$res[$ext['key']] = $ext['value'];
|
||||
}
|
||||
}
|
||||
|
||||
return $this->render('modify',[
|
||||
'detail'=>$res,
|
||||
'id'=>$id,
|
||||
]);
|
||||
}
|
||||
|
||||
//保存车主资料
|
||||
public function actionSave()
|
||||
{
|
||||
$post = Yii::$app->request->post();
|
||||
$id = (int)$post['id'];
|
||||
$pid = Yii::$app->session->get('pid');
|
||||
if(!$post['mobile']){
|
||||
\Yii::$app->getSession()->setFlash('warning', '请输入主手机号码!');
|
||||
$url = Url::toRoute(['guest/edit','id'=>$id]);
|
||||
return $this->redirect(['new','id'=>$id]);
|
||||
}
|
||||
|
||||
$mobile = $post['mobile'];
|
||||
|
||||
//查询对应的系统用户
|
||||
$userModel = new Fans();
|
||||
$user = Fans::find()->where(['mobile'=>$mobile])->one();
|
||||
if(!$user){
|
||||
$pwd = isset($post['password']) ? trim($post['password']) : Yii::$app->params['defaultUserPassword'];
|
||||
$userModel->mobile = $mobile;
|
||||
$userModel->email = $mobile.'@hiluker.com';
|
||||
$userModel->setPassword($pwd);
|
||||
$userModel->generateAuthKey();
|
||||
$userModel->avatar = Yii::$app->params['defaultUserAvatar'];
|
||||
$userModel->created_at = time();
|
||||
$userModel->from = 'pms';
|
||||
$res = $userModel->save();
|
||||
// $res = $userModel->getErrors();
|
||||
$user_id = $userModel->attributes['id']; //获取插入后id
|
||||
}else{
|
||||
$user_id = $user->id;
|
||||
$pwd = isset($post['password']) ? trim($post['password']) : '';
|
||||
if($pwd){
|
||||
$user->setPassword($pwd);
|
||||
$user->generateAuthKey();
|
||||
$user->updated_at = time();
|
||||
$res = $user->save();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//格式化数据
|
||||
$data = [];
|
||||
//目标键=》POST键
|
||||
$cols = ['name'=>'realname','mobile'=>'mobile','idcard'=>'idcard','passport'=>'passport','country'=>'country','province'=>'province','channel'=>'channel','thumb'=>'thumb'];
|
||||
foreach($cols as $col=>$key){
|
||||
$data[$col] = isset($post[$key]) ? trim($post[$key]) : '';
|
||||
}
|
||||
|
||||
$cols = ['gender'=>'gender','total_fee'=>'total_fee','money'=>'money','jifen'=>'jifen','score'=>'score','hotel_id'=>'hotel','employee_id'=>'employee','status_code'=>'status_code','deleted'=>'deleted'];
|
||||
foreach($cols as $col=>$key){
|
||||
$data[$col] = isset($post[$key]) ? (int)$post[$key] : 0;
|
||||
}
|
||||
|
||||
$cols = ['last_checkin'=>'last_checkin','last_contact'=>'last_contact'];
|
||||
foreach($cols as $col=>$key){
|
||||
$data[$col] = isset($post[$key]) ? strtotime($post[$key]) : 0;
|
||||
}
|
||||
|
||||
$cols = ['remark'=>'editor'];
|
||||
foreach($cols as $col=>$key){
|
||||
$data[$col] = isset($post[$key]) ? htmlspecialchars($post[$key]) : '';
|
||||
}
|
||||
|
||||
$birthday = isset($post['ext']['birthday']) ? strtotime($post['ext']['birthday']) : 0;
|
||||
if($birthday){
|
||||
$data['birth_y'] = date('Y',$birthday);
|
||||
$data['birth_m'] = date('m',$birthday);
|
||||
$data['birth_d'] = date('d',$birthday);
|
||||
}
|
||||
|
||||
$data['create_at'] = time();
|
||||
$data['update_at'] = $data['create_at'];
|
||||
$data['pid'] = $pid;
|
||||
$data['mid'] = $user_id;
|
||||
|
||||
//格式化车主资料
|
||||
$AcCustomer = new Customer();
|
||||
foreach($data as $key=>$val){
|
||||
$AcCustomer->$key = $val;
|
||||
}
|
||||
|
||||
//查询该客户是否在库
|
||||
$customer = Customer::find()->where(['pid'=>$data['pid'],'mid'=>$data['mid']])->one();
|
||||
if($customer){
|
||||
$id = $customer->id;
|
||||
}
|
||||
|
||||
//客户资料入库
|
||||
if($id){
|
||||
$AcCustomer->id = $id;
|
||||
unset($data['create_at']);
|
||||
$res = $AcCustomer->updateAll($data,['id'=>$id]);
|
||||
}else{
|
||||
$res = $AcCustomer->save();
|
||||
$id = $AcCustomer->attributes['id']; //获取插入后id
|
||||
}
|
||||
|
||||
//保存扩展资料
|
||||
$AcUserExt = new UserExt();
|
||||
//批量软删
|
||||
$AcUserExt->updateAll(['deleted'=>1],['deleted'=>0,'pid'=>$pid,'mid'=>$user_id]);
|
||||
|
||||
$datas = [];
|
||||
$data = [];
|
||||
$exts = $post['ext'];
|
||||
foreach($exts as $col=>$val){
|
||||
$data['pid'] = $pid;
|
||||
$data['mid'] = $user_id;
|
||||
$data['key'] = $col;
|
||||
$data['mobile'] = $mobile;
|
||||
$data['value'] = trim($val);
|
||||
$datas[] = $data;
|
||||
}
|
||||
|
||||
//批量插入
|
||||
$model = clone $AcUserExt;
|
||||
foreach($datas as $attributes)
|
||||
{
|
||||
$model->isNewRecord = true;
|
||||
$model->setAttributes($attributes,false);
|
||||
$model->save() && $model->id=0;
|
||||
}
|
||||
|
||||
if($res){
|
||||
\Yii::$app->getSession()->setFlash('success', '用户资料保存成功!');
|
||||
return $this->redirect(['edit','id'=>$id]);
|
||||
}else{
|
||||
\Yii::$app->getSession()->setFlash('warning', '用户资料保存失败!');
|
||||
return $this->goBack();
|
||||
}
|
||||
}
|
||||
|
||||
//删除用户
|
||||
public function actionDelete($id)
|
||||
{
|
||||
global $_HI,$_FM;
|
||||
$get = Yii::$app->request->get();
|
||||
$post = Yii::$app->request->post();
|
||||
$id = (int)$get['id'];
|
||||
$data = $where = [];
|
||||
$where['pid'] = Yii::$app->session->get('pid');
|
||||
$where['id'] = $id;
|
||||
$data['update_at'] = time();
|
||||
$data['deleted'] = 1;
|
||||
|
||||
$model = new Customer();
|
||||
foreach($data as $key=>$val){
|
||||
$model->$key = $val;
|
||||
}
|
||||
|
||||
$model->id = $id;
|
||||
$res = $model->updateAll($data,$where);
|
||||
|
||||
$return = [];
|
||||
$return['url'] = Url::toRoute('guest/list');
|
||||
// $return['url'] = Url::previous();
|
||||
$return['timeout'] = 3; //3秒后自动跳转
|
||||
$return['status'] = 0;
|
||||
if($res){
|
||||
$return['msg'] = '删除成功';
|
||||
$return['errorcode'] = 200;
|
||||
$return['data'] = $id;
|
||||
}else{
|
||||
$return['msg'] = '删除失败';
|
||||
$return['errorcode'] = 0;
|
||||
}
|
||||
exit(json_encode($return));
|
||||
}
|
||||
|
||||
//更新车主
|
||||
public function actionMsg()
|
||||
{
|
||||
global $_HI,$_FM;
|
||||
$model = new Customer();
|
||||
$id = Yii::$app->request->get('id');
|
||||
$pid = Yii::$app->session->get('pid');
|
||||
$res = $model->find()->where(['id' => $id])->one();
|
||||
if($res){
|
||||
$res = $res->toArray();
|
||||
$res['last_checkin'] = $res['last_checkin'] ? date('Y-m-d',$res['last_checkin']) : '';
|
||||
$res['last_contact'] = $res['last_contact'] ? date('Y-m-d',$res['last_contact']) : '';
|
||||
$res['realname'] = $res['name'];
|
||||
}else{
|
||||
$res = [];
|
||||
}
|
||||
|
||||
//查询对应的系统用户
|
||||
$userModel = new Fans();
|
||||
$user = User::find()->where(['id'=>$res['mid']])->one();
|
||||
if($user){
|
||||
$res['mobile'] = $user->mobile;
|
||||
}
|
||||
|
||||
return $this->render('../layouts/dev',[]);
|
||||
|
||||
$hotel = Hotel::find()->where(['id' => $res['hotel_id']])->one();
|
||||
if($hotel){
|
||||
$res['hotel_title'] = $hotel->title;
|
||||
}
|
||||
|
||||
$employee = Employee::find()->where(['id' => $res['employee_id']])->one();
|
||||
if($employee){
|
||||
$res['employee_title'] = $employee->name;
|
||||
}
|
||||
|
||||
$exts = UserExt::find()->where(['mid' => $res['mid'],'pid'=>$pid,'deleted'=>0])->all();
|
||||
if($exts){
|
||||
foreach($exts as $ext){
|
||||
$res[$ext['key']] = $ext['value'];
|
||||
}
|
||||
}
|
||||
|
||||
return $this->render('modify',[
|
||||
'detail'=>$res,
|
||||
'id'=>$id,
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionAjax()
|
||||
{
|
||||
$get = Yii::$app->request->get();
|
||||
$post = Yii::$app->request->post();
|
||||
$id = (int)$get['id'];
|
||||
$data = $where = [];
|
||||
$where['pid'] = Yii::$app->session->get('pid');
|
||||
$where['id'] = $id;
|
||||
$data['update_at'] = time();
|
||||
|
||||
$model = new Customer();
|
||||
$res = $model->find()->where(['id' => $id])->one();
|
||||
$return = [];
|
||||
$return['timeout'] = 1; //3秒后自动跳转
|
||||
$return['status_code'] = 0;
|
||||
$return['ajax'] = 1;
|
||||
if($res){
|
||||
$res = $res->toArray();
|
||||
}else{
|
||||
$return['msg'] = '客户数据不存在';
|
||||
$return['errorcode'] = 404;
|
||||
exit(json_encode($return));
|
||||
}
|
||||
|
||||
switch($get['do'])
|
||||
{
|
||||
case 'hide':
|
||||
$data['status_code'] = 0;
|
||||
$model->id = $id;
|
||||
$res = $model->updateAll($data,$where);
|
||||
if($res){
|
||||
$return['msg'] = '客户隐藏标记成功';
|
||||
$return['errorcode'] = 200;
|
||||
$return['data'] = ['css'=>'info'];
|
||||
}else{
|
||||
$return['msg'] = '客户隐藏标记失败';
|
||||
$return['errorcode'] = 0;
|
||||
}
|
||||
break;
|
||||
case 'show':
|
||||
$data['status_code'] = 1;
|
||||
$model->id = $id;
|
||||
$res = $model->updateAll($data,$where);
|
||||
if($res){
|
||||
$return['msg'] = '客户显示标记成功';
|
||||
$return['errorcode'] = 200;
|
||||
$return['data'] = ['css'=>'default'];
|
||||
}else{
|
||||
$return['msg'] = '客户显示标记失败';
|
||||
$return['errorcode'] = 0;
|
||||
}
|
||||
break;
|
||||
case 'contact':
|
||||
$data['last_contact'] = time();
|
||||
$model->id = $id;
|
||||
$res = $model->updateAll($data,$where);
|
||||
if($res){
|
||||
$return['msg'] = '标记成功';
|
||||
$return['errorcode'] = 200;
|
||||
$return['data'] = ['css'=>'default'];
|
||||
}else{
|
||||
$return['msg'] = '标记失败';
|
||||
$return['errorcode'] = 0;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$return['msg'] = '无效的操作';
|
||||
$return['errorcode'] = 200;
|
||||
$return['data'] = ['css'=>'info'];
|
||||
break;
|
||||
}
|
||||
exit(json_encode($return));
|
||||
}
|
||||
|
||||
}
|
||||
Executable
+250
@@ -0,0 +1,250 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @Author: fm453
|
||||
* @Date: 2018-08-17 19:39:41
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2021-09-15T16:40:15+08:00
|
||||
* @Email: fm453@lukegzs.com
|
||||
*/
|
||||
namespace backend\controllers;
|
||||
|
||||
use Yii;
|
||||
use yii\data\Pagination;
|
||||
use yii\helpers\Url;
|
||||
use backend\models\FmHotel as Hotel;
|
||||
|
||||
class HotelController extends \yii\web\Controller
|
||||
{
|
||||
//替代常规的_construct 析构函数;其他方法调用前执行
|
||||
public function init()
|
||||
{
|
||||
parent::init();
|
||||
$session = Yii::$app->session;
|
||||
if(isset($_GET['pid']) && (int)$_GET['pid']>0){
|
||||
$session->set('pid',(int)$_GET['pid']);
|
||||
}
|
||||
$pid = $session->get('pid');
|
||||
if(!$pid){
|
||||
$url = Url::toRoute('/index/index');
|
||||
return $this->redirect($url);
|
||||
}
|
||||
}
|
||||
//主界面
|
||||
public function actionIndex()
|
||||
{
|
||||
return $this->render('../layouts/dev',[]);
|
||||
}
|
||||
|
||||
public function actionList()
|
||||
{
|
||||
$model = new Hotel();
|
||||
$where = [];
|
||||
$where['pid'] = Yii::$app->session->get('pid');
|
||||
$citys = Yii::$app->params['citys'];
|
||||
|
||||
$where['deleted'] = 0;
|
||||
$data = $model->find()->where($where);
|
||||
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
|
||||
$res = $data->offset($pages->offset)->limit($pages->limit)->all();
|
||||
|
||||
$status = ['0'=>'隐藏','1'=>'正常'];
|
||||
return $this->render('list',[
|
||||
'hotels'=>$res,
|
||||
'pager' => $pages,
|
||||
'citys'=>$citys,
|
||||
'status'=>$status
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionSelect()
|
||||
{
|
||||
$model = new Hotel();
|
||||
$where = [];
|
||||
$where['pid'] = Yii::$app->session->get('pid');
|
||||
$citys = Yii::$app->params['citys'];
|
||||
|
||||
$where['deleted'] = 0;
|
||||
$where['status_code'] = 1;
|
||||
$data = $model->find()->where($where);
|
||||
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
|
||||
$res = $data->offset($pages->offset)->limit($pages->limit)->all();
|
||||
$status = ['0'=>'隐藏','1'=>'正常'];
|
||||
$callback = !empty(Yii::$app->session->get('callback')) ? Yii::$app->session->get('callback') : 'hotel';
|
||||
return $this->render('select',[
|
||||
'hotels'=>$res,
|
||||
'pager' => $pages,
|
||||
'citys'=>$citys,
|
||||
'status'=>$status,
|
||||
'callback'=>$callback
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionNew()
|
||||
{
|
||||
return $this->render('modify',[]);
|
||||
}
|
||||
|
||||
public function actionEdit()
|
||||
{
|
||||
$model = new Hotel();
|
||||
$id = Yii::$app->request->get('id');
|
||||
$res = $model->find()->where(['id' => $id])->one();
|
||||
if($res){
|
||||
$res = $res->toArray();
|
||||
}
|
||||
$citys = Yii::$app->params['citys'];
|
||||
$res['city_title'] = isset($citys[$res['city']]['name']) ? $citys[$res['city']]['name'] : '';
|
||||
|
||||
return $this->render('modify',['detail'=>$res]);
|
||||
}
|
||||
|
||||
public function actionSave()
|
||||
{
|
||||
$post = Yii::$app->request->post();
|
||||
$data = [];
|
||||
$data['pid'] = Yii::$app->session->get('pid');
|
||||
$id = $post['id'];
|
||||
//目标键=》POST键
|
||||
$cols = ['title'=>'title','longt'=>'lng','lat'=>'lat','addr'=>'addr'];
|
||||
foreach($cols as $col=>$key){
|
||||
$data[$col] = isset($post[$key]) ? trim($post[$key]) : '';
|
||||
}
|
||||
$cols = ['city'=>'city','deleted'=>'deleted'];
|
||||
foreach($cols as $col=>$key){
|
||||
$data[$col] = isset($post[$key]) ? (int)$post[$key] : 0;
|
||||
}
|
||||
$data['update_at'] = time();
|
||||
$data['create_at'] = time();
|
||||
$data['status_code'] = 1;
|
||||
|
||||
$model = new Hotel();
|
||||
foreach($data as $key=>$val){
|
||||
$model->$key = $val;
|
||||
}
|
||||
if($id){
|
||||
$model->id = $id;
|
||||
$res = $model->updateAll($data,['id'=>$id]);
|
||||
}else{
|
||||
$res = $model->save();
|
||||
}
|
||||
|
||||
$return = [];
|
||||
if($res){
|
||||
$id = $model->attributes['id']; //获取插入后id
|
||||
$return['msg'] = '酒店保存成功';
|
||||
$return['errorcode'] = 200;
|
||||
$return['url'] = Url::toRoute(['hotel/edit','id'=>$id]);
|
||||
$return['buttons'] = [
|
||||
['title'=>'好的,我知道了','class'=>'primary','url'=>$return['url']]
|
||||
];
|
||||
}else{
|
||||
$return['msg'] = '酒店保存失败';
|
||||
$return['errorcode'] = 0;
|
||||
$return['url'] = Url::toRoute(['hotel/new',$post]);
|
||||
$return['buttons'] = [
|
||||
['title'=>'好的,我知道了','class'=>'info','url'=>$return['url']]
|
||||
];
|
||||
}
|
||||
|
||||
$classes = ['0'=>'warning','200'=>'success'];
|
||||
$return['content'] = $return['msg'];
|
||||
$return['class'] = $classes[$return['errorcode']];
|
||||
|
||||
Yii::$app->request->setBodyParams($return);
|
||||
return Yii::$app->runAction('index/msg');
|
||||
}
|
||||
|
||||
public function actionDelete()
|
||||
{
|
||||
$get = Yii::$app->request->get();
|
||||
$post = Yii::$app->request->post();
|
||||
$id = (int)$get['id'];
|
||||
$data = $where = [];
|
||||
$where['pid'] = Yii::$app->session->get('pid');
|
||||
$where['id'] = $id;
|
||||
$data['update_at'] = time();
|
||||
$data['deleted'] = 1;
|
||||
|
||||
$model = new Hotel();
|
||||
foreach($data as $key=>$val){
|
||||
$model->$key = $val;
|
||||
}
|
||||
|
||||
$model->id = $id;
|
||||
$res = $model->updateAll($data,$where);
|
||||
|
||||
$return = [];
|
||||
$return['url'] = Url::toRoute('hotel/list');
|
||||
$return['timeout'] = 3; //3秒后自动跳转
|
||||
$return['status'] = 0;
|
||||
if($res){
|
||||
$return['msg'] = '酒店删除成功';
|
||||
$return['errorcode'] = 200;
|
||||
$return['data'] = $id;
|
||||
}else{
|
||||
$return['msg'] = '酒店删除失败';
|
||||
$return['errorcode'] = 0;
|
||||
}
|
||||
exit(json_encode($return));
|
||||
}
|
||||
|
||||
public function actionAjax()
|
||||
{
|
||||
$get = Yii::$app->request->get();
|
||||
$post = Yii::$app->request->post();
|
||||
$id = (int)$get['id'];
|
||||
$data = $where = [];
|
||||
$where['pid'] = Yii::$app->session->get('pid');
|
||||
$where['id'] = $id;
|
||||
$data['update_at'] = time();
|
||||
|
||||
$model = new Hotel();
|
||||
$res = $model->find()->where(['id' => $id])->one();
|
||||
$return = [];
|
||||
$return['timeout'] = 1; //3秒后自动跳转
|
||||
$return['status'] = 0;
|
||||
$return['ajax'] = 1;
|
||||
if($res){
|
||||
$res = $res->toArray();
|
||||
}else{
|
||||
$return['msg'] = '酒店数据不存在';
|
||||
$return['errorcode'] = 404;
|
||||
exit(json_encode($return));
|
||||
}
|
||||
|
||||
switch($get['do'])
|
||||
{
|
||||
case 'hide':
|
||||
$data['status_code'] = 0;
|
||||
$model->id = $id;
|
||||
$res = $model->updateAll($data,$where);
|
||||
if($res){
|
||||
$return['msg'] = '酒店隐藏成功';
|
||||
$return['errorcode'] = 200;
|
||||
$return['data'] = ['css'=>'info'];
|
||||
}else{
|
||||
$return['msg'] = '酒店隐藏失败';
|
||||
$return['errorcode'] = 0;
|
||||
}
|
||||
break;
|
||||
case 'show':
|
||||
$data['status_code'] = 1;
|
||||
$model->id = $id;
|
||||
$res = $model->updateAll($data,$where);
|
||||
if($res){
|
||||
$return['msg'] = '酒店显示成功';
|
||||
$return['errorcode'] = 200;
|
||||
$return['data'] = ['css'=>'default'];
|
||||
}else{
|
||||
$return['msg'] = '酒店显示失败';
|
||||
$return['errorcode'] = 0;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
exit(json_encode($return));
|
||||
}
|
||||
|
||||
}
|
||||
Executable
+125
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @Author: fm453
|
||||
* @Date: 2018-04-23 14:25:38
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2021-09-15T16:11:41+08:00
|
||||
* @Email: fm453@lukegzs.com
|
||||
*/
|
||||
//主入口页
|
||||
namespace backend\controllers;
|
||||
use common\models\Log;
|
||||
use backend\models\Menu;
|
||||
use yii\data\Pagination;
|
||||
use yii\helpers\Url;
|
||||
|
||||
use Yii;
|
||||
|
||||
class IndexController extends \yii\web\Controller
|
||||
{
|
||||
public $enableCsrfValidation = false;
|
||||
|
||||
//替代常规的_construct 析构函数;其他方法调用前执行
|
||||
public function init()
|
||||
{
|
||||
parent::init();
|
||||
$session = Yii::$app->session;
|
||||
if(isset($_GET['pid']) && (int)$_GET['pid']>0){
|
||||
$session->set('pid',(int)$_GET['pid']);
|
||||
}
|
||||
}
|
||||
|
||||
public function beforeAction($action){
|
||||
$session = Yii::$app->session;
|
||||
$pid = $session->get('pid');
|
||||
if(!$pid){
|
||||
$action->actionMethod='actionIndex';
|
||||
$action->id='index';
|
||||
}
|
||||
return parent::beforeAction($action);
|
||||
}
|
||||
|
||||
public function actionIndex()
|
||||
{
|
||||
$session = Yii::$app->session;
|
||||
if(isset($_GET['pid'])){
|
||||
$pid = (int)$_GET['pid'];
|
||||
if($pid>0){
|
||||
$session->set('pid',$pid);
|
||||
return $this->actionWelcome();
|
||||
exit;
|
||||
}else{
|
||||
return $this->render('index');
|
||||
}
|
||||
}
|
||||
$pid = $session->get('pid');
|
||||
if(!$pid){
|
||||
return $this->render('index');
|
||||
}else{
|
||||
return $this->actionWelcome();
|
||||
}
|
||||
}
|
||||
|
||||
public function actionWelcome()
|
||||
{
|
||||
//登录系统欢迎界面,显示入口集
|
||||
global $_HI,$_FM;
|
||||
|
||||
$navs = array();
|
||||
$entries = array();
|
||||
$entries[] = array('name'=>'客户列表','title'=>'对客户档案进行管理','url'=>Url::toRoute('guest/list'),'icon'=>'fa fa-users','class'=>'primary');
|
||||
$entries[] = array('name'=>'新增客户','title'=>'新增加一个客户','url'=>Url::toRoute('guest/new'),'icon'=>'fa fa-user-plus','class'=>'primary');
|
||||
$navs[] = array('name'=>'客户管理','entries'=>$entries);
|
||||
|
||||
$entries = array();
|
||||
$entries[] = array('name'=>'订单列表','title'=>'点击查看全部订单','url'=>Url::toRoute('order/list'),'icon'=>'fa fa-list','class'=>'primary');
|
||||
$entries[] = array('name'=>'新增订单','title'=>'新增一份订单','url'=>Url::toRoute('order/new'),'icon'=>'fa fa-pencil','class'=>'primary');
|
||||
$entries[] = array('name'=>'咨询列表','title'=>'所有已记录咨询过的客户','url'=>Url::toRoute('orderpre/list'),'icon'=>'fa fa-calendar','class'=>'primary');
|
||||
$entries[] = array('name'=>'记录咨询','title'=>'新记录一个客户咨询','url'=>Url::toRoute('orderpre/new'),'icon'=>'fa fa-calendar-plus-o','class'=>'primary');
|
||||
$navs[] = array('name'=>'订单管理','entries'=>$entries);
|
||||
|
||||
$entries = array();
|
||||
$entries[] = array('name'=>'酒店列表','title'=>'对全部酒店门店进行管理','url'=>Url::toRoute('hotel/list'),'icon'=>'fa fa-th-large','class'=>'primary');
|
||||
$entries[] = array('name'=>'新增酒店','title'=>'新增加一个酒店','url'=>Url::toRoute('hotel/new'),'icon'=>'fa fa-th-list','class'=>'primary');
|
||||
$entries[] = array('name'=>'客房列表','title'=>'对全部酒店门店进行管理','url'=>Url::toRoute('room/list'),'icon'=>'fa fa-cubes','class'=>'primary');
|
||||
$entries[] = array('name'=>'新增客房','title'=>'新增加一个客房','url'=>Url::toRoute('room/new'),'icon'=>'fa fa-cube','class'=>'primary');
|
||||
$entries[] = array('name'=>'员工列表','title'=>'对公司员工档案进行管理','url'=>Url::toRoute('employee/list'),'icon'=>'fa fa-venus-mars','class'=>'primary');
|
||||
$entries[] = array('name'=>'新增员工','title'=>'新增员工','url'=>Url::toRoute('employee/new'),'icon'=>'fa fa-venus-double','class'=>'primary');
|
||||
$navs[] = array('name'=>'酒店管理','entries'=>$entries);
|
||||
|
||||
$entries = array();
|
||||
$entries[] = array('name'=>'切换平台','title'=>'选择要管理的平台','url'=>Url::toRoute(['index/index','pid'=>0]),'icon'=>'fa fa-random','class'=>'primary');
|
||||
$navs[] = array('name'=>'平台管理','entries'=>$entries);
|
||||
|
||||
unset($entries);
|
||||
return $this->render('welcome',[
|
||||
'navs' => $navs,
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionMap()
|
||||
{
|
||||
$lat = (float) Yii::$app->request->get('lat');
|
||||
$lng = (float) Yii::$app->request->get('lng');
|
||||
if (empty($lat) || empty($lng)) {
|
||||
$lat = 0;
|
||||
$lng = 0;
|
||||
}
|
||||
$search = [];
|
||||
$search['keyword'] = Yii::$app->request->get('title');
|
||||
$callback = isset($_GET['callback']) ? $_GET['callback'] : 'showLatLng';
|
||||
return $this->render('map',[
|
||||
'lat'=>$lat,
|
||||
'lng'=>$lng,
|
||||
'search'=>$search,
|
||||
'callback'=>$callback,
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionMsg()
|
||||
{
|
||||
$params = Yii::$app->request->bodyParams;
|
||||
return $this->render('../layouts/msg',$params);
|
||||
}
|
||||
}
|
||||
Executable
+44
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @Author: fm453
|
||||
* @Date: 2018-08-17 19:39:41
|
||||
* @Last Modified by: fm453
|
||||
* @Last Modified time: 2018-08-17 20:08:49
|
||||
* @Email: fm453@lukegzs.com
|
||||
*/
|
||||
namespace backend\controllers;
|
||||
|
||||
use Yii;
|
||||
use yii\data\Pagination;
|
||||
use yii\helpers\Url;
|
||||
|
||||
class OrderController extends \yii\web\Controller
|
||||
{
|
||||
//主界面
|
||||
public function actionIndex()
|
||||
{
|
||||
return $this->render('../layouts/dev',[]);
|
||||
}
|
||||
|
||||
public function actionList()
|
||||
{
|
||||
return $this->render('../layouts/dev',[]);
|
||||
}
|
||||
|
||||
public function actionDriver()
|
||||
{
|
||||
return $this->render('../layouts/dev',[]);
|
||||
}
|
||||
|
||||
public function actionOrder()
|
||||
{
|
||||
return $this->render('../layouts/dev',[]);
|
||||
}
|
||||
|
||||
public function actionNew()
|
||||
{
|
||||
return $this->render('../layouts/dev',[]);
|
||||
}
|
||||
|
||||
}
|
||||
Executable
+39
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @Author: fm453
|
||||
* @Date: 2018-08-17 19:39:41
|
||||
* @Last Modified by: fm453
|
||||
* @Last Modified time: 2018-08-17 20:06:49
|
||||
* @Email: fm453@lukegzs.com
|
||||
*/
|
||||
namespace backend\controllers;
|
||||
|
||||
use Yii;
|
||||
use yii\data\Pagination;
|
||||
use yii\helpers\Url;
|
||||
|
||||
class OrderpreController extends \yii\web\Controller
|
||||
{
|
||||
//主界面
|
||||
public function actionIndex()
|
||||
{
|
||||
return $this->render('../layouts/dev',[]);
|
||||
}
|
||||
|
||||
public function actionList()
|
||||
{
|
||||
return $this->render('../layouts/dev',[]);
|
||||
}
|
||||
|
||||
public function actionDriver()
|
||||
{
|
||||
return $this->render('../layouts/dev',[]);
|
||||
}
|
||||
|
||||
public function actionOrder()
|
||||
{
|
||||
return $this->render('../layouts/dev',[]);
|
||||
}
|
||||
|
||||
}
|
||||
Executable
+308
@@ -0,0 +1,308 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @Author: fm453
|
||||
* @Date: 2018-12-02 11:40:44
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2021-09-15T16:41:13+08:00
|
||||
* @Email: fm453@lukegzs.com
|
||||
*/
|
||||
|
||||
namespace backend\controllers;
|
||||
|
||||
use Yii;
|
||||
use yii\data\Pagination;
|
||||
use yii\helpers\Url;
|
||||
use common\models\Fans;
|
||||
use backend\models\FmUserExt as UserExt;
|
||||
use backend\models\FmRoomOwner as RoomOwner;
|
||||
|
||||
class OwnerController extends \yii\web\Controller
|
||||
{
|
||||
//替代常规的_construct 析构函数;其他方法调用前执行
|
||||
public function init()
|
||||
{
|
||||
parent::init();
|
||||
$session = Yii::$app->session;
|
||||
if(isset($_GET['pid']) && (int)$_GET['pid']>0){
|
||||
$session->set('pid',(int)$_GET['pid']);
|
||||
}
|
||||
$pid = $session->get('pid');
|
||||
if(!$pid){
|
||||
$url = Url::toRoute('/index/index');
|
||||
return $this->redirect($url);
|
||||
}
|
||||
}
|
||||
|
||||
public function actionIndex()
|
||||
{
|
||||
return $this->render('index');
|
||||
}
|
||||
|
||||
//业主列表
|
||||
public function actionList()
|
||||
{
|
||||
$model = new RoomOwner();
|
||||
$where = $where2 = [];
|
||||
$where2[]='and';
|
||||
$where['pid'] = Yii::$app->session->get('pid');
|
||||
$post = Yii::$app->request->post();
|
||||
$search = [];
|
||||
$search['title'] = isset($post['title']) ? trim(htmlspecialchars_decode($post['title'])) : '';
|
||||
if(!empty($search['title'])){
|
||||
$where2[] = ['LIKE','name',$search['title']];
|
||||
}
|
||||
$where['deleted'] = 0;
|
||||
$data = $model->find()->where($where);
|
||||
if($search['title']){
|
||||
$data = $data->andwhere($where2);
|
||||
}
|
||||
|
||||
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
|
||||
$res = $data->offset($pages->offset)->limit($pages->limit)->all();
|
||||
$status = ['0'=>'无协议','1'=>'履约中'];
|
||||
$gender = ['0'=>'未设置','1'=>'男','2'=>'女'];
|
||||
|
||||
return $this->render('list',[
|
||||
'owners'=>$res,
|
||||
'pager' => $pages,
|
||||
'status'=>$status,
|
||||
'gender'=>$gender,
|
||||
'search'=>$search
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionSelect()
|
||||
{
|
||||
$model = new RoomOwner();
|
||||
$where = $where2 = [];
|
||||
$where2[]='and';
|
||||
$where['pid'] = Yii::$app->session->get('pid');
|
||||
$post = Yii::$app->request->post();
|
||||
$search = [];
|
||||
$search['title'] = isset($post['title']) ? trim(htmlspecialchars_decode($post['title'])) : '';
|
||||
if(!empty($search['title'])){
|
||||
$where2[] = ['LIKE','name',$search['title']];
|
||||
}
|
||||
$where['deleted'] = 0;
|
||||
$data = $model->find()->where($where);
|
||||
if($search['title']){
|
||||
$data = $data->andwhere($where2);
|
||||
}
|
||||
|
||||
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
|
||||
$res = $data->offset($pages->offset)->limit($pages->limit)->all();
|
||||
$status = ['0'=>'无协议','1'=>'履约中'];
|
||||
$gender = ['0'=>'未设置','1'=>'男','2'=>'女'];
|
||||
|
||||
$callback = !empty(Yii::$app->session->get('callback')) ? Yii::$app->session->get('callback') : 'owner';
|
||||
return $this->render('select',[
|
||||
'owners'=>$res,
|
||||
'pager' => $pages,
|
||||
'status'=>$status,
|
||||
'gender'=>$gender,
|
||||
'search'=>$search,
|
||||
'callback'=>$callback
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionNew()
|
||||
{
|
||||
return $this->render('modify',[]);
|
||||
}
|
||||
|
||||
//编辑业主资料
|
||||
public function actionEdit()
|
||||
{
|
||||
$model = new RoomOwner();
|
||||
$id = Yii::$app->request->get('id');
|
||||
$res = $model->findOne($id);
|
||||
if($res){
|
||||
$res = $res->toArray();
|
||||
}
|
||||
|
||||
return $this->render('modify',['detail'=>$res]);
|
||||
}
|
||||
|
||||
//保存业主资料
|
||||
public function actionSave()
|
||||
{
|
||||
$post = Yii::$app->request->post();
|
||||
$id = (int)$post['id'];
|
||||
$pid = Yii::$app->session->get('pid');
|
||||
//格式化数据
|
||||
//目标键=》POST键
|
||||
$cols = ['name'=>'name','mobile'=>'mobile'];
|
||||
foreach($cols as $col=>$key){
|
||||
$data[$col] = isset($post[$key]) ? trim($post[$key]) : '';
|
||||
}
|
||||
$cols = ['gender'=>'gender','status'=>'status','deleted'=>'deleted'];
|
||||
foreach($cols as $col=>$key){
|
||||
$data[$col] = isset($post[$key]) ? (int)$post[$key] : 0;
|
||||
}
|
||||
$cols = ['remark'=>'editor'];
|
||||
foreach($cols as $col=>$key){
|
||||
$data[$col] = isset($post[$key]) ? $post[$key] : '';
|
||||
}
|
||||
$data['create_at'] = time();
|
||||
$data['update_at'] = $data['create_at'];
|
||||
$data['status_code'] = 1;
|
||||
$data['pid'] = $pid;
|
||||
|
||||
//保存业主资料
|
||||
$AcRoomOwner = new RoomOwner();
|
||||
foreach($data as $key=>$val){
|
||||
$AcRoomOwner->$key = $val;
|
||||
}
|
||||
|
||||
//查询业主手机号是否在库
|
||||
$roomowner = AcRoomOwner::find()->where(['mobile'=>$data['mobile']])->one();
|
||||
if($roomowner){
|
||||
$id = $roomowner->id;
|
||||
}
|
||||
|
||||
if($id){
|
||||
$AcRoomOwner->id = $id;
|
||||
unset($data['create_at']);
|
||||
$res = $AcRoomOwner->updateAll($data,['id'=>$id]);
|
||||
}else{
|
||||
$res = $AcRoomOwner->save();
|
||||
$id = $AcRoomOwner->attributes['id']; //获取插入后id
|
||||
}
|
||||
|
||||
//查询业主对应的系统账号
|
||||
$userModel = new User();
|
||||
$user = User::find()->where(['mobile'=>$data['mobile']])->one();
|
||||
if(empty($user)){
|
||||
$userModel->mobile = $data['mobile'];
|
||||
$userModel->setPassword(Yii::$app->params['defaultUserPassword']);
|
||||
$userModel->generateAuthKey();
|
||||
$userModel->avatar = Yii::$app->params['defaultUserAvatar'];
|
||||
$userModel->created_at = time();
|
||||
$userModel->status = 1;
|
||||
$userModel->save();
|
||||
$user_id = $userModel->attributes['id']; //获取插入后id
|
||||
}
|
||||
|
||||
// \Yii::$app->getSession()->setFlash('info', '已成功注册该业主!');
|
||||
// $url = Url::toRoute(['owner/edit','id'=>$id]);
|
||||
// return $this->redirect($url);
|
||||
$return = [];
|
||||
if($res){
|
||||
$return['msg'] = '业主信息保存成功';
|
||||
$return['errorcode'] = 200;
|
||||
$return['url'] = Url::toRoute(['owner/edit','id'=>$id]);
|
||||
$return['buttons'] = [
|
||||
['title'=>'好的,我知道了','class'=>'primary','url'=>$return['url']]
|
||||
];
|
||||
}else{
|
||||
$return['msg'] = '业主信息保存失败';
|
||||
$return['errorcode'] = 0;
|
||||
$return['url'] = Url::toRoute(['owner/new',$post]);
|
||||
$return['buttons'] = [
|
||||
['title'=>'好的,我知道了','class'=>'info','url'=>$return['url']]
|
||||
];
|
||||
}
|
||||
|
||||
$classes = ['0'=>'warning','200'=>'success'];
|
||||
$return['content'] = $return['msg'];
|
||||
$return['class'] = $classes[$return['errorcode']];
|
||||
|
||||
Yii::$app->request->setBodyParams($return);
|
||||
return Yii::$app->runAction('index/msg');
|
||||
}
|
||||
|
||||
//删除业主
|
||||
public function actionDelete()
|
||||
{
|
||||
$get = Yii::$app->request->get();
|
||||
$post = Yii::$app->request->post();
|
||||
$id = (int)$get['id'];
|
||||
$data = $where = [];
|
||||
$where['pid'] = Yii::$app->session->get('pid');
|
||||
$where['id'] = $id;
|
||||
$data['update_at'] = time();
|
||||
$data['deleted'] = 1;
|
||||
|
||||
$model = new RoomOwner();
|
||||
foreach($data as $key=>$val){
|
||||
$model->$key = $val;
|
||||
}
|
||||
|
||||
$model->id = $id;
|
||||
$res = $model->updateAll($data,$where);
|
||||
|
||||
$return = [];
|
||||
$return['url'] = Url::toRoute('owner/list');
|
||||
$return['timeout'] = 3; //3秒后自动跳转
|
||||
$return['status'] = 0;
|
||||
if($res){
|
||||
$return['msg'] = '业主删除成功';
|
||||
$return['errorcode'] = 200;
|
||||
$return['data'] = $id;
|
||||
}else{
|
||||
$return['msg'] = '业主删除失败';
|
||||
$return['errorcode'] = 0;
|
||||
}
|
||||
exit(json_encode($return));
|
||||
}
|
||||
|
||||
public function actionAjax()
|
||||
{
|
||||
$get = Yii::$app->request->get();
|
||||
$post = Yii::$app->request->post();
|
||||
$id = (int)$get['id'];
|
||||
$data = $where = [];
|
||||
$where['pid'] = Yii::$app->session->get('pid');
|
||||
$where['id'] = $id;
|
||||
$data['update_at'] = time();
|
||||
|
||||
$model = new RoomOwner();
|
||||
$res = $model->find()->where(['id' => $id])->one();
|
||||
$return = [];
|
||||
$return['timeout'] = 1; //3秒后自动跳转
|
||||
$return['status'] = 0;
|
||||
$return['ajax'] = 1;
|
||||
if($res){
|
||||
$res = $res->toArray();
|
||||
}else{
|
||||
$return['msg'] = '业主数据不存在';
|
||||
$return['errorcode'] = 404;
|
||||
exit(json_encode($return));
|
||||
}
|
||||
|
||||
switch($get['do'])
|
||||
{
|
||||
case 'out':
|
||||
$data['status'] = 0;
|
||||
$model->id = $id;
|
||||
$res = $model->updateAll($data,$where);
|
||||
if($res){
|
||||
$return['msg'] = '业主解除签约标记成功';
|
||||
$return['errorcode'] = 200;
|
||||
$return['data'] = ['css'=>'info'];
|
||||
}else{
|
||||
$return['msg'] = '业主签约标记失败';
|
||||
$return['errorcode'] = 0;
|
||||
}
|
||||
break;
|
||||
case 'in':
|
||||
$data['status'] = 1;
|
||||
$model->id = $id;
|
||||
$res = $model->updateAll($data,$where);
|
||||
if($res){
|
||||
$return['msg'] = '业主解除签约标记成功';
|
||||
$return['errorcode'] = 200;
|
||||
$return['data'] = ['css'=>'default'];
|
||||
}else{
|
||||
$return['msg'] = '业主签约标记失败';
|
||||
$return['errorcode'] = 0;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
exit(json_encode($return));
|
||||
}
|
||||
|
||||
}
|
||||
Executable
+452
@@ -0,0 +1,452 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @Author: fm453
|
||||
* @Date: 2018-08-17 19:39:41
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2021-09-15T16:42:59+08:00
|
||||
* @Email: fm453@lukegzs.com
|
||||
*/
|
||||
namespace backend\controllers;
|
||||
|
||||
use Yii;
|
||||
use yii\data\Pagination;
|
||||
use yii\helpers\Url;
|
||||
use backend\models\FmHotel as Hotel;
|
||||
use backend\models\FmRoom as Room;
|
||||
use backend\models\FmRoomOwner as RoomOwner;
|
||||
|
||||
class RoomController extends \yii\web\Controller
|
||||
{
|
||||
//替代常规的_construct 析构函数;其他方法调用前执行
|
||||
public function init()
|
||||
{
|
||||
parent::init();
|
||||
$session = Yii::$app->session;
|
||||
if(isset($_GET['pid']) && (int)$_GET['pid']>0){
|
||||
$session->set('pid',(int)$_GET['pid']);
|
||||
}
|
||||
$pid = $session->get('pid');
|
||||
if(!$pid){
|
||||
$url = Url::toRoute('/index/index');
|
||||
return $this->redirect($url);
|
||||
}
|
||||
}
|
||||
//主界面
|
||||
public function actionIndex()
|
||||
{
|
||||
return $this->render('../layouts/dev',[]);
|
||||
}
|
||||
|
||||
public function actionList()
|
||||
{
|
||||
global $_HI,$_FM;
|
||||
$pid = Yii::$app->session->get('pid');
|
||||
$citys = Yii::$app->params['citys'];
|
||||
$model = new Room();
|
||||
$where = $where2 = [];
|
||||
$where2[]='and';
|
||||
$where['pid'] = $pid;
|
||||
$post = Yii::$app->request->post();
|
||||
$search = isset($post['search']) ? $post['search'] : [];
|
||||
$page = isset($_GET['page']) ? (int)$_GET['page'] : 0;
|
||||
$session = Yii::$app->session;
|
||||
if($page==0){
|
||||
$session->set('Room:List:'.$pid,$search);
|
||||
}else{
|
||||
$search = $search ? $search : $session->get('Room:List:'.$pid);
|
||||
}
|
||||
|
||||
$hotel_id = Yii::$app->request->get('hotel_id');
|
||||
$hotel_id = (int)$hotel_id;
|
||||
if($hotel_id){
|
||||
$search['hotel'] = $hotel_id;
|
||||
}
|
||||
|
||||
$model = new Room();
|
||||
$where = [];
|
||||
$where['pid'] = Yii::$app->session->get('pid');
|
||||
$search['title'] = isset($search['title']) ? trim(htmlspecialchars_decode($search['title'])) : '';
|
||||
if(!empty($search['title'])){
|
||||
$where2[] = ['LIKE','title',$search['title']];
|
||||
}
|
||||
|
||||
$search['hotel'] = isset($search['hotel']) ? (int)$search['hotel'] : 0;
|
||||
if(!empty($search['hotel'])){
|
||||
$where2[] = ['=','hotel_id',$search['hotel']];
|
||||
$hotel = Hotel::find()->where(['id'=>$search['hotel']])->one();
|
||||
$search['hotel_title'] = $hotel['title'];
|
||||
}
|
||||
|
||||
$search['f'] = isset($search['f']) ? (int)$search['f'] : 0;
|
||||
if(!empty($search['f'])){
|
||||
$where2[] = ['=','f',$search['f']];
|
||||
}else{
|
||||
unset($search['f']);
|
||||
}
|
||||
$search['t'] = isset($search['t']) ? (int)$search['t'] : 0;
|
||||
if(!empty($search['t'])){
|
||||
$where2[] = ['=','t',$search['t']];
|
||||
}else{
|
||||
unset($search['t']);
|
||||
}
|
||||
$search['c'] = isset($search['c']) ? (int)$search['c'] : 0;
|
||||
if(!empty($search['c'])){
|
||||
$where2[] = ['=','c',$search['c']];
|
||||
}else{
|
||||
unset($search['c']);
|
||||
}
|
||||
$search['w'] = isset($search['w']) ? (int)$search['w'] : 0;
|
||||
if(!empty($search['w'])){
|
||||
$where2[] = ['=','w',$search['w']];
|
||||
}else{
|
||||
unset($search['w']);
|
||||
}
|
||||
$search['b'] = isset($search['b']) ? (int)$search['b'] : 0;
|
||||
if(!empty($search['b'])){
|
||||
$where2[] = ['=','b',$search['b']];
|
||||
}else{
|
||||
unset($search['b']);
|
||||
}
|
||||
|
||||
$search['measure'] = isset($search['measure']) ? (int)$search['measure'] : 0;
|
||||
if(!empty($search['measure'])){
|
||||
$where2[] = ['<=','measure',$search['measure']];
|
||||
}else{
|
||||
unset($search['measure']);
|
||||
}
|
||||
|
||||
$where['deleted'] = 0;
|
||||
$data = $model->find()->where($where)->andwhere(['AND',$where2]);
|
||||
|
||||
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
|
||||
$res = $data->orderBy('hotel_id DESC, id DESC')->offset($pages->offset)->limit($pages->limit)->all();
|
||||
|
||||
$status = ['0'=>'隐藏','1'=>'正常'];
|
||||
|
||||
$model = new Hotel();
|
||||
$where = [];
|
||||
$where['pid'] = Yii::$app->session->get('pid');
|
||||
$_hotels = $model->find()->where($where)->all();
|
||||
$hotels = [];
|
||||
foreach($_hotels as $s){
|
||||
$hotels[$s->id] = $s->toArray();
|
||||
}
|
||||
|
||||
$rooms = [];
|
||||
foreach($res as $s){
|
||||
$s = $s->toArray();
|
||||
$rooms[] = $s;
|
||||
}
|
||||
|
||||
return $this->render('list',[
|
||||
'rooms'=>$rooms,
|
||||
'hotels'=>$hotels,
|
||||
'pager' => $pages,
|
||||
'citys'=>$citys,
|
||||
'status'=>$status,
|
||||
'pager' => $pages,
|
||||
'search'=>$search,
|
||||
'hotel_id'=>$hotel_id,
|
||||
'total'=>$data->count(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionSelect()
|
||||
{
|
||||
$model = new Hotel();
|
||||
$where = [];
|
||||
$where['pid'] = Yii::$app->session->get('pid');
|
||||
$citys = Yii::$app->params['citys'];
|
||||
|
||||
$where['deleted'] = 0;
|
||||
$where['status_code'] = 1;
|
||||
$data = $model->find()->where($where);
|
||||
$pages = new Pagination(['totalCount' =>$data->count(), 'pageSize' => '20']);
|
||||
$res = $data->offset($pages->offset)->limit($pages->limit)->all();
|
||||
$status = ['0'=>'隐藏','1'=>'正常'];
|
||||
$callback = !empty(Yii::$app->session->get('callback')) ? Yii::$app->session->get('callback') : 'hotel';
|
||||
return $this->render('select',[
|
||||
'hotels'=>$res,
|
||||
'pager' => $pages,
|
||||
'citys'=>$citys,
|
||||
'status'=>$status,
|
||||
'callback'=>$callback
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionNew()
|
||||
{
|
||||
return $this->render('modify',[]);
|
||||
}
|
||||
|
||||
public function actionEdit()
|
||||
{
|
||||
$model = new Room();
|
||||
$id = Yii::$app->request->get('id');
|
||||
$res = $model->find()->where(['id' => $id])->one();
|
||||
if($res){
|
||||
$res = $res->toArray();
|
||||
$cols = ['signtime','deadline'];
|
||||
foreach($cols as $col){
|
||||
$res[$col] = $res[$col] ? date('Y-m-d',$res[$col]) : '';
|
||||
}
|
||||
$cols = ['income','expense','surplus'];
|
||||
foreach($cols as $col){
|
||||
$res[$col] = round($res[$col]/100,2);
|
||||
}
|
||||
}
|
||||
|
||||
$hotel = Hotel::find()->where(['id' => $res['hotel_id']])->one();
|
||||
if($hotel){
|
||||
$res['hotel_title'] = $hotel->title;
|
||||
}
|
||||
$owner = RoomOwner::findOne($res['owner_id']);
|
||||
if($owner){
|
||||
$res['owner_title'] = $owner->name;
|
||||
}
|
||||
|
||||
return $this->render('modify',[
|
||||
'detail'=>$res,
|
||||
'id'=>$id,
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionSave()
|
||||
{
|
||||
$post = Yii::$app->request->post();
|
||||
$data = [];
|
||||
$data['pid'] = Yii::$app->session->get('pid');
|
||||
$id = $post['id'];
|
||||
$op = Yii::$app->request->get('op');
|
||||
switch($op){
|
||||
case 'basic':
|
||||
//目标键=》POST键
|
||||
$cols = ['title'=>'title','sn'=>'sn','thumb'=>'thumb','longt'=>'lng','lat'=>'lat','addr'=>'addr'];
|
||||
foreach($cols as $col=>$key){
|
||||
$data[$col] = isset($post[$key]) ? trim($post[$key]) : '';
|
||||
}
|
||||
$cols = ['hotel_id'=>'hotel_id','f'=>'f','t'=>'t','c'=>'c','w'=>'w','b'=>'b','measure'=>'measure','deleted'=>'deleted'];
|
||||
foreach($cols as $col=>$key){
|
||||
$data[$col] = isset($post[$key]) ? (int)$post[$key] : 0;
|
||||
}
|
||||
$data['detail'] = $post['editor'];
|
||||
$data['status_code'] = 1;
|
||||
|
||||
break;
|
||||
case 'params':
|
||||
//目标键=》POST键
|
||||
$cols = ['wifi'=>'wifi','cooking'=>'cooking','gas'=>'gas','parker'=>'parker','swimmingpool'=>'swimmingpool'];
|
||||
foreach($cols as $col=>$key){
|
||||
$data[$col] = isset($post[$key]) ? (int)$post[$key] : 0;
|
||||
}
|
||||
break;
|
||||
case 'owner':
|
||||
//目标键=》POST键
|
||||
$cols = ['owner_id'=>'owner_id','signmonths'=>'signmonths'];
|
||||
foreach($cols as $col=>$key){
|
||||
$data[$col] = isset($post[$key]) ? (int)$post[$key] : 0;
|
||||
}
|
||||
$cols = ['income'=>'income','expense'=>'expense','surplus'=>'surplus'];
|
||||
foreach($cols as $col=>$key){
|
||||
$data[$col] = isset($post[$key]) ? (int)($post[$key]*100) : 0;
|
||||
}
|
||||
$cols = ['signtime'=>'signtime','deadline'=>'deadline'];
|
||||
foreach($cols as $col=>$key){
|
||||
$data[$col] = isset($post[$key]) ? strtotime($post[$key]) : 0;
|
||||
}
|
||||
break;
|
||||
case 'other':
|
||||
//目标键=》POST键
|
||||
$cols = ['landscape'=>'landscape','feature'=>'feature','tag'=>'tag','traffic'=>'traffic'];
|
||||
foreach($cols as $col=>$key){
|
||||
$data[$col] = isset($post[$key]) ? trim($post[$key]) : '';
|
||||
}
|
||||
$data['remark'] = $post['remark-editor'];
|
||||
break;
|
||||
default:
|
||||
\Yii::$app->getSession()->setFlash('success', '无效的数据保存操作!');
|
||||
return $this->redirect(['edit','id'=>$id]);
|
||||
break;
|
||||
}
|
||||
$data['update_at'] = time();
|
||||
|
||||
$model = new Room();
|
||||
if($id){
|
||||
$model = $model->findOne($id);
|
||||
}
|
||||
foreach($data as $key=>$val){
|
||||
$model->$key = $val;
|
||||
}
|
||||
if($id){
|
||||
$model->id = $id;
|
||||
$res = $model->update();
|
||||
}else{
|
||||
$model->create_at = $data['update_at'];
|
||||
$res = $model->save();
|
||||
}
|
||||
|
||||
if($res){
|
||||
$id = $id ? $id : $model->attributes['id']; //取插入后id
|
||||
\Yii::$app->getSession()->setFlash('success', '房间资料保存成功!');
|
||||
return $this->redirect(['edit','id'=>$id]);
|
||||
}else{
|
||||
\Yii::$app->getSession()->setFlash('warning', '房间资料保存失败!');
|
||||
if($id){
|
||||
return $this->redirect(['edit','id'=>$id]);
|
||||
}else{
|
||||
return $this->redirect(['new']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function actionDelete()
|
||||
{
|
||||
$get = Yii::$app->request->get();
|
||||
$post = Yii::$app->request->post();
|
||||
$id = (int)$get['id'];
|
||||
$data = $where = [];
|
||||
$where['pid'] = Yii::$app->session->get('pid');
|
||||
$where['id'] = $id;
|
||||
$data['update_at'] = time();
|
||||
$data['deleted'] = 1;
|
||||
|
||||
$model = new Room();
|
||||
foreach($data as $key=>$val){
|
||||
$model->$key = $val;
|
||||
}
|
||||
|
||||
$model->id = $id;
|
||||
$res = $model->updateAll($data,$where);
|
||||
|
||||
$return = [];
|
||||
$return['url'] = Url::toRoute('room/list');
|
||||
$return['timeout'] = 3; //3秒后自动跳转
|
||||
$return['status'] = 0;
|
||||
if($res){
|
||||
$return['msg'] = '房间删除成功';
|
||||
$return['errorcode'] = 200;
|
||||
$return['data'] = $id;
|
||||
}else{
|
||||
$return['msg'] = '房间删除失败';
|
||||
$return['errorcode'] = 0;
|
||||
}
|
||||
exit(json_encode($return));
|
||||
}
|
||||
|
||||
public function actionAjax()
|
||||
{
|
||||
$get = Yii::$app->request->get();
|
||||
$post = Yii::$app->request->post();
|
||||
$id = (int)$get['id'];
|
||||
$data = $where = [];
|
||||
$where['pid'] = Yii::$app->session->get('pid');
|
||||
$where['id'] = $id;
|
||||
$data['update_at'] = time();
|
||||
|
||||
$model = new Room();
|
||||
$res = $model->findOne($id);
|
||||
$return = [];
|
||||
$return['timeout'] = 1; //3秒后自动跳转
|
||||
$return['status'] = 0;
|
||||
$return['ajax'] = 1;
|
||||
if(!$res){
|
||||
$return['msg'] = '房间数据不存在';
|
||||
$return['errorcode'] = 404;
|
||||
exit(json_encode($return));
|
||||
}
|
||||
$data = $res;
|
||||
|
||||
switch($get['do'])
|
||||
{
|
||||
case 'hide':
|
||||
$data->status_code = 0;
|
||||
$res = $data->update();
|
||||
if($res !== false){
|
||||
$return['msg'] = '房间隐藏成功';
|
||||
$return['errorcode'] = 200;
|
||||
$return['data'] = ['css'=>'info'];
|
||||
}else{
|
||||
$return['msg'] = '房间隐藏失败';
|
||||
$return['errorcode'] = 0;
|
||||
}
|
||||
break;
|
||||
case 'show':
|
||||
$data->status_code = 1;
|
||||
$res = $data->update();
|
||||
if($res !== false){
|
||||
$return['msg'] = '房间显示成功';
|
||||
$return['errorcode'] = 200;
|
||||
$return['data'] = ['css'=>'default'];
|
||||
}else{
|
||||
$return['msg'] = '房间显示失败';
|
||||
$return['errorcode'] = 0;
|
||||
}
|
||||
break;
|
||||
case 'cooking':
|
||||
$data->cooking = ($data->cooking) ? 0 : 1;
|
||||
$res = $data->update();
|
||||
if($res !== false){
|
||||
$return['msg'] = '参数标记成功';
|
||||
$return['errorcode'] = 200;
|
||||
$return['data'] = ['css'=>'default'];
|
||||
}else{
|
||||
$return['msg'] = '参数标记失败';
|
||||
$return['errorcode'] = 0;
|
||||
}
|
||||
break;
|
||||
case 'parker':
|
||||
$data->parker = ($data->parker) ? 0 : 1;
|
||||
$res = $data->update();
|
||||
if($res !== false){
|
||||
$return['msg'] = '参数标记成功';
|
||||
$return['errorcode'] = 200;
|
||||
$return['data'] = ['css'=>'default'];
|
||||
}else{
|
||||
$return['msg'] = '参数标记失败';
|
||||
$return['errorcode'] = 0;
|
||||
}
|
||||
break;
|
||||
case 'swimmingpool':
|
||||
$data->swimmingpool = ($data->swimmingpool) ? 0 : 1;
|
||||
$res = $data->update();
|
||||
if($res !== false){
|
||||
$return['msg'] = '参数标记成功';
|
||||
$return['errorcode'] = 200;
|
||||
$return['data'] = ['css'=>'default'];
|
||||
}else{
|
||||
$return['msg'] = '参数标记失败';
|
||||
$return['errorcode'] = 0;
|
||||
}
|
||||
break;
|
||||
case 'gas':
|
||||
$data->gas = ($data->gas) ? 0 : 1;
|
||||
$res = $data->update();
|
||||
if($res !== false){
|
||||
$return['msg'] = '参数标记成功';
|
||||
$return['errorcode'] = 200;
|
||||
$return['data'] = ['css'=>'default'];
|
||||
}else{
|
||||
$return['msg'] = '参数标记失败';
|
||||
$return['errorcode'] = 0;
|
||||
}
|
||||
break;
|
||||
case 'wifi':
|
||||
$data->wifi = ($data->wifi) ? 0 : 1;
|
||||
$res = $data->update();
|
||||
if($res !== false){
|
||||
$return['msg'] = '参数标记成功';
|
||||
$return['errorcode'] = 200;
|
||||
$return['data'] = ['css'=>'default'];
|
||||
}else{
|
||||
$return['msg'] = '参数标记失败';
|
||||
$return['errorcode'] = 0;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
exit(json_encode($return));
|
||||
}
|
||||
|
||||
}
|
||||
Executable
+111
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @Author: fm453
|
||||
* @Date: 2018-04-23 14:29:56
|
||||
* @Last Modified by: fm453
|
||||
* @Last Modified time: 2021-04-28 17:12:54
|
||||
* @Email: fm453@lukegzs.com
|
||||
*/
|
||||
|
||||
namespace backend\controllers;
|
||||
|
||||
use Yii;
|
||||
use yii\web\Controller;
|
||||
use yii\filters\VerbFilter;
|
||||
use yii\filters\AccessControl;
|
||||
use backend\models\LoginForm;
|
||||
use backend\models\Menu;
|
||||
|
||||
use backend\components\Helper;
|
||||
|
||||
/**
|
||||
* Site controller
|
||||
*/
|
||||
class SiteController extends Controller
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function behaviors()
|
||||
{
|
||||
return [
|
||||
'access' => [
|
||||
'class' => AccessControl::className(),
|
||||
'rules' => [
|
||||
[
|
||||
'actions' => ['login', 'error'],
|
||||
'allow' => true,
|
||||
],
|
||||
[
|
||||
'actions' => ['logout', 'index'],
|
||||
'allow' => true,
|
||||
'roles' => ['@'],
|
||||
],
|
||||
],
|
||||
],
|
||||
'verbs' => [
|
||||
'class' => VerbFilter::className(),
|
||||
'actions' => [
|
||||
'logout' => ['get'],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function actions()
|
||||
{
|
||||
return [
|
||||
'error' => [
|
||||
'class' => 'yii\web\ErrorAction',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
public function actionIndex()
|
||||
{
|
||||
$user_id=Yii::$app->user->identity->getId();
|
||||
$user_info = Yii::$app->authManager->getRolesByUser($user_id);
|
||||
$role = $user_info[key($user_info)];
|
||||
$menu = array();
|
||||
$roleType = $role->type;
|
||||
require Yii::getAlias('@backend').'/menus/'.'0.php';
|
||||
$menu2 = new Menu();
|
||||
$menu2 = $menu2->getLeftMenuList();
|
||||
if(isset($_GET['debug']) && $_GET['debug']){
|
||||
$menu = array_merge($menu,$menu2);
|
||||
}
|
||||
|
||||
return $this->render('index',[
|
||||
'menu' => $menu,
|
||||
'user_info' => key($user_info)
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionLogin()
|
||||
{
|
||||
if (!Yii::$app->user->isGuest) {
|
||||
return $this->goHome();
|
||||
}
|
||||
|
||||
$model = new LoginForm();
|
||||
if ($model->load(Yii::$app->request->post()) && $model->login()) {
|
||||
$model->loginLog();
|
||||
return $this->goBack();
|
||||
} else {
|
||||
return $this->render('login', [
|
||||
'model' => $model,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function actionLogout()
|
||||
{
|
||||
Yii::$app->user->logout();
|
||||
return $this->goHome();
|
||||
}
|
||||
|
||||
}
|
||||
Executable
+179
@@ -0,0 +1,179 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @Author: fm453
|
||||
* @Date: 2018-08-17 19:39:41
|
||||
* @Last Modified by: fm453
|
||||
* @Last Modified time: 2021-04-28 17:30:36
|
||||
* @Email: fm453@lukegzs.com
|
||||
*/
|
||||
namespace backend\controllers;
|
||||
|
||||
use Yii;
|
||||
use yii\data\Pagination;
|
||||
use yii\helpers\Url;
|
||||
use backend\models\CAttachment;
|
||||
use common\components\Attachment;
|
||||
|
||||
class UploadController extends \yii\web\Controller
|
||||
{
|
||||
public $enableCsrfValidation = false; //取消csrf令牌验证;不取消的话文件上传会失败
|
||||
|
||||
//替代常规的_construct 析构函数;其他方法调用前执行
|
||||
public function init()
|
||||
{
|
||||
parent::init();
|
||||
$session = Yii::$app->session;
|
||||
if(isset($_GET['pid']) && (int)$_GET['pid']>0){
|
||||
$session->set('pid',(int)$_GET['pid']);
|
||||
}
|
||||
$pid = $session->get('pid');
|
||||
if(!$pid){
|
||||
$url = Url::toRoute('/index/index');
|
||||
return $this->redirect($url);
|
||||
}
|
||||
}
|
||||
|
||||
//主界面
|
||||
public function actionIndex()
|
||||
{
|
||||
return $this->render('../layouts/dev',[]);
|
||||
}
|
||||
|
||||
public function actionImage()
|
||||
{
|
||||
global $_HI,$_FM;
|
||||
$siteId = Yii::$app->params['siteId'];
|
||||
$session = Yii::$app->session;
|
||||
$pid = (int)$session->get('pid');
|
||||
$model = new CAttachment();
|
||||
$where = [];
|
||||
$where['status_code'] = 1;
|
||||
$where['type'] = 0;
|
||||
$where['siteid'] = $siteId;
|
||||
$where['pid'] = $pid;
|
||||
//分页
|
||||
$orderby = ['id' => SORT_DESC];
|
||||
$Attachemnt = new Attachment();
|
||||
$list = $Attachemnt->getData($model,$where,$orderby);
|
||||
$pager = $Attachemnt->getPagination();
|
||||
|
||||
//附件网址前缀
|
||||
$src = Url::base(true)."/../../upload"; //在网站根目录下使用upload/pics目录;适合使用yii框架主目录入口而非绑定子域名的情形
|
||||
if($_SERVER['DOCUMENT_ROOT'].'/upload' != Yii::getAlias("@upload")){
|
||||
// $src = Url::toRoute(['attach/index','img'=>'']); //换用网络加载转换的方式-反应慢
|
||||
$src = Yii::$app->params['attachSrc'].Yii::$app->params['attachDir'];
|
||||
}
|
||||
|
||||
$callback = isset($_GET['callback']) ? $_GET['callback'] : 'thumb';
|
||||
return $this->render('image/list',[
|
||||
'list'=>$list,
|
||||
'pager' => $pager,
|
||||
'src'=>$src,
|
||||
'callback'=>$callback
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionImage_save()
|
||||
{
|
||||
global $_HI,$_FM;
|
||||
// $post = [
|
||||
// 'name'=> "IMG_3829.JPG",
|
||||
// 'path'=>"/temp",
|
||||
// 'root'=> "/Users/fm453/webdev/localhost/i/upload/temp/IMG_3829.JPG",
|
||||
// 'size'=> 271389,
|
||||
// 'type'=> "image/jpeg",
|
||||
// 'lasttime'=> 'Mon Oct 15 2018 19:43:05 GMT+0800 (中国标准时间)',
|
||||
// 'ext'=> "JPG",
|
||||
// 'params'=> '{type: "image/jpeg", width: 1080, height: 1080}'
|
||||
// ];
|
||||
$post = Yii::$app->request->post();
|
||||
if(!$post['root']){
|
||||
die(json_encode('没有传入文件路径'));
|
||||
}
|
||||
// 文件附件目录
|
||||
$attachDir = Yii::getAlias('@upload'); //附件所在目录
|
||||
|
||||
$targetDir = "/pics"; //开始构建目标转存目录
|
||||
if (!file_exists($attachDir . $targetDir)) {
|
||||
@mkdir($attachDir . $targetDir);
|
||||
}
|
||||
|
||||
$session = Yii::$app->session;
|
||||
$siteId = Yii::$app->params['siteId'];
|
||||
$targetDir .= '/'.$siteId;
|
||||
if (!file_exists($attachDir . $targetDir)) {
|
||||
@mkdir($attachDir . $targetDir);
|
||||
}
|
||||
|
||||
$pid = (int)$session->get('pid');
|
||||
$targetDir .= '/'.$pid;
|
||||
if (!file_exists($attachDir . $targetDir)) {
|
||||
@mkdir($attachDir . $targetDir);
|
||||
}
|
||||
|
||||
$timeDir = date('Ym');
|
||||
$targetDir .= "/".$timeDir;
|
||||
if (!file_exists($attachDir . $targetDir)) {
|
||||
@mkdir($attachDir . $targetDir);
|
||||
}
|
||||
|
||||
//处理请求的文件信息
|
||||
$title = isset($post['name']) ? $post['name'] : md5(TIMESTAMP).'.jpg';
|
||||
//取后缀名
|
||||
if($post['ext']){
|
||||
$suffix = strtolower($post['ext']);
|
||||
}else{
|
||||
$_names = explode('.',$title);
|
||||
$suffix = tolower($_names[count($_names)-1]);
|
||||
}
|
||||
$newName = date('dHis',TIMESTAMP).'_'.md5($title);
|
||||
$root = $post['root'];
|
||||
$newFile = $attachDir . $targetDir."/".$newName.".".$suffix;
|
||||
$tempfile = $post['root'];
|
||||
//文件移动,【完整文件名-含路径,目标目录】
|
||||
rename($tempfile,$newFile);
|
||||
$options = json_encode($post['params']);
|
||||
//文件入库
|
||||
$model = new CAttachment();
|
||||
$model->siteid = $siteId;
|
||||
$model->pid = $pid;
|
||||
$model->uid = $_FM['user']['uid'];
|
||||
$model->mid = 0;
|
||||
$model->type = 0;
|
||||
$model->status_code = 1;
|
||||
$model->title = $title;
|
||||
$model->filesize = $post['size'];
|
||||
$model->route = $targetDir."/".$newName.".".$suffix;
|
||||
$model->options = $options;
|
||||
$model->update_at = $model->create_at = time();
|
||||
$model->save();
|
||||
$id = $model->attributes['id']; //获取插入后id
|
||||
|
||||
$return=[];
|
||||
$return['msg'] = '';
|
||||
$return['code'] = 0;
|
||||
$return['path'] = $model->route;
|
||||
if(!$id){
|
||||
$return['code'] = 453100;
|
||||
$return['msg'] = $model->getErrors();
|
||||
}
|
||||
$return['data'] = ['id'=>$id];
|
||||
die(json_encode($return));
|
||||
}
|
||||
|
||||
public function actionSimditor()
|
||||
{
|
||||
//针对simditor插件
|
||||
global $_HI,$_FM;
|
||||
// "success": true/false,
|
||||
// "msg": "error message", # optional
|
||||
// "file_path": "[real file path]"
|
||||
//
|
||||
$return=[];
|
||||
$return['msg'] = '';
|
||||
$return['success'] = true;
|
||||
$return['file_path'] = 'http://public.hiluker.com/anchengjieshun/banner-ad-1180-300.png';
|
||||
die(json_encode($return));
|
||||
}
|
||||
}
|
||||
Executable
+22
@@ -0,0 +1,22 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>恭喜,站点创建成功!</title>
|
||||
<link rel="stylesheet" href="//cdn.bootcss.com/bootstrap/3.3.4/css/bootstrap.min.css">
|
||||
<script src="//cdn.bootcss.com/jquery/1.11.2/jquery.min.js"></script>
|
||||
<script src="//cdn.bootcss.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container" style="margin-top:9%;">
|
||||
<div class="jumbotron">
|
||||
<div class="panel panel-success">
|
||||
<div class="panel-heading"><h1>恭喜, 站点创建成功!</h1></div>
|
||||
</div>
|
||||
<p><h3>站点创建成功,本页面由系统自动生成。</h3></p>
|
||||
<p><li>本页面在FTP根目录下的index.html</li></p>
|
||||
<p><li>您可以删除或覆盖本页面</li></p>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Executable
+1
@@ -0,0 +1 @@
|
||||
语言包路径
|
||||
Executable
+3
@@ -0,0 +1,3 @@
|
||||
User-agent: *
|
||||
Disallow: /
|
||||
Crawl-delay: 120
|
||||
Executable
+264
@@ -0,0 +1,264 @@
|
||||
<?php
|
||||
return [
|
||||
/* 系统信息 开始 */
|
||||
'Project Name' => 'DACMS',
|
||||
'Short Company Name' => '嗨路客',
|
||||
'Full Company Name' => '海南嗨路客电子商务有限公司',
|
||||
'English Company Name' => 'Hi Luker',
|
||||
'Company Create Time' => '2013',
|
||||
'System Name' => 'DACMS控制面板 Beta',
|
||||
'System' => '系统',
|
||||
/* 系统信息 结束 */
|
||||
|
||||
/* 按钮 开始 */
|
||||
'Profile' => '个人资料',
|
||||
'Settings' => '设置',
|
||||
'Logout' => '退出系统',
|
||||
'Login' => '登录',
|
||||
'Create' => '创建',
|
||||
'Update' => '更新',
|
||||
'Delete' => '删除',
|
||||
'View' => '查看',
|
||||
'List' => '列表',
|
||||
'Submit' => '提交',
|
||||
'Show' => '显示',
|
||||
'Hide' => '隐藏',
|
||||
'Update Status' => '修改状态',
|
||||
'Back' => '返回',
|
||||
'Refresh' => '刷新',
|
||||
'Refund Control' => '退款',
|
||||
'Refund Completed' => '已完成退款',
|
||||
'Refund Agreed' => '已同意退款',
|
||||
'On the Shelf' => '上架',
|
||||
'Off the Shelf' => '下架',
|
||||
'Cancel' => '取消',
|
||||
'Recovery' => '恢复',
|
||||
|
||||
'Set Password' => '修改密码',
|
||||
'Reset Password' => '重置密码',
|
||||
'Add Bike Storage' => '车辆入库',
|
||||
'Add Bike Storage Again' => '继续入库',
|
||||
'Allocate Bike Storage' => '车辆调库',
|
||||
'Tour Group' => '行程团期',
|
||||
'Create Tour Group' => '创建团期',
|
||||
'Create Tour Group Again' => '继续创建团期',
|
||||
/* 按钮 结束 */
|
||||
|
||||
/* 提示 开始 */
|
||||
//以下是提示文字
|
||||
'Username' => '登陆名',
|
||||
'Avatar' => '头像',
|
||||
'Password' => '登录密码',
|
||||
'Remember Me' => '记住密码',
|
||||
'Email' => '邮箱',
|
||||
'Mobile' => '手机',
|
||||
'Role' => '用户组',
|
||||
'Verify Code' => '验证码',
|
||||
'Search' => '查询',
|
||||
'Switching Sidebar' => '切换侧边栏',
|
||||
'System Error!' => '系统出错啦',
|
||||
'System Error' => '系统错误',
|
||||
'Sytem Unknown Error' => '崩溃...系统也不知道哪里错了',
|
||||
'More Controllers' => '更多操作',
|
||||
'Go back' => '返回上一页',
|
||||
|
||||
//以下是提示句子
|
||||
'Not find data' => '暂无数据!',
|
||||
'{start}-{end} a total of {total}'=>'第<b>{start}-{end}</b>条,共<b>{total}</b>条数据',
|
||||
'The requested page does not exist' => '请求的页面不存在',
|
||||
'Are you sure to delete {param}?' => '确定删除 {param} 吗?',
|
||||
'Are you sure you want to delete this item?' => '确定要删除当前记录?',
|
||||
'Delete the item {param} successful!' => '{param}记录删除成功!',
|
||||
'Delete the item {param} failed!' => '{param}记录删除失败!',
|
||||
'Delete the item {param} failed because of {relations}!' => '删除失败,请先删除当前{param}以下关联信息:{relations}。',
|
||||
'Are you sure you want to change status to {param}?' => '确定要修改当前状态为 {param} 吗?',
|
||||
'User name will be used as the login account' => '用户名将作为管理员登录账号使用。',
|
||||
'Password must be the same.' => '两次密码不一致。',
|
||||
'Old password is incorrect.' => '原密码错误。',
|
||||
"Are you sure to reset {param}'s password?" => '确定要重置 {param} 的密码吗?',
|
||||
'Reset password successful!' => '密码重置成功!',
|
||||
'Reset password failed!' => '密码重置失败!',
|
||||
'Update status successful!' => '状态修改成功!',
|
||||
'Update status failed!' => '状态修改失败!',
|
||||
'Add Sensitive Word:' => '增加敏感词:',
|
||||
'Recommend {param} successful!' => '{param}推荐成功!',
|
||||
'Role delete successful!' => '角色删除成功!',
|
||||
'Role delete failed! Please checked it.' => '角色删除失败!请检查系统是否存在该角色的管理员。',
|
||||
'You don\'t have permission to access this action.Please contract administrator to know about permission managment.' => '没有访问权限!请联系管理员了解权限管理。',
|
||||
'You\'re not allow to access this action.' => '没有访问权限!',
|
||||
'Input \'0\' means unlimited of this item.' => '输入0表示无限制',
|
||||
|
||||
'Unknown operation.' => '未知操作。',
|
||||
'<a href="{profile}">{admin}</a> view the {label} record:<a href="{url}">{item}</a>.' => '<a href="{profile}">{admin}</a> 查看了{label} <a href="{url}">{item}</a>。',
|
||||
'<a href="{profile}">{admin}</a> created a new {label} record:<a href="{url}">{item}</a>.' => '<a href="{profile}">{admin}</a> 创建了{label} <a href="{url}">{item}</a>。',
|
||||
'<a href="{profile}">{admin}</a> updated the {label} record:{attributes} of <a href="{url}">{item}</a>.' => '<a href="{profile}">{admin}</a> 修改了{label} <a href="{url}">{item}</a> 的以下信息:{attributes}。',
|
||||
'<a href="{profile}">{admin}</a> deleted the {label} record:{item}.' => '<a href="{profile}">{admin}</a> 删除了{label} {item}。',
|
||||
'<a href="{profile}">{admin}</a> reset the <a href="{url}">{item}</a> password to {password}.' => '<a href="{profile}">{admin}</a> 把 <a href="{url}">{item}</a> 的密码重置为了 {password}。',
|
||||
'<a href="{profile}">{admin}</a> update the {label} <a href="{url}">{item}</a> <a href="{subitem_url}">{subitem}</a> status to {status}.' => '<a href="{profile}">{admin}</a> 把{label} <a href="{url}">{item}</a> 的 <a href="{subitem_url}">{subitem}</a> 状态修改为了 {status}。',
|
||||
'<a href="{profile}">{admin}</a> deleted the {label} <a href="{url}">{title}</a> comment record:{item}.' => '<a href="{profile}">{admin}</a> 删除了{label} <a href="{url}">{title}</a> 的评论 {item}。',
|
||||
'<a href="{profile}">{admin}</a> login system.' => '<a href="{profile}">{admin}</a> 登录了系统。',
|
||||
'<a href="{profile}">{admin}</a> logout system.' => '<a href="{profile}">{admin}</a> 退出了系统。',
|
||||
'<a href="{profile}">{admin}</a> recommended {num} {unit}<a href="{url}">{item}</a>.' => '<a href="{profile}">{admin}</a> 推荐了{num}{unit} <a href="{url}">{item}</a>。',
|
||||
'<a href="{profile}">{admin}</a> operated an order refund,code is <a href="{url}">{item}</a>,amount is {refund_amount}, refund massage is {msg}.' => '<a href="{profile}">{admin}</a> 操作了一笔订单退款,订单编号:<a href="{url}">{item}</a>,退款金额:{refund_amount}元,操作信息:{msg}。',
|
||||
/* 提示 结束 */
|
||||
|
||||
/* 标题 开始 */
|
||||
'Console' => '控制台',
|
||||
/* 标题 结束 */
|
||||
|
||||
/* 系统导航栏 开始 */
|
||||
'See all' => '查看全部',
|
||||
'Notifications' => '通知',
|
||||
'Messages' => '消息',
|
||||
'New Comments' => '新的评论',
|
||||
'New Orders' => '新的订单',
|
||||
'New Users' => '新注册用户',
|
||||
/* 系统导航栏 结束 */
|
||||
|
||||
/* 通用文字 开始 */
|
||||
//跟状态相关的文字
|
||||
'Normal' => '正常',
|
||||
'Forbidden' => '禁用',
|
||||
'Read Only' => '只读',
|
||||
'Writable' => '可写',
|
||||
'Yes' => '是',
|
||||
'No' => '不是',
|
||||
'Offline' => '已下线',
|
||||
'Online' => '上线中',
|
||||
'Fixing' => '维修中',
|
||||
'Unlimited' => '不限',
|
||||
|
||||
'Dashboard' => '控制面板',
|
||||
'Administrator' => '管理员',
|
||||
'Role' => '角色',
|
||||
'Role Management' => '角色管理',
|
||||
'Role Defined' => '角色定义',
|
||||
'Site Manager Name' => '网点负责人',
|
||||
'General Employee' => '普通员工',
|
||||
'Site Manager' => '门店经理',
|
||||
'City Name' => '所属城市',
|
||||
'Site Name' => '所属网点',
|
||||
'Bike Storage Management' => '车辆库存管理',
|
||||
|
||||
//跟性别相关的文字
|
||||
'Sex' => '性别',
|
||||
'Male' => '男',
|
||||
'Famale' => '女',
|
||||
|
||||
//其他
|
||||
'All' => '全部',
|
||||
'Unknown' => '未知',
|
||||
'User Defined' => '自定义',
|
||||
'Moment Ago' => '刚刚',
|
||||
'Permission Group' => '权限组',
|
||||
'General Information' => '基本信息',
|
||||
'Relevant Route' => '相关路书',
|
||||
'Relevant Comment' => '相关评论',
|
||||
'Route Features' => '路书特点',
|
||||
'Employee Information' => '员工信息',
|
||||
'Setting Permission' => '权限设置',
|
||||
'Processing Record' => '处理记录',
|
||||
'Processing History' => '处理记录历史',
|
||||
'Bike Information' => '车辆信息',
|
||||
'Fee Detail' => '费用详情',
|
||||
'Relevant Order' => '相关订单',
|
||||
'Content Detail' => '内容详情',
|
||||
'Comment List' => '回复列表',
|
||||
'Delete Comment' => '删除评论',
|
||||
'Comment' => '评价',
|
||||
'Recommend Content' => '推荐内容',
|
||||
'Add Recommend' => '添加推荐',
|
||||
'Recommending' =>'推荐',
|
||||
'Route Characteristic' => '路书特点',
|
||||
'Storage General Information' => '库存单信息',
|
||||
'Bike Common Storage List' => '入库车型列表',
|
||||
'Bike Storage List' => '入库车辆列表',
|
||||
'Storage Information' => '库存信息',
|
||||
'Use Record' => '使用记录',
|
||||
'Rent Information' => '租赁信息',
|
||||
'Fees Information' => '费用信息',
|
||||
'Service Information' => '服务信息',
|
||||
'Coupon Information' => '优惠券信息',
|
||||
'Coupon Recived Information' => '领取信息',
|
||||
'Coupon Used Information' => '使用信息',
|
||||
'Recived Coupon' => '领用券',
|
||||
'Fee and Spec' => '费用与规格',
|
||||
'Time and Schedule' => '时间与日程',
|
||||
'Other Text' => '其他文本',
|
||||
'Insurance' => '保险',
|
||||
'Optional Field' => '其他项目',
|
||||
'Pay Information' => '支付信息',
|
||||
'Estimated Fees' => '预计费用',
|
||||
'Tour Information' => '行程信息',
|
||||
'Activity Apply Information' => '报名信息',
|
||||
'Share Information' => '分享信息',
|
||||
'Settle Account Information' => '结算账号信息',
|
||||
'Site List' => '网点列表',
|
||||
'Memeber Information' => '人员信息',
|
||||
'Site Bike Rent Information' => '租赁信息',
|
||||
'Site and Role Information' => '网点角色信息',
|
||||
'Site Service Information' => '服务网点信息',
|
||||
'Edit Information' => '编辑信息',
|
||||
'Route Map Information' => '路书地图信息',
|
||||
'Book Information' => '预约信息',
|
||||
'Rent Information' => '租车信息',
|
||||
'Refund Information' => '退款信息',
|
||||
'Insurance Information' => '保险信息',
|
||||
|
||||
'' => '',
|
||||
/* 通用文字 结束 */
|
||||
|
||||
/* Controller名 */
|
||||
'Addition' => '选件',
|
||||
'Admin' => '管理员',
|
||||
'Article' => '文档',
|
||||
'BikeCommon' => '车型',
|
||||
'Bike' => '车辆',
|
||||
'Destination' => '兴趣点',
|
||||
'Employee' => '店员',
|
||||
'Role' => '角色',
|
||||
'Route' => '路书',
|
||||
'Site' => '网点',
|
||||
'User' => '会员',
|
||||
'WorkOrder' => '工单',
|
||||
'CommonArticle' => '常用文本',
|
||||
'OperateLog' => '日志记录',
|
||||
'Order' => '订单',
|
||||
'OrderBikeComment' => '订单评价',
|
||||
'SensitiveWord' => '敏感词',
|
||||
'Topic' => '帖子',
|
||||
'Recommend' => '推荐位',
|
||||
'SiteBikeRent' => '车型租赁',
|
||||
'BikeStorageLog' => '车辆库存',
|
||||
'BookOrder' => '预约订单',
|
||||
'RentOrder' => '租车订单',
|
||||
'OrderRefund' => '租车退款',
|
||||
'Coupon' => '优惠券',
|
||||
'UserCoupon' => '用户优惠券',
|
||||
'Tour' => '行程',
|
||||
'TourGroupCommon' => '行程团期',
|
||||
'Activity' => '活动',
|
||||
'Business' => '商家',
|
||||
'TourOrder' => '行程订单',
|
||||
'TeamOrder' => '团体订单',
|
||||
'ActivityUser' => '活动报名',
|
||||
'TourOrderRefund' => '行程退款',
|
||||
'Category' => '分类',
|
||||
'AccountOrder' => '租车结算单',
|
||||
|
||||
/* 字段名 */
|
||||
'Recommend Count' => '推荐数',
|
||||
'Lon And Lat' => '经纬度',
|
||||
|
||||
/* 控制面板 */
|
||||
'New Orders' => '今日订单',
|
||||
'Login Users' => '登录用户',
|
||||
'New Registers' => '新增注册',
|
||||
'Today Amount' => '成交金额',
|
||||
'Topic Count' => '帖子数量',
|
||||
'Order Status Chart' => '订单统计',
|
||||
'This Week' => '本周',
|
||||
'Last Week' => '上周',
|
||||
'This Month' => '本月',
|
||||
'Last Month' => '上月',
|
||||
];
|
||||
Executable
+264
@@ -0,0 +1,264 @@
|
||||
<?php
|
||||
return [
|
||||
/* 系统信息 开始 */
|
||||
'Project Name' => 'Hi',
|
||||
'Short Company Name' => '嗨路客',
|
||||
'Full Company Name' => '海南嗨路客电子商务有限公司',
|
||||
'English Company Name' => 'Hi Luker',
|
||||
'Company Create Time' => '2013',
|
||||
'System Name' => '管理系统后台',
|
||||
'System' => '系统',
|
||||
/* 系统信息 结束 */
|
||||
|
||||
/* 按钮 开始 */
|
||||
'Profile' => '个人资料',
|
||||
'Settings' => '设置',
|
||||
'Logout' => '退出系统',
|
||||
'Login' => '登录',
|
||||
'Create' => '创建',
|
||||
'Update' => '更新',
|
||||
'Delete' => '删除',
|
||||
'View' => '查看',
|
||||
'List' => '列表',
|
||||
'Submit' => '提交',
|
||||
'Show' => '显示',
|
||||
'Hide' => '隐藏',
|
||||
'Update Status' => '修改状态',
|
||||
'Back' => '返回',
|
||||
'Refresh' => '刷新',
|
||||
'Refund Control' => '退款',
|
||||
'Refund Completed' => '已完成退款',
|
||||
'Refund Agreed' => '已同意退款',
|
||||
'On the Shelf' => '上架',
|
||||
'Off the Shelf' => '下架',
|
||||
'Cancel' => '取消',
|
||||
'Recovery' => '恢复',
|
||||
|
||||
'Set Password' => '修改密码',
|
||||
'Reset Password' => '重置密码',
|
||||
'Add Bike Storage' => '车辆入库',
|
||||
'Add Bike Storage Again' => '继续入库',
|
||||
'Allocate Bike Storage' => '车辆调库',
|
||||
'Tour Group' => '行程团期',
|
||||
'Create Tour Group' => '创建团期',
|
||||
'Create Tour Group Again' => '继续创建团期',
|
||||
/* 按钮 结束 */
|
||||
|
||||
/* 提示 开始 */
|
||||
//以下是提示文字
|
||||
'Username' => '登陆名',
|
||||
'Avatar' => '头像',
|
||||
'Password' => '登录密码',
|
||||
'Remember Me' => '记住密码',
|
||||
'Email' => '邮箱',
|
||||
'Mobile' => '手机',
|
||||
'Role' => '用户组',
|
||||
'Verify Code' => '验证码',
|
||||
'Search' => '查询',
|
||||
'Switching Sidebar' => '切换侧边栏',
|
||||
'System Error!' => '系统出错啦',
|
||||
'System Error' => '系统错误',
|
||||
'Sytem Unknown Error' => '崩溃...系统也不知道哪里错了',
|
||||
'More Controllers' => '更多操作',
|
||||
'Go back' => '返回上一页',
|
||||
|
||||
//以下是提示句子
|
||||
'Not find data' => '暂无数据!',
|
||||
'{start}-{end} a total of {total}'=>'第<b>{start}-{end}</b>条,共<b>{total}</b>条数据',
|
||||
'The requested page does not exist' => '请求的页面不存在',
|
||||
'Are you sure to delete {param}?' => '确定删除 {param} 吗?',
|
||||
'Are you sure you want to delete this item?' => '确定要删除当前记录?',
|
||||
'Delete the item {param} successful!' => '{param}记录删除成功!',
|
||||
'Delete the item {param} failed!' => '{param}记录删除失败!',
|
||||
'Delete the item {param} failed because of {relations}!' => '删除失败,请先删除当前{param}以下关联信息:{relations}。',
|
||||
'Are you sure you want to change status to {param}?' => '确定要修改当前状态为 {param} 吗?',
|
||||
'User name will be used as the login account' => '用户名将作为管理员登录账号使用。',
|
||||
'Password must be the same.' => '两次密码不一致。',
|
||||
'Old password is incorrect.' => '原密码错误。',
|
||||
"Are you sure to reset {param}'s password?" => '确定要重置 {param} 的密码吗?',
|
||||
'Reset password successful!' => '密码重置成功!',
|
||||
'Reset password failed!' => '密码重置失败!',
|
||||
'Update status successful!' => '状态修改成功!',
|
||||
'Update status failed!' => '状态修改失败!',
|
||||
'Add Sensitive Word:' => '增加敏感词:',
|
||||
'Recommend {param} successful!' => '{param}推荐成功!',
|
||||
'Role delete successful!' => '角色删除成功!',
|
||||
'Role delete failed! Please checked it.' => '角色删除失败!请检查系统是否存在该角色的管理员。',
|
||||
'You don\'t have permission to access this action.Please contract administrator to know about permission managment.' => '没有访问权限!请联系管理员了解权限管理。',
|
||||
'You\'re not allow to access this action.' => '没有访问权限!',
|
||||
'Input \'0\' means unlimited of this item.' => '输入0表示无限制',
|
||||
|
||||
'Unknown operation.' => '未知操作。',
|
||||
'<a href="{profile}">{admin}</a> view the {label} record:<a href="{url}">{item}</a>.' => '<a href="{profile}">{admin}</a> 查看了{label} <a href="{url}">{item}</a>。',
|
||||
'<a href="{profile}">{admin}</a> created a new {label} record:<a href="{url}">{item}</a>.' => '<a href="{profile}">{admin}</a> 创建了{label} <a href="{url}">{item}</a>。',
|
||||
'<a href="{profile}">{admin}</a> updated the {label} record:{attributes} of <a href="{url}">{item}</a>.' => '<a href="{profile}">{admin}</a> 修改了{label} <a href="{url}">{item}</a> 的以下信息:{attributes}。',
|
||||
'<a href="{profile}">{admin}</a> deleted the {label} record:{item}.' => '<a href="{profile}">{admin}</a> 删除了{label} {item}。',
|
||||
'<a href="{profile}">{admin}</a> reset the <a href="{url}">{item}</a> password to {password}.' => '<a href="{profile}">{admin}</a> 把 <a href="{url}">{item}</a> 的密码重置为了 {password}。',
|
||||
'<a href="{profile}">{admin}</a> update the {label} <a href="{url}">{item}</a> <a href="{subitem_url}">{subitem}</a> status to {status}.' => '<a href="{profile}">{admin}</a> 把{label} <a href="{url}">{item}</a> 的 <a href="{subitem_url}">{subitem}</a> 状态修改为了 {status}。',
|
||||
'<a href="{profile}">{admin}</a> deleted the {label} <a href="{url}">{title}</a> comment record:{item}.' => '<a href="{profile}">{admin}</a> 删除了{label} <a href="{url}">{title}</a> 的评论 {item}。',
|
||||
'<a href="{profile}">{admin}</a> login system.' => '<a href="{profile}">{admin}</a> 登录了系统。',
|
||||
'<a href="{profile}">{admin}</a> logout system.' => '<a href="{profile}">{admin}</a> 退出了系统。',
|
||||
'<a href="{profile}">{admin}</a> recommended {num} {unit}<a href="{url}">{item}</a>.' => '<a href="{profile}">{admin}</a> 推荐了{num}{unit} <a href="{url}">{item}</a>。',
|
||||
'<a href="{profile}">{admin}</a> operated an order refund,code is <a href="{url}">{item}</a>,amount is {refund_amount}, refund massage is {msg}.' => '<a href="{profile}">{admin}</a> 操作了一笔订单退款,订单编号:<a href="{url}">{item}</a>,退款金额:{refund_amount}元,操作信息:{msg}。',
|
||||
/* 提示 结束 */
|
||||
|
||||
/* 标题 开始 */
|
||||
'Console' => '控制台',
|
||||
/* 标题 结束 */
|
||||
|
||||
/* 系统导航栏 开始 */
|
||||
'See all' => '查看全部',
|
||||
'Notifications' => '通知',
|
||||
'Messages' => '消息',
|
||||
'New Comments' => '新的评论',
|
||||
'New Orders' => '新的订单',
|
||||
'New Users' => '新注册用户',
|
||||
/* 系统导航栏 结束 */
|
||||
|
||||
/* 通用文字 开始 */
|
||||
//跟状态相关的文字
|
||||
'Normal' => '正常',
|
||||
'Forbidden' => '禁用',
|
||||
'Read Only' => '只读',
|
||||
'Writable' => '可写',
|
||||
'Yes' => '是',
|
||||
'No' => '不是',
|
||||
'Offline' => '已下线',
|
||||
'Online' => '上线中',
|
||||
'Fixing' => '维修中',
|
||||
'Unlimited' => '不限',
|
||||
|
||||
'Dashboard' => '控制面板',
|
||||
'Administrator' => '管理员',
|
||||
'Role' => '角色',
|
||||
'Role Management' => '角色管理',
|
||||
'Role Defined' => '角色定义',
|
||||
'Site Manager Name' => '网点负责人',
|
||||
'General Employee' => '普通员工',
|
||||
'Site Manager' => '门店经理',
|
||||
'City Name' => '所属城市',
|
||||
'Site Name' => '所属网点',
|
||||
'Bike Storage Management' => '车辆库存管理',
|
||||
|
||||
//跟性别相关的文字
|
||||
'Sex' => '性别',
|
||||
'Male' => '男',
|
||||
'Famale' => '女',
|
||||
|
||||
//其他
|
||||
'All' => '全部',
|
||||
'Unknown' => '未知',
|
||||
'User Defined' => '自定义',
|
||||
'Moment Ago' => '刚刚',
|
||||
'Permission Group' => '权限组',
|
||||
'General Information' => '基本信息',
|
||||
'Relevant Route' => '相关路书',
|
||||
'Relevant Comment' => '相关评论',
|
||||
'Route Features' => '路书特点',
|
||||
'Employee Information' => '员工信息',
|
||||
'Setting Permission' => '权限设置',
|
||||
'Processing Record' => '处理记录',
|
||||
'Processing History' => '处理记录历史',
|
||||
'Bike Information' => '车辆信息',
|
||||
'Fee Detail' => '费用详情',
|
||||
'Relevant Order' => '相关订单',
|
||||
'Content Detail' => '内容详情',
|
||||
'Comment List' => '回复列表',
|
||||
'Delete Comment' => '删除评论',
|
||||
'Comment' => '评价',
|
||||
'Recommend Content' => '推荐内容',
|
||||
'Add Recommend' => '添加推荐',
|
||||
'Recommending' =>'推荐',
|
||||
'Route Characteristic' => '路书特点',
|
||||
'Storage General Information' => '库存单信息',
|
||||
'Bike Common Storage List' => '入库车型列表',
|
||||
'Bike Storage List' => '入库车辆列表',
|
||||
'Storage Information' => '库存信息',
|
||||
'Use Record' => '使用记录',
|
||||
'Rent Information' => '租赁信息',
|
||||
'Fees Information' => '费用信息',
|
||||
'Service Information' => '服务信息',
|
||||
'Coupon Information' => '优惠券信息',
|
||||
'Coupon Recived Information' => '领取信息',
|
||||
'Coupon Used Information' => '使用信息',
|
||||
'Recived Coupon' => '领用券',
|
||||
'Fee and Spec' => '费用与规格',
|
||||
'Time and Schedule' => '时间与日程',
|
||||
'Other Text' => '其他文本',
|
||||
'Insurance' => '保险',
|
||||
'Optional Field' => '其他项目',
|
||||
'Pay Information' => '支付信息',
|
||||
'Estimated Fees' => '预计费用',
|
||||
'Tour Information' => '行程信息',
|
||||
'Activity Apply Information' => '报名信息',
|
||||
'Share Information' => '分享信息',
|
||||
'Settle Account Information' => '结算账号信息',
|
||||
'Site List' => '网点列表',
|
||||
'Memeber Information' => '人员信息',
|
||||
'Site Bike Rent Information' => '租赁信息',
|
||||
'Site and Role Information' => '网点角色信息',
|
||||
'Site Service Information' => '服务网点信息',
|
||||
'Edit Information' => '编辑信息',
|
||||
'Route Map Information' => '路书地图信息',
|
||||
'Book Information' => '预约信息',
|
||||
'Rent Information' => '租车信息',
|
||||
'Refund Information' => '退款信息',
|
||||
'Insurance Information' => '保险信息',
|
||||
|
||||
'' => '',
|
||||
/* 通用文字 结束 */
|
||||
|
||||
/* Controller名 */
|
||||
'Addition' => '选件',
|
||||
'Admin' => '管理员',
|
||||
'Article' => '文档',
|
||||
'BikeCommon' => '车型',
|
||||
'Bike' => '车辆',
|
||||
'Destination' => '兴趣点',
|
||||
'Employee' => '店员',
|
||||
'Role' => '角色',
|
||||
'Route' => '路书',
|
||||
'Site' => '网点',
|
||||
'User' => '会员',
|
||||
'WorkOrder' => '工单',
|
||||
'CommonArticle' => '常用文本',
|
||||
'OperateLog' => '日志记录',
|
||||
'Order' => '订单',
|
||||
'OrderBikeComment' => '订单评价',
|
||||
'SensitiveWord' => '敏感词',
|
||||
'Topic' => '帖子',
|
||||
'Recommend' => '推荐位',
|
||||
'SiteBikeRent' => '车型租赁',
|
||||
'BikeStorageLog' => '车辆库存',
|
||||
'BookOrder' => '预约订单',
|
||||
'RentOrder' => '租车订单',
|
||||
'OrderRefund' => '租车退款',
|
||||
'Coupon' => '优惠券',
|
||||
'UserCoupon' => '用户优惠券',
|
||||
'Tour' => '行程',
|
||||
'TourGroupCommon' => '行程团期',
|
||||
'Activity' => '活动',
|
||||
'Business' => '商家',
|
||||
'TourOrder' => '行程订单',
|
||||
'TeamOrder' => '团体订单',
|
||||
'ActivityUser' => '活动报名',
|
||||
'TourOrderRefund' => '行程退款',
|
||||
'Category' => '分类',
|
||||
'AccountOrder' => '租车结算单',
|
||||
|
||||
/* 字段名 */
|
||||
'Recommend Count' => '推荐数',
|
||||
'Lon And Lat' => '经纬度',
|
||||
|
||||
/* 控制面板 */
|
||||
'New Orders' => '今日订单',
|
||||
'Login Users' => '登录用户',
|
||||
'New Registers' => '新增注册',
|
||||
'Today Amount' => '成交金额',
|
||||
'Topic Count' => '帖子数量',
|
||||
'Order Status Chart' => '订单统计',
|
||||
'This Week' => '本周',
|
||||
'Last Week' => '上周',
|
||||
'This Month' => '本月',
|
||||
'Last Month' => '上月',
|
||||
];
|
||||
Executable
+154
@@ -0,0 +1,154 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @Author: fm453
|
||||
* @Date: 2018-08-17 17:56:16
|
||||
* @Last Modified by: fm453
|
||||
* @Last Modified time: 2019-01-10 16:55:54
|
||||
* @Email: fm453@lukegzs.com
|
||||
*/
|
||||
$v2 = array();
|
||||
$v2[] = array(
|
||||
'name' => '首页',
|
||||
'route' => '/index/welcome',
|
||||
'data' => '{"icon":"fa fa-home"}',
|
||||
);
|
||||
$menu[] = array(
|
||||
'name' => '主工作台',
|
||||
'parent' => null,
|
||||
'route' => '/index/welcome',
|
||||
'data' => '{"icon":"fa fa-home"}',
|
||||
'_child' => $v2
|
||||
);
|
||||
|
||||
$v2 = array();
|
||||
$v2[] = array(
|
||||
'name' => '客户列表',
|
||||
'route' => '/guest/list',
|
||||
'data' => '{"icon":"fa fa-users"}',
|
||||
);
|
||||
$v2[] = array(
|
||||
'name' => '新增客户',
|
||||
'route' => '/guest/new',
|
||||
'data' => '{"icon":"fa fa-plus-square"}',
|
||||
);
|
||||
$menu[] = array(
|
||||
'name' => '客户管理',
|
||||
'parent' => null,
|
||||
'route' => '/guest/index',
|
||||
'data' => '{"icon":"fa fa-users"}',
|
||||
'_child' => $v2
|
||||
);
|
||||
|
||||
$v2 = array();
|
||||
$v2[] = array(
|
||||
'name' => '酒店列表',
|
||||
'route' => '/hotel/list',
|
||||
'data' => '{"icon":"fa fa-users"}',
|
||||
);
|
||||
$v2[] = array(
|
||||
'name' => '客房列表',
|
||||
'route' => '/room/list',
|
||||
'data' => '{"icon":"fa fa-plus-square"}',
|
||||
);
|
||||
$v2[] = array(
|
||||
'name' => '新增客房',
|
||||
'route' => '/room/new',
|
||||
'data' => '{"icon":"fa fa-plus-square"}',
|
||||
);
|
||||
$v2[] = array(
|
||||
'name' => '业主管理',
|
||||
'route' => '/owner/list',
|
||||
'data' => '{"icon":"fa fa-plus-users"}',
|
||||
);
|
||||
$menu[] = array(
|
||||
'name' => '客房管理',
|
||||
'parent' => null,
|
||||
'route' => '/room/index',
|
||||
'data' => '{"icon":"fa fa-building"}',
|
||||
'_child' => $v2
|
||||
);
|
||||
|
||||
$v2 = array();
|
||||
$v2[] = array(
|
||||
'name' => '订单列表',
|
||||
'route' => '/order/list',
|
||||
'data' => '{"icon":"fa fa-users"}',
|
||||
);
|
||||
$v2[] = array(
|
||||
'name' => '录入订单',
|
||||
'route' => '/order/new',
|
||||
'data' => '{"icon":"fa fa-plus-square"}',
|
||||
);
|
||||
$menu[] = array(
|
||||
'name' => '订单管理',
|
||||
'route' => '/order/index',
|
||||
'data' => '{"icon":"fa fa-tasks"}',
|
||||
'_child' => $v2
|
||||
);
|
||||
|
||||
$v2 = array();
|
||||
$v3 = array();
|
||||
$v3[] = array(
|
||||
'name' => '房费',
|
||||
'route' => '/fee/room',
|
||||
'data' => '',
|
||||
);
|
||||
$v3[] = array(
|
||||
'name' => '杂费',
|
||||
'route' => '/fee/incidental',
|
||||
'data' => '',
|
||||
);
|
||||
$v3[] = array(
|
||||
'name' => '二销',
|
||||
'route' => '/fee/sale',
|
||||
'data' => '',
|
||||
);
|
||||
$v3[] = array(
|
||||
'name' => '其他',
|
||||
'route' => '/fee/other',
|
||||
'data' => '',
|
||||
);
|
||||
$v2[] = array(
|
||||
'name' => '费用管理',
|
||||
'route' => '/fee/index',
|
||||
'data' => '{"icon":"fa fa-money"}',
|
||||
'_child'=>$v3
|
||||
);
|
||||
|
||||
$v3 = array();
|
||||
$v3[] = array(
|
||||
'name' => '资产列表',
|
||||
'route' => '/asset/list',
|
||||
'data' => '',
|
||||
);
|
||||
$v2[] = array(
|
||||
'name' => '资产管理',
|
||||
'route' => '/asset/index',
|
||||
'data' => '{"icon":"fa fa-user-secret"}',
|
||||
'_child'=>$v3
|
||||
);
|
||||
|
||||
$v3 = array();
|
||||
$v3[] = array(
|
||||
'name' => '员工列表',
|
||||
'route' => '/employee/list',
|
||||
'data' => '',
|
||||
);
|
||||
$v2[] = array(
|
||||
'name' => '员工管理',
|
||||
'route' => '/employee/index',
|
||||
'data' => '{"icon":"fa fa-building"}',
|
||||
'_child'=>$v3
|
||||
);
|
||||
$v2[] = array(
|
||||
'name' =>'合约管理',
|
||||
'route' => 'contract/index',
|
||||
'data' => '{"icon":"fa fa-file"}',
|
||||
);
|
||||
$menu[] = array(
|
||||
'name' => '办公处理',
|
||||
'route' => '/oa/index',
|
||||
'data' => '{"icon":"fa fa-desktop"}',
|
||||
'_child' => $v2
|
||||
);
|
||||
Executable
+112
@@ -0,0 +1,112 @@
|
||||
<?php
|
||||
namespace backend\models;
|
||||
|
||||
use Yii;
|
||||
use backend\models\AuthAssignment;
|
||||
|
||||
class Adminer extends \yii\db\ActiveRecord
|
||||
{
|
||||
|
||||
public $password;
|
||||
|
||||
const STATUS_DELETE = 0;
|
||||
const STATUS_ACTIVE = 10;
|
||||
|
||||
public static $statusTexts = [
|
||||
self::STATUS_DELETE => '禁用',
|
||||
self::STATUS_ACTIVE => '启用',
|
||||
];
|
||||
|
||||
public static $statusStyles = [
|
||||
self::STATUS_DELETE => 'label-warning',
|
||||
self::STATUS_ACTIVE => 'label-info',
|
||||
];
|
||||
|
||||
public static function tableName() {
|
||||
return '{{%c_adminer}}';
|
||||
}
|
||||
|
||||
public function rules() {
|
||||
return [
|
||||
//[['username', 'email'], 'required'],
|
||||
//[['username'], 'string', 'length' => [6, 15]],
|
||||
//[['password'], 'required', 'on' => ['create']],
|
||||
//[['reg_ip', 'last_login_time', 'last_login_ip'], 'integer'],
|
||||
//[['auth_key'], 'string', 'length' => 32],
|
||||
//[['username', 'email'], 'unique'],
|
||||
//[['email'], 'email'],
|
||||
//['status', 'default', 'value' => self::STATUS_ACTIVE],
|
||||
//['status', 'in', 'range' => [
|
||||
// self::STATUS_ACTIVE, self::STATUS_DELETE
|
||||
//]],
|
||||
|
||||
[['username','email'], 'required'],
|
||||
//[['role', 'status', 'created_at', 'updated_at'], 'integer'],
|
||||
[['username', 'password_hash', 'password_reset_token', 'email'], 'string', 'max' => 255],
|
||||
[['auth_key'], 'string', 'max' => 32],
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
public function attributeLabels() {
|
||||
return [
|
||||
'id' => 'ID',
|
||||
'username' => Yii::t('common' ,'Username'),
|
||||
'auth_key' => Yii::t('common' ,'Password'),
|
||||
'auth_key' => Yii::t('common' ,'Password'),
|
||||
'password_hash' => 'Password Hash',
|
||||
'email' => Yii::t('common' ,'Email'),
|
||||
'mobile' => Yii::t('common' ,'Mobile'),
|
||||
'reg_ip' => 'Reg Ip',
|
||||
'last_login_time' => '最后登录时间',
|
||||
'last_login_ip' => '最后登录IP',
|
||||
'status' => '状态',
|
||||
'created_at' => 'Created At',
|
||||
'updated_at' => 'Updated At',
|
||||
'user_role' => '所属角色',
|
||||
'role' => Yii::t('common' ,'Role'),
|
||||
];
|
||||
}
|
||||
|
||||
//获取所有用户
|
||||
public function get_all_user(){
|
||||
$user = Yii::$app->db->createCommand('select * from '. tableName())->queryAll();
|
||||
return $user;
|
||||
}
|
||||
|
||||
public function getUsergrouplist()
|
||||
{
|
||||
/**
|
||||
* 第一个参数为要关联的字表模型类名称,
|
||||
*第二个参数指定 通过子表的 customer_id 去关联主表的 id 字段
|
||||
*/
|
||||
return $this->hasMany(AuthAssignment::className(), ['user_id' => 'id']);
|
||||
}
|
||||
public function getUsergroup()
|
||||
{
|
||||
/**
|
||||
* 第一个参数为要关联的字表模型类名称,
|
||||
*第二个参数指定 通过子表的 customer_id 去关联主表的 id 字段
|
||||
*/
|
||||
return $this->hasOne(AuthAssignment::className(), ['user_id' => 'id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates password hash from password and sets it to the model
|
||||
*
|
||||
* @param string $password
|
||||
*/
|
||||
public function setPassword($password)
|
||||
{
|
||||
$this->password_hash = Yii::$app->security->generatePasswordHash($password);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates "remember me" authentication key
|
||||
*/
|
||||
public function generateAuthKey()
|
||||
{
|
||||
$this->auth_key = Yii::$app->security->generateRandomString();
|
||||
}
|
||||
|
||||
}
|
||||
Executable
+58
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
namespace backend\models;
|
||||
|
||||
use Yii;
|
||||
|
||||
/**
|
||||
* This is the model class for table "auth_assignment".
|
||||
*
|
||||
* @property string $item_name
|
||||
* @property string $user_id
|
||||
* @property integer $created_at
|
||||
*
|
||||
* @property AuthItem $itemName
|
||||
*/
|
||||
class AuthAssignment extends \yii\db\ActiveRecord
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return '{{%auth_assignment}}';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['item_name', 'user_id'], 'required'],
|
||||
[['created_at'], 'integer'],
|
||||
[['item_name', 'user_id'], 'string', 'max' => 64],
|
||||
[['item_name'], 'exist', 'skipOnError' => true, 'targetClass' => AuthItem::className(), 'targetAttribute' => ['item_name' => 'name']],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'item_name' => 'Item Name',
|
||||
'user_id' => 'User ID',
|
||||
'created_at' => 'Created At',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
*/
|
||||
public function getItemName()
|
||||
{
|
||||
return $this->hasOne(AuthItem::className(), ['name' => 'item_name']);
|
||||
}
|
||||
}
|
||||
Executable
+217
@@ -0,0 +1,217 @@
|
||||
<?php
|
||||
|
||||
namespace backend\models;
|
||||
|
||||
use Yii;
|
||||
use common\models\base\BaseModel;
|
||||
use backend\models\Menu;
|
||||
|
||||
/**
|
||||
* This is the model class for table "auth_item".
|
||||
*
|
||||
* @property string $name
|
||||
* @property integer $type
|
||||
* @property string $description
|
||||
* @property string $rule_name
|
||||
* @property string $data
|
||||
* @property integer $created_at
|
||||
* @property integer $updated_at
|
||||
*
|
||||
* @property AuthAssignment[] $authAssignments
|
||||
* @property AuthRule $ruleName
|
||||
* @property AuthItemChild[] $authItemChildren
|
||||
* @property AuthItemChild[] $authItemChildren0
|
||||
* @property AuthItem[] $children
|
||||
* @property AuthItem[] $parents
|
||||
*/
|
||||
class AuthItem extends BaseModel
|
||||
{
|
||||
const T_ROLE = 1; //角色
|
||||
const T_POWER = 2; //权限
|
||||
|
||||
//定义场景
|
||||
const SCENARIOS_CREATE = 'create';
|
||||
const SCENARIOS_DELETE = 'delete';
|
||||
const SCENARIOS_UPDATE = 'update';
|
||||
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return '{{%auth_item}}';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['name', 'type'], 'required'],
|
||||
[['type', 'created_at', 'updated_at'], 'integer'],
|
||||
[['description', 'data'], 'string'],
|
||||
[['name', 'rule_name'], 'string', 'max' => 64],
|
||||
[['rule_name'], 'exist', 'skipOnError' => true, 'targetClass' => AuthRule::className(), 'targetAttribute' => ['rule_name' => 'name']],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'name' => '名称',
|
||||
'type' => '类型',
|
||||
'description' => '描述',
|
||||
'rule_name' => '规则名称',
|
||||
'data' => 'Data',
|
||||
'created_at' => '创建时间',
|
||||
'updated_at' => '更新时间',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
*/
|
||||
public function getAuthAssignments()
|
||||
{
|
||||
return $this->hasMany(AuthAssignment::className(), ['item_name' => 'name']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
*/
|
||||
public function getRuleName()
|
||||
{
|
||||
return $this->hasOne(AuthRule::className(), ['name' => 'rule_name']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
*/
|
||||
public function getAuthItemChildren()
|
||||
{
|
||||
return $this->hasMany(AuthItemChild::className(), ['parent' => 'name']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
*/
|
||||
public function getAuthItemChildren0()
|
||||
{
|
||||
return $this->hasMany(AuthItemChild::className(), ['child' => 'name']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
*/
|
||||
public function getChildren()
|
||||
{
|
||||
return $this->hasMany(AuthItem::className(), ['name' => 'child'])->viaTable('auth_item_child', ['parent' => 'name']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
*/
|
||||
public function getParents()
|
||||
{
|
||||
return $this->hasMany(AuthItem::className(), ['name' => 'parent'])->viaTable('auth_item_child', ['child' => 'name']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 场景设置
|
||||
* @see \yii\base\Model::scenarios()
|
||||
*/
|
||||
public function scenarios()
|
||||
{
|
||||
$scenarios = [
|
||||
self:: SCENARIOS_CREATE => ['name', 'type', 'description'],
|
||||
self:: SCENARIOS_DELETE => ['name'],
|
||||
self:: SCENARIOS_UPDATE => ['name', 'type', 'description'],
|
||||
];
|
||||
return array_merge(parent:: scenarios(), $scenarios);
|
||||
}
|
||||
/**
|
||||
* 角色&权限的创建方法
|
||||
* @return boolean 返回成功或者失败的状态值
|
||||
*/
|
||||
public function addItem()
|
||||
{
|
||||
//实例化AuthManager类
|
||||
$auth = Yii::$app->authManager;
|
||||
if($this->type == self::T_ROLE){
|
||||
$item = $auth->createRole($this->name);
|
||||
$item->description = $this->description?:'创建['.$this->name.']角色';
|
||||
}else{
|
||||
$item = $auth->createPermission($this->name);
|
||||
$item->description = $this->description?:'创建['.$this->name.']权限';
|
||||
}
|
||||
|
||||
return $auth->add($item);
|
||||
|
||||
}
|
||||
/**
|
||||
* 角色&权限的删除方法
|
||||
* @return boolean 返回成功或者失败的状态值
|
||||
*/
|
||||
public function romoveItem()
|
||||
{
|
||||
$this->name = trim($this->name);
|
||||
if($this->validate()){
|
||||
$auth = Yii::$app->authManager;
|
||||
$item = $auth->getRole($this->name)?:$auth->getPermission($this->name);
|
||||
return $auth->remove($item);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* 获取权限
|
||||
* @param unknown $id
|
||||
* @throws \Exception
|
||||
*/
|
||||
|
||||
public function getItem($id) {
|
||||
$model = AuthItem:: findOne(['name'=>$id]);
|
||||
if(!$model)
|
||||
throw new \Exception( '编辑的角色或权限不存在!' );
|
||||
|
||||
$this-> name = $model-> name;
|
||||
$this-> type = $model-> type;
|
||||
$this-> description = $model-> description;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑权限
|
||||
* @param unknown $item_name
|
||||
* @return boolean
|
||||
*/
|
||||
public function updateItem($item_name)
|
||||
{
|
||||
$auth = Yii:: $app-> authManager;
|
||||
if($this->type == self::T_ROLE){
|
||||
$item = $auth->createRole($this-> name);
|
||||
$item-> description = $this-> description?: '创建['.$this-> name. ']角色';
|
||||
}else{
|
||||
$item = $auth->createPermission($this-> name);
|
||||
$item-> description = $this-> description?: '创建['.$this-> name. ']权限';
|
||||
}
|
||||
return $auth->update($item_name, $item);
|
||||
}
|
||||
|
||||
//获取所有的权限
|
||||
public function getAllPermission(){
|
||||
$permission = self::find()->where(['type'=>2])->all();
|
||||
return $permission;
|
||||
}
|
||||
|
||||
//关联菜单数据
|
||||
public function getPermissionName(){
|
||||
return $this->hasOne(Menu::className(), ['route' => 'name']);
|
||||
}
|
||||
}
|
||||
Executable
+70
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace backend\models;
|
||||
|
||||
use Yii;
|
||||
|
||||
/**
|
||||
* This is the model class for table "auth_item_child".
|
||||
*
|
||||
* @property string $parent
|
||||
* @property string $child
|
||||
*
|
||||
* @property AuthItem $parent0
|
||||
* @property AuthItem $child0
|
||||
*/
|
||||
class AuthItemChild extends \yii\db\ActiveRecord
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return '{{%auth_item_child}}';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['parent', 'child'], 'required'],
|
||||
[['parent', 'child'], 'string', 'max' => 64],
|
||||
[['parent'], 'exist', 'skipOnError' => true, 'targetClass' => AuthItem::className(), 'targetAttribute' => ['parent' => 'name']],
|
||||
[['child'], 'exist', 'skipOnError' => true, 'targetClass' => AuthItem::className(), 'targetAttribute' => ['child' => 'name']],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'parent' => 'Parent',
|
||||
'child' => 'Child',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
*/
|
||||
public function getParent0()
|
||||
{
|
||||
return $this->hasOne(AuthItem::className(), ['name' => 'parent']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
*/
|
||||
public function getChild0()
|
||||
{
|
||||
return $this->hasOne(AuthItem::className(), ['name' => 'child']);
|
||||
}
|
||||
|
||||
public function getPermission($id){
|
||||
$permission = self::find()->where(['parent'=>$id])->asArray()->all();
|
||||
return $permission;
|
||||
}
|
||||
}
|
||||
Executable
+60
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace backend\models;
|
||||
|
||||
use Yii;
|
||||
|
||||
/**
|
||||
* This is the model class for table "auth_rule".
|
||||
*
|
||||
* @property string $name
|
||||
* @property string $data
|
||||
* @property integer $created_at
|
||||
* @property integer $updated_at
|
||||
*
|
||||
* @property AuthItem[] $authItems
|
||||
*/
|
||||
class AuthRule extends \yii\db\ActiveRecord
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return '{{%auth_rule}}';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['name'], 'required'],
|
||||
[['data'], 'string'],
|
||||
[['created_at', 'updated_at'], 'integer'],
|
||||
[['name'], 'string', 'max' => 64],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'name' => 'Name',
|
||||
'data' => 'Data',
|
||||
'created_at' => 'Created At',
|
||||
'updated_at' => 'Updated At',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
*/
|
||||
public function getAuthItems()
|
||||
{
|
||||
return $this->hasMany(AuthItem::className(), ['rule_name' => 'name']);
|
||||
}
|
||||
}
|
||||
Executable
+79
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @Author: fm453
|
||||
* @Date: 2018-11-22 02:10:33
|
||||
* @Last Modified by: fm453
|
||||
* @Last Modified time: 2018-11-22 10:23:52
|
||||
* @Email: fm453@lukegzs.com
|
||||
*/
|
||||
|
||||
namespace backend\models;
|
||||
|
||||
use Yii;
|
||||
|
||||
/**
|
||||
* This is the model class for table "c_attachment".
|
||||
*
|
||||
* @property int $id
|
||||
* @property int $pid 平台ID
|
||||
* @property int $mid 关联会员ID
|
||||
* @property int $uid 关联管理员ID
|
||||
* @property int $type 附件类型
|
||||
* @property string $title 附件标题
|
||||
* @property string $route 附件路径
|
||||
* @property int $filesize 附件大小(byte)
|
||||
* @property string $options 额外参数
|
||||
* @property int $status_code 状态代码
|
||||
* @property int $deleted 是否删除
|
||||
* @property int $update_at 数据更新时间
|
||||
* @property int $create_at 数据创建时间
|
||||
*/
|
||||
class CAttachment extends \yii\db\ActiveRecord
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return 'c_attachment';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['siteid','pid', 'mid', 'uid', 'type', 'filesize', 'update_at', 'create_at'], 'required'],
|
||||
[['siteid','pid', 'mid', 'uid', 'type', 'filesize', 'status_code', 'update_at', 'create_at'], 'integer'],
|
||||
[['options'], 'string'],
|
||||
[['title', 'route'], 'string', 'max' => 255],
|
||||
[['deleted'], 'string', 'max' => 1],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'id' => Yii::t('app', 'ID'),
|
||||
'siteid' => Yii::t('app', '站点ID'),
|
||||
'pid' => Yii::t('app', '平台ID'),
|
||||
'mid' => Yii::t('app', '关联会员ID'),
|
||||
'uid' => Yii::t('app', '关联管理员ID'),
|
||||
'type' => Yii::t('app', '附件类型'),
|
||||
'title' => Yii::t('app', '附件标题'),
|
||||
'route' => Yii::t('app', '附件路径'),
|
||||
'filesize' => Yii::t('app', '附件大小(byte)'),
|
||||
'options' => Yii::t('app', '额外参数'),
|
||||
'status_code' => Yii::t('app', '状态代码'),
|
||||
'deleted' => Yii::t('app', '是否删除'),
|
||||
'update_at' => Yii::t('app', '数据更新时间'),
|
||||
'create_at' => Yii::t('app', '数据创建时间'),
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
Executable
+76
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
namespace backend\models;
|
||||
/**
|
||||
* @author Xianan Huang
|
||||
*
|
||||
*/
|
||||
use Yii;
|
||||
use yii\base\Model;
|
||||
use backend\models\AuthRule;
|
||||
class ItemForm extends Model
|
||||
{
|
||||
public $name;
|
||||
|
||||
public $type;
|
||||
|
||||
public $description;
|
||||
|
||||
const T_ROLE = 1; //角色
|
||||
const T_POWER = 2; //权限
|
||||
|
||||
//定义场景
|
||||
const SCENARIOS_CREATE = 'create';
|
||||
const SCENARIOS_DELETE = 'delete';
|
||||
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['name', 'type'], 'required'],
|
||||
['name', 'unique', 'targetClass' => '\common\models\AuthItemModel', 'message' => '此名称已经被占用。'],
|
||||
['type', 'integer'],
|
||||
[['name', 'description'], 'string', 'max' => 25],
|
||||
[['rule_name'], 'exist', 'skipOnError' => true, 'targetClass' => AuthRule::className(), 'targetAttribute' => ['rule_name' => 'name']]
|
||||
];
|
||||
}
|
||||
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'name' => '名称',
|
||||
'type' => '类型',
|
||||
'description' => '描述',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 场景设置
|
||||
* @see \yii\base\Model::scenarios()
|
||||
*/
|
||||
public function scenarios()
|
||||
{
|
||||
$scenarios = [
|
||||
self:: SCENARIOS_CREATE => ['name', 'type', 'description'],
|
||||
self:: SCENARIOS_DELETE => ['name'],
|
||||
];
|
||||
return array_merge(parent:: scenarios(), $scenarios);
|
||||
}
|
||||
/**
|
||||
* 角色&权限的创建方法
|
||||
* @return boolean 返回成功或者失败的状态值
|
||||
*/
|
||||
public function addItem()
|
||||
{
|
||||
//实例化AuthManager类
|
||||
$auth = Yii::$app->authManager;
|
||||
if($this->type == self::T_ROLE){
|
||||
$item = $auth->createRole($this->name);
|
||||
$item->description = $this->description?:'创建['.$this->name.']角色';
|
||||
}else{
|
||||
$item = $auth->createPermission($this->name);
|
||||
$item->description = $this->description?:'创建['.$this->name.']权限';
|
||||
}
|
||||
|
||||
return $auth->add($item);
|
||||
|
||||
}
|
||||
}
|
||||
Executable
+48
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace backend\models;
|
||||
|
||||
use Yii;
|
||||
|
||||
/**
|
||||
* This is the model class for table "log".
|
||||
*
|
||||
* @property string $username
|
||||
* @property string $ip
|
||||
* @property string $data
|
||||
* @property string $create_time
|
||||
*/
|
||||
class Log extends \yii\db\ActiveRecord
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return '{{%c_log}}';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['username', 'create_time'], 'string', 'max' => 32],
|
||||
[['ip', 'data'], 'string', 'max' => 64],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'username' => 'Username',
|
||||
'ip' => 'Ip',
|
||||
'data' => 'Data',
|
||||
'create_time' => 'Create Time',
|
||||
];
|
||||
}
|
||||
}
|
||||
Executable
+48
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace backend\models;
|
||||
|
||||
use Yii;
|
||||
|
||||
/**
|
||||
* This is the model class for table "logs".
|
||||
*
|
||||
* @property string $username
|
||||
* @property string $ip
|
||||
* @property string $data
|
||||
* @property string $create_time
|
||||
*/
|
||||
class Logs extends \yii\db\ActiveRecord
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return '{{%c_logs}}';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['username', 'create_time'], 'string', 'max' => 32],
|
||||
[['ip', 'data'], 'string', 'max' => 64],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'username' => 'Username',
|
||||
'ip' => 'Ip',
|
||||
'data' => 'Data',
|
||||
'create_time' => 'Create Time',
|
||||
];
|
||||
}
|
||||
}
|
||||
Executable
+104
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
|
||||
namespace backend\models;
|
||||
|
||||
use Yii;
|
||||
use backend\models\AuthAssignment;
|
||||
/**
|
||||
* This is the model class for table "c_user".
|
||||
*
|
||||
* @property integer $id
|
||||
* @property string $username
|
||||
* @property string $auth_key
|
||||
* @property string $password_hash
|
||||
* @property string $password_reset_token
|
||||
* @property string $email
|
||||
* @property integer $role
|
||||
* @property integer $status
|
||||
* @property integer $created_at
|
||||
* @property integer $updated_at
|
||||
*/
|
||||
class User extends \yii\db\ActiveRecord
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return '{{%c_user}}';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['username','email'], 'required'],
|
||||
//[['role', 'status', 'created_at', 'updated_at'], 'integer'],
|
||||
[['username', 'password_hash', 'password_reset_token', 'email'], 'string', 'max' => 255],
|
||||
[['auth_key'], 'string', 'max' => 32],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'id' => 'ID',
|
||||
'username' => Yii::t('common' ,'Username'),
|
||||
'auth_key' => Yii::t('common' ,'Password'),
|
||||
'password_hash' => 'Password Hash',
|
||||
'password_reset_token' => 'Password Reset Token',
|
||||
'email' => Yii::t('common' ,'Email'),
|
||||
'mobile' => Yii::t('common' ,'Mobile'),
|
||||
'role' => Yii::t('common' ,'Role'),
|
||||
'status' => 'Status',
|
||||
'created_at' => 'Created At',
|
||||
'updated_at' => 'Updated At',
|
||||
];
|
||||
}
|
||||
//获取所有用户
|
||||
public function get_all_user(){
|
||||
$user = Yii::$app->db->createCommand('select * from '. tableName())->queryAll();
|
||||
return $user;
|
||||
}
|
||||
|
||||
public function getUsergrouplist()
|
||||
{
|
||||
/**
|
||||
* 第一个参数为要关联的字表模型类名称,
|
||||
*第二个参数指定 通过子表的 customer_id 去关联主表的 id 字段
|
||||
*/
|
||||
return $this->hasMany(AuthAssignment::className(), ['user_id' => 'id']);
|
||||
}
|
||||
public function getUsergroup()
|
||||
{
|
||||
/**
|
||||
* 第一个参数为要关联的字表模型类名称,
|
||||
*第二个参数指定 通过子表的 customer_id 去关联主表的 id 字段
|
||||
*/
|
||||
return $this->hasOne(AuthAssignment::className(), ['user_id' => 'id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates password hash from password and sets it to the model
|
||||
*
|
||||
* @param string $password
|
||||
*/
|
||||
public function setPassword($password)
|
||||
{
|
||||
$this->password_hash = Yii::$app->security->generatePasswordHash($password);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates "remember me" authentication key
|
||||
*/
|
||||
public function generateAuthKey()
|
||||
{
|
||||
$this->auth_key = Yii::$app->security->generateRandomString();
|
||||
}
|
||||
|
||||
}
|
||||
Executable
+154
@@ -0,0 +1,154 @@
|
||||
<?php
|
||||
|
||||
namespace backend\models;
|
||||
|
||||
use Yii;
|
||||
|
||||
/**
|
||||
* This is the model class for table "c_menu".
|
||||
*
|
||||
* @property integer $id
|
||||
* @property string $name
|
||||
* @property integer $parent
|
||||
* @property string $route
|
||||
* @property integer $order
|
||||
* @property string $data
|
||||
*/
|
||||
class Menu extends \yii\db\ActiveRecord
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return '{{%c_menu}}';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['name'], 'required'],
|
||||
[['parent', 'sort'], 'integer'],
|
||||
[['data'], 'string'],
|
||||
[['status'], 'string'],
|
||||
[['name'], 'string', 'max' => 128],
|
||||
[['route'], 'string', 'max' => 256],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'id' => 'ID',
|
||||
'name' => '名称',
|
||||
'parent' => '父级',
|
||||
'route' => '路由',
|
||||
'sort' => '排序',
|
||||
'data' => '描述',
|
||||
];
|
||||
}
|
||||
|
||||
//获取顶级菜单列表
|
||||
public function getAllMenu(){
|
||||
$menu = Yii::$app->db->createCommand("SELECT * FROM ".$this->tableName()." WHERE parent='0' ")->queryAll();
|
||||
return $menu;
|
||||
}
|
||||
//获取所有菜单列表
|
||||
public function getMenuList(){
|
||||
$menu = Yii::$app->db->createCommand("SELECT * FROM ".$this->tableName()." ORDER BY sort ASC ")->queryAll();
|
||||
$menu = self::list_to_tree($menu,'id','parent');
|
||||
return $menu;
|
||||
}
|
||||
//获取左侧菜单列表
|
||||
public function getLeftMenuList(){
|
||||
$uid = Yii::$app->user->identity->getId();
|
||||
$auth = Yii::$app->authManager;
|
||||
$Permission = $auth->getPermissionsByUser($uid);
|
||||
$RoutesList = '';
|
||||
foreach($Permission as $vo){
|
||||
$RoutesList .= "'".$vo->name."',";
|
||||
}
|
||||
$RoutesList = substr($RoutesList,0,-1);
|
||||
if($RoutesList == ''){
|
||||
$RoutesList = "'/index/welcome','/site/index'";
|
||||
}
|
||||
$menu = Yii::$app->db->createCommand("SELECT * FROM ".$this->tableName()." WHERE route IN ($RoutesList) ORDER BY `order` ASC")->queryAll();
|
||||
$menu = Yii::$app->db->createCommand("SELECT * FROM ".$this->tableName()." ORDER BY `order` ASC")->queryAll();
|
||||
$menu = self::list_to_tree2($menu,'id','parent');
|
||||
return $menu;
|
||||
}
|
||||
|
||||
//通过id找到router
|
||||
public function getRouteById($id){
|
||||
$router = Yii::$app->db->createCommand("SELECT * FROM `".$this->tableName()."` WHERE id='$id'")->queryOne();
|
||||
return $router['route'];
|
||||
}
|
||||
|
||||
/**
|
||||
* 把返回的数据集转换成Tree
|
||||
* @param array $list 要转换的数据集
|
||||
* @param string $pid parent标记字段
|
||||
* @param string $level level标记字段
|
||||
* @return array
|
||||
* @author 麦当苗儿 <zuojiazi@vip.qq.com>
|
||||
*/
|
||||
function list_to_tree($list, $pk='id', $pid = 'pid', $child = '_child', $root = 0) {
|
||||
// 创建Tree
|
||||
$tree = array();
|
||||
if(is_array($list)) {
|
||||
// 创建基于主键的数组引用
|
||||
$refer = array();
|
||||
foreach ($list as $key => $data) {
|
||||
$refer[$data[$pk]] =& $list[$key];
|
||||
}
|
||||
foreach ($list as $key => $data) {
|
||||
// 判断是否存在parent
|
||||
$parentId = $data[$pid];
|
||||
if ($root == $parentId) {
|
||||
$tree[] =& $list[$key];
|
||||
}else{
|
||||
if (isset($refer[$parentId])) {
|
||||
$parent =& $refer[$parentId];
|
||||
$list[$key]['name'] =' |--'.$list[$key]['name'];
|
||||
$parent[$child][] =& $list[$key];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $tree;
|
||||
}
|
||||
|
||||
function list_to_tree2($list, $pk='id', $pid = 'pid', $child = '_child', $root = 0) {
|
||||
// 创建Tree
|
||||
$tree = array();
|
||||
if(is_array($list)) {
|
||||
// 创建基于主键的数组引用
|
||||
$refer = array();
|
||||
foreach ($list as $key => $data) {
|
||||
$refer[$data[$pk]] =& $list[$key];
|
||||
}
|
||||
foreach ($list as $key => $data) {
|
||||
// 判断是否存在parent
|
||||
$parentId = $data[$pid];
|
||||
if ($root == $parentId) {
|
||||
$tree[] =& $list[$key];
|
||||
}else{
|
||||
if (isset($refer[$parentId])) {
|
||||
$parent =& $refer[$parentId];
|
||||
$list[$key]['name'] =$list[$key]['name'];
|
||||
$parent[$child][] =& $list[$key];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $tree;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Executable
+104
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
|
||||
namespace backend\models;
|
||||
|
||||
use Yii;
|
||||
use backend\models\AuthAssignment;
|
||||
/**
|
||||
* This is the model class for table "c_user".
|
||||
*
|
||||
* @property integer $id
|
||||
* @property string $username
|
||||
* @property string $auth_key
|
||||
* @property string $password_hash
|
||||
* @property string $password_reset_token
|
||||
* @property string $email
|
||||
* @property integer $role
|
||||
* @property integer $status
|
||||
* @property integer $created_at
|
||||
* @property integer $updated_at
|
||||
*/
|
||||
class User extends \yii\db\ActiveRecord
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return '{{%c_user}}';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['username','email'], 'required'],
|
||||
//[['role', 'status', 'created_at', 'updated_at'], 'integer'],
|
||||
[['username', 'password_hash', 'password_reset_token', 'email'], 'string', 'max' => 255],
|
||||
[['auth_key'], 'string', 'max' => 32],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'id' => 'ID',
|
||||
'username' => Yii::t('common' ,'Username'),
|
||||
'auth_key' => Yii::t('common' ,'Password'),
|
||||
'password_hash' => 'Password Hash',
|
||||
'password_reset_token' => 'Password Reset Token',
|
||||
'email' => Yii::t('common' ,'Email'),
|
||||
'mobile' => Yii::t('common' ,'Mobile'),
|
||||
'role' => Yii::t('common' ,'Role'),
|
||||
'status' => 'Status',
|
||||
'created_at' => 'Created At',
|
||||
'updated_at' => 'Updated At',
|
||||
];
|
||||
}
|
||||
//获取所有用户
|
||||
public function get_all_user(){
|
||||
$user = Yii::$app->db->createCommand('select * from '. tableName())->queryAll();
|
||||
return $user;
|
||||
}
|
||||
|
||||
public function getUsergrouplist()
|
||||
{
|
||||
/**
|
||||
* 第一个参数为要关联的字表模型类名称,
|
||||
*第二个参数指定 通过子表的 customer_id 去关联主表的 id 字段
|
||||
*/
|
||||
return $this->hasMany(AuthAssignment::className(), ['user_id' => 'id']);
|
||||
}
|
||||
public function getUsergroup()
|
||||
{
|
||||
/**
|
||||
* 第一个参数为要关联的字表模型类名称,
|
||||
*第二个参数指定 通过子表的 customer_id 去关联主表的 id 字段
|
||||
*/
|
||||
return $this->hasOne(AuthAssignment::className(), ['user_id' => 'id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates password hash from password and sets it to the model
|
||||
*
|
||||
* @param string $password
|
||||
*/
|
||||
public function setPassword($password)
|
||||
{
|
||||
$this->password_hash = Yii::$app->security->generatePasswordHash($password);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates "remember me" authentication key
|
||||
*/
|
||||
public function generateAuthKey()
|
||||
{
|
||||
$this->auth_key = Yii::$app->security->generateRandomString();
|
||||
}
|
||||
|
||||
}
|
||||
Executable
+1
@@ -0,0 +1 @@
|
||||
*
|
||||
Executable
+220
@@ -0,0 +1,220 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @Author: fm453
|
||||
* @Date: 2021-09-10 17:33:23
|
||||
* @Last Modified by: fm453
|
||||
* @Last Modified time: 2021-09-10 17:34:36
|
||||
* @Email: fm453@lukegzs.com
|
||||
*/
|
||||
|
||||
namespace backend\models;
|
||||
|
||||
use Yii;
|
||||
use yii\db\ActiveRecord;
|
||||
use yii\behaviors\TimestampBehavior;
|
||||
use yii\base\NotSupportedException;
|
||||
use backend\models\AuthAssignment;
|
||||
use yii\web\IdentityInterface;
|
||||
|
||||
class Adminer extends ActiveRecord implements IdentityInterface
|
||||
{
|
||||
|
||||
public $password;
|
||||
|
||||
const STATUS_DELETE = 0;
|
||||
const STATUS_ACTIVE = 10;
|
||||
|
||||
public static $statusTexts = [
|
||||
self::STATUS_DELETE => '禁用',
|
||||
self::STATUS_ACTIVE => '启用',
|
||||
];
|
||||
|
||||
public static $statusStyles = [
|
||||
self::STATUS_DELETE => 'label-warning',
|
||||
self::STATUS_ACTIVE => 'label-info',
|
||||
];
|
||||
|
||||
public static function tableName() {
|
||||
return '{{%c_adminer}}';
|
||||
}
|
||||
|
||||
public function behaviors() {
|
||||
return [
|
||||
TimestampBehavior::className(),
|
||||
];
|
||||
}
|
||||
|
||||
public function rules() {
|
||||
return [
|
||||
[['username', 'email'], 'required'],
|
||||
[['username'], 'string', 'length' => [5, 32]],
|
||||
[['nickname'],'string','max'=>32],
|
||||
[['password'], 'required', 'on' => ['create']],
|
||||
[['auth_key'], 'string', 'length' => 32],
|
||||
[['username', 'email','mobile'], 'unique'],
|
||||
[['email'], 'email'],
|
||||
['status', 'default', 'value' => self::STATUS_ACTIVE],
|
||||
['status', 'in', 'range' => [
|
||||
self::STATUS_DELETE,self::STATUS_ACTIVE,1
|
||||
]], //状态值1是软删除
|
||||
[['status', 'created_at', 'updated_at'], 'integer'],
|
||||
[['username', 'password_hash', 'password_reset_token', 'email'], 'string', 'max' => 255],
|
||||
//去除首尾空白
|
||||
[['username', 'nickname', 'mobile', 'email'], 'filter', 'filter' => 'trim'],
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
public function attributeLabels() {
|
||||
return [
|
||||
'id' => 'ID',
|
||||
'username' => Yii::t('common' ,'Username'),
|
||||
'nickname' => '姓名',
|
||||
'auth_key' => Yii::t('common' ,'Password'),
|
||||
'password_hash' => 'Password Hash',
|
||||
'email' => Yii::t('common' ,'Email'),
|
||||
'mobile' => Yii::t('common' ,'Mobile'),
|
||||
'status' => '状态',
|
||||
'created_at' => 'Created At',
|
||||
'updated_at' => 'Updated At',
|
||||
'user_role' => '所属角色',
|
||||
'role' => Yii::t('common' ,'Role'),
|
||||
];
|
||||
}
|
||||
|
||||
public function scenarios() {
|
||||
$scenarios = parent::scenarios();
|
||||
$scenarios['create'] = ['username', 'email', 'password', 'status'];
|
||||
$scenarios['update'] = ['username', 'email', 'password', 'status'];
|
||||
return $scenarios;
|
||||
}
|
||||
|
||||
/*用户组 S*/
|
||||
public function getUsergrouplist()
|
||||
{
|
||||
/**
|
||||
* 第一个参数为要关联的字表模型类名称,
|
||||
*第二个参数指定 通过子表的 customer_id 去关联主表的 id 字段
|
||||
*/
|
||||
return $this->hasMany(AuthAssignment::className(), ['user_id' => 'id']);
|
||||
}
|
||||
public function getUsergroup()
|
||||
{
|
||||
/**
|
||||
* 第一个参数为要关联的字表模型类名称,
|
||||
*第二个参数指定 通过子表的 customer_id 去关联主表的 id 字段
|
||||
*/
|
||||
return $this->hasOne(AuthAssignment::className(), ['user_id' => 'id']);
|
||||
}
|
||||
/*用户组 E*/
|
||||
|
||||
/**
|
||||
* Generates "remember me" authentication key
|
||||
*/
|
||||
public function generateAuthKey()
|
||||
{
|
||||
$this->auth_key = Yii::$app->security->generateRandomString();
|
||||
}
|
||||
|
||||
public function beforeSave($insert) {
|
||||
if($this->isNewRecord) {
|
||||
$this->generateAuthKey();
|
||||
}
|
||||
if(!empty($this->password)) $this->setPassword($this->password);
|
||||
return parent::beforeSave($insert);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成加密后的密码
|
||||
* @param [string] $password [用户密码]
|
||||
*/
|
||||
public function setPassword($password) {
|
||||
$this->password_hash = Yii::$app->security->generatePasswordHash($password);
|
||||
}
|
||||
|
||||
/*获取所有用户*/
|
||||
public function get_all_user(){
|
||||
// $user = Yii::$app->db->createCommand('select * from '. tableName())->queryAll();
|
||||
$user = static::findAll();
|
||||
return $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取账号信息
|
||||
* @param [int] $id [后台用户id]
|
||||
*/
|
||||
public static function findIdentity($id) {
|
||||
return static::findOne(['id' => $id, 'status' => self::STATUS_ACTIVE]);
|
||||
}
|
||||
|
||||
public static function findIdentityByAccessToken($token, $type = null) {
|
||||
throw new NotSupportedException('"findIdentityByAccessToken" is not implemented.');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取账号信息
|
||||
* @param [string] $username [用户名]
|
||||
*/
|
||||
public static function findByUsername($username) {
|
||||
return static::findOne(['username' => $username, 'status' => self::STATUS_ACTIVE]);
|
||||
}
|
||||
|
||||
//获取用户所在的用户组
|
||||
public function getGroup() {
|
||||
return implode(',', array_keys(Yii::$app->authManager->getRolesByUser($this->id)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取账号主键值(id)
|
||||
*/
|
||||
public function getId() {
|
||||
return $this->getPrimaryKey();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取账号auth_key值
|
||||
*/
|
||||
public function getAuthKey() {
|
||||
return $this->auth_key;
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证auth_key
|
||||
* @param [string] $authKey [auth key]
|
||||
*/
|
||||
public function validateAuthKey($authKey) {
|
||||
return $this->getAuthKey() === $authKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证用户密码
|
||||
* @param [string] $password [用户密码]
|
||||
*/
|
||||
public function validatePassword($password) {
|
||||
return Yii::$app->security->validatePassword($password, $this->password_hash);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取账号状态
|
||||
*/
|
||||
public function getStatus() {
|
||||
return self::$statusTexts[$this->status];
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取账号状态样式
|
||||
*/
|
||||
public function getStatusStyle() {
|
||||
return self::$statusStyles[$this->status];
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取状态
|
||||
*/
|
||||
public function getStatusTexts() {
|
||||
return self::$statusTexts;
|
||||
}
|
||||
|
||||
}
|
||||
Executable
+65
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @Author: fm453
|
||||
* @Date: 2021-09-10 17:34:17
|
||||
* @Last Modified by: fm453
|
||||
* @Last Modified time: 2021-09-10 17:34:25
|
||||
* @Email: fm453@lukegzs.com
|
||||
*/
|
||||
namespace backend\models;
|
||||
|
||||
use Yii;
|
||||
|
||||
/**
|
||||
* This is the model class for table "auth_assignment".
|
||||
*
|
||||
* @property string $item_name
|
||||
* @property string $user_id
|
||||
* @property integer $created_at
|
||||
*
|
||||
* @property AuthItem $itemName
|
||||
*/
|
||||
class AuthAssignment extends \yii\db\ActiveRecord
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return '{{%auth_assignment}}';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['item_name', 'user_id'], 'required'],
|
||||
[['created_at'], 'integer'],
|
||||
[['item_name', 'user_id'], 'string', 'max' => 64],
|
||||
[['item_name'], 'exist', 'skipOnError' => true, 'targetClass' => AuthItem::className(), 'targetAttribute' => ['item_name' => 'name']],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'item_name' => 'Item Name',
|
||||
'user_id' => 'User ID',
|
||||
'created_at' => 'Created At',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
*/
|
||||
public function getItemName()
|
||||
{
|
||||
return $this->hasOne(AuthItem::className(), ['name' => 'item_name']);
|
||||
}
|
||||
}
|
||||
Executable
+224
@@ -0,0 +1,224 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @Author: fm453
|
||||
* @Date: 2021-09-10 17:35:20
|
||||
* @Last Modified by: fm453
|
||||
* @Last Modified time: 2021-09-10 17:35:48
|
||||
* @Email: fm453@lukegzs.com
|
||||
*/
|
||||
namespace backend\models;
|
||||
|
||||
use Yii;
|
||||
use common\models\base\BaseModel;
|
||||
use backend\models\Menu;
|
||||
|
||||
/**
|
||||
* This is the model class for table "auth_item".
|
||||
*
|
||||
* @property string $name
|
||||
* @property integer $type
|
||||
* @property string $description
|
||||
* @property string $rule_name
|
||||
* @property string $data
|
||||
* @property integer $created_at
|
||||
* @property integer $updated_at
|
||||
*
|
||||
* @property AuthAssignment[] $authAssignments
|
||||
* @property AuthRule $ruleName
|
||||
* @property AuthItemChild[] $authItemChildren
|
||||
* @property AuthItemChild[] $authItemChildren0
|
||||
* @property AuthItem[] $children
|
||||
* @property AuthItem[] $parents
|
||||
*/
|
||||
class AuthItem extends BaseModel
|
||||
{
|
||||
const T_ROLE = 1; //角色
|
||||
const T_POWER = 2; //权限
|
||||
|
||||
//定义场景
|
||||
const SCENARIOS_CREATE = 'create';
|
||||
const SCENARIOS_DELETE = 'delete';
|
||||
const SCENARIOS_UPDATE = 'update';
|
||||
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return '{{%auth_item}}';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['name', 'type'], 'required'],
|
||||
[['type', 'created_at', 'updated_at'], 'integer'],
|
||||
[['description', 'data'], 'string'],
|
||||
[['name', 'rule_name'], 'string', 'max' => 64],
|
||||
[['rule_name'], 'exist', 'skipOnError' => true, 'targetClass' => AuthRule::className(), 'targetAttribute' => ['rule_name' => 'name']],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'name' => '名称',
|
||||
'type' => '类型',
|
||||
'description' => '描述',
|
||||
'rule_name' => '规则名称',
|
||||
'data' => 'Data',
|
||||
'created_at' => '创建时间',
|
||||
'updated_at' => '更新时间',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
*/
|
||||
public function getAuthAssignments()
|
||||
{
|
||||
return $this->hasMany(AuthAssignment::className(), ['item_name' => 'name']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
*/
|
||||
public function getRuleName()
|
||||
{
|
||||
return $this->hasOne(AuthRule::className(), ['name' => 'rule_name']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
*/
|
||||
public function getAuthItemChildren()
|
||||
{
|
||||
return $this->hasMany(AuthItemChild::className(), ['parent' => 'name']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
*/
|
||||
public function getAuthItemChildren0()
|
||||
{
|
||||
return $this->hasMany(AuthItemChild::className(), ['child' => 'name']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
*/
|
||||
public function getChildren()
|
||||
{
|
||||
return $this->hasMany(AuthItem::className(), ['name' => 'child'])->viaTable('auth_item_child', ['parent' => 'name']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
*/
|
||||
public function getParents()
|
||||
{
|
||||
return $this->hasMany(AuthItem::className(), ['name' => 'parent'])->viaTable('auth_item_child', ['child' => 'name']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 场景设置
|
||||
* @see \yii\base\Model::scenarios()
|
||||
*/
|
||||
public function scenarios()
|
||||
{
|
||||
$scenarios = [
|
||||
self:: SCENARIOS_CREATE => ['name', 'type', 'description'],
|
||||
self:: SCENARIOS_DELETE => ['name'],
|
||||
self:: SCENARIOS_UPDATE => ['name', 'type', 'description'],
|
||||
];
|
||||
return array_merge(parent:: scenarios(), $scenarios);
|
||||
}
|
||||
/**
|
||||
* 角色&权限的创建方法
|
||||
* @return boolean 返回成功或者失败的状态值
|
||||
*/
|
||||
public function addItem()
|
||||
{
|
||||
//实例化AuthManager类
|
||||
$auth = Yii::$app->authManager;
|
||||
if($this->type == self::T_ROLE){
|
||||
$item = $auth->createRole($this->name);
|
||||
$item->description = $this->description?:'创建['.$this->name.']角色';
|
||||
}else{
|
||||
$item = $auth->createPermission($this->name);
|
||||
$item->description = $this->description?:'创建['.$this->name.']权限';
|
||||
}
|
||||
|
||||
return $auth->add($item);
|
||||
|
||||
}
|
||||
/**
|
||||
* 角色&权限的删除方法
|
||||
* @return boolean 返回成功或者失败的状态值
|
||||
*/
|
||||
public function romoveItem()
|
||||
{
|
||||
$this->name = trim($this->name);
|
||||
if($this->validate()){
|
||||
$auth = Yii::$app->authManager;
|
||||
$item = $auth->getRole($this->name)?:$auth->getPermission($this->name);
|
||||
return $auth->remove($item);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* 获取权限
|
||||
* @param unknown $id
|
||||
* @throws \Exception
|
||||
*/
|
||||
|
||||
public function getItem($id) {
|
||||
$model = AuthItem:: findOne(['name'=>$id]);
|
||||
if(!$model)
|
||||
throw new \Exception( '编辑的角色或权限不存在!' );
|
||||
|
||||
$this-> name = $model-> name;
|
||||
$this-> type = $model-> type;
|
||||
$this-> description = $model-> description;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑权限
|
||||
* @param unknown $item_name
|
||||
* @return boolean
|
||||
*/
|
||||
public function updateItem($item_name)
|
||||
{
|
||||
$auth = Yii:: $app-> authManager;
|
||||
if($this->type == self::T_ROLE){
|
||||
$item = $auth->createRole($this-> name);
|
||||
$item-> description = $this-> description?: '创建['.$this-> name. ']角色';
|
||||
}else{
|
||||
$item = $auth->createPermission($this-> name);
|
||||
$item-> description = $this-> description?: '创建['.$this-> name. ']权限';
|
||||
}
|
||||
return $auth->update($item_name, $item);
|
||||
}
|
||||
|
||||
//获取所有的权限
|
||||
public function getAllPermission(){
|
||||
$permission = self::find()->where(['type'=>2])->all();
|
||||
return $permission;
|
||||
}
|
||||
|
||||
//关联菜单数据
|
||||
public function getPermissionName(){
|
||||
return $this->hasOne(Menu::className(), ['route' => 'name']);
|
||||
}
|
||||
}
|
||||
Executable
+77
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @Author: fm453
|
||||
* @Date: 2021-04-26 08:32:06
|
||||
* @Last Modified by: fm453
|
||||
* @Last Modified time: 2021-09-10 17:36:26
|
||||
* @Email: fm453@lukegzs.com
|
||||
*/
|
||||
namespace backend\models;
|
||||
|
||||
use Yii;
|
||||
|
||||
/**
|
||||
* This is the model class for table "auth_item_child".
|
||||
*
|
||||
* @property string $parent
|
||||
* @property string $child
|
||||
*
|
||||
* @property AuthItem $parent0
|
||||
* @property AuthItem $child0
|
||||
*/
|
||||
class AuthItemChild extends \yii\db\ActiveRecord
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return '{{%auth_item_child}}';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['parent', 'child'], 'required'],
|
||||
[['parent', 'child'], 'string', 'max' => 64],
|
||||
[['parent'], 'exist', 'skipOnError' => true, 'targetClass' => AuthItem::className(), 'targetAttribute' => ['parent' => 'name']],
|
||||
[['child'], 'exist', 'skipOnError' => true, 'targetClass' => AuthItem::className(), 'targetAttribute' => ['child' => 'name']],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'parent' => 'Parent',
|
||||
'child' => 'Child',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
*/
|
||||
public function getParent0()
|
||||
{
|
||||
return $this->hasOne(AuthItem::className(), ['name' => 'parent']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
*/
|
||||
public function getChild0()
|
||||
{
|
||||
return $this->hasOne(AuthItem::className(), ['name' => 'child']);
|
||||
}
|
||||
|
||||
public function getPermission($id){
|
||||
$permission = self::find()->where(['parent'=>$id])->asArray()->all();
|
||||
return $permission;
|
||||
}
|
||||
}
|
||||
Executable
+67
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @Author: fm453
|
||||
* @Date: 2021-09-10 17:36:45
|
||||
* @Last Modified by: fm453
|
||||
* @Last Modified time: 2021-09-10 17:40:19
|
||||
* @Email: fm453@lukegzs.com
|
||||
*/
|
||||
namespace backend\models;
|
||||
|
||||
use Yii;
|
||||
|
||||
/**
|
||||
* This is the model class for table "auth_rule".
|
||||
*
|
||||
* @property string $name
|
||||
* @property string $data
|
||||
* @property integer $created_at
|
||||
* @property integer $updated_at
|
||||
*
|
||||
* @property AuthItem[] $authItems
|
||||
*/
|
||||
class AuthRule extends \yii\db\ActiveRecord
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return '{{%auth_rule}}';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['name'], 'required'],
|
||||
[['data'], 'string'],
|
||||
[['created_at', 'updated_at'], 'integer'],
|
||||
[['name'], 'string', 'max' => 64],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'name' => 'Name',
|
||||
'data' => 'Data',
|
||||
'created_at' => 'Created At',
|
||||
'updated_at' => 'Updated At',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \yii\db\ActiveQuery
|
||||
*/
|
||||
public function getAuthItems()
|
||||
{
|
||||
return $this->hasMany(AuthItem::className(), ['rule_name' => 'name']);
|
||||
}
|
||||
}
|
||||
Executable
+29
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @Author: fm453
|
||||
* @Date: 2018-11-22 02:22:45
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2021-09-15T15:27:09+08:00
|
||||
* @Email: fm453@lukegzs.com
|
||||
*/
|
||||
|
||||
namespace backend\models;
|
||||
|
||||
use Yii;
|
||||
|
||||
class FmContract extends \yii\db\ActiveRecord
|
||||
{
|
||||
//指定数据库
|
||||
public static function getDb()
|
||||
{
|
||||
return Yii::$app->get('lvju');
|
||||
}
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return '{{%contract}}';
|
||||
}
|
||||
}
|
||||
Executable
+31
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @Author: fm453
|
||||
* @Date: 2018-11-22 02:22:45
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2021-09-15T15:27:18+08:00
|
||||
* @Email: fm453@lukegzs.com
|
||||
*/
|
||||
|
||||
namespace backend\models;
|
||||
|
||||
use Yii;
|
||||
|
||||
class FmCustomer extends \yii\db\ActiveRecord
|
||||
{
|
||||
//指定数据库
|
||||
public static function getDb()
|
||||
{
|
||||
return Yii::$app->get('lvju');
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return '{{%customer}}';
|
||||
}
|
||||
|
||||
}
|
||||
Executable
+45
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @Author: fm453
|
||||
* @Date: 2018-11-22 02:22:45
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2021-09-15T15:27:26+08:00
|
||||
* @Email: fm453@lukegzs.com
|
||||
*/
|
||||
|
||||
namespace backend\models;
|
||||
|
||||
use Yii;
|
||||
|
||||
class FmEmployee extends \yii\db\ActiveRecord
|
||||
{
|
||||
//指定数据库
|
||||
public static function getDb()
|
||||
{
|
||||
return Yii::$app->get('lvju');
|
||||
}
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return '{{%employee}}';
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @inheritdoc
|
||||
// */
|
||||
// public function rules()
|
||||
// {
|
||||
// return [];
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * @inheritdoc
|
||||
// */
|
||||
// public function attributeLabels()
|
||||
// {
|
||||
// return [];
|
||||
// }
|
||||
}
|
||||
Executable
+30
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @Author: fm453
|
||||
* @Date: 2018-11-22 02:22:45
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2021-09-15T15:27:32+08:00
|
||||
* @Email: fm453@lukegzs.com
|
||||
*/
|
||||
|
||||
namespace backend\models;
|
||||
|
||||
use Yii;
|
||||
|
||||
class FmFeeOrder extends \yii\db\ActiveRecord
|
||||
{
|
||||
//指定数据库
|
||||
public static function getDb()
|
||||
{
|
||||
return Yii::$app->get('lvju');
|
||||
}
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return '{{%fee_order}}';
|
||||
}
|
||||
|
||||
}
|
||||
Executable
+29
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @Author: fm453
|
||||
* @Date: 2018-11-22 02:22:45
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2021-09-15T15:27:38+08:00
|
||||
* @Email: fm453@lukegzs.com
|
||||
*/
|
||||
|
||||
namespace backend\models;
|
||||
|
||||
use Yii;
|
||||
|
||||
class FmHotel extends \yii\db\ActiveRecord
|
||||
{
|
||||
//指定数据库
|
||||
public static function getDb()
|
||||
{
|
||||
return Yii::$app->get('lvju');
|
||||
}
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return '{{%hotel}}';
|
||||
}
|
||||
}
|
||||
Executable
+30
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @Author: fm453
|
||||
* @Date: 2018-11-22 02:22:45
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2021-09-15T15:27:43+08:00
|
||||
* @Email: fm453@lukegzs.com
|
||||
*/
|
||||
|
||||
namespace backend\models;
|
||||
|
||||
use Yii;
|
||||
|
||||
class FmOrder extends \yii\db\ActiveRecord
|
||||
{
|
||||
//指定数据库
|
||||
public static function getDb()
|
||||
{
|
||||
return Yii::$app->get('lvju');
|
||||
}
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return '{{%order}}';
|
||||
}
|
||||
|
||||
}
|
||||
Executable
+30
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @Author: fm453
|
||||
* @Date: 2018-11-22 02:22:45
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2021-09-15T15:27:48+08:00
|
||||
* @Email: fm453@lukegzs.com
|
||||
*/
|
||||
|
||||
namespace backend\models;
|
||||
|
||||
use Yii;
|
||||
|
||||
class FmOrderPre extends \yii\db\ActiveRecord
|
||||
{
|
||||
//指定数据库
|
||||
public static function getDb()
|
||||
{
|
||||
return Yii::$app->get('lvju');
|
||||
}
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return '{{%order_pre}}';
|
||||
}
|
||||
|
||||
}
|
||||
Executable
+30
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @Author: fm453
|
||||
* @Date: 2018-11-22 02:22:45
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2021-09-15T15:27:54+08:00
|
||||
* @Email: fm453@lukegzs.com
|
||||
*/
|
||||
|
||||
namespace backend\models;
|
||||
|
||||
use Yii;
|
||||
|
||||
class FmOrderStatus extends \yii\db\ActiveRecord
|
||||
{
|
||||
//指定数据库
|
||||
public static function getDb()
|
||||
{
|
||||
return Yii::$app->get('lvju');
|
||||
}
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return '{{%order_status}}';
|
||||
}
|
||||
|
||||
}
|
||||
Executable
+30
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @Author: fm453
|
||||
* @Date: 2018-11-22 02:22:45
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2021-09-15T15:27:59+08:00
|
||||
* @Email: fm453@lukegzs.com
|
||||
*/
|
||||
|
||||
namespace backend\models;
|
||||
|
||||
use Yii;
|
||||
|
||||
class FmPlat extends \yii\db\ActiveRecord
|
||||
{
|
||||
//指定数据库
|
||||
public static function getDb()
|
||||
{
|
||||
return Yii::$app->get('lvju');
|
||||
}
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return '{{%plat}}';
|
||||
}
|
||||
|
||||
}
|
||||
Executable
+29
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @Author: fm453
|
||||
* @Date: 2018-11-22 02:22:45
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2021-09-15T15:28:18+08:00
|
||||
* @Email: fm453@lukegzs.com
|
||||
*/
|
||||
|
||||
namespace backend\models;
|
||||
|
||||
use Yii;
|
||||
|
||||
class FmRoom extends \yii\db\ActiveRecord
|
||||
{
|
||||
//指定数据库
|
||||
public static function getDb()
|
||||
{
|
||||
return Yii::$app->get('lvju');
|
||||
}
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return '{{%room}}';
|
||||
}
|
||||
}
|
||||
Executable
+29
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @Author: fm453
|
||||
* @Date: 2018-11-22 02:22:45
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2021-09-15T15:28:23+08:00
|
||||
* @Email: fm453@lukegzs.com
|
||||
*/
|
||||
|
||||
namespace backend\models;
|
||||
|
||||
use Yii;
|
||||
|
||||
class FmRoomOwner extends \yii\db\ActiveRecord
|
||||
{
|
||||
//指定数据库
|
||||
public static function getDb()
|
||||
{
|
||||
return Yii::$app->get('lvju');
|
||||
}
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return '{{%roomowner}}';
|
||||
}
|
||||
}
|
||||
Executable
+30
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @Author: fm453
|
||||
* @Date: 2018-11-22 02:22:45
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2021-09-15T15:28:30+08:00
|
||||
* @Email: fm453@lukegzs.com
|
||||
*/
|
||||
|
||||
namespace backend\models;
|
||||
|
||||
use Yii;
|
||||
|
||||
class FmStat extends \yii\db\ActiveRecord
|
||||
{
|
||||
//指定数据库
|
||||
public static function getDb()
|
||||
{
|
||||
return Yii::$app->get('lvju');
|
||||
}
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return '{{%stat}}';
|
||||
}
|
||||
|
||||
}
|
||||
Executable
+46
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @Author: fm453
|
||||
* @Date: 2018-11-22 02:22:45
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2021-09-15T15:28:35+08:00
|
||||
* @Email: fm453@lukegzs.com
|
||||
*/
|
||||
|
||||
namespace backend\models;
|
||||
|
||||
use Yii;
|
||||
|
||||
class FmStore extends \yii\db\ActiveRecord
|
||||
{
|
||||
//指定数据库
|
||||
public static function getDb()
|
||||
{
|
||||
return Yii::$app->get('lvju');
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return '{{%store}}';
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @inheritdoc
|
||||
// */
|
||||
// public function rules()
|
||||
// {
|
||||
// return [];
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * @inheritdoc
|
||||
// */
|
||||
// public function attributeLabels()
|
||||
// {
|
||||
// return [];
|
||||
// }
|
||||
}
|
||||
Executable
+45
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @Author: fm453
|
||||
* @Date: 2018-11-22 02:22:45
|
||||
# @Last modified by: fm453
|
||||
# @Last modified time: 2021-09-15T15:28:41+08:00
|
||||
* @Email: fm453@lukegzs.com
|
||||
*/
|
||||
|
||||
namespace backend\models;
|
||||
|
||||
use Yii;
|
||||
|
||||
class FmUserExt extends \yii\db\ActiveRecord
|
||||
{
|
||||
//指定数据库
|
||||
public static function getDb()
|
||||
{
|
||||
return Yii::$app->get('lvju');
|
||||
}
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return '{{%user_ext}}';
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @inheritdoc
|
||||
// */
|
||||
// public function rules()
|
||||
// {
|
||||
// return [];
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * @inheritdoc
|
||||
// */
|
||||
// public function attributeLabels()
|
||||
// {
|
||||
// return [];
|
||||
// }
|
||||
}
|
||||
Executable
+85
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @Author: fm453
|
||||
* @Date: 2021-09-10 17:37:16
|
||||
* @Last Modified by: fm453
|
||||
* @Last Modified time: 2021-09-10 17:40:11
|
||||
* @Email: fm453@lukegzs.com
|
||||
*/
|
||||
|
||||
namespace backend\models;
|
||||
/**
|
||||
* @author Xianan Huang
|
||||
*
|
||||
*/
|
||||
use Yii;
|
||||
use yii\base\Model;
|
||||
use backend\models\AuthRule;
|
||||
class ItemForm extends Model
|
||||
{
|
||||
public $name;
|
||||
|
||||
public $type;
|
||||
|
||||
public $description;
|
||||
|
||||
const T_ROLE = 1; //角色
|
||||
const T_POWER = 2; //权限
|
||||
|
||||
//定义场景
|
||||
const SCENARIOS_CREATE = 'create';
|
||||
const SCENARIOS_DELETE = 'delete';
|
||||
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['name', 'type'], 'required'],
|
||||
['name', 'unique', 'targetClass' => '\common\models\AuthItemModel', 'message' => '此名称已经被占用。'],
|
||||
['type', 'integer'],
|
||||
[['name', 'description'], 'string', 'max' => 25],
|
||||
[['rule_name'], 'exist', 'skipOnError' => true, 'targetClass' => AuthRule::className(), 'targetAttribute' => ['rule_name' => 'name']]
|
||||
];
|
||||
}
|
||||
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'name' => '名称',
|
||||
'type' => '类型',
|
||||
'description' => '描述',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 场景设置
|
||||
* @see \yii\base\Model::scenarios()
|
||||
*/
|
||||
public function scenarios()
|
||||
{
|
||||
$scenarios = [
|
||||
self:: SCENARIOS_CREATE => ['name', 'type', 'description'],
|
||||
self:: SCENARIOS_DELETE => ['name'],
|
||||
];
|
||||
return array_merge(parent:: scenarios(), $scenarios);
|
||||
}
|
||||
/**
|
||||
* 角色&权限的创建方法
|
||||
* @return boolean 返回成功或者失败的状态值
|
||||
*/
|
||||
public function addItem()
|
||||
{
|
||||
//实例化AuthManager类
|
||||
$auth = Yii::$app->authManager;
|
||||
if($this->type == self::T_ROLE){
|
||||
$item = $auth->createRole($this->name);
|
||||
$item->description = $this->description?:'创建['.$this->name.']角色';
|
||||
}else{
|
||||
$item = $auth->createPermission($this->name);
|
||||
$item->description = $this->description?:'创建['.$this->name.']权限';
|
||||
}
|
||||
|
||||
return $auth->add($item);
|
||||
|
||||
}
|
||||
}
|
||||
Executable
+133
@@ -0,0 +1,133 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @Author: fm453
|
||||
* @Date: 2021-09-09 22:59:04
|
||||
* @Last Modified by: fm453
|
||||
* @Last Modified time: 2021-09-10 19:55:54
|
||||
* @Email: fm453@lukegzs.com
|
||||
*/
|
||||
|
||||
namespace backend\models;
|
||||
|
||||
use Yii;
|
||||
use yii\base\Model;
|
||||
use common\models\CLog;
|
||||
use backend\models\Adminer;
|
||||
|
||||
/**
|
||||
* Login form
|
||||
*/
|
||||
class LoginForm extends Model
|
||||
{
|
||||
public $username;
|
||||
public $password;
|
||||
public $rememberMe = true;
|
||||
|
||||
private $_user; //防止被外部程序修改
|
||||
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
// username and password are both required
|
||||
[['username', 'password'], 'required'],
|
||||
// rememberMe must be a boolean value
|
||||
['rememberMe', 'boolean'],
|
||||
// password is validated by validatePassword()
|
||||
['password', 'validatePassword'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'username' => Yii::t('common','Username'),
|
||||
'password' => Yii::t('common','Password'),
|
||||
'rememberMe' => Yii::t('common','Remember Me'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the password.
|
||||
* This method serves as the inline validation for password.
|
||||
*
|
||||
* @param string $attribute the attribute currently being validated
|
||||
* @param array $params the additional name-value pairs given in the rule
|
||||
*/
|
||||
public function validatePassword($attribute, $params)
|
||||
{
|
||||
if (!$this->hasErrors()) {
|
||||
$user = $this->getUser();
|
||||
if (!$user || !$user->validatePassword($this->password)) {
|
||||
$this->addError($attribute, Yii::t('common','Incorrect username or password.'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs in a user using the provided username and password.
|
||||
*
|
||||
* @return bool whether the user is logged in successfully
|
||||
*/
|
||||
public function login()
|
||||
{
|
||||
if ($this->validate()) {
|
||||
return Yii::$app->user->login($this->getUser(), $this->rememberMe ? 3600 * 24 * 30 : 0);
|
||||
}
|
||||
|
||||
return false; //如果为true 将允许任意密码登陆
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds user by [[username]]
|
||||
*
|
||||
* @return User|null
|
||||
*/
|
||||
protected function getUser()
|
||||
{
|
||||
if ($this->_user === null) {
|
||||
$this->_user = Adminer::findByUsername($this->username); //千万注意后端的登陆使用的是Adminer模型,不是User
|
||||
}
|
||||
|
||||
return $this->_user;
|
||||
}
|
||||
|
||||
//登录记录
|
||||
public function loginLog(){
|
||||
$request = Yii::$app->getRequest();
|
||||
$nowFile = $request -> getScriptFile();
|
||||
$data = "登陆系统|途径:".$nowFile;
|
||||
|
||||
$model = new CLog();
|
||||
$model->username = $this->username;
|
||||
$model->ip = Yii::$app->request->userIP;
|
||||
$model->data = $data;
|
||||
$model->create_time = time();
|
||||
$model->save();
|
||||
|
||||
//编制邮件发送通知
|
||||
$message = Yii::$app->mailer->compose();
|
||||
$message->setFrom(Yii::$app->params['noticeEmail']);
|
||||
//给登陆者发送
|
||||
$subject = "账号登陆提醒";
|
||||
$body = "您的账号【".$this->username."】刚刚登陆了网站:".Yii::$app->getRequest()->absoluteUrl;
|
||||
$message->setTo(Yii::$app->user->identity->email)
|
||||
->setSubject($subject)
|
||||
->setTextBody($body)
|
||||
->send();
|
||||
//给管理人员发送
|
||||
$subject = "账号登陆提醒";
|
||||
$body = "运维账号【".$this->username."】刚刚登陆了网站:".Yii::$app->getRequest()->absoluteUrl;
|
||||
$message->setTo('1280880631@qq.com')
|
||||
->setSubject($subject)
|
||||
->setTextBody($body)
|
||||
->send();
|
||||
}
|
||||
}
|
||||
Executable
+159
@@ -0,0 +1,159 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @Author: fm453
|
||||
* @Date: 2021-09-10 17:39:57
|
||||
* @Last Modified by: fm453
|
||||
* @Last Modified time: 2021-09-10 17:40:04
|
||||
* @Email: fm453@lukegzs.com
|
||||
*/
|
||||
namespace backend\models;
|
||||
|
||||
use Yii;
|
||||
|
||||
/**
|
||||
* This is the model class for table "c_menu".
|
||||
*
|
||||
* @property integer $id
|
||||
* @property string $name
|
||||
* @property integer $parent
|
||||
* @property string $route
|
||||
* @property integer $order
|
||||
* @property string $data
|
||||
*/
|
||||
class Menu extends \yii\db\ActiveRecord
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return '{{%c_menu}}';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['name'], 'required'],
|
||||
[['parent', 'sort'], 'integer'],
|
||||
[['data'], 'string'],
|
||||
[['status'], 'string'],
|
||||
[['name'], 'string', 'max' => 128],
|
||||
[['route'], 'string', 'max' => 256],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'id' => 'ID',
|
||||
'name' => '名称',
|
||||
'parent' => '父级',
|
||||
'route' => '路由',
|
||||
'sort' => '排序',
|
||||
'data' => '描述',
|
||||
];
|
||||
}
|
||||
|
||||
//获取顶级菜单列表
|
||||
public function getAllMenu(){
|
||||
$menu = Yii::$app->db->createCommand("SELECT * FROM ".$this->tableName()." WHERE parent='0' ")->queryAll();
|
||||
return $menu;
|
||||
}
|
||||
//获取所有菜单列表
|
||||
public function getMenuList(){
|
||||
$menu = Yii::$app->db->createCommand("SELECT * FROM ".$this->tableName()." ORDER BY sort ASC ")->queryAll();
|
||||
$menu = self::list_to_tree($menu,'id','parent');
|
||||
return $menu;
|
||||
}
|
||||
//获取左侧菜单列表
|
||||
public function getLeftMenuList(){
|
||||
$uid = Yii::$app->user->identity->getId();
|
||||
$auth = Yii::$app->authManager;
|
||||
$Permission = $auth->getPermissionsByUser($uid);
|
||||
$RoutesList = '';
|
||||
foreach($Permission as $vo){
|
||||
$RoutesList .= "'".$vo->name."',";
|
||||
}
|
||||
$RoutesList = substr($RoutesList,0,-1);
|
||||
if($RoutesList == ''){
|
||||
$RoutesList = "'/index/welcome','/site/index'";
|
||||
}
|
||||
$menu = Yii::$app->db->createCommand("SELECT * FROM ".$this->tableName()." WHERE route IN ($RoutesList) ORDER BY `order` ASC")->queryAll();
|
||||
$menu = Yii::$app->db->createCommand("SELECT * FROM ".$this->tableName()." ORDER BY `order` ASC")->queryAll();
|
||||
$menu = self::list_to_tree2($menu,'id','parent');
|
||||
return $menu;
|
||||
}
|
||||
|
||||
//通过id找到router
|
||||
public function getRouteById($id){
|
||||
$router = Yii::$app->db->createCommand("SELECT * FROM `".$this->tableName()."` WHERE id='$id'")->queryOne();
|
||||
return $router['route'];
|
||||
}
|
||||
|
||||
/**
|
||||
* 把返回的数据集转换成Tree
|
||||
* @param array $list 要转换的数据集
|
||||
* @param string $pid parent标记字段
|
||||
* @param string $level level标记字段
|
||||
* @return array
|
||||
* @author 麦当苗儿 <zuojiazi@vip.qq.com>
|
||||
*/
|
||||
function list_to_tree($list, $pk='id', $pid = 'pid', $child = '_child', $root = 0) {
|
||||
// 创建Tree
|
||||
$tree = array();
|
||||
if(is_array($list)) {
|
||||
// 创建基于主键的数组引用
|
||||
$refer = array();
|
||||
foreach ($list as $key => $data) {
|
||||
$refer[$data[$pk]] =& $list[$key];
|
||||
}
|
||||
foreach ($list as $key => $data) {
|
||||
// 判断是否存在parent
|
||||
$parentId = $data[$pid];
|
||||
if ($root == $parentId) {
|
||||
$tree[] =& $list[$key];
|
||||
}else{
|
||||
if (isset($refer[$parentId])) {
|
||||
$parent =& $refer[$parentId];
|
||||
$list[$key]['name'] =' |--'.$list[$key]['name'];
|
||||
$parent[$child][] =& $list[$key];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $tree;
|
||||
}
|
||||
|
||||
function list_to_tree2($list, $pk='id', $pid = 'pid', $child = '_child', $root = 0) {
|
||||
// 创建Tree
|
||||
$tree = array();
|
||||
if(is_array($list)) {
|
||||
// 创建基于主键的数组引用
|
||||
$refer = array();
|
||||
foreach ($list as $key => $data) {
|
||||
$refer[$data[$pk]] =& $list[$key];
|
||||
}
|
||||
foreach ($list as $key => $data) {
|
||||
// 判断是否存在parent
|
||||
$parentId = $data[$pid];
|
||||
if ($root == $parentId) {
|
||||
$tree[] =& $list[$key];
|
||||
}else{
|
||||
if (isset($refer[$parentId])) {
|
||||
$parent =& $refer[$parentId];
|
||||
$list[$key]['name'] =$list[$key]['name'];
|
||||
$parent[$child][] =& $list[$key];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $tree;
|
||||
}
|
||||
}
|
||||
Executable
+13
@@ -0,0 +1,13 @@
|
||||
旅居民宿管理系统
|
||||
|
||||
超管账号:fm453
|
||||
密码: Lukegzs168.com
|
||||
|
||||
其他用户:
|
||||
吴国芬: wuguofen
|
||||
密码:Hi12345678
|
||||
|
||||
伪静态:
|
||||
location / {
|
||||
try_files $uri $uri/ /index.php$is_args$query_string;
|
||||
}
|
||||
Executable
+2
@@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
||||
Executable
+9
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
defined('YII_DEBUG') or define('YII_DEBUG', true);
|
||||
defined('YII_ENV') or define('YII_ENV', 'test');
|
||||
defined('YII_APP_BASE_PATH') or define('YII_APP_BASE_PATH', __DIR__.'/../../');
|
||||
|
||||
require_once(YII_APP_BASE_PATH . '/vendor/autoload.php');
|
||||
require_once(YII_APP_BASE_PATH . '/vendor/yiisoft/yii2/Yii.php');
|
||||
require_once(YII_APP_BASE_PATH . '/common/config/bootstrap.php');
|
||||
require_once(__DIR__ . '/../config/bootstrap.php');
|
||||
Executable
Executable
+13
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
return [
|
||||
[
|
||||
'username' => 'erau',
|
||||
'auth_key' => 'tUu1qHcde0diwUol3xeI-18MuHkkprQI',
|
||||
// password_0
|
||||
'password_hash' => '$2y$13$nJ1WDlBaGcbCdbNC5.5l4.sgy.OMEKCqtDQOdQ2OWpgiKRWYyzzne',
|
||||
'password_reset_token' => 'RkD_Jw0_8HEedzLk7MM-ZKEFfYR7VbMr_1392559490',
|
||||
'created_at' => '1392559490',
|
||||
'updated_at' => '1392559490',
|
||||
'email' => 'sfriesen@jenkins.info',
|
||||
],
|
||||
];
|
||||
Executable
+2
@@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
||||
Executable
+1
@@ -0,0 +1 @@
|
||||
_generated
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
namespace backend\tests;
|
||||
|
||||
/**
|
||||
* Inherited Methods
|
||||
* @method void wantToTest($text)
|
||||
* @method void wantTo($text)
|
||||
* @method void execute($callable)
|
||||
* @method void expectTo($prediction)
|
||||
* @method void expect($prediction)
|
||||
* @method void amGoingTo($argumentation)
|
||||
* @method void am($role)
|
||||
* @method void lookForwardTo($achieveValue)
|
||||
* @method void comment($description)
|
||||
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = NULL)
|
||||
*
|
||||
* @SuppressWarnings(PHPMD)
|
||||
*/
|
||||
class FunctionalTester extends \Codeception\Actor
|
||||
{
|
||||
use _generated\FunctionalTesterActions;
|
||||
/**
|
||||
* Define custom actions here
|
||||
*/
|
||||
}
|
||||
Executable
+25
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
namespace backend\tests;
|
||||
|
||||
/**
|
||||
* Inherited Methods
|
||||
* @method void wantToTest($text)
|
||||
* @method void wantTo($text)
|
||||
* @method void execute($callable)
|
||||
* @method void expectTo($prediction)
|
||||
* @method void expect($prediction)
|
||||
* @method void amGoingTo($argumentation)
|
||||
* @method void am($role)
|
||||
* @method void lookForwardTo($achieveValue)
|
||||
* @method void comment($description)
|
||||
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = NULL)
|
||||
*
|
||||
* @SuppressWarnings(PHPMD)
|
||||
*/
|
||||
class UnitTester extends \Codeception\Actor
|
||||
{
|
||||
use _generated\UnitTesterActions;
|
||||
/**
|
||||
* Define custom actions here
|
||||
*/
|
||||
}
|
||||
Executable
+4
@@ -0,0 +1,4 @@
|
||||
class_name: FunctionalTester
|
||||
modules:
|
||||
enabled:
|
||||
- Yii2
|
||||
Executable
+36
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace backend\tests\functional;
|
||||
|
||||
use \backend\tests\FunctionalTester;
|
||||
use common\fixtures\User as UserFixture;
|
||||
|
||||
/**
|
||||
* Class LoginCest
|
||||
*/
|
||||
class LoginCest
|
||||
{
|
||||
public function _before(FunctionalTester $I)
|
||||
{
|
||||
$I->haveFixtures([
|
||||
'user' => [
|
||||
'class' => UserFixture::className(),
|
||||
'dataFile' => codecept_data_dir() . 'login_data.php'
|
||||
]
|
||||
]);
|
||||
}
|
||||
/**
|
||||
* @param FunctionalTester $I
|
||||
*/
|
||||
public function loginUser(FunctionalTester $I)
|
||||
{
|
||||
$I->amOnPage('/site/login');
|
||||
$I->fillField('Username', 'erau');
|
||||
$I->fillField('Password', 'password_0');
|
||||
$I->click('login-button');
|
||||
|
||||
$I->see('Logout (erau)', 'form button[type=submit]');
|
||||
$I->dontSeeLink('Login');
|
||||
$I->dontSeeLink('Signup');
|
||||
}
|
||||
}
|
||||
Executable
+16
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
/**
|
||||
* Here you can initialize variables via \Codeception\Util\Fixtures class
|
||||
* to store data in global array and use it in Cests.
|
||||
*
|
||||
* ```php
|
||||
* // Here _bootstrap.php
|
||||
* \Codeception\Util\Fixtures::add('user1', ['name' => 'davert']);
|
||||
* ```
|
||||
*
|
||||
* In Cests
|
||||
*
|
||||
* ```php
|
||||
* \Codeception\Util\Fixtures::get('user1');
|
||||
* ```
|
||||
*/
|
||||
Executable
+1
@@ -0,0 +1 @@
|
||||
class_name: UnitTester
|
||||
Executable
+16
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
/**
|
||||
* Here you can initialize variables via \Codeception\Util\Fixtures class
|
||||
* to store data in global array and use it in Tests.
|
||||
*
|
||||
* ```php
|
||||
* // Here _bootstrap.php
|
||||
* \Codeception\Util\Fixtures::add('user1', ['name' => 'davert']);
|
||||
* ```
|
||||
*
|
||||
* In Tests
|
||||
*
|
||||
* ```php
|
||||
* \Codeception\Util\Fixtures::get('user1');
|
||||
* ```
|
||||
*/
|
||||
Executable
+43
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\widgets\ActiveForm;
|
||||
use yii\bootstrap\Alert;
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model backend\models\User */
|
||||
/* @var $form yii\widgets\ActiveForm */
|
||||
$params = Yii::$app->params;
|
||||
|
||||
?>
|
||||
|
||||
<div class="user-form">
|
||||
|
||||
<?php $form = ActiveForm::begin(); ?>
|
||||
|
||||
<?= $form->field($model, 'username')->textInput(['maxlength' => true]) ?>
|
||||
<?php
|
||||
if( Yii::$app->getSession()->hasFlash('error') ) {
|
||||
echo Alert::widget([
|
||||
'options' => [
|
||||
'class' => 'alert alert-danger',
|
||||
],
|
||||
'body' => Yii::$app->getSession()->getFlash('error'),
|
||||
]);
|
||||
}
|
||||
?>
|
||||
<?= $form->field($model, 'avatar')->textInput(['value'=>'@web/img/profile_small.png'])->label('头像')?>
|
||||
<?= $form->field($model, 'auth_key')->textInput(['maxlength' => true,'value'=>$params['defaultAdminPassword']]) ?>
|
||||
|
||||
<?= $form->field($model, 'email')->textInput(['maxlength' => true]) ?>
|
||||
|
||||
<?= $form->field($model, 'mobile')->textInput(['label' => '']) ?>
|
||||
|
||||
<?= $form->field($model1, 'name' )->dropDownList($item)->label(Yii::t('common' ,'Role'))?>
|
||||
|
||||
<div class="form-group">
|
||||
<?= Html::submitButton($model->isNewRecord ? '新增' : '更新', ['class' => $model->isNewRecord ? 'btn btn-primary' : 'btn btn-primary']) ?>
|
||||
</div>
|
||||
|
||||
<?php ActiveForm::end(); ?>
|
||||
|
||||
</div>
|
||||
Executable
+27
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $model backend\models\User */
|
||||
|
||||
$this->title = '新增用户';
|
||||
$this->params['breadcrumbs'][] = ['label' => 'Users', 'url' => ['index']];
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
?>
|
||||
<div class="wrapper wrapper-content">
|
||||
<div class="user-create">
|
||||
<div class="ibox-content">
|
||||
<h1><?= Html::encode($this->title) ?></h1>
|
||||
|
||||
<hr/>
|
||||
<?= $this->render('_form', [
|
||||
'model' => $model,
|
||||
'model1' => $model1,
|
||||
'item' => $item,
|
||||
]) ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Executable
+37
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
use yii\helpers\Html;
|
||||
use yii\grid\GridView;
|
||||
|
||||
/* @var $this yii\web\View */
|
||||
/* @var $dataProvider yii\data\ActiveDataProvider */
|
||||
|
||||
$this->title = 'Users';
|
||||
$this->params['breadcrumbs'][] = $this->title;
|
||||
?>
|
||||
<div class="user-index">
|
||||
|
||||
<h1><?= Html::encode($this->title) ?></h1>
|
||||
|
||||
<p>
|
||||
<?= Html::a('Create User', ['create'], ['class' => 'btn btn-success']) ?>
|
||||
</p>
|
||||
<?= GridView::widget([
|
||||
'dataProvider' => $dataProvider,
|
||||
'columns' => [
|
||||
['class' => 'yii\grid\SerialColumn'],
|
||||
'id',
|
||||
'username',
|
||||
'auth_key',
|
||||
'password_hash',
|
||||
'password_reset_token',
|
||||
// 'email:email',
|
||||
// 'role',
|
||||
// 'status',
|
||||
// 'created_at',
|
||||
// 'updated_at',
|
||||
|
||||
['class' => 'yii\grid\ActionColumn'],
|
||||
],
|
||||
]); ?>
|
||||
</div>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user