syn.action.php 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | Fanwe 方维p2p借贷系统
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2011 http://www.fanwe.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Author: 云淡风轻(1956838968@qq.com)
  8. // +----------------------------------------------------------------------
  9. class synModule extends baseModule
  10. {
  11. //登录 test
  12. public function login()
  13. {
  14. if(IS_DEBUG){
  15. $mobile = intval($_REQUEST['mobile']);
  16. $uid = intval($_REQUEST['id']);
  17. if($mobile){
  18. $user_data = $GLOBALS['db']->getRow("select * from ".DB_PREFIX."user where mobile =".$mobile);
  19. }else{
  20. if($uid){
  21. $user_data = $GLOBALS['db']->getRow("select * from ".DB_PREFIX."user where id =".$uid);
  22. }else{
  23. print_r("请填写会员ID");exit;
  24. }
  25. }
  26. es_session::set("user_info",$user_data);
  27. $GLOBALS['user_info'] = $user_data;
  28. es_cookie::set("client_ip",CLIENT_IP,3600*24*30);
  29. es_cookie::set("nick_name",$user_data['nick_name'],3600*24*30);
  30. es_cookie::set("user_id",$user_data['id'],3600*24*30);
  31. es_cookie::set("user_pwd",md5($user_data['user_pwd']."_EASE_COOKIE"),3600*24*30);
  32. es_cookie::set("is_agree",$user_data['is_agree'],3600*24*30);
  33. es_cookie::set("PHPSESSID2",es_session::id(),3600*24*30);
  34. print_r($user_data);
  35. }
  36. }
  37. //循环同步到IM
  38. function synchronization_im(){
  39. if(IS_DEBUG){
  40. fanwe_require(APP_ROOT_PATH."system/libs/user.php");
  41. $user_id = intval($_REQUEST['id']);
  42. if($user_id){
  43. $user = $GLOBALS['db']->getAll("SELECT id,nick_name,head_image FROM ".DB_PREFIX."user where id = ".$user_id);
  44. }else{
  45. $user = $GLOBALS['db']->getAll("SELECT id,nick_name,head_image FROM ".DB_PREFIX."user where synchronize=0 ");
  46. }
  47. if($user){
  48. foreach($user as $k=>$user_data){
  49. accountimport($user_data);
  50. }
  51. echo $user_id."用户已同步";
  52. }else{
  53. echo "用户已同步";
  54. }
  55. }
  56. }
  57. //循环同步到redis
  58. function synchronization_redis(){
  59. if(IS_DEBUG){
  60. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/UserRedisService.php');
  61. $user_redis = new UserRedisService();
  62. $user_id = intval($_REQUEST['id']);
  63. $type = intval($_REQUEST['type']);
  64. if($user_id){
  65. if($type==1&&$_REQUEST['c']!=''){
  66. fanwe_require(APP_ROOT_PATH."system/libs/user.php");
  67. $user_info =array();
  68. if($_REQUEST['c']=='mobile'||$_REQUEST['c']=='all')
  69. $user_info['mobile'] ='';
  70. if($_REQUEST['c']=='qq'||$_REQUEST['c']=='all')
  71. $user_info['qq_openid'] ='';
  72. if($_REQUEST['c']=='wx'||$_REQUEST['c']=='all'){
  73. $user_info['wx_openid'] ='';
  74. $user_info['wx_unionid'] ='';
  75. }
  76. if($_REQUEST['c']=='sina'||$_REQUEST['c']=='all'){
  77. $user_info['sina_id'] ='';
  78. }
  79. if($_REQUEST['c']=='wx_gz'||$_REQUEST['c']=='all'){
  80. $user_info['gz_openid'] ='';
  81. $user_info['subscribe'] ='';
  82. }
  83. $where = "id=".intval($user_id);
  84. $GLOBALS['db']->autoExecute(DB_PREFIX."user",$user_info,'UPDATE',$where);
  85. }
  86. $user = $GLOBALS['db']->getRow("SELECT * FROM ".DB_PREFIX."user where id = ".$user_id);
  87. if($user){
  88. $user_redis->update_db($user_id,$user);
  89. echo "用户redis同步完成";
  90. }else{
  91. echo "用户redis已同步";
  92. }
  93. }
  94. }
  95. }
  96. //图片同步
  97. function synchronization_image(){
  98. if(IS_DEBUG){
  99. $user_id = intval($_REQUEST['id']);
  100. if($user_id){
  101. $user_data = $GLOBALS['db']->getRow("select id,head_image from ".DB_PREFIX."user where id =".$user_id);
  102. if($GLOBALS['distribution_cfg']['OSS_TYPE']&&$GLOBALS['distribution_cfg']['OSS_TYPE']!='NONE')
  103. {
  104. syn_to_remote_image_server($user_data['head_image']);
  105. }
  106. echo "执行结束";exit;
  107. }else{
  108. echo "ID空";exit;
  109. }
  110. }
  111. }
  112. //测试读取缓存 load_auto_cache
  113. public function m_configs(){
  114. if(IS_DEBUG){
  115. $cache_name = $_REQUEST['cache_name'];
  116. $rm_cache = intval($_REQUEST['rm_cache']);
  117. if($rm_cache){
  118. rm_auto_cache($cache_name);
  119. }
  120. $cache = load_auto_cache($cache_name);
  121. print_r($cache);exit;
  122. }
  123. }
  124. function get_ip(){
  125. print_r(get_info());
  126. }
  127. //修改用户id到指定位数
  128. public function update_user_id(){
  129. $sql = "update ".DB_PREFIX."user set id=id+100000";
  130. $GLOBALS['db']->query($sql);
  131. $sql = "select id from ".DB_PREFIX."user order by id desc";
  132. $max_id = $GLOBALS['db']->getOne($sql,true,true);
  133. $max_id = intval($max_id)+1;
  134. $sql = "alter table ".DB_PREFIX."user_id AUTO_INCREMENT=".$max_id;
  135. $GLOBALS['db']->query($sql);
  136. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/BaseRedisService.php');
  137. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/UserRedisService.php');
  138. //删除定时器加入直播的机器人列表
  139. $user_redis = new UserRedisService();
  140. $video_con_keys = $user_redis->redis->keys($GLOBALS['distribution_cfg']['REDIS_PREFIX'].'user_robot');
  141. $video_con_count = $user_redis->redis->delete($video_con_keys);
  142. print_r("删除加入直播间的机器人:".$video_con_count);
  143. print_r("<br/>");
  144. $user_data = $GLOBALS['db']->getAll("select * from ".DB_PREFIX."user");
  145. if(count($user_data)>0){
  146. require_once(APP_ROOT_PATH.'system/tim/TimApi.php');
  147. $api = createTimAPI();
  148. $user_redis = new UserRedisService();
  149. foreach($user_data as $k=>$v){
  150. //同步到im
  151. $ret = $api->account_import((string)$v['id'], $v['nick_name'], $v['head_image']);
  152. if($ret['ErrorCode']==0){
  153. $GLOBALS['db']->query("update ".DB_PREFIX."user set synchronize = 1 where id =".$v['id']);
  154. $v['synchronize'] = 1;
  155. $ret_im[] = $v['id'];
  156. }
  157. //同步用户到redis
  158. $user_redis->insert_db($v['id'],$v);
  159. $ret_redis[] = $v['id'];
  160. }
  161. }
  162. print_r("同步到redis用户:");
  163. print_r($ret_redis);
  164. print_r("<br/>");
  165. print_r("同步到im用户:");
  166. print_r($ret_im);exit;
  167. }
  168. //删除定时器加入直播的机器人列表
  169. public function del_user_robot(){
  170. if(IS_DEBUG){
  171. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/BaseRedisService.php');
  172. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/UserRedisService.php');
  173. $user_redis = new UserRedisService();
  174. $video_con_keys = $user_redis->redis->keys($GLOBALS['distribution_cfg']['REDIS_PREFIX'].'user_robot');
  175. $video_con_count = $user_redis->redis->delete($video_con_keys);
  176. print_r($video_con_count);exit;
  177. }
  178. }
  179. //同步机器人到redis
  180. public function robot($json = 0){
  181. //if(IS_DEBUG){
  182. $user_data = $GLOBALS['db']->getAll("select * from ".DB_PREFIX."user where is_robot = 1");
  183. if(count($user_data)>0){
  184. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/BaseRedisService.php');
  185. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/UserRedisService.php');
  186. $user_redis = new UserRedisService();
  187. foreach($user_data as $k=>$v){
  188. $user_redis->insert_db($v['id'],$v);
  189. $ret[] = $v['id'];
  190. }
  191. }
  192. if($json){
  193. $root = array('status'=>1,'error'=>'实际数量:'.count($user_data).' 同步数量:'.count($ret));
  194. ajax_return($root);
  195. }
  196. print_r($ret);exit;
  197. //}
  198. }
  199. //同步机器人到im
  200. public function robot_im1($json = 0){
  201. //if(IS_DEBUG){
  202. $user_data = $GLOBALS['db']->getAll("select * from ".DB_PREFIX."user where is_robot = 1 limit 0,100");
  203. require_once(APP_ROOT_PATH.'system/tim/TimApi.php');
  204. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/BaseRedisService.php');
  205. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/UserRedisService.php');
  206. $user_redis = new UserRedisService();
  207. $api = createTimAPI();
  208. if(is_array($api)){
  209. if($json){
  210. ajax_return($api);
  211. }
  212. print_r($api);exit;
  213. }
  214. if(count($user_data)){
  215. foreach($user_data as $k=>$v){
  216. //添加成功,同步信息
  217. $ret = $api->account_import((string)$v['id'], $v['nick_name'], $v['head_image']);
  218. if($ret['ErrorCode']==0){
  219. $GLOBALS['db']->query("update ".DB_PREFIX."user set synchronize = 1 where id =".$v['id']);
  220. $data['synchronize'] = 1;
  221. $user_redis->update_db($v['id'],$data);
  222. $ret_im[] = $v['id'];
  223. }else{
  224. print_r($ret);echo "<hr/>";exit;
  225. }
  226. }
  227. }
  228. if($json){
  229. $root = array('status'=>1,'error'=>'实际数量:'.count($user_data).' 同步数量:'.count($ret));
  230. ajax_return($root);
  231. }
  232. print_r($ret_im);exit;
  233. //}
  234. }
  235. //同步机器人到im
  236. public function robot_im2($json = 0){
  237. //if(IS_DEBUG){
  238. $user_data = $GLOBALS['db']->getAll("select * from ".DB_PREFIX."user where is_robot = 1 limit 200,100");
  239. require_once(APP_ROOT_PATH.'system/tim/TimApi.php');
  240. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/BaseRedisService.php');
  241. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/UserRedisService.php');
  242. $user_redis = new UserRedisService();
  243. $api = createTimAPI();
  244. if(is_array($api)){
  245. if($json){
  246. ajax_return($api);
  247. }
  248. print_r($api);exit;
  249. }
  250. if(count($user_data)){
  251. foreach($user_data as $k=>$v){
  252. //添加成功,同步信息
  253. $ret = $api->account_import((string)$v['id'], $v['nick_name'], $v['head_image']);
  254. if($ret['ErrorCode']==0){
  255. $GLOBALS['db']->query("update ".DB_PREFIX."user set synchronize = 1 where id =".$v['id']);
  256. $data['synchronize'] = 1;
  257. $user_redis->update_db($v['id'],$data);
  258. $ret_im[] = $v['id'];
  259. }else{
  260. print_r($ret);echo "<hr/>";exit;
  261. }
  262. }
  263. }
  264. if($json){
  265. $root = array('status'=>1,'error'=>'实际数量:'.count($user_data).' 同步数量:'.count($ret));
  266. ajax_return($root);
  267. }
  268. print_r($ret_im);exit;
  269. //}
  270. }
  271. //同步机器人到im
  272. public function robot_im3($json = 0){
  273. //if(IS_DEBUG){
  274. $user_data = $GLOBALS['db']->getAll("select * from ".DB_PREFIX."user where is_robot = 1 limit 300,100");
  275. require_once(APP_ROOT_PATH.'system/tim/TimApi.php');
  276. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/BaseRedisService.php');
  277. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/UserRedisService.php');
  278. $user_redis = new UserRedisService();
  279. $api = createTimAPI();
  280. if(is_array($api)){
  281. if($json){
  282. ajax_return($api);
  283. }
  284. print_r($api);exit;
  285. }
  286. if(count($user_data)){
  287. foreach($user_data as $k=>$v){
  288. //添加成功,同步信息
  289. $ret = $api->account_import((string)$v['id'], $v['nick_name'], $v['head_image']);
  290. if($ret['ErrorCode']==0){
  291. $GLOBALS['db']->query("update ".DB_PREFIX."user set synchronize = 1 where id =".$v['id']);
  292. $data['synchronize'] = 1;
  293. $user_redis->update_db($v['id'],$data);
  294. $ret_im[] = $v['id'];
  295. }else{
  296. print_r($ret);echo "<hr/>";exit;
  297. }
  298. }
  299. }
  300. if($json){
  301. $root = array('status'=>1,'error'=>'实际数量:'.count($user_data).' 同步数量:'.count($ret));
  302. ajax_return($root);
  303. }
  304. print_r($ret_im);exit;
  305. //}
  306. }
  307. //同步某个用户信息到redis
  308. public function update_user(){
  309. if(IS_DEBUG){
  310. $id = $_REQUEST['id'];
  311. $user_data = $GLOBALS['db']->getRow("select * from ".DB_PREFIX."user where id = ".$id);
  312. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/BaseRedisService.php');
  313. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/UserRedisService.php');
  314. $user_redis = new UserRedisService();
  315. $user_redis->update_db($user_data['id'],$user_data);
  316. }
  317. }
  318. public function pay_live(){
  319. if(IS_DEBUG){
  320. //扣费开始
  321. $m_config = load_auto_cache("m_config");//初始化手机端配置
  322. $uesddiamonds_to_score = $m_config['uesddiamonds_to_score'];
  323. $ticket_to_rate = $m_config['ticket_to_rate'];
  324. $sql = "select id,from_user_id,to_user_id,total_ticket from ".DB_PREFIX."live_pay_log where create_date = '2017-01-18' order by id desc";
  325. $live_pay_log_info = $GLOBALS['db']->getAll($sql);
  326. foreach($live_pay_log_info as $k=>$v){
  327. //$total_ticket = round($v['live_fee']*floatval($ticket_to_rate),2);
  328. //echo $v['id']."--".$v['to_user_id']."--".$v['total_ticket'];echo "<hr/>";
  329. //echo $v['to_user_id'].",";
  330. //$sql = "update ".DB_PREFIX."live_pay_log set total_ticket = ".$total_ticket." where total_ticket=0 and id = ".$v['id'];
  331. //$GLOBALS['db']->query($sql);
  332. //if($GLOBALS['db']->affected_rows()){
  333. //$sql = "update ".DB_PREFIX."user set score = score + ".$v['total_score']." where id = ".$v['from_user_id'];
  334. //$GLOBALS['db']->query($sql);
  335. //$sql = "update ".DB_PREFIX."user set ticket = ticket + ".$v['total_ticket']." where id = ".$v['to_user_id'];
  336. //$GLOBALS['db']->query($sql);
  337. //user_deal_to_reids(array($v['from_user_id']));//同步user信息到redis
  338. //更新主播直播间获得印票
  339. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/VideoContributionRedisService.php');
  340. $videoCont_redis = new VideoContributionRedisService();
  341. $videoCont_redis->insert_db($v['from_user_id'], $v['to_user_id'],$v['id'], $v['total_ticket']);
  342. //}
  343. }
  344. print_r(count($live_pay_log_info));exit;
  345. /**/
  346. }
  347. }
  348. //所有用户等级改为1,其他与等级相关字段清零
  349. public function syn_user_level($json =0,$user_id=0){
  350. if(IS_DEBUG){
  351. $sql = "";
  352. if($user_id>0){
  353. $sql = " and id=".$user_id;
  354. }
  355. $GLOBALS['db']->query("update ".DB_PREFIX."user set score=0,online_time=0,user_level=1 where is_robot = 0 ".$sql);
  356. $user_data = $GLOBALS['db']->getAll("select id,score,online_time,user_level from ".DB_PREFIX."user where is_robot = 0 ".$sql,true,true);
  357. if(count($user_data)>0){
  358. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/BaseRedisService.php');
  359. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/UserRedisService.php');
  360. $user_redis = new UserRedisService();
  361. foreach($user_data as $k=>$v){
  362. $user_redis->update_db($v['id'],$v);
  363. $ret[] = $v['id'];
  364. }
  365. }
  366. if($json){
  367. $root = array('status'=>0,'error'=>'修改失败!');
  368. if(count($user_data) == count($ret)){
  369. $root['status'] = 1;
  370. $root['error'] = '修改成功!';
  371. }
  372. ajax_return($root);
  373. }
  374. print_r($ret);exit;
  375. }
  376. }
  377. //根据用户id,等级,积分修改用户等级
  378. public function update_user_level(){
  379. if(IS_DEBUG){
  380. $id = $_REQUEST['id'];
  381. $user_level = $_REQUEST['user_level'];
  382. $score = $_REQUEST['score'];
  383. $GLOBALS['db']->query("update ".DB_PREFIX."user set user_level=".$user_level.",score=".$score.",online_time = 0 where id in(".$id.")");
  384. $user_data = $GLOBALS['db']->getAll("select id,user_level,score,online_time from ".DB_PREFIX."user where id in(".$id.")");
  385. if(count($user_data)>0){
  386. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/BaseRedisService.php');
  387. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/UserRedisService.php');
  388. $user_redis = new UserRedisService();
  389. foreach($user_data as $k=>$v){
  390. $user_redis->update_db($v['id'],$v);
  391. $ret[] = $v['id'];
  392. }
  393. }
  394. print_r($ret);exit;
  395. }
  396. }
  397. public function clear_data(){
  398. if(IS_DEBUG){
  399. $html = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  400. <html>
  401. <head>
  402. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  403. <title>数据操作</title>
  404. </head>
  405. <body>
  406. <script type="text/javascript" src="'.SITE_DOMAIN.'/admin/Tpl/default/Common/js/jquery.js"></script>
  407. <div align="center" style="padding-top: 50px;">
  408. <form action="'.SITE_DOMAIN.'/mapi/index.php?ctl=syn&act=clear" method="get" id="form_type">
  409. 清除信息:<select name="type" id="type" onchange="change_type();">
  410. <option value="0">选择数据的操作方式</option>
  411. <option value="1">机器人同步到im</option>
  412. <option value="2">机器人同步到redis</option>
  413. <option value="3">修改等级为1(积分清零)</option>
  414. <option value="4">用户的钻石、消费钻石、印票、可用印票清零</option>
  415. <option value="5">用户的粉丝、关注数量清零</option>
  416. <option value="6">清空所有记录(包含用户、直播、提现、充值等除配置外所有数据,不含机器人)</option>
  417. </select>
  418. <br/>
  419. <div style="display: none;padding-top: 20px;" id="user_module">
  420. 主播ID:<input type = "text" value="" name="user_id" id="user_id"/>(不填则操作所有主播)
  421. </div>
  422. <br/>
  423. <input type="button" class="submit button" value="提交" onclick="submit_type();"/>
  424. </form>
  425. </div>
  426. <script type="text/javascript">
  427. $(function(){
  428. var type = $("#type option:selected") .val();
  429. if(type==3 || type==4 || type==5){
  430. $("#user_module").show();
  431. }else{
  432. $("#user_module").hide();
  433. $("#user_id").val("");
  434. }
  435. });
  436. function change_type(){
  437. var type = $("#type option:selected") .val();
  438. if(type==3 || type==4 || type==5){
  439. $("#user_module").show();
  440. }else{
  441. $("#user_module").hide();
  442. $("#user_id").val("");
  443. }
  444. }
  445. function submit_type(){
  446. var type = $("#type option:selected") .val();
  447. if(type>0){
  448. var confirm_str = "确定将";
  449. var user_id = $("#user_id").val();
  450. var user_str = "所有";
  451. if(user_id){
  452. user_str = user_id;
  453. }
  454. confirm_str = confirm_str+user_str+$("#type option:selected") .text() +"吗?";
  455. if(confirm(confirm_str)){
  456. var url = $("#form_type").attr("action");
  457. var query = $("#form_type").serialize();
  458. $.ajax({
  459. url:url,
  460. data:query,
  461. dataType:"json",
  462. type:"post",
  463. success:function(result){
  464. alert(result.error);
  465. func();
  466. function func(){
  467. if(result.status==1){
  468. location.href=location.href;
  469. }
  470. }
  471. }
  472. });
  473. }
  474. }else{
  475. alert("请选择数据的操作方式!!");
  476. }
  477. }
  478. </script>
  479. </body>
  480. </html>';
  481. echo $html;
  482. }else{
  483. print_r("请开启debug模式");exit;
  484. }
  485. }
  486. public function clear(){
  487. $root = array('status'=>0,'error'=>'');
  488. if(IS_DEBUG){
  489. $type = $_REQUEST['type'];
  490. $root['error'] = '请选择数据的操作方式!!';
  491. if($type){
  492. $user_id = intval($_REQUEST['user_id']);
  493. if($type == 3 || $type==4 || $type==5){
  494. $user_id = $GLOBALS['db']->getOne("select id from " . DB_PREFIX . "user where is_robot=0 and id = " . intval($user_id),true,true);
  495. if(intval($user_id)<=0){
  496. $root['error'] = '主播ID不存在';
  497. ajax_return($root);
  498. }
  499. }
  500. if($type == 1){
  501. $this->robot_im(1);
  502. }elseif($type == 2){
  503. $this->robot(1);
  504. }elseif($type == 3){
  505. $this->syn_user_level(1,$user_id);
  506. }elseif($type==4){
  507. $sql = "";
  508. if($user_id>0){
  509. $sql = " and id=".$user_id;
  510. }
  511. $GLOBALS['db']->query("update ".DB_PREFIX."user set diamonds=0,use_diamonds=0,ticket=0,refund_ticket=0 where is_robot = 0 ".$sql);
  512. $user_data = $GLOBALS['db']->getAll("select id,diamonds,use_diamonds,ticket,refund_ticket from ".DB_PREFIX."user where is_robot = 0 ".$sql,true,true);
  513. if(count($user_data)>0){
  514. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/BaseRedisService.php');
  515. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/UserRedisService.php');
  516. $user_redis = new UserRedisService();
  517. foreach($user_data as $k=>$v){
  518. $user_redis->update_db($v['id'],$v);
  519. $ret[] = $v['id'];
  520. }
  521. }
  522. $root = array('status'=>0,'error'=>'清除失败!');
  523. if(count($user_data) == count($ret)){
  524. $root['status'] = 1;
  525. $root['error'] = '清除成功!';
  526. }
  527. ajax_return($root);
  528. }elseif($type==5){
  529. $sql = "";
  530. if($user_id>0){
  531. $sql = " and id=".$user_id;
  532. }
  533. $GLOBALS['db']->query("update ".DB_PREFIX."user set fans_count=0,focus_count=0 where is_robot = 0 ".$sql);
  534. $user_data = $GLOBALS['db']->getAll("select id,fans_count,focus_count from ".DB_PREFIX."user where is_robot = 0 ".$sql,true,true);
  535. if(count($user_data)>0){
  536. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/BaseRedisService.php');
  537. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/UserRedisService.php');
  538. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/UserFollwRedisService.php');
  539. $user_redis = new UserRedisService();
  540. foreach($user_data as $k=>$v){
  541. $user_redis->update_db($v['id'],$v);
  542. $ret[] = $v['id'];
  543. $user_follow_redis = new UserFollwRedisService($user_id);
  544. $user_follow_redis->redis->delete($user_follow_redis->user_follow_db.$v['id']);
  545. $user_follow_redis->redis->delete($user_follow_redis->user_followed_by_db.$v['id']);
  546. }
  547. }
  548. $root = array('status'=>0,'error'=>'清除失败!');
  549. if(count($user_data) == count($ret)){
  550. $root['status'] = 1;
  551. $root['error'] = '清除成功!';
  552. }
  553. ajax_return($root);
  554. }elseif($type==6){
  555. $this->clear_all();
  556. }
  557. }
  558. }else{
  559. $root['error'] = '请开启debug模式';
  560. }
  561. print_r($root);
  562. }
  563. //清空用户数据
  564. public function clear_all(){
  565. $result = array();
  566. $result['api_log'] = $GLOBALS['db']->query("delete from ".DB_PREFIX."api_log");
  567. $result['black'] = $GLOBALS['db']->query("delete from ".DB_PREFIX."black");
  568. $result['deal_msg_list'] = $GLOBALS['db']->query("delete from ".DB_PREFIX."deal_msg_list");
  569. $result['mobile_verify_code'] = $GLOBALS['db']->query("delete from ".DB_PREFIX."mobile_verify_code");
  570. $result['exchange_log'] = $GLOBALS['db']->query("delete from ".DB_PREFIX."exchange_log");
  571. $result['flow_statistics'] = $GLOBALS['db']->query("delete from ".DB_PREFIX."flow_statistics");
  572. $result['log'] = $GLOBALS['db']->query("delete from ".DB_PREFIX."log");
  573. $result['payment_notice'] = $GLOBALS['db']->query("delete from ".DB_PREFIX."payment_notice");
  574. $result['push_anchor'] = $GLOBALS['db']->query("delete from ".DB_PREFIX."push_anchor");
  575. $result['slb_group'] = $GLOBALS['db']->query("delete from ".DB_PREFIX."slb_group");
  576. $result['tipoff'] = $GLOBALS['db']->query("delete from ".DB_PREFIX."tipoff");
  577. //清空主播
  578. $result['user'] = $GLOBALS['db']->query("delete from ".DB_PREFIX."user where is_robot = 0");
  579. $result['user_admin'] = $GLOBALS['db']->query("delete from ".DB_PREFIX."user_admin");
  580. $result['user_id'] = $GLOBALS['db']->query("delete from ".DB_PREFIX."user_id");
  581. $result['user_log'] = $GLOBALS['db']->query("delete from ".DB_PREFIX."user_log");
  582. $result['user_music'] = $GLOBALS['db']->query("delete from ".DB_PREFIX."user_music");
  583. $result['user_refund'] = $GLOBALS['db']->query("delete from ".DB_PREFIX."user_refund");
  584. $result['login_log'] = $GLOBALS['db']->query("delete from ".DB_PREFIX."login_log");
  585. //清空直播记录
  586. $result['room_id'] = $GLOBALS['db']->query("delete from ".DB_PREFIX."room_id");
  587. $result['video'] = $GLOBALS['db']->query("delete from ".DB_PREFIX."video");
  588. $result['video_history'] = $GLOBALS['db']->query("delete from ".DB_PREFIX."video_history");
  589. $result['video_cate'] = $GLOBALS['db']->query("delete from ".DB_PREFIX."video_cate");
  590. $result['video_lianmai'] = $GLOBALS['db']->query("delete from ".DB_PREFIX."video_lianmai");
  591. $result['video_lianmai_history'] = $GLOBALS['db']->query("delete from ".DB_PREFIX."video_lianmai_history");
  592. $result['video_monitor'] = $GLOBALS['db']->query("delete from ".DB_PREFIX."video_monitor");
  593. $result['video_monitor_history'] = $GLOBALS['db']->query("delete from ".DB_PREFIX."video_monitor_history");
  594. $result['video_red'] = $GLOBALS['db']->query("delete from ".DB_PREFIX."video_red");
  595. $result['video_share'] = $GLOBALS['db']->query("delete from ".DB_PREFIX."video_share");
  596. $result['video_share_history'] = $GLOBALS['db']->query("delete from ".DB_PREFIX."video_share_history");
  597. $result['video_prop'] = $GLOBALS['db']->query("delete from ".DB_PREFIX."video_prop");
  598. if(defined('OPEN_LIVE_PAY')&&OPEN_LIVE_PAY){
  599. $result['live_pay_log'] = $GLOBALS['db']->query("delete from ".DB_PREFIX."live_pay_log");
  600. $result['live_pay_log_history'] = $GLOBALS['db']->query("delete from ".DB_PREFIX."live_pay_log_history");
  601. }
  602. //家族
  603. if(defined('OPEN_FAMILY_MODULE')&&OPEN_FAMILY_MODULE==1){
  604. $result['family'] = $GLOBALS['db']->query("delete from ".DB_PREFIX."family");
  605. $result['family_join'] = $GLOBALS['db']->query("delete from ".DB_PREFIX."family_join");
  606. $result['family_level'] = $GLOBALS['db']->query("delete from ".DB_PREFIX."family_level");
  607. }
  608. if(defined('OPEN_GAME_MODULE')&&OPEN_GAME_MODULE==1){
  609. $result = array_merge($result,$this->clear_game_data());
  610. }
  611. if(defined('OPEN_GAME_MODULE')&&OPEN_PAI_MODULE==1){
  612. $result = array_merge($result,$this->pai_delete_data());
  613. }
  614. if(defined('OPEN_GAME_MODULE')&&SHOPPING_GOODS==1){
  615. $result = array_merge($result,$this->shop_delete_data());
  616. }
  617. if(defined('OPEN_GAME_MODULE')&&OPEN_PODCAST_GOODS==1){
  618. $result = array_merge($result,$this->podcast_goods_delete_data());
  619. }
  620. $root = array();
  621. $root['status'] = 1;
  622. $root['error'] = json_encode($result);
  623. print_r($root);
  624. }
  625. public function clear_game_data()
  626. {
  627. require_once APP_ROOT_PATH . 'mapi/lib/core/Model.class.php';
  628. Model::$lib = dirname(__FILE__);
  629. $result = array();
  630. $variable = [
  631. 'coin_log',
  632. 'game_log',
  633. 'game_log_history',
  634. 'user_game_log',
  635. 'user_game_log_history',
  636. 'banker_log',
  637. 'banker_log_history',
  638. 'game_distribution',
  639. ];
  640. foreach ($variable as $value) {
  641. $result[$value] = Model::build($value)->delete(['id' => ['>', 0]]);
  642. }
  643. return $result;
  644. }
  645. //清空竞拍数据
  646. public function pai_delete_data(){
  647. require_once APP_ROOT_PATH . 'mapi/lib/core/Model.class.php';
  648. Model::$lib = dirname(__FILE__);
  649. $result = array();
  650. $variable = [
  651. 'pai_goods',
  652. 'pai_join',
  653. 'goods_order',
  654. 'user_address',
  655. 'user_notice',
  656. 'pai_tags',
  657. 'user_diamonds_log',
  658. 'pai_log',
  659. 'pai_violations',
  660. 'goods',
  661. 'user_goods',
  662. 'courier',
  663. 'goods_cate',
  664. 'goods_tags',
  665. ];
  666. foreach($variable as $key => $value){
  667. $result[$value] = Model::build($value)->delete(['id'=>['>',0]]);
  668. }
  669. return $result;
  670. }
  671. //清空购物数据
  672. public function shop_delete_data(){
  673. require_once APP_ROOT_PATH . 'mapi/lib/core/Model.class.php';
  674. Model::$lib = dirname(__FILE__);
  675. $result = array();
  676. $variable = [
  677. 'goods_order',
  678. 'user_address',
  679. 'user_notice',
  680. 'pai_tags',
  681. 'user_diamonds_log',
  682. 'goods',
  683. 'user_goods',
  684. 'courier',
  685. 'shopping_cart',
  686. 'goods_cate',
  687. 'goods_tags',
  688. ];
  689. foreach($variable as $key => $value){
  690. $result[$value] = Model::build($value)->delete(['id'=>['>',0]]);
  691. }
  692. return $result;
  693. }
  694. //清空小店数据
  695. public function podcast_goods_delete_data(){
  696. require_once APP_ROOT_PATH . 'mapi/lib/core/Model.class.php';
  697. Model::$lib = dirname(__FILE__);
  698. $result = array();
  699. $result['podcast_goods'] = Model::build('podcast_goods')->delete(['id'=>['>',0]]);
  700. return $result;
  701. }
  702. //获取腾讯aeskey
  703. public function get_aes_key(){
  704. if(IS_DEBUG) {
  705. $m_config = load_auto_cache("m_config");//初始化手机端配置
  706. require_once(APP_ROOT_PATH . 'system/tim/TimApi.php');
  707. $api = createTimAPI();
  708. $group_id = strim($m_config['full_group_id']);
  709. $base_info_filter = array("Introduction");
  710. $ret = $api->group_get_group_info2(array('0' => $group_id), $base_info_filter);
  711. print_r($ret);
  712. }
  713. }
  714. //获取服务端key
  715. public function get_privatekey(){
  716. $key_list = get_privatekey();
  717. print_r($key_list);
  718. }
  719. }
  720. ?>