Demo.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. use app\common\library\Transaction;
  5. use app\common\library\Easemob;
  6. /**
  7. * 示例接口
  8. */
  9. class Demo extends Api
  10. {
  11. //如果$noNeedLogin为空表示所有接口都需要登录才能请求
  12. //如果$noNeedRight为空表示所有接口都需要验证权限才能请求
  13. //如果接口已经设置无需登录,那也就无需鉴权了
  14. //
  15. // 无需登录的接口,*表示全部
  16. protected $noNeedLogin = ['*'];
  17. // 无需鉴权的接口,*表示全部
  18. protected $noNeedRight = ['test2'];
  19. /**
  20. * 测试方法
  21. *
  22. * @ApiTitle (测试名称)
  23. * @ApiSummary (测试描述信息)
  24. * @ApiMethod (POST)
  25. * @ApiRoute (/api/demo/test/id/{id}/name/{name})
  26. * @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
  27. * @ApiParams (name="id", type="integer", required=true, description="会员ID")
  28. * @ApiParams (name="name", type="string", required=true, description="用户名")
  29. * @ApiParams (name="data", type="object", sample="{'user_id':'int','user_name':'string','profile':{'email':'string','age':'integer'}}", description="扩展数据")
  30. * @ApiReturnParams (name="code", type="integer", required=true, sample="0")
  31. * @ApiReturnParams (name="msg", type="string", required=true, sample="返回成功")
  32. * @ApiReturnParams (name="data", type="object", sample="{'user_id':'int','user_name':'string','profile':{'email':'string','age':'integer'}}", description="扩展数据返回")
  33. * @ApiReturn ({
  34. 'code':'1',
  35. 'msg':'返回成功'
  36. })
  37. */
  38. public function test()
  39. {
  40. $easemob = new Easemob();
  41. //推送给某一个人
  42. //$easemob->push_text(1009,'测试标题','测试内容');
  43. //全量推送
  44. //$easemob->push_all('全量标题','全量内容');
  45. //header
  46. //Authorization:Bearer ${YourAppToken}
  47. }
  48. /**
  49. * 无需登录的接口
  50. *
  51. */
  52. public function test1()
  53. {
  54. $this->success('返回成功', ['action' => 'test1']);
  55. }
  56. /**
  57. * 需要登录的接口
  58. *
  59. */
  60. public function test2()
  61. {
  62. $this->success('返回成功', ['action' => 'test2']);
  63. }
  64. /**
  65. * 需要登录且需要验证有相应组的权限
  66. *
  67. */
  68. public function test3()
  69. {
  70. $this->success('返回成功', ['action' => 'test3']);
  71. }
  72. /**
  73. * 苹果token解密
  74. *
  75. * @param $token
  76. * @return array|bool|mixed|string
  77. */
  78. private function verifyAppleToken($token)
  79. {
  80. $arr = explode('.',$token);
  81. if(count($arr) != 3){
  82. return [];
  83. }
  84. $header = $arr[0];
  85. $header = base64_decode($header);
  86. $header = json_decode($header,true);
  87. if(empty($header)){
  88. return [];
  89. }
  90. if($header['alg'] != 'ES256'){
  91. return [];
  92. }
  93. $data = $arr[1];
  94. $data = base64_decode($data);
  95. $data = json_decode($data,true);
  96. if(empty($data)){
  97. return [];
  98. }
  99. $sign = $arr[2];
  100. if(empty($sign)){
  101. return [];
  102. }
  103. return $data;
  104. }
  105. /**
  106. * ios 事件通知
  107. * @return bool
  108. */
  109. public function auto_renewal_vip_notify()
  110. {
  111. //$this->notify_log_start('ios');
  112. // 通知事件
  113. // 订阅类型-入库 首次订阅 重新订阅 续费 套餐升级
  114. // 自动续费状态 自动订阅状态 1开启 2-关闭
  115. // 自动续费结果 0默认 1成功 2失败 3过期
  116. // 是否退款
  117. // 是否升级
  118. try {
  119. $raw = '{"signedPayload":"eyJhbGciOiJFUzI1NiIsIng1YyI6WyJNSUlFTURDQ0E3YWdBd0lCQWdJUWZUbGZkMGZOdkZXdnpDMVlJQU5zWGpBS0JnZ3Foa2pPUFFRREF6QjFNVVF3UWdZRFZRUURERHRCY0hCc1pTQlhiM0pzWkhkcFpHVWdSR1YyWld4dmNHVnlJRkpsYkdGMGFXOXVjeUJEWlhKMGFXWnBZMkYwYVc5dUlFRjF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dVdHOHh2TkJ0SjNrQTE1cUFZTGhqd0ViWHk5WU1rV2xsdyIsInN0YXR1cyI6MX0sInZlcnNpb24iOiIyLjAiLCJzaWduZWREYXRlIjoxNjk4NzE0NTAwOTY4fQ.aIKW1ji9jK-aUi3dHhZW8zchRYWckt4Xbvuj6Ajd4XZi7LIzRjYSXJgpVLhSLd7_NwVtU7qrM0C3Lq7fV9lMaw"}';
  120. $raw = json_decode($raw,true);
  121. $token = $raw['signedPayload'] ?? '';
  122. $data = $this->verifyAppleToken($token);
  123. dump($data);
  124. if (empty($data)) {
  125. //timbao add
  126. //记录苹果通知逻辑中的bug
  127. exit;
  128. }
  129. $transaction_info = $this->verifyAppleToken($data['data']['signedTransactionInfo']);
  130. dump($transaction_info);
  131. $rs = '默认';
  132. switch ($data['notificationType']) {
  133. case 'DID_RENEW': // 续订
  134. $rs = Transaction::autoRenew($transaction_info);
  135. break;
  136. case 'REFUND': // 退款
  137. $rs = Transaction::refund($transaction_info);
  138. break;
  139. case 'DID_CHANGE_RENEWAL_STATUS': // 连续续订状态 变更
  140. $rs = Transaction::changeRenewStatus($transaction_info, $data['subtype']);
  141. break;
  142. case 'EXPIRED': // 过期通知
  143. $rs = Transaction::updateExpiredTrans($transaction_info);
  144. break;
  145. case 'SUBSCRIBED': // 订阅通知
  146. $rs = Transaction::updateSubscribed($transaction_info, $data['subtype']);
  147. break;
  148. case 'DID_FAIL_TO_RENEW': // 续订失败
  149. $rs = Transaction::updateRenewFailTrans($transaction_info);
  150. break;
  151. case 'DID_CHANGE_RENEWAL_PREF': //升级 降级
  152. if ($data['subtype'] == 'UPGRADE') {
  153. $rs = Transaction::autoRenew($transaction_info, true);
  154. }
  155. break;
  156. }
  157. echo $rs;
  158. exit;
  159. }catch (Exception $e) {
  160. echo $e->getMessage();
  161. exit;
  162. }
  163. }
  164. }