Example #1
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);
 }
Example #2
0
 private function getBeautyParlor($id)
 {
     $info = BeautyParlor::query()->columns(['bp_id as id', 'bp_name as name', 'bp_medal as medal', 'bp_address as address', 'bp_tel as tel', 'AsText(bp_coordinate) as bp_coordinate'])->where('bp_id=:id:')->bind(['id' => $id])->execute()->getFirst();
     $coordinate = str_replace("POINT(", '', $info->bp_coordinate);
     $coordinate = str_replace(")", '', $coordinate);
     $coordinate = explode(" ", $coordinate);
     if ($info) {
         return ['id' => $info->id, 'name' => $info->name, 'medal_refund' => \Apps\Common\Libs\BeautyParlor::getMedalRefund($info->medal), 'medal_verify' => \Apps\Common\Libs\BeautyParlor::getMedalVerify($info->medal), 'latitude' => $coordinate[0], 'longitude' => $coordinate[1], 'tel' => $info->tel, 'address' => $info->address];
     }
     return null;
 }
Example #3
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;
 }
 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;
 }
Example #5
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];
 }
Example #6
0
 private function syncBP($id)
 {
     $info = \Apps\Common\Models\BeautyParlor::findFirst('bp_id = ' . $id);
     if (!$info) {
         return false;
     }
     // 删除数据
     if ($info->bp_state <= 0) {
         $this->delete(SearchDataType::BeautyParlors, $info->bp_id);
         return true;
     }
     // 同步数据
     $bpTags = \Apps\Common\Libs\BeautyParlor::getTags($id);
     // 标题中包含的内容
     $titleArr = [$info->bp_name, implode(',', $bpTags), $info->bp_address];
     $title = implode(',', $titleArr);
     $searchContent = $info->bp_intro;
     $tagInt = \Apps\Common\Libs\SysArea::districtToOpenCityId($info->bp_district);
     $tagStr = strval($info->bp_tel);
     $showData = json_encode(['id' => $info->bp_id, 'name' => $info->bp_name, 'cover' => $info->bp_cover, 'address' => $info->bp_address, 'medal_refund' => \Apps\Common\Libs\BeautyParlor::getMedalRefund($info->bp_medal), 'medal_verify' => \Apps\Common\Libs\BeautyParlor::getMedalRefund($info->bp_medal), 'tags' => $bpTags]);
     $this->save(SearchDataType::BeautyParlors, $id, $showData, $title, $searchContent, $tagInt, $tagStr);
     return true;
 }
Example #7
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'])->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);
 }
Example #8
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);
 }
Example #9
0
 /**
  * 美容院
  */
 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);
 }