Browse Source

是否平台新用户

master
weigang 5 years ago
parent
commit
b0e417ff34
  1. 10
      app/Model/OrderMain.php
  2. 31
      app/Service/UserService.php
  3. 15
      app/Service/UserServiceInterface.php
  4. 1
      config/autoload/dependencies.php
  5. 2
      config/autoload/middlewares.php

10
app/Model/OrderMain.php

@ -0,0 +1,10 @@
<?php
namespace App\Model;
class OrderMain extends Model
{
protected $table = 'ims_cjdc_order_main';
}

31
app/Service/UserService.php

@ -0,0 +1,31 @@
<?php
namespace App\Service;
use App\Model\OrderMain;
use App\Model\User;
class UserService implements UserServiceInterface
{
/**
* 是否平台新用户
* 在很多奖励的地方会需要用到这个查询
* 判定条件:
* 没有在平台下过单(包括线上和线下)
* @param $user_id
* @return mixed|void
*/
public function isStageNewUser($user_id): bool
{
$exist = OrderMain::query()
->where(['user_id' => $user_id])
->where(function ($query){
$query->where('state', 'in', [4,5,10])
->orWhere('dm_state', 'in', [2,3]);
})
->exists();
return !$exist;
}
}

15
app/Service/UserServiceInterface.php

@ -0,0 +1,15 @@
<?php
namespace App\Service;
interface UserServiceInterface
{
/**
* 是否平台新用户
* @param $user_id
* @return mixed
*/
public function isStageNewUser($user_id): bool;
}

1
config/autoload/dependencies.php

@ -16,4 +16,5 @@ return [
\App\Service\AdServiceInterface::class => \App\Service\AdService::class,
\App\Commons\Log::class => \App\Commons\Log::class,
\App\Service\CouponRebateServiceInterface::class => \App\Service\CouponRebateService::class,
\App\Service\UserServiceInterface::class => \App\Service\UserService::class,
];

2
config/autoload/middlewares.php

@ -11,8 +11,8 @@ declare(strict_types=1);
*/
return [
'http' => [
\App\Middleware\CorsMiddleware::class,
\App\Middleware\Auth\ApiMiddleware::class,
\Hyperf\Validation\Middleware\ValidationMiddleware::class,
\App\Middleware\CorsMiddleware::class,
],
];
Loading…
Cancel
Save