Ejemplo n.º 1
0
 public function run()
 {
     if (false == $this->verifyUserAuth()) {
         return false;
     }
     $page = $this->getDataItem('page', 1);
     $limit = 10;
     $offset = ($page - 1) * $limit;
     $userId = $this->getUserAuth()->userId;
     if ($userId == '') {
         return $this->errorLog(ResultStatus::URL_PARAM_CANNOT_EMPTY, '参数异常');
     }
     //$userId=1;
     $my_favorites = BpFavorites::query()->where("user_id = {$userId}")->limit($limit, $offset)->execute()->toArray();
     foreach ($my_favorites as $fav) {
         $bp_list[] = BeautyParlor::findFirst(["bp_id = " . $fav['bp_id'], "columns" => ['bp_id as id', 'bp_name as name', 'bp_cover as cover', 'bp_address as address']])->toArray();
     }
     foreach ($bp_list as $k => $v) {
         $bp_list[$k]['cover'] = "http://img.meelier.com/" . $bp_list[$k]['cover'];
         $tagarr = BeautyParlorTag::query()->columns('i.tag_title')->leftJoin('Apps\\Common\\Models\\BeautyParlorTagInfo', 'Apps\\Common\\Models\\BeautyParlorTag.tag_id = i.tag_id', 'i')->where("Apps\\Common\\Models\\BeautyParlorTag.bp_id = " . $bp_list[$k]['id'])->orderby("Apps\\Common\\Models\\BeautyParlorTag.sort asc")->limit(3, 0)->execute()->toArray();
         $newarr = [];
         foreach ($tagarr as $key => $val) {
             $newarr[] = $tagarr[$key]['tag_title'];
         }
         $bp_list[$k]['tags'] = $newarr;
     }
     $this->setResult($bp_list);
 }
Ejemplo n.º 2
0
 /**
  * 获取美容院的标签信息
  * @param $id
  * @return array
  */
 public function getBeautyParlorTags($id)
 {
     $data = BeautyParlorTag::query()->columns(['tag_title'])->leftJoin('Apps\\Common\\Models\\BeautyParlorTagInfo', 'ti.tag_id = Apps\\Common\\Models\\BeautyParlorTag.tag_id', 'ti')->where('bp_id = :id: AND tag_state > 0', ['id' => $id])->execute();
     $result = [];
     foreach ($data as $d) {
         $result[] = $d->tag_title;
     }
     return $result;
 }
Ejemplo n.º 3
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;
 }
Ejemplo n.º 4
0
 public function run()
 {
     $city_code = $this->getDataItem('citycode', 0);
     $cityId = $this->getCityId($city_code);
     if ($cityId <= 0) {
         return $this->errorLog(ResultStatus::CITY_NOT_OPEN, '城市未开通');
         //$cityId=2;
     }
     $list = CosPointBp::query()->columns(['b.bp_name', 'Apps\\Common\\Models\\CosPointBp.img_url  as bp_cover', 'b.bp_address', 'b.bp_medal', 'b.bp_id'])->leftJoin('Apps\\Common\\Models\\BeautyParlor', 'Apps\\Common\\Models\\CosPointBp.bp_id=b.bp_id', 'b')->where('Apps\\Common\\Models\\CosPointBp.addr = "' . $cityId . '"')->orderBy('Apps\\Common\\Models\\CosPointBp.sort desc')->execute()->toArray();
     foreach ($list as $k => $v) {
         $list[$k]['medal_refund'] = substr($list[$k]['bp_medal'], 0, 1);
         $list[$k]['medal_verify'] = substr($list[$k]['bp_medal'], 1, 1);
         $list[$k]['bp_cover'] = "http://img.meelier.com/" . $list[$k]['bp_cover'];
         $list[$k]['tag'] = BeautyParlorTag::query()->columns('i.tag_title')->leftJoin('Apps\\Common\\Models\\BeautyParlorTagInfo', 'Apps\\Common\\Models\\BeautyParlorTag.tag_id = i.tag_id', 'i')->where("Apps\\Common\\Models\\BeautyParlorTag.bp_id = " . $list[$k]['bp_id'])->orderby("Apps\\Common\\Models\\BeautyParlorTag.sort asc")->limit(3, 0)->execute()->toArray();
     }
     foreach ($list as $k => $v) {
         unset($list[$k]['bp_medal']);
     }
     if (count($list) == 0) {
         unset($list);
     }
     $this->setResult($list);
 }
