use of com.actionworks.flashsale.domain.exception.DomainException in project flash-sale by ThoughtsBeta.
the class BucketsDomainServiceImpl method resumeBuckets.
@Override
public boolean resumeBuckets(Long itemId) {
logger.info("resumeBuckets|启用库存分桶|{}", itemId);
if (itemId == null || itemId <= 0) {
throw new DomainException(PARAMS_INVALID);
}
boolean success = bucketsRepository.resumeStockBuckets(itemId);
if (!success) {
return false;
}
StockBucketEvent stockBucketEvent = new StockBucketEvent();
stockBucketEvent.setEventType(StockBucketEventType.ENABLED);
stockBucketEvent.setItemId(itemId);
domainEventPublisher.publish(stockBucketEvent);
logger.info("suspendBuckets|库存桶已禁用|{}", itemId);
return true;
}
use of com.actionworks.flashsale.domain.exception.DomainException in project flash-sale by ThoughtsBeta.
the class FlashActivityDomainServiceImpl method onlineActivity.
@Override
public void onlineActivity(Long userId, Long activityId) {
logger.info("activityOnline|上线秒杀活动|{},{}", userId, activityId);
if (StringUtils.isEmpty(userId) || activityId == null) {
throw new DomainException(PARAMS_INVALID);
}
Optional<FlashActivity> flashActivityOptional = flashActivityRepository.findById(activityId);
if (!flashActivityOptional.isPresent()) {
throw new DomainException(FLASH_ACTIVITY_DOES_NOT_EXIST);
}
FlashActivity flashActivity = flashActivityOptional.get();
if (FlashActivityStatus.isOnline(flashActivity.getStatus())) {
return;
}
flashActivity.setStatus(FlashActivityStatus.ONLINE.getCode());
flashActivityRepository.save(flashActivity);
logger.info("activityOnline|活动已上线|{},{}", userId, flashActivity.getId());
FlashActivityEvent flashActivityEvent = new FlashActivityEvent();
flashActivityEvent.setEventType(FlashActivityEventType.ONLINE);
flashActivityEvent.setFlashActivity(flashActivity);
domainEventPublisher.publish(flashActivityEvent);
logger.info("activityOnline|活动上线事件已发布|{}", JSON.toJSON(flashActivityEvent));
}
use of com.actionworks.flashsale.domain.exception.DomainException in project flash-sale by ThoughtsBeta.
the class FlashActivityDomainServiceImpl method modifyActivity.
@Override
public void modifyActivity(Long userId, FlashActivity flashActivity) {
logger.info("activityModification|秒杀活动修改|{},{}", userId, JSON.toJSONString(flashActivity));
if (flashActivity == null || !flashActivity.validateParamsForCreateOrUpdate()) {
throw new DomainException(ONLINE_FLASH_ACTIVITY_PARAMS_INVALID);
}
flashActivityRepository.save(flashActivity);
logger.info("activityModification|活动已修改|{},{}", userId, flashActivity.getId());
FlashActivityEvent flashActivityEvent = new FlashActivityEvent();
flashActivityEvent.setEventType(FlashActivityEventType.MODIFIED);
flashActivityEvent.setFlashActivity(flashActivity);
domainEventPublisher.publish(flashActivityEvent);
logger.info("activityModification|活动修改事件已发布|{}", JSON.toJSON(flashActivityEvent));
}
Aggregations