当前位置: 首页 > news >正文

828华为云征文|华为云服务器Flexus X搭建悟空crm管理系统——助力企业云上管理(解决APP Referer校验失败问题)

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、客户详情功能模块代码

public function read(){$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 \app\admin\model\User();$auth_user_ids = $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('crm_customer')->alias('customer')->where(['customer_id' => $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['user_id'] = $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 \app\admin\model\User();$recordModel = new \app\admin\model\Record();$fileModel = new \app\admin\model\File();$actionRecordModel = new \app\admin\model\ActionRecord();if (!is_array($param['id'])) {$customer_id[] = $param['id'];} else {$customer_id = $param['id'];}$delIds = [];$errorMessage = [];//数据权限判断$auth_user_ids = $userModel->getUserByPer('crm', 'customer', 'delete');//判断是否客户池数据(客户池数据只有管理员可以删)$adminId = $userModel->getAdminId();$wherePool = $customerModel->getWhereByPool();foreach ($customer_id as $k => $v) {$isDel = true;//数据详情$data = db('crm_customer')->where(['customer_id' => $v])->find();if (!$data) {$isDel = false;$errorMessage[] = 'id为' . $v . '的客户删除失败,错误原因:' . $customerModel->getError();}$resPool = db('crm_customer')->alias('customer')->where(['customer_id' => $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('crm_business')->where(['customer_id' => $v])->find();if ($resBusiness) {$isDel = false;$errorMessage[] = '客户下存在商机,不能删除';}}if ($isDel) {$resContacts = db('crm_contacts')->where(['customer_id' => $v])->find();if ($resContacts) {$isDel = false;// $errorMessage[] = '名称为' . $data['name'] . '的客户删除失败,错误原因:客户下存在联系人,不能删除';$errorMessage[] = '客户下存在联系人,不能删除';}}if ($isDel) {$resContract = db('crm_contract')->where(['customer_id' => $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('crm_customer', $delIds);// 删除关联操作记录$actionRecordModel->delDataById(['types' => 'crm_customer', 'action_id' => $delIds]);foreach ($dataInfo as $k => $v) {RecordActionLog($userInfo['id'], 'crm_customer', '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 \app\admin\model\User();if (!$param['owner_user_id']) {return resultArray(['error' => '变更负责人不能为空']);}if (!$param['customer_id'] || !is_array($param['customer_id'])) {return resultArray(['error' => '请选择需要转移的客户']);}$is_remove = ($param['is_remove'] == 2) ? 2 : 1;$type = $param['type'] == 2 ?: 1;$types = $param['types'] ?: [];$data = [];$data['owner_user_id'] = $param['owner_user_id'];$data['update_time'] = time();$data['follow'] = '待跟进';# 获取客户的时间$data['obtain_time'] = time();$ownerUserName = $userModel->getUserNameById($param['owner_user_id']);$errorMessage = [];foreach ($param['customer_id'] as $customer_id) {$customerInfo = db('crm_customer')->where(['customer_id' => $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['user_id'] = [$customerInfo['owner_user_id']]; //协作人$teamData['types'] = 'crm_customer'; //类型$teamData['types_id'] = $customer_id; //类型ID$teamData['is_del'] = ($is_remove == 1) ? 1 : '';$res = $settingModel->createTeamData($teamData);# 处理分配标识,待办事项专用$data['is_allocation'] = 1;$resCustomer = db('crm_customer')->where(['customer_id' => $customer_id])->update($data);if (!$resCustomer) {$errorMessage[] = $customerInfo['name'] . '转移失败,错误原因:数据出错;';continue;} else {# 处理转移时,负责人出现在只读和读写成员列表中$customerArray = [];$teamCustomer = db('crm_customer')->field(['owner_user_id', 'ro_user_id', 'rw_user_id'])->where('customer_id', $customer_id)->find();if (!empty($teamCustomer['ro_user_id'])) {$customerRo = arrayToString(array_diff(stringToArray($teamCustomer['ro_user_id']), [$teamCustomer['owner_user_id']]));$customerArray['ro_user_id'] = $customerRo;}if (!empty($teamCustomer['rw_user_id'])) {$customerRo = arrayToString(array_diff(stringToArray($teamCustomer['rw_user_id']), [$teamCustomer['owner_user_id']]));$customerArray['rw_user_id'] = $customerRo;}db('crm_customer')->where('customer_id', $customer_id)->update($customerArray);}if (in_array('crm_contacts', $types)) {$contactsIds = [];$contactsIds = db('crm_contacts')->where(['customer_id' => $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('crm_business')->where(['customer_id' => $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('crm_contract')->where(['customer_id' => $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'], 'crm_customer', $customer_id, '', '', '将客户转移给:' . $ownerUserName);RecordActionLog($userInfo['id'], 'crm_customer', 'transfer', $customerInfo['name'], '', '', '将客户:' . $customerInfo['name'] . '转移给:' . $ownerUserName);}if (!$errorMessage) {return resultArray(['data' => '转移成功']);} else {return resultArray(['error' => $errorMessage]);}}

企业CRM管理系统部署上线之后,我们可以在华为云的控制台可以观察监控着CPU使用情况、内存、磁盘等等一切运作情况。华为云真的是性能强大、安全、稳定的云产品!!!
在这里插入图片描述

华为云828 为企业提供多行业场景解决方案及企业专属优惠,助力企业实现数字化转型升级,大家赶紧去选购吧!!

在这里插入图片描述

在这里插入图片描述

相关文章:

  • 北京网站建设多少钱?
  • 辽宁网页制作哪家好_网站建设
  • 高端品牌网站建设_汉中网站制作
  • Linux中的Vim文本编辑器
  • 设计模式之装饰器模式:让对象功能扩展更优雅的艺术
  • elementUI table 给表头添加气泡显示(鼠标悬浮显示注释)
  • Spring扩展点系列-InstantiationAwareBeanPostProcessor
  • 用ACF和PACF计算出一堆数据的周期个数以及周期时长,数据分析python
  • 【区块链 + 物联网】区块链边缘计算网关设备 | FISCO BCOS应用案例
  • 鸿蒙Next-拉起支付宝的三种方式——教程
  • 2024最新!Facebook手机版和网页版改名教程!
  • 【30天玩转python】条件语句与循环
  • RLC(电阻、电感、电容)
  • 简单的spring batch学习
  • 基础学习之——Docker 的基本概念和优势,以及在应用程序开发中的实际应用。
  • pycharm破解教程
  • 前端框架有哪些
  • 在VMware中的centos stream 9上用packstack安装openstack的单机版
  • JS中 map, filter, some, every, forEach, for in, for of 用法总结
  • [数据结构]链表的实现在PHP中
  • 0基础学习移动端适配
  • Elasticsearch 参考指南(升级前重新索引)
  • ES6系列(二)变量的解构赋值
  • JavaScript工作原理(五):深入了解WebSockets,HTTP/2和SSE,以及如何选择
  • mockjs让前端开发独立于后端
  • quasar-framework cnodejs社区
  • UMLCHINA 首席专家潘加宇鼎力推荐
  • vue.js框架原理浅析
  • zookeeper系列(七)实战分布式命名服务
  • 前端每日实战:70# 视频演示如何用纯 CSS 创作一只徘徊的果冻怪兽
  • 树莓派 - 使用须知
  • 我的面试准备过程--容器(更新中)
  • 译米田引理
  • 在Mac OS X上安装 Ruby运行环境
  • HanLP分词命名实体提取详解
  • 摩拜创始人胡玮炜也彻底离开了,共享单车行业还有未来吗? ...
  • #includecmath
  • #pragma 指令
  • #vue3 实现前端下载excel文件模板功能
  • #大学#套接字
  • (八)Spring源码解析:Spring MVC
  • (附源码)spring boot校园拼车微信小程序 毕业设计 091617
  • (附源码)springboot青少年公共卫生教育平台 毕业设计 643214
  • (十八)SpringBoot之发送QQ邮件
  • .net core docker部署教程和细节问题
  • .Net Core 中间件验签
  • .NET 设计模式初探
  • .Net 应用中使用dot trace进行性能诊断
  • .NET6使用MiniExcel根据数据源横向导出头部标题及数据
  • .NET下的多线程编程—1-线程机制概述
  • .NET中使用Redis (二)
  • .net中我喜欢的两种验证码
  • .so文件(linux系统)
  • /proc/vmstat 详解
  • @configuration注解_2w字长文给你讲透了配置类为什么要添加 @Configuration注解
  • @require_PUTNameError: name ‘require_PUT‘ is not defined 解决方法
  • [ABC275A] Find Takahashi 题解
  • [Angularjs]ng-select和ng-options