HouseServer.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: xiaofeng
  5. * Date: 2018/6/11
  6. * Time: 上午9:28
  7. */
  8. namespace common\api;
  9. use mobile\server\IpServer;
  10. use Yii;
  11. use backend\base\Help;
  12. class HouseServer{
  13. /*
  14. * 楼盘点击量
  15. * */
  16. public function HouseClick($hid)
  17. {
  18. $ipModel = new IpInfoServer();
  19. $ip = $ipModel->getUserIp();
  20. $clickModel = new \common\models\HouseClickrecord();
  21. $row = $clickModel->FingByIp($ip,$hid);
  22. if(empty($row))
  23. {
  24. $clickModel->ip = $ip;
  25. $clickModel->hid = $hid;
  26. if($clickModel->save())
  27. {
  28. $houseModel = new \common\models\House();
  29. $houseRow = $houseModel->FindById($hid);
  30. if(!empty($houseRow))
  31. {
  32. $houseRow->click_num = ++$houseRow->click_num;
  33. if($houseRow->save(false))
  34. {
  35. return true;
  36. }
  37. }
  38. }
  39. }
  40. }
  41. //处理搜索楼盘名字时出现特殊字符
  42. public function HouseNameConvert($name)
  43. {
  44. if(empty($name)) return;
  45. $Symbol = [',','.'," ",',','。','/','?'];
  46. $str = $name;
  47. $mb = mb_strlen($str,'utf-8');
  48. $st = strlen($str);
  49. $arr['pinyin'] = [];
  50. $arr['zhongwen'] = [];
  51. if($st==$mb)
  52. {
  53. $arr['pinyin'] = $str;
  54. foreach ($Symbol as $val)
  55. {
  56. $exp = explode($val,$str);
  57. if(count($exp) >1)
  58. {
  59. $arr['pinyin'] = $exp;
  60. }
  61. }
  62. if(is_array($arr['pinyin']))
  63. {
  64. $namestrs = '';
  65. foreach ( $arr['pinyin'] as $key=>$val) {
  66. if(empty($val) || in_array($val,$Symbol))
  67. {
  68. unset( $arr['pinyin'][$key]);
  69. }
  70. $namestrs .= $val;
  71. }
  72. array_push( $arr['pinyin'],$namestrs);
  73. }
  74. }
  75. else
  76. {
  77. $arr['zhongwen'] = $str;
  78. foreach ($Symbol as $val)
  79. {
  80. $exp = explode($val,$name);
  81. if(count($exp) >1)
  82. {
  83. $arr['zhongwen'] = $exp;
  84. }
  85. }
  86. if(is_array($arr['zhongwen']))
  87. {
  88. $namestr = '';
  89. foreach ( $arr['zhongwen'] as $key=>$val) {
  90. if(empty($val) || in_array($val,$Symbol))
  91. {
  92. unset( $arr['zhongwen'][$key]);
  93. }
  94. $namestr .= $val;
  95. }
  96. array_push( $arr['zhongwen'],$namestr);
  97. }
  98. }
  99. return $arr;
  100. }
  101. }