Index.php 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721
  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 getWebsiteInfoForMini() {
  226. $params = $this->request->request("params"); //内容
  227. $res = config("site.".$params);
  228. if($params == "boxGiftLogo") $res = $this->httpurl(config("site.".$params));
  229. $this->success("获取成功!",$res);
  230. }
  231. /*
  232. * 获取系统消息列表
  233. */
  234. public function getMessage() {
  235. $page = $this->request->request('page',1); // 分页
  236. $pageNum = $this->request->request('pageNum',10); // 分页
  237. // 分页搜索构建
  238. $pageStart = ($page-1)*$pageNum;
  239. $flag = $this->request->request("flag",1,"intval"); //标识:1=只取一条,0=全部
  240. $user_id = $this->auth->id;
  241. $obj = \app\common\model\Message::where(["user_id"=>$user_id])->order("createtime","desc")->limit($pageStart,$pageNum);
  242. if($flag == 1) {
  243. $list = $obj->find();
  244. $list || $list = [];
  245. $list && $list["createtime"] = get_last_time($list["createtime"]);
  246. } else {
  247. $list = $obj->select();
  248. if($list) foreach($list as $k => &$v) {
  249. $v["createtime"] = get_last_time($v["createtime"]);
  250. }
  251. }
  252. $this->success("获取成功!",$list);
  253. }
  254. /**
  255. * 删除系统消息
  256. */
  257. public function delMessage() {
  258. $id = $this->request->request("id",0,"intval"); //消息ID
  259. if($id <= 0) {
  260. $this->error("参数传入错误!");
  261. }
  262. $res = \app\common\model\Message::where(["id"=>$id,"user_id"=>$this->auth->id])->delete();
  263. if($res) {
  264. $this->success("删除成功!");
  265. } else {
  266. $this->error("删除失败!");
  267. }
  268. }
  269. /**
  270. * 获取下载二维码和邀请码
  271. */
  272. public function getInviteCode() {
  273. // 获取二维码
  274. $qrcode = $this->httpurl(config("site.qrcode"));
  275. $miniqrcode = $this->httpurl(config("site.miniqrcode"));
  276. // 获取用户邀请码
  277. $inviteCode = \app\common\model\User::where(["id"=>$this->auth->id])->value("invite_no");
  278. $host = $_SERVER["REQUEST_SCHEME"]."://".$_SERVER["HTTP_HOST"];
  279. $downlowdLink = $host."/index/index/appJump?t=wlt".rand(10,999).Random::alpha(8);
  280. $this->success("获取成功!",["qrcode"=>$qrcode,"miniqrcode"=>$miniqrcode,"inviteCode"=>$inviteCode,"downlowdLink"=>$downlowdLink]);
  281. }
  282. /**
  283. * 获取app分享海报
  284. */
  285. public function getAppShare() {
  286. $this->success("获取成功!",["url"=>$this->httpurl(config("site.appShare"))]);
  287. }
  288. /**
  289. * 获取版本更新信息
  290. */
  291. public function getEdition() {
  292. // 获取二维码
  293. $is_force = config("site.is_force");
  294. $apkUrl = config("site.apk_url");
  295. $apkName = config("site.apkName");
  296. $desc = config("site.desc");
  297. $versionCode = config("site.versionCode");
  298. $this->success("获取成功!",["versionCode"=>$versionCode,"isForceUpdate"=>$is_force,"apkUrl"=>$apkUrl,"apkName"=>$apkName,"desc"=>$desc]);
  299. }
  300. /**
  301. * 获取邀请图片
  302. */
  303. public function getInviteImg() {
  304. $plat = $this->request->request("plat",1); //平台:1=小程序,2=app
  305. if(!in_array($plat,[1,2])) $this->error("参数错误");
  306. // 获取用户的邀请码
  307. $invitecode = \app\common\model\User::where(["id"=>$this->auth->id])->value("invite_no");
  308. // 文字图片合成
  309. $bigImgPath = $this->httpurlLocal('/assets/img/inviteimg.jpeg');
  310. $img = imagecreatefromstring(file_get_contents($bigImgPath));
  311. //字体文件
  312. $font = realpath('./assets/fonts/lato/lato-black.ttf');
  313. //字体颜色(RGB)
  314. $black = imagecolorallocate($img, 217, 76, 41);
  315. //字体大小
  316. $fontSize = 30;
  317. //旋转角度
  318. $circleSize = 0;
  319. //左边距
  320. $left = 275;
  321. //上边距
  322. $top = 540;
  323. imagefttext($img, $fontSize, $circleSize, $left, $top, $black, $font, $invitecode);
  324. $filename = date("YmdH").".jpeg";
  325. $path = "/uploads/qrcode/".$filename;
  326. $file = $_SERVER['DOCUMENT_ROOT'] . $path;//打开文件准备写入
  327. list($bgWidth, $bgHight, $bgType) = getimagesize($bigImgPath);
  328. switch ($bgType) {
  329. case 1://gif
  330. header('Content-Type:image/gif');
  331. imagegif($img,$file);
  332. break;
  333. case 2://jpg
  334. header('Content-Type:image/jpg');
  335. imagejpeg($img,$file);
  336. break;
  337. case 3://jpg
  338. header('Content-Type:image/png');
  339. imagepng($img,$file);
  340. break;
  341. default:
  342. break;
  343. }
  344. //销毁照片
  345. imagedestroy($img);
  346. // 图片和二维码合成
  347. $qrcode = $plat == 1 ? config("site.miniqrcode"):config("site.qrcode");
  348. $background = $file;
  349. $target = $this->httpurl($qrcode);
  350. $background_iamge = imagecreatefromstring(file_get_contents($background));
  351. $target_image = imagecreatefromstring(file_get_contents($target));
  352. list($target_width, $target_height, $target_type) = getimagesize($target);
  353. imagecopymerge($background_iamge , $target_image , 250, 700, 0, 0, $target_width, $target_height, 100);
  354. list($background_width, $background_height, $background_type) = getimagesize($background);
  355. switch ($background_type) {
  356. case 1://gif
  357. header('Content-Type:image/gif');
  358. imagegif($background_iamge,$file);
  359. break;
  360. case 2://jpg
  361. header('Content-Type:image/jpg');
  362. imagejpeg($background_iamge,$file);
  363. break;
  364. case 3://jpg
  365. header('Content-Type:image/png');
  366. imagepng($background_iamge,$file);
  367. break;
  368. default:
  369. break;
  370. }
  371. $savepath = $this->httpurlLocal($path);
  372. $this->success("获取成功!",$savepath);
  373. }
  374. //轮播图
  375. public function banner() {
  376. $type = input('type', 0, 'intval'); //类型:0=交友轮播图,1=动态轮播图
  377. $list = Db::name('banner')->field('id, title, image, url')->where(['status' => 1, 'type' => $type])->order('weigh', 'desc')->select();
  378. $list = list_domain_image($list, ['image']);
  379. $this->success('轮播图', $list);
  380. }
  381. //谁看过我汇总
  382. public function visitlist(){
  383. $time = Db::name('user_visit_time')->where(['user_id' => $this->auth->id])->value('visittime');
  384. $where = [];
  385. if ($time) {
  386. $where['updatetime'] = ['gt', $time];
  387. }
  388. $list = [];
  389. $count = Db::name('user_visit')->where(['to_uid' => $this->auth->id])->where($where)->count('id');
  390. if ($count) {
  391. $uid_list = Db::name('user_visit')->field('uid')->where(['to_uid' => $this->auth->id])->where($where)->limit(9)->column('uid');
  392. $mt_user = Db::name('user');
  393. foreach ($uid_list as &$v) {
  394. $avatar = $mt_user->where(['id' => $v])->value('avatar');
  395. $list[] = one_domain_image($avatar);
  396. }
  397. }
  398. $data['count'] = $count;
  399. $data['list'] = $list;
  400. $this->success('success',$data);
  401. }
  402. //筛选年龄段
  403. public function agerange() {
  404. $list = [
  405. [
  406. 'id' => 0,
  407. 'title' => '不限'
  408. ],
  409. [
  410. 'id' => 1,
  411. 'title' => '18-25岁'
  412. ],
  413. [
  414. 'id' => 2,
  415. 'title' => '25-30岁'
  416. ],
  417. [
  418. 'id' => 3,
  419. 'title' => '30-35岁'
  420. ],
  421. [
  422. 'id' => 4,
  423. 'title' => '35-40岁'
  424. ],
  425. [
  426. 'id' => 5,
  427. 'title' => '40-45岁'
  428. ],
  429. [
  430. 'id' => 6,
  431. 'title' => '45-50岁'
  432. ],
  433. [
  434. 'id' => 7,
  435. 'title' => '50岁以上'
  436. ]
  437. ];
  438. $this->success('筛选年龄段', $list);
  439. }
  440. /**
  441. * calc_map_distance() , 根据地图上的两个点各自的x,y坐标,计算出2点之间的直线距离
  442. * @param array $point_1 第1个点的x,y坐标 array( 101 , 202 )
  443. * @param array $point_2 第2个点的x,y坐标 array( 101 , 202 )
  444. * @param bool $calc_as_string 是否计算为字符串公里距离 , 如果未否返回数字
  445. * @return float | false | string
  446. */
  447. private function calc_map_distance( $point_1=array( ) , $point_2=array( ) , $calc_as_string=false ) {
  448. if( empty( $point_1 ) || empty( $point_2 ) ){
  449. return false;
  450. }
  451. // 经纬度不存在,或者经纬度超过最大范围 +-180 , +-90 ,返回false
  452. $p1_x = $point_1[0];
  453. $p1_y = $point_1[1];
  454. $p2_x = $point_2[0];
  455. $p2_y = $point_2[1];
  456. if(
  457. $p1_x < -180 || $p1_x > 180
  458. || $p2_x < -180 || $p2_x > 180
  459. || $p1_y < -90 || $p1_y > 90
  460. || $p2_y < -90 || $p2_y > 90
  461. || $p1_x == '' || $p1_y == ''
  462. || $p2_x == '' || $p2_y == ''
  463. ){
  464. return '距离未知';
  465. }
  466. // 根据2点各自的坐标,计算2点之间直线距离的公式
  467. $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);
  468. // 是否计算为字符串公里距离
  469. if( !$calc_as_string ){
  470. return (string)round( $distance / 1000 , 1 ) . 'km';
  471. }
  472. // 如果计算为字符串公里距离
  473. if( $distance / 1000 > 1 ){
  474. $k = (string)round( $distance / 1000 , 1 );
  475. $m = (string)$distance % 1000 ;
  476. // $distance = "{$k}公里{$m}米";
  477. $distance = "{$k}km";
  478. }
  479. else{
  480. $distance = "{$distance}m";
  481. }
  482. return $distance;
  483. }
  484. //女号私信异性完成任务
  485. public function girlchattask() {
  486. if ($this->auth->gender != 0) { //只有女生可以
  487. $this->error('您的网络开小差啦~');
  488. }
  489. //检测用户
  490. $to_user_id = input_post('to_user_id');
  491. $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();
  492. if(!$to_user_info){
  493. $this->error('不存在的用户');
  494. }
  495. if ($to_user_info['is_kefu'] == 1 || $this->auth->is_kefu == 1) { //我是客服或者对方是客服
  496. $this->success('success');
  497. }
  498. if ($to_user_info['gender'] != 1) {
  499. $this->error('性别异常~');
  500. }
  501. $task_rs = \app\common\model\TaskLog::tofinish($this->auth->id,23);
  502. if($task_rs === false){
  503. $this->error('完成任务赠送奖励失败');
  504. }
  505. $this->success('success');
  506. }
  507. //腾讯内容审核回调方法
  508. public function tencentcall() {
  509. $content = file_get_contents('php://input');
  510. $content = json_decode($content, true);
  511. error_log(print_r($content, 1) . PHP_EOL, 3, './tencentcall3.txt');
  512. if (isset($content['Scene']) && $content['CtxcbResult'] == 1) { //语音文件: 只返回违规的数据; 处理方式: 撤回
  513. $tenim = new Tenim;
  514. $rs = $tenim->withdraw_message($content['From_Account'], $content['ContactItem']['To_Account'], $content['MsgID']);
  515. // error_log(print_r($rs, 1) . PHP_EOL, 3, './tencentcall4.txt');
  516. } elseif (isset($content['TaskId'])) { //音视频通话: 返回所有数据; 处理方式: 强制退出im, 清空token
  517. if ($content['Status'] == 'RUNNING') {
  518. //该字段用于返回所查询内容的任务状态。取值:FINISH(任务已完成)、PENDING (任务等待中)、RUNNING (任务进行中)、ERROR (任务出错)、CANCELLED (任务已取消)。
  519. if ($content['ImageSegments']) { //图片(视频)审核结果
  520. $image_info = $content['ImageSegments'][0]['Result'];
  521. if ($image_info['Label'] != 'Normal') {
  522. //该字段用于返回检测结果所对应的恶意标签。返回值:Porn:色情,Abuse:谩骂,Ad:广告,Custom:自定义违规;以及其他令人反感、不安全或不适宜的内容类型。
  523. $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
  524. //获取违规用户id
  525. $url = explode('?', $url);
  526. $url = $url[0];
  527. $user_id_url = explode('/', $url);
  528. $user_id_url = $user_id_url[count($user_id_url) - 1];
  529. $user_id_arr = explode('_', $user_id_url);
  530. $user_id = $user_id_arr[2];
  531. //退出im
  532. $tenIm = new Tenim();
  533. $tenIm->loginoutim($user_id);
  534. //清空token
  535. Token::clear($user_id);
  536. $tiaoshi = $user_id . '---' . $content['TaskId'] . '---' .$image_info['Label'] .'---'. date('Y-m-d H:i:s');
  537. error_log(print_r($tiaoshi, 1) . PHP_EOL, 3, './dayin1.txt');
  538. }
  539. } elseif ($content['AudioSegments']) { //音频审核结果
  540. $audio_info = $content['AudioSegments'][0]['Result'];
  541. if ($audio_info['Label'] != 'Normal') {
  542. //该字段用于返回检测结果所对应的恶意标签。返回值:Porn:色情,Abuse:谩骂,Ad:广告,Custom:自定义违规;以及其他令人反感、不安全或不适宜的内容类型。
  543. $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
  544. //获取违规用户id
  545. $url = explode('?', $url);
  546. $url = $url[0];
  547. $user_id_url = explode('/', $url);
  548. $user_id_url = $user_id_url[count($user_id_url) - 1];
  549. $user_id_arr = explode('_', $user_id_url);
  550. $user_id = $user_id_arr[2];
  551. //退出im
  552. $tenIm = new Tenim();
  553. $tenIm->loginoutim($user_id);
  554. //清空token
  555. Token::clear($user_id);
  556. $tiaoshi = $user_id . '---' . $content['TaskId'] . '---' .$audio_info['Label'] .'---'. date('Y-m-d H:i:s');
  557. error_log(print_r($tiaoshi, 1) . PHP_EOL, 3, './dayin2.txt');
  558. }
  559. }
  560. }
  561. }
  562. }
  563. //头条
  564. public function headlines() {
  565. $time = strtotime(date('Y-m-d', time()));
  566. //聊天送礼物
  567. $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();
  568. //动态送礼物
  569. $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();
  570. $list = array_merge($list1, $list2);
  571. if ($list) {
  572. $mt_user = Db::name('user');
  573. foreach ($list as &$v) {
  574. $user_info= $mt_user->field('nickname, avatar')->where(['id' => $v['user_id']])->find();
  575. $v['from_nickname'] = '有缘人';//$user_info['nickname'];
  576. $v['avatar'] = one_domain_image($user_info['avatar']);
  577. $v['to_nickname'] = '有缘人';//$mt_user->where(['id' => $v['user_to_id']])->value('nickname');
  578. }
  579. }
  580. $this->success('头条', $list);
  581. }
  582. //首页顶部分类名称
  583. public function typename() {
  584. $typename = config('site.typename');
  585. $typename = explode(',', $typename);
  586. $data[] = $typename[0] ? : '推荐';
  587. $data[] = $typename[1] ? : '附近';
  588. $data[] = $typename[2] ? : '新人';
  589. $this->success('sussess', $data);
  590. }
  591. //获取版本更新信息
  592. public function getversion() {
  593. // 获取二维码
  594. $is_force = config("site.is_force"); //是否强制更新 1是 0否
  595. $apk_url = config("site.apk_url"); //下载链接
  596. $apk_name = config("site.apk_name"); //apk更新标题
  597. $apk_desc = config("site.apk_desc"); //apk更新描述
  598. $version_code = config("site.version_code"); //版本迭代号
  599. $data['is_force'] = $is_force;
  600. $data['apk_url'] = $apk_url;
  601. $data['apk_name'] = $apk_name;
  602. $data['apk_desc'] = $apk_desc;
  603. $data['version_code'] = $version_code;
  604. $this->success('Success', $data);
  605. }
  606. //获取ios版本更新信息
  607. public function getiosversion() {
  608. // 获取二维码
  609. $is_force = config("site.ios_is_force"); //是否强制更新 1是 0否
  610. $apk_url = config("site.ios_apk_url"); //下载链接
  611. $apk_name = config("site.ios_apk_name"); //apk更新标题
  612. $apk_desc = config("site.ios_apk_desc"); //apk更新描述
  613. $version_code = config("site.ios_version_code"); //版本迭代号
  614. $data['is_force'] = $is_force;
  615. $data['apk_url'] = $apk_url;
  616. $data['apk_name'] = $apk_name;
  617. $data['apk_desc'] = $apk_desc;
  618. $data['version_code'] = $version_code;
  619. $this->success('Success', $data);
  620. }
  621. }