An automatic recharge system based on AI message recognition
The AI-based message recognition-based automatic recharge system solves the problem that traditional recharge systems cannot parse unstructured vouchers, enabling automated cross-platform accounting processing and improving accuracy and security.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHENG DU SHI JI FEI YANG KE JI JI TUAN YOU XIAN GONG SI
- Filing Date
- 2026-01-26
- Publication Date
- 2026-04-21
AI Technical Summary
Traditional automatic recharge systems cannot respond to unstructured transfer vouchers submitted by users through communication channels, and have difficulty parsing complex message streams containing text declarations and image screenshots. This results in cross-platform fund collection relying on manual verification and entry, leading to processing delays and accounting errors. Furthermore, the lack of anti-tampering and anti-replay verification mechanisms causes erroneous fund transfers and operational security risks.
An AI-based message recognition-based automatic recharge system is adopted. The information extraction module filters composite messages, the voucher parsing module analyzes text and image features, the logic risk control module performs multi-dimensional risk control verification, and the instruction execution module drives the payment interface to achieve an automated closed loop from message recognition to fund injection.
It enables precise blocking of forged or duplicate requests without human intervention, improves the accuracy and security of cross-platform accounting processing, and constructs a multi-dimensional risk control logic based on the consistency comparison between declared values and identified amounts, the uniqueness retrieval of serial number hash fingerprints, and the timeliness determination of timestamps.
Smart Images

