1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- <?php
- /**
- * 机器人相关
- */
- defined('IN_WEB') or die('Include Error!');
- class ModelRobot{
- /**
- * 获得全部机器人
- * @return array
- * Created by: Owen
- * Created on: 2019/7/24 17:47
- * Description:
- */
- public function getAllRobot(){
- $userList = oo::commonOprRedis('common')->get(okeys::GetRobotUserList());
- if(!empty($userList)){
- $userList = json_decode($userList,true);
- if(!empty($userList)&&is_array($userList)){
- return $userList;
- }
- }
- $tb = otable::Robot();
- $sql = "SELECT * FROM {$tb} WHERE 1";
- $ret = oo::commonOprDb('api')->getAll($sql,1);
- $robot = [];
- foreach ($ret as $row){
- $robot[] = $row['uid'];
- }
- oo::commonOprRedis('common')->set(okeys::GetRobotUserList(),json_encode($robot));
- return $robot;
- }
-
- /**
- * 设置机器人金钱排行
- * Created by: Owen
- * Created on: 2019/7/24 17:47
- * Description:
- */
- public function rankRobot(){
- $robot = self::getAllRobot();
- $InUid = implode(',',$robot);
- $ghtable = otable::gh_gameserver(1);
- $sql = "SELECT * FROM {$ghtable} WHERE mid IN ({$InUid})";
- $ret = oo::commonOprDb('ghgames')->getAll($sql,MYSQLI_ASSOC);
- foreach ($ret as $row){
- oo::commonOprRedis('common')->zAdd(okeys::rankRobot(),$row['money'],$row['mid']);
- }
- }
-
- }
|