Ver Fonte

暂不区分客服

liugc há 9 meses atrás
pai
commit
f408b09c93

+ 8 - 1
app/adminapi/controller/notice/NoticeController.php

@@ -30,7 +30,7 @@ use app\common\service\wechat\WeChatOaService;
  */
 class NoticeController extends BaseAdminController
 {
-    public array $notNeedLogin = ['testNotice'];
+    public array $notNeedLogin = ['testNotice','assignBusinessToCustomer'];
     /**
      * @notes 查看通知设置列表
      * @return \think\response\Json
@@ -110,6 +110,13 @@ class NoticeController extends BaseAdminController
         $result = OnlineCustomerService::subOnlineCustomerService($params['admin_id']);
         return $this->success('', $result?:[]);
     }
+
+    // /notice.notice/assignBusinessToCustomer
+    public function assignBusinessToCustomer(){
+        $prams = $this->request->param();
+        return $this->success('', ['admin_id'=>OnlineCustomerService::assignBusinessToCustomer($prams['business_type'],$prams['business_id'])??0], 0, 1);
+    }
+
     public function getUnifiedNotific()
     {
         $params = $this->request->post();

+ 2 - 4
app/adminapi/logic/external/ExternalConsultationLogic.php

@@ -20,6 +20,7 @@ use app\common\model\external\ExternalConsultation;
 use app\common\logic\BaseLogic;
 use app\common\model\external\ExternalConsultationFollowLog;
 use app\common\model\external\ExternalConsultationOrder;
+use app\common\service\OnlineCustomerService;
 use think\facade\Cache;
 use think\facade\Db;
 
@@ -201,10 +202,7 @@ class ExternalConsultationLogic extends BaseLogic
     }
     public static function delCache($id)
     {
-        $consultation_notific_arr = Cache::store('common_redis')->get('consultation_notific');
-        unset($consultation_notific_arr[$id]);
-        Cache::store('common_redis')->set('consultation_notific',$consultation_notific_arr);
-        return true;
+        return OnlineCustomerService::customerClsMessage('consultation',$id);
     }
     public static function selectCache()
     {

+ 5 - 1
app/adminapi/logic/works/ServiceWorkLogic.php

@@ -26,6 +26,7 @@ use app\common\logic\WorkerAccountLogLogic;
 use app\common\model\external\ExternalPlatformOrders;
 use app\common\model\third\ThirdOrders;
 use app\common\model\works\ServiceWorkDeterminedPrice;
+use app\common\service\OnlineCustomerService;
 use app\workerapi\logic\MasterWorkerLogic;
 use think\Exception;
 use think\db\Query;
@@ -563,6 +564,8 @@ class ServiceWorkLogic extends BaseLogic
             ServiceWorkerAllocateWorkerLogic::add($work_log);
             Db::commit();
 
+            $work->id && OnlineCustomerService::customerClsMessage('servicework',$work->id);
+
             // 外部平台工单 - 通知外边平台
             if($work->external_platform_id > 0){
                 ExternalPlatformLogic::generalServiceWork('1003',['work_id' => $work->id]);
@@ -1171,7 +1174,7 @@ class ServiceWorkLogic extends BaseLogic
             if($serviceWork->isEmpty()){
                 throw new \Exception('工单不存在');
             }
-            ServiceWorkCustomerLog::create([
+             $res = ServiceWorkCustomerLog::create([
                 'work_id'=>$serviceWork->id,
                 'type'=>$params['type']??0,
                 'content'=>$params['content']??'',
@@ -1179,6 +1182,7 @@ class ServiceWorkLogic extends BaseLogic
                 'create_time'=>time(),
             ]);
             Db::commit();
+            $res && OnlineCustomerService::customerClsMessage('servicework',$serviceWork->id);
             return true;
         } catch (\Exception $e) {
             Db::rollback();

+ 8 - 6
app/common/service/OnlineCustomerService.php

@@ -100,8 +100,10 @@ class OnlineCustomerService
     }
     public static function customerClsMessage($business_type,$business_id){
         $notificList = Cache::store('common_redis')->get($business_type.'_notific');
-        unset($notificList[$business_id]);
-        Cache::store('common_redis')->set($business_type.'_notific',$notificList);
+        if(isset($notificList[$business_id])){
+            unset($notificList[$business_id]);
+            Cache::store('common_redis')->set($business_type.'_notific',$notificList);
+        }
         return true;
     }
 
@@ -118,8 +120,10 @@ class OnlineCustomerService
 
         $count = 0;
         if (!empty($notificList)) {
-            $counts = array_count_values($notificList);
-            $count = $counts[$admin_id] ?? 0;
+            // TODO 测试 tmp 暂不区分客服
+            $count = count($notificList);
+            /*$counts = array_count_values($notificList);
+            $count = $counts[$admin_id] ?? 0;*/
         }
         $to_router = $notificationTitle =  '';
         if(isset(self::$business_types[$business_type]) && self::$business_types[$business_type]){
@@ -130,8 +134,6 @@ class OnlineCustomerService
     }
 
     public static function getAllNotificList($admin_id,$business_codes = [],$prefix = '',$is_test = 0){
-        // TODO 测试 tmp
-        $admin_id = 1;
         if($is_test){
             return [
                 ['type'=>'consultation','mp3_url'=>'','unique_code'=> md5('consultation'.time()),'to_router'=>'/works/external_consultation','notificationTitle' => '客咨消息','notific_count' => 5],