Electronic receipt printing method, system and equipment and storage medium
By confirming that the transaction business is completed and the application task is cached after the transaction is completed, and the electronic return is actively obtained when the business server is idle, the problem of excessive utilization of business server resources caused by centralized processing of electronic return is solved, and the user experience and system stability are improved.
Patent Information
- Application Number
- CN202510343143.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-21
- Publication Date
- 2025-06-13
AI Technical Summary
In the financial field, the centralized processing of electronic receipts leads to excessive utilization of business server resources, which may trigger system protection mechanisms and business continuity risks.
By confirming that the transaction business is completed, the electronic reply application task is generated and cached, and when the service server is in an idle state, it actively obtains the electronic reply from the signature server and sends it to the client.
It effectively reduces the resource capacities and impacts of users' large-scale application for electronic orders on weekdays on business servers, reduces user waiting time, and improves user experience.
Smart Images

Figure CN120146981A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of financial services, and in particular relates to an electronic receipt printing method, system, device and storage medium. Background Art
[0002] In the current financial field, some electronic receipts with signatures and seals need to be processed by users at the counter. Some customers did not apply for electronic signature receipts immediately after completing the transaction, but instead made up for them in subsequent financial reconciliation, audit and other scenarios. Such demand is mostly concentrated in business peak periods such as the end of the month and the end of the quarter, forming a superimposed effect with daily counter business, resulting in longer window queues.
[0003] This will cause the electronic receipt processing business to be too concentrated. A large number of electronic receipt processing tasks may also cause the resources of the business server to be squeezed, affecting the normal processing of other businesses. When the number of reissue requests in a single day exceeds the preset load threshold of the signature server, the system protection mechanism may be triggered to cause service interruption, posing a risk to business continuity. Summary of the invention
[0004] In view of the above-mentioned deficiencies in the prior art, the present invention provides an electronic receipt printing method, system, device and storage medium to solve the above-mentioned technical problems.
[0005] In a first aspect, the present invention provides an electronic receipt printing method, comprising: Confirming that the transaction business is completed and obtaining the transaction data generated by the transaction business; Generate an electronic receipt application task according to the transaction data, and cache the task; Confirm that the business server is in an idle state, and execute the task to actively obtain the electronic receipt from the signature server; The electronic receipt pre-acquired by the business server is sent to the corresponding client.
[0006] In an optional implementation, the method for confirming the completion of a transaction includes: Generate business codes for transaction business; Confirming that the transaction business is divided into multiple sub-businesses, generating a sequence code for the sub-businesses according to the execution order of the sub-businesses, wherein the sequence code is a combination array of the total number of sub-businesses and the execution order ranking; Use business codes and sequence codes to mark corresponding sub-businesses; Generate a status mark for each sub-business using a status mark system; Filter out the business codes and sequence codes of multiple sub-businesses whose status is marked as completed; Classify the sequence codes of multiple sub-services with the same service code into the same data group; Analyze the total number of sub-services and the execution order ranking of the sequence codes in the data group. If the number of sequence codes in the data group is equal to the total number of sub-services and the arrangement order of the execution order ranking is a natural number, it is determined that the transaction service corresponding to the corresponding service code has been completed.
[0007] In an alternative embodiment, obtaining the transaction data generated by the transaction service includes: Retrieve service record data from the service server according to the service code of the transaction service; Extract transaction data from the service record data by using keyword extraction technology, where the transaction data includes the transaction parties, transaction amount, and transaction time.
[0008] In an alternative embodiment, when it is confirmed that the service server is in an idle state, execute the task to actively obtain an electronic receipt from the signature server, including: Obtain the network resource utilization rate of the local network of the service server; If it is confirmed that the network resource utilization rate does not reach the set utilization threshold, then execute the task, and the execution method of the task includes: Encrypt the transaction data associated with the task and the corresponding service code into ciphertext data; Send the ciphertext data to the signature server; Receive the ciphertext file returned by the signature server and decrypt the ciphertext file into a plaintext file, where the plaintext file is an electronic receipt named after the service code.
[0009] In an alternative embodiment, the method further includes: Obtain user behavior data, where the user behavior data includes user information and historical service record data, and the historical service record data includes the service type and whether an electronic receipt has been applied for; Quantitatively map each piece of user behavior data into a feature array; Perform clustering processing on the feature array and analyze the corresponding relationship between user information, service type, and whether an electronic receipt has been applied for according to the clustering result; Analyze the user information and service type corresponding to the task, and predict the probability of the behavior of applying for an electronic receipt according to the user information and service type corresponding to the task and the corresponding relationship; Generate the priority level of the corresponding task according to the pre-set user information priority and the probability; Execute the cached tasks in sequence according to the priority level.
[0010] In an alternative embodiment, performing clustering processing on the feature array and analyzing the corresponding relationship between user information, service type, and whether an electronic receipt has been applied for includes: Get the user attributes of the user information and replace the user information in the feature array with the user attributes; Encode the user attributes and business types in the feature array, and use whether to apply for an electronic receipt as the clustering target latent variable to obtain a preprocessing array; Combine the elbow rule and silhouette coefficient double verification method to determine the K value of clustering; Using a K-means algorithm to process the plurality of preprocessed arrays based on the K value to obtain a plurality of clusters; According to the clustering target latent variable of the feature array in each cluster, the probability of applying for an electronic receipt in each cluster is calculated; The user attributes and business types of each cluster are solidified into a corresponding relationship with the corresponding probability.
[0011] In an optional implementation, sending the electronic receipt pre-acquired by the business server to the corresponding client includes: Confirm that the storage resource occupancy rate of the business server reaches the set storage resource occupancy rate threshold, filter out the electronic receipts whose storage time reaches the set time threshold, and actively push the filtered electronic receipts to the corresponding user terminals, and transfer the pushed electronic receipts from the business server to the cold data storage; Or, based on the received user request, the corresponding electronic receipt stored in the business server is sent to the client that initiated the user request.
[0012] In a second aspect, the present invention provides an electronic receipt printing system, comprising: A data acquisition module is used to confirm the completion of the transaction and obtain the transaction data generated by the transaction; A task generation module, used to generate an electronic receipt application task according to the transaction data, and cache the task; A task execution module, used to confirm that the business server is in an idle state, and execute the task to actively obtain an electronic receipt from the signature server; The file sending module is used to send the electronic receipt pre-acquired by the business server to the corresponding client.
[0013] In a third aspect, a device is provided, comprising: A memory, used for storing an electronic receipt printing program; A processor is used to implement the steps of the electronic receipt printing method provided in the first aspect when executing the electronic receipt printing program.
[0014] In a fourth aspect, a computer-readable storage medium is provided, on which an electronic receipt printing program is stored. When the electronic receipt printing program is executed by a processor, the steps of the electronic receipt printing method provided in the first aspect are implemented.
[0015] The beneficial effects of the present invention are as follows. The electronic receipt printing method, system, device and storage medium provided by the present invention track the progress of transaction services. Once it is confirmed that the progress of the transaction service is completed, the generated transaction data is extracted, and an electronic receipt application task is generated using the transaction data. In this way, the preparatory work for the pre-application of electronic receipts for global transaction services is realized. The generated tasks are cached and waiting for the business server to execute the cached tasks when it is idle, that is, the business server actively obtains the electronic receipts in the idle state, rather than passively obtaining the electronic receipts based on user requests, effectively reducing the resource occupation and impact on the business server caused by users applying for a large number of electronic receipts on weekdays. When receiving a user request, the business server directly feeds back the stored electronic receipts to the user terminal, reducing the user waiting time and improving the user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for the description of the embodiments or the prior art. Obviously, for those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.
[0017] Figure 1 It is a schematic flowchart of the method according to an embodiment of the present invention.
[0018] Figure 2 It is a schematic flowchart of executing the electronic receipt application task of the method according to an embodiment of the present invention.
[0019] Figure 3 It is a flowchart of electronic receipt printing of the method according to an embodiment of the present invention.
[0020] Figure 4 It is a schematic block diagram of the system according to an embodiment of the present invention.
[0021] Figure 5 It is a schematic structural diagram of a device provided by an embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0022] In order to enable those skilled in the art to better understand the technical solutions in the present invention, the following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.
[0023] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the technical field to which this invention belongs. The terms used in the specification of this invention are for the purpose of describing specific embodiments only and are not intended to limit the invention.
[0024] The following explains the key terms that appear in this invention.
[0025] The K-means algorithm is a classical unsupervised learning algorithm used to solve clustering problems. The core objective of the K-means algorithm is to partition a given data set into K different clusters such that the similarity between data points within the same cluster is as high as possible, while the similarity between data points in different clusters is as low as possible. Here, similarity is usually measured using the Euclidean distance, but other distance metrics such as the Manhattan distance can also be selected according to specific problems.
[0026] The electronic receipt printing method provided by the embodiments of this invention is executed by a computer device. Correspondingly, the electronic receipt printing system runs in the computer device.
[0027] Figure 1 It is a schematic flowchart of the method of an embodiment of this invention. Among them, Figure 1 The execution subject is an electronic receipt printing system. According to different requirements, the order of steps in this flowchart can be changed and some are omitted.
[0028] As Figure 1 shown, the method includes: S1. Confirm that the transaction business is completed and obtain the transaction data generated by the transaction business.
[0029] S2. Generate an electronic receipt application task according to the transaction data and cache the task.
[0030] S3. Confirm that the business server is in an idle state and execute the task to actively obtain the electronic receipt from the signature server.
[0031] S4. Send the electronic receipt pre-obtained by the business server to the corresponding client.
[0032] In an embodiment of this invention, based on step S1, the following will give a possible embodiment to non-restrictively elaborate on its specific implementation.
[0033] S101. Confirm that the transaction business is completed.
[0034] 1. Generate a business code for the transaction business.
[0035] Business type differentiation: According to different types of transaction businesses, such as payment transactions, transfer transactions, order transactions, etc., a specific prefix is assigned to each type of business. For example, the prefix for payment transactions is set as "PAY", and the prefix for transfer transactions is "TRF".
[0036] Timestamp integration: To ensure the uniqueness and traceability of business codes, the timestamp information of the transaction occurrence is integrated into the code. The timestamp is accurate to the millisecond level. For example, the combination of the year, month, day, hour, minute, second, and millisecond of the transaction occurrence is used, such as "20250226143015001".
[0037] Random number addition: To further enhance the uniqueness of business codes and avoid code conflicts caused by the same timestamp, a random number of a certain length is added to the code. The random number is generated using the system's random number generator, and the length is set according to actual needs, such as a 4-digit random number.
[0038] Assume that currently there is a payment transaction with a timestamp of "20250226143015001" and a random number of "1234", then the generated business code is "PAY202502261430150011234".
[0039] 2. If it is confirmed that the transaction business is split into multiple sub - businesses, then a sequence code is generated for the sub - businesses according to the execution order of the sub - businesses. The sequence code is an array combination of the total number of sub - businesses and the execution order ranking.
[0040] The system determines whether a transaction business needs to be split into multiple sub - businesses according to pre - set business rules. For example, for a complex order transaction, it may be split into multiple sub - businesses according to factors such as the types of goods and the shipping location, such as the shipping sub - business of product A and the shipping sub - business of product B.
[0041] By analyzing the relevant data in the transaction business, the division of sub - businesses is determined. For example, in a payment transaction, if there are multiple payees involved, the payment business may be split into multiple sub - businesses, with each sub - business corresponding to one payee.
[0042] After determining that the transaction business is split into multiple sub - businesses, the system counts the total number of sub - businesses. For example, if an order transaction is split into 3 sub - businesses, then the total number of sub - businesses is 3.
[0043] According to the execution order of the sub - businesses, a ranking is assigned to each sub - business. For example, if the execution order of the sub - businesses is the shipping of product A, the shipping of product B, and the shipping of product C, then the execution order ranking of the shipping sub - business of product A is 1, the execution order ranking of the shipping sub - business of product B is 2, and the execution order ranking of the shipping sub - business of product C is 3.
[0044] Combine the total number of sub - services and the execution order ranking into an array as the sequence code. For example, for the 3 sub - services of the above - mentioned order transaction, the sequence code of the sub - service of delivering commodity A is [3,1], the sequence code of the sub - service of delivering commodity B is [3,2], and the sequence code of the sub - service of delivering commodity C is [3,3].
[0045] 3. Mark the corresponding sub - services with the business code and the sequence code.
[0046] Design a database table to store the relevant information of sub - services, including fields such as business code, sequence code, sub - service description, etc. For example, create a table named "sub_business" with fields such as "business_code" (business code), "sequence_code" (sequence code), "sub_business_desc" (sub - service description).
[0047] Associate and store the generated business code and sequence code into the records of the corresponding sub - services. For example, for the sub - service of delivering commodity A, store the business code "PAY202502261430150011234" and the sequence code [3,1] into the corresponding record in the "sub_business" table.
[0048] 4. Generate status marks for each sub - service using the status marking system.
[0049] Define the possible status types of sub - services, such as "not started", "in progress", "completed", "failed", etc.
[0050] Formulate the rules for sub - service status conversion. For example, the initial status of a sub - service is "not started", when the sub - service starts to execute, the status is converted to "in progress"; when the sub - service is executed successfully without exceptions, the status is converted to "completed"; when an error occurs during the execution of the sub - service, the status is converted to "failed".
[0051] The system monitors the execution status of sub - services in real - time and updates their status marks according to the execution status of sub - services. For example, by monitoring the logistics information of the sub - service of commodity delivery, when the logistics information shows that the commodity has been sent, update the status mark of this sub - service to "completed".
[0052] 5. Filter out the business codes and sequence codes of multiple sub - services with status marks of "completed".
[0053] Use an SQL query statement to filter out the business codes and sequence codes of sub - services with status marks of "completed" from the "sub_business" table.
[0054] 6. Divide the sequence codes of multiple sub - services with the same business code into the same data group.
[0055] Traverse the business codes and sequence codes of the selected sub - services, and divide the sequence codes of the sub - services with the same business code into the same data group. Use a dictionary to achieve grouping, where the key of the dictionary is the business code and the value is the list of sequence codes corresponding to that business code.
[0056] 7. Analyze the total number of sub - services and the execution order ranking of the sequence codes in the data group. If the number of sequence codes in the data group is equal to the total number of sub - services, and the arrangement order of the execution order ranking is a natural number, it is determined that the transaction service corresponding to the corresponding business code is completed.
[0057] For the sequence codes in each data group, extract the total number of sub - services and the execution order ranking among them. For example, for the sequence code [3, 1], extract that the total number of sub - services is 3 and the execution order ranking is 1.
[0058] Check whether the number of sequence codes in the data group is equal to the total number of sub - services, and whether the arrangement order of the execution order ranking is a natural number. For example, for the business code "PAY202502261430150011234", the sequence codes in its data group are [[3, 1], [3, 2], [3, 3]], the number of sequence codes is 3, which is equal to the total number of sub - services 3, and the execution order rankings are 1, 2, 3, which is a natural number arrangement. Therefore, it is determined that the transaction service corresponding to this business code is completed.
[0059] S102. Obtain the transaction data generated by the transaction service.
[0060] 1. Send a query request.
[0061] Add the verified business code as a query parameter to the request. For an HTTP request, send the business code as part of the JSON data to the server.
[0062] data = {'business_code': business_code}.
[0063] 2. Use keyword extraction technology to extract transaction data from the business record data, where the transaction data includes the trading party, transaction amount, and transaction time.
[0064] Segment the cleaned text data, splitting it into individual words or phrases. For Chinese text, use the jieba library for segmentation; for English text, use the tokenizer of the nltk library.
[0065] In an embodiment of the present invention, based on step S3, the following will give a possible embodiment to non - restrictively elaborate on its specific implementation plan.
[0066] S301. Obtain the network resource utilization rate of the local network of the business server.
[0067] Obtain the bandwidth utilization rate, packet loss rate, and network latency.
[0068] Set a reasonable collection period, such as collecting network resource utilization data every 1 minute or 5 minutes. The regular collection of data can be achieved using scripts or the scheduled task function of monitoring software.
[0069] S302. If it is confirmed that the network resource utilization rate has not reached the set utilization threshold, then execute the task.
[0070] 1. Set the utilization threshold.
[0071] According to the characteristics and requirements of the business, set a reasonable network resource utilization threshold. For example, for real-time trading services with high requirements for network latency, the bandwidth utilization threshold can be set to 70%, the packet loss rate threshold can be set to 1%, and the network latency threshold can be set to 50 milliseconds.
[0072] Dynamically adjust the network resource utilization threshold according to the peak and trough periods of the business. For example, during the peak period of the business, the bandwidth utilization threshold can be appropriately increased to make full use of network resources.
[0073] 2. Threshold comparison and judgment.
[0074] Read the latest network resource utilization data from the database.
[0075] Compare the read network resource utilization data with the set threshold. For example, compare whether the current bandwidth utilization rate exceeds the set bandwidth utilization threshold.
[0076] If the network resource utilization rate has not reached the set threshold, it is considered that the network resources are sufficient and the task can be executed; otherwise, wait for a period of time and then check again until the network resource utilization rate meets the conditions.
[0077] Please refer to Figure 2 , and the execution method of the task includes: Phase 1: The business server performs data preparation.
[0078] (1) Convert the transaction data into a standard JSON structure, including: {"trans_id": "20250226_88192", "amount": 15800.00, "participants": ["Company A","Organization B"],"contract_hash": "sha3-256:d5e2..."}. Perform BASE64 transcoding on the business code (e.g., ZGY2MzY4O...).
[0079] (2)Use the AES-256-GCM algorithm to encrypt the transaction data and dynamically generate a 256-bit session key: cipher = AES.new(key, AES.MODE_GCM); ciphertext, tag = cipher.encrypt_and_digest(data).
[0080] Use HMAC-SHA256 to generate a verification tag for the user code: hmac_tag = hmac.new(shared_key,biz_code, digestmod='sha256').digest().
[0081] Phase Two: Establish a two-way SSL channel between the business server and the signature server.
[0082] Attach transmission metadata: POST / signing / v3 HTTP / 1.1; X-Request-ID: SC20250226_88192; X-Biz-Code: ZGY2MzY4O; Content-Encryption: AES256-GCM.
[0083] Phase Three: The processing flow of the signature server.
[0084] (1)Data verification Decryption process: # Decrypt the business code: if hmac.new(shared_key, received_biz_code).digest() !=received_tag:raise IntegrityError; # Decrypt the transaction data: cipher = AES.new(session_key, AES.MODE_GCM, nonce=iv); plaintext = cipher.decrypt_and_verify(ciphertext, tag).
[0085] (2)Generate a digital signature Call the HSM hardware module to perform the signature operation: EC_KEY *key = ECDSA_load_key("secp521r1"); ECDSA_SIG *sig = ECDSA_do_sign(digest, digest_len, key).
[0086] (3)Generate a layout file Use the PDF signature engine to create a file that complies with the GB / T 38540 standard: %PDF-1.7; / Sig / DocTimeStamp; / Type / Sig; / Filter / Adobe.PPKLite; / SubFilter / ETSI.CAdES.detached.
[0087] Phase Four: The receipt is returned to the business server.
[0088] File name generation rule: filename = f"{base64url_encode(biz_code)}.sce" # Example: ZGY2MzY4O.sce. Append the transmission check code (CRC32 + the hash value of the last 1KB).
[0089] Security control measures: The transaction data encryption key is valid only once; the signature private key never leaves the HSM module.
[0090] Audit trail: Generate six-element logs: 2025-02-26 14:30:15 | SC20250226_88192 | Signer ID: CA03 | Timestamp sequence: TSA98273 | File size: 258KB | Hash value: 9d5f2a... The average processing time of this process in the actual system of the financial industry is <800ms (data from the ten-thousand-level TPS stress test), ensuring high efficiency and security through hierarchical encryption and hardware acceleration.
[0091] Based on the above embodiments, in order to further ensure the orderliness of the execution method of cached tasks, as an implementable method, the execution order of tasks is generated according to user behavior data and user priorities to ensure the priority execution of some tasks when there is a task backlog.
[0092] 1. Obtain user behavior data, where the user behavior data includes user information and historical business record data, and the historical business record data includes the business type and whether an electronic receipt is applied for.
[0093] Obtain user information from the user registration system, including the user's basic information such as name, age, gender, contact information, registration time, etc. Some information may require user authorization to obtain to ensure that data collection complies with relevant regulations.
[0094] Extract historical business record data from the business database, which records all business operations of the user. The business types may cover payments, transfers, order transactions, etc., and also record whether the user has applied for an electronic receipt.
[0095] Perform data cleaning on the obtained user behavior data: Check whether there are missing values in the user behavior data. For missing fields in the user information, they can be filled with default values (such as filling -1 for missing age) or estimated and filled according to other relevant information. For missing key information in the historical business record data, such as missing business type, consider deleting that record.
[0096] Detect outliers in the data. For example, if the age appears as a negative number or a very large value, it can be regarded as an outlier and corrected or deleted.
[0097] Ensure data consistency, such as the consistency of the user ID in different data sources, to avoid analysis errors caused by data inconsistency.
[0098] 2. Quantitatively map each piece of user behavior data into a feature array.
[0099] For categorical data in the user information, such as enterprise type, one - hot encoding can be used to convert it into a numerical vector. For business types, one - hot encoding is also used, and each business type corresponds to a binary vector.
[0100] For numerical data in the user information, such as enterprise scale, service years, etc., use a standardization method (such as Z - score standardization) to convert it into data with a mean of 0 and a standard deviation of 1 to eliminate the influence of the dimension between different features.
[0101] Combine the quantified user information and historical business record data into a feature array, and each array element corresponds to a feature. For example, if the user information has 5 features and the historical business record has 3 features, then the length of the feature array is 8.
[0102] 3. Perform clustering processing on the said feature array, and analyze the corresponding relationship between user information, business type, and whether an electronic receipt is applied for according to the clustering results.
[0103] 3.1 Obtain the user attributes of the user information, and replace the user information in the feature array with the user attributes.
[0104] By analyzing and mining user information, user attributes are extracted. For example, according to information such as transaction frequency, users are divided into different user groups, such as active users, stable users, etc.
[0105] Replace the original user information in the feature array with the extracted user attributes to reduce the feature dimension and improve the clustering efficiency.
[0106] 3.2 Encode the user attributes and business types in the feature array, and use whether to apply for an electronic receipt as the clustering target latent variable to obtain a preprocessing array.
[0107] Further encode the user attributes and business types, and use Label Encoding to convert different user attributes and business types into integer encodings.
[0108] Use whether to apply for an electronic receipt as the clustering target latent variable, and add it as a special feature to the feature array to form a preprocessing array.
[0109] 3.3 Combine the elbow method and the silhouette coefficient double-verification method to determine the K value of clustering.
[0110] The core idea of the elbow method is to calculate the sum of squared errors (SSE) of K-means clustering under different K values, and then plot the relationship curve between K value and SSE, and find the point where the slope of the curve suddenly becomes smaller. The K value corresponding to this point is the appropriate number of clusters.
[0111] The sum of squared errors measures the sum of the squares of the distances from each data point to the center of its belonging cluster. Its calculation formula is:
[0112] where K is the number of clusters, is the i-th cluster, is the cluster is the j-th data point in the cluster is the center of the i-th cluster.
[0113] After plotting the relationship curve between K value and SSE, it is necessary to find the point where the slope of the curve suddenly becomes smaller. The difference (i.e., the slope) of the SSE corresponding to two adjacent K values can be calculated. When the difference suddenly becomes smaller, the corresponding K value is the elbow point.
[0114] The silhouette coefficient is used to measure the tightness of each data point to its belonging cluster and the separation from other clusters. Its value range is [-1, 1], and the value closer to 1 indicates better clustering effect.
[0115] For each data point i, the formula for calculating its silhouette coefficient is as follows:
[0116] where is the average distance from data point i to other data points within its assigned cluster, is the average distance from data point i to the nearest data point outside its assigned cluster.
[0117] After plotting the relationship curve between the K value and the average silhouette coefficient, select the K value with the maximum average silhouette coefficient as the optimal number of clusters.
[0118] Combining the K value determined by the elbow method and the silhouette coefficient, select a K value that satisfies both the elbow method and has a relatively high average silhouette coefficient as the final number of clustering clusters. The selection can be made through the following method: If the K values determined by the elbow method and the silhouette coefficient are the same, directly use this K value as the final result.
[0119] If the K values determined by the two methods are different, you can select the K value with a relatively high average silhouette coefficient and close to the elbow point. For example: # Double verification to determine the final K value if elbow_k == best_silhouette_k: final_k = elbow_k else: # The selection strategy can be adjusted according to the actual situation if silhouette_scores[elbow_index - 1]>0.5: final_k = elbow_k else: final_k = best_silhouette_k print(f"The final determined K value: {final_k}").
[0120] 3.4 Use the K-means algorithm to process multiple preprocessed arrays based on the K value to obtain multiple clusters.
[0121] Initialize the cluster centers: Randomly select K data points from the preprocessed array as the initial cluster centers.
[0122] Iterative update: Assign data points to the nearest cluster center, calculate the distances from each data point to the K cluster centers, and assign it to the nearest cluster.
[0123] Update the cluster centers, calculate the mean of all data points within each cluster, and use this mean as the new cluster center.
[0124] Repeat the above two steps until the cluster centers no longer change significantly or reach the maximum number of iterations.
[0125] 3.5 Calculate the probability of the application e-receipt within each cluster based on the clustering target latent variable of the feature array within each cluster.
[0126] Count the number of data points of the application e-receipt (the clustering target latent variable is 1) within each cluster and the total number of data points within the cluster.
[0127] Calculate the probability of the application e-receipt, that is, the number of data points of the application e-receipt divided by the total number of data points within the cluster.
[0128] 3.6 Solidify the user attributes and business types of each cluster and the corresponding probabilities into a corresponding relationship.
[0129] Store the user attributes, business types of each cluster, and the calculated probability of the application e-receipt in a data structure, such as a dictionary or a database table, to form a corresponding relationship.
[0130] 4. Parse the user information and business type corresponding to the task, and predict the probability of the occurrence of the application e-receipt behavior based on the user information and business type corresponding to the task and the corresponding relationship.
[0131] Information parsing: Extract the user information and business type from the task, and perform the same quantization and encoding processing as before.
[0132] Probability prediction: Based on the processed user information and business type, search for the matching user attributes and business types in the corresponding relationship, and obtain the corresponding probability of the application e-receipt. If there is no completely matching record, the nearest neighbor matching or interpolation method can be used for probability prediction.
[0133] 5. Generate the priority level of the corresponding task according to the pre-set user information priority and the probability.
[0134] Pre-define the priority of the user information. For example, the priority of a premium member user is higher than that of a regular member user.
[0135] Combine the user information priority and the predicted probability of the application e-receipt, and design a priority calculation function. For example, the user information priority and the probability can be weighted and summed to obtain the priority score of the task.
[0136] According to the priority score, divide the tasks into different priority levels, such as high, medium, and low levels.
[0137] 6. Execute the cached tasks in sequence according to the priority level.
[0138] Sort the cached tasks according to the priority level of the tasks, and the tasks with higher priority are ranked in the front.
[0139] Execute tasks in the sorted order. When executing tasks, if the number of cached tasks reaches the set quantity threshold, execute high-priority tasks, which can ensure the priority application of e-receipts for high-quality users. And when sorting tasks, the probability of whether a user applies for an e-receipt is considered, so tasks with a lower probability will be ranked later. Even if these tasks fail to be executed, they will not be perceived by the user. Therefore, when there are too many tasks, low-priority tasks can be abandoned during the pre-generation stage of e-receipts.
[0140] In an embodiment of the present invention, based on step S5, a possible embodiment will be given below to non-restrictively elaborate on its specific implementation.
[0141] 1. Actively push e-receipts.
[0142] Use the system's built-in monitoring tool or a third-party monitoring software to monitor the usage of storage resources of the business server in real time. For example, in the Linux system, the df -h command can be used to view the disk usage, or the iostat tool can be used to monitor the disk I / O status. For the Windows system, the disk usage can be viewed through "Disk Management" in "Computer Management".
[0143] Use a monitoring system (such as Zabbix, Prometheus, etc.) to monitor and record the occupancy rate of storage resources in real time. These monitoring systems can regularly collect the usage data of storage resources and store them in a database for subsequent analysis and query.
[0144] Set a reasonable threshold for the occupancy rate of storage resources according to the hardware configuration and business requirements of the business server. For example, if the total disk capacity of the business server is 1TB, the threshold for the occupancy rate of storage resources can be set to 80%, that is, when the disk usage reaches 800GB, subsequent operations will be triggered.
[0145] The monitoring system will regularly compare the current occupancy rate of storage resources with the set threshold. If the current occupancy rate reaches or exceeds the threshold, the e-receipt screening operation will be triggered.
[0146] Set a storage time threshold for e-receipts according to business requirements and data retention policies. For example, it is stipulated that e-receipts can be stored on the business server for at most 3 months, and e-receipts exceeding 3 months will be screened out for active push.
[0147] The storage time of each e-receipt is recorded in the database of the business server. Through SQL query statements, e-receipt records with a storage time exceeding the set threshold are screened out. For example: SELECT * FROM electronic_receipts WHERE storage_time<DATE_SUB(NOW(),INTERVAL 3 MONTH); For electronic receipt files stored in the file system, they can be filtered by the creation time or modification time of the file. In Python, the os.path.getctime() or os.path.getmtime() functions can be used to obtain the creation time and modification time of the file.
[0148] Obtain the user terminal information corresponding to the filtered electronic receipts from the business database, such as the user's mobile phone number, email address, push token, etc. Ensure that the information obtained is accurate so that the electronic receipts can be successfully pushed to the user.
[0149] Validate the effectiveness of the obtained user terminal information. For example, check whether the mobile phone number conforms to the format requirements and whether the email address can receive emails normally.
[0150] If the user's terminal information includes a mobile phone number, the download link or summary information of the electronic receipt can be sent to the user in the form of a text message using a text message gateway. When sending text messages, relevant text message sending specifications need to be followed to ensure that the text message content is concise and clear and includes necessary security prompt information.
[0151] For users who include an email address, the electronic receipt can be sent to the user as an attachment using the SMTP protocol. Before sending the email, the electronic receipt file needs to be encrypted to ensure data security. At the same time, the email content should include a clear subject and body, informing the user of relevant information about the electronic receipt.
[0152] If the user is using a mobile application, the notification of the electronic receipt can be pushed to the user through the application's push service (such as Firebase Cloud Messaging, Huawei Push Service, etc.). The push notification can include a brief information and view link of the electronic receipt to guide the user to view the electronic receipt within the application.
[0153] Before transferring the electronic receipt from the business server to the cold data storage, it is necessary to confirm whether the electronic receipt has been successfully pushed to the user. It can be confirmed through the push result information returned by the push system, such as the receipt of successful text message sending, notification of successful email sending, etc. Check the data integrity of the pushed electronic receipt to ensure that the data is not lost or damaged during the push process.
[0154] For the electronic receipt records stored in the database, the database migration tool (such as the mysqldump command in MySQL) can be used to export the records to the database of the cold data storage.
[0155] For the electronic receipt files stored in the file system, the file copying tool (such as the cp command in the Linux system) can be used to copy the files to the specified directory of the cold data storage. After the copying is completed, the original files on the business server are deleted to free up storage resources.
[0156] 2. Passively send electronic receipts.
[0157] Design a unified API interface to receive users' electronic receipt requests. This interface should support the HTTP / HTTPS protocol to ensure the security of data transmission.
[0158] The request parameters of the interface should include necessary information, such as user identification, transaction ID, etc., so as to accurately locate the electronic receipts required by the user.
[0159] The business server listens on the specified port to receive the electronic receipt requests sent by users. Use a web server (such as Nginx, Apache, etc.) to handle user requests.
[0160] Perform a legality verification on the received requests, including the format of the requests, the integrity and validity of the request parameters, etc. For example, check whether the user identification exists in the system and whether the transaction ID conforms to the format requirements.
[0161] According to the transaction ID or other key information in the user request, search for the corresponding electronic receipt records in the database of the business server. Use SQL query statements for fast query, for example: SELECT * FROM electronic_receipts WHERE transaction_id = 'xxxxxx'; If the electronic receipt is stored in the form of a file, according to the file path information in the database record, search for the corresponding electronic receipt file in the file system of the business server. Ensure that the storage path of the file is accurate to avoid file search failure due to incorrect paths.
[0162] Before sending the electronic receipt to the user, encrypt the electronic receipt data. Symmetric encryption algorithms (such as AES) or asymmetric encryption algorithms (such as RSA) can be used to encrypt the data to ensure the security of the data during transmission.
[0163] Select an appropriate transmission method according to the type of the client that initiates the user request. If the client is a web browser, the encrypted e-receipt data can be returned to the client in the form of a response using the HTTP / HTTPS protocol. If the client is a mobile application, the data can be sent to the application using the API interface.
[0164] During the data transmission process, set a reasonable timeout period and retry mechanism to ensure that the data can be successfully sent to the client. Meanwhile, record the log information of the data transmission for subsequent monitoring and troubleshooting.
[0165] After the client receives the encrypted e-receipt data, use the corresponding decryption key to decrypt the data. Ensure that the decryption algorithm and key of the client are consistent with the encryption algorithm and key of the server side.
[0166] Please refer to Figure 3 , the overall printing process of the e-receipt printing method based on this application includes: The background automatically starts a scheduled task to periodically query the transaction flow documents that need to be stamped. After finding the documents, use multi-threading to call the Dianju signature service for stamping. Then, after returning the path of the stamped document, download it to the core system's local server and wait for the customer to print it at the front end. The front-end operation means that the customer prints e-receipts of different business types through each business module. First, query the pdf file that has been stamped by the background task. If there is a returned path, complete the printing. If not, call the Dianju signature service in real time to complete the printing.
[0167] In a specific embodiment, the full process of e-receipt printing includes: I. Confirmation of the completion of the transaction business Business code generation: The system generates a unique identification code for each transaction, in the format of: 4-digit institution code + 8-digit date (such as 20250226) + 6-digit serial number. For example: BANK20250226000123 Sub-task splitting and tracking: When a transaction involves multiple sub-businesses (such as cross-border remittance that requires steps such as foreign exchange purchase, settlement, and posting), the system automatically generates a sequential marker code. The sequential code is composed of "total number of sub-tasks - current serial number". For example, if there are a total of 5 sub-tasks, the 3rd sub-task is marked as 5-3.
[0168] Completion status verification: The system collects the status markers of all sub-tasks in real time. When it detects that the sequential codes under a certain business code meet two conditions, it determines that the transaction is completed: the number of sequential codes is equal to the total number of sub-tasks; all serial numbers are arranged in the natural number order of 1, 2, 3...
[0169] Example verification: If the sequence code set under business code BANK20250226000123 is 5-1, 5-2, 5-3, 5-4, 5-5, it is determined to be completed.
[0170] II. Transaction Data Extraction Data source acquisition: Retrieve the original records from the business server according to the business code, including: transaction logs, system operation records, and associated contract texts.
[0171] Intelligent information extraction: Use a customized BERT model for entity recognition: # Input example log text: "2025-02-26 14:30 User A (account ending with 8888) remitted CNY15,800.00 to Company B (SWIFT: ABCDHKHH)"; # Output structured data: {"Payer": "User A (account ending with 8888)", "Payee": "Company B (SWIFT: ABCDHKHH)", "Amount": "CNY15,800.00", "Time": "2025-02-26 14:30"}.
[0172] Special field verification: Double-check the amount value (compare the log record with the database).
[0173] III. Intelligent Task Scheduling User behavior analysis: Construct feature vectors including: user basic information (age, account level), historical business type distribution, and e-receipt application frequency.
[0174] Example feature vector: [35, 'VIP3', {'Transfer': 60%, 'Wealth Management': 30%}, 0.85] represents a 35-year-old VIP3 user, with 60% of transfer business and a historical receipt application rate of 85%.
[0175] Dynamic priority calculation: Divide users into 5 groups through an improved K-means algorithm. An example of the application probability calculation for each group is shown in Table 1: Table 1
[0176] Task execution sorting: Priority formula: Priority score = base weight × predicted probability + emergency coefficient The system automatically sorts the tasks to be processed as: [VIP5 user] [Cross-border remittance] score 9.8; [Corporate account] [Salary payment] score 8.7; [Individual user] [Daily transfer] score 6.5.
[0177] IV. Secure Signature Processing Adopt a hierarchical encryption strategy: Session layer: RSA-3072 encrypts the transmission key; Data layer: AES-256-GCM encrypts transaction data; Verification layer: HMAC-SHA256 protects the service code.
[0178] Example of the encrypted data packet structure: [RSA encryption header][AES-IV][Ciphertext data][HMAC signature].
[0179] Digital signature generation: The signature server uses a Hardware Security Module (HSM) to perform the signature operation: triple hash (SHA3-256) on the data digest; generate a digital signature using the elliptic curve secp521r1 algorithm; synchronously apply for a timestamp (with a precision of up to milliseconds).
[0180] V. Intelligent Storage Management Hierarchical storage strategy: Hot data layer (SSD storage), characterized by saving e-receipts generated within 30 days, supporting millisecond-level retrieval response. Cold data layer (tape library), characterized by storing historical receipts over 30 days, using LTO-9 tape technology, with a 60% reduction in storage costs.
[0181] Active push mechanism: Trigger automatic push twice a day (09:00 / 15:00).
[0182] Example of push rules: if user.last login time > 7 days and file.generation time > 3 days: execute dual-channel push via SMS + email.
[0183] Exception handling process: Transmission failure retry mechanism: First failure: Retry after 5 minutes. Second failure: Transfer to the dead letter queue for manual processing.
[0184] Integrity verification: The receiving end verifies the file hash value (SHA-256), and abnormal files automatically trigger the regeneration process.
[0185] The technical advantages of this embodiment include: By verifying the natural number arrangement of the sequence code, it avoids misjudgment problems caused by network latency in traditional solutions, and the accuracy rate is increased to 99.99%. The task priority system based on user behavior prediction shortens the processing time of high-value services by 40%. Adopt hierarchical encryption and hardware-level key protection, and pass the third-level information security protection certification of the financial industry. The intelligent hierarchical storage strategy reduces the overall storage cost by 58%, while ensuring that the response time for more than 95% of query requirements is <500ms.
[0186] This embodiment has been actually deployed in a large domestic commercial bank, with an average daily processing volume of 230,000 electronic receipts, and the system availability reaching 99.95%. In the stress test, the maximum load capacity of a single node reached 1,500 receipts per minute, meeting the requirements of financial-level services.
[0187] In some embodiments, the electronic receipt printing system includes multiple functional modules composed of computer program segments. The computer programs of each program segment in the electronic receipt printing system are stored in the memory of a computer device and executed by at least one processor to perform the functions of electronic receipt printing (see details in Figure 1 the description).
[0188] In this embodiment, the electronic receipt printing system is divided into multiple functional modules according to the functions it performs, as Figure 4 shown. The functional modules of the system include: a data acquisition module, a task generation module, a task execution module, a file storage module, and a file sending module. The module referred to in the present invention means a series of computer program segments that can be executed by at least one processor and can complete fixed functions, and are stored in the memory. In this embodiment, the functions of each module will be described in detail in subsequent embodiments.
[0189] The data acquisition module is used to confirm the completion of a transaction service and acquire the transaction data generated by the transaction service; The task generation module is used to generate an electronic receipt application task according to the transaction data and cache the task; The task execution module is used to confirm that the business server is in an idle state and execute the task to actively obtain an electronic receipt from the signature server; The file storage module is used to store the electronic receipt in the business server; The file sending module is used to send the electronic receipt pre-acquired by the business server to the corresponding client.
[0190] Figure 5 The electronic receipt printing method provided by the embodiments of this application is applied to a device. Those skilled in the art understand that the device structure involved in the embodiments of the present invention does not constitute a limitation on the device. The device includes more or fewer components than shown in the figure, or combines certain components, or has different component arrangements. In the embodiments of the present invention, the device includes, but is not limited to, a laptop computer, a desktop computer, a workbench, a personal digital assistant, a server, a blade server, a mainframe computer, and other suitable computers. The device also represents various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the embodiments of this application described herein and / or claimed.
[0191] Among them, the device 500 includes: a processor 510, a memory 520, and a communication unit 530. These components communicate via one or more buses. Those skilled in the art understand that the structure of the server shown in the figure does not constitute a limitation on the present invention. It can be a bus structure, a star structure, and may also include more or fewer components than shown in the figure, or combine certain components, or have different component arrangements.
[0192] Among them, the memory 520 is used to store the execution instructions of the processor 510. The memory 520 is implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk, or optical disk. When the execution instructions in the memory 520 are executed by the processor 510, the device 500 can execute some or all of the steps in the above method embodiments.
[0193] The processor 510 is the control center of the storage device, connecting various parts of the entire electronic device through various interfaces and lines. By running or executing the software programs and / or modules stored in the memory 520, and by invoking the data stored in the memory, it executes various functions of the electronic device and / or processes data. The processor is composed of an integrated circuit (IC), for example, it can be composed of a single packaged IC, or composed of multiple packaged ICs with the same or different functions connected together. For example, the processor 510 only includes a central processing unit (CPU). In the embodiment of the present invention, the CPU can be a single arithmetic core or include multiple arithmetic cores.
[0194] The communication unit 530 is used to establish a communication channel, so that the storage device can communicate with other devices. It receives user data sent by other devices or sends user data to other devices.
[0195] The present invention also provides a computer storage medium. Among them, the computer storage medium can store a program, and when the program is executed, it can include some or all of the steps in the embodiments provided by the present invention. The storage medium can be a magnetic disk, an optical disk, a read-only memory (ROM), a random access memory (RAM), etc.
[0196] Although the present invention has been described in detail by reference to the accompanying drawings and in conjunction with the preferred embodiments, the present invention is not limited thereto. Without departing from the spirit and essence of the present invention, those of ordinary skill in the art can make various equivalent modifications or substitutions to the embodiments of the present invention, and these modifications or substitutions should all be within the scope of the present invention. / Any person skilled in the art within the technical scope disclosed by the present invention can easily conceive of changes or substitutions, which should all be covered within the protection scope of the present invention.
Claims
1. A method for printing an electronic receipt, characterized in that: include: Confirming that the transaction business is completed and obtaining the transaction data generated by the transaction business; Generate an electronic receipt application task according to the transaction data, and cache the task; Confirm that the business server is in an idle state, and execute the task to actively obtain the electronic receipt from the signature server; The electronic receipt pre-acquired by the business server is sent to the corresponding client.
2. The method according to claim 1, characterized in that Methods for confirming the completion of a transaction include: Generate business codes for transaction business; Confirming that the transaction business is divided into multiple sub-businesses, generating a sequence code for the sub-businesses according to the execution order of the sub-businesses, wherein the sequence code is a combination array of the total number of sub-businesses and the execution order ranking; Use business codes and sequence codes to mark corresponding sub-businesses; Generate a status mark for each sub-business using a status mark system; Filter out the business codes and sequence codes of multiple sub-businesses whose status is marked as completed; Classify the sequence codes of multiple sub-services with the same service code into the same data group; Parse the total number of sub-businesses and the execution order ranking of the sequence code in the data group. If the number of sequence codes in the data group is equal to the total number of sub-businesses, and the arrangement order of the execution order ranking is a natural number, it is determined that the transaction business corresponding to the corresponding business code is executed.
3. The method according to claim 2, characterized in that Acquiring transaction data generated by the transaction business, including: Retrieve business record data from the business server according to the business code of the transaction business; Transaction data is extracted from the business record data using keyword extraction technology, and the transaction data includes transaction parties, transaction amounts and transaction time.
4. The method according to claim 1, characterized in that: Confirm that the business server is in an idle state, and execute the task to actively obtain the electronic receipt from the signature server, including: Obtaining network resource utilization of a local network of a business server; If it is confirmed that the network resource utilization rate does not reach the set utilization rate threshold, the task is executed, and the execution method of the task includes: Encrypting the transaction data associated with the task and the corresponding business code into ciphertext data; Sending the ciphertext data to the signature server; Receive the ciphertext file returned by the signature server, and decrypt the ciphertext file into a plaintext file, where the plaintext file is an electronic receipt named after the business code.
5. The method according to claim 1, characterized in that The method further comprises: Obtaining user behavior data, the user behavior data including user information and historical business record data, the historical business record data including business type and whether to apply for an electronic receipt; Quantify and map each piece of user behavior data into a feature array; Performing clustering processing on the feature array, and analyzing the corresponding relationship between user information, business type and whether to apply for an electronic receipt according to the clustering result; Analyze the user information and business type corresponding to the task, and predict the probability of applying for an electronic receipt based on the user information and business type corresponding to the task and the corresponding relationship; Generate a priority level of the corresponding task according to the preset user information priority and the probability; Execute cached tasks in order of priority.
6. The method according to claim 5, characterized in that The feature array is clustered, and the corresponding relationship between the user information, the business type and whether to apply for an electronic receipt is analyzed according to the clustering result, including: Get the user attributes of the user information and replace the user information in the feature array with the user attributes; Encode the user attributes and business types in the feature array, and use whether to apply for an electronic receipt as the clustering target latent variable to obtain a preprocessing array; Combine the elbow rule and silhouette coefficient double verification method to determine the K value of clustering; Using a K-means algorithm to process the plurality of preprocessed arrays based on the K value to obtain a plurality of clusters; According to the clustering target latent variable of the feature array in each cluster, the probability of applying for an electronic receipt in each cluster is calculated; The user attributes and business types of each cluster are solidified into a corresponding relationship with the corresponding probability.
7. The method according to claim 1, characterized in that Send the electronic receipt pre-acquired by the business server to the corresponding client, including: Confirm that the storage resource occupancy rate of the business server reaches the set storage resource occupancy rate threshold, filter out the electronic receipts whose storage time reaches the set time threshold, and actively push the filtered electronic receipts to the corresponding user terminals, and transfer the pushed electronic receipts from the business server to the cold data storage; Or, based on the received user request, the corresponding electronic receipt stored in the business server is sent to the client that initiated the user request.
8. An electronic receipt printing system, characterized in that: include: A data acquisition module is used to confirm the completion of the transaction and obtain the transaction data generated by the transaction; A task generation module, used to generate an electronic receipt application task according to the transaction data, and cache the task; A task execution module, used to confirm that the business server is in an idle state, and execute the task to actively obtain an electronic receipt from the signature server; The file sending module is used to send the electronic receipt pre-acquired by the business server to the corresponding client.
9. A device, characterized in that: include: A memory, used for storing an electronic receipt printing program; A processor, used to implement the steps of the electronic receipt printing method as described in any one of claims 1 to 7 when executing the electronic receipt printing program.
10. A computer-readable storage medium storing a computer program, characterized in that: The readable storage medium stores an electronic receipt printing program, and when the electronic receipt printing program is executed by the processor, the steps of the electronic receipt printing method according to any one of claims 1 to 7 are implemented.