CN113762957A - Data interaction method and system for code scanning shopping - Google Patents

Data interaction method and system for code scanning shopping Download PDF

Info

Publication number
CN113762957A
CN113762957A CN202010508148.1A CN202010508148A CN113762957A CN 113762957 A CN113762957 A CN 113762957A CN 202010508148 A CN202010508148 A CN 202010508148A CN 113762957 A CN113762957 A CN 113762957A
Authority
CN
China
Prior art keywords
data
server
thread
uploading
connection
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202010508148.1A
Other languages
Chinese (zh)
Inventor
崔阳
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Individual
Original Assignee
Individual
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Individual filed Critical Individual
Priority to CN202010508148.1A priority Critical patent/CN113762957A/en
Publication of CN113762957A publication Critical patent/CN113762957A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q20/00Payment architectures, schemes or protocols
    • G06Q20/38Payment protocols; Details thereof
    • G06Q20/382Payment protocols; Details thereof insuring higher security of transaction
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q20/00Payment architectures, schemes or protocols
    • G06Q20/38Payment protocols; Details thereof
    • G06Q20/40Authorisation, e.g. identification of payer or payee, verification of customer or shop credentials; Review and approval of payers, e.g. check credit lines or negative lists
    • G06Q20/401Transaction verification
    • G06Q20/4014Identity check for transactions
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q30/00Commerce
    • G06Q30/06Buying, selling or leasing transactions
    • G06Q30/0601Electronic shopping [e-shopping]
    • G06Q30/0633Lists, e.g. purchase orders, compilation or processing
    • G06Q30/0635Processing of requisition or of purchase orders
    • GPHYSICS
    • G07CHECKING-DEVICES
    • G07GREGISTERING THE RECEIPT OF CASH, VALUABLES, OR TOKENS
    • G07G1/00Cash registers
    • G07G1/12Cash registers electronically operated
    • G07G1/14Systems including one or more distant stations co-operating with a central processing unit
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/08Network architectures or network communication protocols for network security for authentication of entities
    • H04L63/083Network architectures or network communication protocols for network security for authentication of entities using passwords
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/08Network architectures or network communication protocols for network security for authentication of entities
    • H04L63/0876Network architectures or network communication protocols for network security for authentication of entities based on the identity of the terminal or configuration, e.g. MAC address, hardware or software configuration or device fingerprint
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/12Protocols specially adapted for proprietary or special-purpose networking environments, e.g. medical networks, sensor networks, networks in vehicles or remote metering networks
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/14Session management
    • H04L67/141Setup of application sessions
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/56Provisioning of proxy services
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/56Provisioning of proxy services
    • H04L67/565Conversion or adaptation of application format or content

