Notive.php 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. namespace App\Http\Controllers\Gnight;
  3. use App\Http\Controllers\Controller;
  4. use App\Http\Controllers\Miniprogram\Core;
  5. use App\Models\Gnight\UserModel;
  6. class Notive extends Controller
  7. {
  8. /**
  9. * 获得新的语音通知
  10. * @param int $uid
  11. * @return bool
  12. * @throws \Exception
  13. */
  14. public function getVoice(int $uid)
  15. {
  16. $public_id = config('miniprogram.public_id');
  17. $template_id = '6LemoOMIGrgzoqqFF6HLAqUSE6bHRSoGWVODfvPR9UQ';
  18. $page = "pages/starter/starter?launch_type=postman";
  19. $datas = array(
  20. 'keyword1' => array(
  21. 'value' => "解锁一条新语音"
  22. ),
  23. 'keyword2' => array(
  24. 'value' => '又有一个好友帮你解锁了!-若不想接收此消息,可在“我-通知开关”中关闭'
  25. ),
  26. 'keyword3' => array(
  27. 'value' => date('Y-m-d H:i:m')
  28. )
  29. );
  30. $emphasis_keyword = "keyword1.DATA";
  31. $core = new Core();
  32. return $core->template($uid, $template_id, $public_id, $page, $datas, $emphasis_keyword);
  33. }
  34. /**
  35. * 成功解锁通知
  36. * @param int $uid
  37. * @return bool
  38. * @throws \Exception
  39. */
  40. public function lock(int $uid)
  41. {
  42. $user = UserModel::find($uid);
  43. $public_id = config('miniprogram.public_id');
  44. // $template_id = 'm9Qv4FMHxsDx-J7dEMd9Sgn6ddx1LJRfNnJ2C3WBFIo';
  45. $template_id = 'vdZmmmUmHMyFLjV3CTvRANavzruks5fm5ixYegRfZ1U';
  46. $page = "pages/starter/starter?launch_type=postman";
  47. $datas = array(
  48. 'keyword1' => array(
  49. 'value' => "邀好友,解锁声音背后的TA"
  50. ),
  51. 'keyword2' => array(
  52. 'value' => date('Y-m-d H:i:m')
  53. ),
  54. 'keyword3' => array(
  55. 'value' => "亲爱的{$user->nickname}, 你已成功获得三位好友助力,点击查看声音背后的TA吧!"
  56. )
  57. );
  58. $core = new Core();
  59. return $core->template($user->uid, $template_id, $public_id, $page, $datas);
  60. }
  61. /**
  62. * 成功解锁通知
  63. * @param int $uid
  64. * @return bool
  65. * @throws \Exception
  66. */
  67. public function tmp(int $uid)
  68. {
  69. $user = UserModel::find($uid);
  70. $public_id = config('miniprogram.public_id');
  71. $template_id = 'IBtFcUbtcpyP6dQg66FlhQ2IB0DgaKpisS9ZOIpjSaI';
  72. if (isset($user->like) && in_array($user->like, [1, 2])) {
  73. $g = new \App\Models\Gnight\GetVoiceModel();
  74. $v = $g->pop($uid);
  75. $page = "pages/starter/starter?scene=voice_id%3d{$v}";
  76. } else {
  77. $page = "pages/starter/starter?launch_type=postman";
  78. }
  79. $datas = array(
  80. 'keyword1' => array(
  81. 'value' => "七夕告白语音"
  82. ),
  83. 'keyword2' => array(
  84. 'value' => "叮-你收到一条『七夕告白语音』请查收~"
  85. )
  86. );
  87. $emphasis_keyword = "keyword1.DATA";
  88. $core = new Core();
  89. return $core->template($user->uid, $template_id, $public_id, $page, $datas, $emphasis_keyword);
  90. }
  91. }