本文整理汇总了Java中org.killbill.billing.entitlement.api.SubscriptionEvent类的典型用法代码示例。如果您正苦于以下问题:Java SubscriptionEvent类的具体用法?Java SubscriptionEvent怎么用?Java SubscriptionEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SubscriptionEvent类属于org.killbill.billing.entitlement.api包,在下文中一共展示了SubscriptionEvent类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getBusinessSubscriptionFromTransition
import org.killbill.billing.entitlement.api.SubscriptionEvent; //导入依赖的package包/类
private BusinessSubscription getBusinessSubscriptionFromTransition(final Account account,
final SubscriptionEvent subscriptionTransition,
final String serviceName,
final CurrencyConverter currencyConverter) {
return new BusinessSubscription(subscriptionTransition.getNextPlan(),
subscriptionTransition.getNextPhase(),
subscriptionTransition.getNextPriceList(),
account.getCurrency(),
subscriptionTransition.getEffectiveDate(),
// We don't record the blockedBilling/blockedEntitlement values
// as they are implicitly reflected in the subscription transition event name
// Note: we don't have information on blocked changes though
serviceName,
subscriptionTransition.getServiceStateName(),
currencyConverter);
}
开发者ID:killbill,项目名称:killbill-analytics-plugin,代码行数:17,代码来源:BusinessSubscriptionTransitionFactory.java
示例2: computeServicePeriodEndDate
import org.killbill.billing.entitlement.api.SubscriptionEvent; //导入依赖的package包/类
public static LocalDate computeServicePeriodEndDate(final InvoiceItem invoiceItem,
@Nullable final PlanPhase planPhase,
@Nullable final SubscriptionBundle bundle) {
if (invoiceItem.getEndDate() != null) {
return invoiceItem.getEndDate();
} else if (planPhase == null || bundle == null) {
return null;
} else {
final Optional<SubscriptionEvent> nextEvent = Iterables.<SubscriptionEvent>tryFind(bundle.getTimeline().getSubscriptionEvents(),
new Predicate<SubscriptionEvent>() {
SubscriptionEvent subscriptionEventForInvoiceItem = null;
@Override
public boolean apply(final SubscriptionEvent input) {
if (input.getEntitlementId().equals(invoiceItem.getSubscriptionId()) &&
// planPhase can't be null here
planPhase.equals(input.getNextPhase()) &&
input.getEffectiveDate().compareTo(invoiceItem.getStartDate()) == 0) {
subscriptionEventForInvoiceItem = input;
return false;
}
return subscriptionEventForInvoiceItem != null &&
input.getEntitlementId().equals(invoiceItem.getSubscriptionId()) &&
// planPhase can't be null here (prev phase can be for the first event)
planPhase.equals(input.getPrevPhase());
}
}
);
if (nextEvent.isPresent()) {
return nextEvent.get().getEffectiveDate();
} else {
return null;
}
}
}
示例3: buildTransitionsForBundle
import org.killbill.billing.entitlement.api.SubscriptionEvent; //导入依赖的package包/类
private Collection<BusinessSubscriptionTransitionModelDao> buildTransitionsForBundle(final BusinessContextFactory businessContextFactory,
final Account account,
final SubscriptionBundle bundle,
final CurrencyConverter currencyConverter,
final Long accountRecordId,
final Long tenantRecordId,
@Nullable final ReportGroup reportGroup) throws AnalyticsRefreshException {
final List<SubscriptionEvent> transitions = bundle.getTimeline().getSubscriptionEvents();
return buildTransitionsForBundle(businessContextFactory, account, bundle, transitions, currencyConverter, accountRecordId, tenantRecordId, reportGroup);
}
开发者ID:killbill,项目名称:killbill-analytics-plugin,代码行数:11,代码来源:BusinessSubscriptionTransitionFactory.java
示例4: createBusinessSubscriptionTransition
import org.killbill.billing.entitlement.api.SubscriptionEvent; //导入依赖的package包/类
private BusinessSubscriptionTransitionModelDao createBusinessSubscriptionTransition(final BusinessContextFactory businessContextFactory,
final Account account,
final SubscriptionBundle subscriptionBundle,
final SubscriptionEvent subscriptionTransition,
@Nullable final BusinessSubscription prevNextSubscription,
final BusinessSubscription nextSubscription,
final CurrencyConverter currencyConverter,
final Long accountRecordId,
final Long tenantRecordId,
@Nullable final ReportGroup reportGroup) throws AnalyticsRefreshException {
final BusinessSubscriptionEvent businessEvent = BusinessSubscriptionEvent.fromTransition(subscriptionTransition);
final Long subscriptionEventRecordId = businessContextFactory.getSubscriptionEventRecordId(subscriptionTransition.getId(), subscriptionTransition.getSubscriptionEventType().getObjectType());
final AuditLog creationAuditLog = businessContextFactory.getSubscriptionEventCreationAuditLog(subscriptionTransition.getId(), subscriptionTransition.getSubscriptionEventType().getObjectType());
return new BusinessSubscriptionTransitionModelDao(account,
accountRecordId,
subscriptionBundle,
subscriptionTransition,
subscriptionEventRecordId,
businessEvent,
prevNextSubscription,
nextSubscription,
currencyConverter,
creationAuditLog,
tenantRecordId,
reportGroup);
}
开发者ID:killbill,项目名称:killbill-analytics-plugin,代码行数:28,代码来源:BusinessSubscriptionTransitionFactory.java
示例5: createBusinessAccountTransitions
import org.killbill.billing.entitlement.api.SubscriptionEvent; //导入依赖的package包/类
public Collection<BusinessAccountTransitionModelDao> createBusinessAccountTransitions(final BusinessContextFactory businessContextFactory) throws AnalyticsRefreshException {
final Iterable<SubscriptionEvent> blockingStatesOrdered = businessContextFactory.getAccountBlockingStates();
if (!blockingStatesOrdered.iterator().hasNext()) {
return ImmutableList.<BusinessAccountTransitionModelDao>of();
}
return createBusinessAccountTransitions(businessContextFactory, blockingStatesOrdered);
}
示例6: getBlockingHistory
import org.killbill.billing.entitlement.api.SubscriptionEvent; //导入依赖的package包/类
protected Iterable<SubscriptionEvent> getBlockingHistory(final UUID accountId, final TenantContext context) throws AnalyticsRefreshException {
final List<SubscriptionBundle> bundles = getSubscriptionBundlesForAccount(accountId, context);
// Find all subscription events for that account
final Iterable<SubscriptionEvent> subscriptionEvents = Iterables.<SubscriptionEvent>concat(Iterables.<SubscriptionBundle, List<SubscriptionEvent>>transform(bundles,
new Function<SubscriptionBundle, List<SubscriptionEvent>>() {
@Override
public List<SubscriptionEvent> apply(final SubscriptionBundle bundle) {
return bundle.getTimeline().getSubscriptionEvents();
}
}
));
// Filter all service state changes
return Iterables.<SubscriptionEvent>filter(subscriptionEvents,
new Predicate<SubscriptionEvent>() {
@Override
public boolean apply(final SubscriptionEvent event) {
return event.getSubscriptionEventType() != null &&
// We want events coming from the blocking states table...
ObjectType.BLOCKING_STATES.equals(event.getSubscriptionEventType().getObjectType()) &&
// ...that are for any service but entitlement
!BusinessSubscriptionTransitionFactory.ENTITLEMENT_SERVICE_NAME.equals(event.getServiceName());
}
}
);
}
示例7: BusinessSubscriptionTransitionModelDao
import org.killbill.billing.entitlement.api.SubscriptionEvent; //导入依赖的package包/类
public BusinessSubscriptionTransitionModelDao(final Account account,
final Long accountRecordId,
final SubscriptionBundle bundle,
final SubscriptionEvent transition,
final Long subscriptionEventRecordId,
final BusinessSubscriptionEvent event,
@Nullable final BusinessSubscription previousSubscription,
final BusinessSubscription nextSubscription,
final CurrencyConverter currencyConverter,
@Nullable final AuditLog creationAuditLog,
final Long tenantRecordId,
@Nullable final ReportGroup reportGroup) {
this(subscriptionEventRecordId,
bundle.getId(),
bundle.getExternalKey(),
transition.getEntitlementId(),
transition.getEffectiveDate(),
event,
previousSubscription,
nextSubscription,
currencyConverter.getConvertedCurrency(),
creationAuditLog != null ? creationAuditLog.getCreatedDate() : null,
creationAuditLog != null ? creationAuditLog.getUserName() : null,
creationAuditLog != null ? creationAuditLog.getReasonCode() : null,
creationAuditLog != null ? creationAuditLog.getComment() : null,
account.getId(),
account.getName(),
account.getExternalKey(),
accountRecordId,
tenantRecordId,
reportGroup);
}
开发者ID:killbill,项目名称:killbill-analytics-plugin,代码行数:33,代码来源:BusinessSubscriptionTransitionModelDao.java
示例8: fromTransition
import org.killbill.billing.entitlement.api.SubscriptionEvent; //导入依赖的package包/类
public static BusinessSubscriptionEvent fromTransition(final SubscriptionEvent transition) {
switch (transition.getSubscriptionEventType()) {
// A subscription enters either through migration or as newly created subscription
case START_ENTITLEMENT:
return startEntitlement(transition.getNextPlan());
case START_BILLING:
return startBilling(transition.getNextPlan());
case PAUSE_ENTITLEMENT:
return pauseEntitlement(transition.getNextPlan());
case PAUSE_BILLING:
return pauseBilling(transition.getNextPlan());
case RESUME_ENTITLEMENT:
return resumeEntitlement(transition.getNextPlan());
case RESUME_BILLING:
return resumeBilling(transition.getNextPlan());
case CHANGE:
return subscriptionChanged(transition.getNextPlan());
case PHASE:
return subscriptionPhaseChanged(transition.getNextPlan());
case STOP_ENTITLEMENT:
return stopEntitlement(transition.getPrevPlan());
case STOP_BILLING:
return stopBilling(transition.getPrevPlan());
case SERVICE_STATE_CHANGE:
return subscriptionStateChanged(transition.getNextPlan());
default:
// Should never happen
return unexpectedEvent(transition.getNextPlan());
}
}
示例9: getAccountBlockingStates
import org.killbill.billing.entitlement.api.SubscriptionEvent; //导入依赖的package包/类
public synchronized Iterable<SubscriptionEvent> getAccountBlockingStates() throws AnalyticsRefreshException {
if (accountBlockingStates == null) {
accountBlockingStates = getBlockingHistory(accountId, callContext);
}
return accountBlockingStates;
}
示例10: testRespectPrevPerService
import org.killbill.billing.entitlement.api.SubscriptionEvent; //导入依赖的package包/类
@Test(groups = "fast")
public void testRespectPrevPerService() throws Exception {
final BusinessAccountTransitionFactory factory = new BusinessAccountTransitionFactory();
final List<SubscriptionEvent> events = new LinkedList<SubscriptionEvent>();
final SubscriptionEvent event1 = Mockito.mock(SubscriptionEvent.class);
Mockito.when(event1.getId()).thenReturn(UUID.randomUUID());
Mockito.when(event1.getSubscriptionEventType()).thenReturn(SubscriptionEventType.SERVICE_STATE_CHANGE);
Mockito.when(event1.getEffectiveDate()).thenReturn(new LocalDate(2012, 5, 1));
Mockito.when(event1.getServiceName()).thenReturn("service-A");
events.add(event1);
final SubscriptionEvent event2 = Mockito.mock(SubscriptionEvent.class);
Mockito.when(event2.getId()).thenReturn(UUID.randomUUID());
Mockito.when(event2.getSubscriptionEventType()).thenReturn(SubscriptionEventType.SERVICE_STATE_CHANGE);
Mockito.when(event2.getEffectiveDate()).thenReturn(new LocalDate(2012, 5, 2));
Mockito.when(event2.getServiceName()).thenReturn("service-B");
events.add(event2);
final SubscriptionEvent event3 = Mockito.mock(SubscriptionEvent.class);
Mockito.when(event3.getId()).thenReturn(UUID.randomUUID());
Mockito.when(event3.getSubscriptionEventType()).thenReturn(SubscriptionEventType.SERVICE_STATE_CHANGE);
Mockito.when(event3.getEffectiveDate()).thenReturn(new LocalDate(2012, 6, 1));
Mockito.when(event3.getServiceName()).thenReturn("service-A");
events.add(event3);
final SubscriptionEvent event4 = Mockito.mock(SubscriptionEvent.class);
Mockito.when(event4.getId()).thenReturn(UUID.randomUUID());
Mockito.when(event4.getSubscriptionEventType()).thenReturn(SubscriptionEventType.SERVICE_STATE_CHANGE);
Mockito.when(event4.getEffectiveDate()).thenReturn(new LocalDate(2012, 6, 2));
Mockito.when(event4.getServiceName()).thenReturn("service-B");
events.add(event4);
final BusinessContextFactory businessContextFactory = new BusinessContextFactory(account.getId(), callContext, currencyConversionDao, killbillAPI, osgiConfigPropertiesService, clock, analyticsConfigurationHandler);
final List<BusinessAccountTransitionModelDao> result = ImmutableList.<BusinessAccountTransitionModelDao>copyOf(factory.createBusinessAccountTransitions(businessContextFactory, events));
Assert.assertEquals(result.get(0).getService(), "service-A");
Assert.assertEquals(result.get(0).getStartDate(), new LocalDate(2012, 5, 1));
Assert.assertEquals(result.get(0).getEndDate(), new LocalDate(2012, 6, 1));
Assert.assertEquals(result.get(1).getService(), "service-B");
Assert.assertEquals(result.get(1).getStartDate(), new LocalDate(2012, 5, 2));
Assert.assertEquals(result.get(1).getEndDate(), new LocalDate(2012, 6, 2));
Assert.assertEquals(result.get(2).getService(), "service-A");
Assert.assertEquals(result.get(2).getStartDate(), new LocalDate(2012, 6, 1));
Assert.assertNull(result.get(2).getEndDate());
Assert.assertEquals(result.get(3).getService(), "service-B");
Assert.assertEquals(result.get(3).getStartDate(), new LocalDate(2012, 6, 2));
Assert.assertNull(result.get(3).getEndDate());
}
开发者ID:killbill,项目名称:killbill-analytics-plugin,代码行数:46,代码来源:TestBusinessAccountTransitionFactory.java