11
This commit is contained in:
@@ -203,8 +203,12 @@ class CommonController extends BaseController{
|
|||||||
/**
|
/**
|
||||||
* 登录
|
* 登录
|
||||||
* @Apidoc\Method("POST")
|
* @Apidoc\Method("POST")
|
||||||
* @Apidoc\Param("username", type="string",require=true, desc="用户名")
|
* @Apidoc\Param("username", type="string",require=false, desc="用户名登录必填")
|
||||||
* @Apidoc\Param("password", type="string",require=true, desc="密码")
|
* @Apidoc\Param("mobile", type="string",require=false, desc="手机号登录必填")
|
||||||
|
* @Apidoc\Param("type", type="string",require=true,default="mobile",desc="登录方式,username,mobile,email")
|
||||||
|
* @Apidoc\Param("password", type="string",require=false, desc="密码的登录必填")
|
||||||
|
* @Apidoc\Param("code", type="string",require=false, desc="验证码登录必填")
|
||||||
|
* @Apidoc\Param("region", type="string",require=false,default="86", desc="区域,手机号登录必填")
|
||||||
*/
|
*/
|
||||||
public function login(Request $request){
|
public function login(Request $request){
|
||||||
$username = input('username');
|
$username = input('username');
|
||||||
@@ -237,7 +241,8 @@ class CommonController extends BaseController{
|
|||||||
if($user === false){
|
if($user === false){
|
||||||
return $this->fail(\support\Jwt::getError());
|
return $this->fail(\support\Jwt::getError());
|
||||||
}
|
}
|
||||||
$user= Hook('user.profile',$user);
|
//登录成功的事件
|
||||||
|
$user = Hook("user.login_successed", $user);
|
||||||
return $this->success(__('successful'), $user[0]);
|
return $this->success(__('successful'), $user[0]);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return $this->error($e->getMessage());
|
return $this->error($e->getMessage());
|
||||||
@@ -271,28 +276,28 @@ class CommonController extends BaseController{
|
|||||||
return $this->error(__('Invalid parameters'));
|
return $this->error(__('Invalid parameters'));
|
||||||
}
|
}
|
||||||
//验证Token
|
//验证Token
|
||||||
if (!Validate::check(['newpassword' => $newpassword], ['newpassword' => 'require|regex:\S{6,30}'])) {
|
if (!Validate::check(['newpassword' => $newpassword], ['newpassword' => 'require|regex:\S{6,32}'])) {
|
||||||
return $this->error(__('Password must be 6 to 30 characters'));
|
return $this->error(__('Password must be 6 to 32 characters'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$mobile && !$email){
|
if (!$mobile && !$email){
|
||||||
try{
|
try{
|
||||||
$user = \support\Jwt::getUser();
|
$user = \support\Jwt::getUser();
|
||||||
}catch(\Exception $e){
|
}catch(\Exception $e){
|
||||||
log_alert($e->getMessage());
|
//log_alert($e->getMessage());
|
||||||
$user = false;
|
$user = false;
|
||||||
}
|
}
|
||||||
if($user){
|
if($user){
|
||||||
captcha_verfiy('mobile','reset_pwd',$user->mobile);
|
captcha_verfiy('mobile','reset_pwd',$user->mobile);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
if ($email && Validate::is($email, "email")) {
|
|
||||||
captcha_verfiy('email','reset_pwd',$email);
|
|
||||||
$user = UserModel::getByEmail($email);
|
|
||||||
}
|
|
||||||
if ($mobile && Validate::regex($mobile, "^1\d{10}$")) {
|
if ($mobile && Validate::regex($mobile, "^1\d{10}$")) {
|
||||||
captcha_verfiy('mobile','reset_pwd',$mobile);
|
captcha_verfiy('mobile','reset_pwd',$mobile);
|
||||||
$user = UserModel::getByMobile($mobile);
|
$region = Input('region');
|
||||||
|
$region = str_replace('+','',$region);
|
||||||
|
$user = UserModel::where('region',$region)->where('mobile',$mobile)->find();
|
||||||
|
}else if ($email && Validate::is($email, "email")) {
|
||||||
|
captcha_verfiy('email','reset_pwd',$email);
|
||||||
|
$user = UserModel::getByEmail($email);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!$user) {
|
if (!$user) {
|
||||||
@@ -327,8 +332,8 @@ class CommonController extends BaseController{
|
|||||||
return $this->error(__('Invalid parameters'));
|
return $this->error(__('Invalid parameters'));
|
||||||
}
|
}
|
||||||
//验证Token
|
//验证Token
|
||||||
if (!Validate::check(['newpassword' => $newpassword], ['newpassword' => 'require|regex:\S{6,6}'])) {
|
if (!Validate::check(['newpassword' => $newpassword], ['newpassword' => 'require|regex:\S{6,32}'])) {
|
||||||
return $this->error(__('Trade password must be 6 characters'));
|
return $this->error(__('Trade password must be 6-32 characters'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$mobile && !$email){
|
if (!$mobile && !$email){
|
||||||
|
|||||||
@@ -99,10 +99,11 @@ class ThaliController extends BaseController{
|
|||||||
return $this->fail(__('Role does not exist'));
|
return $this->fail(__('Role does not exist'));
|
||||||
}
|
}
|
||||||
$role_id = $thali->role_id;
|
$role_id = $thali->role_id;
|
||||||
if($user->role_id >= $role_id){
|
if($user->role_id > $role_id){
|
||||||
return $this->fail(__('Your level is too high to purchase this character'));
|
return $this->fail(__('Your level is too high to purchase this character'));
|
||||||
}
|
}
|
||||||
$price = $thali->price;
|
$price = $thali->price;
|
||||||
|
|
||||||
if($quantity == 1){
|
if($quantity == 1){
|
||||||
$price = $thali->month_price;
|
$price = $thali->month_price;
|
||||||
}
|
}
|
||||||
@@ -112,7 +113,17 @@ class ThaliController extends BaseController{
|
|||||||
if($quantity == 12){
|
if($quantity == 12){
|
||||||
$price = $thali->year_price;
|
$price = $thali->year_price;
|
||||||
}
|
}
|
||||||
$amount = $price * $quantity;
|
//升级
|
||||||
|
$isUpgrade=true;
|
||||||
|
//续费
|
||||||
|
if($user->role_id == $role_id){
|
||||||
|
$isUpgrade = false;
|
||||||
|
}
|
||||||
|
$amount = $price;
|
||||||
|
if($isUpgrade){
|
||||||
|
//按那个价格算,目前是按原价,剩余时间不做抵扣
|
||||||
|
}
|
||||||
|
//$amount = $price * $quantity;
|
||||||
if($amount <=0){
|
if($amount <=0){
|
||||||
return $this->fail(__('This character group is not allowed to be sold'));
|
return $this->fail(__('This character group is not allowed to be sold'));
|
||||||
}
|
}
|
||||||
@@ -121,14 +132,17 @@ class ThaliController extends BaseController{
|
|||||||
}
|
}
|
||||||
\support\Jwt::verify_trade_password($request->post('trade_password'));
|
\support\Jwt::verify_trade_password($request->post('trade_password'));
|
||||||
$user = \support\Jwt::getUser();
|
$user = \support\Jwt::getUser();
|
||||||
$user->role_id = $role_id;
|
|
||||||
$user->expire_at = ($user->expire_at>time() ? $user->expire_at : time())+86400* $quantity * 30;
|
$user->expire_at = ($user->expire_at>time() ? $user->expire_at : time())+86400* $quantity * 30;
|
||||||
|
if($isUpgrade){
|
||||||
|
$user->expire_at = (time())+86400* $quantity * 30;
|
||||||
|
$user->role_id = $role_id;
|
||||||
|
}
|
||||||
$user->save();
|
$user->save();
|
||||||
cache('user_role_'.$user->userID,[
|
cache('user_role_'.$user->userID,[
|
||||||
'role_id'=>$role_id,'expire_at'=>$user->expire_at
|
'role_id'=>$role_id,'expire_at'=>$user->expire_at
|
||||||
],$user->expire_at-time());
|
],$user->expire_at-time());
|
||||||
|
|
||||||
\app\model\User::score($user->id,-$amount,\app\enum\BalanceType::PURCHASE_ROLE,$role_id);
|
\app\model\User::score($user->id,-$amount,\app\enum\BalanceType::PURCHASE_ROLE,json_encode(['role_id'=>$role_id,'quantity'=>$quantity,'role_name'=>$thali->title]));
|
||||||
//Hook('user.roleup', $user);
|
//Hook('user.roleup', $user);
|
||||||
// $data = [
|
// $data = [
|
||||||
// 'role_id' => $role_id,
|
// 'role_id' => $role_id,
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ class HookController{
|
|||||||
"nextCode"=> 0
|
"nextCode"=> 0
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
//用户注册完成后
|
||||||
function callbackAfterUserRegisterCommand(Request $request): Response
|
function callbackAfterUserRegisterCommand(Request $request): Response
|
||||||
{
|
{
|
||||||
$userID= Input('userID');
|
$userID= Input('userID');
|
||||||
@@ -60,25 +61,25 @@ class HookController{
|
|||||||
{
|
{
|
||||||
//log_alert(Input());
|
//log_alert(Input());
|
||||||
|
|
||||||
$user_id = Input('sendID');
|
// $user_id = Input('sendID');
|
||||||
$recv_user_id = Input( 'recvID');
|
// $recv_user_id = Input( 'recvID');
|
||||||
$status = Input('status',1);
|
// $status = Input('status',1);
|
||||||
$sessionType = Input('sessionType',null);
|
// $sessionType = Input('sessionType',null);
|
||||||
if($status == 1 && $sessionType != 4){
|
// if($status == 1 && $sessionType != 4){
|
||||||
//$max = 10000000000;//限制消息数量
|
// //$max = 10000000000;//限制消息数量
|
||||||
$user_rights = get_user_rights($user_id);
|
// $user_rights = get_user_rights($user_id);
|
||||||
$max = $user_rights['max_send_msg_count'];
|
// $max = $user_rights['max_send_msg_count'];
|
||||||
$sended_msg_count = cache('single_msg_count_'.$user_id)??0 + cache('group_msg_count_'.$user_id)??0;
|
// $sended_msg_count = cache('single_msg_count_'.$user_id)??0 + cache('group_msg_count_'.$user_id)??0;
|
||||||
if($sended_msg_count > $max){
|
// if($sended_msg_count > $max){
|
||||||
return json([
|
// return json([
|
||||||
"actionCode" => 0,
|
// "actionCode" => 0,
|
||||||
"errCode" => 1002,
|
// "errCode" => 1002,
|
||||||
"errMsg" => "超出消息数量限制,请先开通或升级会员",
|
// "errMsg" => "超出消息数量限制,请先开通或升级会员",
|
||||||
"errDlt" => "超出消息数量限制,请先开通或升级会员",
|
// "errDlt" => "超出消息数量限制,请先开通或升级会员",
|
||||||
"nextCode"=> 1
|
// "nextCode"=> 1
|
||||||
]);
|
// ]);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
return json([
|
return json([
|
||||||
"actionCode" => 0,
|
"actionCode" => 0,
|
||||||
"errCode" => 0,
|
"errCode" => 0,
|
||||||
@@ -122,8 +123,6 @@ class HookController{
|
|||||||
*/
|
*/
|
||||||
public function callbackBeforeSendGroupleMsgCommand(Request $request): Response
|
public function callbackBeforeSendGroupleMsgCommand(Request $request): Response
|
||||||
{
|
{
|
||||||
//log_alert('callbackBeforeSendGroupleMsgCommand:');
|
|
||||||
//log_alert(Input());
|
|
||||||
return json([
|
return json([
|
||||||
"actionCode" => 0,
|
"actionCode" => 0,
|
||||||
"errCode" => 0,
|
"errCode" => 0,
|
||||||
@@ -138,9 +137,6 @@ class HookController{
|
|||||||
*/
|
*/
|
||||||
public function callbackAfterSendGroupleMsgCommand(Request $request): Response
|
public function callbackAfterSendGroupleMsgCommand(Request $request): Response
|
||||||
{
|
{
|
||||||
|
|
||||||
//log_alert('callbackAfterSendGroupleMsgCommand:');
|
|
||||||
//log_alert(Input());
|
|
||||||
return json([
|
return json([
|
||||||
"actionCode" => 0,
|
"actionCode" => 0,
|
||||||
"errCode" => 0,
|
"errCode" => 0,
|
||||||
@@ -160,7 +156,7 @@ class HookController{
|
|||||||
$handleResult = Input('handleResult');
|
$handleResult = Input('handleResult');
|
||||||
$key = 'friend_count_'.$from_user_id;
|
$key = 'friend_count_'.$from_user_id;
|
||||||
$user_rights = get_user_rights($from_user_id);
|
$user_rights = get_user_rights($from_user_id);
|
||||||
$max = $user_rights['max_friend_count'];
|
$max = isset($user_rights['max_friend_count']) ? $user_rights['max_friend_count'] : -1;
|
||||||
if(cache($key) > $max){
|
if(cache($key) > $max){
|
||||||
return json([
|
return json([
|
||||||
"actionCode" => 0,
|
"actionCode" => 0,
|
||||||
@@ -210,7 +206,7 @@ class HookController{
|
|||||||
if($handleResult == 1){
|
if($handleResult == 1){
|
||||||
$key = 'friend_count_'.$to_user_id;
|
$key = 'friend_count_'.$to_user_id;
|
||||||
$user_rights = get_user_rights($to_user_id);
|
$user_rights = get_user_rights($to_user_id);
|
||||||
$max = $user_rights['max_friend_count'];
|
$max = isset($user_rights['max_friend_count']) ? $user_rights['max_friend_count'] : -1;
|
||||||
if(cache($key) > $max){
|
if(cache($key) > $max){
|
||||||
return json([
|
return json([
|
||||||
"actionCode" => 0,
|
"actionCode" => 0,
|
||||||
@@ -276,6 +272,8 @@ class HookController{
|
|||||||
"nextCode"=> 0
|
"nextCode"=> 0
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//用户删除好友之后得回调
|
||||||
function callbackAfterDeleteFriendCommand() : Response {
|
function callbackAfterDeleteFriendCommand() : Response {
|
||||||
$friendUserID = Input('friendUserID');
|
$friendUserID = Input('friendUserID');
|
||||||
$ownerUserID = Input('ownerUserID');
|
$ownerUserID = Input('ownerUserID');
|
||||||
@@ -297,6 +295,215 @@ class HookController{
|
|||||||
"nextCode"=> 0
|
"nextCode"=> 0
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 在创建群组之前的回调
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function callbackbeforeCreateGroupCommand(Request $request): Response
|
||||||
|
{
|
||||||
|
$from_user_id = Input('fromUserID');
|
||||||
|
$to_user_id = Input('toUserID');
|
||||||
|
$handleResult = Input('handleResult');
|
||||||
|
if($handleResult == 1){
|
||||||
|
$key = 'friend_count_'.$to_user_id;
|
||||||
|
$user_rights = get_user_rights($to_user_id);
|
||||||
|
$max = isset($user_rights['max_friend_count']) ? $user_rights['max_friend_count'] : -1;
|
||||||
|
if(cache($key) > $max){
|
||||||
|
return json([
|
||||||
|
"actionCode" => 0,
|
||||||
|
"errCode" => 1001,
|
||||||
|
"errMsg" => "超出好友数量限制,请先开通或升级会员",
|
||||||
|
"errDlt" => "超出好友数量限制,请先开通或升级会员",
|
||||||
|
"nextCode"=> 1
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return json([
|
||||||
|
"actionCode" => 0,
|
||||||
|
"errCode" => 0,
|
||||||
|
"errMsg" => "",
|
||||||
|
"errDlt" => "",
|
||||||
|
"nextCode"=> 0
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 在创建群组之后的回调
|
||||||
|
* @param Request $request
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function callbackafterCreateGroupCommand(Request $request):Response
|
||||||
|
{
|
||||||
|
return json([
|
||||||
|
"actionCode" => 0,
|
||||||
|
"errCode" => 0,
|
||||||
|
"errMsg" => "",
|
||||||
|
"errDlt" => "",
|
||||||
|
"nextCode"=> 0
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 转让群主之后的回调
|
||||||
|
* @param Request $request
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function callbackAfterTransferGroupOwnerCommand(Request $request):Response
|
||||||
|
{
|
||||||
|
$oldOwnerUserID = Input('oldOwnerUserID');
|
||||||
|
$newOwnerUserID = Input('newOwnerUserID');
|
||||||
|
cache_add('user_'.$oldOwnerUserID.'_create_group_count',-1);
|
||||||
|
cache_add('user_'.$newOwnerUserID.'_create_group_count',1);
|
||||||
|
return json([
|
||||||
|
"actionCode" => 0,
|
||||||
|
"errCode" => 0,
|
||||||
|
"errMsg" => "",
|
||||||
|
"errDlt" => "",
|
||||||
|
"nextCode"=> 0
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解散群组后回调
|
||||||
|
* @param Request $request
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function callbackAfterDisMissGroupCommand(Request $request):Response
|
||||||
|
{
|
||||||
|
$groupID = Input('groupID');
|
||||||
|
$ownerID = Input('ownerID');
|
||||||
|
return json([
|
||||||
|
"actionCode" => 0,
|
||||||
|
"errCode" => 0,
|
||||||
|
"errMsg" => "",
|
||||||
|
"errDlt" => "",
|
||||||
|
"nextCode"=> 0
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户退出群组的回调
|
||||||
|
* @param Request $request
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function callbackAfterQuitGroupCommand(Request $request):Response
|
||||||
|
{
|
||||||
|
$groupID = Input('groupID');
|
||||||
|
$userID = Input('userID');
|
||||||
|
cache_add('user_'.$userID.'_join_group_count',-1);
|
||||||
|
cache_add('group_'.$groupID.'_user_count',-1);
|
||||||
|
return json([
|
||||||
|
"actionCode" => 0,
|
||||||
|
"errCode" => 0,
|
||||||
|
"errMsg" => "",
|
||||||
|
"errDlt" => "",
|
||||||
|
"nextCode"=> 0
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 群成员进群之前的回调
|
||||||
|
* @param Request $request
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function callbackBeforeMembersJoinGroupCommand(Request $request):Response
|
||||||
|
{
|
||||||
|
$groupID = Input('groupID');
|
||||||
|
$memberList = Input('memberList');
|
||||||
|
return json([
|
||||||
|
"actionCode" => 0,
|
||||||
|
"errCode" => 0,
|
||||||
|
"errMsg" => "",
|
||||||
|
"errDlt" => "",
|
||||||
|
"nextCode"=> 0
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 踢除群组成员的回调
|
||||||
|
* @param Request $request
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function callbackAfterKickGroupCommand(Request $request):Response
|
||||||
|
{
|
||||||
|
$groupID = Input('groupID');
|
||||||
|
$kickedUserIDs = Input('kickedUserIDs');
|
||||||
|
return json([
|
||||||
|
"actionCode" => 0,
|
||||||
|
"errCode" => 0,
|
||||||
|
"errMsg" => "",
|
||||||
|
"errDlt" => "",
|
||||||
|
"nextCode"=> 0
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新成员加入群组之后的回调
|
||||||
|
* @param Request $request
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function callbackAfterJoinGroupCommand(Request $request):Response
|
||||||
|
{
|
||||||
|
$groupID = Input('groupID');
|
||||||
|
$userID = Input('userID');
|
||||||
|
cache_add('user_'.$userID.'_join_group_count',-1);
|
||||||
|
cache_add('group_'.$groupID.'_user_count',-1);
|
||||||
|
return json([
|
||||||
|
"actionCode" => 0,
|
||||||
|
"errCode" => 0,
|
||||||
|
"errMsg" => "",
|
||||||
|
"errDlt" => "",
|
||||||
|
"nextCode"=> 0
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 邀请新成员加入群组之前的回调
|
||||||
|
* @param Request $request
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function callbackBeforeInviteJoinGroupCommand(Request $request):Response
|
||||||
|
{
|
||||||
|
$groupID = Input('groupID');
|
||||||
|
$invitedUserIDs = Input('invitedUserIDs');
|
||||||
|
return json([
|
||||||
|
"actionCode" => 0,
|
||||||
|
"errCode" => 0,
|
||||||
|
"errMsg" => "",
|
||||||
|
"errDlt" => "",
|
||||||
|
"nextCode"=> 0
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 申请加入群组之前的回调
|
||||||
|
* @param Request $request
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function callbackBeforeJoinGroupCommand(Request $request):Response
|
||||||
|
{
|
||||||
|
$groupID = Input('groupID');
|
||||||
|
$applyID = Input('applyID');
|
||||||
|
return json([
|
||||||
|
"actionCode" => 0,
|
||||||
|
"errCode" => 0,
|
||||||
|
"errMsg" => "",
|
||||||
|
"errDlt" => "",
|
||||||
|
"nextCode"=> 0
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function getSdk(){
|
function getSdk(){
|
||||||
$IM = new \support\OpenImSdk\Client([
|
$IM = new \support\OpenImSdk\Client([
|
||||||
'host' => 'http://127.0.0.1:10002', // OpenIM API地址
|
'host' => 'http://127.0.0.1:10002', // OpenIM API地址
|
||||||
|
|||||||
+7
-8
@@ -39,6 +39,13 @@ class User{
|
|||||||
$this->buildTeam($user);
|
$this->buildTeam($user);
|
||||||
}
|
}
|
||||||
function login_successed($data=[]){
|
function login_successed($data=[]){
|
||||||
|
$data = $this->profile($data);
|
||||||
|
/**
|
||||||
|
* @var \support\OpenImSdk\Client $IM
|
||||||
|
*/
|
||||||
|
$IM = request()->IM;
|
||||||
|
$imToken = $IM->auth->getUserToken($data['userID'],Input('platform'));
|
||||||
|
$data['imToken'] = $imToken['token'];
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
function profile($user=[]){
|
function profile($user=[]){
|
||||||
@@ -65,15 +72,7 @@ class User{
|
|||||||
$data['avatar'] = $data['avatar']?:"/static/img/avatar.png";
|
$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['role'] = isset($role_arr[$data['role_id']]) ? $role_arr[$data['role_id']] : __('普通用户');//\app\model\UserRole::where('id',$data['role_id'])->value('name');
|
||||||
|
|
||||||
/**
|
|
||||||
* @var \support\OpenImSdk\Client $IM
|
|
||||||
*/
|
|
||||||
$IM = request()->IM;
|
|
||||||
$imToken = $IM->auth->getUserToken(idEncode($data['id']),Input('platform'));
|
|
||||||
$data['imToken'] = $imToken['token'];
|
|
||||||
$last_see = $last_see ?? cache('last_see_'.$data['id']);
|
$last_see = $last_see ?? cache('last_see_'.$data['id']);
|
||||||
$data['id'] = idEncode($data['id']);
|
|
||||||
$data['userID'] = $data['id'] ;
|
|
||||||
$count = 0;
|
$count = 0;
|
||||||
$data['friend_settings'] = [
|
$data['friend_settings'] = [
|
||||||
'unread_count' => $count ??0,
|
'unread_count' => $count ??0,
|
||||||
|
|||||||
+2
-13
@@ -720,27 +720,16 @@ if(!function_exists('generateShortUniqueID')){
|
|||||||
}
|
}
|
||||||
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{
|
||||||
// return [
|
|
||||||
// 'name' => 'VIP',
|
|
||||||
// 'max_send_msg_count' => 999999999999,
|
|
||||||
// 'max_friend_count' => 999999999999,
|
|
||||||
// 'max_group_join_count' => 999999999999,
|
|
||||||
// 'max_gourp_create_count' => 999999999999
|
|
||||||
// ];
|
|
||||||
$user_id = idDecode($user_id);
|
$user_id = idDecode($user_id);
|
||||||
$key = 'user_rights_'.$user_id;
|
$key = 'user_rights_'.$user_id;
|
||||||
$result = cache($key);
|
$result = cache($key);
|
||||||
if(!$result){
|
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());
|
|
||||||
$result = \think\facade\Db::name('user_role')->alias('ur')
|
$result = \think\facade\Db::name('user_role')->alias('ur')
|
||||||
->join('user u','ur.id = u.role_id')
|
->join('user u','ur.id = u.role_id')
|
||||||
->where('u.id',$user_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')
|
->field('ur.name,ur.right')
|
||||||
->find();
|
->find();
|
||||||
|
$result['right'] = json_decode($result['right'],true);
|
||||||
cache($key,$result,86400);
|
cache($key,$result,86400);
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
|
|||||||
@@ -13,7 +13,17 @@ class ActionHook implements MiddlewareInterface
|
|||||||
public function process(Request $request, callable $next) : Response
|
public function process(Request $request, callable $next) : Response
|
||||||
{
|
{
|
||||||
if ($request->controller) {
|
if ($request->controller) {
|
||||||
|
$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'){
|
||||||
|
$response = response('',204,$headers);
|
||||||
|
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 () {
|
||||||
@@ -38,7 +48,9 @@ class ActionHook implements MiddlewareInterface
|
|||||||
return $after_response;
|
return $after_response;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if($request->controller == '\\hg\\apidoc\\Controller' && !$response->getHeader('Access-Control-Allow-Methods')){
|
||||||
|
$response->withHeaders($headers);
|
||||||
|
}
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
return $next($request);
|
return $next($request);
|
||||||
|
|||||||
+3
-3
@@ -37,21 +37,21 @@ class Thali extends Base
|
|||||||
*/
|
*/
|
||||||
public function getMonthPriceAttr($value,$row)
|
public function getMonthPriceAttr($value,$row)
|
||||||
{
|
{
|
||||||
return bcmul($row['price'],$row['month_discount'],2);
|
return round(bcmul($row['price'],$row['month_discount'],2));
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 季价
|
* 季价
|
||||||
*/
|
*/
|
||||||
public function getQuarterPriceAttr($value,$row)
|
public function getQuarterPriceAttr($value,$row)
|
||||||
{
|
{
|
||||||
return bcmul($row['price'],$row['quarter_discount'],2);
|
return round(bcmul($row['price']*3,$row['quarter_discount'],2));
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 年价
|
* 年价
|
||||||
*/
|
*/
|
||||||
public function getYearPriceAttr($value,$row)
|
public function getYearPriceAttr($value,$row)
|
||||||
{
|
{
|
||||||
return bcmul($row['price'],$row['year_discount'],2);
|
return round(bcmul($row['price']*12,$row['year_discount'],2));
|
||||||
}
|
}
|
||||||
function Role(){
|
function Role(){
|
||||||
return $this->hasOne('UserRole','id','role_id')->bind([
|
return $this->hasOne('UserRole','id','role_id')->bind([
|
||||||
|
|||||||
@@ -35,5 +35,19 @@ class UserRole extends Base
|
|||||||
{
|
{
|
||||||
return $this->rules ? explode(',', $this->rules) : [];
|
return $this->rules ? explode(',', $this->rules) : [];
|
||||||
}
|
}
|
||||||
|
public function setRightAttr($v='',$row=[])
|
||||||
|
{
|
||||||
|
if(is_array($v)){
|
||||||
|
return json_encode($v);
|
||||||
|
}
|
||||||
|
return $v;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function getRightIds($v='',$row=[])
|
||||||
|
{
|
||||||
|
return $v ? (is_array($v) ? $v : json_decode($v,true)) : [];
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -89,20 +89,6 @@ return [
|
|||||||
// 'proxy' => null,
|
// 'proxy' => null,
|
||||||
'prefix' => '',
|
'prefix' => '',
|
||||||
],
|
],
|
||||||
'ossmy' => [
|
|
||||||
'driver' => \Shopwwi\WebmanFilesystem\Adapter\AliyunOssAdapterFactory::class,
|
|
||||||
'accessId' => 'LTAI5tLsFoJAda5juPabytuU',
|
|
||||||
'accessSecret' => 'ZyiKpt6lqLBfHPZcvHd7SWM7eENRJW',
|
|
||||||
'bucket' => 'wjba',
|
|
||||||
'endpoint' => 'oss-cn-hongkong.aliyuncs.com',
|
|
||||||
'url' => '//wjba.oss-accelerate.aliyuncs.com', // 静态文件访问域名
|
|
||||||
// 'timeout' => 3600,
|
|
||||||
// 'connectTimeout' => 10,
|
|
||||||
'isCName' => false,
|
|
||||||
'prefix' => '',
|
|
||||||
// 'token' => null,
|
|
||||||
// 'proxy' => null,
|
|
||||||
],
|
|
||||||
'qiniu' => [
|
'qiniu' => [
|
||||||
'driver' => \Shopwwi\WebmanFilesystem\Adapter\QiniuAdapterFactory::class,
|
'driver' => \Shopwwi\WebmanFilesystem\Adapter\QiniuAdapterFactory::class,
|
||||||
'accessKey' => 'QINIU_ACCESS_KEY',
|
'accessKey' => 'QINIU_ACCESS_KEY',
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
<select name="pid" class="form-control">
|
<select name="pid" class="form-control">
|
||||||
<option value="">无</option>
|
<option value="">无</option>
|
||||||
{foreach name="rolelist" item="vo"}
|
{foreach name="rolelist" item="vo"}
|
||||||
<option value="{$vo.id}" {if !is_null($row.pid) && $row.pid==$key}selected{/if}>{$vo.name}</option>
|
<option value="{$vo.id}" {if !is_null($row.pid) && $row.pid==$vo.id}selected{/if}>{$vo.name}</option>
|
||||||
{/foreach}
|
{/foreach}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
@@ -21,28 +21,34 @@
|
|||||||
<input type="text" name="name" value="{$row.name|null}" data-rule="required;length(2~20)" class="form-control" />
|
<input type="text" name="name" value="{$row.name|null}" data-rule="required;length(2~20)" class="form-control" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<!--<div class="form-group">-->
|
||||||
|
<!-- <label class="control-label col-xs-12 col-sm-2">最大消息数量:</label>-->
|
||||||
|
<!-- <div class="col-xs-12 col-sm-8 col-md-6">-->
|
||||||
|
<!-- <input type="number" name="right[max_send_msg_count]" value="{$row.right.max_send_msg_count|default=10}" class="form-control" min="0" data-rule="required;range(0~99999999)" />-->
|
||||||
|
<!-- </div>-->
|
||||||
|
<!--</div>-->
|
||||||
<div class="form-group">
|
<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">
|
<div class="col-xs-12 col-sm-8 col-md-6">
|
||||||
<input type="number" name="max_send_msg_count" value="{$row.max_send_msg_count|default=10}" class="form-control" min="0" data-rule="required;range(0~99999999)" />
|
<input type="number" name="right[max_friend_count]" value="{$row.right.max_friend_count|default=10000}" class="form-control" min="0" data-rule="required;range(0~99999999)" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<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">
|
<div class="col-xs-12 col-sm-8 col-md-6">
|
||||||
<input type="text" name="max_friend_count" value="{$row.max_friend_count|default=10}" data-rule="required;length(3~6)" class="form-control" />
|
<input type="number" name="right[max_group_join_count]" value="{$row.right.max_group_join_count|default=10000}" class="form-control" min="0" data-rule="required;range(0~99999999)" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<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">
|
<div class="col-xs-12 col-sm-8 col-md-6">
|
||||||
<input type="text" name="max_group_join_count" value="{$row.max_group_join_count|default=10}" data-rule="required;length(3~6)" class="form-control" />
|
<input type="number" name="right[max_group_create_count]" value="{$row.right.max_group_create_count|default=10}" class="form-control" min="0" data-rule="required;range(0~99999999)" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<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">
|
<div class="col-xs-12 col-sm-8 col-md-6">
|
||||||
<input type="text" name="max_gourp_create_count" value="{$row.max_gourp_create_count|default=10}" data-rule="required;length(3~6)" class="form-control" />
|
<input type="number" name="right[max_group_user_count]" value="{$row.right.max_group_user_count|default=10}" class="form-control" min="0" data-rule="required;range(0~99999999)" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{php}
|
{php}
|
||||||
|
|||||||
@@ -41,24 +41,36 @@ define(['table','form','yntree'], function (Table,Form,YnTree1) {
|
|||||||
filter: "string",
|
filter: "string",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'max_send_msg_count',
|
field: 'max_friend_count',
|
||||||
title: '最大消息数量',
|
title: '最大好友',
|
||||||
filter: "number",
|
filter: "number",
|
||||||
|
formatter:function(v,row){
|
||||||
|
return row.right.max_friend_count;
|
||||||
|
},
|
||||||
|
visible:false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'max_friend_count',
|
field: 'max_group_user_count',
|
||||||
title: '最大好友数量',
|
title: '群容量',
|
||||||
filter: "number",
|
formatter:function(v,row){
|
||||||
|
return row.right.max_group_user_count;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'max_group_join_count',
|
field: 'max_group_join_count',
|
||||||
title: '群组加入限制',
|
title: '加入群组',
|
||||||
filter: "number",
|
filter: "number",
|
||||||
|
formatter:function(v,row){
|
||||||
|
return row.right.max_group_join_count;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: 'max_gourp_create_count',
|
field: 'max_group_create_count',
|
||||||
title: '群组创建限制',
|
title: '创建群组',
|
||||||
filter: "number",
|
filter: "number",
|
||||||
|
formatter:function(v,row){
|
||||||
|
return row.right.max_group_create_count;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "创建时间",
|
title: "创建时间",
|
||||||
|
|||||||
@@ -296,8 +296,6 @@ class Jwt
|
|||||||
];
|
];
|
||||||
$_token = \support\Jwt\JwtToken::generateToken($_user);
|
$_token = \support\Jwt\JwtToken::generateToken($_user);
|
||||||
$user->token = $_token['access_token'];
|
$user->token = $_token['access_token'];
|
||||||
//登录成功的事件
|
|
||||||
Hook("user.login_successed", $user);
|
|
||||||
return self::getUserinfo($user);
|
return self::getUserinfo($user);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
Db::rollback();
|
Db::rollback();
|
||||||
|
|||||||
Reference in New Issue
Block a user