| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718 |
- <?php
- // +----------------------------------------------------------------------
- // | Fanwe 方维直播系统
- // +----------------------------------------------------------------------
- // | Copyright (c) 2011 http://www.fanwe.com All rights reserved.
- // +----------------------------------------------------------------------
- // | Author: 云淡风轻(1956838968@qq.com)
- // +----------------------------------------------------------------------
- class EduUserGeneralAction extends CommonAction
- {
- public function __construct()
- {
- parent::__construct();
- require_once APP_ROOT_PATH . "/admin/Lib/Action/UserCommonAction.class.php";
- require_once APP_ROOT_PATH . "/system/libs/user.php";
- }
- public function index()
- {
- $common = new UserCommon();
- $data = $_REQUEST;
- // $data['is_authentication'] = array('in',array(0,1,3));
- $data['is_robot'] = 0;
- $common->index($data);
- }
- public function edit()
- {
- $common = new UserCommon();
- $data = $_REQUEST;
- $common->edit($data);
- $user = $this->get('vo');
- }
- public function delete()
- {
- //彻底删除指定记录
- $common = new UserCommon();
- $data = $_REQUEST;
- $common->delete($data);
- }
- public function update()
- {
- $common = new UserCommon();
- $data = $_REQUEST;
- $common->update($data);
- }
- public function set_effect()
- {
- $common = new UserCommon();
- $data = $_REQUEST;
- $n_is_effect = $common->set_effect($data);
- $this->ajaxReturn($n_is_effect, l("SET_EFFECT_" . $n_is_effect), 1);
- }
- public function set_ban()
- {
- $common = new UserCommon();
- $data = $_REQUEST;
- $n_is_effect = $common->set_ban($data);
- $this->ajaxReturn($n_is_effect, l("SET_BAN_" . $n_is_effect), 1);
- }
- //禁热门
- public function set_hot_on()
- {
- $common = new UserCommon();
- $data = $_REQUEST;
- $n_is_effect = $common->set_hot_on($data);
- $this->ajaxReturn($n_is_effect, l("SET_HOT_ON_" . $n_is_effect), 1);
- }
- //新增关注
- public function add_focus()
- {
- $common = new UserCommon();
- $data = $_REQUEST;
- $common->add_focus($data);
- }
- //新增关注
- public function set_follow()
- {
- $common = new UserCommon();
- $data = $_REQUEST;
- $common->set_follow($data);
- }
- //关注列表
- public function focus_list()
- {
- $common = new UserCommon();
- $data = $_REQUEST;
- $common->focus_list($data);
- }
- //新增粉丝
- public function add_fans()
- {
- $common = new UserCommon();
- $data = $_REQUEST;
- $common->add_fans($data);
- }
- //新增粉丝
- public function set_follower()
- {
- $common = new UserCommon();
- $data = $_REQUEST;
- $common->set_follower($data);
- }
- //粉丝列表
- public function fans_list()
- {
- $common = new UserCommon();
- $data = $_REQUEST;
- $common->fans_list($data);
- }
- //删除关注
- public function del_focus_list()
- {
- $common = new UserCommon();
- $data = $_REQUEST;
- $common->del_focus_list($data);
- }
- //删除粉丝
- public function del_fans_list()
- {
- $common = new UserCommon();
- $data = $_REQUEST;
- $common->del_fans_list($data);
- }
- //印票贡献榜
- public function contribution_list()
- {
- $common = new UserCommon();
- $data = $_REQUEST;
- $common->contribution_list($data);
- }
- /**
- * 删除印票贡献榜
- */
- /*public function del_contribution_list()
- {
- $ajax = intval($_REQUEST['ajax']);
- $id = $_REQUEST ['id'];
- if (isset ( $id )) {
- $common = new UserCommon();
- $data = $_REQUEST;
- $status = $common->del_contribution_list($data);
- if ($status!==false) {
- $this->success (l("FOREVER_DELETE_SUCCESS"),$ajax);
- } else {
- $this->error (l("FOREVER_DELETE_FAILED"),$ajax);
- }
- } else {
- $this->error (l("INVALID_OPERATION"),$ajax);
- }
- }*/
- //消息推送
- public function push()
- {
- $common = new UserCommon();
- $data = $_REQUEST;
- $common->push($data);
- }
- //删除推送消息
- public function del_push()
- {
- $ajax = intval($_REQUEST['ajax']);
- $id = $_REQUEST ['id'];
- if (isset ($id)) {
- $common = new UserCommon();
- $data = $_REQUEST;
- $status = $common->del_push($data);
- if ($status !== false) {
- $this->success(l("FOREVER_DELETE_SUCCESS"), $ajax);
- } else {
- $this->error(l("FOREVER_DELETE_FAILED"), $ajax);
- }
- } else {
- $this->error(l("INVALID_OPERATION"), $ajax);
- }
- }
- //账户管理
- public function account()
- {
- $common = new UserCommon();
- $data = $_REQUEST;
- $status = $common->account($data);
- }
- //账户修改
- public function modify_account()
- {
- $common = new UserCommon();
- $data = $_REQUEST;
- $status = $common->modify_account($data);
- if ($status) {
- $this->success(L("UPDATE_SUCCESS"));
- } else {
- $this->error("累计充值数据有误!");
- }
- }
- //账户日志
- public function account_detail()
- {
- $common = new UserCommon();
- $data = $_REQUEST;
- $common->account_detail($data);
- }
- //兑换日志
- public function exchange_log()
- {
- $common = new UserCommon();
- $data = $_REQUEST;
- $common->exchange_log($data);
- }
- //删除账户日志
- public function foreverdelete_account_detail()
- {
- //彻底删除指定记录
- $ajax = intval($_REQUEST['ajax']);
- $id = $_REQUEST ['id'];
- $data = $_REQUEST;
- if (isset ($id)) {
- $common = new UserCommon();
- $status = $common->foreverdelete_account_detail($data);
- if ($status !== false) {
- $this->success(l("FOREVER_DELETE_SUCCESS"), $ajax);
- } else {
- $this->error(l("FOREVER_DELETE_FAILED"), $ajax);
- }
- } else {
- $this->error(l("INVALID_OPERATION"), $ajax);
- }
- }
- //删除兑换日志
- public function foreverdelete_exchange_log()
- {
- //彻底删除指定记录
- $ajax = intval($_REQUEST['ajax']);
- $id = $_REQUEST ['id'];
- $data = $_REQUEST;
- if (isset ($id)) {
- $common = new UserCommon();
- $status = $common->foreverdelete_exchange_log($data);
- if ($status !== false) {
- $this->success(l("FOREVER_DELETE_SUCCESS"), $ajax);
- } else {
- $this->error(l("FOREVER_DELETE_FAILED"), $ajax);
- }
- } else {
- $this->error(l("INVALID_OPERATION"), $ajax);
- }
- }
- //检查用户
- public function check_user()
- {
- $common = new UserCommon();
- $user_id = $_REQUEST['id'];
- admin_ajax_return($common->check_user($user_id));
- }
- //礼物日志
- public function prop()
- {
- $common = new UserCommon();
- $data = $_REQUEST;
- $common->prop($data);
- }
- //收礼物日志
- public function closed_prop()
- {
- $data = $_REQUEST;
- $now = get_gmtime();
- $user_id = intval($_REQUEST['id']);
- $user_info = M("User")->getById($user_id);
- $prop_list = M("prop")->where("is_effect <>0")->findAll();
- $where = "l.to_user_id=" . $user_id;
- $model = D("video_prop");
- //赠送时间
- $current_Year = date('Y');
- $current_YM = date('Ym');
- for ($i = 0; $i < 5; $i++) {
- $years[$i] = $current_Year - $i;
- }
- for ($i = 01; $i < 13; $i++) {
- $month[$i] = str_pad(0 + $i, 2, 0, STR_PAD_LEFT);
- }
- if (strim($data['years']) != -1 && strim($data['month'] != -1)) {
- $time = $data['years'] . '' . $data['month'];
- } else {
- $time = $current_YM;
- }
- if (strim($data['years']) != -1 && strim($data['month'] == -1)) {
- $this->error("请选择月份");
- }
- if (strim($data['years']) == -1 && strim($data['month'] != -1)) {
- $this->error("请选择年份");
- }
- //查询ID
- if (strim($data['from_user_id']) != '') {
- $parameter .= "l.from_user_id=" . intval($data['from_user_id']) . "&";
- $sql_w .= "l.from_user_id=" . intval($data['from_user_id']) . " and ";
- }
- //查询昵称
- if (trim($data['nick_name']) != '') {
- $parameter .= "u.nick_name like " . urlencode('%' . trim($data['nick_name']) . '%') . "&";
- $sql_w .= "u.nick_name like '%" . trim($data['nick_name']) . "%' and ";
- }
- if (!isset($_REQUEST['prop_id'])) {
- $_REQUEST['prop_id'] = -1;
- }
- //查询礼物
- if ($_REQUEST['prop_id'] != -1) {
- if (isset($data['prop_id'])) {
- $parameter .= "l.prop_id=" . intval($data['prop_id']) . "&";
- $sql_w .= "l.prop_id=" . intval($data['prop_id']) . " and ";
- }
- }
- //默认查询本月的记录,选择查询时间时,如果查询时间 不等于当前时间,则查询他表
- if ($data['years'] != '' && $data['month'] != '') {
- $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
- FROM " . DB_PREFIX . "video_prop_" . $time . " as l
- 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" . "
- WHERE $where " . " and " . $sql_w . " 1=1 ";
- $count_sql = "SELECT count(l.id) as tpcount
- FROM " . DB_PREFIX . "video_prop_" . $time . " as l
- 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" . "
- WHERE $where " . " and " . $sql_w . " 1=1 ";
- $total_ticket_sql = "SELECT SUM(l.total_ticket) as tpcount
- FROM " . DB_PREFIX . "video_prop_" . date('Ym', NOW_TIME) . " as l
- 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" . "
- WHERE $where " . " and " . $sql_w . " 1=1 ";
- } else {
- $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
- FROM " . DB_PREFIX . "video_prop_" . date('Ym', NOW_TIME) . " as l
- 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" . "
- WHERE $where " . " and " . $sql_w . " 1=1 ";
- $count_sql = "SELECT count(l.id) as tpcount
- FROM " . DB_PREFIX . "video_prop_" . date('Ym', NOW_TIME) . " as l
- 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" . "
- WHERE $where " . " and " . $sql_w . " 1=1 ";
- $total_ticket_sql = "SELECT SUM(l.total_ticket) as tpcount
- FROM " . DB_PREFIX . "video_prop_" . date('Ym', NOW_TIME) . " as l
- 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" . "
- WHERE $where " . " and " . $sql_w . " 1=1 ";
- }
- $count = $GLOBALS['db']->getOne($count_sql);
- $total_ticket = $GLOBALS['db']->getOne($total_ticket_sql);
- $volist = $this->_Sql_list($model, $sql_str, '&' . $parameter, 1, 0, $count_sql);
- foreach ($volist as $k => $v) {
- if ($volist[$k]['prop_id'] == 12) {
- $volist[$k]['total_ticket'] = '';
- }
- $volist[$k]['create_time'] = date('Y-m-d', $volist[$k]['create_time']);
- }
- $this->assign("user_info", $user_info);
- $this->assign("prop", $prop_list);
- $this->assign("years", $years);
- $this->assign("month", $month);
- $this->assign("list", $volist);
- $this->assign("count", intval($count));
- $this->assign('total_ticket', intval($total_ticket));
- $this->display();
- }
- //分享奖励
- public function distribution_log()
- {
- $common = new UserCommon();
- $data = $_REQUEST;
- $common->distribution_log($data);
- }
- //分销子成员奖励
- public function distribution_user()
- {
- $common = new UserCommon();
- $data = $_REQUEST;
- $common->distribution_user($data);
- }
- //删除礼物日志
- public function delete_prop()
- {
- //彻底删除指定记录
- $ajax = intval($_REQUEST['ajax']);
- $id = intval($_REQUEST ['id']);
- $data = $_REQUEST;
- if (isset ($id)) {
- $common = new UserCommon();
- $status = $common->del_prop($data);
- if ($status !== false) {
- $this->success(l("FOREVER_DELETE_SUCCESS"), $ajax);
- } else {
- $this->error(l("FOREVER_DELETE_FAILED"), $ajax);
- }
- } else {
- $this->error(l("INVALID_OPERATION"), $ajax);
- }
- }
- public function forbid_msg()
- {
- $common = new UserCommon();
- $data = $_REQUEST;
- $common->forbid_msg($data);
- }
- //商品管理
- public function goods()
- {
- $user_id = intval($_REQUEST['user_id']);
- if (strim($_REQUEST['name']) != '') {
- $map['name'] = array('like', '%' . strim($_REQUEST['name']) . '%');
- }
- $map['is_effect'] = 1;
- $model = D('goods');
- if (!empty ($model)) {
- $this->_list($model, $map);
- }
- $list = $this->get('list');
- $user_list = $GLOBALS['db']->getAll("select goods_id from " . DB_PREFIX . "user_goods where is_effect=1 and user_id=" . $user_id);
- foreach ($list as $k => $v) {
- $imgs = array();
- $imgs_details = array();
- $imgs = json_decode($v['imgs'], 1);
- $imgs_details = json_decode($v['imgs_details'], 1);
- $list[$k]['imgs'] = $imgs[0];
- $list[$k]['imgs_details'] = $imgs_details[0];
- $list[$k]['has'] = '否';
- foreach ($user_list as $value1) {
- if ($v['id'] == $value1['goods_id']) {
- $list[$k]['has'] = '是';
- break;
- }
- }
- }
- $sort = array_column($list, 'has');
- array_multisort($sort, SORT_DESC, $list);
- $this->assign("list", $list);
- $this->display();
- }
- //上架商品
- public function shelves()
- {
- $ajax = intval($_REQUEST['ajax']);
- $goods_id = intval($_REQUEST ['id']);
- $user_id = intval($_REQUEST ['user_id']);
- if (isset($goods_id)) {
- $where['goods_id'] = $goods_id;
- $where['user_id'] = $user_id;
- $user_goods = M('user_goods')->where($where)->select();
- $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);
- if ($user_goods) {
- $list = M('user_goods')->where($where)->save($goods_info);
- } else {
- $data = array_merge($where, $goods_info);
- $list = M('user_goods')->add($data);
- }
- if ($list !== false) {
- $result['info'] = "上架成功!";
- $result['status'] = 1;
- admin_ajax_return($result);
- } else {
- $result['info'] = "上架失败!";
- $result['status'] = 0;
- admin_ajax_return($result);
- }
- } else {
- $this->error(l("INVALID_OPERATION"), $ajax);
- }
- }
- //下架商品
- public function sold()
- {
- $ajax = intval($_REQUEST['ajax']);
- $goods_id = intval($_REQUEST ['id']);
- $user_id = intval($_REQUEST ['user_id']);
- if (isset($goods_id)) {
- $condition['goods_id'] = $goods_id;
- $condition['user_id'] = $user_id;
- $user_goods = M('user_goods')->where($condition)->select();
- if ($user_goods) {
- $list = M('user_goods')->where($condition)->delete();
- }
- if ($list !== false) {
- $result['info'] = "下架成功!";
- $result['status'] = 1;
- admin_ajax_return($result);
- } else {
- $result['info'] = "下架失败!";
- $result['status'] = 0;
- admin_ajax_return($result);
- }
- } else {
- $this->error(l("INVALID_OPERATION"), $ajax);
- }
- }
- public function clear_view_count()
- {
- $sql = "update " . DB_PREFIX . "user set view_count = 0";
- $res = $GLOBALS['db']->query($sql);
- if ($res) {
- $result['info'] = "清除成功!";
- $result['status'] = 1;
- } else {
- $result['info'] = "清除失败!";
- $result['status'] = 0;
- }
- admin_ajax_return($result);
- }
- public function weibo_index()
- {
- $common = new UserCommon();
- $data = $_REQUEST;
- // $data['is_authentication'] = array('in',array(0,1,3));
- $data['is_robot'] = 0;
- $common->index($data);
- }
- public function set_sort()
- {
- $id = intval($_REQUEST['id']);
- $sort = intval($_REQUEST['sort']);
- $log_info = M("User")->where("id=" . $id)->getField("nick_name");
- if (!check_sort($sort)) {
- $this->error(l("SORT_FAILED"), 1);
- }
- M("User")->where("id=" . $id)->setField("weibo_recommend_weight", $sort);
- save_log($log_info . l("SORT_SUCCESS"), 1);
- $this->success(l("SORT_SUCCESS"), 1);
- }
- public function game_rate()
- {
- if ($_POST) {
- $user_id = intval($_REQUEST['user_id']);
- $rate = intval($_REQUEST['rate']);
- if (!$user_id) {
- $this->ajax_return(array(
- 'status' => 0,
- 'error' => '参数错误',
- ));
- }
- if ($rate > 100 || $rate < 0) {
- $this->ajax_return(array(
- 'status' => 0,
- 'error' => '参数错误',
- ));
- }
- $where = array('id' => $user_id);
- $user_model = M('user');
- $res = $user_model->setField('rate', $rate, $where);
- if ($res) {
- fanwe_require(APP_ROOT_PATH . 'mapi/lib/redis/BaseRedisService.php');
- fanwe_require(APP_ROOT_PATH . 'mapi/lib/redis/UserRedisService.php');
- $user_redis = new UserRedisService();
- $user_redis->update_db($user_id, ['rate' => $rate]);
- $this->ajax_return(array(
- 'status' => 1,
- 'error' => '更新成功',
- ));
- }
- $this->ajax_return(array(
- 'status' => 0,
- 'error' => '更新失败',
- ));
- } else {
- $user_id = intval($_REQUEST['user_id']);
- $user_model = M('user');
- $user_info = $user_model->field(array('id', 'rate'))->find($user_id);
- $user_info['rate'] = +$user_info['rate'];
- $this->assign("user_info", $user_info);
- $this->display();
- }
- }
- protected function ajax_return($data)
- {
- header("Content-Type:text/html; charset=utf-8");
- echo(json_encode($data));
- exit;
- }
- public function game_distribution()
- {
- if ($_POST) {
- $user_id = intval($_REQUEST['user_id']);
- $game_distribution1 = intval($_REQUEST['game_distribution1']);
- $game_distribution2 = intval($_REQUEST['game_distribution2']);
- if (!$user_id) {
- $this->ajax_return(array(
- 'status' => 0,
- 'error' => '参数错误',
- ));
- }
- $where = array('id' => $user_id);
- $user_model = M('user');
- $res = $user_model->where($where)->save([
- 'game_distribution1' => $game_distribution1,
- 'game_distribution2' => $game_distribution2
- ]);
- if ($res) {
- fanwe_require(APP_ROOT_PATH . 'mapi/lib/redis/BaseRedisService.php');
- fanwe_require(APP_ROOT_PATH . 'mapi/lib/redis/UserRedisService.php');
- $user_redis = new UserRedisService();
- $user_redis->update_db($user_id,
- ['game_distribution1' => $game_distribution1, 'game_distribution2' => $game_distribution2]);
- $this->ajax_return(array(
- 'status' => 1,
- 'error' => '更新成功',
- ));
- }
- $this->ajax_return(array(
- 'status' => 0,
- 'error' => '更新失败',
- ));
- } else {
- $user_id = intval($_REQUEST['user_id']);
- $user_model = M('user');
- $user_info = $user_model->field(array('id', 'game_distribution1', 'game_distribution2'))->find($user_id);
- $user_info['game_distribution1'] = +$user_info['game_distribution1'];
- $user_info['game_distribution2'] = +$user_info['game_distribution2'];
- $this->assign("user_info", $user_info);
- $this->display();
- }
- }
- public function game_distribution_detail()
- {
- $user_id = intval($_REQUEST['user_id']);
- if ($_REQUEST['type']) {
- $model = M('game_distribution');
- $table = DB_PREFIX . 'user u,' . DB_PREFIX . 'game_distribution gd';
- $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`";
- $where = "(gd.first_distreibution_id = $user_id or gd.second_distreibution_id = $user_id) and u.id = gd.user_id";
- $group = 'u.id';
- $list = $model->table($table)->field($field)->where($where)->group($group)->findAll();
- $this->assign("list", $list);
- } else {
- $map = [
- 'user_id' => $user_id,
- ];
- $model = M('game_distribution');
- if (!empty($model)) {
- $this->_list($model, $map);
- }
- }
- $this->assign("user_id", $user_id);
- $this->display();
- }
- }
- ?>
|