UserGeneralAction.class.php 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895
  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 UserGeneralAction 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. 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. $user_info['nick_name'] = emoji_decode($user_info['nick_name']);
  250. $prop_list = M("prop")->where("is_effect <>0")->findAll();
  251. $where = "l.to_user_id=".$user_id ;
  252. $model = D ("video_prop");
  253. //赠送时间
  254. $current_Year = date('Y');
  255. $current_YM = date('Ym');
  256. for ($i=0; $i<5; $i++)
  257. {
  258. $years[$i] = $current_Year - $i;
  259. }
  260. for ($i=01; $i<13; $i++)
  261. {
  262. $month[$i] = str_pad(0+$i,2,0,STR_PAD_LEFT);
  263. }
  264. if(strim($data['years'])!=-1&&strim($data['month']!=-1)){
  265. $time=$data['years'].''.$data['month'];
  266. }else{
  267. $time=$current_YM;
  268. }
  269. if(strim($data['years'])!=-1&&strim($data['month']==-1)){
  270. $this->error("请选择月份");
  271. }
  272. if(strim($data['years'])==-1&&strim($data['month']!=-1)){
  273. $this->error("请选择年份");
  274. }
  275. //查询ID
  276. if(strim($data['from_user_id'])!=''){
  277. $parameter.= "l.from_user_id=".intval($data['from_user_id']). "&";
  278. $sql_w .= "l.from_user_id=".intval($data['from_user_id'])." and ";
  279. }
  280. //查询昵称
  281. if(trim($data['nick_name'])!='')
  282. {
  283. $parameter.= "u.nick_name like " . urlencode ( '%'.trim($data['nick_name']).'%' ) . "&";
  284. $sql_w .= "u.nick_name like '%".trim($data['nick_name'])."%' and ";
  285. }
  286. if (!isset($_REQUEST['prop_id'])) {
  287. $_REQUEST['prop_id'] = -1;
  288. }
  289. //查询礼物
  290. if($_REQUEST['prop_id']!=-1) {
  291. if (isset($data['prop_id'])) {
  292. $parameter .= "l.prop_id=" . intval($data['prop_id']) . "&";
  293. $sql_w .= "l.prop_id=" . intval($data['prop_id']) . " and ";
  294. }
  295. }
  296. //默认查询本月的记录,选择查询时间时,如果查询时间 不等于当前时间,则查询他表
  297. if($data['years']!=''&&$data['month']!=''){
  298. $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
  299. FROM ".DB_PREFIX."video_prop_".$time." as l
  300. 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" ."
  301. WHERE $where "." and ".$sql_w." 1=1 group by id";
  302. $count_sql = "SELECT count(l.id) as tpcount
  303. FROM ".DB_PREFIX."video_prop_".$time." as l
  304. 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" ."
  305. WHERE $where "." and ".$sql_w." 1=1 ";
  306. $total_ticket_sql = "SELECT SUM(l.total_ticket) as tpcount
  307. FROM ".DB_PREFIX."video_prop_".$time." as l
  308. 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" ."
  309. WHERE $where "." and ".$sql_w." 1=1 ";
  310. $table = DB_PREFIX . 'video_prop_'.$time;
  311. }else{
  312. $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
  313. FROM ".DB_PREFIX."video_prop_".date('Ym',NOW_TIME)." as l
  314. 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" ."
  315. WHERE $where "." and ".$sql_w." 1=1 group by id";
  316. $count_sql = "SELECT count(l.id) as tpcount
  317. FROM ".DB_PREFIX."video_prop_".date('Ym',NOW_TIME)." as l
  318. 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" ."
  319. WHERE $where "." and ".$sql_w." 1=1 ";
  320. $total_ticket_sql = "SELECT SUM(l.total_ticket) as tpcount
  321. FROM ".DB_PREFIX."video_prop_".date('Ym',NOW_TIME)." as l
  322. 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" ."
  323. WHERE $where "." and ".$sql_w." 1=1 ";
  324. $table = DB_PREFIX . 'video_prop_'.date('Ym',NOW_TIME);
  325. }
  326. $result = $GLOBALS['db']->getRow("SHOW TABLES LIKE'$table'");
  327. if($result){
  328. $count = $GLOBALS['db']->getOne($count_sql);
  329. $total_ticket = $GLOBALS['db']->getOne($total_ticket_sql);
  330. } else {
  331. $count = 0;
  332. $total_ticket = 0;
  333. }
  334. $volist = $this->_Sql_list($model,$sql_str,'&'.$parameter,1,0,$count_sql);
  335. foreach($volist as $k=>$v){
  336. if($volist[$k]['prop_id']==12){
  337. $volist[$k]['total_ticket']='';
  338. }
  339. $volist[$k]['create_time']=date('Y-m-d',$volist[$k]['create_time']);
  340. $volist[$k]['nick_name'] = emoji_decode($volist[$k]['nick_name']);
  341. }
  342. $this->assign("user_info",$user_info);
  343. $this->assign("prop",$prop_list);
  344. $this->assign("years",$years);
  345. $this->assign("month",$month);
  346. $this->assign("list", $volist);
  347. $this->assign("count",intval($count));
  348. $this->assign('total_ticket',intval($total_ticket));
  349. $this->display ();
  350. }
  351. //分享奖励
  352. public function distribution_log(){
  353. $common = new UserCommon();
  354. $data = $_REQUEST;
  355. $common->distribution_log($data);
  356. }
  357. //分销子成员奖励
  358. public function distribution_user(){
  359. $common = new UserCommon();
  360. $data = $_REQUEST;
  361. $common->distribution_user($data);
  362. }
  363. //删除礼物日志
  364. public function delete_prop()
  365. {
  366. //彻底删除指定记录
  367. $ajax = intval($_REQUEST['ajax']);
  368. $id = intval($_REQUEST ['id']);
  369. $data = $_REQUEST;
  370. if (isset ( $id )) {
  371. $common = new UserCommon();
  372. $status = $common->del_prop($data);
  373. if ($status!==false) {
  374. $this->success (l("FOREVER_DELETE_SUCCESS"),$ajax);
  375. } else {
  376. $this->error (l("FOREVER_DELETE_FAILED"),$ajax);
  377. }
  378. } else {
  379. $this->error (l("INVALID_OPERATION"),$ajax);
  380. }
  381. }
  382. public function forbid_msg(){
  383. $common = new UserCommon();
  384. $data = $_REQUEST;
  385. $common->forbid_msg($data);
  386. }
  387. //商品管理
  388. public function goods(){
  389. $user_id = intval($_REQUEST['user_id']);
  390. if(strim($_REQUEST['name'])!=''){
  391. $map['name'] = array('like','%'.strim($_REQUEST['name']).'%');
  392. }
  393. $map['is_effect'] = 1;
  394. $model = D ('goods');
  395. if (! empty ( $model )) {
  396. $this->_list ( $model, $map );
  397. }
  398. $list = $this->get('list');
  399. $user_list = $GLOBALS['db']->getAll("select goods_id from ".DB_PREFIX."user_goods where is_effect=1 and user_id=".$user_id);
  400. foreach($list as $k => $v){
  401. $imgs=array();
  402. $imgs_details=array();
  403. $imgs=json_decode($v['imgs'],1);
  404. $imgs_details=json_decode($v['imgs_details'],1);
  405. $list[$k]['imgs'] = $imgs[0];
  406. $list[$k]['imgs_details'] = $imgs_details[0];
  407. $list[$k]['has']= '否';
  408. foreach($user_list as $value1){
  409. if($v['id'] == $value1['goods_id']){
  410. $list[$k]['has'] = '是';
  411. break;
  412. }
  413. }
  414. }
  415. $sort = array_column($list, 'has');
  416. array_multisort($sort, SORT_DESC, $list);
  417. $this->assign("list",$list);
  418. $this->display();
  419. }
  420. //上架商品
  421. public function shelves(){
  422. $ajax = intval($_REQUEST['ajax']);
  423. $goods_id = intval($_REQUEST ['id']);
  424. $user_id = intval($_REQUEST ['user_id']);
  425. if (isset($goods_id)) {
  426. $where['goods_id'] = $goods_id;
  427. $where['user_id'] = $user_id;
  428. $user_goods = M('user_goods')->where($where)->select();
  429. $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);
  430. if($user_goods){
  431. $list = M('user_goods')->where($where)->save($goods_info);
  432. }else{
  433. $data = array_merge($where,$goods_info);
  434. $list = M('user_goods')->add($data);
  435. }
  436. if ($list!==false) {
  437. $result['info'] = "上架成功!";
  438. $result['status'] = 1;
  439. } else {
  440. $result['info'] = "上架失败!";
  441. $result['status'] = 0;
  442. }
  443. $this->ajax_return($result);
  444. } else {
  445. $this->error (l("INVALID_OPERATION"),$ajax);
  446. }
  447. }
  448. //下架商品
  449. public function sold(){
  450. $ajax = intval($_REQUEST['ajax']);
  451. $goods_id = intval($_REQUEST ['id']);
  452. $user_id = intval($_REQUEST ['user_id']);
  453. if (isset($goods_id)) {
  454. $condition['goods_id'] = $goods_id;
  455. $condition['user_id'] = $user_id;
  456. $user_goods = M('user_goods')->where($condition)->select();
  457. if($user_goods){
  458. $list = M('user_goods')->where($condition)->delete();
  459. }
  460. if ($list!==false) {
  461. $result['info'] = "下架成功!";
  462. $result['status'] = 1;
  463. } else {
  464. $result['info'] = "下架失败!";
  465. $result['status'] = 0;
  466. }
  467. $this->ajax_return($result);
  468. } else {
  469. $this->error (l("INVALID_OPERATION"),$ajax);
  470. }
  471. }
  472. public function clear_view_count(){
  473. $sql = "update ".DB_PREFIX."user set view_count = 0";
  474. $res = $GLOBALS['db']->query($sql);
  475. if($res){
  476. $result['info'] = "清除成功!";
  477. $result['status'] = 1;
  478. }else{
  479. $result['info'] = "清除失败!";
  480. $result['status'] = 0;
  481. }
  482. admin_ajax_return($result);
  483. }
  484. public function weibo_index()
  485. {
  486. $common = new UserCommon();
  487. $data = $_REQUEST;
  488. // $data['is_authentication'] = array('in',array(0,1,3));
  489. $data['is_robot'] = 0;
  490. $common->index($data);
  491. }
  492. public function set_sort()
  493. {
  494. $id = intval($_REQUEST['id']);
  495. $sort = intval($_REQUEST['sort']);
  496. $log_info = M("User")->where("id=".$id)->getField("nick_name");
  497. if(!check_sort($sort))
  498. {
  499. $this->error(l("SORT_FAILED"),1);
  500. }
  501. M("User")->where("id=".$id)->setField("weibo_recommend_weight",$sort);
  502. save_log($log_info.l("SORT_SUCCESS"),1);
  503. $this->success(l("SORT_SUCCESS"),1);
  504. }
  505. public function weixin_distribution()
  506. {
  507. $user_id = intval($_REQUEST['user_id']);
  508. if (!$user_id) {
  509. $this->ajax_return(array(
  510. 'status' => 0,
  511. 'error' => '参数错误',
  512. ));
  513. }
  514. $model = M('weixin_distribution');
  515. if ($_POST) {
  516. $is_top = intval($_REQUEST['is_top']);
  517. $pid = intval($_REQUEST['pid']);
  518. $first_rate = intval($_REQUEST['first_rate']);
  519. $second_rate = intval($_REQUEST['second_rate']);
  520. if ($first_rate > 100 || $first_rate < 0) {
  521. $this->ajax_return(array(
  522. 'status' => 0,
  523. 'error' => '一级分成比例错误',
  524. ));
  525. }
  526. if ($second_rate > 100 || $second_rate < 0) {
  527. $this->ajax_return(array(
  528. 'status' => 0,
  529. 'error' => '二级分成比例错误',
  530. ));
  531. }
  532. $data = compact('first_rate','second_rate','user_id');
  533. $where = array('user_id' => $user_id);
  534. $res = $model->where($where)->find();
  535. if ($is_top) {
  536. $data['pid'] = 0;
  537. $data['topid'] = $user_id;
  538. } else {
  539. if ($res['topid']) {
  540. if ($pid != $res['pid']) {
  541. $this->ajax_return(array(
  542. 'status' => 0,
  543. 'error' => '该用户已绑定上级或成为顶级用户,不可修改绑定。',
  544. ));
  545. }
  546. } else {
  547. if (!$pid) {
  548. $this->ajax_return(array(
  549. 'status' => 0,
  550. 'error' => '该用户未参与分销',
  551. ));
  552. }
  553. $p = $model->where(['user_id'=>$pid])->find();
  554. if (!$p['topid']) {
  555. $this->ajax_return(array(
  556. 'status' => 0,
  557. 'error' => '上级用户未参与分销',
  558. ));
  559. }
  560. $data['pid'] = $pid;
  561. $data['topid'] = $p['topid'];
  562. }
  563. }
  564. if ($res) {
  565. $res = $model->save($data);
  566. } else {
  567. $data['create_time'] = NOW_TIME;
  568. $res = $model->add($data);
  569. }
  570. if ($res) {
  571. $this->ajax_return(array(
  572. 'status' => 1,
  573. 'error' => '更新成功',
  574. ));
  575. }
  576. $this->ajax_return(array(
  577. 'status' => 0,
  578. 'error' => '更新失败',
  579. ));
  580. } else {
  581. $user_info = $model->where(['user_id'=>$user_id])->find();
  582. $user_info['user_id'] = $user_id;
  583. $user_info['pid'] = intval($user_info['pid']);
  584. $this->assign("user_info", $user_info);
  585. $this->display();
  586. }
  587. }
  588. public function game_rate()
  589. {
  590. if ($_POST) {
  591. $user_id = intval($_REQUEST['user_id']);
  592. $rate = intval($_REQUEST['rate']);
  593. if (!$user_id) {
  594. $this->ajax_return(array(
  595. 'status' => 0,
  596. 'error' => '参数错误',
  597. ));
  598. }
  599. if ($rate > 100 || $rate < 0) {
  600. $this->ajax_return(array(
  601. 'status' => 0,
  602. 'error' => '参数错误',
  603. ));
  604. }
  605. $where = array('id' => $user_id);
  606. $user_model = M('user');
  607. $res = $user_model->setField('rate', $rate, $where);
  608. if ($res) {
  609. fanwe_require(APP_ROOT_PATH . 'mapi/lib/redis/BaseRedisService.php');
  610. fanwe_require(APP_ROOT_PATH . 'mapi/lib/redis/UserRedisService.php');
  611. $user_redis = new UserRedisService();
  612. $user_redis->update_db($user_id, ['rate' => $rate]);
  613. $this->ajax_return(array(
  614. 'status' => 1,
  615. 'error' => '更新成功',
  616. ));
  617. }
  618. $this->ajax_return(array(
  619. 'status' => 0,
  620. 'error' => '更新失败',
  621. ));
  622. } else {
  623. $user_id = intval($_REQUEST['user_id']);
  624. $user_model = M('user');
  625. $user_info = $user_model->field(array('id', 'rate'))->find($user_id);
  626. $user_info['rate'] = +$user_info['rate'];
  627. $this->assign("user_info", $user_info);
  628. $this->display();
  629. }
  630. }
  631. protected function ajax_return($data)
  632. {
  633. header("Content-Type:text/html; charset=utf-8");
  634. echo (json_encode($data));
  635. exit;
  636. }
  637. public function game_distribution()
  638. {
  639. if ($_POST) {
  640. $user_id = intval($_REQUEST['user_id']);
  641. $game_distribution1 = intval($_REQUEST['game_distribution1']);
  642. $game_distribution2 = intval($_REQUEST['game_distribution2']);
  643. if (!$user_id) {
  644. $this->ajax_return(array(
  645. 'status' => 0,
  646. 'error' => '参数错误',
  647. ));
  648. }
  649. $where = array('id' => $user_id);
  650. $user_model = M('user');
  651. $data = ['game_distribution1'=>$game_distribution1,'game_distribution2'=>$game_distribution2];
  652. if (defined('GAME_DISTRIBUTION_TOP') && GAME_DISTRIBUTION_TOP) {
  653. if ($_REQUEST['is_top']) {
  654. $data['game_distribution_top_id'] = $user_id;
  655. } else {
  656. $where = array('user_id' => $user_id);
  657. $res = $user_model->where($where)->find();
  658. if (!$res['game_distribution_top_id']) {
  659. $this->ajax_return(array(
  660. 'status' => 0,
  661. 'error' => '该用户未参与分销',
  662. ));
  663. }
  664. }
  665. }
  666. $res = $user_model->where($where)->save($data);
  667. if ($res) {
  668. fanwe_require(APP_ROOT_PATH . 'mapi/lib/redis/BaseRedisService.php');
  669. fanwe_require(APP_ROOT_PATH . 'mapi/lib/redis/UserRedisService.php');
  670. $user_redis = new UserRedisService();
  671. $user_redis->update_db($user_id, $data);
  672. $this->ajax_return(array(
  673. 'status' => 1,
  674. 'error' => '更新成功',
  675. ));
  676. }
  677. $this->ajax_return(array(
  678. 'status' => 0,
  679. 'error' => '更新失败',
  680. ));
  681. } else {
  682. $user_id = intval($_REQUEST['user_id']);
  683. $user_model = M('user');
  684. $user_info = $user_model->field(array('id', 'game_distribution1', 'game_distribution2'))->find($user_id);
  685. $user_info['game_distribution1'] = +$user_info['game_distribution1'];
  686. $user_info['game_distribution2'] = +$user_info['game_distribution2'];
  687. $this->assign("user_info", $user_info);
  688. $this->display();
  689. }
  690. }
  691. public function invitation_code()
  692. {
  693. $user_id = intval($_REQUEST['user_id']);
  694. $user_model = M('user');
  695. $user_info = $user_model->field(['invitation_code','create_time'])->find($user_id);
  696. if ($user_info['invitation_code']) {
  697. exit($user_info['invitation_code']);
  698. }
  699. $users = $user_model->field(['id','create_time'])->where(['invitation_code' => ''])->findAll();
  700. foreach ($users as $v) {
  701. $res = $user_model->save(['invitation_code' => substr(md5($v['id'] . ':' . $v['create_time']), -16),'id' => $v['id']]);
  702. }
  703. exit(substr(md5($user_id . ':' . $user_info['create_time']), -16));
  704. }
  705. public function game_distribution_detail()
  706. {
  707. $user_id = intval($_REQUEST['user_id']);
  708. if ($_REQUEST['type']) {
  709. $model = M('game_distribution');
  710. $table = DB_PREFIX . 'user u,' . DB_PREFIX . 'game_distribution gd';
  711. $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";
  712. $where = "(gd.first_distreibution_id = $user_id or gd.second_distreibution_id = $user_id) and u.id = gd.user_id";
  713. $group = 'u.id,gd.is_ticket';
  714. $list = $model->table($table)->field($field)->where($where)->group($group)->findAll();
  715. $this->assign("list", $list);
  716. } else {
  717. $map = [
  718. 'user_id' => $user_id,
  719. ];
  720. $model = M('game_distribution');
  721. if (!empty($model)) {
  722. $this->_list($model, $map);
  723. }
  724. }
  725. $this->assign("user_id", $user_id);
  726. $this->display();
  727. }
  728. //禁游戏
  729. public function forbid_game(){
  730. $id= intval($_REQUEST['user_id']);
  731. $open_game =$GLOBALS['db']->getRow("select open_game from ".DB_PREFIX."user where id =".$id);
  732. $where = 'id='.$id;
  733. require_once APP_ROOT_PATH.'mapi/lib/redis/BaseRedisService.php';
  734. require_once APP_ROOT_PATH.'mapi/lib/redis/UserRedisService.php';
  735. $user_redis = new UserRedisService();
  736. $data['open_game'] = 1;
  737. $info = '';
  738. if($open_game['open_game']==1) {
  739. $data['open_game'] = 0;
  740. $info = '取消';
  741. }
  742. $list = $GLOBALS['db']->autoExecute(DB_PREFIX."user",$data,'UPDATE',$where);
  743. if ($list!==false) {
  744. $user_redis->update_db($id, $data);
  745. $this->success ($info.'禁游戏成功',1);
  746. }else{
  747. $this->error ($info.'禁游戏成功',1);
  748. }
  749. }
  750. //禁付费
  751. public function forbid_pay(){
  752. $id= intval($_REQUEST['user_id']);
  753. $open_game =$GLOBALS['db']->getRow("select open_pay from ".DB_PREFIX."user where id =".$id);
  754. $where = 'id='.$id;
  755. require_once APP_ROOT_PATH.'mapi/lib/redis/BaseRedisService.php';
  756. require_once APP_ROOT_PATH.'mapi/lib/redis/UserRedisService.php';
  757. $user_redis = new UserRedisService();
  758. $data['open_pay'] = 1;
  759. $info = '';
  760. if($open_game['open_pay']==1) {
  761. $data['open_pay'] = 0;
  762. $info = '取消';
  763. }
  764. $list = $GLOBALS['db']->autoExecute(DB_PREFIX."user",$data,'UPDATE',$where);
  765. if ($list!==false) {
  766. $user_redis->update_db($id, $data);
  767. $this->success ($info.'禁付费成功',1);
  768. }else{
  769. $this->error ($info.'禁付费成功',1);
  770. }
  771. }
  772. //禁竞拍
  773. public function forbid_auction(){
  774. $id= intval($_REQUEST['user_id']);
  775. $open_game =$GLOBALS['db']->getRow("select open_auction from ".DB_PREFIX."user where id =".$id);
  776. $where = 'id='.$id;
  777. require_once APP_ROOT_PATH.'mapi/lib/redis/BaseRedisService.php';
  778. require_once APP_ROOT_PATH.'mapi/lib/redis/UserRedisService.php';
  779. $user_redis = new UserRedisService();
  780. $data['open_auction'] = 1;
  781. $info = '';
  782. if($open_game['open_auction']==1) {
  783. $data['open_auction'] = 0;
  784. $info = '取消';
  785. }
  786. $list = $GLOBALS['db']->autoExecute(DB_PREFIX."user",$data,'UPDATE',$where);
  787. if ($list!==false) {
  788. $user_redis->update_db($id, $data);
  789. $this->success ($info.'禁竞拍成功',1);
  790. }else{
  791. $this->error ($info.'禁竞拍成功',1);
  792. }
  793. }
  794. //设置机器人送礼物特权
  795. public function roboter()
  796. {
  797. $id = intval($_REQUEST['id']);
  798. $c_is_roboter = M("User")->where("id=".$id)->getField("roboter"); //当前状态
  799. $n_is_roboter = $c_is_roboter == 0 ? 1 : 0; //需设置的状态
  800. $result=M("User")->where("id=".$id)->setField("roboter",$n_is_roboter);
  801. $user_data = array();
  802. if($result){
  803. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/BaseRedisService.php');
  804. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/UserRedisService.php');
  805. $user_redis = new UserRedisService();
  806. $user_data['roboter'] = $n_is_roboter;
  807. $user_redis->update_db($id,$user_data);
  808. }
  809. $this->ajaxReturn($n_is_roboter,l("roboter_".$n_is_roboter),1);
  810. }
  811. }
  812. ?>