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); }
public function run() { $id = intval($this->getDataItem('id', 0)); if (0 < $id) { /** * 查询服务信息 */ $service = BeautyParlorService::query()->columns(['service_id as id', 'service_cover as cover', 'service_name as name', 'service_price as price', 'service_unit as price_show', 'service_state as state', 'service_description as description', 'service_intro as intro', 'beauty_parlor_id as bp_id', 'service_is_sell as is_sell'])->where('service_id=:id:')->bind(['id' => $id])->execute()->getFirst(); } $data = null; $beauty_parlor_info = BeautyParlor::query()->columns(['bp_address as address', 'bp_tel as tel', 'AsText(bp_coordinate) as bp_coordinate'])->where("bp_id = " . $service->bp_id)->execute()->getFirst(); $coordinate = str_replace("POINT(", '', $beauty_parlor_info->bp_coordinate); $coordinate = str_replace(")", '', $coordinate); $coordinate = explode(" ", $coordinate); if ($service) { $data = ['id' => $service->id, 'cover' => PicUrl::BeautyParlorCover($service->cover, $this->getDi()), 'name' => $service->name, 'price' => $service->price, 'description' => $service->description, 'intro' => \Apps\Common\Libs\BeautyParlor::formatServiceIntro($service->intro, $this->getDi(), true), 'service_state' => $service->state, 'is_sell' => $service->is_sell]; if ($service->price > 0) { $unit = $service->price_show; $data['price_show'] = $service->price . '元' . ($unit ? '/' . $unit : ''); } $data['beauty_parlor'] = $this->getBeautyParlor($service->bp_id); } $this->setResult($data); }
private function syncBPS($id) { $info = BeautyParlorService::findFirst('service_id = ' . $id); if (!$info) { return false; } // 删除数据 if ($info->service_state <= 0) { $this->delete(SearchDataType::BeautyParlorService, $info->service_id); return true; } // 店铺数据 $bpInfo = \Apps\Common\Models\BeautyParlor::findFirst('bp_id = ' . $info->beauty_parlor_id); // 同步数据 // 标题中包含的内容 $titleArr = [$info->service_name, $info->service_description]; $title = implode(',', $titleArr); $searchContent = \Apps\Common\Libs\BeautyParlor::formatServiceIntro($info->service_intro, $this->getDI()); $tagInt = $info->service_is_sell; $tagStr = ''; $showData = json_encode(['id' => $info->service_id, 'name' => $info->service_name, 'cover' => $info->service_cover, 'price' => $info->service_price, 'unit' => $info->service_unit, 'description' => $info->service_description, 'bp_id' => $bpInfo->bp_id, 'bp_name' => $bpInfo->bp_name]); $this->save(SearchDataType::BeautyParlorService, $id, $showData, $title, $searchContent, $tagInt, $tagStr); return true; }
/** * 美容院服务 */ public function beautyParlorServiceAction() { $id = $this->request->getQuery('id'); if (empty($id)) { echo '美容院服务项目不存在!'; $this->view->disable(); return; } $service = BeautyParlorService::query()->columns(['service_id as id', 'service_cover cover', 'service_name as name', 'service_price as price', 'service_unit as price_show', 'service_description as description', 'service_intro as intro', 'beauty_parlor_id as bp_id'])->where('service_state>0 and service_id=:id:')->bind(['id' => $id])->execute()->getFirst(); if (!$service) { echo '美容院服务项目不存在!'; $this->view->disable(); return; } $data = ['id' => $service->id, 'cover' => PicUrl::BeautyParlorCover($service->cover, $this->getDi()), 'name' => $service->name, 'price' => $service->price, 'description' => $service->description, 'intro' => \Apps\Common\Libs\BeautyParlor::formatServiceIntro($service->intro, $this->di)]; if ($service->price > 0) { $unit = $service->price_show; $data['price_show'] = $service->price . '元' . ($unit ? '/' . $unit : ''); } $data['beauty_parlor'] = BeautyParlor::query()->columns(['bp_id as id', 'bp_name as name', 'bp_medal as medal'])->where('bp_id=:id:')->bind(['id' => $service->bp_id])->execute()->getFirst(); $this->view->setVar('service', $data); $this->tag->setTitle($data['beauty_parlor']->name); }