123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253 |
- <?php
- /**
- * 客户沟通记录Controller
- * Created by PhpStorm.
- * User: haoren
- * Date: 2021/02/23
- * Time: 13:00
- */
- namespace JinDouYun\Controller\Customer;
- use Exception;
- use Mall\Framework\Core\ErrorCode;
- use Mall\Framework\Core\StatusCode;
- use JinDouYun\Controller\BaseController;
- use JinDouYun\Model\Customer\MCustomerCommunication;
- class CustomerCommunication extends BaseController
- {
- private $objMCustomerCommunication;
- public function __construct($isCheckAcl = false, $isMustLogin = true)
- {
- parent::__construct($isCheckAcl, $isMustLogin);
- $this->objMCustomerCommunication = new MCustomerCommunication($this->onlineEnterpriseId,$this->onlineUserId);
- }
- /**
- * 获取参数
- * @return array
- */
- public function commonFieldFilter()
- {
- $params = $this->request->getRawJson();
- if (empty($params)) {
- $this->sendOutput('参数为空', ErrorCode::$paramError);
- }
- $data = [
- 'customerId' => isset($params['customerId']) ? $params['customerId'] : '',
- 'staffId' => isset($params['staffId']) ? $params['staffId'] : '',
- 'content' => isset($params['content']) ? $params['content'] : '',
- ];
- //必填项
- foreach ($data as $key => $value) {
- if (empty($value) && $value !== 0) {
- $this->sendOutput($key . '参数错误', ErrorCode::$paramError);
- }
- }
- //选填项
- $data['time'] = isset($params['time']) && !empty($params['time']) ? $params['time'] : time();
- $data['location'] = isset($params['location']) && !empty($params['location']) ? $params['location'] : '';
- $data['picture'] = isset($params['picture']) && !empty($params['picture']) ? $params['picture'] : '';
- return $data;
- }
- /**
- * 客户沟通记录添加
- */
- public function addCustomerCommunication()
- {
- $data = $this->commonFieldFilter();
- $result = $this->objMCustomerCommunication->addCustomerCommunication($data);
- if ($result->isSuccess()) {
- parent::sendOutput($result->getData());
- } else {
- parent::sendOutput($result->getData(), $result->getErrorCode());
- }
- }
- /**
- * 客户沟通记录删除
- * @throws Exception
- */
- public function delCustomerCommunication()
- {
- $id = $this->request->param('request_id');
- if (empty($id)) {
- $this->sendOutput('参数为空', ErrorCode::$paramError);
- }
- $result = $this->objMCustomerCommunication->delCustomerCommunication($id);
- if ($result->isSuccess()) {
- parent::sendOutput($result->getData());
- } else {
- parent::sendOutput($result->getData(), $result->getErrorCode());
- }
- }
- /**
- * 客户沟通记录修改
- */
- public function updateCustomerCommunication()
- {
- $id = $this->request->param('request_id');
- if (empty($id)) {
- $this->sendOutput('id参数为空', ErrorCode::$paramError);
- }
- $data = $this->commonFieldFilter();
- $result = $this->objMCustomerCommunication->updateCustomerCommunication($data, $id);
- if ($result->isSuccess()) {
- parent::sendOutput($result->getData());
- } else {
- parent::sendOutput($result->getData(), $result->getErrorCode());
- }
- }
- /**
- * 客户沟通记录列表
- */
- public function getAllCustomerCommunication()
- {
- $params = $this->request->getRawJson();
- $pageParams = pageToOffset($params['page'] ?: 1, $params['pageSize'] ?: 10);
- $selectParams['limit'] = $pageParams['limit'];
- $selectParams['offset'] = $pageParams['offset'];
- if(isset($params['customerId']) && !empty($params['customerId'])){
- $selectParams['customerId'] = $params['customerId'];
- }
- if(isset($params['staffId']) && !empty($params['staffId'])){
- $selectParams['staffId'] = $params['staffId'];
- }
- if(isset($params['start']) && !empty($params['start'])){
- $selectParams['start'] = $params['start'];
- }
- if(isset($params['end']) && !empty($params['end'])){
- $selectParams['end'] = $params['end'];
- }
- $result = $this->objMCustomerCommunication->getAllCustomerCommunication($selectParams);
- if ($result->isSuccess()) {
- $returnData = $result->getData();
- $pageData = [
- 'pageIndex' => $params['page'],
- 'pageSize' => $params['pageSize'],
- 'pageTotal' => $returnData['total'],
- ];
- parent::sendOutput($returnData['data'], 0, $pageData);
- } else {
- parent::sendOutput($result->getData(), ErrorCode::$dberror);
- }
- }
- /**
- * 客户沟通记录详情
- */
- public function getCustomerCommunication()
- {
- $id = $this->request->param('request_id');
- if (empty($id)) {
- $this->sendOutput('参数为空', ErrorCode::$paramError);
- }
- $result = $this->objMCustomerCommunication->getCustomerCommunication(['id' => $id]);
- if ($result->isSuccess()) {
- parent::sendOutput($result->getData());
- } else {
- parent::sendOutput($result->getData(), $result->getErrorCode());
- }
- }
-
- /**
- * 客户拜访报表
- */
- public function getCustomerCallOnReportForm()
- {
- $params = $this->request->getRawJson();
- $pageParams = pageToOffset($params['page'] ?: 1, $params['pageSize'] ?: 10);
- $selectParams['limit'] = $pageParams['limit'];
- $selectParams['offset'] = $pageParams['offset'];
- $selectParams['departmentId'] = isset($params['departmentId']) ? $params['departmentId'] :'';
- $selectParams['start'] = isset($params['start']) ? $params['start'] :'';
- $selectParams['end'] = isset($params['end']) ? $params['end'] :'';
- $result = $this->objMCustomerCommunication->getCustomerCallOnReportForm($selectParams);
-
- if ($result->isSuccess()) {
- $returnData = $result->getData();
- $pageData = [
- 'pageIndex' => $params['page'],
- 'pageSize' => $params['pageSize'],
- 'pageTotal' => $returnData['total'],
- ];
- parent::sendOutput($returnData['data'], 0, $pageData);
- } else {
- parent::sendOutput($result->getData(), ErrorCode::$dberror);
- }
- }
-
- /**
- * 客户拜访记录详情
- */
- public function getCustomerVisitInfo()
- {
- $params = $this->request->getRawJson();
- $pageParams = pageToOffset($params['page'] ?: 1, $params['pageSize'] ?: 10);
- $selectParams['limit'] = $pageParams['limit'];
- $selectParams['offset'] = $pageParams['offset'];
- $selectParams['staffId'] = getArrayItem($params,'staffId');
-
- $result = $this->objMCustomerCommunication->getCustomerVisitInfo($selectParams);
-
- if ($result->isSuccess()) {
- $returnData = $result->getData();
- $pageData = [
- 'pageIndex' => $params['page'],
- 'pageSize' => $params['pageSize'],
- 'pageTotal' => $returnData['total'],
- ];
- parent::sendOutput($returnData['data'], 0, $pageData);
- } else {
- parent::sendOutput($result->getData(), ErrorCode::$dberror);
- }
- }
-
- /**
- * 未拜访客户统计列表
- */
- public function getCustomerNoVisit()
- {
- $params = $this->request->getRawJson();
- $pageParams = pageToOffset($params['page'] ?: 1, $params['pageSize'] ?: 10);
- $selectParams['limit'] = $pageParams['limit'];
- $selectParams['offset'] = $pageParams['offset'];
- $selectParams['days'] = getArrayItem($params,'intervalDay',0);
- $selectParams['customerName'] = getArrayItem($params,'customerName');//客户id
- $selectParams['staffId'] = getArrayItem($params,'staffId');//员工id
- $selectParams['province'] = getArrayItem($params,'province');
- $selectParams['city'] = getArrayItem($params,'city');
- $selectParams['district'] = getArrayItem($params,'district');
- $result = $this->objMCustomerCommunication->getCustomerNoVisit($selectParams);
-
- if ($result->isSuccess()) {
- $returnData = $result->getData();
- $pageData = [
- 'pageIndex' => $params['page'],
- 'pageSize' => $params['pageSize'],
- 'pageTotal' => $returnData['total'],
- ];
- parent::sendOutput($returnData['data'], 0, $pageData);
- } else {
- parent::sendOutput($result->getData(), ErrorCode::$dberror);
- }
- }
- }
|