ShopBootstrap.php 974 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: dingran
  5. * Date: 2019/3/12
  6. * Time: 下午5:42
  7. */
  8. namespace app\common\middleware;
  9. use app\common\helpers\Url;
  10. use app\common\services\Utils;
  11. use app\common\traits\JsonTrait;
  12. use app\platform\modules\application\models\AppUser;
  13. class ShopBootstrap
  14. {
  15. use JsonTrait;
  16. private $authRole = ['operator', 'clerk'];
  17. public function handle($request, \Closure $next, $guard = null)
  18. {
  19. if (\Auth::guard('admin')->user()->uid !== 1) {
  20. $account = AppUser::getAccount(\Auth::guard('admin')->user()->uid);
  21. if (!is_null($account) && in_array($account->role, $this->authRole)) {
  22. \YunShop::app()->uniacid = $account->uniacid;
  23. Utils::addUniacid($account->uniacidb);
  24. return $this->successJson('成功', ['url' => Url::absoluteWeb('index.index', ['uniacid' => $account->uniacid])]);
  25. }
  26. }
  27. return $next($request);
  28. }
  29. }