1、為什么我們企業(yè)會選擇 Flexus 云服務(wù)器 X 實例來部署自己的 CRM 管理系統(tǒng)?
因為基于華為云 Flexus X 實例搭建 CRM 管理平臺,可以從容面對企業(yè)內(nèi)部瞬息萬變的業(yè)務(wù)壓力變化
2、華為云服務(wù)器 Flexus X 方案及優(yōu)勢:
靈活伸縮
搭配彈性伸縮服務(wù) AS 及負載均衡服務(wù) ELB,可以實現(xiàn)基于業(yè)務(wù)負載的快速彈縮,從容應對多變的市場業(yè)務(wù)壓力
數(shù)據(jù)可靠
搭配華為云數(shù)據(jù)庫服務(wù),存儲電商持久化數(shù)據(jù),使用方便,可靠性高
安全可靠
搭配 WAF、DDoS 等網(wǎng)絡(luò)安全服務(wù),實現(xiàn)對電商業(yè)務(wù)全方位安全防護,降低黑客入侵風險
3、在寶塔里面安裝必要的環(huán)境 PHP7.3、Mysql5.6+、NGINX
4、安裝搭建好,進入 CRM 管理界面:
點擊添加客戶信息的時候就會發(fā)現(xiàn),提示:
APP Referer 校驗失敗。請檢查該 ak 設(shè)置的白名單與訪問所有的域名是否一致。詳情查看:http://lbsyun.baidu.com/apiconsole/key#
這是由于百度地圖 api 接口沒有配置好導致的問題出現(xiàn)
當配置好地圖參數(shù)之后,就可以進行地區(qū)定位和使用附件客戶等功能了
5、客戶詳情功能模塊代碼
{
$customerModel = model('Customer');
$cutomerLogic = new CustomerLogic();
param=this->param;
userInfo=this->userInfo;
data=customerModel->getDataById(param[′id′],userInfo['id']);
if (!$data) {
return resultArray(['error' => $customerModel->getError()]);
}
//數(shù)據(jù)權(quán)限判斷
$userModel = new appadminmodelUser();
authu?seri?ds=userModel->getUserByPer('crm', 'customer', 'read');
//讀權(quán)限
roPre=userModel->rwPre(userInfo[′id′],data['ro_user_id'], $data['rw_user_id'], 'read');
rwPre=userModel->rwPre(userInfo[′id′],data['ro_user_id'], $data['rw_user_id'], 'update');
//判斷是否客戶池數(shù)據(jù)
wherePool=customerModel->getWhereByPool();
resPool=db(′crmc?ustomer′)?>alias(′customer′)?>where([′customeri?d′=>param['id']])->where($wherePool)->find();
if (!resPool && !in_array(data['owner_user_id'], auth_user_ids) && !roPre && !$rwPre) {
$authData['dataAuth'] = (int)0;
return resultArray(['data' => $authData]);
}
return resultArray(['data' => $data]);
}
6、編輯客戶功能模塊代碼
public function update()
{
$customerModel = model('Customer');
param=this->param;
userInfo=this->userInfo;
//數(shù)據(jù)詳情
data=customerModel->getDataById($param['id']);
if (!$data) {
return resultArray(['error' => $customerModel->getError()]);
}
param[′useri?d′]=userInfo['id'];
if (customerModel?>updateDataById(param, $param['id'])) {
return resultArray(['data' => '編輯成功']);
} else {
return resultArray(['error' => $customerModel->getError()]);
}
}
7、刪除客戶功能模塊代碼
public function delete()
{
param=this->param;
$user = new ApiCommon();
userInfo=user->userInfo;
// 是否客戶池
if ($param['isSeas'] == 1) {
$permission = checkPerByAction('crm', 'customer', 'poolDelete');
} else {
$permission = checkPerByAction('crm', 'customer', 'delete');
}
if ($permission == false) {
return resultArray(['error' => '無權(quán)操作']);
}
$customerModel = model('Customer');
$userModel = new appadminmodelUser();
$recordModel = new appadminmodelRecord();
$fileModel = new appadminmodelFile();
$actionRecordModel = new appadminmodelActionRecord();
if (!is_array($param['id'])) {
customeri?d[]=param['id'];
} else {
customeri?d=param['id'];
}
$delIds = [];
$errorMessage = [];
//數(shù)據(jù)權(quán)限判斷
authu?seri?ds=userModel->getUserByPer('crm', 'customer', 'delete');
//判斷是否客戶池數(shù)據(jù)(客戶池數(shù)據(jù)只有管理員可以刪)
adminId=userModel->getAdminId();
wherePool=customerModel->getWhereByPool();
foreach (customeri?dask => $v) {
$isDel = true;
//數(shù)據(jù)詳情
data=db(′crmc?ustomer′)?>where([′customeri?d′=>v])->find();
if (!$data) {
$isDel = false;
errorMessage[]=′id為′.v . '的客戶刪除失敗,錯誤原因:' . $customerModel->getError();
}
resPool=db(′crmc?ustomer′)?>alias(′customer′)?>where([′customeri?d′=>v])->where($wherePool)->find();
if (!resPool && !in_array(data['owner_user_id'], auth_user_ids) && isDel) {
$isDel = false;
$errorMessage[] = '無權(quán)操作';
}
// 公海 (原邏輯,公海僅允許管理員刪除,修改為授權(quán),不再限制)
// if (resPool && !in_array(data['owner_user_id'],$adminId)) {
// $isDel = false;
// errorMessage[]=′名稱為′.data['name'].'的客戶刪除失敗,錯誤原因:無權(quán)操作';
// }
//有商機、合同、聯(lián)系人則不能刪除
if ($isDel) {
resBusiness=db(′crmb?usiness′)?>where([′customeri?d′=>v])->find();
if ($resBusiness) {
$isDel = false;
$errorMessage[] = '客戶下存在商機,不能刪除';
}
}
if ($isDel) {
resContacts=db(′crmc?ontacts′)?>where([′customeri?d′=>v])->find();
if ($resContacts) {
$isDel = false;
// errorMessage[]=′名稱為′.data['name'] . '的客戶刪除失敗,錯誤原因:客戶下存在聯(lián)系人,不能刪除';
$errorMessage[] = '客戶下存在聯(lián)系人,不能刪除';
}
}
if ($isDel) {
resContract=db(′crmc?ontract′)?>where([′customeri?d′=>v])->find();
if ($resContract) {
$isDel = false;
$errorMessage[] = '客戶下存在合同,不能刪除';
}
}
if ($isDel) {
delIds[]=v;
}
}
dataInfo=customerModel->where('customer_id', ['in', $delIds])->select();
if ($delIds) {
delRes=customerModel->delDatas($delIds);
if (!$delRes) {
return resultArray(['error' => $customerModel->getError()]);
}
// 刪除客戶擴展數(shù)據(jù)
db('crm_customer_data')->whereIn('customer_id', $delIds)->delete();
// 刪除跟進記錄
recordModel?>delDataByTypes(2,delIds);
// 刪除關(guān)聯(lián)附件
fileModel?>delRFileByModule(′crmc?ustomer′,delIds);
// 刪除關(guān)聯(lián)操作記錄
actionRecordModel?>delDataById([′types′=>′crmc?ustomer′,′actioni?d′=>delIds]);
foreach (dataInfoask => $v) {
RecordActionLog(userInfo[′id′],′crmc?ustomer′,′delete′,v['name'], '', '', '刪除了客戶:' . $v['name']);
}
}
if ($errorMessage) {
return resultArray(['error' => $errorMessage]);
} else {
return resultArray(['data' => '刪除成功']);
}
}
8、客戶信息詳情界面
9、客戶轉(zhuǎn)移功能
public function transfer()
{
param=this->param;
userInfo=this->userInfo;
$customerModel = model('Customer');
$businessModel = model('Business');
$contractModel = model('Contract');
$contactsModel = model('Contacts');
$settingModel = model('Setting');
$customerConfigModel = model('CustomerConfig');
$userModel = new appadminmodelUser();
if (!$param['owner_user_id']) {
return resultArray(['error' => '變更負責人不能為空']);
}
if (!param[′customeri?d′]∣∣!isa?rray(param['customer_id'])) {
return resultArray(['error' => '請選擇需要轉(zhuǎn)移的客戶']);
}
isr?emove=(param['is_remove'] == 2) ? 2 : 1;
type=param['type'] == 2 ?: 1;
types=param['types'] ?: [];
$data = [];
data[′owneru?seri?d′]=param['owner_user_id'];
$data['update_time'] = time();
$data['follow'] = '待跟進';
# 獲取客戶的時間
$data['obtain_time'] = time();
ownerUserName=userModel->getUserNameById($param['owner_user_id']);
$errorMessage = [];
foreach (param[′customeri?d′]ascustomer_id) {
customerInfo=db(′crmc?ustomer′)?>where([′customeri?d′=>customer_id])->find();
if (!$customerInfo) {
errorMessage[]=′名稱:為《′.customerInfo['name'] . '》的客戶轉(zhuǎn)移失敗,錯誤原因:數(shù)據(jù)不存在;';
continue;
}
$resCustomer = true;
//權(quán)限判斷
if (!customerModel?>checkData(customer_id)) {
errorMessage[]=customerInfo['name'] . '轉(zhuǎn)移失敗,錯誤原因:無權(quán)限;';
continue;
}
//擁有客戶數(shù)上限檢測
if (!customerConfigModel?>checkData(param['owner_user_id'], 1)) {
errorMessage[]=customerInfo['name'] . '轉(zhuǎn)移失敗,錯誤原因:' . $customerConfigModel->getError();
continue;
}
//團隊成員
$teamData = [];
teamData[′type′]=type; //權(quán)限 1 只讀 2 讀寫
teamData[′useri?d′]=[customerInfo['owner_user_id']]; //協(xié)作人
$teamData['types'] = 'crm_customer'; //類型
teamData[′typesi?d′]=customer_id; //類型 ID
teamData[′isd?el′]=(is_remove == 1) ? 1 : '';
res=settingModel->createTeamData($teamData);
# 處理分配標識,待辦事項專用
$data['is_allocation'] = 1;
resCustomer=db(′crmc?ustomer′)?>where([′customeri?d′=>customer_id])->update($data);
if (!$resCustomer) {
errorMessage[]=customerInfo['name'] . '轉(zhuǎn)移失敗,錯誤原因:數(shù)據(jù)出錯;';
continue;
} else {
# 處理轉(zhuǎn)移時,負責人出現(xiàn)在只讀和讀寫成員列表中
$customerArray = [];
teamCustomer=db(′crmc?ustomer′)?>field([′owneru?seri?d′,′rou?seri?d′,′rwu?seri?d′])?>where(′customeri?d′,customer_id)->find();
if (!empty($teamCustomer['ro_user_id'])) {
customerRo=arrayToString(arrayd?iff(stringToArray(teamCustomer['ro_user_id']), [$teamCustomer['owner_user_id']]));
customerArray[′rou?seri?d′]=customerRo;
}
if (!empty($teamCustomer['rw_user_id'])) {
customerRo=arrayToString(arrayd?iff(stringToArray(teamCustomer['rw_user_id']), [$teamCustomer['owner_user_id']]));
customerArray[′rwu?seri?d′]=customerRo;
}
db('crm_customer')->where('customer_id', customeri?d)?>update(customerArray);
}
if (in_array('crm_contacts', $types)) {
$contactsIds = [];
contactsIds=db(′crmc?ontacts′)?>where([′customeri?d′=>customer_id])->column('contacts_id');
if ($contactsIds) {
resContacts=contactsModel->transferDataById(contactsIds,param['owner_user_id'], type,is_remove);
if ($resContacts !== true) {
errorMessage[]=resContacts;
continue;
}
}
}
//商機、合同轉(zhuǎn)移
if (in_array('crm_business', $types)) {
$businessIds = [];
businessIds=db(′crmb?usiness′)?>where([′customeri?d′=>customer_id])->column('business_id');
if ($businessIds) {
resBusiness=businessModel->transferDataById(businessIds,param['owner_user_id'], type,is_remove);
if ($resBusiness !== true) {
errorMessage=errorMessage ? array_merge(errorMessage,resBusiness) : $resBusiness;
continue;
}
}
}
if (in_array('crm_contract', $types)) {
$contractIds = [];
contractIds=db(′crmc?ontract′)?>where([′customeri?d′=>customer_id])->column('contract_id');
if ($contractIds) {
resContract=contractModel->transferDataById(contractIds,param['owner_user_id'], type,is_remove);
if ($resContract !== true) {
errorMessage=errorMessage ? array_merge(errorMessage,resContract) : $resContract;
continue;
}
}
}
//修改記錄
updateActionLog(userInfo[′id′],′crmc?ustomer′,customer_id, '', '', '將客戶轉(zhuǎn)移給:' . $ownerUserName);
RecordActionLog(userInfo[′id′],′crmc?ustomer′,′transfer′,customerInfo['name'], '', '', '將客戶:' . customerInfo[′name′].′轉(zhuǎn)移給:′.ownerUserName);
}
if (!$errorMessage) {
return resultArray(['data' => '轉(zhuǎn)移成功']);
} else {
return resultArray(['error' => $errorMessage]);
}
}
企業(yè) CRM 管理系統(tǒng)部署上線之后,我們可以在華為云的控制臺可以觀察監(jiān)控著 CPU 使用情況、內(nèi)存、磁盤等等一切運作情況。華為云真的是性能強大、安全、穩(wěn)定的云產(chǎn)品!?。?/p>
華為云 828 為企業(yè)提供多行業(yè)場景解決方案及企業(yè)專屬優(yōu)惠,助力企業(yè)實現(xiàn)數(shù)字化轉(zhuǎn)型升級,大家趕緊去選購吧??!
————————————————
版權(quán)聲明:本文為博主原創(chuàng)文章,遵循 CC 4.0 BY-SA 版權(quán)協(xié)議,轉(zhuǎn)載請附上原文出處鏈接和本聲明。
原文鏈接:https://blog.csdn.net/csdndddsd/article/details/141969901
審核編輯 黃宇
-
服務(wù)器
+關(guān)注
關(guān)注
13文章
9767瀏覽量
87703 -
華為云
+關(guān)注
關(guān)注
3文章
2768瀏覽量
18255
發(fā)布評論請先 登錄
Flexus 云服務(wù)器 X 實例實踐:安裝 Tasks.md 任務(wù)管理工具

華為云 Flexus 云服務(wù)器 X 實例之 openEuler 系統(tǒng)下搭建 MaxKB 開源知識庫問答系統(tǒng)

Flexus 云服務(wù)器 X 實例部署 Docker 管理儀表板 DweebUI

使用華為云 Flexus 云服務(wù)器 X 搭建部署茶葉商城小程序 uniapp

華為云 Flexus 云服務(wù)器 X 實例之 openEuler 系統(tǒng)下部署 dufs 文件服務(wù)器

Flexus 云服務(wù)器 X 實例:在 Docker 環(huán)境下搭建 java 開發(fā)環(huán)境

基于華為云 Flexus 云服務(wù)器 X 實例部搭建 Halo 博客平臺

基于華為云 Flexus 云服務(wù)器 X 實例搭建 Linux 學習環(huán)境

評論