Landscapes

  • Engineering & Computer Science (AREA)
  • Business, Economics & Management (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Accounting & Taxation (AREA)
  • Signal Processing (AREA)
  • General Physics & Mathematics (AREA)
  • Physics & Mathematics (AREA)
  • Finance (AREA)
  • Computer Security & Cryptography (AREA)
  • Theoretical Computer Science (AREA)
  • Strategic Management (AREA)
  • General Business, Economics & Management (AREA)
  • Computing Systems (AREA)
  • Computer Hardware Design (AREA)
  • General Engineering & Computer Science (AREA)
  • Power Engineering (AREA)
  • Medical Informatics (AREA)
  • Health & Medical Sciences (AREA)
  • General Health & Medical Sciences (AREA)
  • Development Economics (AREA)
  • Economics (AREA)
  • Marketing (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention provides a data interaction method and a data interaction system for code scanning shopping, which are used for data interaction between a code scanning shopping system and a merchant terminal, and are characterized in that the data interaction layer is used for communication between a server of the code scanning shopping system and a database of the merchant terminal, and the data interaction layer and the server are communicated by adopting an MQTT protocol in a publish/subscribe mode; the communication between the data interaction layer and the database is directly accessed by adopting an SQL method. The method and the system effectively reduce the load of the server, enable the server to be capable of centralizing order response and processing, accelerate the transaction speed, and meanwhile, the data used by the server when calculating the amount of the order can be updated automatically in time, thereby ensuring the transaction accuracy, and moreover, an identity authentication mechanism is added in data access, thereby improving the data transaction safety.

Description

Data interaction method and system for code scanning shopping
Technical Field
The invention relates to the technical field of data interaction, in particular to a data interaction method and a data interaction system for code scanning shopping.
Background
In recent years, with rapid development of the internet of things and popularization of novel mobile social software such as WeChat, a novel shopping mode of self-service retail business is gradually created. Code scanning shopping is one of core functions of self-service retail and is also a key technical support of intelligent retail. The basic process is as follows: a user scans bar codes of commodities to be purchased by using mobile devices such as mobile phones and tablet computers at merchants supporting code scanning shopping, such as shopping centers and supermarkets, and can check commodity information, know product recommendations, generate orders by self and settle accounts. Meanwhile, the merchant can push services such as preferential information, promotion activities, member information and the like to the mobile equipment of the user at irregular intervals, so that the shopping experience of the user can be improved, the labor cost of the merchant can be reduced, an effective long contact mechanism can be established between the merchant and the user, and more accurate services can be provided for the user. Because of this, more and more merchants have begun using code-scanning shopping systems. The hardware part of the code scanning shopping system mainly comprises a server, a merchant terminal and user mobile equipment. The server is responsible for processing orders, the merchant terminal is responsible for storing commodity information, user information and order information, and the mobile device is responsible for providing a user interface for operating the code scanning shopping system for a user.
However, in the application process of the existing code scanning shopping system, there is a phenomenon that a user's code scanning shopping experience is affected to some extent, including external factors such as hardware configuration of a mobile device, 4G or Wi-Fi signal strength and bandwidth, and the number of users who shop by themselves within a certain time period, and the core design of the system itself, as shown in fig. 1, the communication process between a payment device and a system server in the existing system, where the design of interactive operation between the system server and a database is simple, and there are the following disadvantages:
(1) although the method is easy to implement, the server cannot be separated from the low-speed and frequent database operation, and the server load is too heavy, which may affect the efficiency of code scanning shopping.
(2) The problem of timely and efficient updating of server commodity information is not considered, and the server may use expired and wrong data when calculating the amount of the order.
(3) The server and merchant terminal are not considered to be deployed in different networks, and may be limited in utility in some situations.
In view of the shortcomings of the core design of the existing code scanning system, a new technical scheme is required to be provided to improve the experience of the user, which includes the following performance indexes:
(1) and the response is quick. The direct reason why the user chooses to shop by scanning the code is to save the queuing time and energy of settlement, and if the order response time is too long during the code scanning shopping and even is higher than the queuing time, the shopping desire of the user can be greatly reduced, and the user can give up the shopping. Therefore, the response of the code scanning shopping system server to the order has to have real-time performance and quickness, and is strictly controlled within the tolerance range of the user.
(2) Accuracy of the transaction data. The price of the commodity is changed rapidly, the price of the same commodity is different on different dates, even in different time periods of a day and along with activities such as sales promotion and discount, and therefore the price of the commodity needs to be updated in time by the code scanning shopping system server, and the total amount of the order commodity obtained through calculation is guaranteed to be completely consistent with the actual amount of money. Meanwhile, the completed order data must be timely and accurately recorded in the database, so as to provide data reference for the merchant to analyze the sales condition and the user behavior.
(3) Security of the transaction process. Code-scanning shopping involves financial activities with greater risk. The data transmitted during the transaction process must be secured to prevent leakage.
Disclosure of Invention
In view of the problems of the prior art, the inventor considers that an improved technical scheme is provided, and a data interaction method and a data interaction system for code scanning shopping are designed for the improved technical scheme, and the specific technical means is as follows:
the invention provides a data interaction method for code scanning shopping, which is used for data interaction between a code scanning shopping system and a merchant terminal.
The interaction between the data interaction layer and the server and the database at least comprises the following steps:
s1: after the main thread of the data interaction layer is started, server connection is carried out, and the data interaction layer tries to establish MQTT connection with the server;
s2: if the MQTT connection is successfully established in the step S1, performing identity authentication on the merchant terminal;
s3: if the identity verification of the merchant terminal passes in the step S2, initializing the data interaction layer, where the initialization includes sending an MQTT subscription theme of the merchant terminal, setting a timer to 0, creating a data timed upload sub-thread, creating a data write-back sub-thread, setting a parameter value, and performing MQTT connection monitoring to the server;
s4, when the timer starts to count time and reaches the uploading time point in the step S3, the data timing uploading sub thread recovers the operation, the data timing uploading is carried out, and the related data are read from the database and uploaded to the server;
s5: when the data meeting the MQTT subscription theme of the merchant terminal in step S3 reaches the data interaction layer after being forwarded by the server, the data interaction layer analyzes the category information in the data header information. If the data is confirmed to be order data, the data write-back sub-thread is started to write back the data, and the order data is written into the database.
Further, an access proxy is also performed in the server connection, and the specific process is as follows:
s1-1: detecting the communication state of the merchant terminal and the server under the condition that the network connection is normal, and directly trying to establish MQTT connection if the communication is normal;
s1-2: if the connection test in the step S2-1 fails, performing the access proxy, that is, trying to establish MQTT connection with the server again according to the preset proxy server IP address and port number;
s1-3: if the data interaction layer and the server successfully establish the MQTT connection through the step S2-1 or the step S2-2, the server connection is normally ended, and if the connection fails, a warning is issued.
Further, the authentication is used to authenticate the identity of the merchant terminal after the data interaction layer establishes MQTT connection with the server, and the subsequent functions can be executed after the authentication is passed, where the authentication process includes:
s2-1: sending verification information of the merchant terminal to the server, and waiting for a verification result returned by the server;
s2-2: if the verification is passed in the step S2-1, continuously uploading the MQTT subscription theme of the merchant terminal to the server, and if the verification is not passed, sending error-reporting prompt information and terminating the established MQTT connection.
Further, the data regular uploading is provided with a data regular uploading sub-thread, which is used for automatically reading various data required by the server when processing the order from the database and uploading the data to the server when a preset uploading time point arrives, and the flow of the data regular uploading is as follows:
s4-1: the timer starts timing, and when the uploading time point is not reached, the data timing uploading thread is in a blocking state; when the uploading time point arrives, the data timed uploading sub-thread recovers running and tries to connect with the database in an SQL mode;
s4-2: when the connection between the data timing uploading sub-thread and the database is successful in the step S4-1, reading data to be uploaded from the database and converting the data into a JSON format, adding head information to the uploaded data, and uploading the data to the server according to a preset MQTT release theme;
s4-3: after the main thread of the data interaction layer receives the information that the data returned by the server is correctly received, the data timing uploading sub-thread enters a blocking state, and the timer is reset to 0 and then starts a new round of timing; when the main thread of the data interaction layer receives data verification error information sent by the server or does not receive confirmation information that the data returned by the server is correctly received within a specified time, the data timing uploading sub-thread retries to upload the data;
s4-4: and when the number of times of repeatedly trying to upload data by the data timing upload sub-thread reaches the maximum value, stopping the upload task at the current time point by the data timing upload sub-thread, waiting for the arrival of the next upload time point, and sending out alarm information.
Further, the data write-back is provided with a data write-back sub-thread, which is used for automatically acquiring and synchronously updating successfully completed order data which is uploaded to the server by the code scanning shopping system into the database of the merchant terminal, and the data write-back process comprises the following steps:
s5-1: when data subscribed by the merchant terminal is sent to the server, the server forwards the data to the data interaction layer, and after a main thread of the data interaction layer receives the data, the class information in the data header information is analyzed to judge whether the data is order data;
s5-2: if the data sent in step S5-1 is order data, writing the data into an order buffer queue, and waking up the data write-back sub-thread, wherein the order buffer queue is set as a critical resource;
s5-3: the data write-back sub-thread tries to connect with the database in an SQL mode, and after the connection is successful, the order data is written into the database after being converted into a format;
s5-4: and when the order buffer queue is empty, the data write-back sub-thread enters a blocking state.
Further, the MQTT connection monitoring reestablishes a connection when detecting an MQTT connection abnormal interruption with the server during the operation of the main thread of the data interaction layer; the MQTT connection monitoring detects the connection state of the data interaction layer and the server at regular time according to a set time interval; when the MQTT connection is found to be interrupted, trying to reestablish the server connection; and if the reconnection times exceed the maximum value, a warning message is sent out.
Furthermore, the invention provides a data interaction system for code scanning shopping, which is used for finishing data interaction between a code scanning shopping system and a merchant terminal, and is characterized in that the data interaction system for communication between a server of the code scanning shopping system and a database of the merchant terminal at least comprises a server connection module, an identity verification module, a data timing uploading module, a data write-back module and an MQTT connection monitoring module; the data interaction system communicates with the server by adopting an MQTT protocol of a publish/subscribe mode; the data interaction system is communicated with the database and directly accessed by adopting an SQL method.
Further, the operation flow among the modules of the data interaction system is as follows: after a main thread of the data interaction system is started, calling the server connection module to try to establish MQTT connection with the server; if the MQTT connection is successfully established, calling the identity authentication module to perform identity authentication of the merchant terminal; if the identity authentication of the merchant terminal passes, the data interaction system carries out data initialization; the data initialization comprises the steps of sending an MQTT subscription theme of a merchant terminal to the server, setting a timer to be 0, creating a data timing uploading sub-thread, creating a data writing back sub-thread, setting a parameter value and calling an MQTT connection monitoring module; when the timer starts to time and reaches an uploading time point, the data timing uploading sub-thread recovers running, the data timing uploading module is called, and relevant data are read from the database and uploaded to the server; and when the item value of the order data subscribed by the merchant terminal forwarded by the server reaches the data interaction system, the data write-back sub-thread is started, and the data write-back module is called to write the order data into the database.
Further, the server connection module further includes an access agent sub-module, and the specific operation flow is as follows: detecting the communication state of the merchant terminal and the server under the condition that the network connection is normal, and directly trying to establish MQTT connection if the communication is normal; if the test connection fails, starting the access agent submodule, and trying to establish MQTT connection with the server again according to the preset IP address and port number of the agent server; if the data interaction system and the server successfully establish the MQTT connection, the server connection module is normally ended, and if the connection fails, a warning is given out.
The identity authentication module is further configured to perform identity authentication on the merchant terminal after the data interaction system establishes MQTT connection with the server, and perform subsequent functions after the authentication is passed, where the process of the identity authentication module is as follows: the identity authentication module sends authentication information of the merchant terminal to the server and waits for the server to return an authentication result; if the verification is passed, the MQTT subscription theme of the merchant terminal is continuously uploaded to the server, if the verification is not passed, error reporting prompt information is sent out, and the established MQTT connection is terminated.
The data timing uploading module is further provided with a data timing uploading sub-thread, and is used for automatically reading various data required by the server when processing the order from the database when a preset uploading time point is reached, and uploading the data to the server, wherein the flow of the data timing uploading module is as follows: the timer starts timing, and when the uploading time point is not reached, the data timing uploading thread is in a blocking state; when the uploading time point arrives, the data timed uploading sub-thread recovers running and tries to connect with the database in an SQL mode; when the connection between the data timing uploading sub-thread and the database is successful, reading data to be uploaded from the database, converting the data into a JSON format, adding head information to the uploaded data, and uploading the data to the server according to a preset MQTT release theme; after the main thread of the data interaction system receives the information that the data returned by the server is correctly received, the data timing uploading sub-thread enters a blocking state, and the timer is reset to 0 and then starts a new round of timing; when a main thread of the data interaction system receives data verification error information sent by the server or does not receive confirmation information that data returned by the server is correctly received within a specified time, the data timing uploading sub-thread retries to upload data; and when the number of times of repeatedly trying to upload data by the data timing upload sub-thread reaches the maximum value, stopping the upload task at the current time point by the data timing upload sub-thread, waiting for the arrival of the next upload time point, and sending out alarm information.
Further, the data write-back module includes a data write-back sub-thread, which is used to automatically acquire and synchronously update successfully completed order data uploaded to the server by the code scanning shopping system into the database of the merchant terminal, and the data write-back module has the following processes: when the data subscribed by the merchant terminal is sent to a server, the server forwards the data to the data interaction system; after receiving the data, the main thread of the data interaction system analyzes the category information in the data header information and judges whether the data is order data; if the sent data is order data, writing the data into an order buffer queue, and simultaneously awakening the data write-back sub-thread; wherein the order buffer queue is set as a critical resource; the data write-back sub-thread tries to connect with the database in an SQL mode, and after the connection is successful, the order data is written into the database after being converted into a format; and when the order buffer queue is empty, the data write-back sub-thread enters a blocking state.
The MQTT connection monitoring module is further configured to reestablish a connection when detecting an abnormal interruption of an MQTT connection with the server during a running period of a main thread of the data interaction system; the MQTT connection monitoring module detects the connection state of the data interaction system and the server at regular time according to a set time interval; when the MQTT connection is interrupted, trying to call the server connection module to reestablish the connection; and if the reconnection times exceed the maximum value, a warning message is sent out.
Further, the authentication information of the authentication module includes a merchant terminal ID and an authentication password.
Further, the data interaction system and the database may be deployed on the same merchant terminal, or the data interaction system may be deployed separately.
The data interaction method and the data interaction system for code scanning shopping have the following beneficial effects.
(1) And response rapidness is improved. The main work of the code scanning shopping system server comprises two parts of processing order data submitted by a user and reading and writing a database. Because the database reading and writing operations are very frequent and slow, if the server intervenes in the database reading and writing too much, the performance of the server is necessarily reduced, and the situations of untimely response and order processing are caused. Therefore, the data interaction layer is arranged in the code scanning shopping system, the server is separated from the read-write database operation, the data interaction layer is responsible for reading and writing the database of the merchant terminal according to the instruction sent by the server, and the server can concentrate on the processing of order data, so that the response speed of the code scanning shopping system is improved.
(2) The accuracy of the transaction data is improved. The commodity information stored in the code scanning shopping system server needs to be updated in time, otherwise, the problem of wrong calculated amount can occur. Aiming at the point, the invention designs a data timing uploading function, can automatically update the commodity information stored by the server in time at the time point specified by the merchant, and enables the server to use the latest data each time when processing the order, thereby improving the accuracy of the transaction amount.
(3) And the safety of the transaction process is improved. When the merchant terminal logs in the server, the identity verification function in the data interaction layer requires the server to verify the identity of the merchant terminal, and only when the identity information stored in the merchant terminal and the identity information stored in the server are consistent, the follow-up operation can be executed, so that identity falsifying and data hijacking can be effectively avoided, and the safety of the transaction process is improved.
(4) The problem of different networks in different regions is solved. By expanding the support of the socks5 protocol in the MqttClient class, the data interaction layer of the invention has the function of access proxy. When the condition that the merchant terminal and the server are in different networks or cannot be connected due to the firewall setting and the like is detected, the merchant terminal and the server can still access each other through the preset proxy server, and the applicability of the code scanning shopping system to the merchant terminal and the server in different regions and networks is improved.
(5) Saving network resources. Considering that the bandwidth of the code scanning shopping environment is usually limited, the invention adopts the MQTT protocol based on the publish/subscribe mode, and can provide real-time and reliable messaging service between the code scanning shopping system server and the database of the merchant terminal with less resource and bandwidth occupation.
(6) The operation efficiency is high, and the deployment is simple. The invention adopts the design idea of the middleware technology and the high-performance programming method, and has the advantages of small code quantity after programming realization, high operation efficiency, simple installation and uninstallation, and easy popularization and application.
Drawings
FIG. 1 is a schematic diagram illustrating a communication manner between a payment device and a system server in a code-scanning shopping system in the prior art.
Fig. 2 is a schematic diagram of an interaction mode of a data interaction layer for communication between a server of a code-scanning shopping system and a database of a merchant terminal in the invention.
FIG. 3 is a flowchart illustrating the overall operation of the data interaction layer according to the present invention.
Fig. 4 is a flowchart illustrating a server connection method of a data interaction layer according to the present invention.
Fig. 5 is a flowchart illustrating an operation of the authentication method of the data interaction layer according to the present invention.
Fig. 6 is a flowchart illustrating the operation of the data timing uploading method of the data interaction layer according to the present invention.
FIG. 7 is a flowchart illustrating a data write-back method of the data interaction layer according to the present invention.
FIG. 8 is a flowchart illustrating the operation of the MQTT connection monitoring method of the data interaction layer according to the present invention.
FIG. 9 is a design diagram of an interactive interface of the data interactive system of the present invention.
Detailed Description
Fig. 2 is a schematic diagram showing an interaction mode of a data interaction layer in communication between a server of a code-scanning shopping system and a database of a merchant terminal according to the present invention. The invention adds a data interaction layer between a server of the original code scanning shopping system and a database of a merchant terminal, and the data interaction layer is used as a communication intermediate layer between the server of the code scanning shopping system and the database of the merchant terminal and at least comprises a server connection, an identity verification function module, a data timing uploading function module, a data write-back function module and an MQTT connection monitoring function module. The data interaction layer communicates with the server by adopting an MQTT protocol in a publish/subscribe mode, which requires that the server and the merchant terminal both need to support the MQTT protocol, and the data interaction layer communicates with the database by directly adopting an SQL method for connection. The data interaction layer has the advantages of low coupling degree with other parts of the system, and easy deployment and function expansion. After the data interaction layer is added, the layer manages commodity data interaction operation between the server and the merchant terminal database, so that the server is separated from low-speed and frequent database operation, the server load is effectively reduced, and the server can be centralized in order response and processing. Meanwhile, the data used by the server when calculating the amount of the order should be updated in time and automatically, and the original manual and semi-manual updating mode is replaced, so that inconsistent errors are avoided.
Fig. 3 is a flowchart illustrating the overall operation of the data interaction layer according to the present invention. After a main thread of a data interaction layer program is started, server connection is carried out, whether an access agent method needs to be started or not is determined according to the connection condition of the server and a merchant terminal, and then MQTT connection is tried to be established with the server. And if the verification is successful, the identity verification of the merchant terminal is carried out at the server side, and the initialization work is further completed after the verification, wherein the initialization work comprises the steps of sending an MQTT subscription theme of the merchant terminal to the server, setting a timer to be 0, creating a data timing uploading sub-thread and a data write-back sub-thread and setting other parameter values. And after the initialization is finished, the timer starts to time, and when the uploading time point is reached, the data timing uploading sub-thread reads related data from the database of the merchant terminal and uploads the data to the server. When the data of the business terminal MQTT subscription theme forwarded by the server reaches the data interaction layer, the data interaction layer analyzes the category information in the data header information. If the data is confirmed to be order data, the data write-back sub-thread is started and writes the order data into a merchant terminal database. If the main thread detects interruption of the MQTT connection with the server during operation, the main thread automatically tries to reestablish the MQTT connection. If the reconnection times exceed the maximum value, a warning is sent out, so that the data interaction layer always keeps in a running state during the working period of the code scanning shopping system.
Fig. 4 is a flowchart illustrating a method for connecting a server in a data interaction layer according to the present invention. The server connection module is used for establishing MQTT connection between the data interaction layer and the server, comprises an access agent module, and has the function that when the server and the merchant terminal are in different networks or firewalls and cannot directly establish the MQTT connection, the connection can still be completed through a preset agent server, for example, a socks5 protocol can be selected to support the access agent. The concrete mode is as follows: firstly, the communication state of a merchant terminal and a server is checked under the condition that the network connection is normal, if the connection state is normal, the MQTT connection can be directly tried to be established, if the connection state is failed, an access agent is started, and the MQTT connection with the server is tried again according to the preset IP address and the preset port number of the agent server. If the connection is successful, the module is normally ended, and if the connection is failed, a warning is given out. The server connection module can establish MQTT connection by using a method provided by MqttClient class of an MQTTnet class library (the version number is 2.4.5).
Fig. 5 is a flowchart illustrating an operation of the authentication method of the data interaction layer according to the present invention. The identity authentication module firstly authenticates the identity of the merchant terminal after requiring the data interaction layer to establish MQTT connection with the server, and can execute subsequent functions after the authentication is passed, so that the identity of a subscriber can be determined in advance in a publish/subscribe mode, order data forwarded by the server is prevented from being hijacked, and the safety of a payment process is ensured. The concrete mode is as follows: after the data interaction layer establishes MQTT connection with the server, the identity authentication module sends the merchant terminal ID and the authentication password of the merchant terminal to the server, and then waits for the server to return an authentication result. If the verification is passed, the MQTT subscription theme of the merchant terminal is continuously uploaded to the server, if the verification is not passed, error warning information is sent out, the previously established MQTT connection is terminated, and the operation of the identity verification module is ended.
Fig. 6 is a flowchart illustrating a method for uploading data at regular time according to the data interaction layer of the present invention. When the preset uploading time point arrives, the data timing uploading module automatically reads various data required by the server when the server processes the order from the database of the merchant terminal, such as: commodity price, discount and user grade data are uploaded to the server, the original manual and semi-manual updating mode is replaced, and server data are updated timely and automatically, so that the accuracy of processing orders and generating transaction amount by the server is guaranteed. The concrete mode is as follows: and a timer of the data timing uploading module is responsible for timing, when the uploading time point is not reached, the data timing uploading sub-thread is in a blocking state, and when the uploading time point is reached, the data timing uploading sub-thread recovers running and tries to be connected with the database in an SQL mode. And when the connection between the data timing uploading sub-thread and the database is successful, reading data to be uploaded from the database, converting the data into a JSON format, adding head information to the uploaded data, and uploading the data to the server according to a preset MQTT release theme. And if the main thread of the data interaction layer receives the information that the data replied by the server is correctly received, the sub-thread of the data timing uploading is enabled to enter a blocking state, the timer is reset to 0, and a new round of timing is started. On the contrary, if the main thread of the data interaction layer receives data verification error information sent by the server or does not receive confirmation information of the server within the specified time, the data timing uploading sub-thread retries the uploading of the data. And when the number of retries of uploading reaches the maximum value, abandoning the uploading task at the time point, waiting for the arrival of the next uploading time point, and sending out alarm information. At this time, the administrator can check the system status according to the warning information, and decide whether to update the system manually or wait for the next uploading time point to update the data automatically.
Fig. 7 is a flowchart illustrating a data write-back method of the data interaction layer according to the present invention. The data write-back module writes the successfully completed order data into the database of the merchant terminal. Because the MQTT protocol of the publish/subscribe mode is adopted, when a user uploads order information to the server at the mobile payment equipment terminal, the data interaction layer can automatically and synchronously acquire the order data and write the order data into the database of the merchant terminal, and the server only needs to forward the corresponding order data in the process without directly intervening the operation of the database, so that the load of the server is greatly reduced, and the response speed of the system is improved. The concrete mode is as follows: when the data (JSON format) subscribed by the merchant terminal arrives at the server, the server forwards the data to the data interaction layer. And when the main thread of the data interaction layer receives the data, analyzing the category information in the data head information and judging whether the data is order data or not. And if the order data is the order data, writing the data back into the order buffer queue, simultaneously awakening the data write back sub-thread of the data write back module, trying to connect the data write back sub-thread with the database in an SQL mode, and writing the order data into the database after the order data is converted into the format after the connection is successful. And because a plurality of order data can arrive at the same time, in order to prevent read-write errors, the order buffer queue is required to be set as a critical resource for protection, and the synchronization of the main thread and the data write-back sub-thread is ensured. And then when the order buffer queue is empty, the data write back sub-thread enters a blocking state.
Fig. 8 is a flowchart illustrating the MQTT connection monitoring method of the data interaction layer according to the present invention. The MQTT connection monitoring module is used for reestablishing connection when the main thread of the data interaction layer detects that the MQTT connection with the server is abnormally interrupted during operation. The MQTT connection monitoring module can detect the connection state between the data interaction layer and the server every 300 seconds (the interval value can be set by an administrator) by using events such as ClientConnected and ClientDisconnected of MqttClient classes. When the MQTT connection is interrupted, immediately trying to call the server connection module to reestablish the connection, and if the reconnection times exceed the maximum value, giving an alarm.
FIG. 9 is a diagram of an interactive interface design of the data interactive system of the present invention. The login interface for starting and operating the data interaction system is displayed, and comprises the IP information of the server, the login information such as the type, IP, name and login name of the database of the merchant terminal. And after the correct login information is filled, the data interaction system can be normally started.
The invention provides a data interaction layer which can be used as a code scanning shopping system server and a merchant terminal database, aiming at realizing the separation of a server and a low-speed and frequent database operation in a code scanning shopping system. The method and the system effectively reduce the load of the server, enable the server to be centralized in order response and processing, and accelerate the transaction speed. Meanwhile, the data used by the server when calculating the amount of the order can be updated in time and automatically, and the transaction accuracy is ensured. And an identity authentication mechanism is added in data access, so that the data transaction safety is improved. Hardware requirements on the merchant terminal in the code scanning transaction system are greatly reduced, so that the merchant deployment cost is greatly reduced, the workload of managers is reduced, the shopping experience is improved, and greater economic value is created.

Claims (10)

1. A data interaction method for code scanning shopping is used for data interaction between a code scanning shopping system and a merchant terminal, and is characterized in that: a data interaction layer for communication between the server of the code scanning shopping system and the database of the merchant terminal, wherein the data interaction layer and the server adopt an MQTT protocol in a publish/subscribe mode for communication; the communication between the data interaction layer and the database is directly accessed by adopting an SQL method;
the interaction between the data interaction layer and the server and the database at least comprises the following steps:
s1: after a main thread of the data interaction layer is started, server connection is carried out, and the data interaction layer tries to establish MQTT connection with the server;
s2: if the MQTT connection is successfully established in the step S1, performing identity verification on the merchant terminal;
s3: if the identity authentication of the merchant terminal passes in the step S2, the data interaction layer initializes; the initialization comprises the steps of sending an MQTT subscription theme of the merchant terminal to the server, setting a timer to be 0, creating a data timing uploading sub-thread, creating a data write-back sub-thread, setting a parameter value and carrying out MQTT connection monitoring;
s4, when the timer starts to count time and reaches the uploading time point in the step S3, the data timing uploading sub thread recovers to run, the data timing uploading is carried out, and relevant data are read from the database and uploaded to the server;
s5: and if the data is confirmed to be order data, the data write-back sub-thread is started to write back the data, and the order data is written into the database.
2. The data interaction method for code-scanning shopping as claimed in claim 1, wherein:
the server connection also carries out access proxy, and the specific flow is as follows:
s1-1: detecting the communication state of the merchant terminal and the server under the condition that the network connection is normal, and directly trying to establish MQTT connection if the communication is normal;
s1-2: if the connection test in the step S1-1 fails, the access proxy is carried out, namely, the MQTT connection is tried to be established with the server again according to the preset proxy server IP address and the preset port number;
s1-3: if the data interaction layer successfully establishes the MQTT connection with the server through the step S1-1 or the step S1-2, the server connection is normally ended, and if the connection fails, a warning is issued.
3. The data interaction method for code-scanning shopping as claimed in claim 1, wherein:
the identity authentication is used for firstly performing identity authentication on the merchant terminal after the MQTT connection is established between the data interaction layer and the server, and the follow-up function can be executed after the authentication is passed, wherein the identity authentication process comprises the following steps:
s2-1: sending verification information of the merchant terminal to the server, and waiting for a verification result returned by the server;
s2-2: if the verification is passed in the step S2-1, continuously uploading the MQTT subscription theme of the merchant terminal to the server, and if the verification is not passed, sending error-reporting prompt information and terminating the established MQTT connection.
4. The data interaction method for code-scanning shopping as claimed in claim 1, wherein:
the data timing uploading device is provided with a data timing uploading sub-thread and is used for automatically reading various data required by the server when an order is processed from the database and uploading the data to the server when a preset uploading time point is reached, and the data timing uploading process comprises the following steps:
s4-1: the timer starts timing, and when the uploading time point is not reached, the data timing uploading sub-thread is in a blocking state; when the uploading time point is reached, the data timed uploading sub-thread recovers running and tries to be connected with the database in an SQL mode;
s4-2: when the data timing uploading sub-thread is successfully connected with the database in the step S4-1, reading data to be uploaded from the database, converting the data into a JSON format, adding head information to the uploaded data, and uploading the data to the server according to a preset MQTT release theme;
s4-3: after the main thread of the data interaction layer receives the information that the data returned by the server is correctly received, the data timing uploading sub-thread enters a blocking state, and the timer is reset to 0 and then starts a new round of timing; when the main thread of the data interaction layer receives data verification error information sent by the server or does not receive confirmation information that the data returned by the server is correctly received within a specified time, the data timing uploading sub-thread retries to upload the data;
s4-4: and when the number of times of repeatedly trying to upload data by the data timing uploading sub-thread reaches the maximum value, stopping the uploading task at the time point by the data timing uploading sub-thread, waiting for the next uploading time point to arrive, and sending out alarm information.
5. The data interaction method for code-scanning shopping as claimed in claim 1, wherein:
the data write-back is provided with a data write-back sub-thread and is used for automatically acquiring and synchronously updating successfully completed order data uploaded to the server by the code scanning shopping system into a database of the merchant terminal, and the data write-back process comprises the following steps:
s5-1: when data which accord with the subscription theme of the merchant terminal is sent to the server, the server forwards the data to the data interaction layer; after receiving the data, the main thread of the data interaction layer analyzes the category information in the data header information and judges whether the data is order data;
s5-2: if the data sent in the step S5-1 is order data, writing the data into an order buffer queue, and simultaneously waking up the data write-back sub-thread; wherein the order buffer queue is set as a critical resource;
s5-3: the data write-back sub-thread tries to connect with the database in an SQL mode, and when the connection is successful, the order data is written into the database after being converted into a format;
s5-4: and when the order buffer queue is empty, the data write-back sub-thread enters a blocking state.
6. The data interaction method for code-scanning shopping as claimed in claim 1, wherein:
the MQTT connection monitoring is used for reestablishing connection when the MQTT connection with the server is detected to be abnormally interrupted during the operation of the main thread of the data interaction layer; the MQTT connection monitoring detects the connection state of the data interaction layer and the server at regular time according to a set time interval; when the MQTT connection is found to be interrupted, trying to carry out the server connection again; and issuing a warning message if the number of reconnections exceeds the maximum value.
7. A data interaction system for scanning sign indicating number shopping for accomplish scan sign indicating number shopping system and merchant terminal machine between data interaction, its characterized in that: the data interaction system used for communication between the server of the code scanning shopping system and the database of the merchant terminal at least comprises a server connection module, an identity verification module, a data timing uploading module, a data write-back module and an MQTT connection monitoring module; the data interaction system communicates with the server by adopting an MQTT protocol of a publish/subscribe mode; the data interaction system is communicated with the database and directly accessed by adopting an SQL method;
the operation flow among the modules of the data interaction system is as follows: after a main thread of the data interaction system is started, calling the server connection module to try to establish MQTT connection with the server; if the MQTT connection is successfully established, calling the identity authentication module to perform identity authentication of the merchant terminal; if the identity verification of the merchant terminal passes, the data interaction system carries out data initialization; the data initialization comprises the steps of sending an MQTT subscription theme of the merchant terminal to the server, setting a timer to be 0, creating a data timing uploading sub-thread, creating a data write-back sub-thread, setting a parameter value and calling an MQTT connection monitoring module; when the timer starts to time and reaches an uploading time point, the data timing uploading sub-thread recovers running, the data timing uploading module is called, and relevant data are read from the database and uploaded to the server; and if the data is confirmed to be order data, the data write-back sub-thread is started, and the data write-back module is called to write the order data into the database.
8. The data interaction system for code-scanning shopping as claimed in claim 7, wherein:
the server connection module also comprises an access agent submodule, and the specific operation flow is as follows: detecting the communication state of the merchant terminal and the server under the condition that the network connection is normal, and directly trying to establish MQTT connection if the communication is normal; if the test connection fails, starting the access agent submodule, and trying to establish MQTT connection with the server again according to the preset IP address and port number of the agent server; if the data interaction system and the server successfully establish the MQTT connection, the server connection module is normally ended, and if the connection fails, a warning is sent out;
the identity verification module is used for firstly performing identity verification on the merchant terminal after the data interaction system establishes MQTT connection with the server, and the follow-up functions can be executed after the verification is passed, wherein the flow of the identity verification module is as follows: the identity authentication module sends authentication information of the merchant terminal to the server and waits for the server to return an authentication result; if the verification is passed, continuously uploading the MQTT subscription theme of the merchant terminal to the server, if the verification is not passed, sending error-reporting prompt information and terminating the established MQTT connection;
the data timing uploading module is provided with a data timing uploading sub-thread and is used for automatically reading various data required by the server when processing orders from the database when a preset uploading time point is reached, and uploading the data to the server, and the flow of the data timing uploading module is as follows: the timer starts timing, and when the uploading time point is not reached, the data timing uploading sub-thread is in a blocking state; when the uploading time point is reached, the data timed uploading sub-thread recovers running and tries to be connected with the database in an SQL mode; when the data timing uploading sub-thread is successfully connected with the database, reading data to be uploaded from the database, converting the data into a JSON format, adding head information to the uploaded data, and uploading the uploaded data to the server according to a preset MQTT release theme; after the main thread of the data interaction system receives the information that the data returned by the server is correctly received, the data timing uploading sub-thread enters a blocking state, and the timer is reset to 0 and then starts a new round of timing; when a main thread of the data interaction system receives data verification error information sent by the server or does not receive confirmation information that data returned by the server is correctly received within a specified time, the data timing uploading sub-thread retries uploading data; when the number of times of repeatedly trying to upload data by the data timing uploading sub-thread reaches the maximum value, stopping the uploading task at the current time point by the data timing uploading sub-thread, waiting for the next uploading time point to arrive, and sending out warning information;
the data write-back module comprises a data write-back sub-thread and is used for automatically acquiring and synchronously updating successfully completed order data uploaded to the server by the code scanning shopping system into a database of the merchant terminal, and the data write-back module has the following processes: when data which accord with the business terminal subscription theme is sent to the server, the server forwards the data to the data interaction system; after receiving the data, the main thread of the data interaction system analyzes the category information in the data header information and judges whether the data is order data; if the sent data is order data, writing the data into an order buffer queue, and simultaneously awakening the data write-back sub-thread; wherein the order buffer queue is set as a critical resource; the data write-back sub-thread tries to connect with the database in an SQL mode, and when the connection is successful, the order data is written into the database after being converted into a format; when the order buffer queue is empty, the data write-back sub-thread enters a blocking state;
the MQTT connection monitoring module is used for reestablishing connection when the MQTT connection with the server is detected to be abnormally interrupted during the running period of the main thread of the data interaction system; the MQTT connection monitoring module detects the connection state of the data interaction system and the server at regular time according to a set time interval; when the MQTT connection is interrupted, attempting to call the server connection module to reestablish the connection; and if the reconnection times exceed the maximum value, a warning message is sent out.
9. The data interaction system for code-scanning shopping as claimed in claim 7 or 8, wherein:
the authentication information of the identity authentication module comprises a merchant terminal ID and an authentication password.
10. The data interaction system for code-scanning shopping as claimed in claim 7 or 8, wherein:
the data interaction system and the database may be deployed on the same merchant terminal, or the data interaction system may be deployed separately.
CN202010508148.1A 2020-06-05 2020-06-05 Data interaction method and system for code scanning shopping Pending CN113762957A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010508148.1A CN113762957A (en) 2020-06-05 2020-06-05 Data interaction method and system for code scanning shopping

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010508148.1A CN113762957A (en) 2020-06-05 2020-06-05 Data interaction method and system for code scanning shopping

Publications (1)

Publication Number Publication Date
CN113762957A true CN113762957A (en) 2021-12-07

Family

ID=78785306

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010508148.1A Pending CN113762957A (en) 2020-06-05 2020-06-05 Data interaction method and system for code scanning shopping

Country Status (1)

Country Link
CN (1) CN113762957A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115208585A (en) * 2022-09-07 2022-10-18 环球数科集团有限公司 Data interaction method and system based on zero knowledge proof

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101848236A (en) * 2010-05-06 2010-09-29 北京邮电大学 Real-time data distribution system with distributed network architecture and working method thereof

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101848236A (en) * 2010-05-06 2010-09-29 北京邮电大学 Real-time data distribution system with distributed network architecture and working method thereof

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
崔阳: "基于MQTT协议的扫码支付中间件设计与实现", 《现代计算机》, vol. 2019, no. 20, pages 82 - 85 *

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115208585A (en) * 2022-09-07 2022-10-18 环球数科集团有限公司 Data interaction method and system based on zero knowledge proof

Similar Documents

Publication Publication Date Title
WO2019196244A1 (en) Real-time order callback method and system
CN104156863A (en) OTA website order processing system and method
CN111459575A (en) Call request processing method and device and computer storage medium
CN111176858A (en) Data request processing method and device
US7729948B1 (en) Systems and methods for enabling customer care assistance with self-service transactions
CN104182683A (en) Method, device and system for monitoring online transactions
CN111176866A (en) Data interaction method and electronic equipment
CN111311200B (en) Management method and device for guest consultation work order platform
CN113762957A (en) Data interaction method and system for code scanning shopping
CN112953769B (en) Data transmission method, device, computer system and readable storage medium
CN111198773B (en) Message-based application communication method and device
US9577967B2 (en) Method and system for managing an informational site using a social networking application
CN105761069B (en) POS terminal communication method and system
CN109670952B (en) Collecting and paying transaction platform
CN109118822B (en) Intelligent parking management method and platform
CN111259032A (en) Service processing method and device
CN110751464A (en) Information prompting method, device, equipment and storage medium
CN105072166A (en) Service outlet and customer real-time interactive communication method and device
US20140279212A1 (en) Multi-channel wireless pre-approval system
CN111192034B (en) Method and device for processing service request data
CN113934604A (en) Service state monitoring method, device, equipment and storage medium
CN112055377A (en) Self-service equipment and networking control method thereof
CN112733113A (en) Device authentication method, device, system, electronic device and medium
CN112116343A (en) Cash register system based on C/S and B/S fusion
CN107533603A (en) SMS processing method, device and terminal

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination