class Activity1A0001ValidationMidware {

    /**
     * Language service.
     */
    @Inject
    private LangPropsService langPropsService;

    /**
     * Activity query service.
     */
    @Inject
    private ActivityQueryService activityQueryService;

    /**
     * Liveness query service.
     */
    @Inject
    private LivenessQueryService livenessQueryService;

    public void handle(final RequestContext context) {<FILL_FUNCTION_BODY>}
}

        final JSONObject currentUser = Sessions.getUser();
        final String userId = currentUser.optString(Keys.OBJECT_ID);
        final int currentLiveness = livenessQueryService.getCurrentLivenessPoint(userId);
        final int livenessMax = Symphonys.ACTIVITY_YESTERDAY_REWARD_MAX;
        final float liveness = (float) currentLiveness / livenessMax * 100;
        final float livenessThreshold = Symphonys.ACTIVITY_1A0001_LIVENESS_THRESHOLD;
        if (liveness < livenessThreshold) {
            String msg = langPropsService.get("activityNeedLivenessLabel");
            msg = msg.replace("${liveness}", livenessThreshold + "%");
            msg = msg.replace("${current}", String.format("%.2f", liveness) + "%");
            context.renderJSON(new JSONObject().put(Keys.MSG, msg));
            context.abort();
            return;
        }

        if (Symphonys.ACTIVITY_1A0001_CLOSED) {
            context.renderJSON(new JSONObject().put(Keys.MSG, langPropsService.get("activityClosedLabel")));
            context.abort();
            return;
        }

        final Calendar calendar = Calendar.getInstance();

        final int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK);
        if (dayOfWeek == Calendar.SATURDAY || dayOfWeek == Calendar.SUNDAY) {
            context.renderJSON(new JSONObject().put(Keys.MSG, langPropsService.get("activity1A0001CloseLabel")));
            context.abort();
            return;
        }

        final int hour = calendar.get(Calendar.HOUR_OF_DAY);
        final int minute = calendar.get(Calendar.MINUTE);
        if (hour > 14 || (hour == 14 && minute > 55)) {
            context.renderJSON(new JSONObject().put(Keys.MSG, langPropsService.get("activityEndLabel")));
            context.abort();
            return;
        }

        final JSONObject requestJSONObject = context.requestJSON();
        final int amount = requestJSONObject.optInt(Common.AMOUNT);
        if (200 != amount && 300 != amount && 400 != amount && 500 != amount) {
            context.renderJSON(new JSONObject().put(Keys.MSG, langPropsService.get("activityBetFailLabel")));
            context.abort();
            return;
        }

        final int smallOrLarge = requestJSONObject.optInt(Common.SMALL_OR_LARGE);
        if (0 != smallOrLarge && 1 != smallOrLarge) {
            context.renderJSON(new JSONObject().put(Keys.MSG, langPropsService.get("activityBetFailLabel")));
            context.abort();
            return;
        }

        if (UserExt.USER_STATUS_C_VALID != currentUser.optInt(UserExt.USER_STATUS)) {
            context.renderJSON(new JSONObject().put(Keys.MSG, langPropsService.get("userStatusInvalidLabel")));
            context.abort();
            return;
        }

        if (activityQueryService.is1A0001Today(userId)) {
            context.renderJSON(new JSONObject().put(Keys.MSG, langPropsService.get("activityParticipatedLabel")));
        }

        final int balance = currentUser.optInt(UserExt.USER_POINT);
        if (balance - amount < 0) {
            context.renderJSON(new JSONObject().put(Keys.MSG, langPropsService.get("insufficientBalanceLabel")));
            context.abort();
            return;
        }

        context.handle();
    
<no_super_class>