diff --git a/src/Controllers/UserController.php b/src/Controllers/UserController.php index 7f289202..65f37bb2 100755 --- a/src/Controllers/UserController.php +++ b/src/Controllers/UserController.php @@ -9,6 +9,7 @@ use App\Models\Config; use App\Models\LoginIp; use App\Models\Node; use App\Models\OnlineLog; +use App\Models\Huodong; use App\Services\Auth; use App\Services\Captcha; use App\Services\Reward; @@ -38,10 +39,20 @@ final class UserController extends BaseController if (Config::obtain('enable_checkin_captcha')) { $captcha = Captcha::generate(); } - + + $oAnn = (new Ann())->orderBy('date', 'desc')->first(); + + $oHuodong = Huodong::DateHit(); + + $sHuodongStr = $oHuodong->title.":".$oHuodong->content; + + $oAnn->content = str_replace("{{huodong}}", $sHuodongStr, $oAnn->content); + + $oAnn->date = date("Y-m-d", strtotime($oAnn->date)); + return $response->write( $this->view() - ->assign('ann', (new Ann())->orderBy('date', 'desc')->first()) + ->assign('ann', $oAnn) ->assign('captcha', $captcha) ->assign('class_expire_days', $class_expire_days) ->assign('UniversalSub', Subscribe::getUniversalSubLink($this->user)) diff --git a/src/Models/Huodong.php b/src/Models/Huodong.php index bd7a2400..63457149 100755 --- a/src/Models/Huodong.php +++ b/src/Models/Huodong.php @@ -6,30 +6,18 @@ namespace App\Models; use Illuminate\Database\Query\Builder; -/** - * @property int $id 工单ID - * @property string $title 工单标题 - * @property string $content 工单内容 - * @property int $userid 用户ID - * @property int $datetime 创建时间 - * @property string $status 工单状态 - * @property string $type 工单类型 - * - * @mixin Builder - */ final class Huodong extends Model { protected $connection = 'default'; protected $table = 'huodong'; -// public function type(): string -// { -// return match ($this->type) { -// 'howto' => '使用', -// 'billing' => '财务', -// 'account' => '账户', -// default => '其他', -// }; -// } + public static function DateHit($sDate = null) + { + $sDate = $sDate ?? date("Y-m-d"); + + $oHuodong = self::where("start_date", "<=", $sDate)->where("end_date", ">=", $sDate)->first(); + + return $oHuodong; + } }