优化订单到期提醒

This commit is contained in:
cloud 2020-12-30 21:45:55 +08:00
parent 7b1246a856
commit 9b794ee251
3 changed files with 35 additions and 31 deletions

View File

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

View File

@ -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 ]; $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天提醒 //订单到期前后3天提醒
$val['htypes'] = self::noticestr($val['noticeday']);
$val['h_cid'] = self::$customer[ $val['h_cid'] ]; $val['h_cid'] = self::$customer[ $val['h_cid'] ];
$val['h_wid'] = parent::tab_tokenfield(arrayto_string($workersstr), 1); $val['h_wid'] = parent::tab_tokenfield(arrayto_string($workersstr), 1);
$val['htypes'] = $htypes;
$numberurl = $this->own_name_table . 'contract&h_number=' . $val['h_number']; $numberurl = $this->own_name_table . 'contract&h_number=' . $val['h_number'];
$val['h_number'] = '<a href="' . $numberurl . '" title="查看排期"> ' . $val['h_number'] . '</a>'; $val['h_number'] = '<a href="' . $numberurl . '" title="查看排期"> ' . $val['h_number'] . '</a>';

View File

@ -351,15 +351,17 @@ class update extends admin
$sequence = self::split_table_name('sequence', true); $sequence = self::split_table_name('sequence', true);
$contract = self::split_table_name('contract', true); $contract = self::split_table_name('contract', true);
$noticeday = self::split_table_name('noticeday', true); $noticeday = self::split_table_name('noticeday', true);
$array['noticeday'] = " CREATE VIEW {$noticeday} AS $h_noticeday = "CONCAT_WS(',','3,2,1,0,-1,-2,-3',`ct`.`h_noticeday`)";
SELECT $array['noticeday'] = " CREATE VIEW {$noticeday} AS
SELECT DISTINCT
ct.*, ct.*,
substring_index( substring_index( ct.h_noticeday, ',', sq.seq ), ',',- ( 1 ) ) AS noticeday, substring_index( substring_index( {$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, DATE_SUB(ct.h_endtime,INTERVAL substring_index( substring_index( {$h_noticeday}, ',', sq.seq ), ',',- ( 1 ) ) DAY) AS endtime
sq.seq
FROM FROM
{$sequence} AS sq INNER JOIN {$contract} AS ct {$sequence} AS sq INNER JOIN {$contract} AS ct
ON sq.seq <= ( ( 1 + length( ct.h_noticeday ) ) - length( REPLACE ( ct.h_noticeday, ',', '' ) ) ) "; 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); $weuser = self::split_table_name('weuser', true);