pull/1/head
旭晓耿 4 years ago
parent 2b7b3791a1
commit 97662ba32e

@ -170,3 +170,25 @@ function sendRequest($url, $params = array() , $headers = array()) {
curl_close($ch);
return $return;
}
/**
* 验证序列号
* @param
* @return
*/
function checkWkCode($wkcode) {
$pub = config('public_key');
$openssl_pub = openssl_pkey_get_public($pub);
// 验签
$resArr = openssl_public_decrypt(Hex2String($wkcode), $decrypted, $pub);
if(!$resArr) return false;
return $decrypted;
}
function Hex2String($hex){
$string = '';
for ($i=0; $i < strlen($hex); $i+=2){
$string .= chr(hexdec($hex[$i].$hex[$i+1]));
}
return $string;
}

@ -84,7 +84,7 @@ class Field extends ApiCommon
* 自定义字段数据
*/
public function read()
{
{
$fieldModel = model('Field');
$param = $this->param;
$data = $fieldModel->getDataList($param);
@ -116,14 +116,22 @@ class Field extends ApiCommon
$types_id = $param['types_id'] ? : 0;
// $data['types'] = $param['types'];
$data = $param['data'];
$saveParam = []; # 新增数据
$updateParam = []; # 编辑数据
$delParam = []; # 删除数据
$fieldIds = []; # 删除数据兼容前端11.*.*版本)
$data = $param['data'];
$saveParam = []; # 新增数据
$updateParam = []; # 编辑数据
$delParam = []; # 删除数据
$fieldIds = []; # 删除数据兼容前端11.*.*版本)
$errorMessage = []; # 错误数据
$i = 0;
foreach ($data AS $k => $v) {
$i++;
# 必填的字段不可以隐藏
if (!empty($v['is_null']) && !empty($v['is_hidden'])) {
$errorMessage = '必填的字段不可以隐藏!';
break;
}
if ($v['field_id']) {
if (isset($v['is_deleted']) && $v['is_deleted'] == '1') {
# 删除
@ -143,8 +151,8 @@ class Field extends ApiCommon
}
}
# 错误数据
$errorMessage = [];
# 必填的字段不可以隐藏
if ($errorMessage) return resultArray(['error' => $errorMessage]);
# 兼容前端11.*.*版本的删除条件处理,通过比较差异,来确定谁被前端给删除了 todo 这段代码需要写在新增上面,不然会把新增的给删除掉
$oldFieldIds = Db::name('admin_field')->where('types', $types)->column('field_id');
@ -170,7 +178,7 @@ class Field extends ApiCommon
# 删除
if (!empty($delParam)) {
if (!$data = $fieldModel->delDataById($delParam)) {
$errorMessage[] = $fieldModel->getError();
if (!empty($fieldModel->getError())) $errorMessage[] = $fieldModel->getError();
}
}
@ -312,12 +320,17 @@ class Field extends ApiCommon
case 'crm_visit' :
$visit = new \app\crm\model\Visit();
$dataInfo = $visit->getDataById(intval($param['action_id']));
$fieldModel = new \app\admin\model\Field();
$datetimeField = $fieldModel->getFieldByFormType('crm_visit', 'datetime'); //日期时间类型
foreach ($datetimeField as $key => $val) {
$dataInfo[$val] = !empty($dataInfo[$val]) ? date('Y-m-d H:i:s', $dataInfo[$val]) : null;
}
//判断权限
$auth_user_ids = $userModel->getUserByPer('crm', 'visit', $param['action']);
//读写权限
$roPre = $userModel->rwPre($user_id, $dataInfo['ro_user_id'], $dataInfo['rw_user_id'], 'read');
$rwPre = $userModel->rwPre($user_id, $dataInfo['ro_user_id'], $dataInfo['rw_user_id'], 'update');
if (!in_array($dataInfo['owner_user_id'],$auth_user_ids) && !$roPre && !$rwPre) {
if (!in_array($user_id, stringToArray($dataInfo['owner_user_id'])) && !in_array($user_id,$auth_user_ids) && !$roPre && !$rwPre) {
header('Content-Type:application/json; charset=utf-8');
exit(json_encode(['code'=>102,'error'=>'无权操作']));
}
@ -614,6 +627,10 @@ class Field extends ApiCommon
$userFieldModel = model('UserField');
$width = $param['width'] > 10 ? $param['width'] : '';
$unField = array('pool_day','owner_user_name','is_lock','create_user_name');
switch ($param['field']) {
case 'status_id_info' : $param['field'] = 'status_id';
break;
}
if (!in_array($param['field'],$unField)) {
$res = $userFieldModel->setColumnWidth($param['types'], $param['field'], $width, $userInfo['id']);
if (!$res) {

@ -52,6 +52,7 @@ class Index extends ApiCommon
if ($value['field'] == 'address') $field_arr[$key]['form_type'] = 'map_address';
if ($value['field'] == 'deal_status') $field_arr[$key]['form_type'] = 'deal_status';
if ($value['field'] == 'check_status') $field_arr[$key]['form_type'] = 'check_status';
if ($param['types'] == 'crm_visit' && $value['field'] == 'owner_user_id') $field_arr[$key]['name'] = '回访人';
}
return resultArray(['data' => $field_arr]);

@ -27,15 +27,15 @@ class Install extends Controller
$param = Request::instance()->param();
$this->param = $param;
$request = request();
$m = strtolower($request->module());
$c = strtolower($request->controller());
$a = strtolower($request->action());
if (!in_array($a, array('upgrade','upgradeprocess','checkversion')) && file_exists(CONF_PATH . "install.lock")) {
echo "<meta http-equiv='content-type' content='text/html; charset=UTF-8'> <script>alert('请勿重复安装!');location.href='".$_SERVER["HTTP_HOST"]."';</script>";
die();
}
// $request = request();
// $m = strtolower($request->module());
// $c = strtolower($request->controller());
// $a = strtolower($request->action());
//
// if (!in_array($a, array('upgrade','upgradeprocess','checkversion')) && file_exists(CONF_PATH . "install.lock")) {
// echo "<meta http-equiv='content-type' content='text/html; charset=UTF-8'> <script>alert('请勿重复安装!');location.href='".$_SERVER["HTTP_HOST"]."';</script>";
// die();
// }
}
private $upgrade_site = "http://message.72crm.com/";
@ -73,7 +73,7 @@ class Install extends Controller
public function version()
{
$res = include(CONF_PATH.'version.php');
return $res ? : array('VERSION' => '9.0.0','RELEASE' => '20190330');
return $res ? : array('VERSION' => '11.0.0','RELEASE' => '20210219');
}
public function step2(){
@ -114,6 +114,7 @@ class Install extends Controller
$username = $param['root'];
$password = $param['pwd'];
$wkcode = $param['wkcode'];
if (empty($db_config['hostname'])) {
return resultArray(['error' => '请填写数据库主机!']);
}
@ -141,6 +142,17 @@ class Install extends Controller
if (empty($username)) {
return resultArray(['error' => '请填写管理员用户名!']);
}
if (empty($wkcode)) {
return resultArray(['error' => '请填写序列号!']);
}
$resCheckData = checkWkCode($wkcode);
if (!$resCheckData) {
return resultArray(['error' => '序列号错误!']);
}
$resData = object_to_array(json_decode($resCheckData));
if ($resData['date'] != date('Y-m-d')) {
return resultArray(['error' => '序列号已失效,请前往悟空官网个人中心获取最新数据!']);
}
if (empty($password)) {
return resultArray(['error' => '请填写管理员密码!']);
}
@ -161,6 +173,7 @@ class Install extends Controller
}
$db_config['database'] = $database;
self::mkDatabase($db_config);
self::mkLicense($wkcode);
$C_Patch = substr($_SERVER['SCRIPT_FILENAME'],0,-10);
$sql = file_get_contents( $C_Patch.'/public/sql/5kcrm.sql');
$sqlList = parse_sql($sql, 0, ['5kcrm_' => $db_config['prefix']]);
@ -185,9 +198,14 @@ class Install extends Controller
//插入信息
Db::connect($db_config)->query("insert into ".$db_config['prefix']."admin_user (username, password, salt, img, thumb_img, realname, create_time, num, email, mobile, sex, status, structure_id, post, parent_id, type, authkey, authkey_time ) values ( '".$username."', '".$password."', '".$salt."', '', '', '管理员', ".time().", '', '', '".$username."', '', 1, 1, 'CEO', 0, 1, '', 0 )");
Db::connect($db_config)->query("insert into ".$db_config['prefix']."hrm_user_det (user_id, join_time, type, status, userstatus, create_time, update_time, mobile, sex, age, job_num, idtype, idnum, birth_time, nation, internship, done_time, parroll_id, email, political, location, leave_time ) values ( 1, ".time().", 1, 1, 2, ".time().", ".time().", '".$username."', '', 0, '', 0, '', '', 0, 0, 0, 0, '', '', '', 0 )");
touch(CONF_PATH . "install.lock");
touch(CONF_PATH . "install.lock");
return resultArray(['data'=>'安装成功']);
}
public function step5()
{
return $this->fetch();
}
//ajax 进度条
public function progress()
@ -314,7 +332,7 @@ INFO;
{
$items = [
'os' => ['操作系统', PHP_OS, '类Unix', 'ok'],
'php' => ['PHP版本', PHP_VERSION, '7.2 ( <em style="color: #888; font-size: 12px;">>= 5.6</em> )', 'ok','性能更佳'],
'php' => ['PHP版本', PHP_VERSION, '7.3 ( <em style="color: #888; font-size: 12px;">>= 5.6</em> )', 'ok','性能更佳'],
'gd' => ['gd', '开启', '开启', 'ok'],
'openssl' => ['openssl', '开启', '开启', 'ok'],
'pdo' => ['pdo', '开启', '开启', 'ok'],
@ -379,4 +397,32 @@ INFO;
}
return $items;
}
/**
* 验证序列号
* @param
* @return
*/
public function checkCodeOld($username) {
$encryption = md5($username);
$substr = substr($username, strlen($username)-6);
$subArr = str_split($substr, 1);
$code = '';
for ($i = 0; $i <= 5; $i++) {
$code .= $encryption[$subArr[$i]];
}
return $code;
}
//写入license文件
private function mkLicense($wkcode)
{
file_put_contents( CONF_PATH.'license.dat', $wkcode);
// 判断写入是否成功
// $config = include CONF_PATH.'license.dat';
// if (empty($config)) {
// return resultArray(['error' => 'license配置写入失败']);
// }
return true;
}
}

@ -91,7 +91,8 @@ class Users extends ApiCommon
$data = $userModel->getDataById($param['id']);
if (!$data) {
return resultArray(['error' => $userModel->getError()]);
}
}
$data['serverUserInfo'] = $this->queryLoginUser();
return resultArray(['data' => $data]);
}
@ -500,6 +501,7 @@ class Users extends ApiCommon
$data['username'] = $param['username'];
$data['password'] = user_md5($param['password'], $userData['salt'], $param['username']);
$data['userInfo'] = $userData;
$data['mobile'] = $param['username'];
$resSync = model('Sync')->syncData($data);
if ($resSync) {
unset($data['userInfo']);
@ -658,9 +660,6 @@ class Users extends ApiCommon
/**
* 设置关注
*
* @return \think\response\Json
* @throws \think\Exception
* @throws \think\exception\PDOException
*/
public function userStar()
{
@ -700,10 +699,6 @@ class Users extends ApiCommon
/**
* 获取下属(全部层级)
*
* @return \think\response\Json
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function subordinate()
{
@ -720,4 +715,21 @@ class Users extends ApiCommon
return resultArray(['data' => $data]);
}
/**
* 获取当前登录人信息
*
*/
public function queryLoginUser()
{
$resData = [];
$wkcode = file_get_contents(CONF_PATH.'license.dat');
if ($wkcode) {
$resCheckData = checkWkCode($wkcode);
if ($resCheckData) {
$resData = object_to_array(json_decode($resCheckData));
}
}
return $resData;
}
}

@ -535,7 +535,7 @@ class FieldGrantLogic
{
$content = [];
$visitList = Db::name('admin_field')->field(['name', 'field'])->where('types', 'crm_visit')->select();
$visitList = Db::name('admin_field')->field(['name', 'field'])->where(['type' => 'crm_visit', 'operating' => 0])->select();
# 处理自定义字段
foreach ($visitList AS $key => $value) {
@ -551,14 +551,19 @@ class FieldGrantLogic
}
# 处理固定字段
// $content[] = ['name' => '回访时间', 'field' => 'visit_time', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0];
$content[] = ['name' => '负责人', 'field' => 'owner_user_id', 'read' => 1, 'read_operation' => 0, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0];
$content[] = ['name' => '客户', 'field' => 'customer_id', 'read' => 1, 'read_operation' => 0, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0];
$content[] = ['name' => '联系人', 'field' => 'contract_id', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0];
$content[] = ['name' => '回访编号', 'field' => 'number', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0];
$content[] = ['name' => '回访形式', 'field' => 'shape', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0];
$content[] = ['name' => '客户满意度', 'field' => 'satisfaction', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0];
$content[] = ['name' => '回访时间', 'field' => 'visit_time', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0];
$content[] = ['name' => '客户名称', 'field' => 'customer_id', 'read' => 1, 'read_operation' => 0, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0];
$content[] = ['name' => '联系人', 'field' => 'contacts_id', 'read' => 1, 'read_operation' => 1, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0];
$content[] = ['name' => '合同编号', 'field' => 'contract_id', 'read' => 1, 'read_operation' => 0, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0];
$content[] = ['name' => '客户反馈', 'field' => 'feedback', 'read' => 1, 'read_operation' => 1, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0];
$content[] = ['name' => '回访人', 'field' => 'owner_user_id', 'read' => 1, 'read_operation' => 0, 'write' => 1, 'write_operation' => 1, 'is_diy' => 0];
$content[] = ['name' => '创建时间', 'field' => 'create_time', 'read' => 1, 'read_operation' => 0, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0];
$content[] = ['name' => '编辑时间', 'field' => 'update_time', 'read' => 1, 'read_operation' => 0, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0];
$content[] = ['name' => '创建人', 'field' => 'create_user_id', 'read' => 1, 'read_operation' => 0, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0];
$content[] = ['name' => '合同', 'field' => 'contacts_id', 'read' => 1, 'read_operation' => 0, 'write' => 0, 'write_operation' => 0, 'is_diy' => 0];
Db::name('admin_field_grant')->insert([
'role_id' => $roleId,

@ -10,7 +10,7 @@ class MessageLogic
{
$where = '';
switch ($label) {
case '1': //任务
$where = array('in', [1, 2, 3]);//
break;
@ -21,7 +21,7 @@ class MessageLogic
$where = array('in', [6, 7, 8]);
break;
case '4': //公告
$where = array('eq', 9);
$where = 9;
break;
case '5' : //日程
$where = 10;
@ -36,14 +36,14 @@ class MessageLogic
}
return $where;
}
public function getDataList($param)
{
$userId = $param['user_id'];
unset($param['user_id']);
//types 1表示已读 0表示未读
if (isset($param['is_read'])) {
$where['m.read_time'] = ['=', 0];
$where['m.read_time'] = 0;
}
$where['m.to_user_id'] = $userId;
$where['m.is_delete'] = ['eq', 1];
@ -74,11 +74,11 @@ class MessageLogic
->page($param['page'], $param['limit'])
->order($order)
->select();
$dataCount = db('admin_message')
->alias('m')
->join('__ADMIN_USER__ user', 'user.id=m.from_user_id', 'LEFT')
->where($where)->count();
}
$dataCount = db('admin_message')
->alias('m')
->join('__ADMIN_USER__ user', 'user.id=m.from_user_id', 'LEFT')
->where($where)->count();
//1表示已读 0表示未读
foreach ($list as $k => $v) {
if ($v['read_time'] == 0) {
@ -90,48 +90,38 @@ class MessageLogic
if ($v['type'] == 4) {
$content = db('admin_comment')
->where(
[ 'status' => 1,
'comment_id' => $v['action_id'],
['status' => 1,
'type_id' => $v['action_id'],
'type' => ['like', '%' . $v['controller_name' . '%']],
'user_id' => $v['from_user_id']
])
->find();
if (!empty($content)) {
$list[$k]['content'] = $content['content'];
}
} elseif (in_array($v['type'], ['12', '15'])) {
->select();
$list[$k]['content'] = $content[$k]['content'];
} elseif (in_array($v['type'], ['7','12', '15',25])) {
$content = db('admin_examine_record')->where(['types_id' => $v['action_id'], 'types' => ['like', '%' . $v['controller_name' . '%']], 'check_user_id' => $v['from_user_id']])->field('content')->find();
if ($content['content']) {
$list[$k]['content'] = $content['content'];
}
}
if ($v['type'] == 10) {
$item = db('oa_event_notice')->where('id', $v['action_id'])->find();
if ($item) {
$noticetype = $item['noticetype'];
if($item['noticetype'] == 1){
$advance_time =$v['advance_time'] - ($item['number'] * 60);
}elseif ($item['noticetype'] == 2){
$advance_time =$v['advance_time'] - ($item['number'] * 60 * 60);
}else{
$advance_time = $v['advance_time'] - ($item['number'] * 60 * 60 * 24);
}
$time = time();
if ($time == $advance_time ||$time>$advance_time) {
$type['value']=$item['number'];
$type['type']=$item['noticetype'];
$list[$k]['content']= $type;
$list[$k]['action_id'] = $item['event_id'];
}
}
// p(222);
if ($v['type'] == 10 && $v['advance_time'] < time()) {
$item = db('oa_event_notice')->where('id', $v['action_id'])->find();
if ($item) {
$type['value'] = $item['number'];
$type['type'] = $item['noticetype'];
$list[$k]['content'] = $type;
$list[$k]['action_id'] = $item['event_id'];
}
} elseif($v['type'] == 10 && $v['advance_time'] > time()) {
unset($list[$k]);
}
$time=time();
if (in_array($v['type'], ['17', '18', '19', '20', '27'])) {
$error_file_path = db('admin_import_record')->where('id', $v['action_id'])->find();
if($error_file_path['error_data_file_path']==''){
$list[$k]['title'] = '';
$week = strtotime("+7 day", $error_file_path['create_time']);
if ($time > (int)$week && $error_file_path['error_data_file_path'] != '') {
$list[$k]['valid'] = 0;
} else {
$list[$k]['valid'] = 1;
}
$list[$k]['error_file_path'] = $error_file_path['error_data_file_path'];
}
@ -151,7 +141,7 @@ class MessageLogic
}
return $data;
}
/**
* 修改状态变为已读
* @param $param
@ -173,7 +163,7 @@ class MessageLogic
$data['list'] = $list;
return $data;
}
/**
* 删除
*
@ -190,7 +180,7 @@ class MessageLogic
}
return db('admin_message')->where(['message_id' => $param['message_id']])->update(['is_delete' => 2]);
}
/**
* 批量更新
* @param $param
@ -200,7 +190,7 @@ class MessageLogic
*/
public function readAllMessage($param)
{
$where = [
'to_user_id' => $param['user_id'],
'read_time' => 0
@ -220,7 +210,7 @@ class MessageLogic
$data['list'] = $list;
return $data;
}
/**
* 批量删除已读
* @param $param
@ -244,7 +234,7 @@ class MessageLogic
$data['list'] = $list;
return $data;
}
public function unreadCount($param)
{
$userId = $param['user_id'];
@ -253,7 +243,7 @@ class MessageLogic
$label = '';
$where['to_user_id'] = ['eq', $userId];
$where['is_delete'] = ['eq', 1];
$where['type'] = $this->label('');
$allCount = db('admin_message')->where($where)->count();
$where['type'] = $this->label(1);
@ -265,10 +255,10 @@ class MessageLogic
$where['type'] = 9;
$announceCount = db('admin_message')->where($where)->count();
$where['type'] = $this->label(5);
$eventCount = db('admin_message')->where($where)->where('advance_time', '>=', time())->count();
$eventCount = db('admin_message')->where($where)->where(['advance_time'=>['<', time()],'advance_time'=>['<>',0]])->count();
$where['type'] = $this->label(6);
$crmCount = db('admin_message')->where($where)->count();
$data = [];
$data['allCount'] = $allCount ?: 0;
$data['taskCount'] = $taskCount ?: 0;

@ -109,6 +109,13 @@ class WorkLogic
if (!Db::name('admin_group')->where('id', $id)->delete()) return ['status' => false, 'error' => '操作失败!'];
# 将项目权限变更为只读权限
$readOnlyId = db('admin_group')->where(['title' => '只读', 'types' => 7, 'system' => 1])->value('id');
if (!empty($readOnlyId)) {
db('work')->where('group_id', $id)->update(['group_id' => $readOnlyId]); # 处理公开项目的权限
db('work_user')->where('group_id', $id)->update(['group_id' => $readOnlyId]); # 处理私有项目的权限
}
return ['status' => true];
}
}

@ -295,6 +295,7 @@ class Common extends Model
*/
public function exportHandle($list, $field_list, $type = '')
{
foreach ($list as &$val) {
foreach ($field_list as $field) {
switch ($field['form_type']) {
@ -310,7 +311,7 @@ class Common extends Model
$val[$field['field']] = implode(',', array_column($temp, 'name'));
break;
case 'datetime':
$val[$field['field']] = strtotime($val[$field['field']]) ? $val[$field['field']] : date('Y-m-d H:i:s', $val[$field['field']]);
$val[$field['field']] = strtotime($val[$field['field']]) ? $val[$field['field']] : '';
break;
case 'customer':
case 'business':

@ -324,7 +324,7 @@ class ExamineStep extends Common
$is_recheck = 1;
}
}
if (in_array($check_user_id, stringToArray($dataInfo['check_user_id'])) && !in_array($dataInfo['check_status'],['2','3'])) {
if (in_array($check_user_id, stringToArray($dataInfo['check_user_id'])) && !in_array($dataInfo['check_status'],['2','3','4'])) {
$is_check = 1;
}
@ -339,6 +339,7 @@ class ExamineStep extends Common
$createUserInfo['check_type'] = 3;
$newlist[0]['type'] = '3'; //创建
$newlist[0]['status'] = '5'; //创建前端要求给创建人加一个status字段定义为5
}
$newlist[0]['user_id_info'] = array($createUserInfo);
$newlist[0]['time'] = !empty($dataInfo['update_time']) ? date('Y-m-d H:i:s', $dataInfo['update_time']) : null;

File diff suppressed because it is too large Load Diff

@ -182,10 +182,6 @@ class Field extends Model
if ($param['types'] == 'crm_customer') {
$map['field'] = array('not in', ['deal_status']);
}
if ($param['types'] == 'crm_visit') {
$map['types'] = array('in', ['', $types]);
$map['field'] = ['not in', ['create_user_id', 'update_time', 'create_time']];
}
$list = Db::name('AdminField')->where($map)->order('order_id')->select();
foreach ($list as $k => $v) {
$list[$k]['setting'] = $v['setting'] ? explode(chr(10), $v['setting']) : [];
@ -655,7 +651,7 @@ class Field extends Model
}
} else {
$field_list = $this->where($map)->field('field,types,name,form_type,default_value,is_unique,is_null,input_tips,setting')->order($order)->select();
$field_list = $this->where($map)->where( 'is_hidden',0)->field('field,types,name,form_type,default_value,is_unique,is_null,input_tips,setting,is_hidden')->order($order)->select();
//客户
if (in_array($param['types'], ['crm_customer'])) {
@ -754,7 +750,16 @@ class Field extends Model
];
} elseif ($v['form_type'] == 'user') {
$value = $userModel->getListByStr($dataInfo[$v['field']]) ?: [];
} elseif ($v['form_type'] == 'structure') {
if (empty($value)) $default_value = $userModel->getListByStr($param['user_id']) ? : [];
} elseif ($v['form_type'] == 'single_user') {
# 单用户
$userInfo = $userModel->getListByStr($dataInfo[$v['field']]);
$value = !empty($userInfo[0]) ? $userInfo[0] : [];
if (empty($value)) {
$userInfo = $userModel->getListByStr($param['user_id']);
$default_value = !empty($userInfo[0]) ? $userInfo[0] : [];
}
}elseif ($v['form_type'] == 'structure') {
$value = $structureModel->getListByStr($dataInfo[$v['field']]) ?: [];
} elseif ($v['form_type'] == 'file') {
$fileIds = [];
@ -882,7 +887,8 @@ 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', 'checkbox', 'structure', 'business_status']];
$map['form_type'] = ['not in', ['file', 'form', 'business_status']];
$map['is_hidden'] = 0;
$field_list = db('admin_field')
->where($map)
->whereOr(['types' => ''])
@ -1026,12 +1032,16 @@ class Field extends Model
$userLevel = isSuperAdministrators($user_id);
$fieldList = $this->getFieldList($types, $types_id);
$where = [];
if ($userFieldData) {
$fieldArr = [];
$i = 0;
foreach ($userFieldData as $k => $v) {
if (empty($fieldList[$k])) {
unset($userFieldData[$k]);
continue;
}
if (empty($v['is_hide'])) {
$fieldArr[$i]['field'] = $k;
$fieldArr[$i]['name'] = $fieldList[$k]['name'];
@ -1081,8 +1091,9 @@ class Field extends Model
'form_type' => ['not in', ['file', 'form']],
'field' => ['not in', $unField],
'types_id' => ['eq', $types_id],
'is_hidden'=>0
])
->field(['field', 'name', 'form_type'])
->field(['field', 'name', 'form_type,is_hidden'])
->order('order_id asc')
->select();
@ -1192,7 +1203,6 @@ class Field extends Model
} else {
$listArr = $dataList;
}
$typesArray = explode('_', $types);
$type = array_pop($typesArray);
if (isset($this->orther_field_list[$types])) {
@ -1257,6 +1267,11 @@ class Field extends Model
if ($unFormType) $data['form_type'] = array('not in', $unFormType);
$field_arr = $this->fieldSearch($data);
}
if ($types == 'crm_visit') {
foreach ($field_arr AS $key => $value) {
if ($value['name'] == '负责人') unset($field_arr[(int)$key]);
}
}
return $field_arr;
}
@ -1315,9 +1330,12 @@ class Field extends Model
$where = [];
$where[$field] = ['eq', $val];
if ($id) {
//为编辑时的验重
$where[$dataModel->getpk()] = ['neq', $id];
if ($id) {
//为编辑时的验重
$where[$dataModel->getpk()] = ['neq', $id];
}
if($types=='crm_product'){
$where['delete_user_id'] = 0;
}
if ($res = $dataModel->where($where)->find()) {
$this->error = '该数据已存在,请修改后提交!';
@ -1378,7 +1396,7 @@ class Field extends Model
case 'userStr' :
$val = explode(',', $val);
$val = count($userModel->getUserNameByArr($val)) > 1 ? ArrayToString($userModel->getUserNameByArr($val)) : implode(',', $userModel->getUserNameByArr($val));
break;
break;
case 'structure' :
$val = ArrayToString($structureModel->getStructureNameByArr($val));
break;
@ -1648,6 +1666,7 @@ class Field extends Model
break;
case 'owner_user_id' :
$data[$key]['fieldName'] = 'owner_user_name';
$data[$key]['name'] = '回访人';
break;
case 'contacts_id' :
$data[$key]['fieldName'] = 'contacts_name';

@ -609,7 +609,7 @@ class Record extends Common
}
$fileModel = new \app\admin\model\File();
$record_ids = db('crm_activity')->where(['activity_type' => $types,'activity_type_id' => ['in',$types_id]])->column('activity_id');
db('crm_activity')->where(['activity_type' => $types,'activity_type_id' => ['in',$types_id],'type'=>1])->delete();
db('crm_activity')->where(['activity_type' => $types,'activity_type_id' => ['in',$types_id]])->delete();
//删除关联附件
$fileModel->delRFileByModule('crm_activity',$record_ids);
return true;

@ -53,10 +53,10 @@ class Scene extends Common
foreach ($value AS $k => $v) {
$sceneData[$k] = [
'condition' => trim($v['condition']),
'value' => $v['value'],
'value' => $v['value'],
'form_type' => $v['form_type'],
'name' => $v['name'],
'type' => $v['type']
'name' => $v['name'],
'type' => $v['type']
];
}
}
@ -200,7 +200,13 @@ class Scene extends Common
$sceneData = [];
foreach ($param['data'] AS $key => $value) {
foreach ($value AS $k => $v) {
$sceneData[$k] = $v;
$sceneData[$k] = [
'condition' => trim($v['condition']),
'value' => $v['value'],
'form_type' => $v['form_type'],
'name' => $v['name'],
'type' => $v['type']
];
}
}
if (!empty($sceneData)) $param['data'] = $sceneData;
@ -210,7 +216,9 @@ class Scene extends Common
$res = $this->allowField(true)->save($param, ['scene_id' => $id]);
if ($param['is_default'] == 1) {
$this->defaultDataById($param,$param['id']);
}
} else {
db('admin_scene_default')->where(['user_id' => $user_id, 'types' => $param['types'], 'scene_id' => $id])->delete();
}
if ($res) {
return true;
} else {

@ -47,7 +47,7 @@ class User extends Common
'name' => '手机号(登录名)',
'form_type' => 'mobile',
'is_null' => 1,
'is_unique' => 1
// 'is_unique' => 1 //guogaobo 导入此字段会进行验重查询调用修改用户方法
],
[
'field' => 'password',
@ -256,6 +256,10 @@ class User extends Common
}
$param = $temp;
$param['structure_id'] = 0;
if(db('admin_user')->where('username',$param['username'])->find()){
$this->error = '手机号已存在';
return false;
}
} else {
if (empty($param['group_id']) || !is_array($param['group_id'])) {
$this->error = '请至少勾选一个用户组';
@ -269,7 +273,6 @@ class User extends Common
return false;
}
$syncModel = new \app\admin\model\Sync();
$this->startTrans();
try {
$salt = substr(md5(time()),0,4);
@ -350,6 +353,7 @@ class User extends Common
*/
public function updateDataById($param, $id)
{
if ($param['user_id']) {
//修改个人信息
$data['email'] = $param['email'];
@ -396,6 +400,7 @@ class User extends Common
$this->error = '直属上级不能是自己或下属';
return false;
}
p(2333);
if (db('admin_user')->where(['id' => ['neq',$id],'username' => $param['username']])->find()) {
$this->error = '手机号已存在';
return false;
@ -925,8 +930,6 @@ class User extends Common
$authList['jxc'] = (Object)[];
$authList['knowledge'] = (Object)[];
$authList['crm']['receivables']['excelexport'] = false;
return $authList;
}

@ -147,7 +147,7 @@ class UserField extends Model
$field_list[$v['field']]['name'] = $v['name'];
$fieldArr[$k]['width'] = '';
}
//已设置字段
$value = $this->where(['types' => $types,'user_id' => $user_id])->value('datas');
$value = $value ? json_decode($value, true) : [];
@ -162,6 +162,8 @@ class UserField extends Model
$a = 0;
$b = 0;
foreach ($value as $k=>$v) {
if (empty($field_list[$k]['name'])) continue;
if (empty($v['is_hide'])) {
$valueList[] = $k;
$value_list[$a]['field'] = $k;
@ -193,6 +195,16 @@ class UserField extends Model
$data = [];
$data['value_list'] = $value_list ? : []; //展示列
$data['hide_list'] = $hide_list ? : []; //隐藏列
if ($types == 'crm_visit') {
foreach ($data['value_list'] AS $key => $value) {
if ($value['name'] == '负责人') $data['value_list'][$key]['name'] = '回访人';
}
foreach ($data['hide_list'] AS $key => $value) {
if ($value['name'] == '负责人') $data['hide_list'][$key]['name'] = '回访人';
}
}
return $data ? : [];
}
}

@ -28,7 +28,7 @@
官方地址:<a target="_blank" href="http://www.5kcrm.com">www.5kcrm.com</a> / <a target="_blank" href="https://www.72crm.com">www.72crm.com</a><br>
官方电话400-0812-558<br>
官方邮箱service@5kcrm.com<br>
官方社区:<a target="_blank" href="http://www.72crm.net">bbs.72crm.net</a><br>
官方社区:<a target="_blank" href="https://bbs.72crm.com">bbs.72crm.com</a><br>
官方社群:<a target="_blank" href="//shang.qq.com/wpa/qunwpa?idkey=f4687b809bf63f08f707aa1c56dee8dbcb9526237c429c4532222021d65bf83c">悟空CRM交流10群486745026</a><br>
<br>
<p>一、协议中提到的名词约定</p>

@ -16,17 +16,23 @@
<div class="top">
<div class="step-group">
<div class="step active">
<div class="sort">1</div>
<div class="sort">
<img class="pic" style="width:100%; height: 100%;" src="__STATIC__/icon/success.png" alt="">
</div>
<div class="desc">检查安装环境</div>
</div>
<div class="step line"></div>
<div class="step">
<div class="sort">2</div>
<div class="sort">
<img class="pic" style="width:100%; height: 100%;" src="__STATIC__/icon/success_gray.png" alt="">
</div>
<div class="desc">创建数据库</div>
</div>
<div class="step line"></div>
<div class="step">
<div class="sort">3</div>
<div class="sort">
<img class="pic" style="width:100%; height: 100%;" src="__STATIC__/icon/success_gray.png" alt="">
</div>
<div class="desc">安装成功</div>
</div>
</div>
@ -34,7 +40,7 @@
<div class="container">
<div class="content">
<div class="base-top">
<span class="title">1 检查安装环境</span>
<span class="title">检查安装环境</span>
<span class="version">当前版本:{$data['version']['VERSION']} {$data['version']['RELEASE']}</span>
</div>
<div class="table">

@ -7,87 +7,114 @@
<link rel="shortcut icon" href="__STATIC__/icon/favicon.ico">
<link rel="stylesheet" href="__STATIC__/style/base.css">
<link rel="stylesheet" href="__STATIC__/style/step2.css">
<link rel="stylesheet" href="__STATIC__/style/loading.css">
<script src="__STATIC__/js/jquery-3.3.1.min.js"></script>
</head>
<body>
<body style="width: 100%; height: 100%;position: relative;">
<div id="cover">
<div id="loader-container">
<p id="loadingText">creating...</p>
</div>
</div>
<div class="header-wrapper">
{include file="public/header"}
</div>
<div class="top">
<div class="step-group">
<div class="step active">
<div class="sort">1</div>
<div class="sort">
<img class="pic" style="width:100%; height: 100%;" src="__STATIC__/icon/success.png" alt="">
</div>
<div class="desc">检查安装环境</div>
</div>
<div class="step active line"></div>
<div class="step active">
<div class="sort">2</div>
<div class="sort">
<img class="pic" style="width:100%; height: 100%;" src="__STATIC__/icon/success.png" alt="">
</div>
<div class="desc">创建数据库</div>
</div>
<div class="step line"></div>
<div class="step">
<div class="sort">3</div>
<div class="sort">
<img class="pic" style="width:100%; height: 100%;" src="__STATIC__/icon/success_gray.png" alt="">
</div>
<div class="desc">安装成功</div>
</div>
</div>
</div>
<div class="container">
<div class="container">
<div class="content">
<div class="base-top">
<span class="title">2 创建数据库</span>
<span class="title">创建数据库</span>
<span class="version">当前版本:{$envir_data['version']['VERSION']} {$envir_data['version']['RELEASE']}</span>
</div>
<div class="form">
<div class="form-sec-title">请填写数据库信息</div>
<div class="form-item">
<div class="form-label">数据库主机:</div>
<input type="text" name="databaseUrl">
<!--<div class="error" style="display: none">数据库主机不能空</div>-->
<div class="remind">数据库地址一般为127.0.0.1</div>
</div>
<div class="form-item">
<div class="form-label">数据库名:</div>
<input type="text" name="databaseName">
</div>
<div class="form-item">
<div class="form-label">端口:</div>
<input type="text" name="databasePort">
<div class="remind">一般为 3306</div>
</div>
<div class="form-item">
<div class="form-label">数据库用户名:</div>
<input type="text" name="databaseUser">
<div class="remind">生产环境建议创建独立账号</div>
</div>
<div class="form-item">
<div class="form-label">数据库密码:</div>
<input type="password" name="databasePwd">
</div>
<div class="form-item">
<div class="form-item">
<div class="form-label">数据库主机:</div>
<input type="text" class="wkform" name="databaseUrl" placeholder="127.0.0.1">
<!--<div class="error" style="display: none">数据库主机不能空</div>-->
<!-- <div class="remind">数据库地址一般为127.0.0.1</div> -->
</div>
<div class="form-item">
<div class="form-label">数据库名:</div>
<input type="text" class="wkform" name="databaseName">
</div>
<div class="form-item">
<div class="form-label">端口:</div>
<input type="text" class="wkform" name="databasePort" placeholder="一般为3306">
<!-- <div class="remind">一般为 3306</div> -->
</div>
<div class="form-item">
<div class="form-label">数据库用户名:</div>
<input type="text" class="wkform" name="databaseUser" placeholder="生产环境建议创建独立账号">
<!-- <div class="remind">生产环境建议创建独立账号</div> -->
</div>
<div class="form-item">
<div class="form-label">数据库密码:</div>
<input type="password" class="wkform" name="databasePwd">
</div>
<div class="form-item">
<div class="form-label">表前缀:</div>
<input type="text" name="databaseTable">
<div class="remind">默认为5kcrm_</div>
</div>
<div class="form-sec-title">请填写管理员信息</div>
<div class="form-item">
<div class="form-label">管理员账号:</div>
<input type="text" name="root" placeholder="请输入手机号码">
<input type="text" class="wkform" name="databaseTable" placeholder="默认我5kcrm-">
<!-- <div class="remind">默认为5kcrm_</div> -->
</div>
<div class="form-item">
<div class="form-label">安装序列号:</div>
<textarea name="wkcode" class="wkform" rows="6" placeholder="请输入您的序列号"></textarea>
<div class="remind">
<span class="title">您需要通过手机号来<a class="base-a" target="_blank" href="https://www.72crm.com/login">注册悟空ID</a>,该手机号将作为您登录系统的管理员账号。您需要进入【悟空个人中心】,点击【开源版下载】<a class="base-a" target="_blank" href="https://www.72crm.com/login">获取您的序列号</a>如您已经注册悟空ID您只需要点击<a class="base-a" target="_blank" href="https://www.72crm.com/login">登录个人中心</a>即可查看您的序列号</span>
</div>
<div class="form-item">
</div>
<div class="form-sec-title">请填写管理员信息</div>
<p style="color:#d5d5d5;font-size: 12px;">
请填写以下管理员信息,是指完成且系统安装成功后,您可以使用管理员信息登录系统.
</p>
<div class="form-item">
<div class="form-label">管理员账号:</div>
<input type="text" class="wkform" name="root" placeholder="请输入您的手机号码">
</div>
<div class="form-item">
<div class="form-label">管理员密码:</div>
<input type="password" name="pwd">
<input type="password" class="wkform" name="pwd" placeholder="6~20位字母加数字组合">
</div>
</div>
<div class="base-des">
</div>
<div class="install_progress_a">
<!-- <progress class="install_progress" max="97" value="8"></progress> -->
</div>
<div class="control">
<div class="prev btn">上一步</div>
<div class="next btn primary">下一步</div>
<div class="next btn primary">安装</div>
</div>
</div>
</div>
</div>
<div class="footer-wrapper">
{include file="public/footer"}
</div>

@ -16,17 +16,23 @@
<div class="top">
<div class="step-group">
<div class="step active">
<div class="sort">1</div>
<div class="sort">
<img class="pic" style="width:100%; height: 100%;" src="__STATIC__/icon/success.png" alt="">
</div>
<div class="desc">检查安装环境</div>
</div>
<div class="step active line"></div>
<div class="step active">
<div class="sort">2</div>
<div class="sort">
<img class="pic" style="width:100%; height: 100%;" src="__STATIC__/icon/success.png" alt="">
</div>
<div class="desc">创建数据库</div>
</div>
<div class="step line active"></div>
<div class="step">
<div class="sort">3</div>
<div class="sort">
<img class="pic" style="width:100%; height: 100%;" src="__STATIC__/icon/success_gray.png" alt="">
</div>
<div class="desc">安装成功</div>
</div>
</div>

@ -0,0 +1,64 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<title>悟空CRM安装向导</title>
<link rel="shortcut icon" href="__STATIC__/icon/favicon.ico">
<link rel="stylesheet" href="__STATIC__/style/base.css">
<link rel="stylesheet" href="__STATIC__/style/step3.css">
<script src="__STATIC__/js/jquery-3.3.1.min.js"></script>
</head>
<body>
<div class="header-wrapper">
{include file="public/header"}
</div>
<div class="top">
<div class="step-group">
<div class="step active">
<div class="sort">
<img class="pic" style="width:100%; height: 100%;" src="__STATIC__/icon/success.png" alt="">
</div>
<div class="desc">检查安装环境</div>
</div>
<div class="step active line"></div>
<div class="step active">
<div class="sort">
<img class="pic" style="width:100%; height: 100%;" src="__STATIC__/icon/success.png" alt="">
</div>
<div class="desc">创建数据库</div>
</div>
<div class="step line active"></div>
<div class="step">
<div class="sort">
<img class="pic" style="width:100%; height: 100%;" src="__STATIC__/icon/success.png" alt="">
</div>
<div class="desc">安装成功</div>
</div>
</div>
</div>
<div class="container">
<div class="result">
<div class="status-box" style="display:flex; align-items:center;justify-content:center">
<img class="pic" style="width: 50px; height: 50px;" src="__STATIC__/icon/success.png" alt="">
</div>
<h1 style="text-align:center">恭喜您,已成功安装悟空CRM</h1>
<div class="desc" style="color:#acacac; font-weight: 600; margin-top: 50px; line-height:30px">
<p>您已经成功安装开源PHP悟空CRM,您可以尽情享用悟空CRM开源版算有功能及服务.</p>
<p>使用管理员账号即可登录</p>
</div>
<div class="control">
<div class="btn primary login">立即登录</div>
</div>
</div>
</div>
<div class="footer-wrapper">
{include file="public/footer"}
</div>
</body>
<script>
$('.login').click(function () {
window.location = '../../../index.html'
})
</script>
</html>

@ -1,6 +1,6 @@
<footer class="footer">
<div class="content">
悟空CRM受国家计算机软件著作权保护未经授权不得进行商业行为违者必究。<br>
&copy;2021 悟空软件<a target="_blank" href="http://www.5kcrm.com">www.5kcrm.com</a>
&copy;2021 悟空软件 <a target="_blank" style="color: #fff;" href="http://www.5kcrm.com">www.5kcrm.com</a>
</div>
</footer>

@ -122,10 +122,11 @@ class Examine extends ApiCommon
unset($where['create_time']);
unset($where['create_user_id']);
unset($where['create_user_id']);
$where['check_status'] = 'all';
// $where['check_status'] = 'all';
$where['page'] = $param['page'];
$where['limit'] = $param['limit'];
$where['user_id'] = $user_id;
$where['bi_types'] = 'bi';
$where['between_time'] = array($start_time,$end_time);
$list = $examineModel->getDataList($where);

@ -165,10 +165,29 @@ function where_arr($array = [], $m = '', $c = '', $a = '')
if (!empty($v['start'])) $v['start'] = date('Y-m-d', $v['start']);
if (!empty($v['end'])) $v['end'] = date('Y-m-d', $v['end']);
}
if ($v['form_type'] == 'user') {
# 创建人、负责人、回访人(非自定义字段)
if ($v['form_type'] == 'user' && in_array($k, ['create_user_id', 'owner_user_id'])) {
if ($v['condition'] == 'is') $v['condition'] = 'contains';
}
if ($types == 'contract') {
# 自定义字段的user、structure类型
if (($v['form_type'] == 'user' && !in_array($k, ['create_user_id', 'owner_user_id'])) || $v['form_type'] == 'structure') {
if ($v['condition'] == 'is') $v['condition'] = 'contains';
if ($v['condition'] == 'isNot') {
return "(".$c.$k." not like '%".$v['value'][0]."%' OR ".$c.$k." is null)";
}
}
# 处理多选字段的精确搜索
if ($v['form_type'] == 'checkbox' && !empty($v['value'])) {
if ($v['condition'] == 'is' && count($v['value']) == 1) $v['value'][0] = ',' . $v['value'][0] . ',';
if ($v['condition'] == 'is' && count($v['value']) > 1) {
$checkboxLike = '';
foreach ($v['value'] AS $kk => $vv) {
$checkboxLike .= $c.$k." like "."'%".$vv."%' AND ";
}
return "(".$checkboxLike."LENGTH(".$c.$k.") = LENGTH('".arrayToString($v['value'])."'))";
}
}
if ($types == 'contract' && !empty($v['value'])) {
switch ($k) {
case 'business_id' :
$k = 'name';
@ -186,11 +205,11 @@ function where_arr($array = [], $m = '', $c = '', $a = '')
break;
}
}
if ($types == 'receivables' && $v['name'] == '合同编号') {
if ($types == 'receivables' && $v['name'] == '合同编号' && !empty($v['value'])) {
$k = 'num';
$c = 'contract.';
}
if ($types == 'receivables' && $k == 'plan_id') {
if ($types == 'receivables' && $k == 'plan_id' && !empty($v['value'])) {
$planIds = [];
foreach ($v['value'] AS $kk => $vv) {
$planIdArray = db('crm_receivables_plan')->whereLike('num', '%' . $vv . '%')->column('plan_id');
@ -200,17 +219,21 @@ function where_arr($array = [], $m = '', $c = '', $a = '')
}
$v['value'] = array_unique($planIds);
}
if ($types == 'invoice' && $v['type'] == 'invoice_status') {
if ($types == 'invoice' && $v['type'] == 'invoice_status' && !empty($v['value'])) {
foreach ($v['value'] AS $kk => $vv) {
if ($vv == '已开票') $v['value'][$kk] = 1;
if ($vv == '未开票') $v['value'][$kk] = 0;
}
}
if ($types == 'visit' && $v['type'] == 'contract_name') {
if ($types == 'visit' && $v['type'] == 'contract_name' && !empty($v['value'])) {
$k = 'num';
$c = 'contract.';
}
if ($k == 'check_status' && is_array($v) && in_array($v['value'][0], $checkStatusList)) {
if ($types == 'visit' && $v['type'] == 'contacts_name' && !empty($v['value'])) {
$k = 'name';
$c = 'contacts.';
}
if ($k == 'check_status' && is_array($v) && in_array($v['value'][0], $checkStatusList) && !empty($v['value'])) {
$v['value'] = $checkStatusArray[$v['value'][0]] ?: '0';
}
if (is_array($v)) {

@ -276,11 +276,6 @@ class Business extends ApiCommon
$errorMessage[] = $businessInfo['name'].'"转移失败,错误原因:无权限;';
continue;
}
$resBusiness = db('crm_business')->where(['business_id' => $business_id])->update($data);
if (!$resBusiness) {
$errorMessage[] = $businessInfo['name'].'"转移失败,错误原因:数据出错;';
continue;
}
//团队成员
teamUserId(
@ -291,7 +286,25 @@ class Business extends ApiCommon
$is_remove,
0
);
$resBusiness = db('crm_business')->where(['business_id' => $business_id])->update($data);
if (!$resBusiness) {
$errorMessage[] = $businessInfo['name'].'"转移失败,错误原因:数据出错;';
continue;
} else {
$businessArray = [];
$teamBusiness = db('crm_business')->field(['owner_user_id', 'ro_user_id', 'rw_user_id'])->where('business_id', $business_id)->find();
if (!empty($teamBusiness['ro_user_id'])) {
$businessRo = arrayToString(array_diff(stringToArray($teamBusiness['ro_user_id']), [$teamBusiness['owner_user_id']]));
$businessArray['ro_user_id'] = $businessRo;
}
if (!empty($teamBusiness['rw_user_id'])) {
$businessRo = arrayToString(array_diff(stringToArray($teamBusiness['rw_user_id']), [$teamBusiness['owner_user_id']]));
$businessArray['rw_user_id'] = $businessRo;
}
db('crm_business')->where('business_id', $business_id)->update($businessArray);
}
//修改记录
updateActionLog($userInfo['id'], 'crm_business', $business_id, '', '', '将商机转移给:'.$ownerUserName);
}

@ -214,12 +214,6 @@ class Contract extends ApiCommon
if (!in_array($dataInfo['check_status'], ['3', '4', '5', '6'])) {
return resultArray(['error' => '当前状态为审批中或已审批通过,不可编辑']);
}
if ($param['is_draft'] || (!empty($param['check_status']) && $param['check_status'] == 5)) {
//保存为草稿
$param['check_status'] = 5; //草稿(未提交)
$param['check_user_id'] = $param['check_user_id'] ? ','.$param['check_user_id'].',' : '';
} else {
if (($examineStatus != false && $examineStatus != 'false') || $examineStatus == 1) {
//将合同审批状态至为待审核,提交后重新进行审批
//审核判断(是否有符合条件的审批流)
@ -244,7 +238,7 @@ class Contract extends ApiCommon
} else {
$check_user_id = $param['check_user_id'] ? ','.$param['check_user_id'].',' : '';
}
if ($param['is_draft']) {
if ($param['is_draft'] || (!empty($param['check_status']) && $param['check_status'] == 5)) {
//保存为草稿
$param['check_status'] = 5;
$param['check_user_id'] = $param['check_user_id'] ? ','.$param['check_user_id'].',' : '';
@ -257,7 +251,7 @@ class Contract extends ApiCommon
}
$param['flow_user_id'] = '';
}
}
if ($contractModel->updateDataById($param, $param['id'])) {
//将审批记录至为无效
@ -314,7 +308,7 @@ class Contract extends ApiCommon
$isDel = false;
$errorMessage[] = '名称为'.$data['name'].'的合同删除失败,错误原因:当前合同已作废,非超级管理员,不可删除';
}
if (!in_array($data['check_status'],['0','4','5','6']) && !in_array(1,$adminTypes)) {
if (!in_array($data['check_status'], [4, 5]) && !in_array(1,$adminTypes)) {
$isDel = false;
$errorMessage[] = '名称为'.$data['name'].'的合同删除失败,错误原因:当前状态为审批中或已审批通过,不可删除';
}
@ -335,9 +329,9 @@ class Contract extends ApiCommon
return resultArray(['error' => $contractModel->getError()]);
}
//删除跟进记录
$recordModel->delDataByTypes('crm_contract',$delIds);
$recordModel->delDataByTypes(6,$delIds);
//删除关联附件
$fileModel->delRFileByModule(6,$delIds);
$fileModel->delRFileByModule('crm_contract',$delIds);
//删除关联操作记录
$actionRecordModel->delDataById(['types'=>'crm_contract','action_id'=>$delIds]);
// 删除回款记录
@ -395,15 +389,10 @@ class Contract extends ApiCommon
$errorMessage[] = $contractInfo['name'].'"转移失败,错误原因:无权限;';
continue;
}
if (in_array($contractInfo['check_status'],['0','1'])) {
$errorMessage[] = $contractInfo['name'].'"转移失败,错误原因:待审或审批中,无法转移;';
continue;
}
$resContract = db('crm_contract')->where(['contract_id' => $contract_id])->update($data);
if (!$resContract) {
$errorMessage[] = $contractInfo['name'].'"转移失败,错误原因:数据出错;';
continue;
}
// if (in_array($contractInfo['check_status'],['0','1'])) {
// $errorMessage[] = $contractInfo['name'].'"转移失败,错误原因:待审或审批中,无法转移;';
// continue;
// }
//团队成员
teamUserId(
@ -411,9 +400,29 @@ class Contract extends ApiCommon
$contract_id,
$type,
[$contractInfo['owner_user_id']],
$is_remove,
($is_remove == 1) ? 1 : '',
0
);
$resContract = db('crm_contract')->where(['contract_id' => $contract_id])->update($data);
if (!$resContract) {
$errorMessage[] = $contractInfo['name'].'"转移失败,错误原因:数据出错;';
continue;
} else {
# 处理负责人重复显示在团队成员中的bug
$contractArray = [];
$teamContract = db('crm_contract')->field(['owner_user_id', 'ro_user_id', 'rw_user_id'])->where('contract_id', $contract_id)->find();
if (!empty($teamContract['ro_user_id'])) {
$contractRo = arrayToString(array_diff(stringToArray($teamContract['ro_user_id']), [$teamContract['owner_user_id']]));
$contractArray['ro_user_id'] = $contractRo;
}
if (!empty($teamContract['rw_user_id'])) {
$contractRo = arrayToString(array_diff(stringToArray($teamContract['rw_user_id']), [$teamContract['owner_user_id']]));
$contractArray['rw_user_id'] = $contractRo;
}
db('crm_contract')->where('contract_id', $contract_id)->update($contractArray);
}
//修改记录
updateActionLog($userInfo['id'], 'crm_contract', $contract_id, '', '', '将合同转移给:'.$ownerUserName);
}

@ -316,7 +316,20 @@ class Customer extends ApiCommon
if (!$resCustomer) {
$errorMessage[] = $customerInfo['name'].'转移失败,错误原因:数据出错;';
continue;
}
} else {
# 处理转移时,负责人出现在只读和读写成员列表中
$customerArray = [];
$teamCustomer = db('crm_customer')->field(['owner_user_id', 'ro_user_id', 'rw_user_id'])->where('customer_id', $customer_id)->find();
if (!empty($teamCustomer['ro_user_id'])) {
$customerRo = arrayToString(array_diff(stringToArray($teamCustomer['ro_user_id']), [$teamCustomer['owner_user_id']]));
$customerArray['ro_user_id'] = $customerRo;
}
if (!empty($teamCustomer['rw_user_id'])) {
$customerRo = arrayToString(array_diff(stringToArray($teamCustomer['rw_user_id']), [$teamCustomer['owner_user_id']]));
$customerArray['rw_user_id'] = $customerRo;
}
db('crm_customer')->where('customer_id', $customer_id)->update($customerArray);
}
if (in_array('crm_contacts',$types)) {
$contactsIds = [];
@ -339,7 +352,7 @@ class Customer extends ApiCommon
if ($resBusiness !== true) {
$errorMessage = $errorMessage ? array_merge($errorMessage,$resBusiness) : $resBusiness;
continue;
}
}
}
}
@ -677,7 +690,7 @@ class Customer extends ApiCommon
$file = request()->file('file');
// $res = $excelModel->importExcel($file, $param, $this);
$res = $excelModel->batchImportData($file, $param, $this);
return resultArray(['data' => '导入成功']);
return resultArray(['data' => $excelModel->getError()]);
}
/**

@ -315,6 +315,8 @@ class Invoice extends ApiCommon
*/
public function delete(InvoiceLogic $invoiceLogic)
{
$actionRecordModel = new \app\admin\model\ActionRecord();
$fileModel = new \app\admin\model\File();
$idArray = $this->param['id'];
$userinfo = $this->userInfo['id'];
@ -326,7 +328,7 @@ class Invoice extends ApiCommon
if (!isSuperAdministrators($userinfo['id'])) {
$list = $invoiceLogic->getExamineStatus($idString, true);
foreach ($list AS $key => $value) {
if (!in_array($value['check_status'], ['3', '4', '5', '6'])) {
if (!in_array($value['check_status'], [4, 5])) {
$status = false;
break;
}
@ -338,8 +340,9 @@ class Invoice extends ApiCommon
if (!$invoiceLogic->delete($idArray)) return resultArray(['error' => '删除失败!']);
# 删除附件
$fileModel = new \app\admin\model\File();
$fileModel->delRFileByModule('crm_invoice', $idArray);
//删除关联操作记录
$actionRecordModel->delDataById(['types'=>'crm_invoice','action_id'=>$idArray]);
return resultArray(['data' => '删除成功!']);
}

@ -226,7 +226,8 @@ class Leads extends ApiCommon
$data['deal_time'] = time();
$data['create_time'] = time();
$data['update_time'] = time();
$data['next_time'] = $leadsInfo['next_time'] ? date('Y-m-d H:i:s', $leadsInfo['next_time']) : 0;
$data['next_time'] = $leadsInfo['next_time'];
if (empty($data['telephone'])) $data['telephone'] = 0;
# 获取客户的时间
$data['obtain_time'] = time();
//权限判断
@ -404,6 +405,9 @@ class Leads extends ApiCommon
$file = request()->file('file');
// $res = $excelModel->importExcel($file, $param);
$res = $excelModel->batchImportData($file, $param, $this);
if (!$res) {
return resultArray(['error' => $excelModel->getError()]);
}
return resultArray(['data' => $excelModel->getError()]);
}

@ -10,6 +10,7 @@ namespace app\crm\controller;
use app\admin\controller\ApiCommon;
use app\crm\model\Product as ProductModel;
use app\admin\model\File as FileModel;
use app\admin\model\ActionRecord as ActionRecordModel;
use think\Db;
use think\Hook;
use think\Request;
@ -294,6 +295,8 @@ class Product extends ApiCommon
ProductModel::commit();
// 删除关联附件
(new FileModel)->delRFileByModule('crm_product', $delIds);
// 操作记录
(new ActionRecordModel)->delDataById('crm_product', $delIds);
// 添加删除记录
actionLog($delIds, '', '', '');
return resultArray(['data' => '删除成功']);

@ -19,42 +19,79 @@ use think\Db;
class Receivables extends ApiCommon
{
use AutoNumberTrait;
/**
* 用于判断权限
* @permission 无限制
* @allow 登录用户可访问
* @other 其他根据系统设置
**/
**/
public function _initialize()
{
$action = [
'permission'=>[''],
'allow'=>['check','revokecheck','system','count']
'permission' => [''],
'allow' => ['check', 'revokecheck', 'system', 'count']
];
Hook::listen('check_auth',$action);
Hook::listen('check_auth', $action);
$request = Request::instance();
$a = strtolower($request->action());
$a = strtolower($request->action());
if (!in_array($a, $action['permission'])) {
parent::_initialize();
}
}
}
/**
* 回款列表
* @return
* @author Michael_xu
* @return
*/
public function index()
{
$receivablesModel = model('Receivables');
$param = $this->param;
$userInfo = $this->userInfo;
$param['user_id'] = $userInfo['id'];
$data = $receivablesModel->getDataList($param);
$param['user_id'] = $userInfo['id'];
$data = $receivablesModel->getDataList($param);
return resultArray(['data' => $data]);
}
/**
* 导出
* @param
* @return
* @author guogaobo
*/
public function excelExport()
{
$param = $this->param;
$userInfo = $this->userInfo;
$param['user_id'] = $userInfo['id'];
if ($param['receivables_id']) {
$param['receivables_id'] = ['condition' => 'in', 'value' => $param['receivables_id'], 'form_type' => 'text', 'name' => ''];
$param['is_excel'] = 1;
}
$excelModel = new \app\admin\model\Excel();
// 导出的字段列表
$fieldModel = new \app\admin\model\Field();
$field_list = $fieldModel->getIndexFieldConfig('crm_receivables', $userInfo['id']);
// 文件名
$file_name = '5kcrm_receivables_' . date('Ymd');
$model = model('Receivables');
$temp_file = $param['temp_file'];
unset($param['temp_file']);
$page = $param['page'] ?: 1;
unset($param['page']);
unset($param['export_queue_index']);
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, 'Receivables');
return $data;
});
}
/**
* 添加回款
*
@ -69,7 +106,7 @@ class Receivables extends ApiCommon
$param['owner_user_id'] = $userInfo['id'];
$examineStatus = $param['examineStatus']; // 审批是否停用
unset($param['examineStatus']);
# 自动设置回款编号
$numberInfo = [];
if (empty($param['number'])) {
@ -80,39 +117,39 @@ class Receivables extends ApiCommon
if ($param['is_draft'] || (!empty($param['check_status']) && $param['check_status'] == 5)) {
//保存为草稿
$param['check_status'] = 5; //草稿(未提交)
$param['check_user_id'] = $param['check_user_id'] ? ','.$param['check_user_id'].',' : '';
} else {
if (($examineStatus != false && $examineStatus != 'false') || $examineStatus == 1) {
//审核判断(是否有符合条件的审批流)
$examineFlowModel = new \app\admin\model\ExamineFlow();
if (!$examineFlowModel->checkExamine($param['owner_user_id'], 'crm_receivables')) {
return resultArray(['error' => '暂无审批人,无法创建']);
}
//添加审批相关信息
$examineFlowData = $examineFlowModel->getFlowByTypes($param['owner_user_id'], 'crm_receivables');
if (!$examineFlowData) {
return resultArray(['error' => '无可用审批流,请联系管理员']);
}
$param['flow_id'] = $examineFlowData['flow_id'];
//获取审批人信息
if ($examineFlowData['config'] == 1) {
//固定审批流
$nextStepData = $examineStepModel->nextStepUser($userInfo['id'], $examineFlowData['flow_id'], 'crm_receivables', 0, 0, 0);
$next_user_ids = arrayToString($nextStepData['next_user_ids']) ? : '';
$check_user_id = $next_user_ids ? : [];
$param['order_id'] = 1;
} else {
$check_user_id = $param['check_user_id'] ? ','.$param['check_user_id'].',' : '';
}
if (!$check_user_id) {
return resultArray(['error' => '无可用审批人,请联系管理员']);
}
$param['check_user_id'] = is_array($check_user_id) ? ','.implode(',',$check_user_id).',' : $check_user_id;
$param['check_user_id'] = $param['check_user_id'] ? ',' . $param['check_user_id'] . ',' : '';
}
if (($examineStatus != false && $examineStatus != 'false') || $examineStatus == 1) {
//审核判断(是否有符合条件的审批流)
$examineFlowModel = new \app\admin\model\ExamineFlow();
if (!$examineFlowModel->checkExamine($param['owner_user_id'], 'crm_receivables')) {
return resultArray(['error' => '暂无审批人,无法创建']);
}
//添加审批相关信息
$examineFlowData = $examineFlowModel->getFlowByTypes($param['owner_user_id'], 'crm_receivables');
if (!$examineFlowData) {
return resultArray(['error' => '无可用审批流,请联系管理员']);
}
$param['flow_id'] = $examineFlowData['flow_id'];
//获取审批人信息
if ($examineFlowData['config'] == 1) {
//固定审批流
$nextStepData = $examineStepModel->nextStepUser($userInfo['id'], $examineFlowData['flow_id'], 'crm_receivables', 0, 0, 0);
$next_user_ids = arrayToString($nextStepData['next_user_ids']) ?: '';
$check_user_id = $next_user_ids ?: [];
$param['order_id'] = 1;
} else {
# 审批流停用,将状态改为审核通过
$param['check_status'] = 2;
$check_user_id = $param['check_user_id'] ? ',' . $param['check_user_id'] . ',' : '';
}
if (!$check_user_id) {
return resultArray(['error' => '无可用审批人,请联系管理员']);
}
$param['check_user_id'] = is_array($check_user_id) ? ',' . implode(',', $check_user_id) . ',' : $check_user_id;
} else {
# 审批流停用,将状态改为审核通过
$param['check_status'] = 2;
}
$res = $receivablesModel->createData($param);
if ($res) {
//回款计划关联
@ -121,18 +158,18 @@ class Receivables extends ApiCommon
}
# 更新crm_number_sequence表中的last_date、create_time字段
if (!empty($numberInfo['data'])) (new NumberSequence())->batchUpdate($numberInfo['data']);
return resultArray(['data' => '添加成功']);
} else {
return resultArray(['error' => $receivablesModel->getError()]);
}
}
/**
* 回款详情
* @param
* @return
* @author Michael_xu
* @param
* @return
*/
public function read()
{
@ -140,27 +177,27 @@ class Receivables extends ApiCommon
$userModel = new \app\admin\model\User();
$param = $this->param;
$data = $receivablesModel->getDataById($param['id']);
//判断权限
$auth_user_ids = $userModel->getUserByPer('crm', 'receivables', 'read');
if (!in_array($data['owner_user_id'],$auth_user_ids)) {
if (!in_array($data['owner_user_id'], $auth_user_ids)) {
$authData['dataAuth'] = 0;
return resultArray(['data' => $authData]);
}
}
if (!$data) {
return resultArray(['error' => $receivablesModel->getError()]);
}
return resultArray(['data' => $data]);
}
/**
* 编辑回款
* @param
* @return
* @author Michael_xu
* @param
* @return
*/
public function update()
{
{
$receivablesModel = model('Receivables');
$userModel = new \app\admin\model\User();
$param = $this->param;
@ -171,11 +208,11 @@ class Receivables extends ApiCommon
//判断权限
$dataInfo = $receivablesModel->getDataById($param['id']);
$auth_user_ids = $userModel->getUserByPer('crm', 'receivables', 'update');
if (!in_array($dataInfo['owner_user_id'],$auth_user_ids)) {
if (!in_array($dataInfo['owner_user_id'], $auth_user_ids)) {
header('Content-Type:application/json; charset=utf-8');
exit(json_encode(['code'=>102,'error'=>'无权操作']));
exit(json_encode(['code' => 102, 'error' => '无权操作']));
}
# 自动设置回款编号
$numberInfo = [];
if (empty($param['number'])) {
@ -183,22 +220,22 @@ class Receivables extends ApiCommon
if (empty($numberInfo['number'])) return resultArray(['error' => '请填写回款编号!']);
$param['number'] = $numberInfo['number'];
}
//已进行审批,不能编辑
if (!in_array($dataInfo['check_status'], ['3', '4', '5', '6'])) {
return resultArray(['error' => '当前状态为审批中或已审批通过,不可编辑']);
}
if ($param['is_draft'] || (!empty($param['check_status']) && $param['check_status'] == 5)) {
//保存为草稿
$param['check_status'] = 5; //草稿(未提交)
$param['check_user_id'] = $param['check_user_id'] ? ','.$param['check_user_id'].',' : '';
$param['check_user_id'] = $param['check_user_id'] ? ',' . $param['check_user_id'] . ',' : '';
} else {
if (($examineStatus != false && $examineStatus != 'false') || $examineStatus == 1) {
if ($param['is_draft']) {
//保存为草稿
$param['check_status'] = 5;
$param['check_user_id'] = $param['check_user_id'] ? ','.$param['check_user_id'].',' : '';
$param['check_user_id'] = $param['check_user_id'] ? ',' . $param['check_user_id'] . ',' : '';
} else {
//将回款审批状态至为待审核,提交后重新进行审批
//审核判断(是否有符合条件的审批流)
@ -217,47 +254,50 @@ class Receivables extends ApiCommon
if ($examineFlowData['config'] == 1) {
//固定审批流
$nextStepData = $examineStepModel->nextStepUser($dataInfo['owner_user_id'], $examineFlowData['flow_id'], 'crm_receivables', 0, 0, 0);
$next_user_ids = arrayToString($nextStepData['next_user_ids']) ? : '';
$check_user_id = $next_user_ids ? : [];
$next_user_ids = arrayToString($nextStepData['next_user_ids']) ?: '';
$check_user_id = $next_user_ids ?: [];
$param['order_id'] = 1;
} else {
$check_user_id = $param['check_user_id'] ? ','.$param['check_user_id'].',' : '';
$check_user_id = $param['check_user_id'] ? ',' . $param['check_user_id'] . ',' : '';
}
if (!$check_user_id) {
return resultArray(['error' => '无可用审批人,请联系管理员']);
}
$param['check_user_id'] = is_array($check_user_id) ? ','.implode(',',$check_user_id).',' : $check_user_id;
$param['check_user_id'] = is_array($check_user_id) ? ',' . implode(',', $check_user_id) . ',' : $check_user_id;
$param['check_status'] = 0;
$param['flow_user_id'] = '';
}
}
}
$res = $receivablesModel->updateDataById($param, $param['id']);
if ($res) {
//将审批记录至为无效
$examineRecordModel = new \app\admin\model\ExamineRecord();
$examineRecordModel->setEnd(['types' => 'crm_receivables','types_id' => $param['id']]);
$examineRecordModel->setEnd(['types' => 'crm_receivables', 'types_id' => $param['id']]);
# 更新crm_number_sequence表中的last_date、create_time字段
if (!empty($numberInfo['data'])) (new NumberSequence())->batchUpdate($numberInfo['data']);
return resultArray(['data' => '编辑成功']);
} else {
return resultArray(['error' => $receivablesModel->getError()]);
}
}
}
/**
* 删除回款
* @param
* @return
* @author Michael_xu
* @param
* @return
*/
public function delete()
{
$actionRecordModel = new \app\admin\model\ActionRecord();
$fileModel = new \app\admin\model\File();
$recordModel = new \app\admin\model\Record();
$receivablesModel = model('Receivables');
$param = $this->param;
$userInfo = $this->userInfo;
$userInfo = $this->userInfo;
if (!is_array($param['id'])) {
$receivables_id = [$param['id']];
} else {
@ -265,61 +305,68 @@ class Receivables extends ApiCommon
}
$delIds = [];
$errorMessage = [];
//数据权限判断
$userModel = new \app\admin\model\User();
$auth_user_ids = $userModel->getUserByPer('crm', 'receivables', 'delete');
$adminTypes = adminGroupTypes($userInfo['id']);
foreach ($receivables_id as $k=>$v) {
foreach ($receivables_id as $k => $v) {
$isDel = true;
//数据详情
$data = $receivablesModel->getDataById($v);
if (!$data) {
$isDel = false;
$errorMessage[] = 'id为'.$v.'的回款删除失败,错误原因:'.$receivablesModel->getError();
$errorMessage[] = 'id为' . $v . '的回款删除失败,错误原因:' . $receivablesModel->getError();
continue;
}
if (!in_array($data['owner_user_id'],$auth_user_ids)) {
if (!in_array($data['owner_user_id'], $auth_user_ids)) {
$isDel = false;
$errorMessage[] = '名称为'.$data['number'].'的回款删除失败,错误原因:无权操作';
$errorMessage[] = '名称为' . $data['number'] . '的回款删除失败,错误原因:无权操作';
continue;
}
if (!in_array($data['check_status'],['0','4','5']) && !in_array(1,$adminTypes)) {
if (!in_array($data['check_status'], [4, 5]) && !in_array(1, $adminTypes)) {
$isDel = false;
$errorMessage[] = '名称为'.$data['number'].'的回款删除失败,错误原因:请先撤销审核';
$errorMessage[] = '名称为' . $data['number'] . '的回款删除失败,错误原因:请先撤销审核';
continue;
}
if ($isDel) {
if (db('crm_receivables_plan')->where('receivables_id', $v)->value('plan_id')) {
$isDel = false;
$errorMessage[] = '名称为'.$data['number'].'的回款删除失败,错误原因:回款已关联回款计划,不能删除!';
$errorMessage[] = '名称为' . $data['number'] . '的回款删除失败,错误原因:回款已关联回款计划,不能删除!';
continue;
}
}
}
if ($isDel) {
$delIds[] = $v;
}
}
}
if ($delIds) {
$data = $receivablesModel->delDatas($delIds);
if (!$data) {
return resultArray(['error' => $receivablesModel->getError()]);
}
actionLog($delIds,'','','');
}
//删除跟进记录
$recordModel->delDataByTypes(7,$delIds);
# 删除附件
$fileModel->delRFileByModule('crm_receivables', $delIds);
//删除关联操作记录
$actionRecordModel->delDataById(['types' => 'crm_receivables', 'action_id' => $delIds]);
actionLog($delIds, '', '', '');
}
if ($errorMessage) {
return resultArray(['error' => $errorMessage]);
} else {
return resultArray(['data' => '删除成功']);
}
}
}
}
/**
* 回款审核
* @author Michael_xu
* @param
* @param
* @return
*/
* @author Michael_xu
*/
public function check()
{
$param = $this->param;
@ -329,19 +376,19 @@ class Receivables extends ApiCommon
$examineStepModel = new \app\admin\model\ExamineStep();
$examineRecordModel = new \app\admin\model\ExamineRecord();
$examineFlowModel = new \app\admin\model\ExamineFlow();
$receivablesData = [];
$receivablesData['update_time'] = time();
$receivablesData['check_status'] = 1; //0待审核1审核通中2审核通过3审核未通过
//权限判断
if (!$examineStepModel->checkExamine($user_id, 'crm_receivables', $param['id'])) {
return resultArray(['error' => $examineStepModel->getError()]);
return resultArray(['error' => $examineStepModel->getError()]);
};
//审批主体详情
$dataInfo = $receivablesModel->getDataById($param['id']);
$flowInfo = $examineFlowModel->getDataById($dataInfo['flow_id']);
$is_end = 0; // 1审批结束
$status = $param['status'] ? 1 : 0; //1通过0驳回
$checkData = [];
$checkData['check_user_id'] = $user_id;
@ -350,7 +397,7 @@ class Receivables extends ApiCommon
$checkData['check_time'] = time();
$checkData['content'] = $param['content'];
$checkData['flow_id'] = $dataInfo['flow_id'];
$checkData['order_id'] = $dataInfo['order_id'] ? : 1;
$checkData['order_id'] = $dataInfo['order_id'] ?: 1;
$checkData['status'] = $status;
if ($status == 1) {
@ -358,8 +405,8 @@ class Receivables extends ApiCommon
//固定流程
//获取下一审批信息
$nextStepData = $examineStepModel->nextStepUser($dataInfo['owner_user_id'], $dataInfo['flow_id'], 'crm_receivables', $param['id'], $dataInfo['order_id'], $user_id);
$next_user_ids = $nextStepData['next_user_ids'] ? : [];
$receivablesData['order_id'] = $nextStepData['order_id'] ? : '';
$next_user_ids = $nextStepData['next_user_ids'] ?: [];
$receivablesData['order_id'] = $nextStepData['order_id'] ?: '';
if (!$next_user_ids) {
$is_end = 1;
//审批结束
@ -368,21 +415,21 @@ class Receivables extends ApiCommon
} else {
//修改主体相关审批信息
$receivablesData['check_user_id'] = arrayToString($next_user_ids);
}
}
} else {
//自选流程
$is_end = $param['is_end'] ? 1 : '';
$check_user_id = $param['check_user_id'] ? : '';
$check_user_id = $param['check_user_id'] ?: '';
if ($is_end !== 1 && empty($check_user_id)) {
return resultArray(['error' => '请选择下一审批人']);
return resultArray(['error' => '请选择下一审批人']);
}
$receivablesData['check_user_id'] = arrayToString($param['check_user_id']);
}
}
if ($is_end == 1) {
$checkData['check_status'] = !empty($status) ? 2 : 3;
$receivablesData['check_user_id'] = '';
$receivablesData['check_status'] = 2;
}
}
} else {
//审批驳回
$is_end = 1;
@ -391,7 +438,7 @@ class Receivables extends ApiCommon
// $examineRecordModel->setEnd(['types' => 'crm_receivables','types_id' => $param['id']]);
}
//已审批人ID
$receivablesData['flow_user_id'] = stringToArray($dataInfo['flow_user_id']) ? arrayToString(array_merge(stringToArray($dataInfo['flow_user_id']),[$user_id])) : arrayToString([$user_id]);
$receivablesData['flow_user_id'] = stringToArray($dataInfo['flow_user_id']) ? arrayToString(array_merge(stringToArray($dataInfo['flow_user_id']), [$user_id])) : arrayToString([$user_id]);
$resReceivables = db('crm_receivables')->where(['receivables_id' => $param['id']])->update($receivablesData);
if ($resReceivables) {
if ($status) {
@ -416,33 +463,33 @@ class Receivables extends ApiCommon
$dataInfo['owner_user_id']
);
}
//审批记录
$resRecord = $examineRecordModel->createData($checkData);
if ($is_end == 1 && !empty($status)) {
//发送站内信 通过
(new Message())->send(
Message::RECEIVABLES_PASS,
[
'title' => $dataInfo['number'],
'action_id' => $param['id']
],
$dataInfo['owner_user_id']
);
Message::RECEIVABLES_PASS,
[
'title' => $dataInfo['number'],
'action_id' => $param['id']
],
$dataInfo['owner_user_id']
);
}
return resultArray(['data' => '审批成功']);
return resultArray(['data' => '审批成功']);
} else {
return resultArray(['error' => '审批失败,请重试!']);
return resultArray(['error' => '审批失败,请重试!']);
}
}
/**
* 回款撤销审核
* @author Michael_xu
* @param
* @param
* @return
*/
* @author Michael_xu
*/
public function revokeCheck()
{
$param = $this->param;
@ -453,23 +500,23 @@ class Receivables extends ApiCommon
$examineRecordModel = new \app\admin\model\ExamineRecord();
$customerModel = model('Customer');
$userModel = new \app\admin\model\User();
$receivablesData = [];
$receivablesData['update_time'] = time();
$receivablesData['check_status'] = 0; //0待审核1审核通中2审核通过3审核未通过
//审批主体详情
$dataInfo = $receivablesModel->getDataById($param['id']);
$dataInfo = $receivablesModel->getDataById($param['id']);
//权限判断(创建人或负责人或管理员)
if ($dataInfo['check_status'] == 2) {
return resultArray(['error' => '已审批结束,不能撤销']);
}
return resultArray(['error' => '已审批结束,不能撤销']);
}
if ($dataInfo['check_status'] == 4) {
return resultArray(['error' => '无需撤销']);
}
$admin_user_ids = $userModel->getAdminId();
return resultArray(['error' => '无需撤销']);
}
$admin_user_ids = $userModel->getAdminId();
if ($dataInfo['owner_user_id'] !== $user_id && !in_array($user_id, $admin_user_ids)) {
return resultArray(['error' => '没有权限']);
}
}
$is_end = 0; // 1审批结束
$status = 2; //1通过0驳回, 2撤销
@ -492,12 +539,12 @@ class Receivables extends ApiCommon
// $examineRecordModel->setEnd(['types' => 'crm_receivables','types_id' => $param['id']]);
//审批记录
$resRecord = $examineRecordModel->createData($checkData);
return resultArray(['data' => '撤销成功']);
return resultArray(['data' => '撤销成功']);
} else {
return resultArray(['error' => '撤销失败,请重试!']);
return resultArray(['error' => '撤销失败,请重试!']);
}
}
/**
* 转移
*
@ -505,50 +552,50 @@ class Receivables extends ApiCommon
*/
public function transfer()
{
$param = $this->param;
$userInfo = $this->userInfo;
$param = $this->param;
$userInfo = $this->userInfo;
$receivablesModel = model('Receivables');
$userModel = new \app\admin\model\User();
$authIds = $userModel->getUserByPer();
$authIds = $userModel->getUserByPer();
if (empty($param['owner_user_id'])) return resultArray(['error' => '变更负责人不能为空']);
if (empty($param['receivables_id']) || !is_array($param['receivables_id'])) return resultArray(['error' => '请选择需要转移的回款']);
$owner_user_info = $userModel->getUserById($param['owner_user_id']);
$data = [
'owner_user_id' => $param['owner_user_id'],
'update_time' => time(),
'update_time' => time(),
];
$errorMessage = [];
foreach ($param['receivables_id'] as $receivables_id) {
$receivables_info = $receivablesModel->getDataById($receivables_id);
if (!$receivables_info) {
$errorMessage[] = 'id:为《'.$receivables_id.'》的回款转移失败,错误原因:数据不存在;';
$errorMessage[] = 'id:为《' . $receivables_id . '》的回款转移失败,错误原因:数据不存在;';
continue;
}
# 转移至当前负责人的直接跳过
if ($param['owner_user_id'] == $receivables_info['owner_user_id']) continue;
if (!in_array($receivables_info['owner_user_id'], $authIds)) {
$errorMessage[] = $receivables_info['number'].'"转移失败,错误原因:无权限;';
$errorMessage[] = $receivables_info['number'] . '"转移失败,错误原因:无权限;';
continue;
}
if (in_array($receivables_info['check_status'],['0','1'])) {
$errorMessage[] = $receivables_info['number'].'转移失败,错误原因:待审或审批中,无法转移;';
if (in_array($receivables_info['check_status'], ['0', '1'])) {
$errorMessage[] = $receivables_info['number'] . '转移失败,错误原因:待审或审批中,无法转移;';
continue;
}
$res = $receivablesModel->where(['receivables_id' => $receivables_id])->update($data);
if (!$res) {
$errorMessage[] = $receivables_info['number'].'"转移失败,错误原因:数据出错;';
$errorMessage[] = $receivables_info['number'] . '"转移失败,错误原因:数据出错;';
continue;
}
updateActionLog($userInfo['id'], 'crm_receivables', $receivables_id, '', '', '将回款转移给:' . $owner_user_info['realname']);
updateActionLog($userInfo['id'], 'crm_receivables', $receivables_id, '', '', '将回款转移给:' . $owner_user_info['realname']);
}
if (!$errorMessage) {
return resultArray(['data' => '转移成功']);
@ -556,7 +603,7 @@ class Receivables extends ApiCommon
return resultArray(['error' => $errorMessage]);
}
}
/**
* 系统信息
*
@ -568,14 +615,14 @@ class Receivables extends ApiCommon
public function system()
{
if (empty($this->param['id'])) return resultArray(['error' => '参数错误!']);
$receivablesModel = new \app\crm\model\Receivables();
$data = $receivablesModel->getSystemInfo($this->param['id']);
return resultArray(['data' => $data]);
}
/**
* table标签栏数量
*
@ -587,10 +634,10 @@ class Receivables extends ApiCommon
public function count()
{
if (empty($this->param['receivables_id'])) return resultArray(['error' => '参数错误!']);
# 附件
$fileCount = Db::name('crm_receivables_file')->alias('receivables')->join('__ADMIN_FILE__ file', 'file.file_id = receivables.file_id', 'LEFT')->where('receivables_id', $this->param['receivables_id'])->count();
return resultArray(['data' => ['fileCount' => $fileCount]]);
}
}

@ -68,9 +68,8 @@ class Visit extends ApiCommon
if (empty($numberInfo['number'])) return resultArray(['error' => '请填写回访编号!']);
$param['number'] = $numberInfo['number'];
}
$param['owner_user_id'] = $param['visit_user_id'] ? : $userInfo['id'];
$param['owner_user_id'] = $param['owner_user_id'] ? : $userInfo['id'];
$param['create_user_id'] = $userInfo['id'];
$param['visit_user_id'] = $param['visit_user_id'] ? : $userInfo['id'];
$param['update_time'] = time();
$res = $Visit->createData($param);
if ($res) {
@ -119,8 +118,7 @@ class Visit extends ApiCommon
$param = $this->param;
$userInfo = $this->userInfo;
$param['user_id'] = $userInfo['id'];
$param['owner_user_id'] = $param['visit_user_id'] ? : $userInfo['id'];
$param['visit_user_id'] = $param['visit_user_id'] ? : $userInfo['id'];
$param['owner_user_id'] = $param['owner_user_id'] ? : $userInfo['id'];
# 设置回访编号
$numberInfo = [];
if (empty($param['number'])) {

@ -359,8 +359,9 @@ class ActivityLogic
$fileModel = new \app\admin\model\File();
foreach ($dataArray AS $key => $value) {
# 用户信息 todo 有模型文件,时间问题,暂时将查询写在循环中
$realname = Db::name('admin_user')->where('id', $dataArray[$key]['create_user_id'])->value('realname');
$dataArray[$key]['create_user_name'] = $realname;
$realname = Db::name('admin_user')->where('id', $dataArray[$key]['create_user_id'])->find();
$dataArray[$key]['create_user_name'] = $realname['realname'];
$dataArray[$key]['thumb_img'] = $realname['thumb_img'] ? getFullPath($realname['thumb_img']) : '';;
# 附件信息
if ($value['type'] = 1) {
@ -785,7 +786,7 @@ class ActivityLogic
# 审批
if ($activityType == 9) {
$categoryId = Db::name('oa_examine')->where('examine_id', $activityTypeId)->value('category_id');
$activityTypeName = Db::name('oa_examine_category')->where('category_id', $categoryId);
$activityTypeName = Db::name('oa_examine_category')->where('category_id', $categoryId)->value('title');
}
# 日程
if ($activityType == 10) {

@ -12,11 +12,12 @@ use app\admin\controller\ApiCommon;
use app\admin\model\User;
use app\crm\model\Customer;
use think\Db;
use think\Validate;
class CommonLogic
{
public $error = '操作失败!';
/**
* 快捷编辑【线索、客户、联系人、商机、合同、回款、回访、产品】
*
@ -37,56 +38,113 @@ class CommonLogic
* $param['name'] 字段中文名,用作提示
* $param['value] 字段值
*/
$actionId = $param['action_id'];
$types = $param['types'];
$types = $param['types'];
unset($param['action_id']);
unset($param['types']);
# 模型
$model = db($types);
# 主键
$primaryKey = '';
if ($types == 'crm_leads') $primaryKey = 'leads_id';
if ($types == 'crm_customer') $primaryKey = 'customer_id';
if ($types == 'crm_contacts') $primaryKey = 'contacts_id';
if ($types == 'crm_business') $primaryKey = 'business_id';
if ($types == 'crm_contract') $primaryKey = 'contract_id';
if ($types == 'crm_receivables') $primaryKey = 'receivables_id';
if ($types == 'crm_visit') $primaryKey = 'visit_id';
if ($types == 'crm_product') $primaryKey = 'product_id';
// author guogaobo $item模块
$info='';
switch ($types) {
case 'crm_leads' :
$primaryKey = 'leads_id';
$dataModel=new \app\crm\model\Leads();
$info=$dataModel->getDataById($actionId);
break;
case 'crm_customer' :
$primaryKey = 'customer_id';
$info=db('crm_customer')->where('customer_id',$actionId)->find();
break;
case 'crm_contacts' :
$primaryKey = 'contacts_id';
$dataModel=new \app\crm\model\Contacts();
$info=$dataModel->getDataById($actionId);
break;
case 'crm_business' :
$primaryKey = 'business_id';
$dataModel=new \app\crm\model\Business();
$info=$dataModel->getDataById($actionId);
break;
case 'crm_contract' :
$primaryKey = 'contract_id';
$info=db('crm_contract')->where('customer_id',$actionId)->find();
break;
case 'crm_receivables' :
$primaryKey = 'receivables_id';
$info=db('crm_receivables')->where('customer_id',$actionId)->find();
break;
case 'crm_visit' :
$primaryKey = 'visit_id';
$dataModel=new \app\crm\logic\VisitLogic();
$info=$dataModel->getDataById($actionId);
break;
case 'crm_product' :
$primaryKey = 'product_id';
$dataModel=new \app\crm\model\Product();
$info=$dataModel->getDataById($actionId);
break;
}
$apiCommon = new ApiCommon();
$userModel = new User();
if (in_array($types, ['crm_contract', 'crm_receivables'])) {
$checkStatus = $model->where($primaryKey, $actionId)->value('check_status');
if (!in_array($checkStatus, [4, 5, 6])) {
$this->error = '只能编辑状态为撤销、草稿或作废的信息!';
return false;
}
}
# 产品修改验证
if($types == 'crm_product'){
foreach ($param['list'] as $val){
$infoData=db('crm_product')->where(['name'=>$val['name'],'delete_user_id'=>0])->find();
if(!empty($infoData)){
$fieldModel = new \app\admin\model\Field();
$validateArr = $fieldModel->validateField('crm_product'); //获取自定义字段验证规则
$validate = new Validate($validateArr['rule'], $validateArr['message']);
$result = $validate->check($val);
if (!$result) {
$this->error = $validate->getError();
return false;
}
}
}
}
# 客户模块快捷编辑权限验证
if ($types == 'crm_customer') {
$dataInfo = $model->field(['ro_user_id', 'rw_user_id', 'owner_user_id'])->where($primaryKey, $actionId)->find();
$dataInfo = $model->field(['ro_user_id', 'rw_user_id', 'owner_user_id'])->where($primaryKey, $actionId)->find();
$auth_user_ids = $userModel->getUserByPer('crm', 'customer', 'update');
$rwPre = $userModel->rwPre($apiCommon->userInfo['id'], $dataInfo['ro_user_id'], $dataInfo['rw_user_id'], 'update');
$wherePool = (new Customer())->getWhereByPool();
$resPool = db('crm_customer')->alias('customer')->where(['customer_id' => $param['action_id']])->where($wherePool)->find();
if ($resPool || (!in_array($dataInfo['owner_user_id'],$auth_user_ids) && !$rwPre)) {
if ($resPool || (!in_array($dataInfo['owner_user_id'], $auth_user_ids) && !$rwPre)) {
$this->error = '无权操作!';
return false;
}
}
# 商机模块快捷编辑权限验证
if ($types == 'crm_business') {
$dataInfo = $model->field(['ro_user_id', 'rw_user_id', 'owner_user_id'])->where($primaryKey, $actionId)->find();
$dataInfo = $model->field(['ro_user_id', 'rw_user_id', 'owner_user_id'])->where($primaryKey, $actionId)->find();
$auth_user_ids = $userModel->getUserByPer('crm', 'business', 'update');
$rwPre = $userModel->rwPre($apiCommon->userInfo['id'], $dataInfo['ro_user_id'], $dataInfo['rw_user_id'], 'update');
if (!in_array($dataInfo['owner_user_id'],$auth_user_ids) && !$rwPre) {
if (!in_array($dataInfo['owner_user_id'], $auth_user_ids) && !$rwPre) {
$this->error = '无权操作!';
return false;
}
}
# 合同模块快捷编辑权限验证
if ($types == 'crm_contract') {
$dataInfo = $model->field(['ro_user_id', 'rw_user_id', 'owner_user_id'])->where($primaryKey, $actionId)->find();
$dataInfo = $model->field(['ro_user_id', 'rw_user_id', 'owner_user_id'])->where($primaryKey, $actionId)->find();
$auth_user_ids = $userModel->getUserByPer('crm', 'contract', 'update');
$rwPre = $userModel->rwPre($apiCommon->userInfo['id'], $dataInfo['ro_user_id'], $dataInfo['rw_user_id'], 'update');
if (!in_array($dataInfo['owner_user_id'], $auth_user_ids) && !$rwPre) {
@ -95,51 +153,100 @@ class CommonLogic
}
}
foreach ($param AS $key => $value) {
# 查询自定义字段信息
$fieldInfo = Db::name('admin_field')->field(['max_length', 'is_unique', 'is_null', 'name'])
->where('types', $types)->where('field', $key)->find();
# 字符长度
if (!empty($fieldInfo['max_length']) && strlen($value) > $fieldInfo['max_length']) {
$this->error = $fieldInfo['name'] . ' 字符长度不能超过 ' . $fieldInfo['max_length'] . ' 个字符!';
return false;
}
$fieldModel = new \app\admin\model\Field();
# 日期时间类型
$datetimeField = $fieldModel->getFieldByFormType($types, 'datetime');
# 附件类型
$fileField = $fieldModel->getFieldByFormType($types, 'file');
# 多选类型
$checkboxField = $fieldModel->getFieldByFormType($types, 'checkbox');
# 人员类型
$userField = $fieldModel->getFieldByFormType($types, 'user');
# 部门类型
$structureField = $fieldModel->getFieldByFormType($types, 'structure');
foreach ($param['list'] as $key => $value) {
foreach ($value as $k => $v) {
# 查询自定义字段信息
$fieldInfo = Db::name('admin_field')->field(['max_length', 'is_unique', 'is_null', 'name'])
->where('types', $types)->where('field', $k)->find();
# 字符长度
if (!empty($fieldInfo['max_length']) && strlen($v) > $fieldInfo['max_length']) {
$this->error = $fieldInfo['name'] . ' 字符长度不能超过 ' . $fieldInfo['max_length'] . ' 个字符!';
return false;
}
# 必填
if (!empty($fieldInfo['is_null']) && empty($value)) {
$this->error = $fieldInfo['name'] . ' 是必填信息,不能为空!';
return false;
}
# 必填
if (!empty($fieldInfo['is_null']) && empty($v)) {
$this->error = $fieldInfo['name'] . ' 是必填信息,不能为空!';
return false;
}
# 唯一
if (!empty($fieldInfo['is_unique']) && $model->where([$primaryKey => ['neq', $actionId]])->where($key, $value)->value($primaryKey)) {
$this->error = $fieldInfo['name'] . ' 内容重复!';
return false;
# 唯一
if (!empty($fieldInfo['is_unique']) && $model->where([$primaryKey => ['neq', $actionId]])->where($k, $v)->value($primaryKey)) {
$this->error = $fieldInfo['name'] . ' 内容重复!';
return false;
}
}
}
# 编辑参数
$data = [];
$item=[];
if (!empty($param['list'])) {
foreach ($param['list'] AS $key => $value) {
foreach ($value AS $k => $v) {
# 处理下次联系时间格式
if ($k == 'next_time') {
foreach ($param['list'] as $key => $value) {
foreach ($value as $k => $v) {
if ($k == 'next_time' || in_array($k, $datetimeField)) {
# 处理下次联系时间格式、datetime类型数据
$data[$k] = !empty($v) ? strtotime($v) : '';
} else {
$data[$k] = $v;
}
# 处理产品类别
if ($types == 'crm_product' && $k == 'category_id') {
} elseif ($types == 'crm_product' && $k == 'category_id') {
# 处理产品类别
$categorys = explode(',', $v);
$data[$k] = $categorys[count($categorys) - 1];
$data[$k] = $categorys[count($categorys) - 1];
} elseif (in_array($k, $fileField)) {
# 处理附件类型数据
$fileArray = [];
foreach ($v AS $kk => $vv) {
if (!empty($vv['file_id'])) $fileArray[] = $vv['file_id'];
}
if (!empty($fileArray)) $data[$k] = arrayToString($fileArray);
} elseif (in_array($k, $checkboxField)) {
# 处理多选类型数据
$data[$k] = arrayToString($v);
} elseif (in_array($k, $userField)) {
# 处理人员类型数据
$userArray = [];
foreach ($v AS $kk => $vv) {
if (!empty($vv['id'])) $userArray[] = $vv['id'];
}
$data[$k] = !empty($userArray) ? arrayToString($userArray) : '';
} elseif (in_array($k, $structureField)) {
# 处理部门类型数据
$structureArray = [];
foreach ($v AS $kk => $vv) {
if (!empty($vv['id'])) $structureArray[] = $vv['id'];
}
$data[$k] = !empty($structureArray) ? arrayToString($structureArray) : '';
} elseif ($types == 'crm_visit' && $k == 'contract_id') {
# 处理回访提交过来的合同编号
if (!empty($v[0]['contract_id'])) $data[$k] = $v[0]['contract_id'];
}else {
$data[$k] = $v;
}
}
$item=$value;
}
$data[$primaryKey] = $actionId;
$data[$primaryKey] = $actionId;
$data['update_time'] = time();
}
return $model->update($data);
$res = $model->update($data);
//详细信息修改新增操作记录
if ($res) {
//修改记录
$user_id = $apiCommon->userInfo;
updateActionLog($user_id['id'], $types, $actionId, $info, $item);
}
return $res;
}
}

@ -23,6 +23,10 @@ class IndexLogic extends Common
'12' => 'december',
];
/**
* @param $param
* @return array
*/
public function index($param)
{
$adminModel = new \app\admin\model\Admin();
@ -69,17 +73,16 @@ class IndexLogic extends Common
$contract_auth_user_ids = $userModel->getUserByPer('crm', 'contract', 'index');
$receivables_auth_user_ids = $userModel->getUserByPer('crm', 'receivables', 'index');
$record_auth_user_ids = $userModel->getUserByPer('crm', 'activity', 'index');
$resCount = queryCache(
$this->getCountSql([
'start_time' => $between_time[0],
'end_time' => $between_time[1],
'customer_auth_user_ids' => array_intersect($userIds, $customer_auth_user_ids),
'contacts_auth_user_ids' => array_intersect($userIds, $contacts_auth_user_ids),
'business_auth_user_ids' => array_intersect($userIds, $business_auth_user_ids),
'contract_auth_user_ids' => array_intersect($userIds, $contract_auth_user_ids),
'receivables_auth_user_ids' => array_intersect($userIds, $receivables_auth_user_ids),
'record_auth_user_ids' => array_intersect($userIds, $record_auth_user_ids),
'customer_auth_user_ids' => array_intersect($userIds, $customer_auth_user_ids) ? :[-1],
'contacts_auth_user_ids' => array_intersect($userIds, $contacts_auth_user_ids) ? :[-1],
'business_auth_user_ids' => array_intersect($userIds, $business_auth_user_ids) ? :[-1],
'contract_auth_user_ids' => array_intersect($userIds, $contract_auth_user_ids) ? :[-1],
'receivables_auth_user_ids' => array_intersect($userIds, $receivables_auth_user_ids) ? :[-1],
'record_auth_user_ids' => array_intersect($userIds, $record_auth_user_ids) ? :[-1],
])
);

@ -54,12 +54,7 @@ class VisitLogic extends Common
//高级筛选
$map = where_arr($map, 'crm', 'visit', 'index');
$order = ['visit.update_time desc'];
if (isset($map['visit.visit_time'])) {
$map['visit.visit_time'][1][0] = date('Y-m-d', $map['visit.visit_time'][1][0]);
$map['visit.visit_time'][1][1] = date('Y-m-d', $map['visit.visit_time'][1][1]);
}
$authMap = [];
if (!$partMap) {
$a = 'index';
@ -68,20 +63,20 @@ class VisitLogic extends Common
if (!is_array($map['visit.owner_user_id'][1])) {
$map['visit.owner_user_id'][1] = [$map['visit.owner_user_id'][1]];
}
if ($map['visit.owner_user_id'][0] == 'neq') {
if (in_array($map['visit.owner_user_id'][0], ['neq', 'notin'])) {
$auth_user_ids = array_diff($auth_user_ids, $map['visit.owner_user_id'][1]) ?: []; //取差集
} else {
$auth_user_ids = array_intersect($map['visit.owner_user_id'][1], $auth_user_ids) ?: []; //取交集
}
unset($map['visit.owner_user_id']);
$auth_user_ids = array_merge(array_unique(array_filter($auth_user_ids))) ?: ['-1'];
$authMap['visit.owner_user_id'] = array('in', $auth_user_ids);
unset($map['visit.owner_user_id']);
} else {
$authMapData = [];
$authMapData['auth_user_ids'] = $auth_user_ids;
$authMapData['user_id'] = $user_id;
$authMap = function ($query) use ($authMapData) {
$query->where('visit.owner_user_id', array('in', $authMapData['auth_user_ids']))
$query->where('visit.owner_user_id', ['in', $authMapData['auth_user_ids']])
->whereOr('visit.ro_user_id', array('like', '%,' . $authMapData['user_id'] . ',%'))
->whereOr('visit.rw_user_id', array('like', '%,' . $authMapData['user_id'] . ',%'));
};
@ -96,6 +91,7 @@ class VisitLogic extends Common
//人员类型
$userField = $fieldModel->getFieldByFormType('crm_visit', 'user'); //人员类型
$structureField = $fieldModel->getFieldByFormType('crm_visit', 'structure'); //部门类型
$datetimeField = $fieldModel->getFieldByFormType('crm_visit', 'datetime'); //日期时间类型
//排序
if ($order_type && $order_field) {
@ -118,12 +114,11 @@ class VisitLogic extends Common
->where($partMap)
->where($authMap)
->limit($request['offset'], $request['length'])
->field(array_merge($indexField, [
'contract.num' => 'contract_number',
'customer.name' => 'customer_name',
'contacts.name' => 'contacts_name',
]))
->field('visit.*,
contract.num as contract_number,
customer.name as customer_name,
contacts.name as contacts_name'
)
->orderRaw($order)
->group('visit.visit_id')
->select();
@ -140,10 +135,15 @@ class VisitLogic 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'] : '';
foreach ($userField as $key => $val) {
$list[$k][$val . '_info'] = isset($v[$val]) ? $userModel->getListByStr($v[$val]) : [];
$usernameField = !empty($v[$val]) ? db('admin_user')->whereIn('id', stringToArray($v[$val]))->column('realname') : [];
$list[$k][$val] = implode($usernameField, ',');
}
foreach ($structureField as $key => $val) {
$list[$k][$val . '_info'] = isset($v[$val]) ? $structureModel->getDataByStr($v[$val]) : [];
$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;
}
$list[$k]['contract_id_info']['contract_id'] = $v['contract_id'];
$list[$k]['contract_id_info']['name'] = $v['contract_name'];
@ -161,7 +161,7 @@ class VisitLogic extends Common
$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'], $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;
@ -198,6 +198,11 @@ class VisitLogic extends Common
$dataInfo['contacts_id_info'] = db('crm_contacts')->where(['contacts_id' => $dataInfo['contacts_id']])->field('contacts_id,name')->find();
$dataInfo['contacts_name'] = !empty($dataInfo['contacts_id_info']['name']) ? $dataInfo['contacts_id_info']['name'] : '';
# 处理日期格式
$fieldModel = new \app\admin\model\Field();
$datetimeField = $fieldModel->getFieldByFormType('crm_visit', '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;
return $dataInfo;
@ -330,7 +335,7 @@ class VisitLogic extends Common
return resultArray(['error' => $this->getError()]);
}
//删除关联附件
$fileModel->delRFileByModule('crm_business', $delIds);
$fileModel->delRFileByModule('crm_visit', $delIds);
//删除关联操作记录
$actionRecordModel->delDataById(['types' => 'crm_visit', 'visit_id' => $delIds]);
actionLog($delIds, '', '', '');

File diff suppressed because it is too large Load Diff

@ -85,7 +85,7 @@ class Contacts extends Common
if (!is_array($map['contacts.owner_user_id'][1])) {
$map['contacts.owner_user_id'][1] = [$map['contacts.owner_user_id'][1]];
}
if ($map['contacts.owner_user_id'][0] == 'neq') {
if (in_array($map['contacts.owner_user_id'][0], ['neq', 'notin'])) {
$auth_user_ids = array_diff($auth_user_ids, $map['contacts.owner_user_id'][1]) ? : []; //取差集
} else {
$auth_user_ids = array_intersect($map['contacts.owner_user_id'][1], $auth_user_ids) ? : []; //取交集
@ -107,7 +107,8 @@ class Contacts extends Common
//列表展示字段
$indexField = $fieldModel->getIndexField('crm_contacts', $user_id, 1) ? : array('name');
$userField = $fieldModel->getFieldByFormType('crm_contacts', 'user'); //人员类型
$structureField = $fieldModel->getFieldByFormType('crm_contacts', 'structure'); //部门类型
$structureField = $fieldModel->getFieldByFormType('crm_contacts', 'structure'); //部门类型
$datetimeField = $fieldModel->getFieldByFormType('crm_contacts', 'datetime'); //日期时间类型
//排序
if ($order_type && $order_field) {
@ -130,7 +131,7 @@ class Contacts extends Common
->where($searchMap)
->where($authMap)
->where($customerWhere)
->count('contacts_id');
->count('contacts_id');
if ($getCount == 1) {
$data['dataCount'] = $dataCount ? : 0;
return $data;
@ -144,7 +145,6 @@ class Contacts extends Common
->where($customerWhere)
->limit($request['offset'], $request['length'])
->field('contacts.*,customer.name as customer_name')
->field(implode(',',$indexField).',customer.name as customer_name')
->orderRaw($order)
->select();
@ -154,11 +154,16 @@ class Contacts extends Common
$list[$k]['customer_id_info']['customer_id'] = $v['customer_id'] ? : '';
$list[$k]['customer_id_info']['name'] = $v['customer_name'] ? : '';
foreach ($userField as $key => $val) {
$list[$k][$val.'_info'] = isset($v[$val]) ? $userModel->getListByStr($v[$val]) : [];
$usernameField = !empty($v[$val]) ? db('admin_user')->whereIn('id', stringToArray($v[$val]))->column('realname') : [];
$list[$k][$val] = implode($usernameField, ',');
}
foreach ($structureField as $key => $val) {
$list[$k][$val.'_info'] = isset($v[$val]) ? $structureModel->getDataByStr($v[$val]) : [];
}
$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;
}
//权限
$permission = [];
@ -173,9 +178,6 @@ class Contacts extends Common
$permission['is_delete'] = $is_delete;
$list[$k]['permission'] = $permission;
# 下次联系时间
$list[$k]['next_time'] = !empty($v['next_time']) ? date('Y-m-d H:i:s', $v['next_time']) : null;
# 关注
$starWhere = ['user_id' => $user_id, 'target_id' => $v['contacts_id'], 'type' => 'crm_contacts'];
$star = Db::name('crm_star')->where($starWhere)->value('star_id');
@ -227,9 +229,6 @@ class Contacts extends Common
$param['primary'] = 1;
}
# 处理下次联系时间
if (!empty($param['next_time'])) $param['next_time'] = strtotime($param['next_time']);
//处理部门、员工、附件、多选类型字段
$arrFieldAtt = $fieldModel->getArrayField('crm_contacts');
foreach ($arrFieldAtt as $k=>$v) {
@ -249,7 +248,7 @@ class Contacts extends Common
'create_user_id' => $param['create_user_id'],
'update_time' => time(),
'create_time' => time(),
'customer_ids' => $param['customer_id']
'customer_ids' => $param['customer_id']
]);
# 处理商机首要联系人
@ -319,9 +318,6 @@ class Contacts extends Common
return false;
}
# 处理下次联系时间
if (!empty($param['next_time'])) $param['next_time'] = strtotime($param['next_time']);
//处理部门、员工、附件、多选类型字段
$arrFieldAtt = $fieldModel->getArrayField('crm_contacts');
foreach ($arrFieldAtt as $k=>$v) {
@ -382,7 +378,11 @@ class Contacts extends Common
# 处理决策人显示问题
$dataInfo['decision'] = !empty($dataInfo['decision']) && $dataInfo['decision'] == '是' ? '是' : '';
# 处理时间格式
$dataInfo['next_time'] = !empty($dataInfo['next_time']) ? date('Y-m-d H:i:s', $dataInfo['next_time']) : null;
$fieldModel = new \app\admin\model\Field();
$datetimeField = $fieldModel->getFieldByFormType('crm_contacts', '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;
$dataInfo['last_time'] = !empty($dataInfo['last_time']) ? date('Y-m-d H:i:s', $dataInfo['last_time']) : null;

@ -99,7 +99,7 @@ class Contract extends Common
if (!is_array($map['contract.owner_user_id'][1])) {
$map['contract.owner_user_id'][1] = [$map['contract.owner_user_id'][1]];
}
if ($map['contract.owner_user_id'][0] == 'neq') {
if (in_array($map['contract.owner_user_id'][0], ['neq', 'notin'])) {
$auth_user_ids = array_diff($auth_user_ids, $map['contract.owner_user_id'][1]) ? : []; //取差集
} else {
$auth_user_ids = array_intersect($map['contract.owner_user_id'][1], $auth_user_ids) ? : []; //取交集
@ -127,6 +127,7 @@ class Contract extends Common
//人员类型
$userField = $fieldModel->getFieldByFormType('crm_contract', 'user');
$structureField = $fieldModel->getFieldByFormType('crm_contract', 'structure'); //部门类型
$datetimeField = $fieldModel->getFieldByFormType('crm_contract', 'datetime'); //日期时间类型
//排序
if ($order_type && $order_field) {
$order = $fieldModel->getOrderByFormtype('crm_contract','contract',$order_field,$order_type);
@ -186,11 +187,16 @@ class Contract 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'] : '';
foreach ($userField as $key => $val) {
$list[$k][$val.'_info'] = isset($v[$val]) ? $userModel->getListByStr($v[$val]) : [];
$usernameField = !empty($v[$val]) ? db('admin_user')->whereIn('id', stringToArray($v[$val]))->column('realname') : [];
$list[$k][$val] = implode($usernameField, ',');
}
foreach ($structureField as $key => $val) {
$list[$k][$val.'_info'] = isset($v[$val]) ? $structureModel->getDataByStr($v[$val]) : [];
$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;
}
$list[$k]['business_id_info']['business_id'] = $v['business_id'];
$list[$k]['business_id_info']['name'] = $v['business_name'];
$list[$k]['customer_id_info']['customer_id'] = $v['customer_id'];
@ -226,6 +232,9 @@ class Contract 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;
$list[$k]['order_date'] = ($v['order_date']!='0000-00-00') ? $v['order_date'] : null;
$list[$k]['start_time'] = ($v['start_time']!='0000-00-00') ? $v['start_time'] : null;
$list[$k]['end_time'] = ($v['end_time']!='0000-00-00') ? $v['end_time'] : null;
# 签约人姓名
$orderNames = Db::name('admin_user')->whereIn('id', trim($v['order_user_id'], ','))->column('realname');
$list[$k]['order_user_name'] = implode(',', $orderNames);
@ -488,6 +497,11 @@ class Contract extends Common
$orderNames = Db::name('admin_user')->whereIn('id', trim($dataInfo['order_user_id'], ','))->column('realname');
$dataInfo['order_user_name'] = implode(',', $orderNames);
# 处理时间根式
$fieldModel = new \app\admin\model\Field();
$datetimeField = $fieldModel->getFieldByFormType('crm_contract', 'datetime'); //日期时间类型
foreach ($datetimeField as $key => $val) {
$dataInfo[$val] = !empty($dataInfo[$val]) ? date('Y-m-d H:i:s', $dataInfo[$val]) : null;
}
$dataInfo['next_time'] = !empty($dataInfo['next_time']) ? date('Y-m-d H:i:s', $dataInfo['next_time']) : 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;
@ -510,10 +524,10 @@ class Contract extends Common
foreach ($ids as $id) {
$contractInfo = [];
$contractInfo = db('crm_contract')->where(['contract_id' => $id])->find();
if (in_array($contractInfo['check_status'],['0','1'])) {
$errorMessage[] = '合同:'.$contractInfo['name'].'"转移失败,错误原因:审批中,无法转移;';
continue;
}
// if (in_array($contractInfo['check_status'],['0','1'])) {
// $errorMessage[] = '合同:'.$contractInfo['name'].'"转移失败,错误原因:审批中,无法转移;';
// continue;
// }
//团队成员
$teamData = [];
$teamData['type'] = $type; //权限 1只读2读写
@ -529,7 +543,19 @@ class Contract extends Common
if (!db('crm_contract')->where(['contract_id' => $id])->update($data)) {
$errorMessage[] = '合同:'.$contractInfo['name'].'"转移失败,错误原因:数据出错;';
continue;
}
} else {
$contractArray = [];
$teamContract = db('crm_contract')->field(['owner_user_id', 'ro_user_id', 'rw_user_id'])->where('contract_id', $id)->find();
if (!empty($teamContract['ro_user_id'])) {
$contractRo = arrayToString(array_diff(stringToArray($teamContract['ro_user_id']), [$teamContract['owner_user_id']]));
$contractArray['ro_user_id'] = $contractRo;
}
if (!empty($teamContract['rw_user_id'])) {
$contractRo = arrayToString(array_diff(stringToArray($teamContract['rw_user_id']), [$teamContract['owner_user_id']]));
$contractArray['rw_user_id'] = $contractRo;
}
db('crm_contract')->where('contract_id', $id)->update($contractArray);
}
}
if ($errorMessage) {
return $errorMessage;

@ -127,7 +127,7 @@ class Customer extends Common
if (!is_array($map['customer.owner_user_id'][1])) {
$map['customer.owner_user_id'][1] = [$map['customer.owner_user_id'][1]];
}
if ($map['customer.owner_user_id'][0] == 'neq') {
if (in_array($map['customer.owner_user_id'][0], ['neq', 'notin'])) {
$auth_user_ids = array_diff($auth_user_ids, $map['customer.owner_user_id'][1]) ? : []; //取差集
} else {
$auth_user_ids = array_intersect($map['customer.owner_user_id'][1], $auth_user_ids) ? : []; //取交集
@ -169,6 +169,7 @@ class Customer extends Common
$indexField = $fieldModel->getIndexField('crm_customer', $user_id, 1) ? : array('name');
$userField = $fieldModel->getFieldByFormType('crm_customer', 'user'); //人员类型
$structureField = $fieldModel->getFieldByFormType('crm_customer', 'structure'); //部门类型
$datetimeField = $fieldModel->getFieldByFormType('crm_customer', 'datetime'); //日期时间类型
//排序
if ($order_type && $order_field) {
$order = $fieldModel->getOrderByFormtype('crm_customer','customer',$order_field,$order_type);
@ -190,8 +191,7 @@ class Customer extends Common
->where($poolMap)
->where($otherMap)
->limit($request['offset'], $request['length'])
->field(implode(',',$indexField))
->order($order_t) /*置顶*/
->field('customer.*')
->orderRaw($order)
->select();
//保护规则
@ -228,14 +228,19 @@ class Customer extends Common
$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, $field_list)) {
$list[$k][$val.'_info'] = isset($v[$val]) ? $userModel->getListByStr($v[$val]) : [];
$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, $field_list)) {
$list[$k][$val.'_info'] = isset($v[$val]) ? $structureModel->getDataByStr($v[$val]) : [];
$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;
}
//商机数
$list[$k]['business_count'] = $business_count[$v['customer_id']]['count'] ?: 0;
//距进入公海天数
@ -268,9 +273,6 @@ class Customer extends Common
$permission['is_delete'] = $is_delete;
$list[$k]['permission'] = $permission;
# 下次联系时间
$list[$k]['next_time'] = !empty($v['next_time']) ? date('Y-m-d H:i:s', $v['next_time']) : null;
# 关注
$starWhere = ['user_id' => $user_id, 'target_id' => $v['customer_id'], 'type' => 'crm_customer'];
$star = Db::name('crm_star')->where($starWhere)->value('star_id');
@ -327,9 +329,6 @@ class Customer extends Common
return false;
}
unset($param['customer_id']);
# 处理下次联系时间
if (!empty($param['next_time'])) $param['next_time'] = strtotime($param['next_time']);
//处理部门、员工、附件、多选类型字段
$arrFieldAtt = $fieldModel->getArrayField('crm_customer');
@ -377,71 +376,68 @@ class Customer extends Common
* @author Michael_xu
* @param
* @return
*/
public function updateDataById($param, $customer_id = '')
{
$user_id = $param['user_id'];
$dataInfo = $this->get($customer_id);
if (!$dataInfo) {
$this->error = '数据不存在或已删除';
return false;
}
//数据权限判断
*/
public function updateDataById($param, $customer_id = '')
{
$user_id = $param['user_id'];
$dataInfo = $this->get($customer_id);
if (!$dataInfo) {
$this->error = '数据不存在或已删除';
return false;
}
$id = $param['id']?:$customer_id;
//数据权限判断
$userModel = new \app\admin\model\User();
$auth_user_ids = $userModel->getUserByPer('crm', 'customer', 'update');
//读写权限
$rwPre = $userModel->rwPre($user_id, $dataInfo['ro_user_id'], $dataInfo['rw_user_id'], 'update');
$rwPre = $userModel->rwPre($user_id, $dataInfo['ro_user_id'], $dataInfo['rw_user_id'], 'update');
//判断是否客户池数据
$wherePool = $this->getWhereByPool();
$resPool = db('crm_customer')->alias('customer')->where(['customer_id' => $param['id']])->where($wherePool)->find();
$resPool = db('crm_customer')->alias('customer')->where(['customer_id' => $id])->where($wherePool)->find();
if ($resPool || (!in_array($dataInfo['owner_user_id'],$auth_user_ids) && !$rwPre)) {
$this->error = '无权操作';
return false;
}
$param['customer_id'] = $customer_id;
//过滤不能修改的字段
$unUpdateField = ['create_user_id','is_deleted','delete_time','user_id'];
foreach ($unUpdateField as $v) {
unset($param[$v]);
}
$param['deal_status'] = $dataInfo['deal_status'];
$fieldModel = new \app\admin\model\Field();
// 自动验证
$validateArr = $fieldModel->validateField($this->name); //获取自定义字段验证规则
$validate = new Validate($validateArr['rule'], $validateArr['message']);
$result = $validate->check($param);
if (!$result) {
$this->error = $validate->getError();
return false;
}
//地址
$param['address'] = $param['address'] ? implode(chr(10),$param['address']) : '';
if ($param['deal_status'] == '已成交' && $dataInfo->data['deal_status'] == '未成交') {
}
$param['customer_id'] = $customer_id;
//过滤不能修改的字段
$unUpdateField = ['create_user_id','is_deleted','delete_time','user_id'];
foreach ($unUpdateField as $v) {
unset($param[$v]);
}
$param['deal_status'] = $dataInfo['deal_status'];
$fieldModel = new \app\admin\model\Field();
// 自动验证
$validateArr = $fieldModel->validateField($this->name); //获取自定义字段验证规则
$validate = new Validate($validateArr['rule'], $validateArr['message']);
$result = $validate->check($param);
if (!$result) {
$this->error = $validate->getError();
return false;
}
//地址
$param['address'] = $param['address'] ? implode(chr(10),$param['address']) : '';
if ($param['deal_status'] == '已成交' && $dataInfo->data['deal_status'] == '未成交') {
$param['deal_time'] = time();
}
# 处理下次联系时间
if (!empty($param['next_time'])) $param['next_time'] = strtotime($param['next_time']);
//处理部门、员工、附件、多选类型字段
$arrFieldAtt = $fieldModel->getArrayField('crm_customer');
foreach ($arrFieldAtt as $k=>$v) {
$param[$v] = arrayToString($param[$v]);
}
$param['follow'] = '已跟进';
if ($this->update($param, ['customer_id' => $customer_id], true)) {
//修改记录
updateActionLog($user_id, 'crm_customer', $customer_id, $dataInfo->data, $param);
$data = [];
$data['customer_id'] = $customer_id;
return $data;
} else {
$this->error = '编辑失败';
return false;
}
}
//处理部门、员工、附件、多选类型字段
$arrFieldAtt = $fieldModel->getArrayField('crm_customer');
foreach ($arrFieldAtt as $k=>$v) {
$param[$v] = arrayToString($param[$v]);
}
$param['follow'] = '已跟进';
if ($this->update($param, ['customer_id' => $customer_id], true)) {
//修改记录
updateActionLog($user_id, 'crm_customer', $customer_id, $dataInfo->data, $param);
$data = [];
$data['customer_id'] = $customer_id;
return $data;
} else {
$this->error = '编辑失败';
return false;
}
}
/**
* 客户数据
@ -495,7 +491,11 @@ class Customer extends Common
$primaryId = Db::name('crm_contacts')->where(['customer_id' => $id, 'primary' => 1])->value('contacts_id');
$dataInfo['contacts_id'] = !empty($primaryId) && $this->getContactsAuth($primaryId) ? $primaryId : 0;
# 处理时间格式
$dataInfo['next_time'] = !empty($dataInfo['next_time']) ? date('Y-m-d H:i:s', $dataInfo['next_time']) : null;
$fieldModel = new \app\admin\model\Field();
$datetimeField = $fieldModel->getFieldByFormType('crm_customer', '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;
$dataInfo['last_time'] = !empty($dataInfo['last_time']) ? date('Y-m-d H:i:s', $dataInfo['last_time']) : null;

@ -14,6 +14,7 @@ class Invoice extends Common
{
protected $name = 'crm_invoice';
protected $pk = 'invoice_id';
protected $dateFormat = "Y-m-d H:i:s";
/**
* 关联用户模型

@ -90,7 +90,7 @@ class Leads extends Common
if (!is_array($map['leads.owner_user_id'][1])) {
$map['leads.owner_user_id'][1] = [$map['leads.owner_user_id'][1]];
}
if ($map['leads.owner_user_id'][0] == 'neq') {
if (in_array($map['leads.owner_user_id'][0], ['neq', 'notin'])) {
$auth_user_ids = array_diff($auth_user_ids, $map['leads.owner_user_id'][1]) ?: []; //取差集
} else {
$auth_user_ids = array_intersect($map['leads.owner_user_id'][1], $auth_user_ids) ?: []; //取交集
@ -104,6 +104,7 @@ class Leads extends Common
$indexField = $fieldModel->getIndexField('crm_leads', $user_id, 1) ?: array('name');
$userField = $fieldModel->getFieldByFormType('crm_leads', 'user'); //人员类型
$structureField = $fieldModel->getFieldByFormType('crm_leads', 'structure'); //部门类型
$datetimeField = $fieldModel->getFieldByFormType('crm_leads', 'datetime'); //日期时间类型
//排序
if ($order_type && $order_field) {
@ -139,10 +140,15 @@ class Leads 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'] : '';
foreach ($userField as $key => $val) {
$list[$k][$val . '_info'] = isset($v[$val]) ? $userModel->getListByStr($v[$val]) : [];
$usernameField = !empty($v[$val]) ? db('admin_user')->whereIn('id', stringToArray($v[$val]))->column('realname') : [];
$list[$k][$val] = implode($usernameField, ',');
}
foreach ($structureField as $key => $val) {
$list[$k][$val . '_info'] = isset($v[$val]) ? $structureModel->getDataByStr($v[$val]) : [];
$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;
}
//权限
$permission = [];
@ -156,8 +162,6 @@ class Leads extends Common
$permission['is_update'] = $is_update;
$permission['is_delete'] = $is_delete;
$list[$k]['permission'] = $permission;
# 下次联系时间
$list[$k]['next_time'] = !empty($v['next_time']) ? date('Y-m-d H:i:s', $v['next_time']) : null;
# 关注
$starWhere = ['user_id' => $user_id, 'target_id' => $v['leads_id'], 'type' => 'crm_leads'];
$star = Db::name('crm_star')->where($starWhere)->value('star_id');
@ -210,9 +214,6 @@ class Leads extends Common
$param[$v] = arrayToString($param[$v]);
}
# 处理下次联系时间
if (!empty($param['next_time'])) $param['next_time'] = strtotime($param['next_time']);
if ($this->data($param)->allowField(true)->isUpdate(false)->save()) {
//修改记录
updateActionLog($param['create_user_id'], 'crm_leads', $this->leads_id, '', '', '创建了线索');
@ -276,9 +277,6 @@ class Leads extends Common
return false;
}
# 处理下次联系时间
if (!empty($param['next_time'])) $param['next_time'] = strtotime($param['next_time']);
//处理部门、员工、附件、多选类型字段
$arrFieldAtt = $fieldModel->getArrayField('crm_leads');
foreach ($arrFieldAtt as $k => $v) {
@ -323,7 +321,11 @@ class Leads extends Common
$starId = empty($userId) ? 0 : Db::name('crm_star')->where(['user_id' => $userId, 'target_id' => $id, 'type' => 'crm_leads'])->value('star_id');
$dataInfo['star'] = !empty($starId) ? 1 : 0;
# 处理时间格式处理
$dataInfo['next_time'] = !empty($dataInfo['next_time']) ? date('Y-m-d H:i:s', $dataInfo['next_time']) : null;
$fieldModel = new \app\admin\model\Field();
$datetimeField = $fieldModel->getFieldByFormType('crm_leads', '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;
$dataInfo['last_time'] = !empty($dataInfo['last_time']) ? date('Y-m-d H:i:s', $dataInfo['last_time']) : null;

@ -35,7 +35,7 @@ class Product extends Common
* @return array
*/
public function getDataList($request)
{
{
$userModel = new \app\admin\model\User();
$structureModel = new \app\admin\model\Structure();
$fieldModel = new \app\admin\model\Field();
@ -48,8 +48,8 @@ class Product extends Common
$isStatus = !empty($request['is_status']) ? $request['is_status'] : 0;
unset($request['scene_id']);
unset($request['search']);
unset($request['user_id']);
unset($request['order_field']);
unset($request['user_id']);
unset($request['order_field']);
unset($request['order_type']);
unset($request['is_status']);
@ -87,7 +87,7 @@ class Product extends Common
if (!is_array($map['product.owner_user_id'][1])) {
$map['product.owner_user_id'][1] = [$map['product.owner_user_id'][1]];
}
if ($map['product.owner_user_id'][0] == 'neq') {
if (in_array($map['product.owner_user_id'][0], ['neq', 'notin'])) {
$auth_user_ids = array_diff($auth_user_ids, $map['product.owner_user_id'][1]) ?: []; //取差集
} else {
$auth_user_ids = array_intersect($map['product.owner_user_id'][1], $auth_user_ids) ?: []; //取交集
@ -102,25 +102,26 @@ class Product extends Common
$indexField = $fieldModel->getIndexField('crm_product', $user_id, 1) ? : ['name'];
$userField = $fieldModel->getFieldByFormType('crm_product', 'user'); //人员类型
$structureField = $fieldModel->getFieldByFormType('crm_product', 'structure'); //部门类型
$datetimeField = $fieldModel->getFieldByFormType('crm_product', 'datetime'); //日期时间类型
//排序
if ($order_type && $order_field) {
$order = $fieldModel->getOrderByFormtype('crm_product','product',$order_field,$order_type);
} else {
$order = 'product.update_time desc';
}
}
$join = [
['__CRM_PRODUCT_CATEGORY__ product_category', 'product_category.category_id = product.category_id', 'LEFT'],
];
$map['product.delete_user_id']=0;
$list = db('crm_product')->alias('product')
->join($join)
->where($map)
->where($authMap)
->limit($request['offset'], $request['length'])
->field($indexField)
->field(array_merge($indexField, ['product_category.name' => 'category_name']))
->field('product.*,product_category.name as category_name')
->orderRaw($order)
->select();
$dataCount = db('crm_product')->alias('product')
@ -132,11 +133,16 @@ class Product 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'] : '';
foreach ($userField as $key => $val) {
$list[$k][$val.'_info'] = isset($v[$val]) ? $userModel->getListByStr($v[$val]) : [];
$usernameField = !empty($v[$val]) ? db('admin_user')->whereIn('id', stringToArray($v[$val]))->column('realname') : [];
$list[$k][$val] = implode($usernameField, ',');
}
foreach ($structureField as $key => $val) {
$list[$k][$val.'_info'] = isset($v[$val]) ? $structureModel->getDataByStr($v[$val]) : [];
$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;
}
//产品类型
$list[$k]['category_id_info'] = $v['category_name'];
# 处理日期格式
@ -153,23 +159,25 @@ class Product extends Common
/**
* 创建产品主表信息
* @author Michael_xu
* @param
* @return
*/
* @param
* @return
*/
public function createData($param)
{
$fieldModel = new \app\admin\model\Field();
$productCategoryModel = model('ProductCategory');
// 自动验证
$validateArr = $fieldModel->validateField($this->name); //获取自定义字段验证规则
$validate = new Validate($validateArr['rule'], $validateArr['message']);
$result = $validate->check($param);
if (!$result) {
$this->error = $validate->getError();
return false;
}
$dataInfo = db('crm_product')->where(['name'=>$param['name'],'delete_user_id'=>0])->find();
if(isset($dataInfo)){
// 自动验证
$validateArr = $fieldModel->validateField($this->name); //获取自定义字段验证规则
$validate = new Validate($validateArr['rule'], $validateArr['message']);
$result = $validate->check($param);
if (!$result) {
$this->error = $validate->getError();
return false;
}
}
//处理部门、员工、附件、多选类型字段
$arrFieldAtt = $fieldModel->getArrayField('crm_product');
foreach ($arrFieldAtt as $k=>$v) {
@ -200,17 +208,18 @@ class Product extends Common
} else {
$this->error = '添加失败';
return false;
}
}
}
/**
* 编辑产品主表信息
* @author Michael_xu
* @param
* @return
*/
* @param
* @return
*/
public function updateDataById($param, $product_id = '')
{
$userModel = new \app\admin\model\User();
$dataInfo = $this->getDataById($product_id);
$productCategoryModel = model('ProductCategory');
if (!$dataInfo) {
@ -222,7 +231,7 @@ class Product extends Common
if (!in_array($dataInfo['owner_user_id'], $auth_user_ids)) {
$this->error = '无权操作';
return false;
}
}
$param['product_id'] = $product_id;
//过滤不能修改的字段
@ -232,15 +241,16 @@ class Product extends Common
}
$fieldModel = new \app\admin\model\Field();
// 自动验证
$validateArr = $fieldModel->validateField($this->name); //获取自定义字段验证规则
$validate = new Validate($validateArr['rule'], $validateArr['message']);
$result = $validate->check($param);
if (!$result) {
$this->error = $validate->getError();
return false;
}
// 自动验证
// $validateArr = $fieldModel->validateField($this->name); //获取自定义字段验证规则
// $validate = new Validate($validateArr['rule'], $validateArr['message']);
//
// $result = $validate->check($param);
// if (!$result) {
// $this->error = $validate->getError();
// return false;
// }
//处理部门、员工、附件、多选类型字段
$arrFieldAtt = $fieldModel->getArrayField('crm_product');
@ -250,17 +260,16 @@ class Product extends Common
//产品分类
$category_id = $param['category_id'];
if (is_array($category_id)) {
$param['category_id'] = $productCategoryModel->getIdByStr($category_id);
$param['category_str'] = arrayToString($category_id);
}
// if (is_array($category_id)) {
// $param['category_id'] = $productCategoryModel->getIdByStr($category_id);
// $param['category_str'] = arrayToString($category_id);
// }
if(!is_int($category_id)){
$list=db('crm_product_category')->column('category_id','name');
$param['category_id']=1;
foreach ($list as $k=>$v){
if($k==$param['category_id']){
if($k==$category_id){
$param['category_id']=$v;
}else{
$param['category_id']=0;
}
}
}
@ -274,7 +283,7 @@ class Product extends Common
$this->rollback();
$this->error = '编辑失败';
return false;
}
}
}
/**
@ -287,8 +296,9 @@ class Product extends Common
* @throws \think\exception\DbException
*/
public function getDataById($id = '')
{
{
$map['product_id'] = $id;
$map['delete_user_id'] = 0;
$dataInfo = db('crm_product')->where($map)->find();
if (!$dataInfo) {
$this->error = '暂无此数据';
@ -302,8 +312,13 @@ class Product extends Common
$userModel = new \app\admin\model\User();
$dataInfo['create_user_id_info'] = $userModel->getUserById($dataInfo['create_user_id']);
$dataInfo['category_id_info'] = db('crm_product_category')->where(['category_id' => $dataInfo['category_id']])->value('name');
$dataInfo['category_id_info'] = db('crm_product_category')->where(['category_id' => $dataInfo['category_id']])->value('name');
# 处理日期格式
$fieldModel = new \app\admin\model\Field();
$datetimeField = $fieldModel->getFieldByFormType('crm_product', '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;
return $dataInfo;
@ -320,19 +335,15 @@ class Product extends Common
*/
private function getProductImages($fileIds)
{
$result = [];
$files = Db::name('admin_file')->whereIn('file_id', $fileIds)->select();
$files = Db::name('admin_file')->field(['file_id', 'file_path_thumb', 'file_path', 'save_name'])->whereIn('file_id', $fileIds)->select();
foreach ($files AS $key => $value) {
$result[] = [
'file_id' => $value['file_id'],
'file_path_thumb' => getFullPath($value['file_path_thumb']),
'file_path' => getFullPath($value['file_path']),
'save_name' => $value['save_name']
];
$files[$key]['file_path'] = getFullPath($value['file_path']);
$files[$key]['file_path_thumb'] = getFullPath($value['file_path_thumb']);
$files[$key]['size'] = format_bytes($value['size']);
}
return $result;
return $files;
}
/**
@ -346,10 +357,10 @@ class Product extends Common
* @param subtotal 小计(折扣后价格)
* @param unit 单位
* @param total_price 折扣后整单总价
* @param discount_rate 整单折扣
* @param discount_rate 整单折扣
* @param objId 关联对象ID
* @return
*/
* @return
*/
public function createObject($types, $param, $objId)
{
switch ($types) {
@ -375,7 +386,7 @@ class Product extends Common
$product[$key]['discount'] = $value['discount']; //折扣
$product[$key]['unit'] = $value['unit'] ? : ''; //单位
$product[$key]['subtotal'] = $value['subtotal'];
// $total_price += $product[$key]['subtotal'] = round(($value['price'] * $value['num']) * $discount); //总价
// $total_price += $product[$key]['subtotal'] = round(($value['price'] * $value['num']) * $discount); //总价
$product[$key][$db_id] = $objId;
}
@ -388,18 +399,18 @@ class Product extends Common
//产品合计
$rData['discount_rate'] = !empty($param['discount_rate']) ? $param['discount_rate'] : 0.00; //整单折扣
$discount_rate = ((100 - $rData['discount_rate']) > 0) ? (100 - $rData['discount_rate'])/100 : 0;
// $rData['total_price'] = $total_price ? $total_price*$discount_rate : '0.00'; //整单合计
$rData['total_price'] = $param['total_price'] ? : '0.00'; //整单合计
db($rDb)->where([$db_id => $objId])->update($rData);
// $rData['total_price'] = $total_price ? $total_price*$discount_rate : '0.00'; //整单合计
$rData['total_price'] = $param['total_price'] ? : '0.00'; //整单合计
db($rDb)->where([$db_id => $objId])->update($rData);
// 提交事务
Db::commit();
return true;
return true;
} catch (\Exception $e) {
$this->error = '产品数据创建出错';
// 回滚事务
Db::rollback();
return false;
Db::rollback();
return false;
}
} else {
//删除产品信息
@ -425,7 +436,7 @@ class Product extends Common
$perUserIds = $userModel->getUserByPer('bi', 'product', 'read'); //权限范围内userIds
$whereData = $adminModel->getWhere($param, '', $perUserIds); //统计条件
$userIds = $whereData['userIds'];
$between_time = $whereData['between_time'];
$between_time = $whereData['between_time'];
$where = [];
//时间段
$where['contract.create_time'] = ['between', $between_time];
@ -457,7 +468,7 @@ class Product extends Common
$list[$k]['contract_id_info'] = $contract_info ? : array();
//产品
$product_info = [];
$product_info['name'] = $v['product_name'];
$product_info['name'] = $v['product_name'];
$product_info['product_id'] = $v['product_id'];
$list[$k]['product_id_info'] = $product_info ? : array();
//负责人
@ -467,14 +478,14 @@ class Product extends Common
$list[$k]['owner_user_name'] = $owner_user_id_info['realname'];
}
return $list;
}
}
/**
* [根据产品类别ID查询父级ID]
* @author Michael_xu
* @param
* @return
*/
* @param
* @return
*/
public function getPidStr($category_id, $idArr, $first = '')
{
if ($first == 1) $idArr = [];

@ -83,7 +83,7 @@ class Receivables extends Common
if (!is_array($map['receivables.owner_user_id'][1])) {
$map['receivables.owner_user_id'][1] = [$map['receivables.owner_user_id'][1]];
}
if ($map['receivables.owner_user_id'][0] == 'neq') {
if (in_array($map['receivables.owner_user_id'][0], ['neq', 'notin'])) {
$auth_user_ids = array_diff($auth_user_ids, $map['receivables.owner_user_id'][1]) ? : []; //取差集
} else {
$auth_user_ids = array_intersect($map['receivables.owner_user_id'][1], $auth_user_ids) ? : []; //取交集
@ -97,7 +97,8 @@ class Receivables extends Common
$indexField = $fieldModel->getIndexField('crm_receivables', $user_id, 1) ? : array('number');
//人员类型
$userField = $fieldModel->getFieldByFormType('crm_receivables', 'user');
$structureField = $fieldModel->getFieldByFormType('crm_receivables', 'structure'); //部门类型
$structureField = $fieldModel->getFieldByFormType('crm_receivables', 'structure'); //部门类型
$datetimeField = $fieldModel->getFieldByFormType('crm_receivables', 'datetime'); //日期时间类型
if ($request['order_type'] && $request['order_field']) {
$order = $fieldModel->getOrderByFormtype('crm_receivables','receivables',$order_field,$order_type);
@ -134,7 +135,7 @@ class Receivables extends Common
->where($map)
->where($authMap)
->limit($request['offset'], $request['length'])
->field(implode(',',$indexField).',customer.name as customer_name,contract.name as contract_name,contract.num as contract_num,contract.money as contract_money')
->field('receivables.*,customer.name as customer_name,contract.name as contract_name,contract.num as contract_num,contract.money as contract_money')
->orderRaw($order)
->select();
@ -150,11 +151,16 @@ class Receivables extends Common
$list[$k]['contract_id_info']['money'] = $v['contract_money'] ? : '0.00';
$list[$k]['contract_money'] = $v['contract_money'] ? : '0.00';
foreach ($userField as $key => $val) {
$list[$k][$val.'_info'] = isset($v[$val]) ? $userModel->getListByStr($v[$val]) : [];
$usernameField = !empty($v[$val]) ? db('admin_user')->whereIn('id', stringToArray($v[$val]))->column('realname') : [];
$list[$k][$val] = implode($usernameField, ',');
}
foreach ($structureField as $key => $val) {
$list[$k][$val.'_info'] = isset($v[$val]) ? $structureModel->getDataByStr($v[$val]) : [];
$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;
}
$list[$k]['check_status_info'] = $this->statusArr[$v['check_status']];
//期数
$plan_num = db('crm_receivables_plan')->where(['plan_id' => $v['plan_id']])->value('num');
@ -403,6 +409,11 @@ class Receivables extends Common
$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;
# 处理时间格式
$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;
return $dataInfo;

@ -236,7 +236,9 @@ class Event extends ApiCommon
$eventModel = model('Event');
$data = $eventModel->getDataById($this->param['event_id']);
if(!$data['title']){
return resultArray(['error' => '日程已删除']);
}
return resultArray(['data' => $data]);
}

@ -468,7 +468,7 @@ class Examine extends ApiCommon
$is_end = 1;
//审批结束
$checkData['check_status'] = !empty($status) ? 2 : 3;
$examineData['check_user_id'] = '';
// $examineData['check_user_id'] = '';
} else {
//修改主体相关审批信息
$examineData['check_user_id'] = arrayToString($next_user_ids);
@ -484,7 +484,7 @@ class Examine extends ApiCommon
}
if ($is_end == 1) {
$checkData['check_status'] = !empty($status) ? 2 : 3;
$examineData['check_user_id'] = '';
// $examineData['check_user_id'] = '';
$examineData['check_status'] = 2;
}
} else {
@ -588,8 +588,9 @@ class Examine extends ApiCommon
$checkData['status'] = $status;
$examineData['check_status'] = 4;
$examineData['check_user_id'] = '';
$examineData['flow_user_id'] = '';
# 如果将审批人置空,会导致普通员工在右上角消息中无法查看审批
$examineData['check_user_id'] = $dataInfo['check_user_id'];
$examineData['flow_user_id'] = '';
$resExamine = db('oa_examine')->where(['examine_id' => $examine_id])->update($examineData);
if ($resExamine) {
//将审批记录至为无效

@ -33,7 +33,7 @@ class Task extends ApiCommon
Hook::listen('check_auth', $action);
$request = Request::instance();
$a = strtolower($request->action());
if (!in_array($a, $action['permission'])) {
parent::_initialize();
}
@ -48,7 +48,7 @@ class Task extends ApiCommon
}
}
}
//判断任务(需创建人和负责人才能编辑删除)
public function checkSub($task_id)
{
@ -62,7 +62,7 @@ class Task extends ApiCommon
exit(json_encode(['code' => 102, 'error' => '没有权限']));
}
}
/**
* 查看下属创建的任务
* @param //负责和参与
@ -71,9 +71,9 @@ class Task extends ApiCommon
*/
public function subTaskList()
{
}
/**
* 查看所有的项目
* @param
@ -88,7 +88,7 @@ class Task extends ApiCommon
$data['count'] = $count;
return resultArray(['data' => $data]);
}
/**
* 查看某个项目下任务列表
* @param
@ -104,7 +104,7 @@ class Task extends ApiCommon
$list = $taskModel->getDataList($param, $userInfo['id']);
return resultArray(['data' => $list]);
}
/**
* 查看我的任务
* @param
@ -137,7 +137,6 @@ class Task extends ApiCommon
} else {
$where['t.status'] = [['=', 1], ['=', 5], 'OR'];
}
if ($param['main_user_id']) {
$where['t.main_user_id'] = $param['main_user_id'];
}
@ -154,25 +153,25 @@ class Task extends ApiCommon
$subArr[] = $v;
$subArr[] = '|';
}
$subValue = $subList ? arrayToString($subArr) : '';
$subValue = $subList ? arrayToString($subArr) : '';
$where['t.ishidden'] = 0;
$where['t.pid'] = 0;
if ($type != 0) {
switch ($type) {
case '1' :
$type = 't.main_user_id in ('.$subStr.')';
$type = 't.main_user_id in (' . $subStr . ')';
break; //下属负责的
case '3' :
//使用正则查询
// SELECT * FROM 5kcrm_task WHERE owner_user_id REGEXP '(,1,|,2,|,3,)';
$type = $subValue ? 't.owner_user_id REGEXP "('.$subValue.')"' : '';
$type = $subValue ? 't.owner_user_id REGEXP "(' . $subValue . ')"' : '';
break; //下属参与的
}
} else {
if (!$subValue) {
$type = 't.is_open = 1 AND (t.main_user_id in (' . $subStr . ') or t.create_user_id in (' . $subStr . '))';
} else {
$type .= 't.is_open = 1 AND (t.main_user_id in (' . $subStr . ') or t.create_user_id in (' . $subStr . ') or t.owner_user_id REGEXP "('.$subValue.')")';
$type .= 't.is_open = 1 AND (t.main_user_id in (' . $subStr . ') or t.create_user_id in (' . $subStr . ') or t.owner_user_id REGEXP "(' . $subValue . ')")';
}
}
// $where['t.work_id'] = 0;
@ -195,13 +194,12 @@ class Task extends ApiCommon
$query->where($type);
})
->count();
$completeCount = db('task') ->alias('t')->where($where)
$completeCount = db('task')->alias('t')
->where($map)
->where(function ($query) use ($type) {
$query->where($type);
})->where('t.status', 5)->count();
})
->where($map)->where(['t.status' => 5, 't.ishidden' => 0, 'priority' => $priority])->count();
foreach ($taskList as $k => $v) {
$temp = $v ?: [];
if ($v['pid']) {
@ -217,7 +215,7 @@ class Task extends ApiCommon
$taskList[$k]['lableList'] = $v['lable_id'] ? $lableModel->getDataByStr($v['lable_id']) : [];
$taskList[$k]['main_user'] = $v['main_user_id'] ? $userModel->getUserById($v['main_user_id']) : array();
$taskList[$k]['relationCount'] = $taskModel->getRelationCount($v['task_id']);
$taskList[$k]['create_time'] = date('Y-m-d', $v['create_time']) ?: '';
$taskList[$k]['update_time'] = date('Y-m-d', $v['update_time']) ?: '';
$taskList[$k]['start_time'] = $v['start_time'] == 0 ? null : date('Y-m-d', $v['start_time']);;
@ -226,7 +224,7 @@ class Task extends ApiCommon
if (!empty($v['stop_time']) && (strtotime(date('Ymd')) + 86400 > $v['stop_time'])) $is_end = 1;
$taskList[$k]['is_end'] = $is_end;
}
} else {
$map['t.pid'] = 0;
// $map['t.work_id'] = 0;
@ -236,15 +234,15 @@ class Task extends ApiCommon
$type = 't.main_user_id =' . $userInfo['id'] . '';
break; //我负责的
case '3' :
$type = 't.owner_user_id like "%,'.$userInfo['id'].',%"';
$type = 't.owner_user_id like "%,' . $userInfo['id'] . ',%"';
break; //我参与的
}
} else {
$adminIds = $userModel->getAdminId();
if (in_array($userInfo['id'],$adminIds)) {
$type = 't.is_open = 1';
if (in_array($userInfo['id'], $adminIds)) {
$type = 't.is_open = 1';
} else {
$type = 't.is_open = 1 AND (t.main_user_id =' . $userInfo['id'] .' OR t.owner_user_id like "%,'.$userInfo['id'].',%")';
$type = 't.is_open = 1 AND (t.main_user_id =' . $userInfo['id'] . ' OR t.owner_user_id like "%,' . $userInfo['id'] . ',%")';
}
}
$where['t.ishidden'] = 0;
@ -259,33 +257,35 @@ class Task extends ApiCommon
->order('t.task_id desc')
->select();
$dataCount = db('task')->alias('t')->where($where)->where($type)->where($map)->count();
$completeCount = db('task')->alias('t')->where($where)->where($type)->where($map)->where('t.status', 5)->count();
$completeCount = db('task')->alias('t')
->where($type)
->where($map)->where(['t.status' => 5, 't.ishidden' => 0, 'priority' => $priority])->count();
foreach ($taskList as $key => $value) {
$pname = '';
if ($value['pid']) {
$pname = Db::name('Task')->where('task_id ='.$value['pid'])->value('name');
$pname = Db::name('Task')->where('task_id =' . $value['pid'])->value('name');
}
$taskList[$key]['pname'] = $pname ? : '';
$taskList[$key]['pname'] = $pname ?: '';
$taskList[$key]['thumb_img'] = $value['thumb_img'] ? getFullPath($value['thumb_img']) : '';
$taskList[$key]['subcount'] = Db::name('Task')->where(['ishidden' => 0,'status' => 1,'pid' => $value['task_id']])->count(); //子任务
$taskList[$key]['subdonecount'] = Db::name('Task')->where(['ishidden' => 0,'status' => 5,'pid' => $value['task_id']])->count(); //已完成子任务
$taskList[$key]['commentcount'] = Db::name('AdminComment')->where(['type' => 'task','type_id' => $value['task_id']])->count();
$taskList[$key]['filecount'] = Db::name('WorkTaskFile')->where('task_id ='.$value['task_id'])->count();
$taskList[$key]['subcount'] = Db::name('Task')->where(['ishidden' => 0, 'status' => 1, 'pid' => $value['task_id']])->count(); //子任务
$taskList[$key]['subdonecount'] = Db::name('Task')->where(['ishidden' => 0, 'status' => 5, 'pid' => $value['task_id']])->count(); //已完成子任务
$taskList[$key]['commentcount'] = Db::name('AdminComment')->where(['type' => 'task', 'type_id' => $value['task_id']])->count();
$taskList[$key]['filecount'] = Db::name('WorkTaskFile')->where('task_id =' . $value['task_id'])->count();
$taskList[$key]['lableList'] = $value['lable_id'] ? $lableModel->getDataByStr($value['lable_id']) : [];
$taskList[$key]['create_time'] = date('Y-m-d', $value['create_time']) ?: '';
$taskList[$key]['update_time'] = date('Y-m-d', $value['update_time']) ?: '';
$taskList[$key]['start_time'] = $value['start_time']==0?null:date('Y-m-d', $value['start_time']);;
$taskList[$key]['stop_time'] = $value['stop_time']==0?null:date('Y-m-d', $value['stop_time']);
$taskList[$key]['create_time'] = date('Y-m-d', $value['create_time']) ?: '';
$taskList[$key]['update_time'] = date('Y-m-d', $value['update_time']) ?: '';
$taskList[$key]['start_time'] = $value['start_time'] == 0 ? null : date('Y-m-d', $value['start_time']);;
$taskList[$key]['stop_time'] = $value['stop_time'] == 0 ? null : date('Y-m-d', $value['stop_time']);
//负责人信息
$taskList[$key]['main_user'] = $value['main_user_id'] ? $userModel->getDataById($value['main_user_id']) : array();
$taskList[$key]['relationCount'] = $taskModel->getRelationCount($value['task_id']);
$is_end = 0;
if (!empty($value['stop_time']) && (strtotime(date('Ymd'))+86399 > $value['stop_time'])) $is_end = 1;
if (!empty($value['stop_time']) && (strtotime(date('Ymd')) + 86399 > $value['stop_time'])) $is_end = 1;
$taskList[$key]['is_end'] = $is_end;
}
}
$data = [];
$data['page']['list'] = $taskList ?: [];
$data['page']['dataCount'] = $dataCount ?: 0;
@ -302,7 +302,7 @@ class Task extends ApiCommon
}
return resultArray(['data' => $data]);
}
/**
* 任务列表导出
* @return \think\response\Json|void
@ -316,7 +316,7 @@ class Task extends ApiCommon
$data = $TaskLogic->excelExport($param);
return $data;
}
/**
* 获取任务详情
* @param
@ -338,7 +338,7 @@ class Task extends ApiCommon
return resultArray(['error' => $taskmodel->getError()]);
}
}
/**
* 任务编辑保存
* @param
@ -365,7 +365,7 @@ class Task extends ApiCommon
return resultArray(['error' => $taskModel->getError()]);
}
}
/**
* 解除关联关系
* @param
@ -403,7 +403,7 @@ class Task extends ApiCommon
return resultArray(['error' => '操作失败']);
}
}
/**
* 获取任务操作记录
* @param
@ -420,7 +420,7 @@ class Task extends ApiCommon
$list = $taskModel->getTaskLogList($param) ?: [];
return resultArray(['data' => $list]);
}
/**
* 优先级设置
* @param
@ -432,7 +432,7 @@ class Task extends ApiCommon
$param = $this->param;
$userInfo = $this->userInfo;
$param['create_user_id'] = $userInfo['id'];
if (!isset($param['priority_id']) || !$param['task_id']) {
return resultArray(['error' => '参数错误']);
}
@ -446,7 +446,7 @@ class Task extends ApiCommon
return resultArray(['error' => '操作失败']);
}
}
/**
* 参与人/参与部门编辑
* @param
@ -481,7 +481,7 @@ class Task extends ApiCommon
}
return resultArray(['error' => '修改失败']);
}
/**
* 单独删除参与人
* @param
@ -504,7 +504,7 @@ class Task extends ApiCommon
return resultArray(['error' => $taskModel->getError()]);
}
}
/**
* 单独删除参与部门
* @param
@ -527,7 +527,7 @@ class Task extends ApiCommon
return resultArray(['error' => $taskModel->getError()]);
}
}
/**
* 设置任务截止时间
* @param
@ -553,7 +553,7 @@ class Task extends ApiCommon
return resultArray(['error' => $taskModel->getError()]);
}
}
/**
* 添加删除标签
* @param
@ -584,7 +584,7 @@ class Task extends ApiCommon
return resultArray(['error' => $taskModel->getError()]);
}
}
/**
* 任务标题描述更新
* @param
@ -606,7 +606,7 @@ class Task extends ApiCommon
return resultArray(['error' => $taskModel->getError()]);
}
}
/**
* 任务标记结束
* @param
@ -646,7 +646,7 @@ class Task extends ApiCommon
}
return resultArray(['data' => '操作成功']);
}
/**
* 日历任务展示/月份
* @param
@ -666,7 +666,7 @@ class Task extends ApiCommon
return resultArray(['error' => $taskModel->getError()]);
}
}
/**
* 添加任务
* @param
@ -689,7 +689,7 @@ class Task extends ApiCommon
return resultArray(['error' => $taskModel->getError()]);
}
}
/**
* 删除主负责人
* @param
@ -717,7 +717,7 @@ class Task extends ApiCommon
}
return resultArray(['data' => '操作成功']);
}
/**
* 重命名任务
* @param
@ -740,7 +740,7 @@ class Task extends ApiCommon
return resultArray(['error' => $workModel->getError()]);
}
}
/**
* 删除任务
* @param
@ -765,7 +765,7 @@ class Task extends ApiCommon
return resultArray(['error' => $workModel->getError()]);
}
}
/**
* 归档任务 改变状态
* @param
@ -793,7 +793,7 @@ class Task extends ApiCommon
return resultArray(['error' => $taskModel->getError()]);
}
}
/**
* 恢复归档任务
* @param
@ -821,7 +821,7 @@ class Task extends ApiCommon
return resultArray(['error' => $taskModel->getError()]);
}
}
/**
* 归档任务列表
* @param

@ -10,7 +10,193 @@ use think\Validate;
class ExamineLogic extends Common
{
private $statusArr = ['0' => '待审核', '1' => '审核中', '2' => '审核通过', '3' => '已拒绝', '4' => '已撤回'];
public function getDataList($request)
{
$userModel = new \app\admin\model\User();
$fileModel = new \app\admin\model\File();
$recordModel = new \app\admin\model\Record();
$examine_by = $request['examine_by']; //1待我审批 2我已审批 all 全部
$user_id = $request['user_id'];
$bi = $request['bi_types'];
$check_status = $request['check_status']; //0 待审批 2 审批通过 4 审批拒绝 all 全部
unset($request['by']);
unset($request['bi_types']);
unset($request['user_id']);
unset($request['check_status']);
unset($request['examine_by']);
$request = $this->fmtRequest($request);
$map = $request['map'] ?: [];
if (isset($map['search']) && $map['search']) {
//普通筛选
$map['examine.content'] = ['like', '%' . $map['search'] . '%'];
} else {
$map = where_arr($map, 'oa', 'examine', 'index'); //高级筛选
}
unset($map['search']);
//审批类型
$map['examine.category_id'] = $map['examine.category_id'] ?: array('gt', 0);
$map_str = '';
$logmap = '';
switch ($examine_by) {
case 'all' :
//如果超管则能看到全部
if (!isSuperAdministrators($user_id)) {
$map_str = "(( check_user_id LIKE '%," . $user_id . ",%' OR check_user_id = " . $user_id . " ) OR ( flow_user_id LIKE '%," . $user_id . ",%' OR `flow_user_id` = " . $user_id . " ) )";
}
break;
case '1' :
$map['check_user_id'] = [['like', '%,' . $user_id . ',%']];
break; //待审
case '2' :
$map_str = "(( check_user_id LIKE '%," . $user_id . ",%' OR check_user_id = " . $user_id . " )
OR ( flow_user_id LIKE '%," . $user_id . ",%' OR `flow_user_id` = " . $user_id . " ) )";
// $map['flow_user_id'] = [['like', '%,' . $user_id . ',%'], ['eq', $user_id], 'or'];
break; //已审
default:
$map['examine.create_user_id'] = $user_id;
break;
}
$order = 'examine.create_time desc,examine.update_time desc';
//发起时间
if ($map['examine.between_time'][0] && $map['examine.between_time'][1]) {
$start_time = $map['examine.between_time'][0];
$end_time = $map['examine.between_time'][1];
$map['examine.create_time'] = array('between', array($start_time, $end_time));
}
unset($map['examine.between_time']);
//审核状态 0 待审批 2 审批通过 4 审批拒绝 all 全部
if (isset($check_status)) {
if ($check_status == 'all') {
$map['examine.check_status'] = ['egt', 0];
if (isSuperAdministrators($user_id)) {
unset($map['examine.create_user_id']);
}
} elseif ($check_status == 4) {
$map['examine.check_status'] = ['eq', 3];
} elseif ($check_status == 0) {
$map['examine.check_status'] = ['<=', 1];
} else {
$map['examine.check_status'] = $check_status;
}
} else {
if ($examine_by == 'all') {
$map['examine.check_status'] = ['egt', 0];
} elseif ($examine_by == 1) {
$map['examine.check_status'] = ['elt', 1];
} elseif ($examine_by == 2) {
$map['examine.check_status'] = ['egt', 2];
}
}
$join = [
['__ADMIN_USER__ user', 'user.id = examine.create_user_id', 'LEFT'],
['__OA_EXAMINE_CATEGORY__ examine_category', 'examine_category.category_id = examine.category_id', 'LEFT'],
];
$list_view = db('oa_examine')
->alias('examine')
->where($map_str)
->where($map)
->join($join);
$res = [];
$list = $list_view
->page($request['page'], $request['limit'])
->field('examine.*,user.realname,user.thumb_img,examine_category.title as category_name,examine_category.category_id as examine_config,examine_category.icon as examineIcon')
->order($order)
->select();
foreach ($list as $k => $v) {
$causeCount = 0;
$causeTitle = '';
$duration = $v['duration'] ?: '0.0';
$money = $v['money'] ?: '0.00';
$list[$k]['causeTitle'] = $causeTitle;
$list[$k]['causeCount'] = $causeCount ?: 0;
$item = db('oa_examine_travel')->where(['examine_id' => $v['examine_id']])->select();
if ($item) {
foreach ($item as $key => $value) {
if($v['check_status']==4){
$usernames = '';
}else{
$usernames = db('admin_user')->whereIn('id', stringToArray($v['check_user_id']))->column('realname');
}
//关联业务
$relationArr = [];
$relationArr = $recordModel->getListByRelationId('examine', $v['examine_id']);
$item[$key]['relation'] = arrayToString(array_column($relationArr['businessList'], 'name')) . ' ' .
arrayToString(array_column($relationArr['contactsList'], 'name')) . ' ' .
arrayToString(array_column($relationArr['contractList'], 'name')) . ' ' .
arrayToString(array_column($relationArr['customerList'], 'name'));
$res[] = [
'category_name' => $v['category_name'],
'create_time' => !empty($v['create_time']) ? date('Y-m-d H:i:s', $v['create_time']) : null,
'realname' => $v['realname'],
'check_status_info' => $this->statusArr[(int)$v['check_status']],
'examine_name' => implode($usernames, ''),
'content' => $v['content'],
'remark' => $v['remark'],
'duration' => $v['duration'],
'vehicle' => $value['vehicle'],
'trip' => $value['trip'],
'money' => $value['money'],
'traffic' => $value['traffic'],
'stay' => $value['stay'],
'diet' => $value['diet'],
'other' => $value['other'],
'start_address' => $value['start_address'],
'end_address' => $value['end_address'],
'start_time' => !empty($value['start_time']) ? date('Y-m-d H:i:s', $value['start_time']) : null,
'end_time' => !empty($value['end_time']) ? date('Y-m-d H:i:s', $value['end_time']) : null,
'description' => $value['description'],
'replyList' => str_replace(',', ' ', $item[$key]['relation']),
];
}
} else {
$list[$k]['create_time'] = !empty($v['create_time']) ? date('Y-m-d H:i:s', $v['create_time']) : null;
$list[$k]['start_time'] = !empty($v['start_time']) ? date('Y-m-d H:i:s', $v['start_time']) : null;
$list[$k]['end_time'] = !empty($v['end_time']) ? date('Y-m-d H:i:s', $v['end_time']) : null;
if($v['check_status']==4){
$usernames = '';
}else{
$usernames = db('admin_user')->whereIn('id', stringToArray($v['check_user_id']))->column('realname');
}
//关联业务
$relationArr = [];
$relationArr = $recordModel->getListByRelationId('examine', $v['examine_id']);
$list[$k]['relation'] = arrayToString(array_column($relationArr['businessList'], 'name')) . ' ' .
arrayToString(array_column($relationArr['contactsList'], 'name')) . ' ' .
arrayToString(array_column($relationArr['contractList'], 'name')) . ' ' .
arrayToString(array_column($relationArr['customerList'], 'name'));
$res[] = [
'category_name' => $v['category_name'],
'create_time' => !empty($v['create_time']) ? date('Y-m-d H:i:s', $v['create_time']) : null,
'realname' => $v['realname'],
'check_status_info' => $this->statusArr[(int)$v['check_status']],
'examine_name' => implode($usernames, ''),
'content' => $v['content'],
'remark' => $v['remark'],
'duration' => $v['duration'],
'vehicle' => '',
'money' => $v['money'],
'traffic' => '',
'stay' => '',
'diet' => '',
'other' => '',
'start_address' => '',
'end_address' => '',
'start_time' => !empty($v['start_time']) ? date('Y-m-d H:i:s', $v['start_time']) : null,
'end_time' => !empty($v['end_time']) ? date('Y-m-d H:i:s', $v['end_time']) : null,
'description' => '',
'replyList' => str_replace(',', ' ', $item[$key]['relation']),
];
}
}
return $res;
}
/**
* 审批导出
* @param $param
@ -19,35 +205,125 @@ class ExamineLogic extends Common
public function excelExport($param)
{
$excelModel = new \app\admin\model\Excel();
$field_list1 = [
array('name' => '审批类型', 'field' => 'category_name', 'form_type' => 'text'),
array('name' => '创建时间', 'field' => 'create_time', 'form_type' => ''),
array('name' => '创建人', 'field' => 'create_user_id', 'form_type' => 'user'),
array('name' => '状态', 'field' => 'check_status_info','form_type' => ''),
array('name' => '当前审批人', 'field' => 'check_user_id','form_type' => 'userStr'),
// array('name' => '下一审批人', 'field' => 'last_user_id','form_type' => 'user'),
// array('name' => '关联业务', 'field' => 'relation','form_type' => ''),
];
// 导出的字段列表
$fieldModel = new \app\admin\model\Field();
$field_list = $fieldModel->getIndexFieldConfig('oa_examine', $param['user_id'], $param['category_id']);
$data = $this->getDataList($param);
$list = [];
switch ($param['category_id']) {
case '1' :
$field_list = [
'0' => ['name' => '审批类型', 'field' => 'category_name'],
'1' => ['name' => '创建时间', 'field' => 'create_time'],
'2' => ['name' => '创建人', 'field' => 'realname'],
'3' => ['name' => '状态', 'field' => 'check_status_info'],
'4' => ['name' => '当前审批人', 'field' => 'examine_name'],
'5' => ['name' => '备注', 'field' => 'description'],
'6' => ['name' => '关联业务', 'field' => 'replyList'],
];
break;
case '2' :
$field_list = [
'0' => ['name' => '审批类型', 'field' => 'category_name'],
'1' => ['name' => '创建时间', 'field' => 'create_time'],
'2' => ['name' => '创建人', 'field' => 'realname'],
'3' => ['name' => '状态', 'field' => 'check_status_info'],
'4' => ['name' => '当前审批人', 'field' => 'examine_name'],
'5' => ['name' => '审批内容', 'field' => 'content'],
'6' => ['name' => '开始时间', 'field' => 'start_time'],
'7' => ['name' => '结束时间', 'field' => 'end_time'],
'8' => ['name' => '时长', 'field' => 'duration'],
'9' => ['name' => '备注', 'field' => 'description'],
'10' => ['name' => '关联业务', 'field' => 'replyList'],
];
break;
case '3' :
$field_list = [
'0' => ['name' => '审批类型', 'field' => 'category_name'],
'1' => ['name' => '创建时间', 'field' => 'create_time'],
'2' => ['name' => '创建人', 'field' => 'realname'],
'3' => ['name' => '状态', 'field' => 'check_status_info'],
'4' => ['name' => '当前审批人', 'field' => 'examine_name'],
'5' => ['name' => '出差事由', 'field' => 'content'],
'6' => ['name' => '备注', 'field' => 'remark'],
'7' => ['name' => '出差总天数', 'field' => 'duration'],
'8' => ['name' => '交通工具', 'field' => 'vehicle'],
'9' => ['name' => '单程往返', 'field' => 'trip'],
'10' => ['name' => '出发城市', 'field' => 'start_address'],
'11' => ['name' => '目的城市', 'field' => 'end_address'],
'12' => ['name' => '开始时间', 'field' => 'start_time'],
'13' => ['name' => '结束时间', 'field' => 'end_time'],
'14' => ['name' => '出差备注', 'field' => 'description'],
'15' => ['name' => '时长', 'field' => 'duration'],
'16' => ['name' => '关联业务', 'field' => 'replyList'],
];
break;
case '4' :
$field_list = [
'0' => ['name' => '审批类型', 'field' => 'category_name'],
'1' => ['name' => '创建时间', 'field' => 'create_time'],
'2' => ['name' => '创建人', 'field' => 'realname',],
'3' => ['name' => '状态', 'field' => 'check_status_info'],
'4' => ['name' => '当前审批人', 'field' => 'examine_name'],
'5' => ['name' => '加班原因', 'field' => 'content'],
'6' => ['name' => '开始时间', 'field' => 'start_time'],
'7' => ['name' => '结束时间', 'field' => 'end_time'],
'8' => ['name' => '加班总天数', 'field' => 'duration'],
'9' => ['name' => '备注', 'field' => 'description'],
'10' => ['name' => '关联业务', 'field' => 'replyList'],
];
break;
case '5':
$field_list = [
'0' => ['name' => '审批类型', 'field' => 'category_name'],
'1' => ['name' => '创建时间', 'field' => 'create_time'],
'2' => ['name' => '创建人', 'field' => 'realname'],
'3' => ['name' => '状态', 'field' => 'check_status_info'],
'4' => ['name' => '当前审批人', 'field' => 'examine_name'],
'5' => ['name' => '差旅内容', 'field' => 'content'],
'6' => ['name' => '报销总金额', 'field' => 'money'],
'7' => ['name' => '备注', 'field' => 'remark'],
'8' => ['name' => '出发城市', 'field' => 'start_address'],
'9' => ['name' => '目的城市', 'field' => 'end_address'],
'10' => ['name' => '开始时间', 'field' => 'start_time'],
'11' => ['name' => '结束时间', 'field' => 'end_time'],
'12' => ['name' => '交通费', 'field' => 'traffic'],
'13' => ['name' => '住宿费', 'field' => 'stay'],
'14' => ['name' => '餐饮费', 'field' => 'diet'],
'15' => ['name' => '其他费用', 'field' => 'other'],
'16' => ['name' => '合计', 'field' => 'money'],
'17' => ['name' => '费用明细描述', 'field' => 'description'],
'18' => ['name' => '关联业务', 'field' => 'relation'],
];
break;
case '6' :
$field_list = [
'0' => ['name' => '审批类型', 'field' => 'category_name'],
'1' => ['name' => '创建时间', 'field' => 'create_time'],
'2' => ['name' => '创建人', 'field' => 'realname'],
'3' => ['name' => '状态', 'field' => 'check_status_info'],
'4' => ['name' => '当前审批人', 'field' => 'examine_name'],
'5' => ['name' => '借款事由', 'field' => 'content'],
'6' => ['name' => '开始时间', 'field' => 'start_time'],
'7' => ['name' => '结束时间', 'field' => 'end_time'],
'8' => ['name' => '借款金额', 'field' => 'money'],
'9' => ['name' => '备注', 'field' => 'description'],
'10' => ['name' => '关联业务', 'field' => 'replyList'],
];
break;
default :
$field_list = [
'0' => ['name' => '审批类型', 'field' => 'category_name'],
'1' => ['name' => '创建时间', 'field' => 'create_time'],
'2' => ['name' => '创建人', 'field' => 'realname'],
'3' => ['name' => '状态', 'field' => 'check_status_info'],
'4' => ['name' => '当前审批人', 'field' => 'examine_name'],
'5' => ['name' => '备注', 'field' => 'description'],
'6' => ['name' => '关联业务', 'field' => 'replyList'],
];
}
$file_name = 'oa_examine';
$temp_file = $param['temp_file'];
unset($param['temp_file']);
$page = $param['page'] ?: 1;
$model = model('Examine');
$field_list = array_merge_recursive($field_list1, $field_list);
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);
// $newData['list'] = $model->exportHandle($data['page']['list'], $field_list, 'oa_examine');
$newData['list'] = $data['page']['list'];
return $newData;
});
return $excelModel->dataExportCsv($file_name, $field_list, $data);
}
/**
* 审批数据
* @param $param
@ -65,9 +341,9 @@ class ExamineLogic extends Common
$query->where('a.check_user_id', ['like', '%' . $user_id . '%'])->whereOr('a.flow_user_id', ['like', '%' . $user_id . '%']);
};
} elseif ($param['status'] == 1) {
$where['a.check_status'] = ['in', [2,3]];
$whereOr = function ($query) use ( $user_id) {
$query->where('a.check_user_id',['like', '%' . $user_id . '%'])->whereOr('a.flow_user_id', ['like', '%' . $user_id . '%']);
$where['a.check_status'] = ['in', [2, 3]];
$whereOr = function ($query) use ($user_id) {
$query->where('a.check_user_id', ['like', '%' . $user_id . '%'])->whereOr('a.flow_user_id', ['like', '%' . $user_id . '%']);
};
} elseif ($param['status'] == 3) {
$where['a.check_status'] = ['lt', 5];
@ -98,7 +374,7 @@ class ExamineLogic extends Common
$list[$k]['customer_id_info']['customer_id'] = $v['customer_id'];
$list[$k]['customer_id_info']['name'] = $v['customer_name'];
$list[$k]['create_user_info'] = $userModel->getUserById($v['create_user_id']);
}
$dataCount = db('crm_contract')
->alias('a')
@ -135,7 +411,7 @@ class ExamineLogic extends Common
$list[$k]['create_user_info'] = $userModel->getUserById($v['create_user_id']);
$list[$k]['contract_id_info']['contract_id'] = $v['contract_id'];
$list[$k]['contract_id_info']['name'] = $v['contract_name'];
}
break;
case '3':
@ -153,7 +429,7 @@ class ExamineLogic extends Common
->select();
foreach ($list as $k => $v) {
$list[$k]['create_user_info'] = $userModel->getUserById($v['create_user_id']);
}
$dataCount = db('crm_invoice')
->alias('a')
@ -162,13 +438,13 @@ class ExamineLogic extends Common
->where($whereOr)
->count();
break;
}
foreach ($list as $key => $v) {
$list[$key]['create_time'] = date('Y-m-d H:i:s', $v['create_time']) ?: '';
}
$data = [];
$data['page']['list'] = $list;
$data['page']['dataCount'] = $dataCount ?: 0;
@ -184,5 +460,5 @@ class ExamineLogic extends Common
}
return $data;
}
}

@ -38,15 +38,8 @@ class LogLogic extends Common
public function getDataList($request)
{
$userModel = new \app\admin\model\User();
$structureModel = new \app\admin\model\Structure();
$fileModel = new \app\admin\model\File();
$commonModel = new \app\admin\model\Comment();
$BusinessModel = new \app\crm\model\Business();
$ContactsModel = new \app\crm\model\Contacts();
$ContractModel = new \app\crm\model\Contract();
$CustomerModel = new \app\crm\model\Customer();
$recordModel = new \app\admin\model\Record();
$user_id = $request['read_user_id'];
$by = $request['by'] ?: '';
@ -78,44 +71,39 @@ class LogLogic extends Common
}
$requestData = $this->requestData();
//获取权限范围内的员工
//获取权限范围内的员工
$auth_user_ids = getSubUserId();
if ($request['send_user_id'] && !in_array(trim(arrayToString($request['send_user_id']), ','), $auth_user_ids)) {
$map['log.create_user_id'] = $user_id;
} else {
if ($request['send_user_id'] && in_array(trim(arrayToString($request['send_user_id']), ','), $auth_user_ids)) {
$map['log.create_user_id'] = ['in', trim(arrayToString($request['send_user_id']), ',')];
$map['log.send_user_ids'] = ['like', '%,' . $request['read_user_id'] . ',%'];
} else {
$dataWhere['user_id'] = $user_id;
$dataWhere['structure_id'] = $request['structure_id'];
$dataWhere['auth_user_ids'] = $auth_user_ids;
$logMap = '';
switch ($by) {
case 'me' :
$map['log.create_user_id'] = $user_id;
break;
case 'other':
$logMap = function ($query) use ($dataWhere) {
$query->where('log.send_user_ids', array('like', '%,' . $dataWhere['user_id'] . ',%'))
->whereOr('log.send_structure_ids', array('like', '%,' . $dataWhere['structure_id'] . ',%'));
};
break;
default :
$logMap = function ($query) use ($dataWhere) {
$query->where('log.create_user_id', array('in', implode(',', $dataWhere['auth_user_ids'])))
->whereOr('log.send_user_ids', array('like', '%,' . $dataWhere['user_id'] . ',%'))
->whereOr('log.send_structure_ids', array('like', '%,' . $dataWhere['structure_id'] . ',%'));
};
break;
}
}
$dataWhere['user_id'] = $user_id;
$dataWhere['structure_id'] = $request['structure_id'];
$dataWhere['auth_user_ids'] = $auth_user_ids;
$logMap = '';
if ($request['send_user_id'] != '') {
$map['log.create_user_id'] = ['in', trim(arrayToString($request['send_user_id']), ',')];
}
switch ($by) {
case 'me' :
$map['log.create_user_id'] = $user_id;
break;
case 'other':
$logMap = function ($query) use ($dataWhere) {
$query->where('log.send_user_ids', array('like', '%,' . $dataWhere['user_id'] . ',%'))
->whereOr('log.send_structure_ids', array('like', '%,' . $dataWhere['structure_id'] . ',%'));
};
break;
default :
$logMap = function ($query) use ($dataWhere) {
$query->where('log.create_user_id', array('in', implode(',', $dataWhere['auth_user_ids'])))
->whereOr('log.send_user_ids', array('like', '%,' . $dataWhere['user_id'] . ',%'))
->whereOr('log.send_structure_ids', array('like', '%,' . $dataWhere['structure_id'] . ',%'));
};
break;
}
$list = Db::name('OaLog')
->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')
->order('log.update_time desc')
->select();
@ -651,11 +639,8 @@ class LogLogic extends Common
/**
* 销售简报跟进数量统计
* @param $param
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*
* @param $param 参数
*/
public function activityCount($param)
{
@ -665,17 +650,18 @@ class LogLogic extends Common
if (empty($param['log_id'])) {
$between_time = [$start_time['start_time'], $start_time['end_time']];
$map['create_time'] = array('between', $between_time);
$map['create_user_id'] =$user_id;
} else {
$start_time = strtotime(date("Y-m-d", $item['create_time']));
$end_time = strtotime(date("Y-m-d H:i:s", $item['create_time']));
$between_time = [$start_time, $end_time];
$map['create_time'] = array('between', $between_time);
$map['create_user_id'] = $item['create_user_id'];
}
$map['status']=1;
$typesList = ['1', '2', '3', '5', '6'];
foreach ($typesList as $k => $v) {
$activityData = db('crm_activity')->where($map)->where(['create_user_id' => $item['create_user_id'], 'type' => 1, 'activity_type' => $v])->count();
$activityData = db('crm_activity')->where($map)->where(['type' => 1, 'activity_type' => $v])->count();
if($v==1){
$arr[$k]['types'] ='crm_leads';
$arr[$k]['activity_type'] =1;
@ -693,7 +679,6 @@ class LogLogic extends Common
$arr[$k]['activity_type'] =6;
}
$arr[$k]['dataCount'] = $activityData;
}
$data = $arr;
return $data;

@ -15,8 +15,8 @@ class TaskLogic
$userModel = new \app\admin\model\User();
$taskModel = new TaskModel();
$recordModel = new \app\admin\model\Record();
$str = ','.$param['user_id'].',';
$str = ',' . $param['user_id'] . ',';
//自定义时间
$map['t.stop_time'] = $param['dueDate'] ? strtotime($param['dueDate'] . ' +1 month -1 day') : ['>=', 0];
$search = $param['search'];
@ -34,14 +34,14 @@ class TaskLogic
} else {
$where['t.status'] = [['=', 1], ['=', 5], 'OR'];
}
if ($param['main_user_id']) {
$where['t.main_user_id'] = $param['main_user_id'];
}
//项目id
$priority = ($param['priority'] || $param['priority'] == '0') ? $param['priority'] : ['in', [0, 1, 2, 3]];
$where['t.priority'] = $priority;
$where['t.priority'] = $priority;
if ($param['work_id'] != 0) {
$where['t.work_id'] = $param['work_id'];
$taskList = db('task')
@ -56,9 +56,9 @@ class TaskLogic
$where = [];
$where['ishidden'] = 0;
$where['pid'] = 0;
$where['whereStr'] = ' ( task.create_user_id =' . $param['user_id'] . ' or ( task.owner_user_id like "%,'.$param['user_id'].',%") or ( task.main_user_id = '.$param['user_id'].' ) )';
$where['whereStr'] = ' ( task.create_user_id =' . $param['user_id'] . ' or ( task.owner_user_id like "%,' . $param['user_id'] . ',%") or ( task.main_user_id = ' . $param['user_id'] . ' ) )';
if (!empty($this->param['search'])) {
$where['taskSearch'] = ' and (task.name like "%'.$this->param['search'].'%" OR task.description like "%'.$this->param['search'].'%")';
$where['taskSearch'] = ' and (task.name like "%' . $this->param['search'] . '%" OR task.description like "%' . $this->param['search'] . '%")';
}
# 截止日期
$timeWhere = $this->getTimeParam($param['time_type']);
@ -76,12 +76,11 @@ class TaskLogic
->join('AdminUser u', 'u.id = t.main_user_id', 'LEFT')
->field('t.task_id,t.name as task_name,t.main_user_id,t.description,t.priority,t.stop_time,t.create_time,t.owner_user_id,t.start_time,t.create_user_id,u.realname as main_user_name,t.is_top')
->where($where)
->where($whereStr)
->where($timeWhere)
->where($labelWhere)
->order('t.task_id desc')
->select();
} else {
///下属任务
if ($param['mold'] == 1) {
@ -96,21 +95,21 @@ class TaskLogic
if ($type != 0) {
switch ($type) {
case '1' :
$type = 't.main_user_id in ('.$subStr.')';
$type = 't.main_user_id in (' . $subStr . ')';
break; //下属负责的
case '3' :
//使用正则查询
// SELECT * FROM 5kcrm_task WHERE owner_user_id REGEXP '(,1,|,2,|,3,)';
$type = $subValue ? 't.owner_user_id REGEXP "('.$subValue.')"' : '';
$type = $subValue ? 't.owner_user_id REGEXP "(' . $subValue . ')"' : '';
break; //下属参与的
}
} else {
if (!$subValue) {
$type = 't.is_open = 1 AND (t.main_user_id in (' . $subStr . ') or t.create_user_id in (' . $subStr . '))';
} else {
$type .= 't.is_open = 1 AND (t.main_user_id in (' . $subStr . ') or t.create_user_id in (' . $subStr . ') or t.owner_user_id REGEXP "('.$subValue.')")';
$type .= 't.is_open = 1 AND (t.main_user_id in (' . $subStr . ') or t.create_user_id in (' . $subStr . ') or t.owner_user_id REGEXP "(' . $subValue . ')")';
}
}
}
$map['t.pid'] = 0;
$map['t.ishidden'] = 0;
$taskList = Db::name('Task')
@ -121,12 +120,12 @@ class TaskLogic
)
->where(function ($query) use ($type) {
$query->where($type);
})
})
->where($where)
->where($map)
->order('t.task_id desc')
->select();
} else {
->select();
} else {
$map['t.pid'] = 0;
// $map['t.work_id'] = 0;
if ($type != 0) {
@ -135,15 +134,15 @@ class TaskLogic
$type = 't.main_user_id =' . $param['user_id'] . '';
break; //我负责的
case '3' :
$type = 't.owner_user_id like "%,'.$param['user_id'].',%"';
$type = 't.owner_user_id like "%,' . $param['user_id'] . ',%"';
break; //我参与的
}
} else {
$adminIds = $userModel->getAdminId();
if (in_array($param['user_id'],$adminIds)) {
$type = 't.is_open = 1';
if (in_array($param['user_id'], $adminIds)) {
$type = 't.is_open = 1';
} else {
$type = 't.is_open = 1 AND (t.main_user_id =' . $param['user_id'] .' OR t.owner_user_id like "%,'.$param['user_id'].',%")';
$type = 't.is_open = 1 AND (t.main_user_id =' . $param['user_id'] . ' OR t.owner_user_id like "%,' . $param['user_id'] . ',%")';
}
}
$where['t.ishidden'] = 0;
@ -154,10 +153,9 @@ class TaskLogic
->where($where)
->where($type)
->where($map)
->page($param['page'], $param['limit'])
->order('t.task_id desc')
->select();
}
}
}
}
foreach ($taskList as $key => $value) {
@ -185,7 +183,7 @@ class TaskLogic
//创建时间
$taskList[$key]['create_time'] = $value['create_time'] ? date('Y-m-d H:i:s', $value['create_time']) : '';
//开始时间
$taskList[$key]['start_time'] = $value['start_time'] ? date('Y-m-d H:i:s', $value['start_time']) : '';
$taskList[$key]['start_time'] = $value['start_time'] ? date('Y-m-d H:i:s', $value['start_time']) : '';
//结束时间
$taskList[$key]['stop_time'] = $value['stop_time'] ? date('Y-m-d H:i:s', $value['stop_time']) : '';
//优先级
@ -217,14 +215,14 @@ class TaskLogic
}
return $taskList;
}
/**
* 任务导出
* @param $param
*/
public function excelExport($param)
{
$data = $this->getDataList($param);
$excelModel = new \app\admin\model\Excel();
if ($param['work_id'] != 0) {
@ -280,7 +278,7 @@ class TaskLogic
}
return $excelModel->taskExportCsv($file_name, $field_list, $title, $data);
}
public function where($param)
{
$taskModel = new TaskModel();
@ -289,11 +287,11 @@ class TaskLogic
$workModel = new WorkModel();
$userModel = new \app\admin\model\User();
$work_id = $param['work_id'] ?: '';
if ($param['main_user_id']) {
$map['t.main_user_id'] = ['in', $param['main_user_id']];
}
//截止时间
if ($param['stop_time_type']) {
if ($param['stop_time_type'] == '5') { //没有截至日期
@ -326,7 +324,7 @@ class TaskLogic
$map['t.stop_time'] = ['between', [$timeAry[0], $timeAry[1]]];
}
}
if ($param['lable_id']) {
$taskIds = [];
$task_ids = [];
@ -339,7 +337,7 @@ class TaskLogic
$lableWhere['ishidden'] = 0;
$lableWhere['pid'] = 0;
$lableWhere['is_archive'] = 0;
$task_id = $taskModel->where($lableWhere)->column('task_id');
if ($task_id && $task_ids) {
$task_ids = array_unique(array_filter(array_merge($task_ids, $task_id)));
@ -349,12 +347,12 @@ class TaskLogic
}
$map['t.task_id'] = ['in', $task_ids];
} else {
$map['t.task_id'] = $work_id;
}
return $map;
}
/**
* 获取截止日期参数
* @param $type
@ -363,46 +361,46 @@ class TaskLogic
private function getTimeParam($type)
{
$result = [];
# 今天
if ($type == 1) {
$result = '(task.stop_time > 0 AND task.stop_time <= ' . strtotime(date('Y-m-d 23:59:59')) . ')';
}
# 明天
if ($type == 2) {
$tomorrow = date("Y-m-d 23:59:59", strtotime("+1 day"));
$result = '(task.stop_time > 0 AND task.stop_time <= ' . strtotime($tomorrow) . ')';
}
# 本周
if ($type == 3) {
$week = mktime(23, 59, 59, date("m"), date("d") - date("w") + 7, date("Y"));
$result = '(task.stop_time > 0 AND task.stop_time <= ' . $week . ')';
}
# 本月
if ($type == 4) {
$month = mktime(23, 59, 59, date("m"), date("t"), date("Y"));
$result = '(task.stop_time > 0 AND task.stop_time <= ' . $month . ')';
}
# 未设置截止日期
if ($type == 5) {
$result = $result = '(task.stop_time = 0)';;
}
# 已延期
if ($type == 6) {
$result = '(task.status = 2 OR task.stop_time >= ' . time() . ')';
}
# 今日更新
if ($type == 7) {
$result = '(task.update_time >= ' . strtotime(date('Y-m-d 00:00:00')) . ' AND task.update_time <= ' . strtotime(date('Y-m-d 23:59:59')) . ')';
}
return $result;
}
}

@ -27,42 +27,49 @@ class UserLogic
$initials_type = ($param['initials'] == 1) ? 1 : 2;
$where['user.status'] = 1;
if ($search) {
$where = function ($query) use ($search) {
$whereMap = function ($query) use ($search) {
$query->where('user.realname', array('like', '%' . $search . '%'))
->whereOr('user.mobile', array('like', '%' . $search . '%'));
};
}
if ($param['star_type'] == 1) {
$item = Db::name('crm_star')->where('user_id', $user_id)->column('target_id');
$where['user.id'] = ['in', $item];
}
if ($param['structure_id'] == '') {
$list = Db::name('admin_user')
->alias('user')
->join('__ADMIN_STRUCTURE__ structure', 'structure.id = user.structure_id', 'LEFT')
->where($where)
->field('user.id,user.thumb_img,user.realname,user.post,structure.name as structure_name,user.mobile')
->page($param['page'], $param['limit'])
->select();
foreach ($list as $k => $v) {
$starWhere = ['user_id' => $user_id, 'target_id' => $v['id'], 'type' => 'admin_user'];
$star = Db::name('crm_star')->where($starWhere)->value('star_id');
$list[$k]['thumb_img'] = $v['thumb_img'] ? getFullPath($v['thumb_img']) : '';
$list[$k]['star'] = !empty($star) ? 1 : 0;
if($param['structure_id']){
$where['user.id']= $param['structure_id'];
}
if (isset($param['star_type'])) {
if ($param['star_type'] == 1) {
$item = Db::name('crm_star')->where(['user_id'=>$user_id,'type'=>'admin_user'])->column('target_id');
if(!empty($item)) {
$where['user.id'] = ['in', $item];
$list = Db::name('admin_user')
->alias('user')
->join('__ADMIN_STRUCTURE__ structure', 'structure.id = user.structure_id', 'LEFT')
->where($where)
->where($whereMap)
->field('user.id,user.thumb_img,user.realname,user.post,structure.name as structure_name,user.mobile')
->page($param['page'], $param['limit'])
->select();
foreach ($list as $k => $v) {
$starWhere = ['user_id' => $user_id, 'target_id' => $v['id'], 'type' => 'admin_user'];
$star = Db::name('crm_star')->where($starWhere)->value('star_id');
$list[$k]['thumb_img'] = $v['thumb_img'] ? getFullPath($v['thumb_img']) : '';
$list[$k]['star'] = !empty($star) ? 1 : 0;
}
$dataCount = Db::name('admin_user')
->alias('user')
->join('__ADMIN_STRUCTURE__ structure', 'structure.id = user.structure_id', 'LEFT')
->where($where)
->count();
$newarray = $this->groupByInitials($list, 'realname', $initials_type);
}else{
return false;
}
}
$dataCount = Db::name('admin_user')
->alias('user')
->join('__ADMIN_STRUCTURE__ structure', 'structure.id = user.structure_id', 'LEFT')
->where($where)
->count();
$newarray = $this->groupByInitials($list, 'realname', $initials_type);
} else {
$list = Db::name('admin_user')
->alias('user')
->join('__ADMIN_STRUCTURE__ structure', 'structure.id = user.structure_id', 'LEFT')
->where($where)
->where('structure.id', $param['structure_id'])
->where($whereMap)
->field('user.id,user.thumb_img,user.realname,user.post,structure.name as structure_name')
->page($param['page'], $param['limit'])
->select();
@ -70,7 +77,6 @@ class UserLogic
->alias('user')
->join('__ADMIN_STRUCTURE__ structure', 'structure.id = user.structure_id', 'LEFT')
->where($where)
->where('structure.id', $param['structure_id'])
->count();
foreach ($list as $k => $v) {
$starWhere = ['user_id' => $user_id, 'target_id' => $v['id'], 'type' => 'admin_user'];

@ -30,7 +30,7 @@ class Event extends Common
'start_time' => 'timestamp',
'end_time' => 'timestamp',
];
/**
* [getDataList 日程list]
* @param [by] $by [查询时间段类型]
@ -42,7 +42,7 @@ class Event extends Common
$userModel = new \app\admin\model\User();
$recordModel = new \app\admin\model\Record();
$user_id = $param['user_id'];
//默认本账户or 自定义用户id
if ($param['start_time'] && $param['end_time']) {
$start_time = $param['start_time'];
@ -51,38 +51,35 @@ class Event extends Common
$start_time = mktime(0, 0, 0, date('m'), 1, date('Y'));
$end_time = mktime(23, 59, 59, date('m'), date('t'), date('Y'));
}
$where = '( ( start_time BETWEEN ' . $start_time . ' AND ' . $end_time . ' ) AND ( create_user_id = ' . $user_id . ' or owner_user_ids like "%,' . $user_id . ',%" ) )
OR ( ( end_time BETWEEN ' . $start_time . ' AND ' . $end_time . ' ) AND ( create_user_id = ' . $user_id . ' or owner_user_ids like "%,' . $user_id . ',%" ) )
OR ( start_time < ' . $start_time . ' AND end_time > ' . $end_time . ' AND ( create_user_id = ' . $user_id . ' or owner_user_ids like "%,' . $user_id . ',%" ) )';
$event_date = Db::name('OaEvent')->where($where)->select();
foreach ($event_date as $k => $v) {
foreach ($event_date as $k=>$v) {
$event_date[$k]['create_user_info'] = $userModel->getUserById($v['create_user_id']);
$event_date[$k]['ownerList'] = $userModel->getDataByStr($v['owner_user_ids']) ?: [];
$relationArr = [];
$event_date[$k]['ownerList'] = $userModel->getDataByStr($v['owner_user_ids']) ? : [];
$relationArr= [];
$relationArr = $recordModel->getListByRelationId('event', $v['event_id']);
$event_date[$k]['businessList'] = $relationArr['businessList'];
$event_date[$k]['contactsList'] = $relationArr['contactsList'];
$event_date[$k]['contractList'] = $relationArr['contractList'];
$event_date[$k]['customerList'] = $relationArr['customerList'];
$event_date[$k]['type'] = 'event';
$event_date[$k]['remindtype'] = (int)$v['remindtype'];
$noticeInfo = Db::name('OaEventNotice')->where(['event_id' => $v['event_id']])->find();
$is_repeat = 0;
if ($noticeInfo) {
$is_repeat = 1;
}
$color = db('admin_oa_schedule')->where('schedule_id', $v['schedule_id'])->find();
$event_date[$k]['color'] = $color['color'];
$event_date[$k]['is_repeat'] = $is_repeat;
$event_date[$k]['stop_time'] = $noticeInfo ? $noticeInfo['stop_time'] : '';
$event_date[$k]['noticetype'] = $noticeInfo ? $noticeInfo['noticetype'] : '';
if ($noticeInfo['noticetype'] == '2') {
$event_date[$k]['repeat'] = $noticeInfo['repeated'] ? explode('|||', $noticeInfo['repeated']) : [];
$event_date[$k]['repeat'] = $noticeInfo['repeated'] ? explode('|||',$noticeInfo['repeated']) : [];
} else {
$event_date[$k]['repeat'] = '';
$event_date[$k]['repeat'] = '';
}
//权限
$is_update = 0;
@ -93,17 +90,15 @@ class Event extends Common
}
$permission['is_update'] = $is_update;
$permission['is_delete'] = $is_delete;
$event_date[$k]['permission'] = $permission;
$event_date[$k]['permission'] = $permission;
$event_date[$k]['start_time'] = !empty($v['start_time']) ? $v['start_time'] * 1000 : null;
$event_date[$k]['end_time'] = !empty($v['end_time']) ? $v['end_time'] * 1000 : null;
$event_date[$k]['type_id'] = $v['schedule_id'];
}
return $event_date ?: [];
return $event_date ? : [];
}
/**
* 系统自定义类型数据(任务)
*
@ -116,7 +111,7 @@ class Event extends Common
public function eventTask($param)
{
$user_id = $param['user_id'];
// 默认本账户or 自定义用户id
if ($param['start_time'] && $param['end_time']) {
$start_time = $param['start_time'];
@ -129,7 +124,7 @@ class Event extends Common
'((stop_time BETWEEN ' . $start_time . ' AND ' . $end_time . ' ) AND ( create_user_id = ' . $user_id . ' or owner_user_id like "%,' . $user_id . ',%"))
OR ((stop_time > ' . $start_time . ' AND stop_time <' . $end_time . ') AND ( create_user_id = ' . $user_id . ' or owner_user_id like "%,' . $user_id . ',%"))
OR ((stop_time > ' . $start_time . ' AND stop_time >' . $end_time . ') AND ( create_user_id = ' . $user_id . ' or owner_user_id like "%,' . $user_id . ',%"))';
//分配的任务 负责人或参与人是当前用户
$event_date = db('task')->where(['stop_time' => ['>', 0], 'ishidden' => ['=', 0]])->where($between_time)
->field('task_id,name,start_time,stop_time')->select();
@ -142,7 +137,7 @@ class Event extends Common
}
return $event_date;
}
/**
* 系统自定义类型数据(客户)
*
@ -157,8 +152,8 @@ class Event extends Common
$userModel = new \app\admin\model\User();
$recordModel = new \app\admin\model\Record();
$user_id = $param['user_id'];
//默认本账户or 自定义用户id
if ($param['start_time'] && $param['end_time']) {
$start_time = $param['start_time'];
@ -174,7 +169,7 @@ class Event extends Common
$between_time = '((next_time BETWEEN ' . $start_time . ' AND ' . $end_time . ') AND ( create_user_id = ' . $user_id . ' or owner_user_id = ' . $user_id . '))
OR ((next_time > ' . $start_time . ' AND next_time <' . $end_time . ') AND ( create_user_id = ' . $user_id . ' or owner_user_id =' . $user_id . '))
OR ((next_time > ' . $start_time . ' AND next_time > ' . $end_time . ') AND ( create_user_id = ' . $user_id . ' or owner_user_id = ' . $user_id . '))';
$event_date = db('crm_customer')->where(['next_time'=> ['>', 0],'owner_user_id'=>['<>',0]])->where($between_time)->where('')
$event_date = db('crm_customer')->where(['next_time' => ['>', 0], 'owner_user_id' => ['<>', 0]])->where($between_time)->where('')
->field('next_time as start_time,customer_id,name ')->group('start_time')->select();
$item = [];
foreach ($event_date as $k2 => $v) {
@ -233,10 +228,10 @@ class Event extends Common
$event_date[$k4]['stop_time'] = !empty($v['start_time']) ? strtotime($v['start_time']) * 1000 : null;
$item[] = $v['start_time'] ? $v['start_time'] : '';
}
$list_data['receivables'] = $item ? array_values(array_unique($item)) : [];
//需联系的线索 next_time
$between_time = '(( next_time BETWEEN ' . $start_time . ' AND ' . $end_time . ')AND ( create_user_id = ' . $user_id . ' or owner_user_id = ' . $user_id . ' ))
OR ((next_time > ' . $start_time . ' AND next_time <' . $end_time . ') AND ( create_user_id = ' . $user_id . ' or owner_user_id = ' . $user_id . ' ))
@ -256,14 +251,14 @@ class Event extends Common
$event_date[$k5]['stop_time'] = !empty($v['start_time']) ? $v['start_time'] * 1000 : null;
$item[] = $v['start_time'] ? date('Y-m-d', $v['start_time']) : '';
}
$list_data['leads'] = $item ? array_values(array_unique($item)) : [];
//需联系的商机 next_time
$between_time =
'((next_time BETWEEN ' . $start_time . ' AND ' . $end_time . ' ) AND ( create_user_id = ' . $user_id . ' or owner_user_id = ' . $user_id . ' ))
OR ((next_time > ' . $start_time . ' AND next_time <' . $end_time . ') AND ( create_user_id = ' . $user_id . ' or owner_user_id = ' . $user_id . ' ))
OR ((next_time > ' . $start_time . ' AND next_time >' . $end_time . ') AND ( create_user_id = ' . $user_id . ' or owner_user_id = ' . $user_id . ' ))';
$event_date = db('crm_business')->where($between_time)->where('next_time', '>', 0)->field('next_time as start_time,business_id,name ')->select();
unset($item);
foreach ($event_date as $k6 => $v) {
@ -273,10 +268,10 @@ class Event extends Common
$event_date[$k6]['start_time'] = !empty($v['start_time']) ? strtotime($v['start_time']) * 1000 : null;
$event_date[$k6]['stop_time'] = !empty($v['start_time']) ? strtotime($v['start_time']) * 1000 : null;
$item[] = $v['start_time'] ? date('Y-m-d', $v['start_time']) : '';
}
$list_data['businessNext'] = $item ? array_values(array_unique($item)) : [];
//需要联系的客户 next_time crm_customer
$return_time = date('Y-m-d', $start_time);
$return_end = date('Y-m-d', $end_time);
@ -292,7 +287,7 @@ class Event extends Common
->field('deal_date as start_time,business_id,name')
->group('start_time')
->select();
unset($item);
foreach ($event_date as $k7 => $v) {
$event_date[$k7]['color'] = 7;
@ -305,7 +300,7 @@ class Event extends Common
$list_data['business'] = $item ? array_values(array_unique($item)) : [];
return $list_data ?: [];
}
/**
* 日历上显示
* @return array
@ -316,7 +311,7 @@ class Event extends Common
public function listStatus($param)
{
$userId = $param['user_id'];
if ($param['start_time'] && $param['end_time']) {
$start_time = $param['start_time'];
$end_time = $param['end_time'];
@ -324,7 +319,7 @@ class Event extends Common
$start_time = mktime(0, 0, 0, date('m'), 1, date('Y'));
$end_time = mktime(23, 59, 59, date('m'), date('t'), date('Y'));
}
$list = Db::name('oa_event')->where(['end_time' => ['>', 0], 'start_time' => ['>', 0]])
->where(function ($query) use ($userId) {
$query->whereOr('create_user_id', $userId);
@ -336,7 +331,7 @@ class Event extends Common
}
return $list;
}
/**
* 类型列表
* @return array|void
@ -367,7 +362,7 @@ class Event extends Common
$data['list'] = $list;
return $data;
}
/**
* 修改展示类型
* @param $param
@ -395,11 +390,11 @@ class Event extends Common
->whereIn('schedule_id', arrayToString($param['schedule_id']))
->update(['type' => 1]);
}
} else {
db('admin_oa_schedule_relation')->where('user_id', $param['user_id'])->insert(['schedule_id' => $v, 'user_id' => $param['user_id'], 'type' => 1, 'create_time' => time()]);
}
} else {
db('admin_oa_schedule_relation')->where('user_id', $param['user_id'])->insert(['schedule_id' => $v, 'user_id' => $param['user_id'], 'type' => 1, 'create_time' => time()]);
}
@ -407,7 +402,7 @@ class Event extends Common
$data = [];
return $data;
}
/**
* 创建日程信息
*
@ -428,27 +423,27 @@ class Event extends Common
$param['create_time'] = time();
$param['update_time'] = time();
unset($param['user_id']);
# 关联数据
$relation = [];
if (!empty($param['customer_ids'])) $relation['customer_ids'] = arrayToString($param['customer_ids']);
if (!empty($param['contacts_ids'])) $relation['contacts_ids'] = arrayToString($param['contacts_ids']);
if (!empty($param['business_ids'])) $relation['business_ids'] = arrayToString($param['business_ids']);
if (!empty($param['contract_ids'])) $relation['contract_ids'] = arrayToString($param['contract_ids']);
# 提醒数据
$notice = $param['notice'];
# 删除多余字段
unset($param['customer_ids']);
unset($param['contacts_ids']);
unset($param['business_ids']);
unset($param['contract_ids']);
unset($param['notice']);
if ($this->allowField(true)->save($param)) {
$eventId = $this->event_id;
# 提醒
if (!empty($notice)) {
$noticeData = [];
@ -467,18 +462,18 @@ class Event extends Common
}
if (!empty($noticeData)) Db::name('oa_event_notice')->insertAll($noticeData);
}
# 关联数据
if (!empty($relation)) {
$relation['event_id'] = $eventId;
$relation['status'] = 1;
$relation['create_time'] = time();
Db::name('oa_event_relation')->insert($relation);
}
actionLog($eventId, $param['owner_user_ids'], '', '创建了日程');
$data['event_id'] = $eventId;
// 站内信
$item = Db::name('oa_event_notice')->where('event_id', $eventId)->select();
@ -500,18 +495,18 @@ class Event extends Common
],
stringToArray($param['owner_user_ids'])
);
}
return $data;
} else {
$this->error = '添加失败';
return false;
}
}
/**
* 即将到期合同列表
* @param $param
@ -562,13 +557,13 @@ class Event extends Common
$event_date[$k]['return_date'] = $v['return_date'] ? $v['return_date'] : null;
}
}
$data = [];
$data['list'] = $event_date;
$data['countData'] = $count;
return $data;
}
/**
* 续联系客户
* @param $param
@ -605,7 +600,7 @@ class Event extends Common
$data['countData'] = $count;
return $data;
}
/**
* 续联系客户
* @param $param
@ -642,7 +637,7 @@ class Event extends Common
$data['countData'] = $count;
return $data;
}
/**
* 计划回款
* @param $param
@ -659,7 +654,7 @@ class Event extends Common
//需要联系的客户 next_time crm_customer
$between_time['business.next_time'] = ['between', [$return_time, $return_end]];
$between_time['business.create_user_id|business.owner_user_id'] = ['eq', $user_id];
$event_date = db('crm_business')
->alias('business')
->join('__ADMIN_USER__ user', 'user.id = business.owner_user_id', 'LEFT')
@ -682,7 +677,7 @@ class Event extends Common
$data['countData'] = $count;
return $data;
}
/**
* 预计成交商机
* @param $param
@ -719,7 +714,7 @@ class Event extends Common
$data['countData'] = $count;
return $data;
}
/**
* 公共时间处理
* @param $param
@ -728,8 +723,8 @@ class Event extends Common
{
$userModel = new \app\admin\model\User();
$recordModel = new \app\admin\model\Record();
//默认本账户or 自定义用户id
if ($param['start_time'] && $param['end_time']) {
$start_time = $param['start_time'];
@ -744,7 +739,7 @@ class Event extends Common
$data = [$start_time, $end_time];
return $data;
}
/**
* 编辑日程信息
*
@ -776,35 +771,35 @@ class Event extends Common
$param['end_time'] = !empty($param['end_time']) ? strtotime($param['end_time']) : $todayTime[1];
$param['update_time'] = time();
unset($param['user_id']);
# 关联数据
$relation = [];
if (!empty($param['customer_ids'])) $relation['customer_ids'] = arrayToString($param['customer_ids']);
if (!empty($param['contacts_ids'])) $relation['contacts_ids'] = arrayToString($param['customer_ids']);
if (!empty($param['business_ids'])) $relation['business_ids'] = arrayToString($param['customer_ids']);
if (!empty($param['contract_ids'])) $relation['contract_ids'] = arrayToString($param['customer_ids']);
if (!empty($param['contacts_ids'])) $relation['contacts_ids'] = arrayToString($param['contacts_ids']);
if (!empty($param['business_ids'])) $relation['business_ids'] = arrayToString($param['business_ids']);
if (!empty($param['contract_ids'])) $relation['contract_ids'] = arrayToString($param['contract_ids']);
# 提醒数据
$notice = $param['notice'];
# 删除多余字段
unset($param['customer_ids']);
unset($param['contacts_ids']);
unset($param['business_ids']);
unset($param['contract_ids']);
unset($param['notice']);
if ($this->allowField(true)->save($param, ['event_id' => $event_id])) {
$eventId = $this->event_id;
actionLog($event_id, $param['owner_user_ids'], '', '修改了日程');
$list = db('oa_event_notice')->where('event_id', $eventId)->select();
$item = Db::name('OaEventNotice')->where(['event_id' => $eventId])->delete();
if (!$item) {
if ($list) {
foreach ($list as $k => $v) {
Db::name('admin_message')->where(['type' => 9, 'action_id' => $v['id']])->delete();
}
}
$item = Db::name('OaEventNotice')->where(['event_id' => $eventId])->delete();
# 提醒
if (!empty($notice)) {
$noticeData = [];
@ -813,7 +808,7 @@ class Event extends Common
if ($value['type'] == 1) $startTime = $param['start_time'] - ($value['number'] * 60);
if ($value['type'] == 2) $startTime = $param['start_time'] - ($value['number'] * 60 * 60);
if ($value['type'] == 3) $startTime = $param['start_time'] - ($value['number'] * 60 * 60 * 24);
$noticeData[] = [
'event_id' => $eventId,
'noticetype' => $value['type'],
@ -822,47 +817,54 @@ class Event extends Common
'stop_time' => $param['end_time']
];
}
if (!empty($noticeData)) Db::name('oa_event_notice')->insertAll($noticeData);
}
if (!$item) {
$item = Db::name('OaEventNotice')->where('event_id', $eventId)->select();
foreach ($item as $val) {
if ($value['noticetype'] == '1') { //分
$dd = strtotime($param['start_time']) - ($val['number'] * 60);
} else if ($val['noticetype'] == '2') { //时
$dd = strtotime($param['start_time']) - ($val['number'] * 60 * 60);
} else if ($val['noticetype'] == '3') {//天
$dd = strtotime($param['start_time']) - ($val['number'] * 60 * 60 * 24);
if (!empty($noticeData)) {
$item = Db::name('oa_event_notice')->insertAll($noticeData);
if ($item) {
$item = Db::name('oa_event_notice')->where('event_id', $eventId)->select();
foreach ($item as $val) {
if ($value['noticetype'] == '1') { //分
$dd = strtotime($param['start_time']) - ($val['number'] * 60);
} else if ($val['noticetype'] == '2') { //时
$dd = strtotime($param['start_time']) - ($val['number'] * 60 * 60);
} else if ($val['noticetype'] == '3') {//天
$dd = strtotime($param['start_time']) - ($val['number'] * 60 * 60 * 24);
}
// 站内信
(new Message())->send(
Message::EVENT_MESSAGE,
[
'title' => $param['title'],
'action_id' => $val['id'],
'advance_time' => $dd ?: 0
],
stringToArray($param['owner_user_ids'])
);
}
}
// 站内信
(new Message())->send(
Message::EVENT_MESSAGE,
[
'title' => $param['title'],
'action_id' => $val['id'],
'advance_time' => $dd ?: 0
],
array_diff(stringToArray($param['owner_user_ids']), stringToArray($dataInfo['owner_user_ids']))
);
}
}
$data['event_id'] = $event_id;
Db::name('OaEventRelation')->where(['event_id' => $event_id])->update([
'customer_ids' => trim($relation['customer_ids'], ','),
'contacts_ids' => trim($relation['contacts_ids'], ','),
'business_ids' => trim($relation['business_ids'], ','),
'contract_ids' => trim($relation['contract_ids'], ','),
]);
$data['event_id'] = $event_id;
if (Db::name('OaEventRelation')->where(['event_id' => $event_id])->find()) {
Db::name('OaEventRelation')->where(['event_id' => $event_id])->update($relation);
} else {
if (!empty($relation)) {
$relation['event_id'] = $eventId;
$relation['status'] = 1;
$relation['create_time'] = time();
Db::name('OaEventRelation')->where(['event_id' => $event_id])->insert($relation);
}
}
return $data;
} else {
$this->error = '编辑失败';
return false;
}
}
/**
* 日程数据
*
@ -876,25 +878,25 @@ class Event extends Common
{
# 日程数据
$eventData = Db::name('oa_event')->where('event_id', $eventId)->find();
# 颜色类型
$eventData['color'] = Db::name('admin_oa_schedule')->where('schedule_id', $eventData['schedule_id'])->value('color');
# 创建人信息
$eventData['create_user_name'] = Db::name('admin_user')->where('id', $eventData['create_user_id'])->value('realname');
# 参与人信息
$eventData['owner_user_info'] = Db::name('admin_user')->field(['id', 'realname'])->whereIn('id', trim($eventData['owner_user_ids'], ','))->select();
# 处理日程的日期数据
$eventData['start_time'] = !empty($eventData['start_time']) ? date('Y-m-d H:i:s', $eventData['start_time']) : '';
$eventData['end_time'] = !empty($eventData['end_time']) ? date('Y-m-d H:i:s', $eventData['end_time']) : '';
$eventData['create_time'] = !empty($eventData['create_time']) ? date('Y-m-d H:i:s', $eventData['create_time']) : '';
$eventData['update_time'] = !empty($eventData['update_time']) ? date('Y-m-d H:i:s', $eventData['update_time']) : '';
# 日程提醒数据
$noticeData = Db::name('oa_event_notice')->where('event_id', $eventId)->select();
# 整理日程提醒数据
$eventData['notice'] = [];
foreach ($noticeData as $key => $value) {
@ -903,10 +905,10 @@ class Event extends Common
'value' => $value['number']
];
}
# 关联客户数据
$relationData = Db::name('oa_event_relation')->where('event_id', $eventId)->find();
# 关联的客户数据
$eventData['customer'] = [];
if (!empty($relationData['customer_ids'])) {
@ -927,10 +929,10 @@ class Event extends Common
if (!empty($relationData['contract_ids'])) {
$eventData['contract'] = Db::name('crm_contract')->field(['contract_id', 'name'])->whereIn('contract_id', trim($relationData['contract_ids'], ','))->select();
}
return $eventData;
}
//根据ID 删除日程
public function delDataById($param)
{
@ -939,12 +941,12 @@ class Event extends Common
$this->error = '数据不存在或已删除';
return false;
}
if ($dataInfo['create_user_id'] != $param['user_id']) {
$this->error = '没有编辑权限';
return false;
}
$map['event_id'] = $param['event_id'];
$map['create_user_id'] = $param['user_id'];
$flag = $this->where($map)->delete();

@ -23,8 +23,8 @@ class Examine extends Common
protected $createTime = 'create_time';
protected $updateTime = 'update_time';
protected $autoWriteTimestamp = true;
private $statusArr = ['待审核','审核中','审核通过','已拒绝','已撤回'];
private $statusArr = ['待审核', '审核中', '审核通过', '已拒绝', '已撤回'];
/**
* [getDataList 审批list]
* @param [string] $map [查询条件]
@ -38,11 +38,13 @@ class Examine extends Common
$userModel = new \app\admin\model\User();
$fileModel = new \app\admin\model\File();
$recordModel = new \app\admin\model\Record();
$examine_by = $request['examine_by']; //1待我审批 2我已审批 all 全部
$user_id = $request['user_id'];
$bi = $request['bi_types'];
$check_status = $request['check_status']; //0 待审批 2 审批通过 4 审批拒绝 all 全部
unset($request['by']);
unset($request['bi_types']);
unset($request['user_id']);
unset($request['check_status']);
unset($request['examine_by']);
@ -56,8 +58,8 @@ class Examine extends Common
}
unset($map['search']);
//审批类型
$map['examine.category_id'] = $map['examine.category_id'] ? : array('gt', 0);
$map['examine.category_id'] = $map['examine.category_id'] ?: array('gt', 0);
$map_str = '';
$logmap = '';
switch ($examine_by) {
@ -71,7 +73,9 @@ class Examine extends Common
$map['check_user_id'] = [['like', '%,' . $user_id . ',%']];
break; //待审
case '2' :
$map['flow_user_id'] = [['like', '%,' . $user_id . ',%'], ['eq', $user_id], 'or'];
$map_str = "(( check_user_id LIKE '%," . $user_id . ",%' OR check_user_id = " . $user_id . " )
OR ( flow_user_id LIKE '%," . $user_id . ",%' OR `flow_user_id` = " . $user_id . " ) )";
// $map['flow_user_id'] = [['like', '%,' . $user_id . ',%'], ['eq', $user_id], 'or'];
break; //已审
default:
$map['examine.create_user_id'] = $user_id;
@ -85,9 +89,9 @@ class Examine extends Common
$map['examine.create_time'] = array('between', array($start_time, $end_time));
}
unset($map['examine.between_time']);
//审核状态 0 待审批 2 审批通过 4 审批拒绝 all 全部
if ($check_status) {
if (isset($check_status)) {
if ($check_status == 'all') {
$map['examine.check_status'] = ['egt', 0];
if (isSuperAdministrators($user_id)) {
@ -95,13 +99,20 @@ class Examine extends Common
}
} elseif ($check_status == 4) {
$map['examine.check_status'] = ['eq', 3];
} elseif ($check_status == 0) {
$map['examine.check_status'] = ['<=', 1];
} else {
$map['examine.check_status'] = $check_status;
}
} else {
$map['examine.check_status'] = ['egt', 0];
}
}else{
if ($examine_by == 'all') {
$map['examine.check_status'] = ['egt', 0];
} elseif ($examine_by == 1) {
$map['examine.check_status'] = ['elt', 1];
} elseif($examine_by == 2) {
$map['examine.check_status'] = ['egt', 2];
}
}
$join = [
['__ADMIN_USER__ user', 'user.id = examine.create_user_id', 'LEFT'],
['__OA_EXAMINE_CATEGORY__ examine_category', 'examine_category.category_id = examine.category_id', 'LEFT'],
@ -111,7 +122,7 @@ class Examine extends Common
->where($map_str)
->where($map)
->join($join);
$list = $list_view
->page($request['page'], $request['limit'])
->field('examine.*,user.realname,user.thumb_img,examine_category.title as category_name,examine_category.category_id as examine_config,examine_category.icon as examineIcon')
@ -123,7 +134,7 @@ class Examine extends Common
->join($join)
->count('examine_id');
$admin_user_ids = $userModel->getAdminId();
foreach ($list as $k => $v) {
$list[$k]['create_user_info'] = $userModel->getUserById($v['create_user_id']);
$causeCount = 0;
@ -131,10 +142,10 @@ class Examine extends Common
$duration = $v['duration'] ?: '0.0';
$money = $v['money'] ?: '0.00';
if (in_array($v['category_id'], ['3', '5'])) {
$causeCount = db('oa_examine_travel')->where(['examine_id' => $v['examine_id']])->count() ? : 0;
$causeCount = db('oa_examine_travel')->where(['examine_id' => $v['examine_id']])->count() ?: 0;
if ($v['category_id'] == 3) $causeTitle = $causeCount . '个行程,共' . $duration . '天';
if ($v['category_id'] == 5) $causeTitle = $causeCount . '个报销事项,共' . $money . '元';
//附件
$fileList = [];
$imgList = [];
@ -152,11 +163,11 @@ class Examine extends Common
}
$list[$k]['fileList'] = $fileList ?: [];
$list[$k]['imgList'] = $imgList ?: [];
}
$list[$k]['causeTitle'] = $causeTitle;
$list[$k]['causeCount'] = $causeCount ? : 0;
$list[$k]['causeCount'] = $causeCount ?: 0;
//关联业务
$relationArr = [];
$relationArr = $recordModel->getListByRelationId('examine', $v['examine_id']);
@ -164,7 +175,7 @@ class Examine extends Common
$list[$k]['contactsList'] = $relationArr['contactsList'];
$list[$k]['contractList'] = $relationArr['contractList'];
$list[$k]['customerList'] = $relationArr['customerList'];
//附件
$fileList = [];
$imgList = [];
@ -182,7 +193,7 @@ class Examine extends Common
}
$list[$k]['fileList'] = $fileList ?: [];
$list[$k]['imgList'] = $imgList ?: [];
//创建人或管理员有撤销权限
$permission = [];
$is_recheck = 0;
@ -195,7 +206,7 @@ class Examine extends Common
$is_recheck = 1;
}
}
//创建人(失败、撤销状态时可编辑)
if ($v['create_user_id'] == $user_id && in_array($v['check_status'], ['3', '4'])) {
$is_update = 1;
@ -210,25 +221,25 @@ class Examine extends Common
if ($examineFlowData['config'] == 1) {
//固定审批流
$examineStepModel = new \app\admin\model\ExamineStep();
$nextStepData = $examineStepModel->nextStepUser($user_id, $examineFlowData['flow_id'], 'oa_examine', 0, 0, 0);
$is_check = $nextStepData['next_user_ids'] ? 1 : 0;
// $nextStepData = $examineStepModel->nextStepUser($user_id, $examineFlowData['flow_id'], 'oa_examine', 0, 0, 0);
$is_check = in_array($user_id, stringToArray($v['check_user_id'])) && in_array($v['check_status'], [0, 1]) ? 1 : 0;
$is_end = 1;
} else {
$is_end = 0;
if ($v['check_user_id'] == (',' . $user_id . ',')) {
if ($v['check_user_id'] == (',' . $user_id . ',') && in_array($v['check_status'], [0, 1])) {
$is_check = 1;
}else{
} else {
$is_check = 0;
}
}
if ($v['last_user_id'] == 0) {
$user_name = $userModel->getListByStr(stringToArray($v['check_user_id']));
$list[$k]['examine_name'] = $user_name[0]['realname'];
} else {
$user_name = $userModel->getListByStr(stringToArray($v['last_user_id']));
$list[$k]['examine_name'] = $user_name[0]['realname'];
}
if($v['check_status']==4){
$usernames = db('admin_user')->whereIn('id', stringToArray($user_id))->column('realname');
}else{
$usernames = db('admin_user')->whereIn('id', stringToArray($v['check_user_id']))->column('realname');
}
$list[$k]['examine_name'] = implode($usernames, '');
$permission['is_check'] = $is_check;
$permission['is_delete'] = $is_delete;
$permission['is_recheck'] = $is_recheck;
@ -236,12 +247,13 @@ class Examine extends Common
$list[$k]['permission'] = $permission;
$list[$k]['config'] = $is_end;
$list[$k]['check_status_info'] = $this->statusArr[(int)$v['check_status']];
$list[$k]['create_time'] = date('Y-m-d H:i:s', $v['create_time']);
$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;
}
$data = [];
$data['page']['list'] = $list;
$data['page']['dataCount'] = $dataCount ?: 0;
if ($request['page'] != 1 && (int)($request['page'] * $request['limit']) >= (int)$dataCount) {
$data['page']['firstPage'] = false;
$data['page']['lastPage'] = true;
@ -254,7 +266,7 @@ class Examine extends Common
}
return $data;
}
/**
* 创建审批信息
* @param
@ -279,9 +291,9 @@ class Examine extends Common
$this->error = $validate->getError();
return false;
}
$categoryInfo = $examineCategoryModel->getDataById($param['category_id']);
$fileArr = $param['file_id']; //接收表单附件
unset($param['file_id']);
$param['start_time'] = $param['start_time'] ? strtotime($param['start_time']) : 0;
@ -309,7 +321,7 @@ class Examine extends Common
$rdata['status'] = 1;
$rdata['create_time'] = time();
Db::name('OaExamineRelation')->insert($rdata);
//处理差旅相关
$resTravel = true;
if (in_array($param['category_id'], ['3', '5']) && $param['cause']) {
@ -329,11 +341,11 @@ class Examine extends Common
],
$send_user_id
);
$data = [];
$data['examine_id'] = $this->examine_id;
# 添加活动记录
if (!empty($rdata['customer_ids']) || !empty($rdata['contacts_ids']) || !empty($rdata['business_ids']) || !empty($rdata['contract_ids'])) {
Db::name('crm_activity')->insert([
@ -350,7 +362,7 @@ class Examine extends Common
'contract_ids' => !empty($rdata['contract_ids']) ? trim($rdata['contract_ids'], ',') : '',
]);
}
return $data;
} else {
$this->error = $examineDataModel->getError();
@ -361,7 +373,7 @@ class Examine extends Common
return false;
}
}
/**
* 编辑审批信息
*
@ -387,14 +399,14 @@ class Examine extends Common
$this->error = '数据不存在或已删除';
return false;
}
//过滤不能修改的字段
$unUpdateField = ['create_user_id', 'is_deleted', 'delete_time'];
foreach ($unUpdateField as $v) {
unset($param[$v]);
}
$categoryInfo = $examineCategoryModel->getDataById($dataInfo['category_id']);
//验证
$fieldModel = new \app\admin\model\Field();
$validateArr = $fieldModel->validateField($this->name, $dataInfo['category_id']); //获取自定义字段验证规则
@ -404,7 +416,7 @@ class Examine extends Common
$this->error = $validate->getError();
return false;
}
$fileArr = $param['file_id']; //接收表单附件
unset($param['file_id']);
$param['start_time'] = $param['start_time'] ? strtotime($param['start_time']) : 0;
@ -422,7 +434,7 @@ class Examine extends Common
return false;
}
}
//站内信
$send_user_id = stringToArray($param['check_user_id']);
if ($send_user_id) {
@ -435,7 +447,7 @@ class Examine extends Common
$send_user_id
);
}
//相关业务
$rdata = [];
$rdata['customer_ids'] = $param['oaExamineRelation']['customer_ids'] ? arrayToString($param['oaExamineRelation']['customer_ids']) : [];
@ -443,7 +455,7 @@ class Examine extends Common
$rdata['business_ids'] = $param['oaExamineRelation']['business_ids'] ? arrayToString($param['oaExamineRelation']['business_ids']) : [];
$rdata['contract_ids'] = $param['oaExamineRelation']['contract_ids'] ? arrayToString($param['oaExamineRelation']['contract_ids']) : [];
Db::name('OaExamineRelation')->where('examine_id = ' . $examine_id)->update($rdata);
//处理差旅相关
$resTravel = true;
if (in_array($dataInfo['category_id'], ['3', '5']) && $param['cause']) {
@ -465,10 +477,10 @@ class Examine extends Common
$send_user_id
);
}
$data = [];
$data['examine_id'] = $examine_id;
# 删除活动记录
Db::name('crm_activity')->where(['activity_type' => 9, 'activity_type_id' => $examine_id])->delete();
# 添加活动记录
@ -487,7 +499,7 @@ class Examine extends Common
'contract_ids' => !empty($rdata['contract_ids']) ? trim($rdata['contract_ids'], ',') : '',
]);
}
return $data;
} else {
$this->error = $examineDataModel->getError();
@ -498,7 +510,7 @@ class Examine extends Common
return false;
}
}
/**
* 审批数据
* @param $id 审批ID
@ -516,7 +528,7 @@ class Examine extends Common
->where($map)
->alias('examine')
->join('__OA_EXAMINE_CATEGORY__ examine_category', 'examine_category.category_id = examine.category_id', 'LEFT');
$dataInfo = $data_view
->field('examine.*,examine_category.title as category_name,examine_category.icon as examineIcon')
->find();
@ -534,7 +546,7 @@ class Examine extends Common
// foreach ($fieldList as $k=>$v) {
// $dataInfo[$v] = $fieldModel->getFormValueByField($v, $dataInfo[$v]);
// }
//关联业务
$relationArr = [];
$relationArr = $recordModel->getListByRelationId('examine', $id);
@ -542,7 +554,7 @@ class Examine extends Common
$dataInfo['contactsList'] = $relationArr['contactsList'];
$dataInfo['contractList'] = $relationArr['contractList'];
$dataInfo['customerList'] = $relationArr['customerList'];
$travelList = [];
if (in_array($dataInfo['category_id'], ['3', '5'])) {
//行程、费用明细
@ -574,7 +586,7 @@ class Examine extends Common
}
}
$dataInfo['travelList'] = $travelList;
//附件
$fileList = [];
$imgList = [];
@ -596,7 +608,7 @@ class Examine extends Common
$dataInfo['examine_id'] = $id;
return $dataInfo;
}
/**
* 审批差旅数据保存
* @param examine_id 审批ID
@ -615,7 +627,7 @@ class Examine extends Common
unset($v['files']);
$newData = $v;
$newData['examine_id'] = $examine_id;
$fileArr = $v['file_id']; //接收表单附件
unset($newData['file_id']);
unset($newData['fileList']);
@ -643,7 +655,7 @@ class Examine extends Common
}
return true;
}
/**
* 审批差旅数据编辑
* @param examine_id 审批ID
@ -657,7 +669,7 @@ class Examine extends Common
}
$oldTravelIds = db('oa_examine_travel')->where(['examine_id' => $examine_id])->column('travel_id');
$oldTravelFileIds = db('oa_examine_travel_file')->where(['travel_id' => ['in', $oldTravelIds]])->column('r_id');
$successRes = true;
foreach ($data as $k => $v) {
$newData = [];

@ -23,7 +23,7 @@ class Log extends Common
protected $createTime = 'create_time';
protected $updateTime = 'update_time';
protected $autoWriteTimestamp = true;
/**
* [getDataList 日志list]
* @param [string] $map [查询条件]
@ -39,10 +39,10 @@ class Log extends Common
$fileModel = new \app\admin\model\File();
$commonModel = new \app\admin\model\Comment();
$recordModel = new \app\admin\model\Record();
$user_id = $request['read_user_id'];
$by = $request['by'] ?: '';
$map = [];
$search = $request['search'];
if (isset($request['search']) && $request['search']) {
@ -138,7 +138,7 @@ class Log extends Common
$list[$k]['contactsList'] = $relationArr['contactsList'];
$list[$k]['contractList'] = $relationArr['contractList'];
$list[$k]['customerList'] = $relationArr['customerList'];
if ($v['is_relation'] == 1) {
$list[$k]['bulletin']['customerNum'] = $v['save_customer'];
$list[$k]['bulletin']['businessNum'] = $v['save_business'];
@ -148,7 +148,7 @@ class Log extends Common
} else {
$list[$k]['bulletin'] = 0;
}
$is_update = 0;
$is_delete = 0;
//3天内的日志可删,可修改
@ -183,11 +183,11 @@ class Log extends Common
$data['page']['firstPage'] = true;
$data['page']['lastPage'] = false;
}
return $data;
}
// 创建日志信息
public function createData($param)
{
@ -209,7 +209,7 @@ class Log extends Common
foreach ($arr as $value) {
unset($param[$value]);
}
if ($param['category_id'] == 1) {
$param['title'] = date('Y-m-d') . '-日报';
} else if ($param['category_id'] == 2) {
@ -217,7 +217,7 @@ class Log extends Common
} else if ($param['category_id'] == 3) {
$param['title'] = date('Y-m-d') . '-月报';
}
if ($this->data($param)->allowField(true)->save()) {
$log_id = $this->log_id;
//操作记录
@ -231,7 +231,7 @@ class Log extends Common
return false;
}
}
$temp = User::where(['structure_id' => ['in', $param['send_structure_ids']]])->column('id');
(new Message())->send(
Message::LOG_SEND,
@ -245,7 +245,7 @@ class Log extends Common
$data = [];
$data['log_id'] = $log_id;
$data = $param;
if (count($fileArr)) {
$fileList = Db::name('AdminFile')->where('file_id in (' . implode(',', $fileArr) . ')')->select();
foreach ($fileList as $k => $v) {
@ -258,20 +258,20 @@ class Log extends Common
//发送部门
$data['sendStructureList'] = $param['send_structure_ids'] ? $userModel->getListByStr($param['send_structure_ids']) : [];
$data['log_id'] = $log_id;
$rdata['log_id'] = $log_id;
$rdata['status'] = 1;
$rdata['create_time'] = time();
//关联业务
Db::name('OaLogRelation')->insert($rdata);
//相关业务
$relationArr = $recordModel->getListByRelationId('log', $log_id);
$data['businessList'] = $relationArr['businessList'];
$data['contactsList'] = $relationArr['contactsList'];
$data['contractList'] = $relationArr['contractList'];
$data['customerList'] = $relationArr['customerList'];
# 添加活动记录
if (!empty($rdata['customer_ids']) || !empty($rdata['contacts_ids']) || !empty($rdata['business_ids']) || !empty($rdata['contract_ids'])) {
Db::name('crm_activity')->insert([
@ -288,14 +288,14 @@ class Log extends Common
'contract_ids' => !empty($rdata['contract_ids']) ? trim($rdata['contract_ids'], ',') : '',
]);
}
return $data;
} else {
$this->error = '添加失败';
return false;
}
}
/**
* 编辑日志信息
* @param
@ -318,7 +318,7 @@ class Log extends Common
$rdata['contacts_ids'] = $param['contacts_ids'] ? arrayToString($param['contacts_ids']) : '';
$rdata['business_ids'] = $param['business_ids'] ? arrayToString($param['business_ids']) : '';
$rdata['contract_ids'] = $param['contract_ids'] ? arrayToString($param['contract_ids']) : '';
$arr = ['customer_ids', 'contacts_ids', 'business_ids', 'contract_ids'];
foreach ($arr as $value) {
unset($param[$value]);
@ -332,7 +332,7 @@ class Log extends Common
unset($param['file']);
$param['send_user_ids'] = $param['send_user_ids'] ? arrayToString($param['send_user_ids']) : '';
$param['send_structure_ids'] = $param['send_structure_ids'] ? arrayToString($param['send_structure_ids']) : '';
if ($this->allowField(true)->save($param, ['log_id' => $log_id])) {
//操作日志
Db::name('AdminActionLog')->where(['action_id' => $log_id])->update(['join_user_ids' => $this->send_user_ids, 'structure_ids' => $this->send_structure_ids]);
@ -373,7 +373,7 @@ class Log extends Common
return false;
}
}
/**
* 日志数据
* @param $id 日志ID
@ -385,7 +385,7 @@ class Log extends Common
$userModel = new \app\admin\model\User();
$structureModel = new \app\admin\model\Structure();
$commonModel = new \app\admin\model\Comment();
$map['log.log_id'] = $id;
$data_view = db('oa_log')
->where($map)
@ -396,7 +396,7 @@ class Log extends Common
$this->error = '暂无此数据';
return false;
}
$relation = Db::name('OaLogRelation')->where('log_id =' . $id)->find();
$BusinessModel = new \app\crm\model\Business(); //商机
$dataInfo['businessList'] = $relation['business_ids'] ? $BusinessModel->getDataByStr($relation['business_ids']) : [];
@ -406,7 +406,7 @@ class Log extends Common
$dataInfo['contractList'] = $relation['contract_ids'] ? $ContractModel->getDataByStr($relation['contract_ids']) : [];
$CustomerModel = new \app\crm\model\Customer();//客户
$dataInfo['customerList'] = $relation['customer_ids'] ? $CustomerModel->getDataByStr($relation['customer_ids']) : [];
$dataInfo['create_user_info']['realname'] = $dataInfo['realname'] ?: '';
$dataInfo['create_user_info']['id'] = $dataInfo['create_user_id'] ?: '';
$dataInfo['create_user_info']['thumb_img'] = $dataInfo['thumb_img'] ? getFullPath($dataInfo['thumb_img']) : '';
@ -430,7 +430,7 @@ class Log extends Common
$dataInfo['replyList'] = $commonModel->read($param);
return $dataInfo;
}
/**
* 日志删除
*

@ -333,8 +333,8 @@ class Task extends ApiCommon
# 获取任务的项目信息
$workInfo = Db::name('work')->field(['work_id', 'group_id', 'is_open'])->where('work_id', $taskData['work_id'])->find();
# 是否是公开项目
$userId = empty($workInfo['is_open']) ? $userInfo['id'] : 0;
$groupId = !empty($workInfo['is_open']) ? $workInfo['group_id '] : 0;
$userId = $userInfo['id'];
$groupId = !empty($workInfo['is_open']) ? $workInfo['group_id'] : 0;
# 获取项目下的权限
$taskData['auth'] = !empty($taskData['work_id']) ? $this->getRuleList($workInfo['work_id'], $userId, $groupId) : [];

@ -84,6 +84,9 @@ class Tasklable extends ApiCommon
$str = ','.$userInfo['id'].',';
$param['whereStr'] = ' ( task.create_user_id ='.$userInfo['id'].' or ( task.owner_user_id like "%'.$str.'%") or ( task.main_user_id = '.$userInfo['id'].' ) )';
}
# 标签列表只查询项目下的任务
$param['work_id'] = ['neq', 0];
$resData = $taskModel->getTaskList($param);
$taskList = $resData['list'] ? : [];

@ -147,7 +147,7 @@ class work extends ApiCommon
$workInfo = $workModel->getDataById($this->param['work_id']);
# 是否是公开项目
$userId = empty($workInfo['is_open']) ? $this->userInfo['id'] : 0;
$userId = $this->userInfo['id'];
$groupId = !empty($workInfo['is_open']) ? $workInfo['group_id'] : 0;
# 项目成员
@ -632,5 +632,25 @@ class work extends ApiCommon
return resultArray(['data' => '操作成功!']);
}
/**
* 项目排序
*
* @author alvin guogaobo
* @version 1.0 版本号
* @since 2021/2/23 0023 15:27
*/
// public function workStart(){
// $param=$this->param;
// $userInfo=$this->userInfo;
// $param['work']=serialize($param);
// $param['user_id']=$userInfo['id'];
// $workStart=new WorkLogic();
// $res=$workStart->workStart($param);
// if(!$res){
// return resultArray(['error'=>'操作失败']);
// }
// return resultArray(['data'=>'操作成功']);
// }
}

@ -14,40 +14,40 @@ use think\Db;
class WorkLogic
{
use WorkAuthTrait;
public function index($param)
{
# 排序
$orderField = 'work_id';
$orderSort = 'asc';
$orderSort = 'asc';
if (!empty($param['sort_type']) && $param['sort_type'] == 1) {
$orderField = 'work_id';
$orderSort = 'asc';
$orderSort = 'asc';
}
if (!empty($param['sort_type']) && $param['sort_type'] == 2) {
$orderField = 'work_id';
$orderSort = 'desc';
$orderSort = 'desc';
}
if (!empty($param['sort_type']) && $param['sort_type'] == 3) {
$orderField = 'update_time';
$orderSort = 'desc';
$orderSort = 'desc';
}
# 搜索
$searchWhere = '';
$dateWhere = [];
$userWhere = [];
$dateWhere = [];
$userWhere = [];
$ownerUserId = !empty($param['owner_user_id']) ? $param['owner_user_id'] : '';
$search = !empty($param['search']) ? $param['search'] : '';
$type = !empty($param['type']) ? $param['type'] : 0;
$startTime = !empty($param['start_time']) ? $param['start_time'] : '';
$endTime = !empty($param['end_time']) ? $param['end_time'] : '';
$search = !empty($param['search']) ? $param['search'] : '';
$type = !empty($param['type']) ? $param['type'] : 0;
$startTime = !empty($param['start_time']) ? $param['start_time'] : '';
$endTime = !empty($param['end_time']) ? $param['end_time'] : '';
unset($param['search']);
unset($param['type']);
unset($param['start_time']);
unset($param['end_time']);
unset($param['owner_user_id']);
switch ($type) {
case 1 :
# 今天
@ -69,46 +69,136 @@ class WorkLogic
$dateWhere['update_time'][] = ['egt', strtotime(date('Y-01-01 00:00:00', strtotime('last year')))];
$dateWhere['update_time'][] = ['elt', strtotime(date('Y-12-31 23:59:59', strtotime('last year')))];
}
# 时间区间
if (!empty($startTime)) $dateWhere['update_time'] = ['egt', strtotime($startTime . '00:00:00')];
if (!empty($endTime)) $dateWhere['update_time'] = ['elt', strtotime($endTime . '23:59:59')];
if (!empty($endTime)) $dateWhere['update_time'] = ['elt', strtotime($endTime . '23:59:59')];
# 搜索内容
if ($search) $searchWhere = '(name like "%' . $search . '%") OR (description like "%' . $search . '%")';
# 成员
if (!empty($ownerUserId)) {
$userIds = Db::name('work_user')->whereIn('user_id', $ownerUserId)->column('work_id');
$userWhere['work_id'] = ['in', $userIds];
}
$userModel = new \app\admin\model\User();
$userModel = new \app\admin\model\User();
$perUserIds = $userModel->getUserByPer('work', 'work', 'index');
$authUser = array_unique(array_merge([$param['user_id']], $perUserIds));
$authUser = array_unique(array_merge([$param['user_id']], $perUserIds));
$data = Db::name('work')
->where(function($query) {
$query->where('status', 1);
$query->where('ishidden', 0);
})
->where(function ($query) use ($param, $authUser) {
$query->whereOr(['create_user_id' => ['in', $authUser]]);
$query->whereOr('is_open', 1);
$query->whereOr(function ($query) use ($param) {
$query->where('is_open', 0);
$query->where('owner_user_id', 'like', '%' . $param['user_id'] . '%');
});
})
->where($searchWhere)
->where($dateWhere)
->where($userWhere)
->order($orderField, $orderSort)->select();
->where(function ($query) {
$query->where('status', 1);
$query->where('ishidden', 0);
})
->where(function ($query) use ($param, $authUser) {
$query->whereOr(['create_user_id' => ['in', $authUser]]);
$query->whereOr('is_open', 1);
$query->whereOr(function ($query) use ($param) {
$query->where('is_open', 0);
$query->where('owner_user_id', 'like', '%' . $param['user_id'] . '%');
});
})
->where($searchWhere)
->where($dateWhere)
->where($userWhere)
->order($orderField, $orderSort)->select();
foreach ($data AS $key => $value) {
foreach ($data as $key => $value) {
$data[$key]['authList']['project'] = $this->getRuleList($value['work_id'], $param['user_id'], $value['group_id']);
}
return $data;
}
/**
* @param $param work 排序数组值 user_id用户
*
* @author alvin guogaobo
* @version 1.0 版本号
* @since 2021/2/23 15:42
*/
// public function workStart($param)
// {
// $item = Db::name('workStart')->where('user_id', $param['user_id'])->find();
// $data = [];
// $data['datas'] = $param['work'];
// $data['user_id'] = $param['user_id'];
// if (!$item) {
// return Db::name('workStart')->insertGetId($data);
// } else {
// return Db::name('workStart')->where('user_id', $param['user_id'])->update([$data]);
// }
// }
/**
* 根据数组指定键名排序数组
* @param $array array 被排序数组
* @param $key_name string 数组键名
* @param $sort string desc|asc 升序或者降序
* @return array 返回排序后的数组
*/
// function gw_sort($array, $param)
// {
// $whilr = array
// (
// [0] => ['work_id' => 5,
// 'name' => 222,
// 'status' => 1,
// 'create_time' => 1613628469,
// 'create_user_id' => 7,
// 'description' => 222,
// 'color' => '#53D397',
// 'is_open' => 1,
// 'owner_user_id' => ',1,2,3,4,5,7,',
// 'ishidden' => 0,
// 'archive_time' => 0,
// 'group_id' => 12,
// 'cover_url' => 'http://192.168.1.31/72crm-php/public/uploads/20210218/12ece02733c8684ce987f207062173b5.png',
// 'update_time' => 1613629916,
// 'is_follow' => 0,
// 'is_system_cover' => 0,],
//
// [1] => [
//
// 'work_id' => 7,
// 'name' => '啊啊',
// 'status' => 1,
// 'create_time' => 1614059388,
// 'create_user_id' => 1,
// 'description' => '',
// 'color' => '#53D397',
// 'is_open' => 0,
// 'owner_user_id' => ',1,3,',
// 'ishidden' => 0,
// 'archive_time' => 0,
// 'group_id' => 12,
// 'cover_url' => 'https://file.72crm.com/static/pc/images/pm/project-cover-1.jpg',
// 'update_time' => 1614059926,
// 'is_follow' => 0,
// 'is_system_cover' => 1,
// ]
//
// );
// $item = Db::name('workStart')->where('user_id', $param['user_id'])->find();
// $key_name_array = array();//保存被排序数组键名
// foreach ($whilr as $key => $val) {
// foreach ($item as $v){
// $key_name_array[] = array_merge(array_flip($val), $v);
// }
// }
// $key_name_array = array_flip($key_name_array);//反转键名和值得到数组排序后的位置
// $result = array();
// foreach($array as $k=>$v){
// foreach ($item as $vall){
// $this_key_name_value = $v[$vall];//当前数组键名值依次是20,10,30
// $save_position = $key_name_array[$this_key_name_value];//获取20,10,30排序后存储位置
// $result[$save_position] = $v;//当前项存储到数组指定位置
// }
// }
// ksort($result);
//
// return $result;
// }
}

@ -50,6 +50,7 @@ class Task extends Common
$workModel = model('Work');
$userModel = new \app\admin\model\User();
$work_id = $request['work_id'];
$map=[];
$ret = $workModel->checkWork($work_id, $user_id);
if (!$ret) {
$this->error = $workModel->getError();
@ -68,11 +69,7 @@ class Task extends Common
} else {
$newList = $classList['list'];
}
if ($request['main_user_id']) {
$map['main_user_id'] = ['in', $request['main_user_id']];
}
//截止时间
if ($request['stop_time_type']) {
if ($request['stop_time_type'] == '5') { //没有截至日期
$map['stop_time'] = '0';
@ -104,6 +101,7 @@ class Task extends Common
$map['stop_time'] = ['between', [$timeAry[0], $timeAry[1]]];
}
}
if ($request['lable_id']) {
$taskIds = [];
$task_ids = [];
@ -125,18 +123,20 @@ class Task extends Common
}
$map['task_id'] = ['in', $task_ids];
}
$data = array();
foreach ($newList as $key => $value) {
$data[$key]['class_id'] = $value['class_id'] ?: -1;
$data[$key]['class_name'] = $value['name'];
$map['status'] = $map['status'] ?: ['in', ['1', '5']];
$map['ishidden'] = 0;
$map['work_id'] = $request['work_id'];
$map['class_id'] = $value['class_id'];
$map['pid'] = 0;
$map['is_archive'] = 0;
$map['main_user_id']=$request['main_user_id'];
$taskList = [];
$resTaskList = $this->getTaskList($map);
$data[$key]['count'] = $resTaskList['count'];
@ -414,7 +414,7 @@ class Task extends Common
unset($param[$value]);
}
$main_user_id = $param['main_user_id'] ?: $param['create_user_id'];
$param['owner_user_id'] = ','.$main_user_id.','; //参与人
$param['main_user_id'] = $main_user_id; //负责人
$param['start_time'] = !empty($param['start_time']) ? strtotime($param['start_time']) : 0;
$param['stop_time'] = !empty($param['stop_time']) ? strtotime($param['stop_time']) : 0;
@ -443,14 +443,14 @@ class Task extends Common
//操作日志
actionLog($task_id, '', '', '新建了任务');
//抄送站内信
// (new Message())->send(
// Message::TASK_ALLOCATION,
// [
// 'title' => $param['name'],
// 'action_id' => $task_id
// ],
// $param['owner_user_id']
// );
(new Message())->send(
Message::TASK_ALLOCATION,
[
'title' => $param['name'],
'action_id' => $task_id
],
trim(',',$param['owner_user_id'])
);
}
# 添加活动记录
@ -642,14 +642,14 @@ class Task extends Common
//设置负责人
$userdet = $userModel->getDataById($param['main_user_id']);
$data['after'] = '设定' . $userdet['realname'] . '为主要负责人!';
// (new Message())->send(
// Message::TASK_ALLOCATION,
// [
// 'title' => $taskInfo['name'],
// 'action_id' => $param['task_id']
// ],
// $param['main_user_id']
// );
(new Message())->send(
Message::TASK_ALLOCATION,
[
'title' => $taskInfo['name'],
'action_id' => $param['task_id']
],
$param['main_user_id']
);
break;
}
@ -899,15 +899,17 @@ class Task extends Common
*/
public function getTaskList($request)
{
$search = $request['search'];
$search = $request['search']?:'';
$whereStr = $request['whereStr'] ?: [];
$lable_id = $request['lable_id'] ?: '';
$main_user_id = $request['main_user_id'] ?: '';
$taskSearch = !empty($request['taskSearch']) ? $request['taskSearch'] : '';
$isArchive = !empty($request['is_archive']) ? $request['is_archive'] : 0;
unset($request['search']);
unset($request['whereStr']);
unset($request['lable_id']);
unset($request['taskSearch']);
// unset($request['search']);
// unset($request['whereStr']);
// unset($request['lable_id']);
unset($request['main_user_id']);
$request = $this->fmtRequest($request);
$requestMap = $request['map'] ?: [];
$userModel = new \app\admin\model\User();
@ -924,6 +926,13 @@ class Task extends Common
}
$dataCount = db('task')->alias('task')->where($map)->where($whereStr)->where($taskSearch)->count();
$taskList = [];
$logWhere='';
if ($main_user_id) {
foreach ($main_user_id as $key => $value) {
$logWhere.= '( task.owner_user_id like "%,' . $value . ',%") OR ';
}
if (!empty($logWhere)) $logWhere = '(' . rtrim($logWhere, 'OR ') . ')';
}
if ($dataCount) {
$taskList = db('task')
->alias('task')
@ -932,6 +941,7 @@ class Task extends Common
->field('task.task_id,task.name,task.main_user_id,task.is_top,task.work_id,task.lable_id,task.priority,task.stop_time,task.status,task.pid,task.create_time,task.owner_user_id,u.realname as main_user_name,u.thumb_img,w.name as work_name,color')
->where($map)
->where($whereStr)
->where($logWhere)
->where($taskSearch)
->order('task.status asc,task.order_id asc')
->select();
@ -1036,7 +1046,6 @@ class Task extends Common
->where($labelWhere)
->order($order)
->select();
foreach ($taskList as $key => $value) {
if ($value['pid'] > 0) {
$p_det = $this->field('task_id,name')->where(['task_id' => $value['pid']])->find();
@ -1084,35 +1093,38 @@ class Task extends Common
# 今天
if ($type == 1) {
$result = '(task.stop_time > 0 AND task.stop_time <= ' . strtotime(date('Y-m-d 23:59:59')) . ')';
$result = '(task.stop_time >= ' . strtotime(date('Y-m-d 00:00:00')) . ' AND task.stop_time <= ' . strtotime(date('Y-m-d 23:59:59')) . ')';
}
# 明天
if ($type == 2) {
$tomorrow = date("Y-m-d 23:59:59", strtotime("+1 day"));
$result = '(task.stop_time > 0 AND task.stop_time <= ' . strtotime($tomorrow) . ')';
$start = date("Y-m-d 00:00:00", strtotime("+1 day"));
$result = '(task.stop_time >= ' . strtotime($start) . ' AND task.stop_time <= ' . strtotime($tomorrow) . ')';
}
# 本周
if ($type == 3) {
$week = mktime(23, 59, 59, date("m"), date("d") - date("w") + 7, date("Y"));
$result = '(task.stop_time > 0 AND task.stop_time <= ' . $week . ')';
$start_week=mktime(0, 0, 0, date('m'), date('d') - date('w') + 1, date('Y'));
$result = '(task.stop_time >= ' . $start_week . ' AND task.stop_time <= ' . $week . ')';
}
# 本月
if ($type == 4) {
$timestamp = mktime(0, 0, 0, date('m'), 1, date('Y'));
$month = mktime(23, 59, 59, date("m"), date("t"), date("Y"));
$result = '(task.stop_time > 0 AND task.stop_time <= ' . $month . ')';
$result = '(task.stop_time > ' . $timestamp . ' AND task.stop_time <= ' . $month . ')';
}
# 未设置截止日期
if ($type == 5) {
$result = $result = '(task.stop_time = 0)';;
$result = '(task.stop_time = 0)';;
}
# 已延期
if ($type == 6) {
$result = '(task.status = 2 OR task.stop_time >= ' . time() . ')';
$result = '(task.status = 2 OR task.stop_time < ' . time() . ')'.'AND task.stop_time <> 0 AND task.status = 1';
}
# 今日更新

@ -75,6 +75,7 @@ class Work extends Common
$ownerData['work_id'] = $workId;
$ownerData['create_user_id'] = $createUserId;
$ownerData['owner_user_id'] = $ownerUserId;
$ownerData['group_id'] = !empty($param['group_id']) ? $param['group_id'] : 0;
# 创建项目下的相关成员
$this->addOwner($ownerData);
@ -129,6 +130,10 @@ class Work extends Common
$ownerData['is_open'] = $param['is_open'];
$ownerData['group_id'] = $param['group_id'];
$this->addOwner($ownerData);
}
# 公开项目更新时的权限变更
if ($param['is_open'] == 1 && !empty($param['group_id']) && $param['group_id'] != $workInfo['group_id']) {
db('work_user')->where(['work_id' => $workInfo['work_id'], 'user_id' => ['neq', $workInfo['create_user_id']]])->update(['group_id' => $param['group_id']]);
}
$resUpdata = $this->where($map)->update($param);
if ($resUpdata) {
@ -307,7 +312,7 @@ class Work extends Common
$group_id = 1;
} else {
# 默认角色
$group_id = db('admin_group')->where(['pid' => 5, 'system' => 1])->order('id asc')->value('id');
$group_id = !empty($param['group_id']) ? $param['group_id'] : db('admin_group')->where(['pid' => 5, 'system' => 1])->order('id asc')->value('id');
}
$data['group_id'] = $group_id;
$saveData[] = $data;

@ -265,5 +265,8 @@ return [
// 商业智能查询缓存时间(秒)
'bi_cache_time' => 1800,
// 商业智能慢查询查询时间(查询超过该时间进行数据缓存)(毫秒)
'bi_slow_query_time' => 500
'bi_slow_query_time' => 500,
'public_key' => '-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAkqKFcAQtIp4rlkB5LOMnViyVY/hhA6x0R9ftwtEXsAFu4hBZrm9txdEvxSrDCUsx3Zwv/gdimeOzTtfSKffdoE/DwllNP9Zu6nsr2kGRgPrRwjtlO+j2FOM0b9UY1SQ/bWE+a9oQL2jL9xMSbtX1xG/+HcMo1bT+pa6FNQzs3egmvMt75/jaxINPSraj4kgNFawSBk7qDBEqDYiQwtPTuaNW1YZIs++/gZHsCRgGs/JrAbxNpl7+v/+Z503I3I2rs/8eUM5d16NXR8M7vtobUDCTIiQOgRahO8WMadgFlwavyVCYhy/TBXyj5RUfWaS26LrEN3vkj4TjoJu5m9LQ5QIDAQAB
-----END PUBLIC KEY-----',
];

@ -15,6 +15,7 @@ return [
'admin/install/step2' => ['admin/install/step2', ['method' => 'GET']],
'admin/install/step3' => ['admin/install/step3', ['method' => 'GET']],
'admin/install/step4' => ['admin/install/step4', ['method' => 'POST|AJAX']],
'admin/install/step5' => ['admin/install/step5', ['method' => 'GET']],
'admin/install/progress' => ['admin/install/progress', ['method' => 'POST']],
//子部门列表

@ -233,6 +233,8 @@ return [
'crm/receivables/system' => ['crm/receivables/system', ['method' => 'POST']],
// 【回款】菜单数量
'crm/receivables/count' => ['crm/receivables/count', ['method' => 'POST']],
//【回款】导出
'crm/receivables/excelExport' => ['crm/receivables/excelExport', ['method' => 'POST']],
// 【回款计划】列表
'crm/receivables_plan/index' => ['crm/receivables_plan/index', ['method' => 'POST']],

@ -1,5 +1,5 @@
<?php
return array(
'VERSION'=>'11.0.0',
'RELEASE'=>'20210205',
'VERSION'=>'11.0.1',
'RELEASE'=>'20210227',
);

@ -1708,10 +1708,10 @@ INSERT INTO `5kcrm_admin_scene` (`types`, `name`, `user_id`, `order_id`, `data`,
INSERT INTO `5kcrm_admin_scene` (`types`, `name`, `user_id`, `order_id`, `data`, `is_hide`, `type`, `bydata`, `create_time`, `update_time`) VALUES ('crm_visit', '下属负责的回访', '0', '1', '', '0', '1', 'sub', '1546272000', '1551515457');
INSERT INTO `5kcrm_admin_field` ( `types`, `types_id`, `field`, `name`, `form_type`, `default_value`, `max_length`, `is_unique`, `is_null`, `input_tips`, `setting`, `order_id`, `operating`, `create_time`, `update_time`, `type`, `relevant`, `is_hidden`) VALUES ('crm_visit', '0', 'number', '回访编号', 'text', '', '0', '0', '1', '', NULL, '1', '1', '1553788800', '1553788800', '0', NULL, '0');
INSERT INTO `5kcrm_admin_field` ( `types`, `types_id`, `field`, `name`, `form_type`, `default_value`, `max_length`, `is_unique`, `is_null`, `input_tips`, `setting`, `order_id`, `operating`, `create_time`, `update_time`, `type`, `relevant`, `is_hidden`) VALUES ('crm_visit', '0', 'visit_time', '回访时间', 'date', '', '0', '0', '1', '', '', '2', '1', '1553788800', '1553788800', '0', '', '0');
INSERT INTO `5kcrm_admin_field` ( `types`, `types_id`, `field`, `name`, `form_type`, `default_value`, `max_length`, `is_unique`, `is_null`, `input_tips`, `setting`, `order_id`, `operating`, `create_time`, `update_time`, `type`, `relevant`, `is_hidden`) VALUES ('crm_visit', '0', 'visit_user_id', '回访人', 'user', '', '0', '0', '1', '', '', '3', '1', '1553788800', '1553788800', '0', '', '0');
INSERT INTO `5kcrm_admin_field` ( `types`, `types_id`, `field`, `name`, `form_type`, `default_value`, `max_length`, `is_unique`, `is_null`, `input_tips`, `setting`, `order_id`, `operating`, `create_time`, `update_time`, `type`, `relevant`, `is_hidden`) VALUES ('crm_visit', '0', 'owner_user_id', '回访人', 'single_user', '', '0', '0', '1', '', '', '9', '3', '1553788800', '1553788800', '0', '', '0');
INSERT INTO `5kcrm_admin_field` ( `types`, `types_id`, `field`, `name`, `form_type`, `default_value`, `max_length`, `is_unique`, `is_null`, `input_tips`, `setting`, `order_id`, `operating`, `create_time`, `update_time`, `type`, `relevant`, `is_hidden`) VALUES ('crm_visit', '0', 'shape', '回访形式', 'select', '', '0', '0', '0', '', '见面拜访\r\n电话\r\n短信\r\n邮件\r\n微信', '4', '1', '1553788800', '1553788800', '0', NULL, '0');
INSERT INTO `5kcrm_admin_field` ( `types`, `types_id`, `field`, `name`, `form_type`, `default_value`, `max_length`, `is_unique`, `is_null`, `input_tips`, `setting`, `order_id`, `operating`, `create_time`, `update_time`, `type`, `relevant`, `is_hidden`) VALUES ( 'crm_visit', '0', 'customer_id', '客户名称', 'customer', '', '0', '0', '1', '', '', '5', '1', '1553788800', '1553788800', '0', '', '0');
INSERT INTO `5kcrm_admin_field` ( `types`, `types_id`, `field`, `name`, `form_type`, `default_value`, `max_length`, `is_unique`, `is_null`, `input_tips`, `setting`, `order_id`, `operating`, `create_time`, `update_time`, `type`, `relevant`, `is_hidden`) VALUES ( 'crm_visit', '0', 'contacts_id', '联系人', 'contacts', '', '0', '0', '0', '', '', '6', '1', '1553788800', '1553788800', '0', '', '0');
INSERT INTO `5kcrm_admin_field` ( `types`, `types_id`, `field`, `name`, `form_type`, `default_value`, `max_length`, `is_unique`, `is_null`, `input_tips`, `setting`, `order_id`, `operating`, `create_time`, `update_time`, `type`, `relevant`, `is_hidden`) VALUES ( 'crm_visit', '0', 'contacts_id', '联系人', 'contacts', '', '0', '0', '0', '', '', '6', '3', '1553788800', '1553788800', '0', '', '0');
INSERT INTO `5kcrm_admin_field` ( `types`, `types_id`, `field`, `name`, `form_type`, `default_value`, `max_length`, `is_unique`, `is_null`, `input_tips`, `setting`, `order_id`, `operating`, `create_time`, `update_time`, `type`, `relevant`, `is_hidden`) VALUES ( 'crm_visit', '0', 'contract_id', '合同编号', 'contract', '', '0', '0', '1', '', '', '7', '1', '1553788800', '1553788800', '0', '', '0');
INSERT INTO `5kcrm_admin_field` ( `types`, `types_id`, `field`, `name`, `form_type`, `default_value`, `max_length`, `is_unique`, `is_null`, `input_tips`, `setting`, `order_id`, `operating`, `create_time`, `update_time`, `type`, `relevant`, `is_hidden`) VALUES ('crm_visit', '0', 'satisfaction', '客户满意度', 'select', '', '0', '0', '0', '', '很满意\r\n满意\r\n一般不满意\r\n很不满意', '8', '1', '1553788800', '1553788800', '0', NULL, '0');
INSERT INTO `5kcrm_admin_field` ( `types`, `types_id`, `field`, `name`, `form_type`, `default_value`, `max_length`, `is_unique`, `is_null`, `input_tips`, `setting`, `order_id`, `operating`, `create_time`, `update_time`, `type`, `relevant`, `is_hidden`) VALUES ( 'crm_visit', '0', 'feedback', '客户反馈', 'textarea', '', '0', '0', '0', '', '', '9', '1', '1553788800', '1553788800', '0', '', '0');
@ -1751,7 +1751,7 @@ DROP TABLE IF EXISTS `5kcrm_crm_visit`;
CREATE TABLE `5kcrm_crm_visit` (
`visit_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '回访id',
`owner_user_id` int(11) NOT NULL COMMENT '负责人',
`visit_user_id` int(11) NOT NULL COMMENT '回访人',
`owner_user_id` int(11) NOT NULL COMMENT '回访人',
`create_user_id` int(11) NOT NULL COMMENT '创建人id',
`customer_id` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '客户名称',
`contract_id` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '合同编号',
@ -1840,12 +1840,12 @@ ALTER TABLE `5kcrm_oa_examine` ADD COLUMN `last_user_id` varchar(200) not null d
ALTER TABLE `5kcrm_oa_announcement` ADD COLUMN `is_read` tinyint(2) not null default 0 comment '1表示已读 0表示未读';
ALTER TABLE `5kcrm_oa_examine_category` ADD COLUMN `icon` varchar(255) NOT NULL COMMENT '类型图标和颜色';
UPDATE `5kcrm_oa_examine_category` SET `category_id`='1', `title`='普通审批', `remark`='普通审批', `create_user_id`='1', `status`='1', `is_sys`='1', `user_ids`='', `structure_ids`='', `create_time`='1612576450', `update_time`='1612576450', `is_deleted`='0', `delete_time`='0', `delete_user_id`='0', `flow_id`='65' ,`icon`='wk wk-leave,#00CAAB' WHERE (`category_id`='1');
UPDATE `5kcrm_oa_examine_category` SET `category_id`='2', `title`='请假审批', `remark`='请假审批', `create_user_id`='1', `status`='1', `is_sys`='1', `user_ids`='', `structure_ids`='', `create_time`='1612518097', `update_time`='1612518097', `is_deleted`='0', `delete_time`='0', `delete_user_id`='0', `flow_id`='63' ,`icon`='wk wk-l-record,#3ABCFB' WHERE (`category_id`='2');
UPDATE `5kcrm_oa_examine_category` SET `category_id`='3', `title`='出差审批', `remark`='出差审批', `create_user_id`='1', `status`='1', `is_sys`='1', `user_ids`='', `structure_ids`='', `create_time`='1548911542', `update_time`='1548911542', `is_deleted`='0', `delete_time`='0', `delete_user_id`='0', `flow_id`='1' ,`icon`='wk wk-trip,#3ABCFB' WHERE (`category_id`='3');
UPDATE `5kcrm_oa_examine_category` SET `category_id`='4', `title`='加班审批', `remark`='加班审批', `create_user_id`='1', `status`='1', `is_sys`='1', `user_ids`='', `structure_ids`='', `create_time`='1548911542', `update_time`='1548911542', `is_deleted`='0', `delete_time`='0', `delete_user_id`='0', `flow_id`='1' ,`icon`='wk wk-overtime,#FAAD14' WHERE (`category_id`='4');
UPDATE `5kcrm_oa_examine_category` SET `category_id`='5', `title`='差旅报销', `remark`='差旅报销', `create_user_id`='1', `status`='1', `is_sys`='1', `user_ids`='', `structure_ids`='', `create_time`='1548911542', `update_time`='1548911542', `is_deleted`='0', `delete_time`='0', `delete_user_id`='0', `flow_id`='1' ,`icon`='wk wk-reimbursement,#3ABCFB' WHERE (`category_id`='5');
UPDATE `5kcrm_oa_examine_category` SET `category_id`='6', `title`='借款申请', `remark`='借款申请', `create_user_id`='1', `status`='1', `is_sys`='1', `user_ids`='', `structure_ids`='', `create_time`='1548911542', `update_time`='1548911542', `is_deleted`='0', `delete_time`='0', `delete_user_id`='0', `flow_id`='1' ,`icon`='wk wk-go-out,#FF6033' WHERE (`category_id`='6');
UPDATE `5kcrm_oa_examine_category` SET `category_id`='1', `title`='普通审批', `remark`='普通审批', `create_user_id`='1', `status`='1', `is_sys`='1', `user_ids`='', `structure_ids`='', `create_time`='1612576450', `update_time`='1612576450', `is_deleted`='0', `delete_time`='0', `delete_user_id`='0', `flow_id`='1' ,`icon`='wk wk-leave,#00CAAB' WHERE (`category_id`='1');
UPDATE `5kcrm_oa_examine_category` SET `category_id`='2', `title`='请假审批', `remark`='请假审批', `create_user_id`='1', `status`='1', `is_sys`='1', `user_ids`='', `structure_ids`='', `create_time`='1612518097', `update_time`='1612518097', `is_deleted`='0', `delete_time`='0', `delete_user_id`='0', `flow_id`='2' ,`icon`='wk wk-l-record,#3ABCFB' WHERE (`category_id`='2');
UPDATE `5kcrm_oa_examine_category` SET `category_id`='3', `title`='出差审批', `remark`='出差审批', `create_user_id`='1', `status`='1', `is_sys`='1', `user_ids`='', `structure_ids`='', `create_time`='1548911542', `update_time`='1548911542', `is_deleted`='0', `delete_time`='0', `delete_user_id`='0', `flow_id`='3' ,`icon`='wk wk-trip,#3ABCFB' WHERE (`category_id`='3');
UPDATE `5kcrm_oa_examine_category` SET `category_id`='4', `title`='加班审批', `remark`='加班审批', `create_user_id`='1', `status`='1', `is_sys`='1', `user_ids`='', `structure_ids`='', `create_time`='1548911542', `update_time`='1548911542', `is_deleted`='0', `delete_time`='0', `delete_user_id`='0', `flow_id`='4' ,`icon`='wk wk-overtime,#FAAD14' WHERE (`category_id`='4');
UPDATE `5kcrm_oa_examine_category` SET `category_id`='5', `title`='差旅报销', `remark`='差旅报销', `create_user_id`='1', `status`='1', `is_sys`='1', `user_ids`='', `structure_ids`='', `create_time`='1548911542', `update_time`='1548911542', `is_deleted`='0', `delete_time`='0', `delete_user_id`='0', `flow_id`='5' ,`icon`='wk wk-reimbursement,#3ABCFB' WHERE (`category_id`='5');
UPDATE `5kcrm_oa_examine_category` SET `category_id`='6', `title`='借款申请', `remark`='借款申请', `create_user_id`='1', `status`='1', `is_sys`='1', `user_ids`='', `structure_ids`='', `create_time`='1548911542', `update_time`='1548911542', `is_deleted`='0', `delete_time`='0', `delete_user_id`='0', `flow_id`='6' ,`icon`='wk wk-go-out,#FF6033' WHERE (`category_id`='6');
INSERT INTO `5kcrm_admin_rule` VALUES ('154', '0', '其他设置', 'other_rule', '2', '105', '0');
INSERT INTO `5kcrm_admin_rule` VALUES ('155', '0', '日志欢迎语', 'welcome', '3', '154', '0');
@ -1955,7 +1955,7 @@ CREATE TABLE `5kcrm_crm_receivables_file` (
`receivables_id` int(10) unsigned NOT NULL,
`file_id` int(10) unsigned NOT NULL,
PRIMARY KEY (`r_id`) USING BTREE
) ENGINE=MyISAM AUTO_INCREMENT=0 DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED;
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED;
INSERT INTO `5kcrm_crm_config` (`name`, `value`, `description`) VALUES ('activity_phrase', 'a:5:{i:0;s:18:\\\"电话无人接听\\\";i:1;s:15:\\\"客户无意向\\\";i:2;s:42:\\\"客户意向度适中,后续继续跟进\\\";i:3;s:42:\\\"客户意向度较强,成交几率较大\\\";i:4;s:3:\\\"312\\\";}', '跟进记录常用语');
INSERT INTO `5kcrm_crm_config` (`name`, `value`, `description`) VALUES ('visit_config', '1', '是否开启回访提醒1开启0不开启');

@ -1,3 +1,3 @@
insert into `5kcrm_admin_user` (`username`, `password`, `salt`, `realname`, `create_time`, `status`, `structure_id`, `parent_id`, `type`) values ( '18888888888', '302dd3f6dba54513f2a5a1bf696e2d8d', '1b2d', '管理员', '1487217060', 1, 1, 0, 1);
insert into `5kcrm_admin_user` (`username`, `password`, `salt`, `realname`, `create_time`, `status`, `structure_id`, `parent_id`, `type`) values ( '18888888888', '05a9918b455b2209673c36676422bb81', '7217', '管理员', '1613611667', 1, 1, 0, 1);
insert into `5kcrm_hrm_user_det` (`user_id`, `join_time`, `type`, `status`, `userstatus`, `create_time`, `update_time`) values ( 1, '1487217060', 1, 1, 2, '1487217060', '1487217060');
insert into `5kcrm_hrm_user_det` (`user_id`, `join_time`, `type`, `status`, `userstatus`, `create_time`, `update_time`) values ( 1, '1613611667', 1, 1, 2, '1613611667', '1613611667');

@ -380,13 +380,6 @@ ALTER TABLE `5kcrm_oa_examine` ADD COLUMN `last_user_id` varchar(200) not null d
ALTER TABLE `5kcrm_oa_announcement` ADD COLUMN `is_read` tinyint(2) not null default 0 comment '1表示已读 0表示未读';
ALTER TABLE `5kcrm_oa_examine_category` ADD COLUMN `icon` varchar(255) NOT NULL COMMENT '类型图标和颜色';
UPDATE `5kcrm_oa_examine_category` SET `category_id`='1', `title`='普通审批', `remark`='普通审批', `create_user_id`='1', `status`='1', `is_sys`='1', `user_ids`='', `structure_ids`='', `create_time`='1612576450', `update_time`='1612576450', `is_deleted`='0', `delete_time`='0', `delete_user_id`='0', `flow_id`='65' ,`icon`='wk wk-leave,#00CAAB' WHERE (`category_id`='1');
UPDATE `5kcrm_oa_examine_category` SET `category_id`='2', `title`='请假审批', `remark`='请假审批', `create_user_id`='1', `status`='1', `is_sys`='1', `user_ids`='', `structure_ids`='', `create_time`='1612518097', `update_time`='1612518097', `is_deleted`='0', `delete_time`='0', `delete_user_id`='0', `flow_id`='63' ,`icon`='wk wk-l-record,#3ABCFB' WHERE (`category_id`='2');
UPDATE `5kcrm_oa_examine_category` SET `category_id`='3', `title`='出差审批', `remark`='出差审批', `create_user_id`='1', `status`='1', `is_sys`='1', `user_ids`='', `structure_ids`='', `create_time`='1548911542', `update_time`='1548911542', `is_deleted`='0', `delete_time`='0', `delete_user_id`='0', `flow_id`='1' ,`icon`='wk wk-trip,#3ABCFB' WHERE (`category_id`='3');
UPDATE `5kcrm_oa_examine_category` SET `category_id`='4', `title`='加班审批', `remark`='加班审批', `create_user_id`='1', `status`='1', `is_sys`='1', `user_ids`='', `structure_ids`='', `create_time`='1548911542', `update_time`='1548911542', `is_deleted`='0', `delete_time`='0', `delete_user_id`='0', `flow_id`='1' ,`icon`='wk wk-overtime,#FAAD14' WHERE (`category_id`='4');
UPDATE `5kcrm_oa_examine_category` SET `category_id`='5', `title`='差旅报销', `remark`='差旅报销', `create_user_id`='1', `status`='1', `is_sys`='1', `user_ids`='', `structure_ids`='', `create_time`='1548911542', `update_time`='1548911542', `is_deleted`='0', `delete_time`='0', `delete_user_id`='0', `flow_id`='1' ,`icon`='wk wk-reimbursement,#3ABCFB' WHERE (`category_id`='5');
UPDATE `5kcrm_oa_examine_category` SET `category_id`='6', `title`='借款申请', `remark`='借款申请', `create_user_id`='1', `status`='1', `is_sys`='1', `user_ids`='', `structure_ids`='', `create_time`='1548911542', `update_time`='1548911542', `is_deleted`='0', `delete_time`='0', `delete_user_id`='0', `flow_id`='1' ,`icon`='wk wk-go-out,#FF6033' WHERE (`category_id`='6');
INSERT INTO `5kcrm_admin_rule` VALUES ('154', '0', '其他设置', 'other_rule', '2', '105', '0');
INSERT INTO `5kcrm_admin_rule` VALUES ('155', '0', '日志欢迎语', 'welcome', '3', '154', '0');
INSERT INTO `5kcrm_admin_rule` VALUES ('156', '0', '设置欢迎语', 'setWelcome', '3', '154', '0');

@ -0,0 +1,2 @@
UPDATE `5kcrm_admin_field` SET `operating`= 3, `field` = 'owner_user_id', `form_type` = 'single_user' WHERE `types` = 'crm_visit' AND `field` = 'visit_user_id';
UPDATE `5kcrm_admin_field` SET `operating`= 3 WHERE `types` = 'crm_visit' AND `field` = 'contacts_id';

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 460 KiB

@ -45,7 +45,12 @@ var rules = {
required: true,
regexp: /^(?=.*[a-zA-Z])(?=.*\d).{6,20}$/,
label: '管理员密码(6~20位字母加数字组合)'
}
},
wkcode: {
required: false,
regexp: null,
label: '序列号'
},
};
var timer = null;
@ -63,32 +68,36 @@ $('.next').click(function () {
// 校验form数据 true 校验通过 false 校验失败
var forms = getFormData();
var result = checkForm();
console.log('result---', result, forms);
// console.log('result---', result, forms);
if (result) {
$.ajax({
cache: true,
type: "POST",
dataType: 'json',
url: "./step4",
data: {
form: forms
},
async: false,
success: function (result) {
if (result.code == '200') {
alert(result.data);
window.location = '../../../index.html';
} else if (result.code == '400') {
alert(result.error); //失败
return false;
// window.location = 'step3.html'
} else {
window.location = 'step3.html'
alert('安装失败');
$('#cover').css('display', 'block');//显示遮罩层
setTimeout(()=>{
$.ajax({
cache: true,
type: "POST",
dataType: 'json',
url: "./step4",
data: {
form: forms
},
async: false,
success: function (result) {
if (result.code == '200') {
window.location = 'step5.html';
} else if (result.code == '400') {
$('#cover').css('display', 'none');
alert(result.error); //失败
return false;
// window.location = 'step3.html'
} else {
window.location = 'step3.html'
alert('安装失败');
}
}
}
// getRes();
});
// getRes();
});
})
}
});
@ -168,7 +177,7 @@ function _initFormValue() {
* @return {form}
*/
function getFormData() {
$('input').each(function (index, item) {
$('.wkform').each(function (index, item) {
form[item.name] = item.value;
// 重置表单状态
$(item).removeClass('input-error');
@ -186,6 +195,7 @@ function getFormData() {
* @return {boolean}
*/
function checkForm() {
var result = {};
for (var key in rules) {
var rule = rules[key];
@ -228,9 +238,4 @@ function renderErrorMsg(key, msg) {
$(item).addClass('input-error')
}
})
}
/**
* 提交表单
*/
function submitForm() {}
}

@ -10,6 +10,11 @@ html, body {
background-color: #f2f2f2;
font-family: ,Microsoft Yahei,LiHei Pro,Hiragino Sans,GBHelvetica Neue,Helvetica,Arial,PingFang SC,WenQuanYi Micro Hei,sans-serif;
}
body {
background-image: url('../img/bg.png');
background-size: 100% 100%;
background-repeat: no-repeat;
}
li {
list-style: none;
@ -72,7 +77,10 @@ li {
.top {
width: 790px;
height: 65px;
margin: 0 auto;
margin:40px auto 20px auto;
border: 1px solid white;
border-radius: 5px ;
background-color: #fff ;
}
/* container */
@ -81,6 +89,7 @@ li {
min-height: 493px;
background-color: white;
border: 1px solid #e1e1e1;
border-radius:5px;
margin: 0 auto;
}
@ -93,7 +102,7 @@ li {
width: 820px;
text-align: center;
font-size: 15px;
color: #8c8c8c;
color: #fff;
line-height: 30px;
margin: 0 auto;
padding: 30px 0;
@ -112,6 +121,9 @@ li {
text-align: center;
margin: 20px 0;
float: left;
display: flex;
align-items: center;
justify-content: center;
}
.step.line {
width: 10%;
@ -122,12 +134,12 @@ li {
.step .sort {
width: 25px;
height: 25px;
color: white;
color: #8c8c8c;
line-height: 25px;
text-align: center;
font-size: 14px;
border-radius: 50%;
background-color: #d1d1d1;
/* background-color: #d1d1d1; */
margin-right: 5px;
display: inline-block;
}
@ -139,13 +151,13 @@ li {
}
.step.active .sort {
background-color: #3e84e9;
background-color: #fff;
}
.step.active .desc {
color: #3e84e9;
color: black;
}
.step.active.line {
background-color: #3e84e9;
/* background-color: #fff; */
}
@ -156,7 +168,7 @@ li {
line-height: 40px;
font-size: 16px;
color: #3e84e9;
border-radius: 40px;
border-radius: 5px;
background-color: white;
border: 1px solid #3e84e9;
display: inline-block;
@ -172,16 +184,44 @@ li {
width: 100%;
height: 54px;
line-height: 54px;
background-color: #f7f7f7;
/* background-color: #f7f7f7; */
padding: 0 26px;
border-bottom: 1px solid #e1e1e1;
/* border-bottom: 1px solid #e1e1e1; */
font-weight: 600;
}
.base-top .title {
color: #8c8c8c;
/* color: #8c8c8c; */
font-size: 16px;
}
.base-top .version {
font-size: 13px;
color: #d1d1d1;
color: #8c8c8c;
float: right;
}
.base-des {
margin: 0 auto;
line-height: 35px;
width: 790px;
background-color: #fff;
padding: 0 40px;
margin-bottom: 20px;
color: #8c8c8c;
}
.base-a{
cursor: pointer;
user-select: none;
text-decoration: none;
color: #3e84e9;
}
#cover{
position:absolute;left:0px;top:0px;
background:rgba(0, 0, 0, 0.4);
width:100%; /*宽度设置为100%,这样才能使隐藏背景层覆盖原页面*/
height:100%;
opacity:0.6; /*非IE浏览器下设置透明度为60%*/
display:none;
z-Index:99;
}

@ -1,5 +1,6 @@
.container {
padding: 20px;
border-radius: 10px;
}
.agreement-title {
width: 100%;

@ -0,0 +1,52 @@
#loader-container {
width: 200px;
height: 200px;
color: white;
margin: 0 auto;
position: fixed;
top: 50%;
left: 50%;
margin-right: -50%;
transform: translate(-50%, -50%);
border: 5px solid #3498db;
border-radius: 50%;
-webkit-animation: borderScale 1s infinite ease-in-out;
animation: borderScale 1s infinite ease-in-out;
z-index: 100;
opacity:1
}
#loadingText {
font-family: 'Raleway', sans-serif;
font-weight: bold;
font-size: 2em;
position: absolute;
top: 50%;
left: 50%;
margin-right: -50%;
transform: translate(-50%, -50%);
}
@-webkit-keyframes borderScale {
0% {
border: 5px solid white;
}
50% {
border: 25px solid #3498db;
}
100% {
border: 5px solid white;
}
}
@keyframes borderScale {
0% {
border: 5px solid white;
}
50% {
border: 25px solid #3498db;
}
100% {
border: 5px solid white;
}
}

@ -15,14 +15,18 @@
table {
width: 100%;
border: 1px solid #e1e1e1;
border-collapse: collapse;
/* border-collapse: collapse; */
border-collapse: separate;
border-spacing: 0;
border-radius:5px;
overflow: hidden;
}
.table tr {
height: 34px;
text-align: center;
}
th, td {
border: 1px solid #e1e1e1;
border-bottom: 1px solid #f7f7f7;
width: 30%;
}
th:first-child, td:first-child, th:last-child, td:last-child {
@ -31,8 +35,9 @@ th:first-child, td:first-child, th:last-child, td:last-child {
th {
font-weight: normal;
background-color: #3e84e9;
color: white;
background-color: #f7f7f7;
/* color: white; */
font-weight: 600;
}

@ -28,13 +28,15 @@
float: left;
}
.content .form .form-item input {
width: 276px;
height: 34px;
line-height: 34px;
width: 550px;
height: 40px;
line-height: 40px;
border: 1px solid #d7d7d7;
padding: 0 10px;
margin-right: 20px;
/* margin-right: 20px; */
float: left;
border-radius: 5px;
color: #8c8c8c;
}
.content .form .form-item input:focus {
border-color: transparent !important;
@ -51,13 +53,17 @@
float: left;
}
.content .form .form-item .remind {
width: 292px;
line-height: 34px;
font-size: 12px;
margin-top: 10px;
margin-left: 120px;
width: 550px;
line-height: 20px;
color: #777;
background-color: #ecf8ff;
padding: 0 16px;
background-color: #fff6e7;
padding: 0 12px;
border-radius: 3px;
float: left;
border:1px solid #d7d7d7;
}
.install_progress_a {
@ -69,5 +75,20 @@
text-align: center;
padding: 20px 0;
color: #777;
}
.content .form .form-item textarea {
height: 100px;
width: 550px;
line-height: 25px;
border: 1px solid #d7d7d7;
padding: 0 10px;
/* margin-right: 20px; */
float: left;
border-radius: 5px;
color: #8c8c8c;
}
.content .form .form-item textarea:focus {
border-color: transparent !important;
outline-color: #3e84e9;
}

@ -0,0 +1,2 @@
UPDATE `5kcrm_admin_field` SET `operating`= 3, `field` = 'owner_user_id', `form_type` = 'single_user' WHERE `types` = 'crm_visit' AND `field` = 'visit_user_id';
UPDATE `5kcrm_admin_field` SET `operating`= 3 WHERE `types` = 'crm_visit' AND `field` = 'contacts_id';
Loading…
Cancel
Save