修复逻辑: 如果start_time设置, end_time设为start_time前7天. 否则设为7天前.

This commit is contained in:
mkm 2024-05-23 17:03:25 +08:00
parent 4575eccbe5
commit 67d6fc5a3e

View File

@ -22,11 +22,15 @@ class FinancialRecordController extends BaseApiController
public function lists()
{
$start_time = $this->request->get('start_time');
$end_time = $this->request->get('end_time');
if(!isset($start_time)||!isset($end_time)){
// $end_time = $this->request->get('end_time');
if(!isset($start_time)){
$start_time=date('Y-m-d',time());
$end_time=date('Y-m-d',strtotime('-7 days'));
}else{
//start_time设置时间减7天
$end_time=date('Y-m-d',strtotime('-7 days',strtotime($start_time)));
}
$start_time = strtotime($start_time); // 开始时间
$end_time = strtotime($end_time); // 结束时间