This commit is contained in:
全栈小学生 2024-09-28 09:31:13 +08:00
parent c8c6c2ca22
commit e539980215
65 changed files with 936 additions and 336 deletions

View File

@ -38,7 +38,9 @@ class Config extends BaseAdminController
[ 'is_mobile', 0 ], [ 'is_mobile', 0 ],
[ 'is_auth_register', 1 ], [ 'is_auth_register', 1 ],
[ 'is_bind_mobile', 0 ], [ 'is_bind_mobile', 0 ],
['agreement_show', 0] [ 'agreement_show', 0 ],
[ 'bg_url', '' ],
[ 'desc', '' ]
]); ]);
$this->validate($data, 'app\validate\member\LoginConfig.set'); $this->validate($data, 'app\validate\member\LoginConfig.set');
( new MemberConfigService() )->setLoginConfig($data); ( new MemberConfigService() )->setLoginConfig($data);

View File

@ -29,7 +29,7 @@ class Schedule extends BaseAdminController
{ {
$data = $this->request->params([ $data = $this->request->params([
['key', ''], ['key', ''],
['status', ''], ['status', 'all'],
]); ]);
return success(data: (new ScheduleService())->getPage($data)); return success(data: (new ScheduleService())->getPage($data));
@ -128,4 +128,19 @@ class Schedule extends BaseAdminController
{ {
return success(data: ScheduleDict::getDateType()); return success(data: ScheduleDict::getDateType());
} }
/**
* 执行一次任务
* @param int $id
* @return Response
*/
public function doSchedule(int $id)
{
$res = (new ScheduleService())->doSchedule($id);
if ($res) {
return success('SUCCESS');
} else {
return fail('FAIL');
}
}
} }

View File

@ -0,0 +1,39 @@
<?php
// +----------------------------------------------------------------------
// | Niucloud-admin 企业快速开发的多应用管理平台
// +----------------------------------------------------------------------
// | 官方网址https://www.niucloud.com
// +----------------------------------------------------------------------
// | niucloud团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace app\adminapi\controller\sys;
use app\service\admin\schedule\ScheduleLogService;
use core\base\BaseAdminController;
use think\Response;
/**
* 计划任务执行记录
*/
class ScheduleLog extends BaseAdminController
{
/**
* 任务执行记录列表
* @return Response
*/
public function lists()
{
$data = $this->request->params([
['schedule_id', ''],
['key', ''],
['status', 'all'],
['execute_time', []]
]);
return success(data: (new ScheduleLogService())->getPage($data));
}
}

View File

