Browse Source

Merge branch 'coupon_rebate' of ssh://120.24.33.109:11022/hyzjshwo/lanzu_api_hyperf into coupon_rebate

master
liangyuyan 6 years ago
parent
commit
b93ce619d9
  1. 11
      app/Controller/CouponRebateController.php
  2. 27
      app/Service/CouponRebate.php
  3. 31
      app/Service/CouponRebateService.php
  4. 5
      app/Service/CouponRebateServiceInterface.php
  5. 2
      config/autoload/dependencies.php

11
app/Controller/CouponRebateController.php

@ -14,7 +14,7 @@ namespace App\Controller;
use Hyperf\DbConnection\Db; use Hyperf\DbConnection\Db;
use Hyperf\Redis\Redis; use Hyperf\Redis\Redis;
use Hyperf\Utils\ApplicationContext; use Hyperf\Utils\ApplicationContext;
use App\Service\CouponRebateInterface;
use App\Service\CouponRebateServiceInterface;
use http\Client\Curl\User; use http\Client\Curl\User;
use Hyperf\Di\Annotation\Inject; use Hyperf\Di\Annotation\Inject;
use App\Model\Coupon; use App\Model\Coupon;
@ -24,11 +24,6 @@ use App\Request\CouponRebateReceiveRequest;
use App\Service\CouponRebateService; use App\Service\CouponRebateService;
class CouponRebateController extends BaseController class CouponRebateController extends BaseController
{ {
/**
* @Inject
* @var CouponRebateInterface
*/
protected $CouponRebate;
/** /**
* @Inject * @Inject
@ -42,7 +37,7 @@ class CouponRebateController extends BaseController
public function isCouponRebate() public function isCouponRebate()
{ {
$user_id = $this->request->input('user_id', 0); $user_id = $this->request->input('user_id', 0);
$res = $this->CouponRebate->isCouponRebate($user_id);
$res = $this->CouponRebateService->isCouponRebate($user_id);
return $this->success($res); return $this->success($res);
} }
@ -51,7 +46,7 @@ class CouponRebateController extends BaseController
*/ */
public function getActiveInfo() public function getActiveInfo()
{ {
$res = $this->CouponRebate->getActiveInfo();
$res = $this->CouponRebateService->getActiveInfo();
return $this->success($res); return $this->success($res);
} }

27
app/Service/CouponRebate.php

@ -10,33 +10,6 @@ use Hyperf\Paginator\Paginator;
class CouponRebate implements CouponRebateInterface 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')
->get();
return $res;
}
} }

31
app/Service/CouponRebateService.php

@ -149,4 +149,35 @@ class CouponRebateService implements CouponRebateServiceInterface
return $result; 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;
}
} }

5
app/Service/CouponRebateServiceInterface.php

@ -8,4 +8,9 @@ interface CouponRebateServiceInterface
* 领取优惠券 * 领取优惠券
*/ */
public function userReceiveCoupon($params); public function userReceiveCoupon($params);
public function isCouponRebate($user_id);
public function getActiveInfo();
} }

2
config/autoload/dependencies.php

@ -15,5 +15,5 @@ return [
\App\Service\ParamsTokenServiceInterface::class => \App\Service\ParamsTokenSsdbService::class, \App\Service\ParamsTokenServiceInterface::class => \App\Service\ParamsTokenSsdbService::class,
\App\Service\AdServiceInterface::class => \App\Service\AdService::class, \App\Service\AdServiceInterface::class => \App\Service\AdService::class,
\App\Commons\Log::class => \App\Commons\Log::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,
]; ];
Loading…
Cancel
Save