Exemple #1
0
 public function run()
 {
     $id = intval($this->getDataItem('id', 0));
     if (0 < $id) {
         $this->question = Question::query()->columns(['u.user_id', 'u.user_nickname', 'u.user_cover', 'Apps\\Common\\Models\\Question.question_id as question_id', 'Apps\\Common\\Models\\Question.question_content as question_content', 'Apps\\Common\\Models\\Question.question_pics as question_pics', 'Apps\\Common\\Models\\Question.answer_num as answer_num', 'Apps\\Common\\Models\\Question.question_follows as follow_num', '0 user_is_follow', 'Apps\\Common\\Models\\Question.question_addtime as addtime'])->leftJoin('Apps\\Common\\Models\\UserBase', 'Apps\\Common\\Models\\Question.user_id=u.user_id', 'u')->where('Apps\\Common\\Models\\Question.question_id= :id: and Apps\\Common\\Models\\Question.question_state > 0')->bind(['id' => $id])->execute()->getFirst();
     } else {
         return $this->errorLog(ResultStatus::POST_BODY_PARAM_ERROR, '参数异常');
     }
     if ($this->question) {
         if (unserialize(base64_decode($this->question->question_content))) {
             $this->question->question_content = unserialize(base64_decode($this->question->question_content));
         }
         $this->question->question_pics = PicUrl::Question(json_decode($this->question->question_pics), $this->getDi());
         $this->question->addtime = \Apps\Common\Libs\DateTime::Format($this->question->addtime);
         $this->question->user_cover = PicUrl::UserCover($this->question->user_cover, $this->getDi());
         $this->verifyUserAuth(false);
         $userId = $this->getUserAuth() ? $this->getUserAuth()->userId : 0;
         if ($userId > 0) {
             $count = QuestionFollow::count(['conditions' => 'question_id = :qid: AND user_id = :uid:', 'bind' => ['qid' => $id, 'uid' => $userId]]);
             $this->question->user_is_follow = $count > 0 ? 1 : 0;
         }
     } else {
         $this->question = null;
     }
     $this->setResult($this->question);
 }
Exemple #2
0
 public function run()
 {
     if (!$this->verifyUserAuth()) {
         return false;
     }
     $id = intval($this->getDataItem('id', 0));
     $user_id = intval($this->getDataItem('user_id', 0));
     $content = $this->getDataItem('content', '');
     if ($id == 0 || $user_id == 0) {
         $this->errorLog(ResultStatus::URL_PARAM_CANNOT_EMPTY, 'URL参数不全');
         return false;
     }
     $contentLenth = $this->utf8_strlen($content);
     if ($contentLenth < 1 || $contentLenth > 100) {
         $this->errorLog(ResultStatus::POST_BODY_FORMAT_ERROR, '评论字符应在1~100之间.');
         return false;
     }
     $ActivityComment = new ActivityComment();
     $date = date('Y-m-d H:i:s');
     $data = ['comment_user_id' => $user_id, 'comment_content' => $content, 'addtime' => $date, 'activity_id' => $id];
     if ($ActivityComment->save($data)) {
         $ActivityComment->getReadConnection()->query("UPDATE activity SET comments = comments + 1 WHERE activity_id = {$id}");
         $userInfo = UserBase::getOne($user_id);
         $this->setResult(['comment_id' => $ActivityComment->comment_id, 'user_id' => $user_id, 'comment_content' => $content, 'addtime' => $date, 'user_gender' => $userInfo['user_gender'], 'user_cover' => PicUrl::ActivityCover($userInfo['user_cover'], $this->getDi())]);
     } else {
         $this->errorLog(ResultStatus::ERROR, '评论失败.');
     }
 }
Exemple #3
0
 public function run()
 {
     $to_user_id = $this->getDataItem('user_id');
     if (!(is_numeric($to_user_id) && $to_user_id > 0)) {
         return $this->errorLog(ResultStatus::POST_BODY_PARAM_ERROR, '用户id不能为空.');
     }
     /**
      * 验证用户权限
      */
     /*if(!empty($this->parameters->userToken) && $this->verifyUserAuth() && $this->getUserAuth()->userId == $userid){
           return $this->errorLog(111, '请跳转我的问答.');
       }*/
     $field = ['user_cover', 'user_nickname', 'user_gender', 'user_birthday', 'user_realname', 'user_district', 'user_money', 'user_money_virtual', 'bind_phone user_mobile', 'persional_sign', 'user_expert'];
     $info = UserBase::query()->columns($field)->where('user_id=' . $to_user_id)->execute()->getFirst()->toArray();
     // 获取城市信息
     $SysAreaZipDistrictPhonecode = new SysAreaZipDistrictPhonecode();
     $city = $SysAreaZipDistrictPhonecode->getOne($info['user_district']);
     $info['user_district'] = $city['FULL_NAME'] ?: '';
     // 加入关注数和粉丝数
     $UserFollow = new UserFollow();
     $info['follow_count'] = $UserFollow->getFollowCount($to_user_id, 1);
     $info['fans_count'] = $UserFollow->getToFollowCount($to_user_id, 1);
     $info['user_cover'] = $info['user_cover'] ? PicUrl::UserCover($info['user_cover'], $this->getDi()) : '';
     $info['persional_sign'] = $info['persional_sign'] ? unserialize(base64_decode($info['persional_sign'])) : '';
     $this->verifyUserAuth(false);
     if ($user_id = $this->getUserAuth()->userId) {
         $info['is_follow'] = $UserFollow->is_follow($user_id, $to_user_id, 1) ? '1' : '0';
     } else {
         $info['is_follow'] = '0';
     }
     $this->setResult($info);
 }
Exemple #4
0
 public function run()
 {
     $id = intval($this->getDataItem('id', 0));
     if (0 < $id) {
         $this->activity = Activity::query()->columns(['activity_id id', 'city_id city', 'activity_type type', 'activity_title as title', 'activity_intro as intro', '0 beauty_parlors'])->where('activity_id=:id:')->bind(['id' => $id])->execute()->getFirst();
         if ($this->activity) {
             $parlor = ActivityBeautyParlor::query()->columns(['bp_id as id', 'bp_name as name', 'bp_cover as cover', 'bp_address as address', '0 as tags', 'bp_medal as medal'])->leftJoin('Apps\\Common\\Models\\BeautyParlor', 'Apps\\Common\\Models\\ActivityBeautyParlor.beauty_parlor_id=bp.bp_id', 'bp')->where('bp.bp_state > 0 and activity_id = :id:')->bind(['id' => $id])->execute()->toArray();
             $this->activity->beauty_parlors = $parlor;
         }
     }
     $this->activity = $this->activity ? $this->activity : null;
     if ($this->activity) {
         //$this->activity->cover = PicUrl::ActivityCover($this->activity->cover, $this->getDi());
         for ($i = 0; $i < count($this->activity->beauty_parlors); $i++) {
             $this->activity->beauty_parlors[$i]['cover'] = PicUrl::BeautyParlorCover($this->activity->beauty_parlors[$i]['cover'], $this->getDi());
             $medal = $this->activity->beauty_parlors[$i]['medal'];
             unset($this->activity->beauty_parlors[$i]['medal']);
             $this->activity->beauty_parlors[$i]['medal_refund'] = \Apps\Common\Libs\BeautyParlor::getMedalRefund($medal);
             $this->activity->beauty_parlors[$i]['medal_verify'] = \Apps\Common\Libs\BeautyParlor::getMedalVerify($medal);
             $this->activity->beauty_parlors[$i]['tags'] = \Apps\Common\Libs\BeautyParlor::getTags($this->activity->beauty_parlors[$i]['id']);
         }
         $this->activity->intro = \Apps\Common\Libs\BeautyParlor::formatServiceIntro($this->activity->intro, $this->getDi(), true);
     }
     $this->setResult($this->activity);
 }
