Background:
The system simulates a transaction intent management tool to handle the process from initialization to completion and calculate the final balances of merchants' accounts. Transaction states include:
- PENDING: The transaction is created and awaiting processing.
- IN_PROGRESS: The transaction is being processed.
- DONE: The transaction is completed, and the balance is updated.
Core Features:
- START (optional): Initializes a merchant account with an initial balance and an optional refund limit.
- NEW: Creates a transaction intent for the specified account with the given amount in the PENDING state.
- PROCESS: Moves a transaction from PENDING to IN_PROGRESS.
- COMPLETE: Moves a transaction from IN_PROGRESS to DONE and adds the amount to the merchant's balance.
Example:
Input:
START account1 0
NEW txn1 account1 50
PROCESS txn1
COMPLETE txn1
Output:
account1 50
Extended Features:
- MODIFY: Updates the amount for a PENDING transaction intent.
- CANCEL: Reverts a transaction from IN_PROGRESS to PENDING.
- RETURN: Processes a refund for a DONE transaction and deducts the amount from the account's balance.
Example:
Input:
START account1 0
NEW txn1 account1 50
PROCESS txn1
CANCEL txn1
PROCESS txn1
COMPLETE txn1
RETURN txn1
Output:
account1 0
Time-Limited Refunds:
Each command includes a marker indicating the timestamp. Merchants can set a refund time limit; transactions can only be refunded within this limit.
- If no limit is set, refunds are allowed indefinitely.
- A limit of 0 means no refunds are allowed.
Example:
Input:
1 START account1 0 5
2 NEW txn1 account1 100
8 COMPLETE txn1
11 RETURN txn1
16 RETURN txn1
Output:
account1 100
Task Objective:
Process a list of commands to manage transaction intents and output the final balances of all accounts.
Input Format:
A time-ordered list of commands.
Output Format:
A list of account balances in ascending order by account ID.
Output Example:
["account1 50", "account2 100"]
我们长期稳定承接各大科技公司如TikTok、Google、Amazon等的OA笔试代写服务,确保满分通过。如有需求,请随时联系我们。
We consistently provide professional online assessment services for major tech companies like TikTok, Google, and Amazon, guaranteeing perfect scores. Feel free to contact us if you're interested.