This commit is contained in:
全栈小学生 2024-08-17 09:40:17 +08:00
parent bf224633d5
commit 58d6348768
98 changed files with 1037 additions and 1154 deletions

View File

@ -2,7 +2,6 @@
namespace app;
use app\dict\sys\AppTypeDict;
use core\exception\AdminException;
use core\exception\AuthException;
use core\exception\ServerException;
use think\db\exception\DataNotFoundException;

View File

@ -13,7 +13,6 @@ namespace app\adminapi\controller\login;
use app\service\admin\auth\ConfigService;
use app\service\admin\auth\LoginService;
use app\service\admin\upgrade\UpgradeService;
use app\service\core\addon\WapTrait;
use core\base\BaseAdminController;
use think\Response;
@ -62,14 +61,4 @@ class Login extends BaseAdminController
{
return success(( new ConfigService() )->getConfig());
}
public function test()
{
( new UpgradeService() )->executeSql(root_path() . 'app/upgrade/v011/upgrade.sql');
}
public function geAddonPackagePath(string $addon)
{
return root_path() . 'addon' . DIRECTORY_SEPARATOR . $addon . DIRECTORY_SEPARATOR . 'package' . DIRECTORY_SEPARATOR;
}
}

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

@ -94,21 +94,6 @@ class Notice extends BaseAdminController
return success();
}
/**
* 消息列表
* @return Response
*/
public function getLogList()
{
$data = $this->request->params([
['key', ''],
['receiver', ''],
]);
$res = (new NoticeService())->getLogPage($data);
return success($res);
}
/**
* 消息修改
* @return Response

View File

@ -25,6 +25,9 @@ class Stat extends BaseAdminController
/**
* 首页数据
* @return Response
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function index()
{

View File

@ -86,6 +86,16 @@ class User extends BaseAdminController
return success();
}
/**
* 删除用户
* @param $uid
* @return Response
*/
public function del($uid) {
(new UserService())->del($uid);
return success("DELETE_SUCCESS");
}
/**
* 获取用户站点创建限制
* @param $uid

View File

@ -16,7 +16,6 @@ use app\adminapi\middleware\AdminCheckToken;
use app\adminapi\middleware\AdminLog;
// USER_CODE_BEGIN -- sys_dict
Route::group('dict', function () {
//数据字典列表
@ -39,5 +38,4 @@ Route::group('dict', function () {
AdminCheckToken::class,
AdminCheckRole::class,
AdminLog::class
]);
// USER_CODE_END -- sys_dict
]);

View File

@ -18,7 +18,7 @@ use think\facade\Route;
/**
* 路由
*/
Route::group('member', function () {
Route::group('member', function() {
/***************************************************** 会员管理 ****************************************************/
//会员列表
Route::get('member', 'member.Member/lists');

View File

@ -32,8 +32,6 @@ Route::group('notice', function () {
Route::get('notice/sms/:sms_type', 'notice.Notice/smsConfig');
//短信配置修改
Route::put('notice/sms/:sms_type', 'notice.Notice/editSms');
//消息发送记录
Route::get('notice/log', 'notice.Notice/getLogList');
//消息修改
Route::post('notice/edit', 'notice.Notice/edit');

View File

@ -15,7 +15,7 @@ use think\facade\Route;
/**
* 路由
*/
Route::group(function () {
Route::group(function() {
//用户登录
Route::get('login/:app_type', 'login.Login/login');
@ -26,9 +26,7 @@ Route::group(function () {
Route::get('captcha/create', 'login.Captcha/create');
//一次校验验证码
Route::get('captcha/check', 'login.Captcha/check');
Route::get('test', 'login.Login/test');
});
//加载插件路由
(new DictLoader("Route"))->load(['app_type' => 'adminapi']);
( new DictLoader("Route") )->load([ 'app_type' => 'adminapi' ]);

View File

@ -28,6 +28,8 @@ Route::group('user', function () {
Route::get('user_select', 'user.User/getUserSelect');
//用户详情
Route::get('user/:uid', 'user.User/info');
// 删除用户
Route::delete('user/:uid', 'user.User/del');
// 查询账号是否存在
Route::get('isexist', 'user.User/checkUserIsExist');
//添加用户

View File

@ -62,6 +62,7 @@ class Account extends BaseApiController
{
$data = $this->request->params([
['from_type', ''],
['trade_type', ''],
['create_time', []]
]);
return success((new MemberAccountService())->getBalancePage($data));

View File

@ -550,7 +550,7 @@ class ComponentDict
'sort' => 10014,
'position' => 'fixed',
'value' => [
"imageSize" => 80,
"imageSize" => 40,
"aroundRadius" => 0,
'style' => 'style-1',
"styleName" => "风格一",

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

@ -68,7 +68,9 @@ class PagesDict
"list" => []
];
$wap_index_list = ( new ConfigService() )->getWapIndexList();
$wap_index_list = ( new ConfigService() )->getWapIndexList([
'site_id' => $params[ 'site_id' ] ?? 0
]);
if (!empty($wap_index_list)) {
foreach ($wap_index_list as $k => $v) {

View File

@ -11,8 +11,6 @@
namespace app\dict\member;
use app\dict\common\ChannelDict;
/**
* 会员签到状态枚举类
* Class MemberDict

View File

@ -11,8 +11,6 @@
namespace app\dict\member;
use app\dict\common\ChannelDict;
/**
* 会员签到类型枚举类
* Class MemberDict

View File

@ -132,7 +132,7 @@ return [
'router_path' => '',
'view_path' => '',
'methods' => '',
'sort' => '40',
'sort' => '75',
'status' => '1',
'is_show' => '1',
'children' => [
@ -320,7 +320,7 @@ return [
'router_path' => 'setting/storage',
'view_path' => 'setting/storage',
'methods' => 'get',
'sort' => '30',
'sort' => '70',
'status' => '1',
'is_show' => '1',
'children' => [
@ -364,7 +364,7 @@ return [
'router_path' => 'setting/adminlogin',
'view_path' => 'setting/adminlogin',
'methods' => 'get',
'sort' => '20',
'sort' => '65',
'status' => '1',
'is_show' => '1',
'children' => [
@ -394,7 +394,7 @@ return [
'router_path' => '',
'view_path' => '',
'methods' => 'get',
'sort' => '20',
'sort' => '60',
'status' => '1',
'is_show' => '1',
'children' => [
@ -408,7 +408,7 @@ return [
'router_path' => 'setting/oplatform',
'view_path' => 'wxoplatform/setting',
'methods' => 'get',
'sort' => '20',
'sort' => '100',
'status' => '1',
'is_show' => '1',
'children' => [
@ -438,7 +438,7 @@ return [
'router_path' => 'wxoplatform/weapp_version',
'view_path' => 'wxoplatform/weapp_version',
'methods' => 'get',
'sort' => '10',
'sort' => '99',
'status' => '1',
'is_show' => '1',
'children' => [
@ -470,7 +470,7 @@ return [
'router_path' => 'setting/attachment',
'view_path' => 'tools/attachment',
'methods' => 'get',
'sort' => '10',
'sort' => '55',
'status' => '1',
'is_show' => '1',
'children' => [
@ -570,7 +570,7 @@ return [
'router_path' => 'setting/map',
'view_path' => 'setting/map',
'methods' => 'get',
'sort' => '9',
'sort' => '50',
'status' => '1',
'is_show' => '1',
'children' => [
@ -600,7 +600,7 @@ return [
'router_path' => 'setting/layout',
'view_path' => 'setting/layout',
'methods' => 'get',
'sort' => '8',
'sort' => '45',
'status' => '1',
'is_show' => '1',
'children' => [
@ -855,6 +855,20 @@ return [
'status' => '1',
'is_show' => '1',
],
[
'menu_name' => '删除站点用户',
'menu_key' => 'add_user',
'menu_short_name' => '',
'menu_type' => '2',
'icon' => '',
'api_url' => 'user/user/<uid>',
'router_path' => '',
'view_path' => '',
'methods' => 'delete',
'sort' => '100',
'status' => '1',
'is_show' => '1',
],
[
'menu_name' => '获取用户套餐权限',
'menu_key' => 'get_user_create_site_limit',
@ -938,7 +952,7 @@ return [
'router_path' => 'app_manage/app_store',
'view_path' => 'index/store',
'methods' => 'get',
'sort' => '70',
'sort' => '78',
'status' => '1',
'is_show' => '1',
'children' => [
@ -1038,7 +1052,7 @@ return [
'router_path' => 'app_manage/tools',
'view_path' => 'index/tools',
'methods' => 'get',
'sort' => '70',
'sort' => '77',
'status' => '1',
'is_show' => '1',
],
@ -1053,7 +1067,7 @@ return [
'router_path' => '',
'view_path' => '',
'methods' => '',
'sort' => '60',
'sort' => '76',
'status' => '1',
'is_show' => '0',
'children' => [

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' => 'setting/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' => [
@ -1786,7 +1786,6 @@ return [
],
]
],
[
'menu_name' => '会员设置',
'menu_key' => 'setting_member',

View File

@ -16,7 +16,6 @@ use app\dict\common\ChannelDict;
class PayChannelDict
{
/**
* 支付渠道类型
* @return array
@ -43,5 +42,4 @@ class PayChannelDict
return $list;
}
}

View File

@ -25,15 +25,15 @@ return [
'class' => 'app\job\schedule\SiteExpireClose',
'function' => ''
],
[
'key' => 'site_stat',
'name' => '站点统计',
'desc' => '',
'time' => [
'type' => 'hour',
'hour' => 1,
],
'class' => 'app\job\schedule\SiteStatJob',
'function' => ''
]
// [
// 'key' => 'site_stat',
// 'name' => '站点统计',
// 'desc' => '',
// 'time' => [
// 'type' => 'hour',
// 'hour' => 1,
// ],
// 'class' => 'app\job\schedule\SiteStatJob',
// 'function' => ''
// ]
];

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

@ -27,7 +27,6 @@ $system_event = [
'MemberAccount' => [ 'app\listener\member\MemberAccountListener' ],
//扫码事件
'Scan' => [ 'app\listener\scan\ScanListener' ],
'AddSiteAfter' => [ 'app\listener\site\AddSiteAfterListener' ],
/**
* 支付相关事件
*/
@ -89,12 +88,12 @@ $system_event = [
//导出数据类型
'ExportDataType' => [
//会员导出
'app\listener\member\MemberExportTypeListener',
'app\listener\member_export\MemberExportTypeListener',
],
//导出数据源
'ExportData' => [
//会员导出
'app\listener\member\MemberExportDataListener',
'app\listener\member_export\MemberExportDataListener',
],
//统计执行
'StatExecute' => [],
@ -102,10 +101,10 @@ $system_event = [
'StatField' => [],
// 获取海报数据
'GetPosterData' => ['app\listener\system\Poster'],
'GetPosterData' => [ 'app\listener\system\Poster' ],
// 小程序授权变更事件
'WeappAuthChangeAfter' => ['app\listener\system\WeappAuthChangeAfter']
'WeappAuthChangeAfter' => [ 'app\listener\system\WeappAuthChangeAfter' ]
],
'subscribe' => [
],

View File

@ -6,8 +6,6 @@ namespace app\install\controller;
use app\model\site\Site;
use app\model\sys\SysUser;
use app\service\admin\install\InstallSystemService;
use app\service\admin\site\SiteGroupService;
use app\service\admin\site\SiteService;
use app\service\core\schedule\CoreScheduleInstallService;
use Exception;
use think\facade\Cache;
@ -39,7 +37,7 @@ class Index extends BaseInstall
$host = ( empty($_SERVER[ 'REMOTE_ADDR' ]) ? $_SERVER[ 'REMOTE_HOST' ] : $_SERVER[ 'REMOTE_ADDR' ] );
$name = $_SERVER[ 'SERVER_NAME' ];
$verison = !(version_compare(PHP_VERSION, '8.0.0') == -1);
$verison = !( version_compare(PHP_VERSION, '8.0.0') == -1 );
//pdo
$pdo = extension_loaded('pdo') && extension_loaded('pdo_mysql');
$system_variables[] = [ "name" => "pdo", "need" => "开启", "status" => $pdo ];
@ -65,9 +63,9 @@ class Index extends BaseInstall
[ "path" => $root_path . DIRECTORY_SEPARATOR, "path_name" => "niucloud/", "name" => "网站目录" ],
[ "path" => $root_path . DIRECTORY_SEPARATOR . ".env", "path_name" => "niucloud/.env", "name" => "env" ],
[ "path" => $root_path . DIRECTORY_SEPARATOR . ".example.env", "path_name" => "niucloud/.example_env", "name" => "env" ],
[ "path" => $root_path . DIRECTORY_SEPARATOR . 'runtime'.DIRECTORY_SEPARATOR, "path_name" => "niucloud/runtime", "name" => "runtime" ],
[ "path" => $root_path . DIRECTORY_SEPARATOR . 'public'.DIRECTORY_SEPARATOR.'upload'.DIRECTORY_SEPARATOR, "path_name" => "niucloud/public/upload", "name" => "upload" ],
[ "path" => $root_path . DIRECTORY_SEPARATOR . 'app'.DIRECTORY_SEPARATOR.'install'.DIRECTORY_SEPARATOR, "path_name" => "niucloud/app/install", "name" => "安装目录" ]
[ "path" => $root_path . DIRECTORY_SEPARATOR . 'runtime' . DIRECTORY_SEPARATOR, "path_name" => "niucloud/runtime", "name" => "runtime" ],
[ "path" => $root_path . DIRECTORY_SEPARATOR . 'public' . DIRECTORY_SEPARATOR . 'upload' . DIRECTORY_SEPARATOR, "path_name" => "niucloud/public/upload", "name" => "upload" ],
[ "path" => $root_path . DIRECTORY_SEPARATOR . 'app' . DIRECTORY_SEPARATOR . 'install' . DIRECTORY_SEPARATOR, "path_name" => "niucloud/app/install", "name" => "安装目录" ]
];
//目录 可读 可写检测
$is_dir = true;
@ -164,7 +162,7 @@ class Index extends BaseInstall
"message" => "数据库不存在,系统将自动创建"
];
}
} catch ( Exception $e) {
} catch (Exception $e) {
$result = [
"status" => 1,
"message" => "数据库不存在,系统将自动创建"
@ -182,7 +180,7 @@ class Index extends BaseInstall
}
return success($result);
} catch ( Exception $e) {
} catch (Exception $e) {
$result = [
"status" => -1,
"message" => $e->getMessage()
@ -210,7 +208,7 @@ class Index extends BaseInstall
$sqls = explode("\n", trim($sql));
$sqls = array_filter($sqls);
foreach ($sqls as $query) {
$str1 = $query[0] ?? '';
$str1 = $query[ 0 ] ?? '';
if ($str1 != '#' && $str1 != '-')
$sql_query[ $num ] .= $query;
}
@ -263,7 +261,7 @@ class Index extends BaseInstall
// return fail('平台信息不能为空!');
// }
if($site_username == $username) {
if ($site_username == $username) {
$this->setSuccessLog([ '站点账号不能跟平台账号一致', 'error' ]);
return fail('站点账号不能跟平台账号一致!');
}
@ -289,7 +287,7 @@ class Index extends BaseInstall
Cache::set('install_status', 1);//成功
return success();
} catch ( Exception $e) {
} catch (Exception $e) {
$this->setSuccessLog([ '安装失败' . $e->getMessage(), 'error' ]);
return fail('安装失败' . $e->getMessage());
}
@ -315,7 +313,7 @@ class Index extends BaseInstall
return fail('平台两次密码输入不一样,请重新输入');
}
if($site_username == $username) {
if ($site_username == $username) {
return fail('站点账号不能跟平台账号一致');
}
@ -331,13 +329,12 @@ class Index extends BaseInstall
return fail('菜单初始化失败');
}
//初始化计划任务
$res = ( new CoreScheduleInstallService())->installSystemSchedule();
$res = ( new CoreScheduleInstallService() )->installSystemSchedule();
if (!$res) {
$this->setSuccessLog([ '计划任务初始化失败', 'error' ]);
return fail('计划任务初始化失败');
}
$user = ( new SysUser() )->where([ [ 'uid', '=', 1 ] ])->findOrEmpty();
if (!$user->isEmpty()) {
$user->save([
@ -345,7 +342,7 @@ class Index extends BaseInstall
'password' => create_password($password),
]);
}
( new Site() )->where([ [ 'site_id', '=', 1 ] ])->update(['site_id' => 0]);
( new Site() )->where([ [ 'site_id', '=', 1 ] ])->update([ 'site_id' => 0 ]);
$site = ( new Site() )->where([ [ 'site_id', '=', 0 ] ])->findOrEmpty();
if (!$site->isEmpty()) {
$site->save([
@ -353,7 +350,7 @@ class Index extends BaseInstall
]);
}
//修改自增主键默认值
Db::execute("alter table ".env('database.prefix', '')."site auto_increment = 100000");
Db::execute("alter table " . env('database.prefix', '') . "site auto_increment = 100000");
//获取默认套餐
$fp = fopen($this->lock_file, 'wb');
@ -367,7 +364,7 @@ class Index extends BaseInstall
Cache::set('install_status', 2);//成功
// Cache::tag(MenuService::$cache_tag_name)->clear();
return success();
} catch ( Exception $e) {
} catch (Exception $e) {
$this->setSuccessLog([ '安装失败' . $e->getMessage(), 'error' ]);
return fail('安装失败' . $e->getMessage());
}
@ -445,7 +442,7 @@ class Index extends BaseInstall
$sql_item = $this->str_replace_first($table_name, $new_table_name, $sql);
@mysqli_query($conn, $sql_item);
if ($is_write) $this->setSuccessLog([ '创建表' . $table_name, 'success' ]);
} catch ( Exception $e) {
} catch (Exception $e) {
$this->setSuccessLog([ $e->getMessage(), 'error' ]);
return fail('数据库解析失败' . $e->getMessage());
}
@ -517,7 +514,7 @@ class Index extends BaseInstall
if ($data[ 1 ] == 'error') {
Cache::set('install_status', -1);
}
$time = @(int)microtime(true);
$time = @(int) microtime(true);
$data[] = date('Y-m-d H:i:s', $time);
$install_data = Cache::get('install_data') ?? [];
$install_data[] = $data;

View File

@ -2,7 +2,7 @@
SET NAMES utf8mb4;
DROP TABLE IF EXISTS `addon`;
CREATE TABLE `addon` (
CREATE TABLE `addon` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
`title` varchar(40) NOT NULL DEFAULT '' COMMENT '插件名称',
`icon` varchar(255) NOT NULL DEFAULT '' COMMENT '插件图标',
@ -24,7 +24,7 @@ CREATE TABLE `addon` (
DROP TABLE IF EXISTS `addon_log`;
CREATE TABLE `addon_log` (
CREATE TABLE `addon_log` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
`action` varchar(40) NOT NULL DEFAULT '' COMMENT '操作类型 install 安装 uninstall 卸载 update 更新',
`key` varchar(20) NOT NULL DEFAULT '' COMMENT '插件标识',
@ -78,12 +78,12 @@ CREATE TABLE `diy_page` (
`template` varchar(255) NOT NULL DEFAULT '' COMMENT '模板名称',
`mode` varchar(255) NOT NULL DEFAULT 'diy' COMMENT '页面展示模式diy自定义fixed固定',
`value` longtext COMMENT '页面数据json格式',
`is_default` int(11) NOT NULL DEFAULT '0' COMMENT '是否默认页面10',
`is_change` int(11) NOT NULL DEFAULT '0' COMMENT '数据是否发生过变化1变化了2没有',
`is_default` int(11) NOT NULL DEFAULT 0 COMMENT '是否默认页面10',
`is_change` int(11) NOT NULL DEFAULT 0 COMMENT '数据是否发生过变化1变化了2没有',
`share` varchar(1000) NOT NULL DEFAULT '' COMMENT '分享内容',
`visit_count` int(11) NOT NULL DEFAULT '0' COMMENT '访问量',
`create_time` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
`update_time` int(11) NOT NULL DEFAULT '0' COMMENT '更新时间',
`visit_count` int(11) NOT NULL DEFAULT 0 COMMENT '访问量',
`create_time` int(11) NOT NULL DEFAULT 0 COMMENT '创建时间',
`update_time` int(11) NOT NULL DEFAULT 0 COMMENT '更新时间',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '自定义页面' ROW_FORMAT = Dynamic;
@ -458,91 +458,6 @@ CREATE TABLE `pay_transfer` (
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '转账表' ROW_FORMAT = Dynamic;
DROP TABLE IF EXISTS `recharge_order`;
CREATE TABLE `recharge_order` (
`order_id` int(11) NOT NULL AUTO_INCREMENT,
`site_id` int(11) NOT NULL DEFAULT 0 COMMENT '站点id',
`order_no` varchar(50) NOT NULL DEFAULT '' COMMENT '订单编号',
`order_from` varchar(55) NOT NULL DEFAULT '' COMMENT '订单来源',
`order_type` varchar(50) NOT NULL DEFAULT '' COMMENT '订单类型',
`out_trade_no` varchar(50) NOT NULL DEFAULT '' COMMENT '支付流水号',
`order_status` int(11) NOT NULL DEFAULT 0 COMMENT '订单状态',
`refund_status` int(11) NOT NULL DEFAULT 0 COMMENT '退款状态',
`member_id` int(11) NOT NULL DEFAULT 0 COMMENT '会员id',
`ip` varchar(20) NOT NULL DEFAULT '' COMMENT '会员ip',
`member_message` varchar(50) NOT NULL DEFAULT '' COMMENT '会员留言信息',
`order_item_money` decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '订单项目金额',
`order_discount_money` decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '订单优惠金额',
`order_money` decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '订单金额',
`create_time` int(11) NOT NULL DEFAULT 0 COMMENT '创建时间',
`pay_time` int(11) NOT NULL DEFAULT 0 COMMENT '订单支付时间',
`close_time` int(11) NOT NULL DEFAULT 0 COMMENT '订单关闭时间',
`is_delete` int(11) NOT NULL DEFAULT 0 COMMENT '是否删除(针对后台)',
`is_enable_refund` int(11) NOT NULL DEFAULT 0 COMMENT '是否允许退款',
`remark` varchar(255) NOT NULL DEFAULT '' COMMENT '商家留言',
`invoice_id` int(11) NOT NULL DEFAULT 0 COMMENT '发票id0表示不开发票',
`close_reason` varchar(255) NOT NULL DEFAULT '' COMMENT '关闭原因',
PRIMARY KEY (`order_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '订单表' ROW_FORMAT = Dynamic;
DROP TABLE IF EXISTS `recharge_order_item`;
CREATE TABLE `recharge_order_item` (
`order_item_id` int(11) NOT NULL AUTO_INCREMENT,
`order_id` int(11) NOT NULL DEFAULT 0 COMMENT '订单id',
`site_id` int(11) NOT NULL DEFAULT 0 COMMENT '站点id',
`member_id` int(11) NOT NULL DEFAULT 0 COMMENT '购买会员id',
`item_id` int(11) NOT NULL DEFAULT 0 COMMENT '项目id',
`item_type` varchar(255) NOT NULL DEFAULT '' COMMENT '项目类型',
`item_name` varchar(400) NOT NULL DEFAULT '' COMMENT '项目名称',
`item_image` varchar(2000) NOT NULL DEFAULT '' COMMENT '项目图片',
`price` decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '项目单价',
`num` decimal(10, 3) NOT NULL DEFAULT 0.000 COMMENT '购买数量',
`item_money` decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '项目总价',
`is_refund` int(11) NOT NULL DEFAULT 0 COMMENT '是否退款',
`refund_no` varchar(255) NOT NULL DEFAULT '' COMMENT '退款编号',
`refund_status` int(11) NOT NULL DEFAULT 0 COMMENT '退款状态',
`create_time` int(11) NOT NULL DEFAULT 0 COMMENT '创建时间',
PRIMARY KEY (`order_item_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '订单商品表' ROW_FORMAT = Dynamic;
DROP TABLE IF EXISTS `recharge_order_item_refund`;
CREATE TABLE `recharge_order_item_refund` (
`refund_id` int(11) NOT NULL AUTO_INCREMENT,
`order_item_id` int(11) NOT NULL DEFAULT 0 COMMENT '订单id',
`order_id` int(11) NOT NULL DEFAULT 0 COMMENT '订单id',
`order_no` varchar(255) NOT NULL DEFAULT '' COMMENT '订单编号',
`refund_no` varchar(255) NOT NULL DEFAULT '0' COMMENT '退款单号',
`site_id` int(11) NOT NULL DEFAULT 0 COMMENT '站点id',
`member_id` int(11) NOT NULL DEFAULT 0 COMMENT '会员id',
`num` decimal(10, 3) NOT NULL DEFAULT 0.000 COMMENT '退货数量',
`money` decimal(10, 2) NOT NULL DEFAULT 0.00 COMMENT '总退款',
`status` int(11) NOT NULL DEFAULT 0 COMMENT '退款状态',
`create_time` int(11) NOT NULL DEFAULT 0 COMMENT '创建时间',
`audit_time` int(11) NOT NULL DEFAULT 0 COMMENT '审核时间',
`transfer_time` int(11) NOT NULL DEFAULT 0 COMMENT '转账时间',
`item_type` varchar(255) NOT NULL DEFAULT '' COMMENT '项目类型',
PRIMARY KEY (`refund_id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '订单退款表' ROW_FORMAT = Dynamic;
DROP TABLE IF EXISTS `recharge_order_log`;
CREATE TABLE `recharge_order_log` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`order_id` int(11) NOT NULL DEFAULT 0 COMMENT '订单id',
`site_id` int(11) NOT NULL DEFAULT 0 COMMENT '站点id',
`action` varchar(255) NOT NULL DEFAULT '' COMMENT '操作内容',
`uid` int(11) NOT NULL DEFAULT 0 COMMENT '操作人id',
`nick_name` varchar(50) NOT NULL DEFAULT '' COMMENT '操作人名称',
`order_status` int(11) NOT NULL DEFAULT 0 COMMENT '订单状态,操作后',
`action_way` bigint(20) NOT NULL DEFAULT 2 COMMENT '操作类型1买家2卖家 3 系统任务',
`order_status_name` varchar(255) NOT NULL DEFAULT '' COMMENT '订单状态名称,操作后',
`action_time` int(11) NOT NULL DEFAULT 0 COMMENT '操作时间',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '订单操作记录表' ROW_FORMAT = Dynamic;
DROP TABLE IF EXISTS `site`;
CREATE TABLE `site` (
`site_id` int(11) NOT NULL AUTO_INCREMENT,
@ -1119,7 +1034,7 @@ INSERT INTO `site`(site_id, site_name, group_id, keywords, app_type, logo, `desc
UPDATE `site` SET site_id = 0 WHERE site_id = 1;
INSERT INTO `sys_user` VALUES ('1', '', '', '', '', '', '0', '0', '0', '1', '0', '0', '0');
-- INSERT INTO `sys_user` VALUES ('1', '', '', '', '', '', '0', '0', '0', '1', '0', '0', '0');
INSERT INTO `sys_user_role` VALUES ('1', '1', '0', '', '0', '1', '1');

View File

@ -4,7 +4,6 @@
<meta name="renderer" content="webkit" />
<meta http-equiv="X-UA-COMPATIBLE" content="IE=edge,chrome=1" />
<title>安装程序 - NiuCloud-Admin</title>
<!-- <script src="INSTALL_JS/jquery-2.2.js"></script>-->
<link rel="icon" type="image/x-icon" href="INSTALL_IMG/shop_bitbug_favicon.ico" />
<link rel="stylesheet" type="text/css" href="INSTALL_CSS/style.css" />
<link rel="stylesheet" type="text/css" href="INSTALL_CSS/layui.css" />

View File

@ -159,13 +159,13 @@
</div>
<div class="btn-box">
<input type="button" class="btn-back" value="后退" onclick="window.location.href='{$root_url}/install.php/index/index?step=2'" />
<input type="button" class="btn-next" lay-submit lay-filter="install"value="开始安装" id="form_submit">
<input type="button" class="btn-next" lay-submit lay-filter="install" value="开始安装" id="form_submit">
</div>
</div>
{/block}
{block name='script'}
<script language="javascript" type="text/javascript">
<script type="text/javascript">
ControlContent(2);
var is_existdb = 1;//数据库是否存在
var message = '数据库账号或密码不能为空';

View File

@ -21,8 +21,8 @@ class SiteStatJob extends BaseJob
{
public function doJob()
{
event('Stat');
Log::write('站点统计' . date('Y-m-d h:i:s'));
// event('Stat');
// Log::write('站点统计' . date('Y-m-d h:i:s'));
return true;
}
}

View File

@ -28,7 +28,7 @@ return [
'DOWNLOAD_FAIL' => 'download fail',
'SET_SUCCESS' => 'set success',
'AGREEMENT_TYPE_NOT_EXIST' => 'agreement type is not exit',
'FIELD_NOT_FOUND' => 'cloumn is not exit',
'FIELD_NOT_FOUND' => 'column is not exit',
'REFRESH_SUCCESS' => 'refresh success',
'CAPTCHA_ERROR' => 'captcha fail',
@ -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,7 @@ return [
'ZIP_FILE_NOT_FOUND' => '找不到可用的压缩文件',
'ZIP_ARCHIVE_NOT_INSTALL' => 'ZipArchive扩展未安装',
'DOWNLOAD_SUCCESS' => '下载成功',
'APP_NOT_ALLOW_UNINSTALL' => '该应用下存在站点卸载前请先删除相关站点',
'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>',
@ -74,6 +74,8 @@ return [
'SITE_USER_CAN_NOT_LOGIN_IN_ADMIN' => '站点用户无法在平台端进行登录',
'ADMIN_USER_CAN_NOT_LOGIN_IN_SITE' => '平台用户无法在站点端进行登录',
'APP_TYPE_NOT_EXIST' => '无效的登录端口',
"USER_NOT_ALLOW_DEL" => "该用户是一些站点的管理员不允许删除",
"SUPER_ADMIN_NOT_ALLOW_DEL" => "超级管理员不允许删除",
//用户组权限
@ -110,7 +112,7 @@ return [
'OSS_FILE_URL_NOT_EXIST' => '远程资源文件地址不能为空',
'BASE_IMAGE_FILE_NOT_EXIST' => 'base图片资源不能为空',
'UPLOAD_TYPE_NOT_SUPPORT' => '不支持的上传类型',
'FILE_ERROE' => '无效的资源',
'FILE_ERROR' => '无效的资源',
'UPLOAD_STORAGE_TYPE_ALL_CLOSE' => '至少要有一个启用的存储方式',
'STORAGE_NOT_HAS_HTTP_OR_HTTPS' => '空间域名请补全http://或https://',
@ -143,7 +145,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' => '手机验证码有误',
@ -185,7 +187,7 @@ return [
'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

@ -9,14 +9,14 @@
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace app\listener\member;
namespace app\listener\member_export;
use app\model\member\Member;
/**
* 会员导出数据源查询
* Class MemberExportTypeListener
* @package app\listener\member
* Class MemberExportDataListener
* @package app\listener\member_export
*/
class MemberExportDataListener
{
@ -26,7 +26,7 @@ class MemberExportDataListener
$data = [];
if ($param['type'] == 'member') {
$model = new Member();
$field = 'member_id, member_no, username, mobile, nickname, birthday, member_level, point, balance, money, growth, commission, register_channel, status, create_time, last_visit_time';
$field = 'member_id, member_no, mobile, nickname, birthday, member_level, point, balance, money, growth, commission, register_channel, status, create_time, last_visit_time';
//查询导出数据
$search_model = $model->where([['site_id', '=', $param['site_id']]])->withSearch(['keyword','register_type', 'create_time', 'is_del', 'member_label', 'register_channel'], $param['where'])
->with(['memberLevelNameBind'])->field($field)->append(['register_channel_name', 'sex_name', 'status_name']);
@ -36,10 +36,9 @@ class MemberExportDataListener
$data = $search_model->select()->toArray();
}
foreach ($data as $key => $value) {
$data[$key]['username'] = !empty($value['username']) ? $value['username'] : '-';
$data[$key]['mobile'] = $value['mobile']."\t";
$data[$key]['create_time'] = !empty($value['create_time']) ? $value['create_time'] : '0000-00-00 00:00:00';
$data[$key]['last_visit_time'] = !empty($value['last_visit_time']) ? $value['last_visit_time'] : '0000-00-00 00:00:00';
$data[$key]['create_time'] = !empty($value['create_time']) ? $value['create_time'] : '';
$data[$key]['last_visit_time'] = !empty($value['last_visit_time']) ? $value['last_visit_time'] : '';
}
}
return $data;

View File

@ -9,7 +9,7 @@
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace app\listener\member;
namespace app\listener\member_export;
/**
* 会员导出数据类型查询
@ -25,7 +25,6 @@ class MemberExportTypeListener
'member' => [
'name' => '会员列表',
'column' => [
'username' => [ 'name' => '真实姓名'],
'nickname' => [ 'name' => '会员昵称'],
'mobile' => [ 'name' => '手机号'],
'member_level_name' => [ 'name' => '会员等级'],

View File

@ -1,151 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | Niucloud-admin 企业快速开发的saas管理平台
// +----------------------------------------------------------------------
// | 官方网址https://www.niucloud.com
// +----------------------------------------------------------------------
// | niucloud团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace app\listener\site;
use app\dict\diy\TemplateDict;
use app\service\admin\diy\DiyRouteService;
use app\service\admin\diy\DiyService;
/**
* 添加站点成功后事件
*/
class AddSiteAfterListener
{
/**
* 初始化站点
* @param array $params
*/
public function handle($params = [])
{
$site_id = $params[ 'site_id' ];
request()->siteId($site_id);
$count = count($params[ 'main_app' ]);
$addon = array_merge([ '' ], $params[ 'main_app' ]);
foreach ($addon as $k => $v) {
if ($count > 1) {
// 站点多应用,使用系统的页面
if ($k == 0) {
$is_start = 1;
} else {
$is_start = 0;
}
} else {
// 站点单应用,将应用的设为使用中
if ($k == 0) {
$is_start = 0;
} else {
$is_start = 1;
}
}
// 设置 首页 默认模板
$this->setDiyData([
'key' => 'DIY_INDEX',
'type' => 'index',
'addon' => $v,
'is_start' => $is_start,
'site_id' => $site_id
]);
// 设置 个人中心 默认模板
$this->setDiyData([
'key' => 'DIY_MEMBER_INDEX',
'type' => 'member_index',
'addon' => $v,
'is_start' => $is_start,
'site_id' => $site_id
]);
}
}
/**
* 设置 首页/个人中心 的第一个模板 设置为启动页
* @param $params
*/
private function setDiyData($params)
{
$addon = $params[ 'addon' ] ?? '';
$addon_flag = $params[ 'key' ];
// 默认
$default_template = TemplateDict::getTemplate([
'key' => [ $params[ 'key' ] ]
]);
$addon_template_info = array_shift($default_template);
// 查询插件定义的页面类型
$addon_template = TemplateDict::getTemplate([
'type' => $params[ 'type' ],
'addon' => $addon
]);
if (!empty($addon_template)) {
$addon_flag = array_keys($addon_template)[ 0 ];
$addon_template_info = array_shift($addon_template);
}
$diy_service = new DiyService();
$addon_index_template = $diy_service->getFirstPageData($addon_flag, $addon);
if (!empty($addon_index_template)) {
$diy_service->add([
'page_title' => $addon_index_template[ 'title' ],
"title" => $addon_index_template[ 'title' ],
"name" => $addon_flag,
"type" => $addon_flag,
"template" => $addon_index_template[ 'template' ],
"mode" => $addon_index_template[ 'mode' ],
"value" => json_encode($addon_index_template[ 'data' ]),
"is_default" => 1,
"is_change" => 0
]);
$diy_page_list = $diy_service->getList([
[ 'site_id', '=', $params[ 'site_id' ] ],
[ 'type', '=', $params[ 'key' ] ]
], 'id,name,type');
// 多应用时,将首页和个人中心设为系统的
foreach ($diy_page_list as $k => $v) {
if ($v[ 'name' ] == $params[ 'key' ]) {
$diy_service->setUse($v[ 'id' ]);
break;
}
}
if ($params[ 'is_start' ] == 1) {
// 查询链接,设置启动页
$other_page = ( new DiyRouteService() )->getList([ 'url' => $addon_template_info[ 'page' ], 'addon' => $addon ]);
if (!empty($other_page)) {
$diy_service->changeTemplate([
'type' => $params[ 'key' ], // 页面类型
'name' => $other_page[ 0 ][ 'name' ], // 链接名称标识
'parent' => $other_page[ 0 ][ 'parent' ], // 链接父级名称标识
'page' => $other_page[ 0 ][ 'page' ], // 链接路由
'title' => $other_page[ 0 ][ 'title' ], // 链接标题
'action' => $other_page[ 0 ][ 'action' ] // 是否存在操作decorate 表示支持装修
]);
}
}
}
}
}

View File

@ -12,9 +12,6 @@
namespace app\model\dict;
use core\base\BaseModel;
use think\model\concern\SoftDelete;
use think\model\relation\HasMany;
use think\model\relation\HasOne;
/**
* 数据字典模型
@ -24,8 +21,6 @@ use think\model\relation\HasOne;
class Dict extends BaseModel
{
/**
* 数据表主键
* @var string
@ -43,7 +38,7 @@ class Dict extends BaseModel
];
// 设置json类型字段
protected $json = ['dictionary'];
protected $json = [ 'dictionary' ];
// 设置JSON数据返回数组
protected $jsonAssoc = true;
@ -71,7 +66,4 @@ class Dict extends BaseModel
}
}
}

View File

@ -11,7 +11,6 @@
namespace app\model\member;
use app\service\core\member\CoreMemberService;
use core\base\BaseModel;
/**

View File

@ -41,24 +41,10 @@ class SysNoticeLog extends BaseModel
];
// 设置json类型字段
protected $json = ['params', 'content'];
protected $json = [ 'params', 'content' ];
// 设置JSON数据返回数组
protected $jsonAssoc = true;
/**
* 名称
* @param $value
* @param $data
* @return string
*/
public function getContentAttr($value, $data)
{
if ($value) {
$temp = json_decode($value, true);
}
return $temp ?? $value;
}
/**
* 名称
* @param $value
@ -68,9 +54,9 @@ class SysNoticeLog extends BaseModel
public function getNameAttr($value, $data)
{
$name = '';
if (!empty($data['key'])) {
$temp = NoticeDict::getNotice()[$data['key']] ?? [];
$name = $temp['name'] ?? '';
if (!empty($data[ 'key' ])) {
$temp = NoticeDict::getNotice()[ $data[ 'key' ] ] ?? [];
$name = $temp[ 'name' ] ?? '';
}
return $name;
}
@ -84,9 +70,9 @@ class SysNoticeLog extends BaseModel
public function getNoticeTypeNameAttr($value, $data)
{
$name = '';
if (!empty($data['notice_type'])) {
$temp = NoticeTypeDict::getType()[$data['notice_type']] ?? [];
$name = $temp['name'] ?? '';
if (!empty($data[ 'notice_type' ])) {
$temp = NoticeTypeDict::getType()[ $data[ 'notice_type' ] ] ?? [];
$name = $temp[ 'name' ] ?? '';
}
return $name;
}
@ -125,14 +111,14 @@ class SysNoticeLog extends BaseModel
*/
public function searchCreateTimeAttr(Query $query, $value, $data)
{
$start_time = empty($value[0]) ? 0 : strtotime($value[0]);
$end_time = empty($value[1]) ? 0 : strtotime($value[1]);
$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('create_time', $start_time, $end_time);
} else if ($start_time > 0 && $end_time == 0) {
$query->where([['create_time', '>=', $start_time]]);
$query->where([ [ 'create_time', '>=', $start_time ] ]);
} else if ($start_time == 0 && $end_time > 0) {
$query->where([['create_time', '<=', $end_time]]);
$query->where([ [ 'create_time', '<=', $end_time ] ]);
}
}

View File

@ -13,9 +13,6 @@ namespace app\model\sys;
use app\dict\sys\PrinterDict;
use core\base\BaseModel;
use think\model\concern\SoftDelete;
use think\model\relation\HasMany;
use think\model\relation\HasOne;
/**
* 小票打印模板模型

View File

@ -11,7 +11,6 @@
namespace app\model\sys;
use app\dict\sys\RoleStatusDict;
use app\dict\sys\UserDict;
use core\base\BaseModel;
use think\model\concern\SoftDelete;
@ -108,7 +107,7 @@ class SysUser extends BaseModel
public function getStatusNameAttr($value, $data)
{
if (empty($data['status'])) return '';
return RoleStatusDict::getStatus()[$data['status']] ?? '';
return UserDict::getStatus()[$data['status']] ?? '';
}
/**

View File

@ -11,7 +11,6 @@
namespace app\model\verify;
use app\dict\verify\VerifyDict;
use app\model\member\Member;
use core\base\BaseModel;

View File

@ -18,9 +18,7 @@ use app\model\site\Site;
use app\model\sys\SysMenu;
use app\service\admin\addon\AddonService;
use app\service\admin\site\SiteService;
use app\service\core\addon\CoreAddonService;
use core\base\BaseAdminService;
use think\Collection;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
@ -41,9 +39,10 @@ class AuthSiteService extends BaseAdminService
/**
* 获取授权当前的站点信息
*/
public function getSiteInfo(){
public function getSiteInfo()
{
//通过用户id获取
return (new SiteService())->getSiteCache($this->site_id);
return ( new SiteService() )->getSiteCache($this->site_id);
}
@ -53,8 +52,9 @@ class AuthSiteService extends BaseAdminService
* @param int|string $status
* @return mixed
*/
public function getMenuList(int $is_tree, int|string $status, $addon = 'all', int $is_button = 1){
return (new SiteService())->getMenuList($this->site_id, $is_tree, $status, $addon, $is_button);
public function getMenuList(int $is_tree, $status, $addon = 'all', int $is_button = 1)
{
return ( new SiteService() )->getMenuList($this->site_id, $is_tree, $status, $addon, $is_button);
}
/**
@ -62,8 +62,9 @@ class AuthSiteService extends BaseAdminService
* @param int|string $status
* @return mixed
*/
public function getApiList(int|string $status){
return (new SiteService())->getApiList($this->site_id, $status);
public function getApiList($status)
{
return ( new SiteService() )->getApiList($this->site_id, $status);
}
/**
@ -73,9 +74,10 @@ class AuthSiteService extends BaseAdminService
* @throws DbException
* @throws ModelNotFoundException
*/
public function getShowMenuList(){
$menu_keys = (new SiteService())->getMenuIdsBySiteId($this->site_id, 1);
return (new SysMenu())->where([['menu_key', 'in', $menu_keys], ['menu_type', '=', MenuTypeDict::MENU], ['app_type', '=', AppTypeDict::SITE],['is_show', '=', 1]])->select()->toArray();
public function getShowMenuList()
{
$menu_keys = ( new SiteService() )->getMenuIdsBySiteId($this->site_id, 1);
return ( new SysMenu() )->where([ [ 'menu_key', 'in', $menu_keys ], [ 'menu_type', '=', MenuTypeDict::MENU ], [ 'app_type', '=', AppTypeDict::SITE ], [ 'is_show', '=', 1 ] ])->select()->toArray();
}
/**
@ -85,7 +87,8 @@ class AuthSiteService extends BaseAdminService
* @throws DbException
* @throws ModelNotFoundException
*/
public function getAuthAddonList(){
return (new AddonService())->getAddonListBySiteId($this->site_id);
public function getAuthAddonList()
{
return ( new AddonService() )->getAddonListBySiteId($this->site_id);
}
}

View File

@ -73,13 +73,18 @@ class LoginService extends BaseAdminService
$this->request->uid($userinfo->uid);
$auth_site_service = (new HomeAuthSiteService());
$user_role_service = new UserRoleService();
$default_site_id = 0;
if($app_type == AppTypeDict::ADMIN){
$default_site_id = $this->request->defaultSiteId();
$userrole = (new UserRoleService())->getUserRole($default_site_id, $userinfo->uid);
$userrole = $user_role_service->getUserRole($default_site_id, $userinfo->uid);
if (!empty($userrole)) {
if (!$userrole['status']) throw new AuthException('USER_LOCK');
if (!$userrole['is_admin']) {
$rules = $user_role_service->getRoleByUserRoleIds($userrole['role_ids'], $default_site_id);
if (empty($rules) || count($rules) == 0) throw new AuthException('USER_LOCK');
}
} else {
$app_type = AppTypeDict::SITE;
}
@ -88,6 +93,16 @@ class LoginService extends BaseAdminService
if(!empty($site_ids)){
$default_site_id = in_array($this->site_id, $site_ids) || AuthService::isSuperAdmin() ? $this->site_id : $site_ids[0];
}
if (!empty($default_site_id)) {
$userrole = $user_role_service->getUserRole($default_site_id, $userinfo->uid);
if (!empty($userrole)) {
if (!$userrole['status']) throw new AuthException('USER_LOCK');
if (!$userrole['is_admin']) {
$rules = $user_role_service->getRoleByUserRoleIds($userrole['role_ids'], $default_site_id);
if (empty($rules) || count($rules) == 0) throw new AuthException('USER_LOCK');
}
}
}
} else {
throw new AuthException('APP_TYPE_NOT_EXIST');
}

View File

@ -17,6 +17,7 @@ use app\dict\diy\PagesDict;
use app\dict\diy\TemplateDict;
use app\model\diy\Diy;
use app\service\admin\sys\SystemService;
use app\service\core\diy\CoreDiyConfigService;
use core\base\BaseAdminService;
use core\exception\AdminException;
use Exception;
@ -158,7 +159,10 @@ class DiyService extends BaseAdminService
public function edit(int $id, array $data)
{
$data[ 'update_time' ] = time();
$this->model->where([ [ 'id', '=', $id ], [ 'site_id', '=', $this->site_id ] ])->update($data);
if (empty($data[ 'site_id' ])) {
$data[ 'site_id' ] = $this->site_id;
}
$this->model->where([ [ 'id', '=', $id ], [ 'site_id', '=', $data[ 'site_id' ] ] ])->update($data);
return true;
}
@ -446,11 +450,12 @@ class DiyService extends BaseAdminService
* 获取默认页面数据
* @param $type
* @param string $addon
* @param int $site_id
* @return array|mixed
*/
public function getFirstPageData($type, $addon = '')
public function getFirstPageData($type, $addon = '', $site_id = 0)
{
$pages = PagesDict::getPages([ 'type' => $type, 'addon' => $addon ]);
$pages = PagesDict::getPages([ 'type' => $type, 'addon' => $addon, 'site_id' => $site_id ]);
if (!empty($pages)) {
$template = array_key_first($pages);
$page = array_shift($pages);
@ -576,4 +581,148 @@ class DiyService extends BaseAdminService
return $page_template;
}
/**
* 更新微页面数据
* @param $params
* @throws Exception
*/
public function loadDiyData($params)
{
$count = count($params[ 'main_app' ]);
$addon = array_merge([ '' ], $params[ 'main_app' ]);
foreach ($addon as $k => $v) {
if ($count > 1) {
// 站点多应用,使用系统的页面
if ($k == 0) {
$is_start = 1;
} else {
$is_start = 0;
}
} else {
// 站点单应用,将应用的设为使用中
if ($k == 0) {
$is_start = 0;
} else {
$is_start = 1;
}
}
// 设置 首页 默认模板
$this->setDiyData([
'key' => 'DIY_INDEX',
'type' => 'index',
'addon' => $v,
'is_start' => $is_start,
'site_id' => $params[ 'site_id' ],
'main_app' => $addon
]);
// 设置 个人中心 默认模板
$this->setDiyData([
'key' => 'DIY_MEMBER_INDEX',
'type' => 'member_index',
'addon' => $v,
'is_start' => $is_start,
'site_id' => $params[ 'site_id' ],
'main_app' => $addon
]);
}
}
/**
* 设置 首页/个人中心 的第一个模板 设置为启动页
* @param $params
* @throws Exception
*/
private function setDiyData($params)
{
$addon = $params[ 'addon' ] ?? '';
$addon_flag = $params[ 'key' ];
// 默认
$default_template = TemplateDict::getTemplate([
'key' => [ $params[ 'key' ] ]
]);
$addon_template_info = array_shift($default_template);
// 查询插件定义的页面类型
$addon_template = TemplateDict::getTemplate([
'type' => $params[ 'type' ],
'addon' => $addon
]);
if (!empty($addon_template)) {
$addon_flag = array_keys($addon_template)[ 0 ];
$addon_template_info = array_shift($addon_template);
}
$addon_index_template = $this->getFirstPageData($addon_flag, $addon, $params[ 'site_id' ]);
$field = 'id,title,page_title,name,template,type,mode,value,is_default,is_change';
$info = $this->model->field($field)->where([ [ 'name', '=', $addon_flag ], [ 'site_id', '=', $params[ 'site_id' ] ], [ 'is_default', '=', 1 ] ])->findOrEmpty()->toArray();
if (!empty($addon_index_template)) {
if (empty($info)) {
$this->add([
'site_id' => $params[ 'site_id' ],
'page_title' => $addon_index_template[ 'title' ],
"title" => $addon_index_template[ 'title' ],
"name" => $addon_flag,
"type" => $addon_flag,
"template" => $addon_index_template[ 'template' ],
"mode" => $addon_index_template[ 'mode' ],
"value" => json_encode($addon_index_template[ 'data' ]),
"is_default" => 1,
"is_change" => 0
]);
} else {
// 针对 多应用首页的数据更新
if ($info[ 'name' ] == 'DIY_INDEX' && $info[ 'type' ] == 'DIY_INDEX') {
$this->edit($info[ 'id' ], [
'site_id' => $params[ 'site_id' ],
"value" => json_encode($addon_index_template[ 'data' ])
]);
}
}
$diy_page_list = $this->model->where([
[ 'site_id', '=', $params[ 'site_id' ] ],
[ 'type', '=', $params[ 'key' ] ] ])->field('id,name,type')->order('update_time desc')->select()->toArray();
// 多应用时,将首页和个人中心设为系统的
foreach ($diy_page_list as $k => $v) {
if ($v[ 'name' ] == $params[ 'key' ]) {
$this->model->where([ [ 'name', '=', $v[ 'name' ] ], [ 'site_id', '=', $params[ 'site_id' ] ] ])->update([ 'is_default' => 0 ]);
$this->model->where([ [ 'id', '=', $v[ 'id' ] ], [ 'site_id', '=', $params[ 'site_id' ] ] ])->update([ 'is_default' => 1, 'update_time' => time() ]);
break;
}
}
if ($params[ 'is_start' ] == 1) {
// 查询链接,设置启动页
$other_page = ( new DiyRouteService() )->getList([ 'url' => $addon_template_info[ 'page' ], 'addon' => $addon ]);
if (!empty($other_page)) {
( new CoreDiyConfigService() )->setStartUpPageConfig($params[ 'site_id' ], [
'type' => $params[ 'key' ], // 页面类型
'name' => $other_page[ 0 ][ 'name' ], // 链接名称标识
'parent' => $other_page[ 0 ][ 'parent' ], // 链接父级名称标识
'page' => $other_page[ 0 ][ 'page' ], // 链接路由
'title' => $other_page[ 0 ][ 'title' ], // 链接标题
'action' => $other_page[ 0 ][ 'action' ] // 是否存在操作decorate 表示支持装修
]);
}
}
}
}
}

View File

@ -11,7 +11,6 @@
namespace app\service\admin\generator;
use app\model\addon\Addon;
use app\model\generator\GenerateColumn;
use app\model\generator\GenerateTable;
use core\base\BaseAdminService;
@ -23,7 +22,6 @@ use think\db\exception\ModelNotFoundException;
use think\facade\Db;
use think\helper\Str;
use think\Model;
use think\model\relation\HasOne;
/**

View File

@ -11,9 +11,6 @@
namespace app\service\admin\generator\core;
use app\dict\sys\MenuDict;
use app\model\sys\SysMenu;
use think\facade\Cache;
use think\helper\Str;
/**

View File

@ -15,7 +15,6 @@ namespace app\service\admin\generator\core;
use app\service\core\menu\CoreMenuService;
use think\helper\Str;
/**

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

@ -16,7 +16,6 @@ use app\dict\member\MemberRegisterTypeDict;
use app\model\member\Member;
use app\service\admin\sys\ExportService;
use app\service\core\member\CoreMemberService;
use app\service\core\sys\CoreExportService;
use core\base\BaseAdminService;
use core\dict\DictLoader;
use core\exception\AdminException;

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.site_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)->where([['member_sign.site_id', '=', $this->site_id]])->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)->where([ [ 'member_sign.site_id', '=', $this->site_id ] ])->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($this->site_id, $data['day_award']);
if (!empty($data[ 'day_award' ])) {
$data[ 'day_award' ] = ( new CoreMemberService() )->getGiftContent($this->site_id, $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($this->site_id, $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($this->site_id, $gift);
}
return $data;
}
@ -73,7 +73,7 @@ class MemberSignService extends BaseAdminService
public function getInfo(int $sign_id)
{
$field = 'sign_id, site_id, member_id, days, day_award, continue_award, continue_tag, create_time, is_sign';
return $this->model->where([['sign_id', '=', $sign_id], ['site_id', '=', $this->site_id]])->field($field)->append(['is_sign_name'])->findOrEmpty()->toArray();
return $this->model->where([ [ 'sign_id', '=', $sign_id ], [ 'site_id', '=', $this->site_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

@ -12,10 +12,8 @@
namespace app\service\admin\pay;
use app\dict\pay\PayDict;
use app\model\pay\Pay;
use app\model\pay\Refund;
use app\service\core\pay\CoreRefundService;
use app\service\core\paytype\CoreOfflineService;
use core\base\BaseAdminService;
/**

View File

@ -15,6 +15,8 @@ use app\model\addon\Addon;
use app\model\site\Site;
use app\model\site\SiteGroup;
use app\model\sys\SysMenu;
use app\service\admin\diy\DiyService;
use app\service\admin\sys\ConfigService;
use app\service\admin\sys\MenuService;
use app\service\core\addon\CoreAddonService;
use app\service\core\site\CoreSiteService;
@ -36,6 +38,7 @@ class SiteGroupService extends BaseAdminService
{
public static $cache_tag_name = 'site_group_cache';
public static $cache_name = 'site_group_menu_ids';
public function __construct()
{
parent::__construct();
@ -50,7 +53,7 @@ class SiteGroupService extends BaseAdminService
public function getPage(array $where = [])
{
$field = 'group_id, group_name, group_desc, app, addon, create_time, update_time';
$search_model = $this->model->withSearch(['keywords'],$where)->field($field)->append(['app_name', 'addon_name'])->order('create_time desc');
$search_model = $this->model->withSearch([ 'keywords' ], $where)->field($field)->append([ 'app_name', 'addon_name' ])->order('create_time desc');
$list = $this->pageQuery($search_model);
return $list;
}
@ -65,7 +68,7 @@ class SiteGroupService extends BaseAdminService
public function getAll()
{
$field = 'group_id, group_name, group_desc, create_time, update_time, app';
return $this->model->field($field)->select()->toArray();
return $this->model->field($field)->order('create_time desc')->select()->toArray();
}
/**
@ -76,7 +79,7 @@ class SiteGroupService extends BaseAdminService
public function getInfo(int $group_id)
{
$field = 'group_id, group_name, group_desc, app, addon, create_time, update_time';
return $this->model->where([['group_id', '=', $group_id]])->field($field)->findOrEmpty()->toArray();
return $this->model->where([ [ 'group_id', '=', $group_id ] ])->field($field)->findOrEmpty()->toArray();
}
@ -88,7 +91,7 @@ class SiteGroupService extends BaseAdminService
public function add(array $data)
{
//判断应用是否全部是有效的已安装应用
$this->checkAddon(array_merge($data['app'], $data['addon']));
$this->checkAddon(array_merge($data[ 'app' ], $data[ 'addon' ]));
$res = $this->model->create($data);
return $res->group_id;
}
@ -99,24 +102,32 @@ class SiteGroupService extends BaseAdminService
* @param array $data
* @return true
*/
public function edit(int $group_id, array $data){
$group = $this->model->where([['group_id', '=', $group_id]])->findOrEmpty()->toArray();
public function edit(int $group_id, array $data)
{
$group = $this->model->where([ [ 'group_id', '=', $group_id ] ])->findOrEmpty()->toArray();
//判断应用是否全部是有效的已安装应用
$this->checkAddon(array_merge($data['app'], $data['addon']));
$this->model->update($data, [['group_id', '=', $group_id]]);
$this->checkAddon(array_merge($data[ 'app' ], $data[ 'addon' ]));
$this->model->update($data, [ [ 'group_id', '=', $group_id ] ]);
//删除缓存
$cache_name = self::$cache_name . $group_id;
Cache::delete($cache_name);
$site_list = (new Site())->field('site_id,initalled_addon')->where([ ['group_id', '=', $group_id] ])->select()->toArray();
$site_list = ( new Site() )->field('site_id,initalled_addon')->where([ [ 'group_id', '=', $group_id ] ])->select()->toArray();
if (!empty($site_list)) {
sort($data['app']); sort($group['app']); sort($data['addon']); sort($group['addon']);
sort($data[ 'app' ]);
sort($group[ 'app' ]);
sort($data[ 'addon' ]);
sort($group[ 'addon' ]);
if (json_encode($data['app']) != json_encode($group['app']) || json_encode($data['addon']) != json_encode($group['addon'])) {
if (json_encode($data[ 'app' ]) != json_encode($group[ 'app' ]) || json_encode($data[ 'addon' ]) != json_encode($group[ 'addon' ])) {
foreach ($site_list as $site) {
$this->siteAddonsChange($site, $group, $data);
Cache::tag(CoreSiteService::$cache_tag_name . $site['site_id'])->clear();
Cache::tag(CoreSiteService::$cache_tag_name . $site[ 'site_id' ])->clear();
// 更新微页面数据
$diy_service = new DiyService();
$diy_service->loadDiyData([ 'site_id' => $site[ 'site_id' ], 'main_app' => $data[ 'app' ] ]);
}
}
}
@ -131,25 +142,28 @@ class SiteGroupService extends BaseAdminService
* @param $new_group
* @return void
*/
public function siteAddonsChange($site_info, $old_group, $new_group) {
$initalled_addon = $site_info['initalled_addon'];
public function siteAddonsChange($site_info, $old_group, $new_group)
{
$initalled_addon = $site_info[ 'initalled_addon' ];
if (empty($initalled_addon)) {
$initalled_addon = array_merge($old_group['app'], $old_group['addon']);
$initalled_addon = array_merge($old_group[ 'app' ], $old_group[ 'addon' ]);
}
//添加站点成功事件
event("AddSiteAfter", [ 'site_id' => $site_info['site_id'], 'main_app' => array_diff($new_group['app'], $initalled_addon) , 'site_addons' => array_diff($new_group['addon'], $initalled_addon) ]);
// 添加站点成功事件
event("AddSiteAfter", [ 'site_id' => $site_info[ 'site_id' ], 'main_app' => array_diff($new_group[ 'app' ], $initalled_addon), 'site_addons' => array_diff($new_group[ 'addon' ], $initalled_addon) ]);
$initalled_addon = array_values(array_unique(array_merge($initalled_addon, $new_group['app'], $new_group['addon'])));
(new Site())->update(['app' => $new_group['app'], 'initalled_addon' => $initalled_addon], [ ['site_id', '=', $site_info['site_id'] ] ]);
$initalled_addon = array_values(array_unique(array_merge($initalled_addon, $new_group[ 'app' ], $new_group[ 'addon' ])));
( new Site() )->update([ 'app' => $new_group[ 'app' ], 'initalled_addon' => $initalled_addon ], [ [ 'site_id', '=', $site_info[ 'site_id' ] ] ]);
}
public function checkAddon($group_roles){
$install_addon_list = (new CoreAddonService())->getInstallAddonList();
public function checkAddon($group_roles)
{
$install_addon_list = ( new CoreAddonService() )->getInstallAddonList();
$install_addon_keys = array_column($install_addon_list, 'key');
if(count(array_intersect($install_addon_keys, $group_roles)) != count($group_roles)) throw new AdminException('SITE_GROUP_APP_NOT_EXIST');
if (count(array_intersect($install_addon_keys, $group_roles)) != count($group_roles)) throw new AdminException('SITE_GROUP_APP_NOT_EXIST');
return true;
}
/**
* 删除分组
* @param int $group_id
@ -158,12 +172,11 @@ class SiteGroupService extends BaseAdminService
*/
public function del(int $group_id)
{
$count = (new Site())->where([['group_id', '=', $group_id]])->count();
if($count > 0)
{
$count = ( new Site() )->where([ [ 'group_id', '=', $group_id ] ])->count();
if ($count > 0) {
throw new CommonException('SITE_GROUP_IS_EXIST');
}
$res = $this->model->where([['group_id', '=', $group_id]])->delete();
$res = $this->model->where([ [ 'group_id', '=', $group_id ] ])->delete();
$cache_name = self::$cache_name . $group_id;
Cache::delete($cache_name);
@ -175,19 +188,20 @@ class SiteGroupService extends BaseAdminService
* @param $group_id
* @return void
*/
public function getGroupAddon($group_id){
public function getGroupAddon($group_id)
{
$cache_name = self::$cache_name . $group_id;
return cache_remember(
$cache_name,
function () use ($group_id) {
function() use ($group_id) {
$group = $this->model->findOrEmpty($group_id);
$addon = [];
if (!$group->isEmpty()) {
$addon = array_merge($group['app'], $group['addon']);
$addon = array_merge($group[ 'app' ], $group[ 'addon' ]);
}
return $addon;
},
[MenuService::$cache_tag_name,self::$cache_tag_name]
[ MenuService::$cache_tag_name, self::$cache_tag_name ]
);
}
@ -214,11 +228,12 @@ class SiteGroupService extends BaseAdminService
* @throws DbException
* @throws ModelNotFoundException
*/
public function getUserSiteGroupAll($uid) {
public function getUserSiteGroupAll($uid)
{
$field = 'group_id, group_name, group_desc, create_time, update_time, app';
$list = $this->model->field($field)->select()->toArray();
foreach ($list as &$item) {
$item['site_num'] = self::getUserSiteGroupSiteNum($uid, $item['group_id']);
$item[ 'site_num' ] = self::getUserSiteGroupSiteNum($uid, $item[ 'group_id' ]);
}
return $list;
}
@ -229,13 +244,14 @@ class SiteGroupService extends BaseAdminService
* @param $group_id
* @return void
*/
public static function getUserSiteGroupSiteNum($uid, $group_id) {
public static function getUserSiteGroupSiteNum($uid, $group_id)
{
return Db::name("sys_user_role")->alias('sur')
->join('site s', 'sur.site_id = s.site_id')
->where([
['sur.uid', '=', $uid],
['sur.is_admin', '=', 1],
['s.group_id', '=', $group_id]
[ 'sur.uid', '=', $uid ],
[ 'sur.is_admin', '=', 1 ],
[ 's.group_id', '=', $group_id ]
])->count();
}

View File

@ -20,6 +20,7 @@ use app\model\site\SiteGroup;
use app\model\sys\SysUserRole;
use app\service\admin\addon\AddonService;
use app\service\admin\auth\AuthService;
use app\service\admin\diy\DiyService;
use app\service\admin\generator\GenerateService;
use app\service\admin\sys\MenuService;
use app\service\admin\sys\RoleService;
@ -65,11 +66,11 @@ class SiteService extends BaseAdminService
$condition = [
[ 'app_type', '<>', 'admin' ]
];
$search_model = $this->model->where($condition)->withSearch([ 'create_time', 'expire_time', 'keywords', 'status', 'group_id', 'app', 'site_domain' ], $where)->with(['groupName'])->field($field)->append([ 'status_name' ])->order('create_time desc');
return $this->pageQuery($search_model, function ($item){
$item['admin'] = (new SysUserRole())->where([ ['site_id', '=', $item['site_id'] ], ['is_admin', '=', 1] ])
$search_model = $this->model->where($condition)->withSearch([ 'create_time', 'expire_time', 'keywords', 'status', 'group_id', 'app', 'site_domain' ], $where)->with([ 'groupName' ])->field($field)->append([ 'status_name' ])->order('create_time desc');
return $this->pageQuery($search_model, function($item) {
$item[ 'admin' ] = ( new SysUserRole() )->where([ [ 'site_id', '=', $item[ 'site_id' ] ], [ 'is_admin', '=', 1 ] ])
->field('uid')
->with(['userinfo'])
->with([ 'userinfo' ])
->find()->toArray();
});
}
@ -85,8 +86,8 @@ class SiteService extends BaseAdminService
district_id, address, full_address, phone, business_hours, create_time, expire_time, group_id, app, addons, site_domain';
$info = $this->model->where([ [ 'site_id', '=', $site_id ] ])->with([ 'groupName' ])->field($field)->append([ 'status_name' ])->findOrEmpty()->toArray();
if (!empty($info)) {
$site_addons = (new CoreSiteService())->getAddonKeysBySiteId($site_id);
$info['site_addons'] = (new Addon())->where([ ['key', 'in', $site_addons]])->field('key,title,desc,icon,type')->select()->toArray();
$site_addons = ( new CoreSiteService() )->getAddonKeysBySiteId($site_id);
$info[ 'site_addons' ] = ( new Addon() )->where([ [ 'key', 'in', $site_addons ] ])->field('key,title,desc,icon,type')->select()->toArray();
}
return $info;
}
@ -100,7 +101,7 @@ class SiteService extends BaseAdminService
*/
public function add(array $data)
{
$site_group = (new SiteGroup())->where([ ['group_id', '=', $data[ 'group_id' ] ] ])->field('app,addon')->findOrEmpty();
$site_group = ( new SiteGroup() )->where([ [ 'group_id', '=', $data[ 'group_id' ] ] ])->field('app,addon')->findOrEmpty();
if ($site_group->isEmpty()) throw new CommonException('SITE_GROUP_NOT_EXIST');
$data[ 'app_type' ] = 'site';
@ -111,7 +112,7 @@ class SiteService extends BaseAdminService
'group_id' => $data[ 'group_id' ],
'create_time' => time(),
'expire_time' => $data[ 'expire_time' ],
'app' => $site_group['app'],
'app' => $site_group[ 'app' ],
'addons' => ''
];
Db::startTrans();
@ -119,8 +120,8 @@ class SiteService extends BaseAdminService
$site = $this->model->create($data_site);
$site_id = $site->site_id;
if ($data['uid']) {
(new UserRoleService())->add($data['uid'], ['role_ids' => '', 'is_admin' => 1], $site_id);
if ($data[ 'uid' ]) {
( new UserRoleService() )->add($data[ 'uid' ], [ 'role_ids' => '', 'is_admin' => 1 ], $site_id);
} else {
//添加用户
$data_user = [
@ -132,19 +133,23 @@ class SiteService extends BaseAdminService
'role_ids' => '',
'is_admin' => 1
];
$data['uid'] = ( new UserService() )->addSiteUser($data_user, $site_id);
$data[ 'uid' ] = ( new UserService() )->addSiteUser($data_user, $site_id);
}
//添加站点成功事件
event("AddSiteAfter", [ 'site_id' => $site_id, 'main_app' => $site_group['app'], 'site_addons' => $site_group['addon'] ]);
event("AddSiteAfter", [ 'site_id' => $site_id, 'main_app' => $site_group[ 'app' ], 'site_addons' => $site_group[ 'addon' ] ]);
Cache::delete('user_role_list_' . $data['uid']);
// 更新微页面数据
$diy_service = new DiyService();
$diy_service->loadDiyData([ 'site_id' => $site_id, 'main_app' => $site_group[ 'app' ] ]);
Cache::delete('user_role_list_' . $data[ 'uid' ]);
Db::commit();
return $site_id;
} catch ( Exception $e) {
} catch (Exception $e) {
Db::rollback();
throw new AdminException($e->getMessage().$e->getFile().$e->getLine());
throw new AdminException($e->getMessage() . $e->getFile() . $e->getLine());
}
}
@ -156,37 +161,37 @@ class SiteService extends BaseAdminService
*/
public function edit(int $site_id, array $data)
{
$site = $this->model->where([ [ 'site_id', '=', $site_id ] ])->with(['site_group'])->findOrEmpty();
$site = $this->model->where([ [ 'site_id', '=', $site_id ] ])->with([ 'site_group' ])->findOrEmpty();
if ($site->isEmpty()) throw new AdminException('SITE_NOT_EXIST');
Db::startTrans();
try {
if (isset($data[ 'group_id' ]) && $site['group_id'] != $data[ 'group_id' ]) {
$old_site_group = $site['site_group'];
if (isset($data[ 'group_id' ]) && $site[ 'group_id' ] != $data[ 'group_id' ]) {
$old_site_group = $site[ 'site_group' ];
$site_group = (new SiteGroup())->where([ ['group_id', '=', $data[ 'group_id' ] ] ])->field('app,addon')->findOrEmpty();
$data['app'] = $site_group['app'];
$site_group = ( new SiteGroup() )->where([ [ 'group_id', '=', $data[ 'group_id' ] ] ])->field('app,addon')->findOrEmpty();
$data[ 'app' ] = $site_group[ 'app' ];
if (empty($site->initalled_addon)) {
$site->initalled_addon = array_merge($old_site_group['app'], $old_site_group['addon']);
$site->initalled_addon = array_merge($old_site_group[ 'app' ], $old_site_group[ 'addon' ]);
}
//添加站点成功事件
event("AddSiteAfter", [ 'site_id' => $site_id, 'main_app' => array_diff($site_group['app'], $site->initalled_addon) , 'site_addons' => array_diff($site_group['addon'], $site->initalled_addon) ]);
event("AddSiteAfter", [ 'site_id' => $site_id, 'main_app' => array_diff($site_group[ 'app' ], $site->initalled_addon), 'site_addons' => array_diff($site_group[ 'addon' ], $site->initalled_addon) ]);
$data['initalled_addon'] = array_values(array_unique(array_merge($site->initalled_addon, $site_group['app'], $site_group['addon'])));
$data[ 'initalled_addon' ] = array_values(array_unique(array_merge($site->initalled_addon, $site_group[ 'app' ], $site_group[ 'addon' ])));
}
if (isset($data['expire_time']) && $site['status'] != SiteDict::CLOSE) {
$data['status'] = strtotime($data['expire_time']) > time() ? SiteDict::ON : SiteDict::EXPIRE;
if (isset($data[ 'expire_time' ]) && !empty($data[ 'expire_time' ])) {
$data[ 'status' ] = strtotime($data[ 'expire_time' ]) > time() ? SiteDict::ON : SiteDict::EXPIRE;
}
$site->save($data);
Cache::tag(self::$cache_tag_name . $site_id)->clear();
Db::commit();
return true;
} catch ( Exception $e) {
} catch (Exception $e) {
Db::rollback();
throw new AdminException($e->getMessage().$e->getFile().$e->getLine());
throw new AdminException($e->getMessage() . $e->getFile() . $e->getLine());
}
}
@ -194,17 +199,18 @@ class SiteService extends BaseAdminService
* 删除站点
* @param int $site_id
*/
public function del(int $site_id) {
public function del(int $site_id)
{
Db::startTrans();
try {
$site = $this->model->where([ [ 'site_id', '=', $site_id ] ])->findOrEmpty()->toArray();
// 删除站点相关数据
$sys_models = (new GenerateService())->getModels(['addon' => 'system']);
$sys_models = ( new GenerateService() )->getModels([ 'addon' => 'system' ]);
$addon_models = [];
$addons = (new CoreSiteService())->getAddonKeysBySiteId($site_id);
foreach($addons as $addon) {
$addon_models[] = (new GenerateService())->getModels(['addon' => $addon ]);
$addons = ( new CoreSiteService() )->getAddonKeysBySiteId($site_id);
foreach ($addons as $addon) {
$addon_models[] = ( new GenerateService() )->getModels([ 'addon' => $addon ]);
}
$models = array_merge($sys_models, ...$addon_models);
@ -213,7 +219,7 @@ class SiteService extends BaseAdminService
$class = new $name();
if (in_array('site_id', $class->getTableFields())) {
$class->where([ ['site_id', '=', $site['site_id'] ] ])->delete();
$class->where([ [ 'site_id', '=', $site[ 'site_id' ] ] ])->delete();
}
}
@ -243,7 +249,7 @@ class SiteService extends BaseAdminService
*/
public function getSiteCache(int $site_id)
{
return (new CoreSiteService())->getSiteCache($site_id);
return ( new CoreSiteService() )->getSiteCache($site_id);
}
@ -268,16 +274,16 @@ class SiteService extends BaseAdminService
if (AuthService::isSuperAdmin()) {
$is_admin = 1;
} else {
$user_role_info = (new AuthService())->getAuthRole($this->site_id);
if(empty($user_role_info))
$user_role_info = ( new AuthService() )->getAuthRole($this->site_id);
if (empty($user_role_info))
return [];
$is_admin = $user_role_info['is_admin'];//是否是超级管理员组
$is_admin = $user_role_info[ 'is_admin' ];//是否是超级管理员组
}
if ($is_admin) {
return ( new MenuService() )->getAllMenuList($app_type, $status, $is_tree, $is_button);
} else {
$user_role_ids = $user_role_info['role_ids'];
$user_role_ids = $user_role_info[ 'role_ids' ];
$role_service = new RoleService();
$menu_keys = $role_service->getMenuIdsByRoleIds($this->site_id, $user_role_ids);
return ( new MenuService() )->getMenuListByMenuKeys($this->site_id, $menu_keys, $this->app_type, 1, is_button:$is_button);
@ -342,17 +348,19 @@ class SiteService extends BaseAdminService
* 获取站点的插件
* @return array
*/
public function getSiteAddons(array $where) {
$site_addon = (new CoreSiteService())->getAddonKeysBySiteId($this->site_id);
return (new Addon())->where([['type', '=', AddonDict::ADDON], ['status', '=', AddonDict::ON], ['key', 'in', $site_addon ]])->withSearch(['title'], $where)->append(['status_name'])->field('title, icon, key, desc, status, type, support_app')->select()->toArray();
public function getSiteAddons(array $where)
{
$site_addon = ( new CoreSiteService() )->getAddonKeysBySiteId($this->site_id);
return ( new Addon() )->where([ [ 'type', '=', AddonDict::ADDON ], [ 'status', '=', AddonDict::ON ], [ 'key', 'in', $site_addon ] ])->withSearch([ 'title' ], $where)->append([ 'status_name' ])->field('title, icon, key, desc, status, type, support_app')->select()->toArray();
}
/**
* 获取站点支持的应用插件
* @return array
*/
public function getAddonKeysBySiteId() {
$site_addon = (new CoreSiteService())->getAddonKeysBySiteId($this->site_id);
public function getAddonKeysBySiteId()
{
$site_addon = ( new CoreSiteService() )->getAddonKeysBySiteId($this->site_id);
return $site_addon;
}
}

View File

@ -51,7 +51,7 @@ class SiteUserService extends BaseAdminService
$condition = [];
if (isset($where['username']) && $where['username'] !== '') $condition[] = ['username', 'like', "%{$this->model->handelSpecialCharacter($where['username'])}%"];
$query->where($condition);
})->where([ ['SysUserRole.site_id', '=', $this->site_id ], ['is_admin', '=', 0 ] ]);
})->where([ ['SysUserRole.site_id', '=', $this->site_id ]]);
return $this->pageQuery($search_model, function ($item){
if (!empty($item['role_ids'])) {
$item['role_array'] = (new SysRole())->where([ ['role_id', 'in', $item['role_ids'] ] ])->column('role_name');

View File

@ -11,10 +11,8 @@
namespace app\service\admin\stat;
use app\model\order\RechargeOrder;
use app\service\admin\site\SiteService;
use core\base\BaseAdminService;
use think\db\exception\DbException;
/**
@ -34,56 +32,19 @@ class SiteStatService extends BaseAdminService
* 获取站点统计数据
* @return int[]
*/
public function getIndexData(){
public function getIndexData()
{
$data = [
'site_info' => '',
];
$data['site_info'] = (new SiteService())->getInfo($this->site_id);
$site_create_time = strtotime($data['site_info']['create_time']);
$site_expire_time = strtotime($data['site_info']['expire_time']);
$data['site_info']['mix'] = (number_format((time() - $site_create_time) / ($site_expire_time - $site_create_time), 2) * 100).'%';
$data['site_info']['over_date'] = $site_expire_time - time() > 0 ? number_format(($site_expire_time - time())/ 86400, 2) : 0;
$data[ 'site_info' ] = ( new SiteService() )->getInfo($this->site_id);
$site_create_time = strtotime($data[ 'site_info' ][ 'create_time' ]);
$site_expire_time = strtotime($data[ 'site_info' ][ 'expire_time' ]);
$data[ 'site_info' ][ 'mix' ] = ( number_format(( time() - $site_create_time ) / ( $site_expire_time - $site_create_time ), 2) * 100 ) . '%';
$data[ 'site_info' ][ 'over_date' ] = $site_expire_time - time() > 0 ? number_format(( $site_expire_time - time() ) / 86400, 2) : 0;
return $data;
}
/**
* 订单金额
* @param $start_time
* @param $end_time
* @return float
*/
public function orderMoney($start_time, $end_time)
{
$where[] = [
['site_id', '=', $this->site_id],
['order_status', '>', 0],
['create_time', 'between', [$start_time, $end_time]]
];
return (new RechargeOrder())->where($where)->sum('order_money');
}
/**
* 订单数量
* @param $start_time
* @param $end_time
* @return int
* @throws DbException
*/
public function orderCount($start_time, $end_time)
{
$where[] = [
['site_id', '=', $this->site_id],
['order_status', '>', 0],
['create_time', 'between', [$start_time, $end_time]]
];
return (new RechargeOrder())->where($where)->count('order_id');
}
}

View File

@ -39,7 +39,7 @@ class StatService extends BaseAdminService
/**
* 获取统计数据
* @return int[]
* @return array
* @throws DataNotFoundException
* @throws DbException
* @throws ModelNotFoundException
@ -66,7 +66,7 @@ class StatService extends BaseAdminService
'value' => []
],
'member_stat' => [
'type' => ['男', '女', '未知'],
'type' => [ '男', '女', '未知' ],
'value' => []
],
'site_group_stat' => [
@ -94,48 +94,48 @@ class StatService extends BaseAdminService
$day_start_time = strtotime(date('Y-m-d'));
//当天结束之间
$day_end_time = $day_start_time + 86400;
$data['today_data']['total_member_count'] = (new CoreMemberService())->getCount();
$data['today_data']['today_member_count'] = (new CoreMemberService())->getCount(['create_time' => get_start_and_end_time_by_day()]);
$data['today_data']['total_site_count'] = (new SiteService())->getCount();
$data['today_data']['today_site_count'] = (new SiteService())->getCount(['create_time' => [$day_start_time, $day_end_time]]);
$data['today_data']['norma_site_count'] = (new SiteService())->getCount(['status' => [1],'app_type' => ['site']]);
$data['today_data']['expire_site_count'] = (new SiteService())->getCount(['status' => [2]]);
$data['today_data']['week_expire_site_count'] = (new Site())->where([
['status', '=', 1],
['expire_time', 'BETWEEN', [time(), time() + 86400*7 ] ]
$data[ 'today_data' ][ 'total_member_count' ] = ( new CoreMemberService() )->getCount();
$data[ 'today_data' ][ 'today_member_count' ] = ( new CoreMemberService() )->getCount([ 'create_time' => get_start_and_end_time_by_day() ]);
$data[ 'today_data' ][ 'total_site_count' ] = ( new SiteService() )->getCount();
$data[ 'today_data' ][ 'today_site_count' ] = ( new SiteService() )->getCount([ 'create_time' => [ $day_start_time, $day_end_time ] ]);
$data[ 'today_data' ][ 'norma_site_count' ] = ( new SiteService() )->getCount([ 'status' => [ 1 ], 'app_type' => [ 'site' ] ]);
$data[ 'today_data' ][ 'expire_site_count' ] = ( new SiteService() )->getCount([ 'status' => [ 2 ] ]);
$data[ 'today_data' ][ 'week_expire_site_count' ] = ( new Site() )->where([
[ 'status', '=', 1 ],
[ 'expire_time', 'BETWEEN', [ time(), time() + 86400 * 7 ] ]
])->count();
$data['system'] = (new SystemService())->getInfo();
$data['version'] = $data['system']['version'] ?? [];
$data[ 'system' ] = ( new SystemService() )->getInfo();
$data[ 'version' ] = $data[ 'system' ][ 'version' ] ?? [];
$time = time();
for ($i = 1; $i <= 7; $i++){
for ($i = 1; $i <= 7; $i++) {
$item_day = date('Y-m-d', strtotime('+' . $i - 7 . ' days', $time));
$data['site_stat']['date'][] = $item_day;
$data['site_stat']['value'][] = (new Site())->where([['create_time','between',get_start_and_end_time_by_day($item_day)]])->count();
$data[ 'site_stat' ][ 'date' ][] = $item_day;
$data[ 'site_stat' ][ 'value' ][] = ( new Site() )->where([ [ 'create_time', 'between', get_start_and_end_time_by_day($item_day) ] ])->count();
$data['member_count_stat']['date'][] = $item_day;
$data['member_count_stat']['value'][] = (new Member())->where([['create_time','between',get_start_and_end_time_by_day($item_day)]])->count();
$data[ 'member_count_stat' ][ 'date' ][] = $item_day;
$data[ 'member_count_stat' ][ 'value' ][] = ( new Member() )->where([ [ 'create_time', 'between', get_start_and_end_time_by_day($item_day) ] ])->count();
}
$man_count = (new CoreMemberService())->getCount(['sex' => '1']);
$woman_count = (new CoreMemberService())->getCount(['sex' => '2']);
$data['member_stat']['value'] = [$man_count, $woman_count, (int)($data['today_data']['total_member_count'] - $man_count - $woman_count)];
$man_count = ( new CoreMemberService() )->getCount([ 'sex' => '1' ]);
$woman_count = ( new CoreMemberService() )->getCount([ 'sex' => '2' ]);
$data[ 'member_stat' ][ 'value' ] = [ $man_count, $woman_count, (int) ( $data[ 'today_data' ][ 'total_member_count' ] - $man_count - $woman_count ) ];
$site_group_list = (new SiteGroupService())->getAll([]);
$site_group_list = ( new SiteGroupService() )->getAll([]);
if(!empty($site_group_list)){
foreach($site_group_list as $v){
$data['site_group_stat']['type'][] = $v['group_name'];
$data['site_group_stat']['value'][] = (new SiteService())->getCount(['group_id' => $v['group_id']]);
if (!empty($site_group_list)) {
foreach ($site_group_list as $v) {
$data[ 'site_group_stat' ][ 'type' ][] = $v[ 'group_name' ];
$data[ 'site_group_stat' ][ 'value' ][] = ( new SiteService() )->getCount([ 'group_id' => $v[ 'group_id' ] ]);
}
}
$app_count = (new CoreAddonService())->getLocalAddonCount();
$app_installed_count = (new CoreAddonService())->getCount();
$app_count = ( new CoreAddonService() )->getLocalAddonCount();
$app_installed_count = ( new CoreAddonService() )->getCount();
$app = [
'app_count' => $app_count,
'app_no_installed_count' => $app_count-$app_installed_count,
'app_no_installed_count' => $app_count - $app_installed_count,
'app_installed_count' => $app_installed_count,
];
$data['app'] = $app;
$data[ 'app' ] = $app;
return $data;
}

View File

@ -34,6 +34,7 @@ class MenuService extends BaseAdminService
{
public static $cache_tag_name = 'menu_cache';
public function __construct()
{
parent::__construct();
@ -47,12 +48,12 @@ class MenuService extends BaseAdminService
*/
public function add(array $data)
{
$menu = $this->find($data['menu_key'], $data['app_type']);
if(!$menu->isEmpty()) throw new AdminException('validate_menu.exit_menu_key');//创建失败
$menu = $this->find($data[ 'menu_key' ], $data[ 'app_type' ]);
if (!$menu->isEmpty()) throw new AdminException('validate_menu.exit_menu_key');//创建失败
$data['source'] = MenuDict::CREATE;
$data[ 'source' ] = MenuDict::CREATE;
$res = $this->model->create($data);
if(!$res) throw new AdminException('ADD_FAIL');//创建失败
if (!$res) throw new AdminException('ADD_FAIL');//创建失败
Cache::tag(self::$cache_tag_name)->clear();
return $res;
@ -68,8 +69,8 @@ class MenuService extends BaseAdminService
public function edit(string $app_type, string $menu_key, array $data)
{
$where = array(
['app_type', '=', $app_type],
['menu_key', '=', $menu_key]
[ 'app_type', '=', $app_type ],
[ 'menu_key', '=', $menu_key ]
);
$res = $this->model->update($data, $where);
Cache::tag(self::$cache_tag_name)->clear();
@ -81,8 +82,9 @@ class MenuService extends BaseAdminService
* @param string $menu_key
* @return array
*/
public function get(string $app_type, string $menu_key){
return $this->model->where([['app_type', '=', $app_type],['menu_key', '=', $menu_key]])->findOrEmpty()->toArray();
public function get(string $app_type, string $menu_key)
{
return $this->model->where([ [ 'app_type', '=', $app_type ], [ 'menu_key', '=', $menu_key ] ])->findOrEmpty()->toArray();
}
/**
@ -90,12 +92,13 @@ class MenuService extends BaseAdminService
* @param string $app_type
* @return SysMenu|array|mixed|Model
*/
public function find(string $menu_key, string $app_type = ''){
public function find(string $menu_key, string $app_type = '')
{
$where = array(
['menu_key', '=', $menu_key]
[ 'menu_key', '=', $menu_key ]
);
if(!empty($app_type)){
$where[] = ['app_type', '=', $app_type];
if (!empty($app_type)) {
$where[] = [ 'app_type', '=', $app_type ];
}
$menu = $this->model->where($where)->findOrEmpty();
return $menu;
@ -107,15 +110,16 @@ class MenuService extends BaseAdminService
* @return bool
* @throws DbException
*/
public function del(string $app_type, string $menu_key){
public function del(string $app_type, string $menu_key)
{
//查询是否有下级菜单或按钮
$menu = $this->find($menu_key, $app_type);
if($this->model->where([['parent_key', '=', $menu_key], ['app_type', '=', $app_type]])->count() > 0)
if ($this->model->where([ [ 'parent_key', '=', $menu_key ], [ 'app_type', '=', $app_type ] ])->count() > 0)
throw new AdminException('MENU_NOT_ALLOW_DELETE');
$res = $menu->delete();
Cache::tag(self::$cache_tag_name)->clear();
return $res;
return $res;
}
/**
@ -133,12 +137,12 @@ class MenuService extends BaseAdminService
public function getMenuListByMenuKeys(int $site_id, array $menu_keys, string $app_type, int $is_tree = 0, $addon = 'all', $is_button = 1)
{
sort($menu_keys);
$cache_name = 'menu' . md5(implode("_", $menu_keys)) . $is_tree.$addon.$site_id;
$cache_name = 'menu' . md5(implode("_", $menu_keys)) . $is_tree . $addon . $site_id;
$menu_list = cache_remember(
$cache_name,
function () use ($site_id, $menu_keys, $app_type, $is_tree, $addon) {
function() use ($site_id, $menu_keys, $app_type, $is_tree, $addon) {
$where = [
['menu_key', 'in', $menu_keys],
[ 'menu_key', 'in', $menu_keys ],
];
$addons = ( new AddonService() )->getAddonKeysBySiteId($site_id);
$addons[] = '';
@ -146,16 +150,16 @@ class MenuService extends BaseAdminService
$delete_menu_addon = [];
$addon_loader = new DictLoader("Menu");
if($addon != 'all'){
$where[] = ['addon', '=', $addon];
if ($addon != 'all') {
$where[] = [ 'addon', '=', $addon ];
$delete_menu = $addon_loader->load(["addon" => $addon, "app_type" => $app_type])['delete'] ?? [];
$delete_menu = $addon_loader->load([ "addon" => $addon, "app_type" => $app_type ])[ 'delete' ] ?? [];
if (!empty($delete_menu) && is_array($delete_menu)) $delete_menu_addon[] = $delete_menu;
} else {
$where[] = ['addon', 'in', $addons];
$where[] = [ 'addon', 'in', $addons ];
foreach ($addons as $addon) {
$delete_menu = $addon_loader->load(["addon" => $addon, "app_type" => $app_type])['delete'] ?? [];
$delete_menu = $addon_loader->load([ "addon" => $addon, "app_type" => $app_type ])[ 'delete' ] ?? [];
if (!empty($delete_menu) && is_array($delete_menu)) $delete_menu_addon[] = $delete_menu;
}
}
@ -164,24 +168,22 @@ class MenuService extends BaseAdminService
if (!empty($delete_menu_addon)) {
$delete_intersect = array_intersect(...$delete_menu_addon);
if (!empty($delete_intersect)) {
$where[] = ['menu_key', 'not in', $delete_intersect];
$where[] = [ 'menu_key', 'not in', $delete_intersect ];
}
}
if(!empty($app_type)){
$where[] = ['app_type', '=', $app_type];
if (!empty($app_type)) {
$where[] = [ 'app_type', '=', $app_type ];
}
return $this->model->where($where)->order('sort', 'desc')->select()->toArray();
},
self::$cache_tag_name
);
foreach ($menu_list as &$v)
{
$lang_menu_key = "dict_menu_". $v['app_type']. '.'. $v['menu_key'];
$lang_menu_name = get_lang("dict_menu_". $v['app_type']. '.'. $v['menu_key']);
foreach ($menu_list as &$v) {
$lang_menu_key = "dict_menu_" . $v[ 'app_type' ] . '.' . $v[ 'menu_key' ];
$lang_menu_name = get_lang("dict_menu_" . $v[ 'app_type' ] . '.' . $v[ 'menu_key' ]);
//语言已定义
if($lang_menu_key != $lang_menu_name)
{
$v['menu_name'] = $lang_menu_name;
if ($lang_menu_key != $lang_menu_name) {
$v[ 'menu_name' ] = $lang_menu_name;
}
}
@ -195,44 +197,42 @@ class MenuService extends BaseAdminService
public function getAllMenuList($app_type = '', $status = 'all', $is_tree = 0, $is_button = 0)
{
$site_id = $this->site_id;
$cache_name = 'site_menu_api_' .$app_type.'_'. $status . '_' . $is_tree . '_' . $is_button . '_' . $this->site_id;
$cache_name = 'site_menu_api_' . $app_type . '_' . $status . '_' . $is_tree . '_' . $is_button . '_' . $this->site_id;
$menu_list = cache_remember(
$cache_name,
function () use ($status, $is_tree, $is_button, $app_type, $site_id) {
function() use ($status, $is_tree, $is_button, $app_type, $site_id) {
$where = [
['app_type', '=', $app_type],
['addon', 'in', array_merge([''], get_site_addons($site_id)) ]
[ 'app_type', '=', $app_type ],
[ 'addon', 'in', array_merge([ '' ], get_site_addons($site_id)) ]
];
if ($status != 'all') {
$where[] = ['status', '=', $status];
$where[] = [ 'status', '=', $status ];
}
// 排除菜单
$delete_menu_addon = [];
$addon_loader = new DictLoader("Menu");
foreach (get_site_addons($site_id) as $addon) {
$delete_menu = $addon_loader->load(["addon" => $addon, "app_type" => $app_type])['delete'] ?? [];
$delete_menu = $addon_loader->load([ "addon" => $addon, "app_type" => $app_type ])[ 'delete' ] ?? [];
if (!empty($delete_menu) && is_array($delete_menu)) $delete_menu_addon[] = $delete_menu;
}
if (!empty($delete_menu_addon)) {
$delete_intersect = array_intersect(...$delete_menu_addon);
if (!empty($delete_intersect)) {
$where[] = ['menu_key', 'not in', $delete_intersect];
$where[] = [ 'menu_key', 'not in', $delete_intersect ];
}
}
return $this->model->where($where)->order('sort desc')->select()->toArray();
},
[self::$cache_tag_name, SiteService::$cache_tag_name]
[ self::$cache_tag_name, SiteService::$cache_tag_name ]
);
foreach ($menu_list as &$v)
{
$lang_menu_key = "dict_menu_". $v['app_type']. '.'. $v['menu_key'];
$lang_menu_name = get_lang("dict_menu_". $v['app_type']. '.'. $v['menu_key']);
foreach ($menu_list as &$v) {
$lang_menu_key = "dict_menu_" . $v[ 'app_type' ] . '.' . $v[ 'menu_key' ];
$lang_menu_name = get_lang("dict_menu_" . $v[ 'app_type' ] . '.' . $v[ 'menu_key' ]);
//语言已定义
if($lang_menu_key != $lang_menu_name)
{
$v['menu_name'] = $lang_menu_name;
if ($lang_menu_key != $lang_menu_name) {
$v[ 'menu_name' ] = $lang_menu_name;
}
}
return $is_tree ? $this->menuToTree($menu_list, 'menu_key', 'parent_key', 'children', 'auth', '', $is_button) : $menu_list;
@ -251,16 +251,16 @@ class MenuService extends BaseAdminService
$cache_name = 'api' . md5(implode("_", $menu_keys));
return cache_remember(
$cache_name,
function () use ($menu_keys, $app_type) {
function() use ($menu_keys, $app_type) {
$where = [
['menu_key', 'in', $menu_keys]
[ 'menu_key', 'in', $menu_keys ]
];
if(!empty($app_type)){
$where[] = ['app_type', '=', $app_type];
if (!empty($app_type)) {
$where[] = [ 'app_type', '=', $app_type ];
}
$menu_list = (new SysMenu())->where($where)->order('sort', 'desc')->column('api_url,methods');
$menu_list = ( new SysMenu() )->where($where)->order('sort', 'desc')->column('api_url,methods');
foreach ($menu_list as $v) {
$auth_menu_list[$v['methods']][] = $v['api_url'];
$auth_menu_list[ $v[ 'methods' ] ][] = $v[ 'api_url' ];
}
return $auth_menu_list ?? [];
},
@ -281,13 +281,13 @@ class MenuService extends BaseAdminService
$cache_name = 'button' . md5(implode("_", $menu_keys));
return cache_remember(
$cache_name,
function () use ($menu_keys, $app_type) {
function() use ($menu_keys, $app_type) {
$where = [
['menu_key', 'in', $menu_keys],
['menu_type', '=', MenuTypeDict::BUTTON]
[ 'menu_key', 'in', $menu_keys ],
[ 'menu_type', '=', MenuTypeDict::BUTTON ]
];
if(!empty($app_type)){
$where[] = ['app_type', '=', $app_type];
if (!empty($app_type)) {
$where[] = [ 'app_type', '=', $app_type ];
}
return $this->model->where($where)->order('sort', 'desc')->column('menu_key');
},
@ -303,21 +303,21 @@ class MenuService extends BaseAdminService
*/
public function getAllApiList($app_type = '', $status = 'all')
{
$cache_name = 'all_api' .$app_type.'_'. $status;
$cache_name = 'all_api' . $app_type . '_' . $status;
return cache_remember(
$cache_name,
function () use ($status, $app_type) {
function() use ($status, $app_type) {
$where = [
['api_url', '<>', ''],
['app_type', '=', $app_type],
[ 'api_url', '<>', '' ],
[ 'app_type', '=', $app_type ],
];
if ($status != 'all') {
$where[] = ['status', '=', $status];
$where[] = [ 'status', '=', $status ];
}
$menu_list = $this->model->where($where)->order('sort', 'desc')->column('methods, api_url');
$auth_menu_list = [];
foreach ($menu_list as $v) {
$auth_menu_list[$v['methods']][] = $v['api_url'];
$auth_menu_list[ $v[ 'methods' ] ][] = $v[ 'api_url' ];
}
return $auth_menu_list;
},
@ -331,17 +331,18 @@ class MenuService extends BaseAdminService
* @param $status
* @return mixed|string
*/
public function getAllMenuIdsByAppType(string $app_type, $status = 'all'){
$cache_name = 'menu_id_by_app_type_' .$app_type;
public function getAllMenuIdsByAppType(string $app_type, $status = 'all')
{
$cache_name = 'menu_id_by_app_type_' . $app_type;
return cache_remember(
$cache_name,
function () use ($app_type, $status) {
function() use ($app_type, $status) {
$where = [
//
['app_type', '=', $app_type],
[ 'app_type', '=', $app_type ],
];
if ($status != 'all') {
$where[] = ['status', '=', $status];
$where[] = [ 'status', '=', $status ];
}
return $this->model->where($where)->order('sort desc')->column('menu_key');
},
@ -350,22 +351,21 @@ class MenuService extends BaseAdminService
}
/**
* 获取所有按钮菜单
*/
public function getAllButtonList($app_type = '', $status = 'all', $is_tree = 0)
{
$cache_name = 'menu_api_' .$app_type.'_' . $status . '_' . $is_tree;
$cache_name = 'menu_api_' . $app_type . '_' . $status . '_' . $is_tree;
return cache_remember(
$cache_name,
function () use ($status, $is_tree, $app_type) {
function() use ($status, $is_tree, $app_type) {
$where = [
['menu_type', '=', MenuTypeDict::BUTTON],
['app_type', '=', $app_type],
[ 'menu_type', '=', MenuTypeDict::BUTTON ],
[ 'app_type', '=', $app_type ],
];
if ($status != 'all') {
$where[] = ['status', '=', $status];
$where[] = [ 'status', '=', $status ];
}
return $this->model->where($where)->order('sort', 'desc')->column('menu_key');
},
@ -390,20 +390,20 @@ class MenuService extends BaseAdminService
// 创建基于主键的数组引用
$refer = array();
foreach ($list as $key => $data) {
$refer[$data[$pk]] =& $list[$key];
$refer[ $data[ $pk ] ] =& $list[ $key ];
}
foreach ($list as $key => $data) {
// 判断是否存在parent
$parent_id = $data[$pid];
$parent_id = $data[ $pid ];
if ($root == $parent_id) {
$tree[] =& $list[$key];
$tree[] =& $list[ $key ];
} else {
if (isset($refer[$parent_id])) {
$parent =& $refer[$parent_id];
if ($list[$key]['menu_type'] == 2 && $is_button == 1) {
$parent[$button_name][] =& $list[$key]['menu_key'];
if (isset($refer[ $parent_id ])) {
$parent =& $refer[ $parent_id ];
if ($list[ $key ][ 'menu_type' ] == 2 && $is_button == 1) {
$parent[ $button_name ][] =& $list[ $key ][ 'menu_key' ];
} else {
$parent[$child][] =& $list[$key];
$parent[ $child ][] =& $list[ $key ];
}
}
@ -419,17 +419,18 @@ class MenuService extends BaseAdminService
* @param $menu_key
* @return string
*/
public function getFullRouterPath($menu_key){
$menu = $this->model->where([['menu_key', '=', $menu_key]])->findOrEmpty($menu_key);
if($menu->isEmpty()) return '';
public function getFullRouterPath($menu_key)
{
$menu = $this->model->where([ [ 'menu_key', '=', $menu_key ] ])->findOrEmpty($menu_key);
if ($menu->isEmpty()) return '';
$parents = [];
$this->getParentDirectory($menu, $parents);
$parents = array_reverse($parents);
$router_path = implode('/', $parents);
if(!empty($router_path)){
$router_path .= '/'.$menu['router_path'];
}else{
$router_path = $menu['router_path'];
if (!empty($router_path)) {
$router_path .= '/' . $menu[ 'router_path' ];
} else {
$router_path = $menu[ 'router_path' ];
}
return $router_path;
}
@ -440,11 +441,12 @@ class MenuService extends BaseAdminService
* @param $parents
* @return void
*/
public function getParentDirectory(SysMenu $menu, &$parents){
if(!$menu->isEmpty() && !empty($menu['parent_key'])){
$parent_menu = $this->model->where([['menu_key', '=', $menu['parent_key']]])->findOrEmpty();
if(!empty($parent_menu)){
if(!empty($parent_menu['router_path'])) $parents[] = $parent_menu['router_path'];
public function getParentDirectory(SysMenu $menu, &$parents)
{
if (!$menu->isEmpty() && !empty($menu[ 'parent_key' ])) {
$parent_menu = $this->model->where([ [ 'menu_key', '=', $menu[ 'parent_key' ] ] ])->findOrEmpty();
if (!empty($parent_menu)) {
if (!empty($parent_menu[ 'router_path' ])) $parents[] = $parent_menu[ 'router_path' ];
$this->getParentDirectory($parent_menu, $parents);
}
}
@ -460,20 +462,20 @@ class MenuService extends BaseAdminService
public function getApiListBySystem(string $app_type = '', array $addons = [])
{
sort($addons);
$cache_name = 'system_menu_api_' . $app_type.implode("_", $addons);
$cache_name = 'system_menu_api_' . $app_type . implode("_", $addons);
return cache_remember(
$cache_name,
function () use ($app_type, $addons) {
function() use ($app_type, $addons) {
$addons[] = '';
$where = [
['addon', 'in', $addons]
[ 'addon', 'in', $addons ]
];
if(!empty($app_type)){
$where[] = ['app_type', '=', $app_type];
if (!empty($app_type)) {
$where[] = [ 'app_type', '=', $app_type ];
}
$menu_list = (new SysMenu())->where($where)->order('sort', 'desc')->column('api_url,methods');
$menu_list = ( new SysMenu() )->where($where)->order('sort', 'desc')->column('api_url,methods');
foreach ($menu_list as $v) {
$auth_menu_list[$v['methods']][] = $v['api_url'];
$auth_menu_list[ $v[ 'methods' ] ][] = $v[ 'api_url' ];
}
return $auth_menu_list ?? [];
},
@ -497,25 +499,25 @@ class MenuService extends BaseAdminService
$cache_name = 'menu' . md5(implode("_", $addons)) . $is_tree . $status;
$menu_list = cache_remember(
$cache_name,
function () use ($addons, $app_type, $is_tree, $status) {
function() use ($addons, $app_type, $is_tree, $status) {
$where = [
['addon', 'in', $addons]
[ 'addon', 'in', $addons ]
];
if(!empty($app_type)){
$where[] = ['app_type', '=', $app_type];
if (!empty($app_type)) {
$where[] = [ 'app_type', '=', $app_type ];
}
if ($status != 'all') $where[] = ['status', '=', $status];
if ($status != 'all') $where[] = [ 'status', '=', $status ];
// 排除插件中delete的菜单
$delete_menu_addon = [];
$addon_loader = new DictLoader("Menu");
foreach ($addons as $addon) {
$delete_menu = $addon_loader->load(["addon" => $addon, "app_type" => $app_type])['delete'] ?? [];
$delete_menu = $addon_loader->load([ "addon" => $addon, "app_type" => $app_type ])[ 'delete' ] ?? [];
if (!empty($delete_menu) && is_array($delete_menu)) $delete_menu_addon[] = $delete_menu;
}
if (!empty($delete_menu_addon)) {
$delete_intersect = array_intersect(...$delete_menu_addon);
if (!empty($delete_intersect)) {
$where[] = ['menu_key', 'not in', $delete_intersect];
$where[] = [ 'menu_key', 'not in', $delete_intersect ];
}
}
return $this->model->where($where)->order('sort', 'desc')->select()->toArray();
@ -523,14 +525,12 @@ class MenuService extends BaseAdminService
self::$cache_tag_name
);
foreach ($menu_list as &$v)
{
$lang_menu_key = "dict_menu_". $v['app_type']. '.'. $v['menu_key'];
$lang_menu_name = get_lang("dict_menu_". $v['app_type']. '.'. $v['menu_key']);
foreach ($menu_list as &$v) {
$lang_menu_key = "dict_menu_" . $v[ 'app_type' ] . '.' . $v[ 'menu_key' ];
$lang_menu_name = get_lang("dict_menu_" . $v[ 'app_type' ] . '.' . $v[ 'menu_key' ]);
//语言已定义
if($lang_menu_key != $lang_menu_name)
{
$v['menu_name'] = $lang_menu_name;
if ($lang_menu_key != $lang_menu_name) {
$v[ 'menu_name' ] = $lang_menu_name;
}
}
return $is_tree ? $this->menuToTree($menu_list, 'menu_key', 'parent_key', 'children', 'auth', '', $is_button) : $menu_list;
@ -543,20 +543,21 @@ class MenuService extends BaseAdminService
* @param array $addons
* @return mixed|string
*/
public function getMenuKeysBySystem(string $app_type, array $addons){
public function getMenuKeysBySystem(string $app_type, array $addons)
{
sort($addons);
$cache_name = 'menu_keys_' . $app_type.implode("_", $addons);
$cache_name = 'menu_keys_' . $app_type . implode("_", $addons);
return cache_remember(
$cache_name,
function () use ($app_type, $addons) {
function() use ($app_type, $addons) {
$addons[] = '';
$where = [
['addon', 'in', $addons]
[ 'addon', 'in', $addons ]
];
if(!empty($app_type)){
$where[] = ['app_type', '=', $app_type];
if (!empty($app_type)) {
$where[] = [ 'app_type', '=', $app_type ];
}
return (new SysMenu())->where($where)->order('sort', 'desc')->column('menu_key');
return ( new SysMenu() )->where($where)->order('sort', 'desc')->column('menu_key');
},
self::$cache_tag_name
);
@ -565,46 +566,42 @@ class MenuService extends BaseAdminService
public function getSystemMenu($status = 'all', $is_tree = 0, $is_button = 0)
{
if($is_button == 0)
{
if ($is_button == 0) {
$where = [
['menu_type', 'in', [0,1]]
[ 'menu_type', 'in', [ 0, 1 ] ]
];
}
if ($status != 'all') {
$where[] = ['status', '=', $status];
$where[] = [ 'status', '=', $status ];
}
$where[] = [ 'addon', '=',''];
$menu_list = (new SysMenu())->where($where)->order('sort desc')->select()->toArray();
foreach ($menu_list as &$v)
{
$lang_menu_key = 'dict_menu_admin' . '.'. $v['menu_key'];
$where[] = [ 'addon', '=', '' ];
$menu_list = ( new SysMenu() )->where($where)->order('sort desc')->select()->toArray();
foreach ($menu_list as &$v) {
$lang_menu_key = 'dict_menu_admin' . '.' . $v[ 'menu_key' ];
$lang_menu_name = get_lang($lang_menu_key);
//语言已定义
if($lang_menu_key != $lang_menu_name)
{
$v['menu_name'] = $lang_menu_name;
if ($lang_menu_key != $lang_menu_name) {
$v[ 'menu_name' ] = $lang_menu_name;
}
}
return $is_tree ? $this->menuToTree($menu_list, 'menu_key', 'parent_key', 'children', 'auth', '', $is_button) : $menu_list;
}
public function getAddonMenu($app_key,$status = 'all', $is_tree = 0, $is_button = 0)
public function getAddonMenu($app_key, $status = 'all', $is_tree = 0, $is_button = 0)
{
if($is_button == 0)
{
if ($is_button == 0) {
$where = [
['menu_type', 'in', [0,1]]
[ 'menu_type', 'in', [ 0, 1 ] ]
];
}
if ($status != 'all') {
$where[] = ['status', '=', $status];
$where[] = [ 'status', '=', $status ];
}
$where[] = [ 'addon', '=',$app_key];
$menu_list = (new SysMenu())->where($where)->select()->toArray();
$where[] = [ 'addon', '=', $app_key ];
$menu_list = ( new SysMenu() )->where($where)->select()->toArray();
return $is_tree ? $this->menuToTree($menu_list, 'menu_key', 'parent_key', 'children', 'auth', '', $is_button) : $menu_list;
}
@ -612,29 +609,28 @@ class MenuService extends BaseAdminService
* 查询菜单类型为目录的菜单
* @param string $addon
*/
public function getMenuByTypeDir(string $addon = 'system') {
public function getMenuByTypeDir(string $addon = 'system')
{
$cache_name = 'menu_api_by_type_dir' . $addon;
$menu_list = cache_remember(
$cache_name,
function () use ($addon) {
function() use ($addon) {
$where = [
['menu_type', '=', 0 ],
['app_type', '=', 'site']
[ 'menu_type', '=', 0 ],
[ 'app_type', '=', 'site' ]
];
//查询应用
$where[] = ['addon', '=', $addon == 'system' ? '' : $addon ];
return (new SysMenu())->where($where)->order('sort desc')->select()->toArray();
$where[] = [ 'addon', '=', $addon == 'system' ? '' : $addon ];
return ( new SysMenu() )->where($where)->order('sort desc')->select()->toArray();
},
self::$cache_tag_name
);
foreach ($menu_list as &$v)
{
$lang_menu_key = 'dict_menu_admin' . '.'. $v['menu_key'];
foreach ($menu_list as &$v) {
$lang_menu_key = 'dict_menu_admin' . '.' . $v[ 'menu_key' ];
$lang_menu_name = get_lang($lang_menu_key);
//语言已定义
if($lang_menu_key != $lang_menu_name)
{
$v['menu_name'] = $lang_menu_name;
if ($lang_menu_key != $lang_menu_name) {
$v[ 'menu_name' ] = $lang_menu_name;
}
}

View File

@ -221,4 +221,4 @@ class RoleService extends BaseAdminService
);
}
}
}

View File

@ -13,9 +13,7 @@ namespace app\service\admin\sys;
use app\job\sys\CheckJob;
use app\service\core\site\CoreSiteService;
use app\service\core\sys\CoreConfigService;
use core\base\BaseAdminService;
use core\exception\CommonException;
use think\facade\Db;
use Throwable;

View File

@ -28,10 +28,9 @@ class RestoreService extends UpgradeService
$backup_dir = $this->upgrade_dir .$this->upgrade_task['key'] . DIRECTORY_SEPARATOR . 'backup' . DIRECTORY_SEPARATOR . 'code' . DIRECTORY_SEPARATOR;
if (is_dir($backup_dir)) {
// 删除前端文件
if (is_dir(public_path() . 'admin')) del_target_dir(public_path() . 'admin', true);
if (is_dir(public_path() . 'wap')) del_target_dir(public_path() . 'wap', true);
if (is_dir(public_path() . 'web')) del_target_dir(public_path() . 'web', true);
// if (is_dir(public_path() . 'admin')) del_target_dir(public_path() . 'admin', true);
// if (is_dir(public_path() . 'wap')) del_target_dir(public_path() . 'wap', true);
// if (is_dir(public_path() . 'web')) del_target_dir(public_path() . 'web', true);
dir_copy($backup_dir, rtrim($this->root_path, DIRECTORY_SEPARATOR));
}
return true;

View File

@ -12,6 +12,7 @@
namespace app\service\admin\user;
use app\dict\sys\RoleStatusDict;
use app\dict\sys\UserDict;
use app\model\sys\SysRole;
use app\model\sys\SysUserRole;
@ -139,11 +140,12 @@ class UserRoleService extends BaseAdminService
function() use($role_ids, $site_id) {
$where = array(
['role_id', 'in', $role_ids],
['site_id', '=', $site_id]
['site_id', '=', $site_id],
['status', '=', RoleStatusDict::ON ]
);
return SysRole::where($where)->column('role_name');
},
[self::$role_cache_name, RoleService::$cache_tag_name.$this->site_id]
[self::$role_cache_name, RoleService::$cache_tag_name.$site_id]
);
}

View File

@ -250,13 +250,15 @@ class UserService extends BaseAdminService
* @return true
*/
public function del(int $uid){
$where = [
['uid', '=', $uid],
['site_id', '=', $this->site_id]
];
(new SysUserRole())->where($where)->delete();
return true;
AuthService::isSuperAdmin();
$super_admin_uid = Cache::get('super_admin_uid');
if ($super_admin_uid == $uid) throw new CommonException("SUPER_ADMIN_NOT_ALLOW_DEL");
$site_num = (new SysUserRole())->where([['uid', '=', $uid], ['site_id', '<>', request()->defaultSiteId() ] ])->count();
if ($site_num) throw new CommonException("USER_NOT_ALLOW_DEL");
$this->model->where([ ['uid', '=', $uid] ])->delete();
return true;
}
/**

View File

@ -16,7 +16,6 @@ use app\service\core\sys\CoreConfigService;
use app\service\core\wechat\CoreWechatApiService;
use core\base\BaseAdminService;
use core\exception\WechatException;
use EasyWeChat\Kernel\Exceptions\InvalidArgumentException;
use EasyWeChat\Kernel\Exceptions\InvalidConfigException;
use GuzzleHttp\Exception\GuzzleException;
use think\Model;

View File

@ -95,7 +95,7 @@ class AuthService extends BaseApiService
* 绑定手机号
* @param string $mobile
* @param string $mobile_code
* @return true
* @return array
*/
public function bindMobile(string $mobile, string $mobile_code)
{
@ -125,7 +125,9 @@ class AuthService extends BaseApiService
$member->save([
'mobile' => $mobile
]);
return true;
return [
'mobile' => $mobile
];
}
}

View File

@ -11,7 +11,6 @@
namespace app\service\api\member;
use app\dict\member\MemberAccountChangeTypeDict;
use app\dict\member\MemberAccountTypeDict;
use app\model\member\Member;
use app\model\member\MemberAccountLog;
@ -25,7 +24,7 @@ use think\db\exception\DbException;
*/
class MemberAccountService extends BaseApiService
{
public function __construct()
{
parent::__construct();
@ -39,9 +38,9 @@ class MemberAccountService extends BaseApiService
*/
public function getPage(array $where = [])
{
$where['member_id'] = $this->member_id;
$where[ 'member_id' ] = $this->member_id;
$field = 'id, member_id, site_id, account_type, account_data, from_type, related_id, create_time, memo';
$search_model = $this->model->where([['site_id', '=', $this->site_id]])->withSearch(['member_id','account_type', 'from_type', 'create_time','account_data_gt', 'account_data_lt','keyword'],$where)->field($field)->order('create_time desc')->append(['from_type_name', 'account_type_name']);
$search_model = $this->model->where([ [ 'site_id', '=', $this->site_id ] ])->withSearch([ 'member_id', 'account_type', 'from_type', 'create_time', 'account_data_gt', 'account_data_lt', 'keyword' ], $where)->field($field)->order('create_time desc')->append([ 'from_type_name', 'account_type_name' ]);
return $this->pageQuery($search_model);
}
@ -53,25 +52,25 @@ class MemberAccountService extends BaseApiService
public function getPointPage(array $where = [])
{
$type_where = [];
switch ($where['amount_type']){
switch ($where[ 'amount_type' ]) {
case 'income':
$type_where = [
['account_data', '>', 0 ],
[ 'account_data', '>', 0 ],
];
break;
case 'disburse':
$type_where = [
['account_data', '<', 0 ],
[ 'account_data', '<', 0 ],
];
break;
default:
break;
}
$where['member_id'] = $this->member_id;
$where[ 'member_id' ] = $this->member_id;
$field = 'id, member_id, site_id, account_type, account_data, from_type, related_id, create_time, memo';
$search_model = $this->model->where([['site_id', '=', $this->site_id]])->where($type_where)->withSearch(['member_id','account_type', 'from_type', 'create_time','account_data_gt', 'account_data_lt'],$where)->field($field)->order('create_time desc')->append(['from_type_name', 'account_type_name']);
$search_model = $this->model->where([ [ 'site_id', '=', $this->site_id ] ])->where($type_where)->withSearch([ 'member_id', 'account_type', 'from_type', 'create_time', 'account_data_gt', 'account_data_lt' ], $where)->field($field)->order('create_time desc')->append([ 'from_type_name', 'account_type_name' ]);
$list = $this->pageQuery($search_model);
$list['data'] = $this->monthlyGrouping($list['data']);
$list[ 'data' ] = $this->monthlyGrouping($list[ 'data' ]);
return $list;
}
@ -82,41 +81,38 @@ class MemberAccountService extends BaseApiService
*/
public function getBalancePage(array $data = [])
{
switch ($data['from_type']){
switch ($data[ 'trade_type' ]) {
case 'income':
$type_where = [
['account_type', 'in', [MemberAccountTypeDict::BALANCE,MemberAccountTypeDict::MONEY]],
['account_data', '>', 0 ],
['from_type', '<>', 'cash_out']
[ 'account_type', 'in', [ MemberAccountTypeDict::BALANCE, MemberAccountTypeDict::MONEY ] ],
[ 'account_data', '>', 0 ],
[ 'from_type', '<>', 'cash_out' ]
];
break;
case 'disburse':
$type_where = [
['account_type', 'in', [MemberAccountTypeDict::BALANCE,MemberAccountTypeDict::MONEY]],
['account_data', '<', 0 ],
['from_type', '<>', 'cash_out']
[ 'account_type', 'in', [ MemberAccountTypeDict::BALANCE, MemberAccountTypeDict::MONEY ] ],
[ 'account_data', '<', 0 ],
[ 'from_type', '<>', 'cash_out' ]
];
break;
case 'cash_out':
$type_where = [
['account_type', '=', MemberAccountTypeDict::MONEY],
['from_type', '=', $data['from_type']]
[ 'account_type', '=', MemberAccountTypeDict::MONEY ],
[ 'from_type', '=', 'cash_out' ]
];
break;
default:
$type_where = [
['account_type', 'in', [MemberAccountTypeDict::BALANCE,MemberAccountTypeDict::MONEY]],
[ 'account_type', 'in', [ MemberAccountTypeDict::BALANCE, MemberAccountTypeDict::MONEY ] ],
];
break;
}
$where['member_id'] = $this->member_id;
$where['create_time'] = $data['create_time'];
$where[ 'member_id' ] = $this->member_id;
$where[ 'create_time' ] = $data[ 'create_time' ];
$field = 'id, member_id, site_id, account_type, account_data, account_sum, from_type, related_id, create_time, memo';
$search_model = $this->model->where([['site_id', '=', $this->site_id]])->where($type_where)->withSearch(['member_id', 'create_time'],$where)->field($field)->order('create_time desc')->append(['from_type_name', 'account_type_name']);
$search_model = $this->model->where([ [ 'site_id', '=', $this->site_id ] ])->where($type_where)->withSearch([ 'member_id', 'create_time' ], $where)->field($field)->order('create_time desc')->append([ 'from_type_name', 'account_type_name' ]);
return $this->pageQuery($search_model);
}
@ -128,7 +124,7 @@ class MemberAccountService extends BaseApiService
public function getInfo(int $id)
{
$field = 'id, member_id, site_id, account_type, account_data, from_type, related_id, create_time, memo';
return $this->model->where([['id', '=', $id], ['site_id', '=', $this->site_id], ['member_id', '=', $this->member_id]])->field($field)->append(['from_type_name', 'account_type_name'])->findOrEmpty()->toArray();
return $this->model->where([ [ 'id', '=', $id ], [ 'site_id', '=', $this->site_id ], [ 'member_id', '=', $this->member_id ] ])->field($field)->append([ 'from_type_name', 'account_type_name' ])->findOrEmpty()->toArray();
}
/**
@ -137,10 +133,11 @@ class MemberAccountService extends BaseApiService
* @return int
* @throws DbException
*/
public function getCount(array $where = []){
$where['member_id'] = $this->member_id;
public function getCount(array $where = [])
{
$where[ 'member_id' ] = $this->member_id;
return $this->model->where([['site_id', '=', $this->site_id]])->withSearch(['member_id','account_type', 'from_type', 'create_time'],$where)->count();
return $this->model->where([ [ 'site_id', '=', $this->site_id ] ])->withSearch([ 'member_id', 'account_type', 'from_type', 'create_time' ], $where)->count();
}
/**
@ -149,20 +146,21 @@ class MemberAccountService extends BaseApiService
* @return int
* @throws DbException
*/
public function getPointCount(){
public function getPointCount()
{
$data = [
'point' => 0,
'point_get' => 0,
'use'=> 0,//使用
'use' => 0,//使用
];
$info = (new Member())->where([['site_id', '=', $this->site_id], ['member_id', '=', $this->member_id]])->field('point,point_get')->findOrEmpty()->toArray();
$data['point'] = $info['point'] ?? 0;
$data['point_get'] = $info['point_get'] ?? 0;
$data['use'] = abs($this->model->where([
['site_id', '=', $this->site_id],
['member_id', '=', $this->member_id],
['account_type', '=', MemberAccountTypeDict::POINT],
['account_data', '<', 0]
$info = ( new Member() )->where([ [ 'site_id', '=', $this->site_id ], [ 'member_id', '=', $this->member_id ] ])->field('point,point_get')->findOrEmpty()->toArray();
$data[ 'point' ] = $info[ 'point' ] ?? 0;
$data[ 'point_get' ] = $info[ 'point_get' ] ?? 0;
$data[ 'use' ] = abs($this->model->where([
[ 'site_id', '=', $this->site_id ],
[ 'member_id', '=', $this->member_id ],
[ 'account_type', '=', MemberAccountTypeDict::POINT ],
[ 'account_data', '<', 0 ]
])->sum('account_data'));
return $data;
@ -185,13 +183,12 @@ class MemberAccountService extends BaseApiService
$arr_return_data = [];
foreach ($arr_data as $data) {
//按月份分组
$year_month = mb_substr($data[$time_field], 0, 7);
$year_month = mb_substr($data[ $time_field ], 0, 7);
$arr_month[$year_month]['month_data'][] = $data;
$arr_month[ $year_month ][ 'month_data' ][] = $data;
if (!isset($arr_month[$year_month]['month_info']))
{
$arr_month[$year_month]['month_info'] =
if (!isset($arr_month[ $year_month ][ 'month_info' ])) {
$arr_month[ $year_month ][ 'month_info' ] =
[
'year' => mb_substr($year_month, 0, 4),
'month' => mb_substr($year_month, 5, 2),

View File

@ -51,6 +51,7 @@ class MemberLevelService extends BaseApiService
$length = empty($item['level_benefits']) ? 0 : count($item['level_benefits']);
if ($length < 4) {
if (empty($item['level_benefits'])) $list[$k]['level_benefits'] = [];
foreach ($filling as $key => $content) {
if (count($list[$k]['level_benefits']) == 4) break;
$list[$k]['level_benefits'][$key] = [

View File

@ -16,9 +16,6 @@ use app\service\core\member\CoreMemberService;
use core\base\BaseApiService;
use core\exception\ApiException;
use core\util\Barcode;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
use think\Model;
/**

View File

@ -29,8 +29,6 @@ class SiteService extends BaseApiService
$this->model = new Site();
}
/**
* 获取授权当前站点信息(用做缓存)
* @return mixed

View File

@ -13,9 +13,7 @@ namespace app\service\api\sys;
use app\service\core\member\CoreMemberConfigService;
use app\service\core\member\CoreMemberService;
use app\service\core\scan\CoreScanService;
use core\base\BaseApiService;
use core\dict\DictLoader;
/**
* Class BaseService

View File

@ -63,9 +63,9 @@ class UploadService extends BaseApiService
*/
public function document($file, string $type = '')
{
if(!in_array($type, FileDict::getSceneType()))
if (!in_array($type, FileDict::getSceneType()))
throw new UploadFileException('UPLOAD_TYPE_ERROR');
$dir = $this->root_path.'/document/'.$type.'/'.$this->site_id.'/'.date('Ym').'/'.date('d');
$dir = $this->root_path . '/document/' . $type . '/' . $this->site_id . '/' . date('Ym') . '/' . date('d');
$core_upload_service = new CoreUploadService();
return $core_upload_service->document($file, $this->site_id, $type, $dir, StorageDict::LOCAL);
}

View File

@ -29,11 +29,11 @@ class VerifyService extends BaseApiService
* @param $data = ['order_id' => , 'goods_id' => ]
* @return string
*/
public function getVerifyCode(string|int $type, array $data)
public function getVerifyCode($type, array $data)
{
$list = (new CoreVerifyService())->create($this->site_id, $this->member_id, $type, $data);
$list = ( new CoreVerifyService() )->create($this->site_id, $this->member_id, $type, $data);
$temp = [];
foreach($list as $item){
foreach ($list as $item) {
$temp[] = [
'code' => $item,
'qrcode' => qrcode($item, '', [], $this->site_id, outfile: false)
@ -47,8 +47,9 @@ class VerifyService extends BaseApiService
* @param $code
* @return bool
*/
public function getInfoByCode($code){
return (new CoreVerifyService())->getInfoByCode($this->site_id, $code);
public function getInfoByCode($code)
{
return ( new CoreVerifyService() )->getInfoByCode($this->site_id, $code);
}
/**
@ -56,17 +57,19 @@ class VerifyService extends BaseApiService
* @param $code
* @return bool
*/
public function verify($code){
return (new CoreVerifyService())->verify($this->site_id, $code, $this->member_id);
public function verify($code)
{
return ( new CoreVerifyService() )->verify($this->site_id, $code, $this->member_id);
}
/**
* 校验是否是核销员
* @return bool
*/
public function checkVerifier(){
$verifier = (new Verifier())->where([['member_id', '=', $this->member_id], ['site_id', '=', $this->site_id]])->findOrEmpty();
if(!$verifier->isEmpty()) return true;
public function checkVerifier()
{
$verifier = ( new Verifier() )->where([ [ 'member_id', '=', $this->member_id ], [ 'site_id', '=', $this->site_id ] ])->findOrEmpty();
if (!$verifier->isEmpty()) return true;
return false;
}
@ -76,21 +79,21 @@ class VerifyService extends BaseApiService
* @return array
* @throws \think\db\exception\DbException
*/
public function getRecordsPageByVerifier(array $data){
public function getRecordsPageByVerifier(array $data)
{
$field = '*';
$search_model = (new Verify())->where([
['site_id', '=', $this->site_id],
['verifier_member_id', '=', $this->member_id]
])
->withSearch(['code', 'type', 'create_time', 'relate_tag', 'keyword'], $data)
->with([
'member' => function($query){
$query->field('member_id, nickname, mobile, headimg');
}
])
->field($field)
->order('create_time desc')
->append(['type_name']);
$search_model = ( new Verify() )->where([
[ 'site_id', '=', $this->site_id ],
[ 'verifier_member_id', '=', $this->member_id ]
])->withSearch([ 'code', 'type', 'create_time', 'relate_tag', 'keyword' ], $data)
->with([
'member' => function($query) {
$query->field('member_id, nickname, mobile, headimg');
}
])
->field($field)
->order('create_time desc')
->append([ 'type_name' ]);
return $this->pageQuery($search_model);
}
@ -99,20 +102,18 @@ class VerifyService extends BaseApiService
* @param int $id
* @return array
*/
public function getRecordsDetailByVerifier(string|int $code){
public function getRecordsDetailByVerifier($code)
{
$field = '*';
return (new Verify())->where([
['site_id', '=', $this->site_id],
['verifier_member_id', '=', $this->member_id],
['code', '=', $code]
])
->with([
'member' => function($query){
$query->field('member_id, nickname, mobile, headimg');
}
])
->field($field)
->append(['type_name'])->findOrEmpty()->toArray();
return ( new Verify() )->where([
[ 'site_id', '=', $this->site_id ],
[ 'verifier_member_id', '=', $this->member_id ],
[ 'code', '=', $code ]
])->with([
'member' => function($query) {
$query->field('member_id, nickname, mobile, headimg');
}
])->field($field)->append([ 'type_name' ])->findOrEmpty()->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

@ -121,13 +121,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

@ -15,8 +15,6 @@ use app\service\core\wechat\CoreWechatServeService;
use core\base\BaseApiService;
use EasyWeChat\Kernel\Exceptions\BadRequestException;
use EasyWeChat\Kernel\Exceptions\InvalidArgumentException;
use EasyWeChat\Kernel\Exceptions\RuntimeException;
use Psr\Http\Message\ResponseInterface;
use ReflectionException;
use Symfony\Component\HttpFoundation\Response;
use Throwable;

View File

@ -13,7 +13,6 @@ namespace app\service\core\addon;
use app\dict\sys\MenuDict;
use app\model\sys\SysMenu;
use app\service\admin\sys\MenuService;
use core\base\BaseCoreService;
use core\exception\AddonException;

View File

@ -11,11 +11,9 @@
namespace app\service\core\addon;
use app\dict\addon\AddonDict;
use app\job\sys\AddonInstall;
use app\model\site\Site;
use app\model\site\SiteGroup;
use app\service\admin\sys\MenuService;
use app\service\admin\sys\SystemService;
use app\service\core\menu\CoreMenuService;
use app\service\core\schedule\CoreScheduleInstallService;
use core\exception\AddonException;
@ -25,7 +23,6 @@ use think\db\exception\DbException;
use think\db\exception\PDOException;
use think\facade\Cache;
use think\facade\Db;
use think\Response;
/**
* 安装服务层
@ -525,8 +522,11 @@ class CoreAddonInstallService extends CoreAddonBaseService
*/
public function uninstall()
{
$site_num = (new Site())->where([ ['app', 'like', "%$this->addon%"] ])->count('site_id');
if ($site_num) throw new CommonException('APP_NOT_ALLOW_UNINSTALL');
$site_groups = (new SiteGroup())->where([ ['app|addon', 'like', "%\"$this->addon\"%"] ])->column("group_id");
if (!empty($site_groups)) {
$site_num = (new Site())->where([ ['group_id', 'in', $site_groups] ])->count('site_id');
if ($site_num) throw new CommonException('APP_NOT_ALLOW_UNINSTALL');
}
(new CoreAddonDevelopBuildService())->build($this->addon);

View File

@ -12,9 +12,7 @@
namespace app\service\core\addon;
use app\dict\addon\AddonDict;
use app\dict\sys\AppTypeDict;
use app\model\addon\Addon;
use app\service\admin\site\SiteGroupService;
use app\service\core\niucloud\CoreModuleService;
use think\db\exception\DbException;
use Throwable;
@ -50,7 +48,7 @@ class CoreAddonService extends CoreAddonBaseService
'desc' => $v['app']['app_desc'],
'key' => $v['app']['app_key'] ?? '',
'version' => $v['version'] ?? '',
'author' => $v['app']['app_name'],
'author' => $v['site_name'],
'type' => $v['app']['app_type'],
'support_app' => $v['app']['support_channel'] ?? [],
'is_download' => false,
@ -266,7 +264,7 @@ class CoreAddonService extends CoreAddonBaseService
$data = $core_addon_service->getAddonConfig($key);
if (isset($data['key'])) {
$data['icon'] = is_file($data['icon']) ? image_to_base64($data['icon']) : '';
$data['cover'] = is_file($data['icon']) ? image_to_base64($data['cover']) : '';
$data['cover'] = is_file($data['cover']) ? image_to_base64($data['cover']) : '';
$data['type_name'] = empty($data['type']) ? '' : AddonDict::getType()[$data['type']] ?? '';
}
if(isset($data['support_app']) && !empty($data['support_app']))

View File

@ -36,15 +36,15 @@ class CoreMemberAccountService extends BaseCoreService
$member_info = $member_model->where([
[ 'member_id', '=', $member_id ],
[ 'site_id', '=', $site_id ]
])->field($account_type .','.$account_type."_get" .', username, mobile, nickname')->lock(true)->find();
if(empty($member_info)) throw new CommonException('MEMBER_NOT_EXIST');
])->field($account_type . ',' . $account_type . "_get" . ', username, mobile, nickname')->lock(true)->find();
if (empty($member_info)) throw new CommonException('MEMBER_NOT_EXIST');
$account_new_data = round((float) $member_info[ $account_type ] + (float) $account_data, 2);
if ($account_new_data < 0) {
throw new CommonException('ACCOUNT_INSUFFICIENT');
}
$data = array (
$data = array(
'site_id' => $site_id,
'member_id' => $member_id,
'account_type' => $account_type,
@ -55,7 +55,7 @@ class CoreMemberAccountService extends BaseCoreService
'nickname' => $member_info[ 'nickname' ],
'mobile' => $member_info[ 'mobile' ],
'memo' => $memo,
'related_id'=>$related_id,
'related_id' => $related_id,
);
Db::startTrans();
@ -63,37 +63,36 @@ class CoreMemberAccountService extends BaseCoreService
$res = $member_account_log_model->create($data);
//账户更新
if($account_data > 0)
{
if ($account_data > 0) {
if ($account_type == MemberAccountTypeDict::GROWTH) {
$account_type_get = $member_info[ $account_type."_get" ] + $account_data;
$account_type_get = $member_info[ $account_type . "_get" ] + $account_data;
} else {
$from_type_arr = MemberAccountChangeTypeDict::getType($account_type)[$from_type];
$is_change_get = $from_type_arr['is_change_get'] ?? 1;
$from_type_arr = MemberAccountChangeTypeDict::getType($account_type)[ $from_type ];
$is_change_get = $from_type_arr[ 'is_change_get' ] ?? 1;
if ($is_change_get) {
$account_type_get = $member_info[ $account_type."_get" ] + $account_data;
$account_type_get = $member_info[ $account_type . "_get" ] + $account_data;
} else {
$account_type_get = $member_info[ $account_type."_get" ];
$account_type_get = $member_info[ $account_type . "_get" ];
}
}
}else{
$account_type_get = $member_info[ $account_type."_get" ];
} else {
$account_type_get = $member_info[ $account_type . "_get" ];
}
$member_model->update([
$account_type => $account_new_data,
$account_type."_get" => $account_type_get
$account_type . "_get" => $account_type_get
], [
'member_id' => $member_id
]);
//账户变化事件
$data[] = [
$account_type => $account_new_data,
$account_type."_get" => $account_type_get
$account_type . "_get" => $account_type_get
];
event("MemberAccount", $data);
Db::commit();
return $res->id;
} catch ( Exception $e) {
} catch (Exception $e) {
Db::rollback();
throw new CommonException($e->getMessage());
}

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;
/**
* 会员相关设置
@ -31,14 +29,17 @@ class CoreMemberConfigService extends BaseCoreService
* @param int $site_id
* @return array
*/
public function getLoginConfig(int $site_id){
$info = (new CoreConfigService())->getConfig($site_id, 'LOGIN')['value'] ?? [];
public function getLoginConfig(int $site_id)
{
$info = ( new CoreConfigService() )->getConfig($site_id, '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' ] ?? '精选好物,购物优惠的省钱平台' // 描述
];
}
@ -48,15 +49,18 @@ class CoreMemberConfigService extends BaseCoreService
* @param array $data
* @return true
*/
public function setLoginConfig(int $site_id, array $data){
public function setLoginConfig(int $site_id, array $data)
{
$config = [
'is_username' => $data['is_username'] ?? 1,//是否用户名密码登录
'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 // 政策协议是否展示
'is_username' => $data[ 'is_username' ] ?? 1,//是否用户名密码登录
'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, // 政策协议是否展示
'bg_url' => $data[ 'bg_url' ] ?? '', // 背景图片
'desc' => $data[ 'desc' ] ?? '' // 描述
];
(new CoreConfigService())->setConfig($site_id, 'LOGIN', $config);
( new CoreConfigService() )->setConfig($site_id, 'LOGIN', $config);
return true;
}
@ -65,11 +69,12 @@ class CoreMemberConfigService extends BaseCoreService
* @param int $site_id
* @return array
*/
public function getMemberConfig(int $site_id){
$info = (new CoreConfigService())->getConfig($site_id, 'MEMBER')['value'] ?? [];
public function getMemberConfig(int $site_id)
{
$info = ( new CoreConfigService() )->getConfig($site_id, 'MEMBER')[ 'value' ] ?? [];
return [
'prefix' => $info['prefix'] ?? '',// 会员编码前缀
'length' => $info['length'] ?? 4, // 会员编码长度
'prefix' => $info[ 'prefix' ] ?? '',// 会员编码前缀
'length' => $info[ 'length' ] ?? 4, // 会员编码长度
];
}
@ -79,12 +84,13 @@ class CoreMemberConfigService extends BaseCoreService
* @param array $data
* @return true
*/
public function setMemberConfig(int $site_id, array $data){
public function setMemberConfig(int $site_id, array $data)
{
$config = [
'prefix' => $data['prefix'] ?? '',// 会员编码前缀
'length' => $data['length'] ?? 4,// 会员编码长度
'prefix' => $data[ 'prefix' ] ?? '',// 会员编码前缀
'length' => $data[ 'length' ] ?? 4,// 会员编码长度
];
(new CoreConfigService())->setConfig($site_id, 'MEMBER', $config);
( new CoreConfigService() )->setConfig($site_id, 'MEMBER', $config);
return true;
}
@ -93,8 +99,9 @@ class CoreMemberConfigService extends BaseCoreService
* @param int $site_id
* @return array
*/
public function getGrowthRuleConfig(int $site_id){
return (new CoreConfigService())->getConfigValue($site_id, 'GROWTH_RULE');
public function getGrowthRuleConfig(int $site_id)
{
return ( new CoreConfigService() )->getConfigValue($site_id, 'GROWTH_RULE');
}
/**
@ -103,8 +110,9 @@ class CoreMemberConfigService extends BaseCoreService
* @param array $data
* @return true
*/
public function setGrowthRuleConfig(int $site_id, array $data){
(new CoreConfigService())->setConfig($site_id, 'GROWTH_RULE', $data);
public function setGrowthRuleConfig(int $site_id, array $data)
{
( new CoreConfigService() )->setConfig($site_id, 'GROWTH_RULE', $data);
return true;
}
@ -113,8 +121,9 @@ class CoreMemberConfigService extends BaseCoreService
* @param int $site_id
* @return array
*/
public function getPointRuleConfig(int $site_id){
return (new CoreConfigService())->getConfigValue($site_id, 'POINT_RULE');
public function getPointRuleConfig(int $site_id)
{
return ( new CoreConfigService() )->getConfigValue($site_id, 'POINT_RULE');
}
/**
@ -123,8 +132,9 @@ class CoreMemberConfigService extends BaseCoreService
* @param array $data
* @return true
*/
public function setPointRuleConfig(int $site_id, array $data){
(new CoreConfigService())->setConfig($site_id, 'POINT_RULE', $data);
public function setPointRuleConfig(int $site_id, array $data)
{
( new CoreConfigService() )->setConfig($site_id, 'POINT_RULE', $data);
return true;
}
@ -133,16 +143,17 @@ class CoreMemberConfigService extends BaseCoreService
* @param int $site_id
* @return array
*/
public function getCashOutConfig(int $site_id){
$config = (new CoreConfigService())->getConfig($site_id, ConfigKeyDict::MEMBER_CASH_OUT)['value'] ?? [];
public function getCashOutConfig(int $site_id)
{
$config = ( new CoreConfigService() )->getConfig($site_id, ConfigKeyDict::MEMBER_CASH_OUT)[ 'value' ] ?? [];
return [
'is_open' => $config['is_open'] ?? '0',//是否启用提现
'transfer_type' => $config['transfer_type'] ?? [],//提现方式
'min' => $config['min'] ?? '0',//最低提现金额
'is_open' => $config[ 'is_open' ] ?? '0',//是否启用提现
'transfer_type' => $config[ 'transfer_type' ] ?? [],//提现方式
'min' => $config[ 'min' ] ?? '0',//最低提现金额
// 'max' => '0',//最高提现金额
'rate' => $config['rate'] ?? '0',//手续费比率
'is_auto_verify' => $config['is_auto_verify'] ?? '0', //是否自动审核
'is_auto_transfer' => $config['is_auto_transfer'] ?? '0', //是否自动转账
'rate' => $config[ 'rate' ] ?? '0',//手续费比率
'is_auto_verify' => $config[ 'is_auto_verify' ] ?? '0', //是否自动审核
'is_auto_transfer' => $config[ 'is_auto_transfer' ] ?? '0', //是否自动转账
];
}
@ -152,20 +163,21 @@ class CoreMemberConfigService extends BaseCoreService
* @param array $data
* @return true
*/
public function setCashOutConfig(int $site_id, array $data){
public function setCashOutConfig(int $site_id, array $data)
{
//校验转账方式是否合法
$transfer_type_list = array_keys(TransferDict::getTransferType());
if(array_diff(array_diff($data['transfer_type'], $transfer_type_list), $transfer_type_list)) throw new CommonException('TRANSFER_TYPE_NOT_EXIST');
if (array_diff(array_diff($data[ 'transfer_type' ], $transfer_type_list), $transfer_type_list)) throw new CommonException('TRANSFER_TYPE_NOT_EXIST');
$config = [
'is_open' => $data['is_open'],//是否启用提现
'transfer_type' => $data['transfer_type'] ?? [],//提现方式
'min' => $data['min'] ?? '',//最低提现金额
'is_auto_verify' => $data['is_auto_verify'] ?? 0, //是否自动审核
'is_auto_transfer' => $data['is_auto_transfer'] ?? 0, //是否自动转账
'is_open' => $data[ 'is_open' ],//是否启用提现
'transfer_type' => $data[ 'transfer_type' ] ?? [],//提现方式
'min' => $data[ 'min' ] ?? '',//最低提现金额
'is_auto_verify' => $data[ 'is_auto_verify' ] ?? 0, //是否自动审核
'is_auto_transfer' => $data[ 'is_auto_transfer' ] ?? 0, //是否自动转账
// 'max' => $data['max'] ?? '',//最高提现金额
'rate' => $data['rate'] ?? '',//手续费比率
'rate' => $data[ 'rate' ] ?? '',//手续费比率
];
(new CoreConfigService())->setConfig($site_id, ConfigKeyDict::MEMBER_CASH_OUT, $config);
( new CoreConfigService() )->setConfig($site_id, ConfigKeyDict::MEMBER_CASH_OUT, $config);
return true;
}

View File

@ -11,12 +11,10 @@
namespace app\service\core\niucloud;
use app\service\admin\niucloud\NiucloudService;
use core\util\niucloud\BaseNiucloudClient;
use core\util\niucloud\http\Response;
use GuzzleHttp\Exception\GuzzleException;
use Psr\Http\Message\ResponseInterface;
use RuntimeException;
/**
* 官网授权管理服务层

View File

@ -14,7 +14,6 @@ namespace app\service\core\niucloud;
use app\model\addon\Addon;
use app\service\core\addon\CoreAddonBaseService;
use app\service\core\addon\CoreAddonDevelopDownloadService;
use app\service\core\addon\CoreAddonInstallService;
use core\base\BaseCoreService;
use core\exception\CommonException;
use core\util\niucloud\BaseNiucloudClient;

View File

@ -11,7 +11,6 @@
namespace app\service\core\niucloud;
use app\service\admin\niucloud\NiucloudService;
use core\util\niucloud\BaseNiucloudClient;
use core\util\niucloud\http\Response;
use GuzzleHttp\Exception\GuzzleException;

View File

@ -11,11 +11,7 @@
namespace app\service\core\niucloud;
use app\service\admin\niucloud\NiucloudService;
use core\util\niucloud\BaseNiucloudClient;
use core\util\niucloud\http\Response;
use GuzzleHttp\Exception\GuzzleException;
use Psr\Http\Message\ResponseInterface;
/**
* 官网授权管理服务层
@ -40,6 +36,4 @@ class CoreNotifyService extends BaseNiucloudClient
return success();
}
}

View File

@ -56,7 +56,7 @@ class CorePayEventService extends BaseCoreService
$this->site_id = $site_id;
$this->channel = $channel;
$this->type = $type;
$this->config = (new CorePayChannelService())->getConfigByChannelAndType($this->site_id, $this->channel, $this->type);
$this->config = ( new CorePayChannelService() )->getConfigByChannelAndType($this->site_id, $this->channel, $this->type);
return $this;
}
@ -68,9 +68,9 @@ class CorePayEventService extends BaseCoreService
*/
public function app(string $action = 'query')
{
$notify_url = (string)url("/api/pay/notify/$this->site_id/$this->channel/$this->type/$action", [], '', true);//异步回调通知地址
$this->config['notify_url'] = $notify_url;
$this->config['site_id'] = $this->site_id;
$notify_url = (string) url("/api/pay/notify/$this->site_id/$this->channel/$this->type/$action", [], '', true);//异步回调通知地址
$this->config[ 'notify_url' ] = $notify_url;
$this->config[ 'site_id' ] = $this->site_id;
return new PayLoader($this->type, $this->config);
}
@ -91,8 +91,8 @@ class CorePayEventService extends BaseCoreService
{
$pay_fun = '';
if(mb_strlen($body, 'UTF-8') > 15){
$body = mb_substr($body, 0, 15, 'UTF-8').'...';
if (mb_strlen($body, 'UTF-8') > 15) {
$body = mb_substr($body, 0, 15, 'UTF-8') . '...';
}
$params = array(
'out_trade_no' => $out_trade_no,
@ -108,7 +108,7 @@ class CorePayEventService extends BaseCoreService
);
switch ($this->type) {
case PayDict::WECHATPAY:
$params['money'] = (int)bcmul($params['money'], 100);
$params[ 'money' ] = (int) bcmul($params[ 'money' ], 100);
switch ($this->channel) {
case ChannelDict::H5://h5
$pay_fun = 'wap';
@ -174,7 +174,7 @@ class CorePayEventService extends BaseCoreService
$transfer_type = TransferDict::getPayTypeByTransfer($this->type);
switch ($transfer_type) {
case PayDict::WECHATPAY:
$money *= 100;
$money = (int) bcmul($money, 100);
break;
case PayDict::ALIPAY:
break;
@ -218,8 +218,8 @@ class CorePayEventService extends BaseCoreService
public function refund(string $out_trade_no, float $money, float $total, string $refund_no, $voucher = '')
{
if ($this->type == PayDict::WECHATPAY) {
$money *= 100;
$total *= 100;
$money = (int) bcmul($money, 100);
$total = (int) bcmul($total, 100);
}
return $this->app('refund')->refund([
'site_id' => $this->site_id,
@ -253,7 +253,7 @@ class CorePayEventService extends BaseCoreService
*/
public function getOrder(string $out_trade_no)
{
return $this->app()->getOrder(['out_trade_no' => $out_trade_no]);
return $this->app()->getOrder([ 'out_trade_no' => $out_trade_no ]);
}
/**

View File

@ -80,12 +80,12 @@ class CorePayService extends BaseCoreService
public function findPayInfoByTrade(int $site_id, string $trade_type, int $trade_id)
{
$where = array(
['site_id', '=', $site_id],
['trade_type', '=', $trade_type],
['trade_id', '=', $trade_id],
['status', '<>', PayDict::STATUS_CANCLE],///不查询已取消的单据
[ 'site_id', '=', $site_id ],
[ 'trade_type', '=', $trade_type ],
[ 'trade_id', '=', $trade_id ],
[ 'status', '<>', PayDict::STATUS_CANCLE ],///不查询已取消的单据
);
return $this->model->where($where)->append(['type_name', 'status_name'])->findOrEmpty();
return $this->model->where($where)->append([ 'type_name', 'status_name' ])->findOrEmpty();
}
/**
@ -97,10 +97,10 @@ class CorePayService extends BaseCoreService
public function findPayInfoByOutTradeNo(int $site_id, string $out_trade_no)
{
$where = array(
['site_id', '=', $site_id],
['out_trade_no', '=', $out_trade_no]
[ 'site_id', '=', $site_id ],
[ 'out_trade_no', '=', $out_trade_no ]
);
return $this->model->where($where)->append(['type_name', 'status_name'])->findOrEmpty();
return $this->model->where($where)->append([ 'type_name', 'status_name' ])->findOrEmpty();
}
/**
@ -116,13 +116,13 @@ class CorePayService extends BaseCoreService
public function getInfoByOutTradeNo(int $site_id, string $out_trade_no, string $channel)
{
$where = array(
['site_id', '=', $site_id],
['out_trade_no', '=', $out_trade_no]
[ 'site_id', '=', $site_id ],
[ 'out_trade_no', '=', $out_trade_no ]
);
$pay = $this->model->where($where)->append(['type_name', 'status_name'])->findOrEmpty()->toArray();
$pay = $this->model->where($where)->append([ 'type_name', 'status_name' ])->findOrEmpty()->toArray();
if (!empty($pay)) {
//todo 校验场景控制支付方式
$pay['pay_type_list'] = array_values((new CorePayChannelService())->getAllowPayTypeByChannel($site_id, $channel, $pay['trade_type']));
$pay[ 'pay_type_list' ] = array_values(( new CorePayChannelService() )->getAllowPayTypeByChannel($site_id, $channel, $pay[ 'trade_type' ]));
}
return $pay;
}
@ -145,12 +145,12 @@ class CorePayService extends BaseCoreService
//创建新的支付单据
$pay = $this->createByTrade($site_id, $trade_type, $trade_id);
}
if(!is_array($pay)){
if (!is_array($pay)) {
$pay = $pay->toArray();
}
if (!empty($pay)) {
//todo 校验场景控制支付方式
$pay['pay_type_list'] = array_values((new CorePayChannelService())->getAllowPayTypeByChannel($site_id, $channel, $pay['trade_type']));
$pay[ 'pay_type_list' ] = array_values(( new CorePayChannelService() )->getAllowPayTypeByChannel($site_id, $channel, $pay[ 'trade_type' ]));
}
return $pay;
}
@ -168,7 +168,7 @@ class CorePayService extends BaseCoreService
public function getPayTypeByTrade(int $site_id, string $trade_type, string $channel)
{
//todo 校验场景控制支付方式
return array_values((new CorePayChannelService())->getAllowPayTypeByChannel($site_id, $channel, $trade_type));
return array_values(( new CorePayChannelService() )->getAllowPayTypeByChannel($site_id, $channel, $trade_type));
}
/**
@ -191,14 +191,14 @@ class CorePayService extends BaseCoreService
{
//检测并创建支付单据
$pay = $this->checkOrCreate($site_id, $trade_type, $trade_id);
$out_trade_no = $pay['out_trade_no'];
$money = $pay['money'];
$body = $pay['body'];
$trade_type = $pay['trade_type'];
if (!in_array($type, array_column((new CorePayChannelService())->getAllowPayTypeByChannel($site_id, $channel, $trade_type), 'key'))) throw new PayException('PAYMENT_METHOD_NOT_SCENE');//场景不支持
$out_trade_no = $pay[ 'out_trade_no' ];
$money = $pay[ 'money' ];
$body = $pay[ 'body' ];
$trade_type = $pay[ 'trade_type' ];
if (!in_array($type, array_column(( new CorePayChannelService() )->getAllowPayTypeByChannel($site_id, $channel, $trade_type), 'key'))) throw new PayException('PAYMENT_METHOD_NOT_SCENE');//场景不支持
$pay_result = $this->pay_event->init($site_id, $channel, $type)->pay($out_trade_no, $money, $body, $return_url, $quit_url, $buyer_id, $openid ?? '', $voucher);
//todo 特殊支付方式会直接返回支付状态,状态如果为已支付会直接支付
if (!empty($pay_result['status']) && $pay_result['status'] == PayDict::STATUS_FINISH) {
if (!empty($pay_result[ 'status' ]) && $pay_result[ 'status' ] == PayDict::STATUS_FINISH) {
$pay->save([ 'channel' => $channel ]);
$this->paySuccess($site_id, [
'status' => PayDict::STATUS_FINISH,
@ -233,8 +233,8 @@ class CorePayService extends BaseCoreService
'channel' => $channel
]
);
if(env('queue.state', true) ){
PayReturnTo::dispatch(['site_id' => $site_id, 'out_trade_no' => $out_trade_no], secs: 15);
if (env('queue.state', true)) {
PayReturnTo::dispatch([ 'site_id' => $site_id, 'out_trade_no' => $out_trade_no ], secs: 15);
}
}
return $pay_result;
@ -254,10 +254,10 @@ class CorePayService extends BaseCoreService
//创建新的支付单据
$pay = $this->createByTrade($site_id, $trade_type, $trade_id);
}
if ($pay['status'] == PayDict::STATUS_FINISH) throw new PayException('PAY_SUCCESS');
if ($pay[ 'status' ] == PayDict::STATUS_FINISH) throw new PayException('PAY_SUCCESS');
// if ($pay['status'] == PayDict::STATUS_CANCLE) throw new PayException('PAY_IS_REMOVE');
if ($pay['status'] == PayDict::STATUS_ING || $pay['status'] == PayDict::STATUS_CANCLE) {
if($pay['status'] == PayDict::STATUS_ING ){
if ($pay[ 'status' ] == PayDict::STATUS_ING || $pay[ 'status' ] == PayDict::STATUS_CANCLE) {
if ($pay[ 'status' ] == PayDict::STATUS_ING) {
//尝试关闭原有的支付单据
$this->close($site_id, $pay->out_trade_no);
}
@ -274,19 +274,20 @@ class CorePayService extends BaseCoreService
* @param $trade_id
* @return Pay|array|mixed|Model
*/
public function createByTrade($site_id, $trade_type, $trade_id){
public function createByTrade($site_id, $trade_type, $trade_id)
{
//创建新的支付单据
$data = array_values(array_filter(event('PayCreate', ['site_id' => $site_id,'trade_type' => $trade_type, 'trade_id' => $trade_id])))[0] ?? [];
if(empty($data)) throw new PayException('PAY_NOT_FOUND_TRADE');//找不到可支付的交易
$data = array_values(array_filter(event('PayCreate', [ 'site_id' => $site_id, 'trade_type' => $trade_type, 'trade_id' => $trade_id ])))[ 0 ] ?? [];
if (empty($data)) throw new PayException('PAY_NOT_FOUND_TRADE');//找不到可支付的交易
if(isset($data['status']) && $data['money'] == 0){
$data['status'] = PayDict::STATUS_FINISH;
$data['status_name'] = PayDict::getStatus()[$data['status']] ?? '';
$data['type'] = PayDict::BALANCEPAY;
$data['type_name'] = PayDict::getPayType()[$data['type']]['name'] ?? '';
if (isset($data[ 'status' ]) && $data[ 'money' ] == 0) {
$data[ 'status' ] = PayDict::STATUS_FINISH;
$data[ 'status_name' ] = PayDict::getStatus()[ $data[ 'status' ] ] ?? '';
$data[ 'type' ] = PayDict::BALANCEPAY;
$data[ 'type_name' ] = PayDict::getPayType()[ $data[ 'type' ] ][ 'name' ] ?? '';
return $data;
}else{
$out_trade_no = $this->create($site_id, $data['main_type'], $data['main_id'], $data['money'], $data['trade_type'], $data['trade_id'], $data['body']);
} else {
$out_trade_no = $this->create($site_id, $data[ 'main_type' ], $data[ 'main_id' ], $data[ 'money' ], $data[ 'trade_type' ], $data[ 'trade_id' ], $data[ 'body' ]);
return $this->findPayInfoByOutTradeNo($site_id, $out_trade_no);
}
}
@ -307,12 +308,12 @@ class CorePayService extends BaseCoreService
$pay = $this->findPayInfoByOutTradeNo($site_id, $out_trade_no);
}
if ($pay->isEmpty()) return true;
if ($pay['status'] != PayDict::STATUS_ING) return true;
if ($pay[ 'status' ] != PayDict::STATUS_ING) return true;
if (empty($pay->type)) return true;
//尝试取消或关闭第三方支付
try {
$close = $this->close($site_id, $out_trade_no);
} catch ( Throwable $e ) {
} catch (Throwable $e) {
$close = false;
}
return $close;
@ -328,20 +329,20 @@ class CorePayService extends BaseCoreService
{
$pay = $this->findPayInfoByOutTradeNo($site_id, $out_trade_no);
if ($pay->isEmpty()) throw new PayException('ALIPAY_TRANSACTION_NO_NOT_EXIST');
if($pay['status'] == PayDict::STATUS_CANCLE) return true;
if ($pay[ 'status' ] == PayDict::STATUS_CANCLE) return true;
if (!in_array($pay['status'], [
if (!in_array($pay[ 'status' ], [
PayDict::STATUS_WAIT,
PayDict::STATUS_ING
])) throw new PayException('TREAT_PAYMENT_IS_OPEN');
if ($pay['status'] == PayDict::STATUS_ING) {
if ($pay[ 'status' ] == PayDict::STATUS_ING) {
if (!empty($pay->type)) {
//尝试取消或关闭第三方支付
$close = $this->pay_event->init($site_id, $pay->channel, $pay->type)->close($out_trade_no);
if (!$close) {//有问题查询第三方订单详情
$order = $this->pay_event->init($site_id, $pay->channel, $pay->type)->getOrder($out_trade_no);
if (!empty($order)) {
if ($order['status'] == OnlinePayDict::SUCCESS) {//如果已支付,就将支付调整为已支付
if ($order[ 'status' ] == OnlinePayDict::SUCCESS) {//如果已支付,就将支付调整为已支付
$this->paySuccess($site_id, [
'out_trade_no' => $out_trade_no,
'type' => $pay->type
@ -372,11 +373,11 @@ class CorePayService extends BaseCoreService
// if ($pay->isEmpty()) throw new PayException('ALIPAY_TRANSACTION_NO_NOT_EXIST');
if ($pay->isEmpty()) return true;
// if ($pay['status'] == PayDict::STATUS_FINISH) throw new PayException('DOCUMENT_IS_PAID');//当前单据已支付
if (!in_array($pay['status'], [
if (!in_array($pay[ 'status' ], [
PayDict::STATUS_WAIT,
PayDict::STATUS_ING
])) throw new PayException('IS_PAY_REMOVE_NOT_RESETTING');//只有待支付可以关闭支付
if (!$this->close($site_id, $pay['out_trade_no'])) {
if (!$this->close($site_id, $pay[ 'out_trade_no' ])) {
throw new PayException('DOCUMENT_IS_PAY_REMOVE');
}
return true;
@ -395,9 +396,9 @@ class CorePayService extends BaseCoreService
$pay = $this->findPayInfoByOutTradeNo($site_id, $out_trade_no);
if ($pay->isEmpty()) throw new PayException('ALIPAY_TRANSACTION_NO_NOT_EXIST');
if ($pay['status'] == PayDict::STATUS_FINISH) throw new PayException('DOCUMENT_IS_PAID');
if ($pay['status'] == PayDict::STATUS_CANCLE) throw new PayException('PAY_IS_REMOVE');
$status = $params['status'];
if ($pay[ 'status' ] == PayDict::STATUS_FINISH) throw new PayException('DOCUMENT_IS_PAID');
if ($pay[ 'status' ] == PayDict::STATUS_CANCLE) throw new PayException('PAY_IS_REMOVE');
$status = $params[ 'status' ];
switch ($status) {
case OnlinePayDict::SUCCESS://支付成功
$this->paySuccess($site_id, array_merge([
@ -433,19 +434,19 @@ class CorePayService extends BaseCoreService
*/
public function notify(int $site_id, string $channel, string $type, string $action)
{
$callback = function ($out_trade_no, $params) use ($site_id, $type, $action) {
$callback = function($out_trade_no, $params) use ($site_id, $type, $action) {
try {
switch ($action) {
case 'pay'://支付结果通知
return $this->payNotify($site_id, $out_trade_no, $type, $params);
break;
case 'refund':
return (new CoreRefundService())->refundNotify($site_id, $out_trade_no, $type, $params);
return ( new CoreRefundService() )->refundNotify($site_id, $out_trade_no, $type, $params);
break;
}
//找不到对应的业务
return true;
} catch ( PayException $e ) {
} catch (PayException $e) {
return false;
}
};
@ -460,17 +461,17 @@ class CorePayService extends BaseCoreService
*/
public function check(int $site_id, array $data)
{
$out_trade_no = $data['out_trade_no'];
$out_trade_no = $data[ 'out_trade_no' ];
$pay = $this->findPayInfoByOutTradeNo($site_id, $out_trade_no);
if ($pay->isEmpty()) throw new PayException('ALIPAY_TRANSACTION_NO_NOT_EXIST');
if ($pay['status'] == PayDict::STATUS_FINISH) throw new PayException('PAY_SUCCESS');//单据已支付
if ($pay['status'] == PayDict::STATUS_CANCLE) throw new PayException('PAY_IS_REMOVE');//单据已取消
if ($pay[ 'status' ] == PayDict::STATUS_FINISH) throw new PayException('PAY_SUCCESS');//单据已支付
if ($pay[ 'status' ] == PayDict::STATUS_CANCLE) throw new PayException('PAY_IS_REMOVE');//单据已取消
//查询第三方支付单据
$pay_info = $this->pay_event->init($site_id, $pay->channel, $pay->type)->getOrder($out_trade_no);
$type = $pay['type'];
$type = $pay[ 'type' ];
if (empty($pay_info))
return false;
$status = $pay_info['status'];
$status = $pay_info[ 'status' ];
switch ($status) {
case OnlinePayDict::SUCCESS://支付成功
$this->paySuccess($site_id, [
@ -503,27 +504,27 @@ class CorePayService extends BaseCoreService
*/
public function paySuccess($site_id, $params)
{
$out_trade_no = $params['out_trade_no'];
$out_trade_no = $params[ 'out_trade_no' ];
$pay = $this->findPayInfoByOutTradeNo($site_id, $out_trade_no);
$type = $params['type'];
$type = $params[ 'type' ];
$trade_type = $pay->trade_type;
$trade_id = $pay->trade_id;
$data = array(
'pay_time' => time(),
'status' => PayDict::STATUS_FINISH,
'type' => $type,
'trade_no' => $params['trade_no'] ?? '',
'voucher' => $params['voucher'] ?? '',
'mch_id' => $params['mch_id'] ?? '',
'trade_no' => $params[ 'trade_no' ] ?? '',
'voucher' => $params[ 'voucher' ] ?? '',
'mch_id' => $params[ 'mch_id' ] ?? '',
);
//允许修改的值
$allow_field = array('trade_no', 'voucher', 'status', 'pay_time', 'type', 'mch_id');
$allow_field = array( 'trade_no', 'voucher', 'status', 'pay_time', 'type', 'mch_id' );
// 启动事务
Db::startTrans();
try {
$pay->allowField($allow_field)->save($data);
$result = event('PaySuccess', ['out_trade_no' => $out_trade_no, 'trade_type' => $trade_type, 'site_id' => $site_id, 'trade_id' => $trade_id]);
$result = event('PaySuccess', [ 'out_trade_no' => $out_trade_no, 'trade_type' => $trade_type, 'site_id' => $site_id, 'trade_id' => $trade_id ]);
// if (!check_event_result($result)) {
// Db::rollback();
// return false;
@ -531,10 +532,10 @@ class CorePayService extends BaseCoreService
// 提交事务
Db::commit();
return true;
} catch ( Throwable $e ) {
} catch (Throwable $e) {
// 回滚事务
Db::rollback();
throw new PayException($e->getMessage().$e->getFile().$e->getLine());
throw new PayException($e->getMessage() . $e->getFile() . $e->getLine());
}
return true;
}
@ -547,17 +548,17 @@ class CorePayService extends BaseCoreService
*/
public function payClose($site_id, $data)
{
$out_trade_no = $data['out_trade_no'];
$out_trade_no = $data[ 'out_trade_no' ];
Db::startTrans();
try {
$pay = $this->findPayInfoByOutTradeNo($site_id, $out_trade_no);
$pay->save([
'status' => PayDict::STATUS_CANCLE,
'fail_reason' => $data['reason'] ?? ''
'fail_reason' => $data[ 'reason' ] ?? ''
]);
$result = event('PayClose', ['out_trade_no' => $out_trade_no, 'site_id' => $site_id, 'trade_type' => $pay->trade_type, 'trade_id' => $pay->trade_id ]);
$result = event('PayClose', [ 'out_trade_no' => $out_trade_no, 'site_id' => $site_id, 'trade_type' => $pay->trade_type, 'trade_id' => $pay->trade_id ]);
if (!check_event_result($result)) {
Db::rollback();
return false;
@ -565,10 +566,10 @@ class CorePayService extends BaseCoreService
// 提交事务
Db::commit();
return true;
} catch ( Throwable $e ) {
} catch (Throwable $e) {
// 回滚事务
Db::rollback();
throw new PayException($e->getMessage().$e->getFile().$e->getLine());
throw new PayException($e->getMessage() . $e->getFile() . $e->getLine());
}
}

View File

@ -61,6 +61,7 @@ class CoreScheduleInstallService extends BaseCoreService
$this->model->where([['addon', '=', $addon]])->delete();
return true;
}
/**
* 安装计划任务
* @param array $data
@ -70,16 +71,19 @@ 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

@ -32,14 +32,14 @@ class CoreSiteAccountService extends BaseCoreService
*/
public function addPayLog(array $pay_info)
{
$pay_info = (new Pay())->where([['out_trade_no', '=', $pay_info['out_trade_no']], ['site_id', '=', $pay_info['site_id']]])->findOrEmpty()->toArray();
$pay_info = ( new Pay() )->where([ [ 'out_trade_no', '=', $pay_info[ 'out_trade_no' ] ], [ 'site_id', '=', $pay_info[ 'site_id' ] ] ])->findOrEmpty()->toArray();
$data = [
'site_id' => $pay_info['site_id'],
'site_id' => $pay_info[ 'site_id' ],
'type' => 'pay',
'money' => $pay_info['money'],
'trade_no' => $pay_info['out_trade_no'],
'money' => $pay_info[ 'money' ],
'trade_no' => $pay_info[ 'out_trade_no' ],
];
$res = (new SiteAccountLog())->create($data);
$res = ( new SiteAccountLog() )->create($data);
return $res->id;
}
@ -51,14 +51,14 @@ class CoreSiteAccountService extends BaseCoreService
*/
public function addRefundLog(int $site_id, string $refund_no)
{
$refund_info = (new Refund())->where([['refund_no', '=', $refund_no], ['site_id', '=', $site_id]])->findOrEmpty()->toArray();
$refund_info = ( new Refund() )->where([ [ 'refund_no', '=', $refund_no ], [ 'site_id', '=', $site_id ] ])->findOrEmpty()->toArray();
$data = [
'site_id' => $refund_info['site_id'],
'site_id' => $refund_info[ 'site_id' ],
'type' => 'refund',
'money' => $refund_info['money'] *(-1),
'trade_no' => $refund_info['refund_no'],
'money' => $refund_info[ 'money' ] * ( -1 ),
'trade_no' => $refund_info[ 'refund_no' ],
];
$res = (new SiteAccountLog())->create($data);
$res = ( new SiteAccountLog() )->create($data);
return $res->id;
}
@ -70,14 +70,14 @@ class CoreSiteAccountService extends BaseCoreService
*/
public function addTransferLog(int $site_id, string $transfer_no)
{
$transfer_info = (new Transfer())->where([['transfer_no', '=', $transfer_no], ['site_id', '=', $site_id]])->findOrEmpty()->toArray();
$transfer_info = ( new Transfer() )->where([ [ 'transfer_no', '=', $transfer_no ], [ 'site_id', '=', $site_id ] ])->findOrEmpty()->toArray();
$data = [
'site_id' => $transfer_info['site_id'],
'site_id' => $transfer_info[ 'site_id' ],
'type' => 'transfer',
'money' => $transfer_info['money'] *(-1),
'trade_no' => $transfer_info['transfer_no'],
'money' => $transfer_info[ 'money' ] * ( -1 ),
'trade_no' => $transfer_info[ 'transfer_no' ],
];
$res = (new SiteAccountLog())->create($data);
$res = ( new SiteAccountLog() )->create($data);
return $res->id;
}

View File

@ -17,8 +17,6 @@ use app\dict\sys\AppTypeDict;
use app\model\addon\Addon;
use app\model\site\Site;
use app\model\site\SiteGroup;
use app\service\admin\site\SiteGroupService;
use app\service\admin\site\SiteService;
use core\base\BaseCoreService;
use core\exception\CommonException;
use think\db\exception\DataNotFoundException;
@ -55,11 +53,11 @@ class CoreSiteService extends BaseCoreService
$where = [
[ 'site_id', '=', $site_id ],
];
$info = $this->model->where($where)->field('site_id, site_name, front_end_name, front_end_logo, app_type, keywords, logo, icon, `desc`, status, latitude, longitude, province_id, city_id, district_id, address, full_address, phone, business_hours, create_time, expire_time, group_id, app, addons, site_domain')->append([ 'status_name' ])->findOrEmpty()->toArray();
$info = $this->model->where($where)->field('site_id, site_name, front_end_name, front_end_logo,front_end_icon, app_type, keywords, logo, icon, `desc`, status, latitude, longitude, province_id, city_id, district_id, address, full_address, phone, business_hours, create_time, expire_time, group_id, app, addons, site_domain')->append([ 'status_name' ])->findOrEmpty()->toArray();
if (!empty($info)) {
$site_addons = (new CoreSiteService())->getAddonKeysBySiteId((int)$site_id);
$info['apps'] = (new Addon())->where([ ['key', 'in', $site_addons], ['type', '=', AddonDict::APP]])->field('key,title,desc,icon,type')->select()->toArray();
$info['site_addons'] = (new Addon())->where([ ['key', 'in', $site_addons], ['type', '=', AddonDict::ADDON]])->field('key,title,desc,icon,type')->select()->toArray();
$site_addons = ( new CoreSiteService() )->getAddonKeysBySiteId((int) $site_id);
$info[ 'apps' ] = ( new Addon() )->where([ [ 'key', 'in', $site_addons ], [ 'type', '=', AddonDict::APP ] ])->field('key,title,desc,icon,type')->select()->toArray();
$info[ 'site_addons' ] = ( new Addon() )->where([ [ 'key', 'in', $site_addons ], [ 'type', '=', AddonDict::ADDON ] ])->field('key,title,desc,icon,type')->select()->toArray();
}
return $info;
},
@ -72,14 +70,15 @@ class CoreSiteService extends BaseCoreService
* @param string $domain
* @return mixed|string
*/
public function getSiteIdByDomain(string $domain) {
public function getSiteIdByDomain(string $domain)
{
if (empty($domain)) return;
$cache_name = 'site_domain';
return cache_remember(
$cache_name . $domain,
function() use ($domain) {
return $this->model->where([ ['site_domain', '=', $domain] ])->value('site_id');
return $this->model->where([ [ 'site_domain', '=', $domain ] ])->value('site_id');
},
self::$cache_tag_name
);
@ -135,12 +134,13 @@ class CoreSiteService extends BaseCoreService
* @param int $site_id
* @return array
*/
public function getAddonKeysBySiteId(int $site_id){
public function getAddonKeysBySiteId(int $site_id)
{
$cache_name = 'site_addon_key_cache';
return cache_remember(
$cache_name . $site_id,
function() use ($site_id) {
$site_info = (new Site())->where([ ['site_id', '=', $site_id] ])->field('group_id,app_type,addons')->findOrEmpty();
$site_info = ( new Site() )->where([ [ 'site_id', '=', $site_id ] ])->field('group_id,app_type,addons')->findOrEmpty();
if ($site_info->isEmpty()) return [];
$app_type = $site_info[ 'app_type' ];
@ -149,14 +149,14 @@ class CoreSiteService extends BaseCoreService
if ($app_type == AppTypeDict::SITE) {
$group_id = $site_info[ 'group_id' ] ?? 0;
if ($group_id > 0) {
$group = (new SiteGroup())->field('app,addon')->findOrEmpty($group_id);
$group = ( new SiteGroup() )->field('app,addon')->findOrEmpty($group_id);
if (!$group->isEmpty()) {
$group_addon_keys = array_merge($group['app'], $group['addon']);
$group_addon_keys = array_merge($group[ 'app' ], $group[ 'addon' ]);
}
}
}
//在查询站点所拥有的应用插件,两者结合
$site_addon_keys = is_array($site_info['addons']) ? $site_info['addons'] : [];
$site_addon_keys = is_array($site_info[ 'addons' ]) ? $site_info[ 'addons' ] : [];
return array_merge($group_addon_keys ?? [], $site_addon_keys);
},
self::$cache_tag_name . $site_id

View File

@ -74,7 +74,7 @@ class CoreSysConfigService extends BaseCoreService
*/
public function getWapIndexList($data = [])
{
$result = array_filter(event("WapIndex"));
$result = array_filter(event("WapIndex", [ 'site_id' => $data[ 'site_id' ] ?? 0 ]));
if (empty($result)) return [];
$index_list = [];

View File

@ -75,8 +75,10 @@ class CoreWeappAuthService extends BaseCoreService
public function getUserPhoneNumber(int $site_id, string $code)
{
$api = CoreWeappService::appApiClient($site_id);
CoreWeappService::refreshToken($site_id); // 为防止多次拒绝手机号的情况需要刷新token
return $api->postJson('wxa/business/getuserphonenumber', [
'code' => (string) $code
]);
}
}

View File

@ -171,12 +171,13 @@ class CoreWeappDeliveryService extends BaseCoreService
* 2、平台会在路径后面增加支付单的 transaction_id、merchant_id、merchant_trade_no 作为query参数如果存在二级商户号则还会再增加 sub_merchant_id 参数,开发者可以在小程序中通过onLaunch等方式获取。
* 3、如你需要在path中携带自定义的query参数请注意与上面的参数进行区分
* @param int $site_id
* @param string $type
* @return mixed
* @throws InvalidArgumentException
*/
public function setMsgJumpPath(int $site_id)
public function setMsgJumpPath(int $site_id, $type)
{
$config_data = $this->getConfig($site_id);
$config_data = $this->getConfig($site_id, $type);
if (true || empty($config_data) || ( !empty($config_data[ 'value' ]) && empty($config_data[ 'value' ][ 'path' ]) )) {
try {
$path = 'app/pages/weapp/order_shipping';
@ -186,7 +187,7 @@ class CoreWeappDeliveryService extends BaseCoreService
$data = [
'path' => $path
];
$this->setConfig($site_id, $data);
$this->setConfig($site_id, $type, $data);
}
return $result;
@ -248,25 +249,27 @@ class CoreWeappDeliveryService extends BaseCoreService
/**
* 获取配置信息
* @param int $site_id
* @param string $type
* @return array
*/
public function getConfig(int $site_id)
public function getConfig(int $site_id, $type)
{
$config_service = new CoreConfigService();
$res = $config_service->getConfig($site_id, 'WEAPP_ORDER_SHIPPING_CONFIG');
$res = $config_service->getConfig($site_id, 'WEAPP_ORDER_SHIPPING_CONFIG_' . $type);
return $res;
}
/**
* 设置配置
* @param int $site_id
* @param string $type
* @param array $value
* @return SysConfig|bool|Model
*/
public function setConfig(int $site_id, array $value)
public function setConfig(int $site_id, $type, array $value)
{
$config_service = new CoreConfigService();
$res = $config_service->setConfig($site_id, 'WEAPP_ORDER_SHIPPING_CONFIG', $value);
$res = $config_service->setConfig($site_id, 'WEAPP_ORDER_SHIPPING_CONFIG_' . $type, $value);
return $res;
}

View File

@ -37,19 +37,19 @@ class CoreWeappService extends BaseCoreService
$core_weapp_service = new CoreWeappConfigService();
$weapp_config = $core_weapp_service->getWeappConfig($site_id);
if ($weapp_config['is_authorization']) {
$authorization_info = $core_weapp_service->getWeappAuthorizationInfo($site_id)['authorization_info'];
return CoreOplatformService::app()->getMiniAppWithRefreshToken($weapp_config['app_id'], $authorization_info['authorizer_refresh_token']);
if ($weapp_config[ 'is_authorization' ]) {
$authorization_info = $core_weapp_service->getWeappAuthorizationInfo($site_id)[ 'authorization_info' ];
return CoreOplatformService::app()->getMiniAppWithRefreshToken($weapp_config[ 'app_id' ], $authorization_info[ 'authorizer_refresh_token' ]);
} else {
if(empty($weapp_config['app_id']) || empty($weapp_config['app_secret'])) throw new WechatException('WEAPP_NOT_EXIST');//公众号未配置
if (empty($weapp_config[ 'app_id' ]) || empty($weapp_config[ 'app_secret' ])) throw new WechatException('WEAPP_NOT_EXIST');//公众号未配置
$config = array(
'app_id' => $weapp_config['app_id'],
'secret' => $weapp_config['app_secret'],
'token' => $weapp_config['token'],
'aes_key' => $weapp_config['encryption_type'] == 'not_encrypt' ? '' :$weapp_config['encoding_aes_key'],// 明文模式请勿填写 EncodingAESKey
'app_id' => $weapp_config[ 'app_id' ],
'secret' => $weapp_config[ 'app_secret' ],
'token' => $weapp_config[ 'token' ],
'aes_key' => $weapp_config[ 'encryption_type' ] == 'not_encrypt' ? '' : $weapp_config[ 'encoding_aes_key' ],// 明文模式请勿填写 EncodingAESKey
'http' => [
'throw' => true, // 状态码非 200、300 时是否抛出异常,默认为开启
'throw' => true, // 状态码非 200、300 时是否抛出异常,默认为开启
'timeout' => 5.0,
'retry' => true, // 使用默认重试配置
],
@ -70,6 +70,17 @@ class CoreWeappService extends BaseCoreService
return self::app($site_id)->getClient();
}
/**
* 刷新token
* @param int $site_id
* @return \EasyWeChat\Kernel\HttpClient\AccessTokenAwareClient
* @throws InvalidArgumentException
*/
public static function refreshToken(int $site_id)
{
self::app($site_id)->getAccessToken()->refresh();
}
/**
* 生成小程序码
* @param int $site_id
@ -80,10 +91,11 @@ class CoreWeappService extends BaseCoreService
* @return mixed
* @throws InvalidArgumentException
*/
public function qrcode(int $site_id, $page, $data, $filepath, $width = 430){
public function qrcode(int $site_id, $page, $data, $filepath, $width = 430)
{
$scene = [];
foreach($data as $v){
$scene[] = $v['key'].'-'.$v['value'];
foreach ($data as $v) {
$scene[] = $v[ 'key' ] . '-' . $v[ 'value' ];
}
$response = self::appApiClient($site_id)->postJson('/wxa/getwxacodeunlimit', [
'scene' => implode('&', $scene),
@ -105,7 +117,8 @@ class CoreWeappService extends BaseCoreService
* @param $site_id
* @return void
*/
public function getWeappPreviewImage($site_id) {
public function getWeappPreviewImage($site_id)
{
$app = self::appApiClient($site_id);
$response = $app->get('/wxa/get_qrcode');
if ($response->isFailed()) {
@ -114,7 +127,7 @@ class CoreWeappService extends BaseCoreService
}
$dir = public_path() . "qrcode/{$site_id}/";
mkdirs_or_notexist($dir);
$filepath = $dir . time().'.png';
$filepath = $dir . time() . '.png';
file_put_contents($filepath, $response->getContent());
return $filepath;
}

View File

@ -1,6 +1,6 @@
<?php
return [
'version' => '0.5.0',
'code' => '202407250001'
'version' => '0.5.1',
'code' => '202408160001'
];

View File

@ -15,7 +15,6 @@ use app\service\core\weapp\CoreWeappService;
use EasyWeChat\Kernel\Exceptions\InvalidArgumentException;
use EasyWeChat\Kernel\Exceptions\InvalidConfigException;
use EasyWeChat\Kernel\Support\Collection;
use EasyWeChat\MiniProgram\SubscribeMessage\Client;
use GuzzleHttp\Exception\GuzzleException;
use Psr\Http\Message\ResponseInterface;

View File

@ -15,7 +15,6 @@ use app\service\core\wechat\CoreWechatService;
use EasyWeChat\Kernel\Exceptions\InvalidArgumentException;
use EasyWeChat\Kernel\Exceptions\InvalidConfigException;
use EasyWeChat\Kernel\Support\Collection;
use EasyWeChat\OfficialAccount\TemplateMessage\Client;
use GuzzleHttp\Exception\GuzzleException;
use Psr\Http\Message\ResponseInterface;

View File

@ -62,7 +62,7 @@ class Aliyun extends BaseUpload
$bucket = $this->config['bucket'];
try {
$base64_file = base64_decode($base64_data);
if (!$base64_file) throw new UploadFileException('FILE_ERROE');
if (!$base64_file) throw new UploadFileException('FILE_ERROR');
$this->client()->putObject(
$bucket,
$key,

View File

@ -101,7 +101,7 @@ class Qiniu extends BaseUpload
$upload_mgr = new UploadManager();
//将 base64 编码的图片数据解码
$base64_file = base64_decode($base64_data);
if (!$base64_file) throw new UploadFileException('FILE_ERROE');
if (!$base64_file) throw new UploadFileException('FILE_ERROR');
// 初始化 UpLoadManager 对象并进行文件的上传
list($ret, $err) = $upload_mgr->put($up_token, $key, $base64_file);
if ($err !== null) throw new UploadFileException($err->message);

View File

@ -84,7 +84,7 @@ class Tencent extends BaseUpload
$bucket = $this->config['bucket'];
try {
$base64_file = base64_decode($base64_data);
if (!$base64_file) throw new UploadFileException('FILE_ERROE');
if (!$base64_file) throw new UploadFileException('FILE_ERROR');
$result = $this->client()->putObject(array(
'Bucket' => $bucket, //存储桶名称由BucketName-Appid 组成可以在COS控制台查看 https://console.tencentcloud.com/cos5/bucket
'Key' => $key,

View File

@ -12,10 +12,7 @@
namespace core\util;
use Exception;
use think\cache\driver\Redis;
use think\facade\Cache;
use think\facade\Log;
use think\facade\Queue as ThinkQueue;
/**
* Class Queue