update niucloud

This commit is contained in:
全栈小学生 2023-07-01 16:20:54 +08:00
parent 509de0cd05
commit e0b9bb5804
104 changed files with 2053 additions and 479 deletions

View File

@ -1,9 +1,11 @@
<?php
return [
'recharge_success' => [
'temp_key' => '111',
'tid' => '111',
'content' => [
['消息内容', '{name}', 'keyword1'],
],
'kid_list' => [1, 3, 4, 2],
'scene_desc' => ''
]
];

View File

@ -0,0 +1,56 @@
<?php
// +----------------------------------------------------------------------
// | Niucloud-admin 企业快速开发的saas管理平台
// +----------------------------------------------------------------------
// | 官方网址https://www.niucloud-admin.com
// +----------------------------------------------------------------------
// | niucloud团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace app\adminapi\controller\applet;
use app\model\applet\AppletSiteVersion;
use app\service\admin\applet\AppletVersionService;
use app\service\admin\applet\AppletVersionSiteService;
use core\base\BaseAdminController;
use think\Response;
/**
* 站点小程序版本升级下载控制器
*/
class SiteVersion extends BaseAdminController
{
/**
* 列表
* @return Response
*/
public function lists()
{
$data = $this->request->params([
]);
return success(( new AppletVersionSiteService())->getPage($data));
}
/**
* 详情
* @param int $id
*/
public function info(int $id)
{
return success(( new AppletVersionSiteService() )->getInfo($id));
}
/**
* 查询最后一个下载或升级的版本
* @param string $type
* @return Response
*/
public function getLastVersion(string $type){
return success(( new AppletVersionSiteService() )->getLastVersion($type));
}
}

View File

@ -0,0 +1,110 @@
<?php
// +----------------------------------------------------------------------
// | Niucloud-admin 企业快速开发的saas管理平台
// +----------------------------------------------------------------------
// | 官方网址https://www.niucloud-admin.com
// +----------------------------------------------------------------------
// | niucloud团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace app\adminapi\controller\applet;
use app\service\admin\applet\AppletVersionService;
use core\base\BaseAdminController;
use think\Response;
/**
* 小程序版本管理控制器
*/
class Version extends BaseAdminController
{
/**
* 列表
* @return Response
*/
public function lists()
{
$data = $this->request->params([
]);
return success(( new AppletVersionService() )->getPage($data));
}
/**
* 详情
* @param int $id
*/
public function info(int $id)
{
return success(( new AppletVersionService() )->getInfo($id));
}
/**
* 添加
* @return Response
*/
public function add()
{
$data = $this->request->params([
[ 'type', '' ],
[ 'desc', '' ],
[ 'status', '' ],
[ 'path', '' ],
[ 'version', '' ],
]);
$id = ( new AppletVersionService() )->add($data);
return success('ADD_SUCCESS');
}
/**
* 编辑
* @param int $id
* @return Response
*/
public function edit(int $id)
{
$data = $this->request->params([
[ 'desc', '' ],
[ 'status', '' ],
[ 'path', '' ],
[ 'version', '' ],
]);
( new AppletVersionService() )->edit($id, $data);
return success('EDIT_SUCCESS');
}
/**
* 删除
* @param int $id
*/
public function del(int $id)
{
( new AppletVersionService() )->del($id);
return success('DELETE_SUCCESS');
}
/**
* 设置状态
* @param int $id
* @param $type
* @return Response
*/
public function setStatus(int $id, $status){
( new AppletVersionService() )->setStatus($id, $status);
return success('EDIT_SUCCESS');
}
/**
* 小程序包上传
* @return Response
* @throws \Exception
*/
public function upload(){
$data = $this->request->params([
['file', 'file'],
], true);
return success(data:( new AppletVersionService() )->upload($data['file']));
}
}

View File

@ -0,0 +1,33 @@
<?php
// +----------------------------------------------------------------------
// | Niucloud-admin 企业快速开发的saas管理平台
// +----------------------------------------------------------------------
// | 官方网址https://www.niucloud-admin.com
// +----------------------------------------------------------------------
// | niucloud团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace app\adminapi\controller\applet;
use app\service\admin\applet\AppletDownloadService;
use core\base\BaseAdminController;
/**
* 小程序版本下载控制器
*/
class VersionDownload extends BaseAdminController
{
/**
* 下载
* @param $id
* @return mixed
*/
public function download($id){
return (new AppletDownloadService())->download($id);
}
}

View File

@ -31,6 +31,7 @@ class Diy extends BaseAdminController
$data = $this->request->params([
[ "title", "" ],
[ "type", "" ],
[ 'mode', '' ]
]);
return success(( new DiyService() )->getPage($data));
}
@ -70,9 +71,10 @@ class Diy extends BaseAdminController
[ "name", "" ],
[ "type", "" ],
[ 'template', '' ],
[ 'mode', 'diy' ],
[ 'mode', 'diy' ], // 页面展示模式diy自定义fixed固定
[ "value", "" ],
[ 'is_default', 0 ]
[ 'is_default', 0 ],
[ 'is_change', '' ]
]);
$this->validate($data, 'app\validate\diy\Diy.add');

View File

@ -25,13 +25,13 @@ class Attachment extends BaseAdminController
public function lists()
{
$data = $this->request->params([
['att_type', ''],
['cate_id', 0],
['real_name', ''],
['page', 0],
['limit', 0],
[ 'att_type', '' ],
[ 'cate_id', 0 ],
[ 'real_name', '' ],
[ 'page', 0 ],
[ 'limit', 0 ],
]);
return success((new AttachmentService())->getPage($data));
return success(( new AttachmentService() )->getPage($data));
}
/**
@ -48,11 +48,12 @@ class Attachment extends BaseAdminController
* 批量删除
* @return Response
*/
public function batchDel(){
public function batchDel()
{
$data = $this->request->params([
['att_ids', []],
[ 'att_ids', [] ],
]);
(new AttachmentService())->delAll($data['att_ids']);
( new AttachmentService() )->delAll($data[ 'att_ids' ]);
return success('DELETE_SUCCESS');
}
@ -63,11 +64,11 @@ class Attachment extends BaseAdminController
public function addCategory()
{
$data = $this->request->params([
['type', FileDict::IMAGE],
['name', '']
[ 'type', FileDict::IMAGE ],
[ 'name', '' ]
]);
$this->validate($data, 'app\validate\sys\AttachmentCategory.add');
(new AttachmentService())->addCategory($data);
( new AttachmentService() )->addCategory($data);
return success('ADD_SUCCESS');
}
@ -77,10 +78,10 @@ class Attachment extends BaseAdminController
public function categoryLists()
{
$data = $this->request->params([
['type', ''],
['name', ''],
[ 'type', '' ],
[ 'name', '' ],
]);
return success((new AttachmentService())->getCategoryList($data));
return success(( new AttachmentService() )->getCategoryList($data));
}
/**
@ -90,10 +91,10 @@ class Attachment extends BaseAdminController
public function editCategory($id)
{
$data = $this->request->params([
['name', '']
[ 'name', '' ]
]);
$this->validate($data, 'app\validate\sys\AttachmentCategory.edit');
(new AttachmentService())->editCategory($id, $data);
( new AttachmentService() )->editCategory($id, $data);
return success('EDIT_SUCCESS');
}
@ -104,7 +105,7 @@ class Attachment extends BaseAdminController
*/
public function deleteCategory($id)
{
(new AttachmentService())->delCategory($id);
( new AttachmentService() )->delCategory($id);
return success('DELETE_SUCCESS');
}
@ -115,9 +116,9 @@ class Attachment extends BaseAdminController
public function moveCategory($att_id)
{
$data = $this->request->params([
['cate_id', '']
[ 'cate_id', '' ]
]);
(new AttachmentService())->modifyCategory($att_id, $data['cate_id']);
( new AttachmentService() )->modifyCategory($att_id, $data[ 'cate_id' ]);
return success('SUCCESS');
}
@ -129,11 +130,36 @@ class Attachment extends BaseAdminController
public function batchMoveCategory()
{
$data = $this->request->params([
['cate_id', ''],
['att_ids', []]
[ 'cate_id', '' ],
[ 'att_ids', [] ]
]);
(new AttachmentService())->batchModifyCategory($data['att_ids'], $data['cate_id']);
( new AttachmentService() )->batchModifyCategory($data[ 'att_ids' ], $data[ 'cate_id' ]);
return success('SUCCESS');
}
/**
* 获取图标库分类列表
*/
public function getIconCategoryList()
{
$data = $this->request->params([
[ 'name', '' ],
]);
return success(( new AttachmentService() )->getIconCategoryList($data));
}
/**
* 获取图标库列表
*/
public function getIconList()
{
$data = $this->request->params([
[ 'page', 0 ],
[ 'limit', 0 ],
[ 'cate_id', 0 ],
[ 'real_name', '' ],
]);
return success(( new AttachmentService() )->getIconList($data));
}
}

View File

@ -0,0 +1,39 @@
<?php
// +----------------------------------------------------------------------
// | Niucloud-admin 企业快速开发的saas管理平台
// +----------------------------------------------------------------------
// | 官方网址https://www.niucloud-admin.com
// +----------------------------------------------------------------------
// | niucloud团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace app\adminapi\controller\sys;
use app\dict\sys\DateDict;
use core\base\BaseAdminController;
/**
* 公共数据字典
*/
class Common extends BaseAdminController
{
/**
* 月份
* @return \think\Response
*/
public function getMonth(){
return success((new DateDict())->getMonth());
}
/**
* 星期
* @return \think\Response
*/
public function getWeek(){
return success((new DateDict())->getWeek());
}
}

View File

@ -33,6 +33,13 @@ class Schedule extends BaseAdminController
}
/**
* 计划任务模板
* @return \think\Response
*/
public function template(){
return success(data:(new ScheduleService())->getTemplateList());
}
/**
* 获取任务模式
@ -62,6 +69,7 @@ class Schedule extends BaseAdminController
[ 'time', [] ],
[ 'status', ScheduleDict::OFF ],
]);
$this->validate($data, 'app\validate\sys\Schedule.add');
( new ScheduleService() )->add($data);
return success('ADD_SUCCESS');
}
@ -74,7 +82,7 @@ class Schedule extends BaseAdminController
public function edit(int $id)
{
$data = $this->request->params([
[ 'key', '' ],
// [ 'key', '' ],
[ 'time', [] ],
[ 'status', ScheduleDict::OFF ],
]);
@ -100,8 +108,15 @@ class Schedule extends BaseAdminController
*/
public function del(int $id)
{
( new ScheduleService() )->del($id);
return success('DELETE_SUCCESS');
}
/**
* 时间间隔类型
* @return \think\Response
*/
public function getDateType(){
return success(data:ScheduleDict::getDateType());
}
}

View File

@ -12,7 +12,7 @@
namespace app\adminapi\controller\upload;
use app\dict\sys\StorageDict;
use app\service\admin\file\StorageConfigService;
use app\service\admin\upload\StorageConfigService;
use core\base\BaseAdminController;
use core\exception\AdminException;
use think\Response;

View File

@ -11,8 +11,8 @@
namespace app\adminapi\controller\upload;
use app\service\admin\file\UploadConfigService;
use app\service\admin\file\UploadService;
use app\service\admin\upload\UploadConfigService;
use app\service\admin\upload\UploadService;
use core\base\BaseAdminController;
use think\Response;
@ -56,7 +56,7 @@ class Upload extends BaseAdminController
['file', 'file'],
], true);
$upload_service = new UploadService();
return success($upload_service->document($data['file'], $type, true));
return success($upload_service->document($data['file'], $type));
}
/**

View File

@ -0,0 +1,35 @@
<?php
// +----------------------------------------------------------------------
// | Niucloud-admin 企业快速开发的saas管理平台
// +----------------------------------------------------------------------
// | 官方网址https://www.niucloud-admin.com
// +----------------------------------------------------------------------
// | niucloud团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace app\adminapi\controller\weapp;
use app\service\admin\weapp\WeappConfigService;
use core\base\BaseAdminController;
use think\Response;
class Package extends BaseAdminController
{
public function lists(){
return success();
}
public function add(){
$data = $this->request->params([
['version', ''],
['path', ''],
['desc', ''],
['config', []],
]);
}
}

View File

@ -0,0 +1,54 @@
<?php
// +----------------------------------------------------------------------
// | Niucloud-admin 企业快速开发的saas管理平台
// +----------------------------------------------------------------------
// | 官方网址https://www.niucloud-admin.com
// +----------------------------------------------------------------------
// | niucloud团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: Niucloud Team
// +----------------------------------------------------------------------
use app\adminapi\middleware\AdminCheckRole;
use app\adminapi\middleware\AdminCheckToken;
use app\adminapi\middleware\AdminLog;
use think\facade\Route;
/**
* 路由
*/
Route::group('applet', function () {
/***************************************************** 小程序版本 ****************************************************/
//列表
Route::get('version', 'applet.Version/lists');
//详情
Route::get('version/:id', 'applet.Version/info');
//创建版本
Route::post('version', 'applet.Version/add');
//编辑
Route::put('version/:id', 'applet.Version/edit');
//删除
Route::delete('version/:id', 'applet.Version/del');
//设置状态
Route::put('version/status/:id/:status', 'applet.Version/setStatus');
//上传
Route::post('upload', 'applet.Version/upload');
/***************************************************** 站点下载或升级版本记录 ****************************************************/
//列表
Route::get('site/version', 'applet.SiteVersion/lists');
//详情
Route::get('site/version/:id', 'applet.SiteVersion/info');
//最后一个升级的版本
Route::post('site/version/last', 'applet.SiteVersion/getLastVersion');
//下载
Route::post('version/download/:id', 'applet.VersionDownload/download');
})->middleware([
AdminCheckToken::class,
AdminCheckRole::class,
AdminLog::class
]);

View File

