This commit is contained in:
全栈小学生 2023-06-01 19:37:03 +08:00
parent ee1a7c20d6
commit 2370e1a476
42 changed files with 115 additions and 106 deletions

View File

@ -26,8 +26,6 @@ Route::group(function () {
//一次校验验证码
Route::get('captcha/check', 'login.Captcha/check');
Route::get('terminal', 'sys.Terminal/exec');
Route::get('test', 'login.Login/test');
});

View File

@ -1,8 +1,6 @@
<?php
// 全局中间件定义文件
use app\api\middleware\AllowCrossDomain;
return [
//跨域请求中间件
AllowCrossDomain::class,
];

View File

@ -53,10 +53,8 @@ class AllowCrossDomain
$origin = rtrim(str_replace('https://','',str_replace('http://','',$referer)),"/");
}
// $origin = $request->header('origin');
if(env('app_debug') || ($origin && in_array($origin, $allow_origin))){
header('Access-Control-Allow-Origin: *');
// header('Access-Control-Allow-Origin: ' . $origin);
}else{
header('Access-Control-Allow-Origin: *');
throw new ServerException('SERVER_CROSS_REQUEST_FAIL', 409);

View File

@ -12,6 +12,7 @@
use app\api\middleware\ApiChannel;
use app\api\middleware\ApiCheckToken;
use app\api\middleware\ApiLog;
use app\api\middleware\AllowCrossDomain;
use think\facade\Route;
@ -33,6 +34,6 @@ Route::group('article', function () {
//文章分类详情
Route::get('category/:id', 'article.ArticleCategory/info');
})->middleware(ApiChannel::class)
})->middleware(AllowCrossDomain::class)->middleware(ApiChannel::class)
->middleware(ApiCheckToken::class, false)
->middleware(ApiLog::class);

View File

@ -12,6 +12,7 @@
use app\api\middleware\ApiChannel;
use app\api\middleware\ApiCheckToken;
use app\api\middleware\ApiLog;
use app\api\middleware\AllowCrossDomain;
use think\facade\Route;
@ -22,6 +23,6 @@ Route::group('auth',function () {
Route::put('logout', 'login.Login/logout');
})->middleware(ApiChannel::class)
})->middleware(AllowCrossDomain::class)->middleware(ApiChannel::class)
->middleware(ApiCheckToken::class, true)
->middleware(ApiLog::class);

View File

@ -11,6 +11,7 @@
use app\api\middleware\ApiCheckToken;
use app\api\middleware\ApiLog;
use app\api\middleware\AllowCrossDomain;
use think\facade\Route;
@ -26,5 +27,5 @@ Route::group('diy', function() {
Route::get('share', 'diy.Diy/share');
})->middleware(ApiLog::class)
})->middleware(AllowCrossDomain::class)->middleware(ApiLog::class)
->middleware(ApiCheckToken::class, false);

View File

@ -12,6 +12,7 @@
use app\api\middleware\ApiChannel;
use app\api\middleware\ApiCheckToken;
use app\api\middleware\ApiLog;
use app\api\middleware\AllowCrossDomain;
use think\facade\Route;
@ -28,6 +29,6 @@ Route::group('file', function () {
//base64图片
Route::post('image/base64', 'upload.Upload/imageBase64');
})->middleware(ApiChannel::class)
})->middleware(AllowCrossDomain::class)->middleware(ApiChannel::class)
->middleware(ApiCheckToken::class, true)
->middleware(ApiLog::class);

View File

@ -12,6 +12,7 @@
use app\api\middleware\ApiChannel;
use app\api\middleware\ApiCheckToken;
use app\api\middleware\ApiLog;
use app\api\middleware\AllowCrossDomain;
use think\facade\Route;
@ -71,7 +72,7 @@ Route::group('member', function() {
Route::put('cashout_account/:account_id', 'member.CashOutAccount/edit');
// 删除提现账号
Route::delete('cashout_account/:account_id', 'member.CashOutAccount/del');
})->middleware(ApiChannel::class)
})->middleware(AllowCrossDomain::class)->middleware(ApiChannel::class)
->middleware(ApiCheckToken::class, true)
->middleware(ApiLog::class);
@ -81,6 +82,6 @@ Route::group('member', function() {
/***************************************************** 会员管理 ****************************************************/
//会员日志
Route::post('log', 'member.Member/log');
})->middleware(ApiChannel::class)
})->middleware(AllowCrossDomain::class)->middleware(ApiChannel::class)
->middleware(ApiCheckToken::class)
->middleware(ApiLog::class);

