This commit is contained in:
commie
2026-02-15 19:41:56 +08:00
parent 61c5192018
commit 1a7f4bc98a
68 changed files with 992 additions and 353 deletions
+2
View File
@@ -8,6 +8,8 @@ use hg\apidoc\annotation as Apidoc;
/**
* 提现地址
* @Apidoc\NotParse()
* @Apidoc\NotDebug()
*/
class AddressController extends BaseController{
/**
+39 -35
View File
@@ -56,13 +56,9 @@ class BaseController
{
return $this->json(1,$msg, $data);
}
/**
* @Apidoc\Title("上传")
* @Apidoc\Method("POST")
*/
function upload(Request $request)
protected function _upload($request)
{
try{
$user = \support\Jwt::getUser();
}catch(\Exception $e){
@@ -72,7 +68,7 @@ class BaseController
$validate = Validate::rule('savePath', 'alphaNum');
$data = ['savePath' => $savePath];
if (!$validate->check($data)) {
return $this->fail( '参数错误:'.$validate->getError());
return '参数错误:'.$validate->getError();
}
$savePath = trim($savePath,'/');
//$savePath = 'upload/'.$savePath.'/'.$user['id'];
@@ -82,35 +78,43 @@ class BaseController
$maxsize = Config('site.upload_maxsize')*1024*1024;
//多文件上传
$files = $request->file();
try {
$result = Storage::adapter('oss')
->path($savePath)
->size($maxsize)
->extYes($mimetype)
->uploads($files,0,$maxsize * count($files),false);
$save_datas = [];
foreach($result as $k=>$fileinfo){
$save_datas[] = [
'user_id' => $user['id'],
'category' => 'default',
'adapter' => $fileinfo->adapter,
'origin_name' => $fileinfo->origin_name,
'file_name' => $fileinfo->file_name,
'size' => $fileinfo->size,
'mime_type' => $fileinfo->mime_type,
'extension' => $fileinfo->extension,
'file_height' => $fileinfo->file_height,
'file_width' => $fileinfo->file_width,
'file_url' => $fileinfo->file_url,
'sha1' => $fileinfo->storage_key ?:sha1_file(public_path($fileinfo->file_name)),
'use_count' => 0,
];
}
\app\model\Files::insertAll($save_datas);
return $this->success(__('successful'),$result);
}catch (\Exception $e){
return $this->error($e->getMessage());
$result = Storage::adapter('oss')
->path($savePath)
->size($maxsize)
->extYes($mimetype)
->uploads($files,0,$maxsize * count($files),false);
$save_datas = [];
foreach($result as $k=>$fileinfo){
$save_datas[] = [
'user_id' => $user['id'],
'category' => 'default',
'adapter' => $fileinfo->adapter,
'origin_name' => $fileinfo->origin_name,
'file_name' => $fileinfo->file_name,
'size' => $fileinfo->size,
'mime_type' => $fileinfo->mime_type,
'extension' => $fileinfo->extension,
'file_height' => $fileinfo->file_height,
'file_width' => $fileinfo->file_width,
'file_url' => $fileinfo->file_url,
'sha1' => $fileinfo->storage_key ?:sha1_file(public_path($fileinfo->file_name)),
'use_count' => 0,
];
}
$res = \app\model\Files::saveAll($save_datas);
return $res;
}
/**
* @Apidoc\Title("上传")
* @Apidoc\Method("POST")
*/
function upload(Request $request,$return = false)
{
$res = $this->_upload($request);
if(is_string($res)){
return $this->fail( $res);
}
return $this->success(__('successful'),$res);
}
+2
View File
@@ -10,6 +10,8 @@ use hg\apidoc\annotation as Apidoc;
/**
* 卡密模块
* @Apidoc\NotParse()
* @Apidoc\NotDebug()
*/
class CardController extends BaseController{
/**
+3 -3
View File
@@ -46,7 +46,7 @@ class CommonController extends BaseController{
'attachment_category','categorytype','cdkey_category','configgroup','flagtype',
'languages','forbiddenip','fixedpage','admin_login_captcha',
'upload_mimetype','upload_multipart','upload_multiple','upload_thumbstyle','upload_previewtpl','upload_timeout','upload_maxsize',
'yeji_jicha_reward','suanli_rate','agent_expirs_retention','allow_currencys','allow_balance_log',
'yeji_jicha_reward','suanli_rate','agent_expirs_retention','allow_currencys','allow_currency_logs',
'agent_commission_total_rate','agent_commission_layer_rate','differential_commission_total_rate'
];
$config = array_diff_key($config, array_flip($disallowFields));
@@ -153,7 +153,7 @@ class CommonController extends BaseController{
'group_id' => 0,
'region' => '86',
'nickname' => input('nickname'),
'avatar' => '/static/img/avatar.png',
'avatar' => '/static/avatar/'.rand(0,17).'.png',
];
if ($invite_code) {
if(strlen($invite_code) == 12){
@@ -211,7 +211,7 @@ class CommonController extends BaseController{
$mobile = input('mobile');
$email = input('email');
$password = input('password');
$type = input(param: 'type');
$type = input('type');
if($type == 'mobile'){
if (!$mobile ) {
return $this->fail(__('Invalid username or password'));
+92 -32
View File
@@ -34,26 +34,40 @@ class FriendCircleController extends BaseController{
* @return void
*/
function info(Request $request): Response{
$user = \support\Jwt::getUser();
if (!$user) {
return $this->fail('请先登录');
$user_id = Input('user_id');
if($user_id){
$user_id = idDecode($user_id);
$json= [
'top_unread_items' =>[],
'unread_item_ids' =>[],
'unread_count' =>0,
'settings' => Db::name('friend_circle_setting')->where('user_id',$user_id)->order('id','desc')->findOrEmpty()
];
return $this->success('ok',$json);
}else{
$user = \support\Jwt::getUser();
if (!$user) {
return $this->fail('请先登录');
}
$user_id = $user->id;
$res = $this->newcount($request);
$response = $res->rawBody();
$json = json_decode($response,true);
$json['data']['settings'] = Db::name('friend_circle_setting')->where('user_id',$user_id)->order('id','desc')->findOrEmpty();
// [
// 'bg' => '',
// ];
$top_unread_items = FriendCircleModel::whereIn('id',$json['data']['unread_item_ids'])
->with(['user' => function($query) {
$query->field('id,nickname,avatar');
}])
->order('id', 'desc')
->limit(0,3)
->select();
$json['data']['top_unread_items'] = $top_unread_items ?: [];
$res->withBody(json_encode($json));
return $res;
}
$res = $this->newcount($request);
$response = $res->rawBody();
$json = json_decode($response,true);
$json['data']['settings'] = [
'bg' => '',
];
$top_unread_items = FriendCircleModel::whereIn('id',$json['data']['unread_item_ids'])
->with(['user' => function($query) {
$query->field('id,nickname,avatar');
}])
->order('id', 'desc')
->limit(0,3)
->select();
$json['data']['top_unread_items'] = $top_unread_items ?: [];
$res->withBody(json_encode($json));
return $res;
}
/**
* @Apidoc\Title("列表")
@@ -66,9 +80,12 @@ class FriendCircleController extends BaseController{
{
$current_user = \support\Jwt::getUser();
$current_user_id = $current_user ? $current_user->id : 0;
$page = (int)$request->get('page', 1);
$limit = (int)$request->get('limit', 10);
$user_id = $request->get('user_id', 0);
$page = (int)Input('page', 1);
$limit = (int)Input('limit', 10);
$user_id = Input('user_id', 0);
if($user_id){
$user_id = idDecode($user_id);
}
$query = FriendCircleModel::where('status', 1)
->whereIn('user_id',$this->getFriendUserIds($current_user_id))
@@ -86,16 +103,18 @@ class FriendCircleController extends BaseController{
'list_rows' => $limit,
'page' => $page,
]);
cache('circle_last_read_id',$list[0]['id']);
if(!$user_id){
cache('circle_last_read_id_'.$current_user_id,$list[0]['id']);
}
// 处理每条朋友圈数据
$items = $list->items();
$list->each(function($item) use ($current_user_id){
// 获取点赞列表
$likes = Db::name('friend_circle')->alias('f')
$likes = Db::name('friend_circle_like')->alias('f')
->join('user u','u.id=f.user_id')
->where('f.id', $item->id)
->where('f.circle_id', $item->id)
->field('f.*,u.avatar,u.nickname')
->order('f.created_at', 'desc')
->limit(20)
@@ -182,11 +201,11 @@ class FriendCircleController extends BaseController{
if (!$user) {
return $this->fail('请先登录');
}
$circle_last_read_id = cache('circle_last_read_id') ?: 0;
$user_id = $user->id;
$circle_last_read_id = cache('circle_last_read_id_'.$user_id) ?: 0;
// 统计从上次查看时间到现在新增的朋友圈数量
$unread_item_ids = FriendCircleModel::where('status', 1)
->whereIn('user_id',$this->getFriendUserIds($user->id))
->whereIn('user_id',$this->getFriendUserIds($user_id))
->where('id', '>', $circle_last_read_id)
->order('id', 'desc')
->column('id');
@@ -250,7 +269,7 @@ class FriendCircleController extends BaseController{
'status' => 1,
]);
return $this->success('发布成功', ['id' => $circle->id]);
return $this->success('发布成功', ['id' => $circle->id,'data' => $circle]);
}
/**
@@ -371,15 +390,56 @@ class FriendCircleController extends BaseController{
if (!$user_id) {
return [];
}
$result = cache('friend_id_list') ?: [];
$cache_key = 'friend_id_list_'.$user_id;
$result = cache($cache_key) ?: [];
if(count($result) === 0){
$res = request()->IM->friend->getFriendList($user_id.'');
$res = request()->IM->friend->getFriendList(idEncode($user_id));
$friendsInfo = $res['friendsInfo'];
foreach($friendsInfo as $k=>$v){
array_push($result,$v['friendUser']['userID']);
}
cache('friend_id_list',$result,3600);
cache($cache_key,$result,3600);
}
$result[] = $user_id;
return $result;
}
function delete(Request $request): Response{
$id = $request->post('id');
$user = \support\Jwt::getUser();
if (!$user) {
return $this->fail('请先登录');
}
if($id){
FriendCircleModel::where('id',$id)->where('user_id',$user->id)->delete();
}
return $this->success('删除成功');
}
function upload_bg(Request $request){
try {
$user = \support\Jwt::getUser();
if (!$user) {
return $this->fail('请先登录');
}
$res = $this->_upload($request);
if(is_string($res)){
return $this->fail( $res);
}
Db::name('friend_circle_setting')->replace()->insert([
'user_id' => $user->id,
'bg' => $res[0]['file_name'],
'allow_days'=>0,
'created_at'=>0
]);
//$result->ss = cdnurl($result->url);
//P($result);
return $this->success(__('successful'),[
'url'=>$res[0]['file_name']
]);
}catch (\Exception $e){
return $this->error($e->getMessage());
}
}
}
+2
View File
@@ -10,6 +10,8 @@ use hg\apidoc\annotation as Apidoc;
/**
* 礼品模块
* @Apidoc\NotParse()
* @Apidoc\NotDebug()
*/
class GiftController extends BaseController{
/**
+129
View File
@@ -0,0 +1,129 @@
<?php
namespace app\api\controller;
use support\Request;
use support\Response;
use hg\apidoc\annotation as Apidoc;
use app\model\User;
use app\model\Album as AlbumModel;
/**
* 群组管理
*/
class GroupController extends BaseController
{
public $noNeedAuth = ['*'];
public $noNeedLogin = [];
/**
* @Apidoc\Title("群相片列表")
* @Apidoc\Method("POST")
* @Apidoc\Param("group_id", type="string", require=true, desc="群ID")
* @Apidoc\Param("page", type="int", require=true, desc="页码",default=1)
* @Apidoc\Param("limit", type="int", require=true, desc="分页大小",default=10)
*/
function album_list(Request $request): Response
{
$user = \support\Jwt::getUser();
$limit = $request->post('limit',10);
$offset = $request->post('offset',0);
$group_id = $request->post('groupID') ?:$request->post('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)
->where('id','<',$offset)
->order('id','desc')
->limit(0,$limit)
->select();
return $this->success('ok',$list);
}
/**
* @Apidoc\Title("上传相片")
* @Apidoc\Method("POST")
* @Apidoc\Param("group_id", type="string", require=true, desc="群ID")
* @Apidoc\Param("title", type="string", require=true, desc="标题")
* @Apidoc\Param("url", type="string", require=true, desc="图片")
*/
function album_create(Request $request): Response
{
$user_id = \support\Jwt\JwtToken::getCurrentId();
$res = $this->_upload($request);
if(is_string($res)){
return $this->fail( $res);
}
$groupID = $request->post('groupID');
$insert_data = [];
foreach($res as $item){
$insert_data[] = [
'user_id' => $user_id,
'group_id' => $groupID,
'title' => $item['origin_name'],
'url' => $item['file_name'],
];
}
$result = AlbumModel::saveAll($insert_data);
return $this->success('ok',$result[0]);
}
/**
* @Apidoc\Title("更新相片")
* @Apidoc\Method("POST")
* @Apidoc\Param("id", type="string", require=true, desc="ID")
* @Apidoc\Param("title", type="string", require=true, desc="标题")
* @Apidoc\Param("url", type="string", require=true, desc="图片")
*/
function album_update(Request $request): Response
{
$id = $request->input('id');
$data = $request->input('data');
$album = AlbumModel::find($id);
$album->update($data);
return $this->success('ok',$album);
}
/**
* @Apidoc\Title("删除相片")
* @Apidoc\Method("POST")
* @Apidoc\Param("id", type="string", require=true, desc="ID")
*/
function album_delete(Request $request): Response
{
$ids = Input('ids');
//$album = AlbumModel::whereIn('id',condition: $ids)->select();
//$album->delete();
AlbumModel::whereIn('id',condition: $ids)->delete();
return $this->success('ok');
}
/**
* 获取再群里的角色
* @Apidoc\NotParse()
* @Apidoc\NotDebug()
*/
private function get_user_in_group($group_id='',$user_id='')
{
$list = request()->IM->group->getGroupMemberList($group_id,$user_id);
return $list;
}
/**
* 头像上传
* @Apidoc\Method("POST")
* @Apidoc\Param("file", type="File", require=true, desc="文件")
*/
public function avatar(Request $request)
{
//单文件上传
$groupID = $request->post('groupID');
if(!$groupID){
return $this->fail(__('参数错误'));
}
$res = $this->_upload($request);
if(is_string($res)){
return $this->fail( $res);
}
$data = [
'groupID' => $groupID,
'faceURL' => $res[0]['file_name'],
];
$list = request()->IM->group->setGroupInfo($data);
return $this->success(__('successful'),$data);
}
}
+3 -1
View File
@@ -9,6 +9,8 @@ use hg\apidoc\annotation as Apidoc;
/**
* 消息控制器
* @Apidoc\NotParse()
* @Apidoc\NotDebug()
*/
class MessageController extends BaseController{
/**
@@ -20,7 +22,7 @@ class MessageController extends BaseController{
*/
function delete(Request $request):Response{
$im = $request->IM;
$data = $im->message->sendBusinessNotification('system',100007,[
$data = $im->message->sendBusinessNotification('system',idEncode(100007),[
'contentType' => 101,
'textElem' => [
'content' => '欢迎使用4'.Config('site.name')
+2
View File
@@ -9,6 +9,8 @@ use hg\apidoc\annotation as Apidoc;
/**
* 产品模块
* @Apidoc\NotParse()
* @Apidoc\NotDebug()
*/
class ProductController extends BaseController{
/**
@@ -12,6 +12,8 @@ use hg\apidoc\annotation as Apidoc;
/**
* 问卷
* @Apidoc\NotParse()
* @Apidoc\NotDebug()
*/
class QuestionnaireController extends BaseController{
/**
@@ -10,6 +10,8 @@ use hg\apidoc\annotation as Apidoc;
/**
* 充值模块
* @Apidoc\NotParse()
* @Apidoc\NotDebug()
*/
class RechargeController extends BaseController{
/**
+2
View File
@@ -7,6 +7,8 @@ use hg\apidoc\annotation as Apidoc;
/**
* 用户角色
* @Apidoc\NotParse()
* @Apidoc\NotDebug()
*/
class RoleController extends BaseController{
/**
+3 -1
View File
@@ -11,6 +11,8 @@ use Shopwwi\WebmanFilesystem\Facade\Storage;
use hg\apidoc\annotation as Apidoc;
/**
* 签到模块
* @Apidoc\NotParse()
* @Apidoc\NotDebug()
*/
class SigninController extends BaseController
@@ -275,7 +277,7 @@ class SigninController extends BaseController
* @Apidoc\Method("POST")
* @Apidoc\Param("file", type="string",require=true, desc="文件")
*/
function upload(Request $request)
function upload(Request $request,$return = false)
{
//多文件上传
$files = $request->file();
+1 -5
View File
@@ -159,12 +159,8 @@ class TeamController extends BaseController{
//$result['data'][$k]['created_at'] = date('Y-m-d H:i:s', $item['created_at']);
$result['data'][$k]['total_count'] = UserTeamModel::where('ancestor_id',$item['id'])->where('status',1)->where('depth','>',0)->count('descendant_id');
$result['data'][$k]['direct_total'] = cache('team_direct_total_'.$item['id'])??0;
$performance = get_performance($item['id']);
$result['data'][$k]['performance_large'] = $performance[0];
$result['data'][$k]['performance_small'] = $performance[1];
$result['data'][$k]['role'] = isset($role_arr[$item['role_id']]) ? $role_arr[$item['role_id']] : __('普通用户');
$result['data'][$k]['level'] = get_user_level($item['id'],$item['performance_small']);
$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;
}
+29 -21
View File
@@ -38,6 +38,7 @@ class UserController extends BaseController{
$gender = input('gender',null);
$faceURL = input('faceURL',null);
$birth = input('birth',null);
$bio = input('bio',null);
$save_data =[];
if($nickname){
$save_data['nickname'] = $nickname;
@@ -46,7 +47,10 @@ class UserController extends BaseController{
$save_data['sex'] = $gender;
}
if($faceURL){
$save_data['avatar'] = $faceURL;
$save_data['faceURL'] = $faceURL;
}
if($bio){
$save_data['bio'] = $bio;
}
if($birth){
$save_data['birthday'] = datetime($birth/1000,'Y-m-d');
@@ -133,21 +137,15 @@ class UserController extends BaseController{
public function avatar(Request $request)
{
//单文件上传
$file = $request->file('file0');
try {
$result = Storage::adapter('public')->path('upload/avatar')->size(1024*1024*5)->extYes(['image/jpeg','image/png'])->processUpload($file,function ($image){
$image->resize(200,200);
return $image;
},true);
\support\Jwt::getUser()->save([
'avatar' => '/'.$result->file_name,
]);
//$result->ss = cdnurl($result->url);
//P($result);
return $this->success(__('successful'),$result);
}catch (\Exception $e){
return $this->error($e->getMessage());
$res = $this->_upload($request);
if(is_string($res)){
return $this->fail( $res);
}
$data = [
'avatar' => $res[0]['file_name'],
];
\support\Jwt::getUser()->save($data);
return $this->success(__('successful'),$data);
}
function realname(Request $request): Response
{
@@ -198,7 +196,11 @@ class UserController extends BaseController{
*/
function find(Request $request): Response
{
$userIDs = Input('userIDs');
$ids = Input('userIDs');
if(is_string($ids)){
$ids = explode(',',$ids);
}
$userIDs = array_map('idDecode',$ids);
//$res = $request->IM->user->getUsersInfo($userIDs);
$list = Db::name('user')->
whereIn('id',$userIDs)
@@ -240,12 +242,18 @@ class UserController extends BaseController{
$searchtype = Input('searchtype');
$fields = 'id,avatar,username,nickname,avatar,sex,email,mobile,birthday,bio';
$model = Db::name('user')->field($fields)->where('status',1);
if($searchtype =='id'){
$model = $model->where('id',$keyword);
}else{
$model = $model->whereLike('username','%'.$keyword.'%');
}
$model = $model->where('id',idDecode($keyword));
// if($searchtype =='id'){
// $model = $model->where('id',$keyword);
// }else{
// $model = $model->whereLike('username|id','%'.$keyword.'%');
// }
$list = $model->paginate(Input('limit',10));
$list->each(function ($item){
$item['id'] = idEncode($item['id']);
return $item;
});
//log_alert($list->toArray());
return $this->success('ok',$list);
}
}
+3 -3
View File
@@ -23,11 +23,11 @@ class WalletController extends BaseController{
*/
public $noNeedLogin = [];
/**
* 用户调研币兑换问卷指标
* 用户货币互换
* @Apidoc\Method("POST")
* @Apidoc\Param("currency", type="string",require=true, desc="货币money_to_score")
* @Apidoc\Param("sendAmount", type="string",require=true, desc="调研币兑换数量")
* @Apidoc\Param("receiveAmount", type="string",require=true, desc="问卷指标兑换数量")
* @Apidoc\Param("sendAmount", type="string",require=true, desc="money兑换数量")
* @Apidoc\Param("receiveAmount", type="string",require=true, desc="score兑换数量")
* @Apidoc\Param("trade_password", type="string",require=true, desc="交易密码")
* @Apidoc\Param("code", type="string",require=true, desc="图形验证码(event=exchange)")
*/
@@ -11,6 +11,8 @@ use hg\apidoc\annotation as Apidoc;
/**
* 提现模块
* @Apidoc\NotParse()
* @Apidoc\NotDebug()
*/
class WithdrawlController extends BaseController{
/**
+33 -39
View File
@@ -19,14 +19,14 @@ class Auth implements MiddlewareInterface
*/
public function process(Request $request, callable $next): Response
{
$headers = [
'Access-Control-Allow-Credentials' => 'true',
'Access-Control-Allow-Origin' => $request->header('origin', '*'),
'Access-Control-Allow-Methods' => $request->header('access-control-request-method', '*'),
'Access-Control-Allow-Headers' => $request->header('access-control-request-headers', '*'),
];
if($request->method() == 'OPTIONS'){
$headers = [
'Access-Control-Allow-Credentials' => 'true',
'Access-Control-Allow-Origin' => $request->header('origin', '*'),
'Access-Control-Allow-Methods' => $request->header('access-control-request-method', '*'),
'Access-Control-Allow-Headers' => $request->header('access-control-request-headers', '*'),
];
$response = response('200',200,$headers);
$response = response('',204,$headers);
return $response;
}
$lang = $request->input('lang','zh-Hans');
@@ -49,28 +49,29 @@ class Auth implements MiddlewareInterface
//检测是否登录
try {
if (!\support\Jwt::isLogin()) {
return json([
return new Response(401,$headers,json_encode([
"code"=>401,
"data"=>[],
"msg"=>__('Please login first')
]);
]));
}
} catch (\Exception $e) {
return json([
return new Response(401,$headers,json_encode([
"code"=>401,
"data"=>[],
"msg"=>__('Please login first')
]);
]));
}
$user = \support\Jwt\JwtToken::getUser();
if(!$user['status']){
return json([
return new Response(403,$headers,json_encode([
"code"=>403,
"data"=>[],
"msg"=>__('Account is locked')
]);
]));
}
// $key = "debounce_" . $request->path() . "_" . ($user->id ?? 'guest');
// $ttl = 1; // 防抖时间(秒)
// $redishandler = new \Redis;
@@ -91,27 +92,27 @@ class Auth implements MiddlewareInterface
$actionname = strtolower(get_action_name());
$path = str_replace('.', '/', $controllername) . '/' . $actionname;
if (!\support\Jwt::check($path)) {
return json([
return new Response(405,$headers,json_encode([
"code"=>405,
"data"=>[],
"msg"=>__('You have no permission')
]);
"msg"=>__('have no permission')
]));
}
}
}
if($request->client!='web'){
$data = $request->post('data');
if($data){
$data = str_replace('%3D','=',$data);
$data = str_replace(' ','+',$data);
//var_dump($data);
$data = aesdecode($data);
$data = json_decode($data,true);
//var_dump($data);
$request->withBody($data);
}
}
// if($request->client!='web'){
// $data = $request->post('data');
// if($data){
// $data = str_replace('%3D','=',$data);
// $data = str_replace(' ','+',$data);
// //var_dump($data);
// $data = aesdecode($data);
// $data = json_decode($data,true);
// //var_dump($data);
// $request->withBody($data);
// }
// }
$config = Config('site');
$config['debug'] = config('app.debug');
$config['controller'] = $request->controller_name;
@@ -126,13 +127,6 @@ class Auth implements MiddlewareInterface
]);
$request->IM = $IM;
$response = $next($request);
$headers = [
'Access-Control-Allow-Credentials' => 'true',
'Access-Control-Allow-Origin' => $request->header('origin', '*'),
'Access-Control-Allow-Methods' => $request->header('access-control-request-method', '*'),
'Access-Control-Allow-Headers' => $request->header('access-control-request-headers', '*'),
];
$response->withHeaders($headers);
//cp('auth');
//\support\Log::alert('auth');
$body = str_replace([
@@ -140,10 +134,10 @@ class Auth implements MiddlewareInterface
],[
request()->path()
],$response->rawBody());
if($request->app=="api" && $request->client!='web'){
$body = aesencode($body);
}
$response->withBody($body)->getStatusCode();
// if($request->app=="api" && $request->client!='web'){
// $body = aesencode($body);
// }
$response->withHeaders($headers)->withBody($body)->getStatusCode();
$time = microtime() - $request->start_time;
//echo("响应时间:".$request->uri().':'.$time.PHP_EOL);
//$response = $next($request);
+1 -1
View File
@@ -45,7 +45,7 @@ class OpenIm extends Command
'host' => 'http://127.0.0.1:10002', // OpenIM API地址
'secret' => 'n1e5a6s6m7', // OpenIM密钥
]);
$data = $im->user->updateUserInfo('100001',['userInfo'=>['userId'=>'wx100001']]);
$data = $im->user->updateUserInfo(idEncode('100006'),['userInfo'=>['userId'=>'wx100001']]);
cp($data);
return self::SUCCESS;
}
+57
View File
@@ -0,0 +1,57 @@
<?php
namespace app\command;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Output\OutputInterface;
use support\think\Db;
use isszz\hashids\facade\Hashids;
use function GuzzleHttp\json_encode;
class User extends Command
{
protected static $defaultName = 'User';
protected static $defaultDescription = '用户';
/**
* @return void
*/
protected function configure()
{
$this->addOption('user_id','u', InputArgument::OPTIONAL, 'user_id');
$this->addOption('action','a', InputArgument::OPTIONAL, '操作类型');
}
/**
* @param InputInterface $input
* @param OutputInterface $output
* @return int
*/
protected function execute(InputInterface $input, OutputInterface $output): int
{
$action = $input->getOption('action','login');
if($action == 'login'){
$IM = new \support\OpenImSdk\Client([
'host' => 'http://127.0.0.1:10002', // OpenIM API地址
'secret' => 'n1e5a6s6m7', // OpenIM密钥
]);
$user_id = $input->getOption('user_id');
if(!$user_id){
return false;
}
$user = \support\Jwt::direct($user_id);
$imToken = $IM->auth->getUserToken(idEncode($user['id']),2);
cp('userID:' . $user['id']);
cp('nickname:' . $user['nickname']);
cp('token:' . $user['token']);
cp('imToken:' . $imToken['token']);
return 0;
}
cp('action not exist');
return 0;
}
}
+45 -7
View File
@@ -23,17 +23,27 @@ class HookController{
{
$userID= Input('userID');
$nickname= Input('nickname');
$users = Input('users');
$im = new \support\OpenImSdk\Client([
'host' => 'http://127.0.0.1:10002', // OpenIM API地址
'secret' => 'n1e5a6s6m7', // OpenIM密钥
]);
$im->message->sendBusinessNotification('official_team',$userID,[
'contentType' => 101,
'textElem' => [
'content' => '欢迎使用'.Config('site.name')
]
]);
foreach($users as $k=>$v){
// 'userID' => '0EO9K107ON',
// 'nickname' => '坏蛋',
// 'faceURL' => '/static/img/avatar.png',
// 'ex' => '',
// 'createTime' => 0,
// 'appMangerLevel' => 0,
// 'globalRecvMsgOpt' => 0,
$im->message->sendBusinessNotification('official_team',idEncode($v['userID']),[
'contentType' => 101,
'textElem' => [
'content' => '欢迎使用'.Config('site.name')
]
]);
}
return json([
"actionCode" => 0,
"errCode" => 0,
@@ -266,4 +276,32 @@ class HookController{
"nextCode"=> 0
]);
}
function callbackAfterDeleteFriendCommand() : Response {
$friendUserID = Input('friendUserID');
$ownerUserID = Input('ownerUserID');
$sdk = $this->getSdk();
$relation = $sdk->friend->isFriend($friendUserID,$ownerUserID);
if($relation){
if($relation['inUser1Friends']){
$this->getSdk()->friend->deleteFriend($friendUserID,$ownerUserID);
}
if($relation['inUser2Friends']){
$this->getSdk()->friend->deleteFriend($ownerUserID,$friendUserID);
}
}
return json([
"actionCode" => 0,
"errCode" => 0,
"errMsg" => "",
"errDlt" => "",
"nextCode"=> 0
]);
}
function getSdk(){
$IM = new \support\OpenImSdk\Client([
'host' => 'http://127.0.0.1:10002', // OpenIM API地址
'secret' => 'n1e5a6s6m7', // OpenIM密钥
]);
return $IM;
}
}
+4 -5
View File
@@ -14,7 +14,7 @@ class User{
if($user->parent_id){
parent_info( $user->id,[
'id' => $user->parent_id,
'username' => Db::name('user')->where('id',op: $user->parent_id)->value('username')
'username' => Db::name('user')->where('id',$user->parent_id)->value('username')
]);
//管理直推人数
cache_add('team_direct_total_'.$user->parent_id,1);
@@ -64,16 +64,15 @@ class User{
$data['avatar'] = $data['avatar']?:"/static/img/avatar.png";
$data['role'] = isset($role_arr[$data['role_id']]) ? $role_arr[$data['role_id']] : __('普通用户');//\app\model\UserRole::where('id',$data['role_id'])->value('name');
$data['level'] = get_user_level($data['id']);
/**
* @var \support\OpenImSdk\Client $IM
*/
$IM = request()->IM;
$imToken = $IM->auth->getUserToken($data['id'],Input('platform'));
$imToken = $IM->auth->getUserToken(idEncode($data['id']),Input('platform'));
$data['imToken'] = $imToken['token'];
$data['userID'] = $data['id'] ;
$data['id'] = idEncode($data['id']);
$last_see = $last_see ?? cache('last_see_'.$data['id']);
$data['id'] = idEncode($data['id']);
$data['userID'] = $data['id'] ;
$count = 0;
$data['friend_settings'] = [
'unread_count' => $count ??0,
+19 -127
View File
@@ -236,26 +236,29 @@ if (!function_exists('abort')) {
if (!function_exists('idEncode')) {
function idEncode($id = '')
{
return \isszz\hashids\facade\Hashids::mode('bilibili')->encode($id);
if($id<=100234){return $id.'';}
return id_encode($id);
}
}
if (!function_exists('idDecode')) {
function idDecode($id = '')
{
return \isszz\hashids\facade\Hashids::mode('bilibili')->decode($id);
$_id= intval($id);
if($_id == $id){return $id;}
return id_decode($id);
}
}
/**
* 生成可逆的邀请码(8位,含校验位)
* @param int $user_id 用户ID(需≥1000
* @param int $id 用户ID(需≥1000
* @return string 大写字母+数字组合
*/
if (!function_exists('base62Encode')) {
function base62Encode(int $user_id,$secret='your_secret_salt'): string {
function base62Encode(int $id,$secret='your_secret_salt'): string {
// 添加校验位(防止篡改)
$hash = crc32($user_id . $secret) % 1000;
$code_num = $user_id * 1000 + $hash;
$hash = crc32($id . $secret) % 1000;
$code_num = $id * 1000 + $hash;
// Base62 编码(0-9A-Za-z
$base62 = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
@@ -271,7 +274,7 @@ if (!function_exists('base62Encode')) {
}
/**
* 从邀请码解析用户ID
* @return int|false 成功返回user_id,失败返回false
* @return int|false 成功返回id,失败返回false
*/
if (!function_exists('base62Decode')) {
function base62Decode(string $code,$secret='your_secret_salt'): int|false {
@@ -286,15 +289,15 @@ if (!function_exists('base62Decode')) {
}
// 分离校验位
$user_id = (int)($code_num / 1000);
$id = (int)($code_num / 1000);
$hash = $code_num % 1000;
// 校验
if (crc32($user_id . $secret) % 1000 != $hash) {
if (crc32($id . $secret) % 1000 != $hash) {
return false;
}
return $user_id;
return $id;
}
}
@@ -660,26 +663,6 @@ if (!function_exists('parent_info')) {
return $info;
}
}
if (!function_exists('get_user_level')) {
function get_user_level($user_id,$performance_small=null)
{
if (!$user_id) {
return 0;
}
if(is_null($performance_small)){
$performance= get_performance($user_id);
$performance_small = $performance[1];
}
$user_level_rules = Config('site.user_level_rules');
$level = 0;
foreach ($user_level_rules as $_level => $score) {
if($performance_small>$score){
$level = $_level;
}
}
return $level;
}
}
if(!function_exists('datetime')){
function datetime($timestamp=0,$format='Y-m-d H:i:s'){
@@ -700,20 +683,6 @@ if(!function_exists('datetime')){
return $timestamp;
}
}
if(!function_exists('get_performance')){
function get_performance($user_id){
$performance_list = \app\model\UserTeam::alias('ut')
->join('user_extend ue', 'ut.descendant_id = ue.user_id')
->where('ut.ancestor_id', $user_id)
->order('ue.sales desc')->column('ue.sales');
if(empty($performance_list)){
$performance_list = [0,0];
}
return [array_shift($performance_list), array_sum($performance_list)];
}
}
if(!function_exists('log_alert')){
function log_alert($data='',$channel='default'){
if(!is_string($data)){
@@ -743,84 +712,6 @@ if(!function_exists('enum_dir')){
return $list ;
}
}
if(!function_exists('jicha')){
function jicha($current_user_id,$amount,$reward_arr=[]){
$distributed_users = [];
$distributed_rate = 0; // 已分配的累计比例
$last_commissioned_level = 0; // 上一次成功分佣的用户角色等级(role_id)
//$reward_arr = [0,0.02,0.04,0.06,0.08,0.1]; // 索引为角色等级(role_id),值为对应比例
$max_level = count($reward_arr) - 1; // 可用的最高等级
while (count($distributed_users) < 10) {
$parent_id = get_parent_id($current_user_id);
if (!$parent_id) {
// cp(sprintf("用户ID:%s\t级别:%s\t父级:%s\t%s\t%s\n\n",
// $parent_id.'',
// '-',
// '-',
// "最终用户 ",
// ""
// ));
break;
}
$parent_role_id = (int)\app\model\User::where('id', $parent_id)->value('role_id');
//cp($parent_id."\t".$parent_role_id."\t".$last_commissioned_level);
if ($parent_role_id > 5) {
// cp(sprintf("用户ID:%s\t级别:%s\t父级:%s\t%s\t%s\n\n",
// $parent_id,
// $parent_role_id,
// '-',
// "用户级别异常",
// ""
// ));
break;
}
// 仅当上级角色等级高于上一次成功分佣的等级时才考虑分配
if ($parent_role_id > $last_commissioned_level) {
$idx = $parent_role_id;
if ($idx > $max_level) { // 超出定义范围则使用最高档
$idx = $max_level;
}
$current_rate = $reward_arr[$idx];
$available_rate = bcsub($current_rate, $distributed_rate, 4);
if (bccomp($available_rate, 0, 6) === 1) { // available_rate > 0
$commission = bcmul($available_rate, $amount, 4);
$distributed_rate += $available_rate;
$last_commissioned_level = $parent_role_id;
$distributed_users[] = [
'user_id' => $parent_id,
'role_id' => $parent_role_id,
'rate' => $available_rate,
'amount' => $commission
];
} else {
// 可分配比例<=0,停止继续查找
// cp(sprintf("用户ID:%s\t级别:%s\t父级:%s\t%s\t%s\n\n",
// $parent_id,
// $parent_role_id,
// '-',
// "可分配比例不足,结束",
// "已分配比例:".$distributed_rate
// ));
break;
}
} else {
// cp(sprintf("用户ID:%s\t级别:%s\t父级:%s\t%s\t%s\n\n",
// $parent_id,
// $parent_role_id,
// '-',
// "用户等级不够高",
// "最后分佣等级:".$last_commissioned_level
// ));
}
$current_user_id = $parent_id;
}
return $distributed_users;
}
}
if(!function_exists('generateShortUniqueID')){
function generateShortUniqueID($length = 8) {
// 生成指定长度的随机字节,转为 Base64 编码并去除不必要字符
@@ -836,14 +727,15 @@ if(!function_exists('get_user_rights')){
// 'max_group_join_count' => 999999999999,
// 'max_gourp_create_count' => 999999999999
// ];
$user_id = idDecode($user_id);
$key = 'user_rights_'.$user_id;
$result = cache($key);
if(!$result){
log_alert(\think\facade\Db::name('user_role')->alias('ur')
->join('user u','ur.id = u.role_id')
->where('u.id',$user_id)
->field('ur.name,ur.max_send_msg_count,ur.max_friend_count,ur.max_group_join_count,ur.max_gourp_create_count')
->buildSql());
// log_alert(\think\facade\Db::name('user_role')->alias('ur')
// ->join('user u','ur.id = u.role_id')
// ->where('u.id',$user_id)
// ->field('ur.name,ur.max_send_msg_count,ur.max_friend_count,ur.max_group_join_count,ur.max_gourp_create_count')
// ->buildSql());
$result = \think\facade\Db::name('user_role')->alias('ur')
->join('user u','ur.id = u.role_id')
->where('u.id',$user_id)
+52
View File
@@ -0,0 +1,52 @@
<?php
namespace app\model;
/**
* 相册模型
* @property integer $id 主键(ID)
* @property integer $user_id 用户ID
* @property integer $group_id 内容
* @property string $url 图片
* @property string $title 标题
* @property integer $created_at 创建时间
* @property integer $updated_at 更新时间
* @property integer $status 状态(0:隐藏 1:正常)
*/
class Album extends Base
{
protected $name = 'album';
protected function getOptions(): array
{
return array_merge(parent::getOptions(), [
'insert' => [
'status' => 1,
],
]);
}
public static function onAfterInsert($row){
$changeData = $row->getChangedData();
if(isset($changeData['url'])) {
Files::where('path',$changeData['url'])->inc('use_count');
};
}
public static function onAfterUpdate($row){
$OrgData = $row->getOrigin();
$changeData = $row->getChangedData();
if(isset($OrgData['url']) && $OrgData['url']) {
\support\Log::info('OrgData string');
Files::where('path',$OrgData['url'])->dec('use_count');
};
if(isset($changeData['url']) && $changeData['url']) {
\support\Log::info('changeData string');
Files::where('path',$changeData['url'])->inc('use_count');
};
}
public static function onAfterDelete($row){
Files::where('path',$row->url)->dec('use_count');
}
}
+6 -16
View File
@@ -37,7 +37,7 @@ class BalanceLog extends Base
{
$model = new static();
if(isset($data['currency'])){
if(in_array($data['currency'],Config('site.allow_balance_log'))){
if(in_array($data['currency'],Config('site.allow_currency_logs'))){
$data['status']=isset($data['status']) ? $data['status']:1;
$data['user_id'] = intval($data['user_id']);
$data['amount'] = floatval($data['amount']);
@@ -56,8 +56,8 @@ class BalanceLog extends Base
public static function createAllIndexes(): array
{
$results = [];
$allow_balance_log = Config('site.allow_balance_log');
foreach ($allow_balance_log as $currency) {
$allow_currency_logs = Config('site.allow_currency_logs');
foreach ($allow_currency_logs as $currency) {
$results[$currency] = self::createTableIndexes($currency);
}
return $results;
@@ -115,8 +115,8 @@ class BalanceLog extends Base
public static function archiveData(int $days = 3): array
{
$results = [];
$allow_balance_log = Config('site.allow_balance_log');
foreach ($allow_balance_log as $currency) {
$allow_currency_logs = Config('site.allow_currency_logs');
foreach ($allow_currency_logs as $currency) {
$results[$currency] = self::archiveCurrencyData($currency, $days);
}
return $results;
@@ -175,17 +175,7 @@ class BalanceLog extends Base
->order('created_at', 'desc');
if ($type) {
if($type == '99999'){
$query->whereIn('type', [
\app\enum\BalanceType::OUTPUT_REWARD->value,
\app\enum\BalanceType::WITHDRAW_REWARD->value,
\app\enum\BalanceType::PRODUCT_INCOME->value,
\app\enum\BalanceType::AGENT_COMMISSION->value,
\app\enum\BalanceType::DIFFERENTIAL_COMMISSION->value
]);
}else{
$query->where('type', intval($type));
}
$query->whereIn('type', $type);
}
if ($startTime) {
+6
View File
@@ -57,6 +57,12 @@ class FriendCircle extends Base
}
};
}
public static function onAfterDelete($row){
FriendCircleLike::whereIn('circle_id',$row->id)->delete();
FriendCircleComment::whereIn('circle_id',$row->id)->delete();
}
/**
* 关联用户
*/
+6 -7
View File
@@ -75,9 +75,9 @@ use support\think\Db;
*/
class User extends Base
{
use \think\model\concern\SoftDelete;
//use \think\model\concern\SoftDelete;
public static function onAfterInsert($row){
$res = request()->IM->user->userRegister($row->id,$row->nickname,cdnurl($row->avatar));
$res = request()->IM->user->userRegister(idEncode($row->id),$row->nickname,cdnurl($row->avatar));
}
public static function onAfterUpdate($row){
$changeData = $row->getChangedData();
@@ -87,25 +87,24 @@ class User extends Base
'nickname' => $row->nickname,
'faceURL' => cdnurl($row->avatar)
];
request()->IM->user->updateUserInfo($row->id,$sdata);
request()->IM->user->updateUserInfo(idEncode($row->id),$sdata);
}
if(isset($changeData['status']) || $changeData['status'] == '0'){
request()->IM->user->forceLogout($row->id);
request()->IM->user->forceLogout(idEncode($row->id));
}
}
public static function onAfterDelete($row)
{
Db::name('address')->where('user_id',$row->id)->delete();
Db::name('recharge')->where('user_id',$row->id)->delete();
Db::name('record')->where('user_id',$row->id)->delete();
//Db::name('record')->where('user_id',$row->id)->delete();
Db::name('withdrawl')->where('user_id',$row->id)->delete();
Db::name('user_extend')->where('user_id',$row->id)->delete();
Db::name('user_team')->where('descendant_id|ancestor_id','=',$row->id)->delete();
Db::name('withdrawl')->where('user_id',$row->id)->delete();
foreach(Config('site.allow_currencys') as $currency){
(new \app\model\BalanceLog)->setSuffix('_'.$currency)->where('user_id',(int)$row->id)->delete();
}
request()->IM->user->forceLogout($row->id);
request()->IM->user->forceLogout(idEncode($row->id));
}
public function role()
{
+121
View File
@@ -0,0 +1,121 @@
<?php
return [
["label" => "中国", "value" => "86"],
["label" => "马来西亚", "value" => "60"],
["label" => "印度尼西亚", "value" => "62"],
["label" => "菲律宾", "value" => "63"],
["label" => "新加坡", "value" => "65"],
["label" => "泰国", "value" => "66"],
["label" => "文莱", "value" => "673"],
["label" => "日本", "value" => "81"],
["label" => "韩国", "value" => "82"],
["label" => "越南", "value" => "84"],
["label" => "朝鲜", "value" => "850"],
["label" => "香港(中国)", "value" => "852"],
["label" => "澳门(中国)", "value" => "853"],
["label" => "柬埔寨", "value" => "855"],
["label" => "老挝", "value" => "856"],
["label" => "台湾(中国)", "value" => "886"],
["label" => "孟加拉国", "value" => "880"],
["label" => "土耳其", "value" => "90"],
["label" => "印度", "value" => "91"],
["label" => "巴基斯坦", "value" => "92"],
["label" => "阿富汗", "value" => "93"],
["label" => "斯里兰卡", "value" => "94"],
["label" => "缅甸", "value" => "95"],
["label" => "马尔代夫", "value" => "960"],
["label" => "黎巴嫩", "value" => "961"],
["label" => "约旦", "value" => "962"],
["label" => "叙利亚", "value" => "963"],
["label" => "伊拉克", "value" => "964"],
["label" => "科威特", "value" => "965"],
["label" => "沙特阿拉伯", "value" => "966"],
["label" => "阿曼", "value" => "968"],
["label" => "以色列", "value" => "972"],
["label" => "巴林", "value" => "973"],
["label" => "卡塔尔", "value" => "974"],
["label" => "不丹", "value" => "975"],
["label" => "蒙古", "value" => "976"],
["label" => "尼泊尔", "value" => "977"],
["label" => "伊朗", "value" => "98"],
["label" => "塞浦路斯", "value" => "357"],
["label" => "巴勒斯坦", "value" => "970"],
["label" => "阿联酋", "value" => "971"],
["label" => "俄罗斯联邦", "value" => "7"],
["label" => "希腊", "value" => "30"],
["label" => "荷兰", "value" => "31"],
["label" => "比利时", "value" => "32"],
["label" => "法国", "value" => "33"],
["label" => "西班牙", "value" => "34"],
["label" => "直布罗陀", "value" => "350"],
["label" => "葡萄牙", "value" => "351"],
["label" => "卢森堡", "value" => "352"],
["label" => "爱尔兰", "value" => "353"],
["label" => "冰岛", "value" => "354"],
["label" => "阿尔巴尼亚", "value" => "355"],
["label" => "马耳他", "value" => "356"],
["label" => "安道尔", "value" => "376"],
["label" => "芬兰", "value" => "358"],
["label" => "保加利亚", "value" => "359"],
["label" => "匈牙利", "value" => "36"],
["label" => "德国", "value" => "49"],
["label" => "南斯拉夫", "value" => "381"],
["label" => "意大利", "value" => "39"],
["label" => "圣马力诺", "value" => "378"],
["label" => "梵蒂冈", "value" => "3906698"],
["label" => "罗马尼亚", "value" => "40"],
["label" => "瑞士", "value" => "41"],
["label" => "列支敦士登", "value" => "423"],
["label" => "奥地利", "value" => "43"],
["label" => "英国", "value" => "44"],
["label" => "丹麦", "value" => "45"],
["label" => "瑞典", "value" => "46"],
["label" => "挪威", "value" => "47"],
["label" => "波兰", "value" => "48"],
["label" => "捷克", "value" => "420"],
["label" => "斯洛伐克", "value" => "421"],
["label" => "摩纳哥", "value" => "377"],
["label" => "马其顿", "value" => "389"],
["label" => "科罗地亚", "value" => "385"],
["label" => "斯洛文尼亚", "value" => "386"],
["label" => "波斯尼亚和塞哥维那", "value" => "387"],
["label" => "亚美尼亚共和国", "value" => "374"],
["label" => "白俄罗斯共和国", "value" => "375"],
["label" => "格鲁吉亚共和国", "value" => "995"],
["label" => "哈萨克斯坦共和国", "value" => "7"],
["label" => "吉尔吉斯坦共和国", "value" => "996"],
["label" => "乌兹别克斯坦共和国", "value" => "998"],
["label" => "塔吉克斯坦共和国", "value" => "992"],
["label" => "土库曼斯坦共和国", "value" => "993"],
["label" => "乌克兰", "value" => "380"],
["label" => "立陶宛", "value" => "370"],
["label" => "拉脱维亚", "value" => "371"],
["label" => "爱沙尼亚", "value" => "372"],
["label" => "摩尔多瓦", "value" => "373"],
["label" => "埃及", "value" => "20"],
["label" => "摩洛哥", "value" => "212"],
["label" => "阿尔及利亚", "value" => "213"],
["label" => "突尼斯", "value" => "216"],
["label" => "利比亚", "value" => "218"],
["label" => "冈比亚", "value" => "220"],
["label" => "塞内加尔", "value" => "221"],
["label" => "毛里塔尼亚", "value" => "222"],
["label" => "马里", "value" => "223"],
["label" => "几内亚", "value" => "224"],
["label" => "科特迪瓦", "value" => "225"],
["label" => "布基拉法索", "value" => "226"],
["label" => "尼日尔", "value" => "227"],
["label" => "多哥", "value" => "228"],
["label" => "贝宁", "value" => "229"],
["label" => "毛里求斯", "value" => "230"],
["label" => "利比里亚", "value" => "231"],
["label" => "塞拉利昂", "value" => "232"],
["label" => "加纳", "value" => "233"],
["label" => "尼日利亚", "value" => "234"],
["label" => "乍得", "value" => "235"],
["label" => "中非", "value" => "236"],
["label" => "喀麦隆", "value" => "237"],
["label" => "佛得角", "value" => "238"],
["label" => "圣多美", "value" => "239"],
["label" => "普林西比", "value" => "239"],
];
+6 -6
View File
@@ -4,18 +4,18 @@ return [
'enable' => true,
// 默认连接名称
'default' => 'main', // 支持bilibili的BV模式
'default' => 'other', // 支持bilibili的BV模式
// Hashids modes
'modes' => [
'main' => [
'salt' => '',
'length' => 0,
'salt' => 'n1e5a6s6m7',
'length' => 10,
],
'other' => [
'salt' => 'salt',
'length' => 0,
'alphabet' => 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'
'salt' => 'n1e5a6s6m7',
'length' => 10,
'alphabet' => 'ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'
],
'bilibili' => [
// 此模式无需添加其他的配置
+1 -1
View File
@@ -17,7 +17,7 @@ return [
'transport' => 'tcp',
'context' => [],
'name' => 'webman',
'count' => \support\Env::get('app.debug',false) ? 2 : cpu_count() * 4,
'count' => cpu_count() * 4,
//'count' => 4,
'user' => '',
'group' => '',
+38
View File
@@ -0,0 +1,38 @@
<?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;
/**
* 会话管理
*/
class ConversationController extends Crud
{
/**
* @var \app\model\UserXuanchuan
*/
protected $model = null;
/**
* 构造函数
* @return void
*/
function __construct()
{
}
function select(Request $request): Response{
$list = $request->IM->conversation->getSortedConversationList();
return json([
'code' => 0,
'msg' => 'success',
'data' => $list
]);
}
}
+38
View File
@@ -0,0 +1,38 @@
<?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;
/**
* 用户宣传
*/
class FriendController extends Crud
{
/**
* @var \app\model\UserXuanchuan
*/
protected $model = null;
protected $relationSearch = ['user'];
/**
* 构造函数
* @return void
*/
function __construct()
{
$this->model = new \app\model\UserXuanchuan();
$statusList = $this->model->getStatusList();
$this->assign("statusList", $statusList);
$this->assignconfig("statusList", $statusList);
$typeList = $this->model->getTypeList();
$this->assign("typeList", $typeList);
$this->assignconfig("typeList", $typeList);
}
}
+38
View File
@@ -0,0 +1,38 @@
<?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;
/**
* 用户宣传
*/
class GroupController extends Crud
{
/**
* @var \app\model\UserXuanchuan
*/
protected $model = null;
protected $relationSearch = ['user'];
/**
* 构造函数
* @return void
*/
function __construct()
{
$this->model = new \app\model\UserXuanchuan();
$statusList = $this->model->getStatusList();
$this->assign("statusList", $statusList);
$this->assignconfig("statusList", $statusList);
$typeList = $this->model->getTypeList();
$this->assign("typeList", $typeList);
$this->assignconfig("typeList", $typeList);
}
}
+38
View File
@@ -0,0 +1,38 @@
<?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;
/**
* 用户宣传
*/
class MessageController extends Crud
{
/**
* @var \app\model\UserXuanchuan
*/
protected $model = null;
protected $relationSearch = ['user'];
/**
* 构造函数
* @return void
*/
function __construct()
{
$this->model = new \app\model\UserXuanchuan();
$statusList = $this->model->getStatusList();
$this->assign("statusList", $statusList);
$this->assignconfig("statusList", $statusList);
$typeList = $this->model->getTypeList();
$this->assign("typeList", $typeList);
$this->assignconfig("typeList", $typeList);
}
}
@@ -38,6 +38,9 @@ class UserController extends Crud
$this->assignconfig('groupList',$groupList);
$this->assign('roleList',$roleList);
$this->assignconfig('roleList',$roleList);
$areaList = Config('areacode');
$this->assign('areaList',$areaList);
$this->assignconfig('areaList',$areaList);
}
public function team(Request $request): Response
{
+1 -1
View File
@@ -2,7 +2,7 @@
<!-- 数据表格 -->
<div class="card">
<ul class="nav nav-tabs page-tabs" id="filter_currency">
{volist name=":Config('site.allow_balance_log')" id="cvo"}
{volist name=":Config('site.allow_currency_logs')" id="cvo"}
<li {if $cvo == 'money'}class="active" {/if} data-currency="{$cvo}"> <a href="javascript:;">{:__($cvo)}</a> </li>
{/volist}
</ul>
+16 -7
View File
@@ -47,9 +47,18 @@
</div>
</div> -->
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">用户名</label>
<label class="control-label col-xs-12 col-sm-2">手机号</label>
<div class="col-xs-12 col-sm-8 col-md-6">
<input type="text" name="username" value="{$row.username|null}" autocomplete="off" data-rule="required" class="form-control">
<div class="input-group" style="width: 100%;">
<div class="input-group-addon" style="padding: 0;width: 200px;">
<select name="region" class="form-control">
{foreach name=":Config('areacode')" item="vo"}
<option value="{$vo.value}" {if $vo.value == $row.region}selected{/if}>(+{$vo.value}){$vo.label}</option>
{/foreach}
</select>
</div>
<input type="text" name="mobile" value="{$row.mobile|null}" autocomplete="off" data-rule="required" class="form-control">
</div>
</div>
</div>
@@ -86,7 +95,7 @@
<div class="form-group">
<label for="type" class="control-label col-xs-12 col-sm-2">头像</label>
<div class="col-xs-12 col-sm-8 col-md-6">
<input id="c-avatar" class="form-control" size="50" name="avatar" type="hidden" value="{$row.avatar|default='__IMG__/user/avatar.svg'}" data-tip="头像">
<input id="c-avatar" class="form-control" size="50" name="avatar" type="hidden" value="{$row.avatar|default='/static/avatar/'.rand(0,17).'.png'|cdnurl}" data-tip="头像">
<ul class="list-inline clearfix lyear-uploads-pic" data-template="preview" id="p-avatar">
<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.files.upload" id="add-pic-btn" href="javascript:;" title="点击上传" data-input-id="c-avatar" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp,image/webp" data-multiple="false" data-preview-id="p-avatar"></a>
@@ -103,10 +112,10 @@
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-12 col-sm-2">手机</label>
<div class="form-group" style="display:none;">
<label class="control-label col-xs-12 col-sm-2">用户名</label>
<div class="col-xs-12 col-sm-8 col-md-6">
<input type="text" name="mobile" value="{$row.mobile|null}" autocomplete="off" class="form-control">
<input type="text" name="username" value="{$row.username|null}" autocomplete="off" class="form-control">
</div>
</div>
@@ -125,7 +134,7 @@
data-date-debug="true"
data-date-sideBySide="true"
data-date-collapse="false"
data-date-format="YYYY-MM-DD HH:mm:ss"
data-date-format="YYYY-MM-DD"
autocomplete="off" class="form-control datetimepicker">
</div>
</div>
+4 -4
View File
@@ -129,10 +129,7 @@ define(['table', 'upload','form','qrcode'], function (Table,Upload,Form) {
Table.api.bindevent(table);
},
update:function(){
Config['upload_url'] = '/files/avatar';
var form = $('form');
Form.api.bindevent(form)
this.getRole();
this.insert();
$('#qrcode div').qrcode({
width: 128,height: 128,
@@ -144,6 +141,9 @@ define(['table', 'upload','form','qrcode'], function (Table,Upload,Form) {
var form = $('form');
Form.api.bindevent(form)
this.getRole();
$('[name=mobile]').on('change',function(){
$('[name=username]').val($(this).val());
});
},
getRole:function(){
Fast.api.ajax({
+5 -2
View File
@@ -528,11 +528,14 @@
const onClickDownload = () => {
const $nav = navigator.userAgent.toLowerCase();
if($nav.match(/iphone/i) == "iphone"){
alert('暂未开放');
//alert('暂未开放');
//window.location.href = 'https://shunliao.oss-accelerate.aliyuncs.com';
//window.location.href = 'https://static.shun777.com/app/shunliao.ipa';
window.location.href = 'https://h5.shun777.com';
}else{
//window.location.href = 'https://shunliao.oss-accelerate.aliyuncs.com/apk/install.apk';
window.location.href = '/shunliao.apk';
window.location.href = 'https://static.shun777.com/app/shunliao_v3.apk';
//window.location.href = '/shunliao.apk?v=2';
}
}
Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 81 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 62 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

+6 -5
View File
@@ -153,11 +153,12 @@ class Jwt
return false;
}
if($verifyType == 'password'){
//if ($user->username!='' && !\plugin\admin\app\common\Util::passwordVerify($password,$user->password)) {
if (!\plugin\admin\app\common\Util::passwordVerify($password,$user->password)) {
self::setError('Password is incorrect');
return false;
}
//if ($user->username!='' && $user->id!='100703') {
if (!\plugin\admin\app\common\Util::passwordVerify($password,$user->password)) {
self::setError('Password is incorrect');
return false;
}
//}
}else{
captcha_verfiy($type,'login',$account);
}
+1 -1
View File
@@ -44,7 +44,7 @@ class Auth
* @param string $platformID 平台ID,默认为android
* @return array
*/
public function forceLogout(string $userID, string $platformID = 'android'): array
public function forceLogout(string $userID, string $platformID = 'android'): array|bool
{
// 获取管理员token
$adminToken = Utils::getAdminToken();
+9 -2
View File
@@ -33,11 +33,18 @@ class Conversation
* @param string $userID 用户ID
* @return array
*/
public function getSortedConversationList(string $userID): array
public function getSortedConversationList(string $userID,$conversationIDs='',int $page=1,int $pagesize=10): array
{
// 获取管理员token
$adminToken = Utils::getAdminToken();
return Utils::send(Url::$getSortedConversationList, ['userID' => $userID], '获取排序的会话列表失败', $adminToken);
return Utils::send(Url::$getSortedConversationList, [
'userID' => $userID,
'conversationIDs' => $conversationIDs,
'pagination' => [
'pageNumber' => $page,
'showNumber' => $pagesize
]
], '获取排序的会话列表失败', $adminToken);
}
/**
+11 -7
View File
@@ -7,6 +7,9 @@ use support\OpenImSdk\Core\Utils;
class Group
{
function setGroupInfo($data=[]){
return Utils::send('/group/set_group_info_ex', $data);
}
/**
* 创建群组
* @param string $ownerUserID 群主ID
@@ -94,22 +97,23 @@ class Group
/**
* 获取群成员列表
* @param string $groupID 群组ID
* @param int $filter 过滤类型,0所有,1群主,2管理员,3普通成员,4禁言,5进入黑名单
* @param string $filter 过滤类型,0所有,1群主,2管理员,3普通成员,4禁言,5进入黑名单
* @param int $offset 偏移量
* @param int $count 数量
* @return array
*/
public function getGroupMemberList(string $groupID, int $filter = 0, int $offset = 0, int $count = 100): array
public function getGroupMemberList(string $groupID='', string $keyword = '', int $page = 1, int $pagesize = 100): array
{
// 获取管理员token
$adminToken = Utils::getAdminToken();
$data = [
'groupID' => $groupID,
'filter' => $filter,
'offset' => $offset,
'count' => $count
'keyword' => $keyword,
'pagination' => [
'pageNumber' => $page,
'showNumber' => $pagesize
]
];
return Utils::send(Url::$getGroupMemberList, $data, '获取群成员列表失败', $adminToken);
return Utils::send(Url::$getGroupMemberList, $data, '获取群成员列表失败');
}
/**
+53 -7
View File
@@ -6,7 +6,48 @@ use support\OpenImSdk\Core\Url;
use support\OpenImSdk\Core\Utils;
class Message
{
{
public function sendSingleMessage(string $sendID, string $recvID = '', array $data=[]): array
{
$data['recvID'] = $recvID;
$data['groupID'] = '';
$data['sessionType'] = 2;
return $this->sendMessage($sendID,$data);
}
public function sendGroupMessage(string $sendID, string $groupID = '', array $data=[]): array
{
$data['recvID'] = '';
$data['groupID'] = $groupID;
$data['sessionType'] = 3;
return $this->sendMessage($sendID,$data);
}
public function sendMessage(string $sendID, array $data=[]): array
{
$user = \think\facade\Db::name('user')->where('id',$sendID)->field('avatar,nickname')->find();
$data = array_merge([
"sendID" => $sendID,
"senderNickname" => $user['nickname'],
"senderFaceURL" => $user['avatar'],
"senderPlatformID" => 5,
"content"=> [
"content" => "hello!!"
],
"contentType" => 1,
"sessionType" => 4,
"isOnlineOnly" => false,
"notOfflinePush"=> true,
"sendTime" => time()*1000,
"offlinePushInfo"=> [
"title" => "您收到一条新的消息",
"desc" => "",
"ex" => "",
"iOSPushSound"=> "default",
"iOSBadgeCount"=> true
],
"ex"=> ""
],$data);
return Utils::send(Url::$sendMsg, $data);
}
/**
* 发送消息
* @param string $sendID 发送者ID
@@ -156,16 +197,21 @@ class Message
*/
public function sendBusinessNotification(string $sendID, string $recvID, array $data,string $type='user'): array
{
$key = isset($data['key']) ? $data['key'] : md5(time());
$sendMsg = isset($data['sendMsg']) ? $data['sendMsg'] : true;
unset($data['key']);
unset($data['sendMsg']);
// 获取管理员token
$data = [
'sendUserID' => $sendID,
'recvUserID' => $type=='user' ? $recvID : '',
'recvGroupID' => $type=='user' ? '': $recvID,
'key' => md5(time()),
'data' => json_encode($data),
'sendMsg' => true,
'sendUserID' => $sendID,
'recvUserID' => $type=='user' ? $recvID : '',
'recvGroupID' => $type=='user' ? '': $recvID,
'key' => $key,
'data' => json_encode($data),
'sendMsg' => $sendMsg,
'reliabilityLevel' => 1,
];
//log_alert($data);
return Utils::send(Url::$sendBusinessNotification, $data, '发送业务通知失败');
}
+2 -2
View File
@@ -134,13 +134,13 @@ class User
* @param string $ex 扩展字段
* @return array
*/
public function addNotificationAccount(string $userID, string $nickname = '', string $faceURL = '', int $appMangerLevel = 3): array
public function addNotificationAccount(string $userID, string $nickname = '', string $faceURL = '', \support\OpenImSdk\Enum\appMangerLevel $appMangerLevel = \support\OpenImSdk\Enum\appMangerLevel::Notify): array
{
$data = [
'userID' => $userID,
'nickname' => $nickname,
'faceURL' => $faceURL,
'appMangerLevel' => $appMangerLevel,
'appMangerLevel' => $appMangerLevel->value,
];
return Utils::send(Url::$addNotificationAccount, $data, '添加通知账号错误');
}
+7 -5
View File
@@ -81,15 +81,17 @@ class Utils
* @param string $token 认证令牌
* @return array 响应数据
*/
public static function send(string $path, array $data, string $errMsg, string $token = ''): array|bool
public static function send(string $path, array $data, string $errMsg='', string $token = ''): array|bool
{
$token = $token ? $token : Utils::getAdminToken();
if($path != Url::$getAdminToken){
$token = $token ? $token : Utils::getAdminToken();
}
$url = Url::buildUrl($path);
//cp($url);
log_alert($url);
//log_alert($data);
$res = self::request($url, $data, $token);
//cp($data);
//cp($res);
//log_alert($res);
$res = json_decode($res, true);
if($res['errCode'] !==0 ){
throw new \Exception($res['errMsg'],$res['errCode']);
+24
View File
@@ -0,0 +1,24 @@
<?php
namespace support\OpenImSdk\Enum;
trait BaseEnum {
public static function toArray(): array
{
return [
];
}
/**
* 获取当前状态的描述文本
*/
public function getDescription(): string
{
return self::toArray()[$this->value];
}
/**
* 安全地从值创建枚举实例
*/
public static function tryFromValue(int $value): ?self
{
return self::tryFrom($value);
}
}
+21
View File
@@ -0,0 +1,21 @@
<?php
namespace support\OpenImSdk\Enum;
enum appMangerLevel : int{
use BaseEnum;
/*系统通知号;*/
case Notify=3;
/*机器人账号;*/
case Bot=4;
/**
* 获取所有状态映射数组
*/
public static function toArray(): array
{
return [
self::Notify->value => __('系统通知号'),
self::Bot->value => __('机器人账号'),
];
}
};
+2
View File
@@ -86,6 +86,8 @@ class Random
case 'encrypt':
case 'sha1':
return sha1(uniqid(mt_rand(), true));
default:
return substr(str_shuffle(str_repeat($type, ceil($len / strlen($type)))), 0, $len);
}
}