pull/1/head
Michael_xu 3 years ago
parent 43045d9956
commit 25706b1136

@ -287,18 +287,18 @@ class ExamineFlow extends ApiCommon
* @version 1.0 版本号
* @since 2021/3/15 0015 13:37
*/
public function checkFlow($param,$userInfo){
public function checkFlow($param,$userInfo)
{
$examineStepModel = model('ExamineStep');
$examineFlowModel = model('ExamineFlow');
$check_user_id = $userInfo['id'];
$flow_id = $param['flow_id'];
$types = $param['types'];
$types_id = $param['types_id'];
$typesArr = ['crm_contract', 'crm_receivables', 'crm_invoice', 'oa_examine'];
$typesArr = ['crm_contract', 'crm_receivables', 'crm_invoice', 'oa_examine', 'jxc_purchase', 'jxc_retreat', 'jxc_sale', 'jxc_salereturn', 'jxc_payment', 'jxc_collection', 'jxc_allocation', 'jxc_inventory'];
if (!$types || !in_array($types, $typesArr)) {
return resultArray(['error' => '参数错误']);
}
if ($flow_id) {
$examineFlowData = $examineFlowModel->getDataById($param['flow_id']);
if (!$examineFlowData) {

@ -145,6 +145,21 @@ class Field extends ApiCommon
$errorMessage = '数字字段类型的小数配置错误!';
break;
}
# 数组数据转换为字符串保存
if ($v['form_type'] == 'date_interval') {
$v['default_value']=trim((string)implode(',',$v['default_value']),'"');
}
if( $v['form_type']=='position'){
$v['default_value']=json_encode($v['default_value']);
}
# 数组数据转换为字符串保存
// if (!empty($v['fieldExtendList'])) {
// foreach ($v['fieldExtendList'] as $key=> $value){
// if($value['form_type']=='textarea'){
// $v['fieldExtendList'][$key]['default_value']=!empty($value['default_value'])?(string)trim("'".$value['default_value']."'",'"'):'';
// }
// }
// }
if ($v['field_id']) {
if (isset($v['is_deleted']) && $v['is_deleted'] == '1') {
@ -164,7 +179,6 @@ class Field extends ApiCommon
$saveParam[$k]['types_id'] = $types_id;
}
}
# 必填的字段不可以隐藏
if ($errorMessage) return resultArray(['error' => $errorMessage]);
@ -174,14 +188,12 @@ class Field extends ApiCommon
foreach ($deleteIds AS $key => $value) {
if (!in_array($value, $delParam)) $delParam[] = $value;
}
# 新增
if (!empty($saveParam)) {
if (!$data = $fieldModel->createData($types, $saveParam)) {
$errorMessage[] = $fieldModel->getError();
}
}
# 编辑
if (!empty($updateParam)) {
if (!$data = $fieldModel->updateDataById($updateParam, $types)) {
@ -259,10 +271,14 @@ class Field extends ApiCommon
if ($action == 'read' || $action == 'update') {
//获取详情数据
if (($param['action'] == 'update' || $param['action'] == 'read') && $param['action_id']) {
$model='';
if($param['action'] == 'update'){
$model='update';
}
switch ($param['types']) {
case 'crm_customer' :
$customerModel = new \app\crm\model\Customer();
$dataInfo = $customerModel->getDataById(intval($param['action_id']));
$dataInfo = $customerModel->getDataById($param['action_id'],'',$model);
//判断权限
$auth_user_ids = $userModel->getUserByPer('crm', 'customer', $param['action']);
//读写权限
@ -278,9 +294,10 @@ class Field extends ApiCommon
break;
case 'crm_leads' :
$leadsModel = new \app\crm\model\Leads();
$dataInfo = $leadsModel->getDataById(intval($param['action_id']));
$dataInfo = $leadsModel->getDataById($param['action_id'],'',$model);
//判断权限
$auth_user_ids = $userModel->getUserByPer('crm', 'leads', $param['action']);
if (!in_array($dataInfo['owner_user_id'],$auth_user_ids)) {
header('Content-Type:application/json; charset=utf-8');
exit(json_encode(['code'=>102,'error'=>'无权操作']));
@ -288,7 +305,7 @@ class Field extends ApiCommon
break;
case 'crm_contacts' :
$contactsModel = new \app\crm\model\Contacts();
$dataInfo = $contactsModel->getDataById(intval($param['action_id']));
$dataInfo = $contactsModel->getDataById($param['action_id'],'',$model);
//判断权限
$auth_user_ids = $userModel->getUserByPer('crm', 'contacts', $param['action']);
if (!in_array($dataInfo['owner_user_id'],$auth_user_ids)) {
@ -298,7 +315,7 @@ class Field extends ApiCommon
break;
case 'crm_business' :
$businessModel = new \app\crm\model\Business();
$dataInfo = $businessModel->getDataById(intval($param['action_id']));
$dataInfo = $businessModel->getDataById($param['action_id'],'',$model);
//判断权限
$auth_user_ids = $userModel->getUserByPer('crm', 'business', $param['action']);
//读写权限
@ -311,7 +328,7 @@ class Field extends ApiCommon
break;
case 'crm_contract' :
$contractModel = new \app\crm\model\Contract();
$dataInfo = $contractModel->getDataById(intval($param['action_id']));
$dataInfo = $contractModel->getDataById($param['action_id'],'',$model);
//判断权限
$auth_user_ids = $userModel->getUserByPer('crm', 'contract', $param['action']);
//读写权限
@ -324,7 +341,7 @@ class Field extends ApiCommon
break;
case 'crm_product' :
$productModel = new \app\crm\model\Product();
$dataInfo = $productModel->getDataById(intval($param['action_id']));
$dataInfo = $productModel->getDataById($param['action_id'],'',$model);
//判断权限
$auth_user_ids = $userModel->getUserByPer('crm', 'product', $param['action']);
@ -335,7 +352,7 @@ class Field extends ApiCommon
break;
case 'crm_receivables' :
$receivablesModel = new \app\crm\model\Receivables();
$dataInfo = $receivablesModel->getDataById(intval($param['action_id']));
$dataInfo = $receivablesModel->getDataById($param['action_id'],'',$model);
//判断权限
$auth_user_ids = $userModel->getUserByPer('crm', 'receivables', $param['action']);
if (!in_array($dataInfo['owner_user_id'],$auth_user_ids)) {
@ -345,7 +362,13 @@ class Field extends ApiCommon
break;
case 'crm_receivables_plan' :
$receivablesPlanModel = new \app\crm\model\ReceivablesPlan();
$dataInfo = $receivablesPlanModel->getDataById(intval($param['action_id']));
$dataInfo = $receivablesPlanModel->getDataById($param['action_id'],'',$model);
//判断权限
$auth_user_ids = $userModel->getUserByPer('crm', 'receivables_plan', $param['action']);
if (!in_array($dataInfo['owner_user_id'],$auth_user_ids)) {
header('Content-Type:application/json; charset=utf-8');
exit(json_encode(['code'=>102,'error'=>'无权操作']));
}
break;
case 'oa_examine' :
$examineModel = new \app\oa\model\Examine();
@ -362,7 +385,7 @@ class Field extends ApiCommon
break;
case 'crm_visit' :
$visit = new \app\crm\model\Visit();
$dataInfo = $visit->getDataById(intval($param['action_id']));
$dataInfo = $visit->getDataById($param['action_id'],'',$model);
$fieldModel = new \app\admin\model\Field();
$datetimeField = $fieldModel->getFieldByFormType('crm_visit', 'datetime'); //日期时间类型
foreach ($datetimeField as $key => $val) {
@ -379,8 +402,8 @@ class Field extends ApiCommon
}
break;
case 'crm_invoice' :
$visit = new \app\crm\model\Invoice();
$dataInfo = $visit->getDataById(intval($param['action_id']));
$Invoice = new \app\crm\model\Invoice();
$dataInfo = $Invoice->getDataById($param['action_id'],'',$model);
$fieldModel = new \app\admin\model\Field();
$datetimeField = $fieldModel->getFieldByFormType('crm_invoice', 'datetime'); //日期时间类型
foreach ($datetimeField as $key => $val) {
@ -400,7 +423,6 @@ class Field extends ApiCommon
$param['user_id'] = $user_id;
$action_id = $param['action_id'] ? : '';
$data = $fieldModel->field($param, $dataInfo) ? : [];
# 多公海数据详情
if (!empty($param['pool_id']) && $param['action'] == 'read') {
$data = $this->setPoolDetailData($data, $param['pool_id'], $param['action_id']);
@ -511,7 +533,7 @@ class Field extends ApiCommon
case 'crm_leads' :
$leadsModel = new Leads();
$leadsData = $leadsModel->getSystemInfo($action_id);
$leadsArray = ['create_user_id' => '创建人', 'create_time' => '创建时间', 'update_time' => '更新时间', 'last_time' => '最后跟进时间'];
$leadsArray = ['create_user_id' => '创建人' ,'owner_user_id' => '负责人', 'owner_user_structure_name' => '所属部门', 'create_time' => '创建时间', 'update_time' => '更新时间', 'last_time' => '最后跟进时间'];
foreach ($leadsData AS $key => $value) {
if (empty($leadsArray[$key]) ) continue;
@ -528,8 +550,7 @@ class Field extends ApiCommon
case 'crm_customer' :
$customerModel = new Customer();
$customerData = $customerModel->getSystemInfo($action_id);
$customerArray = ['obtain_time' => '负责人获取客户时间', 'owner_user_id' => '负责人', 'create_user_id' => '创建人', 'create_time' => '创建时间', 'update_time' => '更新时间', 'last_time' => '最后跟进时间', 'last_record' => '最后跟进记录', 'deal_status' => '成交状态'];
$customerArray = ['obtain_time' => '负责人获取客户时间', 'owner_user_id' => '负责人', 'owner_user_structure_name' => '所属部门', 'create_user_id' => '创建人', 'create_time' => '创建时间', 'update_time' => '更新时间', 'last_time' => '最后跟进时间', 'last_record' => '最后跟进记录', 'deal_status' => '成交状态'];
foreach ($customerData AS $key => $value) {
if (empty($customerArray[$key]) || (!empty($param['pool_id']) && in_array($key, ['obtain_time', 'owner_user_id']))) continue;
@ -545,7 +566,7 @@ class Field extends ApiCommon
case 'crm_contacts' :
$contactsModel = new Contacts();
$contactsData = $contactsModel->getSystemInfo($action_id);
$contactsArray = ['create_user_id' => '创建人', 'create_time' => '创建时间', 'update_time' => '更新时间', 'last_time' => '最后跟进时间'];
$contactsArray = ['create_user_id' => '创建人' ,'owner_user_id' => '负责人', 'owner_user_structure_name' => '所属部门', 'create_time' => '创建时间', 'update_time' => '更新时间', 'last_time' => '最后跟进时间'];
foreach ($contactsData AS $key => $value) {
if (empty($contactsArray[$key])) continue;
@ -562,7 +583,7 @@ class Field extends ApiCommon
case 'crm_business' :
$businessModel = new Business();
$businessData = $businessModel->getSystemInfo($action_id);
$businessArray = ['create_user_id' => '创建人', 'create_time' => '创建时间', 'update_time' => '更新时间', 'last_time' => '最后跟进时间'];
$businessArray = ['create_user_id' => '创建人' ,'owner_user_id' => '负责人', 'owner_user_structure_name' => '所属部门', 'create_time' => '创建时间', 'update_time' => '更新时间', 'last_time' => '最后跟进时间'];
foreach ($businessData AS $key => $value) {
if (empty($businessArray[$key])) continue;
@ -579,7 +600,7 @@ class Field extends ApiCommon
case 'crm_contract' :
$contractModel = new Contract();
$contractData = $contractModel->getSystemInfo($action_id);
$contractArray = ['create_user_id' => '创建人', 'create_time' => '创建时间', 'update_time' => '更新时间', 'last_time' => '最后跟进时间', 'done_money' => '已收款金额', 'un_money' => '未收款金额'];
$contractArray = ['create_user_id' => '创建人','owner_user_id' => '负责人', 'owner_user_structure_name' => '所属部门', 'create_time' => '创建时间', 'update_time' => '更新时间', 'last_time' => '最后跟进时间', 'done_money' => '已收款金额', 'un_money' => '未收款金额'];
foreach ($contractData AS $key => $value) {
if (empty($contractArray[$key])) continue;
@ -596,7 +617,7 @@ class Field extends ApiCommon
case 'crm_receivables' :
$receivablesModel = new Receivables();
$receivablesData = $receivablesModel->getSystemInfo($action_id);
$receivablesArray = ['create_user_id' => '创建人', 'create_time' => '创建时间', 'update_time' => '更新时间'];
$receivablesArray = ['create_user_id' => '创建人','owner_user_id' => '负责人', 'owner_user_structure_name' => '所属部门', 'create_time' => '创建时间', 'update_time' => '更新时间'];
foreach ($receivablesData AS $key => $value) {
if (empty($receivablesArray[$key])) continue;
@ -613,7 +634,7 @@ class Field extends ApiCommon
case 'crm_product' :
$productModel = new Product();
$productData = $productModel->getSystemInfo($action_id);
$productArray = ['create_user_id' => '创建人', 'create_time' => '创建时间', 'update_time' => '更新时间'];
$productArray = ['create_user_id' => '创建人' ,'owner_user_id' => '负责人', 'owner_user_structure_name' => '所属部门', 'create_time' => '创建时间', 'update_time' => '更新时间'];
foreach ($productData AS $key => $value) {
if (empty($productArray[$key])) continue;
@ -630,7 +651,7 @@ class Field extends ApiCommon
case 'crm_visit' :
$visitLogic = new VisitLogic();
$visitData = $visitLogic->getSystemInfo($action_id);
$visitArray = ['create_user_id' => '创建人', 'create_time' => '创建时间', 'update_time' => '更新时间'];
$visitArray = ['create_user_id' => '创建人' ,'owner_user_id' => '负责人', 'owner_user_structure_name' => '所属部门', 'create_time' => '创建时间', 'update_time' => '更新时间'];
foreach ($visitData AS $key => $value) {
if (empty($visitArray[$key])) continue;
@ -646,18 +667,23 @@ class Field extends ApiCommon
break;
case 'crm_invoice' :
$invoiceData = db('crm_invoice')->field(['create_user_id', 'owner_user_id', 'create_time', 'update_time'])->where('invoice_id', $action_id)->find();
$createUserName = db('admin_user')->where('id', $invoiceData['create_user_id'])->value('realname');
$ownerUserName = db('admin_user')->where('id', $invoiceData['owner_user_id'])->value('realname');
$data[] = ['field' => 'create_user_id', 'name' => '创建人', 'form_type' => 'user', 'value' => $createUserName, 'system' => 1];
$data[] = ['field' => 'create_user_id', 'name' => '负责人', 'form_type' => 'user', 'value' => $ownerUserName, 'system' => 1];
$data[] = ['field' => 'create_time', 'name' => '创建时间', 'form_type' => 'datetime', 'value' => date('Y-m-d H:i:s', $invoiceData['create_time']), 'system' => 1];
$data[] = ['field' => 'update_time', 'name' => '更新时间', 'form_type' => 'datetime', 'value' => date('Y-m-d H:i:s', $invoiceData['update_time']), 'system' => 1];
# zjf 20210726
$userModel = new \app\admin\model\User();
$ownerUserInfo = $userModel->getUserById($invoiceData['owner_user_id']);
$data[] = ['field' => 'owner_user_id', 'name' => '负责人', 'form_type' => 'user', 'value' => $ownerUserInfo['realname'], 'system' => 1];
$data[] = ['field' => 'owner_user_structure_name', 'name' => '所属部门', 'form_type' => 'text', 'value' => $ownerUserInfo['structure_name'], 'system' => 1];
}
}
# 处理自定义字段别名、权限
$data = $fieldModel->resetField($user_id, $param['types'], $param['action'], $data);
# 处理自定义字段分组排序
if (in_array($param['action'], ['save', 'update', 'relative']) && $format == 2) $data = getFieldGroupOrderData($data);

@ -63,9 +63,13 @@ class Index extends ApiCommon
if ($param['types'] == 'crm_visit' && $value['field'] == 'owner_user_id') $field_arr[$key]['name'] = '回访人';
}
if(in_array($param['types'],['crm_customer','crm_customer_pool','crm_contacts','crm_business','crm_contract','crm_receivables'])){
$field=[['field'=>'team_id','name'=>'相关团队','form_type'=>'user','setting'=>[]]];
$field=[['field'=>'team_id','name'=>'相关团队','form_type'=>'text','setting'=>[]]];
$field_arr=array_merge($field_arr,$field);
}
// if($param['types'] == 'jxc_product'){
// $field_arr[] = ['field'=>'product_code','name'=>'产品编码','form_type'=>'text','setting'=>[]];
// }
// $field_arr[] = ['field'=>'owner_structure','name'=>'所属部门','form_type'=>'structure','setting'=>[]];
return resultArray(['data' => $field_arr]);
}

@ -47,9 +47,14 @@ class FieldGrantLogic
'number', 'visit_time', 'owner_user_id', 'shape', 'customer_id', 'contacts_id', 'contract_id', 'satisfaction',
'feedback', 'create_user_id', 'create_time', 'update_time'
],
'invoice' => [
'invoice_apple_number', 'customer_id', 'contract_id', 'contract_money', 'invoice_date', 'invoice_money', 'invoice_type', 'remark'
],
'receivables_plan' => [
'receivables_id','un_money','real_money','real_data', 'num', 'money', 'owner_user_id', 'return_date', 'customer_id', 'remind', 'contract_id', 'create_user_id', 'create_time', 'update_time'
]
];
/**
@ -70,7 +75,6 @@ class FieldGrantLogic
};
$count = Db::name('admin_field_grant')->where($where)->count();
# 如果该角色下没有字段授权数据则自动添加
if ($count == 0 && Db::name('admin_group')->where('id', $param['role_id'])->find()) {
$this->createCrmFieldGrant($param['role_id']);
@ -113,6 +117,9 @@ class FieldGrantLogic
$this->createVisitFieldGrant($roleId);
# 添加发票字段授权信息
$this->createInvoiceFieldGrant($roleId);
# 添加回款计划字段授权信息
$this->createReceivablesPlanFieldGrant($roleId);
}
/**
@ -157,7 +164,7 @@ class FieldGrantLogic
$list = Db::name('admin_field_grant')->where('module', 'crm')->where('role_id', $copyId)->select();
foreach ($list AS $key => $value) {
foreach ($list as $key => $value) {
$data[] = [
'role_id' => $roleId,
'module' => $value['module'],
@ -192,7 +199,7 @@ class FieldGrantLogic
# 查询自定义字段表
$fieldBaseData = [];
$fieldList = Db::name('admin_field')->field(['name', 'field'])->where('types', $types)->select();
foreach ($fieldList AS $key => $value) {
foreach ($fieldList as $key => $value) {
# 排除掉固定字段
if (in_array($value['field'], $this->except[$typesArray[1]])) continue;
@ -203,11 +210,11 @@ class FieldGrantLogic
$grantList = Db::name('admin_field_grant')->field(['grant_id', 'content'])->where('column', $typesArray[1])->select();
# 处理授权字段的数据更新
foreach ($grantList AS $key => $value) {
foreach ($grantList as $key => $value) {
$content = unserialize($value['content']);
$fieldData = $fieldBaseData;
foreach ($content AS $k => $v) {
foreach ($content as $k => $v) {
# 只处理自定义字段
if ($v['is_diy'] == 0) continue;
@ -227,7 +234,7 @@ class FieldGrantLogic
# 【处理新增】如果$fieldData还有数据说明是新增的则进行同步新增。
if (!empty($fieldData)) {
foreach ($fieldData AS $k => $v) {
foreach ($fieldData as $k => $v) {
$content[] = [
'name' => $v['name'],
'field' => $v['field'],
@ -257,33 +264,34 @@ class FieldGrantLogic
{
# 固定字段
$content = [
['field' => 'name', 'read' => 1, 'read_operation' => 0, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '线索名称'],
['field' => 'email', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '邮箱'],
['field' => 'source', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '线索来源'],
['field' => 'mobile', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '手机'],
['field' => 'telephone', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '电话'],
['field' => 'detail_address', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '地址'],
['field' => 'industry', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '客户行业'],
['field' => 'level', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '客户级别'],
['field' => 'next_time', 'read' => 1, 'read_operation' => 0, 'write' => 1, 'write_operation' => 0, 'is_diy' => 0, 'name' => '下次联系时间'],
['field' => 'remark', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '备注'],
['field' => 'owner_user_id', 'read' => 1, 'read_operation' => 0, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '负责人'],
['field' => 'last_record', 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '最后跟进记录'],
['field' => 'create_user_id', 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '创建人'],
['field' => 'create_time', 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '创建时间'],
['field' => 'update_time', 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '更新时间'],
['field' => 'last_time', 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '最后跟进时间'],
['field' => 'name', 'maskType' => 0, 'read' => 1, 'read_operation' => 0, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '线索名称'],
['field' => 'email', 'maskType' => 0, 'form_type'=>'email', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '邮箱'],
['field' => 'source', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '线索来源'],
['field' => 'mobile', 'maskType' => 0, 'read' => 1,'form_type'=>'mobile', 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '手机'],
['field' => 'telephone', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '电话'],
['field' => 'detail_address', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '地址'],
['field' => 'industry', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '客户行业'],
['field' => 'level', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '客户级别'],
['field' => 'next_time', 'maskType' => 0, 'read' => 1, 'read_operation' => 0, 'write' => 1, 'write_operation' => 0, 'is_diy' => 0, 'name' => '下次联系时间'],
['field' => 'remark', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '备注'],
['field' => 'owner_user_id', 'maskType' => 0, 'read' => 1, 'read_operation' => 0, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '负责人'],
['field' => 'last_record', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '最后跟进记录'],
['field' => 'create_user_id', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '创建人'],
['field' => 'create_time', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '创建时间'],
['field' => 'update_time', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '更新时间'],
['field' => 'last_time', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '最后跟进时间'],
];
$leadsList = Db::name('admin_field')->field(['name', 'field'])->where('types', 'crm_leads')->select();
# 自定义字段
foreach ($leadsList AS $key => $value) {
foreach ($leadsList as $key => $value) {
if (in_array($value['field'], $this->except['leads'])) continue;
$content[] = [
'name' => $value['name'],
'field' => $value['field'],
'form_type'=>$value['form_type'],
'read' => 1,
'read_operation' => 1,
'write' => 1,
@ -291,7 +299,6 @@ class FieldGrantLogic
'is_diy' => 1
];
}
Db::name('admin_field_grant')->insert([
'role_id' => $roleId,
'module' => 'crm',
@ -313,32 +320,32 @@ class FieldGrantLogic
{
# 固定字段
$content = [
['field' => 'name', 'read' => 1, 'read_operation' => 0, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '客户名称'],
['field' => 'source', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '客户来源'],
['field' => 'mobile', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '手机'],
['field' => 'telephone', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '电话'],
['field' => 'website', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '网址'],
['field' => 'industry', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '客户行业'],
['field' => 'level', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '客户级别'],
['field' => 'next_time', 'read' => 1, 'read_operation' => 0, 'write' => 1, 'write_operation' => 0, 'is_diy' => 0, 'name' => '下次联系时间'],
['field' => 'remark', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '备注'],
['field' => 'email', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '邮箱'],
['field' => 'owner_user_id', 'read' => 1, 'read_operation' => 0, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '负责人'],
['field' => 'last_record', 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '最后跟进记录'],
['field' => 'create_user_id', 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '创建人'],
['field' => 'create_time', 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '创建时间'],
['field' => 'update_time', 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '更新时间'],
['field' => 'last_time', 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '最后跟进时间'],
['field' => 'obtain_time', 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '负责人获取客户时间'],
['field' => 'deal_status', 'read' => 1, 'read_operation' => 0, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '成交状态'],
['field' => 'is_lock', 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '锁定状态'],
['field' => 'pool_day', 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '距进入公海天数'],
['field' => 'name', 'maskType' => 0, 'read' => 1, 'read_operation' => 0, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '客户名称'],
['field' => 'source', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '客户来源'],
['field' => 'mobile', 'maskType' => 0,'form_type'=>'mobile', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '手机'],
['field' => 'telephone', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '电话'],
['field' => 'website', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '网址'],
['field' => 'industry', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '客户行业'],
['field' => 'level', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '客户级别'],
['field' => 'next_time', 'maskType' => 0, 'read' => 1, 'read_operation' => 0, 'write' => 1, 'write_operation' => 0, 'is_diy' => 0, 'name' => '下次联系时间'],
['field' => 'remark', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '备注'],
['field' => 'email', 'maskType' => 0,'form_type'=>'email', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '邮箱'],
['field' => 'owner_user_id', 'maskType' => 0, 'read' => 1, 'read_operation' => 0, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '负责人'],
['field' => 'last_record', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '最后跟进记录'],
['field' => 'create_user_id', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '创建人'],
['field' => 'create_time', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '创建时间'],
['field' => 'update_time', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '更新时间'],
['field' => 'last_time', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '最后跟进时间'],
['field' => 'obtain_time', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '负责人获取客户时间'],
['field' => 'deal_status', 'maskType' => 0, 'read' => 1, 'read_operation' => 0, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '成交状态'],
['field' => 'is_lock', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '锁定状态'],
['field' => 'pool_day', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '距进入公海天数'],
];
$customerList = Db::name('admin_field')->field(['name', 'field'])->where('types', 'crm_customer')->select();
# 自定义字段
foreach ($customerList AS $key => $value) {
foreach ($customerList as $key => $value) {
if (in_array($value['field'], $this->except['customer'])) continue;
$content[] = [
@ -373,28 +380,28 @@ class FieldGrantLogic
{
# 固定字段
$content = [
['field' => 'name', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '姓名'],
['field' => 'customer_id', 'read' => 1, 'read_operation' => 0, 'write' => 1, 'write_operation' => 0, 'is_diy' => 0, 'name' => '客户名称'],
['field' => 'mobile', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '手机'],
['field' => 'telephone', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '电话'],
['field' => 'email', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '邮箱'],
['field' => 'post', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '职务'],
['field' => 'decision', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '是否关键决策人'],
['field' => 'detail_address', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '地址'],
['field' => 'next_time', 'read' => 1, 'read_operation' => 0, 'write' => 1, 'write_operation' => 0, 'is_diy' => 0, 'name' => '下次联系时间'],
['field' => 'remark', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '备注'],
['field' => 'sex', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '性别'],
['field' => 'owner_user_id', 'read' => 1, 'read_operation' => 0, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '负责人'],
['field' => 'create_user_id', 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '创建人'],
['field' => 'create_time', 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '创建时间'],
['field' => 'update_time', 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '更新时间'],
['field' => 'last_time', 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '最后跟进时间'],
['field' => 'name', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '姓名'],
['field' => 'customer_id', 'maskType' => 0, 'read' => 1, 'read_operation' => 0, 'write' => 1, 'write_operation' => 0, 'is_diy' => 0, 'name' => '客户名称'],
['field' => 'mobile', 'maskType' => 0,'form_type'=>'mobile', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '手机'],
['field' => 'telephone', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '电话'],
['field' => 'email', 'maskType' => 0, 'form_type'=>'email','read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '邮箱'],
['field' => 'post', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '职务'],
['field' => 'decision', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '是否关键决策人'],
['field' => 'detail_address', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '地址'],
['field' => 'next_time', 'maskType' => 0, 'read' => 1, 'read_operation' => 0, 'write' => 1, 'write_operation' => 0, 'is_diy' => 0, 'name' => '下次联系时间'],
['field' => 'remark', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '备注'],
['field' => 'sex', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '性别'],
['field' => 'owner_user_id', 'maskType' => 0, 'read' => 1, 'read_operation' => 0, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '负责人'],
['field' => 'create_user_id', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '创建人'],
['field' => 'create_time', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '创建时间'],
['field' => 'update_time', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '更新时间'],
['field' => 'last_time', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '最后跟进时间'],
];
$contactsList = Db::name('admin_field')->field(['name', 'field'])->where('types', 'crm_contacts')->select();
# 自定义字段
foreach ($contactsList AS $key => $value) {
foreach ($contactsList as $key => $value) {
if (in_array($value['field'], $this->except['contacts'])) continue;
$content[] = [
@ -429,24 +436,24 @@ class FieldGrantLogic
{
# 固定字段
$content = [
['field' => 'name', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '商机名称'],
['field' => 'customer_id', 'read' => 1, 'read_operation' => 0, 'write' => 1, 'write_operation' => 0, 'is_diy' => 0, 'name' => '客户名称'],
['field' => 'money', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '商机金额'],
['field' => 'deal_date', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '预计成交日期'],
['field' => 'remark', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '备注'],
['field' => 'status_id', 'read' => 1, 'read_operation' => 0, 'write' => 1, 'write_operation' => 0, 'is_diy' => 0, 'name' => '商机阶段'],
['field' => 'type_id', 'read' => 1, 'read_operation' => 0, 'write' => 1, 'write_operation' => 0, 'is_diy' => 0, 'name' => '商机状态组'],
['field' => 'owner_user_id', 'read' => 1, 'read_operation' => 0, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '负责人'],
['field' => 'create_user_id', 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '创建人'],
['field' => 'create_time', 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '创建时间'],
['field' => 'update_time', 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '更新时间'],
['field' => 'last_time', 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '最后跟进时间'],
['field' => 'name', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '商机名称'],
['field' => 'customer_id', 'maskType' => 0, 'read' => 1, 'read_operation' => 0, 'write' => 1, 'write_operation' => 0, 'is_diy' => 0, 'name' => '客户名称'],
['field' => 'money', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '商机金额'],
['field' => 'deal_date', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '预计成交日期'],
['field' => 'remark', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '备注'],
['field' => 'status_id', 'maskType' => 0, 'read' => 1, 'read_operation' => 0, 'write' => 1, 'write_operation' => 0, 'is_diy' => 0, 'name' => '商机阶段'],
['field' => 'type_id', 'maskType' => 0, 'read' => 1, 'read_operation' => 0, 'write' => 1, 'write_operation' => 0, 'is_diy' => 0, 'name' => '商机状态组'],
['field' => 'owner_user_id', 'maskType' => 0, 'read' => 1, 'read_operation' => 0, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '负责人'],
['field' => 'create_user_id', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '创建人'],
['field' => 'create_time', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '创建时间'],
['field' => 'update_time', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '更新时间'],
['field' => 'last_time', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '最后跟进时间'],
];
$BusinessList = Db::name('admin_field')->field(['name', 'field'])->where('types', 'crm_business')->select();
# 自定义字段
foreach ($BusinessList AS $key => $value) {
foreach ($BusinessList as $key => $value) {
if (in_array($value['field'], $this->except['business'])) continue;
$content[] = [
@ -481,32 +488,32 @@ class FieldGrantLogic
{
# 固定字段
$content = [
['field' => 'name', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '合同名称'],
['field' => 'num', 'read' => 1, 'read_operation' => 0, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '合同编号'],
['field' => 'customer_id', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '客户名称'],
['field' => 'business_id', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '商机名称'],
['field' => 'money', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '合同金额'],
['field' => 'order_date', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '下单时间'],
['field' => 'start_time', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '合同开始时间'],
['field' => 'end_time', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '合同结束时间'],
['field' => 'contacts_id', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '客户签约人'],
['field' => 'order_user_id', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '公司签约人'],
['field' => 'remark', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '备注'],
['field' => 'owner_user_id', 'read' => 1, 'read_operation' => 0, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '负责人'],
['field' => 'create_user_id', 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '创建人'],
['field' => 'create_time', 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '创建时间'],
['field' => 'update_time', 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '更新时间'],
['field' => 'last_time', 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '最后跟进时间'],
['field' => 'last_record', 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '最后跟进记录'],
['field' => 'done_money', 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '已收款金额'],
['field' => 'un_money', 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '未收款金额'],
['field' => 'check_status', 'read' => 1, 'read_operation' => 0, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '审核状态'],
['field' => 'name', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '合同名称'],
['field' => 'num', 'maskType' => 0, 'read' => 1, 'read_operation' => 0, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '合同编号'],
['field' => 'customer_id', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '客户名称'],
['field' => 'business_id', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '商机名称'],
['field' => 'money', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '合同金额'],
['field' => 'order_date', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '下单时间'],
['field' => 'start_time', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '合同开始时间'],
['field' => 'end_time', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '合同结束时间'],
['field' => 'contacts_id', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '客户签约人'],
['field' => 'order_user_id', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '公司签约人'],
['field' => 'remark', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '备注'],
['field' => 'owner_user_id', 'maskType' => 0, 'read' => 1, 'read_operation' => 0, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '负责人'],
['field' => 'create_user_id', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '创建人'],
['field' => 'create_time', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '创建时间'],
['field' => 'update_time', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '更新时间'],
['field' => 'last_time', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '最后跟进时间'],
['field' => 'last_record', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '最后跟进记录'],
['field' => 'done_money', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '已收款金额'],
['field' => 'un_money', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '未收款金额'],
['field' => 'check_status', 'maskType' => 0, 'read' => 1, 'read_operation' => 0, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '审核状态'],
];
$contractList = Db::name('admin_field')->field(['name', 'field'])->where('types', 'crm_contract')->select();
# 自定义字段
foreach ($contractList AS $key => $value) {
foreach ($contractList as $key => $value) {
if (in_array($value['field'], $this->except['contract'])) continue;
$content[] = [
@ -541,26 +548,26 @@ class FieldGrantLogic
{
# 固定字段
$content = [
['field' => 'number', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '回款编号'],
['field' => 'customer_id', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '客户名称'],
['field' => 'contract_id', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '合同编号'],
['field' => 'plan_id', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '期数'],
['field' => 'return_time', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '回款日期'],
['field' => 'money', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '回款金额'],
['field' => 'return_type', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '回款方式'],
['field' => 'remark', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '备注'],
['field' => 'contract_money', 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '合同金额'],
['field' => 'owner_user_id', 'read' => 1, 'read_operation' => 0, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '负责人'],
['field' => 'create_user_id', 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '创建人'],
['field' => 'create_time', 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '创建时间'],
['field' => 'update_time', 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '更新时间'],
['field' => 'check_status', 'read' => 1, 'read_operation' => 0, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '审核状态'],
['field' => 'number', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '回款编号'],
['field' => 'customer_id', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '客户名称'],
['field' => 'contract_id', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '合同编号'],
['field' => 'plan_id', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '期数'],
['field' => 'return_time', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '回款日期'],
['field' => 'money', 'maskType' => 0,'form_type'=>'floatnumber', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '回款金额'],
['field' => 'return_type', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '回款方式'],
['field' => 'remark', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '备注'],
['field' => 'contract_money', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '合同金额'],
['field' => 'owner_user_id', 'maskType' => 0, 'read' => 1, 'read_operation' => 0, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '负责人'],
['field' => 'create_user_id', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '创建人'],
['field' => 'create_time', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '创建时间'],
['field' => 'update_time', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '更新时间'],
['field' => 'check_status', 'maskType' => 0, 'read' => 1, 'read_operation' => 0, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '审核状态'],
];
$receivablesList = Db::name('admin_field')->field(['name', 'field'])->where('types', 'crm_receivables')->select();
# 自定义字段
foreach ($receivablesList AS $key => $value) {
foreach ($receivablesList as $key => $value) {
if (in_array($value['field'], $this->except['receivables'])) continue;
$content[] = [
@ -595,23 +602,23 @@ class FieldGrantLogic
{
# 固定字段
$content = [
['field' => 'name', 'read' => 1, 'read_operation' => 0, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '产品名称'],
['field' => 'category_id', 'read' => 1, 'read_operation' => 0, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '产品类型'],
['field' => 'unit', 'read' => 1, 'read_operation' => 0, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '产品单位'],
['field' => 'num', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '产品编码'],
['field' => 'price', 'read' => 1, 'read_operation' => 0, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '价格'],
['field' => 'description', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '产品描述'],
['field' => 'status', 'read' => 1, 'read_operation' => 0, 'write' => 1, 'write_operation' => 0, 'is_diy' => 0, 'name' => '是否上下架'],
['field' => 'owner_user_id', 'read' => 1, 'read_operation' => 0, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '负责人'],
['field' => 'create_user_id', 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '创建人'],
['field' => 'create_time', 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '创建时间'],
['field' => 'update_time', 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '更新时间'],
['field' => 'name', 'maskType' => 0, 'read' => 1, 'read_operation' => 0, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '产品名称'],
['field' => 'category_id', 'maskType' => 0, 'read' => 1, 'read_operation' => 0, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '产品类型'],
['field' => 'unit', 'maskType' => 0, 'read' => 1, 'read_operation' => 0, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '产品单位'],
['field' => 'num', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '产品编码'],
['field' => 'price', 'maskType' => 0, 'read' => 1, 'read_operation' => 0, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '价格'],
['field' => 'description', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '产品描述'],
['field' => 'status', 'maskType' => 0, 'read' => 1, 'read_operation' => 0, 'write' => 1, 'write_operation' => 0, 'is_diy' => 0, 'name' => '是否上下架'],
['field' => 'owner_user_id', 'maskType' => 0, 'read' => 1, 'read_operation' => 0, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '负责人'],
['field' => 'create_user_id', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '创建人'],
['field' => 'create_time', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '创建时间'],
['field' => 'update_time', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '更新时间'],
];
$productList = Db::name('admin_field')->field(['name', 'field'])->where('types', 'crm_product')->select();
# 自定义字段
foreach ($productList AS $key => $value) {
foreach ($productList as $key => $value) {
if (in_array($value['field'], $this->except['product'])) continue;
$content[] = [
@ -645,24 +652,24 @@ class FieldGrantLogic
private function createVisitFieldGrant($roleId)
{
$content = [
['field' => 'number', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '回访编号'],
['field' => 'visit_time', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '回访时间'],
['field' => 'owner_user_id', 'read' => 1, 'read_operation' => 0, 'write' => 1, 'write_operation' => 0, 'is_diy' => 0, 'name' => '回访人'],
['field' => 'shape', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '回访形式'],
['field' => 'customer_id', 'read' => 1, 'read_operation' => 0, 'write' => 1, 'write_operation' => 0, 'is_diy' => 0, 'name' => '客户名称'],
['field' => 'contacts_id', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '联系人'],
['field' => 'contract_id', 'read' => 1, 'read_operation' => 0, 'write' => 1, 'write_operation' => 0, 'is_diy' => 0, 'name' => '合同编号'],
['field' => 'satisfaction', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '客户满意度'],
['field' => 'feedback', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '客户反馈'],
['field' => 'create_user_id', 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '创建人'],
['field' => 'create_time', 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '创建时间'],
['field' => 'update_time', 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '更新时间'],
['field' => 'number', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '回访编号'],
['field' => 'visit_time', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '回访时间'],
['field' => 'owner_user_id', 'maskType' => 0, 'read' => 1, 'read_operation' => 0, 'write' => 1, 'write_operation' => 0, 'is_diy' => 0, 'name' => '回访人'],
['field' => 'shape', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '回访形式'],
['field' => 'customer_id', 'maskType' => 0, 'read' => 1, 'read_operation' => 0, 'write' => 1, 'write_operation' => 0, 'is_diy' => 0, 'name' => '客户名称'],
['field' => 'contacts_id', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '联系人'],
['field' => 'contract_id', 'maskType' => 0, 'read' => 1, 'read_operation' => 0, 'write' => 1, 'write_operation' => 0, 'is_diy' => 0, 'name' => '合同编号'],
['field' => 'satisfaction', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '客户满意度'],
['field' => 'feedback', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '客户反馈'],
['field' => 'create_user_id', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '创建人'],
['field' => 'create_time', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '创建时间'],
['field' => 'update_time', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '更新时间'],
];
$visitList = Db::name('admin_field')->field(['name', 'field'])->where('types', 'crm_visit')->select();
# 处理自定义字段
foreach ($visitList AS $key => $value) {
foreach ($visitList as $key => $value) {
if (in_array($value['field'], $this->except['visit'])) continue;
$content[] = [
@ -687,7 +694,7 @@ class FieldGrantLogic
}
/**
* 处理回访字段授权信息
* 处理发票字段授权信息
*
* @param $roleId
* @author fanqi
@ -696,20 +703,20 @@ class FieldGrantLogic
private function createInvoiceFieldGrant($roleId)
{
$content = [
['field' => 'invoice_apple_number', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '发票申请编号'],
['field' => 'customer_id', 'read' => 1, 'read_operation' => 0, 'write' => 1, 'write_operation' => 0, 'is_diy' => 0, 'name' => '客户名称'],
['field' => 'contract_id', 'read' => 1, 'read_operation' => 0, 'write' => 1, 'write_operation' => 0, 'is_diy' => 0, 'name' => '合同编号'],
['field' => 'contract_money', 'read' => 1, 'read_operation' => 0, 'write' => 1, 'write_operation' => 0, 'is_diy' => 0, 'name' => '合同金额'],
['field' => 'invoice_money', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '开票金额'],
['field' => 'invoice_date', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '开票日期'],
['field' => 'invoice_type', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '开票类型'],
['field' => 'remark', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '备注'],
['field' => 'invoice_apple_number', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '发票申请编号'],
['field' => 'customer_id', 'maskType' => 0, 'read' => 1, 'read_operation' => 0, 'write' => 1, 'write_operation' => 0, 'is_diy' => 0, 'name' => '客户名称'],
['field' => 'contract_id', 'maskType' => 0, 'read' => 1, 'read_operation' => 0, 'write' => 1, 'write_operation' => 0, 'is_diy' => 0, 'name' => '合同编号'],
['field' => 'contract_money', 'maskType' => 0, 'read' => 1, 'read_operation' => 0, 'write' => 1, 'write_operation' => 0, 'is_diy' => 0, 'name' => '合同金额'],
['field' => 'invoice_money', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '开票金额'],
['field' => 'invoice_date', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '开票日期'],
['field' => 'invoice_type', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '开票类型'],
['field' => 'remark', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '备注'],
];
$invoiceList = Db::name('admin_field')->field(['name', 'field'])->where('types', 'crm_invoice')->select();
# 处理自定义字段
foreach ($invoiceList AS $key => $value) {
foreach ($invoiceList as $key => $value) {
if (in_array($value['field'], $this->except['invoice'])) continue;
$content[] = [
@ -732,4 +739,52 @@ class FieldGrantLogic
'update_time' => time()
]);
}
/**
* 处理回款计划字段授权信息
*
* @param int $roleId
* @author fanqi
* @date 2021-03-22
*/
private function createReceivablesPlanFieldGrant($roleId)
{
$content = [
['field' => 'num', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '期数'],
['field' => 'money', 'maskType' => 0, 'form_type'=>'floatnumber', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '计划回款金额'],
['field' => 'owner_user_id', 'maskType' => 0, 'read' => 1, 'read_operation' => 0, 'write' => 1, 'write_operation' => 0, 'is_diy' => 0, 'name' => '负责人'],
['field' => 'return_date', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '计划回款日期'],
['field' => 'customer_id', 'maskType' => 0, 'read' => 1, 'read_operation' => 0, 'write' => 1, 'write_operation' => 0, 'is_diy' => 0, 'name' => '客户名称'],
['field' => 'remind', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0, 'name' => '提前几日提醒'],
['field' => 'contract_id', 'maskType' => 0, 'read' => 1, 'read_operation' => 0, 'write' => 1, 'write_operation' => 0, 'is_diy' => 0, 'name' => '合同编号'],
['field' => 'create_user_id', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '创建人'],
['field' => 'create_time', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '创建时间'],
['field' => 'update_time', 'maskType' => 0, 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0, 'name' => '更新时间'],
];
$visitList = Db::name('admin_field')->field(['name', 'field'])->where('types', 'crm_receivables_plan')->select();
# 处理自定义字段
foreach ($visitList as $key => $value) {
if (in_array($value['field'], $this->except['receivables_plan'])) continue;
$content[] = [
'name' => $value['name'],
'field' => $value['field'],
'read' => 1,
'read_operation' => 1,
'write' => 1,
'write_operation' => 1,
'is_diy' => 1
];
}
Db::name('admin_field_grant')->insert([
'role_id' => $roleId,
'module' => 'crm',
'column' => 'receivables_plan',
'content' => serialize($content),
'create_time' => time(),
'update_time' => time()
]);
}
}

@ -207,12 +207,12 @@ class PrintingLogic
{
$result = [];
$businessList = Db::name('admin_field')->field(['name', 'field'])->where('types', 'crm_business')->select();
$businessList = Db::name('admin_field')->field(['name', 'field','form_type'])->where('types', 'crm_business')->select();
# 处理自定义字段
foreach ($businessList AS $key => $value) {
if ($value['field'] == 'customer_id') continue;
if ($value['form_type']=='detail_table') continue;
$result[] = [
'name' => $value['name'],
'field' => $value['field']
@ -240,13 +240,13 @@ class PrintingLogic
{
$result = [];
$customerList = Db::name('admin_field')->field(['name', 'field'])->where('types', 'crm_customer')->select();
$customerList = Db::name('admin_field')->field(['name', 'field','form_type'])->where('types', 'crm_customer')->select();
# 处理自定义字段
foreach ($customerList AS $key => $value) {
if (in_array($value['field'], ['next_time'])) continue;
if (in_array($type, [5, 6]) && in_array($value['field'], ['deal_status'])) continue;
if ($value['form_type']=='detail_table') continue;
$result[] = [
'name' => $value['name'],
'field' => $value['field']
@ -274,13 +274,13 @@ class PrintingLogic
{
$result = [];
$productList = Db::name('admin_field')->field(['name', 'field'])->where('types', 'crm_product')->select();
$productList = Db::name('admin_field')->field(['name', 'field','form_type'])->where('types', 'crm_product')->select();
# 处理自定义字段
foreach ($productList AS $key => $value) {
if (in_array($value['field'], ['status'])) continue;
if (in_array($type, [5, 6]) && in_array($value['field'], ['description'])) continue;
if ($value['form_type']=='detail_table') continue;
$result[] = [
'name' => $value['name'],
'field' => $value['field']
@ -310,13 +310,13 @@ class PrintingLogic
{
$result = [];
$contractList = Db::name('admin_field')->field(['name', 'field'])->where('types', 'crm_contract')->select();
$contractList = Db::name('admin_field')->field(['name', 'field','form_type'])->where('types', 'crm_contract')->select();
# 处理自定义字段
foreach ($contractList AS $key => $value) {
if (in_array($type, [6, 7]) && in_array($value['field'], ['customer_id'])) continue;
if ($type == 7 && in_array($value['field'], ['business_id'])) continue;
if ($value['form_type']=='detail_table') continue;
$result[] = [
'name' => $value['name'],
'field' => $value['field']
@ -347,12 +347,12 @@ class PrintingLogic
{
$result = [];
$contactsList = Db::name('admin_field')->field(['name', 'field'])->where('types', 'crm_contacts')->select();
$contactsList = Db::name('admin_field')->field(['name', 'field','form_type'])->where('types', 'crm_contacts')->select();
# 处理自定义字段
foreach ($contactsList AS $key => $value) {
if ($value['field'] == 'next_time') continue;
if ($value['form_type']=='detail_table') continue;
$result[] = [
'name' => $value['name'],
'field' => $value['field']
@ -374,13 +374,13 @@ class PrintingLogic
{
$result = [];
$receivablesList = Db::name('admin_field')->field(['name', 'field'])->where('types', 'crm_receivables')->select();
$receivablesList = Db::name('admin_field')->field(['name', 'field','form_type'])->where('types', 'crm_receivables')->select();
# 处理自定义字段
foreach ($receivablesList AS $key => $value) {
if (in_array($value['field'], ['contract_id'])) continue;
if (in_array($type, [7]) && in_array($value['field'], ['contract_id'])) continue;
if ($value['form_type']=='detail_table') continue;
$result[] = [
'name' => $value['name'],
'field' => $value['field']

@ -16,7 +16,7 @@ class ActionRecord extends Common
* 我们约定每个模块的数据表都加上相同的前缀比如CRM模块用crm作为数据表前缀
*/
protected $name = 'admin_action_record';
public $typesArr = ['crm_leads','crm_customer','crm_contacts','crm_product','crm_business','crm_contract','crm_receivables','crm_visit'];
public $typesArr = ['crm_leads','crm_customer','crm_contacts','crm_product','crm_business','crm_contract','crm_receivables','crm_visit','jxc_product','jxc_supplier','jxc_purchase','jxc_retreat','jxc_sale','jxc_salereturn','jxc_receipt','jxc_outbound','jxc_payment','jxc_collection','jxc_inventory','jxc_allocation'];
/**
* [getDataList 获取列表]
@ -92,6 +92,18 @@ class ActionRecord extends Common
case 'crm_visit' :
$checkRes = checkPerByAction('crm', 'visit', 'read');
break;
case 'jxc_product': $checkRes = checkPerByAction('jxc', 'product', 'read'); break;
case 'jxc_supplier': $checkRes = checkPerByAction('jxc', 'supplier', 'read'); break;
case 'jxc_purchase': $checkRes = checkPerByAction('jxc', 'purchase', 'read'); break;
case 'jxc_retreat': $checkRes = checkPerByAction('jxc', 'retreat', 'read'); break;
case 'jxc_sale': $checkRes = checkPerByAction('jxc', 'sale', 'read'); break;
case 'jxc_salereturn': $checkRes = checkPerByAction('jxc', 'salereturn', 'read'); break;
case 'jxc_receipt': $checkRes = checkPerByAction('jxc', 'receipt', 'read'); break;
case 'jxc_outbound': $checkRes = checkPerByAction('jxc', 'outbound', 'read'); break;
case 'jxc_payment': $checkRes = checkPerByAction('jxc', 'payment', 'read'); break;
case 'jxc_collection': $checkRes = checkPerByAction('jxc', 'collection', 'read'); break;
case 'jxc_inventory': $checkRes = checkPerByAction('jxc', 'inventory', 'read'); break;
case 'jxc_allocation': $checkRes = checkPerByAction('jxc', 'allocation', 'read'); break;
}
if ($checkRes !== false) {
return true;

@ -295,9 +295,9 @@ class Common extends Model
*/
public function exportHandle($list, $field_list, $type = '')
{
foreach ($list as &$val) {
foreach ($field_list as $field) {
// p($field);
switch ($field['form_type']) {
case 'user':
if (isset($val[$field['field'] . 'name'])) {
@ -320,6 +320,16 @@ class Common extends Model
case 'contacts':
$val[$field['field']] = $val[$field['field'] . '_info']['name'];
break;
case 'boolean_value':
if( $val[$field['field']]==0){
$val[$field['field']]='否';
}else{
$val[$field['field']]='是';
}
break;
case 'date_interval' :
$val[$field['field']] = implode('_', $val[$field['field']]);
break;
default :
switch ($field['field']) {
// 商机销售阶段、商机状态组
@ -337,6 +347,13 @@ class Common extends Model
case 'plan_id' :
$val[$field['field']] = $val[$field['field'] . '_info'];
break;
case 'warehouse_isuse' :
$val[$field['field']] = $val[$field['field']] == 0 ? '已停用' : '已启用';
break;
default :
if($field['form_type'] == 'text'){
$val[$field['field']] = (string)$val[$field['field']];
}
}
}
}

@ -22,7 +22,7 @@ class ExamineFlow extends Common
protected $createTime = 'create_time';
protected $updateTime = 'update_time';
protected $autoWriteTimestamp = true;
protected $typesArr = ['crm_contract', 'crm_receivables', 'crm_invoice', 'oa_examine'];
protected $typesArr = ['crm_contract', 'crm_receivables', 'crm_invoice', 'oa_examine', 'jxc_purchase', 'jxc_retreat', 'jxc_sale', 'jxc_salereturn', 'jxc_payment', 'jxc_collection', 'jxc_allocation', 'jxc_inventory'];
/**
* [getDataList 审批流程list]

@ -57,13 +57,22 @@ class ExamineRecord extends Common
$result = [];
# 获取创建者信息(业务审批)
if (in_array($param['types'], ['crm_contract', 'crm_receivables', 'crm_invoice'])) {
if (in_array($param['types'], ['crm_contract', 'crm_receivables', 'crm_invoice', 'jxc_purchase', 'jxc_retreat', 'jxc_sale', 'jxc_salereturn', 'jxc_payment', 'jxc_collection', 'jxc_allocation', 'jxc_inventory'])) {
$model = db($param['types']);
$primaryKey = null;
if ($param['types'] == 'crm_contract') $primaryKey = 'contract_id';
if ($param['types'] == 'crm_receivables') $primaryKey = 'receivables_id';
if ($param['types'] == 'crm_invoice') $primaryKey = 'invoice_id';
if ($param['types'] == 'jxc_purchase') $primaryKey = 'purchase_id';
if ($param['types'] == 'jxc_retreat') $primaryKey = 'retreat_id';
if ($param['types'] == 'jxc_sale') $primaryKey = 'sale_id';
if ($param['types'] == 'jxc_salereturn') $primaryKey = 'salereturn_id';
if ($param['types'] == 'jxc_payment') $primaryKey = 'payment_note_id';
if ($param['types'] == 'jxc_collection') $primaryKey = 'collection_note_id';
if ($param['types'] == 'jxc_allocation') $primaryKey = 'allocation_id';
if ($param['types'] == 'jxc_inventory') $primaryKey = 'inventory_id';
$info = $model->field(['create_time', 'owner_user_id'])->where($primaryKey, $param['types_id'])->find();
$userInfo = $userModel->getUserById($info['owner_user_id']);

@ -180,6 +180,14 @@ class ExamineStep extends Common
case 'crm_contract' : $dataInfo = db('crm_contract')->where(['contract_id' => intval($types_id)])->field('create_user_id,owner_user_id,check_user_id,flow_id,order_id,check_status,update_time')->find(); break;
case 'crm_receivables' : $dataInfo = db('crm_receivables')->where(['receivables_id' => intval($types_id)])->field('create_user_id,owner_user_id,check_user_id,flow_id,order_id,check_status,update_time')->find(); break;
case 'crm_invoice': $dataInfo = db('crm_invoice')->where(['invoice_id' => intval($types_id)])->field('create_user_id,owner_user_id,check_user_id,flow_id,order_id,check_status,update_time')->find(); break;
case 'jxc_purchase': $dataInfo = db('jxc_purchase')->where(['purchase_id' => intval($types_id)])->field('create_user_id,owner_user_id,check_user_id,flow_id,order_id,check_status,update_time')->find(); break;
case 'jxc_retreat': $dataInfo = db('jxc_retreat')->where(['retreat_id' => intval($types_id)])->field('create_user_id,owner_user_id,check_user_id,flow_id,order_id,check_status,update_time')->find(); break;
case 'jxc_sale': $dataInfo = db('jxc_sale')->where(['sale_id' => intval($types_id)])->field('create_user_id,owner_user_id,check_user_id,flow_id,order_id,check_status,update_time')->find(); break;
case 'jxc_salereturn': $dataInfo = db('jxc_salereturn')->where(['salereturn_id' => intval($types_id)])->field('create_user_id,owner_user_id,check_user_id,flow_id,order_id,check_status,update_time')->find(); break;
case 'jxc_payment': $dataInfo = db('jxc_payment')->where(['payment_note_id' => intval($types_id)])->field('create_user_id,owner_user_id,check_user_id,flow_id,order_id,check_status,update_time')->find(); break;
case 'jxc_collection': $dataInfo = db('jxc_collection')->where(['collection_note_id' => intval($types_id)])->field('create_user_id,owner_user_id,check_user_id,flow_id,order_id,check_status,update_time')->find(); break;
case 'jxc_inventory': $dataInfo = db('jxc_inventory')->where(['inventory_id' => intval($types_id)])->field('create_user_id,owner_user_id,check_user_id,flow_id,order_id,check_status,update_time')->find(); break;
case 'jxc_allocation': $dataInfo = db('jxc_allocation')->where(['allocation_id' => intval($types_id)])->field('create_user_id,owner_user_id,check_user_id,flow_id,order_id,check_status,update_time')->find(); break;
}
$stepInfo = [];
if ($dataInfo['flow_id'] && !in_array($dataInfo['check_status'],['5'])) {

@ -399,15 +399,15 @@ class Excel extends Common
}
// 排队中
if (!$queue->canExec()) {
return resultArray([
'data' => [
'page' => -2,
'export_queue_index' => $export_queue_index,
'info' => $queue->error
]
]);
}
// if (!$queue->canExec()) {
// return resultArray([
// 'data' => [
// 'page' => -2,
// 'export_queue_index' => $export_queue_index,
// 'info' => $queue->error
// ]
// ]);
// }
// 没有临时文件名,代表第一次导出,生成临时文件名称,并写入表头数据
if ($temp_file === null) {
@ -468,7 +468,7 @@ class Excel extends Common
if (is_numeric($val[$rule['field']]) && strlen($val[$rule['field']]) > 15) {
$val[$rule['field']] = "\t" . $val[$rule['field']] . "\t";
}
$rows[] = $fieldModel->getValueByFormtype($val[$rule['field']], $rule['form_type']);
$rows[] = $fieldModel->getValueByFormtype($val[$rule['field']], $rule['form_type'],$val);
}
}
fputcsv($fp, $rows);
@ -519,11 +519,7 @@ class Excel extends Common
$queue->dequeue();
return false;
}
if (!empty($param['pool_id'])) {
$user_id = $param['create_user_id'];
} else {
$user_id = $param['owner_user_id'];
}
// 采用伪队列 允许三人同时导入数据
$queue = new Queue(self::IMPORT_QUEUE, 50000000);
$import_queue_index = input('import_queue_index');
@ -687,6 +683,7 @@ class Excel extends Common
$fieldModel = new \app\admin\model\Field();
$fieldParam['types'] = $types;
$fieldParam['action'] = 'excel';
if (!empty($param['pool_id'])) {
$list = [];
$field_list = db('crm_customer_pool_field_setting')->where(['pool_id' => $param['pool_id'], 'is_hidden' => 0,
@ -765,6 +762,7 @@ class Excel extends Common
}
}
}
// 每次导入条数
$page_size = 100;
@ -812,6 +810,7 @@ class Excel extends Common
'update_time' => time(),
];
}
if ($temp !== count($field_list)) {
@unlink($save_path);
$queue->dequeue();
@ -920,7 +919,7 @@ class Excel extends Common
$userId = db('admin_user')->where('realname', $val[2])->value('id');
$data['owner_user_id'] = $userId ?: 0;
}
$owner = db('crm_customer_pool')->where(['pool_id' => $param['pool_id']])->value('admin_user_ids');
$owner = db('crm_customer_pool')->where(['pool_id' => $param['pool_id']])->value('user_ids');
$auth = db('admin_access')->where('user_id', $param['create_user_id'])->column('group_id');
// 数据重复时
if ($old_data_id_list) {
@ -933,11 +932,7 @@ class Excel extends Common
$up_success_count = 0;
foreach ($old_data_id_list as $id) {
if ($types == 'crm_customer' && !empty($param['pool_id'])) {
if (!in_array($param['create_user_id'], trim(stringToArray($owner), ',')) && !in_array(1, $auth) && $param['create_user_id'] != 1) {
$temp_error = '当前导入人员对该公海数据,无导入权限';
$error_data_func($val, $temp_error);
break;
} else {
if (!in_array($param['create_user_id'], trim(stringToArray($owner), ',')) && $param['create_user_id'] != 1) {
if (!$dataModel->updateDataById($data, $id)) {
$temp_error = $dataModel->getError();
if ($temp_error == '无权操作') {
@ -947,6 +942,10 @@ class Excel extends Common
$dataModel->rollback();
break;
}
break;
} else {
$temp_error = '当前导入人员对该公海数据,无导入权限';
$error_data_func($val, $temp_error);
}
} else {
if (!$dataModel->updateDataById($data, $id)) {
@ -985,15 +984,16 @@ class Excel extends Common
}
} else {
if ($types == 'crm_customer' && !empty($param['pool_id'])) {
if (!in_array($param['create_user_id'], trim(stringToArray($owner), ',')) && !in_array(1, $auth) && $param['create_user_id'] != 1) {
$temp_error = '当前导入人员对该公海数据,无导入权限';
$error_data_func($val, $temp_error);
} else {
if (!in_array($param['create_user_id'], trim(stringToArray($owner), ',')) && $param['create_user_id'] != 1) {
$data = array_merge($data, $default_data);
$data['excel'] = 1;
if (!$resData = $dataModel->createData($data)) {
$error_data_func($val, $dataModel->getError());
}
} else {
$temp_error = '当前导入人员对该公海数据,无导入权限';
$error_data_func($val, $temp_error);
}
} else {
$data = array_merge($data, $default_data);
@ -2013,7 +2013,7 @@ class Excel extends Common
}
// 开始行 +2 跳过表头
$start_row = ($page - 1) * $page_size + 2;
$start_row = ($page - 1) * $page_size + 3;
// 结束行
$end_row = $start_row + $page_size - 1;
if ($end_row > $max_row) {
@ -2032,10 +2032,14 @@ class Excel extends Common
];
// 开始导入数据
foreach ($dataList as $val) {
$data = [];
$empty_count = 0;
$not_null_field = [];
$fk = 0;
foreach ($field_list as $field) {
$temp_value = trim($val[$fk]);
// 特殊字段特殊处理
$temp_value = $this->handleData($temp_value, $field);
// $temp_value = $this->handleData($temp_value, $field);
$data[$field['field']] = $temp_value;
if ($temp_value == '') {
if ($field['is_null']) {
@ -2053,8 +2057,6 @@ class Excel extends Common
$error_data_func($val, '空行');
continue;
}
$data = [];
$fk = 0;
$classData = db('work_task_class')->where(['name' => $val[6], 'work_id' => $param['work_id']])->order('class_id', 'asc')->select();
$max_order_id = db('work_task_class')->where(['work_id' => $param['work_id'], 'status' => 1])->max('order_id');
if ($classData[0]['class_id'] != '') {
@ -2071,7 +2073,6 @@ class Excel extends Common
$data['class_id'] = db('work_task_class')->insertGetId($item);
}
$dataModel = new \app\work\model\Task();
$data = array_merge($data, $default_data);
if (!$resData = $dataModel->createTask($data)) {
$error_data_func($val, $dataModel->getError());
@ -2445,7 +2446,7 @@ class Excel extends Common
$this->batchTaskImportData('', $excelData);
} elseif ($base == 'ActivityImport') {
$this->ActivityImport('', $excelData);
} else {
} elseif($base == 'batchImportData') {
$this->batchImportData('', $excelData);
}
$data = 0;

@ -43,9 +43,22 @@ class Field extends Model
'crm_receivables_plan',
'crm_invoice',
'crm_visit',
'jxc_product',
'jxc_supplier',
'jxc_purchase',
'jxc_retreat',
'jxc_sale',
'jxc_salereturn',
'jxc_receipt',
'jxc_outbound',
'jxc_payment',
'jxc_collection',
'jxc_inventory',
'jxc_allocation',
]; //支持自定义字段的表,不包含表前缀
private $formtype_arr = [
'text',
'pic',
'textarea',
'mobile',
'email',
@ -209,8 +222,129 @@ class Field extends Model
'width' => '',
'is_hidden' => 0,
]
],
'jxc_supplier' => [
[
'field' => 'detail_address',
'name' => '地址',
'form_type' => 'map_address',
'width' => '',
'is_hidden' => 0,
]
],
'jxc_purchase' => [
[
'field' => 'check_status',
'name' => '审核状态',
'form_type' => 'text',
'width' => '',
'is_hidden' => 0,
]
],
'jxc_retreat' => [
[
'field' => 'check_status',
'name' => '审核状态',
'form_type' => 'text',
'width' => '',
'is_hidden' => 0,
]
],
'jxc_product' => [
[
'field' => 'product_code',
'name' => '产品编码',
'form_type' => 'text',
'width' => '',
'is_hidden' => 0,
],
[
'field' => 'product_picture',
'name' => '产品图片',
'form_type' => 'text',
'width' => '',
'is_hidden' => 0,
],
[
'field' => 'sp_data_value',
'name' => '产品规格',
'form_type' => 'text',
'width' => '',
'is_hidden' => 0,
]
],
'jxc_sale' => [
[
'field' => 'check_status',
'name' => '审核状态',
'form_type' => 'text',
'width' => '',
'is_hidden' => 0,
]
],
'jxc_salereturn' => [
[
'field' => 'check_status',
'name' => '审核状态',
'form_type' => 'text',
'width' => '',
'is_hidden' => 0,
]
],
'jxc_receipt' => [
[
'field' => 'state',
'name' => '状态',
'form_type' => 'text',
'width' => '',
'is_hidden' => 0,
]
],
'jxc_outbound' => [
[
'field' => 'state',
'name' => '状态',
'form_type' => 'text',
'width' => '',
'is_hidden' => 0,
]
],
'jxc_allocation' => [
[
'field' => 'check_status',
'name' => '审核状态',
'form_type' => 'text',
'width' => '',
'is_hidden' => 0,
]
],
'jxc_inventory' => [
[
'field' => 'check_status',
'name' => '审核状态',
'form_type' => 'text',
'width' => '',
'is_hidden' => 0,
]
],
'jxc_collection' => [
[
'field' => 'check_status',
'name' => '审核状态',
'form_type' => 'text',
'width' => '',
'is_hidden' => 0,
]
],
'jxc_payment' => [
[
'field' => 'check_status',
'name' => '审核状态',
'form_type' => 'text',
'width' => '',
'is_hidden' => 0,
]
],
];
protected function initialize()
@ -238,18 +372,28 @@ class Field extends Model
if ($param['types'] == 'crm_customer') {
$map['field'] = array('not in', ['deal_status']);
}
if ($types == 'crm_receivables_plan') {
$setting = Db::name('AdminField')->where('types', 'crm_receivables')->value('setting');
}
$list = Db::name('AdminField')->where($map)->order('form_position', 'asc')->select();
$detailTableList = db('admin_field_extend')->field(['field', 'content'])->where('types', $types)->select();
$detailTableData = [];
foreach ($detailTableList as $key => $value) {
$detailTableData[$value['field']] = !empty($value['content']) ? json_decode($value['content']) : [];
$detailTableData[$value['field']] = !empty($value['content']) ? json_decode($value['content'], true) : [];
}
foreach ($list as $k => $v) {
$list[$k]['setting'] = $v['setting'] ? explode(chr(10), $v['setting']) : [];
if ($types == 'crm_receivables_plan') {
$list[$k]['stting'] = $setting ? explode(chr(10), $v['setting']) : [];
}
if ($v['form_type'] == 'checkbox') {
$list[$k]['default_value'] = $v['default_value'] ? explode(',', $v['default_value']) : array();
}
if (in_array($v['form_type'], ['position', 'date_interval'])) {
if ($v['form_type']=='date_interval') {
$list[$k]['default_value'] = !empty($v['default_value']) ? explode(',',$v['default_value']) : [];
}
if($v['form_type']=='position'){
$list[$k]['default_value'] = !empty($v['default_value']) ? json_decode($v['default_value'], true) : [];
}
if ($v['form_type'] == 'detail_table') {
@ -260,6 +404,9 @@ class Field extends Model
$list[$k]['xaxis'] = (int)$coordinate[0];
$list[$k]['yaxis'] = (int)$coordinate[1];
}
if (!empty($v['relevant'])) {
$list[$k]['relevant'] = !empty($v['relevant']) ? (int)$v['relevant'] : [];
}
if (!empty($v['options'])) {
$list[$k]['optionsData'] = json_decode($v['options'], true);
} else {
@ -268,6 +415,8 @@ class Field extends Model
// 处理数值范围字段
$list[$k]['minNumRestrict'] = $v['min_num_restrict'];
$list[$k]['maxNumRestrict'] = $v['max_num_restrict'];
unset($list[$k]['min_num_restrict']);
unset($list[$k]['max_num_restrict']);
}
return getFieldGroupOrderData((array)$list);
@ -291,7 +440,6 @@ class Field extends Model
$this->error = '参数错误';
return false;
}
# 公海数据
$poolList = [];
$poolData = [];
@ -312,6 +460,10 @@ class Field extends Model
// 设置$formAssistId值
$formAssistId += 1;
$data['formAssistId'] = $formAssistId;
// 数值范围
if (!empty($data['minNumRestrict'])) $data['min_num_restrict'] = $data['minNumRestrict'];
if (!empty($data['maxNumRestrict'])) $data['max_num_restrict'] = $data['maxNumRestrict'];
// 清除坐标
unset($data['xaxis']);
unset($data['yaxis']);
@ -327,9 +479,11 @@ class Field extends Model
$error_message[] = $data['name'] . '参数错误';
}
$data['types_id'] = $data['types_id'] ?: 0;
if (!in_array($data['form_type'], $this->formtype_arr)) {
$error_message[] = $data['name'] . ',字段类型错误';
}
//生成字段名
if (!$data['field']) $data['field'] = $this->createField($types, $types == 'oa_examine' ? 'oa_' : 'crm_');
@ -371,9 +525,9 @@ class Field extends Model
}
# 处理日期区间、地址类型的默认数据
if (in_array($data['form_type'], ['position', 'date_interval']) && !empty($data['default_value'])) {
$data['default_value'] = json_encode($data['default_value'], JSON_NUMERIC_CHECK);
}
// if (in_array($data['form_type'], ['position', 'date_interval']) && !empty($data['default_value'])) {
// $data['default_value'] = json_encode($data['default_value']);
// }
# 处理明细表格中的字段数据
if ($data['form_type'] == 'detail_table' && !empty($data['fieldExtendList']) && $this->setDetailTableData($types, $data['field'], $data['fieldExtendList']) === false) {
@ -389,11 +543,6 @@ class Field extends Model
if (empty($data['name']) && $data['form_type'] == 'desc_text') {
$data['name'] = '描述文字';
}
// 数值范围
if (!empty($data['minNumRestrict'])) $data['min_num_restrict'] = $data['minNumRestrict'];
if (!empty($data['maxNumRestrict'])) $data['max_num_restrict'] = $data['maxNumRestrict'];
unset($data['field_id']);
if ($i > 1) {
@ -547,7 +696,7 @@ class Field extends Model
* @return [array]
* @author Michael_xu
*/
public function settingValue($data)
public function settingValue($data, $controller = '')
{
//将英文逗号转换为中文逗号
$new_setting = [];
@ -559,11 +708,15 @@ class Field extends Model
$data['setting'] = implode(chr(10), $new_setting);
//默认值
$new_default_value = [];
if ($data['default_value'] && $data['form_type'] == 'checkbox') {
if ($data['default_value'] && $data['form_type'] == 'checkbox' && !empty($data['default_value'])) {
foreach ($data['default_value'] as $k => $v) {
$new_default_value[] = str_replace(',', '', $v);
}
$data['default_value'] = implode(',', $new_default_value);
}elseif($data['default_value'] && $data['form_type'] == 'select' && !empty($data['default_value'])){
$data['default_value'] = $data['default_value'];
} else {
$data['default_value'] = '';
}
return $data;
}
@ -597,7 +750,6 @@ class Field extends Model
// 获取最大formAssistId
$formAssistId = db('admin_field')->where('types', $types)->order('formAssistId', 'desc')->value('formAssistId');
$formAssistId = !empty($formAssistId) ? $formAssistId : 1000;
$i = 0;
foreach ($param as $data) {
// 设置formAssistId
@ -605,6 +757,17 @@ class Field extends Model
$formAssistId += 1;
$data['formAssistId'] = $formAssistId;
}
// 数值范围
if (!empty($data['minNumRestrict'])) {
$data['min_num_restrict'] = $data['minNumRestrict'];
}else{
$data['min_num_restrict']='';
}
if (!empty($data['maxNumRestrict'])){
$data['max_num_restrict'] = $data['maxNumRestrict'];
}else{
$data['max_num_restrict'] = '';
}
// 清除坐标
unset($data['xaxis']);
unset($data['yaxis']);
@ -628,7 +791,7 @@ class Field extends Model
//单选、下拉、多选类型(使用回车符隔开)
if (in_array($data['form_type'], ['radio', 'select', 'checkbox']) && $data['setting']) {
//将英文逗号转换为中文逗号
$data = $this->settingValue($data);
$data = $this->settingValue($data, 'update');
}
// 验证
$validate = validate($this->name);
@ -644,9 +807,11 @@ class Field extends Model
// }
# 处理日期区间、地址类型的默认数据
if (in_array($data['form_type'], ['position', 'date_interval']) && !empty($data['default_value'])) {
$data['default_value'] = json_encode($data['default_value'], JSON_NUMERIC_CHECK);
}
// if (in_array($data['form_type'], ['position']) && !empty($data['default_value'])) {
// dump($data['default_value']);
// p(json_encode($data['default_value']));
// $data['default_value'] = json_encode($data['default_value']);
// }
# 处理明细表格中的字段数据
if ($data['form_type'] == 'detail_table' && !empty($data['fieldExtendList']) && $this->setDetailTableData($data['types'], $data['field'], $data['fieldExtendList']) === false) {
@ -659,11 +824,6 @@ class Field extends Model
// $data['options'] = json_encode($data['options'], JSON_NUMERIC_CHECK);
// }
// 数值范围
if (!empty($data['minNumRestrict'])) $data['min_num_restrict'] = $data['minNumRestrict'];
if (!empty($data['maxNumRestrict'])) $data['max_num_restrict'] = $data['maxNumRestrict'];
if (isset($data['minNumRestrict'])) unset($data['minNumRestrict']);
if (isset($data['maxNumRestrict'])) unset($data['maxNumRestrict']);
// $resField = $this->allowField(true)->save($data, ['field_id' => $field_id]);
unset($data['showSetting']);
@ -817,6 +977,7 @@ class Field extends Model
if (!$resData) {
$delMessage[] = $dataInfo['name'] . ',删除失败';
}
//删除列表字段配置数据
$userFieldList = db('admin_user_field')->where(['types' => $dataInfo['types']])->select();
foreach ($userFieldList as $key => $val) {
@ -829,7 +990,9 @@ class Field extends Model
$dataUserField = [];
$dataUserField['value'] = $datas;
$dataUserField['hide_value'] = [];
$resUserField = model('UserField')->updateConfig($dataInfo['types'], $dataUserField, $val['id']);
$userFieldModel = new \app\admin\model\UserField();
$resUserField = $userFieldModel->updateConfig($dataInfo['types'], $dataUserField, $val['id']);
// $resUserField = model('UserField')->updateConfig($dataInfo['types'], $dataUserField, $val['id']);
}
}
//删除场景字段数据
@ -952,18 +1115,25 @@ class Field extends Model
$order = 'order_id asc, field_id asc';
if ($param['action'] == 'index' || $param['action'] == 'pool') {
$field_list = $this->getIndexFieldConfig($types, $param['user_id']);
$field_list[] = [
'field' => 'owner_user_structure_name',
'name' => '所属部门',
'form_type' => 'structure',
'writeStatus' => 0,
'is_hidden' => 1,
'fieldName' => 'owner_user_structure_name'
];
foreach ($field_list as $k => $v) {
# 处理字段授权
$field_list[$k]['writeStatus'] = 1;
if (!$userLevel && $param['module'] == 'crm' && !empty($grantData[$param['types']])) {
$status = getFieldGrantStatus($v['field'], $grantData[$param['types']]);
# 查看权限
if ($status['read'] == 0) {
unset($field_list[(int)$k]);
continue;
}
$field_list[$k]['maskType'] = $status['maskType'];
# 编辑权限
$field_list[$k]['writeStatus'] = $status['write'];
}
@ -999,23 +1169,22 @@ class Field extends Model
];
}
} else {
$fields = 'field_id,field,types,name,form_type,default_value,is_unique,is_null,input_tips,setting,is_hidden,form_position,precisions,options,style_percent,formAssistId';
$fields = 'field_id,field,types,name,max_num_restrict as maxNumRestrict,min_num_restrict as minNumRestrict,form_type,default_value,is_unique,is_null,input_tips,setting,is_hidden,form_position,precisions,options,style_percent,formAssistId,remark';
$field_list = db('admin_field')->field($fields)->where($map)->where('is_hidden', 0)->order($order)->select();
// 获取X坐标值
$x = $this->getFormPositionXValue($types, $types_id);
# 详情页面增加负责人字段
if ($param['action'] == 'read' && !in_array($param['types'], ['crm_visit', 'crm_product', 'oa_examine', 'crm_invoice'])) {
$field_list[] = [
'field' => 'owner_user_id',
'name' => '负责人',
'form_type' => 'user',
'writeStatus' => 0,
'fieldName' => 'owner_user_name',
'value' => $dataInfo['owner_user_name'],
];
}
// if ($param['action'] == 'read' && !in_array($param['types'], ['crm_visit', 'crm_product', 'oa_examine', 'crm_invoice'])) {
// $field_list[] = [
// 'field' => 'owner_user_id',
// 'name' => '负责人',
// 'form_type' => 'user',
// 'writeStatus' => 0,
// 'fieldName' => 'owner_user_name',
// 'value' => $dataInfo['owner_user_name'],
// ];
// }
//客户
if (in_array($param['types'], ['crm_customer'])) {
@ -1072,9 +1241,9 @@ class Field extends Model
];
}
# 产品基本信息增加负责人信息
if ($param['action'] == 'read' && $param['types'] == 'crm_product') {
$new_field_list[] = db('admin_field')->where(['types_id' => 0, 'field' => 'owner_user_id'])->find();
}
// if ($param['action'] == 'read' && $param['types'] == 'crm_product') {
// $new_field_list[] = db('admin_field')->where(['types_id' => 0, 'field' => 'owner_user_id'])->find();
// }
if ($new_field_list) $field_list = array_merge(collection($field_list)->toArray(), $new_field_list);
foreach ($field_list as $k => $v) {
# 处理字段授权
@ -1084,12 +1253,20 @@ class Field extends Model
# 查看权限
if (empty($status['read'])) {
unset($field_list[(int)$k]);
continue;
}
# 编辑权限
if ($param['action'] != 'save') $field_list[$k]['writeStatus'] = $status['write'];
}
if ($param['action'] == 'read') {
$field_list[$k]['maskType'] = $status['maskType'];
if($status['maskType']!=0){
$field_list[$k]['writeStatus'] = 0;
}
}
# (联系人,商机,合同,回款,回访)关联其他模块的字段在详情页面不允许修改;创建人、负责人不允许修改
@ -1154,7 +1331,7 @@ class Field extends Model
];
} elseif ($v['form_type'] == 'user') {
$value = $userModel->getListByStr($dataInfo[$v['field']]) ?: [];
if (empty($value)) $default_value = $userModel->getListByStr($param['user_id']) ?: [];
// if (empty($value)) $default_value = $userModel->getListByStr($param['user_id']) ?: [];
} elseif ($v['form_type'] == 'single_user') {
# 单用户
$userInfo = $userModel->getListByStr($dataInfo[$v['field']]);
@ -1285,20 +1462,96 @@ class Field extends Model
} elseif ($v['form_type'] == 'desc_text') {
// 描述文字
$value = !empty($dataInfo[$v['field']]) ? $dataInfo[$v['field']] : $v['default_value'];
} elseif (in_array($v['form_type'], ['position', 'location', 'date_interval', 'detail_table'])) {
} elseif ($v['form_type']=='location') {
// 地址、定位、日期区间、明细表格
$primaryKey = getPrimaryKeyName($param['types']);
$positionJson = !empty($dataInfo[$primaryKey]) ? db($param['types'] . '_data')->where([$primaryKey => $dataInfo[$primaryKey], 'field' => $v['field']])->value($param['types'] == 'oa_examine' ? 'value' : 'content') : '';
$positionData = !empty($positionJson) ? json_decode($positionJson, true) : '';
$value = $positionData;
} elseif($v['form_type']=='detail_table'){
// $fieldGrant = db('admin_field_mask')->where('types', 'contract')->select();
$primaryKey = getPrimaryKeyName($param['types']);
$positionJson = !empty($dataInfo[$primaryKey]) ? db($param['types'] . '_data')->where([$primaryKey => $dataInfo[$primaryKey], 'field' => $v['field']])->value($param['types'] == 'oa_examine' ? 'value' : 'content') : '';
$positionData = !empty($positionJson) ? json_decode($positionJson, true) : '';
foreach ($positionData as $kk => $val){
foreach ($val as $key => $values){
if($values['form_type']=='user'){
$positionData[$kk][$key]['value']= !empty($values['value'])?$userModel->getListByStr($values['value']) :[];
}
if($values['form_type']=='structure'){
$positionData[$kk][$key]['value']= !empty($values['value'])? $structureModel->getListByStr($values['value']) : [];
}
if($values['form_type']=='datetime' && is_numeric($values['value'])){
$positionData[$kk][$key]['value']= date('Y-m-d, H:i:s',$values['value']);
}
if($values['form_type']=='boolean_value'){
$positionData[$kk][$key]['value']= (string)$values['value'];
}
if($values['form_type']=='file'){
$fileIds = stringToArray($values['value']);
$whereFile = [];
$whereFile['module'] = 'other';
$whereFile['module_id'] = 1;
$whereFile['file_id'] = ['in', $fileIds];
$fileList = $fileModel->getDataList($whereFile, 'all');
$positionData[$kk][$key]['value'] = $fileList['list'] ?: [];
}
// foreach ($fieldGrant as $val) {
// if (in_array($val['statue_type'], [1, 3]) && $val['form_type'] == ['mobile']) {
// $positionData[$kk][$key]['value'] = !empty($values['value']) ? (string)substr_replace($values['value'], '*', 2, 4) : null;
// } elseif (in_array($val['statue_type'], [1, 3]) && $val['form_type'] == ['email']) {
// $email_array = explode("@", $values['value']);
// $str = substr_replace($email_array[0], '*', 1);
// $positionData[$kk][$key]['value'] = !empty($values['value']) ? (string)$str . $email_array[1] : null;
// } elseif (in_array($val['statue_type'], [1, 3]) && in_array($val['form_type'],['position','floatnumber'])) {
// $positionData[$kk][$key]['value'] = !empty($dataInfo[$val['fiele_id']]) ? (string)substr_replace($values['value'], '*',0,strlen($values['value'])) : null;
// }
// }
$positionData[$kk][$key]['optionsData']=!empty($field_list[$k]['options']) ? json_decode($field_list[$k]['options'], true) : '';
}
}
$value = $positionData;
if ($v['form_type'] == 'detail_table') {
$content = db('admin_field_extend')->where(['types' => $types, 'field' => $v['field']])->value('content');
$field_list[$k]['fieldExtendList'] = json_decode($content, true);
$content=json_decode($content, true);
foreach ($content as &$vv){
$vv['optionsData']=!empty($field_list[$k]['options']) ? json_decode($field_list[$k]['options'], true) : '';
}
$field_list[$k]['fieldExtendList'] = $content;
}
} elseif($v['form_type']=='position'){
// 地址
$default_value = !empty($v['default_value']) ? json_decode($v['default_value'], true) : [];
if(!empty($dataInfo[$v['field']])){
$position= explode(',',$dataInfo[$v['field']]);
for ($i=0; $i<count($position); $i++) {
$b[]['name'] =trim(json_encode($position[$i],JSON_UNESCAPED_UNICODE),'"');
}
$value =$b;
}
} elseif($v['form_type']=='date_interval'){
if (!empty($dataInfo[$v['field']])) {
$position= explode('_',$dataInfo[$v['field']]);
$value =$position;
}
$default_value = !empty($v['default_value'])?explode(',',$v['default_value']):[];
} else {
$value = isset($dataInfo[$v['field']]) ? $dataInfo[$v['field']] : '';
}
// $fieldGrant = db('admin_field_mask')->where('types', 'contract')->select();
// foreach ($fieldGrant as $val) {
// if (in_array($val['statue_type'], [1, 3]) && $val['form_type'] == ['mobile']) {
// $value = !empty($dataInfo[$val['fiele_id']]) ? (string)substr_replace($dataInfo[$val['fiele_id']], '*', 2, 4) : null;
// } elseif (in_array($val['statue_type'], [1, 3]) && $val['form_type'] == ['email']) {
// $email_array = explode("@", $dataInfo[$val['fiele_id']]);
// $str = substr_replace($email_array[0], '*', 1);
// $value = !empty($dataInfo[$val['fiele_id']]) ? (string)$str . $email_array[1] : null;
// } elseif (in_array($val['statue_type'], [1, 3]) && in_array($val['form_type'],['position','floatnumber'])) {
// $value = !empty($dataInfo[$val['fiele_id']]) ? (string)substr_replace($dataInfo[$val['fiele_id']], '*',0,strlen($dataInfo[$val['fiele_id']])) : null;
// }
// }
$field_list[$k]['setting'] = $setting;
$field_list[$k]['default_value'] = $default_value;
$field_list[$k]['value'] = $value;
@ -1347,7 +1600,7 @@ class Field extends Model
$userModel = new \app\admin\model\User();
$user_id = $param['user_id'];
$map['types'] = ['in', ['', $types]];
$map['form_type'] = ['not in', ['file', 'form', 'business_status', 'detail_table', 'desc_text', 'handwriting_sign', 'date_interval']];
$map['form_type'] = ['not in', ['file', 'pic', 'structure', 'form', 'business_status', 'detail_table', 'desc_text', 'handwriting_sign', 'date_interval']];
$map['is_hidden'] = 0;
$field_list = db('admin_field')
->where($map)
@ -1415,6 +1668,12 @@ class Field extends Model
$field_list[$k]['form_type'] = 'module';
$field_list[$k]['field'] = 'contacts_name';
}
if ($v['field'] == 'warehouse_id' && in_array($param['types'], ['jxc_receipt', 'jxc_outbound'])) {
$field_list[$k]['form_type'] = 'text';
}
if ($v['form_type'] == 'warehouse_cause') {
$field_list[$k]['form_type'] = 'text';
}
if ($v['form_type'] == 'category') {
@ -1521,7 +1780,6 @@ class Field extends Model
$userFieldData = $userFieldData ? json_decode($userFieldData, true) : [];
$grantData = getFieldGrantData($user_id);
$userLevel = isSuperAdministrators($user_id);
$fieldList = $this->getFieldList($types, $types_id, $excel);
$where = [];
if ($userFieldData) {
@ -1551,12 +1809,11 @@ class Field extends Model
foreach ($dataList as $k => $v) {
if (!$userLevel && !empty($grantData[$types])) {
$status = getFieldGrantStatus($v['field'], $grantData[$types]);
$dataList[(int)$k]['maskType']=$status['maskType'];
# 查看权限
if ($status['read'] == 0) unset($dataList[(int)$k]);
}
}
return array_values($dataList) ?: [];
}
@ -1576,9 +1833,12 @@ class Field extends Model
$unField = ['owner_user_id'];
}
if ($excel == 'excel') {
if ($types == 'jxc_product') {
$unField = ['product_picture'];
}
$where = [
'types' => ['IN', ['', $newTypes]],
'form_type' => ['not in', ['file', 'form', 'deal_status','position','location','handwriting_sign','date_interval','detail_table','desc_text','boolean_value']],
'form_type' => ['not in', ['file', 'form', 'pic', 'deal_status', 'handwriting_sign', 'detail_table', 'desc_text']],
'field' => ['not in', $unField],
'types_id' => ['eq', $types_id],
'is_hidden' => 0
@ -1609,9 +1869,11 @@ class Field extends Model
}
if (isset($this->orther_field_list[$newTypes])) {
foreach ($this->orther_field_list[$newTypes] as $val) {
if($val['field'] != 'product_picture'){
$res[] = $val;
}
}
}
if ($types == 'crm_customer') {
$res[] = [
@ -1626,8 +1888,26 @@ class Field extends Model
'form_type' => 'text',
'is_hidden' => 0
];
} elseif ($types == 'crm_receivables_plan') {
$res[] = [
'field' => 'real_money',
'name' => '实际回款金额',
'form_type' => 'floatnumber',
'is_hidden' => 0
];
$res[] = [
'field' => 'real_data',
'name' => '实际回款日期',
'form_type' => 'date',
'is_hidden' => 0
];
$res[] = [
'field' => 'un_money',
'name' => '未回金额',
'form_type' => 'floatnumber',
'is_hidden' => 0
];
}
return array_column($res, null, 'field');
}
@ -1724,6 +2004,15 @@ class Field extends Model
}
$sysField = ['invoice.invoice_id', 'invoice.owner_user_id', 'invoice.invoice_status', 'invoice.invoice_number', 'invoice.invoice_type', 'invoice.check_status', 'invoice.customer_id', 'invoice.contract_id', 'invoice.create_user_id', 'invoice.flow_id', 'invoice.real_invoice_date', 'invoice.logistics_number'];
break;
case 'crm_receivables_plan' :
$newList = [];
foreach ($dataList as $k => $v) {
$newList[] = 'receivables_plan.' . $v;
}
$sysField = ['receivables_plan.plan_id', 'receivables_plan.num', 'receivables_plan.receivables_id', 'receivables_plan.status', 'receivables_plan.contract_id', 'receivables_plan.customer_id', 'receivables_plan.money', 'receivables_plan.return_date', 'receivables_plan.return_type', 'receivables_plan.remind', 'receivables_plan.remind_date', 'receivables_plan.remark',
'receivables_plan.create_user_id', 'receivables_plan.owner_user_id', 'receivables_plan.create_time', 'receivables_plan.update_time', 'receivables_plan.file', 'receivables_plan.is_dealt', 'receivables_plan.un_money', 'receivables_plan.real_data', 'receivables_plan.real_money'
];
break;
}
$listArr = $sysField ? array_unique(array_merge($newList, $sysField)) : $dataList;
} else {
@ -1877,6 +2166,42 @@ class Field extends Model
case 'oa_examine' :
$dataModel = db('oa_examine');
break;
case 'jxc_supplier' :
$dataModel = new \app\jxc\model\Supplier();//db('jxc_supplier');
break;
case 'jxc_product' :
$dataModel = db('jxc_product');
break;
case 'jxc_purchase' :
$dataModel = db('jxc_purchase');
break;
case 'jxc_retreat' :
$dataModel = db('jxc_retreat');
break;
case 'jxc_sale' :
$dataModel = db('jxc_sale');
break;
case 'jxc_salereturn' :
$dataModel = db('jxc_salereturn');
break;
case 'jxc_receipt' :
$dataModel = db('jxc_receipt');
break;
case 'jxc_outbound' :
$dataModel = db('jxc_outbound');
break;
case 'jxc_payment' :
$dataModel = db('jxc_payment');
break;
case 'jxc_collection' :
$dataModel = db('jxc_collection');
break;
case 'jxc_inventory' :
$dataModel = db('jxc_inventory');
break;
case 'jxc_allocation' :
$dataModel = db('jxc_allocation');
break;
}
$where = [];
@ -1887,7 +2212,13 @@ class Field extends Model
if ($types == 'crm_product') {
$where['delete_user_id'] = 0;
}
if ($res = $dataModel->where($where)->find()) {
if ($types == 'jxc_product') {
$where['is_del'] = 0;
}
$res = $dataModel->where($where)->find();
if ($res) {
$this->error = '该数据已存在,请修改后提交!';
return false;
}
@ -1932,7 +2263,7 @@ class Field extends Model
* 根据form_type处理数据
* @author lee
*/
public function getValueByFormtype($val, $form_type)
public function getValueByFormtype($val, $form_type, $dataInfo)
{
$userModel = new \app\admin\model\User();
$structureModel = new \app\admin\model\Structure();
@ -1941,14 +2272,22 @@ class Field extends Model
// $val = $val > 0 ? date('Y-m-d H:i:s', $val) : '';
// break;
case 'user' :
if (is_numeric($val)) {
$val = count($userModel->getUserNameByArr($val)) > 1 ? ArrayToString($userModel->getUserNameByArr($val)) : implode(',', $userModel->getUserNameByArr(stringToArray($val)));
} else {
$val = $val;
}
break;
case 'userStr' :
$val = explode(',', $val);
$val = count($userModel->getUserNameByArr($val)) > 1 ? ArrayToString($userModel->getUserNameByArr($val)) : implode(',', $userModel->getUserNameByArr($val));
break;
case 'structure' :
if (is_numeric($val)) {
$val = implode(',', $structureModel->getStructureNameByArr(stringToArray($val)));
} else {
$val = $val;
}
break;
case 'customer' :
$val = db('crm_customer')->where(['customer_id' => $val])->value('name');
@ -1968,6 +2307,54 @@ class Field extends Model
case 'business_status' :
$val = db('crm_business_status')->where(['status_id' => $val])->value('name');
break;
case 'location' :
$val = $val['address'];
break;
case 'position' :
$val = trim(arrayToString(array_column($val, 'name')), ',');
break;
case 'warehouse_cause' :
$val = db('jxc_warehouse')->where(['warehouse_id' => $val])->value('warehouse_name');
break;
case 'sale_cause' :
$val = db('jxc_sale')->where(['sale_id' => $val])->value('order_number');
break;
case 'supplier_cause' :
$val = db('jxc_supplier')->where(['supplier_id' => $val])->value('supplier_name');
break;
case 'purchase_cause' :
$val = db('jxc_purchase')->where(['purchase_id' => $val])->value('order_number');
break;
case 'order_cause' :
if($dataInfo['receipt_type'] == '销售退货入库'){
$val = db('jxc_salereturn')->where(['salereturn_id' => $val])->value('order_number');
}elseif ($dataInfo['receipt_type'] == '采购入库') {
$val = db('jxc_purchase')->where(['purchase_id' => $val])->value('order_number');
}elseif ($dataInfo['outbound_type'] == '销售出库') {
$val = db('jxc_sale')->where(['sale_id' => $val])->value('order_number');
}elseif ($dataInfo['outbound_type'] == '采购退货出库') {
$val = db('jxc_retreat')->where(['retreat_id' => $val])->value('order_number');
}
break;
case 'category_cause' :
$val = db('jxc_product_category')->where(['category_id' => $val])->value('category_name');
break;
case 'product_cause' :
$val = db('jxc_product')->where(['product_id' => $val])->value('product_name');
break;
case 'collection_object' :
if($dataInfo['collection_type'] == '采购退货'){
// $val = db('jxc_supplier')->where(['supplier_id' => $val])->value('supplier_name');
}elseif ($dataInfo['collection_type'] == '销售出库') {
$val = db('jxc_sale')->where(['sale_id' => $val])->value('order_number');
}elseif ($dataInfo['payment_type'] == '采购') {
$val = db('crm_customer')->where(['customer_id' => $val])->value('name');
}elseif ($dataInfo['payment_type'] == '销售退货') {
$val = db('jxc_salereturn')->where(['salereturn_id' => $val])->value('order_number');
}
break;
}
return $val;
}
@ -2012,11 +2399,15 @@ class Field extends Model
return false;
}
if (!$data) return $data;
$list = $this->where(['types' => $types, 'relevant' => ['neq', '']])->field('field,relevant')->select();
if (!$list) return $data;
$newData = $data;
$list = db('admin_field')->where(['types' => $types, 'relevant' => ['neq', '']])->field('field,relevant')->select();
foreach ($list as &$val){
$val=!empty($val)?$val:'';
}
$newData = [];
//crm_hfsomz
foreach ($list as $k => $v) {
$newData[$v['relevant']] = $data[$v['field']];
$customer_field=db('admin_field')->where(['types' => 'crm_customer', 'field_id' => $v['relevant']])->field('field')->find();
$newData[$customer_field['field']] = $data[$v['field']];
}
return $newData ?: [];
}
@ -2033,6 +2424,7 @@ class Field extends Model
public function getOrderByFormtype($types, $prefix, $field, $order_type)
{
$form_type = $this->where(['types' => $types, 'field' => $field])->value('form_type');
// die('123');
// if (!$form_type) {
// $this->error = '参数错误';
// return false;
@ -2244,11 +2636,11 @@ class Field extends Model
}
if (!empty($id)) {
return db('admin_field_extend')->where('id', $id)->update(['content' => json_encode($data, JSON_NUMERIC_CHECK)]);
return db('admin_field_extend')->where('id', $id)->update(['content' => json_encode($data)]);
}
if (empty($id)) {
return db('admin_field_extend')->insert(['types' => $types, 'field' => $field, 'content' => json_encode($data, JSON_NUMERIC_CHECK), 'create_time' => time()]);
return db('admin_field_extend')->insert(['types' => $types, 'field' => $field, 'content' => json_encode($data), 'create_time' => time()]);
}
return false;

@ -40,7 +40,19 @@ class File extends Common
'crm_invoice',
'crm_activity',
'crm_visit',
'crm_receivables'
'crm_receivables',
'jxc_product',
'jxc_supplier',
'jxc_purchase',
'jxc_retreat',
'jxc_sale',
'jxc_salereturn',
'jxc_receipt',
'jxc_outbound',
'jxc_payment',
'jxc_collection',
'jxc_inventory',
'jxc_allocation'
];
/**
@ -135,6 +147,18 @@ class File extends Common
case 'crm_activity': $r = db('crm_activity_file'); $r_name = 'activity_id'; break;
case 'crm_visit': $r = db('crm_visit_file'); $r_name = 'visit_id'; break;
case 'crm_receivables': $r = db('crm_receivables_file'); $r_name = 'receivables_id'; break;
case 'jxc_product': $r = db('jxc_product_file'); $r_name = 'product_id'; break;
case 'jxc_supplier': $r = db('jxc_supplier_file'); $r_name = 'supplier_id'; break;
case 'jxc_purchase': $r = db('jxc_purchase_file'); $r_name = 'purchase_id'; break;
case 'jxc_retreat': $r = db('jxc_retreat_file'); $r_name = 'retreat_id'; break;
case 'jxc_sale': $r = db('jxc_sale_file'); $r_name = 'sale_id'; break;
case 'jxc_salereturn': $r = db('jxc_salereturn_file'); $r_name = 'salereturn_id'; break;
case 'jxc_receipt': $r = db('jxc_receipt_file'); $r_name = 'receipt_id'; break;
case 'jxc_outbound': $r = db('jxc_outbound_file'); $r_name = 'outbound_id'; break;
case 'jxc_payment': $r = db('jxc_payment_file'); $r_name = 'payment_note_id'; break;
case 'jxc_collection': $r = db('jxc_collection_file'); $r_name = 'collection_note_id'; break;
case 'jxc_inventory': $r = db('jxc_inventory_file'); $r_name = 'inventory_id'; break;
case 'jxc_allocation': $r = db('jxc_allocation_file'); $r_name = 'allocation_id'; break;
default : break;
}
$rData = [];
@ -293,6 +317,18 @@ class File extends Common
case 'crm_activity' : $r = db('crm_activity_file'); $module = db('crm_activity'); break;
case 'crm_visit' : $r = db('crm_visit_file'); $module = db('crm_visit'); break;
case 'crm_receivables' : $r = db('crm_receivables_file'); $module = db('crm_receivables'); break;
case 'jxc_product' : $r = db('jxc_product_file'); $module = db('jxc_product'); break;
case 'jxc_supplier' : $r = db('jxc_supplier_file'); $module = db('jxc_supplier'); break;
case 'jxc_purchase' : $r = db('jxc_purchase_file'); $module = db('jxc_purchase'); break;
case 'jxc_retreat' : $r = db('jxc_retreat_file'); $module = db('jxc_retreat'); break;
case 'jxc_sale' : $r = db('jxc_sale_file'); $module = db('jxc_sale'); break;
case 'jxc_salereturn' : $r = db('jxc_salereturn_file'); $module = db('jxc_salereturn'); break;
case 'jxc_receipt' : $r = db('jxc_receipt_file'); $module = db('jxc_receipt'); break;
case 'jxc_outbound' : $r = db('jxc_outbound_file'); $module = db('jxc_outbound'); break;
case 'jxc_payment' : $r = db('jxc_payment_file'); $module = db('jxc_payment'); break;
case 'jxc_collection' : $r = db('jxc_collection_file'); $module = db('jxc_collection'); break;
case 'jxc_inventory' : $r = db('jxc_inventory_file'); $module = db('jxc_inventory'); break;
case 'jxc_allocation' : $r = db('jxc_allocation_file'); $module = db('jxc_allocation'); break;
default : break;
}
if ($r) {
@ -526,6 +562,43 @@ class File extends Common
case 'crm_receivables' :
$r = db('crm_receivables_file');
$r_name = 'receivables_id';
case 'jxc_product' :
$r = db('jxc_product_file');
$r_name = 'product_id';
case 'jxc_supplier' :
$r = db('jxc_supplier_file');
$r_name = 'supplier_id';
case 'jxc_purchase' :
$r = db('jxc_purchase_file');
$r_name = 'purchase_id';
case 'jxc_retreat' :
$r = db('jxc_retreat_file');
$r_name = 'retreat_id';
case 'jxc_sale' :
$r = db('jxc_sale_file');
$r_name = 'sale_id';
case 'jxc_salereturn':
$r = db('jxc_salereturn_file');
$r_name = 'salereturn_id';
case 'jxc_receipt' :
$r = db('jxc_receipt_file');
$r_name = 'receipt_id';
case 'jxc_outbound' :
$r = db('jxc_outbound_file');
$r_name = 'outbound_id';
case 'jxc_inventory' :
$r = db('jxc_inventory_file');
$r_name = 'inventory_id';
case 'jxc_allocation' :
$r = db('jxc_allocation_file');
$r_name = 'allocation_id';
case 'jxc_collection' :
$r = db('jxc_collection_file');
$r_name = 'collection_note_id';
case 'jxc_payment' :
$r = db('jxc_payment_file');
$r_name = 'payment_note_id';
default : break;
}
$rWhere = [];

@ -74,7 +74,7 @@ class LoginRecord extends Common
$data['address'] = $ip_address['country'];
// 效果图有这个备注字段不知道存啥就把UA记录了一下
$data['remark'] = $_SERVER['HTTP_USER_AGENT'];
// $data['remark'] = $_SERVER['HTTP_USER_AGENT'];
$this->save($data);
}

@ -169,6 +169,103 @@ class Message extends Common
* 移除队成员
*/
const TEAM_LEADS = 32;
/**
* 采购单待审批
*/
const PURCHASE_TO_DO = 33;
/**
* 采购单审批驳回
*/
const PURCHASE_REJECT = 34;
/**
* 采购单审批通过
*/
const PURCHASE_PASS = 35;
/**
* 采购退货单待审批
*/
const RETREAT_TO_DO = 36;
/**
* 采购退货单审批驳回
*/
const RETREAT_REJECT = 37;
/**
* 采购退货单审批通过
*/
const RETREAT_PASS = 38;
/**
* 销售订单待审批
*/
const SALE_TO_DO = 39;
/**
* 销售订单审批驳回
*/
const SALE_REJECT = 40;
/**
* 销售订单审批通过
*/
const SALE_PASS = 41;
/**
* 销售退货单待审批
*/
const SALERETURN_TO_DO = 42;
/**
* 销售退货单审批驳回
*/
const SALERETURN_REJECT = 43;
/**
* 销售退货单审批通过
*/
const SALERETURN_PASS = 44;
/**
* 回款单待审批
*/
const COLLECTION_TO_DO = 45;
/**
* 回款单审批驳回
*/
const COLLECTION_REJECT = 46;
/**
* 回款单审批通过
*/
const COLLECTION_PASS = 47;
/**
* 付款单待审批
*/
const PAYMENT_TO_DO = 48;
/**
* 付款单审批驳回
*/
const PAYMENT_REJECT = 49;
/**
* 付款单审批通过
*/
const PAYMENT_PASS = 50;
/**
* 调拨待审批
*/
const ALLOCATION_TO_DO = 51;
/**
* 调拨审批驳回
*/
const ALLOCATION_REJECT = 52;
/**
* 调拨审批通过
*/
const ALLOCATION_PASS = 53;
/**
* 盘点待审批
*/
const INVENTORY_TO_DO = 54;
/**
* 盘点审批驳回
*/
const INVENTORY_REJECT = 55;
/**
* 盘点审批通过
*/
const INVENTORY_PASS = 56;
/**
* 消息类型
*
@ -326,6 +423,32 @@ class Message extends Common
self::BUSINESS_PASS,
self::CUSTOMER_PASS,
self::CONTRACT_END,
],
'jxc' => [
self::PURCHASE_TO_DO,
self::PURCHASE_REJECT,
self::PURCHASE_PASS,
self::RETREAT_TO_DO,
self::RETREAT_REJECT,
self::RETREAT_PASS,
self::SALE_TO_DO,
self::SALE_REJECT,
self::SALE_PASS,
self::SALERETURN_TO_DO,
self::SALERETURN_REJECT,
self::SALERETURN_PASS,
self::COLLECTION_TO_DO,
self::COLLECTION_REJECT,
self::COLLECTION_PASS,
self::PAYMENT_TO_DO,
self::PAYMENT_REJECT,
self::PAYMENT_PASS,
self::ALLOCATION_TO_DO,
self::ALLOCATION_REJECT,
self::ALLOCATION_PASS,
self::INVENTORY_TO_DO,
self::INVENTORY_REJECT,
self::INVENTORY_PASS,
]
];
@ -468,6 +591,54 @@ class Message extends Common
case self::BUSINESS_PASS:
return BusinessModel::where(['business_id' => $data['action_id']])->value('name') ?: '';
// 采购单
case self::PURCHASE_TO_DO:
case self::PURCHASE_REJECT:
case self::PURCHASE_PASS:
return PurchaseModel::where(['purchase_id' => $data['action_id']])->value('order_number') ?: '';
// 采购退货单
case self::RETREAT_TO_DO:
case self::RETREAT_REJECT:
case self::RETREAT_PASS:
return RetreatModel::where(['retreat_id' => $data['action_id']])->value('order_number') ?: '';
// 销售订单
case self::SALE_TO_DO:
case self::SALE_REJECT:
case self::SALE_PASS:
return SaleModel::where(['sale_id' => $data['action_id']])->value('order_number') ?: '';
// 销售退货单订单
case self::SALERETURN_TO_DO:
case self::SALERETURN_REJECT:
case self::SALERETURN_PASS:
return SalereturnModel::where(['salereturn_id' => $data['action_id']])->value('order_number') ?: '';
// 回款单
case self::COLLECTION_TO_DO:
case self::COLLECTION_REJECT:
case self::COLLECTION_PASS:
return CollectionModel::where(['collection_note_id' => $data['action_id']])->value('collection_no') ?: '';
// 付款单
case self::PAYMENT_TO_DO:
case self::PAYMENT_REJECT:
case self::PAYMENT_PASS:
return PaymentModel::where(['payment_note_id' => $data['action_id']])->value('payment_no') ?: '';
// 调拨
case self::ALLOCATION_TO_DO:
case self::ALLOCATION_REJECT:
case self::ALLOCATION_PASS:
return PaymentModel::where(['allocation_id' => $data['action_id']])->value('allocation_code') ?: '';
// 盘点
case self::INVENTORY_TO_DO:
case self::INVENTORY_REJECT:
case self::INVENTORY_PASS:
return PaymentModel::where(['inventory_id' => $data['action_id']])->value('inventory_number') ?: '';
}
return '';

@ -21,7 +21,7 @@ class Scene extends Common
protected $updateTime = false;
protected $autoWriteTimestamp = true;
private $types_arr = ['crm_leads','crm_customer','crm_customer_pool','crm_contacts','crm_product','crm_business','crm_contract','crm_receivables','crm_visit','crm_invoice']; //支持场景的分类
private $types_arr = ['crm_leads','crm_customer','crm_customer_pool','crm_contacts','crm_product','crm_business','crm_contract','crm_receivables','crm_visit','crm_invoice', 'jxc_product', 'jxc_supplier', 'jxc_purchase', 'jxc_retreat', 'jxc_sale', 'jxc_salereturn', 'jxc_receipt', 'jxc_outbound', 'jxc_payment', 'jxc_collection', 'jxc_inventory', 'jxc_allocation']; //支持场景的分类
protected $type = [
'data' => 'array',
@ -467,6 +467,7 @@ class Scene extends Common
$map['is_end'] = ['condition' => 'is', 'value' => [2], 'form_type' => 'text'];
break;
case 'star' :
# 我的关注
$where = $this->getStarParam($types, $user_id);
if (!empty($where)) $map = $where;
break;
@ -482,11 +483,79 @@ class Scene extends Common
# 下架的产品
$map['status'] = ['condition' => 'is', 'value' => ['下架'], 'form_type' => 'select', 'name' => '是否上架', 'type' => 'status'];
break;
case 'jxc_put_on_shelves' :
# 上架的产品
$map['product_ishelf'] = ['condition' => 'is', 'value' => ['上架'], 'form_type' => 'select', 'name' => '是否上架', 'type' => 'product_ishelf'];
break;
case 'jxc_pull_off_shelves' :
# 下架的产品
$map['product_ishelf'] = ['condition' => 'is', 'value' => ['下架'], 'form_type' => 'select', 'name' => '是否上架', 'type' => 'product_ishelf'];
break;
default :
# 全部
$auth_user_ids = '';
}
if($types=='receivables_plan'){
switch ($bydata) {
case 'me' :
# 我负责的
$auth_user_ids[] = $user_id;
break;
case 'sub' :
# 下属负责的
$auth_user_ids = getSubUserId(false, 0, $user_id) ? : ['-1'];
break;
case 'all' :
# 全部
$auth_user_ids = '';
break;
case 'not' :
# 全部未回款
$map['status'] = ['neq',1];
break;
case 'not_overdue' :
# 全部逾期未回款
// $map['status'] =array(['neq',1],['neq',4],'or');
$map['status'] =['neq',1];
$map['return_date'] = ['lt',time()];
break;
case 'not_moth' :
# 本月到期未回款
$timeAry = ByDateTime('month');
$map['status'] =['neq',1];
$map['return_date'] = ['between',[$timeAry[0],$timeAry[1]]];
break;
case 'not_week' :
# 本周到期未回款
$timeAry = ByDateTime('week');
$map['status'] =['neq',1];
$map['return_date'] = ['between',[$timeAry[0],$timeAry[1]]];
break;
case 'complete' :
# 已回款
$map['status'] =['eq',1];
break;
case 'complete_moth' :
# 本月已回款
$timeAry = ByDateTime('month');
$map['status'] =['eq',1];
$map['return_date'] = ['between',[$timeAry[0],$timeAry[1]]];
break;
case 'complete_week' :
# 本周已回款
$timeAry = ByDateTime('week');
$map['status'] =['eq',1];
$map['return_date'] = ['between',[$timeAry[0],$timeAry[1]]]; break;
case 'complete_part' :
# 部分已回
$map['status'] = ['eq',2];
break;
default :
# 全部
$auth_user_ids = '';
}
}
$auth_user_ids = $auth_user_ids ? : [];
if ($auth_user_ids) {

@ -28,18 +28,30 @@ class Structure extends Common
{
$cat = new \com\Category('admin_structure', array('id', 'pid', 'name', 'title'));
$data = $cat->getList('', 0, 'id');
foreach ($data as $k=>$v){
$data[$k]['owner_user_name']=foreachData('admin_structure',$v['owner_user_id'])?:null;
//选择部门传入当前部门权限范围内的员工
$data[$k]['user_id']=$this->getSubUserByStructrue($v['id']);
}
// 若type为tree则返回树状结构
if ($type == 'tree') {
$tree = new \com\Tree();
$data = $tree->list_to_tree($data, 'id', 'pid', 'child', 0, true, array(''));
}
foreach ($data as $k=>$v){
$data[$k]['owner_user_name']=foreachData('admin_structure',$v['owner_user_id'])?:null;
}
return $data;
}
//获取部门下权限范围内员工
public function getSubUserByStructrue($param)
{
$userModel = model('User');
$structureList = $userModel->getSubUserByStr($param, 1);
if ($param) {
$where['id'] = ['in', $structureList];
}
$list = Db::name('AdminUser')->field('id,realname')->where($where)->select();
$list = $list ?: array();
return $list;
}
/*
*根据字符串展示参与部门 use by work
*add by yykun

@ -80,6 +80,12 @@ class User extends Common
'name' => '岗位',
'form_type' => 'text',
'is_null' => 0,
],
[
'field' => 'department',
'name' => '部门',
'form_type' => 'text',
'is_null' => 1,
]
];
@ -274,7 +280,18 @@ class User extends Common
$temp[$val['field']] = $param[$val['field']];
}
$param = $temp;
$param['structure_id'] = 0;
$department=explode('/',$param['department']);
$pid=1;
foreach ($department as $k => $v){
$structure=db('admin_structure')->where('name',$v)->find();
if(empty($structure)){
$id=db('admin_structure')->insertGetId(['name'=>$v,'pid'=>$pid]);
$pid=$id;
}else{
$pid=$structure['id'];
}
}
$param['structure_id'] = $pid;
if (db('admin_user')->where('username', $param['username'])->find()) {
$this->error = '手机号已存在';
return false;
@ -457,6 +474,18 @@ class User extends Common
}
$param['realname'] = $name;
}
$department=explode('/',$param['department']);
$pid=1;
foreach ($department as $k => $v){
$structure=db('admin_structure')->where('name',$v)->find();
if(empty($structure)){
$id=db('admin_structure')->insertGetId(['name'=>$v,'pid'=>$pid]);
$pid=$id;
}else{
$pid=$structure['id'];
}
}
$param['structure_id'] = $pid;
$param['userId']=!empty($param['create_user_id'])?:$param['owner_user_id'];
unset($param['owner_user_id']);
unset($param['create_user_id']);
@ -755,7 +784,11 @@ class User extends Common
if ($v['name'] == 'market') {
$rules[$k]['name'] = 'activityForm';
}
if($v['name'] == 'warehouseProduct'){
$rules[$k]['name'] = 'warehouseProduct';
}
}
// p($rules);die();
//菜单管理(弃用)
// $menuMap['status'] = 1;
// $menuMap['rule_id'] = array('in',$newRuleIds);
@ -765,6 +798,7 @@ class User extends Common
$tree = new \com\Tree();
//处理规则成树状
$rulesList = $tree->list_to_tree($rules, 'id', 'pid', 'child', 0, true, array('pid'));
//权限数组
$authList = rulesListToArray($rulesList, $newRuleIds);
//应用控制
@ -817,6 +851,11 @@ class User extends Common
if (in_array('calendar', $adminConfig)) {
$authList['oa']['calendar'] = (object)[];
}
# 进销存
if (in_array('jxc', $adminConfig)) {
$authList['jxc']['field'] = (object)[];
$authList['jxc']['params'] = (object)[];
}
# 公海权限
$structureId = db('admin_user')->where('id', $u_id)->value('structure_id');
$poolStatus = db('crm_customer_pool')->where('status', 1)->where(function ($requery) use ($u_id, $structureId, $adminTypes) {
@ -827,6 +866,7 @@ class User extends Common
if (!empty($poolStatus)) $authList['crm']['pool'] = ['index' => true];
$ret['authList'] = $this->resetAuthorityFiled($authList);
$res['manage'] = $rules;
return $ret;
}
@ -988,7 +1028,11 @@ class User extends Common
$authList['email'] = (object)[];
$authList['hrm'] = (object)[];
$authList['jxc'] = (object)[];
// $authList['jxc'] = (object)[];
# jxc
$authList['manage']['jxc']['field'] = true;
$authList['manage']['jxc']['params'] = true;
$authList['knowledge'] = (object)[];
return $authList;
@ -1084,6 +1128,7 @@ class User extends Common
*/
public function getSubUserByStr($structure_id, $type = 1)
{
// p($structure_id);die;
$allStrIds = (array)$structure_id;
if ($type == 2) {
$structureModel = new \app\admin\model\Structure();
@ -1433,10 +1478,12 @@ class User extends Common
foreach ($ids as $v) {
$data['id'] = $v;
$data['structure_id'] = $param['structure_id'];
$flag = foreachData('', $data);
$flag=$this->isUpdate(true)->save($data);
// $flag = foreachData('', $data);
// p(Db::name('AdminUser')->getLastSql());
}
if ($flag) {
return $flag;
if ($flag!==false) {
return 1;
} else {
$this->error = '修改失败,请稍后重试';
return false;

@ -2,6 +2,7 @@
/**
* 字段验证(线索、客户、联系人、商机、合同、回款、回访、产品、办公审批)
*/
namespace app\admin\traits;
trait FieldVerificationTrait
@ -15,9 +16,9 @@ trait FieldVerificationTrait
* @param string $types 自定义表栏目类型crm_leads、crm_customer ...
* @param int $dataId 编辑时相应的模块数据的ID
* @param int $typesId 自定义表栏目类型ID
* @author fanqi
* @since 2021-05-18
* @return string
* @since 2021-05-18
* @author fanqi
*/
public function fieldDataValidate($param, $types, $userId, $dataId = 0, $typesId = 0)
{
@ -28,18 +29,18 @@ trait FieldVerificationTrait
# 查询自定义字段表数据
$fieldList = $this->getFieldList($types, $typesId);
# 验证
foreach ($fieldList AS $key => $value) {
foreach ($fieldList as $key => $value) {
# 字段授权,没有读写权限,跳过验证。
if (!$userLevel && !empty($grantData[$types])) {
$status = getFieldGrantStatus($value['field'], $grantData[$types]);
if (empty($status['read']) || (empty($dataId) && empty($status['write']))) continue;
}
# 验证非明细表格字段数据
if (!empty($value['is_null']) && !in_array($value['form_type'], ['detail_table', 'boolean_value']) && (isset($param[$value['field']]) && empty($param[$value['field']]))) {
if ($value['form_type'] != 'detail_table' && !empty($value['is_null']) && !in_array($value['form_type'], ['detail_table', 'boolean_value']) && (isset($param[$value['field']]) && empty($param[$value['field']]))) {
$error = $value['name'] . '字段不能为空!';
break;
}
@ -62,29 +63,27 @@ trait FieldVerificationTrait
break;
}
# 验证明细表格不能为空
if (!empty($value['is_null']) && $value['form_type'] == 'detail_table' && isset($param[$value['field']]) && empty($param[$value['field']])) {
$error = $value['name'] . '数据不能为空!';
}
# 验证明细表格可以为空,明细表格里的字段不能为空的情况。
if ($value['form_type'] == 'detail_table') {
foreach ($param[$value['field']] AS $val) {
foreach ($val AS $v) {
if (!empty($v['is_null']) && empty($v['is_hidden']) && isset($v['value']) && empty($v['value'])) {
foreach ($param[$value['field']] as $val) {
foreach ($val as $v) {
if ($v['form_type']!='boolean_value' && !empty($v['is_null']) && empty($v['is_hidden']) && isset($v['value']) && empty($v['value'])) {
$error = $value['name'] . '中的' . $v['name'] . '字段不能为空!';
break;
}
}
}
}
if (empty($value['is_unique'])) continue;
// 人员、部门、文件、手写签名、描述文字、多选、明细表格跳过验证
if (in_array($value['form_type'], ['user', 'structure', 'file', 'handwriting_sign', 'desc_text', 'checkbox', 'detail_table'])) continue;
if (in_array($value['form_type'], ['file', 'handwriting_sign', 'desc_text', 'checkbox', 'detail_table'])) continue;
$uniqueStatus = false;
# 验证唯一性
if ($value['form_type'] == 'date_interval' && !empty($param[$value['field']])) {
// 日期区间
@ -95,8 +94,15 @@ trait FieldVerificationTrait
} elseif ($value['form_type'] == 'location' && !empty($param[$value['field']])) {
// 定位
$uniqueStatus = $this->checkDataUniqueForLocation($types, $value['field'], $param[$value['field']], $dataId);
} elseif ($value['form_type'] == 'user' && !empty($param[$value['field']])) {
// 人员
$uniqueStatus = $this->checkDataUniqueForUser($types, $value['field'], $param[$value['field']], $dataId);
} elseif ($value['form_type'] == 'structure' && !empty($param[$value['field']])) {
// 部门
$uniqueStatus = $this->checkDataUniqueForStructure($types, $value['field'], $param[$value['field']], $dataId);
} else {
if (!empty($param[$value['field']])) $uniqueStatus = $this->checkDataUniqueForCommon($types, $value['field'], $param[$value['field']], $dataId);
}
if (!empty($uniqueStatus)) {
@ -104,7 +110,6 @@ trait FieldVerificationTrait
break;
}
}
return $error;
}
@ -117,9 +122,9 @@ trait FieldVerificationTrait
* @param string $field 字段名称
* @param string $value 字段值
* @param int $dataId 更新时传来的数据ID
* @author fanqi
* @since 2021-05-18
* @return float|mixed|string
* @since 2021-05-18
* @author fanqi
*/
private function checkDataUniqueForCommon($types, $field, $value, $dataId = 0)
{
@ -142,9 +147,9 @@ trait FieldVerificationTrait
* @param string $field 字段名称
* @param array $value 字段值
* @param int $dataId 更新时传来的数据ID
* @author fanqi
* @since 2021-05-18
* @return float|mixed|string
* @since 2021-05-18
* @author fanqi
*/
private function checkDataUniqueForDateInterval($types, $field, $value, $dataId = 0)
{
@ -167,9 +172,9 @@ trait FieldVerificationTrait
* @param string $field 字段名称
* @param array $value 字段值
* @param int $dataId 更新时传来的数据ID
* @author fanqi
* @since 2021-05-18
* @return float|mixed|string
* @since 2021-05-18
* @author fanqi
*/
private function checkDataUniqueForPosition($types, $field, $value, $dataId = 0)
{
@ -192,9 +197,9 @@ trait FieldVerificationTrait
* @param string $field 字段名称
* @param array $value 字段值
* @param int $dataId 更新时传来的数据ID
* @author fanqi
* @since 2021-05-18
* @return float|mixed|string
* @since 2021-05-18
* @author fanqi
*/
private function checkDataUniqueForLocation($types, $field, $value, $dataId = 0)
{
@ -210,39 +215,62 @@ trait FieldVerificationTrait
return db($types)->where($where)->value($primaryKey);
}
// /**
// * 验证唯一性(部门)
// *
// * @param string $types 栏目类型
// * @param string $field 字段名称
// * @param string $value 字段值
// * @param int $dataId 更新时传来的数据ID
// * @author fanqi
// * @since 2021-05-18
// * @return float|mixed|string
// */
// private function checkDataUniqueForStructure($types, $field, $value, $dataId = 0)
// {
// if (empty($value)) return false;
//
// # 主键
// $primaryKey = getPrimaryKeyName($types);
//
// # 查询条件
// $where[$field] = ',' . $value . ',';
// if (!empty($dataId)) $where[$primaryKey] = ['neq', $dataId];
//
// return db($types)->where($where)->value($primaryKey);
// }
/**
* 验证唯一性(部门)
*
* @param string $types 栏目类型
* @param string $field 字段名称
* @param string $value 字段值
* @param int $dataId 更新时传来的数据ID
* @return float|mixed|string
* @since 2021-05-18
* @author fanqi
*/
private function checkDataUniqueForStructure($types, $field, $value, $dataId = 0)
{
if (empty($value)) return false;
# 主键
$primaryKey = getPrimaryKeyName($types);
# 查询条件
$where[$field] = ',' . $value . ',';
if (!empty($dataId)) $where[$primaryKey] = ['neq', $dataId];
return db($types)->where($where)->value($primaryKey);
}
/**
* @param $types 栏目类型
* @param $field 字段名称
* @param $value 字段值
* @param int $dataId 更新时传来的数据ID
* @return false|float|mixed|string|null
* @since 2021-05-18
* @author fanqi
*/
private function checkDataUniqueForUser($types, $field, $value, $dataId = 0)
{
if (empty($value)) return false;
# 主键
$primaryKey = getPrimaryKeyName($types);
# 查询条件
$where[$field] = ',' . $value . ',';
if (!empty($dataId)) $where[$primaryKey] = ['neq', $dataId];
return db($types)->where($where)->value($primaryKey);
}
/**
* 自定义字段列表
*
* @param string $types 自定义表栏目类型crm_leads、crm_customer ...
* @param int $typesId 自定义表栏目类型ID
* @author fanqi
* @since 2021-05-18
* @return bool|\PDOStatement|string|\think\Collection
* @since 2021-05-18
* @author fanqi
*/
private function getFieldList($types, $typesId)
{
@ -259,4 +287,5 @@ trait FieldVerificationTrait
return db('admin_field')->field($fields)->where($where)->select();
}
}

@ -340,6 +340,7 @@ function advancedQuery($param, $m = '', $c = '', $a = '')
'nextQuarter', 'month', 'lastMonth', 'nextMonth', 'week', 'lastWeek', 'nextWeek', 'today',
'yesterday', 'tomorrow', 'previous7day', 'previous30day', 'future7day', 'future30day'
];
foreach ($param as $key => $value) {
// 过滤不能参与搜索的字段类型
if (!empty($value['form_type']) && in_array($value['form_type'], ['file', 'handwriting_sign', 'desc_text', 'detail_table', 'date_interval'])) continue;
@ -376,18 +377,32 @@ function advancedQuery($param, $m = '', $c = '', $a = '')
$value['condition'] = 'is';
}
if (!empty($value['value'][0]) && in_array($value['value'][0], $betweenType)) {
$value = advancedQueryHandleDate($value);
}
// 代办事项
if (isset($value) && !isset($value['condition']) && !isset($value['value']) && !isset($value['form_type'])) {
$result[$c . $key] = is_array($value) ? $value : ['in', $value];
continue;
}
// 等于(时间段)类型筛选
if (!empty($value['value'][0]) && in_array($value['value'][0], $betweenType)) {
$value = advancedQueryHandleDate($value);
}
// 创建人、负责人
if (in_array($key, ['create_user_id', 'owner_user_id'])) {
if($value['condition'] == 'contains'){
$result[$c . $key] = ['in', $value['value']];
}else if ($value['condition'] == 'notContains') {
$result[$c . $key] = ['not in', $value['value']];
}else if ($value['condition'] == 'isNull') {
$result[$c . $key] = ['eq', ''];
}else if ($value['condition'] == 'isNotNull') {
$result[$c . $key] = ['neq', ''];
}
}
// 模块、审核状态、成交状态、产品分类、单行文本、多行文本、网址、手机、邮箱、下拉框、布尔值、多选、定位、创建人、负责人
if (isset($value['form_type']) && in_array($value['form_type'], ['module', 'check_status', 'deal_status', 'category', 'text', 'textarea', 'mobile', 'email', 'select', 'boolean_value', 'checkbox', 'location', 'website']) || in_array($key, ['create_user_id', 'owner_user_id'])) {
if (isset($value['form_type']) && in_array($value['form_type'], ['module', 'check_status', 'deal_status', 'category', 'text', 'textarea', 'mobile', 'email', 'select', 'boolean_value', 'checkbox', 'location', 'website','user',])) {
$result[$c . $key] = advancedQueryFormatForCommon($value['value'], $value['condition'], $value['form_type'], $key);
}
@ -400,11 +415,16 @@ function advancedQuery($param, $m = '', $c = '', $a = '')
if (isset($value['form_type']) && in_array($value['form_type'], ['map_address', 'position'])) {
$result[$c . $key] = advancedQueryFormatForAddress($value['value'], $value['form_type']);
}
// 人员、部门
if (isset($value['form_type']) && in_array($value['form_type'], ['user', 'structure', 'single_user']) && !in_array($key, ['create_user_id', 'owner_user_id']) && $value['type'] != 'team_id') {
if ($value['type'] == 'owner_structure') { # 所属部门
$userIds = db('admin_user')->whereIn('structure_id', implode(',', $value['value']))->column('id');
$result[$c . 'owner_user_id'] = ['in', $userIds];
} else {
$result[$c . $key] = advancedQueryFormatForPersonnel($value['value'], $value['condition']);
}
}
// 商机状态组
if (isset($value['form_type']) && $value['form_type'] == 'business_type') {
if (!empty($value['type_id'])) $result[$c . 'type_id'] = ['eq', $value['type_id']];
@ -519,7 +539,11 @@ function advancedQueryFormatForPersonnel($data, $condition)
if ($condition == 'isNot') $condition = 'notContains';
// 处理查询参数
$data = advancedQueryDataTransform($data, $condition);
if (in_array($condition, ['contains', 'notContains'])) {
array_walk($data, function ($value, $key) use (&$data) {
$data[$key] = '%,' . $value . ',%';
});
}
// 搜索条件
return advancedQueryWhere($condition, $data);
@ -559,7 +583,11 @@ function advancedQueryFormatForCommon($data, $condition, $formType, $key)
if (in_array($formType, ['checkbox']) && $condition == 'isNot') $condition = 'notContains';
// 处理查询参数
if (in_array($condition, ['contains', 'notContains', 'startWith', 'endWith'])) $data = advancedQueryDataTransform($data, $condition);
if(in_array($condition, ['contains', 'notContains']) && in_array($key,['create_user_id','owner_user_id'])){
$data = advancedQueryDataUserform($data, $condition);
}elseif (in_array($condition, ['contains', 'notContains', 'startWith', 'endWith'])){
$data = advancedQueryDataTransform($data, $condition);
}
// 处理回访形式
if (in_array($key, ['shape', 'satisfaction'])) {
@ -579,19 +607,19 @@ function advancedQueryFormatForCommon($data, $condition, $formType, $key)
$data[0] = str_replace('已作废', 6, $data[0]);
}
return advancedQueryWhere($condition, $data);
return advancedQueryWhere($condition, $data,$key);
}
/**
* 设置搜索条件
*
* @param string $condition 查询方式
* @param string $data 查询数据
* @param string|array $data 查询数据
* @return array
* @since 2021-05-22
* @author fanqi
*/
function advancedQueryWhere($condition, $data)
function advancedQueryWhere($condition, $data, $key='')
{
$result = [];
@ -613,7 +641,8 @@ function advancedQueryWhere($condition, $data)
if ($condition == 'range') $result = ['between', $data]; // 处于某个时间段
if ($condition == 'isNull') $result = [['eq', ''], ['null'], 'OR']; // 为空
if ($condition == 'isNotNull') $result = [['neq', ''], ['not null'], 'AND']; // 不为空
if ($condition == 'contains' && in_array($key,['create_user_id','owner_user_id'])) $result = ['in', $data]; // 暂定为创建人 负责人 包含
if ($condition == 'notContains' && in_array($key,['create_user_id','owner_user_id'])) $result = ['notin', $data]; // 暂定为创建人 负责人不包含
return $result;
}
@ -649,6 +678,24 @@ function advancedQueryDataTransform($data, $condition)
return $data;
}
/**
* 处理要查询的数据 包含不包含条件 数据为数字专用
*
* @param array $data 要查询的数据
* @param string $condition 查询方式
* @return mixed
* @author: alvin guogaobo
* @version: 11.1.0
* Date: 2021/9/2 14:44
*/
function advancedQueryDataUserform($data, $condition){
if (in_array($condition, ['contains', 'notContains'])) {
array_walk($data, function ($value, $key) use (&$data) {
$data[$key] = $value;
});
}
return $data;
}
/**
* 等于(时间段)数据处理
*
@ -661,8 +708,9 @@ function advancedQueryHandleDate($data)
{
// 本年度
if ($data['value'][0] == 'year') {
$data['value'][0] = date('Y-m-d 00:00:00');
$data['value'][1] = date('Y-m-d 23:59:59');
$arrTime = DataTime::year();
$data['value'][0] = date('Y-m-d 00:00:00', $arrTime[0]);
$data['value'][1] = date('Y-m-d 23:59:59', $arrTime[1]);
}
// 上一年度
@ -1299,7 +1347,11 @@ function updateActionLog($user_id, $types, $action_id, $oldData = [], $newData =
$old_value = $oldData[$k] ?: '空';
if ($newFieldArr[$k]['form_type'] == 'datetime') {
$new_value = $v ? date('Y-m-d', $v) : '空';
if (date('Y-m-d H:i:s', strtotime($oldData[$k])) == $oldData[$k]) {
$old_value = !empty($oldData[$k]) ? $oldData[$k] : '空';
} else {
$old_value = !empty($oldData[$k]) ? date('Y-m-d', $oldData[$k]) : '空';
}
if (empty($v) && empty($oldData[$k])) continue;
} elseif ($newFieldArr[$k]['form_type'] == 'user') {
$new_value = $v ? implode(',', $userModel->getUserNameByArr(stringToArray($v))) : '';
@ -1873,7 +1925,7 @@ function getTimeByType($type = 'today', $is_last = false)
function getFullPath($path)
{
if ($path) {
$protocol = strpos(strtolower($_SERVER['HTTP_REFERER']), 'https') === false ? 'http' : 'https';
$protocol = strpos(strtolower($_SERVER['REQUEST_SCHEME']), 'https') === false ? 'http' : 'https';
return $protocol . '://' . $_SERVER['HTTP_HOST'] . substr($_SERVER["SCRIPT_NAME"], 0, -10) . substr(str_replace(DS, '/', $path), 1);
} else {
return '';
@ -2693,8 +2745,7 @@ if (!function_exists('getFieldGrantStatus')) {
function getFieldGrantStatus($field, $grantData)
{
# 默认状态都是不能查看、不能编辑,通过配置来取最大权限。
$result = ['read' => 0, 'write' => 0];
$result = ['read' => 0, 'write' => 0,'maskType'=>0];
foreach ($grantData as $key => $value) {
$fieldBool = false;
@ -2708,17 +2759,20 @@ if (!function_exists('getFieldGrantStatus')) {
if ($va['field'] == $field && $result['write'] == 0) {
$result['write'] = $va['write'] > $result['write'] ? $va['write'] : $result['write'];
}
if ($va['field'] == $field && $va['maskType'] != 0) {
$result['maskType'] = !empty($va['maskType'])?$va['maskType']:0;
}
if ($va['field'] == $field) $fieldBool = true;
}
# 对于不在权限控制之内的字段将状态都改为1。
if (!$fieldBool) {
$result['read'] = 1;
$result['write'] = 1;
}
}
return $result;
}
}
@ -3007,36 +3061,36 @@ if (!function_exists('getFieldGroupOrderData')) {
$formPositionEmpty = [];
$formPositionExist = [];
$result = [];
// 处理数据,将有位置信息和无位置信息的数据分开存放。
foreach ($data as $key => $value) {
if (empty($value['form_position'])) {
$formPositionEmpty[] = $value;
continue;
}
$formPositionArray = explode(',', $value['form_position']);
$x = (int)$formPositionArray[0];
$y = (int)$formPositionArray[1];
if (!isset($value['xaxis'])) $value['xaxis'] = $x;
if (!isset($value['yaxis'])) $value['yaxis'] = $y;
if ($value['form_type'] == 'date_interval' && !is_array($value['default_value'])) {
$value['default_value'] = !empty($value['default_value']) ? explode(',', $value['default_value']) : [];
}
$formPositionExist[$x][$y] = $value;
}
// 排序
ksort($formPositionExist);
// 处理有位置信息的数据
foreach ($formPositionExist as $key => $value) {
foreach ($value as $k => $v) {
if (!empty($formPositionExist[$key][$k])) $result[$key][$k] = $v;
}
$result[$key] = array_values($result[$key]);
}
// 将无位置信息的数据放置尾端
foreach ($formPositionEmpty as $key => $value) {
$result[] = [$value];
@ -3070,6 +3124,18 @@ if (!function_exists('getPrimaryKeyName')) {
if ($types == 'crm_product') $primaryKey = 'product_id';
if ($types == 'crm_invoice') $primaryKey = 'invoice_id';
if ($types == 'oa_examine') $primaryKey = 'examine_id';
if ($types == 'jxc_product') $primaryKey = 'product_id';
if ($types == 'jxc_supplier') $primaryKey = 'supplier_id';
if ($types == 'jxc_purchase') $primaryKey = 'purchase_id';
if ($types == 'jxc_retreat') $primaryKey = 'retreat_id';
if ($types == 'jxc_sale') $primaryKey = 'sale_id';
if ($types == 'jxc_salereturn') $primaryKey = 'salereturn_id';
if ($types == 'jxc_receipt') $primaryKey = 'receipt_id';
if ($types == 'jxc_outbound') $primaryKey = 'outbound_id';
if ($types == 'jxc_payment') $primaryKey = 'payment_note_id';
if ($types == 'jxc_collection') $primaryKey = 'collection_note_id';
if ($types == 'jxc_inventory') $primaryKey = 'inventory_id';
if ($types == 'jxc_allocation') $primaryKey = 'allocation_id';
return $primaryKey;
}

@ -112,7 +112,35 @@ class PoolCommand extends Command
}
});
}
/**
* 自动入公海操作记录
* @param $ruleList
* @param $customerWhere
*
* @author alvin guogaobo
* @version 1.0 版本号
* @since 2021/6/3 0003 10:38
*/
// private function updateInfo($ruleList, $customerWhere)
// {
// foreach ($ruleList as $k => $v) {
// $levels = json_decode($v['level'], true);
// foreach ($levels as $k1 => $v1) {
// if (!empty($v1['limit_day'])) {
// $time = $v1['limit_day'];
// } else {
// $time = $this->getMinDay($levels);
// }
// }
// foreach ($customerWhere as $val) {
// if ($v['type'] == 1) updateActionLog(0, 'crm_customer', $val, '', '', '超过' . $time . '天无新建跟进记录自动进入公海');
// if ($v['type'] == 2) updateActionLog(0, 'crm_customer', $val, '', '', '超过' . $time . '天无新建商机自动进入公海');
// if ($v['type'] == 3) updateActionLog(0, 'crm_customer', $val, '', '', '超过' . $time . '天未成交自动进入公海');
//
// }
// }
// }
//
protected function execute(Input $input, Output $output)

@ -71,6 +71,7 @@ class Team extends Command
{
$this->timer = Timer::add(1, function () {
# 只在凌晨12点至6点间执行
if ((int)date('H') >= 0 && (int)date('H') < 6) {
# 团队成员过滤规则
db('crm_team')->where('target_time',0)->delete();
@ -125,6 +126,7 @@ class Team extends Command
}
$upData = db($types)->where([$data_name => $v['target_id']])->update($data);
db('crm_team')->where(['target_id' => $v['target_id'], 'types' => $v['types'], 'team_user_id' => ['in', arrayToString($team_user_id)]])->delete();
// updateActionLog(0, $v['types'], $data, '', '', '自动删除到期员工');
}
Db::commit();
} catch (\Exception $e) {

@ -116,7 +116,10 @@ class Contract extends ApiCommon
$param['check_user_id'] = is_array($check_user_id) ? ','.implode(',',$check_user_id).',' : $check_user_id;
} else {
# 审批流停用,将状态改为审核通过
$param['check_status'] = 2;
// $param['check_status'] = 2;
# 审批流停用,将状态改为正常 zjf 20210727 默认值为7
$param['check_status'] = 7;
}
}
@ -212,7 +215,7 @@ class Contract extends ApiCommon
}
# 已进行审批,不能编辑
if (!in_array($dataInfo['check_status'], ['3', '4', '5', '6'])) {
if (!in_array($dataInfo['check_status'], ['3', '4', '5', '6', '7']) && $dataInfo['check_status']!=0) {
return resultArray(['error' => '当前状态为审批中或已审批通过,不可编辑']);
}
@ -260,10 +263,10 @@ class Contract extends ApiCommon
$examineFlowWheres['status'] = 1;
$examineFlowWheres['is_deleted'] = 0;
$contractExamineCount = db('admin_examine_flow')->where($examineFlowWheres)->count();
# 审核没有开启,更新作废合同的状态
if ($contractExamineCount == 0 && $dataInfo['check_status'] == 6 && empty($param['is_draft'])) $param['check_status'] = 2;
# 审核没有开启,更新作废合同的状态
if ($contractExamineCount == 0 && $dataInfo['check_status'] == 5 && empty($param['is_draft'])) $param['check_status'] = 2;
# 审核没有开启,更新作废合同的状态 zjf 20210727 改状态为正常 值为7
if ($contractExamineCount == 0 && $dataInfo['check_status'] == 6 && empty($param['is_draft'])) $param['check_status'] = 7;
# 审核没有开启,更新作废合同的状态 zjf 20210727 改状态为正常 值为7
if ($contractExamineCount == 0 && $dataInfo['check_status'] == 5 && empty($param['is_draft'])) $param['check_status'] = 7;
# 审核没有开启,保存为草稿
if ($contractExamineCount == 0 && !empty($param['is_draft'])) $param['check_status'] = 5;

@ -11,6 +11,8 @@ use app\admin\controller\ApiCommon;
use app\crm\logic\CustomerLogic;
use app\crm\traits\SearchConditionTrait;
use app\crm\traits\StarTrait;
use phpDocumentor\Reflection\Types\False_;
use think\Cache;
use think\Hook;
use think\Request;
use think\Db;
@ -101,6 +103,7 @@ class Customer extends ApiCommon
public function read()
{
$customerModel = model('Customer');
$cutomerLogic = new CustomerLogic();
$param = $this->param;
$userInfo = $this->userInfo;
$data = $customerModel->getDataById($param['id'], $userInfo['id']);
@ -414,7 +417,7 @@ class Customer extends ApiCommon
# 获取客户数据
$customerData = [];
$customerList = db('crm_customer')->field(['customer_id', 'owner_user_id', 'name'])->whereIn('customer_id', $customerIds)->select();
foreach ($customerList AS $key => $value) {
foreach ($customerList as $key => $value) {
$customerData[$value['customer_id']] = $value;
}
@ -424,8 +427,7 @@ class Customer extends ApiCommon
$poolRecordData = [];
$fieldRecordData = [];
$operationLogData = [];
foreach ($customerIds AS $key => $value)
{
foreach ($customerIds as $key => $value) {
if (empty($customerData[$value])) {
$message[] = '将客户放入公海失败,错误原因:数据不存在!';
unset($customerIds[(int)$key]);
@ -819,7 +821,7 @@ class Customer extends ApiCommon
'default_value' => '',
'is_null' => 1,
'input_tips' => '',
'setting' => Array(),
'setting' => array(),
'is_hidden' => 0,
'writeStatus' => 1,
'value' => '']
@ -880,6 +882,7 @@ class Customer extends ApiCommon
*/
public function top()
{
$customerModel=model('Customer');
$param = $this->param;
$userInfo = $this->userInfo;
$param['create_role_id'] = $userInfo['id'];
@ -901,49 +904,6 @@ class Customer extends ApiCommon
}
}
/**
* 客户公海导出
* @param
* @return
* @author Michael_xu
*/
public function poolExcelExport()
{
$param = $this->param;
$userInfo = $this->userInfo;
$param['user_id'] = $userInfo['id'];
if ($param['customer_id']) {
$param['customer_id'] = ['condition' => 'in', 'value' => $param['customer_id'], 'form_type' => 'text', 'name' => ''];
$action_name='导出选中';
}
$param['is_excel'] = 1;
$excelModel = new \app\admin\model\Excel();
// 导出的字段列表
$fieldModel = new \app\admin\model\Field();
$field_list = $fieldModel->getIndexFieldConfig('crm_customer', $userInfo['id']);
$field_list = array_filter($field_list, function ($val) {
return $val['field'] != 'owner_user_id';
});
// 文件名
$file_name = '5kcrm_customer_pool_' . date('Ymd');
$param['action'] = 'pool';
$model = model('Customer');
$temp_file = $param['temp_file'];
unset($param['temp_file']);
$page = $param['page'] ?: 1;
unset($param['page']);
unset($param['export_queue_index']);
RecordActionLog($userInfo['id'],'crm_customer','excelexport',$action_name,'','','导出客户');
return $excelModel->batchExportCsv($file_name, $temp_file, $field_list, $page, function ($page, $limit) use ($model, $param) {
$param['page'] = $page;
$param['limit'] = $limit;
$data = $model->getDataList($param);
$data['list'] = $model->exportHandle($data['list'], $field_list,'crm_customer');
return $data;
});
}
/**
* 客户成交状态
* @param status 1已成交,2未成交
@ -1194,9 +1154,9 @@ class Customer extends ApiCommon
/**
* 客户级别列表
*
* @author fanqi
* @since 2021-03-29
* @return \think\response\Json
* @since 2021-03-29
* @author fanqi
*/
public function level()
{

@ -371,7 +371,9 @@ class CustomerPool extends ApiCommon
}
break;
case 'detail_address':
if($param['is_excel']!=1){
unset($pool_list[$k]);
}
break;
case ($v['form_type'] == 'select') || ($v['form_type'] == 'checkbox') :
$set= db('admin_field')->where(['types' => 'crm_customer', 'field' => $v['field']])->find();

@ -309,7 +309,7 @@ class Index extends ApiCommon
foreach ($time['list'] as $val) {
$item = [];
$item['type'] = $val['type'];
$item['type'] = date('m-d',strtotime($val['type']));
$item['money'] = $res_money[$val['type']]['sum'] ?: 0;
$money += $item['money'];

@ -135,7 +135,7 @@ class Invoice extends ApiCommon
$param['check_user_id'] = is_array($check_user_id) ? ',' . implode(',', $check_user_id) . ',' : $check_user_id;
} else {
# 审批流停用,将状态改为审核通过
$param['check_status'] = 2;
$param['check_status'] = 7;
}
// 数据验证
@ -350,7 +350,7 @@ class Invoice extends ApiCommon
// }
$checkStatus = $invoiceLogic->getExamineStatus($param['invoice_id']);
if (!in_array($checkStatus, ['3', '4', '5', '6'])) return resultArray(['error' => '当前状态为审批中或已审批通过,不可编辑']);
if (!in_array($checkStatus, ['3', '4', '5', '6', '7']) && $checkStatus!=0) return resultArray(['error' => '当前状态为审批中或已审批通过,不可编辑']);
# 自动设置发票编号
$numberInfo = [];

@ -233,6 +233,7 @@ class Leads extends ApiCommon
$data['create_time'] = time();
$data['update_time'] = time();
$data['next_time'] = $leadsInfo['next_time'];
if (empty($data['telephone'])) $data['telephone'] = 0;
# 获取客户的时间
$data['obtain_time'] = time();
@ -245,7 +246,9 @@ class Leads extends ApiCommon
$errorMessage[] = '线索《' . $leadsInfo['name'] . '》转化失败,错误原因:无权限;';
continue;
}
$resCustomer = $customerModel->createData($data);
if (!$resCustomer) {
$errorMessage[] = '线索《' . $leadsInfo['name'] . '》转化失败,错误原因:' . $customerModel->getError();
continue;

@ -490,11 +490,12 @@ class Message extends ApiCommon
switch ($type) {
case '1' :
$param['end_time'] = array('between',array(date('Y-m-d',time()),date('Y-m-d',time()+86400*$expireDay)));
$param['expire_remind'] = 1;
$param['expire_remind'] = 0;
break;
case '2' : $param['end_time'] = array('lt',date('Y-m-d',time())); break;
}
$data = $contractModel->getDataList($param);
// p($contractModel->getLastSql());
if ($types == 'list') {
return resultArray(['data' => $data]);
}

@ -74,7 +74,7 @@ class Receivables extends ApiCommon
$excelModel = new \app\admin\model\Excel();
// 导出的字段列表
$fieldModel = new \app\admin\model\Field();
$field_list = $fieldModel->getIndexFieldConfig('crm_receivables', $userInfo['id']);
$field_list = $fieldModel->getIndexFieldConfig('crm_receivables', $userInfo['id'],'','excel');
// 文件名
$file_name = '5kcrm_receivables_' . date('Ymd');
$model = model('Receivables');
@ -148,7 +148,10 @@ class Receivables extends ApiCommon
$param['check_user_id'] = is_array($check_user_id) ? ',' . implode(',', $check_user_id) . ',' : $check_user_id;
} else {
# 审批流停用,将状态改为审核通过
$param['check_status'] = 2;
// $param['check_status'] = 2;
# 审批流停用,将状态改为正常 zjf 20210727 默认值为7
$param['check_status'] = 7;
}
$res = $receivablesModel->createData($param);
@ -224,7 +227,7 @@ class Receivables extends ApiCommon
}
//已进行审批,不能编辑
if (!in_array($dataInfo['check_status'], ['3', '4', '5', '6'])) {
if (!in_array($dataInfo['check_status'], ['3', '4', '5', '6', '7']) && $dataInfo['check_status']!=0) {
return resultArray(['error' => '当前状态为审批中或已审批通过,不可编辑']);
}
@ -271,7 +274,6 @@ class Receivables extends ApiCommon
}
}
}
$res = $receivablesModel->updateDataById($param, $param['id']);
if ($res) {
//将审批记录至为无效
@ -474,7 +476,19 @@ class Receivables extends ApiCommon
//审批记录
$resRecord = $examineRecordModel->createData($checkData);
$receivablesPlan=db('crm_receivables_plan')->where('receivables_id',$param['id'])->find();
$data=[];
$data['un_money']=$receivablesPlan['real_money']-$dataInfo['money'] <= 0 ? 0 :$receivablesPlan['un_money']-$dataInfo['money'];
$data['real_money']=$receivablesPlan['real_money']-$dataInfo['money'] <= 0 ?$dataInfo['money']:$receivablesPlan['real_money']-$dataInfo['money'];
$data['real_data']=date('Y-m-d',time());
if( $data['un_money']==0){
$data['status']=1;
}else{
$data['status']=2;
}
if(!db('crm_receivables_plan')->where('receivables_id',$param['id'])->update($data)){
return resultArray(['data' => '审批失败,未更新回款计划信息!']);
}
if ($is_end == 1 && !empty($status)) {
//发送站内信 通过
(new Message())->send(

@ -162,4 +162,41 @@ class ReceivablesPlan extends ApiCommon
return resultArray(['error'=>'参数错误']);
}
}
/**
* 回款计划导出
* @param
* @return
* @author Michael_xu
*/
public function excelExport()
{
$param = $this->param;
$userInfo = $this->userInfo;
$param['user_id'] = $userInfo['id'];
$action_name = '导出全部';
if ($param['plan_id']) {
$param['plan_id'] = ['condition' => 'in', 'value' => $param['plan_id'], 'form_type' => 'text', 'name' => ''];
$action_name='导出选中';
}
$excelModel = new \app\admin\model\Excel();
// 导出的字段列表
$fieldModel = new \app\admin\model\Field();
$field_list = $fieldModel->getIndexFieldConfig('crm_receivables_plan', $userInfo['id'],'','excel');
// 文件名
$file_name = '5kcrm_receivables_plan_' . date('Ymd');
$model = model('ReceivablesPlan');
$temp_file = $param['temp_file'];
unset($param['temp_file']);
$page = $param['page'] ?: 1;
unset($param['page']);
unset($param['export_queue_index']);
// RecordActionLog($userInfo['id'],'crm_receivables_plan','excelexport',$action_name,'','','导出回款');
return $excelModel->batchExportCsv($file_name, $temp_file, $field_list, $page, function ($page, $limit) use ($model, $param, $field_list) {
$param['page'] = $page;
$param['limit'] = $limit;
$data = $model->getDataList($param);
$data['list'] = $model->exportHandle($data['list'], $field_list, 'ReceivablesPlan');
return $data;
});
}
}

@ -442,13 +442,15 @@ class ActivityLogic
$param['type'] = 1;
$param['next_time'] = !empty($param['next_time']) ? strtotime($param['next_time']) : 0;
$param['business_ids'] = !empty($param['business_ids']) ? arrayToString($param['business_ids']) : '';
$param['create_time'] = time();
$param['update_time'] = time();
if(empty($param['excel'])){
if (!empty($param['contacts_ids'])) $param['contacts_ids'] = ',' . $param['contacts_ids'] . ',';
}else{
$param['create_time'] = $param['create_time'];
unset($param['excel']);
}
$activityJson = Activity::create($param);
if (empty($activityJson)) return false;

@ -31,19 +31,12 @@ class IndexLogic extends Common
{
$adminModel = new \app\admin\model\Admin();
$userModel = new \app\admin\model\User();
$customerModel = new \app\crm\model\Customer();
$contactsModel = new \app\crm\model\Contacts();
$businessModel = new \app\crm\model\Business();
$contractModel = new \app\crm\model\Contract();
$receivablesModel = new \app\crm\model\Receivables();
$activityModel = new \app\crm\model\Activity();
$last_between_time = ByDateTime($param['type']);
if($param['start_time'] && $param['end_time']){
$param['start_time']=$param['start_time'].' 00:00:00';
$param['end_time']=$param['end_time'].' 23:59:59';
}
$whereArr = $adminModel->getWhere($param, 1, ''); //统计条件
// $lastArr = $adminModel->getWhere($param, 1, '', true); //统计条件
$userIds = $whereArr['userIds'];
$between_time = $whereArr['between_time'];
@ -853,13 +846,11 @@ class IndexLogic extends Common
if ($v['activity_type'] == 2) {
$activity_name = Db::name('crm_customer')->where('customer_id', $v['activity_type_id'])->find();
$list[$k]['activity_type_name'] = $activity_name['name'];
$activity_business = Db::name('crm_business')->where('business_id', $v['activity_type_id'])->select();
$activity_contacts = Db::name('crm_contacts')->where('contacts_id', $v['activity_type_id'])->select();
$activity_business = Db::name('crm_business')->where('business_id',['in',$v['business_ids']])->find();
$activity_contacts = Db::name('crm_contacts')->where('contacts_id', ['in',$v['contacts_ids']])->find();
$list[$k]['business_list'] = $activity_business ?: [];
$list[$k]['contacts_list'] = $activity_contacts ?: [];
}
if ($v['activity_type'] == 3) {
$activity_name = Db::name('crm_contacts')->where('contacts_id', $v['activity_type_id'])->find();
$list[$k]['activity_type_name'] = $activity_name['name'];
@ -913,7 +904,7 @@ class IndexLogic extends Common
->alias('t')
->join('__ADMIN_USER__ user', 'user.id = t.create_user_id', 'LEFT')
->where($where_activity)
->field('t.content,t.next_time,t.update_time,t.create_time,t.category,t.activity_type,t.type,t.activity_id,t.activity_type_id,user.realname as create_user_name,user.thumb_img')
->field('t.business_ids,t.contacts_ids,t.content,t.next_time,t.update_time,t.create_time,t.category,t.activity_type,t.type,t.activity_id,t.activity_type_id,user.realname as create_user_name,user.thumb_img')
->page($param['page'], $param['limit'])
->order('t.create_time desc')
->select();
@ -928,8 +919,8 @@ class IndexLogic extends Common
if ($param['activity_type'] == 2) {
$activity_name = Db::name('crm_customer')->where('customer_id', $v['activity_type_id'])->find();
$list[$k]['activity_type_name'] = $activity_name['name'];
$activity_business = Db::name('crm_business')->where('business_id', $v['activity_type_id'])->select();
$activity_contacts = Db::name('crm_contacts')->where('contacts_id', $v['activity_type_id'])->select();
$activity_business = Db::name('crm_business')->where('business_id',['in',$v['business_ids']])->find();
$activity_contacts = Db::name('crm_contacts')->where('contacts_id', ['in',$v['contacts_ids']])->find();
$list[$k]['business_list'] = $activity_business ?: [];
$list[$k]['contacts_list'] = $activity_contacts ?: [];
}

@ -176,21 +176,35 @@ class InvoiceLogic
$positionField = $fieldModel->getFieldByFormType('crm_invoice', 'position'); // 地址类型字段
$handwritingField = $fieldModel->getFieldByFormType('crm_invoice', 'handwriting_sign'); // 手写签名类型字段
$locationField = $fieldModel->getFieldByFormType('crm_invoice', 'location'); // 定位类型字段
$boxField = $fieldModel->getFieldByFormType('crm_customer', 'checkbox'); // 多选类型字段
$floatField = $fieldModel->getFieldByFormType('crm_invoice', 'floatnumber'); // 货币类型字段
// $fieldGrant = db('admin_field_mask')->where('types', 'invoice')->select();
# 扩展数据
$extraData = [];
$invoice_id_list = !empty($list) ? array_column($list, 'invoice_id') : [];
$extraList = db('crm_invoice_data')->whereIn('invoice_id', $invoice_id_list)->select();
foreach ($extraList AS $key => $value) {
foreach ($extraList as $key => $value) {
$extraData[$value['invoice_id']][$value['field']] = $value['content'];
}
$grantData = getFieldGrantData($userId);
foreach ($grantData['crm_invoice'] as $key => $value) {
foreach ($value as $ke => $va) {
if($va['maskType']!=0){
$fieldGrant[$ke]['maskType'] = $va['maskType'];
$fieldGrant[$ke]['form_type'] = $va['form_type'];
$fieldGrant[$ke]['field'] = $va['field'];
}
}
}
# 处理发票类型
foreach ($list as $key => $value) {
$list[$key]['check_status_info'] = $this->check_status[$value['check_status']];
$list[$key]['invoice_status'] = !empty($value['invoice_status']) ? '已开票' : '未开票';
$list[$key]['create_time'] = !empty($value['create_time']) ? date('Y-m-d H:i:s', $value['create_time']) : null;
$list[$key]['update_time'] = !empty($value['update_time']) ? date('Y-m-d H:i:s', $value['update_time']) : null;
# 系统字段 负责人部门 zjf 20210726
$ownerUserIdInfo = $userModel->getUserById($value['owner_user_id']);
$list[$key]['owner_user_structure_name'] = $ownerUserIdInfo['structure_name'];
foreach ($userField as $k => $val) {
$usernameField = !empty($value[$val]) ? db('admin_user')->whereIn('id', stringToArray($value[$val]))->column('realname') : [];
$list[$key][$val] = implode($usernameField, ',');
@ -214,7 +228,7 @@ class InvoiceLogic
$list[$key][$val] = !empty($extraData[$value['invoice_id']][$val]) ? json_decode($extraData[$value['invoice_id']][$val], true) : null;
}
// 手写签名类型字段
foreach ($handwritingField AS $k => $val) {
foreach ($handwritingField as $k => $val) {
$handwritingData = !empty($value[$val]) ? db('admin_file')->where('file_id', $value[$val])->value('file_path') : null;
$list[$key][$val] = ['url' => !empty($handwritingData) ? getFullPath($handwritingData) : null];
}
@ -222,12 +236,38 @@ class InvoiceLogic
foreach ($locationField as $k => $val) {
$list[$key][$val] = !empty($extraData[$value['invoice_id']][$val]) ? json_decode($extraData[$value['invoice_id']][$val], true) : null;
}
// 多选框类型字段
foreach ($boxField as $k => $val) {
$list[$key][$val] = !empty($value[$val]) ? trim($value[$val], ',') : null;
}
//货币类型字段
foreach ($floatField as $k => $val) {
$list[$key][$val] = $value[$val] != '0.00' ? (string)$value[$val] : null;
}
//掩码相关类型字段
foreach ($fieldGrant AS $key => $v){
//掩码相关类型字段
if ($v['maskType']!=0 && $v['form_type'] == 'mobile') {
$pattern = "/(1[3458]{1}[0-9])[0-9]{4}([0-9]{4})/i";
$rs = preg_replace($pattern, "$1****$2", $value[$v['field']]);
$list[$k][$v['field']] = !empty($value[$v['field']]) ? (string)$rs : null;
} elseif ($v['maskType']!=0 && $v['form_type'] == 'email') {
$email_array = explode("@", $value[$v['field']]);
$prevfix = (strlen($email_array[0]) < 4) ? "" : substr($value[$v['field']], 0, 2); //
$str = preg_replace('/([\d\w+_-]{0,100})@/', "***@", $value[$v['field']], -1, $count);
$rs = $prevfix . $str;
$list[$k][$v['field']] = !empty($value[$v['field']]) ?$rs: null;
} elseif ($v['maskType']!=0 && in_array($v['form_type'],['position','floatnumber'])) {
$list[$k][$v['field']] = !empty($value[$v['field']]) ? (string)substr_replace($value[$v['field']], '*****',0,strlen($value[$v['field']])) : null;
}
}
$data = [];
$data['list'] = $list ?: [];
$data['dataCount'] = $dataCount ?: 0;
return $data;
}
}
/**
* 创建
@ -235,7 +275,8 @@ class InvoiceLogic
* @param $param
* @return Invoice|int|string
*/
public function save($param)
public
function save($param)
{
return db('crm_invoice')->insert($param, false, true);
}
@ -250,7 +291,8 @@ class InvoiceLogic
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function read($invoiceId, $isUpdate)
public
function read($invoiceId, $isUpdate)
{
$apiCommon = new ApiCommon();
@ -263,7 +305,32 @@ class InvoiceLogic
$dataArray = $dataObject->toArray();
if (!empty($isUpdate)) return $dataArray;
$grantData = getFieldGrantData($userId);
foreach ($grantData['crm_leads'] as $key => $value) {
foreach ($value as $ke => $va) {
if($va['maskType']!=0){
$fieldGrant[$ke]['maskType'] = $va['maskType'];
$fieldGrant[$ke]['form_type'] = $va['form_type'];
$fieldGrant[$ke]['field'] = $va['field'];
}
}
}
foreach ($fieldGrant AS $key => $val){
//掩码相关类型字段
if ($val['maskType']!=0 && $val['form_type'] == 'mobile') {
$pattern = "/(1[3458]{1}[0-9])[0-9]{4}([0-9]{4})/i";
$rs = preg_replace($pattern, "$1****$2", $dataArray[$val['field']]);
$dataArray[$val['field']] = !empty($dataInfo[$val['field']]) ? (string)$rs : null;
} elseif ($val['maskType']!=0 && $val['form_type'] == 'email') {
$email_array = explode("@", $dataArray[$val['field']]);
$prevfix = (strlen($email_array[0]) < 4) ? "" : substr($dataArray[$val['field']], 0, 2); //
$str = preg_replace('/([\d\w+_-]{0,100})@/', "***@", $dataArray[$val['field']], -1, $count);
$rs = $prevfix . $str;
$dataArray[$val['field']] = !empty($dataInfo[$val['field']]) ?$rs: null;
} elseif ($val['maskType']!=0 && in_array($val['form_type'],['position','floatnumber'])) {
$dataArray[$val['field']] = !empty($dataInfo[$val['field']]) ? (string)substr_replace($dataArray[$val['field']], '*****',0,strlen($dataArray[$val['field']])) : null;
}
}
# 主键ID
$result['invoice_id'] = $dataArray['invoice_id'];
@ -324,7 +391,8 @@ class InvoiceLogic
* @param $param
* @return Invoice
*/
public function update($param)
public
function update($param)
{
return Invoice::update($param);
}
@ -335,7 +403,8 @@ class InvoiceLogic
* @param $where
* @return int
*/
public function delete($where)
public
function delete($where)
{
return Invoice::destroy($where);
}
@ -350,7 +419,8 @@ class InvoiceLogic
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getExamineStatus($invoiceId, $isDelete = false)
public
function getExamineStatus($invoiceId, $isDelete = false)
{
# 删除
if ($isDelete) {
@ -368,7 +438,8 @@ class InvoiceLogic
* @param $ownerUserId
* @return Invoice
*/
public function transfer($invoiceIds, $ownerUserId)
public
function transfer($invoiceIds, $ownerUserId)
{
return Invoice::whereIn('invoice_id', $invoiceIds)->update(['owner_user_id' => $ownerUserId]);
}
@ -379,7 +450,8 @@ class InvoiceLogic
* @param $param
* @return Invoice
*/
public function setInvoice($param)
public
function setInvoice($param)
{
return Invoice::update($param);
}
@ -393,7 +465,8 @@ class InvoiceLogic
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getExamineInfo($invoiceId)
public
function getExamineInfo($invoiceId)
{
$field = ['check_status', 'flow_id', 'order_id', 'check_user_id', 'flow_user_id', 'invoice_apple_number', 'owner_user_id', 'create_user_id'];
@ -406,7 +479,8 @@ class InvoiceLogic
* @param $data
* @return Invoice
*/
public function setExamineInfo($data)
public
function setExamineInfo($data)
{
return Invoice::update($data);
}
@ -420,7 +494,8 @@ class InvoiceLogic
* @param $content
* @param $userId
*/
public function createExamineRecord($invoiceId, $examineInfo, $realname, $content, $userId)
public
function createExamineRecord($invoiceId, $examineInfo, $realname, $content, $userId)
{
$data = [
'types' => 'crm_invoice',
@ -442,7 +517,8 @@ class InvoiceLogic
* @param $where
* @return int|mixed|string|null
*/
public function getInvoiceId($where)
public
function getInvoiceId($where)
{
return Db::name('crm_invoice')->where($where)->value('invoice_id');
}

@ -100,6 +100,9 @@ class VisitLogic extends Common
$positionField = $fieldModel->getFieldByFormType('crm_visit', 'position'); // 地址类型字段
$handwritingField = $fieldModel->getFieldByFormType('crm_visit', 'handwriting_sign'); // 手写签名类型字段
$locationField = $fieldModel->getFieldByFormType('crm_visit', 'location'); // 定位类型字段
$boxField = $fieldModel->getFieldByFormType('crm_customer', 'checkbox'); // 多选类型字段
$floatField = $fieldModel->getFieldByFormType('crm_visit', 'floatnumber'); // 货币类型字段
// $fieldGrant = db('admin_field_mask')->where('types', 'visit')->select();
# 处理人员和部门类型的排序报错问题(前端传来的是包含_name的别名字段)
$temporaryField = str_replace('_name', '', $order_field);
if (in_array($temporaryField, $userField) || in_array($temporaryField, $structureField)) {
@ -147,12 +150,26 @@ class VisitLogic extends Common
foreach ($extraList AS $key => $value) {
$extraData[$value['visit_id']][$value['field']] = $value['content'];
}
$grantData = getFieldGrantData($user_id);
foreach ($grantData['crm_visit_'] as $key => $value) {
foreach ($value as $ke => $va) {
if($va['maskType']!=0){
$fieldGrant[$ke]['maskType'] = $va['maskType'];
$fieldGrant[$ke]['form_type'] = $va['form_type'];
$fieldGrant[$ke]['field'] = $va['field'];
}
}
}
foreach ($list as $k => $v) {
$list[$k]['contract_num'] = $v['contract_number'];
$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'] : '';
# 系统字段 负责人部门 zjf 20210726
$list[$k]['owner_user_structure_name'] = $list[$k]['owner_user_id_info']['structure_name'];
foreach ($userField as $key => $val) {
$usernameField = !empty($v[$val]) ? db('admin_user')->whereIn('id', stringToArray($v[$val]))->column('realname') : [];
$list[$k][$val.'_name'] = implode($usernameField, ',');
@ -184,6 +201,31 @@ class VisitLogic extends Common
foreach ($locationField AS $key => $val) {
$list[$k][$val] = !empty($extraData[$v['visit_id']][$val]) ? json_decode($extraData[$v['visit_id']][$val], true) : null;
}
// 多选框类型字段
foreach ($boxField AS $key => $val) {
$list[$k][$val] = !empty($v[$val]) ? trim($v[$val], ',') : null;
}
// 货币类型字段
foreach ($floatField AS $key => $val) {
$list[$k][$val] = $v[$val]!='0.00' ? (string)$v[$val] : null;
}
//掩码相关类型字段
foreach ($fieldGrant AS $key => $val){
//掩码相关类型字段
if ($val['maskType']!=0 && $val['form_type'] == 'mobile') {
$pattern = "/(1[3458]{1}[0-9])[0-9]{4}([0-9]{4})/i";
$rs = preg_replace($pattern, "$1****$2", $v[$val['field']]);
$list[$k][$val['field']] = !empty($v[$val['field']]) ? (string)$rs : null;
} elseif ($val['maskType']!=0 && $val['form_type'] == 'email') {
$email_array = explode("@", $v[$val['field']]);
$prevfix = (strlen($email_array[0]) < 4) ? "" : substr($v[$val['field']], 0, 2); //
$str = preg_replace('/([\d\w+_-]{0,100})@/', "***@", $v[$val['field']], -1, $count);
$rs = $prevfix . $str;
$list[$k][$val['field']] = !empty($v[$val['field']]) ?$rs: null;
} elseif ($val['maskType']!=0 && in_array($val['form_type'],['position','floatnumber'])) {
$list[$k][$val['field']] = !empty($v[$val['field']]) ? (string)substr_replace($v[$val['field']], '*****',0,strlen($v[$val['field']])) : null;
}
}
$list[$k]['contract_id_info']['contract_id'] = $v['contract_id'];
$list[$k]['contract_id_info']['name'] = $v['contract_name'];
$list[$k]['customer_id_info']['customer_id'] = $v['create_user_id'];
@ -226,6 +268,32 @@ class VisitLogic extends Common
$this->error = '暂无此数据';
return false;
}
$grantData = getFieldGrantData($userId);
foreach ($grantData['crm_leads'] as $key => $value) {
foreach ($value as $ke => $va) {
if($va['maskType']!=0){
$fieldGrant[$ke]['maskType'] = $va['maskType'];
$fieldGrant[$ke]['form_type'] = $va['form_type'];
$fieldGrant[$ke]['field'] = $va['field'];
}
}
}
foreach ($fieldGrant AS $key => $val){
//掩码相关类型字段
if ($val['maskType']!=0 && $val['form_type'] == 'mobile') {
$pattern = "/(1[3458]{1}[0-9])[0-9]{4}([0-9]{4})/i";
$rs = preg_replace($pattern, "$1****$2", $dataInfo[$val['field']]);
$dataInfo[$val['field']] = !empty($dataInfo[$val['field']]) ? (string)$rs : null;
} elseif ($val['maskType']!=0 && $val['form_type'] == 'email') {
$email_array = explode("@", $dataInfo[$val['field']]);
$prevfix = (strlen($email_array[0]) < 4) ? "" : substr($dataInfo[$val['field']], 0, 2); //
$str = preg_replace('/([\d\w+_-]{0,100})@/', "***@", $dataInfo[$val['field']], -1, $count);
$rs = $prevfix . $str;
$dataInfo[$val['field']] = !empty($dataInfo[$val['field']]) ?$rs: null;
} elseif ($val['maskType']!=0 && in_array($val['form_type'],['position','floatnumber'])) {
$dataInfo[$val['field']] = !empty($dataInfo[$val['field']]) ? (string)substr_replace($dataInfo[$val['field']], '*****',0,strlen($v[$val['field']])) : null;
}
}
$userModel = new \app\admin\model\User();
$dataInfo['create_user_id_info'] = isset($dataInfo['create_user_id']) ? $userModel->getUserById($dataInfo['create_user_id']) : [];
$dataInfo['owner_user_id_info'] = isset($dataInfo['owner_user_id']) ? $userModel->getUserById($dataInfo['owner_user_id']) : [];
@ -584,13 +652,25 @@ class VisitLogic extends Common
public function getSystemInfo($id)
{
# 回访
$visit = Db::name('crm_visit')->field(['create_user_id', 'create_time', 'update_time'])->where('visit_id', $id)->find();
$visit = Db::name('crm_visit')->field(['create_user_id', 'owner_user_id', 'create_time', 'update_time'])->where('visit_id', $id)->find();
# 创建人
$realname = Db::name('admin_user')->where('id', $visit['create_user_id'])->value('realname');
# zjf 20210726
$userModel = new \app\admin\model\User();
$ownerUserInfo = $userModel->getUserById($visit['owner_user_id']);
# 负责人部门
$ownerStructureName = $ownerUserInfo['structure_name'];
# 负责人
$ownerUserName = $ownerUserInfo['realname'];
return [
'create_user_id' => $realname,
'owner_user_id' => $ownerUserName,
'create_time' => date('Y-m-d H:i:s', $visit['create_time']),
'update_time' => date('Y-m-d H:i:s', $visit['update_time'])
'update_time' => date('Y-m-d H:i:s', $visit['update_time']),
'owner_user_structure_name' => $ownerStructureName
];
}
}

@ -161,6 +161,9 @@ class Business extends Common
$positionField = $fieldModel->getFieldByFormType('crm_business', 'position'); // 地址类型字段
$handwritingField = $fieldModel->getFieldByFormType('crm_business', 'handwriting_sign'); // 手写签名类型字段
$locationField = $fieldModel->getFieldByFormType('crm_business', 'location'); // 定位类型字段
$boxField = $fieldModel->getFieldByFormType('crm_business', 'checkbox'); // 多选类型字段
$floatField = $fieldModel->getFieldByFormType('crm_business', 'floatnumber'); // 货币类型字段
// $fieldGrant = db('admin_field_mask')->where('types', 'business')->select();
# 处理人员和部门类型的排序报错问题(前端传来的是包含_name的别名字段)
$temporaryField = str_replace('_name', '', $order_field);
if (in_array($temporaryField, $userField) || in_array($temporaryField, $structureField)) {
@ -224,6 +227,16 @@ class Business extends Common
foreach ($extraList AS $key => $value) {
$extraData[$value['business_id']][$value['field']] = $value['content'];
}
$grantData = getFieldGrantData($user_id);
foreach ($grantData['crm_business'] as $key => $value) {
foreach ($value as $ke => $va) {
if($va['maskType']!=0){
$fieldGrant[$ke]['maskType'] = $va['maskType'];
$fieldGrant[$ke]['form_type'] = $va['form_type'];
$fieldGrant[$ke]['field'] = $va['field'];
}
}
}
foreach ($list as $k => $v) {
$list[$k]['customer_id_info']['customer_id'] = $v['customer_id'];
$list[$k]['customer_id_info']['name'] = $v['customer_name'];
@ -262,6 +275,31 @@ class Business extends Common
foreach ($locationField AS $key => $val) {
$list[$k][$val] = !empty($extraData[$v['business_id']][$val]) ? json_decode($extraData[$v['business_id']][$val], true) : null;
}
// 多选框类型字段
foreach ($boxField AS $key => $val) {
$list[$k][$val] = !empty($v[$val]) ? trim($v[$val], ',') : null;
}
// 货币类型字段
foreach ($floatField AS $key => $val) {
$list[$k][$val] = $v[$val]!='0.00' ? (string)$v[$val] : null;
}
//掩码相关类型字段
foreach ($fieldGrant AS $key => $val){
//掩码相关类型字段
if ($val['maskType']!=0 && $val['form_type'] == 'mobile') {
$pattern = "/(1[3458]{1}[0-9])[0-9]{4}([0-9]{4})/i";
$rs = preg_replace($pattern, "$1****$2", $v[$val['field']]);
$list[$k][$val['field']] = !empty($v[$val['field']]) ? (string)$rs : null;
} elseif ($val['maskType']!=0 && $val['form_type'] == 'email') {
$email_array = explode("@", $v[$val['field']]);
$prevfix = (strlen($email_array[0]) < 4) ? "" : substr($v[$val['field']], 0, 2); //
$str = preg_replace('/([\d\w+_-]{0,100})@/', "***@", $v[$val['field']], -1, $count);
$rs = $prevfix . $str;
$list[$k][$val['field']] = !empty($v[$val['field']]) ?$rs: null;
} elseif ($val['maskType']!=0 && in_array($val['form_type'],['position','floatnumber'])) {
$list[$k][$val['field']] = !empty($v[$val['field']]) ? (string)substr_replace($v[$val['field']], '*****',0,strlen($v[$val['field']])) : null;
}
}
$statusInfo = [];
$status_count = 0;
if (!$v['is_end']) {
@ -301,6 +339,9 @@ class Business extends Common
$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;
$list[$k]['last_time'] = !empty($v['last_time']) ? date('Y-m-d H:i:s', $v['last_time']) : null;
# 系统字段 负责人部门 zjf 20210726
$list[$k]['owner_user_structure_name'] = $list[$k]['owner_user_id_info']['structure_name'];
}
$data = [];
$data['list'] = $list ?: [];
@ -633,13 +674,41 @@ class Business extends Common
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getDataById($id = '', $userId = 0)
public function getDataById($id = '', $userId = 0,$model='')
{
$dataInfo = db('crm_business')->where('business_id', $id)->find();
if (!$dataInfo) {
$this->error = '暂无此数据';
return false;
}
if(empty($model) && $model!='update'){
$grantData = getFieldGrantData($userId);
foreach ($grantData['crm_business'] as $key => $value) {
foreach ($value as $ke => $va) {
if($va['maskType']!=0){
$fieldGrant[$ke]['maskType'] = $va['maskType'];
$fieldGrant[$ke]['form_type'] = $va['form_type'];
$fieldGrant[$ke]['field'] = $va['field'];
}
}
}
foreach ($fieldGrant AS $key => $val){
//掩码相关类型字段
if ($val['maskType']!=0 && $val['form_type'] == 'mobile') {
$pattern = "/(1[3458]{1}[0-9])[0-9]{4}([0-9]{4})/i";
$rs = preg_replace($pattern, "$1****$2", $dataInfo[$val['field']]);
$dataInfo[$val['field']] = !empty($dataInfo[$val['field']]) ? (string)$rs : null;
} elseif ($val['maskType']!=0 && $val['form_type'] == 'email') {
$email_array = explode("@", $dataInfo[$val['field']]);
$prevfix = (strlen($email_array[0]) < 4) ? "" : substr($dataInfo[$val['field']], 0, 2); //
$str = preg_replace('/([\d\w+_-]{0,100})@/', "***@", $dataInfo[$val['field']], -1, $count);
$rs = $prevfix . $str;
$dataInfo[$val['field']] = !empty($dataInfo[$val['field']]) ?$rs: null;
} elseif ($val['maskType']!=0 && in_array($val['form_type'],['position','floatnumber'])) {
$dataInfo[$val['field']] = !empty($dataInfo[$val['field']]) ? (string)substr_replace($dataInfo[$val['field']], '*****',0,strlen($dataInfo[$val['field']])) : null;
}
}
}
$userModel = new \app\admin\model\User();
$dataInfo['create_user_id_info'] = isset($dataInfo['create_user_id']) ? $userModel->getUserById($dataInfo['create_user_id']) : [];
$dataInfo['owner_user_id_info'] = isset($dataInfo['owner_user_id']) ? $userModel->getUserById($dataInfo['owner_user_id']) : [];
@ -902,15 +971,24 @@ class Business extends Common
public function getSystemInfo($id)
{
# 商机
$business = Db::name('crm_business')->field(['create_user_id', 'create_time', 'update_time', 'last_time'])->where('business_id', $id)->find();
$business = Db::name('crm_business')->field(['create_user_id' ,'owner_user_id', 'create_time', 'update_time', 'last_time'])->where('business_id', $id)->find();
# 创建人
$realname = Db::name('admin_user')->where('id', $business['create_user_id'])->value('realname');
# zjf 20210726
$userModel = new \app\admin\model\User();
$ownerUserInfo = $userModel->getUserById($business['owner_user_id']);
# 负责人部门
$ownerStructureName = $ownerUserInfo['structure_name'];
# 负责人
$ownerUserName = $ownerUserInfo['realname'];
return [
'create_user_id' => $realname,
'owner_user_id' => $ownerUserName,
'create_time' => date('Y-m-d H:i:s', $business['create_time']),
'update_time' => date('Y-m-d H:i:s', $business['update_time']),
'last_time' => !empty($business['last_time']) ? date('Y-m-d H:i:s', $business['last_time']) : ''
'last_time' => !empty($business['last_time']) ? date('Y-m-d H:i:s', $business['last_time']) : '',
'owner_user_structure_name' => $ownerStructureName
];
}

@ -136,6 +136,9 @@ class Contacts extends Common
$positionField = $fieldModel->getFieldByFormType('crm_contacts', 'position'); // 地址类型字段
$handwritingField = $fieldModel->getFieldByFormType('crm_contacts', 'handwriting_sign'); // 手写签名类型字段
$locationField = $fieldModel->getFieldByFormType('crm_contacts', 'location'); // 定位类型字段
$boxField = $fieldModel->getFieldByFormType('crm_contacts', 'checkbox'); // 多选类型字段
$floatField = $fieldModel->getFieldByFormType('crm_contacts', 'floatnumber'); // 货币类型字段
// $fieldGrant = db('admin_field_mask')->where('types', 'contacts')->select();
# 处理人员和部门类型的排序报错问题(前端传来的是包含_name的别名字段)
$temporaryField = str_replace('_name', '', $order_field);
if (in_array($temporaryField, $userField) || in_array($temporaryField, $structureField)) {
@ -187,6 +190,16 @@ class Contacts extends Common
foreach ($extraList as $key => $value) {
$extraData[$value['contacts_id']][$value['field']] = $value['content'];
}
$grantData = getFieldGrantData($user_id);
foreach ($grantData['crm_contacts'] as $key => $value) {
foreach ($value as $ke => $va) {
if($va['maskType']!=0){
$fieldGrant[$ke]['maskType'] = $va['maskType'];
$fieldGrant[$ke]['form_type'] = $va['form_type'];
$fieldGrant[$ke]['field'] = $va['field'];
}
}
}
foreach ($list as $k => $v) {
$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']) : [];
@ -223,6 +236,31 @@ class Contacts extends Common
foreach ($locationField AS $key => $val) {
$list[$k][$val] = !empty($extraData[$v['contacts_id']][$val]) ? json_decode($extraData[$v['contacts_id']][$val], true) : null;
}
// 多选框类型字段
foreach ($boxField AS $key => $val) {
$list[$k][$val] = !empty($v[$val]) ? trim($v[$val], ',') : null;
}
// 货币类型字段
foreach ($floatField AS $key => $val) {
$list[$k][$val] = $v[$val]!='0.00' ? (string)$v[$val] : null;
}
//掩码相关类型字段
foreach ($fieldGrant AS $key => $val){
//掩码相关类型字段
if ($val['maskType']!=0 && $val['form_type'] == 'mobile') {
$pattern = "/(1[3458]{1}[0-9])[0-9]{4}([0-9]{4})/i";
$rs = preg_replace($pattern, "$1****$2", $v[$val['field']]);
$list[$k][$val['field']] = !empty($v[$val['field']]) ? (string)$rs : null;
} elseif ($val['maskType']!=0 && $val['form_type'] == 'email') {
$email_array = explode("@", $v[$val['field']]);
$prevfix = (strlen($email_array[0]) < 4) ? "" : substr($v[$val['field']], 0, 2); //
$str = preg_replace('/([\d\w+_-]{0,100})@/', "***@", $v[$val['field']], -1, $count);
$rs = $prevfix . $str;
$list[$k][$val['field']] = !empty($v[$val['field']]) ?$rs: null;
} elseif ($val['maskType']!=0 && in_array($val['form_type'],['position','floatnumber'])) {
$list[$k][$val['field']] = !empty($v[$val['field']]) ? (string)substr_replace($v[$val['field']], '*****',0,strlen($v[$val['field']])) : null;
}
}
//权限
$permission = [];
$is_read = 0;
@ -248,6 +286,9 @@ class Contacts extends Common
$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'] : '';
# 系统字段 负责人部门 zjf 20210726
$list[$k]['owner_user_structure_name'] = $list[$k]['owner_user_id_info']['structure_name'];
}
$data = [];
$data['list'] = $list;
@ -586,7 +627,7 @@ class Contacts extends Common
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getDataById($id = '', $userId = 0)
public function getDataById($id = '', $userId = 0,$model='')
{
$map['contacts_id'] = $id;
$dataInfo = db('crm_contacts')->where($map)->find();
@ -594,6 +635,35 @@ class Contacts extends Common
$this->error = '暂无此数据';
return false;
}
if(empty($model) && $model!='update'){
$grantData = getFieldGrantData($userId);
foreach ($grantData['crm_contacts'] as $key => $value) {
foreach ($value as $ke => $va) {
if($va['maskType']!=0){
$fieldGrant[$ke]['maskType'] = $va['maskType'];
$fieldGrant[$ke]['form_type'] = $va['form_type'];
$fieldGrant[$ke]['field'] = $va['field'];
}
}
}
foreach ($fieldGrant AS $key => $val){
//掩码相关类型字段
if ($val['maskType']!=0 && $val['form_type'] == 'mobile') {
$pattern = "/(1[3458]{1}[0-9])[0-9]{4}([0-9]{4})/i";
$rs = preg_replace($pattern, "$1****$2", $dataInfo[$val['field']]);
$dataInfo[$val['field']] = !empty($dataInfo[$val['field']]) ? (string)$rs : null;
} elseif ($val['maskType']!=0 && $val['form_type'] == 'email') {
$email_array = explode("@", $dataInfo[$val['field']]);
$prevfix = (strlen($email_array[0]) < 4) ? "" : substr($dataInfo[$val['field']], 0, 2); //
$str = preg_replace('/([\d\w+_-]{0,100})@/', "***@", $dataInfo[$val['field']], -1, $count);
$rs = $prevfix . $str;
$dataInfo[$val['field']] = !empty($dataInfo[$val['field']]) ?$rs: null;
} elseif ($val['maskType']!=0 && in_array($val['form_type'],['position','floatnumber'])) {
$dataInfo[$val['field']] = !empty($dataInfo[$val['field']]) ? (string)substr_replace($dataInfo[$val['field']], '*****',0,strlen($dataInfo[$val['field']])) : null;
}
}
}
$userModel = new \app\admin\model\User();
$dataInfo['create_user_id_info'] = isset($dataInfo['create_user_id']) ? $userModel->getUserById($dataInfo['create_user_id']) : [];
$dataInfo['owner_user_id_info'] = isset($dataInfo['owner_user_id']) ? $userModel->getUserById($dataInfo['owner_user_id']) : [];
@ -694,15 +764,25 @@ class Contacts extends Common
public function getSystemInfo($id)
{
# 联系人
$contacts = Db::name('crm_contacts')->field(['create_user_id', 'create_time', 'update_time', 'last_time'])->where('contacts_id', $id)->find();
$contacts = Db::name('crm_contacts')->field(['create_user_id','owner_user_id' , 'create_time', 'update_time', 'last_time'])->where('contacts_id', $id)->find();
# 创建人
$realname = Db::name('admin_user')->where('id', $contacts['create_user_id'])->value('realname');
# zjf 20210726
$userModel = new \app\admin\model\User();
$ownerUserInfo = $userModel->getUserById($contacts['owner_user_id']);
# 负责人部门
$ownerStructureName = $ownerUserInfo['structure_name'];
# 负责人
$ownerUserName = $ownerUserInfo['realname'];
return [
'create_user_id' => $realname,
'owner_user_id' => $ownerUserName,
'create_time' => date('Y-m-d H:i:s', $contacts['create_time']),
'update_time' => date('Y-m-d H:i:s', $contacts['update_time']),
'last_time' => !empty($contacts['last_time']) ? date('Y-m-d H:i:s', $contacts['last_time']) : ''
'last_time' => !empty($contacts['last_time']) ? date('Y-m-d H:i:s', $contacts['last_time']) : '',
'owner_user_structure_name' => $ownerStructureName
];
}
}

@ -23,7 +23,7 @@ class Contract extends Common
protected $createTime = 'create_time';
protected $updateTime = 'update_time';
protected $autoWriteTimestamp = true;
private $statusArr = ['0'=>'待审核','1'=>'审核中','2'=>'审核通过','3'=>'已拒绝','4'=>'已撤回','5'=>'未提交','6'=>'已作废'];
private $statusArr = ['0'=>'待审核','1'=>'审核中','2'=>'审核通过','3'=>'已拒绝','4'=>'已撤回','5'=>'未提交','6'=>'已作废', '7'=>'正常'];
/**
* [getDataList 合同list]
@ -36,6 +36,9 @@ class Contract extends Common
*/
public function getDataList($request)
{
// if($param['check_status'] == 2){
// die('11');
// }
$userModel = new \app\admin\model\User();
$structureModel = new \app\admin\model\Structure();
$fieldModel = new \app\admin\model\Field();
@ -62,8 +65,8 @@ class Contract extends Common
unset($request['isMessage']);
$request = $this->fmtRequest( $request );
$requestMap = $request['map'] ? : [];
$sceneModel = new \app\admin\model\Scene();
# getCount是代办事项传来的参数代办事项不需要使用场景
$sceneMap = [];
@ -148,6 +151,9 @@ class Contract extends Common
$positionField = $fieldModel->getFieldByFormType('crm_contract', 'position'); // 地址类型字段
$handwritingField = $fieldModel->getFieldByFormType('crm_contract', 'handwriting_sign'); // 手写签名类型字段
$locationField = $fieldModel->getFieldByFormType('crm_contract', 'location'); // 定位类型字段
$boxField = $fieldModel->getFieldByFormType('crm_contract', 'checkbox'); // 多选类型字段
$floatField = $fieldModel->getFieldByFormType('crm_contract', 'floatnumber'); // 货币类型字段
# 处理人员和部门类型的排序报错问题(前端传来的是包含_name的别名字段)
$temporaryField = str_replace('_name', '', $order_field);
if (in_array($temporaryField, $userField) || in_array($temporaryField, $structureField)) {
@ -188,6 +194,12 @@ class Contract extends Common
if ($vv == 'contract.customer_name') unset($indexField[(int)$kk]);
if ($vv == 'contract.business_name') unset($indexField[(int)$kk]);
}
# zjf 20210727 添加回款绑定合同 合同列表 状态为审核通过和正常
if($requestMap['check_status'] == 2){
$map['contract.check_status'] = ['in', [2,7]];
}
$list = db('crm_contract')
->alias('contract')
->join('__CRM_CUSTOMER__ customer','contract.customer_id = customer.customer_id','LEFT')
@ -218,6 +230,16 @@ class Contract extends Common
foreach ($extraList AS $key => $value) {
$extraData[$value['contract_id']][$value['field']] = $value['content'];
}
$grantData = getFieldGrantData($user_id);
foreach ($grantData['crm_contract'] as $key => $value) {
foreach ($value as $ke => $va) {
if($va['maskType']!=0){
$fieldGrant[$ke]['maskType'] = $va['maskType'];
$fieldGrant[$ke]['form_type'] = $va['form_type'];
$fieldGrant[$ke]['field'] = $va['field'];
}
}
}
foreach ($list as $k=>$v) {
$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']) : [];
@ -253,6 +275,31 @@ class Contract extends Common
// 定位类型字段
foreach ($locationField AS $key => $val) {
$list[$k][$val] = !empty($extraData[$v['contract_id']][$val]) ? json_decode($extraData[$v['contract_id']][$val], true) : null;
}
// 多选框类型字段
foreach ($boxField AS $key => $val) {
$list[$k][$val] = !empty($v[$val]) ? trim($v[$val], ',') : null;
}
// 货币类型字段
foreach ($floatField AS $key => $val) {
$list[$k][$val] = $v[$val]!='0.00' ? (string)$v[$val] : null;
}
//掩码相关类型字段
foreach ($fieldGrant AS $key => $val){
//掩码相关类型字段
if ($val['maskType']!=0 && $val['form_type'] == 'mobile') {
$pattern = "/(1[3458]{1}[0-9])[0-9]{4}([0-9]{4})/i";
$rs = preg_replace($pattern, "$1****$2", $v[$val['field']]);
$list[$k][$val['field']] = !empty($v[$val['field']]) ? (string)$rs : null;
} elseif ($val['maskType']!=0 && $val['form_type'] == 'email') {
$email_array = explode("@", $v[$val['field']]);
$prevfix = (strlen($email_array[0]) < 4) ? "" : substr($v[$val['field']], 0, 2); //
$str = preg_replace('/([\d\w+_-]{0,100})@/', "***@", $v[$val['field']], -1, $count);
$rs = $prevfix . $str;
$list[$k][$val['field']] = !empty($v[$val['field']]) ?$rs: null;
} elseif ($val['maskType']!=0 && in_array($val['form_type'],['position','floatnumber'])) {
$list[$k][$val['field']] = !empty($v[$val['field']]) ? (string)substr_replace($v[$val['field']], '*****',0,strlen($v[$val['field']])) : null;
}
}
$list[$k]['business_id_info']['business_id'] = $v['business_id'];
$list[$k]['business_id_info']['name'] = $v['business_name'];
@ -260,6 +307,7 @@ class Contract extends Common
$list[$k]['customer_id_info']['name'] = $v['customer_name'];
$list[$k]['contacts_id_info']['contacts_id'] = $v['contacts_id'];
$list[$k]['contacts_id_info']['name'] = $v['contacts_name'];
$list[$k]['check_status_info'] = $this->statusArr[$v['check_status']];
$moneyInfo = [];
$moneyInfo = $receivablesModel->getMoneyByContractId($v['contract_id']);
@ -298,6 +346,9 @@ class Contract extends Common
$list[$k]['order_user_name'] = implode(',', $orderNames);
unset($list[$k]['order_user_id']);
$list[$k]['order_user_id_name'] = $v['order_user_id'];
# 系统字段 负责人部门 zjf 20210726
$list[$k]['owner_user_structure_name'] = $list[$k]['owner_user_id_info']['structure_name'];
}
$data = [];
$data['list'] = $list;
@ -749,7 +800,7 @@ class Contract extends Common
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getDataById($id = '', $userId = 0)
public function getDataById($id = '', $userId = 0,$model='')
{
$receivablesModel = new \app\crm\model\Receivables();
$userModel = new \app\admin\model\User();
@ -759,6 +810,35 @@ class Contract extends Common
$this->error = '暂无此数据';
return false;
}
if(empty($model) && $model!='update'){
$grantData = getFieldGrantData($userId);
foreach ($grantData['crm_contract'] as $key => $value) {
foreach ($value as $ke => $va) {
if($va['maskType']!=0){
$fieldGrant[$ke]['maskType'] = $va['maskType'];
$fieldGrant[$ke]['form_type'] = $va['form_type'];
$fieldGrant[$ke]['field'] = $va['field'];
}
}
}
foreach ($fieldGrant AS $key => $val){
//掩码相关类型字段
if ($val['maskType']!=0 && $val['form_type'] == 'mobile') {
$pattern = "/(1[3458]{1}[0-9])[0-9]{4}([0-9]{4})/i";
$rs = preg_replace($pattern, "$1****$2", $dataInfo[$val['field']]);
$dataInfo[$val['field']] = !empty($dataInfo[$val['field']]) ? (string)$rs : null;
} elseif ($val['maskType']!=0 && $val['form_type'] == 'email') {
$email_array = explode("@", $dataInfo[$val['field']]);
$prevfix = (strlen($email_array[0]) < 4) ? "" : substr($dataInfo[$val['field']], 0, 2); //
$str = preg_replace('/([\d\w+_-]{0,100})@/', "***@", $dataInfo[$val['field']], -1, $count);
$rs = $prevfix . $str;
$dataInfo[$val['field']] = !empty($dataInfo[$val['field']]) ?$rs: null;
} elseif ($val['maskType']!=0 && in_array($val['form_type'],['position','floatnumber'])) {
$dataInfo[$val['field']] = !empty($dataInfo[$val['field']]) ? (string)substr_replace($dataInfo[$val['field']], '*****',0,strlen($dataInfo[$val['field']])) : null;
}
}
}
$dataInfo['create_user_info'] = isset($dataInfo['create_user_id']) ? $userModel->getUserById($dataInfo['create_user_id']) : [];
$dataInfo['owner_user_id_info'] = isset($dataInfo['owner_user_id']) ? $userModel->getUserById($dataInfo['owner_user_id']) : [];
$dataInfo['create_user_name'] = !empty($dataInfo['create_user_info']['realname']) ? $dataInfo['create_user_info']['realname'] : '';
@ -903,20 +983,32 @@ class Contract extends Common
public function getSystemInfo($id)
{
# 合同
$business = Db::name('crm_contract')->where('contract_id', $id)->find();
$contract = Db::name('crm_contract')->where('contract_id', $id)->find();
# 创建人
$realname = Db::name('admin_user')->where('id', $business['create_user_id'])->value('realname');
$realname = Db::name('admin_user')->where('id', $contract['create_user_id'])->value('realname');
# zjf 20210726
$userModel = new \app\admin\model\User();
$ownerUserInfo = $userModel->getUserById($contract['owner_user_id']);
# 负责人部门
$ownerStructureName = $ownerUserInfo['structure_name'];
# 负责人
$ownerUserName = $ownerUserInfo['realname'];
# 回款
$receivablesModel = new Receivables();
$receivables = $receivablesModel->getMoneyByContractId($id);
return [
'create_user_id' => $realname,
'create_time' => date('Y-m-d H:i:s', $business['create_time']),
'update_time' => date('Y-m-d H:i:s', $business['update_time']),
'last_time' => !empty($business['last_time']) ? date('Y-m-d H:i:s', $business['last_time']) : '',
'owner_user_id' => $ownerUserName,
'create_time' => date('Y-m-d H:i:s', $contract['create_time']),
'update_time' => date('Y-m-d H:i:s', $contract['update_time']),
'last_time' => !empty($contract['last_time']) ? date('Y-m-d H:i:s', $contract['last_time']) : '',
'done_money' => $receivables['doneMoney'],
'un_money' => $receivables['unMoney']
'un_money' => $receivables['unMoney'],
'owner_user_structure_name' => $ownerStructureName
];
}

@ -70,7 +70,6 @@ class Customer extends Common
$request = $this->fmtRequest( $request );
$requestMap = $request['map'] ? : [];
$sceneModel = new \app\admin\model\Scene();
# 客户默认条件
$customerMap = $this->getWhereByCustomer();
@ -105,11 +104,12 @@ class Customer extends Common
unset($map['team_id']);
}else{
$map = $requestMap ? array_merge($sceneMap, $requestMap) : $sceneMap;
}
# 高级筛选
$map = advancedQuery($map, 'crm', 'customer', 'index');
# 工作台仪表盘
$requestData = $this->requestData();
$dashboardWhere = [];
@ -204,13 +204,16 @@ class Customer extends Common
$positionField = $fieldModel->getFieldByFormType('crm_customer', 'position'); // 地址类型字段
$handwritingField = $fieldModel->getFieldByFormType('crm_customer', 'handwriting_sign'); // 手写签名类型字段
$locationField = $fieldModel->getFieldByFormType('crm_customer', 'location'); // 定位类型字段
$boxField = $fieldModel->getFieldByFormType('crm_customer', 'checkbox'); // 多选类型字段
$floatField = $fieldModel->getFieldByFormType('crm_customer', 'floatnumber'); // 货币类型字段
# 处理人员和部门类型的排序报错问题(前端传来的是包含_name的别名字段)
$temporaryField = str_replace('_name', '', $order_field);
if (in_array($temporaryField, $userField) || in_array($temporaryField, $structureField)) {
$order_field = $temporaryField;
}
# 排序
if ($order_type && $order_field) {
if ($order_type && $order_field && $order_field != 'owner_user_structure_name') {
$order = $fieldModel->getOrderByFormtype('crm_customer','customer',$order_field,$order_type);
} else {
$order = 'customer.update_time desc';
@ -229,7 +232,9 @@ class Customer extends Common
->limit($request['offset'], $request['length'])
->field($indexField)
->orderRaw($order)
// ->fetchSql()
->select();
// p(db('crm_customer')->getLastSql());
$readAuthIds = $userModel->getUserByPer('crm', 'customer', 'read');
$updateAuthIds = $userModel->getUserByPer('crm', 'customer', 'update');
$deleteAuthIds = $userModel->getUserByPer('crm', 'customer', 'delete');
@ -245,23 +250,37 @@ class Customer extends Common
])
->group('customer_id')
->select();
$business_count = array_column($business_count, null, 'customer_id');
$field_list = $fieldModel->getIndexFieldConfig('crm_customer', $user_id);
$field_list = array_column($field_list, 'field');
# 扩展数据
$extraData = [];
$extraList = db('crm_customer_data')->whereIn('customer_id', $customer_id_list)->select();
foreach ($extraList AS $key => $value) {
$extraData[$value['customer_id']][$value['field']] = $value['content'];
}
$grantData = getFieldGrantData($user_id);
foreach ($grantData['crm_customer'] as $key => $value) {
foreach ($value as $ke => $va) {
if($va['maskType']!=0){
$fieldGrant[$ke]['maskType'] = $va['maskType'];
$fieldGrant[$ke]['form_type'] = $va['form_type'];
$fieldGrant[$ke]['field'] = $va['field'];
}
}
}
# 获取进入公海天数
$poolDays = $this->getPoolDay($customer_id_list);
# 整理数据
foreach ($list AS $k => $v) {
$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'] : '';
# 用户类型字段
foreach ($userField AS $key => $val) {
if (in_array($val, $indexField)) {
@ -300,6 +319,31 @@ class Customer extends Common
// 定位类型字段
foreach ($locationField AS $key => $val) {
$list[$k][$val] = !empty($extraData[$v['customer_id']][$val]) ? json_decode($extraData[$v['customer_id']][$val], true) : null;
}
// 多选框类型字段
foreach ($boxField AS $key => $val) {
$list[$k][$val] = !empty($v[$val]) ? trim($v[$val], ',') : null;
}
// 货币类型字段
foreach ($floatField AS $key => $val) {
$list[$k][$val] = $v[$val]!='0.00' ? (string)$v[$val] : null;
}
//掩码相关类型字段
foreach ($fieldGrant AS $key => $val){
//掩码相关类型字段
if ($val['maskType']!=0 && $val['form_type'] == 'mobile') {
$pattern = "/(1[3458]{1}[0-9])[0-9]{4}([0-9]{4})/i";
$rs = preg_replace($pattern, "$1****$2", $v[$val['field']]);
$list[$k][$val['field']] = !empty($v[$val['field']]) ? (string)$rs : null;
} elseif ($val['maskType']!=0 && $val['form_type'] == 'email') {
$email_array = explode("@", $v[$val['field']]);
$prevfix = (strlen($email_array[0]) < 4) ? "" : substr($v[$val['field']], 0, 2); //
$str = preg_replace('/([\d\w+_-]{0,100})@/', "***@", $v[$val['field']], -1, $count);
$rs = $prevfix . $str;
$list[$k][$val['field']] = !empty($v[$val['field']]) ?$rs: null;
} elseif ($val['maskType']!=0 && in_array($val['form_type'],['position','floatnumber'])) {
$list[$k][$val['field']] = !empty($v[$val['field']]) ? (string)substr_replace($v[$val['field']], '*****',0,strlen($v[$val['field']])) : null;
}
}
# 商机数
$list[$k]['business_count'] = $business_count[$v['customer_id']]['count'] ?: 0;
@ -331,6 +375,9 @@ class Customer extends Common
# 进入公海天数
$list[$k]['pool_day'] = isset($poolDays[$v['customer_id']]) ? $poolDays[$v['customer_id']] : '';
$list[$k]['is_pool'] = 0;
# 系统字段 负责人部门 zjf 20210726
$list[$k]['owner_user_structure_name'] = $list[$k]['owner_user_id_info']['structure_name'];
}
}
$data = [];
@ -423,10 +470,11 @@ class Customer extends Common
$locationField = $fieldModel->getFieldByFormType('crm_customer', 'location');
$dateIntervalField = $fieldModel->getFieldByFormType('crm_customer', 'date_interval');
$detailTableField = $fieldModel->getFieldByFormType('crm_customer', 'detail_table');
$dateField = $fieldModel->getFieldByFormType('crm_customer', 'date');
foreach ($param AS $key => $value) {
// 处理地址类型字段数据
if (in_array($key, $positionField)) {
if (!empty($value)) {
if (!empty($value) && is_array($value)) {
$customerData[] = [
'field' => $key,
'content' => json_encode($value, JSON_NUMERIC_CHECK),
@ -434,32 +482,44 @@ class Customer extends Common
];
$positionNames = array_column($value, 'name');
$param[$key] = implode(',', $positionNames);
} elseif(!empty($value) && !is_array($value)){
$param[$key] = $value;
}else{
$param[$key] = '';
}
}
// 处理定位类型字段数据
if (in_array($key, $locationField)) {
if (!empty($value)) {
if (!empty($value) && isset($value['address'])) {
$customerData[] = [
'field' => $key,
'content' => json_encode($value, JSON_NUMERIC_CHECK),
'create_time' => time()
];
$param[$key] = $value['address'];
} elseif(!empty($value) && !isset($value['address'])){
$vv['address']=$value;
$customerData[] = [
'field' => $key,
'content' => json_encode($vv, JSON_NUMERIC_CHECK),
'create_time' => time()
];
$param[$key] = $value;
} else{
$param[$key] = '';
}
}
// 处理日期区间类型字段数据
if (in_array($key, $dateIntervalField)) {
if (!empty($value)) {
if (!empty($value) && is_array($value)) {
$customerData[] = [
'field' => $key,
'content' => json_encode($value, JSON_NUMERIC_CHECK),
'create_time' => time()
];
$param[$key] = implode('_', $value);
$param[$key] = trim(implode('_', $value),'"');
} elseif(!empty($value) && !is_array($value)){
$param[$key] = $value;
}else{
$param[$key] = '';
}
@ -477,12 +537,26 @@ class Customer extends Common
$param[$key] = '';
}
}
$param[$key]=!empty($value)?trim($value,','):'';
if (in_array($key, $dateField)) {
if (!empty($value) ) {
$customerData[] = [
'field' => $key,
'content' => json_encode($value, JSON_NUMERIC_CHECK),
'create_time' => time()
];
$param[$key] = $value;
} else{
$param[$key] = null;
}
}
}
// p($customerData);
# 设置今日需联系客户
if (!empty($param['next_time']) && $param['next_time'] >= strtotime(date('Y-m-d 00:00:00'))) $param['is_dealt'] = 0;
$pool_id = !empty($param['pool_id']) ? $param['pool_id'] : 0;
unset($param['pool_id']);
if ($this->data($param)->allowField(true)->isUpdate(false)->save()) {
$data['customer_id'] = $this->customer_id;
$data['name'] = $param['name'];
@ -647,11 +721,13 @@ class Customer extends Common
// 处理日期区间类型字段数据
if (in_array($key, $dateIntervalField)) {
if (!empty($value)) {
$customerData[] = [
'field' => $key,
'content' => json_encode($value, JSON_NUMERIC_CHECK),
'create_time' => time()
];
$param[$key] =implode('_', $value);
} else {
$param[$key] = '';
@ -671,7 +747,6 @@ class Customer extends Common
}
}
}
// 设置今日需联系客户
if (!empty($param['next_time']) && $param['next_time'] >= strtotime(date('Y-m-d 00:00:00'))) $param['is_dealt'] = 0;
@ -709,12 +784,40 @@ class Customer extends Common
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getDataById($id = '', $userId = 0)
public function getDataById($id = '', $userId = 0,$model='')
{
$dataInfo = db('crm_customer')->where(['customer_id' => $id])->find();
if (!$dataInfo) {
$this->error = '数据不存在或已删除';
return false;
}
if(empty($model) && $model!='update'){
$grantData = getFieldGrantData($userId);
foreach ($grantData['crm_customer'] as $key => $value) {
foreach ($value as $ke => $va) {
if($va['maskType']!=0){
$fieldGrant[$ke]['maskType'] = $va['maskType'];
$fieldGrant[$ke]['form_type'] = $va['form_type'];
$fieldGrant[$ke]['field'] = $va['field'];
}
}
}
foreach ($fieldGrant AS $key => $val){
//掩码相关类型字段
if ($val['maskType']!=0 && $val['form_type'] == 'mobile') {
$pattern = "/(1[3458]{1}[0-9])[0-9]{4}([0-9]{4})/i";
$rs = preg_replace($pattern, "$1****$2", $dataInfo[$val['field']]);
$dataInfo[$val['field']] = !empty($dataInfo[$val['field']]) ? (string)$rs : null;
} elseif ($val['maskType']!=0 && $val['form_type'] == 'email') {
$email_array = explode("@", $dataInfo[$val['field']]);
$prevfix = (strlen($email_array[0]) < 4) ? "" : substr($dataInfo[$val['field']], 0, 2); //
$str = preg_replace('/([\d\w+_-]{0,100})@/', "***@", $dataInfo[$val['field']], -1, $count);
$rs = $prevfix . $str;
$dataInfo[$val['field']] = !empty($dataInfo[$val['field']]) ?$rs: null;
} elseif ($val['maskType']!=0 && in_array($val['form_type'],['position','floatnumber'])) {
$dataInfo[$val['field']] = !empty($dataInfo[$val['field']]) ? (string)substr_replace($dataInfo[$val['field']], '*****',0,strlen($dataInfo[$val['field']])) : null;
}
}
}
$userModel = new \app\admin\model\User();
$dataInfo['create_user_id_info'] = isset($dataInfo['create_user_id']) ? $userModel->getUserById($dataInfo['create_user_id']) : [];
@ -1608,22 +1711,24 @@ class Customer extends Common
*/
public function getNearbyList($param)
{
$apiCommon = new ApiCommon();
$userModel = new \app\admin\model\User();
# 客户条件
$poolStatus = checkPerByAction('crm', 'customer', 'pool');
# 客户
$customerAuth = [];
$customerWhere = [];
if (!empty($param['type']) && $param['type'] == 2) {
if ((!empty($param['type']) && $param['type'] == 2) || !$poolStatus) {
$customerWhere = $this->getWhereByCustomer();
}
# 公海条件
# 公海
$poolWhere = [];
if (!empty($param['type']) && $param['type'] == 9) {
if (!empty($param['type']) && $param['type'] == 9 && $poolStatus) {
$poolWhere = ['customer.owner_user_id' => 0];
$model = '公海客户管理模块';
}
# 距离条件
# 附近
$lngLatRange = $this->getLngLatRange($param['lng'], $param['lat'], $param['distance']);
$lngLatWhere = function ($query) use ($lngLatRange) {
$query->where(['lng' => ['egt', $lngLatRange['minLng']]]);
@ -1643,23 +1748,31 @@ class Customer extends Common
->where($customerWhere)
->where($poolWhere)
->where($lngLatWhere)
->where($customerAuth)
->field(['customer_id', 'name', 'address', 'detail_address', 'owner_user_id', 'lat', 'lng', 'next_time', 'last_time'])
->order('update_time', 'desc')
->select();
# 组装数据
foreach ($list as $key => $value) {
# todo 暂时将查询写在循环中
$ownerUserInfo = !empty($value['owner_user_id']) ? $userModel->getUserById($value['owner_user_id']) : [];
$ownerUserName = !empty($ownerUserInfo['realname']) ? $ownerUserInfo['realname'] : '';
$list[$key]['owner_user_name'] = !empty($ownerUserName) ? $ownerUserName : '暂无负责人';
$list[$key]['distance'] = $this->getLngLatDistance($param['lng'], $param['lat'], $value['lng'], $value['lat'], 1, 0);
$list[$key]['last_time'] = !empty($value['last_time']) ? date('y-m-d H:i:s', $value['last_time']) : !empty($value['next_time']) ? date('y-m-d H:i:s', $value['next_time']) : null;
$list[$key]['model']=$model;
if ($value['owner_user_id'] != 0) {
$list[$key]['model'] = '客户';
} else {
$list[$key]['model'] = '公海';
}
}
return ['list' => $list, 'count' => $count];
}
/**
* 计算两点地理坐标之间的距离
*
@ -1737,9 +1850,15 @@ class Customer extends Common
$customer = Db::name('crm_customer')->field($field)->where('customer_id', $id)->find();
# 创建人
$createUserName = Db::name('admin_user')->where('id', $customer['create_user_id'])->value('realname');
# 负责人
$ownerUserName = Db::name('admin_user')->where('id', $customer['owner_user_id'])->value('realname');
# zjf 20210726
$userModel = new \app\admin\model\User();
$ownerUserInfo = $userModel->getUserById($customer['owner_user_id']);
# 负责人部门
$ownerStructureName = $ownerUserInfo['structure_name'];
# 负责人
$ownerUserName = $ownerUserInfo['realname'];
return [
'obtain_time' => !empty($customer['obtain_time']) ? date('Y-m-d H:i:s', $customer['obtain_time']) : '',
'last_record' => !empty($customer['last_record']) ? $customer['last_record'] : '',
@ -1748,7 +1867,8 @@ class Customer extends Common
'create_time' => date('Y-m-d H:i:s', $customer['create_time']),
'update_time' => date('Y-m-d H:i:s', $customer['update_time']),
'last_time' => !empty($customer['last_time']) ? date('Y-m-d H:i:s', $customer['last_time']) : '',
'deal_status' => $customer['deal_status']
'deal_status' => $customer['deal_status'],
'owner_user_structure_name' => $ownerStructureName
];
}

@ -51,4 +51,97 @@ class Invoice extends Common
'owner_user_name' => 'realname'
]);
}
/**
* @param string $id
* @param int $userId
* @param string $model
* @author: alvin guogaobo
* @version: 11.1.0
* Date: 2021/8/30 14:11
*/
public function getDataById($id = '', $userId = 0, $model='')
{
$map['invoice_id'] = $id;
$dataInfo = $this->where($map)->find();
if (!$dataInfo) {
$this->error = '暂无此数据';
return false;
}
if(empty($model) && $model!='update'){
$grantData = getFieldGrantData($userId);
foreach ($grantData['crm_invoice'] as $key => $value) {
foreach ($value as $ke => $va) {
if($va['maskType']!=0){
$fieldGrant[$ke]['maskType'] = $va['maskType'];
$fieldGrant[$ke]['form_type'] = $va['form_type'];
$fieldGrant[$ke]['field'] = $va['field'];
}
}
}
foreach ($fieldGrant AS $key => $val){
//掩码相关类型字段
if ($val['maskType']!=0 && $val['form_type'] == 'mobile') {
$pattern = "/(1[3458]{1}[0-9])[0-9]{4}([0-9]{4})/i";
$rs = preg_replace($pattern, "$1****$2", $dataInfo[$val['field']]);
$dataInfo[$val['field']] = !empty($dataInfo[$val['field']]) ? (string)$rs : null;
} elseif ($val['maskType']!=0 && $val['form_type'] == 'email') {
$email_array = explode("@", $dataInfo[$val['field']]);
$prevfix = (strlen($email_array[0]) < 4) ? "" : substr($dataInfo[$val['field']], 0, 2); //
$str = preg_replace('/([\d\w+_-]{0,100})@/', "***@", $dataInfo[$val['field']], -1, $count);
$rs = $prevfix . $str;
$dataInfo[$val['field']] = !empty($dataInfo[$val['field']]) ?$rs: null;
} elseif ($val['maskType']!=0 && in_array($val['form_type'],['position','floatnumber'])) {
$dataInfo[$val['field']] = !empty($dataInfo[$val['field']]) ? (string)substr_replace($dataInfo[$val['field']], '*****',0,strlen($dataInfo[$val['field']])) : null;
}
}
}
// $userModel = new \app\admin\model\User();
// $dataInfo['create_user_id_info'] = isset($dataInfo['create_user_id']) ? $userModel->getUserById($dataInfo['create_user_id']) : [];
// $dataInfo['owner_user_id_info'] = isset($dataInfo['owner_user_id']) ? $userModel->getUserById($dataInfo['owner_user_id']) : [];
// $dataInfo['create_user_name'] = !empty($dataInfo['create_user_id_info']['realname']) ? $dataInfo['create_user_id_info']['realname'] : '';
// $dataInfo['owner_user_name'] = !empty($dataInfo['owner_user_id_info']['realname']) ? $dataInfo['owner_user_id_info']['realname'] : '';
// $dataInfo['customer_id_info'] = $dataInfo['customer_id'] ? db('crm_customer')->where(['customer_id' => $dataInfo['customer_id']])->field('customer_id,name')->find() : [];
// $dataInfo['contract_id_info'] = $dataInfo['contract_id'] ? db('crm_contract')->where(['contract_id' => $dataInfo['contract_id']])->field('contract_id,name,money')->find() : [];
// $dataInfo['receivables_id'] = $id;
// $userModel = new \app\admin\model\User();
// $dataInfo['create_user_info'] = $userModel->getUserById($dataInfo['create_user_id']);
// $dataInfo['plan_id'] = $id;
// # 处理时间格式
// $fieldModel = new \app\admin\model\Field();
// $datetimeField = $fieldModel->getFieldByFormType('crm_receivables', 'datetime'); //日期时间类型
// foreach ($datetimeField as $key => $val) {
// $dataInfo[$val] = !empty($dataInfo[$val]) ? date('Y-m-d H:i:s', $dataInfo[$val]) : null;
// }
// $dataInfo['create_time'] = !empty($dataInfo['create_time']) ? date('Y-m-d H:i:s', $dataInfo['create_time']) : null;
// $dataInfo['update_time'] = !empty($dataInfo['update_time']) ? date('Y-m-d H:i:s', $dataInfo['update_time']) : null;
// // 字段授权
// if (!empty($userId)) {
// $grantData = getFieldGrantData($userId);
// $userLevel = isSuperAdministrators($userId);
// foreach ($dataInfo as $key => $value) {
// if (!$userLevel && !empty($grantData['crm_receivables'])) {
// $status = getFieldGrantStatus($key, $grantData['crm_receivables']);
//
// # 查看权限
// if ($status['read'] == 0) unset($dataInfo[$key]);
// }
// }
// if (!$userLevel && !empty($grantData['crm_receivables'])) {
// # 客户名称
// $customerStatus = getFieldGrantStatus('customer_id', $grantData['crm_receivables']);
// if ($customerStatus['read'] == 0) {
// $dataInfo['customer_name'] = '';
// $dataInfo['customer_id_info'] = [];
// }
// # 合同金额
// $contractMoneyStatus = getFieldGrantStatus('contract_money', $grantData['crm_receivables']);
// if ($contractMoneyStatus['read'] == 0) $dataInfo['contract_id_info']['money'] = '';
// # 合同名称
// $contractMoneyStatus = getFieldGrantStatus('contract_money', $grantData['crm_receivables']);
// if ($contractMoneyStatus['read'] == 0) $dataInfo['contract_id_info']['money'] = '';
// }
// }
return $dataInfo;
}
}

@ -112,6 +112,8 @@ class Leads extends Common
$positionField = $fieldModel->getFieldByFormType('crm_leads', 'position'); // 地址类型字段
$handwritingField = $fieldModel->getFieldByFormType('crm_leads', 'handwriting_sign'); // 手写签名类型字段
$locationField = $fieldModel->getFieldByFormType('crm_leads', 'location'); // 定位类型字段
$boxField = $fieldModel->getFieldByFormType('crm_leads', 'checkbox'); // 多选类型字段
$floatField = $fieldModel->getFieldByFormType('crm_leads', 'floatnumber'); // 货币类型字段
# 处理人员和部门类型的排序报错问题(前端传来的是包含_name的别名字段)
$temporaryField = str_replace('_name', '', $order_field);
if (in_array($temporaryField, $userField) || in_array($temporaryField, $structureField)) {
@ -153,7 +155,6 @@ class Leads extends Common
->field(implode(',', $indexField))
->orderRaw($order)
->select();
// echo db('crm_leads')->getLastSql();exit;
# 扩展数据
$extraData = [];
$leads_id_list = !empty($list) ? array_column($list, 'leads_id') : [];
@ -161,6 +162,17 @@ class Leads extends Common
foreach ($extraList AS $key => $value) {
$extraData[$value['leads_id']][$value['field']] = $value['content'];
}
$grantData = getFieldGrantData($user_id);
foreach ($grantData['crm_leads'] as $key => $value) {
foreach ($value as $ke => $va) {
if($va['maskType']!=0){
$fieldGrant[$ke]['maskType'] = $va['maskType'];
$fieldGrant[$ke]['form_type'] = $va['form_type'];
$fieldGrant[$ke]['field'] = $va['field'];
}
}
}
foreach ($list as $k => $v) {
$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']) : [];
@ -197,6 +209,36 @@ class Leads extends Common
foreach ($locationField AS $key => $val) {
$list[$k][$val] = !empty($extraData[$v['leads_id']][$val]) ? json_decode($extraData[$v['leads_id']][$val], true) : null;
}
// 多选框类型字段
foreach ($boxField AS $key => $val) {
$list[$k][$val] = !empty($v[$val]) ? trim($v[$val], ',') : null;
}
// 货币类型字段
foreach ($floatField AS $key => $val) {
$list[$k][$val] = $v[$val]!='0.00' ? (string)$v[$val] : null;
}
foreach ($fieldGrant AS $key => $val){
//掩码相关类型字段
if ($val['maskType']!=0 && $val['form_type'] == 'mobile') {
$pattern = "/(1[3458]{1}[0-9])[0-9]{4}([0-9]{4})/i";
$rs = preg_replace($pattern, "$1****$2", $v[$val['field']]);
$list[$k][$val['field']] = !empty($v[$val['field']]) ? (string)$rs : null;
} elseif ($val['maskType']!=0 && $val['form_type'] == 'email') {
$email_array = explode("@", $v[$val['field']]);
$prevfix = (strlen($email_array[0]) < 4) ? "" : substr($v[$val['field']], 0, 2); //
$str = preg_replace('/([\d\w+_-]{0,100})@/', "***@", $v[$val['field']], -1, $count);
$rs = $prevfix . $str;
$list[$k][$val['field']] = !empty($v[$val['field']]) ?$rs: null;
} elseif ($val['maskType']!=0 && in_array($val['form_type'],['position','floatnumber'])) {
$list[$k][$val['field']] = !empty($v[$val['field']]) ? (string)substr_replace($v[$val['field']], '*****',0,strlen($v[$val['field']])) : null;
}
}
// 货币类型字段
foreach ($floatField AS $key => $val) {
$list[$k][$val] = $v[$val]!='0.00' ? (string)$v[$val] : null;
}
//权限
$permission = [];
$is_read = 0;
@ -217,6 +259,9 @@ class Leads extends Common
$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;
$list[$k]['last_time'] = !empty($v['last_time']) ? date('Y-m-d H:i:s', $v['last_time']) : null;
# 系统字段 负责人部门 zjf 20210726
$list[$k]['owner_user_structure_name'] = $list[$k]['owner_user_id_info']['structure_name'];
}
$data = [];
$data['list'] = $list;
@ -362,7 +407,7 @@ class Leads extends Common
'type' => 2,
'activity_type' => 1,
'activity_type_id' => $this->leads_id,
'content' => $param['name'],
'content' => $param['name']?:'',
'create_user_id' => $param['create_user_id'],
'update_time' => time(),
'create_time' => time(),
@ -542,7 +587,7 @@ class Leads extends Common
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getDataById($id = '', $userId = 0)
public function getDataById($id = '', $userId = 0, $model='')
{
$map['leads_id'] = $id;
$dataInfo = db('crm_leads')->where($map)->find();
@ -550,6 +595,35 @@ class Leads extends Common
$this->error = '暂无此数据';
return false;
}
if(empty($model) && $model!='update'){
$grantData = getFieldGrantData($userId);
foreach ($grantData['crm_leads'] as $key => $value) {
foreach ($value as $ke => $va) {
if($va['maskType']!=0){
$fieldGrant[$ke]['maskType'] = $va['maskType'];
$fieldGrant[$ke]['form_type'] = $va['form_type'];
$fieldGrant[$ke]['field'] = $va['field'];
}
}
}
foreach ($fieldGrant AS $key => $val){
//掩码相关类型字段
if ($val['maskType']!=0 && $val['form_type'] == 'mobile') {
$pattern = "/(1[3458]{1}[0-9])[0-9]{4}([0-9]{4})/i";
$rs = preg_replace($pattern, "$1****$2", $dataInfo[$val['field']]);
$dataInfo[$val['field']] = !empty($dataInfo[$val['field']]) ? (string)$rs : null;
} elseif ($val['maskType']!=0 && $val['form_type'] == 'email') {
$email_array = explode("@", $dataInfo[$val['field']]);
$prevfix = (strlen($email_array[0]) < 4) ? "" : substr($dataInfo[$val['field']], 0, 2); //
$str = preg_replace('/([\d\w+_-]{0,100})@/', "***@", $dataInfo[$val['field']], -1, $count);
$rs = $prevfix . $str;
$dataInfo[$val['field']] = !empty($dataInfo[$val['field']]) ?$rs: null;
} elseif ($val['maskType']!=0 && in_array($val['form_type'],['position','floatnumber'])) {
$dataInfo[$val['field']] = !empty($dataInfo[$val['field']]) ? (string)substr_replace($dataInfo[$val['field']], '*****',0,strlen($dataInfo[$val['field']])) : null;
}
}
}
$userModel = new \app\admin\model\User();
$dataInfo['create_user_id_info'] = isset($dataInfo['create_user_id']) ? $userModel->getUserById($dataInfo['create_user_id']) : [];
$dataInfo['owner_user_id_info'] = isset($dataInfo['owner_user_id']) ? $userModel->getUserById($dataInfo['owner_user_id']) : [];
@ -592,19 +666,28 @@ class Leads extends Common
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public
function getSystemInfo($id)
public function getSystemInfo($id)
{
# 线索
$leads = Db::name('crm_leads')->field(['create_user_id', 'create_time', 'update_time', 'last_time'])->where('leads_id', $id)->find();
$leads = Db::name('crm_leads')->field(['create_user_id','owner_user_id', 'create_time', 'update_time', 'last_time'])->where('leads_id', $id)->find();
# 创建人
$realname = Db::name('admin_user')->where('id', $leads['create_user_id'])->value('realname');
# zjf 20210726
$userModel = new \app\admin\model\User();
$ownerUserInfo = $userModel->getUserById($leads['owner_user_id']);
# 负责人部门
$ownerStructureName = $ownerUserInfo['structure_name'];
# 负责人
$ownerUserName = $ownerUserInfo['realname'];
return [
'create_user_id' => $realname,
'owner_user_id' => $ownerUserName,
'create_time' => date('Y-m-d H:i:s', $leads['create_time']),
'update_time' => date('Y-m-d H:i:s', $leads['update_time']),
'last_time' => !empty($leads['last_time']) ? date('Y-m-d H:i:s', $leads['last_time']) : ''
'last_time' => !empty($leads['last_time']) ? date('Y-m-d H:i:s', $leads['last_time']) : '',
'owner_user_structure_name' => $ownerStructureName
];
}
}

@ -107,6 +107,9 @@ class Product extends Common
$positionField = $fieldModel->getFieldByFormType('crm_product', 'position'); // 地址类型字段
$handwritingField = $fieldModel->getFieldByFormType('crm_product', 'handwriting_sign'); // 手写签名类型字段
$locationField = $fieldModel->getFieldByFormType('crm_product', 'location'); // 定位类型字段
$boxField = $fieldModel->getFieldByFormType('crm_product', 'checkbox'); // 多选类型字段
$floatField = $fieldModel->getFieldByFormType('crm_product', 'floatnumber'); // 货币类型字段
# 处理人员和部门类型的排序报错问题(前端传来的是包含_name的别名字段)
$temporaryField = str_replace('_name', '', $order_field);
if (in_array($temporaryField, $userField) || in_array($temporaryField, $structureField)) {
@ -142,6 +145,16 @@ class Product extends Common
foreach ($extraList AS $key => $value) {
$extraData[$value['product_id']][$value['field']] = $value['content'];
}
$grantData = getFieldGrantData($user_id);
foreach ($grantData['crm_product'] as $key => $value) {
foreach ($value as $ke => $va) {
if($va['maskType']!=0){
$fieldGrant[$ke]['maskType'] = $va['maskType'];
$fieldGrant[$ke]['form_type'] = $va['form_type'];
$fieldGrant[$ke]['field'] = $va['field'];
}
}
}
foreach ($list as $k => $v) {
$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']) : [];
@ -178,11 +191,39 @@ class Product extends Common
foreach ($locationField AS $key => $val) {
$list[$k][$val] = !empty($extraData[$v['product_id']][$val]) ? json_decode($extraData[$v['product_id']][$val], true) : null;
}
// 多选框类型字段
foreach ($boxField AS $key => $val) {
$list[$k][$val] = !empty($v[$val]) ? trim($v[$val], ',') : null;
}
// 货币类型字段
foreach ($floatField AS $key => $val) {
$list[$k][$val] = $v[$val]!='0.00' ? (string)$v[$val] : null;
}
//掩码相关类型字段
foreach ($fieldGrant AS $key => $val){
//掩码相关类型字段
if ($val['maskType']!=0 && $val['form_type'] == 'mobile') {
$pattern = "/(1[3458]{1}[0-9])[0-9]{4}([0-9]{4})/i";
$rs = preg_replace($pattern, "$1****$2", $v[$val['field']]);
$list[$k][$val['field']] = !empty($v[$val['field']]) ? (string)$rs : null;
} elseif ($val['maskType']!=0 && $val['form_type'] == 'email') {
$email_array = explode("@", $v[$val['field']]);
$prevfix = (strlen($email_array[0]) < 4) ? "" : substr($v[$val['field']], 0, 2); //
$str = preg_replace('/([\d\w+_-]{0,100})@/', "***@", $v[$val['field']], -1, $count);
$rs = $prevfix . $str;
$list[$k][$val['field']] = !empty($v[$val['field']]) ?$rs: null;
} elseif ($val['maskType']!=0 && in_array($val['form_type'],['position','floatnumber'])) {
$list[$k][$val['field']] = !empty($v[$val['field']]) ? (string)substr_replace($v[$val['field']], '*****',0,strlen($v[$val['field']])) : null;
}
}
//产品类型
$list[$k]['category_id_info'] = $v['category_name'];
# 处理日期格式
$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;
@ -503,7 +544,7 @@ class Product extends Common
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getDataById($id = '', $userId = 0)
public function getDataById($id = '', $userId = 0,$model='')
{
$map['product_id'] = $id;
$map['delete_user_id'] = 0;
@ -512,6 +553,34 @@ class Product extends Common
$this->error = '暂无此数据';
return false;
}
if(empty($model) && $model!='update'){
$grantData = getFieldGrantData($userId);
foreach ($grantData['crm_product'] as $key => $value) {
foreach ($value as $ke => $va) {
if($va['maskType']!=0){
$fieldGrant[$ke]['maskType'] = $va['maskType'];
$fieldGrant[$ke]['form_type'] = $va['form_type'];
$fieldGrant[$ke]['field'] = $va['field'];
}
}
}
foreach ($fieldGrant AS $key => $val){
//掩码相关类型字段
if ($val['maskType']!=0 && $val['form_type'] == 'mobile') {
$pattern = "/(1[3458]{1}[0-9])[0-9]{4}([0-9]{4})/i";
$rs = preg_replace($pattern, "$1****$2", $dataInfo[$val['field']]);
$dataInfo[$val['field']] = !empty($dataInfo[$val['field']]) ? (string)$rs : null;
} elseif ($val['maskType']!=0 && $val['form_type'] == 'email') {
$email_array = explode("@", $dataInfo[$val['field']]);
$prevfix = (strlen($email_array[0]) < 4) ? "" : substr($dataInfo[$val['field']], 0, 2); //
$str = preg_replace('/([\d\w+_-]{0,100})@/', "***@", $dataInfo[$val['field']], -1, $count);
$rs = $prevfix . $str;
$dataInfo[$val['field']] = !empty($dataInfo[$val['field']]) ?$rs: null;
} elseif ($val['maskType']!=0 && in_array($val['form_type'],['position','floatnumber'])) {
$dataInfo[$val['field']] = !empty($dataInfo[$val['field']]) ? (string)substr_replace($dataInfo[$val['field']], '*****',0,strlen($dataInfo[$val['field']])) : null;
}
}
}
# 获取封面图片
$dataInfo['cover_images'] = $this->getProductImages($dataInfo['cover_images']);
@ -947,14 +1016,25 @@ class Product extends Common
public function getSystemInfo($id)
{
# 产品
$product = Db::name('crm_product')->field(['create_user_id', 'create_time', 'update_time'])->where('product_id', $id)->find();
$product = Db::name('crm_product')->field(['create_user_id','owner_user_id', 'create_time', 'update_time'])->where('product_id', $id)->find();
# 创建人
$realname = Db::name('admin_user')->where('id', $product['create_user_id'])->value('realname');
# zjf 20210726
$userModel = new \app\admin\model\User();
$ownerUserInfo = $userModel->getUserById($product['owner_user_id']);
# 负责人部门
$ownerStructureName = $ownerUserInfo['structure_name'];
# 负责人
$ownerUserName = $ownerUserInfo['realname'];
return [
'create_user_id' => $realname,
'owner_user_id' => $ownerUserName,
'create_time' => date('Y-m-d H:i:s', $product['create_time']),
'update_time' => date('Y-m-d H:i:s', $product['update_time'])
'update_time' => date('Y-m-d H:i:s', $product['update_time']),
'owner_user_structure_name' => $ownerStructureName
];
}

@ -120,8 +120,9 @@ class ProductCategory extends Common
if (db('crm_product')->where(['category_id' => $param['id']])->find()) {
$resDel = false;
}
if ($delSon && is_numeric($id)) {
$childIds = $this->getAllChild($id);
if ($delSon && is_numeric($param['id'])) {
$childIds = $this->getAllChild($param['id']);
if($childIds){
if (db('crm_product')->where(['category_id' => ['in',$childIds]])->find()) {
$resDel = false;
@ -132,6 +133,7 @@ class ProductCategory extends Common
$this->error = '请先移除该类型及子类下的相关产品';
return false;
}
$data=db('crm_product_category')->where('category_id' , $param['id'])->find();
//提交事务
$this->startTrans();
@ -145,7 +147,7 @@ class ProductCategory extends Common
}
}
# 系统操作日志
SystemActionLog($param['user_id'], 'crm_product','customer', $id, 'update',$data['name'] , '', '','删除了产品分类:'.$data['name']);
SystemActionLog($param['user_id'], 'crm_product','customer', $param['id'], 'update',$data['name'] , '', '','删除了产品分类:'.$data['name']);
$this->commit();
return true;
} catch(\Exception $e) {

@ -25,7 +25,7 @@ class Receivables extends Common
protected $createTime = 'create_time';
protected $updateTime = 'update_time';
protected $autoWriteTimestamp = true;
private $statusArr = ['0' => '待审核', '1' => '审核中', '2' => '审核通过', '3' => '已拒绝', '4' => '已撤回'];
private $statusArr = ['0' => '待审核', '1' => '审核中', '2' => '审核通过', '3' => '已拒绝', '4' => '已撤回', '7' => '正常'];
/**
* [getDataList 回款list]
@ -140,6 +140,9 @@ class Receivables extends Common
$positionField = $fieldModel->getFieldByFormType('crm_receivables', 'position'); // 地址类型字段
$handwritingField = $fieldModel->getFieldByFormType('crm_receivables', 'handwriting_sign'); // 手写签名类型字段
$locationField = $fieldModel->getFieldByFormType('crm_receivables', 'location'); // 定位类型字段
$boxField = $fieldModel->getFieldByFormType('crm_receivables', 'checkbox'); // 多选类型字段
$floatField = $fieldModel->getFieldByFormType('crm_receivables', 'floatnumber'); // 货币类型字段
// $fieldGrant = db('admin_field_mask')->where('types', 'receivables')->select();
# 处理人员和部门类型的排序报错问题(前端传来的是包含_name的别名字段)
$temporaryField = str_replace('_name', '', $order_field);
if (in_array($temporaryField, $userField) || in_array($temporaryField, $structureField)) {
@ -192,6 +195,16 @@ class Receivables extends Common
foreach ($extraList as $key => $value) {
$extraData[$value['receivables_id']][$value['field']] = $value['content'];
}
$grantData = getFieldGrantData($user_id);
foreach ($grantData['crm_receivables'] as $key => $value) {
foreach ($value as $ke => $va) {
if($va['maskType']!=0){
$fieldGrant[$ke]['maskType'] = $va['maskType'];
$fieldGrant[$ke]['form_type'] = $va['form_type'];
$fieldGrant[$ke]['field'] = $va['field'];
}
}
}
foreach ($list as $k => $v) {
$list[$k]['create_user_id_info'] = $v['create_user_id'] ? $userModel->getUserById($v['create_user_id']) : [];
$list[$k]['owner_user_id_info'] = $v['owner_user_id'] ? $userModel->getUserById($v['owner_user_id']) : [];
@ -234,6 +247,30 @@ class Receivables extends Common
foreach ($locationField AS $key => $val) {
$list[$k][$val] = !empty($extraData[$v['receivables_id']][$val]) ? json_decode($extraData[$v['receivables_id']][$val], true) : null;
}
// 多选框类型字段
foreach ($boxField AS $key => $val) {
$list[$k][$val] = !empty($v[$val]) ? trim($v[$val],',') : null;
}
// 货币类型字段
foreach ($floatField AS $key => $val) {
$list[$k][$val] = $v[$val]!='0.00' ? (string)$v[$val] : null;
}
foreach ($fieldGrant AS $key => $val){
//掩码相关类型字段
if ($val['maskType']!=0 && $val['form_type'] == 'mobile') {
$pattern = "/(1[3458]{1}[0-9])[0-9]{4}([0-9]{4})/i";
$rs = preg_replace($pattern, "$1****$2", $v[$val['field']]);
$list[$k][$val['field']] = !empty($v[$val['field']]) ? (string)$rs : null;
} elseif ($val['maskType']!=0 && $val['form_type'] == 'email') {
$email_array = explode("@", $v[$val['field']]);
$prevfix = (strlen($email_array[0]) < 4) ? "" : substr($v[$val['field']], 0, 2); //
$str = preg_replace('/([\d\w+_-]{0,100})@/', "***@", $v[$val['field']], -1, $count);
$rs = $prevfix . $str;
$list[$k][$val['field']] = !empty($v[$val['field']]) ?$rs: null;
} elseif ($val['maskType']!=0 && in_array($val['form_type'],['position','floatnumber'])) {
$list[$k][$val['field']] = !empty($v[$val['field']]) ? (string)substr_replace($v[$val['field']], '*****',0,strlen($v[$val['field']])) : null;
}
}
$list[$k]['check_status_info'] = $this->statusArr[$v['check_status']];
//期数
$plan_num = db('crm_receivables_plan')->where(['plan_id' => $v['plan_id']])->value('num');
@ -253,6 +290,10 @@ class Receivables extends Common
# 日期
$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;
@ -300,7 +341,7 @@ class Receivables extends Common
if ($check_status == 6) {
$this->error = '合同已作废';
return false;
} elseif ($check_status != 2) {
} elseif ($check_status != 2 && $check_status != 7) {
$this->error = '合同未审核通过';
return false;
}
@ -664,7 +705,7 @@ class Receivables extends Common
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getDataById($id = '', $userId = 0)
public function getDataById($id = '', $userId = 0,$model='')
{
$map['receivables_id'] = $id;
$dataInfo = db('crm_receivables')->where($map)->find();
@ -672,6 +713,35 @@ class Receivables extends Common
$this->error = '暂无此数据';
return false;
}
if(empty($model) && $model!='update'){
$grantData = getFieldGrantData($userId);
foreach ($grantData['crm_receivables'] as $key => $value) {
foreach ($value as $ke => $va) {
if($va['maskType']!=0){
$fieldGrant[$ke]['maskType'] = $va['maskType'];
$fieldGrant[$ke]['form_type'] = $va['form_type'];
$fieldGrant[$ke]['field'] = $va['field'];
}
}
}
foreach ($fieldGrant AS $key => $val){
//掩码相关类型字段
if ($val['maskType']!=0 && $val['form_type'] == 'mobile') {
$pattern = "/(1[3458]{1}[0-9])[0-9]{4}([0-9]{4})/i";
$rs = preg_replace($pattern, "$1****$2", $dataInfo[$val['field']]);
$dataInfo[$val['field']] = !empty($dataInfo[$val['field']]) ? (string)$rs : null;
} elseif ($val['maskType']!=0 && $val['form_type'] == 'email') {
$email_array = explode("@", $dataInfo[$val['field']]);
$prevfix = (strlen($email_array[0]) < 4) ? "" : substr($dataInfo[$val['field']], 0, 2); //
$str = preg_replace('/([\d\w+_-]{0,100})@/', "***@", $dataInfo[$val['field']], -1, $count);
$rs = $prevfix . $str;
$dataInfo[$val['field']] = !empty($dataInfo[$val['field']]) ?$rs: null;
} elseif ($val['maskType']!=0 && in_array($val['form_type'],['position','floatnumber'])) {
$dataInfo[$val['field']] = !empty($dataInfo[$val['field']]) ? (string)substr_replace($dataInfo[$val['field']], '*****',0,strlen($dataInfo[$val['field']])) : null;
}
}
}
$userModel = new \app\admin\model\User();
$dataInfo['create_user_id_info'] = isset($dataInfo['create_user_id']) ? $userModel->getUserById($dataInfo['create_user_id']) : [];
$dataInfo['owner_user_id_info'] = isset($dataInfo['owner_user_id']) ? $userModel->getUserById($dataInfo['owner_user_id']) : [];
@ -919,14 +989,23 @@ class Receivables extends Common
public function getSystemInfo($id)
{
# 回款
$receivables = Db::name('crm_receivables')->field(['create_user_id', 'create_time', 'update_time'])->where('receivables_id', $id)->find();
$receivables = Db::name('crm_receivables')->field(['create_user_id' ,'owner_user_id', 'create_time', 'update_time'])->where('receivables_id', $id)->find();
# 创建人
$realname = Db::name('admin_user')->where('id', $receivables['create_user_id'])->value('realname');
# zjf 20210726
$userModel = new \app\admin\model\User();
$ownerUserInfo = $userModel->getUserById($receivables['owner_user_id']);
# 负责人部门
$ownerStructureName = $ownerUserInfo['structure_name'];
# 负责人
$ownerUserName = $ownerUserInfo['realname'];
return [
'create_user_id' => $realname,
'owner_user_id' => $ownerUserName,
'create_time' => date('Y-m-d H:i:s', $receivables['create_time']),
'update_time' => date('Y-m-d H:i:s', $receivables['update_time'])
'update_time' => date('Y-m-d H:i:s', $receivables['update_time']),
'owner_user_structure_name' => $ownerStructureName
];
}
}

@ -7,6 +7,7 @@
namespace app\crm\model;
use app\admin\traits\FieldVerificationTrait;
use think\composer\LibraryInstaller;
use think\Db;
use app\admin\model\Common;
use app\crm\model\Contract as ContractModel;
@ -15,8 +16,6 @@ use think\Validate;
class ReceivablesPlan extends Common
{
use FieldVerificationTrait;
/**
* 为了数据库的整洁同时又不影响Model和Controller的名称
* 我们约定每个模块的数据表都加上相同的前缀比如CRM模块用crm作为数据表前缀
@ -25,19 +24,21 @@ class ReceivablesPlan extends Common
protected $createTime = 'create_time';
protected $updateTime = 'update_time';
protected $autoWriteTimestamp = true;
protected $statusArr = [0 =>'待回款', 1=>'完成', 2=>'部分回款', 3=>'已作废', 4=>'已逾期', 5=>'待生效'];
/**
* [getDataList 回款计划list]
* @author Michael_xu
* @param [string] $map [查询条件]
* @param [number] $page [当前页数]
* @param [number] $limit [每页数量]
* @param [string] $types 1 未使用的回款计划
* @return [array] [description]
* @author Michael_xu
*/
public function getDataList($request)
{
$userModel = new \app\admin\model\User();
$fieldModel = new \app\admin\model\Field();
$search = $request['search'];
$user_id = $request['user_id'];
$scene_id = (int)$request['scene_id'];
@ -46,6 +47,9 @@ class ReceivablesPlan extends Common
$getCount = $request['getCount'];
$status = isset($request['status']) ? $request['status'] : 1;
$dealt = $request['dealt']; # 待办事项
$order_field = $request['order_field'];
$order_type = $request['order_type'];
$is_excel = $request['is_excel'];
unset($request['scene_id']);
unset($request['search']);
unset($request['user_id']);
@ -54,10 +58,25 @@ class ReceivablesPlan extends Common
unset($request['getCount']);
unset($request['status']);
unset($request['dealt']);
unset($request['order_field']);
unset($request['order_type']);
unset($request['is_excel']);
$request = $this->fmtRequest($request);
$map = $request['map'] ?: [];
$sceneModel = new \app\admin\model\Scene();
$sceneMap = [];
if (empty($getCount)) {
if ($scene_id) {
//自定义场景
$sceneMap = $sceneModel->getDataById($scene_id, $user_id, 'receivables_plan') ?: [];
} else {
//默认场景
$sceneMap = $sceneModel->getDefaultData('crm_receivables_plan', $user_id) ?: [];
}
}
if (isset($map['search'])) {
//普通筛选
$map['name'] = ['like', '%' . $map['search'] . '%'];
unset($map['search']);
@ -103,41 +122,171 @@ class ReceivablesPlan extends Common
}
}
$dataCount = db('crm_receivables_plan')
->alias('receivables_plan')
->join('__CRM_CONTRACT__ contract', 'receivables_plan.contract_id = contract.contract_id', 'LEFT')
->join('__CRM_CUSTOMER__ customer', 'receivables_plan.customer_id = customer.customer_id', 'LEFT')
->join('__CRM_RECEIVABLES__ receivables', 'receivables_plan.plan_id = receivables.plan_id', 'LEFT')
->where($map)
->where($sceneMap)
->where($whereData)
->count('receivables_plan.plan_id');
$indexField = $fieldModel->getIndexField('crm_receivables_plan', $user_id, 1) ?: array('name'); // 列表展示字段
$userField = $fieldModel->getFieldByFormType('crm_receivables_plan', 'user'); // 人员类型
$structureField = $fieldModel->getFieldByFormType('crm_receivables_plan', 'structure'); // 部门类型
$datetimeField = $fieldModel->getFieldByFormType('crm_receivables_plan', 'datetime'); // 日期时间类型
$booleanField = $fieldModel->getFieldByFormType('crm_receivables_plan', 'boolean_value'); // 布尔值类型字段
$dateIntervalField = $fieldModel->getFieldByFormType('crm_receivables_plan', 'date_interval'); // 日期区间类型字段
$positionField = $fieldModel->getFieldByFormType('crm_receivables_plan', 'position'); // 地址类型字段
$handwritingField = $fieldModel->getFieldByFormType('crm_receivables_plan', 'handwriting_sign'); // 手写签名类型字段
if (!empty($getCount) && $getCount == 1) {
$data['dataCount'] = !empty($dataCount) ? $dataCount : 0;
return $data;
}
# 处理人员和部门类型的排序报错问题(前端传来的是包含_name的别名字段)
$temporaryField = str_replace('_name', '', $order_field);
if (in_array($temporaryField, $userField) || in_array($temporaryField, $structureField)) {
$order_field = $temporaryField;
}
# 排序
if ($order_type && $order_field) {
$order = $fieldModel->getOrderByFormtype('crm_receivables_plan', 'receivables_plan', $order_field, $order_type);
} else {
$order = 'receivables_plan.num asc';
}
$list = db('crm_receivables_plan')
->alias('receivables_plan')
->join('__CRM_CONTRACT__ contract', 'receivables_plan.contract_id = contract.contract_id', 'LEFT')
->join('__CRM_CUSTOMER__ customer', 'receivables_plan.customer_id = customer.customer_id', 'LEFT')
->join('__CRM_RECEIVABLES__ receivables', 'receivables_plan.plan_id = receivables.plan_id', 'LEFT')
->limit($request['offset'], $request['length'])
->field('receivables_plan.*,customer.name as customer_name,contract.num as contract_name,receivables.receivables_id,receivables.check_status')
->field(array_merge($indexField, [
'customer.name' => 'customer_name',
'receivables.receivables_id' => 'receivables_id',
'receivables.check_status' => 'check_status',
'contract.num ' => 'contract_name',
'ifnull(SUM(receivables_plan.money), 0)' => 'done_money',//计划回款总金额
'(ifnull(SUM(receivables.money), 0)-SUM( real_money))' => 'un_money',//未回款总金额
'SUM(real_money) AS real_money'//实际回款总金额
]))
->where($map)
->where($sceneMap)
->where($whereData)
->group('receivables_plan.contract_id')
->orderRaw($order)
->select();
$grantData = getFieldGrantData($user_id);
foreach ($grantData['crm_visit_'] as $key => $value) {
foreach ($value as $ke => $va) {
if($va['maskType']!=0){
$fieldGrant[$ke]['maskType'] = $va['maskType'];
$fieldGrant[$ke]['form_type'] = $va['form_type'];
$fieldGrant[$ke]['field'] = $va['field'];
}
}
}
$readAuthIds = $userModel->getUserByPer('crm', 'receivables_plan', 'read');
$updateAuthIds = $userModel->getUserByPer('crm', 'receivables_plan', 'update');
$deleteAuthIds = $userModel->getUserByPer('crm', 'receivables_plan', 'delete');
$real_money=0.00;
$receivedMoney=0.00;
$unReceivedMoney=0.00;
foreach ($list as $k => $v) {
$list[$k]['create_user_id_info'] = $userModel->getUserById($v['create_user_id']);
$list[$k]['contract_id_info']['name'] = $v['contract_name'] ? : '';
$list[$k]['contract_id_info']['contract_id'] = $v['contract_id'] ? : '';
$list[$k]['customer_id_info']['name'] = $v['customer_name'] ? : '';
$list[$k]['customer_id_info']['customer_id'] = $v['customer_id'] ? : '';
$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'] : '';
foreach ($userField as $key => $val) {
if (in_array($val, $indexField)) {
$usernameField = !empty($v[$val]) ? db('admin_user')->whereIn('id', stringToArray($v[$val]))->column('realname') : [];
$list[$k][$val] = implode($usernameField, ',');
}
}
# 部门类型字段
foreach ($structureField as $key => $val) {
if (in_array($val, $indexField)) {
$structureNameField = !empty($v[$val]) ? db('admin_structure')->whereIn('id', stringToArray($v[$val]))->column('name') : [];
$list[$k][$val] = implode($structureNameField, ',');
}
}
# 日期时间类型字段
foreach ($datetimeField as $key => $val) {
$list[$k][$val] = !empty($v[$val]) ? date('Y-m-d H:i:s', $v[$val]) : null;
}
// 布尔值类型字段
foreach ($booleanField as $key => $val) {
$list[$k][$val] = !empty($v[$val]) ? (string)$v[$val] : '0';
}
// 处理日期区间类型字段的格式
foreach ($dateIntervalField as $key => $val) {
$list[$k][$val] = !empty($extraData[$v['customer_id']][$val]) ? json_decode($extraData[$v['customer_id']][$val], true) : null;
}
// 处理地址类型字段的格式
foreach ($positionField as $key => $val) {
$list[$k][$val] = !empty($extraData[$v['customer_id']][$val]) ? json_decode($extraData[$v['customer_id']][$val], true) : null;
}
// 手写签名类型字段
foreach ($handwritingField as $key => $val) {
$handwritingData = !empty($v[$val]) ? db('admin_file')->where('file_id', $v[$val])->value('file_path') : null;
$list[$k][$val] = ['url' => !empty($handwritingData) ? getFullPath($handwritingData) : null
];
}
foreach ($fieldGrant AS $key => $val){
//掩码相关类型字段
if ($val['maskType']!=0 && $val['form_type'] == 'mobile') {
$pattern = "/(1[3458]{1}[0-9])[0-9]{4}([0-9]{4})/i";
$rs = preg_replace($pattern, "$1****$2", $v[$val['field']]);
$list[$k][$val['field']] = !empty($v[$val['field']]) ? (string)$rs : null;
} elseif ($val['maskType']!=0 && $val['form_type'] == 'email') {
$email_array = explode("@", $v[$val['field']]);
$prevfix = (strlen($email_array[0]) < 4) ? "" : substr($v[$val['field']], 0, 2); //
$str = preg_replace('/([\d\w+_-]{0,100})@/', "***@", $v[$val['field']], -1, $count);
$rs = $prevfix . $str;
$list[$k][$val['field']] = !empty($v[$val['field']]) ?$rs: null;
} elseif ($val['maskType']!=0 && in_array($val['form_type'],['position','floatnumber'])) {
$list[$k][$val['field']] = !empty($v[$val['field']]) ? (string)substr_replace($v[$val['field']], '*****',0,strlen($v[$val['field']])) : null;
}
}
// 状态
if(strtotime($v['return_date'])>strtotime(date("Y-m-d",strtotime("+1 day")))){
$list[$k]['status']=4;
}
# 时间格式
$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;
# 权限
$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;
$real_money += $v['real_money']; //实际回款总金额
$receivedMoney += $v['done_money'];// 回款总金额
$unReceivedMoney += $v['un_money']; // 未回款
}
$data = [];
$data['list'] = $list;
$data['dataCount'] = $dataCount ?: 0;
$data['extraData']['money'] = [
'real_money' => $real_money, # 实际回款总金额
'receivedMoney' => $receivedMoney, # 回款总金额
'unReceivedMoney' => $unReceivedMoney # 未回款
];
return $data ?: [];
}
/**
* 创建回款计划信息
* @author Michael_xu
@ -266,7 +415,20 @@ class ReceivablesPlan extends Common
}
}
}
switch ($res){
case 1:
$param['status']=5;
break;
case 2:
$param['status']=0;
break;
case 3:
$param['status']=3;
break;
case 6:
$param['status']=0;
break;
}
if ($this->data($param)->allowField(true)->save()) {
$data = [];
$data['plan_id'] = $this->plan_id;
@ -424,7 +586,7 @@ class ReceivablesPlan extends Common
* @param $id 回款计划ID
* @return
*/
public function getDataById($id = '')
public function getDataById($id = '', $userId = 0, $model='')
{
$map['plan_id'] = $id;
$dataInfo = $this->where($map)->find();
@ -432,65 +594,81 @@ class ReceivablesPlan extends Common
$this->error = '暂无此数据';
return false;
}
$userModel = new \app\admin\model\User();
$dataInfo['create_user_info'] = $userModel->getUserById($dataInfo['create_user_id']);
$dataInfo['plan_id'] = $id;
if(empty($model) && $model!='update'){
$grantData = getFieldGrantData($userId);
foreach ($grantData['crm_receivables_plan'] as $key => $value) {
foreach ($value as $ke => $va) {
if($va['maskType']!=0){
$fieldGrant[$ke]['maskType'] = $va['maskType'];
$fieldGrant[$ke]['form_type'] = $va['form_type'];
$fieldGrant[$ke]['field'] = $va['field'];
}
}
}
foreach ($fieldGrant AS $key => $val){
//掩码相关类型字段
if ($val['maskType']!=0 && $val['form_type'] == 'mobile') {
$pattern = "/(1[3458]{1}[0-9])[0-9]{4}([0-9]{4})/i";
$rs = preg_replace($pattern, "$1****$2", $dataInfo[$val['field']]);
$dataInfo[$val['field']] = !empty($dataInfo[$val['field']]) ? (string)$rs : null;
} elseif ($val['maskType']!=0 && $val['form_type'] == 'email') {
$email_array = explode("@", $dataInfo[$val['field']]);
$prevfix = (strlen($email_array[0]) < 4) ? "" : substr($dataInfo[$val['field']], 0, 2); //
$str = preg_replace('/([\d\w+_-]{0,100})@/', "***@", $dataInfo[$val['field']], -1, $count);
$rs = $prevfix . $str;
$dataInfo[$val['field']] = !empty($dataInfo[$val['field']]) ?$rs: null;
} elseif ($val['maskType']!=0 && in_array($val['form_type'],['position','floatnumber'])) {
$dataInfo[$val['field']] = !empty($dataInfo[$val['field']]) ? (string)substr_replace($dataInfo[$val['field']], '*****',0,strlen($dataInfo[$val['field']])) : null;
}
}
}
// $userModel = new \app\admin\model\User();
// $dataInfo['create_user_id_info'] = isset($dataInfo['create_user_id']) ? $userModel->getUserById($dataInfo['create_user_id']) : [];
// $dataInfo['owner_user_id_info'] = isset($dataInfo['owner_user_id']) ? $userModel->getUserById($dataInfo['owner_user_id']) : [];
// $dataInfo['create_user_name'] = !empty($dataInfo['create_user_id_info']['realname']) ? $dataInfo['create_user_id_info']['realname'] : '';
// $dataInfo['owner_user_name'] = !empty($dataInfo['owner_user_id_info']['realname']) ? $dataInfo['owner_user_id_info']['realname'] : '';
// $dataInfo['customer_id_info'] = $dataInfo['customer_id'] ? db('crm_customer')->where(['customer_id' => $dataInfo['customer_id']])->field('customer_id,name')->find() : [];
// $dataInfo['contract_id_info'] = $dataInfo['contract_id'] ? db('crm_contract')->where(['contract_id' => $dataInfo['contract_id']])->field('contract_id,name,money')->find() : [];
// $dataInfo['receivables_id'] = $id;
// $userModel = new \app\admin\model\User();
// $dataInfo['create_user_info'] = $userModel->getUserById($dataInfo['create_user_id']);
// $dataInfo['plan_id'] = $id;
// # 处理时间格式
// $fieldModel = new \app\admin\model\Field();
// $datetimeField = $fieldModel->getFieldByFormType('crm_receivables', 'datetime'); //日期时间类型
// foreach ($datetimeField as $key => $val) {
// $dataInfo[$val] = !empty($dataInfo[$val]) ? date('Y-m-d H:i:s', $dataInfo[$val]) : null;
// }
// $dataInfo['create_time'] = !empty($dataInfo['create_time']) ? date('Y-m-d H:i:s', $dataInfo['create_time']) : null;
// $dataInfo['update_time'] = !empty($dataInfo['update_time']) ? date('Y-m-d H:i:s', $dataInfo['update_time']) : null;
// // 字段授权
// if (!empty($userId)) {
// $grantData = getFieldGrantData($userId);
// $userLevel = isSuperAdministrators($userId);
// foreach ($dataInfo as $key => $value) {
// if (!$userLevel && !empty($grantData['crm_receivables'])) {
// $status = getFieldGrantStatus($key, $grantData['crm_receivables']);
//
// # 查看权限
// if ($status['read'] == 0) unset($dataInfo[$key]);
// }
// }
// if (!$userLevel && !empty($grantData['crm_receivables'])) {
// # 客户名称
// $customerStatus = getFieldGrantStatus('customer_id', $grantData['crm_receivables']);
// if ($customerStatus['read'] == 0) {
// $dataInfo['customer_name'] = '';
// $dataInfo['customer_id_info'] = [];
// }
// # 合同金额
// $contractMoneyStatus = getFieldGrantStatus('contract_money', $grantData['crm_receivables']);
// if ($contractMoneyStatus['read'] == 0) $dataInfo['contract_id_info']['money'] = '';
// # 合同名称
// $contractMoneyStatus = getFieldGrantStatus('contract_money', $grantData['crm_receivables']);
// if ($contractMoneyStatus['read'] == 0) $dataInfo['contract_id_info']['money'] = '';
// }
// }
return $dataInfo;
}
//模拟自定义字段返回
public function getField()
{
$field_arr = [
'0' => [
'field' => 'customer_id',
'name' => '客户名称',
'form_type' => 'customer',
'setting' => []
],
'1' => [
'field' => 'contract_id',
'name' => '合同名称',
'form_type' => 'contract',
'setting' => []
],
'2' => [
'field' => 'money',
'name' => '计划回款金额',
'form_type' => 'floatnumber',
'setting' => []
],
'3' => [
'field' => 'return_date',
'name' => '计划回款日期',
'form_type' => 'date',
'setting' => []
],
'4' => [
'field' => 'return_type',
'name' => '计划回款方式',
'form_type' => 'select',
'setting' => '支付宝\n微信\n转账'
],
'5' => [
'field' => 'remind',
'name' => '提前几日提醒',
'form_type' => 'number',
'setting' => []
],
'6' => [
'field' => 'remark',
'name' => '备注',
'form_type' => 'textarea',
'setting' => []
],
'7' => [
'field' => 'file',
'name' => '附件',
'form_type' => 'file',
'setting' => []
]
];
return $field_arr;
}
}

@ -13,4 +13,94 @@ class Visit extends Common
protected $createTime = 'create_time';
protected $updateTime = 'update_time';
protected $autoWriteTimestamp = true;
/**
* 回访计划数据
* @param $id 回款计划ID
* @return
*/
public function getDataById($id = '', $userId = 0, $model='')
{
$map['visit_id'] = $id;
$dataInfo = $this->where($map)->find();
if (!$dataInfo) {
$this->error = '暂无此数据';
return false;
}
if(empty($model) && $model!='update'){
$grantData = getFieldGrantData($userId);
foreach ($grantData['crm_visit'] as $key => $value) {
foreach ($value as $ke => $va) {
if($va['maskType']!=0){
$fieldGrant[$ke]['maskType'] = $va['maskType'];
$fieldGrant[$ke]['form_type'] = $va['form_type'];
$fieldGrant[$ke]['field'] = $va['field'];
}
}
}
foreach ($fieldGrant AS $key => $val){
//掩码相关类型字段
if ($val['maskType']!=0 && $val['form_type'] == 'mobile') {
$pattern = "/(1[3458]{1}[0-9])[0-9]{4}([0-9]{4})/i";
$rs = preg_replace($pattern, "$1****$2", $dataInfo[$val['field']]);
$dataInfo[$val['field']] = !empty($dataInfo[$val['field']]) ? (string)$rs : null;
} elseif ($val['maskType']!=0 && $val['form_type'] == 'email') {
$email_array = explode("@", $dataInfo[$val['field']]);
$prevfix = (strlen($email_array[0]) < 4) ? "" : substr($dataInfo[$val['field']], 0, 2); //
$str = preg_replace('/([\d\w+_-]{0,100})@/', "***@", $dataInfo[$val['field']], -1, $count);
$rs = $prevfix . $str;
$dataInfo[$val['field']] = !empty($dataInfo[$val['field']]) ?$rs: null;
} elseif ($val['maskType']!=0 && in_array($val['form_type'],['position','floatnumber'])) {
$dataInfo[$val['field']] = !empty($dataInfo[$val['field']]) ? (string)substr_replace($dataInfo[$val['field']], '*****',0,strlen($dataInfo[$val['field']])) : null;
}
}
}
// $userModel = new \app\admin\model\User();
// $dataInfo['create_user_id_info'] = isset($dataInfo['create_user_id']) ? $userModel->getUserById($dataInfo['create_user_id']) : [];
// $dataInfo['owner_user_id_info'] = isset($dataInfo['owner_user_id']) ? $userModel->getUserById($dataInfo['owner_user_id']) : [];
// $dataInfo['create_user_name'] = !empty($dataInfo['create_user_id_info']['realname']) ? $dataInfo['create_user_id_info']['realname'] : '';
// $dataInfo['owner_user_name'] = !empty($dataInfo['owner_user_id_info']['realname']) ? $dataInfo['owner_user_id_info']['realname'] : '';
// $dataInfo['customer_id_info'] = $dataInfo['customer_id'] ? db('crm_customer')->where(['customer_id' => $dataInfo['customer_id']])->field('customer_id,name')->find() : [];
// $dataInfo['contract_id_info'] = $dataInfo['contract_id'] ? db('crm_contract')->where(['contract_id' => $dataInfo['contract_id']])->field('contract_id,name,money')->find() : [];
// $dataInfo['receivables_id'] = $id;
// $userModel = new \app\admin\model\User();
// $dataInfo['create_user_info'] = $userModel->getUserById($dataInfo['create_user_id']);
// $dataInfo['plan_id'] = $id;
// # 处理时间格式
// $fieldModel = new \app\admin\model\Field();
// $datetimeField = $fieldModel->getFieldByFormType('crm_receivables', 'datetime'); //日期时间类型
// foreach ($datetimeField as $key => $val) {
// $dataInfo[$val] = !empty($dataInfo[$val]) ? date('Y-m-d H:i:s', $dataInfo[$val]) : null;
// }
// $dataInfo['create_time'] = !empty($dataInfo['create_time']) ? date('Y-m-d H:i:s', $dataInfo['create_time']) : null;
// $dataInfo['update_time'] = !empty($dataInfo['update_time']) ? date('Y-m-d H:i:s', $dataInfo['update_time']) : null;
// // 字段授权
// if (!empty($userId)) {
// $grantData = getFieldGrantData($userId);
// $userLevel = isSuperAdministrators($userId);
// foreach ($dataInfo as $key => $value) {
// if (!$userLevel && !empty($grantData['crm_receivables'])) {
// $status = getFieldGrantStatus($key, $grantData['crm_receivables']);
//
// # 查看权限
// if ($status['read'] == 0) unset($dataInfo[$key]);
// }
// }
// if (!$userLevel && !empty($grantData['crm_receivables'])) {
// # 客户名称
// $customerStatus = getFieldGrantStatus('customer_id', $grantData['crm_receivables']);
// if ($customerStatus['read'] == 0) {
// $dataInfo['customer_name'] = '';
// $dataInfo['customer_id_info'] = [];
// }
// # 合同金额
// $contractMoneyStatus = getFieldGrantStatus('contract_money', $grantData['crm_receivables']);
// if ($contractMoneyStatus['read'] == 0) $dataInfo['contract_id_info']['money'] = '';
// # 合同名称
// $contractMoneyStatus = getFieldGrantStatus('contract_money', $grantData['crm_receivables']);
// if ($contractMoneyStatus['read'] == 0) $dataInfo['contract_id_info']['money'] = '';
// }
// }
return $dataInfo;
}
}

@ -72,6 +72,7 @@ class Log extends ApiCommon
$param = $this->param;
$userInfo = $this->userInfo;
$param['read_user_id'] = $userInfo['id'];
$param['structure_ids'] = $param['structure_id'];
$param['structure_id'] = $userInfo['structure_id'];
$data = model('Log')->getDataList($param);
return resultArray(['data' => $data]);

@ -42,6 +42,9 @@ class Log extends Common
$recordModel = new \app\admin\model\Record();
$user_id = $request['read_user_id'];
$by = $request['by'] ?: '';
if($request['structure_ids']){
$user_id = $userModel->getSubUserByStr($request['structure_ids'], 2);
}
$map = [];
$search = $request['search'];
if (isset($request['search']) && $request['search']) {
@ -66,8 +69,9 @@ class Log extends Common
$map['log.create_time'] = ['between', [$start_time, $end_time]];
}
$requestData = $this->requestData();
//获取权限范围内的员工
$auth_user_ids = getSubUserId();
$auth_user_ids = getSubUserId(true,0,$user_id);
$dataWhere['user_id'] = $user_id;
$dataWhere['structure_id'] = $request['structure_id'];
$dataWhere['auth_user_ids'] = $auth_user_ids;
@ -93,16 +97,18 @@ class Log extends Common
};
break;
}
$list = Db::name('OaLog')
$list = Db::name('oa_log')
->alias('log')
->where($map)
->where($logMap)
->where($searchMap)
->alias('log')
->join('__ADMIN_USER__ user', 'user.id = log.create_user_id', 'LEFT')
->page($request['page'], $request['limit'])
->field('log.*,user.realname,user.thumb_img')
->order('log.update_time desc')
->select();
$dataCount = $this->alias('log')->where($map)->where($logMap)->where($searchMap)->count();
foreach ($list as $k => $v) {
$list[$k]['create_user_info']['realname'] = $v['realname'] ?: '';

@ -266,7 +266,8 @@ return [
'crm/receivables/count' => ['crm/receivables/count', ['method' => 'POST']],
//【回款】导出
'crm/receivables/excelExport' => ['crm/receivables/excelExport', ['method' => 'POST']],
// 【回款计划】导出
'crm/receivablesPlan/excelExport' => ['crm/receivablesPlan/excelExport', ['method' => 'POST']],
// 【回款计划】列表
'crm/receivables_plan/index' => ['crm/receivables_plan/index', ['method' => 'POST']],
// 【回款计划】创建
@ -301,6 +302,7 @@ return [
// 【发票】导出
'crm/invoice/excelExport' => ['crm/invoice/excelExport', ['method' => 'POST']],
// 【发票-开户行】列表
'crm/invoiceInfo/index' => ['crm/invoiceInfo/index', ['method' => 'POST']],
// 【发票-开户行】详情

@ -1,5 +1,5 @@
<?php
return array(
'VERSION'=>'11.1.0',
'RELEASE'=>'20210625',
'VERSION'=>'11.1.1',
'RELEASE'=>'20210903',
);

@ -261,6 +261,7 @@ INSERT INTO `5kcrm_admin_field` VALUES (14, 'crm_customer', 0, 'name', '客户
INSERT INTO `5kcrm_admin_field` VALUES (15, 'crm_customer', 0, 'level', '客户级别', 'select', '', 0, 0, 0, '', 'A重点客户\nB普通客户\nC非优先客户', 3, 191, 1553788800, 1624439032, 3, '', 0, 50, '1,0', 2, '', '', '', 'A重点客户,B普通客户,C非优先客户', 0);
INSERT INTO `5kcrm_admin_field` VALUES (16, 'crm_customer', 0, 'industry', '客户行业', 'select', '', 0, 0, 0, '', 'IT/通信/电子/互联网\n金融业\n房地产\n商业服务\n贸易\n生产\n运输/物流\n服务业\n文化传媒\n政府', 2, 191, 1553788800, 1624439031, 3, '', 0, 50, '0,1', 2, '', '', '', 'IT/通信/电子/互联网,金融业,房地产,商业服务,贸易,生产,运输/物流,服务业,文化传媒,政府', 1025);
INSERT INTO `5kcrm_admin_field` VALUES (17, 'crm_customer', 0, 'source', '客户来源', 'select', '', 0, 0, 0, '', '促销活动\n搜索引擎\n广告\n转介绍\n线上注册\n线上询价\n预约上门\n陌拜\n招商资源\n公司资源\n展会资源\n个人资源\n电话咨询\n邮件咨询', 4, 191, 1553788800, 1624439032, 3, '', 0, 50, '1,1', 2, '', '', '', '促销活动,搜索引擎,广告,转介绍,线上注册,线上询价,预约上门,陌拜,招商资源,公司资源,展会资源,个人资源,电话咨询,邮件咨询', 1026);
INSERT INTO `5kcrm_admin_field` VALUES (18, 'crm_customer', 0, 'deal_status', '成交状态', 'select', '未成交', 0, 0, 1, '', '未成交\n已成交', 0, 191, 1553788800, 1553788800, 0, NULL, 0, 100, '', NULL, NULL, NULL, NULL, NULL, NULL);
INSERT INTO `5kcrm_admin_field` VALUES (19, 'crm_customer', 0, 'telephone', '电话', 'text', '', 0, 0, 0, '', '', 5, 191, 1553788800, 1624439032, 1, '', 0, 50, '2,0', 0, '', '', '', '', 1027);
INSERT INTO `5kcrm_admin_field` VALUES (20, 'crm_customer', 0, 'website', '网址', 'text', '', 0, 0, 0, '', '', 8, 191, 1553788800, 1624439032, 1, '', 0, 50, '3,1', 0, '', '', '', '', 1028);
INSERT INTO `5kcrm_admin_field` VALUES (21, 'crm_customer', 0, 'next_time', '下次联系时间', 'datetime', '', 0, 0, 0, '', '', 9, 63, 1553788800, 1624439032, 13, '', 0, 50, '4,0', 0, '', '', '', '', 1029);
@ -1601,43 +1602,42 @@ CREATE TABLE `5kcrm_crm_contract_product` (
DROP TABLE IF EXISTS `5kcrm_crm_customer`;
CREATE TABLE `5kcrm_crm_customer` (
`customer_id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '客户名称',
`is_lock` tinyint(1) NOT NULL DEFAULT 0 COMMENT '1锁定',
`name` varchar(255) DEFAULT NULL COMMENT '客户名称',
`is_lock` tinyint(1) NOT NULL DEFAULT '0' COMMENT '1锁定',
`deal_time` int(11) NOT NULL COMMENT '领取,分配,创建时间',
`level` varchar(500) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '客户级别',
`industry` varchar(500) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '客户行业',
`source` varchar(500) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '客户来源',
`telephone` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '电话',
`mobile` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '手机',
`website` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '网址',
`remark` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '备注',
`level` varchar(500) DEFAULT NULL COMMENT '客户级别',
`industry` varchar(500) DEFAULT NULL COMMENT '客户行业',
`source` varchar(500) DEFAULT NULL COMMENT '客户来源',
`telephone` varchar(255) DEFAULT NULL COMMENT '电话',
`mobile` varchar(255) DEFAULT NULL COMMENT '手机',
`website` varchar(255) DEFAULT NULL COMMENT '网址',
`remark` text COMMENT '备注',
`create_user_id` int(11) NOT NULL COMMENT '创建人ID',
`owner_user_id` int(11) NOT NULL COMMENT '负责人ID',
`ro_user_id` varchar(500) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '只读权限',
`rw_user_id` varchar(500) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '读写权限',
`address` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '省市区',
`location` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '定位信息',
`detail_address` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '详细地址',
`lng` double(14, 11) NULL DEFAULT NULL COMMENT '地理位置经度',
`lat` double(14, 11) NULL DEFAULT NULL COMMENT '地理位置维度',
`next_time` int(11) NULL DEFAULT NULL COMMENT '下次联系时间',
`follow` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '跟进',
`obtain_time` int(10) NOT NULL DEFAULT 0 COMMENT '负责人获取客户时间',
`ro_user_id` varchar(500) NOT NULL DEFAULT '' COMMENT '只读权限',
`rw_user_id` varchar(500) NOT NULL DEFAULT '' COMMENT '读写权限',
`address` varchar(255) NOT NULL DEFAULT '' COMMENT '省市区',
`location` varchar(255) NOT NULL DEFAULT '' COMMENT '定位信息',
`detail_address` varchar(255) NOT NULL DEFAULT '' COMMENT '详细地址',
`lng` double(14,11) DEFAULT NULL COMMENT '地理位置经度',
`lat` double(14,11) DEFAULT NULL COMMENT '地理位置维度',
`next_time` int(11) DEFAULT NULL COMMENT '下次联系时间',
`follow` varchar(20) DEFAULT NULL COMMENT '跟进',
`obtain_time` int(10) NOT NULL DEFAULT '0' COMMENT '负责人获取客户时间',
`create_time` int(11) NOT NULL COMMENT '创建时间',
`update_time` int(11) NOT NULL COMMENT '更新时间',
`is_dealt` tinyint(1) NOT NULL DEFAULT 1 COMMENT '是否已经处理待办事项1已处理0未处理',
`is_allocation` tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否是分配给我的客户1是0不是',
`last_time` int(10) UNSIGNED NULL DEFAULT NULL COMMENT '最后跟进时间',
`last_record` varchar(512) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '最后跟进记录',
`email` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '邮箱',
`before_owner_user_id` int(10) UNSIGNED NULL DEFAULT 0 COMMENT '前负责人',
`into_pool_time` int(10) UNSIGNED NULL DEFAULT 0 COMMENT '进入公海时间',
`pool_remain` tinyint(1) NOT NULL DEFAULT 0 COMMENT '代办事项待进入公海1已处理0未处理',
`deal_status` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '未成交' COMMENT '成交状态',
`is_dealt` tinyint(1) NOT NULL DEFAULT '1' COMMENT '是否已经处理待办事项1已处理0未处理',
`is_allocation` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否是分配给我的客户1是0不是',
`last_time` int(10) unsigned DEFAULT NULL COMMENT '最后跟进时间',
`last_record` varchar(512) DEFAULT NULL COMMENT '最后跟进记录',
`email` varchar(255) DEFAULT NULL COMMENT '邮箱',
`before_owner_user_id` int(10) unsigned DEFAULT '0' COMMENT '前负责人',
`into_pool_time` int(10) unsigned DEFAULT '0' COMMENT '进入公海时间',
`pool_remain` tinyint(1) NOT NULL DEFAULT '0' COMMENT '代办事项待进入公海1已处理0未处理',
`deal_status` varchar(10) NOT NULL DEFAULT '未成交' COMMENT '成交状态',
PRIMARY KEY (`customer_id`) USING BTREE,
INDEX `bi_analysis`(`create_time`, `owner_user_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '客户表' ROW_FORMAT = DYNAMIC;
KEY `bi_analysis` (`create_time`,`owner_user_id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='客户表';
-- ----------------------------
-- Records of 5kcrm_crm_customer
-- ----------------------------

@ -0,0 +1,5 @@
ALTER TABLE `5kcrm_crm_receivables_plan` ADD COLUMN `real_money` decimal(18,2) NOT NULL DEFAULT '0.00' COMMENT '实际回款金额';
ALTER TABLE `5kcrm_crm_receivables_plan` ADD COLUMN `real_data` date DEFAULT NULL COMMENT '实际回款日期';
ALTER TABLE `5kcrm_crm_receivables_plan` ADD COLUMN `un_money` decimal(18,2) NOT NULL DEFAULT '0.00' COMMENT '未回金额';
INSERT INTO `5kcrm_admin_field` VALUES (18, 'crm_customer', 0, 'deal_status', '成交状态', 'select', '未成交', 0, 0, 1, '', '未成交\n已成交', 0, 191, 1553788800, 1553788800, 0, NULL, 0, 100, '', NULL, NULL, NULL, NULL, NULL, NULL);

@ -88,10 +88,10 @@ $('.next').click(function () {
localStorage.clear();
window.location = 'step5.html';
} else if (result.code == '400') {
alert(result.error);
// alert(result.error);
window.location.href = 'step6.html';
} else {
alert(result.error);
// alert(result.error);
window.location.href = 'step6.html';
}
},

@ -0,0 +1,5 @@
ALTER TABLE `5kcrm_crm_receivables_plan` ADD COLUMN `real_money` decimal(18,2) NOT NULL DEFAULT '0.00' COMMENT '实际回款金额';
ALTER TABLE `5kcrm_crm_receivables_plan` ADD COLUMN `real_data` date DEFAULT NULL COMMENT '实际回款日期';
ALTER TABLE `5kcrm_crm_receivables_plan` ADD COLUMN `un_money` decimal(18,2) NOT NULL DEFAULT '0.00' COMMENT '未回金额';
INSERT INTO `5kcrm_admin_field` VALUES (18, 'crm_customer', 0, 'deal_status', '成交状态', 'select', '未成交', 0, 0, 1, '', '未成交\n已成交', 0, 191, 1553788800, 1553788800, 0, NULL, 0, 100, '', NULL, NULL, NULL, NULL, NULL, NULL);
Loading…
Cancel
Save