From 9b794ee251f2806bb84ad25a71c83754d022c57e Mon Sep 17 00:00:00 2001 From: cloud Date: Wed, 30 Dec 2020 21:45:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=AE=A2=E5=8D=95=E5=88=B0?= =?UTF-8?q?=E6=9C=9F=E6=8F=90=E9=86=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/traits/tdata.class.php | 3 +-- include/traits/tlist.class.php | 47 ++++++++++++++++++---------------- src/update/update.class.php | 16 +++++++----- 3 files changed, 35 insertions(+), 31 deletions(-) diff --git a/include/traits/tdata.class.php b/include/traits/tdata.class.php index afced6e..2341e79 100644 --- a/include/traits/tdata.class.php +++ b/include/traits/tdata.class.php @@ -486,8 +486,7 @@ trait tdata $where .= self::td_search(); break; case 'noticeday': - $where .= ' AND ( (endtime BETWEEN DATE_SUB( CURDATE(), INTERVAL 3 DAY ) AND CURDATE()) OR ' //到期提醒 展示3天 // DATE_SUB - . '(h_endtime BETWEEN DATE_SUB( CURDATE(), INTERVAL 3 DAY ) AND DATE_ADD( CURDATE(), INTERVAL 3 DAY ) ) )'; //订单到期前后展示3天 // DATE_ADD + $where .= ' AND endtime = CURDATE()'; //订单到期前后展示3天 // DATE_ADD break; default: // 如果$where 没有值 会导致计算结果出错,导致前台表格无法获取正确的值,分页显示异常 diff --git a/include/traits/tlist.class.php b/include/traits/tlist.class.php index 0cb4db7..3bc6f3e 100644 --- a/include/traits/tlist.class.php +++ b/include/traits/tlist.class.php @@ -116,6 +116,30 @@ trait tlist } } + // 到期通知计算【新的】 + protected function noticestr($noticeday) + { + //首先判断当前这条信息是属于到期前台3天的 还是属于设置的提醒 + //那就是判断订单结束时间和今天的相差天数 + $day = abs($noticeday); + if ($noticeday > 3) { + //按照设置的提醒来计算 + $str = parent::str_color(1, $day, 800); + $htypes = "{$str} 天后到期提醒"; + } else { + //按照前后3天来设置 + if ($noticeday > 0) { + $str = parent::str_color(4, $day, 800); + //说明还没到期 + $htypes = "{$str} 天后到期"; + } else { + //说明已经到期或者过期 + $htypes = $noticeday == 0 ? parent::str_color(0, '今天到期', 800) : parent::str_color(5, "已过期 {$day} 天", 800); + } + } + return $htypes; + } + // +---------------------------------------------------------------------- // | 各表处理 // +---------------------------------------------------------------------- @@ -650,33 +674,12 @@ trait tlist $workersstr[] = self::$workers[ $hwid ]; } - $h_endtime = strtotime($val['h_endtime']); - $curdate = strtotime(date('Y-m-d', time())); - //首先判断当前这条信息是属于到期前台3天的 还是属于设置的提醒 - //那就是判断订单结束时间和今天的相差天数 - $day = abs(($h_endtime - $curdate) / 86400); - if ($day > 3) { - //按照设置的提醒来计算 - $str = parent::str_color(0, $val['noticeday'], 800); - $htypes = "{$str} 天后到期提醒"; - } else { - //按照前后3天来设置 - if ($h_endtime > $curdate) { - $str = parent::str_color(0, $day, 800); - //说明还没到期 - $htypes = "{$str} 天后到期"; - } else { - //说明已经到期或者过期 - $htypes = $day == 0 ? parent::str_color(0, '今天到期', 800) : parent::str_color(0, "已过期 {$day} 天", 800); - } - } - //设置的到期提醒 //订单到期前后3天提醒 + $val['htypes'] = self::noticestr($val['noticeday']); $val['h_cid'] = self::$customer[ $val['h_cid'] ]; $val['h_wid'] = parent::tab_tokenfield(arrayto_string($workersstr), 1); - $val['htypes'] = $htypes; $numberurl = $this->own_name_table . 'contract&h_number=' . $val['h_number']; $val['h_number'] = ' ' . $val['h_number'] . ''; diff --git a/src/update/update.class.php b/src/update/update.class.php index bdf1c1c..f091e9e 100644 --- a/src/update/update.class.php +++ b/src/update/update.class.php @@ -351,15 +351,17 @@ class update extends admin $sequence = self::split_table_name('sequence', true); $contract = self::split_table_name('contract', true); $noticeday = self::split_table_name('noticeday', true); - $array['noticeday'] = " CREATE VIEW {$noticeday} AS - SELECT + $h_noticeday = "CONCAT_WS(',','3,2,1,0,-1,-2,-3',`ct`.`h_noticeday`)"; + $array['noticeday'] = " CREATE VIEW {$noticeday} AS + SELECT DISTINCT ct.*, - substring_index( substring_index( ct.h_noticeday, ',', sq.seq ), ',',- ( 1 ) ) AS noticeday, - DATE_SUB(ct.h_endtime,INTERVAL substring_index( substring_index( ct.h_noticeday, ',', sq.seq ), ',',- ( 1 ) ) DAY) AS endtime, - sq.seq + substring_index( substring_index( {$h_noticeday}, ',', sq.seq ), ',',- ( 1 ) ) AS noticeday, + DATE_SUB(ct.h_endtime,INTERVAL substring_index( substring_index( {$h_noticeday}, ',', sq.seq ), ',',- ( 1 ) ) DAY) AS endtime FROM - {$sequence} AS sq INNER JOIN {$contract} AS ct - ON sq.seq <= ( ( 1 + length( ct.h_noticeday ) ) - length( REPLACE ( ct.h_noticeday, ',', '' ) ) ) "; + {$sequence} AS sq INNER JOIN {$contract} AS ct + ON sq.seq <= ( ( 1 + length( {$h_noticeday} ) ) - length( REPLACE ( {$h_noticeday}, ',', '' ) ) ) + WHERE + `ct`.`h_endtime` IS NOT NULL"; //查询微信关注用户,排除非关注的用户 $weuser = self::split_table_name('weuser', true);