优化消息模块,支持发送系统消息,优化行为记录类型。

This commit is contained in:
hdm 2021-12-14 00:35:34 +08:00
parent f7c7b3e745
commit 47a3a922a1
39 changed files with 1138 additions and 383 deletions

View File

@ -7,7 +7,7 @@
declare (strict_types = 1);
namespace app\home;
namespace app\base;
use think\App;
use think\exception\HttpResponseException;
@ -53,9 +53,9 @@ abstract class BaseController
*/
public function __construct(App $app)
{
$this->module = strtolower(app('http')->getName());
$this->app = $app;
$this->request = $this->app->request;
$this->module = strtolower(app('http')->getName());
$this->controller = strtolower($this->request->controller());
$this->action = strtolower($this->request->action());
$this->uid = 0;

View File

@ -102,6 +102,39 @@ function format_bytes($size, $delimiter = '')
return round($size, 2) . $delimiter . $units[$i];
}
/**
* 截取字符串
* @param $start 开始截取位置
* @param $length 截取长度
* @return
*/
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));
}
if (utf8_strlen($str) < $length) $suffix = false;
return $suffix ? $slice . '...' : $slice;
}
function utf8_strlen($string = null)
{
preg_match_all("/./us", $string, $match);
return count($match[0]);
}
/**
* PHP截取文字长度
* @return string
@ -319,6 +352,161 @@ function table_assign($code = 0, $msg = '请求成功', $data = [], $httpCode =
throw new \think\exception\HttpResponseException($response);
}
/**
* 人民币转大写
* @param
*/
function cny($ns)
{
static $cnums = array("", "", "", "", "", "", "", "", "", ""),
$cnyunits = array("", "", ""),
$grees = array("", "", "", "", "", "", "", "亿");
list($ns1, $ns2) = explode(".", $ns, 2);
$ns2 = array_filter(array($ns2[1], $ns2[0]));
$ret = array_merge($ns2, array(implode("", _cny_map_unit(str_split($ns1), $grees)), ""));
$ret = implode("", array_reverse(_cny_map_unit($ret, $cnyunits)));
return str_replace(array_keys($cnums), $cnums, $ret);
}
function _cny_map_unit($list, $units)
{
$ul = count($units);
$xs = array();
foreach (array_reverse($list) as $x) {
$l = count($xs);
if ($x != "0" || !($l % 4)) {
$n = ($x == '0' ? '' : $x) . ($units[($l - 1) % $ul]);
} else {
$n = is_numeric($xs[0][0]) ? $x : '';
}
array_unshift($xs, $n);
}
return $xs;
}
/**
* 金额展示规则,超过1万时以万为单位低于1万时以千为单位低于1千时以元为单位
* @param string $money 金额
* @return string
*/
function format_money($money)
{
$data = '0元';
if (($money / 10000) > 1) {
$data = is_int($money / 10000) ? ($money / 10000) . '万' : rand(($money / 10000), 2) . '万';
} elseif (($money / 1000) > 1) {
$data = is_int($money / 1000) ? ($money / 1000) . '千' : rand(($money / 1000), 2) . '千';
} else {
$data = $money . '元';
}
return $data;
}
/**
* 数组转换字符串(以逗号隔开)
* @param
* @return
*/
function arrayToString($array)
{
if (!is_array($array)) {
$data_arr[] = $array;
} else {
$data_arr = $array;
}
$data_arr = array_filter($data_arr); //数组去空
$data_arr = array_unique($data_arr); //数组去重
$data_arr = array_merge($data_arr);
$string = $data_arr ? ',' . implode(',', $data_arr) . ',' : '';
return $string ?: '';
}
/**
* 字符串转换数组(以逗号隔开)
* @param
* @return
*/
function stringToArray($string)
{
if (is_array($string)) {
$data_arr = array_unique(array_filter($string));
} else {
$data_arr = $string ? array_unique(array_filter(explode(',', $string))) : [];
}
$data_arr = $data_arr ? array_merge($data_arr) : [];
return $data_arr ?: [];
}
/**
* 二维数组排序(选择)
* @param $select 要进行排序的select结果集
* @param $field 排序的字段
* @param $order 排序方式1降序2升序
*/
function sort_select($select = array(), $field, $order = 1)
{
$count = count($select);
if ($order == 1) {
for ($i = 0; $i < $count; $i++) {
$k = $i;
for ($j = $i; $j < $count; $j++) {
if ($select[$k][$field] < $select[$j][$field]) {
$k = $j;
}
}
$temp = $select[$i];
$select[$i] = $select[$k];
$select[$k] = $temp;
}
return $select;
} else {
for ($i = 0; $i < $count; $i++) {
$k = $i;
for ($j = $i; $j < $count; $j++) {
if ($select[$k][$field] > $select[$j][$field]) {
$k = $j;
}
}
$temp = $select[$i];
$select[$i] = $select[$k];
$select[$k] = $temp;
}
return $select;
}
}
/**
* fullcalendar日历控件方法1
*/
function parseDateTime($string, $timeZone=null) {
$date = new DateTime(
$string,
$timeZone ? $timeZone : new DateTimeZone('UTC')
);
if ($timeZone) {
$date->setTimezone($timeZone);
}
return $date;
}
/**
* fullcalendar日历控件方法2
*/
function stripTime($datetime) {
return new DateTime($datetime->format('Y-m-d'));
}
/**
* 根据时间戳获取星期几
* @param $time 要转换的时间戳
*/
function getTimeWeek($time, $i = 0)
{
$weekarray = array("", "", "", "", "", "", "");
$oneD = 24 * 60 * 60;
return "星期" . $weekarray[date("w", $time + $oneD * $i)];
}
/**
* 时间戳格式化
* @param int $time
@ -336,20 +524,312 @@ function time_format($time = NULL, $format = 'Y-m-d H:i:s')
return $time != '' ? str_replace('x', $sec, date($format, intval($usec))) : '';
}
function parseDateTime($string, $timeZone=null) {
$date = new DateTime(
$string,
$timeZone ? $timeZone : new DateTimeZone('UTC')
);
if ($timeZone) {
$date->setTimezone($timeZone);
}
return $date;
/**
* 将秒数转换为时间 (年、天、小时、分、秒)
* @param
*/
function getTimeBySec($time)
{
if (is_numeric($time)) {
$value = array(
"years" => 0, "days" => 0, "hours" => 0,
"minutes" => 0, "seconds" => 0,
);
if ($time >= 31556926) {
$value["years"] = floor($time / 31556926);
$time = ($time % 31556926);
$t .= $value["years"] . "";
}
if ($time >= 86400) {
$value["days"] = floor($time / 86400);
$time = ($time % 86400);
$t .= $value["days"] . "";
}
if ($time >= 3600) {
$value["hours"] = floor($time / 3600);
$time = ($time % 3600);
$t .= $value["hours"] . "小时";
}
if ($time >= 60) {
$value["minutes"] = floor($time / 60);
$time = ($time % 60);
$t .= $value["minutes"] . "分钟";
}
if ($time < 60) {
$value["seconds"] = floor($time);
$t .= $value["seconds"] . "";
}
return $t;
} else {
return (bool)FALSE;
}
}
/*
*根据年月计算有几天
*/
function getmonthByYM($param)
{
$month = $param['month'] ? $param['month'] : date('m', time());
$year = $param['year'] ? $param['year'] : date('Y', time());
if (in_array($month, array('1', '3', '5', '7', '8', '01', '03', '05', '07', '08', '10', '12'))) {
$days = '31';
} elseif ($month == 2) {
if ($year % 400 == 0 || ($year % 4 == 0 && $year % 100 !== 0)) {
//判断是否是闰年
$days = '29';
} else {
$days = '28';
}
} else {
$days = '30';
}
return $days;
}
function stripTime($datetime) {
return new DateTime($datetime->format('Y-m-d'));
/**
* 根据时间戳计算当月天数
* @param
*/
function getmonthdays($time)
{
$month = date('m', $time);
$year = date('Y', $time);
if (in_array($month, array('1', '3', '5', '7', '8', '01', '03', '05', '07', '08', '10', '12'))) {
$days = '31';
} elseif ($month == 2) {
if ($year % 400 == 0 || ($year % 4 == 0 && $year % 100 !== 0)) {
//判断是否是闰年
$days = '29';
} else {
$days = '28';
}
} else {
$days = '30';
}
return $days;
}
/**
* 生成从开始时间到结束时间的日期数组
* @param type默认时间戳格式
* @param type = 1 date格式
* @param type = 2 时,获取每日开始、结束时间
*/
function dateList($start, $end, $type = 0)
{
if (!is_numeric($start) || !is_numeric($end) || ($end <= $start)) return '';
$i = 0;
//从开始日期到结束日期的每日时间戳数组
$d = array();
if ($type == 1) {
while ($start <= $end) {
$d[$i] = date('Y-m-d', $start);
$start = $start + 86400;
$i++;
}
} else {
while ($start <= $end) {
$d[$i] = $start;
$start = $start + 86400;
$i++;
}
}
if ($type == 2) {
$list = array();
foreach ($d as $k => $v) {
$list[$k] = getDateRange($v);
}
return $list;
} else {
return $d;
}
}
/**
* 获取指定日期开始时间与结束时间
*/
function getDateRange($timestamp)
{
$ret = array();
$ret['sdate'] = strtotime(date('Y-m-d', $timestamp));
$ret['edate'] = strtotime(date('Y-m-d', $timestamp)) + 86400;
return $ret;
}
/**
* 生成从开始月份到结束月份的月份数组
* @param int $start 开始时间戳
* @param int $end 结束时间戳
*/
function monthList($start, $end)
{
if (!is_numeric($start) || !is_numeric($end) || ($end <= $start)) return '';
$start = date('Y-m', $start);
$end = date('Y-m', $end);
//转为时间戳
$start = strtotime($start . '-01');
$end = strtotime($end . '-01');
$i = 0;
$d = array();
while ($start <= $end) {
//这里累加每个月的的总秒数 计算公式上一月1号的时间戳秒数减去当前月的时间戳秒数
$d[$i] = $start;
$start += strtotime('+1 month', $start) - $start;
$i++;
}
return $d;
}
/**
* 等于(时间段)数据处理
*
* @param $data
* @return array
* @since 2021-06-11
* @author fanqi
*/
function advancedDate($data)
{
// 本年度
if ($data['value'][0] == 'year') {
$arrTime = DataTime::year();
$data['value'][0] = date('Y-m-d 00:00:00', $arrTime[0]);
$data['value'][1] = date('Y-m-d 23:59:59', $arrTime[1]);
}
// 上一年度
if ($data['value'][0] == 'lastYear') {
$data['value'][0] = date('Y-m-d 00:00:00', strtotime(date('Y-m-d') . '-1 year'));
$data['value'][1] = date('Y-m-d 23:59:59', strtotime(date('Y-m-d') . '-1 year'));
}
// 下一年度
if ($data['value'][0] == 'nextYear') {
$data['value'][0] = date('Y-m-d 00:00:00', strtotime(date('Y-m-d') . '+1 year'));
$data['value'][1] = date('Y-m-d 23:59:59', strtotime(date('Y-m-d') . '+1 year'));
}
// 上半年
if ($data['value'][0] == 'firstHalfYear') {
$data['value'][0] = date('Y-01-01 00:00:00');
$data['value'][1] = date('Y-06-30 23:59:59');
}
// 下半年
if ($data['value'][0] == 'nextHalfYear') {
$data['value'][0] = date('Y-07-01 00:00:00');
$data['value'][1] = date('Y-12-31 23:59:59');
}
// 本季度
if ($data['value'][0] == 'quarter') {
$season = ceil((date('n')) / 3);
$data['value'][0] = date('Y-m-d H:i:s', mktime(0, 0, 0, $season * 3 - 3 + 1, 1, date('Y')));
$data['value'][1] = date('Y-m-d H:i:s', mktime(23, 59, 59, $season * 3, date('t', mktime(0, 0, 0, $season * 3, 1, date("Y"))), date('Y')));
}
// 上一季度
if ($data['value'][0] == 'lastQuarter') {
$season = ceil((date('n')) / 3) - 1;
$data['value'][0] = date('Y-m-d H:i:s', mktime(0, 0, 0, $season * 3 - 3 + 1, 1, date('Y')));
$data['value'][1] = date('Y-m-d H:i:s', mktime(23, 59, 59, $season * 3, date('t', mktime(0, 0, 0, $season * 3, 1, date("Y"))), date('Y')));
}
// 下一季度
if ($data['value'][0] == 'nextQuarter') {
$season = ceil((date('n')) / 3);
$data['value'][0] = date('Y-m-d H:i:s', mktime(0, 0, 0, $season * 3 + 1, 1, date('Y')));
$data['value'][1] = date('Y-m-d H:i:s', mktime(23, 59, 59, $season * 3 + 3, date('t', mktime(0, 0, 0, $season * 3, 1, date("Y"))), date('Y')));
}
// 本月
if ($data['value'][0] == 'month') {
$data['value'][0] = date('Y-m-01 00:00:00');
$data['value'][1] = date('Y-m-31 23:59:59');
}
// 上月
if ($data['value'][0] == 'lastMonth') {
$data['value'][0] = date('Y-m-01 00:00:00', strtotime(date('Y-m-d') . '-1 month'));
$data['value'][1] = date('Y-m-31 23:59:59', strtotime(date('Y-m-d') . '-1 month'));
}
// 下月
if ($data['value'][0] == 'nextMonth') {
$data['value'][0] = date('Y-m-01 00:00:00', strtotime(date('Y-m-d') . '+1 month'));
$data['value'][1] = date('Y-m-31 23:59:59', strtotime(date('Y-m-d') . '+1 month'));
}
// 本周
if ($data['value'][0] == 'week') {
$data['value'][0] = date('Y-m-d 00:00:00', mktime(0, 0, 0, date('m'), date('d') - date('w') + 1, date('Y')));
$data['value'][1] = date('Y-m-d 23:59:59', mktime(23, 59, 59, date('m'), date('d') - date('w') + 7, date('Y')));
}
// 上周
if ($data['value'][0] == 'lastWeek') {
$date = date("Y-m-d");
$w = date("w", strtotime($date));
$d = $w ? $w - 1 : 6;
$start = date("Y-m-d", strtotime($date . " - " . $d . " days"));
$data['value'][0] = date('Y-m-d', strtotime($start . " - 7 days"));
$data['value'][1] = date('Y-m-d', strtotime($start . " - 1 days"));
}
// 下周
if ($data['value'][0] == 'nextWeek') {
$date = date("Y-m-d");
$w = date("w", strtotime($date));
$d = $w ? $w - 1 : 6;
$start = date("Y-m-d", strtotime($date . " - " . $d . " days"));
$data['value'][0] = date('Y-m-d', strtotime($start . " + 7 days"));
$data['value'][1] = date('Y-m-d', strtotime($start . " + 13 days"));
}
// 今天
if ($data['value'][0] == 'today') {
$data['value'][0] = date('Y-m-d 00:00:00');
$data['value'][1] = date('Y-m-d 23:59:59');
}
// 昨天
if ($data['value'][0] == 'yesterday') {
$data['value'][0] = date('Y-m-d 00:00:00', strtotime(date('Y-m-d') . '-1 day'));
$data['value'][1] = date('Y-m-d 23:59:59', strtotime(date('Y-m-d') . '-1 day'));
}
// 明天
if ($data['value'][0] == 'tomorrow') {
$data['value'][0] = date('Y-m-d 00:00:00', strtotime(date('Y-m-d') . '+1 day'));
$data['value'][1] = date('Y-m-d 23:59:59', strtotime(date('Y-m-d') . '+1 day'));
}
// 过去7天
if ($data['value'][0] == 'previous7day') {
$data['value'][0] = date('Y-m-d 00:00:00', strtotime(date('Y-m-d') . '-7 day'));
$data['value'][1] = date('Y-m-d 23:59:59', strtotime(date('Y-m-d') . '-1 day'));
}
// 过去30天
if ($data['value'][0] == 'previous30day') {
$data['value'][0] = date('Y-m-d 00:00:00', strtotime(date('Y-m-d') . '-30 day'));
$data['value'][1] = date('Y-m-d 23:59:59', strtotime(date('Y-m-d') . '-1 day'));
}
// 未来7天
if ($data['value'][0] == 'future7day') {
$data['value'][0] = date('Y-m-d 00:00:00', strtotime(date('Y-m-d') . '+1 day'));
$data['value'][1] = date('Y-m-d 23:59:59', strtotime(date('Y-m-d') . '+7 day'));
}
// 未来30天
if ($data['value'][0] == 'future30day') {
$data['value'][0] = date('Y-m-d 00:00:00', strtotime(date('Y-m-d') . '+1 day'));
$data['value'][1] = date('Y-m-d 23:59:59', strtotime(date('Y-m-d') . '+30 day'));
}
return $data;
}
/**
@ -460,15 +940,218 @@ function is_email($user_email)
}
/**
* 验证输入的手机号码是否合法
* @param $mobile_phone 手机号
* @return bool
* 获取客户浏览器类型
*/
function is_mobile_phone($mobile_phone)
function getBrowser()
{
$chars = "/^13[0-9]{1}[0-9]{8}$|15[0-9]{1}[0-9]{8}$|18[0-9]{1}[0-9]{8}$|17[0-9]{1}[0-9]{8}$/";
if (preg_match($chars, $mobile_phone)) {
return true;
$Browser = $_SERVER['HTTP_USER_AGENT'];
if (preg_match('/MSIE/i', $Browser)) {
$Browser = 'MSIE';
} elseif (preg_match('/Firefox/i', $Browser)) {
$Browser = 'Firefox';
} elseif (preg_match('/Chrome/i', $Browser)) {
$Browser = 'Chrome';
} elseif (preg_match('/Safari/i', $Browser)) {
$Browser = 'Safari';
} elseif (preg_match('/Opera/i', $Browser)) {
$Browser = 'Opera';
} else {
$Browser = 'Other';
}
return false;
return $Browser;
}
/**
* 获取客户端系统
*/
function getOS()
{
$agent = $_SERVER['HTTP_USER_AGENT'];
if (preg_match('/win/i', $agent)) {
if (preg_match('/nt 6.1/i', $agent)) {
$OS = 'Windows 7';
} else if (preg_match('/nt 6.2/i', $agent)) {
$OS = 'Windows 8';
} else if (preg_match('/nt 10.0/i', $agent)) {
$OS = 'Windows 10';
} else {
$OS = 'Windows';
}
} elseif (preg_match('/mac/i', $agent)) {
$OS = 'MAC';
} elseif (preg_match('/linux/i', $agent)) {
$OS = 'Linux';
} elseif (preg_match('/unix/i', $agent)) {
$OS = 'Unix';
} elseif (preg_match('/bsd/i', $agent)) {
$OS = 'BSD';
} else {
$OS = 'Other';
}
return $OS;
}
/**
* 根据IP获取地址
*/
function getAddress($ip)
{
$res = file_get_contents("http://ip.360.cn/IPQuery/ipquery?ip=" . $ip);
$res = json_decode($res, 1);
if ($res && $res['errno'] == 0) {
return explode("\t", $res['data'])[0];
} else {
return '';
}
}
/**
* 下载服务器文件
*
* @param string $file 文件路径
* @param string $name 下载名称
* @param boolean $del 下载后删除
* @return void
*/
function download($file, $name = '', $del = false)
{
if (!file_exists($file)) {
return resultArray([
'error' => '文件不存在',
]);
}
// 仅允许下载 public 目录下文件
$res = strpos(realpath($file), realpath('./public'));
if ($res !== 0) {
return resultArray([
'error' => '文件路径错误',
]);
}
$fp = fopen($file, 'r');
$size = filesize($file);
//下载文件需要的头
header("Content-type: application/octet-stream");
header("Accept-Ranges: bytes");
header('ResponseType: blob');
header("Accept-Length: $size");
$file_name = $name != '' ? $name : pathinfo($file, PATHINFO_BASENAME);
// urlencode 处理中文乱码
header("Content-Disposition:attachment; filename=" . urlencode($file_name));
// 导出数据时 csv office Excel 需要添加bom头
if (pathinfo($file, PATHINFO_EXTENSION) == 'csv') {
echo "\xEF\xBB\xBF"; // UTF-8 BOM
}
$fileCount = 0;
$fileUnit = 1024;
while (!feof($fp) && $size - $fileCount > 0) {
$fileContent = fread($fp, $fileUnit);
echo $fileContent;
$fileCount += $fileUnit;
}
fclose($fp);
// 删除
if ($del) @unlink($file);
die();
}
/**
* 导出数据为excel表格
* @param $data 一个二维数组,结构如同从数据库查出来的数组
* @param $title excel的第一行标题,一个数组,如果为空则没有标题
* @param $filename 下载的文件名
* @param exportexcel($arr,array('id','账户','密码','昵称'),'文件名!');
*/
function exportexcel($data = array(), $title = array(), $filename = 'report')
{
header("Content-type:application/octet-stream");
header("Accept-Ranges:bytes");
header("Content-type:application/vnd.ms-excel");
header("Content-Disposition:attachment;filename=" . $filename . ".xls");
header("Pragma: no-cache");
header("Expires: 0");
//导出xls 开始
if (!empty($title)) {
foreach ($title as $k => $v) {
$title[$k] = iconv("UTF-8", "GB2312", $v);
}
$title = implode("\t", $title);
echo "$title\n";
}
if (!empty($data)) {
foreach ($data as $key => $val) {
foreach ($val as $ck => $cv) {
$data[$key][$ck] = iconv("UTF-8", "GB2312", $cv);
}
$data[$key] = implode("\t", $data[$key]);
}
echo implode("\n", $data);
}
}
//根据数据库查询出来数组获取某个字段拼接字符串
function getFieldArray($array = array(), $field = '')
{
if (is_array($array) && $field) {
$ary = array();
foreach ($array as $value) {
$ary[] = $value[$field];
}
$str = implode(',', $ary);
return $str;
} else {
return false;
}
}
/**
* curl 模拟GET请求
* @author lee
***/
function curl_get($url)
{
//初始化
$ch = curl_init();
//设置抓取的url
curl_setopt($ch, CURLOPT_URL, $url);
//设置获取的信息以文件流的形式返回,而不是直接输出。
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); // https请求 不验证证书
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); // https请求 不验证hosts
//执行命令
$output = curl_exec($ch);
curl_close($ch); //释放curl句柄
return $output;
}
/**
* 模拟post进行url请求
* @param string $url
* @param string $param
*/
function curl_post($url = '', $post = array())
{
$curl = curl_init(); // 启动一个CURL会话
curl_setopt($curl, CURLOPT_URL, $url); // 要访问的地址
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0); // 对认证证书来源的检查
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 1); // 从证书中检查SSL加密算法是否存在
curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); // 模拟用户使用的浏览器
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); // 使用自动跳转
curl_setopt($curl, CURLOPT_AUTOREFERER, 1); // 自动设置Referer
curl_setopt($curl, CURLOPT_POST, 1); // 发送一个常规的Post请求
curl_setopt($curl, CURLOPT_POSTFIELDS, $post); // Post提交的数据包
curl_setopt($curl, CURLOPT_TIMEOUT, 30); // 设置超时限制防止死循环
curl_setopt($curl, CURLOPT_HEADER, 0); // 显示返回的Header区域内容
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); // 获取的信息以文件流的形式返回
$res = curl_exec($curl); // 执行操作
if (curl_errno($curl)) {
echo 'Errno' . curl_error($curl);//捕抓异常
}
curl_close($curl); // 关闭CURL会话
return $res; // 返回数据json格式
}

