You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.6 KiB
48 lines
1.6 KiB
<?php
|
|
|
|
namespace App\Service\v3\Implementations;
|
|
|
|
use App\Constants\v3\OrderState;
|
|
use App\Constants\v3\OrderType;
|
|
use App\Model\v3\Order;
|
|
use App\Model\v3\OrderMain;
|
|
use App\Service\v3\Interfaces\UserServiceInterface;
|
|
|
|
class UserService implements UserServiceInterface
|
|
{
|
|
|
|
/**
|
|
* 是否平台新用户
|
|
* 在很多奖励的地方会需要用到这个查询
|
|
* 判定条件:
|
|
* 没有在平台下过单(包括线上和线下)
|
|
* @param $user_id
|
|
* @param $order_main_id
|
|
* @return mixed|void
|
|
*/
|
|
public function isPlatformNewUser($user_id, $order_main_id): bool
|
|
{
|
|
return !OrderMain::query()
|
|
->where(['user_id' => $user_id])
|
|
->where('id', '!=', $order_main_id)
|
|
->whereIn('state', OrderState::FINISH)
|
|
->exists();
|
|
}
|
|
|
|
/**
|
|
* @inheritDoc
|
|
*/
|
|
public function isStoreFirstOrderToday($user_id, $store_id, $current_order_id, $limit_amount = 3)
|
|
{
|
|
return !Order::query()
|
|
->join('lanzu_order_main as main', 'main.id', '=', 'lanzu_order.order_main_id')
|
|
->where(['main.user_id' => $user_id, 'lanzu_order.store_id' => $store_id, 'main.type' => OrderType::OFFLINE])
|
|
->whereIn('main.state', OrderState::FINISH)
|
|
->where('lanzu_order.created_at', '>=', strtotime(date('Y-m-d 00:00:00')))
|
|
->where('lanzu_order.created_at', '<=', strtotime(date('Y-m-d 23:59:59')))
|
|
->where('main.money', '>=', $limit_amount)
|
|
->where('lanzu_order.id', '!=', $current_order_id)
|
|
->exists();
|
|
}
|
|
|
|
}
|