Files
huangjingfen/pro_v3.5.1/.cursor/plans/直推积分奖励问题3排查_fc5fe229.plan.md
2026-04-29 17:35:27 +08:00

123 lines
5.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
name: 直推积分奖励问题3排查
overview: 通过数据库排查发现UID=55 和 UID=56 的 4 笔报单商品订单完全没有生成积分奖励记录,需要部署最新代码后使用补发命令修复。
todos:
- id: deploy-code
content: 将最新 queue 分支代码部署到生产服务器 47.94.76.64
status: pending
- id: patch-rewards
content: 在服务器执行 php think hjf:patch-rewards 补发缺失的积分奖励
status: pending
- id: verify-results
content: 查询 points_release_log 确认 4 笔订单的奖励记录已正确生成
status: pending
isProject: false
---
# 直推积分奖励问题3 排查结果与修复计划
## 数据库排查结果
### 推荐链与分销等级
| UID | 昵称 | spread_uid | agent_level | 等级名(grade) | direct_reward_points |
| --- | --- | ---------- | ----------- | ---------- | -------------------- |
- **UID=1** (初始账号): spread_uid=0, agent_level=3 (服务中心, grade=3), direct=1000, frozen_points=1983
- **UID=2** (潘186): spread_uid=1, agent_level=2 (云店, grade=2), direct=800, frozen_points=9296
- **UID=54** (金25): spread_uid=2, agent_level=1 (创客, grade=1), direct=500, frozen_points=0
- **UID=55** (金68): spread_uid=54, agent_level=0 (非分销员), frozen_points=0
- **UID=56** (wx363053): spread_uid=55, agent_level=0 (非分销员), frozen_points=0
推荐链确认: uid=1 -> uid=2 -> uid=54 -> uid=55 -> uid=56
### UID=55 和 UID=56 的已付款订单(全部 is_queue_goods=1
- **#142** wx770632864445235200 | UID=55 | 范氏国香中式轻养生灸3条套装
- **#144** wx770679631480094720 | UID=55 | 城市休闲折叠单车6速+2条养生灸
- **#145** wx770680112881336320 | UID=55 | 紫兰国香粉嫩套装多部位可选
- **#146** wx770680790747971584 | UID=56 | 城市休闲折叠单车6速+2条养生灸
### 积分奖励记录
**这 4 笔订单在 `eb_points_release_log` 中完全没有任何 reward_direct / reward_umbrella 记录。**
对比同时期 UID=54 自己的订单 (#143 wx770633621278031872) 则正常生成了奖励UID=1 获得 1000 直推奖励)。
### 预期应产生的奖励(以 UID=55 的一笔订单为例)
按当前代码 `propagateReward` 级差算法UID=55 (非分销员) 购买后:
```mermaid
flowchart TD
buyer["UID=55 买家 (agent_level=0, direct=0)"]
uid54["UID=54 创客 (depth=0, direct=500)"]
uid2["UID=2 云店 (depth=1, direct=800)"]
uid1["UID=1 服务中心 (depth=2, direct=1000)"]
buyer -->|"spread_uid=54"| uid54
uid54 -->|"actual=500-0=500"| uid54
uid54 -->|"nextLower=500"| uid2
uid2 -->|"actual=800-500=300"| uid2
uid2 -->|"nextLower=800"| uid1
uid1 -->|"actual=1000-800=200"| uid1
```
- UID=54 应获得 **500** 直推奖励(级差)
- UID=2 应获得 **300** 直推奖励(级差)
- UID=1 应获得 **200** 直推奖励(级差)
UID=56 的订单类似UID=55 非分销员 depth=0 => directCascadeActive 变 false => 仅伞下奖励,如果开关开着的话)。
## 根因分析
1. **服务器代码未更新**生产服务器47.94.76.64上运行的代码很可能不是最新版本。UID=54 的订单(#143)成功产生奖励,但 UID=55/56 的订单(#142/#144/#145/#146)完全没有记录,说明支付回调 [Pay.php](pro_v3.5.1/app/listener/order/Pay.php) 中的积分奖励逻辑未正确触发。
2. `**hjf_queue_pool_enable=0`**公排关闭走的是同步分支Pay.php L164-216应直接调用 `reward()`。但实际未生成记录,说明该服务器的 Pay.php 可能还是旧版本。
3. **UID=54 订单的异常数据**:订单 #143`order.spread_uid=1``user.spread_uid=2`(不一致),且 UID=1 拿到 1000 而非级差 200进一步证实服务器运行的是更早的非级差版本。
## 修复方案
### 步骤 1部署最新代码到生产服务器
确保以下文件已同步到 47.94.76.64
- [app/listener/order/Pay.php](pro_v3.5.1/app/listener/order/Pay.php) — 支付回调中的积分奖励同步逻辑
- [app/services/hjf/PointsRewardServices.php](pro_v3.5.1/app/services/hjf/PointsRewardServices.php) — 级差+直推链校验
- [app/command/HjfPatchMissingRewards.php](pro_v3.5.1/app/command/HjfPatchMissingRewards.php) — 补发命令
### 步骤 2使用补发命令修复缺失的积分奖励
代码部署后,在服务器上依次执行:
```bash
# 先 dry-run 确认哪些订单需要补发
php think hjf:patch-rewards --dry-run
# 也可针对单笔订单验证
php think hjf:patch-rewards --order-id=142 --dry-run
# 确认无误后执行实际补发
php think hjf:patch-rewards
```
该命令已内置幂等检查(跳过已有 reward 记录的订单),安全执行。
### 步骤 3验证补发结果
补发后查询确认:
```sql
SELECT uid, points, type, mark, order_id
FROM eb_points_release_log
WHERE order_id IN (
'wx770632864445235200','wx770679631480094720',
'wx770680112881336320','wx770680790747971584'
)
ORDER BY order_id, uid;
```
预期:每笔 UID=55 的订单应产生 UID=54(500) + UID=2(300) + UID=1(200) 的记录UID=56 的订单因 depth=0 非分销员,直推链中断,仅在伞下开关开启时产生伞下奖励。