<noframes id="bhrfl"><address id="bhrfl"></address>

    <address id="bhrfl"></address>

    <noframes id="bhrfl"><address id="bhrfl"><th id="bhrfl"></th></address>

    <form id="bhrfl"><th id="bhrfl"><progress id="bhrfl"></progress></th></form>

    <em id="bhrfl"><span id="bhrfl"></span></em>

    全部
    常見問題
    產品動態
    精選推薦

    【pro3.0】企業微信同步客戶超時問題臨時解決方案

    管理 管理 編輯 刪除

    臨時解決方案,后期版本會重新優化。

    打開文件:app/services/work/WorkClientServices.php

    搜索并替換authGetExternalcontact方法的代碼

    public function authGetExternalcontact(int $page = 1, string $cursor = '')
        {
            /** @var WorkConfig $config */
            $config = app()->make(WorkConfig::class);
            $corpId = $config->corpId;
            if (!$corpId) {
                return true;
            }
            /** @var WorkMemberServices $memberService */
            $memberService = app()->make(WorkMemberServices::class);
            $menmberList = $memberService->getDataList(['corp_id' => $corpId], ['userid'], $page, 10);
            //沒有數據就返回成功
            if (!$menmberList) {
                return true;
            }
            if($page == 1 && empty($cursor)){
                \think\facade\Db::name('work_client')->where('id', "<>", 0)->delete();
                \think\facade\Db::name('work_client_follow')->where('id', "<>", 0)->delete();
                \think\facade\Db::name('work_client_follow_tags')->where('follow_id ', "<>", 0)->delete();
            }
            $tagRes = Work::getCorpTags();
            $tagMap = [];
            foreach ($tagRes["tag_group"]??[] as $tagGroupItem){
                foreach ($tagGroupItem["tag"]??[] as $tagItem){
                    $tagMap[$tagItem["id"]] = $tagItem +["group_id"=>$tagGroupItem["group_id"],"group_name"=>$tagGroupItem["group_name"]];
                }
            }
    
            $userids = array_column($menmberList, 'userid');
            $response = Work::getBatchClientList($userids, $cursor);
            $externalContactList = $response['external_contact_list'] ?? [];
            $external = [];
            $followUser = [];//內部人員跟蹤
            $externalUserids = [];//客戶信息
            $this->transaction(function () use ($externalContactList, $corpId, $externalUserids, $followUser, $external, $tagMap) {
                foreach ($externalContactList as $item) {
                    $externalContact = $item['external_contact'];
                    $unionid = $externalContact['unionid'] ?? '';
                    if (isset($externalContact['unionid'])) {
                        unset($externalContact['unionid']);
                    }
                    $corpName = $corpFullName = $position = '';
                    if (isset($externalContact['corp_name'])) {
                        $corpName = $externalContact['corp_name'];
                        unset($externalContact['corp_name']);
                    }
                    if (isset($externalContact['corp_full_name'])) {
                        $corpFullName = $externalContact['corp_full_name'];
                        unset($externalContact['corp_full_name']);
                    }
                    if (isset($externalContact['position'])) {
                        $position = $externalContact['position'];
                        unset($externalContact['position']);
                    }
    
                    $externalContact['position'] = $position;
                    unset($externalContact['external_profile']);
                    $externalContact['external_profile'] = json_encode($externalContact['external_profile'] ?? [],JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
    
                    $followUserData = [
                        'userid' => $item['follow_info']['userid'],
                        'remark' => $item['follow_info']['remark'] ?? '',
                        'description' => $item['follow_info']['description'] ?? '',
                        'createtime' => $item['follow_info']['createtime'] ?? '',
                        'remark_corp_name' => $item['follow_info']['remark_corp_name'] ?? '',
                        'remark_mobiles' => json_encode($item['follow_info']['remark_mobiles'] ?? ''),
                        'add_way' => $item['follow_info']['add_way'] ?? '',
                        'oper_userid' => $item['follow_info']['oper_userid'] ?? '',
                        'create_time' => time(),
                        'tags' => [],
                    ];
    
                    foreach ($item['follow_info']['tag_id']??[] as $tagId){
                        $tag = $tagMap[$tagId]??[];
                        $followUserData['tags'][] = [
                            'group_name' => $tag['group_name'] ?? '',
                            'tag_name' => $tag['name'] ?? '',
                            'type' => $tag['type'] ?? 1,
                            'tag_id' => $tag['id'],
                            'create_time' => time()
                        ];
                    }
    
                    $followUser[$externalContact['external_userid']] = $followUserData;
                    $externalUserids[] = $externalContact['external_userid'];
                    $externalUserid = $externalContact['external_userid'];
                    $externalContact['corp_id'] = $corpId;
                    $externalContact['unionid'] = $unionid;
                    $externalContact['corp_name'] = $corpName;
                    $externalContact['corp_full_name'] = $corpFullName;
                    if ($this->dao->count(['external_userid' => $externalUserid, 'corp_id' => $corpId])) {
                        unset($externalContact['external_userid']);
                        $this->dao->update(['external_userid' => $externalUserid], $externalContact);
                    } else {
                        $externalContact['create_time'] = time();
                        $externalContact['update_time'] = time();
                        $external[] = $externalContact;
                    }
                }
                if ($external) {
    
                    $this->dao->saveAll($external);
                }
                $clientList = $this->dao->getColumn([['external_userid', 'in', $externalUserids], ['corp_id', '=', $corpId]], 'id', 'external_userid');
                /** @var WorkClientFollowServices $followService */
                $followService = app()->make(WorkClientFollowServices::class);
                if ($followUser) {
                    /** @var WorkClientFollowTagsServices $tagService */
                    $tagService = app()->make(WorkClientFollowTagsServices::class);
                    foreach ($followUser as $userid => $items) {
                        if(!isset($clientList[$userid])){
                            continue;
                        }
                        $items['client_id'] = $clientList[$userid];
                        if (($id = $followService->value(['client_id' => $clientList[$userid], 'userid' => $items['userid']], 'id'))) {
                            $followService->update($id, [
                                'remark' => $items['remark'],
                                'description' => $items['description'],
                                'createtime' => $items['createtime'],
                                'remark_corp_name' => $items['remark_corp_name'],
                                'remark_mobiles' => $items['remark_mobiles'],
                                'add_way' => $items['add_way'],
                                'oper_userid' => $items['oper_userid'],
                            ]);
                        } else {
                            $res = $followService->save($items);
                            $id = $res->id;
                        }
                        if (!empty($items['tags'])) {
                            $tagService->delete(['follow_id' => $id]);
                            foreach ($items['tags'] as &$tag) {
                                $tag['follow_id'] = $id;
                            }
                            $tagService->saveAll($items['tags']);
                        }
                    }
                }
            });
    
            if (isset($response['next_cursor']) && $response['next_cursor']) {
                WorkClientJob::dispatchDo('authClient', [$page, $response['next_cursor'] ?? '']);
            } else if (empty($response['next_cursor'])) {
                WorkClientJob::dispatchDo('authClient', [$page + 1, '']);
            }
    
            return true;
        }


    請登錄后查看

    ''神算子 最后編輯于2024-07-15 18:36:27

    快捷回復
    回復
    回復
    回復({{post_count}}) {{!is_user ? '我的回復' :'全部回復'}}
    排序 默認正序 回復倒序 點贊倒序

    {{item.user_info.nickname ? item.user_info.nickname : item.user_name}} LV.{{ item.user_info.bbs_level }}

    作者 管理員 企業

    {{item.floor}}# 同步到gitee 已同步到gitee {{item.is_suggest == 1? '取消推薦': '推薦'}}
    {{item.is_suggest == 1? '取消推薦': '推薦'}}
    沙發 板凳 地板 {{item.floor}}#
    {{item.user_info.title || '暫無簡介'}}
    附件

    {{itemf.name}}

    {{item.created_at}}  {{item.ip_address}}
    打賞
    已打賞¥{{item.reward_price}}
    {{item.like_count}}
    {{item.showReply ? '取消回復' : '回復'}}
    刪除
    回復
    回復

    {{itemc.user_info.nickname}}

    {{itemc.user_name}}

    回復 {{itemc.comment_user_info.nickname}}

    附件

    {{itemf.name}}

    {{itemc.created_at}}
    打賞
    已打賞¥{{itemc.reward_price}}
    {{itemc.like_count}}
    {{itemc.showReply ? '取消回復' : '回復'}}
    刪除
    回復
    回復
    查看更多
    打賞
    已打賞¥{{reward_price}}
    2115
    {{like_count}}
    {{collect_count}}
    添加回復 ({{post_count}})

    相關推薦

    快速安全登錄

    使用微信掃碼登錄
    {{item.label}} 加精
    {{item.label}} {{item.label}} 板塊推薦 常見問題 產品動態 精選推薦 首頁頭條 首頁動態 首頁推薦
    取 消 確 定
    回復
    回復
    問題:
    問題自動獲取的帖子內容,不準確時需要手動修改. [獲取答案]
    答案:
    提交
    bug 需求 取 消 確 定
    打賞金額
    當前余額:¥{{rewardUserInfo.reward_price}}
    {{item.price}}元
    請輸入 0.1-{{reward_max_price}} 范圍內的數值
    打賞成功
    ¥{{price}}
    完成 確認打賞

    微信登錄/注冊

    切換手機號登錄

    {{ bind_phone ? '綁定手機' : '手機登錄'}}

    {{codeText}}
    切換微信登錄/注冊
    暫不綁定
    亚洲欧美字幕
    CRMEB客服

    CRMEB咨詢熱線 咨詢熱線

    400-8888-794

    微信掃碼咨詢

    CRMEB開源商城下載 源碼下載 CRMEB幫助文檔 幫助文檔
    返回頂部 返回頂部
    CRMEB客服