Esempio n. 1
0
 /**
  * 提升用户的等级 到 多少级
  *
  * @param $gift int 提升等级
  * @param $uid int 用户uid
  */
 public function present($gift, $uid)
 {
     $model = new Model();
     $this->setRedis();
     $userinfo = $this->_redisInstance->hGetAll('huser_info:' . $uid);
     // 判断是否要提升到的等级是否小于本身用户的等级了,如果小于就不提升了
     if ($userinfo['lv_rich'] >= $gift) {
         return true;
     } else {
         $lv_rich = $gift;
         // 根据等级计算 对应的值
         $lvs = $this->getLvRich();
         $rich = $lvs[$lv_rich]['level_value'];
     }
     $data = array('lv_rich' => $lv_rich, 'rich' => $rich);
     $result = $model->flush('video_user', $data, array('uid' => $uid));
     // 更新用户的等级的redis
     if ($result !== false) {
         $this->_redisInstance->hset('huser_info:' . $uid, 'lv_rich', $lv_rich);
         $this->_redisInstance->hset('huser_info:' . $uid, 'rich', $rich);
         // 记录日志
         $exp_log = array('uid' => $uid, 'exp' => $rich - $userinfo['rich'], 'type' => 1, 'status' => 2, 'roled' => $userinfo['roled'], 'admin_id' => 10000, 'init_time' => date('Y-m-d H:i:s'), 'dml_time' => date('Y-m-d H:i:s'), 'dml_flag' => 1, 'curr_exp' => $userinfo['rich']);
         $model->add('video_user_mexp', $exp_log);
         return true;
     }
     return false;
 }
Esempio n. 2
0
 /**
  * 检查首次预约的任务
  *
  * @param $task
  * @param $uid
  *
  * @return mixed
  */
 public function check($task, $uid)
 {
     $this->task = $task;
     $this->uid = $uid;
     $model = new Model();
     $userTask = $model->find('select * from video_task_user where vtask_id=' . $task['vtask_id'] . ' and uid=' . $uid);
     $user = $model->find('select * from video_user where uid=' . $uid);
     if ($task['pre_vtask_id']) {
         $isDo = $model->find('select * from video_task_user where vtask_id=? and uid=?', array($task['pre_vtask_id'], $user['uid']));
         // 当没有申请或者没有完成父任务时
         if (!$isDo || $isDo['status'] != 1) {
             return 'can_apply';
         }
     }
     /**
      * 如果没有接任务的话,就判断是否可以自动申请任务
      */
     if (!$userTask) {
         /**
          * 只要用户满足做这个任务的条件就要插入一条数据 等待预约的验证
          */
         $c = serialize(array('csc' => 0, 'update_time' => time()));
         $data = array('uid' => $uid, 'vtask_id' => $task['vtask_id'], 'status' => 0, 'csc' => $c, 'apply_date' => time(), 'init_time' => date('Y-m-d H:i:s'), 'dml_time' => date('Y-m-d H:i:s'), 'dml_flag' => 1);
         $model->add('video_task_user', $data);
         // 增加一个申请人数
         $this->updateTaskApplicants($task);
         return 'doing';
     }
     $ut = $userTask;
     $csc = unserialize($ut['csc']);
     if ($ut['status'] == 1) {
         return 'all';
     }
     if ($ut['status'] == -1) {
         return 'failed';
     }
     if ($ut['status'] == 0 && $csc['csc'] == 100) {
         return 'success';
     }
     /**
      * 当没有完成的时候要检查进度
      */
     if ($ut['status'] == 0 && $csc['csc'] != 100) {
         /**
          * 检查是否完成了预约,是就更新状态
          * 要求在申请任务之后 预约的才算
          */
         $invite = $model->find('select * from video_room_duration where invitetime>? and reuid=?', array($ut['apply_date'], $uid));
         if ($invite) {
             $data = array();
             $csc['csc'] = 100;
             $csc['update_time'] = time();
             $data['csc'] = serialize($csc);
             $model->flush('video_task_user', $data, array('auto_id' => $ut['auto_id']));
             return 'success';
         }
         return 'doing';
     }
 }
Esempio n. 3
0
 /**
  * 添加用户的礼物到背包中
  *
  * @param $gifts
  * @param $uid
  */
 public function present($gifts, $uid)
 {
     // 暂时性的屏蔽掉
     return true;
     $model = new Model();
     $gift = $gifts[0];
     $data = array('uid' => $uid, 'icon_id' => $gift['id'], 'type' => 1, 'init_time' => date('Y-m-d H:i:s'), 'dml_flag' => 1);
     $model->add('video_user_icon', $data);
 }
Esempio n. 4
0
 public function add($fields, $privs)
 {
     $res = $fields;
     $id_role = parent::add($res);
     if ($id_role != false) {
         if (count($privs) > 0) {
             foreach ($privs as $key => $id_priv) {
                 $this->db->insert('roles_privs', ['id_role' => $id_role, 'id_priv' => $id_priv]);
             }
         }
     } else {
         return false;
     }
     return $id_role;
 }
Esempio n. 5
0
 public function add($fields, $file)
 {
     $res = $fields;
     if ($file['name'] != '') {
         $id_image = Image::app()->add($file);
         if ($id_image === false) {
             return false;
         } else {
             $res['id_image'] = $id_image;
         }
     }
     $id_user = parent::add($res);
     if ($id_user == false && $id_image != null) {
         Image::app()->delete($id_image);
     }
     return $id_user;
 }
