Beispiel #1
0
 /**
  * 诚信认证图片上传
  */
 public function actionAuthPictures()
 {
     $user_id = Cookie::getInstance()->getCookie('bhy_id')->value;
     $data = $this->thumb();
     // 保存数据
     if (1 == $data['status']) {
         //删除旧图片
         if ($photo = UserPhoto::getInstance()->getPhotoList($user_id, $this->get['type'])) {
             $thumb_path = __DIR__ . "/../.." . $photo[0]['thumb_path'];
             if (is_file($thumb_path) && unlink($thumb_path)) {
                 $pic_path = str_replace('thumb', 'picture', $thumb_path);
                 unlink($pic_path);
             }
             $photo[0]['thumb_path'] = $data['thumb_path'];
             $photo[0]['pic_path'] = $data['pic_path'];
             $photo[0]['update_time'] = $data['time'];
             $photo[0]['is_check'] = 2;
             if (!UserPhoto::getInstance()->savePhoto($photo, $user_id, $photo[0]['type'])) {
                 $data = ['status' => -1, 'info' => '保存失败!~'];
             }
         } else {
             $photo['type'] = $this->get['type'];
             $photo['thumb_path'] = $data['thumb_path'];
             $photo['pic_path'] = $data['pic_path'];
             $photo['time'] = $data['time'];
             if (!UserPhoto::getInstance()->addPhoto($user_id, $photo)) {
                 $data = ['status' => -1, 'info' => '保存失败!~'];
             }
         }
     }
     $this->renderAjax($data);
 }
Beispiel #2
0
 /**
  * 添加管理员用户
  * @param $id
  * @param $data
  */
 public function addAdminUser($id, $data)
 {
     $member['id'] = $id;
     $member['phone'] = $data['phone'];
     $member['personalized'] = $data['introduction'];
     $member['info']['real_name'] = $data['name'];
     $member['info']['qq'] = isset($data['qq']) && !empty($data['qq']) ? $data['qq'] : '';
     $member['info']['wechat'] = isset($data['wechat']) && !empty($data['wechat']) ? $data['wechat'] : '';
     $member['password'] = $data['password'];
     $member['sex'] = !empty($data['sex']) ? $data['sex'] : 1;
     if (\common\models\User::getInstance()->addUser($member) && !empty($data['photo'])) {
         $photo['type'] = 1;
         $photo['thumb_path'] = $data['photo'];
         $photo['pic_path'] = str_replace('thumb', 'picture', $data['photo']);
         $photo['time'] = time();
         $photo['is_check'] = 1;
         UserPhoto::getInstance()->addPhoto($id, $photo, 1);
     } else {
         return false;
     }
     return true;
 }
Beispiel #3
0
 public function upPhoto($user_id, $type, $data, $headPic = '')
 {
     $photo = $type == 1 ? $data : explode(',', $data);
     $arr = [];
     foreach ($photo as $k => $v) {
         $arr[$k]['pic_path'] = str_replace('thumb', 'picture', $v);
         $arr[$k]['thumb_path'] = $v;
         $arr[$k]['is_check'] = 1;
         $arr[$k]['time'] = time();
         $arr[$k]['type'] = $type;
         /*if($type != 1) {
               $arr[$k]['type'] = $type;
           } else {
               UserPhoto::getInstance()->addPhoto($user_id, $arr[$k]);
           }*/
     }
     // 上传照片
     $photoType = count($arr) == 0 ? 1 : $arr[0]['type'];
     UserPhoto::getInstance()->savePhoto($arr, $user_id, $photoType, $headPic);
     if ($type != 1) {
         $user = (new Query())->select('*')->from($this->tablePrefix . 'user_information')->where(['user_id' => $user_id])->one();
         // 修改用户认证值
         if (($type == 2 || $type == 3) && ($card = UserPhoto::getInstance()->getPhotoList($user_id, 23))) {
             if (count($card) == 2 && !($user['honesty_value'] & 1)) {
                 $user['honesty_value'] = $user['honesty_value'] + 1;
             } elseif ($user['honesty_value'] & 1) {
                 $user['honesty_value'] = $user['honesty_value'] - 1;
             }
             $userInfo['has_identify'] = 1;
         } elseif ($type == 4) {
             if (!($user['honesty_value'] & 4)) {
                 $user['honesty_value'] = $user['honesty_value'] + 4;
             }
         } elseif ($type == 5) {
             if (!($user['honesty_value'] & 2)) {
                 $user['honesty_value'] = $user['honesty_value'] + 2;
             }
         } elseif ($type == 6) {
             if (!($user['honesty_value'] & 8)) {
                 $user['honesty_value'] = $user['honesty_value'] + 8;
             }
         }
         $userInfo['honesty_value'] = $user['honesty_value'];
         // 修改认证值
         $this->getDb()->createCommand()->update($this->tablePrefix . 'user_information', $userInfo, ['user_id' => $user_id])->execute();
         $this->getDb()->createCommand()->update($this->tablePrefix . 'user', ['status' => 2], ['id' => $user_id])->execute();
         //UserInformation::getInstance()->updateUserInfo($user_id, ['honesty_value' => $user['honesty_value']]);
         //$this->getDb()->createCommand()->update($this->tablePrefix.'user_information', ['honesty_value' => $user['honesty_value']], ['user_id' => $user_id])->execute();
     }
 }
Beispiel #4
0
 public function actionGetPicIsCheck()
 {
     $data = $this->post;
     $photo = UserPhoto::getInstance()->queryPicIsCheckByPath($data['thumb_path']);
     if (!$photo || $photo['is_check'] != 1) {
         $this->renderAjax(['status' => 0, 'msg' => '照片不存在或未审核的照片!']);
     } else {
         $this->renderAjax(['status' => 1, 'msg' => '该照片可以设为头像', 'data' => $photo]);
     }
 }
Beispiel #5
0
 public function indexIsShowData($user_id)
 {
     if ($user_id) {
         $blacked = UserFollow::getInstance()->getFollowList('blacked', $user_id);
         $follow = UserFollow::getInstance()->getFollowList('followed', $user_id);
         $blackedList = [];
         $followList = [];
         foreach ($blacked as $k => $v) {
             $blackedList[] = $v['user_id'];
         }
         foreach ($follow as $k => $v) {
             $followList[] = $v['user_id'];
         }
         $honestyStatus = UserPhoto::getInstance()->getPhotoList($user_id, 2, 2);
         $headpicStatus = UserPhoto::getInstance()->userHeadpic($user_id);
         return ['status' => 1, 'blacked' => $blackedList, 'follow' => $followList, 'honestyStatus' => $honestyStatus, 'headpicStatus' => $headpicStatus];
     } else {
         return ['status' => 1, 'blacked' => [], 'follow' => [], 'honestyStatus' => [], 'headpicStatus' => []];
     }
 }
Beispiel #6
0
 public function checkPhoto($user_id, $type, $honesty_value)
 {
     if ($data = UserPhoto::getInstance()->getPhotoList($user_id, $type, 1)) {
         if ($data[0]['is_check'] == 1) {
             if ($type == 5) {
                 $honesty_value = $honesty_value + 2;
             } elseif ($type == 4) {
                 $honesty_value = $honesty_value + 4;
             } elseif ($type == 6) {
                 $honesty_value = $honesty_value + 8;
             }
             UserInformation::getInstance()->updateUserInfo($user_id, ['honesty_value' => $honesty_value]);
             return 1;
         } elseif ($data[0]['is_check'] == 0) {
             return 0;
         } else {
             return 2;
         }
     } else {
         return '';
     }
 }