提交crmeb框架代码

This commit is contained in:
焦钰锟 2025-02-26 11:49:20 +08:00
parent a8a8221a73
commit 5f13387985
10678 changed files with 1466556 additions and 2 deletions

6
.gitignore vendored Normal file
View File

@ -0,0 +1,6 @@
# Windows thumbnail cache files
/.idea
crmeb/public/install/install.lock
crmeb/public/.htaccess
crmeb/public/uploads/
template/admin/node_modules

1
.htaccess Normal file
View File

@ -0,0 +1 @@

1
.user.ini Normal file
View File

@ -0,0 +1 @@
open_basedir=/www/wwwroot/j01.hschool.com.cn/:/tmp/

7
404.html Normal file
View File

@ -0,0 +1,7 @@
<html>
<head><title>404 Not Found</title></head>
<body>
<center><h1>404 Not Found</h1></center>
<hr><center>nginx</center>
</body>
</html>

21
LICENSE Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2019 JakHuang
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

36
README.en.md Normal file
View File

@ -0,0 +1,36 @@
# 测试crmeb-admin
#### Description
{**When you're done, you can delete the content in this README and update the file with details for others getting started with your repository**}
#### Software Architecture
Software architecture description
#### Installation
1. xxxx
2. xxxx
3. xxxx
#### Instructions
1. xxxx
2. xxxx
3. xxxx
#### Contribution
1. Fork the repository
2. Create Feat_xxx branch
3. Commit your code
4. Create Pull Request
#### Gitee Feature
1. You can use Readme\_XXX.md to support different languages, such as Readme\_en.md, Readme\_zh.md
2. Gitee blog [blog.gitee.com](https://blog.gitee.com)
3. Explore open source project [https://gitee.com/explore](https://gitee.com/explore)
4. The most valuable open source project [GVP](https://gitee.com/gvp)
5. The manual of Gitee [https://gitee.com/help](https://gitee.com/help)
6. The most popular members [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)

112
README.md
View File

@ -1,3 +1,111 @@
# crmeb-background-api
<div align="center" >
<img src="https://images.gitee.com/uploads/images/2021/1109/164354_0aafe3d2_892944.gif" />
</div>
crmeb后台api
<div align="center">
支持免费商用的PHP Admin框架系统
</div>
<div align="center" >
<a href="http://www.crmeb.com">
<img src="https://img.shields.io/badge/Licence-MIT-green.svg?style=flat" />
</a>
<a href="http://www.crmeb.com">
<img src="https://img.shields.io/badge/Edition-5.0-blue.svg" />
</a>
<a href="https://gitee.com/ZhongBangKeJi/CRMEB/repository/archive/master.zip">
<img src="https://img.shields.io/badge/Download-50m-red.svg" />
</a>
<a href='https://gitee.com/ZhongBangKeJi/CRMEB/stargazers'>
<img src='https://gitee.com/ZhongBangKeJi/CRMEB/badge/star.svg?theme=gvp' alt='star'></img>
</a>
</div>
####
<div align="center">
[官网](https://www.crmeb.com/) |
[在线体验](http://v4.crmeb.net/admin/) |
[帮助文档](https://doc.crmeb.com/single/crmeb_v4) |
[技术社区](https://www.crmeb.com/ask/)
[comment]: <> ([宽屏预览]&#40;https://gitee.com/ZhongBangKeJi/CRMEB/blob/master/README.md&#41;)
</div>
<div align="center" >
<a href="https://gitee.com/ZhongBangKeJi/CRMEB/blob/master/README.md">宽 屏 预 览</a>
</div>
### 介绍
CRMEB Admin框架采用TP6+Mysql+Element前后端分离全部100%开源。方便二开,更有详细使用文档、接口文档、数据字典、二开文档/视频教程。为开发者赋能助力企业发展、国家富强致力于打造最受欢迎的Admin框架项目
### 系统亮点
~~~
多 语 言:后台随时配置语言包,移动端支持多语言切换;
高 性 能redis缓存、队列、长连接、多种云储存、支持集群部署
个 性 UI多种风格切换、支持DIY各种首页/专题页面
前后端分离后端TP6管理端iviewui移动端uniapp
代码规范遵循PSR-2命名规范、Restful标准接口、代码严格分层、注释齐全、统一错误码
权限管理:内置强大灵活的权限管理,可以控制到每一个菜单;
开发配置:低代码增加配置、系统组合数据模块;
二开效率PHP快速生成表单、内置所有事件、后台在线编辑器、代码注释齐全、完整接口文档
快速上手:详细帮助文档、接口文档、数据库字典、代码注释、一键安装;
系统安全:系统操作日志、系统生产日志、文件校验、数据备份;
用户体验:等您来评!
~~~
### 运行环境
```
Nignx/Apache/IIS
PHP 7.1 ~ 7.4
MySQL 5.7
Redis
```
### 系统演示
管理后台: http://v5.crmeb.net/admin 账号demo 密码crmeb.com
### 官方论坛
产品BUG、优化建议欢迎社区反馈https://www.crmeb.com/ask/
### 推荐项目(欢迎合作QQ763569752 )
| 项目名称 | 关注量 | 项目介绍 |
| ------------ | ------------ | ------------ |
| [![](https://img.shields.io/badge/CRMEB-CRMChat-blue.svg)](https://gitee.com/ZhongBangKeJi/CRMChat) | [![](https://gitee.com/ZhongBangKeJi/CRMChat/badge/star.svg)](https://gitee.com/ZhongBangKeJi/CRMChat/stargazers) | CRMChat客服系统支持接入各种渠道. |
| [![](https://img.shields.io/badge/CRMEB-crmeb_java-blue.svg)](https://gitee.com/ZhongBangKeJi/crmeb_java) | [![](https://gitee.com/ZhongBangKeJi/crmeb_java/badge/star.svg)](https://gitee.com/ZhongBangKeJi/crmeb_java/stargazers) | JAVA版开源商城. |
| [![](https://img.shields.io/badge/xaboy-formbuilder-blue.svg)](https://gitee.com/xaboy/form-builder) | [![](https://gitee.com/xaboy/form-builder/badge/star.svg)](https://gitee.com/xaboy/form-builder/stargazers) | PHP表单生成器快速生成现代化的form表单。 |
| [![](https://img.shields.io/badge/就眠儀式-LayuiVue-blue.svg)](https://gitee.com/layui/layui-vue) | [![](https://gitee.com/layui/layui-vue/badge/star.svg)](https://gitee.com/layui/layui-vue/stargazers) | layui-vue(谐音:类UI)是一套Vue3.0 的桌面端组件库. |
| [![](https://img.shields.io/badge/逆天的蝈蝈-TpFlow-blue.svg)](https://gitee.com/ntdgg/tpflow) | [![](https://gitee.com/ntdgg/tpflow/badge/star.svg?theme=gvp)](https://gitee.com/ntdgg/tpflow/stargazers) | TpFlow工作流引擎是一套规范化的流程管理系统基于业务而驱动系统生命力的一套引擎. |
欢迎反馈问题 [反馈问题](https://gitee.com/ZhongBangKeJi/CRMEB/issues)。
欢迎提交代码 [提交代码](https://gitee.com/ZhongBangKeJi/CRMEB/pulls)。
### 特别鸣谢
排名不分先后感谢这些软件的开发者thinkphp、vue、mysql、redis、echarts、tree-table-vue、swiper、form-create等如有遗漏请联系我

3
crmeb/.constant Normal file
View File

@ -0,0 +1,3 @@
<?php
define('INSTALL_DATE',1739781192);
define('SERIALNUMBER','53N7OQ');

0
crmeb/.env Normal file
View File

1
crmeb/.example.env Normal file
View File

@ -0,0 +1 @@
APP_DEBUG = true [APP] DEFAULT_TIMEZONE = Asia/Shanghai [DATABASE] TYPE = mysql HOSTNAME = 127.0.0.1 DATABASE = test USERNAME = username PASSWORD = password HOSTPORT = 3306 CHARSET = utf8 DEBUG = true [LANG] default_lang = zh-cn

1
crmeb/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
*.log

42
crmeb/.travis.yml Normal file
View File

@ -0,0 +1,42 @@
sudo: false
language: php
branches:
only:
- stable
cache:
directories:
- $HOME/.composer/cache
before_install:
- composer self-update
install:
- composer install --no-dev --no-interaction --ignore-platform-reqs
- zip -r --exclude='*.git*' --exclude='*.zip' --exclude='*.travis.yml' ThinkPHP_Core.zip .
- composer require --update-no-dev --no-interaction "topthink/think-image:^1.0"
- composer require --update-no-dev --no-interaction "topthink/think-migration:^1.0"
- composer require --update-no-dev --no-interaction "topthink/think-captcha:^1.0"
- composer require --update-no-dev --no-interaction "topthink/think-mongo:^1.0"
- composer require --update-no-dev --no-interaction "topthink/think-worker:^1.0"
- composer require --update-no-dev --no-interaction "topthink/think-helper:^1.0"
- composer require --update-no-dev --no-interaction "topthink/think-queue:^1.0"
- composer require --update-no-dev --no-interaction "topthink/think-angular:^1.0"
- composer require --dev --update-no-dev --no-interaction "topthink/think-testing:^1.0"
- zip -r --exclude='*.git*' --exclude='*.zip' --exclude='*.travis.yml' ThinkPHP_Full.zip .
script:
- php think unit
deploy:
provider: releases
api_key:
secure: TSF6bnl2JYN72UQOORAJYL+CqIryP2gHVKt6grfveQ7d9rleAEoxlq6PWxbvTI4jZ5nrPpUcBUpWIJHNgVcs+bzLFtyh5THaLqm39uCgBbrW7M8rI26L8sBh/6nsdtGgdeQrO/cLu31QoTzbwuz1WfAVoCdCkOSZeXyT/CclH99qV6RYyQYqaD2wpRjrhA5O4fSsEkiPVuk0GaOogFlrQHx+C+lHnf6pa1KxEoN1A0UxxVfGX6K4y5g4WQDO5zT4bLeubkWOXK0G51XSvACDOZVIyLdjApaOFTwamPcD3S1tfvuxRWWvsCD5ljFvb2kSmx5BIBNwN80MzuBmrGIC27XLGOxyMerwKxB6DskNUO9PflKHDPI61DRq0FTy1fv70SFMSiAtUv9aJRT41NQh9iJJ0vC8dl+xcxrWIjU1GG6+l/ZcRqVx9V1VuGQsLKndGhja7SQ+X1slHl76fRq223sMOql7MFCd0vvvxVQ2V39CcFKao/LB1aPH3VhODDEyxwx6aXoTznvC/QPepgWsHOWQzKj9ftsgDbsNiyFlXL4cu8DWUty6rQy8zT2b4O8b1xjcwSUCsy+auEjBamzQkMJFNlZAIUrukL/NbUhQU37TAbwsFyz7X0E/u/VMle/nBCNAzgkMwAUjiHM6FqrKKBRWFbPrSIixjfjkCnrMEPw=
file:
- ThinkPHP_Core.zip
- ThinkPHP_Full.zip
skip_cleanup: true
on:
tags: true

3
crmeb/.version Normal file
View File

@ -0,0 +1,3 @@
version=CRMEB-Admin v5.0.0
version_code=500
project_signature=23bd74f734a4863aa58919ef34ebecb2

120
crmeb/README.md Normal file
View File

@ -0,0 +1,120 @@
CRMEB v4.5 后端程序目录
===============
> 运行环境要求PHP7.1-7.4。
## 安装
## 一键安装
上传你的代码,站点入口目录设置/public
在浏览器中输入你的域名或IP例如www.yourdomain.com,
安装程序会自动执行安装。期间系统会提醒你输入数据库信息以完成安装安装完成后建议删除install目录下index.php文件或将其改名。
后台访问地址:
1.域名/admin
2.域名/index.php/admin
3.域名/index.php?s=/admin
公众号和H5首页访问地址
1.域名/
安装过程中请牢记您的账号密码!
## 重新安装
1. 清除数据库
2. 删除/public/install.lock 文件
## 手动安装
1.创建数据库,倒入数据库文件
数据库文件目录/public/install/crmeb.sql
2.修改数据库连接文件
配置文件路径/.env
~~~
APP_DEBUG = true
[APP]
DEFAULT_TIMEZONE = Asia/Shanghai
[DATABASE]
TYPE = mysql
HOSTNAME = 127.0.0.1 #数据库连接地址
DATABASE = test #数据库名称
USERNAME = username #数据库登录账号
PASSWORD = password #数据库登录密码
HOSTPORT = 3306 #数据库端口
CHARSET = utf8
DEBUG = true
[LANG]
default_lang = zh-cn
[REDIS]
REDIS_HOSTNAME = 127.0.0.1 # redis链接地址
PORT = 6379 #端口号
REDIS_PASSWORD = 123456 #密码
SELECT = 0 #数据库
~~~
3.修改目录权限linux系统777
/public
/runtime
4.后台登录:
http://域名/admin
默认账号admin 密码crmeb.com
## 消息队列
```sh
php think queue:listen --queue
```
## 消息队列
```sh
php think queue:listen --queue
```
## 定时任务
在自动收货,库存预警等功能使用到
```sh
php think timer [ status ] [ --d ]
```
参数
- status: 状态
- start: 启动
- stop: 关闭
- restart: 重启
- --d : 后台执行
## 长连接服务
在h5聊天,后台管理员消息通知等功能使用到
```sh
php think workerman [ status ] [ --d ]
```
windows环境下需要分三步执行
```sh
# 内部通讯服务
php think workerman start --d
```
参数
- status: 状态
- start: 启动
- stop: 关闭
- restart: 重启
- --d : 后台执行
## 文档
[使用手册](https://doc.crmeb.com)
[TP6开发手册](https://www.kancloud.cn/manual/thinkphp6_0/content)
## 参与开发
请参阅 [CRMEB](https://github.com/crmeb/CRMEB)。
## 版权信息
本项目包含的第三方源码和二进制文件之版权信息另行标注。
版权所有Copyright © 2017-2023 by CRMEB (http://www.crmeb.com)
All rights reserved。
CRMEB® 商标和著作权所有者为西安众邦网络科技有限公司。

31
crmeb/app/AppService.php Normal file
View File

@ -0,0 +1,31 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app;
use crmeb\services\SystemConfigService;
use crmeb\services\GroupDataService;
use crmeb\utils\Json;
use think\Service;
class AppService extends Service
{
public $bind = [
'json' => Json::class,
'sysConfig' => SystemConfigService::class,
'sysGroupData' => GroupDataService::class
];
public function boot()
{
defined('DS') || define('DS', DIRECTORY_SEPARATOR);
}
}

View File

@ -0,0 +1,68 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app;
use think\db\exception\DataNotFoundException;
use think\db\exception\ModelNotFoundException;
use think\exception\Handle;
use think\exception\HttpException;
use think\exception\HttpResponseException;
use think\exception\ValidateException;
use think\Response;
use Throwable;
/**
* 应用异常处理类
*/
class ExceptionHandle extends Handle
{
/**
* 不需要记录信息(日志)的异常类列表
* @var array
*/
protected $ignoreReport = [
HttpException::class,
HttpResponseException::class,
ModelNotFoundException::class,
DataNotFoundException::class,
ValidateException::class,
];
/**
* 记录异常信息(包括日志或者其它方式记录)
*
* @access public
* @param Throwable $exception
* @return void
*/
public function report(Throwable $exception): void
{
// 使用内置的方式记录异常日志
parent::report($exception);
}
/**
* Render an exception into an HTTP response.
*
* @access public
* @param \think\Request $request
* @param Throwable $e
* @return Response
*/
public function render($request, Throwable $e): Response
{
// 添加自定义异常处理机制
// 其他错误交给系统处理
return parent::render($request, $e);
}
}

216
crmeb/app/Request.php Normal file
View File

@ -0,0 +1,216 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app;
use Spatie\Macroable\Macroable;
/**
* Class Request
* @package app
* @method tokenData() 获取token信息
* @method user(string $key = null) 获取用户信息
* @method uid() 获取用户uid
* @method isAdminLogin() 后台登陆状态
* @method adminId() 后台管理员id
* @method adminInfo() 后台管理信息
* @method kefuId() 客服id
* @method kefuInfo() 客服信息
*/
class Request extends \think\Request
{
use Macroable;
/**
* 不过滤变量名
* @var array
*/
protected $except = ['menu_path', 'api_url', 'unique_auth',
'description', 'custom_form', 'content', 'tableField'];
/**
* 获取请求的数据
* @param array $params
* @param bool $suffix
* @param bool $filter
* @return array
*/
public function more(array $params, bool $suffix = false, bool $filter = true): array
{
$p = [];
$i = 0;
foreach ($params as $param) {
if (!is_array($param)) {
$p[$suffix == true ? $i++ : $param] = $this->filterWord(is_string($this->param($param)) ? trim($this->param($param)) : $this->param($param), $filter && !in_array($param, $this->except));
} else {
if (!isset($param[1])) $param[1] = null;
if (!isset($param[2])) $param[2] = '';
if (is_array($param[0])) {
$name = is_array($param[1]) ? $param[0][0] . '/a' : $param[0][0] . '/' . $param[0][1];
$keyName = $param[0][0];
} else {
$name = is_array($param[1]) ? $param[0] . '/a' : $param[0];
$keyName = $param[0];
}
$p[$suffix == true ? $i++ : ($param[3] ?? $keyName)] = $this->filterWord(
is_string($this->param($name, $param[1], $param[2])) ?
trim($this->param($name, $param[1], $param[2])) :
$this->param($name, $param[1], $param[2]),
$filter && !in_array($keyName, $this->except));
}
}
return $p;
}
/**
* 过滤接受的参数
* @param $str
* @param bool $filter
* @return array|mixed|string|string[]
*/
public function filterWord($str, bool $filter = true)
{
if (!$str || !$filter) return $str;
// 把数据过滤
$farr = [
"/<(\\/?)(script|i?frame|style|html|body|title|link|meta|object|\\?|\\%)([^>]*?)>/isU",
"/(<[^>]*)on[a-zA-Z]+\s*=([^>]*>)/isU",
'/phar/is',
"/select|join|where|drop|like|modify|rename|insert|update|table|database|alter|truncate|\'|\/\*|\.\.\/|\.\/|union|into|load_file|outfile/is"
];
if (is_array($str)) {
foreach ($str as &$v) {
if (is_array($v)) {
foreach ($v as &$vv) {
if (!is_array($vv)) {
$vv = $this->replaceWord($farr, $vv);
}
}
} else {
$v = $this->replaceWord($farr, $v);
}
}
} else {
$str = $this->replaceWord($farr, $str);
}
return $str;
}
/**
* 替换
* @param $farr
* @param $str
* @return array|string|string[]|null
* @author: 吴汐
* @email: 442384644@qq.com
* @date: 2023/9/19
*/
public function replaceWord($farr, $str)
{
if (filter_var($str, FILTER_VALIDATE_URL)) {
$url = parse_url($str);
$host = $url['scheme'] . '://' . $url['host'];
$str = $host . preg_replace($farr, '', str_replace($host, '', $str));
} else {
$str = preg_replace($farr, '', $str);
}
return $str;
}
/**
* 获取get参数
* @param array $params
* @param bool $suffix
* @param bool $filter
* @return array
*/
public function getMore(array $params, bool $suffix = false, bool $filter = true): array
{
return $this->more($params, $suffix, $filter);
}
/**
* 获取post参数
* @param array $params
* @param bool $suffix
* @param bool $filter
* @return array
*/
public function postMore(array $params, bool $suffix = false, bool $filter = true): array
{
return $this->more($params, $suffix, $filter);
}
/**
* 获取用户访问端
* @return array|string|null
*/
public function getFromType()
{
return $this->header('Form-type', '');
}
/**
* 当前访问端
* @param string $terminal
* @return bool
*/
public function isTerminal(string $terminal)
{
return strtolower($this->getFromType()) === $terminal;
}
/**
* 是否是H5端
* @return bool
*/
public function isH5()
{
return $this->isTerminal('h5');
}
/**
* 是否是微信端
* @return bool
*/
public function isWechat()
{
return $this->isTerminal('wechat');
}
/**
* 是否是小程序端
* @return bool
*/
public function isRoutine()
{
return $this->isTerminal('routine');
}
/**
* 是否是app端
* @return bool
*/
public function isApp()
{
return $this->isTerminal('app');
}
/**
* 是否是app端
* @return bool
*/
public function isPc()
{
return $this->isTerminal('pc');
}
}

View File

@ -0,0 +1,104 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\adminapi;
use crmeb\exceptions\AdminException;
use crmeb\exceptions\ApiException;
use crmeb\exceptions\AuthException;
use think\db\exception\DbException;
use think\exception\Handle;
use think\exception\HttpResponseException;
use think\exception\ValidateException;
use think\facade\Env;
use think\facade\Log;
use think\Response;
use Throwable;
class AdminApiExceptionHandle extends Handle
{
/**
* 不需要记录信息(日志)的异常类列表
* @var array
*/
protected $ignoreReport = [
ValidateException::class,
AuthException::class,
AdminException::class,
ApiException::class,
];
/**
* 记录异常信息(包括日志或者其它方式记录)
* @access public
* @param Throwable $exception
* @return void
*/
public function report(Throwable $exception): void
{
if (!$this->isIgnoreReport($exception)) {
try {
$data = [
'file' => $exception->getFile(),
'line' => $exception->getLine(),
'message' => $this->getMessage($exception),
'code' => $this->getCode($exception),
];
//日志内容
$log = [
request()->adminId(), //管理员ID
request()->ip(), //客户ip
ceil(msectime() - (request()->time(true) * 1000)), //耗时(毫秒)
request()->rule()->getMethod(), //请求类型
str_replace("/", "", request()->rootUrl()), //应用
request()->baseUrl(), //路由
json_encode(request()->param(), JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),//请求参数
json_encode($data, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES), //报错数据
];
Log::write(implode("|", $log), "error");
} catch (\Throwable $e) {
Log::write($e->getMessage(), "error");
}
}
}
/**
* Render an exception into an HTTP response.
* @access public
* @param \think\Request $request
* @param Throwable $e
* @return Response
*/
public function render($request, Throwable $e): Response
{
if ($e instanceof HttpResponseException) {
return parent::render($request, $e);
}
$massageData = Env::get('app_debug', false) ? [
'message' => $e->getMessage(),
'file' => $e->getFile(),
'line' => $e->getLine(),
'trace' => $e->getTrace(),
'previous' => $e->getPrevious(),
] : [];
$message = $e->getMessage();
// 添加自定义异常处理机制
if ($e instanceof AuthException || $e instanceof AdminException || $e instanceof ApiException || $e instanceof ValidateException) {
return app('json')->make($e->getCode() ?: 400, $message, $massageData);
} else {
return app('json')->fail($message, $massageData);
}
}
}

View File

@ -0,0 +1,159 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
if (!function_exists('get_this_class_methods')) {
/**获取当前类方法
* @param $class
* @return array
*/
function get_this_class_methods($class, $unarray = [])
{
$arrayall = get_class_methods($class);
if ($parent_class = get_parent_class($class)) {
$arrayparent = get_class_methods($parent_class);
$arraynow = array_diff($arrayall, $arrayparent);//去除父级的
} else {
$arraynow = $arrayall;
}
return array_diff($arraynow, $unarray);//去除无用的
}
}
if (!function_exists('setconfig')) {
/**
* 修改config的函数
* @param $arr1 or $string 配置前缀
* @param $arr2 or $string 数据变量
* @return bool 返回状态
*/
function setconfig($name, $pat, $rep)
{
/**
* 原理就是 打开config配置文件 然后使用正则查找替换 然后在保存文件. 不能修改值为数组的配置
* 传递的参数为2个数组 前面的为配置 后面的为数值. 正则的匹配为单引号 如果你的是分号 请自行修改为分号
* $pat[0] = 参数前缀; : default_return_type
* $rep[0] = 要替换的内容; : json
*/
$pats = $reps = [];
if (is_array($pat) && is_array($rep)) {
for ($i = 0; $i < count($pat); $i++) {
$pats[$i] = '/\'' . $pat[$i] . '\'(.*?),/';
$reps[$i] = "'" . $pat[$i] . "'" . "=>" . "'" . $rep[$i] . "',";
}
$fileurl = app()->getConfigPath() . $name . ".php";
$string = file_get_contents($fileurl); //加载配置文件
$string = preg_replace($pats, $reps, $string); // 正则查找然后替换
@file_put_contents($fileurl, $string); // 写入配置文件
return true;
} else if (is_string($pat) && is_string($rep)) {
$pats = '/\'' . $pat . '\'(.*?),/';
if (substr_count($rep, '[')) {
$reps = "'" . $pat . "'" . "=>" . $rep . ",";
} else {
$rep = str_replace('\'', "", $rep);
$reps = "'" . $pat . "'" . "=>" . "'" . $rep . "',";
}
$fileurl = app()->getConfigPath() . $name . ".php";
$string = file_get_contents($fileurl); //加载配置文件
$string = preg_replace($pats, $reps, $string); // 正则查找然后替换
@file_put_contents($fileurl, $string); // 写入配置文件
return true;
} else {
return false;
}
}
}
if (!function_exists('arrayToText')) {
/**
* 修改config的函数
* @param $array
* @return string
*/
function arrayToText($array)
{
$config = print_r($array, true);
$config = str_replace('[', "\"", $config);
$config = str_replace(']', "\"", $config);
$input = explode("\n", $config);
foreach ($input as $k => $v) {
if (empty($v) || strpos($v, 'Array') !== false || strpos($v, '(') !== false || strpos($v, ')') !== false) {
continue;
}
$tmpValArr = explode('=>', $v);
if (count($tmpValArr) == 2) {
$input[$k] = $tmpValArr[0] . '=> \'' . trim($tmpValArr[1]) . '\',';
}
}
$config = implode("\n", $input);
$config = str_replace('Array', "", $config);
$config = str_replace('(', "[", $config);
$config = str_replace(')', "],", $config);
$config = rtrim($config, "\n");
$config = rtrim($config, ",");
$config = "<?php \n return " . $config . ';';
// $fileurl = app()->getConfigPath() ."templates.php";
// @file_put_contents($fileurl, $config); // 写入配置文件
return $config;
}
}
if (!function_exists('attr_format')) {
/**
* 格式化属性
* @param $arr
* @return array
*/
function attr_format($arr): array
{
$len = count($arr); // 获取数组长度
$title = array_column($arr, 'value'); // 获取数组中 value 列的值组成的新数组
$result = []; // 初始化结果数组
if ($len > 0) { // 判断数组是否为空
if ($len > 1) { // 如果数组长度大于 1
$result = $arr[0]['detail']; // 将第一个元素的 detail 属性赋值给结果数组
for ($i = 0; $i < $len - 1; $i++) { // 从第二个元素开始循环
$temp = $result; // 将结果数组赋值给临时变量
$result = []; // 初始化结果数组
foreach ($temp as $item) { // 遍历临时变量中的每个元素
foreach ($arr[$i + 1]['detail'] as $datum) { // 遍历当前元素的 detail 属性
$result[] = trim($item) . ',' . trim($datum); // 将两个元素拼接成一个字符串并添加到结果数组中
}
}
}
} else { // 如果数组长度大于等于 1
foreach ($arr[0]['detail'] as $item) { // 遍历第一个元素的 detail 属性
$result[] = trim($item); // 将每个元素添加到结果数组中
}
}
}
return [$result, $title];
}
}
if (!function_exists('verify_domain')) {
/**
* 验证域名是否合法
* @param string $domain
* @return bool
*/
function verify_domain(string $domain): bool
{
$res = "/^(?=^.{3,255}$)(http(s)?:\/\/)(www\.)?[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+(:\d+)*(\/\w+\.\w+)*$/";
if (preg_match($res, $domain))
return true;
else
return false;
}
}

View File

@ -0,0 +1,25 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
// +----------------------------------------------------------------------
// | 应用设置
// +----------------------------------------------------------------------
return [
// 是否强制使用路由
'url_route_must' => true,
// 合并路由规则
'route_rule_merge' => true,
// 路由是否完全匹配
'route_complete_match' => true,
// 是否自动转换URL中的控制器和操作名
'url_convert' => false,
];

View File

@ -0,0 +1,93 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\adminapi\controller;
use crmeb\basic\BaseController;
use think\facade\Validate;
/**
* 基类 所有控制器继承的类
* Class AuthController
* @package app\adminapi\controller
*/
class AuthController extends BaseController
{
/**
* 当前登陆管理员信息
* @var
*/
protected $adminInfo;
/**
* 当前登陆管理员ID
* @var
*/
protected $adminId;
/**
* 当前管理员权限
* @var array
*/
protected $auth = [];
/**
* 初始化
*/
protected function initialize()
{
$this->adminId = $this->request->adminId();//获取当前登陆管理员ID
$this->adminInfo = $this->request->adminInfo();//获取当前登陆管理员信息
$this->auth = $this->request->adminInfo['rule'] ?? [];//获取当前登陆管理员权限
}
/**
* 验证数据
* @param array $data
* @param $validate
* @param null $message
* @param bool $batch
* @return bool
*/
final protected function validate(array $data, $validate, $message = null, bool $batch = false)
{
if (is_array($validate)) {
$v = new Validate();//验证器
$v->rule($validate);//验证规则
} else {
if (strpos($validate, '.')) {// 支持场景
// 支持场景
list($validate, $scene) = explode('.', $validate);
}
$class = false !== strpos($validate, '\\') ? $validate : $this->app->parseClass('validate', $validate);//获取验证器类名
$v = new $class();//实例化验证器
if (!empty($scene)) {
$v->scene($scene);//验证场景
}
if (is_string($message) && empty($scene)) {
$v->scene($message);
}
}
if (is_array($message))
$v->message($message);
// 是否批量验证
if ($batch) {
$v->batch(true);
}
return $v->failException(true)->check($data);
}
}

View File

@ -0,0 +1,402 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\adminapi\controller;
use app\services\system\config\SystemConfigServices;
use app\services\system\SystemAuthServices;
use app\services\order\StoreOrderServices;
use app\services\product\product\StoreProductServices;
use app\services\product\product\StoreProductReplyServices;
use app\services\system\UpgradeServices;
use app\services\user\UserExtractServices;
use app\services\product\sku\StoreProductAttrValueServices;
use app\services\system\SystemMenusServices;
use app\services\user\UserServices;
use crmeb\services\CacheService;
use crmeb\services\HttpService;
/**
* 公共接口基类 主要存放公共接口
* Class Common
* @package app\adminapi\controller
*/
class Common extends AuthController
{
/**
* 获取logo
* @return mixed
*/
public function getLogo()
{
return app('json')->success([
'logo' => sys_config('site_logo'),
'logo_square' => sys_config('site_logo_square'),
'site_name' => sys_config('site_name')
]);
}
/**
* 获取授权信息
* @return mixed
*/
public function auth()
{
$version = get_crmeb_version();
$host = $this->request->host();
// 正常域名
$res = HttpService::request('http://authorize.crmeb.net/api/auth_cert_query', 'post', [
'domain_name' => $host,
'label' => 34,
'version' => $version
]);
$res = $res ? json_decode($res, true) : [];
//兼容test.
if (!isset($res['data']['status']) || $res['data']['status'] !== 1) {
$host = str_replace('test.', '', $host);
$res = HttpService::request('http://authorize.crmeb.net/api/auth_cert_query', 'post', [
'domain_name' => $host,
'label' => 34,
'version' => $version
]);
$res = $res ? json_decode($res, true) : [];
}
//如果是主域名兼容www.
if (!isset($res['data']['status']) || $res['data']['status'] !== 1) {
$host = str_replace('www.', '', $host);
$res = HttpService::request('http://authorize.crmeb.net/api/auth_cert_query', 'post', [
'domain_name' => $host,
'label' => 34,
'version' => $version
]);
$res = $res ? json_decode($res, true) : [];
}
//升级状态
// /** @var UpgradeServices $upgradeServices */
// $upgradeServices = app()->make(UpgradeServices::class);
// $upgradeStatus = $upgradeServices->getUpgradeStatus();
$status = $res['data']['status'] ?? -9;
switch ((int)$status) {
case 1:
//审核成功
$authCode = $res['data']['auth_code'] ?? '';
$autoContent = $res['data']['auto_content'] ?? '';
try {
/** @var SystemConfigServices $services */
$services = app()->make(SystemConfigServices::class);
if ($services->count(['menu_name' => 'cert_crmeb'])) {
$services->update(['menu_name' => 'cert_crmeb'], ['value' => json_encode($autoContent . ',' . $authCode)]);
} else {
$services->save([
'menu_name' => 'cert_crmeb',
'type' => 'text',
'input_type' => 'input',
'config_tab_id' => 1,
'value' => json_encode($autoContent . ',' . $authCode),
'status' => 2,
'info' => '授权密钥'
]);
}
} catch (\Throwable $e) {
return app('json')->fail(400330);
}
return app('json')->success(['status' => 1, 'copyright' => $res['data']['copyright'], 'authCode' => $authCode, 'day' => 0, 'force_reminder' => $upgradeStatus['force_reminder'] ?? 0]);
default:
return app('json')->success(['status' => -9, 'force_reminder' => $upgradeStatus['force_reminder'] ?? 0]);
}
}
/**
* 申请授权
* @return mixed
*/
public function auth_apply(SystemAuthServices $services)
{
$data = $this->request->postMore([
['company_name', ''],
['domain_name', ''],
['order_id', ''],
['phone', ''],
['label', 19],
['captcha', ''],
]);
if (!$data['company_name']) {
return app('json')->fail(400331);
}
if (!$data['domain_name']) {
return app('json')->fail(400332);
}
if (!$data['phone']) {
return app('json')->fail(400333);
}
if (!$data['order_id']) {
return app('json')->fail(400334);
}
if (!$data['captcha']) {
return app('json')->fail(400137);
}
$services->authApply($data);
return app('json')->success(400335);
}
/**
* 首页头部统计数据
* @return mixed
*/
public function homeStatics()
{
/** @var UserServices $orderServices */
$userServices = app()->make(UserServices::class);
$info = $userServices->homeStatics();
return app('json')->success(compact('info'));
}
//增长率
public function growth($nowValue, $lastValue)
{
if ($lastValue == 0 && $nowValue == 0) return 0;
if ($lastValue == 0) return round($nowValue, 2);
if ($nowValue == 0) return -round($lastValue, 2);
return bcmul(bcdiv((bcsub($nowValue, $lastValue, 2)), $lastValue, 2), 100, 2);
}
/**
* 订单图表
*/
public function orderChart()
{
$cycle = $this->request->param('cycle') ?: 'thirtyday';//默认30天
$userServices = app()->make(UserServices::class); // 获取 UserServices 类的实例
$chartdata = $userServices->orderCharts($cycle); // 调用 orderCharts 方法获取图表数据
return app('json')->success($chartdata); // 返回 JSON 格式的图表数据
}
/**
* 用户图表
*/
public function userChart()
{
/** @var UserServices $uServices */
$uServices = app()->make(UserServices::class);
$chartdata = $uServices->userChart();
return app('json')->success($chartdata);
}
/**
* 交易额排行
* @return mixed
*/
public function purchaseRanking()
{
/** @var StoreProductAttrValueServices $valueServices */
$valueServices = app()->make(StoreProductAttrValueServices::class);
$list = '';
return app('json')->success(compact('list'));
}
/**
* 待办事统计
* @return mixed
*/
public function jnotice()
{
$store_stock = sys_config('store_stock');
if ($store_stock < 0) $store_stock = 2;
/** @var StoreProductServices $storeServices */
$storeServices = app()->make(StoreProductServices::class);
$data['inventory'] = $storeServices->count(['type' => 5, 'store_stock' => $store_stock]);//警戒库存
/** @var StoreProductReplyServices $replyServices */
$replyServices = app()->make(StoreProductReplyServices::class);
$data['commentnum'] = $replyServices->replyCount();
/** @var UserExtractServices $extractServices */
$extractServices = app()->make(UserExtractServices::class);
$data['reflectnum'] = $extractServices->userExtractCount();//提现
$data['msgcount'] = intval($data['inventory']) + intval($data['commentnum']) + intval($data['reflectnum']);
$value = [];
if ($data['inventory'] != 0) {
$value[] = [
'title' => "您有$data[inventory]个商品库存预警",
'type' => 2,
'url' => '/admin/product/product_list?type=5',
];
}
if ($data['commentnum'] != 0) {
$value[] = [
'title' => "您有$data[commentnum]条评论待回复",
'type' => 3,
'url' => '/admin/product/product_reply?is_reply=0'
];
}
if ($data['reflectnum'] != 0) {
$value[] = [
'title' => "您有$data[reflectnum]个提现申请待审核",
'type' => 4,
'url' => '/admin/finance/user_extract/index?status=0',
];
}
return app('json')->success($this->noticeData($value));
}
/**
* 消息返回格式
* @param array $data
* @return array
*/
public function noticeData(array $data): array
{
// 消息图标
$iconColor = [
// 邮件 消息
'mail' => [
'icon' => 'md-mail',
'color' => '#3391e5'
],
// 普通 消息
'bulb' => [
'icon' => 'md-bulb',
'color' => '#87d068'
],
// 警告 消息
'information' => [
'icon' => 'md-information',
'color' => '#fe5c57'
],
// 关注 消息
'star' => [
'icon' => 'md-star',
'color' => '#ff9900'
],
// 申请 消息
'people' => [
'icon' => 'md-people',
'color' => '#f06292'
],
];
// 消息类型
$type = array_keys($iconColor);
// 默认数据格式
$default = [
'icon' => 'md-bulb',
'iconColor' => '#87d068',
'title' => '',
'url' => '',
'type' => 'bulb',
'read' => 0,
'time' => 0
];
$value = [];
foreach ($data as $item) {
$val = array_merge($default, $item);
if (isset($item['type']) && in_array($item['type'], $type)) {
$val['type'] = $item['type'];
$val['iconColor'] = $iconColor[$item['type']]['color'] ?? '';
$val['icon'] = $iconColor[$item['type']]['icon'] ?? '';
}
$value[] = $val;
}
return $value;
}
/**
* 格式化菜单
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function menusList()
{
/** @var SystemMenusServices $menusServices */
$menusServices = app()->make(SystemMenusServices::class);
$list = $menusServices->getSearchList();
$counts = $menusServices->getColumn([
['is_show', '=', 1],
['auth_type', '=', 1],
['is_del', '=', 0],
['is_show_path', '=', 0],
], 'pid');
$data = [];
foreach ($list as $key => $item) {
$pid = $item->getData('pid');
$data[$key] = json_decode($item, true);
$data[$key]['pid'] = $pid;
$data[$key]['menu_path'] = '/' . config('app.admin_prefix', 'admin') . $item['menu_path'];
if (in_array($item->id, $counts)) {
$data[$key]['type'] = 1;
} else {
$data[$key]['type'] = 0;
}
}
return app('json')->success(sort_list_tier($data));
}
/**
* 查询购买版权
* @return mixed
*/
public function copyright()
{
$copyrightContext = sys_config('nncnL_crmeb_copyright', '');
$copyrightImage = sys_config('nncnL_crmeb_copyright_image', '');
return app('json')->success(compact('copyrightContext', 'copyrightImage'));
}
/**
* 保存版权
* @return mixed
*/
public function saveCopyright()
{
[$copyright, $copyrightImg] = $this->request->postMore(['copyright', 'copyright_img',], true);
/** @var SystemConfigServices $services */
$services = app()->make(SystemConfigServices::class);
if ($services->count(['menu_name' => 'nncnL_crmeb_copyright'])) {
$services->update(['menu_name' => 'nncnL_crmeb_copyright'], ['value' => json_encode($copyright)]);
} else {
$services->save([
'menu_name' => 'nncnL_crmeb_copyright',
'type' => 'text',
'input_type' => 'input',
'config_tab_id' => 1,
'value' => json_encode($copyright),
'status' => 2,
'info' => ''
]);
}
if ($services->count(['menu_name' => 'nncnL_crmeb_copyright_image'])) {
$services->update(['menu_name' => 'nncnL_crmeb_copyright_image'], ['value' => json_encode($copyrightImg)]);
} else {
$services->save([
'menu_name' => 'nncnL_crmeb_copyright_image',
'type' => 'text',
'input_type' => 'input',
'config_tab_id' => 1,
'value' => json_encode($copyrightImg),
'status' => 2,
'info' => ''
]);
}
CacheService::clear();
return app('json')->success(100000);
}
}

View File

@ -0,0 +1,130 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\adminapi\controller;
use crmeb\services\CacheService;
use think\facade\App;
use crmeb\utils\Captcha;
use app\services\system\admin\SystemAdminServices;
/**
* 后台登陆
* Class Login
* @package app\adminapi\controller
*/
class Login extends AuthController
{
/**
* Login constructor.
* @param App $app
* @param SystemAdminServices $services
*/
public function __construct(App $app, SystemAdminServices $services)
{
parent::__construct($app);// 调用父类构造函数
$this->services = $services;// 实例化系统管理员服务类
}
protected function initialize()
{
// TODO: Implement initialize() method.
}
/**
* 验证码
* @return $this|\think\Response
*/
public function captcha()
{
return app()->make(Captcha::class)->create();// 生成验证码
}
/**
* @return mixed
*/
public function ajcaptcha()
{
$captchaType = $this->request->get('captchaType');// 验证码类型
return app('json')->success(aj_captcha_create($captchaType));// 生成验证码
}
/**
* 一次验证
* @return mixed
*/
public function ajcheck()
{
[$token, $pointJson, $captchaType] = $this->request->postMore([
['token', ''],
['pointJson', ''],
['captchaType', ''],
], true);
try {
aj_captcha_check_one($captchaType, $token, $pointJson);// 验证验证码
return app('json')->success();
} catch (\Throwable $e) {
return app('json')->fail(400336);
}
}
/**
* 登陆
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function login()
{
[$account, $password, $key, $captchaVerification, $captchaType] = $this->request->postMore([
'account',
'pwd',
['key', ''],
['captchaVerification', ''],
['captchaType', '']
], true);
if ($captchaVerification != '') {
try {
aj_captcha_check_two($captchaType, $captchaVerification);
} catch (\Throwable $e) {
return app('json')->fail(400336);
}
}
if (strlen(trim($password)) < 6 || strlen(trim($password)) > 32) {
return app('json')->fail(400762);
}
$this->validate(['account' => $account, 'pwd' => $password], \app\adminapi\validate\setting\SystemAdminValidata::class, 'get');
$result = $this->services->login($account, $password, 'admin', $key);
if (!$result) {
$num = CacheService::get('login_captcha', 1);
if ($num > 1) {
return app('json')->fail(400140, ['login_captcha' => 1]);
}
CacheService::set('login_captcha', $num + 1, 60);
return app('json')->fail(400140, ['login_captcha' => 0]);
}
CacheService::delete('login_captcha');
return app('json')->success($result);
}
/**
* 获取后台登录页轮播图以及LOGO
* @return mixed
*/
public function info()
{
return app('json')->success($this->services->getLoginInfo());
}
}

View File

@ -0,0 +1,109 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\adminapi\controller;
use app\Request;
use app\services\system\attachment\SystemAttachmentServices;
use app\services\system\SystemRouteServices;
use crmeb\services\CacheService;
use think\Response;
class PublicController
{
/**
* 下载文件
* @param string $key
* @return Response|\think\response\File
*/
public function download(string $key = '')
{
/**
* 根据给定的key从缓存中获取文件名和路径并下载该文件
*
* @param string $key 缓存中存储文件名和路径的key
* @return mixed 返回下载文件的响应或错误响应
*/
if (!$key) {
// 如果文件名和路径不存在或文件不存在则返回500错误响应
return Response::create()->code(500);
}
// 从缓存中获取文件名和路径
$fileName = CacheService::get($key);
if (is_array($fileName) && isset($fileName['path']) && isset($fileName['fileName']) && $fileName['path'] && $fileName['fileName'] && file_exists($fileName['path'])) {
// 如果文件名和路径都存在且文件存在,则删除缓存并下载文件
CacheService::delete($key);
return download($fileName['path'], $fileName['fileName']);//
}
// 如果文件名和路径不存在或文件不存在则返回500错误响应
return Response::create()->code(500);
}
/**
* 获取workerman请求域名
* @return mixed
*/
public function getWorkerManUrl()
{
/**
* 获取 WorkerMan 服务器地址并返回 JSON 格式的成功响应
*
* @return \Illuminate\Http\JsonResponse
*/
return app('json')->success(getWorkerManUrl());
}
/**
* 扫码上传
* @param Request $request
* @param int $upload_type
* @param int $type
* @return Response
* @author 吴汐
* @email 442384644@qq.com
* @date 2023/06/13
*/
public function scanUpload(Request $request, $upload_type = 0, $type = 0)
{
/**
* 上传文件
*
* @param Request $request HTTP请求对象
* @return mixed 返回JSON格式的响应结果
*/
[$file, $uploadToken, $pid] = $request->postMore([
['file', 'file'], // 获取上传的文件
['uploadToken', ''], // 获取上传令牌
['pid', 0] // 获取项目ID
], true);
$service = app()->make(SystemAttachmentServices::class); // 实例化系统附件服务类
if (CacheService::get('scan_upload') != $uploadToken) { // 判断上传令牌是否正确
return app('json')->fail(410086); // 上传令牌错误,返回失败响应
}
$service->upload((int)$pid, $file, $upload_type, $type, '', $uploadToken); // 调用系统附件服务类的上传方法
return app('json')->success(100032); // 返回成功响应
}
public function import(Request $request)
{
$filePath = $request->param('file_path', ''); // 从请求参数中获取文件路径
if (empty($filePath)) { // 如果文件路径为空
return app('json')->fail(12894); // 返回失败响应错误码为12894
}
app()->make(SystemRouteServices::class)->import($filePath); // 调用SystemRouteServices类的import方法导入系统路由
return app('json')->success(100010); // 返回成功响应状态码为100010
}
}

View File

@ -0,0 +1,16 @@
<?php
/**
* @author: liaofei<136327134@qq.com>
* @day: 2020/9/12
*/
namespace app\adminapi\controller;
class Test
{
public function index()
{
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,202 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\adminapi\controller\v1\application\routine;
use app\jobs\notice\SyncMessageJob;
use app\services\message\SystemNotificationServices;
use app\services\other\QrcodeServices;
use app\services\system\attachment\SystemAttachmentServices;
use crmeb\exceptions\AdminException;
use think\exception\ValidateException;
use think\facade\App;
use app\adminapi\controller\AuthController;
use crmeb\services\FileService;
use app\services\other\UploadService;
use crmeb\services\app\MiniProgramService;
/**
* Class RoutineTemplate
* @package app\adminapi\controller\v1\application\routine
*/
class RoutineTemplate extends AuthController
{
protected $cacheTag = '_system_wechat';
/**
* 构造方法
* WechatTemplate constructor.
* @param App $app
* @param SystemNotificationServices $services
*/
public function __construct(App $app, SystemNotificationServices $services)
{
parent::__construct($app);
$this->services = $services;
}
/**
* 同步订阅消息
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function syncSubscribe()
{
if (!sys_config('routine_appId') || !sys_config('routine_appsecret')) {
throw new AdminException(400236);
}
$list = MiniProgramService::getSubscribeTemplateList();
foreach ($list->data as $v) {
MiniProgramService::delSubscribeTemplate($v['priTmplId']);
}
$tempKeys = $this->services->getTempKey('routine');
foreach ($tempKeys as $key => $content) {
SyncMessageJob::dispatch('SyncSubscribe', [$key, $content]);
}
return app('json')->success(100038);
}
/**
* 下载小程序
* @return mixed
*/
public function downloadTemp()
{
[$name, $is_live] = $this->request->postMore([
['name', ''],
['is_live', 0]
], true);
if (sys_config('routine_appId', '') == '') throw new AdminException(400236);
try {
@unlink(public_path() . 'statics/download/routine.zip');
//拷贝源文件
/** @var FileService $fileService */
$fileService = app(FileService::class);
$fileService->copyDir(public_path() . 'statics/mp_view', public_path() . 'statics/download');
//替换appid和名称
$this->updateConfigJson(sys_config('routine_appId'), $name != '' ? $name : sys_config('routine_name'));
//是否开启直播
if ($is_live == 0) $this->updateAppJson();
//替换url
$this->updateUrl('https://' . $_SERVER['HTTP_HOST']);
//压缩文件
$fileService->addZip(public_path() . 'statics/download', public_path() . 'statics/download/routine.zip', public_path() . 'statics/download');
$data['url'] = sys_config('site_url') . '/statics/download/routine.zip';
return app('json')->success($data);
} catch (\Throwable $e) {
throw new AdminException($e->getMessage());
}
}
/**
* 替换url
* @param $url
*/
public function updateUrl($url)
{
$fileUrl = app()->getRootPath() . "public/statics/download/common/vendor.js";
$string = file_get_contents($fileUrl); //加载配置文件
$string = str_replace('https://demo.crmeb.com', $url, $string); // 正则查找然后替换
$newFileUrl = app()->getRootPath() . "public/statics/download/common/vendor.js";
@file_put_contents($newFileUrl, $string); // 写入配置文件
}
/**
* 判断是否开启直播(弃用)
* @param int $iszhibo
*/
public function updateAppJson()
{
$fileUrl = app()->getRootPath() . "public/statics/download/app.json";
$string = file_get_contents($fileUrl); //加载配置文件
$pats = '/,
"plugins": \{
"live-player-plugin": \{
"version": "(.*?)",
"provider": "(.*?)"
}
}/';
$string = preg_replace($pats, '', $string); // 正则查找然后替换
$newFileUrl = app()->getRootPath() . "public/statics/download/app.json";
@file_put_contents($newFileUrl, $string); // 写入配置文件
}
/**
* 替换appid
* @param string $appid
* @param string $projectanme
*/
public function updateConfigJson($appId = '', $projectName = '')
{
$fileUrl = app()->getRootPath() . "public/statics/download/project.config.json";
$string = file_get_contents($fileUrl); //加载配置文件
// 替换appid
$appIdOld = '/"appid"(.*?),/';
$appIdNew = '"appid"' . ': ' . '"' . $appId . '",';
$string = preg_replace($appIdOld, $appIdNew, $string); // 正则查找然后替换
// 替换小程序名称
$projectNameOld = '/"projectname"(.*?),/';
$projectNameNew = '"projectname"' . ': ' . '"' . $projectName . '",';
$string = preg_replace($projectNameOld, $projectNameNew, $string); // 正则查找然后替换
$newFileUrl = app()->getRootPath() . "public/statics/download/project.config.json";
@file_put_contents($newFileUrl, $string); // 写入配置文件
}
/**
* 获取小程序码
* @return string
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function getDownloadInfo()
{
$data['routine_name'] = sys_config('routine_name', '');
if (sys_config('routine_appId') == '') {
$data['code'] = '';
} else {
$name = $data['routine_name'] . '.jpg';
/** @var SystemAttachmentServices $systemAttachmentModel */
$systemAttachmentModel = app()->make(SystemAttachmentServices::class);
$imageInfo = $systemAttachmentModel->getInfo(['name' => $name]);
if (!$imageInfo) {
/** @var QrcodeServices $qrcode */
$qrcode = app()->make(QrcodeServices::class);
$resForever = $qrcode->qrCodeForever(0, 'code');
if ($resForever) {
$resCode = MiniProgramService::appCodeUnlimitService($resForever->id, '', 280);
$res = ['res' => $resCode, 'id' => $resForever->id];
} else {
$res = false;
}
if (!$res) throw new ValidateException(400237);
$upload = UploadService::init(1);
if ($upload->to('routine/code')->setAuthThumb(false)->stream((string)$res['res'], $name) === false) {
return $upload->getError();
}
$imageInfo = $upload->getUploadInfo();
$imageInfo['image_type'] = 1;
$systemAttachmentModel->attachmentAdd($imageInfo['name'], $imageInfo['size'], $imageInfo['type'], $imageInfo['dir'], $imageInfo['thumb_path'], 1, $imageInfo['image_type'], $imageInfo['time'], 2);
$qrcode->update($res['id'], ['status' => 1, 'time' => time(), 'qrcode_url' => $imageInfo['dir']]);
$data['code'] = sys_config('site_url') . $imageInfo['dir'];
} else $data['code'] = sys_config('site_url') . $imageInfo['att_dir'];
}
$data['appId'] = sys_config('routine_appId');
$data['help'] = 'https://doc.crmeb.com/web/single/crmeb_v4/978';
return app('json')->success($data);
}
}

View File

@ -0,0 +1,57 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\adminapi\controller\v1\application\wechat;
use app\adminapi\controller\AuthController;
use app\services\wechat\WechatMenuServices;
use think\facade\App;
/**
* 微信菜单 控制器
* Class Menus
* @package app\admin\controller\wechat
*/
class Menus extends AuthController
{
/**
* 构造方法
* Menus constructor.
* @param App $app
* @param WechatMenuServices $services
*/
public function __construct(App $app, WechatMenuServices $services)
{
parent::__construct($app);
$this->services = $services;
}
/**
* 获取菜单
* @return mixed
*/
public function index()
{
$menus = $this->services->getWechatMenu();
return app('json')->success(compact('menus'));
}
/**
* 保存菜单
* @return mixed
*/
public function save()
{
$buttons = request()->post('button/a', []);
if (!count($buttons)) return app('json')->fail(400238);
$this->services->saveMenu($buttons);
return app('json')->success(100001);
}
}

View File

@ -0,0 +1,172 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\adminapi\controller\v1\application\wechat;
use app\services\other\QrcodeServices;
use EasyWeChat\Core\Exceptions\HttpException;
use app\adminapi\controller\AuthController;
use app\services\wechat\WechatReplyServices;
use app\services\wechat\WechatKeyServices;
use think\facade\App;
/**
* 关键字管理 控制器
* Class Reply
* @package app\admin\controller\wechat
*/
class Reply extends AuthController
{
/**
* 构造方法
* Menus constructor.
* @param App $app
* @param WechatReplyServices $services
*/
public function __construct(App $app, WechatReplyServices $services)
{
parent::__construct($app);
$this->services = $services;
}
/**
* 关注回复
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function reply()
{
$where = $this->request->getMore([
['key', ''],
]);
if ($where['key'] == '') return app('json')->fail(100100);
$info = $this->services->getDataByKey($where['key']);
return app('json')->success(compact('info'));
}
/**
* 关键字回复列表
* @return mixed
*/
public function index()
{
$where = $this->request->getMore([
['key', ''],
['type', ''],
]);
$where['key_type'] = 0;
$list = $this->services->getKeyAll($where);
return app('json')->success($list);
}
/**
* 关键字详情
* @param $id
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
*/
public function read($id)
{
$info = $this->services->getKeyInfo($id);
return app('json')->success(compact('info'));
}
/**
* 保存关键字
* @param int $id
* @return mixed
*/
public function save($id = 0)
{
$data = $this->request->postMore([
'key',
'type',
['status', 0],
['data', []],
]);
try {
if (!isset($data['key']) && empty($data['key']))
return app('json')->fail(400239);
if (!isset($data['type']) && empty($data['type']))
return app('json')->fail(400240);
if (!in_array($data['type'], $this->services->replyType()))
return app('json')->fail(400241);
if (!isset($data['data']) || !is_array($data['data']))
return app('json')->fail(400242);
$res = $this->services->redact($data['data'], $id, $data['key'], $data['type'], $data['status']);
if (!$res)
return app('json')->fail(100006);
else
return app('json')->success(100000, $data);
} catch (HttpException $e) {
return app('json')->fail($e->getMessage());
}
}
/**
* 删除关键字
* @param $id
* @return mixed
*/
public function delete($id)
{
if (!$this->services->delete($id)) {
return app('json')->fail(100008);
} else {
/** @var WechatKeyServices $keyServices */
$keyServices = app()->make(WechatKeyServices::class);
$res = $keyServices->delete($id, 'reply_id');
if (!$res) {
return app('json')->fail(100008);
}
}
return app('json')->success(100002);
}
/**
* 修改状态
* @param $id
* @param $status
* @return mixed
*/
public function set_status($id, $status)
{
if ($status == '' || $id == 0) return app('json')->fail(100100);
$this->services->update($id, ['status' => $status], 'id');
return app('json')->success(100014);
}
/**
* 生成关注回复二维码
* @param $id
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function code_reply($id)
{
if (!$id) {
return app('json')->fail('100100');
}
/** @var QrcodeServices $qrcode */
$qrcode = app()->make(QrcodeServices::class);
$code = $qrcode->getForeverQrcode('reply', $id);
if (!$code['ticket']) {
return app('json')->fail(400237);
}
return app('json')->success($code->toArray());
}
}

View File

@ -0,0 +1,203 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\adminapi\controller\v1\application\wechat;
use app\adminapi\controller\AuthController;
use crmeb\services\app\WechatService;
use think\facade\App;
use app\services\wechat\WechatNewsCategoryServices;
use app\services\article\CaseServices;
use think\facade\Log;
/**
* 图文信息
* Class WechatNewsCategory
* @package app\admin\controller\wechat
*
*/
class WechatNewsCategory extends AuthController
{
/**
* 构造方法
* Menus constructor.
* @param App $app
* @param WechatNewsCategoryServices $services
*/
public function __construct(App $app, WechatNewsCategoryServices $services)
{
parent::__construct($app);
$this->services = $services;
}
/**
* 图文消息列表
* @return mixed
*/
public function index()
{
$where = $this->request->getMore([
['page', 1],
['limit', 20],
['cate_name', '']
]);
$list = $this->services->getAll($where);
return app('json')->success($list);
}
/**
* 图文详情
* @param $id
* @return mixed
*/
public function read($id)
{
$info = $this->services->get($id);
/** @var CaseServices $services */
$services = app()->make(CaseServices::class);
$new = $services->articlesList($info['new_id']);
if ($new) $new = $new->toArray();
$info['new'] = $new;
return app('json')->success(compact('info'));
}
/**
* 删除图文
* @param $id
* @return mixed
*/
public function delete($id)
{
if (!$this->services->delete($id))
return app('json')->fail(100008);
else
return app('json')->success(100002);
}
/**
* 新增或编辑保存
* @return mixed
*/
public function save()
{
$data = $this->request->postMore([
['list', []],
['id', 0]
]);
try {
$id = [];
$countList = count($data['list']);
if (!$countList) return app('json')->fail(400243);
/** @var CaseServices $services */
$services = app()->make(CaseServices::class);
foreach ($data['list'] as $k => $v) {
if ($v['title'] == '') return app('json')->fail(400244);
if ($v['author'] == '') return app('json')->fail(400245);
if ($v['content'] == '') return app('json')->fail(400246);
if ($v['synopsis'] == '') return app('json')->fail(400247);
$v['status'] = 1;
$v['add_time'] = time();
if ($v['id']) {
$idC = $v['id'];
$services->save($v);
unset($v['id']);
$data['list'][$k]['id'] = $idC;
$id[] = $idC;
} else {
$res = $services->save($v);
unset($v['id']);
$id[] = $res['id'];
$data['list'][$k]['id'] = $res['id'];
}
}
$countId = count($id);
if ($countId != $countList) {
if ($data['id']) return app('json')->fail(100007);
else return app('json')->fail(100022);
} else {
$newsCategory['cate_name'] = $data['list'][0]['title'];
$newsCategory['new_id'] = implode(',', $id);
$newsCategory['sort'] = 0;
$newsCategory['add_time'] = time();
$newsCategory['status'] = 1;
if ($data['id']) {
$this->services->update($data['id'], $newsCategory, 'id');
return app('json')->success(100001);
} else {
$this->services->save($newsCategory);
return app('json')->success(100021);
}
}
} catch (\Exception $e) {
return app('json')->fail(100101);
}
}
/**
* 发送消息
*/
public function push()
{
$data = $this->request->postMore([
['id', 0],
['user_ids', '']
]);
if (!$data['id']) return app('json')->fail(100100);
$list = $this->services->getWechatNewsItem($data['id']);
$wechatNews = [];
if ($list) {
if (is_array($list['new']) && count($list['new'])) {
$wechatNews['title'] = $list['new'][0]['title'];
$wechatNews['image_input'] = $list['new'][0]['image_input'];
$wechatNews['date'] = date('m月d日', time());
$wechatNews['description'] = $list['new'][0]['synopsis'];
$wechatNews['id'] = $list['new'][0]['id'];
}
}
if ($data['user_ids'] != '') {//客服消息
$wechatNews = $this->services->wechatPush($wechatNews);
$message = WechatService::newsMessage($wechatNews);
$errorLog = [];//发送失败的用户
$user = $this->services->getWechatUser($data['user_ids'], 'nickname,subscribe,openid', 'uid');
if ($user) {
foreach ($user as $v) {
if ($v['subscribe'] && $v['openid']) {
try {
WechatService::staffService()->message($message)->to($v['openid'])->send();
} catch (\Exception $e) {
Log::error($v['nickname'] . '发送失败,原因' . $e->getMessage());
$errorLog[] = $v['nickname'] . '发送失败';
}
} else {
$errorLog[] = $v['nickname'] . '没有关注发送失败(不是微信公众号用户)';
}
}
} else return app('json')->fail(100031);
if (!count($errorLog)) return app('json')->success(100030);
else return app('json')->success(100030);
}
}
/**
* 发送消息图文列表
* @return mixed
*/
public function send_news()
{
$where = $this->request->getMore([
['cate_name', ''],
['page', 1],
['limit', 10]
]);
return app('json')->success($this->services->list($where));
}
}

View File

@ -0,0 +1,188 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\adminapi\controller\v1\application\wechat;
use app\adminapi\controller\AuthController;
use app\services\wechat\WechatQrcodeCateServices;
use app\services\wechat\WechatQrcodeRecordServices;
use app\services\wechat\WechatQrcodeServices;
use think\facade\App;
class WechatQrcode extends AuthController
{
protected $qrcodeCateServices;
protected $wechatQrcodeServices;
protected $qrcodeRecordServices;
/**
* WechatQrcode constructor.
* @param App $app
* @param WechatQrcodeCateServices $services
*/
public function __construct(App $app, WechatQrcodeCateServices $qrcodeCateServices, WechatQrcodeServices $wechatQrcodeServices, WechatQrcodeRecordServices $qrcodeRecordServices)
{
parent::__construct($app);
$this->qrcodeCateServices = $qrcodeCateServices;
$this->wechatQrcodeServices = $wechatQrcodeServices;
$this->qrcodeRecordServices = $qrcodeRecordServices;
}
/**
* 分类列表
* @return mixed
*/
public function getCateList()
{
$data = $this->qrcodeCateServices->getCateList();
$count = $this->qrcodeCateServices->count(['is_del' => 0]);
return app('json')->success(compact('data', 'count'));
}
/**
* 添加编辑表单
* @param $id
* @return mixed
* @throws \FormBuilder\Exception\FormBuilderException
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function createForm($id)
{
return app('json')->success($this->qrcodeCateServices->createForm($id));
}
/**
* 保存数据
* @return mixed
*/
public function saveCate()
{
$data = $this->request->postMore([
['id', 0],
['cate_name', '']
]);
$this->qrcodeCateServices->saveData($data);
return app('json')->success(100000);
}
/**
* 删除分类
* @param $id
* @return mixed
*/
public function delCate($id)
{
$this->qrcodeCateServices->delCate($id);
return app('json')->success(100000);
}
/**
* 保存渠道码
* @param $id
* @return mixed
*/
public function saveQrcode($id = 0)
{
$data = $this->request->postMore([
['uid', 0],
['name', ''],
['image', ''],
['cate_id', 0],
['label_id', []],
['type', 0],
['content', ''],
['time', 0],
]);
$this->wechatQrcodeServices->saveQrcode($id, $data);
return app('json')->success(100000);
}
/**
* 获取渠道码列表
* @return mixed
*/
public function qrcodeList()
{
$where = $this->request->getMore([
['name', ''],
['cate_id', 0]
]);
$where['is_del'] = 0;
$data = $this->wechatQrcodeServices->qrcodeList($where);
return app('json')->success($data);
}
/**
* 获取详情
* @param int $id
* @return mixed
*/
public function qrcodeInfo($id = 0)
{
if (!$id) return app('json')->fail(100100);
$info = $this->wechatQrcodeServices->qrcodeInfo($id);
return app('json')->success($info);
}
/**
* 删除渠道码
* @param int $id
* @return mixed
*/
public function delQrcode($id = 0)
{
if (!$id) return app('json')->fail(100100);
$this->wechatQrcodeServices->update($id, ['is_del' => 1]);
return app('json')->success(100002);
}
/**
* 切换状态
* @param $id
* @param $status
* @return mixed
*/
public function setStatus($id, $status)
{
if (!$id) return app('json')->fail(100100);
$this->wechatQrcodeServices->update($id, ['status' => $status]);
return app('json')->success(100014);
}
/**
* 用户列表
* @param $qid
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function userList($qid)
{
return app('json')->success($this->qrcodeRecordServices->userList($qid));
}
/**
* 渠道码统计
* @param $qid
* @return mixed
*/
public function qrcodeStatistic($qid)
{
[$time] = $this->request->getMore([
['time', ''],
], true);
$where['qid'] = $qid;
return app('json')->success($this->qrcodeRecordServices->qrcodeStatistic($where, $time));
}
}

View File

@ -0,0 +1,64 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\adminapi\controller\v1\application\wechat;
use app\adminapi\controller\AuthController;
use app\jobs\notice\SyncMessageJob;
use app\services\message\SystemNotificationServices;
use crmeb\exceptions\AdminException;
use crmeb\services\app\WechatService;
use think\facade\App;
/**
* 微信模板消息
* Class WechatTemplate
* @package app\adminapi\controller\v1\application\wechat
*/
class WechatTemplate extends AuthController
{
/**
* 构造方法
* WechatTemplate constructor.
* @param App $app
* @param SystemNotificationServices $services
*/
public function __construct(App $app, SystemNotificationServices $services)
{
parent::__construct($app);
$this->services = $services;
}
/**
* 同步微信模版消息
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function syncSubscribe()
{
if (!sys_config('wechat_appid') || !sys_config('wechat_appsecret')) {
throw new AdminException(400248);
}
$tempIds = $this->services->getTempId('wechat');
foreach ($tempIds as $v) {
WechatService::deleleTemplate($v);
}
$tempKeys = $this->services->getTempKey('wechat');
foreach ($tempKeys as $key => $content) {
SyncMessageJob::dispatch('SyncWechat', [$key, $content['wechat_content']]);
}
return app('json')->success(100038);
}
}

View File

@ -0,0 +1,175 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\adminapi\controller\v1\caseinfo;
use app\adminapi\controller\AuthController;
use app\services\caseinfo\CaseCategoryServices;
use crmeb\services\CacheService;
use think\facade\App;
/**
* 文章分类管理
* Class CaseCategory
* @package app\adminapi\controller\v1\cms
*/
class CaseCategory extends AuthController
{
/**
* @var CaseCategoryServices
*/
protected $service;
/**
* CaseCategory constructor.
* @param App $app
* @param CaseCategoryServices $service
*/
public function __construct(App $app, CaseCategoryServices $service)
{
parent::__construct($app);
$this->service = $service;
}
/**
* 获取分类列表
* @return mixed
*/
public function index()
{
$where = $this->request->getMore([
['status', ''],
['title', ''],
['type', 0]
]);
$type = $where['type'];
unset($where['type']);
$data = $this->service->getList($where);
if ($type == 1) $data = $data['list'];
return app('json')->success($data);
}
/**
* 创建新增表单
* @return mixed
* @throws \FormBuilder\Exception\FormBuilderException
*/
public function create()
{
return app('json')->success($this->service->createForm(0));
}
/**
* 保存新建分类
* @return mixed
* @throws \Psr\SimpleCache\InvalidArgumentException
*/
public function save()
{
$data = $this->request->postMore([
['title', ''],
['pid', 0],
['intr', ''],
['image', ''],
['sort', 0],
['status', 0]
]);
if (!$data['title']) {
return app('json')->fail(400100);
}
$data['add_time'] = time();
$this->service->save($data);
CacheService::delete('ARTICLE_CATEGORY');
return app('json')->success(100021);
}
/**
* 创建修改表单
* @param int $id
* @return mixed
* @throws \FormBuilder\Exception\FormBuilderException
*/
public function edit($id = 0)
{
if (!$id) return app('json')->fail(100100);
return app('json')->success($this->service->createForm($id));
}
/**
* 保存修改分类
* @param $id
* @return mixed
* @throws \Psr\SimpleCache\InvalidArgumentException
*/
public function update($id)
{
$data = $this->request->postMore([
['id', 0],
['title', ''],
['pid', 0],
['intr', ''],
['image', ''],
['sort', 0],
['status', 0]
]);
$this->service->update($data);
CacheService::delete('ARTICLE_CATEGORY');
return app('json')->success(100001);
}
/**
* 删除文章分类
* @param $id
* @return mixed
* @throws \Psr\SimpleCache\InvalidArgumentException
*/
public function delete($id)
{
if (!$id) return app('json')->fail(100100);
$this->service->del($id);
CacheService::delete('ARTICLE_CATEGORY');
return app('json')->success(100002);
}
/**
* 修改文章分类状态
* @param int $id
* @param int $status
* @return mixed
* @throws \Psr\SimpleCache\InvalidArgumentException
*/
public function set_status($id, $status)
{
if ($status == '' || $id == 0) return app('json')->fail(100100);
$this->service->setStatus($id, $status);
CacheService::delete('ARTICLE_CATEGORY');
return app('json')->success(100014);
}
/**
* 获取文章分类
* @return mixed
*/
public function categoryList()
{
return app('json')->success($this->service->getArticleTwoCategory());
}
/**
* 树形列表
* @return mixed
* @throws \ReflectionException
*/
public function getTreeList()
{
$list = $this->service->getTreeList();
return app('json')->success($list);
}
}

View File

@ -0,0 +1,138 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\adminapi\controller\v1\caseinfo;
use app\adminapi\controller\AuthController;
use app\services\caseinfo\CaseServices;
use think\facade\App;
/**
* 文章管理
* Class Caseinfo
* @package app\adminapi\controller\v1\cms
*/
class Caseinfo extends AuthController
{
/**
* @var CaseServices
*/
protected $service;
/**
* Caseinfo constructor.
* @param App $app
* @param CaseServices $service
*/
public function __construct(App $app, CaseServices $service)
{
parent::__construct($app);
$this->service = $service;
}
/**
* 获取列表
* @return mixed
*/
public function index()
{
$where = $this->request->getMore([
['title', ''],
['pid', 0, '', 'cid'],
]);
$data = $this->service->getList($where);
return app('json')->success($data);
}
/**
* 保存文章数据
* @return mixed
*/
public function save()
{
$data = $this->request->postMore([
['id', 0],
['cid', ''],
['title', ''],
['author', ''],
['image_input', ''],
['content', ''],
['synopsis', 0],
['share_title', ''],
['share_synopsis', ''],
['sort', 0],
['url', ''],
['is_banner', 0],
['is_hot', 0],
['status', 1]
]);
$this->service->save($data);
return app('json')->success(100021);
}
/**
* 获取单个文章数据
* @param int $id
* @return mixed
*/
public function read($id = 0)
{
if (!$id) return app('json')->fail(100100);
$info = $this->service->read($id);
return app('json')->success($info);
}
/**
* 删除文章
* @param int $id
* @return mixed
*/
public function delete($id = 0)
{
if (!$id) return app('json')->fail(100100);
$this->service->del($id);
return app('json')->success(100002);
}
/**
* 文章关联商品
* @param int $id
* @return mixed
*/
public function relation($id)
{
if (!$id) return app('json')->fail(100100);
list($product_id) = $this->request->postMore([
['product_id', 0]
], true);
$res = $this->service->bindProduct($id, $product_id);
if ($res) {
return app('json')->success(400300);
} else {
return app('json')->fail(400301);
}
}
/**
* 取消商品关联
* @param int $id
* @return mixed
*/
public function unrelation($id)
{
if (!$id) return app('json')->fail(100100);
$res = $this->service->bindProduct($id);
if ($res) {
return app('json')->success(100019);
} else {
return app('json')->fail(100020);
}
}
}

View File

@ -0,0 +1,138 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\adminapi\controller\v1\cms;
use app\adminapi\controller\AuthController;
use app\services\article\CaseServices;
use think\facade\App;
/**
* 文章管理
* Class Caseinfo
* @package app\adminapi\controller\v1\cms
*/
class Article extends AuthController
{
/**
* @var CaseServices
*/
protected $service;
/**
* Caseinfo constructor.
* @param App $app
* @param CaseServices $service
*/
public function __construct(App $app, CaseServices $service)
{
parent::__construct($app);
$this->service = $service;
}
/**
* 获取列表
* @return mixed
*/
public function index()
{
$where = $this->request->getMore([
['title', ''],
['pid', 0, '', 'cid'],
]);
$data = $this->service->getList($where);
return app('json')->success($data);
}
/**
* 保存文章数据
* @return mixed
*/
public function save()
{
$data = $this->request->postMore([
['id', 0],
['cid', ''],
['title', ''],
['author', ''],
['image_input', ''],
['content', ''],
['synopsis', 0],
['share_title', ''],
['share_synopsis', ''],
['sort', 0],
['url', ''],
['is_banner', 0],
['is_hot', 0],
['status', 1]
]);
$this->service->save($data);
return app('json')->success(100021);
}
/**
* 获取单个文章数据
* @param int $id
* @return mixed
*/
public function read($id = 0)
{
if (!$id) return app('json')->fail(100100);
$info = $this->service->read($id);
return app('json')->success($info);
}
/**
* 删除文章
* @param int $id
* @return mixed
*/
public function delete($id = 0)
{
if (!$id) return app('json')->fail(100100);
$this->service->del($id);
return app('json')->success(100002);
}
/**
* 文章关联商品
* @param int $id
* @return mixed
*/
public function relation($id)
{
if (!$id) return app('json')->fail(100100);
list($product_id) = $this->request->postMore([
['product_id', 0]
], true);
$res = $this->service->bindProduct($id, $product_id);
if ($res) {
return app('json')->success(400300);
} else {
return app('json')->fail(400301);
}
}
/**
* 取消商品关联
* @param int $id
* @return mixed
*/
public function unrelation($id)
{
if (!$id) return app('json')->fail(100100);
$res = $this->service->bindProduct($id);
if ($res) {
return app('json')->success(100019);
} else {
return app('json')->fail(100020);
}
}
}

View File

@ -0,0 +1,175 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\adminapi\controller\v1\cms;
use app\adminapi\controller\AuthController;
use app\services\article\CaseCategoryServices;
use crmeb\services\CacheService;
use think\facade\App;
/**
* 文章分类管理
* Class CaseCategory
* @package app\adminapi\controller\v1\cms
*/
class ArticleCategory extends AuthController
{
/**
* @var CaseCategoryServices
*/
protected $service;
/**
* CaseCategory constructor.
* @param App $app
* @param CaseCategoryServices $service
*/
public function __construct(App $app, CaseCategoryServices $service)
{
parent::__construct($app);
$this->service = $service;
}
/**
* 获取分类列表
* @return mixed
*/
public function index()
{
$where = $this->request->getMore([
['status', ''],
['title', ''],
['type', 0]
]);
$type = $where['type'];
unset($where['type']);
$data = $this->service->getList($where);
if ($type == 1) $data = $data['list'];
return app('json')->success($data);
}
/**
* 创建新增表单
* @return mixed
* @throws \FormBuilder\Exception\FormBuilderException
*/
public function create()
{
return app('json')->success($this->service->createForm(0));
}
/**
* 保存新建分类
* @return mixed
* @throws \Psr\SimpleCache\InvalidArgumentException
*/
public function save()
{
$data = $this->request->postMore([
['title', ''],
['pid', 0],
['intr', ''],
['image', ''],
['sort', 0],
['status', 0]
]);
if (!$data['title']) {
return app('json')->fail(400100);
}
$data['add_time'] = time();
$this->service->save($data);
CacheService::delete('ARTICLE_CATEGORY');
return app('json')->success(100021);
}
/**
* 创建修改表单
* @param int $id
* @return mixed
* @throws \FormBuilder\Exception\FormBuilderException
*/
public function edit($id = 0)
{
if (!$id) return app('json')->fail(100100);
return app('json')->success($this->service->createForm($id));
}
/**
* 保存修改分类
* @param $id
* @return mixed
* @throws \Psr\SimpleCache\InvalidArgumentException
*/
public function update($id)
{
$data = $this->request->postMore([
['id', 0],
['title', ''],
['pid', 0],
['intr', ''],
['image', ''],
['sort', 0],
['status', 0]
]);
$this->service->update($data);
CacheService::delete('ARTICLE_CATEGORY');
return app('json')->success(100001);
}
/**
* 删除文章分类
* @param $id
* @return mixed
* @throws \Psr\SimpleCache\InvalidArgumentException
*/
public function delete($id)
{
if (!$id) return app('json')->fail(100100);
$this->service->del($id);
CacheService::delete('ARTICLE_CATEGORY');
return app('json')->success(100002);
}
/**
* 修改文章分类状态
* @param int $id
* @param int $status
* @return mixed
* @throws \Psr\SimpleCache\InvalidArgumentException
*/
public function set_status($id, $status)
{
if ($status == '' || $id == 0) return app('json')->fail(100100);
$this->service->setStatus($id, $status);
CacheService::delete('ARTICLE_CATEGORY');
return app('json')->success(100014);
}
/**
* 获取文章分类
* @return mixed
*/
public function categoryList()
{
return app('json')->success($this->service->getArticleTwoCategory());
}
/**
* 树形列表
* @return mixed
* @throws \ReflectionException
*/
public function getTreeList()
{
$list = $this->service->getTreeList();
return app('json')->success($list);
}
}

View File

@ -0,0 +1,458 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\adminapi\controller\v1\export;
use app\adminapi\controller\AuthController;
use app\services\agent\AgentManageServices;
use app\services\other\export\ExportServices;
use app\services\order\StoreOrderServices;
use app\services\product\product\StoreProductServices;
use app\services\system\store\SystemStoreServices;
use app\services\user\member\MemberCardServices;
use app\services\user\UserBillServices;
use app\services\user\UserRechargeServices;
use app\services\wechat\WechatUserServices;
use think\facade\App;
/**
* 导出excel类
* Class ExportExcel
* @package app\adminapi\controller\v1\export
*/
class ExportExcel extends AuthController
{
/**
* @var ExportServices
*/
protected $service;
/**
* ExportExcel constructor.
* @param App $app
* @param ExportServices $services
*/
public function __construct(App $app, ExportServices $services)
{
parent::__construct($app);
$this->service = $services;
}
public function userList()
{
$where = $this->request->getMore([
['page', 1],
['limit', 20],
['nickname', ''],
['status', ''],
['pay_count', ''],
['is_promoter', ''],
['order', ''],
['data', ''],
['user_type', ''],
['country', ''],
['province', ''],
['city', ''],
['user_time_type', ''],
['user_time', ''],
['sex', ''],
[['level', 0], 0],
[['group_id', 'd'], 0],
['label_id', ''],
['now_money', 'normal'],
['field_key', ''],
['isMember', ''],
['ids', []]
]);
return app('json')->success($this->service->exportUserList($where));
}
/**
* 订单导出
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function orderList()
{
$where = $this->request->getMore([
['status', ''],
['real_name', ''],
['is_del', ''],
['data', '', '', 'time'],
['type', ''],
['pay_type', ''],
['order', ''],
['field_key', ''],
['ids', []],
]);
$where['is_system_del'] = 0;
$where['pid'] = 0;
return app('json')->success($this->service->exportOrderList($where));
}
/**
* 发货订单列表导出
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function orderDeliveryList()
{
return app('json')->success($this->service->exportOrderDeliveryList());
}
/**
* 商品列表导出
* @return mixed
*/
public function productList()
{
$where = $this->request->getMore([
['store_name', ''],
['cate_id', ''],
['type', 1],
['ids', []]
]);
return app('json')->success($this->service->exportProductList($where));
}
/**
* 砍价商品列表导出
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function bargainList()
{
$where = $this->request->getMore([
['status', ''],
['store_name', ''],
]);
$where['is_del'] = 0;
return app('json')->success($this->service->exportBargainList($where));
}
/**
* 拼团商品导出
* @return mixed
*/
public function combinationList()
{
$where = $this->request->getMore([
['is_show', ''],
['store_name', '']
]);
$where['is_del'] = 0;
return app('json')->success($this->service->exportCombinationList($where));
}
/**
* 秒杀商品导出
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function seckillList()
{
$where = $this->request->getMore([
[['status', 's'], ''],
[['store_name', 's'], '']
]);
return app('json')->success($this->service->exportSeckillList($where));
}
/**
* 会员卡导出
* @param $id
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function memberCardList($id)
{
return app('json')->success($this->service->exportMemberCard($id));
}
/**
* 保存用户资金监控的excel表格
* @param UserBillServices $services
* @return mixed
*/
public function userFinance(UserBillServices $services)
{
$where = $this->request->getMore([
['start_time', ''],
['end_time', ''],
['nickname', ''],
['type', ''],
]);
$data = $services->getBillList($where, '*', false);
return app('json')->success($this->service->userFinance($data['data'] ?? []));
}
/**
* 用户佣金
* @param UserBillServices $services
* @return mixed
*/
public function userCommission(UserBillServices $services)
{
$where = $this->request->getMore([
['page', 1],
['limit', 20],
['nickname', ''],
['price_max', ''],
['price_min', ''],
['excel', '1'],
['time', ''],
]);
$data = $services->getCommissionList($where, false);
return app('json')->success($this->service->userCommission($data['list'] ?? []));
}
/**
* 用户积分
* @param UserBillServices $services
* @return mixed
*/
public function userPoint(UserBillServices $services)
{
$where = $this->request->getMore([
['start_time', ''],
['end_time', ''],
['nickname', ''],
['excel', '1'],
]);
$data = $services->getPointList($where, '*', false);
return app('json')->success($this->service->userPoint($data['list'] ?? []));
}
/**
* 用户充值
* @param UserRechargeServices $services
* @return mixed
*/
public function userRecharge(UserRechargeServices $services)
{
$where = $this->request->getMore([
['data', ''],
['paid', ''],
['page', 1],
['limit', 20],
['nickname', ''],
['excel', '1'],
]);
$data = $services->getRechargeList($where, '*', false);
return app('json')->success($this->service->userRecharge($data['list'] ?? []));
}
/**
* 分销管理 用户推广
* @param AgentManageServices $services
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function userAgent(AgentManageServices $services)
{
$where = $this->request->getMore([
['nickname', ''],
['data', ''],
['excel', '1'],
]);
$data = $services->agentSystemPage($where, false);
return app('json')->success($this->service->userAgent($data['list']));
}
/**
* 微信用户导出(弃用)
* @param WechatUserServices $services
* @return mixed
*/
public function wechatUser(WechatUserServices $services)
{
$where = $this->request->getMore([
['page', 1],
['limit', 20],
['nickname', ''],
['data', ''],
['tagid_list', ''],
['groupid', '-1'],
['sex', ''],
['export', '1'],
['subscribe', '']
]);
$tagidList = explode(',', $where['tagid_list']);
foreach ($tagidList as $k => $v) {
if (!$v) {
unset($tagidList[$k]);
}
}
$tagidList = array_unique($tagidList);
$where['tagid_list'] = implode(',', $tagidList);
$data = $services->exportData($where);
return app('json')->success($this->service->wechatUser($data));
}
/**
* 商铺砍价活动导出
* @param StoreBargainServices $services
* @return mixed
*/
public function storeBargain(StoreBargainServices $services)
{
$where = $this->request->getMore([
['start_status', ''],
['status', ''],
['store_name', ''],
]);
$data = $services->getList($where);
return app('json')->success($this->service->storeBargain($data));
}
/**
* 拼团导出
* @param StoreCombinationServices $services
* @return mixed
*/
public function storeCombination(StoreCombinationServices $services)
{
$where = $this->request->getMore([
['start_status', ''],
['is_show', ''],
['store_name', ''],
]);
$data = $services->getList($where);
/** @var StorePinkServices $storePinkServices */
$storePinkServices = app()->make(StorePinkServices::class);
$countAll = $storePinkServices->getPinkCount([]);
$countTeam = $storePinkServices->getPinkCount(['k_id' => 0, 'status' => 2]);
$countPeople = $storePinkServices->getPinkCount(['k_id' => 0]);
foreach ($data as &$item) {
$item['count_people'] = $countPeople[$item['id']] ?? 0;//拼团数量
$item['count_people_all'] = $countAll[$item['id']] ?? 0;//参与人数
$item['count_people_pink'] = $countTeam[$item['id']] ?? 0;//成团数量
$item['stop_status'] = $item['stop_time'] < time() ? 1 : 0;
if ($item['is_show']) {
if ($item['start_time'] > time())
$item['start_name'] = '未开始';
else if ($item['stop_time'] < time())
$item['start_name'] = '已结束';
else if ($item['stop_time'] > time() && $item['start_time'] < time()) {
$item['start_name'] = '进行中';
}
} else $item['start_name'] = '已结束';
}
return app('json')->success($this->service->storeCombination($data));
}
/**
* 秒杀导出
* @param StoreSeckillServices $services
* @return mixed
*/
public function storeSeckill(StoreSeckillServices $services)
{
$where = $this->request->getMore([
['start_status', ''],
['status', ''],
['store_name', '']
]);
$data = $services->getList($where);
return app('json')->success($this->service->storeSeckill($data));
}
/**
* 商品导出
* @param StoreProductServices $services
* @return mixed
*/
public function storeProduct(StoreProductServices $services)
{
$where = $this->request->getMore([
['store_name', ''],
['cate_id', ''],
['type', 1]
]);
$data = $services->searchList($where, true, false);
return app('json')->success($this->service->storeProduct($data['list'] ?? []));
}
/**
* 订单列表导出
* @param StoreOrderServices $services
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function storeOrder(StoreOrderServices $services)
{
$where = $this->request->getMore([
['status', ''],
['real_name', ''],
['data', '', '', 'time']
]);
$where['pid'] = 0;
$ids = $this->request->get('ids');
if ($ids) {
$idsArr = array_filter(explode(',', $ids));
if ($idsArr) {
$where['id'] = $idsArr;
}
}
$data = $services->getExportList($where);
return app('json')->success($this->service->storeOrder($data));
}
/**
* 获取提货点
* @param SystemStoreServices $services
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function storeMerchant(SystemStoreServices $services)
{
$where = $this->request->getMore([
[['keywords', 's'], ''],
[['type', 'd'], 0],
]);
$data = $services->getExportData($where);
return app('json')->success($this->service->storeMerchant($data));
}
/**
* 会员卡导出
* @param int $id
* @param MemberCardServices $services
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function memberCard(int $id, MemberCardServices $services)
{
$data = $services->getExportData(['batch_card_id' => $id]);
return app('json')->success($this->service->memberCard($data));
}
}

View File

@ -0,0 +1,202 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\adminapi\controller\v1\file;
use app\adminapi\controller\AuthController;
use app\services\system\attachment\SystemAttachmentServices;
use crmeb\services\CacheService;
use think\facade\App;
/**
* 附件管理类
* Class SystemAttachment
* @package app\adminapi\controller\v1\file
*/
class SystemAttachment extends AuthController
{
/**
* @var SystemAttachmentServices
*/
protected $service;
/**
* @param App $app
* @param SystemAttachmentServices $service
*/
public function __construct(App $app, SystemAttachmentServices $service)
{
parent::__construct($app);
$this->service = $service;
}
/**
* 显示列表
* @return mixed
*/
public function index()
{
$where = $this->request->getMore([
['pid', 0],
['real_name', '']
]);
return app('json')->success($this->service->getImageList($where));
}
/**
* 删除指定资源
* @return mixed
*/
public function delete()
{
[$ids] = $this->request->postMore([
['ids', '']
], true);
$this->service->del($ids);
return app('json')->success(100002);
}
/**
* 图片上传
* @param int $upload_type
* @param int $type
* @return mixed
*/
public function upload($upload_type = 0, $type = 0)
{
[$pid, $file, $menuName] = $this->request->postMore([
['pid', 0],
['file', 'file'],
['menu_name', '']
], true);
$res = $this->service->upload((int)$pid, $file, $upload_type, $type, $menuName);
return app('json')->success(100032, ['src' => $res]);
}
/**
* 移动图片
* @return mixed
*/
public function moveImageCate()
{
$data = $this->request->postMore([
['pid', 0],
['images', '']
]);
$this->service->move($data);
return app('json')->success(100034);
}
/**
* 修改文件名
* @param $id
* @return mixed
*/
public function update($id)
{
$realName = $this->request->post('real_name', '');
if (!$realName) {
return app('json')->fail(400104);
}
$this->service->update($id, ['real_name' => $realName]);
return app('json')->success(100001);
}
/**
* 获取上传类型
* @return mixed
*/
public function uploadType()
{
$data['upload_type'] = (string)sys_config('upload_type', 1);
return app('json')->success($data);
}
/**
* 视频分片上传
* @return mixed
*/
public function videoUpload()
{
$data = $this->request->postMore([
['chunkNumber', 0],//第几分片
['currentChunkSize', 0],//分片大小
['chunkSize', 0],//总大小
['totalChunks', 0],//分片总数
['file', 'file'],//文件
['md5', ''],//MD5
['filename', ''],//文件名称
]);
$res = $this->service->videoUpload($data, $_FILES['file']);
return app('json')->success($res);
}
/**
* 获取扫码上传页面链接以及参数
* @return \think\Response
* @author 吴汐
* @email 442384644@qq.com
* @date 2023/06/13
*/
public function scanUploadQrcode()
{
[$pid] = $this->request->getMore([
['pid', 0]
], true);
$uploadToken = md5(time());
CacheService::set('scan_upload', $uploadToken, 600);
$url = sys_config('site_url') . '/app/upload?pid=' . $pid . '&token=' . $uploadToken;
return app('json')->success(['url' => $url]);
}
/**
* 删除二维码
* @return \think\Response
* @author 等风来
* @email 136327134@qq.com
* @date 2023/6/26
*/
public function removeUploadQrcode()
{
CacheService::delete('scan_upload');
return app('json')->success();
}
/**
* 获取扫码上传的图片数据
* @param $scan_token
* @return \think\Response
* @author 吴汐
* @email 442384644@qq.com
* @date 2023/06/13
*/
public function scanUploadImage($scan_token)
{
return app('json')->success($this->service->scanUploadImage($scan_token));
}
/**
* 网络图片上传
* @return \think\Response
* @throws \Exception
* @author 吴汐
* @email 442384644@qq.com
* @date 2023/06/13
*/
public function onlineUpload()
{
$data = $this->request->postMore([
['pid', 0],
['images', []]
]);
$this->service->onlineUpload($data);
return app('json')->success(100032);
}
}

View File

@ -0,0 +1,132 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\adminapi\controller\v1\file;
use app\adminapi\controller\AuthController;
use app\services\system\attachment\SystemAttachmentCategoryServices;
use think\facade\App;
/**
* 图片分类管理类
* Class SystemAttachmentCategory
* @package app\adminapi\controller\v1\file
*/
class SystemAttachmentCategory extends AuthController
{
/**
* @var SystemAttachmentCategoryServices
*/
protected $service;
/**
* @param App $app
* @param SystemAttachmentCategoryServices $service
*/
public function __construct(App $app, SystemAttachmentCategoryServices $service)
{
parent::__construct($app);
$this->service = $service;
}
/**
* 显示资源列表
* @return \think\Response
* @throws \ReflectionException
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function index()
{
$where = $this->request->getMore([
['name', ''],
['pid', 0],
['all', 0]
]);
if ($where['name'] != '' || $where['all'] == 1) $where['pid'] = '';
return app('json')->success($this->service->getAll($where));
}
/**
* 新增表单
* @return mixed
* @throws \FormBuilder\Exception\FormBuilderException
*/
public function create($id)
{
return app('json')->success($this->service->createForm($id));
}
/**
* 保存新增
* @return mixed
*/
public function save()
{
$data = $this->request->postMore([
['pid', 0],
['name', '']
]);
if (is_array($data['pid'])) $data['pid'] = end($data['pid']);
if (!$data['name']) {
return app('json')->fail(400100);
}
$this->service->save($data);
return app('json')->success(100021);
}
/**
* 编辑表单
* @param $id
* @return mixed
* @throws \FormBuilder\Exception\FormBuilderException
*/
public function edit($id)
{
return app('json')->success($this->service->editForm($id));
}
/**
* 保存更新的资源
* @param $id
* @return mixed
*/
public function update($id)
{
$data = $this->request->postMore([
['pid', 0],
['name', '']
]);
if (is_array($data['pid'])) $data['pid'] = end($data['pid']);
if (!$data['name']) {
return app('json')->fail(400100);
}
if ($data['pid'] == $id) {
return app('json')->fail('上级分类不能是自己');
}
$info = $this->service->get($id);
$count = $this->service->count(['pid' => $id]);
if ($count && $info['pid'] != $data['pid']) return app('json')->fail(400105);
$this->service->update($id, $data);
return app('json')->success(100001);
}
/**
* 删除指定资源
* @param int $id
* @return \think\Response
*/
public function delete($id)
{
$this->service->del($id);
return app('json')->success(100002);
}
}

View File

@ -0,0 +1,174 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\adminapi\controller\v1\freight;
use app\adminapi\controller\AuthController;
use app\services\shipping\ExpressServices;
use think\facade\App;
/**
* 物流
* Class Express
* @package app\adminapi\controller\v1\freight
*/
class Express extends AuthController
{
/**
* 构造方法
* Express constructor.
* @param App $app
* @param ExpressServices $services
*/
public function __construct(App $app, ExpressServices $services)
{
parent::__construct($app);
$this->services = $services;
}
/**
* 获取物流列表
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function index()
{
$where = $this->request->getMore([
['keyword', ''],
['is_show', '']
]);
return app('json')->success($this->services->getExpressList($where));
}
/**
* 显示创建资源表单页
* @return mixed
* @throws \FormBuilder\Exception\FormBuilderException
*/
public function create()
{
return app('json')->success($this->services->createForm());
}
/**
* 保存新建的资源
* @return \think\Response
*/
public function save()
{
$data = $this->request->postMore([
'name',
'code',
['sort', 0],
['is_show', 0]]);
if (!$data['name']) return app('json')->fail(400400);
$this->services->save($data);
return app('json')->success(400401);
}
/**
* 显示编辑资源表单页
* @param $id
* @return mixed
* @throws \FormBuilder\Exception\FormBuilderException
*/
public function edit($id)
{
return app('json')->success($this->services->updateForm((int)$id));
}
/**
* 保存更新的资源
* @param $id
* @return mixed
*/
public function update($id)
{
$data = $this->request->postMore([
['account', ''],
['key', ''],
['net_name', ''],
['courier_name', ''],
['customer_name', ''],
['code_name', ''],
['sort', 0],
['is_show', 0]]);
if (!$expressInfo = $this->services->get($id)) return app('json')->fail(100026);
if ($expressInfo['partner_id'] == 1 && !$data['account']) {
return app('json')->fail(400402);
}
if ($expressInfo['partner_key'] == 1 && !$data['key']) {
return app('json')->fail(400403);
}
if ($expressInfo['net'] == 1 && !$data['net_name']) {
return app('json')->fail(400404);
}
if ($expressInfo['check_man'] == 1 && !$data['courier_name']) {
return app('json')->fail(500001);
}
if ($expressInfo['partner_name'] == 1 && !$data['customer_name']) {
return app('json')->fail(500002);
}
if ($expressInfo['is_code'] == 1 && !$data['code_name']) {
return app('json')->fail(500003);
}
$expressInfo->account = $data['account'];
$expressInfo->key = $data['key'];
$expressInfo->net_name = $data['net_name'];
$expressInfo->courier_name = $data['courier_name'];
$expressInfo->customer_name = $data['customer_name'];
$expressInfo->code_name = $data['code_name'];
$expressInfo->sort = $data['sort'];
$expressInfo->is_show = $data['is_show'];
$expressInfo->status = 1;
$expressInfo->save();
return app('json')->success(100001);
}
/**
* 删除指定资源
* @param $id
* @return mixed
*/
public function delete($id)
{
if (!$id) return app('json')->fail(100100);
$res = $this->services->delete($id);
if (!$res)
return app('json')->fail(100008);
else
return app('json')->success(100002);
}
/**
* 修改状态
* @param int $id
* @param string $status
* @return mixed
*/
public function set_status($id = 0, $status = '')
{
if ($status == '' || $id == 0) return app('json')->fail(100100);
$this->services->update($id, ['is_show' => $status]);
return app('json')->success(100014);
}
/**
* 同步平台快递公司
* @return mixed
*/
public function syncExpress()
{
$this->services->syncExpress();
return app('json')->success(100038);
}
}

View File

@ -0,0 +1,76 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\adminapi\controller\v1\notification\sms;
use app\adminapi\controller\AuthController;
use app\services\yihaotong\SmsAdminServices;
use think\facade\App;
/**
* 短信账号
* Class SmsAdmin
* @package app\adminapi\controller\v1\sms
*/
class SmsAdmin extends AuthController
{
/**
* 构造方法
* SmsAdmin constructor.
* @param App $app
* @param SmsAdminServices $services
*/
public function __construct(App $app, SmsAdminServices $services)
{
parent::__construct($app);
$this->services = $services;
}
/**
* 发送验证码
* @return mixed
*/
public function captcha()
{
if (!request()->isPost()) {
return app('json')->fail(100031);
}
$phone = request()->param('phone');
if (!trim($phone)) {
return app('json')->fail(400132);
}
return app('json')->success($this->services->captcha($phone));
}
/**
* 修改/注册短信平台账号
* @return mixed
*/
public function save()
{
[$account, $password, $phone, $code, $url, $sign] = $this->request->postMore([
['account', ''],
['password', ''],
['phone', ''],
['code', ''],
['url', ''],
['sign', ''],
], true);
$signLen = mb_strlen(trim($sign));
if (!strlen(trim($account))) return app('json')->fail(400133);
if (!strlen(trim($password))) return app('json')->fail(400134);
if (!$signLen) return app('json')->fail(400135);
if ($signLen > 8) return app('json')->fail(400136);
if (!strlen(trim($code))) return app('json')->fail(400137);
if (!strlen(trim($url))) return app('json')->fail(400138);
$status = $this->services->register($account, $password, $url, $phone, $code, $sign);
return app('json')->success($status['msg']);
}
}

View File

@ -0,0 +1,137 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\adminapi\controller\v1\notification\sms;
use app\services\system\config\SystemConfigServices;
use app\services\yihaotong\SmsAdminServices;
use app\services\serve\ServeServices;
use app\adminapi\controller\AuthController;
use crmeb\services\CacheService;
use think\facade\App;
/**
* 短信配置
* Class SmsConfig
* @package app\admin\controller\sms
*/
class SmsConfig extends AuthController
{
/**
* 构造方法
* SmsConfig constructor.
* @param App $app
* @param SmsAdminServices $services
*/
public function __construct(App $app, SmsAdminServices $services)
{
parent::__construct($app);
$this->services = $services;
}
/**
* 保存短信配置
* @return mixed
* @throws \Psr\SimpleCache\InvalidArgumentException
*/
public function save_basics()
{
[$account, $token] = $this->request->postMore([
['sms_account', ''],
['sms_token', '']
], true);
$this->validate(['sms_account' => $account, 'sms_token' => $token], \app\adminapi\validate\notification\SmsConfigValidate::class);
if ($this->services->login($account, $token)) {
return app('json')->success(400139);
} else {
return app('json')->fail(400140);
}
}
/**
* 检测登录
* @param ServeServices $services
* @return mixed
* @throws \Psr\SimpleCache\InvalidArgumentException
*/
public function is_login(ServeServices $services)
{
$configServices = app()->make(SystemConfigServices::class);
$sms_info = CacheService::get('sms_account');
$data = ['status' => false, 'info' => ''];
if ($sms_info) {
try {
$result = $services->user()->getUser();
} catch (\Throwable $e) {
$result = [];
}
if (!$result) {
$this->logout();
} else {
$data['status'] = true;
$data['info'] = $sms_info;
}
return app('json')->success($data);
} else {
CacheService::clear();
$account = sys_config('sms_account');
$password = sys_config('sms_token');
//没有退出登录 清空这两个数据 自动登录
if ($account && $password) {
$res = $services->user()->login($account, $password);
if ($res) {
CacheService::set('sms_account', $account);
$data['status'] = true;
$data['info'] = $account;
}
}
}
return app('json')->success($data);
}
/**
* 退出
* @return mixed
* @throws \Psr\SimpleCache\InvalidArgumentException
*/
public function logout()
{
CacheService::delete('sms_account');
$this->services->updateSmsConfig('', '');
CacheService::clear();
return app('json')->success(100042);
}
/**
* 短信发送记录
* @param ServeServices $services
* @return mixed
*/
public function record(ServeServices $services)
{
[$page, $limit, $status] = $this->request->getMore([
[['page', 'd'], 0],
[['limit', 'd'], 10],
['type', '', '', 'status'],
], true);
return app('json')->success($services->user()->record($page, $limit, 1, $status));
}
/**
* 获取当前登陆的短信账号信息
* @return mixed
*/
public function data()
{
return app('json')->success($this->services->getSmsData());
}
}

View File

@ -0,0 +1,88 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\adminapi\controller\v1\notification\sms;
use app\adminapi\controller\AuthController;
use crmeb\services\{sms\Sms};
/**
* 短信购买
* Class SmsPay
* @package app\admin\controller\sms
*/
class SmsPay extends AuthController
{
/**
* @var Sms
*/
protected $smsHandle;
/**
* @return mixed|void
*/
public function initialize()
{
parent::initialize(); // TODO: Change the autogenerated stub
$this->smsHandle = new Sms('yihaotong', [
'sms_account' => sys_config('sms_account'),
'sms_token' => sys_config('sms_token'),
'site_url' => sys_config('site_url')
]);
if (!$this->smsHandle->isLogin()) {
return app('json')->fail(400141);
}
}
/**
* 获取账号信息
* @return mixed
*/
public function number()
{
$countInfo = $this->smsHandle->count();
if ($countInfo['status'] == 400) return app('json')->fail($countInfo['msg']);
$info['account'] = sys_config('sms_account');
$info['number'] = $countInfo['data']['number'];
$info['send_total'] = $countInfo['data']['send_total'];
return app('json')->success($info);
}
/**
* 获取支付套餐
* @return mixed
*/
public function price()
{
list($page, $limit) = $this->request->getMore([
['page', 1],
['limit', 20],
], true);
$mealInfo = $this->smsHandle->meal($page, $limit);
if ($mealInfo['status'] == 400) return app('json')->fail($mealInfo['msg']);
return app('json')->success($mealInfo['data']);
}
/**
* 获取支付码
* @return mixed
*/
public function pay()
{
list($payType, $mealId, $price) = $this->request->postMore([
['payType', 'weixin'],
['mealId', 0],
['price', 0],
], true);
$payInfo = $this->smsHandle->pay($payType, $mealId, $price, $this->adminId);
if ($payInfo['status'] == 400) return app('json')->fail($payInfo['msg']);
return app('json')->success($payInfo['data']);
}
}

View File

@ -0,0 +1,77 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\adminapi\controller\v1\notification\sms;
use app\adminapi\controller\AuthController;
use crmeb\services\sms\Sms;
/**
* 公共短信模板
* Class SmsPublicTemp
* @package app\admin\controller\sms
*/
class SmsPublicTemp extends AuthController
{
/**
* @var Sms
*/
protected $smsHandle;
/**
* @return mixed|void
*/
public function initialize()
{
parent::initialize(); // TODO: Change the autogenerated stub
$this->smsHandle = new Sms('yihaotong', [
'sms_account' => sys_config('sms_account'),
'sms_token' => sys_config('sms_token'),
'site_url' => sys_config('site_url')
]);
if (!$this->smsHandle->isLogin()) {
return app('json')->fail(400141);
}
}
/**
* 异步获取公共模板列表
* @return mixed
*/
public function index()
{
$where = $this->request->getMore([
['is_have', ''],
['page', 1],
['limit', 20],
]);
$templateList = $this->smsHandle->publictemp($where);
if ($templateList['status'] == 400) return app('json')->fail($templateList['msg']);
$arr = $templateList['data']['data'];
foreach ($arr as $key => $value) {
switch ($value['type']) {
case 1:
$arr[$key]['type'] = '验证码';
break;
case 2:
$arr[$key]['type'] = '通知';
break;
case 3:
$arr[$key]['type'] = '推广';
break;
default:
$arr[$key]['type'] = '';
break;
}
}
$templateList['data']['data'] = $arr;
return app('json')->success($templateList['data']);
}
}

View File

@ -0,0 +1,97 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\adminapi\controller\v1\notification\sms;
use app\adminapi\controller\AuthController;
use app\services\serve\ServeServices;
use think\facade\App;
/**
* 短信模板申请
* Class SmsTemplateApply
* @package app\admin\controller\sms
*/
class SmsTemplateApply extends AuthController
{
/**
* @param App $app
* @param ServeServices $services
*/
public function __construct(App $app, ServeServices $services)
{
parent::__construct($app);
$this->services = $services;
}
/**
* 异步获取模板列表
* @return mixed
*/
public function index()
{
$where = $this->request->getMore([
[['type', 'd'], 0],
['status', ''],
['title', ''],
[['page', 'd'], 1],
[['limit', 'd'], 20],
]);
$where['temp_type'] = $where['type'];
$templateList = $this->services->sms()->temps($where['page'], $where['limit'], $where['type']);
$templateList['data'] = $templateList['data'] ?? [];
foreach ($templateList['data'] as $key => &$item) {
$item['templateid'] = $item['temp_id'];
switch ((int)$item['temp_type']) {
case 1:
$item['type'] = '验证码';
break;
case 2:
$item['type'] = '通知';
break;
case 30:
$item['type'] = '营销短信';
break;
}
}
return app('json')->success($templateList);
}
/**
* 显示创建资源表单页
* @return mixed
* @throws \FormBuilder\Exception\FormBuilderException
*/
public function create()
{
return app('json')->success($this->services->getSmsTemplateForm());
}
/**
* 保存新建的资源
* @return mixed
*/
public function save()
{
$data = $this->request->postMore([
['title', ''],
['content', ''],
['type', 0]
]);
if (!strlen(trim($data['title']))) {
return app('json')->fail(400142);
}
if (!strlen(trim($data['content']))) {
return app('json')->fail(400143);
}
$this->services->sms()->apply($data['title'], $data['content'], $data['type']);
return app('json')->success(100027);
}
}

View File

@ -0,0 +1,222 @@
<?php
/**
* +----------------------------------------------------------------------
* | CRMEB [ CRMEB赋能开发者助力企业发展 ]
* +----------------------------------------------------------------------
* | Copyright (c) 2016~2025 https://www.crmeb.com All rights reserved.
* +----------------------------------------------------------------------
* | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
* +----------------------------------------------------------------------
* | Author: CRMEB Team <admin@crmeb.com>
* +----------------------------------------------------------------------
*/
/**
* 公司历程
* @author crud自动生成代码
* @date 2025/02/21
*/
namespace app\adminapi\controller\v1\process;
use app\adminapi\controller\AuthController;
use think\facade\App;
use app\services\crud\ProcessServices;
/**
* Class Process
* @date 2025/02/21
* @package app\adminapi\controller\crud
*/
class Process extends AuthController
{
/**
* @var ProcessServices
*/
protected $service;
/**
* ProcessController constructor.
* @param App $app
* @param ProcessServices $service
*/
public function __construct(App $app, ProcessServices $service)
{
parent::__construct($app);
$this->service = $service;
}
/**
* 列表
* @date 2025/02/21
* @return \think\Response
*/
public function index()
{
$where = $this->request->getMore([
['title', ''],
['subtitle', ''],
['set_time', ''],
['content', ''],
['sort', ''],
['status', ''],
['add_time', ''],
['hide', ''],
]);
return app('json')->success($this->service->getCrudListIndex($where));
}
/**
* 创建
* @return \think\Response
* @date 2025/02/21
*/
public function create()
{
return app('json')->success($this->service->getCrudForm());
}
/**
* 保存
* @return \think\Response
* @date 2025/02/21
*/
public function save()
{
$data = $this->request->postMore([
['title', ''],
['image_input', ''],
['subtitle', ''],
['set_time', ''],
['content', ''],
['sort', ''],
['status', ''],
['add_time', ''],
['hide', ''],
]);
validate(\app\adminapi\validate\crud\ProcessValidate::class)->check($data);
$this->service->crudSave($data);
return app('json')->success(100021);
}
/**
* 编辑获取数据
* @param $id
* @return \think\Response
* @date 2025/02/21
*/
public function edit($id)
{
return app('json')->success($this->service->getCrudForm((int)$id));
}
/**
* 修改
* @param $id
* @return \think\Response
* @date 2025/02/21
*/
public function update($id)
{
if (!$id) {
return app('json')->fail(100100);
}
$data = $this->request->postMore([
['title', ''],
['image_input', ''],
['subtitle', ''],
['set_time', ''],
['content', ''],
['sort', ''],
['status', ''],
['add_time', ''],
['hide', ''],
]);
validate(\app\adminapi\validate\crud\ProcessValidate::class)->check($data);
$this->service->crudUpdate((int)$id, $data);
return app('json')->success(100001);
}
/**
* 修改状态
* @param $id
* @return \think\Response
* @date 2025/02/21
*/
public function status($id)
{
if (!$id) {
return app('json')->fail(100100);
}
$data = $this->request->postMore([
['field', ''],
['value', '']
]);
$filedAll = ['status'];
if (!in_array($data['field'], $filedAll)) {
return app('json')->fail(100100);
}
if ($this->service->update(['id'=> $id], [$data['field']=> $data['value']])) {
return app('json')->success(100001);
} else {
return app('json')->fail(100100);
}
}
/**
* 删除
* @param $id
* @return \think\Response
* @date 2025/02/21
*/
public function delete($id)
{
if (!$id) {
return app('json')->fail(100100);
}
if ($this->service->destroy((int)$id)) {
return app('json')->success(100002);
} else {
return app('json')->success(100008);
}
}
/**
* 查看
* @param $id
* @return \think\Response
* @date 2025/02/21
*/
public function read($id)
{
if (!$id) {
return app('json')->fail(100100);
}
$info = $this->service->get($id, ['*'], []);
if (!$info) {
return app('json')->fail(100100);
}
return app('json')->success($info->toArray());
}
}

View File

@ -0,0 +1,114 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\adminapi\controller\v1\product;
use app\adminapi\controller\AuthController;
use app\services\product\product\CopyTaobaoServices;
use app\services\serve\ServeServices;
use think\facade\App;
/**
* Class CopyTaobao
* @package app\adminapi\controller\v1\product
*/
class CopyTaobao extends AuthController
{
/**
* CopyTaobao constructor.
* @param App $app
* @param CopyTaobaoServices $services
*/
public function __construct(App $app, CopyTaobaoServices $services)
{
parent::__construct($app);
$this->services = $services;
}
/**
* 获取复制商品配置信息
* @return mixed
*/
public function getConfig()
{
$data = [];
$copy = sys_config('system_product_copy_type', 1);
$data['copy_type'] = $copy;
$data['copy_num'] = 0;
if ($copy == 1) {//一号通
/** @var ServeServices $serverServices */
$serverServices = app()->make(ServeServices::class);
try {
$info = $serverServices->user()->getUser();
} catch (\Throwable $e) {
$info = [];
}
if ($info) {
$data['copy_num'] = $info['copy']['num'] ?? 0;
}
}
return app('json')->success($data);
}
/**
* 复制商品
* @return mixed
*/
public function copyProduct()
{
list($type, $id, $shopid, $url) = $this->request->postMore([
['type', ''],
['id', ''],
['shopid', ''],
['url', '']
], true);
$res = $this->services->copyProduct($type, $id, $shopid, $url);
return app('json')->success($res);
}
/**
* 保存图片保存商品信息
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function save_product()
{
$data = $this->request->postMore([
['cate_id', ''],
['store_name', ''],
['store_info', ''],
['keyword', ''],
['unit_name', ''],
['image', ''],
['slider_image', []],
['price', 0],
['ot_price', 0],
['give_integral', ''],
['postage', ''],
['sales', 0],
['ficti', ''],
['stock', 0],
['cost', 0],
['description_images', []],
['description', ''],
['is_show', 0],
['soure_link', ''],
['temp_id', 0],
['spec_type', 0],
['items', []],
['attrs', []]
]);
$this->services->save($data);
return app('json')->success(100000);
}
}

View File

@ -0,0 +1,172 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\adminapi\controller\v1\product;
use app\adminapi\controller\AuthController;
use app\services\product\product\StoreCategoryServices;
use think\facade\App;
/**
* 商品分类控制器
* Class StoreCategory
* @package app\admin\controller\system
*/
class StoreCategory extends AuthController
{
/**
* @var StoreCategoryServices
*/
protected $service;
/**
* StoreCategory constructor.
* @param App $app
* @param StoreCategoryServices $service
*/
public function __construct(App $app, StoreCategoryServices $service)
{
parent::__construct($app);
$this->service = $service;
}
/**
* 分类列表
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function index()
{
$where = $this->request->getMore([
['is_show', ''],
['pid', ''],
['cate_name', ''],
]);
$data = $this->service->getList($where);
return app('json')->success($data);
}
/**
* 商品分类搜索
* @param $type
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function tree_list($type)
{
$list = $this->service->getTierList(1, $type);
return app('json')->success($list);
}
/**
* 获取分类cascader格式数据
* @param $type
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function cascader_list($type = 1)
{
return app('json')->success($this->service->cascaderList(1, $type));
}
/**
* 修改状态
* @param string $is_show
* @param string $id
*/
public function set_show($is_show = '', $id = '')
{
if ($is_show == '' || $id == '') return app('json')->fail(100100);
$this->service->setShow($id, $is_show);
return app('json')->success($is_show == 1 ? 100003 : 100004);
}
/**
* 生成新增表单
* @return mixed
* @throws \FormBuilder\Exception\FormBuilderException
*/
public function create()
{
return app('json')->success($this->service->createForm());
}
/**
* 保存新增分类
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function save()
{
$data = $this->request->postMore([
['pid', 0],
['cate_name', ''],
['pic', ''],
['big_pic', ''],
['sort', 0],
['is_show', 0]
]);
$this->service->createData($data);
return app('json')->success(100000);
}
/**
* 生成更新表单
* @param $id
* @return mixed
* @throws \FormBuilder\Exception\FormBuilderException
*/
public function edit($id)
{
return app('json')->success($this->service->editForm((int)$id));
}
/**
* 更新分类
* @param $id
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function update($id)
{
$data = $this->request->postMore([
['pid', 0],
['cate_name', ''],
['pic', ''],
['big_pic', ''],
['sort', 0],
['is_show', 0]
]);
$this->service->editData($id, $data);
return app('json')->success(100001);
}
/**
* 删除分类
* @param $id
* @return mixed
*/
public function delete($id)
{
$this->service->del((int)$id);
return app('json')->success(100002);
}
}

View File

@ -0,0 +1,420 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\adminapi\controller\v1\product;
use app\adminapi\controller\AuthController;
use app\services\order\StoreCartServices;
use app\services\other\CacheServices;
use app\services\product\product\StoreCategoryServices;
use app\services\product\product\StoreProductServices;
use crmeb\services\FileService;
use app\services\other\UploadService;
use think\facade\App;
use think\Request;
/**
* Class StoreProduct
* @package app\adminapi\controller\v1\product
*/
class StoreProduct extends AuthController
{
protected $service;
public function __construct(App $app, StoreProductServices $service)
{
parent::__construct($app);
$this->service = $service;
}
/**
* 显示资源列表头部
* @return mixed
*/
public function type_header()
{
$where = $this->request->getMore([
['store_name', ''],
['cate_id', ''],
]);
$list = $this->service->getHeader($where);
return app('json')->success(compact('list'));
}
/**
* 获取退出未保存的数据
* @param CacheServices $services
* @return mixed
*/
public function getCacheData(CacheServices $services)
{
return app('json')->success(['info' => $services->getDbCache($this->adminId . '_product_data', [])]);
}
/**
* 1分钟保存一次产品数据
* @param CacheServices $services
* @return mixed
*/
public function saveCacheData(CacheServices $services)
{
$data = $this->request->postMore([
['cate_id', []],
['store_name', ''],
['store_info', ''],
['keyword', ''],
['unit_name', '件'],
['image', []],
['recommend_image', ''],
['slider_image', []],
['postage', 0],
['is_sub', []],//佣金是单独还是默认
['sort', 0],
['sales', 0],
['ficti', 100],
['give_integral', 0],
['is_show', 0],
['temp_id', 0],
['is_hot', 0],
['is_benefit', 0],
['is_best', 0],
['is_new', 0],
['mer_use', 0],
['is_postage', 0],
['is_good', 0],
['description', ''],
['spec_type', 0],
['video_link', ''],
['items', []],
['attrs', []],
['activity', []],
['coupon_ids', []],
['label_id', []],
['command_word', ''],
['tao_words', ''],
['type', 0]
]);
$services->setDbCache($this->adminId . '_product_data', $data, 68400);
return app('json')->success(100000);
}
/**
* 删除数据缓存
* @param CacheServices $services
* @return mixed
*/
public function deleteCacheData(CacheServices $services)
{
$services->delectDbCache($this->adminId . '_product_data');
return app('json')->success(100002);
}
/**
* 显示资源列表
* @return mixed
*/
public function index()
{
$where = $this->request->getMore([
['store_name', ''],
['cate_id', ''],
['type', 1],
['sales', 'normal']
]);
$data = $this->service->getList($where);
return app('json')->success($data);
}
/**
* 修改状态
* @param string $is_show
* @param string $id
* @return mixed
*/
public function set_show($is_show = '', $id = '')
{
$this->service->setShow([$id], $is_show);
return app('json')->success(100014);
}
/**
* 设置批量商品上架
* @return mixed
*/
public function product_show()
{
[$ids] = $this->request->postMore([
['ids', []]
], true);
$this->service->setShow($ids, 1);
return app('json')->success(100014);
}
/**
* 设置批量商品下架
* @return mixed
*/
public function product_unshow()
{
[$ids] = $this->request->postMore([
['ids', []]
], true);
$this->service->setShow($ids, 0);
return app('json')->success(100014);
}
/**
* 获取规格模板
* @return mixed
*/
public function get_rule()
{
$list = $this->service->getRule();
return app('json')->success($list);
}
/**
* 获取商品详细信息
* @param int $id
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function get_product_info($id = 0)
{
return app('json')->success($this->service->getInfo((int)$id));
}
/**
* 保存新建或编辑
* @param $id
* @return mixed
* @throws \Exception
*/
public function save($id)
{
$data = $this->request->postMore([
['virtual_type', 0],// 商品类型
['cate_id', []],//分类id
['store_name', ''],//商品名称
['keyword', ''],//关键字
['unit_name', '件'],//单位
['store_info', ''],//商品简介
['slider_image', []],//轮播图
['video_open', 0],//是否开启视频
['video_link', ''],//视频链接
['spec_type', 0],//单多规格
['items', []],//规格
['attrs', []],//规格
['description', ''],//商品详情
['description_images', []],//商品详情
['logistics', []],//物流方式
['freight', 1],//运费设置
['postage', 0],//邮费
['temp_id', 0],//运费模版id
['give_integral', 0],//赠送积分
['presale', 0],//预售商品开关
['presale_time', 0],//预售时间
['presale_day', 0],//预售发货日
['vip_product', 0],//是否付费会员商品
['is_sub', []],//佣金是单独还是默认
['recommend', []],//商品推荐
['activity', []],//活动优先级
['recommend_list', []],//优品推荐商品
['coupon_ids', []],//优惠券
['label_id', []],//用户标签
['command_word', ''],//商品口令
['is_show', 0],//是否上架
['ficti', 0],//虚拟销量
['sort', 0],//排序
['recommend_image', ''],//商品推荐图
['sales', 0],//销量
['custom_form', []],//自定义表单
['type', 0],
['is_copy', 0],//是否是复制商品
['is_limit', 0],//是否限购
['limit_type', 0],//限购类型
['limit_num', 0],//限购数量
['min_qty', 1],//起购数量
]);
$this->service->save((int)$id, $data);
return app('json')->success(100000);
}
/**
* 删除指定资源
*
* @param int $id
* @return \think\Response
*/
public function delete($id)
{
//删除商品检测是否有参与活动
$this->service->checkActivity($id);
$res = $this->service->del($id);
/** @var StoreCartServices $cartService */
$cartService = app()->make(StoreCartServices::class);
$cartService->changeStatus($id, 0);
return app('json')->success($res);
}
/**
* 生成规格列表
* @param int $id
* @param int $type
* @return mixed
*/
public function is_format_attr($id = 0, $type = 0)
{
$data = $this->request->postMore([
['attrs', []],
['items', []],
['is_virtual', 0],
['virtual_type', 0]
]);
// if ($id > 0 && $type == 1) $this->service->checkActivity($id);
$info = $this->service->getAttr($data, $id, $type);
return app('json')->success(compact('info'));
}
/**
* 获取选择的商品列表
* @return mixed
*/
public function search_list()
{
$where = $this->request->getMore([
['cate_id', ''],
['store_name', ''],
['type', 1],
['is_live', 0],
['is_new', ''],
['is_virtual', -1],
['is_presale', -1]
]);
$where['is_show'] = 1;
$where['is_del'] = 0;
$where['cate_id'] = stringToIntArray($where['cate_id']);
/** @var StoreCategoryServices $storeCategoryServices */
$storeCategoryServices = app()->make(StoreCategoryServices::class);
if ($where['cate_id'] !== '') {
if ($storeCategoryServices->value(['id' => $where['cate_id']], 'pid')) {
$where['sid'] = $where['cate_id'];
} else {
$where['cid'] = $where['cate_id'];
}
}
unset($where['cate_id']);
$list = $this->service->searchList($where);
return app('json')->success($list);
}
/**
* 获取某个商品规格
* @return mixed
*/
public function get_attrs()
{
[$id, $type] = $this->request->getMore([
[['id', 'd'], 0],
[['type', 'd'], 0],
], true);
$info = $this->service->getProductRules($id, $type);
return app('json')->success(compact('info'));
}
/**
* 获取运费模板列表
* @return mixed
*/
public function get_template()
{
return app('json')->success($this->service->getTemp());
}
/**
* 获取视频上传token
* @return mixed
* @throws \Exception
*/
public function getTempKeys(Request $request)
{
$upload = UploadService::init();
$type = (int)sys_config('upload_type', 1);
$key = $request->get('key', '');
$path = $request->get('path', '');
$contentType = $request->get('contentType', '');
if ($type === 5) {
if (!$key || !$contentType) {
return app('json')->fail('缺少参数');
}
$re = $upload->getTempKeys($key, $path, $contentType);
} else {
$re = $upload->getTempKeys();
}
return $re ? app('json')->success($re) : app('json')->fail(100016);
}
/**
* 检测商品是否开活动
* @param $id
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function check_activity($id)
{
$this->service->checkActivity($id);
return app('json')->success(100002);
}
/**
* 导入卡密
* @return mixed
* @throws \PhpOffice\PhpSpreadsheet\Reader\Exception
*/
public function import_card()
{
$data = $this->request->getMore([
['file', ""]
]);
if (!$data['file']) return app('json')->fail(400168);
$file = public_path() . substr($data['file'], 1);
/** @var FileService $readExcelService */
$readExcelService = app()->make(FileService::class);
$cardData = $readExcelService->readExcel($file, 'card');
return app('json')->success($cardData);
}
/**
* 商品批量设置
* @return mixed
*/
public function batchSetting()
{
$data = $this->request->postMore([
['ids', []],
['cate_id', []],
['logistics', []],
['freight', 2],
['postage', 0],
['temp_id', 1],
['give_integral', 0],
['coupon_ids', []],
['label_id', []],
['recommend', []],
['type', 0]
]);
$this->service->batchSetting($data);
return app('json')->success(100014);
}
}

View File

@ -0,0 +1,113 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\adminapi\controller\v1\product;
use app\adminapi\controller\AuthController;
use app\services\product\product\StoreProductReplyServices;
use think\facade\App;
/**
* 评论管理 控制器
* Class StoreProductReply
* @package app\admin\controller\store
*/
class StoreProductReply extends AuthController
{
public function __construct(App $app, StoreProductReplyServices $service)
{
parent::__construct($app);
$this->services = $service;
}
/**
* 显示资源列表
*
* @return \think\Response
*/
public function index()
{
$where = $this->request->getMore([
['is_reply', ''],
['store_name', ''],
['account', ''],
['data', ''],
['product_id', 0],
['key', ''],
['order', '']
]);
$list = $this->services->sysPage($where);
return app('json')->success($list);
}
/**
* 删除评论
* @param $id
* @return mixed
*/
public function delete($id)
{
$this->services->del($id);
return app('json')->success(100002);
}
/**
* 回复评论
* @param $id
* @return mixed
*/
public function set_reply($id)
{
[$content] = $this->request->postMore([
['content', '']
], true);
$this->services->setReply($id, $content);
return app('json')->success(400169);
}
/**
* 创建虚拟评论表单
* @return mixed
* @throws \FormBuilder\Exception\FormBuilderException
*/
public function fictitious_reply()
{
list($product_id) = $this->request->postMore([
['product_id', 0],
], true);
return app('json')->success($this->services->createForm($product_id));
}
/**
* 保存虚拟评论
* @return mixed
*/
public function save_fictitious_reply()
{
$data = $this->request->postMore([
['image', ''],
['nickname', ''],
['avatar', ''],
['comment', ''],
['pics', []],
['product_score', 0],
['service_score', 0],
['product_id', 0],
['add_time', 0],
['suk', ''],
]);
if (!$data['product_id']) {
$data['product_id'] = $data['image']['product_id'] ?? '';
}
$this->validate(['product_id' => $data['product_id'], 'nickname' => $data['nickname'], 'avatar' => $data['avatar'], 'comment' => $data['comment'], 'product_score' => $data['product_score'], 'service_score' => $data['service_score']], \app\adminapi\validate\product\StoreProductReplyValidate::class, 'save');
$this->services->saveReply($data);
return app('json')->success(100000);
}
}

View File

@ -0,0 +1,87 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\adminapi\controller\v1\product;
use app\adminapi\controller\AuthController;
use app\services\product\sku\StoreProductRuleServices;
use think\facade\App;
/**
* 规则管理
* Class StoreProductRule
* @package app\adminapi\controller\v1\product
*/
class StoreProductRule extends AuthController
{
public function __construct(App $app, StoreProductRuleServices $service)
{
parent::__construct($app);
$this->services = $service;
}
/**
* 规格列表
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function index()
{
$where = $this->request->getMore([
['rule_name', '']
]);
$list = $this->services->getList($where);
return app('json')->success($list);
}
/**
* 保存规格
* @param $id
* @return mixed
*/
public function save($id)
{
$data = $this->request->postMore([
['rule_name', ''],
['spec', []]
]);
$this->services->save($id, $data);
return app('json')->success(100000);
}
/**
* 获取规格信息
* @param $id
* @return mixed
*/
public function read($id)
{
$info = $this->services->getInfo($id);
return app('json')->success($info);
}
/**
* 删除指定资源
*
* @param int $id
* @return \think\Response
*/
public function delete()
{
[$ids] = $this->request->postMore([
['ids', '']
], true);
$this->services->del((string)$ids);
return app('json')->success(100002);
}
}

View File

@ -0,0 +1,100 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\adminapi\controller\v1\serve;
use app\adminapi\controller\AuthController;
use app\services\serve\ServeServices;
use app\services\shipping\ExpressServices;
use think\facade\App;
/**
* 一号通平台物流服务
* Class Export
* @package app\adminapi\controller\v1\serve
*/
class Export extends AuthController
{
/**
* Export constructor.
* @param App $app
* @param ExpressServices $services
*/
public function __construct(App $app, ExpressServices $services)
{
parent::__construct($app);
$this->services = $services;
}
/**
* 物流公司
* @return mixed
*/
public function getExportAll()
{
return app('json')->success($this->services->expressList());
}
/**
*
* 获取面单信息
* @param string $com
* @return mixed
*/
public function getExportTemp(ServeServices $services)
{
[$com] = $this->request->getMore([
['com', ''],
], true);
return app('json')->success($services->express()->temp($com));
}
/**
* 打印电子面单是否开启
* @return mixed
*/
public function dumpIsOpen(ServeServices $services)
{
$userInfo = $services->user()->getUser();
$res = false;
if ($userInfo['dump']['open']) {
$res = true;
if (!sys_config('config_export_siid')
&& !sys_config('config_export_com')
&& !sys_config('config_export_to_name')
&& !sys_config('config_export_to_tel')
&& !sys_config('config_export_to_address')
) {
$res = false;
}
}
return app('json')->success(['isOpen' => $res]);
}
/**
* @param ServeServices $services
* @return \think\Response
* @author 等风来
* @email 136327134@qq.com
* @date 2023/5/15
*/
public function getShipmentOrderList(ServeServices $services)
{
$where = $this->request->getMore([
['page', 1],
['limit', 10],
]);
return app('json')->success($services->express()->getShipmentOrderList($where));
}
}

View File

@ -0,0 +1,117 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\adminapi\controller\v1\serve;
use app\adminapi\controller\AuthController;
use app\adminapi\validate\serve\ServeValidata;
use app\Request;
use app\services\yihaotong\SmsAdminServices;
use crmeb\services\CacheService;
use app\services\serve\ServeServices;
use think\facade\App;
/**
* 服务登录
* Class Login
* @package app\adminapi\controller\v1\serve
*/
class Login extends AuthController
{
public function __construct(App $app, ServeServices $services)
{
parent::__construct($app);
$this->services = $services;
}
/**
* 发送验证码
* @param string $phone
* @return mixed
*/
public function captcha(string $phone)
{
$this->validate(['phone' => $phone], ServeValidata::class, 'phone');
return app('json')->success('发送成功', $this->services->user()->code($phone));
}
/**
* 验证验证码
* @param string $phone
* @param $code
* @return mixed
*/
public function checkCode()
{
[$phone, $verify_code] = $this->request->postMore([
['phone', ''],
['verify_code', ''],
], true);
$this->validate(['phone' => $phone], ServeValidata::class, 'phone');
return app('json')->success('success', $this->services->user()->checkCode($phone, $verify_code));
}
/**
* 注册服务
* @param Request $request
* @param SmsAdminServices $services
* @return mixed
*/
public function register(Request $request, SmsAdminServices $services)
{
$data = $request->postMore([
['phone', ''],
['account', ''],
['password', ''],
['verify_code', ''],
]);
$data['account'] = $data['phone'];
$this->validate($data, ServeValidata::class);
$data['password'] = md5($data['password']);
$res = $this->services->user()->register($data);
if ($res) {
$services->updateSmsConfig($data['account'], md5($data['account'] . md5($data['password'])));
return app('json')->success(400170);
} else {
return app('json')->fail(400171);
}
}
/**
* 平台登录
* @return mixed
* @throws \Psr\SimpleCache\InvalidArgumentException
*/
public function login(SmsAdminServices $services)
{
[$account, $password] = $this->request->postMore([
['account', ''],
['password', '']
], true);
$this->validate(['account' => $account, 'password' => $password], ServeValidata::class, 'login');
$password = md5($account . md5($password));
$res = $this->services->user()->login($account, $password);
if ($res) {
CacheService::clear();
CacheService::set('sms_account', $account);
$services->updateSmsConfig($account, $password);
return app('json')->success(400139, $res);
} else {
return app('json')->fail(400172);
}
}
}

View File

@ -0,0 +1,213 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\adminapi\controller\v1\serve;
use app\adminapi\controller\AuthController;
use app\adminapi\validate\serve\ExpressValidata;
use app\adminapi\validate\serve\MealValidata;
use app\adminapi\validate\serve\ServeValidata;
use app\services\system\config\SystemConfigServices;
use crmeb\services\CacheService;
use app\services\serve\ServeServices;
use think\facade\App;
/**
* Class Serve
* @package app\adminapi\controller\v1\serve
*/
class Serve extends AuthController
{
/**
* Serve constructor.
* @param App $app
* @param ServeServices $services
*/
public function __construct(App $app, ServeServices $services)
{
parent::__construct($app);
$this->services = $services;
}
/**
* 检测登录
* @return mixed
*/
public function is_login()
{
$sms_info = CacheService::get('sms_account');
if ($sms_info) {
return app('json')->success(['status' => true, 'info' => $sms_info]);
} else {
return app('json')->success(['status' => false]);
}
}
/**
* 获取套餐列表
* @param string $type
* @return mixed
*/
public function mealList(string $type)
{
$res = $this->services->user()->mealList($type);
if ($res) {
return app('json')->success($res);
} else {
return app('json')->fail(400173);
}
}
/**
* 获取支付码
* @return mixed
*/
public function payMeal()
{
$data = $this->request->postMore([
['meal_id', ''],
['price', ''],
['num', ''],
['type', ''],
['pay_type', ''],
]);
$openInfo = $this->services->user()->getUser();
if (!$openInfo) app('json')->fail(400174);
switch ($data['type']) {
case "sms" :
if (!$openInfo['sms']['open']) return app('json')->fail(400175);
break;
case "query" :
if (!$openInfo['query']['open']) return app('json')->fail(400176);
break;
case "dump" :
if (!$openInfo['dump']['open']) return app('json')->fail(400177);
break;
case "copy" :
if (!$openInfo['copy']['open']) return app('json')->fail(400178);
break;
}
$this->validate($data, MealValidata::class);
$res = $this->services->user()->payMeal($data);
if ($res) {
return app('json')->success($res);
} else {
return app('json')->fail(400174);
}
}
/**
* 开通打印电子面单
* @return mixed
*/
public function openExpress()
{
$data = $this->request->postMore([
['com', ''],
['temp_id', ''],
['to_name', ''],
['to_tel', ''],
['to_address', ''],
['siid', ''],
]);
$this->validate($data, ExpressValidata::class);
/** @var SystemConfigServices $systemConfigService */
$systemConfigService = app()->make(SystemConfigServices::class);
$systemConfigService->saveExpressInfo($data);
$this->services->express()->open();
return app('json')->success(100044);
}
/**
* 获取用户信息,用户信息内包含是否开通服务字段
* @return mixed
*/
public function getUserInfo()
{
return app('json')->success($this->services->user()->getUser());
}
/**
* 查询记录
* @return mixed
*/
public function getRecord()
{
[$page, $limit, $type] = $this->request->getMore([
[['page', 'd'], 0],
[['limit', 'd'], 10],
[['type', 'd'], 0],
], true);
return app('json')->success($this->services->user()->record($page, $limit, $type));
}
/**
* 开通服务
* @param int $type
* @return mixed
*/
public function openServe($type = 0)
{
if ($type) {
$this->services->copy()->open();
} else {
$this->services->express()->open();
}
return app('json')->success(100044);
}
/**
* 修改密码
* @return mixed
*/
public function modify()
{
$data = $this->request->postMore([
['account', ''],
['password', ''],
['phone', ''],
['verify_code', ''],
]);
$this->validate($data, ServeValidata::class);
$data['password'] = md5($data['password']);
$this->services->user()->modify($data);
CacheService::delete('sms_account');
return app('json')->success(100001);
}
/**
* 修改手机号
* @return mixed
*/
public function updatePhone()
{
$data = $this->request->postMore([
['account', ''],
['phone', ''],
['verify_code', ''],
]);
$this->validate($data, ServeValidata::class, 'phone');
$this->services->user()->modifyPhone($data);
CacheService::delete('sms_account');
return app('json')->success(100001);
}
}

View File

@ -0,0 +1,121 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\adminapi\controller\v1\serve;
use app\adminapi\controller\AuthController;
use app\adminapi\validate\serve\ServeValidata;
use app\services\serve\ServeServices;
use think\facade\App;
/**
* Class Sms
* @package app\adminapi\controller\v1\serve
*/
class Sms extends AuthController
{
/**
* Sms constructor.
* @param App $app
* @param ServeServices $services
*/
public function __construct(App $app, ServeServices $services)
{
parent::__construct($app);
$this->services = $services;
}
/**
* 开通服务
* @param string $sign
* @return mixed
*/
public function openServe(string $sign)
{
if (!$sign) {
return app('json')->fail(400179);
}
$this->services->sms()->setSign($sign)->open();
return app('json')->success(100044);
}
/**
* 修改短信签名
* @param string $sign
* @return mixed
*/
public function editSign(string $sign)
{
[$sign, $phone, $code] = $this->request->postMore([
['sign', ''],
['phone', ''],
['code', ''],
], true);
$this->validate(['phone' => $phone], ServeValidata::class, 'phone');
if (!$sign) {
return app('json')->fail(400179);
}
$this->services->sms()->modify($sign, $phone, $code);
return app('json')->success(400180);
}
/**
* 获取短信模板
* @return mixed
*/
public function temps()
{
[$page, $limit, $type] = $this->request->getMore([
['page', 1],
['limit', 10],
['temp_type', 0],
], true);
return app('json')->success($this->services->getSmsTempsList((int)$page, (int)$limit, (int)$type));
}
/**
* 申请模板
* @return mixed
*/
public function apply()
{
[$title, $content, $type] = $this->request->postMore([
['title', ''],
['content', ''],
['type', 0]
], true);
if (!$title || !$content || !$type) {
return app('json')->success(400143);
}
return app('json')->success($this->services->sms()->apply($title, $content, (int)$type));
}
/**
* 获取申请记录
* @return mixed
*/
public function applyRecord()
{
[$page, $limit, $tempType] = $this->request->getMore([
[['page', 'd'], 1],
[['limit', 'd'], 10],
[['temp_type', 'd'], 0],
], true);
return app('json')->success($this->services->sms()->applys($tempType, $page, $limit));
}
}

View File

@ -0,0 +1,105 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\adminapi\controller\v1\setting;
use app\adminapi\controller\AuthController;
use app\services\system\lang\LangCodeServices;
use think\facade\App;
class LangCode extends AuthController
{
/**
* @param App $app
* @param LangCodeServices $services
*/
public function __construct(App $app, LangCodeServices $services)
{
parent::__construct($app);
$this->services = $services;
}
/**
* 获取语言列表
* @return mixed
* @throws \ReflectionException
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function langCodeList()
{
$where = $this->request->getMore([
['is_admin', 0],
['type_id', 0],
['code', ''],
['remarks', '']
]);
return app('json')->success($this->services->langCodeList($where));
}
/**
* 获取语言详情
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function langCodeInfo()
{
[$code] = $this->request->getMore([
['code', ''],
], true);
return app('json')->success($this->services->langCodeInfo($code));
}
/**
* 新增编辑语言
* @return mixed
* @throws \Exception
*/
public function langCodeSave()
{
$data = $this->request->postMore([
['is_admin', 0],
['code', ''],
['remarks', ''],
['edit', 0],
['list', []]
]);
$this->services->langCodeSave($data);
return app('json')->success(100000);
}
/**
* 删除语言
* @param $id
* @return mixed
*/
public function langCodeDel($id)
{
$this->services->langCodeDel($id);
return app('json')->success(100002);
}
/**
* 机器翻译
* @return mixed
* @throws \Throwable
*/
public function langCodeTranslate()
{
[$text] = $this->request->postMore([
['text', '']
], true);
if ($text == '') return app('json')->fail(100100);
return app('json')->success($this->services->langCodeTranslate($text));
}
}

View File

@ -0,0 +1,79 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\adminapi\controller\v1\setting;
use app\adminapi\controller\AuthController;
use app\services\system\lang\LangCountryServices;
use think\facade\App;
class LangCountry extends AuthController
{
/**
* @param App $app
* @param LangCountryServices $services
*/
public function __construct(App $app, LangCountryServices $services)
{
parent::__construct($app);
$this->services = $services;
}
/**
* 国家语言列表
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function langCountryList()
{
$where = $this->request->getMore([
['keyword', ''],
]);
return app('json')->success($this->services->langCountryList($where));
}
/**
* 设置国家语言类型表单
* @param $id
* @return mixed
* @throws \FormBuilder\Exception\FormBuilderException
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function langCountryForm($id)
{
return app('json')->success($this->services->langCountryForm($id));
}
/**
* 地区语言修改
* @param $id
* @return mixed
*/
public function langCountrySave($id)
{
$data = $this->request->postMore([
['name', ''],
['code', ''],
['type_id', 0],
]);
$this->services->langCountrySave($id, $data);
return app('json')->success(100000);
}
public function langCountryDel($id)
{
$this->services->langCountryDel($id);
return app('json')->success(100002);
}
}

View File

@ -0,0 +1,95 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\adminapi\controller\v1\setting;
use app\adminapi\controller\AuthController;
use app\services\system\lang\LangTypeServices;
use crmeb\services\CacheService;
use think\facade\App;
class LangType extends AuthController
{
/**
* @param App $app
* @param LangTypeServices $services
*/
public function __construct(App $app, LangTypeServices $services)
{
parent::__construct($app);
$this->services = $services;
}
/**
* 获取语言类型列表
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function langTypeList()
{
$where['is_del'] = 0;
return app('json')->success($this->services->langTypeList($where));
}
/**
* 添加语言类型表单
* @param int $id
* @return mixed
* @throws \FormBuilder\Exception\FormBuilderException
*/
public function langTypeForm(int $id = 0)
{
return app('json')->success($this->services->langTypeForm($id));
}
/**
* 保存语言类型
* @return mixed
*/
public function langTypeSave()
{
$data = $this->request->postMore([
['id', 0],
['language_name', ''],
['file_name', ''],
['is_default', 0],
['status', 0]
]);
$this->services->langTypeSave($data);
CacheService::delete('lang_type_data');
return app('json')->success(100000);
}
/**
* 修改语言类型状态
* @param $id
* @param $status
* @return mixed
*/
public function langTypeStatus($id, $status)
{
$this->services->langTypeStatus($id, $status);
return app('json')->success(100014);
}
/**
* 删除语言类型
* @param int $id
* @return mixed
*/
public function langTypeDel(int $id = 0)
{
$this->services->langTypeDel($id);
CacheService::delete('lang_type_data');
return app('json')->success(100002);
}
}

View File

@ -0,0 +1,113 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\adminapi\controller\v1\setting;
use app\adminapi\controller\AuthController;
use app\services\shipping\ShippingTemplatesServices;
use app\services\shipping\SystemCityServices;
use think\facade\App;
/**
* 运费模板
* Class ShippingTemplates
* @package app\adminapi\controller\v1\setting
*/
class ShippingTemplates extends AuthController
{
/**
* 构造方法
* ShippingTemplates constructor.
* @param App $app
* @param ShippingTemplatesServices $services
*/
public function __construct(App $app, ShippingTemplatesServices $services)
{
parent::__construct($app);
$this->services = $services;
}
/**
* 运费模板列表
* @return mixed
*/
public function temp_list()
{
$where = $this->request->getMore([
[['name', 's'], '']
]);
return app('json')->success($this->services->getShippingList($where));
}
/**
* 修改
* @return string
* @throws \Exception
*/
public function edit($id)
{
return app('json')->success($this->services->getShipping((int)$id));
}
/**
* 保存或者修改
* @param int $id
*/
public function save($id = 0)
{
$data = $this->request->postMore([
[['region_info', 'a'], []],
[['appoint_info', 'a'], []],
[['no_delivery_info', 'a'], []],
[['sort', 'd'], 0],
[['type', 'd'], 0],
[['name', 's'], ''],
[['appoint', 'd'], 0],
[['no_delivery', 'd'], 0]
]);
$this->validate($data, \app\adminapi\validate\setting\ShippingTemplatesValidate::class, 'save');
$temp['name'] = $data['name'];
$temp['type'] = $data['type'];
$temp['appoint'] = $data['appoint'] && $data['appoint_info'] ? 1 : 0;
$temp['no_delivery'] = $data['no_delivery'] && $data['no_delivery_info'] ? 1 : 0;
$temp['sort'] = $data['sort'];
$temp['add_time'] = time();
$this->services->save((int)$id, $temp, $data);
return app('json')->success(100000);
}
/**
* 删除运费模板
*/
public function delete()
{
[$id] = $this->request->getMore([
[['id', 'd'], 0],
], true);
if ($id == 1) {
return app('json')->fail(400181);
} else {
$this->services->detete($id);
return app('json')->success(100002);
}
}
/**
* 城市数据
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function city_list(SystemCityServices $services)
{
return app('json')->success($services->getShippingCity());
}
}

View File

@ -0,0 +1,214 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\adminapi\controller\v1\setting;
use app\adminapi\controller\AuthController;
use app\services\system\admin\SystemAdminServices;
use crmeb\services\CacheService;
use think\facade\{App, Config};
/**
* Class SystemAdmin
* @package app\adminapi\controller\v1\setting
*/
class SystemAdmin extends AuthController
{
/**
* SystemAdmin constructor.
* @param App $app
* @param SystemAdminServices $services
*/
public function __construct(App $app, SystemAdminServices $services)
{
parent::__construct($app);
$this->services = $services;
}
/**
* 显示管理员资源列表
*
* @return \think\Response
*/
public function index()
{
$where = $this->request->getMore([
['name', '', '', 'account_like'],
['roles', ''],
['is_del', 1],
['status', '']
]);
$where['level'] = $this->adminInfo['level'] + 1;
return app('json')->success($this->services->getAdminList($where));
}
/**
* 创建表单
* @return mixed
* @throws \FormBuilder\Exception\FormBuilderException
*/
public function create()
{
return app('json')->success($this->services->createForm($this->adminInfo['level'] + 1));
}
/**
* 保存管理员
* @return mixed
*/
public function save()
{
$data = $this->request->postMore([
['account', ''],
['conf_pwd', ''],
['pwd', ''],
['real_name', ''],
['roles', []],
['status', 0],
]);
$this->validate($data, \app\adminapi\validate\setting\SystemAdminValidata::class);
$data['level'] = $this->adminInfo['level'] + 1;
$this->services->create($data);
return app('json')->success(100000);
}
/**
* 显示编辑资源表单页.
*
* @param int $id
* @return \think\Response
*/
public function edit($id)
{
if (!$id) {
return app('json')->fail(400182);
}
return app('json')->success($this->services->updateForm($this->adminInfo['level'] + 1, (int)$id));
}
/**
* 修改管理员信息
* @param $id
* @return mixed
*/
public function update($id)
{
$data = $this->request->postMore([
['account', ''],
['conf_pwd', ''],
['pwd', ''],
['real_name', ''],
['roles', []],
['status', 0],
]);
$this->validate($data, \app\adminapi\validate\setting\SystemAdminValidata::class, 'update');
if ($this->services->save((int)$id, $data)) {
return app('json')->success(100001);
} else {
return app('json')->fail(100007);
}
}
/**
* 删除管理员
* @param $id
* @return mixed
*/
public function delete($id)
{
if (!$id) return app('json')->fail(100100);
if ($this->services->update((int)$id, ['is_del' => 1, 'status' => 0]))
return app('json')->success(100002);
else
return app('json')->fail(100008);
}
/**
* 修改状态
* @param $id
* @param $status
* @return mixed
*/
public function set_status($id, $status)
{
$this->services->update((int)$id, ['status' => $status]);
return app('json')->success(100014);
}
/**
* 获取当前登陆管理员的信息
* @return mixed
*/
public function info()
{
return app('json')->success($this->adminInfo);
}
/**
* 修改当前登陆admin信息
* @return mixed
*/
public function update_admin()
{
$data = $this->request->postMore([
['real_name', ''],
['head_pic', ''],
['pwd', ''],
['new_pwd', ''],
['conf_pwd', ''],
]);
if ($data['pwd']) {
if (!preg_match('/^(?![^a-zA-Z]+$)(?!\D+$).{6,}$/', $data['new_pwd'])) {
return app('json')->fail(400183);
}
}
if ($this->services->updateAdmin($this->adminId, $data))
return app('json')->success(100001);
else
return app('json')->fail(100007);
}
/**
* 修改当前登陆admin的文件管理密码
* @return mixed
*/
public function set_file_password()
{
$data = $this->request->postMore([
['file_pwd', ''],
['conf_file_pwd', ''],
]);
if (!preg_match('/^(?![^a-zA-Z]+$)(?!\D+$).{6,}$/', $data['file_pwd'])) {
return app('json')->fail(400183);
}
if ($this->services->setFilePassword($this->adminId, $data))
return app('json')->success(100001);
else
return app('json')->fail(100007);
}
/**
* 退出登陆
* @return mixed
*/
public function logout()
{
$key = trim(ltrim($this->request->header(Config::get('cookie.token_name')), 'Bearer'));
CacheService::delete(md5($key));
return app('json')->success();
}
}

View File

@ -0,0 +1,54 @@
<?php
namespace app\adminapi\controller\v1\setting;
use app\adminapi\controller\AuthController;
use app\services\other\AgreementServices;
use think\facade\App;
class SystemAgreement extends AuthController
{
/**
* 构造方法
* SystemCity constructor.
* @param App $app
* @param AgreementServices $services
*/
public function __construct(App $app, AgreementServices $services)
{
parent::__construct($app);
$this->services = $services;
}
/**
* 获取协议内容
* @param $type
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function getAgreement($type)
{
if (!$type) return app('json')->fail(400184);
$info = $this->services->getAgreementBytype($type);
return app('json')->success($info);
}
/**
* 保存协议内容
* @return mixed
*/
public function saveAgreement()
{
$data = $this->request->postMore([
['id', 0],
['type', 0],
['title', ''],
['content', ''],
]);
$data['status'] = 1;
$this->services->saveAgreement($data, $data['id']);
return app('json')->success(100000);
}
}

View File

@ -0,0 +1,156 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\adminapi\controller\v1\setting;
use app\adminapi\controller\AuthController;
use app\services\shipping\SystemCityServices;
use think\facade\App;
use crmeb\services\{CacheService};
/**
* 城市数据
* Class SystemCity
* @package app\adminapi\controller\v1\setting
*/
class SystemCity extends AuthController
{
/**
* 构造方法
* SystemCity constructor.
* @param App $app
* @param SystemCityServices $services
*/
public function __construct(App $app, SystemCityServices $services)
{
parent::__construct($app);
$this->services = $services;
}
/**
* 城市列表
* @return string
* @throws \Exception
*/
public function index()
{
$where = $this->request->getMore([
[['parent_id', 'd'], 0]
]);
return app('json')->success($this->services->getCityList($where));
}
/**
* 添加城市
* @return mixed
* @throws \FormBuilder\Exception\FormBuilderException
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function add()
{
[$parentId] = $this->request->getMore([
[['parent_id', 'd'], 0]
], true);
return app('json')->success($this->services->createCityForm($parentId));
}
/**
* 保存
*/
public function save()
{
$data = $this->request->postMore([
[['id', 'd'], 0],
[['name', 's'], ''],
[['merger_name', 's'], ''],
[['area_code', 's'], ''],
[['lng', 's'], ''],
[['lat', 's'], ''],
[['level', 'd'], 0],
[['parent_id', 'd'], 0],
]);
$this->validate($data, \app\adminapi\validate\setting\SystemCityValidate::class, 'save');
if ($data['parent_id'] == 0) {
$data['merger_name'] = $data['name'];
} else {
$data['merger_name'] = $this->services->value(['id' => $data['parent_id']], 'name') . ',' . $data['name'];
}
if ($data['id'] == 0) {
unset($data['id']);
$data['level'] = $data['level'] + 1;
$data['city_id'] = intval($this->services->getCityIdMax() + 1);
$this->services->save($data);
return app('json')->success(100000);
} else {
unset($data['level']);
unset($data['parent_id']);
$this->services->update($data['id'], $data);
return app('json')->success(100001);
}
}
/**
* 修改城市
* @return string
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function edit()
{
[$id] = $this->request->getMore([
[['id', 'd'], 0]
], true);
return app('json')->success($this->services->updateCityForm($id));
}
/**
* 删除城市
* @throws \Exception
*/
public function delete()
{
[$id] = $this->request->getMore([
[['city_id', 'd'], 0]
], true);
$this->services->deleteCity($id);
return app('json')->success(100002);
}
/**
* 清除城市缓存
* @throws \Psr\SimpleCache\InvalidArgumentException
*/
public function clean_cache()
{
$res1 = CacheService::delete('CITY_LIST');
$res2 = CacheService::delete('CITY_FULL_LIST');
if ($res1 && $res2) {
return app('json')->success(400185);
} else {
return app('json')->fail(400186);
}
}
/**
* 获取城市数据完整列表
* @return \think\Response
* @author 吴汐
* @email 442384644@qq.com
* @date 2023/04/10
*/
public function fullList()
{
return app('json')->success($this->services->fullList('parent_id,name as label,city_id as value'));
}
}

View File

@ -0,0 +1,439 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\adminapi\controller\v1\setting;
use app\adminapi\controller\AuthController;
use app\Request;
use app\services\system\config\SystemConfigServices;
use app\services\system\config\SystemConfigTabServices;
use crmeb\services\CacheService;
use crmeb\services\easywechat\orderShipping\MiniOrderService;
use think\facade\App;
/**
* 系统配置
* Class SystemConfig
* @package app\adminapi\controller\v1\setting
*/
class SystemConfig extends AuthController
{
/**
* SystemConfig constructor.
* @param App $app
* @param SystemConfigServices $services
*/
public function __construct(App $app, SystemConfigServices $services)
{
parent::__construct($app);
$this->services = $services;
}
/**
* 显示资源列表
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function index()
{
$where = $this->request->getMore([
['tab_id', 0],
['status', -1]
]);
if (!$where['tab_id']) {
return app('json')->fail(100100);
}
if ($where['status'] == -1) {
unset($where['status']);
}
return app('json')->success($this->services->getConfigList($where));
}
/**
* 显示创建资源表单页.
* @return \think\Response
* @throws \FormBuilder\Exception\FormBuilderException
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function create()
{
[$type, $tabId] = $this->request->getMore([
[['type', 'd'], ''],
[['tab_id', 'd'], 1]
], true);
return app('json')->success($this->services->createFormRule($type, $tabId));
}
/**
* 保存新建的资源
* @return \think\Response
*/
public function save()
{
$data = $this->request->postMore([
['menu_name', ''],
['type', ''],
['input_type', 'input'],
['config_tab_id', 0],
['parameter', ''],
['upload_type', 1],
['required', ''],
['width', 0],
['height', 0],
['value', ''],
['info', ''],
['desc', ''],
['sort', 0],
['status', 0]
]);
if (is_array($data['config_tab_id'])) $data['config_tab_id'] = end($data['config_tab_id']);
if (!$data['info']) return app('json')->fail(400274);
if (!$data['menu_name']) return app('json')->fail(400275);
if (!$data['desc']) return app('json')->fail(400276);
if ($data['sort'] < 0) {
$data['sort'] = 0;
}
if ($data['type'] == 'text') {
if (!$data['width']) return app('json')->fail(400277);
if ($data['width'] <= 0) return app('json')->fail(400278);
}
if ($data['type'] == 'textarea') {
if (!$data['width']) return app('json')->fail(400279);
if (!$data['height']) return app('json')->fail(400280);
if ($data['width'] < 0) return app('json')->fail(400281);
if ($data['height'] < 0) return app('json')->fail(400282);
}
if ($data['type'] == 'radio' || $data['type'] == 'checkbox') {
if (!$data['parameter']) return app('json')->fail(400283);
$this->services->valiDateRadioAndCheckbox($data);
}
$data['value'] = json_encode($data['value']);
$config = $this->services->getOne(['menu_name' => $data['menu_name']]);
if ($config) {
$this->services->update($config['id'], $data, 'id');
} else {
$this->services->save($data);
}
CacheService::clear();
return app('json')->success(400284);
}
/**
* 显示指定的资源
*
* @param int $id
* @return \think\Response
*/
public function read($id)
{
if (!$id) {
return app('json')->fail(100100);
}
$info = $this->services->getReadList((int)$id);
return app('json')->success(compact('info'));
}
/**
* 显示编辑资源表单页.
*
* @param int $id
* @return \think\Response
*/
public function edit($id)
{
return app('json')->success($this->services->editConfigForm((int)$id));
}
/**
* 保存更新的资源
*
* @param int $id
* @return \think\Response
*/
public function update($id)
{
$type = request()->post('type');
if ($type == 'text' || $type == 'textarea' || $type == 'radio' || ($type == 'upload' && (request()->post('upload_type') == 1 || request()->post('upload_type') == 3))) {
$value = request()->post('value');
} else {
$value = request()->post('value/a');
}
if (!$value) $value = request()->post(request()->post('menu_name'));
$data = $this->request->postMore([
['menu_name', ''],
['type', ''],
['input_type', 'input'],
['config_tab_id', 0],
['parameter', ''],
['upload_type', 1],
['required', ''],
['width', 0],
['height', 0],
['value', $value],
['info', ''],
['desc', ''],
['sort', 0],
['status', 0]
]);
if (is_array($data['config_tab_id'])) $data['config_tab_id'] = end($data['config_tab_id']);
if (!$this->services->get($id)) {
return app('json')->fail(100026);
}
$data['value'] = json_encode($data['value']);
$this->services->update($id, $data);
CacheService::clear();
return app('json')->success(100001);
}
/**
* 删除指定资源
* @param int $id
* @return \think\Response
*/
public function delete($id)
{
if (!$this->services->delete($id))
return app('json')->fail(100008);
else {
CacheService::clear();
return app('json')->success(100002);
}
}
/**
* 修改状态
* @param $id
* @param $status
* @return mixed
*/
public function set_status($id, $status)
{
if ($status == '' || $id == 0) {
return app('json')->fail(100100);
}
$this->services->update($id, ['status' => $status]);
CacheService::clear();
return app('json')->success(100014);
}
/**
* 基础配置
* */
public function edit_basics(Request $request)
{
$tabId = $this->request->param('tab_id', 1);
if (!$tabId) {
return app('json')->fail(100100);
}
$url = $request->baseUrl();
return app('json')->success($this->services->getConfigForm($url, $tabId));
}
/**
* 保存数据 true
* */
public function save_basics(Request $request)
{
$post = $this->request->post();
foreach ($post as $k => $v) {
if (is_array($v)) {
$res = $this->services->getUploadTypeList($k);
foreach ($res as $kk => $vv) {
if ($kk == 'upload') {
if ($vv == 1 || $vv == 3) {
$post[$k] = $v[0];
}
}
}
}
}
$this->validate($post, \app\adminapi\validate\setting\SystemConfigValidata::class);
if (isset($post['upload_type'])) {
$this->services->checkThumbParam($post);
}
if (isset($post['extract_type']) && !count($post['extract_type'])) {
return app('json')->fail(400753);
}
if (isset($post['store_brokerage_binding_status'])) {
$this->services->checkBrokerageBinding($post);
}
if (isset($post['store_brokerage_ratio']) && isset($post['store_brokerage_two'])) {
$num = $post['store_brokerage_ratio'] + $post['store_brokerage_two'];
if ($num > 100) {
return app('json')->fail(400285);
}
}
if (isset($post['spread_banner'])) {
$num = count($post['spread_banner']);
if ($num > 5) {
return app('json')->fail(400286);
}
}
if (isset($post['user_extract_min_price'])) {
if (!preg_match('/[0-9]$/', $post['user_extract_min_price'])) {
return app('json')->fail(400287);
}
}
if (isset($post['wss_open'])) {
$this->services->saveSslFilePath((int)$post['wss_open'], $post['wss_local_pk'] ?? '', $post['wss_local_cert'] ?? '');
}
if (isset($post['store_brokerage_price']) && $post['store_brokerage_statu'] == 3) {
if ($post['store_brokerage_price'] === '') {
return app('json')->fail(400288);
}
if ($post['store_brokerage_price'] < 0) {
return app('json')->fail(400289);
}
}
if (isset($post['store_brokerage_binding_time']) && $post['store_brokerage_binding_status'] == 2) {
if (!preg_match("/^[0-9][0-9]*$/", $post['store_brokerage_binding_time'])) {
return app('json')->fail(400290);
}
}
if (isset($post['uni_brokerage_price']) && $post['uni_brokerage_price'] < 0) {
return app('json')->fail(400756);
}
if (isset($post['day_brokerage_price_upper']) && $post['day_brokerage_price_upper'] < -1) {
return app('json')->fail(400757);
}
if (isset($post['pay_new_weixin_open']) && (bool)$post['pay_new_weixin_open']) {
if (empty($post['pay_new_weixin_mchid'])) {
return app('json')->fail(400763);
}
}
if (isset($post['uni_brokerage_price']) && preg_match('/\.[0-9]{2,}[1-9][0-9]*$/', (string)$post['uni_brokerage_price']) > 0) {
return app('json')->fail(500029);
}
if (isset($post['weixin_ckeck_file'])) {
$from = public_path() . $post['weixin_ckeck_file'];
$to = public_path() . array_reverse(explode('/', $post['weixin_ckeck_file']))[0];
@copy($from, $to);
}
if (isset($post['ico_path'])) {
$from = public_path() . $post['ico_path'];
$toAdmin = public_path('admin') . 'favicon.ico';
$toHome = public_path('home') . 'favicon.ico';
$toPublic = public_path() . 'favicon.ico';
@copy($from, $toAdmin);
@copy($from, $toHome);
@copy($from, $toPublic);
}
if (isset($post['reward_integral']) || isset($post['reward_money'])) {
if ($post['reward_money'] < 0) return app('json')->fail('赠送余额不能小于0元');
if ($post['reward_integral'] < 0) return app('json')->fail('赠送积分不能小于0');
}
if (isset($post['sign_give_point'])) {
if (!is_int($post['sign_give_point']) || $post['sign_give_point'] < 0) return app('json')->fail('签到赠送积分请填写大于等于0的整数');
}
if (isset($post['sign_give_exp'])) {
if ((int)$post['sign_give_exp'] < 0) return app('json')->fail('签到赠送经验请填写大于等于0的整数');
}
if (isset($post['integral_frozen'])) {
if (!ctype_digit($post['integral_frozen']) || $post['integral_frozen'] < 0) return app('json')->fail('积分冻结天数请填写大于等于0的整数');
}
if (isset($post['store_free_postage'])) {
if (!is_int($post['store_free_postage']) || $post['store_free_postage'] < 0) return app('json')->fail('满额包邮请填写大于等于0的整数');
}
if (isset($post['withdrawal_fee'])) {
if ($post['withdrawal_fee'] < 0 || $post['withdrawal_fee'] > 100) return app('json')->fail('提现手续费范围在0-100之间');
}
if (isset($post['routine_auth_type']) && count($post['routine_auth_type']) == 0) return app('json')->fail('微信和手机号登录开关至少开启一个');
if (isset($post['integral_max_num'])) {
if (!ctype_digit($post['integral_max_num']) || $post['integral_max_num'] < 0) return app('json')->fail('积分抵扣上限请填写大于等于0的整数');
}
if (isset($post['customer_phone'])) {
if (!ctype_digit($post['customer_phone']) || strlen($post['customer_phone']) > 11) return app('json')->fail('客服手机号为11位数字');
}
if (isset($post['refund_time_available'])) {
if (!ctype_digit($post['refund_time_available'])) return app('json')->fail('售后期限必须为大于0的整数');
}
foreach ($post as $k => $v) {
$config_one = $this->services->getOne(['menu_name' => $k]);
if ($config_one) {
$config_one['value'] = $v;
$this->services->valiDateValue($config_one);
$this->services->update($k, ['value' => json_encode($v)], 'menu_name');
}
}
CacheService::clear();
return app('json')->success(100001);
}
/**
* 获取系统设置头部分类
* @param SystemConfigTabServices $services
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function header_basics(SystemConfigTabServices $services)
{
[$type, $pid] = $this->request->getMore([
[['type', 'd'], 0],
[['pid', 'd'], 0]
], true);
if ($type == 3) {//其它分类
$config_tab = [];
} else {
$config_tab = $services->getConfigTab($pid);
if (empty($config_tab)) $config_tab[] = $services->get($pid, ['id', 'id as value', 'title as label', 'pid', 'icon', 'type']);
}
return app('json')->success(compact('config_tab'));
}
/**
* 获取单个配置的值
* @param $name
* @return mixed
*/
public function get_system($name)
{
$value = sys_config($name);
return app('json')->success(compact('value'));
}
/**
* 获取某个分类下的所有配置
* @param $tabId
* @return mixed
*/
public function get_config_list($tabId)
{
$list = $this->services->getConfigTabAllList($tabId);
$data = [];
foreach ($list as $item) {
$data[$item['menu_name']] = json_decode($item['value']);
}
return app('json')->success($data);
}
/**
* 获取版本号信息
* @return mixed
*/
public function getVersion()
{
$version = get_crmeb_version();
return app('json')->success([
'version' => $version,
'label' => 19
]);
}
}

View File

@ -0,0 +1,161 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\adminapi\controller\v1\setting;
use app\adminapi\controller\AuthController;
use app\services\system\config\SystemConfigServices;
use app\services\system\config\SystemConfigTabServices;
use think\facade\App;
/**
* 配置分类
* Class SystemConfigTab
* @package app\adminapi\controller\v1\setting
*/
class SystemConfigTab extends AuthController
{
/**
* g构造方法
* SystemConfigTab constructor.
* @param App $app
* @param SystemConfigTabServices $services
*/
public function __construct(App $app, SystemConfigTabServices $services)
{
parent::__construct($app);
$this->services = $services;
}
/**
* 显示资源列表
*
* @return \think\Response
*/
public function index()
{
$where = $this->request->getMore([
['status', ''],
['title', '']
]);
return app('json')->success($this->services->getConfgTabList($where));
}
/**
* 显示创建资源表单页.
*
* @return \think\Response
*/
public function create()
{
return app('json')->success($this->services->createForm());
}
/**
* 保存新建的资源
*
* @return \think\Response
*/
public function save()
{
$data = $this->request->postMore([
'eng_title',
'status',
'title',
'icon',
['type', 0],
['sort', 0],
['pid', 0],
]);
if (is_array($data['pid'])) $data['pid'] = end($data['pid']);
if (!$data['title']) return app('json')->fail(400291);
$this->services->save($data);
return app('json')->success(400292);
}
/**
* 显示指定的资源
*
* @param int $id
* @return \think\Response
*/
public function read($id)
{
//
}
/**
* 显示编辑资源表单页.
*
* @param int $id
* @return \think\Response
*/
public function edit($id)
{
return app('json')->success($this->services->updateForm((int)$id));
}
/**
* 保存更新的资源
*
* @param int $id
* @return \think\Response
*/
public function update($id)
{
$data = $this->request->postMore([
'title',
'status',
'eng_title',
'icon',
['type', 0],
['sort', 0],
['pid', 0],
]);
if (is_array($data['pid'])) $data['pid'] = end($data['pid']);
if (!$data['title']) return app('json')->fail(400291);
if (!$data['eng_title']) return app('json')->fail(400275);
$this->services->update($id, $data);
return app('json')->success(100001);
}
/**
* 删除指定资源
*
* @param int $id
* @return \think\Response
*/
public function delete(SystemConfigServices $services, $id)
{
if ($services->count(['tab_id' => $id])) {
return app('json')->fail(400293);
}
if (!$this->services->delete($id))
return app('json')->fail(100008);
else
return app('json')->success(100002);
}
/**
* 修改状态
* @param $id
* @param $status
* @return mixed
*/
public function set_status($id, $status)
{
if ($status == '' || $id == 0) {
return app('json')->fail(100100);
}
$this->services->update($id, ['status' => $status]);
return app('json')->success(100014);
}
}

View File

@ -0,0 +1,902 @@
<?php
/**
* +----------------------------------------------------------------------
* | CRMEB [ CRMEB赋能开发者助力企业发展 ]
* +----------------------------------------------------------------------
* | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
* +----------------------------------------------------------------------
* | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
* +----------------------------------------------------------------------
* | Author: CRMEB Team <admin@crmeb.com>
* +----------------------------------------------------------------------
*/
namespace app\adminapi\controller\v1\setting;
use app\adminapi\controller\AuthController;
use app\Request;
use app\services\system\log\SystemFileServices;
use app\services\system\SystemCrudDataService;
use app\services\system\SystemCrudServices;
use app\services\system\SystemMenusServices;
use app\services\system\SystemRouteServices;
use crmeb\services\CacheService;
use crmeb\services\crud\enum\FormTypeEnum;
use crmeb\services\crud\Make;
use crmeb\services\crud\Service;
use crmeb\services\FileService;
use think\facade\App;
use think\facade\Db;
use think\facade\Env;
use think\helper\Str;
use think\Response;
/**
* Class SystemCrud
* @author 等风来
* @email 136327134@qq.com
* @date 2023/4/6
* @package app\adminapi\controller\v1\setting
*/
class SystemCrud extends AuthController
{
/**
* SystemCrud constructor.
* @param App $app
* @param SystemCrudServices $services
*/
public function __construct(App $app, SystemCrudServices $services)
{
parent::__construct($app);
$this->services = $services;
}
/**
* @return Response
* @author 等风来
* @email 136327134@qq.com
* @date 2023/4/11
*/
public function index()
{
return app('json')->success($this->services->getList());
}
/**
* @return Response
* @author 等风来
* @email 136327134@qq.com
* @date 2023/4/11
*/
public function save(SystemCrudDataService $service, $id = 0)
{
$data = $this->request->postMore([
['pid', 0],//上级菜单id
['menuName', ''],//菜单名
['tableName', ''],//表名
['modelName', ''],//模块名称
['tableComment', ''],//表备注
['tableField', []],//表字段
['tableIndex', []],//索引
['filePath', []],//生成文件位置
['isTable', 0],//是否生成表
['deleteField', []],//删除的表字段
]);
$fromField = $searchField = $hasOneField = $columnField = $tableIndex = [];
$dictionaryids = array_column($data['tableField'], 'dictionary_id');
if ($dictionaryids) {
$dictionaryList = $service->getColumn([['id', 'in', $dictionaryids]], 'value', 'id');
foreach ($dictionaryList as &$value) {
$value = is_string($value) ? json_decode($value, true) : $value;
}
} else {
$dictionaryList = [];
}
foreach ($data['tableField'] as $item) {
//判断字段长度
if (in_array($item['field_type'], [FormTypeEnum::DATE_TIME, 'timestamp', 'time', 'date', 'year']) && $item['limit'] > 6) {
return app('json')->fail('字段' . $item['field'] . '长度不能大于6');
}
if ($item['field_type'] == 'enum' && !is_array($item['limit'])) {
return app('json')->fail('数据类型为枚举时,长度为数组类型');
}
//收集列表展示数据
if ($item['is_table'] && !in_array($item['field_type'], ['primaryKey', 'addSoftDelete'])) {
if (isset($item['primaryKey']) && !$item['primaryKey']) {
$columnField[] = [
'field' => $item['field'],
'name' => $item['table_name'] ?: $item['comment'],
'type' => $item['from_type'],
];
}
}
$name = $item['table_name'] ?: $item['comment'];
$option = $item['options'] ?? (isset($item['dictionary_id']) ? ($dictionaryList[$item['dictionary_id']] ?? []) : []);
//收集表单展示数据
if ($item['from_type']) {
if (!$name) {
return app('json')->fail(500048, [], ['field' => $item['field']]);
}
if (!$option && in_array($item['from_type'], [FormTypeEnum::RADIO, FormTypeEnum::SELECT])) {
return app('json')->fail('表单类型为radio或select时,options字段不能为空');
}
$fromField[] = [
'field' => $item['field'],
'type' => $item['from_type'],
'name' => $name,
'required' => $item['required'],
'option' => $option
];
}
//搜索
if (!empty($item['search'])) {
$searchField[] = [
'field' => $item['field'],
'type' => $item['from_type'],
'name' => $name,
'search' => $item['search'],
'options' => $option
];
}
//关联
if (!empty($item['hasOne'])) {
$hasOneField[] = [
'field' => $item['field'],
'hasOne' => $item['hasOne'] ?? '',
'name' => $name,
];
}
//索引
if (!empty($item['index'])) {
$tableIndex[] = $item['field'];
}
}
if (!$fromField) {
return app('json')->fail(500046);
}
if (!$columnField) {
return app('json')->fail(500047);
}
$data['fromField'] = $fromField;
$data['tableIndex'] = $tableIndex;
$data['columnField'] = $columnField;
$data['searchField'] = $searchField;
$data['hasOneField'] = $hasOneField;
if (!$data['tableName']) {
return app('json')->fail(500042);
}
$this->services->createCrud($id, $data);
return app('json')->success(500043);
}
/**
* 获取创建文件的目录存放位置
* @return Response
* @author 等风来
* @email 136327134@qq.com
* @date 2023/4/11
*/
public function getFilePath()
{
[$tableName] = $this->request->postMore([
['tableName', ''],
], true);
if (!$tableName) {
return app('json')->fail(500042);
}
if (in_array($tableName, SystemCrudServices::NOT_CRUD_TABANAME)) {
return app('json')->fail(500041);
}
$routeName = 'crud/' . Str::snake($tableName);
$key = 'id';
$tableField = [];
$field = $this->services->getColumnNamesList($tableName);
foreach ($field as $item) {
if ($item['primaryKey']) {
$key = $item['name'];
}
$tableField[] = [
'field' => $item['name'],
'field_type' => $item['type'],
'primaryKey' => (bool)$item['primaryKey'],
'default' => $item['default'],
'limit' => $item['limit'],
'comment' => $item['comment'],
'required' => false,
'is_table' => false,
'table_name' => '',
'from_type' => '',
];
}
$make = $this->services->makeFile($tableName, $routeName, false, [
'menuName' => '',
'key' => $key,
'fromField' => [],
'columnField' => [],
]);
$makePath = [];
foreach ($make as $k => $item) {
$makePath[$k] = $item['path'];
}
return app('json')->success(compact('makePath', 'tableField'));
}
/**
* @param $id
* @return Response
* @author 等风来
* @email 136327134@qq.com
* @date 2023/4/12
*/
public function read($id)
{
if (!$id) {
return app('json')->fail(500035);
}
$info = $this->services->get($id);
if (!$info) {
return app('json')->fail(100026);
}
$routeName = 'crud/' . Str::snake($info->table_name);
$column = $this->services->getColumnNamesList($info->table_name);
$key = 'id';
foreach ($column as $value) {
if ($value['primaryKey']) {
$key = $value['name'];
break;
}
}
$softDelete = false;
foreach ((array)$info->field['tableField'] as $item) {
if (isset($item['field_type']) && $item['field_type'] === 'addSoftDelete') {
$softDelete = true;
break;
}
}
$make = $this->services->makeFile($info->table_name, $routeName, false, [
'menuName' => $info->name,
'modelName' => $info->model_name,
'tableField' => $info->field['tableField'] ?? [],
'key' => $key,
'softDelete' => $softDelete,
'fromField' => $info->field['fromField'] ?? [],
'columnField' => $info->field['columnField'] ?? [],
'searchField' => $info->field['searchField'] ?? [],
'hasOneField' => $info->field['hasOneField'] ?? [],
]);
$data = [];
foreach ($make as $key => $item) {
if (in_array($key, ['pages', 'router', 'api'])) {
$path = Make::adminTemplatePath() . $item['path'];
} else {
$path = app()->getRootPath() . $item['path'];
}
$item['name'] = $item['path'];
try {
$item['content'] = file_get_contents($path, LOCK_EX);
$data[$key] = $item;
} catch (\Throwable $e) {
}
}
//调整排序
$makeData = [];
$names = [
'controller' => '控制器',
'validate' => '验证器',
'service' => '逻辑层',
'dao' => '数据库操作',
'model' => '模型层',
'route' => '后端路由',
'router' => '前端路由',
'api' => '前端接口',
'pages' => '前端页面'
];
foreach ($names as $name => $value) {
if (isset($data[$name])) {
$data[$name]['file_name'] = $value;
$makeData[] = $data[$name];
}
}
$data = $makeData;
$info = $info->toArray();
//记录没有修改之前的数据
foreach ((array)$info['field']['tableField'] as $key => $item) {
$item['default_field'] = $item['field'];
$item['default_limit'] = $item['limit'];
$item['default_field_type'] = $item['field_type'];
$item['default_comment'] = $item['comment'];
$item['default_default'] = $item['default'];
$item['default_default_type'] = $item['default_type'] ?? '1';
$item['default_type'] = $item['default_type'] ?? '1';
$item['is_table'] = !!$item['is_table'];
$item['required'] = !!$item['required'];
$item['index'] = isset($item['index']) && !!$item['index'];
$item['primaryKey'] = isset($item['primaryKey']) ? (int)$item['primaryKey'] : 0;
if (!isset($item['dictionary_id'])) {
$item['dictionary_id'] = 0;
}
$info['field']['tableField'][$key] = $item;
}
//对比数据库,是否有新增字段
$newColumn = [];
$fieldAll = array_column($info['field']['tableField'], 'field');
foreach ($column as $value) {
if (!in_array($value['name'], $fieldAll)) {
$newColumn[] = [
'field' => $value['name'],
'field_type' => $value['type'],
'primaryKey' => $value['primaryKey'] ? 1 : 0,
'default' => $value['default'],
'limit' => $value['limit'],
'comment' => $value['comment'],
'required' => '',
'is_table' => '',
'table_name' => '',
'from_type' => '',
'default_field' => $value['name'],
'default_limit' => $value['limit'],
'default_field_type' => $value['type'],
'default_comment' => $value['comment'],
'default_default' => $value['default'],
];
}
}
if ($newColumn) {
$info['field']['tableField'] = array_merge($newColumn, $info['field']['tableField']);
}
$keyInfo = $deleteInfo = $createInfo = $updateInfo = [];
$tableField = [];
foreach ($info['field']['tableField'] as $item) {
if ($item['primaryKey']) {
$keyInfo = $item;
continue;
}
if ($item['field_type'] == 'timestamp' && $item['field'] === 'delete_time') {
$deleteInfo = $item;
continue;
}
if ($item['field_type'] == 'timestamp' && $item['field'] === 'create_time') {
$createInfo = $item;
continue;
}
if ($item['field_type'] == 'timestamp' && $item['field'] === 'update_time') {
$updateInfo = $item;
continue;
}
$tableField[] = $item;
}
if ($keyInfo) {
array_unshift($tableField, $keyInfo);
}
if ($createInfo) {
array_push($tableField, $createInfo);
}
if ($updateInfo) {
array_push($tableField, $updateInfo);
}
if ($deleteInfo) {
array_push($tableField, $deleteInfo);
}
$info['field']['tableField'] = $tableField;
$info['field']['pid'] = (int)$info['field']['pid'];
return app('json')->success(['file' => $data, 'crudInfo' => $info]);
}
/**
* @param Request $request
* @param SystemFileServices $service
* @param $id
* @return Response
* @author 等风来
* @email 136327134@qq.com
* @date 2023/4/24
*/
public function savefile(Request $request, SystemFileServices $service, $id)
{
$comment = $request->param('comment');
$filepath = $request->param('filepath');
$pwd = $request->param('pwd');
if ($pwd == '') {
return app('json')->fail('请输入文件管理密码');
}
if (config('filesystem.password') != $pwd) {
return app('json')->fail('文件管理密码错误');
}
if (empty($filepath) || !$id) {
return app('json')->fail(410087);
}
$crudInfo = $this->services->get($id, ['make_path']);
if (!$crudInfo) {
return app('json')->fail('修改的CRUD文件不存在');
}
$makeFilepath = '';
foreach ($crudInfo->make_path as $key => $item) {
$path = $item;
if (in_array($key, ['pages', 'router', 'api'])) {
$item = Make::adminTemplatePath() . $item;
} else {
$item = app()->getRootPath() . $item;
}
if ($filepath == $path) {
$makeFilepath = $item;
break;
}
}
if (!$makeFilepath || !in_array($filepath, $crudInfo->make_path)) {
return app('json')->fail('您没有权限修改此文件');
}
$res = $service->savefile($makeFilepath, $comment);
if ($res) {
return app('json')->success(100000);
} else {
return app('json')->fail(100006);
}
}
/**
* 获取tree菜单
* @return Response
* @author 等风来
* @email 136327134@qq.com
* @date 2023/4/11
*/
public function getMenus()
{
return app('json')->success(app()->make(SystemMenusServices::class)
->getList(['auth_type' => 1, 'is_show' => 1], ['auth_type', 'pid', 'id', 'menu_name as label', 'id as value']));
}
/**
* 获取可以进行关联的表名
* @return Response
* @author 等风来
* @email 136327134@qq.com
* @date 2023/8/2
*/
public function getAssociationTable()
{
return app('json')->success($this->services->getTableAll());
}
/**
* 获取表的详细信息
* @param string $tableName
* @return Response
* @author 等风来
* @email 136327134@qq.com
* @date 2023/8/2
*/
public function getAssociationTableInfo(string $tableName)
{
if (!$tableName) {
return app('json')->fail('缺少表名');
}
// if (in_array($tableName, SystemCrudServices::NOT_CRUD_TABANAME)) {
// return app('json')->fail('不允许查看当前表明细');
// }
$tableInfo = $this->services->getColumnNamesList($tableName);
$data = [];
foreach ($tableInfo as $key => $item) {
$data[] = [
'label' => $item['comment'] ?: $key,
'value' => $key,
'leaf' => true
];
}
return app('json')->success($data);
}
/**
* 获取创建表数据类型
* @return Response
* @author 等风来
* @email 136327134@qq.com
* @date 2023/4/11
*/
public function columnType()
{
return app('json')->success($this->services->getTabelRule());
}
/**
* @param SystemMenusServices $services
* @param $id
* @return Response
* @author 等风来
* @email 136327134@qq.com
* @date 2023/4/11
*/
public function delete(SystemMenusServices $services, $id)
{
if (!$id) {
return app('json')->fail(500035);
}
$info = $this->services->get($id);
if (!$info) {
return app('json')->fail(100026);
}
$menusServices = app()->make(SystemMenusServices::class);
if ($info->menu_ids) {
$menusServices->deleteMenus($info->menu_ids);
}
if ($info->menu_id) {
$menusServices->deleteMenus([$info->menu_id]);
}
$routeServices = app()->make(SystemRouteServices::class);
if ($info->route_ids) {
$routeServices->deleteRoutes($info->route_ids);
}
Db::query("DROP TABLE `" . Env::get('database.prefix', 'eb_') . $info->table_name . "`");
if ($info->make_path) {
$errorFile = [];
foreach ($info->make_path as $key => $item) {
if (in_array($key, ['pages', 'router', 'api'])) {
$item = Make::adminTemplatePath() . $item;
} else {
$item = app()->getRootPath() . $item;
}
try {
unlink($item);
} catch (\Throwable $e) {
$errorFile[] = $item;
}
}
if ($errorFile) {
return app('json')->success(500040, [], [
'message' => '文件:' . implode("\n", $errorFile) . ';无法被删除!'
]);
}
}
$info->delete();
return app('json')->success(100002);
}
/**
* 下载文件
* @param $id
* @return Response
* @author 等风来
* @email 136327134@qq.com
* @date 2023/4/15
*/
public function download($id)
{
if (!$id) {
return app('json')->fail(500035);
}
$info = $this->services->get($id);
if (!$info) {
return app('json')->fail(100026);
}
$zipPath = app()->getRootPath() . 'backup' . DS . Str::camel($info->table_name);
$zipName = app()->getRootPath() . 'backup' . DS . Str::camel($info->table_name) . '.zip';
if (is_file($zipName)) {
unlink($zipName);
}
$makePath = $info->make_path ?? [];
foreach ($makePath as $key => $item) {
if (in_array($key, ['pages', 'router', 'api'])) {
$item = $zipPath . str_replace(dirname(app()->getRootPath()), '', Make::adminTemplatePath()) . $item;
} else {
$item = $zipPath . DS . 'crmeb' . DS . $item;
}
$makePath[$key] = $item;
}
$routeName = 'crud/' . Str::snake($info->table_name);
$column = $this->services->getColumnNamesList($info->table_name);
$key = 'id';
foreach ($column as $value) {
if ($value['primaryKey']) {
$key = $value['name'];
break;
}
}
$softDelete = false;
foreach ((array)$info->field['tableField'] as $item) {
if (isset($item['field_type']) && $item['field_type'] === 'addSoftDelete') {
$softDelete = true;
break;
}
}
$this->services->makeFile($info->table_name, $routeName, true, [
'menuName' => $info->name,
'tableFields' => $info->field['tableField'] ?? [],
'key' => $key,
'softDelete' => $softDelete,
'fromField' => $info->field['fromField'] ?? [],
'columnField' => $info->field['columnField'] ?? [],
'searchField' => $info->field['searchField'] ?? [],
'hasOneField' => $info->field['hasOneField'] ?? [],
], $makePath, $zipPath);
if (!extension_loaded('zip')) {
return app('json')->fail(500039);
}
$fileService = new FileService();
$fileService->addZip($zipPath, $zipName, app()->getRootPath() . 'backup');
$key = md5($zipName);
CacheService::set($key, [
'path' => $zipName,
'fileName' => Str::camel($info->table_name) . '.zip',
], 300);
return app('json')->success(['download_url' => sys_config('site_url') . '/adminapi/download/' . $key]);
}
/**
* 获取权限路由
* @param $tableName
* @return Response
* @author 等风来
* @email 136327134@qq.com
* @date 2023/4/20
*/
public function getRouteList($tableName)
{
$info = $this->services->get(['table_name' => $tableName]);
if (!$info) {
return app('json')->fail('crud详情查询失败');
}
$routeList = app()->make(SystemMenusServices::class)->getColumn([
['id', 'in', $info->menu_ids],
['auth_type', '=', 2]
], 'methods,api_url');
$newRoute = [];
foreach ($routeList as $item) {
if ($item['methods'] == 'GET') {
if (strstr($item['api_url'], 'create')) {
$newRoute['create'] = $item['api_url'];
} else if (strstr($item['api_url'], 'edit')) {
$newRoute['edit'] = $item['api_url'];
} else if (strstr($item['api_url'], 'status')) {
$newRoute['status'] = $item['api_url'];
} else {
if (strstr($item['api_url'], '<id>')) {
$newRoute['read'] = $item['api_url'];
} else {
$newRoute['index'] = $item['api_url'];
}
}
} else if ($item['methods'] == 'DELETE') {
$newRoute['delete'] = $item['api_url'];
} else if ($item['methods'] == 'PUT' && strstr($item['api_url'], 'status')) {
$newRoute['status'] = $item['api_url'];
}
}
$column = $this->services->getColumnNamesList($info->table_name);
$key = 'id';
foreach ($column as $value) {
if ($value['primaryKey']) {
$key = $value['name'];
break;
}
}
$columns = [
[
'title' => 'ID',
'key' => $key,
'from_type' => '',
]
];
$readFields = [
'name' => $info->field['modelName'] ?: $info->field['menuName'],
'all' => [],
];
foreach ((array)$info->field['tableField'] as $item) {
if (isset($item['primaryKey']) && $item['primaryKey']) {
continue;
}
$prefix = app()->make(Service::class)->getAttrPrefix();
$readFields['all'][] = [
'field' => in_array($item['from_type'], [FormTypeEnum::FRAME_IMAGES,
FormTypeEnum::DATE_TIME_RANGE,
FormTypeEnum::RADIO,
FormTypeEnum::SELECT,
FormTypeEnum::CHECKBOX]) ? $item['field'] . $prefix : $item['field'],
'comment' => $item['comment'],
'from_type' => $item['from_type'],
];
if (isset($item['is_table']) && $item['is_table']) {
$label = '';
if (in_array($item['from_type'], [FormTypeEnum::SWITCH, FormTypeEnum::DATE_TIME_RANGE, FormTypeEnum::FRAME_IMAGE_ONE, FormTypeEnum::FRAME_IMAGES])) {
$keyName = 'slot';
if ($item['from_type'] == FormTypeEnum::FRAME_IMAGES) {
$label = $prefix;
} else if ($item['from_type'] == FormTypeEnum::DATE_TIME_RANGE) {
$label = $prefix;
}
} elseif (in_array($item['from_type'], [FormTypeEnum::RADIO, FormTypeEnum::SELECT, FormTypeEnum::CHECKBOX])) {
$label = $prefix;
$keyName = 'key';
} else {
$keyName = 'key';
}
$columns[] = [
'title' => $item['table_name'] ?: $item['comment'],
$keyName => $item['field'] . $label,
'from_type' => $item['from_type'],
];
}
}
$searchField = $info->field['searchField'] ?? [];
$search = [];
foreach ((array)$searchField as $item) {
if (!$item['type']) {
$item['type'] = FormTypeEnum::INPUT;
}
if ($item['search'] == 'BETWEEN') {
$item['type'] = 'date-picker';
} else {
if (in_array($item['type'], [FormTypeEnum::CHECKBOX, FormTypeEnum::RADIO, FormTypeEnum::SELECT])) {
$item['type'] = FormTypeEnum::SELECT;
} else {
$item['type'] = FormTypeEnum::INPUT;
}
}
$search[] = [
'field' => $item['field'],
'type' => $item['type'],
'name' => $item['name'],
'option' => $item['options'] ?? [],
];
}
$route = $newRoute;
return app('json')->success(compact('key', 'route', 'columns', 'readFields', 'search'));
}
/**
* 修改或者保存字典数据
* @param SystemCrudDataService $service
* @param int $id
* @return Response
* @author 等风来
* @email 136327134@qq.com
* @date 2023/8/1
*/
public function saveDataDictionary(SystemCrudDataService $service, $id = 0)
{
$data = $this->request->postMore([
['name', ''],
['value', []],
]);
if (!$data['name']) {
return app('json')->fail('数据字段名不能为空');
}
if (!$data['value']) {
return app('json')->fail('数据字段内容不能为空');
}
$data['value'] = json_encode($data['value']);
if ($id) {
$service->update($id, $data);
} else {
$service->save($data);
}
return app('json')->success($id ? '修改成功' : '添加成功');
}
/**
* 查看数据字典
* @param SystemCrudDataService $service
* @param $id
* @return Response
* @author 等风来
* @email 136327134@qq.com
* @date 2023/8/7
*/
public function getDataDictionaryOne(SystemCrudDataService $service, $id)
{
if (!$id) {
return app('json')->fail('缺少参数');
}
$info = $service->get($id);
if (!$info) {
return app('json')->fail('没有查询到数据');
}
return app('json')->success($info->toArray());
}
/**
* 获取数据字典列表
* @param SystemCrudDataService $service
* @return Response
* @throws \ReflectionException
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author 等风来
* @email 136327134@qq.com
* @date 2023/8/1
*/
public function getDataDictionary(SystemCrudDataService $service)
{
$name = $this->request->get('name', '');
$data = $service->getlistAll($name);
return app('json')->success($data);
}
/**
* 删除数据字典
* @param SystemCrudDataService $service
* @param $id
* @return Response
* @author 等风来
* @email 136327134@qq.com
* @date 2023/8/4
*/
public function deleteDataDictionary(SystemCrudDataService $service, $id)
{
if (!$id) {
return app('json')->fail('缺少参数');
}
if ($service->delete($id)) {
return app('json')->success('删除成功');
} else {
return app('json')->fail('删除失败');
}
}
}

View File

@ -0,0 +1,215 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\adminapi\controller\v1\setting;
use app\services\system\config\SystemGroupDataServices;
use think\facade\App;
use app\adminapi\controller\AuthController;
use app\services\system\config\SystemGroupServices;
/**
* 组合数据
* Class SystemGroup
* @package app\adminapi\controller\v1\setting
*/
class SystemGroup extends AuthController
{
/**
* 构造方法
* SystemGroup constructor.
* @param App $app
* @param SystemGroupServices $services
*/
public function __construct(App $app, SystemGroupServices $services)
{
parent::__construct($app);
$this->services = $services;
}
/**
* 显示资源列表
*
* @return \think\Response
*/
public function index()
{
$where = $this->request->getMore([
['title', '']
]);
return app('json')->success($this->services->getGroupList($where));
}
/**
* 显示创建资源表单页.
*
* @return \think\Response
*/
public function create()
{
//
}
/**
* 保存新建的资源
*
* @return \think\Response
*/
public function save()
{
$params = $this->request->postMore([
['name', ''],
['config_name', ''],
[['cate_id', 'd'], 0],
['info', ''],
['typelist', []],
]);
//数据组名称判断
if (!$params['name']) {
return app('json')->fail(400187);
}
if (!$params['config_name']) {
return app('json')->fail(400274);
}
$data["name"] = $params['name'];
$data["config_name"] = $params['config_name'];
$data["info"] = $params['info'];
$data["cate_id"] = $params['cate_id'];
//字段信息判断
if (!count($params['typelist']))
return app('json')->fail(400294);
else {
$validate = ["name", "type", "title", "description"];
foreach ($params["typelist"] as $key => $value) {
foreach ($value as $name => $field) {
if (empty($field["value"]) && in_array($name, $validate))
return app('json')->fail("字段" . ($key + 1) . "" . $field["placeholder"] . "不能为空!");
else
$data["fields"][$key][$name] = $field["value"];
}
}
}
$data["fields"] = json_encode($data["fields"]);
$this->services->save($data);
\crmeb\services\CacheService::clear();
return app('json')->success(400295);
}
/**
* 显示指定的资源
*
* @param int $id
* @return \think\Response
*/
public function read($id)
{
$info = $this->services->get($id);
$fields = json_decode($info['fields'], true);
$type_list = [];
foreach ($fields as $key => $v) {
$type_list[$key]['name']['value'] = $v['name'];
$type_list[$key]['title']['value'] = $v['title'];
$type_list[$key]['type']['value'] = $v['type'];
$type_list[$key]['param']['value'] = $v['param'];
}
$info['typelist'] = $type_list;
unset($info['fields']);
return app('json')->success(compact('info'));
}
/**
* 显示编辑资源表单页.
*
* @param int $id
* @return \think\Response
*/
public function edit($id)
{
//
}
/**
* 保存更新的资源
*
* @param int $id
* @return \think\Response
*/
public function update($id)
{
$params = $this->request->postMore([
['name', ''],
['config_name', ''],
[['cate_id', 'd'], 0],
['info', ''],
['typelist', []],
]);
//数据组名称判断
if (!$params['name']) return app('json')->fail(400187);
if (!$params['config_name']) return app('json')->fail(400274);
//判断ID是否存在存在就是编辑不存在就是添加
if (!$id) {
if ($this->services->count(['config_name' => $params['config_name']])) {
return app('json')->fail(400296);
}
}
$data["name"] = $params['name'];
$data["config_name"] = $params['config_name'];
$data["info"] = $params['info'];
$data["cate_id"] = $params['cate_id'];
//字段信息判断
if (!count($params['typelist']))
return app('json')->fail(400294);
else {
$validate = ["name", "type", "title", "description"];
foreach ($params["typelist"] as $key => $value) {
foreach ($value as $name => $field) {
if (empty($field["value"]) && in_array($name, $validate))
return app('json')->fail(400297);
else
$data["fields"][$key][$name] = $field["value"];
}
}
}
$data["fields"] = json_encode($data["fields"]);
$this->services->update($id, $data);
\crmeb\services\CacheService::clear();
return app('json')->success(400295);
}
/**
* 删除指定资源
*
* @param int $id
* @return \think\Response
*/
public function delete($id, SystemGroupDataServices $services)
{
if (!$this->services->delete($id))
return app('json')->fail(100008);
else {
$services->delete($id, 'gid');
return app('json')->success(100002);
}
}
/**
* 获取组合数据
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function getGroup()
{
return app('json')->success($this->services->getGroupList(['cate_id' => 1], ['id', 'name', 'config_name'])['list']);
}
}

View File

@ -0,0 +1,324 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\adminapi\controller\v1\setting;
use crmeb\exceptions\AdminException;
use app\services\other\CacheServices;
use think\facade\App;
use app\adminapi\controller\AuthController;
use app\services\system\config\SystemGroupDataServices;
use app\services\system\config\SystemGroupServices;
/**
* 数据管理
* Class SystemGroupData
* @package app\adminapi\controller\v1\setting
*/
class SystemGroupData extends AuthController
{
/**
* 构造方法
* SystemGroupData constructor.
* @param App $app
* @param SystemGroupDataServices $services
*/
public function __construct(App $app, SystemGroupDataServices $services)
{
parent::__construct($app);
$this->services = $services;
}
/**
* 获取数据列表头
* @return mixed
*/
public function header(SystemGroupServices $services)
{
[$gid, $config_name] = $this->request->getMore([
['gid', 0],
['config_name', '']
], true);
if (!$gid && !$config_name) return app('json')->fail(100100);
if (!$gid) {
$gid = $services->value(['config_name' => $config_name], 'id');
}
return app('json')->success($services->getGroupDataTabHeader($gid));
}
/**
* 显示资源列表
*
* @return \think\Response
*/
public function index(SystemGroupServices $group)
{
$where = $this->request->getMore([
['gid', 0],
['status', ''],
['config_name', '']
]);
if (!$where['gid'] && !$where['config_name']) return app('json')->fail(100100);
if (!$where['gid']) {
$where['gid'] = $group->value(['config_name' => $where['config_name']], 'id');
}
unset($where['config_name']);
return app('json')->success($this->services->getGroupDataList($where));
}
/**
* 显示创建资源表单页.
*
* @return \think\Response
*/
public function create()
{
$gid = $this->request->param('gid/d');
if ($this->services->isGroupGidSave($gid, 4, 'index_categy_images')) {
return app('json')->fail(400298);
}
if ($this->services->isGroupGidSave($gid, 7, 'sign_day_num')) {
return app('json')->fail(400299);
}
return app('json')->success($this->services->createForm($gid));
}
/**
* 保存新建的资源
*
* @return \think\Response
*/
public function save(SystemGroupServices $services)
{
$params = request()->post();
$gid = (int)$params['gid'];
$group = $services->getOne(['id' => $gid], 'id,config_name,fields');
if ($group && $group['config_name'] == 'order_details_images') {
$groupDatas = $this->services->getColumn(['gid' => $gid], 'value', 'id');
foreach ($groupDatas as $groupData) {
$groupData = json_decode($groupData, true);
if (isset($groupData['order_status']['value']) && $groupData['order_status']['value'] == $params['order_status']) {
return app('json')->fail(400188);
}
}
}
if ($group && $group['config_name'] == 'user_recharge_quota') {
if ($params['price'] <= 0) return app('json')->fail('售价必须大于0');
if ($params['give_money'] < 0) return app('json')->fail('赠送不能小于0');
}
$this->services->checkSeckillTime($services, $gid, $params);
$this->checkSign($services, $gid, $params);
$fields = json_decode($group['fields'], true) ?? [];
$value = [];
foreach ($params as $key => $param) {
foreach ($fields as $index => $field) {
if ($key == $field["title"]) {
if ($param == "")
return app('json')->fail(400297);
else {
$value[$key]["type"] = $field["type"];
$value[$key]["value"] = $param;
}
}
}
}
$data = [
"gid" => $params['gid'],
"add_time" => time(),
"value" => json_encode($value),
"sort" => $params["sort"] ?: 0,
"status" => $params["status"]
];
$this->services->save($data);
\crmeb\services\CacheService::clear();
return app('json')->success(400189);
}
/**
* 显示指定的资源
*
* @param int $id
* @return \think\Response
*/
public function read($id)
{
//
}
/**
* 显示编辑资源表单页.
*
* @param int $id
* @return \think\Response
*/
public function edit($id)
{
$gid = $this->request->param('gid/d');
if (!$gid) {
return app('json')->fail(100100);
}
return app('json')->success($this->services->updateForm((int)$gid, (int)$id));
}
/**
* 保存更新的资源
*
* @param \think\Request $request
* @param int $id
* @return \think\Response
*/
public function update(SystemGroupServices $services, $id)
{
$groupData = $this->services->get($id);
$fields = $services->getValueFields((int)$groupData["gid"]);
$params = request()->post();
$group = $services->getOne(['id' => $params['gid']], 'id,config_name,fields');
if ($group && $group['config_name'] == 'user_recharge_quota') {
if ($params['price'] <= 0) return app('json')->fail('售价必须大于0');
if ($params['give_money'] < 0) return app('json')->fail('赠送不能小于0');
}
$this->services->checkSeckillTime($services, $groupData["gid"], $params, $id);
$this->checkSign($services, $groupData["gid"], $params);
$value = [];
foreach ($params as $key => $param) {
foreach ($fields as $index => $field) {
if ($key == $field["title"]) {
if ($param == '')
return app('json')->fail(400297);
else {
$value[$key]["type"] = $field["type"];
$value[$key]["value"] = $param;
}
}
}
}
$data = [
"value" => json_encode($value),
"sort" => $params["sort"],
"status" => $params["status"]
];
$this->services->update($id, $data);
\crmeb\services\CacheService::clear();
return app('json')->success(100001);
}
/**
* 删除指定资源
*
* @param int $id
* @return \think\Response
*/
public function delete($id)
{
if (!$this->services->delete($id))
return app('json')->fail(100008);
else {
\crmeb\services\CacheService::clear();
return app('json')->success(100002);
}
}
/**
* 修改状态
* @param $id
* @param $status
* @return mixed
*/
public function set_status($id, $status)
{
if ($status == '' || $id == 0) return app('json')->fail(100100);
$this->services->update($id, ['status' => $status]);
\crmeb\services\CacheService::clear();
return app('json')->success(100014);
}
/**
* 检查签到配置
* @param SystemGroupServices $services
* @param $gid
* @param $params
* @param int $id
* @return mixed
*/
public function checkSign(SystemGroupServices $services, $gid, $params, $id = 0)
{
$name = $services->value(['id' => $gid], 'config_name');
if ($name == 'sign_day_num') {
if (!$params['sign_num']) {
throw new AdminException(400196);
}
if (!preg_match('/^\+?[1-9]\d*$/', $params['sign_num'])) {
throw new AdminException(400197);
}
}
}
/**
* 获取客服页面广告内容
* @return mixed
*/
public function getKfAdv()
{
/** @var CacheServices $cache */
$cache = app()->make(CacheServices::class);
$content = $cache->getDbCache('kf_adv', '');
return app('json')->success(compact('content'));
}
/**
* 设置客服页面广告内容
* @return mixed
*/
public function setKfAdv()
{
$content = $this->request->post('content');
/** @var CacheServices $cache */
$cache = app()->make(CacheServices::class);
$cache->setDbCache('kf_adv', $content);
return app('json')->success(100014);
}
public function saveAll()
{
$params = request()->post();
if (!isset($params['config_name']) || !isset($params['data'])) {
return app('json')->fail(100100);
}
$this->services->saveAllData($params['data'], $params['config_name']);
return app('json')->success(400295);
}
/**
* 获取用户协议内容
* @return mixed
*/
public function getUserAgreement()
{
/** @var CacheServices $cache */
$cache = app()->make(CacheServices::class);
$content = $cache->getDbCache('user_agreement', '');
return app('json')->success(compact('content'));
}
/**
* 设置用户协议内容
* @return mixed
*/
public function setUserAgreement()
{
$content = $this->request->post('content');
/** @var CacheServices $cache */
$cache = app()->make(CacheServices::class);
$cache->setDbCache('user_agreement', $content);
return app('json')->success(100014);
}
}

View File

@ -0,0 +1,339 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\adminapi\controller\v1\setting;
use app\adminapi\controller\AuthController;
use app\services\system\SystemMenusServices;
use app\services\system\SystemRouteCateServices;
use app\services\system\SystemRouteServices;
use think\facade\App;
use think\facade\Route;
/**
* 菜单权限
* Class SystemMenus
* @package app\adminapi\controller\v1\setting
*/
class SystemMenus extends AuthController
{
/**
* SystemMenus constructor.
* @param App $app
* @param SystemMenusServices $services
*/
public function __construct(App $app, SystemMenusServices $services)
{
parent::__construct($app);
$this->services = $services;
$this->request->filter(['addslashes', 'trim']);
}
/**
* 菜单展示列表
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author 吴汐
* @email 442384644@qq.com
* @date 2023/05/06
*/
public function index()
{
$where = $this->request->getMore([
['is_show', ''],
['keyword', ''],
['auth_type', ''],
]);
return app('json')->success($this->services->getList($where));
}
/**
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author 等风来
* @email 136327134@qq.com
* @date 2023/4/14
*/
public function unique()
{
$adminInfo = $this->request->adminInfo();
[$menus, $uniqueAuth] = app()->make(SystemMenusServices::class)->getMenusList($adminInfo['roles'], (int)$adminInfo['level']);
return app('json')->success(compact('menus', 'uniqueAuth'));
}
/**
* 显示创建资源表单页.
*
* @return \think\Response
*/
public function create()
{
return app('json')->success($this->services->createMenus());
}
/**
* 保存菜单权限
* @return mixed
*/
public function save()
{
$data = $this->request->getMore([
['menu_name', ''],
['controller', ''],
['module', 'admin'],
['action', ''],
['icon', ''],
['params', ''],
['path', []],
['menu_path', ''],
['api_url', ''],
['methods', ''],
['unique_auth', ''],
['header', ''],
['is_header', 0],
['pid', 0],
['sort', 0],
['auth_type', 0],
['access', 1],
['is_show', 0],
['is_show_path', 0],
]);
$data['is_show_path'] = $data['is_show'];
if (!$data['menu_name'])
return app('json')->fail(400198);
$data['path'] = implode('/', $data['path']);
if ($this->services->save($data)) {
return app('json')->success(100021);
} else {
return app('json')->fail(100022);
}
}
/**
* 批量保存权限
* @return \think\Response
* @author 等风来
* @email 136327134@qq.com
* @date 2023/4/11
*/
public function batchSave()
{
$menus = $this->request->post('menus', []);
if (!$menus) {
return app('json')->fail(100026);
}
$data = [];
$uniqueAuthAll = $this->services->getColumn(['is_del' => 0, 'is_show' => 1], 'unique_auth');
$uniqueAuthAll = array_filter($uniqueAuthAll, function ($item) {
return !!$item;
});
$uniqueAuthAll = array_unique($uniqueAuthAll);
$uniqueFn = function ($path) use ($uniqueAuthAll) {
$attPath = explode('/', $path);
$uniqueAuth = '';
if ($attPath) {
$pathData = [];
foreach ($attPath as $vv) {
if (strstr($vv, '<') === false) {
$pathData[] = $vv;
}
}
$uniqueAuth = implode('-', $pathData);
}
if (in_array($uniqueAuth, $uniqueAuthAll)) {
$uniqueAuth .= '-' . uniqid();
}
array_push($uniqueAuthAll, $uniqueAuth);
return $uniqueAuth;
};
foreach ($menus as $menu) {
if (empty($menu['menu_name'])) {
return app('json')->fail(400198);
}
if (isset($menu['unique_auth']) && $menu['unique_auth']) {
$menu['unique_auth'] = explode('/', $menu['api_url']);
}
$data[] = [
'methods' => $menu['method'],
'menu_name' => $menu['menu_name'],
'unique_auth' => !empty($menu['unique_auth']) ? $menu['unique_auth'] : $uniqueFn($menu['api_url']),
'api_url' => $menu['api_url'],
'pid' => $menu['path'],
'auth_type' => 2,
'is_show' => 1,
'is_show_path' => 1,
];
}
$this->services->saveAll($data);
return app('json')->success(100021);
}
/**
* 获取一条菜单权限信息
* @param int $id
* @return \think\Response
*/
public function read($id)
{
if (!$id) {
return app('json')->fail(100026);
}
return app('json')->success($this->services->find((int)$id));
}
/**
* 修改菜单权限表单获取
* @param int $id
* @return \think\Response
*/
public function edit($id)
{
if (!$id) {
return app('json')->fail(100100);
}
return app('json')->success($this->services->updateMenus((int)$id));
}
/**
* 修改菜单
* @param $id
* @return mixed
*/
public function update($id)
{
if (!$id || !($menu = $this->services->get($id)))
return app('json')->fail(100026);
$data = $this->request->postMore([
'menu_name',
'controller',
['module', 'admin'],
'action',
'params',
['icon', ''],
['menu_path', ''],
['api_url', ''],
['methods', ''],
['unique_auth', ''],
['path', []],
['sort', 0],
['pid', 0],
['is_header', 0],
['header', ''],
['auth_type', 0],
['access', 1],
['is_show', 0],
['is_show_path', 0],
]);
if (!$data['menu_name'])
return app('json')->fail(400198);
$data['path'] = implode('/', $data['path']);
if ($this->services->update($id, $data))
return app('json')->success(100001);
else
return app('json')->fail(100007);
}
/**
* 删除指定资源
*
* @param int $id
* @return \think\Response
*/
public function delete($id)
{
if (!$id) {
return app('json')->fail(100100);
}
if (!$this->services->delete((int)$id)) {
return app('json')->fail(100008);
} else {
return app('json')->success(100002);
}
}
/**
* 权限的开启和关闭,显示和隐藏
* @param $id
* @return mixed
*/
public function show($id)
{
if (!$id) {
return app('json')->fail(100100);
}
[$isShow, $isShowPath] = $this->request->postMore([['is_show', 0], ['is_show_path', 0]], true);
if ($isShow == -1) {
$res = $this->services->update($id, ['is_show_path' => $isShowPath]);
} else {
$res = $this->services->update($id, ['is_show' => $isShow, 'is_show_path' => $isShow]);
}
if ($res) {
return app('json')->success(100001);
} else {
return app('json')->fail(100007);
}
}
/**
* 获取菜单数据
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function menus()
{
[$menus, $unique] = $this->services->getMenusList($this->adminInfo['roles'], (int)$this->adminInfo['level']);
return app('json')->success(['menus' => $menus, 'unique' => $unique]);
}
/**
* 获取路由分类
* @param SystemRouteCateServices $service
* @return \think\Response
* @author 等风来
* @email 136327134@qq.com
* @date 2023/4/25
*/
public function ruleCate(SystemRouteCateServices $service)
{
return app('json')->success($service->getAllList('adminapi'));
}
/**
* 获取接口列表
* @return array
*/
public function ruleList(SystemRouteServices $services)
{
$cateId = request()->get('cate_id', 0);
//获取所有的路由
$ruleList = $services->selectList(['cate_id' => $cateId, 'app_name' => 'adminapi'])->toArray();
return app('json')->success($ruleList);
}
}

View File

@ -0,0 +1,124 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\adminapi\controller\v1\setting;
use app\adminapi\controller\AuthController;
use app\services\message\SystemNotificationServices;
use crmeb\services\CacheService;
use think\facade\App;
/**
* Class SystemRole
* @package app\adminapi\controller\v1\setting
*/
class SystemNotification extends AuthController
{
/**
* SystemRole constructor.
* @param App $app
* @param SystemNotificationServices $services
*/
public function __construct(App $app, SystemNotificationServices $services)
{
parent::__construct($app);
$this->services = $services;
}
/**
* 显示资源列表
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function index()
{
$where = $this->request->getMore([
['type', ''],
]);
return app('json')->success($this->services->getNotList($where));
}
/**
* 显示编辑
* @return \think\Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function info()
{
$where = $this->request->getMore([
['type', ''],
['id', 0]
]);
if (!$where['id']) return app('json')->fail(100100);
return app('json')->success($this->services->getNotInfo($where));
}
/**
* 保存新建的资源
* @return mixed
* @throws \Psr\SimpleCache\InvalidArgumentException
*/
public function save()
{
$data = $this->request->postMore([
['id', 0],
['type', ''],
['name', ''],
['title', ''],
['is_system', 0],
['is_app', 0],
['is_wechat', 0],
['is_routine', 0],
['is_sms', 0],
['is_ent_wechat', 0],
['system_title', ''],
['system_text', ''],
['tempid', ''],
['ent_wechat_text', ''],
['url', ''],
['wechat_id', ''],
['routine_id', ''],
['mark', ''],
['sms_id', ''],
]);
if ($data['mark'] == 'verify_code') $data['type'] = 'is_sms';
if (!$data['id']) return app('json')->fail(100100);
if ($this->services->saveData($data)) {
CacheService::clear();
return app('json')->success(100001);
} else {
return app('json')->fail(100007);
}
}
/**
* 修改消息状态
* @param $type
* @param $status
* @param $id
* @return mixed
* @throws \Psr\SimpleCache\InvalidArgumentException
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function set_status($type, $status, $id)
{
if ($type == '' || $status == '' || $id == 0) return app('json')->fail(100100);
$this->services->update($id, [$type => $status]);
$res = $this->services->getOneNotce(['id' => $id]);
CacheService::clear();
return app('json')->success(100014);
}
}

View File

@ -0,0 +1,155 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\adminapi\controller\v1\setting;
use app\adminapi\controller\AuthController;
use app\services\system\admin\SystemAdminServices;
use app\services\system\admin\SystemRoleServices;
use app\services\system\SystemMenusServices;
use crmeb\services\CacheService;
use think\facade\App;
/**
* Class SystemRole
* @package app\adminapi\controller\v1\setting
*/
class SystemRole extends AuthController
{
/**
* SystemRole constructor.
* @param App $app
* @param SystemRoleServices $services
*/
public function __construct(App $app, SystemRoleServices $services)
{
parent::__construct($app);
$this->services = $services;
}
/**
* 显示资源列表
* @return mixed
*/
public function index()
{
$where = $this->request->getMore([
['status', ''],
['role_name', ''],
]);
$where['level'] = $this->adminInfo['level'] + 1;
return app('json')->success($this->services->getRoleList($where));
}
/**
* 显示创建资源表单页
* @param SystemMenusServices $services
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function create(SystemMenusServices $services)
{
$menus = $services->getmenus($this->adminInfo['level'] == 0 ? [] : $this->adminInfo['roles']);
return app('json')->success(compact('menus'));
}
/**
* 保存新建的资源
*
* @return \think\Response
*/
public function save($id)
{
$data = $this->request->postMore([
'role_name',
['status', 0],
['checked_menus', [], '', 'rules']
]);
if (!$data['role_name']) return app('json')->fail(400220);
if (!is_array($data['rules']) || !count($data['rules']))
return app('json')->fail(400221);
$data['rules'] = implode(',', $data['rules']);
if ($id) {
if (!$this->services->update($id, $data)) return app('json')->fail(100007);
CacheService::clear();
return app('json')->success(100001);
} else {
$data['level'] = $this->adminInfo['level'] + 1;
if (!$this->services->save($data)) return app('json')->fail(400223);
CacheService::clear();
return app('json')->success(400222);
}
}
/**
* 显示编辑资源表单页
* @param SystemMenusServices $services
* @param $id
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function edit(SystemMenusServices $services, $id)
{
$role = $this->services->get($id);
if (!$role) {
return app('json')->fail(100100);
}
$menus = $services->getMenus($this->adminInfo['level'] == 0 ? [] : $this->adminInfo['roles'], explode(',', $role['rules']));
return app('json')->success(['role' => $role->toArray(), 'menus' => $menus]);
}
/**
* 删除指定资源
* @param SystemAdminServices $adminServices
* @param $id
* @return mixed
*/
public function delete(SystemAdminServices $adminServices, $id)
{
if ($adminServices->checkRoleUse($id)) {
return app('json')->fail(400754);
}
if (!$this->services->delete($id))
return app('json')->fail(100008);
else {
CacheService::clear();
return app('json')->success(100002);
}
}
/**
* 修改状态
* @param $id
* @param $status
* @return mixed
*/
public function set_status($id, $status)
{
if (!$id) {
return app('json')->fail(100100);
}
$role = $this->services->get($id);
if (!$role) {
return app('json')->fail(400199);
}
$role->status = $status;
if ($role->save()) {
CacheService::clear();
return app('json')->success(100001);
} else {
return app('json')->fail(100007);
}
}
}

View File

@ -0,0 +1,169 @@
<?php
/**
* +----------------------------------------------------------------------
* | CRMEB [ CRMEB赋能开发者助力企业发展 ]
* +----------------------------------------------------------------------
* | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
* +----------------------------------------------------------------------
* | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
* +----------------------------------------------------------------------
* | Author: CRMEB Team <admin@crmeb.com>
* +----------------------------------------------------------------------
*/
namespace app\adminapi\controller\v1\setting;
use app\adminapi\controller\AuthController;
use app\services\system\SystemRouteServices;
use crmeb\services\CacheService;
use think\facade\App;
/**
* Class SystemRoute
* @author 等风来
* @email 136327134@qq.com
* @date 2023/4/6
* @package app\adminapi\controller\v1\setting
*/
class SystemRoute extends AuthController
{
/**
* SystemRoute constructor.
* @param App $app
* @param SystemRouteServices $services
*/
public function __construct(App $app, SystemRouteServices $services)
{
parent::__construct($app);
$this->services = $services;
}
/**
* 同步路由权限
* @param string $appName
* @return \think\Response
* @author 等风来
* @email 136327134@qq.com
* @date 2023/4/6
*/
public function syncRoute(string $appName = 'adminapi')
{
$this->services->syncRoute($appName);
return app('json')->success(100038);
}
/**
* 列表数据
* @return \think\Response
* @author 等风来
* @email 136327134@qq.com
* @date 2023/4/7
*/
public function index()
{
$where = $this->request->getMore([
['name_like', ''],
['app_name', 'adminapi']
]);
return app('json')->success($this->services->getList($where));
}
/**
* tree数据
* @return \think\Response
* @author 等风来
* @email 136327134@qq.com
* @date 2023/4/7
*/
public function tree()
{
[$name, $appName] = $this->request->getMore([
['name_like', ''],
['app_name', 'adminapi']
], true);
return app('json')->success($this->services->getTreeList($appName, $name));
}
/**
* @return \think\Response
* @author 等风来
* @email 136327134@qq.com
* @date 2023/4/7
*/
public function save($id = 0)
{
$data = $this->request->postMore([
['cate_id', 0],
['name', ''],
['path', ''],
['method', ''],
['type', 0],
['app_name', ''],
['query', []],
['header', []],
['request', []],
['response', []],
['request_example', []],
['response_example', []],
['describe', ''],
]);
// if (!$data['name']) {
// return app('json')->fail(500031);
// }
// if (!$data['path']) {
// return app('json')->fail(500032);
// }
// if (!$data['method']) {
// return app('json')->fail(500033);
// }
// if (!$data['app_name']) {
// return app('json')->fail(500034);
// }
if ($id) {
$this->services->update($id, $data);
} else {
$data['add_time'] = date('Y-m-d H:i:s');
$this->services->save($data);
}
CacheService::clear();
return app('json')->success($id ? 100001 : 100021);
}
/**
* @param $id
* @return \think\Response
* @author 等风来
* @email 136327134@qq.com
* @date 2023/4/7
*/
public function read($id)
{
return app('json')->success($this->services->getInfo((int)$id));
}
/**
* @param $id
* @return \think\Response
* @author 等风来
* @email 136327134@qq.com
* @date 2023/4/7
*/
public function delete($id)
{
if (!$id) {
return app('json')->fail(500035);
}
$this->services->destroy($id);
return app('json')->success(100002);
}
}

View File

@ -0,0 +1,156 @@
<?php
/**
* +----------------------------------------------------------------------
* | CRMEB [ CRMEB赋能开发者助力企业发展 ]
* +----------------------------------------------------------------------
* | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
* +----------------------------------------------------------------------
* | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
* +----------------------------------------------------------------------
* | Author: CRMEB Team <admin@crmeb.com>
* +----------------------------------------------------------------------
*/
namespace app\adminapi\controller\v1\setting;
use app\adminapi\controller\AuthController;
use app\services\system\SystemRouteCateServices;
use app\services\system\SystemRouteServices;
use think\facade\App;
use think\Request;
/**
* Class SystemRouteCate
* @author 等风来
* @email 136327134@qq.com
* @date 2023/4/6
* @package app\adminapi\controller\v1\setting
*/
class SystemRouteCate extends AuthController
{
/**
* SystemRouteCate constructor.
* @param App $app
* @param SystemRouteCateServices $services
*/
public function __construct(App $app, SystemRouteCateServices $services)
{
parent::__construct($app);
$this->services = $services;
}
/**
* @return \think\Response
* @author 等风来
* @email 136327134@qq.com
* @date 2023/4/6
*/
public function index()
{
return app('json')->success($this->services->getAllList());
}
/**
* @return \think\Response
* @author 等风来
* @email 136327134@qq.com
* @date 2023/4/6
*/
public function create()
{
return app('json')->success($this->services->getFrom(0, $this->request->get('app_name', 'adminapi')));
}
/**
* @param Request $request
* @return \think\Response
* @author 等风来
* @email 136327134@qq.com
* @date 2023/4/6
*/
public function save(Request $request)
{
$data = $request->postMore([
['path', []],
['name', ''],
['sort', 0],
['app_name', ''],
]);
if (!$data['name']) {
return app('json')->fail(500037);
}
$data['add_time'] = time();
$data['pid'] = $data['path'][count($data['path']) - 1] ?? 0;
$this->services->save($data);
return app('json')->success(100000);
}
/**
* @param $id
* @return \think\Response
* @author 等风来
* @email 136327134@qq.com
* @date 2023/4/6
*/
public function edit($id)
{
return app('json')->success($this->services->getFrom($id, $this->request->get('app_name', 'adminapi')));
}
/**
* @param Request $request
* @param $id
* @return \think\Response
* @author 等风来
* @email 136327134@qq.com
* @date 2023/4/6
*/
public function update(Request $request, $id)
{
$data = $request->postMore([
['path', []],
['name', ''],
['sort', 0],
['app_name', ''],
]);
if (!$data['name']) {
return app('json')->fail(500037);
}
$data['pid'] = $data['path'][count($data['path']) - 1] ?? 0;
$this->services->update($id, $data);
return app('json')->success(100001);
}
/**
* @param SystemRouteServices $service
* @param $id
* @return \think\Response
* @author 等风来
* @email 136327134@qq.com
* @date 2023/4/6
*/
public function delete(SystemRouteServices $service, $id)
{
if (!$id) {
return app('json')->fail(500035);
}
if ($service->count(['cate_id' => $id])) {
return app('json')->fail(500038);
}
$this->services->delete($id);
return app('json')->success(100002);
}
}

View File

@ -0,0 +1,261 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\adminapi\controller\v1\setting;
use app\adminapi\controller\AuthController;
use app\services\system\config\SystemConfigServices;
use app\services\system\config\SystemStorageServices;
use app\services\other\UploadService;
use think\facade\App;
/**
* Class SystemStorage
* @package app\adminapi\controller\v1\setting
*/
class SystemStorage extends AuthController
{
/**
* SystemStorage constructor.
* @param App $app
* @param SystemStorageServices $services
*/
public function __construct(App $app, SystemStorageServices $services)
{
parent::__construct($app);
$this->services = $services;
}
/**
* @return mixed
*/
public function index()
{
return app('json')->success($this->services->getList(['type' => $this->request->get('type')]));
}
/**
* 获取创建数据表单
* @param $type
* @return mixed
* @throws \FormBuilder\Exception\FormBuilderException
*/
public function create($type)
{
if (!$type) {
return app('json')->fail(100100);
}
return app('json')->success($this->services->getFormStorage((int)$type));
}
/**
* 获取配置表单
* @param $type
* @return mixed
* @throws \FormBuilder\Exception\FormBuilderException
*/
public function getConfigForm($type)
{
return app('json')->success($this->services->getFormStorageConfig((int)$type));
}
/**
* 获取配置类型
* @return mixed
*/
public function getConfig()
{
return app('json')->success(['type' => (int)sys_config('upload_type', 1)]);
}
/**
* @return mixed
*/
public function saveConfig( )
{
$type = (int)$this->request->post('type', 0);
$data = $this->request->postMore([
['accessKey', ''],
['secretKey', ''],
['appid', ''],
['storageRegion', ''],
]);
$this->services->saveConfig((int)$type, $data);
return app('json')->success(100000);
}
/**
* @param $type
* @return mixed
*/
public function synch($type)
{
$this->services->synchronization((int)$type);
return app('json')->success(100038);
}
/**
* 保存类型
* @param $type
* @return mixed
*/
public function save($type)
{
$data = $this->request->postMore([
['accessKey', ''],
['secretKey', ''],
['appid', ''],
['name', ''],
['region', ''],
['acl', ''],
]);
$type = (int)$type;
if ($type === 4) {
if (!$data['appid'] && !sys_config('tengxun_appid')) {
return app('json')->fail(400224);
}
}
if (!$data['accessKey']) {
unset($data['accessKey'], $data['secretKey'], $data['appid']);
}
$this->services->saveStorage((int)$type, $data);
return app('json')->success(100021);
}
/**
* 修改状态
* @param SystemConfigServices $services
* @param $id
* @return mixed
*/
public function status(SystemConfigServices $services, $id)
{
if (!$id) {
return app('json')->fail(100100);
}
$info = $this->services->get($id);
$info->status = 1;
if (!$info->domain) {
return app('json')->fail(400225);
}
// $services->update('upload_type', ['value' => json_encode($info->type)], 'menu_name');
\crmeb\services\CacheService::clear();
//设置跨域规则
try {
$upload = UploadService::init($info->type);
$res = $upload->setBucketCors($info->name, $info->region);
if (false === $res) {
return app('json')->fail($upload->getError());
}
} catch (\Throwable $e) {
}
//修改状态
$this->services->transaction(function () use ($id, $info) {
// $this->services->update(['status' => 1, 'is_delete' => 0], ['status' => 0]);
$this->services->update(['type' => $info->type], ['status' => 0]);
$info->save();
});
return app('json')->success(100001);
}
/**
* @param $id
* @return mixed
* @throws \FormBuilder\Exception\FormBuilderException
*/
public function getUpdateDomainForm($id)
{
return app('json')->success($this->services->getUpdateDomainForm((int)$id));
}
/**
* @param $id
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function updateDomain($id)
{
$domain = $this->request->post('domain', '');
$cdn = $this->request->post('cdn', '');
$data = $this->request->postMore([
['pri', ''],
['ca', '']
]);
if (!$domain) {
return app('json')->fail(100100);
}
if (strstr($domain, 'https://') === false && strstr($domain, 'http://') === false) {
return app('json')->fail(400226);
}
// if (strstr($domain, 'https://') !== false && !$data['pri']) {
// return app('json')->fail('域名为HTTPS访问时必须填写证书');
// }
$this->services->updateDomain($id, $domain, ['cdn' => $cdn]);
return app('json')->success(100001);
}
/**
* 删除
* @param $id
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function delete($id)
{
if (!$id) {
return app('json')->fail(100100);
}
if ($this->services->deleteStorage($id)) {
return app('json')->success(100002);
} else {
return app('json')->fail(100008);
}
}
/**
* 切换存储类型
* @param SystemConfigServices $services
* @param $type
* @return mixed
*/
public function uploadType(SystemConfigServices $services, $type)
{
$status = $this->services->count(['type' => $type, 'status' => 1]);
if (!$status && $type != 1) {
return app('json')->success(400227);
}
$services->update('upload_type', ['value' => json_encode($type)], 'menu_name');
\crmeb\services\CacheService::clear();
if ($type != 1) {
$msg = 400228;
} else {
$msg = 400229;
}
return app('json')->success($msg);
}
}

View File

@ -0,0 +1,78 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\adminapi\controller\v1\system;
use app\adminapi\controller\AuthController;
use app\services\system\AppVersionServices;
use think\facade\App;
/**
*
* Class AppVersion
* @package app\adminapi\controller\v1\system
*/
class AppVersion extends AuthController
{
/**
* user constructor.
* @param App $app
* @param AppVersionServices $services
*/
public function __construct(App $app, AppVersionServices $services)
{
parent::__construct($app);
$this->services = $services;
}
/**
* 版本列表
* @return mixed
*/
public function list()
{
[$platform] = $this->request->getMore([
['platform', '']
], true);
return app('json')->success($this->services->versionList($platform));
}
/**
* 新增版本表单
* @return mixed
*/
public function crate($id)
{
return app('json')->success($this->services->createForm($id));
}
/**
* 保存数据
* @return mixed
*/
public function save()
{
$data = $this->request->postMore([
['id', 0],
['version', ''],
['platform', 1],
['info', ''],
['is_force', 1],
['url', ''],
['is_new', 1],
]);
$id = $data['id'];
unset($data['id']);
$this->services->versionSave($id, $data);
return app('json')->success(100021);
}
}

View File

@ -0,0 +1,51 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\adminapi\controller\v1\system;
use think\facade\App;
use app\services\system\log\ClearServices;
use app\adminapi\controller\AuthController;
/**
* 首页控制器
* Class Clear
* @package app\admin\controller
*
*/
class Clear extends AuthController
{
public function __construct(App $app, ClearServices $services)
{
parent::__construct($app);
$this->services = $services;
}
/**
* 刷新数据缓存
*/
public function refresh_cache()
{
$this->services->refresCache();
return app('json')->success(400302);
}
/**
* 删除日志
*/
public function delete_log()
{
$this->services->deleteLog();
return app('json')->success(100002);
}
}

View File

@ -0,0 +1,454 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\adminapi\controller\v1\system;
use app\services\product\product\StoreDescriptionServices;
use app\services\product\product\StoreProductCateServices;
use app\services\product\product\StoreProductCouponServices;
use app\services\product\product\StoreProductReplyServices;
use app\services\product\sku\StoreProductAttrResultServices;
use app\services\product\sku\StoreProductAttrServices;
use app\services\product\sku\StoreProductAttrValueServices;
use think\facade\App;
use app\adminapi\controller\AuthController;
use app\services\system\SystemClearServices;
use app\services\product\product\StoreProductServices;
use app\services\system\attachment\SystemAttachmentServices;
/**
* 清除默认数据理控制器
* Class SystemClearData
* @package app\admin\controller\system
*/
class SystemClearData extends AuthController
{
/**
* 构造方法
* SystemClearData constructor.
* @param App $app
* @param SystemClearServices $services
*/
public function __construct(App $app, SystemClearServices $services)
{
parent::__construct($app);
$this->services = $services;
}
/**
* 统一方法
* @param $type
* @return mixed
*/
public function index($type)
{
switch ($type) {
case 'temp':
return $this->userTemp();
case 'recycle':
return $this->recycleProduct();
case 'store':
return $this->storeData();
case 'category':
return $this->categoryData();
case 'order':
return $this->orderData();
case 'kefu':
return $this->kefuData();
case 'wechat':
return $this->wechatData();
case 'article':
return $this->articleData();
case 'attachment':
return $this->attachmentData();
case 'system':
return $this->systemData();
case 'user':
return $this->userRelevantData();
default:
return app('json')->fail(100100);
}
}
/**
* 清除用户生成的临时附件
* @return mixed
*/
public function userTemp()
{
/** @var SystemAttachmentServices $services */
$services = app()->make(SystemAttachmentServices::class);
$imageUrl = $services->getColumn(['module_type' => 2], 'att_dir');
foreach ($imageUrl as $item) {
@unlink(app()->getRootPath() . 'public' . $item);
}
$services->delete(2, 'module_type');
$this->services->clearData(['qrcode'], true);
return app('json')->success(100046);
}
/**
* 清除回收站商品
* @return mixed
*/
public function recycleProduct()
{
/** @var StoreProductServices $product */
$product = app()->make(StoreProductServices::class);
$ids = $product->getColumn(['is_del' => 1], 'id');
//清除规格表数据
/** @var StoreProductAttrServices $ProductAttr */
$productAttr = app()->make(StoreProductAttrServices::class);
$productAttr->delete([['product_id', 'in', $ids], ['type', '=', '0']]);
/** @var StoreProductAttrResultServices $productAttrResult */
$productAttrResult = app()->make(StoreProductAttrResultServices::class);
$productAttrResult->delete([['product_id', 'in', $ids], ['type', '=', '0']]);
/** @var StoreProductAttrValueServices $productAttrValue */
$productAttrValue = app()->make(StoreProductAttrValueServices::class);
$productAttrValue->delete([['product_id', 'in', $ids], ['type', '=', '0']]);
//删除商品详情
/** @var StoreDescriptionServices $productDescription */
$productDescription = app()->make(StoreDescriptionServices::class);
$productDescription->delete([['product_id', 'in', $ids], ['type', '=', '0']]);
//删除商品关联分类数据
/** @var StoreProductCateServices $productCate */
$productCate = app()->make(StoreProductCateServices::class);
$productCate->delete([['product_id', 'in', $ids]]);
//删除商品关联优惠券数据
/** @var StoreProductCouponServices $productCoupon */
$productCoupon = app()->make(StoreProductCouponServices::class);
$productCoupon->delete([['product_id', 'in', $ids]]);
//删除商品收藏记录
/** @var StoreProductReplyServices $productRelation */
$productRelation = app()->make(StoreProductReplyServices::class);
$productRelation->delete([['product_id', 'in', $ids], ['reply_type', '=', 'product']]);
//删除商品的评论
/** @var StoreProductReplyServices $productReply */
$productReply = app()->make(StoreProductReplyServices::class);
$productReply->delete([['product_id', 'in', $ids]]);
/** @var StoreProductServices $services */
$services = app()->make(StoreProductServices::class);
$services->delete(1, 'is_del');
return app('json')->success(100046);
}
/**
* 清除用户数据
* @return mixed
*/
public function userRelevantData()
{
$this->services->clearData([
'agent_level_task_record',
'member_card',
'member_card_batch',
'capital_flow',
'delivery_service',
'division_agent_apply',
'luck_lottery_record',
'other_order',
'other_order_status',
'qrcode',
'sms_record',
'store_bargain_user',
'store_bargain_user_help',
'store_cart',
'store_coupon_issue_user',
'store_coupon_user',
'store_integral_order',
'store_integral_order_status',
'store_order',
'store_order_cart_info',
'store_order_economize',
'store_order_invoice',
'store_order_refund',
'store_order_status',
'store_pink',
'store_product_relation',
'store_product_reply',
'store_service',
'store_service_feedback',
'store_service_log',
'store_service_record',
'store_visit',
'system_store_staff',
'user',
'user_address',
'user_bill',
'user_brokerage',
'user_brokerage_frozen',
'user_cancel',
'user_enter',
'user_extract',
'user_friends',
'user_group',
'user_invoice',
'user_label',
'user_label_relation',
'user_level',
'user_money',
'user_notice',
'user_notice_see',
'user_recharge',
'user_search',
'user_sign',
'user_spread',
'user_visit',
'wechat_user',
], true);
$this->services->delDirAndFile('./public/uploads/store/comment');
return app('json')->success(100046);
}
/**
* 清除商城数据
* @return mixed
*/
public function storeData()
{
$this->services->clearData([
'agent_level_task',
'agent_level_task_record',
'article',
'article_category',
'article_content',
'auxiliary',
'cache',
'capital_flow',
'category',
'delivery_service',
'division_agent_apply',
'live_anchor',
'live_goods',
'live_room',
'live_room_goods',
'luck_lottery',
'luck_lottery_record',
'luck_prize',
'member_card',
'member_card_batch',
'message_system',
'other_order',
'other_order_status',
'qrcode',
'sms_record',
'store_advance',
'store_bargain',
'store_bargain_user',
'store_bargain_user_help',
'store_cart',
'store_category',
'store_combination',
'store_coupon_issue',
'store_coupon_issue_user',
'store_coupon_product',
'store_coupon_user',
'store_integral',
'store_integral_order',
'store_integral_order_status',
'store_order',
'store_order_cart_info',
'store_order_economize',
'store_order_invoice',
'store_order_refund',
'store_order_status',
'store_pink',
'store_product',
'store_product_attr',
'store_product_attr_result',
'store_product_attr_value',
'store_product_cate',
'store_product_coupon',
'store_product_description',
'store_product_log',
'store_product_relation',
'store_product_reply',
'store_product_rule',
'store_product_virtual',
'store_seckill',
'store_service',
'store_service_feedback',
'store_service_log',
'store_service_record',
'store_visit',
'system_file',
'system_log',
'system_notice',
'system_notice_admin',
'system_store',
'system_store_staff',
'user',
'user_address',
'user_bill',
'user_brokerage',
'user_brokerage_frozen',
'user_cancel',
'user_enter',
'user_extract',
'user_friends',
'user_group',
'user_invoice',
'user_label',
'user_label_relation',
'user_level',
'user_money',
'user_notice',
'user_notice_see',
'user_recharge',
'user_search',
'user_sign',
'user_spread',
'user_visit',
'wechat_key',
'wechat_media',
'wechat_message',
'wechat_news_category',
'wechat_qrcode',
'wechat_qrcode_cate',
'wechat_qrcode_record',
'wechat_reply',
'wechat_user',
], true);
return app('json')->success(100046);
}
/**
* 清除商品分类
* @return mixed
*/
public function categoryData()
{
$this->services->clearData(['store_category'], true);
return app('json')->success(100046);
}
/**
* 清除订单数据
* @return mixed
*/
public function orderData()
{
$this->services->clearData([
'other_order',
'other_order_status',
'store_cart',
'store_integral_order',
'store_integral_order_status',
'store_order',
'store_order_cart_info',
'store_order_economize',
'store_order_invoice',
'store_order_refund',
'store_order_status',
'store_pink',
], true);
return app('json')->success(100046);
}
/**
* 清除客服数据
* @return mixed
*/
public function kefuData()
{
$this->services->clearData([
'store_service',
'store_service_log',
'store_service_record',
'store_service_feedback',
'store_service_speechcraft'
], true);
$this->services->delDirAndFile('./public/uploads/store/service');
return app('json')->success(100046);
}
/**
* 清除微信管理数据
* @return mixed
*/
public function wechatData()
{
$this->services->clearData([
'cache',
'wechat_key',
'wechat_media',
'wechat_message',
'wechat_news_category',
'wechat_qrcode',
'wechat_qrcode_cate',
'wechat_qrcode_record',
'wechat_reply'
], true);
$this->services->delDirAndFile('./public/uploads/wechat');
return app('json')->success(100046);
}
/**
* 清除所有附件
* @return mixed
*/
public function attachmentData()
{
$this->services->clearData([
'system_attachment',
'system_attachment_category'
], true);
$this->services->delDirAndFile('./public/uploads/');
return app('json')->success(100046);
}
//清除内容分类
public function articleData()
{
$this->services->clearData([
'article_category',
'article',
'article_content'
], true);
return app('json')->success(100046);
}
//清除系统记录
public function systemData()
{
$this->services->clearData([
'system_notice_admin',
'system_log'
], true);
return app('json')->success(100046);
}
/**
* 替换域名方法
* @return mixed
*/
public function replaceSiteUrl()
{
list($url) = $this->request->postMore([
['url', '']
], true);
if (!$url)
return app('json')->fail(400304);
if (!verify_domain($url))
return app('json')->fail(400305);
$this->services->replaceSiteUrl($url);
return app('json')->success(400306);
}
}

View File

@ -0,0 +1,92 @@
<?php
namespace app\adminapi\controller\v1\system;
use app\adminapi\controller\AuthController;
use app\services\system\crontab\SystemCrontabServices;
use think\facade\App;
class SystemCrontab extends AuthController
{
public function __construct(App $app, SystemCrontabServices $services)
{
parent::__construct($app);
$this->services = $services;
}
/**
* 获取定时任务列表
* @return mixed
*/
public function getTimerList()
{
$where = ['is_del' => 0];
return app('json')->success($this->services->getTimerList($where));
}
/**
* 获取定时任务详情
* @param $id
* @return mixed
*/
public function getTimerInfo($id)
{
return app('json')->success($this->services->getTimerInfo($id));
}
/**
* 获取定时任务类型
* @return mixed
*/
public function getMarkList()
{
return app('json')->success($this->services->getMarkList());
}
/**
* 保存定时任务
* @return mixed
*/
public function saveTimer()
{
$data = $this->request->postMore([
['id', 0],
['name', ''],
['mark', ''],
['content', ''],
['type', 0],
['is_open', 0],
['week', 0],
['day', 0],
['hour', 0],
['minute', 0],
['second', 0],
]);
$this->services->saveTimer($data);
return app('json')->success(100000);
}
/**
* 删除定时任务
* @param $id
* @return mixed
*/
public function delTimer($id)
{
$this->services->delTimer($id);
return app('json')->success(100002);
}
/**
* 设置定时任务状态
* @param $id
* @param $is_open
* @return mixed
*/
public function setTimerStatus($id, $is_open)
{
$this->services->setTimerStatus($id, $is_open);
return app('json')->success(100014);
}
}

View File

@ -0,0 +1,186 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\adminapi\controller\v1\system;
use think\facade\App;
use think\facade\Db;
use think\facade\Session;
use app\adminapi\controller\AuthController;
use app\services\system\SystemDatabackupServices;
/**
* 数据备份
* Class SystemDatabackup
* @package app\admin\controller\system
*
*/
class SystemDatabackup extends AuthController
{
/**
* 构造方法
* SystemDatabackup constructor.
* @param App $app
* @param SystemDatabackupServices $services
*/
public function __construct(App $app, SystemDatabackupServices $services)
{
parent::__construct($app);
$this->services = $services;
}
/**
* 获取数据库表
*/
public function index()
{
return app('json')->success($this->services->getDataList());
}
/**
* 查看表结构 详情
*/
public function read()
{
$tablename = request()->param('tablename', '', 'htmlspecialchars');
return app('json')->success($this->services->getRead($tablename));
}
/**
* 更新数据表或者表字段备注
* @return \think\Response
* @author 吴汐
* @email 442384644@qq.com
* @date 2023/04/11
*/
public function updateMark()
{
[$table, $field, $type, $mark, $is_field] = $this->request->postMore([
['table', ''],
['field', ''],
['type', ''],
['mark', ''],
['is_field', 0],
], true);
if ($is_field == 0) {
$sql = "ALTER TABLE $table COMMENT '$mark'";
} else {
$sql = "ALTER TABLE $table MODIFY COLUMN $field $type COMMENT '$mark'";
}
Db::execute($sql);
return app('json')->success(100024);
}
/**
* 优化表
*/
public function optimize()
{
$tables = $this->request->param('tables', '', 'htmlspecialchars');
$res = $this->services->getDbBackup()->optimize($tables);
return app('json')->success($res ? 100047 : 100048);
}
/**
* 修复表
*/
public function repair()
{
$tables = $this->request->param('tables', '', 'htmlspecialchars');
$res = $this->services->getDbBackup()->repair($tables);
return app('json')->success($res ? 100049 : 100050);
}
/**
* 备份表
*/
public function backup()
{
$tables = $this->request->param('tables', '', 'htmlspecialchars');
$data = $this->services->backup($tables);
return app('json')->success(100051);
}
/**
* 获取备份记录表
*/
public function fileList()
{
return app('json')->success($this->services->getBackup());
}
/**
* 删除备份记录表
*/
public function delFile()
{
$filename = intval(request()->post('filename'));
$files = $this->services->getDbBackup()->delFile($filename);
return app('json')->success(100002);
}
/**
* 导入备份记录表
*/
public function import()
{
[$part, $start, $time] = $this->request->postMore([
[['part', 'd'], 0],
[['start', 'd'], 0],
[['time', 'd'], 0],
], true);
$db = $this->services->getDbBackup();
if (is_numeric($time) && !$start) {
$list = $db->getFile('timeverif', $time);
if (is_array($list)) {
session::set('backup_list', $list);
return app('json')->success(400307, array('part' => 1, 'start' => 0));
} else {
return app('json')->fail(400308);
}
} else if (is_numeric($part) && is_numeric($start) && $part && $start) {
$list = session::get('backup_list');
$start = $db->setFile($list)->import($start);
if (false === $start) {
return app('json')->fail(400309);
} elseif (0 === $start) {
if (isset($list[++$part])) {
$data = array('part' => $part, 'start' => 0);
return app('json')->success(400310, $data);
} else {
session::delete('backup_list');
return app('json')->success(400311);
}
} else {
$data = array('part' => $part, 'start' => $start[0]);
if ($start[1]) {
$rate = floor(100 * ($start[0] / $start[1]));
return app('json')->success(400310, $data);
} else {
$data['gz'] = 1;
return app('json')->success(400310, $data);
}
}
} else {
return app('json')->fail(100100);
}
}
/**
* 下载备份记录表
*/
public function downloadFile()
{
$time = intval(request()->param('time'));
return app('json')->success(['key' => $this->services->getDbBackup()->downloadFile($time, 0, true)]);
}
}

View File

@ -0,0 +1,268 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\adminapi\controller\v1\system;
use think\facade\App;
use app\adminapi\controller\AuthController;
use app\services\system\log\SystemFileServices;
/**
* 文件校验控制器
* Class SystemFile
* @package app\admin\controller\system
*
*/
class SystemFile extends AuthController
{
/**
* 构造方法
* SystemFile constructor.
* @param App $app
* @param SystemFileServices $services
*/
public function __construct(App $app, SystemFileServices $services)
{
parent::__construct($app);
$this->services = $services;
}
/**
* 文件校验记录
* @return mixed
*/
public function index()
{
return app('json')->success(['list' => $this->services->getFileList()]);
}
/**
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*
* @date 2022/09/07
* @author yyw
*/
public function login()
{
[$password] = $this->request->postMore([
'password',
], true);
$adminInfo = $this->request->adminInfo();
if (!$adminInfo) return app('json')->fail(100101);
if ($adminInfo['level'] != 0) return app('json')->fail(100101);
if ($password === '') return app('json')->fail(400256);
return app('json')->success($this->services->login($password, 'file_edit'));
}
//打开目录
public function opendir()
{
[$dir, $fileDir, $superior] = $this->request->getMore([
['dir', ''],
['filedir', ''],
['superior', ''],
], true);
return app('json')->success($this->services->opendir($dir, $fileDir, $superior));
}
//文件备注
public function fileMark()
{
[$path, $fileToken] = $this->request->postMore([
['path', ''],
['fileToken', ''],
], true);
if ($path == '') return app('json')->fail(100100);
return app('json')->success($this->services->markForm($path, $fileToken));
}
//文件备注保存
public function fileMarkSave()
{
[$full_path, $mark] = $this->request->postMore([
['full_path', ''],
['mark', ''],
], true);
$full_path = $this->request->param('full_path');
if ($full_path == '') return app('json')->fail(100100);
$this->services->fileMarkSave($full_path, $mark);
return app('json')->success(100000);
}
//读取文件
public function openfile()
{
$file = $this->request->param('filepath');
if (empty($file)) return app('json')->fail(410087);
return app('json')->success($this->services->openfile($file));
}
//保存文件
public function savefile()
{
$comment = $this->request->param('comment');
$filepath = $this->request->param('filepath');
if (empty($filepath)) {
return app('json')->fail('文件路径不存在');
}
$res = $this->services->savefile($filepath, $comment);
if ($res) {
return app('json')->success(100000);
} else {
return app('json')->fail(100006);
}
}
/**
* 创建文件夹
* @return mixed
*
* @date 2022/09/17
* @author yyw
*/
public function createFolder()
{
[$path, $name] = $this->request->postMore([
['path', ''],
['name', '']
], true);
if (empty($path) || empty($name)) {
return app('json')->fail(410087);
}
$data = [];
try {
$res = $this->services->createFolder($path, $name);
if ($res) {
$data = [
'children' => [],
'contextmenu' => true,
'isDir' => true,
'loading' => false,
'path' => $path,
'pathname' => $path . DS . $name,
'title' => $name,
];
} else {
return app('json')->fail(100005);
}
} catch (\Exception $e) {
return app('json')->fail($e->getMessage());
}
return app('json')->success($data);
}
/**
* 创建文件
* @return mixed
*
* @date 2022/09/17
* @author yyw
*/
public function createFile()
{
[$path, $name] = $this->request->postMore([
['path', ''],
['name', '']
], true);
if (empty($path) || empty($name)) {
return app('json')->fail(410087);
}
$data = [];
try {
$res = $this->services->createFile($path, $name);
if ($res) {
$data = [
'children' => [],
'contextmenu' => true,
'isDir' => false,
'loading' => false,
'path' => $path,
'pathname' => $path . DS . $name,
'title' => $name,
];
} else {
return app('json')->fail(100005);
}
} catch (\Exception $e) {
return app('json')->fail($e->getMessage());
}
return app('json')->success($data);
}
/**
* 删除文件或文件夹
* @return mixed
*
* @date 2022/09/17
* @author yyw
*/
public function delFolder()
{
[$path] = $this->request->postMore([
['path', '']
], true);
if (empty($path)) {
return app('json')->fail(410087);
}
try {
$this->services->delFolder($path);
} catch (\Exception $e) {
return app('json')->fail($e->getMessage());
}
return app('json')->success(100010);
}
/**
* 文件重命名
* @return mixed
*
* @date 2022/09/28
* @author yyw
*/
public function rename()
{
[$newname, $oldname] = $this->request->postMore([
['newname', ''],
['oldname', '']
], true);
if (empty($newname) || empty($oldname)) {
return app('json')->fail(410087);
}
try {
$this->services->rename($newname, $oldname);
} catch (\Exception $e) {
return app('json')->fail($e->getMessage());
}
return app('json')->success(100010);
}
public function copyFolder()
{
[$surDir, $toDir] = $this->request->postMore([
['surDir', ''],
['toDir', '']
], true);
if (empty($surDir) || empty($toDir)) {
return app('json')->fail(410087);
}
try {
return app('json')->success($this->services->copyFolder($surDir, $toDir));
} catch (\Exception $e) {
return app('json')->fail($e->getMessage());
}
}
}

View File

@ -0,0 +1,60 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\adminapi\controller\v1\system;
use think\facade\App;
use app\adminapi\controller\AuthController;
use app\services\system\log\SystemLogServices;
use app\services\system\admin\SystemAdminServices;
/**
* 管理员操作记录表控制器
* Class SystemLog
* @package app\adminapi\controller\v1\system
*/
class SystemLog extends AuthController
{
/**
* 构造方法
* SystemLog constructor.
* @param App $app
* @param SystemLogServices $services
*/
public function __construct(App $app, SystemLogServices $services)
{
parent::__construct($app);
$this->services = $services;
$this->services->deleteLog();
}
/**
* 显示操作记录
*/
public function index()
{
$where = $this->request->getMore([
['pages', ''],
['path', ''],
['ip', ''],
['admin_id', ''],
['data', '', '', 'time'],
]);
return app('json')->success($this->services->getLogList($where, (int)$this->adminInfo['level']));
}
public function search_admin(SystemAdminServices $services)
{
$info = $services->getOrdAdmin('id,real_name', $this->adminInfo['level']);
return app('json')->success(compact('info'));
}
}

View File

@ -0,0 +1,216 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\adminapi\controller\v1\system;
use app\adminapi\controller\AuthController;
use app\services\system\config\SystemConfigServices;
use crmeb\services\UpgradeService as uService;
//use app\models\system\SystemConfig;
use think\facade\Db;
/**
* 在线升级控制器
* Class SystemUpgradeclient
* @package app\admin\controller\system
*
*/
class SystemUpgradeClient extends AuthController
{
protected $serverweb = array('version' => '1.0', 'version_code' => 0);//本站点信息
public function initialize()
{
parent::initialize();
self::snyweninfo();//更新站点信息
}
//同步更新站点信息
public function snyweninfo()
{
/** @var SystemConfigServices $systemConfig */
$systemConfig = app()->make(SystemConfigServices::class);
$this->serverweb['ip'] = $this->request->ip();
$this->serverweb['host'] = $this->request->host();
$this->serverweb['https'] = !empty($this->request->domain()) ? $this->request->domain() : $systemConfig->getConfigValue('site_url');
$this->serverweb['webname'] = $systemConfig->getConfigValue('site_name');
$local = uService::getVersion();
if ($local['code'] == 200 && isset($local['msg']['version']) && isset($local['msg']['version_code'])) {
$this->serverweb['version'] = uService::replace($local['msg']['version']);
$this->serverweb['version_code'] = (int)uService::replace($local['msg']['version_code']);
}
uService::snyweninfo($this->serverweb);
}
//是否授权
public function isauth()
{
return uService::isauth();
}
/**
* 升级列表
*/
public function index()
{
$where = $this->request->getMore([
['page', 1],
['limit', 20]
]);
$list = uService::request_post(uService::$isList, ['page' => $where['page'], 'limit' => $where['limit']]);
if (is_array($list) && isset($list['code']) && isset($list['data']) && $list['code'] == 200) {
$list = $list['data'];
} else {
$list = [];
}
return app('json')->success($list);
}
//删除备份文件
public function setcopydel()
{
$post = input('post.');
if (!isset($post['id'])) app('json')->fail('删除备份文件失败缺少参数ID');
if (!isset($post['ids'])) app('json')->fail('删除备份文件失败缺少参数IDS');
$fileservice = new uService;
if (is_array($post['ids'])) {
foreach ($post['ids'] as $file) {
$fileservice->del_dir(app()->getRootPath() . 'public' . DS . 'copyfile' . $file);
}
}
if ($post['id']) {
$copyFile = app()->getRootPath() . 'public' . DS . 'copyfile' . $post['id'];
$fileservice->del_dir($copyFile);
}
return app('json')->success('删除成功');
}
public function get_new_version_conte()
{
$post = $this->request->post();
if (!isset($post['id'])) app('json')->fail('缺少参数ID');
$versionInfo = uService::request_post(uService::$NewVersionCount, ['id' => $post['id']]);
if (isset($versionInfo['code']) && isset($versionInfo['data']['count']) && $versionInfo['code'] == 200) {
return app('json')->success(['count' => $versionInfo['data']['count']]);
} else {
return app('json')->fail('服务器异常');
}
}
//一键升级
public function auto_upgrade()
{
$prefix = config('database.prefix');
$fileservice = new uService;
$post = $this->request->post();
if (!isset($post['id'])) return app('json')->fail('缺少参数ID');
$versionInfo = $fileservice->request_post(uService::$isNowVersion, ['id' => $post['id']]);
if ($versionInfo === null) return app('json')->fail('服务器异常,请稍后再试');
if (isset($versionInfo['code']) && $versionInfo['code'] == 400) return app('json')->fail($versionInfo['msg'] ?? '您暂时没有权限升级,请联系管理员!');
if (is_array($versionInfo) && isset($versionInfo['data'])) {
$list = $versionInfo['data'];
$id = [];
foreach ($list as $key => $val) {
$savefile = app()->getRootPath() . 'public' . DS . 'upgrade_lv';
//1检查远程下载文件并下载
if (($save_path = $fileservice->check_remote_file_exists($val['zip_name'], $savefile)) === false) app('json')->fail('远程升级包不存在');
//2首先解压文件
$savename = app()->getRootPath() . 'public' . DS . 'upgrade_lv' . DS . time();
$fileservice->zipOpen($save_path, $savename);
//3执行SQL文件
Db::startTrans();
try {
//参数3不介意大小写的
$sqlfile = $fileservice->listDirInfo($savename . DS, true, 'sql');
if (is_array($sqlfile) && !empty($sqlfile)) {
foreach ($sqlfile as $file) {
if (file_exists($file)) {
//为一键安装做工作记得表前缀要改为[#DB_PREFIX#]哦
$execute_sql = explode(";\r", str_replace(['[#DB_PREFIX#]', "\n"], [$prefix, "\r"], file_get_contents($file)));
foreach ($execute_sql as $_sql) {
if ($query_string = trim(str_replace(array(
"\r",
"\n",
"\t"
), '', $_sql))) Db::execute($query_string);
}
//执行完sql记得删掉哦
$fileservice->unlinkFile($file);
}
}
}
Db::commit();
} catch (\Exception $e) {
Db::rollback();
//删除解压下的文件
$fileservice->del_dir(app()->getRootPath() . 'public' . DS . 'upgrade_lv');
//删除压缩包
$fileservice->unlinkFile($save_path);
//升级失败发送错误信息
$fileservice->request_post(uService::$isInsertLog, [
'content' => '升级失败,错误信息为:' . $e->getMessage(),
'add_time' => time(),
'ip' => $this->request->ip(),
'http' => $this->request->domain(),
'type' => 'error',
'version' => $val['version']
]);
return app('json')->fail('升级失败SQL文件执行有误');
}
//4,备份文件
$copyFile = app()->getRootPath() . 'public' . DS . 'copyfile' . $val['id'];
$copyList = $fileservice->getDirs($savename . DS);
if (isset($copyList['dir'])) {
if ($copyList['dir'][0] == '.' && $copyList['dir'][1] == '..') {
array_shift($copyList['dir']);
array_shift($copyList['dir']);
}
foreach ($copyList['dir'] as $dir) {
if (file_exists(app()->getRootPath() . $dir, $copyFile . DS . $dir)) {
$fileservice->copyDir(app()->getRootPath() . $dir, $copyFile . DS . $dir);
}
}
}
//5覆盖文件
$fileservice->handleDir($savename, app()->getRootPath());
//6,删除升级生成的目录
$fileservice->del_dir(app()->getRootPath() . 'public' . DS . 'upgrade_lv');
//7,删除压缩包
$fileservice->unlinkFile($save_path);
//8,改写本地升级文件
$handle = fopen(app()->getRootPath() . '.version', 'w+');
if ($handle === false) return app('json')->fail(app()->getRootPath() . '.version' . '无法写入打开');
$content = <<<EOT
version={$val['version']}
version_code={$val['id']}
EOT;
if (fwrite($handle, $content) === false) return app('json')->fail('升级包写入失败');
fclose($handle);
//9,向服务端发送升级日志
$posts = [
'ip' => $this->request->ip(),
'https' => $this->request->domain(),
'update_time' => time(),
'content' => '一键升级成功,升级版本号为:' . $val['version'] . '。版本code为' . $val['id'],
'type' => 'log',
'versionbefor' => $this->serverweb['version'],
'versionend' => $val['version']
];
$inset = $fileservice->request_post(uService::$isInsertLog, $posts);
$id[] = $val['id'];
}
//10,升级完成
return app('json')->success('升级成功', ['code' => end($id), 'version' => $val['version']]);
} else {
return app('json')->fail('服务器异常,请稍后再试');
}
}
}

View File

@ -0,0 +1,453 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\adminapi\controller\v1\user;
use app\services\user\UserServices;
use app\adminapi\controller\AuthController;
use think\exception\ValidateException;
use think\facade\App;
class User extends AuthController
{
/**
* user constructor.
* @param App $app
* @param UserServices $services
*/
public function __construct(App $app, UserServices $services)
{
parent::__construct($app);
$this->services = $services;
}
/**
* 用户列表
* @return mixed
*/
public function index()
{
$where = $this->request->getMore([
['page', 1],
['limit', 20],
['nickname', ''],
['status', ''],
['pay_count', ''],
['is_promoter', ''],
['order', ''],
['data', ''],
['user_type', ''],
['country', ''],
['province', ''],
['city', ''],
['user_time_type', ''],
['user_time', ''],
['sex', ''],
[['level', 0], 0],
[['group_id', 'd'], 0],
['label_id', ''],
['now_money', 'normal'],
['field_key', ''],
['isMember', '']
]);
$where['label_id'] = stringToIntArray($where['label_id']);
return app('json')->success($this->services->index($where));
}
/**
* 添加用户表单
* @return mixed
* @throws \FormBuilder\Exception\FormBuilderException
*/
public function create()
{
return app('json')->success($this->services->saveForm());
}
/**
* 添加编辑用户信息时候的信息
* @param $uid
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function userSaveInfo($uid = 0)
{
$data = $this->services->getUserSaveInfo($uid);
return app('json')->success($data);
}
/**
* 保存新建用户
* @return mixed
* @throws \think\Exception
*/
public function save()
{
$data = $this->request->postMore([
['real_name', ''],
['phone', 0],
['birthday', ''],
['card_id', ''],
['addres', ''],
['mark', ''],
['pwd', ''],
['true_pwd', ''],
['level', 0],
['group_id', 0],
['label_id', []],
['spread_open', 1],
['is_promoter', 0],
['status', 0]
]);
if (!$data['real_name']) {
return app('json')->fail(410245);
}
if (!$data['phone']) {
return app('json')->fail(410245);
}
if (!check_phone($data['phone'])) {
return app('json')->fail(400252);
}
if ($this->services->count(['phone' => $data['phone'], 'is_del' => 0])) {
return app('json')->fail(400314);
}
$data['nickname'] = $data['real_name'];
if ($data['card_id']) {
if (!check_card($data['card_id'])) return app('json')->fail(400315);
}
if (!$data['pwd']) {
return app('json')->fail(400256);
}
if (!$data['true_pwd']) {
return app('json')->fail(400263);
}
if ($data['pwd'] != $data['true_pwd']) {
return app('json')->fail(400264);
}
if (strlen($data['pwd']) < 6 || strlen($data['pwd']) > 32) {
return app('json')->fail(400762);
}
$data['pwd'] = md5($data['pwd']);
unset($data['true_pwd']);
$data['avatar'] = sys_config('h5_avatar');
$data['adminId'] = $this->adminId;
$data['user_type'] = 'h5';
$label = $data['label_id'];
unset($data['label_id']);
foreach ($label as $k => $v) {
if (!$v) {
unset($label[$k]);
}
}
$data['birthday'] = empty($data['birthday']) ? 0 : strtotime($data['birthday']);
$data['add_time'] = time();
$this->services->transaction(function () use ($data, $label) {
$res = true;
$userInfo = $this->services->save($data);
$this->services->rewardNewUser((int)$userInfo->uid);
if ($label) {
$res = $this->services->saveSetLabel([$userInfo->uid], $label);
}
if ($data['level']) {
$res = $this->services->saveGiveLevel((int)$userInfo->uid, (int)$data['level']);
}
if (!$res) {
return app('json')->fail(100006);
}
});
return app('json')->success(100021);
}
/**
* 获取用户账户详情
* @param $id
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function read($id)
{
if (is_string($id)) {
$id = (int)$id;
}
return app('json')->success($this->services->read($id));
}
/**
* 赠送会员等级表单
* @param $id
* @return mixed
*/
public function give_level($id)
{
if (!$id) return app('json')->fail(100100);
return app('json')->success($this->services->giveLevel((int)$id));
}
/**
* 执行赠送会员等级
* @param $id
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function save_give_level($id)
{
if (!$id) return app('json')->fail(100100);
list($level_id) = $this->request->postMore([
['level_id', 0],
], true);
return app('json')->success($this->services->saveGiveLevel((int)$id, (int)$level_id) ? 400218 : 400219);
}
/**
* 赠送付费会员时长表单
* @param $id
* @return mixed
* @throws \FormBuilder\Exception\FormBuilderException
*/
public function give_level_time($id)
{
if (!$id) return app('json')->fail(100100);
return app('json')->success($this->services->giveLevelTime((int)$id));
}
/**
* 执行赠送付费会员时长
* @param $id
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function save_give_level_time($id)
{
if (!$id) return app('json')->fail(100100);
list($days) = $this->request->postMore([
['days', 0],
], true);
return app('json')->success($this->services->saveGiveLevelTime((int)$id, (int)$days) ? 400218 : 400219);
}
/**
* 清除会员等级
* @param $id
* @return mixed
*/
public function del_level($id)
{
if (!$id) return app('json')->fail(100100);
return app('json')->success($this->services->cleanUpLevel((int)$id) ? 400185 : 400186);
}
/**
* 设置会员分组
* @return mixed
*/
public function set_group()
{
list($uids) = $this->request->postMore([
['uids', []],
], true);
if (!$uids) return app('json')->fail(100100);
return app('json')->success($this->services->setGroup($uids));
}
/**
* 保存会员分组
* @return mixed
*/
public function save_set_group()
{
list($group_id, $uids) = $this->request->postMore([
['group_id', 0],
['uids', ''],
], true);
if (!$uids) return app('json')->fail(100100);
if (!$group_id) return app('json')->fail(400316);
$uids = explode(',', $uids);
return app('json')->success($this->services->saveSetGroup($uids, (int)$group_id) ? 100014 : 100015);
}
/**
* 设置用户标签
* @return mixed
*/
public function set_label()
{
list($uids) = $this->request->postMore([
['uids', []],
], true);
$uid = implode(',', $uids);
if (!$uid) return app('json')->fail(100100);
return app('json')->success($this->services->setLabel($uids));
}
/**
* 保存用户标签
* @return mixed
*/
public function save_set_label()
{
list($lables, $uids) = $this->request->postMore([
['label_id', []],
['uids', ''],
], true);
if (!$uids) return app('json')->fail(100100);
if (!$lables) return app('json')->fail(400317);
$uids = explode(',', $uids);
return app('json')->success($this->services->saveSetLabel($uids, $lables) ? 100014 : 100015);
}
/**
* 编辑其他
* @param $id
* @return mixed
* @throws \FormBuilder\Exception\FormBuilderException
*/
public function edit_other($id)
{
if (!$id) return app('json')->fail(100026);
return app('json')->success($this->services->editOther((int)$id));
}
/**
* 执行编辑其他
* @param $id
* @return mixed
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
*/
public function update_other($id)
{
$data = $this->request->postMore([
['money_status', 0],
['money', 0],
['integration_status', 0],
['integration', 0],
]);
if (!$id) return app('json')->fail(100100);
$data['adminId'] = $this->adminId;
$data['money'] = (string)$data['money'];
$data['integration'] = (string)$data['integration'];
$data['is_other'] = true;
return app('json')->success($this->services->updateInfo($id, $data) ? 100001 : 100007);
}
/**
* 编辑会员信息
* @param $id
* @return mixed
* @throws \FormBuilder\Exception\FormBuilderException
*/
public function edit($id)
{
if (!$id) return app('json')->fail(100100);
return app('json')->success($this->services->edit($id));
}
/**
* 修改用户
* @param $id
* @return mixed
* @throws \think\Exception
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
*/
public function update($id)
{
$data = $this->request->postMore([
['money_status', 0],
['is_promoter', 0],
['real_name', ''],
['card_id', ''],
['birthday', ''],
['mark', ''],
['money', 0],
['integration_status', 0],
['integration', 0],
['status', 0],
['level', 0],
['phone', 0],
['addres', ''],
['label_id', []],
['group_id', 0],
['pwd', ''],
['true_pwd'],
['spread_open', 1]
]);
if (!$id) return app('json')->fail(100100);
if (!$data['real_name']) {
return app('json')->fail(410245);
}
if (!$data['phone']) {
return app('json')->fail(410245);
}
if ($data['phone']) {
if (!preg_match("/^1[3456789]\d{9}$/", $data['phone'])) return app('json')->fail(400252);
}
if ($this->services->count(['phone' => $data['phone'], 'is_del' => 0, 'not_uid' => $id])) {
return app('json')->fail(400314);
}
if ($data['card_id']) {
if (!check_card($data['card_id'])) return app('json')->fail(400315);
}
if ($data['pwd']) {
if (!$data['true_pwd']) {
return app('json')->fail(400263);
}
if ($data['pwd'] != $data['true_pwd']) {
return app('json')->fail(400264);
}
if (strlen($data['pwd']) < 6 || strlen($data['pwd']) > 32) {
return app('json')->fail(400762);
}
$data['pwd'] = md5($data['pwd']);
} else {
unset($data['pwd']);
}
unset($data['true_pwd']);
$data['adminId'] = $this->adminId;
$data['money'] = (string)$data['money'];
$data['integration'] = (string)$data['integration'];
return app('json')->success($this->services->updateInfo($id, $data) ? 100001 : 100007);
}
/**
* 获取单个用户信息
* @param $id
* @return mixed
*/
public function oneUserInfo($id)
{
$data = $this->request->getMore([
['type', ''],
]);
$id = (int)$id;
if ($data['type'] == '') return app('json')->fail(100100);
return app('json')->success($this->services->oneUserInfo($id, $data['type']));
}
/**
* 同步微信粉丝用户
* @return mixed
*/
public function syncWechatUsers()
{
$this->services->syncWechatUsers();
return app('json')->success(400318);
}
}

View File

@ -0,0 +1,59 @@
<?php
namespace app\adminapi\controller\v1\user;
use app\adminapi\controller\AuthController;
use app\services\user\UserCancelServices;
use think\facade\App;
class UserCancel extends AuthController
{
/**
* UserCancel constructor.
* @param App $app
* @param UserCancelServices $services
*/
public function __construct(App $app, UserCancelServices $services)
{
parent::__construct($app);
$this->services = $services;
}
/**
* 获取注销列表
* @return mixed
*/
public function getCancelList()
{
$where = $this->request->postMore([
['status', 0],
['keywords', ''],
]);
$data = $this->services->getCancelList($where);
return app('json')->success($data);
}
/**
* 备注
* @return mixed
*/
public function setMark()
{
[$id, $mark] = $this->request->postMore([
['id', 0],
['mark', ''],
], true);
$this->services->serMark($id, $mark);
return app('json')->success(100024);
}
public function agreeCancel($id)
{
return app('json')->success(400319);
}
public function refuseCancel($id)
{
return app('json')->success(400320);
}
}

View File

@ -0,0 +1,87 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\adminapi\controller\v1\user;
use app\adminapi\controller\AuthController;
use app\services\user\UserGroupServices;
use think\facade\App;
/**
* 会员设置
* Class UserLevel
* @package app\admin\controller\user
*/
class UserGroup extends AuthController
{
/**
* user constructor.
* @param App $app
* @param UserGroupServices $services
*/
public function __construct(App $app, UserGroupServices $services)
{
parent::__construct($app);
$this->services = $services;
}
/**
* 分组列表
*/
public function index()
{
return app('json')->success($this->services->getGroupList('*', true));
}
/**
* 添加/修改分组页面
* @param int $id
* @return string
*/
public function add()
{
$data = $this->request->getMore([
['id', 0],
]);
return app('json')->success($this->services->add((int)$data['id']));
}
/**
*
* @param int $id
* @return mixed
*/
public function save()
{
$data = $this->request->postMore([
['id', 0],
['group_name', ''],
]);
if (!$data['group_name']) {
return app('json')->fail(400321);
}
$this->services->save((int)$data['id'], $data);
return app('json')->success(100017);
}
/**
* 删除
* @param $id
* @throws \Exception
*/
public function delete()
{
$data = $this->request->getMore([
['id', 0],
]);
if (!$data['id']) return app('json')->fail(100100);
return app('json')->success($this->services->delGroup((int)$data['id']));
}
}

View File

@ -0,0 +1,167 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\adminapi\controller\v1\user;
use app\adminapi\controller\AuthController;
use app\services\user\UserLabelCateServices;
use app\services\user\UserLabelRelationServices;
use app\services\user\UserLabelServices;
use think\facade\App;
/**
* 用户标签控制器
* Class UserLabel
* @package app\adminapi\controller\v1\user
*/
class UserLabel extends AuthController
{
/**
* UserLabel constructor.
* @param App $app
* @param UserLabelServices $service
*/
public function __construct(App $app, UserLabelServices $services)
{
parent::__construct($app);
$this->services = $services;
}
/**
* 标签列表
* @param int $label_cate
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function index($label_cate = '')
{
return app('json')->success($this->services->getList(['label_cate' => $label_cate]));
}
/**
* 添加修改标签表单
* @return mixed
* @throws \FormBuilder\Exception\FormBuilderException
*/
public function add()
{
[$id, $cateId] = $this->request->getMore([
['id', 0],
['cate_id', 0],
], true);
return app('json')->success($this->services->add((int)$id, (int)$cateId));
}
/**
* 保存标签表单数据
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function save()
{
$data = $this->request->postMore([
['id', 0],
['label_cate', 0],
['label_name', ''],
]);
if (!$data['label_name'] = trim($data['label_name'])) return app('json')->fail(400322);
$this->services->save((int)$data['id'], $data);
return app('json')->success(100000);
}
/**
* 删除
* @param $id
* @throws \Exception
*/
public function delete()
{
list($id) = $this->request->getMore([
['id', 0],
], true);
if (!$id) return app('json')->fail(100100);
$this->services->delLabel((int)$id);
return app('json')->success(100002);
}
/**
* 标签分类
* @param UserLabelCateServices $services
* @return mixed
*/
public function getUserLabel(UserLabelCateServices $services, $uid)
{
return app('json')->success($services->getUserLabel((int)$uid));
}
/**
* 设置用户标签
* @param UserLabelRelationServices $services
* @param $uid
* @return mixed
*/
public function setUserLabel(UserLabelRelationServices $services, $uid)
{
[$labels, $unLabelIds] = $this->request->postMore([
['label_ids', []],
['un_label_ids', []]
], true);
if (!count($labels) && !count($unLabelIds)) {
return app('json')->fail(100100);
}
if ($services->setUserLable($uid, $labels) && $services->unUserLabel($uid, $unLabelIds)) {
return app('json')->success(100014);
} else {
return app('json')->fail(100015);
}
}
/**
* 获取带分类的用户标签列表
* @param \app\services\user\label\UserLabelCateServices $userLabelCateServices
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function tree_list(UserLabelCateServices $userLabelCateServices)
{
$cate = $userLabelCateServices->getLabelCateAll();
$data = [];
$label = [];
if ($cate) {
foreach ($cate as $value) {
$data[] = [
'id' => $value['id'] ?? 0,
'value' => $value['id'] ?? 0,
'label_cate' => 0,
'label_name' => $value['name'] ?? '',
'label' => $value['name'] ?? '',
'store_id' => $value['store_id'] ?? 0,
'type' => $value['type'] ?? 1,
];
}
$label = $this->services->getList(['type' => 1]);
$label = $label['list'] ?? [];
if ($label) {
foreach ($label as &$item) {
$item['label'] = $item['label_name'];
$item['value'] = $item['id'];
}
}
}
return app('json')->success($this->services->get_tree_children($data, $label));
}
}

View File

@ -0,0 +1,174 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
declare (strict_types=1);
namespace app\adminapi\controller\v1\user;
use app\adminapi\controller\AuthController;
use app\services\user\UserLabelCateServices;
use app\adminapi\validate\user\UserLabeCateValidata;
use app\services\user\UserLabelServices;
use think\facade\App;
use app\Request;
/**
* Class UserLabelCate
* @package app\adminapi\controller\v1\user
*/
class UserLabelCate extends AuthController
{
/**
* UserLabelCate constructor.
* @param App $app
* @param UserLabelCateServices $services
*/
public function __construct(App $app, UserLabelCateServices $services)
{
parent::__construct($app);
$this->services = $services;
}
/**
* 显示资源列表
*
* @return \think\Response
*/
public function index(Request $request)
{
$where = $request->postMore([
['name', '']
]);
$where['type'] = 0;
return app('json')->success($this->services->getLabelList($where));
}
/**
* 显示创建资源表单页.
*
* @return \think\Response
*/
public function create()
{
return app('json')->success($this->services->createForm());
}
/**
* 保存新建的资源
*
* @param Request $request
* @return \think\Response
*/
public function save(Request $request)
{
$data = $request->postMore([
['name', ''],
['sort', 0]
]);
$this->validate($data, UserLabeCateValidata::class);
if ($this->services->count(['name' => $data['name']])) {
return app('json')->fail(400101);
}
$data['type'] = 0;
if ($this->services->save($data)) {
$this->services->deleteCateCache();
return app('json')->success(100000);
} else {
return app('json')->fail(100006);
}
}
/**
* 显示指定的资源
*
* @param int $id
* @return \think\Response
*/
public function read($id)
{
if (!$id) {
return app('json')->fail(100100);
}
$info = $this->services->get($id);
if (!$info) {
return app('json')->fail(100026);
}
return app('json')->success($info->toArray());
}
/**
* 显示编辑资源表单页.
*
* @param int $id
* @return \think\Response
*/
public function edit($id)
{
return app('json')->success($this->services->updateForm((int)$id));
}
/**
* 保存更新的资源
*
* @param Request $request
* @param int $id
* @return \think\Response
*/
public function update(Request $request, $id)
{
$data = $request->postMore([
['name', ''],
['sort', 0],
]);
$this->validate($data, UserLabeCateValidata::class);
if ($this->services->update($id, $data)) {
$this->services->deleteCateCache();
return app('json')->success(100001);
} else {
return app('json')->fail(100007);
}
}
/**
* 删除指定资源
*
* @param int $id
* @return \think\Response
*/
public function delete($id)
{
if (!$id || !($info = $this->services->get($id))) {
return app('json')->fail(100026);
}
/** @var $labelService $labelservice */
$labelService = app()->make(UserLabelServices::class);
$count = $labelService->getCount(['label_cate' => $id]);
if($count) return app('json')->fail(400323);
if ($info->delete()) {
$this->services->deleteCateCache();
return app('json')->success(100002);
} else {
return app('json')->fail(100008);
}
}
/**
* 获取用户标签分类全部
* @return mixed
*/
public function getAll()
{
return app('json')->success($this->services->getLabelCateAll());
}
}

View File

@ -0,0 +1,131 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\adminapi\controller\v1\user;
use app\adminapi\controller\AuthController;
use app\services\user\UserLevelServices;
use think\facade\App;
/**
* 会员设置
* Class UserLevel
* @package app\adminapi\controller\v1\user
*/
class UserLevel extends AuthController
{
/**
* user constructor.
* @param App $app
* @param UserLevelServices $services
*/
public function __construct(App $app, UserLevelServices $services)
{
parent::__construct($app);
$this->services = $services;
}
/*
* 获取添加资源表单
* */
public function create()
{
$where = $this->request->getMore(
['id', 0]
);
return app('json')->success($this->services->edit((int)$where['id']));
}
/*
* 会员等级添加或者修改
* @param $id 修改的等级id
* @return json
* */
public function save()
{
$data = $this->request->postMore([
['id', 0],
['name', ''],
['is_forever', 0],
['money', 0],
['is_pay', 0],
['valid_date', 0],
['grade', 0],
['discount', 0],
['icon', ''],
['image', ''],
['is_show', ''],
['exp_num', 0]
]);
if ($data['valid_date'] == 0) $data['is_forever'] = 1;//有效时间为0的时候就是永久
if (!$data['name']) return app('json')->fail(400324);
if (!$data['grade']) return app('json')->fail(400325);
if (!$data['icon']) return app('json')->fail(400327);
if (!$data['image']) return app('json')->fail(400328);
if (!$data['exp_num']) return app('json')->fail(400329);
$this->services->save((int)$data['id'], $data);
return app('json')->success(100000);
}
/*
* 获取系统设置的vip列表
* @param int page
* @param int limit
* */
public function get_system_vip_list()
{
$where = $this->request->getMore([
['page', 0],
['limit', 10],
['title', ''],
['is_show', ''],
]);
return app('json')->success($this->services->getSytemList($where));
}
/*
* 删除会员等级
* @param int $id
* */
public function delete($id)
{
return app('json')->success($this->services->delLevel((int)$id));
}
/**
* 设置会员等级显示|隐藏
*
* @return json
*/
public function set_show($is_show = '', $id = '')
{
if ($is_show == '' || $id == '') return app('json')->fail(100100);
return app('json')->success($this->services->setShow((int)$id, (int)$is_show));
}
/**
* 等级列表快速编辑
* field:value name:钻石会员/grade:8/discount:92.00
* @return json
*/
public function set_value($id)
{
$data = $this->request->postMore([
['field', ''],
['value', '']
]);
if ($data['field'] == '' || $data['value'] == '') return app('json')->fail(100100);
$this->services->setValue((int)$id, $data);
return app('json')->success(100000);
}
}

View File

@ -0,0 +1,24 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
// 事件定义文件
return [
'listen' => [
'AppInit' => [],
'HttpRun' => [],
'HttpEnd' => [],
'LogLevel' => [],
'LogWrite' => [],
'UserLogin'=>[
// \crmeb\listeners\user\UserLogin::class
]
]
];

View File

@ -0,0 +1,14 @@
.
├── config
├── controller
├── lang
├── middleware
├── route
├── validate
├── AdminApiExceptionHandle.php
├── common.php
├── event.php
├── filetree.txt
└── provider.php
6 directories, 5 files

View File

@ -0,0 +1,61 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\adminapi\middleware;
use app\Request;
use app\services\system\admin\AdminAuthServices;
use crmeb\interfaces\MiddlewareInterface;
use think\facade\Config;
use crmeb\services\CacheService;
/**
* 后台登陆验证中间件
* Class AdminAuthTokenMiddleware
* @package app\adminapi\middleware
*/
class AdminAuthTokenMiddleware implements MiddlewareInterface
{
/**
* @param Request $request
* @param \Closure $next
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author 吴汐
* @email 442384644@qq.com
* @date 2023/04/07
*/
public function handle(Request $request, \Closure $next)
{
$token = trim(ltrim($request->header(Config::get('cookie.token_name', 'Authori-zation')), 'Bearer'));
if (!$token) {
$token = trim(ltrim($request->get('token')));
}
/** @var AdminAuthServices $service */
$service = app()->make(AdminAuthServices::class);
$adminInfo = $service->parseToken($token);
$request->macro('isAdminLogin', function () use (&$adminInfo) {
return !is_null($adminInfo);
});
$request->macro('adminId', function () use (&$adminInfo) {
return $adminInfo['id'];
});
$request->macro('adminInfo', function () use (&$adminInfo) {
return $adminInfo;
});
return $next($request);
}
}

View File

@ -0,0 +1,46 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\adminapi\middleware;
use app\Request;
use app\services\system\admin\SystemRoleServices;
use crmeb\exceptions\AuthException;
use crmeb\interfaces\MiddlewareInterface;
/**
* 权限规则验证
* Class AdminCheckRoleMiddleware
* @package app\http\middleware
*/
class AdminCheckRoleMiddleware implements MiddlewareInterface
{
/**
* 权限规则验证
* @param Request $request
* @param \Closure $next
* @return mixed
* @throws \throwable
*/
public function handle(Request $request, \Closure $next)
{
if (!$request->adminId() || !$request->adminInfo())
throw new AuthException(100100);
if ($request->adminInfo()['level']) {
/** @var SystemRoleServices $systemRoleService */
$systemRoleService = app()->make(SystemRoleServices::class);
$systemRoleService->verifyAuth($request);
}
return $next($request);
}
}

View File

@ -0,0 +1,40 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\adminapi\middleware;
use app\Request;
use app\services\system\admin\AdminAuthServices;
use app\services\system\log\SystemFileServices;
use crmeb\exceptions\AuthException;
use crmeb\interfaces\MiddlewareInterface;
use crmeb\services\CacheService;
use think\facade\Config;
/**
* 后台登陆验证中间件
* Class AdminAuthTokenMiddleware
* @package app\adminapi\middleware
*/
class AdminEditorTokenMiddleware implements MiddlewareInterface
{
public function handle(Request $request, \Closure $next)
{
$token = CacheService::get(trim($request->get('fileToken')));
/** @var SystemFileServices $service */
$service = app()->make(SystemFileServices::class);
$service->parseToken($token);
return $next($request);
}
}

View File

@ -0,0 +1,42 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\adminapi\middleware;
use app\Request;
use app\services\system\log\SystemLogServices;
use crmeb\interfaces\MiddlewareInterface;
/**
* 日志中間件
* Class AdminLogMiddleware
* @package app\adminapi\middleware
*/
class AdminLogMiddleware implements MiddlewareInterface
{
/**
* @param Request $request
* @param \Closure $next
* @return mixed
*/
public function handle(Request $request, \Closure $next)
{
try {
/** @var SystemLogServices $services */
$services = app()->make(SystemLogServices::class);
$services->recordAdminLog($request->adminId(), $request->adminInfo()['account'], 'system');
} catch (\Throwable $e) {
}
return $next($request);
}
}

View File

@ -0,0 +1,15 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
// 容器Provider定义文件
return [
'think\exception\Handle' => \app\adminapi\AdminApiExceptionHandle::class,
];

View File

@ -0,0 +1,82 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
use think\facade\Route;
/**
* 应用模块 相关路由
*/
Route::group('app', function () {
/** 公众号 */
Route::group(function () {
//菜单值
Route::get('wechat/menu', 'v1.application.wechat.menus/index')->option(['real_name' => '微信公众号菜单列表']);
//保存菜单
Route::post('wechat/menu', 'v1.application.wechat.menus/save')->option(['real_name' => '保存微信公众号菜单']);
//图文列表
Route::get('wechat/news', 'v1.application.wechat.WechatNewsCategory/index')->option(['real_name' => '图文列表']);
//详情
Route::get('wechat/news/:id', 'v1.application.wechat.WechatNewsCategory/read')->option(['real_name' => '图文详情']);
//保存图文
Route::post('wechat/news', 'v1.application.wechat.WechatNewsCategory/save')->option(['real_name' => '保存图文']);
//删除图文
Route::delete('wechat/news/:id', 'v1.application.wechat.WechatNewsCategory/delete')->option(['real_name' => '删除图文']);
//发送图文消息
Route::post('wechat/push', 'v1.application.wechat.WechatNewsCategory/push')->option(['real_name' => '发送图文消息']);
//关注回复
Route::get('wechat/reply', 'v1.application.wechat.Reply/reply')->option(['real_name' => '关注回复']);
//获取关注回复二维码
Route::get('wechat/code_reply/:id', 'v1.application.wechat.Reply/code_reply')->option(['real_name' => '获取关注回复二维码']);
//关键字回复列表
Route::get('wechat/keyword', 'v1.application.wechat.Reply/index')->option(['real_name' => '关键字回复列表']);
//关键字详情
Route::get('wechat/keyword/:id', 'v1.application.wechat.Reply/read')->option(['real_name' => '关键字回复详情']);
//保存关键字修改
Route::post('wechat/keyword/:id', 'v1.application.wechat.Reply/save')->option(['real_name' => '保存关键字回复']);
//删除关键字
Route::delete('wechat/keyword/:id', 'v1.application.wechat.Reply/delete')->option(['real_name' => '删除关键字回复']);
//修改关键字状态
Route::put('wechat/keyword/set_status/:id/:status', 'v1.application.wechat.Reply/set_status')->option(['real_name' => '修改关键字回复状态']);
//一键同步微信模版消息消息
Route::get('wechat/syncSubscribe', 'v1.application.wechat.WechatTemplate/syncSubscribe')->name('syncSubscribe')->option(['real_name' => '一键同步模版消息']);
})->option(['parent' => 'app', 'cate_name' => '公众号']);
/** 小程序 */
Route::group(function () {
//一键同步订阅消息
Route::get('routine/syncSubscribe', 'v1.application.routine.RoutineTemplate/syncSubscribe')->name('syncSubscribe')->option(['real_name' => '一键同步订阅消息']);
//下载小程序模版页面数据
Route::get('routine/info', 'v1.application.routine.RoutineTemplate/getDownloadInfo')->option(['real_name' => '下载小程序页面数据']);
//下载小程序模版
Route::post('routine/download', 'v1.application.routine.RoutineTemplate/downloadTemp')->option(['real_name' => '下载小程序模版']);
})->option(['parent' => 'app', 'cate_name' => '小程序']);
/** 公众号渠道码 */
Route::group(function () {
Route::get('wechat_qrcode/cate/list', 'v1.application.wechat.WechatQrcode/getCateList')->option(['real_name' => '渠道码分类列表']);
Route::get('wechat_qrcode/cate/create/:id', 'v1.application.wechat.WechatQrcode/createForm')->option(['real_name' => '渠道码分类添加编辑表单']);
Route::post('wechat_qrcode/cate/save', 'v1.application.wechat.WechatQrcode/saveCate')->option(['real_name' => '渠道码分类保存']);
Route::delete('wechat_qrcode/cate/del/:id', 'v1.application.wechat.WechatQrcode/delCate')->option(['real_name' => '渠道码分类删除']);
Route::post('wechat_qrcode/save/:id', 'v1.application.wechat.WechatQrcode/saveQrcode')->option(['real_name' => '保存渠道码']);
Route::get('wechat_qrcode/info/:id', 'v1.application.wechat.WechatQrcode/qrcodeInfo')->option(['real_name' => '渠道码详情']);
Route::get('wechat_qrcode/list', 'v1.application.wechat.WechatQrcode/qrcodeList')->option(['real_name' => '渠道码列表']);
Route::delete('wechat_qrcode/del/:id', 'v1.application.wechat.WechatQrcode/delQrcode')->option(['real_name' => '删除渠道码']);
Route::put('wechat_qrcode/set_status/:id/:status', 'v1.application.wechat.WechatQrcode/setStatus')->option(['real_name' => '切换渠道码状态']);
Route::get('wechat_qrcode/user_list/:qid', 'v1.application.wechat.WechatQrcode/userList')->option(['real_name' => '渠道码用户列表']);
Route::get('wechat_qrcode/statistic/:qid', 'v1.application.wechat.WechatQrcode/qrcodeStatistic')->option(['real_name' => '渠道码统计']);
})->option(['parent' => 'app', 'cate_name' => '公众号渠道码']);
})->middleware([
\app\http\middleware\AllowOriginMiddleware::class,
\app\adminapi\middleware\AdminAuthTokenMiddleware::class,
\app\adminapi\middleware\AdminCheckRoleMiddleware::class,
\app\adminapi\middleware\AdminLogMiddleware::class
])->option(['mark' => 'app', 'mark_name' => '应用模块']);

View File

@ -0,0 +1,64 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
use think\facade\Route;
/**
* 案例管理 相关路由
*/
Route::group('caseinfo', function () {
/** 案例 */
Route::group(function () {
//案例资源路由
Route::resource('caseinfo', 'v1.caseinfo.Caseinfo')->option([
'real_name' => [
'index' => '获取案例列表',
'create' => '获取案例表单',
'read' => '获取案例详细信息',
'save' => '保存案例',
'edit' => '获取修改案例表单',
'update' => '修改案例',
'delete' => '删除案例'
]
]);
//关联商品
Route::put('caseinfo/relation/:id', 'v1.caseinfo.Caseinfo/relation')->name('Relation')->option(['real_name' => '案例关联商品']);
//取消关联
Route::put('caseinfo/unrelation/:id', 'v1.caseinfo.Caseinfo/unrelation')->name('UnRelation')->option(['real_name' => '取消案例关联商品']);
})->option(['parent' => 'caseinfo', 'cate_name' => '案例管理']);
/** 案例分类 */
Route::group( function () {
//案例分类资源路由
Route::resource('category', 'v1.caseinfo.CaseCategory')->except(['read'])->option([
'real_name' => [
'index' => '获取案例分类列表',
'create' => '获取案例分类表单',
'save' => '保存案例分类',
'edit' => '获取修改案例分类表单',
'update' => '修改案例分类',
'delete' => '删除案例分类'
]
]);
//修改状态
Route::put('category/set_status/:id/:status', 'v1.caseinfo.CaseCategory/set_status')->name('CategoryStatus')->option(['real_name' => '修改案例分类状态']);
//分类列表
Route::get('category_list', 'v1.caseinfo.CaseCategory/categoryList')->name('categoryList')->option(['real_name' => '分类列表']);
//分类树形列表
Route::get('category_tree_list', 'v1.caseinfo.CaseCategory/getTreeList')->name('getTreeList')->option(['real_name' => '分类树形列表']);
})->option(['parent' => 'caseinfo', 'cate_name' => '案例分类']);
})->middleware([
\app\http\middleware\AllowOriginMiddleware::class,
\app\adminapi\middleware\AdminAuthTokenMiddleware::class,
\app\adminapi\middleware\AdminCheckRoleMiddleware::class,
\app\adminapi\middleware\AdminLogMiddleware::class
])->option(['mark' => 'caseinfo', 'mark_name' => '案例模块']);

View File

@ -0,0 +1,64 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
use think\facade\Route;
/**
* 文章管理 相关路由
*/
Route::group('cms', function () {
/** 文章 */
Route::group(function () {
//文章资源路由
Route::resource('cms', 'v1.cms.Caseinfo')->option([
'real_name' => [
'index' => '获取文章列表',
'create' => '获取文章表单',
'read' => '获取文章详细信息',
'save' => '保存文章',
'edit' => '获取修改文章表单',
'update' => '修改文章',
'delete' => '删除文章'
]
]);
//关联商品
Route::put('cms/relation/:id', 'v1.cms.Caseinfo/relation')->name('Relation')->option(['real_name' => '文章关联商品']);
//取消关联
Route::put('cms/unrelation/:id', 'v1.cms.Caseinfo/unrelation')->name('UnRelation')->option(['real_name' => '取消文章关联商品']);
})->option(['parent' => 'cms', 'cate_name' => '文章管理']);
/** 文章分类 */
Route::group(function () {
//文章分类资源路由
Route::resource('category', 'v1.cms.CaseCategory')->except(['read'])->option([
'real_name' => [
'index' => '获取文章分类列表',
'create' => '获取文章分类表单',
'save' => '保存文章分类',
'edit' => '获取修改文章分类表单',
'update' => '修改文章分类',
'delete' => '删除文章分类'
]
]);
//修改状态
Route::put('category/set_status/:id/:status', 'v1.cms.CaseCategory/set_status')->name('CategoryStatus')->option(['real_name' => '修改文章分类状态']);
//分类列表
Route::get('category_list', 'v1.cms.CaseCategory/categoryList')->name('categoryList')->option(['real_name' => '分类列表']);
//分类树形列表
Route::get('category_tree_list', 'v1.cms.CaseCategory/getTreeList')->name('getTreeList')->option(['real_name' => '分类树形列表']);
})->option(['parent' => 'cms', 'cate_name' => '文章分类']);
})->middleware([
\app\http\middleware\AllowOriginMiddleware::class,
\app\adminapi\middleware\AdminAuthTokenMiddleware::class,
\app\adminapi\middleware\AdminCheckRoleMiddleware::class,
\app\adminapi\middleware\AdminLogMiddleware::class
])->option(['mark' => 'cms', 'mark_name' => '文章模块']);

View File

@ -0,0 +1,51 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
use think\facade\Route;
/**
* 文件下载、导出相关路由
*/
Route::group(function () {
//下载备份记录表
Route::get('backup/download', 'v1.system.SystemDatabackup/downloadFile')->option(['real_name' => '下载表备份记录']);
//首页统计数据
Route::get('home/header', 'Common/homeStatics')->option(['real_name' => '首页统计数据']);
//首页订单图表
Route::get('home/order', 'Common/orderChart')->option(['real_name' => '首页订单图表']);
//首页用户图表
Route::get('home/user', 'Common/userChart')->option(['real_name' => '首页用户图表']);
//首页交易额排行
Route::get('home/rank', 'Common/purchaseRanking')->option(['real_name' => '首页交易额排行']);
//消息提醒
Route::get('jnotice', 'Common/jnotice')->option(['real_name' => '消息提醒']);
//验证授权
Route::get('check_auth', 'Common/auth')->option(['real_name' => '验证授权']);
//申请授权
Route::post('auth_apply', 'Common/auth_apply')->option(['real_name' => '申请授权']);
//授权
Route::get('auth', 'Common/auth')->option(['real_name' => '授权信息']);
//获取左侧菜单
Route::get('menus', 'v1.setting.SystemMenus/menus')->option(['real_name' => '左侧菜单']);
//获取搜索菜单列表
Route::get('menusList', 'Common/menusList')->option(['real_name' => '搜索菜单列表']);
//获取logo
Route::get('logo', 'Common/getLogo')->option(['real_name' => '获取logo']);
//查询版权
Route::get('copyright', 'Common/copyright')->option(['real_name' => '申请版权']);
//保存版权
Route::post('copyright', 'Common/saveCopyright')->option(['real_name' => '保存版权']);
})->middleware([
\app\http\middleware\AllowOriginMiddleware::class,
\app\adminapi\middleware\AdminAuthTokenMiddleware::class,
\app\adminapi\middleware\AdminCheckRoleMiddleware::class,
\app\adminapi\middleware\AdminLogMiddleware::class
])->option(['mark' => 'common', 'mark_name' => '系统数据']);

View File

@ -0,0 +1,35 @@
<?php
/**
* +----------------------------------------------------------------------
* | CRMEB [ CRMEB赋能开发者助力企业发展 ]
* +----------------------------------------------------------------------
* | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
* +----------------------------------------------------------------------
* | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
* +----------------------------------------------------------------------
* | Author: CRMEB Team <admin@crmeb.com>
* +----------------------------------------------------------------------
*/
use think\facade\Route;
/**
* crud 自动加载路由
* 自动加载crud目录下的所有路由文件
*/
Route::group(function () {
$path = $this->app->getRootPath() . 'app' . DS . 'adminapi' . DS . 'route' . DS . 'crud';
if (is_dir($path)) {
$files = scandir($path);
foreach ($files as $file) {
if ($file != '.' && $file != '..') {
include $path . DS . $file;
}
}
}
})->middleware([
\app\http\middleware\AllowOriginMiddleware::class,
\app\adminapi\middleware\AdminAuthTokenMiddleware::class,
\app\adminapi\middleware\AdminCheckRoleMiddleware::class,
\app\adminapi\middleware\AdminLogMiddleware::class
])->option(['mark' => 'crud', 'mark_name' => '生成代码路由']);

View File

@ -0,0 +1,48 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
use think\facade\Route;
/**
* 导出excel相关路由
*/
Route::group('export', function () {
//用户列表
Route::get('user_list', 'v1.export.ExportExcel/userList')->option(['real_name' => '用户列表导出']);
//订单列表
Route::get('order_list', 'v1.export.ExportExcel/orderList')->option(['real_name' => '订单列表导出']);
//发货订单列表
Route::get('order_delivery_list', 'v1.export.ExportExcel/orderDeliveryList')->option(['real_name' => '发货订单列表导出']);
//商品列表
Route::get('product_list', 'v1.export.ExportExcel/productList')->option(['real_name' => '商品列表导出']);
//砍价列表
Route::get('bargain_list', 'v1.export.ExportExcel/bargainList')->option(['real_name' => '砍价商品列表导出']);
//拼团列表
Route::get('combination_list', 'v1.export.ExportExcel/combinationList')->option(['real_name' => '拼团商品列表导出']);
//秒杀列表
Route::get('seckill_list', 'v1.export.ExportExcel/seckillList')->option(['real_name' => '秒杀商品列表导出']);
//导出会员卡
Route::get('member_card/:id', 'v1.export.ExportExcel/memberCardList')->option(['real_name' => '会员卡导出']);
//分销用户推广列表
Route::get('userAgent', 'v1.export.ExportExcel/userAgent')->option(['real_name' => '分销员推广列表导出']);
//用户资金监控
Route::get('userFinance', 'v1.export.ExportExcel/userFinance')->option(['real_name' => '用户资金导出']);
//用户佣金
Route::get('userCommission', 'v1.export.ExportExcel/userCommission')->option(['real_name' => '用户佣金导出']);
//用户积分
Route::get('userPoint', 'v1.export.ExportExcel/userPoint')->option(['real_name' => '用户积分导出']);
//用户充值
Route::get('userRecharge', 'v1.export.ExportExcel/userRecharge')->option(['real_name' => '用户充值导出']);
})->middleware([
\app\http\middleware\AllowOriginMiddleware::class,
\app\adminapi\middleware\AdminAuthTokenMiddleware::class,
\app\adminapi\middleware\AdminCheckRoleMiddleware::class,
\app\adminapi\middleware\AdminLogMiddleware::class
])->option(['mark' => 'export', 'mark_name' => '数据导出']);

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