Skip to content

Commit

Permalink
feat: check_in add more info
Browse files Browse the repository at this point in the history
  • Loading branch information
MistEO committed Jan 16, 2025
1 parent 4b8de7b commit e7a6b28
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
18 changes: 11 additions & 7 deletions src/check_in/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
1 change: 1 addition & 0 deletions src/database/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class CheckIn(Model):
activated_at = DateTimeField()
application = CharField()
module = CharField()
user_agent = CharField()

class Meta:
database = db
Expand Down
4 changes: 3 additions & 1 deletion src/order/afdian/query_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down

0 comments on commit e7a6b28

Please sign in to comment.