public function listAction() { $this->setLeftNav('comment_list'); $req = $this->request; $id = intval($req->getQuery('id', null, 0)); if ($id <= 0) { $this->view->disable(); echo '美容院不存在!'; return; } $page = intval($req->getQuery('page', null, 1)); $page = $page > 0 ? $page : 1; $limit = $this->pageNavLimit; $offset = $limit * ($page - 1); $list = BeautyParlorComment::query()->columns(['comment_id', 'ub.user_id', 'ub.user_nickname', 'ub.user_cover', 'ub.user_gender', 'comment_info', 'comment_photos', 'comment_state', 'comment_addtime', 'comment_reply', 'comment_reply_addtime'])->leftJoin('Apps\\Common\\Models\\UserBase', 'ub.user_id = Apps\\Common\\Models\\BeautyParlorComment.user_id', 'ub')->where('beauty_parlor_id = :id:', ['id' => $id])->limit($limit, $offset)->orderBy('comment_id DESC')->execute()->toArray(); foreach ($list as $k => $v) { if (unserialize(base64_decode($v['comment_info']))) { $list[$k]['comment_info'] = unserialize(base64_decode($v['comment_info'])); } } $total = BeautyParlorComment::count('beauty_parlor_id = ' . $id); $this->view->setVar('commentList', $list); $this->view->setVar('total', $total); $this->view->setVar('page', $page); $this->view->setVar('limit', $limit); $this->view->setVar('id', $id); }
public function run() { $id = intval($this->getDataItem('id', 0)); // 评论总数 $total = BeautyParlorComment::count(['conditions' => 'beauty_parlor_id = :bid: and comment_state = 1', 'bind' => ['bid' => $id]]); $this->setResult(["total" => $total]); }
/** * 美容院评论列表 * @date: 2016年1月19日 * @author: chenxiaolin */ public function listAction() { $this->setLeftNav('comment_list'); $req = $this->request; $id = intval($req->getQuery('id', null, 0)); if ($id <= 0) { $this->view->disable(); echo '美容院不存在!'; return; } $page = intval($req->getQuery('page', null, 1)); $page = $page > 0 ? $page : 1; $limit = $this->pageNavLimit; $offset = $limit * ($page - 1); $user_name = $req->getQuery('user_name'); $comment_addtime = $req->getQuery('comment_addtime'); $timeSlotarr = explode("至", $comment_addtime); $where = []; if ($user_name != '') { $user = UserBase::query()->columns(['user_id'])->where("user_nickname like '%" . $user_name . "%'")->execute(); foreach ($user as $k => $v) { $user_id .= $v['user_id'] . ','; } $user_id = rtrim($user_id, ","); if (!empty($user_id)) { $where[] = "Apps\\Common\\Models\\BeautyParlorComment.user_id in ( {$user_id} )"; } else { $where[] = "Apps\\Common\\Models\\BeautyParlorComment.user_id in ( 0 )"; } $this->view->setVar("user_name", $user_name); } if ($comment_addtime != '') { $where[] = "comment_addtime > '" . $timeSlotarr[0] . "'"; $where[] = "comment_addtime < '" . $timeSlotarr[1] . "'"; $this->view->setVar("comment_addtime", $comment_addtime); } $where[] = "beauty_parlor_id = {$id}"; $whereStr = implode(' AND ', $where); $list = BeautyParlorComment::query()->columns(['comment_id', 'ub.user_id', 'ub.user_nickname', 'ub.user_cover', 'ub.user_gender', 'comment_info', 'comment_photos', 'comment_state', 'comment_addtime', 'comment_reply', 'comment_reply_addtime'])->leftJoin('Apps\\Common\\Models\\UserBase', 'ub.user_id = Apps\\Common\\Models\\BeautyParlorComment.user_id', 'ub')->where($whereStr)->limit($limit, $offset)->orderBy('comment_id DESC')->execute()->toArray(); foreach ($list as $k => $v) { if (unserialize(base64_decode($v['comment_info']))) { $list[$k]['comment_info'] = unserialize(base64_decode($v['comment_info'])); } } //$total = BeautyParlorComment::count('beauty_parlor_id = ' . $id); $total = BeautyParlorComment::count($whereStr); $this->view->setVar('commentList', $list); $this->view->setVar('total', $total); $this->view->setVar('page', $page); $this->view->setVar('limit', $limit); $this->view->setVar('id', $id); }
public function run() { $id = intval($this->getDataItem('id', 0)); $user_id = intval($this->getDataItem('user_id', 0)); if (0 < $id) { /** * 查询基础信息 */ $info = BeautyParlorModel::query()->columns(['bp_id as id', 'bp_name as name', 'bp_cover as cover', 'bp_address as address', 'bp_tel as tel', 'bp_medal as medal', 'bp_intro as intro', 'X(bp_coordinate) latitude', 'Y(bp_coordinate) longitude'])->where('bp_state>0 and bp_id=:id:')->bind(['id' => $id])->execute()->getFirst(); } else { return $this->errorLog(ResultStatus::URL_PARAM_CANNOT_EMPTY, '参数异常'); } if ($info) { $this->parlor['id'] = $info->id; $this->parlor['name'] = $info->name; $this->parlor['cover'] = $info->cover; $this->parlor['address'] = $info->address; $this->parlor['tel'] = $info->tel; $this->parlor['intro'] = $info->intro; $this->parlor['latitude'] = $info->latitude; $this->parlor['longitude'] = $info->longitude; $this->parlor['medal_refund'] = \Apps\Common\Libs\BeautyParlor::getMedalRefund($info->medal); $this->parlor['medal_verify'] = \Apps\Common\Libs\BeautyParlor::getMedalVerify($info->medal); /** * 增加图片列表 */ $pics = BeautyParlorPhotos::query()->columns(['photo_url url'])->where('photo_state>0 and beauty_parlor_id=:bid:')->bind(['bid' => $id])->execute()->toArray(); $this->parlor['pics'] = []; foreach ($pics as $pic) { $this->parlor['pics'][] = PicUrl::BeautyParlorPic($pic['url'], $this->getDi()); } /** * 增加服务范围列表 */ $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])->execute()->toArray(); $this->parlor['services'] = []; 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 : ''); } $this->parlor['services'][] = $d; } // 评论总数 $this->parlor['comment_num'] = BeautyParlorComment::count(['conditions' => 'beauty_parlor_id = :bid: and comment_state = 1', 'bind' => ['bid' => $id]]); } else { $this->errorLog(ResultStatus::QUERY_DATA_NOT_EXIST, 'ID不存在'); } $this->parlor['favorite_num'] = BpFavorites::count(['conditions' => "bp_id = " . $this->parlor['id']]); if ($user_id != '') { $is_favorite = BpFavorites::findFirst("user_id = {$user_id} and bp_id =" . $this->parlor['id']); /* var_dump($is_favorite); exit; */ if ($is_favorite) { $this->parlor['is_favorite'] = 1; //已收藏 } else { $this->parlor['is_favorite'] = 0; //未收藏 } } else { $this->parlor['is_favorite'] = 0; } $this->setResult($this->parlor); }
public function run() { $id = intval($this->getDataItem('id', 0)); $user_id = intval($this->getDataItem('user_id', 0)); if (0 < $id) { /** * 查询基础信息 */ $info = BeautyParlorModel::query()->columns(['bp_id as id', 'bp_name as name', 'bp_cover as cover', 'bp_address as address', 'bp_tel as tel', 'bp_medal as medal', 'bp_intro as intro', 'X(bp_coordinate) latitude', 'Y(bp_coordinate) longitude', 'bpa.open_time', 'bpa.close_time', 'bpa.low_price', 'bpa.open_year', 'bpa.shop_area', 'bpa.service_num', 'bpa.facilities'])->leftJoin('Apps\\Common\\Models\\BeautyParlorAttr', 'Apps\\Common\\Models\\BeautyParlor.bp_id = bpa.beauty_parlor_id', 'bpa')->where('Apps\\Common\\Models\\BeautyParlor.bp_state>0 and Apps\\Common\\Models\\BeautyParlor.bp_id=:id:')->bind(['id' => $id])->execute()->getFirst(); } else { return $this->errorLog(ResultStatus::URL_PARAM_CANNOT_EMPTY, '参数异常'); } if ($info) { $this->parlor['id'] = $info->id; $this->parlor['name'] = $info->name; $this->parlor['cover'] = PicUrl::BeautyParlorCover($info->cover, $this->getDi()); $this->parlor['address'] = $info->address; $this->parlor['tel'] = $info->tel; $this->parlor['intro'] = $info->intro; $this->parlor['latitude'] = $info->latitude; $this->parlor['longitude'] = $info->longitude; $this->parlor['medal_refund'] = \Apps\Common\Libs\BeautyParlor::getMedalRefund($info->medal); $this->parlor['medal_verify'] = \Apps\Common\Libs\BeautyParlor::getMedalVerify($info->medal); $this->parlor['open_time'] = $info->open_time == null ? '' : $info->open_time; $this->parlor['close_time'] = $info->close_time == null ? '' : $info->close_time; $this->parlor['low_price'] = $info->low_price == null ? '' : $info->low_price; $this->parlor['open_year'] = $info->open_year == null ? '' : $info->open_year; $this->parlor['shop_area'] = $info->shop_area == null ? '' : $info->shop_area; $this->parlor['facilities'] = $info->facilities == null ? [] : (json_decode($info->facilities) ?: []); $this->parlor['pics'] = []; $this->parlor['services'] = []; /** * 增加图片列表 如果深度验店 */ if ($this->parlor['medal_verify']) { $pics = BeautyParlorPhotos::query()->columns(['photo_url url'])->where('photo_state>0 and beauty_parlor_id=:bid:')->bind(['bid' => $id])->execute()->toArray(); foreach ($pics as $pic) { $this->parlor['pics'][] = PicUrl::BeautyParlorPic($pic['url'], $this->getDi()); } /** * 增加服务范围列表 */ $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(3, 0)->execute()->toArray(); 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 : ''); } $this->parlor['services'][] = $d; } } /** * 增加tag列表 */ $tag = BeautyParlorTag::query()->columns(['i.tag_title'])->leftJoin('Apps\\Common\\Models\\BeautyParlorTagInfo', 'Apps\\Common\\Models\\BeautyParlorTag.tag_id = i.tag_id', 'i')->where('i.tag_state=1 and bp_id=:bid:')->bind(['bid' => $id])->orderBy('sort desc,bp_tag_addtime asc')->execute()->toArray(); $this->parlor['tags'] = $tag; // 评论总数 $this->parlor['comment_num'] = BeautyParlorComment::count(['conditions' => 'beauty_parlor_id = :bid: and comment_state = 1', 'bind' => ['bid' => $id]]); //获取3条评论 $comments = BeautyParlorComment::query()->columns(['u.user_id', 'u.user_nickname', 'u.user_cover', 'u.user_gender', '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=' . $id . ' and Apps\\Common\\Models\\BeautyParlorComment.comment_state = 1')->orderBy('Apps\\Common\\Models\\BeautyParlorComment.comment_addtime desc')->limit(3, 0)->execute()->toArray(); foreach ($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->parlor['comments'] = $data; } else { return $this->errorLog(ResultStatus::QUERY_DATA_NOT_EXIST, 'ID不存在'); } $this->parlor['favorite_num'] = BpFavorites::count(['conditions' => "bp_id = " . $this->parlor['id']]); if ($user_id != '') { $is_favorite = BpFavorites::findFirst("user_id = {$user_id} and bp_id =" . $this->parlor['id']); /* var_dump($is_favorite); exit; */ if ($is_favorite) { $this->parlor['is_favorite'] = 1; //已关注 } else { $this->parlor['is_favorite'] = 0; //未关注 } } else { $this->parlor['is_favorite'] = 0; } $this->setResult($this->parlor); }
/** * 美容院 */ public function beautyParlorAction() { $id = $this->request->getQuery('id'); if (empty($id)) { echo '美容院不存在!'; $this->view->disable(); return; } /** * 查询基础信息 */ $info = BeautyParlor::query()->columns(['bp_id as id', 'bp_name as name', 'bp_cover as cover', 'bp_address as address', 'bp_tel as tel', 'bp_medal as medal', 'bp_intro as intro', 'X(bp_coordinate) latitude', 'Y(bp_coordinate) longitude'])->where('bp_id=:id:')->bind(['id' => $id])->execute()->getFirst(); if (!$info) { echo '美容院不存在!'; $this->view->disable(); return; } $parlor = []; $parlor['id'] = $info->id; $parlor['name'] = $info->name; $parlor['cover'] = $info->cover; $parlor['address'] = $info->address; $parlor['tel'] = $info->tel; $parlor['intro'] = $info->intro; $parlor['latitude'] = $info->latitude; $parlor['longitude'] = $info->longitude; $parlor['medal_refund'] = \Apps\Common\Libs\BeautyParlor::getMedalRefund($info->medal); $parlor['medal_verify'] = \Apps\Common\Libs\BeautyParlor::getMedalVerify($info->medal); /** * 增加图片列表 */ $pics = BeautyParlorPhotos::query()->columns(['photo_url url'])->where('photo_state>0 and beauty_parlor_id=:bid:')->bind(['bid' => $id])->execute()->toArray(); $parlor['pics'] = []; foreach ($pics as $pic) { $parlor['pics'][] = PicUrl::BeautyParlorPic($pic['url'], $this->getDi()); } /** * 增加服务范围列表 */ $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 beauty_parlor_id=:bid:')->bind(['bid' => $id])->execute()->toArray(); $parlor['services'] = []; 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 : ''); } $parlor['services'][] = $d; } // 评论总数 $parlor['comment_num'] = BeautyParlorComment::count(['conditions' => 'beauty_parlor_id = :bid:', 'bind' => ['bid' => $id]]); $this->view->setVar('parlor', $parlor); $this->tag->setTitle($parlor['name']); $this->assets->collection('footer')->addJs('/libs/zepto/zepto-1.1.6.min.js', false)->addJs('/libs/iscroll/iscroll.js', false)->addJs('/assets/frontend/js/share/bp-view.js', false); }
public function run() { /** * 验证用户权限 */ if (false == $this->verifyUserAuth()) { return false; } $bp_id = intval($this->getDataItem('beauty_parlor_id', 0)); $appoint_id = intval($this->getDataItem('appoint_id', 0)); $comment_info = Keyword::Filter($this->getDataItem('content', '')); //关键字替换 $keyword = CosQKeyword::query()->execute()->toArray(); foreach ($keyword as $k => $v) { $comment_info = str_replace($v['keyword'], '***', $comment_info); } $comment_info = base64_encode(serialize($comment_info)); //$type = intval($this -> getDataItem('type')); $type = $this->getDataItem('type'); //评论图片 $up = new UploadPic(); $comment_photos = json_encode($up->beautyParlorComment()); if ($type !== null && $type >= 0 && in_array($type, array(0, 1))) { if ($type == 0) { //添加美容院评论 if ($bp_id > 0 && !empty($comment_info)) { // 查询最大楼层 $floor = BeautyParlorComment::maximum(["column" => "comment_floor", "conditions" => "beauty_parlor_id = :id: and type = 0", "bind" => ["id" => $bp_id]]); $bpc = new BeautyParlorComment(); $bpc->user_id = $this->getUserAuth()->userId; $bpc->comment_floor = ($floor ? $floor : 0) + 1; $bpc->beauty_parlor_id = $bp_id; $bpc->comment_info = $comment_info; $bpc->comment_photos = $comment_photos; $bpc->type = $type; if ($bpc->save()) { $this->id = $bpc->comment_id; $this->success = 1; } else { return $this->databaseErrorLog($bpc); } } else { return $this->errorLog(ResultStatus::POST_BODY_PARAM_ERROR, ""); } //评论成功,推送消息 $branch = BeautyParlor::findFirst("bp_id = {$bp_id}")->toArray(); $branchId = $branch['branch_id']; if (empty($branchId)) { //没有分店,不推送 return $this->setResult(['id' => $this->id, 'success' => $this->success]); } else { $num = Branch::query()->columns('s.shop_uid')->leftJoin('Apps\\Common\\Models\\CosShop', 'Apps\\Common\\Models\\Branch.shop_id = s.shop_id', 's')->where('Apps\\Common\\Models\\Branch.branch_id = ' . $branchId)->execute()->toArray(); $phoneNum = $num[0]['shop_uid']; $param = array('type' => 7, 'ispushservice' => 0, 'phone' => $phoneNum, 'content' => '有人对您的美容院进行了评论,快去看看吧!', 'shop_id' => 0); $push = new Jpush(); $rs = $push->setval($param); if (!empty($rs)) { $data = json_decode($rs, true); $status = $data['status']; if ($status == 400) { //数据错误 return $this->setResult(['id' => $this->id, 'success' => $this->success]); } } else { $rs = $push->push(); return $this->setResult(['id' => $this->id, 'success' => $this->success]); } } } if ($type == 1) { //添加预约评论 if ($bp_id > 0 && $appoint_id > 0 && !empty($comment_info)) { //判断预约是否已被当前用户评论 $is_comment = BeautyParlorComment::count(["conditions" => "appointment_id = :id: and beauty_parlor_id = :bp_id: and user_id = :user_id:", "bind" => ["id" => $appoint_id, "bp_id" => $bp_id, "user_id" => $this->getUserAuth()->userId]]); if ($is_comment > 0) { //已评论 return $this->errorLog(ResultStatus::POST_BODY_PARAM_ERROR, "预约已评论"); } else { //查询最大楼层 $floor = BeautyParlorComment::maximum(["column" => "comment_floor", "conditions" => "appointment_id = :id: and beauty_parlor_id = :bp_id:", "bind" => ["id" => $appoint_id, "bp_id" => $bp_id]]); $bpc = new BeautyParlorComment(); $query = new CosOnlineAppointment(); $appoint = $query->findFirst("id = {$appoint_id}"); if ($appoint) { $data['state'] = 1; $rs = $appoint->update($data); } else { return $this->errorLog(ResultStatus::POST_BODY_PARAM_ERROR, "当前预约不存在"); } $bpc->user_id = $this->getUserAuth()->userId; $bpc->comment_floor = ($floor ? $floor : 0) + 1; $bpc->beauty_parlor_id = $bp_id; $bpc->comment_info = $comment_info; $bpc->comment_photos = $comment_photos; $bpc->type = $type; $bpc->appointment_id = $appoint_id; if ($bpc->save() && $rs) { $this->id = $bpc->comment_id; $this->success = 1; } else { return $this->databaseErrorLog($bpc); } } } else { return $this->errorLog(ResultStatus::POST_BODY_PARAM_ERROR, ""); } return $this->setResult(['id' => $this->id, 'success' => $this->success]); } } else { return $this->errorLog(ResultStatus::POST_BODY_PARAM_ERROR, "评论类型错误"); } /* $bp_id = intval($this->getDataItem('beauty_parlor_id',0)); $comment_info = Keyword::Filter($this->getDataItem('content','')); $up = new UploadPic(); $comment_photos = json_encode($up->beautyParlorComment()); if($bp_id > 0 && !empty($comment_info)) { // 查询最大楼层 $floor = BeautyParlorComment::maximum([ "column" => "comment_floor", "conditions" => "beauty_parlor_id = :id:", "bind" => [ "id" => $bp_id ] ]); //关键字替换 $keyword = CosQKeyword::query() -> execute() -> toArray(); foreach ($keyword as $k => $v){ $comment_info = str_replace($v['keyword'], '***', $comment_info); //$comment_info = str_replace($v['keyword'], str_repeat('*', strlen($v['keyword'])/3), $comment_info); } $bpc = new BeautyParlorComment(); $bpc->user_id = $this->getUserAuth()->userId; $bpc->comment_floor = ($floor ? $floor : 0) + 1; $bpc->beauty_parlor_id=$bp_id; $bpc->comment_info=$comment_info; $bpc->comment_photos=$comment_photos; if($bpc->save()){ $this->id = $bpc->comment_id; $this->success = 1; }else{ return $this->databaseErrorLog($bpc); } } else { return $this->errorLog(ResultStatus::POST_BODY_PARAM_ERROR, ""); } $this->setResult([ 'id'=>$this->id, 'success'=>$this->success ]); */ }