objMCustomerVisitsLog = new MCustomerVisitsLog($this->onlineEnterpriseId, $this->onlineUserId); } /** * 添加和编辑客户指定访问记录公共字段处理方法 * * @return array */ public function commonFieldFilter() { $params = $this->request->getRawJson(); if( empty($params) ){ $this->sendOutput('参数为空', ErrorCode::$paramError ); } $visitsLogData = [ 'usercenterid' => getArrayItem($params,'usercenterid'), 'customerid' => getArrayItem($params,'customerid'), 'shopid' => getArrayItem($params,'shopid'), 'goodsid' => getArrayItem($params,'goodsid'), ]; $visitsLogData['updateTime'] = time(); foreach($visitsLogData as $key => $value){ if(empty($value) && $value !== 0){ $this->sendOutput($key.'参数错误', ErrorCode::$paramError ); } } return $visitsLogData; } /** * 获取指定客户浏览记录 */ public function getCustomerVisitsLogInfo() { $customerVisitsLogId = $this->request->param('request_id'); if ( !$customerVisitsLogId ) { $this->sendOutput('参数错误', ErrorCode::$paramError ); } $result = $this->objMCustomerVisitsLog->getCustomerVisitsLogInfo($customerVisitsLogId); if($result->isSuccess()){ $this->sendOutput($result->getData()); }else{ $this->sendOutput($result->getData(), $result->getErrorCode()); } } /** * 获取所有的客户浏览记录 */ public function getAllCustomerVisitsLog() { $params = $this->request->getRawJson(); if (empty($params)) { $this->sendOutput('参数为空', ErrorCode::$paramError); } $pageParams = pageToOffset($params['page'] ?: 1, $params['pageSize'] ?: 10); $params['limit'] = $pageParams['limit']; $params['offset'] = $pageParams['offset']; $returnData = $this->objMCustomerVisitsLog->getAllCustomerVisitsLog($params); if ($returnData->isSuccess()) { $returnData = $returnData->getData(); $pageData = [ 'pageIndex' => $params['page'], 'pageSize' => $params['pageSize'], 'pageTotal' => $returnData['total'], ]; parent::sendOutput($returnData['data'], 0, $pageData); } else { parent::sendOutput($returnData->getData(), ErrorCode::$dberror); } } }