@ -122,6 +122,10 @@ Route::group('sys', function () {
Route::put('upload/config', 'upload.Upload/setUploadConfig');
//获取上传设置
Route::get('upload/config', 'upload.Upload/getUploadConfig');
// 获取图标库列表
Route::get('attachment/icon_category', 'sys.Attachment/getIconCategoryList');
// 获取图标库列表
Route::get('attachment/icon', 'sys.Attachment/getIconList');
/***************************************************** 协议管理 ****************************************************/
//消息列表
Route::get('agreement', 'sys.Agreement/lists');
@ -167,13 +171,19 @@ Route::group('sys', function () {
Route::delete('schedule/:id', 'sys.Schedule/del');
//任务模式
Route::get('schedule/type', 'sys.Schedule/getType');
//任务模板
Route::get('schedule/template', 'sys.Schedule/template');
//任务时间间隔
Route::get('schedule/datetype', 'sys.Schedule/getDateType');
/***************************************************** 应用管理 ****************************************************/
Route::get('applist', 'sys.App/getAppList');
/***************************************************** 清理缓存-刷新菜单 ****************************************************/
Route::post('schema/clear', 'sys.System/schemaCache');
/***************************************************** 公共字典数据 ****************************************************/
Route::get('date/month', 'sys.Common/getMonth');
Route::get('date/week', 'sys.Common/getWeek');
})->middleware([
AdminCheckToken::class,

View File

@ -19,6 +19,10 @@ use core\base\BaseApiController;
class Upload extends BaseApiController
{
/**
* 图片上传
* @return \think\Response
*/
public function image(){
$data = $this->request->params([
['file', 'file'],
@ -27,6 +31,10 @@ class Upload extends BaseApiController
return success($upload_service->image($data['file']));
}
/**
* 远程图片拉取
* @return \think\Response
*/
public function imageFetch(){
$data = $this->request->params([
['url', ''],
@ -36,7 +44,10 @@ class Upload extends BaseApiController
}
/**
* base64图片上传
* @return \think\Response
*/
public function imageBase64(){
$data = $this->request->params([
['content', ''],

View File

@ -11,6 +11,7 @@
namespace app\api\controller\weapp;
use app\service\api\notice\NoticeService;
use app\service\api\weapp\WeappAuthService;
use core\base\BaseApiController;
use EasyWeChat\Kernel\Exceptions\InvalidArgumentException;
@ -44,4 +45,10 @@ class Weapp extends BaseApiController
$weapp_auth_service = new WeappAuthService();
return success($weapp_auth_service->register($data['openid'], $data['mobile'], $data['mobile_code']));
}
public function subscribeMessage(){
$data = $this->request->params([ ['keys', ''] ]);
return success((new NoticeService())->getWeappNoticeTemplateId($data['keys']));
}
}

View File

@ -40,10 +40,7 @@ class ApiChannel
if (in_array($request->rule()->getRule(), $channel_rules)) {
$site_id = $request->param('site_id', -1);
if ($site_id != -1) {
$site_info = (new CoreSiteService())->getSiteCache($site_id);
if(empty($site_info)) throw new AuthException('SITE_NOT_EXIST');
$site_code = $site_info['code'] ?? '';
$request->pushHeader([ system_name('api_site_id_name') => $site_code ]);
$request->pushHeader([ system_name('api_site_id_name') => $site_id ]);
}
}
return $next($request);

View File

@ -40,6 +40,8 @@ Route::group(function() {
Route::post('weapp/login', 'weapp.Weapp/login');
//小程序通过code注册
Route::post('weapp/register', 'weapp.Weapp/register');
// 获取小程序订阅消息模板id
Route::get('weapp/subscribemsg', 'weapp.Weapp/subscribeMessage');
//登录
Route::get('login', 'login.Login/login');
//第三方绑定

View File

@ -6,6 +6,7 @@ use think\facade\Lang;
use think\facade\Queue;
use think\facade\Cache;
use core\util\Snowflake;
use app\service\core\upload\CoreImageService;
// 应用公共文件
/**
@ -369,11 +370,11 @@ function filter($string)
*/
function create_no(string $prefix = '', string $tag = '')
{
$dataCenterId = 1;
$machineId = 2;
$snowflake = new Snowflake($dataCenterId, $machineId);
$data_center_id = 1;
$machine_id = 2;
$snowflake = new Snowflake($data_center_id, $machine_id);
$id = $snowflake->generateId();
return $prefix.$tag.$id;
return $prefix.date('YmdHi').$tag.$id;
}
/**
@ -706,4 +707,74 @@ function cache_remember(string $name = null, $value = '', $tag = null, $options
*/
function project_path() {
return dirname(root_path()) . DIRECTORY_SEPARATOR;
}
}
/**
* 图片转base64
* @param string $path
* @param $is_delete 转换后是否删除原图
* @return void
*/
function image_to_base64(string $path, $is_delete = false) {
if (!file_exists($path)) return 'image not exist';
$mime = getimagesize($path)['mime'];
$image_data = file_get_contents($path);
// 将图片转换为 base64
$base64_data = base64_encode($image_data);
if ($is_delete) @unlink($path);
return "data:{$mime};base64,{$base64_data}";
}
/**
* 获取缩略图
* @param $site_id
* @param $image
* @param $thumb_type
* @return mixed
* @throws Exception
*/
function get_thumb_images($site_id, $image, $thumb_type = 'all', bool $is_throw_exception = false){
return (new CoreImageService())->thumb($site_id, $image, $thumb_type, $is_throw_exception);
}
/**
* 版本号转整数 例如1.0.0=001.000.000=001000000=1000000
* @param string $ver
* @return int
*/
function version_to_int($version) {
$version_array = explode(".", $version);
$v1 = sprintf('%03s', (int) $version_array[0] ?? 0);
$v2 = sprintf('%03s', (int) $version_array[1] ?? 0);
$v3 = sprintf('%03s', (int) $version_array[2] ?? 0);
return (int) "{$v1}{$v2}{$v3}";
}
/**
* 整数版本号转字符串例如 1000000=001000000=001.000.000=1.0.0
* @param int $ver
* @return string
*/
function version_to_string($ver) {
if($ver > 999) {
if($ver > 999999) {
$ver = $ver . "";
$v3 = (int) substr($ver, -3);
$v2 = (int) substr($ver, -6, 3);
$v1 = (int) substr($ver, 0, strlen($ver) - 6);
} else {
$ver = $ver . "";
$v3 = (int) substr($ver, -3);
$v2 = (int) substr($ver, 0, strlen($ver) - 3);
$v1 = 0;
}
} else {
$v3 = $ver;
$v2 = 0;
$v1 = 0;
}
return "{$v1}.{$v2}.{$v3}";
}

View File

@ -0,0 +1,43 @@
<?php
// +----------------------------------------------------------------------
// | Niucloud-admin 企业快速开发的saas管理平台
// +----------------------------------------------------------------------
// | 官方网址https://www.niucloud-admin.com
// +----------------------------------------------------------------------
// | niucloud团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace app\dict\applet;
/**
* 小程序版本
* Class ChannelDict
* @package app\dict\common
*/
class AppletlDict
{
const ON = '1';//草稿
//微信公众号
const OFF = '2';
const PUBLISHED = '3';
const DOWNLOAD = 'download';//下载
const UPGRADE = 'upgrade';//升级
/**
* 小程序版本状态
* @return array
*/
public static function getStatus(){
$data = [
self::ON => get_lang('dict_applet.channel_weapp'),//启用
self::OFF => get_lang('dict_applet.channel_wechat'),//下架
];
return $data;
}
}

View File

@ -21,10 +21,6 @@ use core\dict\DictLoader;
class ComponentDict
{
/**
* 获取组件
* @return array|null
*/
public static function getComponent()
{
$system_components = [

View File

@ -20,10 +20,6 @@ use core\dict\DictLoader;
*/
class LinkDict
{
/**
* 获取链接
* @return array
*/
public static function getLink()
{
$system_links = [

View File

@ -21,11 +21,6 @@ use core\dict\DictLoader;
class PagesDict
{
/**
* 获取页面数据
* @param array $params
* @return array|string|null
*/
public static function getPages($params = [])
{
$system_pages = [
@ -258,14 +253,74 @@ class PagesDict
]
],
// 'tourism' => [
// "title" => "旅游", // 页面名称
// "title" => "固定模板示例", // 页面名称
// 'cover' => 'static/resource/images/diy/template/tourism_cover.png', // 页面封面图
// 'preview' => '', // 页面预览图
// 'desc' => '酒店旅游住宿门票景点', // 页面描述
// 'desc' => '描述固定模板', // 页面描述
// 'mode' => 'fixed', // 页面模式diy自定义fixed固定
// 'data' => [
// 'component' => 'tourism-index', // 模板组件名称
// 'link' => '' // 装修链接
// "global" => [
// "title" => "固定模板示例",
// "pageBgColor" => "#F8F8F8",
// 'bgUrl' => '',
// 'imgWidth' => '',
// 'imgHeight' => '',
// "bottomTabBarSwitch" => true,
// "template" => [
// 'textColor' => "#303133",
// "pageBgColor" => "",
// "componentBgColor" => "",
// "topRounded" => 0,
// "bottomRounded" => 0,
// "elementBgColor" => "",
// "topElementRounded" => 0,
// "bottomElementRounded" => 0,
// "margin" => [
// "top" => 0,
// "bottom" => 0,
// "both" => 0
// ]
// ],
// 'topStatusBar' => [
// 'bgColor' => "#ffffff",
// 'isTransparent' => false,
// 'isShow' => true,
// 'style' => 'style-1',
// 'textColor' => "#333333",
// 'textAlign' => 'center',
// ],
// 'popWindow' => [
// 'imgUrl' => "",
// 'imgWidth' => '',
// 'imgHeight' => '',
// 'count' => -1,
// 'show' => 0,
// 'link' => [
// 'name' => ""
// ],
// ]
// ],
// "value" => [
// [
// "id" => "524jcssmp8c0",
// "componentName" => "DemoIndex",
// "componentTitle" => "固定模板示例",
// "uses" => 0,
// "ignore" => [],
// "pageBgColor" => "",
// "componentBgColor" => "rgba(255, 255, 255, 1)",
// "topRounded" => 0,
// "bottomRounded" => 0,
// "elementBgColor" => "",
// "topElementRounded" => 0,
// "bottomElementRounded" => 0,
// "margin" => [
// "top" => 0,
// "bottom" => 0,
// "both" => 0
// ]
// ]
// ]
// ]
// ]
],
@ -932,6 +987,7 @@ class PagesDict
// ]
]
];
$pages = ( new DictLoader("UniappPages") )->load($system_pages);
if (!empty($params[ 'type' ])) {
if (!empty($pages[ $params[ 'type' ] ])) {
@ -943,12 +999,11 @@ class PagesDict
}
}
}
return $temp;
} else {
return [];
}
return $temp;
}
return $pages;

View File

@ -21,11 +21,6 @@ use core\dict\DictLoader;
class TemplateDict
{
/**
* 获取页面模板
* @param array $params
* @return array|string|null
*/
public static function getTemplate($params = [])
{
$system_pages = [

View File

@ -458,6 +458,19 @@
'sort' => 20,
'status' => 1,
'is_show' => 1,
],
[
'menu_name' => '小程序平台',
'menu_key' => 'setting_oplatform',
'menu_type' => 1,
'icon' => 'iconfont-iconweixin',
'api_url' => 'sys/weapp',
'router_path' => 'weapp',
'view_path' => 'setting/weapp',
'methods' => 'get',
'sort' => 20,
'status' => 1,
'is_show' => 1,
]
]
],

View File

@ -485,7 +485,7 @@ return
'is_show' => 1,
'children' => [
[
'menu_name' => '账单管理',
'menu_name' => '财务流水',
'menu_key' => 'site_account_list',
'menu_type' => 1,
'icon' => 'element-Postcard',

View File

@ -1,12 +1,14 @@
<?php
return [
'recharge_success' => [
'temp_key' => '755',
'tid' => '755',
'content' => [
['交易单号', '{trade_no}', 'keyword1'],
['充值金额', '{price}', 'keyword2'],
['账户余额', '{balance}', 'keyword3'],
['充值时间', '{time}', 'keyword4'],
],
'kid_list' => [1, 3, 4, 2],
'scene_desc' => ''
]
];

View File

@ -19,6 +19,8 @@ class ScheduleDict
const ON = 1;
const OFF = 2;
/**
* 任务模式
* @return array
@ -40,4 +42,19 @@ class ScheduleDict
self::OFF => get_lang('dict_schedule.off'),//关闭
];
}
const MIN = 'min';//每隔几分钟
const HOUR = 'hour';//每隔几小时
const DAY = 'day';//每隔几天
const WEEK = 'week';//每周
const MONTH = 'month';//每月
public static function getDateType(){
return [
self::MIN => get_lang('dict_schedule.min'),
self::HOUR => get_lang('dict_schedule.hour'),
self::DAY => get_lang('dict_schedule.day'),
self::WEEK => get_lang('dict_schedule.week'),
self::MONTH => get_lang('dict_schedule.month'),
];
}
}

View File

@ -50,7 +50,7 @@ class FileDict
const WECHAT = 'wechat';//微信支付
const APPLET = 'applet';//小程序上传
/**
* 获取上传的场景
@ -62,6 +62,23 @@ class FileDict
self::ALIYUN,//阿里云相关上传
self::IMAGE,//图片上传
self::VIDEO,//视频上传
self::APPLET,//小程序包上传
];
}
const BIG = 'big';
const MID = 'mid';
const SMALL = 'small';
/**
* 缩略图规格
* @return string[]
*/
public static function getThumbType(){
return [
self::BIG,//微信相关上传
self::MID,//阿里云相关上传
self::SMALL,//图片上传
];
}
}

View File

@ -0,0 +1,31 @@
<?php
// +----------------------------------------------------------------------
// | Niucloud-admin 企业快速开发的saas管理平台
// +----------------------------------------------------------------------
// | 官方网址https://www.niucloud-admin.com
// +----------------------------------------------------------------------
// | niucloud团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace app\dict\sys;
use core\dict\DictLoader;
/**
* 获取图标
* Class IconDict
* @package app\dict\sys
*/
class IconDict
{
public static function getIcon($params = [])
{
$system_pages = [];
$pages = ( new DictLoader("Icon") )->load($system_pages);
return $pages;
}
}

View File

@ -39,7 +39,8 @@ $system_event = [
//退款成功
'RefundSuccess' => [ 'app\listener\pay\RefundSuccessListener' ],
//转账成功
'TransferSuccess' => [ 'app\listener\pay\TransferSuccessListener' ], 'SiteIndex' => [
'TransferSuccess' => [ 'app\listener\pay\TransferSuccessListener' ],
'SiteIndex' => [
'app\listener\system\SiteIndexListener'
],

View File

@ -344,7 +344,7 @@ class Index extends BaseInstall
]);
}
//修改自增主键默认值
Db::execute("alter table ".env('database.prefix', '')."site auto_increment = 1");
Db::execute("alter table ".env('database.prefix', '')."site auto_increment = 100000");
//获取默认套餐
$group_id = (new SiteGroupService())->addAllMenuGroup();

View File

@ -28,6 +28,36 @@ CREATE TABLE `addon_log` (
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='插件日志表';
DROP TABLE IF EXISTS `applet_site_version`;
CREATE TABLE `applet_site_version` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
`site_id` int(11) NOT NULL DEFAULT '0' COMMENT '站点id',
`version_id` int(11) NOT NULL DEFAULT '0' COMMENT '版本id',
`type` varchar(20) NOT NULL DEFAULT '' COMMENT '小程序类型',
`action` varchar(20) NOT NULL DEFAULT '' COMMENT '操作方式 download 下载 upgrade 更新',
`create_time` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='站点小程序版本表';
DROP TABLE IF EXISTS `applet_version`;
CREATE TABLE `applet_version` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
`config` varchar(255) NOT NULL DEFAULT '' COMMENT '配置信息',
`type` varchar(20) NOT NULL DEFAULT '' COMMENT '小程序类型',
`desc` text COMMENT '插件描述',
`status` tinyint(4) NOT NULL DEFAULT '1' COMMENT '状态 下架 上架',
`uid` varchar(40) NOT NULL DEFAULT '' COMMENT '发布者',
`path` varchar(255) NOT NULL DEFAULT '' COMMENT '小程序包地址',
`version` varchar(20) NOT NULL DEFAULT '' COMMENT '版本号',
`version_num` varchar(20) NOT NULL DEFAULT '' COMMENT '版本号数字(用于排序)',
`release_version` varchar(20) NOT NULL DEFAULT '' COMMENT '发布线上版本号',
`create_time` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
`delete_time` int(11) NOT NULL DEFAULT '0' COMMENT '删除时间',
`update_time` int(11) NOT NULL DEFAULT '0' COMMENT '更新时间',
`site_id` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='小程序版本表';
DROP TABLE IF EXISTS `article`;
CREATE TABLE `article` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '文章id',
@ -88,6 +118,7 @@ CREATE TABLE `diy_page` (
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='自定义页面';
DROP TABLE IF EXISTS `diy_route`;
CREATE TABLE `diy_route` (
`id` int(11) NOT NULL AUTO_INCREMENT,
@ -108,13 +139,13 @@ CREATE TABLE `generate_column` (
`column_name` varchar(100) NOT NULL DEFAULT '' COMMENT '字段名称',
`column_comment` varchar(300) NOT NULL DEFAULT '' COMMENT '字段描述',
`column_type` varchar(100) NOT NULL DEFAULT '' COMMENT '字段类型',
`is_required` tinyint(4) DEFAULT '0' COMMENT '是否必填 0-非必填 1-必填',
`is_pk` tinyint(4) DEFAULT '0' COMMENT '是否为主键 0-不是 1-是',
`is_insert` tinyint(4) DEFAULT '0' COMMENT '是否为插入字段 0-不是 1-是',
`is_update` tinyint(4) DEFAULT '0' COMMENT '是否为更新字段 0-不是 1-是',
`is_lists` tinyint(4) DEFAULT '1' COMMENT '是否为列表字段 0-不是 1-是',
`is_query` tinyint(4) DEFAULT '1' COMMENT '是否为查询字段 0-不是 1-是',
`is_search` tinyint(4) DEFAULT '1' COMMENT '是否搜索字段',
`is_required` tinyint(1) DEFAULT '0' COMMENT '是否必填 0-非必填 1-必填',
`is_pk` tinyint(1) DEFAULT '0' COMMENT '是否为主键 0-不是 1-是',
`is_insert` tinyint(1) DEFAULT '0' COMMENT '是否为插入字段 0-不是 1-是',
`is_update` tinyint(1) DEFAULT '0' COMMENT '是否为更新字段 0-不是 1-是',
`is_lists` tinyint(1) DEFAULT '1' COMMENT '是否为列表字段 0-不是 1-是',
`is_query` tinyint(1) DEFAULT '1' COMMENT '是否为查询字段 0-不是 1-是',
`is_search` tinyint(1) DEFAULT '1' COMMENT '是否搜索字段',
`query_type` varchar(100) DEFAULT '=' COMMENT '查询类型',
`view_type` varchar(100) DEFAULT 'input' COMMENT '显示类型',
`dict_type` varchar(255) DEFAULT '' COMMENT '字典类型',
@ -140,10 +171,10 @@ 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 DEFAULT '0',
`reserve_time` int(10) unsigned DEFAULT '0',
`available_time` int(10) unsigned NOT NULL DEFAULT '0',
`create_time` int(10) unsigned NOT NULL DEFAULT '0',
`attempts` tinyint(4) unsigned NOT NULL DEFAULT '0',
`reserve_time` int(11) unsigned DEFAULT '0',
`available_time` int(11) unsigned DEFAULT '0',
`create_time` int(11) unsigned DEFAULT '0',
PRIMARY KEY (`id`),
KEY `queue` (`queue`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='消息队列任务表';
@ -350,6 +381,7 @@ CREATE TABLE `pay` (
`main_id` int(11) NOT NULL DEFAULT '0' COMMENT '支付会员id',
`out_trade_no` varchar(255) NOT NULL DEFAULT '' COMMENT '支付流水号',
`trade_type` varchar(255) NOT NULL DEFAULT '' COMMENT '业务类型',
`trade_id` int(11) NOT NULL DEFAULT '0' COMMENT '业务id',
`trade_no` varchar(255) NOT NULL DEFAULT '' COMMENT '交易单号',
`body` varchar(1000) NOT NULL DEFAULT '' COMMENT '支付主体',
`money` decimal(10,2) NOT NULL COMMENT '支付金额',
@ -516,7 +548,6 @@ CREATE TABLE `recharge_order_log` (
DROP TABLE IF EXISTS `site`;
CREATE TABLE `site` (
`site_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
`site_code` varchar(32) NOT NULL DEFAULT '' COMMENT '站点code码',
`site_name` varchar(50) NOT NULL DEFAULT '' COMMENT '站点名称',
`group_id` int(11) NOT NULL DEFAULT '0' COMMENT '分组ID(0:不限制)',
`keywords` varchar(255) NOT NULL DEFAULT '' COMMENT '关键字',
@ -542,9 +573,9 @@ CREATE TABLE `site` (
PRIMARY KEY (`site_id`),
KEY `create_time` (`create_time`),
KEY `group_id` (`group_id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 AVG_ROW_LENGTH=1365 COMMENT='站点表';
) ENGINE=InnoDB AUTO_INCREMENT=100000 DEFAULT CHARSET=utf8mb4 COMMENT='站点表';
INSERT INTO `site` VALUES ('1', '11000001', 'niucloud-admin', '0', '', 'admin', '', '', '1', '', '', '0', '0', '0', '', '', '', '', '0', '0', '', '', '', '0');
INSERT INTO `site` VALUES ('1', 'niucloud-admin', '0', '', 'admin', '', '', '1', '', '', '0', '0', '0', '', '', '', '', '0', '0', '', '', '', '0');
DROP TABLE IF EXISTS `site_account_log`;
CREATE TABLE `site_account_log` (
@ -4333,7 +4364,7 @@ CREATE TABLE `sys_menu` (
`view_path` varchar(255) NOT NULL DEFAULT '' COMMENT '菜单文件地址',
`methods` varchar(10) NOT NULL DEFAULT '' COMMENT '提交方式POST GET PUT DELETE',
`sort` tinyint(4) NOT NULL DEFAULT '1' COMMENT '排序',
`status` tinyint(3) unsigned NOT NULL DEFAULT '1' COMMENT '正常,禁用(禁用后不允许访问)',
`status` tinyint(4) unsigned NOT NULL DEFAULT '1' COMMENT '正常,禁用(禁用后不允许访问)',
`is_show` tinyint(4) NOT NULL DEFAULT '1' COMMENT '是否显示',
`create_time` int(11) NOT NULL DEFAULT '0',
`delete_time` int(11) NOT NULL DEFAULT '0',
@ -4342,7 +4373,7 @@ CREATE TABLE `sys_menu` (
KEY `is_show` (`is_show`),
KEY `menu_key` (`menu_key`,`app_type`),
KEY `parent_key` (`parent_key`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 AVG_ROW_LENGTH=406 COMMENT='菜单表';
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='菜单表';
DROP TABLE IF EXISTS `sys_notice`;
CREATE TABLE `sys_notice` (
@ -4369,15 +4400,15 @@ CREATE TABLE `sys_notice_log` (
`site_id` int(11) NOT NULL DEFAULT '0' COMMENT '站点id',
`key` varchar(255) DEFAULT '' COMMENT '消息key',
`notice_type` varchar(50) DEFAULT 'sms' COMMENT '消息类型sms,wechat.weapp',
`uid` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '通知的用户id',
`uid` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '通知的用户id',
`member_id` int(11) NOT NULL DEFAULT '0' COMMENT '消息的会员id',
`nickname` varchar(255) NOT NULL DEFAULT '' COMMENT '接收人用户昵称或姓名',
`receiver` varchar(255) NOT NULL DEFAULT '' COMMENT '接收人对应手机号openid',
`content` text COMMENT '消息数据',
`is_click` tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT '点击次数',
`is_visit` tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT '访问次数',
`is_click` tinyint(4) unsigned NOT NULL DEFAULT '0' COMMENT '点击次数',
`is_visit` tinyint(4) unsigned NOT NULL DEFAULT '0' COMMENT '访问次数',
`visit_time` int(11) NOT NULL DEFAULT '0' COMMENT '访问时间',
`create_time` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '消息时间',
`create_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '消息时间',
`result` varchar(1000) NOT NULL DEFAULT '' COMMENT '结果',
`params` text,
PRIMARY KEY (`id`),
@ -4411,7 +4442,7 @@ CREATE TABLE `sys_role` (
`site_id` int(11) NOT NULL DEFAULT '0' COMMENT '站点id',
`role_name` varchar(255) NOT NULL DEFAULT '' COMMENT '角色名称',
`rules` text COMMENT '角色权限(menus_id)',
`status` tinyint(3) unsigned NOT NULL DEFAULT '1' COMMENT '状态',
`status` tinyint(4) unsigned NOT NULL DEFAULT '1' COMMENT '状态',
`create_time` int(11) NOT NULL DEFAULT '0' COMMENT '添加时间',
`update_time` int(11) NOT NULL DEFAULT '0' COMMENT '最后修改时间',
PRIMARY KEY (`role_id`),
@ -4445,11 +4476,11 @@ CREATE TABLE `sys_user` (
`password` varchar(100) NOT NULL DEFAULT '' COMMENT '用户密码',
`real_name` varchar(16) NOT NULL DEFAULT '' COMMENT '实际姓名',
`last_ip` varchar(16) NOT NULL DEFAULT '' COMMENT '最后一次登录ip',
`last_time` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '最后一次登录时间',
`create_time` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '添加时间',
`login_count` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '登录次数',
`status` tinyint(3) unsigned NOT NULL DEFAULT '1' COMMENT '后台管理员状态 1有效0无效',
`is_del` tinyint(3) unsigned NOT NULL DEFAULT '0',
`last_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '最后一次登录时间',
`create_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '添加时间',
`login_count` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '登录次数',
`status` tinyint(4) unsigned NOT NULL DEFAULT '1' COMMENT '后台管理员状态 1有效0无效',
`is_del` tinyint(4) unsigned NOT NULL DEFAULT '0',
`delete_time` tinyint(4) NOT NULL DEFAULT '0' COMMENT '删除时间',
`update_time` int(11) NOT NULL DEFAULT '0' COMMENT '更新时间',
PRIMARY KEY (`uid`),
@ -4458,7 +4489,7 @@ CREATE TABLE `sys_user` (
KEY `is_del` (`is_del`),
KEY `password` (`password`),
KEY `update_time` (`update_time`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 AVG_ROW_LENGTH=372 COMMENT='后台管理员表';
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COMMENT='后台管理员表';
INSERT INTO `sys_user` VALUES ('1', '', '', '', '', '', '0', '0', '0', '1', '0', '0', '0');
@ -4467,12 +4498,12 @@ CREATE TABLE `sys_user_log` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '管理员操作记录ID',
`ip` varchar(16) NOT NULL DEFAULT '' COMMENT '登录IP',
`site_id` int(11) NOT NULL DEFAULT '0' COMMENT '站点id',
`uid` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '管理员id',
`uid` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '管理员id',
`username` varchar(64) NOT NULL DEFAULT '' COMMENT '管理员姓名',
`url` varchar(128) NOT NULL DEFAULT '' COMMENT '链接',
`params` text COMMENT '参数',
`type` varchar(32) NOT NULL DEFAULT '' COMMENT '请求方式',
`create_time` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '操作时间',
`create_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '操作时间',
PRIMARY KEY (`id`),
KEY `create_time` (`create_time`),
KEY `site_id` (`site_id`),
@ -4491,7 +4522,7 @@ CREATE TABLE `sys_user_role` (
KEY `create_time` (`create_time`),
KEY `site_id` (`site_id`),
KEY `uid` (`uid`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 AVG_ROW_LENGTH=481 COMMENT='用户权限表';
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COMMENT='用户权限表';
INSERT INTO `sys_user_role` VALUES ('1', '1', '0', '', '0', '1');
@ -4542,11 +4573,11 @@ CREATE TABLE `wechat_reply` (
`site_id` int(11) NOT NULL DEFAULT '0' COMMENT '站点id',
`keyword` varchar(64) NOT NULL DEFAULT '' COMMENT '关键词',
`reply_type` tinyint(4) NOT NULL COMMENT '回复类型 subscribe-关注回复 keyword-关键字回复 default-默认回复',
`matching_type` tinyint(3) unsigned NOT NULL DEFAULT '1' COMMENT '匹配方式1-全匹配2-模糊匹配',
`content_type` tinyint(3) unsigned NOT NULL DEFAULT '1' COMMENT '内容类型1-文本',
`matching_type` tinyint(4) unsigned NOT NULL DEFAULT '1' COMMENT '匹配方式1-全匹配2-模糊匹配',
`content_type` tinyint(4) unsigned NOT NULL DEFAULT '1' COMMENT '内容类型1-文本',
`content` text NOT NULL COMMENT '回复内容',
`status` tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT '启动状态1-启动0-关闭',
`sort` int(10) unsigned NOT NULL DEFAULT '50' COMMENT '排序',
`status` tinyint(4) unsigned NOT NULL DEFAULT '0' COMMENT '启动状态1-启动0-关闭',
`sort` int(11) unsigned NOT NULL DEFAULT '50' COMMENT '排序',
`create_time` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
`update_time` int(11) NOT NULL DEFAULT '0' COMMENT '更新时间',
`delete_time` int(11) NOT NULL DEFAULT '0' COMMENT '删除时间',

View File

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

View File

@ -31,7 +31,7 @@ class Notice extends BaseJob
//通过业务获取模板变量属于以及发送对象
$result = event('NoticeData', ['site_id' => $site_id, 'key' => $key, 'data' => $data, 'template' => $template]);
$notice_data = array_values(array_filter($result))[0] ?? [];
if(empty($notice_data)) throw new NoticeException();
if(empty($notice_data)) throw new NoticeException('NOTICE_TEMPLATE_IS_NOT_EXIST');
event('Notice', ['site_id' => $site_id, 'key' => $key, 'to' => $notice_data['to'], 'vars' => $notice_data['vars'], 'template' => $template]);
return true;
}

View File

@ -76,7 +76,7 @@ return [
'OSS_TYPE_NOT_EXIST' => '云存储类型不存在',
'URL_FILE_NOT_EXIST' => '获取不到网址指向的文件',
'PLEACE_SELECT_IMAGE' => '请选择要删除的图片',
'CERT_TYPE_ERROR' => '不是有效的证书类型',
'UPLOAD_TYPE_ERROR' => '不是有效的上传类型',
//消息管理
@ -121,5 +121,6 @@ return [
500000 => '你选择的支付方式未启用',
//站点相关
'SITE_GROUP_IS_EXIST' => '站点分组已存在站点,请调整站点后重试',
//小程序版本
'APPLET_VERSION_NOT_EXISTS' => 'applet version not exists',
];

View File

@ -102,7 +102,13 @@ return [
'type_cron' => 'time work',
'type_crond' => 'period work',
'on' => 'on',
'off' => 'off'
'off' => 'off',
//时间间隔
'min' => 'every few minutes',
'hour' => 'every few hours',
'day' => 'every few day',
'week' => 'weekly',
'month' => 'monthly',
],
//支付相关
'dict_pay' => [

View File

@ -131,5 +131,10 @@ return [
'appid_require' => 'appid is require',
'appsecret_require' => 'appsecret is require',
],
//计划任务
'validate_schedule' => [
'schedule_require' => 'schedule is require',
'schedule_unique' => 'schedule is exist',
'not_exit_schedule_type' => 'not exit schedule type',
],
];

View File

@ -88,7 +88,7 @@ return [
'OSS_TYPE_NOT_EXIST' => '云存储类型不存在',
'URL_FILE_NOT_EXIST' => '获取不到网址指向的文件',
'PLEACE_SELECT_IMAGE' => '请选择要删除的图片',
'CERT_TYPE_ERROR' => '不是有效的上传类型',
'UPLOAD_TYPE_ERROR' => '不是有效的上传类型',
'OSS_FILE_URL_NOT_EXIST' => '远程资源文件地址不能为空',
'BASE_IMAGE_FILE_NOT_EXIST' => 'base图片资源不能为空',
'UPLOAD_TYPE_NOT_SUPPORT' => '不支持的上传类型',
@ -108,6 +108,7 @@ return [
'NOTICE_NOT_OPEN_SMS' => '当前消息未开启短信发送',
'NOTICE_SMS_EMPTY' => '手机号为空',
'NOTICE_SMS_NOT_OPEN' => '短信未启用',
'NOTICE_TEMPLATE_IS_NOT_EXIST' => '消息不存在',
//会员相关
'MOBILE_IS_EXIST' => '当前手机号已绑定账号',
@ -159,8 +160,6 @@ return [
'WEAPP_EMPOWER_NOT_EXIST' => '微信小程序授信信息不存在',
'WEAPP_EMPOWER_TEL_NOT_EXIST' => '微信小程序授信手机号不存在',
//支付相关
//站点相关
'SITE_GROUP_IS_EXIST' => '当前套餐存在站点,请调整站点对应套餐后重试',
'SITE_EXPIRE' => '站点已过期',
@ -185,11 +184,13 @@ return [
'CHANNEL_MARK_INVALID' => '无效的渠道标识',
'TEMPLATE_NOT_EXIST' => '模板不存在',
'IS_EXIST_TEMPLATE_NOT_MODIFY' => '已存在的支付模板不支持修改支付类型',
'ONLY_PAYING_CAN_PAY' => '只有待支付的订单可以支付',
//退款相关
'REFUND_NOT_EXIST' => '退款单据不存在',
//订单相关 8***
'ORDER_NOT_EXIST' => '订单不存在',
'ORDER_CLOSED' => '订单已关闭',
'DOCUMENT_IS_PAID' => '单据已支付',
// 退款相关
'NOT_ALLOW_APPLY_REFUND' => '该订单不允许退款',
@ -207,4 +208,8 @@ return [
'JOB_NOT_EXISTS' => '任务类不存在',
'JOB_CREATE_FAIL' => '任务创建失败',
//小程序版本
'APPLET_VERSION_NOT_EXISTS' => '小程序版本不存在',
];

View File

@ -137,7 +137,14 @@ return [
'type_cron' => '定时任务',
'type_crond' => '周期任务',
'on' => '启用',
'off' => '关闭'
'off' => '关闭',
'min' => '每隔几分钟',
'hour' => '每隔几小时',
'day' => '每隔几天',
'week' => '每周',
'month' => '每月',
],
//支付相关
'dict_pay' => [

View File

@ -171,5 +171,11 @@ return [
'not_support_account_type' => '该账户不支持提现',
'not_support_transfer_type' => '不支持该提现方式',
'account_id_require' => '请选择提现账户'
]
],
//计划任务
'validate_schedule' => [
'schedule_require' => '计划任务必须选择',
'schedule_unique' => '当前计划任务已存在',
'not_exit_schedule_type' => '不是有效的任务类型',
],
];

View File

@ -39,11 +39,7 @@ class Weapp
}
$weapp_data[$v[2]]['value'] = $search_content;
}
$url = '';
if(!empty($url)){
//todo 拼装h5端的链接
$url = $vars['__weapp_page'];
}
$url = $vars['__weapp_page'] ?? '';
$log_data = array(
'key' => $key,
'message_type' => NoticeTypeDict::WEAPP,

View File

@ -5,6 +5,7 @@ namespace app\listener\notice;
use app\dict\notice\NoticeTypeDict;
use app\service\core\member\CoreMemberService;
use app\service\core\notice\CoreNoticeLogService;
use app\service\core\weapp\CoreWeappConfigService;
use core\exception\NoticeException;
use core\template\TemplateLoader;
@ -20,36 +21,33 @@ class Wechat
$to = $data['to'];//发送对象主题
//完全信任消息的设置, 不再依赖support_type
if($template['is_wechat']){
if ($template['is_wechat']) {
$member_id = $to['member_id'] ?? 0;
//会员的
if($member_id > 0){//查询openid
if ($member_id > 0) {//查询openid
$info = (new CoreMemberService())->getInfoByMemberId($site_id, $member_id);
$openid = $info['wx_openid'] ?? '';
$nickname = $info['nickname'] ?? '';
}
//或者还有用户的
if(!empty($openid)){
if (!empty($openid)) {
$wechat_template_id = $template['wechat_template_id'];
$wechat = $template['wechat'];
$wechat_content = $wechat['content'];
$wechat_data = [];
foreach($wechat_content as $k => $v){
foreach ($wechat_content as $k => $v) {
$search_content = $v[1];
foreach($vars as $item_k => $item_v){
$search_content = str_replace('{'.$item_k.'}', $item_v, $search_content);
foreach ($vars as $item_k => $item_v) {
$search_content = str_replace('{' . $item_k . '}', $item_v, $search_content);
}
$wechat_data[$v[2]] = $search_content;
}
$first = $wechat['wechat_first'] ?? '';
$remark = $wechat['wechat_remark'] ?? '';
if(!empty($first)) $vars['first'] = $first;
if(!empty($remark)) $vars['remark'] = $remark;
$url = '';
if(!empty($url)){
//todo 拼装h5端的链接
$url = $vars['__wechat_page'];
}
if (!empty($first)) $vars['first'] = $first;
if (!empty($remark)) $vars['remark'] = $remark;
//todo 拼装h5端的链接
$url = $vars['__wechat_page'] ?? '';
//消息日志
$log_data = array(
'key' => $key,
@ -62,23 +60,35 @@ class Wechat
'content' => $wechat
);
try{
(new TemplateLoader(NoticeTypeDict::WECHAT, ['site_id' => $site_id]))->send(
[
'template_id' => $wechat_template_id,
'first' => $remark,
'remark' => $remark,
'data' => $wechat_data,
'openid' => $openid,
'url' => $url,
'miniprogram' => $miniprogram ?? '',
]);
$weapp_page = $vars['__weapp_page'] ?? '';
if (!empty($weapp_page)) {
$appid = (new CoreWeappConfigService())->getWeappConfig($site_id)['app_id'] ?? '';
if (!empty($appid)) {
$miniprogram = array(
'appid' => $appid,
'pagepath' => $weapp_page
);
}
}
try {
$send_data = [
'template_id' => $wechat_template_id,
'first' => $remark,
'remark' => $remark,
'data' => $wechat_data,
'openid' => $openid,
'url' => $url,
];
if (!empty($miniprogram)) {
$send_data['miniprogram'] = $miniprogram;
}
(new TemplateLoader(NoticeTypeDict::WECHAT, ['site_id' => $site_id]))->send($send_data);
(new CoreNoticeLogService())->add($site_id, $log_data);
}catch(NoticeException $e){
} catch ( NoticeException $e ) {
$log_data['result'] = $e->getMessage();
(new CoreNoticeLogService())->add($site_id, $log_data);
//这儿决定要不要抛出
if(!$template['async']){
if (!$template['async']) {
throw new NoticeException($e->getMessage());
}
}

View File

@ -0,0 +1,45 @@
<?php
// +----------------------------------------------------------------------
// | Niucloud-admin 企业快速开发的saas管理平台
// +----------------------------------------------------------------------
// | 官方网址https://www.niucloud-admin.com
// +----------------------------------------------------------------------
// | niucloud团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace app\model\applet;
use app\model\article\Article;
use core\base\BaseModel;
/**
* 小程序包 站点版本模型
*/
class AppletSiteVersion extends BaseModel
{
/**
* 数据表主键
* @var string
*/
protected $pk = 'id';
/**
* 模型名称
* @var string
*/
protected $name = 'applet_site_version';
/**
* 版本主表
* @return \think\model\relation\HasOne
*/
public function appletVersion()
{
return $this->hasOne( AppletVersion::class, 'id', 'version_id')->joinType('left')
->withField('desc, status, version, version_num, release_version')
->bind([ 'desc', 'status', 'version', 'version_num', 'release_version']);
}
}

View File

@ -0,0 +1,38 @@
<?php
// +----------------------------------------------------------------------
// | Niucloud-admin 企业快速开发的saas管理平台
// +----------------------------------------------------------------------
// | 官方网址https://www.niucloud-admin.com
// +----------------------------------------------------------------------
// | niucloud团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace app\model\applet;
use app\model\article\Article;
use core\base\BaseModel;
/**
* 小程序包版本模型
*/
class AppletVersion extends BaseModel
{
/**
* 数据表主键
* @var string
*/
protected $pk = 'id';
/**
* 模型名称
* @var string
*/
protected $name = 'applet_version';
}

View File

@ -11,6 +11,7 @@
namespace app\model\article;
use app\dict\sys\FileDict;
use app\model\site\Site;
use core\base\BaseModel;
use think\db\Query;
@ -100,16 +101,31 @@ class Article extends BaseModel
}
public function getArticleUrlAttr($value, $data) {
$site = Site::find($data['site_id']);
$site_tag = $site['site_code'];
$wap_domain = !empty(env("system.wap_domain")) ? preg_replace('#/$#', '', env("system.wap_domain")) : request()->domain();
$web_domain = !empty(env("system.web_domain")) ? preg_replace('#/$#', '', env("system.web_domain")) : request()->domain();
return [
'wap_url' => $wap_domain . "/wap/" . $site_tag . "/pages/article/detail?id={$data['id']}",
'web_url' => $web_domain . "/web/" . $site_tag . "/article/detail?id={$data['id']}"
'wap_url' => $wap_domain . "/wap/" . $data['site_id'] . "/pages/article/detail?id={$data['id']}",
'web_url' => $web_domain . "/web/" . $data['site_id'] . "/article/detail?id={$data['id']}"
];
}
public function getImageThumbBigAttr($value, $data) {
if($data['image'] != ''){
return get_thumb_images($data['site_id'], $data['image'], FileDict::BIG);
}
}
public function getImageThumbMidAttr($value, $data) {
if($data['image'] != ''){
return get_thumb_images($data['site_id'], $data['image'], FileDict::MID);
}
}
public function getImageThumbSmallAttr($value, $data) {
if($data['image'] != ''){
return get_thumb_images($data['site_id'], $data['image'], FileDict::SMALL);
}
}
}

View File

@ -136,6 +136,18 @@ class Diy extends BaseModel
}
}
/**
* 搜索器:页面展示模式diy自定义fixed固定
* @param $value
* @param $data
*/
public function searchModeAttr($query, $value, $data)
{
if ($value) {
$query->where("mode", $value);
}
}
/**
* 搜索器:自定义页面数据json格式
* @param $value

View File

@ -14,6 +14,7 @@ namespace app\model\sys;
use app\dict\sys\MenuDict;
use app\dict\sys\MenuTypeDict;
use core\base\BaseModel;
use think\model\concern\SoftDelete;
/**
* 菜单模型
@ -22,6 +23,7 @@ use core\base\BaseModel;
*/
class SysMenu extends BaseModel
{
use SoftDelete;
/**
* 数据表主键
* @var string

View File

@ -0,0 +1,44 @@
<?php
// +----------------------------------------------------------------------
// | Niucloud-admin 企业快速开发的saas管理平台
// +----------------------------------------------------------------------
// | 官方网址https://www.niucloud-admin.com
// +----------------------------------------------------------------------
// | niucloud团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace app\service\admin\applet;
use app\model\article\Article;
use app\service\core\applet\CoreAppletDownloadService;
use app\service\core\applet\CoreAppletVersionService;
use core\base\BaseAdminService;
/**
* 小程序下载服务层
*/
class AppletDownloadService extends BaseAdminService
{
public function __construct()
{
parent::__construct();
}
/**
* 小程序下载
* @param int $id
* @return \think\response\File
*/
public function download(int $id)
{
$core_applet_download_service = new CoreAppletDownloadService($id);
return $core_applet_download_service->download($this->site_id);
}
}

View File

@ -0,0 +1,124 @@
<?php
// +----------------------------------------------------------------------
// | Niucloud-admin 企业快速开发的saas管理平台
// +----------------------------------------------------------------------
// | 官方网址https://www.niucloud-admin.com
// +----------------------------------------------------------------------
// | niucloud团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace app\service\admin\applet;
use app\dict\applet\AppletlDict;
use app\dict\sys\FileDict;
use app\model\applet\AppletVersion;
use app\model\article\Article;
use app\service\core\applet\CoreAppletVersionService;
use app\service\core\upload\CoreUploadService;
use core\base\BaseAdminService;
/**
* 文章服务层
* Class ArticleService
* @package app\service\admin\article
*/
class AppletVersionService extends BaseAdminService
{
protected $core_applet_version_service;
public function __construct()
{
parent::__construct();
$this->model = new AppletVersion();
$this->core_applet_version_service = new CoreAppletVersionService;
}
/**
* 获取列表
* @param array $where
* @param string $order
*/
public function getPage(array $where = [])
{
return $this->core_applet_version_service->getPage($where);
}
/**
* 获取信息
* @param int $id
*/
public function getInfo(int $id)
{
return $this->core_applet_version_service->getInfo($id);
}
/**
* 添加
* @param array $data
* @return true
*/
public function add(array $data)
{
$data['version_num'] = version_to_int($data['version']);//版本号数字
$data['uid'] = $this->uid;//发布者
$data['status'] = AppletlDict::OFF;
$this->model->create($data);
return true;
}
/**
* 上传小程序包
* @param $file
* @return true
* @throws \Exception
*/
public function upload($file){
$core_upload_service = new CoreUploadService();
$type = FileDict::APPLET;
$dir = '/applet/'.$type.'/version/';
return $core_upload_service->document($file, $this->site_id, $type, $dir, FileDict::LOCAL);
}
/**
* 设置版本状态
* @param $id
* @param $status
* @return true
*/
public function setStatus(int $id, $status){
$data = array(
'status' => $status
);
$where = array(
['id', '=', $id]
);
$this->model->where($where)->update($data);
return true;
}
/**
* 编辑
* @param int $id
* @param array $data
*/
public function edit(int $id, array $data)
{
$data['version_num'] = version_to_int($data['version']);//版本号数字
$data['status'] = AppletlDict::OFF;
$data['update_time'] = time();
$this->model->where([['id', '=', $id]])->create($data);
return true;
}
/**
* 删除
* @param int $id
* @return true
*/
public function del(int $id){
$this->model->where([['id', '=', $id]])->delete();
return true;
}
}

View File

@ -0,0 +1,73 @@
<?php
// +----------------------------------------------------------------------
// | Niucloud-admin 企业快速开发的saas管理平台
// +----------------------------------------------------------------------
// | 官方网址https://www.niucloud-admin.com
// +----------------------------------------------------------------------
// | niucloud团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace app\service\admin\applet;
use app\dict\applet\AppletlDict;
use app\dict\sys\FileDict;
use app\model\article\Article;
use app\service\core\applet\CoreAppletSiteVersionService;
use app\service\core\applet\CoreAppletVersionService;
use app\service\core\upload\CoreUploadService;
use core\base\BaseAdminService;
/**
* 文章服务层
*/
class AppletVersionSiteService extends BaseAdminService
{
protected $core_applet_site_version_service;
public function __construct()
{
parent::__construct();
$this->core_applet_site_version_service = new CoreAppletSiteVersionService();
}
/**
* 获取列表
* @param array $where
* @return mixed
*/
public function getPage(array $where = [])
{
return $this->core_applet_site_version_service->getPage($this->site_id, $where);
}
/**
* 获取信息
* @param int $id
* @return array
*/
public function getInfo(int $id)
{
return $this->core_applet_site_version_service->getInfo($this->site_id, $id);
}
/**
* 查询最后一个下载或升级的版本
* @param string $type
* @return mixed|string
*/
public function getLastVersion(string $type){
return $this->core_applet_site_version_service->getLastVersion($this->site_id, $type);
}
/**
* 查询可升级的版本
* @param string $type
* @return null
*/
public function getUpgradeVersion(string $type){
return $this->core_applet_site_version_service->getUpgradeVersion($this->site_id, $type);
}
}

View File

@ -38,7 +38,7 @@ class ArticleService extends BaseAdminService
$where[] = [ 'site_id', '=', $this->site_id ];
$field = 'id, category_id, site_id, title, intro, summary, image, author, content, visit, visit_virtual, is_show, sort, create_time, update_time';
$order = 'create_time desc';
$search_model = $this->model->where([ [ 'site_id', '=', $this->site_id ] ])->withSearch([ 'title', 'category_id', 'is_show'], $where)->with('articleCategory')->field($field)->order($order)->append(['article_url']);
$search_model = $this->model->where([ [ 'site_id', '=', $this->site_id ] ])->withSearch([ 'title', 'category_id', 'is_show'], $where)->with('articleCategory')->field($field)->order($order)->append(['article_url','image_thumb_small']);
return $this->pageQuery($search_model);
}
@ -50,7 +50,7 @@ class ArticleService extends BaseAdminService
{
$field = 'id, category_id, site_id, title, intro, summary, image, author, content, visit, visit_virtual, is_show, sort, create_time, update_time';
return $this->model->where([ [ 'id', '=', $id ], [ 'site_id', '=', $this->site_id ] ])->with('articleCategory')->field($field)->findOrEmpty()->toArray();
return $this->model->where([ [ 'id', '=', $id ], [ 'site_id', '=', $this->site_id ] ])->with('articleCategory')->field($field)->append(['image_thumb_small'])->findOrEmpty()->toArray();
}
/**

View File

@ -36,12 +36,11 @@ class AuthService extends BaseAdminService
* @param $site_id
*/
public function checkSiteAuth(Request $request){
$site_code = $request->adminSiteId();
$site_id = $request->adminSiteId();
//todo 将站点编号转化为站点id
$site_info = (new CoreSiteService())->getSiteInfoBySiteCode($site_code);
$site_info = (new CoreSiteService())->getSiteCache($site_id);
//站点不存在
if(empty($site_info)) throw new AuthException('SITE_NOT_EXIST');
$site_id = $site_info['site_id'];
//没有当前站点的信息
if(!$this->getAuthRole($site_id)) throw new AuthException('NO_SITE_PERMISSION');

View File

@ -16,7 +16,6 @@ use app\dict\diy\LinkDict;
use app\dict\diy\PagesDict;
use app\dict\diy\TemplateDict;
use app\model\diy\Diy;
use app\model\site\Site;
use app\service\admin\sys\SystemService;
use core\base\BaseAdminService;
use Exception;
@ -45,8 +44,8 @@ class DiyService extends BaseAdminService
{
$where[] = [ 'site_id', '=', $this->site_id ];
$field = 'id,site_id,title,name,template,type,mode,is_default,share,visit_count,create_time,update_time';
$order = "is_default desc,update_time desc";
$search_model = $this->model->where([ [ 'site_id', '=', $this->site_id ] ])->withSearch([ "title", "type" ], $where)->field($field)->order($order)->append([ 'type_name' ]);
$order = "update_time desc";
$search_model = $this->model->where([ [ 'site_id', '=', $this->site_id ] ])->withSearch([ "title", "type", 'mode' ], $where)->field($field)->order($order)->append([ 'type_name' ]);
$list = $this->pageQuery($search_model);
return $list;
}
@ -62,7 +61,7 @@ class DiyService extends BaseAdminService
*/
public function getList(array $where = [], $field = 'id,site_id,title,name,template,type,mode,is_default,share,visit_count,create_time,update_time')
{
$order = "is_default desc,update_time desc";
$order = "update_time desc";
$list = $this->model->where([ [ [ 'site_id', '=', $this->site_id ] ] ])->withSearch([ "title", "type", 'mode' ], $where)->field($field)->select()->order($order)->toArray();
return $list;
}
@ -74,14 +73,14 @@ class DiyService extends BaseAdminService
*/
public function getInfo(int $id)
{
$field = 'id,site_id,title,name,template,type,mode,value,is_default,share,visit_count';
$field = 'id,site_id,title,name,template,type,mode,value,is_default,is_change,share,visit_count';
$info = $this->model->field($field)->where([ [ 'id', '=', $id ], [ 'site_id', '=', $this->site_id ] ])->findOrEmpty()->toArray();
return $info;
}
public function getInfoByName(string $name)
{
$field = 'id,site_id,title,name,template,type,mode,value,is_default,share,visit_count';
$field = 'id,site_id,title,name,template,type,mode,value,is_default,is_change,share,visit_count';
$info = $this->model->field($field)->where([ [ 'name', '=', $name ], [ 'site_id', '=', $this->site_id ], [ 'is_default', '=', 1 ] ])->findOrEmpty()->toArray();
return $info;
}
@ -188,7 +187,6 @@ class DiyService extends BaseAdminService
if (!empty($data)) {
// 编辑赋值
if (isset($template[ $data[ 'type' ] ])) {
$page = $template[ $data[ 'type' ] ];
$data[ 'type_name' ] = $page[ 'title' ];
@ -260,8 +258,6 @@ class DiyService extends BaseAdminService
}
$data[ 'component' ] = $this->getComponentList($data[ 'type' ]);
$data[ 'domain_url' ] = ( new SystemService() )->getUrl();
$site = Site::find($this->site_id);
$data[ 'site_id' ] = $site[ 'site_code' ];
return $data;
}
@ -408,7 +404,7 @@ class DiyService extends BaseAdminService
foreach ($template as $k => $v) {
// 查询我的微页面
$template[ $k ][ 'my_page' ] = $this->getList([ 'type' => $k, 'mode' => 'diy' ], 'id,title,name,template,type,is_default,mode');
$template[ $k ][ 'my_page' ] = $this->getList([ 'type' => $k ], 'id,title,name,template,type,is_default,mode');
$template[ $k ][ 'domain_url' ] = ( new SystemService() )->getUrl();
// 查询默认页面数据
@ -432,28 +428,30 @@ class DiyService extends BaseAdminService
if (!empty($info)) {
$use_template[ 'id' ] = $info[ 'id' ];
$use_template[ 'title' ] = $info[ 'title' ];
// 检测模板是否存在
if (!empty($info[ 'template' ])) {
if (in_array($info[ 'template' ], array_keys($v[ 'template' ]))) {
$use_template[ 'template' ] = $info[ 'template' ];
$use_template[ 'mode' ] = $info[ 'mode' ];
$use_template[ 'hope' ] = $info[ 'mode' ] == 'fixed' ? 'template' : $info[ 'mode' ];
}
}
$use_template[ 'template' ] = $info[ 'template' ];
$use_template[ 'mode' ] = $info[ 'mode' ];
$use_template[ 'hope' ] = $info[ 'mode' ] == 'fixed' ? 'template' : $info[ 'mode' ];
$use_template[ 'preview' ] = ''; // 默认图
$use_template[ 'desc' ] = '通过自定义装修的页面';
// 查询模板页面数
$page_data = $this->getPageData($k, $use_template[ 'template' ]);
if (!empty($page_data)) {
$use_template[ 'cover' ] = $page_data[ 'cover' ]; // 默认图
$use_template[ 'desc' ] = $page_data[ 'desc' ];
if ($info[ 'is_change' ] == 1) {
// 修改过模板,预览实际内容
$use_template[ 'url' ] = '/' . $v[ 'page' ] . '?id=' . $info[ 'id' ];
} else {
$use_template[ 'cover' ] = $page_data[ 'cover' ]; // 默认图
$use_template[ 'desc' ] = $page_data[ 'desc' ];
}
} else {
// 自定义页面,实时预览效果
$site = Site::find($this->site_id);
$use_template[ 'url' ] = '/pages/index/diy?&mode=preview&site_id=' . $site[ 'site_code' ] . '&id=' . $info[ 'id' ];
$use_template[ 'url' ] = '/pages/index/diy?id=' . $info[ 'id' ];
// 清空模板信息
$use_template[ 'cover' ] = ''; // 默认图
$use_template[ 'template' ] = '';
$use_template[ 'mode' ] = 'diy';
$use_template[ 'hope' ] = $use_template[ 'mode' ];
}
}
$template[ $k ][ 'use_template' ] = $use_template;

View File

@ -15,7 +15,7 @@
/**
* {CLASS_COMMENT}
* Class {UCASE_NAME}Controller
* Class {UCASE_CLASS_NAME}
* @package app\adminapi\controller{PACKAGE_NAME}
*/
class {UCASE_CLASS_NAME} extends BaseAdminController

View File

@ -3,7 +3,7 @@
<el-card class="box-card !border-none" shadow="never">
<div class="flex justify-between items-center">
<span class="text-[24px]">{{pageName}}</span>
<span class="text-[20px]">{{pageName}}</span>
<el-button type="primary" class="w-[100px]" @click="addEvent">
{{ t('addArticle') }}
</el-button>

View File

@ -17,6 +17,7 @@ use app\service\admin\sys\MenuService;
use app\service\core\menu\CoreMenuService;
use core\base\BaseAdminService;
use think\facade\Cache;
use think\facade\Db;
/**
* 系统安装
@ -48,7 +49,8 @@ class InstallSystemService extends BaseAdminService
$admin_menus = $this->loadMenu(AppTypeDict::ADMIN);
$site_menus = $this->loadMenu(AppTypeDict::SITE);
$menus = array_merge($admin_menus, $site_menus);
$sys_menu->where([ [ 'id', '>', 0 ] ])->delete();
Db::name("sys_menu")->where([ [ 'id', '>', 0 ] ])->delete();
//$sys_menu->where([ [ 'id', '>', 0 ] ])->force(true)->delete();
$sys_menu->replace()->insertAll($menus);
//插件菜单
(new CoreMenuService())->refreshAllAddonMenu();

View File

@ -67,7 +67,7 @@ class ScheduleService extends BaseAdminService
public function add(array $data)
{
$res = (new CoreScheduleService())->add($data);
return $res->id;
return true;
}
@ -75,6 +75,7 @@ class ScheduleService extends BaseAdminService
* 编辑
* @param int $id
* @param array $data
* @return true
*/
public function edit(int $id, array $data)
{
@ -85,9 +86,19 @@ class ScheduleService extends BaseAdminService
/**
* 删除
* @param int $id
* @return true
*/
public function del(int $id)
{
return (new CoreScheduleService())->del($id);
(new CoreScheduleService())->del($id);
return true;
}
/**
* 计划任务模板
* @return array|null
*/
public function getTemplateList(){
return (new CoreScheduleService())->getTemplateList();
}
}

View File

@ -46,7 +46,7 @@ class SiteService extends BaseAdminService
{
$field = 'site_id, site_name, front_end_name, front_end_logo, app_type, keywords, logo, icon, `desc`, status, latitude, longitude, province_id, city_id,
district_id, address, full_address, phone, business_hours, create_time, expire_time, group_id, site_code';
district_id, address, full_address, phone, business_hours, create_time, expire_time, group_id';
$search_model = $this->model->where([ [ 'app_type', '<>', 'admin' ] ])->withSearch([ 'create_time', 'expire_time', 'keywords', 'status', 'group_id' ], $where)->with('groupName')->field($field)->append([ 'status_name' ])->order('create_time desc');
$list = $this->pageQuery($search_model);
return $list;
@ -60,7 +60,7 @@ class SiteService extends BaseAdminService
public function getInfo(int $site_id)
{
$field = 'site_id, site_name, front_end_name, front_end_logo, app_type, keywords, logo, icon, `desc`, status, latitude, longitude, province_id, city_id,
district_id, address, full_address, phone, business_hours, create_time, expire_time, group_id, site_code';
district_id, address, full_address, phone, business_hours, create_time, expire_time, group_id';
return $this->model->where([ [ 'site_id', '=', $site_id ] ])->with('groupName')->field($field)->append([ 'status_name' ])->findOrEmpty()->toArray();
}
@ -88,7 +88,6 @@ class SiteService extends BaseAdminService
try {
$site = $this->model->create($data_site);
$site_id = $site->site_id;
$this->model->where([ [ 'site_id', '=', $site_id ] ])->update([ 'site_code' => $this->createSiteCodeBySiteId($site_id) ]);
//添加用户
$data_user = [
'username' => $data[ 'username' ],
@ -112,24 +111,6 @@ class SiteService extends BaseAdminService
}
}
/**
* 通过站点id生成站点code
* @param int $site_id
*/
public function createSiteCodeBySiteId(int $site_id)
{
return ( $site_id + 1000000 ) * 11 + 1;
}
/**
* 通过站点code获取站点id
* @param $site_code
*/
public function getSiteIdBySiteCode($site_code)
{
return ( $site_code - 1 ) / 11 - 1000000;
}
/**
* 修改站点
* @param int $site_id
@ -168,7 +149,7 @@ class SiteService extends BaseAdminService
$where = [
[ 'site_id', '=', $site_id ],
];
$site = $this->model->where($where)->field('site_id, app_type,site_name,front_end_name,front_end_logo,logo,icon,group_id, status, expire_time, site_code')->append([ 'status_name' ])->findOrEmpty();
$site = $this->model->where($where)->field('site_id, app_type,site_name,front_end_name,front_end_logo,logo,icon,group_id, status, expire_time')->append([ 'status_name' ])->findOrEmpty();
return $site->toArray();
},
self::$cache_tag_name . $site_id

View File

@ -40,64 +40,9 @@ class SiteStatService extends BaseAdminService
*/
public function getIndexData(){
$data = [
'today_data' => [
'member_count' => 1,
'order_money' => 1388.5,
'visit_count' => 650,
'total_member_count' => 0,
'total_order_money' => 13851.12,
'total_visit_count' => 6580,
'total_order_count' => 29
],
'system' => [],
'version' => [],
'visit_stat' => [
'date' => [],
'value' => []
],
'member_stat' => [
'type' => ['男','女','未知'],
'value' => []
],
'site_info' => '',
'about' => [
[
'name' => 'Niucloud官方公众号',
'image' => 'static/resource/icon/index_icon/wx_qrcode.jpg',
'desc' => '微信扫码关注'
],
[
'name' => '添加企业微信群',
'image' => 'static/resource/icon/index_icon/wework_qrcode.png',
'desc' => '更多内容请扫码加入'
]
]
];
$data['today_data']['total_member_count'] = (new MemberService())->getCount([['create_time', '>=', Carbon::today()->timestamp]]);
$data['today_data']['total_order_money'] = $this->orderMoney(Carbon::today()->timestamp, time());
$data['today_data']['total_order_count'] = $this->orderCount(Carbon::today()->timestamp, time());
$data['today_data']['total_visit_count'] = (new MemberService())->getCount([['last_visit_time', '>=', Carbon::today()->timestamp]]);
$data['today_data']['today_member_visit_count'] = (new CoreMemberService())->getCount(['site_id' => $this->site_id,'last_visit_time' => get_start_and_end_time_by_day()]);
$data['total_data']['total_member_count'] = (new MemberService())->getCount();
$data['total_data']['total_order_money'] = number_format($this->orderMoney(0, time()), 2);
$data['total_data']['total_order_count'] = $this->orderCount(0, time());
$data['total_data']['total_visit_count'] = (new MemberService())->getCount();
$data['system'] = (new SystemService())->getInfo();
$data['version'] = $data['system']['version'] ?? [];
$time = 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'] ]);
$data['member_stat']['value'] = [$man_count, $woman_count, (int)($member_count - $man_count - $woman_count)];
$data['site_info'] = (new SiteService())->getInfo($this->site_id);
$site_create_time = strtotime($data['site_info']['create_time']);
$site_expire_time = strtotime($data['site_info']['expire_time']);

View File

@ -124,7 +124,7 @@ class AreaService extends BaseAdminService
public function getAreaId($name, $level){
$field = 'id';
$info = $this->model->field($field)->where([['name', 'like', '%' . $name . '%' ], ['level', '=', $level]])->findOrEmpty()->toArray();
return $info;
return $info['id'];
}
/**

View File

@ -11,6 +11,8 @@
namespace app\service\admin\sys;
use app\dict\sys\FileDict;
use app\dict\sys\IconDict;
use app\model\sys\SysAttachment;
use app\model\sys\SysAttachmentCategory;
use app\service\core\sys\CoreAttachmentService;
@ -39,7 +41,7 @@ class AttachmentService extends BaseAdminService
*/
public function add(array $data)
{
$data['site_id'] = $this->site_id;
$data[ 'site_id' ] = $this->site_id;
return $this->core_attachment_service->add($data);
}
@ -63,11 +65,11 @@ class AttachmentService extends BaseAdminService
*/
public function modifyCategory($att_id, $cate_id)
{
$where = array(
['att_id', '=', $att_id],
['site_id', '=', $this->site_id],
$where = array (
[ 'att_id', '=', $att_id ],
[ 'site_id', '=', $this->site_id ],
);
$this->model->where($where)->update(['cate_id' => $cate_id, 'update_time' => time()]);
$this->model->where($where)->update([ 'cate_id' => $cate_id, 'update_time' => time() ]);
return true;
}
@ -80,11 +82,11 @@ class AttachmentService extends BaseAdminService
public function batchModifyCategory($att_ids, $cate_id)
{
$where = array(
['att_id', 'in', is_string($att_ids) ? explode($att_ids) : $att_ids],
['site_id', '=', $this->site_id],
$where = array (
[ 'att_id', 'in', is_string($att_ids) ? explode($att_ids) : $att_ids ],
[ 'site_id', '=', $this->site_id ],
);
$this->model->where($where)->update(['cate_id' => $cate_id, 'update_time' => time()]);
$this->model->where($where)->update([ 'cate_id' => $cate_id, 'update_time' => time() ]);
return true;
}
@ -115,19 +117,22 @@ class AttachmentService extends BaseAdminService
*/
public function getPage(array $data)
{
$where = array(
['site_id', '=', $this->site_id]
$where = array (
[ 'site_id', '=', $this->site_id ]
);
if (!empty($data['att_type'])) {
$where[] = ['att_type', '=', $data['att_type']];
if (!empty($data[ 'att_type' ])) {
$where[] = [ 'att_type', '=', $data[ 'att_type' ] ];
}
if (!empty($data['cate_id'])) {
$where[] = ['cate_id', '=', $data['cate_id']];
if (!empty($data[ 'cate_id' ])) {
$where[] = [ 'cate_id', '=', $data[ 'cate_id' ] ];
}
if (!empty($data['real_name'])) {
$where[] = ['real_name', 'like', '%' . $data['real_name'] . '%'];
if (!empty($data[ 'real_name' ])) {
$where[] = [ 'real_name', 'like', '%' . $data[ 'real_name' ] . '%' ];
}
return $this->getPageList($this->model, $where, 'att_id,path,real_name,att_type,url', 'att_id desc');
return $this->getPageList($this->model, $where, 'att_id,path,real_name,att_type,url', 'att_id desc', each:function($item, $key)
{
$item[ 'thumb' ] = get_thumb_images($this->site_id, $item[ 'url' ], FileDict::SMALL);
});
}
/**
@ -136,7 +141,7 @@ class AttachmentService extends BaseAdminService
*/
public function addCategory(array $data)
{
$data['site_id'] = $this->site_id;
$data[ 'site_id' ] = $this->site_id;
$category_model = new SysAttachmentCategory();
$attachment = $category_model->create($data);
if (!$attachment->id)
@ -151,9 +156,9 @@ class AttachmentService extends BaseAdminService
*/
public function findCategory(int $site_id, int $id)
{
$where = array(
['site_id', '=', $site_id],
['id', '=', $id]
$where = array (
[ 'site_id', '=', $site_id ],
[ 'id', '=', $id ]
);
$category_model = new SysAttachmentCategory();
$category = $category_model->where($where)->findOrEmpty();
@ -169,9 +174,9 @@ class AttachmentService extends BaseAdminService
*/
public function editCategory(int $id, array $data)
{
$where = array(
['site_id', '=', $this->site_id],
['id', '=', $id]
$where = array (
[ 'site_id', '=', $this->site_id ],
[ 'id', '=', $id ]
);
$category_model = new SysAttachmentCategory();
return $category_model->where($where)->update($data);
@ -186,7 +191,7 @@ class AttachmentService extends BaseAdminService
{
//查询是否有下级菜单或按钮
$category = $this->findCategory($this->site_id, $id);
if ($this->model->where([['cate_id', '=', $id]])->count() > 0)
if ($this->model->where([ [ 'cate_id', '=', $id ] ])->count() > 0)
throw new AdminException('ATTACHMENT_GROUP_HAS_IMAGE');
//下级存在图片不能删除
@ -203,16 +208,16 @@ class AttachmentService extends BaseAdminService
*/
public function getCategoryPage(array $data)
{
$where = array(
['site_id', '=', $this->site_id]
$where = array (
[ 'site_id', '=', $this->site_id ]
);
if (!empty($data['type'])) {
$where[] = ['type', '=', $data['type']];
if (!empty($data[ 'type' ])) {
$where[] = [ 'type', '=', $data[ 'type' ] ];
}
if (!empty($data['name'])) {
$where[] = ['name', 'like', '%' . $data['name'] . '%'];
if (!empty($data[ 'name' ])) {
$where[] = [ 'name', 'like', '%' . $data[ 'name' ] . '%' ];
}
return $this->getPageList((new SysAttachmentCategory()), $where, 'id,name', 'id desc');
return $this->getPageList(( new SysAttachmentCategory() ), $where, 'id,name', 'id desc');
}
/**
@ -222,16 +227,90 @@ class AttachmentService extends BaseAdminService
*/
public function getCategoryList(array $data)
{
$where = array(
['site_id', '=', $this->site_id]
$where = array (
[ 'site_id', '=', $this->site_id ]
);
if (!empty($data['type'])) {
$where[] = ['type', '=', $data['type']];
if (!empty($data[ 'type' ])) {
$where[] = [ 'type', '=', $data[ 'type' ] ];
}
if (!empty($data['name'])) {
$where[] = ['name', 'like', '%' . $data['name'] . '%'];
if (!empty($data[ 'name' ])) {
$where[] = [ 'name', 'like', '%' . $data[ 'name' ] . '%' ];
}
return SysAttachmentCategory::where($where)->field('id,name,type')->order('id desc')->select()->toArray();
}
/**
* 获取图标库分类列表
* @param array $data
* @return array|null
*/
public function getIconCategoryList(array $data)
{
$icon_list = IconDict::getIcon();
foreach ($icon_list as $k => $v) {
unset($icon_list[ $k ][ 'glyphs' ]);
if (!empty($data[ 'name' ]) && strpos($v[ 'name' ], $data[ 'name' ]) === false) {
unset($icon_list[ $k ]);
}
}
$icon_list = array_values($icon_list);
return $icon_list;
}
/**
* 获取图标库列表
* @param array $data
* @return array|null
*/
public function getIconList(array $data)
{
$icon_list = IconDict::getIcon();
$res = [
'current_page' => intval($data[ 'page' ]),
'per_page' => intval($data[ 'limit' ]),
'data' => [],
'total' => 0
];
$temp_data = [];
foreach ($icon_list as $k => $v) {
$icon = $icon_list[ $k ][ 'glyphs' ]; // 图标列表
foreach ($icon as $ck => $cv) {
// 素材表中数据保持要一致
$icon[ $ck ][ 'att_id' ] = $cv[ 'icon_id' ];
$icon[ $ck ][ 'url' ] = $icon_list[ $k ][ 'font_family' ] . '-' . $icon_list[ $k ][ 'css_prefix_text' ] . $cv[ 'font_class' ];
$icon[ $ck ][ 'real_name' ] = $cv[ 'name' ];
// 查询名称
if (!empty($data[ 'real_name' ]) && strpos($cv[ 'name' ], $data[ 'real_name' ]) === false) {
unset($icon[ $ck ]);
}
}
$icon = array_values($icon);
if (!empty($data[ 'cate_id' ]) && $data[ 'cate_id' ] == $v[ 'id' ]) {
// 查询指定分类下的图标
$temp_data = $icon;
break;
} else {
// 查询全部图标
$temp_data = array_merge($temp_data, $icon);
}
}
// 手动分页
$res[ 'total' ] = count($temp_data); // 总数量
$start = ( $res[ 'current_page' ] - 1 ) * $res[ 'per_page' ]; // 数组下标从0 开始
$icon_list = array_slice($temp_data, $start, $res[ 'per_page' ]);
$res[ 'data' ] = $icon_list;
return $res;
}
}

View File

@ -164,6 +164,31 @@ class ConfigService extends BaseAdminService
$config['value'] = [
'view_path' => 'index/site_index'
];
}else{
$result = event("SiteIndex");
$index_list = [];
foreach ($result as $k => $v)
{
$index_list = empty($index_list) ? $v: array_merge($index_list, $v);
}
$tag = 0;
$view_path = $config['value']['view_path'];
foreach ($index_list as $k => $v)
{
$v_view_path = $v['view_path'] ?? '';
if($view_path == $v_view_path)
{
$tag = 1;
break;
}
}
if($tag == 0)
{
$config['value'] = [
'view_path' => 'index/site_index'
];
}
}
return $config['value']['view_path'];
}
@ -235,9 +260,16 @@ class ConfigService extends BaseAdminService
$menu = $config['value'] ?? [];
if(!empty($menu)){
$menu_service = new MenuService();
foreach($menu as &$v){
$item_router_path = $v['router_path'] ?? '';
if(!$item_router_path) $v['router_path'] = $menu_service->getFullRouterPath($v['menu_key']);
foreach($menu as $k => &$v){
$menu_key = $v['menu_key'] ?? '';
if($menu_key != ''){
$item_router_path = $menu_service->getFullRouterPath($menu_key);
if(empty($item_router_path)){
unset($v[$k]);
}else{
$v['router_path'] = $item_router_path;
}
}
}
}
return $menu;

View File

@ -380,7 +380,8 @@ class MenuService extends BaseAdminService
* @return string
*/
public function getFullRouterPath($menu_key){
$menu = $this->find($menu_key);
$menu = $this->model->where([['menu_key', '=', $menu_key]])->findOrEmpty($menu_key);
if($menu->isEmpty()) return '';
$parents = [];
$this->getParentDirectory($menu, $parents);
$parents = array_reverse($parents);

View File

@ -48,16 +48,13 @@ class SystemService extends BaseAdminService
*/
public function getUrl()
{
$site = Site::find($this->site_id);
$site_tag = $site[ 'site_code' ];
$wap_domain = !empty(env("system.wap_domain")) ? preg_replace('#/$#', '', env("system.wap_domain")) : request()->domain();
$web_domain = !empty(env("system.web_domain")) ? preg_replace('#/$#', '', env("system.web_domain")) : request()->domain();
$data = [
'wap_domain' => env("system.wap_domain"),
'wap_url' => $wap_domain . "/wap/" . $site_tag,
'web_url' => $web_domain . "/web/" . $site_tag,
'wap_url' => $wap_domain . "/wap/" . $this->site_id,
'web_url' => $web_domain . "/web/" . $this->site_id,
];
return $data;
}

View File

@ -9,7 +9,7 @@
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace app\service\admin\file;
namespace app\service\admin\upload;
use app\dict\sys\StorageDict;
use app\service\core\upload\CoreStorageService;

View File

@ -9,7 +9,7 @@
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace app\service\admin\file;
namespace app\service\admin\upload;
use app\model\sys\SysConfig;
use app\service\core\upload\CoreUploadConfigService;

View File

@ -9,7 +9,7 @@
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace app\service\admin\file;
namespace app\service\admin\upload;
use app\dict\sys\FileDict;
use app\dict\sys\StorageDict;
@ -29,8 +29,8 @@ class UploadService extends BaseAdminService
/**
* 附件库上传图片
* @param $file
* @param int $cate_id
* @param string $dir
* @return array
*/
public function image($file, int $cate_id = 0){
@ -55,14 +55,14 @@ class UploadService extends BaseAdminService
/**
* 文件上传
* @param $file
* @param bool $is_local
* @param string $type
* @return array
*/
public function document($file, string $type,bool $is_local = false){
public function document($file, string $type){
if(!in_array($type, FileDict::getSceneType()))
throw new UploadFileException('CERT_TYPE_ERROR');
throw new UploadFileException('UPLOAD_TYPE_ERROR');
$dir = $this->root_path.'/document/'.$type.'/'.$this->site_id.'/'.date('Ym').'/'.date('d');
$core_upload_service = new CoreUploadService();
return $core_upload_service->document($file, $this->site_id, $type, $dir, StorageDict::LOCAL, true);
return $core_upload_service->document($file, $this->site_id, $type, $dir, StorageDict::LOCAL);
}
}

View File

@ -0,0 +1,35 @@
<?php
// +----------------------------------------------------------------------
// | Niucloud-admin 企业快速开发的saas管理平台
// +----------------------------------------------------------------------
// | 官方网址https://www.niucloud-admin.com
// +----------------------------------------------------------------------
// | niucloud团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace app\service\admin\weapp;
use app\model\sys\SysMenu;
use app\service\core\weapp\CoreWeappConfigService;
use core\base\BaseAdminService;
/**
* 小程序包版本发布
*/
class WeappPackageService extends BaseAdminService
{
public function __construct()
{
parent::__construct();
$this->model = new Applet();
}
public function add(array $data)
{
$data['version_num'] = version_to_int($data['version']);//版本号数字
$data['u'] = $this->uid;//发布者
$data['status'] = '';
}
}

View File

@ -69,15 +69,15 @@ class WeappTemplateService extends BaseAdminService
public function syncItem($item){
$key = $item['key'] ?? '';
$weapp = $item['weapp'] ?? [];
$temp_key = $weapp['temp_key'] ?? '';
if(empty($temp_key)) $error = 'WECHAT_TEMPLATE_NEED_NO';
$tid = $weapp['tid'] ?? '';
if(empty($tid)) $error = 'WECHAT_TEMPLATE_NEED_NO';
$weapp_template_id = $item['weapp_template_id'];
//删除原来的消息模板
$template_loader = (new TemplateLoader(NoticeTypeDict::WEAPP, ['site_id' => $this->site_id]));
$template_loader->delete(['template_id' => $weapp_template_id ]);
// (new CoreWeappTemplateService())->deleteTemplate($this->site_id, $weapp_template_id);
//新的消息模板
$tid = $weapp['tid'] ?? '';
$kid_list = $weapp['kid_list'] ?? [];
$scene_desc = $weapp['scene_desc'] ?? '';
// $res = (new CoreWeappTemplateService())->addTemplate($this->site_id, $tid, $kid_list, $scene_desc);

View File

@ -38,7 +38,7 @@ class ArticleService extends BaseApiService
$where[] = [ 'site_id', '=', $this->site_id ];
$field = 'id, category_id, site_id, title, intro, summary, image, author, content, visit, visit_virtual, is_show, sort, create_time, update_time';
$order = 'create_time desc';
$search_model = $this->model->where([ [ 'site_id', '=', $this->site_id ] ])->withSearch([ 'title', 'category_id'], $where)->with('articleCategory')->field($field)->order($order);
$search_model = $this->model->where([ [ 'site_id', '=', $this->site_id ] ])->withSearch([ 'title', 'category_id'], $where)->with('articleCategory')->field($field)->order($order)->append(['image_thumb_mid']);
return $this->pageQuery($search_model);
}
@ -54,7 +54,7 @@ class ArticleService extends BaseApiService
$where[] = [ 'site_id', '=', $this->site_id ];
$field = 'id, category_id, site_id, title, intro, summary, image, author, content, visit, visit_virtual, is_show, sort, create_time, update_time';
$order = 'create_time desc';
return $this->model->where([ [ 'site_id', '=', $this->site_id ] , ['is_show', '=', 1]])->withSearch([ 'title', 'category_id', 'ids' ], $where)->limit($limit)->with('articleCategory')->field($field)->order($order)->select()->toArray();
return $this->model->where([ [ 'site_id', '=', $this->site_id ] , ['is_show', '=', 1]])->withSearch([ 'title', 'category_id', 'ids' ], $where)->limit($limit)->with('articleCategory')->field($field)->append(['image_thumb_mid'])->order($order)->select()->toArray();
}
/**
@ -65,7 +65,7 @@ class ArticleService extends BaseApiService
{
$field = 'id, category_id, site_id, title, intro, summary, image, author, content, visit, visit_virtual, is_show, sort, create_time, update_time';
return $this->model->with('articleCategory')->field($field)->where([ [ 'id', '=', $id ], [ 'site_id', '=', $this->site_id ] ])->findOrEmpty()->toArray();
return $this->model->with('articleCategory')->field($field)->where([ [ 'id', '=', $id ], [ 'site_id', '=', $this->site_id ] ])->append(['image_thumb_big'])->findOrEmpty()->toArray();
}
}

View File

@ -50,14 +50,13 @@ class AuthService extends BaseApiService
* @return true
*/
public function checkSite(Request $request){
$site_code = $request->apiSiteId();//todo 可以是依赖传值,也可以通过domain域名来获取site_id
$site_info = (new CoreSiteService())->getSiteInfoBySiteCode($site_code);
$site_id = $request->apiSiteId();//todo 可以是依赖传值,也可以通过domain域名来获取site_id
$site_info = (new CoreSiteService())->getSiteCache($site_id);
if(empty($site_info)) throw new AuthException('SITE_NOT_EXIST');
if($site_info['status'] == SiteDict::CLOSE){
$rule = trim(strtolower($request->rule()->getRule()));
if($rule != 'site') throw new AuthException('SITE_CLOSE_NOT_ALLOW');
}
$site_id = $site_info['site_id'];
$request->siteId($site_id);
return true;
}

View File

@ -11,6 +11,7 @@
namespace app\service\api\notice;
use app\model\sys\SysNotice;
use core\base\BaseApiService;
/**
@ -36,4 +37,14 @@ class NoticeService extends BaseApiService
{
return ( new \app\service\core\notice\NoticeService() )->send($this->site_id, $key, $data);
}
/**
* 获取微信小程序订阅消息模板id
* @param string $keywords
* @return void
*/
public function getWeappNoticeTemplateId(string $keys) {
$column = (new SysNotice())->where([ ['site_id', '=', $this->site_id], ['key', 'in', explode(',', $keys) ], ['weapp_template_id', '<>', ''], ['is_weapp', '=', 1] ])->column('weapp_template_id');
return $column;
}
}

View File

@ -11,9 +11,11 @@
namespace app\service\api\upload;
use app\dict\sys\FileDict;
use app\dict\sys\StorageDict;
use app\service\core\upload\CoreUploadService;
use core\base\BaseApiService;
use core\exception\UploadFileException;
/**
* 用户服务层
@ -54,13 +56,14 @@ class UploadService extends BaseApiService
/**
* 文件上传
* @param $file
* @param bool $is_local
* @return array
*/
public function document($file, bool $is_local = false)
public function document($file, string $type = '')
{
$dir = $this->root_path . '/' . 'document' . '/' . $this->site_id . '/' . date('Ym') . '/' . date('d');
if(!in_array($type, FileDict::getSceneType()))
throw new UploadFileException('UPLOAD_TYPE_ERROR');
$dir = $this->root_path.'/document/'.$type.'/'.$this->site_id.'/'.date('Ym').'/'.date('d');
$core_upload_service = new CoreUploadService();
return $core_upload_service->document($file, $this->site_id, '', $dir, StorageDict::LOCAL);
return $core_upload_service->document($file, $this->site_id, $type, $dir, StorageDict::LOCAL);
}
}

View File

@ -40,13 +40,13 @@ class CoreAddonInstallService extends CoreAddonBaseService
'wap' => [],
'resource' => []
];
//安装流程
// 安装流程
private $flow_path = [
'file',
'sql',
'menu',
'diy',
''
'diy'
];
/**
@ -60,12 +60,12 @@ class CoreAddonInstallService extends CoreAddonBaseService
];
private $addon;
private $install_addon_path;//待安装的插件目录
private $install_addon_path;// 待安装的插件目录
//对象实例
// 对象实例
public static $instance;
//状态关键字
// 状态关键字
const WAIT_INSTALL = 'wait_install';
const DIR_INSTALLED = 'dir_installed';
@ -73,6 +73,7 @@ class CoreAddonInstallService extends CoreAddonBaseService
const SQL_INSTALLED = 'sql_installed';
const MENU_INSTALLED = 'menu_installed';
const SCHEDULE_INSTALLED = 'schedule_installed';
const WAIT_DEPEND = 'wait_depend';
@ -101,7 +102,6 @@ class CoreAddonInstallService extends CoreAddonBaseService
return self::$instance;
}
public function __construct($addon)
{
parent::__construct();
@ -122,11 +122,13 @@ class CoreAddonInstallService extends CoreAddonBaseService
$from_web_dir = $this->install_addon_path . "web" . DIRECTORY_SEPARATOR;
$from_wap_dir = $this->install_addon_path . "uni-app" . DIRECTORY_SEPARATOR;
$from_resource_dir = $this->install_addon_path . "resource" . DIRECTORY_SEPARATOR;
// 放入的文件
$to_admin_dir = $this->root_path . "admin" . DIRECTORY_SEPARATOR;
$to_web_dir = $this->root_path . "web" . DIRECTORY_SEPARATOR;
$to_wap_dir = $this->root_path . "uni-app" . DIRECTORY_SEPARATOR;
$to_resource_dir = public_path() . "addon" . DIRECTORY_SEPARATOR . $this->addon . DIRECTORY_SEPARATOR;
// 配置文件
$package_path = $this->install_addon_path . 'package' . DIRECTORY_SEPARATOR;
$package_file = [];
@ -172,7 +174,7 @@ class CoreAddonInstallService extends CoreAddonBaseService
array_column($data[ 'runtime' ], 'status'),
[ $data[ 'job_normal' ] ]
);
if (count($data['conflict_files'])) array_push($check_res, false);
if (count($data[ 'conflict_files' ])) array_push($check_res, false);
// 是否通过校验
$data[ 'is_pass' ] = !in_array(false, $check_res);
@ -216,7 +218,6 @@ class CoreAddonInstallService extends CoreAddonBaseService
}
}
//检测wap的uniapp文件
if (is_dir($from_wap_dir)) {
search_dir($from_wap_dir, $this->install_files[ "wap" ]);
@ -441,6 +442,7 @@ class CoreAddonInstallService extends CoreAddonBaseService
$from_web_dir = $this->install_addon_path . "web" . DIRECTORY_SEPARATOR;
$from_wap_dir = $this->install_addon_path . "uni-app" . DIRECTORY_SEPARATOR;
$from_resource_dir = $this->install_addon_path . "resource" . DIRECTORY_SEPARATOR;
// 放入的文件
$to_admin_dir = $this->root_path . "admin" . DIRECTORY_SEPARATOR;
$to_web_dir = $this->root_path . "web" . DIRECTORY_SEPARATOR;
@ -450,6 +452,8 @@ class CoreAddonInstallService extends CoreAddonBaseService
// 安装admin管理端
if (file_exists($from_admin_dir)) {
dir_copy($from_admin_dir, $to_admin_dir, $this->files[ 'admin' ]);
// 编译后台图标库文件
$this->compileAdminIcon();
}
// 安装电脑端
@ -466,6 +470,7 @@ class CoreAddonInstallService extends CoreAddonBaseService
if (file_exists($from_resource_dir)) {
dir_copy($from_resource_dir, $to_resource_dir, $this->files[ 'resource' ]);
}
$this->state = self::DIR_INSTALLED;
return true;
}
@ -502,7 +507,6 @@ class CoreAddonInstallService extends CoreAddonBaseService
}
}
Db::commit();
// 返回订单信息
return true;
} catch (PDOException $e) {
Db::rollback();
@ -559,16 +563,20 @@ class CoreAddonInstallService extends CoreAddonBaseService
if (empty($core_addon_service->getInfoByKey($this->addon))) throw new AddonException('NOT_UNINSTALL');
if (!$this->uninstallSql()) throw new AddonException();
if (!$this->uninstallDir()) throw new AddonException();
// 卸载菜单
$this->uninstallMenu();
// 卸载计划任务
$this->uninstallSchedule();
// 卸载wap
$this->uninstallWap();
$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;
@ -585,12 +593,10 @@ class CoreAddonInstallService extends CoreAddonBaseService
$from_web_dir = $this->install_addon_path . "web" . DIRECTORY_SEPARATOR;
$from_wap_dir = $this->install_addon_path . "uni-app" . DIRECTORY_SEPARATOR;
search_dir($from_admin_dir, $from_admin_dirs, $from_admin_dir);
search_dir($from_web_dir, $from_web_dirs, $from_web_dir);
search_dir($from_wap_dir, $from_wap_dirs, $from_wap_dir);
// 将要删除的根目录
$to_admin_dir = $this->root_path . "admin" . DIRECTORY_SEPARATOR;
$to_web_dir = $this->root_path . "web" . DIRECTORY_SEPARATOR;
@ -600,6 +606,8 @@ class CoreAddonInstallService extends CoreAddonBaseService
// 卸载admin管理端
if (file_exists($from_admin_dir)) {
dir_remove($to_admin_dir, $from_admin_dirs ?? []);
// 编译后台图标库文件
$this->compileAdminIcon();
}
// 卸载pc端
@ -772,7 +780,7 @@ class CoreAddonInstallService extends CoreAddonBaseService
*/
public function installSchedule()
{
( new CoreScheduleInstallService())->installAddonSchedule($this->addon);
( new CoreScheduleInstallService() )->installAddonSchedule($this->addon);
$this->state = self::SCHEDULE_INSTALLED;
return true;
}
@ -783,7 +791,32 @@ class CoreAddonInstallService extends CoreAddonBaseService
*/
public function uninstallSchedule()
{
( new CoreScheduleInstallService())->uninstallAddonSchedule($this->addon);
( new CoreScheduleInstallService() )->uninstallAddonSchedule($this->addon);
return true;
}
/**
* 编译后台图标库文件
* 图标开发注意事项,不能占用 iconfont、icon 关键词(会跟系统图标冲突),建议增加业务前缀,比如 旅游业tourism
* @return bool
*/
public function compileAdminIcon()
{
$compile_path = $this->root_path . str_replace('/', DIRECTORY_SEPARATOR, 'admin/src/styles/icon/');
$content = "";
$root_path = $compile_path . 'addon'; // 插件图标根目录
$file_arr = getFileMap($root_path);
if (!empty($file_arr)) {
foreach ($file_arr as $ck => $cv) {
if (strpos($cv, '.css') !== false) {
$path = str_replace($root_path . '/', '', $ck);
$path = str_replace('/.css', '', $path);
$content .= "@import \"addon/{$path}\";\n";
}
}
}
$res = file_put_contents($compile_path . 'addon-iconfont.css', $content);
return true;
}

View File

@ -35,6 +35,7 @@ trait WapTrait
$content .= " <view v-for=\"(component, index) in data.value\" :key=\"component.id\"\n";
$content .= " @click=\"diyStore.changeCurrentIndex(index, component)\" class=\"draggable-element relative cursor-move\"\n";
$content .= " :class=\"{ selected: diyStore.currentIndex == index,decorate : diyStore.mode == 'decorate' }\" :style=\"component.pageStyle\">\n";
$content .= " <fixed-group :component=\"component\" :index=\"index\" :pullDownRefresh=\"props.pullDownRefresh\"></fixed-group>\n";
$root_path = $compile_path . str_replace('/', DIRECTORY_SEPARATOR, 'components/diy'); // 扩展组件根目录
$file_arr = getFileMap($root_path);
@ -58,9 +59,9 @@ trait WapTrait
$name = implode('', $name_arr);
$file_name = 'diy-' . $path;
$content .= " <template v-if=\"component.componentName == '{$name}'\">\n";
$content .= " <$file_name :component=\"component\" :index=\"index\"></$file_name>\n";
$content .= " </template>\n";
$content .= " <template v-if=\"component.componentName == '{$name}'\">\n";
$content .= " <$file_name :component=\"component\" :index=\"index\" :pullDownRefresh=\"props.pullDownRefresh\"></$file_name>\n";
$content .= " </template>\n";
}
}
}
@ -75,11 +76,11 @@ trait WapTrait
$content .= "<script lang=\"ts\" setup>\n";
$content .= " import useDiyStore from '@/stores/diy';\n";
$content .= " import { onMounted, nextTick, computed, ref } from 'vue';\n";
$content .= " import { onMounted, nextTick, computed, ref,watch } from 'vue';\n";
$content .= " import Sortable from 'sortablejs';\n";
$content .= " import { range } from 'lodash-es';\n";
$content .= " const props = defineProps(['data']);\n";
$content .= " const props = defineProps(['data','pullDownRefresh']);\n";
$content .= " const diyStore = useDiyStore();\n\n";
$content .= " const data = computed(() => {\n";
@ -161,8 +162,8 @@ trait WapTrait
$name = implode('', $name_arr);
$file_name = 'fixed-' . $path;
$content .= " <template v-if=\"data.component == '{$name}'\">\n";
$content .= " <$file_name :data=\"data\"></$file_name>\n";
$content .= " <template v-if=\"props.component.componentName == '{$name}'\">\n";
$content .= " <$file_name :component=\"props.component\" :index=\"props.index\" :pullDownRefresh=\"props.pullDownRefresh\"></$file_name>\n";
$content .= " </template>\n";
}
}
@ -172,12 +173,8 @@ trait WapTrait
$content .= "</template>\n";
$content .= "<script lang=\"ts\" setup>\n";
$content .= " import { computed } from 'vue';\n";
$content .= " const props = defineProps(['data']);\n";
$content .= " const data = computed(() => {\n";
$content .= " return props.data.value;\n";
$content .= " })\n\n";
$content .= " import { computed,watch } from 'vue';\n";
$content .= " const props = defineProps(['component','index','pullDownRefresh']);\n";
$content .= "</script>\n";
$content .= "<style lang=\"scss\" scoped>\n";
@ -189,7 +186,7 @@ trait WapTrait
}
/**
* 编译 pages.json 页面路由代码文件
* 编译 pages.json 页面路由代码文件// {{PAGE}}
* @param $compile_path
* @return bool|int|void
*/

View File

@ -0,0 +1,106 @@
<?php
// +----------------------------------------------------------------------
// | Niucloud-admin 企业快速开发的saas管理平台
// +----------------------------------------------------------------------
// | 官方网址https://www.niucloud-admin.com
// +----------------------------------------------------------------------
// | niucloud团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace app\service\core\applet;
use app\dict\applet\AppletlDict;
use app\service\core\applet\CoreAppletVersionService;
use core\base\BaseCoreService;
use core\exception\CommonException;
/**
* 小程序包下载
*/
class CoreAppletDownloadService extends BaseCoreService
{
protected $replace;//替换文件以及替换的文本变量
protected $version;//版本号
protected $version_id;//版本id
protected $type;//小程序类型
protected $path;
protected $root_path = 'upload';
public function __construct(string $version_id)
{
parent::__construct();
//查询这个版本的信息
$version_info = (new CoreAppletVersionService())->getInfo($version_id);
if(empty($version_info)) throw new CommonException();//不存在的版本
$this->version_id = $version_id;
$this->version = $version_info['version'];
$this->type = $version_info['type'];
$this->path = $version_info['path'];
}
public function setReplace($replace)
{
$this->replace = $replace;
// [
// [
// 'path' => '',
// 'variable' => [
// 'site_name' => '牛'
// ]
// ]
// ];
return $this;
}
/**
* 下载小程序包
* @param int $site_id
* @return \think\response\File
*/
public function download(int $site_id)
{
$zip = new \ZipArchive;
$file_name = $site_id.'.zip';
$dir = $this->root_path .'/applet/'. $this->type.'/'.$this->version.'/';
//新生成一个当前站点这个版本的压缩包,如果已存在就直接下载
$file = $dir.$file_name;
if(!file_exists($file)){
if(!copy($this->path, $file)) throw new CommonException();//文件拷贝失败
if ($zip->open($file) === true) {
//编译
$this->compile($zip);
//关闭
$zip->close();
} else {
throw new CommonException();
}
}
//新增下载记录
(new CoreAppletSiteVersionService())->add($site_id, $this->version_id, AppletlDict::DOWNLOAD);
return download($file, $this->version);
}
/**
* 编译替换
* @param $zip
* @return void
*/
public function compile($zip)
{
foreach ($this->replace as $k => $v) {
$item_path = $v['path'];
$item_variable = $v['variable'];
//Read contents into memory
$old_contents = $zip->getFromName($item_path);
//Modify contents:
foreach($item_variable as $variable_k => $variable_v){
$new_contents = str_replace($variable_k, $variable_v, $old_contents);
}
//Delete the old...
$zip->deleteName($item_path);
//Write the new...
$zip->addFromString($item_path, $new_contents);
}
}
}

View File

@ -0,0 +1,118 @@
<?php
// +----------------------------------------------------------------------
// | Niucloud-admin 企业快速开发的saas管理平台
// +----------------------------------------------------------------------
// | 官方网址https://www.niucloud-admin.com
// +----------------------------------------------------------------------
// | niucloud团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace app\service\core\applet;
use app\dict\applet\AppletlDict;
use app\dict\sys\FileDict;
use app\model\applet\AppletSiteVersion;
use app\model\applet\AppletVersion;
use app\service\core\upload\CoreUploadService;
use core\base\BaseCoreService;
use core\exception\CommonException;
/**
* 小程序包 站点
*/
class CoreAppletSiteVersionService extends BaseCoreService
{
public function __construct()
{
parent::__construct();
$this->model = new AppletSiteVersion();
}
/**
* 版本升级列表
* @param int $site_id
* @param array $where
* @return mixed
*/
public function getPage(int $site_id, array $where = [])
{
if ($site_id > 0) {
$where[] = ['site_id', '=', $site_id];
}
$field = 'id, site_id, version_id, type, action, version, version_num, create_time';
$search_model = $this->model->where($where)->field($field)->order('version_num desc')->with(['appletVersion']);
return $this->pageQuery($search_model);
}
/**
* 获取版本升级信息
* @param int $id
*/
public function getInfo(int $site_id, int $id)
{
$field = 'id, site_id, version_id, type, action, version, version_num, create_time';
return $this->model->where([['id', '=', $id], ['site_id', '=', $site_id]])->field($field)->with(['appletVersion'])->findOrEmpty()->toArray();
}
/**
* 添加版本升级记录
* @param int $site_id
* @param string $action
* @param array $data
* @return true
*/
public function add(int $site_id, int $version_id, string $action)
{
$version_info = (new CoreAppletVersionService())->getInfo($version_id);
if ($version_info) throw new CommonException('APPLET_VERSION_NOT_EXISTS');
$data['site_id'] = $site_id;
$data['type'] = $version_info['type'];
$data['create_time'] = time();
$data['version_id'] = $version_info['id'];
$data['action'] = $action;//操作方式
$this->model->create($data);
return true;
}
/**
* 获取最后一个下载或升级的版本
* @param int $site_id
* @param string $type
* @param string $action
* @return mixed|string
*/
public function getLastVersion(int $site_id, string $type, string $action = '')
{
$where = [['site_id', '=', $site_id], ['type', '=', $type]];
$list = $this->model->where($where)->with(['appletVersion'])->select()->toArray();
$list = array_column($list, null, 'version_num');
ksort($list);
$site_version = reset($list);
return $site_version['version'] ?? '';
}
/**
* 获取当前站点最新可升级的小程序版本
* @param int $site_id
* @param string $type
* @return void
*/
public function getUpgradeVersion(int $site_id, string $type)
{
//查询下一次升级或下载的版本
$version = $this->getLastVersion($site_id, $type);
$where = [['type', '=', $type]];
if (!$version) {
$version_num = version_to_int($version);
$where[] = ['version_num', '>', $version_num];
}
//查询比这个版本号大的版本号
return (new AppletVersion())->where($where)->order('version_num desc')->findOrEmpty();
}
}

View File

@ -0,0 +1,67 @@
<?php
// +----------------------------------------------------------------------
// | Niucloud-admin 企业快速开发的saas管理平台
// +----------------------------------------------------------------------
// | 官方网址https://www.niucloud-admin.com
// +----------------------------------------------------------------------
// | niucloud团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace app\service\core\applet;
use app\dict\applet\AppletlDict;
use app\dict\sys\FileDict;
use app\model\applet\AppletVersion;
use app\service\core\upload\CoreUploadService;
use core\base\BaseCoreService;
use core\exception\CommonException;
/**
* 小程序包发布版本
*/
class CoreAppletVersionService extends BaseCoreService
{
public function __construct()
{
parent::__construct();
$this->model = new AppletVersion();
}
/**
* 获取版本列表
* @param array $where
* @param string $order
*/
public function getPage(array $where = [])
{
$field = 'id, site_id, type, uid, version, version_num, path, create_time, update_time,desc, config';
$search_model = $this->model->where($where)->field($field)->order('create_time desc');
return $this->pageQuery($search_model);
}
/**
* 获取版本信息
* @param int $id
*/
public function getInfo(int $id)
{
$field = 'id, site_id, type, uid, version, version_num, path, create_time, update_time,desc, config';
return $this->model->where([[ 'id', '=', $id ]])->field($field)->findOrEmpty()->toArray();
}
/**
* 通过版本号查询版本内容
* @param string $version
* @return array
*/
public function getInfoByVersion(string $version, string $type){
return $this->model->where([['version', '=', $version], ['type', '=', $type]])->findOrEmpty()->toArray();
}
}

View File

@ -18,6 +18,7 @@ use app\service\admin\sys\MenuService;
use core\dict\DictLoader;
use core\base\BaseCoreService;
use think\facade\Cache;
use think\facade\Db;
/**
* 系统菜单
@ -95,13 +96,13 @@ class CoreMenuService extends BaseCoreService
}
/**
* 删除插件菜单
* 删除插件菜单(强删除)
* @param string $addon
* @return true
*/
public function deleteByAddon(string $addon){
$this->model->where([['addon', '=', $addon]])->delete();
Db::name("sys_menu")->where([['addon', '=', $addon]])->delete();
//$this->model->where([['addon', '=', $addon]])->delete();
return true;
}

View File

@ -41,6 +41,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_async:false);
return Notice::invoke(['site_id' => $site_id, 'key' => $key, 'data' => $data, 'template' => $template], is_async:$template['async']);
}
}

View File

@ -202,6 +202,7 @@ class CorePayEventService extends BaseCoreService
$total = $total * 100;
}
return $this->app('refund')->refund([
'site_id' => $this->site_id,
'out_trade_no' => $out_trade_no,
'money' => $money,
'total' => $total,

View File

@ -197,7 +197,7 @@ class CoreRefundService extends BaseCoreService
])->update([
'status' => RefundDict::SUCCESS
]);
$pay = (new CorePayService())->getInfoByOutTradeNo($out_trade_no);
$pay = (new CorePayService())->findPayInfoByOutTradeNo($site_id, $out_trade_no);
$result = event('RefundSuccess', ['refund_no' => $refund_no, 'trade_type' => $pay->trade_type, 'site_id' => $site_id]);
if(!check_event_result($result)){
return false;

View File

@ -14,6 +14,8 @@ namespace app\service\core\paytype;
use app\dict\member\MemberAccountChangeTypeDict;
use app\dict\member\MemberAccountTypeDict;
use app\dict\pay\PayDict;
use app\dict\pay\RefundDict;
use app\model\pay\Refund;
use app\service\core\member\CoreMemberAccountService;
use app\service\core\pay\CorePayService;
use core\base\BaseCoreService;
@ -89,7 +91,7 @@ class CoreBalanceService extends BaseCoreService
$site_id = $params['site_id'];
$refund_no = $params['refund_no'];
$core_pay_service = new CorePayService();
$pay = $core_pay_service->getInfoByOutTradeNo($out_trade_no);
$pay = $core_pay_service->findPayInfoByOutTradeNo($site_id, $out_trade_no);
$main_id = $pay['main_id'];
$main_type = $pay['main_type'];
@ -106,8 +108,24 @@ class CoreBalanceService extends BaseCoreService
break;
}
return true;
return [
'status' => RefundDict::SUCCESS,
'refund_no' => $refund_no,
'out_trade_no' => $out_trade_no
];
}
/**
* 获取退款信息
* @param string|null $out_trade_no
* @param string|null $refund_no
* @return Refund|array|mixed|\think\Model
*/
public function getRefund(?string $out_trade_no, ?string $refund_no = '') {
return (new Refund())->where([
['refund_no', '=', $refund_no],
])->findOrEmpty();
}
}

View File

@ -102,7 +102,8 @@ class CoreScheduleService extends BaseCoreService
protected function getCrontabContent($data): string
{
$content = '';
switch ($data['type']) {
$type = $data['type'] ?? '';
switch ($type) {
case 'min':// 每隔几分
$content = '每隔'.$data['min'].'分钟执行一次';
break;

View File

@ -45,7 +45,7 @@ class CoreSiteService extends BaseCoreService
$where = [
[ 'site_id', '=', $site_id ],
];
$site = $this->model->where($where)->field('site_id, app_type,site_name,logo,front_end_name,front_end_logo,group_id, status, expire_time, site_code')->append([ 'status_name' ])->findOrEmpty();
$site = $this->model->where($where)->field('site_id, app_type,site_name,logo,front_end_name,front_end_logo,group_id, status, expire_time')->append([ 'status_name' ])->findOrEmpty();
return $site->toArray();
},
self::$cache_tag_name . $site_id
@ -94,26 +94,4 @@ class CoreSiteService extends BaseCoreService
return true;
}
/**
* 通过站点编号获取站点信息
* @param $site_code
* @return mixed|string
*/
public function getSiteInfoBySiteCode($site_code){
$cache_name = 'site_id_cache';
return cache_remember(
$cache_name . $site_code,
function() use ($site_code) {
$site_info = $this->model->where([[
'site_code', '=', $site_code
]])->findOrEmpty();
if(!$site_info->isEmpty()){
return $site_info->toArray();
}
return [];
}
);
}
}

View File

@ -33,15 +33,12 @@ class CoreSysConfigService extends BaseCoreService
* @return array
*/
public function getSceneDomain(int $site_id){
$site = Site::find($site_id);
$site_tag = $site[ 'site_code' ];
$wap_domain = !empty(env("system.wap_domain")) ? preg_replace('#/$#', '', env("system.wap_domain")) : request()->domain();
$web_domain = !empty(env("system.web_domain")) ? preg_replace('#/$#', '', env("system.web_domain")) : request()->domain();
return [
'wap_url' => $wap_domain . "/wap/" . $site_tag . "/",
'web_url' => $web_domain . "/web/" . $site_tag . "/"
'wap_url' => $wap_domain . "/wap/" . $site_id . "/",
'web_url' => $web_domain . "/web/" . $site_id . "/"
];
}

View File

@ -27,12 +27,12 @@ class CoreBase64Service extends CoreFileService
}
/**
* 图片上传
* @param $site_id
* @param $cate_id
* @param $app_type
* @param $file_path
* base64图片上传
* @param string $content
* @param int $site_id
* @param string $file_dir
* @return array
* @throws \Exception
*/
public function image(string $content, int $site_id, string $file_dir)
{

View File

@ -40,7 +40,7 @@ class CoreFileService extends BaseCoreService
/**
* 实例化上传引擎
* @param int $site_id
* @param bool $is_local
* @param string $storage_type
* @return UploadLoader
* @throws \Exception
*/
@ -54,6 +54,8 @@ class CoreFileService extends BaseCoreService
$storage_config = $core_storage_service->getDefaultStorage($this->request->defaultSiteId());
self::$storage_type = $storage_config['storage_type'];
}
$storage_config = $storage_config ?? [];
$storage_config['storage_type'] = self::$storage_type;
//查询启用的上传方式
return new UploadLoader(self::$storage_type, $storage_config ?? []);
}

View File

@ -17,9 +17,7 @@ use app\service\core\sys\CoreAttachmentService;
use core\exception\UploadFileException;
/**
* 图片服务层
* Class CoreUploadService
* @package app\service\core\file
* 图片处理层
*/
class CoreImageService extends CoreFileService
{
@ -29,31 +27,46 @@ class CoreImageService extends CoreFileService
* @param int $site_id
* @param string $file_path
* @param $thumb_type 裁剪的图片规格
* @param bool $is_throw_exception 是否要抛出错误
* @return mixed
* @throws \Exception
*/
public function thumb(int $site_id, string $file_path, $thumb_type = 'all')
public function thumb(int $site_id, string $file_path, $thumb_type = 'all', bool $is_throw_exception = false)
{
$file_parse = parse_url($file_path);
$file_domain = $file_parse['scheme'] . '://' . $file_parse['host'];
$scheme = $file_parse['scheme'] ?? '';
$host = $file_parse['host'] ?? '';
$file_domain = $scheme . '://' . $host;
//判断是哪个云上传的实例
$storage_type_list = (new CoreStorageService())->getStorageConfigList();
foreach($storage_type_list as $k => $v){
$item_params = $v['params'] ?? [];
$item_domain = $item_params['domain'] ?? '';
if($item_domain == $file_domain){
$this->upload_driver = $this->driver($site_id, $v['storage_type']);
$item_storage_type = $v['storage_type'];
if(str_contains($file_path, $item_storage_type.'_')){
$this->upload_driver = $this->driver($site_id, $item_storage_type);
}else{
if($item_domain == $file_domain){
$this->upload_driver = $this->driver($site_id, $item_storage_type);
}
}
}
//没有云上传就用本地上传
if(empty($this->upload_driver)){
$this->upload_driver = $this->driver($site_id, StorageDict::LOCAL);
}
//如果是网络图片,可以将网络图片拉取到本地
//todo 如果是网络图片,可以将网络图片拉取到本地
try {
return $this->upload_driver->thumb($file_path, $thumb_type);
$thumb_list = $this->upload_driver->thumb($file_path, $thumb_type);
return count($thumb_list) > 1 ? $thumb_list : $thumb_list[$thumb_type] ?? '';
} catch (\Throwable $e) {
throw new UploadFileException($e->getMessage());
if($is_throw_exception){
throw new UploadFileException($e->getMessage());
}else{
return '';
}
}
}

View File

@ -23,7 +23,7 @@ class CoreStorageService extends BaseCoreService
/**
* 获取当前启用的存储方式以及配置
* @param $site_id
* @param int $site_id
* @return void
*/
public function getDefaultStorage(int $site_id = 0)
@ -57,7 +57,7 @@ class CoreStorageService extends BaseCoreService
}
/**
* 获取存储配置
* @param $site_id
* @param int $site_id
* @return void
*/
public function getStorageConfig(int $site_id){
@ -69,8 +69,10 @@ class CoreStorageService extends BaseCoreService
}
/**
* 获取云存储列表
* @param int $site_id
* @return array
*/
public function getStorageList(int $site_id = 0)

View File

@ -27,7 +27,7 @@ class CoreUploadConfigService extends BaseCoreService
/**
* 上传配置
* @param $site_id
* @param int $site_id
* @return mixed|string[]
*/
public function getUploadConfig(int $site_id)

View File

@ -17,8 +17,6 @@ use app\service\core\sys\CoreAttachmentService;
/**
* 上传服务层
* Class CoreUploadService
* @package app\service\core\file
*/
class CoreUploadService extends CoreFileService
{
@ -70,19 +68,18 @@ class CoreUploadService extends CoreFileService
* 上传文件
* @param string $file
* @param int $site_id
* @param string $type
* @param string $file_dir
* @param bool $is_local 是否强制本地化
* @param bool $is_rename 是否重命名
* @param string $storage_type
* @return array
* @throws \Exception
*/
public function document(string $file, int $site_id, string $type, string $file_dir, bool $storage_type, bool $is_rename = true)
public function document(string $file, int $site_id, string $type, string $file_dir, string $storage_type)
{
//实例化上传引擎
$this->upload_driver = $this->driver($site_id, $storage_type);
//读取上传附件的信息用于后续得校验和数据写入
$this->upload_driver->read($file, $is_rename);
$this->upload_driver->read($file);
return $this->after($site_id, $file_dir, $type);
}
@ -92,11 +89,11 @@ class CoreUploadService extends CoreFileService
* 上传
* @param int $site_id
* @param string $file_dir
* @param $type
* @param $cate_id
* @param string $type
* @param int $cate_id
* @return array
*/
public function after(int $site_id, string $file_dir, string $type, $cate_id = 0){
public function after(int $site_id, string $file_dir, string $type, int $cate_id = 0){
$file_info = $this->upload_driver->getFileInfo();
@ -122,7 +119,6 @@ class CoreUploadService extends CoreFileService
'cate_id' => $cate_id,
);
$att_id = $core_attachment_service->add($site_id, $data);
}
$return_array = [
'url' => $url

View File

@ -0,0 +1,49 @@
<?php
// +----------------------------------------------------------------------
// | Niucloud-admin 企业快速开发的saas管理平台
// +----------------------------------------------------------------------
// | 官方网址https://www.niucloud-admin.com
// +----------------------------------------------------------------------
// | niucloud团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace app\validate\sys;
use app\service\core\schedule\CoreScheduleService;
use think\Validate;
/**
* Class Schedule
*/
class Schedule extends Validate
{
//用户名或密码的规范可能是从数据库中获取的
protected $rule = [
'key' => 'require|unique:sys_schedule|checkKeyType',
];
protected $message = [
'key.require' => 'validate_schedule.schedule_require',
'key.unique' => 'validate_schedule.schedule_unique',
];
protected $scene = [
'add' => ['key'],
'edit' => [],
];
/**
* 自定义验证 任务类型
* @param $value
* @param $rule
* @param array $data
* @return bool|string
*/
protected function checkKeyType($value, $rule, $data = [])
{
$temp = array_column((new CoreScheduleService())->getTemplateList(), null, 'key');
return isset($temp[$value]) ? true : get_lang("validate_schedule.not_exit_schedule_type");
}
}

View File

@ -54,20 +54,28 @@ return [
],
'size' => 2097152
],
'applet' => [
'ext' => ['zip', 'rar'],
'mime' => [
'application/zip',
'application/vnd.rar'
],
'size' => 2097152
]
],
'thumb' => [
'thumb_type' => [
'big' => [
'width' => 800,
'height' => 800,
],
'mid' => [
'width' => 400,
'height' => 400,
],
'mid' => [
'width' => 100,
'height' => 100,
],
'small' => [
'width' => 50,
'height' => 50,
'width' => 200,
'height' => 200,
],
]

View File

@ -1,6 +1,6 @@
<?php
return [
'version' => '1.0.3',
'code' => '202306080001'
'version' => '1.0.5',
'code' => '202307010001'
];

View File

@ -37,7 +37,7 @@ abstract class BaseDict extends Storage
*/
protected function getLocalAddons()
{
if(!file_exists("../install.lock"))
if(!file_exists(root_path()."install.lock"))
{
//尚未安装不加载插件
return [];

View File

@ -0,0 +1,50 @@
<?php
// +----------------------------------------------------------------------
// | Niucloud-admin 企业快速开发的saas管理平台
// +----------------------------------------------------------------------
// | 官方网址https://www.niucloud-admin.com
// +----------------------------------------------------------------------
// | niucloud团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace core\dict;
/**
* 图标
* Class Icon
* @package core\dict
*/
class Icon extends BaseDict
{
/**
* @param array $data
* @return array
*/
public function load(array $data) : array
{
$sys_path = dirname(app()->getRootPath()) . str_replace('/', DIRECTORY_SEPARATOR, '/admin/src/styles/icon');
$file_arr = getFileMap($sys_path);
$icon_arr = [];
if (!empty($file_arr)) {
foreach ($file_arr as $ck => $cv) {
if (strpos($cv, '.json') !== false) {
$json_string = file_get_contents($ck);
$icon = json_decode($json_string, true);
$icon_arr[] = $icon;
}
}
}
if (count($icon_arr) > 1) {
$last_icon = array_pop($icon_arr); // 最后一个
$first_icon = array_shift($icon_arr); // 第一个
array_unshift($icon_arr, $last_icon); // 将系统图标放到第一位置
$icon_arr[] = $first_icon; // 交换位置
}
return $icon_arr;
}
}

View File

@ -17,10 +17,10 @@ use core\loader\Loader;
* @see \core\template\TemplateLoader
* @package think\facade
* @mixin \core\template\Wechat
* @method string|null send(string $phone, string $templateId, array $data) 发送短信
* @method mixed open(null|string $name = null, mixed $default = null) 开启服务
* @method mixed apply(string $title, string $content, int $type) 申请模板
* @method mixed applys(int $tempType, int $page, int $limit) 模板记录
* @method string|null send(array $data) 发送
* @method mixed addTemplate(array $data) 增加
* @method mixed delete(array $data) 删除
* @method mixed get() 模板记录
*/
class TemplateLoader extends Loader
{

View File

@ -57,7 +57,7 @@ class Weapp extends BaseTemplate
* @return mixed|void
*/
public function addTemplate(array $data){
return $this->template()->addTemplate($data['tid'], $data['kidList'], $data['sceneDesc']);
return $this->template()->addTemplate($data['tid'], $data['kid_list'], $data['scene_desc']);
}
/**

View File

@ -98,7 +98,7 @@ class Aliyun extends BaseUpload
$height = $v['height'];
//拼装缩略路径
$item_thumb = $file_path. '?x-oss-process=image/resize,h_' . $height . ',w_' . $width;
$thumb_data[] = $item_thumb;
$thumb_data[$k] = $item_thumb;
}
}

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