IndexController.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. namespace app\controller;
  3. use app\model\saas\SaasChatStore;
  4. use app\model\saas\SaasUserOpen;
  5. use support\Request;
  6. use Webman\Push\Api;
  7. class IndexController
  8. {
  9. public function index(Request $request)
  10. {
  11. // $api = new Api('http://127.0.0.1:3232', config('plugin.webman.push.app.app_key'),config('plugin.webman.push.app.app_secret'));
  12. // $api->trigger("user-_000KmfiVkio30K9VxoeLUUY3_hngEWcgR7u","message",[
  13. // "type" => "text",
  14. // "time" => time() * 1000,
  15. // "msgId" => time(),
  16. // "content" => "哈稍等哈就说客家话",
  17. // "source" => 2,
  18. // "avatar" => "https://washmy.oss-cn-guangzhou.aliyuncs.com/storage/20260511/23627b2cb8f73a8a90b95c31d726e6ecad0cbb9a.png",
  19. // "poi_id" => "7644106137976965139",
  20. // "openid" => "_000KmfiVkio30K9VxoeLUUY3_hngEWcgR7u",
  21. // "service_id" => "105"
  22. // ]);
  23. // echo "asd";
  24. // $param = [
  25. // "events" => [
  26. // [
  27. // "channel" => "private-user-1",
  28. // "name" => "channel_added"
  29. // ]
  30. // ]
  31. // ];
  32. // $key = hash_hmac('sha256', json_encode($param), config('plugin.webman.push.app.app_secret'), false);
  33. // echo $key."\n";
  34. return view('index');
  35. }
  36. public function view(Request $request)
  37. {
  38. $data = (new SaasChatStore)->select();
  39. if ($data->isEmpty()) return json([]);
  40. foreach ($data as $key=>$val){
  41. $userOpen = (new SaasUserOpen)->where("openid",$val["openid"])->findOrEmpty();
  42. if (!$userOpen->isEmpty()){
  43. (new SaasChatStore)->where("id",$val["id"])->update(["nickname"=>$userOpen['nickname']]);
  44. echo $userOpen['nickname']."===更新成功==\n";
  45. }
  46. }
  47. return json([]);
  48. }
  49. public function json(Request $request)
  50. {
  51. return json(['code' => 0, 'msg' => 'ok']);
  52. }
  53. }