offsetSet('is_shop_pos',1); Session::factory(\YunShop::app()->uniacid); } /** * 前置action */ public function preAction() { } public function callAction($method, $parameters) { if (method_exists($this,'preAction')) { call_user_func_array([$this, 'preAction'],$parameters); } // action设置了需要回滚 if (method_exists($this, 'needTransaction') && $this->needTransaction($method)) { return DB::transaction(function() use ($method,$parameters) { return parent::callAction($method, $parameters); }); } $content = parent::callAction($method, $parameters); return $content;// TODO: Change the autogenerated stub } /** * url参数验证 * * @param array $rules * @param Request|null $request * @param array $messages * @param array $customAttributes * * @throws AppException */ public function validate(array $rules, Request $request = null, array $messages = [], array $customAttributes = []) { if (!isset($request)) { $request = request(); } $validator = $this->getValidationFactory()->make($request->all(), $rules, $messages, $customAttributes); if ($validator->fails()) { throw new AppException($validator->errors()->first()); } } /** * 需要回滚 * * @param $action * * @return bool */ private function needTransaction($action) { return in_array($action, $this->transactionActions) || in_array('*', $this->transactionActions) || $this->transactionActions == '*'; } public function dataIntegrated($data, $flag) { if ($this->apiErrMsg) { return $this->successJson($this->apiErrMsg[0]); } if (0 == $data['status']) { $this->apiErrMsg[] = $data['json']; return; } $this->apiData[$flag] = $data['json']; } public function getIsPublic(): bool { return $this->isPublic; } /** * @param $type * @param $mid * @return bool|\Illuminate\Http\JsonResponse */ protected function jumpUrl($type, $mid) { if (empty($type) || $type == 'undefined') { $type = Client::getType(); } $scope = request()->input('scope', ''); $queryString = ['type' => $type, 'i' => \YunShop::app()->uniacid, 'mid' => $mid, 'scope' => $scope]; if (in_array($type, [MemberFactory::LOGIN_MINI_APP, MemberFactory::LOGIN_DOUYIN, MemberFactory::LOGIN_MINI_APP_FACE])) { return $this->errorJson('请登录', ['login_status' => 0, 'login_url' => Url::absoluteApi('member.login.index', $queryString)]); } if (($scope == 'home' && !$mid) || $scope == 'pass') { return true; } if (in_array($type, [MemberFactory::LOGIN_MOBILE, MemberFactory::LOGIN_APP_YDB, MemberFactory::LOGIN_Native, MemberFactory::LOGIN_APP_ANCHOR, MemberFactory::LOGIN_APP_LSP_WALLET])) { return $this->errorJson('请登录', ['login_status' => 1, 'login_url' => '', 'type' => $type, 'i' => \YunShop::app()->uniacid, 'mid' => $mid, 'scope' => $scope]); } return $this->errorJson('请登录', ['login_status' => 0, 'login_url' => Url::absoluteApi('member.login.index', $queryString)]); } }