Selaa lähdekoodia

pc端添加和编辑,影响im

lizhen_gitee 6 kuukautta sitten
vanhempi
commit
172b18015f
2 muutettua tiedostoa jossa 20 lisäystä ja 0 poistoa
  1. 5 0
      application/admin/controller/Company.php
  2. 15 0
      application/admin/model/Company.php

+ 5 - 0
application/admin/controller/Company.php

@@ -10,6 +10,7 @@ use think\exception\DbException;
 use think\exception\PDOException;
 use think\exception\ValidateException;
 use fast\Random;
+use app\common\library\Tenim;
 
 /**
  * 维保公司管理
@@ -77,6 +78,10 @@ class Company extends Backend
 
             //第一个管理员
             $company_id = $this->model->id;
+            //注册到im
+            //user_用户端小程序,master_师傅,kefu_客服
+            $tenim = new Tenim();
+            $rs = $tenim->register('kefu_'. $company_id, $params['companyname'], localpath_to_netpath($params['avatar']));
             //添加一个管理组
             $auth_group = ['company_id'=>$company_id,'pid'=>0,'name'=>'最高级管理','code'=>'super_admin','rules'=>'*','createtime'=>time(),'updatetime'=>time(),'status'=>'normal',];
             $group_id = Db::name('pc_auth_group')->insertGetId($auth_group);

+ 15 - 0
application/admin/model/Company.php

@@ -4,6 +4,7 @@ namespace app\admin\model;
 
 use think\Model;
 use traits\model\SoftDelete;
+use app\common\library\Tenim;
 
 class Company extends Model
 {
@@ -27,6 +28,20 @@ class Company extends Model
     protected $append = [
         'status_text'
     ];
+
+    protected static function init()
+    {
+        self::afterUpdate(function ($row) {
+            $changed = $row->getChangedData();
+
+            //如果有修改头像或昵称,同步到im
+            if (isset($changed['companyname']) || isset($changed['avatar'])) {
+                //user_用户端小程序,master_师傅,kefu_客服
+                $tenim = new Tenim();
+                $rs = $tenim->useredit('kefu_'. $row['id'], $row['companyname'], localpath_to_netpath($row['avatar']));
+            }
+        });
+    }