From 3481ead47977cfa9986d5126ae8d957978111c4a Mon Sep 17 00:00:00 2001 From: "DESKTOP-GG6FIN9\\Administrator" <15040771@qq.com> Date: Wed, 5 Aug 2020 17:18:53 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E7=BB=9F=E4=B8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Controller/CouponRebateController.php | 11 ++----- app/Service/CouponRebate.php | 28 ------------------ app/Service/CouponRebateService.php | 31 ++++++++++++++++++++ app/Service/CouponRebateServiceInterface.php | 5 ++++ config/autoload/dependencies.php | 2 +- 5 files changed, 40 insertions(+), 37 deletions(-) diff --git a/app/Controller/CouponRebateController.php b/app/Controller/CouponRebateController.php index 43a73e9..c1b2b93 100644 --- a/app/Controller/CouponRebateController.php +++ b/app/Controller/CouponRebateController.php @@ -14,7 +14,7 @@ namespace App\Controller; use Hyperf\DbConnection\Db; use Hyperf\Redis\Redis; use Hyperf\Utils\ApplicationContext; -use App\Service\CouponRebateInterface; +use App\Service\CouponRebateServiceInterface; use http\Client\Curl\User; use Hyperf\Di\Annotation\Inject; use App\Model\Coupon; @@ -24,11 +24,6 @@ use App\Request\CouponRebateReceiveRequest; use App\Service\CouponRebateService; class CouponRebateController extends BaseController { - /** - * @Inject - * @var CouponRebateInterface - */ - protected $CouponRebate; /** * @Inject @@ -42,7 +37,7 @@ class CouponRebateController extends BaseController public function isCouponRebate() { $user_id = $this->request->input('user_id', 0); - $res = $this->CouponRebate->isCouponRebate($user_id); + $res = $this->CouponRebateService->isCouponRebate($user_id); return $this->success($res); } @@ -51,7 +46,7 @@ class CouponRebateController extends BaseController */ public function getActiveInfo() { - $res = $this->CouponRebate->getActiveInfo(); + $res = $this->CouponRebateService->getActiveInfo(); return $this->success($res); } diff --git a/app/Service/CouponRebate.php b/app/Service/CouponRebate.php index 9f05999..1afe901 100644 --- a/app/Service/CouponRebate.php +++ b/app/Service/CouponRebate.php @@ -10,34 +10,6 @@ use Hyperf\Paginator\Paginator; class CouponRebate implements CouponRebateInterface { - public function isCouponRebate($user_id) - { - $res = Db::table('ims_system_coupon_user as u') - ->leftjoin('ims_system_coupon_user_receive as r','u.id','=','r.system_coupon_user_id') - ->where([ - ['r.user_id','=',$user_id], - ['r.receive_type','=',4], - ['u.active_type','=',2], - ]) - ->select('r.id') - ->first(); - return $res; - } - public function getActiveInfo() - { - $time = time(); - $res = Db::table('ims_system_coupon_user') - ->where([ - ['status','=',1], - ['active_type','=',2], - ['start_time','<=',$time], - ['end_time','>',$time], - ]) - ->whereRaw('inventory > inventory_use') - ->orderBy('addtime','desc') - ->get(); - return $res; - } } \ No newline at end of file diff --git a/app/Service/CouponRebateService.php b/app/Service/CouponRebateService.php index cdd384c..9db3bc9 100644 --- a/app/Service/CouponRebateService.php +++ b/app/Service/CouponRebateService.php @@ -132,4 +132,35 @@ class CouponRebateService implements CouponRebateServiceInterface return $result; } + + public function isCouponRebate($user_id) + { + $res = Db::table('ims_system_coupon_user as u') + ->leftjoin('ims_system_coupon_user_receive as r','u.id','=','r.system_coupon_user_id') + ->where([ + ['r.user_id','=',$user_id], + ['r.receive_type','=',4], + ['u.active_type','=',2], + ]) + ->select('r.id') + ->first(); + return $res; + } + + public function getActiveInfo() + { + $time = time(); + $res = Db::table('ims_system_coupon_user') + ->where([ + ['status','=',1], + ['active_type','=',2], + ['start_time','<=',$time], + ['end_time','>',$time], + ]) + ->whereRaw('inventory > inventory_use') + ->orderBy('addtime','desc') + ->get(); + return $res; + } + } \ No newline at end of file diff --git a/app/Service/CouponRebateServiceInterface.php b/app/Service/CouponRebateServiceInterface.php index 1ba93d0..cc8c0ef 100644 --- a/app/Service/CouponRebateServiceInterface.php +++ b/app/Service/CouponRebateServiceInterface.php @@ -8,4 +8,9 @@ interface CouponRebateServiceInterface * 领取优惠券 */ public function userReceiveCoupon($params); + + public function isCouponRebate($user_id); + + public function getActiveInfo(); + } \ No newline at end of file diff --git a/config/autoload/dependencies.php b/config/autoload/dependencies.php index 9089d7f..12dd53c 100644 --- a/config/autoload/dependencies.php +++ b/config/autoload/dependencies.php @@ -15,5 +15,5 @@ return [ \App\Service\ParamsTokenServiceInterface::class => \App\Service\ParamsTokenSsdbService::class, \App\Service\AdServiceInterface::class => \App\Service\AdService::class, \App\Commons\Log::class => \App\Commons\Log::class, - \App\Service\CouponRebateInterface::class => \App\Service\CouponRebate::class, + \App\Service\CouponRebateServiceInterface::class => \App\Service\CouponRebateService::class, ];