Index.php 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681
  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. ];
  43. //排序
  44. $order = 'user.is_active desc, user.logintime desc';
  45. if (in_array($type,[0,1])) {
  46. if ($this->auth->gender == 1) {
  47. $order = 'user.is_active desc, user.logintime desc';
  48. } else {
  49. $order = 'user.is_active desc, user.logintime desc';
  50. }
  51. }
  52. if ($type == 0) {
  53. // $map['user.cityname'] = $this->auth->cityname; //同城
  54. if ($this->auth->gender == 1) {
  55. $map['user.is_recommend'] = 1;
  56. }
  57. //$order = 'user.is_active desc, uw.pay_money desc,uw.get_money desc';
  58. } elseif ($type == 1) {
  59. // $map['user.longitude'] = ['between',[$this->auth->longitude - 0.1,$this->auth->longitude + 0.1]];
  60. // $map['user.latitude'] = ['between',[$this->auth->latitude - 0.1,$this->auth->latitude + 0.1]];
  61. } else {
  62. $map['user.createtime'] = ['egt', time() - 86400 * 30];
  63. // $order = 'user.createtime desc';
  64. }
  65. if ($age_id > 0 && $age_id < 8) {
  66. if ($age_id == 1) {
  67. $agemin = 18;
  68. $agemax = 25;
  69. } elseif ($age_id == 2) {
  70. $agemin = 25;
  71. $agemax = 30;
  72. } elseif ($age_id == 3) {
  73. $agemin = 30;
  74. $agemax = 35;
  75. } elseif ($age_id == 4) {
  76. $agemin = 35;
  77. $agemax = 40;
  78. } elseif ($age_id == 5) {
  79. $agemin = 40;
  80. $agemax = 45;
  81. } elseif ($age_id == 6) {
  82. $agemin = 45;
  83. $agemax = 50;
  84. } elseif ($age_id == 7) {
  85. $agemin = 50;
  86. $agemax = 200;
  87. }
  88. $map['user.birthday'] = ['between', [time() - $agemax * 31536000, time() - $agemin * 31536000]];
  89. }
  90. //dump($map);
  91. $field = [
  92. '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'
  93. ];
  94. //$list = Db::name('user')->alias('user')->field($field)->where($map)->order($order)->autopage()->select();
  95. $list = Db::name('user')->alias('user')->field($field)
  96. //->join('user_wallet uw','uw.user_id = user.id','LEFT')
  97. ->where($map)->order($order)->autopage()->select();
  98. $list = list_domain_image($list,['avatar']);
  99. $mt_enum_job = Db::name('enum_job'); //职业
  100. $mt_enum_wages = Db::name('enum_wages'); //收入
  101. $mt_user_wallet = Db::name('user_wallet'); //vip
  102. $mt_user_greet = Db::name('user_greet'); //是否打过招呼
  103. $mt_wealth_level = Db::name('wealth_level'); //财富等级
  104. $mt_charm_level = Db::name('charm_level'); //魅力等级
  105. $mt_area = Db::name('area'); //城市
  106. $time = time();
  107. $hometown_cityid = [];//城市ids
  108. $user_to_id = [];//打招呼ids
  109. foreach ($list as $key=>$val){
  110. $hometown_cityid[] = $val['hometown_cityid'];
  111. $user_to_id[] = $val['id'];
  112. }
  113. // 城市
  114. $mt_areas = $mt_area->field(['id','name'])->whereIn('id',$hometown_cityid)->select();
  115. $mt_areas = array_column($mt_areas ?? [],'name','id');
  116. // 是否打过招呼
  117. $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();
  118. $mt_user_greets = array_column($mt_user_greets ?? [],'num','user_to_id');
  119. // 是否是vip
  120. $mt_user_wallets = $mt_user_wallet->field(['id','user_id','vip_endtime','pay_money'])->whereIn('user_id',$user_to_id)->select();
  121. // 财富等级
  122. $mt_wealth_levels = $mt_wealth_level->order('id desc')->column('value,image');
  123. // 魅力等级
  124. $mt_charm_levels = $mt_charm_level->order('id desc')->column('value,image');
  125. foreach($list as $key => &$v) {
  126. if ($this->auth->gender == 1) { //用户是男的
  127. $age = birthtime_to_age($v['birthday']);
  128. // $job = $mt_enum_job->where(['id' => $v['job_id']])->value('name');
  129. // $v['desc'] = $distance . ' · ' . $age . '岁';
  130. $v['desc'] = '';
  131. if ($age > 0) {
  132. $v['desc'] = $age . '岁';
  133. } else {
  134. $v['desc'] = '18岁';
  135. }
  136. if ($v['height']) {
  137. $v['desc'] .= ' | ' . $v['height'];
  138. }
  139. // if ($job) {
  140. // $v['desc'] .= ' · ' . $job;
  141. // }
  142. if ($type == 1) {
  143. // $distance = $this->calc_map_distance([$this->auth->longitude, $this->auth->latitude], [$v['longitude'], $v['latitude']]);
  144. // $v['desc'] .= ' | ' . $distance;
  145. $v['desc'] .= ' | 10km+';
  146. }
  147. } else {
  148. if ($type != 1) {
  149. $v['desc'] = $v['bio'] ?: '暂未设置个性签名';
  150. } else {
  151. $age = birthtime_to_age($v['birthday']);
  152. // $wages = $mt_enum_wages->where(['id' => $v['wages_id']])->value('name');
  153. // $v['desc'] = $distance . ' · ' . $age . '岁';
  154. $v['desc'] = '';
  155. if ($age > 0) {
  156. $v['desc'] = $age . '岁';
  157. } else {
  158. $v['desc'] = '18岁';
  159. }
  160. if ($v['hometown_cityid']) {
  161. $hometown_city = $mt_areas[$v['hometown_cityid']] ?? '';
  162. $hometown_city = ($hometown_city && $v['is_hideaddress'] == 0) ? $hometown_city : '';
  163. if ($hometown_city) {
  164. $v['desc'] .= ' | ' . $hometown_city;
  165. }
  166. }
  167. // if ($wages) {
  168. // $v['desc'] .= ' · ' . $wages;
  169. // }
  170. }
  171. }
  172. //查询是否打过招呼
  173. $count = $mt_user_greets[$v['id']] ?? 0;
  174. if ($count) {
  175. $v['is_chat'] = 1; //是否打过招呼: 1是 0否
  176. } else {
  177. $v['is_chat'] = 0; //是否打过招呼: 1是 0否
  178. }
  179. $vip_endtime = 0;
  180. $pay_money = 0;
  181. foreach ($mt_user_wallets as $kk=>$vv){
  182. if ($vv['user_id'] == $v['id']) {
  183. $vip_endtime = $vv['vip_endtime'];
  184. $pay_money = $vv['pay_money'];
  185. break;
  186. }
  187. }
  188. if ($vip_endtime >= $time) {
  189. $v['is_vip'] = 1; //是否是vip: 1是 0否
  190. } else {
  191. $v['is_vip'] = 0; //是否是vip: 1是 0否
  192. }
  193. //查询财富等级
  194. if (!empty($mt_wealth_levels)) {
  195. $name = '';
  196. foreach ($mt_wealth_levels as $kkk=>$vvv){
  197. if ($pay_money > $kkk){
  198. $name = localpath_to_netpath($vvv);
  199. break;
  200. }
  201. }
  202. $v['wealth_level'] = $name;
  203. } else {
  204. $v['wealth_level'] = '';
  205. }
  206. //查询魅力等级
  207. if (!empty($mt_charm_levels)) {
  208. $name = '';
  209. foreach ($mt_charm_levels as $kkk=>$vvv){
  210. if ($pay_money > $kkk){
  211. $name = localpath_to_netpath($vvv);
  212. break;
  213. }
  214. }
  215. $v['charm_level'] = $name;
  216. } else {
  217. $v['charm_level'] = '';
  218. }
  219. }
  220. $this->success('success',$list);
  221. }
  222. /*
  223. * 获取系统消息列表
  224. */
  225. public function getMessage() {
  226. $page = $this->request->request('page',1); // 分页
  227. $pageNum = $this->request->request('pageNum',10); // 分页
  228. // 分页搜索构建
  229. $pageStart = ($page-1)*$pageNum;
  230. $flag = $this->request->request("flag",1,"intval"); //标识:1=只取一条,0=全部
  231. $user_id = $this->auth->id;
  232. $obj = \app\common\model\Message::where(["user_id"=>$user_id])->order("createtime","desc")->limit($pageStart,$pageNum);
  233. if($flag == 1) {
  234. $list = $obj->find();
  235. $list || $list = [];
  236. $list && $list["createtime"] = get_last_time($list["createtime"]);
  237. } else {
  238. $list = $obj->select();
  239. if($list) foreach($list as $k => &$v) {
  240. $v["createtime"] = get_last_time($v["createtime"]);
  241. }
  242. }
  243. $this->success("获取成功!",$list);
  244. }
  245. /**
  246. * 删除系统消息
  247. */
  248. public function delMessage() {
  249. $id = $this->request->request("id",0,"intval"); //消息ID
  250. if($id <= 0) {
  251. $this->error("参数传入错误!");
  252. }
  253. $res = \app\common\model\Message::where(["id"=>$id,"user_id"=>$this->auth->id])->delete();
  254. if($res) {
  255. $this->success("删除成功!");
  256. } else {
  257. $this->error("删除失败!");
  258. }
  259. }
  260. /**
  261. * 获取下载二维码和邀请码
  262. */
  263. public function getInviteCode() {
  264. // 获取二维码
  265. $qrcode = $this->httpurl(config("site.qrcode"));
  266. $miniqrcode = $this->httpurl(config("site.miniqrcode"));
  267. // 获取用户邀请码
  268. $inviteCode = \app\common\model\User::where(["id"=>$this->auth->id])->value("invite_no");
  269. $host = $_SERVER["REQUEST_SCHEME"]."://".$_SERVER["HTTP_HOST"];
  270. $downlowdLink = $host."/index/index/appJump?t=wlt".rand(10,999).Random::alpha(8);
  271. $this->success("获取成功!",["qrcode"=>$qrcode,"miniqrcode"=>$miniqrcode,"inviteCode"=>$inviteCode,"downlowdLink"=>$downlowdLink]);
  272. }
  273. /**
  274. * 获取app分享海报
  275. */
  276. public function getAppShare() {
  277. $this->success("获取成功!",["url"=>$this->httpurl(config("site.appShare"))]);
  278. }
  279. /**
  280. * 获取版本更新信息
  281. */
  282. public function getEdition() {
  283. // 获取二维码
  284. $is_force = config("site.is_force");
  285. $apkUrl = config("site.apk_url");
  286. $apkName = config("site.apkName");
  287. $desc = config("site.desc");
  288. $versionCode = config("site.versionCode");
  289. $this->success("获取成功!",["versionCode"=>$versionCode,"isForceUpdate"=>$is_force,"apkUrl"=>$apkUrl,"apkName"=>$apkName,"desc"=>$desc]);
  290. }
  291. /**
  292. * 获取邀请图片
  293. */
  294. public function getInviteImg() {
  295. $plat = $this->request->request("plat",1); //平台:1=小程序,2=app
  296. if(!in_array($plat,[1,2])) $this->error("参数错误");
  297. // 获取用户的邀请码
  298. $invitecode = \app\common\model\User::where(["id"=>$this->auth->id])->value("invite_no");
  299. // 文字图片合成
  300. $bigImgPath = $this->httpurlLocal('/assets/img/inviteimg.jpeg');
  301. $img = imagecreatefromstring(file_get_contents($bigImgPath));
  302. //字体文件
  303. $font = realpath('./assets/fonts/lato/lato-black.ttf');
  304. //字体颜色(RGB)
  305. $black = imagecolorallocate($img, 217, 76, 41);
  306. //字体大小
  307. $fontSize = 30;
  308. //旋转角度
  309. $circleSize = 0;
  310. //左边距
  311. $left = 275;
  312. //上边距
  313. $top = 540;
  314. imagefttext($img, $fontSize, $circleSize, $left, $top, $black, $font, $invitecode);
  315. $filename = date("YmdH").".jpeg";
  316. $path = "/uploads/qrcode/".$filename;
  317. $file = $_SERVER['DOCUMENT_ROOT'] . $path;//打开文件准备写入
  318. list($bgWidth, $bgHight, $bgType) = getimagesize($bigImgPath);
  319. switch ($bgType) {
  320. case 1://gif
  321. header('Content-Type:image/gif');
  322. imagegif($img,$file);
  323. break;
  324. case 2://jpg
  325. header('Content-Type:image/jpg');
  326. imagejpeg($img,$file);
  327. break;
  328. case 3://jpg
  329. header('Content-Type:image/png');
  330. imagepng($img,$file);
  331. break;
  332. default:
  333. break;
  334. }
  335. //销毁照片
  336. imagedestroy($img);
  337. // 图片和二维码合成
  338. $qrcode = $plat == 1 ? config("site.miniqrcode"):config("site.qrcode");
  339. $background = $file;
  340. $target = $this->httpurl($qrcode);
  341. $background_iamge = imagecreatefromstring(file_get_contents($background));
  342. $target_image = imagecreatefromstring(file_get_contents($target));
  343. list($target_width, $target_height, $target_type) = getimagesize($target);
  344. imagecopymerge($background_iamge , $target_image , 250, 700, 0, 0, $target_width, $target_height, 100);
  345. list($background_width, $background_height, $background_type) = getimagesize($background);
  346. switch ($background_type) {
  347. case 1://gif
  348. header('Content-Type:image/gif');
  349. imagegif($background_iamge,$file);
  350. break;
  351. case 2://jpg
  352. header('Content-Type:image/jpg');
  353. imagejpeg($background_iamge,$file);
  354. break;
  355. case 3://jpg
  356. header('Content-Type:image/png');
  357. imagepng($background_iamge,$file);
  358. break;
  359. default:
  360. break;
  361. }
  362. $savepath = $this->httpurlLocal($path);
  363. $this->success("获取成功!",$savepath);
  364. }
  365. //轮播图
  366. public function banner() {
  367. $type = input('type', 0, 'intval'); //类型:0=交友轮播图,1=动态轮播图
  368. $list = Db::name('banner')->field('id, title, image, url')->where(['status' => 1, 'type' => $type])->order('weigh', 'desc')->select();
  369. $list = list_domain_image($list, ['image']);
  370. $this->success('轮播图', $list);
  371. }
  372. //筛选年龄段
  373. public function agerange() {
  374. $list = [
  375. [
  376. 'id' => 0,
  377. 'title' => '不限'
  378. ],
  379. [
  380. 'id' => 1,
  381. 'title' => '18-25岁'
  382. ],
  383. [
  384. 'id' => 2,
  385. 'title' => '25-30岁'
  386. ],
  387. [
  388. 'id' => 3,
  389. 'title' => '30-35岁'
  390. ],
  391. [
  392. 'id' => 4,
  393. 'title' => '35-40岁'
  394. ],
  395. [
  396. 'id' => 5,
  397. 'title' => '40-45岁'
  398. ],
  399. [
  400. 'id' => 6,
  401. 'title' => '45-50岁'
  402. ],
  403. [
  404. 'id' => 7,
  405. 'title' => '50岁以上'
  406. ]
  407. ];
  408. $this->success('筛选年龄段', $list);
  409. }
  410. /**
  411. * calc_map_distance() , 根据地图上的两个点各自的x,y坐标,计算出2点之间的直线距离
  412. * @param array $point_1 第1个点的x,y坐标 array( 101 , 202 )
  413. * @param array $point_2 第2个点的x,y坐标 array( 101 , 202 )
  414. * @param bool $calc_as_string 是否计算为字符串公里距离 , 如果未否返回数字
  415. * @return float | false | string
  416. */
  417. private function calc_map_distance( $point_1=array( ) , $point_2=array( ) , $calc_as_string=false ) {
  418. if( empty( $point_1 ) || empty( $point_2 ) ){
  419. return false;
  420. }
  421. // 经纬度不存在,或者经纬度超过最大范围 +-180 , +-90 ,返回false
  422. $p1_x = $point_1[0];
  423. $p1_y = $point_1[1];
  424. $p2_x = $point_2[0];
  425. $p2_y = $point_2[1];
  426. if(
  427. $p1_x < -180 || $p1_x > 180
  428. || $p2_x < -180 || $p2_x > 180
  429. || $p1_y < -90 || $p1_y > 90
  430. || $p2_y < -90 || $p2_y > 90
  431. || $p1_x == '' || $p1_y == ''
  432. || $p2_x == '' || $p2_y == ''
  433. ){
  434. return '距离未知';
  435. }
  436. // 根据2点各自的坐标,计算2点之间直线距离的公式
  437. $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);
  438. // 是否计算为字符串公里距离
  439. if( !$calc_as_string ){
  440. return (string)round( $distance / 1000 , 1 ) . 'km';
  441. }
  442. // 如果计算为字符串公里距离
  443. if( $distance / 1000 > 1 ){
  444. $k = (string)round( $distance / 1000 , 1 );
  445. $m = (string)$distance % 1000 ;
  446. // $distance = "{$k}公里{$m}米";
  447. $distance = "{$k}km";
  448. }
  449. else{
  450. $distance = "{$distance}m";
  451. }
  452. return $distance;
  453. }
  454. //女号私信异性完成任务
  455. public function girlchattask() {
  456. if ($this->auth->gender != 0) { //只有女生可以
  457. $this->error('您的网络开小差啦~');
  458. }
  459. //检测用户
  460. $to_user_id = input_post('to_user_id');
  461. $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();
  462. if(!$to_user_info){
  463. $this->error('不存在的用户');
  464. }
  465. if ($to_user_info['is_kefu'] == 1 || $this->auth->is_kefu == 1) { //我是客服或者对方是客服
  466. $this->success('success');
  467. }
  468. if ($to_user_info['gender'] != 1) {
  469. $this->error('性别异常~');
  470. }
  471. $task_rs = \app\common\model\TaskLog::tofinish($this->auth->id,23);
  472. if($task_rs === false){
  473. $this->error('完成任务赠送奖励失败');
  474. }
  475. $this->success('success');
  476. }
  477. //腾讯内容审核回调方法
  478. public function tencentcall() {
  479. $content = file_get_contents('php://input');
  480. $content = json_decode($content, true);
  481. error_log(print_r($content, 1) . PHP_EOL, 3, './tencentcall3.txt');
  482. if (isset($content['Scene']) && $content['CtxcbResult'] == 1) { //语音文件: 只返回违规的数据; 处理方式: 撤回
  483. $tenim = new Tenim;
  484. $rs = $tenim->withdraw_message($content['From_Account'], $content['ContactItem']['To_Account'], $content['MsgID']);
  485. // error_log(print_r($rs, 1) . PHP_EOL, 3, './tencentcall4.txt');
  486. } elseif (isset($content['TaskId'])) { //音视频通话: 返回所有数据; 处理方式: 强制退出im, 清空token
  487. if ($content['Status'] == 'RUNNING') {
  488. //该字段用于返回所查询内容的任务状态。取值:FINISH(任务已完成)、PENDING (任务等待中)、RUNNING (任务进行中)、ERROR (任务出错)、CANCELLED (任务已取消)。
  489. if ($content['ImageSegments']) { //图片(视频)审核结果
  490. $image_info = $content['ImageSegments'][0]['Result'];
  491. if ($image_info['Label'] != 'Normal') {
  492. //该字段用于返回检测结果所对应的恶意标签。返回值:Porn:色情,Abuse:谩骂,Ad:广告,Custom:自定义违规;以及其他令人反感、不安全或不适宜的内容类型。
  493. $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
  494. //获取违规用户id
  495. $url = explode('?', $url);
  496. $url = $url[0];
  497. $user_id_url = explode('/', $url);
  498. $user_id_url = $user_id_url[count($user_id_url) - 1];
  499. $user_id_arr = explode('_', $user_id_url);
  500. $user_id = $user_id_arr[2];
  501. //退出im
  502. $tenIm = new Tenim();
  503. $tenIm->loginoutim($user_id);
  504. //清空token
  505. Token::clear($user_id);
  506. $tiaoshi = $user_id . '---' . $content['TaskId'] . '---' .$image_info['Label'] .'---'. date('Y-m-d H:i:s');
  507. error_log(print_r($tiaoshi, 1) . PHP_EOL, 3, './dayin1.txt');
  508. }
  509. } elseif ($content['AudioSegments']) { //音频审核结果
  510. $audio_info = $content['AudioSegments'][0]['Result'];
  511. if ($audio_info['Label'] != 'Normal') {
  512. //该字段用于返回检测结果所对应的恶意标签。返回值:Porn:色情,Abuse:谩骂,Ad:广告,Custom:自定义违规;以及其他令人反感、不安全或不适宜的内容类型。
  513. $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
  514. //获取违规用户id
  515. $url = explode('?', $url);
  516. $url = $url[0];
  517. $user_id_url = explode('/', $url);
  518. $user_id_url = $user_id_url[count($user_id_url) - 1];
  519. $user_id_arr = explode('_', $user_id_url);
  520. $user_id = $user_id_arr[2];
  521. //退出im
  522. $tenIm = new Tenim();
  523. $tenIm->loginoutim($user_id);
  524. //清空token
  525. Token::clear($user_id);
  526. $tiaoshi = $user_id . '---' . $content['TaskId'] . '---' .$audio_info['Label'] .'---'. date('Y-m-d H:i:s');
  527. error_log(print_r($tiaoshi, 1) . PHP_EOL, 3, './dayin2.txt');
  528. }
  529. }
  530. }
  531. }
  532. }
  533. //头条
  534. public function headlines() {
  535. $time = strtotime(date('Y-m-d', time()));
  536. //聊天送礼物
  537. $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();
  538. //动态送礼物
  539. $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();
  540. $list = array_merge($list1, $list2);
  541. if ($list) {
  542. $mt_user = Db::name('user');
  543. foreach ($list as &$v) {
  544. $user_info= $mt_user->field('nickname, avatar')->where(['id' => $v['user_id']])->find();
  545. $v['from_nickname'] = '有缘人';//$user_info['nickname'];
  546. $v['avatar'] = one_domain_image($user_info['avatar']);
  547. $v['to_nickname'] = '有缘人';//$mt_user->where(['id' => $v['user_to_id']])->value('nickname');
  548. }
  549. }
  550. $this->success('头条', $list);
  551. }
  552. //首页顶部分类名称
  553. public function typename() {
  554. $typename = config('site.typename');
  555. $typename = explode(',', $typename);
  556. $data[] = $typename[0] ? : '推荐';
  557. $data[] = $typename[1] ? : '附近';
  558. $data[] = $typename[2] ? : '新人';
  559. $this->success('sussess', $data);
  560. }
  561. //获取版本更新信息
  562. public function getversion() {
  563. // 获取二维码
  564. $is_force = config("site.is_force"); //是否强制更新 1是 0否
  565. $apk_url = config("site.apk_url"); //下载链接
  566. $apk_name = config("site.apk_name"); //apk更新标题
  567. $apk_desc = config("site.apk_desc"); //apk更新描述
  568. $version_code = config("site.version_code"); //版本迭代号
  569. $data['is_force'] = $is_force;
  570. $data['apk_url'] = $apk_url;
  571. $data['apk_name'] = $apk_name;
  572. $data['apk_desc'] = $apk_desc;
  573. $data['version_code'] = $version_code;
  574. $this->success('Success', $data);
  575. }
  576. //获取ios版本更新信息
  577. public function getiosversion() {
  578. // 获取二维码
  579. $is_force = config("site.ios_is_force"); //是否强制更新 1是 0否
  580. $apk_url = config("site.ios_apk_url"); //下载链接
  581. $apk_name = config("site.ios_apk_name"); //apk更新标题
  582. $apk_desc = config("site.ios_apk_desc"); //apk更新描述
  583. $version_code = config("site.ios_version_code"); //版本迭代号
  584. $data['is_force'] = $is_force;
  585. $data['apk_url'] = $apk_url;
  586. $data['apk_name'] = $apk_name;
  587. $data['apk_desc'] = $apk_desc;
  588. $data['version_code'] = $version_code;
  589. $this->success('Success', $data);
  590. }
  591. }