An online store bill automatic collection and storage method and related equipment
Patent Information
- Application Number
- CN202610979909.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-02
- Publication Date
- 2026-09-25
AI Technical Summary
[0005]本发明提供了一种线上店铺的账单自动采集入库方法和相关设备,解决了固定身份凭证易失效以及人工处理成本高、效率低且易出错的技术问题
[0047]从以上技术方案可以看出,本发明具有以下优点:本发明提供的一种线上店铺的账单自动采集入库方法和相关设备,其通过响应于周期结算任务指令,获取已通过合法授权获得数据访问权限的各目标线上店铺的当前身份凭证和凭证状态,实现任务触发与状态预判,为差异化调用提供依据,若凭证状态为有效状态,则直接调用账单数据接口,减少无效调用和浏览器登录开销,提升采集效率和资源利用率,若凭证状态为失效状态,则触发凭证修复流程后基于修复后的当前身份凭证调用所述账单数据接口,自动应对凭证过期或失效场景,使得采集任务不中断,增强系统鲁棒性,接收账单数据进行解析和结构化处理并入库,形成从数据获取到存储的全自动化闭环,提高数据准确性与时效性。
Smart Images

Figure CN122820352A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data management technology, and in particular to a method and related equipment for automatically collecting and storing invoices from online stores. Background Technology
[0002] Currently, mainstream e-commerce platforms typically provide merchants with a function to query financial statements, but most platforms do not provide official application programming interfaces (APIs) for batch retrieval of statement data. For companies operating a large number of online stores, the finance department needs to complete the reconciliation of financial statements for each store within the monthly settlement cycle. This process involves login authentication, data acquisition, parsing, and database storage.
[0003] Under the current technological background, common implementation methods include: First, fully manual operation, where financial personnel log in to the backend of each store one by one, manually select the time range and download the bill file and then import it into the financial system; Second, a Hypertext Transfer Protocol (HTTP) request scheme based on fixed session credentials (cookies), where the session credentials after login are manually extracted and stored in advance, and then the credential is directly used to call the bill data interface.
[0004] However, the existing solutions mentioned above have the following drawbacks: the manual approach is costly and difficult to scale; the solution based on fixed session credentials cannot cope with the extremely short validity period of session credentials on e-commerce platforms; and all of the above solutions lack the ability to automatically parse and structure billing data for storage. Summary of the Invention
[0005] This invention provides a method and related equipment for automatically collecting and storing invoices for online stores, which solves the technical problems of easily expired fixed identity credentials and high cost, low efficiency and error-proneness of manual processing.
[0006] In a first aspect, the present invention provides a method for automatically collecting and storing invoices from online stores, applied to a store management terminal, wherein the store management terminal stores authorized login information for at least one target online store, including:
[0007] In response to the periodic settlement task instruction, obtain the current identity credentials and credential status of each target online store;
[0008] If the credential status is valid, then based on the current identity credential, the billing data interface of the corresponding target online store is invoked;
[0009] If the credential status is invalid, the credential repair process of the corresponding target online store is triggered, and the billing data interface is called based on the repaired current identity credential.
[0010] If the billing data returned by the billing data interface is received, the billing data is parsed and structured to obtain structured data, which is then stored in the target database.
[0011] In some embodiments, it also includes:
[0012] Based on a preset time interval, the current identity credential information of each target online store in the identity credential pool is obtained; the current identity credential information includes the remaining validity period and credential status of the current identity credential.
[0013] If the remaining valid duration is less than a preset time threshold, or the voucher status is invalid, then the voucher update process for the corresponding target online store is triggered.
[0014] If the credential status is valid, a probe request is sent to the platform server corresponding to the target online store. Based on the request response result returned by the platform server corresponding to the probe request, the credential status is updated.
[0015] In some embodiments, updating the credential status based on the request response result returned by the platform server corresponding to the activation request includes:
[0016] If the request response is a credential expiration indication, then the credential status is switched to an expiration status;
[0017] If the request response indicates that the credential is valid, then the credential status remains unchanged.
[0018] In some embodiments, the process of triggering the corresponding target online store's credential update includes:
[0019] Retrieve the pre-stored login information of the target online store;
[0020] Based on the pre-stored login information, a merchant login request is initiated to the target online store;
[0021] If no verification input prompt appears during the merchant login request process, the identity credential is extracted from the login response as the latest valid credential, the latest valid credential is replaced with the current identity credential of the corresponding target online store in the identity credential pool, and the corresponding credential status is marked as valid.
[0022] If a verification prompt appears during the merchant login request process, the credential status will be marked as invalid.
[0023] In some embodiments, triggering the credential restoration process for the corresponding target online store includes:
[0024] Retrieve the pre-stored login information of the target online store;
[0025] Based on the pre-stored login information, a merchant login request is initiated to the target online store;
[0026] If no verification prompt appears during the merchant login request process, the identity credential is extracted from the login response as the repaired current identity credential.
[0027] If a verification input prompt appears during the merchant login request process, a manual input waiting process is triggered. After receiving the manually input verification information, the verification information is submitted to continue executing the merchant login request, and the identity credential extracted from the login response is used as the repaired current identity credential.
[0028] Replace the repaired current identity credential with the current identity credential of the corresponding target online store in the identity credential pool, and mark the corresponding credential status as valid.
[0029] In some embodiments, the step of invoking the billing data interface based on the repaired current identity credentials includes:
[0030] The interface for obtaining the billing data is based on a preset interface call protocol specification;
[0031] According to the interface call protocol specification, an interface call request is generated based on the repaired current identity credentials;
[0032] Based on the interface call request, the billing data interface is invoked.
[0033] In some embodiments, it also includes:
[0034] If a call failure message is received from the interface, the current number of call failures for the billing data interface is updated.
[0035] If the current number of failed calls is less than a preset number, then after a preset time interval, the process jumps to the step of generating an interface call request based on the repaired current identity credentials in accordance with the interface call protocol specification.
[0036] If the current number of failed calls is equal to or greater than the preset number, the last failed call time is recorded, and the store status of the corresponding target online store is marked as an abnormal interface call status.
[0037] In some embodiments, after parsing the bill data and performing structured processing to obtain structured data and storing it in the target database, the process includes:
[0038] Obtain the store status of each of the target online stores;
[0039] If the store status is an interface call error status, then obtain the store identifier, pre-stored login information, and last call failure time of the corresponding target online store;
[0040] Based on the store identifier, the pre-stored login information, and the last failed call time, store exception information is generated and pushed to the store monitoring system.
[0041] Secondly, the present invention provides an automatic bill collection and storage device for online stores, comprising:
[0042] The credential acquisition module is used to obtain the current identity credentials and credential status of each target online store in response to the periodic settlement task instructions.
[0043] The interface call module is used to call the billing data interface of the corresponding target online store based on the current identity credential if the credential status is valid.
[0044] The credential repair module is used to trigger the credential repair process of the corresponding target online store if the credential status is invalid, and to call the bill data interface based on the repaired current identity credential.
[0045] The bill processing module is used to parse the bill data returned by the bill data interface, perform structured processing on the bill data, obtain structured data, and store it in the target database.
[0046] Thirdly, the present invention provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed, implements the above-mentioned method for automatically collecting and storing online store bills.
[0047] As can be seen from the above technical solutions, the present invention has the following advantages: The present invention provides an automatic collection and storage method and related equipment for online store bills. By responding to the periodic settlement task instruction, it obtains the current identity credentials and credential status of each target online store that has obtained data access permissions through legal authorization, realizes task triggering and status prediction, and provides a basis for differentiated calls. If the credential status is valid, the bill data interface is directly called, reducing invalid calls and browser login overhead, improving collection efficiency and resource utilization. If the credential status is invalid, the credential repair process is triggered, and the bill data interface is called based on the repaired current identity credentials, automatically handling scenarios of expired or invalid credentials, so that the collection task is not interrupted, enhancing system robustness. The bill data is received, parsed, structured, and stored in the database, forming a fully automated closed loop from data acquisition to storage, improving data accuracy and timeliness. Attached Figure Description
[0048] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0049] Figure 1 A flowchart illustrating an automatic bill collection and storage method for online stores, provided as an embodiment of the present invention;
[0050] Figure 2 A system framework diagram of an online store bill automatic collection and warehousing device provided in an embodiment of the present invention;
[0051] Figure 3 This is a schematic diagram of the structure of an automatic bill collection and warehousing device for online stores provided in an embodiment of the present invention;
[0052] Figure 4 This is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation
[0053] This invention provides a method and related equipment for automatically collecting and storing online store bills, which solves the technical problems of existing technologies such as the easy expiration of fixed identity credentials and the high cost, low efficiency and error-proneness of manual processing.
[0054] To make the objectives, features, and advantages of this invention more apparent and understandable, the technical solutions of the embodiments of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the embodiments described below are only some embodiments of this invention, and not all embodiments. Based on the embodiments of this invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this invention.
[0055] Please see Figure 1 , Figure 1 An optional flowchart of an online store bill automatic collection and storage method provided in an embodiment of the present invention is shown. The method is applied to a store management terminal, which stores the authorized login information of at least one target online store. The method includes steps 101 to 104.
[0056] Step 101: In response to the periodic settlement task instruction, obtain the current identity credentials and credentials status of each target online store, where the target online store is a store that has obtained data access permissions through legal authorization;
[0057] The periodic settlement task instruction refers to the task trigger signal automatically generated and issued by the scheduling center according to the preset time strategy (such as 1:00 am on the 1st of each month), which is used to start the process of collecting financial bills for all or part of the target online stores.
[0058] The target online store refers to an e-commerce platform merchant store that has completed registration and configuration in the system and needs to have its bills collected within the current settlement cycle. Each store has a unique store identifier, which is bound to pre-stored login account, password, and associated mobile phone number.
[0059] Identity credentials refer to the set of data issued by the e-commerce platform's server after a user successfully logs into the merchant's backend. This data is used to maintain session state and identify the user. These credentials are typically stored as cookies and contain information such as account identifier, session identifier, and expiration date. In this system, identity credentials are serialized and stored in an identity credential pool.
[0060] Credential status refers to the current availability identifier maintained by the system for each identity credential. Credential status includes, but is not limited to: valid status (the credential can be used normally for interface calls), invalid status (the credential has expired or been rejected by the platform), and pending verification status (manual input of verification information is required during login). Credential status is stored in the corresponding record in the identity credential pool for subsequent process judgment.
[0061] Specifically, in response to the periodic settlement task instruction, the task parameters carried in the instruction are first parsed to determine the list of all target online stores that need to be processed this time. Then, the identity credential pool that stores identity credentials in a centralized manner is retrieved, and identity credentials are matched based on store identifiers to batch read the current identity credentials and associated credential status corresponding to each target store.
[0062] Step 102: If the credential status is valid, then based on the current identity credential, call the billing data interface of the corresponding target online store.
[0063] A valid status means that the identity credentials corresponding to the online store are still within the valid usage period stipulated by the platform. They have not been deemed invalid due to timeout, account abnormality, platform risk control, or other reasons, and can be used normally to access the store's backend interface and retrieve business data. Identity credentials in this status can pass the platform's permission verification without requiring a re-login operation.
[0064] The billing data interface refers to the internal interface of the e-commerce platform backend identified through packet capture and reverse analysis. It is specifically used to download the financial billing files of various online stores. It has a fixed access address, request method, parameter structure and response format. Only requests with valid identity credentials can be successfully completed and the original billing files can be obtained.
[0065] The API call protocol specification refers to the API interaction standard obtained through browser packet capture and parsing. It includes the API access address, request method, message format, required fields, request header configuration, parameter definition, and data transmission rules, and serves as the basis for generating valid call requests and completing platform API interactions.
[0066] Optionally, if the target online store's current identity credentials are valid, the corresponding store's billing data interface is matched, and the interface call protocol specification obtained after packet capture and reverse analysis of the billing data interface is acquired. Based on the interface call protocol specification, an interface call request to simulate real browser access behavior is constructed. Based on the interface call request, the billing data interface is called and the billing data is obtained. The specific process is as follows:
[0067] By using browser developer tools to perform network packet capture and reverse analysis, we can identify the interface call protocol specifications of the billing data interface, such as the Uniform Resource Locator, request method, required parameters, request header fields, and response format. Among them, the required parameters include billing date and billing type; the request header fields include identity credentials, client identifier, access source, asynchronous request identifier, and data reception type; and the response format includes file stream and data packet types.
[0068] In accordance with the API call protocol specification, the current identity credentials are embedded in the request header, and fields such as client identifier, access source, asynchronous request identifier, and data reception type are completed to replicate the access characteristics of a regular browser and circumvent the platform's risk control mechanism. At the same time, in combination with the task parameters contained in the periodic settlement task instruction, business parameters such as billing date and file export format are assembled in the request body.
[0069] The assembled API call request is sent to the target API address, and the response data returned by the platform is received, which is the billing data of the target online store.
[0070] Step 102 generates an interface call request based on the interface call protocol specification. By constructing a complete request header to simulate browser access, it effectively avoids platform risk control interception and reuses valid identity credentials to complete the call without repeated login, reducing resource consumption, achieving stable acquisition of billing data, and ensuring efficient and continuous operation of the automated collection process.
[0071] Step 103: If the voucher status is invalid, the voucher repair process of the corresponding target online store is triggered, and the billing data interface is called based on the repaired current identity voucher.
[0072] The status of invalid credentials refers to the status of the identity credentials corresponding to the online store that have exceeded the validity period, have been judged by the platform as having login abnormalities, cannot pass the interface permission verification, and cannot be directly used to call the billing data interface.
[0073] The credential repair process refers to the complete process of re-login, credential re-acquisition, and status update for invalid identity credentials. It relies on the browser's automation engine to realize account login and complete the replacement of invalid credentials and status reset.
[0074] Specifically, if the credential status is invalid, the credential repair process is automatically triggered, the browser automation engine is started to perform the store login operation to obtain a new valid credential, namely the repaired current identity credential, and the bill data interface is called again based on the repaired current identity credential; if the retry call continues to fail, a limited number of retries are performed; if the number of retries exceeds the preset threshold, the target online store is marked as having an abnormal interface call status.
[0075] In some embodiments, the above-mentioned credential restoration process for triggering the corresponding target online store includes:
[0076] Retrieve the pre-stored login information of the target online store;
[0077] Based on pre-stored login information, initiate a merchant login request to the target online store;
[0078] If no verification prompt appears during the merchant login request process, the identity credential is extracted from the login response as the repaired current identity credential.
[0079] If a verification prompt appears during the merchant login request process, a process of waiting for manual input is triggered. After receiving the verification information entered manually, the verification information is submitted to continue executing the merchant login request, and the identity credential extracted from the login response is used as the current identity credential after repair.
[0080] Replace the repaired current identity credential with the current identity credential of the corresponding target online store in the identity credential pool, and mark the corresponding credential status as valid.
[0081] Pre-stored login information refers to the basic login data such as login accounts and passwords of various online stores that are encrypted and stored in advance. It is the core basis for initiating automatic login requests.
[0082] Merchant login request: A network request initiated by the login authentication interface or login page of the e-commerce platform's merchant backend to verify the store account password and obtain session credentials. This request can be initiated using a browser automation framework (such as Playwright) to simulate real user operations.
[0083] Verification prompts refer to interactive prompts on e-commerce platforms that require users to provide additional verification information (such as SMS verification codes, image verification codes, email verification codes, etc.) besides their account and password during the login process. These prompts can appear in forms such as input boxes and pop-up windows.
[0084] Optionally, the credential repair process includes the following triggering conditions:
[0085] First, the voucher status read in step 101 is invalid (e.g., status value 0 or -1).
[0086] Second, when calling the billing data interface in step 102, a credential invalidation denial-of-service flag is received from the billing data interface.
[0087] The above triggering conditions all indicate that the current credential can no longer be used. In this case, the system will no longer rely on the invalid credential and will immediately use a browser automation framework (such as Playwright) to perform the login.
[0088] The credential restoration process uses a browser automation framework (such as Playwright) to simulate real user login. During the login process, the framework checks for a verification input prompt (such as an SMS verification code input box). If there is no verification input prompt, the login is successful and the identity credential is retrieved directly. If there is a verification input prompt, the system enters a waiting process for manual input: the system marks the store status as -1 and sends a verification input notification (including the store name and the last four digits of the associated mobile phone number) to the relevant personnel. After the relevant personnel obtain the verification code, they enter it and automatically continue logging into the merchant's store page, solving the problem of SMS verification codes not being automatically recognized.
[0089] After obtaining the new identity credential, the credential repair process replaces the original credential of the target online store in the identity credential pool with the new identity credential and updates the credential status to be valid. This operation provides the latest valid credential for subsequent calls or the next periodic settlement task, realizing incremental refresh of the identity credential pool.
[0090] In some embodiments, the above-mentioned invocation of the billing data interface based on the repaired current identity credentials includes:
[0091] The interface call protocol specification for retrieving billing data is preset;
[0092] According to the API call protocol specification, an API call request is generated based on the repaired current identity credentials;
[0093] The API call request invokes the billing data API.
[0094] In some embodiments, the above-mentioned method for automatically collecting and storing online store bills further includes:
[0095] If a call failure message is received from the interface, update the current number of failed calls to the billing data interface.
[0096] If the current number of failed calls is less than the preset number, after a preset time interval, the process will proceed to the step of generating an interface call request based on the repaired current identity credentials in accordance with the interface call protocol specification.
[0097] If the current number of failed calls is equal to or greater than the preset number, the last failed call time will be recorded, and the store status of the corresponding target online store will be marked as an abnormal interface call status.
[0098] Optionally, after the credential repair is completed, according to the interface call protocol specification, based on the new valid credential, i.e., the repaired current identity credential, the interface call request is regenerated and the bill data interface is called; if the call is successful, i.e. the bill data returned by the interface is received, the data parsing and database entry process is entered; if the call failure information is still returned (non-credential invalidation failure, such as network timeout, internal server error), i.e. the credential invalidation denial-of-service flag returned by the interface is received, the current call failure count is updated, and it is determined whether the current call failure count is less than the preset number threshold. If the current call failure count is less than the preset number, after a preset time interval (e.g., 30 seconds, 1 minute), the process jumps to the step of regenerating the call request for retry; if the current call failure count is equal to or exceeds the preset number, the last call failure time is recorded, and the status of the store is marked as an interface call abnormal state, and no further retries are made.
[0099] Step 104: If bill data is received from the bill data interface, the bill data is parsed and structured to obtain structured data, which is then stored in the target database.
[0100] Structured data processing refers to the process of converting raw billing data into relational data tables with unified field definitions, standard data types, and standardized formats. This process includes sub-steps such as file format recognition, data parsing, field mapping, data cleaning, and deduplication detection, ultimately outputting a set of data records that can be directly written to a database.
[0101] Structured data refers to standardized data that has undergone structured processing such as format unification, field alignment, anomaly removal, and deduplication verification, so that the field definitions, data formats, and content specifications all match the storage requirements of the target database.
[0102] The target database refers to a relational database or other data storage system used to store structured billing data, typically the back-end database of a financial system. The table structure in this database predefines columns corresponding to standard field names in the financial system, and is used to receive the cleaned billing data.
[0103] For example, the specific execution flow of step 104 is as follows:
[0104] Step A1: After receiving the bill data returned by the bill data interface, read the file extension and file header content in sequence to automatically distinguish whether the current file is in Excel or CSV format; at the same time, detect the file encoding type and identify it as UTF-8 or GBK encoding.
[0105] Step A2: Based on the identified file format and encoding rules, read all the content according to the inherent row and column structure of the file, and break down the entire bill file into basic raw data units row by row and column by column to complete the parsing of the raw bill data;
[0106] Step A3, perform structured processing, including:
[0107] Field mapping: Extract the original fields such as order number, product amount, actual payment amount, platform commission, and refund amount from the parsed data, and convert them into standard field names defined by the financial system according to the preset correspondence;
[0108] Data cleaning and format conversion: Clean up empty values and invalid special characters in the data; convert monetary values in cents to yuan; standardize various scattered time formats into preset time formats (such as YYYY-MM-DDHH-MM-SS).
[0109] Duplicate detection: Extract the order number from each data entry and compare it with the data already stored in the target database. If the same order number already exists in the database, it is considered duplicate data and is removed; if no matching record exists, it is considered valid data.
[0110] Step A4: The valid data that has undergone the above structured processing is temporarily stored in the data buffer. When the amount of data in the buffer reaches the preset threshold, the structured data is submitted in batches and written to the target database. This process is repeated until all bill data is successfully stored.
[0111] Step A5: After all store billing data has been entered into the database, log information such as file name, total data volume, number of duplicate data entries, and entry completion time.
[0112] In some embodiments, after performing step 104, the method for automatically collecting and storing the bills of the online store includes:
[0113] Obtain the store status of each target online store;
[0114] If the store status is an API call error status, then obtain the store identifier, pre-stored login information, and last call failure time of the corresponding target online store.
[0115] Based on the store identifier, pre-stored login information, and the last failed call time, store exception information is generated and pushed to the store monitoring system.
[0116] After completing step 104, the periodic settlement task is not immediately ended. Instead, it is necessary to handle the abnormal situations that occur during the entire task execution process in a unified manner. The core of the above steps is to identify all stores that are in an abnormal state of interface call due to the inability of the automated process to resolve the issue, generate detailed abnormal information and push it to the monitoring system, and trigger the L2 level pure manual backup process so that the billing data of these stores can be collected and stored manually.
[0117] Optionally, based on the selected stores in the abnormal call state of the interface, extract the store identifier, the account in the pre-stored login information (displayed in an anonymized manner), and the last call failure time for each store, and combine them with preset suggestion information (such as manually downloading the bill if necessary) to generate a structured list of failed stores; then, push the list of failed stores to the store monitoring system so that the relevant managers of the store monitoring system can obtain the list of stores that need to be manually handled in a timely manner.
[0118] In some embodiments, the above-mentioned method for automatically collecting and storing online store bills further includes:
[0119] Based on a preset time interval, obtain the current identity credential information of each target online store in the identity credential pool; the current identity credential information includes the remaining validity period and credential status of the current identity credential.
[0120] If the remaining valid time is less than the preset time threshold, or the voucher status is expired, the voucher update process for the corresponding target online store will be triggered.
[0121] If the voucher status is valid, a live activity detection request is sent to the platform server corresponding to the target online store. Based on the request response result returned by the platform server corresponding to the live activity detection request, the voucher status is updated.
[0122] The preset time interval refers to the pre-configured time point or time period used to actively maintain the identity credential pool. This time period is managed by the credential refresh scheduler in the scheduling center and is usually set to be executed multiple times a day (such as 6:00, 12:00, 18:00, 23:00) to update soon-to-expire credentials in advance and avoid affecting normal data collection after they expire.
[0123] Current identity credential information refers to the supporting data corresponding to the current identity credential, mainly including two core contents: the remaining validity period of the identity credential and the credential status. It serves as the basis for credential inspection and status maintenance.
[0124] A credential verification request is a lightweight Hypertext Transfer Protocol (HTTP) request used to verify whether identity credentials are still valid. This request typically accesses low-overhead interfaces or pages on an e-commerce platform (such as retrieving basic store information, user information, or directly accessing the merchant's backend homepage), and determines credential validity through the response status (HTTP 200, 401, redirect, etc.). credential verification requests do not carry complex business parameters to minimize the load on the platform's server.
[0125] The request response result refers to the response information returned by the platform server to the login request, including but not limited to: Hypertext Transfer Protocol status codes (e.g., 200 for success, 401 for unauthorized), business error codes in the response body (e.g., 10001 for login failure), or redirection addresses in the response (e.g., redirection to the login page). The validity of the credentials is determined based on this result.
[0126] Optionally, the scheduling center can maintain all credentials in the identity credential pool through pre-set scheduled tasks. By using a dual mechanism of predicting the remaining validity period and lightweight liveness detection requests, credentials that are about to expire or have already expired can be detected and processed in advance, thereby ensuring the high availability of the credential pool.
[0127] The remaining validity period prediction refers to iterating through the credential pool in each scheduled task, reading the expected expiration time of each current identity credential, and comparing it with the current system time to obtain the remaining validity period. If the remaining validity period is lower than a preset time threshold, the credential update process is directly triggered. This time threshold-based prediction mechanism can make decisions quickly without sending network requests, greatly improving efficiency.
[0128] The purpose of lightweight identity verification requests is to verify the validity of the current identity credentials, not to retrieve business data. Therefore, priority is given to interfaces or pages on the platform server that have the fastest response time and the smallest data volume, such as accessing the welcome page of the merchant's backend or calling simple interfaces to retrieve unread message counts. The identity verification request header carries the current identity credentials, the request method is GET, and the timeout is short (e.g., 5 seconds). If an HTTP 200 response or a business success code is returned, the current identity credentials are considered valid; if a 401 or 403 response is returned, or a redirect to the login page is given, the current identity credentials are considered invalid. In this way, during off-peak hours, all seemingly valid credentials can be verified online in batches, allowing for the early detection and triggering of silently expired credentials.
[0129] In some embodiments, updating the credential status based on the request response result returned by the platform server corresponding to the activity detection request includes:
[0130] If the response to the request is a certificate expiration indication, then the certificate status will be switched to an expired status.
[0131] If the request response indicates that the credential is valid, then the credential status remains unchanged.
[0132] Optionally, based on the response to the activation request, the status of the corresponding credential in the identity credential pool is automatically updated: if the response indicates that the credential is valid, the valid status is maintained; if the response indicates that the credential is invalid, the credential status is switched to invalid.
[0133] In some embodiments, the above-mentioned process for triggering the credential update of the corresponding target online store includes:
[0134] Retrieve the pre-stored login information of the target online store;
[0135] Based on pre-stored login information, initiate a merchant login request to the target online store;
[0136] If no verification prompt appears during the merchant login request process, the identity credential is extracted from the login response as the latest valid credential, the latest valid credential is replaced with the current identity credential of the corresponding target online store in the identity credential pool, and the corresponding credential status is marked as valid.
[0137] If a verification prompt appears during the merchant login request process, the credential status will be marked as invalid.
[0138] Optionally, trigger the credential update process. For the target online store that needs to update its credentials, call the browser's automation engine to perform a real merchant login based on the pre-stored login information. Depending on whether a verification prompt appears during the login process, either directly extract the identity credentials or perform human-machine collaborative processing later, and finally obtain the latest valid credentials and update the identity credential pool.
[0139] After a merchant submits a login request, the system polls the page to check if a verification prompt (such as an SMS verification code input box) appears. If no verification prompt appears, the login process is completed successfully. The browser context cookie is extracted as the latest valid credential and updated to the identity credential pool. The credential status is then set to valid. If a verification prompt appears, the store status is marked as pending manual processing, the credential status is set to invalid, and a notification message containing the store identifier and associated mobile phone number is sent to relevant personnel for subsequent human-machine collaborative processing.
[0140] Reference Figure 2 , Figure 2 An optional system framework diagram for an online store bill automatic collection and storage method provided by an embodiment of the present invention is shown below. Figure 2As shown, the scheduling center deployed on the store management terminal responds to the periodic settlement task instruction by retrieving the current identity credentials and credential status of each store from the identity credential pool. If the credential status is valid, the file download module directly calls the e-commerce platform's billing data interface to obtain the billing file. If the credential status is invalid, the browser's automation engine executes login to refresh the credential. If a verification code event is triggered during login, the verification is completed through the verification code processing queue in collaboration with human verification before continuing, obtaining a new credential, and updating it to the credential pool. After obtaining the billing file, the file download module hands it over to the data parsing and database module to complete format recognition, field mapping, cleaning, deduplication, and batch database entry. For stores that fail to complete automatically due to multiple failed calls, the multi-level degradation and fallback module generates a failure list and pushes a notification after the task is completed. Financial personnel manually download the bills and import them into the system through the manual fallback upload channel, reusing the parsing and database module to complete the data entry. The system updates the task completion rate accordingly. Through the coordinated cooperation of the above modules, this embodiment realizes a complete closed-loop process from credential maintenance, data collection, exception handling to manual fallback.
[0141] It should be understood that although the steps in the flowcharts of the above embodiments are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the above embodiments may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.
[0142] The following describes the online store bill automatic collection and storage device provided in the embodiments of this application. The online store bill automatic collection and storage device described below can be referred to in correspondence with the online store bill automatic collection and storage method described above.
[0143] Reference Figure 3 , Figure 3 This is an optional structural diagram of an online store bill automatic collection and storage device provided in an embodiment of the present invention. The device is used to execute the above-described online store bill automatic collection and storage method, including:
[0144] The credential acquisition module 201 is used to obtain the current identity credentials and credential status of each target online store in response to the periodic settlement task instruction.
[0145] The interface call module 202 is used to call the billing data interface of the corresponding target online store based on the current identity credential if the credential status is valid.
[0146] The credential repair module 203 is used to trigger the credential repair process of the corresponding target online store if the credential status is invalid, and call the bill data interface based on the repaired current identity credential.
[0147] The bill processing module 204 is used to parse the bill data returned by the bill data interface, perform structured processing, obtain structured data, and store it in the target database.
[0148] In some embodiments, the credential repair module 400 is specifically configured as follows:
[0149] Retrieve the pre-stored login information of the target online store;
[0150] Based on pre-stored login information, initiate a merchant login request to the target online store;
[0151] If no verification prompt appears during the merchant login request process, the identity credential is extracted from the login response as the repaired current identity credential.
[0152] If a verification prompt appears during the merchant login request process, a process of waiting for manual input is triggered. After receiving the verification information entered manually, the verification information is submitted to continue executing the merchant login request, and the identity credential extracted from the login response is used as the current identity credential after repair.
[0153] Replace the repaired current identity credential with the current identity credential of the corresponding target online store in the identity credential pool, and mark the corresponding credential status as valid.
[0154] In some embodiments, the credential repair module 400 is further configured as follows:
[0155] The interface call protocol specification for retrieving billing data is preset;
[0156] According to the API call protocol specification, an API call request is generated based on the repaired current identity credentials;
[0157] The API call request invokes the billing data API.
[0158] In some embodiments, the above-mentioned online store bill automatic collection and storage device further includes a call retry module, which is specifically configured as follows:
[0159] If a call failure message is received from the interface, update the current number of failed calls to the billing data interface.
[0160] If the current number of failed calls is less than the preset number, after a preset time interval, the process will proceed to the step of generating an interface call request based on the repaired current identity credentials in accordance with the interface call protocol specification.
[0161] If the current number of failed calls is equal to or greater than the preset number, the last failed call time will be recorded, and the store status of the corresponding target online store will be marked as an abnormal interface call status.
[0162] In some embodiments, the above-mentioned online store bill automatic collection and storage device further includes a voucher update module, which is specifically configured as follows:
[0163] Based on a preset time interval, obtain the current identity credential information of each target online store in the identity credential pool; the current identity credential information includes the remaining validity period and credential status of the current identity credential.
[0164] If the remaining valid time is less than the preset time threshold, or the voucher status is expired, the voucher update process for the corresponding target online store will be triggered.
[0165] If the voucher status is valid, a live activity detection request is sent to the platform server corresponding to the target online store. Based on the request response result returned by the platform server corresponding to the live activity detection request, the voucher status is updated.
[0166] The above updates the credential status based on the request response result returned by the platform server corresponding to the activity detection request, including:
[0167] If the response to the request is a certificate expiration indication, then the certificate status will be switched to an expired status.
[0168] If the request response indicates that the credential is valid, then the credential status remains unchanged.
[0169] The above-mentioned process for triggering the corresponding online store's voucher update includes:
[0170] Retrieve the pre-stored login information of the target online store;
[0171] Based on pre-stored login information, initiate a merchant login request to the target online store;
[0172] If no verification prompt appears during the merchant login request process, the identity credential is extracted from the login response as the latest valid credential, the latest valid credential is replaced with the current identity credential of the corresponding target online store in the identity credential pool, and the corresponding credential status is marked as valid.
[0173] If a verification prompt appears during the merchant login request process, the credential status will be marked as invalid.
[0174] In some embodiments, the above-mentioned online store bill automatic collection and storage device further includes a store monitoring module, which is specifically configured as follows:
[0175] After parsing and structuring the billing data to obtain structured data and storing it in the target database, the store status of each target online store is obtained.
[0176] If the store status is an API call error status, then obtain the store identifier, pre-stored login information, and last call failure time of the corresponding target online store.
[0177] Based on the store identifier, pre-stored login information, and the last failed call time, store exception information is generated and pushed to the store monitoring system.
[0178] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working process of the above-described device and module can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0179] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple modules or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or modules may be electrical, mechanical, or other forms.
[0180] The modules described as separate components may or may not be physically separate. Similarly, the components shown as modules may or may not be physical modules; they may be located in one place or distributed across multiple network modules. Some or all of the modules can be selected to achieve the purpose of this embodiment, depending on actual needs.
[0181] Furthermore, the functional modules in the various embodiments of the present invention can be integrated into one processing module, or each module can exist physically separately, or two or more modules can be integrated into one module. The integrated modules described above can be implemented in hardware or as software functional modules.
[0182] If the integrated module is implemented as a software functional module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause an electronic device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0183] This invention also provides an electronic device, which includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the aforementioned method for automatically collecting and storing online store bills. This electronic device can be any smart terminal, including tablet computers.
[0184] It is understood that the content of the above method embodiments is applicable to this device embodiment. The specific functions implemented by this device embodiment are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0185] Please see Figure 4 , Figure 4 The hardware structure of an electronic device according to another embodiment is illustrated, including:
[0186] The processor 901 can be implemented using a general-purpose CPU (Central Processing Unit), microprocessor, application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of the present invention.
[0187] The memory 902 can be implemented as a read-only memory (ROM), static storage device, dynamic storage device, or random access memory (RAM). The memory 902 can store the operating system and other applications. When the technical solutions provided in the embodiments of this specification are implemented through software or firmware, the relevant program code is stored in the memory 902 and is called and executed by the processor 901 to execute the online store bill automatic collection and storage method of the embodiments of this invention.
[0188] The input / output interface 903 is used to implement information input and output;
[0189] The communication interface 904 is used to enable communication and interaction between this device and other devices. Communication can be achieved through wired means (such as USB, Ethernet cable, etc.) or wireless means (such as mobile network, WIFI, Bluetooth, etc.).
[0190] Bus 905 transmits information between various components of the device (e.g., processor 901, memory 902, input / output interface 903, and communication interface 904);
[0191] The processor 901, memory 902, input / output interface 903, and communication interface 904 are connected to each other within the device via bus 905.
[0192] This invention also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the above-described method for automatically collecting and storing online store bills.
[0193] It is understood that the content of the above method embodiments is applicable to this storage medium embodiment. The specific functions implemented in this storage medium embodiment are the same as those in the above method embodiments, and the beneficial effects achieved are also the same as those achieved in the above method embodiments.
[0194] Memory, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs and non-transitory computer-executable programs. Furthermore, memory may include high-speed random access memory, and may also include non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid-state storage device. In some embodiments, memory may optionally include memory remotely located relative to the processor, and these remote memories can be connected to the processor via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.
[0195] The above-described embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for automatically collecting and storing invoices from online stores, characterized in that, This is applied to a store management terminal, which stores authorized login information for at least one target online store, including: In response to the periodic settlement task instruction, obtain the current identity credentials and credential status of each target online store; If the credential status is valid, then based on the current identity credential, the billing data interface of the corresponding target online store is invoked; If the credential status is invalid, the credential repair process of the corresponding target online store is triggered, and the billing data interface is called based on the repaired current identity credential. If the billing data returned by the billing data interface is received, the billing data is parsed and structured to obtain structured data, which is then stored in the target database.
2. The method for automatically collecting and storing online store bills according to claim 1, characterized in that, Also includes: Based on a preset time interval, the current identity credential information of each target online store in the identity credential pool is obtained; the current identity credential information includes the remaining validity period and credential status of the current identity credential. If the remaining valid duration is less than a preset time threshold, or the voucher status is invalid, then the voucher update process for the corresponding target online store is triggered. If the credential status is valid, a probe request is sent to the platform server corresponding to the target online store. Based on the request response result returned by the platform server corresponding to the probe request, the credential status is updated.
3. The method for automatically collecting and storing online store bills according to claim 2, characterized in that, The step of updating the credential status based on the request response result returned by the platform server corresponding to the activation request includes: If the request response is a credential expiration indication, then the credential status is switched to an expiration status; If the request response indicates that the credential is valid, then the credential status remains unchanged.
4. The method for automatically collecting and storing online store bills according to claim 2, characterized in that, The process for triggering the corresponding target online store's certificate update includes: Retrieve the pre-stored login information of the target online store; Based on the pre-stored login information, a merchant login request is initiated to the target online store; If no verification input prompt appears during the merchant login request process, the identity credential is extracted from the login response as the latest valid credential, the latest valid credential is replaced with the current identity credential of the corresponding target online store in the identity credential pool, and the corresponding credential status is marked as valid. If a verification prompt appears during the merchant login request process, the credential status will be marked as invalid.
5. The method for automatically collecting and storing online store bills according to claim 1, characterized in that, The process for triggering the corresponding target online store's certificate repair includes: Retrieve the pre-stored login information of the target online store; Based on the pre-stored login information, a merchant login request is initiated to the target online store; If no verification prompt appears during the merchant login request process, the identity credential is extracted from the login response as the repaired current identity credential. If a verification prompt appears during the merchant login request process, the verification information will be submitted after receiving manually entered verification information to continue executing the merchant login request, and the identity credential extracted from the login response will be used as the repaired current identity credential. Replace the repaired current identity credential with the current identity credential of the corresponding target online store in the identity credential pool, and mark the corresponding credential status as valid.
6. The method for automatically collecting and storing online store bills according to claim 1, characterized in that, The step of calling the billing data interface based on the repaired current identity credentials includes: The interface for obtaining the billing data is based on a preset interface call protocol specification; According to the interface call protocol specification, an interface call request is generated based on the repaired current identity credentials; Based on the interface call request, the billing data interface is invoked.
7. The method for automatically collecting and storing online store bills according to claim 6, characterized in that, Also includes: If a call failure message is received from the interface, the current number of call failures for the billing data interface is updated. If the current number of failed calls is less than a preset number, then after a preset time interval, the process jumps to the step of generating an interface call request based on the repaired current identity credentials in accordance with the interface call protocol specification. If the current number of failed calls is equal to or greater than the preset number, the last failed call time is recorded, and the store status of the corresponding target online store is marked as an abnormal interface call status.
8. The method for automatically collecting and storing online store bills according to claim 1, characterized in that, After parsing the bill data and performing structured processing to obtain structured data and storing it in the target database, the process includes: Obtain the store status of each of the target online stores; If the store status is an interface call error status, then obtain the store identifier, pre-stored login information, and last call failure time of the corresponding target online store; Based on the store identifier, the pre-stored login information, and the last failed call time, store exception information is generated and pushed to the store monitoring system.
9. An automatic bill collection and warehousing device for online stores, characterized in that, include: The credential acquisition module is used to obtain the current identity credentials and credential status of each target online store in response to the periodic settlement task instructions. The interface call module is used to call the billing data interface of the corresponding target online store based on the current identity credential if the credential status is valid. The credential repair module is used to trigger the credential repair process of the corresponding target online store if the credential status is invalid, and to call the bill data interface based on the repaired current identity credential. The bill processing module is used to parse the bill data returned by the bill data interface, perform structured processing on the bill data, obtain structured data, and store it in the target database.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed, it implements the method for automatically collecting and storing online store bills as described in any one of claims 1 to 8.