6f2731ee2d
- 验签: pangle.build_sign/verify_callback_sign 改为 GroMore 官方
sign=SHA256("{m-key}:{trans_id}")(普通 SHA256,只签 trans_id);
回调响应改成 GroMore 要求的 {is_verify, reason}
- 发奖: 按回调 reward_amount 发金币(rewards 带回退/夹紧),ad_reward 幂等 + 每日上限
- 分层: app/core/{pangle,wxpay}.py → app/integrations/(对齐 jiguang/meituan/sms);
更新 ad.py / crud/wallet.py / scripts/sim_pangle_callback.py / 测试的 import
(含 test_withdraw 的 monkeypatch 路径 app.core.wxpay→app.integrations.wxpay)
- 测试: test_ad_reward + test_withdraw 共 17 项通过
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
42 lines
1.8 KiB
Python
42 lines
1.8 KiB
Python
"""看激励视频发奖相关 schemas。
|
|
|
|
约定同其余模块:字段 snake_case、金额/次数存整数。
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
class PangleCallbackOut(BaseModel):
|
|
"""回给穿山甲 GroMore 的回调响应。
|
|
|
|
GroMore 服务端激励回调规范(supportcenter/26240)要求响应体为
|
|
`{"is_verify": bool, "reason": int}`:
|
|
- `is_verify=true` + `reason=0`:校验通过、发放奖励(发奖成功 或 当日已达上限均算"已处理")。
|
|
- `is_verify=false`:不发放,`reason` 带错误码透传客户端 SDK(见 ad.py 的 REASON_*)。
|
|
验签失败由 API 层直接返 403,不走这里。"""
|
|
|
|
is_verify: bool = True
|
|
reason: int = 0
|
|
|
|
|
|
class AdRewardStatusOut(BaseModel):
|
|
"""客户端查今日看广告发奖进度(福利页"看视频赚金币"用)。"""
|
|
|
|
used_today: int = Field(..., description="今日已成功发奖次数")
|
|
daily_limit: int = Field(..., description="每日发奖次数上限")
|
|
remaining: int = Field(..., description="今日剩余可领次数")
|
|
coin_per_ad: int = Field(..., description="看完一个激励视频发的金币")
|
|
|
|
|
|
class TestGrantOut(BaseModel):
|
|
"""[仅本地联调]模拟发奖结果。带上今日进度,客户端可直接据此刷新展示。"""
|
|
|
|
granted: bool = Field(..., description="本次是否真的发了金币(达每日上限则 False)")
|
|
status: str = Field(..., description="granted / capped")
|
|
coin: int = Field(..., description="本次发放金币(capped 时为 0)")
|
|
used_today: int = Field(..., description="今日已成功发奖次数")
|
|
daily_limit: int = Field(..., description="每日发奖次数上限")
|
|
remaining: int = Field(..., description="今日剩余可领次数")
|
|
coin_per_ad: int = Field(..., description="看完一个激励视频发的金币")
|