feat: #10000 店铺授权过期状态更新

This commit is contained in:
赵世界 2023-02-10 18:13:44 +08:00
parent 60eaa6cb73
commit b378e2fbb8

View File

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