BmUserGeneralAction.class.php 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852
  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 BmUserGeneralAction extends CommonAction{
  10. public function __construct()
  11. {
  12. parent::__construct();
  13. require_once APP_ROOT_PATH."/admin/Lib/Action/BmUserCommonAction.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. admin_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,l.is_coin
  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_".$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,l.is_coin
  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. $table = DB_PREFIX . 'video_prop_'.to_date($time,'Ym');
  324. $result = $GLOBALS['db']->getRow("SHOW TABLES LIKE'$table'");
  325. if($result){
  326. $count = $GLOBALS['db']->getOne($count_sql);
  327. $total_ticket = $GLOBALS['db']->getOne($total_ticket_sql);
  328. } else {
  329. $count = 0;
  330. $total_ticket = 0;
  331. }
  332. $volist = $this->_Sql_list($model,$sql_str,'&'.$parameter,1,0,$count_sql);
  333. foreach($volist as $k=>$v){
  334. if($volist[$k]['prop_id']==12){
  335. $volist[$k]['total_ticket']='';
  336. }
  337. $volist[$k]['create_time']=date('Y-m-d',$volist[$k]['create_time']);
  338. }
  339. $this->assign("user_info",$user_info);
  340. $this->assign("prop",$prop_list);
  341. $this->assign("years",$years);
  342. $this->assign("month",$month);
  343. $this->assign("list", $volist);
  344. $this->assign("count",intval($count));
  345. $this->assign('total_ticket',intval($total_ticket));
  346. $this->display ();
  347. }
  348. //分享奖励
  349. public function distribution_log(){
  350. $common = new UserCommon();
  351. $data = $_REQUEST;
  352. $common->distribution_log($data);
  353. }
  354. //分销子成员奖励
  355. public function distribution_user(){
  356. $common = new UserCommon();
  357. $data = $_REQUEST;
  358. $common->distribution_user($data);
  359. }
  360. //删除礼物日志
  361. public function delete_prop()
  362. {
  363. //彻底删除指定记录
  364. $ajax = intval($_REQUEST['ajax']);
  365. $id = intval($_REQUEST ['id']);
  366. $data = $_REQUEST;
  367. if (isset ( $id )) {
  368. $common = new UserCommon();
  369. $status = $common->del_prop($data);
  370. if ($status!==false) {
  371. $this->success (l("FOREVER_DELETE_SUCCESS"),$ajax);
  372. } else {
  373. $this->error (l("FOREVER_DELETE_FAILED"),$ajax);
  374. }
  375. } else {
  376. $this->error (l("INVALID_OPERATION"),$ajax);
  377. }
  378. }
  379. public function forbid_msg(){
  380. $common = new UserCommon();
  381. $data = $_REQUEST;
  382. $common->forbid_msg($data);
  383. }
  384. //商品管理
  385. public function goods(){
  386. $user_id = intval($_REQUEST['user_id']);
  387. if(strim($_REQUEST['name'])!=''){
  388. $map['name'] = array('like','%'.strim($_REQUEST['name']).'%');
  389. }
  390. $map['is_effect'] = 1;
  391. $model = D ('goods');
  392. if (! empty ( $model )) {
  393. $this->_list ( $model, $map );
  394. }
  395. $list = $this->get('list');
  396. $user_list = $GLOBALS['db']->getAll("select goods_id from ".DB_PREFIX."user_goods where is_effect=1 and user_id=".$user_id);
  397. foreach($list as $k => $v){
  398. $imgs=array();
  399. $imgs_details=array();
  400. $imgs=json_decode($v['imgs'],1);
  401. $imgs_details=json_decode($v['imgs_details'],1);
  402. $list[$k]['imgs'] = $imgs[0];
  403. $list[$k]['imgs_details'] = $imgs_details[0];
  404. $list[$k]['has']= '否';
  405. foreach($user_list as $value1){
  406. if($v['id'] == $value1['goods_id']){
  407. $list[$k]['has'] = '是';
  408. break;
  409. }
  410. }
  411. }
  412. $sort = array_column($list, 'has');
  413. array_multisort($sort, SORT_DESC, $list);
  414. $this->assign("list",$list);
  415. $this->display();
  416. }
  417. //上架商品
  418. public function shelves(){
  419. $ajax = intval($_REQUEST['ajax']);
  420. $goods_id = intval($_REQUEST ['id']);
  421. $user_id = intval($_REQUEST ['user_id']);
  422. if (isset($goods_id)) {
  423. $where['goods_id'] = $goods_id;
  424. $where['user_id'] = $user_id;
  425. $user_goods = M('user_goods')->where($where)->select();
  426. $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);
  427. if($user_goods){
  428. $list = M('user_goods')->where($where)->save($goods_info);
  429. }else{
  430. $data = array_merge($where,$goods_info);
  431. $list = M('user_goods')->add($data);
  432. }
  433. if ($list!==false) {
  434. $result['info'] = "上架成功!";
  435. $result['status'] = 1;
  436. } else {
  437. $result['info'] = "上架失败!";
  438. $result['status'] = 0;
  439. }
  440. $this->ajax_return($result);
  441. } else {
  442. $this->error (l("INVALID_OPERATION"),$ajax);
  443. }
  444. }
  445. //下架商品
  446. public function sold(){
  447. $ajax = intval($_REQUEST['ajax']);
  448. $goods_id = intval($_REQUEST ['id']);
  449. $user_id = intval($_REQUEST ['user_id']);
  450. if (isset($goods_id)) {
  451. $condition['goods_id'] = $goods_id;
  452. $condition['user_id'] = $user_id;
  453. $user_goods = M('user_goods')->where($condition)->select();
  454. if($user_goods){
  455. $list = M('user_goods')->where($condition)->delete();
  456. }
  457. if ($list!==false) {
  458. $result['info'] = "下架成功!";
  459. $result['status'] = 1;
  460. } else {
  461. $result['info'] = "下架失败!";
  462. $result['status'] = 0;
  463. }
  464. $this->ajax_return($result);
  465. } else {
  466. $this->error (l("INVALID_OPERATION"),$ajax);
  467. }
  468. }
  469. public function clear_view_count(){
  470. $sql = "update ".DB_PREFIX."user set view_count = 0";
  471. $res = $GLOBALS['db']->query($sql);
  472. if($res){
  473. $result['info'] = "清除成功!";
  474. $result['status'] = 1;
  475. }else{
  476. $result['info'] = "清除失败!";
  477. $result['status'] = 0;
  478. }
  479. admin_ajax_return($result);
  480. }
  481. public function weibo_index()
  482. {
  483. $common = new UserCommon();
  484. $data = $_REQUEST;
  485. // $data['is_authentication'] = array('in',array(0,1,3));
  486. $data['is_robot'] = 0;
  487. $common->index($data);
  488. }
  489. public function set_sort()
  490. {
  491. $id = intval($_REQUEST['id']);
  492. $sort = intval($_REQUEST['sort']);
  493. $log_info = M("User")->where("id=".$id)->getField("nick_name");
  494. if(!check_sort($sort))
  495. {
  496. $this->error(l("SORT_FAILED"),1);
  497. }
  498. M("User")->where("id=".$id)->setField("weibo_recommend_weight",$sort);
  499. save_log($log_info.l("SORT_SUCCESS"),1);
  500. $this->success(l("SORT_SUCCESS"),1);
  501. }
  502. public function weixin_distribution()
  503. {
  504. $user_id = intval($_REQUEST['user_id']);
  505. if (!$user_id) {
  506. $this->ajax_return(array(
  507. 'status' => 0,
  508. 'error' => '参数错误',
  509. ));
  510. }
  511. $model = M('weixin_distribution');
  512. if ($_POST) {
  513. $is_top = intval($_REQUEST['is_top']);
  514. $first_rate = intval($_REQUEST['first_rate']);
  515. $second_rate = intval($_REQUEST['second_rate']);
  516. if ($first_rate > 100 || $first_rate < 0) {
  517. $this->ajax_return(array(
  518. 'status' => 0,
  519. 'error' => '一级分成比例错误',
  520. ));
  521. }
  522. if ($second_rate > 100 || $second_rate < 0) {
  523. $this->ajax_return(array(
  524. 'status' => 0,
  525. 'error' => '二级分成比例错误',
  526. ));
  527. }
  528. $data = compact('first_rate','second_rate','user_id');
  529. if ($is_top) {
  530. $data['pid'] = 0;
  531. $data['topid'] = $user_id;
  532. }
  533. $where = array('user_id' => $user_id);
  534. $res = $model->where($where)->find();
  535. if ($res) {
  536. $res = $model->save($data);
  537. } else {
  538. $data['create_time'] = NOW_TIME;
  539. $res = $model->add($data);
  540. }
  541. if ($res) {
  542. $this->ajax_return(array(
  543. 'status' => 1,
  544. 'error' => '更新成功',
  545. ));
  546. }
  547. $this->ajax_return(array(
  548. 'status' => 0,
  549. 'error' => '更新失败',
  550. ));
  551. } else {
  552. $user_info = $model->where(['user_id'=>$user_id])->find();
  553. $user_info['user_id'] = $user_id;
  554. $user_info['pid'] = intval($user_info['pid']);
  555. $this->assign("user_info", $user_info);
  556. $this->display();
  557. }
  558. }
  559. public function game_rate()
  560. {
  561. if ($_POST) {
  562. $user_id = intval($_REQUEST['user_id']);
  563. $rate = intval($_REQUEST['rate']);
  564. if (!$user_id) {
  565. $this->ajax_return(array(
  566. 'status' => 0,
  567. 'error' => '参数错误',
  568. ));
  569. }
  570. if ($rate > 100 || $rate < 0) {
  571. $this->ajax_return(array(
  572. 'status' => 0,
  573. 'error' => '参数错误',
  574. ));
  575. }
  576. $where = array('id' => $user_id);
  577. $user_model = M('user');
  578. $res = $user_model->setField('rate', $rate, $where);
  579. if ($res) {
  580. fanwe_require(APP_ROOT_PATH . 'mapi/lib/redis/BaseRedisService.php');
  581. fanwe_require(APP_ROOT_PATH . 'mapi/lib/redis/UserRedisService.php');
  582. $user_redis = new UserRedisService();
  583. $user_redis->update_db($user_id, ['rate' => $rate]);
  584. $this->ajax_return(array(
  585. 'status' => 1,
  586. 'error' => '更新成功',
  587. ));
  588. }
  589. $this->ajax_return(array(
  590. 'status' => 0,
  591. 'error' => '更新失败',
  592. ));
  593. } else {
  594. $user_id = intval($_REQUEST['user_id']);
  595. $user_model = M('user');
  596. $user_info = $user_model->field(array('id', 'rate'))->find($user_id);
  597. $user_info['rate'] = +$user_info['rate'];
  598. $this->assign("user_info", $user_info);
  599. $this->display();
  600. }
  601. }
  602. protected function ajax_return($data)
  603. {
  604. header("Content-Type:text/html; charset=utf-8");
  605. echo (json_encode($data));
  606. exit;
  607. }
  608. public function game_distribution()
  609. {
  610. if ($_POST) {
  611. $user_id = intval($_REQUEST['user_id']);
  612. $game_distribution1 = intval($_REQUEST['game_distribution1']);
  613. $game_distribution2 = intval($_REQUEST['game_distribution2']);
  614. if (!$user_id) {
  615. $this->ajax_return(array(
  616. 'status' => 0,
  617. 'error' => '参数错误',
  618. ));
  619. }
  620. $where = array('id' => $user_id);
  621. $user_model = M('user');
  622. $data = ['game_distribution1'=>$game_distribution1,'game_distribution2'=>$game_distribution2];
  623. if (defined('GAME_DISTRIBUTION_TOP') && GAME_DISTRIBUTION_TOP && $_REQUEST['is_top']) {
  624. $data['game_distribution_top_id'] = $user_id;
  625. }
  626. $res = $user_model->where($where)->save($data);
  627. if ($res) {
  628. fanwe_require(APP_ROOT_PATH . 'mapi/lib/redis/BaseRedisService.php');
  629. fanwe_require(APP_ROOT_PATH . 'mapi/lib/redis/UserRedisService.php');
  630. $user_redis = new UserRedisService();
  631. $user_redis->update_db($user_id, $data);
  632. $this->ajax_return(array(
  633. 'status' => 1,
  634. 'error' => '更新成功',
  635. ));
  636. }
  637. $this->ajax_return(array(
  638. 'status' => 0,
  639. 'error' => '更新失败',
  640. ));
  641. } else {
  642. $user_id = intval($_REQUEST['user_id']);
  643. $user_model = M('user');
  644. $user_info = $user_model->field(array('id', 'game_distribution1', 'game_distribution2'))->find($user_id);
  645. $user_info['game_distribution1'] = +$user_info['game_distribution1'];
  646. $user_info['game_distribution2'] = +$user_info['game_distribution2'];
  647. $this->assign("user_info", $user_info);
  648. $this->display();
  649. }
  650. }
  651. public function invitation_code()
  652. {
  653. $user_id = intval($_REQUEST['user_id']);
  654. $user_model = M('user');
  655. $user_info = $user_model->field(['invitation_code','create_time'])->find($user_id);
  656. if ($user_info['invitation_code']) {
  657. exit($user_info['invitation_code']);
  658. }
  659. $users = $user_model->field(['id','create_time'])->where(['invitation_code' => ''])->findAll();
  660. foreach ($users as $v) {
  661. $res = $user_model->save(['invitation_code' => substr(md5($v['id'] . ':' . $v['create_time']), -16),'id' => $v['id']]);
  662. }
  663. exit(substr(md5($user_id . ':' . $user_info['create_time']), -16));
  664. }
  665. public function game_distribution_detail()
  666. {
  667. $user_id = intval($_REQUEST['user_id']);
  668. if ($_REQUEST['type']) {
  669. $model = M('game_distribution');
  670. $table = DB_PREFIX . 'user u,' . DB_PREFIX . 'game_distribution gd';
  671. $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";
  672. $where = "(gd.first_distreibution_id = $user_id or gd.second_distreibution_id = $user_id) and u.id = gd.user_id";
  673. $group = 'u.id,gd.is_ticket';
  674. $list = $model->table($table)->field($field)->where($where)->group($group)->findAll();
  675. $this->assign("list", $list);
  676. } else {
  677. $map = [
  678. 'user_id' => $user_id,
  679. ];
  680. $model = M('game_distribution');
  681. if (!empty($model)) {
  682. $this->_list($model, $map);
  683. }
  684. }
  685. $this->assign("user_id", $user_id);
  686. $this->display();
  687. }
  688. //禁游戏
  689. public function forbid_game(){
  690. $id= intval($_REQUEST['user_id']);
  691. $open_game =$GLOBALS['db']->getRow("select open_game from ".DB_PREFIX."user where id =".$id);
  692. $where = 'id='.$id;
  693. require_once APP_ROOT_PATH.'mapi/lib/redis/BaseRedisService.php';
  694. require_once APP_ROOT_PATH.'mapi/lib/redis/UserRedisService.php';
  695. $user_redis = new UserRedisService();
  696. $data['open_game'] = 1;
  697. $info = '';
  698. if($open_game['open_game']==1) {
  699. $data['open_game'] = 0;
  700. $info = '取消';
  701. }
  702. $list = $GLOBALS['db']->autoExecute(DB_PREFIX."user",$data,'UPDATE',$where);
  703. if ($list!==false) {
  704. $user_redis->update_db($id, $data);
  705. $this->success ($info.'禁游戏成功',1);
  706. }else{
  707. $this->error ($info.'禁游戏成功',1);
  708. }
  709. }
  710. //禁付费
  711. public function forbid_pay(){
  712. $id= intval($_REQUEST['user_id']);
  713. $open_game =$GLOBALS['db']->getRow("select open_pay from ".DB_PREFIX."user where id =".$id);
  714. $where = 'id='.$id;
  715. require_once APP_ROOT_PATH.'mapi/lib/redis/BaseRedisService.php';
  716. require_once APP_ROOT_PATH.'mapi/lib/redis/UserRedisService.php';
  717. $user_redis = new UserRedisService();
  718. $data['open_pay'] = 1;
  719. $info = '';
  720. if($open_game['open_pay']==1) {
  721. $data['open_pay'] = 0;
  722. $info = '取消';
  723. }
  724. $list = $GLOBALS['db']->autoExecute(DB_PREFIX."user",$data,'UPDATE',$where);
  725. if ($list!==false) {
  726. $user_redis->update_db($id, $data);
  727. $this->success ($info.'禁付费成功',1);
  728. }else{
  729. $this->error ($info.'禁付费成功',1);
  730. }
  731. }
  732. //禁竞拍
  733. public function forbid_auction(){
  734. $id= intval($_REQUEST['user_id']);
  735. $open_game =$GLOBALS['db']->getRow("select open_auction from ".DB_PREFIX."user where id =".$id);
  736. $where = 'id='.$id;
  737. require_once APP_ROOT_PATH.'mapi/lib/redis/BaseRedisService.php';
  738. require_once APP_ROOT_PATH.'mapi/lib/redis/UserRedisService.php';
  739. $user_redis = new UserRedisService();
  740. $data['open_auction'] = 1;
  741. $info = '';
  742. if($open_game['open_auction']==1) {
  743. $data['open_auction'] = 0;
  744. $info = '取消';
  745. }
  746. $list = $GLOBALS['db']->autoExecute(DB_PREFIX."user",$data,'UPDATE',$where);
  747. if ($list!==false) {
  748. $user_redis->update_db($id, $data);
  749. $this->success ($info.'禁竞拍成功',1);
  750. }else{
  751. $this->error ($info.'禁竞拍成功',1);
  752. }
  753. }
  754. //设置机器人送礼物特权
  755. public function roboter()
  756. {
  757. $id = intval($_REQUEST['id']);
  758. $c_is_roboter = M("User")->where("id=".$id)->getField("roboter"); //当前状态
  759. $n_is_roboter = $c_is_roboter == 0 ? 1 : 0; //需设置的状态
  760. $result=M("User")->where("id=".$id)->setField("roboter",$n_is_roboter);
  761. $user_data = array();
  762. if($result){
  763. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/BaseRedisService.php');
  764. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/UserRedisService.php');
  765. $user_redis = new UserRedisService();
  766. $user_data['roboter'] = $n_is_roboter;
  767. $user_redis->update_db($id,$user_data);
  768. }
  769. $this->ajaxReturn($n_is_roboter,l("roboter_".$n_is_roboter),1);
  770. }
  771. }
  772. ?>