fixed
This commit is contained in:
@@ -20,99 +20,18 @@ use wanghua\general_utility_tools_php\SundryConfig;
|
|||||||
use wanghua\general_utility_tools_php\tool\Tools;
|
use wanghua\general_utility_tools_php\tool\Tools;
|
||||||
use wanghua\general_utility_tools_php\wechat\UserAuth;
|
use wanghua\general_utility_tools_php\wechat\UserAuth;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 听译-用户
|
||||||
|
* Class Users
|
||||||
|
* @package app\api\controller
|
||||||
|
*/
|
||||||
class Users extends BaseHttpApi
|
class Users extends BaseHttpApi
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* desc:根据游戏id查询用户
|
|
||||||
* api/Users/getUserById
|
|
||||||
* 参数:
|
|
||||||
* gameid 用户id
|
|
||||||
* author:wh
|
|
||||||
*/
|
|
||||||
function getUserById(){
|
|
||||||
return Mmodel::catchJson(function (){
|
|
||||||
$gameid = input('gameid');
|
|
||||||
if(empty($gameid)){
|
|
||||||
return Tools::set_fail('参数错误');
|
|
||||||
}
|
|
||||||
$data = Db::table(TabConf::$fa_users)
|
|
||||||
->where('id',$gameid*1)
|
|
||||||
->find();
|
|
||||||
return Tools::set_res(200,'查询成功',$data);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* desc:根据openid查询用户
|
* desc:听译-授权,登录
|
||||||
* api/Users/getUserInfo
|
|
||||||
* 参数:
|
|
||||||
* openid
|
|
||||||
*
|
|
||||||
* 返回:
|
|
||||||
* now_rank 当前排名
|
|
||||||
* all_coins: 累计获得金币
|
|
||||||
* enemy 累计击杀数
|
|
||||||
* eliminate 消消乐道具
|
|
||||||
*/
|
|
||||||
function getUserInfo(){
|
|
||||||
Tools::log_to_write_txt(['查询单个用户 入参:'=>input()]);
|
|
||||||
try {
|
|
||||||
|
|
||||||
$openid = input('openid');
|
|
||||||
if(empty($openid)){
|
|
||||||
return json(Tools::set_fail('参数错误'));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$model_obj = Db::table('fa_ty_users');
|
|
||||||
|
|
||||||
if(input('openid')){
|
|
||||||
$model_obj->where('openid',input('openid'));
|
|
||||||
}
|
|
||||||
$data = $model_obj->find();
|
|
||||||
if(empty($data)){
|
|
||||||
return json(Tools::set_res(234,'用户不存在'));
|
|
||||||
}
|
|
||||||
//更新用户最后登录时间
|
|
||||||
Db::table('fa_ty_users')
|
|
||||||
->data(['last_login_time'=>Tools::get_now_date()])
|
|
||||||
->where('id',$data['id'])
|
|
||||||
->update();
|
|
||||||
|
|
||||||
//写入登录记录
|
|
||||||
Mmodel::existsUpdateInsert('fa_login_record',['date'=>date('Y-m-d')],[
|
|
||||||
'openid'=>$openid,
|
|
||||||
'date'=>date('Y-m-d')
|
|
||||||
]);
|
|
||||||
|
|
||||||
//总计登录天数
|
|
||||||
$data['total_login_days'] = Db::table('fa_login_record')
|
|
||||||
->where('openid',$openid)
|
|
||||||
->count('id');
|
|
||||||
//当前排名
|
|
||||||
$data['now_rank'] = $this->countRank($openid);
|
|
||||||
|
|
||||||
//eliminate
|
|
||||||
$eliminate = Db::table('fa_usereliminate')
|
|
||||||
->where('openid',$data['openid'])
|
|
||||||
->select();
|
|
||||||
$data['eliminate'] = $eliminate;
|
|
||||||
|
|
||||||
|
|
||||||
return json(Tools::set_ok('ok',$data));
|
|
||||||
}catch(\Exception $e){
|
|
||||||
Tools::log_to_write_txt([
|
|
||||||
'error'=>'查询单个用户.异常.'.$e->getMessage(),
|
|
||||||
'参数'=>input(),
|
|
||||||
'error_info'=>$e->getTraceAsString()
|
|
||||||
]);
|
|
||||||
return json(Tools::set_res(500,'操作异常',[]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* desc:授权,登录
|
|
||||||
*
|
*
|
||||||
* /api/users/login
|
* /api/users/login
|
||||||
*
|
*
|
||||||
@@ -125,10 +44,10 @@ class Users extends BaseHttpApi
|
|||||||
function login()
|
function login()
|
||||||
{
|
{
|
||||||
return Mmodel::catchJson(function (){
|
return Mmodel::catchJson(function (){
|
||||||
//$clientid = input('clientid');
|
$clientid = input('clientid');
|
||||||
//if(empty($clientid)){
|
if(empty($clientid)){
|
||||||
// return Tools::set_fail('clientid error');
|
return Tools::set_fail('clientid error');
|
||||||
//}
|
}
|
||||||
|
|
||||||
$username = input('username');
|
$username = input('username');
|
||||||
if(empty($username)){
|
if(empty($username)){
|
||||||
@@ -163,7 +82,7 @@ class Users extends BaseHttpApi
|
|||||||
->data([
|
->data([
|
||||||
'ticket'=>$ticketstr,
|
'ticket'=>$ticketstr,
|
||||||
'expires'=>$expires,//7天
|
'expires'=>$expires,//7天
|
||||||
//'clientid'=>$clientid,
|
'clientid'=>$clientid,
|
||||||
])
|
])
|
||||||
->where('username',$username)
|
->where('username',$username)
|
||||||
->update();
|
->update();
|
||||||
@@ -171,22 +90,5 @@ class Users extends BaseHttpApi
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* desc:保存听译聊天记录
|
|
||||||
*
|
|
||||||
* api/Users/saveChatHistory
|
|
||||||
*
|
|
||||||
* author:wh
|
|
||||||
*/
|
|
||||||
function saveChatHistory(){
|
|
||||||
return Mmodel::catchJson(function (){
|
|
||||||
$obj = new TychatLogic();
|
|
||||||
$chat_content = input('chat_content');
|
|
||||||
if(empty($chat_content)){
|
|
||||||
return Tools::set_fail('参数错误');
|
|
||||||
}
|
|
||||||
$res = $obj->saveChatHistory($chat_content);
|
|
||||||
return Tools::set_ok('ok',$res);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -27,7 +27,7 @@ class UserLogic extends BaseLogic
|
|||||||
Mmodel::catchTrans(function () use ($client_id){
|
Mmodel::catchTrans(function () use ($client_id){
|
||||||
Tools::log_to_write_txt(['服务端收到客户端离线消息:client_id:' . $client_id]);
|
Tools::log_to_write_txt(['服务端收到客户端离线消息:client_id:' . $client_id]);
|
||||||
|
|
||||||
$user = Db::table(TabConf::$fa_users)
|
$user = Db::table('fa_ty_users')
|
||||||
->where('clientid', $client_id)
|
->where('clientid', $client_id)
|
||||||
->find();
|
->find();
|
||||||
if(empty($user)){
|
if(empty($user)){
|
||||||
@@ -43,7 +43,7 @@ class UserLogic extends BaseLogic
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
Tools::log_to_write_txt(['设置离线时间:clientid:' . $client_id]);
|
Tools::log_to_write_txt(['设置离线时间:clientid:' . $client_id]);
|
||||||
Db::table(TabConf::$fa_users)
|
Db::table('fa_ty_users')
|
||||||
->where('clientid', $client_id)
|
->where('clientid', $client_id)
|
||||||
->data([
|
->data([
|
||||||
'clientid'=>'',
|
'clientid'=>'',
|
||||||
@@ -67,4 +67,59 @@ class UserLogic extends BaseLogic
|
|||||||
//Gateway::sendToClient($client_id, json_encode($json, JSON_UNESCAPED_UNICODE));
|
//Gateway::sendToClient($client_id, json_encode($json, JSON_UNESCAPED_UNICODE));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* desc:听译-保存听译聊天记录
|
||||||
|
*
|
||||||
|
* User/saveChatHistory
|
||||||
|
*
|
||||||
|
* author:wh
|
||||||
|
*/
|
||||||
|
function saveChatHistory($client_id,$data){
|
||||||
|
return Mmodel::catchJson(function ()use ($client_id){
|
||||||
|
$obj = new TychatLogic();
|
||||||
|
$chat_content = input('chat_content');
|
||||||
|
if(empty($chat_content)){
|
||||||
|
$json = Tools::json_wss('error', '参数错误');
|
||||||
|
Gateway::sendToClient($client_id, $json);
|
||||||
|
|
||||||
|
}
|
||||||
|
$res = $obj->saveChatHistory($chat_content);
|
||||||
|
return Tools::set_ok('ok',$res);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* desc:绑定医患关系,医患客户端初始化后绑定关系
|
||||||
|
*请求参数:
|
||||||
|
* json消息格式:[
|
||||||
|
'action'=>'user/bindRelation',
|
||||||
|
'items'=>[
|
||||||
|
'username'=>'13333322323',
|
||||||
|
]
|
||||||
|
]
|
||||||
|
* author:wh
|
||||||
|
*/
|
||||||
|
function bindRelation($clientid,$data){
|
||||||
|
if(empty($data['items'])){
|
||||||
|
$json = Tools::json_wss('error','items参数错误');
|
||||||
|
return Gateway::sendToClient($clientid, $json);
|
||||||
|
}
|
||||||
|
$items = $data['items'];
|
||||||
|
if(empty($items['username'])){
|
||||||
|
$json = Tools::json_wss('error','username参数错误');
|
||||||
|
return Gateway::sendToClient($clientid, $json);
|
||||||
|
}
|
||||||
|
Db::table('fa_ty_users')
|
||||||
|
->data([
|
||||||
|
'clientid'=>$clientid,
|
||||||
|
])
|
||||||
|
->where('username',$items['username'])
|
||||||
|
->update();
|
||||||
|
|
||||||
|
//$json = Tools::json_wss('ok','username参数错误');
|
||||||
|
//return Gateway::sendToClient($clientid, $json);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user