View File

@ -55,9 +55,14 @@ function get_system_config($name, $key = '')
//获取指定管理员的信息
function get_admin($id)
{
$admin = Db::name('Admin')->where(['id' => $id])->find();
$admin['department'] = Db::name('Department')->where(['id' => $admin['did']])->value('title');
$admin['position'] = Db::name('Position')->where(['id' => $admin['position_id']])->value('title');
$admin = Db::name('Admin')
->alias('a')
->field('a.*,d.title as department,p.title as position')
->leftJoin ('Department d ','d.id= a.did')
->leftJoin ('Position p ','p.id= a.position_id')
->where(['a.id' => $id])
->cache(true,60)
->find();
$admin['last_login_time'] = empty($admin['last_login_time']) ? '-' : date('Y-m-d H:i', $admin['last_login_time']);
return $admin;
}
@ -113,7 +118,7 @@ function get_admin_group_info($id)
return $group;
}
//菜单父子关系排序,用于后台菜单
//菜单父子关系排序,用于菜单
function get_admin_menus()
{
$admin = get_login_admin();
@ -134,6 +139,21 @@ function get_admin_menus()
return $list;
}
/**
* 节点权限判断
* @return bool
*/
function check_auth($rule, $uid)
{
$auth_list = Cache::get('RulesSrc' . $uid);
if (!in_array($rule, $auth_list)) {
return false;
} else {
return true;
}
}
//读取部门列表
function get_department()
{
@ -141,7 +161,7 @@ function get_department()
return $department;
}
//获取某部门的子部门id
//获取某部门的子部门id.$is_self时候包含自己
function get_department_son($did = 0, $is_self = 1)
{
$department = get_department();
@ -247,18 +267,52 @@ function get_file($id)
}
/**
* 节点权限判断
* @return bool
* 发送站内信
* @param $user_id 接收人user_id
* @param $data 操作内容
* @param $sysMessage 1为系统消息
* @param $template 消息模板
* @return
*/
function check_auth($rule, $uid)
function sendMessage($user_id, $template, $data=[])
{
$auth_list = Cache::get('RulesSrc' . $uid);
if (!in_array($rule, $auth_list)) {
return false;
$content = get_config('message.template')[$template]['template'];
foreach ($data as $key => $val) {
$content = str_replace('{' . $key . '}', $val, $content);
}
if(isSet($data['from_uid'])){
$content = str_replace('{from_user}', get_admin($data['from_uid'])['name'], $content);
}
$content = str_replace('{date}', date('Y-m-d'), $content);
if (!$user_id) return false;
if (!$content) return false;
if (!is_array($user_id)) {
$users[] = $user_id;
} else {
return true;
$users = $user_id;
}
$users = array_unique(array_filter($users));
//组合要发的消息
$send_data = [];
foreach ($users as $key => $value) {
$send_data[] = array(
'to_uid' => $value,//接收人
'action_id' => $data['action_id'],
'title' => $data['title'],
'content' => $content,
'template' => $template,
'module_name' => strtolower(app('http')->getName()),
'controller_name' => strtolower(app('request')->controller()),
'action_name' => strtolower(app('request')->action()),
'send_time' => time(),
'create_time' => time()
);
}
$res = Db::name('Message')->strict(false)->field(true)->insertAll($send_data);
return $res;
}
/**
* 员工操作日志
* @param string $type 操作类型 login add edit view delete
@ -268,56 +322,10 @@ function check_auth($rule, $uid)
function add_log($type, $param_id = '', $param = [])
{
$action = '未知操作';
switch ($type) {
case 'login':
$action = '登录';
break;
case 'upload':
$action = '上传';
break;
case 'add':
$action = '新增';
break;
case 'edit':
$action = '编辑';
break;
case 'view':
$action = '查看';
break;
case 'save':
$action = '保存';
break;
case 'send':
$action = '发送';
break;
case 'delete':
$action = '删除';
break;
case 'check':
$action = '审核';
break;
case 'leave':
$action = '离职';
break;
case 'disable':
$action = '禁用';
break;
case 'recovery':
$action = '恢复';
break;
case 'apply':
$action = '申请';
break;
case 'open':
$action = '开具';
break;
case 'tovoid':
$action = '作废';
break;
case 'reset':
$action = '重新设置';
break;
}
$type_action = get_config('log.type_action');
if($type_action[$type]){
$action = $type_action[$type];
}
if ($type == 'login') {
$login_admin = Db::name('Admin')->where(array('id' => $param_id))->find();
} else {
@ -331,9 +339,9 @@ function add_log($type, $param_id = '', $param = [])
$data['action'] = $action;
$data['param_id'] = $param_id;
$data['param'] = json_encode($param);
$data['module'] = \think\facade\App::initialize()->http->getName();
$data['module'] = strtolower(app('http')->getName());
$data['controller'] = strtolower(app('request')->controller());
$data['function'] = app('request')->action();
$data['function'] = strtolower(app('request')->action());
$parameter = $data['module'] . '/' . $data['controller'] . '/' . $data['function'];
$rule_menu = Db::name('AdminRule')->where(array('src' => $parameter))->find();
if($rule_menu){
@ -362,9 +370,7 @@ function add_log($type, $param_id = '', $param = [])
function send_email($to, $subject = '', $content = '')
{
$mail = new PHPMailer\PHPMailer\PHPMailer();
$email_config = Db::name('config')
->where('name', 'email')
->find();
$email_config = Db::name('config')->where('name', 'email')->find();
$config = unserialize($email_config['content']);
$mail->CharSet = 'UTF-8'; //设定邮件编码默认ISO-8859-1如果发中文此项必须设置否则乱码

View File

@ -9,7 +9,7 @@ declare (strict_types = 1);
namespace app\home\controller;
use app\home\BaseController;
use app\base\BaseController;
use app\home\model\Admin as AdminList;
use app\home\validate\AdminCheck;
use avatars\MDAvatars;

View File

@ -9,7 +9,7 @@ declare (strict_types = 1);
namespace app\home\controller;
use app\home\BaseController;
use app\base\BaseController;
use think\facade\Db;
use think\facade\View;

View File

@ -9,7 +9,7 @@ declare (strict_types = 1);
namespace app\home\controller;
use app\home\BaseController;
use app\base\BaseController;
use app\home\model\AdminLog;
use app\home\validate\AdminCheck;
use think\exception\ValidateException;

View File

@ -9,7 +9,7 @@ declare (strict_types = 1);
namespace app\home\controller;
use app\home\BaseController;
use app\base\BaseController;
use app\home\model\Article as ArticleList;
use app\home\model\ArticleCate;
use app\home\validate\ArticleCateCheck;

View File

@ -9,7 +9,7 @@ declare (strict_types = 1);
namespace app\home\controller;
use app\home\BaseController;
use app\base\BaseController;
use think\facade\Db;
use think\facade\View;

View File

@ -9,7 +9,7 @@ declare (strict_types = 1);
namespace app\home\controller;
use app\home\BaseController;
use app\base\BaseController;
use app\home\validate\ConfCheck;
use think\exception\ValidateException;
use think\facade\Db;

View File

@ -9,7 +9,7 @@ declare (strict_types = 1);
namespace app\home\controller;
use app\home\BaseController;
use app\base\BaseController;
use backup\Backup;
use think\facade\Db;
use think\facade\View;

View File

@ -9,7 +9,7 @@ declare (strict_types = 1);
namespace app\home\controller;
use app\home\BaseController;
use app\base\BaseController;
use app\home\validate\DepartmentCheck;
use think\exception\ValidateException;
use think\facade\Db;

View File

@ -9,7 +9,7 @@ declare (strict_types = 1);
namespace app\home\controller;
use app\home\BaseController;
use app\base\BaseController;
use app\home\model\Expense as ExpenseList;
use app\home\model\ExpenseCate;
use app\home\validate\ExpenseCateCheck;

View File

@ -9,7 +9,7 @@ declare (strict_types = 1);
namespace app\home\controller;
use app\home\BaseController;
use app\base\BaseController;
use app\home\model\Invoice as InvoiceList;
use app\home\validate\InvoiceCheck;
use think\exception\ValidateException;

View File

@ -9,7 +9,7 @@ declare (strict_types = 1);
namespace app\home\controller;
use app\home\BaseController;
use app\base\BaseController;
use think\facade\Db;
use think\facade\View;
@ -53,14 +53,14 @@ class Index extends BaseController
}
//未读消息统计
$mail_map[] = ['to_uid','=',$admin_id];
$mail_map[] = ['is_read','=',1];
$mail_map[] = ['status','=',1];
$mail_count = Db::name('Mail')->where($mail_map)->count();
$statistics['mail_html'] = '<a data-id="27" data-title="收件箱" data-src="/home/mail/inbox.html" class="site-menu-active"> 您有<font style="color:#FF0000">'.$mail_count.'</font>条未读消息</a>';
$statistics['num_mail'] = $mail_count;
if($mail_count==0){
$statistics['mail_html'] = '';
$msg_map[] = ['to_uid','=',$admin_id];
$msg_map[] = ['read_time','=',0];
$msg_map[] = ['status','=',1];
$msg_count = Db::name('Message')->where($msg_map)->count();
$statistics['msg_html'] = '<a data-id="27" data-title="收件箱" data-src="/home/message/inbox.html" class="site-menu-active"> 您有<font style="color:#FF0000">'.$msg_count.'</font>条未读消息</a>';
$statistics['msg_num'] = $msg_count;
if($msg_count==0){
$statistics['msg_html'] = '';
}
foreach ($statistics as $key => $value) {

View File

@ -9,7 +9,7 @@ declare (strict_types = 1);
namespace app\home\controller;
use app\home\BaseController;
use app\base\BaseController;
use app\home\model\InvoiceSubject;
use app\home\model\Invoice as InvoiceList;
use app\home\validate\InvoiceSubjectCheck;

View File

@ -9,7 +9,7 @@ declare (strict_types = 1);
namespace app\home\controller;
use app\home\BaseController;
use app\base\BaseController;
use app\home\validate\KeywordsCheck;
use think\exception\ValidateException;
use think\facade\Db;

View File

@ -9,7 +9,7 @@ declare (strict_types = 1);
namespace app\home\controller;
use app\home\BaseController;
use app\base\BaseController;
use app\home\validate\MenuCheck;
use think\exception\ValidateException;
use think\facade\Db;

View File

@ -9,12 +9,12 @@ declare (strict_types = 1);
namespace app\home\controller;
use app\home\BaseController;
use app\home\model\Mail as MailList;
use app\base\BaseController;
use app\home\model\Message as MessageList;
use think\facade\Db;
use think\facade\View;
class Mail extends BaseController
class Message extends BaseController
{
//收件箱
public function inbox()
@ -24,13 +24,21 @@ class Mail extends BaseController
$param['status'] = 1;
$map = [];
if (!empty($param['keywords'])) {
$map[] = ['name', 'like', '%' . $param['keywords'] . '%'];
$map[] = ['title', 'like', '%' . $param['keywords'] . '%'];
}
if (!empty($param['is_read'])) {
$map[] = ['is_read', '=', $param['is_read']];
if (!empty($param['read'])) {
if($param['read']==0){
$map[] = ['read_time', '=', 0];
}else{
$map[] = ['read_time', '>', 0];
}
}
if (!empty($param['mail_type'])) {
$map[] = ['mail_type', '=', $param['mail_type']];
if (!empty($param['template'])) {
if($param['template']==0){
$map[] = ['template', '=', 0];
}else{
$map[] = ['template', '>', 0];
}
}
$map[] = ['to_uid', '=', $this->uid];
$map[] = ['status', '=', $param['status']];
@ -40,7 +48,7 @@ class Mail extends BaseController
if ($start_time > 0 && $end_time > 0) {
$map[] = ['send_time', 'between', "$start_time,$end_time"];
}
$list = $this->getList($map, $param);
$list = (new MessageList())->getList($map, $param, $this->uid);
return table_assign(0, '', $list);
} else {
return view();
@ -54,7 +62,7 @@ class Mail extends BaseController
$param['status'] = 1;
$map = [];
if (!empty($param['keywords'])) {
$map[] = ['name', 'like', '%' . $param['keywords'] . '%'];
$map[] = ['title', 'like', '%' . $param['keywords'] . '%'];
}
$map[] = ['from_uid', '=', $this->uid];
$map[] = ['to_uid', '=', 0];
@ -66,7 +74,7 @@ class Mail extends BaseController
if ($start_time > 0 && $end_time > 0) {
$map[] = ['send_time', 'between', "$start_time,$end_time"];
}
$list = $this->getList($map, $param);
$list = (new MessageList())->getList($map, $param, $this->uid);
return table_assign(0, '', $list);
} else {
return view();
@ -81,7 +89,7 @@ class Mail extends BaseController
$param['status'] = 2;
$map = [];
if (!empty($param['keywords'])) {
$map[] = ['name', 'like', '%' . $param['keywords'] . '%'];
$map[] = ['title', 'like', '%' . $param['keywords'] . '%'];
}
$map[] = ['from_uid', '=', $this->uid];
$map[] = ['status', '=', 1];
@ -92,7 +100,7 @@ class Mail extends BaseController
if ($start_time > 0 && $end_time > 0) {
$map[] = ['send_time', 'between', "$start_time,$end_time"];
}
$list = $this->getList($map, $param);
$list = (new MessageList())->getList($map, $param, $this->uid);
return table_assign(0, '', $list);
} else {
return view();
@ -107,7 +115,7 @@ class Mail extends BaseController
$param['status'] = 0;
$map = [];
if (!empty($param['keywords'])) {
$map[] = ['name', 'like', '%' . $param['keywords'] . '%'];
$map[] = ['title', 'like', '%' . $param['keywords'] . '%'];
}
$map[] = ['status', '=', $param['status']];
//按时间检索
@ -116,76 +124,39 @@ class Mail extends BaseController
if ($start_time > 0 && $end_time > 0) {
$map[] = ['send_time', 'between', "$start_time,$end_time"];
}
$list = $this->getList($map, $param);
$list = (new MessageList())->getList($map, $param, $this->uid);
return table_assign(0, '', $list);
} else {
return view();
}
}
//获取消息列表
public function getList($map = [], $param = [])
{
$rows = empty($param['limit']) ? get_config('app.page_size') : $param['limit'];
//垃圾箱列表特殊处理
if ($param['status'] == 0) {
$where = [['from_uid', '=', $this->uid], ['to_uid', '=', $this->uid]];
$mail = MailList::where($map)
->where(function ($query) use ($where) {$query->whereOr($where);})
->order('create_time desc')
->paginate($rows, false, ['query' => $param])
->each(function ($item, $key) {
$item->send_time = empty($item->send_time) ? '-' : date('Y-m-d H:i:s', $item->send_time);
$item->from_name = Db::name('Admin')->where(['id' => $item->from_uid])->value('nickname');
$item->to_name = Db::name('Admin')->where(['id' => $item->to_uid])->value('nickname');
$item->type_title = MailList::$Type[$item->type];
$item->mail_type_title = MailList::$MailType[$item->mail_type];
$item->delete_source_title = MailList::$Source[$item->delete_source];
$item->files = Db::name('MailFileInterfix')->where(['mid' => $item->id, 'status' => 1])->count();
});
return $mail;
} else {
$mail = MailList::where($map)
->order('create_time desc')
->paginate($rows, false, ['query' => $param])
->each(function ($item, $key) {
$item->send_time = empty($item->send_time) ? '-' : date('Y-m-d H:i:s', $item->send_time);
$item->from_name = Db::name('Admin')->where(['id' => $item->from_uid])->value('nickname');
$item->to_name = Db::name('Admin')->where(['id' => $item->to_uid])->value('nickname');
$item->type_title = MailList::$Type[$item->type];
$item->mail_type_title = MailList::$MailType[$item->mail_type];
$item->files = Db::name('MailFileInterfix')->where(['mid' => $item->id, 'status' => 1])->count();
});
return $mail;
}
}
//新增信息
public function add()
{
$id = empty(get_params('id')) ? 0 : get_params('id');
$fid = 0;
if ($id > 0) {
$detail = Db::name('Mail')->where(['id' => $id, 'from_uid' => $this->uid])->find();
$detail = Db::name('Message')->where(['id' => $id, 'from_uid' => $this->uid])->find();
if (empty($detail)) {
$this->error('该信息不存在');
}
$fid = $detail['fid'];
$person_name = [];
if ($detail['type'] == 0) { //人员
if ($detail['type'] == 1) { //人员
$users = Db::name('Admin')->where('status', 1)->where('id', 'in', $detail['type_user'])->select()->toArray();
$person_name = array_column($users, 'name');
} elseif ($detail['type'] == 1) { //部门
} elseif ($detail['type'] == 2) { //部门
$departments = Db::name('Department')->where('id', 'in', $detail['type_user'])->select()->toArray();
$person_name = array_column($departments, 'title');
} elseif ($detail['type'] == 2) { //角色
} elseif ($detail['type'] == 3) { //角色
$group_uid = Db::name('PositionGroup')->where('group_id', 'in', $detail['type_user'])->select()->toArray();
$pids = array_column($group_uid, 'pid');
$positions = Db::name('Position')->where('id', 'in', $pids)->select()->toArray();
$person_name = array_column($positions, 'title');
}
$detail['person_name'] = implode(",", $person_name);
$file_array = Db::name('MailFileInterfix')
$file_array = Db::name('MessageFileInterfix')
->field('mf.id,mf.mid,mf.file_id,f.name,f.filesize,f.filepath')
->alias('mf')
->join('file f', 'mf.file_id = f.id', 'LEFT')
@ -197,8 +168,8 @@ class Mail extends BaseController
//引用消息的附件
if($detail['fid']>0){
$detail['from_content'] = Db::name('Mail')->where(['id' => $detail['fid']])->value('content');
$from_file_array = Db::name('MailFileInterfix')
$detail['from_content'] = Db::name('Message')->where(['id' => $detail['fid']])->value('content');
$from_file_array = Db::name('MessageFileInterfix')
->field('mf.id,mf.mid,mf.file_id,f.name,f.filesize,f.filepath')
->alias('mf')
->join('file f', 'mf.file_id = f.id', 'LEFT')
@ -207,7 +178,6 @@ class Mail extends BaseController
->select()->toArray();
$detail['from_file_array'] = $from_file_array;
}
View::assign('file_array', $file_array);
View::assign('detail', $detail);
}
@ -221,7 +191,7 @@ class Mail extends BaseController
{
$id = empty(get_params('id')) ? 0 : get_params('id');
$type = empty(get_params('type')) ? 0 : get_params('type');
$detail = Db::name('Mail')->where(['id' => $id, 'mail_type' => 2])->find();
$detail = Db::name('Message')->where(['id' => $id, 'template' => 0])->find();
if (empty($detail)) {
$this->error('该信息不存在');
}
@ -230,7 +200,7 @@ class Mail extends BaseController
}
$sender = get_admin($detail['from_uid']);
$detail['person_name'] = $sender['name'];
$file_array = Db::name('MailFileInterfix')
$file_array = Db::name('MessageFileInterfix')
->field('mf.id,mf.mid,mf.file_id,f.name,f.filesize,f.filepath')
->alias('mf')
->join('file f', 'mf.file_id = f.id', 'LEFT')
@ -251,14 +221,14 @@ class Mail extends BaseController
{
$param = get_params();
$id = $param['id'];
$detail = Db::name('Mail')->where(['id' => $id])->find();
$detail = Db::name('Message')->where(['id' => $id])->find();
if (empty($detail)) {
$this->error('该信息不存在');
}
if ($detail['to_uid'] != $this->uid && $detail['from_uid'] != $this->uid) {
$this->error('该信息不存在');
}
Db::name('Mail')->where(['id' => $id])->update(['is_read' => 2]);
Db::name('Message')->where(['id' => $id])->update(['read_time' => time()]);
if($detail['from_uid']==0){
$detail['person_name'] = '系统管理员';
}
@ -268,8 +238,8 @@ class Mail extends BaseController
}
//引用消息的附件
if($detail['fid']>0){
$detail['from_content'] = Db::name('Mail')->where(['id' => $detail['fid']])->value('content');
$from_file_array = Db::name('MailFileInterfix')
$detail['from_content'] = Db::name('Message')->where(['id' => $detail['fid']])->value('content');
$from_file_array = Db::name('MessageFileInterfix')
->field('mf.id,mf.mid,mf.file_id,f.name,f.filesize,f.filepath')
->alias('mf')
->join('file f', 'mf.file_id = f.id', 'LEFT')
@ -280,7 +250,7 @@ class Mail extends BaseController
}
//当前消息的附件
$file_array = Db::name('MailFileInterfix')
$file_array = Db::name('MessageFileInterfix')
->field('mf.id,mf.mid,mf.file_id,f.name,f.filesize,f.filepath')
->alias('mf')
->join('file f', 'mf.file_id = f.id', 'LEFT')
@ -294,14 +264,14 @@ class Mail extends BaseController
//已读回执
$read_user_names = [];
if($detail['from_uid'] == $this->uid){
$mails= Db::name('Mail')->where(['pid' => $id])->select()->toArray();
$read_mails= Db::name('Mail')->where(['pid' => $id,'is_read' => 2])->select()->toArray();
$mails= Db::name('Message')->where(['pid' => $id])->select()->toArray();
$read_mails= Db::name('Message')->where([['pid','=',$id],['read_time','>',2]])->select()->toArray();
$read_user_ids = array_column($read_mails, 'to_uid');
$read_users = Db::name('Admin')->where('status', 1)->where('id', 'in', $read_user_ids)->select()->toArray();
$read_user_names = array_column($read_users, 'name');
}
else{
$mails= Db::name('Mail')->where(['pid' => $detail['pid']])->select()->toArray();
$mails= Db::name('Message')->where(['pid' => $detail['pid']])->select()->toArray();
}
$user_ids = array_column($mails, 'to_uid');
$users = Db::name('Admin')->where('status', 1)->where('id', 'in', $user_ids)->select()->toArray();
@ -320,19 +290,19 @@ class Mail extends BaseController
$id = empty($param['id']) ? 0 : $param['id'];
$fid = empty($param['fid']) ? 0 : $param['fid'];
//接受人类型判断
if ($param['type'] == 0) {
if ($param['type'] == 1) {
if (!$param['uids']) {
return to_assign(1, '人员不能为空');
} else {
$type_user = $param['uids'];
}
} elseif ($param['type'] == 1) {
} elseif ($param['type'] == 2) {
if (!$param['dids']) {
return to_assign(1, '部门不能为空');
} else {
$type_user = $param['dids'];
}
} elseif ($param['type'] == 2) {
} elseif ($param['type'] == 3) {
if (!$param['pids']) {
return to_assign(1, '岗位不能为空');
} else {
@ -343,33 +313,32 @@ class Mail extends BaseController
}
//基础信息数据
$admin_id = $this->uid;
$did = get_admin($admin_id)['did'];
$basedata = [];
$basedata['from_uid'] = $admin_id;
$basedata['admin_id'] = $admin_id;
$basedata['did'] = $did;
$basedata['fid'] = $fid;
$basedata['mail_type'] = 2;//同事信息类型
$basedata['is_draft'] = 2;//默认是草稿信息
$basedata['name'] = $param['name'];
$basedata['title'] = $param['title'];
$basedata['type'] = $param['type'];
$basedata['type_user'] = $type_user;
$basedata['content'] = $param['content'];
$basedata['controller_name'] = $this->controller;
$basedata['module_name'] = $this->module;
$basedata['action_name'] = $this->action;
if ($id > 0) {
//编辑信息的情况
$basedata['update_time'] = time();
$basedata['id'] = $id;
$res = Db::name('Mail')->strict(false)->field(true)->update($basedata);
$res = Db::name('Message')->strict(false)->field(true)->update($basedata);
} else {
//新增信息的情况
$basedata['create_time'] = time();
$res = Db::name('Mail')->strict(false)->field(true)->insertGetId($basedata);
$res = Db::name('Message')->strict(false)->field(true)->insertGetId($basedata);
}
if ($res !== false) {
//信息附件处理
if ($id > 0) {
$mid = $id;
Db::name('MailFileInterfix')->where('mid', $mid)->delete();
Db::name('MessageFileInterfix')->where('mid', $mid)->delete();
} else {
$mid = $res;
}
@ -389,7 +358,7 @@ class Mail extends BaseController
);
}
if ($file_data) {
Db::name('MailFileInterfix')->strict(false)->field(true)->insertAll($file_data);
Db::name('MessageFileInterfix')->strict(false)->field(true)->insertAll($file_data);
}
}
add_log('save',$mid);
@ -404,20 +373,20 @@ class Mail extends BaseController
{
$param = get_params();
//查询要发的消息
$msg = Db::name('Mail')->where(['id' => $param['id']])->find();
$msg = Db::name('Message')->where(['id' => $param['id']])->find();
$users = [];
if ($msg) {
$admin_id = $msg['admin_id'];
$admin_id = $msg['from_uid'];
//查询全部收件人
if ($msg['type'] == 0) { //人员
if ($msg['type'] == 1) { //人员
$users = Db::name('Admin')->where('status', 1)->where('id', 'in', $msg['type_user'])->select()->toArray();
} elseif ($msg['type'] == 1) { //部门
} elseif ($msg['type'] == 2) { //部门
$users = Db::name('Admin')->where('status', 1)->where('did', 'in', $msg['type_user'])->select()->toArray();
} elseif ($msg['type'] == 2) { //角色
} elseif ($msg['type'] == 3) { //角色
$group_uid = Db::name('PositionGroup')->where('group_id', 'in', $msg['type_user'])->select()->toArray();
$pids = array_column($group_uid, 'pid');
$users = Db::name('Admin')->where('status', 1)->where('position_id', 'in', $pids)->select()->toArray();
} elseif ($msg['type'] == 3) { //全部
} elseif ($msg['type'] == 4) { //全部
$users = Db::name('Admin')->where('status', 1)->select()->toArray();
}
//组合要发的消息
@ -427,27 +396,27 @@ class Mail extends BaseController
continue;
}
$send_data[] = array(
'pid' => $msg['id'],//来源发件关联id
'fid' => $msg['fid'],//转发或回复消息关联id
'name' => $msg['name'],
'type' => $msg['type'],
'type_user' => $msg['type_user'],
'from_uid' => $admin_id,//发送人
'did' => $value['did'],
'to_uid' => $value['id'],
'mail_type' => 2,//同事信息类型
'content' => $msg['content'],
'send_time' => time(),
'admin_id' => $admin_id,
'create_time' => time()
'pid' => $param['id'],//来源发件关联id
'to_uid' => $value['id'],//接收人
'fid' => $msg['fid'],//转发或回复消息关联id
'title' => $msg['title'],
'content' => $msg['content'],
'type' => $msg['type'],//接收人类型
'type_user' => $msg['type_user'],//接收人数据
'from_uid' => $this->uid,//发送人
'controller_name' => $this->controller,
'module_name' => $this->module,
'action_name' => $this->action,
'send_time' => time(),
'create_time' => time()
);
}
$res = Db::name('Mail')->strict(false)->field(true)->insertAll($send_data);
$res = Db::name('Message')->strict(false)->field(true)->insertAll($send_data);
if ($res!==false) {
//查询原来的附件,并插入
$file_array = Db::name('MailFileInterfix')->where('mid', $msg['id'])->select()->toArray();
$file_array = Db::name('MessageFileInterfix')->where('mid', $msg['id'])->select()->toArray();
if ($file_array) {
$mids = Db::name('Mail')->where('pid', $msg['id'])->select()->toArray();
$mids = Db::name('Message')->where('pid', $msg['id'])->select()->toArray();
foreach ($mids as $k => $v) {
$file_data = array();
foreach ($file_array as $key => $value) {
@ -462,12 +431,12 @@ class Mail extends BaseController
);
}
if ($file_data) {
Db::name('MailFileInterfix')->strict(false)->field(true)->insertAll($file_data);
Db::name('MessageFileInterfix')->strict(false)->field(true)->insertAll($file_data);
}
}
}
//草稿消息变成已发消息
Db::name('Mail')->where(['id' => $msg['id']])->update(['is_draft' => '1', 'send_time' => time(), 'update_time' => time()]);
Db::name('Message')->where(['id' => $msg['id']])->update(['is_draft' => '1', 'send_time' => time(), 'update_time' => time()]);
add_log('send',$msg['id']);
return to_assign(0, '发送成功');
} else {
@ -490,9 +459,8 @@ class Mail extends BaseController
foreach ($idArray as $key => $val) {
if ($type==1) { //设置信息为已读
$list[] = [
'is_read' => 2,
'read_time' => time(),
'id' => $val,
'update_time' => time(),
];
}
else if ($type==2) { //设置信息进入垃圾箱
@ -520,7 +488,7 @@ class Mail extends BaseController
}
foreach ($list as $key => $v) {
if (Db::name('Mail')->update($v) !== false) {
if (Db::name('Message')->update($v) !== false) {
if ($type = 1) {
add_log('view', $v['id']);
} else if ($type = 2) {

View File

@ -9,7 +9,7 @@ declare (strict_types = 1);
namespace app\home\controller;
use app\home\BaseController;
use app\base\BaseController;
use app\home\model\Note as NoteList;
use app\home\model\NoteCate;
use app\home\validate\NoteCateCheck;
@ -158,6 +158,8 @@ class Note extends BaseController
$sid = NoteList::strict(false)->field(true)->insertGetId($param);
if ($sid) {
add_log('add', $sid, $param);
$users= Db::name('Admin')->field('id as from_uid')->where(['status' => 1])->column('id');
sendMessage($users,1,['title'=>$param['title'],'action_id'=>$sid]);
}
return to_assign();

View File

@ -9,7 +9,7 @@ declare (strict_types = 1);
namespace app\home\controller;
use app\home\BaseController;
use app\base\BaseController;
use app\home\model\DepartmentChange as DepartmentChange;
use app\home\model\PersonalQuit as PersonalQuit;
use think\exception\ValidateException;

View File

@ -9,7 +9,7 @@ declare (strict_types = 1);
namespace app\home\controller;
use app\home\BaseController;
use app\base\BaseController;
use app\home\model\Plan as PlanList;
use schedule\Schedule as ScheduleIndex;
use think\facade\Db;

View File

@ -9,7 +9,7 @@ declare (strict_types = 1);
namespace app\home\controller;
use app\home\BaseController;
use app\base\BaseController;
use app\home\validate\PositionCheck;
use think\exception\ValidateException;
use think\facade\Db;

View File

@ -9,7 +9,7 @@ declare (strict_types = 1);
namespace app\home\controller;
use app\home\BaseController;
use app\base\BaseController;
use app\home\model\AdminGroup;
use app\home\validate\GroupCheck;
use think\exception\ValidateException;

View File

@ -9,7 +9,7 @@ declare (strict_types = 1);
namespace app\home\controller;
use app\home\BaseController;
use app\base\BaseController;
use app\home\validate\RuleCheck;
use think\exception\ValidateException;
use think\facade\Db;

View File

@ -9,7 +9,7 @@ declare (strict_types = 1);
namespace app\home\controller;
use app\home\BaseController;
use app\base\BaseController;
use app\home\model\Schedule as ScheduleList;
use schedule\Schedule as ScheduleIndex;
use think\facade\Db;

View File

@ -1,55 +0,0 @@
<?php
/**
* @copyright Copyright (c) 2021 勾股工作室
* @license https://opensource.org/licenses/GPL-2.0
* @link https://www.gougucms.com
*/
namespace app\home\model;
use think\Model;
class Mail extends Model
{
// 垃圾消息来源[delete_source]
const SOURCE_ZERO = 0;
const SOURCE_ONE = 1;
const SOURCE_TWO = 2;
const SOURCE_THREE = 3;
// 阅览人类型[type]
const TYPE_ZERO = 0;
const TYPE_ONE = 1;
const TYPE_TWO = 2;
const TYPE_THREE = 3;
// 是否已读[is_read]
const READ_ONE = 1;
const READ_TWO = 2;
// 消息来源[mail_type]
const MAILTYPE_ZERO = 0;
const MAILTYPE_ONE = 1;
const MAILTYPE_TWO = 2;
const MAILTYPE_THREE = 3;
public static $Source = [
self::SOURCE_ZERO => '无',
self::SOURCE_ONE => '已发消息',
self::SOURCE_TWO => '草稿消息',
self::SOURCE_THREE => '已收消息',
];
public static $Type = [
self::TYPE_ZERO => '同事',
self::TYPE_ONE => '部门',
self::TYPE_TWO => '岗位',
self::TYPE_THREE => '全部',
];
public static $MailType = [
self::MAILTYPE_ONE => '系统消息',
self::SOURCE_TWO => '同事消息',
];
}

View File

@ -0,0 +1,85 @@
<?php
/**
* @copyright Copyright (c) 2021 勾股工作室
* @license https://opensource.org/licenses/GPL-2.0
* @link https://www.gougucms.com
*/
namespace app\home\model;
use think\Model;
use think\facade\Db;
class Message extends Model
{
const ZERO = 0;
const ONE = 1;
const TWO = 2;
const THREE = 3;
const FOUR = 4;
const FINE = 5;
public static $Source = [
self::ZERO => '无',
self::ONE => '已发消息',
self::TWO => '草稿消息',
self::THREE => '已收消息',
];
public static $Type = [
self::ZERO => '系统',
self::ONE => '同事',
self::TWO => '部门',
self::THREE => '岗位',
self::FOUR => '全部',
];
//获取消息列表
public function getList($map = [], $param = [],$uid)
{
$rows = empty($param['limit']) ? get_config('app.page_size') : $param['limit'];
//垃圾箱列表特殊处理
if ($param['status'] == 0) {
$where = [['from_uid', '=', $uid], ['to_uid', '=', $uid]];
$mail = $this->where($map)
->where(function ($query) use ($where) {$query->whereOr($where);})
->order('create_time desc')
->paginate($rows, false, ['query' => $param])
->each(function ($item, $key) {
if($item->template==0){
$item->msg_type = '个人信息';
$item->from_name = Db::name('Admin')->where(['id' => $item->from_uid])->value('name');
}
else{
$item->msg_type = '系统信息';
$item->from_name = '系统';
}
$item->send_time = empty($item->send_time) ? '-' : date('Y-m-d H:i:s', $item->send_time);
$item->to_name = Db::name('Admin')->where(['id' => $item->to_uid])->value('name');
$item->type_title = self::$Type[(int)$item->type];
$item->delete_source_title = self::$Source[(int)$item->delete_source];
$item->files = Db::name('MessageFileInterfix')->where(['mid' => $item->id, 'status' => 1])->count();
});
return $mail;
} else {
$mail = self::where($map)
->order('create_time desc')
->paginate($rows, false, ['query' => $param])
->each(function ($item, $key) {
if($item->template==0){
$item->msg_type = '个人信息';
$item->from_name = Db::name('Admin')->where(['id' => $item->from_uid])->value('name');
}
else{
$item->msg_type = '系统信息';
$item->from_name = '系统';
}
$item->send_time = empty($item->send_time) ? '-' : date('Y-m-d H:i:s', $item->send_time);
$item->to_name = Db::name('Admin')->where(['id' => $item->to_uid])->value('name');
$item->type_title = self::$Type[(int)$item->type];
$item->files = Db::name('MessageFileInterfix')->where(['mid' => $item->id, 'status' => 1])->count();
});
return $mail;
}
}
}

View File

@ -127,8 +127,8 @@
type:'post',
success:function(e){
if(e.code==0 && e.data!=''){
if(e.data.num_mail>0){
$('#msgNum').show().find('a').html(e.data.num_mail);
if(e.data.msg_num>0){
$('#msgNum').show().find('a').html(e.data.msg_num);
}
else{
$('#msgNum').hide().find('a').html(0);
@ -136,7 +136,7 @@
if(isClose==0){
var html = '<ul id="messageul" style="line-height:24px;">';
$.each(e.data, function(key, value) {
if(key!='num_mail'){
if(key!='msg_num'){
html += '<li style="cursor:pointer;">'+value+'</li>';
}
});

View File

@ -12,10 +12,10 @@
<tr>
<td class="layui-td-gray2">接收人类型</td>
<td>
<input type="radio" name="type" lay-filter="type" value="0" title="同事" checked>
<input type="radio" name="type" lay-filter="type" value="1" title="部门">
<input type="radio" name="type" lay-filter="type" value="2" title="岗位">
<input type="radio" name="type" lay-filter="type" value="3" title="全部">
<input type="radio" name="type" lay-filter="type" value="1" title="同事" checked>
<input type="radio" name="type" lay-filter="type" value="2" title="部门">
<input type="radio" name="type" lay-filter="type" value="3" title="岗位">
<input type="radio" name="type" lay-filter="type" value="4" title="全部">
</td>
</tr>
<tr id ="person">
@ -30,7 +30,7 @@
<tr>
<td class="layui-td-gray2">主题<span style="color: red">*</span></td>
<td>
<input type="text" name="name" value="" lay-verify="required" lay-reqText="请输入消息主题" placeholder="请输入消息主题" class="layui-input" lay-verify="required">
<input type="text" name="title" value="" lay-verify="required" lay-reqText="请输入消息主题" placeholder="请输入消息主题" class="layui-input" lay-verify="required">
</td>
</tr>
<tr><td class="layui-td-gray2">发送内容<span style="color: red">*</span></td>
@ -69,10 +69,10 @@
<tr>
<td class="layui-td-gray2">接收人类型</td>
<td>
<input type="radio" name="type" lay-filter="type" value="0" title="同事" {eq name="$detail.type" value="0"}checked{/eq}>
<input type="radio" name="type" lay-filter="type" value="1" title="部门" {eq name="$detail.type" value="1"}checked{/eq}>
<input type="radio" name="type" lay-filter="type" value="2" title="岗位" {eq name="$detail.type" value="2"}checked{/eq}>
<input type="radio" name="type" lay-filter="type" value="3" title="全部" {eq name="$detail.type" value="3"}checked{/eq}>
<input type="radio" name="type" lay-filter="type" value="1" title="同事" {eq name="$detail.type" value="1"}checked{/eq}>
<input type="radio" name="type" lay-filter="type" value="2" title="部门" {eq name="$detail.type" value="2"}checked{/eq}>
<input type="radio" name="type" lay-filter="type" value="3" title="岗位" {eq name="$detail.type" value="3"}checked{/eq}>
<input type="radio" name="type" lay-filter="type" value="4" title="全部" {eq name="$detail.type" value="4"}checked{/eq}>
</td>
</tr>
<tr id ="person" {eq name="$detail.type" value="3"}style="display:none;"{/eq}>
@ -91,7 +91,7 @@
<tr>
<td class="layui-td-gray2">主题<span style="color: red">*</span></td>
<td>
<input type="text" name="name" value="{$detail.name}" lay-verify="required" lay-reqText="请输入消息主题" placeholder="请输入消息主题" class="layui-input" lay-verify="required">
<input type="text" name="title" value="{$detail.title}" lay-verify="required" lay-reqText="请输入消息主题" placeholder="请输入消息主题" class="layui-input" lay-verify="required">
</td>
</tr>
<tr><td class="layui-td-gray2">发送内容<span style="color: red">*</span></td>
@ -195,14 +195,14 @@
//监听保存到草稿并发送
form.on('submit(webform)', function(data){
$.ajax({
url: "/home/mail/save",
url: "/home/message/save",
type:'post',
data:data.field,
success:function(e){
if(e.code==0){
layer.msg('消息保存成功,正在发送中...');
$.ajax({
url: "/home/mail/send",
url: "/home/message/send",
type:'post',
data:{'id':e.data},
success:function(e){
@ -226,7 +226,7 @@
//监听保存到草稿
form.on('submit(draftform)', function(data){
$.ajax({
url: "/home/mail/save",
url: "/home/message/save",
type:'post',
data:data.field,
success:function(e){
@ -339,11 +339,11 @@
//选择对应人
$('[name="person_name"]').on('click',function(){
type = $("input[name='type']:checked").val();
if(type == 0){
if(type == 1){
addEmployee();
}else if(type == 1){
selectDepartment();
}else if(type == 2){
selectDepartment();
}else if(type == 3){
selectAuditor();
}
});

View File

@ -59,14 +59,14 @@
elem: '#test',
toolbar: '#toolbarDemo',
title:'草稿箱',
url: "/home/mail/draft", //数据接口
url: "/home/message/draft", //数据接口
page: true ,//开启分页
limit: 15,
cellMinWidth: 80, //全局定义常规单元格的最小宽度layui 2.2.1 新增
cols: [[ //表头
{type:'checkbox',fixed:'left'},
{field: 'type_title', title: '接收人类型',width:100,align:'center'},
{field: 'name', title: '消息主题'},
{field: 'title', title: '消息主题'},
{field: 'create_time', title: '保存时间', align:'center',width:160},
{field: 'files', title: '附件(个)',align:'center', width:86},
{field: 'right', title: '操作',fixed:'right', toolbar: '#barDemo', width:100, align:'center'}
@ -80,7 +80,7 @@
if(obj.event === 'del'){
layer.confirm('确定该信息要放入垃圾箱吗?', {icon: 3, title:'提示'}, function(index){
$.ajax({
url: "/home/mail/check",
url: "/home/message/check",
data:{ids:data.id,type:2,source:2},
success:function(e){
layer.msg(e.msg);
@ -93,7 +93,7 @@
});
}
if(obj.event === 'edit'){
rightpage.open('/home/mail/add?id='+data.id);
rightpage.open('/home/message/add?id='+data.id);
return;
}
});
@ -102,7 +102,7 @@
var checkStatus = table.checkStatus(obj.config.id); //获取选中行状态
var data = checkStatus.data;
if (obj.event === 'add') {
rightpage.open("/home/mail/add");
rightpage.open("/home/message/add");
return;
}
if(data.length==0){
@ -125,7 +125,7 @@
title: '提示'
}, function (index) {
$.ajax({
url: "/home/mail/check",
url: "/home/message/check",
data: {
ids: idArray.join(','),
type:type,

View File

@ -16,14 +16,14 @@
</div>
</div>
<div class="layui-input-inline" style="width:136px">
<select name="is_read">
<select name="read">
<option value="">选择消息状态</option>
<option value="1">未读消息</option>
<option value="2">已读消息</option>
</select>
</div>
<div class="layui-input-inline" style="width:136px">
<select name="mail_type">
<select name="template">
<option value="">选择消息类型</option>
<option value="1">系统消息</option>
<option value="2">个人消息</option>
@ -33,9 +33,6 @@
</form>
<table class="layui-hide" id="test" lay-filter="test"></table>
</div>
<script type="text/html" id="mail_type">
<span class="layui-type{{d.mail_type}}">{{d.mail_type_title}}</span>
</script>
<script type="text/html" id="toolbarDemo">
<div class="layui-btn-container">
@ -75,20 +72,20 @@
elem: '#test',
toolbar: '#toolbarDemo',
title:'收件箱',
url: "/home/mail/inbox", //数据接口
url: "/home/message/inbox", //数据接口
page: true ,//开启分页
limit: 15,
cellMinWidth: 80, //全局定义常规单元格的最小宽度layui 2.2.1 新增
cols: [[ //表头
{type:'checkbox',fixed:'left'},
{field: 'mail_type_title', title: '消息类型',toolbar: '#mail_type',width:88,align:'center'},
{field: 'msg_type', title: '消息类型',width:88,align:'center'},
{field: 'from_name', title: '发件人', width:100,align:'center'},
{field: 'name', title: '消息主题'},
{field: 'title', title: '消息主题'},
{field: 'send_time', title: '发件时间', align:'center',width:160},
{field: 'is_read', title: '是否已读',align:'center', width:86,templet:function(d){
var html='<span style="color:#FF5722"></span>';
if(d.is_read==2){
html='<span style="color:#5FB878"></span>';
{field: 'read_time', title: '是否已读',align:'center', width:86,templet:function(d){
var html='<span style="color:#5FB878"></span>';
if(d.read_time==0){
html='<span style="color:#FF5722"></span>';
}
return html;
}},
@ -104,7 +101,7 @@
if(obj.event === 'del'){
layer.confirm('确定该信息要放入垃圾箱吗?', {icon: 3, title:'提示'}, function(index){
$.ajax({
url: "/home/mail/check",
url: "/home/message/check",
data:{ids:data.id,type:2,source:3},
success:function(e){
layer.msg(e.msg);
@ -117,15 +114,15 @@
});
}
if(obj.event === 'view'){
rightpage.open('/home/mail/read?id='+data.id);
rightpage.open('/home/message/read?id='+data.id);
return;
}
if(obj.event === 'reply'){
rightpage.open('/home/mail/reply?id='+data.id+'&type=1');
rightpage.open('/home/message/reply?id='+data.id+'&type=1');
return;
}
if(obj.event === 'resend'){
rightpage.open('/home/mail/reply?id='+data.id+'&type=2');
rightpage.open('/home/message/reply?id='+data.id+'&type=2');
return;
}
});
@ -135,7 +132,7 @@
var checkStatus = table.checkStatus(obj.config.id); //获取选中行状态
var data = checkStatus.data;
if (obj.event === 'add') {
rightpage.open("/home/mail/add");
rightpage.open("/home/message/add");
return;
}
if(data.length==0){
@ -162,7 +159,7 @@
title: '提示'
}, function (index) {
$.ajax({
url: "/home/mail/check",
url: "/home/message/check",
data: {
ids: idArray.join(','),
type:type,

View File

@ -6,7 +6,7 @@
<table class="layui-table">
<tr>
<td class="layui-td-gray2">信息主题</td>
<td colspan="5">{$detail.name}</td>
<td colspan="5">{$detail.title}</td>
</tr>
<tr>
<td class="layui-td-gray2">发送人</td>
@ -94,7 +94,7 @@
</tr>
{/notempty}
</table>
{if condition="($detail.mail_type == 2) AND ($detail.pid != 0)"}
{if condition="($detail.template == 0) AND ($detail.pid != 0)"}
<div class="layui-form-item" style=" padding-top:10px;">
<a class="layui-btn" href="/home/mail/reply?id={$detail.id}&type=1">回复</a>
</div>

View File

@ -15,10 +15,10 @@
<tr>
<td class="layui-td-gray2">接收人类型</td>
<td>
<input type="radio" name="type" lay-filter="type" value="0" title="同事" checked>
<input type="radio" name="type" lay-filter="type" value="1" title="部门">
<input type="radio" name="type" lay-filter="type" value="2" title="岗位">
<input type="radio" name="type" lay-filter="type" value="3" title="全部">
<input type="radio" name="type" lay-filter="type" value="1" title="同事" checked>
<input type="radio" name="type" lay-filter="type" value="2" title="部门">
<input type="radio" name="type" lay-filter="type" value="3" title="岗位">
<input type="radio" name="type" lay-filter="type" value="4" title="全部">
</td>
</tr>
{if condition="$type eq 1"}
@ -34,7 +34,7 @@
<tr>
<td class="layui-td-gray2">主题<span style="color: red">*</span></td>
<td>
<input type="text" name="name" value="回复:{$detail.name}" lay-verify="required" lay-reqText="请输入消息主题" placeholder="请输入消息主题" class="layui-input" lay-verify="required">
<input type="text" name="title" value="回复:{$detail.title}" lay-verify="required" lay-reqText="请输入消息主题" placeholder="请输入消息主题" class="layui-input" lay-verify="required">
</td>
</tr>
{else/}
@ -50,7 +50,7 @@
<tr>
<td class="layui-td-gray2">主题<span style="color: red">*</span></td>
<td>
<input type="text" name="name" value="转发:{$detail.name}" lay-verify="required" lay-reqText="请输入消息主题" placeholder="请输入消息主题" class="layui-input" lay-verify="required">
<input type="text" name="title" value="转发:{$detail.title}" lay-verify="required" lay-reqText="请输入消息主题" placeholder="请输入消息主题" class="layui-input" lay-verify="required">
</td>
</tr>
{/if}
@ -142,14 +142,14 @@
//监听保存到草稿并发送
form.on('submit(webform)', function(data){
$.ajax({
url: "/home/mail/save",
url: "/home/message/save",
type:'post',
data:data.field,
success:function(e){
if(e.code==0){
layer.msg('消息保存成功,正在发送中...');
$.ajax({
url: "/home/mail/send",
url: "/home/message/send",
type:'post',
data:{'id':e.data},
success:function(e){
@ -173,7 +173,7 @@
//监听保存到草稿
form.on('submit(draftform)', function(data){
$.ajax({
url: "/home/mail/save",
url: "/home/message/save",
type:'post',
data:data.field,
success:function(e){
@ -286,11 +286,11 @@
//选择对应人
$('[name="person_name"]').on('click',function(){
type = $("input[name='type']:checked").val();
if(type == 0){
if(type == 1){
addEmployee();
}else if(type == 1){
selectDepartment();
}else if(type == 2){
selectDepartment();
}else if(type == 3){
selectAuditor();
}
});

View File

@ -60,7 +60,7 @@
elem: '#test',
toolbar: '#toolbarDemo',
title:'垃圾箱',
url: "/home/mail/rubbish", //数据接口
url: "/home/message/rubbish", //数据接口
page: true ,//开启分页
limit: 15,
cellMinWidth: 80, //全局定义常规单元格的最小宽度layui 2.2.1 新增
@ -68,7 +68,7 @@
{type:'checkbox',fixed:'left'},
{field: 'delete_source_title', title: '来源',toolbar: '#mail_type',width:90,align:'center'},
{field: 'from_name', title: '发件人', width:110,align:'center'},
{field: 'name', title: '消息主题'},
{field: 'title', title: '消息主题'},
{field: 'send_time', title: '发送时间', align:'center',width:160},
{field: 'files', title: '附件(个)',align:'center', width:88},
{field: 'right', title: '操作',fixed:'right', toolbar: '#barDemo', width:160, align:'center'}
@ -80,13 +80,13 @@
table.on('tool(test)', function(obj){
var data = obj.data;
if(obj.event === 'view'){
rightpage.open('/home/mail/read?id='+data.id);
rightpage.open('/home/message/read?id='+data.id);
return;
}
if(obj.event === 'del'){
layer.confirm('确定把该信息彻底删除吗?', {icon: 3, title:'提示'}, function(index){
$.ajax({
url: "/home/mail/check",
url: "/home/message/check",
data:{ids:data.id,type:4},
success:function(e){
layer.msg(e.msg);
@ -101,7 +101,7 @@
if(obj.event === 'recover'){
layer.confirm('确定把该信息移出垃圾箱吗?', {icon: 3, title:'提示'}, function(index){
$.ajax({
url: "/home/mail/check",
url: "/home/message/check",
data:{ids:data.id,type:3},
success:function(e){
layer.msg(e.msg);
@ -120,7 +120,7 @@
var checkStatus = table.checkStatus(obj.config.id); //获取选中行状态
var data = checkStatus.data;
if (obj.event === 'add') {
rightpage.open("/home/mail/add");
rightpage.open("/home/message/add");
return;
}
if(data.length==0){
@ -147,7 +147,7 @@
title: '提示'
}, function (index) {
$.ajax({
url: "/home/mail/check",
url: "/home/message/check",
data: {
ids: idArray.join(','),
type:type

View File

@ -59,14 +59,14 @@
elem: '#test',
toolbar: '#toolbarDemo',
title:'发件箱',
url: "/home/mail/sendbox", //数据接口
url: "/home/message/sendbox", //数据接口
page: true ,//开启分页
limit: 15,
cellMinWidth: 80, //全局定义常规单元格的最小宽度layui 2.2.1 新增
cols: [[ //表头
{type:'checkbox',fixed:'left'},
{field: 'type_title', title: '接收人类型',width:100,align:'center'},
{field: 'name', title: '消息主题'},
{field: 'title', title: '消息主题'},
{field: 'send_time', title: '发件时间', align:'center',width:160},
{field: 'files', title: '附件(个)',align:'center', width:86},
{field: 'right', title: '操作',fixed:'right', toolbar: '#barDemo', width:136, align:'center'}
@ -80,7 +80,7 @@
if(obj.event === 'del'){
layer.confirm('确定该信息要放入垃圾箱吗?', {icon: 3, title:'提示'}, function(index){
$.ajax({
url: "/home/mail/check",
url: "/home/message/check",
data:{ids:data.id,type:2,source:1},
success:function(e){
layer.msg(e.msg);
@ -93,11 +93,11 @@
})
}
if(obj.event === 'view'){
rightpage.open('/home/mail/read?id='+data.id);
rightpage.open('/home/message/read?id='+data.id);
return;
}
if(obj.event === 'resend'){
rightpage.open('/home/mail/reply?id='+data.id+'&type=2');
rightpage.open('/home/message/reply?id='+data.id+'&type=2');
return;
}
});
@ -106,7 +106,7 @@
var checkStatus = table.checkStatus(obj.config.id); //获取选中行状态
var data = checkStatus.data;
if (obj.event === 'add') {
rightpage.open("/home/mail/add");
rightpage.open("/home/message/add");
return;
}
if(data.length==0){
@ -129,7 +129,7 @@
title: '提示'
}, function (index) {
$.ajax({
url: "/home/mail/check",
url: "/home/message/check",
data: {
ids: idArray.join(','),
type:type,

View File

@ -145,10 +145,10 @@ INSERT INTO `oa_admin_menu` VALUES (24, 3, '企业员工', 'home/admin/index', '
INSERT INTO `oa_admin_menu` VALUES (25, 3, '人事调动', 'home/personal/change', '',1,0,0);
INSERT INTO `oa_admin_menu` VALUES (26, 3, '离职档案', 'home/personal/leave', '',1,0,0);
INSERT INTO `oa_admin_menu` VALUES (27, 4, '收件箱', 'home/mail/inbox', '',1,0,0);
INSERT INTO `oa_admin_menu` VALUES (28, 4, '已发送', 'home/mail/sendbox', '',1,0,0);
INSERT INTO `oa_admin_menu` VALUES (29, 4, '草稿箱', 'home/mail/draft', '',1,0,0);
INSERT INTO `oa_admin_menu` VALUES (30, 4, '垃圾箱', 'home/mail/rubbish', '',1,0,0);
INSERT INTO `oa_admin_menu` VALUES (27, 4, '收件箱', 'home/message/inbox', '',1,0,0);
INSERT INTO `oa_admin_menu` VALUES (28, 4, '已发送', 'home/message/sendbox', '',1,0,0);
INSERT INTO `oa_admin_menu` VALUES (29, 4, '草稿箱', 'home/message/draft', '',1,0,0);
INSERT INTO `oa_admin_menu` VALUES (30, 4, '垃圾箱', 'home/message/rubbish', '',1,0,0);
INSERT INTO `oa_admin_menu` VALUES (31, 5, '公告类别', 'home/note/cate', '',1,0,0);
INSERT INTO `oa_admin_menu` VALUES (32, 5, '公告列表', 'home/note/index', '',1,0,0);
@ -272,17 +272,17 @@ INSERT INTO `oa_admin_rule` VALUES (64, 3, 'home/personal/leave', '离职档案'
INSERT INTO `oa_admin_rule` VALUES (65, 64, 'home/personal/leave_add', '新增/编辑离职档案','离职档案',1,0,0);
INSERT INTO `oa_admin_rule` VALUES (66, 64, 'home/personal/leave_delete', '删除离职档案','离职档案',1,0,0);
INSERT INTO `oa_admin_rule` VALUES (67, 4, 'home/mail/inbox', '收件箱','收件箱',1,0,0);
INSERT INTO `oa_admin_rule` VALUES (68, 67, 'home/mail/add', '添加/修改消息','消息',1,0,0);
INSERT INTO `oa_admin_rule` VALUES (69, 67, 'home/mail/send', '发送消息','消息',1,0,0);
INSERT INTO `oa_admin_rule` VALUES (70, 67, 'home/mail/save', '保存消息到草稿','消息到草稿',1,0,0);
INSERT INTO `oa_admin_rule` VALUES (71, 67, 'home/mail/reply', '回复消息','消息',1,0,0);
INSERT INTO `oa_admin_rule` VALUES (72, 67, 'home/mail/check', '设置消息状态','消息状态',1,0,0);
INSERT INTO `oa_admin_rule` VALUES (73, 67, 'home/mail/read', '查看消息','消息',1,0,0);
INSERT INTO `oa_admin_rule` VALUES (67, 4, 'home/message/inbox', '收件箱','收件箱',1,0,0);
INSERT INTO `oa_admin_rule` VALUES (68, 67, 'home/message/add', '添加/修改消息','消息',1,0,0);
INSERT INTO `oa_admin_rule` VALUES (69, 67, 'home/message/send', '发送消息','消息',1,0,0);
INSERT INTO `oa_admin_rule` VALUES (70, 67, 'home/message/save', '保存消息到草稿','消息到草稿',1,0,0);
INSERT INTO `oa_admin_rule` VALUES (71, 67, 'home/message/reply', '回复消息','消息',1,0,0);
INSERT INTO `oa_admin_rule` VALUES (72, 67, 'home/message/check', '设置消息状态','消息状态',1,0,0);
INSERT INTO `oa_admin_rule` VALUES (73, 67, 'home/message/read', '查看消息','消息',1,0,0);
INSERT INTO `oa_admin_rule` VALUES (74, 4, 'home/mail/sendbox', '发件箱','发件箱',1,0,0);
INSERT INTO `oa_admin_rule` VALUES (75, 4, 'home/mail/draft', '草稿箱','草稿箱',1,0,0);
INSERT INTO `oa_admin_rule` VALUES (76, 4, 'home/mail/rubbish', '垃圾箱','垃圾箱',1,0,0);
INSERT INTO `oa_admin_rule` VALUES (74, 4, 'home/message/sendbox', '发件箱','发件箱',1,0,0);
INSERT INTO `oa_admin_rule` VALUES (75, 4, 'home/message/draft', '草稿箱','草稿箱',1,0,0);
INSERT INTO `oa_admin_rule` VALUES (76, 4, 'home/message/rubbish', '垃圾箱','垃圾箱',1,0,0);
INSERT INTO `oa_admin_rule` VALUES (77, 5, 'home/note/cate', '公告分类','公告分类',1,0,0);
INSERT INTO `oa_admin_rule` VALUES (78, 77, 'home/note/cate_add', '添加/修改公告分类','公告分类',1,0,0);
@ -716,39 +716,39 @@ CREATE TABLE `oa_keywords` (
INSERT INTO `oa_keywords`(`id`, `title`, `sort`, `status`, `create_time`, `update_time`) VALUES (1, '勾股OA', 1, 1, 1638006730, 0);
-- ----------------------------
-- Table structure for oa_mail
-- Table structure for oa_message
-- ----------------------------
DROP TABLE IF EXISTS `oa_mail`;
CREATE TABLE `oa_mail` (
DROP TABLE IF EXISTS `oa_message`;
CREATE TABLE `oa_message` (
`id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
`name` varchar(100) NOT NULL DEFAULT '' COMMENT '消息主题',
`type` tinyint(1) UNSIGNED NULL DEFAULT 0 COMMENT '阅览人类型0 人员 1部门 2岗位 3全部',
`type_user` text NULL COMMENT '人员ID或部门ID或角色ID全员则为空',
`mail_type` tinyint(1) UNSIGNED NULL DEFAULT 1 COMMENT '消息类型1系统消息2同事消息',
`title` varchar(100) NOT NULL DEFAULT '' COMMENT '消息主题',
`template` tinyint(2) NOT NULL DEFAULT 0 COMMENT '消息模板,用于前端拼接消息',
`content` text NULL COMMENT '消息内容',
`from_uid` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '发送人id',
`to_uid` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '接收人id',
`type` tinyint(1) UNSIGNED NULL DEFAULT 0 COMMENT '阅览人类型1 人员 2部门 3岗位 4全部',
`type_user` text NULL COMMENT '人员ID或部门ID或角色ID全员则为空',
`send_time` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '发送日期',
`content` text NULL COMMENT '消息内容',
`is_read` tinyint(1) UNSIGNED NOT NULL DEFAULT 1 COMMENT '是否已读1未读消息2已读消息',
`admin_id` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建人',
`did` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建人所属部门',
`read_time` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '阅读时间',
`module_name` varchar(30) NOT NULL COMMENT '模块',
`controller_name` varchar(30) NOT NULL COMMENT '控制器',
`action_name` varchar(30) NOT NULL COMMENT '方法',
`action_id` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '操作模块数据的id针对系统消息',
`pid` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '来源发件id',
`fid` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '转发或回复消息关联id',
`status` tinyint(1) NOT NULL DEFAULT 1 COMMENT '状态:-1已删除消息 0垃圾消息 1正常消息',
`is_draft` tinyint(1) NOT NULL DEFAULT 1 COMMENT '是否是草稿1正常消息 2草稿消息',
`delete_source` tinyint(1) UNSIGNED NULL DEFAULT 0 COMMENT '垃圾消息来源: 1已发消息 2草稿消息 3已收消息',
`action` varchar(50) NOT NULL DEFAULT '' COMMENT '来源模块(针对系统消息)',
`action_id` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '来源模块数据的id针对系统消息',
`create_time` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '创建时间',
`update_time` int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '更新时间',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COMMENT = '消息表';
-- ----------------------------
-- Table structure for oa_mail_file_interfix
-- Table structure for oa_message_file_interfix
-- ----------------------------
DROP TABLE IF EXISTS `oa_mail_file_interfix`;
CREATE TABLE `oa_mail_file_interfix` (
DROP TABLE IF EXISTS `oa_message_file_interfix`;
CREATE TABLE `oa_message_file_interfix` (
`id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
`mid` int(11) UNSIGNED NOT NULL COMMENT '消息id',
`file_id` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '相关联附件id',

View File

@ -41,5 +41,27 @@ return [
],
// 其它日志通道配置
],
'type_action' => [
'login' => '登录',
'upload' => '上传',
'down' => '下载',
'import' => '导入',
'export' => '导出',
'add' => '新增',
'edit' => '编辑',
'view' => '查看',
'save' => '保存',
'delete' => '删除',
'send' => '发送',
'disable' => '禁用',
'recovery' => '恢复',
'apply' => '申请',
'check' => '审核通过',
'refue' => '审核拒绝',
'open' => '开具',
'tovoid' => '作废',
'leave' => '离职',
'reset' => '重新设置',
],
];

47
config/message.php Normal file
View File

@ -0,0 +1,47 @@
<?php
// +----------------------------------------------------------------------
// | 缓存设置
// +----------------------------------------------------------------------
return [
// 系统消息模板
'template' => [
1 => [
'name' => '公告',
'template' => '您有一个新公告:{title} ,请及时查看。',
],
2 => [
'type' => '报销审批',
'template' => '{from_user} 提交 {title} 报销审批,请及时处理。',
],
3 => [
'type' => '报销审批',
'template' => '{from_user} 拒绝您的 {title} 报销审批,拒绝理由:{remark},请及时处理。',
],
4 => [
'type' => '报销审批',
'template' => '您的 {title} 报销已经审批通过,请及时查看。',
],
5 => [
'type' => '报销发放',
'template' => '您的 {title} 报销已经发放,请查看是否到账。',
],
6 => [
'type' => '发票审批',
'template' => '{from_user} 提交 {title} 发票审批待您处理,请及时查看。',
],
7 => [
'type' => '发票审批',
'template' => '{from_user} 拒绝您的 {title} 发票审批,请及时处理。',
],
8 => [
'type' => '发票审批',
'template' => '您的 {title} 发票已经审批通过,请及时查看。',
],
9 => [
'type' => '发票审批',
'template' => '您的 {title} 发票已经开票成功,请及时查看。',
],
],
];

View File

@ -6,7 +6,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>跳转提示</title>
<?php if(isMobile()==true){?>
<?php if(is_mobile()==true){?>
<style type="text/css">
body, h1, h2, p,dl,dd,dt{margin: 0;padding: 0;font: 15px/1.5 ,tahoma,arial;}
body{background:#efefef;}