1、為什么我們企業會選擇 Flexus 云服務器 X 實例來部署自己的 CRM 管理系統?
因為基于華為云 Flexus X 實例搭建 CRM 管理平臺,可以從容面對企業內部瞬息萬變的業務壓力變化
2、華為云服務器 Flexus X 方案及優勢:
靈活伸縮
搭配彈性伸縮服務 AS 及負載均衡服務 ELB,可以實現基于業務負載的快速彈縮,從容應對多變的市場業務壓力
數據可靠
搭配華為云數據庫服務,存儲電商持久化數據,使用方便,可靠性高
安全可靠
搭配 WAF、DDoS 等網絡安全服務,實現對電商業務全方位安全防護,降低黑客入侵風險
3、在寶塔里面安裝必要的環境 PHP7.3、Mysql5.6+、NGINX
4、安裝搭建好,進入 CRM 管理界面:
點擊添加客戶信息的時候就會發現,提示:
APP Referer 校驗失敗。請檢查該 ak 設置的白名單與訪問所有的域名是否一致。詳情查看:http://lbsyun.baidu.com/apiconsole/key#
這是由于百度地圖 api 接口沒有配置好導致的問題出現
當配置好地圖參數之后,就可以進行地區定位和使用附件客戶等功能了
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()]);
}
//數據權限判斷
$userModel = new appadminmodelUser();
authu?seri?ds=userModel->getUserByPer('crm', 'customer', 'read');
//讀權限
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');
//判斷是否客戶池數據
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;
//數據詳情
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' => '無權操作']);
}
$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 = [];
//數據權限判斷
authu?seri?ds=userModel->getUserByPer('crm', 'customer', 'delete');
//判斷是否客戶池數據(客戶池數據只有管理員可以刪)
adminId=userModel->getAdminId();
wherePool=customerModel->getWhereByPool();
foreach (customeri?dask => $v) {
$isDel = true;
//數據詳情
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[] = '無權操作';
}
// 公海 (原邏輯,公海僅允許管理員刪除,修改為授權,不再限制)
// if (resPool && !in_array(data['owner_user_id'],$adminId)) {
// $isDel = false;
// errorMessage[]=′名稱為′.data['name'].'的客戶刪除失敗,錯誤原因:無權操作';
// }
//有商機、合同、聯系人則不能刪除
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'] . '的客戶刪除失敗,錯誤原因:客戶下存在聯系人,不能刪除';
$errorMessage[] = '客戶下存在聯系人,不能刪除';
}
}
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()]);
}
// 刪除客戶擴展數據
db('crm_customer_data')->whereIn('customer_id', $delIds)->delete();
// 刪除跟進記錄
recordModel?>delDataByTypes(2,delIds);
// 刪除關聯附件
fileModel?>delRFileByModule(′crmc?ustomer′,delIds);
// 刪除關聯操作記錄
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、客戶轉移功能
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' => '請選擇需要轉移的客戶']);
}
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'] . '》的客戶轉移失敗,錯誤原因:數據不存在;';
continue;
}
$resCustomer = true;
//權限判斷
if (!customerModel?>checkData(customer_id)) {
errorMessage[]=customerInfo['name'] . '轉移失敗,錯誤原因:無權限;';
continue;
}
//擁有客戶數上限檢測
if (!customerConfigModel?>checkData(param['owner_user_id'], 1)) {
errorMessage[]=customerInfo['name'] . '轉移失敗,錯誤原因:' . $customerConfigModel->getError();
continue;
}
//團隊成員
$teamData = [];
teamData[′type′]=type; //權限 1 只讀 2 讀寫
teamData[′useri?d′]=[customerInfo['owner_user_id']]; //協作人
$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'] . '轉移失敗,錯誤原因:數據出錯;';
continue;
} else {
# 處理轉移時,負責人出現在只讀和讀寫成員列表中
$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;
}
}
}
//商機、合同轉移
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, '', '', '將客戶轉移給:' . $ownerUserName);
RecordActionLog(userInfo[′id′],′crmc?ustomer′,′transfer′,customerInfo['name'], '', '', '將客戶:' . customerInfo[′name′].′轉移給:′.ownerUserName);
}
if (!$errorMessage) {
return resultArray(['data' => '轉移成功']);
} else {
return resultArray(['error' => $errorMessage]);
}
}
企業 CRM 管理系統部署上線之后,我們可以在華為云的控制臺可以觀察監控著 CPU 使用情況、內存、磁盤等等一切運作情況。華為云真的是性能強大、安全、穩定的云產品!!!
華為云 828 為企業提供多行業場景解決方案及企業專屬優惠,助力企業實現數字化轉型升級,大家趕緊去選購吧!!
————————————————
版權聲明:本文為博主原創文章,遵循 CC 4.0 BY-SA 版權協議,轉載請附上原文出處鏈接和本聲明。
原文鏈接:https://blog.csdn.net/csdndddsd/article/details/141969901
審核編輯 黃宇
-
服務器
+關注
關注
12文章
9307瀏覽量
86071 -
華為云
+關注
關注
3文章
2689瀏覽量
17588
發布評論請先 登錄
相關推薦
華為云 Flexus 云服務器 X 實例之 openEuler 系統下搭建 MaxKB 開源知識庫問答系統
![<b class='flag-5'>華為</b><b class='flag-5'>云</b> <b class='flag-5'>Flexus</b> <b class='flag-5'>云</b><b class='flag-5'>服務器</b> <b class='flag-5'>X</b> 實例之 openEuler <b class='flag-5'>系統</b>下<b class='flag-5'>搭建</b> MaxKB 開源知識庫問答<b class='flag-5'>系統</b>](https://file1.elecfans.com//web3/M00/06/4C/wKgZPGeJtfKARwc5AAEOFncth-U860.png)
使用華為云 Flexus 云服務器 X 搭建部署茶葉商城小程序 uniapp
![使用<b class='flag-5'>華為</b><b class='flag-5'>云</b> <b class='flag-5'>Flexus</b> <b class='flag-5'>云</b><b class='flag-5'>服務器</b> <b class='flag-5'>X</b> <b class='flag-5'>搭建</b>部署茶葉商城小程序 uniapp](https://file1.elecfans.com//web3/M00/05/C9/wKgZO2eEpfyAYSXwAAaQvjnH3d4510.png)
Flexus 云服務器 X 實例:在 Docker 環境下搭建 java 開發環境
![<b class='flag-5'>Flexus</b> <b class='flag-5'>云</b><b class='flag-5'>服務器</b> <b class='flag-5'>X</b> 實例:在 Docker 環境下<b class='flag-5'>搭建</b> java 開發環境](https://file1.elecfans.com//web3/M00/04/30/wKgZPGdxDsqAZxq9AAEJcgNsafo044.png)
基于華為云 Flexus 云服務器 X 實例部搭建 Halo 博客平臺
![基于<b class='flag-5'>華為</b><b class='flag-5'>云</b> <b class='flag-5'>Flexus</b> <b class='flag-5'>云</b><b class='flag-5'>服務器</b> <b class='flag-5'>X</b> 實例部<b class='flag-5'>搭建</b> Halo 博客平臺](https://file1.elecfans.com//web3/M00/03/D4/wKgZO2dsEiuAKz3YAACZ1hQEldg800.png)
評論