Selaa lähdekoodia

没设置打招呼的女性,给她四个固定的

lizhen_gitee 13 tuntia sitten
vanhempi
commit
7b34103a27
2 muutettua tiedostoa jossa 67 lisäystä ja 1 poistoa
  1. 33 1
      application/api/controller/Greet.php
  2. 34 0
      application/api/controller/Usercenter.php

+ 33 - 1
application/api/controller/Greet.php

@@ -32,7 +32,8 @@ class Greet extends Api
             $where['user_id'] = $this->auth->id;
             $greet = Db::name('user_greet_content')->where($where)->orderRaw('rand()')->find();
             if(empty($greet)){
-                $this->error('先设置打招呼内容吧');
+                $this->add_girl_greet($this->auth->id);
+                $greet = Db::name('user_greet_content')->where($where)->orderRaw('rand()')->find();
             }
             if(!empty($greet) && $greet['type'] != 0){
                 $greet['content'] = one_domain_image($greet['content']);
@@ -74,6 +75,37 @@ class Greet extends Api
         $this->success('操作成功', $rs);
     }
 
+    private function add_girl_greet($user_id){
+        $girl_greet = [
+            [
+                'user_id' => $user_id,
+                'title'   => '默认',
+                'content' => '你好,想认识你,可以聊聊吗?',
+                'is_default' => 1,
+                'createtime' => time(),
+            ],
+            [
+                'user_id' => $user_id,
+                'title'   => '默认',
+                'content' => '听说主动打招呼的人运气都不会太差,所以我来试试!',
+                'createtime' => time(),
+            ],
+            [
+                'user_id' => $user_id,
+                'title'   => '默认',
+                'content' => '嗨!看到你的资料觉得挺有意思的,认识一下?',
+                'createtime' => time(),
+            ],
+            [
+                'user_id' => $user_id,
+                'title'   => '默认',
+                'content' => '我猜你收到很多消息,但我的这条一定最特别!',
+                'createtime' => time(),
+            ],
+        ];
+        Db::name('user_greet_content')->insertAll($girl_greet);
+    }
+
     //查询每天弹出搭讪框次数
     public function freegreetnum() {
         $user = $this->auth->getUser();

+ 34 - 0
application/api/controller/Usercenter.php

@@ -1112,6 +1112,10 @@ $resArray['money'] = $money;  //返回给前端的计算结果
             $mt_user_greet_content = Db::name('user_greet_content');
             foreach ($lists as &$v) {
                 $info = $mt_user_greet_content->where(['user_id' => $v['id'], 'is_default' => 1])->find();
+                if(!$info){
+                    $this->add_girl_greet($v['id']);
+                    $info = $mt_user_greet_content->where(['user_id' => $v['id'], 'is_default' => 1])->find();
+                }
                 if ($info) {
                     if ($info['type'] == 0) {
                         $v['greet_content'] = $info['content'];
@@ -1132,6 +1136,36 @@ $resArray['money'] = $money;  //返回给前端的计算结果
         $this->success('success',$return_data);
     }
 
+    private function add_girl_greet($user_id){
+        $girl_greet = [
+            [
+                'user_id' => $user_id,
+                'title'   => '默认',
+                'content' => '你好,想认识你,可以聊聊吗?',
+                'is_default' => 1,
+                'createtime' => time(),
+            ],
+            [
+                'user_id' => $user_id,
+                'title'   => '默认',
+                'content' => '听说主动打招呼的人运气都不会太差,所以我来试试!',
+                'createtime' => time(),
+            ],
+            [
+                'user_id' => $user_id,
+                'title'   => '默认',
+                'content' => '嗨!看到你的资料觉得挺有意思的,认识一下?',
+                'createtime' => time(),
+            ],
+            [
+                'user_id' => $user_id,
+                'title'   => '默认',
+                'content' => '我猜你收到很多消息,但我的这条一定最特别!',
+                'createtime' => time(),
+            ],
+        ];
+        Db::name('user_greet_content')->insertAll($girl_greet);
+    }
 
     //查询免费体验视频通话用户信息
     public function getfreevideouserinfo() {