TestController.php 5.5 KB

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