diff --git a/app/Controller/v3/SmsController.php b/app/Controller/v3/SmsController.php index 4d6eaa2..5a7d40d 100644 --- a/app/Controller/v3/SmsController.php +++ b/app/Controller/v3/SmsController.php @@ -34,7 +34,7 @@ class SmsController extends BaseController // 获取参数 $params = $request->validated(); // 获取并发送验证码 - $this->verifyCodeService->make($params['user_id'], $params['tel']); + $this->verifyCodeService->do($params['user_id'], $params['tel']); return $this->success([]); } diff --git a/app/Controller/v3/UserController.php b/app/Controller/v3/UserController.php index 58112ac..122680d 100644 --- a/app/Controller/v3/UserController.php +++ b/app/Controller/v3/UserController.php @@ -5,7 +5,7 @@ namespace App\Controller\v3; use App\Constants\v3\ErrorCode; use App\Controller\BaseController; use App\Request\v3\UserBindTelRequest; -use App\Service\v3\Interfaces\UserBindServiceInterface; +use App\Service\v3\Interfaces\UserBindTelServiceInterface; use App\Service\v3\Interfaces\VerifyCodeServiceInterface; use Hyperf\Di\Annotation\Inject; @@ -25,9 +25,9 @@ class UserController extends BaseController /** * @Inject - * @var UserBindServiceInterface + * @var UserBindTelServiceInterface */ - protected $userBindService; + protected $userBindTelService; public function bindTel(UserBindTelRequest $request) { @@ -37,7 +37,7 @@ class UserController extends BaseController // 校验验证码 $this->verifyCodeService->check($params['user_id'], $params['tel'], $params['verify_code']); // 绑定 - $this->userBindService->makeTel($params['user_id'], $params['tel']); + $this->userBindTelService->do($params['user_id'], $params['tel']); return $this->success([]); } diff --git a/app/Service/v3/Implementations/SmsAliService.php b/app/Service/v3/Implementations/SmsAliSendService.php similarity index 81% rename from app/Service/v3/Implementations/SmsAliService.php rename to app/Service/v3/Implementations/SmsAliSendService.php index 4eccbea..fe86434 100644 --- a/app/Service/v3/Implementations/SmsAliService.php +++ b/app/Service/v3/Implementations/SmsAliSendService.php @@ -11,9 +11,9 @@ use Exception; use App\Commons\Log; use App\Constants\v3\SmsTemplateCode; use Hyperf\Di\Annotation\Inject; -use App\Service\v3\Interfaces\SmsServiceInterface; +use App\Service\v3\Interfaces\SmsSendServiceInterface; -class SmsAliService implements SmsServiceInterface +class SmsAliSendService implements SmsSendServiceInterface { /** @@ -22,7 +22,7 @@ class SmsAliService implements SmsServiceInterface */ protected $log; - public function send($tel, $template, $templateParams) + public function do($tel, $template, $templateParams) { try { @@ -60,10 +60,20 @@ class SmsAliService implements SmsServiceInterface } } - public function makeVerifyCode($tel, $code) + public function check() + { + // TODO: Implement check() method. + } + + public function undo() + { + // TODO: Implement undo() method. + } + + public function doVerifyCode($tel, $code) { $params = ['user_name' => '疯狂的水叔叔', 'market_name' => '验证码', 'money' => $code]; - return $this->send($tel, SmsTemplateCode::ALI_VERIFY_CODE, json_encode($params)); + return $this->do($tel, SmsTemplateCode::ALI_VERIFY_CODE, json_encode($params)); } public function checkVerifyCode($tel, $code) @@ -71,8 +81,9 @@ class SmsAliService implements SmsServiceInterface // TODO: Implement checkVerifyCode() method. } - public function removeVerifyCode($tel, $code) + public function undoVerifyCode($tel, $code) { // TODO: Implement removeVerifyCode() method. } + } \ No newline at end of file diff --git a/app/Service/v3/Implementations/UserBindService.php b/app/Service/v3/Implementations/UserBindTelService.php similarity index 73% rename from app/Service/v3/Implementations/UserBindService.php rename to app/Service/v3/Implementations/UserBindTelService.php index 3dc6b88..8d4552d 100644 --- a/app/Service/v3/Implementations/UserBindService.php +++ b/app/Service/v3/Implementations/UserBindTelService.php @@ -5,12 +5,12 @@ namespace App\Service\v3\Implementations; use App\Constants\v3\ErrorCode; use App\Exception\ErrorCodeException; use App\Model\v3\User; -use App\Service\v3\Interfaces\UserBindServiceInterface; +use App\Service\v3\Interfaces\UserBindTelServiceInterface; -class UserBindService implements UserBindServiceInterface +class UserBindTelService implements UserBindTelServiceInterface { - public function makeTel($userId, $tel) + public function do($userId, $tel) { $user = User::find($userId); $user->tel = $tel; @@ -20,13 +20,13 @@ class UserBindService implements UserBindServiceInterface return true; } - public function checkTel($userId) + public function check($userId) { $user = User::find($userId); return $user->tel ? true : false; } - public function removeTel($userId) + public function undo($userId) { $user = User::find($userId); $user->tel = ''; diff --git a/app/Service/v3/Implementations/VerifyCodeService.php b/app/Service/v3/Implementations/VerifyCodeService.php index abb48cd..e59846d 100644 --- a/app/Service/v3/Implementations/VerifyCodeService.php +++ b/app/Service/v3/Implementations/VerifyCodeService.php @@ -7,7 +7,7 @@ use App\Constants\v3\SsdbKeys; use App\Exception\BusinessException; use App\Exception\ErrorCodeException; use App\Service\v3\Interfaces\HelperServiceInterface; -use App\Service\v3\Interfaces\SmsServiceInterface; +use App\Service\v3\Interfaces\SmsSendServiceInterface; use App\Service\v3\Interfaces\VerifyCodeServiceInterface; use App\TaskWorker\SSDBTask; use Hyperf\Utils\ApplicationContext; @@ -17,7 +17,7 @@ class VerifyCodeService implements VerifyCodeServiceInterface { /** * @Inject - * @var SmsServiceInterface + * @var SmsSendServiceInterface */ protected $smsService; @@ -27,7 +27,7 @@ class VerifyCodeService implements VerifyCodeServiceInterface */ protected $helperService; - public function make($userId, $tel) + public function do($userId, $tel) { // 获取验证码 $verifyCode = $this->helperService->makeNumCode(6); @@ -53,7 +53,7 @@ class VerifyCodeService implements VerifyCodeServiceInterface } // 发送短信 - $smsRes = $this->smsService->makeVerifyCode($tel, $verifyCode); + $smsRes = $this->smsService->doVerifyCode($tel, $verifyCode); if (!$smsRes) { throw new ErrorCodeException(ErrorCode::VERIFY_CODE_ERROR); } @@ -73,12 +73,12 @@ class VerifyCodeService implements VerifyCodeServiceInterface throw new ErrorCodeException(ErrorCode::INVALID_VERIFY_CODE); } - $this->remove($userId, $tel); + $this->undo($userId, $tel); return true; } - public function remove($userId, $tel) + public function undo($userId, $tel) { $ssdbClient = ApplicationContext::getContainer()->get(SSDBTask::class); return $ssdbClient->exec( diff --git a/app/Service/v3/Interfaces/SmsSendServiceInterface.php b/app/Service/v3/Interfaces/SmsSendServiceInterface.php new file mode 100644 index 0000000..d704721 --- /dev/null +++ b/app/Service/v3/Interfaces/SmsSendServiceInterface.php @@ -0,0 +1,13 @@ + \App\Service\SmsAliService::class, \App\Service\OrderListServiceInterface::class => \App\Service\OrderListService::class, \App\Service\v3\Interfaces\GoodsServiceInterface::class => \App\Service\v3\Implementations\GoodsService::class, - \App\Service\v3\Interfaces\SmsServiceInterface::class => \App\Service\v3\Implementations\SmsAliService::class, + \App\Service\v3\Interfaces\SmsSendServiceInterface::class => \App\Service\v3\Implementations\SmsAliSendService::class, \App\Service\v3\Interfaces\HelperServiceInterface::class => \App\Service\v3\Implementations\HelperService::class, \App\Service\v3\Interfaces\VerifyCodeServiceInterface::class => \App\Service\v3\Implementations\VerifyCodeService::class, - \App\Service\v3\Interfaces\UserBindServiceInterface::class => \App\Service\v3\Implementations\UserBindService::class, + \App\Service\v3\Interfaces\UserBindTelServiceInterface::class => \App\Service\v3\Implementations\UserBindTelService::class, \App\Service\v3\Interfaces\OrderServiceInterface::class => \App\Service\v3\Implementations\OrderService::class, ];