diff --git a/src/check_in/__init__.py b/src/check_in/__init__.py index 69970ac..1116355 100644 --- a/src/check_in/__init__.py +++ b/src/check_in/__init__.py @@ -13,22 +13,26 @@ async def check_in(body: dict): logger.debug(f"body: {body}") cdk = body.get("cdk", "") - app = body.get("app", "") - if not cdk or not app: - logger.error(f"no cdk or app field") - return {"ec": 400, "em": "no cdk or app field"} + res_id = body.get("res_id", "") + if not cdk or not res: + logger.error(f"no cdk or res field") + return {"ec": 400, "em": "no cdk or res field"} now = datetime.now() + user_agent = body.get("user_agent", "") + module = body.get("module", "") try: CheckIn.create( cdk=cdk, activated_at=now, - application=app, + application=res_id, + module=module, + user_agent=user_agent ) except Exception as e: - logger.error(f"check_in failed, cdk: {cdk}, app: {app}") - return {"ec": 403, "em": f"check_in failed, cdk: {cdk}, app: {app}"} + logger.error(f"check_in failed, cdk: {cdk}, res: {res}") + return {"ec": 403, "em": f"check_in failed, cdk: {cdk}, res: {res}"} return {"ec": 200, "em": "OK"} diff --git a/src/database/__init__.py b/src/database/__init__.py index f880c6c..634c407 100644 --- a/src/database/__init__.py +++ b/src/database/__init__.py @@ -72,6 +72,7 @@ class CheckIn(Model): activated_at = DateTimeField() application = CharField() module = CharField() + user_agent = CharField() class Meta: database = db diff --git a/src/order/afdian/query_order.py b/src/order/afdian/query_order.py index ebbe1af..9c71744 100644 --- a/src/order/afdian/query_order.py +++ b/src/order/afdian/query_order.py @@ -18,7 +18,9 @@ async def query_order(order_id: str): try: bill = Bill.get(Bill.platform == "afdian", Bill.order_id == order_id) except Exception as e: - logger.warning(f"Query bill failed, order_id: {order_id}, error: {e}") + # 如果订单号是正确的,能走到这里说明没收到爱发电的推送 + # 主动去爱发电查一下 + logger.warning(f"Query bill failed, order_id: {order_id}") bill, message = await process_order(order_id) if not bill: logger.error(f"order not found, order_id: {order_id}")