123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- <?php
- /**
- * Created by PhpStorm.
- * User: xiaofeng
- * Date: 2018/6/11
- * Time: 上午9:28
- */
- namespace common\api;
- use mobile\server\IpServer;
- use Yii;
- use backend\base\Help;
- class HouseServer{
- /*
- * 楼盘点击量
- * */
- public function HouseClick($hid)
- {
- $ipModel = new IpInfoServer();
- $ip = $ipModel->getUserIp();
- $clickModel = new \common\models\HouseClickrecord();
- $row = $clickModel->FingByIp($ip,$hid);
- if(empty($row))
- {
- $clickModel->ip = $ip;
- $clickModel->hid = $hid;
- if($clickModel->save())
- {
- $houseModel = new \common\models\House();
- $houseRow = $houseModel->FindById($hid);
- if(!empty($houseRow))
- {
- $houseRow->click_num = ++$houseRow->click_num;
- if($houseRow->save(false))
- {
- return true;
- }
- }
- }
- }
- }
- //处理搜索楼盘名字时出现特殊字符
- public function HouseNameConvert($name)
- {
- if(empty($name)) return;
- $Symbol = [',','.'," ",',','。','/','?'];
- $str = $name;
- $mb = mb_strlen($str,'utf-8');
- $st = strlen($str);
- $arr['pinyin'] = [];
- $arr['zhongwen'] = [];
- if($st==$mb)
- {
- $arr['pinyin'] = $str;
- foreach ($Symbol as $val)
- {
- $exp = explode($val,$str);
- if(count($exp) >1)
- {
- $arr['pinyin'] = $exp;
- }
- }
- if(is_array($arr['pinyin']))
- {
- $namestrs = '';
- foreach ( $arr['pinyin'] as $key=>$val) {
- if(empty($val) || in_array($val,$Symbol))
- {
- unset( $arr['pinyin'][$key]);
- }
- $namestrs .= $val;
- }
- array_push( $arr['pinyin'],$namestrs);
- }
- }
- else
- {
- $arr['zhongwen'] = $str;
- foreach ($Symbol as $val)
- {
- $exp = explode($val,$name);
- if(count($exp) >1)
- {
- $arr['zhongwen'] = $exp;
- }
- }
- if(is_array($arr['zhongwen']))
- {
- $namestr = '';
- foreach ( $arr['zhongwen'] as $key=>$val) {
- if(empty($val) || in_array($val,$Symbol))
- {
- unset( $arr['zhongwen'][$key]);
- }
- $namestr .= $val;
- }
- array_push( $arr['zhongwen'],$namestr);
- }
- }
- return $arr;
- }
- }
|