wupengfei 2 سال پیش
والد
کامیت
6604b5b587
4فایلهای تغییر یافته به همراه75 افزوده شده و 54 حذف شده
  1. 3 1
      .idea/workspace.xml
  2. 6 2
      application/api/common.php
  3. 61 0
      application/api/controller/Expedite.php
  4. 5 51
      application/common/model/UserMessage.php

+ 3 - 1
.idea/workspace.xml

@@ -4,6 +4,8 @@
     <list default="true" id="1a36929e-c054-4875-a943-593a74e55fa4" name="Default Changelist" comment="">
       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/application/api/common.php" beforeDir="false" afterPath="$PROJECT_DIR$/application/api/common.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/application/api/controller/Expedite.php" beforeDir="false" afterPath="$PROJECT_DIR$/application/api/controller/Expedite.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/application/common/model/UserMessage.php" beforeDir="false" afterPath="$PROJECT_DIR$/application/common/model/UserMessage.php" afterDir="false" />
     </list>
     <option name="SHOW_DIALOG" value="false" />
     <option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -200,7 +202,7 @@
       <workItem from="1670287594399" duration="11535000" />
       <workItem from="1670461023846" duration="27678000" />
       <workItem from="1670547445908" duration="12147000" />
-      <workItem from="1670633686675" duration="10067000" />
+      <workItem from="1670633686675" duration="11233000" />
     </task>
     <servers />
   </component>

+ 6 - 2
application/api/common.php

@@ -5,7 +5,7 @@ use think\Db;
 use JPush\Client;
 require_once env('root_path').'vendor/jpush/jpush/autoload.php';
 
