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.
|
|
<?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) ->where(function ($query){ $query->whereIn('state', OrderState::FINISH); }) ->exists(); }
/** * @inheritDoc */ public function isStoreFirstOrderToday($user_id, $store_id, $current_order_id, $limit_amount = 3) { return !Order::query() ->where(['user_id' => $user_id, 'store_id' => $store_id, 'type' => OrderType::OFFLINE]) ->whereIn('state', OrderState::FINISH) ->where('time_add', '>=', date('Y-m-d 00:00:00')) ->where('time_add', '<=', date('Y-m-d 23:59:59')) ->where('money', '>=', $limit_amount) ->where('id', '!=', $current_order_id) ->exists(); }
}
|