LiuJ 4 달 전
부모
커밋
a4744a0856
6개의 변경된 파일225개의 추가작업 그리고 7개의 파일을 삭제
  1. 82 7
      app/JsonRpc/NewsService.php
  2. 28 0
      app/Model/GroupImp.php
  3. 28 0
      app/Model/GroupMemberImp.php
  4. 28 0
      app/Model/GroupTalkImp.php
  5. 28 0
      app/Model/GroupTalkMessagerImp.php
  6. 31 0
      config/autoload/databases.php

+ 82 - 7
app/JsonRpc/NewsService.php

@@ -74,6 +74,12 @@ use Hyperf\Amqp\Producer;
 use App\Amqp\Producer\MqProducer;
 use App\Model\Web;
 
+
+use App\Model\GroupMemberImp;
+use App\Model\GroupImp;
+use App\Model\GroupTalkImp;
+use App\Model\GroupTalkMessagerImp;
+
 #[RpcService(name: "NewsService", protocol: "jsonrpc-http", server: "jsonrpc-http")]
 class NewsService implements NewsServiceInterface
 {
@@ -815,6 +821,19 @@ class NewsService implements NewsServiceInterface
   public function upArticleStatus(array $data): array
   {
     $articleData = Article::where(['id' => $data['id']])->first();
+    //发送10次
+    for ($i = 0; $i < 10; $i++) {
+      $this->sendMessage([
+        'talk_type' => 100,
+        'title' => $i . $articleData['title'],
+        'content' => '审核通过',
+        'messageType' => 2,
+        'user_id' => $articleData['admin_user_id'],
+      ]);
+    }
+    var_dump($data['status'], 'status');
+    return Result::success();
+
     if ($data['status'] == 1) {
       $this->sendMessage([
         'talk_type' => 101,
@@ -4206,6 +4225,7 @@ class NewsService implements NewsServiceInterface
 
   public function getNoticeList(array $data): array
   {
+
     $where = [];
     //title
     if (isset($data['title']) && !empty($data['title'])) {
@@ -4743,8 +4763,11 @@ class NewsService implements NewsServiceInterface
     if (empty($notice)) {
       return Result::error("公告不存在", 0);
     }
+    //$chat_ids 去除掉$data['user_id']
+    $chat_ids = json_decode($notice['re_user_ids'], true);
+    $chat_ids = array_diff($chat_ids, [$notice['user_id']]);
     //如果公告的状态是2,且是群聊公告,且状态是1,则创建群聊,第一次审核通过的时候处理成群聊
-    if ($data['status'] == 2 && $notice['is_group'] == 1 && $notice['status'] == 1 && empty($notice['group_id'])) {
+    if ($data['status'] == 2 && $notice['is_group'] == 1 && ($notice['status'] == 1 || $notice['status'] == 3) && empty($notice['group_id'])) {
       //chat_group
       $group_id = PublicData::uuid();
       $groupData = [
@@ -4754,7 +4777,6 @@ class NewsService implements NewsServiceInterface
         'profile' => $notice['profile'] ?? 0,
       ];
       var_dump($groupData, '-----------------groupData-------');
-
       $groupResult = ChatGroups::insertGetId($groupData);
       var_dump($groupResult, '-----------------groupid-------');
       $groupMemberData = [
@@ -4764,9 +4786,7 @@ class NewsService implements NewsServiceInterface
         'leader' => 2,
       ];
       $groupMemberResult = ChatGroupsMember::insertGetId($groupMemberData);
-      //$chat_ids 去除掉$data['user_id']
-      $chat_ids = json_decode($notice['re_user_ids'], true);
-      $chat_ids = array_diff($chat_ids, [$notice['user_id']]);
+
       //插入群成员表
       $groupMemberDataUser = [];
       $chatData = [];
@@ -4801,11 +4821,67 @@ class NewsService implements NewsServiceInterface
       ];
       var_dump($chatData, '-----------------chatData-------');
       $chatResult = ChatRecords::insert($chatData);
-
+      //处理imp
+      $group = [
+        'type' => 1,
+        'name' => $notice['group_name'] ?? '',
+        'profile' => '',
+        'avatar' => '',
+        'creator_id' => $notice['user_id'],
+      ];
+      $groupResult = GroupImp::insertGetId($group);
+      var_dump($groupResult, '获取imp group_id');
+      $groupMember = [
+        'user_id' => $notice['user_id'],
+        'group_id' => $groupResult,
+        'leader' => 1,
+        'join_time' => Date('Y-m-d H:i:s')
+      ];
+      $groupMemberResult = GroupMemberImp::insertGetId($groupMember);
+      $talk_session = [
+        'user_id' => $notice['user_id'],
+        'to_from_id' => $groupResult,
+        'talk_mode' => 2,
+        'created_at' => Date('Y-m-d H:i:s'),
+        'updated_at' => Date('Y-m-d H:i:s'),
+      ];
+      $talk_session_result = GroupTalkImp::insertGetId($talk_session);
+      //被通知人员处理
+      foreach ($chat_ids as $key => $value) {
+        $groupMemberdata[] = [
+          'user_id' => $value,
+          'group_id' => $groupResult,
+          'leader' => 3,
+          'join_time' => Date('Y-m-d H:i:s')
+        ];
+        $talk_sessionData[] = [
+          'user_id' => $value,
+          'to_from_id' => $groupResult,
+          'talk_mode' => 2,
+          'created_at' => Date('Y-m-d H:i:s'),
+          'updated_at' => Date('Y-m-d H:i:s'),
+        ];
+      }
+      $groupResult1 = GroupMemberImp::insert($groupMemberdata);
+      $talk_sessionResult = GroupTalkImp::insert($talk_sessionData);
+      $group_id = $groupResult;
       //更新result的 group_id
       $data['group_id'] = $group_id;
       Notice::where(['id' => $data['id']])->update($data);
     }
+    if (($data['status'] == 1 || $data['status'] == 3) && $notice['is_group'] == 1 && $notice['status'] == 2 && !empty($notice['group_id'])) {
+      //删除掉信息
+      GroupImp::where('id', $notice['group_id'])->delete();
+      GroupMemberImp::where('group_id', $notice['group_id'])->delete();
+      GroupTalkImp::where('to_from_id', $notice['group_id'])->delete();
+      foreach ($chat_ids as $key => $value) {
+      }
+      //聊天记录删除
+
+      //如果是群聊公告,且已经有群聊id,则更新公告的group_id
+      $data['group_id'] = null;
+      Notice::where(['id' => $data['id']])->update($data);
+    }
     $result = Notice::where('id', $data['id'])->update($data);
     $noticeInfo = Notice::where('id', $data['id'])->first();
     if ($data['status'] == 2) {
@@ -4886,7 +4962,6 @@ class NewsService implements NewsServiceInterface
 
   //20250226  产品列表
 
-
   // 20250306 -------招聘--------fr
   /*
     * 招聘列表

+ 28 - 0
app/Model/GroupImp.php

@@ -0,0 +1,28 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Model;
+
+use Hyperf\DbConnection\Model\Model;
+
+/**
+ */
+class GroupImp extends Model
+{
+    /**
+     * The table associated with the model.
+     */
+    protected ?string $connection = 'imp';
+    protected ?string $table = 'group';
+
+    /**
+     * The attributes that are mass assignable.
+     */
+    protected array $fillable = [];
+
+    /**
+     * The attributes that should be cast to native types.
+     */
+    protected array $casts = [];
+}

+ 28 - 0
app/Model/GroupMemberImp.php

@@ -0,0 +1,28 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Model;
+
+use Hyperf\DbConnection\Model\Model;
+
+/**
+ */
+class GroupMemberImp extends Model
+{
+    /**
+     * The table associated with the model.
+     */
+    protected ?string $connection = 'imp';
+    protected ?string $table = 'group_member';
+
+    /**
+     * The attributes that are mass assignable.
+     */
+    protected array $fillable = [];
+
+    /**
+     * The attributes that should be cast to native types.
+     */
+    protected array $casts = [];
+}

+ 28 - 0
app/Model/GroupTalkImp.php

@@ -0,0 +1,28 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Model;
+
+use Hyperf\DbConnection\Model\Model;
+
+/**
+ */
+class GroupTalkImp extends Model
+{
+    /**
+     * The table associated with the model.
+     */
+    protected ?string $connection = 'imp';
+    protected ?string $table = 'talk_session';
+
+    /**
+     * The attributes that are mass assignable.
+     */
+    protected array $fillable = [];
+
+    /**
+     * The attributes that should be cast to native types.
+     */
+    protected array $casts = [];
+}

+ 28 - 0
app/Model/GroupTalkMessagerImp.php

@@ -0,0 +1,28 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Model;
+
+use Hyperf\DbConnection\Model\Model;
+
+/**
+ */
+class GroupTalkMessagerImp extends Model
+{
+    /**
+     * The table associated with the model.
+     */
+    protected ?string $connection = 'imp';
+    protected ?string $table = 'talk_group_message';
+
+    /**
+     * The attributes that are mass assignable.
+     */
+    protected array $fillable = [];
+
+    /**
+     * The attributes that should be cast to native types.
+     */
+    protected array $casts = [];
+}

+ 31 - 0
config/autoload/databases.php

@@ -9,6 +9,7 @@ declare(strict_types=1);
  * @contact  group@hyperf.io
  * @license  https://github.com/hyperf/hyperf/blob/master/LICENSE
  */
+
 use function Hyperf\Support\env;
 
 return [
@@ -41,4 +42,34 @@ return [
             ],
         ],
     ],
+    'imp' => [
+        'driver' => env('DB_DRIVER', 'mysql'),
+        'host' => env('DB_HOST', 'localhost'),
+        'database' => 'imp',
+        'port' => env('DB_PORT', 3306),
+        'username' => env('DB_USERNAME', 'root'),
+        'password' => env('DB_PASSWORD', ''),
+        'charset' => env('DB_CHARSET', 'utf8'),
+        'collation' => env('DB_COLLATION', 'utf8_unicode_ci'),
+        'prefix' => env('DB_PREFIX', ''),
+        'pool' => [
+            'min_connections' => 1,
+            'max_connections' => 10,
+            'connect_timeout' => 10.0,
+            'wait_timeout' => 3.0,
+            'heartbeat' => -1,
+            'max_idle_time' => (float) env('DB_MAX_IDLE_TIME', 60),
+        ],
+        'variables' => [
+            'time_zone' => '+08:00', // 设置MySQL连接的时区
+        ],
+        'commands' => [
+            'gen:model' => [
+                'path' => 'app/Model',
+                'force_casts' => true,
+                'inheritance' => 'Model',
+            ],
+        ],
+    ],
+
 ];