Ejemplo n.º 5
0
 /**
  * 获取美容院的标签信息
  * @param $id
  * @return array
  */
 protected function getBeautyParlorTags($id)
 {
     return BeautyParlorTag::query()->columns(['bp_tag_id', 'tag_title', 'Apps\\Common\\Models\\BeautyParlorTag.tag_id tag_id'])->leftJoin('Apps\\Common\\Models\\BeautyParlorTagInfo', 'ti.tag_id = Apps\\Common\\Models\\BeautyParlorTag.tag_id', 'ti')->where('bp_id = :id: AND tag_state > 0', ['id' => $id])->orderby("Apps\\Common\\Models\\BeautyParlorTag.sort asc")->execute();
 }
Ejemplo n.º 6
0
 /**
  * 更新数据
  * @return ResponseResult
  */
 private function updateSave()
 {
     $req = $this->request;
     $response = new ResponseResult();
     $response->callback = $req->getPost('callback', null, 'parent.setFormResult');
     $response->callbackJavascriptTag = true;
     $id = intval($req->getPost('bp_id'));
     if ($id < 1) {
         $response->sendError(ResponseResultStatus::PARAM_CANNOT_EMPTY, '参数异常!');
         return $response;
     }
     $name = $req->getPost('bp_name');
     $district = intval($req->getPost('bp_district', null, 0));
     $address = $req->getPost('bp_address');
     $coordinate = $req->getPost('bp_coordinate');
     $tel = $req->getPost('bp_tel');
     $isSell = intval($req->getPost('bp_is_sell', null, 0));
     $medalRefund = intval($req->getPost('bp_medal_refund', null, 0));
     $medalVerify = intval($req->getPost('bp_medal_verify', null, 0));
     $tags = $req->getPost('bp_tags');
     $ownerMobile = $req->getPost('bp_owner_mobile');
     $intro = $req->getPost('bp_intro');
     // 判断空数据
     if (empty($name) || $district <= 0 || empty($address) || empty($coordinate) || empty($tel) || empty($tags) || empty($intro) || empty($ownerMobile)) {
         $response->sendError(ResponseResultStatus::PARAM_CANNOT_EMPTY, '参数异常!');
         return $response;
     }
     // 保存封面
     $uploadFile = new UploadPic();
     $uploadFile->request = $req;
     $cover = $uploadFile->beautyParlorCover();
     if ($cover == false || !is_array($cover) || count($cover) == 0 || $cover[0] == false) {
         $bpCover = null;
     } else {
         $bpCover = $cover[0];
     }
     // 保存基础数据
     $coordinate = str_replace(',', ' ', $coordinate);
     $bp = BeautyParlor::findFirst('bp_id = ' . $id);
     $data = [];
     if ($bp->bp_name != $name) {
         $data['bp_name'] = $name;
     }
     if (!!$bpCover) {
         $data['bp_cover'] = $bpCover;
     }
     if ($bp->bp_address != $address) {
         $data['bp_address'] = $address;
     }
     if ($bp->bp_district != $district) {
         $data['bp_district'] = $district;
     }
     $data['bp_coordinate'] = new RawValue("GeomFromText('POINT({$coordinate})')");
     if ($bp->bp_tel != $tel) {
         $data['bp_tel'] = $tel;
     }
     if ($bp->bp_owner_mobile != $ownerMobile) {
         $data['bp_owner_mobile'] = $ownerMobile;
     }
     if ($bp->bp_intro != $intro) {
         $data['bp_intro'] = $intro;
     }
     if ($bp->bp_is_sell != $isSell) {
         $data['bp_is_sell'] = $isSell;
     }
     $data['bp_medal'] = strval($medalRefund) . strval($medalVerify);
     $bp->update($data);
     /*标签排序  */
     $tagsarr = explode(",", $tags);
     $status = BeautyParlorTag::find("bp_id = {$id}")->delete();
     if (!$status) {
         $response->sendError(ResponseResultStatus::PARAM_ERROR, '保存标签失败!');
     }
     foreach ($tagsarr as $k => $tag) {
         $taginfo = BeautyParlorTagInfo::find("tag_id = {$tag} and tag_state = 1")->toArray();
         $count = count($taginfo);
         if ($count < 1) {
             $response->sendError(ResponseResultStatus::PARAM_ERROR, '没有ID为' . $tag . '的标签!');
         }
         $tagDb = new BeautyParlorTag();
         $tagDb->bp_id = $id;
         $tagDb->tag_id = $tag;
         $tagDb->sort = $k + 1;
         if ($tagDb->save() == false) {
             $this->databaseErrorLog($tagDb);
         }
     }
     /* 
             $tagsArr = explode(',', $tags);
            	foreach($tagsArr as $tag) {
                 $tagDb = BeautyParlorTag::query()
                     ->columns('bp_tag_id, bp_id, tag_id')
                     ->where('bp_id = :bid: AND tag_id = :tid:')
                     ->bind(['bid'=>$id, 'tid'=>$tag])
                     ->execute()->getFirst();
                 if(!$tagDb) {
                     $tagDb = new BeautyParlorTag();
                     $tagDb->bp_id = $id;
                     $tagDb->tag_id = $tag;
                     if ($tagDb->save() == false) {
                         $this->databaseErrorLog($tagDb);
                     }
                 }
             } */
     // 获取所有的标签
     /* $tagList = BeautyParlorTag::query()
            ->where('bp_id = :bid:')
            ->bind(['bid'=>$id])
            ->execute();
        foreach($tagList as $t) {
            if(in_array(strval($t->tag_id), $tagsArr) == false) {
                $t->delete();
            }
        } */
     // 保存轮播图片
     // 轮播图片
     $pics = $uploadFile->beautyParlorPics();
     if ($pics) {
         foreach ($pics as $pic) {
             $picDb = new BeautyParlorPhotos();
             $picDb->beauty_parlor_id = $id;
             $picDb->photo_url = $pic;
             if ($picDb->save() == false) {
                 $this->databaseErrorLog($picDb);
             }
         }
     }
     SearchASync::Instance()->noticeSync($id, SearchDataType::BeautyParlors);
     $response->sendResult('ok');
     return $response;
 }