View File

@ -12,6 +12,7 @@
use app\api\middleware\ApiChannel;
use app\api\middleware\ApiCheckToken;
use app\api\middleware\ApiLog;
use app\api\middleware\AllowCrossDomain;
use think\facade\Route;
@ -27,6 +28,6 @@ Route::group('order', function () {
Route::get('recharge', 'order.Recharge/lists');
// 充值订单详情
Route::get('recharge/:order_id', 'order.Recharge/detail');
})->middleware(ApiChannel::class)
})->middleware(AllowCrossDomain::class)->middleware(ApiChannel::class)
->middleware(ApiCheckToken::class, true)
->middleware(ApiLog::class);

View File

@ -11,6 +11,7 @@
use app\api\middleware\ApiChannel;
use app\api\middleware\ApiCheckToken;
use app\api\middleware\AllowCrossDomain;
use app\api\middleware\ApiLog;
use think\facade\Route;
@ -18,7 +19,7 @@ use think\facade\Route;
Route::any('pay/notify/:site_id/:channel/:type/:action', 'pay.Pay/notify')
->middleware(ApiChannel::class)
->middleware(ApiCheckToken::class)
->middleware(ApiLog::class);
->middleware(ApiLog::class)->allowCrossDomain();
/**
* 路由
*/
@ -28,6 +29,6 @@ Route::group('pay',function () {
//支付信息
Route::get('info/:out_trade_no', 'pay.Pay/info');
})->middleware(ApiChannel::class)
})->middleware(AllowCrossDomain::class)->middleware(ApiChannel::class)
->middleware(ApiCheckToken::class)
->middleware(ApiLog::class);

View File

