Browse Source

//非首次注册男性用户每次打开app,系统自动推送女性(公会)打招呼消息3人次,登录触发

lizhen_gitee 2 years ago
parent
commit
f38b6b1ff5
2 changed files with 38 additions and 0 deletions
  1. 1 0
      application/api/controller/Baseconfig.php
  2. 37 0
      application/api/controller/User.php

+ 1 - 0
application/api/controller/Baseconfig.php

@@ -32,6 +32,7 @@ class Baseconfig extends Api
     //启动广告图
     public function start_advert(){
 
+        //非首次注册男性用户每次打开app,系统自动推送女性(公会)打招呼消息3人次
         if($this->auth->isLogin()){
             if($this->auth->gender == 1 && $this->auth->gh_id == 0){
                 $this->firstopen_send($this->auth->id);

+ 37 - 0
application/api/controller/User.php

@@ -66,6 +66,28 @@ class User extends Api
         }
     }
 
+    //非首次注册男性用户每次打开app,系统自动推送女性(公会)打招呼消息3人次。
+    private function firstopen_send($oneuser){
+        //找出公会的人
+        $map = [
+            'gh_id'  => ['gt',0],
+        ];
+        $ghuser = Db::name('user')->where($map)->orderRaw('rand()')->limit(3)->column('id');
+        //dump($ghuser);
+
+        //随机取出一句话
+        $oneword = Db::name('plantask_accost')->orderRaw('rand()')->limit(3)->column('title');
+        //dump($oneword);
+
+        $tenim = new \app\common\library\Tenim;
+
+        for($i = 0;$i < 3;$i++){
+            $ghuser_one  = isset($ghuser[$i])  ? $ghuser[$i]  : $ghuser[array_rand($ghuser)];
+            $oneword_one = isset($oneword[$i]) ? $oneword[$i] : $oneword[array_rand($oneword)];
+            $tenim->sendMessageToUser($ghuser_one,$oneuser,$oneword_one);
+        }
+    }
+
     /**
      * 手机验证码登录
      *
@@ -98,6 +120,11 @@ class User extends Api
             }
             //如果已经有账号则直接登录
             $ret = $this->auth->direct($user->id);
+
+            //非首次注册男性用户每次打开app,系统自动推送女性(公会)打招呼消息3人次
+            if($user->gender == 1 && $user->gh_id == 0){
+                $this->firstopen_send($user->id);
+            }
         } else {
             $extend = [
                 'register_from' => input('register_from',''),
@@ -176,6 +203,11 @@ class User extends Api
             }
             //如果已经有账号则直接登录
             $ret = $this->auth->direct($user->id);
+
+            //非首次注册男性用户每次打开app,系统自动推送女性(公会)打招呼消息3人次
+            if($user->gender == 1 && $user->gh_id == 0){
+                $this->firstopen_send($user->id);
+            }
         } else {
             if (!$nickname || !$avatar) {
                 $this->error(__('Invalid parameters'));
@@ -249,6 +281,11 @@ class User extends Api
                     //如果已经有账号则直接登录
                     $ret = $this->auth->direct($user->id);
                     $is_register = 0;
+
+                    //非首次注册男性用户每次打开app,系统自动推送女性(公会)打招呼消息3人次
+                    if($user->gender == 1 && $user->gh_id == 0){
+                        $this->firstopen_send($user->id);
+                    }
                 } else {
                     $extend = [
                         'register_from' => input('register_from',''),