TestController.php 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <?php
  2. namespace App\Http\Controllers\Api;
  3. use App\Models\DynamicModel;
  4. use App\Models\User;
  5. use App\Models\UserInfoModel;
  6. use App\Services\JPushService;
  7. use App\Services\TencentImAccountService;
  8. use App\Services\TencentImFriendService;
  9. use Illuminate\Support\Facades\Storage;
  10. use PHPUnit\Util\Exception;
  11. class TestController
  12. {
  13. public function creat_user(){
  14. return response()->json(['message'=>"暂时无法使用"]);
  15. $total = 1000;
  16. for ($i=0;$i<$total;$i++){
  17. $ins = array();
  18. $ins['mobile'] = '199'.rand(10000000,99999999);
  19. $ins['password'] = '123456';
  20. $ins['pid'] = 0;
  21. $ins['sex'] = rand(1,2);
  22. $ins['is_vip'] = rand(0,1);
  23. $ins['is_auth'] = 1;
  24. $ins['ycode'] = create_invite_code();
  25. $ins['latitude'] = '30.'.rand(100000,999999);//30.720653
  26. $ins['longitude'] = '103.'.rand(100000,999999);//103.720653
  27. $ins['online'] = rand(0,1);
  28. $ins['notice_status'] = 1;
  29. $user = User::query()->firstOrCreate($ins);
  30. $ins_info = array();
  31. $ins_info['user_id'] = $user->id;
  32. $ins_info['avatar'] = 'https://zhengda.oss-accelerate.aliyuncs.com/chengluApp/image_picker977203985037292577.jpg';
  33. $ins_info['nickname'] = '用户'.$user->id;
  34. $ins_info['birthday'] = rand(1980,2010).'-'.rand(1,12).'-'.rand(1,28);
  35. $ins_info['height'] = rand(140,190);
  36. $ins_info['weight'] = rand(30,100);
  37. $ins_info['work'] = ['学生','老师','程序员','工程师'][rand(0,3)];
  38. $ins_info['info'] = '这是个人介绍';
  39. $ins_info['area'] = '成都市';
  40. $ins_info['area_code'] = '510100';
  41. $ins_info['figure'] = '健美';
  42. $ins_info['feeling'] = '单身';
  43. $ins_info['education'] = '本科';
  44. $ins_info['income'] = '10-30W';
  45. $ins_info['hobby'] = '火锅,音乐,k歌,蹦迪';
  46. $ins_info['drink'] = '饮酒';
  47. $ins_info['photo'] = json_encode(['https://zhengda.oss-accelerate.aliyuncs.com/chengluApp/image_picker977203985037292577.jpg','https://zhengda.oss-cn-chengdu.aliyuncs.com/chengluApp/img/%E4%B8%8B%E8%BD%BD.jpg','https://zhengda.oss-cn-chengdu.aliyuncs.com/chengluApp/img/u%3D3564444755%2C3599870531%26fm%3D26%26gp%3D0.jpg']);
  48. $ins_info['video'] = json_encode(['https://zhengda.oss-cn-chengdu.aliyuncs.com/chengluApp/a69ce78c4898a7bcf13138bbea71608f.mp4']);
  49. UserInfoModel::query()->create($ins_info);
  50. }
  51. echo 'success';
  52. }
  53. public function juzi(){
  54. return [
  55. '坎坷路途,给身边一份温暖。生活,本就是体谅和理解,把快乐装在心中,静静融化,慢慢扩散',
  56. '梦想也许在今天无法实现,但重要的是,它在你心里。重要的是,你一直在努力',
  57. '奋斗的意义,不在于,一定会让你取得多大的成就,只是让你在平凡的日子里,活得比原来的那个',
  58. '心若年轻,岁月不老。那些偷偷溜走的时光,沧桑了我们的容颜,却丰盈了我们的人生。即使青春不',
  59. '人生,就要活得漂亮,走得铿锵。自己不奋斗,终归是摆设。无论你是谁,宁可做拼搏的失败者,也',
  60. ];
  61. }
  62. public function create_dynamic(){
  63. return response()->json(['message'=>"暂时无法使用"]);
  64. $total = 100;
  65. for ($i=0;$i<$total;$i++){
  66. $ins = array();
  67. $ins['user_id'] = rand(30,900);
  68. $ins['content'] = $this->juzi()[rand(0,4)];
  69. $ins['img_url'] = json_encode([
  70. 'https://zhengda.oss-cn-chengdu.aliyuncs.com/chengluApp/img/u%3D3870964477%2C3746012709%26fm%3D26%26gp%3D0.jpg',
  71. 'https://zhengda.oss-cn-chengdu.aliyuncs.com/chengluApp/img/%E4%B8%8B%E8%BD%BD.jpg',
  72. 'https://zhengda.oss-accelerate.aliyuncs.com/chengluApp/image_picker977203985037292577.jpg',
  73. 'https://zhengda.oss-accelerate.aliyuncs.com/chengluApp/image_picker977203985037292577.jpg'
  74. ]);
  75. $ins['type'] = 1;
  76. $ins['status'] = 1;
  77. $ins['site'] = json_encode(["city"=>"成都市","lat"=>"30.720653","lng"=>"103.899019"]);
  78. $ins['tag'] = rand(1,10);
  79. DynamicModel::query()->create($ins);
  80. }
  81. }
  82. public function test_push(){
  83. try {
  84. $res = JPushService::pushNotify([
  85. //标题
  86. 'title' => '测试',
  87. //内容
  88. 'content' => '测试',
  89. //设备标识,跟设备相关
  90. 'reg_id' => 'xxxxxxxxxxx',
  91. //扩展字段
  92. 'extras' => [
  93. 'key' => 'value',
  94. ],
  95. //推送类型
  96. 'type' => JPushService::PUSH_TYPE_ALL,
  97. ]);
  98. }catch (\Exception $exception){
  99. return response()->json(['msg'=>$exception->getMessage()]);
  100. }
  101. return response()->json(['data'=>$res]);
  102. }
  103. public function jg_auth(){
  104. // $tencent = new TencentImAccountService();
  105. // $arr = array();
  106. // for ($i=1;$i<100;$i++){
  107. // $ar = array();
  108. // $ar['UserID'] = 'IM_USER_TEST_'.$i;
  109. // $arr[]=json_encode($ar);
  110. // }
  111. // $res = $tencent->accountDelete($arr);
  112. // dd($res);
  113. $tencent = new TencentImFriendService();
  114. $res = $tencent->friendCheck('IM_USER_TEST_2_75',['IM_USER_TEST_2_80']);
  115. dd($res);
  116. dd(GetDistance(30.720518,103.998353,30.721384,103.996072));
  117. die;
  118. $token="asdasd";
  119. $exId="111111";
  120. $ret = JPushService::jgLoginTokenVerify($token,$exId);
  121. dd($ret);
  122. $res = JPushService::jgOpensslPrivateDecrypt($ret['phone']);
  123. }
  124. }