123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182 |
- <?php
- /**
- * 客户联系人管理模块
- * Created by PhpStorm.
- * User: tpl
- * Date: 2019/10/30
- * Time: 13:54
- */
- namespace JinDouYun\Controller\Customer;
- use Mall\Framework\Core\ErrorCode;
- use Mall\Framework\Core\StatusCode;
- use Jindouyun\Cache\CustomerCache;
- use JinDouYun\Controller\BaseController;
- use JinDouYun\Model\Customer\MCustomerContact;
- class CustomerContact extends BaseController
- {
- private $objMCustomerContact;
- public function __construct($isCheckAcl = true, $isMustLogin = true)
- {
- parent::__construct($isCheckAcl, $isMustLogin);
- $this->objMCustomerContact = new MCustomerContact($this->onlineEnterpriseId, $this->onlineUserId);
- }
- /**
- * 添加和编辑客户联系人管理公共字段处理方法
- *
- * @return array
- */
- public function commonFieldFilter(){
- $params = $this->request->getRawJson();
- if( empty($params) ){
- $this->sendOutput('参数为空', ErrorCode::$paramError );
- }
- $customerContactData = [
- 'customerId' => isset($params['customerId']) ? $params['customerId'] : '',
- 'name' => isset($params['name']) ? $params['name'] : '',
- 'mobile' => isset($params['mobile']) ? $params['mobile'] : '',
- ];
- foreach($customerContactData as $key => $value){
- if(empty($value) && $value !== 0){
- $this->sendOutput($key.'参数错误', ErrorCode::$paramError );
- }
- }
- $customerContactData['provinceCode'] = isset($params['provinceCode']) ? $params['provinceCode'] : '';
- $customerContactData['cityCode'] = isset($params['cityCode']) ? $params['cityCode'] : '';
- $customerContactData['districtCode'] = isset($params['districtCode']) ? $params['districtCode'] : '';
- $customerContactData['address'] = isset($params['address']) ? $params['address'] : '';
- $customerContactData['deleteStatus']= StatusCode::$standard;
- $customerContactData['createTime'] = time();
- $customerContactData['updateTime'] = time();
- return $customerContactData;
- }
- /**
- * 添加客户联系人
- */
- public function addCustomerContact()
- {
- $customerContactData = $this->commonFieldFilter();
- $result = $this->objMCustomerContact->addCustomerContact($customerContactData);
- if($result->isSuccess()){
- parent::sendOutput($result->getData());
- }else{
- parent::sendOutput($result->getData(), $result->getErrorCode());
- }
- }
- /**
- * 获取指定客户联系人信息
- */
- public function getCustomerContactInfo()
- {
- $customerContactId = $this->request->param('request_id');
- if ( !$customerContactId ) {
- $this->sendOutput('参数错误', ErrorCode::$paramError );
- }
- $result = $this->objMCustomerContact->getCustomerContactInfo($customerContactId);
- if($result->isSuccess()){
- $this->sendOutput($result->getData());
- }else{
- $this->sendOutput($result->getData(), $result->getErrorCode());
- }
- }
- /**
- * 编辑客户联系人
- */
- public function editCustomerContact()
- {
- $customerContactId = $this->request->param('request_id');
- if(empty($customerContactId)){
- $this->sendOutput('参数错误', ErrorCode::$paramError);
- }
- $customerContactData = $this->commonFieldFilter();
- $customerContactData['id'] = $customerContactId;
- unset($customerContactData['createTime']);
- $result = $this->objMCustomerContact->editCustomerContact($customerContactData);
- if($result->isSuccess()){
- parent::sendOutput($result->getData());
- }else{
- parent::sendOutput($result->getData(), $result->getErrorCode());
- }
- }
- /**
- * 删除客户联系人
- */
- public function delCustomerContact()
- {
- $customerContactId = $this->request->param('request_id');
- if(!$customerContactId){
- $this->sendOutput('参数错误', ErrorCode::$paramError);
- }
- $result = $this->objMCustomerContact->delCustomerContact($customerContactId);
- if($result->isSuccess()){
- parent::sendOutput($result->getData());
- }else{
- parent::sendOutput($result->getData(), $result->getErrorCode());
- }
- }
- /**
- * 客户联系人启用和禁用
- */
- public function updateCustomerContactStatus()
- {
- $params['id'] = $this->request->param('request_id');
- $params['type'] = $this->request->param('type');
- if($params['type'] == 1){ //启用
- $params['enableStatus'] = StatusCode::$standard;
- }else if($params['type'] == 2){ //停用
- $params['enableStatus'] = StatusCode::$offline;
- }
- foreach($params as $key => $value){
- if(empty($value)){
- $this->sendOutput($key.'参数错误', ErrorCode::$paramError );
- }
- }
- unset($params['type']);
- $result = $this->objMCustomerContact->updateCustomerContactStatus($params);
- if($result->isSuccess()){
- parent::sendOutput($result->getData());
- }else{
- parent::sendOutput($result->getData(), $result->getErrorCode());
- }
- }
- /**
- * 后台所有客户联系人列表
- */
- public function getAllCustomerContact()
- {
- $result = $this->objMCustomerContact->getAllCustomerContact([],'*',true);
- if($result->isSuccess()){
- parent::sendOutput($result->getData(), 0);
- }else{
- parent::sendOutput($result->getData(), $result->getErrorCode());
- }
- }
- }
|