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); }
public function run() { //先验证城市是否开通 modify by tanjinyun 2016/01/11 $city_code = $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; } $longitude = $this->getDataItem('longitude', 0); $latitude = $this->getDataItem('latitude', 0); $page = intval($this->getDataItem('page', 1)); $medal = intval($this->getDataItem('medal', 0)); $keyword = trim($this->getDataItem('keyword', null)); $limit = $this->getConfig()->limit; // $longitude = 106.515605; // $latitude = 29.539727; $config = $this->getDi()->get('appConfig')->amap->lbs_cloud; $key = $config->key; $signKey = $config->sign_key; $tableId = $config->table_id; $syncLogTableName = 'beauty_parlor_amap_sync_log'; //v2.0新增 筛选 $filter = $medal == 1 ? "medal_verify:1" : null; $keywords = $keyword != null ? $keyword : null; $lbs = new LBSCloud($key, $signKey, $tableId, $syncLogTableName); $result = $lbs->around($latitude, $longitude, $limit, $page, $filter, $keywords); if ($result->status) { // var_dump($result);exit; foreach ($result->response as $data) { /** * modify by jinyu * 查询美容院扩展信息 */ $info = BeautyParlorAttr::query()->columns(['b.bp_id', 'b.bp_name', 'b.bp_address', 'b.bp_cover', 'b.bp_tel', 'b.bp_medal', 'open_time', 'close_time', 'low_price', 'open_year', 'shop_area', 'service_num', 'facilities'])->rightJoin('Apps\\Common\\Models\\BeautyParlor', 'b.bp_id = Apps\\Common\\Models\\BeautyParlorAttr.beauty_parlor_id', 'b')->where('beauty_parlor_id=:bp_id: AND bp_state >0')->bind(['bp_id' => $data['bp_id']])->execute()->getFirst(); if ($info) { $this->parlors[] = ['id' => $info['bp_id'], 'name' => $info['bp_name'], 'cover' => PicUrl::BeautyParlorCover($info['bp_cover'], $this->getDi()), 'address' => $info['bp_address'], 'tel' => $info['bp_tel'], 'tags' => $this->formatTagsV2($info['bp_id']), 'distance' => $this->formatDistance($data['_distance']), 'medal_verify' => \Apps\Common\Libs\BeautyParlor::getMedalVerify($info['bp_medal']), 'open_time' => $info['open_time'] == null ? '' : $info['open_time'], 'close_time' => $info['close_time'] == null ? '' : $info['close_time'], 'low_price' => $info['low_price'] == null ? '' : $info['low_price'], 'open_year' => $info['open_year'] == null ? '' : $info['open_year'], 'shop_area' => $info['shop_area'] == null ? '' : $info['shop_area'], 'service_num' => $info['service_num'] == null ? '' : $info['service_num'], 'facilities' => $info['facilities'] == null ? null : (json_decode($info['facilities']) ?: null)]; } else { continue; } } } /** * 第一页获取banner */ if ($page == 1) { $banner = OmBanner::query()->columns(['banner_data'])->where('state = 1 AND banner_name =3 AND city_id =:city_id:')->bind(['city_id' => $is_open->city_id])->execute()->toArray(); foreach ($banner as $k => $v) { $data = json_decode($v['banner_data']); $temp[$k]['url'] = PicUrl::DefaultPics($data->url, $this->getDi()); $temp[$k]['link_type'] = $data->link_type; $temp[$k]['link_data'] = !empty(json_decode($data->link_data)) ? json_decode($data->link_data) : null; } } $list['banner'] = $temp; $list['parlors'] = empty($this->parlors) ? null : $this->parlors; $this->setResult($list); }
/** * 更新数据 * @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; }