diff --git a/application/crm/controller/CustomerPool.php b/application/crm/controller/CustomerPool.php index ed00862..79a6636 100644 --- a/application/crm/controller/CustomerPool.php +++ b/application/crm/controller/CustomerPool.php @@ -43,7 +43,8 @@ class CustomerPool extends ApiCommon 'setfieldconfig', 'exceldownload', 'import', - 'export' + 'export', + 'checkCustomerReveive' ] ]; Hook::listen('check_auth', $action); diff --git a/application/crm/controller/Message.php b/application/crm/controller/Message.php index 2f7fd51..604d4b9 100644 --- a/application/crm/controller/Message.php +++ b/application/crm/controller/Message.php @@ -42,7 +42,10 @@ class Message extends ApiCommon 'remindcustomer', 'checkinvoice', 'visitcontract', - 'alldeal' + 'alldeal', + 'checkBusiness', + 'newBusiness', + 'checkCustomerCheck', ] ]; Hook::listen('check_auth', $action); @@ -771,7 +774,7 @@ class Message extends ApiCommon } # 处理待审核合同、回款、发票 - if (in_array($type, ['checkContract', 'checkReceivables', 'checkInvoice','checkBusiness'])) { + if (in_array($type, ['checkContract', 'checkReceivables', 'checkInvoice', 'checkBusiness'])) { $where['check_status'] = ['lt', '2']; $where['check_user_id'] = ['like', ',%' . $userId . '%,']; diff --git a/application/crm/model/CustomerCheck.php b/application/crm/model/CustomerCheck.php index 7cf6622..50f77ef 100644 --- a/application/crm/model/CustomerCheck.php +++ b/application/crm/model/CustomerCheck.php @@ -23,17 +23,18 @@ class CustomerCheck extends Common /** * 待审核客户列表 * @param $request - * @return + * @return array */ public function getDataList($request) { $userModel = new \app\admin\model\User(); $fieldModel = new \app\admin\model\Field(); - $customer_check_id= $request['customer_check_id']; + $customer_check_id = $request['customer_check_id']; $order_field = $request['order_field']; $order_type = $request['order_type']; $getCount = $request['getCount']; + $user_id = $request['user_id']; $customerCheckIdArray = $request['customerCheckIdArray']; // 待办事项提醒参数 unset($request['scene_id']); unset($request['search']); @@ -52,8 +53,6 @@ class CustomerCheck extends Common $requestMap = $request['map'] ?: []; # getCount是代办事项传来的参数,代办事项不需要使用场景 $sceneMap = []; - - $partMap = []; $teamMap = $requestMap['team_id']; //团队成员 高级筛选 @@ -65,6 +64,11 @@ class CustomerCheck extends Common $map = $requestMap ? array_merge($sceneMap, $requestMap) : $sceneMap; } + // 权限 + $readAuthIds = $userModel->getUserByPer('crm', 'customer', 'read'); + $updateAuthIds = $userModel->getUserByPer('crm', 'customer', 'update'); + $deleteAuthIds = $userModel->getUserByPer('crm', 'customer', 'delete'); + //排序 if ($order_type && $order_field) { $order = $fieldModel->getOrderByFormtype('crm_customer_check', 'customer_check', $order_field, $order_type); @@ -86,7 +90,7 @@ class CustomerCheck extends Common $list = db('crm_customer_check') ->alias('customer_check') - ->join('__CRM_CUSTOMER__ customer', 'business.customer_id = customer.customer_id', 'LEFT') + ->join('__CRM_CUSTOMER__ customer', 'customer_check.customer_id = customer.customer_id', 'LEFT') ->where($map) ->where($partMap) ->where($dealtWhere) @@ -94,8 +98,36 @@ class CustomerCheck extends Common ->field('customer_check.*,customer.name as customer_name') ->orderRaw($order) ->select(); - # 扩展数据 - $extraData = []; + + foreach ($list as $k => $v) { + $list[$k]['customer_id_info']['customer_id'] = $v['customer_id']; + $list[$k]['customer_id_info']['name'] = $v['customer_name']; + $list[$k]['create_user_id_info'] = isset($v['create_user_id']) ? $userModel->getUserById($v['create_user_id']) : []; + $list[$k]['owner_user_id_info'] = isset($v['owner_user_id']) ? $userModel->getUserById($v['owner_user_id']) : []; + $list[$k]['create_user_name'] = !empty($list[$k]['create_user_id_info']['realname']) ? $list[$k]['create_user_id_info']['realname'] : ''; + $list[$k]['owner_user_name'] = !empty($list[$k]['owner_user_id_info']['realname']) ? $list[$k]['owner_user_id_info']['realname'] : ''; + + //权限 + $roPre = $userModel->rwPre($user_id, $v['ro_user_id'], $v['rw_user_id'], 'read'); + $rwPre = $userModel->rwPre($user_id, $v['ro_user_id'], $v['rw_user_id'], 'update'); + $permission = []; + $is_read = 0; + $is_update = 0; + $is_delete = 0; + if (in_array($v['owner_user_id'], $readAuthIds) || $roPre || $rwPre) $is_read = 1; + if (in_array($v['owner_user_id'], $updateAuthIds) || $rwPre) $is_update = 1; + if (in_array($v['owner_user_id'], $deleteAuthIds)) $is_delete = 1; + $permission['is_read'] = $is_read; + $permission['is_update'] = $is_update; + $permission['is_delete'] = $is_delete; + $list[$k]['permission'] = $permission; + + # 日期 + $list[$k]['create_time'] = !empty($v['create_time']) ? date('Y-m-d H:i:s', $v['create_time']) : null; + $list[$k]['update_time'] = !empty($v['update_time']) ? date('Y-m-d H:i:s', $v['update_time']) : null; + # 系统字段 负责人部门 zjf 20210726 + $list[$k]['owner_user_structure_name'] = $list[$k]['owner_user_id_info']['structure_name']; + } $data = []; $data['list'] = $list ?: []; $data['dataCount'] = $dataCount ?: 0;