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 $userId * @param $globalOrderId * @return mixed|void */ public function isPlatformNewUser($userId, $globalOrderId): bool { return !OrderMain::query() ->withTrashed() ->where(['user_id' => $userId]) ->where('global_order_id', '!=', $globalOrderId) ->whereIn('state', OrderState::FINISH) ->exists(); }
/** * @inheritDoc */ public function isStoreFirstOrderToday($userId, $storeId, $currentOrderId, $limitAmount = 3) { return !Order::query() ->join('lanzu_order_main as main', 'main.global_order_id', '=', 'lanzu_order.order_main_id') ->where(['main.user_id' => $userId, 'lanzu_order.store_id' => $storeId, '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', '>=', $limitAmount) ->where('lanzu_order.id', '!=', $currentOrderId) ->exists(); }
}
|