feat: 反馈加来源/场景/运营回复 + 提现类型筛选 (#105)
用户反馈后台:区分反馈类型(比价反馈/普通反馈)+ 审核可给用户留言;提现后台:按提现类型筛选。 - feedback 表加 source(profile/comparison)/scene/admin_reply + 迁移;提交接口 /api/v1/feedback 接收 source/scene,来源判定显式 source 优先、否则据 scene 有无派生(有=comparison); /records 带回 scene + admin_reply。 - admin 反馈:列表加「反馈类型」筛选;采纳/拒绝支持存 admin_reply(给用户的回复,用户端可见); FeedbackOut 带出 source/scene/admin_reply。 - admin 提现:WithdrawOut 暴露 source,列表加「提现类型」筛选(coin_cash=福利页提现 / invite_cash=邀请提现)。 - 补 4 项测试:来源派生、回复存取、反馈按类型筛选、提现按类型筛选。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> --------- Co-authored-by: zzhyyyyy <2685922758@qq.com> Reviewed-on: #105 Co-authored-by: zhuzihao <zhuzihao@wonderable.ai> Co-committed-by: zhuzihao <zhuzihao@wonderable.ai>
This commit was merged in pull request #105.
This commit is contained in:
@@ -36,6 +36,43 @@ def test_feedback_config_returns_default(client) -> None:
|
||||
assert body["group_name"] == "傻瓜比价官方群"
|
||||
|
||||
|
||||
def test_submit_feedback_derives_source_from_scene(client) -> None:
|
||||
"""比价结果页反馈带 scene → source=comparison 并存 scene;「我的」页不带 → profile;
|
||||
客户端显式传 source 优先(即便没 scene 也判 comparison)。历史接口带回 scene。"""
|
||||
token = _login(client, "13622000010")
|
||||
h = {"Authorization": f"Bearer {token}"}
|
||||
|
||||
r = client.post("/api/v1/feedback", data={"content": "比价太慢了", "scene": "比价太慢"}, headers=h)
|
||||
assert r.status_code == 200, r.text
|
||||
fid_cmp = r.json()["id"]
|
||||
|
||||
r = client.post("/api/v1/feedback", data={"content": "普通建议"}, headers=h)
|
||||
assert r.status_code == 200, r.text
|
||||
fid_prof = r.json()["id"]
|
||||
|
||||
r = client.post(
|
||||
"/api/v1/feedback", data={"content": "只填了描述", "source": "comparison"}, headers=h
|
||||
)
|
||||
assert r.status_code == 200, r.text
|
||||
fid_explicit = r.json()["id"]
|
||||
|
||||
db = SessionLocal()
|
||||
try:
|
||||
cmp_fb = db.get(Feedback, fid_cmp)
|
||||
assert cmp_fb.source == "comparison" and cmp_fb.scene == "比价太慢"
|
||||
prof_fb = db.get(Feedback, fid_prof)
|
||||
assert prof_fb.source == "profile" and prof_fb.scene is None
|
||||
assert db.get(Feedback, fid_explicit).source == "comparison"
|
||||
finally:
|
||||
db.close()
|
||||
|
||||
r = client.get("/api/v1/feedback/records", headers=h)
|
||||
assert r.status_code == 200, r.text
|
||||
scenes = {item["id"]: item["scene"] for item in r.json()["records"]}
|
||||
assert scenes[fid_cmp] == "比价太慢"
|
||||
assert scenes[fid_prof] is None
|
||||
|
||||
|
||||
def test_feedback_records_maps_existing_statuses(client) -> None:
|
||||
phone = "13622000003"
|
||||
token = _login(client, phone)
|
||||
|
||||
Reference in New Issue
Block a user