跳到内容

会员积分

受众:开发者 / 运维 摘要:Core Member Points 会员积分运营底座,负责签到、积分规则、订单奖励、退款冲正、手动调整和过期任务。

Member Points 只维护积分运营规则和来源明细。积分余额、冻结余额和积分流水复用 金额与资产points:* 账户与 money_balance_ledger,本模块不自建余额表。

能力范围

能力说明
积分概览当前用户可用、冻结、本月获得 / 使用和即将过期积分
积分任务展示签到、订单奖励、完善资料、首单、评价等奖励任务和规则
签到当前用户每日签到,支持连续签到奖励
订单奖励监听商业事件,按订单现金支付金额发放积分
简单任务奖励监听拥有事实模块发布的中立任务事件,支持资料完善、首单和有效评价按幂等键发放
退款冲正按退款金额比例扣回已奖励积分
营销抽奖奖励供 Marketing points 奖项按抽奖幂等键写入积分流水
手动调整Admin 发放或扣减积分,写 Money 流水和来源明细
过期任务周期扫描到期积分来源并扣减余额

API 路径

API说明
GET /api/v1/member-points/users/me/overview当前用户积分概览
GET /api/v1/member-points/users/me/ledgers当前用户积分流水
GET /api/v1/member-points/tasks当前用户积分任务
POST /api/v1/member-points/users/me/check-in当前用户签到
GET /api/v1/admin/member-points/accounts后台积分账户列表
GET /api/v1/admin/member-points/ledgers后台积分流水
GET /api/v1/admin/member-points/rules后台规则分页
POST /api/v1/admin/member-points/rules保存积分规则
POST /api/v1/admin/member-points/manual-adjustments手动发放 / 扣减
POST /api/v1/admin/member-points/expire-batches/run手动执行过期批次

权限前缀为 member-points:*。默认积分资产为 Money points:mall

数据模型

说明
member_points_rule签到、订单奖励、过期等运营规则
member_points_check_in用户签到记录
member_points_source积分来源、剩余可扣数量和过期时间
member_points_expire_batch过期扫描批次

迁移归属:

文件说明
spring-open-core/spring-open-core-member-points/src/main/resources/db/changelog/migrations/0000_00_00_036000_core_member_points_create_tables.xml建表
spring-open-core/spring-open-core-member-points/src/main/resources/db/changelog/migrations/0000_00_00_036100_core_member_points_seed_data.xml默认资产、规则、权限、菜单和角色绑定

与其他模块的边界

  • Money 是积分余额事实来源,Member Points 不直接维护余额表。
  • Mall 只发布中立商业事件,Member Points 监听后做奖励和冲正,避免 Mall 依赖积分模块。
  • 完善资料、首单、评价等简单任务奖励不开放用户任意领取接口;IAM / Mall 等拥有事实的模块在自身校验通过后发布 profile-completionfirst-orderreview-reward 中立任务事件,Member Points 监听后统一调用 rewardTask 写账。
  • 首单奖励幂等键固定在用户 + mall:first-order 维度,重复支付回调或后续订单不会重复发放;评价奖励幂等键固定在评价 ID 维度,重复保存同一订单商品评价不会重复发放。
  • 复杂营销玩法归 Marketing / Voucher 等模块;Marketing 的 points 抽奖奖项通过 rewardMarketingLottery 使用 member-points:marketing-lottery:{userId}:{operationKey} 幂等键写入 Money points:* 流水,Member Points 不保存抽奖奖池和中奖事实。
  • 多积分资产扩展前应先确认 Money points:<code> 资产和消费方边界。

配置项

配置说明
spring.open.member-points.expire.auto-startup是否自动启动积分过期扫描
spring.open.member-points.expire.task-name过期任务名称,默认 member-points.expire

验证命令

bash
./mvnw -pl spring-open-core/spring-open-core-money,spring-open-core/spring-open-core-member-points,spring-open-modules/spring-open-module-mall -am test -DskipITs -DskipFrontend -Dsurefire.failIfNoSpecifiedTests=false
git diff --check

Released under the Apache License 2.0.