feat: 接入数据大盘聚合与美团 CPS 对账
改了什么:新增新版大盘日期窗口聚合、广告收益拆分、比价耗时字段、美团 CPS 拉单入库与大盘展示,并同步反馈审核和邀请奖励下线口径。 验证:python -m pytest tests/test_admin_read.py tests/test_admin_write.py tests/test_compare_record.py tests/test_invite.py tests/test_feedback.py -q。
This commit is contained in:
@@ -77,9 +77,10 @@ def _call(path: str, body_obj: dict[str, Any]) -> dict[str, Any]:
|
||||
raise MeituanCpsError(f"meituan http {resp.status_code}")
|
||||
|
||||
data = resp.json()
|
||||
if data.get("code") != 0:
|
||||
logger.error("[MT] api error code=%s message=%s", data.get("code"), data.get("message"))
|
||||
raise MeituanCpsError(f"code={data.get('code')} {data.get('message')}")
|
||||
if str(data.get("code")) != "0":
|
||||
message = data.get("message") or data.get("msg")
|
||||
logger.error("[MT] api error code=%s message=%s", data.get("code"), message)
|
||||
raise MeituanCpsError(f"code={data.get('code')} {message}")
|
||||
|
||||
return data
|
||||
|
||||
@@ -142,3 +143,52 @@ def get_referral_link(
|
||||
body["linkTypeList"] = link_type_list or [1, 3]
|
||||
|
||||
return _call("/cps_open/common/api/v1/get_referral_link", body)
|
||||
|
||||
|
||||
def query_order(
|
||||
*,
|
||||
start_time: int,
|
||||
end_time: int,
|
||||
query_time_type: int = 1,
|
||||
page: int = 1,
|
||||
limit: int = 100,
|
||||
platform: int | None = None,
|
||||
business_line: list[int] | None = None,
|
||||
act_id: int | str | None = None,
|
||||
sid: str | None = None,
|
||||
order_id: str | None = None,
|
||||
trade_type: int | None = None,
|
||||
search_type: int = 1,
|
||||
scroll_id: str | None = None,
|
||||
) -> dict[str, Any]:
|
||||
"""按时间窗拉 CPS 订单做对账。
|
||||
|
||||
美团接口要求 startTime/endTime 为 10 位秒级时间戳;commissionRate 返回
|
||||
"300" 表示 3%,订单金额/佣金是元字符串。
|
||||
"""
|
||||
body: dict[str, Any] = {
|
||||
"queryTimeType": query_time_type,
|
||||
"startTime": start_time,
|
||||
"endTime": end_time,
|
||||
"limit": min(max(limit, 1), 100),
|
||||
"searchType": search_type,
|
||||
}
|
||||
if search_type == 2:
|
||||
body["page"] = 1
|
||||
if scroll_id:
|
||||
body["scrollId"] = scroll_id
|
||||
else:
|
||||
body["page"] = max(page, 1)
|
||||
if platform is not None:
|
||||
body["platform"] = platform
|
||||
if business_line:
|
||||
body["businessLine"] = business_line
|
||||
if act_id is not None:
|
||||
body["actId"] = act_id
|
||||
if sid:
|
||||
body["sid"] = sid
|
||||
if order_id:
|
||||
body["orderId"] = order_id
|
||||
if trade_type is not None:
|
||||
body["tradeType"] = trade_type
|
||||
return _call("/cps_open/common/api/v1/query_order", body)
|
||||
|
||||
Reference in New Issue
Block a user