Exemple #5
0
 public function run()
 {
     $id = intval($this->getDataItem('id', 0));
     $page = intval($this->getDataItem('page', 1));
     $limit = $this->getConfig()->limit;
     $offset = ($page - 1) * $limit;
     if (0 < $id) {
         $service = BeautyParlorService::query()->columns(['service_id id', 'service_cover cover', 'service_name name', 'service_price price', 'service_unit unit', 'service_description description'])->where('service_state>0 and service_is_sell = 1 and beauty_parlor_id=:bid:')->bind(['bid' => $id])->limit($limit, $offset)->execute()->toArray();
     } else {
         return $this->errorLog(ResultStatus::URL_PARAM_CANNOT_EMPTY, '参数异常');
     }
     $services = [];
     if ($service) {
         foreach ($service as $d) {
             $d['cover'] = PicUrl::BeautyParlorCover($d['cover'], $this->getDi());
             $unit = $d['unit'];
             unset($d['unit']);
             $d['price_show'] = '';
             if ($d['price'] > 0) {
                 $d['price_show'] = $d['price'] . '元' . ($unit ? '/' . $unit : '');
             }
             $services[] = $d;
         }
         $this->setResult($services);
     } else {
         $this->setResult($services);
     }
 }
 public function run()
 {
     /**
      * 验证用户权限,但不抛错
      */
     /*$this->verifyUserAuth(false);
      	$user_id = $this->getUserAuth()->userId;*/
     $user_id = intval($this->getDataItem('user_id', 0));
     $page = intval($this->getDataItem('page', 1));
     $limit = $this->getConfig()->limit;
     $offset = ($page - 1) * $limit;
     if ($user_id > 0) {
         $list = UserBase::query()->columns(['Apps\\Common\\Models\\UserBase.user_id', 'user_nickname', 'user_cover', 'expert_follow_count', 'f.to_user_id', 'a.attr_value_json'])->leftJoin('Apps\\Common\\Models\\UserFollow', "Apps\\Common\\Models\\UserBase.user_id = f.to_user_id and f.user_id = {$user_id} and f.type = 2", 'f')->leftJoin('Apps\\Common\\Models\\UserAttribute', 'a.user_id = f.to_user_id and a.attr_type = 103 and a.attr_state = 1', 'a')->where('user_expert = 1 and user_state = 1')->orderBy('f.id DESC, expert_follow_count DESC')->limit($limit, $offset)->execute()->toArray();
     } else {
         $list = UserBase::query()->columns(['Apps\\Common\\Models\\UserBase.user_id', 'user_nickname', 'user_cover', 'expert_follow_count', 'a.attr_value_json'])->leftJoin('Apps\\Common\\Models\\UserAttribute', 'a.user_id = Apps\\Common\\Models\\UserBase.user_id and a.attr_type = 103 and a.attr_state = 1', 'a')->where('user_expert = 1 and user_state = 1')->orderBy('expert_follow_count DESC')->limit($limit, $offset)->execute()->toArray();
     }
     foreach ($list as $k => $val) {
         $list[$k]['user_cover'] = PicUrl::ActivityCover($val['user_cover'], $this->getDi());
         // 获取专家的扩展信息
         $info = $val['attr_value_json'] ? json_decode($val['attr_value_json']) : [];
         $list[$k]['experience'] = $info->experience ?: '0';
         // 从业经验
         $list[$k]['experttitle'] = $info->experttitle ?: '';
         // 擅长领域
         $list[$k]['field'] = $info->field ?: [];
         // 专家头衔(array)
         $list[$k]['is_follow'] = $val['to_user_id'] ? '1' : '0';
         unset($list[$k]['to_user_id'], $list[$k]['attr_value_json']);
     }
     $this->setResult($list);
 }
Exemple #7
0
 public function run()
 {
     /**
      * 验证用户权限
      */
     if (false == $this->verifyUserAuth()) {
         return false;
     }
     $area = ['user_cover', 'user_nickname', 'user_gender', 'user_birthday', 'user_realname', 'user_district', 'user_money', 'user_money_virtual', 'user_mobile', 'persional_sign'];
     $fields = $this->getDataItem('fields');
     //字段
     $fields = explode(',', $fields);
     foreach ($fields as $f) {
         if (!in_array($f, $area)) {
             return $this->errorLog(ResultStatus::POST_BODY_PARAM_ERROR, '字段名不存在.');
         }
     }
     $user = UserBase::find('user_id=' . $this->getUserAuth()->userId)->toArray();
     $user = $user[0];
     $fieldsArr = ['user_cover' => 'user_cover', 'user_nickname' => 'user_nickname', 'user_gender' => 'user_gender', 'user_birthday' => 'user_birthday', 'user_realname' => 'user_realname', 'user_district' => 'user_district', 'user_money' => 'user_money', 'user_money_virtual' => 'user_money_virtual', 'user_mobile' => 'user_account', 'persional_sign' => 'persional_sign'];
     $result = [];
     foreach ($fields as $field) {
         $key = $fieldsArr[$field];
         $value = $user[$key];
         if ($field == 'user_cover') {
             $value = PicUrl::UserCover($value, $this->getDi());
         }
         if ($field == 'persional_sign' && unserialize(base64_decode($value))) {
             $value = unserialize(base64_decode($value));
         }
         $result[$key] = $value;
     }
     $this->setResult($result);
 }
Exemple #8
0
 /**
  * 格式化服务项目详情
  * @param $json
  * @param $di
  * @param bool $css
  * @return string
  */
 public static function formatServiceIntro($json, $di, $css = false)
 {
     $data = json_decode($json, true);
     if (is_array($data) == false) {
         return $json;
     }
     $cssStyle = '<style type="text/css">.item {width: 100%; color:#666666;}.item img{width: 100%; margin:5pt 0; padding: 0;}.item p{margin: 0;padding: 5pt 0;line-height: 1.4;}.item h3 {margin: 0;padding: 5pt 0;}</style>';
     $html = '<div class="item">';
     foreach ($data as $d) {
         $v = $d['value'];
         switch ($d['type']) {
             case 'img':
                 $html .= '<img class="img" src="' . PicUrl::BeautyParlorPic($v, $di) . '">';
                 break;
             case 'text':
                 $html .= '<p class="text">' . $v . '</p>';
                 break;
             case 'title':
                 $html .= '<h3 class="title">' . $v . '</h3>';
                 break;
         }
     }
     $html .= '</div>';
     return $css ? $cssStyle . $html : $html;
 }
