First commit
This commit is contained in:
620
app/agent/common.php
Executable file
620
app/agent/common.php
Executable file
@@ -0,0 +1,620 @@
|
||||
<?php
|
||||
// 这是系统自动生成的admin应用公共文件
|
||||
use app\admin\model\Admin as AdminModel;
|
||||
use app\admin\model\Role as RoleModel;
|
||||
use app\agent\model\LongbingPlugeKey;
|
||||
use think\facade\Config;
|
||||
|
||||
|
||||
//删除用户登录信息
|
||||
function delUserForToken($token) {
|
||||
return delCache("Token_".$token);
|
||||
}
|
||||
|
||||
//生成token
|
||||
function createToken() {
|
||||
return uuid();
|
||||
}
|
||||
|
||||
//检查密码是否正确
|
||||
function checkPasswd(string $passwd ,string $offset ,string $hash) {
|
||||
//检查秘钥是否正确
|
||||
return password_verify($offset . $passwd . $offset ,$hash);
|
||||
}
|
||||
|
||||
//获取缓存数据中的 accounts 列表
|
||||
function getAccountList($uniacid = 7777){
|
||||
//获取缓存数据
|
||||
$result = getCache('accounts_' . $uniacid);
|
||||
// var_dump(getCache('accounts_7777'));die;
|
||||
//数据存在返回数据
|
||||
if(!empty($result)) return $result;
|
||||
//缓存数据不存在时,从数据库获取数据,同时写入缓存
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
//设置账号缓存
|
||||
function setAccountToCache($account ,$uniacid = 7777){
|
||||
if(empty(getAccountList($uniacid))) return setCache('accounts_'.$uniacid ,[$account]);
|
||||
return pushCache('accounts_'.$uniacid ,$account);
|
||||
}
|
||||
//移除账号缓存
|
||||
function delAccountToCache($account ,$uniacid = 7777){
|
||||
|
||||
}
|
||||
|
||||
//检查检查用户账号是否存在
|
||||
function checkAccountIsExist($account ,$uniacid = 7777){
|
||||
// //获取账号列表
|
||||
// $account_list = getAccountList($uniacid);
|
||||
// if(empty($account_list)) $account_list = [];
|
||||
// //判断账号是否存在
|
||||
// return in_array($account ,$account_list);
|
||||
$result = false;
|
||||
$count = AdminModel::where(['account' => $account ,'uniacid' => $uniacid ,'deleted' => 0])->count();
|
||||
if(!empty($count)) $result = true;
|
||||
return $result;
|
||||
}
|
||||
//获取角色信息
|
||||
function getRole($role_name = 'user',$uniacid = 7777) {
|
||||
$list_role = listRole($uniacid);
|
||||
foreach($list_role as $role) {
|
||||
if(in_array($role_name, [$role['role_name']])) unset($role_name) ;return $role;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//获取角色模型
|
||||
function getRoleModel() {
|
||||
return new RoleModel();
|
||||
}
|
||||
|
||||
//获取角色列表
|
||||
function listRole($uniacid = 7777){
|
||||
//从缓存中回去数据
|
||||
$result = getCache('ListRole' . $uniacid);
|
||||
if(!empty($result)) return $result;
|
||||
$role_modle = getRoleModel();
|
||||
$list_role = $role_modle->listRoleAll(['uniacid' => $uniacid]);
|
||||
if(!empty($list_role)) {
|
||||
setCache('ListRole' . $uniacid ,$list_role ,3600);
|
||||
foreach($list_role as $role) {
|
||||
setCache('role_' . $uniacid . '_' . $role['role_id'] ,$role ,3600);
|
||||
}
|
||||
}
|
||||
return $list_role;
|
||||
}
|
||||
|
||||
function ckeckRole($role_id ,$uniacid = 7777) {
|
||||
$list_role = listRole($uniacid);
|
||||
unset($list_role);
|
||||
return getCache('role_' . $uniacid . '_' . $role['role_id']);
|
||||
}
|
||||
|
||||
function listUserFilter($filter) {
|
||||
$data = ['user.deleted' => 0 ,'role.deleted' => 0];
|
||||
if(isset($filter['user_id'])) $data['user.user_id'] = $filter['user_id'];
|
||||
if(isset($filter['account'])) $data['user.account'] = ['like' ,'%' . $filter['account'] . '%'];
|
||||
if(isset($filter['name'])) $data['user.name'] = ['like' ,'%' . $filter['name'] . '%'];
|
||||
if(isset($filter['creator_id'])) $data['user.creator_id'] = $filter['creator_id'];
|
||||
if(isset($filter['status'])) $data['status'] = $filter['status'];
|
||||
if(isset($filter['nickname'])) $data['user.nickname'] = ['like' ,'%' . $filter['nickname'] . '%'];
|
||||
if(isset($filter['certificate_num'])) $data['user.certificate_num'] = $filter['certificate_num'];
|
||||
if(isset($filter['email'])) $data['user.email'] = ['like' , '%' . $filter['email'] . '%'];
|
||||
if(isset($filter['wechat'])) $data['user.wechat'] = ['like' , '%' . $filter['wechat'] . '%'];
|
||||
if(isset($filter['qq'])) $data['user.qq'] = ['like' , '%' . $filter['qq'] . '%'];
|
||||
if(isset($filter['mobile'])) $data['user.mobile'] = ['like' , '%' . $filter['mobile'] . '%'];
|
||||
if(isset($filter['role_id'])) $data['user.role_id'] = $filter['role_id'];
|
||||
if(isset($filter['uniacid'])) $data['user.uniacid'] = $filter['uniacid'];
|
||||
if(isset($filter['department_id'])) $data['user.department_id'] = $filter['department_id'];
|
||||
return $data;
|
||||
}
|
||||
|
||||
function getUpdateUserFilter($data) {
|
||||
if(isset($data['user_id'])) unset($data['user_id']);
|
||||
if(isset($data['offset'])) unset($data['offset']);
|
||||
if(isset($data['create_time'])) unset($data['create_time']);
|
||||
if(isset($data['update_time'])) unset($data['update_time']);
|
||||
if(isset($data['delete_time'])) unset($data['delete_time']);
|
||||
return $data;
|
||||
}
|
||||
|
||||
function getOssConfigData($data)
|
||||
{
|
||||
$result['open_oss'] = 0;
|
||||
if(isset($data['miniapp_name'])) $result['miniapp_name'] = $data['miniapp_name'];
|
||||
if(isset($data['open_oss']) && in_array($data['open_oss'], [0,1,2,3,'0','1','2','3'])) $result['open_oss'] = $data['open_oss'];
|
||||
if(isset($data['aliyun_bucket'])) $result['aliyun_bucket'] = $data['aliyun_bucket'];
|
||||
if(isset($data['aliyun_access_key_id'])) $result['aliyun_access_key_id'] = $data['aliyun_access_key_id'];
|
||||
if(isset($data['aliyun_access_key_secret'])) $result['aliyun_access_key_secret'] = $data['aliyun_access_key_secret'];
|
||||
if(isset($data['aliyun_base_dir'])) $result['aliyun_base_dir'] = $data['aliyun_base_dir'];
|
||||
if(isset($data['aliyun_zidinyi_yuming'])) $result['aliyun_zidinyi_yuming'] = $data['aliyun_zidinyi_yuming'];
|
||||
if(isset($data['aliyun_endpoint'])) $result['aliyun_endpoint'] = $data['aliyun_endpoint'];
|
||||
if(isset($data['aliyun_rules'])) $result['aliyun_rules'] = $data['aliyun_rules'];
|
||||
if(isset($data['qiniu_accesskey'])) $result['qiniu_accesskey'] = $data['qiniu_accesskey'];
|
||||
if(isset($data['qiniu_secretkey'])) $result['qiniu_secretkey'] = $data['qiniu_secretkey'];
|
||||
if(isset($data['qiniu_bucket'])) $result['qiniu_bucket'] = $data['qiniu_bucket'];
|
||||
if(isset($data['qiniu_yuming'])) $result['qiniu_yuming'] = $data['qiniu_yuming'];
|
||||
if(isset($data['qiniu_rules'])) $result['qiniu_rules'] = $data['qiniu_rules'];
|
||||
if(isset($data['tenxunyun_appid'])) $result['tenxunyun_appid'] = $data['tenxunyun_appid'];
|
||||
if(isset($data['tenxunyun_secretid'])) $result['tenxunyun_secretid'] = $data['tenxunyun_secretid'];
|
||||
if(isset($data['tenxunyun_secretkey'])) $result['tenxunyun_secretkey'] = $data['tenxunyun_secretkey'];
|
||||
if(isset($data['tenxunyun_bucket'])) $result['tenxunyun_bucket'] = $data['tenxunyun_bucket'];
|
||||
if(isset($data['tenxunyun_region'])) $result['tenxunyun_region'] = $data['tenxunyun_region'];
|
||||
if(isset($data['tenxunyun_yuming'])) $result['tenxunyun_yuming'] = $data['tenxunyun_yuming'];
|
||||
if(isset($data['apiclient_cert'])) $result['apiclient_cert'] = $data['apiclient_cert'];
|
||||
if(isset($data['apiclient_key'])) $result['apiclient_key'] = $data['apiclient_key'];
|
||||
return $result;
|
||||
}
|
||||
//底部菜单数据封装
|
||||
function longbingGetAppTabbarResponse($data)
|
||||
{
|
||||
if(empty($data)) return [];
|
||||
//数据处理
|
||||
$data['data'] = [];
|
||||
//处理过的参数
|
||||
$menus = [];
|
||||
//名片
|
||||
if(isset($data['menu1_is_hide']))
|
||||
{
|
||||
$val = ['menu_name' => 'card'];
|
||||
$val['is_show'] = $data['menu1_is_hide'];
|
||||
if(isset($data['menu1_name'])) $val['name'] = $data['menu1_name'];
|
||||
if(isset($data['menu1_url'])) $val['url'] = $data['menu1_url'];
|
||||
if(isset($data['menu1_url_out'])) $val['url_out'] = $data['menu1_url_out'];
|
||||
if(isset($data['menu1_url_jump_way'])) $val['url_jump_way'] = $data['menu1_url_jump_way'];
|
||||
$data['data']['card'] = $val;
|
||||
}
|
||||
//商城
|
||||
if(isset($data['menu2_is_hide']))
|
||||
{
|
||||
$val = ['menu_name' => 'shop'];
|
||||
$val['is_show'] = $data['menu2_is_hide'];
|
||||
if(isset($data['menu2_name'])) $val['name'] = $data['menu2_name'];
|
||||
if(isset($data['menu2_url'])) $val['url'] = $data['menu2_url'];
|
||||
if(isset($data['menu2_url_out'])) $val['url_out'] = $data['menu2_url_out'];
|
||||
if(isset($data['menu2_url_jump_way'])) $val['url_jump_way'] = $data['menu2_url_jump_way'];
|
||||
$data['data']['shop'] = $val;
|
||||
}
|
||||
//动态
|
||||
if(isset($data['menu3_is_hide']))
|
||||
{
|
||||
$val = ['menu_name' => 'dynamic'];
|
||||
$val['is_show'] = $data['menu3_is_hide'];
|
||||
if(isset($data['menu3_name'])) $val['name'] = $data['menu3_name'];
|
||||
if(isset($data['menu3_url'])) $val['url'] = $data['menu3_url'];
|
||||
if(isset($data['menu3_url_out'])) $val['url_out'] = $data['menu3_url_out'];
|
||||
if(isset($data['menu3_url_jump_way'])) $val['url_jump_way'] = $data['menu3_url_jump_way'];
|
||||
$data['data']['dynamic'] = $val;
|
||||
}
|
||||
//官网
|
||||
if(isset($data['menu4_is_hide']))
|
||||
{
|
||||
$val = ['menu_name' => 'website'];
|
||||
$val['is_show'] = $data['menu4_is_hide'];
|
||||
$menus[] = 'menu4_name';
|
||||
if(isset($data['menu4_name'])) $val['name'] = $data['menu4_name'];
|
||||
if(isset($data['menu4_url'])) $val['url'] = $data['menu4_url'];
|
||||
if(isset($data['menu4_url_out'])) $val['url_out'] = $data['menu4_url_out'];
|
||||
if(isset($data['menu4_url_jump_way'])) $val['url_jump_way'] = $data['menu4_url_jump_way'];
|
||||
$data['data']['website'] = $val;
|
||||
}
|
||||
//预约
|
||||
if(isset($data['menu_appoint_is_hide']))
|
||||
{
|
||||
$val = ['menu_name' => 'appointment'];
|
||||
$val['is_show'] = $data['menu_appoint_is_hide'];
|
||||
if(isset($data['menu_appoint_name'])) $val['name'] = $data['menu_appoint_name'];
|
||||
if(isset($data['menu_appoint_url'])) $val['url'] = $data['menu_appoint_url'];
|
||||
if(isset($data['menu_appoint_url_out'])) $val['url_out'] = $data['menu_appoint_url_out'];
|
||||
if(isset($data['menu_appoint_url_jump_way'])) $val['url_jump_way'] = $data['menu_appoint_url_jump_way'];
|
||||
$data['data']['appointment'] = $val;
|
||||
}
|
||||
//活动报名
|
||||
if(isset($data['menu_activity_is_show']))
|
||||
{
|
||||
$val = ['menu_name' => 'activity'];
|
||||
$val['is_show'] = $data['menu_activity_is_show'];
|
||||
if(isset($data['menu_activity_name'])) $val['name'] = $data['menu_activity_name'];
|
||||
if(isset($data['menu_activity_url'])) $val['url'] = $data['menu_activity_url'];
|
||||
if(isset($data['menu_activity_url_out'])) $val['url_out'] = $data['menu_activity_url_out'];
|
||||
if(isset($data['menu_activity_url_jump_way'])) $val['url_jump_way'] = $data['menu_activity_url_jump_way'];
|
||||
$data['data']['activity'] = $val;
|
||||
}
|
||||
//房产
|
||||
if(isset($data['menu_house_is_show']))
|
||||
{
|
||||
$val = ['menu_name' => 'house'];
|
||||
$val['is_show'] = $data['menu_house_is_show'];
|
||||
if(isset($data['menu_house_name']))$val['name'] = $data['menu_house_name'];
|
||||
if(isset($data['menu_house_url']))$val['url'] = $data['menu_house_url'];
|
||||
if(isset($data['menu_house_url_out']))$val['url_out'] = $data['menu_house_url_out'];
|
||||
if(isset($data['menu_house_url_jump_way']))$val['url_jump_way'] = $data['menu_house_url_jump_way'];
|
||||
$data['data']['house'] = $val;
|
||||
}
|
||||
$menus = ["menu1_name","menu1_is_hide","menu1_url","menu1_url_out","menu1_url_jump_way","menu2_name","menu2_is_hide","menu2_url","menu2_url_out","menu2_url_jump_way","menu3_name","menu3_is_hide","menu3_url","menu3_url_out","menu3_url_jump_way","menu4_name","menu4_is_hide","menu4_url","menu4_url_out","menu4_url_jump_way","menu_appoint_name","menu_appoint_is_hide","menu_appoint_url","menu_appoint_url_out","menu_appoint_url_jump_way","menu_activity_is_show","menu_activity_name","menu_activity_is_hide","menu_activity_url","menu_activity_url_out","menu_activity_url_jump_way","menu_house_is_show","menu_house_name","menu_house_is_hide","menu_house_url","menu_house_url_out","menu_house_url_jump_way"];
|
||||
foreach($menus as $menu)
|
||||
{
|
||||
unset($data[$menu]);
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
function longbingGetWxAppTabbarResponse($data)
|
||||
{
|
||||
if(empty($data)) return [];
|
||||
//数据处理
|
||||
$data['data'] = [];
|
||||
//处理过的参数
|
||||
$menus = [];
|
||||
//名片
|
||||
if(isset($data['menu1_is_hide']) && !empty($data['menu1_is_hide']))
|
||||
{
|
||||
$val = [];
|
||||
$val['is_show'] = $data['menu1_is_hide'];
|
||||
$val['key'] = 1;
|
||||
$val['iconPath'] = 'icon-mingpian';
|
||||
$val['selectedIconPath'] = 'icon-mingpian1';
|
||||
$val['pageComponents'] = 'cardHome';
|
||||
if(isset($data['menu1_name'])) $val['name'] = $data['menu1_name'];
|
||||
if(isset($data['menu1_url'])) $val['url'] = $data['menu1_url'];
|
||||
if(isset($data['menu1_url_out'])) $val['url_out'] = $data['menu1_url_out'];
|
||||
if(isset($data['menu1_url_jump_way'])) $val['jump_way'] = $data['menu1_url_jump_way'];
|
||||
$data['data'][] = $val;
|
||||
}
|
||||
//商城
|
||||
if(isset($data['menu2_is_hide']) && !empty($data['menu2_is_hide']))
|
||||
{
|
||||
$val = [];
|
||||
$val['key'] = 2;
|
||||
$val['is_show'] = $data['menu2_is_hide'];
|
||||
$val['iconPath'] = 'icon-shangcheng1';
|
||||
$val['selectedIconPath'] = 'icon-shangcheng';
|
||||
$val['pageComponents'] = 'shopHome';
|
||||
if(isset($data['menu2_name'])) $val['name'] = $data['menu2_name'];
|
||||
if(isset($data['menu2_url'])) $val['url'] = $data['menu2_url'];
|
||||
if(isset($data['menu2_url_out'])) $val['url_out'] = $data['menu2_url_out'];
|
||||
if(isset($data['menu2_url_jump_way'])) $val['url_jump_way'] = $data['menu2_url_jump_way'];
|
||||
$data['data'][] = $val;
|
||||
}
|
||||
//动态
|
||||
if(isset($data['menu3_is_hide']) && !empty($data['menu3_is_hide']))
|
||||
{
|
||||
$val = [];
|
||||
$val['key'] = 3;
|
||||
$val['is_show'] = $data['menu3_is_hide'];
|
||||
$val['iconPath'] = 'icon-dongtai1';
|
||||
$val['selectedIconPath'] = 'icon-dongtai';
|
||||
$val['pageComponents'] = 'infoHome';
|
||||
if(isset($data['menu3_name'])) $val['name'] = $data['menu3_name'];
|
||||
if(isset($data['menu3_url'])) $val['url'] = $data['menu3_url'];
|
||||
if(isset($data['menu3_url_out'])) $val['url_out'] = $data['menu3_url_out'];
|
||||
if(isset($data['menu3_url_jump_way'])) $val['url_jump_way'] = $data['menu3_url_jump_way'];
|
||||
$data['data'][] = $val;
|
||||
}
|
||||
//官网
|
||||
if(isset($data['menu4_is_hide']) && !empty($data['menu4_is_hide']))
|
||||
{
|
||||
$val = [];
|
||||
$val['key'] = 4;
|
||||
$val['is_show'] = $data['menu4_is_hide'];
|
||||
$val['iconPath'] = 'icon-guanwang';
|
||||
$val['selectedIconPath'] = 'icon-guanwang1';
|
||||
$val['pageComponents'] = 'websiteHome';
|
||||
if(isset($data['menu4_name'])) $val['name'] = $data['menu4_name'];
|
||||
if(isset($data['menu4_url'])) $val['url'] = $data['menu4_url'];
|
||||
if(isset($data['menu4_url_out'])) $val['url_out'] = $data['menu4_url_out'];
|
||||
if(isset($data['menu4_url_jump_way'])) $val['url_jump_way'] = $data['menu4_url_jump_way'];
|
||||
$data['data'][] = $val;
|
||||
}
|
||||
//预约
|
||||
if(isset($data['menu_appoint_is_hide']) && !empty($data['menu_appoint_is_hide']))
|
||||
{
|
||||
$val = [];
|
||||
$val['key'] = 7;
|
||||
$val['is_show'] = $data['menu_appoint_is_hide'];
|
||||
$val['iconPath'] = 'icon-yuyue';
|
||||
$val['selectedIconPath'] = 'icon-yuyue1';
|
||||
$val['pageComponents'] = 'reserveHome';
|
||||
if(isset($data['menu_appoint_name'])) $val['name'] = $data['menu_appoint_name'];
|
||||
if(isset($data['menu_appoint_url'])) $val['url'] = $data['menu_appoint_url'];
|
||||
if(isset($data['menu_appoint_url_out'])) $val['url_out'] = $data['menu_appoint_url_out'];
|
||||
if(isset($data['menu_appoint_url_jump_way'])) $val['url_jump_way'] = $data['menu_appoint_url_jump_way'];
|
||||
$data['data'][] = $val;
|
||||
}
|
||||
//活动报名
|
||||
if(isset($data['menu_activity_is_show']) && !empty($data['menu_activity_is_show']))
|
||||
{
|
||||
$val = [];
|
||||
$val['key'] = 6;
|
||||
$val['is_show'] = $data['menu_activity_is_show'];
|
||||
$val['iconPath'] = 'icon-huodong1';
|
||||
$val['selectedIconPath'] = 'icon-huodong';
|
||||
$val['pageComponents'] = 'avtivityHome';
|
||||
if(isset($data['menu_activity_name'])) $val['name'] = $data['menu_activity_name'];
|
||||
if(isset($data['menu_activity_url'])) $val['url'] = $data['menu_activity_url'];
|
||||
if(isset($data['menu_activity_url_out'])) $val['url_out'] = $data['menu_activity_url_out'];
|
||||
if(isset($data['menu_activity_url_jump_way'])) $val['url_jump_way'] = $data['menu_activity_url_jump_way'];
|
||||
$data['data'][] = $val;
|
||||
}
|
||||
//房产
|
||||
if(isset($data['menu_house_is_show']) && !empty($data['menu_house_is_show']))
|
||||
{
|
||||
$val = [];
|
||||
$val['key'] = 5;
|
||||
$val['is_show'] = $data['menu_house_is_show'];
|
||||
$val['iconPath'] = 'icon-fangchan1';
|
||||
$val['selectedIconPath'] = 'icon-fangchan';
|
||||
$val['pageComponents'] = 'houseHome';
|
||||
if(isset($data['menu_house_name']))$val['name'] = $data['menu_house_name'];
|
||||
if(isset($data['menu_house_url']))$val['url'] = $data['menu_house_url'];
|
||||
if(isset($data['menu_house_url_out']))$val['url_out'] = $data['menu_house_url_out'];
|
||||
if(isset($data['menu_house_url_jump_way']))$val['url_jump_way'] = $data['menu_house_url_jump_way'];
|
||||
$data['data'][] = $val;
|
||||
}
|
||||
$menus = ["menu1_name","menu1_is_hide","menu1_url","menu1_url_out","menu1_url_jump_way","menu2_name","menu2_is_hide","menu2_url","menu2_url_out","menu2_url_jump_way","menu3_name","menu3_is_hide","menu3_url","menu3_url_out","menu3_url_jump_way","menu4_name","menu4_is_hide","menu4_url","menu4_url_out","menu4_url_jump_way","menu_appoint_name","menu_appoint_is_hide","menu_appoint_url","menu_appoint_url_out","menu_appoint_url_jump_way","menu_activity_is_show","menu_activity_name","menu_activity_is_hide","menu_activity_url","menu_activity_url_out","menu_activity_url_jump_way","menu_house_is_show","menu_house_name","menu_house_is_hide","menu_house_url","menu_house_url_out","menu_house_url_jump_way"];
|
||||
foreach($menus as $menu)
|
||||
{
|
||||
unset($data[$menu]);
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
function longbingGetAppTabbarRequest($data)
|
||||
{
|
||||
$result = [];
|
||||
foreach($data as $key => $val)
|
||||
{
|
||||
switch($val['menu_name'])
|
||||
{
|
||||
case 'card':
|
||||
if(isset($val['is_show'])) $result['menu1_is_hide'] = $val['is_show'];
|
||||
if(isset($val['name'])) $result['menu1_name'] = $val['name'];
|
||||
// if(isset($val['url'])) $result['menu1_url'] = $val['url'];
|
||||
if(isset($val['url_out'])) $result['menu1_url_out'] = $val['url_out'];
|
||||
if(isset($val['url_jump_way'])) $result['menu1_url_jump_way'] = $val['url_jump_way'];
|
||||
break;
|
||||
case 'shop':
|
||||
if(isset($val['is_show'])) $result['menu2_is_hide'] = $val['is_show'];
|
||||
if(isset($val['name'])) $result['menu2_name'] = $val['name'];
|
||||
// if(isset($val['url'])) $result['menu2_url'] = $val['url'];
|
||||
if(isset($val['url_out'])) $result['menu2_url_out'] = $val['url_out'];
|
||||
if(isset($val['url_jump_way'])) $result['menu2_url_jump_way'] = $val['url_jump_way'];
|
||||
break;
|
||||
case 'dynamic':
|
||||
if(isset($val['is_show'])) $result['menu3_is_hide'] = $val['is_show'];
|
||||
if(isset($val['name'])) $result['menu3_name'] = $val['name'];
|
||||
// if(isset($val['url'])) $result['menu3_url'] = $val['url'];
|
||||
if(isset($val['url_out'])) $result['menu3_url_out'] = $val['url_out'];
|
||||
if(isset($val['url_jump_way'])) $result['menu3_url_jump_way'] = $val['url_jump_way'];
|
||||
break;
|
||||
case 'website':
|
||||
if(isset($val['is_show'])) $result['menu4_is_hide'] = $val['is_show'];
|
||||
if(isset($val['name'])) $result['menu4_name'] = $val['name'];
|
||||
// if(isset($val['url'])) $result['menu4_url'] = $val['url'];
|
||||
if(isset($val['url_out'])) $result['menu4_url_out'] = $val['url_out'];
|
||||
if(isset($val['url_jump_way'])) $result['menu4_url_jump_way'] = $val['url_jump_way'];
|
||||
break;
|
||||
case 'appointment':
|
||||
if(isset($val['is_show'])) $result['menu_appoint_is_hide'] = $val['is_show'];
|
||||
if(isset($val['name'])) $result['menu_appoint_name'] = $val['name'];
|
||||
// if(isset($val['url'])) $result['menu_appoint_url'] = $val['url'];
|
||||
if(isset($val['url_out'])) $result['menu_appoint_url_out'] = $val['url_out'];
|
||||
if(isset($val['url_jump_way'])) $result['menu_appoint_url_jump_way'] = $val['url_jump_way'];
|
||||
break;
|
||||
case 'activity':
|
||||
if(isset($val['is_show'])) $result['menu_activity_is_show'] = $val['is_show'];
|
||||
if(isset($val['name'])) $result['menu_activity_name'] = $val['name'];
|
||||
// if(isset($val['url'])) $result['menu_activity_url'] = $val['url'];
|
||||
if(isset($val['url_out'])) $result['menu_activity_url_out'] = $val['url_out'];
|
||||
if(isset($val['url_jump_way'])) $result['menu_activity_url_jump_way'] = $val['url_jump_way'];
|
||||
break;
|
||||
case 'house':
|
||||
if(isset($val['is_show'])) $result['menu_house_is_show'] = $val['is_show'];
|
||||
if(isset($val['name'])) $result['menu_house_name'] = $val['name'];
|
||||
// if(isset($val['url'])) $result['menu_house_url'] = $val['url'];
|
||||
if(isset($val['url_out'])) $result['menu_house_url_out'] = $val['url_out'];
|
||||
if(isset($val['url_jump_way'])) $result['menu_house_url_jump_way'] = $val['url_jump_way'];
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/*
|
||||
* 获取branch id 程序唯一识别号
|
||||
* @author yangqi
|
||||
*/
|
||||
function longbingGetBranchId()
|
||||
{
|
||||
$app_config = Config::get( 'app' );
|
||||
$key = 'branch_id';
|
||||
$result = false;
|
||||
if ( isset( $app_config[ $key ] ) ) $result = $app_config[ $key ];
|
||||
return $result;
|
||||
}
|
||||
|
||||
/*
|
||||
* 获取branch id 程序版本号
|
||||
* @author yangqi
|
||||
*/
|
||||
function longbingGetBranchVersionId()
|
||||
{
|
||||
$app_config = Config::get( 'app' );
|
||||
$key = 'version_id';
|
||||
$result = false;
|
||||
if ( isset( $app_config[ $key ] ) ) $result = $app_config[ $key ];
|
||||
return $result;
|
||||
}
|
||||
|
||||
/*
|
||||
* 获取branch version name
|
||||
* @author yangqi
|
||||
*/
|
||||
function longbingGetBranchVersionName()
|
||||
{
|
||||
$app_config = Config::get( 'app' );
|
||||
$key = 'version_name';
|
||||
$result = '2.0.1';
|
||||
if ( isset( $app_config[ $key ] ) ) $result = $app_config[ $key ];
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取站点绑定的数据
|
||||
* @yangqi
|
||||
*/
|
||||
function longbingGetWebSiteBingData()
|
||||
{
|
||||
//生成数据
|
||||
$pluge_key_model = new LongbingPlugeKey();
|
||||
$result = $pluge_key_model->getPlugeKey();
|
||||
return $result;
|
||||
}
|
||||
|
||||
//更新站点绑定数据
|
||||
function longbingUpdateWebSiteBingData($filter ,$data)
|
||||
{
|
||||
$pluge_key_model = new LongbingPlugeKey();
|
||||
$result = $pluge_key_model->updatePlugeKey($filter ,$data);
|
||||
return !empty($result);
|
||||
}
|
||||
|
||||
function longbingGetSaasUrl()
|
||||
{
|
||||
$app_config = Config::get( 'app' );
|
||||
$key = 'longbing_saas_url';
|
||||
$result = 'http://api.longbing.org';
|
||||
if ( isset( $app_config[ $key ] ) && !empty($app_config[ $key ])) $result = $app_config[ $key ];
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载文件
|
||||
*/
|
||||
function longbingGetFile($url, $save_dir = '', $filename = '', $type = 0) {
|
||||
if (trim($url) == '') {
|
||||
return false;
|
||||
}
|
||||
if (trim($save_dir) == '') {
|
||||
$save_dir = './';
|
||||
}
|
||||
if (0 !== strrpos($save_dir, '/')) {
|
||||
$save_dir.= '/';
|
||||
}
|
||||
//创建保存目录
|
||||
if (!file_exists($save_dir) && !mkdir($save_dir, 0777, true)) {
|
||||
return false;
|
||||
}
|
||||
//获取远程文件所采用的方法
|
||||
if ($type) {
|
||||
$ch = curl_init();
|
||||
$timeout = 5;
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
|
||||
$content = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
} else {
|
||||
ob_start();
|
||||
readfile($url);
|
||||
$content = ob_get_contents();
|
||||
ob_end_clean();
|
||||
}
|
||||
$size = strlen($content);
|
||||
//文件大小
|
||||
$fp2 = @fopen($save_dir . $filename, 'a');
|
||||
|
||||
fwrite($fp2, $content);
|
||||
fclose($fp2);
|
||||
// unset($content, $url);
|
||||
return array(
|
||||
'file_name' => $filename,
|
||||
'save_path' => $save_dir . $filename
|
||||
);
|
||||
}
|
||||
/*
|
||||
php 从zip压缩文件中提取文件
|
||||
*/
|
||||
function longbingUnZipFile($zip_file_url ,$path = './upload/') {
|
||||
$zip = new ZipArchive;
|
||||
if ($zip->open($zip_file_url) === TRUE) {//中文文件名要使用ANSI编码的文件格式
|
||||
$zip->extractTo($path);//提取全部文件
|
||||
$zip->close();
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
PHP文件目录copy
|
||||
@param string $dirsrc 原目录名称字符串
|
||||
@param string $dirto 目标目录名称字符串
|
||||
*/
|
||||
function longbingCopyDir($dirSrc,$dirTo)
|
||||
{
|
||||
//判断目标文件夹是否存在
|
||||
if(is_file($dirTo))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
//判断目的文件夹是否存在
|
||||
if(!file_exists($dirTo))
|
||||
{
|
||||
mkdir($dirTo);
|
||||
}
|
||||
//拷贝文件
|
||||
if($handle=opendir($dirSrc))
|
||||
{
|
||||
while($filename=readdir($handle))
|
||||
{
|
||||
if($filename!='.' && $filename!='..')
|
||||
{
|
||||
$subsrcfile=$dirSrc . '/' . $filename;
|
||||
$subtofile=$dirTo . '/' . $filename;
|
||||
if(is_dir($subsrcfile))
|
||||
{
|
||||
longbingCopyDir($subsrcfile,$subtofile);//再次递归调用copydir
|
||||
}
|
||||
if(is_file($subsrcfile))
|
||||
{
|
||||
copy($subsrcfile,$subtofile);
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir($handle);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function longbingGetBetween($input, $start, $end) {
|
||||
$str = substr($input, strlen($start)+strpos($input, $start),(strlen($input) - strpos($input, $end))*(-1));
|
||||
return $str;
|
||||
}
|
||||
|
||||
|
||||
function longbingGetZipName ($url) {
|
||||
return longbingGetBetween($url ,"/" ,".zip");
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新APP
|
||||
*/
|
||||
function longbingUpdateAppFile($down_url ,$save_dir, $file_name ,$cp_dir) {
|
||||
$file_name = longbingGetZipName('/' .$file_name);
|
||||
$download_file = longbingGetFile($down_url, $save_dir, $filename = $file_name.'.zip', $type = 1);
|
||||
|
||||
|
||||
if(empty($download_file)) return FALSE;
|
||||
$zip_url = $save_dir . "/" . $file_name.".zip";
|
||||
$get_app_file = longbingUnZipFile($zip_url ,$save_dir);
|
||||
|
||||
if(empty($get_app_file)) return FALSE;
|
||||
$update_file = longbingCopyDir($save_dir. "/" . $file_name , $cp_dir);
|
||||
return $update_file;
|
||||
}
|
||||
154
app/agent/controller/ActivityController.php
Executable file
154
app/agent/controller/ActivityController.php
Executable file
@@ -0,0 +1,154 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\agent\controller;
|
||||
|
||||
use app\agent\service\AdminUserService;
|
||||
use think\App;
|
||||
use app\agent\model\Cardauth2ActivityModel;
|
||||
use app\AgentRest;
|
||||
use think\facade\Db;
|
||||
|
||||
class ActivityController extends AgentRest
|
||||
{
|
||||
public function __construct ( App $app ){
|
||||
parent::__construct( $app );
|
||||
if ($this->_user['role_name'] != 'admin') {
|
||||
echo json_encode(['code' => 401, 'error' => lang('Permission denied')]);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function list()
|
||||
{
|
||||
$param = $this->_param;
|
||||
$m_activity_auth2 = new Cardauth2ActivityModel();
|
||||
|
||||
//By.jingshuixian 2020年4月21日15:13:50
|
||||
//区分行业版数据
|
||||
if($this->_is_weiqin){
|
||||
$app_model_name = APP_MODEL_NAME;
|
||||
$list = $m_activity_auth2->alias('a')
|
||||
->field(['a.id', 'a.modular_id', 'a. create_time', 'a.sign', 'c.mini_app_name'])
|
||||
->join('longbing_card_config c', 'a.modular_id = c.uniacid')
|
||||
->join('account' , 'a.modular_id = account.uniacid')
|
||||
->join('wxapp_versions v' , 'a.modular_id = v.uniacid')
|
||||
->where([['a.status', '=', 1] , ['account.type', '=', 4] ,['account.isdeleted', '=', 0] , ['v.modules', 'like', "%{$app_model_name}%"]])
|
||||
->group('a.modular_id')
|
||||
->paginate(['list_rows' => $param['page_count'] ? $param['page_count'] : 10, 'page' => $param['page'] ? $param['page'] : 1])->toArray();
|
||||
|
||||
|
||||
|
||||
}else{
|
||||
|
||||
|
||||
$list = $m_activity_auth2->alias('a')
|
||||
->field(['a.id', 'a.modular_id', 'a. create_time', 'a.sign', 'c.mini_app_name'])
|
||||
->join('longbing_card_config c', 'a.modular_id = c.uniacid')
|
||||
->where([['a.status', '=', 1]])
|
||||
->paginate(['list_rows' => $param['page_count'] ? $param['page_count'] : 10, 'page' => $param['page'] ? $param['page'] : 1])->toArray();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$wxapp_map = [];
|
||||
$wxapp = Db::name('account_wxapp')->field(['uniacid', 'name'])->select();
|
||||
foreach ($wxapp as $item) {
|
||||
$wxapp_map[$item['uniacid']] = $item['name'];
|
||||
}
|
||||
|
||||
foreach ($list['data'] as $k => $item) {
|
||||
$list['data'][$k]['name'] = $wxapp_map[$item['modular_id']] ?? $item['mini_app_name'];
|
||||
unset($list['data'][$k]['mini_app_name']);
|
||||
}
|
||||
|
||||
|
||||
$list['total_activity_number'] = AdminUserService::getSassNum('activity',$this->_uniacid);
|
||||
|
||||
$list['total_activity_used'] = (int)$m_activity_auth2->where([['uniacid','in',$this->_uniacid_arr]])->sum('count');
|
||||
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
|
||||
public function create()
|
||||
{
|
||||
$data = $this->_input;
|
||||
|
||||
if (!isset($data['modular_id'])) {
|
||||
return $this->success('参数错误');
|
||||
}
|
||||
|
||||
$time = time();
|
||||
$auth_activity = Cardauth2ActivityModel::where([['modular_id', '=', $data['modular_id']]])->findOrEmpty();
|
||||
|
||||
if (!$auth_activity->isEmpty()) {
|
||||
return $this->error('已存在此小程序');
|
||||
}
|
||||
|
||||
$total_activity_number = AdminUserService::getSassNum('activity',$this->_uniacid);
|
||||
|
||||
$total_activity_used = (int)$auth_activity->where([['uniacid','in',$this->_uniacid_arr]])->sum('count');
|
||||
$remain = $total_activity_number - $total_activity_used;
|
||||
if ($remain <= 0) {
|
||||
return $this->error('分配的数量超过可用的总数');
|
||||
}
|
||||
|
||||
$rst = $auth_activity->save([
|
||||
'modular_id' => $data[ 'modular_id' ],
|
||||
'create_time' => $time,
|
||||
'update_time' => $time,
|
||||
'sign' => intval( $time + ( 366 * 24 * 60 * 60 ) ),
|
||||
'count' => 1,
|
||||
'uniacid' => $this->_uniacid,
|
||||
]);
|
||||
|
||||
if ($rst) {
|
||||
return $this->success('success');
|
||||
}
|
||||
|
||||
return $this->error('fail');
|
||||
}
|
||||
|
||||
|
||||
public function extendedOneYear ()
|
||||
{
|
||||
$data = $this->_input;
|
||||
if (!isset($data['modular_id'])) {
|
||||
return $this->success('参数错误');
|
||||
}
|
||||
|
||||
$time = time();
|
||||
$auth_activity = Cardauth2ActivityModel::where([['modular_id', '=', $data['modular_id']]])->findOrEmpty();
|
||||
|
||||
if ($auth_activity->isEmpty()) {
|
||||
return $this->error('小程序不存在');
|
||||
}
|
||||
|
||||
$total_activity_number = AdminUserService::getSassNum('activity',$this->_uniacid);
|
||||
|
||||
$total_activity_used = (int)$auth_activity->where([['uniacid','in',$this->_uniacid_arr]])->sum('count');
|
||||
$remain = $total_activity_number - $total_activity_used;
|
||||
if ($remain <= 0) {
|
||||
return $this->error('分配的数量超过可用的总数');
|
||||
}
|
||||
|
||||
$rst = $auth_activity->save([
|
||||
'sign' => $auth_activity[ 'sign' ] > $time ? ($auth_activity[ 'sign' ] + ( 366 * 24 * 60 * 60 )) : ( $time + ( 366 * 24 * 60 * 60 ) ),
|
||||
'count' => $auth_activity['count'] + 1,
|
||||
'update_time' => $time,
|
||||
]);
|
||||
|
||||
|
||||
if ($rst) {
|
||||
return $this->success('success');
|
||||
}
|
||||
|
||||
|
||||
return $this->error('fail');
|
||||
}
|
||||
|
||||
}
|
||||
188
app/agent/controller/AdminAuthAppController.php
Executable file
188
app/agent/controller/AdminAuthAppController.php
Executable file
@@ -0,0 +1,188 @@
|
||||
<?php
|
||||
namespace app\agent\controller;
|
||||
|
||||
use app\admin\info\PermissionAdmin;
|
||||
use app\agent\model\Cardauth2ActivityModel;
|
||||
use app\agent\model\Cardauth2AuthAppModel as Cardauth2Model;
|
||||
use think\App;
|
||||
use app\AgentRest;
|
||||
use app\agent\service\AdminUserService;
|
||||
use think\facade\Db;
|
||||
|
||||
/**
|
||||
* @author shuixian
|
||||
* @DataTime: 2020/1/3 9:44
|
||||
* Class AdminAuthAppController
|
||||
* @package app\agent\controller
|
||||
*/
|
||||
class AdminAuthAppController extends AgentRest
|
||||
{
|
||||
|
||||
private $auth_app_name = '' ;
|
||||
|
||||
public function __construct ( App $app ){
|
||||
parent::__construct( $app );
|
||||
|
||||
//自动配置APPNAME
|
||||
if(isset($this->_param['app_name'])) $this->auth_app_name = $this->_param['app_name'] ;
|
||||
|
||||
$this->error(lang('app_name is empty')) ;
|
||||
|
||||
if ($this->_user['role_name'] != 'admin') {
|
||||
echo json_encode(['code' => 401, 'error' => lang('Permission denied')]);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-01-03 13:46
|
||||
* @功能说明:授权列表
|
||||
*/
|
||||
public function list(){
|
||||
$param = $this->_param;
|
||||
if (!isset($param['app_name'])) {
|
||||
return $this->error('参数错误');
|
||||
}
|
||||
|
||||
|
||||
//By.jingshuixian 2020年4月21日15:13:50
|
||||
//区分行业版数据
|
||||
|
||||
//获取列表
|
||||
if($this->_is_weiqin){
|
||||
|
||||
$app_model_name = APP_MODEL_NAME;
|
||||
$list = Cardauth2Model
|
||||
::alias('a')
|
||||
->field(['a.id', 'a.modular_id', 'a. create_time', 'a.sign', 'c.mini_app_name'])
|
||||
->join('longbing_card_config c', 'a.modular_id = c.uniacid')
|
||||
|
||||
->join('account' , 'a.modular_id = account.uniacid')
|
||||
->join('wxapp_versions v' , 'a.modular_id = v.uniacid')
|
||||
|
||||
->where([['a.status', '=', 1],['app_name','like',"%". $param['app_name'] ."%"] , ['account.type', '=', 4] ,['account.isdeleted', '=', 0] , ['v.modules', 'like', "%{$app_model_name}%"] ])
|
||||
->group('a.id')
|
||||
->paginate(['list_rows' => $param['page_count'] ? $param['page_count'] : 10, 'page' => $param['page'] ? $param['page'] : 1])
|
||||
->toArray();
|
||||
|
||||
}else{
|
||||
|
||||
$list = Cardauth2Model
|
||||
::alias('a')
|
||||
->field(['a.id', 'a.modular_id', 'a. create_time', 'a.sign', 'c.mini_app_name'])
|
||||
->join('longbing_card_config c', 'a.modular_id = c.uniacid')
|
||||
->where([['a.status', '=', 1],['app_name','=',$param['app_name']]])
|
||||
->group('a.id')
|
||||
->paginate(['list_rows' => $param['page_count'] ? $param['page_count'] : 10, 'page' => $param['page'] ? $param['page'] : 1])
|
||||
->toArray();
|
||||
|
||||
}
|
||||
|
||||
$wxapp_map = [];
|
||||
$wxapp = Db::name('account_wxapp')->field(['uniacid', 'name'])->select();
|
||||
foreach ($wxapp as $item) {
|
||||
$wxapp_map[$item['uniacid']] = $item['name'];
|
||||
}
|
||||
//小程序名称
|
||||
foreach ($list['data'] as $k => $item) {
|
||||
$list['data'][$k]['name'] = $wxapp_map[$item['modular_id']] ?? $item['mini_app_name'];
|
||||
unset($list['data'][$k]['mini_app_name']);
|
||||
}
|
||||
//总的授权数量
|
||||
$list['total_number'] = AdminUserService::getSassNum($param['app_name'],$this->_uniacid);
|
||||
//已经使用数量
|
||||
$list['total_used'] = Cardauth2Model::where([['uniacid','in',$this->_uniacid_arr],['app_name','=',$param['app_name']]])->sum('count');
|
||||
|
||||
return $this->success($list);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-01-03 13:31
|
||||
* @功能说明:创建小程序授权
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$data = $this->_input;
|
||||
if (!isset($data['modular_id'])||!isset($data['app_name'])) {
|
||||
return $this->error('参数错误');
|
||||
}
|
||||
//获取代理端授权数量
|
||||
$num = AdminUserService::getSassNum($data['app_name'],$this->_uniacid);
|
||||
|
||||
|
||||
$time = time();
|
||||
//查询是否有该小程序下的模块
|
||||
$auth = Cardauth2Model::where([['modular_id', '=', $data['modular_id']],['app_name','=',$data['app_name']]])->findOrEmpty();
|
||||
|
||||
if (!$auth->isEmpty()) {
|
||||
return $this->error('已存在此小程序');
|
||||
}
|
||||
//已经使用
|
||||
$total_num = Cardauth2Model::where([['uniacid','in',$this->_uniacid_arr],['app_name','=',$data['app_name']]])->sum('count');
|
||||
//剩余数量
|
||||
$remain = $num - $total_num;
|
||||
if ($remain <= 0) {
|
||||
return $this->error('分配的数量超过可用的总数');
|
||||
}
|
||||
//添加新的授权
|
||||
$rst = $auth->save([
|
||||
'modular_id' => $data[ 'modular_id' ],
|
||||
'create_time' => $time,
|
||||
'update_time' => $time,
|
||||
'sign' => intval( $time + ( 366 * 24 * 60 * 60 ) ),
|
||||
'count' => 1,
|
||||
'uniacid' => $this->_uniacid,
|
||||
'app_name' => $data['app_name'],
|
||||
'sign_data' =>'ndvjnfjvnjnv'.$time
|
||||
]);
|
||||
if ($rst) {
|
||||
return $this->success('success');
|
||||
}
|
||||
return $this->error('fail');
|
||||
}
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-01-03 13:42
|
||||
* @功能说明:增加小程序授权一年
|
||||
*/
|
||||
public function extendedOneYear ()
|
||||
{
|
||||
$data = $this->_input;
|
||||
//参数验证
|
||||
if (!isset($data['modular_id'])||!isset($data['app_name'])) {
|
||||
return $this->error('参数错误');
|
||||
}
|
||||
$time = time();
|
||||
$auth = Cardauth2Model::where([['modular_id', '=', $data['modular_id']],['app_name','=',$data['app_name']]])->findOrEmpty();
|
||||
if ($auth->isEmpty()) {
|
||||
return $this->error('小程序不存在');
|
||||
}
|
||||
//获取授权数量
|
||||
$num = AdminUserService::getSassNum($data['app_name'],$this->_uniacid);
|
||||
//获取已使用数量
|
||||
$total_used = Cardauth2Model::where([['uniacid','in',$this->_uniacid_arr],['app_name','=',$data['app_name']]])->sum('count');
|
||||
|
||||
$remain = $num - $total_used;
|
||||
//判断剩余数量
|
||||
if ($remain <= 0) {
|
||||
return $this->error('分配的数量超过可用的总数');
|
||||
}
|
||||
//修改授权时间|增加使用数量
|
||||
$rst = $auth->save([
|
||||
'sign' => $auth[ 'sign' ] > $time ? ($auth[ 'sign' ] + ( 366 * 24 * 60 * 60 )) : ( $time + ( 366 * 24 * 60 * 60 ) ),
|
||||
'count' => $auth['count'] + 1,
|
||||
'update_time' => $time,
|
||||
]);
|
||||
|
||||
if ($rst) {
|
||||
return $this->success('success');
|
||||
}
|
||||
|
||||
return $this->error('fail');
|
||||
}
|
||||
|
||||
}
|
||||
135
app/agent/controller/AdminAuthController.php
Executable file
135
app/agent/controller/AdminAuthController.php
Executable file
@@ -0,0 +1,135 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\agent\controller;
|
||||
|
||||
|
||||
use app\agent\model\AdminModel;
|
||||
use app\agent\model\Cardauth2ConfigModel;
|
||||
use app\BaseController;
|
||||
use think\facade\Lang;
|
||||
use think\Response;
|
||||
|
||||
class AdminAuthController extends BaseController
|
||||
{
|
||||
//登陆
|
||||
public function auth()
|
||||
{
|
||||
$input = json_decode( $this->request->getInput(), true );
|
||||
$admin = AdminModel::where([
|
||||
['account', '=', $input['account'] ?? ''],
|
||||
['deleted', '=', 0],
|
||||
['status', '=', 1],
|
||||
])->findOrEmpty();
|
||||
|
||||
if ($admin->isEmpty()) {
|
||||
return $this->error('用户不存在', 400);
|
||||
}
|
||||
|
||||
//判断密码是否正确
|
||||
if (!checkPasswd($input['passwd'], $admin['offset'], $admin['passwd'])) {
|
||||
return $this->error('密码错误', 400);
|
||||
}
|
||||
//返回数据
|
||||
$user = [
|
||||
'admin_id' => $admin->admin_id,
|
||||
'level' => $admin->level,
|
||||
'account'=> $admin->account,
|
||||
'role' => $admin->role->role_name ?? 'user',
|
||||
'role_name' => $admin->role->role_name ?? 'user',
|
||||
'uniacid' => $admin->appAdmin->modular_id ?? -1,
|
||||
];
|
||||
|
||||
if ($user['uniacid'] == -1) {
|
||||
return $this->error("用户没有绑定小程序, 请联系代理端超级管理员");
|
||||
}
|
||||
if (isset($input['isAgent']) && $input['isAgent'] == true && $user['role'] != 'admin') {
|
||||
return $this->error('普通用户禁止访问');
|
||||
}
|
||||
|
||||
if (isset($input['isAgent']) && $input['isAgent'] == false && $user['role'] == 'admin') {
|
||||
return $this->error('超级管理员禁止访问, 请创建子管理员账号并绑定小程序登录');
|
||||
}
|
||||
|
||||
$result['user'] = $user;
|
||||
$result['token'] = createToken();
|
||||
if (empty($result['token'])) {
|
||||
return $this->error('系统错误', 400);
|
||||
}
|
||||
|
||||
//添加缓存数据
|
||||
setUserForToken($result['token'], $user, 99999999);
|
||||
return $this->success($result, 200);
|
||||
}
|
||||
|
||||
|
||||
//注销
|
||||
public function unAuth()
|
||||
{
|
||||
$header = $this->request->header();
|
||||
$token = $header['token'] ?? null;
|
||||
if ($token == null || !getUserForToken($token)) {
|
||||
$this->error('用户未登录');
|
||||
}
|
||||
|
||||
//删除缓存
|
||||
delUserForToken($token);
|
||||
//返回数据
|
||||
return $this->success(true);
|
||||
}
|
||||
|
||||
//获取账户状态
|
||||
public function AuthStatus(){
|
||||
$header = $this->request->header();
|
||||
$token = $header['token'] ?? null;
|
||||
$user = getUserForToken($token);
|
||||
|
||||
$resData = longbing_auth_status($user['uniacid']);
|
||||
return $this->success($resData);
|
||||
}
|
||||
|
||||
public function isWe7()
|
||||
{
|
||||
$is_we7 = defined('IS_WEIQIN');
|
||||
|
||||
return $this->success($is_we7);
|
||||
}
|
||||
|
||||
|
||||
public function success ( $data, $code = 200 )
|
||||
{
|
||||
$result[ 'data' ] = $data;
|
||||
$result[ 'code' ] = $code;
|
||||
$result[ 'sign' ] = null;
|
||||
//复杂的签名
|
||||
// if(isset($this->_user['keys'])){
|
||||
// $result['sign'] = rsa2CreateSign($this->_user['keys'] ,json_encode($data));
|
||||
// }
|
||||
//简单的签名
|
||||
if ( !empty( $this->_token ) ) $result[ 'sign' ] = createSimpleSign( $this->_token, is_string( $data ) ? $data : json_encode( $data ) );
|
||||
|
||||
return $this->response( $result, 'json', $code );
|
||||
}
|
||||
|
||||
//返回错误数据
|
||||
public function error ( $msg, $code = 400 )
|
||||
{
|
||||
$result[ 'error' ] = Lang::get($msg);
|
||||
$result[ 'code' ] = $code;
|
||||
return $this->response( $result, 'json', 200 );
|
||||
}
|
||||
|
||||
/**
|
||||
* 输出返回数据
|
||||
* @access protected
|
||||
* @param mixed $data 要返回的数据
|
||||
* @param String $type 返回类型 JSON XML
|
||||
* @param integer $code HTTP状态码
|
||||
* @return Response
|
||||
*/
|
||||
protected function response ( $data, $type = 'json', $code = 200 )
|
||||
{
|
||||
return Response::create( $data, $type )->code( $code );
|
||||
}
|
||||
|
||||
}
|
||||
207
app/agent/controller/AdminController.php
Executable file
207
app/agent/controller/AdminController.php
Executable file
@@ -0,0 +1,207 @@
|
||||
<?php
|
||||
namespace app\agent\controller;
|
||||
|
||||
use think\App;
|
||||
use app\AdminRest;
|
||||
use app\agent\model\AdminModel;
|
||||
use app\agent\model\AppAdminModel;
|
||||
use app\AgentRest;
|
||||
use app\agent\validate\AgentAdminValidate;
|
||||
|
||||
class AdminController extends AgentRest
|
||||
{
|
||||
public function __construct ( App $app ){
|
||||
parent::__construct( $app );
|
||||
if ($this->_user['role_name'] != 'admin') {
|
||||
echo json_encode(['code' => 401, 'error' => lang('Permission denied')]);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
*获取用户列表
|
||||
*/
|
||||
public function list()
|
||||
{
|
||||
$param = $this->_param;
|
||||
|
||||
|
||||
$dis = [];
|
||||
|
||||
|
||||
if(!empty($param['name'])){
|
||||
|
||||
$dis[] = ['a.account','like',"%".$param['name'].'%'];
|
||||
|
||||
$dis[] = ['d.mini_app_name','like',"%".$param['name'].'%'];
|
||||
}
|
||||
|
||||
$list = AdminModel::alias('a')
|
||||
->field(['a.admin_id', 'a.level','a.account', 'a.role_id', 'a.create_time', 'r.description','d.mini_app_name as mini_name','c.modular_id'])
|
||||
->leftJoin('longbing_role r', 'a.role_id = r.role_id')
|
||||
->leftJoin('longbing_app_admin c', 'a.admin_id = c.admin_id')
|
||||
->leftJoin('longbing_card_config d', 'c.modular_id = d.uniacid')
|
||||
->where([['a.status', '=', 1], ['a.uniacid', '=', $this->_uniacid]])
|
||||
->where(function ($query) use ($dis){
|
||||
$query->whereOr($dis);
|
||||
})
|
||||
->order('a.create_time desc')
|
||||
->paginate(['list_rows' => $param['page_count'] ? $param['page_count'] : 10, 'page' => $param['page'] ? $param['page'] : 1])
|
||||
->toArray();
|
||||
|
||||
|
||||
// $admin_ids = array_column($list['data'], 'admin_id');
|
||||
// $app_admins = [];
|
||||
// $app_admins_tmp = AppAdminModel::alias('aa')
|
||||
// ->field(['aa.admin_id', 'aa.modular_id', 'c.mini_app_name' => 'mini_name'])
|
||||
// ->leftJoin('longbing_card_config c', 'aa.modular_id = c.uniacid')
|
||||
// ->where([['aa.admin_id', 'IN', $admin_ids]])->select();
|
||||
//
|
||||
// foreach ($app_admins_tmp as $k => $v) {
|
||||
// $app_admins[$v['admin_id']] = $v;
|
||||
// }
|
||||
|
||||
foreach ($list['data'] as $k => $v) {
|
||||
|
||||
$list['data'][$k]['is_bind'] = !empty($v['mini_name']);
|
||||
|
||||
|
||||
if($v['description']!='超级管理员'){
|
||||
|
||||
$list['data'][$k]['description'] = $v['level']==0?'管理员':'员工';
|
||||
}
|
||||
|
||||
// $list['data'][$k]['mini_name'] = $app_admins[$v['admin_id']]['mini_name'] ?? null;
|
||||
// $list['data'][$k]['modular_id'] = $app_admins[$v['admin_id']]['modular_id'] ?? null;
|
||||
}
|
||||
|
||||
$list['zhihuituike'] = longbingIsZhihuituike();
|
||||
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
//添加用户
|
||||
public function addSubAdmin()
|
||||
{
|
||||
$input = $this->_input;
|
||||
|
||||
$validate = new AgentAdminValidate();
|
||||
if (false == $validate->scene('addSubAdmin')->check($input)) {
|
||||
return $this->error($validate->getError());
|
||||
};
|
||||
|
||||
/**
|
||||
* @var AdminModel $subAdmin
|
||||
*/
|
||||
$subAdmin = AdminModel::where([['account', '=', $input['account']], ['status', '=', 1]])->findOrEmpty();
|
||||
if (!$subAdmin->isEmpty()) {
|
||||
return $this->error('该账号已存在');
|
||||
}
|
||||
|
||||
$offset = createOffset();
|
||||
$new = [
|
||||
'admin_id' => uuid(),
|
||||
'account' => $input['account'],
|
||||
'uniacid' => $this->_uniacid,
|
||||
'offset' => $offset,
|
||||
'passwd' => createPasswd($input['passwd'], $offset),
|
||||
'role_id' => 'e7d81116997011e99b985595a87cbdcb',
|
||||
'creator_id' => $this->_user['admin_id'],
|
||||
'status' => 1,
|
||||
|
||||
'level' => $input['level']
|
||||
];
|
||||
$rst = $subAdmin->save($new);
|
||||
if (!$rst) {
|
||||
return $this->error('fail');
|
||||
}
|
||||
return $this->success($rst);
|
||||
}
|
||||
|
||||
/*
|
||||
* 管理员修改用户信息
|
||||
*/
|
||||
public function updateSubAdmin()
|
||||
{
|
||||
//获取数据
|
||||
$input = $this->_input;
|
||||
//字段校验
|
||||
$validate = new AgentAdminValidate();
|
||||
if (false == $validate->scene('addSubAdmin')->check($input)) {
|
||||
return $this->error($validate->getError());
|
||||
};
|
||||
|
||||
/**
|
||||
* @var AdminModel $subAdmin
|
||||
*/
|
||||
$subAdmin = AdminModel::where([['admin_id', '=', $input['admin_id']], ['uniacid', '=', $this->_uniacid]])->find();
|
||||
if (empty($subAdmin)) {
|
||||
return $this->error('用户不存在');
|
||||
}
|
||||
//强制修改密码
|
||||
$input['passwd'] = createPasswd($input['passwd'] ,$subAdmin['offset']);
|
||||
$result = $subAdmin->save([
|
||||
'passwd' => $input['passwd'],
|
||||
'level' => $input['level'],
|
||||
]);
|
||||
|
||||
return $this->success($result);
|
||||
}
|
||||
|
||||
|
||||
public function delSubAdmin()
|
||||
{
|
||||
$input = $this->_input;
|
||||
|
||||
$validate = new AgentAdminValidate();
|
||||
if (false == $validate->scene('delSubAdmin')->check($input)) {
|
||||
return $this->error($validate->getError());
|
||||
};
|
||||
|
||||
/**
|
||||
* @var AdminModel $subAdmin
|
||||
*/
|
||||
$subAdmin = AdminModel::where([['admin_id', '=', $input['admin_id']], ['uniacid', '=', $this->_uniacid]])->findOrEmpty();
|
||||
|
||||
if ($subAdmin->isEmpty()) {
|
||||
return $this->error('用户不存在');
|
||||
}
|
||||
|
||||
if ($subAdmin->admin_id == $this->_user['admin_id']) {
|
||||
return $this->error("不可以删除自己");
|
||||
}
|
||||
|
||||
$rst = $subAdmin->save([
|
||||
'status' => 0,
|
||||
]);
|
||||
|
||||
return $this->success($rst);
|
||||
}
|
||||
|
||||
|
||||
public function bindApp()
|
||||
{
|
||||
$input = $this->_input;
|
||||
$admin_id = $input['admin_id'];
|
||||
$modular_id = $input['modular_id'];
|
||||
|
||||
if ($admin_id == $this->_user['admin_id']) {
|
||||
return $this->error("超级管理员不能绑定小程序, 您可以创建子账号绑定");
|
||||
}
|
||||
$admin_bind_count = AppAdminModel::where([['admin_id', '=', $admin_id]])->count();
|
||||
if ($admin_bind_count > 0) {
|
||||
return $this->error('该用户已经绑定了一个小程序');
|
||||
}
|
||||
|
||||
$appAdmin = new AppAdminModel();
|
||||
$rst = $appAdmin->save([
|
||||
'id' => md5($modular_id . $admin_id),
|
||||
'modular_id' => $modular_id,
|
||||
'uniacid' => $this->_uniacid,
|
||||
'admin_id' => $admin_id
|
||||
]);
|
||||
|
||||
return $this->success($rst);
|
||||
|
||||
}
|
||||
}
|
||||
150
app/agent/controller/AgentLevel.php
Executable file
150
app/agent/controller/AgentLevel.php
Executable file
@@ -0,0 +1,150 @@
|
||||
<?php
|
||||
namespace app\agent\controller;
|
||||
|
||||
|
||||
use think\App;
|
||||
use app\AgentRest;
|
||||
|
||||
|
||||
/**
|
||||
* @author shuixian
|
||||
* @DataTime: 2020/1/3 9:44
|
||||
* Class AdminAuthAppController
|
||||
* @package app\agent\controller
|
||||
*/
|
||||
class AgentLevel extends AgentRest
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-05-12 13:20
|
||||
* @功能说明:代理商等级列表
|
||||
*/
|
||||
public function levelList(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$dis[] = ['uniacid','in',$this->_uniacid_arr];
|
||||
|
||||
$dis[] = ['status','=',1];
|
||||
//模型
|
||||
$agent_model = new \app\agent\model\AgentLevel();
|
||||
//查询
|
||||
$data = $agent_model->levelList($dis,$input['page_count']);
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-05-12 13:21
|
||||
* @功能说明:添加代理商
|
||||
*/
|
||||
public function agentAdd(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$input['uniacid'] = $this->_uniacid;
|
||||
|
||||
if(empty(trim($input['title']))){
|
||||
|
||||
$this->errorMsg('标题不能为空');
|
||||
}
|
||||
|
||||
$agent_model = new \app\agent\model\AgentLevel();
|
||||
|
||||
$res = $agent_model->levelAdd($input);
|
||||
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-05-12 13:31
|
||||
* @功能说明:编辑代理商
|
||||
*/
|
||||
public function agentUpdate(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$agent_model = new \app\agent\model\AgentLevel();
|
||||
|
||||
$data = $agent_model->levelUpdate(['id'=>$input['id']],$input);
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-05-12 13:33
|
||||
* @功能说明:代理商详情
|
||||
*/
|
||||
public function agentInfo(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$agent_model = new \app\agent\model\AgentLevel();
|
||||
|
||||
$data = $agent_model->levelInfo(['id'=>$input['id'],'status'=>1]);
|
||||
|
||||
return $this->success($data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-05-12 14:12
|
||||
* @功能说明:选择框
|
||||
*/
|
||||
public function levelSelect(){
|
||||
|
||||
$dis[] = ['uniacid','=',$this->_uniacid];
|
||||
|
||||
$dis[] = ['uniacid','in',$this->_uniacid_arr];
|
||||
|
||||
$agent_model = new \app\agent\model\AgentLevel();
|
||||
|
||||
$data = $agent_model->levelSelect($dis);
|
||||
|
||||
return $this->success($data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-05-26 13:46
|
||||
* @功能说明:删除
|
||||
*/
|
||||
public function levelDel(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$level_model = new \app\agent\model\AgentLevel();
|
||||
|
||||
$agent_model = new \app\agent\model\AgentList();
|
||||
|
||||
$dis[] = ['level','=',$input['id']];
|
||||
|
||||
$dis[] = ['status','>',-1];
|
||||
|
||||
$info = $agent_model->agentInfo($dis);
|
||||
|
||||
// dump($info);exit;
|
||||
|
||||
if(!empty($info)){
|
||||
|
||||
$this->errorMsg('该等级正在被使用,使用代理商:'.$info['user_name']);
|
||||
}
|
||||
|
||||
$data = $level_model->levelUpdate(['id'=>$input['id']],['status'=>-1]);
|
||||
|
||||
return $this->success($data);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
139
app/agent/controller/AgentList.php
Executable file
139
app/agent/controller/AgentList.php
Executable file
@@ -0,0 +1,139 @@
|
||||
<?php
|
||||
namespace app\agent\controller;
|
||||
|
||||
|
||||
use think\App;
|
||||
use app\AgentRest;
|
||||
|
||||
|
||||
/**
|
||||
* @author shuixian
|
||||
* @DataTime: 2020/1/3 9:44
|
||||
* Class AdminAuthAppController
|
||||
* @package app\agent\controller
|
||||
*/
|
||||
class AgentList extends AgentRest
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-05-12 13:20
|
||||
* @功能说明:代理商列表
|
||||
*/
|
||||
public function agentList(){
|
||||
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$dis[] = ['uniacid','in',$this->_uniacid_arr];
|
||||
//模型
|
||||
$agent_model = new \app\agent\model\AgentList();
|
||||
//等级搜索
|
||||
if(!empty($input['level'])){
|
||||
|
||||
$dis[] = ['level','=',$input['level']];
|
||||
}
|
||||
//用户名搜索
|
||||
if(!empty($input['user_name'])){
|
||||
|
||||
$dis[] = ['user_name','like','%'.$input['user_name'].'%'];
|
||||
}
|
||||
//状态搜索
|
||||
if(!empty($input['status'])){
|
||||
|
||||
$icon = $input['status']==1?'>':'<';
|
||||
|
||||
$dis[] =['over_time',$icon,time()];
|
||||
}
|
||||
//省搜索
|
||||
if(!empty($input['province_code'])){
|
||||
|
||||
$dis[] = ['province_code','=',$input['province_code']];
|
||||
|
||||
}
|
||||
//市搜索
|
||||
if(!empty($input['city_code'])){
|
||||
|
||||
$dis[] = ['city_code','=',$input['city_code']];
|
||||
|
||||
}
|
||||
//查询
|
||||
$data = $agent_model->agentList($dis,$input['page_count']);
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-05-12 13:21
|
||||
* @功能说明:添加代理商
|
||||
*/
|
||||
public function agentAdd(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$input['uniacid'] = $this->_uniacid;
|
||||
|
||||
$agent_model = new \app\agent\model\AgentList();
|
||||
|
||||
$res = $agent_model->agentAdd($input);
|
||||
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-05-12 13:31
|
||||
* @功能说明:编辑代理商
|
||||
*/
|
||||
public function agentUpdate(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$agent_model = new \app\agent\model\AgentList();
|
||||
|
||||
$data = $agent_model->agentUpdate(['id'=>$input['id']],$input);
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-05-12 13:33
|
||||
* @功能说明:代理商详情
|
||||
*/
|
||||
public function agentInfo(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$agent_model = new \app\agent\model\AgentList();
|
||||
|
||||
$data = $agent_model->agentInfo(['id'=>$input['id']]);
|
||||
|
||||
return $this->success($data);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-05-12 14:12
|
||||
* @功能说明:
|
||||
*/
|
||||
public function agentSelect(){
|
||||
|
||||
$dis[] = ['uniacid','in',$this->_uniacid_arr];
|
||||
|
||||
$agent_model = new \app\agent\model\AgentList();
|
||||
|
||||
$data = $agent_model->where($dis)->order('id desc')->field('id,user_name')->select()->toArray();
|
||||
|
||||
return $this->success($data);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
804
app/agent/controller/AppController.php
Executable file
804
app/agent/controller/AppController.php
Executable file
@@ -0,0 +1,804 @@
|
||||
<?php
|
||||
namespace app\agent\controller;
|
||||
|
||||
use longbingcore\tools\LongbingArr;
|
||||
use think\App;
|
||||
use app\agent\model\AppAdminModel;
|
||||
use app\agent\model\Cardauth2ConfigModel;
|
||||
use app\agent\model\Cardauth2CopyrightModel;
|
||||
use app\AgentRest;
|
||||
use app\admin\model\AppConfig as CardConfig;
|
||||
use app\agent\validate\Cardauth2ConfigValidate;
|
||||
use think\facade\Db;
|
||||
use app\Common\Rsa2Sign;
|
||||
|
||||
class AppController extends AgentRest
|
||||
{
|
||||
public function __construct ( App $app ){
|
||||
|
||||
parent::__construct( $app );
|
||||
if ($this->_user['role_name'] != 'admin') {
|
||||
echo json_encode(['code' => 401, 'error' => lang('Permission denied')]);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-05-14 14:18
|
||||
* @功能说明:授权管理
|
||||
*/
|
||||
public function list()
|
||||
{
|
||||
$param = $this->_param;
|
||||
|
||||
$m_config = new Cardauth2ConfigModel();
|
||||
|
||||
$dis[] = ['a.status', '=', 1];
|
||||
//小程序名字搜索
|
||||
if(!empty($param['mini_name'])){
|
||||
|
||||
$dis[] = ['a.mini_name','like','%'.$param['mini_name'].'%'];
|
||||
}
|
||||
//代理商搜索
|
||||
if(!empty($param['agent_id'])){
|
||||
|
||||
$dis[] = ['a.agent_id','=',$param['agent_id']];
|
||||
}
|
||||
|
||||
if($this->_is_weiqin){
|
||||
|
||||
//By.jingshuixian 2020年4月16日18:31:41
|
||||
//新增根据模块名称关联查询 , 目的是 装修只能找到装修的授权列表, 名片只能找到名片授权列表
|
||||
//新增授权 小程序列表也需要调整
|
||||
//ims_account 微擎小程序记录表
|
||||
//ims_wxapp_versions 微擎小程序版本表
|
||||
|
||||
$app_model_name = APP_MODEL_NAME;
|
||||
$dis[] = ['v.modules', 'like', "%{$app_model_name}%"] ;
|
||||
$list = $m_config
|
||||
->alias('a')
|
||||
->join('wxapp_versions v' , 'a.modular_id = v.uniacid')
|
||||
->field(['a.id', 'a.mini_name', 'a.modular_id', 'a.number', 'a.copyright_id', 'a.create_time', 'a.end_time', 'a.remark','a.agent_id','a.upload_setting'])
|
||||
->group('a.modular_id')
|
||||
->where($dis)
|
||||
->paginate(['list_rows' => $param['page_count'] ? $param['page_count'] : 10, 'page' => $param['page'] ? $param['page'] : 1])
|
||||
->toArray();
|
||||
|
||||
}else{
|
||||
|
||||
|
||||
$list = $m_config
|
||||
->alias('a')
|
||||
->field(['id', 'mini_name', 'modular_id', 'number', 'copyright_id', 'create_time', 'end_time', 'remark','agent_id','upload_setting'])
|
||||
->where($dis)
|
||||
->paginate(['list_rows' => $param['page_count'] ? $param['page_count'] : 10, 'page' => $param['page'] ? $param['page'] : 1])
|
||||
->toArray();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$copyrights = [];
|
||||
$copyright_ids = array_column($list['data'] ?? [], 'copyright_id');
|
||||
$copyrights_temp = Cardauth2CopyrightModel::where([['id', 'IN', $copyright_ids], ['status', '=', 1]])->field(['id', 'name'])->select();
|
||||
foreach ($copyrights_temp as $item) {
|
||||
$copyrights[$item['id']] = $item['name'];
|
||||
}
|
||||
|
||||
//代理商模型
|
||||
$agent_model = new \app\agent\model\AgentList();
|
||||
|
||||
foreach ($list['data'] as $k => $item) {
|
||||
|
||||
$list['data'][$k]['copyright'] = $copyrights[$item['copyright_id']] ?? "";
|
||||
// //代理商名字
|
||||
$agent_name = $agent_model->where(['id'=>$item['agent_id']])->value('user_name');
|
||||
|
||||
$list['data'][$k]['agent_name'] = !empty($agent_name)?$agent_name:'';
|
||||
|
||||
}
|
||||
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
public function get()
|
||||
{
|
||||
$id = $this->_param['id'] ?? null;
|
||||
if (!$id) {
|
||||
return $this->error('参数错误');
|
||||
}
|
||||
|
||||
$config = Cardauth2ConfigModel::find($id);
|
||||
$config['boss'] = $config['boos'] ?? null;
|
||||
$config['activity'] = $config['activity_switch'] ?? null;
|
||||
$config['appiont'] = $config['appoint'] ?? null;
|
||||
|
||||
$eventData = event('AgentAppAuthEdit' , $config);
|
||||
|
||||
|
||||
$eventData = LongbingArr::array_merge($eventData);
|
||||
|
||||
$config['authList'] = $eventData ;
|
||||
|
||||
return $this->success($config);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增小程序授权时,获取所有权限列表
|
||||
*
|
||||
* @return \think\Response
|
||||
* @author shuixian
|
||||
* @DataTime: 2019/12/30 14:00
|
||||
*/
|
||||
public function getAuthList(){
|
||||
|
||||
$eventData = event('AgentAppAuthEdit' , []);
|
||||
$eventData = LongbingArr::array_merge($eventData);
|
||||
$config['authList'] = $eventData ;
|
||||
|
||||
return $this->success($config);
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
$input = $this->_input;
|
||||
|
||||
$time = time();
|
||||
if (defined('IS_WEIQIN')) {
|
||||
$validate = new Cardauth2ConfigValidate();
|
||||
$check = $validate->scene('create')->append('modular_id', 'require')->check($input);
|
||||
if ($check == false) {
|
||||
return $this->error($validate->getError());
|
||||
}
|
||||
|
||||
$m_auth2_config = Cardauth2ConfigModel::where([['modular_id', '=', $input['modular_id']], ['status', '=', 1]])->findOrEmpty();
|
||||
|
||||
if (!$m_auth2_config->isEmpty()) {
|
||||
return $this->error('小程序已存在');
|
||||
}
|
||||
|
||||
$mini_name = Db::name('account_wxapp')->field(['acid', 'name'])->where([['uniacid', '=', $input['modular_id']]])->find();
|
||||
$rst = $m_auth2_config->save(
|
||||
[
|
||||
//代理商
|
||||
'agent_id' => !empty($input['agent_id'])?$input['agent_id']:0,
|
||||
|
||||
'upload_setting' => !empty($input['upload_setting'])?$input['upload_setting']:0,
|
||||
|
||||
'modular_id' => $input['modular_id'],
|
||||
'number' => $input['number'],
|
||||
'uniacid' => 0,
|
||||
'create_time' => $time,
|
||||
'update_time' => $time,
|
||||
'remark' => $input['remark'],
|
||||
'end_time' => $input['end_time'],
|
||||
'mini_name' => $mini_name['name'] ?? '',
|
||||
'copyright_id' => $input['copyright_id'],
|
||||
'send_switch' => $input['send_switch'],
|
||||
'boos' => $input['boss'],
|
||||
'appoint' => $input['appiont'],
|
||||
'payqr' => $input['payqr'],
|
||||
'shop_switch' => $input['shop_switch'],
|
||||
'timeline_switch' => $input['timeline_switch'],
|
||||
'website_switch' => $input['website_switch'],
|
||||
'article' => $input['article'],
|
||||
'activity' => $input['activity'],
|
||||
'pay_shop' => $input['pay_shop'],
|
||||
'house_switch' => $input['house_switch'],
|
||||
//带客有礼
|
||||
'passenger_switch' => $input['passenger_switch'],
|
||||
//百度
|
||||
'baidu_switch' => $input['baidu_switch'],
|
||||
//截流
|
||||
'closure_switch' => $input['closure_switch'],
|
||||
//红包
|
||||
'redbag_switch' => $input['redbag_switch'],
|
||||
//满减
|
||||
'reduction_switch' => $input['reduction_switch'],
|
||||
//直播
|
||||
'livevideo_switch' => $input['livevideo_switch'],
|
||||
//短视频
|
||||
'shortvideo_switch'=> $input['shortvideo_switch'],
|
||||
//会员
|
||||
'member_switch' => $input['member_switch'],
|
||||
//餐饮
|
||||
'restaurant_switch' => $input['restaurant_switch'],
|
||||
// 霸王餐
|
||||
'overlord_switch' => $input['overlord_switch'],
|
||||
// 付费课程
|
||||
'payclass_switch' => $input['payclass_switch'],
|
||||
|
||||
'bargain_switch' => $input['bargain_switch'],
|
||||
|
||||
'question_switch' => $input['question_switch'],
|
||||
|
||||
|
||||
// 'tool_switch' => $input['tool_switch'],
|
||||
]
|
||||
);
|
||||
|
||||
return $this->success($rst);
|
||||
|
||||
}
|
||||
|
||||
|
||||
$validate = new Cardauth2ConfigValidate();
|
||||
$check = $validate->scene('create')->check($input);
|
||||
if ($check == false) {
|
||||
return $this->error($validate->getError());
|
||||
}
|
||||
|
||||
$m_auth2_config = Cardauth2ConfigModel::where([['mini_name', '=', $input['mini_name']]])->findOrEmpty();
|
||||
if (!$m_auth2_config->isEmpty()) {
|
||||
return $this->error('小程序已存在');
|
||||
}
|
||||
|
||||
$lenth_name = strlen($input['mini_name']);
|
||||
if ($lenth_name <= 0 || $lenth_name >= 30 ) {
|
||||
return $this->error("名字长度只能在0到30个字符");
|
||||
}
|
||||
|
||||
$max_uniacid_card_config = CardConfig::field('uniacid')->order('uniacid', 'desc')->limit(1)->select()->toArray();
|
||||
$max_uniacid = $max_uniacid_card_config[0]['uniacid'] ?? 0;
|
||||
|
||||
$auth_name = Cardauth2ConfigModel::where([['mini_name', '=', $input['mini_name']], ['status', '=', 1]])->find();
|
||||
if(!empty($auth_name)){
|
||||
return $this->error("小程序名字不能重复");
|
||||
}
|
||||
$rst = $m_auth2_config->save(
|
||||
[
|
||||
//代理商
|
||||
'agent_id' => !empty($input['agent_id'])?$input['agent_id']:0,
|
||||
|
||||
'upload_setting' => !empty($input['upload_setting'])?$input['upload_setting']:0,
|
||||
|
||||
'modular_id' => $max_uniacid + 1,
|
||||
'number' => $input['number'],
|
||||
'uniacid' => $this->_uniacid,
|
||||
'create_time' => $time,
|
||||
'update_time' => $time,
|
||||
'remark' => $input['remark'],
|
||||
'end_time' => $input['end_time'],
|
||||
'mini_name' => $input['mini_name'],
|
||||
'copyright_id' => $input['copyright_id'],
|
||||
'send_switch' => $input['send_switch'],
|
||||
'boos' => $input['boss'],
|
||||
'appoint' => $input['appiont'],
|
||||
'payqr' => $input['payqr'],
|
||||
'shop_switch' => $input['shop_switch'],
|
||||
'timeline_switch' => $input['timeline_switch'],
|
||||
'website_switch' => $input['website_switch'],
|
||||
'article' => $input['article'],
|
||||
'activity_switch' => $input['activity'] ?? $input['activity_switch'],
|
||||
'pay_shop' => $input['pay_shop'],
|
||||
'house_switch' => $input['house_switch'],
|
||||
//带客有礼
|
||||
'passenger_switch' => $input['passenger_switch'],
|
||||
//百度
|
||||
'baidu_switch' => $input['baidu_switch'],
|
||||
//截流
|
||||
'closure_switch' => $input['closure_switch'],
|
||||
//红包
|
||||
'redbag_switch' => $input['redbag_switch'],
|
||||
//满减
|
||||
'reduction_switch' => $input['reduction_switch'],
|
||||
//直播
|
||||
'livevideo_switch' => $input['livevideo_switch'],
|
||||
//短视频
|
||||
'shortvideo_switch'=> $input['shortvideo_switch'],
|
||||
//会员
|
||||
'member_switch' => $input['member_switch'],
|
||||
// 餐饮
|
||||
'restaurant_switch' => $input['restaurant_switch'],
|
||||
// 霸王餐
|
||||
'overlord_switch' => $input['overlord_switch'],
|
||||
// 付费课程
|
||||
'payclass_switch' => $input['payclass_switch'],
|
||||
|
||||
'bargain_switch' => $input['bargain_switch'],
|
||||
|
||||
'question_switch' => $input['question_switch'],
|
||||
// 'tool_switch' => $input['tool_switch'],
|
||||
]
|
||||
);
|
||||
|
||||
$rst = $rst && $m_auth2_config->cardConfig()->save([
|
||||
'uniacid' => $m_auth2_config->modular_id,
|
||||
'create_time' => $m_auth2_config->create_time,
|
||||
'update_time' => $m_auth2_config->update_time,
|
||||
'copyright' => "",
|
||||
'is_sync' =>1,
|
||||
'mini_app_name' => $m_auth2_config->mini_name,
|
||||
'create_txt' => "创建我的智能名片",
|
||||
]);
|
||||
|
||||
|
||||
if ($rst) {
|
||||
return $this->success($m_auth2_config->id);
|
||||
}
|
||||
|
||||
return $this->error('fail');
|
||||
|
||||
}
|
||||
|
||||
public function update()
|
||||
{
|
||||
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$input['boos'] = $input['boss'];
|
||||
$input['appoint'] = $input['appiont'];
|
||||
$input['activity_switch'] = $input['activity'];
|
||||
|
||||
if (defined('IS_WEIQIN')) {
|
||||
$validate = new Cardauth2ConfigValidate();
|
||||
$check = $validate->scene('update')->check($input);
|
||||
if ($check == false) {
|
||||
return $this->error($validate->getError());
|
||||
}
|
||||
|
||||
$m_auth2_config = Cardauth2ConfigModel::where('id', '=', $input['id'])->findOrEmpty();
|
||||
if ($m_auth2_config->isEmpty()) {
|
||||
return $this->error('未找到小程序');
|
||||
}
|
||||
|
||||
/**
|
||||
* @var Cardauth2ConfigModel $m_auth2_config
|
||||
*/
|
||||
$rst = $m_auth2_config->allowField([
|
||||
|
||||
'agent_id',
|
||||
|
||||
'upload_setting',
|
||||
|
||||
'number',
|
||||
'end_time',
|
||||
'copyright_id',
|
||||
'send_switch',
|
||||
'boos',
|
||||
'appoint',
|
||||
'payqr',
|
||||
'shop_switch',
|
||||
'timeline_switch',
|
||||
'website_switch',
|
||||
'article',
|
||||
'activity_switch',
|
||||
'pay_shop' ,
|
||||
'house_switch',
|
||||
'tool_switch',
|
||||
'remark',
|
||||
'closure_switch',
|
||||
'baidu_switch',
|
||||
//带客有礼
|
||||
'passenger_switch',
|
||||
//红包
|
||||
'redbag_switch',
|
||||
//满减
|
||||
'reduction_switch',
|
||||
//视频
|
||||
'livevideo_switch',
|
||||
//短视频
|
||||
'shortvideo_switch',
|
||||
//会员
|
||||
'member_switch',
|
||||
// 餐饮
|
||||
'restaurant_switch',
|
||||
// 霸王餐
|
||||
'overlord_switch',
|
||||
// 付费课程
|
||||
'payclass_switch',
|
||||
|
||||
'bargain_switch',
|
||||
|
||||
'question_switch',
|
||||
])->save($input);
|
||||
|
||||
return $this->success($rst);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
$validate = new Cardauth2ConfigValidate();
|
||||
$check = $validate->scene('update')->check($input);
|
||||
if ($check == false) {
|
||||
return $this->error($validate->getError());
|
||||
}
|
||||
|
||||
$m_auth2_config = Cardauth2ConfigModel::where('id', '=', $input['id'])->findOrEmpty();
|
||||
if ($m_auth2_config->isEmpty()) {
|
||||
return $this->error('未找到小程序');
|
||||
}
|
||||
|
||||
clearCache($m_auth2_config['uniacid']);
|
||||
|
||||
$auth_name = Cardauth2ConfigModel::where([['mini_name', '=', $input['mini_name']], ['status', '=', 1],['id','<>',$input['id']]])->find();
|
||||
if(!empty($auth_name)){
|
||||
return $this->error("小程序名字不能重复");
|
||||
}
|
||||
|
||||
/**
|
||||
* @var Cardauth2ConfigModel $m_auth2_config
|
||||
*/
|
||||
$rst = $m_auth2_config->allowField([
|
||||
'agent_id',
|
||||
|
||||
'upload_setting',
|
||||
|
||||
'mini_name',
|
||||
'number',
|
||||
'end_time',
|
||||
'copyright_id',
|
||||
'send_switch',
|
||||
'boos',
|
||||
'appoint',
|
||||
'payqr',
|
||||
'shop_switch',
|
||||
'timeline_switch',
|
||||
'website_switch',
|
||||
'article',
|
||||
'activity_switch',
|
||||
'pay_shop' ,
|
||||
'house_switch',
|
||||
'remark',
|
||||
'closure_switch',
|
||||
//百度
|
||||
'baidu_switch',
|
||||
//带课有礼
|
||||
'passenger_switch',
|
||||
//红包
|
||||
'redbag_switch',
|
||||
//满减
|
||||
'reduction_switch',
|
||||
//视频
|
||||
'livevideo_switch',
|
||||
//短视频
|
||||
'shortvideo_switch',
|
||||
//会员
|
||||
'member_switch',
|
||||
// 餐饮
|
||||
'restaurant_switch',
|
||||
// 霸王餐
|
||||
'overlord_switch',
|
||||
// 付费课程
|
||||
'payclass_switch',
|
||||
|
||||
'bargain_switch',
|
||||
|
||||
'question_switch',
|
||||
])->save($input);
|
||||
|
||||
|
||||
$rst = $rst && $m_auth2_config->cardConfig->save([
|
||||
'uniacid' => $m_auth2_config->modular_id,
|
||||
'update_time' => $m_auth2_config->update_time,
|
||||
'copyright' => "",
|
||||
'mini_app_name' => $m_auth2_config->mini_name,
|
||||
]);
|
||||
|
||||
if ($rst) {
|
||||
return $this->success($m_auth2_config->id);
|
||||
}
|
||||
|
||||
return $this->error('fail');
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function delete()
|
||||
{
|
||||
$input = $this->_input;
|
||||
|
||||
$validate = new Cardauth2ConfigValidate();
|
||||
$check = $validate->scene('delete')->check($input);
|
||||
if ($check == false) {
|
||||
return $this->error($validate->getError());
|
||||
}
|
||||
|
||||
/**
|
||||
* @var Cardauth2ConfigModel $m_auth2_config
|
||||
*/
|
||||
$m_auth2_config = Cardauth2ConfigModel::where('id', '=', $input['id'])->findOrEmpty();
|
||||
if ($m_auth2_config->isEmpty()) {
|
||||
return $this->error('未找到小程序');
|
||||
}
|
||||
$rst = $m_auth2_config->delete();
|
||||
|
||||
if ($rst) {
|
||||
if (!defined('IS_WEIQIN')) {
|
||||
//删除小程序
|
||||
CardConfig::where([['uniacid', '=', $m_auth2_config->modular_id]])->delete();
|
||||
//删除绑定关系
|
||||
AppAdminModel::where([['modular_id', '=', $m_auth2_config->modular_id]])->delete();
|
||||
|
||||
}
|
||||
|
||||
return $this->success($m_auth2_config->id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return $this->error('fail');
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function getWxApp()
|
||||
{
|
||||
if (defined('IS_WEIQIN')) {
|
||||
|
||||
//By.jingshuixian 2020年4月20日15:54:09
|
||||
//解决行业版数据独立的问题
|
||||
//$account_uniacids = Db::name('account')->where([['type', '=', 4], ['isdeleted', '=', 0]])->column('uniacid');
|
||||
//$wxapp = Db::name('account_wxapp')->field(['acid', 'name'])->where([['uniacid', 'IN', $account_uniacids]])->select()->toArray();
|
||||
/*foreach ($wxapp as $k => $item) {
|
||||
$wxapp[$k]['mini_name'] = $item['name'];
|
||||
$wxapp[$k]['modular_id'] = $item['acid'];
|
||||
}*/
|
||||
|
||||
// $a = Db::name('account_wxapp')->select();
|
||||
|
||||
$app_model_name = APP_MODEL_NAME;
|
||||
$m_config = new Cardauth2ConfigModel();
|
||||
$wxapp = Db::name('account')
|
||||
->alias('a')
|
||||
->join('wxapp_versions v' , 'a.uniacid = v.uniacid')
|
||||
->join('account_wxapp account_wxapp' , 'a.uniacid = account_wxapp.uniacid')
|
||||
->field(['account_wxapp.name as mini_name', 'account_wxapp.uniacid as modular_id'])
|
||||
->where([ ['v.modules', 'like', "%".'"'.$app_model_name.'"'."%"] , ['a.type', '=', 4] ,['a.isdeleted', '=', 0] ])
|
||||
->group('a.uniacid')
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
|
||||
return $this->success($wxapp);
|
||||
}else{
|
||||
|
||||
$dis[] = ['uniacid','<>',8888];
|
||||
|
||||
$dis[] = ['status','=',1];
|
||||
|
||||
$dis[] = ['mini_app_name','<>',''];
|
||||
|
||||
$list = CardConfig::field(['mini_app_name' => 'mini_name', 'uniacid' => 'modular_id'])->where($dis)->select()->toArray();
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function isWe7()
|
||||
{
|
||||
$is_we7 = defined('IS_WEIQIN');
|
||||
|
||||
return $this->success($is_we7);
|
||||
}
|
||||
|
||||
|
||||
public function redirectAppBackgroundToken()
|
||||
{
|
||||
if (defined('IS_WEIQIN')) {
|
||||
return $this->error('微擎用户禁止访问');
|
||||
};
|
||||
|
||||
$modular_id = $this->_input['modular_id'];
|
||||
|
||||
$user = [
|
||||
'admin_id' => $this->_user['admin_id'],
|
||||
'account'=> $this->_user['account'],
|
||||
'role' => $this->_user['role'],
|
||||
'role_name' => $this->_user['role_name'],
|
||||
'uniacid' => $modular_id,
|
||||
];
|
||||
|
||||
$result['user'] = $user;
|
||||
$result['token'] = createToken();
|
||||
if (empty($result['token'])) {
|
||||
return $this->error('System is busy,please try again later.', 400);
|
||||
}
|
||||
//添加缓存数据
|
||||
setUserForToken($result['token'], $user);
|
||||
return $this->success($result, 200);
|
||||
|
||||
}
|
||||
|
||||
//站点绑定
|
||||
public function websitebind()
|
||||
{
|
||||
$type = $this->_input['type'] ?? null;
|
||||
if (!in_array($type, ['get', 'post'])) {
|
||||
return $this->error(lang('param error'));
|
||||
}
|
||||
|
||||
$version_id = longbingGetBranchVersionId();
|
||||
$branch_id = longbingGetBranchId();
|
||||
$version_name = longbingGetBranchVersionName();
|
||||
|
||||
$domain_name = $_SERVER['HTTP_HOST'];
|
||||
$server_url = longbingGetSaasUrl();//接口地址
|
||||
|
||||
$bindInfo = longbingGetWebSiteBingData();
|
||||
|
||||
|
||||
if ($type == 'get') {
|
||||
$data = array(
|
||||
'version_id' => $version_id,
|
||||
'branch_id' => $branch_id,
|
||||
'version_name' => $version_name,
|
||||
'domain_name' => $domain_name,
|
||||
);
|
||||
//获取最新版本
|
||||
if(!empty($bindInfo))
|
||||
{
|
||||
//检查数据是否存在
|
||||
if(empty($bindInfo) || empty($bindInfo['website_keys']) || empty($bindInfo['website_keys']) || empty($bindInfo['domain_keys'])) {
|
||||
$data['newest_version_name'] = $data['version_name'];
|
||||
$data['website_keys'] = '';
|
||||
}else{
|
||||
$data['website_keys'] = $bindInfo['website_keys'];
|
||||
//获取最新的版本信息
|
||||
$new_branch = json_decode($this->lb_api_notice_increment_we7($server_url.'/app_version/'.$branch_id,null,['Accept-Charset:utf-8','Origin:'.$bindInfo['domain_name'],'Referer:'.$bindInfo['domain_name']],'GET'),true);
|
||||
|
||||
if(empty($new_branch) || !isset($new_branch['result']['data']) || empty($new_branch['result']['data']) || isset($new_branch['error']) || in_array($new_branch['result']['data']['version_id'], [$version_id]))
|
||||
{
|
||||
$data['newest_version_name'] = $data['version_name'];
|
||||
$data['newest_version_id'] = $data['version_id'];
|
||||
}else{
|
||||
$data['newest_version_id'] = $new_branch['result']['data']['version_id'];
|
||||
$data['newest_version_name'] = $new_branch['result']['data']['version_name'];
|
||||
}
|
||||
}
|
||||
}
|
||||
return $this->success($data);
|
||||
|
||||
} else {
|
||||
if (isset($bindInfo['website_keys']) && $bindInfo['website_keys'] ) {
|
||||
return $this->error('已经绑定过了, 无需重复绑定');
|
||||
}
|
||||
$website_key = $this->_input['website_keys'] ?? null;
|
||||
if ($type == 'post' && $website_key == null) {
|
||||
return $this->error('请输入密钥');
|
||||
}
|
||||
|
||||
$res = json_decode(($this->lb_api_notice_increment_we7($server_url . '/website/check?keys=' . $website_key, [], ['Accept-Charset:utf-8', 'Origin:' . $domain_name], 'GET')), true);
|
||||
|
||||
if (isset($res['error'])) {
|
||||
return $this->error($res['error']['message']);
|
||||
}
|
||||
$data = $res['result']['data'];
|
||||
|
||||
|
||||
$save_data = [
|
||||
'domain_name' => $domain_name,
|
||||
'domain_keys' => json_encode($data['domain_keys'], true),
|
||||
'domain_id' => $data['domain_id'],
|
||||
'website_id' => $data['website_id'],
|
||||
'website_keys' => $website_key,
|
||||
];
|
||||
if(empty($bindInfo))
|
||||
{
|
||||
$result = Db::name('lb_pluge_key')->save($save_data);
|
||||
}else{
|
||||
$result = Db::name('lb_pluge_key')->where('id', '=', $bindInfo['id'])->update($save_data);
|
||||
}
|
||||
|
||||
|
||||
if ($result === false) {
|
||||
return $this->error(lang('faild'));
|
||||
}
|
||||
}
|
||||
|
||||
return $this->success(true);
|
||||
}
|
||||
/**
|
||||
* 更新程序
|
||||
* @author yangqi
|
||||
*/
|
||||
public function updateApp()
|
||||
{
|
||||
if(longbingIsWeiqin()) return $this->error(lang('not need update'));
|
||||
//app 识别号
|
||||
$branch_id = longbingGetBranchId();
|
||||
//version_id
|
||||
$version_id = longbingGetBranchVersionId();
|
||||
//获取saas url
|
||||
$server_url = longbingGetSaasUrl();
|
||||
|
||||
if(empty($branch_id) || empty($version_id) || empty($server_url)) return $this->error(lang('not need update'));
|
||||
|
||||
//获取站点绑定信息
|
||||
$bing_data = longbingGetWebSiteBingData();
|
||||
//检查数据是否存在
|
||||
if(empty($bing_data) || empty($bing_data['website_keys']) || empty($bing_data['website_keys']) || empty($bing_data['domain_keys'])) return $this->error(lang('webiste not bing.'));
|
||||
//获取最新的版本信息
|
||||
$new_branch = json_decode($this->lb_api_notice_increment_we7($server_url.'/app_version/'.$branch_id,null,['Accept-Charset:utf-8','Origin:'.$bing_data['domain_name'],'Referer:'.$bing_data['domain_name']],'GET'),true);
|
||||
|
||||
if(empty($new_branch) || !isset($new_branch['result']['data']) || empty($new_branch['result']['data']) || isset($new_branch['error']) || in_array($new_branch['result']['data']['version_id'], [$version_id])) return $this->error(lang('not need update'));
|
||||
// $version_id = $new_branch['result']['data']['version_id'];
|
||||
//获取加密秘钥
|
||||
$keys = $bing_data['domain_keys'];
|
||||
$keys = json_decode($keys ,true);
|
||||
|
||||
$signModel=new Rsa2Sign($keys);
|
||||
//生成查询条件
|
||||
$data =["branch_id"=>$branch_id ,"version_id"=>$version_id];
|
||||
//机密数据
|
||||
$sign=$signModel->createSign(json_encode($data,true));
|
||||
// 授权检查
|
||||
$res= json_decode($this->lb_api_notice_increment_we7($server_url.'/authorization?sign='.$sign,json_encode(["authorization"=>$data]),['Accept-Charset:utf-8','Origin:'.$bing_data['domain_name'],'Referer:'.$bing_data['domain_name']],'POST'),true);
|
||||
|
||||
//接口结果 判断是否成功
|
||||
if(isset($res['error'])){
|
||||
return $this->error(lang($res['error']['message']));
|
||||
}
|
||||
//获取更新数据url
|
||||
$down_load_url=isset($res['result']['data']['backstage_url']) && $res['result']['data']['backstage_url'] ? $res['result']['data']['backstage_url'] : '';
|
||||
if(!$down_load_url){
|
||||
//无需更新
|
||||
return $this->returnSuccess(['code'=>-1],'无需更新');
|
||||
}
|
||||
//模块名称(目录名称)
|
||||
$model_name=isset($res['result']['data']['model_name']) ? $res['result']['data']['model_name']: '';
|
||||
$version_id=isset($res['result']['data']['version_id']) ? $res['result']['data']['version_id']: '';
|
||||
$version_name =isset($res['result']['data']['version_name']) ? $res['result']['data']['version_name']: '';
|
||||
$file_name = isset($res['result']['data']['backstage_name']) ? $res['result']['data']['backstage_name']: '';
|
||||
//下载覆盖文件
|
||||
$save_dir=ROOT_PATH . 'temp';
|
||||
$cp_dir=ROOT_PATH ;
|
||||
|
||||
//更新文件
|
||||
if(longbingUpdateAppFile($down_load_url,$save_dir ,$file_name,$cp_dir)){
|
||||
//是否有更新数据库
|
||||
if($model_name && file_exists(APP_PATH.$model_name.'/upgrade.php')){
|
||||
$sql_all='';//更新数据库
|
||||
require_once APP_PATH.$model_name.'/upgrade.php';
|
||||
}
|
||||
//写入最新版本
|
||||
$data=[
|
||||
// 'uniacid' => $uniacid,
|
||||
'version_id' => $version_id,
|
||||
'branch_id' => $branch_id,
|
||||
'version_name' => $version_name
|
||||
];
|
||||
$data = longbingGetWebSiteBingData(['id' => $bing_data['id']] ,$data);
|
||||
return $this->success(lang('update success'));
|
||||
}else{
|
||||
return $this->success(lang('update error'));
|
||||
}
|
||||
}
|
||||
|
||||
private function lb_api_notice_increment_we7 ( $url, $data, $headers = [ 'Accept-Charset:utf-8' ], $request_type = 'POST' )
|
||||
{
|
||||
$ch = curl_init();
|
||||
// $header = "Accept-Charset: utf-8";
|
||||
curl_setopt( $ch, CURLOPT_URL, $url );
|
||||
//设置头文件的信息作为数据流输出
|
||||
curl_setopt( $ch, CURLOPT_HEADER, 0 );
|
||||
curl_setopt( $ch, CURLOPT_HTTPHEADER, $headers );
|
||||
curl_setopt( $ch, CURLOPT_CUSTOMREQUEST, $request_type );
|
||||
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );
|
||||
curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, FALSE );
|
||||
curl_setopt( $ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; MSIE 5.01; Windows NT 5.0)' );
|
||||
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1 );
|
||||
curl_setopt( $ch, CURLOPT_AUTOREFERER, 1 );
|
||||
curl_setopt( $ch, CURLOPT_POSTFIELDS, $data );
|
||||
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
|
||||
$tmpInfo = curl_exec( $ch );
|
||||
// var_dump($tmpInfo);
|
||||
// exit;
|
||||
if ( curl_errno( $ch ) ) {
|
||||
return false;
|
||||
} else {
|
||||
// var_dump($tmpInfo);
|
||||
return $tmpInfo;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
128
app/agent/controller/AppUpgrade.php
Executable file
128
app/agent/controller/AppUpgrade.php
Executable file
@@ -0,0 +1,128 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | Longbing [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright Chengdu longbing Technology Co., Ltd.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Website http://longbing.org/
|
||||
// +----------------------------------------------------------------------
|
||||
// | Sales manager: +86-13558882532 / +86-13330887474
|
||||
// | Technical support: +86-15680635005
|
||||
// | After-sale service: +86-17361005938
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\agent\controller;
|
||||
|
||||
|
||||
include_once LONGBING_EXTEND_PATH . 'LongbingUpgrade.php';
|
||||
|
||||
use app\admin\model\WxUpload;
|
||||
use app\admin\service\UpdateService;
|
||||
use app\AgentRest;
|
||||
use app\diy\service\DiyService;
|
||||
use LongbingUpgrade;
|
||||
use think\facade\Env;
|
||||
|
||||
class AppUpgrade extends AgentRest
|
||||
{
|
||||
|
||||
/**
|
||||
* @author jingshuixian
|
||||
* @DataTime: 2020-06-08 9:33
|
||||
* @功能说明: 获得升级信息
|
||||
*/
|
||||
public function getUpgradeInfo(){
|
||||
|
||||
$goods_name = config('app.AdminModelList')['app_model_name'];
|
||||
|
||||
$auth_uniacid = config('app.AdminModelList')['auth_uniacid'];
|
||||
|
||||
$version_no = config('app.AdminModelList')['version_no'];
|
||||
|
||||
$upgrade = new LongbingUpgrade($auth_uniacid , $goods_name , Env::get('j2hACuPrlohF9BvFsgatvaNFQxCBCc' , false));
|
||||
|
||||
$data = $upgrade->checkAuth();
|
||||
|
||||
$data['location_version_no'] = $version_no ;
|
||||
|
||||
$data['is_upgrade'] = $this->getIsUpgrade();
|
||||
|
||||
$this->update();
|
||||
|
||||
return $this->success( $data );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* By.jingshuixian
|
||||
* 2019年11月23日21:43:47
|
||||
* 升级脚本导入执行
|
||||
*/
|
||||
public function update(){
|
||||
|
||||
$key = 'init_all_data';
|
||||
|
||||
setCache($key,'',7200,$this->_uniacid);
|
||||
|
||||
UpdateService::installSql($this->_uniacid);
|
||||
|
||||
UpdateService::initWeiqinConfigData();
|
||||
|
||||
DiyService::addDefaultDiyData($this->_uniacid);
|
||||
//各个模块初始化数据事件
|
||||
event('InitModelData');
|
||||
//处理雷达
|
||||
lbInitRadarMsg($this->_uniacid);
|
||||
|
||||
return $this->success([]);
|
||||
|
||||
}
|
||||
/**
|
||||
* @author jingshuixian
|
||||
* @DataTime: 2020-06-08 18:04
|
||||
* @功能说明: 判断是否有升级权限
|
||||
*/
|
||||
private function getIsUpgrade(){
|
||||
|
||||
$goods_name = config('app.AdminModelList')['app_model_name'];
|
||||
|
||||
if(($goods_name == 'longbing_card')||!longbingIsWeiqin()){
|
||||
|
||||
return true;
|
||||
|
||||
}else{
|
||||
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author jingshuixian
|
||||
* @DataTime: 2020-06-08 14:43
|
||||
* @功能说明: 升级后台系统
|
||||
*/
|
||||
public function upgrade(){
|
||||
|
||||
if($this->getIsUpgrade()){
|
||||
$goods_name = config('app.AdminModelList')['app_model_name'];
|
||||
$auth_uniacid = config('app.AdminModelList')['auth_uniacid'];
|
||||
$version_no = config('app.AdminModelList')['version_no'];
|
||||
|
||||
$upgrade = new LongbingUpgrade($auth_uniacid , $goods_name , Env::get('j2hACuPrlohF9BvFsgatvaNFQxCBCc' , false));
|
||||
|
||||
$file_temp_path = ROOT_PATH . "runtime/" ;
|
||||
$toFilePath = ROOT_PATH ;
|
||||
// 自动下载文件到 core/runtime 解压到 core/ 根目是thinkphp所在目录
|
||||
$data = $upgrade->update( $toFilePath ,$file_temp_path );
|
||||
|
||||
return $this->success( $data );
|
||||
}else{
|
||||
return $this->success( [] );
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
171
app/agent/controller/AritcleController.php
Executable file
171
app/agent/controller/AritcleController.php
Executable file
@@ -0,0 +1,171 @@
|
||||
<?php
|
||||
namespace app\agent\controller;
|
||||
|
||||
use app\agent\service\AdminUserService;
|
||||
use think\App;
|
||||
use app\agent\model\Cardauth2ArticleModel;
|
||||
use app\AgentRest;
|
||||
use app\agent\validate\Cardauth2ArticleValidate;
|
||||
use think\facade\Db;
|
||||
|
||||
class AritcleController extends AgentRest
|
||||
{
|
||||
|
||||
public function __construct ( App $app ){
|
||||
parent::__construct( $app );
|
||||
if ($this->_user['role_name'] != 'admin') {
|
||||
echo json_encode(['code' => 401, 'error' => lang('Permission denied')]);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
public function list()
|
||||
{
|
||||
$param = $this->_param;
|
||||
$m_article_auth2 = new Cardauth2ArticleModel();
|
||||
|
||||
//By.jingshuixian 2020年4月21日15:13:50
|
||||
//区分行业版数据
|
||||
|
||||
if($this->_is_weiqin){
|
||||
|
||||
$app_model_name = APP_MODEL_NAME;
|
||||
$list = $m_article_auth2->alias('a')
|
||||
->field(['a.id', 'a.modular_id', 'a.number', 'a. create_time', 'c.autograph', 'c.signature', 'c.mini_app_name'])
|
||||
->join('longbing_card_config c', 'a.modular_id = c.uniacid')
|
||||
->join('account' , 'a.modular_id = account.uniacid')
|
||||
->join('wxapp_versions v' , 'a.modular_id = v.uniacid')
|
||||
->group('a.modular_id')
|
||||
->where([['a.status', '=', 1] , ['account.type', '=', 4] ,['account.isdeleted', '=', 0] , ['v.modules', 'like', "%{$app_model_name}%"]])
|
||||
->paginate(['list_rows' => $param['page_count'] ? $param['page_count'] : 10, 'page' => $param['page'] ? $param['page'] : 1])->toArray();
|
||||
|
||||
}else{
|
||||
|
||||
$list = $m_article_auth2->alias('a')
|
||||
->field(['a.id', 'a.modular_id', 'a.number', 'a. create_time', 'c.autograph', 'c.signature', 'c.mini_app_name'])
|
||||
->join('longbing_card_config c', 'a.modular_id = c.uniacid')
|
||||
->where([['a.status', '=', 1]])
|
||||
->paginate(['list_rows' => $param['page_count'] ? $param['page_count'] : 10, 'page' => $param['page'] ? $param['page'] : 1])->toArray();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
$wxapp_map = [];
|
||||
$wxapp = Db::name('account_wxapp')->field(['uniacid', 'name'])->select();
|
||||
foreach ($wxapp as $item) {
|
||||
$wxapp_map[$item['uniacid']] = $item['name'];
|
||||
}
|
||||
|
||||
foreach ($list['data'] as $k => $item) {
|
||||
$list['data'][$k]['used'] = $item['signature'];
|
||||
$list['data'][$k]['left'] = $item['number'] - $item['signature'];
|
||||
$list['data'][$k]['name'] = $wxapp_map[$item['modular_id']] ?? $item['mini_app_name'];
|
||||
unset($list['data'][$k]['signature'], $list['data'][$k]['autograph'], $list['data'][$k]['mini_app_name']);
|
||||
}
|
||||
//授权数量
|
||||
$list['total_article_number'] = AdminUserService::getSassNum('article',$this->_uniacid);
|
||||
//使用数量
|
||||
$list['total_article_used'] = (int)$m_article_auth2->where([['uniacid','in',$this->_uniacid_arr]])->sum('number');
|
||||
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
|
||||
public function create()
|
||||
{
|
||||
|
||||
$data = $this->_input;
|
||||
|
||||
$validate = new Cardauth2ArticleValidate();
|
||||
|
||||
$check = $validate->scene('create')->check($data);
|
||||
if ($check == false) {
|
||||
return $this->error($validate->getError());
|
||||
}
|
||||
|
||||
$time = time();
|
||||
$auth_article = Cardauth2ArticleModel::where([['modular_id', '=', $data['modular_id']]])->findOrEmpty();
|
||||
|
||||
if (!$auth_article->isEmpty()) {
|
||||
return $this->error('已存在此小程序');
|
||||
}
|
||||
|
||||
$total_article_number = AdminUserService::getSassNum('article',$this->_uniacid);
|
||||
|
||||
$total_article_used = (int)$auth_article->where([['uniacid','in',$this->_uniacid_arr]])->sum('number');
|
||||
|
||||
$remain = $total_article_number - $total_article_used - $data['number'];
|
||||
|
||||
if ($remain < 0) {
|
||||
return $this->error('分配的超过可用的总数');
|
||||
}
|
||||
|
||||
$rst = $auth_article->save([
|
||||
'modular_id' => $data[ 'modular_id' ],
|
||||
'number' => $data[ 'number' ],
|
||||
'create_time' => $time,
|
||||
'update_time' => $time,
|
||||
'uniacid' => $this->_uniacid,
|
||||
]);
|
||||
|
||||
$auth_article->cardConfig->save(['autograph' => $data['number'] + 80666]);
|
||||
|
||||
|
||||
if ($rst) {
|
||||
return $this->success('success');
|
||||
}
|
||||
|
||||
|
||||
return $this->error('fail');
|
||||
}
|
||||
|
||||
|
||||
public function update()
|
||||
{
|
||||
$data = $this->_input;
|
||||
|
||||
$validate = new Cardauth2ArticleValidate();
|
||||
$check = $validate->scene('create')->check($data);
|
||||
if ($check == false) {
|
||||
return $this->error($validate->getError());
|
||||
}
|
||||
|
||||
|
||||
$auth_article = Cardauth2ArticleModel::where([['modular_id', '=', $data['modular_id']]])->findOrEmpty();
|
||||
if ($auth_article->isEmpty()) {
|
||||
return $this->error('小程序不存在');
|
||||
}
|
||||
|
||||
|
||||
$old_number = $auth_article['number'];
|
||||
$new_numer = $data['number'];
|
||||
if ($old_number > $new_numer) {
|
||||
return $this->error('不能减少授权数量');
|
||||
}
|
||||
|
||||
|
||||
$total_article_number = AdminUserService::getSassNum('article',$this->_uniacid);
|
||||
|
||||
$total_article_used = (int)$auth_article->where([['uniacid','in',$this->_uniacid_arr]])->sum('number') - $old_number + $new_numer;
|
||||
$remain = $total_article_number - $total_article_used;
|
||||
if ($remain < 0) {
|
||||
return $this->error('分配的数量超过可用的总数');
|
||||
}
|
||||
|
||||
|
||||
$time = time();
|
||||
$rst = $auth_article->save([
|
||||
'number' => $new_numer,
|
||||
'update_time' => $time,
|
||||
]);
|
||||
$auth_article->cardConfig->save(['autograph' => $data['number'] + 80666]);
|
||||
|
||||
if ($rst) {
|
||||
return $this->success('success');
|
||||
}
|
||||
|
||||
|
||||
return $this->error('fail');
|
||||
}
|
||||
|
||||
}
|
||||
149
app/agent/controller/BossController.php
Executable file
149
app/agent/controller/BossController.php
Executable file
@@ -0,0 +1,149 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\agent\controller;
|
||||
|
||||
use app\agent\service\AdminUserService;
|
||||
use think\App;
|
||||
use app\AdminRest;
|
||||
use app\agent\model\Cardauth2BossModel;
|
||||
use app\AgentRest;
|
||||
use think\facade\Db;
|
||||
|
||||
class BossController extends AgentRest
|
||||
{
|
||||
|
||||
public function __construct ( App $app ){
|
||||
parent::__construct( $app );
|
||||
if ($this->_user['role_name'] != 'admin') {
|
||||
echo json_encode(['code' => 401, 'error' => lang('Permission denied')]);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
public function list()
|
||||
{
|
||||
$param = $this->_param;
|
||||
$m_boss_auth2 = new Cardauth2BossModel();
|
||||
|
||||
//By.jingshuixian 2020年4月21日15:13:50
|
||||
//区分行业版数据
|
||||
|
||||
//获取列表
|
||||
if($this->_is_weiqin){
|
||||
$app_model_name = APP_MODEL_NAME;
|
||||
$list = $m_boss_auth2->alias('a')
|
||||
->field(['a.id', 'a.modular_id', 'a. create_time', 'a.sign', 'c.mini_app_name'])
|
||||
->join('longbing_card_config c', 'a.modular_id = c.uniacid')
|
||||
->join('account' , 'a.modular_id = account.uniacid')
|
||||
->join('wxapp_versions v' , 'a.modular_id = v.uniacid')
|
||||
->where([['a.status', '=', 1] , ['account.type', '=', 4] ,['account.isdeleted', '=', 0] , ['v.modules', 'like', "%{$app_model_name}%"] ])
|
||||
->group('a.modular_id')
|
||||
->paginate(['list_rows' => $param['page_count'] ? $param['page_count'] : 10, 'page' => $param['page'] ? $param['page'] : 1])->toArray();
|
||||
|
||||
|
||||
}else{
|
||||
$list = $m_boss_auth2->alias('a')
|
||||
->field(['a.id', 'a.modular_id', 'a. create_time', 'a.sign', 'c.mini_app_name'])
|
||||
->join('longbing_card_config c', 'a.modular_id = c.uniacid')
|
||||
->where([['a.status', '=', 1]])
|
||||
->paginate(['list_rows' => $param['page_count'] ? $param['page_count'] : 10, 'page' => $param['page'] ? $param['page'] : 1])->toArray();
|
||||
}
|
||||
|
||||
$wxapp_map = [];
|
||||
$wxapp = Db::name('account_wxapp')->field(['uniacid', 'name'])->select();
|
||||
foreach ($wxapp as $item) {
|
||||
$wxapp_map[$item['uniacid']] = $item['name'];
|
||||
}
|
||||
|
||||
foreach ($list['data'] as $k => $item) {
|
||||
$list['data'][$k]['name'] = $wxapp_map[$item['modular_id']] ?? $item['mini_app_name'];
|
||||
unset($list['data'][$k]['mini_app_name']);
|
||||
}
|
||||
|
||||
//授权数量
|
||||
$list['total_house_number'] = AdminUserService::getSassNum('boss',$this->_uniacid);
|
||||
//使用数量
|
||||
$list['total_house_used'] = $m_boss_auth2->where([['uniacid','in',$this->_uniacid_arr]])->sum('count');
|
||||
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
|
||||
public function create()
|
||||
{
|
||||
$data = $this->_input;
|
||||
if (!isset($data['modular_id'])) {
|
||||
return $this->success('参数错误');
|
||||
}
|
||||
|
||||
$time = time();
|
||||
$auth_boss = Cardauth2BossModel::where([['modular_id', '=', $data['modular_id']]])->findOrEmpty();
|
||||
|
||||
if (!$auth_boss->isEmpty()) {
|
||||
return $this->error('已存在此小程序');
|
||||
}
|
||||
|
||||
$total_boss_number = AdminUserService::getSassNum('boss',$this->_uniacid);
|
||||
|
||||
$total_boss_used = $auth_boss->where([['uniacid','in',$this->_uniacid_arr]])->sum('count');
|
||||
|
||||
$remain = $total_boss_number - $total_boss_used;
|
||||
if ($remain <= 0) {
|
||||
return $this->error('分配的数量超过可用的总数');
|
||||
}
|
||||
|
||||
$rst = $auth_boss->save([
|
||||
'modular_id' => $data[ 'modular_id' ],
|
||||
'create_time' => $time,
|
||||
'update_time' => $time,
|
||||
'sign' => intval( $time + ( 366 * 24 * 60 * 60 ) ),
|
||||
'count' => 1,
|
||||
'uniacid' => $this->_uniacid,
|
||||
]);
|
||||
|
||||
if ($rst) {
|
||||
return $this->success('success');
|
||||
}
|
||||
|
||||
return $this->error('fail');
|
||||
}
|
||||
|
||||
|
||||
public function extendedOneYear ()
|
||||
{
|
||||
$data = $this->_input;
|
||||
if (!isset($data['modular_id'])) {
|
||||
return $this->success('参数错误');
|
||||
}
|
||||
|
||||
$time = time();
|
||||
$auth_boss = Cardauth2BossModel::where([['modular_id', '=', $data['modular_id']]])->findOrEmpty();
|
||||
|
||||
if ($auth_boss->isEmpty()) {
|
||||
return $this->error('小程序不存在');
|
||||
}
|
||||
|
||||
$total_boss_number = AdminUserService::getSassNum('boss',$this->_uniacid);
|
||||
|
||||
$total_boss_used = $auth_boss->where([['uniacid','in',$this->_uniacid_arr]])->sum('count');
|
||||
$remain = $total_boss_number - $total_boss_used;
|
||||
if ($remain <= 0) {
|
||||
return $this->error('分配的数量超过可用的总数');
|
||||
}
|
||||
|
||||
$rst = $auth_boss->save([
|
||||
'sign' => $auth_boss[ 'sign' ] > $time ? ($auth_boss[ 'sign' ] + ( 366 * 24 * 60 * 60 )) : ( $time + ( 366 * 24 * 60 * 60 ) ),
|
||||
'count' => $auth_boss['count'] + 1,
|
||||
'update_time' => $time,
|
||||
]);
|
||||
|
||||
|
||||
if ($rst) {
|
||||
return $this->success('success');
|
||||
}
|
||||
|
||||
|
||||
return $this->error('fail');
|
||||
}
|
||||
|
||||
}
|
||||
62
app/agent/controller/ConfigDefault.php
Executable file
62
app/agent/controller/ConfigDefault.php
Executable file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
namespace app\agent\controller;
|
||||
|
||||
use think\App;
|
||||
use app\AdminRest;
|
||||
use app\agent\model\Cardauth2DefaultModel;
|
||||
use app\AgentRest;
|
||||
use think\Validate;
|
||||
|
||||
class ConfigDefault extends AgentRest
|
||||
{
|
||||
public function __construct ( App $app ){
|
||||
parent::__construct( $app );
|
||||
if ($this->_user['role_name'] != 'admin') {
|
||||
echo json_encode(['code' => 401, 'error' => lang('Permission denied')]);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
public function getOne()
|
||||
{
|
||||
$default = Cardauth2DefaultModel::order('id', 'desc')->limit(1)->select();
|
||||
|
||||
if (!isset($default[0])) {
|
||||
$default = new Cardauth2DefaultModel();
|
||||
$default->uniacid = $this->_uniacid;
|
||||
$default->card_number = 0;
|
||||
$default->send_switch = 0;
|
||||
$default->save();
|
||||
return $this->success($default);
|
||||
}
|
||||
return $this->success($default[0]->toArray());
|
||||
}
|
||||
|
||||
|
||||
public function update()
|
||||
{
|
||||
|
||||
$input = $this->_input;
|
||||
$validate = new Validate();
|
||||
$validate->rule([
|
||||
'card_number|名片数量' => 'require|number|egt:0',
|
||||
'send_switch|短信群发' => 'require|number|in:0,1',
|
||||
]);
|
||||
|
||||
if (!$validate->check($input)) {
|
||||
return $this->error($validate->getError());
|
||||
}
|
||||
|
||||
|
||||
$default = Cardauth2DefaultModel::order('id', 'desc')->limit(1)->select();
|
||||
if (!$default) {
|
||||
$default->card_number = $input['card_number'] ;
|
||||
$default->send_switch = $input['send_switch'] ;
|
||||
$default->save();
|
||||
}
|
||||
$default[0]->card_number = $input['card_number'] ;
|
||||
$default[0]->send_switch = $input['send_switch'] ;
|
||||
$default[0]->save();
|
||||
|
||||
return $this->success('success');
|
||||
}
|
||||
}
|
||||
108
app/agent/controller/CopyRightAgentController.php
Executable file
108
app/agent/controller/CopyRightAgentController.php
Executable file
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
namespace app\agent\controller;
|
||||
|
||||
use app\agent\model\Cardauth2ConfigModel;
|
||||
use think\App;
|
||||
use app\agent\model\Cardauth2CopyrightModel;
|
||||
use app\AgentRest;
|
||||
use app\agent\validate\CopyRightAgentValidate;
|
||||
|
||||
class CopyRightAgentController extends AgentRest
|
||||
{
|
||||
public function __construct ( App $app ){
|
||||
parent::__construct( $app );
|
||||
if ($this->_user['role_name'] != 'admin') {
|
||||
echo json_encode(['code' => 401, 'error' => lang('Permission denied')]);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
public function list()
|
||||
{
|
||||
|
||||
$param= $this->_param;
|
||||
|
||||
$list = Cardauth2CopyrightModel::where([['status', '=', 1],['uniacid','in',$this->_uniacid_arr]])
|
||||
->paginate(['list_rows' => $param['page_count'] ? $param['page_count'] : 10, 'page' => $param['page'] ? $param['page'] : 1])
|
||||
->toArray();
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
public function getAll()
|
||||
{
|
||||
$list = Cardauth2CopyrightModel::field(['id', 'name'])->where([['status', '=', 1],['uniacid','in',$this->_uniacid_arr]])->select()
|
||||
->toArray();
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
|
||||
public function create()
|
||||
{
|
||||
$data = $this->_input;
|
||||
$validate = new CopyRightAgentValidate();
|
||||
$check = $validate->scene('create')->check($data);
|
||||
if ($check == false) {
|
||||
return $this->error($validate->getError());
|
||||
}
|
||||
|
||||
$data['uniacid'] = $this->_uniacid;
|
||||
|
||||
$m = new Cardauth2CopyrightModel();
|
||||
$m->data($data, true, ['name', 'image', 'text', 'phone', 'uniacid']);
|
||||
if ($m->save()) {
|
||||
$id = $m->id;
|
||||
return $this->success($id);
|
||||
}
|
||||
return $this->error('fail');
|
||||
}
|
||||
|
||||
|
||||
public function update()
|
||||
{
|
||||
$data = $this->_input;
|
||||
$validate = new CopyRightAgentValidate();
|
||||
$check = $validate->scene('update')->check($data);
|
||||
if ($check == false) {
|
||||
return $this->error($validate->getError());
|
||||
}
|
||||
|
||||
$copyRight = Cardauth2CopyrightModel::find($data['id']);
|
||||
if (!$copyRight) {
|
||||
return $this->error('系统错误');
|
||||
}
|
||||
|
||||
if ($copyRight->allowField(['name', 'image', 'text', 'phone'])->save($data)) {
|
||||
return $this->success('success');
|
||||
};
|
||||
return $this->error('fail');
|
||||
}
|
||||
|
||||
|
||||
public function get()
|
||||
{
|
||||
$copyRight = Cardauth2CopyrightModel::find($this->_param['id']);
|
||||
return $this->success($copyRight);
|
||||
}
|
||||
|
||||
public function destroy()
|
||||
{
|
||||
$validate = new CopyRightAgentValidate();
|
||||
$check = $validate->scene('destroy')->check($this->_input);
|
||||
if ($check == false) {
|
||||
return $this->error($validate->getError());
|
||||
}
|
||||
$m_config = new Cardauth2ConfigModel();
|
||||
|
||||
$auth_config = $m_config->where(['copyright_id'=>$this->_input['id']])->find();
|
||||
if(!empty($auth_config)){
|
||||
return $this->error('This copyright is in use and cannot be deleted');
|
||||
}
|
||||
|
||||
$rst = Cardauth2CopyrightModel::destroy(function ($query) {
|
||||
$query->where('id', '=', $this->_input['id'] ?? 0);
|
||||
});
|
||||
|
||||
return $this->success($rst);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
148
app/agent/controller/HouseController.php
Executable file
148
app/agent/controller/HouseController.php
Executable file
@@ -0,0 +1,148 @@
|
||||
<?php
|
||||
namespace app\agent\controller;
|
||||
|
||||
use app\agent\service\AdminUserService;
|
||||
use think\App;
|
||||
use app\AdminRest;
|
||||
use app\agent\model\Cardauth2HouseModel;
|
||||
use app\AgentRest;
|
||||
use think\facade\Db;
|
||||
|
||||
class HouseController extends AgentRest
|
||||
{
|
||||
public function __construct ( App $app ){
|
||||
parent::__construct( $app );
|
||||
if ($this->_user['role_name'] != 'admin') {
|
||||
echo json_encode(['code' => 401, 'error' => lang('Permission denied')]);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function list()
|
||||
{
|
||||
$param = $this->_param;
|
||||
$m_house_auth2 = new Cardauth2HouseModel();
|
||||
|
||||
//By.jingshuixian 2020年4月21日15:13:50
|
||||
//区分行业版数据
|
||||
|
||||
//获取列表
|
||||
if($this->_is_weiqin) {
|
||||
$app_model_name = APP_MODEL_NAME;
|
||||
$list = $m_house_auth2->alias('a')
|
||||
->field(['a.id', 'a.modular_id', 'a. create_time', 'a.sign', 'c.mini_app_name'])
|
||||
->join('longbing_card_config c', 'a.modular_id = c.uniacid')
|
||||
|
||||
->join('account' , 'a.modular_id = account.uniacid')
|
||||
->join('wxapp_versions v' , 'a.modular_id = v.uniacid')
|
||||
|
||||
->where([ ['a.status', '=', 1] , ['account.type', '=', 4] ,['account.isdeleted', '=', 0] , ['v.modules', 'like', "%{$app_model_name}%"] ])
|
||||
->group('a.modular_id')
|
||||
->paginate(['list_rows' => $param['page_count'] ? $param['page_count'] : 10, 'page' => $param['page'] ? $param['page'] : 1])->toArray();
|
||||
|
||||
}else{
|
||||
$list = $m_house_auth2->alias('a')
|
||||
->field(['a.id', 'a.modular_id', 'a. create_time', 'a.sign', 'c.mini_app_name'])
|
||||
->join('longbing_card_config c', 'a.modular_id = c.uniacid')
|
||||
->where([['a.status', '=', 1]])
|
||||
->paginate(['list_rows' => $param['page_count'] ? $param['page_count'] : 10, 'page' => $param['page'] ? $param['page'] : 1])->toArray();
|
||||
}
|
||||
|
||||
|
||||
|
||||
$wxapp_map = [];
|
||||
$wxapp = Db::name('account_wxapp')->field(['uniacid', 'name'])->select();
|
||||
foreach ($wxapp as $item) {
|
||||
$wxapp_map[$item['uniacid']] = $item['name'];
|
||||
}
|
||||
|
||||
foreach ($list['data'] as $k => $item) {
|
||||
$list['data'][$k]['name'] = $wxapp_map[$item['modular_id']] ?? $item['mini_app_name'];
|
||||
unset($list['data'][$k]['mini_app_name']);
|
||||
}
|
||||
|
||||
|
||||
$list['total_house_number'] = AdminUserService::getSassNum('house',$this->_uniacid);
|
||||
|
||||
$list['total_house_used'] = $m_house_auth2->where([['uniacid','in',$this->_uniacid_arr]])->sum('count');
|
||||
return $this->success($list);
|
||||
}
|
||||
|
||||
|
||||
public function create()
|
||||
{
|
||||
$data = $this->_input;
|
||||
if (!isset($data['modular_id'])) {
|
||||
return $this->success('参数错误');
|
||||
}
|
||||
|
||||
$time = time();
|
||||
$auth_house = Cardauth2HouseModel::where([['modular_id', '=', $data['modular_id']]])->findOrEmpty();
|
||||
|
||||
if (!$auth_house->isEmpty()) {
|
||||
return $this->error('已存在此小程序');
|
||||
}
|
||||
|
||||
$total_house_number = AdminUserService::getSassNum('house',$this->_uniacid);
|
||||
|
||||
$total_house_used = $auth_house->where([['uniacid','in',$this->_uniacid_arr]])->sum('count');
|
||||
$remain = $total_house_number - $total_house_used;
|
||||
if ($remain <= 0) {
|
||||
return $this->error('分配的数量超过可用的总数');
|
||||
}
|
||||
|
||||
$rst = $auth_house->save([
|
||||
'modular_id' => $data[ 'modular_id' ],
|
||||
'create_time' => $time,
|
||||
'update_time' => $time,
|
||||
'sign' => intval( $time + ( 366 * 24 * 60 * 60 ) ),
|
||||
'count' => 1,
|
||||
'uniacid' => $this->_uniacid,
|
||||
]);
|
||||
|
||||
if ($rst) {
|
||||
return $this->success('success');
|
||||
}
|
||||
|
||||
return $this->error('fail');
|
||||
}
|
||||
|
||||
|
||||
public function extendedOneYear ()
|
||||
{
|
||||
$data = $this->_input;
|
||||
if (!isset($data['modular_id'])) {
|
||||
return $this->success('参数错误');
|
||||
}
|
||||
|
||||
$time = time();
|
||||
$auth_house = Cardauth2HouseModel::where([['modular_id', '=', $data['modular_id']]])->findOrEmpty();
|
||||
|
||||
if ($auth_house->isEmpty()) {
|
||||
return $this->error('小程序不存在');
|
||||
}
|
||||
|
||||
$total_house_number = AdminUserService::getSassNum('house',$this->_uniacid);
|
||||
|
||||
$total_house_used = $auth_house->where([['uniacid','in',$this->_uniacid_arr]])->sum('count');
|
||||
$remain = $total_house_number - $total_house_used;
|
||||
if ($remain <= 0) {
|
||||
return $this->error('分配的数量超过可用的总数');
|
||||
}
|
||||
|
||||
$rst = $auth_house->save([
|
||||
'sign' => $auth_house[ 'sign' ] > $time ? ($auth_house[ 'sign' ] + ( 366 * 24 * 60 * 60 )) : ( $time + ( 366 * 24 * 60 * 60 ) ),
|
||||
'count' => $auth_house['count'] + 1,
|
||||
'update_time' => $time,
|
||||
]);
|
||||
|
||||
|
||||
if ($rst) {
|
||||
return $this->success('success');
|
||||
}
|
||||
|
||||
|
||||
return $this->error('fail');
|
||||
}
|
||||
|
||||
}
|
||||
37
app/agent/controller/Index.php
Executable file
37
app/agent/controller/Index.php
Executable file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\agent\controller;
|
||||
|
||||
|
||||
|
||||
use think\facade\View;
|
||||
|
||||
class Index
|
||||
{
|
||||
|
||||
|
||||
public function index()
|
||||
{
|
||||
$timestamp = '?v=' . time();
|
||||
$is_we7 = defined('IS_WEIQIN') ? true : false;
|
||||
$appcss = $is_we7 ? '/addons/'. APP_MODEL_NAME .'/core2/public/agent/static/css/app.css' : '/agent/static/css/app.css';
|
||||
$manifest = $is_we7 ? '/addons/'. APP_MODEL_NAME .'/core2/public/agent/static/js/manifest.js' : '/agent/static/js/manifest.js';
|
||||
$vendor = $is_we7 ? '/addons/'. APP_MODEL_NAME .'/core2/public/agent/static/js/vendor.js' : '/agent/static/js/vendor.js';
|
||||
$app = $is_we7 ? '/addons/'. APP_MODEL_NAME .'/core2/public/agent/static/js/app.js' : '/agent/static/js/app.js';
|
||||
|
||||
$jsPath = $is_we7 ? '/addons/'. APP_MODEL_NAME .'/core2/public/agent/' : '/agent/';
|
||||
global $_W;
|
||||
$is_founder = isset($_W['isfounder']) ? $_W['isfounder'] : false;
|
||||
View::assign('jsPath', $jsPath);
|
||||
View::assign('isWe7', $is_we7);
|
||||
View::assign('is_founder', $is_founder);
|
||||
View::assign('appcss', $appcss.$timestamp);
|
||||
View::assign('manifest', $manifest .$timestamp);
|
||||
View::assign('vendor', $vendor .$timestamp );
|
||||
View::assign('app', $app . $timestamp);
|
||||
return View::fetch();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
48
app/agent/controller/MessageConfigController.php
Executable file
48
app/agent/controller/MessageConfigController.php
Executable file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
namespace app\agent\controller;
|
||||
|
||||
use think\App;
|
||||
use app\AdminRest;
|
||||
use app\AgentRest;
|
||||
use think\facade\Db;
|
||||
use think\Validate;
|
||||
|
||||
class MessageConfigController extends AgentRest
|
||||
{
|
||||
public function __construct ( App $app ){
|
||||
parent::__construct( $app );
|
||||
if ($this->_user['role_name'] != 'admin') {
|
||||
echo json_encode(['code' => 401, 'error' => lang('Permission denied')]);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
public function delMessageByDay()
|
||||
{
|
||||
if (!isset($this->_input['modular_id']) || !isset($this->_input['days'])) {
|
||||
return $this->success('success');
|
||||
}
|
||||
|
||||
$validate = new Validate();
|
||||
$validate->rule([
|
||||
'days|清除时间' => 'integer',
|
||||
]);
|
||||
|
||||
if (!$validate->check($this->_input)) {
|
||||
return $this->error($validate->getError());
|
||||
}
|
||||
|
||||
$modular_id = $this->_input['modular_id'];
|
||||
$days = $this->_input['days'];
|
||||
|
||||
if ($days > 0) {
|
||||
$beginTime = mktime(0, 0, 0, date('m'), date('d') - $days, date('Y'));
|
||||
} else {
|
||||
$beginTime = 99999999999;
|
||||
}
|
||||
|
||||
$rst = Db::name('longbing_card_message')->where([['uniacid', '=', $modular_id], ['create_time', '<', $beginTime]])->delete(true);
|
||||
return $this->success($rst);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
205
app/agent/controller/OssConfig.php
Executable file
205
app/agent/controller/OssConfig.php
Executable file
@@ -0,0 +1,205 @@
|
||||
<?php
|
||||
namespace app\agent\controller;
|
||||
|
||||
use app\Common\Upload;
|
||||
use think\App;
|
||||
use app\AgentRest;
|
||||
use app\agent\model\OssConfig as model;
|
||||
use think\facade\Db;
|
||||
use think\file\UploadedFile;
|
||||
|
||||
class OssConfig extends AgentRest
|
||||
{
|
||||
|
||||
|
||||
protected $model;
|
||||
|
||||
public function __construct ( App $app ){
|
||||
|
||||
parent::__construct( $app );
|
||||
|
||||
$this->model = new model();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-05-14 10:08
|
||||
* @功能说明:列表
|
||||
*/
|
||||
public function configList(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$dis[] = [
|
||||
|
||||
'uniacid','in' , $this->_uniacid_arr
|
||||
|
||||
];
|
||||
|
||||
if(!empty($input['name'])){
|
||||
|
||||
$dis[] = ['name','like','%'.$input['name'].'%'];
|
||||
}
|
||||
|
||||
$data = $this->model->configList($dis,$input['page_count']);
|
||||
|
||||
return $this->success($data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-05-14 10:12
|
||||
* @功能说明:添加
|
||||
*/
|
||||
public function configAdd(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$input['uniacid'] = $this->_uniacid;
|
||||
Db::startTrans();
|
||||
$res = $this->model->configAdd($input);
|
||||
|
||||
$id = $this->model->getLastInsID();
|
||||
|
||||
if(!empty($id) && !empty($input['open_oss']))
|
||||
{
|
||||
$path = LONGBING_EXTEND_PATH . 'timg.jpg';
|
||||
|
||||
if(file_exists($path)){
|
||||
|
||||
$dis['id'] = $id;
|
||||
|
||||
$config = $this->model->configInfo($dis);
|
||||
|
||||
$file = new UploadedFile($path ,'test.jpg');
|
||||
|
||||
$file_upload_model = new Upload($this->_uniacid);
|
||||
|
||||
$check = $file_upload_model->upload('picture' ,$file,$config);
|
||||
|
||||
if(empty($check)) return $this->error(lang('上传配置错误,请检查上传配置是否正确'));
|
||||
}
|
||||
}
|
||||
Db::commit();
|
||||
|
||||
return $this->success($res);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-05-14 10:14
|
||||
* @功能说明:编辑
|
||||
*/
|
||||
public function configUpdate(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$dis = [
|
||||
|
||||
'id' => $input['id']
|
||||
|
||||
];
|
||||
Db::startTrans();
|
||||
$res = $this->model->configUpdate($dis,$input);
|
||||
|
||||
if(!empty($res) && !empty($input['open_oss']))
|
||||
{
|
||||
$path = LONGBING_EXTEND_PATH . 'timg.jpg';
|
||||
|
||||
if(file_exists($path)){
|
||||
|
||||
$config = $this->model->configInfo($dis);
|
||||
|
||||
$file = new UploadedFile($path ,'test.jpg');
|
||||
|
||||
$file_upload_model = new Upload($this->_uniacid);
|
||||
|
||||
$check = $file_upload_model->upload('picture' ,$file,$config);
|
||||
|
||||
if(empty($check)) return $this->error(lang('上传配置错误,请检查上传配置是否正确'));
|
||||
}
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-05-14 10:17
|
||||
* @功能说明:详情
|
||||
*/
|
||||
public function configInfo(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$dis = [
|
||||
|
||||
'id' => $input['id']
|
||||
|
||||
];
|
||||
|
||||
$res = $this->model->configInfo($dis);
|
||||
|
||||
return $this->success($res);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-05-14 10:18
|
||||
* @功能说明:删除
|
||||
*/
|
||||
public function configDel(){
|
||||
|
||||
$input = $this->_input;
|
||||
|
||||
$dis = [
|
||||
|
||||
'id' => $input['id']
|
||||
|
||||
];
|
||||
|
||||
$res = $this->model->configDel($dis);
|
||||
|
||||
if($res==200){
|
||||
|
||||
$this->errorMsg('已有小程序使用该配置');
|
||||
|
||||
}
|
||||
|
||||
return $this->success($res);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-05-14 10:35
|
||||
* @功能说明:配置下拉框
|
||||
*/
|
||||
public function configSelect(){
|
||||
|
||||
$dis[] = [
|
||||
|
||||
'uniacid','in' , $this->_uniacid_arr
|
||||
|
||||
];
|
||||
|
||||
$data = $this->model->where($dis)->order('id desc')->select();
|
||||
|
||||
return $this->success($data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
991
app/agent/controller/PermissionContrller.php
Executable file
991
app/agent/controller/PermissionContrller.php
Executable file
@@ -0,0 +1,991 @@
|
||||
<?php
|
||||
namespace app\agent\controller;
|
||||
|
||||
use app\activity\info\PermissionActivity;
|
||||
use app\article\info\PermissionArticle;
|
||||
use app\baidu\info\PermissionBaidu;
|
||||
use app\bargain\info\PermissionBargain;
|
||||
use app\boss\info\PermissionBoss;
|
||||
use app\closure\info\PermissionClosure;
|
||||
use app\house\info\PermissionHouse;
|
||||
use app\livevideo\info\PermissionLivevideo;
|
||||
use app\member\info\PermissionMember;
|
||||
use app\overlord\info\PermissionOverlord;
|
||||
use app\payclass\info\PermissionPayclass;
|
||||
use app\question\info\PermissionQuestion;
|
||||
use app\restaurant\info\PermissionRestaurant;
|
||||
use app\passenger\info\PermissionPassenger;
|
||||
use app\redbag\info\PermissionRedbag;
|
||||
use app\reduction\info\PermissionReduction;
|
||||
use app\shortvideo\info\PermissionShortvideo;
|
||||
use think\App;
|
||||
use app\AdminRest;
|
||||
use app\AgentRest;
|
||||
use think\facade\Config;
|
||||
|
||||
class PermissionContrller extends AgentRest
|
||||
{
|
||||
public function __construct ( App $app ){
|
||||
parent::__construct( $app );
|
||||
if ($this->_user['role_name'] != 'admin') {
|
||||
echo json_encode(['code' => 401, 'error' => lang('Permission denied')]);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
public function getAgentPermission()
|
||||
{
|
||||
$is_super_admin = ($this->_role == 'admin') ? true : false;
|
||||
|
||||
if (!$is_super_admin) {
|
||||
return $this->error('非法请求, 请联系超级管理员');
|
||||
}
|
||||
|
||||
$is_we7 = defined('IS_WEIQIN');
|
||||
|
||||
$permissionArticle = new PermissionArticle(0);
|
||||
|
||||
$permissionBoss = new PermissionBoss(0);
|
||||
|
||||
$permissionBaidu = new PermissionBaidu(0);
|
||||
//截流
|
||||
$permissionClosure = new PermissionClosure(0);
|
||||
//带客有礼
|
||||
$permissionPassenger = new PermissionPassenger(0);
|
||||
//新客福包
|
||||
$permissionRedbag = new PermissionRedbag(0);
|
||||
//满减
|
||||
$permissionReduction = new PermissionReduction(0);
|
||||
//直播
|
||||
$permissionLivevideo = new PermissionLivevideo(0);
|
||||
//短视频
|
||||
$permissionShortvideo = new PermissionShortvideo(0);
|
||||
// 会员等级
|
||||
$permissionMember = new PermissionMember(0);
|
||||
// 餐饮
|
||||
$permissionRestaurant = new PermissionRestaurant(0);
|
||||
//霸王餐
|
||||
$permissionOverlord = new PermissionOverlord(0);
|
||||
//付费课程
|
||||
$permissionPayclass = new PermissionPayclass(0);
|
||||
|
||||
$permissionBargain = new PermissionBargain(0);
|
||||
|
||||
$permissionQuestion = new PermissionQuestion(0);
|
||||
|
||||
$has_article = $permissionArticle->sAuth();
|
||||
|
||||
$has_boss = $permissionBoss->sAuth();
|
||||
|
||||
if($has_boss==true){
|
||||
|
||||
$has_boss = $permissionBoss->getSaasValue()>0?true:false;
|
||||
|
||||
}
|
||||
|
||||
$has_baidu = $permissionBaidu->sAuth();
|
||||
//截流
|
||||
$has_closure = $permissionClosure->sAuth();
|
||||
//带客有礼
|
||||
$has_passenger = $permissionPassenger->sAuth();
|
||||
//新客户包
|
||||
$has_redbag = $permissionRedbag->sAuth();
|
||||
//满减
|
||||
$has_reduction = $permissionReduction->sAuth();
|
||||
//直播
|
||||
$has_livevideo = $permissionLivevideo->sAuth();
|
||||
//短视频
|
||||
$has_shortvideo= $permissionShortvideo->sAuth();
|
||||
//会员
|
||||
$has_member = $permissionMember->sAuth();
|
||||
//餐饮
|
||||
$has_restaurant = $permissionRestaurant->sAuth();
|
||||
// 霸王餐
|
||||
$has_overlord = $permissionOverlord->sAuth();
|
||||
// 付费课程
|
||||
$has_payclass = $permissionPayclass->sAuth();
|
||||
//临时写法==== By.jingshuixian
|
||||
$permissionHouse = new PermissionHouse(0);
|
||||
|
||||
$has_house = $permissionHouse->sAuth();
|
||||
|
||||
$permissionActivity = new PermissionActivity(0);
|
||||
|
||||
$has_activity = $permissionActivity->sAuth();
|
||||
|
||||
$has_bargain = $permissionBargain->sAuth();
|
||||
|
||||
$has_question = $permissionQuestion->sAuth();
|
||||
|
||||
|
||||
if(APP_MODEL_NAME=='longbing_restaurant'){
|
||||
|
||||
$has_restaurant = false;
|
||||
}
|
||||
|
||||
if(APP_MODEL_NAME=='longbing_shortvideo'){
|
||||
|
||||
$has_shortvideo = false;
|
||||
}
|
||||
|
||||
if(APP_MODEL_NAME=='longbing_member'){
|
||||
|
||||
$has_member = false;
|
||||
}
|
||||
|
||||
if(APP_MODEL_NAME=='longbing_house'){
|
||||
|
||||
$has_house = false;
|
||||
}
|
||||
|
||||
if(APP_MODEL_NAME=='longbing_liveshop'){
|
||||
|
||||
$has_livevideo = false;
|
||||
}
|
||||
|
||||
$all_meta_json = <<<AGENT
|
||||
|
||||
[
|
||||
{
|
||||
"path":"/",
|
||||
"name":"Auth",
|
||||
"component":"Layout",
|
||||
"hidden":false,
|
||||
"redirect":"/auth",
|
||||
"meta":{
|
||||
"menuName":"AuthManage",
|
||||
"icon":"iconauthorise"
|
||||
},
|
||||
"children":[
|
||||
{
|
||||
"path":"auth",
|
||||
"name":"AuthManage",
|
||||
"component":"/auth",
|
||||
"hidden":false,
|
||||
"meta":{
|
||||
"keepAlive":true,
|
||||
"menuName":"AuthManage",
|
||||
"icon":"iconauthorise",
|
||||
"url":"",
|
||||
"pagePermission":[
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"path":"editAuth",
|
||||
"name":"EditAuth",
|
||||
"component":"/editAuth",
|
||||
"hidden":true,
|
||||
"meta":{
|
||||
"keepAlive":false,
|
||||
"menuName":"EditAuth",
|
||||
"icon":"",
|
||||
"url":"",
|
||||
"pagePermission":[
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"path": "/",
|
||||
"name": "AgentLevel",
|
||||
"component": "Layout",
|
||||
"hidden": false,
|
||||
"redirect": "/agentLevel",
|
||||
"meta": {
|
||||
"menuName": "AgentLevelManage",
|
||||
"icon": "iconAgentLevel"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"path": "agentLevel",
|
||||
"name": "AgentLevelManage",
|
||||
"component": "/agentLevel",
|
||||
"hidden": false,
|
||||
"meta": {
|
||||
"keepAlive": true,
|
||||
"menuName": "AgentLevelManage",
|
||||
"icon": "iconAgentLevel",
|
||||
"url": "",
|
||||
"pagePermission": [
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "editAgentLevel",
|
||||
"name": "EditAgentLevel",
|
||||
"component": "/editAgentLevel",
|
||||
"hidden": true,
|
||||
"meta": {
|
||||
"keepAlive": false,
|
||||
"menuName": "EditAgentLevel",
|
||||
"icon": "",
|
||||
"url": "",
|
||||
"pagePermission": [
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"path": "/",
|
||||
"name": "AgentAuth",
|
||||
"component": "Layout",
|
||||
"hidden": false,
|
||||
"redirect": "/agentAuth",
|
||||
"meta": {
|
||||
"menuName": "AgentAuthManage",
|
||||
"icon": "iconagentauth"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"path": "agentAuth",
|
||||
"name": "AgentAuthManage",
|
||||
"component": "/agentAuth",
|
||||
"hidden": false,
|
||||
"meta": {
|
||||
"keepAlive": true,
|
||||
"menuName": "AgentAuthManage",
|
||||
"icon": "iconagentauth",
|
||||
"url": "",
|
||||
"pagePermission": [
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "editAgentAuth",
|
||||
"name": "EditAgentAuth",
|
||||
"component": "/editAgentAuth",
|
||||
"hidden": true,
|
||||
"meta": {
|
||||
"keepAlive": false,
|
||||
"menuName": "EditAgentAuth",
|
||||
"icon": "",
|
||||
"url": "",
|
||||
"pagePermission": [
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"path":"/copyright",
|
||||
"name":"Copyright",
|
||||
"component":"Layout",
|
||||
"redirect":"/copyright/index",
|
||||
"hidden":false,
|
||||
"meta":{
|
||||
"menuName":"CopyrightManage",
|
||||
"icon":"iconbanquan"
|
||||
},
|
||||
"children":[
|
||||
{
|
||||
"path":"index",
|
||||
"name":"CopyrightIndex",
|
||||
"component":"/copyright",
|
||||
"hidden":false,
|
||||
"meta":{
|
||||
"keepAlive":true,
|
||||
"menuName":"CopyrightManage",
|
||||
"icon":"iconbanquan",
|
||||
"url":"",
|
||||
"pagePermission":[
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"path":"edit",
|
||||
"name":"EditCopyright",
|
||||
"component":"/editCopyright",
|
||||
"hidden":true,
|
||||
"meta":{
|
||||
"keepAlive":false,
|
||||
"menuName":"EditCopyright",
|
||||
"icon":"",
|
||||
"url":"",
|
||||
"pagePermission":[
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
,
|
||||
{
|
||||
"path": "/",
|
||||
"name": "Upload",
|
||||
"component": "Layout",
|
||||
"hidden": false,
|
||||
"redirect": "/upload",
|
||||
"meta": {
|
||||
"menuName": "UploadManage",
|
||||
"icon": "iconuploadset"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"path": "upload",
|
||||
"name": "UploadManage",
|
||||
"component": "/upload",
|
||||
"hidden": false,
|
||||
"meta": {
|
||||
"keepAlive": true,
|
||||
"menuName": "UploadManage",
|
||||
"icon": "iconuploadset",
|
||||
"url": "",
|
||||
"pagePermission": [
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "editUpload",
|
||||
"name": "EditUpload",
|
||||
"component": "/editUpload",
|
||||
"hidden": true,
|
||||
"meta": {
|
||||
"keepAlive": false,
|
||||
"menuName": "EditUpload",
|
||||
"icon": "",
|
||||
"url": "",
|
||||
"pagePermission": [
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"path":"/default",
|
||||
"name":"Default",
|
||||
"component":"Layout",
|
||||
"redirect":"/default/setting",
|
||||
"hidden":false,
|
||||
"meta":{
|
||||
"menuName":"DefaultSetting",
|
||||
"icon":"iconshezhi"
|
||||
},
|
||||
"children":[
|
||||
{
|
||||
"path":"setting",
|
||||
"name":"DefaultSetting",
|
||||
"component":"/default",
|
||||
"hidden":false,
|
||||
"meta":{
|
||||
"keepAlive":false,
|
||||
"menuName":"DefaultSetting",
|
||||
"icon":"iconshezhi",
|
||||
"url":"",
|
||||
"pagePermission":[
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"path":"/chat",
|
||||
"name":"Chat",
|
||||
"component":"Layout",
|
||||
"redirect":"/chat/record",
|
||||
"hidden":false,
|
||||
"meta":{
|
||||
"menuName":"ChatRecord",
|
||||
"icon":"iconliaotian"
|
||||
},
|
||||
"children":[
|
||||
{
|
||||
"path":"record",
|
||||
"name":"ChatRecord",
|
||||
"component":"/chatRecord",
|
||||
"hidden":false,
|
||||
"meta":{
|
||||
"keepAlive":true,
|
||||
"menuName":"ChatRecord",
|
||||
"icon":"iconliaotian",
|
||||
"url":"",
|
||||
"pagePermission":[
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"path":"/article",
|
||||
"name":"Article",
|
||||
"component":"Layout",
|
||||
"redirect":"/article/index",
|
||||
"hidden":false,
|
||||
"meta":{
|
||||
"menuName":"Article",
|
||||
"icon":"iconwenzhangguanli"
|
||||
},
|
||||
"children":[
|
||||
{
|
||||
"path":"index",
|
||||
"name":"ArticleIndex",
|
||||
"component":"/article",
|
||||
"hidden":false,
|
||||
"meta":{
|
||||
"keepAlive":true,
|
||||
"menuName":"Article",
|
||||
"icon":"iconwenzhangguanli",
|
||||
"url":"",
|
||||
"pagePermission":[
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"path":"/activity",
|
||||
"name":"Activity",
|
||||
"component":"Layout",
|
||||
"redirect":"/activity/index",
|
||||
"hidden":false,
|
||||
"meta":{
|
||||
"menuName":"Activity",
|
||||
"icon":"iconhuodongyingxiao"
|
||||
},
|
||||
"children":[
|
||||
{
|
||||
"path":"index",
|
||||
"name":"ActivityIndex",
|
||||
"component":"/activity",
|
||||
"hidden":false,
|
||||
"meta":{
|
||||
"keepAlive":true,
|
||||
"menuName":"Activity",
|
||||
"icon":"iconhuodongyingxiao",
|
||||
"url":"",
|
||||
"pagePermission":[
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"path":"/house",
|
||||
"name":"House",
|
||||
"component":"Layout",
|
||||
"redirect":"/house/index",
|
||||
"hidden":false,
|
||||
"meta":{
|
||||
"menuName":"House",
|
||||
"icon":"iconfangchan01"
|
||||
},
|
||||
"children":[
|
||||
{
|
||||
"path":"index",
|
||||
"name":"HouseIndex",
|
||||
"component":"/house",
|
||||
"hidden":false,
|
||||
"meta":{
|
||||
"keepAlive":true,
|
||||
"menuName":"House",
|
||||
"icon":"iconfangchan01",
|
||||
"url":"",
|
||||
"pagePermission":[
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"path":"/baidu",
|
||||
"name":"Baidu",
|
||||
"component":"Layout",
|
||||
"redirect":"/baidu/index",
|
||||
"hidden":false,
|
||||
"meta":{
|
||||
"menuName":"Baidu",
|
||||
"icon":"iconicon_baidulogo"
|
||||
},
|
||||
"children":[
|
||||
{
|
||||
"path":"index",
|
||||
"name":"BaiduIndex",
|
||||
"component":"/baidu",
|
||||
"hidden":false,
|
||||
"meta":{
|
||||
"keepAlive": true,
|
||||
"menuName":"Baidu",
|
||||
"icon":"iconicon_baidulogo",
|
||||
"url": "",
|
||||
"pagePermission":[
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"path": "/closure",
|
||||
"name": "Closure",
|
||||
"component": "Layout",
|
||||
"redirect": "/closure/index",
|
||||
"hidden":false,
|
||||
"meta": {
|
||||
"menuName": "Closure",
|
||||
"icon": "icon_closure"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"path": "index",
|
||||
"name": "ClosureIndex",
|
||||
"component": "/closure",
|
||||
"hidden": false,
|
||||
"meta": {
|
||||
"keepAlive": true,
|
||||
"menuName": "Closure",
|
||||
"icon": "icon_closure",
|
||||
"url": "",
|
||||
"pagePermission": [
|
||||
]
|
||||
}
|
||||
}]
|
||||
},
|
||||
{
|
||||
"path": "/passenger",
|
||||
"name": "Passenger",
|
||||
"component": "Layout",
|
||||
"redirect": "/passenger/index",
|
||||
"hidden": false,
|
||||
"meta": {
|
||||
"menuName": "Passenger",
|
||||
"icon": "icon_passenger"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"path": "index",
|
||||
"name": "PassengerIndex",
|
||||
"component": "/passenger",
|
||||
"hidden": false,
|
||||
"meta": {
|
||||
"keepAlive": true,
|
||||
"menuName": "Passenger",
|
||||
"icon": "icon_passenger",
|
||||
"url": "",
|
||||
"pagePermission": [
|
||||
]
|
||||
}
|
||||
}]
|
||||
},
|
||||
{
|
||||
"path": "/cash",
|
||||
"name": "Cash",
|
||||
"component": "Layout",
|
||||
"redirect": "/cash/index",
|
||||
"hidden": false,
|
||||
"meta": {
|
||||
"menuName": "Cash",
|
||||
"icon": "iconxinkefuli"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"path": "index",
|
||||
"name": "CashIndex",
|
||||
"component": "/cash",
|
||||
"hidden": false,
|
||||
"meta": {
|
||||
"keepAlive": true,
|
||||
"menuName": "Cash",
|
||||
"icon": "iconxinkefuli",
|
||||
"url": "",
|
||||
"pagePermission": [
|
||||
]
|
||||
}
|
||||
}]
|
||||
}
|
||||
,
|
||||
{
|
||||
"path": "/reduction",
|
||||
"name": "Reduction",
|
||||
"component": "Layout",
|
||||
"redirect": "/reduction/index",
|
||||
"hidden": false,
|
||||
"meta": {
|
||||
"menuName": "Reduction",
|
||||
"icon": "iconreduction"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"path": "index",
|
||||
"name": "ReductionIndex",
|
||||
"component": "/reduction",
|
||||
"hidden": false,
|
||||
"meta": {
|
||||
"keepAlive": true,
|
||||
"menuName": "Reduction",
|
||||
"icon": "iconreduction",
|
||||
"url": "",
|
||||
"pagePermission": [
|
||||
]
|
||||
}
|
||||
}]
|
||||
},
|
||||
{
|
||||
"path": "/live",
|
||||
"name": "Live",
|
||||
"component": "Layout",
|
||||
"redirect": "/live/index",
|
||||
"hidden": false,
|
||||
"meta": {
|
||||
"menuName": "Live",
|
||||
"icon": "iconlive"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"path": "index",
|
||||
"name": "LiveIndex",
|
||||
"component": "/live",
|
||||
"hidden": false,
|
||||
"meta": {
|
||||
"keepAlive": true,
|
||||
"menuName": "Live",
|
||||
"icon": "iconlive",
|
||||
"url": "",
|
||||
"pagePermission": [
|
||||
]
|
||||
}
|
||||
}]
|
||||
},
|
||||
{
|
||||
"path": "/shortvideo",
|
||||
"name": "Shortvideo",
|
||||
"component": "Layout",
|
||||
"redirect": "/shortvideo/index",
|
||||
"hidden": false,
|
||||
"meta": {
|
||||
"menuName": "Shortvideo",
|
||||
"icon": "iconShortVideo"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"path": "index",
|
||||
"name": "ShortvideoIndex",
|
||||
"component": "/shortvideo",
|
||||
"hidden": false,
|
||||
"meta": {
|
||||
"keepAlive": true,
|
||||
"menuName": "Shortvideo",
|
||||
"icon": "iconShortVideo",
|
||||
"url": "",
|
||||
"pagePermission": [
|
||||
]
|
||||
}
|
||||
}]
|
||||
},
|
||||
{
|
||||
"path":"/company",
|
||||
"name":"Company",
|
||||
"component":"Layout",
|
||||
"redirect":"/company/index",
|
||||
"hidden":false,
|
||||
"meta":{
|
||||
"menuName":"Company",
|
||||
"icon":"icongongsikehuguanli"
|
||||
},
|
||||
"children":[
|
||||
{
|
||||
"path":"index",
|
||||
"name":"CompanyIndex",
|
||||
"component":"/company",
|
||||
"hidden":false,
|
||||
"meta":{
|
||||
"keepAlive":true,
|
||||
"menuName":"Company",
|
||||
"icon":"icongongsikehuguanli",
|
||||
"url":"",
|
||||
"pagePermission":[
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"path":"/vip",
|
||||
"name":"Member",
|
||||
"component":"Layout",
|
||||
"redirect":"/member/index",
|
||||
"hidden":false,
|
||||
"meta":{
|
||||
"menuName":"Member",
|
||||
"icon":"iconreduction"
|
||||
},
|
||||
"children":[
|
||||
{
|
||||
"path":"index",
|
||||
"name":"MemberIndex",
|
||||
"component":"/member",
|
||||
"hidden":false,
|
||||
"meta":{
|
||||
"keepAlive":true,
|
||||
"menuName":"Member",
|
||||
"icon":"iconMember",
|
||||
"url":"",
|
||||
"pagePermission":[
|
||||
]
|
||||
}
|
||||
}]
|
||||
},
|
||||
{
|
||||
"path":"/restaurant",
|
||||
"name":"Restaurant",
|
||||
"component":"Layout",
|
||||
"redirect":"/restaurant/index",
|
||||
"hidden":false,
|
||||
"meta":{
|
||||
"menuName":"Restaurant",
|
||||
"icon":"iconcanyin1"
|
||||
},
|
||||
"children":[
|
||||
{
|
||||
"path":"index",
|
||||
"name":"RestaurantIndex",
|
||||
"component":"/restaurant",
|
||||
"hidden":false,
|
||||
"meta":{
|
||||
"keepAlive":true,
|
||||
"menuName":"Restaurant",
|
||||
"icon":"iconcanyin1",
|
||||
"url":"",
|
||||
"pagePermission":[
|
||||
]
|
||||
}
|
||||
}]
|
||||
},
|
||||
{
|
||||
"path": "/overlord",
|
||||
"name": "Overlord",
|
||||
"component": "Layout",
|
||||
"redirect": "/overlord/index",
|
||||
"hidden": false,
|
||||
"meta": {
|
||||
"menuName": "Overlord",
|
||||
"icon": "iconhuodongyingxiao"
|
||||
},
|
||||
"children": [{
|
||||
"path": "index",
|
||||
"name": "OverlordIndex",
|
||||
"component": "/overlord",
|
||||
"hidden": false,
|
||||
"meta": {
|
||||
"keepAlive": true,
|
||||
"menuName": "Overlord",
|
||||
"icon": "iconhuodongyingxiao",
|
||||
"url": "",
|
||||
"pagePermission": []
|
||||
}
|
||||
}]
|
||||
}
|
||||
,
|
||||
{
|
||||
"path": "/bargain",
|
||||
"name": "Bargain",
|
||||
"component": "Layout",
|
||||
"redirect": "/bargain/index",
|
||||
"hidden": false,
|
||||
"meta": {
|
||||
"menuName": "Bargain",
|
||||
"icon": "iconkanjiajilu"
|
||||
},
|
||||
"children": [{
|
||||
"path": "index",
|
||||
"name": "BargainIndex",
|
||||
"component": "/bargain",
|
||||
"hidden": false,
|
||||
"meta": {
|
||||
"keepAlive": true,
|
||||
"menuName": "Bargain",
|
||||
"icon": "iconkanjiajilu",
|
||||
"url": "",
|
||||
"pagePermission": []
|
||||
}
|
||||
}]
|
||||
},
|
||||
{
|
||||
"path": "/payclass",
|
||||
"name": "Payclass",
|
||||
"component": "Layout",
|
||||
"redirect": "/payclass/index",
|
||||
"hidden": false,
|
||||
"meta": {
|
||||
"menuName": "Payclass",
|
||||
"icon": "iconcourse"
|
||||
},
|
||||
"children": [{
|
||||
"path": "index",
|
||||
"name": "PayclassIndex",
|
||||
"component": "/payclass",
|
||||
"hidden": false,
|
||||
"meta": {
|
||||
"keepAlive": true,
|
||||
"menuName": "Payclass",
|
||||
"icon": "iconcourse",
|
||||
"url": "",
|
||||
"pagePermission": []
|
||||
}
|
||||
}]
|
||||
},
|
||||
{
|
||||
"path": "/questionnaire",
|
||||
"name": "Questionnaire",
|
||||
"component": "Layout",
|
||||
"redirect": "/questionnaire/index",
|
||||
"hidden": false,
|
||||
"meta": {
|
||||
"menuName": "Questionnaire",
|
||||
"icon": "iconrenwu"
|
||||
},
|
||||
"children": [{
|
||||
"path": "index",
|
||||
"name": "QuestionnaireIndex",
|
||||
"component": "/questionnaire",
|
||||
"hidden": false,
|
||||
"meta": {
|
||||
"keepAlive": true,
|
||||
"menuName": "Questionnaire",
|
||||
"icon": "iconrenwu",
|
||||
"url": "",
|
||||
"pagePermission": []
|
||||
}
|
||||
}]
|
||||
},
|
||||
{
|
||||
"path":"/account",
|
||||
"name":"Account",
|
||||
"component":"Layout",
|
||||
"redirect":"/account/index",
|
||||
"hidden":false,
|
||||
"meta":{
|
||||
"menuName":"Account",
|
||||
"icon":""
|
||||
},
|
||||
"children":[
|
||||
{
|
||||
"path":"index",
|
||||
"name":"AccountIndex",
|
||||
"component":"/account",
|
||||
"hidden":false,
|
||||
"meta":{
|
||||
"keepAlive":true,
|
||||
"menuName":"AccountManage",
|
||||
"icon":"iconshezhi",
|
||||
"url":"",
|
||||
"pagePermission":[
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"path":"edit",
|
||||
"name":"EditAccount",
|
||||
"component":"/editAccount",
|
||||
"hidden":true,
|
||||
"meta":{
|
||||
"keepAlive":false,
|
||||
"menuName":"EditAccount",
|
||||
"icon":"iconshezhi",
|
||||
"url":"",
|
||||
"pagePermission":[
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"path":"/site",
|
||||
"name":"Site",
|
||||
"component":"Layout",
|
||||
"redirect":"/account/index",
|
||||
"hidden":false,
|
||||
"meta":{
|
||||
"menuName":"Site",
|
||||
"icon":""
|
||||
},
|
||||
"children":[
|
||||
{
|
||||
"path":"index",
|
||||
"name":"SiteBind",
|
||||
"component":"/site",
|
||||
"hidden":false,
|
||||
"meta":{
|
||||
"menuName":"SiteBind",
|
||||
"icon":"iconqiu",
|
||||
"pagePermission":[
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
AGENT;
|
||||
|
||||
|
||||
$all_meta = json_decode($all_meta_json, true);
|
||||
|
||||
foreach ($all_meta as $k => $v) {
|
||||
$name = $v['name'];
|
||||
|
||||
switch ($name) {
|
||||
case 'Article' :
|
||||
if (!$has_article) unset($all_meta[$k]);
|
||||
break;
|
||||
case 'Activity' :
|
||||
if (!$has_activity) unset($all_meta[$k]);
|
||||
break;
|
||||
case 'House' :
|
||||
if (!$has_house) unset($all_meta[$k]);
|
||||
break;
|
||||
case 'Company' :
|
||||
if (!$has_boss) unset($all_meta[$k]);
|
||||
break;
|
||||
case 'Account' :
|
||||
if ($is_we7) unset($all_meta[$k]);
|
||||
break;
|
||||
case 'Default' :
|
||||
if (!$is_we7) unset($all_meta[$k]);
|
||||
break;
|
||||
case 'Baidu' :
|
||||
if (!$has_baidu) unset($all_meta[$k]);
|
||||
break;
|
||||
case 'Closure' :
|
||||
if (!$has_closure) unset($all_meta[$k]);
|
||||
break;
|
||||
case 'Passenger' :
|
||||
if (!$has_passenger) unset($all_meta[$k]);
|
||||
break;
|
||||
case 'Cash' :
|
||||
if (!$has_redbag) unset($all_meta[$k]);
|
||||
break;
|
||||
case 'Reduction' :
|
||||
if (!$has_reduction) unset($all_meta[$k]);
|
||||
break;
|
||||
case 'Live' :
|
||||
if (!$has_livevideo) unset($all_meta[$k]);
|
||||
break;
|
||||
case 'Shortvideo':
|
||||
if (!$has_shortvideo) unset($all_meta[$k]);
|
||||
break;
|
||||
case 'Member':
|
||||
if (!$has_member) unset($all_meta[$k]);
|
||||
break;
|
||||
case 'Restaurant':
|
||||
if (!$has_restaurant) unset($all_meta[$k]);
|
||||
break;
|
||||
case 'Overlord':
|
||||
if (!$has_overlord) unset($all_meta[$k]);
|
||||
break;
|
||||
case 'Payclass':
|
||||
if (!$has_payclass) unset($all_meta[$k]);
|
||||
break;
|
||||
case 'Bargain':
|
||||
if (!$has_bargain) unset($all_meta[$k]);
|
||||
break;
|
||||
case 'Questionnaire':
|
||||
if (!$has_question) unset($all_meta[$k]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $this->success(array_values($all_meta));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
44
app/agent/controller/UserController.php
Executable file
44
app/agent/controller/UserController.php
Executable file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
namespace app\agent\controller;
|
||||
|
||||
use think\App;
|
||||
use app\agent\model\AdminModel;
|
||||
use app\AgentRest;
|
||||
|
||||
class UserController extends AgentRest{
|
||||
public function __construct ( App $app ){
|
||||
parent::__construct( $app );
|
||||
}
|
||||
//
|
||||
public function updateSelfPasswd()
|
||||
{
|
||||
if(defined('IS_WEIQIN'))
|
||||
{
|
||||
return $this->error(lang('没有权限'));
|
||||
}
|
||||
//获取数据
|
||||
$input = $this->_input;
|
||||
if(isset($input['admin'])) $input = $input['admin'];
|
||||
//检查用户初始密码是否正确
|
||||
$user = $this->_user;
|
||||
if(isset($user['admin_id']) && !empty($user['admin_id']))
|
||||
{
|
||||
$admin_model = new AdminModel();
|
||||
$user = $admin_model->getAdmin(['admin_id' => $user['admin_id']]);
|
||||
// var_dump($user);die;
|
||||
}else{
|
||||
return $this->error(lang('admin is not exist'));
|
||||
}
|
||||
if(empty($user)) return $this->error(lang('admin is not exist'));
|
||||
// var_dump($user);die;
|
||||
$check = checkPasswd($input['old_passwd'] ,$user['offset'] ,$user['passwd']);
|
||||
if(!$check) return $this->error(lang('old passwd error'));
|
||||
//修改密码
|
||||
$passwd = createPasswd($input['new_passwd'] ,$user['offset']);
|
||||
//保存修改
|
||||
$admin_model = new AdminModel();
|
||||
$result = $admin_model->updateAdmin(['admin_id' => $user['admin_id']] ,['passwd' => $passwd]);
|
||||
//返回数据
|
||||
return $this->success($result);
|
||||
}
|
||||
}
|
||||
23
app/agent/info/Info.php
Executable file
23
app/agent/info/Info.php
Executable file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: shuixian
|
||||
* Date: 2019/11/20
|
||||
* Time: 18:30
|
||||
*/
|
||||
|
||||
return [
|
||||
|
||||
//模块名称[必填]
|
||||
'name' => 'agent',
|
||||
//模块标题[必填]
|
||||
'title' =>'代理管理端',
|
||||
// 模块唯一标识[必填],格式:模块名.开发者标识.module
|
||||
'identifier' => 'agent.longbing.module',
|
||||
// 版本[必填],格式采用三段式:主版本号.次版本号.修订版本号
|
||||
'version' => '1.0.19',
|
||||
// 模块依赖[可选],格式[[模块名, 模块唯一标识, 依赖版本, 对比方式]]
|
||||
'need_module' => [],
|
||||
// 插件依赖[可选],格式[[插件名, 插件唯一标识, 依赖版本, 对比方式]]
|
||||
'need_plugin' => [],
|
||||
];
|
||||
17
app/agent/lang/zh-cn.php
Executable file
17
app/agent/lang/zh-cn.php
Executable file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
return [
|
||||
'hello thinkphp' => '欢迎使用ThinkPHP',
|
||||
'data type error' => '数据类型错误',
|
||||
'tabbar count can not be greater than' => '菜单栏数量不能大于',
|
||||
'auto get template error' => '自动获取服务通知模板失败,请稍后再试。',
|
||||
'wx app site error ,please check site message.' => '微信小程序配置异常,请检查站点配置',
|
||||
'wx app site error' => '微信小程序配置异常,请检查站点配置',
|
||||
'param error' => '参数错误',
|
||||
'update success' => '更新成功',
|
||||
'update error' => '更新失败,请稍后再试',
|
||||
'Permission denied' => '权限不足,请联系超级管理员操作。',
|
||||
'old passwd error' => '原密码错误,请检查原密码。',
|
||||
'This copyright is in use and cannot be deleted' => '该版权正在被使用 无法删除',
|
||||
'app_name is empty' => '应用名称不能为空。',
|
||||
|
||||
];
|
||||
56
app/agent/model/AdminModel.php
Executable file
56
app/agent/model/AdminModel.php
Executable file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\agent\model;
|
||||
|
||||
|
||||
use app\BaseModel;
|
||||
|
||||
class AdminModel extends BaseModel
|
||||
{
|
||||
protected $name = 'longbing_admin';
|
||||
|
||||
|
||||
public function appAdmin()
|
||||
{
|
||||
return $this->hasOne(AppAdminModel::class, 'admin_id', 'admin_id');
|
||||
}
|
||||
|
||||
|
||||
public function role()
|
||||
{
|
||||
return $this->hasOne(AdminRoleModel::class, 'role_id', 'role_id');
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function createAdmin($data)
|
||||
{
|
||||
$data['create_time'] = time();
|
||||
$result = $this->save($data);
|
||||
return !empty($result);
|
||||
}
|
||||
|
||||
//修改
|
||||
public function updateAdmin($filter ,$data)
|
||||
{
|
||||
$filter['status'] = 1;
|
||||
$data['update_time'] = time();
|
||||
$result = $this->where($filter)->update($data);
|
||||
// var_dump($result);die;
|
||||
return !empty($result);
|
||||
}
|
||||
/**
|
||||
* 获取用户
|
||||
*/
|
||||
public function getAdmin($filter)
|
||||
{
|
||||
$filter['deleted'] = 0;
|
||||
$filter['status'] = 1;
|
||||
$result = $this->where($filter)->find();
|
||||
if(!empty($result)) $result = $result->toArray();
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
13
app/agent/model/AdminRoleModel.php
Executable file
13
app/agent/model/AdminRoleModel.php
Executable file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\agent\model;
|
||||
|
||||
|
||||
use app\BaseModel;
|
||||
|
||||
class AdminRoleModel extends BaseModel {
|
||||
|
||||
protected $name = 'longbing_role';
|
||||
|
||||
}
|
||||
93
app/agent/model/AgentLevel.php
Executable file
93
app/agent/model/AgentLevel.php
Executable file
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\agent\model;
|
||||
|
||||
|
||||
use app\BaseModel;
|
||||
use think\facade\Db;
|
||||
|
||||
class AgentLevel extends BaseModel
|
||||
{
|
||||
protected $name = 'longbing_card_agent_level';
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-05-12 10:54
|
||||
* @功能说明:代理等级列表
|
||||
*/
|
||||
public function levelList($dis,$page=10){
|
||||
|
||||
$list = $this->where($dis)->order('top desc,id desc')->paginate($page)->toArray();
|
||||
|
||||
return $list;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-05-12 10:55
|
||||
* @功能说明:添加代理商等级
|
||||
*/
|
||||
public function levelAdd($data){
|
||||
//创建时间
|
||||
$data['create_time'] = time();
|
||||
//更新时间
|
||||
$data['update_time'] = time();
|
||||
//状态
|
||||
$data['status'] = 1;
|
||||
|
||||
$res = $this->insert($data);
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-05-12 10:57
|
||||
* @功能说明:代理商等级编辑
|
||||
*/
|
||||
public function levelUpdate($dis,$data){
|
||||
|
||||
$data['update_time'] = time();
|
||||
|
||||
$res = $this->where($dis)->update($data);
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-05-12 13:34
|
||||
* @功能说明:代理商等级详情
|
||||
*/
|
||||
public function levelInfo($dis){
|
||||
|
||||
$data = $this->where($dis)->find();
|
||||
|
||||
return !empty($data)?$data->toArray():[];
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-05-26 13:28
|
||||
* @功能说明:代理商选择框
|
||||
*/
|
||||
public function levelSelect($dis){
|
||||
|
||||
$data = $this->where($dis)->order('top desc,id desc')->select();
|
||||
|
||||
return !empty($data)?$data->toArray():[];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
152
app/agent/model/AgentList.php
Executable file
152
app/agent/model/AgentList.php
Executable file
@@ -0,0 +1,152 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\agent\model;
|
||||
|
||||
|
||||
use app\BaseModel;
|
||||
use think\facade\Db;
|
||||
|
||||
class AgentList extends BaseModel
|
||||
{
|
||||
protected $name = 'longbing_card_agent_list';
|
||||
|
||||
|
||||
|
||||
protected $append = [
|
||||
|
||||
'status_text',
|
||||
|
||||
'have_count',
|
||||
|
||||
'level_title'
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
* @param $data
|
||||
* @功能说明:代理商等级名字
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-05-26 14:07
|
||||
*/
|
||||
public function getLevelTitleAttr($value,$data){
|
||||
|
||||
if(!empty($data['level'])){
|
||||
|
||||
$level_model = new AgentLevel();
|
||||
|
||||
$dis[] = ['id','=',$data['level']];
|
||||
|
||||
$dis[] = ['status','=',1];
|
||||
|
||||
return $level_model->where($dis)->value('title');
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-05-12 13:54
|
||||
* @功能说明:获取状态
|
||||
*/
|
||||
public function getStatusTextAttr($value,$data){
|
||||
|
||||
if(!empty($data['over_time'])){
|
||||
|
||||
switch ($data['over_time']){
|
||||
|
||||
case $data['over_time']>time():
|
||||
|
||||
return '使用中';
|
||||
|
||||
break;
|
||||
case $data['over_time']<time():
|
||||
|
||||
return '已过期';
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-05-12 14:04
|
||||
* @功能说明:获取已经安装的数量
|
||||
*/
|
||||
public function getHaveCountAttr($value,$data){
|
||||
|
||||
$num = Db::name('longbing_cardauth2_config')->where(['agent_id'=>$data['id']])->count();
|
||||
|
||||
return $num;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-05-12 10:54
|
||||
* @功能说明:代理商列表
|
||||
*/
|
||||
public function agentList($dis,$page=10){
|
||||
|
||||
$list = $this->where($dis)->order('id desc')->paginate($page)->toArray();
|
||||
|
||||
return $list;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-05-12 10:55
|
||||
* @功能说明:添加代理商
|
||||
*/
|
||||
public function agentAdd($data){
|
||||
//创建时间
|
||||
$data['create_time'] = time();
|
||||
//更新时间
|
||||
$data['update_time'] = time();
|
||||
|
||||
$res = $this->insert($data);
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-05-12 10:57
|
||||
* @功能说明:代理商编辑
|
||||
*/
|
||||
public function agentUpdate($dis,$data){
|
||||
|
||||
$data['update_time'] = time();
|
||||
|
||||
$res = $this->where($dis)->update($data);
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-05-12 13:34
|
||||
* @功能说明:代理商详情
|
||||
*/
|
||||
public function agentInfo($dis){
|
||||
|
||||
$data = $this->where($dis)->find();
|
||||
|
||||
return !empty($data)?$data->toArray():[];
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
13
app/agent/model/AppAdminModel.php
Executable file
13
app/agent/model/AppAdminModel.php
Executable file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\agent\model;
|
||||
|
||||
|
||||
use app\BaseModel;
|
||||
|
||||
class AppAdminModel extends BaseModel
|
||||
{
|
||||
protected $name = 'longbing_app_admin';
|
||||
|
||||
}
|
||||
14
app/agent/model/Cardauth2ActivityModel.php
Executable file
14
app/agent/model/Cardauth2ActivityModel.php
Executable file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\agent\model;
|
||||
|
||||
|
||||
use app\BaseModel;
|
||||
|
||||
class Cardauth2ActivityModel extends BaseModel
|
||||
{
|
||||
protected $name = 'longbing_cardauth2_activity';
|
||||
|
||||
|
||||
}
|
||||
19
app/agent/model/Cardauth2ArticleModel.php
Executable file
19
app/agent/model/Cardauth2ArticleModel.php
Executable file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\agent\model;
|
||||
|
||||
|
||||
use app\BaseModel;
|
||||
use app\dynamic\model\CardConfig;
|
||||
|
||||
class Cardauth2ArticleModel extends BaseModel
|
||||
{
|
||||
protected $name = 'longbing_cardauth2_article';
|
||||
|
||||
public function cardConfig()
|
||||
{
|
||||
return $this->hasOne(CardConfig::class, 'uniacid', 'modular_id');
|
||||
}
|
||||
|
||||
}
|
||||
53
app/agent/model/Cardauth2AuthAppModel.php
Executable file
53
app/agent/model/Cardauth2AuthAppModel.php
Executable file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\agent\model;
|
||||
|
||||
|
||||
use app\agent\model\Cardauth2AuthAppModel as Cardauth2Model;
|
||||
use app\BaseModel;
|
||||
|
||||
class Cardauth2AuthAppModel extends BaseModel
|
||||
{
|
||||
protected $name = 'longbing_cardauth2_auth_app';
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-06-04 17:53
|
||||
* @功能说明:获取插件使用数量
|
||||
*/
|
||||
public static function getUseNum($app_name,$is_weiqin){
|
||||
|
||||
|
||||
if($is_weiqin){
|
||||
|
||||
$app_model_name = APP_MODEL_NAME;
|
||||
$count = Cardauth2Model
|
||||
::alias('a')
|
||||
->field(['a.id', 'a.modular_id', 'a. create_time', 'a.sign', 'c.mini_app_name'])
|
||||
->join('longbing_card_config c', 'a.modular_id = c.uniacid')
|
||||
|
||||
->join('account' , 'a.modular_id = account.uniacid')
|
||||
->join('wxapp_versions v' , 'a.modular_id = v.uniacid')
|
||||
|
||||
->where([['a.status', '=', 1],['app_name','like',"%".$app_name ."%"] , ['account.type', '=', 4] ,['account.isdeleted', '=', 0] , ['v.modules', 'like', "%{$app_model_name}%"] ])
|
||||
->group('a.id')
|
||||
->sum('count');
|
||||
|
||||
}else{
|
||||
|
||||
$count = Cardauth2Model
|
||||
::alias('a')
|
||||
->field(['a.id', 'a.modular_id', 'a. create_time', 'a.sign', 'c.mini_app_name'])
|
||||
->join('longbing_card_config c', 'a.modular_id = c.uniacid')
|
||||
->where([['a.status', '=', 1],['app_name','=',$app_name]])
|
||||
->group('a.id')
|
||||
->sum('count');
|
||||
}
|
||||
|
||||
return $count;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
14
app/agent/model/Cardauth2BossModel.php
Executable file
14
app/agent/model/Cardauth2BossModel.php
Executable file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\agent\model;
|
||||
|
||||
|
||||
use app\BaseModel;
|
||||
|
||||
class Cardauth2BossModel extends BaseModel
|
||||
{
|
||||
protected $name = 'longbing_cardauth2_boss';
|
||||
|
||||
|
||||
}
|
||||
18
app/agent/model/Cardauth2ConfigModel.php
Executable file
18
app/agent/model/Cardauth2ConfigModel.php
Executable file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\agent\model;
|
||||
|
||||
|
||||
use app\BaseModel;
|
||||
use app\dynamic\model\CardConfig;
|
||||
|
||||
class Cardauth2ConfigModel extends BaseModel
|
||||
{
|
||||
protected $name = 'longbing_cardauth2_config';
|
||||
|
||||
public function cardConfig()
|
||||
{
|
||||
return $this->hasOne(CardConfig::class, 'uniacid', 'modular_id');
|
||||
}
|
||||
}
|
||||
13
app/agent/model/Cardauth2CopyrightModel.php
Executable file
13
app/agent/model/Cardauth2CopyrightModel.php
Executable file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\agent\model;
|
||||
|
||||
|
||||
use app\BaseModel;
|
||||
|
||||
class Cardauth2CopyrightModel extends BaseModel
|
||||
{
|
||||
protected $name = 'longbing_cardauth2_copyright';
|
||||
|
||||
}
|
||||
68
app/agent/model/Cardauth2DefaultModel.php
Executable file
68
app/agent/model/Cardauth2DefaultModel.php
Executable file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\agent\model;
|
||||
|
||||
|
||||
use app\BaseModel;
|
||||
use think\facade\Db;
|
||||
use think\facade\Env;
|
||||
|
||||
class Cardauth2DefaultModel extends BaseModel
|
||||
{
|
||||
|
||||
protected $name = 'longbing_cardauth2_default';
|
||||
public function getinfo(){
|
||||
$data = $this->order('id','desc')->select()->toArray();
|
||||
if($data){
|
||||
$data = $data[0];
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
public function is_table(){
|
||||
$prefix = config('database.connections.mysql.prefix');
|
||||
$table = $prefix.$this->name;
|
||||
$res = Db::query('SHOW TABLES LIKE '."'".$table."'");
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获得配置值
|
||||
*
|
||||
* @param string|\think\model\concern\string $key
|
||||
* @return int|mixed
|
||||
* @author shuixian
|
||||
* @DataTime: 2020/1/2 22:51
|
||||
*/
|
||||
public function getDefaultValue($key ,$defualt = -1 ){
|
||||
|
||||
$defaultConfig = $this->getinfo();
|
||||
$number = isset($defaultConfig[$key]) ? $defaultConfig[$key] : $defualt ;
|
||||
return $number;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获得名片数量默认配置
|
||||
*
|
||||
* @return array
|
||||
* @author shuixian
|
||||
* @DataTime: 2020/1/2 22:51
|
||||
*/
|
||||
public function getCardNumber(){
|
||||
|
||||
return $this->getDefaultValue('card_number');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取短信群发默认配置
|
||||
*
|
||||
* @return array
|
||||
* @author shuixian
|
||||
* @DataTime: 2020/1/2 22:53
|
||||
*/
|
||||
public function getSendMsg(){
|
||||
return $this->getDefaultValue('send_switch' , 0 );
|
||||
}
|
||||
}
|
||||
14
app/agent/model/Cardauth2HouseModel.php
Executable file
14
app/agent/model/Cardauth2HouseModel.php
Executable file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\agent\model;
|
||||
|
||||
|
||||
use app\BaseModel;
|
||||
|
||||
class Cardauth2HouseModel extends BaseModel
|
||||
{
|
||||
protected $name = 'longbing_cardauth2_house';
|
||||
|
||||
|
||||
}
|
||||
30
app/agent/model/LongbingPlugeKey.php
Executable file
30
app/agent/model/LongbingPlugeKey.php
Executable file
@@ -0,0 +1,30 @@
|
||||
<?PHP
|
||||
|
||||
namespace app\agent\model;
|
||||
use app\BaseModel;
|
||||
|
||||
Class LongbingPlugeKey extends BaseModel
|
||||
{
|
||||
protected $name = 'lb_pluge_key';
|
||||
|
||||
public function getPlugeKey($filter = [])
|
||||
{
|
||||
$result = $this;
|
||||
if(!empty($filter)) $result = $result->where($filter);
|
||||
$result = $result->limit(1)->select();
|
||||
if(!empty($result))
|
||||
{
|
||||
$result = $result->toArray();
|
||||
if(isset($result[0])) $result = $result[0];
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function updatePlugeKey($filter ,$data = [])
|
||||
{
|
||||
$data['update_time'] = time();
|
||||
$result = $this->where($filter)->update($data);
|
||||
return !empty($result);
|
||||
}
|
||||
|
||||
}
|
||||
109
app/agent/model/OssConfig.php
Executable file
109
app/agent/model/OssConfig.php
Executable file
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\agent\model;
|
||||
|
||||
|
||||
use app\BaseModel;
|
||||
use think\facade\Db;
|
||||
|
||||
class OssConfig extends BaseModel
|
||||
{
|
||||
protected $name = 'longbing_oos_config';
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-05-14 09:53
|
||||
* @功能说明:添加配置
|
||||
*/
|
||||
public function configAdd($data){
|
||||
|
||||
$data['create_time'] = time();
|
||||
|
||||
$data['update_time'] = time();
|
||||
|
||||
$data['status'] = 1;
|
||||
|
||||
$data['is_sync'] = 1;
|
||||
|
||||
$res = $this->insert($data);
|
||||
|
||||
return $res;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-05-14 10:02
|
||||
* @功能说明:编辑
|
||||
*/
|
||||
public function configUpdate($dis,$data){
|
||||
|
||||
$data['update_time'] = time();
|
||||
|
||||
$res = $this->where($dis)->update($data);
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-05-14 10:04
|
||||
* @功能说明:列表
|
||||
*/
|
||||
public function configList($dis,$page){
|
||||
|
||||
$data = $this->where($dis)->order('id desc')->paginate($page)->toArray();
|
||||
|
||||
return $data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-05-14 10:15
|
||||
* @功能说明:详情
|
||||
*/
|
||||
public function configInfo($dis){
|
||||
|
||||
$data = $this->where($dis)->find();
|
||||
|
||||
return !empty($data)?$data->toArray():[];
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $dis
|
||||
* @功能说明:删除
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-05-14 10:18
|
||||
*/
|
||||
public function configDel($dis){
|
||||
|
||||
$config_dis = [
|
||||
|
||||
'upload_setting' => $dis['id']
|
||||
|
||||
];
|
||||
|
||||
$info = Db::name('longbing_cardauth2_config')->where($config_dis)->find();
|
||||
|
||||
if(!empty($info)){
|
||||
|
||||
return 200;
|
||||
}
|
||||
|
||||
$res = $this->where($dis)->delete();
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
141
app/agent/route/route.php
Executable file
141
app/agent/route/route.php
Executable file
@@ -0,0 +1,141 @@
|
||||
<?php
|
||||
use think\facade\Route;
|
||||
/**
|
||||
* @model agent
|
||||
* @author yangqi
|
||||
* @create time 2019年11月25日23:09:59
|
||||
*
|
||||
*/
|
||||
Route::get('index', 'Index/index');
|
||||
|
||||
Route::group('admin', function () {
|
||||
Route::post('auth', 'AdminAuthController/auth');
|
||||
Route::get('isWe7', 'AdminAuthController/isWe7');
|
||||
Route::get('unAuth', 'AdminAuthController/unAuth');
|
||||
Route::get('authStatus', 'AdminAuthController/AuthStatus');
|
||||
Route::get('list', 'AdminController/list');
|
||||
Route::post('addSubAdmin', 'AdminController/addSubAdmin');
|
||||
Route::post('updateSubAdmin', 'AdminController/updateSubAdmin');
|
||||
Route::post('delSubAdmin', 'AdminController/delSubAdmin');
|
||||
Route::post('bindApp', 'AdminController/bindApp');
|
||||
//代理商列表
|
||||
Route::any('AgentList/agentList', 'AgentList/agentList');
|
||||
//添加代理商
|
||||
Route::any('AgentList/agentAdd', 'AgentList/agentAdd');
|
||||
//编辑代理商
|
||||
Route::any('AgentList/agentUpdate', 'AgentList/agentUpdate');
|
||||
//代理商详情
|
||||
Route::any('AgentList/agentInfo', 'AgentList/agentInfo');
|
||||
//代理下拉选择框
|
||||
Route::any('AgentList/agentSelect', 'AgentList/agentSelect');
|
||||
//上传配置添加
|
||||
Route::any('OssConfig/configAdd', 'OssConfig/configAdd');
|
||||
//上传配置列表
|
||||
Route::any('OssConfig/configList', 'OssConfig/configList');
|
||||
//上传配置编辑
|
||||
Route::any('OssConfig/configUpdate', 'OssConfig/configUpdate');
|
||||
//上传配置详情
|
||||
Route::any('OssConfig/configInfo', 'OssConfig/configInfo');
|
||||
//上传配置删除
|
||||
Route::any('OssConfig/configDel', 'OssConfig/configDel');
|
||||
//上传配置下拉框
|
||||
Route::any('OssConfig/configSelect', 'OssConfig/configSelect');
|
||||
//添加代理商等级
|
||||
Route::any('AgentLevel/agentAdd', 'AgentLevel/agentAdd');
|
||||
//代理商等级列表
|
||||
Route::any('AgentLevel/levelList', 'AgentLevel/levelList');
|
||||
//代理商等级更新
|
||||
Route::any('AgentLevel/agentUpdate', 'AgentLevel/agentUpdate');
|
||||
//代理商等级详情
|
||||
Route::any('AgentLevel/agentInfo', 'AgentLevel/agentInfo');
|
||||
//代理商等级选择框
|
||||
Route::any('AgentLevel/levelSelect', 'AgentLevel/levelSelect');
|
||||
//删除代理商等级
|
||||
Route::any('AgentLevel/levelDel', 'AgentLevel/levelDel');
|
||||
//删除代理商等级
|
||||
Route::any('getUpgradeInfo', 'AppUpgrade/getUpgradeInfo');
|
||||
//获取当前系统版本和升级信息
|
||||
Route::any('upgrade', 'AppUpgrade/upgrade');
|
||||
//更新管理后台系统
|
||||
Route::any('uploadWxapp', 'AppUpgrade/uploadWxapp');
|
||||
|
||||
});
|
||||
|
||||
Route::group('user' ,function() {
|
||||
Route::post('updatePasswd' ,'UserController/updateSelfPasswd');
|
||||
});
|
||||
|
||||
Route::group('CopyRightAgent', function () {
|
||||
Route::get('list', 'CopyRightAgentController/list');
|
||||
Route::get('getAll', 'CopyRightAgentController/getAll');
|
||||
Route::get('get', 'CopyRightAgentController/get');
|
||||
Route::post('create', 'CopyRightAgentController/create');
|
||||
Route::post('update', 'CopyRightAgentController/update');
|
||||
Route::post('destory', 'CopyRightAgentController/destroy');
|
||||
});
|
||||
|
||||
|
||||
Route::group('ConfigDefault', function () {
|
||||
Route::get('getOne', 'ConfigDefault/getOne');
|
||||
Route::post('update', 'ConfigDefault/update');
|
||||
});
|
||||
|
||||
|
||||
Route::group('Permission', function () {
|
||||
Route::get('getAgentPermission', 'PermissionContrller/getAgentPermission');
|
||||
});
|
||||
|
||||
|
||||
Route::group('MessageConfig', function () {
|
||||
Route::post('delMessageByDay', 'MessageConfigController/delMessageByDay');
|
||||
});
|
||||
|
||||
|
||||
Route::group('AritcleConfig', function () {
|
||||
Route::get('list', 'AritcleController/list');
|
||||
Route::post('create', 'AritcleController/create');
|
||||
Route::post('update', 'AritcleController/update');
|
||||
});
|
||||
|
||||
Route::group('ActivityConfig', function () {
|
||||
Route::get('list', 'ActivityController/list');
|
||||
Route::post('create', 'ActivityController/create');
|
||||
Route::post('extendedOneYear', 'ActivityController/extendedOneYear');
|
||||
});
|
||||
|
||||
|
||||
Route::group('HouseConfig', function () {
|
||||
Route::get('list', 'HouseController/list');
|
||||
Route::post('create', 'HouseController/create');
|
||||
Route::post('extendedOneYear', 'HouseController/extendedOneYear');
|
||||
});
|
||||
|
||||
|
||||
Route::group('BossConfig', function () {
|
||||
Route::get('list', 'BossController/list');
|
||||
Route::post('create', 'BossController/create');
|
||||
Route::post('extendedOneYear', 'BossController/extendedOneYear');
|
||||
});
|
||||
|
||||
|
||||
Route::group('App', function () {
|
||||
Route::get('list$', 'AppController/list');
|
||||
Route::get('get$', 'AppController/get');
|
||||
Route::get('getAuthList$', 'AppController/getAuthList');
|
||||
Route::post('create$', 'AppController/create');
|
||||
Route::post('update$', 'AppController/update');
|
||||
Route::post('delete$', 'AppController/delete');
|
||||
Route::get('getWxApp$', 'AppController/getWxApp');
|
||||
Route::get('isWe7$', 'AppController/isWe7');
|
||||
Route::post('redirectAppBackgroundToken$', 'AppController/redirectAppBackgroundToken');
|
||||
Route::any('websitebind$', 'AppController/websitebind');
|
||||
Route::post('updateApp$' ,'AppController/updateApp');
|
||||
});
|
||||
|
||||
|
||||
//新的授权列表路由
|
||||
Route::group('AdmincardAuth', function () {
|
||||
Route::get('list', 'AdminAuthAppController/list');
|
||||
Route::post('create', 'AdminAuthAppController/create');
|
||||
Route::post('extendedOneYear', 'AdminAuthAppController/extendedOneYear');
|
||||
});
|
||||
160
app/agent/service/AdminUserService.php
Executable file
160
app/agent/service/AdminUserService.php
Executable file
@@ -0,0 +1,160 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | Longbing [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright Chengdu longbing Technology Co., Ltd.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Website http://longbing.org/
|
||||
// +----------------------------------------------------------------------
|
||||
// | Sales manager: +86-13558882532 / +86-13330887474
|
||||
// | Technical support: +86-15680635005
|
||||
// | After-sale service: +86-17361005938
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\agent\service;
|
||||
|
||||
|
||||
use app\agent\model\AdminModel;
|
||||
use app\agent\model\AdminRoleModel;
|
||||
use app\agent\model\AppAdminModel;
|
||||
|
||||
class AdminUserService
|
||||
{
|
||||
|
||||
/**
|
||||
* 新增管理员
|
||||
*
|
||||
* @param $uniacid
|
||||
* @param $input
|
||||
* @return bool
|
||||
* @author shuixian
|
||||
* @DataTime: 2019/12/31 18:46
|
||||
*/
|
||||
public static function addAdminUser($uniacid , $input){
|
||||
|
||||
/**
|
||||
* @var AdminModel $subAdmin
|
||||
*/
|
||||
$subAdmin = AdminModel::where([['account', '=', $input['account']], ['status', '=', 1]])->findOrEmpty();
|
||||
if (!$subAdmin->isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$offset = createOffset();
|
||||
$new = [
|
||||
'admin_id' => $input['uuid'],
|
||||
'account' => $input['account'],
|
||||
'uniacid' => $uniacid ,
|
||||
'offset' => $offset,
|
||||
'passwd' => createPasswd($input['passwd'], $offset),
|
||||
'role_id' => $input['role_id'],
|
||||
'creator_id' => $input['admin_id'],
|
||||
'status' => 1,
|
||||
];
|
||||
$rst = $subAdmin->save($new);
|
||||
if (!$rst) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化默认角色
|
||||
*
|
||||
* @throws \Exception
|
||||
* @author shuixian
|
||||
* @DataTime: 2019/12/31 18:46
|
||||
*/
|
||||
public static function initDefaultRole(){
|
||||
|
||||
$adminRole = new AdminRoleModel();
|
||||
$data = [] ;
|
||||
if(!$adminRole->where(['role_id'=> 'e1af223e997011e997cb77d35351cc48'])->count()){
|
||||
|
||||
|
||||
$data[] = [
|
||||
'role_id' =>'e1af223e997011e997cb77d35351cc48',
|
||||
'role_name' =>'admin',
|
||||
'description' =>'超级管理员',
|
||||
'create_time' =>null,
|
||||
'update_time' =>null,
|
||||
'delete_time' =>null,
|
||||
'deleted' =>'0',
|
||||
'uniacid' =>'8888',
|
||||
|
||||
];
|
||||
|
||||
}
|
||||
if(!$adminRole->where(['role_id'=> 'e7d81116997011e99b985595a87cbdcb'])->count()) {
|
||||
$data[] = [
|
||||
'role_id' => 'e7d81116997011e99b985595a87cbdcb',
|
||||
'role_name' => 'user',
|
||||
'description' => '普通用户',
|
||||
'create_time' => null,
|
||||
'update_time' => null,
|
||||
'delete_time' => null,
|
||||
'deleted' => '0',
|
||||
'uniacid' => '8888',
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
$adminRole->saveAll($data);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定小程序管理员
|
||||
*
|
||||
* @param $data
|
||||
* @author shuixian
|
||||
* @DataTime: 2019/12/31 18:49
|
||||
*/
|
||||
public static function bindAppAdmin($data){
|
||||
|
||||
if(AppAdminModel::where(['id'=> $data['id']])->count()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$appAdmin = new AppAdminModel();
|
||||
|
||||
$appAdmin->save($data) ;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $app_name
|
||||
* @功能说明:获取授权数量
|
||||
* @author chenniang
|
||||
* @DataTime: 2020-01-03 11:19
|
||||
*/
|
||||
public static function getSassNum($key,$uniacid){
|
||||
//类名
|
||||
$className = 'Permission' . ucfirst($key);
|
||||
//类路径
|
||||
$permissionPath = APP_PATH . $key . '/info/' . $className . '.php';
|
||||
|
||||
// dump(file_exists($permissionPath),$permissionPath);exit;
|
||||
$num = 0;
|
||||
if (file_exists($permissionPath) && require_once($permissionPath)) {
|
||||
|
||||
|
||||
|
||||
//实例文件名
|
||||
$permissionClassName = 'app\\' . $key . '\\info\\'. $className;
|
||||
|
||||
$permission = new $permissionClassName($uniacid);
|
||||
//获取授权数量
|
||||
$num = $permission->getAuthNumber();
|
||||
}
|
||||
return $num;
|
||||
}
|
||||
|
||||
}
|
||||
27
app/agent/validate/AgentAdminValidate.php
Executable file
27
app/agent/validate/AgentAdminValidate.php
Executable file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\agent\validate;
|
||||
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class AgentAdminValidate extends Validate
|
||||
{
|
||||
|
||||
protected $rule = [
|
||||
'admin_id' => ['require'],
|
||||
'status' => ['require','number', 'in' => [-1, 0, 1]],
|
||||
'account|名字' => ['require'],
|
||||
'passwd|密码' => [ 'require'],
|
||||
];
|
||||
|
||||
protected $scene = [
|
||||
'addSubAdmin' => ['account', 'passwd'],
|
||||
'updateSubAdmin' => ['passwd'],
|
||||
'delSubAdmin' => ['admin_id']
|
||||
];
|
||||
|
||||
|
||||
|
||||
}
|
||||
21
app/agent/validate/Cardauth2ArticleValidate.php
Executable file
21
app/agent/validate/Cardauth2ArticleValidate.php
Executable file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\agent\validate;
|
||||
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class Cardauth2ArticleValidate extends Validate
|
||||
{
|
||||
protected $rule = [
|
||||
'modular_id' => 'require|number|gt:0',
|
||||
'number|获客文章数量' => 'require|integer|egt:0',
|
||||
];
|
||||
|
||||
protected $scene = [
|
||||
'create' => ['number', 'modular_id'],
|
||||
];
|
||||
|
||||
|
||||
}
|
||||
62
app/agent/validate/Cardauth2ConfigValidate.php
Executable file
62
app/agent/validate/Cardauth2ConfigValidate.php
Executable file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\agent\validate;
|
||||
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class Cardauth2ConfigValidate extends Validate
|
||||
{
|
||||
|
||||
protected $rule = [
|
||||
'id' => 'require|number|gt:0',
|
||||
'number|名片数量' => 'require|integer|egt:0',
|
||||
'end_time|到期时间' => 'require|integer',
|
||||
'copyright_id|版权id' => 'require|integer',
|
||||
'send_switch' => 'require|integer',
|
||||
'boss|BOSS数量' => 'require|integer|egt:0',
|
||||
// 'appiont' =>'require|integer',
|
||||
'payqr' =>'require|integer',
|
||||
'shop_switch' => 'require|integer',
|
||||
'timeline_switch' => 'require|integer',
|
||||
'website_switch' => 'require|integer',
|
||||
'article' => 'require|integer',
|
||||
// 'activity_switch' => 'require|integer',
|
||||
'pay_shop' => 'require|integer',
|
||||
'house_switch' => 'require|integer',
|
||||
// 'tool_switch' => 'require|integer',
|
||||
];
|
||||
|
||||
protected $scene = [
|
||||
'create' => ['number', 'end_time', 'copyright_id', 'send_switch',
|
||||
'boss', 'appiont', 'payqr', 'shop_switch', 'timeline_switch',
|
||||
'website_switch', 'article', 'activity', 'pay_shop' ,
|
||||
'house_switch'],
|
||||
'delete' => ['id']
|
||||
];
|
||||
|
||||
|
||||
public function sceneUpdate()
|
||||
{
|
||||
return $this->only(['id','number', 'end_time', 'copyright_id', 'send_switch',
|
||||
'boss', 'appiont', 'payqr', 'shop_switch', 'timeline_switch',
|
||||
'website_switch', 'article', 'activity', 'pay_shop' ,
|
||||
'house_switch', 'tool_switch'])
|
||||
->remove('number', 'require')
|
||||
->remove('end_time', 'require')
|
||||
->remove('copyright_id', 'require')
|
||||
->remove('boss', 'require')
|
||||
->remove('appiont', 'require')
|
||||
->remove('payqr', 'require')
|
||||
->remove('shop_switch', 'require')
|
||||
->remove('timeline_switch', 'require')
|
||||
->remove('website_switch', 'require')
|
||||
->remove('article', 'require')
|
||||
->remove('activity', 'require')
|
||||
->remove('pay_shop', 'require')
|
||||
->remove('house_switch', 'require')
|
||||
->remove('tool_switch', 'require');
|
||||
}
|
||||
|
||||
}
|
||||
34
app/agent/validate/CopyRightAgentValidate.php
Executable file
34
app/agent/validate/CopyRightAgentValidate.php
Executable file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace app\agent\validate;
|
||||
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class CopyRightAgentValidate extends Validate
|
||||
{
|
||||
protected $rule = [
|
||||
'id' => ['require','number', '>=' => 1],
|
||||
'status' => ['require','number', 'in' => [-1, 0, 1]],
|
||||
'name|名称' => ['require'],
|
||||
'image|版权图片' => [ 'require', 'length' => '10,500'],
|
||||
'text|版权文字' => ['require'],
|
||||
'phone|联系号码' => ['require', 'length' => '8,20'],
|
||||
];
|
||||
|
||||
protected $scene = [
|
||||
'create' => ['name', 'image', 'text', 'phone'],
|
||||
'get' => ['id'],
|
||||
'destroy' => ['id']
|
||||
];
|
||||
|
||||
|
||||
public function sceneUpdate()
|
||||
{
|
||||
return $this->only(['id', 'image','phone'])
|
||||
->remove('image', 'require')
|
||||
->remove('phone', 'require');
|
||||
}
|
||||
|
||||
}
|
||||
26
app/agent/view/index/index.html
Executable file
26
app/agent/view/index/index.html
Executable file
@@ -0,0 +1,26 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset=utf-8>
|
||||
<meta name="renderer" content="webkit"/>
|
||||
<meta name="force-rendering" content="webkit"/>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1"/>
|
||||
<meta name=viewport content="width=device-width,initial-scale=1">
|
||||
<title>代理管理端</title>
|
||||
<link href='{$appcss}' rel=stylesheet>
|
||||
</head>
|
||||
<body>
|
||||
<div id=app></div>
|
||||
<script>
|
||||
var lbConfig = {
|
||||
jsPath: '{$jsPath}',
|
||||
isWe7: '{$isWe7}',
|
||||
is_founder: '{$is_founder}'
|
||||
}
|
||||
window.lbConfig = lbConfig;
|
||||
</script>
|
||||
<script type=text/javascript src='{$manifest}'></script>
|
||||
<script type=text/javascript src='{$vendor}'></script>
|
||||
<script type=text/javascript src='{$app}'></script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user