16
This commit is contained in:
@@ -21,7 +21,7 @@ class ArticleController extends BaseController{
|
|||||||
$limit = (int)input('limit',10);
|
$limit = (int)input('limit',10);
|
||||||
$category_id = (int)input('category_id',0);
|
$category_id = (int)input('category_id',0);
|
||||||
|
|
||||||
$model = ArchivesModel::where('status','1')->where('type','article');
|
$model = ArchivesModel::where('status','normal')->where('type','article');
|
||||||
if($category_id){
|
if($category_id){
|
||||||
$model = $model->where('category_id',$category_id);
|
$model = $model->where('category_id',$category_id);
|
||||||
}
|
}
|
||||||
@@ -29,7 +29,7 @@ class ArticleController extends BaseController{
|
|||||||
$user_id=0;
|
$user_id=0;
|
||||||
try {
|
try {
|
||||||
$user_id = \support\Jwt\JwtToken::getCurrentId();
|
$user_id = \support\Jwt\JwtToken::getCurrentId();
|
||||||
} catch (\Throwable $th) {
|
} catch (\Exception $e) {
|
||||||
}
|
}
|
||||||
$list->each(function($item)use($user_id){
|
$list->each(function($item)use($user_id){
|
||||||
if(!$user_id){
|
if(!$user_id){
|
||||||
@@ -51,7 +51,7 @@ class ArticleController extends BaseController{
|
|||||||
$limit = (int)input('limit',10);
|
$limit = (int)input('limit',10);
|
||||||
$model = ArchivesModel::alias('a')
|
$model = ArchivesModel::alias('a')
|
||||||
->join('content c', 'a.id = c.id')
|
->join('content c', 'a.id = c.id')
|
||||||
->where('a.status','1')
|
->where('a.status','normal')
|
||||||
->where('a.type','article')
|
->where('a.type','article')
|
||||||
->where('a.category_id',9);
|
->where('a.category_id',9);
|
||||||
$list = $model->Field('a.title,a.id,c.content')->order('a.id','desc')->paginate($limit);
|
$list = $model->Field('a.title,a.id,c.content')->order('a.id','desc')->paginate($limit);
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ class BalanceLogController extends BaseController{
|
|||||||
$list->each(function($item)use($BalanceTypeList){
|
$list->each(function($item)use($BalanceTypeList){
|
||||||
if($item->type == \app\enum\BalanceType::TRANSFER->value && $item->memo){
|
if($item->type == \app\enum\BalanceType::TRANSFER->value && $item->memo){
|
||||||
$item['target'] = UserModel::where('id',$item->memo)->value('username');
|
$item['target'] = UserModel::where('id',$item->memo)->value('username');
|
||||||
$item->memo = idEncode($item->memo);
|
$item->memo = \support\Encrypt::userIDencode($item->memo);
|
||||||
}
|
}
|
||||||
$item->_type= $item->type;
|
$item->_type= $item->type;
|
||||||
$item->type= $BalanceTypeList[$item->type];
|
$item->type= $BalanceTypeList[$item->type];
|
||||||
|
|||||||
@@ -284,7 +284,6 @@ class CommonController extends BaseController{
|
|||||||
try{
|
try{
|
||||||
$user = \support\Jwt::getUser();
|
$user = \support\Jwt::getUser();
|
||||||
}catch(\Exception $e){
|
}catch(\Exception $e){
|
||||||
//log_alert($e->getMessage());
|
|
||||||
$user = false;
|
$user = false;
|
||||||
}
|
}
|
||||||
if($user){
|
if($user){
|
||||||
@@ -341,7 +340,6 @@ class CommonController extends BaseController{
|
|||||||
try{
|
try{
|
||||||
$user = \support\Jwt::getUser();
|
$user = \support\Jwt::getUser();
|
||||||
}catch(\Exception $e){
|
}catch(\Exception $e){
|
||||||
log_alert($e->getMessage());
|
|
||||||
$user = false;
|
$user = false;
|
||||||
}
|
}
|
||||||
if($user){
|
if($user){
|
||||||
@@ -362,7 +360,6 @@ class CommonController extends BaseController{
|
|||||||
//模拟一次登录,需不需要充值登录信息?????
|
//模拟一次登录,需不需要充值登录信息?????
|
||||||
//\support\Jwt::direct($user->id);
|
//\support\Jwt::direct($user->id);
|
||||||
try{
|
try{
|
||||||
log_alert($user->id.' 重置交易密码'.$newpassword);
|
|
||||||
UserModel::where('id',$user->id)->save([
|
UserModel::where('id',$user->id)->save([
|
||||||
'trade_password' => \plugin\admin\app\common\Util::passwordHash($newpassword)
|
'trade_password' => \plugin\admin\app\common\Util::passwordHash($newpassword)
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ class ContactController extends BaseController{
|
|||||||
{
|
{
|
||||||
$current_user = \support\Jwt::getUser();
|
$current_user = \support\Jwt::getUser();
|
||||||
$user_id = $current_user->id;
|
$user_id = $current_user->id;
|
||||||
$userID = idEncode($user_id);
|
$userID = \support\Encrypt::userIDencode($user_id);
|
||||||
$res = $request->IM->friend()->getFriendList($userID,1,10000);
|
$res = $request->IM->friend()->getFriendList($userID,1,10000);
|
||||||
return $this->success('ok',$res['data']['friendsInfo']);
|
return $this->success('ok',$res['data']['friendsInfo']);
|
||||||
}
|
}
|
||||||
@@ -46,8 +46,7 @@ class ContactController extends BaseController{
|
|||||||
if(!$userID){
|
if(!$userID){
|
||||||
return $this->error('UserID is Empty');
|
return $this->error('UserID is Empty');
|
||||||
}
|
}
|
||||||
$userID = idDecode($userID);
|
$res = \app\model\User::where('userID',$userID)->find();
|
||||||
$res = \app\model\User::where('id',$userID)->find();
|
|
||||||
return $this->success('ok',$res);
|
return $this->success('ok',$res);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@@ -61,11 +60,6 @@ class ContactController extends BaseController{
|
|||||||
if(!$userIDs){
|
if(!$userIDs){
|
||||||
return $this->error('UserID is Empty');
|
return $this->error('UserID is Empty');
|
||||||
}
|
}
|
||||||
//$userIDs = explode(',',$userIDs);
|
|
||||||
//$userIDs = idDecode($userIDs);
|
|
||||||
//$current_user = \support\Jwt::getUser();
|
|
||||||
//$user_id = $current_user->id;
|
|
||||||
//$userID = idEncode($user_id);
|
|
||||||
$res = \app\model\User::whereIn('userID',$userIDs)->select();
|
$res = \app\model\User::whereIn('userID',$userIDs)->select();
|
||||||
return $this->success('ok',$res);
|
return $this->success('ok',$res);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class FriendCircleController extends BaseController{
|
|||||||
function info(Request $request): Response{
|
function info(Request $request): Response{
|
||||||
$user_id = Input('user_id');
|
$user_id = Input('user_id');
|
||||||
if($user_id){
|
if($user_id){
|
||||||
$user_id = idDecode($user_id);
|
$user_id = \support\Encrypt::userIDDecode($user_id);
|
||||||
$json= [
|
$json= [
|
||||||
'top_unread_items' =>[],
|
'top_unread_items' =>[],
|
||||||
'unread_item_ids' =>[],
|
'unread_item_ids' =>[],
|
||||||
@@ -84,7 +84,7 @@ class FriendCircleController extends BaseController{
|
|||||||
$limit = (int)Input('limit', 10);
|
$limit = (int)Input('limit', 10);
|
||||||
$user_id = Input('user_id', 0);
|
$user_id = Input('user_id', 0);
|
||||||
if($user_id){
|
if($user_id){
|
||||||
$user_id = idDecode($user_id);
|
$user_id = \support\Encrypt::userIDDecode($user_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
$query = FriendCircleModel::where('status', 1)
|
$query = FriendCircleModel::where('status', 1)
|
||||||
@@ -393,7 +393,7 @@ class FriendCircleController extends BaseController{
|
|||||||
$cache_key = 'friend_id_list_'.$user_id;
|
$cache_key = 'friend_id_list_'.$user_id;
|
||||||
$result = cache($cache_key) ?: [];
|
$result = cache($cache_key) ?: [];
|
||||||
if(count($result) === 0){
|
if(count($result) === 0){
|
||||||
$res = request()->IM->friend->getFriendList(idEncode($user_id));
|
$res = request()->IM->friend->getFriendList(\support\Encrypt::userIDencode($user_id));
|
||||||
$friendsInfo = $res['friendsInfo'];
|
$friendsInfo = $res['friendsInfo'];
|
||||||
foreach($friendsInfo as $k=>$v){
|
foreach($friendsInfo as $k=>$v){
|
||||||
array_push($result,$v['friendUser']['userID']);
|
array_push($result,$v['friendUser']['userID']);
|
||||||
|
|||||||
@@ -29,8 +29,6 @@ class GroupController extends BaseController
|
|||||||
$offset = $request->post('offset',0);
|
$offset = $request->post('offset',0);
|
||||||
$group_id = $request->post('groupID') ?:$request->post('group_id');
|
$group_id = $request->post('groupID') ?:$request->post('group_id');
|
||||||
//$ls = $this->get_user_in_group($group_id);
|
//$ls = $this->get_user_in_group($group_id);
|
||||||
//log_alert($ls);
|
|
||||||
log_alert([$offset,$group_id,$limit]);
|
|
||||||
$list = AlbumModel::where('group_id',$group_id)
|
$list = AlbumModel::where('group_id',$group_id)
|
||||||
->where('id','<',$offset)
|
->where('id','<',$offset)
|
||||||
->order('id','desc')
|
->order('id','desc')
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ class MessageController extends BaseController{
|
|||||||
*/
|
*/
|
||||||
function delete(Request $request):Response{
|
function delete(Request $request):Response{
|
||||||
$im = $request->IM;
|
$im = $request->IM;
|
||||||
$data = $im->message->sendBusinessNotification('system',idEncode(100007),[
|
$data = $im->message->sendBusinessNotification('system',\support\Encrypt::userIDencode(100007),[
|
||||||
'contentType' => 101,
|
'contentType' => 101,
|
||||||
'textElem' => [
|
'textElem' => [
|
||||||
'content' => '欢迎使用4'.Config('site.name')
|
'content' => '欢迎使用4'.Config('site.name')
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ class RechargeController extends BaseController{
|
|||||||
return $this->error(__('Failed to create recharge order, please try again later'));
|
return $this->error(__('Failed to create recharge order, please try again later'));
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
$sign = aesencode(json_encode($data));
|
$sign = \support\Encrypt::aesencode(json_encode($data));
|
||||||
return $this->success(__('successful'),[
|
return $this->success(__('successful'),[
|
||||||
'order' => [
|
'order' => [
|
||||||
'id' => 0,
|
'id' => 0,
|
||||||
@@ -306,7 +306,7 @@ class RechargeController extends BaseController{
|
|||||||
* @Apidoc\NotDebug()
|
* @Apidoc\NotDebug()
|
||||||
*/
|
*/
|
||||||
public function notify(){
|
public function notify(){
|
||||||
$data = aesdecode(input('data'));
|
$data = \support\Encrypt::aesdecode(input('data'));
|
||||||
$data = json_decode($data,true);
|
$data = json_decode($data,true);
|
||||||
/** @var RechargeModel $vo */
|
/** @var RechargeModel $vo */
|
||||||
$vo = RechargeModel::where('id',$data['out_trade_no'])->find();
|
$vo = RechargeModel::where('id',$data['out_trade_no'])->find();
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ class TeamController extends BaseController{
|
|||||||
->join('user_extend ue', 'u.id = ue.user_id')
|
->join('user_extend ue', 'u.id = ue.user_id')
|
||||||
->where('u.parent_id', $user['id'])
|
->where('u.parent_id', $user['id'])
|
||||||
//->where('ue.active', 1)
|
//->where('ue.active', 1)
|
||||||
->field('u.id, u.username,u.money,u.score,u.role_id, u.group,u.avatar, u.created_at')
|
->field('u.id,u.userID, u.username,u.money,u.score,u.role_id, u.group,u.avatar, u.created_at')
|
||||||
->order('u.created_at desc');
|
->order('u.created_at desc');
|
||||||
if($kw){
|
if($kw){
|
||||||
$model = $model->whereLike("u.username",'%'.$kw.'%');
|
$model = $model->whereLike("u.username",'%'.$kw.'%');
|
||||||
@@ -161,7 +161,6 @@ class TeamController extends BaseController{
|
|||||||
$result['data'][$k]['direct_total'] = cache('team_direct_total_'.$item['id'])??0;
|
$result['data'][$k]['direct_total'] = cache('team_direct_total_'.$item['id'])??0;
|
||||||
$result['data'][$k]['role'] = isset($role_arr[$item['role_id']]) ? $role_arr[$item['role_id']] : __('普通用户');
|
$result['data'][$k]['role'] = isset($role_arr[$item['role_id']]) ? $role_arr[$item['role_id']] : __('普通用户');
|
||||||
//$result['data'][$k]['questionnaire_count'] = WorkRecordModel::where('user_id',$item['id'])->count('id');
|
//$result['data'][$k]['questionnaire_count'] = WorkRecordModel::where('user_id',$item['id'])->count('id');
|
||||||
$result['data'][$k]['id'] = idEncode($item['id']);
|
|
||||||
//return $item;
|
//return $item;
|
||||||
}
|
}
|
||||||
return $this->success(__('successful'),$result);
|
return $this->success(__('successful'),$result);
|
||||||
@@ -176,7 +175,7 @@ class TeamController extends BaseController{
|
|||||||
$user = \support\Jwt::getUser();
|
$user = \support\Jwt::getUser();
|
||||||
$id = $request->post('id');
|
$id = $request->post('id');
|
||||||
$level = $request->post('level');
|
$level = $request->post('level');
|
||||||
$id = idDecode($id);
|
$id = \support\Encrypt::userIDDecode($id);
|
||||||
if(!$id || !$level){
|
if(!$id || !$level){
|
||||||
return $this->error(__('Invalid parameters'));
|
return $this->error(__('Invalid parameters'));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -160,7 +160,6 @@ class UserController extends BaseController{
|
|||||||
'idcard' => Input('idcard'),
|
'idcard' => Input('idcard'),
|
||||||
'user_id' => $user->id,
|
'user_id' => $user->id,
|
||||||
];
|
];
|
||||||
log_alert($data);
|
|
||||||
if(!$data['realname'] || !$data['idcard']){
|
if(!$data['realname'] || !$data['idcard']){
|
||||||
return $this->error(__('Incoret param'));
|
return $this->error(__('Incoret param'));
|
||||||
}
|
}
|
||||||
@@ -201,12 +200,13 @@ class UserController extends BaseController{
|
|||||||
if(is_string($ids)){
|
if(is_string($ids)){
|
||||||
$ids = explode(',',$ids);
|
$ids = explode(',',$ids);
|
||||||
}
|
}
|
||||||
$userIDs = array_map('idDecode',$ids);
|
//$userIDs = array_map('\support\Encrypt::userIDDecode',$ids);
|
||||||
//$res = $request->IM->user->getUsersInfo($userIDs);
|
//$res = $request->IM->user->getUsersInfo($userIDs);
|
||||||
$list = Db::name('user')->
|
$list = Db::name('user')->
|
||||||
whereIn('id',$userIDs)
|
whereIn('userID',$ids)
|
||||||
->paginate(Input('limit',10));
|
->paginate(Input('limit',10));
|
||||||
$list->each(function($user){
|
$list->each(function($user){
|
||||||
|
$user['id'] = $user['userID'];
|
||||||
unset($user['password']);
|
unset($user['password']);
|
||||||
unset($user['trade_password']);
|
unset($user['trade_password']);
|
||||||
//unset($user['avatar']);
|
//unset($user['avatar']);
|
||||||
@@ -241,9 +241,9 @@ class UserController extends BaseController{
|
|||||||
{
|
{
|
||||||
$keyword = Input('keyword');
|
$keyword = Input('keyword');
|
||||||
$searchtype = Input('searchtype');
|
$searchtype = Input('searchtype');
|
||||||
$fields = 'id,avatar,username,nickname,avatar,sex,email,mobile,birthday,bio';
|
$fields = 'userID,avatar,username,nickname,avatar,sex,email,mobile,birthday,bio';
|
||||||
$model = Db::name('user')->field($fields)->where('status',1);
|
$model = Db::name('user')->field($fields)->where('status',1);
|
||||||
$model = $model->where('id',idDecode($keyword));
|
$model = $model->where('userID',$keyword);
|
||||||
// if($searchtype =='id'){
|
// if($searchtype =='id'){
|
||||||
// $model = $model->where('id',$keyword);
|
// $model = $model->where('id',$keyword);
|
||||||
// }else{
|
// }else{
|
||||||
@@ -251,10 +251,9 @@ class UserController extends BaseController{
|
|||||||
// }
|
// }
|
||||||
$list = $model->paginate(Input('limit',10));
|
$list = $model->paginate(Input('limit',10));
|
||||||
$list->each(function ($item){
|
$list->each(function ($item){
|
||||||
$item['id'] = idEncode($item['id']);
|
$item['id'] = $item['userID'];
|
||||||
return $item;
|
return $item;
|
||||||
});
|
});
|
||||||
//log_alert($list->toArray());
|
|
||||||
return $this->success('ok',$list);
|
return $this->success('ok',$list);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -88,7 +88,7 @@ class WalletController extends BaseController{
|
|||||||
if(str_contains($username,'@')){
|
if(str_contains($username,'@')){
|
||||||
$to_user = UserModel::where('username',$username)->find();
|
$to_user = UserModel::where('username',$username)->find();
|
||||||
}else{
|
}else{
|
||||||
$to_user_id = idDecode($username);
|
$to_user_id = \support\Encrypt::userIDDecode($username);
|
||||||
$to_user = UserModel::where('id',$to_user_id)->find();
|
$to_user = UserModel::where('id',$to_user_id)->find();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ class WithdrawlController extends BaseController{
|
|||||||
* @Apidoc\NotDebug()
|
* @Apidoc\NotDebug()
|
||||||
*/
|
*/
|
||||||
public function notify(){
|
public function notify(){
|
||||||
$data = aesdecode(input('data',''));
|
$data = \support\Encrypt::aesdecode(input('data',''));
|
||||||
$data = json_decode($data,true);
|
$data = json_decode($data,true);
|
||||||
/** @var WithdrawlModel $vo */
|
/** @var WithdrawlModel $vo */
|
||||||
$vo = WithdrawlModel::where('id',$data['out_trade_no'])->find();
|
$vo = WithdrawlModel::where('id',$data['out_trade_no'])->find();
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ class Auth implements MiddlewareInterface
|
|||||||
// $data = str_replace('%3D','=',$data);
|
// $data = str_replace('%3D','=',$data);
|
||||||
// $data = str_replace(' ','+',$data);
|
// $data = str_replace(' ','+',$data);
|
||||||
// //var_dump($data);
|
// //var_dump($data);
|
||||||
// $data = aesdecode($data);
|
// $data = \support\Encrypt::aesdecode($data);
|
||||||
// $data = json_decode($data,true);
|
// $data = json_decode($data,true);
|
||||||
// //var_dump($data);
|
// //var_dump($data);
|
||||||
// $request->withBody($data);
|
// $request->withBody($data);
|
||||||
@@ -135,7 +135,7 @@ class Auth implements MiddlewareInterface
|
|||||||
request()->path()
|
request()->path()
|
||||||
],$response->rawBody());
|
],$response->rawBody());
|
||||||
// if($request->app=="api" && $request->client!='web'){
|
// if($request->app=="api" && $request->client!='web'){
|
||||||
// $body = aesencode($body);
|
// $body = \support\Encrypt::aesencode($body);
|
||||||
// }
|
// }
|
||||||
$response->withHeaders($headers)->withBody($body)->getStatusCode();
|
$response->withHeaders($headers)->withBody($body)->getStatusCode();
|
||||||
$time = microtime() - $request->start_time;
|
$time = microtime() - $request->start_time;
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ class OpenIm extends Command
|
|||||||
private function change_user(InputInterface $input, OutputInterface $output):int{
|
private function change_user(InputInterface $input, OutputInterface $output):int{
|
||||||
|
|
||||||
$im = $this->getSdk();
|
$im = $this->getSdk();
|
||||||
$data = $im->user->updateUserInfo(idEncode('100006'),['userInfo'=>['userId'=>'wx100001']]);
|
$data = $im->user->updateUserInfo(\support\Encrypt::userIDencode('100006'),['userInfo'=>['userId'=>'wx100001']]);
|
||||||
cp($data);
|
cp($data);
|
||||||
return self::SUCCESS;
|
return self::SUCCESS;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ class User extends Command
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$user = \support\Jwt::direct($user_id);
|
$user = \support\Jwt::direct($user_id);
|
||||||
$imToken = $IM->auth->getUserToken(idEncode($user['id']),2);
|
$imToken = $IM->auth->getUserToken($user['userID'],2);
|
||||||
cp('userID:' . $user['id']);
|
cp('userID:' . $user['id']);
|
||||||
cp('nickname:' . $user['nickname']);
|
cp('nickname:' . $user['nickname']);
|
||||||
cp('token:' . $user['token']);
|
cp('token:' . $user['token']);
|
||||||
|
|||||||
@@ -59,7 +59,6 @@ class GitController
|
|||||||
$script_fn = 'wjb_cdkey.sh';
|
$script_fn = 'wjb_cdkey.sh';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//log_alert($script_fn);
|
|
||||||
if(!$script_fn){
|
if(!$script_fn){
|
||||||
return response('Not main branch', 200);
|
return response('Not main branch', 200);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -179,6 +179,7 @@ class HookController{
|
|||||||
//执行顺序,callbackBeforeCreateGroupCommand -> callbackBeforeMembersJoinGroupCommand -> callbackAfterCreateGroupCommand
|
//执行顺序,callbackBeforeCreateGroupCommand -> callbackBeforeMembersJoinGroupCommand -> callbackAfterCreateGroupCommand
|
||||||
public function callbackbeforeCreateGroupCommand(Request $request): Response
|
public function callbackbeforeCreateGroupCommand(Request $request): Response
|
||||||
{
|
{
|
||||||
|
return $this->success();
|
||||||
$groupID = Input('groupID');
|
$groupID = Input('groupID');
|
||||||
$creatorUserID = Input('creatorUserID');
|
$creatorUserID = Input('creatorUserID');
|
||||||
$key = 'user_'.$creatorUserID.'_create_group_count';
|
$key = 'user_'.$creatorUserID.'_create_group_count';
|
||||||
@@ -244,7 +245,7 @@ class HookController{
|
|||||||
//群成员进群之前的回调
|
//群成员进群之前的回调
|
||||||
public function callbackBeforeMembersJoinGroupCommand(Request $request):Response
|
public function callbackBeforeMembersJoinGroupCommand(Request $request):Response
|
||||||
{
|
{
|
||||||
log_alert(Input());
|
return $this->success();
|
||||||
$groupID = Input('groupID');
|
$groupID = Input('groupID');
|
||||||
$memberList = Input('memberList');
|
$memberList = Input('memberList');
|
||||||
$ownerID = $this->getGroupOwner($groupID);
|
$ownerID = $this->getGroupOwner($groupID);
|
||||||
@@ -294,6 +295,7 @@ class HookController{
|
|||||||
//执行顺序,callbackBeforeInviteJoinGroupCommand -> callbackBeforeMembersJoinGroupCommand
|
//执行顺序,callbackBeforeInviteJoinGroupCommand -> callbackBeforeMembersJoinGroupCommand
|
||||||
public function callbackBeforeInviteJoinGroupCommand(Request $request):Response
|
public function callbackBeforeInviteJoinGroupCommand(Request $request):Response
|
||||||
{
|
{
|
||||||
|
return $this->success();
|
||||||
$groupID = Input('groupID');
|
$groupID = Input('groupID');
|
||||||
$invitedUserIDs = Input('invitedUserIDs');
|
$invitedUserIDs = Input('invitedUserIDs');
|
||||||
//获取群组当前用户数量
|
//获取群组当前用户数量
|
||||||
@@ -313,6 +315,7 @@ class HookController{
|
|||||||
//申请加入群组之前的回调
|
//申请加入群组之前的回调
|
||||||
public function callbackBeforeJoinGroupCommand(Request $request):Response
|
public function callbackBeforeJoinGroupCommand(Request $request):Response
|
||||||
{
|
{
|
||||||
|
return $this->success();
|
||||||
$groupID = Input('groupID');
|
$groupID = Input('groupID');
|
||||||
$applyID = Input('applyID');
|
$applyID = Input('applyID');
|
||||||
//获取群组当前用户数量
|
//获取群组当前用户数量
|
||||||
|
|||||||
@@ -139,13 +139,13 @@ class Product{
|
|||||||
if($this->debug){
|
if($this->debug){
|
||||||
return print_r($str);
|
return print_r($str);
|
||||||
}
|
}
|
||||||
\support\Log::channel('product_buy')->alert($str);
|
log_alert($str);
|
||||||
}else{
|
}else{
|
||||||
$str = json_encode($args);
|
$str = json_encode($args);
|
||||||
if($this->debug){
|
if($this->debug){
|
||||||
return print_r($str);
|
return print_r($str);
|
||||||
}
|
}
|
||||||
\support\Log::channel('product_buy')->alert($str);
|
log_alert($str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+1
-1
@@ -9,7 +9,7 @@ class User{
|
|||||||
cache_add('statistics_register_'.$date,1);
|
cache_add('statistics_register_'.$date,1);
|
||||||
$saveData = [
|
$saveData = [
|
||||||
'invite_code' => build_invite_code($user->id),
|
'invite_code' => build_invite_code($user->id),
|
||||||
'userID' => idEncode($user->id)
|
'userID' => \support\Encrypt::userIDencode($user->id)
|
||||||
];
|
];
|
||||||
//管理直推人数和团队人数
|
//管理直推人数和团队人数
|
||||||
if($user->parent_id){
|
if($user->parent_id){
|
||||||
|
|||||||
+1
-117
@@ -185,34 +185,6 @@ if (!function_exists('captcha_verfiy')) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!function_exists('aesencode')) {
|
|
||||||
function aesencode($str, $key = '')
|
|
||||||
{
|
|
||||||
if (!$key) {
|
|
||||||
$key = Config('pay.api_token');
|
|
||||||
}
|
|
||||||
if (is_array($str) || is_object($str)) {
|
|
||||||
$str = json_encode($str, JSON_UNESCAPED_UNICODE);
|
|
||||||
}
|
|
||||||
$key = hash('sha256', $key, true);
|
|
||||||
$iv = substr($key, 0, 16);
|
|
||||||
$encrypted = openssl_encrypt($str, 'AES-256-CBC', $key, OPENSSL_RAW_DATA, $iv);
|
|
||||||
return base64_encode($encrypted);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!function_exists('aesdecode')) {
|
|
||||||
function aesdecode($str, $key = '')
|
|
||||||
{
|
|
||||||
if (!$key) {
|
|
||||||
$key = Config('pay.api_token');
|
|
||||||
}
|
|
||||||
$key = hash('sha256', $key, true);
|
|
||||||
$iv = substr($key, 0, 16);
|
|
||||||
$encrypted = base64_decode($str);
|
|
||||||
$decrypted = openssl_decrypt($encrypted, 'AES-256-CBC', $key, OPENSSL_RAW_DATA, $iv);
|
|
||||||
return $decrypted;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!function_exists('cdnurl')) {
|
if (!function_exists('cdnurl')) {
|
||||||
function cdnurl($path = '')
|
function cdnurl($path = '')
|
||||||
{
|
{
|
||||||
@@ -233,73 +205,6 @@ if (!function_exists('abort')) {
|
|||||||
throw new \support\exception\BusinessException($msg, $code);
|
throw new \support\exception\BusinessException($msg, $code);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!function_exists('idEncode')) {
|
|
||||||
function idEncode($id = '')
|
|
||||||
{
|
|
||||||
if($id<=100234){return $id.'';}
|
|
||||||
return id_encode($id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!function_exists('idDecode')) {
|
|
||||||
function idDecode($id = '')
|
|
||||||
{
|
|
||||||
$_id= intval($id);
|
|
||||||
if($_id == $id){return $id;}
|
|
||||||
return id_decode($id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 生成可逆的邀请码(8位,含校验位)
|
|
||||||
* @param int $id 用户ID(需≥1000)
|
|
||||||
* @return string 大写字母+数字组合
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (!function_exists('base62Encode')) {
|
|
||||||
function base62Encode(int $id,$secret='your_secret_salt'): string {
|
|
||||||
// 添加校验位(防止篡改)
|
|
||||||
$hash = crc32($id . $secret) % 1000;
|
|
||||||
$code_num = $id * 1000 + $hash;
|
|
||||||
|
|
||||||
// Base62 编码(0-9A-Za-z)
|
|
||||||
$base62 = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
|
|
||||||
$code = '';
|
|
||||||
while ($code_num > 0) {
|
|
||||||
$code = $base62[$code_num % 62] . $code;
|
|
||||||
$code_num = (int)($code_num / 62);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 补全到8位
|
|
||||||
return str_pad($code, 8, '0', STR_PAD_LEFT);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 从邀请码解析用户ID
|
|
||||||
* @return int|false 成功返回id,失败返回false
|
|
||||||
*/
|
|
||||||
if (!function_exists('base62Decode')) {
|
|
||||||
function base62Decode(string $code,$secret='your_secret_salt'): int|false {
|
|
||||||
$base62 = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
|
|
||||||
$code_num = 0;
|
|
||||||
|
|
||||||
// Base62 解码
|
|
||||||
for ($i = 0; $i < strlen($code); $i++) {
|
|
||||||
$pos = strpos($base62, $code[$i]);
|
|
||||||
if ($pos === false) return false;
|
|
||||||
$code_num = $code_num * 62 + $pos;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 分离校验位
|
|
||||||
$id = (int)($code_num / 1000);
|
|
||||||
$hash = $code_num % 1000;
|
|
||||||
|
|
||||||
// 校验
|
|
||||||
if (crc32($id . $secret) % 1000 != $hash) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $id;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!function_exists('P')) {
|
if (!function_exists('P')) {
|
||||||
function P()
|
function P()
|
||||||
@@ -614,22 +519,6 @@ if (!function_exists('build_invite_code')) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!function_exists('layun_auth')) {
|
|
||||||
function layun_auth($type = "url", $version = 1)
|
|
||||||
{
|
|
||||||
if ($type == 'url') {
|
|
||||||
$key = "";
|
|
||||||
$sercet = "2RxmtM";
|
|
||||||
if ($version == 1) {
|
|
||||||
$time = time();
|
|
||||||
$hash = md5($time . '_' . md5($time . '_' . $sercet));
|
|
||||||
} else {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!function_exists('get_parent_id')) {
|
if (!function_exists('get_parent_id')) {
|
||||||
function get_parent_id($user_id)
|
function get_parent_id($user_id)
|
||||||
{
|
{
|
||||||
@@ -712,12 +601,7 @@ if(!function_exists('enum_dir')){
|
|||||||
return $list ;
|
return $list ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!function_exists('generateShortUniqueID')){
|
|
||||||
function generateShortUniqueID($length = 8) {
|
|
||||||
// 生成指定长度的随机字节,转为 Base64 编码并去除不必要字符
|
|
||||||
return substr(bin2hex(random_bytes($length / 2)), 0, $length);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(!function_exists('get_user_rights')){
|
if(!function_exists('get_user_rights')){
|
||||||
function get_user_rights($user_id):array{
|
function get_user_rights($user_id):array{
|
||||||
$user_id = idDecode($user_id);
|
$user_id = idDecode($user_id);
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ class ActionHook implements MiddlewareInterface
|
|||||||
$response = response('',204,$headers);
|
$response = response('',204,$headers);
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
log_alert($request->controller);
|
|
||||||
// 禁止直接访问beforeAction afterAction
|
// 禁止直接访问beforeAction afterAction
|
||||||
if (substr($request->action,0,9) === '__before_' || substr($request->action,0,8) === '__after_') {
|
if (substr($request->action,0,9) === '__before_' || substr($request->action,0,8) === '__after_') {
|
||||||
$callback = Route::getFallback() ?? function () {
|
$callback = Route::getFallback() ?? function () {
|
||||||
|
|||||||
+4
-4
@@ -77,7 +77,7 @@ class User extends Base
|
|||||||
{
|
{
|
||||||
//use \think\model\concern\SoftDelete;
|
//use \think\model\concern\SoftDelete;
|
||||||
public static function onAfterInsert($row){
|
public static function onAfterInsert($row){
|
||||||
$res = request()->IM->user->userRegister(idEncode($row->id),$row->nickname,cdnurl($row->avatar));
|
$res = request()->IM->user->userRegister(\support\Encrypt::userIDencode($row->id),$row->nickname,cdnurl($row->avatar));
|
||||||
}
|
}
|
||||||
public static function onAfterUpdate($row){
|
public static function onAfterUpdate($row){
|
||||||
$changeData = $row->getChangedData();
|
$changeData = $row->getChangedData();
|
||||||
@@ -87,10 +87,10 @@ class User extends Base
|
|||||||
'nickname' => $row->nickname,
|
'nickname' => $row->nickname,
|
||||||
'faceURL' => cdnurl($row->avatar)
|
'faceURL' => cdnurl($row->avatar)
|
||||||
];
|
];
|
||||||
request()->IM->user->updateUserInfo(idEncode($row->id),$sdata);
|
request()->IM->user->updateUserInfo(\support\Encrypt::userIDencode($row->id),$sdata);
|
||||||
}
|
}
|
||||||
if(isset($changeData['status']) || $changeData['status'] == '0'){
|
if(isset($changeData['status']) || $changeData['status'] == '0'){
|
||||||
request()->IM->user->forceLogout(idEncode($row->id));
|
request()->IM->user->forceLogout(\support\Encrypt::userIDencode($row->id));
|
||||||
}
|
}
|
||||||
if(isset($changeData['expire_at']) || isset($changeData['role_id'])){
|
if(isset($changeData['expire_at']) || isset($changeData['role_id'])){
|
||||||
cache('user_rights_'.$row->id,null);
|
cache('user_rights_'.$row->id,null);
|
||||||
@@ -107,7 +107,7 @@ class User extends Base
|
|||||||
foreach(Config('site.allow_currencys') as $currency){
|
foreach(Config('site.allow_currencys') as $currency){
|
||||||
(new \app\model\BalanceLog)->setSuffix('_'.$currency)->where('user_id',(int)$row->id)->delete();
|
(new \app\model\BalanceLog)->setSuffix('_'.$currency)->where('user_id',(int)$row->id)->delete();
|
||||||
}
|
}
|
||||||
request()->IM->user->forceLogout(idEncode($row->id));
|
request()->IM->user->forceLogout(\support\Encrypt::userIDencode($row->id));
|
||||||
}
|
}
|
||||||
public function role()
|
public function role()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -36,7 +36,6 @@ class Sms implements Consumer
|
|||||||
);
|
);
|
||||||
try {
|
try {
|
||||||
$res = get($url);
|
$res = get($url);
|
||||||
log_alert($res.$statusStr[$res]);
|
|
||||||
\support\Log::channel('mail')->alert($data['email']."短信已经发送");
|
\support\Log::channel('mail')->alert($data['email']."短信已经发送");
|
||||||
} catch (\Throwable $th) {
|
} catch (\Throwable $th) {
|
||||||
\support\Log::channel('mail')->alert('发送短信出错:'.$th->getMessage());
|
\support\Log::channel('mail')->alert('发送短信出错:'.$th->getMessage());
|
||||||
|
|||||||
@@ -21,54 +21,6 @@ return [
|
|||||||
//runtime_path() . '/logs/webman'.ceil(date('H')/6).'.log',
|
//runtime_path() . '/logs/webman'.ceil(date('H')/6).'.log',
|
||||||
runtime_path() . '/logs/webman.log',
|
runtime_path() . '/logs/webman.log',
|
||||||
7, //$maxFiles
|
7, //$maxFiles
|
||||||
Monolog\Logger::INFO,
|
|
||||||
],
|
|
||||||
'formatter' => [
|
|
||||||
'class' => Monolog\Formatter\LineFormatter::class,
|
|
||||||
'constructor' => [null, 'Y-m-d H:i:s', true],
|
|
||||||
],
|
|
||||||
]
|
|
||||||
],
|
|
||||||
],
|
|
||||||
'server' => [
|
|
||||||
'handlers' => [
|
|
||||||
[
|
|
||||||
'class' => Monolog\Handler\RotatingFileHandler::class,
|
|
||||||
'constructor' => [
|
|
||||||
runtime_path() . '/logs/server.log',
|
|
||||||
7, //$maxFiles
|
|
||||||
Monolog\Logger::ALERT,
|
|
||||||
],
|
|
||||||
'formatter' => [
|
|
||||||
'class' => Monolog\Formatter\LineFormatter::class,
|
|
||||||
'constructor' => [null, 'Y-m-d H:i:s', true],
|
|
||||||
],
|
|
||||||
]
|
|
||||||
],
|
|
||||||
],
|
|
||||||
'studio' => [
|
|
||||||
'handlers' => [
|
|
||||||
[
|
|
||||||
'class' => Monolog\Handler\RotatingFileHandler::class,
|
|
||||||
'constructor' => [
|
|
||||||
runtime_path() . '/logs/studio.log',
|
|
||||||
7, //$maxFiles
|
|
||||||
Monolog\Logger::ALERT,
|
|
||||||
],
|
|
||||||
'formatter' => [
|
|
||||||
'class' => Monolog\Formatter\LineFormatter::class,
|
|
||||||
'constructor' => [null, 'Y-m-d H:i:s', true],
|
|
||||||
],
|
|
||||||
]
|
|
||||||
],
|
|
||||||
],
|
|
||||||
'power' => [
|
|
||||||
'handlers' => [
|
|
||||||
[
|
|
||||||
'class' => Monolog\Handler\RotatingFileHandler::class,
|
|
||||||
'constructor' => [
|
|
||||||
runtime_path() . '/logs/power.log',
|
|
||||||
7, //$maxFiles
|
|
||||||
Monolog\Logger::ALERT,
|
Monolog\Logger::ALERT,
|
||||||
],
|
],
|
||||||
'formatter' => [
|
'formatter' => [
|
||||||
@@ -94,38 +46,6 @@ return [
|
|||||||
]
|
]
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'role_buy' => [
|
|
||||||
'handlers' => [
|
|
||||||
[
|
|
||||||
'class' => Monolog\Handler\RotatingFileHandler::class,
|
|
||||||
'constructor' => [
|
|
||||||
runtime_path() . '/logs/role_buy.log',
|
|
||||||
7, //$maxFiles
|
|
||||||
Monolog\Logger::DEBUG,
|
|
||||||
],
|
|
||||||
'formatter' => [
|
|
||||||
'class' => Monolog\Formatter\LineFormatter::class,
|
|
||||||
'constructor' => [null, 'Y-m-d H:i:s', true],
|
|
||||||
],
|
|
||||||
]
|
|
||||||
],
|
|
||||||
],
|
|
||||||
'product_buy' => [
|
|
||||||
'handlers' => [
|
|
||||||
[
|
|
||||||
'class' => Monolog\Handler\RotatingFileHandler::class,
|
|
||||||
'constructor' => [
|
|
||||||
runtime_path() . '/logs/product_buy.log',
|
|
||||||
7, //$maxFiles
|
|
||||||
Monolog\Logger::DEBUG,
|
|
||||||
],
|
|
||||||
'formatter' => [
|
|
||||||
'class' => Monolog\Formatter\LineFormatter::class,
|
|
||||||
'constructor' => [null, 'Y-m-d H:i:s', true],
|
|
||||||
],
|
|
||||||
]
|
|
||||||
],
|
|
||||||
],
|
|
||||||
'mail' => [
|
'mail' => [
|
||||||
'handlers' => [
|
'handlers' => [
|
||||||
[
|
[
|
||||||
|
|||||||
@@ -66,7 +66,6 @@ class FilesController extends Crud
|
|||||||
$data = $this->base($request, $savePath);
|
$data = $this->base($request, $savePath);
|
||||||
}catch(\Exception $e){
|
}catch(\Exception $e){
|
||||||
return $this->fail( $e->getMessage());
|
return $this->fail( $e->getMessage());
|
||||||
log_alert($e->getMessage());
|
|
||||||
}
|
}
|
||||||
return $this->success( '上传成功', $data);
|
return $this->success( '上传成功', $data);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,27 +12,48 @@ use Throwable;
|
|||||||
/**
|
/**
|
||||||
* 用户宣传
|
* 用户宣传
|
||||||
*/
|
*/
|
||||||
class FriendController extends Crud
|
class FriendController extends OpenimBase
|
||||||
{
|
{
|
||||||
|
protected $relationSearch = [];
|
||||||
/**
|
|
||||||
* @var \app\model\UserXuanchuan
|
|
||||||
*/
|
|
||||||
protected $model = null;
|
|
||||||
protected $relationSearch = ['user'];
|
|
||||||
/**
|
/**
|
||||||
* 构造函数
|
* 构造函数
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function __construct()
|
function __construct()
|
||||||
{
|
{
|
||||||
$this->model = new \app\model\UserXuanchuan();
|
$this->model = new User();
|
||||||
$statusList = $this->model->getStatusList();
|
$statusList = $this->model->getStatusList();
|
||||||
$this->assign("statusList", $statusList);
|
$this->assign("statusList", $statusList);
|
||||||
$this->assignconfig("statusList", $statusList);
|
$this->assignconfig("statusList", $statusList);
|
||||||
$typeList = $this->model->getTypeList();
|
}
|
||||||
$this->assign("typeList", $typeList);
|
function select(Request $request): Response
|
||||||
$this->assignconfig("typeList", $typeList);
|
{
|
||||||
|
$res = $this->getSdk()->friend->getFriendList(Input('userID'), 1, 5000);
|
||||||
|
|
||||||
|
$userIDs = [];
|
||||||
|
foreach ($res['friendsInfo'] as $key => $value) {
|
||||||
|
$userIDs[] = $value['friendUser']['userID'];
|
||||||
|
}
|
||||||
|
//$_users = \app\model\User::whereIn('userID', $userIDs)->column('*','userID');
|
||||||
|
|
||||||
|
|
||||||
|
[$where, $format, $limit, $field, $order] = $this->selectInput($request);
|
||||||
|
$where['userId'] = ['symbol'=>'in', 'value1'=>$userIDs];
|
||||||
|
$query = $this->doSelect($where, $field, $order);
|
||||||
|
return $this->doFormat($query, $format, $limit);
|
||||||
|
|
||||||
|
$list = [];
|
||||||
|
foreach ($res['friendsInfo'] as $key => $value) {
|
||||||
|
$item = array_merge($value['friendUser'], $_users[$value['friendUser']['userID']] ?? [],$value['friendUser']);
|
||||||
|
unset($item['friendUser']);
|
||||||
|
$list[] =$item;
|
||||||
|
}
|
||||||
|
return json([
|
||||||
|
"code" => 0,
|
||||||
|
"count" => $res['total'],
|
||||||
|
"data" => $list,
|
||||||
|
"msg" => "ok"
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace plugin\admin\app\controller;
|
||||||
|
|
||||||
|
use app\model\User;
|
||||||
|
use plugin\admin\app\controller\Crud;
|
||||||
|
use support\exception\BusinessException;
|
||||||
|
use support\Request;
|
||||||
|
use support\Response;
|
||||||
|
use Throwable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* OpenimBase
|
||||||
|
*/
|
||||||
|
class OpenimBase extends Crud
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var \support\OpenImSdk\Client
|
||||||
|
*/
|
||||||
|
protected $sdk = null;
|
||||||
|
protected function getSdk(){
|
||||||
|
if($this->sdk){
|
||||||
|
return $this->sdk;
|
||||||
|
}
|
||||||
|
$this->sdk = new \support\OpenImSdk\Client([
|
||||||
|
'host' => 'http://127.0.0.1:10002', // OpenIM API地址
|
||||||
|
'secret' => 'n1e5a6s6m7', // OpenIM密钥
|
||||||
|
]);
|
||||||
|
return $this->sdk;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -58,10 +58,8 @@ class QuestionnaireController extends Crud
|
|||||||
if($showField && input($showField)){
|
if($showField && input($showField)){
|
||||||
$query = $query->whereLike($showField,'%'.input($showField).'%');
|
$query = $query->whereLike($showField,'%'.input($showField).'%');
|
||||||
}
|
}
|
||||||
//log_alert($ids,'cansnow');
|
|
||||||
$query = $query->whereNotIn('id',$ids);
|
$query = $query->whereNotIn('id',$ids);
|
||||||
$list = $query->field([$showField,$keyField])->paginate($limit);
|
$list = $query->field([$showField,$keyField])->paginate($limit);
|
||||||
//log_alert($query->getLastSql(),'cansnow');
|
|
||||||
|
|
||||||
return $this->success('ok',$list);
|
return $this->success('ok',$list);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ class TeamController extends Crud
|
|||||||
public function select(Request $request): Response
|
public function select(Request $request): Response
|
||||||
{
|
{
|
||||||
[$where, $format, $limit, $field, $order] = $this->selectInput($request);
|
[$where, $format, $limit, $field, $order] = $this->selectInput($request);
|
||||||
//log_alert($where);
|
|
||||||
$user_id = 0;
|
$user_id = 0;
|
||||||
if($where['user_id']['value1']){
|
if($where['user_id']['value1']){
|
||||||
$user_id = $where['user_id']['value1'];
|
$user_id = $where['user_id']['value1'];
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ use app\model\Base;
|
|||||||
class Config extends Base
|
class Config extends Base
|
||||||
{
|
{
|
||||||
public function setValueAttr($v,$row){
|
public function setValueAttr($v,$row){
|
||||||
log_alert($row);
|
|
||||||
if(is_array($v)){
|
if(is_array($v)){
|
||||||
return json_encode($v,JSON_UNESCAPED_UNICODE);
|
return json_encode($v,JSON_UNESCAPED_UNICODE);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ class User extends \app\model\User
|
|||||||
if(isset($changeData[$currency])){
|
if(isset($changeData[$currency])){
|
||||||
$cha = $changeData[$currency] - $orgData[$currency];
|
$cha = $changeData[$currency] - $orgData[$currency];
|
||||||
if($cha!=0){
|
if($cha!=0){
|
||||||
\support\Log::channel('cansnow')->alert('管理员手动修改用户余额:'.$row->id.',货币:'.$currency.',修改金额:'.$cha.',原始数据:'.$orgData[$currency].',修改后的数据:'.$changeData[$currency]);
|
log_alert('管理员手动修改用户余额:'.$row->id.',货币:'.$currency.',修改金额:'.$cha.',原始数据:'.$orgData[$currency].',修改后的数据:'.$changeData[$currency],'cansnow');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
{layout name="layout"}
|
||||||
|
<div class="toolbar" class="toolbar-btn-action">
|
||||||
|
<a id="btn_add" class="btn btn-primary m-r-5 btn-add" data-url="{:url('insert')}" data-title="新增" data-offset="r" data-area="80%,100%" data-anim="5" data-shade="0.3" data-move="false">
|
||||||
|
<span class="mdi mdi-plus" aria-hidden="true"></span>新增
|
||||||
|
</a>
|
||||||
|
<a id="btn_edit" class="btn btn-success m-r-5 btn-disabled disabled btn-multi" data-params="status=1">
|
||||||
|
<span class="mdi mdi-check" aria-hidden="true"></span>启用
|
||||||
|
</a>
|
||||||
|
<a id="btn_edit" class="btn btn-warning m-r-5 btn-disabled disabled btn-multi" data-params="status=0">
|
||||||
|
<span class="mdi mdi-block-helper" aria-hidden="true"></span>禁用
|
||||||
|
</a>
|
||||||
|
<a id="btn_delete" class="btn btn-danger btn-del btn-disabled disabled">
|
||||||
|
<span class="mdi mdi-window-close" aria-hidden="true"></span>删除
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<!-- 数据表格 -->
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-body">
|
||||||
|
<table id="table"></table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,88 @@
|
|||||||
|
{layout name="layout"}
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-body">
|
||||||
|
<form class="form-horizontal" action="__SELF__" method="post">
|
||||||
|
<input type="hidden" name="id" value="{$row.id|null}" />
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="type" class="control-label col-xs-12 col-sm-3">名称</label>
|
||||||
|
<div class="col-xs-12 col-sm-6 col-md-6">
|
||||||
|
<input type="text" name="title" value="{$row.title|null}" class="form-control" data-rule="required;length(2~100)" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="type" class="control-label col-xs-12 col-sm-3">封面:</label>
|
||||||
|
<div class="col-xs-12 col-sm-8 col-md-6">
|
||||||
|
<input id="c-image" class="form-control" size="50" name="image" type="hidden" value="{$row.image|default=''}" data-tip="image">
|
||||||
|
<ul class="list-inline clearfix lyear-uploads-pic" data-template="preview" id="p-image">
|
||||||
|
<li nodelete class="col-xs-4 col-sm-3 col-md-2">
|
||||||
|
<a class="pic-add faupload" style="height: auto;border: 0;" permission="app.admin.upload.image" id="add-pic-btn" href="javascript:;" title="点击上传" data-input-id="c-image" data-mimetype="image/*" data-multiple="false" data-preview-id="p-image"></a>
|
||||||
|
<a class="pic-add fachoose" style="height: auto;border: 0;display: none;" permission="app.admin.files.list" id="choose-pic-btn" href="javascript:;" title="选择文件" data-input-id="c-image" data-mimetype="image/*" data-multiple="false" data-preview-id="p-image"></a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="type" class="control-label col-xs-12 col-sm-3">单价</label>
|
||||||
|
<div class="col-xs-12 col-sm-6 col-md-6">
|
||||||
|
<div class="input-group">
|
||||||
|
<input type="text" name="price" value="{$row.price|null=3.5}" class="form-control" data-rule="required;range(0.5~)" />
|
||||||
|
<div class="input-group-addon">¥</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="type" class="control-label col-xs-12 col-sm-3">库存</label>
|
||||||
|
<div class="col-xs-12 col-sm-6 col-md-6">
|
||||||
|
<div class="input-group">
|
||||||
|
<input type="number" name="stock" value="{$row.stock|default=0}" class="form-control" min="0" data-rule="required;range(0~99)" />
|
||||||
|
<div class="input-group-addon">份</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="type" class="control-label col-xs-12 col-sm-3">用户累计限购</label>
|
||||||
|
<div class="col-xs-12 col-sm-6 col-md-6">
|
||||||
|
<div class="input-group">
|
||||||
|
<input type="number" name="user_quantity" value="{$row.user_quantity|default=0}" class="form-control" min="0" data-rule="required;range(0~99)" />
|
||||||
|
<div class="input-group-addon">份</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="control-label col-xs-12 col-sm-3">备注</label>
|
||||||
|
<div class="col-xs-12 col-sm-6 col-md-6">
|
||||||
|
<textarea type="text" name="memo" class="form-control" >{$row.memo|null}</textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="type" class="control-label col-xs-12 col-sm-3">销量</label>
|
||||||
|
<div class="col-xs-12 col-sm-6 col-md-6">
|
||||||
|
<div class="input-group">
|
||||||
|
<input type="number" name="sales" value="{$row.sales|default=0}" disabled class="form-control" min="0" data-rule="required;range(0~99)" />
|
||||||
|
<div class="input-group-addon">份</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="control-label col-xs-12 col-sm-3">状态</label>
|
||||||
|
<div class="col-xs-12 col-sm-6 col-md-6">
|
||||||
|
{volist name="statusList" id="rvo"}
|
||||||
|
<label class="lyear-radio radio-primary radio-inline">
|
||||||
|
<input type="radio" name="status" {if $row.status == $key} checked{/if} value="{$key}">
|
||||||
|
<span>{$rvo}</span>
|
||||||
|
</label>
|
||||||
|
{/volist}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="control-label col-xs-12 col-sm-3"></label>
|
||||||
|
<div class="col-xs-12 col-sm-6 col-md-6 layer-footer">
|
||||||
|
<button type="submit" class="btn btn-primary m-r-5">提交</button>
|
||||||
|
<button type="reset" class="btn btn-warning m-r-5">重置</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{include file="common/file_preview" id="preview"/}
|
||||||
@@ -0,0 +1,146 @@
|
|||||||
|
define(['table', 'upload','form'], function (Table,Upload,Form) {
|
||||||
|
var friend = {
|
||||||
|
//Do setup work hereAction
|
||||||
|
index: function () {
|
||||||
|
window.statuskOption= Config.statusList;
|
||||||
|
window.filterData = {
|
||||||
|
};
|
||||||
|
|
||||||
|
Table.api.init({
|
||||||
|
extend: {
|
||||||
|
index_url: 'friend/select?userID='+Fast.api.query('userID'),
|
||||||
|
add_url: 'friend/insert',
|
||||||
|
edit_url: 'friend/update',
|
||||||
|
del_url: 'friend/delete',
|
||||||
|
multi_url: 'friend/multi',
|
||||||
|
dragsort_url: null,
|
||||||
|
table: 'user',
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
var table = $("#table");
|
||||||
|
var columns = [
|
||||||
|
{checkbox: true},
|
||||||
|
{
|
||||||
|
field: 'id',
|
||||||
|
title: 'ID',
|
||||||
|
filter: "number",
|
||||||
|
sortable: true,
|
||||||
|
visible:false // 是否排序
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'userID',
|
||||||
|
title: 'userID',
|
||||||
|
filter: "string"
|
||||||
|
},
|
||||||
|
// {
|
||||||
|
// title: "上级",
|
||||||
|
// field: "referrer.username"
|
||||||
|
// },
|
||||||
|
{
|
||||||
|
title: "角色",
|
||||||
|
field: "role_id",
|
||||||
|
formatter:function(v,row){
|
||||||
|
return row.role ? row.role.name : '用户';
|
||||||
|
},
|
||||||
|
filter: "select",
|
||||||
|
filterOption:"roleOption"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "用户名",
|
||||||
|
field: "username"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "昵称",
|
||||||
|
field: "nickname"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "头像",
|
||||||
|
field: "avatar",
|
||||||
|
formatter: function (v,d) {
|
||||||
|
return '<img src="'+encodeURI(d['avatar'])+'" style="max-width:32px;max-height:32px;" alt="" />'
|
||||||
|
},
|
||||||
|
visible: false
|
||||||
|
},
|
||||||
|
// {
|
||||||
|
// title: "等级",
|
||||||
|
// field: "level",
|
||||||
|
// visible: false,
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// title: "生日",
|
||||||
|
// field: "birthday",
|
||||||
|
// visible: false,
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// title: "后缀",
|
||||||
|
// field: "decimal_part",
|
||||||
|
// //visible: false,
|
||||||
|
// },
|
||||||
|
];
|
||||||
|
var currencys = ['money','score','currency1','currency2','currency3','currency4','currency5','currency6','currency7','currency8','currency9'];
|
||||||
|
for (let i = 0; i < currencys.length; i++) {
|
||||||
|
if(Config.allow_currencys.indexOf(currencys[i])!==-1){
|
||||||
|
columns.push({
|
||||||
|
title: __(currencys[i]),
|
||||||
|
field: currencys[i],
|
||||||
|
formatter:Table.api.formatter.number,
|
||||||
|
//sortable: true,
|
||||||
|
//visible: false,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
columns.push({
|
||||||
|
title: "注册时间",
|
||||||
|
field: "created_at",
|
||||||
|
filter:'datetime'
|
||||||
|
});
|
||||||
|
columns.push({
|
||||||
|
title: "状态",
|
||||||
|
field: "status",
|
||||||
|
formatter: Table.api.formatter.switch
|
||||||
|
});
|
||||||
|
columns.push({
|
||||||
|
field: 'operate', title: '操作',
|
||||||
|
table: table,
|
||||||
|
events: Table.api.events.operate,
|
||||||
|
formatter: Table.api.formatter.operate,
|
||||||
|
buttons:[
|
||||||
|
// {
|
||||||
|
// text:"团队",
|
||||||
|
// name:"team",
|
||||||
|
// icon:"mdi mdi-account-group-outline",
|
||||||
|
// classname:"btn btn-xs btn-info btn-dialog",
|
||||||
|
// extend:' data-offset="r" data-area="80%,100%" data-anim="5" data-shade="0.3" data-move="false"',
|
||||||
|
// url:'user/team'
|
||||||
|
// }
|
||||||
|
]
|
||||||
|
});
|
||||||
|
var tableOptions = {
|
||||||
|
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
||||||
|
pk: 'id',
|
||||||
|
sortName: 'id',
|
||||||
|
commonSearch: false,
|
||||||
|
search: false,
|
||||||
|
columns: [columns]
|
||||||
|
};
|
||||||
|
// 初始化表格
|
||||||
|
table.bootstrapTable(tableOptions);
|
||||||
|
// 为表格绑定事件
|
||||||
|
Table.api.bindevent(table);
|
||||||
|
},
|
||||||
|
update:function(){
|
||||||
|
this.bindevent();
|
||||||
|
},
|
||||||
|
insert:function(){
|
||||||
|
this.bindevent();
|
||||||
|
},
|
||||||
|
bindevent:function(){
|
||||||
|
Config['upload_url'] = 'files/upload';
|
||||||
|
var form = $('form');
|
||||||
|
var that = this;
|
||||||
|
Form.api.bindevent(form)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return friend
|
||||||
|
});
|
||||||
+2
-1
@@ -534,7 +534,8 @@
|
|||||||
window.location.href = 'https://h5.shun777.com';
|
window.location.href = 'https://h5.shun777.com';
|
||||||
}else{
|
}else{
|
||||||
//window.location.href = 'https://shunliao.oss-accelerate.aliyuncs.com/apk/install.apk';
|
//window.location.href = 'https://shunliao.oss-accelerate.aliyuncs.com/apk/install.apk';
|
||||||
window.location.href = 'https://static.shun777.com/app/shunliao_v3.apk';
|
window.location.href = 'https://static.shun777.com/app/shunliao_v4.apk';
|
||||||
|
//https://d1facirggd28tx.cloudfront.net/shunliao580.apk
|
||||||
//window.location.href = '/shunliao.apk?v=2';
|
//window.location.href = '/shunliao.apk?v=2';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ $app = Request()->app;
|
|||||||
$controller =get_controller_name();
|
$controller =get_controller_name();
|
||||||
$langs = [];
|
$langs = [];
|
||||||
$fn= __DIR__.'/'.($app?$app.'/' : '').strtolower($controller).'.php';
|
$fn= __DIR__.'/'.($app?$app.'/' : '').strtolower($controller).'.php';
|
||||||
//log_alert($fn);
|
|
||||||
if(file_exists($fn)){
|
if(file_exists($fn)){
|
||||||
$langs = require $fn;
|
$langs = require $fn;
|
||||||
if(!is_array( $langs)){
|
if(!is_array( $langs)){
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ $app = Request()->app;
|
|||||||
$controller =get_controller_name();
|
$controller =get_controller_name();
|
||||||
$langs = [];
|
$langs = [];
|
||||||
$fn= __DIR__.'/'.($app?$app.'/' : '').strtolower($controller).'.php';
|
$fn= __DIR__.'/'.($app?$app.'/' : '').strtolower($controller).'.php';
|
||||||
//log_alert($fn);
|
|
||||||
if(file_exists($fn)){
|
if(file_exists($fn)){
|
||||||
$langs = require $fn;
|
$langs = require $fn;
|
||||||
if(!is_array( $langs)){
|
if(!is_array( $langs)){
|
||||||
|
|||||||
@@ -0,0 +1,231 @@
|
|||||||
|
<?php
|
||||||
|
namespace support;
|
||||||
|
class Encrypt
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类似QQ的非连续数字ID加密
|
||||||
|
* 使用可逆的位运算混淆算法
|
||||||
|
* 特点:
|
||||||
|
* 1. 连续输入产生非连续、看起来随机的输出
|
||||||
|
* 2. 加密解密完全可逆
|
||||||
|
* 3. 输出为8位纯数字(10000000 - 99999999),类似QQ号
|
||||||
|
* 4. 支持约9000万个ID (0 - 89999999)
|
||||||
|
*/
|
||||||
|
|
||||||
|
// 最大ID值(支持9000万个ID)
|
||||||
|
private static $maxId = 90000000;
|
||||||
|
// 加密结果基数(确保8位数)
|
||||||
|
private static $baseValue = 10000000;
|
||||||
|
/**
|
||||||
|
* 加密连续数字ID为非连续数字ID
|
||||||
|
* 使用基于哈希的可逆映射
|
||||||
|
* @param int $plainId 原始连续ID (0 - 89999999)
|
||||||
|
* @param int $userKey 可选的额外密钥
|
||||||
|
* @return int 加密后的非连续ID(8位数)
|
||||||
|
*/
|
||||||
|
static function userIDencode($userID,$key=0):string{
|
||||||
|
if(!is_numeric(($userID))){
|
||||||
|
return $userID;
|
||||||
|
}
|
||||||
|
$userID = intval($userID);
|
||||||
|
if($userID<=100234){
|
||||||
|
return $userID.'';
|
||||||
|
}
|
||||||
|
if($userID<=102028){
|
||||||
|
return id_encode($userID);
|
||||||
|
}
|
||||||
|
$key = intval($key);
|
||||||
|
|
||||||
|
$plainId = abs(intval($userID)) % self::$maxId;
|
||||||
|
|
||||||
|
// 使用哈希函数生成伪随机序列,然后建立双射映射
|
||||||
|
// 方法:使用线性同余生成器 (LCG) 的变体
|
||||||
|
// 公式:encrypted = (a * plainId + b) mod m
|
||||||
|
// 其中 a 和 m 互质,保证可逆
|
||||||
|
|
||||||
|
// 选择一个大质数作为乘数(与9000万互质)
|
||||||
|
$a = 15485863; // 大质数,与90000000互质
|
||||||
|
$b = 2038074743; // 大常数
|
||||||
|
$m = self::$maxId;
|
||||||
|
|
||||||
|
// 加密
|
||||||
|
$encrypted = ($a * $plainId + $b + $key) % $m;
|
||||||
|
|
||||||
|
// 确保结果是8位数(10000000 - 99999999)
|
||||||
|
return (self::$baseValue + $encrypted).'';
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 解密非连续数字ID为原始连续ID
|
||||||
|
* @param int $encryptedId 加密后的非连续ID(8位数)
|
||||||
|
* @param int $userKey 可选的额外密钥
|
||||||
|
* @return int 原始连续ID
|
||||||
|
*/
|
||||||
|
static function userIDDecode($userID,$key=0):string{
|
||||||
|
if(!is_numeric(($userID))){
|
||||||
|
return id_decode($userID.'');
|
||||||
|
}
|
||||||
|
if($userID<=100234){
|
||||||
|
return $userID.'';
|
||||||
|
}
|
||||||
|
$key = intval($key);
|
||||||
|
// 去除基数,得到原始混淆值
|
||||||
|
$cipherId = ($userID - self::$baseValue + self::$maxId) % self::$maxId;
|
||||||
|
|
||||||
|
// LCG解密:plain = (encrypted - b) * a^-1 mod m
|
||||||
|
$a = 15485863;
|
||||||
|
$b = 2038074743;
|
||||||
|
$m = self::$maxId;
|
||||||
|
|
||||||
|
// 计算 a 的模逆元 (使用扩展欧几里得算法)
|
||||||
|
$aInv = self::modInverse($a, $m);
|
||||||
|
|
||||||
|
// 解密
|
||||||
|
$temp = ($cipherId - $b - $key) % $m;
|
||||||
|
if ($temp < 0) $temp += $m;
|
||||||
|
|
||||||
|
$plainId = ($aInv * $temp) % $m;
|
||||||
|
|
||||||
|
return $plainId.'';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 使用扩展欧几里得算法计算模逆元
|
||||||
|
* 返回 x 使得 (a * x) % m = 1
|
||||||
|
*/
|
||||||
|
private static function modInverse($a, $m) {
|
||||||
|
$m0 = $m;
|
||||||
|
$x0 = 0;
|
||||||
|
$x1 = 1;
|
||||||
|
|
||||||
|
if ($m == 1) return 0;
|
||||||
|
|
||||||
|
while ($a > 1) {
|
||||||
|
// q 是商
|
||||||
|
$q = intval($a / $m);
|
||||||
|
$t = $m;
|
||||||
|
|
||||||
|
// m 是余数,处理完后 a 和 m 互换
|
||||||
|
$m = $a % $m;
|
||||||
|
$a = $t;
|
||||||
|
|
||||||
|
// 更新 x0 和 x1
|
||||||
|
$t = $x0;
|
||||||
|
$x0 = $x1 - $q * $x0;
|
||||||
|
$x1 = $t;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 确保 x1 是正数
|
||||||
|
if ($x1 < 0) $x1 += $m0;
|
||||||
|
|
||||||
|
return $x1;
|
||||||
|
}
|
||||||
|
static function generateShortUniqueID($length = 8)
|
||||||
|
{
|
||||||
|
// 生成指定长度的随机字节,转为 Base64 编码并去除不必要字符
|
||||||
|
return substr(bin2hex(random_bytes($length / 2)), 0, $length);
|
||||||
|
}
|
||||||
|
|
||||||
|
static function idEncode($id = '')
|
||||||
|
{
|
||||||
|
if ($id <= 100234) {
|
||||||
|
return $id . '';
|
||||||
|
}
|
||||||
|
return id_encode($id);
|
||||||
|
}
|
||||||
|
static function idDecode($id = '')
|
||||||
|
{
|
||||||
|
$_id = intval($id);
|
||||||
|
if ($_id == $id) {
|
||||||
|
return $id;
|
||||||
|
}
|
||||||
|
return id_decode($id);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 生成可逆的邀请码(8位,含校验位)
|
||||||
|
* @param int $id 用户ID(需≥1000)
|
||||||
|
* @return string 大写字母+数字组合
|
||||||
|
*/
|
||||||
|
|
||||||
|
static function base62Encode(int $id, $secret = 'your_secret_salt'): string
|
||||||
|
{
|
||||||
|
// 添加校验位(防止篡改)
|
||||||
|
$hash = crc32($id . $secret) % 1000;
|
||||||
|
$code_num = $id * 1000 + $hash;
|
||||||
|
|
||||||
|
// Base62 编码(0-9A-Za-z)
|
||||||
|
$base62 = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
|
||||||
|
$code = '';
|
||||||
|
while ($code_num > 0) {
|
||||||
|
$code = $base62[$code_num % 62] . $code;
|
||||||
|
$code_num = (int) ($code_num / 62);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 补全到8位
|
||||||
|
return str_pad($code, 8, '0', STR_PAD_LEFT);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 从邀请码解析用户ID
|
||||||
|
* @return int|false 成功返回id,失败返回false
|
||||||
|
*/
|
||||||
|
static function base62Decode(string $code, $secret = 'your_secret_salt'): int|false
|
||||||
|
{
|
||||||
|
$base62 = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
|
||||||
|
$code_num = 0;
|
||||||
|
|
||||||
|
// Base62 解码
|
||||||
|
for ($i = 0; $i < strlen($code); $i++) {
|
||||||
|
$pos = strpos($base62, $code[$i]);
|
||||||
|
if ($pos === false)
|
||||||
|
return false;
|
||||||
|
$code_num = $code_num * 62 + $pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 分离校验位
|
||||||
|
$id = (int) ($code_num / 1000);
|
||||||
|
$hash = $code_num % 1000;
|
||||||
|
|
||||||
|
// 校验
|
||||||
|
if (crc32($id . $secret) % 1000 != $hash) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $id;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Aes加密
|
||||||
|
* @param mixed $str
|
||||||
|
* @param mixed $key
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
static function aesencode($str, $key = '')
|
||||||
|
{
|
||||||
|
if (!$key) {
|
||||||
|
$key = Config('pay.api_token');
|
||||||
|
}
|
||||||
|
if (is_array($str) || is_object($str)) {
|
||||||
|
$str = json_encode($str, JSON_UNESCAPED_UNICODE);
|
||||||
|
}
|
||||||
|
$key = hash('sha256', $key, true);
|
||||||
|
$iv = substr($key, 0, 16);
|
||||||
|
$encrypted = openssl_encrypt($str, 'AES-256-CBC', $key, OPENSSL_RAW_DATA, $iv);
|
||||||
|
return base64_encode($encrypted);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Aes解密
|
||||||
|
* @param mixed $str
|
||||||
|
* @param mixed $key
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
static function aesdecode($str, $key = '')
|
||||||
|
{
|
||||||
|
if (!$key) {
|
||||||
|
$key = Config('pay.api_token');
|
||||||
|
}
|
||||||
|
$key = hash('sha256', $key, true);
|
||||||
|
$iv = substr($key, 0, 16);
|
||||||
|
$encrypted = base64_decode($str);
|
||||||
|
$decrypted = openssl_decrypt($encrypted, 'AES-256-CBC', $key, OPENSSL_RAW_DATA, $iv);
|
||||||
|
return $decrypted;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -88,7 +88,7 @@ class Utils
|
|||||||
$token = $token ? $token : Utils::getAdminToken();
|
$token = $token ? $token : Utils::getAdminToken();
|
||||||
}
|
}
|
||||||
$url = Url::buildUrl($path);
|
$url = Url::buildUrl($path);
|
||||||
log_alert($url);
|
//log_alert($url);
|
||||||
//log_alert($data);
|
//log_alert($data);
|
||||||
$res = self::request($url, $data, $token);
|
$res = self::request($url, $data, $token);
|
||||||
//log_alert($res);
|
//log_alert($res);
|
||||||
|
|||||||
Reference in New Issue
Block a user