Exemple #9
0
 public function run()
 {
     $questionId = intval($this->getDataItem('question_id', 0));
     $user_id = intval($this->getDataItem('user_id', 0));
     $page = intval($this->getDataItem('page', 1));
     //        $questionId = 194;
     if ($questionId < 1) {
         return $this->errorLog(ResultStatus::POST_BODY_PARAM_ERROR, '参数不完整或者参数错误!');
     }
     $limit = $this->getConfig()->limit;
     $offset = ($page - 1) * $limit;
     $QuestionAnswer = new QuestionAnswer();
     $expertReplyList = $QuestionAnswer->query()->columns(['u.user_id', 'u.user_cover', 'u.user_nickname', 'u.user_gender', 'answer_id', 'answer_content', 'original_content', 'support_count', 'answer_addtime', 'answer_pics'])->leftJoin('\\Apps\\Common\\Models\\UserBase', 'u.user_id = \\Apps\\Common\\Models\\QuestionAnswer.user_id', 'u')->where("answer_state = 1 and type = 1 and question_id = {$questionId}")->orderBy('answer_addtime DESC')->limit($limit, $offset)->execute()->toArray();
     $QuestionAnswerFollow = new QuestionAnswerFollow();
     foreach ($expertReplyList as $k => $val) {
         $expertReplyList[$k]['user_cover'] = PicUrl::UserCover($val['user_cover'], $this->getDi());
         $expertReplyList[$k]['answer_content'] = unserialize(base64_decode($val['answer_content'])) ?: $val['answer_content'];
         if ($user_id > 0) {
             $expertReplyList[$k]['is_support'] = $QuestionAnswerFollow->is_support($user_id, $val['answer_id']) ? '1' : '0';
         } else {
             $expertReplyList[$k]['is_support'] = '0';
         }
         $answer_pics = [];
         if ($answer_pics_list = json_decode($val['answer_pics'], true)) {
             foreach ($answer_pics_list as $value) {
                 $answer_pics[] = PicUrl::Question($value, $this->getDi());
             }
         }
         $expertReplyList[$k]['answer_pics'] = $answer_pics;
     }
     $this->setResult($expertReplyList);
 }
 public function run()
 {
     $page = intval($this->getDataItem('page', 1));
     $keyword = $this->getDataItem('keyword');
     $city_code = trim($this->getDataItem('city_code'));
     if ($city_code == null || $city_code == '') {
         return $this->errorLog(ResultStatus::POST_BODY_PARAM_ERROR, "城市编码为空");
         exit;
     }
     $is_open = SysOpenCity::findFirst(['columns' => "city_id", 'conditions' => "city_code = {$city_code} AND city_state = 1"]);
     if (!$is_open->city_id > 0) {
         return $this->errorLog(ResultStatus::CITY_NOT_OPEN, "城市未开通");
         exit;
     }
     //根据城市编码 获取 城市区
     $city = SysAreaZipDistrictPhonecode::query()->columns(['K_ID'])->where("PHONE_CODE = {$city_code}")->execute()->toArray();
     foreach ($city as $k) {
         $citys[] = $k['K_ID'];
     }
     $citys = implode(',', $citys);
     $count = $this->getConfig()->limit;
     if (empty($keyword)) {
         $offset = ($page - 1) * $count;
         $list = BeautyParlorServiceModel::query()->columns(['service_id id', 'service_cover cover', 'service_name name', 'service_price price', 'service_unit unit', 'service_description description', 'b.bp_id', 'b.bp_name'])->leftJoin('Apps\\Common\\Models\\BeautyParlor', 'Apps\\Common\\Models\\BeautyParlorService.beauty_parlor_id = b.bp_id', 'b')->where("Apps\\Common\\Models\\BeautyParlorService.service_state = 1 and b.bp_state = 1 AND b.bp_district in ({$citys})")->limit($count, $offset)->execute()->toArray();
         foreach ($list as $k => $v) {
             $unit = $v['unit'];
             unset($v['unit']);
             $list[$k]['price_show'] = '';
             if ($v['price'] > 0) {
                 $list[$k]['price_show'] = $v['price'] . '元' . ($unit ? '/' . $unit : '');
             }
             $list[$k]['cover'] = PicUrl::BeautyParlorCover($list[$k]['cover'], $this->getDi());
         }
         $this->setResult($list);
     } else {
         /*多关键字搜索*/
         $keywordarr = explode(" ", trim($keyword));
         foreach ($keywordarr as $r) {
             $wherearr[] = "Apps\\Common\\Models\\BeautyParlorService.service_name like '%" . $r . "%'";
         }
         $where = implode(" or ", $wherearr);
         ////////////////////////////////////////////////////////////////
         /* $limit = $this->getConfig()->limit;
            $offset = ($page-1) * $limit;
            $data = $this->searchBPS($keyword, $limit, $offset);
            $this->setResult($data); */
         $offset = ($page - 1) * $count;
         $list = BeautyParlorServiceModel::query()->columns(['service_id id', 'service_cover cover', 'service_name name', 'service_price price', 'service_unit unit', 'service_description description', 'b.bp_id', 'b.bp_name'])->leftJoin('Apps\\Common\\Models\\BeautyParlor', 'Apps\\Common\\Models\\BeautyParlorService.beauty_parlor_id = b.bp_id', 'b')->where("{$where} and Apps\\Common\\Models\\BeautyParlorService.service_state = 1 and b.bp_state = 1 AND b.bp_district in ({$citys})")->limit($count, $offset)->execute()->toArray();
         foreach ($list as $k => $v) {
             $unit = $v['unit'];
             unset($list[$k]['unit']);
             $list[$k]['price_show'] = '';
             if ($v['price'] > 0) {
                 $list[$k]['price_show'] = $v['price'] . '元' . ($unit ? '/' . $unit : '');
             }
             $list[$k]['cover'] = PicUrl::BeautyParlorCover($list[$k]['cover'], $this->getDi());
         }
         $this->setResult($list);
     }
 }
 /**
  * 获取浏览记录的用户列表
  * @param int $question_id 问题id
  * @param int $offset 分页偏移量
  * @param int $limit 页大小
  * @return array
  */
 public function getViewsUserList($question_id, $offset = 0, $limit = 10)
 {
     $list = $this->query()->columns(['u.user_id', 'u.user_cover'])->where('question_id = ' . $question_id)->leftJoin('\\Apps\\Common\\Models\\UserBase', 'u.user_id = \\Apps\\Common\\Models\\QuestionViewsUser.user_id', 'u')->groupBy('\\Apps\\Common\\Models\\QuestionViewsUser.user_id')->orderBy('add_time DESC')->limit($limit, $offset)->execute()->toArray();
     foreach ($list as $k => $val) {
         $list[$k]['user_cover'] = PicUrl::UserCover($val['user_cover'], $this->getDi());
     }
     return $list;
 }
Exemple #12
0
 public function run()
 {
     $his_id = $this->getDataItem('his_id');
     //要查询用户的id
     $type = $this->getDataItem('type', '');
     $page = intval($this->getDataItem('page', 1));
     /**
      * 验证用户权限
      */
     if (!empty($this->parameters->userToken) && true == $this->verifyUserAuth()) {
         if ($this->getUserAuth()->userId == $his_id) {
             return $this->errorLog(111, '请跳转我的问答.');
         }
     }
     $limit = $this->getConfig()->limit;
     $offset = ($page - 1) * $limit;
     $typeArray = ['his', 'his_answer', 'his_follow'];
     if (!in_array($type, $typeArray)) {
         return $this->errorLog(ResultStatus::POST_BODY_PARAM_ERROR, '查询的类型不存在.');
     }
     $columns = ['u.user_id', 'u.user_nickname', 'u.user_cover', 'Apps\\Common\\Models\\Question.question_id question_id', 'Apps\\Common\\Models\\Question.question_content question_content', 'Apps\\Common\\Models\\Question.question_pics question_pics', 'Apps\\Common\\Models\\Question.answer_num answer_num', 'Apps\\Common\\Models\\Question.question_browsers browser_num', 'Apps\\Common\\Models\\Question.question_follows follow_num', 'Apps\\Common\\Models\\Question.question_addtime addtime'];
     $userId = $his_id;
     $data = [];
     switch ($type) {
         case 'his':
             $data = $this->getHis($userId, $columns, $limit, $offset);
             break;
         case 'his_answer':
             $data = $this->getAnswer($userId, $limit, $offset);
             break;
         case 'his_follow':
             $data = $this->getFollow($userId, $columns, $limit, $offset);
             break;
     }
     $result = [];
     if ($data && count($data) > 0) {
         foreach ($data as $arr) {
             $tmp = PicUrl::Question(json_decode($arr['question_pics']), $this->getDi());
             if (is_string($tmp)) {
                 $arr['question_pics'] = $tmp;
             }
             if (is_array($tmp)) {
                 $arr['question_pics'] = array_slice($tmp, 0, 2);
             }
             //$arr['addtime'] = \Apps\Common\Libs\DateTime::Format($arr['addtime']);
             $arr['user_cover'] = PicUrl::UserCover($arr['user_cover'], $this->getDi());
             if (unserialize(base64_decode($arr['question_content']))) {
                 $arr['question_content'] = unserialize(base64_decode($arr['question_content']));
             }
             $result[] = $arr;
         }
     }
     $this->setResult($result);
 }
