checkData($types, $action_id, $request['user_id'])) { return []; } $dataList = db('admin_action_record')->where(['types' => $types,'action_id' => $action_id])->order('id','desc')->select(); if($types == 'crm_customer') { $leads_id = db('crm_leads')->where(['customer_id' => $action_id, 'is_transform' => 1])->value('leads_id'); if($leads_id){ $leads_dataList = db('admin_action_record')->where(['types' => 'crm_leads','action_id' => $leads_id])->order('id','desc')->select(); $dataList = array_merge($leads_dataList, $dataList); # 对线索和客户的合并数据进行排序 $sortData = array_column($dataList, 'create_time'); array_multisort($sortData,SORT_DESC , $dataList); } } $userModel = model('User'); foreach ($dataList as $k=>$v) { $dataList[$k]['user_id_info'] = isset($v['user_id']) ? $userModel->getUserById($v['user_id']) : []; $dataList[$k]['content'] = explode('.|.', $v['content']); } return $dataList; } /** * [checkData 权限判断] * @return [array] */ public function checkData($types, $action_id, $user_id) { if (!in_array($types, $this->typesArr)) { return false; } if (!$action_id) { return false; } $adminTypes = adminGroupTypes($user_id); if (in_array(1,$adminTypes)) { return true; } $checkRes = false; switch ($types) { case 'crm_leads' : $checkRes = checkPerByAction('crm', 'leads', 'read'); break; case 'crm_customer' : $checkRes = checkPerByAction('crm', 'customer', 'read'); break; case 'crm_contacts' : $checkRes = checkPerByAction('crm', 'contacts', 'read'); break; case 'crm_product' : $checkRes = checkPerByAction('crm', 'product', 'read'); break; case 'crm_business' : $checkRes = checkPerByAction('crm', 'business', 'read'); break; case 'crm_contract' : $checkRes = checkPerByAction('crm', 'contract', 'read'); break; case 'crm_receivables' : $checkRes = checkPerByAction('crm', 'receivables', 'read'); break; case 'crm_visit' : $checkRes = checkPerByAction('crm', 'visit', 'read'); break; } if ($checkRes !== false) { return true; } } /** * 删除字段修改记录 * @param * @return */ public function delDataById($request) { $types = trim($request['types']); $action_id = $request['action_id']; if ($types && $action_id) { $res = db('admin_action_record')->where(['types' => $types,'action_id' => ['in',$action_id]])->delete(); } } }