Skip to content

项目架构

分包

lucky-api、lucky-app、lucky-domain、lucky-infrastructure、lucky-trigger、lucky-types

领域划分

活动域

抽奖活动相关,划分为三个子域

  • 用户账户域,负责充值(通过下 sku 订单,扣减 sku 库存实现)和查询用户活动账户额度
  • 抽奖订单域,负责产生(抽奖前)抽奖订单
  • 活动 sku 域,负责趋势更新 sku 数据库的库存

奖品域

负责存储用户中奖记录,通知其他业务发放奖品

返利域

负责存储用户返利记录,通知充值用户账户

策略域

抽奖策略相关,划分为三个子域

  • 策略装配域,负责活动预热:缓存奖品库存、全量/权重抽奖策略
  • 执行抽奖域,负责执行抽奖
  • 规则引擎域,负责组装规则责任链和责任树

task 任务域

负责为 MQ 提供服务,查询、更新 task 补偿表,以及发送 MQ 消息

shell
    |-- README.md
    |-- pom.xml
    |-- lucky-api
    |   |-- pom.xml
    |   |-- src
    |   |   |-- main
    |   |       |-- java
    |   |           |-- cn
    |   |               |-- xyfv
    |   |                   |-- trigger
    |   |                       |-- api
    |   |                           |-- IRaffleActivityService.java
    |   |                           |-- IRaffleStrategyService.java
    |   |                           |-- dto
    |   |                               |-- ActivityDrawRequestDTO.java
    |   |                               |-- ActivityDrawResponseDTO.java
    |   |                               |-- RaffleAwardListRequestDTO.java
    |   |                               |-- ...
    |-- lucky-app
    |   |-- Dockerfile
    |   |-- build.sh
    |   |-- pom.xml
    |   |-- stop.sh
    |   |-- src
    |   |   |-- main
    |   |   |   |-- java
    |   |   |   |   |-- cn
    |   |   |   |       |-- xyfv
    |   |   |   |           |-- Application.java
    |   |   |   |           |-- config
    |   |   |   |               |-- GuavaConfig.java
    |   |   |   |               |-- RedisClientConfig.java
    |   |   |   |               |-- RedisClientConfigProperties.java
    |   |   |   |               |-- ThreadPoolConfig.java
    |   |   |   |               |-- ThreadPoolConfigProperties.java
    |   |   |   |-- resources
    |   |   |       |-- application.yml
    |   |   |       |-- logback-spring.xml
    |   |   |       |-- mybatis
    |   |   |           |-- config
    |   |   |           |-- mapper
    |   |   |-- test
    |-- lucky-domain
    |   |-- pom.xml
    |   |-- src
    |   |   |-- main
    |   |       |-- java
    |   |           |-- cn
    |   |               |-- xyfv
    |   |                   |-- domain
    |   |                       |-- activity
    |   |                       |   |-- event
    |   |                       |   |   |-- ActivitySkuStockZeroMessageEvent.java
    |   |                       |   |-- model
    |   |                       |   |   |-- aggregate
    |   |                       |   |   |   |-- CreatePartakeOrderAggregate.java
    |   |                       |   |   |   |-- CreateQuotaOrderAggregate.java
    |   |                       |   |   |-- entity
    |   |                       |   |   |   |-- ActivityAccountDayEntity.java
    |   |                       |   |   |   |-- ActivityAccountEntity.java
    |   |                       |   |   |   |-- ActivityAccountMonthEntity.java
    |   |                       |   |   |   |-- ActivityCountEntity.java
    |   |                       |   |   |   |-- ActivityEntity.java
    |   |                       |   |   |   |-- ActivityOrderEntity.java
    |   |                       |   |   |   |-- ActivitySkuEntity.java
    |   |                       |   |   |   |-- PartakeRaffleActivityEntity.java
    |   |                       |   |   |   |-- SkuRechargeEntity.java
    |   |                       |   |   |   |-- UserRaffleOrderEntity.java
    |   |                       |   |   |-- valobj
    |   |                       |   |       |-- ActivitySkuStockKeyVO.java
    |   |                       |   |       |-- ActivityStateVO.java
    |   |                       |   |       |-- OrderStateVO.java
    |   |                       |   |       |-- UserRaffleOrderStateVO.java
    |   |                       |   |-- repository
    |   |                       |   |   |-- IActivityRepository.java
    |   |                       |   |-- service
    |   |                       |       |-- IRaffleActivityAccountQuotaService.java
    |   |                       |       |-- IRaffleActivityPartakeService.java
    |   |                       |       |-- IRaffleActivitySkuStockService.java
    |   |                       |       |-- armory
    |   |                       |       |   |-- ActivityArmory.java
    |   |                       |       |   |-- IActivityArmory.java
    |   |                       |       |   |-- IActivityDispatch.java
    |   |                       |       |-- partake
    |   |                       |       |   |-- AbstractRaffleActivityPartake.java
    |   |                       |       |   |-- RaffleActivityPartakeService.java
    |   |                       |       |-- quota
    |   |                       |           |-- AbstractRaffleActivityAccountQuota.java
    |   |                       |           |-- RaffleActivityAccountQuotaService.java
    |   |                       |           |-- RaffleActivityAccountQuotaSupport.java
    |   |                       |           |-- rule
    |   |                       |               |-- AbstractActionChain.java
    |   |                       |               |-- IActionChain.java
    |   |                       |               |-- IActionChainArmory.java
    |   |                       |               |-- factory
    |   |                       |               |   |-- DefaultActivityChainFactory.java
    |   |                       |               |-- impl
    |   |                       |                   |-- ActivityBaseActionChain.java
    |   |                       |                   |-- ActivitySkuStockActionChain.java
    |   |                       |-- award
    |   |                       |   |-- event
    |   |                       |   |   |-- SendAwardMessageEvent.java
    |   |                       |   |-- model
    |   |                       |   |   |-- aggregate
    |   |                       |   |   |   |-- UserAwardRecordAggregate.java
    |   |                       |   |   |-- entity
    |   |                       |   |   |   |-- TaskEntity.java
    |   |                       |   |   |   |-- UserAwardRecordEntity.java
    |   |                       |   |   |-- valobj
    |   |                       |   |       |-- AwardStateVO.java
    |   |                       |   |       |-- TaskStateVO.java
    |   |                       |   |-- repository
    |   |                       |   |   |-- IAwardRepository.java
    |   |                       |   |-- service
    |   |                       |       |-- AwardService.java
    |   |                       |       |-- IAwardService.java
    |   |                       |-- rebate
    |   |                       |   |-- event
    |   |                       |   |   |-- SendRebateMessageEvent.java
    |   |                       |   |-- model
    |   |                       |   |   |-- aggregate
    |   |                       |   |   |   |-- BehaviorRebateAggregate.java
    |   |                       |   |   |-- entity
    |   |                       |   |   |   |-- BehaviorEntity.java
    |   |                       |   |   |   |-- BehaviorRebateOrderEntity.java
    |   |                       |   |   |   |-- TaskEntity.java
    |   |                       |   |   |-- valobj
    |   |                       |   |       |-- BehaviorTypeVO.java
    |   |                       |   |       |-- DailyBehaviorRebateVO.java
    |   |                       |   |       |-- RebateTypeVO.java
    |   |                       |   |       |-- TaskStateVO.java
    |   |                       |   |-- repository
    |   |                       |   |   |-- IBehaviorRebateRepository.java
    |   |                       |   |-- service
    |   |                       |       |-- BehaviorRebateService.java
    |   |                       |       |-- IBehaviorRebateService.java
    |   |                       |-- strategy
    |   |                       |   |-- model
    |   |                       |   |   |-- entity
    |   |                       |   |   |   |-- AwardEntity.java
    |   |                       |   |   |   |-- RaffleAwardEntity.java
    |   |                       |   |   |   |-- RaffleFactorEntity.java
    |   |                       |   |   |   |-- RuleActionEntity.java
    |   |                       |   |   |   |-- RuleMatterEntity.java
    |   |                       |   |   |   |-- StrategyAwardEntity.java
    |   |                       |   |   |   |-- StrategyConditionEntity.java
    |   |                       |   |   |   |-- StrategyEntity.java
    |   |                       |   |   |   |-- StrategyRuleEntity.java
    |   |                       |   |   |-- valobj
    |   |                       |   |       |-- RuleLimitTypeVO.java
    |   |                       |   |       |-- RuleLogicCheckTypeVO.java
    |   |                       |   |       |-- RuleTreeNodeLineVO.java
    |   |                       |   |       |-- RuleTreeNodeVO.java
    |   |                       |   |       |-- RuleTreeVO.java
    |   |                       |   |       |-- RuleWeightVO.java
    |   |                       |   |       |-- StrategyAwardRuleModelVO.java
    |   |                       |   |       |-- StrategyAwardStockKeyVO.java
    |   |                       |   |-- repository
    |   |                       |   |   |-- IStrategyRepository.java
    |   |                       |   |-- service
    |   |                       |       |-- AbstractRaffleStrategy.java
    |   |                       |       |-- IRaffleAward.java
    |   |                       |       |-- IRaffleRule.java
    |   |                       |       |-- IRaffleStock.java
    |   |                       |       |-- IRaffleStrategy.java
    |   |                       |       |-- armory
    |   |                       |       |   |-- IStrategyArmory.java
    |   |                       |       |   |-- IStrategyDispatch.java
    |   |                       |       |   |-- StrategyArmoryDispatch.java
    |   |                       |       |-- raffle
    |   |                       |       |   |-- DefaultRaffleStrategy.java
    |   |                       |       |-- rule
    |   |                       |           |-- chain
    |   |                       |           |   |-- AbstractLogicChain.java
    |   |                       |           |   |-- ILogicChain.java
    |   |                       |           |   |-- ILogicChainArmory.java
    |   |                       |           |   |-- factory
    |   |                       |           |   |   |-- DefaultChainFactory.java
    |   |                       |           |   |-- impl
    |   |                       |           |       |-- BlackListLogicChain.java
    |   |                       |           |       |-- DefaultLogicChain.java
    |   |                       |           |       |-- RuleWeightLogicChain.java
    |   |                       |           |-- tree
    |   |                       |               |-- ILogicTreeNode.java
    |   |                       |               |-- factory
    |   |                       |               |   |-- DefaultTreeFactory.java
    |   |                       |               |   |-- engine
    |   |                       |               |       |-- IDecisionTreeEngine.java
    |   |                       |               |       |-- impl
    |   |                       |               |           |-- DecisionTreeEngine.java
    |   |                       |               |-- impl
    |   |                       |                   |-- RuleLockLogicTreeNode.java
    |   |                       |                   |-- RuleLuckAwardLogicTreeNode.java
    |   |                       |                   |-- RuleStockLogicTreeNode.java
    |   |                       |-- task
    |   |                           |-- model
    |   |                           |   |-- entity
    |   |                           |       |-- TaskEntity.java
    |   |                           |-- repository
    |   |                           |   |-- ITaskRepository.java
    |   |                           |-- service
    |   |                               |-- ITaskService.java
    |   |                               |-- TaskService.java
    |-- lucky-infrastructure
    |   |-- pom.xml
    |   |-- src
    |   |   |-- main
    |   |       |-- java
    |   |           |-- cn
    |   |               |-- xyfv
    |   |                   |-- infrastructure
    |   |                       |-- event
    |   |                       |   |-- EventPublisher.java
    |   |                       |-- persistent
    |   |                           |-- dao
    |   |                           |   |-- IAwardDao.java
    |   |                           |   |-- IDailyBehaviorRebateDao.java
    |   |                           |   |-- IRaffleActivityAccountDao.java
    |   |                           |   |-- ...
    |   |                           |-- po
    |   |                           |   |-- Award.java
    |   |                           |   |-- DailyBehaviorRebate.java
    |   |                           |   |-- RaffleActivity.java
    |   |                           |   |-- ...
    |   |                           |-- redis
    |   |                           |   |-- IRedisService.java
    |   |                           |   |-- RedissonService.java
    |   |                           |-- repository
    |   |                               |-- ActivityRepository.java
    |   |                               |-- AwardRepository.java
    |   |                               |-- BehaviorRebateRepository.java
    |   |                               |-- StrategyRepository.java
    |   |                               |-- TaskRepository.java
    |-- lucky-trigger
    |   |-- pom.xml
    |   |-- src
    |   |   |-- main
    |   |       |-- java
    |   |           |-- cn
    |   |               |-- xyfv
    |   |                   |-- trigger
    |   |                       |-- http
    |   |                       |   |-- RaffleActivityController.java
    |   |                       |   |-- RaffleStrategyController.java
    |   |                       |-- job
    |   |                       |   |-- SendMessageTaskJob.java
    |   |                       |   |-- UpdateActivitySkuStockJob.java
    |   |                       |   |-- UpdateAwardStockJob.java
    |   |                       |-- listener
    |   |                           |-- ActivitySkuStockZeroCustomer.java
    |   |                           |-- RebateMessageCustomer.java
    |   |                           |-- SendAwardCustomer.java
    |-- lucky-types
    |   |-- pom.xml
    |   |-- src
    |   |   |-- main
    |   |       |-- java
    |   |           |-- cn
    |   |               |-- xyfv
    |   |                   |-- types
    |   |                       |-- common
    |   |                       |   |-- Constants.java
    |   |                       |-- enums
    |   |                       |   |-- ResponseCode.java
    |   |                       |-- event
    |   |                       |   |-- BaseEvent.java
    |   |                       |-- exception
    |   |                       |   |-- AppException.java
    |   |                       |-- model
    |   |                           |-- Response.java
    |-- docs
        |-- dev-ops
            |-- app
                |-- start.sh
                |-- stop.sh