@ -13,12 +13,13 @@ use app\api\middleware\ApiChannel;
use app\api\middleware\ApiCheckToken;
use app\api\middleware\ApiLog;
use think\facade\Route;
use app\api\middleware\AllowCrossDomain;
//公众号消息推送
Route::any('wechat/serve/:site_id', 'wechat.Serve/serve')
->middleware(ApiChannel::class)
->middleware(ApiCheckToken::class)
->middleware(ApiLog::class);
->middleware(ApiLog::class)->allowCrossDomain();
/**
@ -74,7 +75,8 @@ Route::group(function () {
Route::get('site', 'sys.Config/site');
//场景域名
Route::get('scene_domain', 'sys.Config/getSceneDomain');
})->middleware(ApiChannel::class)
})->middleware(AllowCrossDomain::class)
->middleware(ApiChannel::class)
->middleware(ApiCheckToken::class)
->middleware(ApiLog::class);
//加载插件路由

View File

@ -19,7 +19,7 @@ namespace app\dict\sys;
class SmsDict
{
//阿里云短信
const ALISMS = 'ali';
const ALISMS = 'aliyun';
//腾讯云短信
const TENCENTSMS = 'tencent';

View File

@ -25,7 +25,7 @@ class StorageDict
const QINIU = 'qiniu';
//阿里云存储
const ALI = 'ali';
const ALI = 'aliyun';
//腾讯云存储
const TENCENT = 'tencent';

View File

@ -234,6 +234,11 @@ class Index extends BaseInstall
return fail('平台信息不能为空!');
}
if ($site_username == $username) {
$this->setSuccessLog([ '站点管理员和平台管理员不能相同,请重新输入', 'error' ]);
return fail('站点管理员和平台管理员不能相同,请重新输入');
}
if ($password != $password2) {
$this->setSuccessLog([ '平台两次密码输入不一样,请重新输入', 'error' ]);
return fail('平台两次密码输入不一样,请重新输入');
@ -244,6 +249,11 @@ class Index extends BaseInstall
return fail('平台信息不能为空!');
}
if($site_username == $username) {
$this->setSuccessLog([ '站点账号不能跟平台账号一致', 'error' ]);
return fail('站点账号不能跟平台账号一致!');
}
if ($site_password != $site_password2) {
$this->setSuccessLog([ '站点两次密码输入不一样,请重新输入', 'error' ]);
return fail('站点两次密码输入不一样,请重新输入');
@ -292,7 +302,11 @@ class Index extends BaseInstall
}
if ($site_name == '' || $site_username == '' || $site_password == '') {
return fail('平台信息不能为空!');
return fail('站点信息不能为空!');
}
if($site_username == $username) {
return fail('站点账号不能跟平台账号一致');
}
if ($site_password != $site_password2) {

View File

@ -1210,9 +1210,9 @@ CREATE TABLE jobs (
id int(11) NOT NULL AUTO_INCREMENT,
queue varchar(255) NOT NULL,
payload longtext NOT NULL,
attempts tinyint(3) UNSIGNED NOT NULL,
reserved tinyint(3) UNSIGNED NOT NULL,
reserve_time int(10) UNSIGNED DEFAULT NULL,
attempts tinyint(3) UNSIGNED NOT NULL DEFAULT 0,
reserved tinyint(3) UNSIGNED NOT NULL DEFAULT 0,
reserve_time int(10) UNSIGNED DEFAULT 0,
available_time int(10) UNSIGNED NOT NULL,
create_time int(10) UNSIGNED NOT NULL,
PRIMARY KEY (id)

View File

@ -50,7 +50,7 @@
</div>
<a href="javascript:void(0)" class="other-links-text" >站点电脑端</a>
</li>
<li class="other-links-item" onclick="window.open('{$root_url}/wap/s1')">
<li class="other-links-item" onclick="window.open('{$root_url}/wap/s1/')">
<div class="other-links-pic">
<img src="INSTALL_IMG/site_h5.png" alt="">
</div>

View File

@ -62,7 +62,7 @@ return [
//存储方式
'storage_type_local' => 'local',
'storage_type_qiniu' => 'qiniu',
'storage_type_ali' => 'ali',
'storage_type_ali' => 'aliyun',
'storage_type_qcloud' => 'tencent',
],

View File

@ -106,6 +106,7 @@ return [
'WECHAT_TEMPLATE_NEED_NO' => '微信消息模板缺少模板编号',
'NOTICE_NOT_OPEN_SMS' => '当前消息未开启短信发送',
'NOTICE_SMS_EMPTY' => '手机号为空',
'NOTICE_SMS_NOT_OPEN' => '短信未启用',
//会员相关
'MOBILE_IS_EXIST' => '当前手机号已绑定账号',

View File

@ -20,7 +20,7 @@ class Sms
$to = $data['to'];//发送对象主题
$mobile = $to['mobile'] ?? '';
//完全信任消息的设置, 不再依赖support_type
if (!$template['is_sms']) {
if ($template['is_sms']) {
$sms_id = $template['sms_id'];//发送模板id
$content = $template['sms_content'];
$member_id = $to['member_id'] ?? 0;

View File

@ -73,10 +73,6 @@ class Weapp
}
}
}
}else {
if (!$template['async']) {
throw new NoticeException('WEAPP_TEMPLATE_NOTICE_NOT_OPEN');
}
}
return true;
}

View File

@ -84,10 +84,6 @@ class Wechat
}
}
}
}else {
if (!$template['async']) {
throw new NoticeException('WECHAT_TEMPLATE_NOTICE_NOT_OPEN');
}
}
return true;
}

View File

@ -14,9 +14,10 @@ class MemberVerifySuccess extends BaseNoticeTemplate
private $key = 'member_verify_code';
public function handle(array $data)
public function handle(array $params)
{
if ($this->key == $data['key']) {
if ($this->key == $params['key']){
$data = $params['data'];
return $this->toReturn(
[
'code' => $data['code'],

View File

@ -28,7 +28,7 @@ class AddSiteAfterListener
{
// 初始化文章数据
( new InstallArticleService() )->install([ 'site_id' => $data[ 'site_id' ] ]);
// ( new InstallArticleService() )->install([ 'site_id' => $data[ 'site_id' ] ]);
//加载插件语言包
return;
}

View File

@ -229,6 +229,7 @@ class DiyService extends BaseAdminService
}
$data[ 'component' ] = $this->getComponentList($data[ 'name' ]);
$data[ 'domain_url' ] = ( new SystemService() )->getUrl();
$data[ 'site_id' ] = $this->site_id;
return $data;
}

View File

@ -19,6 +19,7 @@ use app\service\admin\sys\SystemService;
use app\service\core\member\CoreMemberService;
use Carbon\Carbon;
use core\base\BaseAdminService;
use think\facade\Db;
/**
@ -54,7 +55,7 @@ class SiteStatService extends BaseAdminService
'version' => [],
'visit_stat' => [
'date' => [],
'value' => [980,1323,882,762,865,923,1105]
'value' => []
],
'member_stat' => [
'type' => ['男','女','未知'],
@ -88,7 +89,12 @@ class SiteStatService extends BaseAdminService
$data['system'] = (new SystemService())->getInfo();
$data['version'] = $data['system']['version'] ?? [];
$time = time();
for ($i=1; $i<=7; $i++) $data['visit_stat']['date'][] = date('Y-m-d', strtotime( '+' . $i-7 .' days', $time));
for ($i=1; $i<=7; $i++){
$time_data = date('Y-m-d', strtotime( '+' . $i-7 .' days', $time));
$data['visit_stat']['date'][] = $time_data;
$time_arr = get_start_and_end_time_by_day($time_data);
$data['visit_stat']['value'][] = (new MemberService())->getCount([[ '', 'exp', Db::raw('(`create_time` >= ' . $time_arr[0] . ') and (`create_time` < ' . $time_arr[1] . ')') ]]);
}
$member_count = (new MemberService())->getCount();
$man_count = (new MemberService())->getCount([ ['sex', '=', '1'] ]);
$woman_count = (new MemberService())->getCount([ ['sex', '=', '2'] ]);

View File

@ -49,7 +49,7 @@ class SystemService extends BaseAdminService
*/
public function getUrl()
{
$site_tag = $this->site_id == 1 ? '' : '/s' . $this->site_id;
$site_tag = $this->site_id == 31 ? '' : '/s' . $this->site_id;
$data = [
'wap_url' => ( !empty(env("system.wap_domain")) ? env("system.wap_domain") : request()->domain() ) . "/wap" . $site_tag,
'web_url' => ( !empty(env("system.web_domain")) ? env("system.web_domain") : request()->domain() ) . "/web" . $site_tag,
@ -122,11 +122,11 @@ class SystemService extends BaseAdminService
* 清理缓存
*/
public function schemaCache(){
if (is_dir(dirname($_SERVER['DOCUMENT_ROOT']) . '/runtime/schema')) {
rmdirs(dirname($_SERVER['DOCUMENT_ROOT']) . '/runtime/schema');
return 'CLEAR_MYSQL_CACHE_SUCCESS';
}
return;
return 'CLEAR_MYSQL_CACHE_SUCCESS';
}
/**

View File

@ -50,7 +50,7 @@ class RegisterService extends BaseApiService
$member_id = $data;
} else{
if(empty($data['nickname'])){
$data['nickname'] = $data['username'] ?? substr_replace($data['mobile'], '****', 3, 4) ?? $this->createName();
$data['nickname'] = $data['username'] ?? !empty($mobile) ? substr_replace($mobile, '****', 3, 4) : $this->createName();
}
$data['register_channel'] = $this->channel;
$data['register_type'] = $type;

View File

@ -31,7 +31,6 @@ class NoticeService extends BaseApiService
* 发送消息
* @param $key
* @param $data
* @param bool $is_delay 是否延时
* @return bool
*/
public function send($key, $data)

View File

@ -109,7 +109,7 @@ class WechatAuthService extends BaseApiService
$is_bind_mobile = $config['is_bind_mobile'];
$is_auth_register = $config['is_auth_register'];
if ($is_bind_mobile == 0 && $is_auth_register == 1) {
return $this->register($openid);
return $this->register($openid, '', $nickname, $avatar);
} else {
return ['avatar' => $avatar, 'nickname' => $nickname, 'openid' => $openid];
}
@ -146,7 +146,7 @@ class WechatAuthService extends BaseApiService
* @return void
* @throws InvalidArgumentException
*/
public function register(string $openid, string|int $mobile = '')
public function register(string $openid, string|int $mobile = '', string $nickname = '', string $avatar = '')
{
$member_service = new MemberService();
$member_info = $member_service->findMemberInfo(['wx_openid' => $openid, 'site_id' => $this->site_id]);
@ -155,6 +155,8 @@ class WechatAuthService extends BaseApiService
$result = $register_service->register($mobile,
[
'wx_openid' => $openid,
'nickname' => $nickname,
'headimg' => $avatar
],
MemberRegisterTypeDict::WECHAT
);

View File

@ -518,6 +518,7 @@ class CoreAddonInstallService extends CoreAddonBaseService
$core_addon_service->set($install_data);
//清理缓存
Cache::tag(self::$cache_tag_name)->clear();
Cache::set("local_install_addons", []);
//执行命令
//执行插件安装方法
$class = "addon\\" . $this->addon . "\\" . Str::studly($this->addon);
@ -559,7 +560,7 @@ class CoreAddonInstallService extends CoreAddonBaseService
$core_addon_service = new CoreAddonService();
$core_addon_service->delByKey($this->addon);
Cache::set("local_install_addons", []);
//清理缓存
Cache::tag(self::$cache_tag_name)->clear();
return true;

View File

@ -39,13 +39,17 @@ class CoreAddonService extends CoreAddonBaseService
$install_addon_list = $this->model->append(['status_name'])->column('title, icon, key, desc, status, author, version, install_time, update_time, cover', 'key');
foreach($files as $path) {
$data = $this->getAddonConfig($path);
$icon = addon_resource($data['key'], "icon.png");
$data['icon'] = is_file($icon) ? $icon : '';
$cover = addon_resource($data['key'], "cover.png");
$data['cover'] = is_file($cover) ? $cover : '';
$key = $data['key'];
$data['install_info'] = $install_addon_list[$key] ?? [];
$list[] = $data;
if(isset($data['key']))
{
$icon = addon_resource($data['key'], "icon.png");
$data['icon'] = is_file($icon) ? $icon : '';
$cover = addon_resource($data['key'], "cover.png");
$data['cover'] = is_file($cover) ? $cover : '';
$key = $data['key'];
$data['install_info'] = $install_addon_list[$key] ?? [];
$list[] = $data;
}
}
}
return $list;

View File

@ -94,7 +94,7 @@ class CoreSmsService extends BaseCoreService
{
$info = (new CoreConfigService())->getConfig($site_id, 'SMS')['value'] ?? [];
if (empty($info))
throw new NoticeException('NO_SMS_DRIVER_OPEN');
throw new NoticeException('NOTICE_SMS_NOT_OPEN');
$sms_type = $info['default'] ?? '';
$config = array(

View File

@ -48,6 +48,6 @@ class NoticeService extends BaseCoreService
$template = (new CoreNoticeService())->getInfo($site_id, $key);
if(empty($template)) return false;
return Notice::invoke(['site_id' => $site_id, 'key' => $key, 'data' => $data, 'template' => $template], is_open:$template['async']);
return Notice::invoke(['site_id' => $site_id, 'key' => $key, 'data' => $data, 'template' => $template], is_async:false);
}
}

View File

@ -13,11 +13,9 @@ namespace app\service\core\sys;
use app\model\sys\SysAttachment;
use app\service\core\upload\CoreFileService;
use app\service\core\upload\CoreStorageService;
use core\base\BaseCoreService;
use core\exception\AdminException;
use core\exception\UploadFileException;
use core\upload\FileDriver;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;

View File

@ -28,7 +28,7 @@ class CoreStorageService extends BaseCoreService
*/
public function getDefaultStorage(int $site_id = 0)
{
$storage_list = $this->getStorageList($site_id);
$storage_list = $this->getStorageConfigList($site_id);
foreach($storage_list as $k => $v){
if($v['is_use'] == StorageDict::ON){
$item_storage = $v['params'] ?? [];
@ -76,4 +76,28 @@ class CoreStorageService extends BaseCoreService
}
return $list;
}
/**
* 获取配置列表
* @param int $site_id
* @return array
*/
public function getStorageConfigList(int $site_id = 0)
{
$config_type = $this->getStorageConfig($site_id);
$storage_type_list = StorageDict::getType();
$list = [];
foreach ($storage_type_list as $k => $v) {
$data = [];
$data['storage_type'] = $k;
$data['is_use'] = $k == $config_type['default'] ? StorageDict::ON : StorageDict::OFF;
$data['name'] = $v['name'];
foreach ($v['params'] as $k_param => $v_param) {
$data['params'][$k_param] = $config_type[$k][$k_param] ?? '';
}
$list[] = $data;
}
return $list;
}
}

View File

@ -34,7 +34,7 @@ abstract class BaseJob extends Dispatch
/**
* 运行队列
* 消费任务
* @param Job $job
* @param $params
*/
@ -52,7 +52,7 @@ abstract class BaseJob extends Dispatch
/**
* 执行队列
* 执行任务
* @param string $action
* @param Job $job
* @param array $data

View File

@ -42,19 +42,13 @@ abstract class BaseDict extends Storage
//尚未安装不加载插件
return [];
}
$cache_name = "local_install_addons";
return cache_remember(
$cache_name,
function () {
$list = Db::name("addon")->column("key");
return $list;
},
self::$cache_tag_name
);
// return Cache::tag(self::$cache_tag_name)->remember($cache_name, function () {
// $list = Db::name("addon")->column("key");
// return $list;
// });
$addons = Cache::get("local_install_addons");
if(empty($addons))
{
$addons = Db::name("addon")->column("key");
Cache::set("local_install_addons", $addons);
}
return $addons;
}
/**

View File

@ -47,7 +47,6 @@ class Aliyun extends BaseSms
AlibabaCloud::accessKeyClient($this->app_key, $this->secret_key)
->regionId('cn-hangzhou')
->asDefaultClient();
$result = AlibabaCloud::rpcRequest()
->product('Dysmsapi')
->host('dysmsapi.aliyuncs.com')
@ -60,7 +59,7 @@ class Aliyun extends BaseSms
'PhoneNumbers' => $mobile,
'SignName' => $this->sign,
'TemplateCode' => $template_id,
'TemplateParam' => $data,
'TemplateParam' => json_encode($data, JSON_UNESCAPED_UNICODE),
],
])
->request();

View File

@ -8,15 +8,12 @@
// +----------------------------------------------------------------------
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace core\upload;
use app\service\core\upload\CoreUploadConfigService;
use core\exception\UploadFileException;
use core\loader\DriverConfig;
use core\loader\Storage;
/**
* Class BaseUpload
*/

View File

@ -1,11 +1,4 @@
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2023-02-17
* Time: 15:58
*/
namespace core\upload;
use core\exception\UploadFileException;
@ -13,8 +6,6 @@ use Exception;
/**
* 文件管理驱动类
* Class FileDriver
* @package core\file
*/
class Local extends BaseUpload
{

View File

@ -1,11 +1,4 @@
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2023-02-17
* Time: 15:58
*/
namespace core\upload;
use core\exception\UploadFileException;
@ -14,8 +7,6 @@ use Qcloud\Cos\Client;
/**
* 腾讯云存储引擎 (COS)
* Class Qiniu
* @package app\common\library\storage\engine
*/
class Qcloud extends BaseUpload
{

View File

@ -1,11 +1,4 @@
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2023-02-17
* Time: 15:58
*/
namespace core\upload;
use core\exception\UploadFileException;
@ -18,8 +11,6 @@ use function core\upload\storage\str_contains;
/**
* 文件管理驱动类
* Class FileDriver
* @package core\file
*/
class Qiniu extends BaseUpload
{