优化合同到期提醒

This commit is contained in:
cloud 2020-12-30 23:43:59 +08:00
parent 9b794ee251
commit a50e90b2a3
3 changed files with 7 additions and 8 deletions

View File

@ -486,7 +486,7 @@ trait tdata
$where .= self::td_search(); $where .= self::td_search();
break; break;
case 'noticeday': case 'noticeday':
$where .= ' AND endtime = CURDATE()'; //订单到期前后展示3天 // DATE_ADD $where .= " AND endtime = CURDATE() "; //订单到期前后展示3天 // DATE_ADD
break; break;
default: default:
// 如果$where 没有值 会导致计算结果出错,导致前台表格无法获取正确的值,分页显示异常 // 如果$where 没有值 会导致计算结果出错,导致前台表格无法获取正确的值,分页显示异常

View File

@ -355,7 +355,7 @@ class update extends admin
$array['noticeday'] = " CREATE VIEW {$noticeday} AS $array['noticeday'] = " CREATE VIEW {$noticeday} AS
SELECT DISTINCT SELECT DISTINCT
ct.*, ct.*,
substring_index( substring_index( {$h_noticeday}, ',', sq.seq ), ',',- ( 1 ) ) AS noticeday, cast(substring_index( substring_index( {$h_noticeday}, ',', sq.seq ), ',',- ( 1 ) ) AS signed) AS noticeday,
DATE_SUB(ct.h_endtime,INTERVAL substring_index( substring_index( {$h_noticeday}, ',', sq.seq ), ',',- ( 1 ) ) DAY) AS endtime DATE_SUB(ct.h_endtime,INTERVAL substring_index( substring_index( {$h_noticeday}, ',', sq.seq ), ',',- ( 1 ) ) DAY) AS endtime
FROM FROM
{$sequence} AS sq INNER JOIN {$contract} AS ct {$sequence} AS sq INNER JOIN {$contract} AS ct

View File

@ -59,25 +59,24 @@ class timing extends appweb
$num = ['daya' => 0, 'dayb' => 0, 'dayc' => 0]; $num = ['daya' => 0, 'dayb' => 0, 'dayc' => 0];
//查询到期订单 //查询到期订单
//查询的是设置的提醒天数以及订单结束日期的前后3天数 //查询的是设置的提醒天数以及订单结束日期的前后3天数
$where = " endtime = CURDATE() OR (h_endtime BETWEEN CURDATE() AND DATE_ADD( CURDATE(), INTERVAL 3 DAY ) ) "; $where = " AND endtime = CURDATE() AND noticeday >= 0 ";
$noticeday = $this->tsql->table('noticeday')->where($where)->all(); $noticeday = $this->tsql->table('noticeday')->where($where)->all();
foreach ($noticeday as $val) { foreach ($noticeday as $val) {
//延时2秒 //延时2秒 // 通知天数 noticeday
sleep(3); sleep(3);
$h_endtime = strtotime($val['h_endtime']);
//首先判断当前这条信息是属于到期前台3天的 还是属于设置的提醒 //首先判断当前这条信息是属于到期前台3天的 还是属于设置的提醒
//那就是判断订单结束时间和今天的相差天数 //那就是判断订单结束时间和今天的相差天数
$day = abs(($h_endtime - $strdate) / 86400); $day = $val['noticeday'];
if ($day > 3) { if ($day > 3) {
//按照设置的提醒来计算 //按照设置的提醒来计算
$htypes = "合同 {$val['noticeday']} 天后到期提醒"; $htypes = "合同 {$day} 天后到期提醒";
//蓝色 //蓝色
$color = "#57c7d4"; $color = "#57c7d4";
$type = 1; $type = 1;
$num['daya']++; $num['daya']++;
} else { } else {
//说明还没到期 //说明还没到期
if ($h_endtime > $strdate) { if ($day > 0) {
$htypes = "合同 {$day} 天后到期"; $htypes = "合同 {$day} 天后到期";
//黄色 //黄色
$color = "#f2a654"; $color = "#f2a654";