@ -46,6 +46,14 @@ Route::group('member', function() {
Route::get('status/list', 'member.Member/getStatusList'); Route::get('status/list', 'member.Member/getStatusList');
//会员设置状态 //会员设置状态
Route::put('setstatus/:status', 'member.Member/setStatus'); Route::put('setstatus/:status', 'member.Member/setStatus');
// 获取会员权益字典
Route::get('dict/benefits', 'member.Member/getMemberBenefitsDict');
// 获取会员礼包字典
Route::get('dict/gift', 'member.Member/getMemberGiftDict');
// 获取成长值规则字典
Route::get('dict/growth_rule', 'member.Member/getGrowthRuleDict');
// 获取积分规则字典
Route::get('dict/point_rule', 'member.Member/getPointRuleDict');
/***************************************************** 会员标签 ****************************************************/ /***************************************************** 会员标签 ****************************************************/
//会员标签列表 //会员标签列表
Route::get('label', 'member.MemberLabel/lists'); Route::get('label', 'member.MemberLabel/lists');
@ -101,6 +109,10 @@ Route::group('member', function() {
Route::get('config/point_rule', 'member.Config/getPointRuleConfig'); Route::get('config/point_rule', 'member.Config/getPointRuleConfig');
//设置积分规则 //设置积分规则
Route::post('config/point_rule', 'member.Config/setPointRuleConfig'); Route::post('config/point_rule', 'member.Config/setPointRuleConfig');
//获取注册与登录设置
Route::get('config/member', 'member.Config/getMemberConfig');
//更新注册与登录设置
Route::post('config/member', 'member.Config/setMemberConfig');
/***************************************************** 会员体现**************************************************/ /***************************************************** 会员体现**************************************************/
//会员提现列表 //会员提现列表
Route::get('cash_out', 'member.CashOut/lists'); Route::get('cash_out', 'member.CashOut/lists');
@ -116,18 +128,6 @@ Route::group('member', function() {
Route::get('cash_out/status', 'member.CashOut/getStatusList'); Route::get('cash_out/status', 'member.CashOut/getStatusList');
//提现统计信息 //提现统计信息
Route::get('cash_out/stat', 'member.CashOut/stat'); Route::get('cash_out/stat', 'member.CashOut/stat');
//获取注册与登录设置
Route::get('config/member', 'member.Config/getMemberConfig');
//更新注册与登录设置
Route::post('config/member', 'member.Config/setMemberConfig');
// 获取会员权益字典
Route::get('dict/benefits', 'member.Member/getMemberBenefitsDict');
// 获取会员礼包字典
Route::get('dict/gift', 'member.Member/getMemberGiftDict');
// 获取成长值规则字典
Route::get('dict/growth_rule', 'member.Member/getGrowthRuleDict');
// 获取积分规则字典
Route::get('dict/point_rule', 'member.Member/getPointRuleDict');
/***************************************************** 会员等级 ****************************************************/ /***************************************************** 会员等级 ****************************************************/
//会员等级分页列表 //会员等级分页列表
Route::get('level', 'member.MemberLevel/pages'); Route::get('level', 'member.MemberLevel/pages');

View File

@ -186,6 +186,12 @@ Route::group('sys', function() {
Route::get('schedule/template', 'sys.Schedule/template'); Route::get('schedule/template', 'sys.Schedule/template');
//任务时间间隔 //任务时间间隔
Route::get('schedule/datetype', 'sys.Schedule/getDateType'); Route::get('schedule/datetype', 'sys.Schedule/getDateType');
//执行一次任务
Route::put('schedule/do/:id', 'sys.Schedule/doSchedule');
//任务执行记录列表
Route::get('schedule/log/list', 'sys.ScheduleLog/lists');
/***************************************************** 应用管理 ****************************************************/ /***************************************************** 应用管理 ****************************************************/
Route::get('applist', 'sys.App/getAppList'); Route::get('applist', 'sys.App/getAppList');

View File

@ -16,7 +16,7 @@ use core\base\BaseApiController;
/** /**
* 协议控制器 * 协议控制器
* Class Article * Class Agreement
* @package app\api\controller\agreement * @package app\api\controller\agreement
*/ */
class Agreement extends BaseApiController class Agreement extends BaseApiController

View File

@ -11,6 +11,9 @@
namespace app\api\controller\sys; namespace app\api\controller\sys;
use app\service\api\diy\DiyConfigService;
use app\service\api\member\MemberConfigService;
use app\service\api\member\MemberLevelService;
use app\service\api\sys\ConfigService; use app\service\api\sys\ConfigService;
use core\base\BaseApiController; use core\base\BaseApiController;
use think\Response; use think\Response;
@ -65,4 +68,20 @@ class Config extends BaseApiController
{ {
return success(( new ConfigService() )->getMap()); return success(( new ConfigService() )->getMap());
} }
/**
* 获取初始化数据信息
* @return Response
*/
public function init()
{
$res = [];
$res[ 'tabbar_list' ] = ( new DiyConfigService() )->getBottomList();
$res[ 'map_config' ] = ( new ConfigService() )->getMap();
$res[ 'site_info' ] = ( new ConfigService() )->getWebSite();
$res[ 'member_level' ] = ( new MemberLevelService() )->getList();
$res[ 'login_config' ] = ( new MemberConfigService() )->getLoginConfig();
return success($res);
}
} }

View File

@ -42,11 +42,6 @@ class ApiCheckToken
try { try {
$token = $request->apiToken(); $token = $request->apiToken();
$token_info = ( new LoginService() )->parseToken($token); $token_info = ( new LoginService() )->parseToken($token);
} catch (AuthException $e) {
//是否将登录错误抛出
if ($is_throw_exception)
return fail($e->getMessage(), [], $e->getCode());
}
if (!empty($token_info)) { if (!empty($token_info)) {
$request->memberId($token_info[ 'member_id' ]); $request->memberId($token_info[ 'member_id' ]);
} }
@ -54,6 +49,11 @@ class ApiCheckToken
( new AuthService() )->checkMember($request); ( new AuthService() )->checkMember($request);
// 校验渠道 // 校验渠道
( new AuthService() )->checkChannel($request); ( new AuthService() )->checkChannel($request);
} catch (AuthException $e) {
//是否将登录错误抛出
if ($is_throw_exception)
return fail($e->getMessage(), [], $e->getCode());
}
return $next($request); return $next($request);
} }
} }

View File

@ -104,6 +104,9 @@ Route::group(function() {
// 获取地图设置 // 获取地图设置
Route::get('map', 'sys.Config/getMap'); Route::get('map', 'sys.Config/getMap');
// 获取初始化数据信息
Route::get('init', 'sys.Config/init');
/***************************************************** 地区管理 ****************************************************/ /***************************************************** 地区管理 ****************************************************/
//通过pid获取列表 //通过pid获取列表
Route::get('area/list_by_pid/:pid', 'sys.Area/listByPid'); Route::get('area/list_by_pid/:pid', 'sys.Area/listByPid');

View File

@ -955,3 +955,18 @@ function str_sub($str, $length = 10, $is_need_apostrophe = true)
{ {
return mb_substr($str, 0, $length, 'UTF-8') . ( $is_need_apostrophe ? '...' : '' ); return mb_substr($str, 0, $length, 'UTF-8') . ( $is_need_apostrophe ? '...' : '' );
} }
/**
* 使用正则表达式匹配特殊字符
* @param $str
* @return bool
*/
function is_special_character($str)
{
$pattern = '/[!@#$%^&*()\[\]{}<>\|?:;"]/';
if (preg_match($pattern, $str)) {
return true;
} else {
return false;
}
}

View File

@ -12,7 +12,7 @@ class CommonDict
public const UNKNOWN = 0; public const UNKNOWN = 0;
public const MAN = 1; public const MAN = 1;
public const WOMAN = 2; public const WOMAN = 2;
public const ENCRYPT_STR = '*****************************';
/** /**
* 性别 * 性别

View File

@ -63,63 +63,63 @@ class LinkDict
'name' => 'MEMBER_PERSONAL', 'name' => 'MEMBER_PERSONAL',
'title' => get_lang('dict_diy.member_my_personal'), 'title' => get_lang('dict_diy.member_my_personal'),
'url' => '/app/pages/member/personal', 'url' => '/app/pages/member/personal',
'is_share' => 1, 'is_share' => 0,
'action' => '' 'action' => ''
], ],
[ [
'name' => 'MEMBER_BALANCE', 'name' => 'MEMBER_BALANCE',
'title' => get_lang('dict_diy.member_my_balance'), 'title' => get_lang('dict_diy.member_my_balance'),
'url' => '/app/pages/member/balance', 'url' => '/app/pages/member/balance',
'is_share' => 1, 'is_share' => 0,
'action' => '' 'action' => ''
], ],
[ [
'name' => 'MEMBER_POINT', 'name' => 'MEMBER_POINT',
'title' => get_lang('dict_diy.member_my_point'), 'title' => get_lang('dict_diy.member_my_point'),
'url' => '/app/pages/member/point', 'url' => '/app/pages/member/point',
'is_share' => 1, 'is_share' => 0,
'action' => '' 'action' => ''
], ],
[ [
'name' => 'MEMBER_COMMISSION', 'name' => 'MEMBER_COMMISSION',
'title' => get_lang('dict_diy.member_my_commission'), 'title' => get_lang('dict_diy.member_my_commission'),
'url' => '/app/pages/member/commission', 'url' => '/app/pages/member/commission',
'is_share' => 1, 'is_share' => 0,
'action' => '' 'action' => ''
], ],
[ [
'name' => 'MEMBER_ADDRESS', 'name' => 'MEMBER_ADDRESS',
'title' => get_lang('dict_diy.member_my_address'), 'title' => get_lang('dict_diy.member_my_address'),
'url' => '/app/pages/member/address', 'url' => '/app/pages/member/address',
'is_share' => 1, 'is_share' => 0,
'action' => '' 'action' => ''
], ],
[ [
'name' => 'MEMBER_MY_LEVEL', 'name' => 'MEMBER_MY_LEVEL',
'title' => get_lang('dict_diy.member_my_level'), 'title' => get_lang('dict_diy.member_my_level'),
'url' => '/app/pages/member/level', 'url' => '/app/pages/member/level',
'is_share' => 1, 'is_share' => 0,
'action' => '' 'action' => ''
], ],
[ [
'name' => 'MEMBER_MY_SIGN_IN', 'name' => 'MEMBER_MY_SIGN_IN',
'title' => get_lang('dict_diy.member_my_sign_in'), 'title' => get_lang('dict_diy.member_my_sign_in'),
'url' => '/app/pages/member/sign_in', 'url' => '/app/pages/member/sign_in',
'is_share' => 1, 'is_share' => 0,
'action' => '' 'action' => ''
], ],
[ [
'name' => 'MEMBER_VERIFY_INDEX', 'name' => 'MEMBER_VERIFY_INDEX',
'title' => get_lang('dict_diy.member_verify_index'), 'title' => get_lang('dict_diy.member_verify_index'),
'url' => '/app/pages/verify/index', 'url' => '/app/pages/verify/index',
'is_share' => 1, 'is_share' => 0,
'action' => '' 'action' => ''
], ],
[ [
'name' => 'MEMBER_CONTACT', 'name' => 'MEMBER_CONTACT',
'title' => get_lang('dict_diy.member_contact'), 'title' => get_lang('dict_diy.member_contact'),
'url' => '/app/pages/member/contact', 'url' => '/app/pages/member/contact',
'is_share' => 1, 'is_share' => 0,
'action' => '' 'action' => ''
], ],
] ]

View File

@ -302,7 +302,7 @@ return [
'router_path' => '', 'router_path' => '',
'view_path' => '', 'view_path' => '',
'methods' => '', 'methods' => '',
'sort' => '70', 'sort' => '89',
'status' => '1', 'status' => '1',
'is_show' => '1', 'is_show' => '1',
'children' => [ 'children' => [
@ -715,7 +715,7 @@ return [
'router_path' => '', 'router_path' => '',
'view_path' => '', 'view_path' => '',
'methods' => '', 'methods' => '',
'sort' => '60', 'sort' => '88',
'status' => '1', 'status' => '1',
'is_show' => '1', 'is_show' => '1',
'children' => [ 'children' => [
@ -801,7 +801,7 @@ return [
'router_path' => 'finance/refund', 'router_path' => 'finance/refund',
'view_path' => 'finance/pay_refund', 'view_path' => 'finance/pay_refund',
'methods' => 'get', 'methods' => 'get',
'sort' => '9', 'sort' => '96',
'status' => '1', 'status' => '1',
'is_show' => '1', 'is_show' => '1',
'children' => [ 'children' => [
@ -831,7 +831,7 @@ return [
'router_path' => 'finance/refund/detail', 'router_path' => 'finance/refund/detail',
'view_path' => 'finance/refund_detail', 'view_path' => 'finance/refund_detail',
'methods' => 'get', 'methods' => 'get',
'sort' => '9', 'sort' => '95',
'status' => '1', 'status' => '1',
'is_show' => '0', 'is_show' => '0',
], ],
@ -848,7 +848,7 @@ return [
'router_path' => '', 'router_path' => '',
'view_path' => '', 'view_path' => '',
'methods' => '', 'methods' => '',
'sort' => '56', 'sort' => '87',
'status' => '1', 'status' => '1',
'is_show' => '1', 'is_show' => '1',
'children' => [ 'children' => [
@ -1013,7 +1013,7 @@ return [
'router_path' => '', 'router_path' => '',
'view_path' => '', 'view_path' => '',
'methods' => '', 'methods' => '',
'sort' => '55', 'sort' => '86',
'status' => '1', 'status' => '1',
'is_show' => '1', 'is_show' => '1',
'children' => [ 'children' => [
@ -1044,7 +1044,7 @@ return [
'router_path' => '', 'router_path' => '',
'view_path' => '', 'view_path' => '',
'methods' => '', 'methods' => '',
'sort' => '50', 'sort' => '85',
'status' => '1', 'status' => '1',
'is_show' => '1', 'is_show' => '1',
'children' => [ 'children' => [
@ -1517,7 +1517,7 @@ return [
'router_path' => '', 'router_path' => '',
'view_path' => '', 'view_path' => '',
'methods' => '', 'methods' => '',
'sort' => '40', 'sort' => '84',
'status' => '1', 'status' => '1',
'is_show' => '1', 'is_show' => '1',
'children' => [ 'children' => [
@ -1631,7 +1631,7 @@ return [
'router_path' => 'auth/role', 'router_path' => 'auth/role',
'view_path' => 'auth/role', 'view_path' => 'auth/role',
'methods' => 'get', 'methods' => 'get',
'sort' => '70', 'sort' => '99',
'status' => '1', 'status' => '1',
'is_show' => '1', 'is_show' => '1',
'children' => [ 'children' => [
@ -1689,7 +1689,7 @@ return [
'router_path' => 'setting/auth/log', 'router_path' => 'setting/auth/log',
'view_path' => 'auth/log', 'view_path' => 'auth/log',
'methods' => 'get', 'methods' => 'get',
'sort' => '60', 'sort' => '98',
'status' => '1', 'status' => '1',
'is_show' => '1', 'is_show' => '1',
], ],
@ -1706,7 +1706,7 @@ return [
'router_path' => '', 'router_path' => '',
'view_path' => '', 'view_path' => '',
'methods' => '', 'methods' => '',
'sort' => '30', 'sort' => '83',
'status' => '1', 'status' => '1',
'is_show' => '1', 'is_show' => '1',
'children' => [ 'children' => [
@ -2333,7 +2333,7 @@ return [
'router_path' => 'setting/export', 'router_path' => 'setting/export',
'view_path' => 'setting/export', 'view_path' => 'setting/export',
'methods' => 'get', 'methods' => 'get',
'sort' => '97', 'sort' => '98',
'status' => '1', 'status' => '1',
'is_show' => '1', 'is_show' => '1',
'children' => [ 'children' => [
@ -3041,6 +3041,20 @@ return [
], ],
], ],
], ],
[
'menu_name' => '执行日志',
'menu_key' => 'tools_schedule_log',
'menu_short_name' => '执行日志',
'menu_type' => '1',
'icon' => 'iconfont iconjihuarenwu',
'api_url' => 'sys/schedule/log/list',
'router_path' => 'tools/schedule_log',
'view_path' => 'tools/schedule_log',
'methods' => '',
'sort' => '40',
'status' => '1',
'is_show' => '0'
],
[ [
'menu_name' => '授权信息', 'menu_name' => '授权信息',
'menu_key' => 'app_auth', 'menu_key' => 'app_auth',

View File

@ -57,19 +57,22 @@ class PayDict
'name' => get_lang('dict_pay.type_wechatpay'), 'name' => get_lang('dict_pay.type_wechatpay'),
'key' => self::WECHATPAY, 'key' => self::WECHATPAY,
'icon' => self::WECHATPAY_ICON, 'icon' => self::WECHATPAY_ICON,
'setting_component' => '/src/app/views/setting/components/pay-wechatpay.vue' 'setting_component' => '/src/app/views/setting/components/pay-wechatpay.vue',
'encrypt_params' => ['mch_public_cert_path', 'mch_secret_cert', 'mch_secret_key'],
],//微信支付 ],//微信支付
self::ALIPAY => [ self::ALIPAY => [
'name' => get_lang('dict_pay.type_alipay'), 'name' => get_lang('dict_pay.type_alipay'),
'key' => self::ALIPAY, 'key' => self::ALIPAY,
'icon' => self::ALIPAY_ICON, 'icon' => self::ALIPAY_ICON,
'setting_component' => '/src/app/views/setting/components/pay-alipay.vue' 'setting_component' => '/src/app/views/setting/components/pay-alipay.vue',
'encrypt_params' => ['app_secret_cert', 'app_public_cert_path', 'alipay_public_cert_path', 'alipay_root_cert_path'],
],//支付宝支付 ],//支付宝支付
self::BALANCEPAY => [ self::BALANCEPAY => [
'name' => get_lang('dict_pay.type_balancepay'), 'name' => get_lang('dict_pay.type_balancepay'),
'key' => self::BALANCEPAY, 'key' => self::BALANCEPAY,
'icon' => self::BALANCEPAY_ICON, 'icon' => self::BALANCEPAY_ICON,
'setting_component' => '' 'setting_component' => '',
'encrypt_params' => ['secret_key'],
],//微信支付 ],//微信支付
]; ];

View File

@ -0,0 +1,32 @@
<?php
// +----------------------------------------------------------------------
// | Niucloud-admin 企业快速开发的多应用管理平台
// +----------------------------------------------------------------------
// | 官方网址https://www.niucloud.com
// +----------------------------------------------------------------------
// | niucloud团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace app\dict\schedule;
class ScheduleLogDict
{
public const SUCCESS = 'success';//执行成功
public const ERROR = 'error';//执行失败
/**
* 任务执行状态
* @return array
*/
public static function getStatus()
{
return [
self::SUCCESS => get_lang('dict_schedule_log.success'),//执行成功
self::ERROR => get_lang('dict_schedule_log.error'),//执行失败
];
}
}

View File

@ -32,8 +32,8 @@ class AgreementDict
'privacy' => get_lang('dict_agreement.privacy'),//隐私协议 'privacy' => get_lang('dict_agreement.privacy'),//隐私协议
]; ];
$addon_data = event("AgreementType"); $addon_data = event("AgreementType");
Log::write("检测数据"); // Log::write("检测数据");
Log::write($addon_data); // Log::write($addon_data);
foreach ($addon_data as $k => $v) foreach ($addon_data as $k => $v)
{ {
$data = array_merge($data, $v); $data = array_merge($data, $v);

View File

@ -47,6 +47,7 @@ class SmsDict
'app_key' => 'APP_KEY', 'app_key' => 'APP_KEY',
'secret_key' => 'SECRET_KEY' 'secret_key' => 'SECRET_KEY'
], ],
'encrypt_params' => ['secret_key'],
'component' => '/src/app/views/setting/components/sms-ali.vue', 'component' => '/src/app/views/setting/components/sms-ali.vue',
], ],
self::TENCENTSMS => [ self::TENCENTSMS => [
@ -58,6 +59,7 @@ class SmsDict
'secret_id' => 'SECRET_ID', 'secret_id' => 'SECRET_ID',
'secret_key' => 'SECRET_KEY' 'secret_key' => 'SECRET_KEY'
], ],
'encrypt_params' => ['secret_key'],
'component' => '/src/app/views/setting/components/sms-tencent.vue', 'component' => '/src/app/views/setting/components/sms-tencent.vue',
], ],
]; ];

