public function run() { $to_user_id = $this->getDataItem('user_id'); if (!(is_numeric($to_user_id) && $to_user_id > 0)) { return $this->errorLog(ResultStatus::POST_BODY_PARAM_ERROR, '用户id不能为空.'); } /** * 验证用户权限 */ /*if(!empty($this->parameters->userToken) && $this->verifyUserAuth() && $this->getUserAuth()->userId == $userid){ return $this->errorLog(111, '请跳转我的问答.'); }*/ $field = ['user_cover', 'user_nickname', 'user_gender', 'user_birthday', 'user_realname', 'user_district', 'user_money', 'user_money_virtual', 'bind_phone user_mobile', 'persional_sign', 'user_expert']; $info = UserBase::query()->columns($field)->where('user_id=' . $to_user_id)->execute()->getFirst()->toArray(); // 获取城市信息 $SysAreaZipDistrictPhonecode = new SysAreaZipDistrictPhonecode(); $city = $SysAreaZipDistrictPhonecode->getOne($info['user_district']); $info['user_district'] = $city['FULL_NAME'] ?: ''; // 加入关注数和粉丝数 $UserFollow = new UserFollow(); $info['follow_count'] = $UserFollow->getFollowCount($to_user_id, 1); $info['fans_count'] = $UserFollow->getToFollowCount($to_user_id, 1); $info['user_cover'] = $info['user_cover'] ? PicUrl::UserCover($info['user_cover'], $this->getDi()) : ''; $info['persional_sign'] = $info['persional_sign'] ? unserialize(base64_decode($info['persional_sign'])) : ''; $this->verifyUserAuth(false); if ($user_id = $this->getUserAuth()->userId) { $info['is_follow'] = $UserFollow->is_follow($user_id, $to_user_id, 1) ? '1' : '0'; } else { $info['is_follow'] = '0'; } $this->setResult($info); }
public function run() { $page = intval($this->getDataItem('page', 1)); $keyword = $this->getDataItem('keyword'); $city_code = trim($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; } //根据城市编码 获取 城市区 $city = SysAreaZipDistrictPhonecode::query()->columns(['K_ID'])->where("PHONE_CODE = {$city_code}")->execute()->toArray(); foreach ($city as $k) { $citys[] = $k['K_ID']; } $citys = implode(',', $citys); $count = $this->getConfig()->limit; if (empty($keyword)) { $offset = ($page - 1) * $count; $list = BeautyParlorServiceModel::query()->columns(['service_id id', 'service_cover cover', 'service_name name', 'service_price price', 'service_unit unit', 'service_description description', 'b.bp_id', 'b.bp_name'])->leftJoin('Apps\\Common\\Models\\BeautyParlor', 'Apps\\Common\\Models\\BeautyParlorService.beauty_parlor_id = b.bp_id', 'b')->where("Apps\\Common\\Models\\BeautyParlorService.service_state = 1 and b.bp_state = 1 AND b.bp_district in ({$citys})")->limit($count, $offset)->execute()->toArray(); foreach ($list as $k => $v) { $unit = $v['unit']; unset($v['unit']); $list[$k]['price_show'] = ''; if ($v['price'] > 0) { $list[$k]['price_show'] = $v['price'] . '元' . ($unit ? '/' . $unit : ''); } $list[$k]['cover'] = PicUrl::BeautyParlorCover($list[$k]['cover'], $this->getDi()); } $this->setResult($list); } else { /*多关键字搜索*/ $keywordarr = explode(" ", trim($keyword)); foreach ($keywordarr as $r) { $wherearr[] = "Apps\\Common\\Models\\BeautyParlorService.service_name like '%" . $r . "%'"; } $where = implode(" or ", $wherearr); //////////////////////////////////////////////////////////////// /* $limit = $this->getConfig()->limit; $offset = ($page-1) * $limit; $data = $this->searchBPS($keyword, $limit, $offset); $this->setResult($data); */ $offset = ($page - 1) * $count; $list = BeautyParlorServiceModel::query()->columns(['service_id id', 'service_cover cover', 'service_name name', 'service_price price', 'service_unit unit', 'service_description description', 'b.bp_id', 'b.bp_name'])->leftJoin('Apps\\Common\\Models\\BeautyParlor', 'Apps\\Common\\Models\\BeautyParlorService.beauty_parlor_id = b.bp_id', 'b')->where("{$where} and Apps\\Common\\Models\\BeautyParlorService.service_state = 1 and b.bp_state = 1 AND b.bp_district in ({$citys})")->limit($count, $offset)->execute()->toArray(); foreach ($list as $k => $v) { $unit = $v['unit']; unset($list[$k]['unit']); $list[$k]['price_show'] = ''; if ($v['price'] > 0) { $list[$k]['price_show'] = $v['price'] . '元' . ($unit ? '/' . $unit : ''); } $list[$k]['cover'] = PicUrl::BeautyParlorCover($list[$k]['cover'], $this->getDi()); } $this->setResult($list); } }
public function run() { $account = $this->getDataItem('account'); // 验证电话号码格式 $password = $this->getDataItem('password'); $pushId = $this->getDataItem('push_id', ''); // push id $osType = $this->getDataItem('os_type'); // $account = '18723568682'; // $password = '******'; // 验证数据完整 if (empty($account) || empty($password)) { $this->message = '账户名和密码都不能为空!'; } else { if ($this->verifyAccount($account, $password)) { // 获取 user token if ($this->saveuserauth($this->apiAccessToken->id, $this->userInfo['user_id'])) { $this->success = 1; $this->message = '登录成功!'; $this->userToken = $this->getUserAuth()->userToken; $this->saveUserPushId($this->userInfo['user_id'], $pushId, $osType); $this->userInfo['user_mobile'] = $this->userInfo['bind_phone'] ?: $this->userInfo['user_account']; $this->userInfo['user_cover'] = $this->userInfo['user_cover'] ? PicUrl::UserCover($this->userInfo['user_cover'], $this->getDi()) : ''; $this->userInfo['persional_sign'] = $this->userInfo['persional_sign'] ? unserialize(base64_decode($this->userInfo['persional_sign'])) : ''; // 获取城市信息 $SysAreaZipDistrictPhonecode = new SysAreaZipDistrictPhonecode(); $city = $SysAreaZipDistrictPhonecode->getOne($this->userInfo['user_district']); $this->userInfo['user_district'] = $city['FULL_NAME'] ?: ''; // 加入关注数和粉丝数 $UserFollow = new UserFollow(); $this->userInfo['follow_count'] = $UserFollow->getFollowCount($this->userInfo['user_id'], 1); $this->userInfo['fans_count'] = $UserFollow->getToFollowCount($this->userInfo['user_id'], 1); // 删除不要的字段 unset($this->userInfo['user_account'], $this->userInfo['user_password'], $this->userInfo['user_state'], $this->userInfo['user_addtime'], $this->userInfo['is_manage'], $this->userInfo['bind_phone']); } else { $this->message = '获取User Token异常!'; } } } if (!$this->userInfo) { // 登录失败依然保留字段 $this->userInfo = ["user_id" => "", "user_nickname" => "", "user_mobile" => "", "user_cover" => "", "user_gender" => "0", "user_birthday" => "", "user_realname" => "", "user_expert" => "", "user_district" => "", "user_money" => "", "user_money_virtual" => "", "persional_sign" => "", "follow_count" => 0, "fans_count" => 0]; } $info = ['success' => $this->success, 'user_token' => $this->userToken, 'message' => $this->message]; $info = array_merge($info, $this->userInfo); $this->setResult($info); }
public function run() { // 验证用户权限 if (!$this->verifyUserAuth()) { return false; } $field = ['user_cover', 'user_nickname', 'user_gender', 'user_birthday', 'user_realname', 'user_district', 'user_money', 'user_money_virtual', 'bind_phone user_mobile', 'persional_sign', 'user_id', 'user_expert']; $info = UserBase::query()->columns($field)->where('user_id=' . $this->getUserAuth()->userId)->execute()->getFirst()->toArray(); // 获取城市信息 $SysAreaZipDistrictPhonecode = new SysAreaZipDistrictPhonecode(); $city = $SysAreaZipDistrictPhonecode->getOne($info['user_district']); $info['user_district'] = $city['FULL_NAME'] ?: ''; $info['user_cover'] = $info['user_cover'] ? PicUrl::UserCover($info['user_cover'], $this->getDi()) : ''; $info['persional_sign'] = $info['persional_sign'] ? unserialize(base64_decode($info['persional_sign'])) : ''; // 加入关注数和粉丝数 $UserFollow = new UserFollow(); $info['follow_count'] = $UserFollow->getFollowCount($info['user_id'], 1); $info['fans_count'] = $UserFollow->getToFollowCount($info['user_id'], 1); $this->setResult($info); }
/** * 通过区县标识获取开通城市ID * @param $district * @return int */ public static function districtToOpenCityId($district) { // 获取地区的区号 $area = SysAreaZipDistrictPhonecode::findFirst('K_ID = ' . $district); if (!$area) { return 0; } $phoneCode = $area->PHONE_CODE; $openCityInfo = SysOpenCity::query()->where('city_code = :code:', ['code' => $phoneCode])->execute()->getFirst(); if (!$openCityInfo) { return 0; } return $openCityInfo->city_id; }
public function areaAction() { $this->view->disable(); $province = SysAreaZipDistrictPhonecode::getProvince(); $data = []; foreach ($province as $p) { $pv = $p['value']; $city = SysAreaZipDistrictPhonecode::getCity($pv); $cityData = []; foreach ($city as $c) { $cv = $c['value']; $district = SysAreaZipDistrictPhonecode::getDistrict($pv, $cv); $districtData = []; foreach ($district as $d) { $districtData[] = [$d['id'], $d['value']]; } $cityData[] = [$cv, $districtData]; } $data[] = [$pv, $cityData]; } echo json_encode($data, JSON_UNESCAPED_UNICODE); }
/** * 用户列表 */ public function listAction() { $this->setLeftNav('list'); $req = $this->request; $page = intval($req->getQuery('page', null, 1)); $page = $page > 0 ? $page : 1; $limit = $this->pageNavLimit; $offset = $limit * ($page - 1); $columns = ['user_id', 'user_account', 'user_nickname', 'user_cover', 'user_gender', 'user_expert', 'user_birthday', 'user_realname', 'user_district', 'FULL_NAME district', 'user_state', 'user_addtime', 'persional_sign']; $filterName = $req->getQuery('filterName', null, ''); $filterMobile = $req->getQuery('filterMobile', null, ''); $filterState = intval($req->getQuery('filterState', null, -10000)); $filterGender = intval($req->getQuery('filterGender', null, -10000)); $filterExpert = intval($req->getQuery('filterExpert', null, -10000)); $filterProvince = $req->getQuery('filterProvince', null, ''); $filterCity = $req->getQuery('filterCity', null, ''); $filterDistrict = intval($req->getQuery('filterDistrict', null, -10000)); $where = []; $bind = []; if (!!$filterName) { $where[] = 'user_nickname LIKE :fname:'; $bind['fname'] = '%' . $filterName . '%'; } if (!!$filterMobile) { $where[] = 'user_account = :mobile:'; $bind['mobile'] = $filterMobile; } if ($filterState > -10000) { $where[] = 'user_state = :state:'; $bind['state'] = $filterState; } if ($filterGender > -10000) { $where[] = 'user_gender = :gender:'; $bind['gender'] = $filterGender; } if ($filterExpert > -10000) { $where[] = 'user_expert = :expert:'; $bind['expert'] = $filterExpert; } // 地区 $districts = []; if ($filterDistrict > -10000) { $where[] = 'user_district = :district:'; $bind['district'] = $filterDistrict; } elseif (!empty($filterCity)) { // 获取所有城市的下级区县值 $dids = SysAreaZipDistrictPhonecode::query()->columns(['K_ID id'])->where('P_NM = :province: AND C_NM = :city:', ['province' => $filterProvince, 'city' => $filterCity])->execute(); foreach ($dids as $d) { $districts[] = $d->id; } } elseif (!empty($filterProvince)) { // 获取所有城市的下级区县值 $dids = SysAreaZipDistrictPhonecode::query()->columns(['K_ID id'])->where('P_NM = :p:', ['p' => $filterProvince])->execute(); foreach ($dids as $d) { $districts[] = $d->id; } } if (count($districts) > 0) { $where[] = 'user_district IN(' . implode(', ', $districts) . ')'; } $whereStr = count($where) > 0 ? implode(' AND ', $where) : ''; $query = UserBase::query()->columns($columns)->leftJoin('Apps\\Common\\Models\\SysAreaZipDistrictPhonecode', 'K_ID=user_district', 'area'); if (count($where) > 0) { $query = $query->where($whereStr); } if (count($bind) > 0) { $query = $query->bind($bind); } $data = $query->orderBy('user_id DESC')->limit($limit, $offset)->execute(); $total = UserBase::count(['conditions' => $whereStr, 'bind' => $bind]); $this->view->setVars(['filterName' => $filterName, 'filterMobile' => $filterMobile, 'filterState' => $filterState, 'filterGender' => $filterGender, 'filterExpert' => $filterExpert, 'filterProvince' => $filterProvince, 'filterCity' => $filterCity, 'filterDistrict' => $filterDistrict]); $this->view->setVars(['page' => $page, 'limit' => $limit, 'total' => $total]); $this->view->setVar('data', $data); }
protected function getDistrictInfo($id) { return SysAreaZipDistrictPhonecode::findFirst('K_ID = ' . $id); }
/** * 美容院列表 */ public function listAction() { $this->setLeftNav('bp_list'); $req = $this->request; $page = intval($req->getQuery('page', null, 1)); $page = $page > 0 ? $page : 1; $limit = $this->pageNavLimit; $offset = $limit * ($page - 1); $filterProvince = $req->getQuery('filterProvince', null, ''); $filterCity = $req->getQuery('filterCity', null, ''); $filterDistrict = intval($req->getQuery('filterDistrict', null, -10000)); $filterState = intval($req->getQuery('filterState', null, -10000)); $filterSell = intval($req->getQuery('filterSell', null, -10000)); $filterMedal = intval($req->getQuery('filterMedal', null, -10000)); $filterName = $req->getQuery('filterName', null, ''); $columns = ['bp_id', 'bp_name', 'bp_cover', 'bp_address', 'bp_district', 'FULL_NAME district', 'bp_coordinate', 'bp_tel', 'bp_intro', 'bp_state', 'bp_is_sell', 'bp_medal', 'bp_addtime']; $where = []; $bind = []; $medal = []; if (!!$filterName) { $where[] = 'bp_name LIKE :fname:'; $bind['fname'] = '%' . $filterName . '%'; } if ($filterState > -10000) { $where[] = 'bp_state = :state:'; $bind['state'] = $filterState; } if ($filterSell > -10000) { $where[] = 'bp_is_sell = :sell:'; $bind['sell'] = $filterSell; } // 勋章 switch ($filterMedal) { case 1: $medal = ['10', '11']; break; case 2: $medal = ['01', '11']; break; case 3: $where[] = 'bp_medal = :medal:'; $bind['medal'] = '11'; } $districts = []; // 地区 if ($filterDistrict > -10000) { $where[] = 'bp_district = :district:'; $bind['district'] = $filterDistrict; } elseif (!empty($filterCity)) { // 获取所有城市的下级区县值 $dids = SysAreaZipDistrictPhonecode::query()->columns(['K_ID id'])->where('P_NM = :province: AND C_NM = :city:', ['province' => $filterProvince, 'city' => $filterCity])->execute(); foreach ($dids as $d) { $districts[] = $d->id; } } elseif (!empty($filterProvince)) { // 获取所有城市的下级区县值 $dids = SysAreaZipDistrictPhonecode::query()->columns(['K_ID id'])->where('P_NM = :p:', ['p' => $filterProvince])->execute(); foreach ($dids as $d) { $districts[] = $d->id; } } if (count($medal) > 0) { $where[] = 'bp_medal IN(' . implode(', ', $medal) . ')'; } if (count($districts) > 0) { $where[] = 'bp_district IN(' . implode(', ', $districts) . ')'; } $whereStr = implode(' AND ', $where); $query = BeautyParlor::query()->columns($columns)->leftJoin('Apps\\Common\\Models\\SysAreaZipDistrictPhonecode', 'K_ID=bp_district', 'area'); if (!empty($whereStr)) { $query = $query->where($whereStr); } if (count($bind) > 0) { $query = $query->bind($bind); } $bpList = $query->orderBy('bp_id DESC')->limit($limit, $offset)->execute(); // 总数 $total = BeautyParlor::count(['conditions' => $whereStr, 'bind' => $bind]); $this->view->setVar('filterProvince', $filterProvince); $this->view->setVar('filterCity', $filterCity); $this->view->setVar('filterDistrict', $filterDistrict); $this->view->setVar('filterState', $filterState); $this->view->setVar('filterName', $filterName); $this->view->setVar('filterSell', $filterSell); $this->view->setVar('filterMedal', $filterMedal); $this->view->setVar('total', $total); $this->view->setVar('page', $page); $this->view->setVar('limit', $limit); $this->view->setVar('bpList', $bpList); $this->view->setVar('bpStateList', \Apps\Common\Enum\BeautyParlor::valuesExplain()); }
public function run() { $type = $this->getDataItem('type'); $openId = $this->getDataItem('openid'); $nickname = $this->getDataItem('nickname'); $cover = $this->getDataItem('cover'); $otherData = $this->getDataItem('other_data'); $pushId = $this->getDataItem('push_id'); // push id $osType = $this->getDataItem('os_type'); // 验证数据完整性 if (empty($type) || empty($openId) || empty($nickname)) { return $this->errorLog(ResultStatus::POST_BODY_PARAM_ERROR, "业务参数不全."); } if (!in_array($type, ['weixin', 'weibo'])) { return $this->errorLog(ResultStatus::POST_BODY_PARAM_ERROR, "类型不支持."); } $attrType = 101; if ($type == 'weibo') { $attrType = 102; } // 判断用户是否已经注册了 $userId = $this->isRegister($attrType, $openId); if ($userId === false) { // 注册新账号 $userId = $this->register($type, $attrType, $openId, $nickname, $cover, $otherData); if ($userId === false) { return; } } $info = []; // 获取 user token if ($this->saveUserAuth($this->apiAccessToken->id, $userId)) { $this->success = 1; $this->userid = $userId; $this->message = '登录成功!'; $this->userToken = $this->getUserAuth()->userToken; $this->saveUserPushId($userId, $pushId, $osType); if ($model = UserBase::query()->where("user_id = {$userId}")->execute()->getFirst()) { $info = $model->toArray(); $info['user_mobile'] = $info['bind_phone'] ?: $info['user_account']; if ($info['user_cover'] == 'default.png' && $attrType == 101) { $info['user_cover'] = json_decode($otherData)->headimgurl; } else { $info['user_cover'] = $info['user_cover'] ? PicUrl::UserCover($info['user_cover'], $this->getDi()) : ''; } $info['persional_sign'] = $info['persional_sign'] ? unserialize(base64_decode($info['persional_sign'])) : ''; // 获取城市信息 $SysAreaZipDistrictPhonecode = new SysAreaZipDistrictPhonecode(); $city = $SysAreaZipDistrictPhonecode->getOne($info['user_district']); $info['user_district'] = $city['FULL_NAME'] ?: ''; // 加入关注数和粉丝数 $UserFollow = new UserFollow(); $info['follow_count'] = $UserFollow->getFollowCount($info['user_id'], 1); $info['fans_count'] = $UserFollow->getToFollowCount($info['user_id'], 1); // 删除不要的字段 unset($info['user_account'], $info['user_password'], $info['user_state'], $info['user_addtime'], $info['is_manage']); } } else { $this->message = '获取User Token异常!'; } if (!$info) { $info = ["user_id" => "", "user_nickname" => "", "user_cover" => "", "user_gender" => "0", "user_birthday" => "", "user_realname" => "", "user_expert" => "", "user_district" => "", "user_money" => "", "user_money_virtual" => "", "persional_sign" => "", "follow_count" => 0, "fans_count" => 0]; } $info = array_merge($info, ['success' => $this->success, 'user_token' => $this->userToken, 'message' => $this->message, 'user_id' => $this->userid]); $this->setResult($info); }
public function run() { $account = $this->getDataItem('account', 1); //帐号 $password = $this->getDataItem('password', 1); //密码 $nickname = Keyword::Filter($this->getDataItem('nickname', 1)); //昵称 $smsCode = $this->getDataItem('sms_code', ''); //短信验证 if ($this->userInfoByAccount($account)) { $this->setResult(['success' => 101, 'user_token' => $this->userToken, 'message' => '账户名已存在']); return; } if (empty($password) || empty($nickname)) { $this->setResult(['success' => 103, 'user_token' => $this->userToken, 'message' => '密码和昵称不能为空']); return; } if (empty($smsCode)) { $this->setResult(['success' => 102, 'user_token' => $this->userToken, 'message' => '短信验证码必填']); return; } if (!MobileSMS::Check('register', $smsCode, $account, $this->apiAccessToken->id)) { $this->setResult(['success' => 102, 'user_token' => $this->userToken, 'message' => '短信验证码错误']); return; } $this->userInfo = new UserBase(); $this->userInfo->user_account = $account; $this->userInfo->user_password = $this->hashPassword($password); $this->userInfo->user_nickname = $nickname; $this->userInfo->user_cover = $this->getConfig()->defaultCover; //'default.jpg'; $this->userInfo->bind_phone = $account; if ($this->userInfo->save()) { $this->success = 1; $this->message = '注册成功'; $this->saveUserAuth($this->apiAccessToken->id, $this->userInfo->user_id); $this->userToken = $this->getUserAuth()->userToken; } else { $this->message = '注册失败'; $this->databaseErrorLog($this->userInfo); } if ($this->success == 1) { if ($model = UserBase::findFirst('user_id = ' . $this->userInfo->user_id)) { $info = $model->toArray(); } else { $info = []; } $info['user_mobile'] = $info['bind_phone']; $info['user_cover'] = $info['user_cover'] ? PicUrl::UserCover($info['user_cover'], $this->getDi()) : ''; // 获取城市信息 $SysAreaZipDistrictPhonecode = new SysAreaZipDistrictPhonecode(); $city = $SysAreaZipDistrictPhonecode->getOne($info['user_district']); $info['user_district'] = $city['FULL_NAME'] ?: ''; // 删除不要的字段 unset($info['user_account'], $info['user_password'], $info['user_state'], $info['user_addtime'], $info['is_manage']); $this->setResult(array_merge($info, ['success' => $this->success, 'user_token' => $this->userToken, 'message' => $this->message])); } else { $this->setResult(['success' => $this->success, 'user_token' => $this->userToken, 'message' => $this->message, 'user_id' => $this->userInfo->user_id]); } }
/** * 编辑用户信息 * @date: 2016-1-5 * @author: futao */ public function editAction() { $this->setLeftNav("update"); $req = $this->request; $id = $req->getQuery("id", null, 0); $action = $req->getQuery("action", null, ''); $info = UserBase::query()->columns(['user_account', 'user_password', 'user_district', 'user_nickname', 'user_realname', 'bind_phone', 'persional_sign', 'user_birthday', 'user_cover', 'user_gender', 'user_expert'])->where("user_id = :id:")->bind(['id' => $id])->execute()->getFirst(); if (!$info) { $this->view->disable(); echo '用户不存在!'; return; } if ($info->user_expert == 1) { $userAttr = UserAttribute::findFirst('user_id =' . $id . ' and attr_type = 103 and attr_state = 1'); $this->view->setVar('user_attr', json_decode($userAttr->attr_value_json)); } //个性签名解码 if (unserialize(base64_decode($info->persional_sign))) { $info->persional_sign = unserialize(base64_decode($info->persional_sign)); } $info->user_cover = PicUrl::UserCover($info->user_cover, $this->di); $userArea = SysAreaZipDistrictPhonecode::findFirst("K_ID = " . $info->user_district); $this->view->setVar('userArea', $userArea); $this->view->setVar('userInfo', $info); $this->view->setVar('userId', $id); $this->view->setVar('action', $action); }
public function run() { /** * 验证用户权限 */ if (false == $this->verifyUserAuth()) { return false; } $area = ['user_cover', 'user_nickname', 'user_gender', 'user_birthday', 'user_realname', 'user_district', 'persional_sign']; $field = $this->getDataItem('field'); //字段 $value = trim($this->getDataItem('value', '')); //值 if (!in_array($field, $area)) { return $this->errorLog(ResultStatus::POST_BODY_PARAM_ERROR, '字段名不存在.'); } if ($user = UserBase::findFirst('user_id=' . $this->getUserAuth()->userId)) { if ($field == 'user_cover') { $up = new UploadPic(); $user->user_cover = $up->userCover(); if (!$user->user_cover) { return $this->errorLog(ResultStatus::POST_BODY_PARAM_ERROR, '文件流不能为空.'); } $value = PicUrl::UserCover($user->user_cover, $this->getDi()); } elseif ($field == 'user_district') { if (!is_numeric($value)) { return $this->errorLog(ResultStatus::POST_BODY_PARAM_ERROR, '城市格式错误.'); } if (!\Apps\Common\Models\SysAreaZipDistrictPhonecode::count('K_ID = ' . $value)) { return $this->errorLog(ResultStatus::POST_BODY_PARAM_ERROR, '城市不存在.'); } $user->user_district = $value; // 获取城市信息 $city = (new SysAreaZipDistrictPhonecode())->getOne($value); $value = $city['FULL_NAME'] ?: ''; } elseif ($field == 'persional_sign') { if ($value && $this->utf8_strlen($value) > 30) { return $this->errorLog(ResultStatus::POST_BODY_PARAM_ERROR, '个性签名字数超过了30个字符'); } else { $user->persional_sign = $value ? base64_encode(serialize($value)) : ''; } } elseif ($field == 'user_nickname') { $nicknameLength = $this->utf8_strlen($value); if ($nicknameLength < 1 || $nicknameLength > 10) { return $this->errorLog(ResultStatus::POST_BODY_PARAM_ERROR, '昵称长度需在1~10字节之间'); } $user->user_nickname = $value; } elseif ($field == 'user_realname') { if (empty($value)) { return $this->errorLog(ResultStatus::POST_BODY_PARAM_ERROR, '姓名不能为空'); } if ($this->utf8_strlen($value) > 10) { return $this->errorLog(ResultStatus::POST_BODY_PARAM_ERROR, '姓名不能超过10个字符'); } $user->user_realname = $value; } elseif ($field == 'user_gender') { if (!in_array($value, ['0', '1', '2'])) { return $this->errorLog(ResultStatus::POST_BODY_PARAM_ERROR, '请输入正确的性别'); } $user->user_gender = $value; } elseif ($field == 'user_birthday') { if (!$this->validateDate($value)) { return $this->errorLog(ResultStatus::POST_BODY_PARAM_ERROR, '日期格式错误'); } $user->user_birthday = $value; } if ($user->save()) { $this->setResult(['success' => 1, 'message' => $field . ' 更新成功', 'value' => $value]); return true; } } $this->setResult(['success' => 0, 'message' => '更新失败', 'value' => '']); }
/** * 1.0版本 * * @return $this|ResponseResult */ public function addBpAction() { $this->setLeftNav('bp_list'); $req = $this->request; $id = intval($req->getQuery('id', null, 0)); $page = intval($req->getQuery('page', null, 1)); $page = $page > 0 ? $page : 1; $limit = $this->pageNavLimit; $offset = $limit * ($page - 1); $filterProvince = $req->getQuery('filterProvince', null, ''); $filterCity = $req->getQuery('filterCity', null, ''); $filterDistrict = intval($req->getQuery('filterDistrict', null, -10000)); $filterName = $req->getQuery('filterName', null, ''); $columns = ['bp_id', 'bp_name', 'bp_cover', 'bp_address', 'bp_district', 'FULL_NAME district', 'bp_coordinate', 'bp_tel', 'bp_intro', 'bp_state', 'bp_is_sell', 'bp_medal', 'bp_addtime']; $where = ['bp_state > 0']; $bind = []; if (!!$filterName) { $where[] = 'bp_name LIKE :fname:'; $bind['fname'] = '%' . $filterName . '%'; } $districts = []; // 地区 if ($filterDistrict > -10000) { $where[] = 'bp_district = :district:'; $bind['district'] = $filterDistrict; } elseif (!empty($filterCity)) { // 获取所有城市的下级区县值 $dids = SysAreaZipDistrictPhonecode::query()->columns(['K_ID id'])->where('P_NM = :province: AND C_NM = :city:', ['province' => $filterProvince, 'city' => $filterCity])->execute(); foreach ($dids as $d) { $districts[] = $d->id; } } elseif (!empty($filterProvince)) { // 获取所有城市的下级区县值 $dids = SysAreaZipDistrictPhonecode::query()->columns(['K_ID id'])->where('P_NM = :p:', ['p' => $filterProvince])->execute(); foreach ($dids as $d) { $districts[] = $d->id; } } if (count($districts) > 0) { $where[] = 'bp_district IN(' . implode(', ', $districts) . ')'; } $whereStr = implode(' AND ', $where); $query = BeautyParlor::query()->columns($columns)->leftJoin('Apps\\Common\\Models\\SysAreaZipDistrictPhonecode', 'K_ID=bp_district', 'area'); if (!empty($whereStr)) { $query = $query->where($whereStr); } if (count($bind) > 0) { $query = $query->bind($bind); } $bpList = $query->orderBy('bp_id DESC')->limit($limit, $offset)->execute()->toArray(); // 总数 $total = BeautyParlor::count(['conditions' => $whereStr, 'bind' => $bind]); // 查看是否已经在此活动中 // 查询所有参与的列表 $joinList = ActivityBeautyParlor::find('state > 0 AND activity_id = ' . $id); $joinBpIds = []; foreach ($joinList as $j) { $joinBpIds[] = strval($j->beauty_parlor_id); } for ($i = 0; $i < count($bpList); $i++) { if (in_array(strval($bpList[$i]['bp_id']), $joinBpIds)) { $bpList[$i]['bp_state'] = 1; } else { $bpList[$i]['bp_state'] = 0; } } $this->view->setVar('id', $id); $this->view->setVar('filterProvince', $filterProvince); $this->view->setVar('filterCity', $filterCity); $this->view->setVar('filterDistrict', $filterDistrict); $this->view->setVar('filterName', $filterName); $this->view->setVar('total', $total); $this->view->setVar('page', $page); $this->view->setVar('limit', $limit); $this->view->setVar('data', $bpList); }
/** * 问答举报列表 * @date: 2016年1月6日 * @author: chenxiaolin */ public function questionReportAction() { $this->setLeftNav('questionReport'); $req = $this->request; $page = intval($req->getQuery('page', null, 1)); $page = $page > 0 ? $page : 1; $limit = $this->pageNavLimit; $offset = $limit * ($page - 1); $city = SysAreaZipDistrictPhonecode::query()->columns(['P_NM', 'PHONE_CODE'])->groupBy('P_NM')->execute(); $filterCity = $req->getQuery('filterCity', null, -10000); $report_content = $req->getQuery('report_content'); $where = []; if ($filterCity > -10000) { $where[] = "Apps\\Common\\Models\\QuestionReport.city_code = {$filterCity}"; $this->view->setVar("filterCity", $filterCity); } if ($report_content != '') { $where[] = "report_content like '%" . $report_content . "%'"; $this->view->setVar("report_content", $report_content); } $whereStr = implode(' AND ', $where); $total = QuestionReport::count($whereStr); $data = QuestionReport::query()->columns(['distinct report_id', 'report_content', 'user.bind_phone', 'question_id', 'report_addtime', 'user.user_nickname', 'area.P_NM as city_name'])->leftJoin('Apps\\Common\\Models\\SysAreaZipDistrictPhonecode', 'area.PHONE_CODE=Apps\\Common\\Models\\QuestionReport.city_code', 'area')->leftJoin('Apps\\Common\\Models\\UserBase', 'user.user_id=Apps\\Common\\Models\\QuestionReport.user_id', 'user')->where($whereStr)->limit($limit, $offset)->orderBy('report_addtime DESC')->execute(); $this->view->setVar('data', $data); $this->view->setVar('total', $total); $this->view->setVar('page', $page); $this->view->setVar('limit', $limit); $this->view->setVar('city', $city); }
/** * 添加开通的城市 */ public function openCityAddAction() { $req = $this->request; if (!$req->isPost()) { return; } $response = new ResponseResult(); $response->callback = $req->getPost('callback', null, 'parent.setFormResult'); $response->callbackJavascriptTag = true; $province = $req->getPost('province', null, ''); $city = $req->getPost('city', null, ''); if (empty($province) || empty($city)) { $response->sendError(ResponseResultStatus::PARAM_CANNOT_EMPTY, '参数问题!'); return $response; } // 获取地区数据信息 if ($city != '1') { $info = SysAreaZipDistrictPhonecode::query()->where('C_NM = :nm:', ['nm' => $city])->execute()->getFirst(); } else { $info = SysAreaZipDistrictPhonecode::query()->where('P_NM = :nm:', ['nm' => $province])->execute()->getFirst(); } if (!$info) { $response->sendError(ResponseResultStatus::PARAM_CANNOT_EMPTY, '参数问题!'); return $response; } // 判断是否存在 if (SysOpenCity::count('city_code = ' . $info->PHONE_CODE) > 0) { $response->sendError(ResponseResultStatus::BUSINESS, '已经存在!'); return $response; } $cityInfo = new SysOpenCity(); $cityInfo->city_code = $info->PHONE_CODE; $cityInfo->city_name = $city != '1' ? $info->C_NM : $info->P_NM; $cityInfo->city_order = 0; $cityInfo->city_state = 0; if ($cityInfo->save() == false) { $this->databaseErrorLog($cityInfo); $response->sendError(ResponseResultStatus::DATABASE_ERROR, '保存数据异常!'); } else { $response->sendResult($cityInfo->city_id); } return $response; }