Index.php 50 KB

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