From 5e1077a0dbe1c047ce226647339f8ecde7f0cbe5 Mon Sep 17 00:00:00 2001 From: weigang Date: Fri, 11 Sep 2020 14:58:19 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A4=BE=E5=8C=BA=E7=BB=91=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Controller/v3/CommunityController.php | 30 ++++++++++++ app/Request/v3/CommunityBindRequest.php | 45 +++++++++++++++++ .../UserCommunityBindService.php | 36 ++++++++++++++ .../UserRelationBindServiceInterface.php | 48 +++++++++++++++++++ config/autoload/dependencies.php | 1 + config/routes.php | 1 + 6 files changed, 161 insertions(+) create mode 100644 app/Controller/v3/CommunityController.php create mode 100644 app/Request/v3/CommunityBindRequest.php create mode 100644 app/Service/v3/Implementations/UserCommunityBindService.php create mode 100644 app/Service/v3/Interfaces/UserRelationBindServiceInterface.php diff --git a/app/Controller/v3/CommunityController.php b/app/Controller/v3/CommunityController.php new file mode 100644 index 0000000..ab4dfaf --- /dev/null +++ b/app/Controller/v3/CommunityController.php @@ -0,0 +1,30 @@ +validated(); + $jsonData = $data['json_data'] ?? json_encode([]); + $res = $this->userCommunityService->bindLimitByUser(UserRelationBind::BIND_TYPE_COMMUNITY, $data['source_id'], $data['user_id'], $jsonData); + return $this->success(['id' => $res->id]); + } + +} diff --git a/app/Request/v3/CommunityBindRequest.php b/app/Request/v3/CommunityBindRequest.php new file mode 100644 index 0000000..3f10776 --- /dev/null +++ b/app/Request/v3/CommunityBindRequest.php @@ -0,0 +1,45 @@ + 'required|nonempty', + 'user_id' => 'required|nonempty|exists_enable:ims_cjdc_user,id', + 'json_data' => 'json', + ]; + } + + public function messages(): array + { + return [ + '*.nonempty' => ':attribute参数异常', + 'user_id.exists_enable' => '用户不存在', + ]; + } + + public function attributes(): array + { + return [ + + ]; + } +} diff --git a/app/Service/v3/Implementations/UserCommunityBindService.php b/app/Service/v3/Implementations/UserCommunityBindService.php new file mode 100644 index 0000000..5c5ee02 --- /dev/null +++ b/app/Service/v3/Implementations/UserCommunityBindService.php @@ -0,0 +1,36 @@ +updateOrCreate( + ['bind_type' => $bind_type, 'user_id' => $user_id], + ['source_id' => $source_id, 'json_data' => $extra_data] + ); + } + + public function bindLimitBySource($bind_type, $source_id, $user_id, $extra_data) + { + // TODO: Implement bindLimitBySource() method. + } + + public function bind($bind_type, $source_id, $user_id, $extra_data) + { + // TODO: Implement bind() method. + } + + public function isBinded($bind_type, $source_id, $user_id) + { + // TODO: Implement isBinded() method. + } +} \ No newline at end of file diff --git a/app/Service/v3/Interfaces/UserRelationBindServiceInterface.php b/app/Service/v3/Interfaces/UserRelationBindServiceInterface.php new file mode 100644 index 0000000..721b2b1 --- /dev/null +++ b/app/Service/v3/Interfaces/UserRelationBindServiceInterface.php @@ -0,0 +1,48 @@ + \App\JsonRpc\FeieService::class, \App\JsonRpc\LocationServiceInterface::class => \App\JsonRpc\LocationService::class, \App\Service\v3\Interfaces\OrderStatisticsServiceInterface::class => \App\Service\v3\Implementations\OrderStatisticsService::class, + \App\Service\v3\Interfaces\UserRelationBindServiceInterface::class => \App\Service\v3\Implementations\UserCommunityBindService::class, ]; diff --git a/config/routes.php b/config/routes.php index 70cd298..9a0a58e 100644 --- a/config/routes.php +++ b/config/routes.php @@ -140,6 +140,7 @@ Router::addGroup('/v3/', function () { Router::post('withdraw/pageByStore', 'App\Controller\v3\WithdrawController@pageByStore'); Router::post('userAddress/getAddressAndDistributionPrice', 'App\Controller\v3\UserAddressController@getAddressAndDistributionPrice'); Router::post('withdraw/applyByStore', 'App\Controller\v3\WithdrawController@applyByStore'); + Router::post('community/bind', 'App\Controller\v3\CommunityController@bind'); },['middleware' => [\App\Middleware\Auth\ApiMiddleware::class, \App\Middleware\Auth\UserMiddleware::class]]); // 微信支付回调