View File

@ -54,6 +54,7 @@ class StorageDict
'secret_key' => 'SECRET_KEY', 'secret_key' => 'SECRET_KEY',
'domain' => '空间域名' 'domain' => '空间域名'
], ],
'encrypt_params' => ['secret_key'],
'component' => '/src/app/views/setting/components/storage-qiniu.vue', 'component' => '/src/app/views/setting/components/storage-qiniu.vue',
], ],
@ -67,6 +68,7 @@ class StorageDict
'endpoint' => 'Endpoint', 'endpoint' => 'Endpoint',
'domain' => '空间域名' 'domain' => '空间域名'
], ],
'encrypt_params' => ['secret_key'],
'component' => '/src/app/views/setting/components/storage-ali.vue', 'component' => '/src/app/views/setting/components/storage-ali.vue',
], ],
@ -80,6 +82,7 @@ class StorageDict
'secret_key' => 'SECRET_KEY', 'secret_key' => 'SECRET_KEY',
'domain' => '空间域名' 'domain' => '空间域名'
], ],
'encrypt_params' => ['secret_key'],
'component' => '/src/app/views/setting/components/storage-tencent.vue', 'component' => '/src/app/views/setting/components/storage-tencent.vue',
], ],

View File

@ -58,7 +58,6 @@ $system_event = [
'NoticeData' => [ 'NoticeData' => [
'app\listener\notice_template\VerifyCode',//手机验证码 'app\listener\notice_template\VerifyCode',//手机验证码
'app\listener\notice_template\MemberVerifySuccess', 'app\listener\notice_template\MemberVerifySuccess',
'app\listener\notice_template\RechargeSuccess',
], ],
//全场景消息发送 //全场景消息发送
'Notice' => [ 'Notice' => [
@ -93,7 +92,7 @@ $system_event = [
'StatField' => [], 'StatField' => [],
// 获取海报数据 // 获取海报数据
'GetPosterData' => ['app\listener\system\Poster'], 'GetPosterData' => [ 'app\listener\system\Poster' ]
], ],
'subscribe' => [ 'subscribe' => [
], ],

View File

@ -799,6 +799,22 @@ CREATE TABLE `sys_schedule` (
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '系统任务' ROW_FORMAT = Dynamic; ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '系统任务' ROW_FORMAT = Dynamic;
DROP TABLE IF EXISTS `sys_schedule_log`;
CREATE TABLE `sys_schedule_log` (
`id` int NOT NULL AUTO_INCREMENT COMMENT '执行记录id',
`schedule_id` int NOT NULL DEFAULT 0 COMMENT '任务id',
`addon` varchar(255) NOT NULL DEFAULT '' COMMENT '所属插件',
`key` varchar(255) NOT NULL DEFAULT '' COMMENT '计划任务模板key',
`name` varchar(50) NOT NULL DEFAULT '' COMMENT '计划任务名称',
`execute_time` int NOT NULL COMMENT '执行时间',
`execute_result` text DEFAULT NULL COMMENT '日志信息',
`status` varchar(255) NOT NULL DEFAULT '' COMMENT '执行状态',
`class` varchar(255) NOT NULL DEFAULT '',
`job` varchar(255) NOT NULL DEFAULT '',
PRIMARY KEY (`id`)
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '计划任务执行记录' ROW_FORMAT = Dynamic;
DROP TABLE IF EXISTS `sys_user`; DROP TABLE IF EXISTS `sys_user`;
CREATE TABLE `sys_user` ( CREATE TABLE `sys_user` (
`uid` smallint(5) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '系统用户ID', `uid` smallint(5) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '系统用户ID',

View File

@ -101,7 +101,7 @@ return [
'MEMBER_TYPE_NOT_EXIST' => '账户类型不存在', 'MEMBER_TYPE_NOT_EXIST' => '账户类型不存在',
'MEMBER_IS_EXIST' => '账号已存在', 'MEMBER_IS_EXIST' => '账号已存在',
'REG_CHANNEL_NOT_EXIST' => '无效的注册渠道', 'REG_CHANNEL_NOT_EXIST' => '无效的注册渠道',
'MEMBER_USERNAME_LOGIN_NOT_OPEN' => '未开账号登录注册', 'MEMBER_USERNAME_LOGIN_NOT_OPEN' => '未开账号登录注册',
'AUTH_LOGIN_NOT_OPEN' => '未开启第三方登录注册', 'AUTH_LOGIN_NOT_OPEN' => '未开启第三方登录注册',
'MOBILE_NEEDED' => '手机号必须填写', 'MOBILE_NEEDED' => '手机号必须填写',
'MOBILE_CAPTCHA_ERROR' => '手机验证码有误', 'MOBILE_CAPTCHA_ERROR' => '手机验证码有误',

View File

@ -46,7 +46,6 @@ return [
'ZIP_FILE_NOT_FOUND' => '找不到可用的压缩文件', 'ZIP_FILE_NOT_FOUND' => '找不到可用的压缩文件',
'ZIP_ARCHIVE_NOT_INSTALL' => 'ZipArchive扩展未安装', 'ZIP_ARCHIVE_NOT_INSTALL' => 'ZipArchive扩展未安装',
'DOWNLOAD_SUCCESS' => '下载成功', 'DOWNLOAD_SUCCESS' => '下载成功',
'APP_NOT_ALLOW_UNINSTALL' => '该应用下存在站点卸载前请先删除相关站点',
'ADDON_INSTALL_FAIL' => '插件安装失败', 'ADDON_INSTALL_FAIL' => '插件安装失败',
'ADMIN_DIR_NOT_EXIST' => '未找到admin源码所在目录, <a style="text-decoration: underline;" href="https://www.kancloud.cn/niucloud/niucloud-admin-develop/3213544" target="blank">点击查看相关手册</a>', 'ADMIN_DIR_NOT_EXIST' => '未找到admin源码所在目录, <a style="text-decoration: underline;" href="https://www.kancloud.cn/niucloud/niucloud-admin-develop/3213544" target="blank">点击查看相关手册</a>',
'WEB_DIR_NOT_EXIST' => '未找到web源码所在目录, <a style="text-decoration: underline;" href="https://www.kancloud.cn/niucloud/niucloud-admin-develop/3213544" target="blank">点击查看相关手册</a>', 'WEB_DIR_NOT_EXIST' => '未找到web源码所在目录, <a style="text-decoration: underline;" href="https://www.kancloud.cn/niucloud/niucloud-admin-develop/3213544" target="blank">点击查看相关手册</a>',
@ -82,6 +81,7 @@ return [
//插件安装相关 //插件安装相关
'REPEAT_INSTALL' => '当前插件已安装,不能重复安装', 'REPEAT_INSTALL' => '当前插件已安装,不能重复安装',
'NOT_UNINSTALL' => '当前插件未安装,不能进行卸载操作', 'NOT_UNINSTALL' => '当前插件未安装,不能进行卸载操作',
'ADDON_INFO_FILE_NOT_EXIST' => '未找到插件的info.json文件',
//菜单管理 //菜单管理
'MENU_NOT_EXIST' => '菜单不存在', 'MENU_NOT_EXIST' => '菜单不存在',
@ -143,7 +143,7 @@ return [
'MEMBER_IS_EXIST' => '账号已存在', 'MEMBER_IS_EXIST' => '账号已存在',
'MEMBER_NO_IS_EXIST' => '会员编号已存在', 'MEMBER_NO_IS_EXIST' => '会员编号已存在',
'REG_CHANNEL_NOT_EXIST' => '无效的注册渠道', 'REG_CHANNEL_NOT_EXIST' => '无效的注册渠道',
'MEMBER_USERNAME_LOGIN_NOT_OPEN' => '未开账号登录注册', 'MEMBER_USERNAME_LOGIN_NOT_OPEN' => '未开账号登录注册',
'AUTH_LOGIN_NOT_OPEN' => '未开启第三方登录注册', 'AUTH_LOGIN_NOT_OPEN' => '未开启第三方登录注册',
'MOBILE_NEEDED' => '手机号必须填写', 'MOBILE_NEEDED' => '手机号必须填写',
'MOBILE_CAPTCHA_ERROR' => '手机验证码有误', 'MOBILE_CAPTCHA_ERROR' => '手机验证码有误',
@ -181,11 +181,12 @@ return [
'KEYWORDS_NOT_EXIST' => '关键词回复不存在', 'KEYWORDS_NOT_EXIST' => '关键词回复不存在',
'WECHAT_EMPOWER_NOT_EXIST' => '微信授权信息不存在', 'WECHAT_EMPOWER_NOT_EXIST' => '微信授权信息不存在',
'SCAN_SUCCESS' => '扫码成功', 'SCAN_SUCCESS' => '扫码成功',
'WECHAT_SNAPSHOUTUSER' => '返回的是虚拟账号',
//小程序 //小程序
'WEAPP_NOT_EXIST' => '微信小程序未配置完善', 'WEAPP_NOT_EXIST' => '微信小程序未配置完善',
'WEAPP_EMPOWER_NOT_EXIST' => '微信小程序授信信息不存在', 'WEAPP_EMPOWER_NOT_EXIST' => '微信小程序授信信息不存在',
'WEAPP_EMPOWER_TEL_NOT_EXIST' => '微信小程序授信手机号不存在', 'WEAPP_EMPOWER_TEL_NOT_EXIST' => '微信小程序授信手机号不存在',
'CURR_SITE_IS_NOT_OPEN_SSL' => '微信小程序请求域名只支持https请先配置ssl', 'CURR_SITE_IS_NOT_OPEN_SSL' => '微信小程序请求地址只支持https请先配置ssl',
'WECHAT_MINI_PROGRAM_CODE_GENERATION_FAILED' => '微信小程序码生成失败', 'WECHAT_MINI_PROGRAM_CODE_GENERATION_FAILED' => '微信小程序码生成失败',
//站点相关 //站点相关

View File

@ -153,6 +153,11 @@ return [
'month' => '每月', 'month' => '每月',
], ],
//计划任务执行记录
'dict_schedule_log' => [
'success' => '成功',
'error' => '失败',
],
//支付相关 //支付相关
'dict_pay' => [ 'dict_pay' => [
'type_wechatpay' => '微信支付', 'type_wechatpay' => '微信支付',

View File

@ -25,7 +25,6 @@ class MemberExportTypeListener
'member' => [ 'member' => [
'name' => '会员列表', 'name' => '会员列表',
'column' => [ 'column' => [
'username' => [ 'name' => '真实姓名'],
'nickname' => [ 'name' => '会员昵称'], 'nickname' => [ 'name' => '会员昵称'],
'mobile' => [ 'name' => '手机号'], 'mobile' => [ 'name' => '手机号'],
'member_level_name' => [ 'name' => '会员等级'], 'member_level_name' => [ 'name' => '会员等级'],

View File

@ -1,44 +0,0 @@
<?php
namespace app\listener\notice_template;
use app\service\core\member\CoreMemberService;
use addon\recharge\app\service\core\CoreRechargeOrderService;
class RechargeSuccess extends BaseNoticeTemplate
{
private $key = 'recharge_success';
public function handle(array $params)
{
if ($this->key == $params[ 'key' ]) {
$data = $params[ 'data' ];
$order_id = $data[ 'order_id' ];
$core_order_service = new CoreRechargeOrderService();
$order = $core_order_service->orderInfo($order_id);
if (!empty($order)) {
$member = ( new CoreMemberService() )->getInfoByMemberId($order[ 'member_id' ]);
//通过订单id查询订单信息
return $this->toReturn(
[
'__wechat_page' => '',//模板消息链接
'__miniprogram' => '',//模板消息小程序
'__weapp_page' => '',//小程序链接
'balance' => $member[ 'balance' ],//充值后的余额
'price' => $order[ 'order_item_money' ],//订单项总价
'time' => $order[ 'create_time' ],//创建时间
'trade_no' => $order[ 'out_trade_no' ],//交易流水号
],
[
'member_id' => $order[ 'member_id' ],
]
);
}
}
}
}

View File

@ -11,7 +11,6 @@
namespace app\listener\pay; namespace app\listener\pay;
use addon\recharge\app\service\core\CoreRechargeRefundService;
use app\service\core\pay\CoreAccountService; use app\service\core\pay\CoreAccountService;
/** /**
@ -23,11 +22,5 @@ class RefundSuccessListener
{ {
//添加账单记录 //添加账单记录
(new CoreAccountService())->addRefundLog($refund_info['refund_no']); (new CoreAccountService())->addRefundLog($refund_info['refund_no']);
//交易单据处理
$trade_type = $refund_info['trade_type'] ?? '';
if ($trade_type == 'recharge') {
(new CoreRechargeRefundService())->refundComplete($refund_info['refund_no']);
}
} }
} }

View File

@ -79,7 +79,7 @@ class SysSchedule extends BaseModel
*/ */
public function searchStatusAttr(Query $query, $value, $data) public function searchStatusAttr(Query $query, $value, $data)
{ {
if ($value) { if ($value != 'all') {
$query->where('status', $value); $query->where('status', $value);
} }
} }

View File

@ -0,0 +1,112 @@
<?php
// +----------------------------------------------------------------------
// | Niucloud-admin 企业快速开发的saas管理平台
// +----------------------------------------------------------------------
// | 官方网址https://www.niucloud.com
// +----------------------------------------------------------------------
// | niucloud团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace app\model\sys;
use app\dict\schedule\ScheduleLogDict;
use core\base\BaseModel;
use think\db\Query;
/**
* 计划任务执行记录模型
*/
class SysScheduleLog extends BaseModel
{
/**
* 数据表主键
* @var string
*/
protected $pk = 'id';
/**
* 模型名称
* @var string
*/
protected $name = 'sys_schedule_log';
protected $type = [
'execute_time' => 'timestamp',
];
/**
* 启用状态
* @param $value
* @param $data
* @return mixed
*/
public function getStatusNameAttr($value, $data)
{
if (empty($data['status'])) return '';
return ScheduleLogDict::getStatus()[$data['status']] ?? '';
}
/**
* 任务id搜索器
* @param Query $query
* @param $value
* @param $data
*/
public function searchScheduleIdAttr(Query $query, $value, $data)
{
if ($value) {
$query->where('schedule_id', $value);
}
}
/**
* 任务类型搜索器
* @param Query $query
* @param $value
* @param $data
*/
public function searchKeyAttr(Query $query, $value, $data)
{
if ($value) {
$query->where('key', $value);
}
}
/**
* 状态搜索
* @param Query $query
* @param $value
* @param $data
* @return void
*/
public function searchStatusAttr(Query $query, $value, $data)
{
if ($value != 'all') {
$query->where('status', $value);
}
}
/**
* 执行时间搜索器
* @param $query
* @param $value
* @param $data
*/
public function searchExecuteTimeAttr($query, $value, $data)
{
$start_time = empty($value[0]) ? 0 : strtotime($value[0]);
$end_time = empty($value[1]) ? 0 : strtotime($value[1]);
if ($start_time > 0 && $end_time > 0) {
$query->whereBetweenTime('execute_time', $start_time, $end_time);
} else if ($start_time > 0 && $end_time == 0) {
$query->where([['execute_time', '>=', $start_time]]);
} else if ($start_time == 0 && $end_time > 0) {
$query->where([['execute_time', '<=', $end_time]]);
}
}
}

View File

@ -35,6 +35,15 @@ class DiyConfigService extends BaseAdminService
$list = ( new CoreDiyConfigService() )->getBottomList($params); $list = ( new CoreDiyConfigService() )->getBottomList($params);
$apps = ( new CoreAddonService() )->getList([ [ 'type', '=', 'app' ] ]); $apps = ( new CoreAddonService() )->getList([ [ 'type', '=', 'app' ] ]);
$bottom_list_keys = array_column($list, 'key');
// 排除没有底部导航的应用
foreach ($apps as $k => $v) {
if (!in_array($v[ 'key' ], $bottom_list_keys)) {
unset($apps[ $k ]);
}
}
$apps = array_values($apps);
// 单应用,排除 系统 底部导航设置 // 单应用,排除 系统 底部导航设置
if (count($list) > 1 && count($apps) == 1) { if (count($list) > 1 && count($apps) == 1) {

View File

@ -0,0 +1,3 @@
<el-form-item :label="t('{LCASE_COLUMN_NAME}')">
<upload-file v-model="formData.{COLUMN_NAME}" />
</el-form-item>

View File

@ -0,0 +1,3 @@
<el-form-item :label="t('{LCASE_COLUMN_NAME}')">
<upload-video v-model="formData.{COLUMN_NAME}" />
</el-form-item>

View File

@ -1,6 +1,5 @@
<template> <template>
<el-dialog v-model="showDialog" :title="formData.{PK} ? t('update{UCASE_CLASS_NAME}') : t('add{UCASE_CLASS_NAME}')" width="50%" class="diy-dialog-wrap" <el-dialog v-model="showDialog" :title="formData.{PK} ? t('update{UCASE_CLASS_NAME}') : t('add{UCASE_CLASS_NAME}')" width="50%" class="diy-dialog-wrap" :destroy-on-close="true">
:destroy-on-close="true">
<el-form :model="formData" label-width="120px" ref="formRef" :rules="formRules" class="page-form" v-loading="loading"> <el-form :model="formData" label-width="120px" ref="formRef" :rules="formRules" class="page-form" v-loading="loading">
{FORM_VIEW} {FORM_VIEW}
</el-form> </el-form>

View File

@ -36,8 +36,7 @@ class MemberSignService extends BaseAdminService
public function getPage(array $where = []) public function getPage(array $where = [])
{ {
$member_where = []; $member_where = [];
if(isset($where['keywords']) && $where['keywords'] != '') if (isset($where[ 'keywords' ]) && $where[ 'keywords' ] != '') {
{
$member_where = [ [ 'member.member_no|member.nickname|member.mobile', 'like', '%' . $this->model->handelSpecialCharacter($where[ 'keywords' ]) . '%' ] ]; $member_where = [ [ 'member.member_no|member.nickname|member.mobile', 'like', '%' . $this->model->handelSpecialCharacter($where[ 'keywords' ]) . '%' ] ];
} }
$field = 'sign_id, member_sign.member_id, days, day_award, continue_award, continue_tag, member_sign.create_time, is_sign'; $field = 'sign_id, member_sign.member_id, days, day_award, continue_award, continue_tag, member_sign.create_time, is_sign';
@ -51,7 +50,8 @@ class MemberSignService extends BaseAdminService
* 组合整理数据 * 组合整理数据
* @param $data * @param $data
*/ */
public function makeUp($data){ public function makeUp($data)
{
//日签奖励 //日签奖励
if (!empty($data[ 'day_award' ])) { if (!empty($data[ 'day_award' ])) {
$data[ 'day_award' ] = ( new CoreMemberService() )->getGiftContent($data[ 'day_award' ]); $data[ 'day_award' ] = ( new CoreMemberService() )->getGiftContent($data[ 'day_award' ]);
@ -109,6 +109,9 @@ class MemberSignService extends BaseAdminService
'rule_explain' => '' 'rule_explain' => ''
]; ];
} }
if (empty($info[ 'value' ][ 'continue_award' ]) && gettype($info[ 'value' ][ 'continue_award' ]) == 'string') {
$info[ 'value' ][ 'continue_award' ] = [];
}
return $info[ 'value' ]; return $info[ 'value' ];
} }
} }

View File

@ -11,11 +11,11 @@
namespace app\service\admin\notice; namespace app\service\admin\notice;
use app\dict\common\CommonDict;
use app\dict\sys\SmsDict; use app\dict\sys\SmsDict;
use app\service\core\sys\CoreConfigService; use app\service\core\sys\CoreConfigService;
use core\base\BaseAdminService; use core\base\BaseAdminService;
use core\exception\AdminException; use core\exception\AdminException;
use think\Response;
/** /**
* 短信配置服务层 * 短信配置服务层
@ -49,9 +49,13 @@ class SmsService extends BaseAdminService
$data['name'] = $v['name']; $data['name'] = $v['name'];
foreach ($v['params'] as $k_param => $v_param) foreach ($v['params'] as $k_param => $v_param)
{ {
$value = $config_type[$k][$k_param] ?? '';
$encrypt_params = $sms_type_list[$k]['encrypt_params'] ?? [];
if ($value !== '' && in_array($k_param, $encrypt_params)) $value = CommonDict::ENCRYPT_STR;
$data['params'][$k_param] = [ $data['params'][$k_param] = [
'name' => $v_param, 'name' => $v_param,
'value' => $config_type[$k][$k_param] ?? '' 'value' => $value
]; ];
} }
$data['component'] = $v['component'] ?? ''; $data['component'] = $v['component'] ?? '';
@ -83,9 +87,13 @@ class SmsService extends BaseAdminService
]; ];
foreach ($sms_type_list[$sms_type]['params'] as $k_param => $v_param) foreach ($sms_type_list[$sms_type]['params'] as $k_param => $v_param)
{ {
$value = $config_type[$sms_type][$k_param] ?? '';
$encrypt_params = $sms_type_list[$sms_type]['encrypt_params'] ?? [];
if ($value !== '' && in_array($k_param, $encrypt_params)) $value = CommonDict::ENCRYPT_STR;
$data['params'][$k_param] = [ $data['params'][$k_param] = [
'name' => $v_param, 'name' => $v_param,
'value' => $config_type[$sms_type][$k_param] ?? '' 'value' => $value
]; ];
} }
return $data; return $data;
@ -119,7 +127,9 @@ class SmsService extends BaseAdminService
} }
foreach ($sms_type_list[$sms_type]['params'] as $k_param => $v_param) foreach ($sms_type_list[$sms_type]['params'] as $k_param => $v_param)
{ {
$config[$sms_type][$k_param] = $data[$k_param] ?? ''; $value = $data[$k_param] ?? '';
if ($value == CommonDict::ENCRYPT_STR) $value = isset($config[$sms_type]) ? ($config[$sms_type][$k_param] ?? '') : '';
$config[$sms_type][$k_param] = $value;
} }
return (new CoreConfigService())->setConfig('SMS', $config); return (new CoreConfigService())->setConfig('SMS', $config);

View File

@ -12,6 +12,7 @@
namespace app\service\admin\pay; namespace app\service\admin\pay;
use app\dict\common\ChannelDict; use app\dict\common\ChannelDict;
use app\dict\common\CommonDict;
use app\dict\pay\PayChannelDict; use app\dict\pay\PayChannelDict;
use app\dict\pay\PayDict; use app\dict\pay\PayDict;
use app\model\pay\PayChannel; use app\model\pay\PayChannel;
@ -55,13 +56,20 @@ class PayChannelService extends BaseAdminService
if (!array_key_exists($channel, ChannelDict::getType())) throw new PayException('CHANNEL_MARK_INVALID'); if (!array_key_exists($channel, ChannelDict::getType())) throw new PayException('CHANNEL_MARK_INVALID');
} }
$pay_channel = $this->core_pay_channel_service->find($where); $pay_channel = $this->core_pay_channel_service->find($where);
if ($pay_channel->isEmpty()) { if ($pay_channel->isEmpty()) {
$data[ 'channel' ] = $channel; $data[ 'channel' ] = $channel;
$data[ 'type' ] = $type; $data[ 'type' ] = $type;
$data[ 'config' ] = $this->getConfigByPayType($data[ 'config' ], $type); $data[ 'config' ] = $this->getConfigByPayType($data[ 'config' ], $type);
$res = $this->model->create($data); $res = $this->model->create($data);
} else { } else {
$config = $pay_channel->config;
$data[ 'config' ] = $this->getConfigByPayType($data[ 'config' ], $type); $data[ 'config' ] = $this->getConfigByPayType($data[ 'config' ], $type);
foreach ($data[ 'config' ] as $config_k => $config_v) {
if ($config_v == CommonDict::ENCRYPT_STR && isset($config[$config_k])) {
$data[ 'config' ][$config_k] = $config[$config_k];
}
}
$pay_channel->save($data); $pay_channel->save($data);
} }
return true; return true;
@ -86,10 +94,21 @@ class PayChannelService extends BaseAdminService
foreach ($pay_channel_list_temp as $v) { foreach ($pay_channel_list_temp as $v) {
$pay_channel_list[ $v[ 'channel' ] ][ $v[ 'type' ] ] = $v; $pay_channel_list[ $v[ 'channel' ] ][ $v[ 'type' ] ] = $v;
} }
$pay_type_list = PayDict::getPayType();
foreach ($channel_list as $k => $v) { foreach ($channel_list as $k => $v) {
$temp_item = $pay_channel_list[ $k ] ?? []; $temp_item = $pay_channel_list[ $k ] ?? [];
foreach ($v[ 'pay_type' ] as $item_k => $item_v) { foreach ($v[ 'pay_type' ] as $item_k => $item_v) {
$temp_v_item = $temp_item[ $item_k ] ?? [ 'status' => 0, 'config' => [ 'name' => '' ], 'sort' => 0 ]; if (isset($temp_item[ $item_k ])) {
$temp_v_item = $temp_item[ $item_k ];
$encrypt_params = $pay_type_list[$item_k]['encrypt_params'] ?? [];
foreach ($temp_v_item['config'] as $config_k => $config_v) {
if ($config_v !== '' && in_array($config_k, $encrypt_params)) $temp_v_item['config'][$config_k] = CommonDict::ENCRYPT_STR;
}
} else {
$temp_v_item = [ 'status' => 0, 'config' => [ 'name' => '' ], 'sort' => 0 ];
}
$item_v[ 'config' ] = $temp_v_item[ 'config' ]; $item_v[ 'config' ] = $temp_v_item[ 'config' ];
$item_v[ 'status' ] = $temp_v_item[ 'status' ]; $item_v[ 'status' ] = $temp_v_item[ 'status' ];
$item_v[ 'sort' ] = $temp_v_item[ 'sort' ]; $item_v[ 'sort' ] = $temp_v_item[ 'sort' ];
@ -116,7 +135,17 @@ class PayChannelService extends BaseAdminService
$where = array ( $where = array (
'channel' => $channel 'channel' => $channel
); );
return $this->model->where($where)->field('type, channel, config, sort, status')->select()->toArray(); $list = $this->model->where($where)->field('type, channel, config, sort, status')->select()->toArray();
if (!empty($list)) {
$pay_type_list = PayDict::getPayType();
foreach ($list as $k => &$v) {
$encrypt_params = $pay_type_list[ $v['type'] ]['encrypt_params'] ?? [];
foreach ($v['config'] as $config_k => $config_v) {
if ($config_v !== '' && in_array($config_k, $encrypt_params)) $v['config'][$config_k] = CommonDict::ENCRYPT_STR;
}
}
}
return $list;
} }
/** /**

View File

@ -0,0 +1,54 @@
<?php
// +----------------------------------------------------------------------
// | Niucloud-admin 企业快速开发的多应用管理平台
// +----------------------------------------------------------------------
// | 官方网址https://www.niucloud.com
// +----------------------------------------------------------------------
// | niucloud团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace app\service\admin\schedule;
use app\service\core\schedule\CoreScheduleLogService;
use core\base\BaseAdminService;
/**
* 计划任务执行记录服务层
* Class CoreCronService
* @package app\service\core\cron
*/
class ScheduleLogService extends BaseAdminService
{
public function __construct()
{
parent::__construct();
}
/**
* 获取自动任务列表
* @param array $data
* @return array
*/
public function getPage(array $data = [])
{
return (new CoreScheduleLogService())->getPage($data);
}
/**
* 添加
* @param array $data
* @return true
*/
public function add(array $data)
{
$res = (new CoreScheduleLogService())->add($data);
return true;
}
}

View File

@ -102,4 +102,13 @@ class ScheduleService extends BaseAdminService
public function getTemplateList(){ public function getTemplateList(){
return (new CoreScheduleService())->getTemplateList(); return (new CoreScheduleService())->getTemplateList();
} }
/**
* 执行一次计划任务
* @return true
*/
public function doSchedule(int $id)
{
return (new CoreScheduleService())->doSchedule($id);
}
} }

View File

@ -12,6 +12,7 @@
namespace app\service\admin\sys; namespace app\service\admin\sys;
use app\job\sys\CheckJob; use app\job\sys\CheckJob;
use app\service\core\sys\CoreSysConfigService;
use core\base\BaseAdminService; use core\base\BaseAdminService;
use think\facade\Db; use think\facade\Db;
use Throwable; use Throwable;
@ -47,14 +48,7 @@ class SystemService extends BaseAdminService
*/ */
public function getUrl() public function getUrl()
{ {
$wap_domain = !empty(env("system.wap_domain")) ? preg_replace('#/$#', '', env("system.wap_domain")) : request()->domain(); return (new CoreSysConfigService())->getSceneDomain();
$web_domain = !empty(env("system.web_domain")) ? preg_replace('#/$#', '', env("system.web_domain")) : request()->domain();
return [
'wap_domain' => env("system.wap_domain"),
'wap_url' => $wap_domain . "/wap",
'web_url' => $web_domain . "/web",
];
} }
/** /**

View File

@ -14,11 +14,13 @@ namespace app\service\admin\upgrade;
use app\dict\addon\AddonDict; use app\dict\addon\AddonDict;
use app\model\addon\Addon; use app\model\addon\Addon;
use app\service\admin\install\InstallSystemService; use app\service\admin\install\InstallSystemService;
use app\service\admin\sys\ConfigService;
use app\service\core\addon\CoreAddonCloudService; use app\service\core\addon\CoreAddonCloudService;
use app\service\core\addon\CoreAddonInstallService; use app\service\core\addon\CoreAddonInstallService;
use app\service\core\addon\CoreAddonService; use app\service\core\addon\CoreAddonService;
use app\service\core\addon\CoreDependService; use app\service\core\addon\CoreDependService;
use app\service\core\addon\WapTrait; use app\service\core\addon\WapTrait;
use app\service\core\channel\CoreH5Service;
use app\service\core\menu\CoreMenuService; use app\service\core\menu\CoreMenuService;
use app\service\core\niucloud\CoreModuleService; use app\service\core\niucloud\CoreModuleService;
use app\service\core\schedule\CoreScheduleInstallService; use app\service\core\schedule\CoreScheduleInstallService;
@ -403,6 +405,10 @@ class UpgradeService extends BaseAdminService
} }
} }
} }
$map = (new ConfigService())->getMap();
( new CoreH5Service() )->mapKeyChange($map[ 'key' ]);
return true; return true;
} }

View File

@ -11,6 +11,7 @@
namespace app\service\admin\upload; namespace app\service\admin\upload;
use app\dict\common\CommonDict;
use app\dict\sys\FileDict; use app\dict\sys\FileDict;
use app\dict\sys\StorageDict; use app\dict\sys\StorageDict;
use app\service\core\upload\CoreStorageService; use app\service\core\upload\CoreStorageService;
@ -37,7 +38,27 @@ class StorageConfigService extends BaseAdminService
*/ */
public function getStorageList() public function getStorageList()
{ {
return (new CoreStorageService())->getStorageList(); $config_type = (new CoreStorageService())->getStorageConfig();
$storage_type_list = StorageDict::getType();
$list = [];
foreach ($storage_type_list as $k => $v) {
$data = [];
$data['storage_type'] = $k;
$data['is_use'] = $k == $config_type['default'] ? StorageDict::ON : StorageDict::OFF;
$data['name'] = $v['name'];
$data['component'] = $v['component'];
foreach ($v['params'] as $k_param => $v_param) {
$value = $config_type[$k][$k_param] ?? '';
$encrypt_params = $v['encrypt_params'] ?? [];
if ($value !== '' && in_array($k_param, $encrypt_params)) $value = CommonDict::ENCRYPT_STR;
$data['params'][$k_param] = [
'name' => $v_param,
'value' => $value
];
}
$list[] = $data;
}
return $list;
} }
/** /**
@ -63,9 +84,12 @@ class StorageConfigService extends BaseAdminService
]; ];
foreach ($storage_type_list[$storage_type]['params'] as $k_param => $v_param) foreach ($storage_type_list[$storage_type]['params'] as $k_param => $v_param)
{ {
$value = $config_type[$storage_type][$k_param] ?? '';
$encrypt_params = $storage_type_list[$storage_type]['encrypt_params'] ?? [];
if ($value !== '' && in_array($k_param, $encrypt_params)) $value = CommonDict::ENCRYPT_STR;
$data['params'][$k_param] = [ $data['params'][$k_param] = [
'name' => $v_param, 'name' => $v_param,
'value' => $config_type[$storage_type][$k_param] ?? '' 'value' => $value
]; ];
} }
return $data; return $data;
@ -100,14 +124,15 @@ class StorageConfigService extends BaseAdminService
if($data['is_use']) if($data['is_use'])
{ {
$config['default'] = $storage_type; $config['default'] = $storage_type;
}else{ }else if ($config['default'] == $storage_type) {
$config['default'] = ''; $config['default'] = '';
} }
foreach ($storage_type_list[$storage_type]['params'] as $k_param => $v_param) foreach ($storage_type_list[$storage_type]['params'] as $k_param => $v_param)
{ {
$config[$storage_type][$k_param] = $data[$k_param] ?? ''; $value = $data[$k_param] ?? '';
if ($value == CommonDict::ENCRYPT_STR) $value = isset($config[$storage_type]) ? ($config[$storage_type][$k_param] ?? '') : '';
$config[$storage_type][$k_param] = $value;
} }
return (new CoreConfigService())->setConfig('STORAGE', $config); return (new CoreConfigService())->setConfig('STORAGE', $config);
} }

View File

@ -11,6 +11,7 @@
namespace app\service\admin\weapp; namespace app\service\admin\weapp;
use app\dict\common\CommonDict;
use app\model\sys\SysConfig; use app\model\sys\SysConfig;
use app\service\core\weapp\CoreWeappConfigService; use app\service\core\weapp\CoreWeappConfigService;
use core\base\BaseAdminService; use core\base\BaseAdminService;
@ -30,6 +31,11 @@ class WeappConfigService extends BaseAdminService
public function getWeappConfig() public function getWeappConfig()
{ {
$config_info = (new CoreWeappConfigService())->getWeappConfig(); $config_info = (new CoreWeappConfigService())->getWeappConfig();
foreach ($config_info as $k => $v) {
if ($v !== '' && in_array($k, ['app_secret', 'encoding_aes_key'])) {
$config_info[$k] = CommonDict::ENCRYPT_STR;
}
}
return array_merge($config_info, $this->getWeappStaticInfo()); return array_merge($config_info, $this->getWeappStaticInfo());
} }
@ -40,6 +46,12 @@ class WeappConfigService extends BaseAdminService
* @return SysConfig|bool|Model * @return SysConfig|bool|Model
*/ */
public function setWeappConfig(array $data){ public function setWeappConfig(array $data){
$config = (new CoreWeappConfigService())->getWeappConfig();
foreach ($data as $k => $v) {
if ($v == CommonDict::ENCRYPT_STR) {
$data[$k] = $config[$k];
}
}
return (new CoreWeappConfigService())->setWeappConfig($data); return (new CoreWeappConfigService())->setWeappConfig($data);
} }
@ -49,6 +61,7 @@ class WeappConfigService extends BaseAdminService
*/ */
public function getWeappStaticInfo(){ public function getWeappStaticInfo(){
$domain = request()->domain(); $domain = request()->domain();
$domain = str_replace('http://', 'https://', $domain);
return [ return [
'serve_url' => (string)url('/api/weapp/serve', [],'',true), 'serve_url' => (string)url('/api/weapp/serve', [],'',true),
'request_url' => $domain, 'request_url' => $domain,

View File

@ -11,6 +11,7 @@
namespace app\service\admin\wechat; namespace app\service\admin\wechat;
use app\dict\common\CommonDict;
use app\model\sys\SysConfig; use app\model\sys\SysConfig;
use app\service\core\wechat\CoreWechatConfigService; use app\service\core\wechat\CoreWechatConfigService;
use core\base\BaseAdminService; use core\base\BaseAdminService;
@ -29,7 +30,13 @@ class WechatConfigService extends BaseAdminService
*/ */
public function getWechatConfig() public function getWechatConfig()
{ {
return (new CoreWechatConfigService())->getWechatConfig(); $config_info = (new CoreWechatConfigService())->getWechatConfig();
foreach ($config_info as $k => $v) {
if ($v !== '' && in_array($k, ['app_secret', 'encoding_aes_key'])) {
$config_info[$k] = CommonDict::ENCRYPT_STR;
}
}
return $config_info;
} }
/** /**
@ -38,6 +45,12 @@ class WechatConfigService extends BaseAdminService
* @return SysConfig|bool|Model * @return SysConfig|bool|Model
*/ */
public function setWechatConfig(array $data){ public function setWechatConfig(array $data){
$config = (new CoreWechatConfigService())->getWechatConfig();
foreach ($data as $k => $v) {
if ($v == CommonDict::ENCRYPT_STR) {
$data[$k] = $config[$k];
}
}
return (new CoreWechatConfigService())->setWechatConfig($data); return (new CoreWechatConfigService())->setWechatConfig($data);
} }

View File

@ -33,6 +33,15 @@ class DiyConfigService extends BaseApiService
$list = ( new CoreDiyConfigService() )->getBottomList($params); $list = ( new CoreDiyConfigService() )->getBottomList($params);
$apps = ( new CoreAddonService() )->getList([ [ 'type', '=', 'app' ] ]); $apps = ( new CoreAddonService() )->getList([ [ 'type', '=', 'app' ] ]);
$bottom_list_keys = array_column($list, 'key');
// 排除没有底部导航的应用
foreach ($apps as $k => $v) {
if (!in_array($v[ 'key' ], $bottom_list_keys)) {
unset($apps[ $k ]);
}
}
$apps = array_values($apps);
// 单应用,排除 系统 底部导航设置 // 单应用,排除 系统 底部导航设置
if (count($list) > 1 && count($apps) == 1) { if (count($list) > 1 && count($apps) == 1) {
@ -62,6 +71,16 @@ class DiyConfigService extends BaseApiService
// 检测当前站点是多应用还是单应用 // 检测当前站点是多应用还是单应用
if ($key == 'app') { if ($key == 'app') {
$apps = ( new CoreAddonService() )->getList([ [ 'type', '=', 'app' ] ]); $apps = ( new CoreAddonService() )->getList([ [ 'type', '=', 'app' ] ]);
$list = ( new CoreDiyConfigService() )->getBottomList();
$bottom_list_keys = array_column($list, 'key');
// 排除没有底部导航的应用
foreach ($apps as $k => $v) {
if (!in_array($v[ 'key' ], $bottom_list_keys)) {
unset($apps[ $k ]);
}
}
$apps = array_values($apps);
if (count($apps) == 1) { if (count($apps) == 1) {
$key = $apps[ 0 ][ 'key' ]; $key = $apps[ 0 ][ 'key' ];
} }

View File

@ -24,8 +24,8 @@ use core\exception\AuthException;
/** /**
* 登录服务层 * 登录服务层
* Class BaseService * Class AuthService
* @package app\service * @package app\service\api\login
*/ */
class AuthService extends BaseApiService class AuthService extends BaseApiService
{ {
@ -74,7 +74,7 @@ class AuthService extends BaseApiService
* 绑定手机号 * 绑定手机号
* @param string $mobile * @param string $mobile
* @param string $mobile_code * @param string $mobile_code
* @return true * @return array
*/ */
public function bindMobile(string $mobile, string $mobile_code) public function bindMobile(string $mobile, string $mobile_code)
{ {
@ -104,8 +104,9 @@ class AuthService extends BaseApiService
$member->save([ $member->save([
'mobile' => $mobile 'mobile' => $mobile
]); ]);
return true; return [
'mobile' => $mobile
];
} }
} }

View File

@ -35,7 +35,7 @@ class AddressService extends BaseApiService
*/ */
public function getList(array $where = []) public function getList(array $where = [])
{ {
$field = 'id,member_id,name,mobile,address,address_name,full_address,is_default,lng,lat'; $field = 'id, member_id, name, mobile, province_id, city_id, district_id, address, address_name, full_address, lng, lat, is_default';
$order = 'is_default desc, id desc'; $order = 'is_default desc, id desc';
$list = $this->model->where([ ['member_id', '=', $this->member_id ] ])->field($field)->order($order)->select()->toArray(); $list = $this->model->where([ ['member_id', '=', $this->member_id ] ])->field($field)->order($order)->select()->toArray();

View File

@ -100,13 +100,14 @@ class WeappAuthService extends BaseApiService
} }
if ($member_info->isEmpty()) { if ($member_info->isEmpty()) {
$config = ( new MemberConfigService() )->getLoginConfig(); $config = ( new MemberConfigService() )->getLoginConfig();
$is_auth_register = $config[ 'is_auth_register' ]; // $is_auth_register = $config[ 'is_auth_register' ];
// 去掉强制绑定手机号判断,否则开启强制绑定的情况下小程序第三方注册无法注册 // 去掉强制绑定手机号判断,否则开启强制绑定的情况下小程序第三方注册无法注册
if ($is_auth_register == 1) { // 现在不需要控制自动注册,分为两种情况,一种自动注册,另一种手动点击授权登录注册
return $this->register($openid, wx_unionid: $unionid); return $this->register($openid, wx_unionid: $unionid);
} else { // if ($is_auth_register == 1) {
return [ 'openid' => $openid, 'unionid' => $unionid ]; // } else {
} // return [ 'openid' => $openid, 'unionid' => $unionid ];
// }
} else { } else {
//可能会更新用户和粉丝表 //可能会更新用户和粉丝表
$login_service = new LoginService(); $login_service = new LoginService();

View File

@ -79,6 +79,8 @@ class WechatAuthService extends BaseApiService
} }
$unionid = $userinfo->getRaw()[ 'unionid' ] ?? ''; $unionid = $userinfo->getRaw()[ 'unionid' ] ?? '';
if (empty($openid)) throw new ApiException('WECHAT_EMPOWER_NOT_EXIST'); if (empty($openid)) throw new ApiException('WECHAT_EMPOWER_NOT_EXIST');
$is_snapshotuser = $userinfo->getRaw()[ 'is_snapshotuser' ] ?? 0;
if ($is_snapshotuser == 1) throw new ApiException('WECHAT_SNAPSHOUTUSER');
//todo 这儿还可能会获取用户昵称 头像 性别 ....用以更新会员信息 //todo 这儿还可能会获取用户昵称 头像 性别 ....用以更新会员信息
return [ $avatar ?? '', $nickname ?? '', $openid, $unionid ]; return [ $avatar ?? '', $nickname ?? '', $openid, $unionid ];
//todo 业务落地 //todo 业务落地
@ -121,13 +123,14 @@ class WechatAuthService extends BaseApiService
} }
if ($member_info->isEmpty()) { if ($member_info->isEmpty()) {
$config = ( new MemberConfigService() )->getLoginConfig(); $config = ( new MemberConfigService() )->getLoginConfig();
$is_auth_register = $config[ 'is_auth_register' ]; // $is_auth_register = $config[ 'is_auth_register' ];
// 去掉强制绑定手机号判断,否则开启强制绑定的情况下公众号第三方注册无法注册 // 去掉强制绑定手机号判断,否则开启强制绑定的情况下公众号第三方注册无法注册
if ($is_auth_register == 1) { // 现在不需要控制自动注册,分为两种情况,一种自动注册,另一种手动点击授权登录注册
return $this->register($openid, '', $nickname, $avatar, $unionid); return $this->register($openid, '', $nickname, $avatar, $unionid);
} else { // if ($is_auth_register == 1) {
return [ 'avatar' => $avatar, 'nickname' => $nickname, 'openid' => $openid, 'unionid' => $unionid ]; // } else {
} // return [ 'avatar' => $avatar, 'nickname' => $nickname, 'openid' => $openid, 'unionid' => $unionid ];
// }
} else { } else {
//可能会更新用户和粉丝表 //可能会更新用户和粉丝表
$login_service = new LoginService(); $login_service = new LoginService();

View File

@ -307,6 +307,7 @@ class CoreAddonDevelopService extends CoreAddonBaseService
{ {
$data['key'] = $this->key; $data['key'] = $this->key;
$this->addon_info = $data; $this->addon_info = $data;
$this->addon_info['support_version'] = config('version.version');
} }
/** /**

View File

@ -162,6 +162,20 @@ class CoreAddonInstallService extends CoreAddonBaseService
$install_data = $this->getAddonConfig($this->addon); $install_data = $this->getAddonConfig($this->addon);
if (empty($install_data)) throw new AddonException('ADDON_INFO_FILE_NOT_EXIST'); if (empty($install_data)) throw new AddonException('ADDON_INFO_FILE_NOT_EXIST');
$framework_version = config('version.version');
$framework_version_arr = explode('.', $framework_version);
// 检测框架版本是否支持
if (!isset($install_data['support_version']) || empty($install_data['support_version']))
throw new AddonException('您要安装的插件或应用的info.json文件中未检测到匹配框架当前版本['. $framework_version_arr[0].'.'.$framework_version_arr[1] .'.*]的信息无法安装,<a style="text-decoration: underline;" href="https://www.kancloud.cn/niucloud/niucloud-admin-develop/3244512" target="blank">点击查看相关手册</a>');
$support_framework_arr = explode('.', $install_data['support_version']);
if ($framework_version_arr[0].$framework_version_arr[1] != $support_framework_arr[0].$support_framework_arr[1]) {
if ((float) "$support_framework_arr[0].$support_framework_arr[1]" < (float) "$framework_version_arr[0].$framework_version_arr[1]") {
throw new AddonException('您要安装的插件或应用的info.json文件中检测到支持的框架版本['. $install_data['support_version'] .']低于当前框架版本['. $framework_version_arr[0].'.'.$framework_version_arr[1] .'.*]无法安装,<a style="text-decoration: underline;" href="https://www.kancloud.cn/niucloud/niucloud-admin-develop/3244512" target="blank">点击查看相关手册</a>');
}
}
$check_res = Cache::get($this->cache_key . '_install_check'); $check_res = Cache::get($this->cache_key . '_install_check');
if (!$check_res) throw new CommonException('INSTALL_CHECK_NOT_PASS'); if (!$check_res) throw new CommonException('INSTALL_CHECK_NOT_PASS');

View File

@ -6,5 +6,6 @@
"author": "{author}", "author": "{author}",
"type": "{type}", "type": "{type}",
"support_app": "{support_app}", "support_app": "{support_app}",
"compile":[] "compile":[],
"support_version": "{support_version}"
} }

View File

@ -13,11 +13,9 @@ namespace app\service\core\member;
use app\dict\pay\TransferDict; use app\dict\pay\TransferDict;
use app\dict\sys\ConfigKeyDict; use app\dict\sys\ConfigKeyDict;
use app\model\sys\SysConfig;
use app\service\core\sys\CoreConfigService; use app\service\core\sys\CoreConfigService;
use core\base\BaseCoreService; use core\base\BaseCoreService;
use core\exception\CommonException; use core\exception\CommonException;
use think\Model;
/** /**
* 会员相关设置 * 会员相关设置
@ -38,7 +36,9 @@ class CoreMemberConfigService extends BaseCoreService
'is_mobile' => $info[ 'is_mobile' ] ?? 0, // 是否手机验证码登录 'is_mobile' => $info[ 'is_mobile' ] ?? 0, // 是否手机验证码登录
'is_auth_register' => $info[ 'is_auth_register' ] ?? 1, // 是否第三方自动注册 'is_auth_register' => $info[ 'is_auth_register' ] ?? 1, // 是否第三方自动注册
'is_bind_mobile' => $info[ 'is_bind_mobile' ] ?? 0, // 是否强制绑定手机 'is_bind_mobile' => $info[ 'is_bind_mobile' ] ?? 0, // 是否强制绑定手机
'agreement_show' => $info[ 'agreement_show' ] ?? 0 // 政策协议是否展示 'agreement_show' => $info[ 'agreement_show' ] ?? 0, // 政策协议是否展示
'bg_url' => $info[ 'bg_url' ] ?? '', // 背景图片
'desc' => $info[ 'desc' ] ?? '精选好物,购物优惠的省钱平台' // 描述
]; ];
} }
@ -54,7 +54,9 @@ class CoreMemberConfigService extends BaseCoreService
'is_mobile' => $data[ 'is_mobile' ] ?? 0,//是否手机验证码登录 'is_mobile' => $data[ 'is_mobile' ] ?? 0,//是否手机验证码登录
'is_auth_register' => $data[ 'is_auth_register' ] ?? 1,//是否第三方自动注册 'is_auth_register' => $data[ 'is_auth_register' ] ?? 1,//是否第三方自动注册
'is_bind_mobile' => $data[ 'is_bind_mobile' ] ?? 0,//是否强制绑定手机 'is_bind_mobile' => $data[ 'is_bind_mobile' ] ?? 0,//是否强制绑定手机
'agreement_show' => $data[ 'agreement_show' ] ?? 0 // 政策协议是否展示 'agreement_show' => $data[ 'agreement_show' ] ?? 0, // 政策协议是否展示
'bg_url' => $data[ 'bg_url' ] ?? '', // 背景图片
'desc' => $data[ 'desc' ] ?? '' // 描述
]; ];
( new CoreConfigService() )->setConfig('LOGIN', $config); ( new CoreConfigService() )->setConfig('LOGIN', $config);
return true; return true;

View File

@ -25,7 +25,6 @@ class CoreScheduleInstallService extends BaseCoreService
{ {
parent::__construct(); parent::__construct();
$this->model = new SysSchedule(); $this->model = new SysSchedule();
} }
/** /**
@ -61,6 +60,7 @@ class CoreScheduleInstallService extends BaseCoreService
$this->model->where([['addon', '=', $addon]])->delete(); $this->model->where([['addon', '=', $addon]])->delete();
return true; return true;
} }
/** /**
* 安装计划任务 * 安装计划任务
* @param array $data * @param array $data
@ -70,6 +70,8 @@ class CoreScheduleInstallService extends BaseCoreService
public function install(array $data, string $addon = ''){ public function install(array $data, string $addon = ''){
$schedule_list = []; $schedule_list = [];
foreach($data as $v){ foreach($data as $v){
$isExist = $this->model->where([["key", "=", $v['key']], ['addon', '=', $addon]])->count();
if (!$isExist) {
$schedule_list[] = array( $schedule_list[] = array(
'key' => $v['key'], 'key' => $v['key'],
'status' => ScheduleDict::ON, 'status' => ScheduleDict::ON,
@ -77,7 +79,8 @@ class CoreScheduleInstallService extends BaseCoreService
'addon' => $addon 'addon' => $addon
); );
} }
$this->model->replace()->insertAll($schedule_list); }
if (!empty($schedule_list)) $this->model->replace()->insertAll($schedule_list);
return true; return true;
} }

View File

@ -0,0 +1,54 @@
<?php
// +----------------------------------------------------------------------
// | Niucloud-admin 企业快速开发的多应用管理平台
// +----------------------------------------------------------------------
// | 官方网址https://www.niucloud.com
// +----------------------------------------------------------------------
// | niucloud团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace app\service\core\schedule;
use app\model\sys\SysScheduleLog;
use core\base\BaseCoreService;
/**
* 计划任务执行记录服务层
*/
class CoreScheduleLogService extends BaseCoreService
{
public function __construct()
{
parent::__construct();
$this->model = new SysScheduleLog();
}
/**
* 计划任务执行记录分页列表
* @param array $where
* @return array
*/
public function getPage(array $where = [])
{
$field = 'id, addon, key, name, status, execute_time, execute_result, class, job';
$search_model = $this->model->withSearch(['schedule_id', 'key', 'status', 'execute_time'],$where)->field($field)->order('id desc')->append(['status_name']);
return $this->pageQuery($search_model);
}
/**
* 添加计划任务执行记录
* @param array $data
* @return true
*/
public function add(array $data)
{
$data[ 'execute_time' ] = time();
$this->model->create($data);
return true;
}
}

View File

@ -11,11 +11,13 @@
namespace app\service\core\schedule; namespace app\service\core\schedule;
use app\dict\schedule\ScheduleLogDict;
use app\dict\sys\DateDict; use app\dict\sys\DateDict;
use app\model\sys\SysSchedule; use app\model\sys\SysSchedule;
use core\base\BaseCoreService; use core\base\BaseCoreService;
use core\dict\DictLoader; use core\dict\DictLoader;
use core\exception\CommonException; use core\exception\CommonException;
use think\console\Output;
use think\Container; use think\Container;
use think\db\exception\DataNotFoundException; use think\db\exception\DataNotFoundException;
use think\db\exception\DbException; use think\db\exception\DbException;
@ -201,6 +203,20 @@ class CoreScheduleService extends BaseCoreService
return $this->model->where([ [ 'id', '=', $id ]])->delete(); return $this->model->where([ [ 'id', '=', $id ]])->delete();
} }
/**
* 执行一次计划任务
* @return bool
*/
public function doSchedule(int $id)
{
$info = $this->getInfo($id);
$result = false;
if (!empty($info[ 'class' ])) {
$result = $this->execute($info, '');
}
return $result;
}
/** /**
* 执行任务 * 执行任务
* @param array $schedule * @param array $schedule
@ -215,7 +231,11 @@ class CoreScheduleService extends BaseCoreService
try { try {
$result = Container::getInstance()->invoke([$class, $function ?? 'doJob']); $result = Container::getInstance()->invoke([$class, $function ?? 'doJob']);
if(!empty($output)) $output->writeln('[Schedule]['.date('Y-m-d H:i:s').']'." Processed:" . $job.'('.$name.')'); if(!empty($output)) $output->writeln('[Schedule]['.date('Y-m-d H:i:s').']'." Processed:" . $job.'('.$name.')');
$status = ScheduleLogDict::SUCCESS;
if ($result == 1) $result = '计划任务:'.$name.'执行成功';
}catch( Throwable $e){ }catch( Throwable $e){
$result = '计划任务:'.$name.'发生错误, 错误原因_' . $e->getMessage() . '_' . $e->getFile() . '_' . $e->getLine();
$status = ScheduleLogDict::ERROR;
$error = $e->getMessage(); $error = $e->getMessage();
if(!empty($output)) $output->writeln('[Schedule]['.date('Y-m-d H:i:s').']'." Error:" . $job.'('.$name.') ,'.$error); if(!empty($output)) $output->writeln('[Schedule]['.date('Y-m-d H:i:s').']'." Error:" . $job.'('.$name.') ,'.$error);
Log::write('计划任务:'.$name.'发生错误, 错误原因:'.$error); Log::write('计划任务:'.$name.'发生错误, 错误原因:'.$error);
@ -227,6 +247,20 @@ class CoreScheduleService extends BaseCoreService
'count' => $schedule['count'] + 1, 'count' => $schedule['count'] + 1,
]); ]);
} }
//记录执行日志
$core_schedule_log_service = new CoreScheduleLogService();
$core_schedule_log_service->add([
'schedule_id' => $schedule['id'],
'addon' => $schedule['addon'],
'key' => $schedule['key'],
'name' => $name,
'status' => $status,
'execute_result' => $result ?? '',
'class' => $class,
'job' => $job
]);
return true; return true;
} }
} }

View File

@ -34,10 +34,13 @@ class CoreSysConfigService extends BaseCoreService
{ {
$wap_domain = !empty(env("system.wap_domain")) ? preg_replace('#/$#', '', env("system.wap_domain")) : request()->domain(); $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(); $web_domain = !empty(env("system.web_domain")) ? preg_replace('#/$#', '', env("system.web_domain")) : request()->domain();
$service_domain = request()->domain();
return [ return [
'wap_domain' => $wap_domain,
'wap_url' => $wap_domain . "/wap", 'wap_url' => $wap_domain . "/wap",
'web_url' => $web_domain . "/web" 'web_url' => $web_domain . "/web",
'service_domain' => $service_domain
]; ];
} }

View File

@ -74,9 +74,11 @@ class CoreWechatConfigService extends BaseCoreService
*/ */
public function getWechatStaticInfo() public function getWechatStaticInfo()
{ {
$wap_domain = ( new CoreSysConfigService() )->getSceneDomain()[ 'wap_url' ] ?? ''; $wap_domain = ( new CoreSysConfigService() )->getSceneDomain()[ 'wap_domain' ] ?? '';
$wap_domain = str_replace('http://', '', $wap_domain);
$wap_domain = str_replace('https://', '', $wap_domain);
return [ return [
'serve_url' => (string) url('/api/wechat/serve/', [], '', true), 'serve_url' => (string) url('/api/wechat/serve', [], '', true),
'business_domain' => $wap_domain, 'business_domain' => $wap_domain,
'js_secure_domain' => $wap_domain, 'js_secure_domain' => $wap_domain,
'web_auth_domain' => $wap_domain, 'web_auth_domain' => $wap_domain,

View File

@ -38,13 +38,11 @@ class CoreWechatFansService extends BaseCoreService
*/ */
public function add(array $data) public function add(array $data)
{ {
$fans = $this->model->create($data); $fans = $this->model->create($data);
return $fans->fans_id; return $fans->fans_id;
} }
public function find($where)
public function find(array|string $where)
{ {
return $this->model->where($where)->findOrEmpty(); return $this->model->where($where)->findOrEmpty();
} }

View File

@ -40,12 +40,12 @@ class CoreWechatMessageService extends BaseCoreService
switch ($message['MsgType']) { switch ($message['MsgType']) {
case WechatDict::MESSAGE_TYPE_EVENT: case WechatDict::MESSAGE_TYPE_EVENT:
return $this->event($message); return $this->event($message);
return '收到事件消息'; // return '收到事件消息';
break; break;
case WechatDict::MESSAGE_TYPE_TEXT: case WechatDict::MESSAGE_TYPE_TEXT:
//调用文本回复 //调用文本回复
return $this->text($message); return $this->text($message);
return '收到文字消息'; // return '收到文字消息';
break; break;
case WechatDict::MESSAGE_TYPE_IMAGE: case WechatDict::MESSAGE_TYPE_IMAGE:
return '收到图片消息'; return '收到图片消息';

View File

@ -12,6 +12,7 @@
namespace app\service\core\wechat; namespace app\service\core\wechat;
use core\base\BaseCoreService; use core\base\BaseCoreService;
use core\exception\CommonException;
use EasyWeChat\Kernel\Exceptions\BadRequestException; use EasyWeChat\Kernel\Exceptions\BadRequestException;
use EasyWeChat\Kernel\Exceptions\InvalidArgumentException; use EasyWeChat\Kernel\Exceptions\InvalidArgumentException;
use EasyWeChat\Kernel\Exceptions\InvalidConfigException; use EasyWeChat\Kernel\Exceptions\InvalidConfigException;
@ -47,8 +48,12 @@ class CoreWechatServeService extends BaseCoreService
*/ */
public function userFromCode(string $code) public function userFromCode(string $code)
{ {
try {
$oauth = CoreWechatService::app()->getOauth(); $oauth = CoreWechatService::app()->getOauth();
return $oauth->userFromCode($code); return $oauth->userFromCode($code);
} catch (\Exception $e) {
throw new CommonException($e->getCode());
}
} }
public function getUser($user) public function getUser($user)

View File

@ -0,0 +1,15 @@
DROP TABLE IF EXISTS `sys_schedule_log`;
CREATE TABLE `sys_schedule_log` (
`id` int NOT NULL AUTO_INCREMENT COMMENT '执行记录id',
`schedule_id` int NOT NULL DEFAULT 0 COMMENT '任务id',
`addon` varchar(255) NOT NULL DEFAULT '' COMMENT '所属插件',
`key` varchar(255) NOT NULL DEFAULT '' COMMENT '计划任务模板key',
`name` varchar(50) NOT NULL DEFAULT '' COMMENT '计划任务名称',
`execute_time` int NOT NULL COMMENT '执行时间',
`execute_result` text DEFAULT NULL COMMENT '日志信息',
`status` varchar(255) NOT NULL DEFAULT '' COMMENT '执行状态',
`class` varchar(255) NOT NULL DEFAULT '',
`job` varchar(255) NOT NULL DEFAULT '',
PRIMARY KEY (`id`)
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '计划任务执行记录' ROW_FORMAT = Dynamic;

View File

@ -12,7 +12,6 @@
namespace app\validate\member; namespace app\validate\member;
use core\base\BaseValidate; use core\base\BaseValidate;
/** /**
* 会员收货地址验证器 * 会员收货地址验证器
* Class Address * Class Address

View File

@ -1,6 +1,6 @@
<?php <?php
return [ return [
'version' => '1.4.0', 'version' => '1.4.1',
'code' => '202408060001' 'code' => '202409270001'
]; ];

View File

@ -12,7 +12,6 @@ class AddonException extends RuntimeException
{ {
public function __construct($message = "", $code = 0, Throwable $previous = null) public function __construct($message = "", $code = 0, Throwable $previous = null)
{ {
parent::__construct($message, $code, $previous); parent::__construct($message, $code, $previous);
} }
} }

View File

@ -12,7 +12,6 @@ class AdminException extends RuntimeException
{ {
public function __construct($message = "", $code = 0, Throwable $previous = null) public function __construct($message = "", $code = 0, Throwable $previous = null)
{ {
parent::__construct($message, $code, $previous); parent::__construct($message, $code, $previous);
} }
} }

View File

@ -5,11 +5,13 @@ namespace core\pay;
use app\dict\pay\OnlinePayDict; use app\dict\pay\OnlinePayDict;
use app\dict\pay\RefundDict; use app\dict\pay\RefundDict;
use app\dict\pay\TransferDict; use app\dict\pay\TransferDict;
use core\exception\CommonException;
use core\exception\PayException; use core\exception\PayException;
use Psr\Http\Message\MessageInterface; use Psr\Http\Message\MessageInterface;
use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ResponseInterface;
use think\Response; use think\Response;
use Throwable; use Throwable;
use Yansongda\Artful\Exception\InvalidResponseException;
use Yansongda\Pay\Exception\ContainerException; use Yansongda\Pay\Exception\ContainerException;
use Yansongda\Pay\Exception\InvalidParamsException; use Yansongda\Pay\Exception\InvalidParamsException;
use Yansongda\Pay\Exception\ServiceNotFoundException; use Yansongda\Pay\Exception\ServiceNotFoundException;
@ -48,6 +50,7 @@ class Wechatpay extends BasePay
*/ */
public function mp(array $params) public function mp(array $params)
{ {
try {
$result = $this->returnFormat(Pay::wechat()->mp([ $result = $this->returnFormat(Pay::wechat()->mp([
'out_trade_no' => $params['out_trade_no'], 'out_trade_no' => $params['out_trade_no'],
'description' => $params['body'], 'description' => $params['body'],
@ -62,8 +65,13 @@ class Wechatpay extends BasePay
if ($code == 0) return $result; if ($code == 0) return $result;
//支付错误抛出 //支付错误抛出
throw new PayException($result['message']); throw new PayException($result['message']);
} catch (\Exception $e) {
if ($e instanceof InvalidResponseException) {
throw new PayException($e->response->all()['message'] ?? '');
}
throw new PayException($e->getMessage());
}
} }
/** /**
* 手机网页支付 * 手机网页支付
@ -72,6 +80,7 @@ class Wechatpay extends BasePay
*/ */
public function wap(array $params) public function wap(array $params)
{ {
try {
$order = [ $order = [
'out_trade_no' => $params['out_trade_no'], 'out_trade_no' => $params['out_trade_no'],
'description' => $params['body'], 'description' => $params['body'],
@ -90,6 +99,12 @@ class Wechatpay extends BasePay
$order['_type'] = 'mini'; // 注意这一行 $order['_type'] = 'mini'; // 注意这一行
} }
return $this->returnFormat(Pay::wechat()->h5($order)); return $this->returnFormat(Pay::wechat()->h5($order));
} catch (\Exception $e) {
if ($e instanceof InvalidResponseException) {
throw new PayException($e->response->all()['message'] ?? '');
}
throw new PayException($e->getMessage());
}
} }
public function web(array $params) public function web(array $params)
@ -104,6 +119,7 @@ class Wechatpay extends BasePay
*/ */
public function app(array $params) public function app(array $params)
{ {
try {
return $this->returnFormat(Pay::wechat()->app([ return $this->returnFormat(Pay::wechat()->app([
'out_trade_no' => $params['out_trade_no'], 'out_trade_no' => $params['out_trade_no'],
'description' => $params['body'], 'description' => $params['body'],
@ -111,6 +127,12 @@ class Wechatpay extends BasePay
'total' => $params['money'], 'total' => $params['money'],
], ],
])); ]));
} catch (\Exception $e) {
if ($e instanceof InvalidResponseException) {
throw new PayException($e->response->all()['message'] ?? '');
}
throw new PayException($e->getMessage());
}
} }
/** /**
@ -120,6 +142,7 @@ class Wechatpay extends BasePay
*/ */
public function mini(array $params) public function mini(array $params)
{ {
try {
return $this->returnFormat(Pay::wechat()->mini([ return $this->returnFormat(Pay::wechat()->mini([
'out_trade_no' => $params['out_trade_no'], 'out_trade_no' => $params['out_trade_no'],
'description' => $params['body'], 'description' => $params['body'],
@ -131,6 +154,12 @@ class Wechatpay extends BasePay
'openid' => $params['openid'], 'openid' => $params['openid'],
] ]
])); ]));
} catch (\Exception $e) {
if ($e instanceof InvalidResponseException) {
throw new PayException($e->response->all()['message'] ?? '');
}
throw new PayException($e->getMessage());
}
} }
/** /**
@ -140,6 +169,7 @@ class Wechatpay extends BasePay
*/ */
public function pos(array $params) public function pos(array $params)
{ {
try {
$order = [ $order = [
'out_trade_no' => $params['out_trade_no'], 'out_trade_no' => $params['out_trade_no'],
'body' => $params['body'], 'body' => $params['body'],
@ -149,6 +179,12 @@ class Wechatpay extends BasePay
]; ];
$result = Pay::wechat()->pos($order); $result = Pay::wechat()->pos($order);
return $this->returnFormat($result); return $this->returnFormat($result);
} catch (\Exception $e) {
if ($e instanceof InvalidResponseException) {
throw new PayException($e->response->all()['message'] ?? '');
}
throw new PayException($e->getMessage());
}
} }
/** /**
@ -158,6 +194,7 @@ class Wechatpay extends BasePay
*/ */
public function scan(array $params) public function scan(array $params)
{ {
try {
return $this->returnFormat(Pay::wechat()->scan([ return $this->returnFormat(Pay::wechat()->scan([
'out_trade_no' => $params['out_trade_no'], 'out_trade_no' => $params['out_trade_no'],
'description' => $params['body'], 'description' => $params['body'],
@ -165,6 +202,12 @@ class Wechatpay extends BasePay
'total' => $params['money'], 'total' => $params['money'],
], ],
])); ]));
} catch (\Exception $e) {
if ($e instanceof InvalidResponseException) {
throw new PayException($e->response->all()['message'] ?? '');
}
throw new PayException($e->getMessage());
}
} }
/** /**