lip 3 月之前
父节点
当前提交
fc406f666c
共有 3 个文件被更改,包括 14 次插入7 次删除
  1. 1 1
      app/admin/model/Config.php
  2. 12 5
      app/enterprise/controller/Im.php
  3. 1 1
      app/manage/model/Config.php

+ 1 - 1
app/admin/model/Config.php

@@ -53,7 +53,7 @@ class Config extends BaseModel
         if (!empty($config['type']) && $config['type'] == 'rich_text') {
         if (!empty($config['type']) && $config['type'] == 'rich_text') {
             return $config['val'] ? json_decode($config['val'], true) : '';
             return $config['val'] ? json_decode($config['val'], true) : '';
         }
         }
-        return '';
+        return $config['val'];
     }
     }
 
 
     //获取配置数据
     //获取配置数据

+ 12 - 5
app/enterprise/controller/Im.php

@@ -41,11 +41,18 @@ class Im extends BaseController
         }
         }
         $exist = Message::where('msg_id', $msg_id)->where('to_user', $user_id)->find();
         $exist = Message::where('msg_id', $msg_id)->where('to_user', $user_id)->find();
         if ($exist && $exist['is_click'] == 0) {
         if ($exist && $exist['is_click'] == 0) {
-            Score::create([
-                'user_id' => $user_id,
-                'cs_uid' => $user->cs_uid,
-                'score' => (int)$score,
-            ]);
+            $extends = $exist['extends'] ? json_decode($exist['extends'], true) : [];
+            if (!empty($extends['cs_uid'])) {
+                Score::create([
+                    'user_id' => $user_id,
+                    'cs_uid' => $extends['cs_uid'],
+                    'score' => (int)$score,
+                ]);
+                //保留一位小数
+                $avg_score = Score::where('cs_uid', $extends['cs_uid'])->avg('score');
+                $avg_score = number_format($avg_score, 1);
+                User::where('user_id', $extends['cs_uid'])->update(['score' => $avg_score]);
+            }
             $exist->is_click = 1;
             $exist->is_click = 1;
             $exist->save();
             $exist->save();
         }
         }

+ 1 - 1
app/manage/model/Config.php

@@ -66,6 +66,6 @@ class Config extends BaseModel
         if (!empty($config['type']) && $config['type'] == 'rich_text') {
         if (!empty($config['type']) && $config['type'] == 'rich_text') {
             return $config['val'] ? json_decode($config['val'], true) : '';
             return $config['val'] ? json_decode($config['val'], true) : '';
         }
         }
-        return '';
+        return $config['val'];
     }
     }
 }
 }