diff --git a/app/.htaccess b/app/.htaccess new file mode 100644 index 0000000..e69de29 diff --git a/app/command.php b/app/command.php new file mode 100644 index 0000000..3f91003 --- /dev/null +++ b/app/command.php @@ -0,0 +1,12 @@ + +// +---------------------------------------------------------------------- + +return []; \ No newline at end of file diff --git a/app/common.php b/app/common.php new file mode 100644 index 0000000..5170b1d --- /dev/null +++ b/app/common.php @@ -0,0 +1,3151 @@ + + // note that you have to handle splits with \n, \r, and \t later since they *are* allowed in some inputs + //$val = preg_replace('/([\x00-\x08,\x0b-\x0c,\x0e-\x19])/', '', $val); + // straight replacements, the user should never need these since they're normal characters + // this prevents like + $search = 'abcdefghijklmnopqrstuvwxyz'; + $search .= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; + $search .= '1234567890!@#$%^&*()'; + $search .= '~`";:?+/={}[]-_|\'\\'; + for ($i = 0; $i < strlen($search); $i++) { + // ;? matches the ;, which is optional + // 0{0,7} matches any padded zeros, which are optional and go up to 8 chars + // @ @ search for the hex values + $val = preg_replace('/(&#[xX]0{0,8}'.dechex(ord($search[$i])).';?)/i', $search[$i], $val); // with a ; + // @ @ 0{0,7} matches '0' zero to seven times + $val = preg_replace('/(�{0,8}'.ord($search[$i]).';?)/', $search[$i], $val); // with a ; + } + // now the only remaining whitespace attacks are \t, \n, and \r + $ra1 = array('javascript', 'vbscript', 'expression', 'applet', 'meta', 'xml', 'blink', 'link','script', 'embed', 'object', 'iframe', 'frame', 'frameset', 'ilayer', 'layer', 'bgsound','base'); + $ra2 = array('onabort', 'onactivate', 'onafterprint', 'onafterupdate', 'onbeforeactivate', 'onbeforecopy', 'onbeforecut', 'onbeforedeactivate', 'onbeforeeditfocus', 'onbeforepaste', 'onbeforeprint', 'onbeforeunload', 'onbeforeupdate', 'onblur', 'onbounce', 'oncellchange', 'onchange', 'onclick', 'oncontextmenu', 'oncontrolselect', 'oncopy', 'oncut', 'ondataavailable', 'ondatasetchanged', 'ondatasetcomplete', 'ondblclick', 'ondeactivate', 'ondrag', 'ondragend', 'ondragenter', 'ondragleave', 'ondragover', 'ondragstart', 'ondrop', 'onerror', 'onerrorupdate', 'onfilterchange', 'onfinish', 'onfocus', 'onfocusin', 'onfocusout', 'onhelp', 'onkeydown', 'onkeypress', 'onkeyup', 'onlayoutcomplete', 'onload', 'onlosecapture', 'onmousedown', 'onmouseenter', 'onmouseleave', 'onmousemove', 'onmouseout', 'onmouseover', 'onmouseup', 'onmousewheel', 'onmove', 'onmoveend', 'onmovestart', 'onpaste', 'onpropertychange', 'onreadystatechange', 'onreset', 'onresize', 'onresizeend', 'onresizestart', 'onrowenter', 'onrowexit', 'onrowsdelete', 'onrowsinserted', 'onscroll', 'onselect', 'onselectionchange', 'onselectstart', 'onstart', 'onstop', 'onsubmit', 'onunload'); + $ra = array_merge($ra1, $ra2); + $found = true; // keep replacing as long as the previous round replaced something + while ($found == true) { + $val_before = $val; + for ($i = 0; $i < sizeof($ra); $i++) { + $pattern = '/'; + for ($j = 0; $j < strlen($ra[$i]); $j++) { + if ($j > 0) { + $pattern .= '('; + $pattern .= '(&#[xX]0{0,8}([9ab]);)'; + $pattern .= '|'; + $pattern .= '|(�{0,8}([9|10|13]);)'; + $pattern .= ')*'; + } + $pattern .= $ra[$i][$j]; + } + $pattern .= '/i'; + $replacement = substr($ra[$i], 0, 2).''.substr($ra[$i], 2); // add in <> to nerf the tag + $val = preg_replace($pattern, $replacement, $val); // filter out the hex tags + if ($val_before == $val) { + // no replacements were made, so exit the loop + $found = false; + } + } + } + + $filters=config("filters"); + if(count($filters)&&is_string($val)){ + $filters=array_map("trim",$filters); + $val=str_replace($filters,"***",$val); + } + return $val; +} +/** + * 导出xls + * @param unknown $expTitle + * @param unknown $expCellName + * @param unknown $expTableData + */ +function exportExcel($expTitle,$expCellName,$expTableData){ + error_reporting(E_ALL); + date_default_timezone_set('Europe/London'); + include ROOT_PATH.'extend'.DS.'PHPExcel'.DS.'PHPExcel.php'; + $objPHPExcel = new \PHPExcel(); + $objPHPExcel->getActiveSheet()->setTitle($expTitle); + $objPHPExcel->setActiveSheetIndex(0); + + $cellNum=count($expCellName); + $dataNum=count($expTableData); + + $cellName = array('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','AA','AB','AC','AD','AE','AF','AG','AH','AI','AJ','AK','AL','AM','AN','AO','AP','AQ','AR','AS','AT','AU','AV','AW','AX','AY','AZ'); + for($i=0;$i<$cellNum;$i++){ + $objPHPExcel->setActiveSheetIndex(0)->setCellValue($cellName[$i].'1', $expCellName[$i][1]); + } + for($i=0;$i<$dataNum;$i++){ + for($j=0;$j<$cellNum;$j++){ + $val=$expTableData[$i][$expCellName[$j][0]]; + $opts=isset($expCellName[$j][2])?$expCellName[$j][2]:''; + $format=isset($expCellName[$j][3])?$expCellName[$j][3]:''; + if(is_int($val)&&$opts){ + $opts=explode("||", $opts); + if(isset($opts[$val]))$val=$opts[$val]; + } + if($format=='date'){ + $val=date("Y-m-d",intval($val)); + } + $objPHPExcel->getActiveSheet(0)->setCellValue($cellName[$j].($i+2),$val); + } + } + ob_end_clean();//清楚缓存区,解决乱码问题 + header('Content-Type: application/vnd.ms-excel'); + header('Content-Disposition: attachment;filename="'.$expTitle.'.xls"'); + header('Cache-Control: max-age=0'); + $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); + $objWriter->save('php://output'); + exit; +} + +/** + * 多维数组查询 + * @param unknown $value + * @param unknown $array + * @return unknown|boolean + */ +function deep_in_array($value, $array) { + foreach($array as $item) { + if(!is_array($item)) { + if ($item == $value) { + return $item; + } else { + continue; + } + } + + if(in_array($value, $item)) { + return $item; + } else if(deep_in_array($value, $item)) { + return $item; + } + } + return false; +} +/** + * 对象 转 数组 + * + * @param object $obj 对象 + * @return array + */ +function object_to_array($obj) { + $obj = (array)$obj; + foreach ($obj as $k => $v) { + if (gettype($v) == 'resource') { + return; + } + if (gettype($v) == 'object' || gettype($v) == 'array') { + $obj[$k] = (array)object_to_array($v); + } + } + + return $obj; +} +function parseArr($str=''){ + + $str=str_replace(array('[',']'),'', $str); + $str=trim($str,'"'); + $str=explode('","', $str); + + array_walk($str,"walkparse"); + $maps=[]; + if(count($str)){ + foreach ($str as $vo){ + $vo=explode('=', $vo); + if(count($vo)==2){ + $key=isset($vo[0])?$vo[0]:''; + $val=isset($vo[1])?$vo[1]:''; + if($key)$maps[$key]=$val; + } + } + } + return $maps; +} +function walkparse(&$value,$key){ + $value=urldecode($value); + $value = str_replace(array("/r/n", "/r", "/n"), "", $value); + $value = str_replace(array(" "), "", $value); +} +function parseTd($str='',$id='',$tag=''){ + + $str=str_replace(array('[',']'),'', $str); + $str=trim($str,'"'); + $str=explode('","', $str); + $html=''; + array_walk($str,"walkparse"); + if(count($str)){ + $data=implode('&', $str); + $html.=''; + $html.=''.$id.''; + foreach ($str as $count=>$vo){ + $vo=explode('=', $vo); + if(count($vo)==2){ + if(isset($vo[1])&&$vo[1]){ + if($tag==3&&$count==0){ + $title='艺术品资产托管'; + if($vo[1]==2)$title='艺品拍'; + $html.=''.$title.''; + }else{ + $html.=''.$vo[1].''; + } + continue; + } + } + $html.='  '; + + } + $html.='  '; + } + return $html; +} +// 应用公共文件 +//中文截取 +function sub_str($str,$length =0,$append = true,$dot='...') +{ + + $str = trim($str); + $strlength = strlen($str); + + if(!defined('EC_CHARSET'))define('EC_CHARSET','utf-8'); + + if ($length == 0 || $length >= $strlength){ + return $str; //截取长度等于0或大于等于本字符串的长度,返回字符串本身 + }elseif ($length < 0){ //如果截取长度为负数 + $length = $strlength + $length;//那么截取长度就等于字符串长度减去截取长度 + if ($length < 0){ + $length = $strlength;//如果截取长度的绝对值大于字符串本身长度,则截取长度取字符串本身的长度 + } + } + + if (function_exists('mb_substr')){ + $newstr = mb_substr($str, 0, $length, EC_CHARSET); + }elseif (function_exists('iconv_substr')){ + $newstr = iconv_substr($str, 0, $length, EC_CHARSET); + }else{ + //$newstr = trim_right(substr($str, 0, $length)); + $newstr = substr($str, 0, $length); + } + + if ($append && $str != $newstr){ + $newstr .=$dot; + } + + return $newstr; +} +/** + * 所有用到密码的不可逆加密方式 + * @author rainfer <81818832@qq.com> + * @param string $password + * @param string $password_salt + * @return string + */ +function encrypt_password($password, $password_salt) +{ + return md5(md5($password) . md5($password_salt)); +} +/** + * 列出本地目录的文件 + * @author rainfer <81818832@qq.com> + * @param string $path + * @param string $pattern + * @return array + */ +function list_file($path, $pattern = '*') +{ + if (strpos($pattern, '|') !== false) { + $patterns = explode('|', $pattern); + } else { + $patterns [0] = $pattern; + } + $i = 0; + $dir = array(); + if (is_dir($path)) { + $path = rtrim($path, '/') . '/'; + } + foreach ($patterns as $pattern) { + $list = glob($path . $pattern); + if ($list !== false) { + foreach ($list as $file) { + $dir [$i] ['filename'] = basename($file); + $dir [$i] ['path'] = dirname($file); + $dir [$i] ['pathname'] = realpath($file); + $dir [$i] ['owner'] = fileowner($file); + $dir [$i] ['perms'] = substr(base_convert(fileperms($file), 10, 8), -4); + $dir [$i] ['atime'] = fileatime($file); + $dir [$i] ['ctime'] = filectime($file); + $dir [$i] ['mtime'] = filemtime($file); + $dir [$i] ['size'] = filesize($file); + $dir [$i] ['type'] = filetype($file); + $dir [$i] ['ext'] = is_file($file) ? strtolower(substr(strrchr(basename($file), '.'), 1)) : ''; + $dir [$i] ['isDir'] = is_dir($file); + $dir [$i] ['isFile'] = is_file($file); + $dir [$i] ['isLink'] = is_link($file); + $dir [$i] ['isReadable'] = is_readable($file); + $dir [$i] ['isWritable'] = is_writable($file); + $i++; + } + } + } + $cmp_func = @create_function('$a,$b', ' + if( ($a["isDir"] && $b["isDir"]) || (!$a["isDir"] && !$b["isDir"]) ){ + return $a["filename"]>$b["filename"]?1:-1; + }else{ + if($a["isDir"]){ + return -1; + }else if($b["isDir"]){ + return 1; + } + if($a["filename"] == $b["filename"]) return 0; + return $a["filename"]>$b["filename"]?-1:1; + } + '); + usort($dir, $cmp_func); + return $dir; +} +/** + * 删除文件夹 + * @author rainfer <81818832@qq.com> + * @param string + * @param int + */ +function remove_dir($dir, $time_thres = -1) +{ + foreach (list_file($dir) as $f) { + if ($f ['isDir']) { + remove_dir($f ['pathname'] . '/'); + } else if ($f ['isFile'] && $f ['filename']) { + if ($time_thres == -1 || $f ['mtime'] < $time_thres) { + @unlink($f ['pathname']); + } + } + } +} +/** + * 格式化字节大小 + * @param number $size 字节数 + * @param string $delimiter 数字和单位分隔符 + * @return string 格式化后的带单位的大小 + * @author rainfer <81818832@qq.com> + */ +function format_bytes($size, $delimiter = '') +{ + $units = array(' B', ' KB', ' MB', ' GB', ' TB', ' PB'); + for ($i = 0; $size >= 1024 && $i < 5; $i++) $size /= 1024; + return round($size, 2) . $delimiter . $units[$i]; +} +/** + * curl访问 + * @author rainfer <81818832@qq.com> + * @param string $url + * @param string $type + * @param boolean $data + * @param string $err_msg + * @param int $timeout + * @param array $cert_info + * @return string + */ +function go_curl2($url, $type, $data = false, $header=array(),&$err_msg = null, $timeout = 20,$cert_info = array()) +{ + $type = strtoupper($type); + if ($type == 'GET' && is_array($data)) { + $data = http_build_query($data); + } + $option = array(); + if ( $type == 'POST' ) { + $option[CURLOPT_POST] = 1; + } + if ($data) { + if ($type == 'POST') { + $option[CURLOPT_POSTFIELDS] = http_build_query($data); + } elseif ($type == 'GET') { + $url = strpos($url, '?') !== false ? $url.'&'.$data : $url.'?'.$data; + } + } + $option[CURLOPT_URL] = $url; + $option[CURLOPT_FOLLOWLOCATION] = TRUE; + $option[CURLOPT_MAXREDIRS] = 4; + $option[CURLOPT_RETURNTRANSFER] = TRUE; + $option[CURLOPT_TIMEOUT] = $timeout; + if(count($header)){ + $option[CURLOPT_HTTPHEADER] =$header; + } + //设置证书信息 + if(!empty($cert_info) && !empty($cert_info['cert_file'])) { + $option[CURLOPT_SSLCERT] = $cert_info['cert_file']; + $option[CURLOPT_SSLCERTPASSWD] = $cert_info['cert_pass']; + $option[CURLOPT_SSLCERTTYPE] = $cert_info['cert_type']; + } + //设置CA + if(!empty($cert_info['ca_file'])) { + // 对认证证书来源的检查,0表示阻止对证书的合法性的检查。1需要设置CURLOPT_CAINFO + $option[CURLOPT_SSL_VERIFYPEER] = 1; + $option[CURLOPT_CAINFO] = $cert_info['ca_file']; + } else { + // 对认证证书来源的检查,0表示阻止对证书的合法性的检查。1需要设置CURLOPT_CAINFO + $option[CURLOPT_SSL_VERIFYPEER] = 0; + } + $ch = curl_init(); + curl_setopt_array($ch, $option); + $response = curl_exec($ch); + $curl_no = curl_errno($ch); + $curl_err = curl_error($ch); + curl_close($ch); + // error_log + if($curl_no > 0) { + if($err_msg !== null) { + $err_msg = '('.$curl_no.')'.$curl_err; + } + } + return $response; +} +function go_curl($url, $type, $data = false, $header=array(),&$err_msg = null, $timeout = 20,$cert_info = array()) +{ + $type = strtoupper($type); + $ch = curl_init(); + $option = array(); + if ($data) { + if ($type == 'GET') { + if (is_array($data)) { + $data = http_build_query($data); + } + $url = strpos($url, '?') !== false ? $url.'&'.$data : $url.'?'.$data; + } + } + curl_setopt($ch, CURLOPT_URL,$url); + //设置CA + if(!empty($cert_info['ca_file'])) { + // 对认证证书来源的检查,0表示阻止对证书的合法性的检查。1需要设置CURLOPT_CAINFO + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,1); + curl_setopt($ch, CURLOPT_CAINFO,$cert_info['ca_file']); + } else { + // 对认证证书来源的检查,0表示阻止对证书的合法性的检查。1需要设置CURLOPT_CAINFO + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,false); + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,false); + } + curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1); + curl_setopt($ch, CURLOPT_MAXREDIRS,4); + curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); + if ( $type == 'POST' ) { + curl_setopt($ch, CURLOPT_POST, 1); + if ($data) { + if(count($data))$data=http_build_query($data); + curl_setopt($ch, CURLOPT_POSTFIELDS,$data); + }else{ + curl_setopt($ch, CURLOPT_POSTFIELDS,[]); + } + } + curl_setopt($ch, CURLOPT_TIMEOUT,$timeout); + if(count($header)){ + curl_setopt($ch, CURLOPT_HEADER,0); + curl_setopt($ch, CURLOPT_HTTPHEADER,$header); + } + //设置证书信息 + if(!empty($cert_info) && !empty($cert_info['cert_file'])) { + curl_setopt($ch, CURLOPT_SSLCERT,$cert_info['cert_file']); + curl_setopt($ch, CURLOPT_SSLCERTPASSWD,$cert_info['cert_pass']); + curl_setopt($ch, CURLOPT_SSLCERTTYPE,$cert_info['cert_type']); + } + + $response = curl_exec($ch); + $curl_no = curl_errno($ch); + $curl_err = curl_error($ch); + curl_close($ch); + // error_log + if($curl_no > 0) { + if($err_msg !== null) { + $err_msg = '('.$curl_no.')'.$curl_err; + } + } + + return $response; +} +/** + * 设置全局配置到文件 + * + * @param $key + * @param $value + * @return boolean + */ +function sys_config_setbykey($key, $value) +{ + $file = ROOT_PATH.'data/conf/config.php'; + $cfg = array(); + if (file_exists($file)) { + $cfg = include $file; + } + $item = explode('.', $key); + switch (count($item)) { + case 1: + $cfg[$item[0]] = $value; + break; + case 2: + $cfg[$item[0]][$item[1]] = $value; + break; + } + return file_put_contents($file, " + */ +function get_host() +{ + $host=$_SERVER["HTTP_HOST"]; + $protocol=Request::instance()->isSsl()?"https://":"http://"; + return $protocol.$host; +} +/** + * ajax数据返回,规范格式 + * @param array $data 返回的数据,默认空数组 + * @param string $msg 信息,一般用于错误信息提示 + * @param int $code 错误码,0-未出现错误|其他出现错误 + * @param array $extend 扩展数据 + * @return string + */ +function ajax_return($data = [], $msg = "", $code = 0, $extend = []) +{ + $msg=empty($msg)?'失败':$msg; + $ret = ["code" => $code, "msg" => $msg, "data" => $data]; + $ret = array_merge($ret, $extend); + return Response::create($ret, 'json'); +} +/** + * 根据用户id获取用户组,返回值为字符串 + * @param int $uid 用户id + * @return string + */ +function get_groups($uid) +{ + $auth = new Auth(); + $group = $auth->getGroups($uid); + if($group) + return $group[0]['title']; + else + { + $user_groups = db()->name('auth_group_access a') + ->where("a.uid='$uid'") + ->join(config('database.prefix')."auth_group g"," a.group_id = g.id") + ->field('uid,group_id,title,rules')->select(); + if($user_groups) + return '
组已禁用
 | '.$user_groups[0]['title']; + else + return '