Figure CN121563507B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of electronic payment technology, and in particular to an automatic recharge system based on AI message recognition. Background Technology
[0002] The field of electronic payment technology mainly involves technical means of transferring funds and settling debts between payers and payees using computer networks, communication terminals, and financial data processing systems. It encompasses core aspects such as the generation, transmission, verification, and settlement of payment instructions. Traditional automatic top-up systems refer to a system where the server pre-stores the binding relationship between user account identifiers and payment channels in a database. When the backend billing module detects that the user's account balance is lower than a preset threshold through numerical comparison logic, it automatically retrieves the stored binding information and sends a fixed-format deduction instruction to the bank's host through the payment gateway. Alternatively, the server may initiate a standardized fund transfer request to the financial institution based on a periodic task set by its internal clock to complete the top-up operation.
[0003] Traditional automatic top-up relies on preset account binding and internal balance thresholds to trigger deductions. It cannot respond to unstructured transfer vouchers submitted by users through communication channels, and it is difficult to parse complex message streams containing text declarations and image screenshots. As a result, cross-platform fund collection requires manual verification and manual entry, which can easily lead to processing delays and accounting errors when facing high concurrency requests. Furthermore, it lacks anti-tampering and anti-replay verification mechanisms for image vouchers, and cannot identify forged screenshots or repeatedly used invalid vouchers, resulting in incorrect fund transfers and operational security risks. Summary of the Invention
[0004] The purpose of this invention is to address the shortcomings of existing technologies by proposing an automatic recharge system based on AI message recognition.
[0005] To achieve the above objectives, the present invention adopts the following technical solution: an automatic recharge system based on AI message recognition, comprising:
[0006] The information extraction module filters target composite messages containing text and images, extracts the text of the target composite message to construct a text message string, decodes the image of the target composite message to construct a pixel grayscale matrix, and generates a message reception timestamp.
[0007] The voucher parsing module extracts the declaration value and account identifier string from the text message string, calculates the gradient of the pixel grayscale matrix to locate the region of interest, and identifies the region of interest to generate the voucher amount value, transaction serial number characters and voucher generation timestamp.
[0008] The logical risk control module establishes an amount consistency mark based on the declared value and the voucher amount value, hashes the transaction serial number characters to construct a transaction fingerprint and compares the transaction fingerprint to establish a unique mark, and generates a verification pass status instruction based on the interval between the voucher generation timestamp and the message reception timestamp, the amount consistency mark and the unique mark.
[0009] The instruction execution module, in response to the verification pass status instruction, retrieves the payment interface address, fills the account identifier string and the voucher amount into the template to construct a standard recharge request message, sends the standard recharge request message to the third-party payment gateway, and records the transaction log.
[0010] As a further aspect of the present invention, the specific function of the information extraction module is as follows:
[0011] The data stream monitoring and filtering submodule establishes a long connection session with the instant messaging service port, monitors the transmission protocol header of data packets in real time, identifies the multipurpose Internet Mail extension type of data packets, and filters out the target composite message whose multipurpose Internet Mail extension type is identified as a mixed multipart type and simultaneously contains plain text subparts and image subparts.
[0012] The text cleaning and recombination submodule parses the plain text sub-parts in the target composite message, removes emoji encoding and Hypertext Markup Language tags, and concatenates the remaining valid characters according to the original receiving order of the character stream to construct the text message string;
[0013] The image decoding and mapping submodule parses the image sub-part in the target composite message, performs Base64 decoding on the image binary stream to restore the original image data, traverses each pixel of the original image data, extracts the red, green and blue channel values of each pixel and maps them to single-channel grayscale values, constructs the pixel grayscale matrix, and synchronously reads the current clock cycle value of the system to generate the message reception timestamp.
[0014] As a further aspect of the present invention, the specific function of the credential parsing module is as follows:
[0015] The key information regular expression extraction submodule loads a predefined regular expression library, calls an expression containing floating-point number format rules to scan the text message string, extracts a numerical sequence that conforms to the currency amount format as the declared value, and simultaneously calls an expression containing account encoding rules to scan and extract a string that conforms to the preset account length and character composition as the account identifier string.
[0016] The visual focusing region localization submodule uses an edge detection operator to perform convolution operations on the pixel grayscale matrix, calculates the gradient magnitude of each pixel in the matrix, and delineates a rectangular range containing high-frequency texture features based on the distribution density of the gradient magnitude to locate the region of interest.
[0017] The character optical recognition and parsing submodule performs binarization segmentation and character feature extraction on the pixel array within the region of interest. It compares the extracted features with a pre-set financial character template library to identify the numerical sequence representing the transaction amount and generate the voucher amount value. It also identifies the alphanumeric combination representing the unique transaction number and generates the transaction serial number character, as well as the date and time string representing the transaction time and generates the voucher generation timestamp.
[0018] As a further aspect of the present invention, the specific functional implementation of the logical risk control module is as follows:
[0019] The numerical consistency verification submodule obtains the declared value and the voucher amount value, calculates the absolute difference between the two, and determines whether the absolute difference is less than the system's preset floating-point tolerance threshold. If the determination result is true, the amount consistency mark is established.
[0020] The transaction uniqueness deduplication submodule calls a secure hash algorithm to perform a one-way encryption operation on the transaction serial number characters, constructs a fixed-length transaction fingerprint, and uses the transaction fingerprint as a retrieval key to query the local historical transaction fingerprint database. If the query result shows that the fingerprint does not exist, the unique tag is established.
[0021] The integrated timeliness decision submodule calculates the time difference between the message receiving timestamp and the voucher generation timestamp, determines whether the time difference is within a preset valid time window, and generates the verification passed status instruction when both the amount consistency mark and the uniqueness mark have been established and the time difference is valid.
[0022] As a further aspect of the present invention, the specific function of the instruction execution module is as follows:
[0023] The routing policy matching submodule parses the prefix encoding feature of the account identifier string, searches for the service provider record corresponding to the prefix encoding feature in the local payment routing configuration table, and retrieves the payment interface address corresponding to the service provider.
[0024] The message security encapsulation submodule loads the standard message template of the corresponding service provider, maps the account identifier string to the payee field of the template, maps the voucher amount value to the transaction amount field of the template, and adds a digital signature and verification bit to construct the standard recharge request message.
[0025] The gateway communication auditing submodule sends the standard recharge request message to the retrieved payment interface address via the Hypertext Transfer Security Protocol, listens for the confirmation receipt returned by the gateway, and writes a record containing the sending time, message content summary, and receipt status into an immutable log file to record the transaction log.
[0026] As a further aspect of the present invention, the process of constructing the pixel grayscale matrix in the image decoding mapping submodule specifically includes:
[0027] Obtain the red channel value, green channel value, and blue channel value of each pixel in the original image data;
[0028] Based on the difference in human visual sensitivity to different color light waves, using a preset brightness weighting conversion logic, the red channel value is multiplied by the red channel brightness weighting coefficient, the green channel value is multiplied by the green channel brightness weighting coefficient, and the blue channel value is multiplied by the blue channel brightness weighting coefficient. The three products are then added together to obtain the grayscale value of the pixel.
[0029] The calculated grayscale values are filled into the corresponding coordinate positions of the two-dimensional matrix. All pixels are traversed until the entire matrix is filled, thus constructing the pixel grayscale matrix.
[0030] As a further aspect of the present invention, the process of locating the region of interest in the visual focusing region positioning submodule specifically includes:
[0031] The pixel grayscale matrix is obtained, and the pixel grayscale matrix is scanned using horizontal Sobel convolution kernels and vertical Sobel convolution kernels respectively.
[0032] Calculate the coordinates in the pixel grayscale matrix as follows: The overall gradient magnitude of the pixels The calculation formula is as follows:
[0033] ;
[0034] in, Represents the combined gradient magnitude. This represents the rate of change of grayscale value of that pixel in the horizontal direction. This represents the rate of change of grayscale value of that pixel in the vertical direction;
[0035] Pixels whose combined gradient magnitude is greater than a preset edge threshold are marked as edge points, and the connected regions with the highest edge point density are defined as the regions of interest.
[0036] As a further aspect of the present invention, the process of constructing a transaction fingerprint in the transaction uniqueness deduplication submodule specifically includes:
[0037] Obtain the transaction serial number characters and generate a random salt value string containing the current system date;
[0038] The transaction serial number characters are concatenated with the random salt value string to form a mixed string to be encrypted;
[0039] The SHA-256 hash function is called to perform multiple rounds of iterative operations on the mixed string, generating a fixed-length 256-bit hexadecimal string to construct the transaction fingerprint.
[0040] As a further aspect of the present invention, the process of generating the verification pass status instruction in the comprehensive timeliness decision submodule specifically includes:
[0041] Obtain the voucher generation timestamp and the message reception timestamp, and convert both into long integer values in milliseconds;
[0042] Calculate the absolute value of the difference between two long integer values, and determine whether the absolute value of the difference is less than the preset maximum tolerance threshold for transmission delay;
[0043] Detect whether the amount matching marker and the unique marker exist in the memory;
[0044] The instruction generation logic is triggered to generate the verification pass status instruction only when the absolute value of the difference is less than the threshold and the amount consistency mark and the uniqueness mark are detected simultaneously in memory.
[0045] As a further aspect of the present invention, the process of recording transaction logs in the gateway communication audit submodule specifically includes:
[0046] The precise system time when the standard recharge request message was sent is obtained as the request initiation time;
[0047] Extract the account identifier string and the voucher amount from the standard recharge request message as key business fields;
[0048] Obtain the Hypertext Transfer Protocol status code and the business processing result code in the response message body returned by the third-party payment gateway;
[0049] The request initiation time, the key business fields, the Hypertext Transfer Protocol status code, and the business processing result code are combined into a text record according to a predefined log format, and the text record is appended to the daily rolling log file on the local disk to record the transaction log.
[0050] Compared with the prior art, the advantages and positive effects of the present invention are as follows:
[0051] In this invention, by filtering composite messages and independently extracting text and image features, unstructured vouchers are transformed into computable financial elements using regular expression matching and gradient calculation. A multi-dimensional risk control logic is constructed based on the consistency comparison between declared values and identified amounts, the uniqueness retrieval of serial number hash fingerprints, and the timeliness determination of timestamps. This logic accurately blocks forged or duplicate requests without human intervention. Based on the verified elements, a standardized message-driven payment interface is constructed to achieve an automated closed loop from message recognition to fund injection, thereby improving the accuracy and security of cross-platform accounting processing. Attached Figure Description
[0052] Figure 1 This is a schematic diagram of the structure of an automatic recharge system based on AI message recognition according to the present invention;
[0053] Figure 2 This is a schematic diagram of the information extraction module and its internal data processing flow of the present invention;
[0054] Figure 3 This is a schematic diagram of the voucher parsing module and the region of interest location and recognition process of the present invention;
[0055] Figure 4 This is a schematic diagram of the logical risk control module and the multi-verification process of the present invention;
[0056] Figure 5 This is a schematic diagram of the instruction execution module and transaction log recording process of the present invention. Detailed Implementation
[0057] To make the objectives, technical solutions, and advantages of this invention clearer, the software-based technical solution is described in detail below with reference to system architecture diagrams and embodiments. It should be understood that the specific embodiments described herein are only for explaining the technical solutions of this invention and do not constitute a limitation on the scope of protection.
[0058] All user-related information involved in this invention (including but not limited to biometric information, identity verification information, behavioral data, device information, and other data that can be used for identity verification and personalized services) is collected and processed with the user's full knowledge and voluntary consent. The collection, storage, and use of all information strictly comply with applicable national and regional laws and regulations, and meet relevant data protection standards and policy requirements. The use of data is limited to purposes necessary for providing the technical services of this invention, and reasonable technical and management measures will be taken to ensure the security and confidentiality of users' personal information in terms of information protection and privacy.
[0059] In the description of this invention, the system architecture relationships or data processing flows indicated by terms such as "layer," "module," "interface," "data flow," "client," and "server" are all defined based on the architecture diagram or flowchart corresponding to the embodiments. This way of describing is only used to clearly illustrate the logical relationships between the elements in the technical solution, and not to limit the physical deployment form. The term "multiple" includes two or more technical units, including but not limited to multiple data nodes, processing threads, service instances, or functional components and other scalable elements. The specific number is determined according to the actual business scenario and needs to be specifically specified.
[0060] Please see Figure 1 and Figure 2 This invention provides a technical solution: an automatic recharge system based on AI message recognition, comprising:
[0061] The information extraction module filters target composite messages containing text and images, extracts the text of the target composite message to construct a text message string, decodes the target composite message image to construct a pixel grayscale matrix, and generates a message reception timestamp. In order to cope with the diversity of voucher sources in financial transaction scenarios, this module has integrated a multimodal data preprocessing mechanism, which can be compatible with and recognize transfer vouchers from different banks (such as China Construction Bank, Industrial and Commercial Bank of China, etc.) and different payment platforms (such as Alipay, WeChat, UnionPay QuickPass, etc.), and supports standardized information extraction from raw data in various display formats such as mobile phone screenshots, photos of paper receipts, and electronic PDF documents.
[0062] The specific functions of the information extraction module are as follows:
[0063] The data stream monitoring and filtering submodule establishes a long-lived connection session with the instant messaging service port, monitors the transmission protocol header of data packets in real time, identifies the Multipurpose Internet Mail Extensions (MIL) of data packets, and filters out target composite messages that are identified by the MIL as a mixed multi-part type and simultaneously contain plain text and image subparts. For credentials that exist in the form of electronic documents, this submodule is also configured to identify the characteristics of PDF file streams in application layer transmission and treat them as image sources to be processed for interception.
[0064] The text cleaning and reorganization submodule parses the plain text sub-parts in the target composite message, removes emoji encoding and Hypertext Markup Language tags, and concatenates the remaining valid characters according to the original receiving order of the character stream to construct the text message string;
[0065] The image decoding and mapping submodule parses the image sub-parts in the target composite message, performs Base64 decoding on the image binary stream to restore the original image data, traverses each pixel of the original image data, extracts the red, green, and blue channel values of each pixel and maps them to single-channel grayscale values, constructs a pixel grayscale matrix, and synchronously reads the current clock cycle value of the system to generate a message reception timestamp. During this process, if the original data is identified as a PDF electronic receipt format, the submodule will first call the rendering engine to rasterize it into a high-resolution bitmap; if it is identified as a screenshot or photographed image, it will automatically adapt its color space.
[0066] The process of constructing the pixel grayscale matrix in the image decoding mapping submodule specifically includes:
[0067] Obtain the red channel value, green channel value, and blue channel value of each pixel in the original image data;
[0068] Based on the differences in human visual sensitivity to different color light waves, a preset brightness weighting conversion logic is used to multiply the red channel value by the red channel brightness weighting coefficient, the green channel value by the green channel brightness weighting coefficient, and the blue channel value by the blue channel brightness weighting coefficient, and then add the three products to obtain the grayscale value of the pixel.
[0069] The calculated grayscale values are filled into the corresponding coordinate positions of the two-dimensional matrix. All pixels are traversed until the entire matrix is filled, thus constructing a pixel grayscale matrix.
[0070] As the system's perception front end, the information extraction module has a finely divided internal architecture into a data stream monitoring and filtering submodule, a text cleaning and reorganization submodule, and an image decoding and mapping submodule. Each submodule interacts with data through a shared high-speed memory bus.
[0071] The data stream listening and filtering submodule is configured as a protocol parser for the network interface layer. This submodule binds to the port of the instant messaging service (such as the default 5222 or 443) via a Socket interface, maintaining a full-duplex TCP long connection. After the connection is established, the submodule's internal protocol header analyzer intercepts the transport layer payload in real time, reading the packet header information byte by byte. The analyzer has a built-in MIME type matching table conforming to the RFC2045 standard, specifically for string comparison of the Content-Type field. The submodule triggers subsequent processing logic only when the field value is detected as multipart / mixed. At this point, the submodule further parses the boundary parameter in the protocol header, which defines the separator string for different sub-parts in the composite message. The submodule uses this separator to cut the payload data into discrete data blocks and reads the Content-Type sub-header for each data block. The filtering logic is set as follows: a single message packet must simultaneously detect both text / plain (plain text) and image / jpeg (or image / png or application / pdf) sub-blocks before it is marked as a "target composite message" and stored in the pending queue.
[0072] The aforementioned Multipurpose Internet Mail Extensions (MIME) refers to an Internet standard that extends the email standard to support non-ASCII character text, non-text format attachments (such as images, videos, audio, etc.), and message bodies containing multiple parts.
[0073] The text cleaning and reorganization submodule is connected to the processing queue. First, it loads a UTF-8 decoder to convert the text / plain portion from binary to character. Then, this submodule calls a pre-defined character filter. The filter internally maintains two blacklist mapping tables: one is a Unicode emoji encoding range table (covering ranges such as U+1F600 to U+1F64F), and the other is an HTML tag feature table (e.g., ...). , (e.g., ...). The submodule uses a sliding window algorithm to scan the text stream in byte increments. Once a byte sequence within the window matches the blacklist, it is discarded; otherwise, it is retained. The cleaned characters are fed into a string builder, which strictly reassembles the characters according to the SequenceNumber of the TCP data packets to ensure the logical continuity of the text under out-of-order transmission over the network, ultimately generating a clean text message string.
[0074] The image decoding mapping submodule focuses on processing image / * sub-blocks. This submodule first activates the Base64 decoding engine, using a lookup table to reverse-engineer the ASCII character stream back into a binary byte stream. Then, it calls a bitmap decoder (such as the hardware acceleration interface of the libjpeg-turbo library) to decompress the binary stream into bitmap data. At this point, the image data resides in memory and is represented as a wide... high The array is a two-dimensional pixel array, where each pixel contains an 8-bit value (0-255) for three color channels: R, G, and B. For efficient subsequent processing, the submodule performs a grayscale mapping operation. This operation is weighted based on the biological sensitivity differences of the human eye to different wavelengths of light (the human eye is most sensitive to green light and least sensitive to blue light).
[0075] The aforementioned Base64 decoding refers to a method of representing binary data based on 64 printable characters. By converting every 3 8-bit bytes into 4 6-bit bytes and mapping them to a predefined character set, binary data can be converted into text format for transmission over a network.
[0076] During this mapping process, the submodule traverses each coordinate point of the bitmap array. The system reads the RGB components and simultaneously calls the system's high-precision timer (HPET) to read the current CPU clock cycles (TSC register value), converting it into a nanosecond-level UNIX timestamp as the message's reception timestamp. Finally, the calculated grayscale value is written into a new single-channel two-dimensional matrix, which is the pixel grayscale matrix, directly used for subsequent computer vision processing.
[0077] In the process of constructing the pixel grayscale matrix in the image decoding mapping submodule, the grayscale conversion formula and parameter settings are crucial. The system adopts a brightness calculation formula conforming to the NTSC standard, and the brightness weight coefficients for each channel are set as follows: Red channel brightness weight coefficient Set to 0.299, the brightness weighting coefficient for the green channel. Set to 0.587, the luminance weighting coefficient for the blue channel. The weighting coefficient is set to 0.114. This weighting coefficient is based on experimental data from the CIE (International Commission on Illumination) standard photometric function, and aims to ensure that the calculated grayscale values maintain visual brightness consistency with the original color image.
[0078] The grayscale value of the pixel is calculated using a preset brightness-weighted transformation logic. The formula is as follows:
[0079] ;
[0080] in, Representing coordinates The grayscale value of the pixel. This represents the red channel value of that pixel. This represents the green channel value of that pixel. This represents the blue channel value of that pixel. This represents the brightness weighting coefficient for the red channel (value 0.299). This represents the brightness weighting coefficient for the green channel (value 0.587). This represents the brightness weighting coefficient for the blue channel (value 0.114).
[0081] To verify the calculation logic, assume the coordinates of the original image data are... At this location, the RGB value of a single pixel is collected: the red channel value. The value is 180, the green channel value. The value is 200, representing the blue channel. The value is 50. Substitute this value into the formula above to calculate: The contribution value of the red component is... The contribution value of the green component is The contribution value of the blue component is The summation result is The system uses rounding to obtain the final grayscale value. The result This represents a relatively high gray level (a bright gray close to white), which aligns with the visual perception that the original pixels have high red and green components (displayed as a bright yellow tone). Experimental data shows that when processing financial document images with complex lighting environments, the grayscale matrix generated by the weighted algorithm improves the character edge contrast by approximately 12.5% compared to the averaging method, significantly enhancing the accuracy of subsequent recognition.
[0082] Please see Figure 1 and Figure 3 The voucher parsing module extracts the declared value and account identifier string from the text message string, calculates the pixel grayscale matrix gradient to locate the region of interest, and identifies the region of interest to generate the voucher amount value, transaction serial number characters and voucher generation timestamp.
[0083] The specific functions of the voucher parsing module are as follows:
[0084] The key information regular expression extraction submodule loads a predefined regular expression library, calls expressions containing floating-point number format rules to scan the text message string, extracts numerical sequences that conform to the currency amount format as the declared value, and simultaneously calls expressions containing account encoding rules to scan and extract strings that conform to the preset account length and character composition as the account identifier string.
[0085] The visual focusing region localization submodule uses edge detection operators to perform convolution operations on the pixel grayscale matrix, calculates the gradient magnitude of each pixel in the matrix, and delineates a rectangular area containing high-frequency texture features based on the distribution density of the gradient magnitude to locate the region of interest.
[0086] The character optical recognition and parsing submodule performs binarization segmentation and character feature extraction on the pixel array within the region of interest. It compares the extracted features with a pre-set financial character template library to identify the numerical sequence representing the transaction amount and generate the voucher amount value, identify the alphanumeric combination representing the unique transaction number and generate the transaction serial number character, and identify the date and time string representing the transaction time and generate the voucher generation timestamp.
[0087] The credential parsing module also includes:
[0088] The multi-source voucher intelligent classification submodule is pre-installed with a lightweight convolutional neural network (such as MobileNet or EfficientNet architecture). This network is trained with multiple samples, and the sample set extensively covers successful transfer interfaces from mainstream payment platforms (including but not limited to Alipay, WeChat Pay, and UnionPay QuickPass) and major commercial banks (such as China Merchants Bank and ICBC). Furthermore, to accommodate the complexity of image presentation in real-world business scenarios, the training data specifically includes clear mobile phone screenshots, photographs of paper bank receipts affected by lighting and angle, and standardized screenshots of electronic PDF documents. During processing, the pixel grayscale matrix is normalized and input into the network to extract high-dimensional texture features. The network output layer generates a classification probability vector using the Softmax function. The source and form of the voucher are determined by selecting the index with the highest probability. For example, the current image is identified as "WeChat Pay - Mobile Screenshot", "UnionPay QuickPass - Electronic Receipt" or "China Construction Bank - Counter Receipt Photo".
[0089] The adaptive feature extraction and parsing submodule retrieves the corresponding "Layout Attention Mask" from the database based on the classification results. Furthermore, the submodule employs differentiated preprocessing strategies for different image display formats: for "screenshot" vouchers, it focuses on eliminating compression artifacts; for "photograph" vouchers, it automatically corrects perspective distortion and uneven lighting; and for "PDF" sources, it leverages their vector characteristics to enhance character edges. The submodule performs a dot product operation between the mask and the original image to suppress noise interference in non-critical areas (such as advertising banners and decorative backgrounds) and highlight key field areas. Subsequently, it calls a CRNN (Convolutional Recurrent Neural Network) to perform end-to-end recognition of the weighted region. To address potential perspective distortion in photographic scenes, the submodule introduces a Spatial Transformation Network (STN) for affine transformation correction, straightening tilted text lines before character recognition. This AI-based approach identifies and extracts content information for various types of vouchers, accurately generating the voucher amount, transaction serial number characters, and voucher generation timestamp.
[0090] The process of locating the region of interest in the visual focusing region localization submodule specifically includes:
[0091] Obtain the pixel grayscale matrix, and scan the pixel grayscale matrix using horizontal Sobel convolution kernels and vertical Sobel convolution kernels respectively;
[0092] Calculate the coordinates in the pixel grayscale matrix. The overall gradient magnitude of the pixels The calculation formula is as follows:
[0093] ;
[0094] in, Represents the overall gradient magnitude. This represents the rate of change of grayscale value of that pixel in the horizontal direction. This represents the rate of change of grayscale value of that pixel in the vertical direction;
[0095] Pixels with a combined gradient magnitude greater than a preset edge threshold are marked as edge points, and the connected regions with the highest edge point density are defined as regions of interest.
[0096] The voucher parsing module is a core component that connects unstructured image data with structured financial data. It integrates a key information regular expression extraction submodule, a visual focus area positioning submodule, and a character optical recognition parsing submodule.
[0097] The key information regular expression extraction submodule runs within the text processing pipeline. This submodule loads the PCRE (PerlCompatibleRegularExpressions) engine. For extracting declared values, the submodule compiles a regular expression with the following logic: first, it matches optional currency prefixes, allowing whitespace between the prefix and the number; then, it matches the first non-zero digit, supporting comma-separated format for thousands; finally, it enforces matching to two decimal places. For account identifier strings, the system is set to 16 to 19 characters of pure numbers (covering the length of mainstream bank card numbers), and the regular expression mode is set to \b\d{16,19}\b, where \b ensures that independent word boundaries are extracted, avoiding mismatches of phone numbers. The submodule performs a full-text scan of the text message string and pushes the first match onto the result stack.
[0098] The visual focusing region localization submodule extracts textual information from complex document backgrounds to reduce computational overhead in subsequent processing. This submodule takes the previously generated pixel grayscale matrix as input and uses GPU-accelerated convolutional kernels for parallel computation. The core of the submodule employs the Sobel operator for edge detection. Specifically, the system applies horizontal convolutional kernels... and vertical convolution kernel A sliding window operation is performed on the matrix. For each pixel, its gradient magnitude is calculated. To filter background noise (such as watermarks and patterns on vouchers), the submodule introduces a dynamic thresholding mechanism.
[0099] The Sobel operator mentioned above is a discrete differential operator for image processing. It combines Gaussian smoothing and differential calculation to calculate the approximate gradient of the image grayscale function, thereby detecting edges in the image.
[0100] The character optical recognition and parsing submodule receives the located Region of Interest (ROI). First, the submodule uses Otsu's method to calculate the optimal global threshold, converting the grayscale ROI into a binary (black and white) bitmap to maximize the inter-class variance between the foreground text and the background. Next, a connected component analysis algorithm is used to segment the individual character dot matrix. The feature extraction stage employs a grid feature method, normalizing each character to... The system calculates the density of black pixels within each cell of a grid, generating a feature vector. This feature vector is then fed into a Support Vector Machine (SVM)-based classifier. The classifier uses a template library trained on millions of financial document samples, outputting the character classification result (numbers, letters, or symbols) and its confidence score. The system only accepts recognition results with a confidence score higher than 0.95, ultimately concatenating the data to form the document amount, transaction serial number, and timestamp.
[0101] In the visual focus area localization submodule, accurately calculating the gradient magnitude of each pixel is crucial for locating text edges. The system calculates the overall gradient magnitude. The formula is as follows:
[0102] in, Representing coordinates The comprehensive gradient magnitude of a pixel is used to characterize the degree of grayscale change at that point; This represents the rate of grayscale change of the pixel in the horizontal direction, and is obtained by the horizontal Sobel convolution kernel. This represents the rate of grayscale change of the pixel in the vertical direction, and is obtained by the vertical Sobel convolution kernel. This represents the square root operation, used to calculate the magnitude of a vector by combining components from two orthogonal directions.
[0103] To verify the calculation process, a pixel in the grayscale matrix was selected based on its coordinates. Centered The calculation was performed on a local neighborhood. This neighborhood simulated a vertical edge (dark on the left, bright on the right), and the data is shown in the table below:
[0104] Table 1 Local Pixel Gray Values
[0105] ;
[0106] As shown in Table 1, the data simulates distinct vertical edge features: the left column has a gray level of 50 (dark), while the middle and right columns have a gray level of 150 (bright). The Sobel convolution kernel used is a horizontal kernel. Vertical core .
[0107] Calculate the horizontal gradient Calculate the vertical gradient. Calculate the overall gradient magnitude. : .
[0108] The system's preset edge threshold is 100, a value derived statistically from the distribution of background texture gradient magnitudes. The calculated result of 400 is significantly larger than the preset edge threshold of 100, therefore the coordinates... The point was marked as an "edge point" by the system. This result indicates that the Sobel operator successfully detected the strong edge features present at this location. Experiments show that after introducing this gradient calculation logic, the success rate of locating checks with complex backgrounds reached 98.2%.
[0109] Please see Figure 1 and Figure 4 The logical risk control module establishes an amount consistency mark based on the declared value and the voucher amount value, constructs a transaction fingerprint by hashing the transaction serial number characters and compares the transaction fingerprint to establish a unique mark, and generates a verification pass status instruction based on the interval between the voucher generation timestamp and the message receiving timestamp, the amount consistency mark and the unique mark.
[0110] The specific functions of the logical risk control module are as follows:
[0111] The numerical consistency verification submodule obtains the declared value and the voucher amount value, calculates the absolute difference between the two, and determines whether the absolute difference is less than the system's preset floating-point tolerance threshold. If the result is true, an amount consistency mark is established.
[0112] The transaction uniqueness deduplication submodule calls a secure hash algorithm to perform one-way encryption on the transaction serial number characters, constructs a fixed-length transaction fingerprint, and uses the transaction fingerprint as a retrieval key to query the local historical transaction fingerprint database. If the query result shows that the fingerprint does not exist, a unique tag is established.
[0113] The comprehensive timeliness decision submodule calculates the time difference between the message receiving timestamp and the voucher generation timestamp, determines whether the time difference is within the preset valid time window, and generates a verification pass status command under the condition that the amount consistency mark and uniqueness mark have been established and the time difference is valid.
[0114] The process of constructing transaction fingerprints in the transaction uniqueness deduplication submodule specifically includes:
[0115] Retrieve the transaction serial number characters and generate a random salt value string containing the current system date;
[0116] The transaction serial number characters are concatenated with a random salt value string to form a mixed string to be encrypted;
[0117] The SHA-256 hash function is called to perform multiple rounds of iterative operations on the mixed string, generating a fixed-length 256-bit hexadecimal string to construct the transaction fingerprint;
[0118] The process of generating the verification pass status instruction in the comprehensive timeliness decision-making submodule specifically includes:
[0119] Obtain the voucher generation timestamp and message reception timestamp, and convert both into long integer values in milliseconds;
[0120] Calculate the absolute value of the difference between two long integer values, and determine whether the absolute value of the difference is less than the preset maximum tolerance threshold for transmission delay;
[0121] Check if there are any matching and unique tokens in memory;
[0122] The instruction generation logic is triggered to generate a verification pass status instruction only when the absolute value of the difference is less than the threshold and both the amount consistency marker and the uniqueness marker are detected in memory at the same time.
[0123] The logical risk control module is the last line of defense to ensure the safety of funds. Its design follows the "zero trust" principle and includes a numerical consistency verification submodule, a transaction uniqueness deduplication submodule, and a comprehensive timeliness decision-making submodule.
[0124] The numerical consistency verification submodule is responsible for verifying whether the user's subjective statement matches the objective evidence. This submodule reads the "declared value" extracted from the text and the "document amount value" recognized by OCR. Due to the precision issues of floating-point numbers in computer storage (such as the IEEE 754 standard), the submodule does not directly use the equality sign for comparison, but instead introduces a "floating-point tolerance threshold." The logic unit calculates the absolute value of the difference between the two, and only performs a check if the difference is less than 1. When the time is right, the logical truth value is output. This design effectively avoids misjudgment caused by the slight error in the last digit of the OCR recognition.
[0125] The transaction uniqueness deduplication submodule is designed to prevent replay attacks. This submodule obtains the transaction serial number, which is the unique fingerprint of each bank transaction. To further enhance security and prevent rainbow table attacks, the submodule introduces a "salting" mechanism. The system generates a "salt value string" containing a millisecond-level timestamp and a random number. The submodule concatenates the transaction serial number with the salt value and inputs it into the SHA-256 hardware acceleration engine. The engine performs 64 rounds of compression loops, transforming the input of arbitrary length into a fixed 256-bit hash value (transaction fingerprint). Subsequently, the submodule uses a Bloom filter to quickly screen the local historical database. If the Bloom filter indicates "possibly existing," a precise key-value query is performed in a KV database (such as LevelDB) stored on SSD. Only when the database returns "KeyNotFound" is it confirmed as a new transaction.
[0126] The aforementioned SHA-256 (SecureHashAlgorithm256-bit) refers to a cryptographic hash function belonging to the SHA-2 series. It can convert input data of any length into a fixed-length hash value of 256 bits (32 bytes) and has the characteristics of one-way (irreversible) and collision resistance (different inputs are unlikely to generate the same output).
[0127] The comprehensive timeliness decision-making submodule performs risk control based on the time dimension. The submodule obtains the message reception timestamp ( ) and voucher generation timestamp ( First, the format is standardized, uniformly converted to UTC millisecond values. Next, the time difference is calculated. The core of the logic lies in judgment. Whether it falls within a reasonable range. The lower limit of the range is usually a negative tolerance (allowing a small amount of clock rollback), and the upper limit is a preset "maximum tolerance threshold for transmission delay". This submodule uses an AND gate logic circuit, and only generates a verification passed status command when the amount consistency flag, uniqueness flag and time validity signal are all true.
[0128] The following is a specific example of comprehensive timeliness decision-making. The system sets a maximum tolerance threshold for transmission delay. The threshold is set at 300,000 milliseconds (i.e., 5 minutes), based on the statistical distribution of mobile internet payment callback latency. Obtain the voucher generation timestamp. The OCR identified the message as "2023-10-27 10:00:00", which was converted to a long integer value of 1698372000000 milliseconds. (The message received timestamp is then retrieved.) The system recorded the received time as "2023-10-27 10:02:30", which, when converted to a long integer, is 1698372150000 milliseconds. Calculate the absolute value of the difference. : Milliseconds. Comparison results: ,Right now The result indicates that the transaction took 2.5 minutes from the generation of the voucher to its receipt and processing by the system, which is within the preset 5-minute valid time window and constitutes a time-sensitive and legitimate transaction request.
[0129] Please see Figure 1 and Figure 5 The instruction execution module, in response to the verification pass status instruction, retrieves the payment interface address, fills the account identifier string and voucher amount into the template to construct a standard recharge request message, sends the standard recharge request message to the third-party payment gateway, and records the transaction log.
[0130] The specific functions of the instruction execution module are as follows:
[0131] The routing policy matching submodule parses the prefix encoding feature of the account identifier string, searches for the service provider record corresponding to the prefix encoding feature in the local payment routing configuration table, and retrieves the payment interface address corresponding to the service provider.
[0132] The message security encapsulation submodule loads the standard message template of the corresponding service provider, maps the account identifier string to the payee field of the template, maps the voucher amount value to the transaction amount field of the template, and adds digital signature and verification bit to construct a standard recharge request message.
[0133] The gateway communication auditing submodule sends a standard recharge request message to the retrieved payment interface address via the Hypertext Transfer Security Protocol, listens for the confirmation receipt returned by the gateway, and writes a record containing the sending time, message content summary and receipt status to an immutable log file to record the transaction log.
[0134] The process of recording transaction logs in the gateway communication audit submodule specifically includes:
[0135] The precise system time at which the standard recharge request message was sent is obtained as the request initiation time.
[0136] Extract the account identifier string and voucher amount from the standard recharge request message as key business fields;
[0137] Obtain the Hypertext Transfer Protocol status code and the business processing result code in the response message body returned by the third-party payment gateway;
[0138] The request initiation time, key business fields, Hypertext Transfer Protocol status code, and business processing result code are combined into a text record according to a predefined log format, and this text record is appended to the daily rolling log file on the local disk to record the transaction log.
[0139] The instruction execution module is the executor that translates decisions into actual financial operations. It includes a routing policy matching submodule, a message security encapsulation submodule, and a gateway communication auditing submodule.
[0140] The routing strategy matching submodule acts as an intelligent scheduler. Internally, this submodule maintains a resident in-memory "payment routing configuration table," stored in a HashMap structure. Upon receiving a "verification passed" status command, the submodule extracts the account identifier string (such as a bank card number). The submodule executes the "Longest Prefix Matching" algorithm, reading the first 6 digits of the card number (BIN number, bank identification code). The algorithm searches the configuration table for the key-value pair, matching the corresponding Value object. This object contains the service provider name, API access point URL, and the corresponding communication key index. This process ensures that recharge requests are accurately distributed to the correct bank or third-party payment channel.
[0141] The message security encapsulation submodule is responsible for constructing data packets that conform to the interface specification. Based on the routing matching results, this submodule loads the corresponding XML or JSON template. For example, for a JSON format interface, the submodule instantiates a JSON object, mapping the "account identifier string" to the payee field and the "voucher amount value" to the transaction amount field. To ensure the immutability of the transmitted content, the submodule calls an encryption library, uses a pre-allocated RSA private key to digitally sign the message body, generates a signature field, and appends it to the message header or trailer.
[0142] The aforementioned RSA refers to an asymmetric encryption algorithm that uses the product of two large prime numbers as the modulus of the public key. Its security is based on the mathematical problem of large number factorization and is widely used for data encryption and digital signatures.
[0143] The gateway communication audit submodule is responsible for physical layer sending and logging. This submodule initializes an HTTPSClient and configures the TLS 1.3 protocol to ensure encrypted transmission channels. The submodule initiates a POST request to the retrieved payment interface address, with the payload being the aforementioned standard recharge request message. The submodule enables synchronous blocking and sets a timeout. Once it receives an HTTP 200 OK status code and a success code from the JSON response body returned by the gateway, the submodule determines the recharge was successful. At this point, the submodule triggers a log writing operation. It combines the request initiation time, anonymized key business fields, and the gateway response status code into a structured log record. This record is directly forced to be flushed to the local disk's "daily rolling log file" using the file system's fsync command, ensuring that transaction records are not lost in the event of a system power outage.
[0144] To ensure the traceability and machine readability of transaction logs, the gateway communication audit submodule strictly records each interaction according to a predefined field structure. The log recording structure is shown in the table below:
[0145] Table 2 Example of Transaction Log Record Structure
[0146] ;
[0147] As shown in Table 2, each log record generated by the system contains the aforementioned key fields. After a recharge operation is completed, a text record is appended to the end of the log file. For example: "2023-10-27T10:02:30.123Z","a1b2c3...e5f6","6222********0098",176.92,200,"SUCCESS". By parsing this log record, the system can clearly know that at 10:02 AM on October 27, 2023, a recharge request of 176.92 yuan was successfully initiated for the account ending in 0098, and the payment gateway has confirmed receipt and successful processing. This record, through association with Transaction_ID, can correspond one-to-one with the transaction fingerprint generated by the aforementioned logical risk control module, forming a complete closed-loop evidence chain from "image recognition" to "funds landing". Experimental data shows that, using this structured log auditing solution, the reconciliation error rate was reduced to below 0.001% under stress testing of handling an average of 100,000 transactions per day.
[0148] The above embodiments illustrate preferred embodiments of the present invention. Any equivalent adjustments to the technical solution based on software engineering methods are within the scope of protection, including but not limited to: implementing algorithm logic using different programming languages, refactoring functional modules into services, adjusting data interaction protocols, and optimizing resource scheduling strategies. Any implementation scheme derived from reasonable modifications to the data processing flow, service call chain, or system architecture layer without departing from the core technology of the present invention should be considered within the protection scope defined by the technical solution of the present invention.
Claims
1. An automatic recharge system based on AI message recognition, characterized in that, The system includes: The information extraction module filters target composite messages containing text and images, extracts the text of the target composite message to construct a text message string, decodes the image of the target composite message to construct a pixel grayscale matrix, and generates a message reception timestamp. The specific functions of the information extraction module are as follows: The data stream monitoring and filtering submodule establishes a long connection session with the instant messaging service port, monitors the transmission protocol header of data packets in real time, identifies the multipurpose Internet Mail extension type of data packets, and filters out the target composite message whose multipurpose Internet Mail extension type is identified as a mixed multipart type and simultaneously contains plain text subparts and image subparts. The text cleaning and recombination submodule parses the plain text sub-parts in the target composite message, removes emoji encoding and Hypertext Markup Language tags, and concatenates the remaining valid characters according to the original receiving order of the character stream to construct the text message string; The image decoding and mapping submodule parses the image sub-part in the target composite message, performs Base64 decoding on the image binary stream to restore the original image data, traverses each pixel of the original image data, extracts the red, green and blue channel values of each pixel and maps them to single-channel grayscale values, constructs the pixel grayscale matrix, and synchronously reads the current clock cycle value of the system to generate the message reception timestamp. The process of constructing the pixel grayscale matrix in the image decoding mapping submodule specifically includes: Obtain the red channel value, green channel value, and blue channel value of each pixel in the original image data; Based on the difference in human visual sensitivity to different color light waves, using a preset brightness weighting conversion logic, the red channel value is multiplied by the red channel brightness weighting coefficient, the green channel value is multiplied by the green channel brightness weighting coefficient, and the blue channel value is multiplied by the blue channel brightness weighting coefficient. The three products are then added together to obtain the grayscale value of the pixel. The calculated grayscale values are filled into the corresponding coordinate positions of the two-dimensional matrix. All pixels are traversed until the entire matrix is filled, thus constructing the pixel grayscale matrix. The voucher parsing module extracts the declaration value and account identifier string from the text message string, calculates the gradient of the pixel grayscale matrix to locate the region of interest, and identifies the region of interest to generate the voucher amount value, transaction serial number characters and voucher generation timestamp. The specific functions of the credential parsing module are as follows: The key information regular expression extraction submodule loads a predefined regular expression library, calls an expression containing floating-point number format rules to scan the text message string, extracts a numerical sequence that conforms to the currency amount format as the declared value, and simultaneously calls an expression containing account encoding rules to scan and extract a string that conforms to the preset account length and character composition as the account identifier string. The visual focusing region localization submodule uses an edge detection operator to perform convolution operations on the pixel grayscale matrix, calculates the gradient magnitude of each pixel in the matrix, and delineates a rectangular range containing high-frequency texture features based on the distribution density of the gradient magnitude to locate the region of interest. The character optical recognition and parsing submodule performs binarization segmentation and character feature extraction on the pixel array in the region of interest, compares the extracted features with a preset financial character template library, identifies the numerical sequence representing the transaction amount and generates the voucher amount value, identifies the alphanumeric combination representing the unique transaction number and generates the transaction serial number character, and identifies the date and time string representing the transaction time and generates the voucher generation timestamp. The logical risk control module establishes an amount consistency mark based on the declared value and the voucher amount value, hashes the transaction serial number characters to construct a transaction fingerprint and compares the transaction fingerprint to establish a unique mark, and generates a verification pass status instruction based on the interval between the voucher generation timestamp and the message reception timestamp, the amount consistency mark and the unique mark. The instruction execution module, in response to the verification pass status instruction, retrieves the payment interface address, fills the account identifier string and the voucher amount into the template to construct a standard recharge request message, sends the standard recharge request message to the third-party payment gateway, and records the transaction log; The specific functions of the instruction execution module are as follows: The routing policy matching submodule parses the prefix encoding feature of the account identifier string, searches for the service provider record corresponding to the prefix encoding feature in the local payment routing configuration table, and retrieves the payment interface address corresponding to the service provider. The message security encapsulation submodule loads the standard message template of the corresponding service provider, maps the account identifier string to the payee field of the template, maps the voucher amount value to the transaction amount field of the template, and adds a digital signature and verification bit to construct the standard recharge request message. The gateway communication auditing submodule sends the standard recharge request message to the retrieved payment interface address via the Hypertext Transfer Security Protocol, listens for the confirmation receipt returned by the gateway, and writes a record containing the sending time, message content summary, and receipt status into an immutable log file to record the transaction log.
2. The automatic recharge system based on AI message recognition according to claim 1, characterized in that, The specific functions of the logical risk control module are as follows: The numerical consistency verification submodule obtains the declared value and the voucher amount value, calculates the absolute difference between the two, and determines whether the absolute difference is less than the system's preset floating-point tolerance threshold. If the determination result is true, the amount consistency mark is established. The transaction uniqueness deduplication submodule calls a secure hash algorithm to perform a one-way encryption operation on the transaction serial number characters, constructs a fixed-length transaction fingerprint, and uses the transaction fingerprint as a retrieval key to query the local historical transaction fingerprint database. If the query result shows that the fingerprint does not exist, the unique tag is established. The integrated timeliness decision submodule calculates the time difference between the message receiving timestamp and the voucher generation timestamp, determines whether the time difference is within a preset valid time window, and generates the verification passed status instruction when both the amount consistency mark and the uniqueness mark have been established and the time difference is valid.
3. The automatic recharge system based on AI message recognition according to claim 1, characterized in that, The process of locating the region of interest in the visual focus region localization submodule specifically includes: The pixel grayscale matrix is obtained, and the pixel grayscale matrix is scanned using horizontal Sobel convolution kernels and vertical Sobel convolution kernels respectively. Calculate the coordinates in the pixel grayscale matrix as follows: The overall gradient magnitude of the pixels The calculation formula is as follows: ; in, This represents the combined gradient magnitude. This represents the rate of change of grayscale value of that pixel in the horizontal direction. This represents the rate of change of grayscale value of that pixel in the vertical direction; Pixels whose combined gradient magnitude is greater than a preset edge threshold are marked as edge points, and the connected regions with the highest edge point density are defined as the regions of interest.
4. The automatic recharge system based on AI message recognition according to claim 2, characterized in that, The process of constructing a transaction fingerprint in the transaction uniqueness deduplication submodule specifically includes: Obtain the transaction serial number characters and generate a random salt value string containing the current system date; The transaction serial number characters are concatenated with the random salt value string to form a mixed string to be encrypted; The SHA-256 hash function is called to perform multiple rounds of iterative operations on the mixed string, generating a fixed-length 256-bit hexadecimal string to construct the transaction fingerprint.
5. The automatic recharge system based on AI message recognition according to claim 2, characterized in that, The process of generating the verification pass status instruction in the comprehensive timeliness decision-making submodule specifically includes: Obtain the voucher generation timestamp and the message reception timestamp, and convert both into long integer values in milliseconds; Calculate the absolute value of the difference between two long integer values, and determine whether the absolute value of the difference is less than the preset maximum tolerance threshold for transmission delay; Detect whether the amount matching marker and the unique marker exist in the memory; The instruction generation logic is triggered to generate the verification pass status instruction only when the absolute value of the difference is less than the threshold and the amount consistency mark and the uniqueness mark are detected simultaneously in memory.
6. The automatic recharge system based on AI message recognition according to claim 1, characterized in that, The process of recording transaction logs in the gateway communication audit submodule specifically includes: The precise system time when the standard recharge request message was sent is obtained as the request initiation time; Extract the account identifier string and the voucher amount from the standard recharge request message as key business fields; Obtain the Hypertext Transfer Protocol status code and the business processing result code in the response message body returned by the third-party payment gateway; The request initiation time, the key business fields, the Hypertext Transfer Protocol status code, and the business processing result code are combined into a text record according to a predefined log format, and the text record is appended to the daily rolling log file on the local disk to record the transaction log.
Citation Information
Patent Citations
Transaction data processing method and device and server
CN115170108A