Index.php 42 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. use fast\Random;
  5. use think\Db;
  6. use \think\Log;
  7. use Redis;
  8. use app\common\library\Sms as Smslib;
  9. use app\common\library\Token;
  10. /**
  11. * 首页接口
  12. */
  13. class Index extends Api
  14. {
  15. protected $noNeedLogin = ['zhiyint_registration','index','contactus','tcpTest','getAppShare','getWebsiteInfo','getUserCharmRankList','getPartyHotList','searchUsers','getInviteCode','getEdition','getInviteImg','getWebsiteInfoForMini','getBankList','getSwitch','getBootAnimation', 'tencentcall', 'getversion', 'getversionZx', 'getiosversion'];
  16. protected $noNeedRight = ['*'];
  17. public function index(){
  18. echo 'apisuccess';
  19. exit;
  20. }
  21. //首页。推荐/附近/新人。三个用户列表
  22. public function nearuser()
  23. {
  24. // if(empty($this->auth->longitude) || empty($this->auth->latitude)){
  25. // // $this->success('success',[]);
  26. // $this->error('请先开启定位');
  27. // }
  28. // $type = input('type', 0, 'intval'); //类型: 0附近 1缘分
  29. $type = input('type', 0, 'intval'); //类型: 0推荐 1附近 2新人
  30. $age_id = input('age_id', 0, 'intval'); //年龄段
  31. // $agemin = input('agemin', 0, 'intval'); //最小年龄
  32. // $agemax = input('agemax', 100, 'intval'); //最大年龄
  33. //经过地图测算和公式推算,经度纬度 0.1即为11公里
  34. $map = [
  35. 'user.gender' => $this->auth->gender == 1 ? 0 : 1,// 查询异性
  36. 'user.status' => 1,
  37. 'user.is_kefu' => 0,
  38. 'user.id' => ['neq',$this->auth->id],
  39. // 'user.cityname' => $this->auth->cityname,
  40. // 'user.longitude' => ['between',[$this->auth->longitude - 0.1,$this->auth->longitude + 0.1]],
  41. // 'user.latitude' => ['between',[$this->auth->latitude - 0.1,$this->auth->latitude + 0.1]],
  42. // 'user.is_online|user.is_livebc' => 1, //完全不考虑直播与语聊的权重,只用活跃做排序
  43. // 'user.active_time' => ['gt',time()-86400],
  44. ];
  45. //排序
  46. $order = 'user.is_active desc, user.active_time desc';
  47. if (in_array($type,[0,1])) {
  48. if ($this->auth->gender == 1) {
  49. // $order = 'user.is_active desc, user.active_time desc, uw.get_money desc';
  50. $order = 'user.is_active desc, user.active_time desc';
  51. } else {
  52. // $order = 'user.is_active desc, user.active_time desc, uw.pay_money desc';
  53. $order = 'user.is_active desc, user.active_time desc';
  54. }
  55. }
  56. if ($type == 0) {
  57. // $map['user.cityname'] = $this->auth->cityname; //同城
  58. if ($this->auth->gender == 1) {
  59. $map['user.is_recommend'] = 1;
  60. }
  61. //$order = 'user.is_active desc, uw.pay_money desc,uw.get_money desc';
  62. } elseif ($type == 1) {
  63. // $map['user.longitude'] = ['between',[$this->auth->longitude - 0.1,$this->auth->longitude + 0.1]];
  64. // $map['user.latitude'] = ['between',[$this->auth->latitude - 0.1,$this->auth->latitude + 0.1]];
  65. } else {
  66. $map['user.createtime'] = ['egt', time() - 86400 * 30];
  67. // $order = 'user.createtime desc';
  68. }
  69. if ($age_id > 0 && $age_id < 8) {
  70. if ($age_id == 1) {
  71. $agemin = 18;
  72. $agemax = 25;
  73. } elseif ($age_id == 2) {
  74. $agemin = 25;
  75. $agemax = 30;
  76. } elseif ($age_id == 3) {
  77. $agemin = 30;
  78. $agemax = 35;
  79. } elseif ($age_id == 4) {
  80. $agemin = 35;
  81. $agemax = 40;
  82. } elseif ($age_id == 5) {
  83. $agemin = 40;
  84. $agemax = 45;
  85. } elseif ($age_id == 6) {
  86. $agemin = 45;
  87. $agemax = 50;
  88. } elseif ($age_id == 7) {
  89. $agemin = 50;
  90. $agemax = 200;
  91. }
  92. $map['user.birthday'] = ['between', [time() - $agemax * 31536000, time() - $agemin * 31536000]];
  93. }
  94. //dump($map);
  95. $field = [
  96. 'user.id','user.nickname','user.birthday','user.height','user.longitude','user.latitude','user.avatar','user.bio','user.gender','user.idcard_status', 'user.real_status', 'user.job_id', 'user.is_active', 'user.wages_id', 'user.is_recommend', 'user.cityname', 'user.hometown_cityid', 'user.is_hideaddress'
  97. ];
  98. //$list = Db::name('user')->alias('user')->field($field)->where($map)->order($order)->autopage()->select();
  99. $list = Db::name('user')->alias('user')->field($field)
  100. //->join('user_wallet uw','uw.user_id = user.id','LEFT')
  101. ->where($map)->order($order)->autopage()->select();
  102. $list = list_domain_image($list,['avatar']);
  103. $mt_enum_job = Db::name('enum_job'); //职业
  104. $mt_enum_wages = Db::name('enum_wages'); //收入
  105. $mt_user_wallet = Db::name('user_wallet'); //vip
  106. $mt_user_greet = Db::name('user_greet'); //是否打过招呼
  107. $mt_wealth_level = Db::name('wealth_level'); //财富等级
  108. $mt_charm_level = Db::name('charm_level'); //魅力等级
  109. $mt_area = Db::name('area'); //城市
  110. $time = time();
  111. $hometown_cityid = [];//城市ids
  112. $user_to_id = [];//打招呼ids
  113. foreach ($list as $key=>$val){
  114. $hometown_cityid[] = $val['hometown_cityid'];
  115. $user_to_id[] = $val['id'];
  116. }
  117. // 城市
  118. $mt_areas = $mt_area->field(['id','name'])->whereIn('id',$hometown_cityid)->select();
  119. $mt_areas = array_column($mt_areas ?? [],'name','id');
  120. // 是否打过招呼
  121. $mt_user_greets = $mt_user_greet->field(['user_to_id','count(id) as num'])->where('user_id', $this->auth->id)->whereIn('user_to_id',$user_to_id)->group('user_to_id')->select();
  122. $mt_user_greets = array_column($mt_user_greets ?? [],'num','user_to_id');
  123. // 是否是vip
  124. $mt_user_wallets = $mt_user_wallet->field(['id','user_id','vip_endtime','pay_money'])->whereIn('user_id',$user_to_id)->select();
  125. // 财富等级
  126. $mt_wealth_levels = $mt_wealth_level->order('id desc')->column('value,image');
  127. // 魅力等级
  128. $mt_charm_levels = $mt_charm_level->order('id desc')->column('value,image');
  129. foreach($list as $key => &$v) {
  130. if ($this->auth->gender == 1) { //用户是男的
  131. $age = birthtime_to_age($v['birthday']);
  132. // $job = $mt_enum_job->where(['id' => $v['job_id']])->value('name');
  133. // $v['desc'] = $distance . ' · ' . $age . '岁';
  134. $v['desc'] = '';
  135. if ($age > 0) {
  136. $v['desc'] = $age . '岁';
  137. } else {
  138. $v['desc'] = '18岁';
  139. }
  140. if ($v['height']) {
  141. $v['desc'] .= ' | ' . $v['height'];
  142. }
  143. // if ($job) {
  144. // $v['desc'] .= ' · ' . $job;
  145. // }
  146. if ($type == 1) {
  147. // $distance = $this->calc_map_distance([$this->auth->longitude, $this->auth->latitude], [$v['longitude'], $v['latitude']]);
  148. // $v['desc'] .= ' | ' . $distance;
  149. $v['desc'] .= ' | 10km+';
  150. }
  151. } else {
  152. if ($type != 1) {
  153. $v['desc'] = $v['bio'] ?: '暂未设置个性签名';
  154. } else {
  155. $age = birthtime_to_age($v['birthday']);
  156. // $wages = $mt_enum_wages->where(['id' => $v['wages_id']])->value('name');
  157. // $v['desc'] = $distance . ' · ' . $age . '岁';
  158. $v['desc'] = '';
  159. if ($age > 0) {
  160. $v['desc'] = $age . '岁';
  161. } else {
  162. $v['desc'] = '18岁';
  163. }
  164. if ($v['hometown_cityid']) {
  165. $hometown_city = $mt_areas[$v['hometown_cityid']] ?? '';
  166. $hometown_city = ($hometown_city && $v['is_hideaddress'] == 0) ? $hometown_city : '';
  167. if ($hometown_city) {
  168. $v['desc'] .= ' | ' . $hometown_city;
  169. }
  170. }
  171. // if ($wages) {
  172. // $v['desc'] .= ' · ' . $wages;
  173. // }
  174. }
  175. }
  176. //查询是否打过招呼
  177. $count = $mt_user_greets[$v['id']] ?? 0;
  178. if ($count) {
  179. $v['is_chat'] = 1; //是否打过招呼: 1是 0否
  180. } else {
  181. $v['is_chat'] = 0; //是否打过招呼: 1是 0否
  182. }
  183. $vip_endtime = 0;
  184. $pay_money = 0;
  185. foreach ($mt_user_wallets as $kk=>$vv){
  186. if ($vv['user_id'] == $v['id']) {
  187. $vip_endtime = $vv['vip_endtime'];
  188. $pay_money = $vv['pay_money'];
  189. break;
  190. }
  191. }
  192. if ($vip_endtime >= $time) {
  193. $v['is_vip'] = 1; //是否是vip: 1是 0否
  194. } else {
  195. $v['is_vip'] = 0; //是否是vip: 1是 0否
  196. }
  197. //查询财富等级
  198. if (!empty($mt_wealth_levels)) {
  199. $name = '';
  200. foreach ($mt_wealth_levels as $kkk=>$vvv){
  201. if ($pay_money > $kkk){
  202. $name = localpath_to_netpath($vvv);
  203. break;
  204. }
  205. }
  206. $v['wealth_level'] = $name;
  207. } else {
  208. $v['wealth_level'] = '';
  209. }
  210. //查询魅力等级
  211. if (!empty($mt_charm_levels)) {
  212. $name = '';
  213. foreach ($mt_charm_levels as $kkk=>$vvv){
  214. if ($pay_money > $kkk){
  215. $name = localpath_to_netpath($vvv);
  216. break;
  217. }
  218. }
  219. $v['charm_level'] = $name;
  220. } else {
  221. $v['charm_level'] = '';
  222. }
  223. }
  224. $this->success('success',$list);
  225. }
  226. protected function getRealIpAddr() {
  227. if (!empty($_SERVER['HTTP_CLIENT_IP'])) //check ip from share internet
  228. {
  229. $ip=$_SERVER['HTTP_CLIENT_IP'];
  230. }
  231. elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) //to check ip is pass from proxy
  232. {
  233. $ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
  234. }
  235. else
  236. {
  237. $ip=$_SERVER['REMOTE_ADDR'];
  238. }
  239. return $ip;
  240. }
  241. /**
  242. * 三方接口
  243. *
  244. */
  245. public function zhiyint_registration()
  246. {
  247. $iparr = ["182.37.138.94","18.162.169.63","18.166.207.228","18.167.62.130","18.163.198.60","18.163.33.249","16.163.157.213", "43.198.99.226", "43.198.98.100", "18.163.210.144", "18.167.165.212", "18.166.28.150", "16.163.99.187", "18.163.210.126", "43.198.84.109", "18.163.182.173", "16.162.109.227", "16.162.87.8", "18.162.111.92", "18.166.214.252"];
  248. $ip = $this->getRealIpAddr();
  249. if(!in_array($ip,$iparr)) {
  250. echo json_encode(['error' => "IP not found"]); exit;
  251. }
  252. $UserId = $this->request->request("UserId",'');
  253. $data = json_decode(file_get_contents('php://input'), true);
  254. $UserId = $data['UserId'];
  255. if($UserId)
  256. {
  257. $times = Db::name("user")->where("username",$UserId)->value("createtime");
  258. if(!$times)
  259. {
  260. echo json_encode(['error' => "User ID not found"]); exit;
  261. }
  262. $data = [
  263. 'RegistrationTime' => date("Y-m-d H:i:s",$times)
  264. ];
  265. echo json_encode($data); exit;
  266. }
  267. $data = [
  268. 'error' => "User ID not found"
  269. ];
  270. echo json_encode($data);
  271. }
  272. // /**
  273. // * 生成不重复的随机数字字母组合
  274. // */
  275. // function getUinqueNo($length = 8) {
  276. // $newid = Random::build("alnum",$length);
  277. //// if(in_array($newid,$nos)) {
  278. //// $this->getUinqueNo(8);
  279. //// }
  280. // return $newid;
  281. // }
  282. /**
  283. * 获取用户协议等 小程序
  284. */
  285. public function getWebsiteInfoForMini() {
  286. $params = $this->request->request("params"); //内容
  287. $res = config("site.".$params);
  288. if($params == "boxGiftLogo") $res = $this->httpurl(config("site.".$params));
  289. $this->success("获取成功!",$res);
  290. }
  291. /**
  292. * 联系我们
  293. */
  294. public function contactus() {
  295. $list = \app\common\model\Config::where(["group"=>"basic","name"=>["in",["email","mobile"]]])->select();
  296. $data = [];
  297. foreach($list as $k => $v) {
  298. $v["name"] == "email" && $data["email"] = $v["value"];
  299. $v["name"] == "mobile" && $data["mobile"] = $v["value"];
  300. }
  301. $this->success("获取成功!",$data);
  302. }
  303. /*
  304. * 获取系统消息列表
  305. */
  306. public function getMessage() {
  307. $page = $this->request->request('page',1); // 分页
  308. $pageNum = $this->request->request('pageNum',10); // 分页
  309. // 分页搜索构建
  310. $pageStart = ($page-1)*$pageNum;
  311. $flag = $this->request->request("flag",1,"intval"); //标识:1=只取一条,0=全部
  312. $user_id = $this->auth->id;
  313. $obj = \app\common\model\Message::where(["user_id"=>$user_id])->order("createtime","desc")->limit($pageStart,$pageNum);
  314. if($flag == 1) {
  315. $list = $obj->find();
  316. $list || $list = [];
  317. $list && $list["createtime"] = $this->get_last_time($list["createtime"]);
  318. } else {
  319. $list = $obj->select();
  320. if($list) foreach($list as $k => &$v) {
  321. $v["createtime"] = $this->get_last_time($v["createtime"]);
  322. }
  323. }
  324. $this->success("获取成功!",$list);
  325. }
  326. /**
  327. * 删除系统消息
  328. */
  329. public function delMessage() {
  330. $id = $this->request->request("id",0,"intval"); //消息ID
  331. if($id <= 0) {
  332. $this->error("参数传入错误!");
  333. }
  334. $res = \app\common\model\Message::where(["id"=>$id,"user_id"=>$this->auth->id])->delete();
  335. if($res) {
  336. $this->success("删除成功!");
  337. } else {
  338. $this->error("删除失败!");
  339. }
  340. }
  341. /**
  342. * 获取主播魅力值排行
  343. */
  344. public function getUserCharmRankList() {
  345. $time = $this->request->request("time",0,"intval"); //时间筛选 1=小时榜,2=今日榜,3=本周榜,4=月榜
  346. if(!in_array($time,[1,2,3,4])) {
  347. $this->error("参数传入错误!");
  348. }
  349. $hour = strtotime(date("Y-m-d H:00:00"));
  350. $today = strtotime(date("Y-m-d 00:00:00"));
  351. $weekend = strtotime('monday this week');
  352. // $weekend = mktime(0, 0 , 0,date("m"),date("d")-date("w")+1,date("Y"));
  353. $month = strtotime(date("Y-m-01 00:00:00"));
  354. // 剩余时间
  355. $thistime = time();
  356. switch ($time) {
  357. case 1:
  358. $redtime = 3600-($thistime - $hour);
  359. break;
  360. case 2:
  361. $redtime = 3600*24-($thistime - $today);
  362. break;
  363. case 3:
  364. $redtime = 3600*24*7-($thistime - $weekend);
  365. break;
  366. case 4:
  367. $monthend = mktime(23,59,59,date("m"),date("t"),date("Y"));
  368. $redtime = ($monthend - $month)-($thistime - $month);
  369. break;
  370. }
  371. $timeArr = [1=>$hour,2=>$today,3=>$weekend,4=>$month];
  372. $where = [];
  373. $where["a.createtime"] = ["gt",$timeArr[$time]];
  374. $list = \app\common\model\UserCharmRank::alias("a")
  375. ->field("p.id,sum(a.charm) as charm,u.avatar,u.nickname,u.gender,u.level")
  376. ->where($where)
  377. ->join("hx_user u","u.id = a.user_id")
  378. ->join("hx_party p","p.user_id = a.user_id")
  379. ->group("a.user_id")
  380. ->order("charm","desc")
  381. ->limit(100)
  382. ->select();
  383. $data = [];
  384. $data["redtime"] = $redtime;
  385. $data["data"] = $list;
  386. $this->success("获取成功!",$data);
  387. }
  388. /**
  389. * 获取派对热度排序
  390. */
  391. public function getPartyHotList() {
  392. // 剩余时间
  393. $thistime = time();
  394. $hour = strtotime(date("Y-m-d H:00:00"));
  395. $redtime = 3600-($thistime - $hour);
  396. $where = [];
  397. $where["a.createtime"] = ["gt",$hour];
  398. $where["p.room_type"] = 1;
  399. $list = \app\common\model\PartyHot::alias("a")
  400. ->field("sum(a.hot) as hot,p.id,u.avatar,p.party_name,p.party_logo")
  401. ->where($where)
  402. ->join("hx_party p","p.id = a.party_id")
  403. ->join("hx_user u","u.id = p.user_id")
  404. ->group("a.party_id")
  405. ->order("hot","desc")
  406. ->limit(100)
  407. ->select();
  408. $data = [];
  409. $data["redtime"] = $redtime;
  410. $data["data"] = $list;
  411. $this->success("获取成功!",$data);
  412. }
  413. /**
  414. * 首页搜索
  415. */
  416. public function searchUsers() {
  417. $search = $this->request->request("search"); //关键词筛选
  418. if(!$search) {
  419. $this->error("请输入搜索内容!");
  420. }
  421. // 搜索派对
  422. global $whereOr;
  423. $where = [];
  424. $whereOr["party_id"] = $search;
  425. $whereOr["party_name"] = ["like","%$search%"];
  426. $where["room_type"] = 1;
  427. $partyList = \app\common\model\Party::field("id,party_logo,party_id,party_name")
  428. ->where($where)
  429. ->where(function ($query) {
  430. global $whereOr;
  431. $query->whereOr($whereOr);
  432. })->order("party_hot","desc")->select();
  433. // 搜索直播间
  434. global $whereOrlive;
  435. $where = [];
  436. $whereOrlive["party_id"] = $search;
  437. $whereOrlive["party_name"] = ["like","%$search%"];
  438. $where["room_type"] = 2;
  439. $liveList = \app\common\model\Party::field("id,party_logo,party_id,party_name")
  440. ->where($where)
  441. ->where(function ($query) {
  442. global $whereOrlive;
  443. $query->whereOr($whereOrlive);
  444. })
  445. ->order("party_hot","desc")->select();
  446. // 相关用户
  447. $where = [];
  448. $where["a.nickname"] = ["like","%$search%"];
  449. $where["a.u_id"] = $search;
  450. $userList = \app\common\model\User::alias("a")->field("id,avatar,nickname,u_id,f.fans")
  451. ->join("hx_view_fans f","f.user_id = a.id","left")
  452. ->order("a.is_online,a.noble,a.level")
  453. ->whereOr($where)->select();
  454. $res = [];
  455. $res["partylist"] = $partyList;
  456. $res["livelist"] = $liveList;
  457. $res["userlist"] = $userList;
  458. $this->success("获取成功!",$res);
  459. }
  460. /**
  461. * 获取下载二维码和邀请码
  462. */
  463. public function getInviteCode() {
  464. // 获取二维码
  465. $qrcode = $this->httpurl(config("site.qrcode"));
  466. $miniqrcode = $this->httpurl(config("site.miniqrcode"));
  467. // 获取用户邀请码
  468. $inviteCode = \app\common\model\User::where(["id"=>$this->auth->id])->value("invite_no");
  469. $host = $_SERVER["REQUEST_SCHEME"]."://".$_SERVER["HTTP_HOST"];
  470. $downlowdLink = $host."/index/index/appJump?t=wlt".rand(10,999).Random::alpha(8);
  471. $this->success("获取成功!",["qrcode"=>$qrcode,"miniqrcode"=>$miniqrcode,"inviteCode"=>$inviteCode,"downlowdLink"=>$downlowdLink]);
  472. }
  473. /**
  474. * 获取app分享海报
  475. */
  476. public function getAppShare() {
  477. $this->success("获取成功!",["url"=>$this->httpurl(config("site.appShare"))]);
  478. }
  479. /**
  480. * 获取开机动画(暂时关闭)
  481. */
  482. private function getBootAnimation() {
  483. $this->success("获取成功!",["url"=>$this->httpurl(config("site.bootAnimationUrl")),"time"=>floatval(config("site.bootAnimationTime"))]);
  484. }
  485. /**
  486. * 获取版本更新信息
  487. */
  488. public function getEdition() {
  489. // 获取二维码
  490. $is_force = config("site.is_force");
  491. $apkUrl = config("site.apk_url");
  492. $apkName = config("site.apkName");
  493. $desc = config("site.desc");
  494. $versionCode = config("site.versionCode");
  495. $this->success("获取成功!",["versionCode"=>$versionCode,"isForceUpdate"=>$is_force,"apkUrl"=>$apkUrl,"apkName"=>$apkName,"desc"=>$desc]);
  496. }
  497. /**
  498. * 获取邀请图片
  499. */
  500. public function getInviteImg() {
  501. $plat = $this->request->request("plat",1); //平台:1=小程序,2=app
  502. if(!in_array($plat,[1,2])) $this->error("参数错误");
  503. // 获取用户的邀请码
  504. $invitecode = \app\common\model\User::where(["id"=>$this->auth->id])->value("invite_no");
  505. // 文字图片合成
  506. $bigImgPath = $this->httpurlLocal('/assets/img/inviteimg.jpeg');
  507. $img = imagecreatefromstring(file_get_contents($bigImgPath));
  508. //字体文件
  509. $font = realpath('./assets/fonts/lato/lato-black.ttf');
  510. //字体颜色(RGB)
  511. $black = imagecolorallocate($img, 217, 76, 41);
  512. //字体大小
  513. $fontSize = 30;
  514. //旋转角度
  515. $circleSize = 0;
  516. //左边距
  517. $left = 275;
  518. //上边距
  519. $top = 540;
  520. imagefttext($img, $fontSize, $circleSize, $left, $top, $black, $font, $invitecode);
  521. $filename = date("YmdH").".jpeg";
  522. $path = "/uploads/qrcode/".$filename;
  523. $file = $_SERVER['DOCUMENT_ROOT'] . $path;//打开文件准备写入
  524. list($bgWidth, $bgHight, $bgType) = getimagesize($bigImgPath);
  525. switch ($bgType) {
  526. case 1://gif
  527. header('Content-Type:image/gif');
  528. imagegif($img,$file);
  529. break;
  530. case 2://jpg
  531. header('Content-Type:image/jpg');
  532. imagejpeg($img,$file);
  533. break;
  534. case 3://jpg
  535. header('Content-Type:image/png');
  536. imagepng($img,$file);
  537. break;
  538. default:
  539. break;
  540. }
  541. //销毁照片
  542. imagedestroy($img);
  543. // 图片和二维码合成
  544. $qrcode = $plat == 1 ? config("site.miniqrcode"):config("site.qrcode");
  545. $background = $file;
  546. $target = $this->httpurl($qrcode);
  547. $background_iamge = imagecreatefromstring(file_get_contents($background));
  548. $target_image = imagecreatefromstring(file_get_contents($target));
  549. list($target_width, $target_height, $target_type) = getimagesize($target);
  550. imagecopymerge($background_iamge , $target_image , 250, 700, 0, 0, $target_width, $target_height, 100);
  551. list($background_width, $background_height, $background_type) = getimagesize($background);
  552. switch ($background_type) {
  553. case 1://gif
  554. header('Content-Type:image/gif');
  555. imagegif($background_iamge,$file);
  556. break;
  557. case 2://jpg
  558. header('Content-Type:image/jpg');
  559. imagejpeg($background_iamge,$file);
  560. break;
  561. case 3://jpg
  562. header('Content-Type:image/png');
  563. imagepng($background_iamge,$file);
  564. break;
  565. default:
  566. break;
  567. }
  568. $savepath = $this->httpurlLocal($path);
  569. $this->success("获取成功!",$savepath);
  570. }
  571. /**
  572. * 获取银行列表
  573. */
  574. public function getBankList() {
  575. $this->success("获取成功!",["banklist"=>\app\common\model\Bank::select()]);
  576. }
  577. /**
  578. * 获取开关配置
  579. */
  580. public function getSwitch() {
  581. $this->success("获取成功!",["switch"=>config("site.switch")]);
  582. }
  583. /**
  584. * 评论时间转换
  585. * @param null $time
  586. * @return false|string
  587. */
  588. private function get_last_time($time = NULL) {
  589. $text = '';
  590. $time = $time === NULL || $time > time() ? time() : intval($time);
  591. $t = time() - $time; //时间差 (秒)
  592. $y = date('Y', $time)-date('Y', time());//是否跨年
  593. switch($t){
  594. case $t == 0:
  595. $text = '刚刚';
  596. break;
  597. case $t < 60:
  598. $text = $t . '秒前'; // 一分钟内
  599. break;
  600. case $t < 60 * 60:
  601. $text = floor($t / 60) . '分钟前'; //一小时内
  602. break;
  603. case $t < 60 * 60 * 24:
  604. $text = floor($t / (60 * 60)) . '小时前'; // 一天内
  605. break;
  606. case $t < 60 * 60 * 24 * 3:
  607. $text = floor($time/(60*60*24)) ==1 ?'昨天 ' . date('H:i', $time) : '前天 ' . date('H:i', $time) ; //昨天和前天
  608. break;
  609. case $t < 60 * 60 * 24 * 30:
  610. $text = date('m月d日 H:i', $time); //一个月内
  611. break;
  612. case $t < 60 * 60 * 24 * 365&&$y==0:
  613. $text = date('m月d日', $time); //一年内
  614. break;
  615. default:
  616. $text = date('Y年m月d日', $time); //一年以前
  617. break;
  618. }
  619. return $text;
  620. }
  621. //轮播图
  622. public function banner() {
  623. $type = input('type', 0, 'intval'); //类型:0=交友轮播图,1=动态轮播图
  624. $list = Db::name('banner')->field('id, title, image, url')->where(['status' => 1, 'type' => $type])->order('weigh', 'desc')->select();
  625. $list = list_domain_image($list, ['image']);
  626. $this->success('轮播图', $list);
  627. }
  628. //谁看过我汇总
  629. public function visitlist(){
  630. $time = Db::name('user_visit_time')->where(['user_id' => $this->auth->id])->value('visittime');
  631. $where = [];
  632. if ($time) {
  633. $where['updatetime'] = ['gt', $time];
  634. }
  635. $list = [];
  636. $count = Db::name('user_visit')->where(['to_uid' => $this->auth->id])->where($where)->count('id');
  637. if ($count) {
  638. $uid_list = Db::name('user_visit')->field('uid')->where(['to_uid' => $this->auth->id])->where($where)->limit(9)->column('uid');
  639. $mt_user = Db::name('user');
  640. foreach ($uid_list as &$v) {
  641. $avatar = $mt_user->where(['id' => $v])->value('avatar');
  642. $list[] = one_domain_image($avatar);
  643. }
  644. }
  645. $data['count'] = $count;
  646. $data['list'] = $list;
  647. $this->success('success',$data);
  648. }
  649. //筛选年龄段
  650. public function agerange() {
  651. $list = [
  652. [
  653. 'id' => 0,
  654. 'title' => '不限'
  655. ],
  656. [
  657. 'id' => 1,
  658. 'title' => '18-25岁'
  659. ],
  660. [
  661. 'id' => 2,
  662. 'title' => '25-30岁'
  663. ],
  664. [
  665. 'id' => 3,
  666. 'title' => '30-35岁'
  667. ],
  668. [
  669. 'id' => 4,
  670. 'title' => '35-40岁'
  671. ],
  672. [
  673. 'id' => 5,
  674. 'title' => '40-45岁'
  675. ],
  676. [
  677. 'id' => 6,
  678. 'title' => '45-50岁'
  679. ],
  680. [
  681. 'id' => 7,
  682. 'title' => '50岁以上'
  683. ]
  684. ];
  685. $this->success('筛选年龄段', $list);
  686. }
  687. /**
  688. * calc_map_distance() , 根据地图上的两个点各自的x,y坐标,计算出2点之间的直线距离
  689. * @param array $point_1 第1个点的x,y坐标 array( 101 , 202 )
  690. * @param array $point_2 第2个点的x,y坐标 array( 101 , 202 )
  691. * @param bool $calc_as_string 是否计算为字符串公里距离 , 如果未否返回数字
  692. * @return float | false | string
  693. */
  694. private function calc_map_distance( $point_1=array( ) , $point_2=array( ) , $calc_as_string=false ) {
  695. if( empty( $point_1 ) || empty( $point_2 ) ){
  696. return false;
  697. }
  698. // 经纬度不存在,或者经纬度超过最大范围 +-180 , +-90 ,返回false
  699. $p1_x = $point_1[0];
  700. $p1_y = $point_1[1];
  701. $p2_x = $point_2[0];
  702. $p2_y = $point_2[1];
  703. if(
  704. $p1_x < -180 || $p1_x > 180
  705. || $p2_x < -180 || $p2_x > 180
  706. || $p1_y < -90 || $p1_y > 90
  707. || $p2_y < -90 || $p2_y > 90
  708. || $p1_x == '' || $p1_y == ''
  709. || $p2_x == '' || $p2_y == ''
  710. ){
  711. return '距离未知';
  712. }
  713. // 根据2点各自的坐标,计算2点之间直线距离的公式
  714. $distance = round(6378.138*2*asin(sqrt(pow(sin(( $p1_x *pi()/180-$p2_x*pi()/180)/2),2)+cos( $p1_x *pi()/180)*cos($p2_x*pi()/180)* pow(sin(( $p1_y *pi()/180-$p2_y*pi()/180)/2),2)))*1000);
  715. // 是否计算为字符串公里距离
  716. if( !$calc_as_string ){
  717. return (string)round( $distance / 1000 , 1 ) . 'km';
  718. }
  719. // 如果计算为字符串公里距离
  720. if( $distance / 1000 > 1 ){
  721. $k = (string)round( $distance / 1000 , 1 );
  722. $m = (string)$distance % 1000 ;
  723. // $distance = "{$k}公里{$m}米";
  724. $distance = "{$k}km";
  725. }
  726. else{
  727. $distance = "{$distance}m";
  728. }
  729. return $distance;
  730. }
  731. //打招呼/搭讪
  732. public function greet() {
  733. if ($this->auth->gender == 0 && $this->auth->real_status != 1 && $this->auth->idcard_status != 1) {
  734. $this->error('请先完成实名认证或真人认证');
  735. }
  736. $other_uid = input('user_id', 0, 'intval');
  737. if(!$other_uid) {
  738. $this->error(__('Invalid parameters'));
  739. }
  740. if($other_uid == $this->auth->id){
  741. $this->error('这是您自己');
  742. }
  743. $checkuser = Db::name('user')->find($other_uid);
  744. if(empty($checkuser)) {
  745. $this->error('此用户不存在');
  746. }
  747. $map = [
  748. 'user_id' => $this->auth->id,
  749. 'user_to_id' => $other_uid,
  750. ];
  751. // 取消限制 2023年12月14日 18点47分
  752. // $check = Db::name('user_greet')->where($map)->find();
  753. // if($check){
  754. // $this->error('已经打过招呼了');
  755. // }
  756. $map['createtime'] = time();
  757. Db::startTrans();
  758. $id = Db::name('user_greet')->insertGetId($map);
  759. if (!$id) {
  760. Db::rollback();
  761. $this->error('您的网络开小差了~');
  762. }
  763. //tag任务赠送金币
  764. //搭讪奖励
  765. $task_rs = \app\common\model\TaskLog::tofinish($this->auth->id,24);
  766. if($task_rs === false){
  767. Db::rollback();
  768. $this->error('完成任务赠送奖励失败');
  769. }
  770. Db::commit();
  771. //不需要送礼物了
  772. /*$gift_greet = Db::name('gift_greet')->find();
  773. if ($gift_greet) {
  774. $gift_greet['special'] = one_domain_image($gift_greet['special']);
  775. $gift_greet['image'] = one_domain_image($gift_greet['image']);
  776. } else {
  777. $gift_greet = (object)[];
  778. }*/
  779. $gift_greet = (object)[];
  780. $this->success('操作成功', $gift_greet);
  781. }
  782. //女号私信异性完成任务
  783. public function girlchattask() {
  784. if ($this->auth->gender != 0) { //只有女生可以
  785. $this->error('您的网络开小差啦~');
  786. }
  787. //检测用户
  788. $to_user_id = input_post('to_user_id');
  789. $to_user_info = Db::name('user')->field('id,real_status,gender,free_video,free_audio,free_typing,chat_price,is_kefu')->where('id',$to_user_id)->find();
  790. if(!$to_user_info){
  791. $this->error('不存在的用户');
  792. }
  793. if ($to_user_info['is_kefu'] == 1 || $this->auth->is_kefu == 1) { //我是客服或者对方是客服
  794. $this->success('success');
  795. }
  796. if ($to_user_info['gender'] != 1) {
  797. $this->error('性别异常~');
  798. }
  799. $task_rs = \app\common\model\TaskLog::tofinish($this->auth->id,23);
  800. if($task_rs === false){
  801. $this->error('完成任务赠送奖励失败');
  802. }
  803. $this->success('success');
  804. }
  805. //腾讯内容审核回调方法
  806. public function tencentcall() {
  807. $content = file_get_contents('php://input');
  808. $content = json_decode($content, true);
  809. error_log(print_r($content, 1) . PHP_EOL, 3, './tencentcall3.txt');
  810. if (isset($content['Scene']) && $content['CtxcbResult'] == 1) { //语音文件: 只返回违规的数据; 处理方式: 撤回
  811. $tenim = new Tenim;
  812. $rs = $tenim->withdraw_message($content['From_Account'], $content['ContactItem']['To_Account'], $content['MsgID']);
  813. // error_log(print_r($rs, 1) . PHP_EOL, 3, './tencentcall4.txt');
  814. } elseif (isset($content['TaskId'])) { //音视频通话: 返回所有数据; 处理方式: 强制退出im, 清空token
  815. if ($content['Status'] == 'RUNNING') {
  816. //该字段用于返回所查询内容的任务状态。取值:FINISH(任务已完成)、PENDING (任务等待中)、RUNNING (任务进行中)、ERROR (任务出错)、CANCELLED (任务已取消)。
  817. if ($content['ImageSegments']) { //图片(视频)审核结果
  818. $image_info = $content['ImageSegments'][0]['Result'];
  819. if ($image_info['Label'] != 'Normal') {
  820. //该字段用于返回检测结果所对应的恶意标签。返回值:Porn:色情,Abuse:谩骂,Ad:广告,Custom:自定义违规;以及其他令人反感、不安全或不适宜的内容类型。
  821. $url = $image_info['Url']; //图片地址https://cos.ap-guangzhou.myqcloud.com/tianyu-cms-ap-guangzhou-1312781550/segment-/trtc/1400758343/screenshot_1431291856_2_1669880705.jpg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIDU2hLdl3CBZnuZ1rugInQEXxleKiEtIgHzkXoQu9u_1LZ_Cr9CmyRstQ34Fs_0ktH%2F20221201%2Fap-guangzhou%2Fs3%2Faws4_request&X-Amz-Date=20221201T074505Z&X-Amz-Expires=43200&X-Amz-Security-Token=HuyqAZVXXBWnWFOJZNLYInkTvVfFNqRab1d55d6d8642abaaa3d1c727ba06bd0eg37ybZOWCCsEawceCDvRAt1WL91GOzLIcdyC_DDX80alqE3M1GoQfUYRBETYm7eFxQ_wylmfSaomUU5hylq3twTxz9joT9g2rLfXhBmPeuvBia3n30gHeJtUeHJ7kaKjTDzZzPcq-B3t6hRximMVjKfQ9rKnJpjJGDKh-yqIpEUvyqFFl6Cf3d4lDoF87xwAAPya7Q2tMfZsMCyfgIMEqghMnGgWDMn9fMvDLl_82uGt8kK2TBGVymmeSx9GDGrDqBNo-hMC_EFR9jEUs87aDaD_gTNr2vLypRx87GnJhYCW7i-ExcfDfayKjXWy8LZeOtkc2Y0qDvzrEqcf5GtNBLPhgDzkbRyFgiWe99WsIrXH4RMlONiFitvvNAmWGvbv&X-Amz-SignedHeaders=host&X-Amz-Signature=e3b2a479c08d3fae95782e4bd62d88242726e095a771c28f38ccc7ed96c79d56
  822. //获取违规用户id
  823. $url = explode('?', $url);
  824. $url = $url[0];
  825. $user_id_url = explode('/', $url);
  826. $user_id_url = $user_id_url[count($user_id_url) - 1];
  827. $user_id_arr = explode('_', $user_id_url);
  828. $user_id = $user_id_arr[2];
  829. //退出im
  830. $tenIm = new Tenim();
  831. $tenIm->loginoutim($user_id);
  832. //清空token
  833. Token::clear($user_id);
  834. $tiaoshi = $user_id . '---' . $content['TaskId'] . '---' .$image_info['Label'] .'---'. date('Y-m-d H:i:s');
  835. error_log(print_r($tiaoshi, 1) . PHP_EOL, 3, './dayin1.txt');
  836. }
  837. } elseif ($content['AudioSegments']) { //音频审核结果
  838. $audio_info = $content['AudioSegments'][0]['Result'];
  839. if ($audio_info['Label'] != 'Normal') {
  840. //该字段用于返回检测结果所对应的恶意标签。返回值:Porn:色情,Abuse:谩骂,Ad:广告,Custom:自定义违规;以及其他令人反感、不安全或不适宜的内容类型。
  841. $url = $audio_info['Url']; //音频地址https://cos.ap-guangzhou.myqcloud.com/tianyu-cms-ap-guangzhou-1312781550/segment-/trtc/1400758343/audio_1431291856_354_1669880708.mp3?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIDU2hLdl3CBZnuZ1rugInQEXxleKiEtIgHzkXoQu9u_1LZ_Cr9CmyRstQ34Fs_0ktH%2F20221201%2Fap-guangzhou%2Fs3%2Faws4_request&X-Amz-Date=20221201T074520Z&X-Amz-Expires=43200&X-Amz-Security-Token=HuyqAZVXXBWnWFOJZNLYInkTvVfFNqRab1d55d6d8642abaaa3d1c727ba06bd0eg37ybZOWCCsEawceCDvRAt1WL91GOzLIcdyC_DDX80alqE3M1GoQfUYRBETYm7eFxQ_wylmfSaomUU5hylq3twTxz9joT9g2rLfXhBmPeuvBia3n30gHeJtUeHJ7kaKjTDzZzPcq-B3t6hRximMVjKfQ9rKnJpjJGDKh-yqIpEUvyqFFl6Cf3d4lDoF87xwAAPya7Q2tMfZsMCyfgIMEqghMnGgWDMn9fMvDLl_82uGt8kK2TBGVymmeSx9GDGrDqBNo-hMC_EFR9jEUs87aDaD_gTNr2vLypRx87GnJhYCW7i-ExcfDfayKjXWy8LZeOtkc2Y0qDvzrEqcf5GtNBLPhgDzkbRyFgiWe99WsIrXH4RMlONiFitvvNAmWGvbv&X-Amz-SignedHeaders=host&X-Amz-Signature=b1965689653813b59824647292565ec9297a7e81950bb88d8cbeb95f8393c1ca
  842. //获取违规用户id
  843. $url = explode('?', $url);
  844. $url = $url[0];
  845. $user_id_url = explode('/', $url);
  846. $user_id_url = $user_id_url[count($user_id_url) - 1];
  847. $user_id_arr = explode('_', $user_id_url);
  848. $user_id = $user_id_arr[2];
  849. //退出im
  850. $tenIm = new Tenim();
  851. $tenIm->loginoutim($user_id);
  852. //清空token
  853. Token::clear($user_id);
  854. $tiaoshi = $user_id . '---' . $content['TaskId'] . '---' .$audio_info['Label'] .'---'. date('Y-m-d H:i:s');
  855. error_log(print_r($tiaoshi, 1) . PHP_EOL, 3, './dayin2.txt');
  856. }
  857. }
  858. }
  859. }
  860. }
  861. //头条
  862. public function headlines() {
  863. $time = strtotime(date('Y-m-d', time()));
  864. //聊天送礼物
  865. $list1 = Db::name('gift_user_typing')->field('id, user_id, user_to_id, gift_name')->where(['createtime' => ['egt', $time]])->order('price desc, id desc')/*->page($this->page, $this->listrow)*/->select();
  866. //动态送礼物
  867. $list2 = Db::name('gift_user_dongtai')->field('id, user_id, user_to_id, gift_name')->where(['createtime' => ['egt', $time]])->order('price desc, id desc')/*->page($this->page, $this->listrow)*/->select();
  868. $list = array_merge($list1, $list2);
  869. if ($list) {
  870. $mt_user = Db::name('user');
  871. foreach ($list as &$v) {
  872. $user_info= $mt_user->field('nickname, avatar')->where(['id' => $v['user_id']])->find();
  873. $v['from_nickname'] = '有缘人';//$user_info['nickname'];
  874. $v['avatar'] = one_domain_image($user_info['avatar']);
  875. $v['to_nickname'] = '有缘人';//$mt_user->where(['id' => $v['user_to_id']])->value('nickname');
  876. }
  877. }
  878. $this->success('头条', $list);
  879. }
  880. //查询每天弹出搭讪框次数
  881. public function freegreetnum() {
  882. $user = $this->auth->getUser();
  883. if (isset($user['is_kefu']) && $user['is_kefu'] == 1){
  884. $data['free_greet_num'] = 0;
  885. $data['vip_free_greet_num'] = 0;
  886. $data['boy_free_greet_num'] = 0;
  887. $data['boy_vip_free_greet_num'] = 0;
  888. }else{
  889. //非会员每天弹出搭讪框次数
  890. $data['free_greet_num'] = config('site.free_greet_num') > 0 ? config('site.free_greet_num') : 5;
  891. //vip每天弹出搭讪框次数
  892. $data['vip_free_greet_num'] = config('site.vip_free_greet_num') > 0 ? config('site.vip_free_greet_num') : 5;
  893. // 男性 非会员每天弹出搭讪框次数
  894. $data['boy_free_greet_num'] = config('site.boy_free_greet_num') > 0 ? config('site.boy_free_greet_num') : 1;
  895. // 男性 vip每天弹出搭讪框次数
  896. $data['boy_vip_free_greet_num'] = config('site.boy_vip_free_greet_num') > 0 ? config('site.boy_vip_free_greet_num') : 1;
  897. }
  898. $this->success('success', $data);
  899. }
  900. /**
  901. * 男性打招呼内容
  902. * @return void
  903. * @throws \think\db\exception\DataNotFoundException
  904. * @throws \think\db\exception\ModelNotFoundException
  905. * @throws \think\exception\DbException
  906. */
  907. public function greetBoy()
  908. {
  909. $data = Db::name('user_greet_boy')->select();
  910. $this->success('success', $data);
  911. }
  912. //首页顶部分类名称
  913. public function typename() {
  914. $typename = config('site.typename');
  915. $typename = explode(',', $typename);
  916. $data[] = $typename[0] ? : '推荐';
  917. $data[] = $typename[1] ? : '附近';
  918. $data[] = $typename[2] ? : '新人';
  919. $this->success('sussess', $data);
  920. }
  921. //获取版本更新信息
  922. public function getversion() {
  923. // 获取二维码
  924. $is_force = config("site.is_force"); //是否强制更新 1是 0否
  925. $apk_url = config("site.apk_url"); //下载链接
  926. $apk_name = config("site.apk_name"); //apk更新标题
  927. $apk_desc = config("site.apk_desc"); //apk更新描述
  928. $version_code = config("site.version_code"); //版本迭代号
  929. $data['is_force'] = $is_force;
  930. $data['apk_url'] = $apk_url;
  931. $data['apk_name'] = $apk_name;
  932. $data['apk_desc'] = $apk_desc;
  933. $data['version_code'] = $version_code;
  934. $this->success('Success', $data);
  935. }
  936. // 获取版本更新信息(知心app)
  937. public function getversionZx() {
  938. // 获取二维码
  939. $is_force = config("site.is_force_zx"); //是否强制更新 1是 0否
  940. $apk_url = config("site.apk_url_zx"); //下载链接
  941. $apk_name = config("site.apk_name_zx"); //apk更新标题
  942. $apk_desc = config("site.apk_desc_zx"); //apk更新描述
  943. $version_code = config("site.version_code_zx"); //版本迭代号
  944. $data['is_force'] = $is_force;
  945. $data['apk_url'] = $apk_url;
  946. $data['apk_name'] = str_replace('知音','知心',$apk_name);
  947. $data['apk_desc'] = $apk_desc;
  948. $data['version_code'] = $version_code;
  949. $this->success('Success', $data);
  950. }
  951. //获取ios版本更新信息
  952. public function getiosversion() {
  953. // 获取二维码
  954. $is_force = config("site.ios_is_force"); //是否强制更新 1是 0否
  955. $apk_url = config("site.ios_apk_url"); //下载链接
  956. $apk_name = config("site.ios_apk_name"); //apk更新标题
  957. $apk_desc = config("site.ios_apk_desc"); //apk更新描述
  958. $version_code = config("site.ios_version_code"); //版本迭代号
  959. $data['is_force'] = $is_force;
  960. $data['apk_url'] = $apk_url;
  961. $data['apk_name'] = $apk_name;
  962. $data['apk_desc'] = $apk_desc;
  963. $data['version_code'] = $version_code;
  964. $this->success('Success', $data);
  965. }
  966. }