Esempio n. 6
0
 public function add($fields, $tags, $file)
 {
     $res = $fields;
     if ($file['name'] != '') {
         $id_image = Image::app()->add($file);
         if ($id_image === false) {
             return false;
         } else {
             $res['id_image'] = $id_image;
         }
     }
     $id_post = parent::add($res);
     if ($id_post != false) {
         if (count($tags) > 0) {
             foreach ($tags as $key => $tag) {
                 $this->db->insert('posts_tags', ['id_post' => $id_post, 'id_tag' => $tag]);
             }
         }
     } elseif ($id_post == false && $id_image != null) {
         Image::app()->delete($id_image);
     }
     return $id_post;
 }
Esempio n. 7
0
 /**
  * 添加用户的礼物到背包中
  *
  * @param $gifts
  * @param $uid
  */
 public function present($gifts, $uid)
 {
     $model = new Model();
     $flag = false;
     foreach ($gifts as $gift) {
         $has_gif = $model->find('select * from video_pack where uid=? and gid=?', array($uid, $gift['id']));
         if ($has_gif) {
             if (!empty($gift['exp'])) {
                 $expires = $has_gif['expires'] + $gift['exp'] * 24 * 3600;
                 $model->flush('video_pack', array('expires' => $expires), array('uid' => $uid, 'gid' => $gift['id']));
             }
             $flag = true;
         } else {
             $exp = time() + $gift['exp'] * 24 * 3600;
             $result = $model->add('video_pack', array('uid' => $uid, 'gid' => $gift['id'], 'num' => $gift['num'], 'expires' => $exp));
             if ($result !== false) {
                 $flag = true;
             } else {
                 $flag = false;
             }
         }
     }
     return $flag;
 }
Esempio n. 8
0
 /**
  * 发送提示消息
  */
 protected function sendMsg($uid, $content)
 {
     $arr = array('send_uid' => 0, 'rec_uid' => $uid, 'content' => $content, 'category' => 1, 'status' => 0, 'created' => date('Y-m-d H:i:s'));
     $model = new Model();
     $model->add('video_mail', $arr);
 }
Esempio n. 9
0
 public function add($fields)
 {
     $fields['full_url'] = $this->make_full_url($fields['id_parent'], $fields['url']);
     return parent::add($fields);
 }
Esempio n. 10
0
 /**
  * 检测邮箱任务的完成程度
  *
  * 邮箱如果验证了,就标示邮箱任务已经完成
  * 如果在任务上线系统之前验证过的,就不用了
  * 如果还没验证,就启动任务,并送礼
  * @param $task
  * @param $uid
  *
  * @return mixed
  *
  */
 public function check($task, $uid)
 {
     $this->task = $task;
     $this->uid = $uid;
     /**
      * 获取用户对应的task_user的数据
      * 如果已经验证了,但是又没有为这个用户插入这个任务的话
      * 即在 任务系统上线前 就已经认证的用户 此时要插入一条完成了任务的数据
      */
     $model = new Model();
     $userTask = $model->find('select * from video_task_user where vtask_id=' . $task['vtask_id'] . ' and uid=' . $uid);
     $user = $model->find('select * from video_user where uid=' . $uid);
     if ($user['safemail'] && !$userTask) {
         $c = serialize(array('csc' => 100, 'update_time' => time()));
         $data = array('uid' => $uid, 'vtask_id' => $task['vtask_id'], 'status' => 1, 'csc' => $c, 'apply_date' => time(), 'init_time' => date('Y-m-d H:i:s'), 'dml_flag' => 1);
         $model->add('video_task_user', $data);
         // 当完成后的加上1个完成用户
         $this->updateTaskAchievers($task);
         return 'all';
     }
     /**
      * 既没验证 又没申请任务的
      * 做自动申请操作 等待邮箱的安全验证
      * 就返回false
      *
      */
     if (!$user['safemail'] && !$userTask) {
         $c = serialize(array('csc' => 0, 'update_time' => time()));
         $data = array('uid' => $uid, 'vtask_id' => $task['vtask_id'], 'status' => 0, 'csc' => $c, 'apply_date' => time(), 'init_time' => date('Y-m-d H:i:s'), 'dml_flag' => 1);
         $model->add('video_task_user', $data);
         // 增加一个申请人数
         $this->updateTaskApplicants($task);
         return 'doing';
     }
     /**
      * 完成且领取奖励
      */
     if ($userTask['status'] == 1) {
         return 'all';
     }
     /**
      * 失败的
      */
     if ($userTask['status'] == -1) {
         return 'failed';
     }
     /**
      * 完成了,且等待领取奖励
      */
     $csc = unserialize($userTask['csc']);
     if ($csc['csc'] == 100 && $userTask['status'] == 0) {
         return 'success';
     }
     /**
      * 当进度不是满的,此时要检查下完成情况
      * 进行更新与否的判断和操作
      * 如果用户已经完成了邮箱的验证 就更新状态
      */
     if ($csc['csc'] != 100) {
         if ($user['safemail']) {
             $csc['csc'] = 100;
             $csc['update_time'] = time();
             $model->flush('video_task_user', array('csc' => serialize($csc)), array('auto_id' => $userTask['auto_id']));
             return 'success';
         }
         return 'doing';
     }
 }