-function Jpush($user_id = 0,$alert = '',$module='video',$type='1'){
+function Jpush($user_id = 0,$alert = '',$module='',$type='',$rel_id=''){
     $appKey = '02a7faefd91c8a6a446a6a14';
     $masterSecret = 'ba2e100db997024d9b6e5d35';
     $client = new Client($appKey, $masterSecret,null);
@@ -18,7 +18,10 @@ function Jpush($user_id = 0,$alert = '',$module='video',$type='1'){
             'mutable-content' => true,
             'category' => 'jiguang',
             'extras' => array(
-                'key' => 'value'
+                'key' => 'value',
+                'module' => $module,
+                'type' => $type,
+                'rel_id' => $rel_id,
             ),
         ))->androidNotification($alert, array(
             'title' => '消息通知',
@@ -26,6 +29,7 @@ function Jpush($user_id = 0,$alert = '',$module='video',$type='1'){
             'extras' => array(
                 'module' => $module,
                 'type' => $type,
+                'rel_id' => $rel_id,
             ),
         ))->options(array(
             'apns_production' => true,// false 开发环境 ,true 生产环境

+ 61 - 0
application/api/controller/Expedite.php

@@ -724,5 +724,66 @@ class Expedite extends Base
        $this->success('ok',['url'=>$url_arr[$tag]]);
     }
 
+    /**
+     * @title 获取极光推送类型
+     * @desc  获取极光推送类型
+     * @author  qc
+     * @url /api/Expedite/getJiGuangPushType
+     * @method GET
+     * @return name:is_push type:string default:-- desc:模块类型下的消息是否有极光推送(1推送0不推送)
+     */
+    public function getJiGuangPushType()
+    {
+        $type_desc = [
+            'video'=>[
+                1=>['title'=>'视频投稿','is_push'=>0,'msg'=>['视频投稿成功请等待审核']],
+                2=>['title'=>'视频审核','is_push'=>0,'msg'=>['恭喜您视频审核成功','抱歉啦视频审核失败~~']],
+                3=>['title'=>'视频评论回复','is_push'=>1,'msg'=>['有会员评论了您的回复']],
+                4=>['title'=>'视频评论','is_push'=>1,'msg'=>['有会员评论了您的视频']],
+            ],// 视频
+            'article'=>[
+                1=>['title'=>'图文投稿','is_push'=>0,'msg'=>['图文投稿成功请等待审核']],
+                2=>['title'=>'图文审核','is_push'=>0,'msg'=>['恭喜您图文审核成功','抱歉啦图文审核失败~~']],
+                3=>['title'=>'图文评论回复','is_push'=>1,'msg'=>['有会员评论了您的回复']],
+                4=>['title'=>'图文评论','is_push'=>1,'msg'=>['有会员评论了您的图文']],
+            ],//图文
+            'datum'=>[
+                1=>['title'=>'资料投稿','is_push'=>0,'msg'=>['资料投稿成功请等待审核']],
+                2=>['title'=>'资料审核','is_push'=>0,'msg'=>['恭喜您资料审核成功','抱歉啦资料审核失败~~']],
+                3=>['title'=>'资料评论回复','is_push'=>0,'msg'=>['有会员评论了您的回复']],
+            ],// 资料
+            'activity'=>[
+                1=>['title'=>'活动报名','is_push'=>0,'msg'=>['恭喜您活动报名成功']],
+            ],// 活动
+            'demand'=>[
+                1=>['title'=>'需求投稿','is_push'=>0,'msg'=>['需求投稿成功请等待审核']],
+                2=>['title'=>'需求审核','is_push'=>0,'msg'=>['恭喜您需求审核成功','抱歉啦需求审核失败~~']],
+                3=>['title'=>'需求评论回复','is_push'=>0,'msg'=>['有会员评论了您的回复']],
+                4=>['title'=>'需求评论','is_push'=>0,'msg'=>['有会员评论了您的需求']],
+            ],// 需求
+            'forum'=>[
+                1=>['title'=>'问答投稿','is_push'=>0,'msg'=>['问答投稿成功']],
+                2=>['title'=>'问答审核','is_push'=>0,'msg'=>['恭喜您问答审核成功','抱歉啦问答审核失败']],
+                3=>['title'=>'回复的评论','is_push'=>1,'msg'=>['有会员评论了您的回复']],
+                4=>['title'=>'评论的回复','is_push'=>1,'msg'=>['有会员回复了您的评论']],
+                5=>['title'=>'问答回复','is_push'=>1,'msg'=>['有会员回复了您的问题']],
+            ],// 问答
+            'press'=>[
+                1=>['title'=>'评论回复','is_push'=>1,'msg'=>['有会员回复了您的评论']],
+            ],// 新闻
+            'mall'=>[
+
+            ],// 商城
+            'feedback'=>[
+                1=>['title'=>'反馈内容回复','is_push'=>1,'msg'=>['平台回复了您的反馈']],
+            ],// 反馈
+            'user' =>[
+                1=>['title'=>'反馈内容回复','is_push'=>0,'msg'=>['平台回复了您的反馈']],
+            ],// 会员管理
+        ];
+        $this->success('ok',$type_desc);
+    }
+
+
 
 }

+ 5 - 51
application/common/model/UserMessage.php

@@ -79,71 +79,25 @@ class UserMessage extends Model
         $from_name = User::where('id',$from_user)->value('name');
         switch ($module) {
             case 'video':
-                if(in_array($type,[3,4]))Jpush($to_user,$from_name.$message['content']);// $message['jg_type'] = 1;
+                if(in_array($type,[3,4]))Jpush($to_user,$from_name.$message['content'],$module,$type,$rel_id);// $message['jg_type'] = 1;
                 break;
             case 'article':
-                if(in_array($type,[3,4]))Jpush($to_user,$from_name.$message['content']);// $message['jg_type'] = 1;
+                if(in_array($type,[3,4]))Jpush($to_user,$from_name.$message['content'],$module,$type,$rel_id);// $message['jg_type'] = 1;
                 break;
             case 'press':
-                if(in_array($type,[1])) Jpush($to_user,$from_name.$message['content']);// $message['jg_type'] = 1;
+                if(in_array($type,[1])) Jpush($to_user,$from_name.$message['content'],$module,$type,$rel_id);// $message['jg_type'] = 1;
                 break;
             case 'forum':
                 $switch  = PlatformSwitch::userSwitch($to_user,$rel_id,1);
-                if($switch && in_array($type,[3,4,5]))Jpush($to_user,$from_name.$message['content']);// $message['jg_type'] = 1;
+                if($switch && in_array($type,[3,4,5]))Jpush($to_user,$from_name.$message['content'],$module,$type,$rel_id);// $message['jg_type'] = 1;
                 break;
             case 'feedback':
-                if(in_array($type,[1]))Jpush($to_user,$from_name.$message['content']);// $message['jg_type'] = 1;
-                break;
-            case 'user':
-                $message['jg_type'] = 1;
+                if(in_array($type,[1]))Jpush($to_user,$from_name.$message['content'],$module,$type,$rel_id);// $message['jg_type'] = 1;
                 break;
         }
         self::create($message);
         // 哪些模块中的某些类型需要极光推送
-
-    }
-    // 极光推送 【懒得往别的地方写了】。。。。
-    public static function Jpush($user_id = 0,$alert = ''){
-        if(empty($user_id)) return false;
-        var_dump($user_id,$alert);
-        $appKey = '02a7faefd91c8a6a446a6a14';
-        $masterSecret = 'ba2e100db997024d9b6e5d35';
-        $client = new Client($appKey, $masterSecret,null);
-        $push_payload = $client->push()
-            ->setPlatform(array('ios', 'android'))
-            ->addAlias(intval($user_id))
-            //->addRegistrationId($user_id)
-            //->addAllAudience()
-            ->iosNotification($alert, array(
-                'badge' => '+1',
-                'content-available' => true,
-                'mutable-content' => true,
-                'category' => 'jiguang',
-                'extras' => array(
-                    'key' => 'value',
-                    'jiguang'
-                ),
-            ))->androidNotification($alert, array(
-                'title' => '消息通知',
-                // 'builder_id' => 2,
-                'extras' => array(
-                    'key' => 'value',
-                    'jiguang'=>'',
-                ),
-            ))->options(array(
-                'apns_production' => True,
-            ));
-        try {
-            $response = $push_payload->send();
-          //  return $response;
-        } catch  (\JPush\Exceptions\APIConnectionException $e) {
-           // return $e;
-        } catch (\JPush\Exceptions\APIRequestException $e) {
-           // return $e;
-        }
     }
 
 
-
-
 }