Exemple #13
0
 public function run()
 {
     $orders = $this->getDataItem('orders', 1);
     // 排序方式(1=》最新提问,2=》最新回复,3=》人气问答)
     $page = intval($this->getDataItem('page', 1));
     $is_expert_reply = $this->getDataItem('is_expert_reply', 0);
     // 专家是否回复
     //        $city_code = (string)$this->getDataItem('city_code', '0'); // 原型去掉了
     $user_id = intval($this->getDataItem('user_id', 0));
     $keyword = $this->getDataItem('keyword', '');
     $limit = $this->getConfig()->limit;
     $offset = ($page - 1) * $limit;
     $columns = ['question_id', 'question_content', 'question_pics', 'question_tag', 'answer_num', 'question_browsers', 'question_addtime', 'is_expert_reply', 'u.user_id', 'u.user_nickname', 'u.user_expert', 'u.user_cover', 'u.user_gender'];
     switch ($orders) {
         case 2:
             $orders = 'last_reply_time DESC';
             break;
         case 3:
             $orders = 'question_browsers DESC';
             break;
         default:
             $orders = 'question_addtime DESC';
     }
     $where = 'question_state = 1';
     if ($is_expert_reply == 1) {
         $where .= ' and is_expert_reply = 1';
     }
     if ($keyword) {
         $where .= " and question_content like '%{$keyword}%'";
     }
     $list = Question::query()->columns($columns)->leftJoin('\\Apps\\Common\\Models\\UserBase', 'u.user_id = \\Apps\\Common\\Models\\Question.user_id', 'u')->where($where)->orderBy($orders)->limit($limit, $offset)->execute()->toArray();
     $QuestionFollow = new QuestionFollow();
     foreach ($list as $k => $val) {
         // 是否收藏过
         if ($user_id) {
             $list[$k]['is_collection'] = $QuestionFollow->is_follow($val['question_id'], $user_id);
         } else {
             $list[$k]['is_collection'] = '0';
         }
         $list[$k]['question_tag'] = $val['question_tag'] ? json_decode($val['question_tag'], true) : [];
         $list[$k]['user_cover'] = PicUrl::UserCover($val['user_cover'], $this->getDi());
         $list[$k]['question_content'] = unserialize(base64_decode($val['question_content'])) ?: $val['question_content'];
         if ($val['question_pics']) {
             $question_pics = [];
             foreach (json_decode($val['question_pics'], true) as $key => $value) {
                 $question_pics[] = PicUrl::Question($value, $this->getDi());
             }
             $list[$k]['question_pics'] = $question_pics;
         }
     }
     $this->setResult($list);
 }
Exemple #14
0
 public function run()
 {
     /* $jpush=new Jpush();
       	$param['type'] =1;
       	$param['ispushservice']=1;
       	$param['phone'] ='18623640927';
       	$param['content'] ="HAHHA";
       	$jpush->setval($param);
       	$a=$jpush->push();
       	var_dump($a);
       	exit; */
     $questionId = intval($this->getDataItem('question_id', 0));
     $page = intval($this->getDataItem('page', 1));
     $limit = $this->getConfig()->limit;
     $offset = ($page - 1) * $limit;
     $this->verifyUserAuth(false);
     $userId = $this->getUserAuth() ? $this->getUserAuth()->userId : 0;
     if (0 < $questionId) {
         $this->answers = QuestionAnswer::listByQuestionId($questionId, $limit, $offset, $userId)->toArray();
     } else {
         $this->errorLog(ResultStatus::URL_PARAM_CANNOT_EMPTY, 'question id');
     }
     $this->answers = $this->answers ? $this->answers : [];
     $data = [];
     $dataBest = null;
     foreach ($this->answers as $arr) {
         $arr['user_cover'] = PicUrl::UserCover($arr['user_cover'], $this->getDi());
         $arr['answer_pics'] = PicUrl::Question(json_decode($arr['answer_pics']), $this->getDi());
         $arr['addtime'] = \Apps\Common\Libs\DateTime::Format($arr['addtime']);
         if (unserialize(base64_decode($arr['answer_content']))) {
             $arr['answer_content'] = unserialize(base64_decode($arr['answer_content']));
         }
         // 处理最佳答案
         $best = $arr['answer_best'];
         if ($best > 5 && $page == 1) {
             if ($dataBest == null) {
                 $dataBest = $arr;
                 continue;
             } elseif ($dataBest['answer_best'] < $best) {
                 $dataBest = $arr;
                 continue;
             }
         }
         $arr['answer_best'] = 0;
         $data[] = $arr;
     }
     if ($dataBest != null) {
         $dataBest['answer_best'] = 1;
         array_splice($data, 0, 0, [$dataBest]);
     }
     $this->setResult($data);
 }
Exemple #15
0
 public function run()
 {
     $tag_id = intval($this->getDataItem('tag_id', 0));
     $page = intval($this->getDataItem('page', 1));
     $limit = $this->getConfig()->limit;
     $offset = ($page - 1) * $limit;
     $columns = ['u.user_id', 'u.user_nickname', 'u.user_cover', 'question_id', 'question_content', 'question_pics', 'answer_num', 'question_browsers browser_num', 'question_follows follow_num', 'question_addtime addtime'];
     if (-2 == $tag_id) {
         //精华
         /*
         $this->questions = Question::query()
             ->columns($columns)
             ->leftJoin('Apps\Common\Models\UserBase',
                 'Apps\Common\Models\Question.user_id = u.user_id','u')
             ->where('question_state = 2')
             ->orderBy('question_id desc')
             ->limit($limit,$offset)
             ->execute()->toArray();
         */
         $this->questions = Question::query()->columns($columns)->leftJoin('Apps\\Common\\Models\\UserBase', 'Apps\\Common\\Models\\Question.user_id = u.user_id', 'u')->where('question_state > 0')->orderBy('answer_num desc')->limit($limit, $offset)->execute()->toArray();
     } else {
         if (-1 == $tag_id) {
             //最热
             $this->questions = Question::query()->columns($columns)->leftJoin('Apps\\Common\\Models\\UserBase', 'Apps\\Common\\Models\\Question.user_id = u.user_id', 'u')->where('question_state > 0')->orderBy('question_browsers desc,question_follows desc')->limit($limit, $offset)->execute()->toArray();
         } else {
             if (0 == $tag_id) {
                 //默认
                 $this->questions = Question::query()->columns($columns)->leftJoin('Apps\\Common\\Models\\UserBase', 'Apps\\Common\\Models\\Question.user_id = u.user_id', 'u')->where('question_state>0')->orderBy('question_id desc')->limit($limit, $offset)->execute()->toArray();
             } else {
                 //指定条件
                 $this->questions = Question::query()->columns($columns)->leftJoin('Apps\\Common\\Models\\UserBase', 'Apps\\Common\\Models\\Question.user_id = u.user_id', 'u')->where('question_state > 0 and question_tag = :question_tag:')->bind(['question_tag' => $tag_id])->orderBy('question_id desc')->limit($limit, $offset)->execute()->toArray();
             }
         }
     }
     $this->questions = $this->questions ? $this->questions : [];
     $data = [];
     foreach ($this->questions as $arr) {
         $arr['question_pics'] = PicUrl::Question(json_decode($arr['question_pics']), $this->getDi());
         if (is_string($arr['question_pics'])) {
             $arr['question_pics'] = $arr['question_pics'];
         }
         if (is_array($arr['question_pics']) && count($arr['question_pics']) > 2) {
             $arr['question_pics'] = array_slice($arr['question_pics'], 0, 2);
         }
         $arr['addtime'] = \Apps\Common\Libs\DateTime::Format($arr['addtime']);
         $arr['user_cover'] = PicUrl::UserCover($arr['user_cover'], $this->getDi());
         $arr['question_content'] = unserialize(base64_decode($arr['question_content']));
         $data[] = $arr;
     }
     $this->setResult($data);
 }
