services->validate; $post = $this->request->post(); $rules = [ [['real_name', 'id_no'], 'required'], [['real_name', 'id_no'], 'string'], [['auth_type'],'integer'], [['detail'],'safe'], ]; $labels = [ 'real_name' => '姓名', 'id_no' => '证件号码', ]; $valid = $validateService->validate($post, $rules,$labels); if (!$valid) { throw new \Exception($validateService->getFirstErrorSummary()); } $logic = new AuthLogic(); $post['user_id'] = $this->user_id; $post['mall_id'] = $this->mall_id; $res = $logic->auth($post); if(!$res){ throw new Exception('认证失败'); } return $this->success($res); }catch(Exception $e){ return $this->error($e->getMessage()); } } /** * 认证升级 * * @return string */ public function actionAuthUpgrade() { try{ $validateService = Yii::$app->services->validate; $post = $this->request->post(); $rules = [ [['real_name', 'id_no'], 'required'], [['real_name', 'id_no'], 'string'], [['auth_type'],'integer'], [['detail'],'safe'], ]; $labels = [ 'real_name' => '姓名', 'id_no' => '证件号码', ]; $valid = $validateService->validate($post, $rules,$labels); if (!$valid) { throw new \Exception($validateService->getFirstErrorSummary()); } $logic = new AuthLogic(); $post['user_id'] = $this->user_id; $post['mall_id'] = $this->mall_id; $res = $logic->authUpgrade($post); if(!$res){ throw new Exception('认证失败'); } $config = Yii::$app->services->setting->addons->get($this->mall_id, AddonsEnum::ADDONS_NAME_REAL_AUTH, 'basic'); $msg = '企业信息已提交,工作人员将于'.$config['business_verify_time'].'小时内完成审核'; return $this->success($msg); }catch(Exception $e){ return $this->error($e->getMessage()); } } /** * 获取设置 * * @return string */ public function actionGetSetting() { try{ $logic = new AuthLogic(); $data = $logic->getSetting($this->mall_id,$this->user_id); return $this->success('请求成功', $data); }catch(Exception $e){ return $this->error($e->getMessage()); } } /** * 认证详情 * * @return string */ public function actionAuthDetail() { try{ $logic = new AuthLogic(); $data = $logic->getAuthDetail($this->mall_id,$this->user_id); return $this->success('请求成功', $data,ApiStatusEnum::CODE_SUCCESS,JSON_UNESCAPED_UNICODE); }catch(Exception $e){ return $this->error($e->getMessage()); } } }