public ProcessResult processCall(Call call, Map<String, Object> accumulatedData) { if (call.getType() != Call.CALL_TYPE_SENT) { return null; } Long secondsTotal = (Long) accumulatedData.get(ACCUMULATED_DATA_SECONDS); if (secondsTotal == null) { secondsTotal = new Long(0); } secondsTotal += call.getDuration(); accumulatedData.put(ACCUMULATED_DATA_SECONDS, secondsTotal); ProcessResult ret = new ProcessResult(); if (call.getContact().getMsisdnType() == MsisdnType.ES_SPECIAL_ZER0) { ret.price = 0.0; ret.type = Type.ZERO; } else { boolean insidePlan = secondsTotal <= maxSecondsMonth; if (insidePlan) { ret.price = 0.0; ret.type = Type.INSIDE_PLAN; } else { long duration = (secondsTotal > maxSecondsMonth) && (secondsTotal - call.getDuration() <= maxSecondsMonth) ? secondsTotal - maxSecondsMonth : call.getDuration(); ret.price = initialPrice + (duration * pricePerSecond); ret.type = Type.OUTSIDE_PLAN; } } return ret; }
public ProcessResult processSms(Sms sms, Map<String, Object> accumulatedData) { if (sms.getType() != Sms.SMS_TYPE_SENT) { return null; } ProcessResult ret = new ProcessResult(); ret.price = smsPrice; ret.type = Type.INSIDE_PLAN; return ret; }