Exemple #16
0
 public function run()
 {
     $id = intval($this->getDataItem('id', 0));
     $page = intval($this->getDataItem('page', 1));
     $limit = $this->getConfig()->limit;
     if ($id == 0) {
         return $this->errorLog(ResultStatus::URL_PARAM_CANNOT_EMPTY, 'URL参数不全');
     }
     $list = ActivityComment::query()->columns(['comment_id', 'comment_content', 'addtime', 'comment_user_id user_id', 'u.user_nickname', 'u.user_gender', 'u.user_cover'])->leftJoin('\\Apps\\Common\\Models\\UserBase', 'u.user_id = \\Apps\\Common\\Models\\ActivityComment.comment_user_id', 'u')->where('activity_id = ' . $id)->orderBy('addtime DESC')->limit($limit, ($page - 1) * $limit)->execute()->toArray();
     foreach ($list as $k => $val) {
         $list[$k]['user_cover'] = PicUrl::ActivityCover($val['user_cover'], $this->getDi());
     }
     $this->setResult($list);
 }
 public function run()
 {
     $question_id = intval($this->getDataItem('question_id', 0));
     if ($question_id < 1) {
         return $this->errorLog(ResultStatus::URL_PARAM_CANNOT_EMPTY, '参数错误!');
     }
     $QuestionTag = new QuestionTag();
     if ($tagList = $QuestionTag->query()->where('question_id = ' . $question_id)->execute()->toArray()) {
         $tag_id = '';
         foreach ($tagList as $val) {
             $tag_id .= $val['tag_id'] . ',';
         }
         $tag_id = '(' . trim($tag_id, ',') . ')';
         $question_id_list = $QuestionTag->query()->groupBy('question_id')->where("tag_id in{$tag_id} and question_id != {$question_id}")->orderBy('id DESC')->limit(50)->execute()->toArray();
         if ($question_id_list) {
             /*$where_question_id = '';
               foreach ($question_id_list as $val) {
                   $where_question_id .= $val['question_id'] . ',';
               }
               $where_question_id = '(' . trim($where_question_id, ',') . ')';*/
             // 随机取相关问答的id
             $count = count($question_id_list);
             if ($count >= 3) {
                 $start = mt_rand(0, $count - 3);
                 $where_question_id = '(' . $question_id_list[$start]['question_id'] . ',' . $question_id_list[$start + 1]['question_id'] . ',' . $question_id_list[$start + 2]['question_id'] . ')';
             } else {
                 $where_question_id = '';
                 foreach ($question_id_list as $val) {
                     $where_question_id .= $val['question_id'] . ',';
                 }
                 $where_question_id = '(' . trim($where_question_id, ',') . ')';
             }
             $list = Question::query()->columns(['question_id', 'question_content', 'question_pics', 'question_tag', 'answer_num', 'question_browsers', 'question_addtime', 'u.user_id', 'u.user_nickname', 'u.user_expert', 'u.user_cover', 'u.user_gender'])->leftJoin('\\Apps\\Common\\Models\\UserBase', 'u.user_id = \\Apps\\Common\\Models\\Question.user_id', 'u')->where("question_id in{$where_question_id} and question_state = 1")->execute()->toArray();
             foreach ($list as $k => $val) {
                 $list[$k]['question_tag'] = $val['question_tag'] ? json_decode($val['question_tag'], true) : [];
                 $list[$k]['user_cover'] = PicUrl::UserCover($val['user_cover'], $this->getDi());
                 $list[$k]['question_content'] = unserialize(base64_decode($val['question_content'])) ?: $val['question_content'];
                 if ($val['question_pics']) {
                     $question_pics = [];
                     foreach (json_decode($val['question_pics'], true) as $key => $value) {
                         $question_pics[] = PicUrl::Question($value, $this->getDi());
                     }
                     $list[$k]['question_pics'] = $question_pics;
                 }
             }
             $this->setResult($list);
         }
     }
 }
Exemple #18
0
 public function run()
 {
     /*if(false == $this->verifyUserAuth()){
           return false;
       }*/
     $type = $this->getDataItem('type', '');
     $page = intval($this->getDataItem('page', 1));
     $userId = intval($this->getDataItem('user_id', 0));
     $limit = $this->getConfig()->limit;
     $offset = ($page - 1) * $limit;
     $typeArray = ['my', 'answer', 'follow'];
     if (!in_array($type, $typeArray) || $userId < 1) {
         return $this->errorLog(ResultStatus::POST_BODY_PARAM_ERROR, '查询的类型不存在.');
     }
     $columns = ['u.user_id', 'u.user_nickname', 'u.user_gender', 'u.user_cover', 'Apps\\Common\\Models\\Question.question_id question_id', 'Apps\\Common\\Models\\Question.question_content question_content', 'Apps\\Common\\Models\\Question.question_pics question_pics', 'Apps\\Common\\Models\\Question.answer_num answer_num', 'Apps\\Common\\Models\\Question.question_browsers', 'Apps\\Common\\Models\\Question.question_addtime', 'question_tag'];
     $data = [];
     switch ($type) {
         case 'my':
             $data = $this->getMy($userId, $columns, $limit, $offset);
             break;
         case 'answer':
             $data = $this->getAnswer($userId, $limit, $offset);
             break;
         case 'follow':
             $data = $this->getFollow($userId, $columns, $limit, $offset);
             break;
     }
     $result = [];
     if ($data) {
         foreach ($data as $arr) {
             $tmp = PicUrl::Question(json_decode($arr['question_pics']), $this->getDi());
             if (is_string($tmp)) {
                 $arr['question_pics'] = $tmp;
             }
             if (is_array($tmp)) {
                 //                    $arr['question_pics'] = array_slice($tmp, 0,2);
                 $arr['question_pics'] = $tmp;
             }
             //$arr['addtime'] = \Apps\Common\Libs\DateTime::Format($arr['addtime']);
             $arr['user_cover'] = PicUrl::UserCover($arr['user_cover'], $this->getDi());
             if (unserialize(base64_decode($arr['question_content']))) {
                 $arr['question_content'] = unserialize(base64_decode($arr['question_content']));
             }
             $arr['question_tag'] = json_decode($arr['question_tag'], true) ?: [];
             $result[] = $arr;
         }
     }
     $this->setResult($result);
 }
 /**
  * 问答详情
  * @date: 2016-1-16 
  * @author: futao
  */
 public function infoAction()
 {
     $this->setLeftNav("info");
     $req = $this->request;
     $questionId = intval($req->getQuery('id', null, 0));
     if ($questionId < 0) {
         echo "参数错误!";
         return;
     }
     $questionColumns = ['ub.user_id', 'ub.user_nickname', 'ub.user_cover', 'Apps\\Common\\Models\\Question.user_id', 'Apps\\Common\\Models\\Question.question_content', 'Apps\\Common\\Models\\Question.question_pics', 'Apps\\Common\\Models\\Question.question_addtime', 'Apps\\Common\\Models\\Question.question_browsers', 'Apps\\Common\\Models\\Question.question_id'];
     $info = Question::query()->columns($questionColumns)->leftJoin('Apps\\Common\\Models\\UserBase', 'ub.user_id = Apps\\Common\\Models\\Question.user_id', 'ub')->where("Apps\\Common\\Models\\Question.question_id = {$questionId} and Apps\\Common\\Models\\Question.question_state = 1")->execute()->getFirst();
     if (!$info) {
         echo "问题不存在!";
         exit;
     }
     $info->user_cover = PicUrl::UserCover($info->user_cover, $this->di);
     if (unserialize(base64_decode($info->question_content))) {
         $info->question_content = unserialize(base64_decode($info->question_content));
     }
     if (json_decode($info->question_pics)) {
         $info->question_pics = json_decode($info->question_pics);
     }
     $answerColumns = ['ub.user_nickname', 'ub.user_cover', 'Apps\\Common\\Models\\QuestionAnswer.answer_content', 'Apps\\Common\\Models\\QuestionAnswer.answer_addtime', 'Apps\\Common\\Models\\QuestionAnswer.answer_id', 'Apps\\Common\\Models\\QuestionAnswer.original_content', 'Apps\\Common\\Models\\QuestionAnswer.answer_pics', 'Apps\\Common\\Models\\QuestionAnswer.type', 'Apps\\Common\\Models\\QuestionAnswer.user_id'];
     $answerList = QuestionAnswer::query()->columns($answerColumns)->leftJoin('Apps\\Common\\Models\\UserBase', 'ub.user_id = Apps\\Common\\Models\\QuestionAnswer.user_id', 'ub')->where("Apps\\Common\\Models\\QuestionAnswer.question_id = {$questionId} and Apps\\Common\\Models\\QuestionAnswer.answer_state = 1")->orderBy("Apps\\Common\\Models\\QuestionAnswer.answer_floor asc")->execute()->toArray();
     foreach ($answerList as $k => $val) {
         if (unserialize(base64_decode($answerList[$k]['answer_content']))) {
             $answerList[$k]['answer_content'] = unserialize(base64_decode($answerList[$k]['answer_content']));
         }
         if (unserialize(base64_decode($answerList[$k]['original_content']))) {
             $answerList[$k]['original_content'] = unserialize(base64_decode($answerList[$k]['original_content']));
         }
         if (json_decode($answerList[$k]['answer_pics'])) {
             $answerList[$k]['answer_pics'] = json_decode($answerList[$k]['answer_pics']);
         }
         if ($answerList[$k]['type'] == 1) {
             $answerList[$k]['reply'] = QuestionAnswerComments::query()->columns(['ub.user_nickname', 'ub.user_cover', 'ub.user_id', 'content', 'add_time', 'id'])->leftJoin('Apps\\Common\\Models\\UserBase', 'ub.user_id = Apps\\Common\\Models\\QuestionAnswerComments.user_id', 'ub')->where("question_id = {$questionId} and answer_id = " . $answerList[$k]['answer_id'] . " and to_user_id = " . $answerList[$k]['user_id'])->orderBy("id desc")->execute()->toArray();
         }
         $answerList[$k]['user_cover'] = PicUrl::UserCover($answerList[$k]['user_cover'], $this->di);
     }
     $userList = UserBase::find("is_manage = 1");
     $seeList = QuestionViewsUser::query()->columns(['distinct ub.user_id', 'ub.user_cover'])->leftJoin('Apps\\Common\\Models\\UserBase', 'ub.user_id = Apps\\Common\\Models\\QuestionViewsUser.user_id', 'ub')->where("question_id = {$questionId}")->orderBy("id desc")->limit(7)->execute();
     $this->view->setVar('seelist', $seeList);
     $this->view->setVar('comment_count', QuestionAnswer::count('answer_state = 1 and question_id = ' . $questionId));
     $this->view->setVar('question_id', $questionId);
     $this->view->setVar('userlist', $userList);
     $this->view->setVar('questioninfo', $info);
     $this->view->setVar('answerlist', $answerList);
     $this->view->pick('question/info');
 }
