This commit is contained in:
liuxiaoquan 2023-02-28 15:44:15 +08:00
commit f8c71c69d1
1096 changed files with 178298 additions and 0 deletions

7
.env.debug Normal file
View File

@ -0,0 +1,7 @@
APP_DEBUG = true
[APP]
DEFAULT_TIMEZONE = Asia/Shanghai
[LANG]
default_lang = zh-cn

13
.gitignore vendored Normal file
View File

@ -0,0 +1,13 @@
/.idea
/.vscode
/.gitee
*.log
*.env
*.lock
*.ini
/runtime/*
/public/storage/*
/public/backup/*
/public/static/home/dev
/public/static/home/oa
/config/database.php

201
LICENSE Normal file
View File

@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

37
LICENSE.txt Normal file
View File

@ -0,0 +1,37 @@
ThinkPHP遵循Apache2开源协议发布并提供免费使用。
版权所有Copyright © 2006-2016 by ThinkPHP (http://thinkphp.cn)
All rights reserved。
ThinkPHP® 商标和著作权所有者为上海顶想信息科技有限公司。
Apache Licence是著名的非盈利开源组织Apache采用的协议。
该协议和BSD类似鼓励代码共享和尊重原作者的著作权
允许代码修改,再作为开源或商业软件发布。需要满足
的条件:
1 需要给代码的用户一份Apache Licence
2 如果你修改了代码,需要在被修改的文件中说明;
3 在延伸的代码中(修改和有源代码衍生的代码中)需要
带有原来代码中的协议,商标,专利声明和其他原来作者规
定需要包含的说明;
4 如果再发布的产品中包含一个Notice文件则在Notice文
件中需要带有本协议内容。你可以在Notice中增加自己的
许可但不可以表现为对Apache Licence构成更改。
具体的协议参考http://www.apache.org/licenses/LICENSE-2.0
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
勾股CMS遵循Apache2开源协议发布并提供免费使用。
版权所有Copyright © 2021 by gouguCMS (https://www.gougucms.com)
All rights reserved。

196
README.md Normal file
View File

@ -0,0 +1,196 @@
## 📐 勾股CMS4.0
![输入图片说明](https://www.gougucms.com/storage/image/slogo.jpg)
### ✅ 相关链接
- 项目会不定时进行更新,**建议⭐star⭐和👁watch👁一份**。
- 演示地址https://www.gougucms.com
- 文档地址:[https://blog.gougucms.com/home/book/detail/bid/1.html](https://blog.gougucms.com/home/book/detail/bid/1.html)
- 开发交流QQ群24641076群一满46924914群二名额不多
### ⭕ 开源项目
1. [开源项目系列勾股OA —— OA协同办公系统](https://gitee.com/gougucms/office)
2. [开源项目系列勾股CMS —— CMS内容管理系统框架](https://gitee.com/gougucms/gougucms)
3. [开源项目系列勾股BLOG —— 个人&工作室博客系统](https://gitee.com/gougucms/blog)
4. [开源项目系列勾股DEV —— 项目研发管理系统](https://gitee.com/gougucms/dev)
5. [开源项目系列勾股Admin —— 基于Layui的Web UI解决方案。](https://gitee.com/gouguopen/guoguadmin.git)
### 📋 系统介绍
- 勾股CMS是一套基于ThinkPHP6 + MySql + Layui 开发的轻量级、高性能极速后台开发框架。
- 通用型的后台权限管理框架,各管理模块操作简单,开箱即用。支持前后台用户的操作记录覆盖跟踪。
- 系统整合了易用、且功能强大的富文本编辑器TinyMCE与现今流行的Mardown编辑器Editor.md于自身可在后台配置根据习惯切换不同的编辑器。**封装和优化后,支持截屏复制粘贴上传图片,支持拖拽上传图片。**
- 系统易于功能扩展,方便二次开发,帮助开发者简单高效降低二次开发的成本,满足专注业务深度开发的需求。
- 可以快速基于此系统进行ThinkPHP6的快速开发免去每次都写一次后台基础的痛苦让开发更多关注业务逻辑。既能快速提高开发效率帮助公司节省人力成本同时又不失灵活性。
- 可去版权,真正意义的永久免费,可商用的后台开发框架。
### ✳️ 功能矩阵
![功能导图](https://www.gougucms.com/storage/image/gougucms2.0.png "功能导图")
系统后台集成了主流的通用功能登录验证、系统配置、操作日志管理、角色权限管理、功能管理后台菜单管理、导航设置、网站地图、轮播广告、TAG关键字管理、搜索关键字管理、文件上传、数据备份/还原、文章功能、商品功能、单页面管理、用户管理、用户操作日志、用户注册/登录、 API接口等。更多的个性化功能可以基于当前系统便捷做二次开发。
具体功能如下:
~~~
系统
├─系统管理
│ ├─系统配置
│ ├─功能模块
│ ├─功能节点
│ ├─权限角色
│ ├─部门架构
│ ├─岗位职称
│ ├─系统用户
├─系统工具
│ ├─一键CRUD
│ ├─管 理 员
│ ├─操作日志
│ ├─数据备份
│ ├─数据还原
├─基础数据
│ ├─导航设置
│ ├─网站地图
│ ├─轮播广告
│ ├─SEO关键字
│ ├─搜索关键词
├─平台用户
│ ├─用户等级
│ ├─用户管理
│ ├─操作记录
│ ├─操作日志
├─资讯中心
│ ├─文章分类
│ ├─文章列表
├─商品中心
│ ├─商品分类
│ ├─商品列表
├─图集中心
│ ├─图集分类
│ ├─图集列表
├─单 页 面
│ ├─单页面列表
│ ├─商业智能
├─...
~~~
### 📚 安装教程
**一、服务器。**
服务器最低配置:
~~~
1核CPU (建议2核+)
1G内存 (建议4G+)
1M带宽 (建议3M+)
~~~
服务器运行环境要求:
~~~
PHP >= 7.2.5
Mysql >= 5.5.0 (需支持innodb引擎)
Apache 或 Nginx
PDO PHP Extension
MBstring PHP Extension
CURL PHP Extension
Composer (用于管理第三方扩展包)
~~~
**二、系统安装**
推荐使用命令行安装因为采用命令行安装的方式可以和勾股CMS随时保持更新同步。使用命令行安装请提前准备好Git、Composer。
Linux下勾股CMS的安装请使用以下命令进行安装。
第一步克隆勾股CMS到你本地 **如果不用git的可以在友上角打包下载代码然后解压上传**
git clone https://gitee.com/gougucms/gougucms.git
第二步:进入目录
cd gougucms
第三步下载PHP依赖包
composer install
第四步添加虚拟主机并绑定到项目的public目录 **实际部署中确保绑定域名访问到的是public目录**
第五步:访问 http://www.yoursite.com/install/index 进行安装
⚠️ **注意:安装过程中,系统会自动创建数据库,请确保填写的数据库用户的权限可创建数据库,如果权限不足,请先手动创建空的数据库,然后填写刚创建的数据库名称和用户名也可完成安装。**
🔺 **提醒安装过程中如果进度条卡住一般都是数据库写入权限或者安装环境配置问题请注意检查。遇到问题请到QQ群24641076 反馈**
**PS如需要重新安装请删除目录里面 config/install.lock 的文件,即可重新安装。**
**三、伪静态配置**
**Nginx**
修改nginx.conf 配置文件 加入下面的语句。
~~~
location / {
if (!-e $request_filename){
rewrite ^(.*)$ /index.php?s=$1 last; break;
}
}
~~~
**Apache**
把下面的内容保存为.htaccess文件放到应用入 public 文件的同级目录下。
~~~
<IfModule mod_rewrite.c>
Options +FollowSymlinks -Multiviews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?/$1 [QSA,PT,L]
</IfModule>
~~~
### ❓ 常见问题
1. 安装失败可能存在php配置文件禁止了putenv 和 proc_open函数。解决方法查找php.ini文件位置打开php.ini搜索 disable_functions 项看是否禁用了putenv 和 proc_open函数。如果在禁用列表里移除putenv proc_open然后退出重启php即可。
2. 如果安装后打开页面提示404错误请检查服务器伪静态配置如果是宝塔面板网站伪静态请配置使用thinkphp规则。
3. 如果提示当前权限不足无法写入配置文件config/database.php请检查database.php是否可读还有可能是当前安装程序无法访问父目录请检查PHP的open_basedir配置。
4. 如果composer install失败请尝试在命令行进行切换配置到国内源命令如下composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/。
5. 访问 http://www.你的域名.com/install/index 前请注意查看伪静态请配置是否设置了thinkphp规则。
6. 出现访问报错一般是服务器环境配置问题
比如伪静态配置网站的访问入口是否绑定public目录放配置文件的目录是否有可写权限放缓存的目录是否有可写权限数据库连接确认无误等。
开启debug的方式请查看链接https://blog.gougucms.com/home/book/detail/bid/3/id/77.html
开启debug后看具体的报错信息然后沿着这些思路去一个个排查基本解决。
7. 如果是composer的安装composer install报错可以百度得到具体解决方案的。
8. 遇到解决不了的问题请到QQ群反馈24641076群一满46924914群二名额不多
### 🖼️ 截图预览
|页面截图 | 部分截图|
| :--------: | :--------:|
| ![功能导图](https://www.gougucms.com/storage/image/p1.png "功能导图")|![功能导图](https://www.gougucms.com/storage/image/p2.png "功能导图")|
|![功能导图](https://www.gougucms.com/storage/image/p3.png "功能导图")|![功能导图](https://www.gougucms.com/storage/image/p4.png "功能导图")|
### ⭐ 开源助力
- 勾股CMS遵循Apache2开源协议发布并提供免费使用。
- 开源的系统少不了大家的参与如果大家在体验的过程中发现有问题或者BUG请到Issue里面反馈谢谢
- 毫无保留的真开源如果觉得勾股CMS不错不要吝啬您的赞许和鼓励请给我们⭐ STAR ⭐吧!
### 👍 支持我们
- If the project is very helpful to you, you can buy the author a cup of coffee☕.
- 如果这个项目对您有帮助,可以请作者喝杯咖啡吧☕
|支付宝 | 微信|
| :--------: | :--------:|
| <img src="https://www.gougucms.com/static/home/images/zfb.png" width="300" align=center />|<img src="https://www.gougucms.com/static/home/images/wx.png" width="300" align=center />|

View File

@ -0,0 +1,175 @@
<?php
/**
* @copyright Copyright (c) 2021 勾股工作室
* @license https://opensource.org/licenses/Apache-2.0
* @link https://www.gougucms.com
*/
declare (strict_types = 1);
namespace app\admin;
use think\App;
use think\exception\HttpResponseException;
use think\facade\Request;
/**
* 控制器基础类
*/
abstract class BaseController
{
/**
* Request实例
* @var \think\Request
*/
protected $request;
/**
* 应用实例
* @var \think\App
*/
protected $app;
/**
* 是否批量验证
* @var bool
*/
protected $batchValidate = false;
/**
* 控制器中间件
* @var array
*/
protected $middleware = [];
/**
* 构造方法
* @access public
* @param App $app 应用对象
*/
public function __construct(App $app)
{
$this->app = $app;
$this->request = $this->app->request;
// 控制器初始化
$this->initialize();
}
// 初始化
protected function initialize()
{
$this->param = $this->request->param();
}
//
// 以下为新增,为了使用旧版的 success error redirect 跳转 start
//
/**
* 操作成功跳转的快捷方法
* @access protected
* @param mixed $msg 提示信息
* @param string $url 跳转的URL地址
* @param mixed $data 返回的数据
* @param integer $wait 跳转等待时间
* @param array $header 发送的Header信息
* @return void
*/
protected function success($msg = '', string $url = null, $data = '', int $wait = 3, array $header = [])
{
if (is_null($url) && isset($_SERVER["HTTP_REFERER"])) {
$url = $_SERVER["HTTP_REFERER"];
} elseif ($url) {
$url = (strpos($url, '://') || 0 === strpos($url, '/')) ? $url : app('route')->buildUrl($url);
}
$result = [
'code' => 0,
'msg' => $msg,
'data' => $data,
'url' => $url,
'wait' => $wait,
];
$type = $this->getResponseType();
if ($type == 'html') {
$response = view($this->app->config->get('app.dispatch_success_tmpl'), $result);
} else if ($type == 'json') {
$response = json($result);
}
throw new HttpResponseException($response);
}
/**
* 操作错误跳转的快捷方法
* @access protected
* @param mixed $msg 提示信息
* @param string $url 跳转的URL地址
* @param mixed $data 返回的数据
* @param integer $wait 跳转等待时间
* @param array $header 发送的Header信息
* @return void
*/
protected function error($msg = '', string $url = null, $data = '', int $wait = 3, array $header = [])
{
if (is_null($url)) {
$url = $this->request->isAjax() ? '' : 'javascript:history.back(-1);';
} elseif ($url) {
$url = (strpos($url, '://') || 0 === strpos($url, '/')) ? $url : $this->app->route->buildUrl($url);
}
$result = [
'code' => 1,
'msg' => $msg,
'data' => $data,
'url' => $url,
'wait' => $wait,
];
$type = $this->getResponseType();
if ($type == 'html') {
$response = view($this->app->config->get('app.dispatch_error_tmpl'), $result);
} else if ($type == 'json') {
$response = json($result);
}
throw new HttpResponseException($response);
}
/**
* URL重定向 自带重定向无效
* @access protected
* @param string $url 跳转的URL表达式
* @param array|integer $params 其它URL参数
* @param integer $code http code
* @param array $with 隐式传参
* @return void
*/
protected function redirect($url, $params = [], $code = 302, $with = [])
{
$response = Response::create($url, 'redirect');
if (is_integer($params)) {
$code = $params;
$params = [];
}
$response->code($code)->params($params)->with($with);
throw new HttpResponseException($response);
}
/**
* 获取当前的response 输出类型
* @access protected
* @return string
*/
protected function getResponseType()
{
return $this->request->isJson() || $this->request->isAjax() ? 'json' : 'html';
}
//
// 以上为新增,为了使用旧版的 success error redirect 跳转 end
//
}

389
app/admin/common.php Normal file
View File

@ -0,0 +1,389 @@
<?php
/**
* @copyright Copyright (c) 2021 勾股工作室
* @license https://opensource.org/licenses/Apache-2.0
* @link https://www.gougucms.com
*/
// 应用公共文件,内置主要的数据处理方法
use think\facade\Config;
use think\facade\Request;
use think\facade\Cache;
use think\facade\Db;
//获取后台模块当前登录用户的信息
function get_login_admin($key = "")
{
$session_admin = get_config('app.session_admin');
if (\think\facade\Session::has($session_admin)) {
$gougu_admin = \think\facade\Session::get($session_admin);
if (!empty($key)) {
if (isset($gougu_admin[$key])) {
return $gougu_admin[$key];
} else {
return '';
}
} else {
return $gougu_admin;
}
} else {
return '';
}
}
/**
* 截取摘要
* @return bool
*/
function getDescriptionFromContent($content, $count)
{
$content = preg_replace("@<script(.*?)</script>@is", "", $content);
$content = preg_replace("@<iframe(.*?)</iframe>@is", "", $content);
$content = preg_replace("@<style(.*?)</style>@is", "", $content);
$content = preg_replace("@<(.*?)>@is", "", $content);
$content = str_replace(PHP_EOL, '', $content);
$space = array(" ", " ", " ", " ", " ");
$go_away = array("", "", "", "", "");
$content = str_replace($space, $go_away, $content);
$res = mb_substr($content, 0, $count, 'UTF-8');
if (mb_strlen($content, 'UTF-8') > $count) {
$res = $res . "...";
}
return $res;
}
/**
* PHP格式化字节大小
* @param number $size 字节数
* @param string $delimiter 数字和单位分隔符
* @return string 格式化后的带单位的大小
*/
function format_bytes($size, $delimiter = '')
{
$units = array('B', 'KB', 'MB', 'GB', 'TB', 'PB');
for ($i = 0; $size >= 1024 && $i < 5; $i++) {
$size /= 1024;
}
return round($size, 2) . $delimiter . $units[$i];
}
function create_tree_list($pid, $arr, $group, &$tree = [])
{
foreach ($arr as $key => $vo) {
if ($key == 0) {
$vo['spread'] = true;
}
if (!empty($group) and in_array($vo['id'], $group)) {
$vo['checked'] = true;
} else {
$vo['checked'] = false;
}
if ($vo['pid'] == $pid) {
$child = create_tree_list($vo['id'], $arr, $group);
if ($child) {
$vo['children'] = $child;
}
$tree[] = $vo;
}
}
return $tree;
}
//递归排序,用于分类选择
function set_recursion($result, $pid = 0, $level=-1)
{
/*记录排序后的类别数组*/
static $list = array();
static $space = ['','├─','§§├─','§§§§├─','§§§§§§├─'];
$level++;
foreach ($result as $k => $v) {
if ($v['pid'] == $pid) {
if ($pid != 0) {
$v['title'] = $space[$level] . $v['title'];
}
/*将该类别的数据放入list中*/
$list[] = $v;
set_recursion($result, $v['id'],$level);
}
}
return $list;
}
/**
* 根据id递归返回子数据
* @param $data 数据
* @param $pid 父节点id
*/
function get_data_node($data=[],$pid=0){
$dep = [];
foreach($data as $k => $v){
if($v['pid'] == $pid){
$node=get_data_node($data, $v['id']);
array_push($dep,$v);
if(!empty($node)){
$dep=array_merge($dep,$node);
}
}
}
return array_values($dep);
}
//获取指定管理员的信息
function get_admin($id)
{
$admin = Db::name('Admin')->where(['id' => $id])->find();
$admin['group_id'] = Db::name('AdminGroupAccess')->where(['uid' => $id])->column('group_id');
return $admin;
}
//读取权限节点列表
function get_admin_rule()
{
$rule = Db::name('AdminRule')->where(['status'=>1])->order('sort asc,id asc')->select()->toArray();
return $rule;
}
//读取商品分类
function get_store_category()
{
$store_category = Db::connect('shop')->table('eb_store_category')->field('store_category_id as id,pid,cate_name as title,sort,level')->where(['is_show' => 1])->select()->toArray();
return $store_category;
}
//读取模块列表
function get_admin_module()
{
$group = Db::name('AdminModule')->order('id asc')->select()->toArray();
return $group;
}
//读取权限分组列表
function get_admin_group()
{
$group = Db::name('AdminGroup')->order('create_time asc')->select()->toArray();
return $group;
}
//读取指定权限分组详情
function get_admin_group_info($id)
{
$rule = Db::name('AdminGroup')->where(['id' => $id])->value('rules');
$rules = explode(',', $rule);
return $rules;
}
//读取部门列表
function get_department()
{
$department = Db::name('Department')->where(['status' => 1])->select()->toArray();
return $department;
}
//获取某部门的子部门id.$is_self时候包含自己
function get_department_son($did = 0, $is_self = 1)
{
$department = get_department();
$department_list = get_data_node($department, $did);
$department_array = array_column($department_list, 'id');
if ($is_self == 1) {
//包括自己在内
$department_array[] = $did;
}
return $department_array;
}
//读取员工所在部门的负责人
function get_department_leader($uid=0,$pid=0)
{
$did = get_admin($uid)['did'];
if($pid==0){
$leader = Db::name('Department')->where(['id' => $did])->value('leader_id');
}
else{
$pdid = Db::name('Department')->where(['id' => $did])->value('pid');
if($pdid == 0){
$leader = 0;
}
else{
$leader = Db::name('Department')->where(['id' => $pdid])->value('leader_id');
}
}
return $leader;
}
//读取职位
function get_position()
{
$position = Db::name('Position')->where(['status' => 1])->select()->toArray();
return $position;
}
//读取导航列表,用于后台
function get_nav($nav_id)
{
$nav = Db::name('NavInfo')->where('nav_id', $nav_id)->order('sort asc')->select();
return $nav;
}
//读取关键字列表
function get_keywords()
{
$keywords = Db::name('Keywords')->where(['status' => 1])->order('create_time asc')->select();
return $keywords;
}
//读取文章分类列表
function get_article_cate()
{
$cate = Db::name('ArticleCate')->where(['delete_time' => 0])->order('create_time asc')->select()->toArray();
return $cate;
}
//读取图集分类列表
function get_gallery_cate()
{
$cate = Db::name('GalleryCate')->where(['delete_time' => 0])->order('create_time asc')->select()->toArray();
return $cate;
}
//读取商品分类列表
function get_goods_cate()
{
$cate = Db::name('GoodsCate')->where(['delete_time' => 0])->order('create_time asc')->select()->toArray();
return $cate;
}
//访问按小时归档统计
function hour_document($arrData)
{
$documents = array();
$hour = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23];
foreach ($hour as $val) {
$documents[$val] = 0;
}
foreach ($arrData as $index => $value) {
$archivesTime = intval(date("H", $value['create_time']));
$documents[$archivesTime] += 1;
}
return $documents;
}
//访问按日期归档统计
function date_document($arrData)
{
$documents = array();
foreach ($arrData as $index => $value) {
$archivesTime = date("Y-m-d", $value['create_time']);
if (empty($documents[$archivesTime])) {
$documents[$archivesTime] = 1;
} else {
$documents[$archivesTime] += 1;
}
}
return $documents;
}
/**
* 管理员操作日志
* @param string $type 操作类型 login add edit view delete
* @param int $param_id 操作类型
* @param array $param 提交的参数
*/
function add_log($type, $param_id = '', $param = [])
{
$action = '未知操作';
$type_action = get_config('log.admin_action');
if($type_action[$type]){
$action = $type_action[$type];
}
if ($type == 'login') {
$login_admin = Db::name('Admin')->where(array('id' => $param_id))->find();
} else {
$session_admin = get_config('app.session_admin');
$login_admin = \think\facade\Session::get($session_admin);
}
$data = [];
$data['uid'] = $login_admin['id'];
$data['nickname'] = $login_admin['nickname'];
$data['type'] = $type;
$data['action'] = $action;
$data['param_id'] = $param_id;
$data['param'] = json_encode($param);
$data['module'] = strtolower(app('http')->getName());
$data['controller'] = uncamelize(app('request')->controller());
$data['function'] = strtolower(app('request')->action());
$parameter = $data['module'] . '/' . $data['controller'] . '/' . $data['function'];
$rule_menu = Db::name('AdminRule')->where(array('src' => $parameter))->find();
if($rule_menu){
$data['title'] = $rule_menu['title'];
$data['subject'] = $rule_menu['name'];
}
else{
$data['title'] = '';
$data['subject'] ='系统';
}
$content = $login_admin['nickname'] . '在' . date('Y-m-d H:i:s') . $data['action'] . '了' . $data['subject'];
$data['content'] = $content;
$data['ip'] = app('request')->ip();
$data['create_time'] = time();
Db::name('AdminLog')->strict(false)->field(true)->insert($data);
}
if (!function_exists('getModelTime')) {
/**
* @param BaseQuery $model
* @param string $section
* @param string $prefix
* @param string $field
* @return mixed
* @author xaboy
* @day 2020-04-29
*/
function getModelTime( $model, string $section, $prefix = 'create_time', $field = '-',$time = '')
{
if (!isset($section)) return $model;
switch ($section) {
case 'today':
$model->whereBetween($prefix, [date('Y-m-d H:i:s', strtotime('today')), date('Y-m-d H:i:s', strtotime('tomorrow -1second'))]);
break;
case 'week':
$model->whereBetween($prefix, [date('Y-m-d H:i:s', strtotime('this week 00:00:00')), date('Y-m-d H:i:s', strtotime('next week 00:00:00 -1second'))]);
break;
case 'month':
$model->whereBetween($prefix, [date('Y-m-d H:i:s', strtotime('first Day of this month 00:00:00')), date('Y-m-d H:i:s', strtotime('first Day of next month 00:00:00 -1second'))]);
break;
case 'year':
$model->whereBetween($prefix, [date('Y-m-d H:i:s', strtotime('this year 1/1')), date('Y-m-d H:i:s', strtotime('next year 1/1 -1second'))]);
break;
case 'yesterday':
$model->whereBetween($prefix, [date('Y-m-d H:i:s', strtotime('yesterday')), date('Y-m-d H:i:s', strtotime('today -1second'))]);
break;
case 'quarter':
list($startTime, $endTime) = getMonth();
$model = $model->where($prefix, '>', $startTime);
$model = $model->where($prefix, '<', $endTime);
break;
case 'lately7':
$model = $model->where($prefix, 'between', [date('Y-m-d', strtotime("-7 day")), date('Y-m-d H:i:s')]);
break;
case 'lately30':
$model = $model->where($prefix, 'between', [date('Y-m-d', strtotime("-30 day")), date('Y-m-d H:i:s')]);
break;
default:
if (strstr($section, $field) !== false) {
list($startTime, $endTime) = explode($field, $section);
if (strlen($startTime) == 4) {
$model->whereBetweenTime($prefix, date('Y-m-d H:i:s', strtotime($section)), date('Y-m-d H:i:s', strtotime($section . ' +1day -1second')));
} else {
if ($startTime == $endTime) {
$model = $model->whereBetweenTime($prefix, date('Y-m-d 0:0:0', strtotime($startTime)), date('Y-m-d 23:59:59', strtotime($endTime)));
} else if(strpos($startTime, ':')) {
$model = $model->whereBetweenTime($prefix, $startTime, $endTime);
} else {
$model = $model->whereBetweenTime($prefix, date('Y-m-d H:i:s', strtotime($startTime)), date('Y-m-d H:i:s', strtotime($endTime . ' +1day -1second')));
}
}
}
break;
}
return $model;
}
}

View File

@ -0,0 +1,296 @@
<?php
/**
* @copyright Copyright (c) 2021 勾股工作室
* @license https://opensource.org/licenses/Apache-2.0
* @link https://www.gougucms.com
*/
declare (strict_types = 1);
namespace app\admin\controller;
use app\admin\BaseController;
use app\admin\model\Admin as AdminList;
use app\admin\validate\AdminCheck;
use avatars\MDAvatars;
use think\exception\ValidateException;
use think\facade\Db;
use think\facade\View;
class Admin extends BaseController
{
public function index()
{
if (request()->isAjax()) {
$param = get_params();
$where = array();
if (!empty($param['keywords'])) {
$where[] = ['id|username|nickname|desc|mobile', 'like', '%' . $param['keywords'] . '%'];
}
$where[] = ['status','>=',0];
$rows = empty($param['limit']) ? get_config('app.page_size') : $param['limit'];
$admin = AdminList::where($where)
->order('id desc')
->paginate($rows, false, ['query' => $param])
->each(function ($item, $key) {
$groupId = Db::name('AdminGroupAccess')->where(['uid' => $item->id])->column('group_id');
$groupName = Db::name('AdminGroup')->where('id', 'in', $groupId)->column('title');
$item->groupName = implode(',', $groupName);
$item->last_login_time = empty($item->last_login_time) ? '-' : date('Y-m-d H:i', $item->last_login_time);
});
return table_assign(0, '', $admin);
} else {
return view();
}
}
//添加
public function add()
{
if (request()->isAjax()) {
$param = get_params();
if (!empty($param['id']) && $param['id'] > 0) {
try {
validate(AdminCheck::class)->scene('edit')->check($param);
} catch (ValidateException $e) {
// 验证失败 输出错误信息
return to_assign(1, $e->getError());
}
if (!empty($param['edit_pwd'])) {
//重置密码
if (empty($param['edit_pwd_confirm']) or $param['edit_pwd_confirm'] !== $param['edit_pwd']) {
return to_assign(1, '两次密码不一致');
}
$param['salt'] = set_salt(20);
$param['pwd'] = set_password($param['edit_pwd'], $param['salt']);
}
// 启动事务
Db::startTrans();
try {
Db::name('Admin')->where(['id' => $param['id']])->strict(false)->field(true)->update($param);
Db::name('AdminGroupAccess')->where(['uid' => $param['id']])->delete();
foreach ($param['group_id'] as $k => $v) {
//为了系统安全只有系统所有者才可创建id为1的管理员分组
if ($v == 1 and get_login_admin('id') !== 1) {
throw new ValidateException("你没有权限创建系统所有者", 1);
}
$data[$k] = [
'uid' => $param['id'],
'group_id' => $v,
];
}
Db::name('AdminGroupAccess')->strict(false)->field(true)->insertAll($data);
if (!isset($param['thumb']) || $param['thumb'] == '') {
$char = mb_substr($param['nickname'], 0, 1, 'utf-8');
Db::name('Admin')->where('id', $param['id'])->update(['thumb' => $this->to_avatars($char)]);
}
add_log('edit', $param['id'], $param);
//清除菜单\权限缓存
clear_cache('adminMenu');
clear_cache('adminRules');
// 提交事务
Db::commit();
} catch (\Exception $e) {
// 回滚事务
Db::rollback();
return to_assign(1, '提交失败:' . $e->getMessage());
}
} else {
try {
validate(AdminCheck::class)->scene('add')->check($param);
} catch (ValidateException $e) {
// 验证失败 输出错误信息
return to_assign(1, $e->getError());
}
$param['salt'] = set_salt(20);
$param['pwd'] = set_password($param['pwd'], $param['salt']);
// 启动事务
Db::startTrans();
try {
$uid = Db::name('Admin')->strict(false)->field(true)->insertGetId($param);
foreach ($param['group_id'] as $k => $v) {
//为了系统安全只有系统所有者才可创建id为1的管理员分组
if ($v == 1 and get_login_admin('id') !== 1) {
throw new ValidateException("你没有权限创建系统所有者", 1);
}
$data[$k] = [
'uid' => $uid,
'group_id' => $v,
];
}
Db::name('AdminGroupAccess')->strict(false)->field(true)->insertAll($data);
if (!isset($param['thumb']) || $param['thumb'] == '') {
$char = mb_substr($param['nickname'], 0, 1, 'utf-8');
Db::name('Admin')->where('id', $uid)->update(['thumb' => $this->to_avatars($char)]);
}
add_log('add', $uid, $param);
// 提交事务
Db::commit();
} catch (\Exception $e) {
// 回滚事务
Db::rollback();
return to_assign(1, '提交失败:' . $e->getMessage());
}
}
return to_assign();
}
else{
$id = empty(get_params('id')) ? 0 : get_params('id');
$department = set_recursion(get_department());
$position = Db::name('Position')->where('status', '>=', 0)->order('create_time asc')->select();
if ($id > 0) {
$admin = get_admin(get_params('id'));
View::assign('admin', $admin);
}
View::assign('department', $department);
View::assign('position', $position);
View::assign('id', $id);
return view();
}
}
public function to_avatars($char)
{
$defaultData = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'S', 'Y', 'Z',
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖', '拾',
'一', '二', '三', '四', '五', '六', '七', '八', '九', '十');
if (isset($char)) {
$Char = $char;
} else {
$Char = $defaultData[mt_rand(0, count($defaultData) - 1)];
}
$OutputSize = min(512, empty($_GET['size']) ? 36 : intval($_GET['size']));
$Avatar = new MDAvatars($Char, 256, 1);
$avatar_name = '/avatars/avatar_256_' . set_salt(10) . time() . '.png';
$path = get_config('filesystem.disks.public.url') . $avatar_name;
$res = $Avatar->Save('.' . $path, 256);
$Avatar->Free();
/*
if ($res) {
//写入到附件表
$data = [];
$data['filepath'] = $path;
$data['name'] = $Char;
$data['mimetype'] = 'image/png';
$data['fileext'] = 'png';
$data['filesize'] = 0;
$data['filename'] = $avatar_name;
$data['sha1'] = '';
$data['md5'] = '';
$data['module'] = \think\facade\App::initialize()->http->getName();
$data['action'] = app('request')->action();
$data['uploadip'] = app('request')->ip();
$data['create_time'] = time();
$data['user_id'] = get_login_admin('id') ? get_login_admin('id') : 0;
if ($data['module'] = 'admin') {
//通过后台上传的文件直接审核通过
$data['status'] = 1;
$data['admin_id'] = $data['user_id'];
$data['audit_time'] = time();
}
$data['use'] = 'avatar'; //附件用处
$fid = Db::name('file')->insertGetId($data);
return $fid;
}
*/
return $path;
}
//查看
public function view()
{
$id = get_params('id');
$rule = get_admin_rule();
$user_groups = Db::name('AdminGroupAccess')
->alias('a')
->join("AdminGroup g", "a.group_id=g.id", 'LEFT')
->where("a.uid='{$id}' and g.status='1'")
->select()
->toArray();
$groups = $user_groups ?: [];
$rules = [];
foreach ($groups as $g) {
$rules = array_merge($rules, explode(',', trim($g['rules'], ',')));
}
$rules = array_unique($rules);
$role_rule = create_tree_list(0, $rule, $rules);
$department = get_department();
$position = Db::name('Position')->where('status', '>=', 0)->order('create_time asc')->select();
View::assign('department', $department);
View::assign('position', $position);
View::assign('role_rule', $role_rule);
View::assign('admin', get_admin($id));
add_log('view', get_params('id'));
return view('', ['admin' => get_admin(get_params('id'))]);
}
//删除
public function delete()
{
$id = get_params("id");
if($id == 1){
return to_assign(0, "超级管理员,不能删除");
}
$data['status'] = '-1';
$data['id'] = $id;
$data['update_time'] = time();
if (Db::name('Admin')->update($data) !== false) {
add_log('delete', $id);
return to_assign(0, "删除管理员成功");
} else {
return to_assign(1, "删除失败");
}
}
//管理员操作日志
public function log()
{
if (request()->isAjax()) {
$param = get_params();
$where = array();
if (!empty($param['keywords'])) {
$where[] = ['nickname|rule_menu|param_id', 'like', '%' . $param['keywords'] . '%'];
}
if (!empty($param['title_cate'])) {
$where['title'] = $param['title_cate'];
}
if (!empty($param['rule_menu'])) {
$where['rule_menu'] = $param['rule_menu'];
}
$rows = empty($param['limit']) ? get_config('app.page_size') : $param['limit'];
$content = DB::name('AdminLog')
->field("id,uid,nickname,title,content,rule_menu,ip,param_id,param,FROM_UNIXTIME(create_time,'%Y-%m-%d %H:%i:%s') create_time")
->order('create_time desc')
->where($where)
->paginate($rows, false, ['query' => $param]);
$content->toArray();
foreach ($content as $k => $v) {
$data = $v;
$param_array = json_decode($v['param'], true);
if(is_array($param_array)){
$param_value = '';
foreach ($param_array as $key => $value) {
if (is_array($value)) {
$value = implode(',', $value);
}
$param_value .= $key . ':' . $value . '&nbsp;&nbsp;|&nbsp;&nbsp;';
}
$data['param'] = $param_value;
}
else{
$data['param'] = $param_array;
}
$content->offsetSet($k, $data);
}
return table_assign(0, '', $content);
} else {
return view();
}
}
}

View File

@ -0,0 +1,23 @@
<?php
/**
* @copyright Copyright (c) 2021 勾股工作室
* @license https://opensource.org/licenses/Apache-2.0
* @link https://www.gougucms.com
*/
declare (strict_types = 1);
namespace app\admin\controller;
use app\admin\BaseController;
use think\facade\Db;
use think\facade\View;
class Analysis extends BaseController
{
public function index()
{
return View();
}
}

View File

@ -0,0 +1,511 @@
<?php
/**
* @copyright Copyright (c) 2021 勾股工作室
* @license https://opensource.org/licenses/Apache-2.0
* @link https://blog.gougucms.com
*/
declare (strict_types = 1);
namespace app\admin\controller;
use app\admin\BaseController;
use app\admin\model\AdminLog;
use app\admin\validate\AdminCheck;
use OSS\Core\OssException;
use OSS\OssClient;
use think\exception\ValidateException;
use think\facade\Db;
use think\facade\Session;
class Api extends BaseController
{
//上传文件
public function upload()
{
$param = get_params();
//var_dump($param);exit;
$sourse = 'file';
if(isset($param['sourse'])){
$sourse = $param['sourse'];
}
if($sourse == 'file' || $sourse == 'tinymce'){
if(request()->file('file')){
$file = request()->file('file');
}
else{
return to_assign(1, '没有选择上传文件');
}
}
else{
if (request()->file('editormd-image-file')) {
$file = request()->file('editormd-image-file');
} else {
return to_assign(1, '没有选择上传文件');
}
}
// 获取上传文件的hash散列值
$sha1 = $file->hash('sha1');
$md5 = $file->hash('md5');
$rule = [
'image' => 'jpg,png,jpeg,gif',
'doc' => 'doc,docx,ppt,pptx,xls,xlsx,pdf',
'file' => 'zip,gz,7z,rar,tar',
'video' => 'mpg,mp4,mpeg,avi,wmv,mov,flv,m4v',
];
$fileExt = $rule['image'] . ',' . $rule['doc'] . ',' . $rule['file'] . ',' . $rule['video'];
//1M=1024*1024=1048576字节
$fileSize = 100 * 1024 * 1024;
if (isset($param['type']) && $param['type']) {
$fileExt = $rule[$param['type']];
}
if (isset($param['size']) && $param['size']) {
$fileSize = $param['size'];
}
$validate = \think\facade\Validate::rule([
'image' => 'require|fileSize:' . $fileSize . '|fileExt:' . $fileExt,
]);
$file_check['image'] = $file;
if (!$validate->check($file_check)) {
return to_assign(1, $validate->getError());
}
// 日期前綴
$dataPath = date('Ym');
$use = 'thumb';
$accessKeyId = "LTAI5t7mhH3ij2cNWs1zhPmv"; ;
$accessKeySecret = "gqo2wMpvi8h5bDBmCpMje6BaiXvcPu";
$endpoint = "oss-cn-chengdu.aliyuncs.com";
try {
$ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint);
} catch (OssException $e) {
return to_assign(1, $e->getMessage());
}
$bucket = "lihai001";
$object = 'storage/'.$dataPath.'/'.$md5.'.jpg';
// $filename = \think\facade\Filesystem::disk('public')->putFile($dataPath, $file, function () use ($md5) {
// return $md5;
// });
try {
$filename=$ossClient->uploadFile($bucket, $object,$file);
} catch (OssException $e) {
return to_assign(1, $e->getMessage());
}
if ($filename) {
//写入到附件表
$data = [];
$path = get_config('filesystem.disks.public.url');
$data['filepath'] = $filename['info']['url'];
$data['name'] = $file->getOriginalName();
$data['mimetype'] = $file->getOriginalMime();
$data['fileext'] = $file->extension();
$data['filesize'] = $file->getSize();
$data['filename'] = $object;
$data['sha1'] = $sha1;
$data['md5'] = $md5;
$data['module'] = \think\facade\App::initialize()->http->getName();
$data['action'] = app('request')->action();
$data['uploadip'] = app('request')->ip();
$data['create_time'] = time();
$data['user_id'] = get_login_admin('id') ? get_login_admin('id') : 0;
if ($data['module'] = 'admin') {
//通过后台上传的文件直接审核通过
$data['status'] = 1;
$data['admin_id'] = $data['user_id'];
$data['audit_time'] = time();
}
$data['use'] = request()->has('use') ? request()->param('use') : $use; //附件用处
$res['id'] = Db::name('file')->insertGetId($data);
$res['filepath'] = $data['filepath'];
$res['name'] = $data['name'];
$res['filename'] = $data['filename'];
add_log('upload', $data['user_id'], $data);
if($sourse == 'editormd'){
//editormd编辑器上传返回
return json(['success'=>1,'message'=>'上传成功','url'=>$data['filepath']]);
}
else if($sourse == 'tinymce'){
//tinymce编辑器上传返回
return json(['success'=>1,'message'=>'上传成功','location'=>$data['filepath']]);
}
else{
//普通上传返回
return to_assign(0, '上传成功', $res);
}
} else {
return to_assign(1, '上传失败,请重试');
}
}
//获取权限树所需的节点列表
public function get_rule()
{
$rule = get_admin_rule();
$group = [];
if (!empty(get_params('id'))) {
$group = get_admin_group_info(get_params('id'))['rules'];
}
$list = create_tree_list(0, $rule, $group);
return to_assign(0, '', $list);
}
//获取关键字
public function get_keyword_cate()
{
$keyword = get_keywords();
return to_assign(0, '', $keyword);
}
//获取话题
public function get_topics_cate()
{
$topic = get_topics();
return to_assign(0, '', $topic);
}
//清空缓存
public function cache_clear()
{
\think\facade\Cache::clear();
return to_assign(0, '系统缓存已清空');
}
//发送测试邮件
public function email_to($email)
{
$name = empty(get_config('webconfig.admin_title')) ? '系统' : get_config('webconfig.admin_title');
if (send_email($email, "一封来自{$name}的测试邮件。")) {
return to_assign(0, '发送成功,请注意查收');
}
return to_assign(1, '发送失败');
}
//修改个人信息
public function edit_personal()
{
return view('admin/edit_personal', [
'admin' => get_login_admin(),
]);
}
//保存个人信息修改
public function personal_submit()
{
if (request()->isAjax()) {
$param = get_params();
try {
validate(AdminCheck::class)->scene('editPersonal')->check($param);
} catch (ValidateException $e) {
// 验证失败 输出错误信息
return to_assign(1, $e->getError());
}
unset($param['username']);
$uid = get_login_admin('id');
Db::name('Admin')->where([
'id' => $uid,
])->strict(false)->field(true)->update($param);
$session_admin = get_config('app.session_admin');
Session::set($session_admin, Db::name('admin')->find($uid));
return to_assign();
}
}
//修改密码
public function edit_password()
{
return view('admin/edit_password', [
'admin' => get_login_admin(),
]);
}
//保存密码修改
public function password_submit()
{
if (request()->isAjax()) {
$param = get_params();
try {
validate(AdminCheck::class)->scene('editpwd')->check($param);
} catch (ValidateException $e) {
// 验证失败 输出错误信息
return to_assign(1, $e->getError());
}
$admin = get_login_admin();
if (set_password($param['old_pwd'], $admin['salt']) !== $admin['pwd']) {
return to_assign(1, '旧密码不正确!');
}
unset($param['username']);
$param['salt'] = set_salt(20);
$param['pwd'] = set_password($param['pwd'], $param['salt']);
Db::name('Admin')->where([
'id' => $admin['id'],
])->strict(false)->field(true)->update($param);
$session_admin = get_config('app.session_admin');
Session::set($session_admin, Db::name('admin')->find($admin['id']));
return to_assign();
}
}
// 测试邮件发送
public function email_test()
{
$sender = get_params('email');
//检查是否邮箱格式
$validate = \think\facade\Validate::rule([
'email' => 'email'
]);
$data = [
'email' => $sender
];
if (!$validate->check($data)) {
return to_assign(1, $validate->getError());
}
$email_config = \think\facade\Db::name('config')->where('name', 'email')->find();
$config = unserialize($email_config['content']);
$content = $config['template'];
//所有项目必须填写
if (empty($config['smtp']) || empty($config['smtp_port']) || empty($config['smtp_user']) || empty($config['smtp_pwd'])) {
return to_assign(1, '请完善邮件配置信息!');
}
$send = send_email($sender, '测试邮件', $content);
if ($send) {
return to_assign(0, '邮件发送成功!');
} else {
return to_assign(1, '邮件发送失败!');
}
}
//首页获取
public function get_admin_list()
{
$content = Db::name('Admin')
->where(['status' => 1])
->order('id desc')
->limit(10)
->select()->toArray();
$res['data'] = $content;
return table_assign(0, '', $res);
}
//首页获取最新10位用户
public function get_user_list()
{
$list = Db::name('User')
->where(['status' => 1])
->order('id desc')
->limit(10)
->select()->toArray();
foreach ($list as $key => $val) {
$list[$key]['last_login_time'] = date('Y-m-d H:i:s', $val['last_login_time']);
}
$res['data'] = $list;
return table_assign(0, '', $res);
}
//首页文章
public function get_article_list()
{
$list = Db::name('Article')
->field('a.id,a.title,a.read,a.status,a.create_time,c.title as cate_title')
->alias('a')
->join('article_cate c', 'a.cate_id = c.id')
->where(['a.delete_time' => 0])
->order('a.id desc')
->limit(10)
->select()->toArray();
foreach ($list as $key => $val) {
$list[$key]['create_time'] = date('Y-m-d H:i', $val['create_time']);
}
$res['data'] = $list;
return table_assign(0, '', $res);
}
//系统操作日志
public function log_list()
{
return view('admin/log_list');
}
//获取系统操作日志
public function get_log_list()
{
$param = get_params();
$log = new AdminLog();
$content = $log->get_log_list($param);
return table_assign(0, '', $content);
}
public function getbytype(){
$type = get_params("type");
$flag = get_params("flag");
$id = get_params("id");
if($flag == 'add'){
$www[] = ['pid','<>',0];
}
if($flag == 'edit'){
$www = [];
}
if($id){
$arr = Db::table('fa_category')->where('id',$id)->find();
if($arr && $arr['pid']== 0){
$www[] = ['pid','<>',0];
}
$www[] = ['id','<>',$id];
}
$where['type'] = $type;
$where['status'] = 'normal';
$list = Db::table('fa_category')->field('id,pid,type,name')->where($where)->where($www)->order('weigh asc,id asc')->select()->toArray();
// 添加无
$wu['id'] = 0;
$wu['pid'] = 0;
$wu['type'] = 0;
$wu['name'] = '无';
array_unshift ($list,$wu);
// halt($list);
return to_assign(0, '', $list);
}
public function reply(){
$data= get_params();
$this->adminInfo = get_admin($data['admin_id']);
if ($this->adminInfo['user_id']>0){
$useraddress = Db::table('fa_szxc_information_useraddress')->where('admin_id',$this->adminInfo['id'])->where('status', 1)->find();
$input=[];
if ($useraddress) {
$input['county'] = $useraddress['area_id'];
$input['township'] = $useraddress['street_id'];
$input['village'] = $useraddress['village_id'];
}
$input['user_id']=$this->adminInfo['user_id'];
$input['add_time']=date('Y-m-d H:i:s');
$input['content']=$data['reply'];
$input['vote_id']=$data['id'];
$res=Db::table('fa_article_comment')->strict(false)->field(true)->insert($input);
if ($res){
Db::table('fa_article')->where('id',$input['vote_id'])->update(['is_solve'=>1]);
return to_assign();
}else{
return to_assign(1, '操作失败');
}
}else{
return to_assign(1, '没有绑定前端用户,无法回复');
}
}
public function tongji(){
$mmm = $www = [];
$post = get_params();
//镇农产品需求量分析(事业单位、企业、居民)
$date = 'month';
$num_5 = Db::connect('shop')->table('eb_store_order')
->field('from_unixtime(unix_timestamp(create_time),\'%m-%d\') as time, count(DISTINCT order_id) as total')
->group('time')
->order('time ASC')
->whereBetween('create_time', [date('Y-m-d H:i:s', strtotime('first Day of this month 00:00:00')), date('Y-m-d H:i:s', strtotime('first Day of next month 00:00:00 -1second'))])
->select()->toarray();
$day_time = array_column($num_5,'time');
$total = array_column($num_5,'total');
//农产品市场行情分析、显示
$list['num_6'] = 6;
//农产品市内需求量
$list['num_7'] = 7;
$visitUser = $this->dateVisitUserNum($date, '');
$orderUser = $this->orderUserNum($date, null, '');
$orderPrice = $this->orderPrice($date, null, '');
$payOrderUser = $this->orderUserNum($date, 1, '');
$payOrderPrice = $this->orderPrice($date, 1, '');
// halt($payOrderUser);
// $userRate = $payOrderUser ? bcdiv($payOrderPrice, $payOrderUser, 2) : 0;
// $orderRate = $visitUser ? bcdiv($orderUser, $visitUser, 2) : 0;
// $payOrderRate = $orderUser ? bcdiv($payOrderUser, $orderUser, 2) : 0;
$result = compact('day_time','total','visitUser', 'orderUser', 'orderPrice', 'payOrderUser', 'payOrderPrice');
$result = ['data' => $result];
return table_assign(0, '', $result);
}
public function dateVisitUserNum($date, $merId = null)
{
return Db::connect('shop')->table('eb_user_visit')->alias('A')->join('eb_store_product B', 'A.type_id = B.product_id')->when($date, function ($query, $date) {
getModelTime($query, $date, 'A.create_time');
})->when($merId, function ($query, $merId) {
$query->where('B.mer_id', $merId);
})->where('A.type', 'product')->group('uid')->count();
}
public function orderUserNum($date, $paid = null, $merId = null)
{
return Db::connect('shop')->table('eb_store_order')->when($paid, function ($query, $paid) {
$query->where('paid', $paid);
})->when($merId, function ($query, $merId) {
$query->where('mer_id', $merId);
})->when($date, function ($query, $date) use ($paid) {
if (!$paid) {
getModelTime($query, $date);
// $query->where(function ($query) use ($date) {
// $query->where(function ($query) use ($date) {
// $query->where('paid', 1);
// getModelTime($query, $date, 'pay_time');
// })->whereOr(function ($query) use ($date) {
// $query->where('paid', 0);
// getModelTime($query, $date);
// });
// });
} else
getModelTime($query, $date, 'pay_time');
})->group('uid')->count();
}
public function orderPrice($date, $paid = null, $merId = null)
{
return Db::connect('shop')->table('eb_store_order')->when($paid, function ($query, $paid) {
$query->where('paid', $paid);
})->when($merId, function ($query, $merId) {
$query->where('mer_id', $merId);
})->when($date, function ($query, $date) use ($paid) {
if (!$paid) {
$query->where(function ($query) use ($date) {
$query->where(function ($query) use ($date) {
$query->where('paid', 1);
getModelTime($query, $date, 'pay_time');
})->whereOr(function ($query) use ($date) {
$query->where('paid', 0);
getModelTime($query, $date);
});
});
} else
getModelTime($query, $date, 'pay_time');
})->sum('pay_price');
}
public function streetList(){
$data= get_params();
$id = $data['id'];
$this->adminInfo = get_admin($data['admin_id']);
if ($this->adminInfo['user_id']>0){//不是超级管理员
$www['user_id'] = $this->adminInfo['user_id'];
$user_address = Db::table('fa_szxc_information_useraddress')->where($www)->find();
if($user_address['auth_range'] == 3 || $user_address['auth_range'] == 4){
$where = [];
}else{
$where['street_code'] = $user_address['street_id'];
}
$select= Db::table('fa_geo_street')->where('area_code',$id)->where($where)->field('street_id id,street_code code,street_name name')->select();
}else{
$select= Db::table('fa_geo_street')->where('area_code',$id)->field('street_id id,street_code code,street_name name')->select();
}
$select = ['data' => $select];
return table_assign(0, '', $select);
}
}

View File

@ -0,0 +1,124 @@
<?php
/**
* @copyright Copyright (c) 2021 勾股工作室
* @license https://opensource.org/licenses/Apache-2.0
* @link https://www.gougucms.com
*/
declare (strict_types = 1);
namespace app\admin\controller;
use app\admin\BaseController;
use app\admin\validate\ConfCheck;
use think\exception\ValidateException;
use think\facade\Db;
use think\facade\View;
class Conf extends BaseController
{
public function index()
{
if (request()->isAjax()) {
$param = get_params();
$where = array();
$where[] = ['status', '>=', 0];
$rows = empty($param['limit']) ? get_config('app.page_size') : $param['limit'];
$content = Db::name('Config')
->where($where)
->paginate($rows, false, ['query' => $param]);
return table_assign(0, '', $content);
} else {
return view();
}
}
//添加/编辑配置项
public function add()
{
$param = get_params();
if (request()->isAjax()) {
try {
validate(ConfCheck::class)->check($param);
} catch (ValidateException $e) {
// 验证失败 输出错误信息
return to_assign(1, $e->getError());
}
if (!empty($param['id']) && $param['id'] > 0) {
$param['update_time'] = time();
$res = Db::name('config')->strict(false)->field(true)->update($param);
if ($res) {
add_log('edit', $param['id'], $param);
}
return to_assign();
} else {
$param['create_time'] = time();
$insertId = Db::name('Config')->strict(false)->field(true)->insertGetId($param);
if ($insertId) {
add_log('add', $insertId, $param);
}
return to_assign();
}
} else {
$id = isset($param['id']) ? $param['id'] : 0;
if ($id > 0) {
$config = Db::name('Config')->where(['id' => $id])->find();
View::assign('config', $config);
}
View::assign('id', $id);
return view();
}
}
//删除配置项
public function delete()
{
$id = get_params("id");
$data['status'] = '-1';
$data['id'] = $id;
$data['update_time'] = time();
if (Db::name('Config')->update($data) !== false) {
add_log('delete', $id, $data);
return to_assign(0, "删除成功");
} else {
return to_assign(1, "删除失败");
}
}
//编辑配置信息
public function edit()
{
$param = get_params();
if (request()->isAjax()) {
$data['content'] = serialize($param);
$data['update_time'] = time();
$data['id'] = $param['id'];
$res = Db::name('Config')->strict(false)->field(true)->update($data);
$conf = Db::name('Config')->where('id', $param['id'])->find();
clear_cache('system_config' . $conf['name']);
if ($res) {
add_log('edit', $param['id'], $param);
}
return to_assign();
} else {
$id = isset($param['id']) ? $param['id'] : 0;
$conf = Db::name('Config')->where('id', $id)->find();
$module = strtolower(app('http')->getName());
$class = strtolower(app('request')->controller());
$action = strtolower(app('request')->action());
$template = $module . '/view/'. $class .'/'.$conf['name'].'.html';
$config = [];
if ($conf['content']) {
$config = unserialize($conf['content']);
}
View::assign('id', $id);
View::assign('config', $config);
if(isTemplate($template)){
return view($conf['name']);
}else{
return view('common/errortemplate',['file' =>$template]);
}
}
}
}

View File

@ -0,0 +1,250 @@
<?php
/**
* @copyright Copyright (c) 2021 勾股工作室
* @license https://opensource.org/licenses/GPL-2.0
* @link https://www.gougucms.com
*/
declare (strict_types = 1);
namespace app\admin\controller;
use app\admin\BaseController;
use think\facade\Console;
use think\exception\ValidateException;
use think\facade\Db;
use think\facade\View;
class Crud extends BaseController
{
public function index()
{
$prefix = config('database.connections.mysql.prefix');
//查询所有表信息
$table_info = Db::query('SHOW TABLE STATUS');
foreach ($table_info as $k=>&$val) {
$val['a'] = strpos($val['Comment'],'::crud');
if(strpos($val['Comment'],'::crud') == false){
unset($table_info[$k]);
continue;
}
$val['title'] = str_replace($prefix,'',$val['Name']);
$val['crud'] = $this->check($val['title']);
$val['Comment'] = str_replace('::crud','',$val['Comment']);
}
View::assign('prefix',$prefix);
View::assign('table_info',$table_info);
return view();
}
public function check($table,$type='c',$path='admin')
{
!defined('DS') && define('DS', DIRECTORY_SEPARATOR);
if($type == 'c'){
$table = ucfirst(camelize($table));
$filePath = 'app'. DS . $path . DS . 'controller' . DS . $table . '.php';
$realPath = base_path() . $path . DS . 'controller' . DS . $table . '.php';
}
if($type == 'm'){
$table = ucfirst(camelize($table));
$filePath = 'app'. DS . $path . DS . 'model' . DS . $table . '.php';
$realPath = base_path() . $path . DS . 'model' . DS . $table . '.php';
}
if($type == 'v'){
$table = ucfirst(camelize($table)) . 'Validate';
$filePath = 'app'. DS . $path . DS . 'validate' . DS . $table . '.php';
$realPath = base_path() . $path . DS . 'validate' . DS . $table . '.php';
}
if($type == 'l'){
$filePath = 'app'. DS . $path . DS . 'view' . DS . $table . DS . 'datalist.html';
$realPath = base_path() . $path . DS . 'view' . DS . $table . DS . 'datalist.html';
}
if($type == 'a'){
$filePath = 'app'. DS . $path . DS . 'view' . DS . $table . DS . 'add.html';
$realPath = base_path() . $path . DS . 'view' . DS . $table . DS . 'add.html';
}
if($type == 'e'){
$filePath = 'app'. DS . $path . DS . 'view' . DS . $table . DS . 'edit.html';
$realPath = base_path() . $path . DS . 'view' . DS . $table . DS . 'edit.html';
}
if($type == 'r'){
$filePath = 'app'. DS . $path . DS . 'view' . DS . $table . DS . 'read.html';
$realPath = base_path() . $path . DS . 'view' . DS . $table . DS . 'read.html';
}
if (file_exists($realPath)) {
return $filePath;
}
else{
return 0;
}
}
//crud
public function table()
{
$param = get_params();
$prefix = config('database.connections.mysql.prefix');
//查询指定表信息
$table_info = Db::query('SHOW TABLE STATUS LIKE ' . "'" . $param['name'] . "'");
$detail = $table_info[0];
$detail['title'] = str_replace($prefix,'',$detail['Name']);
$detail['Comment'] = str_replace('::crud','',$detail['Comment']);
$table_columns = Db::query("SHOW FULL COLUMNS FROM " . $param['name']);
//var_dump($table_info);exit;
//var_dump($table_columns);exit;
$detail['c'] = $this->check($detail['title'], $type='c');
$detail['m'] = $this->check($detail['title'], $type='m');
$detail['v'] = $this->check($detail['title'], $type='v');
$detail['l'] = $this->check($detail['title'], $type='l');
$detail['a'] = $this->check($detail['title'], $type='a');
$detail['e'] = $this->check($detail['title'], $type='e');
$detail['r'] = $this->check($detail['title'], $type='r');
View::assign('detail', $detail);
View::assign('columns', $table_columns);
return view();
}
//一键crud
public function crud()
{
$uid = get_login_admin('id');
if($uid!=1){
return to_assign(1,'只有系统超级管理员才有权限使用一键crud功能');
}
$param = get_params();
set_cache('crud_v_'.$param['field'], $param['crud_v']);
set_cache('crud_a_'.$param['field'], $param['crud_a']);
set_cache('crud_e_'.$param['field'], $param['crud_e']);
set_cache('crud_r_'.$param['field'], $param['crud_r']);
set_cache('crud_l_'.$param['field'], $param['crud_l']);
$t = '-t'.$param['field'];
$c = '-c'.$param['field'];
$m = '-m'.$param['name'];
try {
$output = Console::call('crud', [$t,$c,$m]);
//return $output->fetch();
} catch(\Exception $e) {
clear_cache('crud_v_'.$param['field']);
clear_cache('crud_a_'.$param['field']);
clear_cache('crud_e_'.$param['field']);
clear_cache('crud_r_'.$param['field']);
clear_cache('crud_l_'.$param['field']);
return to_assign(1, $e->getMessage());
}
}
//一键生成菜单
public function menu($field='',$name='')
{
$uid = get_login_admin('id');
if($uid!=1){
return to_assign(1,'只有系统超级管理员才有权限使用一键生成菜单功能!');
}
if(empty($field) || empty($name)){
return to_assign(1,'参数错误!');
}
$rule = [
[
'title' => $name.'管理',
'name' => $name,
'src' => '',
'module' => '',
'crud' => $field,
'menu' => '1',
'icon' => 'bi-folder',
'son' => [
[
'title' => $name.'列表',
'name' => $name.'列表',
'src' => 'admin/'.$field.'/datalist',
'module' => '',
'crud' => $field,
'menu' => '1',
'icon' => '',
'son' => [
[
'title' => '新建',
'name' => $name,
'src' => 'admin/'.$field.'/add',
'module' => '',
'crud' => $field,
'menu' => '2',
'icon' => '',
'son' => []
],
[
'title' => '编辑',
'name' => $name,
'src' => 'admin/'.$field.'/edit',
'module' => '',
'crud' => $field,
'menu' => '2',
'icon' => '',
'son' => []
],
[
'title' => '查看',
'name' => $name,
'src' => 'admin/'.$field.'/read',
'module' => '',
'crud' => $field,
'menu' => '2',
'icon' => '',
'son' => []
],
[
'title' => '删除',
'name' => $name,
'src' => 'admin/'.$field.'/del',
'module' => '',
'crud' => $field,
'menu' => '2',
'icon' => '',
'son' => []
]
]
]
]
]
];
//如果安装过该模块,删除原来的菜单信息
Db::name('AdminRule')->where('crud',$field)->delete();
$sort = Db::name('AdminRule')->where('pid',0)->max('sort');
$this->add_rule($rule,0,$sort+1);
//更新超级管理员的权限节点
$rules = Db::name('AdminRule')->column('id');
$admin_rules = implode(',',$rules);
$res = Db::name('AdminGroup')->strict(false)->where('id',1)->update(['rules'=>$admin_rules,'update_time'=>time()]);
if($res!==false){
// 删除后台节点缓存
clear_cache('adminRules');
return to_assign();
}
else{
return to_assign(1,'操作失败');
}
}
//递归插入菜单数据
protected function add_rule($data, $pid=0,$sort=0)
{
foreach($data as $k => $v)
{
$rule=[
'title' => $v['title'],
'name' => $v['name'],
'src' => $v['src'],
'module' => $v['module'],
'menu' => $v['menu'],
'icon' => $v['icon'],
'crud' => $v['crud'],
'pid' => $pid,
'sort' => $sort,
'create_time' => time()
];
$new_id = Db::name('AdminRule')->strict(false)->field(true)->insertGetId($rule);
if(!empty($v['son'] && $new_id)){
$this->add_rule($v['son'],$new_id);
}
}
}
}

View File

@ -0,0 +1,221 @@
<?php
/**
* @copyright Copyright (c) 2021 勾股工作室
* @license https://opensource.org/licenses/Apache-2.0
* @link https://www.gougucms.com
*/
declare (strict_types = 1);
namespace app\admin\controller;
use app\admin\BaseController;
use backup\Backup;
use think\facade\Session;
use think\facade\Db;
use think\facade\View;
class Database extends BaseController
{
//数据表列表
public function database()
{
if (request()->isAjax()) {
// 数据信息
$db = new Backup();
$list = $db->dataList();
// 计算总大小
$total = 0;
foreach ($list as $k => $v) {
$total += $v['data_length'];
$list[$k]['data_size'] = $v['data_length'];
$list[$k]['data_length'] = format_bytes($v['data_length']);
}
// 提示信息
$dataTips = '数据库中共有<strong> ' . count($list) . '</strong> 张表,共计 <strong>' . format_bytes($total) . '</strong>大小。';
$data['data'] = $list;
return table_assign(0, $dataTips, $data);
}
return view();
}
//备份数据
public function backup()
{
$db= new Backup();
if(request()->isPost()){
$tables=get_params('tables');
$fileinfo =$db->getFile();
//检查是否有正在执行的任务
$lock = "{$fileinfo['filepath']}backup.lock";
if(is_file($lock)){
return to_assign(2, '检测到有一个备份任务未完成');
} else {
//创建锁文件
file_put_contents($lock,time());
}
// 检查备份目录是否可写
if(!is_writeable($fileinfo['filepath'])){
return to_assign(1, '备份目录不存在或不可写,请检查后重试!');
}
//缓存锁文件
Session::set('lock', $lock);
//缓存备份文件信息
Session::set('backup_file', $fileinfo['file']);
//缓存要备份的表
Session::set('backup_tables', $tables);
//创建备份文件
if(false !== $db->Backup_Init()){
return to_assign(0, '初始化成功,开始备份...',['tab'=>['id' => 0, 'start' => 0,'table'=>$tables[0]]]);
}else{
return to_assign(1, '初始化失败,备份文件创建失败');
}
}else if(request()->isGet()){
$tables = Session::get('backup_tables');
$file=Session::get('backup_file');
$id=get_params('id');
$start=get_params('start');
$start= $db->setFile($file)->backup($tables[$id], $start);
if(false === $start){
return to_assign(1, '备份出错');
}else if(0 === $start){
if(isset($tables[++$id])){
return to_assign(0, '备份完成',['tab'=>['id' => $id, 'start' => 0,'table'=>$tables[$id-1]]]);
} else { //备份完成,清空缓存
unlink(Session::get('lock'));
Session::delete('backup_tables');
Session::delete('backup_file');
add_log('bak');
return to_assign(0, '备份完成',['tab'=>['start' => 'ok','table'=>$tables[$id-1]]]);
}
}
}else{
return to_assign(1, '参数错误!');
}
}
//优化表
public function optimize($tables= null)
{
$db= new Backup();
//return to_assign(0, $db->optimize($tables));
if($db->optimize($tables)){
add_log('optimize');
return to_assign(0, '数据表优化完成');
}else{
return to_assign(1, '数据表优化出错请重试');
}
}
//修复表
public function repair($tables= null)
{
$db= new Backup();
//return to_assign(0, $db->repair($tables));
if($db->repair($tables)){
add_log('repair');
return to_assign(0, '数据表修复完成');
}else{
return to_assign(1, '数据表修复出错请重试');
}
}
//备份文件列表
public function backuplist()
{
$db= new Backup();
$list = $db->fileList();
$fileinfo =$db->getFile();
$lock = "{$fileinfo['filepath']}backup.lock";
$lock_time = 0;
if(is_file($lock)){
$lock_time = file_get_contents($lock);
}
$listNew = [];
$indx = 0;
foreach ($list as $k => $v) {
$listNew[$indx]['time'] = $k;
$listNew[$indx]['timespan'] = $v['time'];
$listNew[$indx]['data'] = $v;
$indx++;
}
$list = $listNew;
array_multisort(array_column($list, 'time'), SORT_DESC, $list);
return view('',['list'=>$list,'lock_time' => $lock_time]);
}
//数据还原
public function import($time = 0, $part = null, $start = null)
{
$db= new Backup();
$time =(int)$time;
if(is_numeric($time) && is_null($part) && is_null($start)){
$list = $db->getFile('timeverif',$time);
if(is_array($list)){
Session::set('backup_list', $list);
return to_assign(0, '初始化完成,开始还原...',array('part' => 1, 'start' => 0,'time' => $time));
}else{
return to_assign(1, '备份文件可能已经损坏,请检查');
}
}else if(is_numeric($part) && is_numeric($start)){
$list=Session::get('backup_list');
$part =(int)$part;
$start =(int)$start;
$start= $db->setFile($list)->import($start,$time,$part);
if(false===$start){
return to_assign(1, '还原数据出错,请重试');
}elseif(0 === $start){
if(isset($list[++$part])){
$data = array('part' => $part, 'start' => 0,'time' => $time);
return to_assign(0, "正在还原...卷{$part},请勿关闭当前页面",$data);
} else {
Session::delete('backup_list');
return to_assign(0, '还原数据成功');
}
}else{
$data = array('part' => $part, 'start' => $start[0],'time' => $time);
if($start[1]){
$rate = floor(100 * ($start[0] / $start[1]));
return to_assign(0, "正在还原...卷{$part} ({$rate}%),请勿关闭当前页面",$data);
} else {
$data['gz'] = 1;
return to_assign(0, "正在还原...卷{$part},请勿关闭当前页面",$data);
}
return to_assign(0, "正在还原...卷{$part},请勿关闭当前页面");
}
}else{
return to_assign(1, "参数错误");
}
}
/**
* 删除备份文件
*/
public function del($time = 0,$lock=0){
$db= new Backup();
if($lock==1){
$fileinfo =$db->getFile();
$lock = "{$fileinfo['filepath']}backup.lock";
if(is_file($lock)){
$time = file_get_contents($lock);
unlink($lock);
}
}
if($db->delFile((int)$time)){
add_log('delete');
return to_assign(0, '删除成功');
}else{
return to_assign(0, '删除失败,请检查权限');
}
}
/**
* 下载备份文件
*/
public function downfile($time = 0,$part=0){
$db= new Backup();
add_log('down');
$db->downloadFile((int)$time,$part-1);
}
}

View File

@ -0,0 +1,103 @@
<?php
/**
* @copyright Copyright (c) 2021 勾股工作室
* @license https://opensource.org/licenses/GPL-3.0
* @link https://www.gougucms.com
*/
declare (strict_types = 1);
namespace app\admin\controller;
use app\admin\BaseController;
use app\admin\validate\DepartmentCheck;
use think\exception\ValidateException;
use think\facade\Db;
use think\facade\View;
class Department extends BaseController
{
public function index()
{
if (request()->isAjax()) {
$list = Db::name('Department')
->field('d.*,a.nickname as leader')
->alias('d')
->join('Admin a', 'a.id = d.leader_id', 'LEFT')
->order('d.id asc')
->select();
return to_assign(0, '', $list);
} else {
return view();
}
}
//添加部门
public function add()
{
$param = get_params();
if (request()->isAjax()) {
if ($param['id'] > 0) {
try {
validate(DepartmentCheck::class)->scene('edit')->check($param);
} catch (ValidateException $e) {
// 验证失败 输出错误信息
return to_assign(1, $e->getError());
}
$param['update_time'] = time();
$department_array = get_department_son($param['id']);
if (in_array($param['pid'], $department_array)) {
return to_assign(1, '上级部门不能是该部门本身或其下属部门');
} else {
Db::name('Department')->strict(false)->field(true)->update($param);
add_log('edit', $param['id'], $param);
return to_assign();
}
} else {
try {
validate(DepartmentCheck::class)->scene('add')->check($param);
} catch (ValidateException $e) {
// 验证失败 输出错误信息
return to_assign(1, $e->getError());
}
$did = Db::name('Department')->strict(false)->field(true)->insertGetId($param);
add_log('add', $did, $param);
return to_assign();
}
} else {
$id = isset($param['id']) ? $param['id'] : 0;
$pid = isset($param['pid']) ? $param['pid'] : 0;
$department = set_recursion(get_department());
if ($id > 0) {
$detail = Db::name('Department')->where(['id' => $id])->find();
$users = Db::name('Admin')->where(['did' => $id, 'status' => 1])->select();
View::assign('users', $users);
View::assign('detail', $detail);
}
View::assign('department', $department);
View::assign('pid', $pid);
View::assign('id', $id);
return view();
}
}
//删除
public function delete()
{
$id = get_params("id");
$count = Db::name('Department')->where([['pid', '=', $id], ['status', '>=', 0]])->count();
if ($count > 0) {
return to_assign(1, "该部门下还有子部门,无法删除");
}
$users = Db::name('Admin')->where([['did', '=', $id], ['status', '>=', 0]])->count();
if ($users > 0) {
return to_assign(1, "该部门下还有员工,无法删除");
}
if (Db::name('Department')->delete($id) !== false) {
add_log('delete', $id);
return to_assign(0, "删除部门成功");
} else {
return to_assign(1, "删除失败");
}
}
}

View File

@ -0,0 +1,208 @@
<?php
/**
* @copyright Copyright (c) 2021 勾股工作室
* @license https://opensource.org/licenses/Apache-2.0
* @link https://www.gougucms.com
*/
declare (strict_types = 1);
namespace app\admin\controller;
use app\admin\BaseController;
use think\facade\Db;
use think\facade\View;
class Index extends BaseController
{
public function __construct()
{
$this->adminInfo = get_login_admin();
}
public function index()
{
$admin = get_login_admin();
if (get_cache('menu' . $admin['id'])) {
$list = get_cache('menu' . $admin['id']);
} else {
$adminGroup = Db::name('AdminGroupAccess')->where(['uid' => get_login_admin('id')])->column('group_id');
$adminMenu = Db::name('AdminGroup')->where('id', 'in', $adminGroup)->column('rules');
$adminMenus = [];
foreach ($adminMenu as $k => $v) {
$v = explode(',', $v);
$adminMenus = array_merge($adminMenus, $v);
}
$menu = Db::name('AdminRule')->where(['menu' => 1,'status'=>1])->where('id', 'in', $adminMenus)->order('sort asc')->select()->toArray();
$list = list_to_tree($menu);
\think\facade\Cache::tag('adminMenu')->set('menu' . $admin['id'], $list);
}
$theme = Db::name('Admin')->where('id',$admin['id'])->value('theme');
View::assign('theme',$theme);
View::assign('menu', $list);
return View();
}
public function main()
{
if ($this->adminInfo['group_access']==4){
$street_id=Db::table('fa_szxc_information_useraddress')->where('admin_id',$this->adminInfo['id'])->value('street_id');
return <<<EOT
<div id="your-element-selector" style="height: 100%">
<a href="http://localhost:8082?street_id=$street_id" target="_blank" style="font-size: 100px;
color: aliceblue;
display: block;
text-align: center;
text-decoration:none;
top: 40%;">跳转大屏</a>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r134/three.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vanta@0.5.24/dist/vanta.waves.min.js"></script>
<script>
VANTA.WAVES({
el: "#your-element-selector",
mouseControls: true,
touchControls: true,
gyroControls: false,
scale: 1.00,
scaleMobile: 1.00
})
</script>
EOT;
}
if ($this->adminInfo['id']!=1){
$find = Db::table('fa_szxc_information_useraddress')->where('user_id', $this->adminInfo['user_id'])->find();
if ($find) {
if ($find['auth_range']==1){
$where[] = ['village_id', '=', $find['village_id']];
}elseif ($find['auth_range']==2){
$where[] = ['street_id', '=', $find['street_id']];
}elseif ($find['auth_range']==3){
$where[] = ['area_id', '=', $find['area_id']];
}elseif ($find['auth_range']==5){
$where[] = ['brigade_id', '=', $find['brigade_id']];
}
}
}else{
$where=[];
}
$num =Db::table('fa_szxc_information_usermsg')->where($where)->count();
// 大于60岁人数
$old_num = Db::table('fa_szxc_information_usermsg')->where($where)->whereAge('>=', 60)->count();
// 儿童人数
$children_num = Db::table('fa_szxc_information_usermsg')->where($where)->whereAge('<', 15)->count();
// 未婚男
$unmarried_man_num = Db::table('fa_szxc_information_usermsg')->where($where)->where([['gender', '=', 1], ['marital_status', '=', 169]])->count();
// 未婚女
$unmarried_woman_num = Db::table('fa_szxc_information_usermsg')->where($where)->where([['gender', '=', 2], ['marital_status', '=', 169]])->count();
// 少数民族
$nation_s_num = Db::table('fa_szxc_information_usermsg')->where($where)->whereBetween('nation', [13, 68])->count();
// 汉族
$nation_h_num = Db::table('fa_szxc_information_usermsg')->where($where)->where('nation', 12)->count();
// foreach ($where as $key =>$value){
// $where[$key][0] = 'm.'.$value[0];
// }
// 残疾人数
$whether_disabled_num = Db::table('fa_szxc_information_usermsg')
->alias('m')
->where($where)
->join(['fa_szxc_information_insurance'=>'i'],'m.user_id=i.user_id and i.whether_disabled!=112')->count();
// 参保人数
$insurance_type_num = Db::table('fa_szxc_information_usermsg')
->alias('m')
->where($where)
->join(['fa_szxc_information_insurance'=>'i'],'m.user_id=i.user_id and i.insurance_type!=219')->count();
if ($this->adminInfo['id']!=1){
// 工作人员数
$work_num = Db::table('fa_szxc_information_usermsg')
->alias('m')
->where($where)
->join(['fa_user'=>'u'],'m.user_id=u.id and u.group_id = 3')->count();
}else{
$work_num = Db::table('fa_user')
->alias('u')
->where($where)
->where('u.group_id',3)
->join(['fa_szxc_information_usermsg'=>'m'],'u.id = m.user_id')->count();
}
//土地
$land_area_num = Db::table('fa_szxc_information_useraddress')
->alias('u')
->where($where)
->join(['fa_szxc_information_planting'=>'p'], 'u.user_id = p.user_id')->sum('p.land_area');
$sum_218 = Db::table('fa_szxc_information_useraddress')
->alias('u')
->where($where)
->join(['fa_szxc_information_planting'=>'p'], 'u.user_id = p.user_id and p.nature_of_land=218')->sum('p.land_area');
$sum_217 = Db::table('fa_szxc_information_useraddress')
->alias('u')
->where($where)
->join(['fa_szxc_information_planting'=>'p'], 'u.user_id = p.user_id and p.nature_of_land=217')->sum('p.land_area');
$sum_216 = Db::table('fa_szxc_information_useraddress')
->alias('u')
->where($where)
->join(['fa_szxc_information_planting'=>'p'], 'u.user_id = p.user_id')->sum('p.breed_area');
$sum_215 = Db::table('fa_szxc_information_useraddress')
->alias('u')
->where($where)
->join(['fa_szxc_information_planting'=>'p'], 'u.user_id = p.user_id and p.nature_of_land=215')->sum('p.land_area');
$sum_214 = Db::table('fa_szxc_information_useraddress')
->alias('u')
->where($where)
->join(['fa_szxc_information_planting'=>'p'], 'u.user_id = p.user_id and p.nature_of_land=214')->sum('p.land_area');
$sum_70 = Db::table('fa_szxc_information_useraddress')
->alias('u')
->where($where)
->join(['fa_szxc_information_planting'=>'p'], 'u.user_id = p.user_id and p.nature_of_land=70')->sum('p.land_area');
$sum_69 = Db::table('fa_szxc_information_useraddress')
->alias('u')
->where($where)
->join(['fa_szxc_information_planting'=>'p'], 'u.user_id = p.user_id and p.nature_of_land=69')->sum('p.land_area');
// 荒地面积
$waste_land_area = Db::table('fa_szxc_information_useraddress')
->alias('u')
->where($where)
->join(['fa_szxc_information_planting'=>'p'], 'u.user_id = p.user_id')->sum('p.waste_land_area');
View::assign(
[
'totaluser' => $num,//User::where($whe)->count(),// 总用户数
'old_num' => $old_num,
'children_num' => $children_num,
'unmarried_man_num' => $unmarried_man_num,
'unmarried_woman_num' => $unmarried_woman_num,
'whether_disabled_num' => $whether_disabled_num,
'insurance_type_num' => $insurance_type_num,
'nation_s_num' => $nation_s_num,
'nation_h_num' => $nation_h_num,
'work_num' => $work_num,
'land_area_num' => $land_area_num,
'waste_land_area' => $waste_land_area,
'sum_218' => $sum_218,
'sum_217' => $sum_217,
'sum_216' => $sum_216,
'sum_215' => $sum_215,
'sum_214' => $sum_214,
'sum_70' => $sum_70,
'sum_69' => $sum_69,
]
);
return View();
}
//设置theme
public function set_theme()
{
if (request()->isAjax()) {
$param = get_params();
$admin = get_login_admin();
Db::name('Admin')->where('id',$admin['id'])->update(['theme'=>$param['theme']]);
return to_assign();
}
else{
return to_assign(1,'操作错误');
}
}
}

View File

@ -0,0 +1,88 @@
<?php
/**
* @copyright Copyright (c) 2021 勾股工作室
* @license https://opensource.org/licenses/GPL-2.0
* @link https://www.gougucms.com
*/
declare (strict_types = 1);
namespace app\admin\controller;
use app\admin\BaseController;
use app\admin\validate\LevelCheck;
use think\exception\ValidateException;
use think\facade\Db;
use think\facade\View;
class Level extends BaseController
{
public function index()
{
if (request()->isAjax()) {
$level = Db::name('UserLevel')->select();
return to_assign(0, '', $level);
} else {
return view();
}
}
//添加新增/编辑
public function add()
{
$param = get_params();
if (request()->isAjax()) {
$param['title'] = preg_replace('# #','',$param['title']);
if ($param['id'] > 0) {
try {
validate(LevelCheck::class)->scene('edit')->check($param);
} catch (ValidateException $e) {
// 验证失败 输出错误信息
return to_assign(1, $e->getError());
}
$param['update_time'] = time();
Db::name('UserLevel')->strict(false)->field(true)->update($param);
add_log('edit', $param['id'], $param);
} else {
try {
validate(LevelCheck::class)->scene('add')->check($param);
} catch (ValidateException $e) {
// 验证失败 输出错误信息
return to_assign(1, $e->getError());
}
$param['create_time'] = time();
$mid = Db::name('UserLevel')->strict(false)->field(true)->insertGetId($param);
add_log('add', $mid, $param);
}
return to_assign();
} else {
$id = isset($param['id']) ? $param['id'] : 0;
if($id>0){
$detail = Db::name('UserLevel')->where('id',$id)->find();
View::assign('detail', $detail);
}
View::assign('id', $id);
return view();
}
}
//禁用/启用
public function disable()
{
$param = get_params();
$param['update_time']= time();
$res = Db::name('UserLevel')->strict(false)->field('status,update_time')->update($param);
if($res!==false){
if($param['status'] == 0){
add_log('disable', $param['id'], $param);
}
else if($param['status'] == 1){
add_log('recovery', $param['id'], $param);
}
return to_assign();
}
else{
return to_assign(1,'操作失败');
}
}
}

View File

@ -0,0 +1,62 @@
<?php
/**
* @copyright Copyright (c) 2021 勾股工作室
* @license https://opensource.org/licenses/Apache-2.0
* @link https://www.gougucms.com
*/
declare (strict_types = 1);
namespace app\admin\controller;
use app\admin\BaseController;
use think\facade\Db;
use think\facade\View;
class Log extends BaseController
{
//管理员操作日志
public function index()
{
if (request()->isAjax()) {
$param = get_params();
$where = array();
if (!empty($param['keywords'])) {
$where[] = ['nickname|content|param_id', 'like', '%' . $param['keywords'] . '%'];
}
if (!empty($param['action'])) {
$where['action'] = $param['action'];
}
$rows = empty($param['limit']) ? get_config('app.page_size') : $param['limit'];
$content = DB::name('AdminLog')
->field("id,uid,nickname,action,title,content,rule_menu,ip,param_id,param,FROM_UNIXTIME(create_time,'%Y-%m-%d %H:%i:%s') create_time")
->order('create_time desc')
->where($where)
->paginate($rows, false, ['query' => $param]);
$content->toArray();
foreach ($content as $k => $v) {
$data = $v;
$param_array = json_decode($v['param'], true);
if(is_array($param_array)){
$param_value = '';
foreach ($param_array as $key => $value) {
if (is_array($value)) {
$value = implode(',', $value);
}
$param_value .= $key . ':' . $value . '&nbsp;&nbsp;|&nbsp;&nbsp;';
}
$data['param'] = $param_value;
}
else{
$data['param'] = $param_array;
}
$content->offsetSet($k, $data);
}
return table_assign(0, '', $content);
} else {
$type_action = get_config('log.admin_action');
View::assign('type_action', $type_action);
return view();
}
}
}

View File

@ -0,0 +1,72 @@
<?php
/**
* @copyright Copyright (c) 2021 勾股工作室
* @license https://opensource.org/licenses/Apache-2.0
* @link https://www.gougucms.com
*/
declare (strict_types = 1);
namespace app\admin\controller;
use app\admin\validate\UserCheck;
use think\exception\ValidateException;
use think\facade\Db;
use think\facade\Session;
class Login
{
//登录
public function index()
{
return View();
}
//提交登录
public function login_submit()
{
$param = get_params();
try {
validate(UserCheck::class)->check($param);
} catch (ValidateException $e) {
// 验证失败 输出错误信息
return to_assign(1, $e->getError());
}
$admin = Db::name('Admin')->where(['username' => $param['username']])->find();
if (empty($admin)) {
return to_assign(1, '用户名或密码错误');
}
$param['pwd'] = set_password($param['password'], $admin['salt']);
if ($admin['pwd'] !== $param['pwd']) {
return to_assign(1, '用户名或密码错误');
}
if ($admin['status'] == 0) {
return to_assign(1, '该用户禁止登录,请于系统所有者联系');
}
$data = [
'last_login_time' => time(),
'last_login_ip' => request()->ip(),
'login_num' => $admin['login_num'] + 1,
];
Db::name('admin')->where(['id' => $admin['id']])->update($data);
$group_access=Db::name('admin_group_access')->where(['uid' => $admin['id']])->find();
$admin['group_access']=$group_access['group_id'];
$session_admin = get_config('app.session_admin');
Session::set($session_admin, $admin);
$token = make_token();
set_cache($token, $admin, 7200);
$admin['token'] = $token;
add_log('login', $admin['id'], $data);
return to_assign(0, '登录成功', ['uid' => $admin['id']]);
}
//退出登录
public function login_out()
{
$session_admin = get_config('app.session_admin');
Session::delete($session_admin);
//redirect('/')->send();
return to_assign(0, "退出成功");
}
}

View File

@ -0,0 +1,97 @@
<?php
/**
* @copyright Copyright (c) 2021 勾股工作室
* @license https://opensource.org/licenses/GPL-2.0
* @link https://www.gougucms.com
*/
declare (strict_types = 1);
namespace app\admin\controller;
use app\admin\BaseController;
use app\admin\validate\ModuleCheck;
use think\exception\ValidateException;
use think\facade\Db;
use think\facade\View;
class Module extends BaseController
{
public function index()
{
if (request()->isAjax()) {
$module = Db::name('AdminModule')->select();
return to_assign(0, '', $module);
} else {
return view();
}
}
//添加新增/编辑
public function add()
{
$param = get_params();
if (request()->isAjax()) {
$param['name'] = preg_replace('# #', '', $param['name']);
if ($param['id'] > 0) {
$module = Db::name('AdminModule')->where('id', $param['id'])->find();
if ($module['type'] == 1) {
return to_assign(1, '系统默认模块不能编辑');
}
try {
validate(ModuleCheck::class)->scene('edit')->check($param);
} catch (ValidateException $e) {
// 验证失败 输出错误信息
return to_assign(1, $e->getError());
}
$param['update_time'] = time();
Db::name('AdminModule')->strict(false)->field(true)->update($param);
add_log('edit', $param['id'], $param);
} else {
try {
validate(ModuleCheck::class)->scene('add')->check($param);
} catch (ValidateException $e) {
// 验证失败 输出错误信息
return to_assign(1, $e->getError());
}
$param['create_time'] = time();
$mid = Db::name('AdminModule')->strict(false)->field(true)->insertGetId($param);
add_log('add', $mid, $param);
}
return to_assign();
} else {
$id = isset($param['id']) ? $param['id'] : 0;
if ($id > 0) {
$detail = Db::name('AdminModule')->where('id', $id)->find();
View::assign('detail', $detail);
}
View::assign('id', $id);
return view();
}
}
//禁用/启用
public function disable()
{
$param = get_params();
$module = Db::name('AdminModule')->where('id', $param['id'])->find();
if ($module['type'] == 1) {
return to_assign(1, '系统模块不能禁用');
}
$param['update_time'] = time();
$res = Db::name('AdminModule')->strict(false)->field('status,update_time')->update($param);
if ($res !== false) {
Db::name('AdminRule')->strict(false)->where('module', $module['name'])->field('status')->update(['status' => $param['status']]);
// 删除后台节点缓存
clear_cache('adminRules');
if ($param['status'] == 0) {
add_log('disable', $param['id'], $param);
} else if ($param['status'] == 1) {
add_log('recovery', $param['id'], $param);
}
return to_assign();
} else {
return to_assign(1, '操作失败');
}
}
}

View File

@ -0,0 +1,196 @@
<?php
/**
* @copyright Copyright (c) 2021 勾股工作室
* @license https://opensource.org/licenses/Apache-2.0
* @link https://www.gougucms.com
*/
declare (strict_types = 1);
namespace app\admin\controller;
use app\admin\BaseController;
use app\admin\model\Notice as NoticeModel;
use app\admin\validate\NoticeValidate;
use think\exception\ValidateException;
use think\facade\Db;
use think\facade\View;
class Notice extends BaseController
{
/**
* 构造函数
*/
public function __construct()
{
$this->model = new NoticeModel();
$this->uid = get_login_admin('id');
$this->adminInfo = get_login_admin();
if($this->adminInfo['position_id'] != 1){ //不是超级管理员
$www['admin_id'] = $this->adminInfo['id'];
$user_address = Db::table('fa_szxc_information_useraddress')->where($www)->find();
if ($user_address){
if($user_address['auth_range'] == 1){
$where[] = ['village_id','=',$user_address['village_id']];
}elseif ($user_address['auth_range'] == 2){
$where[] = ['street_id','=',$user_address['street_id']];
}elseif ($user_address['auth_range'] == 3){
$where[] = ['area_id','=',$user_address['area_id']];
}else{
$where[] = ['village_id','=',$user_address['village_id']];
}
}else{
$where[] = ['village_id','=',''];
}
}else{
$where = [];
}
// 获取用户信息
$this->users = Db::table('fa_szxc_information_usermsg')->where('status',1)->where($where)->field('user_id,name')->select();
}
/**
* 数据列表
*/
public function datalist()
{
if (request()->isAjax()) {
$param = get_params();
$where = [];
if (isset($param['keywords'])){
$where[]=['title','like','%'.$param['keywords'].'%'];
}
if($this->adminInfo['position_id'] != 1){ //不是超级管理员
$www['admin_id'] = $this->adminInfo['id'];
$user_address = Db::table('fa_szxc_information_useraddress')->where($www)->find();
if ($user_address){
if($user_address['auth_range'] == 1){
$where[] = ['village_id','=',$user_address['village_id']];
}elseif ($user_address['auth_range'] == 2){
$where[] = ['street_id','=',$user_address['street_id']];
}elseif ($user_address['auth_range'] == 3){
$where[] = ['area_id','=',$user_address['area_id']];
}else{
$where[] = ['village_id','=',$user_address['village_id']];
}
}else{
$where[] = ['village_id','=',''];
}
}
$list = $this->model->getNoticeList($where,$param);
foreach ($list as $k =>$v){
$list[$k]['user_name'] = Db::table('fa_szxc_information_usermsg')->where('user_id',$v['user_id'])->value('name');
if($v['status'] == 1){
$list[$k]['status'] = '正常';
}else{
$list[$k]['status'] = '禁用';
}
if($v['is_read'] == 1){
$list[$k]['is_read'] = '已读';
}else{
$list[$k]['is_read'] = '未读';
}
if($v['read_time']){
$list[$k]['read_time'] = date('Y-m-d H:i:s',$v['read_time']);
}
}
return table_assign(0, '', $list);
}
else{
return view();
}
}
/**
* 添加
*/
public function add()
{
if (request()->isAjax()) {
$param = get_params();
// 检验完整性
try {
validate(NoticeValidate::class)->check($param);
} catch (ValidateException $e) {
// 验证失败 输出错误信息
return to_assign(1, $e->getError());
}
if($this->adminInfo['position_id'] != 1) { //不是超级管理员
$adds=Db::table('fa_szxc_information_useraddress')->where('admin_id',$this->adminInfo['id'])->find();
$param['area_id']=$adds['area_id'];
$param['street_id']=$adds['street_id'];
$param['village_id']=$adds['village_id'];
}
$this->model->addNotice($param);
}else{
View::assign('users', $this->users);
return view();
}
}
/**
* 编辑
*/
public function edit()
{
$param = get_params();
if (request()->isAjax()) {
// 检验完整性
try {
validate(NoticeValidate::class)->check($param);
} catch (ValidateException $e) {
// 验证失败 输出错误信息
return to_assign(1, $e->getError());
}
$this->model->editNotice($param);
}else{
$id = isset($param['id']) ? $param['id'] : 0;
$detail = $this->model->getNoticeById($id);
if (!empty($detail)) {
View::assign('detail', $detail);
View::assign('users', $this->users);
return view();
}
else{
throw new \think\exception\HttpException(404, '找不到页面');
}
}
}
/**
* 查看信息
*/
public function read()
{
$param = get_params();
$id = isset($param['id']) ? $param['id'] : 0;
$detail = $this->model->getNoticeById($id);
if (!empty($detail)) {
View::assign('detail', $detail);
View::assign('users', $this->users);
return view();
}
else{
throw new \think\exception\HttpException(404, '找不到页面');
}
}
/**
* 删除
* type=0,逻辑删除,默认
* type=1,物理删除
*/
public function del()
{
$param = get_params();
$id = isset($param['id']) ? $param['id'] : 0;
$this->model->delNoticeById($id,1);
}
}

View File

@ -0,0 +1,97 @@
<?php
/**
* @copyright Copyright (c) 2021 勾股工作室
* @license https://opensource.org/licenses/GPL-3.0
* @link https://www.gougucms.com
*/
declare (strict_types = 1);
namespace app\admin\controller;
use app\admin\BaseController;
use app\admin\validate\PositionCheck;
use think\exception\ValidateException;
use think\facade\Db;
use think\facade\View;
class Position extends BaseController
{
public function index()
{
if (request()->isAjax()) {
$list = Db::name('Position')->where('status', '>=', 0)->order('create_time asc')->select()->toArray();
$res['data'] = $list;
return table_assign(0, '', $res);
} else {
return view();
}
}
//添加&编辑
public function add()
{
$param = get_params();
if (request()->isAjax()) {
if (!empty($param['id']) && $param['id'] > 0) {
try {
validate(PositionCheck::class)->scene('edit')->check($param);
} catch (ValidateException $e) {
// 验证失败 输出错误信息
return to_assign(1, $e->getError());
}
$res = Db::name('Position')->where(['id' => $param['id']])->strict(false)->field(true)->update($param);
if($res!==false){
add_log('edit', $param['id'], $param);
return to_assign();
}
else{
return to_assign(1, '提交失败');
}
} else {
try {
validate(PositionCheck::class)->scene('add')->check($param);
} catch (ValidateException $e) {
// 验证失败 输出错误信息
return to_assign(1, $e->getError());
}
$pid = Db::name('Position')->strict(false)->field(true)->insertGetId($param);
if($pid>0){
add_log('add', $pid, $param);
return to_assign();
}
else{
return to_assign(1, '提交失败');
}
}
}
else{
$id = isset($param['id']) ? $param['id'] : 0;
if ($id > 0) {
$detail = Db::name('Position')->where(['id' => $id])->find();
View::assign('detail', $detail);
}
View::assign('id', $id);
return view();
}
}
//删除
public function delete()
{
$id = get_params("id");
if ($id == 1) {
return to_assign(0, "超级岗位,不能删除");
}
$data['status'] = '-1';
$data['id'] = $id;
$data['update_time'] = time();
if (Db::name('Position')->update($data) !== false) {
add_log('delete', $id);
return to_assign(0, "删除岗位成功");
} else {
return to_assign(1, "删除失败");
}
}
}

View File

@ -0,0 +1,103 @@
<?php
/**
* @copyright Copyright (c) 2021 勾股工作室
* @license https://opensource.org/licenses/Apache-2.0
* @link https://www.gougucms.com
*/
declare (strict_types = 1);
namespace app\admin\controller;
use app\admin\BaseController;
use app\admin\model\AdminGroup;
use app\admin\validate\GroupCheck;
use think\exception\ValidateException;
use think\facade\Db;
use think\facade\View;
class Role extends BaseController
{
public function index()
{
if (request()->isAjax()) {
$param = get_params();
$where = array();
if (!empty($param['keywords'])) {
$where[] = ['id|title|desc', 'like', '%' . $param['keywords'] . '%'];
}
$rows = empty($param['limit']) ? get_config('app.page_size') : $param['limit'];
$group = AdminGroup::where($where)
->order('create_time asc')
->paginate($rows, false, ['query' => $param]);
return table_assign(0, '', $group);
} else {
return view();
}
}
//添加&编辑
public function add()
{
$param = get_params();
if (request()->isAjax()) {
$ruleData = isset($param['rule']) ? $param['rule'] : 0;
$param['rules'] = implode(',', $ruleData);
if (!empty($param['id']) && $param['id'] > 0) {
try {
validate(GroupCheck::class)->scene('edit')->check($param);
} catch (ValidateException $e) {
// 验证失败 输出错误信息
return to_assign(1, $e->getError());
}
//为了系统安全id为1的系统所有者管理组不允许修改
if ($param['id'] == 1) {
return to_assign(1, '为了系统安全,该管理组不允许修改');
}
Db::name('AdminGroup')->where(['id' => $param['id']])->strict(false)->field(true)->update($param);
add_log('edit', $param['id'], $param);
} else {
try {
validate(GroupCheck::class)->scene('add')->check($param);
} catch (ValidateException $e) {
// 验证失败 输出错误信息
return to_assign(1, $e->getError());
}
$gid = Db::name('AdminGroup')->strict(false)->field(true)->insertGetId($param);
add_log('add', $gid, $param);
}
//清除菜单\权限缓存
clear_cache('adminMenu');
return to_assign();
} else {
$id = isset($param['id']) ? $param['id'] : 0;
$rule = get_admin_rule();
if ($id > 0) {
$rules = get_admin_group_info($id);
$role_rule = create_tree_list(0, $rule, $rules);
$role = Db::name('AdminGroup')->where(['id' => $id])->find();
View::assign('role', $role);
} else {
$role_rule = create_tree_list(0, $rule, []);
}
View::assign('role_rule', $role_rule);
View::assign('id', $id);
return view();
}
}
//删除
public function delete()
{
$id = get_params("id");
if ($id == 1) {
return to_assign(1, "该组是系统所有者,无法删除");
}
if (Db::name('AdminGroup')->delete($id) !== false) {
add_log('delete', $id, []);
return to_assign(0, "删除角色成功");
} else {
return to_assign(1, "删除失败");
}
}
}

View File

@ -0,0 +1,94 @@
<?php
/**
* @copyright Copyright (c) 2021 勾股工作室
* @license https://opensource.org/licenses/Apache-2.0
* @link https://www.gougucms.com
*/
declare (strict_types = 1);
namespace app\admin\controller;
use app\admin\BaseController;
use app\admin\validate\RuleCheck;
use think\exception\ValidateException;
use think\facade\Db;
use think\facade\View;
class Rule extends BaseController
{
public function index()
{
if (request()->isAjax()) {
$rule = Db::name('adminRule')->order('sort asc,id asc')->select();
return to_assign(0, '', $rule);
} else {
return view();
}
}
//添加
public function add()
{
$param = get_params();
if (request()->isAjax()) {
$param['src'] = preg_replace('# #','',$param['src']);
if ($param['id'] > 0) {
try {
validate(RuleCheck::class)->scene('edit')->check($param);
} catch (ValidateException $e) {
// 验证失败 输出错误信息
return to_assign(1, $e->getError());
}
Db::name('AdminRule')->strict(false)->field(true)->update($param);
add_log('edit', $param['id'], $param);
} else {
try {
validate(RuleCheck::class)->scene('add')->check($param);
} catch (ValidateException $e) {
// 验证失败 输出错误信息
return to_assign(1, $e->getError());
}
$param['create_time'] = time();
$rid = Db::name('AdminRule')->strict(false)->field(true)->insertGetId($param);
//自动为系统所有者管理组分配新增的节点
$group = Db::name('AdminGroup')->find(1);
if (!empty($group)) {
$newGroup['id'] = 1;
$newGroup['rules'] = $group['rules'] . ',' . $rid;
Db::name('AdminGroup')->strict(false)->field(true)->update($newGroup);
add_log('add', $rid, $param);
}
}
// 删除后台节点缓存
clear_cache('adminRules');
return to_assign();
} else {
$id = isset($param['id']) ? $param['id'] : 0;
$pid = isset($param['pid']) ? $param['pid'] : 0;
if($id>0){
$detail = Db::name('AdminRule')->where('id',$id)->find();
View::assign('detail', $detail);
}
View::assign('id', $id);
View::assign('pid', $pid);
return view();
}
}
//删除
public function delete()
{
$id = get_params("id");
$count = Db::name('AdminRule')->where(["pid" => $id])->count();
if ($count > 0) {
return to_assign(1, "该节点下还有子节点,无法删除");
}
if (Db::name('AdminRule')->delete($id) !== false) {
clear_cache('adminRules');
add_log('delete', $id, []);
return to_assign(0, "删除节点成功");
} else {
return to_assign(1, "删除失败");
}
}
}

View File

@ -0,0 +1,48 @@
<?php
/**
* @copyright Copyright (c) 2021 勾股工作室
* @license https://opensource.org/licenses/Apache-2.0
* @link https://www.gougucms.com
*/
declare (strict_types = 1);
namespace app\admin\controller;
use app\admin\BaseController;
use think\facade\Db;
use think\facade\View;
class Search extends BaseController
{
public function index()
{
if (request()->isAjax()) {
$param = get_params();
$where = array();
if (!empty($param['keywords'])) {
$where[] = ['title', 'like', '%' . $param['keywords'] . '%'];
}
$rows = empty($param['limit']) ? get_config('app.page_size') : $param['limit'];
$content = Db::name('SearchKeywords')
->order('id desc')
->where($where)
->paginate($rows, false, ['query' => $param]);
return table_assign(0, '', $content);
} else {
return view();
}
}
//删除
public function delete()
{
$id = get_params("id");
if (Db::name('SearchKeywords')->delete($id) !== false) {
add_log('delete', $id);
return to_assign(0, "删除成功!");
} else {
return to_assign(1, "删除失败!");
}
}
}

View File

@ -0,0 +1,147 @@
<?php
/**
* @copyright Copyright (c) 2021 勾股工作室
* @license https://opensource.org/licenses/Apache-2.0
* @link https://www.gougucms.com
*/
declare (strict_types = 1);
namespace app\admin\controller;
use app\admin\BaseController;
use app\admin\model\StoreProduct as StoreProductModel;
use app\admin\validate\StoreProductValidate;
use think\exception\ValidateException;
use think\facade\Db;
use think\facade\View;
class StoreProduct extends BaseController
{
/**
* 构造函数
*/
public function __construct()
{
$this->model = new StoreProductModel();
$this->uid = get_login_admin('id');
}
/**
* 数据列表
*/
public function datalist()
{
if (request()->isAjax()) {
$param = get_params();
$where = [];
if (isset($param['keywords']) && !empty($param['keywords'])){
$where[]=['store_name','like','%'.$param['keywords'].'%'];
}
$list = $this->model->getStoreProductList($where,$param);
return table_assign(0, '', $list);
}
else{
return view();
}
}
/**
* 添加
*/
public function add()
{
if (request()->isAjax()) {
$param = get_params();
// 检验完整性
try {
validate(StoreProductValidate::class)->check($param);
} catch (ValidateException $e) {
// 验证失败 输出错误信息
return to_assign(1, $e->getError());
}
$this->model->addStoreProduct($param);
}else{
$store_brand= Db::connect('shop')->table('eb_store_brand')->where(['is_show' => 1])
->select();
View::assign('store_brand', $store_brand);
return view();
}
}
/**
* 编辑
*/
public function edit()
{
$param = get_params();
if (request()->isAjax()) {
// 检验完整性
try {
validate(StoreProductValidate::class)->check($param);
} catch (ValidateException $e) {
// 验证失败 输出错误信息
return to_assign(1, $e->getError());
}
$this->model->editStoreProduct($param);
}else{
$product_id = isset($param['product_id']) ? $param['product_id'] : 0;
$detail = $this->model->getStoreProductById($product_id);
if (!empty($detail)) {
$detail['content'] = Db::table('cms_store_product_content')->where('product_id',$detail['product_id'])->value('content');
$detail['slider_image_arr'] = explode(',',$detail['slider_image']);
// halt($detail['slider_image_arr']);
View::assign('detail', $detail);
$store_brand= Db::connect('shop')->table('eb_store_brand')->where(['is_show' => 1])
->select();
View::assign('store_brand', $store_brand);
return view();
}
else{
throw new \think\exception\HttpException(404, '找不到页面');
}
}
}
/**
* 查看信息
*/
public function read()
{
$param = get_params();
$product_id = isset($param['product_id']) ? $param['product_id'] : 0;
$detail = $this->model->getStoreProductById($product_id);
if (!empty($detail)) {
$detail['content'] = Db::table('cms_store_product_content')->where('product_id',$detail['product_id'])->value('content');
$detail['slider_image_arr'] = explode(',',$detail['slider_image']);
View::assign('detail', $detail);
$store_brand= Db::connect('shop')->table('eb_store_brand')->where(['is_show' => 1])
->select();
View::assign('store_brand', $store_brand);
return view();
}
else{
throw new \think\exception\HttpException(404, '找不到页面');
}
}
/**
* 删除
* type=0,逻辑删除,默认
* type=1,物理删除
*/
public function del()
{
$param = get_params();
$product_id = isset($param['product_id']) ? $param['product_id'] : 0;
$type = isset($param['type']) ? $param['type'] : 0;
$this->model->delStoreProductById($product_id,$type);
}
}

View File

@ -0,0 +1,159 @@
<?php
/**
* @copyright Copyright (c) 2021 勾股工作室
* @license https://opensource.org/licenses/Apache-2.0
* @link https://www.gougucms.com
*/
declare (strict_types = 1);
namespace app\admin\controller;
use app\admin\BaseController;
use app\admin\model\SzxcUserAuthentication as SzxcUserAuthenticationModel;
use app\admin\validate\SzxcUserAuthenticationValidate;
use think\exception\ValidateException;
use think\facade\Db;
use think\facade\View;
class SzxcUserAuthentication extends BaseController
{
/**
* 构造函数
*/
public function __construct()
{
$this->model = new SzxcUserAuthenticationModel();
$this->uid = get_login_admin('id');
$this->adminInfo = get_login_admin();
}
/**
* 数据列表
*/
public function datalist()
{
if (request()->isAjax()) {
$param = get_params();
$where = [];
if (isset($param['keywords'])){
$where[]=['name','like','%'.$param['keywords'].'%'];
}
if($this->adminInfo['position_id'] != 1){ //不是超级管理员
$www['admin_id'] = $this->adminInfo['id'];
$user_address = Db::table('fa_szxc_information_useraddress')->where($www)->find();
if ($user_address){
if($user_address['auth_range'] == 1){
$where[] = ['village_id','=',$user_address['village_id']];
}elseif ($user_address['auth_range'] == 2){
$where[] = ['street_id','=',$user_address['street_id']];
}elseif ($user_address['auth_range'] == 3){
$where[] = ['area_id','=',$user_address['area_id']];
}else{
$where[] = ['village_id','=',$user_address['village_id']];
}
}else{
$where[] = ['village_id','=',''];
}
}
$list = $this->model->getSzxcUserAuthenticationList($where,$param);
foreach ($list as $k=>$v){
$list[$k]['sh_time'] = date('Y-m-d H:i:s',$v['sh_time']);
$list[$k]['admin_id'] = Db::table('cms_admin')->where('id',$v['id'])->value('nickname');
}
return table_assign(0, '', $list);
}
else{
return view();
}
}
/**
* 添加
*/
public function add()
{
if (request()->isAjax()) {
$param = get_params();
// 检验完整性
try {
validate(SzxcUserAuthenticationValidate::class)->check($param);
} catch (ValidateException $e) {
// 验证失败 输出错误信息
return to_assign(1, $e->getError());
}
$adds=Db::table('fa_szxc_information_useraddress')->where('admin_id',$this->adminInfo['id'])->find();
$param['area_id']=$adds['area_id'];
$param['street_id']=$adds['street_id'];
$param['village_id']=$adds['village_id'];
$this->model->addSzxcUserAuthentication($param);
}else{
return view();
}
}
/**
* 编辑
*/
public function edit()
{
$param = get_params();
if (request()->isAjax()) {
// 检验完整性
try {
validate(SzxcUserAuthenticationValidate::class)->check($param);
} catch (ValidateException $e) {
// 验证失败 输出错误信息
return to_assign(1, $e->getError());
}
$this->model->editSzxcUserAuthentication($param);
}else{
$id = isset($param['id']) ? $param['id'] : 0;
$detail = $this->model->getSzxcUserAuthenticationById($id);
if (!empty($detail)) {
View::assign('detail', $detail);
return view();
}
else{
throw new \think\exception\HttpException(404, '找不到页面');
}
}
}
/**
* 查看信息
*/
public function read()
{
$param = get_params();
$id = isset($param['id']) ? $param['id'] : 0;
$detail = $this->model->getSzxcUserAuthenticationById($id);
if (!empty($detail)) {
View::assign('detail', $detail);
return view();
}
else{
throw new \think\exception\HttpException(404, '找不到页面');
}
}
/**
* 删除
* type=0,逻辑删除,默认
* type=1,物理删除
*/
public function del()
{
$param = get_params();
$id = isset($param['id']) ? $param['id'] : 0;
$type = isset($param['type']) ? $param['type'] : 0;
$this->model->delSzxcUserAuthenticationById($id,$type);
}
}

View File

@ -0,0 +1,93 @@
<?php
namespace app\admin\controller\nk;
use app\admin\BaseController;
use think\exception\ValidateException;
use think\facade\Db;
use app\admin\controller\nk\Article;
use think\facade\View;
/**
* 文章
*
* @icon fa fa-circle-o
*/
class Accommodation extends BaseController
{
public function __construct()
{
$this->adminInfo = get_login_admin();
$this->category_id=308;
$this->url=[
'/admin/nk.accommodation/index?category_id='.$this->category_id,
'/admin/nk.accommodation/add',
'/admin/nk.accommodation/edit',
'/admin/nk.accommodation/del',
'/admin/nk.accommodation/read',
];
}
/**
* 查看
*/
public function index()
{
if (request()->isAjax()) {
$params= get_params();
$params['category_id']=$this->category_id;
(new Article())->index($params);
}
return view('nk/article/index',['url'=>$this->url]);
}
/**
* 添加
*/
public function add()
{
if (request()->isAjax()) {
$params= get_params();
$params['category_id']=$this->category_id;
(new Article())->add($params);
}else{
View::assign('editor', get_system_config('other','editor'));
View::assign('url', $this->url);
// 获取用户信息
$this->users = Db::table('fa_szxc_information_usermsg')->where('status',1)->field('user_id,name')->select();
View::assign('users', $this->users);
$street = Db::table('fa_geo_area')->where(['switch' => 1, 'city_code' => '510500'])
->field('area_id id,area_code code,area_name name')
->select();
View::assign('street', $street);
return view('nk/article/add');
}
}
/**
* 修改
*/
public function edit()
{
$params= get_params();
(new Article())->edit($params);
return view('nk/article/edit',['url'=>$this->url]);
}
/**
* 查看信息
*/
public function read()
{
$params = get_params();
(new Article())->read($params);
return view('nk/article/read',['url'=>$this->url]);
}
/**
* 修改
*/
public function del()
{
$params= get_params();
(new Article())->del($params);
}
}

View File

@ -0,0 +1,93 @@
<?php
namespace app\admin\controller\nk;
use app\admin\BaseController;
use think\exception\ValidateException;
use think\facade\Db;
use app\admin\controller\nk\Article;
use think\facade\View;
/**
* 文章
*
* @icon fa fa-circle-o
*/
class Affairs extends BaseController
{
public function __construct()
{
$this->adminInfo = get_login_admin();
$this->category_id=160;
$this->url=[
'/admin/nk.affairs/index?category_id='.$this->category_id,
'/admin/nk.affairs/add',
'/admin/nk.affairs/edit',
'/admin/nk.affairs/del',
'/admin/nk.affairs/read',
];
}
/**
* 查看
*/
public function index()
{
if (request()->isAjax()) {
$params= get_params();
$params['category_id']=$this->category_id;
(new Article())->index($params);
}
return view('nk/article/index',['url'=>$this->url]);
}
/**
* 添加
*/
public function add()
{
if (request()->isAjax()) {
$params= get_params();
$params['category_id']=$this->category_id;
(new Article())->add($params);
}else{
View::assign('editor', get_system_config('other','editor'));
View::assign('url', $this->url);
// 获取用户信息
$this->users = Db::table('fa_szxc_information_usermsg')->where('status',1)->field('user_id,name')->select();
View::assign('users', $this->users);
$street = Db::table('fa_geo_area')->where(['switch' => 1, 'city_code' => '510500'])
->field('area_id id,area_code code,area_name name')
->select();
View::assign('street', $street);
return view('nk/article/add');
}
}
/**
* 修改
*/
public function edit()
{
$params= get_params();
(new Article())->edit($params);
return view('nk/article/edit',['url'=>$this->url]);
}
/**
* 查看信息
*/
public function read()
{
$params = get_params();
(new Article())->read($params);
return view('nk/article/read',['url'=>$this->url]);
}
/**
* 修改
*/
public function del()
{
$params= get_params();
(new Article())->del($params);
}
}

View File

@ -0,0 +1,93 @@
<?php
namespace app\admin\controller\nk;
use app\admin\BaseController;
use think\exception\ValidateException;
use think\facade\Db;
use app\admin\controller\nk\Article;
use think\facade\View;
/**
* 文章
*
* @icon fa fa-circle-o
*/
class Agrotechnical extends BaseController
{
public function __construct()
{
$this->adminInfo = get_login_admin();
$this->category_id=354;
$this->url=[
'/admin/nk.agrotechnical/index?category_id='.$this->category_id,
'/admin/nk.agrotechnical/add',
'/admin/nk.agrotechnical/edit',
'/admin/nk.agrotechnical/del',
'/admin/nk.agrotechnical/read',
];
}
/**
* 查看
*/
public function index()
{
if (request()->isAjax()) {
$params= get_params();
$params['category_id']=$this->category_id;
(new Article())->index($params);
}
return view('nk/article/index',['url'=>$this->url]);
}
/**
* 添加
*/
public function add()
{
if (request()->isAjax()) {
$params= get_params();
$params['category_id']=$this->category_id;
(new Article())->add($params);
}else{
View::assign('editor', get_system_config('other','editor'));
View::assign('url', $this->url);
// 获取用户信息
$this->users = Db::table('fa_szxc_information_usermsg')->where('status',1)->field('user_id,name')->select();
View::assign('users', $this->users);
$street = Db::table('fa_geo_area')->where(['switch' => 1, 'city_code' => '510500'])
->field('area_id id,area_code code,area_name name')
->select();
View::assign('street', $street);
return view('nk/article/add');
}
}
/**
* 修改
*/
public function edit()
{
$params= get_params();
(new Article())->edit($params);
return view('nk/article/edit',['url'=>$this->url]);
}
/**
* 查看信息
*/
public function read()
{
$params = get_params();
(new Article())->read($params);
return view('nk/article/read',['url'=>$this->url]);
}
/**
* 修改
*/
public function del()
{
$params= get_params();
(new Article())->del($params);
}
}

View File

@ -0,0 +1,158 @@
<?php
namespace app\admin\controller\nk;
use app\admin\BaseController;
use think\facade\Db;
use think\facade\View;
/**
* 产品情况
*
* @icon fa fa-circle-o
*/
class Analysis extends BaseController
{
/**
* 构造函数
*/
public function __construct()
{
$this->adminInfo = get_login_admin();
$this->url=[
'/admin/nk.analysis/index',
];
}
/**
* 数据列表
*/
public function index()
{
if (request()->isAjax()) {
$mmm = $www = $where = [];
$post = get_params();
//权限组信息
if ($this->adminInfo['group_access'] != 1) {
$find = Db::table('fa_szxc_information_useraddress')->where('admin_id', $this->adminInfo['id'])->find();
if ($find) {
if ($find['auth_range'] == 1) {
$mmm['b.village_id'] = $www['d.village_id'] = $where['village_id'] = $find['village_id'];
} elseif ($find['auth_range'] == 2) {
$mmm['b.street_id'] = $www['d.street_id'] = $where['street_id'] = $find['street_id'];
} elseif ($find['auth_range'] == 3) {
$mmm['b.area_id'] = $www['d.area_id'] = $where['area_id'] = $find['area_id'];
}
}
}
if ($post) {
if (isset($post['area_id']) && !empty($post['area_id'])) {
$mmm['b.area_id'] = $www['d.area_id'] = $where['area_id'] = $post['area_id'];
}
if (isset($post['street_id']) && !empty($post['street_id'])) {
$mmm['b.street_id'] = $www['d.street_id'] = $where['street_id'] = $post['street_id'];
}
if (isset($post['village_id']) && !empty($post['village_id'])) {
$mmm['b.village_id'] = $www['d.village_id'] = $where['village_id'] = $post['village_id'];
}
// if (isset($post['brigade_id']) && !empty($post['brigade_id'])) {
// $mmm['b.brigade_id'] = $www['d.brigade_id'] = $post['brigade_id'];
// }
}
$map[] = ['a.status','=',1];
$map[] = ['a.is_del','=',0];
//企业农产品销量
$list['num_2'] = Db::connect('shop')->table('eb_product_order_log')->where($where)->where('status',1)->where('mer_type_id','in','2,3')->count();
//本镇已录入的商户
$list['num_4'] = Db::connect('shop')->table('eb_merchant')->alias('a')->join('eb_merchant_address b','a.mer_id = b.mer_id')->where($mmm)->where($map)->count();
//加工企业和品牌企业数量
$map[] = ['a.type_id','in','2,3'];
$list['num_1'] = Db::connect('shop')->table('eb_merchant')->alias('a')->join('eb_merchant_address b','a.mer_id = b.mer_id')->where($mmm)->where($map)->count();
//企业通过我们平台采购的农产品
$list['num_3'] = Db::connect('shop')->table('eb_user')->alias('a')->join('eb_nk_user b','a.uid = b.user_id')->join('eb_product_order_log c','a.uid = c.uid')->join('nk_lihaink_cn.fa_szxc_information_useraddress d','b.n_user_id = d.user_id')->where($www)->where('a.status',1)->where('c.status',1)->count();
//镇农产品需求量分析(事业单位、企业、居民)
//农产品市场行情分析、显示
//农产品市内需求量
$result = ['data' => $list];
return table_assign(0, '', $result);
}
//权限组信息
$mmm = $www = $where = [];
if ($this->adminInfo['group_access'] != 1) { //不是超级管理员
$www2['admin_id'] = $this->adminInfo['id'];
$user_address = Db::table('fa_szxc_information_useraddress')->where($www2)->find();
if ($user_address) {
if ($user_address['auth_range'] == 1) {
$mmm['b.village_id'] = $www['d.village_id'] = $where['village_id'] = $user_address['village_id'];
} elseif ($user_address['auth_range'] == 2) {
$mmm['b.street_id'] = $www['d.street_id'] = $where['street_id'] = $user_address['street_id'];
} elseif ($user_address['auth_range'] == 3) {
$mmm['b.area_id'] = $www['d.area_id'] = $where['area_id'] = $user_address['area_id'];
}
if ($user_address['auth_range'] <=3 &&$user_address['auth_range'] >=1 ) {
$select = Db::table('fa_geo_area')->where('city_code', '510500')->where('area_code', $user_address['area_id'])->select();
} else {
$select = Db::table('fa_geo_area')->where('city_code', '510500')->select();
}
View::assign('row', $user_address);
} else {
$user_address['area_id'] = '';
$user_address['street_id'] = '';
$user_address['village_id'] = '';
$user_address['auth_range'] = '1';
$select = Db::table('fa_geo_area')->where('city_code', '510500')->select();
View::assign('row', $user_address);
}
$is_admin = 0;
} else {
$user_address['area_id'] = '';
$user_address['street_id'] = '';
$user_address['village_id'] = '';
$user_address['auth_range'] = '';
$select = Db::table('fa_geo_area')->where('city_code', '510500')->select();
View::assign('row', $user_address);
$is_admin = 1;
}
$map[] = ['a.status','=',1];
$map[] = ['a.is_del','=',0];
//企业农产品销量
$list['num_2'] = Db::connect('shop')->table('eb_product_order_log')->where($where)->where('status',1)->where('mer_type_id','in','2,3')->count();
//本镇已录入的商户
$list['num_4'] = Db::connect('shop')->table('eb_merchant')->alias('a')->join('eb_merchant_address b','a.mer_id = b.mer_id')->where($mmm)->where($map)->count();
//加工企业和品牌企业数量
$map[] = ['a.type_id','in','2,3'];
$list['num_1'] = Db::connect('shop')->table('eb_merchant')->alias('a')->join('eb_merchant_address b','a.mer_id = b.mer_id')->where($mmm)->where($map)->count();
//企业通过我们平台采购的农产品
$list['num_3'] = Db::connect('shop')->table('eb_user')->alias('a')->join('eb_nk_user b','a.uid = b.user_id')->join('eb_product_order_log c','a.uid = c.uid')->join('nk_lihaink_cn.fa_szxc_information_useraddress d','b.n_user_id = d.user_id')->where($www)->where('a.status',1)->where('c.status',1)->count();
//镇农产品需求量分析(事业单位、企业、居民)
//农产品市场行情分析、显示
//农产品市内需求量
View::assign('data', $list);
View::assign('arealist', $select);
View::assign('is_admin', $is_admin);
View::assign('url', $this->url);
return view();
}
}

View File

@ -0,0 +1,93 @@
<?php
namespace app\admin\controller\nk;
use app\admin\BaseController;
use think\exception\ValidateException;
use think\facade\Db;
use app\admin\controller\nk\Article;
use think\facade\View;
/**
* 文章
*
* @icon fa fa-circle-o
*/
class Announce extends BaseController
{
public function __construct()
{
$this->adminInfo = get_login_admin();
$this->category_id=302;
$this->url=[
'/admin/nk.announce/index?category_id='.$this->category_id,
'/admin/nk.announce/add',
'/admin/nk.announce/edit',
'/admin/nk.announce/del',
'/admin/nk.announce/read',
];
}
/**
* 查看
*/
public function index()
{
if (request()->isAjax()) {
$params= get_params();
$params['category_id']=$this->category_id;
(new Article())->index($params);
}
return view('nk/article/index',['url'=>$this->url]);
}
/**
* 添加
*/
public function add()
{
if (request()->isAjax()) {
$params= get_params();
$params['category_id']=$this->category_id;
(new Article())->add($params);
}else{
View::assign('editor', get_system_config('other','editor'));
View::assign('url', $this->url);
// 获取用户信息
$this->users = Db::table('fa_szxc_information_usermsg')->where('status',1)->field('user_id,name')->select();
View::assign('users', $this->users);
$street = Db::table('fa_geo_area')->where(['switch' => 1, 'city_code' => '510500'])
->field('area_id id,area_code code,area_name name')
->select();
View::assign('street', $street);
return view('nk/article/add');
}
}
/**
* 修改
*/
public function edit()
{
$params= get_params();
(new Article())->edit($params);
return view('nk/article/edit',['url'=>$this->url]);
}
/**
* 查看信息
*/
public function read()
{
$params = get_params();
(new Article())->read($params);
return view('nk/article/read',['url'=>$this->url]);
}
/**
* 修改
*/
public function del()
{
$params= get_params();
(new Article())->del($params);
}
}

View File

@ -0,0 +1,194 @@
<?php
namespace app\admin\controller\nk;
use app\admin\BaseController;
use think\exception\ValidateException;
use think\facade\Db;
use app\admin\controller\nk\Article;
use think\facade\View;
use app\api\model\Area as AreaModel; // 市场区域模型
use app\api\model\AreaManager as AreaManagerModel; // 区域负责人模型
/**
*
* 时间2023年02月17日
* 作者:墨楠小
* 邮箱monanxiao@qq.com
* 区域负责人控制器
*
*/
class Areamanager extends BaseController
{
public function __construct()
{
$this->adminInfo = get_login_admin();
$this->category_id=354;
$this->url=[
'/admin/nk.areamanager/index?category_id='.$this->category_id,
'/admin/nk.areamanager/add',
'/admin/nk.areamanager/edit',
'/admin/nk.areamanager/del',
'/admin/nk.areamanager/read',
];
}
/**
*
* 区域负责人数据列表
*
*/
public function index()
{
if (request()->isAjax()) {
$params= get_params();
$where[]= ['status','=',0];
if (isset($params['keywords']) && !empty($params['keywords'])){
$where[]= ['name','like','%'.$params['keywords'].'%'];
}
if($this->adminInfo['position_id'] != 1){ //不是超级管理员
$www['admin_id'] = $this->adminInfo['id'];
$user_address = Db::table('fa_szxc_information_useraddress')->where($www)->find();
if ($user_address){
if($user_address['auth_range'] == 1){
$where[] = ['village_id','=',$user_address['village_id']];
}elseif ($user_address['auth_range'] == 2){
$where[] = ['street_id','=',$user_address['street_id']];
}elseif ($user_address['auth_range'] == 3){
$where[] = ['area_id','=',$user_address['area_id']];
}else{
$where[] = ['village_id','=',$user_address['village_id']];
}
}else{
$where[] = ['village_id','=',''];
}
}
$total = AreaManagerModel::where($where)->count();
// 负责人信息
$list = AreaManagerModel::with('area')
->where($where)
->page($params['page'])
->limit($params['limit'])
->order('id desc')
->select();
$result = ['total' => $total, 'data' => $list];
return table_assign(0, '', $result);
}else{
return view('nk/areamanager/index',['url'=>$this->url]);
}
}
/**
*
* 区域负责人数据添加
*
*/
public function add()
{
if (request()->isAjax()) {
$params= get_params();
$data['user_id'] = $this->adminInfo['id']; // 操作用户ID
$data['avatar'] = $params['avatar']; // 头像
$data['name'] = $params['name']; // 姓名
$data['duty'] = $params['duty']; // 职务
$data['phone'] = $params['phone']; // 手机号
$data['area_id'] = $params['area_id']; // 区域ID
$area = AreaModel::find($params['area_id']);
$data['farm_product_market_id'] = $area->id; // 市场ID
$data['created_at'] = date('Y-m-d H:i:s');
$res = AreaManagerModel::create($data);
if ($res){
return to_assign(0,'操作成功',['aid'=>$res]);
}
return to_assign(1, '操作失败,原因:'.$res);
}else{
$area = AreaModel::where('status', 0)->column('id, area_name');
View::assign('editor', get_system_config('other','editor'));
View::assign('area', $area);
return view('nk/areamanager/add');
}
}
/**
*
* 区域负责人数据修改
*
*/
public function edit()
{
$param= get_params();
if (request()->isAjax()) {
$params= get_params();
$data['user_id'] = $this->adminInfo['id']; // 操作用户ID
$data['avatar'] = $params['avatar']; // 头像
$data['name'] = $params['name']; // 姓名
$data['duty'] = $params['duty']; // 职务
$data['phone'] = $params['phone']; // 手机号
$data['area_id'] = $params['area_id']; // 区域ID
$data['updated_at'] = date('Y-m-d H:i:s');
$res = AreaManagerModel::where('id', $params['id'])->update($data);
if ($res){
return to_assign();
}else{
return to_assign(1, '操作失败,原因:'.$res);
}
}else{
$id = isset($param['id']) ? $param['id'] : 0;
$detail = AreaManagerModel::find($id);
$area = AreaModel::where('status', 0)->column('id, area_name');
View::assign('editor', get_system_config('other','editor'));
View::assign('area', $area);
if (!empty($detail)) {
View::assign('detail', $detail);
return view();
}else{
throw new \think\exception\HttpException(404, '找不到页面');
}
}
}
/**
*
* 删除区域负责人
*
*/
public function del()
{
$param= get_params();
$areaManager = AreaManagerModel::find($param['id']);
$res = $areaManager->delete();
if ($res){
return to_assign();
}else{
return to_assign(1, '操作失败,原因:'.$res);
}
}
}

View File

@ -0,0 +1,216 @@
<?php
namespace app\admin\controller\nk;
use app\admin\BaseController;
use think\exception\ValidateException;
use think\facade\Db;
use think\facade\View;
/**
* 文章
*
* @icon fa fa-circle-o
*/
class Article extends BaseController
{
public function __construct()
{
$this->adminInfo = get_login_admin();
}
public function index($params)
{
$where[]= ['status','=',1];
if (isset($params['keywords']) && !empty($params['keywords'])){
$where[]=['title','like','%'.$params['keywords'].'%'];
}
if($this->adminInfo['position_id'] != 1){ //不是超级管理员
$www['admin_id'] = $this->adminInfo['id'];
$user_address = Db::table('fa_szxc_information_useraddress')->where($www)->find();
if ($user_address) {
if ($user_address['auth_range'] == 1) {
$where[]= ['county','=',$user_address['area_id']];
$where[] =['township','=', $user_address['street_id']];
$where[] =['village','=', $user_address['village_id']];
} elseif ($user_address['auth_range'] == 2) {
$where[]= ['county','=',$user_address['area_id']];
$where[] =['township','=', $user_address['street_id']];
}
}
}
$category_id =$params['category_id'];
if($category_id){
$map[] = ['category_id','=',$category_id];
}else{
$map = [];
}
$total = Db::table('fa_article')
->where($where)
->where($map)
->count();
$list = Db::table('fa_article')
->withAttr('nickname',function ($value,$data){
return Db::table('fa_szxc_information_usermsg')->where('user_id',$data['user_id'])->value('name');
})
->withAttr('area',function ($value,$data){
return Db::table('fa_geo_area')->where('area_code',$data['county'])->value('area_name');
})
->withAttr('street',function ($value,$data){
return Db::table('fa_geo_street')->where('street_code',$data['township'])->value('street_name');
})
->withAttr('village',function ($value,$data){
return Db::table('fa_geo_village')->where('village_id',$data['village'])->value('village_name');
})
->where($where)
->where($map)
->page($params['page'])
->limit($params['limit'])
->order('id desc')
->field('id,title,user_id,county,township,village,image,view_time')
->select();
$result = ['total' => $total, 'data' => $list];
return table_assign(0, '', $result);
}
public function add($param){
// 检验完整性
try {
validate(\app\admin\validate\nk\ArticleValidate::class)->check($param);
} catch (ValidateException $e) {
// 验证失败 输出错误信息
return to_assign(1, $e->getError());
}
$adds=Db::table('fa_szxc_information_useraddress')->where('admin_id',$this->adminInfo['id'])->find();
if($this->adminInfo['position_id'] != 1) { //不是超级管理员
$param['county']=$adds['area_id'];
$param['township']=$adds['street_id'];
$param['village']=$adds['village_id'];
$param['user_id']=$adds['user_id'];
}else{
if(empty($param['county'])){
$param['county']=$adds['area_id'];
}
if(empty($param['township'])){
$param['township']=$adds['street_id'];
}
if(empty($param['village'])){
$param['village']=$adds['village_id'];
}
if(empty($param['user_id'])){
$param['user_id']=$adds['user_id'];
}
}
$param['view_time']=date('Y-m-d H:i:s');
if(empty($param['category_type'])){
$param['category_type'] = 0;
}
if(empty($param['end_time'])){
$param['end_time'] = date('Y-m-d H:i:s');
}
$res=Db::table('fa_article')->strict(false)->field(true)->insertGetId($param);
if ($res){
if(!empty($param['is_vote']) && $param['is_vote']==1){
$data=['start_time'=>date('Y-m-d H:i:s'),'end_time'=>$param['end_time'],'article_id'=>$res,'county'=>$adds['area_id'],'township'=>$adds['street_id'],'village'=>$adds['village_id']];
Db::table('fa_article_vote_side_tables')->insert($data);
}
return to_assign(0,'操作成功',['aid'=>$res]);
}
return to_assign(1, '操作失败,原因:'.$res);
}
public function edit($param){
if (request()->isAjax()) {
try {
validate(\app\admin\validate\nk\ArticleValidate::class)->check($param);
} catch (ValidateException $e) {
// 验证失败 输出错误信息
return to_assign(1, $e->getError());
}
$adds=Db::table('fa_szxc_information_useraddress')->where('admin_id',$this->adminInfo['id'])->find();
if($this->adminInfo['position_id'] == 1) { //是超级管理员
if(empty($param['county'])){
$param['county']=$adds['area_id'];
}
if(empty($param['township'])){
$param['township']=$adds['street_id'];
}
if(empty($param['village'])){
$param['village']=$adds['village_id'];
}
if(empty($param['user_id'])){
$param['user_id']=$adds['user_id'];
}
}
$res=Db::table('fa_article')->where('id',$param['id'])->strict(false)->field(true)->update($param);
if ($res){
if(!empty($param['is_vote']) && $param['is_vote']==1){
Db::table('fa_article_vote_side_tables')->where('article_id',$param['id'])->update(['end_time'=>$param['end_time']]);
}
return to_assign();
}else{
return to_assign(1, '操作失败,原因:'.$res);
}
}else{
$id = isset($param['id']) ? $param['id'] : 0;
$detail = Db::table('fa_article')->where('id',$id)->find();
View::assign('editor', get_system_config('other','editor'));
if (!empty($detail)) {
View::assign('detail', $detail);
// 获取用户信息
$this->users = Db::table('fa_szxc_information_usermsg')->where('status',1)->field('user_id,name')->select();
View::assign('users', $this->users);
$street = Db::table('fa_geo_area')->where(['switch' => 1, 'city_code' => '510500'])
->field('area_id id,area_code code,area_name name')
->select();
View::assign('street', $street);
}
else{
throw new \think\exception\HttpException(404, '找不到页面');
}
}
}
/**
* 查看信息
*/
public function read($param)
{
$id = isset($param['id']) ? $param['id'] : 0;
$detail = Db::table('fa_article')->where('id',$id)->find();
if (!empty($detail)) {
$detail['comment'] = Db::table('fa_article_comment')
->where('vote_id',$id)
->withAttr('user_info',function ($value,$data){
return Db::table('fa_szxc_information_usermsg')->where('user_id',$data['user_id'])->value('name');
})
->select();
View::assign('detail', $detail);
View::assign('admin_id', $this->adminInfo['id']);
}
else{
throw new \think\exception\HttpException(404, '找不到页面');
}
}
/**
* 删除
*/
public function del($param)
{
$id = isset($param['id']) ? $param['id'] : 0;
$type = isset($param['type']) ? $param['type'] : 0;
$res = Db::table('fa_article')->where('id',$id)->delete();
if ($res){
return to_assign();
}else{
return to_assign(1, '操作失败,原因:'.$res);
}
}
}

View File

@ -0,0 +1,263 @@
<?php
namespace app\admin\controller\nk;
use think\db\exception\DbException as ExceptionDbException;
use think\exception\ValidateException;
use app\admin\BaseController;
use think\facade\Db;
use think\facade\View;
/**
* 文娱旅游
* 公共父类
*/
class ArticleCommon extends BaseController {
const ARTICLE = 'fa_article';
protected $category_id;
function __construct(){
$this->adminInfo = get_login_admin();
// $this->pid = 361;
$this->category_id = 362;
$this->url=[
'/admin/nk.culturatour/index?category_id='.$this->category_id,
'/admin/nk.culturatour/add',
'/admin/nk.culturatour/edit',
'/admin/nk.culturatour/del',
'/admin/nk.culturatour/read',
];
}
/**
* 文章列表
*/
function Index(){
if (request()->isAjax()) {
$params= get_params();
$params['category_id']=$this->category_id;
$where = ['category_id'=>$this->category_id];
$list = Db::table('fa_article')->field('id')->where($where)
->page(1)
->limit(1)
->order('id desc')
->select();
(new Article())->index($params);
}
return view('nk/article/index',['url'=>$this->url]);
}
/**
* 查看文章 【无关联表】
*/
function Read(){
$params = get_params();
(new Article())->read($params);
return view('nk/article/read',['url'=>$this->url]);
}
/**
* 添加文章【无关联表】
*/
function Add(){
if (request()->isAjax()) {
$params= get_params();
$params['category_id']=$this->category_id;
// unset($params['amp;']);
(new Article())->add($params);
}else{
View::assign('editor', get_system_config('other','editor'));
View::assign('url', $this->url);
// 获取用户信息
$this->users = Db::table('fa_szxc_information_usermsg')->where('status',1)->field('user_id,name')->select();
View::assign('users', $this->users);
$street = Db::table('fa_geo_area')->where(['switch' => 1, 'city_code' => '510500'])
->field('area_id id,area_code code,area_name name')
->select();
View::assign('street', $street);
return view('nk/article/add');
}
}
/**
* 编辑文章 【无关联表】
*/
function Edit(){
$params= get_params();
(new Article())->edit($params);
return view('nk/article/edit',['url'=>$this->url]);
}
/**
* 删除文章【无关联表】
*/
function Del(){
$params= get_params();
(new Article())->del($params);
}
/**
* 添加文章与关联表数据.
* 【有关联表】
*/
function addArticle($param, $callback){
// 检验完整性
try {
validate(\app\admin\validate\nk\ArticleValidate::class)->check($param);
} catch (ValidateException $e) {
// 验证失败 输出错误信息
return to_assign(1, $e->getError());
}
$adds=Db::table('fa_szxc_information_useraddress')->where('admin_id',$this->adminInfo['id'])->find();
if($this->adminInfo['position_id'] != 1) { //不是超级管理员
$param['county']=$adds['area_id'];
$param['township']=$adds['street_id'];
$param['village']=$adds['village_id'];
$param['user_id']=$adds['user_id'];
}else{
if(empty($param['county'])){
$param['county']=$adds['area_id'];
}
if(empty($param['township'])){
$param['township']=$adds['street_id'];
}
if(empty($param['village'])){
$param['village']=$adds['village_id'];
}
if(empty($param['user_id'])){
$param['user_id']=$adds['user_id'];
}
}
$param['view_time']=date('Y-m-d H:i:s');
if(empty($param['category_type'])){
$param['category_type'] = 0;
}
if(empty($param['end_time'])){
$param['end_time'] = date('Y-m-d H:i:s');
}
Db::startTrans();
try{
// 新建文章
$aid = Db::table('fa_article')->strict(false)->field(true)->insertGetId($param);
// 新建文章相关表的信息
$pid = $callback($aid);
}catch(ExceptionDbException $e){
Db::rollback();
return to_assign(1, '操作失败,原因:'.$e->getMessage());
}
if (!empty($aid) && !empty($pid)) {
Db::commit();
if(!empty($param['is_vote']) && $param['is_vote']==1){
$data=['start_time'=>date('Y-m-d H:i:s'),'end_time'=>$param['end_time'],'article_id'=>$aid,'county'=>$adds['area_id'],'township'=>$adds['street_id'],'village'=>$adds['village_id']];
Db::table('fa_article_vote_side_tables')->insert($data);
}
return to_assign(0,'操作成功',['aid'=>$aid]);
}
return to_assign(1, '操作失败,原因:'.$aid);
}
/**
* 1. 获取编辑页展示文章与关联表数据.
* 【有关联表】
*/
function getEditData($param, $id, $callback){
// 获取指定文章
$detail = Db::table('fa_article')->where('id',$id)->withAttr('lesson',
$callback
)->find();
View::assign('editor', get_system_config('other','editor'));
// 获取此文章的用户信息
if (!empty($detail)) {
View::assign('detail', $detail);
//获取用户信息
$this->users = Db::table('fa_szxc_information_usermsg')->where('status',1)->field('user_id,name')->select();
View::assign('users', $this->users);
$street = Db::table('fa_geo_area')->where(['switch' => 1, 'city_code' => '510500'])
->field('area_id id,area_code code,area_name name')
->select();
View::assign('street', $street);
}
else{
throw new \think\exception\HttpException(404, '找不到页面');
}
}
/**
* 2. ajax提交编辑更新文章与关联表数据.
* 【有关联表】
*/
function updateEditData($param, $id, $callback){
try {
validate(\app\admin\validate\nk\ArticleValidate::class)->check($param);
} catch (ValidateException $e) {
// 验证失败 输出错误信息
return to_assign(1, $e->getError());
}
$adds=Db::table('fa_szxc_information_useraddress')->where('admin_id',$this->adminInfo['id'])->find();
if($this->adminInfo['position_id'] == 1) { //是超级管理员
if(empty($param['county'])){
$param['county']=$adds['area_id'];
}
if(empty($param['township'])){
$param['township']=$adds['street_id'];
}
if(empty($param['village'])){
$param['village']=$adds['village_id'];
}
if(empty($param['user_id'])){
$param['user_id']=$adds['user_id'];
}
}
// 更新文章信息
$res=Db::table('fa_article')->where('id',$id)->strict(false)->field(true)->update($param);
// 更新文章相关的扩展信息
$callback($param);
if ($res){
// 更新文章相关的投票信息
if(!empty($param['is_vote']) && $param['is_vote']==1){
Db::table('fa_article_vote_side_tables')->where('article_id',$id)->update(['end_time'=>$param['end_time']]);
}
return to_assign();
}else{
return to_assign(1, '操作失败,原因:'.$res);
}
}
/**
* 文章与关联表删除
* 【有关联表】
*/
function delArticle($id, $callback){
// 此处同时删除两个表
Db::startTrans();
try{
$res1 = Db::table('fa_article')->where('id',$id)->delete();
$pid = $callback($id);
}catch (ExceptionDbException $e){
Db::rollback();
$res1 = $pid = '';
return ["code"=>1, "msg"=>'操作失败,原因:'.$e->getMessage()];
}
if ($res1 && $pid){
Db::commit();
return ["code"=>0, "msg"=>'操作成功'];
}else{
return ["code"=>1, "msg"=>'操作失败,原因:两表一起删除失败[主表:'.$res1.'][联表:'.$pid.']'];
}
}
}

View File

@ -0,0 +1,164 @@
<?php
namespace app\admin\controller\nk;
use app\admin\BaseController;
use app\admin\controller\nk\Article;
use think\exception\ValidateException;
use think\facade\Db;
use think\facade\View;
/**
* 直播
*
* @icon fa fa-circle-o
*/
class Broadcast extends BaseController
{
public function __construct()
{
$this->adminInfo = get_login_admin();
$this->url=[
'/admin/nk.broadcast/index',
'/admin/nk.broadcast/add',
'/admin/nk.broadcast/edit',
'/admin/nk.broadcast/del',
'/admin/nk.broadcast/read',
];
}
/**
* 查看
*/
public function index()
{
if (request()->isAjax()) {
$params= get_params();
$where[]=['is_del','=',0];
$where[]=['is_mer_del','=',0];
if (isset($params['keywords'])){
$where[]=['name','like','%'.$params['keywords'].'%'];
}
$total = Db::connect('shop')->table('eb_broadcast_room')
->where($where)->count();
$list = Db::connect('shop')->table('eb_broadcast_room')
->where($where)
->page($params['page'])
->limit($params['limit'])
->order('broadcast_room_id desc')
->select();
$result = ['total' => $total, 'data' => $list];
return table_assign(0, '', $result);
}
View::assign('url', $this->url);
return view();
}
/**
* 添加
*/
public function add()
{
// if (request()->isAjax()) {
// $params= get_params();
// if (!empty($params['is_hot'])&&$params['is_hot']=='on'){
// $params['is_hot']=1;
// }else{
// $params['is_hot']=0;
// }
// if (!empty($params['is_tourism'])&&$params['is_tourism']=='on'){
// $params['is_tourism']=1;
// }else{
// $params['is_tourism']=0;
// }
// if(empty($params['village_id'])){
// return to_assign(1, '请选择村/社区');
// }
// $area_code=Db::table('fa_geo_area')->where('area_code',$params['area_id'])->value('area_name');
// $street_code=Db::table('fa_geo_street')->where('street_code',$params['street_id'])->value('street_name');
// $village_id=Db::table('fa_geo_village')->where('village_id',$params['village_id'])->value('village_name');
// $params['address']='泸州市'.$area_code.$street_code.$village_id;
// $params['createtime']=time();
// $res=Db::table('eb_broadcast_room')->strict(false)->field(true)->insertGetId($params);
// if ($res){
// return to_assign(0,'操作成功',['aid'=>$res]);
// }
// return to_assign(1, '操作失败,原因:'.$res);
// }
//
// $street = Db::table('fa_geo_area')->where(['switch' => 1, 'city_code' => '510500'])
// ->field('area_id id,area_code code,area_name name')
// ->select();
// View::assign('street', $street);
// View::assign('editor', get_system_config('other','editor'));
View::assign('url', $this->url);
return view();
}
/**
* 修改
*/
public function edit()
{
// $params= get_params();
// if (request()->isAjax()) {
// if (!empty($params['is_hot'])&&$params['is_hot']=='on'){
// $params['is_hot']=1;
// }else{
// $params['is_hot']=0;
// }
// if (!empty($params['is_tourism'])&&$params['is_tourism']=='on'){
// $params['is_tourism']=1;
// }else{
// $params['is_tourism']=0;
// }
// if(empty($params['village_id'])){
// return to_assign(1, '请选择村/社区');
// }
// $area_code=Db::table('fa_geo_area')->where('area_code',$params['area_id'])->value('area_name');
// $street_code=Db::table('fa_geo_street')->where('street_code',$params['street_id'])->value('street_name');
// $village_id=Db::table('fa_geo_village')->where('village_id',$params['village_id'])->value('village_name');
// $params['address']='泸州市'.$area_code.$street_code.$village_id;
// $res=Db::table('eb_broadcast_room')->where('id',$params['id'])->strict(false)->field(true)->update($params);
// if ($res){
// return to_assign();
// }else{
// return to_assign(1, '操作失败,原因:'.$res);
// }
// }
// $detail = Db::table('eb_broadcast_room')->where('id',$params['id'])->find();
// $street = Db::table('fa_geo_area')->where(['switch' => 1, 'city_code' => '510500'])
// ->field('area_id id,area_code code,area_name name')
// ->select();
// View::assign('street', $street);
// View::assign('detail', $detail);
View::assign('url', $this->url);
return view();
}
/**
* 查看信息
*/
public function read()
{
$params = get_params();
$detail = Db::table('eb_broadcast_room')->where('id',$params['id'])->find();
View::assign('url', $this->url);
View::assign('detail', $detail);
return view();
}
/**
* 修改
*/
public function del()
{
$param= get_params();
$id = isset($param['id']) ? $param['id'] : 0;
$type = isset($param['type']) ? $param['type'] : 0;
$res = Db::table('eb_broadcast_room')->where('id',$id)->update(['status'=>$type]);
if ($res){
return to_assign();
}else{
return to_assign(1, '操作失败,原因:'.$res);
}
}
}

View File

@ -0,0 +1,122 @@
<?php
declare (strict_types = 1);
namespace app\admin\controller\nk;
use app\admin\BaseController;
use think\facade\Db;
use think\facade\View;
class Category extends BaseController
{
public function __construct()
{
$this->adminInfo = get_login_admin();
// 类型
$map[] = ['pid','=','0'];
$map[] = ['status','=','normal'];
$this->type = Db::table('fa_category')->where($map)->field('id,type,name')->select();
}
public function index()
{
if (request()->isAjax()) {
$list = Db::table('fa_category')->order('weigh asc,id asc')->select()->toArray();
foreach ($list as $k =>$v){
if($v['status'] == 'normal'){
$list[$k]['status'] = '正常';
}else{
$list[$k]['status'] = '禁用';
}
}
return to_assign(0, '', $list);
} else {
return view();
}
}
//添加
public function add()
{
$param = get_params();
if (request()->isAjax()) {
if($param['pid'] == 0){
$www['pid'] = 0;
$www['type'] = $param['type'];
$pid = Db::table('fa_category')->where($www)->value('id');
if($pid){
$param['pid'] = $pid;
}else{
return to_assign(1, '操作失败,请联系系统管理员');
}
}
if ($param['id'] > 0) {
$param['updatetime'] = time();
$res = Db::table('fa_category')->strict(false)->field(true)->where('id',$param['id'])->update($param);
if ($res){
add_log('edit', $param['id'], $param);
return to_assign(0,'操作成功',['aid'=>$res]);
}
return to_assign(1, '操作失败,原因:'.$res);
}else{
$param['status'] = 'normal';
$param['nickname'] = $param['name'];
$param['createtime'] = time();
unset($param['id']);
$res=Db::table('fa_category')->strict(false)->field(true)->insertGetId($param);
if ($res){
add_log('add', $res, $param);
return to_assign(0,'操作成功',['aid'=>$res]);
}
return to_assign(1, '操作失败,原因:'.$res);
}
} else {
$id = isset($param['id']) ? $param['id'] : 0;
$pid = isset($param['pid']) ? $param['pid'] : 0;
if($id>0){
$detail = Db::table('fa_category')->where('id',$id)->find();
View::assign('detail', $detail);
}else{
$detail['pid'] = '';
$detail['type'] = '';
View::assign('detail', $detail);
}
View::assign('id', $id);
View::assign('pid', $pid);
View::assign('type', $this->type);
return view();
}
}
//删除
public function delete()
{
$id = get_params("id");
$count = Db::name('AdminRule')->where(["pid" => $id])->count();
if ($count > 0) {
return to_assign(1, "该节点下还有子节点,无法删除");
}
if (Db::name('AdminRule')->delete($id) !== false) {
clear_cache('adminRules');
add_log('delete', $id, []);
return to_assign(0, "删除节点成功");
} else {
return to_assign(1, "删除失败");
}
}
public function getbytype(){
$type = get_params("type");
$where['type'] = $type;
$where['status'] = 'normal';
$list = Db::table('fa_category')->where($where)->order('weigh asc,id asc')->select();
return to_assign(0, '', $list);
}
}

View File

@ -0,0 +1,93 @@
<?php
namespace app\admin\controller\nk;
use app\admin\BaseController;
use think\exception\ValidateException;
use think\facade\Db;
use app\admin\controller\nk\Article;
use think\facade\View;
/**
* 文章
*
* @icon fa fa-circle-o
*/
class Classroom extends BaseController
{
public function __construct()
{
$this->adminInfo = get_login_admin();
$this->category_id=298;
$this->url=[
'/admin/nk.classroom/index?category_id='.$this->category_id,
'/admin/nk.classroom/add',
'/admin/nk.classroom/edit',
'/admin/nk.classroom/del',
'/admin/nk.classroom/read',
];
}
/**
* 查看
*/
public function index()
{
if (request()->isAjax()) {
$params= get_params();
$params['category_id']=$this->category_id;
(new Article())->index($params);
}
return view('nk/article/index',['url'=>$this->url]);
}
/**
* 添加
*/
public function add()
{
if (request()->isAjax()) {
$params= get_params();
$params['category_id']=$this->category_id;
(new Article())->add($params);
}else{
View::assign('editor', get_system_config('other','editor'));
View::assign('url', $this->url);
// 获取用户信息
$this->users = Db::table('fa_szxc_information_usermsg')->where('status',1)->field('user_id,name')->select();
View::assign('users', $this->users);
$street = Db::table('fa_geo_area')->where(['switch' => 1, 'city_code' => '510500'])
->field('area_id id,area_code code,area_name name')
->select();
View::assign('street', $street);
return view('nk/article/add');
}
}
/**
* 修改
*/
public function edit()
{
$params= get_params();
(new Article())->edit($params);
return view('nk/article/edit',['url'=>$this->url]);
}
/**
* 查看信息
*/
public function read()
{
$params = get_params();
(new Article())->read($params);
return view('nk/article/read',['url'=>$this->url]);
}
/**
* 修改
*/
public function del()
{
$params= get_params();
(new Article())->del($params);
}
}

View File

@ -0,0 +1,182 @@
<?php
namespace app\admin\controller\nk;
use app\admin\BaseController;
use think\facade\Db;
use think\facade\View;
/**
* 文章投诉
*
* @icon fa fa-circle-o
*/
class Comment extends BaseController
{
/**
* 构造函数
*/
public function __construct()
{
$this->adminInfo = get_login_admin();
$this->url=[
'/admin/nk.comment/index',
'/admin/nk.comment/add',
'/admin/nk.comment/edit',
'/admin/nk.comment/del',
'/admin/nk.comment/read',
];
// 获取用户信息
$this->users = Db::table('fa_szxc_information_usermsg')->where('status',1)->field('user_id,name')->select();
}
/**
* 数据列表
*/
public function index()
{
if (request()->isAjax()) {
$params= get_params();
// $where['status']=1;
$where = [];
if (isset($params['keywords'])){
// $where[]=['title','like','%'.$params['keywords'].'%'];
}
if($this->adminInfo['position_id'] != 1){ //不是超级管理员
$www['admin_id'] = $this->adminInfo['id'];
$user_address = Db::table('fa_szxc_information_useraddress')->where($www)->find();
if ($user_address){
if($user_address['auth_range'] == 1){
$where['village'] = $user_address['village_id'];
}elseif ($user_address['auth_range'] == 2){
$where['township'] = $user_address['street_id'];
}elseif ($user_address['auth_range'] == 3){
$where['county'] = $user_address['area_id'];
}else{
$where['village'] = $user_address['village_id'];
}
}else{
$where['village'] = '';
}
}
$total = Db::table('fa_article_comment')
->where($where)
->count();
$list = Db::table('fa_article_comment')
->withAttr('name',function ($value,$data){
return Db::table('fa_szxc_information_usermsg')->where('user_id',$data['user_id'])->value('name');
})
->withAttr('street',function ($value,$data){
return Db::table('fa_geo_street')->where('street_code',$data['township'])->value('street_name');
})
->withAttr('village',function ($value,$data){
return Db::table('fa_geo_village')->where('village_id',$data['village'])->value('village_name');
})
->withAttr('status',function ($value,$data){
if($value == 1){
return '通过';
}else{
return '不通过';
}
})
->where($where)
->page($params['page'])
->limit($params['limit'])
->order('id desc')
->select();
$result = ['total' => $total, 'data' => $list];
return table_assign(0, '', $result);
}
else{
return view('nk/comment/index',['url'=>$this->url]);
}
}
public function add(){
if (request()->isAjax()) {
$param= get_params();
$adds=Db::table('fa_szxc_information_useraddress')->where('admin_id',$this->adminInfo['id'])->find();
$param['county']=$adds['area_id'];
$param['township']=$adds['street_id'];
$param['village']=$adds['village_id'];
$res=Db::table('fa_article_comment')->strict(false)->field(true)->insertGetId($param);
if ($res){
return to_assign(0,'操作成功',['aid'=>$res]);
}
return to_assign(1, '操作失败,原因:'.$res);
}else{
$article = Db::table('fa_article')->where('status',1)->field('id,title')->select();
View::assign('editor', get_system_config('other','editor'));
View::assign('users', $this->users);
View::assign('article', $article);
return view();
}
}
public function edit(){
$param= get_params();
if (request()->isAjax()) {
$res=Db::table('fa_article_comment')->where('id',$param['id'])->strict(false)->field(true)->update($param);
if ($res){
return to_assign();
}else{
return to_assign(1, '操作失败,原因:'.$res);
}
}else{
$id = isset($param['id']) ? $param['id'] : 0;
$detail = Db::table('fa_article_comment')->where('id',$id)->find();
View::assign('editor', get_system_config('other','editor'));
if (!empty($detail)) {
View::assign('detail', $detail);
View::assign('users', $this->users);
$article = Db::table('fa_article')->where('status',1)->field('id,title')->select();
View::assign('article', $article);
return view();
}
else{
throw new \think\exception\HttpException(404, '找不到页面');
}
}
}
/**
* 查看信息
*/
public function read()
{
$param= get_params();
$id = isset($param['id']) ? $param['id'] : 0;
$detail = Db::table('fa_article_comment')->where('id',$id)->find();
if (!empty($detail)) {
View::assign('detail', $detail);
View::assign('users', $this->users);
$article = Db::table('fa_article')->where('status',1)->field('id,title')->select();
View::assign('article', $article);
return view();
}
else{
throw new \think\exception\HttpException(404, '找不到页面');
}
}
/**
* 删除
*/
public function del()
{
$param= get_params();
$id = isset($param['id']) ? $param['id'] : 0;
$type = isset($param['type']) ? $param['type'] : 0;
$res = Db::table('fa_article_comment')->where('id',$id)->delete();
if ($res){
return to_assign();
}else{
return to_assign(1, '操作失败,原因:'.$res);
}
}
}

View File

@ -0,0 +1,119 @@
<?php
namespace app\admin\controller\nk;
use app\admin\BaseController;
use think\facade\Db;
use think\facade\View;
/**
* 村民互动(逛逛)
*
* @icon fa fa-circle-o
*/
class Community extends BaseController
{
/**
* 构造函数
*/
public function __construct()
{
$this->adminInfo = get_login_admin();
$this->url=[
'/admin/nk.community/index',
'/admin/nk.community/add',
'/admin/nk.community/edit',
'/admin/nk.community/del',
'/admin/nk.community/read',
];
}
/**
* 数据列表
*/
public function index()
{
if (request()->isAjax()) {
$params= get_params();
$where['status']=1;
if (isset($params['keywords'])){
// $where[]=['title','like','%'.$params['keywords'].'%'];
}
if($this->adminInfo['position_id'] != 1){ //不是超级管理员
$www['admin_id'] = $this->adminInfo['id'];
$user_address = Db::table('fa_szxc_information_useraddress')->where($www)->find();
if ($user_address){
if ($user_address['auth_range'] == 2){
$where['street_id'] = $user_address['street_id'];
}elseif ($user_address['auth_range'] == 3){
$where['area_id'] = $user_address['area_id'];
}else{
$where['village_id'] = $user_address['village_id'];
}
}else{
$where['village_id'] = '';
}
}
$total = Db::connect('shop')->name('community_address')
->where($where)
->count();
if ($total!=0){
$list = Db::connect('shop')->name('community_address')
->where($where)
->page($params['page'])
->limit($params['limit'])
->select();
$arr=[];
foreach ($list as $k=>$v){
$arr[]=$v['community_id'];
}
$list2=Db::connect('shop')->name('community')->where('community_id','in',$arr)->select();
}else{
$list2=[];
}
$result = ['total' => $total, 'data' => $list2];
return table_assign(0, '', $result);
}
else{
return view('nk/community/index',['url'=>$this->url]);
}
}
/**
* 查看信息
*/
public function read()
{
$param= get_params();
$id = isset($param['id']) ? $param['id'] : 0;
$detail = Db::connect('shop')->name('community')->where('community_id',$id)->find();
if (!empty($detail)) {
View::assign('detail', $detail);
return view();
}
else{
throw new \think\exception\HttpException(404, '找不到页面');
}
}
/**
* 删除
*/
public function del()
{
$param= get_params();
$id = isset($param['id']) ? $param['id'] : 0;
$res = Db::connect('shop')->name('community')->where('community_id',$id)->delete();
Db::connect('shop')->name('community_address')->where('community_id',$id)->delete();
if ($res){
return to_assign();
}else{
return to_assign(1, '操作失败,原因:'.$res);
}
}
}

View File

@ -0,0 +1,189 @@
<?php
namespace app\admin\controller\nk;
use app\admin\BaseController;
use think\facade\Db;
use think\facade\View;
/**
* 文章投诉
*
* @icon fa fa-circle-o
*/
class Complaint extends BaseController
{
/**
* 构造函数
*/
public function __construct()
{
$this->adminInfo = get_login_admin();
$this->url=[
'/admin/nk.complaint/index',
'/admin/nk.complaint/add',
'/admin/nk.complaint/edit',
'/admin/nk.complaint/del',
'/admin/nk.complaint/read',
];
// 获取用户信息
$this->users = Db::table('fa_szxc_information_usermsg')->where('status',1)->field('user_id,name')->select();
}
/**
* 数据列表
*/
public function index()
{
if (request()->isAjax()) {
$params= get_params();
$where['status']=1;
if (isset($params['keywords'])){
// $where[]=['title','like','%'.$params['keywords'].'%'];
}
if($this->adminInfo['position_id'] != 1){ //不是超级管理员
$www['admin_id'] = $this->adminInfo['id'];
$user_address = Db::table('fa_szxc_information_useraddress')->where($www)->find();
if ($user_address){
if($user_address['auth_range'] == 1){
$where['village'] = $user_address['village_id'];
}elseif ($user_address['auth_range'] == 2){
$where['township'] = $user_address['street_id'];
}elseif ($user_address['auth_range'] == 3){
$where['county'] = $user_address['area_id'];
}else{
$where['village'] = $user_address['village_id'];
}
}else{
$where['village'] = '';
}
}
$total = Db::table('fa_article_complaint')
->where($where)
->count();
$list = Db::table('fa_article_complaint')
->withAttr('name',function ($value,$data){
return Db::table('fa_szxc_information_usermsg')->where('user_id',$data['user_id'])->value('name');
})
->withAttr('title',function ($value,$data){
return Db::table('fa_article')->where('id',$data['article_id'])->value('title');
})
->withAttr('street',function ($value,$data){
return Db::table('fa_geo_street')->where('street_code',$data['township'])->value('street_name');
})
->withAttr('village',function ($value,$data){
return Db::table('fa_geo_village')->where('village_id',$data['village'])->value('village_name');
})
->withAttr('createtime',function ($value,$data){
return date('Y-m-d H:i:s',$data['createtime']);
})
->withAttr('type',function ($value,$data){
if($value == 1){
return '文章';
}elseif($value == 2){
return '朋友圈';
}else{
return '';
}
})
->where($where)
->page($params['page'])
->limit($params['limit'])
->order('id desc')
->select();
$result = ['total' => $total, 'data' => $list];
return table_assign(0, '', $result);
}
else{
return view('nk/complaint/index',['url'=>$this->url]);
}
}
public function add(){
if (request()->isAjax()) {
$param= get_params();
$adds=Db::table('fa_szxc_information_useraddress')->where('admin_id',$this->adminInfo['id'])->find();
$param['county']=$adds['area_id'];
$param['township']=$adds['street_id'];
$param['village']=$adds['village_id'];
$res=Db::table('fa_article_complaint')->strict(false)->field(true)->insertGetId($param);
if ($res){
return to_assign(0,'操作成功',['aid'=>$res]);
}
return to_assign(1, '操作失败,原因:'.$res);
}else{
$article = Db::table('fa_article')->where('status',1)->field('id,title')->select();
View::assign('editor', get_system_config('other','editor'));
View::assign('users', $this->users);
View::assign('article', $article);
return view();
}
}
public function edit(){
$param= get_params();
if (request()->isAjax()) {
$res=Db::table('fa_article_complaint')->where('id',$param['id'])->strict(false)->field(true)->update($param);
if ($res){
return to_assign();
}else{
return to_assign(1, '操作失败,原因:'.$res);
}
}else{
$id = isset($param['id']) ? $param['id'] : 0;
$detail = Db::table('fa_article_complaint')->where('id',$id)->find();
View::assign('editor', get_system_config('other','editor'));
if (!empty($detail)) {
View::assign('detail', $detail);
View::assign('users', $this->users);
$article = Db::table('fa_article')->where('status',1)->field('id,title')->select();
View::assign('article', $article);
return view();
}
else{
throw new \think\exception\HttpException(404, '找不到页面');
}
}
}
/**
* 查看信息
*/
public function read()
{
$param= get_params();
$id = isset($param['id']) ? $param['id'] : 0;
$detail = Db::table('fa_article_complaint')->where('id',$id)->find();
if (!empty($detail)) {
View::assign('detail', $detail);
View::assign('users', $this->users);
$article = Db::table('fa_article')->where('status',1)->field('id,title')->select();
View::assign('article', $article);
return view();
}
else{
throw new \think\exception\HttpException(404, '找不到页面');
}
}
/**
* 删除
*/
public function del()
{
$param= get_params();
$id = isset($param['id']) ? $param['id'] : 0;
$type = isset($param['type']) ? $param['type'] : 0;
$res = Db::table('fa_article_complaint')->where('id',$id)->delete();
if ($res){
return to_assign();
}else{
return to_assign(1, '操作失败,原因:'.$res);
}
}
}

View File

@ -0,0 +1,21 @@
<?php
namespace app\admin\controller\nk;
/**
* 文娱旅游
* -- 文章文创
*/
class CulturalArticle extends ArticleCommon{
function __construct()
{
$this->category_id = 362;
$this->url=[
'/admin/nk.culturalarticle/index?category_id='.$this->category_id,
'/admin/nk.culturalarticle/add',
'/admin/nk.culturalarticle/edit',
'/admin/nk.culturalarticle/del',
'/admin/nk.culturalarticle/read',
];
}
}

View File

@ -0,0 +1,21 @@
<?php
namespace app\admin\controller\nk;
/**
* 文娱旅游
* -- 全民打卡
*/
class CulturalCard extends ArticleCommon{
function __construct()
{
$this->category_id = 361;
$this->url=[
'/admin/nk.culturalcard/index?category_id='.$this->category_id,
'/admin/nk.culturalcard/add',
'/admin/nk.culturalcard/edit',
'/admin/nk.culturalcard/del',
'/admin/nk.culturalcard/read',
];
}
}

View File

@ -0,0 +1,21 @@
<?php
namespace app\admin\controller\nk;
/**
* 文娱旅游
* -- 官网攻略
*/
class CulturalPlay extends ArticleCommon{
function __construct()
{
$this->category_id = 360;
$this->url=[
'/admin/nk.culturalplay/index?category_id='.$this->category_id,
'/admin/nk.culturalplay/add',
'/admin/nk.culturalplay/edit',
'/admin/nk.culturalplay/del',
'/admin/nk.culturalplay/read',
];
}
}

View File

@ -0,0 +1,21 @@
<?php
namespace app\admin\controller\nk;
/**
* 文娱旅游
* -- 官网攻略
*/
class CulturalStrategy extends ArticleCommon{
function __construct()
{
$this->category_id = 364;
$this->url=[
'/admin/nk.culturalstrategy/index?category_id='.$this->category_id,
'/admin/nk.culturalstrategy/add',
'/admin/nk.culturalstrategy/edit',
'/admin/nk.culturalstrategy/del',
'/admin/nk.culturalstrategy/read',
];
}
}

View File

@ -0,0 +1,93 @@
<?php
namespace app\admin\controller\nk;
use app\admin\BaseController;
use think\exception\ValidateException;
use think\facade\Db;
use app\admin\controller\nk\Article;
use think\facade\View;
/**
* 文章
*
* @icon fa fa-circle-o
*/
class Education extends BaseController
{
public function __construct()
{
$this->adminInfo = get_login_admin();
$this->category_id=299;
$this->url=[
'/admin/nk.education/index?category_id='.$this->category_id,
'/admin/nk.education/add',
'/admin/nk.education/edit',
'/admin/nk.education/del',
'/admin/nk.education/read',
];
}
/**
* 查看
*/
public function index()
{
if (request()->isAjax()) {
$params= get_params();
$params['category_id']=$this->category_id;
(new Article())->index($params);
}
return view('nk/article/index',['url'=>$this->url]);
}
/**
* 添加
*/
public function add()
{
if (request()->isAjax()) {
$params= get_params();
$params['category_id']=$this->category_id;
(new Article())->add($params);
}else{
View::assign('editor', get_system_config('other','editor'));
View::assign('url', $this->url);
// 获取用户信息
$this->users = Db::table('fa_szxc_information_usermsg')->where('status',1)->field('user_id,name')->select();
View::assign('users', $this->users);
$street = Db::table('fa_geo_area')->where(['switch' => 1, 'city_code' => '510500'])
->field('area_id id,area_code code,area_name name')
->select();
View::assign('street', $street);
return view('nk/article/add');
}
}
/**
* 修改
*/
public function edit()
{
$params= get_params();
(new Article())->edit($params);
return view('nk/article/edit',['url'=>$this->url]);
}
/**
* 查看信息
*/
public function read()
{
$params = get_params();
(new Article())->read($params);
return view('nk/article/read',['url'=>$this->url]);
}
/**
* 修改
*/
public function del()
{
$params= get_params();
(new Article())->del($params);
}
}

View File

@ -0,0 +1,171 @@
<?php
namespace app\admin\controller\nk;
// use app\admin\controller\nk\common\Article as ArticleCommon1;
use think\db\exception\DbException as ExceptionDbException;
use think\exception\ValidateException;
use think\facade\Db;
use think\facade\View;
/**
* 教育培训 直播
*
*
CREATE TABLE `fa_article_education_live` (
`id` int unsigned NOT NULL AUTO_INCREMENT COMMENT '主键id',
`article_id` int NOT NULL COMMENT '文章id',
`lesson_period` int unsigned NOT NULL DEFAULT '0' COMMENT '课时',
`tag_ids` varchar(255) DEFAULT NULL COMMENT '文章标签id字符串',
`is_recommend` tinyint unsigned DEFAULT '0' COMMENT '是否推荐',
PRIMARY KEY (`id`),
UNIQUE KEY `article_id_index` (`article_id`) COMMENT '文章id'
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='教育培训类直播文章扩展表';
CREATE TABLE `fa_article_education_live_series` (
`id` int unsigned NOT NULL AUTO_INCREMENT COMMENT '主键id',
`article_id` int unsigned DEFAULT NULL COMMENT '文章id',
`url` varchar(255) DEFAULT NULL COMMENT '视频地址',
`num` int unsigned NOT NULL COMMENT '第几集',
`title` varchar(255) DEFAULT NULL COMMENT '视频标题',
PRIMARY KEY (`id`),
KEY `article_id_index` (`article_id`) COMMENT '文章id'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='教育培训视频文章扩展表';
CREATE TABLE `fa_tag` (
`id` int unsigned NOT NULL AUTO_INCREMENT COMMENT '主键id',
`tag` varchar(255) DEFAULT NULL COMMENT '标签',
`display` tinyint unsigned NOT NULL DEFAULT '0' COMMENT '禁止显示',
PRIMARY KEY (`id`),
KEY `tag_index` (`tag`) COMMENT '标签名'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='标签表';
*/
class EducationLive extends ArticleCommon {
const ARTICLE_EDUCATION_LIVE = 'fa_article_education_live';
const TAG = 'fa_tag';
function __construct()
{
// 课程name
// *课时
// 观看人数
$this->adminInfo = get_login_admin();
$this->category_id = 370;
$this->url=[
'/admin/nk.educationlive/index?category_id='.$this->category_id,
'/admin/nk.educationlive/add',
'/admin/nk.educationlive/edit',
'/admin/nk.educationlive/del',
'/admin/nk.educationlive/read',
];
}
/**
* 查看 待完
*/
function Read() {
$param = get_params();
$id = isset($param['id']) ? $param['id'] : 0;
$detail = Db::table('fa_article')->where('id',$id)->withAttr('lesson',
function($value, $data)use($id){
return Db::table(self::ARTICLE_EDUCATION_LIVE)->field('lesson_period,tag_ids as series_num')->where('article_id', $id)->find();
}
)->find();
// !待开发--课程集数\ 学习人数
// ->withAttr('learner',
// function($value, $data)use($id){
// return Db::table(self::ARTICLE_EDUCATION_LIVE)->field('lesson_period,tag_ids as num')->where('article_id', $id)->find();
// }
// )
// echo '<pre>';print_r($detail);
// exit();
if (!empty($detail)) {
$detail['comment'] = Db::table('fa_article_comment')
->where('vote_id',$id)
->withAttr('user_info',function ($value,$data){
return Db::table('fa_szxc_information_usermsg')->where('user_id',$data['user_id'])->value('name');
})->select();
View::assign('detail', $detail);
View::assign('admin_id', $this->adminInfo['id']);
return view('nk/educationlive/read',['url'=>$this->url]);
}else{
throw new \think\exception\HttpException(404, '找不到页面');
}
}
/**
* 添加
*/
function Add(){
if (request()->isAjax()) {
$params= get_params();
$params['category_id']=$this->category_id;
// unset($params['amp;']);
$this->addArticle($params, function($aid)use($params){
$params['article_id'] = $aid;
return Db::table(self::ARTICLE_EDUCATION_LIVE)->strict(false)->field(true)->insertGetId($params);
});
}else{
View::assign('editor', get_system_config('other','editor'));
View::assign('url', $this->url);
// 获取用户信息
$this->users = Db::table('fa_szxc_information_usermsg')->where('status',1)->field('user_id,name')->select();
View::assign('users', $this->users);
$street = Db::table('fa_geo_area')->where(['switch' => 1, 'city_code' => '510500'])
->field('area_id id,area_code code,area_name name')
->select();
View::assign('street', $street);
return view('nk/educationlive/add');
}
}
/**
* 编辑
*/
function Edit(){
$params= get_params();
$aid = isset($params['id']) ? $params['id'] : 0;
if (request()->isAjax()) {
$this->updateEditData($params, $aid, function($param)use($aid){
if (!empty($param['tags_id'])){
Db::table(self::ARTICLE_EDUCATION_LIVE)->where('article_id',$aid)->update(['tags_id'=>$param['tags_id']]);
}
});
}else{
$this->getEditData($params, $aid, function()use($aid){
return Db::table(self::ARTICLE_EDUCATION_LIVE)->field('lesson_period,tag_ids as series_num')->where('article_id', $aid)->find();
});
}
return view('nk/educationlive/edit',['url'=>$this->url]);
}
/**
* 删除
*/
function Del(){
$param = get_params();
$id = isset($param['id']) ? $param['id'] : 0;
// $type = isset($param['type']) ? $param['type'] : 0;
// 此处同时删除两个表
$res = $this->delArticle($id, function($id){
$vid = Db::table(self::ARTICLE_EDUCATION_LIVE)->where('article_id', $id)->value('id');
if (!empty($vid)) {
return Db::table(self::ARTICLE_EDUCATION_LIVE)->where('id', $vid)->delete();
}else{
return true;
}
});
if ($res["code"]==1){
return to_assign(1, $res['msg']);
}else{
return to_assign();
}
}
}

View File

@ -0,0 +1,93 @@
<?php
namespace app\admin\controller\nk;
use app\admin\BaseController;
use think\exception\ValidateException;
use think\facade\Db;
use app\admin\controller\nk\Article;
use think\facade\View;
/**
* 文章
*
* @icon fa fa-circle-o
*/
class Eliminate extends BaseController
{
public function __construct()
{
$this->adminInfo = get_login_admin();
$this->category_id=149;
$this->url=[
'/admin/nk.eliminate/index?category_id='.$this->category_id,
'/admin/nk.eliminate/add',
'/admin/nk.eliminate/edit',
'/admin/nk.eliminate/del',
'/admin/nk.eliminate/read',
];
}
/**
* 查看
*/
public function index()
{
if (request()->isAjax()) {
$params= get_params();
$params['category_id']=$this->category_id;
(new Article())->index($params);
}
return view('nk/article/index',['url'=>$this->url]);
}
/**
* 添加
*/
public function add()
{
if (request()->isAjax()) {
$params= get_params();
$params['category_id']=$this->category_id;
(new Article())->add($params);
}else{
View::assign('editor', get_system_config('other','editor'));
View::assign('url', $this->url);
// 获取用户信息
$this->users = Db::table('fa_szxc_information_usermsg')->where('status',1)->field('user_id,name')->select();
View::assign('users', $this->users);
$street = Db::table('fa_geo_area')->where(['switch' => 1, 'city_code' => '510500'])
->field('area_id id,area_code code,area_name name')
->select();
View::assign('street', $street);
return view('nk/article/add');
}
}
/**
* 修改
*/
public function edit()
{
$params= get_params();
(new Article())->edit($params);
return view('nk/article/edit',['url'=>$this->url]);
}
/**
* 查看信息
*/
public function read()
{
$params = get_params();
(new Article())->read($params);
return view('nk/article/read',['url'=>$this->url]);
}
/**
* 修改
*/
public function del()
{
$params= get_params();
(new Article())->del($params);
}
}

View File

@ -0,0 +1,234 @@
<?php
namespace app\admin\controller\nk;
use app\admin\BaseController;
use think\facade\Db;
use think\facade\View;
/**
* 农贸市场
*
* @icon fa fa-circle-o
*/
class Farmers extends BaseController
{
/**
* 构造函数
*/
public function __construct()
{
$this->adminInfo = get_login_admin();
$this->url=[
'/admin/nk.farmers/index',
'/admin/nk.farmers/add',
'/admin/nk.farmers/edit',
'/admin/nk.farmers/del',
'/admin/nk.farmers/read',
];
}
/**
* 数据列表
*/
public function index()
{
if (request()->isAjax()) {
$params= get_params();
$where[]= ['status','=',1];
if (isset($params['keywords']) && !empty($params['keywords'])){
$where[]= ['title','like','%'.$params['keywords'].'%'];
}
if($this->adminInfo['position_id'] != 1){ //不是超级管理员
$www['admin_id'] = $this->adminInfo['id'];
$user_address = Db::table('fa_szxc_information_useraddress')->where($www)->find();
if ($user_address){
if($user_address['auth_range'] == 1){
$where[] = ['village_id','=',$user_address['village_id']];
}elseif ($user_address['auth_range'] == 2){
$where[] = ['street_id','=',$user_address['street_id']];
}elseif ($user_address['auth_range'] == 3){
$where[] = ['area_id','=',$user_address['area_id']];
}else{
$where[] = ['village_id','=',$user_address['village_id']];
}
}else{
$where[] = ['village_id','=',''];
}
}
$total = Db::table('cms_farm_product_market')
->where($where)
->count();
$list = Db::table('cms_farm_product_market')
->withAttr('area_id',function ($value,$data){
return Db::table('fa_geo_area')->where('area_code',$data['area_id'])->value('area_name');
})
->withAttr('street_id',function ($value,$data){
return Db::table('fa_geo_street')->where('street_code',$data['street_id'])->value('street_name');
})
->withAttr('village_id',function ($value,$data){
return Db::table('fa_geo_village')->where('village_id',$data['village_id'])->value('village_name');
})
->withAttr('status',function ($value,$data){
if($value == 1){
return '正常';
}else{
return '禁用';
}
})
->where($where)
->page($params['page'])
->limit($params['limit'])
->order('id desc')
->select();
$result = ['total' => $total, 'data' => $list];
return table_assign(0, '', $result);
}
else{
return view('nk/farmers/index',['url'=>$this->url]);
}
}
public function add(){
if (request()->isAjax()) {
$param= get_params();
$adds=Db::table('fa_szxc_information_useraddress')->where('admin_id',$this->adminInfo['id'])->find();
$param['area_id']=$adds['area_id'];
$param['street_id']=$adds['street_id'];
$param['village_id']=$adds['village_id'];
$param['add_time']=date('Y-m-d H:i:s');
$res=Db::table('cms_farm_product_market')->strict(false)->field(true)->insertGetId($param);
if ($res){
return to_assign(0,'操作成功',['aid'=>$res]);
}
return to_assign(1, '操作失败,原因:'.$res);
}else{
View::assign('editor', get_system_config('other','editor'));
return view();
}
}
public function edit(){
$param= get_params();
if (request()->isAjax()) {
$res=Db::table('cms_farm_product_market')->where('id',$param['id'])->strict(false)->field(true)->update($param);
if ($res){
return to_assign();
}else{
return to_assign(1, '操作失败,原因:'.$res);
}
}else{
$id = isset($param['id']) ? $param['id'] : 0;
$detail = Db::table('cms_farm_product_market')->where('id',$id)->find();
View::assign('editor', get_system_config('other','editor'));
if (!empty($detail)) {
View::assign('detail', $detail);
return view();
}
else{
throw new \think\exception\HttpException(404, '找不到页面');
}
}
}
/**
* 查看信息
*/
public function read()
{
$param= get_params();
$id = isset($param['id']) ? $param['id'] : 0;
$detail = Db::table('cms_farm_product_market')->where('id',$id)->find();
if (!empty($detail)) {
View::assign('detail', $detail);
if($this->adminInfo['position_id'] != 1){ //不是超级管理员
$www['admin_id'] = $this->adminInfo['id'];
$user_address = Db::table('fa_szxc_information_useraddress')->where($www)->find();
if ($user_address){
if($user_address['auth_range'] == 1){
$where[] = ['village_id','=',$user_address['village_id']];
}elseif ($user_address['auth_range'] == 2){
$where[] = ['street_id','=',$user_address['street_id']];
}elseif ($user_address['auth_range'] == 3){
$where[] = ['area_id','=',$user_address['area_id']];
}else{
$where[] = ['village_id','=',$user_address['village_id']];
}
}else{
$where[] = ['village_id','=',''];
}
}else{
$where = [];
}
$farmers = Db::table('cms_manufacturer')->where($where)->where('status',1)->select()->toArray();
if($farmers){
foreach ($farmers as $k =>$v){
$farmers[$k]['juli'] = $this->getDistance($detail['lng'],$detail['lat'],$v['lng'],$v['lat'],2);
}
}else{
$farmers = [];
}
View::assign('farmers', $farmers);
return view();
}
else{
throw new \think\exception\HttpException(404, '找不到页面');
}
}
/**
* 计算两点地理坐标之间的距离
* @param Decimal $longitude1 起点经度
* @param Decimal $latitude1 起点纬度
* @param Decimal $longitude2 终点经度
* @param Decimal $latitude2 终点纬度
* @param Int $unit 单位 1: 2:公里
* @param Int $decimal 精度 保留小数位数
* @return Decimal
*/
function getDistance($longitude1, $latitude1, $longitude2, $latitude2, $unit=2, $decimal=2){
$EARTH_RADIUS = 6370.996; // 地球半径系数
$PI = 3.1415926;
$radLat1 = $latitude1 * $PI / 180.0;
$radLat2 = $latitude2 * $PI / 180.0;
$radLng1 = $longitude1 * $PI / 180.0;
$radLng2 = $longitude2 * $PI /180.0;
$a = $radLat1 - $radLat2;
$b = $radLng1 - $radLng2;
$distance = 2 * asin(sqrt(pow(sin($a/2),2) + cos($radLat1) * cos($radLat2) * pow(sin($b/2),2)));
$distance = $distance * $EARTH_RADIUS * 1000;
if($unit==2){
$distance = $distance / 1000;
}
return round($distance, $decimal);
}
/**
* 删除
*/
public function del()
{
$param= get_params();
$id = isset($param['id']) ? $param['id'] : 0;
$type = isset($param['type']) ? $param['type'] : 0;
$res = Db::table('cms_farm_product_market')->where('id',$id)->delete();
if ($res){
return to_assign();
}else{
return to_assign(1, '操作失败,原因:'.$res);
}
}
}

View File

@ -0,0 +1,172 @@
<?php
namespace app\admin\controller\nk;
use app\admin\BaseController;
use think\facade\Db;
use think\facade\View;
use app\api\model\Area as AreaModel; // 市场区域模型
use think\facade\Log;
/**
* 农贸市场区域管理
*
* @icon fa fa-circle-o
*/
class Farmersarea extends BaseController
{
/**
* 构造函数
*/
public function __construct()
{
$this->adminInfo = get_login_admin();
$this->url=[
'/admin/nk.farmersarea/index',
'/admin/nk.farmersarea/add',
'/admin/nk.farmersarea/edit',
'/admin/nk.farmersarea/del',
'/admin/nk.farmersarea/read',
];
}
/**
* 数据列表
*/
public function index()
{
if (request()->isAjax()) {
$params= get_params();
$where[]= ['status','=',0];
if (isset($params['keywords']) && !empty($params['keywords'])){
$where[]= ['area_name','like','%'.$params['keywords'].'%'];
}
if($this->adminInfo['position_id'] != 1){ //不是超级管理员
$www['admin_id'] = $this->adminInfo['id'];
$user_address = Db::table('fa_szxc_information_useraddress')->where($www)->find();
if ($user_address){
if($user_address['auth_range'] == 1){
$where[] = ['village_id','=',$user_address['village_id']];
}elseif ($user_address['auth_range'] == 2){
$where[] = ['street_id','=',$user_address['street_id']];
}elseif ($user_address['auth_range'] == 3){
$where[] = ['area_id','=',$user_address['area_id']];
}else{
$where[] = ['village_id','=',$user_address['village_id']];
}
}else{
$where[] = ['village_id','=',''];
}
}
$total = AreaModel::where($where)->count();
$list = AreaModel::with('FarmProductMarket')
->where($where)
->page($params['page'])
->limit($params['limit'])
->order('id desc')
->select();
$result = ['total' => $total, 'data' => $list];
return table_assign(0, '', $result);
}
else{
return view('nk/farmersarea/index',['url'=>$this->url]);
}
}
public function add(){
if (request()->isAjax()) {
$param = get_params();
$data['user_id'] = $this->adminInfo['id']; // 操作用户ID
$data['area_name'] = $param['area_name']; // 区域名称
$data['farm_product_market_id'] = $param['farm_product_market_id']; // 所属农贸市场
$data['created_at'] = date('Y-m-d H:i:s');
$res = AreaModel::create($data); // 数据入库
if ($res){
return to_assign(0,'操作成功',['aid'=>$res]);
}
return to_assign(1, '操作失败,原因:'.$res);
}else{
// 农贸市场数据列表
$farmProductMarket = Db::table('cms_farm_product_market')->column('id, title');
View::assign('farmProductMarket', $farmProductMarket);
View::assign('editor', get_system_config('other','editor'));
return view();
}
}
public function edit(){
$param= get_params();
if (request()->isAjax()) {
$param = get_params();
$data['user_id'] = $this->adminInfo['id']; // 操作用户ID
$data['area_name'] = $param['area_name']; // 区域名称
$data['farm_product_market_id'] = $param['farm_product_market_id']; // 所属农贸市场
$data['updated_at'] = date('Y-m-d H:i:s');
$res = AreaModel::where('id', $param['id'])->update($data); // 数据入库
if ($res){
return to_assign();
}else{
return to_assign(1, '操作失败,原因:'.$res);
}
}else{
$id = isset($param['id']) ? $param['id'] : 0;
$detail = AreaModel::find($id);
// 农贸市场数据列表
$farmProductMarket = Db::table('cms_farm_product_market')->column('id, title');
View::assign('farmProductMarket', $farmProductMarket);
View::assign('editor', get_system_config('other','editor'));
if (!empty($detail)) {
View::assign('detail', $detail);
return view();
}
else{
throw new \think\exception\HttpException(404, '找不到页面');
}
}
}
/**
* 删除
*/
public function del()
{
$param= get_params();
$area = AreaModel::find($param['id']);
$res = $area->delete();
if ($res){
return to_assign();
}else{
return to_assign(1, '操作失败,原因:'.$res);
}
}
}

View File

@ -0,0 +1,93 @@
<?php
namespace app\admin\controller\nk;
use app\admin\BaseController;
use think\exception\ValidateException;
use think\facade\Db;
use app\admin\controller\nk\Article;
use think\facade\View;
/**
* 文章
*
* @icon fa fa-circle-o
*/
class Farming extends BaseController
{
public function __construct()
{
$this->adminInfo = get_login_admin();
$this->category_id=311;
$this->url=[
'/admin/nk.farming/index?category_id='.$this->category_id,
'/admin/nk.farming/add',
'/admin/nk.farming/edit',
'/admin/nk.farming/del',
'/admin/nk.farming/read',
];
}
/**
* 查看
*/
public function index()
{
if (request()->isAjax()) {
$params= get_params();
$params['category_id']=$this->category_id;
(new Article())->index($params);
}
return view('nk/article/index',['url'=>$this->url]);
}
/**
* 添加
*/
public function add()
{
if (request()->isAjax()) {
$params= get_params();
$params['category_id']=$this->category_id;
(new Article())->add($params);
}else{
View::assign('editor', get_system_config('other','editor'));
View::assign('url', $this->url);
// 获取用户信息
$this->users = Db::table('fa_szxc_information_usermsg')->where('status',1)->field('user_id,name')->select();
View::assign('users', $this->users);
$street = Db::table('fa_geo_area')->where(['switch' => 1, 'city_code' => '510500'])
->field('area_id id,area_code code,area_name name')
->select();
View::assign('street', $street);
return view('nk/article/add');
}
}
/**
* 修改
*/
public function edit()
{
$params= get_params();
(new Article())->edit($params);
return view('nk/article/edit',['url'=>$this->url]);
}
/**
* 查看信息
*/
public function read()
{
$params = get_params();
(new Article())->read($params);
return view('nk/article/read',['url'=>$this->url]);
}
/**
* 修改
*/
public function del()
{
$params= get_params();
(new Article())->del($params);
}
}

View File

@ -0,0 +1,93 @@
<?php
namespace app\admin\controller\nk;
use app\admin\BaseController;
use think\exception\ValidateException;
use think\facade\Db;
use app\admin\controller\nk\Article;
use think\facade\View;
/**
* 文章
*
* @icon fa fa-circle-o
*/
class Feedback extends BaseController
{
public function __construct()
{
$this->adminInfo = get_login_admin();
$this->category_id=165;
$this->url=[
'/admin/nk.feedback/index?category_id='.$this->category_id,
'/admin/nk.feedback/add',
'/admin/nk.feedback/edit',
'/admin/nk.feedback/del',
'/admin/nk.feedback/read',
];
}
/**
* 查看
*/
public function index()
{
if (request()->isAjax()) {
$params= get_params();
$params['category_id']=$this->category_id;
(new Article())->index($params);
}
return view('nk/article/index',['url'=>$this->url]);
}
/**
* 添加
*/
public function add()
{
if (request()->isAjax()) {
$params= get_params();
$params['category_id']=$this->category_id;
(new Article())->add($params);
}else{
View::assign('editor', get_system_config('other','editor'));
View::assign('url', $this->url);
// 获取用户信息
$this->users = Db::table('fa_szxc_information_usermsg')->where('status',1)->field('user_id,name')->select();
View::assign('users', $this->users);
$street = Db::table('fa_geo_area')->where(['switch' => 1, 'city_code' => '510500'])
->field('area_id id,area_code code,area_name name')
->select();
View::assign('street', $street);
return view('nk/article/add');
}
}
/**
* 修改
*/
public function edit()
{
$params= get_params();
(new Article())->edit($params);
return view('nk/article/edit',['url'=>$this->url]);
}
/**
* 查看信息
*/
public function read()
{
$params = get_params();
(new Article())->read($params);
return view('nk/article/read',['url'=>$this->url]);
}
/**
* 修改
*/
public function del()
{
$params= get_params();
(new Article())->del($params);
}
}

View File

@ -0,0 +1,93 @@
<?php
namespace app\admin\controller\nk;
use app\admin\BaseController;
use think\exception\ValidateException;
use think\facade\Db;
use app\admin\controller\nk\Article;
use think\facade\View;
/**
* 文章
*
* @icon fa fa-circle-o
*/
class Finance extends BaseController
{
public function __construct()
{
$this->adminInfo = get_login_admin();
$this->category_id=161;
$this->url=[
'/admin/nk.finance/index?category_id='.$this->category_id,
'/admin/nk.finance/add',
'/admin/nk.finance/edit',
'/admin/nk.finance/del',
'/admin/nk.finance/read',
];
}
/**
* 查看
*/
public function index()
{
if (request()->isAjax()) {
$params= get_params();
$params['category_id']=$this->category_id;
(new Article())->index($params);
}
return view('nk/article/index',['url'=>$this->url]);
}
/**
* 添加
*/
public function add()
{
if (request()->isAjax()) {
$params= get_params();
$params['category_id']=$this->category_id;
(new Article())->add($params);
}else{
View::assign('editor', get_system_config('other','editor'));
View::assign('url', $this->url);
// 获取用户信息
$this->users = Db::table('fa_szxc_information_usermsg')->where('status',1)->field('user_id,name')->select();
View::assign('users', $this->users);
$street = Db::table('fa_geo_area')->where(['switch' => 1, 'city_code' => '510500'])
->field('area_id id,area_code code,area_name name')
->select();
View::assign('street', $street);
return view('nk/article/add');
}
}
/**
* 修改
*/
public function edit()
{
$params= get_params();
(new Article())->edit($params);
return view('nk/article/edit',['url'=>$this->url]);
}
/**
* 查看信息
*/
public function read()
{
$params = get_params();
(new Article())->read($params);
return view('nk/article/read',['url'=>$this->url]);
}
/**
* 修改
*/
public function del()
{
$params= get_params();
(new Article())->del($params);
}
}

View File

@ -0,0 +1,93 @@
<?php
namespace app\admin\controller\nk;
use app\admin\BaseController;
use think\exception\ValidateException;
use think\facade\Db;
use app\admin\controller\nk\Article;
use think\facade\View;
/**
* 文章
*
* @icon fa fa-circle-o
*/
class Fishing extends BaseController
{
public function __construct()
{
$this->adminInfo = get_login_admin();
$this->category_id=310;
$this->url=[
'/admin/nk.fishing/index?category_id='.$this->category_id,
'/admin/nk.fishing/add',
'/admin/nk.fishing/edit',
'/admin/nk.fishing/del',
'/admin/nk.fishing/read',
];
}
/**
* 查看
*/
public function index()
{
if (request()->isAjax()) {
$params= get_params();
$params['category_id']=$this->category_id;
(new Article())->index($params);
}
return view('nk/article/index',['url'=>$this->url]);
}
/**
* 添加
*/
public function add()
{
if (request()->isAjax()) {
$params= get_params();
$params['category_id']=$this->category_id;
(new Article())->add($params);
}else{
View::assign('editor', get_system_config('other','editor'));
View::assign('url', $this->url);
// 获取用户信息
$this->users = Db::table('fa_szxc_information_usermsg')->where('status',1)->field('user_id,name')->select();
View::assign('users', $this->users);
$street = Db::table('fa_geo_area')->where(['switch' => 1, 'city_code' => '510500'])
->field('area_id id,area_code code,area_name name')
->select();
View::assign('street', $street);
return view('nk/article/add');
}
}
/**
* 修改
*/
public function edit()
{
$params= get_params();
(new Article())->edit($params);
return view('nk/article/edit',['url'=>$this->url]);
}
/**
* 查看信息
*/
public function read()
{
$params = get_params();
(new Article())->read($params);
return view('nk/article/read',['url'=>$this->url]);
}
/**
* 修改
*/
public function del()
{
$params= get_params();
(new Article())->del($params);
}
}

View File

@ -0,0 +1,93 @@
<?php
namespace app\admin\controller\nk;
use app\admin\BaseController;
use think\exception\ValidateException;
use think\facade\Db;
use app\admin\controller\nk\Article;
use think\facade\View;
/**
* 文章
*
* @icon fa fa-circle-o
*/
class Food extends BaseController
{
public function __construct()
{
$this->adminInfo = get_login_admin();
$this->category_id=307;
$this->url=[
'/admin/nk.food/index?category_id='.$this->category_id,
'/admin/nk.food/add',
'/admin/nk.food/edit',
'/admin/nk.food/del',
'/admin/nk.food/read',
];
}
/**
* 查看
*/
public function index()
{
if (request()->isAjax()) {
$params= get_params();
$params['category_id']=$this->category_id;
(new Article())->index($params);
}
return view('nk/article/index',['url'=>$this->url]);
}
/**
* 添加
*/
public function add()
{
if (request()->isAjax()) {
$params= get_params();
$params['category_id']=$this->category_id;
(new Article())->add($params);
}else{
View::assign('editor', get_system_config('other','editor'));
View::assign('url', $this->url);
// 获取用户信息
$this->users = Db::table('fa_szxc_information_usermsg')->where('status',1)->field('user_id,name')->select();
View::assign('users', $this->users);
$street = Db::table('fa_geo_area')->where(['switch' => 1, 'city_code' => '510500'])
->field('area_id id,area_code code,area_name name')
->select();
View::assign('street', $street);
return view('nk/article/add');
}
}
/**
* 修改
*/
public function edit()
{
$params= get_params();
(new Article())->edit($params);
return view('nk/article/edit',['url'=>$this->url]);
}
/**
* 查看信息
*/
public function read()
{
$params = get_params();
(new Article())->read($params);
return view('nk/article/read',['url'=>$this->url]);
}
/**
* 修改
*/
public function del()
{
$params= get_params();
(new Article())->del($params);
}
}

View File

@ -0,0 +1,93 @@
<?php
namespace app\admin\controller\nk;
use app\admin\BaseController;
use think\exception\ValidateException;
use think\facade\Db;
use app\admin\controller\nk\Article;
use think\facade\View;
/**
* 文章
*
* @icon fa fa-circle-o
*/
class Government extends BaseController
{
public function __construct()
{
$this->adminInfo = get_login_admin();
$this->category_id=301;
$this->url=[
'/admin/nk.government/index?category_id='.$this->category_id,
'/admin/nk.government/add',
'/admin/nk.government/edit',
'/admin/nk.government/del',
'/admin/nk.government/read',
];
}
/**
* 查看
*/
public function index()
{
if (request()->isAjax()) {
$params= get_params();
$params['category_id']=$this->category_id;
(new Article())->index($params);
}
return view('nk/article/index',['url'=>$this->url]);
}
/**
* 添加
*/
public function add()
{
if (request()->isAjax()) {
$params= get_params();
$params['category_id']=$this->category_id;
(new Article())->add($params);
}else{
View::assign('editor', get_system_config('other','editor'));
View::assign('url', $this->url);
// 获取用户信息
$this->users = Db::table('fa_szxc_information_usermsg')->where('status',1)->field('user_id,name')->select();
View::assign('users', $this->users);
$street = Db::table('fa_geo_area')->where(['switch' => 1, 'city_code' => '510500'])
->field('area_id id,area_code code,area_name name')
->select();
View::assign('street', $street);
return view('nk/article/add');
}
}
/**
* 修改
*/
public function edit()
{
$params= get_params();
(new Article())->edit($params);
return view('nk/article/edit',['url'=>$this->url]);
}
/**
* 查看信息
*/
public function read()
{
$params = get_params();
(new Article())->read($params);
return view('nk/article/read',['url'=>$this->url]);
}
/**
* 修改
*/
public function del()
{
$params= get_params();
(new Article())->del($params);
}
}

View File

@ -0,0 +1,93 @@
<?php
namespace app\admin\controller\nk;
use app\admin\BaseController;
use think\exception\ValidateException;
use think\facade\Db;
use app\admin\controller\nk\Article;
use think\facade\View;
/**
* 文章
*
* @icon fa fa-circle-o
*/
class Heresy extends BaseController
{
public function __construct()
{
$this->adminInfo = get_login_admin();
$this->category_id=148;
$this->url=[
'/admin/nk.heresy/index?category_id='.$this->category_id,
'/admin/nk.heresy/add',
'/admin/nk.heresy/edit',
'/admin/nk.heresy/del',
'/admin/nk.heresy/read',
];
}
/**
* 查看
*/
public function index()
{
if (request()->isAjax()) {
$params= get_params();
$params['category_id']=$this->category_id;
(new Article())->index($params);
}
return view('nk/article/index',['url'=>$this->url]);
}
/**
* 添加
*/
public function add()
{
if (request()->isAjax()) {
$params= get_params();
$params['category_id']=$this->category_id;
(new Article())->add($params);
}else{
View::assign('editor', get_system_config('other','editor'));
View::assign('url', $this->url);
// 获取用户信息
$this->users = Db::table('fa_szxc_information_usermsg')->where('status',1)->field('user_id,name')->select();
View::assign('users', $this->users);
$street = Db::table('fa_geo_area')->where(['switch' => 1, 'city_code' => '510500'])
->field('area_id id,area_code code,area_name name')
->select();
View::assign('street', $street);
return view('nk/article/add');
}
}
/**
* 修改
*/
public function edit()
{
$params= get_params();
(new Article())->edit($params);
return view('nk/article/edit',['url'=>$this->url]);
}
/**
* 查看信息
*/
public function read()
{
$params = get_params();
(new Article())->read($params);
return view('nk/article/read',['url'=>$this->url]);
}
/**
* 修改
*/
public function del()
{
$params= get_params();
(new Article())->del($params);
}
}

View File

@ -0,0 +1,21 @@
<?php
namespace app\admin\controller\nk;
/**
* 房屋装修
* -- 精品案例
*/
class HouseDecorationCase extends ArticleCommon{
function __construct()
{
$this->category_id = 371;
$this->url=[
'/admin/nk.housedecorationcase/index?category_id='.$this->category_id,
'/admin/nk.housedecorationcase/add',
'/admin/nk.housedecorationcase/edit',
'/admin/nk.housedecorationcase/del',
'/admin/nk.housedecorationcase/read',
];
}
}

View File

@ -0,0 +1,21 @@
<?php
namespace app\admin\controller\nk;
/**
* 房屋装修
* -- 推荐商家
*/
class HouseDecorationCompany extends ArticleCommon{
function __construct()
{
$this->category_id = 372;
$this->url=[
'/admin/nk.housedecorationcompany/index?category_id='.$this->category_id,
'/admin/nk.housedecorationcompany/add',
'/admin/nk.housedecorationcompany/edit',
'/admin/nk.housedecorationcompany/del',
'/admin/nk.housedecorationcompany/read',
];
}
}

View File

@ -0,0 +1,93 @@
<?php
namespace app\admin\controller\nk;
use app\admin\BaseController;
use think\exception\ValidateException;
use think\facade\Db;
use app\admin\controller\nk\Article;
use think\facade\View;
/**
* 文章
*
* @icon fa fa-circle-o
*/
class Industry extends BaseController
{
public function __construct()
{
$this->adminInfo = get_login_admin();
$this->category_id=312;
$this->url=[
'/admin/nk.industry/index?category_id='.$this->category_id,
'/admin/nk.industry/add',
'/admin/nk.industry/edit',
'/admin/nk.industry/del',
'/admin/nk.industry/read',
];
}
/**
* 查看
*/
public function index()
{
if (request()->isAjax()) {
$params= get_params();
$params['category_id']=$this->category_id;
(new Article())->index($params);
}
return view('nk/article/index',['url'=>$this->url]);
}
/**
* 添加
*/
public function add()
{
if (request()->isAjax()) {
$params= get_params();
$params['category_id']=$this->category_id;
(new Article())->add($params);
}else{
View::assign('editor', get_system_config('other','editor'));
View::assign('url', $this->url);
// 获取用户信息
$this->users = Db::table('fa_szxc_information_usermsg')->where('status',1)->field('user_id,name')->select();
View::assign('users', $this->users);
$street = Db::table('fa_geo_area')->where(['switch' => 1, 'city_code' => '510500'])
->field('area_id id,area_code code,area_name name')
->select();
View::assign('street', $street);
return view('nk/article/add');
}
}
/**
* 修改
*/
public function edit()
{
$params= get_params();
(new Article())->edit($params);
return view('nk/article/edit',['url'=>$this->url]);
}
/**
* 查看信息
*/
public function read()
{
$params = get_params();
(new Article())->read($params);
return view('nk/article/read',['url'=>$this->url]);
}
/**
* 修改
*/
public function del()
{
$params= get_params();
(new Article())->del($params);
}
}

View File

@ -0,0 +1,187 @@
<?php
namespace app\admin\controller\nk;
use app\admin\BaseController;
use think\facade\Db;
use think\facade\View;
/**
* 农产品成熟周期
*
* @icon fa fa-circle-o
*/
class Maturity extends BaseController
{
/**
* 构造函数
*/
public function __construct()
{
$this->adminInfo = get_login_admin();
$this->url=[
'/admin/nk.maturity/index',
'/admin/nk.maturity/add',
'/admin/nk.maturity/edit',
'/admin/nk.maturity/del',
'/admin/nk.maturity/read',
];
}
/**
* 数据列表
*/
public function index()
{
if (request()->isAjax()) {
$params= get_params();
$where[]= ['status','=',1];
if (isset($params['keywords']) && !empty($params['keywords'])){
$where[]= ['title','like','%'.$params['keywords'].'%'];
}
if($this->adminInfo['position_id'] != 1){ //不是超级管理员
$www['admin_id'] = $this->adminInfo['id'];
$user_address = Db::table('fa_szxc_information_useraddress')->where($www)->find();
if ($user_address){
if($user_address['auth_range'] == 1){
$where[] = ['village_id','=',$user_address['village_id']];
}elseif ($user_address['auth_range'] == 2){
$where[] = ['street_id','=',$user_address['street_id']];
}elseif ($user_address['auth_range'] == 3){
$where[] = ['area_id','=',$user_address['area_id']];
}else{
$where[] = ['village_id','=',$user_address['village_id']];
}
}
}
$total = Db::table('cms_agriculture_products')
->where($where)
->count();
$list = Db::table('cms_agriculture_products')
->withAttr('area_id',function ($value,$data){
return Db::table('fa_geo_area')->where('area_code',$data['area_id'])->value('area_name');
})
->withAttr('street_id',function ($value,$data){
return Db::table('fa_geo_street')->where('street_code',$data['street_id'])->value('street_name');
})
->withAttr('village_id',function ($value,$data){
return Db::table('fa_geo_village')->where('village_id',$data['village_id'])->value('village_name');
})
->withAttr('image',function ($value,$data){
return Db::table('fa_szxc_planting_type')->where('id',$data['szxc_planting_type_id'])->value('image');
})
->withAttr('status',function ($value,$data){
if($value == 1){
return '正常';
}else{
return '禁用';
}
})
->where($where)
->page($params['page'])
->limit($params['limit'])
->order('id desc')
->select();
$result = ['total' => $total, 'data' => $list];
return table_assign(0, '', $result);
}
return view('',['url'=>$this->url]);
}
public function add(){
if (request()->isAjax()) {
$param= get_params();
$adds=Db::table('fa_szxc_information_useraddress')->where('admin_id',$this->adminInfo['id'])->find();
$param['area_id']=$adds['area_id'];
$param['street_id']=$adds['street_id'];
$param['village_id']=$adds['village_id'];
$param['add_time']=date('Y-m-d H:i:s');
$param['cycle']=json_encode(['start_time'=>$param['start_time'],'end_time'=>$param['end_time'],'zhouqi'=>$param['zhouqi']]);
$param['title'] = Db::table('fa_szxc_planting_type')->where('id',$param['szxc_planting_type_id'])->value('name');
$res=Db::table('cms_agriculture_products')->strict(false)->field(true)->insertGetId($param);
if ($res){
return to_assign(0,'操作成功',['aid'=>$res]);
}
return to_assign(1, '操作失败,原因:'.$res);
}else{
View::assign('url', $this->url);
View::assign('editor', get_system_config('other','editor'));
$szxc_planting_type = Db::table('fa_szxc_planting_type')->select();
View::assign('szxc_planting_type', $szxc_planting_type);
return view();
}
}
public function edit(){
$param= get_params();
if (request()->isAjax()) {
$param['title'] = Db::table('fa_szxc_planting_type')->where('id',$param['szxc_planting_type_id'])->value('name');
$param['cycle']=json_encode(['start_time'=>$param['start_time'],'end_time'=>$param['end_time'],'zhouqi'=>$param['zhouqi']]);
$res=Db::table('cms_agriculture_products')->where('id',$param['id'])->strict(false)->field(true)->update($param);
if ($res){
return to_assign();
}else{
return to_assign(1, '操作失败,原因:'.$res);
}
}else{
$id = isset($param['id']) ? $param['id'] : 0;
$detail = Db::table('cms_agriculture_products')
->withAttr('cycle',function($value,$data){
return json_decode($value,true);
})
->where('id',$id)->find();
View::assign('editor', get_system_config('other','editor'));
if (!empty($detail)) {
View::assign('detail', $detail);
$szxc_planting_type = Db::table('fa_szxc_planting_type')->select();
View::assign('szxc_planting_type', $szxc_planting_type);
return view();
}
else{
throw new \think\exception\HttpException(404, '找不到页面');
}
}
}
/**
* 查看信息
*/
public function read()
{
$param= get_params();
$id = isset($param['id']) ? $param['id'] : 0;
$detail = Db::table('cms_agriculture_products')->where('id',$id)
->withAttr('cycle',function($value,$data){
return json_decode($value,true);
})
->find();
if (!empty($detail)) {
View::assign('detail', $detail);
$szxc_planting_type = Db::table('fa_szxc_planting_type')->select();
View::assign('szxc_planting_type', $szxc_planting_type);
return view();
}
else{
throw new \think\exception\HttpException(404, '找不到页面');
}
}
/**
* 删除
*/
public function del()
{
$param= get_params();
$id = isset($param['id']) ? $param['id'] : 0;
$type = isset($param['type']) ? $param['type'] : 0;
$res = Db::table('cms_agriculture_products')->where('id',$id)->delete();
if ($res){
return to_assign();
}else{
return to_assign(1, '操作失败,原因:'.$res);
}
}
}

View File

@ -0,0 +1,93 @@
<?php
namespace app\admin\controller\nk;
use app\admin\BaseController;
use think\exception\ValidateException;
use think\facade\Db;
use app\admin\controller\nk\Article;
use think\facade\View;
/**
* 文章
*
* @icon fa fa-circle-o
*/
class Mediation extends BaseController
{
public function __construct()
{
$this->adminInfo = get_login_admin();
$this->category_id=147;
$this->url=[
'/admin/nk.mediation/index?category_id='.$this->category_id,
'/admin/nk.mediation/add',
'/admin/nk.mediation/edit',
'/admin/nk.mediation/del',
'/admin/nk.mediation/read',
];
}
/**
* 查看
*/
public function index()
{
if (request()->isAjax()) {
$params= get_params();
$params['category_id']=$this->category_id;
(new Article())->index($params);
}
return view('nk/article/index',['url'=>$this->url]);
}
/**
* 添加
*/
public function add()
{
if (request()->isAjax()) {
$params= get_params();
$params['category_id']=$this->category_id;
(new Article())->add($params);
}else{
View::assign('editor', get_system_config('other','editor'));
View::assign('url', $this->url);
// 获取用户信息
$this->users = Db::table('fa_szxc_information_usermsg')->where('status',1)->field('user_id,name')->select();
View::assign('users', $this->users);
$street = Db::table('fa_geo_area')->where(['switch' => 1, 'city_code' => '510500'])
->field('area_id id,area_code code,area_name name')
->select();
View::assign('street', $street);
return view('nk/article/add');
}
}
/**
* 修改
*/
public function edit()
{
$params= get_params();
(new Article())->edit($params);
return view('nk/article/edit',['url'=>$this->url]);
}
/**
* 查看信息
*/
public function read()
{
$params = get_params();
(new Article())->read($params);
return view('nk/article/read',['url'=>$this->url]);
}
/**
* 修改
*/
public function del()
{
$params= get_params();
(new Article())->del($params);
}
}

View File

@ -0,0 +1,95 @@
<?php
namespace app\admin\controller\nk;
use app\admin\BaseController;
use think\exception\ValidateException;
use think\facade\Db;
use app\admin\controller\nk\Article;
use think\facade\View;
/**
* 文章
*
* @icon fa fa-circle-o
*/
class Meeting extends BaseController
{
public function __construct()
{
$this->adminInfo = get_login_admin();
$this->category_id=162;
$this->url=[
'/admin/nk.meeting/index?category_id='.$this->category_id,
'/admin/nk.meeting/add',
'/admin/nk.meeting/edit',
'/admin/nk.meeting/del',
'/admin/nk.meeting/read',
];
}
/**
* 查看
*/
public function index()
{
if (request()->isAjax()) {
$params= get_params();
$params['category_id']=$this->category_id;
(new Article())->index($params);
}
return view('nk/article/index',['url'=>$this->url]);
}
/**
* 添加
*/
public function add()
{
if (request()->isAjax()) {
$params= get_params();
$params['category_id']=$this->category_id;
(new Article())->add($params);
}else{
View::assign('editor', get_system_config('other','editor'));
View::assign('url', $this->url);
// 获取用户信息
$this->users = Db::table('fa_szxc_information_usermsg')->where('status',1)->field('user_id,name')->select();
View::assign('users', $this->users);
$street = Db::table('fa_geo_area')->where(['switch' => 1, 'city_code' => '510500'])
->field('area_id id,area_code code,area_name name')
->select();
View::assign('street', $street);
View::assign('is_vote', 1);
return view('nk/article/add');
}
}
/**
* 修改
*/
public function edit()
{
$params= get_params();
(new Article())->edit($params);
View::assign('is_vote', 1);
return view('nk/article/edit',['url'=>$this->url]);
}
/**
* 查看信息
*/
public function read()
{
$params = get_params();
(new Article())->read($params);
return view('nk/article/read',['url'=>$this->url]);
}
/**
* 修改
*/
public function del()
{
$params= get_params();
(new Article())->del($params);
}
}

View File

@ -0,0 +1,76 @@
<?php
namespace app\admin\controller\nk;
use app\admin\BaseController;
use think\facade\Db;
use think\facade\View;
/**
* 区域订单手续费(佣金)管理
*
* @icon fa fa-circle-o
*/
class Merchant extends BaseController
{
public function __construct()
{
$this->adminInfo = get_login_admin();
$this->url=[
'/admin/nk.merchant/index',
'/admin/nk.merchant/read',
];
}
/**
* 查看
*/
public function index()
{
$total=0;
$list=[];
$brokerage_price=0;
$find=Db::table('fa_szxc_information_useraddress')->where('user_id',$this->adminInfo['id'])->value('street_id');
if (request()->isAjax()) {
$params= get_params();
if ($find!=0){
$total=Db::connect('shop')->name('merchant_address')->where('street_id',$find)
->where('status',1)->count();
$merchant_id=Db::connect('shop')->name('merchant_address')->where('street_id',$find)
->where('status',1)
->page($params['page'])
->limit($params['limit'])
->field('mer_id')->select();
$arr=[];
foreach ($merchant_id as $k=>$v){
$arr[]=$v['mer_id'];
}
$list=Db::connect('shop')->name('merchant')->where('mer_id','in',$arr)->field('mer_id,mer_name,real_name,mark,create_time,sales,mer_money,margin')->select();
}
$result = ['total' => $total, 'data' => $list];
return table_assign(0, '', $result);
}
return view('',['url'=>$this->url]);
}
/**
* 查看信息
*/
public function read()
{
$params = get_params();
$find=Db::connect('shop')->name('merchant')->where('mer_id',$params['id'])
->withAttr('is_trader',function ($value,$data){
return $value==1?'自营':'非自营';
})
->withAttr('category_id',function ($value,$data){
return Db::connect('shop')->name('merchant_category')->where('merchant_category_id ',$value)->value('category_name');
})
->withAttr('type_id',function ($value,$data){
return Db::connect('shop')->name('merchant_type')->where('mer_type_id ',$value)->value('type_name');
})
->find();
return view('',['url'=>$this->url,'read'=>$find]);
}
}

View File

@ -0,0 +1,93 @@
<?php
namespace app\admin\controller\nk;
use app\admin\BaseController;
use think\exception\ValidateException;
use think\facade\Db;
use app\admin\controller\nk\Article;
use think\facade\View;
/**
* 文章
*
* @icon fa fa-circle-o
*/
class Party extends BaseController
{
public function __construct()
{
$this->adminInfo = get_login_admin();
$this->category_id=176;
$this->url=[
'/admin/nk.party/index?category_id='.$this->category_id,
'/admin/nk.party/add',
'/admin/nk.party/edit',
'/admin/nk.party/del',
'/admin/nk.party/read',
];
}
/**
* 查看
*/
public function index()
{
if (request()->isAjax()) {
$params= get_params();
$params['category_id']=$this->category_id;
(new Article())->index($params);
}
return view('nk/article/index',['url'=>$this->url]);
}
/**
* 添加
*/
public function add()
{
if (request()->isAjax()) {
$params= get_params();
$params['category_id']=$this->category_id;
(new Article())->add($params);
}else{
View::assign('editor', get_system_config('other','editor'));
View::assign('url', $this->url);
// 获取用户信息
$this->users = Db::table('fa_szxc_information_usermsg')->where('status',1)->field('user_id,name')->select();
View::assign('users', $this->users);
$street = Db::table('fa_geo_area')->where(['switch' => 1, 'city_code' => '510500'])
->field('area_id id,area_code code,area_name name')
->select();
View::assign('street', $street);
return view('nk/article/add');
}
}
/**
* 修改
*/
public function edit()
{
$params= get_params();
(new Article())->edit($params);
return view('nk/article/edit',['url'=>$this->url]);
}
/**
* 查看信息
*/
public function read()
{
$params = get_params();
(new Article())->read($params);
return view('nk/article/read',['url'=>$this->url]);
}
/**
* 修改
*/
public function del()
{
$params= get_params();
(new Article())->del($params);
}
}

View File

@ -0,0 +1,93 @@
<?php
namespace app\admin\controller\nk;
use app\admin\BaseController;
use think\exception\ValidateException;
use think\facade\Db;
use app\admin\controller\nk\Article;
use think\facade\View;
/**
* 文章
*
* @icon fa fa-circle-o
*/
class People extends BaseController
{
public function __construct()
{
$this->adminInfo = get_login_admin();
$this->category_id=152;
$this->url=[
'/admin/nk.people/index?category_id='.$this->category_id,
'/admin/nk.people/add',
'/admin/nk.people/edit',
'/admin/nk.people/del',
'/admin/nk.people/read',
];
}
/**
* 查看
*/
public function index()
{
if (request()->isAjax()) {
$params= get_params();
$params['category_id']=$this->category_id;
(new Article())->index($params);
}
return view('nk/article/index',['url'=>$this->url]);
}
/**
* 添加
*/
public function add()
{
if (request()->isAjax()) {
$params= get_params();
$params['category_id']=$this->category_id;
(new Article())->add($params);
}else{
View::assign('editor', get_system_config('other','editor'));
View::assign('url', $this->url);
// 获取用户信息
$this->users = Db::table('fa_szxc_information_usermsg')->where('status',1)->field('user_id,name')->select();
View::assign('users', $this->users);
$street = Db::table('fa_geo_area')->where(['switch' => 1, 'city_code' => '510500'])
->field('area_id id,area_code code,area_name name')
->select();
View::assign('street', $street);
return view('nk/article/add');
}
}
/**
* 修改
*/
public function edit()
{
$params= get_params();
(new Article())->edit($params);
return view('nk/article/edit',['url'=>$this->url]);
}
/**
* 查看信息
*/
public function read()
{
$params = get_params();
(new Article())->read($params);
return view('nk/article/read',['url'=>$this->url]);
}
/**
* 修改
*/
public function del()
{
$params= get_params();
(new Article())->del($params);
}
}

View File

@ -0,0 +1,93 @@
<?php
namespace app\admin\controller\nk;
use app\admin\BaseController;
use think\exception\ValidateException;
use think\facade\Db;
use app\admin\controller\nk\Article;
use think\facade\View;
/**
* 文章
*
* @icon fa fa-circle-o
*/
class Policy extends BaseController
{
public function __construct()
{
$this->adminInfo = get_login_admin();
$this->category_id=355;
$this->url=[
'/admin/nk.policy/index?category_id='.$this->category_id,
'/admin/nk.policy/add',
'/admin/nk.policy/edit',
'/admin/nk.policy/del',
'/admin/nk.policy/read',
];
}
/**
* 查看
*/
public function index()
{
if (request()->isAjax()) {
$params= get_params();
$params['category_id']=$this->category_id;
(new Article())->index($params);
}
return view('nk/article/index',['url'=>$this->url]);
}
/**
* 添加
*/
public function add()
{
if (request()->isAjax()) {
$params= get_params();
$params['category_id']=$this->category_id;
(new Article())->add($params);
}else{
View::assign('editor', get_system_config('other','editor'));
View::assign('url', $this->url);
// 获取用户信息
$this->users = Db::table('fa_szxc_information_usermsg')->where('status',1)->field('user_id,name')->select();
View::assign('users', $this->users);
$street = Db::table('fa_geo_area')->where(['switch' => 1, 'city_code' => '510500'])
->field('area_id id,area_code code,area_name name')
->select();
View::assign('street', $street);
return view('nk/article/add');
}
}
/**
* 修改
*/
public function edit()
{
$params= get_params();
(new Article())->edit($params);
return view('nk/article/edit',['url'=>$this->url]);
}
/**
* 查看信息
*/
public function read()
{
$params = get_params();
(new Article())->read($params);
return view('nk/article/read',['url'=>$this->url]);
}
/**
* 修改
*/
public function del()
{
$params= get_params();
(new Article())->del($params);
}
}

View File

@ -0,0 +1,194 @@
<?php
namespace app\admin\controller\nk;
use app\admin\BaseController;
use think\facade\Db;
use think\facade\View;
/**
* 农产品结构
*
* @icon fa fa-circle-o
*/
class Products extends BaseController
{
/**
* 构造函数
*/
public function __construct()
{
$this->adminInfo = get_login_admin();
$this->url=[
'/admin/nk.products/index',
'/admin/nk.products/add',
'/admin/nk.products/edit',
'/admin/nk.products/del',
'/admin/nk.products/read',
];
}
/**
* 数据列表
*/
public function index()
{
if (request()->isAjax()) {
$params= get_params();
$where[]= ['status','=',1];
if (isset($params['keywords']) && !empty($params['keywords'])){
$where[]= ['title','like','%'.$params['keywords'].'%'];
}
if($this->adminInfo['position_id'] != 1){ //不是超级管理员
$www['admin_id'] = $this->adminInfo['id'];
$user_address = Db::table('fa_szxc_information_useraddress')->where($www)->find();
if ($user_address){
if($user_address['auth_range'] == 1){
$where[] = ['village_id','=',$user_address['village_id']];
}elseif ($user_address['auth_range'] == 2){
$where[] = ['street_id','=',$user_address['street_id']];
}elseif ($user_address['auth_range'] == 3){
$where[] = ['area_id','=',$user_address['area_id']];
}else{
$where[] = ['village_id','=',$user_address['village_id']];
}
}else{
$where[] = ['village_id','=',''];
}
}
$total = Db::table('cms_agriculture_products')
->where($where)
->count();
$list = Db::table('cms_agriculture_products')
->withAttr('area_id',function ($value,$data){
return Db::table('fa_geo_area')->where('area_code',$data['area_id'])->value('area_name');
})
->withAttr('street_id',function ($value,$data){
return Db::table('fa_geo_street')->where('street_code',$data['street_id'])->value('street_name');
})
->withAttr('village_id',function ($value,$data){
return Db::table('fa_geo_village')->where('village_id',$data['village_id'])->value('village_name');
})
->withAttr('maturity',function ($value,$data){
return $maturity = Db::table('cms_agriculture_products_traceability')->where('szxc_planting_type_id',$data['szxc_planting_type_id'])->value('content');
// if($maturity){
// return json_decode($maturity,true);
// }else{
// return '';
// }
})
->withAttr('status',function ($value,$data){
if($value == 1){
return '正常';
}else{
return '禁用';
}
})
->where($where)
->page($params['page'])
->limit($params['limit'])
->order('id desc')
->select();
$result = ['total' => $total, 'data' => $list];
return table_assign(0, '', $result);
}
else{
return view('nk/products/index',['url'=>$this->url]);
}
}
public function add(){
if (request()->isAjax()) {
$param= get_params();
$adds=Db::table('fa_szxc_information_useraddress')->where('admin_id',$this->adminInfo['id'])->find();
$param['area_id']=$adds['area_id'];
$param['street_id']=$adds['street_id'];
$param['village_id']=$adds['village_id'];
$param['add_time']=date('Y-m-d H:i:s');
$param['title'] = Db::table('fa_szxc_planting_type')->where('id',$param['szxc_planting_type_id'])->value('name');
$res=Db::table('cms_agriculture_products')->strict(false)->field(true)->insertGetId($param);
if ($res){
return to_assign(0,'操作成功',['aid'=>$res]);
}
return to_assign(1, '操作失败,原因:'.$res);
}else{
View::assign('editor', get_system_config('other','editor'));
$szxc_planting_type = Db::table('fa_szxc_planting_type')->select();
View::assign('szxc_planting_type', $szxc_planting_type);
return view();
}
}
public function edit(){
$param= get_params();
if (request()->isAjax()) {
$param['title'] = Db::table('fa_szxc_planting_type')->where('id',$param['szxc_planting_type_id'])->value('name');
$res=Db::table('cms_agriculture_products')->where('id',$param['id'])->strict(false)->field(true)->update($param);
if ($res){
return to_assign();
}else{
return to_assign(1, '操作失败,原因:'.$res);
}
}else{
$id = isset($param['id']) ? $param['id'] : 0;
$detail = Db::table('cms_agriculture_products')->where('id',$id)->find();
View::assign('editor', get_system_config('other','editor'));
if (!empty($detail)) {
View::assign('detail', $detail);
$szxc_planting_type = Db::table('fa_szxc_planting_type')->select();
View::assign('szxc_planting_type', $szxc_planting_type);
return view();
}
else{
throw new \think\exception\HttpException(404, '找不到页面');
}
}
}
/**
* 查看信息
*/
public function read()
{
$param= get_params();
$id = isset($param['id']) ? $param['id'] : 0;
$detail = Db::table('cms_agriculture_products')->where('id',$id)->find();
if (!empty($detail)) {
if($detail){
$maturity = Db::table('cms_agriculture_products_traceability')->where('szxc_planting_type_id',$detail['szxc_planting_type_id'])->value('content');
if($maturity){
$maturity = json_decode($maturity,1);
}else{
$maturity = '';
}
$detail['maturity'] = $maturity;
}
View::assign('detail', $detail);
$szxc_planting_type = Db::table('fa_szxc_planting_type')->select();
View::assign('szxc_planting_type', $szxc_planting_type);
return view();
}
else{
throw new \think\exception\HttpException(404, '找不到页面');
}
}
/**
* 删除
*/
public function del()
{
$param= get_params();
$id = isset($param['id']) ? $param['id'] : 0;
$type = isset($param['type']) ? $param['type'] : 0;
$res = Db::table('cms_agriculture_products')->where('id',$id)->delete();
if ($res){
return to_assign();
}else{
return to_assign(1, '操作失败,原因:'.$res);
}
}
}

View File

@ -0,0 +1,93 @@
<?php
namespace app\admin\controller\nk;
use app\admin\BaseController;
use think\exception\ValidateException;
use think\facade\Db;
use app\admin\controller\nk\Article;
use think\facade\View;
/**
* 文章
*
* @icon fa fa-circle-o
*/
class Profile extends BaseController
{
public function __construct()
{
$this->adminInfo = get_login_admin();
$this->category_id=296;
$this->url=[
'/admin/nk.profile/index?category_id='.$this->category_id,
'/admin/nk.profile/add',
'/admin/nk.profile/edit',
'/admin/nk.profile/del',
'/admin/nk.profile/read',
];
}
/**
* 查看
*/
public function index()
{
if (request()->isAjax()) {
$params= get_params();
$params['category_id']=$this->category_id;
(new Article())->index($params);
}
return view('nk/article/index',['url'=>$this->url]);
}
/**
* 添加
*/
public function add()
{
if (request()->isAjax()) {
$params= get_params();
$params['category_id']=$this->category_id;
(new Article())->add($params);
}else{
View::assign('editor', get_system_config('other','editor'));
View::assign('url', $this->url);
// 获取用户信息
$this->users = Db::table('fa_szxc_information_usermsg')->where('status',1)->field('user_id,name')->select();
View::assign('users', $this->users);
$street = Db::table('fa_geo_area')->where(['switch' => 1, 'city_code' => '510500'])
->field('area_id id,area_code code,area_name name')
->select();
View::assign('street', $street);
return view('nk/article/add');
}
}
/**
* 修改
*/
public function edit()
{
$params= get_params();
(new Article())->edit($params);
return view('nk/article/edit',['url'=>$this->url]);
}
/**
* 查看信息
*/
public function read()
{
$params = get_params();
(new Article())->read($params);
return view('nk/article/read',['url'=>$this->url]);
}
/**
* 修改
*/
public function del()
{
$params= get_params();
(new Article())->del($params);
}
}

View File

@ -0,0 +1,21 @@
<?php
namespace app\admin\controller\nk;
/**
* 民生公益
* -- 公益活动
*/
class PublicBenefitActivities extends ArticleCommon{
function __construct()
{
$this->adminInfo = get_login_admin();
$this->category_id = 369;
$this->url=[
'/admin/nk.publicbenefitactivities/index?category_id='.$this->category_id,
'/admin/nk.publicbenefitactivities/add',
'/admin/nk.publicbenefitactivities/edit',
'/admin/nk.publicbenefitactivities/del',
'/admin/nk.publicbenefitactivities/read',
];
}
}

View File

@ -0,0 +1,258 @@
<?php
namespace app\admin\controller\nk;
use think\db\exception\DbException as ExceptionDbException;
use think\exception\ValidateException;
use think\facade\Db;
use think\facade\View;
/**
* 民生公益
* -- 公益项目
*
CREATE TABLE `fa_article_public_benefit` (
`id` int unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID',
`article_id` int unsigned NOT NULL COMMENT '文章id',
`promoter` varchar(255) NOT NULL DEFAULT '' COMMENT '发起人',
`enrolled_num` int unsigned NOT NULL COMMENT '已报名人数',
`is_enrolled` tinyint unsigned NOT NULL DEFAULT '0' COMMENT '是否报名',
PRIMARY KEY (`id`),
UNIQUE KEY `article_id` (`article_id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='民生公益类(公益项目报名)文章扩展表';
*/
class PublicBenefitEnroll extends ArticleCommon{
const ARTICLE_PUBLIC_BENEFIT = 'fa_article_public_benefit';
function __construct()
{
$this->adminInfo = get_login_admin();
$this->category_id = 368;
$this->url=[
'/admin/nk.publicbenefitenroll/index?category_id='.$this->category_id,
'/admin/nk.publicbenefitenroll/add',
'/admin/nk.publicbenefitenroll/edit',
'/admin/nk.publicbenefitenroll/del',
'/admin/nk.publicbenefitenroll/read',
];
}
// protected function addArticle($param){
// // 检验完整性
// try {
// validate(\app\admin\validate\nk\ArticleValidate::class)->check($param);
// } catch (ValidateException $e) {
// // 验证失败 输出错误信息
// return to_assign(1, $e->getError());
// }
// $adds=Db::table('fa_szxc_information_useraddress')->where('admin_id',$this->adminInfo['id'])->find();
// if($this->adminInfo['position_id'] != 1) { //不是超级管理员
// $param['county']=$adds['area_id'];
// $param['township']=$adds['street_id'];
// $param['village']=$adds['village_id'];
// $param['user_id']=$adds['user_id'];
// }else{
// if(empty($param['county'])){
// $param['county']=$adds['area_id'];
// }
// if(empty($param['township'])){
// $param['township']=$adds['street_id'];
// }
// if(empty($param['village'])){
// $param['village']=$adds['village_id'];
// }
// if(empty($param['user_id'])){
// $param['user_id']=$adds['user_id'];
// }
// }
// $param['view_time']=date('Y-m-d H:i:s');
// if(empty($param['category_type'])){
// $param['category_type'] = 0;
// }
// if(empty($param['end_time'])){
// $param['end_time'] = date('Y-m-d H:i:s');
// }
// Db::startTrans();
// try{
// $aid = Db::table('fa_article')->strict(false)->field(true)->insertGetId($param);
// // 更新文章相关的报名信息
// $pid = Db::table(ARTICLE_PUBLIC_BENEFIT)->strict(false)->field(true)->insertGetId(['article_id'=>$aid,'promoter'=>$param['promoter'],'enrolled_num'=>$param['enrolled_num']]);
// }catch(ExceptionDbException $e){
// Db::rollback();
// return to_assign(1, '操作失败,原因:'.$e->getMessage());
// }
// if (!empty($aid) && !empty($pid)) {
// Db::commit();
// if(!empty($param['is_vote']) && $param['is_vote']==1){
// $data=['start_time'=>date('Y-m-d H:i:s'),'end_time'=>$param['end_time'],'article_id'=>$aid,'county'=>$adds['area_id'],'township'=>$adds['street_id'],'village'=>$adds['village_id']];
// Db::table('fa_article_vote_side_tables')->insert($data);
// }
// return to_assign(0,'操作成功',['aid'=>$aid]);
// }
// return to_assign(1, '操作失败,原因:'.$aid);
// }
/**
* 添加
*/
function Add(){
if (request()->isAjax()) {
$params= get_params();
$params['category_id']=$this->category_id;
// unset($params['amp;']);
// 更新文章信息
$this->addArticle($params, function($aid)use($params){
$params['article_id'] = $aid;
// 更新文章相关的报名信息
return Db::table(ARTICLE_EDUCATION_LIVE)->strict(false)->field(true)->insertGetId(['article_id'=>$aid,'promoter'=>$params['promoter'],'enrolled_num'=>$params['enrolled_num']]);
});
}else{
View::assign('editor', get_system_config('other','editor'));
View::assign('url', $this->url);
// 获取用户信息
$this->users = Db::table('fa_szxc_information_usermsg')->where('status',1)->field('user_id,name')->select();
View::assign('users', $this->users);
$street = Db::table('fa_geo_area')->where(['switch' => 1, 'city_code' => '510500'])
->field('area_id id,area_code code,area_name name')
->select();
View::assign('street', $street);
return view('nk/publicbenefitenroll/add');
}
}
/**
* 查看
*/
function Read(){
$param = get_params();
$id = isset($param['id']) ? $param['id'] : 0;
$detail = Db::table('fa_article')->where('id',$id)->withAttr('enroll', function($value, $data)use($id){
return Db::table(self::ARTICLE_PUBLIC_BENEFIT)->field('promoter,enrolled_num')->where('article_id', $id)->find();
})->find();
if (!empty($detail)) {
$detail['comment'] = Db::table('fa_article_comment')
->where('vote_id',$id)
->withAttr('user_info',function ($value,$data){
return Db::table('fa_szxc_information_usermsg')->where('user_id',$data['user_id'])->value('name');
})->select();
View::assign('detail', $detail);
View::assign('admin_id', $this->adminInfo['id']);
return view('nk/publicbenefitenroll/read',['url'=>$this->url]);
}else{
throw new \think\exception\HttpException(404, '找不到页面');
}
}
/**
* 公益项目报名修改
*/
function Edit(){
$param= get_params();
$id = isset($param['id']) ? $param['id'] : 0;
if (request()->isAjax()) {
try {
validate(\app\admin\validate\nk\ArticleValidate::class)->check($param);
} catch (ValidateException $e) {
// 验证失败 输出错误信息
return to_assign(1, $e->getError());
}
$adds=Db::table('fa_szxc_information_useraddress')->where('admin_id',$this->adminInfo['id'])->find();
if($this->adminInfo['position_id'] == 1) { //是超级管理员
if(empty($param['county'])){
$param['county']=$adds['area_id'];
}
if(empty($param['township'])){
$param['township']=$adds['street_id'];
}
if(empty($param['village'])){
$param['village']=$adds['village_id'];
}
if(empty($param['user_id'])){
$param['user_id']=$adds['user_id'];
}
}
// 更新文章信息
$res=Db::table('fa_article')->where('id',$param['id'])->strict(false)->field(true)->update($param);
// 更新文章相关的报名信息
if (!empty($param['promoter'] || !empty($param['enrolled_num']))){
$res = Db::table(self::ARTICLE_PUBLIC_BENEFIT)->where('article_id',$id)->update(['promoter'=>$param['promoter'],'enrolled_num'=>$param['enrolled_num']]);
}
if ($res){
// 更新文章相关的投票信息
if(!empty($param['is_vote']) && $param['is_vote']==1){
Db::table('fa_article_vote_side_tables')->where('article_id',$param['id'])->update(['end_time'=>$param['end_time']]);
}
return to_assign();
}else{
return to_assign(1, '操作失败,原因:'.$res);
}
}else{
// 获取指定公益项目文章
$detail = Db::table('fa_article')->where('id',$id)->withAttr('enroll', function($value, $data)use($id){
return Db::table(self::ARTICLE_PUBLIC_BENEFIT)->field('promoter,enrolled_num')->where('article_id', $id)->find();
})->find();
View::assign('editor', get_system_config('other','editor'));
// 获取此文章的用户信息
if (!empty($detail)) {
// echo '<pre>';print_r($detail);
View::assign('detail', $detail);
// 获取用户信息
$this->users = Db::table('fa_szxc_information_usermsg')->where('status',1)->field('user_id,name')->select();
View::assign('users', $this->users);
$street = Db::table('fa_geo_area')->where(['switch' => 1, 'city_code' => '510500'])
->field('area_id id,area_code code,area_name name')
->select();
View::assign('street', $street);
}
else{
throw new \think\exception\HttpException(404, '找不到页面');
}
}
return view('nk/publicbenefitenroll/edit',['url'=>$this->url]);
}
function Del(){
$param = get_params();
$id = isset($param['id']) ? $param['id'] : 0;
// $type = isset($param['type']) ? $param['type'] : 0;
// 此处同时删除两个表
Db::startTrans();
try{
$res1 = Db::table('fa_article')->where('id',$id)->delete();
$pid = Db::table(self::ARTICLE_PUBLIC_BENEFIT)->where('article_id', $id)->value('id');
if (!empty($pid)) {
$res2 = Db::table(self::ARTICLE_PUBLIC_BENEFIT)->where('article_id', $pid)->delete();
}else{
$pid = true;
}
}catch (ExceptionDbException $e){
Db::rollback();
$res1 = $pid = '';
return to_assign(1, '操作失败,原因:'.$e->getMessage());
}
if ($res1 && $pid){
Db::commit();
return to_assign();
}else{
return to_assign(1, '操作失败原因1'.$res1);
}
}
}

View File

@ -0,0 +1,93 @@
<?php
namespace app\admin\controller\nk;
use app\admin\BaseController;
use think\exception\ValidateException;
use think\facade\Db;
use app\admin\controller\nk\Article;
use think\facade\View;
/**
* 文章
*
* @icon fa fa-circle-o
*/
class Recruit extends BaseController
{
public function __construct()
{
$this->adminInfo = get_login_admin();
$this->category_id=316;
$this->url=[
'/admin/nk.recruit/index?category_id='.$this->category_id,
'/admin/nk.recruit/add',
'/admin/nk.recruit/edit',
'/admin/nk.recruit/del',
'/admin/nk.recruit/read',
];
}
/**
* 查看
*/
public function index()
{
if (request()->isAjax()) {
$params= get_params();
$params['category_id']=$this->category_id;
(new Article())->index($params);
}
return view('nk/article/index',['url'=>$this->url]);
}
/**
* 添加
*/
public function add()
{
if (request()->isAjax()) {
$params= get_params();
$params['category_id']=$this->category_id;
(new Article())->add($params);
}else{
View::assign('editor', get_system_config('other','editor'));
View::assign('url', $this->url);
// 获取用户信息
$this->users = Db::table('fa_szxc_information_usermsg')->where('status',1)->field('user_id,name')->select();
View::assign('users', $this->users);
$street = Db::table('fa_geo_area')->where(['switch' => 1, 'city_code' => '510500'])
->field('area_id id,area_code code,area_name name')
->select();
View::assign('street', $street);
return view('nk/article/add');
}
}
/**
* 修改
*/
public function edit()
{
$params= get_params();
(new Article())->edit($params);
return view('nk/article/edit',['url'=>$this->url]);
}
/**
* 查看信息
*/
public function read()
{
$params = get_params();
(new Article())->read($params);
return view('nk/article/read',['url'=>$this->url]);
}
/**
* 修改
*/
public function del()
{
$params= get_params();
(new Article())->del($params);
}
}

View File

@ -0,0 +1,93 @@
<?php
namespace app\admin\controller\nk;
use app\admin\BaseController;
use think\exception\ValidateException;
use think\facade\Db;
use app\admin\controller\nk\Article;
use think\facade\View;
/**
* 文章
*
* @icon fa fa-circle-o
*/
class Regulation extends BaseController
{
public function __construct()
{
$this->adminInfo = get_login_admin();
$this->category_id=163;
$this->url=[
'/admin/nk.regulation/index?category_id='.$this->category_id,
'/admin/nk.regulation/add',
'/admin/nk.regulation/edit',
'/admin/nk.regulation/del',
'/admin/nk.regulation/read',
];
}
/**
* 查看
*/
public function index()
{
if (request()->isAjax()) {
$params= get_params();
$params['category_id']=$this->category_id;
(new Article())->index($params);
}
return view('nk/article/index',['url'=>$this->url]);
}
/**
* 添加
*/
public function add()
{
if (request()->isAjax()) {
$params= get_params();
$params['category_id']=$this->category_id;
(new Article())->add($params);
}else{
View::assign('editor', get_system_config('other','editor'));
View::assign('url', $this->url);
// 获取用户信息
$this->users = Db::table('fa_szxc_information_usermsg')->where('status',1)->field('user_id,name')->select();
View::assign('users', $this->users);
$street = Db::table('fa_geo_area')->where(['switch' => 1, 'city_code' => '510500'])
->field('area_id id,area_code code,area_name name')
->select();
View::assign('street', $street);
return view('nk/article/add');
}
}
/**
* 修改
*/
public function edit()
{
$params= get_params();
(new Article())->edit($params);
return view('nk/article/edit',['url'=>$this->url]);
}
/**
* 查看信息
*/
public function read()
{
$params = get_params();
(new Article())->read($params);
return view('nk/article/read',['url'=>$this->url]);
}
/**
* 修改
*/
public function del()
{
$params= get_params();
(new Article())->del($params);
}
}

View File

@ -0,0 +1,91 @@
<?php
namespace app\admin\controller\nk;
use app\admin\BaseController;
use think\facade\Db;
use think\facade\View;
/**
* 文章
*
* @icon fa fa-circle-o
*/
class RuralWelfare extends BaseController
{
public function __construct()
{
$this->adminInfo = get_login_admin();
$this->category_id=352;
$this->url=[
'/admin/nk.ruralwelfare/index?category_id='.$this->category_id,
'/admin/nk.ruralwelfare/add',
'/admin/nk.ruralwelfare/edit',
'/admin/nk.ruralwelfare/del',
'/admin/nk.ruralwelfare/read',
];
}
/**
* 查看
*/
public function index()
{
if (request()->isAjax()) {
$params= get_params();
$params['category_id']=$this->category_id;
(new Article())->index($params);
}
return view('nk/article/index',['url'=>$this->url]);
}
/**
* 添加
*/
public function add()
{
if (request()->isAjax()) {
$params= get_params();
$params['category_id']=$this->category_id;
(new Article())->add($params);
}else{
View::assign('editor', get_system_config('other','editor'));
View::assign('url', $this->url);
// 获取用户信息
$this->users = Db::table('fa_szxc_information_usermsg')->where('status',1)->field('user_id,name')->select();
View::assign('users', $this->users);
$street = Db::table('fa_geo_area')->where(['switch' => 1, 'city_code' => '510500'])
->field('area_id id,area_code code,area_name name')
->select();
View::assign('street', $street);
return view('nk/article/add');
}
}
/**
* 修改
*/
public function edit()
{
$params= get_params();
(new Article())->edit($params);
return view('nk/article/edit',['url'=>$this->url]);
}
/**
* 查看信息
*/
public function read()
{
$params = get_params();
(new Article())->read($params);
return view('nk/article/read',['url'=>$this->url]);
}
/**
* 修改
*/
public function del()
{
$params= get_params();
(new Article())->del($params);
}
}

View File

@ -0,0 +1,93 @@
<?php
namespace app\admin\controller\nk;
use app\admin\BaseController;
use think\exception\ValidateException;
use think\facade\Db;
use app\admin\controller\nk\Article;
use think\facade\View;
/**
* 文章
*
* @icon fa fa-circle-o
*/
class Seekers extends BaseController
{
public function __construct()
{
$this->adminInfo = get_login_admin();
$this->category_id=358;
$this->url=[
'/admin/nk.seekers/index?category_id='.$this->category_id,
'/admin/nk.seekers/add',
'/admin/nk.seekers/edit',
'/admin/nk.seekers/del',
'/admin/nk.seekers/read',
];
}
/**
* 查看
*/
public function index()
{
if (request()->isAjax()) {
$params= get_params();
$params['category_id']=$this->category_id;
(new Article())->index($params);
}
return view('nk/article/index',['url'=>$this->url]);
}
/**
* 添加
*/
public function add()
{
if (request()->isAjax()) {
$params= get_params();
$params['category_id']=$this->category_id;
(new Article())->add($params);
}else{
View::assign('editor', get_system_config('other','editor'));
View::assign('url', $this->url);
// 获取用户信息
$this->users = Db::table('fa_szxc_information_usermsg')->where('status',1)->field('user_id,name')->select();
View::assign('users', $this->users);
$street = Db::table('fa_geo_area')->where(['switch' => 1, 'city_code' => '510500'])
->field('area_id id,area_code code,area_name name')
->select();
View::assign('street', $street);
return view('nk/article/add');
}
}
/**
* 修改
*/
public function edit()
{
$params= get_params();
(new Article())->edit($params);
return view('nk/article/edit',['url'=>$this->url]);
}
/**
* 查看信息
*/
public function read()
{
$params = get_params();
(new Article())->read($params);
return view('nk/article/read',['url'=>$this->url]);
}
/**
* 修改
*/
public function del()
{
$params= get_params();
(new Article())->del($params);
}
}

View File

@ -0,0 +1,93 @@
<?php
namespace app\admin\controller\nk;
use app\admin\BaseController;
use think\exception\ValidateException;
use think\facade\Db;
use app\admin\controller\nk\Article;
use think\facade\View;
/**
* 文章
*
* @icon fa fa-circle-o
*/
class Skills extends BaseController
{
public function __construct()
{
$this->adminInfo = get_login_admin();
$this->category_id=353;
$this->url=[
'/admin/nk.skills/index?category_id='.$this->category_id,
'/admin/nk.skills/add',
'/admin/nk.skills/edit',
'/admin/nk.skills/del',
'/admin/nk.skills/read',
];
}
/**
* 查看
*/
public function index()
{
if (request()->isAjax()) {
$params= get_params();
$params['category_id']=$this->category_id;
(new Article())->index($params);
}
return view('nk/article/index',['url'=>$this->url]);
}
/**
* 添加
*/
public function add()
{
if (request()->isAjax()) {
$params= get_params();
$params['category_id']=$this->category_id;
(new Article())->add($params);
}else{
View::assign('editor', get_system_config('other','editor'));
View::assign('url', $this->url);
// 获取用户信息
$this->users = Db::table('fa_szxc_information_usermsg')->where('status',1)->field('user_id,name')->select();
View::assign('users', $this->users);
$street = Db::table('fa_geo_area')->where(['switch' => 1, 'city_code' => '510500'])
->field('area_id id,area_code code,area_name name')
->select();
View::assign('street', $street);
return view('nk/article/add');
}
}
/**
* 修改
*/
public function edit()
{
$params= get_params();
(new Article())->edit($params);
return view('nk/article/edit',['url'=>$this->url]);
}
/**
* 查看信息
*/
public function read()
{
$params = get_params();
(new Article())->read($params);
return view('nk/article/read',['url'=>$this->url]);
}
/**
* 修改
*/
public function del()
{
$params= get_params();
(new Article())->del($params);
}
}

View File

@ -0,0 +1,168 @@
<?php
namespace app\admin\controller\nk;
use app\admin\BaseController;
use think\facade\Db;
use think\facade\View;
/**
* 轮播位置管理
*
* @icon fa fa-circle-o
*/
class Slide extends BaseController
{
/**
* 构造函数
*/
public function __construct()
{
$this->adminInfo = get_login_admin();
$this->url=[
'/admin/nk.slide/index',
'/admin/nk.slide/add',
'/admin/nk.slide/edit',
'/admin/nk.slide/del',
'/admin/nk.slide/read',
];
}
/**
* 数据列表
*/
public function index()
{
if (request()->isAjax()) {
$params= get_params();
// $where['status']=1;
$where = [];
if (isset($params['keywords'])){
$where[]=['title','like','%'.$params['keywords'].'%'];
}
if($this->adminInfo['position_id'] != 1){ //不是超级管理员
$www['admin_id'] = $this->adminInfo['id'];
$user_address = Db::table('fa_szxc_information_useraddress')->where($www)->find();
if ($user_address){
if($user_address['auth_range'] == 1){
$where['village'] = $user_address['village_id'];
}elseif ($user_address['auth_range'] == 2){
$where['township'] = $user_address['street_id'];
}elseif ($user_address['auth_range'] == 3){
$where['county'] = $user_address['area_id'];
}else{
$where['village'] = $user_address['village_id'];
}
}else{
$where['village'] = '';
}
}
$total = Db::table('fa_slide')
->where($where)
->count();
$list = Db::table('fa_slide')
->withAttr('area',function ($value,$data){
return Db::table('fa_geo_area')->where('area_code',$data['county'])->value('area_name');
})
->withAttr('street',function ($value,$data){
return Db::table('fa_geo_street')->where('street_code',$data['township'])->value('street_name');
})
->withAttr('village',function ($value,$data){
return Db::table('fa_geo_village')->where('village_id',$data['village'])->value('village_name');
})
->withAttr('create_time',function ($value,$data){
return date('Y-m-d H:i:s',$data['create_time']);
})
->where($where)
->page($params['page'])
->limit($params['limit'])
->order('id desc')
->select();
$result = ['total' => $total, 'data' => $list];
return table_assign(0, '', $result);
}
else{
return view('nk/slide/index',['url'=>$this->url]);
}
}
public function add(){
if (request()->isAjax()) {
$param= get_params();
$adds=Db::table('fa_szxc_information_useraddress')->where('admin_id',$this->adminInfo['id'])->find();
$param['county']=$adds['area_id'];
$param['township']=$adds['street_id'];
$param['village']=$adds['village_id'];
$param['create_time']= time();
$res=Db::table('fa_slide')->strict(false)->field(true)->insertGetId($param);
if ($res){
return to_assign(0,'操作成功',['aid'=>$res]);
}
return to_assign(1, '操作失败,原因:'.$res);
}else{
View::assign('editor', get_system_config('other','editor'));
return view();
}
}
public function edit(){
$param= get_params();
if (request()->isAjax()) {
$param['update_time']= time();
$res=Db::table('fa_slide')->where('id',$param['id'])->strict(false)->field(true)->update($param);
if ($res){
return to_assign();
}else{
return to_assign(1, '操作失败,原因:'.$res);
}
}else{
$id = isset($param['id']) ? $param['id'] : 0;
$detail = Db::table('fa_slide')->where('id',$id)->find();
View::assign('editor', get_system_config('other','editor'));
if (!empty($detail)) {
View::assign('detail', $detail);
return view();
}
else{
throw new \think\exception\HttpException(404, '找不到页面');
}
}
}
/**
* 查看信息
*/
public function read()
{
$param= get_params();
$id = isset($param['id']) ? $param['id'] : 0;
$detail = Db::table('fa_slide')->where('id',$id)->find();
if (!empty($detail)) {
View::assign('detail', $detail);
return view();
}
else{
throw new \think\exception\HttpException(404, '找不到页面');
}
}
/**
* 删除
*/
public function del()
{
$param= get_params();
$id = isset($param['id']) ? $param['id'] : 0;
$type = isset($param['type']) ? $param['type'] : 0;
$res = Db::table('fa_slide')->where('id',$id)->delete();
if ($res){
return to_assign();
}else{
return to_assign(1, '操作失败,原因:'.$res);
}
}
}

View File

@ -0,0 +1,172 @@
<?php
namespace app\admin\controller\nk;
use app\admin\BaseController;
use think\facade\Db;
use think\facade\View;
/**
* 轮播图管理
*
* @icon fa fa-circle-o
*/
class Slideinfo extends BaseController
{
/**
* 构造函数
*/
public function __construct()
{
$this->adminInfo = get_login_admin();
$this->url=[
'/admin/nk.slideinfo/index',
'/admin/nk.slideinfo/add',
'/admin/nk.slideinfo/edit',
'/admin/nk.slideinfo/del',
'/admin/nk.slideinfo/read',
];
// 获取轮播位置
$this->slide = Db::table('fa_slide')->where('status',1)->select();
}
/**
* 数据列表
*/
public function index()
{
if (request()->isAjax()) {
$params= get_params();
// $where['status']=1;
$where = [];
if (isset($params['keywords'])){
$where[]=['title','like','%'.$params['keywords'].'%'];
}
if($this->adminInfo['position_id'] != 1){ //不是超级管理员
$www['admin_id'] = $this->adminInfo['id'];
$user_address = Db::table('fa_szxc_information_useraddress')->where($www)->find();
if ($user_address){
if($user_address['auth_range'] == 1){
$where['village'] = $user_address['village_id'];
}elseif ($user_address['auth_range'] == 2){
$where['township'] = $user_address['street_id'];
}elseif ($user_address['auth_range'] == 3){
$where['county'] = $user_address['area_id'];
}else{
$where['village'] = $user_address['village_id'];
}
}else{
$where['village'] = '';
}
}
$total = Db::table('fa_slide_info')
->where($where)
->count();
$list = Db::table('fa_slide_info')
->withAttr('area',function ($value,$data){
return Db::table('fa_geo_area')->where('area_code',$data['county'])->value('area_name');
})
->withAttr('street',function ($value,$data){
return Db::table('fa_geo_street')->where('street_code',$data['township'])->value('street_name');
})
->withAttr('village',function ($value,$data){
return Db::table('fa_geo_village')->where('village_id',$data['village'])->value('village_name');
})
->withAttr('create_time',function ($value,$data){
return date('Y-m-d H:i:s',$data['create_time']);
})
->where($where)
->page($params['page'])
->limit($params['limit'])
->order('id desc')
->select();
$result = ['total' => $total, 'data' => $list];
return table_assign(0, '', $result);
}
else{
return view('nk/slideinfo/index',['url'=>$this->url]);
}
}
public function add(){
if (request()->isAjax()) {
$param= get_params();
$adds=Db::table('fa_szxc_information_useraddress')->where('admin_id',$this->adminInfo['id'])->find();
$param['county']=$adds['area_id'];
$param['township']=$adds['street_id'];
$param['village']=$adds['village_id'];
$param['create_time']= time();
$res=Db::table('fa_slide_info')->strict(false)->field(true)->insertGetId($param);
if ($res){
return to_assign(0,'操作成功',['aid'=>$res]);
}
return to_assign(1, '操作失败,原因:'.$res);
}else{
View::assign('editor', get_system_config('other','editor'));
View::assign('slide', $this->slide);
return view();
}
}
public function edit(){
$param= get_params();
if (request()->isAjax()) {
$param['update_time']= time();
$res=Db::table('fa_slide_info')->where('id',$param['id'])->strict(false)->field(true)->update($param);
if ($res){
return to_assign();
}else{
return to_assign(1, '操作失败,原因:'.$res);
}
}else{
$id = isset($param['id']) ? $param['id'] : 0;
$detail = Db::table('fa_slide_info')->where('id',$id)->find();
View::assign('editor', get_system_config('other','editor'));
if (!empty($detail)) {
View::assign('detail', $detail);
View::assign('slide', $this->slide);
return view();
}
else{
throw new \think\exception\HttpException(404, '找不到页面');
}
}
}
/**
* 查看信息
*/
public function read()
{
$param= get_params();
$id = isset($param['id']) ? $param['id'] : 0;
$detail = Db::table('fa_slide_info')->where('id',$id)->find();
if (!empty($detail)) {
View::assign('detail', $detail);
View::assign('slide', $this->slide);
return view();
}
else{
throw new \think\exception\HttpException(404, '找不到页面');
}
}
/**
* 删除
*/
public function del()
{
$param= get_params();
$id = isset($param['id']) ? $param['id'] : 0;
$type = isset($param['type']) ? $param['type'] : 0;
$res = Db::table('fa_slide_info')->where('id',$id)->delete();
if ($res){
return to_assign();
}else{
return to_assign(1, '操作失败,原因:'.$res);
}
}
}

View File

@ -0,0 +1,65 @@
<?php
namespace app\admin\controller\nk;
use app\admin\BaseController;
use think\exception\ValidateException;
use think\facade\Db;
use app\admin\controller\nk\Article;
use think\facade\View;
/**
* 佣金管理
*
* @icon fa fa-circle-o
*/
class Spread extends BaseController
{
public function __construct()
{
$this->adminInfo = get_login_admin();
$this->category_id=309;
$this->url=[
'/admin/nk.spread/index',
'/admin/nk.spread/read',
];
}
/**
* 查看
*/
public function index()
{
$nk_user=Db::connect('shop')->name('nk_user')->where('n_user_id',$this->adminInfo['id'])->value('user_id');
$total=0;
$list=[];
$brokerage_price=Db::connect('shop')->name('user')->where('uid',$nk_user)->value('brokerage_price');
if (request()->isAjax()) {
$params= get_params();
if ($nk_user!=0){
$list=Db::connect('shop')->name('store_order')->where('spread_uid',$nk_user)
->where('status',3)
->field('uid,order_sn,pay_time,extension_one,extension_two,is_selfbuy')
->page($params['page'])
->limit($params['limit'])
->select();
}
$result = ['total' => $total, 'data' => $list];
return table_assign(0, '', $result);
}
View::assign('brokerage_price', $brokerage_price);
return view('',['url'=>$this->url]);
}
/**
* 查看信息
*/
public function read()
{
$params = get_params();
return view('',['url'=>$this->url]);
}
}

View File

@ -0,0 +1,163 @@
<?php
namespace app\admin\controller\nk;
use app\admin\BaseController;
use app\admin\controller\nk\Article;
use think\exception\ValidateException;
use think\facade\Db;
use think\facade\View;
/**
* 镇列表
*
* @icon fa fa-circle-o
*/
class Street extends BaseController
{
public function __construct()
{
$this->adminInfo = get_login_admin();
$this->url=[
'/admin/nk.street/index',
'/admin/nk.street/add',
'/admin/nk.street/edit',
'/admin/nk.street/del',
'/admin/nk.street/read',
];
}
/**
* 查看
*/
public function index()
{
if (request()->isAjax()) {
$params= get_params();
$where[]=['status','=',1];
$where[]=['village_id','=',0];
if (isset($params['keywords'])){
$where[]=['title','like','%'.$params['keywords'].'%'];
}
$total = Db::table('fa_szxc_village')
->where($where)->count();
$list = Db::table('fa_szxc_village')
->withAttr('is_hot',function ($value,$data){
return $value==1?'是':'否';
})
->withAttr('is_tourism',function ($value,$data){
return $value==1?'是':'否';
})
->where($where)
->page($params['page'])
->limit($params['limit'])
->order('id desc')
->select();
$result = ['total' => $total, 'data' => $list];
return table_assign(0, '', $result);
}
View::assign('url', $this->url);
return view();
}
/**
* 添加
*/
public function add()
{
if (request()->isAjax()) {
$params= get_params();
if (!empty($params['is_hot'])&&$params['is_hot']=='on'){
$params['is_hot']=1;
}else{
$params['is_hot']=0;
}
if (!empty($params['is_tourism'])&&$params['is_tourism']=='on'){
$params['is_tourism']=1;
}else{
$params['is_tourism']=0;
}
$area_code=Db::table('fa_geo_area')->where('area_code',$params['area_id'])->value('area_name');
$street_code=Db::table('fa_geo_street')->where('street_code',$params['street_id'])->value('street_name');
$params['address']='泸州市'.$area_code.$street_code;
$params['createtime']=time();
$res=Db::table('fa_szxc_village')->strict(false)->field(true)->insertGetId($params);
if ($res){
return to_assign(0,'操作成功',['aid'=>$res]);
}
return to_assign(1, '操作失败,原因:'.$res);
}
$street = Db::table('fa_geo_area')->where(['switch' => 1, 'city_code' => '510500'])
->field('area_id id,area_code code,area_name name')
->select();
View::assign('street', $street);
View::assign('editor', get_system_config('other','editor'));
View::assign('url', $this->url);
return view();
}
/**
* 修改
*/
public function edit()
{
$params= get_params();
if (request()->isAjax()) {
if (!empty($params['is_hot'])&&$params['is_hot']=='on'){
$params['is_hot']=1;
}else{
$params['is_hot']=0;
}
if (!empty($params['is_tourism'])&&$params['is_tourism']=='on'){
$params['is_tourism']=1;
}else{
$params['is_tourism']=0;
}
$area_code=Db::table('fa_geo_area')->where('area_code',$params['area_id'])->value('area_name');
$street_code=Db::table('fa_geo_street')->where('street_code',$params['street_id'])->value('street_name');
$params['address']='泸州市'.$area_code.$street_code;
$res=Db::table('fa_szxc_village')->where('id',$params['id'])->strict(false)->field(true)->update($params);
if ($res){
return to_assign();
}else{
return to_assign(1, '操作失败,原因:'.$res);
}
}
$detail = Db::table('fa_szxc_village')->where('id',$params['id'])->find();
$street = Db::table('fa_geo_area')->where(['switch' => 1, 'city_code' => '510500'])
->field('area_id id,area_code code,area_name name')
->select();
View::assign('street', $street);
View::assign('detail', $detail);
View::assign('url', $this->url);
return view();
}
/**
* 查看信息
*/
public function read()
{
$params = get_params();
$detail = Db::table('fa_szxc_village')->where('id',$params['id'])->find();
View::assign('url', $this->url);
View::assign('detail', $detail);
return view();
}
/**
* 修改
*/
public function del()
{
$param= get_params();
$id = isset($param['id']) ? $param['id'] : 0;
$type = isset($param['type']) ? $param['type'] : 0;
$res = Db::table('fa_szxc_village')->where('id',$id)->update(['status'=>$type]);
if ($res){
return to_assign();
}else{
return to_assign(1, '操作失败,原因:'.$res);
}
}
}

View File

@ -0,0 +1,139 @@
<?php
/*
* @Author: mkm
* @Date: 2023-02-12 10:38:40
* @LastEditTime: 2023-02-12 11:06:03
* @LastEditors: your name
* @Description:
* @FilePath: \nk-lihaink-cn\app\admin\controller\nk\StreetCulture.php
* 可以输入预定的版权声明、个性签名、空行等
*/
namespace app\admin\controller\nk;
use app\admin\BaseController;
use think\exception\ValidateException;
use think\facade\Db;
use app\admin\controller\nk\Article;
use think\facade\View;
/**
* 农旅文化
*
* @icon fa fa-circle-o
*/
class StreetCulture extends BaseController
{
public function __construct()
{
$this->adminInfo = get_login_admin();
$this->url=[
'/admin/nk.street_culture/index',
'/admin/nk.street_culture/add',
'/admin/nk.street_culture/edit',
'/admin/nk.street_culture/del',
'/admin/nk.street_culture/read',
];
}
/**
* 查看
*/
public function index()
{
if (request()->isAjax()) {
$params= get_params();
$where[]= ['status','=',1];
if (isset($params['keywords']) && !empty($params['keywords'])){
$where[]=['title','like','%'.$params['keywords'].'%'];
}
if($this->adminInfo['position_id'] != 1){ //不是超级管理员
$www['admin_id'] = $this->adminInfo['id'];
$user_address = Db::table('fa_szxc_information_useraddress')->where($www)->find();
if ($user_address) {
if ($user_address['auth_range'] == 1) {
$where[]= ['county','=',$user_address['area_id']];
$where[] =['township','=', $user_address['street_id']];
$where[] =['village','=', $user_address['village_id']];
} elseif ($user_address['auth_range'] == 2) {
$where[]= ['county','=',$user_address['area_id']];
$where[] =['township','=', $user_address['street_id']];
}
}
}
$map[] = ['category_id','in',[307,308,309,310,311,312]];
$total = Db::table('fa_article')
->where($where)
->where($map)
->count();
$list = Db::table('fa_article')
->withAttr('nickname',function ($value,$data){
return Db::table('fa_szxc_information_usermsg')->where('user_id',$data['user_id'])->value('name');
})
->withAttr('area',function ($value,$data){
return Db::table('fa_geo_area')->where('area_code',$data['county'])->value('area_name');
})
->withAttr('street',function ($value,$data){
return Db::table('fa_geo_street')->where('street_code',$data['township'])->value('street_name');
})
->withAttr('village',function ($value,$data){
return Db::table('fa_geo_village')->where('village_id',$data['village'])->value('village_name');
})
->where($where)
->where($map)
->page($params['page'])
->limit($params['limit'])
->order('id desc')
->field('id,title,user_id,county,township,village,image,view_time')
->select();
$result = ['total' => $total, 'data' => $list];
return table_assign(0, '', $result);
}
return view('',['url'=>$this->url]);
}
/**
* 添加
*/
public function add()
{
if (request()->isAjax()) {
$params= get_params();
$params['category_id']=$this->category_id;
(new Article())->add($params);
}else{
View::assign('editor', get_system_config('other','editor'));
View::assign('url', $this->url);
return view('nk/article/add');
}
}
/**
* 修改
*/
public function edit()
{
$params= get_params();
(new Article())->edit($params);
return view('nk/article/edit',['url'=>$this->url]);
}
/**
* 查看信息
*/
public function read()
{
$params = get_params();
(new Article())->read($params);
return view('nk/article/read',['url'=>$this->url]);
}
/**
* 修改
*/
public function del()
{
$params= get_params();
(new Article())->del($params);
}
}

View File

@ -0,0 +1,102 @@
<?php
/*
* @Author: mkm
* @Date: 2023-02-12 10:38:40
* @LastEditTime: 2023-02-12 11:09:35
* @LastEditors: your name
* @Description:
* @FilePath: \nk-lihaink-cn\app\admin\controller\nk\StreetElegant.php
* 可以输入预定的版权声明、个性签名、空行等
*/
namespace app\admin\controller\nk;
use app\admin\BaseController;
use think\exception\ValidateException;
use think\facade\Db;
use app\admin\controller\nk\Article;
use think\facade\View;
/**
* 乡镇风采
*
* @icon fa fa-circle-o
*/
class StreetElegant extends BaseController
{
public function __construct()
{
$this->adminInfo = get_login_admin();
$this->category_id=305;
$this->url=[
'/admin/nk.street_elegant/index?category_id='.$this->category_id,
'/admin/nk.street_elegant/add',
'/admin/nk.street_elegant/edit',
'/admin/nk.street_elegant/del',
'/admin/nk.street_elegant/read',
];
}
/**
* 查看
*/
public function index()
{
if (request()->isAjax()) {
$params= get_params();
$params['category_id']=$this->category_id;
(new Article())->index($params);
}
return view('',['url'=>$this->url]);
}
/**
* 添加
*/
public function add()
{
if (request()->isAjax()) {
$params= get_params();
$params['category_id']=$this->category_id;
(new Article())->add($params);
}else{
View::assign('editor', get_system_config('other','editor'));
View::assign('url', $this->url);
// 获取用户信息
$this->users = Db::table('fa_szxc_information_usermsg')->where('status',1)->field('user_id,name')->select();
View::assign('users', $this->users);
$street = Db::table('fa_geo_area')->where(['switch' => 1, 'city_code' => '510500'])
->field('area_id id,area_code code,area_name name')
->select();
View::assign('street', $street);
return view('nk/article/add');
}
}
/**
* 修改
*/
public function edit()
{
$params= get_params();
(new Article())->edit($params);
return view('nk/article/edit',['url'=>$this->url]);
}
/**
* 查看信息
*/
public function read()
{
$params = get_params();
(new Article())->read($params);
return view('nk/article/read',['url'=>$this->url]);
}
/**
* 修改
*/
public function del()
{
$params= get_params();
(new Article())->del($params);
}
}

View File

@ -0,0 +1,93 @@
<?php
namespace app\admin\controller\nk;
use app\admin\BaseController;
use think\exception\ValidateException;
use think\facade\Db;
use app\admin\controller\nk\Article;
use think\facade\View;
/**
* 文章
*
* @icon fa fa-circle-o
*/
class System extends BaseController
{
public function __construct()
{
$this->adminInfo = get_login_admin();
$this->category_id=297;
$this->url=[
'/admin/nk.system/index?category_id='.$this->category_id,
'/admin/nk.system/add',
'/admin/nk.system/edit',
'/admin/nk.system/del',
'/admin/nk.system/read',
];
}
/**
* 查看
*/
public function index()
{
if (request()->isAjax()) {
$params= get_params();
$params['category_id']=$this->category_id;
(new Article())->index($params);
}
return view('nk/article/index',['url'=>$this->url]);
}
/**
* 添加
*/
public function add()
{
if (request()->isAjax()) {
$params= get_params();
$params['category_id']=$this->category_id;
(new Article())->add($params);
}else{
View::assign('editor', get_system_config('other','editor'));
View::assign('url', $this->url);
// 获取用户信息
$this->users = Db::table('fa_szxc_information_usermsg')->where('status',1)->field('user_id,name')->select();
View::assign('users', $this->users);
$street = Db::table('fa_geo_area')->where(['switch' => 1, 'city_code' => '510500'])
->field('area_id id,area_code code,area_name name')
->select();
View::assign('street', $street);
return view('nk/article/add');
}
}
/**
* 修改
*/
public function edit()
{
$params= get_params();
(new Article())->edit($params);
return view('nk/article/edit',['url'=>$this->url]);
}
/**
* 查看信息
*/
public function read()
{
$params = get_params();
(new Article())->read($params);
return view('nk/article/read',['url'=>$this->url]);
}
/**
* 修改
*/
public function del()
{
$params= get_params();
(new Article())->del($params);
}
}

View File

@ -0,0 +1,93 @@
<?php
namespace app\admin\controller\nk;
use app\admin\BaseController;
use think\exception\ValidateException;
use think\facade\Db;
use app\admin\controller\nk\Article;
use think\facade\View;
/**
* 文章
*
* @icon fa fa-circle-o
*/
class SzxcNotice extends BaseController
{
public function __construct()
{
$this->adminInfo = get_login_admin();
$this->category_id=164;
$this->url=[
'/admin/nk.szxc_notice/index?category_id='.$this->category_id,
'/admin/nk.szxc_notice/add',
'/admin/nk.szxc_notice/edit',
'/admin/nk.szxc_notice/del',
'/admin/nk.szxc_notice/read',
];
}
/**
* 查看
*/
public function index()
{
if (request()->isAjax()) {
$params= get_params();
$params['category_id']=$this->category_id;
(new Article())->index($params);
}
return view('nk/article/index',['url'=>$this->url]);
}
/**
* 添加
*/
public function add()
{
if (request()->isAjax()) {
$params= get_params();
$params['category_id']=$this->category_id;
(new Article())->add($params);
}else{
View::assign('editor', get_system_config('other','editor'));
View::assign('url', $this->url);
// 获取用户信息
$this->users = Db::table('fa_szxc_information_usermsg')->where('status',1)->field('user_id,name')->select();
View::assign('users', $this->users);
$street = Db::table('fa_geo_area')->where(['switch' => 1, 'city_code' => '510500'])
->field('area_id id,area_code code,area_name name')
->select();
View::assign('street', $street);
return view('nk/article/add');
}
}
/**
* 修改
*/
public function edit()
{
$params= get_params();
(new Article())->edit($params);
return view('nk/article/edit',['url'=>$this->url]);
}
/**
* 查看信息
*/
public function read()
{
$params = get_params();
(new Article())->read($params);
return view('nk/article/read',['url'=>$this->url]);
}
/**
* 修改
*/
public function del()
{
$params= get_params();
(new Article())->del($params);
}
}

View File

@ -0,0 +1,93 @@
<?php
namespace app\admin\controller\nk;
use app\admin\BaseController;
use think\exception\ValidateException;
use think\facade\Db;
use app\admin\controller\nk\Article;
use think\facade\View;
/**
* 文章
*
* @icon fa fa-circle-o
*/
class Townnews extends BaseController
{
public function __construct()
{
$this->adminInfo = get_login_admin();
$this->category_id=304;
$this->url=[
'/admin/nk.townnews/index?category_id='.$this->category_id,
'/admin/nk.townnews/add',
'/admin/nk.townnews/edit',
'/admin/nk.townnews/del',
'/admin/nk.townnews/read',
];
}
/**
* 查看
*/
public function index()
{
if (request()->isAjax()) {
$params= get_params();
$params['category_id']=$this->category_id;
(new Article())->index($params);
}
return view('nk/article/index',['url'=>$this->url]);
}
/**
* 添加
*/
public function add()
{
if (request()->isAjax()) {
$params= get_params();
$params['category_id']=$this->category_id;
(new Article())->add($params);
}else{
View::assign('editor', get_system_config('other','editor'));
View::assign('url', $this->url);
// 获取用户信息
$this->users = Db::table('fa_szxc_information_usermsg')->where('status',1)->field('user_id,name')->select();
View::assign('users', $this->users);
$street = Db::table('fa_geo_area')->where(['switch' => 1, 'city_code' => '510500'])
->field('area_id id,area_code code,area_name name')
->select();
View::assign('street', $street);
return view('nk/article/add');
}
}
/**
* 修改
*/
public function edit()
{
$params= get_params();
(new Article())->edit($params);
return view('nk/article/edit',['url'=>$this->url]);
}
/**
* 查看信息
*/
public function read()
{
$params = get_params();
(new Article())->read($params);
return view('nk/article/read',['url'=>$this->url]);
}
/**
* 修改
*/
public function del()
{
$params= get_params();
(new Article())->del($params);
}
}

View File

@ -0,0 +1,93 @@
<?php
namespace app\admin\controller\nk;
use app\admin\BaseController;
use think\exception\ValidateException;
use think\facade\Db;
use app\admin\controller\nk\Article;
use think\facade\View;
/**
* 文章
*
* @icon fa fa-circle-o
*/
class Transaction extends BaseController
{
public function __construct()
{
$this->adminInfo = get_login_admin();
$this->category_id=356;
$this->url=[
'/admin/nk.transaction/index?category_id='.$this->category_id,
'/admin/nk.transaction/add',
'/admin/nk.transaction/edit',
'/admin/nk.transaction/del',
'/admin/nk.transaction/read',
];
}
/**
* 查看
*/
public function index()
{
if (request()->isAjax()) {
$params= get_params();
$params['category_id']=$this->category_id;
(new Article())->index($params);
}
return view('nk/article/index',['url'=>$this->url]);
}
/**
* 添加
*/
public function add()
{
if (request()->isAjax()) {
$params= get_params();
$params['category_id']=$this->category_id;
(new Article())->add($params);
}else{
View::assign('editor', get_system_config('other','editor'));
View::assign('url', $this->url);
// 获取用户信息
$this->users = Db::table('fa_szxc_information_usermsg')->where('status',1)->field('user_id,name')->select();
View::assign('users', $this->users);
$street = Db::table('fa_geo_area')->where(['switch' => 1, 'city_code' => '510500'])
->field('area_id id,area_code code,area_name name')
->select();
View::assign('street', $street);
return view('nk/article/add');
}
}
/**
* 修改
*/
public function edit()
{
$params= get_params();
(new Article())->edit($params);
return view('nk/article/edit',['url'=>$this->url]);
}
/**
* 查看信息
*/
public function read()
{
$params = get_params();
(new Article())->read($params);
return view('nk/article/read',['url'=>$this->url]);
}
/**
* 修改
*/
public function del()
{
$params= get_params();
(new Article())->del($params);
}
}

View File

@ -0,0 +1,93 @@
<?php
namespace app\admin\controller\nk;
use app\admin\BaseController;
use think\exception\ValidateException;
use think\facade\Db;
use app\admin\controller\nk\Article;
use think\facade\View;
/**
* 文章
*
* @icon fa fa-circle-o
*/
class Travel extends BaseController
{
public function __construct()
{
$this->adminInfo = get_login_admin();
$this->category_id=309;
$this->url=[
'/admin/nk.travel/index?category_id='.$this->category_id,
'/admin/nk.travel/add',
'/admin/nk.travel/edit',
'/admin/nk.travel/del',
'/admin/nk.travel/read',
];
}
/**
* 查看
*/
public function index()
{
if (request()->isAjax()) {
$params= get_params();
$params['category_id']=$this->category_id;
(new Article())->index($params);
}
return view('nk/article/index',['url'=>$this->url]);
}
/**
* 添加
*/
public function add()
{
if (request()->isAjax()) {
$params= get_params();
$params['category_id']=$this->category_id;
(new Article())->add($params);
}else{
View::assign('editor', get_system_config('other','editor'));
View::assign('url', $this->url);
// 获取用户信息
$this->users = Db::table('fa_szxc_information_usermsg')->where('status',1)->field('user_id,name')->select();
View::assign('users', $this->users);
$street = Db::table('fa_geo_area')->where(['switch' => 1, 'city_code' => '510500'])
->field('area_id id,area_code code,area_name name')
->select();
View::assign('street', $street);
return view('nk/article/add');
}
}
/**
* 修改
*/
public function edit()
{
$params= get_params();
(new Article())->edit($params);
return view('nk/article/edit',['url'=>$this->url]);
}
/**
* 查看信息
*/
public function read()
{
$params = get_params();
(new Article())->read($params);
return view('nk/article/read',['url'=>$this->url]);
}
/**
* 修改
*/
public function del()
{
$params= get_params();
(new Article())->del($params);
}
}

View File

@ -0,0 +1,91 @@
<?php
namespace app\admin\controller\nk;
use app\admin\BaseController;
use think\facade\Db;
use think\facade\View;
/**
* 文章
*
* @icon fa fa-circle-o
*/
class Treasure extends BaseController
{
public function __construct()
{
$this->adminInfo = get_login_admin();
$this->category_id=305;
$this->url=[
'/admin/nk.treasure/index?category_id='.$this->category_id,
'/admin/nk.treasure/add',
'/admin/nk.treasure/edit',
'/admin/nk.treasure/del',
'/admin/nk.treasure/read',
];
}
/**
* 查看
*/
public function index()
{
if (request()->isAjax()) {
$params= get_params();
$params['category_id']=$this->category_id;
(new Article())->index($params);
}
return view('nk/article/index',['url'=>$this->url]);
}
/**
* 添加
*/
public function add()
{
if (request()->isAjax()) {
$params= get_params();
$params['category_id']=$this->category_id;
(new Article())->add($params);
}else{
View::assign('editor', get_system_config('other','editor'));
View::assign('url', $this->url);
// 获取用户信息
$this->users = Db::table('fa_szxc_information_usermsg')->where('status',1)->field('user_id,name')->select();
View::assign('users', $this->users);
$street = Db::table('fa_geo_area')->where(['switch' => 1, 'city_code' => '510500'])
->field('area_id id,area_code code,area_name name')
->select();
View::assign('street', $street);
return view('nk/article/add');
}
}
/**
* 修改
*/
public function edit()
{
$params= get_params();
(new Article())->edit($params);
return view('nk/article/edit',['url'=>$this->url]);
}
/**
* 查看信息
*/
public function read()
{
$params = get_params();
(new Article())->read($params);
return view('nk/article/read',['url'=>$this->url]);
}
/**
* 修改
*/
public function del()
{
$params= get_params();
(new Article())->del($params);
}
}

View File

@ -0,0 +1,876 @@
<?php
namespace app\admin\controller\nk;
use app\admin\BaseController;
use think\facade\View;
use think\facade\Db;
/**
* 文章
*
* @icon fa fa-circle-o
*/
class User extends BaseController
{
public function __construct()
{
$this->adminInfo = get_login_admin();
$this->category_id = 305;
$this->url = [
'/admin/nk.user/index?category_id=' . $this->category_id,
'/admin/nk.user/add',
'/admin/nk.user/edit',
'/admin/nk.user/del',
'/admin/nk.user/read',
'/admin/nk.user/auths',
'/admin/nk.user/postedit',
];
}
/**
* 查看
*/
public function index()
{
if (request()->isAjax()) {
$mmm = [];
$map = [];
$post = get_params();
if (!empty($post['keywords'])) {
$map[] = ['m.name', 'LIKE', '%' . $post['keywords'] . '%'];
}
if (!empty($post['phone'])) {
$map[] = ['m.phone', 'LIKE', '%' . $post['phone'] . '%'];
}
//权限组信息
if ($this->adminInfo['group_access'] != 1) {
$find = Db::table('fa_szxc_information_useraddress')->where('admin_id', $this->adminInfo['id'])->find();
if ($find) {
if ($find['auth_range'] == 1) {
$mmm['area_id'] = $find['area_id'];
$mmm['street_id'] = $find['street_id'];
$mmm['village_id'] = $find['village_id'];
} elseif ($find['auth_range'] == 2) {
$mmm['area_id'] = $find['area_id'];
$mmm['street_id'] = $find['street_id'];
}elseif ($find['auth_range'] == 5) {
$mmm['area_id'] = $find['area_id'];
$mmm['street_id'] = $find['street_id'];
$mmm['village_id'] = $find['village_id'];
$mmm['brigade_id'] = $find['brigade_id'];
}
}
}
if ($post) {
if (isset($post['area_id']) && !empty($post['area_id'])) {
$mmm['area_id'] = $post['area_id'];
}
if (isset($post['street_id']) && !empty($post['street_id'])) {
$mmm['street_id'] = $post['street_id'];
}
if (isset($post['village_id']) && !empty($post['village_id'])) {
$mmm['village_id'] = $post['village_id'];
}
if (isset($post['brigade_id']) && !empty($post['brigade_id'])) {
$mmm['brigade_id'] = $post['brigade_id'];
}
}
//权限组信息
$total = Db::table('fa_szxc_information_usermsg')
->alias('m')
->where($mmm)
->where($map)
->count();
$list = Db::table('fa_szxc_information_usermsg')
->alias('m')
->where($mmm)
->where($map)
->join(['fa_user' => 'u'], 'm.user_id=u.id')
->join(['fa_user_group' => 'g'], 'g.id=u.group_id')
->field('u.id,m.name,m.phone,u.avatar,u.group_id,u.status,m.gender,m.age,g.name group_name,m.householder_id')
->withAttr('count', function ($value, $data) {
if ($data['householder_id'] != 0) {
$count = Db::table('fa_szxc_information_usermsg')->where('householder_id', $data['householder_id'])->count();
} else {
$count = '未绑定户主无法查询';
}
return $count;
})
->withAttr('gender', function ($value, $data) {
if ($value == 1) {
return '男';
} elseif ($value == 2) {
return '女';
}
})
->order('id DESC')
->page($post['page'])
->limit($post['limit'])
->select();
$result = ['total' => $total, 'data' => $list];
return table_assign(0, '', $result);
}
//权限组信息
if ($this->adminInfo['group_access'] != 1) { //不是超级管理员
$www['admin_id'] = $this->adminInfo['id'];
$user_address = Db::table('fa_szxc_information_useraddress')->where($www)->find();
if ($user_address) {
if ($user_address['auth_range'] <=3 &&$user_address['auth_range'] >=1 ) {
$select = Db::table('fa_geo_area')->where('city_code', '510500')->where('area_code', $user_address['area_id'])->select();
} else {
$select = Db::table('fa_geo_area')->where('city_code', '510500')->select();
}
View::assign('row', $user_address);
} else {
$user_address['area_id'] = '';
$user_address['street_id'] = '';
$user_address['village_id'] = '';
$user_address['auth_range'] = '1';
$select = Db::table('fa_geo_area')->where('city_code', '510500')->select();
View::assign('row', $user_address);
}
$is_admin = 0;
} else {
$user_address['area_id'] = '';
$user_address['street_id'] = '';
$user_address['village_id'] = '';
$user_address['auth_range'] = '';
$select = Db::table('fa_geo_area')->where('city_code', '510500')->select();
View::assign('row', $user_address);
$is_admin = 1;
}
View::assign('arealist', $select);
View::assign('is_admin', $is_admin);
View::assign('url', $this->url);
return view();
}
/**
* 添加
*/
public function add()
{
if (request()->isAjax()) {
$params = get_params();
$params['category_id'] = $this->category_id;
(new Article())->add($params);
} else {
View::assign('editor', get_system_config('other', 'editor'));
View::assign('url', $this->url);
return view('nk/article/add');
}
}
/**
* 修改
*/
public function edit()
{
$params = get_params();
$find = Db::table('fa_szxc_information_usermsg')
->where('user_id', $params['id'])->find();
//获取所有分类
$www2[] = ['type', 'in', ['Nation', 'Education', 'Occupation', 'Zzmm', 'Family', 'Nature_of_land', 'Blood_type', 'Drug_allergy', 'Exposure_history', 'History_of_disease', 'Whether_disabled', 'Cfpfss', 'Fuel_type', 'Drinking_water', 'Toilet_msg', 'Poultry_corral', 'Insurance_type', 'House', 'Car', 'Grade', 'Insurance', 'Medical_insurance_type', 'FamilyHistory', 'Marriage']];
$all_category = Db::table('fa_category')->where($www2)->field('id,type,name,pid')->select();
//种植信息
$planting = Db::table('fa_szxc_information_planting')->where('user_id', $params['id'])
->find();
//保险信息
$insurancearr = Db::table('fa_szxc_information_insurance')->where('user_id', $params['id'])->find();
//健康信息
$healthyarr = Db::table('fa_szxc_information_healthy')->where('user_id', $params['id'])->find();
if ($planting == null) {
$planting = [
"tools_msg" => "",
"crops_msg" => "",
"land_area" => "",
"is_wz" => '',
"nature_of_land" => "",
];
}else{
$strlen = strlen($planting['breed_msg']);
if ($strlen != 0 || $strlen > 10) {
$planting['breed_msg'] = json_decode($planting['breed_msg'], true);
}
$strlen1 = strlen($planting['crops_msg']);
if ($strlen1 != 0 || $strlen1 > 10) {
$planting['crops_msg'] = json_decode($planting['crops_msg'], true);
}
$strlen2 = strlen($planting['tools_msg']);
if ($strlen2 != 0 || $strlen2 > 10) {
$planting['tools_msg'] = json_decode($planting['tools_msg'], true);
}
}
if ($insurancearr == null) {
$insurancearr = [
"endowment_insurance_status" => "",
"is_subsidy" => "",
"insurance_reason" => "",
"medical_insurance_type" => "",
"whether_disabled" => "",
"disability_num" => "",
"disability_type" => "",
"disability_level" => "",
"insurance_type" => "",
"ny_insurance" => "",
"sy_insurance" => "",
];
}
if ($healthyarr == null) {
$healthyarr = [
"medical_insurance_type" => "",
"insurance_type" => "",
"blood_type" => "",
"drug_allergy" => "",
"exposure_history" => "",
"history_of_disease" => "",
"history_of_surgery" => "",
"family_history" => "",
"familial_diseases" => "",
"genetic_history" => "",
"genetic_name" => "",
"whether_disabled" => "",
"cfpfss" => "",
"fuel_type" => "",
"drinking_water" => "",
"toilet_msg" => "",
"poultry_corral" => "",
];
}
View::assign('user_id', $params['id']);
View::assign('healthyarr', $healthyarr);
View::assign('insurancearr', $insurancearr);
View::assign('planting', $planting);
View::assign('all_category', $all_category);
View::assign('user', $find);
View::assign('url', $this->url);
View::assign('editor', get_system_config('other', 'editor'));
return view();
}
/**
* 提交修改
*/
public function postedit()
{
$params = get_params();
// halt($params);
if ($params['type'] == 1) {
unset($params['type']);
$res = Db::table('fa_szxc_information_usermsg')->where('user_id', $params['user_id'])->update($params);
if ($res) {
return to_assign(0, '操作成功');
} else {
return to_assign(1, '操作失败');
}
}
if ($params['type'] == 2) {
$params['crops_msg'] = json_encode($params['crops_msg']);
unset($params['type']);
$find = Db::table('fa_szxc_information_planting')->where('user_id', $params['user_id'])->find();
if ($find) {
$res = Db::table('fa_szxc_information_planting')->where('id', $find['id'])->update($params);
$id = $find['id'];
} else {
$res = Db::table('fa_szxc_information_planting')->where('user_id', $params['user_id'])->insertGetId($params);
$id = $res;
}
if ($res) {
$time = time();
// 新增写入种植表
Db::table('fa_szxc_planting')->where('user_id',$params['user_id'])->delete();
$mianji = 0;
if($params['crops_msg']){
$crops_msg_arr = json_decode($params['crops_msg'],1);
foreach ($crops_msg_arr as $k=>$v){
// 根据名字查询分类
if($v['name']){
$type = Db::table('fa_szxc_planting_type')->where('name',$v['name'])->find();
if($type){
$planting_data['type_id'] = $type['id'];
}else{
$type_data['name'] = $v['name'];
$type_data['createtime'] = $time;
$type_id = Db::table('fa_szxc_planting_type')->strict(false)->insertGetId($type_data);
$planting_data['type_id'] = $type_id;
}
$planting_data['user_id'] = $params['user_id'];
$planting_data['num'] = $v['num']??0;
$planting_data['measure'] = $v['mianji']??0;
$planting_data['createtime'] = $time;
Db::table('fa_szxc_planting')->strict(false)->insertGetId($planting_data);
}
// 计算面积
if($v['mianji']){
$mianji += $v['mianji'];
}
}
}
// 新增写入养殖表
Db::table('fa_szxc_breed')->where('user_id',$params['user_id'])->delete();
// $mianji = 0;
if(isset($params['breed_msg']) && !empty($params['breed_msg'])){
$breed_msg_arr = json_decode($params['breed_msg'],1);
foreach ($breed_msg_arr as $k=>$v){
// 根据名字查询分类
if($v['name']){
$type = Db::table('fa_szxc_breed_type')->where('name',$v['name'])->find();
if($type){
$breed_data['type_id'] = $type['id'];
}else{
$type_data['name'] = $v['name'];
$type_data['createtime'] = $time;
$type_id = Db::table('fa_szxc_breed_type')->strict(false)->insertGetId($type_data);
$breed_data['type_id'] = $type_id;
}
$breed_data['user_id'] = $params['user_id'];
$breed_data['num'] = $v['num']??0;
$breed_data['measure'] = $v['mianji']??0;
$breed_data['createtime'] = $time;
Db::table('fa_szxc_breed')->strict(false)->insertGetId($breed_data);
}
}
}
$waste_land_area = $params['land_area'] - $mianji;
if($waste_land_area < 0){
$waste_land_area = 0;
}
$ddd['waste_land_area'] = $waste_land_area;
Db::table('fa_szxc_information_planting')->where('id', $id)->update($ddd);
return to_assign(0, '操作成功');
} else {
return to_assign(1, '操作失败');
}
}
if ($params['type'] == 3) {
unset($params['type']);
$find = Db::table('fa_szxc_information_insurance')->where('user_id', $params['user_id'])->find();
if ($find) {
$res = Db::table('fa_szxc_information_insurance')->where('id', $find['id'])->update($params);
} else {
$res = Db::table('fa_szxc_information_insurance')->where('user_id', $params['user_id'])->insert($params);
}
if ($res) {
return to_assign(0, '操作成功');
} else {
return to_assign(1, '操作失败');
}
}
if ($params['type'] == 4) {
unset($params['type']);
$find = Db::table('fa_szxc_information_healthy')->where('user_id', $params['user_id'])->find();
if ($find) {
$res = Db::table('fa_szxc_information_healthy')->where('id', $find['id'])->update($params);
} else {
$res = Db::table('fa_szxc_information_healthy')->where('user_id', $params['user_id'])->insert($params);
}
if ($res) {
return to_assign(0, '操作成功');
} else {
return to_assign(1, '操作失败');
}
}
}
/**
* 查看信息
*/
public function read()
{
$params = get_params();
$find = Db::table('fa_szxc_information_usermsg')
->withAttr('gender', function ($value, $data) {
if ($value == 1) {
return '男';
}
return '女';
})->withAttr('education', function ($value, $data) {
return Db::table('fa_category')->where('id', $value)->value('name');
})->withAttr('nation', function ($value, $data) {
return Db::table('fa_category')->where('id', $value)->value('name');
})->withAttr('political_outlook', function ($value, $data) {
return Db::table('fa_category')->where('id', $value)->value('name');
})->withAttr('house_msg', function ($value, $data) {
return Db::table('fa_category')->where('id', $value)->value('name');
})->withAttr('car_msg', function ($value, $data) {
return Db::table('fa_category')->where('id', $value)->value('name');
})->withAttr('marital_status', function ($value, $data) {
return Db::table('fa_category')->where('id', $value)->value('name');
})
->where('user_id', $params['id'])->find();
//家庭信息
//用户id
$user_id = $params['id'];
// 获取户主id
$f_where[] = ['user_ids','find in set',$user_id];
$family_arr = Db::table('fa_szxc_family')->where($f_where)->find();
if ($family_arr) {
$map[] = ['user_id','in',$family_arr['user_ids']];
} else {
$where['user_id'] = $user_id;
$where['status'] = 1;
$householder_id = Db::table('fa_szxc_information_usermsg')->where($where)->value('householder_id');
if ($householder_id) {
$map[] = ['householder_id','=',$householder_id];
$map[] = ['status','=',1];
} else {
$map[] = ['user_id','=',$user_id];
$map[] = ['status','=',1];
}
}
// 获取家庭的人员信息
$family['list'] = Db::table('fa_szxc_information_usermsg')->where($map)
->order('id desc')
->field("id,user_id,name,age,gender,family_num,political_outlook,householder_id,is_hz,address_name,family_relation,phone")
->withAttr('avatar', function ($value, $data) {
return Db::table('fa_user')->where('id', $data['user_id'])->value('avatar');
})
->select()->toArray();
if ($find['householder_id'] == $find['user_id']) {
$family['name'] = '本人';
} else {
$family['name'] = Db::table('fa_szxc_information_usermsg')->where('user_id', $find['householder_id'])->value('name');
$family['relation'] = Db::table('fa_category')->where('id', $find['family_relation'])->value('name');
}
// if ($find == null || $find['householder_id'] == 0) {
// $family['list'] = [];
// } else {
// if ($find['householder_id'] == $find['user_id']) {
// $family['name'] = '本人';
// } else {
// $family['name'] = Db::table('fa_szxc_information_usermsg')->where('user_id', $find['householder_id'])->value('name');
// $family['relation'] = Db::table('fa_category')->where('id', $find['family_relation'])->value('name');
// }
// $family['list'] = Db::table('fa_szxc_information_usermsg')->where('householder_id', $find['householder_id'])->where('user_id', '<>', $find['householder_id'])->field('user_id,name,age,gender,phone')->select();
// }
//种植信息
if ($find || $find['householder_id'] == $params['id']) {
$Planting['is'] = 1;
$Planting['list'] = [];
$finds = Db::table('fa_szxc_information_planting')->where('user_id', $params['id'])
->withAttr('crops_msg', function ($value, $data) {
return json_decode($value, true);
})
->withAttr('breed_msg', function ($value, $data) {
return json_decode($value, true);
})
->withAttr('tools_msg', function ($value, $data) {
return json_decode($value, true);
})
->withAttr('nature_of_land', function ($value, $data) {
return Db::table('fa_category')->where('id', $value)->value('name');
})
->withAttr('is_wz', function ($value, $data) {
return $value == 0 ? '否' : '是';
})
->find();
if ($find) {
$Planting['list'] = $finds;
}
} else {
$Planting['is'] = 0;
}
$insurancearr = Db::table('fa_szxc_information_insurance')
->withAttr('endowment_insurance_status', function ($value, $data) {
return Db::table('fa_category')->where('id', $value)->value('name');
})->withAttr('insurance_type', function ($value, $data) {
return Db::table('fa_category')->where('id', $value)->value('name');
})->withAttr('whether_disabled', function ($value, $data) {
return Db::table('fa_category')->where('id', $value)->value('name');
})->withAttr('disability_level', function ($value, $data) {
return Db::table('fa_category')->where('id', $value)->value('name');
})->withAttr('ny_insurance', function ($value, $data) {
return Db::table('fa_category')->where('id', $value)->value('name');
})->withAttr('sy_insurance', function ($value, $data) {
return Db::table('fa_category')->where('id', $value)->value('name');
})
->where('user_id', $params['id'])->find();
$healthyarr = Db::table('fa_szxc_information_healthy')
->withAttr('blood_type', function ($value, $data) {
return Db::table('fa_category')->where('id', $value)->value('name');
})->withAttr('drug_allergy', function ($value, $data) {
return Db::table('fa_category')->where('id', $value)->value('name');
})->withAttr('exposure_history', function ($value, $data) {
return Db::table('fa_category')->where('id', $value)->value('name');
})->withAttr('history_of_disease', function ($value, $data) {
return Db::table('fa_category')->where('id', $value)->value('name');
})->withAttr('history_of_surgery', function ($value, $data) {
return Db::table('fa_category')->where('id', $value)->value('name');
})->withAttr('family_history', function ($value, $data) {
return Db::table('fa_category')->where('id', $value)->value('name');
})->withAttr('familial_diseases', function ($value, $data) {
return Db::table('fa_category')->where('id', $value)->value('name');
})->withAttr('genetic_history', function ($value, $data) {
return Db::table('fa_category')->where('id', $value)->value('name');
})->withAttr('cfpfss', function ($value, $data) {
return Db::table('fa_category')->where('id', $value)->value('name');
})->withAttr('fuel_type', function ($value, $data) {
return Db::table('fa_category')->where('id', $value)->value('name');
})->withAttr('drinking_water', function ($value, $data) {
return Db::table('fa_category')->where('id', $value)->value('name');
})->withAttr('toilet_msg', function ($value, $data) {
return Db::table('fa_category')->where('id', $value)->value('name');
})->withAttr('poultry_corral', function ($value, $data) {
return Db::table('fa_category')->where('id', $value)->value('name');
})->withAttr('genetic_name', function ($value, $data) {
return Db::table('fa_category')->where('id', $value)->value('name');
})
->where('user_id', $params['id'])->find();
View::assign('id', $params['id']);
View::assign('read', $find);
View::assign('family', $family);
View::assign('planting', $Planting);
View::assign('insurancearr', $insurancearr);
View::assign('healthyarr', $healthyarr);
return view();
}
public function auths()
{
$params = get_params();
if (request()->isPost()) {
$admin = Db::name('Admin')->where('user_id', $params['id'])->find();
$user = Db::table('fa_user')->where('id', $params['id'])->find();
if ($params['village_id'] != '') {
$village = Db::table('fa_geo_village')->where('village_code', $params['village_id'])->find();
}
// 组装地址名
if ($params['area_id'] != '') {
$area_name = Db::table('fa_geo_area')->where('area_code', $params['area_id'])->value('area_name');
}
if ($params['street_id'] != '') {
$street_name = Db::table('fa_geo_street')->where('street_code', $params['street_id'])->value('street_name');
}
if ($params['brigade_id'] != '') {
$brigade_name = Db::table('fa_geo_brigade')->where('id', $params['brigade_id'])->value('brigade_name');
}
$address_name = $area_name . $street_name . $village['village_name'] . $brigade_name;
// $useraddress = [
// 'area_id' => $params['area_id'],
// 'street_id' => $params['street_id'],
// 'village_code' => $params['village_id'],
// 'brigade_id' => $params['brigade_id'],
// 'auth_range' => $params['auth_range'],
// 'village_id' => $params['village_id'] != '' ? $village['village_id'] : 0,
// 'admin_id' => $admin['id'],
// ];
if ($admin) {
Db::startTrans();
try {
if ($params['groupdata'] == 0) {
Db::name('admin_group_access')->where('uid', $admin['id'])->delete();
Db::name('Admin')->where('id', $admin['id'])->update(['status' => 0]);
} else {
$is_have_admin = Db::name('admin_group_access')->where('uid', $admin['id'])->find();
if ($is_have_admin) {
Db::name('admin_group_access')->where('uid', $admin['id'])->update(['group_id' => $params['groupdata']]);
} else {
$group_access2 = ['uid' => $admin['id'], 'group_id' => $params['groupdata']];
//写入权限组
Db::name('admin_group_access')->insert($group_access2);
}
Db::name('Admin')->where('id', $admin['id'])->update(['status' => 1]);
}
$useraddress = [
'area_id' => $params['area_id'],
'street_id' => $params['street_id'],
'village_code' => $params['village_id'],
'brigade_id' => $params['brigade_id'],
'auth_range' => $params['auth_range'],
'village_id' => $params['village_id'] != '' ? $village['village_id'] : 0,
'admin_id' => $admin['id'],
];
Db::table('fa_szxc_information_useraddress')->where('user_id', $params['id'])->update($useraddress);
// 修改user表
$ddd['is_admin'] = 1;
$ddd['group_id'] = $params['group_id'];
Db::table('fa_user')->where('id', $params['id'])->update($ddd);
// 修改商城关系表
$nk_user['n_user_id'] = $params['id'];
$is_nk_user = Db::connect('shop')->name('nk_user')->where($nk_user)->find();
if ($is_nk_user) {
$nk_data['group_id'] = $params['group_id'];
Db::connect('shop')->name('nk_user')->where($nk_user)->update($nk_data);
}
// 修改用户详细地址
$u_msg['address_name'] = $address_name;
$u_msg['area_id'] = $params['area_id'];
$u_msg['street_id'] = $params['street_id'];
$u_msg['village_id'] = $params['village_id'] != '' ? $village['village_id'] : 0;
$u_msg['brigade_id'] = $params['brigade_id'];
Db::table('fa_szxc_information_usermsg')->where('user_id', $params['id'])->update($u_msg);
// 提交事务
Db::commit();
} catch (\Exception $e) {
// 回滚事务
Db::rollback();
return to_assign(1, '操作失败,原因:' . $e->getMessage());
}
return to_assign(0, '操作成功');
} else {
$salt = set_salt(20);
$data = [
'user_id' => $params['id'],
'username' => $user['mobile'],
'nickname' => $user['nickname'],
'thumb' => $user['avatar'],
'mobile' => $user['mobile'],
'did' => 1,
'position_id' => 3,
'salt' => $salt,
'pwd' => set_password(123456, $salt),
'email' => '',
];
Db::startTrans();
try {
$w['user_id'] = $params['id'];
$is_have = Db::table('fa_szxc_information_useraddress')->where($w)->find();
// 创建管理员账号
$admin_id = Db::name('Admin')->insertGetId($data);
// 写入权限组
Db::name('AdminGroupAccess')->strict(false)->field(true)->insert([
'uid' => $admin_id,
'group_id' => $params['groupdata'],
]);
add_log('add', $this->adminInfo['id'], $params);
// Db::table('fa_auth_group_access')->insert($group_access);
// 修改user表
$ddd['is_admin'] = 1;
$ddd['group_id'] = $params['group_id'];
Db::table('fa_user')->where('id', $params['id'])->update($ddd);
// 修改商城关系表
$nk_user['n_user_id'] = $params['id'];
$is_nk_user = Db::connect('shop')->name('nk_user')->where($nk_user)->find();
if ($is_have) {
$useraddress = [
'user_id' => $params['id'],
'admin_id' => $admin_id,
'area_id' => $params['area_id'],
'street_id' => $params['street_id'],
'village_code' => $params['village_id'],
'village_id' => $village['village_id'],
'brigade_id' => $params['brigade_id'],
'auth_range' => $params['auth_range'],
];
Db::table('fa_szxc_information_useraddress')->where($w)->update($useraddress);
if ($is_nk_user) {
$useraddress['group_id'] = $params['group_id'];
unset($useraddress['user_id'],$useraddress['admin_id'],$useraddress['auth_range']);
Db::connect('shop')->name('nk_user')->where($nk_user)->update($useraddress);
}
} else {
$useraddress = [
'user_id' => $params['id'],
'admin_id' => $admin_id,
'area_id' => $params['area_id'],
'street_id' => $params['street_id'],
'village_code' => $params['village_id'],
'village_id' => $village['village_id'],
'brigade_id' => $params['brigade_id'],
'auth_range' => $params['auth_range'],
'createtime' => date('Y-m-d H:i:s')
];
Db::table('fa_szxc_information_useraddress')->insert($useraddress);
}
// 修改用户详细地址
$u_msg['address_name'] = $address_name;
$u_msg['area_id'] = $params['area_id'];
$u_msg['street_id'] = $params['street_id'];
$u_msg['village_id'] = $params['village_id'] != '' ? $village['village_id'] : 0;
$u_msg['brigade_id'] = $params['brigade_id'];
Db::table('fa_szxc_information_usermsg')->where('user_id', $params['id'])->update($u_msg);
// 提交事务
Db::commit();
} catch (\Exception $e) {
// 回滚事务
Db::rollback();
return to_assign(1, '操作失败,原因:' . $e->getMessage());
}
return to_assign(0, '操作成功');
}
}
$user = Db::table('fa_user')->where('id', $params['id'])->field('id,nickname,group_id')->find();
// $geo_brigade = Db::table('fa_geo_brigade')->select();
$useraddress = [
'area_id' => 0,
'street_id' => 0,
'village_id' => 0,
'village_code' => 0,
'brigade_id' => 0,
'admin_group' => 0,
'auth_range' => 1,
];
$address = Db::table('fa_szxc_information_useraddress')->where('user_id', $params['id'])->find();
if ($address) {
$useraddress['area_id'] = $address['area_id'];
$useraddress['street_id'] = $address['street_id'];
$useraddress['village_id'] = $address['village_id'];
$useraddress['brigade_id'] = $address['brigade_id'];
$useraddress['village_code'] = $address['village_code'];
$useraddress['auth_range'] = $address['auth_range'];
$admin = Db::name('admin_group_access')->where('uid', $address['admin_id'])->find();
if ($admin) {
$useraddress['admin_group'] = $admin['group_id'];
}
}
//权限组信息
$groupwhere[] = ['id', '<>', 1];
if ($this->adminInfo['group_access'] != 1) { //不是超级管理员
// $www['admin_id'] = $this->adminInfo['id'];
// $user_address = Db::table('fa_szxc_information_useraddress')->where($www)->find();
// if ($user_address) {
if ($this->adminInfo['group_access'] == 2) {
$auth_range = [['name' => '村级', 'value' => '1']];
$groupwhere[] = ['id', '=', 2];
}
if ($this->adminInfo['group_access'] == 4) {
$auth_range = [['name' => '村级', 'value' => '1'], ['name' => '乡镇', 'value' => '2']];
$groupwhere['id'] = [ '=',[2,4]];
}
// if ($user_address['auth_range'] == 3) {
// $auth_range = [['name' => '村级', 'value' => '1'], ['name' => '乡镇', 'value' => '2'], ['name' => '区县', 'value' => '3']];
// }
// if ($user_address['auth_range'] == 4) {
// $auth_range = [['name' => '村级', 'value' => '1'], ['name' => '乡镇', 'value' => '2'], ['name' => '区县', 'value' => '3'], ['name' => '市级', 'value' => '4']];
// }
// }
} else {
$auth_range = [['name' => '小组', 'value' => '5'],['name' => '村级', 'value' => '1'], ['name' => '乡镇', 'value' => '2'], ['name' => '区县', 'value' => '3'], ['name' => '市级', 'value' => '4']];
}
$street = Db::table('fa_geo_area')->where(['switch' => 1, 'city_code' => '510500'])
->field('area_id id,area_code code,area_name name')
->select();
$brigade = Db::table('fa_geo_brigade')
->limit(30)
->select();
//后端权限
$groupdata = Db::name('admin_group')
->where($groupwhere)
->limit(30)
->select();
$groupdata[] = ['id' => 0, 'title' => '无后台权限'];
//前端权限
$user_group = Db::table('fa_user_group')
->limit(30)
->select();
View::assign('id', $params['id']);
View::assign('user_group', $user_group);
View::assign('groupdata', $groupdata);
View::assign('street', $street);
View::assign('brigade', $brigade);
View::assign('auth_range', $auth_range);
View::assign('user', $user);
View::assign('address', $useraddress);
View::assign('url', $this->url);
View::assign('editor', get_system_config('other', 'editor'));
return view();
}
public function tongji()
{
$post = get_params();
$where = [];
//权限组信息
$find = Db::table('fa_szxc_information_useraddress')->where('user_id', $this->adminInfo['user_id'])->find();
if ($find) {
if ($find['auth_range'] == 1) {
$mmm['area_id'] = $find['area_id'];
$mmm['street_id'] = $find['street_id'];
} elseif ($find['auth_range'] == 2) {
$mmm['area_id'] = $find['area_id'];
}
}
if (!empty($post['village_id'])) {
$where['village_id'] = $post['village_id'];
}
if (!empty($post['brigade_id'])) {
$where['brigade_id'] = $post['brigade_id'];
}
if (!empty($post['street_id'])) {
$where['street_id'] = $post['street_id'];
}
$where['area_id'] = $post['area_id'];
// 大于60岁人数
$old_num = Db::table('fa_szxc_information_usermsg')->where($where)->whereAge('>=', 60)->count();
// 儿童人数
$children_num = Db::table('fa_szxc_information_usermsg')->where($where)->whereAge('<', 15)->count();
// 未婚男
$unmarried_man_num = Db::table('fa_szxc_information_usermsg')->where($where)->where([['gender', '=', 1], ['marital_status', '=', 169]])->count();
// 未婚女
$unmarried_woman_num = Db::table('fa_szxc_information_usermsg')->where($where)->where([['gender', '=', 2], ['marital_status', '=', 169]])->count();
$land_area_num = Db::table('fa_szxc_information_useraddress')
->alias('u')
->where($where)
->join(['fa_szxc_information_planting'=>'p'], 'u.user_id = p.user_id')->sum('p.land_area');
$sum_218 = Db::table('fa_szxc_information_useraddress')
->alias('u')
->where($where)
->join(['fa_szxc_information_planting'=>'p'], 'u.user_id = p.user_id and p.nature_of_land=218')->sum('p.land_area');
$sum_217 = Db::table('fa_szxc_information_useraddress')
->alias('u')
->where($where)
->join(['fa_szxc_information_planting'=>'p'], 'u.user_id = p.user_id and p.nature_of_land=217')->sum('p.land_area');
$sum_216 = Db::table('fa_szxc_information_useraddress')
->alias('u')
->where($where)
->join(['fa_szxc_information_planting'=>'p'], 'u.user_id = p.user_id and p.nature_of_land=216')->sum('p.land_area');
$sum_215 = Db::table('fa_szxc_information_useraddress')
->alias('u')
->where($where)
->join(['fa_szxc_information_planting'=>'p'], 'u.user_id = p.user_id and p.nature_of_land=215')->sum('p.land_area');
$sum_214 = Db::table('fa_szxc_information_useraddress')
->alias('u')
->where($where)
->join(['fa_szxc_information_planting'=>'p'], 'u.user_id = p.user_id and p.nature_of_land=214')->sum('p.land_area');
$sum_70 = Db::table('fa_szxc_information_useraddress')
->alias('u')
->where($where)
->join(['fa_szxc_information_planting'=>'p'], 'u.user_id = p.user_id and p.nature_of_land=70')->sum('p.land_area');
$sum_69 = Db::table('fa_szxc_information_useraddress')
->alias('u')
->where($where)
->join(['fa_szxc_information_planting'=>'p'], 'u.user_id = p.user_id and p.nature_of_land=69')->sum('p.land_area');
$result = [
'old_num' => $old_num,
'children_num' => $children_num,
'unmarried_man_num' => $unmarried_man_num,
'unmarried_woman_num' => $unmarried_woman_num,
'land_area_num' => $land_area_num,
'sum_218' => $sum_218,
'sum_217' => $sum_217,
'sum_216' => $sum_216,
'sum_215' => $sum_215,
'sum_214' => $sum_214,
'sum_70' => $sum_70,
'sum_69' => $sum_69,
];
$result = ['total' => 0, 'data' => $result];
return table_assign(0, '', $result);
}
/**
* 修改
*/
public function del()
{
$params = get_params();
(new Article())->del($params);
}
}

View File

@ -0,0 +1,233 @@
<?php
namespace app\admin\controller\nk;
use app\admin\BaseController;
use think\facade\Db;
use think\facade\View;
/**
* 蔬菜基地
*
* @icon fa fa-circle-o
*/
class Vegetable extends BaseController
{
/**
* 构造函数
*/
public function __construct()
{
$this->adminInfo = get_login_admin();
$this->url=[
'/admin/nk.vegetable/index',
'/admin/nk.vegetable/add',
'/admin/nk.vegetable/edit',
'/admin/nk.vegetable/del',
'/admin/nk.vegetable/read',
];
}
/**
* 数据列表
*/
public function index()
{
if (request()->isAjax()) {
$params= get_params();
$where[]= ['status','=',1];
if (isset($params['keywords']) && !empty($params['keywords'])){
$where[]= ['title','like','%'.$params['keywords'].'%'];
}
if($this->adminInfo['position_id'] != 1){ //不是超级管理员
$www['admin_id'] = $this->adminInfo['id'];
$user_address = Db::table('fa_szxc_information_useraddress')->where($www)->find();
if ($user_address){
if($user_address['auth_range'] == 1){
$where[] = ['village_id','=',$user_address['village_id']];
}elseif ($user_address['auth_range'] == 2){
$where[] = ['street_id','=',$user_address['street_id']];
}elseif ($user_address['auth_range'] == 3){
$where[] = ['area_id','=',$user_address['area_id']];
}else{
$where[] = ['village_id','=',$user_address['village_id']];
}
}else{
$where[] = ['village_id','=',''];
}
}
$total = Db::table('cms_manufacturer')
->where($where)
->count();
$list = Db::table('cms_manufacturer')
->withAttr('area_id',function ($value,$data){
return Db::table('fa_geo_area')->where('area_code',$data['area_id'])->value('area_name');
})
->withAttr('street_id',function ($value,$data){
return Db::table('fa_geo_street')->where('street_code',$data['street_id'])->value('street_name');
})
->withAttr('village_id',function ($value,$data){
return Db::table('fa_geo_village')->where('village_id',$data['village_id'])->value('village_name');
})
->withAttr('status',function ($value,$data){
if($value == 1){
return '正常';
}else{
return '禁用';
}
})
->where($where)
->page($params['page'])
->limit($params['limit'])
->order('id desc')
->select();
$result = ['total' => $total, 'data' => $list];
return table_assign(0, '', $result);
}
else{
return view('nk/vegetable/index',['url'=>$this->url]);
}
}
public function add(){
if (request()->isAjax()) {
$param= get_params();
$adds=Db::table('fa_szxc_information_useraddress')->where('admin_id',$this->adminInfo['id'])->find();
$param['area_id']=$adds['area_id'];
$param['street_id']=$adds['street_id'];
$param['village_id']=$adds['village_id'];
$param['add_time']=date('Y-m-d H:i:s');
$res=Db::table('cms_manufacturer')->strict(false)->field(true)->insertGetId($param);
if ($res){
return to_assign(0,'操作成功',['aid'=>$res]);
}
return to_assign(1, '操作失败,原因:'.$res);
}else{
View::assign('editor', get_system_config('other','editor'));
return view();
}
}
public function edit(){
$param= get_params();
if (request()->isAjax()) {
$res=Db::table('cms_manufacturer')->where('id',$param['id'])->strict(false)->field(true)->update($param);
if ($res){
return to_assign();
}else{
return to_assign(1, '操作失败,原因:'.$res);
}
}else{
$id = isset($param['id']) ? $param['id'] : 0;
$detail = Db::table('cms_manufacturer')->where('id',$id)->find();
View::assign('editor', get_system_config('other','editor'));
if (!empty($detail)) {
View::assign('detail', $detail);
return view();
}
else{
throw new \think\exception\HttpException(404, '找不到页面');
}
}
}
/**
* 查看信息
*/
public function read()
{
$param= get_params();
$id = isset($param['id']) ? $param['id'] : 0;
$detail = Db::table('cms_manufacturer')->where('id',$id)->find();
if (!empty($detail)) {
View::assign('detail', $detail);
if($this->adminInfo['position_id'] != 1){ //不是超级管理员
$www['admin_id'] = $this->adminInfo['id'];
$user_address = Db::table('fa_szxc_information_useraddress')->where($www)->find();
if ($user_address){
if($user_address['auth_range'] == 1){
$where[] = ['village_id','=',$user_address['village_id']];
}elseif ($user_address['auth_range'] == 2){
$where[] = ['street_id','=',$user_address['street_id']];
}elseif ($user_address['auth_range'] == 3){
$where[] = ['area_id','=',$user_address['area_id']];
}else{
$where[] = ['village_id','=',$user_address['village_id']];
}
}else{
$where[] = ['village_id','=',''];
}
}else{
$where = [];
}
$farmers = Db::table('cms_farm_product_market')->where($where)->where('status',1)->select()->toArray();
if($farmers){
foreach ($farmers as $k =>$v){
$farmers[$k]['juli'] = $this->getDistance($detail['lng'],$detail['lat'],$v['lng'],$v['lat'],2);
}
}else{
$farmers = [];
}
View::assign('farmers', $farmers);
return view();
}
else{
throw new \think\exception\HttpException(404, '找不到页面');
}
}
/**
* 计算两点地理坐标之间的距离
* @param Decimal $longitude1 起点经度
* @param Decimal $latitude1 起点纬度
* @param Decimal $longitude2 终点经度
* @param Decimal $latitude2 终点纬度
* @param Int $unit 单位 1: 2:公里
* @param Int $decimal 精度 保留小数位数
* @return Decimal
*/
function getDistance($longitude1, $latitude1, $longitude2, $latitude2, $unit=2, $decimal=2){
$EARTH_RADIUS = 6370.996; // 地球半径系数
$PI = 3.1415926;
$radLat1 = $latitude1 * $PI / 180.0;
$radLat2 = $latitude2 * $PI / 180.0;
$radLng1 = $longitude1 * $PI / 180.0;
$radLng2 = $longitude2 * $PI /180.0;
$a = $radLat1 - $radLat2;
$b = $radLng1 - $radLng2;
$distance = 2 * asin(sqrt(pow(sin($a/2),2) + cos($radLat1) * cos($radLat2) * pow(sin($b/2),2)));
$distance = $distance * $EARTH_RADIUS * 1000;
if($unit==2){
$distance = $distance / 1000;
}
return round($distance, $decimal);
}
/**
* 删除
*/
public function del()
{
$param= get_params();
$id = isset($param['id']) ? $param['id'] : 0;
$type = isset($param['type']) ? $param['type'] : 0;
$res = Db::table('cms_manufacturer')->where('id',$id)->delete();
if ($res){
return to_assign();
}else{
return to_assign(1, '操作失败,原因:'.$res);
}
}
}

View File

@ -0,0 +1,237 @@
<?php
namespace app\admin\controller\nk;
use app\admin\BaseController;
use app\admin\controller\nk\Article;
use think\exception\ValidateException;
use think\facade\Db;
use think\facade\View;
/**
* 文章
*
* @icon fa fa-circle-o
*/
class Village extends BaseController
{
public function __construct()
{
$this->adminInfo = get_login_admin();
$this->url=[
'/admin/nk.village/index',
'/admin/nk.village/add',
'/admin/nk.village/edit',
'/admin/nk.village/del',
'/admin/nk.village/read',
];
}
/**
* 查看
*/
public function index()
{
if (request()->isAjax()) {
$params= get_params();
$where[]=['status','=',1];
$where[]=['village_id','>',0];
if (isset($params['keywords'])){
$where[]=['title','like','%'.$params['keywords'].'%'];
}
if($this->adminInfo['position_id'] != 1){ //不是超级管理员
$www['admin_id'] = $this->adminInfo['id'];
$user_address = Db::table('fa_szxc_information_useraddress')->where($www)->find();
if ($user_address){
if($user_address['auth_range'] == 1){
$where[] = ['village_id','=',$user_address['village_id']];
}elseif ($user_address['auth_range'] == 2){
$where[] = ['street_id','=',$user_address['street_id']];
}elseif ($user_address['auth_range'] == 3){
$where[] = ['area_id','=',$user_address['area_id']];
}else{
$where[] = ['village_id','=',$user_address['village_id']];
}
}else{
$where[] = ['village_id','=',''];
}
}
$total = Db::table('fa_szxc_village')
->where($where)->count();
$list = Db::table('fa_szxc_village')
->withAttr('is_hot',function ($value,$data){
return $value==1?'是':'否';
})
->withAttr('is_tourism',function ($value,$data){
return $value==1?'是':'否';
})
->where($where)
->page($params['page'])
->limit($params['limit'])
->order('id desc')
->select();
$result = ['total' => $total, 'data' => $list];
return table_assign(0, '', $result);
}
View::assign('url', $this->url);
return view();
}
/**
* 添加
*/
public function add()
{
$adds=Db::table('fa_szxc_information_useraddress')->where('admin_id',$this->adminInfo['id'])->find();
if (request()->isAjax()) {
$params= get_params();
if (!empty($params['is_hot'])&&$params['is_hot']=='on'){
$params['is_hot']=1;
}else{
$params['is_hot']=0;
}
if (!empty($params['is_tourism'])&&$params['is_tourism']=='on'){
$params['is_tourism']=1;
}else{
$params['is_tourism']=0;
}
if(empty($params['village_id'])){
return to_assign(1, '请选择村/社区');
}
if($this->adminInfo['position_id'] != 1){ //不是超级管理员
$params['area_id']=$adds['area_id'];
$params['street_id']=$adds['street_id'];
}
$area_code=Db::table('fa_geo_area')->where('area_code',$params['area_id'])->value('area_name');
$street_code=Db::table('fa_geo_street')->where('street_code',$params['street_id'])->value('street_name');
$village_id=Db::table('fa_geo_village')->where('village_id',$params['village_id'])->value('village_name');
$params['address']='泸州市'.$area_code.$street_code.$village_id;
$params['createtime']=time();
$res=Db::table('fa_szxc_village')->strict(false)->field(true)->insertGetId($params);
if ($res){
return to_assign(0,'操作成功',['aid'=>$res]);
}
return to_assign(1, '操作失败,原因:'.$res);
}
if($this->adminInfo['position_id'] != 1){ //不是超级管理员
$www['admin_id'] = $this->adminInfo['id'];
$user_address = Db::table('fa_szxc_information_useraddress')->where($www)->find();
if ($user_address['auth_range'] == 1) {
$street = Db::table('fa_geo_area')->where('city_code', '510500')->field('area_id id,area_code code,area_name name')->where('area_code', $user_address['area_id'])->select();
} elseif ($user_address['auth_range'] == 2) {
$street = Db::table('fa_geo_area')->where('city_code', '510500')->field('area_id id,area_code code,area_name name')->where('area_code', $user_address['area_id'])->select();
} elseif ($user_address['auth_range'] == 3) {
$street = Db::table('fa_geo_area')->where('city_code', '510500')->field('area_id id,area_code code,area_name name')->where('area_code', $user_address['area_id'])->select();
} elseif ($user_address['auth_range'] == 4) {
$street = Db::table('fa_geo_area')->where('city_code', '510500')->field('area_id id,area_code code,area_name name')->select();
} else {
$street = Db::table('fa_geo_area')->where('city_code', '510500')->field('area_id id,area_code code,area_name name')->select();
}
}else{
$street = Db::table('fa_geo_area')->where(['switch' => 1, 'city_code' => '510500'])
->field('area_id id,area_code code,area_name name')
->select();
}
View::assign('street', $street);
View::assign('detail', $adds);
View::assign('editor', get_system_config('other','editor'));
View::assign('url', $this->url);
View::assign('admin_id', $this->adminInfo['id']);
return view();
}
/**
* 修改
*/
public function edit()
{
$params= get_params();
if (request()->isAjax()) {
if (!empty($params['is_hot'])&&$params['is_hot']=='on'){
$params['is_hot']=1;
}else{
$params['is_hot']=0;
}
if (!empty($params['is_tourism'])&&$params['is_tourism']=='on'){
$params['is_tourism']=1;
}else{
$params['is_tourism']=0;
}
if(empty($params['village_id'])){
return to_assign(1, '请选择村/社区');
}
$adds=Db::table('fa_szxc_information_useraddress')->where('admin_id',$this->adminInfo['id'])->find();
if($this->adminInfo['position_id'] != 1){ //不是超级管理员
$params['area_id']=$adds['area_id'];
$params['street_id']=$adds['street_id'];
}
$area_code=Db::table('fa_geo_area')->where('area_code',$params['area_id'])->value('area_name');
$street_code=Db::table('fa_geo_street')->where('street_code',$params['street_id'])->value('street_name');
$village_id=Db::table('fa_geo_village')->where('village_id',$params['village_id'])->value('village_name');
$params['address']='泸州市'.$area_code.$street_code.$village_id;
$res=Db::table('fa_szxc_village')->where('id',$params['id'])->strict(false)->field(true)->update($params);
if ($res){
return to_assign();
}else{
return to_assign(1, '操作失败,原因:'.$res);
}
}
$detail = Db::table('fa_szxc_village')->where('id',$params['id'])->find();
if($this->adminInfo['position_id'] != 1){ //不是超级管理员
$www['admin_id'] = $this->adminInfo['id'];
$user_address = Db::table('fa_szxc_information_useraddress')->where($www)->find();
if ($user_address['auth_range'] == 1) {
$street = Db::table('fa_geo_area')->where('city_code', '510500')->field('area_id id,area_code code,area_name name')->where('area_code', $user_address['area_id'])->select();
} elseif ($user_address['auth_range'] == 2) {
$street = Db::table('fa_geo_area')->where('city_code', '510500')->field('area_id id,area_code code,area_name name')->where('area_code', $user_address['area_id'])->select();
} elseif ($user_address['auth_range'] == 3) {
$street = Db::table('fa_geo_area')->where('city_code', '510500')->field('area_id id,area_code code,area_name name')->where('area_code', $user_address['area_id'])->select();
} elseif ($user_address['auth_range'] == 4) {
$street = Db::table('fa_geo_area')->where('city_code', '510500')->field('area_id id,area_code code,area_name name')->select();
} else {
$street = Db::table('fa_geo_area')->where('city_code', '510500')->field('area_id id,area_code code,area_name name')->select();
}
}else{
$street = Db::table('fa_geo_area')->where(['switch' => 1, 'city_code' => '510500'])
->field('area_id id,area_code code,area_name name')
->select();
}
View::assign('street', $street);
View::assign('detail', $detail);
View::assign('url', $this->url);
View::assign('admin_id', $this->adminInfo['id']);
return view();
}
/**
* 查看信息
*/
public function read()
{
$params = get_params();
$detail = Db::table('fa_szxc_village')->where('id',$params['id'])->find();
View::assign('url', $this->url);
View::assign('detail', $detail);
return view();
}
/**
* 修改
*/
public function del()
{
$param= get_params();
$id = isset($param['id']) ? $param['id'] : 0;
$type = isset($param['type']) ? $param['type'] : 0;
$res = Db::table('fa_szxc_village')->where('id',$id)->update(['status'=>$type]);
if ($res){
return to_assign();
}else{
return to_assign(1, '操作失败,原因:'.$res);
}
}
}

View File

@ -0,0 +1,93 @@
<?php
namespace app\admin\controller\nk;
use app\admin\BaseController;
use think\exception\ValidateException;
use think\facade\Db;
use app\admin\controller\nk\Article;
use think\facade\View;
/**
* 文章
*
* @icon fa fa-circle-o
*/
class Welfare extends BaseController
{
public function __construct()
{
$this->adminInfo = get_login_admin();
$this->category_id=357;
$this->url=[
'/admin/nk.welfare/index?category_id='.$this->category_id,
'/admin/nk.welfare/add',
'/admin/nk.welfare/edit',
'/admin/nk.welfare/del',
'/admin/nk.welfare/read',
];
}
/**
* 查看
*/
public function index()
{
if (request()->isAjax()) {
$params= get_params();
$params['category_id']=$this->category_id;
(new Article())->index($params);
}
return view('nk/article/index',['url'=>$this->url]);
}
/**
* 添加
*/
public function add()
{
if (request()->isAjax()) {
$params= get_params();
$params['category_id']=$this->category_id;
(new Article())->add($params);
}else{
View::assign('editor', get_system_config('other','editor'));
View::assign('url', $this->url);
// 获取用户信息
$this->users = Db::table('fa_szxc_information_usermsg')->where('status',1)->field('user_id,name')->select();
View::assign('users', $this->users);
$street = Db::table('fa_geo_area')->where(['switch' => 1, 'city_code' => '510500'])
->field('area_id id,area_code code,area_name name')
->select();
View::assign('street', $street);
return view('nk/article/add');
}
}
/**
* 修改
*/
public function edit()
{
$params= get_params();
(new Article())->edit($params);
return view('nk/article/edit',['url'=>$this->url]);
}
/**
* 查看信息
*/
public function read()
{
$params = get_params();
(new Article())->read($params);
return view('nk/article/read',['url'=>$this->url]);
}
/**
* 修改
*/
public function del()
{
$params= get_params();
(new Article())->del($params);
}
}

View File

@ -0,0 +1,263 @@
<?php
namespace app\admin\controller\nk\common;
use think\db\exception\DbException as ExceptionDbException;
use think\exception\ValidateException;
use app\admin\BaseController;
use think\facade\Db;
use think\facade\View;
/**
* 文章处理
* 公共父类
*/
class Article extends BaseController {
const ARTICLE = 'fa_article';
protected $category_id;
function __construct(){
$this->adminInfo = get_login_admin();
// $this->pid = 361;
$this->category_id = 362;
$this->url=[
'/admin/nk.culturatour/index?category_id='.$this->category_id,
'/admin/nk.culturatour/add',
'/admin/nk.culturatour/edit',
'/admin/nk.culturatour/del',
'/admin/nk.culturatour/read',
];
}
/**
* 文章列表
*/
function Index(){
if (request()->isAjax()) {
$params= get_params();
$params['category_id']=$this->category_id;
$where = ['category_id'=>$this->category_id];
$list = Db::table('fa_article')->field('id')->where($where)
->page(1)
->limit(1)
->order('id desc')
->select();
(new Article())->index($params);
}
return view('nk/article/index',['url'=>$this->url]);
}
/**
* 查看文章 【无关联表】
*/
function Read(){
$params = get_params();
(new Article())->read($params);
return view('nk/article/read',['url'=>$this->url]);
}
/**
* 添加文章【无关联表】
*/
function Add(){
if (request()->isAjax()) {
$params= get_params();
$params['category_id']=$this->category_id;
// unset($params['amp;']);
(new Article())->add($params);
}else{
View::assign('editor', get_system_config('other','editor'));
View::assign('url', $this->url);
// 获取用户信息
$this->users = Db::table('fa_szxc_information_usermsg')->where('status',1)->field('user_id,name')->select();
View::assign('users', $this->users);
$street = Db::table('fa_geo_area')->where(['switch' => 1, 'city_code' => '510500'])
->field('area_id id,area_code code,area_name name')
->select();
View::assign('street', $street);
return view('nk/article/add');
}
}
/**
* 编辑文章 【无关联表】
*/
function Edit(){
$params= get_params();
(new Article())->edit($params);
return view('nk/article/edit',['url'=>$this->url]);
}
/**
* 删除文章【无关联表】
*/
function Del(){
$params= get_params();
(new Article())->del($params);
}
/**
* 添加文章与关联表数据.
* 【有关联表】
*/
function addArticle($param, $callback){
// 检验完整性
try {
validate(\app\admin\validate\nk\ArticleValidate::class)->check($param);
} catch (ValidateException $e) {
// 验证失败 输出错误信息
return to_assign(1, $e->getError());
}
$adds=Db::table('fa_szxc_information_useraddress')->where('admin_id',$this->adminInfo['id'])->find();
if($this->adminInfo['position_id'] != 1) { //不是超级管理员
$param['county']=$adds['area_id'];
$param['township']=$adds['street_id'];
$param['village']=$adds['village_id'];
$param['user_id']=$adds['user_id'];
}else{
if(empty($param['county'])){
$param['county']=$adds['area_id'];
}
if(empty($param['township'])){
$param['township']=$adds['street_id'];
}
if(empty($param['village'])){
$param['village']=$adds['village_id'];
}
if(empty($param['user_id'])){
$param['user_id']=$adds['user_id'];
}
}
$param['view_time']=date('Y-m-d H:i:s');
if(empty($param['category_type'])){
$param['category_type'] = 0;
}
if(empty($param['end_time'])){
$param['end_time'] = date('Y-m-d H:i:s');
}
Db::startTrans();
try{
// 新建文章
$aid = Db::table('fa_article')->strict(false)->field(true)->insertGetId($param);
// 新建文章相关表的信息
$pid = $callback($aid);
}catch(ExceptionDbException $e){
Db::rollback();
return to_assign(1, '操作失败,原因:'.$e->getMessage());
}
if (!empty($aid) && !empty($pid)) {
Db::commit();
if(!empty($param['is_vote']) && $param['is_vote']==1){
$data=['start_time'=>date('Y-m-d H:i:s'),'end_time'=>$param['end_time'],'article_id'=>$aid,'county'=>$adds['area_id'],'township'=>$adds['street_id'],'village'=>$adds['village_id']];
Db::table('fa_article_vote_side_tables')->insert($data);
}
return to_assign(0,'操作成功',['aid'=>$aid]);
}
return to_assign(1, '操作失败,原因:'.$aid);
}
/**
* 1. 获取编辑页展示文章与关联表数据.
* 【有关联表】
*/
function getEditData($param, $id, $callback){
// 获取指定文章
$detail = Db::table('fa_article')->where('id',$id)->withAttr('lesson',
$callback
)->find();
View::assign('editor', get_system_config('other','editor'));
// 获取此文章的用户信息
if (!empty($detail)) {
View::assign('detail', $detail);
//获取用户信息
$this->users = Db::table('fa_szxc_information_usermsg')->where('status',1)->field('user_id,name')->select();
View::assign('users', $this->users);
$street = Db::table('fa_geo_area')->where(['switch' => 1, 'city_code' => '510500'])
->field('area_id id,area_code code,area_name name')
->select();
View::assign('street', $street);
}
else{
throw new \think\exception\HttpException(404, '找不到页面');
}
}
/**
* 2. ajax提交编辑更新文章与关联表数据.
* 【有关联表】
*/
function updateEditData($param, $id, $callback){
try {
validate(\app\admin\validate\nk\ArticleValidate::class)->check($param);
} catch (ValidateException $e) {
// 验证失败 输出错误信息
return to_assign(1, $e->getError());
}
$adds=Db::table('fa_szxc_information_useraddress')->where('admin_id',$this->adminInfo['id'])->find();
if($this->adminInfo['position_id'] == 1) { //是超级管理员
if(empty($param['county'])){
$param['county']=$adds['area_id'];
}
if(empty($param['township'])){
$param['township']=$adds['street_id'];
}
if(empty($param['village'])){
$param['village']=$adds['village_id'];
}
if(empty($param['user_id'])){
$param['user_id']=$adds['user_id'];
}
}
// 更新文章信息
$res=Db::table('fa_article')->where('id',$id)->strict(false)->field(true)->update($param);
// 更新文章相关的扩展信息
$callback($param);
if ($res){
// 更新文章相关的投票信息
if(!empty($param['is_vote']) && $param['is_vote']==1){
Db::table('fa_article_vote_side_tables')->where('article_id',$id)->update(['end_time'=>$param['end_time']]);
}
return to_assign();
}else{
return to_assign(1, '操作失败,原因:'.$res);
}
}
/**
* 文章与关联表删除
* 【有关联表】
*/
function delArticle($id, $callback){
// 此处同时删除两个表
Db::startTrans();
try{
$res1 = Db::table('fa_article')->where('id',$id)->delete();
$pid = $callback($id);
}catch (ExceptionDbException $e){
Db::rollback();
$res1 = $pid = '';
return ["code"=>1, "msg"=>'操作失败,原因:'.$e->getMessage()];
}
if ($res1 && $pid){
Db::commit();
return ["code"=>0, "msg"=>'操作成功'];
}else{
return ["code"=>1, "msg"=>'操作失败,原因:两表一起删除失败[主表:'.$res1.'][联表:'.$pid.']'];
}
}
}

View File

@ -0,0 +1,174 @@
<?php
namespace app\admin\controller\nk\party;
use app\admin\BaseController;
use think\exception\ValidateException;
use think\facade\Db;
use think\facade\View;
/**
* 党务文章
*
* @icon fa fa-circle-o
*/
class Article extends BaseController
{
public function __construct()
{
$this->adminInfo = get_login_admin();
$this->url=[
'/admin/nk.party.article/index',
'/admin/nk.party.article/add',
'/admin/nk.party.article/edit',
'/admin/nk.party.article/del',
'/admin/nk.party.article/read',
];
}
public function index()
{
if (request()->isAjax()) {
$params= get_params();
$where[]= ['status','=',1];
if (isset($params['keywords']) && !empty($params['keywords'])){
$where[]=['title','like','%'.$params['keywords'].'%'];
}
if($this->adminInfo['position_id'] != 1){ //不是超级管理员
$www['admin_id'] = $this->adminInfo['id'];
$user_address = Db::table('fa_szxc_information_useraddress')->where($www)->find();
if ($user_address){
if($user_address['auth_range'] == 1){
$where[] = ['village','=',$user_address['village_id']];
}elseif ($user_address['auth_range'] == 2){
$where[] = ['township','=',$user_address['street_id']];
}elseif ($user_address['auth_range'] == 3){
$where[] = ['county','=',$user_address['area_id']];
}else{
$where[] = ['village','=',$user_address['village_id']];
}
}else{
$where[] = ['village','=',''];
}
}
$total = Db::table('fa_szxc_party_article')
->where($where)
->count();
$list = Db::table('fa_szxc_party_article')
->withAttr('nickname',function ($value,$data){
return Db::table('fa_szxc_information_usermsg')->where('user_id',$data['user_id'])->value('name');
})
->withAttr('area',function ($value,$data){
return Db::table('fa_geo_area')->where('area_code',$data['county'])->value('area_name');
})
->withAttr('street',function ($value,$data){
return Db::table('fa_geo_street')->where('street_code',$data['township'])->value('street_name');
})
->withAttr('village',function ($value,$data){
return Db::table('fa_geo_village')->where('village_id',$data['village'])->value('village_name');
})
->where($where)
->page($params['page'])
->limit($params['limit'])
->order('id desc')
->field('id,title,user_id,county,township,village,image,view_time')
->select();
$result = ['total' => $total, 'data' => $list];
return table_assign(0, '', $result);
}
else{
return view('nk/party/article/index',['url'=>$this->url]);
}
}
public function add(){
if (request()->isAjax()) {
$param= get_params();
// 检验完整性
try {
validate(\app\admin\validate\nk\ArticleValidate::class)->check($param);
} catch (ValidateException $e) {
// 验证失败 输出错误信息
return to_assign(1, $e->getError());
}
$adds=Db::table('fa_szxc_information_useraddress')->where('admin_id',$this->adminInfo['id'])->find();
$param['view_time']=date('Y-m-d H:i:s');
$param['county']=$adds['area_id'];
$param['township']=$adds['street_id'];
$param['village']=$adds['village_id'];
$param['user_id']=$adds['user_id'];
$res=Db::table('fa_szxc_party_article')->strict(false)->field(true)->insertGetId($param);
if ($res){
return to_assign(0,'操作成功',['aid'=>$res]);
}
return to_assign(1, '操作失败,原因:'.$res);
}else{
View::assign('editor', get_system_config('other','editor'));
return view();
}
}
public function edit(){
$param= get_params();
if (request()->isAjax()) {
try {
validate(\app\admin\validate\nk\ArticleValidate::class)->check($param);
} catch (ValidateException $e) {
// 验证失败 输出错误信息
return to_assign(1, $e->getError());
}
$res=Db::table('fa_szxc_party_article')->where('id',$param['id'])->strict(false)->field(true)->update($param);
if ($res){
return to_assign();
}else{
return to_assign(1, '操作失败,原因:'.$res);
}
}else{
$id = isset($param['id']) ? $param['id'] : 0;
$detail = Db::table('fa_szxc_party_article')->where('id',$id)->find();
View::assign('editor', get_system_config('other','editor'));
if (!empty($detail)) {
View::assign('detail', $detail);
return view();
}
else{
throw new \think\exception\HttpException(404, '找不到页面');
}
}
}
/**
* 查看信息
*/
public function read()
{
$param= get_params();
$id = isset($param['id']) ? $param['id'] : 0;
$detail = Db::table('fa_szxc_party_article')->where('id',$id)->find();
if (!empty($detail)) {
View::assign('detail', $detail);
return view();
}
else{
throw new \think\exception\HttpException(404, '找不到页面');
}
}
/**
* 删除
*/
public function del()
{
$param= get_params();
$id = isset($param['id']) ? $param['id'] : 0;
$type = isset($param['type']) ? $param['type'] : 0;
$res = Db::table('fa_szxc_party_article')->where('id',$id)->delete();
if ($res){
return to_assign();
}else{
return to_assign(1, '操作失败,原因:'.$res);
}
}
}

View File

@ -0,0 +1,172 @@
<?php
namespace app\admin\controller\nk\party;
use app\admin\BaseController;
use think\facade\Db;
use think\facade\View;
/**
* 党支部信息
*
* @icon fa fa-circle-o
*/
class Branch extends BaseController
{
/**
* 构造函数
*/
public function __construct()
{
$this->adminInfo = get_login_admin();
$this->url=[
'/admin/nk.party.branch/index',
'/admin/nk.party.branch/add',
'/admin/nk.party.branch/edit',
'/admin/nk.party.branch/del',
'/admin/nk.party.branch/read',
];
// 获取用户信息
$this->users = Db::table('fa_szxc_information_usermsg')->where('status',1)->field('user_id,name')->select();
}
/**
* 数据列表
*/
public function index()
{
if (request()->isAjax()) {
$params= get_params();
$where[]= ['status','=',1];
if (isset($params['keywords']) && !empty($params['keywords'])){
$where[]=['title','like','%'.$params['keywords'].'%'];
}
if($this->adminInfo['position_id'] != 1){ //不是超级管理员
$www['admin_id'] = $this->adminInfo['id'];
$user_address = Db::table('fa_szxc_information_useraddress')->where($www)->find();
if ($user_address){
if($user_address['auth_range'] == 1){
$where[] = ['village','=',$user_address['village_id']];
}elseif ($user_address['auth_range'] == 2){
$where[] = ['township','=',$user_address['street_id']];
}elseif ($user_address['auth_range'] == 3){
$where[] = ['county','=',$user_address['area_id']];
}else{
$where[] = ['village','=',$user_address['village_id']];
}
}else{
$where[] = ['village','=',''];
}
}
$total = Db::table('fa_szxc_party_branch')
->where($where)
->count();
$list = Db::table('fa_szxc_party_branch')
->withAttr('nickname',function ($value,$data){
return Db::table('fa_szxc_information_usermsg')->where('user_id',$data['user_id'])->value('name');
})
->withAttr('nickname2',function ($value,$data){
return Db::table('fa_szxc_information_usermsg')->where('user_id',$data['two_user_id'])->value('name');
})
->withAttr('area',function ($value,$data){
return Db::table('fa_geo_area')->where('area_code',$data['county'])->value('area_name');
})
->withAttr('street',function ($value,$data){
return Db::table('fa_geo_street')->where('street_code',$data['township'])->value('street_name');
})
->withAttr('village',function ($value,$data){
return Db::table('fa_geo_village')->where('village_id',$data['village'])->value('village_name');
})
->where($where)
->page($params['page'])
->limit($params['limit'])
->order('id desc')
->select();
$result = ['total' => $total, 'data' => $list];
return table_assign(0, '', $result);
}
else{
return view('nk/party/branch/index',['url'=>$this->url]);
}
}
public function add(){
if (request()->isAjax()) {
$param= get_params();
$adds=Db::table('fa_szxc_information_useraddress')->where('admin_id',$this->adminInfo['id'])->find();
$param['county']=$adds['area_id'];
$param['township']=$adds['street_id'];
$param['village']=$adds['village_id'];
$res=Db::table('fa_szxc_party_branch')->strict(false)->field(true)->insertGetId($param);
if ($res){
return to_assign(0,'操作成功',['aid'=>$res]);
}
return to_assign(1, '操作失败,原因:'.$res);
}else{
View::assign('editor', get_system_config('other','editor'));
View::assign('users', $this->users);
return view();
}
}
public function edit(){
$param= get_params();
if (request()->isAjax()) {
$res=Db::table('fa_szxc_party_branch')->where('id',$param['id'])->strict(false)->field(true)->update($param);
if ($res){
return to_assign();
}else{
return to_assign(1, '操作失败,原因:'.$res);
}
}else{
$id = isset($param['id']) ? $param['id'] : 0;
$detail = Db::table('fa_szxc_party_branch')->where('id',$id)->find();
View::assign('editor', get_system_config('other','editor'));
if (!empty($detail)) {
View::assign('detail', $detail);
View::assign('users', $this->users);
return view();
}
else{
throw new \think\exception\HttpException(404, '找不到页面');
}
}
}
/**
* 查看信息
*/
public function read()
{
$param= get_params();
$id = isset($param['id']) ? $param['id'] : 0;
$detail = Db::table('fa_szxc_party_branch')->where('id',$id)->find();
if (!empty($detail)) {
View::assign('detail', $detail);
View::assign('users', $this->users);
return view();
}
else{
throw new \think\exception\HttpException(404, '找不到页面');
}
}
/**
* 删除
*/
public function del()
{
$param= get_params();
$id = isset($param['id']) ? $param['id'] : 0;
$type = isset($param['type']) ? $param['type'] : 0;
$res = Db::table('fa_szxc_party_branch')->where('id',$id)->delete();
if ($res){
return to_assign();
}else{
return to_assign(1, '操作失败,原因:'.$res);
}
}
}

View File

@ -0,0 +1,180 @@
<?php
namespace app\admin\controller\nk\party;
use app\admin\BaseController;
use think\facade\Db;
use think\facade\View;
/**
* 党费清单列管理
*
* @icon fa fa-circle-o
*/
class BranchPayList extends BaseController
{
/**
* 构造函数
*/
public function __construct()
{
$this->adminInfo = get_login_admin();
$this->url=[
'/admin/nk.party.branchpaylist/index',
'/admin/nk.party.branchpaylist/add',
'/admin/nk.party.branchpaylist/edit',
'/admin/nk.party.branchpaylist/del',
'/admin/nk.party.branchpaylist/read',
];
// 获取用户信息
$this->users = Db::table('fa_szxc_information_usermsg')->where('status',1)->field('user_id,name')->select();
// 党支部
$this->party_branch = Db::table('fa_szxc_party_branch')->where('status',1)->field('id,name')->select();
}
/**
* 数据列表
*/
public function index()
{
if (request()->isAjax()) {
$params= get_params();
$where[]= ['status','=',1];
if (isset($params['keywords']) && !empty($params['keywords'])){
$where[]=['title','like','%'.$params['keywords'].'%'];
}
if($this->adminInfo['position_id'] != 1){ //不是超级管理员
$www['admin_id'] = $this->adminInfo['id'];
$user_address = Db::table('fa_szxc_information_useraddress')->where($www)->find();
if ($user_address){
if($user_address['auth_range'] == 1){
$where[] = ['village','=',$user_address['village_id']];
}elseif ($user_address['auth_range'] == 2){
$where[] = ['township','=',$user_address['street_id']];
}elseif ($user_address['auth_range'] == 3){
$where[] = ['county','=',$user_address['area_id']];
}else{
$where[] = ['village','=',$user_address['village_id']];
}
}else{
$where[] = ['village','=',''];
}
}
$total = Db::table('fa_szxc_party_branch_pay_list')
->where($where)
->count();
$list = Db::table('fa_szxc_party_branch_pay_list')
->withAttr('party_branch',function ($value,$data){
return Db::table('fa_szxc_party_branch')->where('id',$data['branch_id'])->value('name');
})
->withAttr('area',function ($value,$data){
return Db::table('fa_geo_area')->where('area_code',$data['county'])->value('area_name');
})
->withAttr('street',function ($value,$data){
return Db::table('fa_geo_street')->where('street_code',$data['township'])->value('street_name');
})
->withAttr('village',function ($value,$data){
return Db::table('fa_geo_village')->where('village_id',$data['village'])->value('village_name');
})
->withAttr('status',function ($value,$data){
if($value == 1){
return '正常';
}else{
return '禁用';
}
})
->where($where)
->page($params['page'])
->limit($params['limit'])
->order('id desc')
->select();
$result = ['total' => $total, 'data' => $list];
return table_assign(0, '', $result);
}
else{
return view('nk/party/branchpaylist/index',['url'=>$this->url]);
}
}
public function add(){
if (request()->isAjax()) {
$param= get_params();
$adds=Db::table('fa_szxc_information_useraddress')->where('admin_id',$this->adminInfo['id'])->find();
$param['county']=$adds['area_id'];
$param['township']=$adds['street_id'];
$param['village']=$adds['village_id'];
$res=Db::table('fa_szxc_party_branch_pay_list')->strict(false)->field(true)->insertGetId($param);
if ($res){
return to_assign(0,'操作成功',['aid'=>$res]);
}
return to_assign(1, '操作失败,原因:'.$res);
}else{
View::assign('editor', get_system_config('other','editor'));
View::assign('party_branch', $this->party_branch);
View::assign('users', $this->users);
return view();
}
}
public function edit(){
$param= get_params();
if (request()->isAjax()) {
$res=Db::table('fa_szxc_party_branch_pay_list')->where('id',$param['id'])->strict(false)->field(true)->update($param);
if ($res){
return to_assign();
}else{
return to_assign(1, '操作失败,原因:'.$res);
}
}else{
$id = isset($param['id']) ? $param['id'] : 0;
$detail = Db::table('fa_szxc_party_branch_pay_list')->where('id',$id)->find();
View::assign('editor', get_system_config('other','editor'));
if (!empty($detail)) {
View::assign('detail', $detail);
View::assign('users', $this->users);
View::assign('party_branch', $this->party_branch);
return view();
}
else{
throw new \think\exception\HttpException(404, '找不到页面');
}
}
}
/**
* 查看信息
*/
public function read()
{
$param= get_params();
$id = isset($param['id']) ? $param['id'] : 0;
$detail = Db::table('fa_szxc_party_branch_pay_list')->where('id',$id)->find();
if (!empty($detail)) {
View::assign('detail', $detail);
View::assign('users', $this->users);
View::assign('party_branch', $this->party_branch);
return view();
}
else{
throw new \think\exception\HttpException(404, '找不到页面');
}
}
/**
* 删除
*/
public function del()
{
$param= get_params();
$id = isset($param['id']) ? $param['id'] : 0;
$type = isset($param['type']) ? $param['type'] : 0;
$res = Db::table('fa_szxc_party_branch_pay_list')->where('id',$id)->delete();
if ($res){
return to_assign();
}else{
return to_assign(1, '操作失败,原因:'.$res);
}
}
}

View File

@ -0,0 +1,188 @@
<?php
namespace app\admin\controller\nk\party;
use app\admin\BaseController;
use think\facade\Db;
use think\facade\View;
/**
* 党费缴纳列管理
*
* @icon fa fa-circle-o
*/
class BranchPayUser extends BaseController
{
/**
* 构造函数
*/
public function __construct()
{
$this->adminInfo = get_login_admin();
$this->url=[
'/admin/nk.party.branchpayuser/index',
'/admin/nk.party.branchpayuser/add',
'/admin/nk.party.branchpayuser/edit',
'/admin/nk.party.branchpayuser/del',
'/admin/nk.party.branchpayuser/read',
];
// 获取用户信息
$this->users = Db::table('fa_szxc_information_usermsg')->where('status',1)->field('user_id,name')->select();
// 党支部
$this->party_branch = Db::table('fa_szxc_party_branch')->where('status',1)->field('id,name')->select();
// 清单
$this->pay_list = Db::table('fa_szxc_party_branch_pay_list')->where('status',1)->field('id')->select();
}
/**
* 数据列表
*/
public function index()
{
if (request()->isAjax()) {
$params= get_params();
$where[]= ['status','=',1];
if (isset($params['keywords']) && !empty($params['keywords'])){
$where[]=['title','like','%'.$params['keywords'].'%'];
}
if($this->adminInfo['position_id'] != 1){ //不是超级管理员
$www['admin_id'] = $this->adminInfo['id'];
$user_address = Db::table('fa_szxc_information_useraddress')->where($www)->find();
if ($user_address){
if($user_address['auth_range'] == 1){
$where[] = ['village','=',$user_address['village_id']];
}elseif ($user_address['auth_range'] == 2){
$where[] = ['township','=',$user_address['street_id']];
}elseif ($user_address['auth_range'] == 3){
$where[] = ['county','=',$user_address['area_id']];
}else{
$where[] = ['village','=',$user_address['village_id']];
}
}else{
$where[] = ['village','=',''];
}
}
$total = Db::table('fa_szxc_party_branch_pay_user')
->where($where)
->count();
$list = Db::table('fa_szxc_party_branch_pay_user')
->withAttr('party_branch',function ($value,$data){
return Db::table('fa_szxc_party_branch')->where('id',$data['branch_id'])->value('name');
})
->withAttr('user_name',function ($value,$data){
return Db::table('fa_szxc_information_usermsg')->where('user_id',$data['user_id'])->value('name');
})
->withAttr('area',function ($value,$data){
return Db::table('fa_geo_area')->where('area_code',$data['county'])->value('area_name');
})
->withAttr('street',function ($value,$data){
return Db::table('fa_geo_street')->where('street_code',$data['township'])->value('street_name');
})
->withAttr('village',function ($value,$data){
return Db::table('fa_geo_village')->where('village_id',$data['village'])->value('village_name');
})
->withAttr('status',function ($value,$data){
if($value == 1){
return '正常';
}else{
return '禁用';
}
})
->where($where)
->page($params['page'])
->limit($params['limit'])
->order('id desc')
->select();
$result = ['total' => $total, 'data' => $list];
return table_assign(0, '', $result);
}
else{
return view('nk/party/branchpayuser/index',['url'=>$this->url]);
}
}
public function add(){
if (request()->isAjax()) {
$param= get_params();
$adds=Db::table('fa_szxc_information_useraddress')->where('admin_id',$this->adminInfo['id'])->find();
$param['county']=$adds['area_id'];
$param['township']=$adds['street_id'];
$param['village']=$adds['village_id'];
$res=Db::table('fa_szxc_party_branch_pay_user')->strict(false)->field(true)->insertGetId($param);
if ($res){
return to_assign(0,'操作成功',['aid'=>$res]);
}
return to_assign(1, '操作失败,原因:'.$res);
}else{
View::assign('editor', get_system_config('other','editor'));
View::assign('party_branch', $this->party_branch);
View::assign('pay_list', $this->pay_list);
View::assign('users', $this->users);
return view();
}
}
public function edit(){
$param= get_params();
if (request()->isAjax()) {
$res=Db::table('fa_szxc_party_branch_pay_user')->where('id',$param['id'])->strict(false)->field(true)->update($param);
if ($res){
return to_assign();
}else{
return to_assign(1, '操作失败,原因:'.$res);
}
}else{
$id = isset($param['id']) ? $param['id'] : 0;
$detail = Db::table('fa_szxc_party_branch_pay_user')->where('id',$id)->find();
View::assign('editor', get_system_config('other','editor'));
if (!empty($detail)) {
View::assign('detail', $detail);
View::assign('users', $this->users);
View::assign('party_branch', $this->party_branch);
View::assign('pay_list', $this->pay_list);
return view();
}
else{
throw new \think\exception\HttpException(404, '找不到页面');
}
}
}
/**
* 查看信息
*/
public function read()
{
$param= get_params();
$id = isset($param['id']) ? $param['id'] : 0;
$detail = Db::table('fa_szxc_party_branch_pay_user')->where('id',$id)->find();
if (!empty($detail)) {
View::assign('detail', $detail);
View::assign('users', $this->users);
View::assign('party_branch', $this->party_branch);
View::assign('pay_list', $this->pay_list);
return view();
}
else{
throw new \think\exception\HttpException(404, '找不到页面');
}
}
/**
* 删除
*/
public function del()
{
$param= get_params();
$id = isset($param['id']) ? $param['id'] : 0;
$type = isset($param['type']) ? $param['type'] : 0;
$res = Db::table('fa_szxc_party_branch_pay_user')->where('id',$id)->delete();
if ($res){
return to_assign();
}else{
return to_assign(1, '操作失败,原因:'.$res);
}
}
}

View File

@ -0,0 +1,211 @@
<?php
namespace app\admin\controller\nk\party;
use app\admin\BaseController;
use think\facade\Db;
use think\facade\View;
/**
* 党员维护
*
* @icon fa fa-circle-o
*/
class Info extends BaseController
{
/**
* 构造函数
*/
public function __construct()
{
$this->adminInfo = get_login_admin();
$this->url=[
'/admin/nk.party.info/index',
'/admin/nk.party.info/add',
'/admin/nk.party.info/edit',
'/admin/nk.party.info/del',
'/admin/nk.party.info/read',
];
// 获取用户信息
$this->users = Db::table('fa_szxc_information_usermsg')->where('status',1)->field('user_id,name')->select();
$this->party_branch = Db::table('fa_szxc_party_branch')->where('status',1)->field('id,name')->select();
}
/**
* 数据列表
*/
public function index()
{
if (request()->isAjax()) {
$params= get_params();
$where[]= ['status','=',1];
if (isset($params['keywords']) && !empty($params['keywords'])){
$where[]=['title','like','%'.$params['keywords'].'%'];
}
if($this->adminInfo['position_id'] != 1){ //不是超级管理员
$www['admin_id'] = $this->adminInfo['id'];
$user_address = Db::table('fa_szxc_information_useraddress')->where($www)->find();
if ($user_address){
if($user_address['auth_range'] == 1){
$where[] = ['village','=',$user_address['village_id']];
}elseif ($user_address['auth_range'] == 2){
$where[] = ['township','=',$user_address['street_id']];
}elseif ($user_address['auth_range'] == 3){
$where[] = ['county','=',$user_address['area_id']];
}else{
$where[] = ['village','=',$user_address['village_id']];
}
}else{
$where[] = ['village','=',''];
}
}
$total = Db::table('fa_szxc_party_info')
->where($where)
->count();
$list = Db::table('fa_szxc_party_info')
->withAttr('name',function ($value,$data){
return Db::table('fa_szxc_information_usermsg')->where('user_id',$data['user_id'])->value('name');
})
->withAttr('nation',function ($value,$data){
return Db::table('fa_szxc_information_usermsg')->where('user_id',$data['user_id'])->value('nation');
})
->withAttr('political_outlook',function ($value,$data){
return Db::table('fa_szxc_information_usermsg')->where('user_id',$data['user_id'])->value('political_outlook');
})
->withAttr('phone',function ($value,$data){
return Db::table('fa_szxc_information_usermsg')->where('user_id',$data['user_id'])->value('phone');
})
->withAttr('marital_status',function ($value,$data){
return Db::table('fa_szxc_information_usermsg')->where('user_id',$data['user_id'])->value('marital_status');
})
->withAttr('idcard',function ($value,$data){
return Db::table('fa_szxc_information_usermsg')->where('user_id',$data['user_id'])->value('idcard');
})
->withAttr('sex',function ($value,$data){
$sex = Db::table('fa_szxc_information_usermsg')->where('user_id',$data['user_id'])->value('gender');
if($sex == 1){
return '男';
}elseif ($sex == 2){
return '女';
}else{
return '';
}
})
->withAttr('age',function ($value,$data){
return Db::table('fa_szxc_information_usermsg')->where('user_id',$data['user_id'])->value('age');
})
->withAttr('area',function ($value,$data){
return Db::table('fa_geo_area')->where('area_code',$data['county'])->value('area_name');
})
->withAttr('street',function ($value,$data){
return Db::table('fa_geo_street')->where('street_code',$data['township'])->value('street_name');
})
->withAttr('village',function ($value,$data){
return Db::table('fa_geo_village')->where('village_id',$data['village'])->value('village_name');
})
->withAttr('party_branch',function ($value,$data){
return Db::table('fa_szxc_party_branch')->where('id',$data['party_branch'])->value('name');
})
->withAttr('status',function ($value,$data){
if($value == 1){
return '正常';
}else{
return '禁用';
}
})
->where($where)
->page($params['page'])
->limit($params['limit'])
->order('id desc')
->select();
$result = ['total' => $total, 'data' => $list];
return table_assign(0, '', $result);
}
else{
return view('nk/party/info/index',['url'=>$this->url]);
}
}
public function add(){
if (request()->isAjax()) {
$param= get_params();
$adds=Db::table('fa_szxc_information_useraddress')->where('admin_id',$this->adminInfo['id'])->find();
$param['county']=$adds['area_id'];
$param['township']=$adds['street_id'];
$param['village']=$adds['village_id'];
$res=Db::table('fa_szxc_party_info')->strict(false)->field(true)->insertGetId($param);
if ($res){
return to_assign(0,'操作成功',['aid'=>$res]);
}
return to_assign(1, '操作失败,原因:'.$res);
}else{
View::assign('editor', get_system_config('other','editor'));
View::assign('users', $this->users);
View::assign('party_branch', $this->party_branch);
return view();
}
}
public function edit(){
$param= get_params();
if (request()->isAjax()) {
$res=Db::table('fa_szxc_party_info')->where('id',$param['id'])->strict(false)->field(true)->update($param);
if ($res){
return to_assign();
}else{
return to_assign(1, '操作失败,原因:'.$res);
}
}else{
$id = isset($param['id']) ? $param['id'] : 0;
$detail = Db::table('fa_szxc_party_info')->where('id',$id)->find();
View::assign('editor', get_system_config('other','editor'));
if (!empty($detail)) {
View::assign('detail', $detail);
View::assign('users', $this->users);
View::assign('party_branch', $this->party_branch);
return view();
}
else{
throw new \think\exception\HttpException(404, '找不到页面');
}
}
}
/**
* 查看信息
*/
public function read()
{
$param= get_params();
$id = isset($param['id']) ? $param['id'] : 0;
$detail = Db::table('fa_szxc_party_info')->where('id',$id)->find();
if (!empty($detail)) {
View::assign('detail', $detail);
View::assign('users', $this->users);
View::assign('party_branch', $this->party_branch);
return view();
}
else{
throw new \think\exception\HttpException(404, '找不到页面');
}
}
/**
* 删除
*/
public function del()
{
$param= get_params();
$id = isset($param['id']) ? $param['id'] : 0;
$type = isset($param['type']) ? $param['type'] : 0;
$res = Db::table('fa_szxc_party_info')->where('id',$id)->delete();
if ($res){
return to_assign();
}else{
return to_assign(1, '操作失败,原因:'.$res);
}
}
}

View File

@ -0,0 +1,175 @@
<?php
namespace app\admin\controller\nk\party;
use app\admin\BaseController;
use think\facade\Db;
use think\facade\View;
/**
* 党务文章投票
*
* @icon fa fa-circle-o
*/
class Vote extends BaseController
{
/**
* 构造函数
*/
public function __construct()
{
$this->adminInfo = get_login_admin();
$this->url=[
'/admin/nk.party.vote/index',
'/admin/nk.party.vote/add',
'/admin/nk.party.vote/edit',
'/admin/nk.party.vote/del',
'/admin/nk.party.vote/read',
];
// 获取用户信息
$this->users = Db::table('fa_szxc_information_usermsg')->where('status',1)->field('user_id,name')->select();
}
/**
* 数据列表
*/
public function index()
{
if (request()->isAjax()) {
$params= get_params();
$where[]= ['status','=',1];
if (isset($params['keywords']) && !empty($params['keywords'])){
$where[]=['title','like','%'.$params['keywords'].'%'];
}
if($this->adminInfo['position_id'] != 1){ //不是超级管理员
$www['admin_id'] = $this->adminInfo['id'];
$user_address = Db::table('fa_szxc_information_useraddress')->where($www)->find();
if ($user_address){
if($user_address['auth_range'] == 1){
$where[] = ['village','=',$user_address['village_id']];
}elseif ($user_address['auth_range'] == 2){
$where[] = ['township','=',$user_address['street_id']];
}elseif ($user_address['auth_range'] == 3){
$where[] = ['county','=',$user_address['area_id']];
}else{
$where[] = ['village','=',$user_address['village_id']];
}
}else{
$where[] = ['village','=',''];
}
}
$total = Db::table('fa_szxc_party_vote')
->where($where)
->count();
$list = Db::table('fa_szxc_party_vote')
->withAttr('name',function ($value,$data){
return Db::table('fa_szxc_information_usermsg')->where('user_id',$data['user_id'])->value('name');
})
->withAttr('area',function ($value,$data){
return Db::table('fa_geo_area')->where('area_code',$data['county'])->value('area_name');
})
->withAttr('street',function ($value,$data){
return Db::table('fa_geo_street')->where('street_code',$data['township'])->value('street_name');
})
->withAttr('village',function ($value,$data){
return Db::table('fa_geo_village')->where('village_id',$data['village'])->value('village_name');
})
->withAttr('status',function ($value,$data){
if($value == 1){
return '正常';
}else{
return '禁用';
}
})
->where($where)
->page($params['page'])
->limit($params['limit'])
->order('id desc')
->select();
$result = ['total' => $total, 'data' => $list];
return table_assign(0, '', $result);
}
else{
return view('nk/party/vote/index',['url'=>$this->url]);
}
}
public function add(){
if (request()->isAjax()) {
$param= get_params();
$adds=Db::table('fa_szxc_information_useraddress')->where('admin_id',$this->adminInfo['id'])->find();
$param['county']=$adds['area_id'];
$param['township']=$adds['street_id'];
$param['village']=$adds['village_id'];
$res=Db::table('fa_szxc_party_vote')->strict(false)->field(true)->insertGetId($param);
if ($res){
return to_assign(0,'操作成功',['aid'=>$res]);
}
return to_assign(1, '操作失败,原因:'.$res);
}else{
View::assign('editor', get_system_config('other','editor'));
View::assign('users', $this->users);
return view();
}
}
public function edit(){
$param= get_params();
if (request()->isAjax()) {
$res=Db::table('fa_szxc_party_vote')->where('id',$param['id'])->strict(false)->field(true)->update($param);
if ($res){
return to_assign();
}else{
return to_assign(1, '操作失败,原因:'.$res);
}
}else{
$id = isset($param['id']) ? $param['id'] : 0;
$detail = Db::table('fa_szxc_party_vote')->where('id',$id)->find();
View::assign('editor', get_system_config('other','editor'));
if (!empty($detail)) {
View::assign('detail', $detail);
View::assign('users', $this->users);
return view();
}
else{
throw new \think\exception\HttpException(404, '找不到页面');
}
}
}
/**
* 查看信息
*/
public function read()
{
$param= get_params();
$id = isset($param['id']) ? $param['id'] : 0;
$detail = Db::table('fa_szxc_party_vote')->where('id',$id)->find();
if (!empty($detail)) {
View::assign('detail', $detail);
View::assign('users', $this->users);
return view();
}
else{
throw new \think\exception\HttpException(404, '找不到页面');
}
}
/**
* 删除
*/
public function del()
{
$param= get_params();
$id = isset($param['id']) ? $param['id'] : 0;
$type = isset($param['type']) ? $param['type'] : 0;
$res = Db::table('fa_szxc_party_vote')->where('id',$id)->delete();
if ($res){
return to_assign();
}else{
return to_assign(1, '操作失败,原因:'.$res);
}
}
}

View File

@ -0,0 +1,173 @@
<?php
namespace app\admin\controller\nk\party;
use app\admin\BaseController;
use think\facade\Db;
use think\facade\View;
/**
* 党务文章投票评论
*
* @icon fa fa-circle-o
*/
class VoteComment extends BaseController
{
/**
* 构造函数
*/
public function __construct()
{
$this->adminInfo = get_login_admin();
$this->url=[
'/admin/nk.party.votecomment/index',
'/admin/nk.party.votecomment/add',
'/admin/nk.party.votecomment/edit',
'/admin/nk.party.votecomment/del',
'/admin/nk.party.votecomment/read',
];
// 获取用户信息
$this->users = Db::table('fa_szxc_information_usermsg')->where('status',1)->field('user_id,name')->select();
$this->party_vote = Db::table('fa_szxc_party_vote')->where('status',1)->field('id,title')->select();
}
/**
* 数据列表
*/
public function index()
{
if (request()->isAjax()) {
$params= get_params();
$where=[];
if (isset($params['keywords']) && !empty($params['keywords'])){
$where[]=['title','like','%'.$params['keywords'].'%'];
}
if($this->adminInfo['position_id'] != 1){ //不是超级管理员
$www['admin_id'] = $this->adminInfo['id'];
$user_address = Db::table('fa_szxc_information_useraddress')->where($www)->find();
if ($user_address){
if($user_address['auth_range'] == 1){
$where[] = ['village','=',$user_address['village_id']];
}elseif ($user_address['auth_range'] == 2){
$where[] = ['township','=',$user_address['street_id']];
}elseif ($user_address['auth_range'] == 3){
$where[] = ['county','=',$user_address['area_id']];
}else{
$where[] = ['village','=',$user_address['village_id']];
}
}else{
$where[] = ['village','=',''];
}
}
$total = Db::table('fa_szxc_party_vote_comment')
->where($where)
->count();
$list = Db::table('fa_szxc_party_vote_comment')
->withAttr('name',function ($value,$data){
return Db::table('fa_szxc_information_usermsg')->where('user_id',$data['user_id'])->value('name');
})
->withAttr('title',function ($value,$data){
return Db::table('fa_szxc_party_vote')->where('id',$data['vote_id'])->value('title');
})
->withAttr('status',function ($value,$data){
if($value == 1){
return '通过';
}else{
return '不通过';
}
})
->where($where)
->page($params['page'])
->limit($params['limit'])
->order('id desc')
->select();
$result = ['total' => $total, 'data' => $list];
return table_assign(0, '', $result);
}
else{
return view('nk/party/votecomment/index',['url'=>$this->url]);
}
}
public function add(){
if (request()->isAjax()) {
$param= get_params();
$adds=Db::table('fa_szxc_information_useraddress')->where('admin_id',$this->adminInfo['id'])->find();
$param['add_time']= date('Y-m-d H:i:s');
$param['county']=$adds['area_id'];
$param['township']=$adds['street_id'];
$param['village']=$adds['village_id'];
$res=Db::table('fa_szxc_party_vote_comment')->strict(false)->field(true)->insertGetId($param);
if ($res){
return to_assign(0,'操作成功',['aid'=>$res]);
}
return to_assign(1, '操作失败,原因:'.$res);
}else{
View::assign('editor', get_system_config('other','editor'));
View::assign('users', $this->users);
View::assign('party_vote', $this->party_vote);
return view();
}
}
public function edit(){
$param= get_params();
if (request()->isAjax()) {
$res=Db::table('fa_szxc_party_vote_comment')->where('id',$param['id'])->strict(false)->field(true)->update($param);
if ($res){
return to_assign();
}else{
return to_assign(1, '操作失败,原因:'.$res);
}
}else{
$id = isset($param['id']) ? $param['id'] : 0;
$detail = Db::table('fa_szxc_party_vote_comment')->where('id',$id)->find();
View::assign('editor', get_system_config('other','editor'));
if (!empty($detail)) {
View::assign('detail', $detail);
View::assign('users', $this->users);
View::assign('party_vote', $this->party_vote);
return view();
}
else{
throw new \think\exception\HttpException(404, '找不到页面');
}
}
}
/**
* 查看信息
*/
public function read()
{
$param= get_params();
$id = isset($param['id']) ? $param['id'] : 0;
$detail = Db::table('fa_szxc_party_vote_comment')->where('id',$id)->find();
if (!empty($detail)) {
View::assign('detail', $detail);
View::assign('users', $this->users);
View::assign('party_vote', $this->party_vote);
return view();
}
else{
throw new \think\exception\HttpException(404, '找不到页面');
}
}
/**
* 删除
*/
public function del()
{
$param= get_params();
$id = isset($param['id']) ? $param['id'] : 0;
$type = isset($param['type']) ? $param['type'] : 0;
$res = Db::table('fa_szxc_party_vote_comment')->where('id',$id)->delete();
if ($res){
return to_assign();
}else{
return to_assign(1, '操作失败,原因:'.$res);
}
}
}

5
app/admin/event.php Normal file
View File

@ -0,0 +1,5 @@
<?php
// 这是系统自动生成的event定义文件
return [
];

Some files were not shown because too many files have changed in this diff Show More