Business.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * Name: 芸众商城系统
  5. * Author: 广州市芸众信息科技有限公司
  6. * Profile: 广州市芸众信息科技有限公司位于国际商贸中心的广州,专注于移动电子商务生态系统打造,拥有芸众社交电商系统、区块链数字资产管理系统、供应链管理系统、电子合同等产品/服务。官网 :www.yunzmall.com www.yunzshop.com
  7. * Date: 2021/9/22
  8. * Time: 13:37
  9. */
  10. namespace business\middleware;
  11. use app\common\services\Session;
  12. use app\common\traits\JsonTrait;
  13. use app\common\facades\Setting;
  14. use app\frontend\modules\member\services\factory\MemberFactory;
  15. use business\common\models\PlatLog;
  16. use business\common\services\BusinessService;
  17. use business\common\services\SettingService;
  18. use Closure;
  19. class Business
  20. {
  21. use JsonTrait;
  22. public function handle($request, Closure $next)
  23. {
  24. \YunShop::app()->uniacid = request()->uniacid;
  25. Setting::$uniqueAccountId = request()->uniacid;
  26. $memberService = MemberFactory::create($type);
  27. $is_login = $memberService->checkLogged();
  28. // $route = \request()->path();
  29. // $route = explode('/', $route);
  30. // \YunShop::app()->uniacid = $route[1];
  31. // Setting::$uniqueAccountId = $route[1];
  32. if (!app('plugins')->isEnabled('business-pc') || !\Yunshop\BusinessPc\services\SettingService::getSetting()['open_state']) {
  33. return $this->errorJson('企业管理PC端未开启');
  34. }
  35. if (!$uid = \YunShop::app()->getMemberId()) { //判断当前用户是否已经前端登录
  36. return $this->errorJson(BusinessService::LOGIN_MSG, BusinessService::getLoginReturn());
  37. }
  38. if (!$business_id = SettingService::getBusinessId()) { //如果当前未选择管理的企业
  39. if ($business_id = PlatLog::getPlatLogId()) { //获取企业历史管理记录
  40. SettingService::setBusinessId($business_id); //设置管理的企业
  41. }
  42. }
  43. return $next($request);
  44. }
  45. }