[ 'phone_area' => 'alpha_dash:ascii|max:5', 'phone' => 'numeric|max:15', ], 'sendVrcodeCode' => [ 'topic' => 'required|numeric', 'phone_area' => 'alpha_dash:ascii|max:5', 'phone' => 'numeric|max:15', ], ]; // no need login function sendRegCode(): \Illuminate\Http\JsonResponse { //发送短信验证码 $request = request(); $aReqData = $request->only([ 'phone_area', 'phone', ]); $oVrCodeService = new VrCodeService(); $oVrCodeService->setIType(VrCode::TOPIC_REGISTER); $validator = Validator::make($aReqData, [ 'phone_area' => 'required|alpha_dash:ascii|max:5', 'phone' => 'required|digits_between:6,15', ]); if ($validator->fails()) { return $this->error($validator->errors()->first()); } $oCustomerUser = new CustomerUserModel(); $oUser = $oCustomerUser->findItemByPhone($aReqData['phone_area'],$aReqData['phone'],['id']); if ($oUser) { return $this->error('vrcode error'); } $oVrCodeService->setSPhoneArea($aReqData['phone_area']); $oVrCodeService->setSPhone($aReqData['phone']); $oVrCodeService->sendCode(); return $this->success(); } //must login /** * @throws ContainerExceptionInterface * @throws AppException * @throws NotFoundExceptionInterface */ function sendVrcodeCode(): \Illuminate\Http\JsonResponse { //发送短信验证码 $request = request(); $aReqData = $request->only([ 'topic', 'phone_area', 'phone', ]); if(!in_array($aReqData['topic'],VrCode::TOPIC)) return $this->error('invalid vrcode type'); $oVrCodeService = new VrCodeService(); $oVrCodeService->setIType($aReqData['topic']); $oAuthService = new AuthService(); $aUser = $oAuthService->getCurrentUser(); if($aUser == null) return $this->error('user not login'); $oVrCodeService->setIUid($aUser['id']); $oVrCodeService->sendCode(); return $this->success(); } }