Merge pull request !145 from 赵世界/develop
This commit is contained in:
赵世界 2023-02-10 10:15:00 +00:00 committed by Gitee
commit 1d2a84ea58
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -19,11 +19,15 @@ class ShopsController extends Controller
public function index(Request $request)
{
$shops = Shop::query()->filter()->paginate($request->get('per_page'));
$time = time();
foreach ($shops as $shop) {
$shop->authUrl = '';
if ('妙选' !== $shop->plat_id && ('未授权' === $shop->status || '重新授权' === $shop->status)) {
$shop->authUrl = BusinessFactory::init()->make($shop->plat_id)->getAuthUrl($shop->id, $shop->getOriginal('plat_id'));
}
if ($shop->expires_at && $time >= $shop->expires_at) {
Shop::query()->where('id', $shop->id)->update(['status' => Shop::$STATUS_UNAUTHORIZED]);
}
}
return ShopsResource::collection($shops);