Exemple #20
0
 private function getGoods($orderId)
 {
     $goodsList = UserOrderGoods::query()->columns(['shop_id', 'bp.bp_name shop_name', 'bp.bp_medal shop_medal_refund', 'bp.bp_medal shop_medal_verify', 'goods_id', 'bps.service_name goods_name', 'bps.service_cover goods_cover', 'goods_price', 'bps.service_unit goods_price_show', 'order_goods_number goods_number'])->leftJoin('Apps\\Common\\Models\\BeautyParlor', 'bp.bp_id = shop_id', 'bp')->leftJoin('Apps\\Common\\Models\\BeautyParlorService', 'bps.service_id = goods_id', 'bps')->where('order_id = :oid:', ['oid' => $orderId])->execute()->toArray();
     for ($i = 0; $i < count($goodsList); $i++) {
         $goodsList[$i]['shop_medal_refund'] = \Apps\Common\Libs\BeautyParlor::getMedalRefund($goodsList[$i]['shop_medal_refund']);
         $goodsList[$i]['shop_medal_verify'] = \Apps\Common\Libs\BeautyParlor::getMedalVerify($goodsList[$i]['shop_medal_verify']);
         $goodsList[$i]['goods_cover'] = PicUrl::BeautyParlorCover($goodsList[$i]['goods_cover'], $this->getDi());
         $unit = $goodsList[$i]['goods_price_show'];
         if ($goodsList[$i]['goods_price'] > 0) {
             $goodsList[$i]['goods_price_show'] = $goodsList[$i]['goods_price'] . '元' . ($unit ? '/' . $unit : '');
         } else {
             $goodsList[$i]['goods_price_show'] = '';
         }
     }
     return $goodsList;
 }
Exemple #21
0
 public function run()
 {
     $account = $this->getDataItem('account');
     // 验证电话号码格式
     $password = $this->getDataItem('password');
     $pushId = $this->getDataItem('push_id', '');
     // push id
     $osType = $this->getDataItem('os_type');
     //        $account = '18723568682';
     //        $password = '******';
     // 验证数据完整
     if (empty($account) || empty($password)) {
         $this->message = '账户名和密码都不能为空!';
     } else {
         if ($this->verifyAccount($account, $password)) {
             // 获取 user token
             if ($this->saveuserauth($this->apiAccessToken->id, $this->userInfo['user_id'])) {
                 $this->success = 1;
                 $this->message = '登录成功!';
                 $this->userToken = $this->getUserAuth()->userToken;
                 $this->saveUserPushId($this->userInfo['user_id'], $pushId, $osType);
                 $this->userInfo['user_mobile'] = $this->userInfo['bind_phone'] ?: $this->userInfo['user_account'];
                 $this->userInfo['user_cover'] = $this->userInfo['user_cover'] ? PicUrl::UserCover($this->userInfo['user_cover'], $this->getDi()) : '';
                 $this->userInfo['persional_sign'] = $this->userInfo['persional_sign'] ? unserialize(base64_decode($this->userInfo['persional_sign'])) : '';
                 // 获取城市信息
                 $SysAreaZipDistrictPhonecode = new SysAreaZipDistrictPhonecode();
                 $city = $SysAreaZipDistrictPhonecode->getOne($this->userInfo['user_district']);
                 $this->userInfo['user_district'] = $city['FULL_NAME'] ?: '';
                 // 加入关注数和粉丝数
                 $UserFollow = new UserFollow();
                 $this->userInfo['follow_count'] = $UserFollow->getFollowCount($this->userInfo['user_id'], 1);
                 $this->userInfo['fans_count'] = $UserFollow->getToFollowCount($this->userInfo['user_id'], 1);
                 // 删除不要的字段
                 unset($this->userInfo['user_account'], $this->userInfo['user_password'], $this->userInfo['user_state'], $this->userInfo['user_addtime'], $this->userInfo['is_manage'], $this->userInfo['bind_phone']);
             } else {
                 $this->message = '获取User Token异常!';
             }
         }
     }
     if (!$this->userInfo) {
         // 登录失败依然保留字段
         $this->userInfo = ["user_id" => "", "user_nickname" => "", "user_mobile" => "", "user_cover" => "", "user_gender" => "0", "user_birthday" => "", "user_realname" => "", "user_expert" => "", "user_district" => "", "user_money" => "", "user_money_virtual" => "", "persional_sign" => "", "follow_count" => 0, "fans_count" => 0];
     }
     $info = ['success' => $this->success, 'user_token' => $this->userToken, 'message' => $this->message];
     $info = array_merge($info, $this->userInfo);
     $this->setResult($info);
 }
 public function sync($id)
 {
     $config = $this->di->get('appConfig')->amap->lbs_cloud;
     $key = $config->key;
     $signKey = $config->sign_key;
     $tableId = $config->table_id;
     $syncLogTableName = 'beauty_parlor_amap_sync_log';
     $lbsColud = new LBSCloud($key, $signKey, $tableId, $syncLogTableName);
     // 获取店铺信息
     $shop = BeautyParlor::query()->columns(['bp_id', 'bp_name', 'bp_address', 'bp_cover', 'bp_tel', 'bp_medal', 'X(bp_coordinate) x', 'Y(bp_coordinate) y'])->where('bp_id=:id:', ['id' => $id])->execute()->getFirst();
     if (!$shop) {
         return false;
     }
     $name = $shop->bp_name;
     $location = $shop->x . ',' . $shop->y;
     $address = $shop->bp_address;
     $customData = ['bp_id' => $shop->bp_id, 'bp_cover' => PicUrl::BeautyParlorCover($shop->bp_cover, $this->di), 'tel' => $shop->bp_tel, 'bp_tags' => implode(',', \Apps\Common\Libs\BeautyParlor::getTags($id)), 'medal_refund' => \Apps\Common\Libs\BeautyParlor::getMedalRefund($shop->bp_medal), 'medal_verify' => \Apps\Common\Libs\BeautyParlor::getMedalVerify($shop->bp_medal)];
     // 获取已经同步的数据
     $aMapData = BeautyParlorAmap::findFirst("source_id={$id}");
     if ($aMapData) {
         // 更新
         $result = $lbsColud->update($id, $aMapData->amap_data_id, $name, $location, $address, $customData, CoordType::AUTONAVI);
         if ($result->status) {
             // 记录更新时间
             $aMapData->sync_time = new RawValue('NOW()');
             if ($aMapData->save() == false) {
                 $this->logDatabaseError($aMapData);
             }
         }
     } else {
         // 新添加
         $result = $lbsColud->create($id, $name, $location, $address, $customData, CoordType::AUTONAVI);
         if ($result->status) {
             // 记录关系数据
             $aMapData = new BeautyParlorAmap();
             $aMapData->source_id = $id;
             $aMapData->amap_data_id = $result->id;
             $aMapData->sync_time = new RawValue('NOW()');
             if ($aMapData->save() == false) {
                 $this->logDatabaseError($aMapData);
             }
         }
     }
     return $result->status;
 }
