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(); } }