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

@ -24,7 +24,7 @@ class Config extends BaseAdminController
*/
public function getLoginConfig()
{
return success((new MemberConfigService())->getLoginConfig());
return success(( new MemberConfigService() )->getLoginConfig());
}
/**
@ -34,14 +34,16 @@ class Config extends BaseAdminController
public function setLoginConfig()
{
$data = $this->request->params([
['is_username', 1],
['is_mobile', 0],
['is_auth_register', 1],
['is_bind_mobile', 0],
['agreement_show', 0]
[ 'is_username', 1 ],
[ 'is_mobile', 0 ],
[ 'is_auth_register', 1 ],
[ 'is_bind_mobile', 0 ],
[ 'agreement_show', 0 ],
[ 'bg_url', '' ],
[ 'desc', '' ]
]);
$this->validate($data, 'app\validate\member\LoginConfig.set');
(new MemberConfigService())->setLoginConfig($data);
( new MemberConfigService() )->setLoginConfig($data);
return success('MODIFY_SUCCESS');
}
@ -51,7 +53,7 @@ class Config extends BaseAdminController
*/
public function getCashOutConfig()
{
return success((new MemberConfigService())->getCashOutConfig());
return success(( new MemberConfigService() )->getCashOutConfig());
}
/**
@ -61,15 +63,15 @@ class Config extends BaseAdminController
public function setCashOutConfig()
{
$data = $this->request->params([
['is_open', 0], //是否开启
['min', 0.01], //最低提现金额
['rate', 0], //提现手续费比率
['is_auto_verify', 0], //是否自动审核
['is_auto_transfer', 0], //是否自动转账
['transfer_type', []] //转账方式
[ 'is_open', 0 ], //是否开启
[ 'min', 0.01 ], //最低提现金额
[ 'rate', 0 ], //提现手续费比率
[ 'is_auto_verify', 0 ], //是否自动审核
[ 'is_auto_transfer', 0 ], //是否自动转账
[ 'transfer_type', [] ] //转账方式
]);
$this->validate($data, 'app\validate\member\CashOutConfig.set');
(new MemberConfigService())->setCashOutConfig($data);
( new MemberConfigService() )->setCashOutConfig($data);
return success('SET_SUCCESS');
}
@ -79,7 +81,7 @@ class Config extends BaseAdminController
*/
public function getMemberConfig()
{
return success((new MemberConfigService())->getMemberConfig());
return success(( new MemberConfigService() )->getMemberConfig());
}
/**
@ -89,11 +91,11 @@ class Config extends BaseAdminController
public function setMemberConfig()
{
$data = $this->request->params([
['prefix', ''],
['length', 10]
[ 'prefix', '' ],
[ 'length', 10 ]
]);
$this->validate($data, 'app\validate\member\MemberConfig.set');
(new MemberConfigService())->setMemberConfig($data);
( new MemberConfigService() )->setMemberConfig($data);
return success('MODIFY_SUCCESS');
}
@ -103,7 +105,7 @@ class Config extends BaseAdminController
*/
public function getGrowthRuleConfig()
{
return success((new MemberConfigService())->getGrowthRuleConfig());
return success(( new MemberConfigService() )->getGrowthRuleConfig());
}
/**
@ -113,12 +115,12 @@ class Config extends BaseAdminController
public function setGrowthRuleConfig()
{
$param = [];
$rules = (new MemberService())->getGrowthRuleDict();
$rules = ( new MemberService() )->getGrowthRuleDict();
foreach ($rules as $key => $item) {
$param[] = [$key, []];
$param[] = [ $key, [] ];
}
$data = $this->request->params($param);
(new MemberConfigService())->setGrowthRuleConfig($data);
( new MemberConfigService() )->setGrowthRuleConfig($data);
return success('MODIFY_SUCCESS');
}
@ -128,7 +130,7 @@ class Config extends BaseAdminController
*/
public function getPointRuleConfig()
{
return success((new MemberConfigService())->getPointRuleConfig());
return success(( new MemberConfigService() )->getPointRuleConfig());
}
/**
@ -138,12 +140,12 @@ class Config extends BaseAdminController
public function setPointRuleConfig()
{
$param = [];
$rules = (new MemberService())->getPointRuleDict();
$rules = ( new MemberService() )->getPointRuleDict();
foreach ($rules as $key => $item) {
$param[] = [$key, []];
$param[] = [ $key, [] ];
}
$data = $this->request->params($param);
(new MemberConfigService())->setPointRuleConfig($data);
( new MemberConfigService() )->setPointRuleConfig($data);
return success('MODIFY_SUCCESS');
}
}

View File

@ -29,7 +29,7 @@ class Schedule extends BaseAdminController
{
$data = $this->request->params([
['key', ''],
['status', ''],
['status', 'all'],
]);
return success(data: (new ScheduleService())->getPage($data));
@ -128,4 +128,19 @@ class Schedule extends BaseAdminController
{
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::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');
@ -101,6 +109,10 @@ Route::group('member', function() {
Route::get('config/point_rule', 'member.Config/getPointRuleConfig');
//设置积分规则
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');
@ -116,18 +128,6 @@ Route::group('member', function() {
Route::get('cash_out/status', 'member.CashOut/getStatusList');
//提现统计信息
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');

View File

@ -186,6 +186,12 @@ Route::group('sys', function() {
Route::get('schedule/template', 'sys.Schedule/template');
//任务时间间隔
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');

View File

@ -16,7 +16,7 @@ use core\base\BaseApiController;
/**
* 协议控制器
* Class Article
* Class Agreement
* @package app\api\controller\agreement
*/
class Agreement extends BaseApiController
@ -25,4 +25,4 @@ class Agreement extends BaseApiController
$res = (new AgreementService())->getAgreement($key);
return success($res);
}
}
}