Exemple #23
0
 public function run()
 {
     // 验证用户权限
     if (!$this->verifyUserAuth()) {
         return false;
     }
     $field = ['user_cover', 'user_nickname', 'user_gender', 'user_birthday', 'user_realname', 'user_district', 'user_money', 'user_money_virtual', 'bind_phone user_mobile', 'persional_sign', 'user_id', 'user_expert'];
     $info = UserBase::query()->columns($field)->where('user_id=' . $this->getUserAuth()->userId)->execute()->getFirst()->toArray();
     // 获取城市信息
     $SysAreaZipDistrictPhonecode = new SysAreaZipDistrictPhonecode();
     $city = $SysAreaZipDistrictPhonecode->getOne($info['user_district']);
     $info['user_district'] = $city['FULL_NAME'] ?: '';
     $info['user_cover'] = $info['user_cover'] ? PicUrl::UserCover($info['user_cover'], $this->getDi()) : '';
     $info['persional_sign'] = $info['persional_sign'] ? unserialize(base64_decode($info['persional_sign'])) : '';
     // 加入关注数和粉丝数
     $UserFollow = new UserFollow();
     $info['follow_count'] = $UserFollow->getFollowCount($info['user_id'], 1);
     $info['fans_count'] = $UserFollow->getToFollowCount($info['user_id'], 1);
     $this->setResult($info);
 }
Exemple #24
0
 private function getRecommend($cityId)
 {
     $bannerBp = OmBanner::query()->columns('banner_data')->where('city_id = :cid: AND banner_name = :key:', ['cid' => $cityId, 'key' => 'index_bp'])->execute()->getFirst();
     if ($bannerBp) {
         $data = BeautyParlor::query()->columns(['bp_id as id', 'bp_name as name', 'bp_cover as cover', 'bp_address as address', 'bp_medal as medal'])->where('bp_state>0 and bp_id=:id:')->bind(['id' => $bannerBp->banner_data])->execute()->getFirst();
         $bpData = ["id" => $data->id, "name" => $data->name, "cover" => PicUrl::BeautyParlorCover($data->cover, $this->getDi()), "address" => $data->address, "tags" => $this->getBeautyParlorTags($data->id), "medal_refund" => \Apps\Common\Libs\BeautyParlor::getMedalRefund($data->medal), "medal_verify" => \Apps\Common\Libs\BeautyParlor::getMedalVerify($data->medal)];
     } else {
         $bpData = null;
     }
     $pics = OmBanner::query()->columns('banner_data')->where('city_id = :cid: AND banner_name = :key:', ['cid' => $cityId, 'key' => 'index_pics'])->execute()->getFirst();
     if ($pics) {
         $picsData = json_decode($pics->banner_data, true);
     } else {
         $picsData = [];
     }
     for ($i = 0; $i < count($picsData); $i++) {
         $picsData[$i]['url'] = PicUrl::DefaultPics($picsData[$i]['url'], $this->getDi());
     }
     return ['pic' => $picsData, 'beauty_parlor' => $bpData];
 }
Exemple #25
0
 /**
  * 获取用户关注的美容院列表
  * @param $user_id
  * @param int $offset
  * @param int $limit
  * @return mixed
  */
 private function getFavorites($user_id, $offset = 0, $limit = 10)
 {
     $list = BpFavorites::query()->columns(['p.bp_id id', 'p.bp_name name', 'p.bp_cover cover', 'p.bp_address address', 'p.bp_tel tel', 'p.bp_medal medal_verify', 'a.low_price', 'a.facilities'])->leftJoin('Apps\\Common\\Models\\BeautyParlor', 'Apps\\Common\\Models\\BpFavorites.bp_id = p.bp_id', 'p')->leftJoin('Apps\\Common\\Models\\BeautyParlorAttr', 'Apps\\Common\\Models\\BpFavorites.bp_id = a.beauty_parlor_id', 'a')->where('p.bp_state = 1 and user_id = ' . $user_id)->limit($limit, $offset)->execute()->toArray();
     $BeautyParlorTag = new BeautyParlorTag();
     foreach ($list as $k => $val) {
         $tags = [];
         if ($tagList = $BeautyParlorTag->getTagList($val['id'])) {
             foreach ($tagList as $key => $value) {
                 $tags[] = $value['tag_title'];
             }
         } else {
             $tags = [];
         }
         $list[$k]['cover'] = PicUrl::BeautyParlorCover($val['cover'], $this->getDi());
         $list[$k]['medal_verify'] = BeautyParlor::getMedalVerify($val['medal']);
         $list[$k]['facilities'] = $val['facilities'] ? json_decode($val['facilities'], true) : [];
         $list[$k]['tag'] = $tags;
     }
     return $list;
 }
Exemple #26
0
 public function run()
 {
     $bp_id = intval($this->getDataItem('id', 0));
     $page = intval($this->getDataItem('page', 1));
     $limit = $this->getConfig()->limit;
     $offset = ($page - 1) * $limit;
     if (0 < $bp_id) {
         $this->comments = BeautyParlorComment::query()->columns(['u.user_id', 'u.user_nickname', 'u.user_cover', 'u.user_expert', 'Apps\\Common\\Models\\BeautyParlorComment.comment_id as comment_id', 'Apps\\Common\\Models\\BeautyParlorComment.comment_info as comment_info', 'Apps\\Common\\Models\\BeautyParlorComment.comment_photos as comment_photos', 'Apps\\Common\\Models\\BeautyParlorComment.comment_floor as comment_floor', 'Apps\\Common\\Models\\BeautyParlorComment.comment_addtime as addtime'])->leftJoin('Apps\\Common\\Models\\UserBase', 'Apps\\Common\\Models\\BeautyParlorComment.user_id=u.user_id', 'u')->where('Apps\\Common\\Models\\BeautyParlorComment.beauty_parlor_id=' . $bp_id . ' and Apps\\Common\\Models\\BeautyParlorComment.comment_state = 1')->orderBy('Apps\\Common\\Models\\BeautyParlorComment.comment_id desc')->limit($limit, $offset)->execute()->toArray();
     }
     $this->comments = $this->comments ? $this->comments : [];
     $data = [];
     foreach ($this->comments as $arr) {
         $arr['user_cover'] = PicUrl::UserCover($arr['user_cover'], $this->getDi());
         $arr['comment_photos'] = PicUrl::BeautyParlorComment(json_decode($arr['comment_photos']), $this->getDi());
         if (unserialize(base64_decode($arr['comment_info']))) {
             $arr['comment_info'] = unserialize(base64_decode($arr['comment_info']));
         }
         $data[] = $arr;
     }
     $this->setResult($data);
 }
 public function run()
 {
     $user_id = intval($this->getDataItem('user_id', 0));
     $expert_id = intval($this->getDataItem('expert_id', 0));
     $page = intval($this->getDataItem('page', 1));
     if ($expert_id < 1) {
         return $this->errorLog(ResultStatus::URL_PARAM_CANNOT_EMPTY, '缺少必传参数!');
     }
     $limit = $this->getConfig()->limit;
     $offset = ($page - 1) * $limit;
     $list = QuestionAnswer::query()->columns(['question_id'])->where('answer_state = 1 and user_id = ' . $expert_id)->groupBy('question_id')->orderBy('answer_id DESC')->limit($limit, $offset)->execute()->toArray();
     if ($list) {
         $where = '';
         foreach ($list as $val) {
             $where .= $val['question_id'] . ',';
         }
         $where = trim($where, ',');
         $result = Question::query()->columns(['question_id', 'question_tag', 'question_pics', 'question_content', 'question_addtime', 'u.user_id', 'u.user_nickname', 'u.user_cover', 'u.user_gender'])->leftJoin('\\Apps\\Common\\Models\\UserBase', 'u.user_id = \\Apps\\Common\\Models\\Question.user_id', 'u')->where("question_state = 1 and question_id in({$where})")->execute()->toArray();
         $QuestionFollow = new QuestionFollow();
         foreach ($result as $k => $val) {
             $result[$k]['question_content'] = unserialize(base64_decode($val['question_content'])) ?: $val['question_content'];
             $result[$k]['user_cover'] = PicUrl::UserCover($val['user_cover'], $this->getDi());
             if ($val['question_pics']) {
                 $result[$k]['question_pics'] = PicUrl::Question(json_decode($val['question_pics']), $this->getDi());
             }
             if (!is_numeric($val['question_tag'])) {
                 $result[$k]['question_tag'] = $val['question_tag'] ? json_decode($val['question_tag'], true) : [];
             } else {
                 $result[$k]['question_tag'] = [];
             }
             if ($user_id > 0) {
                 $result[$k]['is_collection'] = $QuestionFollow->is_follow($val['question_id'], $user_id);
             } else {
                 $result[$k]['is_collection'] = '0';
             }
         }
         $this->setResult($result);
     }
 }
