fuc-new/src/Controllers/TomApi/HuodongController.php
hellcat 1fe8673f62 1
2025-10-01 13:34:29 +08:00

66 lines
1.6 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
declare(strict_types=1);
namespace App\Controllers\TomApi;
use Psr\Http\Message\ResponseInterface;
use Slim\Http\Response;
use Slim\Http\ServerRequest;
use App\Models\Huodong;
//use App\Models\TgStep;
final class HuodongController
{
public function findByDate(ServerRequest $request, Response $response, array $args)
{
$sFindDate = $args['date'];
$oHuodong = Huodong::where("start_date", "<=", $sFindDate)->where("end_date", ">=", $sFindDate)->first();
if ($oHuodong) {
echo json_encode($oHuodong);
}
exit;
}
public function dateHit(ServerRequest $request, Response $response, array $args)
{
$sDate = $args["date"] ?? date("Y-m-d");
// test
// $sDate = "2025-01-01";
$oHuodong = Huodong::where("start_date", "<=", $sDate)->where("end_date", ">=", $sDate)->first();
if ($oHuodong) {
$oHuodong->start_date_str = date("n月j日", strtotime($oHuodong->start_date));
$oHuodong->end_date_str = date("n月j日", strtotime($oHuodong->end_date));
$oHuodong->str = $oHuodong->title."".$oHuodong->start_date_str."".$oHuodong->end_date_str."期间,".$oHuodong->content;
$aReturn = [
"status" => 1,
"data" => $oHuodong
];
} else {
$aReturn = [
"status" => 0
];
}
echo json_encode($aReturn);
exit;
}
}