Search in sources :

Example 1 with PagesQueryCondition

use of com.actionworks.flashsale.domain.model.PagesQueryCondition in project flash-sale by ThoughtsBeta.

the class FlashItemWarmUpScheduler method warmUpFlashItemTask.

@Scheduled(cron = "*/5 * * * * ?")
@BetaTrace
public void warmUpFlashItemTask() {
    logger.info("warmUpFlashItemTask|秒杀品预热调度");
    PagesQueryCondition pagesQueryCondition = new PagesQueryCondition();
    pagesQueryCondition.setStockWarmUp(0);
    PageResult<FlashItem> pageResult = flashItemDomainService.getFlashItems(pagesQueryCondition);
    pageResult.getData().forEach(flashItem -> {
        boolean initSuccess = itemStockCacheService.alignItemStocks(flashItem.getId());
        if (!initSuccess) {
            logger.info("warmUpFlashItemTask|秒杀品库存已经初始化预热失败", flashItem.getId());
            return;
        }
        flashItem.setStockWarmUp(1);
        flashItemDomainService.publishFlashItem(flashItem);
        logger.info("warmUpFlashItemTask|秒杀品库存已经初始化预热成功", flashItem.getId());
    });
}
Also used : FlashItem(com.actionworks.flashsale.domain.model.entity.FlashItem) PagesQueryCondition(com.actionworks.flashsale.domain.model.PagesQueryCondition) Scheduled(org.springframework.scheduling.annotation.Scheduled) BetaTrace(com.actionworks.flashsale.config.annotion.BetaTrace)

Example 2 with PagesQueryCondition

use of com.actionworks.flashsale.domain.model.PagesQueryCondition in project flash-sale by ThoughtsBeta.

the class FlashItemAppBuilder method toFlashItemsQuery.

public static PagesQueryCondition toFlashItemsQuery(FlashItemsQuery flashItemsQuery) {
    PagesQueryCondition pagesQueryCondition = new PagesQueryCondition();
    BeanUtils.copyProperties(flashItemsQuery, pagesQueryCondition);
    return pagesQueryCondition;
}
Also used : PagesQueryCondition(com.actionworks.flashsale.domain.model.PagesQueryCondition)

Example 3 with PagesQueryCondition

use of com.actionworks.flashsale.domain.model.PagesQueryCondition in project flash-sale by ThoughtsBeta.

the class FlashActivityAppBuilder method toFlashActivitiesQuery.

public static PagesQueryCondition toFlashActivitiesQuery(FlashActivitiesQuery flashActivitiesQuery) {
    if (flashActivitiesQuery == null) {
        return new PagesQueryCondition();
    }
    PagesQueryCondition pagesQueryCondition = new PagesQueryCondition();
    BeanUtils.copyProperties(flashActivitiesQuery, pagesQueryCondition);
    return pagesQueryCondition;
}
Also used : PagesQueryCondition(com.actionworks.flashsale.domain.model.PagesQueryCondition)

Example 4 with PagesQueryCondition

use of com.actionworks.flashsale.domain.model.PagesQueryCondition in project flash-sale by ThoughtsBeta.

the class FlashItemDomainServiceImpl method getFlashItems.

@Override
public PageResult<FlashItem> getFlashItems(PagesQueryCondition pagesQueryCondition) {
    if (pagesQueryCondition == null) {
        pagesQueryCondition = new PagesQueryCondition();
    }
    List<FlashItem> flashItems = flashItemRepository.findFlashItemsByCondition(pagesQueryCondition.buildParams());
    Integer total = flashItemRepository.countFlashItemsByCondition(pagesQueryCondition);
    logger.info("Get flash items:{}", flashItems.size());
    return PageResult.with(flashItems, total);
}
Also used : FlashItem(com.actionworks.flashsale.domain.model.entity.FlashItem) PagesQueryCondition(com.actionworks.flashsale.domain.model.PagesQueryCondition)

Example 5 with PagesQueryCondition

use of com.actionworks.flashsale.domain.model.PagesQueryCondition in project flash-sale by ThoughtsBeta.

the class FlashOrderDomainServiceImpl method getOrdersByUser.

@Override
public PageResult<FlashOrder> getOrdersByUser(Long userId, PagesQueryCondition pagesQueryCondition) {
    if (pagesQueryCondition == null) {
        pagesQueryCondition = new PagesQueryCondition();
    }
    List<FlashOrder> flashOrders = flashOrderRepository.findFlashOrdersByCondition(pagesQueryCondition.buildParams());
    int total = flashOrderRepository.countFlashOrdersByCondition(pagesQueryCondition.buildParams());
    logger.info("Get flash orders:{},{}", userId, flashOrders.size());
    return PageResult.with(flashOrders, total);
}
Also used : FlashOrder(com.actionworks.flashsale.domain.model.entity.FlashOrder) PagesQueryCondition(com.actionworks.flashsale.domain.model.PagesQueryCondition)

Aggregations

PagesQueryCondition (com.actionworks.flashsale.domain.model.PagesQueryCondition)11 FlashItem (com.actionworks.flashsale.domain.model.entity.FlashItem)4 BetaTrace (com.actionworks.flashsale.config.annotion.BetaTrace)2 FlashActivity (com.actionworks.flashsale.domain.model.entity.FlashActivity)2 FlashOrder (com.actionworks.flashsale.domain.model.entity.FlashOrder)2 DistributedLock (com.actionworks.flashsale.lock.DistributedLock)2 Scheduled (org.springframework.scheduling.annotation.Scheduled)2 FlashActivitiesCache (com.actionworks.flashsale.app.service.activity.cache.model.FlashActivitiesCache)1 FlashItemsCache (com.actionworks.flashsale.app.service.item.cache.model.FlashItemsCache)1