View File

@ -11,6 +11,9 @@
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 core\base\BaseApiController;
use think\Response;
@ -65,4 +68,20 @@ class Config extends BaseApiController
{
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,18 +42,18 @@ class ApiCheckToken
try {
$token = $request->apiToken();
$token_info = ( new LoginService() )->parseToken($token);
if (!empty($token_info)) {
$request->memberId($token_info[ 'member_id' ]);
}
//校验会员和站点
( new AuthService() )->checkMember($request);
// 校验渠道
( new AuthService() )->checkChannel($request);
} catch (AuthException $e) {
//是否将登录错误抛出
if ($is_throw_exception)
return fail($e->getMessage(), [], $e->getCode());
}
if (!empty($token_info)) {
$request->memberId($token_info[ 'member_id' ]);
}
//校验会员和站点
( new AuthService() )->checkMember($request);
// 校验渠道
( new AuthService() )->checkChannel($request);
return $next($request);
}
}

View File

@ -30,8 +30,8 @@ Route::any('weapp/serve', 'weapp.Serve/serve')
->middleware(ApiLog::class);
Route::group(function() {
Route::post('niucloud/notify', function(){
return (new CoreNotifyService())->notify();
Route::post('niucloud/notify', function() {
return ( new CoreNotifyService() )->notify();
});
});
@ -104,6 +104,9 @@ Route::group(function() {
// 获取地图设置
Route::get('map', 'sys.Config/getMap');
// 获取初始化数据信息
Route::get('init', 'sys.Config/init');
/***************************************************** 地区管理 ****************************************************/
//通过pid获取列表
Route::get('area/list_by_pid/:pid', 'sys.Area/listByPid');

View File

@ -69,10 +69,10 @@ function get_lang($str)
function list_to_tree($list, $pk = 'id', $pid = 'pid', $child = 'child', $root = 0)
{
// 创建Tree
$tree = array ();
$tree = array();
if (is_array($list)) {
// 创建基于主键的数组引用
$refer = array ();
$refer = array();
foreach ($list as $key => $data) {
$refer[ $data[ $pk ] ] =& $list[ $key ];
}
@ -132,7 +132,7 @@ function array_keys_search($array, $keys, $index = '', $is_sort = true)
return [];
if (!empty($index) && count($array) != count($array, COUNT_RECURSIVE))
$array = array_column($array, null, $index);
$list = array ();
$list = array();
foreach ($keys as $key) {
if (isset($array[ $key ])) {
@ -500,7 +500,7 @@ function array_merge2(array $array1, array $array2)
function get_files_by_dir($dir)
{
$dh = @opendir($dir); //打开目录,返回一个目录流
$return = array ();
$return = array();
while ($file = @readdir($dh)) { //循环读取目录下的文件
if ($file != '.' and $file != '..') {
$path = $dir . DIRECTORY_SEPARATOR . $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 ? '...' : '' );
}
/**
* 使用正则表达式匹配特殊字符
* @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 MAN = 1;
public const WOMAN = 2;
public const ENCRYPT_STR = '*****************************';
/**
* 性别
@ -26,4 +26,4 @@ class CommonDict
self::WOMAN => get_lang('dict_sex.woman'),//女
];
}
}
}

View File

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

View File

@ -302,7 +302,7 @@ return [
'router_path' => '',
'view_path' => '',
'methods' => '',
'sort' => '70',
'sort' => '89',
'status' => '1',
'is_show' => '1',
'children' => [
@ -715,7 +715,7 @@ return [
'router_path' => '',
'view_path' => '',
'methods' => '',
'sort' => '60',
'sort' => '88',
'status' => '1',
'is_show' => '1',
'children' => [
@ -801,7 +801,7 @@ return [
'router_path' => 'finance/refund',
'view_path' => 'finance/pay_refund',
'methods' => 'get',
'sort' => '9',
'sort' => '96',
'status' => '1',
'is_show' => '1',
'children' => [
@ -831,7 +831,7 @@ return [
'router_path' => 'finance/refund/detail',
'view_path' => 'finance/refund_detail',
'methods' => 'get',
'sort' => '9',
'sort' => '95',
'status' => '1',
'is_show' => '0',
],
@ -848,7 +848,7 @@ return [
'router_path' => '',
'view_path' => '',
'methods' => '',
'sort' => '56',
'sort' => '87',
'status' => '1',
'is_show' => '1',
'children' => [
@ -1013,7 +1013,7 @@ return [
'router_path' => '',
'view_path' => '',
'methods' => '',
'sort' => '55',
'sort' => '86',
'status' => '1',
'is_show' => '1',
'children' => [
@ -1044,7 +1044,7 @@ return [
'router_path' => '',
'view_path' => '',
'methods' => '',
'sort' => '50',
'sort' => '85',
'status' => '1',
'is_show' => '1',
'children' => [
@ -1517,7 +1517,7 @@ return [
'router_path' => '',
'view_path' => '',
'methods' => '',
'sort' => '40',
'sort' => '84',
'status' => '1',
'is_show' => '1',
'children' => [
@ -1631,7 +1631,7 @@ return [
'router_path' => 'auth/role',
'view_path' => 'auth/role',
'methods' => 'get',
'sort' => '70',
'sort' => '99',
'status' => '1',
'is_show' => '1',
'children' => [
@ -1689,7 +1689,7 @@ return [
'router_path' => 'setting/auth/log',
'view_path' => 'auth/log',
'methods' => 'get',
'sort' => '60',
'sort' => '98',
'status' => '1',
'is_show' => '1',
],
@ -1706,7 +1706,7 @@ return [
'router_path' => '',
'view_path' => '',
'methods' => '',
'sort' => '30',
'sort' => '83',
'status' => '1',
'is_show' => '1',
'children' => [
@ -2333,7 +2333,7 @@ return [
'router_path' => 'setting/export',
'view_path' => 'setting/export',
'methods' => 'get',
'sort' => '97',
'sort' => '98',
'status' => '1',
'is_show' => '1',
'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_key' => 'app_auth',

View File

@ -57,19 +57,22 @@ class PayDict
'name' => get_lang('dict_pay.type_wechatpay'),
'key' => self::WECHATPAY,
'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 => [
'name' => get_lang('dict_pay.type_alipay'),
'key' => self::ALIPAY,
'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 => [
'name' => get_lang('dict_pay.type_balancepay'),
'key' => self::BALANCEPAY,
'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'),//隐私协议
];
$addon_data = event("AgreementType");
Log::write("检测数据");
Log::write($addon_data);
// Log::write("检测数据");
// Log::write($addon_data);
foreach ($addon_data as $k => $v)
{
$data = array_merge($data, $v);

View File

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

View File

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

View File

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

View File

@ -799,6 +799,22 @@ CREATE TABLE `sys_schedule` (
) 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`;
CREATE TABLE `sys_user` (
`uid` smallint(5) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '系统用户ID',

View File

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

View File

@ -46,7 +46,6 @@ return [
'ZIP_FILE_NOT_FOUND' => '找不到可用的压缩文件',
'ZIP_ARCHIVE_NOT_INSTALL' => 'ZipArchive扩展未安装',
'DOWNLOAD_SUCCESS' => '下载成功',
'APP_NOT_ALLOW_UNINSTALL' => '该应用下存在站点卸载前请先删除相关站点',
'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>',
'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' => '当前插件已安装,不能重复安装',
'NOT_UNINSTALL' => '当前插件未安装,不能进行卸载操作',
'ADDON_INFO_FILE_NOT_EXIST' => '未找到插件的info.json文件',
//菜单管理
'MENU_NOT_EXIST' => '菜单不存在',
@ -143,7 +143,7 @@ return [
'MEMBER_IS_EXIST' => '账号已存在',
'MEMBER_NO_IS_EXIST' => '会员编号已存在',
'REG_CHANNEL_NOT_EXIST' => '无效的注册渠道',
'MEMBER_USERNAME_LOGIN_NOT_OPEN' => '未开账号登录注册',
'MEMBER_USERNAME_LOGIN_NOT_OPEN' => '未开账号登录注册',
'AUTH_LOGIN_NOT_OPEN' => '未开启第三方登录注册',
'MOBILE_NEEDED' => '手机号必须填写',
'MOBILE_CAPTCHA_ERROR' => '手机验证码有误',
@ -181,11 +181,12 @@ return [
'KEYWORDS_NOT_EXIST' => '关键词回复不存在',
'WECHAT_EMPOWER_NOT_EXIST' => '微信授权信息不存在',
'SCAN_SUCCESS' => '扫码成功',
'WECHAT_SNAPSHOUTUSER' => '返回的是虚拟账号',
//小程序
'WEAPP_NOT_EXIST' => '微信小程序未配置完善',
'WEAPP_EMPOWER_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' => '微信小程序码生成失败',
//站点相关

View File

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

View File

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

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;
use addon\recharge\app\service\core\CoreRechargeRefundService;
use app\service\core\pay\CoreAccountService;
/**
@ -23,11 +22,5 @@ class RefundSuccessListener
{
//添加账单记录
(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)
{
if ($value) {
if ($value != 'all') {
$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);
$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) {

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>
<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">
<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">
<el-form :model="formData" label-width="120px" ref="formRef" :rules="formRules" class="page-form" v-loading="loading">
{FORM_VIEW}
</el-form>

View File

@ -36,13 +36,12 @@ class MemberSignService extends BaseAdminService
public function getPage(array $where = [])
{
$member_where = [];
if(isset($where['keywords']) && $where['keywords'] != '')
{
$member_where = [['member.member_no|member.nickname|member.mobile', 'like', '%' . $this->model->handelSpecialCharacter($where['keywords']) . '%']];
if (isset($where[ 'keywords' ]) && $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';
$search_model = $this->model->withSearch(['create_time'],$where)->where($member_where)->withJoin(["member" => ['member_no', 'mobile', 'nickname', 'headimg']])->field($field)->append(['is_sign_name'])->order('member_sign.create_time desc');
return $this->pageQuery($search_model, function ($item, $key) {
$search_model = $this->model->withSearch([ 'create_time' ], $where)->where($member_where)->withJoin([ "member" => [ 'member_no', 'mobile', 'nickname', 'headimg' ] ])->field($field)->append([ 'is_sign_name' ])->order('member_sign.create_time desc');
return $this->pageQuery($search_model, function($item, $key) {
$item = $this->makeUp($item);
});
}
@ -51,16 +50,17 @@ class MemberSignService extends BaseAdminService
* 组合整理数据
* @param $data
*/
public function makeUp($data){
public function makeUp($data)
{
//日签奖励
if(!empty($data['day_award'])){
$data['day_award'] = (new CoreMemberService())->getGiftContent($data['day_award']);
if (!empty($data[ 'day_award' ])) {
$data[ 'day_award' ] = ( new CoreMemberService() )->getGiftContent($data[ 'day_award' ]);
}
//连签奖励
if(!empty($data['continue_award'])){
$gift = $data['continue_award'];
unset($gift['continue_sign'], $gift['continue_tag'], $gift['receive_limit'], $gift['receive_num']);
$data['continue_award'] = (new CoreMemberService())->getGiftContent($gift);
if (!empty($data[ 'continue_award' ])) {
$gift = $data[ 'continue_award' ];
unset($gift[ 'continue_sign' ], $gift[ 'continue_tag' ], $gift[ 'receive_limit' ], $gift[ 'receive_num' ]);
$data[ 'continue_award' ] = ( new CoreMemberService() )->getGiftContent($gift);
}
return $data;
}
@ -73,7 +73,7 @@ class MemberSignService extends BaseAdminService
public function getInfo(int $sign_id)
{
$field = 'sign_id, member_id, days, day_award, continue_award, continue_tag, create_time, is_sign';
return $this->model->where([['sign_id', '=', $sign_id]])->field($field)->append(['is_sign_name'])->findOrEmpty()->toArray();
return $this->model->where([ [ 'sign_id', '=', $sign_id ] ])->field($field)->append([ 'is_sign_name' ])->findOrEmpty()->toArray();
}
/**
@ -109,6 +109,9 @@ class MemberSignService extends BaseAdminService
'rule_explain' => ''
];
}
if (empty($info[ 'value' ][ 'continue_award' ]) && gettype($info[ 'value' ][ 'continue_award' ]) == 'string') {
$info[ 'value' ][ 'continue_award' ] = [];
}
return $info[ 'value' ];
}
}

View File

@ -11,11 +11,11 @@
namespace app\service\admin\notice;
use app\dict\common\CommonDict;
use app\dict\sys\SmsDict;
use app\service\core\sys\CoreConfigService;
use core\base\BaseAdminService;
use core\exception\AdminException;
use think\Response;
/**
* 短信配置服务层
@ -49,9 +49,13 @@ class SmsService extends BaseAdminService
$data['name'] = $v['name'];
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] = [
'name' => $v_param,
'value' => $config_type[$k][$k_param] ?? ''
'value' => $value
];
}
$data['component'] = $v['component'] ?? '';
@ -83,9 +87,13 @@ class SmsService extends BaseAdminService
];
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] = [
'name' => $v_param,
'value' => $config_type[$sms_type][$k_param] ?? ''
'value' => $value
];
}
return $data;
@ -119,7 +127,9 @@ class SmsService extends BaseAdminService
}
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);

View File

@ -12,6 +12,7 @@
namespace app\service\admin\pay;
use app\dict\common\ChannelDict;
use app\dict\common\CommonDict;
use app\dict\pay\PayChannelDict;
use app\dict\pay\PayDict;
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');
}
$pay_channel = $this->core_pay_channel_service->find($where);
if ($pay_channel->isEmpty()) {
$data[ 'channel' ] = $channel;
$data[ 'type' ] = $type;
$data[ 'config' ] = $this->getConfigByPayType($data[ 'config' ], $type);
$res = $this->model->create($data);
} else {
$config = $pay_channel->config;
$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);
}
return true;
@ -86,10 +94,21 @@ class PayChannelService extends BaseAdminService
foreach ($pay_channel_list_temp as $v) {
$pay_channel_list[ $v[ 'channel' ] ][ $v[ 'type' ] ] = $v;
}
$pay_type_list = PayDict::getPayType();
foreach ($channel_list as $k => $v) {
$temp_item = $pay_channel_list[ $k ] ?? [];
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[ 'status' ] = $temp_v_item[ 'status' ];
$item_v[ 'sort' ] = $temp_v_item[ 'sort' ];
@ -116,7 +135,17 @@ class PayChannelService extends BaseAdminService
$where = array (
'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(){
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;
use app\job\sys\CheckJob;
use app\service\core\sys\CoreSysConfigService;
use core\base\BaseAdminService;
use think\facade\Db;
use Throwable;
@ -47,14 +48,7 @@ class SystemService extends BaseAdminService
*/
public function getUrl()
{
$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_domain' => env("system.wap_domain"),
'wap_url' => $wap_domain . "/wap",
'web_url' => $web_domain . "/web",
];
return (new CoreSysConfigService())->getSceneDomain();
}
/**

View File

@ -14,11 +14,13 @@ namespace app\service\admin\upgrade;
use app\dict\addon\AddonDict;
use app\model\addon\Addon;
use app\service\admin\install\InstallSystemService;
use app\service\admin\sys\ConfigService;
use app\service\core\addon\CoreAddonCloudService;
use app\service\core\addon\CoreAddonInstallService;
use app\service\core\addon\CoreAddonService;
use app\service\core\addon\CoreDependService;
use app\service\core\addon\WapTrait;
use app\service\core\channel\CoreH5Service;
use app\service\core\menu\CoreMenuService;
use app\service\core\niucloud\CoreModuleService;
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;
}

View File

@ -11,6 +11,7 @@
namespace app\service\admin\upload;
use app\dict\common\CommonDict;
use app\dict\sys\FileDict;
use app\dict\sys\StorageDict;
use app\service\core\upload\CoreStorageService;
@ -37,7 +38,27 @@ class StorageConfigService extends BaseAdminService
*/
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)
{
$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] = [
'name' => $v_param,
'value' => $config_type[$storage_type][$k_param] ?? ''
'value' => $value
];
}
return $data;
@ -100,14 +124,15 @@ class StorageConfigService extends BaseAdminService
if($data['is_use'])
{
$config['default'] = $storage_type;
}else{
}else if ($config['default'] == $storage_type) {
$config['default'] = '';
}
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);
}

View File

@ -11,6 +11,7 @@
namespace app\service\admin\weapp;
use app\dict\common\CommonDict;
use app\model\sys\SysConfig;
use app\service\core\weapp\CoreWeappConfigService;
use core\base\BaseAdminService;
@ -30,6 +31,11 @@ class WeappConfigService extends BaseAdminService
public function 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());
}
@ -40,6 +46,12 @@ class WeappConfigService extends BaseAdminService
* @return SysConfig|bool|Model
*/
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);
}
@ -49,6 +61,7 @@ class WeappConfigService extends BaseAdminService
*/
public function getWeappStaticInfo(){
$domain = request()->domain();
$domain = str_replace('http://', 'https://', $domain);
return [
'serve_url' => (string)url('/api/weapp/serve', [],'',true),
'request_url' => $domain,

View File

@ -11,6 +11,7 @@
namespace app\service\admin\wechat;
use app\dict\common\CommonDict;
use app\model\sys\SysConfig;
use app\service\core\wechat\CoreWechatConfigService;
use core\base\BaseAdminService;
@ -29,7 +30,13 @@ class WechatConfigService extends BaseAdminService
*/
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
*/
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);
}

View File

@ -33,6 +33,15 @@ class DiyConfigService extends BaseApiService
$list = ( new CoreDiyConfigService() )->getBottomList($params);
$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) {
@ -62,6 +71,16 @@ class DiyConfigService extends BaseApiService
// 检测当前站点是多应用还是单应用
if ($key == '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) {
$key = $apps[ 0 ][ 'key' ];
}

View File

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

View File

@ -35,7 +35,7 @@ class AddressService extends BaseApiService
*/
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';
$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()) {
$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);
} else {
return [ 'openid' => $openid, 'unionid' => $unionid ];
}
// 现在不需要控制自动注册,分为两种情况,一种自动注册,另一种手动点击授权登录注册
return $this->register($openid, wx_unionid: $unionid);
// if ($is_auth_register == 1) {
// } else {
// return [ 'openid' => $openid, 'unionid' => $unionid ];
// }
} else {
//可能会更新用户和粉丝表
$login_service = new LoginService();

View File

@ -79,6 +79,8 @@ class WechatAuthService extends BaseApiService
}
$unionid = $userinfo->getRaw()[ 'unionid' ] ?? '';
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 这儿还可能会获取用户昵称 头像 性别 ....用以更新会员信息
return [ $avatar ?? '', $nickname ?? '', $openid, $unionid ];
//todo 业务落地
@ -121,13 +123,14 @@ class WechatAuthService extends BaseApiService
}
if ($member_info->isEmpty()) {
$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);
} else {
return [ 'avatar' => $avatar, 'nickname' => $nickname, 'openid' => $openid, 'unionid' => $unionid ];
}
// 现在不需要控制自动注册,分为两种情况,一种自动注册,另一种手动点击授权登录注册
return $this->register($openid, '', $nickname, $avatar, $unionid);
// if ($is_auth_register == 1) {
// } else {
// return [ 'avatar' => $avatar, 'nickname' => $nickname, 'openid' => $openid, 'unionid' => $unionid ];
// }
} else {
//可能会更新用户和粉丝表
$login_service = new LoginService();

View File

@ -307,6 +307,7 @@ class CoreAddonDevelopService extends CoreAddonBaseService
{
$data['key'] = $this->key;
$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);
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');
if (!$check_res) throw new CommonException('INSTALL_CHECK_NOT_PASS');

View File

@ -6,5 +6,6 @@
"author": "{author}",
"type": "{type}",
"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\sys\ConfigKeyDict;
use app\model\sys\SysConfig;
use app\service\core\sys\CoreConfigService;
use core\base\BaseCoreService;
use core\exception\CommonException;
use think\Model;
/**
* 会员相关设置
@ -34,11 +32,13 @@ class CoreMemberConfigService extends BaseCoreService
{
$info = ( new CoreConfigService() )->getConfig('LOGIN')[ 'value' ] ?? [];
return [
'is_username' => $info[ 'is_username' ] ?? 1,//是否用户名密码登录
'is_mobile' => $info[ 'is_mobile' ] ?? 0,//是否手机验证码登录
'is_auth_register' => $info[ 'is_auth_register' ] ?? 1,//是否第三方自动注册
'is_bind_mobile' => $info[ 'is_bind_mobile' ] ?? 0,//是否强制绑定手机
'agreement_show' => $info[ 'agreement_show' ] ?? 0 // 政策协议是否展示
'is_username' => $info[ 'is_username' ] ?? 1, // 是否用户名密码登录
'is_mobile' => $info[ 'is_mobile' ] ?? 0, // 是否手机验证码登录
'is_auth_register' => $info[ 'is_auth_register' ] ?? 1, // 是否第三方自动注册
'is_bind_mobile' => $info[ 'is_bind_mobile' ] ?? 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_auth_register' => $data[ 'is_auth_register' ] ?? 1,//是否第三方自动注册
'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);
return true;

View File

@ -25,7 +25,6 @@ class CoreScheduleInstallService extends BaseCoreService
{
parent::__construct();
$this->model = new SysSchedule();
}
/**
@ -61,6 +60,7 @@ class CoreScheduleInstallService extends BaseCoreService
$this->model->where([['addon', '=', $addon]])->delete();
return true;
}
/**
* 安装计划任务
* @param array $data
@ -70,14 +70,17 @@ class CoreScheduleInstallService extends BaseCoreService
public function install(array $data, string $addon = ''){
$schedule_list = [];
foreach($data as $v){
$schedule_list[] = array(
'key' => $v['key'],
'status' => ScheduleDict::ON,
'time' => $v['time'],
'addon' => $addon
);
$isExist = $this->model->where([["key", "=", $v['key']], ['addon', '=', $addon]])->count();
if (!$isExist) {
$schedule_list[] = array(
'key' => $v['key'],
'status' => ScheduleDict::ON,
'time' => $v['time'],
'addon' => $addon
);
}
}
$this->model->replace()->insertAll($schedule_list);
if (!empty($schedule_list)) $this->model->replace()->insertAll($schedule_list);
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;
use app\dict\schedule\ScheduleLogDict;
use app\dict\sys\DateDict;
use app\model\sys\SysSchedule;
use core\base\BaseCoreService;
use core\dict\DictLoader;
use core\exception\CommonException;
use think\console\Output;
use think\Container;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
@ -201,6 +203,20 @@ class CoreScheduleService extends BaseCoreService
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
@ -215,7 +231,11 @@ class CoreScheduleService extends BaseCoreService
try {
$result = Container::getInstance()->invoke([$class, $function ?? 'doJob']);
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){
$result = '计划任务:'.$name.'发生错误, 错误原因_' . $e->getMessage() . '_' . $e->getFile() . '_' . $e->getLine();
$status = ScheduleLogDict::ERROR;
$error = $e->getMessage();
if(!empty($output)) $output->writeln('[Schedule]['.date('Y-m-d H:i:s').']'." Error:" . $job.'('.$name.') ,'.$error);
Log::write('计划任务:'.$name.'发生错误, 错误原因:'.$error);
@ -227,6 +247,20 @@ class CoreScheduleService extends BaseCoreService
'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;
}
}
}

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();
$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",
'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()
{
$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 [
'serve_url' => (string) url('/api/wechat/serve/', [], '', true),
'serve_url' => (string) url('/api/wechat/serve', [], '', true),
'business_domain' => $wap_domain,
'js_secure_domain' => $wap_domain,
'web_auth_domain' => $wap_domain,

View File

@ -38,13 +38,11 @@ class CoreWechatFansService extends BaseCoreService
*/
public function add(array $data)
{
$fans = $this->model->create($data);
return $fans->fans_id;
}
public function find(array|string $where)
public function find($where)
{
return $this->model->where($where)->findOrEmpty();
}
@ -58,7 +56,7 @@ class CoreWechatFansService extends BaseCoreService
public function edit(string $open_id, array $data)
{
$condition = [
['openid', '=', $open_id]
[ 'openid', '=', $open_id ]
];
$fans = $this->find($condition);
$core_wechat_api_service = new CoreWechatApiService();
@ -67,34 +65,34 @@ class CoreWechatFansService extends BaseCoreService
throw new CommonException('WECHAT_EMPOWER_NOT_EXIST');
$save_data = array(
'subscribe' => $userinfo['subscribe'],//用户是否订阅该公众号标识值为0时代表此用户没有关注该公众号拉取不到其余信息。
'subscribe' => $userinfo[ 'subscribe' ],//用户是否订阅该公众号标识值为0时代表此用户没有关注该公众号拉取不到其余信息。
);
//用户是否订阅该公众号标识值为0时代表此用户没有关注该公众号拉取不到其余信息
if ($userinfo['subscribe'] == 1) {
if ($userinfo[ 'subscribe' ] == 1) {
$save_data = array_merge($save_data,
[
'language' => $userinfo['language'] ?? '',//用户的语言简体中文为zh_CN
'subscribe_time' => $userinfo['subscribe_time'] ?? '',//用户关注时间,为时间戳。如果用户曾多次关注,则取最后关注时间
'unionid' => $userinfo['unionid'] ?? '',//只有在用户将公众号绑定到微信开放平台帐号后,才会出现该字段。
'remark' => $userinfo['remark'] ?? '',//公众号运营者对粉丝的备注,公众号运营者可在微信公众平台用户管理界面对粉丝添加备注
'groupid' => $userinfo['groupid'] ?? '',//用户所在的分组ID兼容旧的用户分组接口
'subscribe_scene' => $userinfo['subscribe_scene'] ?? '',//返回用户关注的渠道来源ADD_SCENE_SEARCH 公众号搜索ADD_SCENE_ACCOUNT_MIGRATION 公众号迁移ADD_SCENE_PROFILE_CARD 名片分享ADD_SCENE_QR_CODE 扫描二维码ADD_SCENE_PROFILE_LINK 图文页内名称点击ADD_SCENE_PROFILE_ITEM 图文页右上角菜单ADD_SCENE_PAID 支付后关注ADD_SCENE_WECHAT_ADVERTISEMENT 微信广告ADD_SCENE_REPRINT 他人转载 ADD_SCENE_LIVESTREAM 视频号直播, ADD_SCENE_CHANNELS 视频号, ADD_SCENE_OTHERS 其他
'language' => $userinfo[ 'language' ] ?? '',//用户的语言简体中文为zh_CN
'subscribe_time' => $userinfo[ 'subscribe_time' ] ?? '',//用户关注时间,为时间戳。如果用户曾多次关注,则取最后关注时间
'unionid' => $userinfo[ 'unionid' ] ?? '',//只有在用户将公众号绑定到微信开放平台帐号后,才会出现该字段。
'remark' => $userinfo[ 'remark' ] ?? '',//公众号运营者对粉丝的备注,公众号运营者可在微信公众平台用户管理界面对粉丝添加备注
'groupid' => $userinfo[ 'groupid' ] ?? '',//用户所在的分组ID兼容旧的用户分组接口
'subscribe_scene' => $userinfo[ 'subscribe_scene' ] ?? '',//返回用户关注的渠道来源ADD_SCENE_SEARCH 公众号搜索ADD_SCENE_ACCOUNT_MIGRATION 公众号迁移ADD_SCENE_PROFILE_CARD 名片分享ADD_SCENE_QR_CODE 扫描二维码ADD_SCENE_PROFILE_LINK 图文页内名称点击ADD_SCENE_PROFILE_ITEM 图文页右上角菜单ADD_SCENE_PAID 支付后关注ADD_SCENE_WECHAT_ADVERTISEMENT 微信广告ADD_SCENE_REPRINT 他人转载 ADD_SCENE_LIVESTREAM 视频号直播, ADD_SCENE_CHANNELS 视频号, ADD_SCENE_OTHERS 其他
'update_time' => time(),
// 'tagid_list' => $userinfo['tagid_list'],//用户被打上的标签ID列表 , 数据库字段为json
]
);
}
//头像
if (!empty($data['avatar'])) {
$save_data['avatar'] = $data['avatar'];
if (!empty($data[ 'avatar' ])) {
$save_data[ 'avatar' ] = $data[ 'avatar' ];
}
//昵称
if (!empty($data['nickname'])) {
$save_data['nickname'] = $data['nickname'];
if (!empty($data[ 'nickname' ])) {
$save_data[ 'nickname' ] = $data[ 'nickname' ];
}
//取消关注时间
if (!empty($data['unsubscribe_time'])) {
$save_data['unsubscribe_time'] = $data['unsubscribe_time'];
if (!empty($data[ 'unsubscribe_time' ])) {
$save_data[ 'unsubscribe_time' ] = $data[ 'unsubscribe_time' ];
}
// todo qr_scene qr_scene_str 这两个二维码自定义开发功能
if (!$fans->isEmpty()) {
@ -121,10 +119,10 @@ class CoreWechatFansService extends BaseCoreService
'app_id' => $app_id,
'openid' => $from_user_name,
'subscribe' => 1,
'nickname' => $user_info['remark'],
'subscribe_time' => $user_info['subscribe_time'],
'subscribe_scene' => $user_info['subscribe_scene'],
'language' => $user_info['language'],
'nickname' => $user_info[ 'remark' ],
'subscribe_time' => $user_info[ 'subscribe_time' ],
'subscribe_scene' => $user_info[ 'subscribe_scene' ],
'language' => $user_info[ 'language' ],
);
$this->edit($from_user_name, $data);
return true;
@ -145,4 +143,4 @@ class CoreWechatFansService extends BaseCoreService
return true;
}
}
}

View File

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

View File

@ -12,6 +12,7 @@
namespace app\service\core\wechat;
use core\base\BaseCoreService;
use core\exception\CommonException;
use EasyWeChat\Kernel\Exceptions\BadRequestException;
use EasyWeChat\Kernel\Exceptions\InvalidArgumentException;
use EasyWeChat\Kernel\Exceptions\InvalidConfigException;
@ -47,8 +48,12 @@ class CoreWechatServeService extends BaseCoreService
*/
public function userFromCode(string $code)
{
$oauth = CoreWechatService::app()->getOauth();
return $oauth->userFromCode($code);
try {
$oauth = CoreWechatService::app()->getOauth();
return $oauth->userFromCode($code);
} catch (\Exception $e) {
throw new CommonException($e->getCode());
}
}
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;
use core\base\BaseValidate;
/**
* 会员收货地址验证器
* Class Address
@ -21,26 +20,26 @@ use core\base\BaseValidate;
class Address extends BaseValidate
{
protected $rule = [
'name' => 'require',
'mobile' => 'require',
'province_id' => 'require',
'city_id' => 'require',
'district_id' => 'require',
'address' => 'require',
'full_address' => 'require',
];
protected $rule = [
'name' => 'require',
'mobile' => 'require',
'province_id' => 'require',
'city_id' => 'require',
'district_id' => 'require',
'address' => 'require',
'full_address' => 'require',
];
protected $message = [
'name.require' => [ 'common_validate.require', [ 'name' ] ],
'mobile.require' => [ 'common_validate.require', [ 'mobile' ] ],
'address.require' => [ 'common_validate.require', [ 'address' ] ],
'full_address.require' => [ 'common_validate.require', [ 'full_address' ] ],
];
protected $message = [
'name.require' => ['common_validate.require', ['name']],
'mobile.require' => ['common_validate.require', ['mobile']],
'address.require' => ['common_validate.require', ['address']],
'full_address.require' => ['common_validate.require', ['full_address']],
];
protected $scene = [
"add" => [ 'name', 'mobile', 'address', 'full_address', 'lng', 'lat' ],
"edit" => [ 'name', 'mobile', 'address', 'full_address', 'lng', 'lat' ]
];
protected $scene = [
"add" => ['name', 'mobile', 'address', 'full_address', 'lng', 'lat'],
"edit" => ['name', 'mobile', 'address', 'full_address', 'lng', 'lat']
];
}

View File

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

View File

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

View File

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

View File

@ -5,11 +5,13 @@ namespace core\pay;
use app\dict\pay\OnlinePayDict;
use app\dict\pay\RefundDict;
use app\dict\pay\TransferDict;
use core\exception\CommonException;
use core\exception\PayException;
use Psr\Http\Message\MessageInterface;
use Psr\Http\Message\ResponseInterface;
use think\Response;
use Throwable;
use Yansongda\Artful\Exception\InvalidResponseException;
use Yansongda\Pay\Exception\ContainerException;
use Yansongda\Pay\Exception\InvalidParamsException;
use Yansongda\Pay\Exception\ServiceNotFoundException;
@ -48,23 +50,29 @@ class Wechatpay extends BasePay
*/
public function mp(array $params)
{
$result = $this->returnFormat(Pay::wechat()->mp([
'out_trade_no' => $params['out_trade_no'],
'description' => $params['body'],
'amount' => [
'total' => $params['money'],
],
'payer' => [
'openid' => $params['openid'],
],
]));
$code = $result['code'] ?? 0;
if ($code == 0) return $result;
//支付错误抛出
throw new PayException($result['message']);
try {
$result = $this->returnFormat(Pay::wechat()->mp([
'out_trade_no' => $params['out_trade_no'],
'description' => $params['body'],
'amount' => [
'total' => $params['money'],
],
'payer' => [
'openid' => $params['openid'],
],
]));
$code = $result['code'] ?? 0;
if ($code == 0) return $result;
//支付错误抛出
throw new PayException($result['message']);
} catch (\Exception $e) {
if ($e instanceof InvalidResponseException) {
throw new PayException($e->response->all()['message'] ?? '');
}
throw new PayException($e->getMessage());
}
}
/**
* 手机网页支付
* @param array $params
@ -72,24 +80,31 @@ class Wechatpay extends BasePay
*/
public function wap(array $params)
{
$order = [
'out_trade_no' => $params['out_trade_no'],
'description' => $params['body'],
'amount' => [
'total' => $params['money'],
],
'scene_info' => [
'payer_client_ip' => request()->ip(),
'h5_info' => [
'type' => 'Wap',
]
],
];
//这儿有些特殊, 默认情况下H5 支付所使用的 appid 是微信公众号的 appid即配置文件中的 mp_app_id 参数,如果想使用关联的小程序的 appid则只需要在调用参数中增加 ['_type' => 'mini'] 即可
if (!empty($order['type'])) {
$order['_type'] = 'mini'; // 注意这一行
try {
$order = [
'out_trade_no' => $params['out_trade_no'],
'description' => $params['body'],
'amount' => [
'total' => $params['money'],
],
'scene_info' => [
'payer_client_ip' => request()->ip(),
'h5_info' => [
'type' => 'Wap',
]
],
];
//这儿有些特殊, 默认情况下H5 支付所使用的 appid 是微信公众号的 appid即配置文件中的 mp_app_id 参数,如果想使用关联的小程序的 appid则只需要在调用参数中增加 ['_type' => 'mini'] 即可
if (!empty($order['type'])) {
$order['_type'] = 'mini'; // 注意这一行
}
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());
}
return $this->returnFormat(Pay::wechat()->h5($order));
}
public function web(array $params)
@ -104,13 +119,20 @@ class Wechatpay extends BasePay
*/
public function app(array $params)
{
return $this->returnFormat(Pay::wechat()->app([
'out_trade_no' => $params['out_trade_no'],
'description' => $params['body'],
'amount' => [
'total' => $params['money'],
],
]));
try {
return $this->returnFormat(Pay::wechat()->app([
'out_trade_no' => $params['out_trade_no'],
'description' => $params['body'],
'amount' => [
'total' => $params['money'],
],
]));
} catch (\Exception $e) {
if ($e instanceof InvalidResponseException) {
throw new PayException($e->response->all()['message'] ?? '');
}
throw new PayException($e->getMessage());
}
}
/**
@ -120,17 +142,24 @@ class Wechatpay extends BasePay
*/
public function mini(array $params)
{
return $this->returnFormat(Pay::wechat()->mini([
'out_trade_no' => $params['out_trade_no'],
'description' => $params['body'],
'amount' => [
'total' => $params['money'],
'currency' => 'CNY',//一般是人民币
],
'payer' => [
'openid' => $params['openid'],
]
]));
try {
return $this->returnFormat(Pay::wechat()->mini([
'out_trade_no' => $params['out_trade_no'],
'description' => $params['body'],
'amount' => [
'total' => $params['money'],
'currency' => 'CNY',//一般是人民币
],
'payer' => [
'openid' => $params['openid'],
]
]));
} catch (\Exception $e) {
if ($e instanceof InvalidResponseException) {
throw new PayException($e->response->all()['message'] ?? '');
}
throw new PayException($e->getMessage());
}
}
/**
@ -140,15 +169,22 @@ class Wechatpay extends BasePay
*/
public function pos(array $params)
{
$order = [
'out_trade_no' => $params['out_trade_no'],
'body' => $params['body'],
'total_fee' => $params['money'],
'spbill_create_ip' => request()->ip(),
'auth_code' => $params["auth_code"],
];
$result = Pay::wechat()->pos($order);
return $this->returnFormat($result);
try {
$order = [
'out_trade_no' => $params['out_trade_no'],
'body' => $params['body'],
'total_fee' => $params['money'],
'spbill_create_ip' => request()->ip(),
'auth_code' => $params["auth_code"],
];
$result = Pay::wechat()->pos($order);
return $this->returnFormat($result);
} catch (\Exception $e) {
if ($e instanceof InvalidResponseException) {
throw new PayException($e->response->all()['message'] ?? '');
}
throw new PayException($e->getMessage());
}
}
/**
@ -158,13 +194,20 @@ class Wechatpay extends BasePay
*/
public function scan(array $params)
{
return $this->returnFormat(Pay::wechat()->scan([
'out_trade_no' => $params['out_trade_no'],
'description' => $params['body'],
'amount' => [
'total' => $params['money'],
],
]));
try {
return $this->returnFormat(Pay::wechat()->scan([
'out_trade_no' => $params['out_trade_no'],
'description' => $params['body'],
'amount' => [
'total' => $params['money'],
],
]));
} catch (\Exception $e) {
if ($e instanceof InvalidResponseException) {
throw new PayException($e->response->all()['message'] ?? '');
}
throw new PayException($e->getMessage());
}
}
/**