Exemple #28
0
 public function run()
 {
     $user_id = intval($this->getDataItem('user_id', 0));
     $expert_id = intval($this->getDataItem('expert_id', 0));
     //		$expert_id = 289;
     if ($expert_id < 1) {
         return $this->errorLog(ResultStatus::URL_PARAM_CANNOT_EMPTY, '缺少必传参数!');
     }
     $columns = ['user_id', 'user_nickname', 'user_cover', 'expert_follow_count', 'persional_sign'];
     if ($UserBase = UserBase::query()->columns($columns)->where('user_expert = 1 and user_id = ' . $expert_id)->execute()->getFirst()) {
         $info = $UserBase->toArray();
         $info['user_cover'] = PicUrl::ActivityCover($info['user_cover'], $this->getDi());
         if ($userAttribute = UserAttribute::findFirst('attr_type = 103 and attr_state = 1 and user_id = ' . $expert_id)) {
             $attr_value_json = $userAttribute->attr_value_json;
         } else {
             $attr_value_json = [];
         }
         $info['persional_sign'] = $info['persional_sign'] ? unserialize(base64_decode($info['persional_sign'])) : '';
         $attr_value_json = $attr_value_json ? json_decode($attr_value_json) : [];
         $info['experience'] = $attr_value_json->experience ?: '';
         // 从业经验
         $info['experttitle'] = $attr_value_json->experttitle ?: '';
         // 擅长领域
         $info['field'] = $attr_value_json->field ?: [];
         // 专家头衔(array)
         if ($user_id > 0) {
             $info['is_follow'] = (new UserFollow())->is_follow($user_id, $expert_id, 2) ? '1' : '0';
         } else {
             $info['is_follow'] = '0';
         }
         // 回答问题数
         $result = (new UserBase())->getReadConnection()->query("SELECT count(*) c FROM\r\n(SELECT count(*) FROM question_answer WHERE answer_state = 1 AND user_id = {$expert_id} GROUP BY question_id) a;");
         $count = $result->fetch();
         $info['question_count'] = $count['c'];
     } else {
         return $this->errorLog(ResultStatus::POST_BODY_PARAM_ERROR, '用户不存在或不是专家');
     }
     $this->setResult($info);
 }
Exemple #29
0
 public function run()
 {
     /**
      * 验证用户权限
      */
     if (false == $this->verifyUserAuth()) {
         return false;
     }
     $page = intval($this->getDataItem('page', 1));
     $limit = $this->getConfig()->limit;
     $offset = ($page - 1) * $limit;
     $user_id = $this->getUserAuth()->userId;
     $list = CosOnlineAppointment::query()->columns(['id', 'set_man_id', 'shop_id', 'shop_name', 'online_product_id', 'product_name', 'appointment_time', 'appointment_state', 'set_time', 'type'])->where('appointment_state in(0, 1) and set_man_id = ' . $user_id)->orderBy('appointment_time DESC')->limit($limit, $offset)->execute()->toArray();
     $result = [];
     foreach ($list as $val) {
         $cover = '';
         $price = '';
         // 初始单价
         if ($val['type'] == 1) {
             // 美容院
             if ($BeautyParlorAttr = BeautyParlorAttr::findFirst('beauty_parlor_id = ' . $val['shop_id'])) {
                 $price = $BeautyParlorAttr->low_price . '元';
             }
             if ($BeautyParlor = BeautyParlor::findFirst('bp_id = ' . $val['shop_id'])) {
                 $cover = $BeautyParlor->bp_cover;
             }
             $result[] = ['id' => $val['id'], 'order_id' => $val['shop_id'], 'title' => $val['shop_name'], 'cover' => $cover ? PicUrl::BeautyParlorCover($cover, $this->getDi()) : '', 'price' => $price, 'time' => $val['appointment_time'], 'add_time' => $val['set_time'], 'status' => $val['appointment_state'], 'type' => '1'];
         } elseif ($val['type'] == '2') {
             if ($BeautyParlorService = BeautyParlorService::findFirst('service_id = ' . $val['online_product_id'])) {
                 $price = $BeautyParlorService->service_price . '元' . ($BeautyParlorService->service_unit ? '/' . $BeautyParlorService->service_unit : '');
                 $cover = $BeautyParlorService->service_cover;
             }
             $result[] = ['id' => $val['id'], 'order_id' => $val['online_product_id'], 'title' => $val['product_name'] ?: '', 'cover' => $cover ? PicUrl::BeautyParlorCover($cover, $this->getDi()) : '', 'price' => $price, 'time' => $val['appointment_time'], 'add_time' => $val['set_time'], 'status' => $val['appointment_state'], 'type' => '2'];
         } else {
             continue;
         }
     }
     $this->setResult($result);
 }
Exemple #30
0
 public function run()
 {
     $user_id = intval($this->getDataItem('user_id', 0));
     $page = intval($this->getDataItem('page', 1));
     $limit = $this->getConfig()->limit;
     $offset = ($page - 1) * $limit;
     //		$user_id = 12;
     $where = 'user_expert = 1 and user_state = 1';
     if ($user_id > 0) {
         // 用户关注的专家列表
         $followExpert = UserFollow::query()->where("user_id = {$user_id} and type = 2")->execute()->toArray();
         $expert = '';
         foreach ($followExpert as $val) {
             $expert .= $val['to_user_id'] . ',';
         }
         if ($expert && ($expert = trim($expert, ','))) {
             $where = "user_expert = 1 and user_state = 1 and user_id not in({$expert})";
         }
     }
     $list = UserBase::query()->columns(['user_id', 'user_nickname', 'user_cover', 'expert_follow_count'])->where($where)->orderBy('expert_follow_count DESC')->limit($limit, $offset)->execute()->toArray();
     foreach ($list as $k => $val) {
         $list[$k]['user_cover'] = PicUrl::ActivityCover($val['user_cover'], $this->getDi());
         // 获取专家的扩展信息
         if ($userAttribute = UserAttribute::findFirst('attr_type = 103 and attr_state = 1 and user_id = ' . $val['user_id'])) {
             $attr_value_json = $userAttribute->attr_value_json;
         } else {
             $attr_value_json = [];
         }
         $info = $attr_value_json ? json_decode($attr_value_json) : [];
         $list[$k]['experience'] = $info->experience ?: '0';
         // 从业经验
         $list[$k]['experttitle'] = $info->experttitle ?: '';
         // 擅长领域
         $list[$k]['field'] = $info->field ?: '';
         // 专家头衔(array)
     }
     $this->setResult($list);
 }