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