288766443a
从最新 origin/main 重拉的干净分支,只含本人记账改动,不含 marco 的归因订单(order_record)——后者是另一条未合并分支 feat/user-order-records 的功能,此前被误用 git add -A 和记账混进了 feat/savings-accounting-m1。本分支不带它:savings_record 升级为唯一真相表(新增原价/比价价/支付渠道/源平台/幂等键等列,迁移 savings_report_fields 直接挂 f01db5d77dac、不经 order_record_table);/order/report 改写 savings_record(source='compare'),省额=源平台原价−实付;展示 /api/v1/savings/* 真实优先 demo 兜底。无 order_record 的 model/repo/迁移/路由。alembic 单一 head + pytest 54 passed。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: xianze <ze@192.168.0.138> Reviewed-on: #10 Co-authored-by: zhangxianze <zhangxianze@wonderable.ai> Co-committed-by: zhangxianze <zhangxianze@wonderable.ai>
26 lines
959 B
Python
26 lines
959 B
Python
from fastapi import APIRouter
|
|
|
|
from app.api.deps import CurrentUser, DbSession
|
|
from app.repositories import savings as crud_savings
|
|
from app.schemas.order import OrderReportOut, OrderReportRequest
|
|
|
|
router = APIRouter(prefix="/api/v1/order", tags=["order"])
|
|
|
|
|
|
@router.post(
|
|
"/report",
|
|
response_model=OrderReportOut,
|
|
summary="上报归因订单(比价后5分钟内点链接 + 支付金额与比价价相差≤1元)",
|
|
)
|
|
def report_order(req: OrderReportRequest, user: CurrentUser, db: DbSession) -> OrderReportOut:
|
|
# 记账唯一真相表是 savings_record(source='compare')。
|
|
rec, duplicated = crud_savings.create_from_report(db, user.id, req)
|
|
return OrderReportOut(
|
|
id=rec.id,
|
|
platform=rec.platform or req.platform,
|
|
pay_channel=rec.pay_channel or req.pay_channel,
|
|
compared_price_cents=rec.compared_price_cents or 0,
|
|
paid_amount_cents=rec.order_amount_cents,
|
|
duplicated=duplicated,
|
|
)
|