EduUserGeneralAction.class.php 23 KB

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