#!/usr/bin/env python3
"""17 拉取通知：订单状态变更、农户确认合作。after_id 记在本地，下次接着拉。"""
import sys
from kl_agri import *

after = int(arg(1, "KL_AFTER_ID", "notify_after_id", "0"))
resp, ok_ = run("17_notify_pull", "notify/pull", {"after_id": after, "limit": 50})
if ok_:
    for it in resp["data"]["items"]:
        b = it["biz"]
        print(it["notify_id"], it["kind"], b.get("order_status") or b.get("confirmation_status"), b.get("outer_order_id") or b.get("outer_supplier_id"))
    state_set(notify_after_id=resp["data"]["next_after_id"])