Ejemplo n.º 7
0
 public function run()
 {
     //判断城市是否开通 未开通城市  banner 广告位显示全国 美容院不显示
     $banners = [];
     //首页banner
     $questionlists = [];
     //首页推荐问答
     $city_code = $this->getDataItem('city_code', 0);
     $userid = $this->getDataItem('user_id', 0);
     $is_open = SysOpenCity::findFirst(['columns' => "city_id", 'conditions' => "city_code = {$city_code} AND city_state = 1"]);
     $city_id = $is_open->city_id > 0 ? $is_open->city_id : 0;
     $alllimit = $this->getConfig()->national;
     //属于全国的banner条数
     //获取全国banner
     $banners = $this->getBanner($alllimit, 0);
     //获取属于全国的广告
     $advert = $this->getAdvert(0, null, "addtime desc", "position");
     //获取城市问答
     $limit_q = $this->getConfig()->question;
     $questionlists = $this->getQuestion(0, $limit_q, $userid, "sort DESC");
     //城市未开通
     if (!$city_id) {
         foreach ($advert as $k => $v) {
             $advert[$k]['advertisement_cover'] = PicUrl::ActivityCover($v['advertisement_cover'], $this->getDi());
         }
         $lists['banner'] = $banners;
         $lists['question'] = $questionlists;
         $lists['parlors'] = null;
         $lists['adverts'] = empty($advert) ? null : $advert;
         $this->setResult($lists);
     } else {
         $citylimit = $this->getConfig()->city;
         //获取城市banner
         $citybanner = $this->getBanner($citylimit, $city_id);
         $banners = array_merge($banners, $citybanner);
         //获取城市问答
         if (count($questionlists) < $limit_q) {
             //如果全国的问答条数不足 则查询城市问答补充
             $limit_c = $limit_q - count($questionlists);
             $questionlist = $this->getQuestion($city_id, $limit_c, $userid, "sort DESC");
             $questionlists = array_merge($questionlists, $questionlist);
         }
         /*************************************************获取城市广告**********************************/
         $pos_ids = array_column($advert, 'position');
         //如果没有全国的位置1的广告 则 查询是否有全国位置为1的广告
         if (!in_array(1, $pos_ids)) {
             $temp = $this->getAdvert($city_id, "position = 1", "addtime desc");
             if (count($temp)) {
                 $advert = array_merge($advert, $temp);
             }
         }
         //如果没有全国的位置2的广告 则 查询是否有全国位置为2的广告
         if (!in_array(2, $pos_ids)) {
             $temp = $this->getAdvert($city_id, "position = 2", "addtime desc");
             if (count($temp)) {
                 $advert = array_merge($advert, $temp);
             }
         }
         //如果没有全国的位置3的广告 则 查询是否有全国位置为3的广告
         if (!in_array(3, $pos_ids)) {
             $temp = $this->getAdvert($city_id, "position = 3", "addtime desc");
             if (count($temp)) {
                 $advert = array_merge($advert, $temp);
             }
         }
         $advert = $this->multi_array_sort($advert, 'position');
         foreach ($advert as $k => $v) {
             $advert[$k]['advertisement_cover'] = PicUrl::ActivityCover($v['advertisement_cover'], $this->getDi());
         }
         /*************************************************美容院*****************************************/
         //获取位置固定的美容院
         $parlor = $this->getParlor($city_id, 3, "show_start_time DESC,id DESC", "sort");
         $sortids = array_column($parlor, 'sort');
         if (count($sortids) < 3) {
             //当固定位置的首页推荐美容院不足时,随机获取没有固定位置的推荐数据
             $limit_r = 3 - count($sortids);
             $parlor_r = $this->getParlorRand($city_id, $limit_r);
             $parlor = array_merge($parlor, $parlor_r);
         }
         $parlor = $this->multi_array_sort($parlor, 'sort');
         foreach ($parlor as $k => $v) {
             if ($v) {
                 $parlor[$k]['cover'] = PicUrl::BeautyParlorCover($v['cover'], $this->getDi());
                 $parlor[$k]['medal_verify'] = \Apps\Common\Libs\BeautyParlor::getMedalVerify($v['bp_medal']);
                 unset($parlor[$k]['bp_medal']);
                 $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' => $v['id']])->orderBy('sort desc,bp_tag_addtime asc')->execute()->toArray();
                 $tags = array_column($tag, 'tag_title');
                 $parlor[$k]['tags'] = empty($tags) ? null : $tags;
             }
         }
         /***************************************************返回结果集******************************************/
         $lists['banner'] = empty($banners) ? null : $banners;
         $lists['question'] = empty($questionlists) ? null : $questionlists;
         $lists['parlors'] = empty($parlor) ? null : $parlor;
         $lists['adverts'] = empty($advert) ? null : $advert;
         $this->setResult($lists);
     }
 }
