PaiJoinAction.class.php 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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 PaiJoinAction extends CommonAction
  10. {
  11. public function index()
  12. {
  13. $table = 'fanwe_pai_join pai_join, fanwe_pai_goods goods, fanwe_user';
  14. $where = 'pai_join.pai_id = goods.id and pai_join.user_id = fanwe_user.id';
  15. if (isset($_REQUEST['name'])) {
  16. $where .= ' and goods.name like \'%' . addslashes(trim($_REQUEST['name'])) . '%\'';
  17. }
  18. if (isset($_REQUEST['user_name'])) {
  19. $where .= ' and fanwe_user.nick_name like \'%' . addslashes(trim($_REQUEST['user_name'])) . '%\'';
  20. }
  21. $begin_time = trim($_REQUEST['begin_time']) == '' ? 0 : to_timespan($_REQUEST['begin_time']);
  22. $end_time = trim($_REQUEST['end_time']) == '' ? 0 : to_timespan($_REQUEST['end_time']);
  23. if ($begin_time != 0) {
  24. $where .= ' and pai_join.create_time >= \'' . addslashes($begin_time) . '\'';
  25. } elseif ($end_time != 0) {
  26. $where .= ' and pai_join.create_time <= \'' . addslashes($end_time) . '\'';
  27. }
  28. $count = M('pai_join')->table($table)->where($where)->count();
  29. $p = new Page($count, $listRows = 20);
  30. if ($count > 0) {
  31. $field = 'pai_join.*,goods.name,goods.podcast_name as podcast_name,fanwe_user.nick_name as user_name';
  32. $order = 'pai_join.id desc';
  33. $list = M('pai_join')->table($table)->where($where)->field($field)->order($order)->limit($p->firstRow . ',' . $p->listRows)->select();
  34. $max = array();
  35. foreach ($list as &$value) {
  36. $value['create_time'] = to_date($value['create_time']);
  37. $value['user_name'] = emoji_decode($value['user_name']);
  38. $value['podcast_name'] = emoji_decode($value['podcast_name']);
  39. if ($value['pai_status'] == 0) {
  40. if (!isset($max[$value['pai_id']])) {
  41. $map = array('pai_id' => $value['pai_id']);
  42. $max[$value['pai_id']] = M('pai_join')->where($map)->max('pai_diamonds');
  43. }
  44. $value['max'] = $max[$value['pai_id']];
  45. }
  46. }
  47. }
  48. $page = $p->show();
  49. $this->assign("page", $page);
  50. $this->assign("list", $list);
  51. $this->display();
  52. }
  53. public function edit()
  54. {
  55. header('location:http://' . $_SERVER['HTTP_HOST'] . '/'.get_manage_url_name().'?m=PaiGoods&a=edit&id=' . intval($_REQUEST['id']));
  56. die;
  57. }
  58. }