|
@@ -3,401 +3,70 @@ class RUserController extends AdminController{
|
|
|
|
|
|
public function actionIndex()
|
|
|
{
|
|
|
- $status_option = RUser::$status_option;
|
|
|
- $status = CommonFn::getComboboxData($status_option, 100, true, 100);
|
|
|
- $certify_type_option = RUser::$certify_type_option;
|
|
|
- $certify = CommonFn::getComboboxData($certify_type_option, 100, true, 100);
|
|
|
- $app_client_option = RUser::$app_client_option;
|
|
|
- $app_client = CommonFn::getComboboxData($app_client_option, 100, true, 100);
|
|
|
- $this->render('index', array(
|
|
|
- 'status' => $status,
|
|
|
- 'certify' => $certify,
|
|
|
- 'app_client' => $app_client,
|
|
|
- ));
|
|
|
+ $this->render('index');
|
|
|
}
|
|
|
|
|
|
public function actionList(){
|
|
|
- $filter_status = intval(Yii::app()->request->getParam('filter_status', 100));
|
|
|
+
|
|
|
$search = Yii::app()->request->getParam('search', '');
|
|
|
$id = Yii::app()->request->getParam('id', '');
|
|
|
- $group_id = Yii::app()->request->getParam('group_id','');
|
|
|
- $filter_is_certified = intval(Yii::app()->request->getParam('filter_is_certified', 100));
|
|
|
- $filter_certify = intval(Yii::app()->request->getParam('filter_certify', 100));
|
|
|
- $filter_app_client = intval(Yii::app()->request->getParam('filter_app_client', 100));
|
|
|
- $is_fake_user = intval(Yii::app()->request->getParam('is_fake_user', 100));
|
|
|
|
|
|
$params = CommonFn::getPageParams();
|
|
|
if(isset($params['sort']) && isset($params['sort']['register_time'])){
|
|
|
$params['sort'] = array('_id' => $params['sort']['register_time']);
|
|
|
}
|
|
|
|
|
|
- if(isset($params['offset']) && $params['offset']>400000){
|
|
|
- $params['offset'] = $params['offset']-200000;
|
|
|
- }
|
|
|
- $criteria = new EMongoCriteria($params);
|
|
|
|
|
|
- // 查找运营账号对应的马甲号
|
|
|
- // zhouxuchen 2015-11-12
|
|
|
- $fakeOwnerId = Yii::app()->request->getParam('fakeOwnerId', '');
|
|
|
- if (!empty($fakeOwnerId)) {
|
|
|
- $fakeOwner = User::get(intval($fakeOwnerId));
|
|
|
- $fake_users = $fakeOwner->fake_users;
|
|
|
- foreach ($fake_users as $key => $value) {
|
|
|
- $fake_users[$key] = new MongoId($value);
|
|
|
- }
|
|
|
+ $criteria = new EMongoCriteria($params);
|
|
|
|
|
|
- $criteria->_id('in', $fake_users);
|
|
|
- }
|
|
|
|
|
|
- if($group_id != ''){
|
|
|
- $group_id = new MongoId($group_id);
|
|
|
- $criteria->groups('==',$group_id);
|
|
|
- }
|
|
|
|
|
|
if ($id != ''){
|
|
|
$user_id = new MongoId($id);
|
|
|
$criteria->_id('==', $user_id);
|
|
|
}
|
|
|
- //var_dump($id);exit;
|
|
|
- if ($filter_status != 100){
|
|
|
- $criteria->status('==', $filter_status);
|
|
|
- }
|
|
|
- if ($filter_is_certified != 100) {
|
|
|
- $criteria->certify_status('==', $filter_is_certified);
|
|
|
- }
|
|
|
- if ($is_fake_user != 100) {
|
|
|
- $criteria->is_fake_user('==', $is_fake_user);
|
|
|
- }
|
|
|
- if ($filter_certify != 100) {
|
|
|
- $criteria->certify_type('==', $filter_certify);
|
|
|
- }
|
|
|
- if ($filter_app_client != 100) {
|
|
|
- $criteria->app_client_id('==', $filter_app_client);
|
|
|
- }
|
|
|
|
|
|
if ($search != '' && !CommonFn::isMongoId($search) && !CommonFn::isDeviceId($search)){
|
|
|
- $criteria->mobile('or', new MongoRegex('/' . $search . '/'));
|
|
|
- $criteria->name('or', new MongoRegex('/' . $search . '/'));
|
|
|
$criteria->user_name('or', new MongoRegex('/' . $search . '/'));
|
|
|
if (CommonFn::isMongoId($search)){
|
|
|
$criteria->_id('or', new MongoId($search));
|
|
|
}
|
|
|
}
|
|
|
- if($search && !CommonFn::isMongoId($search) && !CommonFn::isDeviceId($search)){
|
|
|
- $_rows = array();
|
|
|
- $conditions = array();
|
|
|
- $conditions['content'] = $search;
|
|
|
- // solr下标从0开始
|
|
|
- $pagesize = 20;
|
|
|
- $page = intval(Yii::app()->request->getParam('page',1));
|
|
|
- $searchResult = Service::factory('SearchService')->searchUser($search,$page,$pagesize);
|
|
|
- $pagedata = CommonFn::formatSearchResult($searchResult,$pagesize,$page);
|
|
|
- foreach ($pagedata['res'] as $value) {
|
|
|
- $post = RUser::get(new MongoId($value['id']));
|
|
|
- if($post){
|
|
|
- $post_temp = RUser::model()->parseRow($post);
|
|
|
- $_rows[] = $post_temp;
|
|
|
- }
|
|
|
- }
|
|
|
- echo CommonFn::composeDatagridData($_rows,$pagedata['sum_count']+200000);
|
|
|
- die();
|
|
|
- }elseif (CommonFn::isMongoId($search)) {
|
|
|
+ if (CommonFn::isMongoId($search)) {
|
|
|
$criteria = new EMongoCriteria();
|
|
|
$criteria->_id('==', new MongoId($search));
|
|
|
- }elseif (CommonFn::isDeviceId($search)) {
|
|
|
- $criteria = new EMongoCriteria();
|
|
|
- $criteria->device_id('==', $search);
|
|
|
}
|
|
|
$cursor = RUser::model()->findAll($criteria);
|
|
|
- $total = $cursor->count()+200000;
|
|
|
+ $total = $cursor->count();
|
|
|
$rows = CommonFn::getRowsFromCursor($cursor);
|
|
|
$parsedRows = RUser::model()->parse($rows);
|
|
|
echo CommonFn::composeDatagridData($parsedRows, $total);
|
|
|
}
|
|
|
|
|
|
public function actionUpdate(){
|
|
|
- $status = intval(Yii::app()->request->getParam('status', 1));
|
|
|
- $certify_status = intval(Yii::app()->request->getParam('certify_status',0));
|
|
|
- $id = Yii::app()->request->getParam('id', '');
|
|
|
- $city_info = Yii::app()->request->getParam('city_info', array());
|
|
|
|
|
|
- $is_fake_user = intval(Yii::app()->request->getParam('is_fake_user', 1));
|
|
|
-
|
|
|
- if($status == 100){
|
|
|
- CommonFn::requestAjax(false, '必须指定用户状态!');
|
|
|
- }
|
|
|
-
|
|
|
- $status=$status>1?1:$status;
|
|
|
- $certify_status=$certify_status!=1?0:1;
|
|
|
+ $id = Yii::app()->request->getParam('id', '');
|
|
|
|
|
|
- $is_fake_user=$is_fake_user>1?1:$is_fake_user;
|
|
|
|
|
|
if(!$id){
|
|
|
CommonFn::requestAjax(false, "缺少必须参数");
|
|
|
}
|
|
|
|
|
|
- $cityArray = array();
|
|
|
- $zCity = new ZCityInfo();
|
|
|
- if(!$zCity->checkCity($city_info,$cityArray)){
|
|
|
- CommonFn::requestAjax(false, '请检查城市信息是否正确!');
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
$criteria = new EMongoCriteria();
|
|
|
$criteria->_id = new MongoId($id);
|
|
|
$user = RUser::model()->find($criteria);
|
|
|
|
|
|
- $old_status = $user->status;
|
|
|
- if (empty($user)){
|
|
|
- CommonFn::requestAjax(false, '用户不存在');
|
|
|
- }
|
|
|
-
|
|
|
- // 认证信息
|
|
|
- $user->certify_status = $certify_status;
|
|
|
- if($certify_status==1){
|
|
|
- $certify_type = intval(Yii::app()->request->getParam('certify_type', 100));
|
|
|
- $certify_info = Yii::app()->request->getParam('certify_info', '');
|
|
|
- if($certify_type == 100 || $certify_info == ''){
|
|
|
- CommonFn::requestAjax(false, '认证用户必须指定认证信息!');
|
|
|
- } else {
|
|
|
- $user->certify_info = $certify_info;
|
|
|
- $user->certify_type = $certify_type;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if($status != 1 && $user->is_fake_user){
|
|
|
- //CommonFn::requestAjax(false, '马甲用户不能被禁言');
|
|
|
- }
|
|
|
-
|
|
|
|
|
|
- $user->status = $status;
|
|
|
+ //$keys = array('status','certify_status','is_fake_user','city_info');
|
|
|
|
|
|
- $user->is_fake_user = $is_fake_user;
|
|
|
- $user->city_info = $cityArray;
|
|
|
-
|
|
|
- $keys = array('status','certify_status','is_fake_user','city_info');
|
|
|
- if ($certify_status == 1) {
|
|
|
- $keys = array_merge($keys, array('certify_info','certify_type'));
|
|
|
- }
|
|
|
+ //$success = $user->save(true, $keys, true);
|
|
|
|
|
|
- $success = $user->save(true, $keys, true);
|
|
|
- $message = $user->getScenarioError();
|
|
|
-
|
|
|
- if($success && $status != $old_status){
|
|
|
- $data = array();
|
|
|
- $time_str = CommonFn::sgmdate("Y年n月d日", time(),1);
|
|
|
- $data['title'] = '握爪';
|
|
|
- if($status ==1 ){
|
|
|
- $status_str = '解禁';
|
|
|
- //禁言后发送通知
|
|
|
- $z_message = new ZMessage();
|
|
|
- $from_user = Yii::app()->params['kefu_user'];
|
|
|
- $m_data = array(
|
|
|
- 'from_user' => $from_user,
|
|
|
- 'to_user' => (string)$user->_id,
|
|
|
- 'content' => '你已经被解禁',
|
|
|
- 'pics' => array(),
|
|
|
- 'voice' => array(),
|
|
|
- 'video'=> array()
|
|
|
- );
|
|
|
- $z_message->addMessage($m_data);
|
|
|
- }elseif($status == 0){
|
|
|
- $status_str = '禁言';
|
|
|
- //禁言后发送通知
|
|
|
- $z_message = new ZMessage();
|
|
|
- $from_user = Yii::app()->params['kefu_user'];
|
|
|
- $m_data = array(
|
|
|
- 'from_user' => $from_user,
|
|
|
- 'to_user' => (string)$user->_id,
|
|
|
- 'content' => '你已经被禁言,如需解禁,请回复此私信与小爪爪联系',
|
|
|
- 'pics' => array(),
|
|
|
- 'voice' => array(),
|
|
|
- 'video'=> array()
|
|
|
- );
|
|
|
- $z_message->addMessage($m_data);
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
CommonFn::requestAjax($success, $message, array());
|
|
|
}
|
|
|
|
|
|
- public function actionAdd(){
|
|
|
- $user_name = Yii::app()->request->getParam('user_name', '');
|
|
|
- $email = Yii::app()->request->getParam('email', '');
|
|
|
- $avatar = Yii::app()->request->getParam('avatar', '');
|
|
|
- $password = Yii::app()->request->getParam('password', '');
|
|
|
- $status = 1;
|
|
|
- $can_binding = intval(Yii::app()->request->getParam('can_binding', 0));
|
|
|
- $city_info = Yii::app()->request->getParam('city_info', array());
|
|
|
-
|
|
|
- if($status == 100){
|
|
|
- CommonFn::requestAjax(false, '必须指定用户状态!');
|
|
|
- }
|
|
|
-
|
|
|
- if(!preg_match(Yii::app()->params['emailReg'], $email)){
|
|
|
- CommonFn::requestAjax(false,'请输入正确的邮箱地址哦');
|
|
|
- }
|
|
|
-
|
|
|
- if ($user_name == '' || mb_strlen($user_name, 'utf-8') < 2 ||mb_strlen($user_name, 'utf-8') > 16){
|
|
|
- CommonFn::requestAjax(false, '用户名必须在2~16个字之间');
|
|
|
- }
|
|
|
-
|
|
|
- if ($avatar&&!CommonFn::checkPicFormat($avatar)){
|
|
|
- CommonFn::requestAjax(false, '用户头像必须是图片URL!');
|
|
|
- }
|
|
|
-
|
|
|
- if(strlen($password)<6 || strlen($password)>20){
|
|
|
- CommonFn::requestAjax(false, '密码必须在6~20个字符');
|
|
|
- }
|
|
|
-
|
|
|
- $cityArray = array();
|
|
|
- $zCity = new ZCityInfo();
|
|
|
- if(!$zCity->checkCity($city_info,$cityArray)){
|
|
|
- CommonFn::requestAjax(false, '请检查城市信息是否正确!');
|
|
|
- }
|
|
|
-
|
|
|
- $criteria = new EMongoCriteria();
|
|
|
- $criteria->email('==',$email);
|
|
|
- $olduser = RUser::model()->find($criteria);
|
|
|
- if($olduser){
|
|
|
- CommonFn::requestAjax(false,'此邮箱已被注册');
|
|
|
- }
|
|
|
-
|
|
|
- $z_user = new ZUser();
|
|
|
- //$z_user->validate_user_name($user_name);
|
|
|
-
|
|
|
- $status=$status>1?1:$status;
|
|
|
-
|
|
|
-
|
|
|
- $user = new RUser();
|
|
|
- $user->user_name = $user_name;
|
|
|
- $user->email = $email;
|
|
|
- $user->avatar = $avatar;
|
|
|
- $user->password = md5($password);
|
|
|
- $user->is_fake_user = $can_binding?1:0;
|
|
|
- $user->status = $status;
|
|
|
- $user->city_info = $cityArray;
|
|
|
- $user->register_time = time();
|
|
|
- $user->last_visit_time = time();
|
|
|
-//var_dump($user);exit;
|
|
|
- $success = $user->save(true);
|
|
|
-
|
|
|
- if($can_binding&&$success){
|
|
|
- $criteria = new EMongoCriteria();
|
|
|
- $criteria->_id('==',Yii::app()->user->id);
|
|
|
- $admin_user = User::model()->find($criteria);
|
|
|
- $fake_users = CommonFn::get_val_if_isset($admin_user,'fake_users',array());
|
|
|
- if(!in_array($user->_id,$admin_user['fake_users'])){
|
|
|
- $fake_users[] = $user->_id;
|
|
|
- }
|
|
|
- $admin_user->fake_users = $fake_users;
|
|
|
- $admin_user->save(true);
|
|
|
- }
|
|
|
-
|
|
|
- CommonFn::requestAjax($success, '', array());
|
|
|
- }
|
|
|
- //修改用户积分
|
|
|
- public function actionChangeScore(){
|
|
|
- $user_id = Yii::app()->request->getParam('user_id');
|
|
|
- $score = intval(Yii::app()->request->getParam('score'));
|
|
|
- $reason = Yii::app()->request->getParam('reason');
|
|
|
-
|
|
|
- if(!$user_id||!$score||!$reason){
|
|
|
- CommonFn::requestAjax(false, "缺少必须参数");
|
|
|
- }
|
|
|
- if(abs($score)>3000||abs($score)<1){
|
|
|
- CommonFn::requestAjax(false, "请设置一个合理的评分范围");
|
|
|
- }
|
|
|
- $user = CommonFn::getObj($user_id,'ZUser');
|
|
|
- if(!$user){
|
|
|
- CommonFn::requestAjax(false, "用户不存在");
|
|
|
- }
|
|
|
- $result = Service::factory('ScoreService')->changeScore($user_id,$score,$reason);
|
|
|
- if($result){
|
|
|
- $model = new ZMessage();
|
|
|
- $from_user = Yii::app()->params['sys_user'];
|
|
|
- if($score>0){
|
|
|
- $data = array(
|
|
|
- 'from_user' => $from_user,
|
|
|
- 'to_user' => $user_id,
|
|
|
- 'content' => '你获得了'.$score.'个爪币的奖励,奖励理由:'.$reason.'。再接再厉哦',
|
|
|
- 'pics' => array(),
|
|
|
- 'voice' => array(),
|
|
|
- 'video'=> array()
|
|
|
- );
|
|
|
- }elseif ($score<0) {
|
|
|
- $data = array(
|
|
|
- 'from_user' => $from_user,
|
|
|
- 'to_user' => $user_id,
|
|
|
- 'content' => '你被扣除了'.$score.'个爪币,惩罚理由:'.$reason.'。',
|
|
|
- 'pics' => array(),
|
|
|
- 'voice' => array(),
|
|
|
- 'video'=> array()
|
|
|
- );
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- $model->addMessage($data);
|
|
|
- CommonFn::requestAjax(true, '爪币修改成功', array());
|
|
|
- }else{
|
|
|
- CommonFn::requestAjax(true, '爪币修改失败,请重试', array());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public function actionBatchAddScore(){
|
|
|
- $start_time = intval(Yii::app()->request->getParam('start_time'));
|
|
|
- $end_time = intval(Yii::app()->request->getParam('stop_time'));
|
|
|
- $score = Yii::app()->request->getParam('score');
|
|
|
- $keyword = Yii::app()->request->getParam('keyword');
|
|
|
- if(!$score || !$keyword || !$start_time || !$end_time){
|
|
|
- $this->render('batchaddscore');
|
|
|
- }else{
|
|
|
- $criteria = new EMongoCriteria();
|
|
|
- $criteria->time('>=',$start_time);
|
|
|
- $criteria->time('<=',$end_time);
|
|
|
- $criteria->content('==', new MongoRegex('/' . $keyword . '/'));
|
|
|
- $topics = Topic::model()->findAll($criteria);
|
|
|
- foreach ($topics as $key => $value) {
|
|
|
- var_dump($value);die();
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- public function actionToMsg(){
|
|
|
- $to_user_id = Yii::app()->request->getParam('to_user_id', '');
|
|
|
- $from_user_id = Yii::app()->request->getParam("from_user_id",'');
|
|
|
- $msg = Yii::app()->request->getParam('message_content', '');
|
|
|
- if(empty($to_user_id)){
|
|
|
- CommonFn::requestAjax(false, '必须选择发送用户!');
|
|
|
- }
|
|
|
- if(empty($msg)){
|
|
|
- CommonFn::requestAjax(false, '请输入私信内容!');
|
|
|
- }
|
|
|
- $model = new ZMessage();
|
|
|
- $from_user = $from_user_id ? $from_user_id : Yii::app()->params['kefu_user'];
|
|
|
- if(!$from_user){
|
|
|
- CommonFn::requestAjax(false, '无法获取系统定义的发送者账号!');
|
|
|
- }
|
|
|
- // 如果msg中存在链接,则做链接的合法化处理
|
|
|
- // zhouxuchen 2016-01-21
|
|
|
- $msg = CommonFn::checkContentURL($msg);
|
|
|
- $data = array(
|
|
|
- 'from_user' => $from_user,
|
|
|
- 'to_user' => $to_user_id,
|
|
|
- 'content' => $msg,
|
|
|
- 'pics' => array(),
|
|
|
- 'voice' => array(),
|
|
|
- 'video'=> array()
|
|
|
- );
|
|
|
- $result = $model->addMessage($data);
|
|
|
- if($result['status']){
|
|
|
- CommonFn::requestAjax($result['status'], '', $result['data']);
|
|
|
- }else{
|
|
|
- CommonFn::requestAjax($result['status'], '', array());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
public function actionGetCoupons(){
|
|
|
$user_id = Yii::app()->getRequest()->getParam("user_id");
|
|
|
$UserCoupon = new UserCoupon();
|
|
@@ -448,7 +117,7 @@ class RUserController extends AdminController{
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 握爪后台发送优惠券
|
|
|
+ * 后台发送优惠券
|
|
|
* zhouxuchen 2015-11-23
|
|
|
*/
|
|
|
// public function actionSendCoupon() {
|