Ejemplo n.º 8
0
 private function getsql($keyword)
 {
     $tmp = [];
     $wherearr = [];
     $newarr = [];
     $keywordarr = explode(" ", $keyword);
     foreach ($keywordarr as $k => $v) {
         unset($tmp);
         $tmp = BeautyParlorTagInfo::query()->columns("tag_id")->where("tag_title = '" . $v . "'")->execute()->toArray();
         if (count($tmp) > 0) {
             //$arr['tag'][]=$tmp;
             $tag_id = BeautyParlorTag::query()->columns("bp_id")->where("tag_id = " . $tmp[0]['tag_id'] . " and sort < 4")->execute()->toArray();
             if (count($tag_id) > 0) {
                 foreach ($tag_id as $r) {
                     $newarr[] = $r['bp_id'];
                 }
                 $bp_ids = implode(",", $newarr);
                 $wherearr[] = "bp_id in ({$bp_ids})";
                 $order = " find_in_set(bp_id,'{$bp_ids}') ";
             }
         }
     }
     foreach ($keywordarr as $k => $v) {
         unset($tmp);
         $tmp = BeautyParlorModel::query()->columns("bp_name")->where("bp_name like '%" . $v . "%'")->execute()->toArray();
         if (count($tmp) > 0) {
             $wherearr[] = "bp_name like '%" . $v . "%'";
         }
     }
     foreach ($keywordarr as $k => $v) {
         unset($tmp);
         $tmp = BeautyParlorModel::query()->columns("bp_address")->where("bp_address like '%" . $v . "%'")->execute()->toArray();
         if (count($tmp) > 0) {
             $wherearr[] = "bp_address like '%" . $v . "%'";
         }
     }
     foreach ($keywordarr as $k => $v) {
         unset($tmp);
         $tmp = BeautyParlorModel::query()->columns("bp_intro")->where("bp_intro like '%" . $v . "%'")->execute()->toArray();
         if (count($tmp) > 0) {
             $wherearr[] = "bp_intro like '%" . $v . "%'";
         }
     }
     $where = implode(" or ", $wherearr);
     if ($where != '') {
         $data['where'] = "(" . $where . ") and (bp_state = 1)";
     } else {
         $data['where'] = "";
     }
     if ($order == '') {
         $order = " bp_id desc";
     }
     $data['order'] = $order;
     return $data;
 }