不存在
'; + } +} +/** + * 随机字符 + * @param int $length 长度 + * @param string $type 类型 + * @param int $convert 转换大小写 1大写 0小写 + * @return string + */ +function random($length=10, $type='letter', $convert=0) +{ + $config = array( + 'number'=>'1234567890', + 'letter'=>'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', + 'string'=>'abcdefghjkmnpqrstuvwxyzABCDEFGHJKMNPQRSTUVWXYZ23456789', + 'all'=>'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890' + ); + + if(!isset($config[$type])) $type = 'letter'; + $string = $config[$type]; + + $code = ''; + $strlen = strlen($string) -1; + for($i = 0; $i < $length; $i++){ + $code .= $string{mt_rand(0, $strlen)}; + } + if(!empty($convert)){ + $code = ($convert > 0)? strtoupper($code) : strtolower($code); + } + return $code; +} +/** + * 是否存在控制器 + * @param string $module 模块 + * @param string $controller 待判定控制器名 + * @return boolean + */ +function has_controller($module,$controller) +{ + $arr=\ReadClass::readDir(APP_PATH . $module. DS .'controller'); + if((!empty($arr[$controller])) && $arr[$controller]['class_name']==$controller){ + return true; + }else{ + return false; + } +} +/** + * 是否存在方法 + * @param string $module 模块 + * @param string $controller 待判定控制器名 + * @param string $action 待判定控制器名 + * @return number 方法结果,0不存在控制器 1存在控制器但是不存在方法 2存在控制和方法 + */ +function has_action($module,$controller,$action) +{ + $arr=\ReadClass::readDir(APP_PATH . $module. DS .'controller'); + if((!empty($arr[$controller])) && $arr[$controller]['class_name']==$controller ){ + $method_name=array_map('array_shift',$arr[$controller]['method']); + if(in_array($action, $method_name)){ + return 2; + }else{ + return 1; + } + }else{ + return 0; + } +} +/** + * 返回不含前缀的数据库表数组 + * + * @author rainfer <81818832@qq.com> + * @param bool + * @return array + */ +function db_get_tables($prefix=false) +{ + $db_prefix =config('database.prefix'); + $list = Db::query('SHOW TABLE STATUS FROM '.config('database.database')); + $list = array_map('array_change_key_case', $list); + $tables = array(); + foreach($list as $k=>$v){ + if(empty($prefix)){ + if(stripos($v['name'],strtolower(config('database.prefix')))===0){ + $tables [] = strtolower(substr($v['name'], strlen($db_prefix))); + } + }else{ + $tables [] = strtolower($v['name']); + } + + } + return $tables; +} +/** + * 返回数据表的sql + * + * @author rainfer <81818832@qq.com> + * + * @param $table : 不含前缀的表名 + * @return string + */ +function db_get_insert_sqls($table) +{ + $db_prefix =config('database.prefix'); + $db_prefix_re = preg_quote($db_prefix); + $db_prefix_holder = db_get_db_prefix_holder(); + $export_sqls = array(); + $export_sqls [] = "DROP TABLE IF EXISTS $db_prefix_holder$table"; + switch (config('database.type')) { + case 'mysql' : + if (!($d = Db::query("SHOW CREATE TABLE $db_prefix$table"))) { + $this->error("'SHOW CREATE TABLE $table' Error!"); + } + $table_create_sql = $d [0] ['Create Table']; + $table_create_sql = preg_replace('/' . $db_prefix_re . '/', $db_prefix_holder, $table_create_sql); + $export_sqls [] = $table_create_sql; + $data_rows = Db::query("SELECT * FROM $db_prefix$table"); + $data_values = array(); + foreach ($data_rows as &$v) { + foreach ($v as &$vv) { + //TODO mysql_real_escape_string替换方法 + //$vv = "'" . @mysql_real_escape_string($vv) . "'"; + $vv = "'" . addslashes(str_replace(array("\r","\n"),array('\r','\n'),$vv)) . "'"; + } + $data_values [] = '(' . join(',', $v) . ')'; + } + if (count($data_values) > 0) { + $export_sqls [] = "INSERT INTO `$db_prefix_holder$table` VALUES \n" . join(",\n", $data_values); + } + break; + } + return join(";\n", $export_sqls) . ";"; +} +/** + * 检测当前数据库中是否含指定表 + * + * @author rainfer <81818832@qq.com> + * + * @param $table : 不含前缀的数据表名 + * @return bool + */ +function db_is_valid_table_name($table) +{ + return in_array($table, db_get_tables()); +} +/** + * 不检测表前缀,恢复数据库 + * + * @author rainfer <81818832@qq.com> + * + * @param $file + * @param $prefix + */ +function db_restore_file($file,$prefix='') +{ + $prefix=$prefix?:db_get_db_prefix_holder(); + $db_prefix=config('database.prefix'); + $sqls = file_get_contents($file); + $sqls = str_replace($prefix, $db_prefix, $sqls); + $sqlarr = explode(";\n", $sqls); + foreach ($sqlarr as &$sql) { + Db::execute($sql); + } +} +/** + * 返回表前缀替代符 + * @author rainfer <81818832@qq.com> + * + * @return string + */ +function db_get_db_prefix_holder() +{ + return '<--db-prefix-->'; +} +/** + * 强制下载 + * @author rainfer <81818832@qq.com> + * + * @param string $filename + * @param string $content + */ +function force_download_content($filename, $content) +{ + header("Pragma: public"); + header("Expires: 0"); + header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); + header("Content-Type: application/force-download"); + header("Content-Transfer-Encoding: binary"); + header("Content-Disposition: attachment; filename=$filename"); + echo $content; + exit (); +} +/** + * 生成参数列表,以数组形式返回 + * @author rainfer <81818832@qq.com> + * @param string + * @return array + */ +function param2array($tag = '') +{ + $param = array(); + $array = explode(';',$tag); + foreach ($array as $v){ + $v=trim($v); + if(!empty($v)){ + list($key,$val) = explode(':',$v); + $param[trim($key)] = trim($val); + } + } + return $param; +} +/** + * 获取新闻分类ids + * @author rainfer <81818832@qq.com> + * + * @param int $id 待获取的id + * @param boolean $self 是否返回自身,默认false + * @param int $open 1表示只显示menu_open=1的,0表示只显示menu_open=0的,2表示不限制 + * @param string $field 默认只返回id数组(一维),其它如:"*"表示全部字段,"id,menu_name"表示返回二维数组 + * @param boolean $lang 是否只返回当前语言下分类,默认false + * @return array|mixed + */ +function get_menu_byid($id=0,$self=false,$open=0,$field='id',$lang=false) +{ + if(empty($open)){ + $where['menu_open']=0; + }elseif($open==1){ + $where['menu_open']=1; + }else{ + $where=array(); + } + $where['menu_l']='zh-cn'; + $arr=Db::name('menu')->where($where)->where(array('id'=>$id))->select(); + if($arr){ + $tree=new \Tree(); + $tree->init($arr); + $rst=$tree->get_childs($arr,$id,true,true); + }else{ + $rst=$self?array($id):array(); + } + if(empty($field) || $field=='id'){ + return $rst; + }else{ + $where=array(); + $where['id']=array('in',$rst); + $arr=Db::name('menu')->where($where)->field($field)->order('listorder asc')->select(); + return $arr; + } +} +/** + * 截取文字 + * @author rainfer <81818832@qq.com> + * + * @param string $text + * @param int $length + * @return string + */ +function subtext($text, $length) +{ + if(mb_strlen($text, 'utf8') > $length) + return mb_substr($text, 0, $length, 'utf8').'...'; + return $text; +} +/** + * 将内容存到Storage中,返回转存后的文件路径 + * @author rainfer <81818832@qq.com> + * @param string $ext + * @param string $content + * @return string + */ +function save_storage_content($ext = null, $content = null) +{ + $newfile = ''; + $path='./data/upload/'; + $path=substr($path,0,2)=='./' ? substr($path,2) :$path; + $path=substr($path,0,1)=='/' ? substr($path,1) :$path; + if ($ext && $content) { + do { + $newfile = $path.date('Y-m-d/') . uniqid() . '.' . $ext; + } while (file_exists($newfile)); + $dir = dirname($newfile); + if (!is_dir($dir)) { + mkdir($dir, 0777, true); + } + file_put_contents($newfile, $content); + } + return $newfile; +} +/** + * 获取所有友情连接 + * @author rainfer <81818832@qq.com> + * @param int + * @return array|mixed + */ +function get_links($lk_cid=1) +{ + $links=cache('links_'.$lk_cid); + if(!$links){ + $links=Db::name("link")->where(array('lk_cid'=>$lk_cid,'lk_status'=>1))->order("lk_order")->select(); + cache('links_'.$lk_cid,$links); + } + return $links; +} +/** + * 返回指定id的菜单 + * @param int $id 表示获得这个ID下的所有子级 + * @param string $top_ul_id 顶级菜单ul的id + * @param string $childtpl 子菜单模板 + * @param string $parenttpl 父菜单模板 + * @param int $showlevel 直接显示层级数,其余为异步显示,0为全部限制 + * @param string $ul_class 子菜单ul样式 + * @param string $li_class 子菜单li样式 + * @param string $top_ul_class 顶级菜单ul的样式 + * @param string $dropdown 有子元素时li的class + * @return string + */ +function get_menu($id=0,$top_ul_id="",$childtpl="\$label",$parenttpl="\$label",$ul_class="" ,$li_class="" ,$top_ul_class="filetree",$showlevel=6,$dropdown='hasChild') +{ + $navs=cache("site_nav"); + if(empty($navs)){ + $navs=get_menu_datas(); + } + $tree = new \Tree(); + $tree->init($navs); + return $tree->get_treeview_menu($id,$top_ul_id, $childtpl, $parenttpl, $showlevel,$ul_class,$li_class, $top_ul_class, 1, FALSE, $dropdown); +} +/** + * 返回指定id的菜单 + * @return array|mixed + */ +function get_menu_datas() +{ + $navs= Db::name("menu")->where('menu_l',Lang::detect())->where(array('menu_open'=>1,'top'=>1))->order(array("listorder" => "ASC"))->select(); + foreach ($navs as $key=>$nav){ + if($nav['menu_type']==2){ + $nav['href']=$nav['menu_address']; + }elseif($nav['menu_type']==4){ + //为了匹配单页路由 + $nav['href']=url('home/Listn/index?id='.$nav['id']); + }else{ + $nav['href']=url('home/Listn/index',array('id'=>$nav['id'])); + if(strtolower($nav['menu_enname'])=='home' && $nav['parentid']==0){ + $nav['href']=url('home/Index/index'); + } + } + $navs[$key]=$nav; + } + cache("site_nav",$navs); + return $navs; +} +/** + * 返回指定id的菜单 + * @param int + * @return array + */ +function get_menu_tree($id) +{ + $navs=cache("site_nav"); + if(empty($navs)){ + $navs=get_menu_datas(); + } + $tree = new \Tree(); + $tree->init($navs); + return $tree->get_tree_array($id); +} +/** + * 截取待html的文本 + * @author rainfer <81818832@qq.com> + * @param string $html + * @param int $max + * @param string $suffix + * @return string; + */ +function html_trim($html, $max, $suffix='...') +{ + $html = trim($html); + if(strlen($html)<= $max){ + return $html; + } + $non_paired_tags = array('br', 'hr', 'img', 'input', 'param'); + $html = preg_replace('/]+)>/i', '', $html); + $count = 0; + $tag_status = 0; + $nodes = array(); + $segment = ''; + $tag_name = ''; + for($i=0;$i' || $char == "\t") + { + $tag_status = 3; + }else + { + $tag_name .= $char; + } + } + if($tag_status == 3 && $char == '>') + { + $tag_status = 4; + $tag_name = strtolower($tag_name); + $tag_type = 1; + if(in_array($tag_name, $non_paired_tags)) + { + $tag_type = 0; + }elseif($tag_name[0] == '/') + { + $tag_type = 2; + } + $nodes[] = array(1, $segment, $tag_name, $tag_type); + $segment = ''; + } + if($tag_status == 0) + { + if($char == '&') + { + for($e=1;$e<=10;$e++) + { + if($html[$i+$e] == ';') + { + $segment .= substr($html, $i+1, $e); + $i += $e; + break; + } + } + }else + { + $char_code = ord($char); + if($char_code >= 224) + { + $segment .= $html[$i+1].$html[$i+2]; + $i += 2; + }elseif($char_code >= 129) + { + $segment .= $html[$i+1]; + $i += 1; + } + } + $count ++; + if($count == $max) + { + $nodes[] = array(0, $segment.$suffix, 'text',0); + break; + } + } + } + $html = ''; + $tag_open_stack = array(); + for($i=0;$i'; + } + return $html; +} + +/** + * 获取当前request参数数组,去除值为空 + * @param string + * @param int + * @param int + * @param string + * @param bool + * @return string + */ +function msubstr($str, $start=0, $length, $charset="utf-8", $suffix=true) +{ + if(function_exists("mb_substr")) + $slice = mb_substr($str, $start, $length, $charset); + elseif(function_exists('iconv_substr')) { + $slice = iconv_substr($str,$start,$length,$charset); + if(false === $slice) { + $slice = ''; + } + }else{ + $re['utf-8'] = "/[\x01-\x7f]|[\xc2-\xdf][\x80-\xbf]|[\xe0-\xef][\x80-\xbf]{2}|[\xf0-\xff][\x80-\xbf]{3}/"; + $re['gb2312'] = "/[\x01-\x7f]|[\xb0-\xf7][\xa0-\xfe]/"; + $re['gbk'] = "/[\x01-\x7f]|[\x81-\xfe][\x40-\xfe]/"; + $re['big5'] = "/[\x01-\x7f]|[\x81-\xfe]([\x40-\x7e]|\xa1-\xfe])/"; + preg_match_all($re[$charset], $str, $match); + $slice = join("",array_slice($match[0], $start, $length)); + } + return ($suffix && $slice!=$str)? $slice.'...' : $slice; +} +/** + * 获取单页面菜单 + * @author rainfer <81818832@qq.com> + * + * @param int $id 菜单id + * @return array; + */ +function get_menu_one($id) +{ + $rst=array(); + if($id){ + $rst=Db::name('menu')->where('menu_l',Lang::detect())->where(array('menu_type'=>4,'id'=>$id))->find(); + } + return $rst; +} +/** + * 检查用户对某个url,内容的可访问性,用于记录如是否赞过,是否访问过等等;开发者可以自由控制,对于没有必要做的检查可以不做,以减少服务器压力 + * @param string $object 访问对象的id,格式:不带前缀的表名+id;如news1表示xx_news表里id为1的记录;如果object为空,表示只检查对某个url访问的合法性 + * @param int $count_limit 访问次数限制,如1,表示只能访问一次,0表示不限制 + * @param boolean $ip_limit ip限制,false为不限制,true为限制 + * @param int $expire 距离上次访问的最小时间单位s,0表示不限制,大于0表示最后访问$expire秒后才可以访问 + * @return true 可访问,false不可访问 + */ +function check_user_action($object="",$count_limit=1,$ip_limit=false,$expire=0) +{ + $action=request()->module()."-".request()->controller()."-".request()->action(); + $userid=session('hid')?session('hid'):0; + $ip=request()->ip(); + $where=array("uid"=>$userid,"action"=>$action,"object"=>$object); + if($ip_limit){ + $where['ip']=$ip; + } + $find_log=Db::name("action_log")->where($where)->find(); + $time=time(); + if($find_log){ + //次数限制 + if($count_limit>0 && $find_log['count']>=$count_limit){ + return false; + } + //时间限制 + if($expire>0 && ($time-$find_log['last_time'])<$expire){ + return false; + } + Db::name("action_log")->where($where)->update(array("count"=>array("exp","count+1"),"last_time"=>$time,"ip"=>$ip)); + }else{ + Db::name("action_log")->insert(array("uid"=>$userid,"action"=>$action,"object"=>$object,"count"=>array("exp","count+1"),"last_time"=>$time,"ip"=>$ip)); + } + return true; +} +/** + * 发送邮件 + * @author rainfer <81818832@qq.com> + * @param string $to 收件人邮箱 + * @param string $title 标题 + * @param string $content 内容 + * @return array + */ +function sendMail($to, $title, $content) +{ + $email_options=get_email_options(); + if($email_options && $email_options['email_open']){ + $mail = new PHPMailer(); //实例化 + // 设置PHPMailer使用SMTP服务器发送Email + $mail->IsSMTP(); + $mail->Mailer='smtp'; + $mail->IsHTML(true); + // 设置邮件的字符编码,若不指定,则为'UTF-8' + $mail->CharSet='UTF-8'; + // 添加收件人地址,可以多次使用来添加多个收件人 + $mail->AddAddress($to); + // 设置邮件正文 + $mail->Body=$content; + // 设置邮件头的From字段。 + $mail->From=$email_options['email_name']; + // 设置发件人名字 + $mail->FromName=$email_options['email_rename']; + // 设置邮件标题 + $mail->Subject=$title; + // 设置SMTP服务器。 + $mail->Host=$email_options['email_smtpname']; + //by Rainfer + // 设置SMTPSecure。 + $mail->SMTPSecure=$email_options['smtpsecure']; + // 设置SMTP服务器端口。 + $port=$email_options['smtp_port']; + $mail->Port=empty($port)?"25":$port; + // 设置为"需要验证" + $mail->SMTPAuth=true; + // 设置用户名和密码。 + $mail->Username=$email_options['email_emname']; + $mail->Password=$email_options['email_pwd']; + // 发送邮件。 + if(!$mail->Send()) { + $mailerror=$mail->ErrorInfo; + return array("error"=>1,"message"=>$mailerror); + }else{ + return array("error"=>0,"message"=>"success"); + } + }else{ + return array("error"=>1,"message"=>'未开启邮件发送或未配置'); + } +} +/** + * 获取后台管理设置的邮件连接 + * @author rainfer <81818832@qq.com> + * @return array + */ +function get_email_options() +{ + $email_options = cache("email_options"); + if(empty($email_options)){ + $option = Db::name("Options")->where('option_l',Lang::detect())->where("option_name='email_options'")->find(); + if($option){ + $email_options = json_decode($option['option_value'],true); + }else{ + $email_options = array(); + } + cache("email_options", $email_options); + } + return $email_options; +} +/** + * 获取后台管理设置的邮件激活连接 + * @author rainfer <81818832@qq.com> + * @return array + */ +function get_active_options() +{ + $active_options = cache("active_options"); + if(empty($active_options)){ + $option = Db::name("Options")->where('option_l',Lang::detect())->where("option_name='active_options'")->find(); + if($option){ + $active_options = json_decode($option['option_value'],true); + }else{ + $active_options = array(); + } + cache("active_options", $active_options); + } + return $active_options; +} +/** + * 实时显示提示信息 + * @param string $msg 提示信息 + * @param string $class 输出样式(success:成功,error:失败) + * @author huajie + */ +function showmsg($msg, $class = '') +{ + echo ""; + flush(); + ob_flush(); +} +/** + * 加密函数 + * @param string $txt 需加密的字符串 + * @param string $key 加密密钥,默认读取data_auth_key配置 + * @return string 加密后的字符串 + */ +function jiami($txt, $key = null) +{ + empty($key) && $key = config('data_auth_key'); + $chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-=_"; + $nh = rand(0, 64); + $ch = $chars[$nh]; + $mdKey = md5($key . $ch); + $mdKey = substr($mdKey, $nh % 8, $nh % 8 + 7); + $txt = base64_encode($txt); + $tmp = ''; + $k = 0; + for ($i = 0; $i < strlen($txt); $i++) { + $k = $k == strlen($mdKey) ? 0 : $k; + $j = ($nh + strpos($chars, $txt [$i]) + ord($mdKey[$k++])) % 64; + $tmp .= $chars[$j]; + } + return $ch . $tmp; +} + +/** + * 解密函数 + * @param string $txt 待解密的字符串 + * @param string $key 解密密钥,默认读取data_auth_key配置 + * @return string 解密后的字符串 + */ +function jiemi($txt, $key = null) +{ + empty($key) && $key = config('data_auth_key'); + $chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-=_"; + $ch = $txt[0]; + $nh = strpos($chars, $ch); + $mdKey = md5($key . $ch); + $mdKey = substr($mdKey, $nh % 8, $nh % 8 + 7); + $txt = substr($txt, 1); + $tmp = ''; + $k = 0; + for ($i = 0; $i < strlen($txt); $i++) { + $k = $k == strlen($mdKey) ? 0 : $k; + $j = strpos($chars, $txt[$i]) - $nh - ord($mdKey[$k++]); + while ($j < 0) { + $j += 64; + } + $tmp .= $chars[$j]; + } + return base64_decode($tmp); +} +/** + * 获取图片完整路径 + * @param string $url 待获取图片url + * @param int $cat 待获取图片类别 0为文章 1前台头像 2后台头像 + * @return string 完整图片imgurl + */ +function get_imgurl($url,$cat=0) +{ + if(stripos($url,'http')!==false){ + //网络图片 + return $url; + }elseif($url && stripos($url,'/')===false && stripos($url,'\\')===false){ + //头像 + return __ROOT__.'/data/upload/avatar/'.$url; + }elseif(empty($url)){ + //$url为空 + if($cat==2){ + $imgurl='girl.jpg'; + }elseif($cat==1){ + $imgurl='headicon.png'; + }else{ + $imgurl='no_img.jpg'; + } + return __ROOT__.'/public/img/'.$imgurl; + }else{ + //本地上传图片 + return __ROOT__.$url; + } +} +/** + * 获取当前request参数数组,去除值为空 + * @return array + */ +function get_query() +{ + $param=request()->except(['s']); + $rst=array(); + foreach($param as $k=>$v){ + if(!empty($v)){ + $rst[$k]=$v; + } + } + return $rst; +} +/** + * 货币转换 + * @param float + * @return string + */ +function long_currency($long) +{ + return sprintf('%d.%02d', intval($long / 100), intval($long % 100)); +} +/** + * 货币转换 + * @param string + * @return float + */ +function currency_long($currency) +{ + $s = explode('.', trim($currency)); + switch (count($s)) { + case 1: + return $s[0] * 100; + case 2: + if (strlen($s[1]) == 1) { + $s[1] .= '0'; + } else if (strlen($s[1]) > 2) { + $s[1] = substr($s[1], 0, 2); + } + return $s[0] * 100 + $s[1]; + } + return 0; +} +/** + * 获取客户端浏览器信息 添加win10 edge浏览器判断 + * @author Jea杨 + * @return string + */ +function getBroswer($arr=false) +{ + $arr=$arr?:false; + $sys = $_SERVER['HTTP_USER_AGENT']; //获取用户代理字符串 + if (stripos($sys, "Firefox/") > 0) { + preg_match("/Firefox\/([^;)]+)+/i", $sys, $b); + $exp[0] = "Firefox"; + $exp[1] = $b[1]; //获取火狐浏览器的版本号 + } elseif (stripos($sys, "Maxthon") > 0) { + preg_match("/Maxthon\/([\d\.]+)/", $sys, $aoyou); + $exp[0] = "傲游"; + $exp[1] = $aoyou[1]; + } elseif (stripos($sys, "MSIE") > 0) { + preg_match("/MSIE\s+([^;)]+)+/i", $sys, $ie); + $exp[0] = "IE"; + $exp[1] = $ie[1]; //获取IE的版本号 + } elseif (stripos($sys, "OPR") > 0) { + preg_match("/OPR\/([\d\.]+)/", $sys, $opera); + $exp[0] = "Opera"; + $exp[1] = $opera[1]; + } elseif (stripos($sys, "Edge") > 0) { + //win10 Edge浏览器 添加了chrome内核标记 在判断Chrome之前匹配 + preg_match("/Edge\/([\d\.]+)/", $sys, $Edge); + $exp[0] = "Edge"; + $exp[1] = $Edge[1]; + } elseif (stripos($sys, "Chrome") > 0) { + preg_match("/Chrome\/([\d\.]+)/", $sys, $google); + $exp[0] = "Chrome"; + $exp[1] = $google[1]; //获取google chrome的版本号 + } elseif (stripos($sys, 'rv:') > 0 && stripos($sys, 'Gecko') > 0) { + preg_match("/rv:([\d\.]+)/", $sys, $IE); + $exp[0] = "IE"; + $exp[1] = $IE[1]; + } elseif (stripos($sys, 'Safari') > 0) { + preg_match("/safari\/([^\s]+)/i", $sys, $safari); + $exp[0] = "Safari"; + $exp[1] = $safari[1]; + } else { + $exp[0] = "未知浏览器"; + $exp[1] = ""; + } + if($arr){ + return $exp; + }else{ + return $exp[0] . '(' . $exp[1] . ')'; + } +} + +/** + * 获取客户端操作系统信息包括win10 + * @author Jea杨 + * @return string + */ +function getOs() +{ + $agent = $_SERVER['HTTP_USER_AGENT']; + + if (preg_match('/win/i', $agent) && strpos($agent, '95')) { + $os = 'Windows 95'; + } else if (preg_match('/win 9x/i', $agent) && strpos($agent, '4.90')) { + $os = 'Windows ME'; + } else if (preg_match('/win/i', $agent) && preg_match('/98/i', $agent)) { + $os = 'Windows 98'; + } else if (preg_match('/win/i', $agent) && preg_match('/nt 6.0/i', $agent)) { + $os = 'Windows Vista'; + } else if (preg_match('/win/i', $agent) && preg_match('/nt 6.1/i', $agent)) { + $os = 'Windows 7'; + } else if (preg_match('/win/i', $agent) && preg_match('/nt 6.2/i', $agent)) { + $os = 'Windows 8'; + } else if (preg_match('/win/i', $agent) && preg_match('/nt 10.0/i', $agent)) { + $os = 'Windows 10';#添加win10判断 + } else if (preg_match('/win/i', $agent) && preg_match('/nt 5.1/i', $agent)) { + $os = 'Windows XP'; + } else if (preg_match('/win/i', $agent) && preg_match('/nt 5/i', $agent)) { + $os = 'Windows 2000'; + } else if (preg_match('/win/i', $agent) && preg_match('/nt/i', $agent)) { + $os = 'Windows NT'; + } else if (preg_match('/win/i', $agent) && preg_match('/32/i', $agent)) { + $os = 'Windows 32'; + } else if (preg_match('/linux/i', $agent)) { + $os = 'Linux'; + } else if (preg_match('/unix/i', $agent)) { + $os = 'Unix'; + } else if (preg_match('/sun/i', $agent) && preg_match('/os/i', $agent)) { + $os = 'SunOS'; + } else if (preg_match('/ibm/i', $agent) && preg_match('/os/i', $agent)) { + $os = 'IBM OS/2'; + } else if (preg_match('/Mac/i', $agent)) { + $os = 'Mac'; + } else if (preg_match('/PowerPC/i', $agent)) { + $os = 'PowerPC'; + } else if (preg_match('/AIX/i', $agent)) { + $os = 'AIX'; + } else if (preg_match('/HPUX/i', $agent)) { + $os = 'HPUX'; + } else if (preg_match('/NetBSD/i', $agent)) { + $os = 'NetBSD'; + } else if (preg_match('/BSD/i', $agent)) { + $os = 'BSD'; + } else if (preg_match('/OSF1/i', $agent)) { + $os = 'OSF1'; + } else if (preg_match('/IRIX/i', $agent)) { + $os = 'IRIX'; + } else if (preg_match('/FreeBSD/i', $agent)) { + $os = 'FreeBSD'; + } else if (preg_match('/teleport/i', $agent)) { + $os = 'teleport'; + } else if (preg_match('/flashget/i', $agent)) { + $os = 'flashget'; + } else if (preg_match('/webzip/i', $agent)) { + $os = 'webzip'; + } else if (preg_match('/offline/i', $agent)) { + $os = 'offline'; + } elseif (preg_match('/ucweb|MQQBrowser|J2ME|IUC|3GW100|LG-MMS|i60|Motorola|MAUI|m9|ME860|maui|C8500|gt|k-touch|X8|htc|GT-S5660|UNTRUSTED|SCH|tianyu|lenovo|SAMSUNG/i', $agent)) { + $os = 'mobile'; + } else { + $os = '未知操作系统'; + } + return $os; +} +/** + * 返回按层级加前缀的菜单数组 + * @author rainfer + * @param array|mixed $menu 待处理菜单数组 + * @param string $id_field 主键id字段名 + * @param string $pid_field 父级字段名 + * @param string $lefthtml 前缀 + * @param int $pid 父级id + * @param int $lvl 当前lv + * @param int $leftpin 左侧距离 + * @return array + */ +function menu_left($menu,$id_field='id',$pid_field='pid',$lefthtml = '─' , $pid=0 , $lvl=0, $leftpin=0) +{ + $arr=array(); + foreach ($menu as $v){ + if($v[$pid_field]==$pid){ + $v['lvl']=$lvl + 1; + $v['leftpin']=$leftpin; + $v['lefthtml']='├'.str_repeat($lefthtml,$lvl); + $arr[]=$v; + $arr= array_merge($arr,menu_left($menu,$id_field,$pid_field,$lefthtml,$v[$id_field], $lvl+1 ,$leftpin+20)); + } + } + return $arr; +} +/** + * 返回后台news相关菜单层级text数组 + * @author rainfer + * @return array|mixed + */ +function menu_text($lang='zh-cn') +{ + $menu_text=cache('menu_text'); + if(empty($menu_text)){ + $map=[]; + $map['menu_l']= 'zh-cn'; + $menu_text=Db::name('menu')->where('menu_type <> 4 and menu_type <> 2')->where($map)-> order('menu_l desc,listorder') -> select(); + $menu_text = menu_left($menu_text,'id','parentid'); + cache('menu_text',$menu_text); + } + return $menu_text; +} +/** + * 数据签名 + * @param array $data 被认证的数据 + * @return string 签名 + */ +function data_signature($data = []) +{ + if(!is_array($data)){ + $data = (array)$data; + } + ksort($data); + $code = http_build_query($data); + $sign = sha1($code); + return $sign; +} +/** + * 递归查找多维数组键名,返回键值数组 + * + * @param string + * @param array + * @param array + * @return array + */ +function array_search_key($needle, $haystack,&$nodes_found=[]){ + foreach ($haystack as $key1=>$value1) { + if ($key1=== $needle){ + $nodes_found[] = $value1; + } + if (is_array($value1)){ + array_search_key($needle, $value1,$nodes_found); + } + } + return $nodes_found; +} +/** + * 递归查找多维数组值,返回键名数组 + * + * @param mixed $needle 待找值 + * @param array $haystack 目标数组 + * @param array + * @param int + * @param array + * @return array + */ +function array_search_value($needle, $haystack,&$nodes_found=[], $a=0, $nodes_temp=array()){ + $a++; + foreach ($haystack as $key1=>$value1) { + $nodes_temp[$a] = $key1; + if (is_array($value1)){ + array_search_value($needle, $value1,$nodes_found, $a, $nodes_temp); + } + else if ($value1 === $needle){ + $nodes_found[] = $nodes_temp; + } + } + return $nodes_found; +} +/** + * 返回管理菜单待找url对应键名数组 + * + * @param string + * @return array + */ +function admin_menu_find($url){ + $rst=array_search_value($url,config('menu')); + if(!$rst) return []; + $rst=$rst[0]; + $value_arr=[]; + foreach ($rst as $key=>$value){ + if($key % 2 ==1) $value_arr[]=$value; + } + return $value_arr; +} +//判断远程文件是否存在 +/* + 函数:remote_file_exists + 功能:判断远程文件是否存在 + 参数: $url_file - 远程文件URL + $flag - true为判断远程文件,false为判断非远程文件 + 返回:存在返回true,不存在或者其他原因返回false +*/ +function remote_file_exists($url_file,$flag = false){ + if($flag == true){ //默认是判断远程文件 + //检测输入 + $url_file = trim($url_file); + if (empty($url_file)) { return false; } + $url_arr = parse_url($url_file); + if (!is_array($url_arr) || empty($url_arr)){ return false; } + + //获取请求数据 + $host = $url_arr['host']; + $path = $url_arr['path'] ."?". $url_arr['query']; + $port = isset($url_arr['port']) ? $url_arr['port'] : "80"; + + //连接服务器 + $fp = fsockopen($host, $port, $err_no, $err_str, 30); + if (!$fp){ return false; } + + //构造请求协议 + $request_str = "GET ".$path." HTTP/1.1\r\n"; + $request_str .= "Host: ".$host."\r\n"; + $request_str .= "Connection: Close\r\n\r\n"; + + //发送请求 + fwrite($fp, $request_str); + $first_header = fgets($fp, 1024); + fclose($fp); + + //判断文件是否存在 + if (trim($first_header) == ""){ return false; } + if (!preg_match("/200/", $first_header)){ + return false; + } + return true; + }else if($flag == false){ //非远程文件 + return file_exists($url_file); + } +} +//创建TOKEN +function creatToken() { + $code = chr(mt_rand(0xB0, 0xF7)) . chr(mt_rand(0xA1, 0xFE)) . chr(mt_rand(0xB0, 0xF7)) . chr(mt_rand(0xA1, 0xFE)) . chr(mt_rand(0xB0, 0xF7)) . chr(mt_rand(0xA1, 0xFE)); + session('TOKEN', authcode($code)); +} + +//判断TOKEN +function checkToken($token) { + if ($token == session('TOKEN')) { + session('TOKEN', NULL); + return TRUE; + } else { + return FALSE; + } +} + +/* 加密TOKEN */ +function authcode($str) { + $key = "LEOET"; + $str = substr(md5($str), 8, 10); + return md5($key . $str); +} +/** + * 获取所有父节点id(含自身) + * @param int $id 节点id + * @return array + */ +function get_menu_parents($id =0) +{ + if(!$id) return []; + $lists=Db::name('menu')->order('listorder,id')->column('parentid','id'); + $ids = []; + while (isset($lists[$id]) && $lists[$id] !=0){ + $ids[]=$id; + $id=$lists[$id]; + } + if(isset($lists[$id]) && $lists[$id]==0) $ids[]=$id; + return array_reverse($ids); +} +/** + * 获取创新价数据 + * @return array + */ +function get_cx_data() +{ + $data=Cache::get('curprice_cx'); + if(!$data && config('curprice.cx_url')){ + $data=json_decode(go_curl(config('curprice.cx_url'),'GET'),true); + Cache::set('curprice_cx',$data,config('curprice.expire')); + } + return $data; +} +/** + * 获取动态价数据 + * @return array + */ +function get_dt_data() +{ + $data=Cache::get('curprice_dt'); + if(!$data && config('curprice.dt_url')){ + $data=json_decode(go_curl(config('curprice.dt_url'),'GET'),true); + Cache::set('curprice_dt',$data,config('curprice.expire')); + } + return $data; +} +/** + * 亿美短信接口发送短信 + * @param string + * @param string + * @param string + * @return mixed + */ +function send_sms($phone='',$message='',$customSmsId = "",$extendedCode = "") +{ + $ymsms=new Ymsms(); + $resobj=$ymsms->SendSimpleSMS($phone, $message,'',$customSmsId,$extendedCode); + if($resobj&&isset($resobj->plaintext)){ + try { + $json=json_decode($resobj->plaintext,true); + if($json&&isset($json['smsId'])){ + return ['code'=>1,'msg'=>'发送成功']; + } + } catch (Exception $e) { + } + return ['code'=>0,'msg'=>'发送失败']; + } + $SendMessageApi = "http://219.239.91.114:8080/sdkproxy/sendsms.action";//"http://hprpt2.eucp.b2m.cn:8080/sdkproxy/sendsms.action"; + $param=config('ymsms'); + unset($param['signname']); + if(!$phone) return ['code'=>0,'msg'=>'手机号不能为空']; + if(!$message) return ['code'=>0,'msg'=>'短信内容不能为空']; + $param['phone']=$phone; + $param['message']=$message; + $param['addserial']=$addserial; + if($param['cdkey'] && $param['password']){ + $data=go_curl($SendMessageApi,'GET',$param); + $data=xml2data($data); + if($data['error']==0){ + return ['code'=>1,'msg'=>'发送成功']; + }else{ + return ['code'=>0,'msg'=>$data['message']]; + } + }else{ + return ['code'=>0,'msg'=>'未设置亿美接口参数']; + } +} +function xml2data($xml){ + $xml = simplexml_load_string(trim($xml)); + $data = array(); + foreach ($xml as $key => $value) { + $data[$key] = strval($value); + } + return $data; +} +//获取含自身的auth_rule的id数组 +function get_rule_ids_child($pid) +{ + $arr=Db::name('auth_rule')->select(); + $tree=new \Tree(); + $tree->init($arr,['parentid'=>'pid']); + return $tree->get_childs($arr,$pid,true,true); +} + +//检查未上传文件,返回文件数组 +function get_unuploadfiles($apply_id,$status=-1,$process=-1,$uid=-1,$role_id=-1,$flag=1) +{ + $whereType=array('apply_id'=>$apply_id,'new_flag'=>1); + $baseinfo=Db::name('cult4baseinfo')->field('apply_type,c_type,p_type,k_type')->where($whereType)->find(); + $apply_type=$baseinfo['apply_type']; + $c_type=$baseinfo['c_type']; + $p_type=$baseinfo['p_type']; + $k_type=$baseinfo['k_type']; + if($uid > 0){ + $role_id=Db::name('member_list')->where('member_list_id',$uid)->value('member_list_groupid'); + }else{ + $uid = -1; + } + if($role_id <= 0 and $role_id != -1)$role_id = -1; + + $rst=[]; + + //必须文件 + //取得固定文件 + $apply_uptypelist_check =UptypeModel::getList($apply_type,$c_type,$p_type,$apply_id,1,[0],1,'ftype_id,status,apply_id,isopen',-1,$k_type); + //取得补充文件 + $apply_uptypelist_tempcheck =UptypeModel::getList($apply_type,$c_type,$p_type,$apply_id,2,[0],1,'ftype_id,status,apply_id,isopen',-1,$k_type); + + if(config('cult4files.check')==1){ + if($status==2 or $status>=32 or $process>=1){//补交材料中(初审未通过):32 + //取得固定文件 + $apply_uptypelist_check = array_merge($apply_uptypelist_check, UptypeModel::getList($apply_type,$c_type,$p_type,$apply_id,1,[1,19],1,'ftype_id,status,apply_id,isopen',-1,$k_type)); + //取得补充文件 + $apply_uptypelist_tempcheck = array_merge($apply_uptypelist_tempcheck, UptypeModel::getList($apply_type,$c_type,$p_type,$apply_id,2,[1,19],1,'ftype_id,status,apply_id,isopen',-1,$k_type)); + + } + } + if(config('cult4files.checkdd')==1){ + if($status==2 or $status>=35 or $process>=2){//补交材料中(尽调未通过):35 + //取得固定文件 + $apply_uptypelist_check = array_merge($apply_uptypelist_check, UptypeModel::getList($apply_type,$c_type,$p_type,$apply_id,1,[2,36],1,'ftype_id,status,apply_id,isopen',-1,$k_type)); + //取得补充文件 + $apply_uptypelist_tempcheck = array_merge($apply_uptypelist_tempcheck, UptypeModel::getList($apply_type,$c_type,$p_type,$apply_id,2,[2,36],1,'ftype_id,status,apply_id,isopen',-1,$k_type)); + } + } + if(config('cult4files.checkreview')==1){ + if($status>=37 or $process>=3){//补交材料中(复审未通过):37 + //取得固定文件 + $apply_uptypelist_check = array_merge($apply_uptypelist_check, UptypeModel::getList($apply_type,$c_type,$p_type,$apply_id,1,[5,20],1,'ftype_id,status,apply_id,isopen',-1,$k_type)); + //取得补充文件 + $apply_uptypelist_tempcheck = array_merge($apply_uptypelist_tempcheck, UptypeModel::getList($apply_type,$c_type,$p_type,$apply_id,2,[5,20],1,'ftype_id,status,apply_id,isopen',-1,$k_type)); + } + } + if(config('cult4files.checkrisk')==1){ + if($status>=38 or $process>=4){//补交材料中(风控审核未通过):38 + //取得固定文件 + $apply_uptypelist_check = array_merge($apply_uptypelist_check, UptypeModel::getList($apply_type,$c_type,$p_type,$apply_id,1,[6,21],1,'ftype_id,status,apply_id,isopen',-1,$k_type)); + //取得补充文件 + $apply_uptypelist_tempcheck = array_merge($apply_uptypelist_tempcheck, UptypeModel::getList($apply_type,$c_type,$p_type,$apply_id,2,[6,21],1,'ftype_id,status,apply_id,isopen',-1,$k_type)); + } + } + if(config('cult4files.checkfee')==1){ + if($status>=41 or $process>=6){//补交材料中(缴费确认未通过):41 + //取得固定文件 + $apply_uptypelist_check = array_merge($apply_uptypelist_check, UptypeModel::getList($apply_type,$c_type,$p_type,$apply_id,1,[9,12,22,39],1,'ftype_id,status,apply_id,isopen',-1,$k_type)); + //取得补充文件 + $apply_uptypelist_tempcheck = array_merge($apply_uptypelist_tempcheck, UptypeModel::getList($apply_type,$c_type,$p_type,$apply_id,2,[9,12,22,39],1,'ftype_id,status,apply_id,isopen',-1,$k_type)); + } + } + if(config('cult4files.checkpro')==1){ + if($status>=42 or $process>=8){//补交材料中(确认专家审核未通过):42 + //取得固定文件 + $apply_uptypelist_check = array_merge($apply_uptypelist_check, UptypeModel::getList($apply_type,$c_type,$p_type,$apply_id,1,[14,15,23],1,'ftype_id,status,apply_id,isopen',-1,$k_type)); + //取得补充文件 + $apply_uptypelist_tempcheck = array_merge($apply_uptypelist_tempcheck, UptypeModel::getList($apply_type,$c_type,$p_type,$apply_id,2,[14,15,23],1,'ftype_id,status,apply_id,isopen',-1,$k_type)); + } + } + if(config('cult4files.checkjc')==1){ + if($status>=43 or $process>=9){//补交材料中(联席会审核未通过):43 + //取得固定文件 + $apply_uptypelist_check = array_merge($apply_uptypelist_check, UptypeModel::getList($apply_type,$c_type,$p_type,$apply_id,1,[4,34,8,11,13,17,16,28],1,'ftype_id,status,apply_id,isopen',-1,$k_type)); + //取得补充文件 + $apply_uptypelist_tempcheck = array_merge($apply_uptypelist_tempcheck, UptypeModel::getList($apply_type,$c_type,$p_type,$apply_id,2,[4,34,8,11,13,17,16,28],1,'ftype_id,status,apply_id,isopen',-1,$k_type)); + } + } + if(config('cult4files.checkmc')==1){ + if($status>=45 or $process>=10){//补交材料中(材料核实未通过):45 + //取得固定文件 + $apply_uptypelist_check = array_merge($apply_uptypelist_check, UptypeModel::getList($apply_type,$c_type,$p_type,$apply_id,1,[25,46,47],1,'ftype_id,status,apply_id,isopen',-1,$k_type)); + //取得补充文件 + $apply_uptypelist_tempcheck = array_merge($apply_uptypelist_tempcheck, UptypeModel::getList($apply_type,$c_type,$p_type,$apply_id,2,[25,46,47],1,'ftype_id,status,apply_id,isopen',-1,$k_type)); + } + } + if(config('cult4files.checknm')==1){ + if($status>=50 or $process>=11){//补交材料中(公告资料审核未通过):50 + //取得固定文件 + $apply_uptypelist_check = array_merge($apply_uptypelist_check, UptypeModel::getList($apply_type,$c_type,$p_type,$apply_id,1,[48,29],1,'ftype_id,status,apply_id,isopen',-1,$k_type)); + //取得补充文件 + $apply_uptypelist_tempcheck = array_merge($apply_uptypelist_tempcheck, UptypeModel::getList($apply_type,$c_type,$p_type,$apply_id,2,[48,29],1,'ftype_id,status,apply_id,isopen',-1,$k_type)); + } + } + if(config('cult4files.checkboard')==1){ + if($status>=53 or $process>=12){//补交材料中(挂牌上市审核未通过):53 + //取得固定文件 + $apply_uptypelist_check = array_merge($apply_uptypelist_check, UptypeModel::getList($apply_type,$c_type,$p_type,$apply_id,1,[51,30],1,'ftype_id,status,apply_id,isopen',-1,$k_type)); + //取得补充文件 + $apply_uptypelist_tempcheck = array_merge($apply_uptypelist_tempcheck, UptypeModel::getList($apply_type,$c_type,$p_type,$apply_id,2,[51,30],1,'ftype_id,status,apply_id,isopen',-1,$k_type)); + } + } + + //固定文件,将数组键名改为$v['ftype_id'] + foreach($apply_uptypelist_check as $k=>$v){ + $where['ftype_id']=array('eq', $v['ftype_id']); + $where['new_flag']=array('eq', 1); + $where['apply_id']=array('eq', $apply_id); + if($flag==1)$where['flag']=array('eq', 1);//已审核的 + $fileInfo = Db::name('cult4upfiles')->where($where)->order('addorder desc')->find(); + + //如果没找到,根据条件添加到列表 + if(!$fileInfo && $v['mustupload']==1){ + if($uid==-1 and $role_id==-1){ + $rst[$v['ftype_id']]=$v; + }else{ + if(($v['upload_role_type']==1 && $v['upload_role_id']==$role_id) || ($v['upload_role_type2']==1 && $v['upload_role_id2']==$role_id)||($role_id==5)) + { + $rst[$v['ftype_id']]=$v; + } + } + } + } + //补充文件,将数组键名改为$v['ftype_id'] + foreach($apply_uptypelist_tempcheck as $k=>$v){ + $where['ftype_id']=array('eq', $v['ftype_id']); + $where['new_flag']=array('eq', 1); + $where['apply_id']=array('eq', $apply_id); + if($flag==1)$where['flag']=array('eq', 1);//已审核的 + $fileInfo = Db::name('cult4upfiles')->where($where)->order('addorder desc')->find(); + //如果没找到,根据条件添加到列表 + if(!$fileInfo){ + if($uid==-1 and $role_id==-1){ + $rst[$v['ftype_id']]=$v; + }else{ + if(($v['upload_role_type']==1 && $v['upload_role_id']==$role_id) || ($v['upload_role_type2']==1 && $v['upload_role_id2']==$role_id)||($role_id==5)) + { + $rst[$v['ftype_id']]=$v; + } + } + } + } + + //非必须文件 + //取得固定文件 + $apply_uptypelist_check2 =UptypeModel::getList($apply_type,$c_type,$p_type,$apply_id,1,[0],1,'ftype_id,status,apply_id,isopen',0,$k_type); + //取得补充文件 + $apply_uptypelist_tempcheck2 =UptypeModel::getList($apply_type,$c_type,$p_type,$apply_id,2,[0],1,'ftype_id,status,apply_id,isopen',0,$k_type); + + if(config('cult4files.check')==1){ + if($status>=32 or $process>=1){//补交材料中(初审未通过):32 + //取得固定文件 + $apply_uptypelist_check2 = array_merge($apply_uptypelist_check2, UptypeModel::getList($apply_type,$c_type,$p_type,$apply_id,1,[1,19],1,'ftype_id,status,apply_id,isopen',0,$k_type)); + //取得补充文件 + $apply_uptypelist_tempcheck2 = array_merge($apply_uptypelist_tempcheck2, UptypeModel::getList($apply_type,$c_type,$p_type,$apply_id,2,[1,19],1,'ftype_id,status,apply_id,isopen',0,$k_type)); + } + } + if(config('cult4files.checkdd')==1){ + if($status>=35 or $process>=2){//补交材料中(尽调未通过):35 + //取得固定文件 + $apply_uptypelist_check2 = array_merge($apply_uptypelist_check2, UptypeModel::getList($apply_type,$c_type,$p_type,$apply_id,1,[2,36],1,'ftype_id,status,apply_id,isopen',0,$k_type)); + //取得补充文件 + $apply_uptypelist_tempcheck2 = array_merge($apply_uptypelist_tempcheck2, UptypeModel::getList($apply_type,$c_type,$p_type,$apply_id,2,[2,36],1,'ftype_id,status,apply_id,isopen',0,$k_type)); + } + } + if(config('cult4files.checkreview')==1){ + if($status>=37 or $process>=3){//补交材料中(复审未通过):37 + //取得固定文件 + $apply_uptypelist_check2 = array_merge($apply_uptypelist_check2, UptypeModel::getList($apply_type,$c_type,$p_type,$apply_id,1,[5,20],1,'ftype_id,status,apply_id,isopen',0,$k_type)); + //取得补充文件 + $apply_uptypelist_tempcheck2 = array_merge($apply_uptypelist_tempcheck2, UptypeModel::getList($apply_type,$c_type,$p_type,$apply_id,2,[5,20],1,'ftype_id,status,apply_id,isopen',0,$k_type)); + } + } + if(config('cult4files.checkrisk')==1){ + if($status>=38 or $process>=4){//补交材料中(风控审核未通过):38 + //取得固定文件 + $apply_uptypelist_check2 = array_merge($apply_uptypelist_check2, UptypeModel::getList($apply_type,$c_type,$p_type,$apply_id,1,[6,21],1,'ftype_id,status,apply_id,isopen',0,$k_type)); + //取得补充文件 + $apply_uptypelist_tempcheck2 = array_merge($apply_uptypelist_tempcheck2, UptypeModel::getList($apply_type,$c_type,$p_type,$apply_id,2,[6,21],1,'ftype_id,status,apply_id,isopen',0,$k_type)); + } + } + if(config('cult4files.checkfee')==1){ + if($status>=41 or $process>=6){//补交材料中(缴费确认未通过):41 + //取得固定文件 + $apply_uptypelist_check2 = array_merge($apply_uptypelist_check2, UptypeModel::getList($apply_type,$c_type,$p_type,$apply_id,1,[9,12,22,39],1,'ftype_id,status,apply_id,isopen',0,$k_type)); + //取得补充文件 + $apply_uptypelist_tempcheck2 = array_merge($apply_uptypelist_tempcheck2, UptypeModel::getList($apply_type,$c_type,$p_type,$apply_id,2,[9,12,22,39],1,'ftype_id,status,apply_id,isopen',0,$k_type)); + } + } + if(config('cult4files.checkpro')==1){ + if($status>=42 or $process>=8){//补交材料中(确认专家审核未通过):42 + //取得固定文件 + $apply_uptypelist_check2 = array_merge($apply_uptypelist_check2, UptypeModel::getList($apply_type,$c_type,$p_type,$apply_id,1,[14,15,23],1,'ftype_id,status,apply_id,isopen',0,$k_type)); + //取得补充文件 + $apply_uptypelist_tempcheck2 = array_merge($apply_uptypelist_tempcheck2, UptypeModel::getList($apply_type,$c_type,$p_type,$apply_id,2,[14,15,23],1,'ftype_id,status,apply_id,isopen',0,$k_type)); + } + } + if(config('cult4files.checkjc')==1){ + if($status>=43 or $process>=9){//补交材料中(联席会审核未通过):43 + //取得固定文件 + $apply_uptypelist_check2 = array_merge($apply_uptypelist_check2, UptypeModel::getList($apply_type,$c_type,$p_type,$apply_id,1,[4,34,8,11,13,17,16,28],1,'ftype_id,status,apply_id,isopen',0,$k_type)); + //取得补充文件 + $apply_uptypelist_tempcheck2 = array_merge($apply_uptypelist_tempcheck2, UptypeModel::getList($apply_type,$c_type,$p_type,$apply_id,2,[4,34,8,11,13,17,16,28],1,'ftype_id,status,apply_id,isopen',0,$k_type)); + } + } + if(config('cult4files.checkmc')==1){ + if($status>=45 or $process>=10){//补交材料中(材料核实未通过):45 + //取得固定文件 + $apply_uptypelist_check2 = array_merge($apply_uptypelist_check2, UptypeModel::getList($apply_type,$c_type,$p_type,$apply_id,1,[25,46,47],1,'ftype_id,status,apply_id,isopen',0,$k_type)); + //取得补充文件 + $apply_uptypelist_tempcheck2 = array_merge($apply_uptypelist_tempcheck2, UptypeModel::getList($apply_type,$c_type,$p_type,$apply_id,2,[25,46,47],1,'ftype_id,status,apply_id,isopen',0,$k_type)); + } + } + if(config('cult4files.checknm')==1){ + if($status>=50 or $process>=11){//补交材料中(公告资料审核未通过):50 + //取得固定文件 + $apply_uptypelist_check2 = array_merge($apply_uptypelist_check2, UptypeModel::getList($apply_type,$c_type,$p_type,$apply_id,1,[48,29],1,'ftype_id,status,apply_id,isopen',0,$k_type)); + //取得补充文件 + $apply_uptypelist_tempcheck2 = array_merge($apply_uptypelist_tempcheck2, UptypeModel::getList($apply_type,$c_type,$p_type,$apply_id,2,[48,29],1,'ftype_id,status,apply_id,isopen',0,$k_type)); + } + } + if(config('cult4files.checkboard')==1){ + if($status>=53 or $process>=12){//补交材料中(挂牌上市审核未通过):53 + //取得固定文件 + $apply_uptypelist_check2 = array_merge($apply_uptypelist_check2, UptypeModel::getList($apply_type,$c_type,$p_type,$apply_id,1,[51,30],1,'ftype_id,status,apply_id,isopen',0,$k_type)); + //取得补充文件 + $apply_uptypelist_tempcheck2 = array_merge($apply_uptypelist_tempcheck2, UptypeModel::getList($apply_type,$c_type,$p_type,$apply_id,2,[51,30],1,'ftype_id,status,apply_id,isopen',0,$k_type)); + } + } + //固定文件 + foreach($apply_uptypelist_check2 as $k=>$v){ + $where2['ftype_id']=array('eq', $v['ftype_id']); + $where2['new_flag']=array('eq', 0); + $where2['apply_id']=array('eq', $apply_id); + $where2['flag']=array('eq', 0);//未审核(未通过) + $fileInfo2 = Db::name('cult4upfiles')->where($where2)->order('addorder desc')->find(); + + //有历史数据 + if($fileInfo2){ + $where3['ftype_id']=array('eq', $v['ftype_id']); + $where3['new_flag']=array('eq', 1); + $where3['apply_id']=array('eq', $apply_id); + if($flag==1)$where3['flag']=array('eq', 1);//已审核的 + $fileInfo3 = Db::name('cult4upfiles')->where($where3)->order('addorder desc')->find(); + + //没有最新数据 + if(!$fileInfo3) { + if($uid==-1 and $role_id==-1){ + $rst[$v['ftype_id']] = $v; + } else { + if (($v['upload_role_type'] == 1 && $v['upload_role_id'] == $role_id) || ($v['upload_role_type2'] == 1 && $v['upload_role_id2'] == $role_id)||($role_id==5)) { + $rst[$v['ftype_id']] = $v; + } + } + } + } + } + + //补充文件 + foreach($apply_uptypelist_tempcheck2 as $k=>$v){ + $where2['ftype_id']=array('eq', $v['ftype_id']); + $where2['new_flag']=array('eq', 0); + $where2['apply_id']=array('eq', $apply_id); + $where['flag']=array('eq', 0);//未审核(未通过) + $fileInfo2 = Db::name('cult4upfiles')->where($where2)->order('addorder desc')->find(); + //有历史数据 + if($fileInfo2){ + $where3['ftype_id']=array('eq', $v['ftype_id']); + $where3['new_flag']=array('eq', 1); + $where3['apply_id']=array('eq', $apply_id); + if($flag==1)$where['flag']=array('eq', 1);//已审核的 + $fileInfo3 = Db::name('cult4upfiles')->where($where3)->order('addorder desc')->find(); + //没有最新数据 + if(!$fileInfo3) { + if($uid==-1 and $role_id==-1){ + $rst[$v['ftype_id']] = $v; + } else { + if (($v['upload_role_type'] == 1 && $v['upload_role_id'] == $role_id) || ($v['upload_role_type2'] == 1 && $v['upload_role_id2'] == $role_id)||($role_id==5)) { + $rst[$v['ftype_id']] = $v; + } + } + } + } + } + return $rst; +} +/** + * 根据模板文件id获取文件路径,返回值为字符串 + * @param int $ftempid 文件id + * @return string + */ +function get_capitaltempfile($ftempid) +{ + $path=Db::name('capital_upfiles')->where(['file_id'=>$ftempid])->value('path'); + return get_imgurl($path); +} +/** + * 根据模板文件id获取文件路径,返回值为字符串 + * @param int $ftempid 文件id + * @return string + */ +function get_tempfile($ftempid) +{ + $path=Db::name('cult4upfiles')->where(['file_id'=>$ftempid])->value('path'); + return get_imgurl($path); +} +/** + * 根据用户id获取前后台用户名,返回值为字符串 + * @param int $uid 用户id + * @param int $utype 用户类型1 前台 2后台 + * @return int + */ +function get_capitalUserName($uid,$utype,$linkStyle='|',$errUserMsg='用户不存在') +{ + $apply = new Capitalapply(); + $userinfo = $apply->getUserInfos($uid,$utype); + if(!empty($userinfo)) + { + if($utype==1)//前台用户 + { + return $userinfo[0]['member_list_username'].' '.$linkStyle.' '.$userinfo[0]['member_list_nickname']; + } + elseif($utype==2)//后台用户 + { + return $userinfo[0]['admin_username'].' '.$linkStyle.' '.$userinfo[0]['admin_realname']; + } + else{ + return "未知状态,请联系管理员"; + } + }else { + return $errUserMsg; + } +} +/** + * 根据用户id获取前后台用户名,返回值为字符串 + * @param int $uid 用户id + * @param int $utype 用户类型1 前台 2后台 + * @return int + */ +function get_cult4UserName($uid,$utype,$linkStyle='|',$errUserMsg='用户不存在') +{ + $apply = new Cult4apply(); + $userinfo = $apply->getUserInfos($uid,$utype); + if(!empty($userinfo)) + { + if($utype==1)//前台用户 + { + return $userinfo[0]['member_list_username'].' '.$linkStyle.' '.$userinfo[0]['member_list_nickname']; + } + elseif($utype==2)//后台用户 + { + return $userinfo[0]['admin_username'].' '.$linkStyle.' '.$userinfo[0]['admin_realname']; + } + else{ + return "未知状态,请联系管理员"; + } + }else { + return $errUserMsg; + } +} + +/** + * 获取多用户名称 + * @param unknown $uids + * @param unknown $utype + * @param string $linkStyle + * @param string $errUserMsg + * @return string[]|string + */ +function get_cult4UserNames($uids,$utype,$linkStyle='|',$errUserMsg='用户不存在'){ + $apply = new Cult4apply(); + $userinfo = $apply->getUserInfos($uids,$utype); + + $uids=explode(',', $uids); + + if(count($uids)){ + $data=[]; + foreach ($userinfo as $row){ + $username=''; + if($row){ + $uid=intval($row['member_list_id']); + if($utype==1){//前台用户 + $username=$row['member_list_username'].' '.$linkStyle.' '.$row['member_list_nickname']; + }elseif($utype==2){//后台用户 + $username=$row['admin_username'].' '.$linkStyle.' '.$row['admin_realname']; + } + $data[$uid]=$username; + } + } + foreach ($uids as $uid){ + if(!isset($data[$uid]))$data[$uid]='未知'; + } + return $data; + } + return $errUserMsg; +} +/** + * 根据角色id获取前后台角色名,返回值为字符串 + * @param int $rid 角色id + * @param int $utype 角色类型1 前台 2后台 + * @return int + */ +function get_cult4RoleName($rid,$utype) +{ + $apply = new Cult4apply(); + $roleinfo = $apply->getRoleInfos($rid,$utype); + if(!empty($roleinfo)) + { + if($utype==1)//前台用户 + { + return '前台 | '.$roleinfo[0]['member_group_name']; + } + elseif($utype==2)//后台用户 + { + return '后台 | '.$roleinfo[0]['title']; + } + else{ + return "未知状态,请联系管理员"; + } + }else { + return "无"; + } +} +/** + * 根据用户id获取前后台用户名/用户昵称,返回值为数组 + * @param int $uid 用户id + * @return string + */ +function get_cult4UserStatus($uid,$utype) +{ + $apply = new Cult4apply(); + $userinfo = $apply->getUserInfos($uid,$utype); + if(!empty($userinfo)) { + if ($utype == 1){//前台用户 + return $userinfo[0]['member_list_open']; + } elseif ($utype == 2){//后台用户 + return $userinfo[0]['admin_open']; + } else { + return "未知用户,请联系管理员"; + } + } +} +/** + * 根据用户id获取前后台用户名/用户昵称,返回值为数组 + * @param int $uid 用户id + * @return string + */ +function get_cult4UserStatuses($uids,$utype){ + $apply = new Cult4apply(); + $userinfo = $apply->getUserInfos($uids,$utype); + + $uids=explode(',', $uids); + if(count($uids)){ + $data=[]; + foreach ($userinfo as $row){ + $status=''; + if($row){ + $uid=intval($row['member_list_id']); + if($utype==1){//前台用户 + $status=$row['member_list_open']; + }elseif($utype==2){//后台用户 + $status=$row['admin_open']; + } + $data[$uid]=$status; + } + } + foreach ($uids as $uid){ + if(!isset($data[$uid]))$data[$uid]=[]; + } + return $data; + } +} +/** + * 根据流程status获取对应的状态描述,返回值为字符串 + * @param int $status_id 流程状态id + * @return string + */ +function get_cult4Status($status_id){ + $status = new Cult4status(); + $curStatus = $status->getStatus($status_id); + return $curStatus[0]['descr']; +} +/** + * 根据流程status获取对应的状态描述,返回值为字符串 + * @param int $status_id 流程状态id + * @return string + */ +function get_cult4Statuses($status_ids){ + $data=[]; + $status = new Cult4status(); + foreach ($status_ids as $status_id){ + $curStatus = $status->getStatus($status_id); + $data[$status_id]=$curStatus[0]['descr']; + } + return $data; +} +/** + * 根据apply_id获取对应的缴费结果,返回值为int + * @param int $apply_id 申请id + * @return int + */ +function get_cult4feeflag($apply_id){ + $where=array( + 'apply_id'=>$apply_id, + 'new_flag'=>1, + ); + $check=Db::name('cult4fee')->where($where)->order('addorder desc,fee_id desc')->find (); + if(!empty($check)){ + return $check['fee_flag']; + } + + return 0; +} +/** + * 根据apply_id获取对应的缴费结果,返回值为int + * @param int $apply_id 申请id + * @return int + */ +function get_cult4feeflags($apply_ids=''){ + $where=array('new_flag'=>1); + $check=Db::name('cult4fee')->where($where)->where('apply_id','in',$apply_ids)->order('addorder desc,fee_id desc')->select(); + + $data=[]; + if(count($check)){ + foreach ($check as $row){ + $aid=$row['apply_id']; + $data[$aid]=$row['fee_flag']; + } + } + foreach ($apply_ids as $aid){ + if(!isset($data[$aid]))$data[$aid]=0; + } + return $data; +} +/** + * 根据apply_id和userid获取对应的核实结果,返回值为int + * @param int $apply_id 申请id + * @param int $uid 用户id + * @return int + */ +function get_cult4IsUserAdvicedMC($apply_id,$uid) +{ + $where=array( + 'apply_id'=>$apply_id, + 'create_id'=>$uid, + 'btnid'=>4, + ); + $Cnt=Db::name('cult4checkmc')->where($where)->count(); + return $Cnt; +} +/** + * 根据文件类型id获取文件描述信息,返回值为字符串 + * @param int $ftypeid 文件类型id + * @return string + */ +function get_cult4FileTypeDescr($ftypeid) +{ + $filetypeinfo = new Cult4uptype(); + $typeinfo = $filetypeinfo->getFileTypeInfo($ftypeid); + return $typeinfo[0]['ftypedescr']; +} +/** + * 根据文件id获取文件路径,返回值为字符串 + * @param int $fid 文件id + * @return string + */ +function get_cult4FilePath($fid) +{ + $fileinfo = new Cult4upfiles(); + $file = $fileinfo->getFileInfo($fid); + return $file[0]['path']; +} +/** + * 根据模板文件id获取文件路径,返回值为字符串 + * @param int $ftempid 文件id + * @return string + */ +function get_cult4TempFilePath($ftempid) +{ + $tempfileinfo = new Cult4upfiles(); + $tempfile = $tempfileinfo->getFileInfo($ftempid); + return $tempfile[0]['path']; +} +/** + * 根据模板文件id获取对应实体文件fileid,返回值为int + * @param int $ftempid 模板文件id + * @param int $applyid 申请id + * @return int 实际文件id + */ +function get_cult4FileIDFromTempID($ftempid,$applyid) +{ + $fileinfo = new Cult4upfiles(); + $tempfile = $fileinfo->getFileInfoFromTempFile($ftempid,$applyid); + if(!empty($tempfile)) { + return $tempfile['file_id']; + }else{ + return 0; + } +} +/** + * 根据模板文件id获取对应实体文件fileid,返回值为int + * @param int $ftempid 模板文件id + * @param int $applyid 申请id + * @return int 实际文件id + */ +function get_capitalFileIDFromTempID($ftempid,$applyid) +{ + $fileinfo = new CapitalUpfiles(); + $tempfile = $fileinfo->getFileInfoFromTempFile($ftempid,$applyid); + if(!empty($tempfile)) { + return $tempfile['file_id']; + }else{ + return 0; + } +} +/** + * 根据模板文件id获取对应实体文件user_id,返回值为int + * @param int $ftempid 模板文件id + * @param int $applyid 申请id + * @return int 实际文件user_id + */ +function get_cult4UserIDFromTempID($ftempid,$applyid) +{ + $tempfileinfo = new Cult4upfiles(); + $tempfile = $tempfileinfo->getFileInfoFromTempFile($ftempid,$applyid); + if(!empty($tempfile)) { + return $tempfile['user_id']; + }else{ + return 0; + } +} + +/** + * 根据模板文件id获取对应实体文件user_type,返回值为int + * @param int $ftempid 模板文件id + * @param int $applyid 申请id + * @return int 实际文件user_type + */ +function get_cult4UserTypeFromTempID($ftempid,$applyid) +{ + $tempfileinfo = new Cult4upfiles(); + $tempfile = $tempfileinfo->getFileInfoFromTempFile($ftempid,$applyid); + if(!empty($tempfile)) { + return $tempfile['user_type']; + }else{ + return 0; + } +} +/** + * 根据模板文件id获取对应实体文件filesize,返回值为int + * @param int $ftempid 模板文件id + * @param int $applyid 申请id + * @return int 实际文件filesize + */ +function get_cult4FileSizeFromTempID($ftempid,$applyid) +{ + $tempfileinfo = new Cult4upfiles(); + $tempfile = $tempfileinfo->getFileInfoFromTempFile($ftempid,$applyid); + if(!empty($tempfile)) { + return $tempfile['filesize']; + }else{ + return 0; + } +} +/** + * 根据模板文件id获取对应实体文件filesize,返回值为int + * @param int $ftempid 模板文件id + * @param int $applyid 申请id + * @return int 实际文件filesize + */ +function get_capitalFileSizeFromTempID($ftempid,$applyid) +{ + $tempfileinfo = new CapitalUpfiles(); + $tempfile = $tempfileinfo->getFileInfoFromTempFile($ftempid,$applyid); + if(!empty($tempfile)) { + return $tempfile['filesize']; + }else{ + return 0; + } +} +/** + * 根据模板文件id获取对应实体文件upload_time,返回值为int + * @param int $ftempid 模板文件id + * @param int $applyid 申请id + * @return int 实际文件upload_time + */ +function get_cult4UploadTimeFromTempID($ftempid,$applyid) +{ + $tempfileinfo = new Cult4upfiles(); + $tempfile = $tempfileinfo->getFileInfoFromTempFile($ftempid,$applyid); + if(!empty($tempfile)) { + return $tempfile['upload_time']; + }else{ + return 0; + } +} +/** + * 根据模板文件id获取对应实体文件upload_time,返回值为int + * @param int $ftempid 模板文件id + * @param int $applyid 申请id + * @return int 实际文件upload_time + */ +function get_capitalUploadTimeFromTempID($ftempid,$applyid) +{ + $tempfileinfo = new CapitalUpfiles(); + $tempfile = $tempfileinfo->getFileInfoFromTempFile($ftempid,$applyid); + if(!empty($tempfile)) { + return $tempfile['upload_time']; + }else{ + return 0; + } +} +/** + * 根据模板文件id获取对应实体文件path,返回值为int + * @param int $ftempid 模板文件id + * @param int $applyid 申请id + * @return string 实际文件path + */ +function get_cult4PathFromTempID($ftempid,$applyid) +{ + $tempfileinfo = new Cult4upfiles(); + $tempfile = $tempfileinfo->getFileInfoFromTempFile($ftempid,$applyid); + if(!empty($tempfile)) { + return $tempfile['path']; + }else{ + return '未上传'; + } +} +/** + * 根据模板文件id获取对应实体文件apply_id,返回值为int + * @param int $fid 模板文件id + * @return int 申请id + */ +function get_cult4ApplyIDFromTempID($fid) +{ + $tempfileinfo = new Cult4uptype(); + $tempfile = $tempfileinfo->getFileTypeInfo($fid); + if(!empty($tempfile)) { + return $tempfile[0]['apply_id']; + }else{ + return -1; + } +} +/** + * 根据模板文件id获取对应实体文件apply_id,返回值为int + * @param int $fid 模板文件id + * @return int 申请id + */ +function get_capitalApplyIDFromTempID($fid) +{ + + $tempfileinfo = new Capitaluptype(); + $tempfile = $tempfileinfo->getFileTypeInfo($fid); + if(!empty($tempfile)) { + return $tempfile[0]['apply_id']; + }else{ + return -1; + } +} +/** + * 根据文件id获取对应实体文件path,返回值为int + * @param int $fid 文件id + * @return string 实际文件path + */ +function get_capitalPathFromFileID($fid) +{ + $fileinfo = new CapitalUpfiles(); + $file = $fileinfo->getFileInfoFromFileId($fid); + if(!empty($file)) { + return $file['path']; + }else{ + return '未上传'; + } +} +/** + * 根据文件id获取对应实体文件path,返回值为int + * @param int $fid 文件id + * @return string 实际文件path + */ +function get_cult4PathFromFileID($fid) +{ + $fileinfo = new Cult4upfiles(); + $file = $fileinfo->getFileInfoFromFileId($fid); + if(!empty($file)) { + return $file['path']; + }else{ + return '未上传'; + } +} +/** + * 根据文件id获取对应实体文件flag,返回值为int + * @param int $fid 文件id + * @return int 实际文件flag + */ +function get_cult4FlagFromFileID($fid) +{ + $fileinfo = new Cult4upfiles(); + $file = $fileinfo->getFileInfoFromFileId($fid); + if(!empty($file)) { + return $file['flag']; + }else{ + return -1; + } +} +/** + * 根据文件id获取对应实体文件flag,返回值为int + * @param int $fid 文件id + * @return int 实际文件flag + */ +function get_capitalFlagFromFileID($fid) +{ + $fileinfo = new CapitalUpfiles(); + $file = $fileinfo->getFileInfoFromFileId($fid); + if(!empty($file)) { + return $file['flag']; + }else{ + return -1; + } +} +/** + * 根据文件id获取对应实体文件apply_id,返回值为int + * @param int $fid 文件id + * @return int 申请id + */ +function get_cult4ApplyIDFromFileID($fid) +{ + $fileinfo = new Cult4upfiles(); + $file = $fileinfo->getFileInfoFromFileId($fid); + if(!empty($file)) { + return $file['apply_id']; + }else{ + return -1; + } +} +/** + * 根据apply_id和用户id获取用户的检查状态 + * @param int $apply_id 操作的申请 + * @param int $admin_id 操作的用户 + * @return int 返回结果 + */ +function check_cult4UserRight($apply_id,$admin_id,$status) +{ + $where=array( + 'apply_id'=>$apply_id, + 'status'=>$status, + ); + //'apply_admin_id'=>$admin_id, + $apply=Db::name('cult4apply')->where($where)->find (); + if(empty($apply)){ + return 0; + } + + return 1; +} +/** + * 根据apply_id和用户id获取用户的检查状态 + * @param int $apply_id 操作的申请 + * @param int $admin_id 操作的用户 + * @return int 返回结果 + */ +function check_capitalUserRight($apply_id,$admin_id,$status) +{ + $where=array( + 'apply_id'=>$apply_id, + 'status'=>$status, + ); + $apply=Db::name('capitalapply')->where($where)->find(); + if(empty($apply)){ + return 0; + } + + return 1; +} +/** + * 根据apply_id获取对应实体的企业名称或者项目名称或者申请人名称,返回值为string + * @param int $apply_id 申请id + * @return string 实际文件path + */ +function get_cult4ApplyName($apply_id) +{ + $data=array(); + $data=Db::name('cult4apply')->alias("a")->join(config('database.prefix').'cult4baseinfo b','a.apply_id =b.apply_id') + ->where(['b.new_flag'=>1,'a.apply_id'=>$apply_id])->find(); + + if(!empty($data)) { + if($data['apply_type']==1||$data['apply_type']==4) + return $data['c_name']; + elseif ($data['apply_type']==2||$data['apply_type']==5) + return $data['p_name']; + elseif ($data['apply_type']==3) + return $data['t_apply_username']; + }else{ + return '
未知
'; + } +} +/** + * 根据apply_id获取对应实体的企业名称或者项目名称或者申请人名称,返回值为string + * @param int $apply_id 申请id + * @return string 实际文件path + */ +function get_cult4ApplyNames($apply_ids=[]){ + $db=Db::name('cult4apply')->alias("a")->join(config('database.prefix').'cult4baseinfo b','a.apply_id =b.apply_id'); + $db->where(['b.new_flag'=>1]); + $db->where('a.apply_id','in',$apply_ids); + $data=$db->select(); + + $list=[]; + if(count($data)){ + + foreach ($data as $row){ + $aid=$row['apply_id']; + $name=''; + if($row['apply_type']==1||$row['apply_type']==4||$row['apply_type']==6){ + $name=$row['c_name']; + $pname=$row['p_name']; + if($pname)$name=$pname; + }elseif ($row['apply_type']==2){ + $name=$row['p_name']; + }elseif ($row['apply_type']==5){ + $name=($row['p_type']==1)?$row['p_com_name']:$row['p_natural_name']; + if(empty($name)){ + $name=$row['c_name']; + } + }elseif ($row['apply_type']==3) + $name=$row['t_apply_username']; + else + $name='
未知
'; + + $list[$aid]=$name; + } + foreach ($apply_ids as $aid){ + if (!isset($list[$aid]))$list[$aid]='
未知
'; + } + } + return $list; +} +/** + * 根据apply_id获取对应实体的申请类型,返回值为int + * @param int $apply_id 申请id + * @return int 实际申请者类型 + */ +function get_cult4ApplyType($apply_id) +{ + $data=array(); + $data=Db::name('cult4apply')->alias("a")->join(config('database.prefix').'cult4baseinfo b','a.apply_id =b.apply_id') + ->where(['b.new_flag'=>1,'a.apply_id'=>$apply_id])->find(); + + if(!empty($data)) { + if($data['apply_type']==1) + return '企业'; + elseif ($data['apply_type']==2) + return '项目'; + elseif ($data['apply_type']==3) + return '人才'; + }else{ + return '
未知
'; + } +} + +/** + * 根据模板文件id获取对应实体的总的上传历史文件数量,返回值为int + * @param int $apply_id 申请文件id + * @param int $ftype_id 模板文件id + * @return int 历史文件数量 + */ +function get_cult4CntHistory($apply_id,$ftype_id) +{ + $count=0; + $count=Db::name('cult4upfiles')->where(['apply_id'=>$apply_id,'ftype_id'=>$ftype_id,'new_flag'=>0])->count(); + return $count; +} + +/** + * 是否可以上传当前文件,返回值为int + * @param int $upload_role_type 上传角色类型 + * @param int $upload_role_id 角色id + * @param int $upload_role_type2 上传角色类型2 + * @param int $upload_role_id2 角色id2 + * @param int $type 2=后台 1=前台 + * @return int 0:不能上传 1:能上传 + */ +function chk_cult4CanUpload($upload_role_type,$upload_role_id,$upload_role_type2,$upload_role_id2,$type=2) +{ + $type=isset($type)?$type:2; + if($type==1){ + $user_id=session('hid'); + $groupid=Db::name('member_list')->where('member_list_id',$user_id)->value('member_list_groupid'); + if( (($upload_role_type==1) and ($upload_role_id==$groupid) ) or (($upload_role_type2==1) and ($upload_role_id2==$groupid)) ){ + return 1; + } + return 0; + }else{ + $user_id=session('admin_auth.aid'); + //当前后台用户对应的组 + $group=Db::name('auth_group_access')->where('uid',$user_id)->find(); + $groupid=0; + if(!(empty($group))){ + $groupid=$group['group_id']; + } + + if($groupid==1)return 1; + + if( (($upload_role_type==2) and ($upload_role_id==$groupid) ) or (($upload_role_type2==2) and ($upload_role_id2==$groupid)) ){ + return 1; + } + return 0; + } +} +/** + * 是否后台可以代前台专家会员评分,返回值为int + * @param int $id 分配专家id + * @return int 0:不能 1:能 + */ +function chk_cult4CanChangeScore($apply_id,$pro_id) +{ + $where=array( + 'apply_id'=>$apply_id, + 'pro_id'=>$pro_id, + 'assign_type'=>0, + 'del_flag'=>0, + ); + $rst=Db::name('cult4proassign')->where($where)->find(); + + if($rst){ + if(($rst['score']==0) and ($rst['advice']==null)) + return 1; + else + return 0; + } + return 1; +} +/** + * 是否后台可以代前台专家会员评分,返回值为int + * @param int $id 分配专家id + * @return int 0:不能 1:能 + */ +function chk_capitalCanChangeScore($apply_id,$pro_id) +{ + $where=array( + 'apply_id'=>$apply_id, + 'pro_id'=>$pro_id, + 'assign_type'=>0, + 'del_flag'=>0, + ); + $rst=Db::name('capitalproassign')->where($where)->find(); + + if($rst){ + if(($rst['score']==0) and ($rst['advice']==null)) + return 1; + else + return 0; + } + return 1; +} +/** + * 是否后台可以代前台专家会员评分,返回值为int + * @param int $id 分配专家id + * @return int 0:不能 1:能 + */ +function getRegionName($pid) +{ + $where=array( + 'id'=>$pid, + ); + $rst=Db::name('region')->where($where)->find(); + + if($rst){ + return $rst['name']; + } + return '未知'; +} +function getApiSign($param){ + ksort($param); + $paramkeys = array_keys($param); + $paramstring =""; + //拼接参数名和参数值字符串 + foreach ($paramkeys as $key){ + $paramstring = "$paramstring$key$param[$key]"; + } + $private_key = "szwjs";//约定秘钥 + $paramstring="$paramstring$private_key"; + return md5($paramstring);//加密获得sign字符串 +} + +/** 调用识别名片接口 + * @param $param + * @return array|mixed + */ +function ImgReconCard($filepath){ + try { + $filepath = realpath ( $filepath ); + $file = array ( + "key" => "NmMiQjAW5627rrGf6HrBp9", + "secret" => "7a4a49a4d7de490aad61c63372aa615f", + "typeId" => "20", + "format" => "json", + "file" => new \CURLFile ( $filepath, 'image/jpeg' ) + ); + $curl = curl_init (); + curl_setopt ( $curl, CURLOPT_URL, "http://netocr.com/api/recog.do" ); + curl_setopt ( $curl, CURLOPT_POST, true ); + curl_setopt ( $curl, CURLOPT_POSTFIELDS, $file ); + curl_setopt ( $curl, CURLOPT_RETURNTRANSFER, true ); + $result = curl_exec ( $curl ); + curl_close ( $curl ); + + $ocr =json_decode ( $result, true ); + if ($ocr) { + if ($ocr ['message'] ['status'] == 0) { + $cardinfo = $ocr ['cardsinfo'] [0]; + foreach ( $cardinfo ['items'] as $k => $v ) { + if ($v ['desc'] == "姓名") { + $card ['name'] = $v ['content']; + } + if ($v ['desc'] == "地址") { + $card ['address'] = $v ['content']; + } + if ($v ['desc'] == "公司") { + $card ['company'] = $v ['content']; + } + if ($v ['desc'] == "手机") { + $card ['tel'] = $v ['content']; + } + } + } + } else { + $card = $ocr; + } + return $card; + + } catch (SOAPFault $e) { + + } +} + +/** + * 根据模板文件id获取文件路径,返回值为字符串 + * @param int $ftempid 文件id + * @return string + */ +function get_tg_tempfile($ftempid) +{ + $path=Db::name('trusteeship_upfiles')->where(['file_id'=>$ftempid])->value('path'); + return get_imgurl($path); +} +function get_TGStatus($status_id) +{ + $curStatus =Db::name('trusteeship_status')->where(['status'=>$status_id])->select(); + return $curStatus[0]['descr']; +} +function get_TGPathFromFileID($fid) +{ + $file = Db::name('trusteeship_upfiles')->where(['file_id'=>$fid])->order('upload_time desc')->find();; + if(!empty($file)) { + return $file['path']; + }else{ + return '未上传'; + } +} + +function get_OrgStatus($status_id) +{ + $curStatus =Db::name('org_status')->where(['status'=>$status_id])->select(); + return $curStatus[0]['descr']; +} +function get_OrgPathFromFileID($fid) +{ + $file = Db::name('org_upfiles')->where(['file_id'=>$fid])->order('upload_time desc')->find();; + if(!empty($file)) { + return $file['path']; + }else{ + return '未上传'; + } +} +function send_post($str_param){ + $host=config('apiHost'); + $api_url =$host.'/midservice/api'; + $ch = curl_init (); + curl_setopt ( $ch, CURLOPT_URL, $api_url ); + curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 ); + curl_setopt ( $ch, CURLOPT_CONNECTTIMEOUT, 10 ); + curl_setopt ( $ch, CURLOPT_POST, 1 ); //启用POST提交 + curl_setopt($ch, CURLOPT_POSTFIELDS, $str_param); + $file_contents = curl_exec ( $ch ); + curl_close ( $ch ); + if(json_decode($file_contents)[0]->result!='000000'){ + session("api_token",null); + } + return json_decode($file_contents)[0]; + +} +/** 掌柜文化金服登录 + * @param $login_name 登录名 + * @param $login_password 登录密码 + * @param $verify 验证码(图像验证码/短信验证码) + * @return string + */ +function login_api($login_name,$login_password,$verify) +{ + $post_data='directives=[{ "api":"MT1100","params":{ "account": "'.$login_name ; + $post_data=$post_data.'", "VERIFYCODE": "'.$verify.'", "CAPTCHA_TOKEN":"'.getapitoken().'", "pwd": "'.$login_password.'" } }]'; + return send_post($post_data); +} + +/** 获取掌柜文化金服系统配置 + * @return mixed + */ +function getSystemConfig(){ + $post_data='directives=[{"api":"MT1001", "params":{}}]'; + return send_post($post_data); +} + +/*** 获取接口token值 + * @return mixed + */ +function getapitoken(){ + if(empty(session("api_token"))){ + $post_data='directives=[{"api":"MT1002", "params":{}}]'; + $token=''; + try { + $result =send_post($post_data); + + $token=$result->data->CAPTCHA_TOKEN; + }catch (\Exception $e){ + + } + session("api_token",$token); + } + return session("api_token"); +} + +/** 获取图形验证码url + * @return string + */ +function getVerifyImg(){ + session("api_token",null); + $host=config('apiHost'); + return $host.'/midservice/captcha?value='.getapitoken(); +} + +function sendSms($phone,$verify_code,$token){ + $post_data='directives=[{"api":"MT1301", "params":{"phoneNumber":"'.$phone.'","CAPTCHA":"'.$verify_code.'","CAPTCHA_TOKEN":"'.$token.'","CAPTCHA_ACTION":"RANDOMCODE"}}]'; + return send_post($post_data); +} + +function register_api($phone,$verify,$token,$password){ + $post_data='directives=[{ "api":"MT1305", "params":{ "phoneNumber": "'.$phone.'", "verifyCode": "'.$verify.'",'; + $post_data = $post_data.'"CAPTCHA_TOKEN":"'.$token.'", "password": "'.$password.'", "memberId":"6666" } }]'; + return send_post($post_data); +} + +/** 检查上传文件的类型 + * @param $table 文件类型表名 + * @param $typeid 文件类型ID + * @param $uptype 上传的文件类型 + */ +function check_upfiletype($table,$typeid,$uptype){ + $ftype = DB::name($table)->where(['ftype_id'=>$typeid])->find(); + if($ftype){ + if($ftype['ftype'] == 'PDF') { + if(in_array(strtoupper($uptype),['PDF'])){ + return true; + } + return false; + }else if($ftype['ftype'] == 'JPG') { + if(in_array(strtoupper($uptype),['JPG'])){ + return true; + } + return false; + }else if($ftype['ftype'] == 'DOC') { + if(in_array(strtoupper($uptype),['DOC','DOCX'])){ + return true; + } + return false; + } + }else{ + return false; + } +} + +function check_cardno($cardType,$value){ + if($cardType==1){//身份证 + $reg = '/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/'; + return preg_match($reg,$value); + }else if($cardType==2){//护照 + return 1; + }else if($cardType==3){//军官证 + return true; + }else if($cardType==4){//港澳通行证 + return 1; + }else if($cardType==5){//台同胞 + return 1; + } +} +function checkHTMLTag($value){ + if(!is_string($value))return false; + $reg = '/^[<]+[a-zA-Z]*[>]*|[<]*[a-zA-Z]*[>]+$/'; + return preg_match($reg,$value); +} diff --git a/app/config.php b/app/config.php new file mode 100644 index 0000000..4cbb84b --- /dev/null +++ b/app/config.php @@ -0,0 +1,275 @@ + +// +---------------------------------------------------------------------- +use \think\Request; + +$basename = Request::instance()->root(); +if (pathinfo($basename, PATHINFO_EXTENSION) == 'php') { + $basename = dirname($basename); +} +$configs= [ + // +---------------------------------------------------------------------- + // | 应用设置 + // +---------------------------------------------------------------------- + + // 应用命名空间 + 'app_namespace' => 'app', + // 应用调试模式 + 'app_debug' =>false, + // 应用Trace + 'app_trace' => true, + // 应用模式状态 + 'app_status' => '', + // 是否支持多模块 + 'app_multi_module' => true, + // 入口自动绑定模块 + 'auto_bind_module' => false, + // 注册的根命名空间 + 'root_namespace' => [], + // 扩展函数文件 + 'extra_file_list' => [THINK_PATH . 'helper' . EXT], + // 默认输出类型 + 'default_return_type' => 'html', + // 默认AJAX 数据返回格式,可选json xml ... + 'default_ajax_return' => 'json', + // 默认JSONP格式返回的处理方法 + 'default_jsonp_handler' => 'jsonpReturn', + // 默认JSONP处理方法 + 'var_jsonp_handler' => 'callback', + // 默认时区 + 'default_timezone' => 'PRC', + // 是否开启多语言 + 'lang_switch_on' => false, + // 默认全局过滤方法 用逗号分隔多个 + 'default_filter' => 'htmlspecialchars', + // 默认语言 + 'default_lang' => 'zh-cn', + // 应用类库后缀 + 'class_suffix' => false, + // 控制器类后缀 + 'controller_suffix' => false, + + // +---------------------------------------------------------------------- + // | 模块设置 + // +---------------------------------------------------------------------- + + // 默认模块名 + 'default_module' => 'home', + // 禁止访问模块 + 'deny_module_list' => ['common'], + // 默认控制器名 + 'default_controller' => 'Index', + // 默认操作名 + 'default_action' => 'index', + // 默认验证器 + 'default_validate' => '', + // 默认的空控制器名 + 'empty_controller' => 'Error', + // 操作方法后缀 + 'action_suffix' => '', + // 自动搜索控制器 + 'controller_auto_search' => false, + + // +---------------------------------------------------------------------- + // | URL设置 + // +---------------------------------------------------------------------- + + // PATHINFO变量名 用于兼容模式 + 'var_pathinfo' => 's', + // 兼容PATH_INFO获取 + 'pathinfo_fetch' => ['ORIG_PATH_INFO', 'REDIRECT_PATH_INFO', 'REDIRECT_URL'], + // pathinfo分隔符 + 'pathinfo_depr' => '/', + // URL伪静态后缀 + 'url_html_suffix' => 'html', + // URL普通方式参数 用于自动生成 + 'url_common_param' => false, + // URL参数方式 0 按名称成对解析 1 按顺序解析 + 'url_param_type' => 0, + // 是否开启路由 + 'url_route_on' => true, + // 路由使用完整匹配 + 'route_complete_match' => false, + // 路由配置文件(支持配置多个) + 'route_config_file' => ['route'], + // 是否强制使用路由 + 'url_route_must' => false, + // 域名部署 + 'url_domain_deploy' => false, + // 域名根,如thinkphp.cn + 'url_domain_root' => '', + // 是否自动转换URL中的控制器和操作名 + 'url_convert' => true, + // 默认的访问控制器层 + 'url_controller_layer' => 'controller', + // 表单请求类型伪装变量 + 'var_method' => '_method', + // 表单ajax伪装变量 + 'var_ajax' => '_ajax', + // 表单pjax伪装变量 + 'var_pjax' => '_pjax', + // 是否开启请求缓存 true自动缓存 支持设置请求缓存规则 + 'request_cache' => false, + // 请求缓存有效期 + 'request_cache_expire' => null, + + // +---------------------------------------------------------------------- + // | 模板设置 + // +---------------------------------------------------------------------- + + 'template' => [ + // 模板引擎类型 支持 php think 支持扩展 + 'type' => 'Think', + // 模板路径 + 'view_path' => '', + // 模板后缀 + 'view_suffix' => 'html', + // 模板文件名分隔符 + 'view_depr' => DS, + // 模板引擎普通标签开始标记 + 'tpl_begin' => '{', + // 模板引擎普通标签结束标记 + 'tpl_end' => '}', + // 标签库标签开始标记 + 'taglib_begin' => '{', + // 标签库标签结束标记 + 'taglib_end' => '}', + ], + 'view_replace_str' => [ + '__ROOT__' => $basename, + '__DATA__' => $basename . '/data', + '__PUBLIC__' => $basename . '/public', + '__UPLOAD__'=> $basename . '/data/upload', + ], + // 默认跳转页面对应的模板文件 + 'dispatch_success_tmpl' => THINK_PATH . 'tpl' . DS . 'dispatch_jump.tpl', + 'dispatch_error_tmpl' => ROOT_PATH . 'public/yfcmf/dispatch_jump.html', + + // +---------------------------------------------------------------------- + // | 异常及错误设置 + // +---------------------------------------------------------------------- + + // 异常页面的模板文件 + 'exception_tmpl' => ROOT_PATH . 'public/yfcmf/error.html', + + // 错误显示信息,非调试模式有效 + 'error_message' => '页面错误!请稍后再试~', + // 显示错误信息 + 'show_error_msg' => true, + // 异常处理handle类 留空使用 \think\exception\Handle + 'exception_handle' => '', + + // +---------------------------------------------------------------------- + // | 日志设置 + // +---------------------------------------------------------------------- + + 'log' => [ + // 日志记录方式,内置 file socket 支持扩展 + 'type' => 'File', + // 日志保存目录 + 'path' => LOG_PATH, + // 日志记录级别 + 'level' => [], + ], + + // +---------------------------------------------------------------------- + // | Trace设置 开启 app_trace 后 有效 + // +---------------------------------------------------------------------- + 'trace' => [ + // 内置Html Console 支持扩展 + 'type' => 'Html', + ], + + // +---------------------------------------------------------------------- + // | 缓存设置 + // +---------------------------------------------------------------------- + + 'cache' => [ + // 驱动方式 + 'type' => 'File', + // 缓存保存目录 + 'path' => CACHE_PATH, + // 缓存前缀 + 'prefix' => '', + // 缓存有效期 0表示永久缓存 + 'expire' => 0, + ], + + // +---------------------------------------------------------------------- + // | 会话设置 + // +---------------------------------------------------------------------- + + 'session' => [ + 'id' => '', + // SESSION_ID的提交变量,解决flash上传跨域 + 'var_session_id' => '', + // SESSION 前缀 + 'prefix' => 'think', + // 驱动方式 支持redis memcache memcached + 'type' => '', + // 是否自动开启 SESSION + 'auto_start' => true, + ], + + // +---------------------------------------------------------------------- + // | Cookie设置 + // +---------------------------------------------------------------------- + 'cookie' => [ + // cookie 名称前缀 + 'prefix' => '', + // cookie 保存时间 + 'expire' => 3600*24*7, + // cookie 保存路径 + 'path' => '/', + // cookie 有效域名 + 'domain' => '', + // cookie 启用安全传输 + 'secure' => false, + // httponly设置 + 'httponly' => '', + // 是否使用 setcookie + 'setcookie' => true, + ], + + //分页配置 + 'paginate' => [ + 'type' => 'bootstrap', + 'var_page' => 'page', + 'list_rows' => 10, + ], + //数据库备份设置 + 'db_path' => './data/backup/', //数据库备份路径必须以 / 结尾; + 'db_part' => '20971520', //该值用于限制压缩后的分卷最大长度。单位:B;建议设置20M + 'db_compress' => '1', //压缩备份文件需要PHP环境支持gzopen,gzwrite函数 0:不压缩 1:启用压缩 + 'db_level' => '9', //压缩级别 1:普通 4:一般 9:最高 + //数据加密 + 'data_auth_key'=>'dMm2VYlyr04ENpTpxGPRLiDLu9ZkhIBR1zW5jM6', + //验证码 + 'verify'=>[ + 'fontSize' => 20, + 'fontttf'=>'1.ttf', + 'useZh'=>false, + 'imageH' => 42, + 'imageW' => 250, + 'length' => 5, + 'useCurve' =>true, + ], +]; +//动态设置 +if(file_exists($file=ROOT_PATH."data/conf/config.php")){ + $configs=array_merge($configs,include ($file)); +} +//调试模式,错误模板保持TP默认 +if($configs['app_debug']){ + $configs['dispatch_success_tmpl']= THINK_PATH . 'tpl' . DS . 'dispatch_jump.tpl'; + $configs['dispatch_error_tmpl']= THINK_PATH . 'tpl' . DS . 'dispatch_jump.tpl'; + $configs['exception_tmpl']= THINK_PATH . 'tpl' . DS . 'think_exception.tpl'; +} +return $configs; diff --git a/app/crons.php b/app/crons.php new file mode 100644 index 0000000..cff07f0 --- /dev/null +++ b/app/crons.php @@ -0,0 +1,14 @@ + +// +---------------------------------------------------------------------- + +// 定时任务 '任务名'=>[任务文件名,定时执行周期,开始执行时间] +return [ + // // 定时清理日志 + 'clearlog' => ['clearlog',86400,1482606000], +]; \ No newline at end of file diff --git a/app/database.php b/app/database.php new file mode 100644 index 0000000..0f50c16 --- /dev/null +++ b/app/database.php @@ -0,0 +1,53 @@ + +// +---------------------------------------------------------------------- + +return [ + // 数据库类型 + 'type' => 'mysql', + // 服务器地址 + 'hostname' => 'localhost', + // 数据库名 + 'database' => 'why_xingtongworl', + // 用户名 + 'username' => 'why_xingtongworl', + // 密码 + 'password' => 'zefBd6Gpa3cjjTph', + // 端口 + 'hostport' => '3306', + // 连接dsn + 'dsn' => '', + // 数据库连接参数 + 'params' => [], + // 数据库编码默认采用utf8 + 'charset' => 'utf8', + // 数据库表前缀 + 'prefix' => 'wjs_', + // 数据库调试模式 + 'debug' => false, + // 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器) + 'deploy' => 0, + // 数据库读写是否分离 主从式有效 + 'rw_separate' => false, + // 读写分离后 主服务器数量 + 'master_num' => 1, + // 指定从服务器序号 + 'slave_no' => '', + // 是否严格检查字段是否存在 + 'fields_strict' => true, + // 数据集返回类型 array 数组 collection Collection对象 + 'resultset_type' => 'array', + // 是否自动写入时间戳字段 + 'auto_timestamp' => false, + //自动时间格式转换 + 'datetime_format'=>false, + // 是否需要进行SQL性能分析 + 'sql_explain' => false, +]; diff --git a/app/lang/en-us.php b/app/lang/en-us.php new file mode 100644 index 0000000..28a7371 --- /dev/null +++ b/app/lang/en-us.php @@ -0,0 +1,51 @@ + +// +---------------------------------------------------------------------- + +// 语言包zh-cn文件 +return [ + 'province'=>'province', + 'city'=>'city', + 'town'=>'town', + 'not logged'=>'You are not logged in!', + 'success'=>'Success!', + 'failed'=>'Failed!', + 'save success'=>'Save success!', + 'save failed'=>'Save failed!', + 'old pwd empty'=>'The original password can not be empty!', + 'old pwd not correct'=>'The old password is incorrect!', + 'new pwd empty'=>'The new password can not be empty!', + 'pwd not same'=>'New and confirmed passwords are not the same!', + 'new pwd the same as old pwd'=>'The new password cannot be the same as the original password!', + 'revise success'=>'Revise success!', + 'revise failed'=>'Revise failed!', + 'avatar update success'=>'Avatar update success!', + 'avatar update failed'=>'Avatar update failed!', + 'submission mode incorrect'=>'Submission mode is not correct!', + 'operation not valid'=>'This operation is not valid!', + 'verifiy incorrect'=>'Verifiy incorrect!', + 'pwd empty'=>'Password can not be empty!', + 'username or pwd incorrect'=>'Username or password error, Please reinput!', + 'login success'=>'Login success!', + 'login failed'=>'Login failed!', + 'email empty'=>'Email can not be empty!', + 'email format incorrect'=>'Email format is incorrect!', + 'repassword empty'=>'Repassword can not be empty!', + 'repassword incorrect'=>'Repassword incorrect!', + 'parameter error'=>'Parameter error!', + 'pwd'=>'Password', + 'delete'=>'Delete', + 'title'=>'Title', + 'description'=>'Description', + 'operation'=>'Operation', + 'save'=>'Save', + 'edit'=>'Edit', + 'admin manage'=>'Admin manage', +]; diff --git a/app/lang/zh-cn.php b/app/lang/zh-cn.php new file mode 100644 index 0000000..e11fa84 --- /dev/null +++ b/app/lang/zh-cn.php @@ -0,0 +1,51 @@ + +// +---------------------------------------------------------------------- + +// 语言包zh-cn文件 +return [ + 'province'=>'省', + 'city'=>'市(地区)', + 'town'=>'镇(区)', + 'not logged'=>'您还没有登录!', + 'success'=>'成功!', + 'failed'=>'失败!', + 'save success'=>'保存成功!', + 'save failed'=>'保存失败!', + 'old pwd empty'=>'原始密码不能为空!', + 'old pwd not correct'=>'原始密码不正确!', + 'new pwd empty'=>'新密码不能为空!', + 'pwd not same'=>'新密码与确认密码不一致!', + 'new pwd the same as old pwd'=>'新密码不能和原始密码相同!', + 'revise success'=>'修改成功!', + 'revise failed'=>'修改失败!', + 'avatar update success'=>'头像更新成功!', + 'avatar update failed'=>'头像更新失败!', + 'submission mode incorrect'=>'提交方式不正确!', + 'operation not valid'=>'此操作无效!', + 'verifiy incorrect'=>'验证码错误!', + 'pwd empty'=>'密码不能为空!', + 'username or pwd incorrect'=>'用户名或者密码错误,重新输入!', + 'login success'=>'登陆成功!', + 'login failed'=>'登陆失败!', + 'email empty'=>'邮箱不能为空!', + 'email format incorrect'=>'邮箱格式不正确!', + 'repassword empty'=>'重复密码不能为空!', + 'repassword incorrect'=>'确认密码不正确!', + 'parameter error'=>'参数错误!', + 'pwd'=>'密码', + 'delete'=>'删除', + 'title'=>'标题', + 'description'=>'描述', + 'operation'=>'操作', + 'save'=>'保存', + 'edit'=>'编辑', + 'admin manage'=>'后台管理', +]; diff --git a/app/org/controller/Orgapply.php b/app/org/controller/Orgapply.php new file mode 100644 index 0000000..87735b0 --- /dev/null +++ b/app/org/controller/Orgapply.php @@ -0,0 +1,747 @@ +$apply_id, + 'new_flag'=>1, + ); + $uptype_list=UptypeModel::getList(-1,$apply_id,$ftype,$status,-1,'status,apply_type,ftype_id',-1); + $page = $uptype_list->render(); + $this->assign('uptype_list',$uptype_list); + $this->assign('page',$page); + return $this->fetch(); + } + /** 上传文件类型添加 + * @param int $status + * @return mixed + */ + public function uptype_add($process=-1,$status=-1){ + if ($process > 0 and $status > 0) { + //权限检查 + if (check_cult4UserRight(input('apply_id'), session('admin_auth.aid'), $status) == 0) { + $this->error('无权限',url('admin/Index/index')); + } + } + //创建token + creatToken(); + + $apply_id=input('apply_id'); + $this->assign('apply_id',$apply_id); + $this->assign('status',$status); + $where['status'] = array('egt',0); + $statuslist=Db::name('org_status')->where($where)->select(); + $this->assign('statuslist',$statuslist); + + return $this->fetch(); + } + /** 上传文件类型保存 + * @param int $status + * @return mixed + */ + public function uptype_runadd($process=-1,$status=-1){ +//添加固定内容 + if (!($process == -1 or $status ==-1)) { + //权限检查 + if (check_cult4UserRight(input('apply_id'), session('admin_auth.aid'), $status) == 0) { + $this->error('无权限',url('admin/Index/index')); + } + } + + $roletype=input('roletype'); + $roleid=input('roletitle'); + $roletype2=input('roletype2'); + $roleid2=input('roletitle2'); + if($roletype<=0 or $roleid<=0) + { + $this->error('请选择资料上传类型及对应的角色!'); + } + if(empty($roletype2))$roletype2=0; + if(empty($roleid2))$roleid2=0; + if(!(($roletype2==0 and $roleid2==0) or ($roletype2>0 and $roleid2>0) or ($roletype2<=0 and $roleid2<=0))) + { + $this->error('请选择资料辅助上传类型及对应的角色!'); + } + //防止重复提交 + if (!checkToken(input('TOKEN'))) { + //return; + } + //状态为-1时对应固定文件 + $apply_id=input('apply_id'); + $whereType=array( + 'apply_id'=>$apply_id, + 'new_flag'=>1, + ); + $mustupload=1; + if($process==-1){ + $apply_id = 0; + $apply_type=input('apply_type'); + $mustupload=input('mustupload'); + } + + //上传模板部分 + $file_id=0; + //支持多个字段单文件 + $file = request()->file('file_one'); + $file_one=''; + + if(!empty($file)){ + $validate = config('upload_validate'); + unset($validate['ext']);//不限制后缀 + //单图 + $info = $file->validate($validate)->rule('uniqid')->move(ROOT_PATH . config('upload_path') . DS . date('Y-m-d')); + if ($info) { + $file_url = config('upload_path'). '/' . date('Y-m-d') . '/' . $info->getFilename(); + //写入数据库 + $data['apply_id'] = 0;//模板文件未使用该字段 + $data['user_id'] = session('admin_auth.aid'); + $data['user_type'] = 2; + $data['status'] = $status; + $data['upload_time'] = time(); + $data['ftype_id'] = 0;//模板文件为0 + $data['ftype'] = 3;//模板类型 + $data['filesize'] = $info->getSize(); + $data['path'] = $file_url; + $data['addorder'] = 0;//固定文件需要更新 + $data['new_flag'] = 1;//固定文件需要更新 + + $file_id = Db::name('org_upfiles')->insert($data,false,true); + + } else { + session('TOKEN', input('TOKEN')); + $this->error($file->getError());//否则就是上传错误,显示错误原因 + } + } + if ($process == -1 or $status ==-1) { + $uptype_id=UptypeModel::add($apply_type,input('ftypedescr'),$file_id,input('ftype'),input('status'),input('isopen',0),0,session('admin_auth.aid'),$roletype,$roleid,$roletype2,$roleid2,$mustupload); + if($uptype_id){ + $this->success('文件类型添加成功',url('org/Orgapply/uptype_list')); + }else{ + session('TOKEN', input('TOKEN')); + $this->error('文件类型添加失败'); + } + }else{ + $uptype_id=UptypeModel::add($apply_type,input('ftypedescr'),$file_id,input('ftype'),$status,input('isopen',0),$apply_id,session('admin_auth.aid'),$roletype,$roleid,$roletype2,$roleid2); + if($uptype_id){ + $sl_data2['apply_id']=input('apply_id'); + $sl_data2['status']=$status; + $this->success('文件类型添加成功',url('org/Orgapply/uptype_list'.$process,$sl_data2)); + }else{ + session('TOKEN', input('TOKEN')); + $this->error('文件类型添加失败'); + } + } + } + /** 上传文件类型编辑 + * @return mixed + */ + public function uptype_edit(){ + if(!request()->isAjax()) { + //创建token + creatToken(); + $ftype_id = input('ftype_id', 0, 'intval'); + if (!$ftype_id) $this->error('参数错误', url('org/Orgapply/uptype_list')); + $uptype = Db::name('org_uptype')->where('ftype_id', $ftype_id)->find(); + $this->assign('uptype', $uptype); + if(!empty($uptype['ftemp_id'])){ + $upfile = Db::name('org_upfiles')->where('file_id', $uptype['ftemp_id'])->find(); + $this->assign('upfile', $upfile); + } + $where['status'] = array('egt',0); + $statuslist=Db::name('org_status')->where($where)->select(); + $this->assign('statuslist',$statuslist); + + $list1=array(); + if($uptype['upload_role_type']==1){ + $map1['member_group_id']=array(array('gt',0),array('neq',2));//>0 and !=2 + $list1=Db::name("member_group")->field(array('member_group_id'=>'id','member_group_name'=>'name'))->where($map1)->select(); + }elseif($uptype['upload_role_type']==2){ + $map2['id']=array('gt',0); + $list1=Db::name("auth_group")->field(array('id'=>'id','title'=>'name'))->where($map2)->select(); + } + $this->assign('list1',$list1); + $list2=array(); + if($uptype['upload_role_type2']==1){ + $map1['member_group_id']=array(array('gt',0),array('neq',2));//>0 and !=2 + $list2=Db::name("member_group")->field(array('member_group_id'=>'id','member_group_name'=>'name'))->where($map1)->select(); + }elseif($uptype['upload_role_type2']==2){ + $map2['id']=array('gt',0); + $list2=Db::name("auth_group")->field(array('id'=>'id','title'=>'name'))->where($map2)->select(); + } + $this->assign('list2',$list2); + return $this->fetch(); + }else{ + $roletype=input('roletype'); + $roleid=input('roletitle'); + $roletype2=input('roletype2'); + $roleid2=input('roletitle2'); + if($roletype<=0 or $roleid<=0) + { + $this->error('请选择资料上传类型及对应的角色!'); + } + if(empty($roletype2))$roletype2=0; + if(empty($roleid2))$roleid2=0; + if(!(($roletype2==0 and $roleid2==0) or ($roletype2>0 and $roleid2>0) or ($roletype2<=0 and $roleid2<=0))) + { + $this->error('请选择资料辅助上传类型及对应的角色!'); + } + //防止重复提交 + if (!checkToken(input('TOKEN'))) { + return; + } + + //固定 + $apply_id = 0; + $apply_type=input('apply_type'); + $mustupload=input('mustupload'); + + //上传模板部分 + $file_id=0; + //支持多个字段单文件 + $file = request()->file('file_one'); + $file_one=''; + + if(!empty($file)){ + $validate = config('upload_validate'); + unset($validate['ext']);//不限制后缀 + //单图 + $info = $file->validate($validate)->rule('uniqid')->move(ROOT_PATH . config('upload_path') . DS . date('Y-m-d')); + + if ($info) { + $file_url = config('upload_path'). '/' . date('Y-m-d') . '/' . $info->getFilename(); + //写入数据库 + $data['apply_id'] = 0;//模板文件未使用该字段 + $data['user_id'] = session('admin_auth.aid'); + $data['user_type'] = 2; + $data['status'] = input('status'); + $data['upload_time'] = time(); + $data['ftype_id'] = 0;//模板文件为0 + $data['ftype'] = 3;//模板类型 + $data['filesize'] = $info->getSize(); + $data['path'] = $file_url; + $data['addorder'] = 0;//固定文件需要更新 + $data['new_flag'] = 1;//固定文件需要更新 + + $file_id = Db::name('org_upfiles')->insert($data,false,true); + + } else { + $this->error($file->getError());//否则就是上传错误,显示错误原因 + } + }else{ + $file_id = input('ftemp_id'); + $data['file_id'] = $file_id;//模板文件未使用该字段 + $data['status'] = input('status'); + Db::name('org_upfiles')->where('file_id',$file_id)->update($data); + } + $sl_data=array( + 'ftype_id'=>input('ftype_id'), + 'ftypedescr'=>input('ftypedescr'), + 'ftemp_id' => $file_id, + 'apply_type' => $apply_type, + 'mustupload' => $mustupload, + 'ftype'=>input('ftype'), + 'status'=>input('status'), + 'isopen'=>input('isopen',0), + 'apply_id'=>$apply_id, + 'user_id'=>session('admin_auth.aid'), + 'create_time'=>time(), + 'upload_role_type'=>$roletype, + 'upload_role_id'=>$roleid, + 'upload_role_type2'=>$roletype2, + 'upload_role_id2'=>$roleid2, + ); + $uptype_id=Db::name('org_uptype')->where('ftype_id',input('ftype_id'))->update($sl_data); + if($uptype_id){ + $this->success('文件类型修改成功',url('org/Orgapply/uptype_list')); + }else{ + $this->error('文件类型修改失败'); + } + } + } + /** 上传文件类型启用停用 + * @param int $status + * @return mixed + */ + public function uptype_state($process =-1, $status =-1){ + $id=input('x'); + if (empty($id)){ + //如果不是固定添加类型 + if (!($process == -1 or $status ==-1)) { + $this->error('文件ID不存在', url('org/Orgapply/uptype_list' . $process)); + }else{ + $this->error('文件ID不存在', url('org/Orgapply/uptype_list')); + } + } + + //取得apply_id + $tempfile = UptypeModel::getFileTypeInfo($id); + if(empty($tempfile)){ + $this->error('无权限',url('admin/Index/index')); + } + $isopen=Db::name('org_uptype')->where('ftype_id',$id)->value('isopen');//判断当前状态情况 + if($isopen==1){ + $statedata = array('isopen'=>0); + Db::name('org_uptype')->where('ftype_id',$id)->setField($statedata); + $this->success('状态禁止'); + }else{ + $statedata = array('isopen'=>1); + Db::name('org_uptype')->where('ftype_id',$id)->setField($statedata); + $this->success('状态开启'); + } + } + + /** + * 审核列表 + */ + public function apply_list($applystatus=-1,$allstatus=-1){ + $search_name=input('search_name'); + $where=array(); + //根据状态值取出对应状态的数据 + if($allstatus == -1){ + $where['a.status'] = array('eq',$applystatus); + } + if(!empty($search_name)){ + $where['m.member_list_username'] = array('like','%'.$search_name.'%'); + } + //取得apply_admin_id为0或者当前用户的数据 + $where['a.apply_admin_id']=array(array('eq',0),array('eq',session('admin_auth.aid')),'or'); + + $apply_list = Db::name('org_apply')->alias("a")->join(config('database.prefix').'member_list m','a.uid =m.member_list_id') + ->join(config('database.prefix').'org_status c','a.status =c.status')->where($where) + ->order('create_time desc,id desc')->paginate(config('paginate.list_rows'),false,['query'=>get_query()]); + $page = $apply_list->render(); + $this->assign('apply_list',$apply_list); + $this->assign('page',$page); + $this->assign('search_name',$search_name); + $this->assign('applystatus',$applystatus); + $this->assign('allstatus',$allstatus); + $this->assign('loginuser',session('admin_auth.aid')); + return $this->fetch(); + } + + /** 受理操作 + * @param $status + */ + public function apply_applyed($status){ + if(session('admin_auth.aid')){ + $data=array( + 'apply_admin_id'=>session('admin_auth.aid'), + 'update_time'=>time(), + 'update_user_id'=>session('admin_auth.aid'), + 'update_user_type'=>1, + ); + $where=array( + 'id'=>input('id'), + 'status'=>$status, + 'apply_admin_id'=>array('EQ', 0), + ); + + $apply=Db::name('org_apply')->where($where)->update($data); + if($apply==0){ + $this->error('数据已更新,请重试!'); + } else { + $this->success('已受理',url('org/Orgapply/apply_check',array('id'=>input('id'),'applystatus'=>$status))); + } + } + else + { + $this->error('用户ID不存在'); + } + } + + public function apply_check(){ + creatToken(); + $apply_id=input('id'); + $apply_status=input('applystatus'); + $user_id=session('admin_auth.aid'); + $this->assign('user_id',$user_id); + + $apply = Db::name('org_apply')->where('id',$apply_id)->where('status',$apply_status)->find(); + $this->assign('apply',$apply); + + //设置当前步骤标题 + if($apply['status']==1){ + $curr_step='缴费金额设置'; + }elseif ($apply['status']==3){ + $curr_step='缴费确认'; + }elseif ($apply['status']==5){ + $curr_step='初审'; + }elseif ($apply['status']==6){ + $curr_step='风控复审'; + }elseif ($apply['status']==7){ + $curr_step='领导审核'; + }elseif ($apply['status']==9){ + $curr_step='企业信息审核'; + } + $this->assign('curr_step',$curr_step); + + //查询缴费确认历史 + if(in_array($apply['status'],[3,5,6,7,9])){ + $apply_cw = Db::name('org_cw')->where('apply_id',$apply_id)->order('create_time desc')->select(); + $this->assign('apply_cw',$apply_cw); + //缴费凭证 + $apply_jfpz = Db::name('org_upfiles')->where(['apply_id'=>$apply_id,'status'=>2])->order('upload_time desc')->find(); + $this->assign('apply_jfpz',$apply_jfpz); + } + //查询初审历史 + if(in_array($apply['status'],[5,6,7,9])){ + $apply_cs = Db::name('org_cs')->where('apply_id',$apply_id)->order('create_time desc')->select(); + $this->assign('apply_cs',$apply_cs); + //上传文件列表 + $where['apply_type']=array(array('eq',0),array('eq',$apply['org_name']), 'or');; + $where['status']=4; + $where['isopen']=1; + $apply_uptypelist = Db::name('org_uptype')->where($where)->select(); + for ($x=0; $xwhere($filewhere)->order('upload_time desc')->find(); + $apply_uptypelist[$x]['file']=$file; + } + $this->assign('apply_uptypelist',$apply_uptypelist); + } + //查询风控复审历史 + if(in_array($apply['status'],[6,7,9])){ + $apply_fk = Db::name('org_fk')->where('apply_id',$apply_id)->order('create_time desc')->select(); + $this->assign('apply_fk',$apply_fk); + } + //查询领导审核历史 + if(in_array($apply['status'],[7,9])){ + $apply_ldsh = Db::name('org_ldsh')->where('apply_id',$apply_id)->order('create_time desc')->select(); + $this->assign('apply_ldsh',$apply_ldsh); + } + return $this->fetch(); + } + + public function apply_runcheck(){ + $id=input('id'); + $apply = Db::name('org_apply')->where('id',$id)->find(); + //审核通过检查是否还有未审核通过的文件 + if(input('submitType')==1) { + $file_count = Db::name('org_upfiles')->where(['apply_id'=>$id,'flag'=>0,'new_flag'=>1])->count(); + if($file_count){ + session('TOKEN',input('TOKEN')); + $this->error('还有文件未审核通过'); + } + }else if($apply['status']!=3){ + $file_count = Db::name('org_upfiles')->where(['apply_id'=>$id,'flag'=>0,'new_flag'=>1])->count(); + if($file_count==0){ + session('TOKEN',input('TOKEN')); + $this->error('文件已全部审核通过,请将文件审核未不通过再操作!'); + } + } + if(empty($apply)){ + session('TOKEN',input('TOKEN')); + $this->error('申请不存在'); + } + if($apply['status']!=1 && $apply['status']!=9){ + if(input('advice')=='') + { + $this->error('请输入审核意见!'); + } + } + + //审核的数据内容 + $data=array( + 'apply_id'=>$id,//申请ID + 'advice'=>input('advice',"未填写"),//审批意见 + 'create_id'=>session('admin_auth.aid'),//审批人 + 'create_time'=>time(),//审批时间 + ); + //根据当前状态和审核操作,变更对应状态 + if($apply['status']==1){//当前状态为设置金额 + $update_status = 2;//缴费中(已设置金额) + $org_data['amount']=input('amount'); + }elseif ($apply['status']==3){//缴费确认 + $table_name = 'org_cw';//将审核数据保存到对应表 + if(input('submitType')==1) { + $update_status = 4;//上传资料中(已确认缴费) + }else{ + $update_status = 11;//会员修改中(缴费确认未通过) + } + }elseif ($apply['status']==5){//初审 + $table_name = 'org_cs';//将审核数据保存到对应表 + if(input('submitType')==1) { + $update_status = 6;//风控复审中(初审已通过) + }else{ + $update_status = 12;//会员修改中(初审未通过) + } + }elseif ($apply['status']==6){//风控复审 + $table_name = 'org_fk';//将审核数据保存到对应表 + if(input('submitType')==1) { + $update_status = 7;//领导审核中(风控复审已通过) + }else{ + $update_status = 13;//会员修改中(风控复审未通过) + } + }elseif ($apply['status']==7){//领导审核 + $table_name = 'org_ldsh';//将审核数据保存到对应表 + if(input('submitType')==1) { + $update_status = 8;//上传企业信息中(领导审核已通过) + }else{ + $update_status = 14;//会员修改中(领导审核未通过) + } + }elseif ($apply['status']==9){//企业信息确认 + $update_status = 10;//申请成功 + } + + //找到当前最大addorder + if(!empty($table_name)){ + $check=Db::name($table_name)->where('apply_id',$id)->order('addorder desc') ->find (); + if(!empty($check)){ + $data['addorder']=$check['addorder']+1; + }else{ + $data['addorder']=0; + } + } + if($apply['org_name']==1) $org_name='省级文化金融服务中心'; + elseif ($apply['org_name']==2)$org_name='市级文化金融服务中心'; + elseif ($apply['org_name']==3)$org_name='(行业)专板'; + elseif ($apply['org_name']==4)$org_name='(行业)专区'; + elseif ($apply['org_name']==5)$org_name='省级运营中心'; + elseif ($apply['org_name']==6)$org_name='市级运营中心'; + elseif ($apply['org_name']==7)$org_name='推荐机构'; + elseif ($apply['org_name']==8)$org_name='驻场服务机构全国'; + elseif ($apply['org_name']==9)$org_name='驻场服务机构区域'; + $defaultFileLink='
请点击:
上传资料
'; + //系统通知内容 + if(input('submitType')==2){ + //审核不通过发送通知给客户 + if($apply['status']==3){ + $notice_title='您(或您关联)的合作机构申请缴费凭证审核不通过,请重新上传!'; + $notic_content='您(或您关联)的合作机构申请不通过,需要您重新修改信息或上传缴费凭证后再提交。
审批意见:
审批意见:'.input('advice',"").$defaultFileLink; + }else if($apply['status']==5){ + $notice_title='您(或您关联)的合作机构申请初审审核不通过,请修改资料!'; + $sys=Orgsetup::get('orgcheck_options','-1'); + $notic_content=str_replace('#APPLYCONTENTS#',input('advice',""),$sys['content_tpl']); + $notic_content=str_replace('#COMNAME#',$apply['comname'],$notic_content); + $notic_content=str_replace('#APPLYNAME#',$org_name,$notic_content); + $notic_content=str_replace('#DATE#',date('Y年m月d日', time()),$notic_content); + }else if($apply['status']==6){ + $notice_title='您(或您关联)的合作机构申请风控审核不通过,请修改资料!'; + $notic_content='您(或您关联)的合作机构申请不通过,需要您重新修改信息或上传资料后再提交。
审批意见:'.input('advice',"").$defaultFileLink; + }else if($apply['status']==7){ + $notice_title='您(或您关联)的合作机构申请领导审核不通过,请修改资料!'; + $notic_content='您(或您关联)的合作机构申请不通过,需要您重新修改信息或上传资料后再提交。
审批意见:'.input('advice',"").$defaultFileLink; + } + }else if($update_status==2){//缴费中,需要发送缴费通知 + $fee_where['name']=$org_name; + $fee_where['code']='orgfee_options'; + $sys=Db::name('org_temp')->where($fee_where)->find();//缴费通知模板 + $notic_content=str_replace('#MONEY#',$org_data['amount'],$sys['content_tpl']); + $notic_content=str_replace('#COMNAME#',$apply['comname'],$notic_content); + $notic_content=str_replace('#ORGNAME#',$org_name,$notic_content); + $notic_content=str_replace('#DATE#',date('Y年m月d日', time()),$notic_content); + $notice_title='您(或您关联)的合作机构申请已审核,请缴费后上传缴费凭证!'; + }else if($update_status==10){//托管成功,发送成功通知给客户 + $org_data=[ + 'enterprise_name'=>input('enterprise_name'), + 'enterprise_desc'=>input('enterprise_desc'), + 'enterprise_address'=>input('enterprise_address'), + 'legal_person'=>input('legal_person'), + 'contact'=>input('contact'), + 'business_code'=>input('business_code'), + 'startdate'=>input('startdate'), + 'enddate'=>input('enddate'), + 'status'=>9 + ]; + //消息通知内容 + $notice_title='('.$org_data['enterprise_name'].')合作机构申请成功通知'; + $sys=Orgsetup::get('orgsuccess_options','-1'); + $notic_content=str_replace('#CODE#',input('business_code'),$sys['content_tpl']); + $notic_content=str_replace('#COMNAME#',input('enterprise_name'),$notic_content); + $notic_content=str_replace('#DATE#',date('Y年m月d日', time()),$notic_content); + //公告内容 + $sys_gg=Orgsetup::get('orggg_options','-1'); + $gg_title='('.$org_data['enterprise_name'].')合作机构申请成功通知'; + $gg_content=str_replace('#CODE#',input('business_code'),$sys_gg['content_tpl']); + $gg_content=str_replace('#COMNAME#',input('enterprise_name'),$gg_content); + $gg_content=str_replace('#DATE#',date('Y年m月d日', time()),$gg_content); + $gg_data=[ + 'n_title'=>$gg_title, + 'n_content'=>$gg_content, + 'n_status'=>1, + 'n_time'=>time(), + 'n_uid'=>1, + 'n_cid'=>1, + 'n_hits'=>0, + ]; + //牌匾内容 + $pb_title='合作机构牌匾'; + $sys_pb=Orgsetup::get('orgplaque_options','-1'); + $pb_content=str_replace('#PBAREANAME#',input('area_name'),$sys_pb['content_tpl']); + $pb_content=str_replace('#PBCODE#',input('business_code'),$pb_content); + $pb_content=str_replace('#PBNAME#',input('enterprise_name'),$pb_content); + $pb_content='
'.$pb_content.'
下载
'; + $pb_data=[ + 'notice_title'=>$pb_title, + 'notice'=>$pb_content, + 'apply_id'=>$id, + 'user_id'=>$apply['uid'], + 'create_id'=>session('admin_auth.aid'), + 'create_type'=>1, + 'create_time'=>time() + ]; + //图片 + $files = request()->file(''); + if(!empty($files['enterprise_logo'])){ + $info = $files['enterprise_logo']->rule('md5')->move(ROOT_PATH . config('upload_path') . DS . date('Y-m-d')); + if ($info) { + $org_data['enterprise_logo']=config('upload_path') . '/' . date('Y-m-d') . '/' . $info->getFilename(); + } + } + if(!empty($files['person_pic'])){ + $info2 = $files['person_pic']->rule('md5')->move(ROOT_PATH . config('upload_path') . DS . date('Y-m-d')); + if ($info2) { + $org_data['person_pic']=config('upload_path') . '/' . date('Y-m-d') . '/' . $info2->getFilename(); + } + } + + //合作机构展示内容 + $org_title=input('enterprise_name'); + if(empty($org_data['enterprise_logo'])){ + $org_data['enterprise_logo']=$apply['enterprise_logo']; + } + if(empty($org_data['person_pic'])){ + $org_data['person_pic']=$apply['person_pic']; + } + $enterprise_logo= ''; + $person_pic= ''; + $sys_org=Orgsetup::get('orginfo_options','-1'); + $org_content=str_replace('#ENTERPRISE_NAME#',$org_data['enterprise_name'],$sys_org['content_tpl']); + $org_content=str_replace('#ENTERPRISE_LOGO#',$enterprise_logo,$org_content); + $org_content=str_replace('#ENTERPRISE_DESC#',$org_data['enterprise_desc'],$org_content); + $org_content=str_replace('#ENTERPRISE_ADDRESS#',$org_data['enterprise_address'],$org_content); + $org_content=str_replace('#LEGAL_PERSON#',$org_data['legal_person'],$org_content); + $org_content=str_replace('#CONTACT#',$org_data['contact'],$org_content); + $org_content=str_replace('#PERSON_PIC#',$person_pic,$org_content); + $org_info=[ + 'n_title'=>$org_title, + 'n_content'=>$org_content, + 'n_status'=>1, + 'n_time'=>time(), + 'n_uid'=>1, + 'n_cid'=>1, + 'n_hits'=>0, + 'n_order'=>1 + ]; + + //盖章授权书 + $sq_title='授权书'; + $sys_sq=Orgsetup::get('orgsq_options','-1'); + $sq_content=$sys_sq['content_tpl']; + $sq_content=str_replace('#ORGNAME#',$org_data['enterprise_name'],$sq_content); + $sq_content=str_replace('#ORGTYPE#',$org_name,$sq_content); + $sq_content=str_replace('#VAILDDATE#',$org_data['startdate'].' 至 '.$org_data['enddate'],$sq_content); + $sq_content=str_replace('#DATE#',date('Y年m月d日', time()),$sq_content); + $sq_content='
'.$sq_content.'
下载
'; + $sq_data=[ + 'notice_title'=>$sq_title, + 'notice'=>$sq_content, + 'apply_id'=>$id, + 'user_id'=>$apply['uid'], + 'create_id'=>session('admin_auth.aid'), + 'create_type'=>1, + 'create_time'=>time() + ]; + }elseif($update_status==4){ + $notice_title='('.$org_name.')合作机构申请缴费确认通知'; + $notic_content = '您上传的缴费凭证已通过财务审核!请上传相关资料。'; + }elseif($update_status==8){ + $notice_title='('.$org_name.')合作机构申请上传企业信息通知'; + $notic_content = '您的合作机构申请已通过,请及时上传企业相关信息。'; + } + Db::startTrans(); + try{ + $org_data['status']=$update_status; + $org_data['update_user_id']=session('admin_auth.aid'); + $org_data['update_user_type']=2;//后台 + $org_data['update_time']=time(); + $org_data['apply_admin_id']=0; + $where=array( + 'id'=>$apply['id'], + 'status'=>$apply['status'], + ); + Db::name('org_apply')->where($where)->update($org_data); + if(!empty($table_name)){ + Db::name($table_name)->insert($data); + } + + if(input('submitType')==2 || in_array($update_status,[2,10,4,8])){ + $n_data=[ + 'notice_title'=>$notice_title, + 'notice'=>$notic_content, + 'apply_id'=>$id, + 'user_id'=>$apply['uid'], + 'create_id'=>session('admin_auth.aid'), + 'create_type'=>1, + 'create_time'=>time() + ]; + Db::name('cult4notice')->insert($n_data); + } + if($update_status==10){ + if(!empty($gg_data)){ + Db::name('bsgg')->insert($gg_data); + } + if(!empty($pb_data)){ + Db::name('cult4notice')->insert($pb_data); + } + if(!empty($sq_data)){ + Db::name('cult4notice')->insert($sq_data); + } + if(!empty($org_info)){ + Db::name($apply['org_type'])->insert($org_info); + } + } + // 提交事务 + Db::commit(); + }catch (\Exception $exception){ + Db::rollback();//回滚事务 + session('TOKEN',input('TOKEN'));//审核失败,将token添加回session里 + $this->error('审核失败'); + } + $this->success('审核成功',url('org/Orgapply/apply_list',array('applystatus'=>$apply['status']))); + } + + /** + * 文件核验开启/禁止 + */ + public function apply_state() + { + $id=input('x'); + if (empty($id)){ + $this->error('用户ID不存在'); + } + + $flag=Db::name('org_upfiles')->where('file_id',$id)->value('flag');//判断当前状态情况 + if($flag==1){ + $flagdata = array('flag'=>0); + Db::name('org_upfiles')->where('file_id',$id)->setField($flagdata); + $this->success('审核未通过'); + }else{ + $flagdata = array('flag'=>1); + Db::name('org_upfiles')->where('file_id',$id)->setField($flagdata); + $this->success('审核已通过'); + } + } + +} \ No newline at end of file diff --git a/app/org/controller/Orgsetup.php b/app/org/controller/Orgsetup.php new file mode 100644 index 0000000..35f084d --- /dev/null +++ b/app/org/controller/Orgsetup.php @@ -0,0 +1,316 @@ +where('code','orgagree_options')->field('id,name,create_time')->select(); + + $this->assign('list',$agree_list); + return $this->fetch(); + } + /** + * 合作机构申请同意协议模板设置显示 + */ + public function orgagree() + { + $sys=self::get('orgagree_options'); + $this->assign('sys',$sys); + return $this->fetch(); + } + + /** + * 合作机构申请同意协议模板设置保存 + */ + public function orgagreerun() + { + if (!request()->isAjax()){ + $this->error('提交方式不正确'); + }else{ + $options=input('post.options/a'); + $options['content_tpl']=htmlspecialchars_decode($options['content_tpl']); + $options['code']='orgagree_options'; + $options['id']=input('id'); + $rst=self::update($options); + if($rst!==false){ + $this->success('合作机构申请同意协议模板设置保存成功',url('org/Orgsetup/orgagree_list')); + }else{ + $this->error('提交参数不正确'); + } + } + } + + /** + * 合作机构申请缴费通知模板列表 + */ + public function orgfee_list() + { + $fee_list=Db::name('org_temp')->where('code','orgfee_options')->field('id,name,create_time')->select(); + + $this->assign('list',$fee_list); + return $this->fetch(); + } + /** + * 合作机构申请缴费通知模板设置显示 + */ + public function orgfee() + { + $sys=self::get('orgfee_options',input('id')); + $this->assign('sys',$sys); + return $this->fetch(); + } + + /** + * 合作机构申请缴费通知模板设置保存 + */ + public function orgfeerun() + { + if (!request()->isAjax()){ + $this->error('提交方式不正确'); + }else{ + $options=input('post.options/a'); + $id = input('id'); + $options['content_tpl']=htmlspecialchars_decode($options['content_tpl']); + $options['code']='orgfee_options'; + $options['id']=$id; + $rst=self::update($options); + if($rst!==false){ + $this->success('合作机构申请缴费通知模板设置保存成功',url('org/Orgsetup/orgfee_list')); + }else{ + $this->error('提交参数不正确'); + } + } + } + /** + * 合作机构申请初审意见书模板设置显示 + */ + public function orgcheck() + { + $sys=self::get('orgcheck_options',-1); + $this->assign('sys',$sys); + return $this->fetch(); + } + + /** + * 合作机构申请初审意见书模板设置保存 + */ + public function orgcheckrun() + { + if (!request()->isAjax()){ + $this->error('提交方式不正确',url('org/Orgsetup/orgcheck')); + }else{ + $options=input('post.options/a'); + $options['content_tpl']=htmlspecialchars_decode($options['content_tpl']); + $options['code']='orgcheck_options'; + $rst=self::update($options); + if($rst!==false){ + $this->success('合作机构申请初审意见书模板设置保存成功',url('org/Orgsetup/orgcheck')); + }else{ + $this->error('提交参数不正确',url('org/Orgsetup/orgcheck')); + } + } + } + /** + * 合作机构申请公告模板设置显示 + */ + public function orggg() + { + $sys=self::get('orggg_options',-1); + $this->assign('sys',$sys); + return $this->fetch(); + } + + /** + * 合作机构申请公告模板设置保存 + */ + public function orgggrun() + { + if (!request()->isAjax()){ + $this->error('提交方式不正确',url('org/Orgsetup/orggg')); + }else{ + $options=input('post.options/a'); + $options['content_tpl']=htmlspecialchars_decode($options['content_tpl']); + $options['code']='orggg_options'; + $rst=self::update($options); + if($rst!==false){ + $this->success('合作机构申请公告模板设置保存成功',url('org/Orgsetup/orggg')); + }else{ + $this->error('提交参数不正确',url('org/Orgsetup/orggg')); + } + } + } + + /** + * 合作机构申请成功通知公告模板设置显示 + */ + public function orgsuccess() + { + $sys=self::get('orgsuccess_options',-1); + $this->assign('sys',$sys); + return $this->fetch(); + } + + /** + * 合作机构申请成功通知公告模板设置保存 + */ + public function orgsuccessrun() + { + if (!request()->isAjax()){ + $this->error('提交方式不正确',url('org/Orgsetup/orgsuccess')); + }else{ + $options=input('post.options/a'); + $options['content_tpl']=htmlspecialchars_decode($options['content_tpl']); + $options['code']='orgsuccess_options'; + $rst=self::update($options); + if($rst!==false){ + $this->success('合作机构申请成功通知公告模板设置保存成功',url('org/Orgsetup/orgsuccess')); + }else{ + $this->error('提交参数不正确',url('org/Orgsetup/orgsuccess')); + } + } + } + /** + * 合作机构申请牌匾模板设置显示 + */ + public function orgplaque() + { + $sys=self::get('orgplaque_options',-1); + $this->assign('sys',$sys); + return $this->fetch(); + } + + /** + * 合作机构申请牌匾模板设置保存 + */ + public function orgplaquerun() + { + if (!request()->isAjax()){ + $this->error('提交方式不正确',url('org/Orgsetup/orgplaque')); + }else{ + $options=input('post.options/a'); + $options['content_tpl']=htmlspecialchars_decode($options['content_tpl']); + $options['code']='orgplaque_options'; + $rst=self::update($options); + if($rst!==false){ + $this->success('合作机构申请成功通知公告模板设置保存成功',url('org/Orgsetup/orgplaque')); + }else{ + $this->error('提交参数不正确',url('org/Orgsetup/orgplaque')); + } + } + } + /** + * 合作机构模板设置显示 + */ + public function orginfo() + { + $sys=self::get('orginfo_options',-1); + $this->assign('sys',$sys); + return $this->fetch(); + } + + /** + * 合作机构模板设置保存 + */ + public function orginforun() + { + if (!request()->isAjax()){ + $this->error('提交方式不正确',url('org/Orgsetup/orginfo')); + }else{ + $options=input('post.options/a'); + $options['content_tpl']=htmlspecialchars_decode($options['content_tpl']); + $options['code']='orginfo_options'; + $rst=self::update($options); + if($rst!==false){ + $this->success('合作机构申请成功通知公告模板设置保存成功',url('org/Orgsetup/orginfo')); + }else{ + $this->error('提交参数不正确',url('org/Orgsetup/orginfo')); + } + } + } + /** + * 授权书模板设置 + */ + public function orgsq() + { + $sys=self::get('orgsq_options',-1); + $this->assign('sys',$sys); + return $this->fetch(); + } + + /** + * 授权书模板设置保存 + */ + public function orgsqrun() + { + if (!request()->isAjax()){ + $this->error('提交方式不正确',url('org/Orgsetup/orgsq')); + }else{ + $options=input('post.options/a'); + $options['content_tpl']=htmlspecialchars_decode($options['content_tpl']); + $options['code']='orgsq_options'; + $rst=self::update($options); + if($rst!==false){ + $this->success('授权书模板设置保存成功',url('org/Orgsetup/orgsq')); + }else{ + $this->error('提交参数不正确',url('org/Orgsetup/orgsq')); + } + } + } + + public static function get($type_code=-1,$id=-1){ + if($type_code!=-1 && $id!=-1){ + $temp = cache($type_code.'_'.$id); + if(empty($temp)){ + $where['code']=$type_code; + $where['id']=$id; + $temp = Db::name('org_temp')->where($where)->find(); + cache($type_code.'_'.$id,$temp); + } + }elseif ($type_code!=-1){ + $temp = cache($type_code.'_'); + if(empty($temp)){ + $where['code']=$type_code; + $temp = Db::name('org_temp')->where($where)->find(); + cache($type_code.'_',$temp); + } + } + return $temp; + } + + public static function update($setup){ + $setup['create_time']=time(); + $setup['create_id']=session('admin_auth.aid'); + if(!empty($setup)){ + if(empty($setup['id'])){ + $where['code']=$setup['code']; + $rst = Db::name('org_temp')->where($where)->update($setup); + if($rst){ + cache($setup['code'].'_',$setup); + } + }else{ + $where['code']=$setup['code']; + $where['id']=$setup['id']; + $rst = Db::name('org_temp')->where($where)->update($setup); + if($rst){ + cache($setup['code'].'_'.$setup['id'],$setup); + } + } + return $rst; + } + } +} \ No newline at end of file diff --git a/app/org/model/Orguptype.php b/app/org/model/Orguptype.php new file mode 100644 index 0000000..b0419fc --- /dev/null +++ b/app/org/model/Orguptype.php @@ -0,0 +1,90 @@ +where("ftype_id='$ftypeid'")->select(); + $filetypeInfo[$ftypeid]=$filetypeInfo?:array(); + return $filetypeInfo[$ftypeid]; + } + /** + * 上传文件类型表 + * @param array + * @param int $apply_id 查询条件(申请ID) + * @param int $type 查询条件(-1:$apply_id对应的临时和固定文件 1:固定 2:临时) + * @param int|array $status 查询条件(文件类型显示在哪个状态) + * @param int $isopen 查询条件(启用状态) + * @param string $order 结果排序 + * @return mixed + */ + public static function getList($apply_type,$apply_id,$type=-1,$status=-1,$isopen=1,$order='ftype_id,status,apply_id,isopen',$mustupload=1) + { + $where=array(); + + //根据状态值取出对应状态的数据0:所有 1:企业股权 2:实物资产 3:知识产权 4:其他权益 + if($apply_type!=-1)$where['apply_type']=array(array('eq',0),array('eq',$apply_type), 'or'); + if($mustupload!=-1)$where['mustupload']=$mustupload; + if($status != -1)$where['status'] = is_array($status)?array('in',$status):array('eq',$status); + if($isopen != -1)$where['isopen'] = array('eq',$isopen); + + if($status == -1) + return Db::name('org_uptype')->where($where)->order($order)->paginate(config('paginate.list_rows'),false,['query'=>get_query()]); + else + return Db::name('org_uptype')->where($where)->order($order)->select(); + } + + /** + * 合作机构申请上传文件类型 + * @param string + * @param string + * @param string + * @param string + * @param string + * @param int + * @param string + * @param int + * @return mixed + */ + public static function add($apply_type,$ftypedescr,$ftemp_id,$ftype,$status,$isopen,$apply_id,$user_id,$roletype,$roleid,$roletype2=0,$roleid2=0,$mustupload=1) + { + $sldata=array( + 'ftypedescr'=>$ftypedescr, + 'ftemp_id' => $ftemp_id, + 'apply_type' => $apply_type, + 'mustupload' => $mustupload, + 'ftype'=>$ftype, + 'status'=>$status, + 'isopen'=>$isopen, + 'apply_id'=>$apply_id, + 'user_id'=>$user_id, + 'create_time'=>time(), + 'upload_role_type'=>$roletype, + 'upload_role_id'=>$roleid, + 'upload_role_type2'=>$roletype2, + 'upload_role_id2'=>$roleid2, + ); + $uptype=Db::name('org_uptype')->insert($sldata); + if($uptype){ + return $uptype; + }else{ + return 0; + } + } +} \ No newline at end of file diff --git a/app/org/view/orgapply/apply_check.html b/app/org/view/orgapply/apply_check.html new file mode 100644 index 0000000..5446a35 --- /dev/null +++ b/app/org/view/orgapply/apply_check.html @@ -0,0 +1,1085 @@ +{extend name="admin@public/base" /} +{block name="main-content"} +
+ + + + + +

合作机构申请信息 - {$curr_step}

+
+
+
+ + + + + +
+
+
+

基本信息

+
+ + + +
+
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+
+ +
+
+

设置缴费金额

+
+ + + +
+
+
+
+
+
+ +
+ +
+ (万元) +
+
+
+ {if condition="$apply.status eq 1"} +
+
+   +
+
+ {/if} +
+
+
+
+
+
+ + {if condition="in_array($apply.status,[3,5,6,7,9])"} +
+
+

缴费确认信息

+
+ + + +
+
+
+
+
+
+
+
+ +
+ {if(!empty($apply_cw))} + + {else/} +
+ 无 +
+ {/if} +
+
+ {if(!empty($apply_jfpz))} +
+ +
+ 查看 +
+
+
+ {/if} + {if condition="$apply.status eq 3"} +
+ +
+ + + + + 请输入您的审核意见,并提交! +
+
+
+
+
+   +   +
+
+ {/if} + +
+
+
+
+
+
+ {/if} + + {if condition="in_array($apply.status,[5,6,7,9])"} +
+
+

初审信息

+
+ + + +
+
+
+
+
+
+
+
+ +
+ {if(!empty($apply_cs))} + + {else/} +
+ 无 +
+ {/if} +
+
+ {if(!empty($apply_uptypelist))} +
+ +
+
+
+
+ + + + + + + + + + + + + + + + + {foreach name="$apply_uptypelist" item="f1"} + {if condition="empty($f1.file)"} + + + + + + + + + {else} + + + + + + + + + + + + {/if} + {/foreach} + +
ID文件描述必须上传者类型上传者文件大小上传时间查看审核
{$f1.ftypedescr}{if condition="$f1.mustupload eq 1"}必须{else/}非必须{/if}未上传第一上传者:{:get_cult4RoleName($f1.upload_role_id,$f1.upload_role_type)}
第二上传者:{:get_cult4RoleName($f1.upload_role_id2,$f1.upload_role_type2)}
未审核
{$f1.file.file_id}{$f1.ftypedescr}{if condition="$f1.mustupload eq 1"}必须{else/}非必须{/if}{if condition="$f1.file.user_type eq 1"}前台会员{else/}后台员工{/if}{:get_cult4UserName($f1.file.user_id,$f1.file.user_type)}{$f1.file.filesize}{$f1.file.upload_time|date='Y-m-d H:i:s',###}查看 + {if condition="$f1.file.flag eq 1"} + {if condition="$apply.status eq 9"} +
+ {/if} + {if condition="$apply.status neq 9"} + +
+
+ {/if} + {else/} + +
+
+ {/if} +
+
+
+
+
+
+ {else/} +
+ +
+ 无上传文件 +
+
+ {/if} + {if condition="$apply.status eq 5"} +
+ +
+ + + + + 请输入您的初审意见,并提交! +
+
+
+
+
+   +   +
+
+ {/if} +
+
+
+
+
+
+ {/if} + + {if condition="in_array($apply.status,[6,7,9])"} +
+
+

风控信息

+
+ + + +
+
+
+
+
+
+
+
+ +
+ {if(!empty($apply_fk))} + + {else/} +
+ 无 +
+ {/if} +
+
+ {if condition="$apply.status eq 6"} +
+ +
+ + + + + 请输入您的审核意见,并提交! +
+
+
+
+
+   +   +
+
+ {/if} + +
+
+
+
+
+
+ {/if} + + {if condition="in_array($apply.status,[7,9])"} +
+
+

领导审核信息

+
+ + + +
+
+
+
+
+
+
+
+ +
+ {if(!empty($apply_ldsh))} + + {else/} +
+ 无 +
+ {/if} +
+
+ {if condition="$apply.status eq 7"} +
+ +
+ + + + + 请输入您的审核意见,并提交! +
+
+
+
+
+   +   +
+
+ {/if} + +
+
+
+
+
+
+ {/if} + + {if condition="in_array($apply.status,[9])"} +
+
+

企业信息确认

+
+ + + +
+
+
+
+
+
+ {if condition="$apply.status eq 9"} +
+ +
+ +
+
+
+
+ +
+ +
+
+
+
+ +
+ +
+
+
+
+ +
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+ +
+
+
+
+
+
+ +
+ +
+
+
+
+ +
+ +
+
+
+
+ +
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+ +
+
+
+
+
+
+ +
+ +
+ +
+
+
+
+
+   + +
+
+ {/if} + +
+
+
+
+
+
+ {/if} +
+
+
+
+
+{/block} +{block name="scripts"} + + + + +{/block} diff --git a/app/org/view/orgapply/apply_list.html b/app/org/view/orgapply/apply_list.html new file mode 100644 index 0000000..65e8fd7 --- /dev/null +++ b/app/org/view/orgapply/apply_list.html @@ -0,0 +1,119 @@ +{extend name="admin@public/base" /} +{block name="main-content"} +
+ + + +
+
+
+
+ + + + + + + + + + + + + + + + + + {foreach name="apply_list" item="v"} + + + + + + + + + + + + {/foreach} + + + + +
ID申请用户名用户状态机构类别机构名称处理状态申请日期操作处理号
{$v.id}{$v.uid,1|get_cult4UserName}{if condition="get_cult4UserStatus($v.uid,1) eq 1"}正常{else/}锁定{/if}{if condition="$v.org_type eq 'whjrfwzx'"/}文化金服服务中心 + {elseif condition="$v.org_type eq 'zbzq'"/}专板(专区) + {elseif condition="$v.org_type eq 'ssyyzx'"/}省(市)运营中心 + {elseif condition="$v.org_type eq 'tjjg'"/}推荐机构 + {elseif condition="$v.org_type eq 'zcfwjg'"/}驻场服务机构{/if} + {if condition="$v.org_name eq 1"/}省级文化金服服务中心 + {elseif condition="$v.org_name eq 2"/}市级文化金融服务中心 + {elseif condition="$v.org_name eq 3"/}(行业)专板 + {elseif condition="$v.org_name eq 4"/}(行业)专区 + {elseif condition="$v.org_name eq 5"/}省级运营中心 + {elseif condition="$v.org_name eq 6"/}市级运营中心 + {elseif condition="$v.org_name eq 7"/}推荐机构 + {elseif condition="$v.org_name eq 8"/}驻场服务机构全国 + {elseif condition="$v.org_name eq 9"/}驻场服务机构区域{/if}{$v.descr}{$v.create_time|date='Y-m-d H:i:s',###} + +
{$page}
+
+
+
+
+ + + +
+{/block} diff --git a/app/org/view/orgapply/uptype_add.html b/app/org/view/orgapply/uptype_add.html new file mode 100644 index 0000000..d9860f9 --- /dev/null +++ b/app/org/view/orgapply/uptype_add.html @@ -0,0 +1,186 @@ +{extend name="admin@public/base" /} +{block name="main-content"} +
+ + + + + + + +
+
+
+ + +
+ +
+ +
+
+
+
+ +
+ + *请选择该固定文件对应的合作机构类型 +
+
+
+
+ +
+ + *请选择项目持有人 +
+
+
+ + +
+ +
+ + *请输入文件类型描述 +
+
+
+ +
+ +
+ +
+
+
+ +
+ +
+ + *选择可接受的文件类型 +
+
+
+ +
+ +
+ {if condition="$status egt 0"}{/if} + + {foreach name="statuslist" item="v" key="i"} + + {/foreach} + +
+
+
+
+ +
+ + + *请选择资料上传者 +
+
+
+
+ +
+ + +
+
+
+
+ +
+ +  默认关闭 +
+
+
+ +
+
+ + + + + + +
+
+
+
+
+ +
+{/block} +{block name="scripts"} + +{/block} \ No newline at end of file diff --git a/app/org/view/orgapply/uptype_edit.html b/app/org/view/orgapply/uptype_edit.html new file mode 100644 index 0000000..79a6b3e --- /dev/null +++ b/app/org/view/orgapply/uptype_edit.html @@ -0,0 +1,182 @@ +{extend name="admin@public/base" /} +{block name="main-content"} +
+ + + + + + + +
+
+
+ + +
+ +
+ +
+
+
+
+ +
+ + *请选择该固定文件对应的合作机构类型 +
+
+
+
+ +
+ + * +
+
+
+ +
+ +
+ + *请输入文件类型描述 +
+
+
+ +
+ +
+ + {if(empty($upfile))}{else/}查看原始上传文件{/if} +
+
+
+ +
+ +
+ + *选择可接受的文件类型 +
+
+
+ +
+ +
+ {if condition="$uptype.status egt 0"}{/if} + + {foreach name="statuslist" item="v" key="i"} + + {/foreach} + +
+
+
+
+ +
+ + + *请选择资料上传者 +
+
+
+
+ +
+ + +
+
+
+
+ +
+ +  默认关闭 +
+
+
+ +
+
+ + + + + + +
+
+
+
+
+ +
+{/block} +{block name="scripts"} + +{/block} \ No newline at end of file diff --git a/app/org/view/orgapply/uptype_list.html b/app/org/view/orgapply/uptype_list.html new file mode 100644 index 0000000..929a992 --- /dev/null +++ b/app/org/view/orgapply/uptype_list.html @@ -0,0 +1,115 @@ +{extend name="admin@public/base" /} +{block name="main-content"} +
+ + + +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + {foreach name="uptype_list" item="v"} + + + + + + + + + + + + + + + + + + {/foreach} + + + + +
ID文件描述文件类型文件模板机构类型接受文件类型上传状态启用状态申请ID操作员上传者辅助上传者操作日期必须项目操作
{$v.ftype_id}{$v.ftypedescr}{if condition="$v.apply_id eq 0"}固定{else/}临时{/if}{if condition="get_OrgPathFromFileID($v.ftemp_id) eq '未上传'"}未上传{else/}查看{/if}{if condition="$v.apply_type eq 0"}所有 + {elseif condition="$v.apply_type eq 1"}省级文化金服服务中心 + {elseif condition="$v.apply_type eq 2"}市级文化金融服务中心 + {elseif condition="$v.apply_type eq 3"}(行业)专板 + {elseif condition="$v.apply_type eq 4"}(行业)专区 + {elseif condition="$v.apply_type eq 5"}省级运营中心 + {elseif condition="$v.apply_type eq 6"}市级运营中心 + {elseif condition="$v.apply_type eq 7"}推荐机构 + {elseif condition="$v.apply_type eq 8"}驻场服务机构全国 + {elseif condition="$v.apply_type eq 9"}驻场服务机构区域{/if} + {$v.ftype}{$v.status|get_OrgStatus} + {if condition="$v['isopen'] eq 1"} + +
+
+ {else/} + +
+
+ {/if} +
{if condition="$v.apply_id eq 0"}无{else/}{$v.apply_id}{/if}{$v.user_id|get_cult4UserName=###,2}{$v.upload_role_id,$v.upload_role_type|get_cult4RoleName}{$v.upload_role_id2,$v.upload_role_type2|get_cult4RoleName}{$v.create_time|date='Y-m-d H:i:s',###}{if condition="$v.mustupload eq 1"}必须{else/}非必须{/if} + + +
{$page}
+
+
+
+ + + +
+{/block} diff --git a/app/org/view/orgsetup/orgagree.html b/app/org/view/orgsetup/orgagree.html new file mode 100644 index 0000000..f14935b --- /dev/null +++ b/app/org/view/orgsetup/orgagree.html @@ -0,0 +1,53 @@ +{extend name="admin@public/base" /} +{block name="main-content"} +
+ + + + + +
+
+
+ +
+ +
+ + + + + +
+
+
+
+
+ + +       + +
+
+
+
+
+
+{/block} \ No newline at end of file diff --git a/app/org/view/orgsetup/orgagree_list.html b/app/org/view/orgsetup/orgagree_list.html new file mode 100644 index 0000000..0a861f0 --- /dev/null +++ b/app/org/view/orgsetup/orgagree_list.html @@ -0,0 +1,40 @@ +{extend name="admin@public/base" /} +{block name="main-content"} +
+
+
+
+
+ + + + + + + + + + + + {foreach name="$list" item="v"} + + + + + + {/foreach} + +
合作机构名称发布日期操作
{$v.name}{$v.create_time|date='Y-m-d H:i:s',###} + + + +
+
+
+
+
+ + + +
+{/block} diff --git a/app/org/view/orgsetup/orgcheck.html b/app/org/view/orgsetup/orgcheck.html new file mode 100644 index 0000000..5fcab37 --- /dev/null +++ b/app/org/view/orgsetup/orgcheck.html @@ -0,0 +1,53 @@ +{extend name="admin@public/base" /} +{block name="main-content"} +
+ + + + + +
+
+
+ +
+ +
+ + + + + +
+
+
+
+
+ + +       + +
+
+
+
+
+
+{/block} \ No newline at end of file diff --git a/app/org/view/orgsetup/orgfee.html b/app/org/view/orgsetup/orgfee.html new file mode 100644 index 0000000..cd678d2 --- /dev/null +++ b/app/org/view/orgsetup/orgfee.html @@ -0,0 +1,53 @@ +{extend name="admin@public/base" /} +{block name="main-content"} +
+ + + + + +
+
+
+ +
+ +
+ + + + + +
+
+
+
+
+ + +       + +
+
+
+
+
+
+{/block} \ No newline at end of file diff --git a/app/org/view/orgsetup/orgfee_list.html b/app/org/view/orgsetup/orgfee_list.html new file mode 100644 index 0000000..8e592d5 --- /dev/null +++ b/app/org/view/orgsetup/orgfee_list.html @@ -0,0 +1,40 @@ +{extend name="admin@public/base" /} +{block name="main-content"} +
+
+
+
+
+ + + + + + + + + + + + {foreach name="$list" item="v"} + + + + + + {/foreach} + +
合作机构名称发布日期操作
{$v.name}{$v.create_time|date='Y-m-d H:i:s',###} + + + +
+
+
+
+
+ + + +
+{/block} diff --git a/app/org/view/orgsetup/orggg.html b/app/org/view/orgsetup/orggg.html new file mode 100644 index 0000000..d635009 --- /dev/null +++ b/app/org/view/orgsetup/orggg.html @@ -0,0 +1,53 @@ +{extend name="admin@public/base" /} +{block name="main-content"} +
+ + + + + +
+
+
+ +
+ +
+ + + + + +
+
+
+
+
+ + +       + +
+
+
+
+
+
+{/block} \ No newline at end of file diff --git a/app/org/view/orgsetup/orginfo.html b/app/org/view/orgsetup/orginfo.html new file mode 100644 index 0000000..51a8bb5 --- /dev/null +++ b/app/org/view/orgsetup/orginfo.html @@ -0,0 +1,53 @@ +{extend name="admin@public/base" /} +{block name="main-content"} +
+ + + + + +
+
+
+ +
+ +
+ + + + + +
+
+
+
+
+ + +       + +
+
+
+
+
+
+{/block} \ No newline at end of file diff --git a/app/org/view/orgsetup/orgplaque.html b/app/org/view/orgsetup/orgplaque.html new file mode 100644 index 0000000..1358c84 --- /dev/null +++ b/app/org/view/orgsetup/orgplaque.html @@ -0,0 +1,53 @@ +{extend name="admin@public/base" /} +{block name="main-content"} +
+ + + + + +
+
+
+ +
+ +
+ + + + + +
+
+
+
+
+ + +       + +
+
+
+
+
+
+{/block} \ No newline at end of file diff --git a/app/org/view/orgsetup/orgsq.html b/app/org/view/orgsetup/orgsq.html new file mode 100644 index 0000000..f2020fb --- /dev/null +++ b/app/org/view/orgsetup/orgsq.html @@ -0,0 +1,53 @@ +{extend name="admin@public/base" /} +{block name="main-content"} +
+ + + + + +
+
+
+ +
+ +
+ + + + + +
+
+
+
+
+ + +       + +
+
+
+
+
+
+{/block} \ No newline at end of file diff --git a/app/org/view/orgsetup/orgsuccess.html b/app/org/view/orgsetup/orgsuccess.html new file mode 100644 index 0000000..5431dfb --- /dev/null +++ b/app/org/view/orgsetup/orgsuccess.html @@ -0,0 +1,53 @@ +{extend name="admin@public/base" /} +{block name="main-content"} +
+ + + + + +
+
+
+ +
+ +
+ + + + + +
+
+
+
+
+ + +       + +
+
+
+
+
+
+{/block} \ No newline at end of file diff --git a/app/route.php b/app/route.php new file mode 100644 index 0000000..dab30e2 --- /dev/null +++ b/app/route.php @@ -0,0 +1,17 @@ + +// +---------------------------------------------------------------------- + +//调用extend的路由类 +$Route = new \Route; +$Route->route_rule(); +return [ + //也可以这里添加路由规则 +]; \ No newline at end of file diff --git a/app/tags.php b/app/tags.php new file mode 100644 index 0000000..4e20aad --- /dev/null +++ b/app/tags.php @@ -0,0 +1,25 @@ + + array ( + ), + 'app_begin' => + array ( + ), + 'module_init' => + array ( + 0 => 'app\\common\\behavior\\WebLog', + ), + 'action_begin' => + array ( + ), + 'view_filter' => + array ( + ), + 'log_write' => + array ( + ), + 'app_end' => + array ( + 0 => 'app\\admin\\behavior\\Cron', + ), +); \ No newline at end of file diff --git a/app/tuoguan/controller/Tgsetup.php b/app/tuoguan/controller/Tgsetup.php new file mode 100644 index 0000000..73e171f --- /dev/null +++ b/app/tuoguan/controller/Tgsetup.php @@ -0,0 +1,256 @@ +lang); + $this->assign('sys',$sys); + return $this->fetch(); + } + + /** + * 托管缴费通知模板设置保存 + */ + public function tgfeerun() + { + if (!request()->isAjax()){ + $this->error('提交方式不正确',url('tuoguan/Tgsetup/tgfee')); + }else{ + $options=input('post.options/a'); + $options['content_tpl']=htmlspecialchars_decode($options['content_tpl']); + $rst=Options::set_options($options,'tgfee_options',$this->lang); + if($rst!==false){ + cache("tgfee_options_".$this->lang,null); + $this->success('托管缴费通知模板设置保存成功',url('tuoguan/Tgsetup/tgfee')); + }else{ + $this->error('提交参数不正确',url('tuoguan/Tgsetup/tgfee')); + } + } + } + + /** + * 托管初审通知模板设置显示 + */ + public function tgcheck() + { + $sys=Options::get_options('tgcheck_options',$this->lang); + $this->assign('sys',$sys); + return $this->fetch(); + } + + /** + * 托管初审通知模板设置保存 + */ + public function tgcheckrun() + { + if (!request()->isAjax()){ + $this->error('提交方式不正确',url('tuoguan/Tgsetup/tgcheck')); + }else{ + $options=input('post.options/a'); + $options['content_tpl']=htmlspecialchars_decode($options['content_tpl']); + $rst=Options::set_options($options,'tgcheck_options',$this->lang); + if($rst!==false){ + cache("tgcheck_options_".$this->lang,null); + $this->success('托管初审通知模板设置保存成功',url('tuoguan/Tgsetup/tgcheck')); + }else{ + $this->error('提交参数不正确',url('tuoguan/Tgsetup/tgcheck')); + } + } + } + /** + * 托管风控审核通知模板设置显示 + */ + public function tgcheckfk() + { + $sys=Options::get_options('tgcheckfk_options',$this->lang); + $this->assign('sys',$sys); + return $this->fetch(); + } + + /** + * 托管风控审核通知模板设置保存 + */ + public function tgcheckfkrun() + { + if (!request()->isAjax()){ + $this->error('提交方式不正确',url('tuoguan/Tgsetup/tgcheckfk')); + }else{ + $options=input('post.options/a'); + $options['content_tpl']=htmlspecialchars_decode($options['content_tpl']); + $rst=Options::set_options($options,'tgcheckfk_options',$this->lang); + if($rst!==false){ + cache("tgcheckfk_options_".$this->lang,null); + $this->success('托管风控审核通知模板设置保存成功',url('tuoguan/Tgsetup/tgcheckfk')); + }else{ + $this->error('提交参数不正确',url('tuoguan/Tgsetup/tgcheckfk')); + } + } + } + + /** + * 托管公告通知模板设置显示 + */ + public function tgsuccessgg() + { + $sys=Options::get_options('tgsuccess_options',$this->lang); + $this->assign('sys',$sys); + return $this->fetch(); + } + + /** + * 托管公告通知模板设置保存 + */ + public function tgsuccessggrun() + { + if (!request()->isAjax()){ + $this->error('提交方式不正确',url('tuoguan/Tgsetup/tgsuccessgg')); + }else{ + $options=input('post.options/a'); + $options['content_tpl']=htmlspecialchars_decode($options['content_tpl']); + $rst=Options::set_options($options,'tgsuccess_options',$this->lang); + if($rst!==false){ + cache("tgsuccess_options_".$this->lang,null); + $this->success('托管公告模板设置保存成功',url('tuoguan/Tgsetup/tgsuccessgg')); + }else{ + $this->error('提交参数不正确',url('tuoguan/Tgsetup/tgsuccessgg')); + } + } + } + /** + * 托管公告通知模板设置显示 + */ + public function tgagree() + { + $sys=Options::get_options('tgagree_options',$this->lang); + $this->assign('sys',$sys); + return $this->fetch(); + } + + /** + * 托管公告通知模板设置保存 + */ + public function tgagreerun() + { + if (!request()->isAjax()){ + $this->error('提交方式不正确',url('tuoguan/Tgsetup/tgagree')); + }else{ + $options=input('post.options/a'); + $options['content_tpl']=htmlspecialchars_decode($options['content_tpl']); + $rst=Options::set_options($options,'tgagree_options',$this->lang); + if($rst!==false){ + cache("tgagree_options_".$this->lang,null); + $this->success('托管公告模板设置保存成功',url('tuoguan/Tgsetup/tgagree')); + }else{ + $this->error('提交参数不正确',url('tuoguan/Tgsetup/tgagree')); + } + } + } + /** + * 托管通知书模板设置显示 + */ + public function tgnotice() + { + $sys=Options::get_options('tgnotice_options',$this->lang); + $this->assign('sys',$sys); + return $this->fetch(); + } + + /** + * 托管通知书模板设置保存 + */ + public function tgnoticerun() + { + if (!request()->isAjax()){ + $this->error('提交方式不正确',url('tuoguan/Tgsetup/tgnotice')); + }else{ + $options=input('post.options/a'); + $options['content_tpl']=htmlspecialchars_decode($options['content_tpl']); + $rst=Options::set_options($options,'tgnotice_options',$this->lang); + if($rst!==false){ + cache("tgnotice_options_".$this->lang,null); + $this->success('托管通知书模板设置保存成功',url('tuoguan/Tgsetup/tgnotice')); + }else{ + $this->error('提交参数不正确',url('tuoguan/Tgsetup/tgnotice')); + } + } + } + + /** + * 资产通知书模板(用户通知书) + */ + public function zc_notice() + { + $sys=Options::get_options('zc_notice',$this->lang); + $this->assign('sys',$sys); + return $this->fetch(); + } + + /** + * 资产通知书模板保存(用户通知书) + */ + public function zc_noticerun() + { + if (!request()->isAjax()){ + $this->error('提交方式不正确',url('tuoguan/Tgsetup/zc_notice')); + }else{ + $options=input('post.options/a'); + $options['content_tpl']=htmlspecialchars_decode($options['content_tpl']); + $rst=Options::set_options($options,'zc_notice',$this->lang); + if($rst!==false){ + cache("zc_notice_".$this->lang,null); + $this->success('模板设置保存成功',url('tuoguan/Tgsetup/zc_notice')); + }else{ + $this->error('提交参数不正确',url('tuoguan/Tgsetup/zc_notice')); + } + } + } + /** + * 资产成功公告模板(官网公告) + */ + public function zc_successgg() + { + $sys=Options::get_options('zc_successgg',$this->lang); + $this->assign('sys',$sys); + return $this->fetch(); + } + + /** + * 资产成功公告模板保存(官网公告) + */ + public function zc_successggrun() + { + if (!request()->isAjax()){ + $this->error('提交方式不正确',url('tuoguan/Tgsetup/zc_successgg')); + }else{ + $options=input('post.options/a'); + $options['content_tpl']=htmlspecialchars_decode($options['content_tpl']); + $rst=Options::set_options($options,'zc_successgg',$this->lang); + if($rst!==false){ + cache("zc_successgg_".$this->lang,null); + $this->success('模板设置保存成功',url('tuoguan/Tgsetup/zc_successgg')); + }else{ + $this->error('提交参数不正确',url('tuoguan/Tgsetup/zc_successgg')); + } + } + } + + +} \ No newline at end of file diff --git a/app/tuoguan/controller/Trusteeship.php b/app/tuoguan/controller/Trusteeship.php new file mode 100644 index 0000000..ba5d974 --- /dev/null +++ b/app/tuoguan/controller/Trusteeship.php @@ -0,0 +1,772 @@ +error('无权限',url('admin/Index/index')); + } + } + $whereType=array( + 'apply_id'=>$apply_id, + 'new_flag'=>1, + ); + if($status==-1){ + //固定类型input('apply_id')==null + $uptype_list=UptypeModel::getList(-1,$apply_id,$ftype,$status,-1,'status,apply_type,ftype_id',-1); + $page = $uptype_list->render(); + $this->assign('uptype_list',$uptype_list); + $this->assign('page',$page); + }else{ + //临时类型 + $uptype_list=UptypeModel::getList(-1,$apply_id,$ftype,$status,-1); + $this->assign('uptype_list',$uptype_list); + + $this->assign('apply_id',$apply_id); + $this->assign('status',$status); + } + return $this->fetch(); + } + + /** + * 托管文件类型添加 + */ + public function uptype_add($process=-1,$status=-1) + { + if ($process > 0 and $status > 0) { + //权限检查 + if (check_cult4UserRight(input('apply_id'), session('admin_auth.aid'), $status) == 0) { + $this->error('无权限',url('admin/Index/index')); + } + } + //创建token + creatToken(); + + $apply_id=input('apply_id'); + $this->assign('apply_id',$apply_id); + $this->assign('status',$status); + $where['status'] = array('egt',0); + $statuslist=Db::name('trusteeship_status')->where($where)->select(); + $this->assign('statuslist',$statuslist); + + return $this->fetch(); + } + /** + * 文化四板固定文件类型修改 + */ + public function uptype_edit(){ + if(!request()->isAjax()) { + //创建token + creatToken(); + + $ftype_id = input('ftype_id', 0, 'intval'); + if (!$ftype_id) $this->error('参数错误', url('tuoguan/Trusteeship/uptype_list')); + $uptype = Db::name('trusteeship_uptype')->where('ftype_id', $ftype_id)->find(); + $this->assign('uptype', $uptype); + if(!empty($uptype['ftemp_id'])){ + $upfile = Db::name('trusteeship_upfiles')->where('file_id', $uptype['ftemp_id'])->find(); + $this->assign('upfile', $upfile); + } + $where['status'] = array('egt',0); + $statuslist=Db::name('trusteeship_status')->where($where)->select(); + $this->assign('statuslist',$statuslist); + + $list1=array(); + if($uptype['upload_role_type']==1){ + $map1['member_group_id']=array(array('gt',0),array('neq',2));//>0 and !=2 + $list1=Db::name("member_group")->field(array('member_group_id'=>'id','member_group_name'=>'name'))->where($map1)->select(); + }elseif($uptype['upload_role_type']==2){ + $map2['id']=array('gt',0); + $list1=Db::name("auth_group")->field(array('id'=>'id','title'=>'name'))->where($map2)->select(); + } + $this->assign('list1',$list1); + $list2=array(); + if($uptype['upload_role_type2']==1){ + $map1['member_group_id']=array(array('gt',0),array('neq',2));//>0 and !=2 + $list2=Db::name("member_group")->field(array('member_group_id'=>'id','member_group_name'=>'name'))->where($map1)->select(); + }elseif($uptype['upload_role_type2']==2){ + $map2['id']=array('gt',0); + $list2=Db::name("auth_group")->field(array('id'=>'id','title'=>'name'))->where($map2)->select(); + } + $this->assign('list2',$list2); + return $this->fetch(); + }else{ + $roletype=input('roletype'); + $roleid=input('roletitle'); + $roletype2=input('roletype2'); + $roleid2=input('roletitle2'); + if($roletype<=0 or $roleid<=0) + { + $this->error('请选择资料上传类型及对应的角色!'); + } + if(empty($roletype2))$roletype2=0; + if(empty($roleid2))$roleid2=0; + if(!(($roletype2==0 and $roleid2==0) or ($roletype2>0 and $roleid2>0) or ($roletype2<=0 and $roleid2<=0))) + { + $this->error('请选择资料辅助上传类型及对应的角色!'); + } + //防止重复提交 + if (!checkToken(input('TOKEN'))) { + return; + } + + //固定 + $apply_id = 0; + $apply_type=input('apply_type'); + $isgp=input('isgp'); + $mustupload=input('mustupload'); + + //上传模板部分 + $file_id=0; + //支持多个字段单文件 + $file = request()->file('file_one'); + $file_one=''; + + if(!empty($file)){ + $validate = config('upload_validate'); + unset($validate['ext']);//不限制后缀 + //单图 + $info = $file->validate($validate)->rule('uniqid')->move(ROOT_PATH . config('upload_path') . DS . date('Y-m-d')); + + if ($info) { + $file_url = config('upload_path'). '/' . date('Y-m-d') . '/' . $info->getFilename(); + //写入数据库 + $data['apply_id'] = 0;//模板文件未使用该字段 + $data['user_id'] = session('admin_auth.aid'); + $data['user_type'] = 2; + $data['status'] = input('status'); + $data['upload_time'] = time(); + $data['ftype_id'] = 0;//模板文件为0 + $data['ftype'] = 3;//模板类型 + $data['filesize'] = $info->getSize(); + $data['path'] = $file_url; + $data['addorder'] = 0;//固定文件需要更新 + $data['new_flag'] = 1;//固定文件需要更新 + + $file_id = Db::name('trusteeship_upfiles')->insert($data,false,true); + + } else { + $this->error($file->getError());//否则就是上传错误,显示错误原因 + } + }else{ + $file_id = input('ftemp_id'); + $data['file_id'] = $file_id;//模板文件未使用该字段 + $data['status'] = input('status'); + Db::name('trusteeship_upfiles')->where('file_id',$file_id)->update($data); + } + $sl_data=array( + 'ftype_id'=>input('ftype_id'), + 'ftypedescr'=>input('ftypedescr'), + 'ftemp_id' => $file_id, + 'apply_type' => $apply_type, + 'isgp' => $isgp, + 'mustupload' => $mustupload, + 'ftype'=>input('ftype'), + 'status'=>input('status'), + 'isopen'=>input('isopen',0), + 'apply_id'=>$apply_id, + 'user_id'=>session('admin_auth.aid'), + 'create_time'=>time(), + 'upload_role_type'=>$roletype, + 'upload_role_id'=>$roleid, + 'upload_role_type2'=>$roletype2, + 'upload_role_id2'=>$roleid2, + ); + $uptype_id=Db::name('trusteeship_uptype')->where('ftype_id',input('ftype_id'))->update($sl_data); + if($uptype_id){ + $this->success('文件类型修改成功',url('tuoguan/Trusteeship/uptype_list')); + }else{ + $this->error('文件类型修改失败'); + } + } + } + /** + * 托管文件类型添加操作 + */ + public function uptype_runadd($process=-1,$status=-1) + { + //添加固定内容 + if (!($process == -1 or $status ==-1)) { + //权限检查 + if (check_cult4UserRight(input('apply_id'), session('admin_auth.aid'), $status) == 0) { + $this->error('无权限',url('admin/Index/index')); + } + } + + $roletype=input('roletype'); + $roleid=input('roletitle'); + $roletype2=input('roletype2'); + $roleid2=input('roletitle2'); + if($roletype<=0 or $roleid<=0) + { + $this->error('请选择资料上传类型及对应的角色!'); + } + if(empty($roletype2))$roletype2=0; + if(empty($roleid2))$roleid2=0; + if(!(($roletype2==0 and $roleid2==0) or ($roletype2>0 and $roleid2>0) or ($roletype2<=0 and $roleid2<=0))) + { + $this->error('请选择资料辅助上传类型及对应的角色!'); + } + //防止重复提交 + if (!checkToken(input('TOKEN'))) { + //return; + } + + //状态为-1时对应固定文件 + $apply_id=input('apply_id'); + $whereType=array( + 'apply_id'=>$apply_id, + 'new_flag'=>1, + ); + $mustupload=1; + if($process==-1){ + $apply_id = 0; + $apply_type=input('apply_type'); + $isgp=input('isgp'); + $mustupload=input('mustupload'); + } + + //上传模板部分 + $file_id=0; + //支持多个字段单文件 + $file = request()->file('file_one'); + $file_one=''; + + if(!empty($file)){ + $validate = config('upload_validate'); + unset($validate['ext']);//不限制后缀 + //单图 + $info = $file->validate($validate)->rule('uniqid')->move(ROOT_PATH . config('upload_path') . DS . date('Y-m-d')); + + if ($info) { + $file_url = config('upload_path'). '/' . date('Y-m-d') . '/' . $info->getFilename(); + //写入数据库 + $data['apply_id'] = 0;//模板文件未使用该字段 + $data['user_id'] = session('admin_auth.aid'); + $data['user_type'] = 2; + $data['status'] = $status; + $data['upload_time'] = time(); + $data['ftype_id'] = 0;//模板文件为0 + $data['ftype'] = 3;//模板类型 + $data['filesize'] = $info->getSize(); + $data['path'] = $file_url; + $data['addorder'] = 0;//固定文件需要更新 + $data['new_flag'] = 1;//固定文件需要更新 + + $file_id = Db::name('trusteeship_upfiles')->insert($data,false,true); + + } else { + $this->error($file->getError());//否则就是上传错误,显示错误原因 + } + } + if ($process == -1 or $status ==-1) { + $uptype_id=UptypeModel::add($apply_type,$isgp,input('ftypedescr'),$file_id,input('ftype'),input('status'),input('isopen',0),0,session('admin_auth.aid'),$roletype,$roleid,$roletype2,$roleid2,$mustupload); + if($uptype_id){ + $this->success('文件类型添加成功',url('tuoguan/Trusteeship/uptype_list')); + }else{ + $this->error('文件类型添加失败'); + } + }else{ + $uptype_id=UptypeModel::add($apply_type,$isgp,input('ftypedescr'),$file_id,input('ftype'),$status,input('isopen',0),$apply_id,session('admin_auth.aid'),$roletype,$roleid,$roletype2,$roleid2); + if($uptype_id){ + $sl_data2['apply_id']=input('apply_id'); + $sl_data2['status']=$status; + $this->success('文件类型添加成功',url('tuoguan/Trusteeship/uptype_list'.$process,$sl_data2)); + }else{ + $this->error('文件类型添加失败'); + } + } + } + + /** + * 托管文件类型列表开启/禁止 + */ + public function uptype_state($process=-1,$status=-1) + { + $id=input('x'); + if (empty($id)){ + //如果不是固定添加类型 + if (!($process == -1 or $status ==-1)) { + $this->error('文件ID不存在', url('tuoguan/trusteeship/uptype_list' . $process)); + }else{ + $this->error('文件ID不存在', url('tuoguan/trusteeship/uptype_list')); + } + } + + //取得apply_id + $tempfile = UptypeModel::getFileTypeInfo($id); + if(empty($tempfile)){ + $this->error('无权限',url('admin/Index/index')); + } + + $isopen=Db::name('trusteeship_uptype')->where('ftype_id',$id)->value('isopen');//判断当前状态情况 + if($isopen==1){ + $statedata = array('isopen'=>0); + Db::name('trusteeship_uptype')->where('ftype_id',$id)->setField($statedata); + $this->success('状态禁止'); + }else{ + $statedata = array('isopen'=>1); + Db::name('trusteeship_uptype')->where('ftype_id',$id)->setField($statedata); + $this->success('状态开启'); + } + } + + /** + * 审核列表 + * + * @param int $applystatus 查询单个状态 + * @param int $allstatus 查询全部状态标识 + * @return fetch + * + */ + public function apply_list($applystatus=-1,$allstatus=-1){ + $admin_id = session('admin_auth.aid'); + $search_name=input('search_name'); + $apply_list=ApplyModel::getList($search_name,$applystatus,$admin_id,'tg_time desc,tg_id desc',$allstatus); + $page = $apply_list->render(); + $this->assign('apply_list',$apply_list); + $this->assign('page',$page); + $this->assign('search_name',$search_name); + $this->assign('applystatus',$applystatus); + $this->assign('allstatus',$allstatus); + $this->assign('loginuser',session('admin_auth.aid')); + return $this->fetch(); + } + /** + * 托管列表 + */ + public function tg_list(){ + $applystatus=11; + $search_name=input('search_name'); + $apply_list=ApplyModel::getList($search_name,$applystatus,'','tg_time desc,tg_id desc',-1); + $page = $apply_list->render(); + $this->assign('apply_list',$apply_list); + $this->assign('page',$page); + $this->assign('search_name',$search_name); + return $this->fetch(); + } + /** + * 受理操作 + */ + public function apply_applyed($tg_status) + { + if(session('admin_auth.aid')){ + $apply = ApplyModel::applyed(input('tg_id'),session('admin_auth.aid'),$tg_status); + + if($apply==0){ + $this->error('数据已更新,请重试!'); + } else { + $this->success('已受理',url('tuoguan/Trusteeship/apply_check',array('tg_id'=>input('tg_id'),'applystatus'=>$tg_status))); + } + } + else + { + $this->error('用户ID不存在'); + } + } + + /* + * 审核用户信息界面 + */ + public function apply_check(){ + //创建token + creatToken(); + $apply_id=input('tg_id'); + $applystatus=input('applystatus'); + $user_id=session('admin_auth.aid'); + $this->assign('user_id',$user_id); + //托管申请信息 + $tgapply = Db::name('trusteeship_apply')->where('tg_id',$apply_id)->find(); + $where['apply_type']=array('in','0,'.$tgapply['tg_type']); + $where['status']=0; + $where['isopen']=1; + if($tgapply['tg_type']==1){ + $where['isgp']=array('in',$tgapply['tg_isgp'].',0'); + } + + //上传文件列表 + $apply_uptypelist = Db::name('trusteeship_uptype')->where($where)->select(); + for ($x=0; $xwhere($filewhere)->order('upload_time desc')->find(); + $apply_uptypelist[$x]['file']=$file; + } + //尽职调查历史 + if($tgapply['tg_status']==12){ + $curr_step='尽职调查';//当前步骤 + } + $apply_jzdc = Db::name('trusteeship_checkdd')->where('apply_id',$apply_id)->order('create_time desc')->select(); + $this->assign('apply_jzdc',$apply_jzdc); + $jzdc_files = Db::name('trusteeship_upfiles')->where(['apply_id'=>$tgapply['tg_id'],'status'=>12])->order('upload_time desc')->select(); + $this->assign('jzdc_files',$jzdc_files); + //查询尽职调查模板 + $temp_files = Db::name('trusteeship_upfiles')->alias("f")->join(config('database.prefix').'trusteeship_uptype t','t.ftemp_id=f.file_id') + ->where(['t.isopen'=>'1','t.status'=>12,'ftypedescr'=>'尽职调查表'])->where('t.apply_type','in',['0',$tgapply['tg_type']])->order('upload_time desc')->select(); + if(!empty($temp_files)){ + $this->assign('temp_files',$temp_files[0]); + } + //初审信息历史 + if($tgapply['tg_status']==1){ + $curr_step='初审';//当前步骤 + } + $apply_cs = Db::name('trusteeship_cs')->where('apply_id',$apply_id)->order('create_time desc')->select(); + $this->assign('apply_cs',$apply_cs); + //风控审核信息历史 + if($tgapply['tg_status']==2){ + $curr_step='风控';//当前步骤 + } + $apply_fk = Db::name('trusteeship_fk')->where('apply_id',$apply_id)->order('create_time desc')->select(); + $this->assign('apply_fk',$apply_fk); + //客户上传缴费凭证历史 + $apply_jfpz = Db::name('trusteeship_upfiles')->where(['apply_id'=>$tgapply['tg_id'],'status'=>3])->order('upload_time desc')->find(); + $this->assign('apply_jfpz',$apply_jfpz); + //缴费确认历史 + if($tgapply['tg_status']==4){ + $curr_step='缴费确认';//当前步骤 + } + $apply_cw = Db::name('trusteeship_cw')->where('apply_id',$apply_id)->order('create_time desc')->select(); + $this->assign('apply_cw',$apply_cw); + //专家评分历史 + if($tgapply['tg_status']==5){ + $curr_step='专家评分';//当前步骤 + } + $apply_zjpf = Db::name('trusteeship_zjpf')->where('apply_id',$apply_id)->order('create_time desc')->find(); + $this->assign('apply_zjpf',$apply_zjpf); + //联席会审核历史 + if($tgapply['tg_status']==6){ + $curr_step='联席会';//当前步骤 + } + $apply_lxh = Db::name('trusteeship_lxh')->where('apply_id',$apply_id)->order('create_time desc')->select(); + //查联席会决议模板 + $lxhjy_tmep = Db::name('trusteeship_upfiles')->alias("f")->join(config('database.prefix').'trusteeship_uptype t','t.ftemp_id=f.file_id') + ->where(['t.isopen'=>'1','t.status'=>6])->where('t.apply_type','in',['0',$tgapply['tg_type']])->order('upload_time desc')->select(); + if(!empty($lxhjy_tmep)){ + $this->assign('lxhjy_tmep',$lxhjy_tmep[0]); + } + + $this->assign('apply_lxh',$apply_lxh); + $this->assign('curr_step',$curr_step); + $this->assign('tgapply',$tgapply); + $this->assign('apply_uptypelist',$apply_uptypelist); + return $this->fetch(); + + + } + /** + * 托管文件核验开启/禁止 + */ + public function apply_state() + { + $id=input('x'); + if (empty($id)){ + $this->error('用户ID不存在'); + } + + $flag=Db::name('trusteeship_upfiles')->where('file_id',$id)->value('flag');//判断当前状态情况 + if($flag==1){ + $flagdata = array('flag'=>0); + Db::name('trusteeship_upfiles')->where('file_id',$id)->setField($flagdata); + $this->success('审核未通过'); + }else{ + $flagdata = array('flag'=>1); + Db::name('trusteeship_upfiles')->where('file_id',$id)->setField($flagdata); + $this->success('审核已通过'); + } + } + /** + * 托管审核 + */ + public function apply_runcheck() + { + //防止重复提交 + if (!checkToken(input('TOKEN'))) { + return; + } + $tg_id=input('tg_id'); + $apply = Db::name('trusteeship_apply')->where('tg_id',$tg_id)->find(); + //检查是否还有未审核通过的文件 + if(input('submitType')==1) { + $file_count = Db::name('trusteeship_upfiles')->where(['apply_id'=>$tg_id,'flag'=>0,'new_flag'=>1])->count(); + if($file_count){ + session('TOKEN',input('TOKEN')); + $this->error('还有文件未审核通过'); + } + }else if($apply['tg_status']!=4){ + $file_count = Db::name('trusteeship_upfiles')->where(['apply_id'=>$tg_id,'flag'=>0,'new_flag'=>1])->count(); + if($file_count==0){ + session('TOKEN',input('TOKEN')); + $this->error('文件已全部审核通过,请将文件审核未不通过再操作!'); + } + } + + if(empty($apply)){ + session('TOKEN',input('TOKEN')); + $this->error('用户ID不存在'); + } + if(config('cult4advice.check')==1) + { + if(input('advice')=='') + { + session('TOKEN',input('TOKEN')); + $this->error('请输入审核意见!'); + } + } + $data=array( + 'apply_id'=>$tg_id,//托管申请ID + 'advice'=>input('advice',"未填写"),//审批意见 + 'create_id'=>session('admin_auth.aid'),//审批人 + 'create_time'=>time(),//审批时间 + ); + if($apply['tg_status']==1){ + $table_name='trusteeship_cs';//托管初审意见表 + if(input('submitType')==1) { + $update_status = 2;//风控审核中(初审已通过) + }else{ + $update_status = 7;//托管会员修改中(初审未通过) + } + }else if($apply['tg_status']==2){ + $table_name='trusteeship_fk';//风控审核意见表 + if(input('submitType')==1) { + if(input('tg_type',1,'intval')==1){//企业股权 + $count=Db::name('cult4apply')->where(['user_id'=>session('hid')])->where('status','eq',31)->count(); + if($count>0){ + $update_status = 4;//已挂牌企业直接财务缴费确认 + }else{ + $update_status = 3;//缴费中(风控审核已通过) + } + } + + }else{ + $update_status = 8;//托管会员修改中(风控审核未通过) + } + }else if($apply['tg_status']==4){ + $table_name='trusteeship_cw';//缴费确认意见表 + if(input('submitType')==1) { + $update_status = 5;//专家评分中(缴费状态已确认) + }else{ + $update_status = 9;//托管会员修改中(缴费确认未通过) + } + }else if($apply['tg_status']==5){//专家只是评分,没有审核 + $table_name='trusteeship_zjpf';//专家评分意见表 + $update_status = 6;//联席会审核中(专家已评分) + $data['score'] = input('score'); + }else if($apply['tg_status']==6){ + $table_name='trusteeship_lxh';//联席会审核意见表 + if(input('submitType')==1) { + $update_status = 11;//托管成功 + }else{ + $update_status = 10;//托管会员修改中(联席会审核未通过) + } + }else if($apply['tg_status']==12){//尽职调查审核 + $file = request()->file('file_one'); + $table_name='trusteeship_checkdd';//联席会审核意见表 + if(input('submitType')==1) { + $update_status = 1;//初审(尽职调查已通过) + }else{ + $update_status = 13;//托管会员修改中(尽职调查未通过) + } + } + //找到当前最大addorder + $check=Db::name($table_name)->where('apply_id',$tg_id)->order('addorder desc') ->find (); + if(!empty($check)){ + $data['addorder']=$check['addorder']+1; + }else{ + $data['addorder']=0; + } + //开始事务 + Db::startTrans(); + try{ + + $sl_data['tg_status']=$update_status; + $sl_data['update_user_id']=session('admin_auth.aid'); + $sl_data['update_user_type']=2;//后台 + $sl_data['update_time']=time(); + $sl_data['apply_admin_id']=0; + $sl_data['tg_org']=input('tg_org'); + $sl_data['tg_cycle']=input('tg_cycle'); + $sl_data['tg_equity']=input('tg_equity'); + $sl_data['tg_assets']=input('tg_assets'); + $where=array( + 'tg_id'=>$apply['tg_id'], + 'tg_status'=>$apply['tg_status'], + ); + Db::name('trusteeship_apply')->where($where)->update($sl_data); + //审核不通过发送通知给客户 + $defaultFileLink='
请点击:
上传资料
'; + if(input('submitType')==2){ + if($apply['tg_status']==1){ + $notice_title='您(或您关联)的托管申请初审不通过,请修改资料!'; + $sys=Options::get_options('tgcheck_options',$this->lang);//初审不通过通知书 + $notic_content=str_replace('#APPLYCONTENTS#',$data['advice'],$sys['content_tpl']); + $notic_content=str_replace('#COMNAME#',$apply['tg_apply_org'],$notic_content); + $notic_content=str_replace('#DATE#',date('Y年m月d日', time()),$notic_content); + }else if($apply['tg_status']==2){ + $notice_title='您(或您关联)的托管申请风控审核不通过,请修改资料!'; + $sys=Options::get_options('tgcheckfk_options',$this->lang);//风控审核不通过通知书 + $notic_content=str_replace('#APPLYCONTENTS#',input('advice').$defaultFileLink,$sys['content_tpl']); + $notic_content=str_replace('#COMNAME#',$apply['tg_apply_org'],$notic_content); + $notic_content=str_replace('#DATE#',date('Y年m月d日', time()),$notic_content); + }else if($apply['tg_status']==4){ + $notice_title='您(或您关联)的托管申请缴费确认审核不通过,请修改资料!'; + $notic_content='您(或您关联)的申请托管不通过,需要您重新修改信息或上传缴费凭证后再提交。
审批意见:'.input('advice').$defaultFileLink; + }else if($apply['tg_status']==6){ + $notice_title='您(或您关联)的托管申请联席会审核不通过,请修改资料!'; + $notic_content='您(或您关联)的申请托管不通过,需要您重新修改信息或上传资料后再提交。
审批意见:'.input('advice').$defaultFileLink; + }else if($apply['tg_status']==12){ + $notice_title='您(或您关联)的托管申请尽职调查审核不通过,请修改资料!'; + $notic_content='您(或您关联)的申请托管不通过,需要您重新修改信息或上传资料后再提交。
审批意见:'.input('advice').$defaultFileLink; + } + }else if($update_status==3){//缴费中,需要发送缴费通知费可以 + $sys=Options::get_options('tgfee_options',$this->lang);//缴费通知 + $notic_content=str_replace('#COMNAME#',$apply['tg_apply_org'],$sys['content_tpl']); + $notic_content=str_replace('#DATE#',date('Y年m月d日', time()),$notic_content); + $notice_title='您(或您关联)的托管申请风控审核已通过,请缴费后上传缴费凭证!'; + }else if($update_status==11){//托管成功,发送成功通知给客户 + $info2 = request()->file('lxhjy')->rule('uniqid')->move(ROOT_PATH . config('upload_path') . DS . date('Y-m-d')); + $file_url = config('upload_path'). '/' . date('Y-m-d') . '/' . $info2->getFilename(); + //写入数据库 + $lxhjy['apply_id'] = $tg_id;//模板文件未使用该字段 + $lxhjy['user_id'] = session('admin_auth.aid'); + $lxhjy['user_type'] = 2; + $lxhjy['status'] = 6; + $lxhjy['upload_time'] = time(); + $lxhjy['ftype_id'] = 0;//模板文件为0 + $lxhjy['ftype'] = 1;//模板类型 + $lxhjy['filesize'] = $info2->getSize(); + $lxhjy['path'] = $file_url; + $lxhjy['addorder'] = 0;//固定文件需要更新 + $lxhjy['new_flag'] = 1;//固定文件需要更新 + $lxhjy['flag'] = 1; + Db::name('trusteeship_upfiles')->insert($lxhjy,false,true); + + if($apply['tg_type']==1){ + $notice_key='tgnotice_options';//企业股权通知书 + $successgg_key = 'tgsuccess_options';//企业股权成功公告 + $tg_thing=input('tg_equity');//股权 + }else{ + $notice_key='zc_successgg';//资产通知书 + $successgg_key = 'zc_successgg';//资产成功公告 + $tg_thing=input('tg_assets');//托管资产 + } + $sys=Options::get_options($notice_key,$this->lang);//缴费通知 + $notice_title='托管申请成功通知书'; + $notic_content =str_replace('#DATE#',date('Y年m月d日', time()),$sys['content_tpl']); + $notic_content=str_replace('#COMNAME#',$apply['tg_apply_org'],$notic_content); + $notic_content=str_replace('#EQUITY#',$tg_thing,$notic_content); + $notic_content=str_replace('#CYCLE#',input('tg_cycle'),$notic_content); + $sys=Options::get_options($successgg_key,$this->lang);//托管成功公告 + $gg_content=$sys['content_tpl']; + $gg_content=str_replace('#EQUITY#',$tg_thing,$gg_content); + $gg_content=str_replace('#CYCLE#',input('tg_cycle'),$gg_content); + $gg_content=str_replace('#COMNAME#',$apply['tg_apply_org'],$gg_content); + $gg_content=str_replace('#DATE#',date('Y年m月d日', time()),$gg_content); + if($apply['tg_isgp']==2){ + if($apply['tg_type']==1){ + //未挂牌企业,公告标题和通知书标题改为“关于企业” + $notic_content=str_replace('关于文化产业板养成板挂牌企业',"关于企业",$notic_content); + $gg_content=str_replace('关于文化产业板养成板挂牌企业',"关于企业",$gg_content); + $notic_content=str_replace('关于文化产业板挂牌企业',"关于企业",$notic_content); + $gg_content=str_replace('关于文化产业板挂牌企业',"关于企业",$gg_content); + }else{ + $notic_content=str_replace('关于文化产业板挂牌企业',"",$notic_content); + $gg_content=str_replace('关于文化产业板挂牌企业',"",$gg_content); + $notic_content=str_replace('##','关于',$notic_content); + $gg_content=str_replace('##','关于',$gg_content); + } + }else{ + $notic_content=str_replace('##','',$notic_content); + $gg_content=str_replace('##','',$gg_content); + } + }else if($update_status==1){//尽职调查审核通过 + $validate = config('upload_validate'); + unset($validate['ext']);//不限制后缀 + //单图 + $info = $file->validate($validate)->rule('uniqid')->move(ROOT_PATH . config('upload_path') . DS . date('Y-m-d')); + if ($info) { + $file_url = config('upload_path'). '/' . date('Y-m-d') . '/' . $info->getFilename(); + //写入数据库 + $filedata['apply_id'] = $tg_id;//模板文件未使用该字段 + $filedata['user_id'] = session('admin_auth.aid'); + $filedata['user_type'] = 2; + $filedata['status'] = 12; + $filedata['upload_time'] = time(); + $filedata['ftype_id'] = 0;//模板文件为0 + $filedata['ftype'] = 1;//模板类型 + $filedata['filesize'] = $info->getSize(); + $filedata['path'] = $file_url; + $filedata['addorder'] = 0;//固定文件需要更新 + $filedata['new_flag'] = 1;//固定文件需要更新 + $filedata['flag'] = 1; + $file_id = Db::name('trusteeship_upfiles')->insert($filedata,false,true); + $data['file_id']=$file_id; + } else { + session('TOKEN',input('TOKEN'));//审核失败,将token添加回session里 + $this->error($file->getError());//否则就是上传错误,显示错误原因 + } + } + + Db::name($table_name)->insert($data); + if(input('submitType')==2 || $update_status==3 || $update_status==11){ + $n_data=[ + 'notice_title'=>$apply['tg_apply_org'].$notice_title, + 'notice'=>$notic_content, + 'apply_id'=>$tg_id, + 'user_id'=>$apply['tg_uid'], + 'is_read'=>'0', + 'create_id'=>session('admin_auth.aid'), + 'create_type'=>1, + 'create_time'=>time() + ]; + Db::name('cult4notice')->insert($n_data); + } + if($update_status==11){ + $gg_data = [ + 'n_content'=>$gg_content, + 'n_title'=>$apply['tg_apply_org'].'托管申请成功公告', + 'n_cid'=>3, + 'n_time'=>time(), + 'n_status'=>1, + 'n_hits'=>0, + 'n_uid'=>1 + ]; + Db::name('bsgg')->insert($gg_data); + } + // 提交事务 + Db::commit(); + }catch (\Exception $exception){ + Db::rollback();//回滚事务 + session('TOKEN',input('TOKEN'));//审核失败,将token添加回session里 + $this->error('审核失败'); + } + $this->success('审核成功',url('tuoguan/Trusteeship/apply_list',array('applystatus'=>$apply['tg_status']))); + } +} \ No newline at end of file diff --git a/app/tuoguan/model/TApply.php b/app/tuoguan/model/TApply.php new file mode 100644 index 0000000..54a7594 --- /dev/null +++ b/app/tuoguan/model/TApply.php @@ -0,0 +1,64 @@ +alias("a")->join(config('database.prefix').'member_list m','a.tg_uid =m.member_list_id') + ->join(config('database.prefix').'trusteeship_status c','a.tg_status =c.status')->where($where)->order($order)->paginate(config('paginate.list_rows'),false,['query'=>get_query()]); + } + + /** + * 申请受理 + * @param int $apply_id 申请id + * @param int $apply_admin_id 受理用户id + * @return int 影响行数0或1 + */ + public static function applyed($apply_id,$apply_admin_id,$status) + { + $sldata=array( + 'apply_admin_id'=>$apply_admin_id, + 'update_time'=>time(), + 'update_user_id'=>$apply_admin_id, + 'update_user_type'=>1, + ); + $where=array( + 'tg_id'=>$apply_id, + 'tg_status'=>$status, + 'apply_admin_id'=>array('EQ', 0), + ); + + $apply=Db::name('trusteeship_apply')->where($where)->update($sldata); + + return $apply; + } +} \ No newline at end of file diff --git a/app/tuoguan/model/Tuptype.php b/app/tuoguan/model/Tuptype.php new file mode 100644 index 0000000..48ef09b --- /dev/null +++ b/app/tuoguan/model/Tuptype.php @@ -0,0 +1,99 @@ +where("ftype_id='$ftypeid'")->select(); + $filetypeInfo[$ftypeid]=$filetypeInfo?:array(); + return $filetypeInfo[$ftypeid]; + } + /** + * 上传文件类型表 + * @param array + * @param int $apply_id 查询条件(申请ID) + * @param int $type 查询条件(-1:$apply_id对应的临时和固定文件 1:固定 2:临时) + * @param int|array $status 查询条件(文件类型显示在哪个状态) + * @param int $isopen 查询条件(启用状态) + * @param string $order 结果排序 + * @return mixed + */ + public static function getList($apply_type,$apply_id,$type=-1,$status=-1,$isopen=1,$order='ftype_id,status,apply_id,isopen',$mustupload=1) + { + $where=array(); + + //根据状态值取出对应状态的数据0:所有 1:企业股权 2:实物资产 3:知识产权 4:其他权益 + if($apply_type!=-1)$where['apply_type']=array(array('eq',0),array('eq',$apply_type), 'or'); + + if($mustupload!=-1)$where['mustupload']=$mustupload; + if($type != -1){ + if($type===1)//固定 + $where['apply_id'] = array('eq', 0); + elseif($type===2)//临时 + $where['apply_id'] = array('eq', $apply_id);//临时文件肯定有对应的apply_id + } + else $where['apply_id'] = array(array('eq',0),array('eq',$apply_id), 'or'); + if($status != -1)$where['status'] = is_array($status)?array('in',$status):array('eq',$status); + if($isopen != -1)$where['isopen'] = array('eq',$isopen); + + if($status == -1) + return Db::name('trusteeship_uptype')->where($where)->order($order)->paginate(config('paginate.list_rows'),false,['query'=>get_query()]); + else + return Db::name('trusteeship_uptype')->where($where)->order($order)->select(); + } + + /** + * 增加托管上传文件类型 + * @param string + * @param string + * @param string + * @param string + * @param string + * @param int + * @param string + * @param int + * @return mixed + */ + public static function add($apply_type,$isgp,$ftypedescr,$ftemp_id,$ftype,$status,$isopen,$apply_id,$user_id,$roletype,$roleid,$roletype2=0,$roleid2=0,$mustupload=1) + { + $sldata=array( + 'ftypedescr'=>$ftypedescr, + 'ftemp_id' => $ftemp_id, + 'apply_type' => $apply_type, + 'isgp' => $isgp, + 'mustupload' => $mustupload, + 'ftype'=>$ftype, + 'status'=>$status, + 'isopen'=>$isopen, + 'apply_id'=>$apply_id, + 'user_id'=>$user_id, + 'create_time'=>time(), + 'upload_role_type'=>$roletype, + 'upload_role_id'=>$roleid, + 'upload_role_type2'=>$roletype2, + 'upload_role_id2'=>$roleid2, + ); + $uptype=Db::name('trusteeship_uptype')->insert($sldata); + if($uptype){ + return $uptype; + }else{ + return 0; + } + } +} \ No newline at end of file diff --git a/app/tuoguan/view/tgsetup/tgagree.html b/app/tuoguan/view/tgsetup/tgagree.html new file mode 100644 index 0000000..e868e91 --- /dev/null +++ b/app/tuoguan/view/tgsetup/tgagree.html @@ -0,0 +1,53 @@ +{extend name="admin@public/base" /} +{block name="main-content"} +
+ + + + + +
+
+
+ +
+ +
+ + + + + +
+
+
+
+
+ + +       + +
+
+
+
+
+
+{/block} \ No newline at end of file diff --git a/app/tuoguan/view/tgsetup/tgcheck.html b/app/tuoguan/view/tgsetup/tgcheck.html new file mode 100644 index 0000000..ba6d3d7 --- /dev/null +++ b/app/tuoguan/view/tgsetup/tgcheck.html @@ -0,0 +1,53 @@ +{extend name="admin@public/base" /} +{block name="main-content"} +
+ + + + + +
+
+
+ +
+ +
+ + + + + +
+
+
+
+
+ + +       + +
+
+
+
+
+
+{/block} \ No newline at end of file diff --git a/app/tuoguan/view/tgsetup/tgcheckfk.html b/app/tuoguan/view/tgsetup/tgcheckfk.html new file mode 100644 index 0000000..6e3851f --- /dev/null +++ b/app/tuoguan/view/tgsetup/tgcheckfk.html @@ -0,0 +1,53 @@ +{extend name="admin@public/base" /} +{block name="main-content"} +
+ + + + + +
+
+
+ +
+ +
+ + + + + +
+
+
+
+
+ + +       + +
+
+
+
+
+
+{/block} \ No newline at end of file diff --git a/app/tuoguan/view/tgsetup/tgfee.html b/app/tuoguan/view/tgsetup/tgfee.html new file mode 100644 index 0000000..44d51b7 --- /dev/null +++ b/app/tuoguan/view/tgsetup/tgfee.html @@ -0,0 +1,53 @@ +{extend name="admin@public/base" /} +{block name="main-content"} +
+ + + + + +
+
+
+ +
+ +
+ + + + + +
+
+
+
+
+ + +       + +
+
+
+
+
+
+{/block} \ No newline at end of file diff --git a/app/tuoguan/view/tgsetup/tgnotice.html b/app/tuoguan/view/tgsetup/tgnotice.html new file mode 100644 index 0000000..21acc0a --- /dev/null +++ b/app/tuoguan/view/tgsetup/tgnotice.html @@ -0,0 +1,53 @@ +{extend name="admin@public/base" /} +{block name="main-content"} +
+ + + + + +
+
+
+ +
+ +
+ + + + + +
+
+
+
+
+ + +       + +
+
+
+
+
+
+{/block} \ No newline at end of file diff --git a/app/tuoguan/view/tgsetup/tgsuccessgg.html b/app/tuoguan/view/tgsetup/tgsuccessgg.html new file mode 100644 index 0000000..d7d4308 --- /dev/null +++ b/app/tuoguan/view/tgsetup/tgsuccessgg.html @@ -0,0 +1,53 @@ +{extend name="admin@public/base" /} +{block name="main-content"} +
+ + + + + +
+
+
+ +
+ +
+ + + + + +
+
+
+
+
+ + +       + +
+
+
+
+
+
+{/block} \ No newline at end of file diff --git a/app/tuoguan/view/tgsetup/zc_notice.html b/app/tuoguan/view/tgsetup/zc_notice.html new file mode 100644 index 0000000..acc1c3a --- /dev/null +++ b/app/tuoguan/view/tgsetup/zc_notice.html @@ -0,0 +1,53 @@ +{extend name="admin@public/base" /} +{block name="main-content"} +
+ + + + + +
+
+
+ +
+ +
+ + + + + +
+
+
+
+
+ + +       + +
+
+
+
+
+
+{/block} \ No newline at end of file diff --git a/app/tuoguan/view/tgsetup/zc_successgg.html b/app/tuoguan/view/tgsetup/zc_successgg.html new file mode 100644 index 0000000..a4871aa --- /dev/null +++ b/app/tuoguan/view/tgsetup/zc_successgg.html @@ -0,0 +1,53 @@ +{extend name="admin@public/base" /} +{block name="main-content"} +
+ + + + + +
+
+
+ +
+ +
+ + + + + +
+
+
+
+
+ + +       + +
+
+
+
+
+
+{/block} \ No newline at end of file diff --git a/app/tuoguan/view/tgsetup/zscq_notice.html b/app/tuoguan/view/tgsetup/zscq_notice.html new file mode 100644 index 0000000..0160062 --- /dev/null +++ b/app/tuoguan/view/tgsetup/zscq_notice.html @@ -0,0 +1,53 @@ +{extend name="admin@public/base" /} +{block name="main-content"} +
+ + + + + +
+
+
+ +
+ +
+ + + + + +
+
+
+
+
+ + +       + +
+
+
+
+
+
+{/block} \ No newline at end of file diff --git a/app/tuoguan/view/tgsetup/zscq_successgg.html b/app/tuoguan/view/tgsetup/zscq_successgg.html new file mode 100644 index 0000000..fb807e6 --- /dev/null +++ b/app/tuoguan/view/tgsetup/zscq_successgg.html @@ -0,0 +1,53 @@ +{extend name="admin@public/base" /} +{block name="main-content"} +
+ + + + + +
+
+
+ +
+ +
+ + + + + +
+
+
+
+
+ + +       + +
+
+
+
+
+
+{/block} \ No newline at end of file diff --git a/app/tuoguan/view/trusteeship/apply_check.html b/app/tuoguan/view/trusteeship/apply_check.html new file mode 100644 index 0000000..0cd9e1c --- /dev/null +++ b/app/tuoguan/view/trusteeship/apply_check.html @@ -0,0 +1,1354 @@ +{extend name="admin@public/base" /} +{block name="main-content"} +
+ + + + + +

托管会员信息 - {$curr_step}

+
+
+
+ + + +
+
+
+

会员基本信息

+
+ + + +
+
+
+
+
+ +
+ + + + +
+
+ {if condition="$tgapply['tg_type'] eq 1"} +
+ +
+ + +
+
+ {/if} +
+ +
+ +
+
+
+ +
+ +
+
+
+ {if(!empty($apply_uptypelist))} +
+ +
+
+
+
+ + + + + + + + + + + + + + + + + + {foreach name="$apply_uptypelist" item="f1"} + {if condition="empty($f1.file)"} + + + + + + + + + + {else} + + + + + + + + + + + + + {/if} + {/foreach} + +
ID文件描述必须上传者类型上传者文件大小上传时间查看审核审核历史
{$f1.ftypedescr}{if condition="$f1.mustupload eq 1"}必须{else/}非必须{/if}未上传第一上传者:{:get_cult4RoleName($f1.upload_role_id,$f1.upload_role_type)}
第二上传者:{:get_cult4RoleName($f1.upload_role_id2,$f1.upload_role_type2)}
未审核{if condition="get_cult4CntHistory($tgapply.tg_id,$f1.ftype_id) eq 0"}无{else/}历史{/if}
{$f1.file.file_id}{$f1.ftypedescr}{if condition="$f1.mustupload eq 1"}必须{else/}非必须{/if}{if condition="$f1.file.user_type eq 1"}前台会员{else/}后台员工{/if}{:get_cult4UserName($f1.file.user_id,$f1.file.user_type)}{$f1.file.filesize}{$f1.file.upload_time|date='Y-m-d H:i:s',###}查看 + {if condition="$f1.file.flag eq 1"} + {if condition="$tgapply.tg_status neq 4 and $tgapply.tg_status neq 5"} + +
+
+ {/if} + {if condition="$tgapply.tg_status eq 4 or $tgapply.tg_status eq 5"} +
+ {/if} + {else/} + +
+
+ {/if} +
{if condition="get_cult4CntHistory($tgapply.tg_id,$f1.ftype_id) eq 0"}无{else/}历史{/if}
+
+
+
+
+
+ {else/} +
+ +
+ 无上传文件 +
+
+ {/if} +
+
+
+ +
+
+

尽职调查信息

+
+ + + +
+
+
+
+
+
+
+
+ +
+ {if(!empty($apply_jzdc))} + + {else/} +
+ 无 +
+ {/if} + {if(!empty($jzdc_files))} + + + + + + + + + + + + + + + + {foreach name="$jzdc_files" item="f1"} + + + + + + + + + + + {/foreach} + +
ID文件描述必须上传者类型上传者文件大小上传时间查看
{$f1.file_id}尽职调查必须{if condition="$f1.user_type eq 1"}前台会员{else/}后台员工{/if}{:get_cult4UserName($f1.user_id,$f1.user_type)}{$f1.filesize}{$f1.upload_time|date='Y-m-d H:i:s',###}查看
+ {/if} +
+
+ {if condition="$tgapply.tg_status eq 12"} +
+ +
+ + {notempty name="temp_files"}下载模板{/notempty} +
+
+
+
+ +
+ +
+
+
+
+ +
+ + + + + 请输入您的尽职调查意见,并提交! +
+
+
+
+
+   +   + +
+
+ {/if} +
+
+
+
+
+
+ + + {if condition="in_array($tgapply.tg_status,[1,2,4,5,6,11])"} +
+
+

初审信息

+
+ + + +
+
+
+
+
+
+
+
+ +
+ {if(!empty($apply_cs))} + + {else/} +
+ 无 +
+ {/if} +
+
+ {if condition="$tgapply.tg_status eq 1"} +
+ +
+ + + + + 请输入您的初审意见,并提交! +
+
+
+
+
+   +   +
+
+ {/if} +
+
+
+
+
+
+ {/if} + + {if condition="in_array($tgapply.tg_status,[2,4,5,6,11])"} +
+
+

风控信息

+
+ + + +
+
+
+
+
+
+
+
+ +
+ {if(!empty($apply_fk))} + + {else/} +
+ 无 +
+ {/if} +
+
+ {if condition="$tgapply.tg_status eq 2"} +
+ +
+ + + + + 请输入您的审核意见,并提交! +
+
+
+
+
+   +   +
+
+ {/if} + +
+
+
+
+
+
+ {/if} + + {if condition="in_array($tgapply.tg_status,[4,5,6,11])"} +
+
+

缴费确认信息

+
+ + + +
+
+
+
+
+
+
+
+ +
+ {if(!empty($apply_cw))} + + {else/} +
+ 无 +
+ {/if} +
+
+ {if(!empty($apply_jfpz))} +
+ +
+ 查看 +
+
+
+ {/if} + {if condition="$tgapply.tg_status eq 4"} +
+ +
+ + + + + 请输入您的审核意见,并提交! +
+
+
+
+
+   +   +
+
+ {/if} + +
+
+
+
+
+
+ {/if} + + {if condition="in_array($tgapply.tg_status,[5,6,11])"} +
+
+

专家审核信息

+
+ + + +
+
+
+
+
+
+
+ {if(!empty($apply_zjpf))} + +
+ +
+
+

专家评分(最高分:100)

+
+
+
+
+ + +
+
+
+ +
+
+
+ {/if} + {if condition="$tgapply.tg_status eq 5"} +
+ +
+ + + + + 请输入您的审核意见,并提交! +
+
+
+

专家评分(最高分:100)

+ +
+
+
+
+ + +
+
+
+ +
+
+
+
+
+
+   +
+
+ {/if} + +
+
+
+
+
+
+ {/if} + + {if condition="in_array($tgapply.tg_status,[6,11])"} +
+
+

联席会审核信息

+
+ + + +
+
+
+
+
+
+
+
+ +
+ {if(!empty($apply_lxh))} + + {else/} +
+ 无 +
+ {/if} +
+
+ {if condition="$tgapply.tg_status eq 6"} +
+ +
+ + {notempty name="lxhjy_tmep"}下载模板{/notempty} +
+
+
+ {if condition="$tgapply['tg_type'] eq 1"} +
+ +
+ +
+
+ {/if} + {if condition="$tgapply['tg_type'] neq 1"} +
+ +
+ +
+
+ {/if} +
+
+ +
+ +
+
+
+
+ +
+ + + + + 请输入您的审核意见,并提交! +
+
+
+
+
+   +   + +
+
+ {/if} + +
+
+
+
+
+
+ {/if} +
+
+
+
+
+{/block} +{block name="scripts"} + + + + + +{/block} diff --git a/app/tuoguan/view/trusteeship/apply_list.html b/app/tuoguan/view/trusteeship/apply_list.html new file mode 100644 index 0000000..a763fcc --- /dev/null +++ b/app/tuoguan/view/trusteeship/apply_list.html @@ -0,0 +1,106 @@ +{extend name="admin@public/base" /} +{block name="main-content"} +
+ + + +
+
+
+
+ + + + + + + + + + + + + + + + + + {foreach name="apply_list" item="v"} + + + + + + + + + + + + {/foreach} + + + + +
ID申请用户名用户状态托管类型挂牌状态处理状态申请日期操作处理号
{$v.tg_id}{$v.tg_uid,1|get_cult4UserName}{if condition="get_cult4UserStatus($v.tg_uid,1) eq 1"}正常{else/}锁定{/if}{if condition="$v.tg_type eq 1"}企业股权{elseif condition="$v.tg_type eq 2"/}实物资产{elseif condition="$v.tg_type eq 3"/}知识产权{else/}其他权益{/if}{if condition="$v.tg_isgp eq 1"}已挂牌{else/}未挂牌{/if}{$v.descr}{$v.tg_time|date='Y-m-d H:i:s',###} + +
{$page}
+
+
+
+
+ + + +
+{/block} diff --git a/app/tuoguan/view/trusteeship/tg_list.html b/app/tuoguan/view/trusteeship/tg_list.html new file mode 100644 index 0000000..c14d305 --- /dev/null +++ b/app/tuoguan/view/trusteeship/tg_list.html @@ -0,0 +1,66 @@ +{extend name="admin@public/base" /} +{block name="main-content"} +
+ +
+
+ +
+
+
+
+
+
+ + + + + + + + + + + + + + + + {foreach name="apply_list" item="v"} + + + + + + + + + + {/foreach} + + + + +
ID申请用户名用户状态托管类型挂牌状态处理状态申请日期
{$v.tg_id}{$v.tg_uid,1|get_cult4UserName}{if condition="get_cult4UserStatus($v.tg_uid,1) eq 1"}正常{else/}锁定{/if}{if condition="$v.tg_type eq 1"}企业股权{elseif condition="$v.tg_type eq 2"/}实物产权{elseif condition="$v.tg_type eq 3"/}知识产权{else/}其他权益{/if}{if condition="$v.tg_type eq 1"}{if condition="$v.tg_isgp eq 1"}已挂牌{else/}未挂牌{/if}{/if}{$v.descr}{$v.tg_time|date='Y-m-d H:i:s',###}
{$page}
+
+
+
+
+ + + +
+{/block} diff --git a/app/tuoguan/view/trusteeship/uptype_add.html b/app/tuoguan/view/trusteeship/uptype_add.html new file mode 100644 index 0000000..d2f5fa2 --- /dev/null +++ b/app/tuoguan/view/trusteeship/uptype_add.html @@ -0,0 +1,193 @@ +{extend name="admin@public/base" /} +{block name="main-content"} +
+ + + + + + + +
+
+
+ + +
+ +
+ +
+
+
+
+ +
+ + *请选择该固定文件对应的托管类型 +
+
+
+
+ +
+ + *请选择是否已挂牌 +
+
+
+
+ +
+ + *请选择项目持有人 +
+
+
+ + +
+ +
+ + *请输入文件类型描述 +
+
+
+ +
+ +
+ +
+
+
+ +
+ +
+ + *选择可接受的文件类型 +
+
+
+ +
+ +
+ {if condition="$status egt 0"}{/if} + + {foreach name="statuslist" item="v" key="i"} + + {/foreach} + +
+
+
+
+ +
+ + + *请选择资料上传者 +
+
+
+
+ +
+ + +
+
+
+
+ +
+ +  默认关闭 +
+
+
+ +
+
+ + + + + + +
+
+
+
+
+ +
+{/block} +{block name="scripts"} + +{/block} \ No newline at end of file diff --git a/app/tuoguan/view/trusteeship/uptype_edit.html b/app/tuoguan/view/trusteeship/uptype_edit.html new file mode 100644 index 0000000..99c32e9 --- /dev/null +++ b/app/tuoguan/view/trusteeship/uptype_edit.html @@ -0,0 +1,189 @@ +{extend name="admin@public/base" /} +{block name="main-content"} +
+ + + + + + + +
+
+
+ + +
+ +
+ +
+
+
+
+ +
+ + *请选择该固定文件对应的托管类型 +
+
+
+
+ +
+ + *请选择是否已挂牌 +
+
+
+
+ +
+ + *请选择项目持有人 +
+
+
+ +
+ +
+ + *请输入文件类型描述 +
+
+
+ +
+ +
+ + {if(empty($upfile))}{else/}查看原始上传文件{/if} +
+
+
+ +
+ +
+ + *选择可接受的文件类型 +
+
+
+ +
+ +
+ {if condition="$uptype.status egt 0"}{/if} + + {foreach name="statuslist" item="v" key="i"} + + {/foreach} + +
+
+
+
+ +
+ + + *请选择资料上传者 +
+
+
+
+ +
+ + +
+
+
+
+ +
+ +  默认关闭 +
+
+
+ +
+
+ + + + + + +
+
+
+
+
+ +
+{/block} +{block name="scripts"} + +{/block} \ No newline at end of file diff --git a/app/tuoguan/view/trusteeship/uptype_list.html b/app/tuoguan/view/trusteeship/uptype_list.html new file mode 100644 index 0000000..b828b3d --- /dev/null +++ b/app/tuoguan/view/trusteeship/uptype_list.html @@ -0,0 +1,105 @@ +{extend name="admin@public/base" /} +{block name="main-content"} +
+ + + +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + {foreach name="uptype_list" item="v"} + + + + + + + + + + + + + + + + + + {/foreach} + + + + +
ID文件描述文件类型文件模板托管类型接受文件类型上传状态启用状态申请ID操作员上传者辅助上传者操作日期必须项目操作
{$v.ftype_id}{$v.ftypedescr}{if condition="$v.apply_id eq 0"}固定{else/}临时{/if}{if condition="get_TGPathFromFileID($v.ftemp_id) eq '未上传'"}未上传{else/}查看{/if}{if condition="$v.apply_type eq 0"}所有{elseif condition="$v.apply_type eq 1"}企业股权{elseif condition="$v.apply_type eq 2"}实物资产{elseif condition="$v.apply_type eq 3"}知识产权{elseif condition="$v.apply_type eq 4"}其他权益{/if}{$v.ftype}{$v.status|get_TGStatus} + {if condition="$v['isopen'] eq 1"} + +
+
+ {else/} + +
+
+ {/if} +
{if condition="$v.apply_id eq 0"}无{else/}{$v.apply_id}{/if}{$v.user_id|get_cult4UserName=###,2}{$v.upload_role_id,$v.upload_role_type|get_cult4RoleName}{$v.upload_role_id2,$v.upload_role_type2|get_cult4RoleName}{$v.create_time|date='Y-m-d H:i:s',###}{if condition="$v.mustupload eq 1"}必须{else/}非必须{/if} + + +
{$page}
+
+
+
+ + + +
+{/block} diff --git a/app/wechat/controller/Index.php b/app/wechat/controller/Index.php new file mode 100644 index 0000000..7f97902 --- /dev/null +++ b/app/wechat/controller/Index.php @@ -0,0 +1,162 @@ + +// +---------------------------------------------------------------------- +namespace app\wechat\controller; + +use think\Db; +use EasyWeChat\Message\Text; +use EasyWeChat\Message\Image; +use EasyWeChat\Message\Voice; +use EasyWeChat\Message\News; +use EasyWeChat\Foundation\Application; + +class Index extends WeBase +{ + public function _initialize() + { + //parent::_initialize(); + //微信平台 + $config=config('we_options'); + if(!empty($config)) $this->options=array_merge($this->options,$config); + $this->app = new Application($this->options); + config('app_debug',false); + config('app_trace',false); + if(input('echostr') && $this->checkSignature()){ + //验证token + return input('echostr'); + } + } + public function index() + { + //消息处理 + $this->app->server->setMessageHandler(function ($message) { + switch ($message->MsgType) { + case 'event': + # 事件消息... + switch ($message->Event) { + case 'subscribe': + # code... + $we_reply_list=Db::name('we_reply')->where('we_reply_key','subscribe')->find(); + if($we_reply_list){ + switch ($we_reply_list['we_reply_type']) { + case 'text'://回复文本 + $text = new Text(['content' => $we_reply_list['we_replytext_content']]); + return $text; + break; + case 'image'://回复图片 + $new= new Image(['media_id' => $we_reply_list['we_replyimage_mediaid']]); + return $new; + break; + case 'voice'://回复语音 + $new=new Voice(['media_id' => $we_reply_list['we_replyvoice_mediaid']]); + return $new; + break; + case 'news'://回复图文消息 + $news=json_decode($we_reply_list['we_replynews'],true); + $new=new News($news); + return $new; + break; + default: + $text = new Text(['content' => '亲,不明白您想说什么']); + return $text; + break; + } + } + break; + case 'unsubscribe': + # code... + //取消关注 + break; + case 'CLICK': + # code... + //点击自定义click菜单 + switch ($message->EventKey) { + case 'key1'://如果为key1菜单,执行 + break; + default : + # code... + break; + } + break; + default : + # code... + break; + } + break; + case 'text': + # 文字消息... + $we_reply_list=Db::name('we_reply')->where('we_reply_key','like','%'.$message->Content.'%')->find(); + if (empty($we_reply_list)){ + $text = new Text(['content' => '亲,不明白您想说什么']); + return $text; + }else{ + switch ($we_reply_list['we_reply_type']) { + case 'text'://回复文本 + $text = new Text(['content' => $we_reply_list['we_replytext_content']]); + return $text; + break; + case 'image'://回复图片 + $new= new Image(['media_id' => $we_reply_list['we_replyimage_mediaid']]); + return $new; + break; + case 'voice'://回复语音 + $new=new Voice(['media_id' => $we_reply_list['we_replyvoice_mediaid']]); + return $new; + break; + case 'news'://回复图文消息 + $news=json_decode($we_reply_list['we_replynews'],true); + $new=new News($news); + return $new; + break; + default: + $text = new Text(['content' => '亲,不明白您想说什么']); + return $text; + break; + } + } + break; + case 'image': + # 图片消息... + break; + case 'voice': + # 语音消息... + break; + case 'video': + # 视频消息... + break; + case 'location': + # 坐标消息... + break; + case 'link': + # 链接消息... + break; + // ... 其它消息 + default: + # code... + break; + } + }); + $this->app->server->serve()->send(); + } + private function checkSignature() + { + $signature =input('signature'); + $timestamp = input('timestamp'); + $nonce = input('nonce'); + $token = $this->options['token']; + $tmpArr = array($token, $timestamp, $nonce); + sort($tmpArr, SORT_STRING); + $tmpStr = implode( $tmpArr ); + $tmpStr = sha1( $tmpStr ); + if( $tmpStr == $signature ){ + return true; + }else{ + return false; + } + } +} \ No newline at end of file diff --git a/app/wechat/controller/We.php b/app/wechat/controller/We.php new file mode 100644 index 0000000..6e7bb14 --- /dev/null +++ b/app/wechat/controller/We.php @@ -0,0 +1,769 @@ + +// +---------------------------------------------------------------------- +namespace app\wechat\controller; + +use think\Db; +use think\Validate; +use EasyWeChat\Message\Article; + +class We extends WeBase +{ + public function _initialize() + { + parent::_initialize(); + $config=config('we_options'); + if(!empty($config)) $this->options=array_merge($this->options,$config); + } + //微信设置显示 + public function wesys() + { + $this->assign('sys',$this->options); + return $this->fetch(); + } + + //保存微信设置 + public function runwesys() + { + if (!request()->isAjax()){ + $this->error('提交方式不正确',url('wechat/We/wesys')); + }else{ + $we_options=input('post.'); + $rst=sys_config_setbyarr($we_options); + if($rst!==false){ + $this->options=array_merge($this->options,$we_options['we_options']); + $this->success('微信设置保存成功',url('wechat/We/wesys')); + }else{ + $this->error('提交参数不正确',url('wechat/We/wesys')); + } + } + } + public function menu_list() + { + $menu=Db::name('we_menu')->order('we_menu_order')->select(); + $menu=menu_left($menu,'we_menu_id','we_menu_leftid'); + $this->assign('menu',$menu); + if(request()->isAjax()){ + return $this->fetch('ajax_menu_list'); + }else{ + return $this->fetch(); + } + } + public function menu_runadd() + { + if(!request()->isAjax()){ + $this->error('提交方式不正确'); + }else{ + $we_menu_type=input('we_menu_type',1,'intval'); + $we_menu_typeval=input('we_menu_typeval',''); + if($we_menu_type==1){ + $rule = [ + ['we_menu_typeval','url','URL地址无效'] + ]; + $validate = new Validate($rule); + $rst = $validate->check(array( + 'we_menu_typeval'=>$we_menu_typeval + )); + if(true !==$rst){ + $this->error('URL地址无效'); + } + } + $we_menu=Db::name('we_menu'); + $we_menu_leftid=input('we_menu_leftid',0,'intval'); + if($we_menu_leftid==0){ + $top_menu=$we_menu->where(['we_menu_leftid'=>0,'we_menu_open'=>1])->count(); + if ($top_menu>2){ + $this->error('顶级菜单不能超过3个',url('wechat/We/menu_list')); + } + }else{ + $child_menu=$we_menu->where(['we_menu_leftid'=>$we_menu_leftid,'we_menu_open'=>1])->count(); + if ($child_menu>4){ + $this->error('子菜单不能超过5个',url('wechat/We/menu_list')); + } + } + $sldata=array( + 'we_menu_leftid'=>$we_menu_leftid, + 'we_menu_name'=>input('we_menu_name'), + 'we_menu_type'=>$we_menu_type, + 'we_menu_typeval'=>$we_menu_typeval, + 'we_menu_order'=>input('we_menu_order',50), + 'we_menu_open'=>input('we_menu_open',0), + ); + $rst=$we_menu->insert($sldata); + if($rst!==false){ + $this->success('菜单添加成功',url('wechat/We/menu_list')); + }else{ + $this->error('菜单添加失败',url('wechat/We/menu_list')); + } + } + } + public function menu_state() + { + $id=input('x'); + $we_menu=Db::name('we_menu'); + $statusone=$we_menu->where('we_menu_id',$id)->value('we_menu_open'); + if($statusone==1){ + $statedata = array('we_menu_open'=>0); + $we_menu->where('we_menu_id',$id)->setField($statedata); + $this->success('状态禁止'); + }else{ + $statedata = array('we_menu_open'=>1); + $we_menu->where('we_menu_id',$id)->setField($statedata); + $this->success('状态开启'); + } + } + public function menu_order() + { + if (!request()->isAjax()){ + $this->error('提交方式不正确'); + }else{ + $we_menu=Db::name('we_menu'); + foreach (input('post.') as $id => $sort){ + $we_menu->where('we_menu_id',$id)->setField('we_menu_order' , $sort); + } + $this->success('排序更新成功',url('wechat/We/menu_list')); + } + } + public function menu_del() + { + $menu=Db::name('we_menu')->select(); + $tree=new \Tree(); + $tree->init($menu,['parentid'=>'we_menu_leftid','id'=>'we_menu_id']); + $ids=$tree->get_childs($menu,input('we_menu_id'),true,true); + $rst=Db::name('we_menu')->where('we_menu_id','in',$ids)->delete(); + if($rst!==false){ + $this->success('菜单删除成功',url('wechat/We/menu_list')); + }else{ + $this->error('菜单删除失败',url('wechat/We/menu_list')); + } + } + public function menu_edit() + { + $we_menu_id=input('we_menu_id'); + $menu=Db::name('we_menu')->where('we_menu_id',$we_menu_id)->find(); + $menu['code']=1; + return json($menu); + } + public function menu_runedit() + { + if(!request()->isAjax()){ + $this->error('提交方式不正确'); + }else{ + $we_menu_type=input('we_menu_type',1,'intval'); + $we_menu_typeval=input('we_menu_typeval',''); + if($we_menu_type==1){ + $rule = [ + ['we_menu_typeval','url','URL地址无效'] + ]; + $validate = new Validate($rule); + $rst = $validate->check(array( + 'we_menu_typeval'=>$we_menu_typeval + )); + if(true !==$rst){ + $this->error('URL地址无效'); + } + } + $we_menu=Db::name('we_menu'); + $sldata=array( + 'we_menu_leftid'=>input('we_menu_leftid',0,'intval'), + 'we_menu_name'=>input('we_menu_name'), + 'we_menu_type'=>$we_menu_type, + 'we_menu_typeval'=>$we_menu_typeval, + 'we_menu_order'=>input('we_menu_order',50), + 'we_menu_open'=>input('we_menu_open',0), + ); + $rst=$we_menu->where('we_menu_id',input('we_menu_id'))->update($sldata); + if($rst!==false){ + $this->success('菜单编辑成功',url('wechat/We/menu_list')); + }else{ + $this->error('菜单编辑失败',url('wechat/We/menu_list')); + } + } + } + public function menu_make() + { + //判断是否配置 + if(empty($this->options['app_id']) || empty($this->options['secret'])){ + $this->error('微信配置不正确',url('wechat/We/menu_list')); + } + //组装数据 + $we_menu=Db::name('we_menu')->where(array('we_menu_leftid'=>0,'we_menu_open'=>1))->order('we_menu_id')->limit(3)->select(); + if(empty($we_menu)){ + $this->error('没有菜单需要生成',url('wechat/We/menu_list')); + } + $new_menu = array(); + $menu_count = 0; + foreach ($we_menu as $v){ + $new_menu[$menu_count]['name'] = $v['we_menu_name']; + $c_menus = Db::name('we_menu')->where(array('we_menu_leftid'=>$v['we_menu_id'],'we_menu_open'=>1))->limit(5)->select(); + if($c_menus){ + foreach($c_menus as $vv){ + $c_menu = array(); + $c_menu['name'] = $vv['we_menu_name']; + $c_menu['type'] = ($vv['we_menu_type']==1)?'view':(($vv['we_menu_type']==2)?'click':$vv['we_menu_type']); + if($c_menu['type'] == 'view'){ + $c_menu['url'] = $vv['we_menu_typeval']; + }else{ + $c_menu['key'] = $vv['we_menu_typeval']; + } + $c_menu['sub_button'] = array(); + if($c_menu['name']){ + $new_menu[$menu_count]['sub_button'][] = $c_menu; + } + } + }else{ + $new_menu[$menu_count]['type'] = ($v['we_menu_type']==1)?'view':(($v['we_menu_type']==2)?'click':$v['we_menu_type']); + if($new_menu[$menu_count]['type'] == 'view'){ + $new_menu[$menu_count]['url'] = $v['we_menu_typeval']; + }else{ + $new_menu[$menu_count]['key'] = $v['we_menu_typeval']; + } + } + $menu_count++; + } + //生成 + $menu = $this->app->menu; + //先删除现有的 + $menu->destroy(); + //再创建 + $return=$menu->add($new_menu); + $return=json_decode($return,true); + if($return['errcode'] == 0){ + $this->success('菜单已成功生成',url('wechat/We/menu_list')); + }else{ + $this->error('生成失败,错误:'.$return['errcode'],url('wechat/We/menu_list')); + } + } + //同步服务端菜单到本地数据库 + public function menu_get() + { + $menu = $this->app->menu; + $menus=$menu->current(); + $we_menu=Db::name('we_menu'); + if($menus['selfmenu_info']['button']){ + $we_menu->where('we_menu_id','gt',0)->delete(); + } + $i=10; + foreach($menus['selfmenu_info']['button'] as $v){ + //1级菜单 + $name=$v['name']; + if(!empty($v['sub_button'])){ + //先插入数据库获得主键 + $sldata=array( + 'we_menu_leftid'=>0, + 'we_menu_name'=>$name, + 'we_menu_type'=>1, + 'we_menu_typeval'=>'', + 'we_menu_order'=>$i, + 'we_menu_open'=>1, + ); + $we_menu_leftid=$we_menu->insertGetId($sldata); + if($we_menu_leftid){ + //2级菜单 + $data=array(); + $j=10; + foreach($v['sub_button']['list'] as $vv){ + $name=$vv['name']; + $type=$vv['type']; + if($type=='click'){ + $typeval=$vv['key']; + }else{ + $typeval=$vv['url']; + } + $data[]=array( + 'we_menu_name'=>$name, + 'we_menu_type'=>($type=='click')?2:(($type=='view')?1:$type), + 'we_menu_typeval'=>$typeval, + 'we_menu_leftid'=>$we_menu_leftid, + 'we_menu_order'=>$j, + 'we_menu_open'=>1 + ); + $j=$j+10; + } + //插入数据库 + $we_menu->insertAll($data); + } + }else{ + $type=$v['type']; + if($type=='click'){ + $typeval=$v['key']; + }else{ + $typeval=$v['url']; + } + //插入数据库 + $sldata=array( + 'we_menu_leftid'=>0, + 'we_menu_name'=>$name, + 'we_menu_type'=>($type=='click')?2:(($type=='view')?1:$type), + 'we_menu_typeval'=>$typeval, + 'we_menu_order'=>$i, + 'we_menu_open'=>1, + ); + $we_menu->insertGetId($sldata); + } + $i=$i+10; + } + $this->success('菜单已同步到数据库',url('wechat/We/menu_list')); + } + //自动回复 + public function reply_list() + { + $reply_list=Db::name('we_reply')->paginate(config('paginate.list_rows')); + $show=$reply_list->render(); + $show=preg_replace("(]*page[=|/](\d+).+?>(.+?)<\/a>)","$2",$show); + $this->assign('reply_list',$reply_list); + $this->assign('page',$show); + if(request()->isAjax()){ + return $this->fetch('ajax_reply_list'); + }else{ + return $this->fetch(); + } + } + public function reply_edit() + { + $we_reply_id=input('we_reply_id'); + $reply=Db::name('we_reply')->where('we_reply_id',$we_reply_id)->find(); + switch($reply['we_reply_type']){ + case 'image': + $we_reply_content=$reply['we_replyimage_mediaid']; + break; + case 'voice': + $we_reply_content=$reply['we_replyvoice_mediaid']; + break; + case 'news': + $we_reply_content=json_decode($reply['we_replynews'],true); + break; + default: + $we_reply_content=$reply['we_replytext_content']; + break; + } + $reply['we_reply_content']=$we_reply_content; + $reply['code']=1; + return json($reply); + } + public function reply_runedit() + { + if(!request()->isAjax()){ + $this->error('提交方式不正确'); + }else{ + //回复内容 + $we_reply_type=input('we_reply_type','text'); + $field_content='we_replytext_content'; + switch($we_reply_type){ + case 'image': + $field_content='we_replyimage_mediaid'; + $we_reply_content=input('we_reply_content'); + break; + case 'voice': + $field_content='we_replyvoice_mediaid'; + $we_reply_content=input('we_reply_content'); + break; + case 'news': + $field_content='we_replynews'; + $news_array=array( + 'title' => input('news_title',''), + 'description' => input('news_description',''), + 'url' => input('news_url',''), + 'image' => input('news_image',''), + ); + $we_reply_content=json_encode($news_array); + break; + default: + $we_reply_content=input('we_reply_content'); + break; + } + $sldata=array( + 'we_reply_key'=>input('we_reply_key'), + 'we_reply_type'=>$we_reply_type, + $field_content=>$we_reply_content, + 'we_reply_open'=>input('we_reply_open',0), + ); + $rst=Db::name('we_reply')->where('we_reply_id',input('we_reply_id'))->update($sldata); + if($rst!==false){ + $this->success('关键词回复编辑成功',url('wechat/We/reply_list')); + }else{ + $this->error('关键词回复编辑失败',url('wechat/We/reply_list')); + } + } + } + public function reply_runadd() + { + if(!request()->isAjax()){ + $this->error('提交方式不正确'); + }else{ + //回复内容 + $we_reply_type=input('we_reply_type','text'); + $field_content='we_replytext_content'; + switch($we_reply_type){ + case 'image': + $field_content='we_replyimage_mediaid'; + $we_reply_content=input('we_reply_content'); + break; + case 'voice': + $field_content='we_replyvoice_mediaid'; + $we_reply_content=input('we_reply_content'); + break; + case 'news': + $field_content='we_replynews'; + $news_array=array( + 'title' => input('news_title',''), + 'description' => input('news_description',''), + 'url' => input('news_url',''), + 'image' => input('news_image',''), + ); + $we_reply_content=json_encode($news_array); + break; + default: + $we_reply_content=input('we_reply_content'); + break; + } + $sldata=array( + 'we_reply_key'=>input('we_reply_key'), + 'we_reply_type'=>$we_reply_type, + $field_content=>$we_reply_content, + 'we_reply_open'=>input('we_reply_open',0), + 'we_reply_addtime'=>time() + ); + $rst=Db::name('we_reply')->insert($sldata); + if($rst!==false){ + $this->success('关键词回复添加成功',url('wechat/We/reply_list')); + }else{ + $this->error('关键词回复添加失败',url('wechat/We/reply_list')); + } + } + } + public function reply_state() + { + $id=input('x'); + $we_reply=Db::name('we_reply'); + $statusone=$we_reply->where('we_reply_id',$id)->value('we_reply_open'); + if($statusone==1){ + $statedata = array('we_reply_open'=>0); + $we_reply->where('we_reply_id',$id)->setField($statedata); + $this->success('状态禁止'); + }else{ + $statedata = array('we_reply_open'=>1); + $we_reply->where('we_reply_id',$id)->setField($statedata); + $this->success('状态开启'); + } + } + //全选删除 + public function reply_alldel() + { + $p = input('p'); + $ids = input('we_reply_id/a'); + if(empty($ids)){ + $this -> error("请选择删除的关键词回复",url('wechat/We/reply_list',array('p'=>$p))); + } + if(!is_array($ids)){ + $ids[]=$ids; + } + $rst=Db::name('we_reply')->where('we_reply_id','in',$ids)->delete(); + if($rst!==false){ + $this->success("关键词回复删除成功",url('wechat/We/reply_list',array('p'=>$p))); + }else{ + $this -> error("关键词回复删除失败",url('wechat/We/reply_list',array('p'=>$p))); + } + } + public function reply_del() + { + $p=input('p'); + $we_reply_id=input('we_reply_id'); + $rst=Db::name('we_reply')->where('we_reply_id',$we_reply_id)->delete(); + if($rst!==false){ + $this->success('关键词回复删除成功',url('wechat/We/reply_list',array('p'=>$p))); + }else{ + $this->error('关键词回复删除失败',url('wechat/We/reply_list',array('p'=>$p))); + } + } + public function mats_list() + { + $mats_list=Db::name('we_mats')->paginate(config('paginate.list_rows')); + $show=$mats_list->render(); + $show=preg_replace("(]*page[=|/](\d+).+?>(.+?)<\/a>)","$2",$show); + $this->assign('mats_list',$mats_list); + $this->assign('page',$show); + if(request()->isAjax()){ + return $this->fetch('ajax_mats_list'); + }else{ + return $this->fetch(); + } + } + //同步服务端素材到本地数据库 + public function mats_get() + { + $mats=Db::name('we_mats'); + $material = $this->app->material; + $types=array('image','video','voice','news'); + $data=array(); + foreach($types as $type){ + $lists = $material->lists($type, 0, 20); + $lists=json_decode($lists,true); + if(!isset($lists['item'])){ + continue; + } + $total_count=$lists['total_count']; + foreach($lists['item'] as $item){ + foreach($item['content']['news_item'] as $key=>$news_item){ + $sldata=array( + 'mats_name'=>($type=='news')?$news_item['title']:$item['name'], + 'mats_type'=>$type, + 'media_id'=>$item['media_id'], + 'update_time'=>$item['update_time'], + 'create_time'=>$item['update_time'], + 'news_content'=>($type=='news')?json_encode($news_item):'', + 'news_index'=>($type=='news')?$key:0, + 'url'=>($type=='news')?'':(isset($item['url'])?$item['url']:''), + ); + $data[]=$sldata; + } + } + $i=1; + $total_count=$total_count-20; + while($total_count>0){ + $start=$i*20-1; + $lists = $material->lists($type, $start, 20); + $lists=json_decode($lists,true); + if(!isset($lists['item'])){ + continue; + } + foreach($lists['item'] as $item){ + foreach($item['content']['news_item'] as $key=>$news_item){ + $sldata=array( + 'mats_name'=>($type=='news')?$news_item['title']:$item['name'], + 'mats_type'=>$type, + 'media_id'=>$item['media_id'], + 'update_time'=>$item['update_time'], + 'create_time'=>$item['update_time'], + 'news_content'=>($type=='news')?json_encode($news_item):'', + 'news_index'=>($type=='news')?$key:0, + 'url'=>($type=='news')?'':(isset($item['url'])?$item['url']:''), + ); + $data[]=$sldata; + } + } + $total_count=$total_count-20; + $i++; + } + } + $mats->insertAll($data); + $this->success('同步素材列表成功',url('wechat/We/mats_list')); + } + public function mats_edit() + { + $mats_id=input('mats_id'); + $mats_list=Db::name('we_mats')->find($mats_id); + $mats_list['news_content']=json_decode($mats_list['news_content'],true); + $mats_list['video_content']=json_decode($mats_list['video_content'],true); + $this->assign('mats_list',$mats_list); + return $this->fetch(); + } + public function mats_runedit() + { + $mats_id=input('mats_id'); + $news_index=input('news_index',0,'intval'); + $mats_list_old=Db::name('we_mats')->find($mats_id); + $mats_content_old=json_decode($mats_list_old['news_content'],true); + $title=input('mats_title'); + $mats_author=input('mats_author'); + $mats_digest=input('mats_digest'); + $mats_content_source_url=input('mats_content_source_url'); + $mats_thumb_media_id=input('mats_thumb_media_id'); + $mats_show_cover_pic=input('mats_show_cover_pic',0,'intval'); + $mats_content=htmlspecialchars_decode(input('mats_content')); + //比较是否有修改 + if($title!=$mats_content_old['title'] || $mats_author!=$mats_content_old['author'] || $mats_digest!=$mats_content_old['digest'] || $mats_content_source_url!=$mats_content_old['content_source_url'] || $mats_thumb_media_id!=$mats_content_old['thumb_media_id'] || $mats_show_cover_pic!=$mats_content_old['show_cover_pic'] || $mats_content!=$mats_content_old['content']){ + $new_data=array( + 'title'=> $title, + 'thumb_media_id' => $mats_thumb_media_id, + 'author' => $mats_author, + 'digest' => $mats_digest, + 'show_cover_pic' => $mats_show_cover_pic, + 'content_source_url' => $mats_content_source_url, + 'content' => $mats_content + ); + $result = $this->app->material->updateArticle($mats_list_old['media_id'], $new_data,$news_index); + $result=json_decode($result,true); + if(isset($result['errcode']) && $result['errcode']==0){ + //修改本地 + $mats_content_old=array_merge($mats_content_old,$new_data); + $sldata=array( + 'mats_name'=>$title, + 'news_content'=>json_encode($mats_content_old), + 'update_time'=>time() + ); + Db::name('we_mats')->where('mats_id',$mats_id)->update($sldata); + $this->success('修改成功',url('wechat/We/mats_list')); + }else{ + $this->error('修改失败',url('wechat/We/mats_list')); + } + }else{ + $this->success('未修改,直接返回',url('wechat/We/mats_list')); + } + } + public function mats_add() + { + return $this->fetch(); + } + public function mats_runadd() + { + $mats_type=input('mats_type'); + $mats_name=input('mats_name'); + if($mats_type=='news'){ + $mediaId=''; + $show_cover_pic=input('show_cover_pic',0,'intval'); + $file=request()->file('news_thumb'); + if($file && $show_cover_pic){ + $info = $file->rule('uniqid')->move(ROOT_PATH . config('upload_path') . DS . date('Y-m-d')); + if($info) { + $file_url=ROOT_PATH.config('upload_path'). '/' . date('Y-m-d') . '/' . $info->getFilename(); + //上传微信 + $material = $this->app->material; + $result = $material->uploadThumb($file_url,input('video_title'),input('video_introduction')); + $mediaId = $result->media_id; + if($mediaId){ + }else{ + $file = null; + @unlink($file_url); + $this->error('上传微信平台失败',url('wechat/We/mats_list')); + } + }else{ + $this->error($file->getError(),url('wechat/We/mats_list')); + } + } + //加入素材数据库 + $new_data=array( + 'title'=> input('news_title'), + 'thumb_media_id' => $mediaId, + 'author' => input('news_author'), + 'digest' => input('news_digest'), + 'show_cover_pic' => $show_cover_pic, + 'content_source_url' => input('content_source_url'), + 'content' => htmlspecialchars_decode(input('mats_content')) + ); + //上传图文素材 + $article = new Article($new_data); + $result=$this->app->material->uploadArticle($article); + $mediaId = $result->media_id; + if($mediaId){ + $sldata=array( + 'mats_name'=>$mats_name, + 'mats_type'=>$mats_type, + 'media_id'=>$mediaId, + 'news_content'=>json_encode($new_data), + 'create_time'=>time(), + 'update_time'=>time() + ); + Db::name('we_mats')->insert($sldata); + $this->success('上传成功',url('wechat/We/mats_list')); + }else{ + $this->error('上传微信平台失败',url('wechat/We/mats_list')); + } + }else{ + $url=$mediaId=''; + $file=request()->file('mats_file'); + if($file){ + $info = $file->rule('uniqid')->move(ROOT_PATH . config('upload_path') . DS . date('Y-m-d')); + if($info) { + $file_url=ROOT_PATH.config('upload_path'). '/' . date('Y-m-d') . '/' . $info->getFilename(); + //上传微信 + $material = $this->app->material; + switch ($mats_type){ + case 'voice': + $result = $material->uploadVoice($file_url); + $mediaId = $result->media_id; + break; + case 'video': + $result = $material->uploadVideo($file_url,input('video_title'),input('video_introduction')); + $mediaId = $result->media_id; + break; + case 'thumb': + $result = $material->uploadThumb($file_url,input('video_title'),input('video_introduction')); + $mediaId = $result->media_id; + break; + default : + $result = $material->uploadImage($file_url,input('video_title'),input('video_introduction')); + $mediaId = $result->media_id; + $url = $result->url; + break; + } + if($mediaId){ + if($mats_type=='image'){ + $data['mtime']=time(); + $data['url']=$url; + Db::name('we_pic')->insert($data); + } + //加入素材数据库 + $sldata=array( + 'mats_name'=>$mats_name, + 'mats_type'=>$mats_type, + 'media_id'=>$mediaId, + 'url'=>$url, + 'create_time'=>time(), + 'update_time'=>time() + ); + if($mats_type=='video'){ + $sldata['video_content']=json_encode(['title'=>input('video_title'),'introduction'=>input('video_introduction')]); + } + Db::name('we_mats')->insert($sldata); + $file = null; + @unlink($file_url); + $this->success('上传成功',url('wechat/We/mats_list')); + }else{ + $file = null; + @unlink($file_url); + $this->error('上传微信平台失败',url('wechat/We/mats_list')); + } + }else{ + $this->error($file->getError(),url('wechat/We/mats_list')); + } + }else{ + $this->error('文件上传失败',url('wechat/We/mats_list')); + } + } + } + public function mats_del() + { + $mats_id=input('mats_id'); + $mast_list=Db::name('we_mats')->find($mats_id); + if(empty($mast_list)){ + $this->error('不存在此素材',url('wechat/We/mats_list')); + } + $mediaId=$mast_list['media_id']; + $result=$this->app->material->delete($mediaId); + $result=json_decode($result,true); + if(isset($result['errcode']) && $result['errcode']==0){ + Db::name('we_mats')->delete($mats_id); + $this->success('素材删除成功',url('wechat/We/mats_list')); + }else{ + $this->error('素材删除失败',url('wechat/We/mats_list')); + } + } + public function mats_alldel() + { + $mats_ids=input('mats_id_id/a'); + if(!is_array($mats_ids)){ + $mats_ids[]=$mats_ids; + } + foreach ($mats_ids as $mats_id){ + $mast_list=Db::name('we_mats')->find($mats_id); + if(empty($mast_list)){ + continue; + } + $mediaId=$mast_list['media_id']; + $result=$this->app->material->delete($mediaId); + $result=json_decode($result,true); + if(isset($result['errcode']) && $result['errcode']==0){ + Db::name('we_mats')->delete($mats_id); + }else{ + continue; + } + } + $this->success('素材删除成功',url('wechat/We/mats_list')); + } +} \ No newline at end of file diff --git a/app/wechat/controller/WeBase.php b/app/wechat/controller/WeBase.php new file mode 100644 index 0000000..5c3838a --- /dev/null +++ b/app/wechat/controller/WeBase.php @@ -0,0 +1,90 @@ + +// +---------------------------------------------------------------------- +namespace app\wechat\controller; + +use app\admin\controller\Base; +use EasyWeChat\Foundation\Application; + +class WeBase extends Base +{ + //微信平台 + protected $options=[ + /** + * Debug 模式,bool 值:true/false + * + * 当值为 false 时,所有的日志都不会记录 + */ + 'debug' => true, + /** + * 账号基本信息,请从微信公众平台/开放平台获取 + */ + 'app_id' => '', + 'secret' => '', + 'token' => '', + 'aes_key' => '', + 'we_name'=>'', + 'we_id'=>'', + 'we_number'=>'', + 'we_type'=>1, + /** + * 日志配置 + * + * level: 日志级别, 可选为: + * debug/info/notice/warning/error/critical/alert/emergency + * permission:日志文件权限(可选),默认为null(若为null值,monolog会取0644) + * file:日志文件位置(绝对路径!!!),要求可写权限 + */ + 'log' => [ + 'level' => 'debug', + 'permission' => 0777, + 'file' => './data/runtime/temp/easywechat.log', + ], + /** + * OAuth 配置 + * + * scopes:公众平台(snsapi_userinfo / snsapi_base),开放平台:snsapi_login + * callback:OAuth授权完成后的回调页地址 + */ + 'oauth' => [ + 'scopes' => ['snsapi_userinfo'], + 'callback' => '/examples/oauth_callback.php', + ], + /** + * 微信支付 + */ + 'payment' => [ + 'merchant_id' => 'your-mch-id', + 'key' => 'key-for-signature', + 'cert_path' => 'path/to/your/cert.pem', // XXX: 绝对路径!!!! + 'key_path' => 'path/to/your/key', // XXX: 绝对路径!!!! + // 'device_info' => '013467007045764', + // 'sub_app_id' => '', + // 'sub_merchant_id' => '', + // ... + ], + /** + * Guzzle 全局设置 + * + * 更多请参考: http://docs.guzzlephp.org/en/latest/request-options.html + */ + 'guzzle' => [ + 'timeout' => 300.0, // 超时时间(秒) + //'verify' => false, // 关掉 SSL 认证(强烈不建议!!!) + ], + ]; + public $app; + public function _initialize() + { + parent::_initialize(); + //微信平台 + $config=config('we_options'); + if(!empty($config)) $this->options=array_merge($this->options,$config); + $this->app = new Application($this->options); + } +} \ No newline at end of file diff --git a/app/wechat/view/we/ajax_mats_list.html b/app/wechat/view/we/ajax_mats_list.html new file mode 100644 index 0000000..c243172 --- /dev/null +++ b/app/wechat/view/we/ajax_mats_list.html @@ -0,0 +1,91 @@ +{foreach name="mats_list" item="v"} + + + + + + {if condition="in_array($v.mats_type,['news','image','video'])"} + + {/if} + + {$v.mats_id} + {$v.mats_name} + {$v.mats_type} + {$v.media_id} + {if condition="$v['mats_type'] eq 'news'"}{$v.news_index}{/if} + {$v.create_time|date='Y-m-d',###} + + + + + + {if condition="in_array($v.mats_type,['news','image','video'])"} + + +
+ {switch name="v['mats_type']" } + {case value="news"} + +
+ +
+ {/case} + {case value="video"} + +
+ +
+ {/case} + {default /} + +
{$v.url}
+ {/switch} +
+ + + {/if} +{/foreach} + +   + {$page} + diff --git a/app/wechat/view/we/ajax_menu_list.html b/app/wechat/view/we/ajax_menu_list.html new file mode 100644 index 0000000..c052768 --- /dev/null +++ b/app/wechat/view/we/ajax_menu_list.html @@ -0,0 +1,68 @@ +{foreach name="menu" item="v"} + + + {$v.we_menu_id} + {$v.lefthtml}{$v.we_menu_name} + {if condition="$v.we_menu_type eq 1"}URL菜单链接{else /}关键词回复菜单{/if} + {$v.we_menu_typeval} + + {if condition="$v['we_menu_open'] eq 1"} + +
+
+ {else/} + +
+
+ {/if} + + + + + + +{/foreach} + + + diff --git a/app/wechat/view/we/ajax_reply_list.html b/app/wechat/view/we/ajax_reply_list.html new file mode 100644 index 0000000..30decae --- /dev/null +++ b/app/wechat/view/we/ajax_reply_list.html @@ -0,0 +1,93 @@ +{foreach name="reply_list" item="v"} + + + + + {$v.we_reply_id} + {$v.we_reply_key} + {$v.we_reply_type} + {switch name="v['we_reply_type']" } + {case value="news"} + {$v.we_replynews|subtext=40} + + + + Details + + + + {/case} + {case value="image"} + {$v.we_replyimage_mediaid} + {/case} + {case value="voice"} + {$v.we_replyvoice_mediaid} + {/case} + {default /} + {$v.we_replytext_content} + {/switch} + {$v.we_reply_addtime|date='Y-m-d H:i:s',###} + + {if condition="$v['we_reply_open'] eq 1"} + +
+
+ {else/} + +
+
+ {/if} + + + + + + + {if condition="$v['we_reply_type'] eq 'news'"} + + +
+ +
+ +
+
+ + + {/if} +{/foreach} + +   + {$page} + diff --git a/app/wechat/view/we/mats_add.html b/app/wechat/view/we/mats_add.html new file mode 100644 index 0000000..24b7efe --- /dev/null +++ b/app/wechat/view/we/mats_add.html @@ -0,0 +1,229 @@ +{extend name="admin@public/base" /} +{block name="main-content"} +
+ + +
+
+
+
+ +
+ +
+
+
+
+ +
+ + + + +
+
+
+
+
+ +
+ + + + +
+
+
+
+ +
+ + + + +
+
+
+
+
+
+ +
+ + +
+
+
+
+
+
+ +
+ + + + +
+
+
+
+ +
+ + + + +
+
+
+
+ +
+ + + + +
+
+
+
+ +
+ + + + +
+
+
+
+ +
+ +   默认不显示 +
+
+
+
+
+ +
+ + +
+
+
+
+
+ +
+ + + + +
+
+
+
+
+
+ + +       + +
+
+
+ +
+
+{/block} +{block name="scripts"} + +{/block} diff --git a/app/wechat/view/we/mats_edit.html b/app/wechat/view/we/mats_edit.html new file mode 100644 index 0000000..cf3a535 --- /dev/null +++ b/app/wechat/view/we/mats_edit.html @@ -0,0 +1,115 @@ +{extend name="admin@public/base" /} +{block name="main-content"} +
+ + +
+
+
+ + + +
+ +
+ + + + +
+
+
+
+ +
+ + + + +
+
+
+
+ +
+ + + + +
+
+
+
+ +
+ + + + +
+
+
+
+ +
+ + + + +
+
+
+
+ +
+ + + + +
+
+
+
+ +
+ +   默认不显示 +
+
+
+
+
+ + +       + +
+
+
+ +
+
+{/block} +{block name="scripts"} + +{/block} diff --git a/app/wechat/view/we/mats_list.html b/app/wechat/view/we/mats_list.html new file mode 100644 index 0000000..fc73c50 --- /dev/null +++ b/app/wechat/view/we/mats_list.html @@ -0,0 +1,53 @@ +{extend name="admin@public/base" /} +{block name="main-content"} +
+ +
+
+
+
+ + + + + + + + + + + + + + + + + {include file="we/ajax_mats_list"/} + +
详情ID素材名素材类型素材ID索引操作
+
+
+
+
+
+{/block} \ No newline at end of file diff --git a/app/wechat/view/we/menu_list.html b/app/wechat/view/we/menu_list.html new file mode 100644 index 0000000..e1f67b7 --- /dev/null +++ b/app/wechat/view/we/menu_list.html @@ -0,0 +1,237 @@ +{extend name="admin@public/base" /} +{block name="main-content"} +
+
+
+ + + + + + + +
+
+
+
+
+
+ + + + + + + + + + + + + + + {include file="we/ajax_menu_list"/} + +
排序ID菜单标题类型操作值开启状态操作
+
+
+
+
+ + + + +
+{/block} diff --git a/app/wechat/view/we/reply_list.html b/app/wechat/view/we/reply_list.html new file mode 100644 index 0000000..b7add46 --- /dev/null +++ b/app/wechat/view/we/reply_list.html @@ -0,0 +1,270 @@ +{extend name="admin@public/base" /} +{block name="main-content"} +
+
+
+ +
+
+
+
+
+
+ + + + + + + + + + + + + + + + {include file="we/ajax_reply_list"/} + +
ID关键词回复类型回复内容/素材ID开启状态操作
+
+
+
+
+ + + + +
+{/block} +{block name="scripts"} + +{/block} \ No newline at end of file diff --git a/app/wechat/view/we/wesys.html b/app/wechat/view/we/wesys.html new file mode 100644 index 0000000..a87c53f --- /dev/null +++ b/app/wechat/view/we/wesys.html @@ -0,0 +1,140 @@ +{extend name="admin@public/base" /} +{block name="main-content"} +
+ + + + + +
+
+
+
+ +
+ +   *必填 + + + +
+
+
+ +
+ +
+ +   *必填 + + + +
+
+
+ +
+ +
+ +   *必填 + + + +
+
+
+ +
+ +
+ + + + +
+
+
+ +
+ +
+ + + + +
+
+
+
+ +
+ + + + +
+
+
+
+ +
+ + + + +
+
+
+
+ +
+ + + + +
+
+
+
+ +
+ 微信公众平台URL设置:http://youdomain/wechat/index/index.html +
+ 微信公众平台Token设置:任意设置,与微信公众平台设置一致即可 +
+
+
+
+ + +       + +
+
+
+
+
+ +
+{/block}