Skip to content

Commit

Permalink
修改 商店插件时区配置为空字符串报错的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
liufei-ereach committed Sep 10, 2024
1 parent 5af7a3c commit 57900bf
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Console/Command/AutoCheckInCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,17 @@ class AutoCheckInCommand extends AbstractCommand
protected $events;
protected $settings;

private $storeTimezone = 'Asia/Shanghai';

public function __construct(SettingsRepositoryInterface $settings, TranslatorInterface $translator, Repository $cache, Dispatcher $events) {
parent::__construct();
$this->cache = $cache;
$this->events = $events;
$this->settings = $settings;
$this->translator = $translator;

$storeTimezone = $this->settings->get('mattoid-store.storeTimezone', 'Asia/Shanghai');
$this->storeTimezone = !!$storeTimezone ? $storeTimezone : 'Asia/Shanghai';
}

protected function configure()
Expand All @@ -33,7 +38,7 @@ protected function configure()

protected function fire()
{
$datetime = Carbon::now()->tz($this->settings->get('mattoid-store.storeTimezone','Asia/Shanghai'));
$datetime = Carbon::now()->tz($this->storeTimezone);
$cartList = StoreCartModel::query()->where('outtime', '>=', $datetime)->where('status', 1)->where('code', 'autoCheckIn')->groupBy('user_id')->get();

foreach ($cartList as $cart) {
Expand Down

0 comments on commit 57900bf

Please sign in to comment.