WeiboUserGeneralAction.class.php 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | Fanwe 方维直播系统
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2011 http://www.fanwe.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Author: 云淡风轻(1956838968@qq.com)
  8. // +----------------------------------------------------------------------
  9. class WeiboUserGeneralAction extends CommonAction{
  10. public function __construct()
  11. {
  12. parent::__construct();
  13. require_once APP_ROOT_PATH."/admin/Lib/Action/UserCommonAction.class.php";
  14. require_once APP_ROOT_PATH."/system/libs/user.php";
  15. }
  16. public function index()
  17. {
  18. $common = new UserCommon();
  19. $data = $_REQUEST;
  20. // $data['is_authentication'] = array('in',array(0,1,3));
  21. $data['is_robot'] = 0;
  22. $common->index($data);
  23. }
  24. public function edit() {
  25. $common = new UserCommon();
  26. $data = $_REQUEST;
  27. $common->edit($data);
  28. }
  29. public function delete() {
  30. //彻底删除指定记录
  31. $common = new UserCommon();
  32. $data = $_REQUEST;
  33. $common->delete($data);
  34. }
  35. public function update() {
  36. $common = new UserCommon();
  37. $data = $_REQUEST;
  38. $common->update($data);
  39. }
  40. public function set_effect()
  41. {
  42. $common = new UserCommon();
  43. $data = $_REQUEST;
  44. $n_is_effect = $common->set_effect($data);
  45. $this->ajaxReturn($n_is_effect,l("SET_EFFECT_".$n_is_effect),1);
  46. }
  47. public function set_ban()
  48. {
  49. $common = new UserCommon();
  50. $data = $_REQUEST;
  51. $n_is_effect = $common->set_ban($data);
  52. $this->ajaxReturn($n_is_effect,l("SET_BAN_".$n_is_effect),1);
  53. }
  54. //禁热门
  55. public function set_hot_on()
  56. {
  57. $common = new UserCommon();
  58. $data = $_REQUEST;
  59. $n_is_effect = $common->set_hot_on($data);
  60. $this->ajaxReturn($n_is_effect,l("SET_HOT_ON_".$n_is_effect),1);
  61. }
  62. //新增关注
  63. public function add_focus(){
  64. $common = new UserCommon();
  65. $data = $_REQUEST;
  66. $common->add_focus($data);
  67. }
  68. //新增关注
  69. public function set_follow(){
  70. $common = new UserCommon();
  71. $data = $_REQUEST;
  72. $common->set_follow($data);
  73. }
  74. //关注列表
  75. public function focus_list(){
  76. $common = new UserCommon();
  77. $data = $_REQUEST;
  78. $common->focus_list($data);
  79. }
  80. //新增粉丝
  81. public function add_fans(){
  82. $common = new UserCommon();
  83. $data = $_REQUEST;
  84. $common->add_fans($data);
  85. }
  86. //新增粉丝
  87. public function set_follower(){
  88. $common = new UserCommon();
  89. $data = $_REQUEST;
  90. $common->set_follower($data);
  91. }
  92. //粉丝列表
  93. public function fans_list(){
  94. $common = new UserCommon();
  95. $data = $_REQUEST;
  96. $common->fans_list($data);
  97. }
  98. //删除关注
  99. public function del_focus_list(){
  100. $common = new UserCommon();
  101. $data = $_REQUEST;
  102. $common->del_focus_list($data);
  103. }
  104. //删除粉丝
  105. public function del_fans_list(){
  106. $common = new UserCommon();
  107. $data = $_REQUEST;
  108. $common->del_fans_list($data);
  109. }
  110. //印票贡献榜
  111. public function contribution_list(){
  112. $common = new UserCommon();
  113. $data = $_REQUEST;
  114. $common->contribution_list($data);
  115. }
  116. /**
  117. * 删除印票贡献榜
  118. */
  119. /*public function del_contribution_list()
  120. {
  121. $ajax = intval($_REQUEST['ajax']);
  122. $id = $_REQUEST ['id'];
  123. if (isset ( $id )) {
  124. $common = new UserCommon();
  125. $data = $_REQUEST;
  126. $status = $common->del_contribution_list($data);
  127. if ($status!==false) {
  128. $this->success (l("FOREVER_DELETE_SUCCESS"),$ajax);
  129. } else {
  130. $this->error (l("FOREVER_DELETE_FAILED"),$ajax);
  131. }
  132. } else {
  133. $this->error (l("INVALID_OPERATION"),$ajax);
  134. }
  135. }*/
  136. //消息推送
  137. public function push(){
  138. $common = new UserCommon();
  139. $data = $_REQUEST;
  140. $common->push($data);
  141. }
  142. //删除推送消息
  143. public function del_push(){
  144. $ajax = intval($_REQUEST['ajax']);
  145. $id = $_REQUEST ['id'];
  146. if (isset ( $id )) {
  147. $common = new UserCommon();
  148. $data = $_REQUEST;
  149. $status = $common->del_push($data);
  150. if ($status!==false) {
  151. $this->success (l("FOREVER_DELETE_SUCCESS"),$ajax);
  152. } else {
  153. $this->error (l("FOREVER_DELETE_FAILED"),$ajax);
  154. }
  155. } else {
  156. $this->error (l("INVALID_OPERATION"),$ajax);
  157. }
  158. }
  159. //账户管理
  160. public function account()
  161. {
  162. $common = new UserCommon();
  163. $data = $_REQUEST;
  164. $status = $common->account($data);
  165. }
  166. //账户修改
  167. public function modify_account()
  168. {
  169. $common = new UserCommon();
  170. $data = $_REQUEST;
  171. $status = $common->modify_account($data);
  172. if($status){
  173. $this->success(L("UPDATE_SUCCESS"));
  174. }else{
  175. $this->error("累计充值数据有误!");
  176. }
  177. }
  178. //账户日志
  179. public function account_detail()
  180. {
  181. $common = new UserCommon();
  182. $data = $_REQUEST;
  183. $common->account_detail($data);
  184. }
  185. //兑换日志
  186. public function exchange_log()
  187. {
  188. $common = new UserCommon();
  189. $data = $_REQUEST;
  190. $common->exchange_log($data);
  191. }
  192. //删除账户日志
  193. public function foreverdelete_account_detail()
  194. {
  195. //彻底删除指定记录
  196. $ajax = intval($_REQUEST['ajax']);
  197. $id = $_REQUEST ['id'];
  198. $data = $_REQUEST;
  199. if (isset ( $id )) {
  200. $common = new UserCommon();
  201. $status = $common->foreverdelete_account_detail($data);
  202. if ($status!==false) {
  203. $this->success (l("FOREVER_DELETE_SUCCESS"),$ajax);
  204. } else {
  205. $this->error (l("FOREVER_DELETE_FAILED"),$ajax);
  206. }
  207. } else {
  208. $this->error (l("INVALID_OPERATION"),$ajax);
  209. }
  210. }
  211. //删除兑换日志
  212. public function foreverdelete_exchange_log()
  213. {
  214. //彻底删除指定记录
  215. $ajax = intval($_REQUEST['ajax']);
  216. $id = $_REQUEST ['id'];
  217. $data = $_REQUEST;
  218. if (isset ( $id )) {
  219. $common = new UserCommon();
  220. $status = $common->foreverdelete_exchange_log($data);
  221. if ($status!==false) {
  222. $this->success (l("FOREVER_DELETE_SUCCESS"),$ajax);
  223. } else {
  224. $this->error (l("FOREVER_DELETE_FAILED"),$ajax);
  225. }
  226. } else {
  227. $this->error (l("INVALID_OPERATION"),$ajax);
  228. }
  229. }
  230. //检查用户
  231. public function check_user(){
  232. $common = new UserCommon();
  233. $user_id = $_REQUEST['id'];
  234. ajax_return($common->check_user($user_id));
  235. }
  236. //礼物日志
  237. public function prop()
  238. {
  239. $common = new UserCommon();
  240. $data = $_REQUEST;
  241. $common->prop($data);
  242. }
  243. //收礼物日志
  244. public function closed_prop(){
  245. $data = $_REQUEST;
  246. $now=get_gmtime();
  247. $user_id = intval($_REQUEST['id']);
  248. $user_info = M("User")->getById($user_id);
  249. $prop_list = M("prop")->where("is_effect <>0")->findAll();
  250. $where = "l.to_user_id=".$user_id ;
  251. $model = D ("video_prop");
  252. //赠送时间
  253. $current_Year = date('Y');
  254. $current_YM = date('Ym');
  255. for ($i=0; $i<5; $i++)
  256. {
  257. $years[$i] = $current_Year - $i;
  258. }
  259. for ($i=01; $i<13; $i++)
  260. {
  261. $month[$i] = str_pad(0+$i,2,0,STR_PAD_LEFT);
  262. }
  263. if(strim($data['years'])!=-1&&strim($data['month']!=-1)){
  264. $time=$data['years'].''.$data['month'];
  265. }else{
  266. $time=$current_YM;
  267. }
  268. if(strim($data['years'])!=-1&&strim($data['month']==-1)){
  269. $this->error("请选择月份");
  270. }
  271. if(strim($data['years'])==-1&&strim($data['month']!=-1)){
  272. $this->error("请选择年份");
  273. }
  274. //查询ID
  275. if(strim($data['from_user_id'])!=''){
  276. $parameter.= "l.from_user_id=".intval($data['from_user_id']). "&";
  277. $sql_w .= "l.from_user_id=".intval($data['from_user_id'])." and ";
  278. }
  279. //查询昵称
  280. if(trim($data['nick_name'])!='')
  281. {
  282. $parameter.= "u.nick_name like " . urlencode ( '%'.trim($data['nick_name']).'%' ) . "&";
  283. $sql_w .= "u.nick_name like '%".trim($data['nick_name'])."%' and ";
  284. }
  285. if (!isset($_REQUEST['prop_id'])) {
  286. $_REQUEST['prop_id'] = -1;
  287. }
  288. //查询礼物
  289. if($_REQUEST['prop_id']!=-1) {
  290. if (isset($data['prop_id'])) {
  291. $parameter .= "l.prop_id=" . intval($data['prop_id']) . "&";
  292. $sql_w .= "l.prop_id=" . intval($data['prop_id']) . " and ";
  293. }
  294. }
  295. //默认查询本月的记录,选择查询时间时,如果查询时间 不等于当前时间,则查询他表
  296. if($data['years']!=''&&$data['month']!=''){
  297. $sql_str = "SELECT l.id,l.create_ym,l.to_user_id, l.create_time,l.prop_id,l.prop_name,l.from_user_id,l.create_date,l.num,l.total_ticket,u.nick_name
  298. FROM ".DB_PREFIX."video_prop_".$time." as l
  299. LEFT JOIN ".DB_PREFIX."user AS u ON l.from_user_id = u.id" ." LEFT JOIN ".DB_PREFIX."prop AS v ON l.prop_name = v.name" ."
  300. WHERE $where "." and ".$sql_w." 1=1 ";
  301. $count_sql = "SELECT count(l.id) as tpcount
  302. FROM ".DB_PREFIX."video_prop_".$time." as l
  303. LEFT JOIN ".DB_PREFIX."user AS u ON l.from_user_id = u.id" ." LEFT JOIN ".DB_PREFIX."prop AS v ON l.prop_name = v.name" ."
  304. WHERE $where "." and ".$sql_w." 1=1 ";
  305. $total_ticket_sql = "SELECT SUM(l.total_ticket) as tpcount
  306. FROM ".DB_PREFIX."video_prop_".date('Ym',NOW_TIME)." as l
  307. LEFT JOIN ".DB_PREFIX."user AS u ON l.from_user_id = u.id" ." LEFT JOIN ".DB_PREFIX."prop AS v ON l.prop_name = v.name" ."
  308. WHERE $where "." and ".$sql_w." 1=1 ";
  309. }else{
  310. $sql_str = "SELECT l.id,l.create_ym,l.to_user_id, l.create_time,l.prop_id,l.prop_name,l.from_user_id,l.create_date,l.num,l.total_ticket,u.nick_name
  311. FROM ".DB_PREFIX."video_prop_".date('Ym',NOW_TIME)." as l
  312. LEFT JOIN ".DB_PREFIX."user AS u ON l.from_user_id = u.id" ." LEFT JOIN ".DB_PREFIX."prop AS v ON l.prop_name = v.name" ."
  313. WHERE $where "." and ".$sql_w." 1=1 ";
  314. $count_sql = "SELECT count(l.id) as tpcount
  315. FROM ".DB_PREFIX."video_prop_".date('Ym',NOW_TIME)." as l
  316. LEFT JOIN ".DB_PREFIX."user AS u ON l.from_user_id = u.id" ." LEFT JOIN ".DB_PREFIX."prop AS v ON l.prop_name = v.name" ."
  317. WHERE $where "." and ".$sql_w." 1=1 ";
  318. $total_ticket_sql = "SELECT SUM(l.total_ticket) as tpcount
  319. FROM ".DB_PREFIX."video_prop_".date('Ym',NOW_TIME)." as l
  320. LEFT JOIN ".DB_PREFIX."user AS u ON l.from_user_id = u.id" ." LEFT JOIN ".DB_PREFIX."prop AS v ON l.prop_name = v.name" ."
  321. WHERE $where "." and ".$sql_w." 1=1 ";
  322. }
  323. $count = $GLOBALS['db']->getOne($count_sql);
  324. $total_ticket = $GLOBALS['db']->getOne($total_ticket_sql);
  325. $volist = $this->_Sql_list($model,$sql_str,'&'.$parameter,1,0,$count_sql);
  326. foreach($volist as $k=>$v){
  327. if($volist[$k]['prop_id']==12){
  328. $volist[$k]['total_ticket']='';
  329. }
  330. $volist[$k]['create_time']=date('Y-m-d',$volist[$k]['create_time']);
  331. }
  332. $this->assign("user_info",$user_info);
  333. $this->assign("prop",$prop_list);
  334. $this->assign("years",$years);
  335. $this->assign("month",$month);
  336. $this->assign("list", $volist);
  337. $this->assign("count",intval($count));
  338. $this->assign('total_ticket',intval($total_ticket));
  339. $this->display ();
  340. }
  341. //分享奖励
  342. public function distribution_log(){
  343. $common = new UserCommon();
  344. $data = $_REQUEST;
  345. $common->distribution_log($data);
  346. }
  347. //分销子成员奖励
  348. public function distribution_user(){
  349. $common = new UserCommon();
  350. $data = $_REQUEST;
  351. $common->distribution_user($data);
  352. }
  353. //删除礼物日志
  354. public function delete_prop()
  355. {
  356. //彻底删除指定记录
  357. $ajax = intval($_REQUEST['ajax']);
  358. $id = intval($_REQUEST ['id']);
  359. $data = $_REQUEST;
  360. if (isset ( $id )) {
  361. $common = new UserCommon();
  362. $status = $common->del_prop($data);
  363. if ($status!==false) {
  364. $this->success (l("FOREVER_DELETE_SUCCESS"),$ajax);
  365. } else {
  366. $this->error (l("FOREVER_DELETE_FAILED"),$ajax);
  367. }
  368. } else {
  369. $this->error (l("INVALID_OPERATION"),$ajax);
  370. }
  371. }
  372. public function forbid_msg(){
  373. $common = new UserCommon();
  374. $data = $_REQUEST;
  375. $common->forbid_msg($data);
  376. }
  377. //商品管理
  378. public function goods(){
  379. $user_id = intval($_REQUEST['user_id']);
  380. if(strim($_REQUEST['name'])!=''){
  381. $map['name'] = array('like','%'.strim($_REQUEST['name']).'%');
  382. }
  383. $map['is_effect'] = 1;
  384. $model = D ('goods');
  385. if (! empty ( $model )) {
  386. $this->_list ( $model, $map );
  387. }
  388. $list = $this->get('list');
  389. $user_list = $GLOBALS['db']->getAll("select goods_id from ".DB_PREFIX."user_goods where is_effect=1 and user_id=".$user_id);
  390. foreach($list as $k => $v){
  391. $imgs=array();
  392. $imgs_details=array();
  393. $imgs=json_decode($v['imgs'],1);
  394. $imgs_details=json_decode($v['imgs_details'],1);
  395. $list[$k]['imgs'] = $imgs[0];
  396. $list[$k]['imgs_details'] = $imgs_details[0];
  397. $list[$k]['has']= '否';
  398. foreach($user_list as $value1){
  399. if($v['id'] == $value1['goods_id']){
  400. $list[$k]['has'] = '是';
  401. break;
  402. }
  403. }
  404. }
  405. $sort = array_column($list, 'has');
  406. array_multisort($sort, SORT_DESC, $list);
  407. $this->assign("list",$list);
  408. $this->display();
  409. }
  410. //上架商品
  411. public function shelves(){
  412. $ajax = intval($_REQUEST['ajax']);
  413. $goods_id = intval($_REQUEST ['id']);
  414. $user_id = intval($_REQUEST ['user_id']);
  415. if (isset($goods_id)) {
  416. $where['goods_id'] = $goods_id;
  417. $where['user_id'] = $user_id;
  418. $user_goods = M('user_goods')->where($where)->select();
  419. $goods_info = $GLOBALS['db']->getRow("select name,imgs,imgs_details,price,pai_diamonds,kd_cost,score,is_effect from ".DB_PREFIX."goods where is_effect=1 and id=".$goods_id);
  420. if($user_goods){
  421. $list = M('user_goods')->where($where)->save($goods_info);
  422. }else{
  423. $data = array_merge($where,$goods_info);
  424. $list = M('user_goods')->add($data);
  425. }
  426. if ($list!==false) {
  427. $result['info'] = "上架成功!";
  428. $result['status'] = 1;
  429. } else {
  430. $result['info'] = "上架失败!";
  431. $result['status'] = 0;
  432. }
  433. $this->ajax_return($result);
  434. } else {
  435. $this->error (l("INVALID_OPERATION"),$ajax);
  436. }
  437. }
  438. //下架商品
  439. public function sold(){
  440. $ajax = intval($_REQUEST['ajax']);
  441. $goods_id = intval($_REQUEST ['id']);
  442. $user_id = intval($_REQUEST ['user_id']);
  443. if (isset($goods_id)) {
  444. $condition['goods_id'] = $goods_id;
  445. $condition['user_id'] = $user_id;
  446. $user_goods = M('user_goods')->where($condition)->select();
  447. if($user_goods){
  448. $list = M('user_goods')->where($condition)->delete();
  449. }
  450. if ($list!==false) {
  451. $result['info'] = "下架成功!";
  452. $result['status'] = 1;
  453. } else {
  454. $result['info'] = "下架失败!";
  455. $result['status'] = 0;
  456. }
  457. $this->ajax_return($result);
  458. } else {
  459. $this->error (l("INVALID_OPERATION"),$ajax);
  460. }
  461. }
  462. public function clear_view_count(){
  463. $sql = "update ".DB_PREFIX."user set view_count = 0";
  464. $res = $GLOBALS['db']->query($sql);
  465. if($res){
  466. $result['info'] = "清除成功!";
  467. $result['status'] = 1;
  468. }else{
  469. $result['info'] = "清除失败!";
  470. $result['status'] = 0;
  471. }
  472. admin_ajax_return($result);
  473. }
  474. public function weibo_index()
  475. {
  476. $common = new UserCommon();
  477. $data = $_REQUEST;
  478. // $data['is_authentication'] = array('in',array(0,1,3));
  479. $data['is_robot'] = 0;
  480. $common->index($data);
  481. }
  482. public function set_sort()
  483. {
  484. $id = intval($_REQUEST['id']);
  485. $sort = intval($_REQUEST['sort']);
  486. $log_info = M("User")->where("id=".$id)->getField("nick_name");
  487. if(!check_sort($sort))
  488. {
  489. $this->error(l("SORT_FAILED"),1);
  490. }
  491. M("User")->where("id=".$id)->setField("weibo_recommend_weight",$sort);
  492. save_log($log_info.l("SORT_SUCCESS"),1);
  493. $this->success(l("SORT_SUCCESS"),1);
  494. }
  495. public function game_rate()
  496. {
  497. if ($_POST) {
  498. $user_id = intval($_REQUEST['user_id']);
  499. $rate = intval($_REQUEST['rate']);
  500. if (!$user_id) {
  501. $this->ajax_return(array(
  502. 'status' => 0,
  503. 'error' => '参数错误',
  504. ));
  505. }
  506. if ($rate > 100 || $rate < 0) {
  507. $this->ajax_return(array(
  508. 'status' => 0,
  509. 'error' => '参数错误',
  510. ));
  511. }
  512. $where = array('id' => $user_id);
  513. $user_model = M('user');
  514. $res = $user_model->setField('rate', $rate, $where);
  515. if ($res) {
  516. fanwe_require(APP_ROOT_PATH . 'mapi/lib/redis/BaseRedisService.php');
  517. fanwe_require(APP_ROOT_PATH . 'mapi/lib/redis/UserRedisService.php');
  518. $user_redis = new UserRedisService();
  519. $user_redis->update_db($user_id, ['rate' => $rate]);
  520. $this->ajax_return(array(
  521. 'status' => 1,
  522. 'error' => '更新成功',
  523. ));
  524. }
  525. $this->ajax_return(array(
  526. 'status' => 0,
  527. 'error' => '更新失败',
  528. ));
  529. } else {
  530. $user_id = intval($_REQUEST['user_id']);
  531. $user_model = M('user');
  532. $user_info = $user_model->field(array('id', 'rate'))->find($user_id);
  533. $user_info['rate'] = +$user_info['rate'];
  534. $this->assign("user_info", $user_info);
  535. $this->display();
  536. }
  537. }
  538. protected function ajax_return($data)
  539. {
  540. header("Content-Type:text/html; charset=utf-8");
  541. echo (json_encode($data));
  542. exit;
  543. }
  544. public function game_distribution()
  545. {
  546. if ($_POST) {
  547. $user_id = intval($_REQUEST['user_id']);
  548. $game_distribution1 = intval($_REQUEST['game_distribution1']);
  549. $game_distribution2 = intval($_REQUEST['game_distribution2']);
  550. if (!$user_id) {
  551. $this->ajax_return(array(
  552. 'status' => 0,
  553. 'error' => '参数错误',
  554. ));
  555. }
  556. $where = array('id' => $user_id);
  557. $user_model = M('user');
  558. $res = $user_model->where($where)->save(['game_distribution1'=>$game_distribution1,'game_distribution2'=>$game_distribution2]);
  559. if ($res) {
  560. fanwe_require(APP_ROOT_PATH . 'mapi/lib/redis/BaseRedisService.php');
  561. fanwe_require(APP_ROOT_PATH . 'mapi/lib/redis/UserRedisService.php');
  562. $user_redis = new UserRedisService();
  563. $user_redis->update_db($user_id, ['game_distribution1'=>$game_distribution1,'game_distribution2'=>$game_distribution2]);
  564. $this->ajax_return(array(
  565. 'status' => 1,
  566. 'error' => '更新成功',
  567. ));
  568. }
  569. $this->ajax_return(array(
  570. 'status' => 0,
  571. 'error' => '更新失败',
  572. ));
  573. } else {
  574. $user_id = intval($_REQUEST['user_id']);
  575. $user_model = M('user');
  576. $user_info = $user_model->field(array('id', 'game_distribution1', 'game_distribution2'))->find($user_id);
  577. $user_info['game_distribution1'] = +$user_info['game_distribution1'];
  578. $user_info['game_distribution2'] = +$user_info['game_distribution2'];
  579. $this->assign("user_info", $user_info);
  580. $this->display();
  581. }
  582. }
  583. public function invitation_code()
  584. {
  585. $user_id = intval($_REQUEST['user_id']);
  586. $user_model = M('user');
  587. $user_info = $user_model->field(['invitation_code','create_time'])->find($user_id);
  588. if ($user_info['invitation_code']) {
  589. exit($user_info['invitation_code']);
  590. }
  591. $users = $user_model->field(['id','create_time'])->where(['invitation_code' => ''])->findAll();
  592. foreach ($users as $v) {
  593. $res = $user_model->save(['invitation_code' => substr(md5($v['id'] . ':' . $v['create_time']), -16),'id' => $v['id']]);
  594. }
  595. exit(substr(md5($user_id . ':' . $user_info['create_time']), -16));
  596. }
  597. public function game_distribution_detail()
  598. {
  599. $user_id = intval($_REQUEST['user_id']);
  600. if ($_REQUEST['type']) {
  601. $model = M('game_distribution');
  602. $table = DB_PREFIX . 'user u,' . DB_PREFIX . 'game_distribution gd';
  603. $field = "u.id,u.nick_name,u.head_image,sum(gd.first_distreibution_money * (gd.first_distreibution_id = {$user_id}) + gd.second_distreibution_money * (gd.second_distreibution_id = {$user_id})) as `sum`,gd.is_ticket";
  604. $where = "(gd.first_distreibution_id = $user_id or gd.second_distreibution_id = $user_id) and u.id = gd.user_id";
  605. $group = 'u.id,gd.is_ticket';
  606. $list = $model->table($table)->field($field)->where($where)->group($group)->findAll();
  607. $this->assign("list", $list);
  608. } else {
  609. $map = [
  610. 'user_id' => $user_id,
  611. ];
  612. $model = M('game_distribution');
  613. if (!empty($model)) {
  614. $this->_list($model, $map);
  615. }
  616. }
  617. $this->assign("user_id", $user_id);
  618. $this->display();
  619. }
  620. //禁游戏
  621. public function forbid_game(){
  622. $id= intval($_REQUEST['user_id']);
  623. $open_game =$GLOBALS['db']->getRow("select open_game from ".DB_PREFIX."user where id =".$id);
  624. $where = 'id='.$id;
  625. require_once APP_ROOT_PATH.'mapi/lib/redis/BaseRedisService.php';
  626. require_once APP_ROOT_PATH.'mapi/lib/redis/UserRedisService.php';
  627. $user_redis = new UserRedisService();
  628. $data['open_game'] = 1;
  629. $info = '';
  630. if($open_game['open_game']==1) {
  631. $data['open_game'] = 0;
  632. $info = '取消';
  633. }
  634. $list = $GLOBALS['db']->autoExecute(DB_PREFIX."user",$data,'UPDATE',$where);
  635. if ($list!==false) {
  636. $user_redis->update_db($id, $data);
  637. $this->success ($info.'禁游戏成功',1);
  638. }else{
  639. $this->error ($info.'禁游戏成功',1);
  640. }
  641. }
  642. //禁付费
  643. public function forbid_pay(){
  644. $id= intval($_REQUEST['user_id']);
  645. $open_game =$GLOBALS['db']->getRow("select open_pay from ".DB_PREFIX."user where id =".$id);
  646. $where = 'id='.$id;
  647. require_once APP_ROOT_PATH.'mapi/lib/redis/BaseRedisService.php';
  648. require_once APP_ROOT_PATH.'mapi/lib/redis/UserRedisService.php';
  649. $user_redis = new UserRedisService();
  650. $data['open_pay'] = 1;
  651. $info = '';
  652. if($open_game['open_pay']==1) {
  653. $data['open_pay'] = 0;
  654. $info = '取消';
  655. }
  656. $list = $GLOBALS['db']->autoExecute(DB_PREFIX."user",$data,'UPDATE',$where);
  657. if ($list!==false) {
  658. $user_redis->update_db($id, $data);
  659. $this->success ($info.'禁付费成功',1);
  660. }else{
  661. $this->error ($info.'禁付费成功',1);
  662. }
  663. }
  664. //禁竞拍
  665. public function forbid_auction(){
  666. $id= intval($_REQUEST['user_id']);
  667. $open_game =$GLOBALS['db']->getRow("select open_auction from ".DB_PREFIX."user where id =".$id);
  668. $where = 'id='.$id;
  669. require_once APP_ROOT_PATH.'mapi/lib/redis/BaseRedisService.php';
  670. require_once APP_ROOT_PATH.'mapi/lib/redis/UserRedisService.php';
  671. $user_redis = new UserRedisService();
  672. $data['open_auction'] = 1;
  673. $info = '';
  674. if($open_game['open_auction']==1) {
  675. $data['open_auction'] = 0;
  676. $info = '取消';
  677. }
  678. $list = $GLOBALS['db']->autoExecute(DB_PREFIX."user",$data,'UPDATE',$where);
  679. if ($list!==false) {
  680. $user_redis->update_db($id, $data);
  681. $this->success ($info.'禁竞拍成功',1);
  682. }else{
  683. $this->error ($info.'禁竞拍成功',1);
  684. }
  685. }
  686. }
  687. ?>