/**
  * 修改保存 update
  */
 public function update()
 {
     $name = 'User';
     $model = D($name);
     $result = $model->do_update_head_auth();
     /* 返回信息 */
     if ($result) {
         if ($_POST['upfile_head_auth_type'] == 1) {
             /* 发送IM 信息 */
             import('Api.ORG.EasemobIMSDK');
             $rest = new \Hxcall();
             $sender = C('EASEMOB.EASEMOB_PREFIX') . '1';
             $receiver = C('EASEMOB.EASEMOB_PREFIX') . $_POST['id'];
             $msg = L('TS_user_authentication_upfile_head');
             $ext = array('type' => 5);
             $rest->hx_send($sender, $receiver, $msg, $ext);
         }
         $this->ajaxReturn(array('msg' => L('YZ_operation_success'), 'result' => 1, 'href' => U('index')));
     } else {
         $result = $model->getError();
         if (is_array($result) && count($result)) {
             /* 验证错误 */
             $errorMsg = validate_error($result);
             $this->ajaxReturn(array('formError' => $errorMsg, 'result' => -1));
         }
         /* 数据库操作错误 */
         $this->ajaxReturn(array('msg' => L('YZ_operation_fail'), 'result' => 1));
     }
 }
 /**
  * 话题点赞 add
  */
 public function add($user_id = NULL, $topic_id = NULL, $IM_user_id = NULL, $IM_upload = NULL)
 {
     if (IS_POST) {
         /* 定义变量 */
         $model = D(CONTROLLER_NAME);
         $result = $model->do_add();
         /* 返回信息 */
         if ($result) {
             $push_user = D('User')->find_by_topic($topic_id);
             if ($push_user['get_gold_notify']) {
                 if (!empty($push_user['push_id'])) {
                     $push_id = array();
                     $push_id[0] = $push_user['push_id'];
                     $notification = array('title' => '你收到一个颜币', 'extras' => array());
                     R('Api/Push/push_message_registration', array($push_id, $notification));
                 }
             }
             if ($IM_upload) {
                 import('Api.ORG.EasemobIMSDK');
                 $rest = new \Hxcall();
                 $sender = C('EASEMOB.EASEMOB_PREFIX') . 'topic_like_add';
                 $receiver = C('EASEMOB.EASEMOB_PREFIX') . $IM_user_id;
                 $msg = '送你颜币';
                 $ext = array('type' => 3, 'id' => $topic_id, 'username' => C('EASEMOB.EASEMOB_PREFIX') . $user_id, 'upload' => $IM_upload, 'remarks' => '', "em_ignore_notification" => true);
                 $rest->hx_send($sender, $receiver, $msg, $ext);
             }
             $this->ajaxReturn(array('RESPONSE_STATUS' => 100, 'Tips' => L('YZ_return_success')));
         } else {
             $this->return_post($model);
         }
     }
     $this->ajaxReturn(array('RESPONSE_STATUS' => 500, 'Tips' => L('YZ_return_failure')));
 }
 /**
  * 回调函数
  */
 protected function _after_do_statusUp()
 {
     $id = I('post.itemID');
     $name = CONTROLLER_NAME;
     $where['id'] = array('EQ', $id);
     $where['display'] = array('EQ', 1);
     $data = M($name)->field('title,user_id')->where($where)->find();
     /* 派发奖励 */
     $where_reward['id'] = array('EQ', $data['user_id']);
     $where_reward['status'] = array('EQ', 1);
     $where_reward['display'] = array('EQ', 1);
     $user_reward = M('User')->field('like_count,like_now_count')->where($where_reward)->find();
     $data_reward['like_count'] = $user_reward['like_count'] + 300;
     $data_reward['like_now_count'] = $user_reward['like_now_count'] + 300;
     M('User')->where($where_reward)->save($data_reward);
     /* 发送IM 信息 */
     import('Api.ORG.EasemobIMSDK');
     $rest = new \Hxcall();
     $sender = C('EASEMOB.EASEMOB_PREFIX') . '1';
     $receiver = C('EASEMOB.EASEMOB_PREFIX') . $data['user_id'];
     $msg = '非常感谢您的热心,您推荐的商家“' . $data['title'] . '”已经通过了小颜的审核。300颜币已入账,请笑纳并继续推荐';
     $rest->hx_send($sender, $receiver, $msg, array('type' => 0));
 }
Exemplo n.º 4
0
 /**
  * 发布话题 do_add
  */
 public function do_add()
 {
     /**
      * 1小时内已经发布过3张图片,将不允许再发布
      */
     $where['user_id'] = array('EQ', I('post.user_id'));
     $t = NOW_TIME - 3600;
     $where['create_time'] = array('EGT', $t);
     /* 查询数据 */
     $total = M('Topic')->where($where)->count('id');
     //logs_system_error(json_encode($where).json_encode($total));
     unset($where);
     if ($total > 0) {
         if ($total >= 3) {
             /* 成功推送IM */
             import('Api.ORG.EasemobIMSDK');
             $rest = new \Hxcall();
             $sender = C('EASEMOB.EASEMOB_PREFIX') . '1';
             $receiver = C('EASEMOB.EASEMOB_PREFIX') . I('post.user_id');
             $msg = L('TS_topic_too_busy');
             $ext = array('type' => 5);
             $rest->hx_send($sender, $receiver, $msg, $ext);
             return false;
         }
     }
     if ($this->create('', self::MODEL_TOPIC_ADD)) {
         $field = 'user_id,upfile,content,longitude,latitude,province,city,area,create_time';
         $result = $this->field($field)->add();
         /* 发布成功 */
         if ($result) {
             /* 用户表累加发布数 */
             $where['id'] = array('EQ', I('post.user_id'));
             M('User')->where($where)->setInc('topic_count');
         }
         return $result;
     }
     return false;
 }
Exemplo n.º 5
0
 /**
  * 回调函数
  */
 protected function _after_do_delete()
 {
     $id = I('post.itemID');
     $field = 'id,upfile,user_id,like_count';
     $where['id'] = array('EQ', $id);
     $data = M('Topic')->field($field)->where($where)->find();
     $userInfo = M('User')->field('like_count,like_now_count,topic_count,topic_like_count,topic_comment_count')->where(array('id' => $data['user_id']))->find();
     if ($userInfo['like_count'] >= $data['like_count'] && $userInfo['like_now_count'] >= $data['like_count']) {
         M('Topic_comment')->where(array('topic_id' => $id))->setField('display', 0);
         //删除当前话题的评论
         /* User表减去点数*/
         $user_where['like_count'] = $userInfo['like_count'] - $data['like_count'];
         //用户总颜值
         $user_where['like_now_count'] = $userInfo['like_now_count'] - $data['like_count'];
         //当前用户颜值
         $user_where['topic_count'] = $userInfo['topic_count'] - 1;
         //用户话题总数-1
         $topiclike_count = M('Topic_like')->where(array('topic_id' => $id))->count();
         $topic_comment_count = M('Topic_comment')->where(array('topic_id' => $id))->count();
         $user_where['topic_like_count'] = $userInfo['topic_like_count'] - $topiclike_count;
         //话题总赞数
         $user_where['topic_comment_count'] = $userInfo['topic_comment_count'] - $topic_comment_count;
         //总评论数
         $bool = M('User')->where(array('id' => $data['user_id']))->save($user_where);
     } else {
         //话题颜值大于用户当前颜值数
         M('Topic_comment')->where(array('topic_id' => $id))->setField('display', 0);
         //删除当前话题的评论
         /* User表减去点数*/
         $user_where['like_count'] = $userInfo['like_count'] - $data['like_count'];
         //用户总颜值
         $user_where['like_now_count'] = 0;
         //当前用户颜值
         $user_where['topic_count'] = $userInfo['topic_count'] - 1;
         //用户话题总数-1
         $topiclike_count = M('Topic_like')->where(array('topic_id' => $id))->count();
         $topic_comment_count = M('Topic_comment')->where(array('topic_id' => $id))->count();
         $user_where['topic_like_count'] = $userInfo['topic_like_count'] - $topiclike_count;
         //话题总赞数
         $user_where['topic_comment_count'] = $userInfo['topic_comment_count'] - $topic_comment_count;
         //总评论数
         $bool = M('User')->where(array('id' => $data['user_id']))->save($user_where);
     }
     /* 发送IM 信息 */
     import('Api.ORG.EasemobIMSDK');
     $rest = new \Hxcall();
     $sender = C('EASEMOB.EASEMOB_PREFIX') . '1';
     $receiver = C('EASEMOB.EASEMOB_PREFIX') . $data['user_id'];
     $msg = L('TS_topic_not_pass');
     $ext = array('type' => 4, 'id' => $data['id'], 'upload' => $data['upfile'], 'remarks' => '');
     $rest->hx_send($sender, $receiver, $msg, $ext);
 }
 /**
  * 回调函数
  */
 protected function _after_do_delete()
 {
     $id = I('post.itemID');
     $field = 'topic.id as topic_id,topic.upfile as topic_upfile,
               topic_comment.user_id';
     $where['topic_comment.id'] = array('EQ', $id);
     $data = M('TopicComment')->alias('topic_comment')->field($field)->join('left join __TOPIC__ topic ON topic_comment.topic_id = topic.id')->where($where)->find();
     import('Api.ORG.EasemobIMSDK');
     $rest = new \Hxcall();
     $sender = C('EASEMOB.EASEMOB_PREFIX') . '1';
     $receiver = C('EASEMOB.EASEMOB_PREFIX') . $data['user_id'];
     $msg = '你发布的评论审核不通过, 已被删除';
     $ext = array('type' => 4, 'id' => $data['topic_id'], 'upload' => $data['topic_upfile'], 'remarks' => '');
     $rest->hx_send($sender, $receiver, $msg, $ext);
 }