erp/app/api/controller/financial/FinancialRecordController.php

46 lines
1.2 KiB
PHP

<?php
namespace app\api\controller\financial;
use app\api\controller\BaseApiController;
use app\api\lists\financial\FinancialRecordLists;
/**
* 商品分类控制器
* Class GoodsclassController
* @package app\admin\controller\goods
*/
class FinancialRecordController extends BaseApiController
{
/**
* @notes 获取商户流水统计
* @return \think\response\Json
* @author likeadmin
* @date 2024/04/23 10:27
*/
public function lists()
{
$start_time = $this->request->get('start_time');
$end_time = $this->request->get('end_time');
if(!isset($start_time)||!isset($end_time)){
$start_time=date('Y-m-d',time());
$end_time=date('Y-m-d',strtotime('-7 days'));
}
$start_time = strtotime($start_time); // 开始时间
$end_time = strtotime($end_time); // 结束时间
// 计算时间差
$time_diff = $end_time - $start_time;
// 7天内的秒数
$seven_days_in_seconds = 7 * 24 * 60 * 60;
// 验证时间差是否在7天内
if ($time_diff > $seven_days_in_seconds) {
return $this->fail('时间差不能超过7天');
}
return $this->dataLists((new FinancialRecordLists));
}
}