TestController.php 5.2 KB

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