Ejemplo n.º 9
0
 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);
 }
Ejemplo n.º 10
0
 /**
  * 更新数据
  * @return ResponseResult
  */
 private function updateSave()
 {
     $req = $this->request;
     $response = new ResponseResult();
     $response->callback = $req->getPost('callback', null, 'parent.setFormResult');
     $response->callbackJavascriptTag = true;
     $id = intval($req->getPost('bp_id'));
     if ($id < 1) {
         $response->sendError(ResponseResultStatus::PARAM_CANNOT_EMPTY, '参数异常!');
         return $response;
     }
     $name = $req->getPost('bp_name');
     $district = intval($req->getPost('bp_district', null, 0));
     $address = $req->getPost('bp_address');
     $coordinate = $req->getPost('bp_coordinate');
     $tel = $req->getPost('bp_tel');
     $isSell = intval($req->getPost('bp_is_sell', null, 0));
     $medalRefund = intval($req->getPost('bp_medal_refund', null, 0));
     $medalVerify = intval($req->getPost('bp_medal_verify', null, 0));
     $tags = $req->getPost('bp_tags');
     $ownerMobile = $req->getPost('bp_owner_mobile');
     $intro = $req->getPost('bp_intro');
     ////////////////////////////////////2.0新加参数////2.0新加参数///////2.0新加参数///////2.0新加参数///////////////////////////////
     $low_price = $req->getPost("low_price", null, 0);
     //起步价
     $open_year = $req->getPost("open_year", null, 0);
     //开业年限
     $shop_area = $req->getPost("shop_area", null, 0);
     //店铺面积
     $service_num = $req->getPost("service_num", null, 0);
     //服务项目数量
     $op_cl_time = $req->getPost("time", null, '');
     //营业时间
     $facilities = $req->getPost("facilities", null, '');
     //设备设施
     if ($op_cl_time != '') {
         $op_cl_time_arr = explode("至", $op_cl_time);
         $open_time = trim($op_cl_time_arr[0]);
         $close_time = trim($op_cl_time_arr[1]);
     } else {
         $open_time = '';
         $close_time = '';
     }
     if ($low_price < 0 || $open_year < 0 || $shop_area < 0 || $service_num < 0) {
         $response->sendError(ResponseResultStatus::PARAM_CANNOT_EMPTY, '数据不能为空!');
         return;
     }
     if ($facilities != '') {
         try {
             $facilities_json = json_encode($facilities);
         } catch (\Exception $e) {
             $response->sendError(ResponseResultStatus::PARAM_CANNOT_EMPTY, '数据错误!');
             return;
         }
     } else {
         $facilities_json = null;
     }
     /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     // 判断空数据
     if (empty($name) || $district <= 0 || empty($address) || empty($coordinate) || empty($tel) || empty($tags) || empty($intro) || empty($ownerMobile)) {
         $response->sendError(ResponseResultStatus::PARAM_CANNOT_EMPTY, '参数异常!');
         return $response;
     }
     // 保存封面
     $uploadFile = new UploadPic();
     $uploadFile->request = $req;
     $cover = $uploadFile->beautyParlorCover();
     if ($cover == false || !is_array($cover) || count($cover) == 0 || $cover[0] == false) {
         $bpCover = null;
     } else {
         $bpCover = $cover[0];
     }
     // 保存基础数据
     $coordinate = str_replace(',', ' ', $coordinate);
     $bp = BeautyParlor::findFirst('bp_id = ' . $id);
     $data = [];
     if ($bp->bp_name != $name) {
         $data['bp_name'] = $name;
     }
     if (!!$bpCover) {
         $data['bp_cover'] = $bpCover;
     }
     if ($bp->bp_address != $address) {
         $data['bp_address'] = $address;
     }
     if ($bp->bp_district != $district) {
         $data['bp_district'] = $district;
     }
     $data['bp_coordinate'] = new RawValue("GeomFromText('POINT({$coordinate})')");
     if ($bp->bp_tel != $tel) {
         $data['bp_tel'] = $tel;
     }
     if ($bp->bp_owner_mobile != $ownerMobile) {
         $data['bp_owner_mobile'] = $ownerMobile;
     }
     if ($bp->bp_intro != $intro) {
         $data['bp_intro'] = $intro;
     }
     if ($bp->bp_is_sell != $isSell) {
         $data['bp_is_sell'] = $isSell;
     }
     $data['bp_medal'] = strval($medalRefund) . strval($medalVerify);
     $bp->update($data);
     /*保存美容院相关数据  */
     $bp_attr = BeautyParlorAttr::findFirst("beauty_parlor_id = {$id}");
     if (!$bp_attr) {
         /* $response->sendError(ResponseResultStatus::ERROR, '修改失败!');
           	return $response; */
         $bp_attr = new BeautyParlorAttr();
     }
     $bp_attr->beauty_parlor_id = $id;
     $bp_attr->close_time = $close_time;
     $bp_attr->open_time = $open_time;
     $bp_attr->low_price = $low_price;
     $bp_attr->open_year = $open_year;
     $bp_attr->facilities = $facilities_json;
     $bp_attr->service_num = $service_num;
     $bp_attr->shop_area = $shop_area;
     if (!$bp_attr->save()) {
         $response->sendError(ResponseResultStatus::ERROR, '添加失败!');
     }
     //处理标签
     $tagsArr = explode(',', $tags);
     foreach ($tagsArr as $tag) {
         $tagDb = BeautyParlorTag::query()->columns('bp_tag_id, bp_id, tag_id')->where('bp_id = :bid: AND tag_id = :tid:')->bind(['bid' => $id, 'tid' => $tag])->execute()->getFirst();
         if (!$tagDb) {
             $tagDb = new BeautyParlorTag();
             $tagDb->bp_id = $id;
             $tagDb->tag_id = $tag;
             if ($tagDb->save() == false) {
                 $this->databaseErrorLog($tagDb);
             }
         }
     }
     // 获取所有的标签
     $tagList = BeautyParlorTag::query()->where('bp_id = :bid:')->bind(['bid' => $id])->execute();
     foreach ($tagList as $t) {
         if (in_array(strval($t->tag_id), $tagsArr) == false) {
             $t->delete();
         }
     }
     // 保存轮播图片
     // 轮播图片
     $pics = $uploadFile->beautyParlorPics();
     if ($pics) {
         foreach ($pics as $pic) {
             $picDb = new BeautyParlorPhotos();
             $picDb->beauty_parlor_id = $id;
             $picDb->photo_url = $pic;
             if ($picDb->save() == false) {
                 $this->databaseErrorLog($picDb);
             }
         }
     }
     SearchASync::Instance()->noticeSync($id, SearchDataType::BeautyParlors);
     $response->sendResult('ok');
     return $response;
 }