A method, device, electronic device and readable storage medium for pre-sale operation of goods
By using a combination of MySQL and ES databases in the pre-sale stage of the product, the matching operation is decoupled, which solves the problems of low matching efficiency and difficult maintenance in the existing technology, and achieves faster response and higher scalability.
Patent Information
- Application Number
- CN202311258888.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-26
- Publication Date
- 2024-08-30
- Estimated Expiration
- 2043-09-26
AI Technical Summary
In the existing technology, the matching efficiency of the product pre-sales stage is low, and business maintenance and expansion are difficult, mainly due to the low efficiency of database query feedback and the high coupling between user needs and the database.
MySQL database and ES database are used to store basic pre-sales information, and the integrated data model is obtained through the integrated operation interface and temporarily stored in the memory. The two types of business instructions are implemented based on the large wide table of the ES database and the integrated data model in the memory. Decouple matching operations, reduce database pressure, and improve response speed and code reuse rate.
It achieves faster command response, reduces the pressure on the database, improves code reuse and scalability, and improves user experience.
Smart Images

Figure CN117611183B
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of commodity management, and in particular to a commodity pre-sale operation method, device, electronic device and readable storage medium. Background Art
[0002] The business of online product management includes pre-sales stage, order stage and after-sales stage. The main contents of the pre-sales stage include the storage management of product information entered into the system and retrieving product information from the system according to user needs and displaying it to the user.
[0003] At present, in the pre-sale stage of commodity management, commodity information is stored in a database, and when user demand arises, the database is directly queried for commodity matching. The feedback efficiency of database queries is low, and the user experience is poor. At the same time, the user demand is usually implemented through data entity operation business logic and programs that are highly coupled with the commodity information stored in the database. Once the commodity information or user demand changes, the business logic and programs need to be comprehensively modified and adjusted, which is not conducive to the subsequent maintenance and expansion of the business.
[0004] Therefore, how to provide a solution to the above technical problems is a problem that those skilled in the art need to solve. Summary of the invention
[0005] In view of this, the embodiments of the present application provide a method, device, electronic device and readable storage medium for pre-sale operation of goods to solve the problems of low matching efficiency and difficulty in business maintenance and expansion in the prior art.
[0006] A first aspect of the embodiments of the present application provides a method for pre-sale operation of a commodity, comprising:
[0007] Receive the pre-sales basic information to be entered, and enter the pre-sales basic information into the MySQL database;
[0008] Synchronize the pre-sales basic information in the MySQL database to the large wide table in the ES database;
[0009] When receiving a first type of business instruction, executing the first type of business instruction based on the large wide table;
[0010] Call the integration operation interface to retrieve the corresponding pre-sales basic information from the MySQL database and integrate it into an integrated data model and temporarily store it in the memory;
[0011] sending the integrated data model to the user terminal so that the user terminal sends the second type of service instruction based on the integrated data model;
[0012] When receiving the second type of business instruction sent by the user terminal, matching is performed in the integrated data model according to the second type of business instruction, a matching result is generated according to the pre-sales basic information obtained by matching, and the matching result is returned to the user terminal;
[0013] The first type of business instructions include instructions for recommendation search services, and the second type of business instructions include instructions for detail matching services.
[0014] A second aspect of the embodiment of the present application provides a commodity pre-sale operation device, comprising:
[0015] The first storage module is used to receive the pre-sale basic information to be entered, and enter the pre-sale basic information into the MySQL database;
[0016] The second storage module is used to synchronize the pre-sales basic information in the MySQL database to the large wide table in the ES database;
[0017] An execution module, configured to execute the first type of business instruction based on the large wide table when receiving the first type of business instruction;
[0018] A data integration module, which is used to call the integration operation interface to retrieve the corresponding pre-sales basic information from the MySQL database and integrate it into an integrated data model and temporarily store it in the memory, and send the integrated data model to the user terminal so that the user terminal sends the second type of business instructions based on the integrated data model;
[0019] A matching module, configured to, upon receiving a second type of business instruction sent by a user terminal, perform matching in the integrated data model according to the second type of business instruction, generate a matching result according to the pre-sales basic information obtained by matching, and return the matching result to the user terminal;
[0020] The first type of business instructions include instructions for recommendation search services, and the second type of business instructions include instructions for detail matching services.
[0021] According to a third aspect of an embodiment of the present application, an electronic device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above method when executing the computer program.
[0022] According to a fourth aspect of an embodiment of the present application, a readable storage medium is provided, which stores a computer program, and when the computer program is executed by a processor, the steps of the above method are implemented.
[0023] Compared with the prior art, the beneficial effects of the embodiments of the present application include at least the following: the embodiments of the present application store pre-sales basic information through MySQL database and ES database, and obtain the integrated data model through the integrated operation interface and temporarily store it in the memory. The two types of business instructions are implemented based on the large wide table of the ES database and the integrated data model in the memory respectively. Compared with only using a single database with a high degree of coupling, the present application respectively gives play to the different storage advantages of the two databases, and at the same time decouples the matching operation of the pre-sales basic information from the database based on the integrated data model, thereby reducing the pressure on the database and achieving faster instruction response. At the same time, low cohesion and high coupling of the code are achieved, which greatly improves the code reuse rate and scalability of the integrated operation interface. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0025] Figure 1 It is a schematic diagram of an application scenario of an embodiment of the present application;
[0026] Figure 2 It is a flow chart of a method for pre-sale operation of a commodity provided in an embodiment of the present application;
[0027] Figure 3 It is a structural schematic diagram of a table design of commodity information provided in an embodiment of the present application;
[0028] Figure 4 It is a structural diagram of a table design of coupon information provided in an embodiment of the present application;
[0029] Figure 5 It is a structural diagram of an integrated data model of commodity information provided in an embodiment of the present application;
[0030] Figure 6 It is a structural diagram of an integrated data model of coupon information provided in an embodiment of the present application;
[0031] Figure 7 It is a flowchart of a commodity information matching algorithm provided in an embodiment of the present application;
[0032] Figure 8 It is a flowchart of a coupon information matching algorithm provided in an embodiment of the present application;
[0033] Fig. 9It is a structural schematic diagram of a commodity pre-sale operation device provided in an embodiment of the present application;
[0034] Fig.10 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0035] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.
[0036] A method, device, electronic device and readable storage medium for pre-sale operation of goods according to an embodiment of the present application will be described in detail below with reference to the accompanying drawings.
[0037] Figure 1 1 is a schematic diagram of an application scenario of an embodiment of the present application. The application scenario may include a first terminal device 101, a second terminal device 102, a third terminal device 103, a server 104 and a network 105.
[0038] The first terminal device 101 can be hardware or software. When the first terminal device 101 is hardware, it can be various electronic devices with a display screen and supporting communication with the server 104, including but not limited to smart phones, tablet computers, laptop portable computers and desktop computers; when the first terminal device 101 is software, it can be installed in the electronic devices described above. The first terminal device 101 can be implemented as multiple software or software modules, or as a single software or software module, and the embodiments of the present application are not limited to this. Furthermore, various applications can be installed on the first terminal device 101, such as data processing applications, instant messaging tools, social platform software, search applications, shopping applications, etc.
[0039] The second terminal device 102 can be hardware or software. When the second terminal device 102 is hardware, it can be various electronic devices with a display screen and supporting communication with the server 104, including but not limited to smart phones, tablet computers, laptop portable computers and desktop computers; when the second terminal device 102 is software, it can be installed in the electronic device described above. The second terminal device 102 can be implemented as multiple software or software modules, or as a single software or software module, which is not limited in the embodiment of the present application. Furthermore, various applications can be installed on the second terminal device 102, such as data processing applications, instant messaging tools, social platform software, search applications, shopping applications, etc.
[0040] The third terminal device 103 can be hardware or software. When the third terminal device 103 is hardware, it can be various electronic devices with a display screen and supporting communication with the server 104, including but not limited to smart phones, tablet computers, laptop portable computers and desktop computers; when the third terminal device 103 is software, it can be installed in the electronic device as described above. The third terminal device 103 can be implemented as multiple software or software modules, or as a single software or software module, which is not limited in the embodiment of the present application. Furthermore, various applications can be installed on the third terminal device 103, such as data processing applications, instant messaging tools, social platform software, search applications, shopping applications, etc.
[0041] The server 104 may be a server that provides various services, for example, a background server that receives a request sent by a terminal device that establishes a communication connection with the server, and the background server may receive and analyze the request sent by the terminal device, and generate a processing result. The server 104 may be a single server, or a server cluster composed of several servers, or a cloud computing service center, which is not limited in the present embodiment of the application.
[0042] It should be noted that the server 104 can be hardware or software. When the server 104 is hardware, it can be various electronic devices that provide various services for the first terminal device 101, the second terminal device 102, and the third terminal device 103. When the server 104 is software, it can be multiple software or software modules that provide various services for the first terminal device 101, the second terminal device 102, and the third terminal device 103, or it can be a single software or software module that provides various services for the first terminal device 101, the second terminal device 102, and the third terminal device 103, and the embodiment of the present application does not limit this.
[0043] The network 105 can be a wired network connected by coaxial cable, twisted pair and optical fiber, or it can be a wireless network that can interconnect various communication devices without wiring, such as Bluetooth, Near Field Communication (NFC), infrared, etc., which is not limited in the embodiments of the present application.
[0044] It should be noted that the specific types, quantities and combinations of the first terminal device 101, the second terminal device 102, the third terminal device 103, the server 104 and the network 105 can be adjusted according to the actual needs of the application scenario, and the embodiments of the present application do not limit this.
[0045] Figure 2It is a flow chart of a method for pre-sale operation of a commodity provided in an embodiment of the present application. Figure 2 The pre-sale operation method of goods can be Figure 1 The server is executed, and the user terminal can Figure 1 The first terminal device, the second terminal device, or the third terminal device is implemented. Figure 2 As shown, the pre-sale operation method of the product includes:
[0046] S201: receiving pre-sales basic information to be entered, and entering the pre-sales basic information into a MySQL database;
[0047] S202: Synchronize the pre-sales basic information in the MySQL database to the large wide table in the ES database;
[0048] S203: When receiving a first type of service instruction, executing the first type of service instruction based on the large wide table;
[0049] S204: calling the integration operation interface to retrieve the corresponding pre-sales basic information from the MySQL database and integrating it into an integrated data model and temporarily storing it in the memory;
[0050] S205: Sending the integrated data model to the user terminal, so that the user terminal sends the second type of service instruction based on the integrated data model;
[0051] S206: when receiving the second type of business instruction sent by the user terminal, matching is performed in the integrated data model according to the second type of business instruction, a matching result is generated according to the pre-sales basic information obtained by matching, and the matching result is returned to the user terminal;
[0052] The first type of business instructions include instructions for recommendation search services, and the second type of business instructions include instructions for detail matching services.
[0053] The embodiment of the present application stores pre-sales basic information through MySQL database and ES database, and obtains the integrated data model through the integrated operation interface and temporarily stores it in the memory. The two types of business instructions are implemented based on the large wide table of the ES database and the integrated data model in the memory respectively. Compared with using only a single database with a high degree of coupling, the present application respectively gives play to the different storage advantages of the two databases, and at the same time decouples the matching operation of the pre-sales basic information from the database based on the integrated data model, thereby reducing the pressure on the database and making the instruction response faster. At the same time, low cohesion and high coupling of the code are achieved, which greatly improves the code reuse rate and scalability of the integrated operation interface.
[0054] First, this embodiment uses two databases, MySQL database and ES (Elasticsearch) database, each of which has its own characteristics. The advantages of MySQL database are: data security and consistency guarantee, such as the status of goods on and off the shelves, which can synchronize the status of goods and other information in real time to prevent unexpected order operations; support transaction operations, which can ensure data security issues in concurrent situations. For example, the correctness of key and important attributes such as the inventory of goods and the number of purchase limits ensures the reliability of key businesses such as ordering and payment.
[0055] The advantages of ES database are: high performance, able to quickly retrieve and filter massive amounts of product data; high flexibility, able to flexibly return data in specified columns, and return data according to business dynamics; support full-text search, automatic word segmentation, and match all eligible products according to keywords. At the same time, the shortcomings of ES database are: data refresh has a certain delay, and it is difficult to ensure data consistency. For example, after removing a product from the shelves, we expect that users will not be able to place orders for the product at the same time; it does not support transactions. Assuming that the number of product A is 5, when multiple users grab a product at the same time, it may result in insufficient inventory of the product at the time of concurrency, but orders can still be placed, and the stability of product sales cannot be guaranteed.
[0056] Therefore, in combination with the characteristics of the two databases, this embodiment sets an action to enter the pre-sale basic information into the MySQL database and synchronize it to the ES database. And according to the characteristics of the two databases, different services are allocated. Specifically, the recommendation search service, such as the product homepage recommendation service and the product search service, is allocated to the ES database, that is, the execution of the first type of business instructions is based on the large wide table of the ES database; the detail matching service, such as the product detail viewing service, the product price calculation service, and the product ordering service, is allocated to the MySQL database, that is, the execution of the second type of business instructions is based on the MySQL database, specifically based on the integrated data model obtained by integrating the MySQL database.
[0057] Specifically, the implementation of the method in this embodiment is based on the following business rules:
[0058] (1) SKU: The full name is Stock Keeping Unit, which is the basic unit for measuring inventory in and out, and can be in units of pieces, boxes, pallets, etc.
[0059] (2) SPU: The full name is Standard Product Unit, which is the smallest unit of commodity information aggregation. It is a set of reusable and easily searchable standardized information that describes the characteristics of a product. In layman's terms, commodities with the same attribute values and characteristics can be called an SPU.
[0060] (3) Coupons: Coupons are targeted at SPUs and can be divided into full-reduction coupons, full-discount coupons, and no-threshold coupons based on the discount content.
[0061] The business rules of SKU, SPU and coupons are common to most merchants, so this embodiment has strong adaptability and versatility.
[0062] Furthermore, the pre-sale basic information includes at least two types of product information and coupon information. The table design of product information and coupon information in the MySQL database can be respectively as follows: Figure 3 and Figure 4 conduct, Figure 3 and Figure 4 It is not a complete table structure, and some table contents are omitted.
[0063] exist Figure 3 In the table design of product information, the specific structure of each table is as follows:
[0064] Spu is a commodity category table that records the full information of the commodity, including the identity number id, unit number spuId, commodity name spuName, title spuTitle, introduction, details, status spuStatus (on and off the shelf status, etc.), base price price, commodity-related vehicle model (or the vehicle model to which the vehicle commodity belongs for sale) vehicleModels and other full field information.
[0065] SpuFile is the spu image video information table, including skuId, name name, file number fileId, file type sort, file model type, file sorting and other information.
[0066] Sku is a commodity subcategory table that records the information of the smallest salable commodity unit, including the basic unit number skuId, price price, associated spuId, the number of points required to purchase using points, and the redundant commodity specification data set skuSpecs when it is created.
[0067] SkuStock is a commodity inventory table that records the inventory quantity information of commodities, including the associated skuId and the inventory type type (such as saleable inventory, discounted inventory, etc.).
[0068] SkuFile is the image and video data table of sku, which has a similar structure to SpuFile and will not be described here.
[0069] Category is a category table that records relevant information about product categories, including multi-level category information (first-level, second-level, and third-level categories).
[0070] Supplier is a supplier information table that records supplier information, including supplier name, associated spuId, province / city / area and specific address detailAddress.
[0071] FeightTemplate is a freight template table that records freight template information for shipments from different provinces, cities, and districts, including the template name and charging method chargingType.
[0072] FeightTemplateIte freight template sub-item table, records the information of the deliverable area corresponding to the freight template, including the deliverable area range province / city / area / detailAddress, if calculated by piece (it includes the first piece quantity, the freight amount corresponding to the first piece quantity, the subsequent piece quantity, and the renewal fee corresponding to the subsequent piece quantity), if calculated by weight (it includes the first weight, the freight amount corresponding to the first weight, the subsequent weight, and the renewal fee corresponding to the subsequent weight).
[0073] exist Figure 4 In the table design of coupon information, the specific structure of each table is as follows:
[0074] Coupon is a card coupon template table, which is used to record some basic information of the card coupon, including the card coupon number id, card coupon name name, card coupon type type (currently there are three types: full discount, discount, and no threshold), acquisition method type obtainWayType, application type applyType (can be all products, specified products, specified categories or specified categories), card coupon quantity generateAmount, card coupon effectiveDays, card coupon start date expirationStartTime, card coupon end date expirationEndTime and other data.
[0075] CouponDetail is a card coupon code information table that records all card coupon code information generated when creating a card coupon, including the card coupon code couponCode, status status (including unbound, unused, and used), and the associated card coupon template id (couponId).
[0076] CouponRelation is a card and coupon usage range table, which records the productId within which the card and coupon can be used. This can be a specific product ID, category ID, or classification ID.
[0077] BindCoupon is a card-coupon binding information table that records the binding relationship between the card-coupon code and the user (or car), including user id (userUuid), mobile phone number mobile, vehicle identification code vin, card-coupon code code, associated card-coupon template id (couponId), associated card-coupon code detail id (couponDetailId), card-coupon start date expirationStartTime, card-coupon end date expirationEndTime, associated time bindTime, etc.
[0078] CouponUsedRecord is a card and coupon usage record table that records the usage information of the card and coupon code, such as the user userUuid and the usage time usedTime.
[0079] Furthermore, pre-sales basic information is stored in a large wide table in the ES database. Large wide tables have the following advantages:
[0080] Even massive amounts of product data can be responded to in a very short time, which can greatly improve service performance and user experience.
[0081] Instantly expand the scope of search. Users can search for products by searching for information about suppliers, categories, harvesting areas, and products. This enables a comprehensive search of multi-dimensional attributes, accurately matches products, and expands the scope of search.
[0082] Even when the search term does not exist, some recommendations can be made through keywords, providing more displayed products and increasing users' willingness to buy.
[0083] Therefore, in this embodiment, the pre-sales basic information is stored in the ES database in the form of a large wide table. The large wide table is the Spu table, which includes various types of information, such as basic product information: spuId, spuName, spuTitle, vehicleModels, price, etc., product image and video information: fileID, sort, fileType, etc., category information: categoryId, categoryName, categoryParentNames, etc., supplier information: supplierId, supplierName, supplierProvince, supplierCity, supplierArea, supplierDetailAddress, etc., freight template information: address, etc.
[0084] Furthermore, since some products have many specification attributes, taking car products as an example, their specification attributes include exterior, interior, wheels, tires, optional packages, etc. Each specification provides multiple options. If there are 5 exteriors, 5 interiors, 3 wheels, 3 tires, and 3 optional packages, 225 sku combinations can be obtained through Cartesian product calculation. With the increasing number of car products and other car-related products, the sku table can reach millions. Furthermore, the model may also include multiple versions (such as rear-wheel drive, four-wheel drive, extended range, electric), so 225×4=1000 sku data need to be queried through the database association at one time.
[0085] Similarly, the card and coupon codes are generated when the card and coupon template is created. Assuming that a card and coupon template is set to generate 10,000 card and coupon codes, the amount of data in the card and coupon code table will be very large, easily reaching the million level.
[0086] At this time, this query demand puts a lot of pressure on the database. In order to disperse this query pressure, you can set up multiple sub-tables in the MySQL database, split all sku data horizontally, and store a piece of basic pre-sales information in a sub-table. When querying, query multiple sub-tables separately, which can improve the response speed of the server and reduce the IO pressure of the database.
[0087] Therefore, each pre-sale basic information in the MySQL database is stored in corresponding multiple sub-tables;
[0088] The process of entering pre-sales basic information into the MySQL database includes:
[0089] Determine the location where the pre-sales basic information is to be entered, which can be any sub-table in the MySQL database;
[0090] Enter the pre-sales basic information into the waiting-to-enter position.
[0091] Specifically, when determining the position to be entered, the algorithm for dividing the table can be set according to actual needs. In this embodiment, two feasible algorithms are proposed as examples:
[0092] The first table partitioning algorithm includes: reading the ID of the pre-sales basic information, converting the ID into a string, regularly taking out n bits randomly, adding the ASCII codes, and performing a modulo operation on the number of libraries to obtain the table number, thereby locating the name of the specific storage table. The advantages of this algorithm are simple implementation, good security, and not easy to be attacked; the disadvantage is that when a new table is added according to the amount of data, the corresponding table changes after the ID is taken, and the location of the table where the data is located needs to be re-migrated.
[0093] The second table partitioning algorithm includes: reading the ID of pre-sales basic information and querying the corresponding creation date. Here, a new table needs to be added upstream to maintain the ID and its creation date. The table can be divided by month, quarter, or year; spell out the specific table name according to the creation date; query the related sku information from the stored table. The advantage of this algorithm is that it does not involve data migration after adding a new table. The data is continuous by time, and it is more intuitive to observe the growth of data; the disadvantage is that an additional table is required to maintain the ID and its creation date.
[0094] These two table partitioning algorithms are applicable to both product information and coupon information.
[0095] It is understandable that after determining the storage format of pre-sales basic information in the MySQL database and the ES database, each time new pre-sales basic information is entered into the MySQL database, the ES database will synchronize the action. The synchronization operation is triggered by the action recording and monitoring of the MySQL database. The action recording and monitoring are generally implemented by binlog synchronization or the preset data change interface sending update instructions to the message middleware. Specifically, the process of synchronizing the pre-sales basic information in the MySQL database to the large wide table of the ES database includes:
[0096] By monitoring the binlog information of the MySQL database, the basic pre-sales information in the MySQL database is synchronized to the large wide table of the ES database;
[0097] Alternatively, after the preset data change interface monitors the information update in the MySQL database, it sends an update instruction to the message middleware, so that the ES database calls and executes the update instruction in the message middleware to synchronize the pre-sales basic information in the MySQL database to the large wide table of the ES database.
[0098] The synchronized pre-sales basic information mainly includes product information, category information, supplier information and freight information. Therefore, the binlog information includes the binlog information of the product table, category table, supplier table and freight information table in the MySQL database; accordingly, the preset data change interface includes the product information change interface, category information change interface, supplier information change interface and freight information change interface.
[0099] The preset data change interface sends the update instruction to the message middleware, which can be RabbitMQ or other message middleware. The main purpose is to ensure program performance and avoid data loss. After receiving the update instruction in the message middleware, the ES database executes it to complete the synchronization.
[0100] After the pre-sale basic information is further stored in the database in step S201, it is necessary to integrate the information in the memory. The basis of the information integration is all the pre-sale basic information in the MySQL database. The pre-sale basic information required by the integration operation interface is retrieved from the MySQL database and integrated to obtain an integrated data model. The integrated data model is not completely consistent with the storage structure in the database. The integration is based on the database to screen and retrieve the information. The integration operation interface is a pre-created, modifiable or adjustable interface. Specifically, the integration operation interface is called to retrieve the corresponding pre-sale basic information from the MySQL database and integrate it into the integrated data model before temporarily storing it in the memory. It also includes:
[0101] Create a database entity class; the internal fields of the database entity class correspond to the field names and types of the MySQL database;
[0102] Based on the database entity class, create a data persistence layer, which is used to define functions for obtaining data information from the MySQL database based on input parameters;
[0103] Create an integrated operation interface, which is used to call the data persistence layer.
[0104] Taking product information as an example, the database entity classes include SpuEntity and SkuEntity. The fields inside the entity class correspond to the field names and types of the spu table and sku table respectively; the data persistence layer includes the SpuJpa class and the SkuJpa class. The SpuJpa class is used to define a function that obtains Spu information from the MySQL database based on the input parameter spuId, and the SkuJpa class is used to define a function that obtains Sku information from the MySQL database based on the input parameter spuId.
[0105] Furthermore, in this embodiment, the process of creating a data persistence layer based on the database entity class includes: based on the database entity class, using the three-party framework QueryDSL-JPA to create SpuJpa class and SkuJpa class. The three-party framework QueryDSL-JPA is a fully automatic ORM (Object Relational Mapping) framework, which uses a pure Java API to write queries without writing SQL statements. Of course, in addition to this three-party framework, other database persistence frameworks can also be used, such as mybatis, which can be selected according to actual working conditions and user needs.
[0106] According to the setting of data persistence layer, this embodiment can define some behaviors specific to the integrated data model, such as matching of product sku and calculation of product price. For example, the SpuJpa class defines a function to obtain Spu information from the MySQL database according to the input parameter spuId as follows:
[0107] public Sku matchSku(List <matchedskuspecitem>needMatchSkuSpecItems){
[0108] for(Sku sku:this.skus){
[0109] if(sku.matchBy(needMatchSkuSpecItems)){
[0110] return sku;
[0111] }
[0112] }
[0113] return null;
[0114] }
[0115] For another example, the SkuJpa class defines a function that obtains Sku information from the MySQL database based on the input parameter spuId as follows:
[0116] public boolean matchBy(List <matchedskuspecitem>
[0117] needMatchSkuSpecItems){
[0118] List <matchedskuspecitem>skuSpecItems=this.specItems.stream()
[0119] .map(item->new MatchedSkuSpecItem(item.getName(),item.getValue()))
[0120] .collect(Collectors.toList());
[0121] Collections.sort(skuSpecItems,
[0122] Comparator.comparing(MatchedSkuSpecItem::getName));
[0123] Collections.sort(needMatchSkuSpecItems,
[0124] Comparator.comparing(MatchedSkuSpecItem::getName));
[0125] String needMatchSkuSpecValueStr=
[0126] needMatchSkuSpecItems.stream().map(item->
[0127] item.getValue()).collect(Collectors.joining("_"));
[0128] String skuSpecValueStr=skuSpecItems.stream().map(item->
[0129] item.getValue()).collect(Collectors.joining("_"));
[0130] return needMatchSkuSpecValueStr.equals(skuSpecValueStr);
[0131] }
[0132] It is understandable that according to the above two functions, the specific sku can be obtained by calling the matchSku of the spu model. Of course, this is only an example, and the specific settings can be made according to actual needs and working conditions.
[0133] Taking product information as an example, the integration operation interface is called to retrieve the corresponding product information from the MySQL database and integrate it according to the fields to obtain the integrated data model. The integrated data model can be Figure 5 As shown, each frame can represent a Java class, and each class includes the unique attributes of product information. Figure 5 Some information fields are omitted, and only the more critical classes and attributes in this embodiment are retained. The outermost layer of the integrated data model is the Spu class of the basic information of the product, in which the collection of all Sku specification combinations is nested. The Sku class contains the associated spuId, price, stock and other information, in which the collection of SkuSpecItem is nested again. The collection of SkuSpecItem refers to the specification value information contained in each specification combination.
[0134] Similar to product information, the integrated data model of coupon information can be as follows Figure 6 As shown in the figure, the outermost layer is the RelatedCouponCode class, which contains the user field of user information (here a CouponCodeUser class is encapsulated to record user information), and then the information collection of the coupon is nested. Coupon contains the coupon id information, coupon name, coupon type and discount information CouponTypeContent, whether it is applicable to all products and the id of the applicable products, and then the coupon code information CouponDetail under the coupon is nested. CouponDetail records the coupon code, the status of the coupon code, the start time and the end time of use, etc.
[0135] In the RelatedCouponCode class, a function for calculating the discount amount (named getDiscountAmount) is defined, and the input parameter is Map<String,Money> , the return value is Money.
[0136] In the Coupon class, define a function (named calculateDiscountAmount) to calculate the discount amount of the current coupon, with a Map as the input parameter.<String,Money> , the return value is Money.
[0137] After executing step S204, the integrated data model is displayed to the user terminal and the second-category business instruction fed back by the user terminal is executed. The action of matching in the integrated data model according to the second-category business instruction is actually a process of searching for specific information. For example, if the second-category business instruction is the ID of an SPU, then the integrated data model in the memory is searched to see whether there is pre-sales basic information that meets the second-category business instruction.
[0138] Specifically, taking product information as an example, the corresponding interface input parameters of the second type of business instructions are: Field 1: spuId, Field 2: List<"Specification Information Object">. The "Specification Information Object" contains two parameters: the first parameter is the specification name (such as tires), and the second parameter is the specification name (such as Michelin tires). After the user selects multiple specification combinations on the user terminal (such as the color of the exterior, wheels, tires, the color of the interior, and optional configuration packages), the specification selected by the current user is returned in the form of the second type of business instructions. This method performs Figure 7 The matching algorithm shown:
[0139] Create a loop;
[0140] Determine whether the SKU index is less than the total number of sku in the integrated data model;
[0141] If not, the loop ends, the process ends, and a null value is returned;
[0142] If yes, call the matching function in the sku model;
[0143] Sort the SkuSpecItem objects in the current sku by the name of the specification in ASCII code, extract the specification values of the sorted objects in sequence and concatenate them into a string;
[0144] Sort the SkuSpecItem objects that encapsulate the request by ASCII code according to the name of the specification, extract the specification values of the sorted objects in sequence and concatenate them into another string;
[0145] Compare the values of the two concatenated strings;
[0146] Determine whether they are equal;
[0147] If yes, then return the current sku object information;
[0148] If not, adjust the sku and start the cycle again.
[0149] It can be seen that in this embodiment, there is a comparison check before the matching result is output. The basis for the comparison check can be the result obtained by another set of matching logic, or the inherent characteristics of the pre-sales basic information in the integrated data model. Therefore, matching is performed in the integrated data model according to the second type of business instructions, and the process of generating a matching result according to the pre-sales basic information obtained by matching includes:
[0150] According to the second type of business instructions, traverse the integrated data model to determine a plurality of pre-sales basic information corresponding to the second type of business instructions in the integrated data model as the first basic information;
[0151] Integrate all the first basic information into a pre-matching result;
[0152] Based on the integrated data model, the pre-matching results are compared and verified, and the pre-matching results are confirmed as matching results after passing the comparison and verification.
[0153] In an exemplary embodiment, the preferential price of a product based on the coupon information is one of the core information of the product that needs to be returned to the user terminal. When the method of this embodiment matches in the integrated data model of the coupon information according to the second type of business instruction, the algorithm input parameters are set as follows:
[0154] Field: Map<String,Money> ;
[0155] The key of the Map is the id of the spu, and the value of the Map is the amount under the spuId. A Money object is used here, which is a class provided by the third-party package for storing amount information. It supports multiple currencies. If there are multiple identical spuIds and different skuIds, the prices of the skus are superimposed.
[0156] Then call the integrated data model of the coupon information, referred to as the function defined in the coupon model (such as getDiscountAmoun) to calculate the discount amount of the product. The specific algorithm is as follows Figure 8 As shown:
[0157] Call the function for calculating discount amount in the coupon model;
[0158] Create a loop;
[0159] Determine whether the number of cycles is less than the number of coupons in the current model;
[0160] If not, sort the returned discount amounts from small to large, return the maximum value, end the loop, end the process, and return a null value;
[0161] If yes, call the function to calculate the discount amount in the coupon model;
[0162] Traverse the number of available coupon codes in the current model (couponDetails);
[0163] Determine whether the number is greater than 0;
[0164] If the number is not greater than 0, the cycle starts again;
[0165] If the number is greater than 0, determine whether the card is applicable to all products;
[0166] If the card is applicable to all products, add up the amounts of all products in the entry to get the added amount;
[0167] If the card is not applicable to all products, the spuId input is calculated to meet the conditions and the amount after superposition is obtained;
[0168] Calculate the discount amount based on the current card type and superimposed amount;
[0169] The discounted price is returned and the cycle starts again.
[0170] It can be seen that the method in this embodiment can reduce data pressure and avoid the writing of complex SQL. The use of coupons is highly universal, the principle is simple and easy to use, and better product search performance is provided to improve user experience.
[0171] All the above optional technical solutions can be combined in any way to form optional embodiments of the present application, and will not be described in detail here. It should be understood that the size of the sequence number of each step in the above embodiment does not mean the order of execution, and the execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present application.
[0172] The following is an embodiment of the device of the present application, which can be used to execute the embodiment of the method of the present application. For details not disclosed in the embodiment of the device of the present application, please refer to the embodiment of the method of the present application.
[0173] Fig. 9 Schematic diagram of a pre-sale operation device for a commodity provided in an embodiment of the present application. Fig. 9 As shown, the commodity pre-sale operation device includes:
[0174] The first storage module 901 is used to receive the pre-sale basic information to be entered, and enter the pre-sale basic information into the MySQL database;
[0175] The second storage module 902 is used to synchronize the pre-sales basic information in the MySQL database to the large wide table in the ES database;
[0176] An execution module 903, configured to execute the first type of business instruction based on the large wide table when receiving the first type of business instruction;
[0177] The data integration module 904 is used to call the integration operation interface to retrieve the corresponding pre-sales basic information from the MySQL database and integrate it into an integrated data model and temporarily store it in the memory, and send the integrated data model to the user terminal so that the user terminal sends the second type of business instructions based on the integrated data model;
[0178] The matching module 905 is used for, when receiving the second type of business instruction sent by the user terminal, matching the second type of business instruction in the integrated data model, generating a matching result according to the pre-sales basic information obtained by matching, and returning the matching result to the user terminal;
[0179] The first type of business instructions include instructions for recommendation search services, and the second type of business instructions include instructions for detail matching services.
[0180] The device of the embodiment of the present application stores pre-sales basic information through MySQL database and ES database, and obtains the integrated data model through the integrated operation interface and temporarily stores it in the memory. The two types of business instructions are implemented based on the large wide table of the ES database and the integrated data model in the memory respectively. Compared with using only a single database with a high degree of coupling, the present application respectively gives play to the different storage advantages of the two databases, and at the same time decouples the matching operation of the pre-sales basic information from the database based on the integrated data model, thereby reducing the pressure on the database and making the instruction response faster. At the same time, low cohesion and high coupling of the code are achieved, which greatly improves the code reuse rate and scalability of the integrated operation interface.
[0181] In an exemplary embodiment, each pre-sale basic information in the MySQL database is stored in a corresponding plurality of sub-tables; and the process of entering the pre-sale basic information into the MySQL database includes:
[0182] Determine the location where the pre-sales basic information is to be entered, which can be any sub-table in the MySQL database;
[0183] Enter the pre-sales basic information into the waiting-to-enter position.
[0184] In an exemplary embodiment, the data integration module 904 calls the integration operation interface to retrieve the corresponding pre-sales basic information from the MySQL database and integrates it into an integrated data model before temporarily storing it in the memory, and is also used to:
[0185] Create a database entity class; the internal fields of the database entity class correspond to the field names and types of the MySQL database;
[0186] Based on the database entity class, create a data persistence layer, which is used to define functions for obtaining data information from the MySQL database based on input parameters;
[0187] Create an integrated operation interface, which is used to call the data persistence layer.
[0188] In an exemplary embodiment, the data persistence layer includes a SpuJpa class and a SkuJpa class. The SpuJpa class is used to define a function for obtaining Spu information from a MySQL database based on an input parameter of spuId, and the SkuJpa class is used to define a function for obtaining Sku information from a MySQL database based on an input parameter of spuId.
[0189] In an exemplary embodiment, the process of creating a data persistence layer based on a database entity class includes:
[0190] Based on the database entity class, use the tripartite framework QueryDSL-JPA to create SpuJpa class and SkuJpa class.
[0191] In an exemplary embodiment, matching is performed in the integrated data model according to the second type of business instructions, and a process of generating a matching result according to the pre-sales basic information obtained by matching includes:
[0192] According to the second type of business instructions, traverse the integrated data model to determine a plurality of pre-sales basic information corresponding to the second type of business instructions in the integrated data model as the first basic information;
[0193] Integrate all the first basic information into a pre-matching result;
[0194] Based on the integrated data model, the pre-matching results are compared and verified, and the pre-matching results are confirmed as matching results after passing the comparison and verification.
[0195] In an exemplary embodiment, the process of synchronizing the pre-sales basic information in the MySQL database to the large wide table in the ES database includes:
[0196] By monitoring the binlog information of the MySQL database, the basic pre-sales information in the MySQL database is synchronized to the large wide table of the ES database;
[0197] Alternatively, after the preset data change interface monitors the information update in the MySQL database, it sends an update instruction to the message middleware, so that the ES database calls and executes the update instruction in the message middleware to synchronize the pre-sales basic information in the MySQL database to the large wide table of the ES database.
[0198] Fig.10 Schematic diagram of an electronic device 10 provided in an embodiment of the present application. Fig.10 As shown, the electronic device 10 of this embodiment includes: a processor 1001, a memory 1002, and a computer program 1003 stored in the memory 1002 and executable on the processor 1001. When the processor 1001 executes the computer program 1003, the steps in the above-mentioned method embodiments are implemented. Alternatively, when the processor 1001 executes the computer program 1003, the functions of the modules / units in the above-mentioned device embodiments are implemented.
[0199] The electronic device 10 may be a desktop computer, a notebook, a PDA, a cloud server, or other electronic device. The electronic device 10 may include, but is not limited to, a processor 1001 and a memory 1002. Those skilled in the art will appreciate that Fig.10 The electronic device 10 is merely an example and does not limit the electronic device 10 . The electronic device 10 may include more or fewer components than shown in the figure, or different components.
[0200] Processor 1001 can be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
[0201] The memory 1002 may be an internal storage unit of the electronic device 10, for example, a hard disk or memory of the electronic device 10. The memory 1002 may also be an external storage device of the electronic device 10, for example, a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card (FlashCard), etc. equipped on the electronic device 10. The memory 1002 may also include both an internal storage unit of the electronic device 10 and an external storage device. The memory 1002 is used to store computer programs and other programs and data required by the electronic device.
[0202] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units.
[0203] If the integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium, such as a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. The computer program may include computer program code, which may be in source code form, object code form, executable file or some intermediate form. The readable storage medium may include: any entity or device capable of carrying computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium, etc.
[0204] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.< / matchedskuspecitem> < / matchedskuspecitem> < / matchedskuspecitem>
Claims
1. A method for pre-sale operation of goods, It is characterized in that include: Receive pre-sale basic information to be entered, and enter the pre-sale basic information into the MySQL database; Synchronize the pre-sales basic information in the MySQL database to the large wide table in the ES database; When receiving a first type of service instruction, executing the first type of service instruction based on the large wide table; Calling the integration operation interface to retrieve the corresponding pre-sales basic information from the MySQL database and integrating it into an integrated data model and temporarily storing it in the memory; Sending the integrated data model to a user terminal, so that the user terminal sends a second type of service instruction based on the integrated data model; When receiving the second type of business instruction sent by the user terminal, matching is performed in the integrated data model according to the second type of business instruction, generating a matching result according to the pre-sales basic information obtained by matching, and returning the matching result to the user terminal; The first type of service instructions include instructions for recommendation search services, and the second type of service instructions include instructions for detail matching services; The integration operation interface is a pre-created interface. Before calling the integration operation interface to retrieve the corresponding pre-sales basic information from the MySQL database and integrate it into an integrated data model and temporarily store it in the memory, it also includes: Create a database entity class; the internal fields of the database entity class correspond to the field names and types of the MySQL database; Based on the database entity class, create a data persistence layer, the data persistence layer is used to define a function to obtain data information from the MySQL database according to input parameters; An integrated operation interface is created, where the integrated operation interface is used to call the data persistence layer.
2. The method for pre-sale operation of goods according to claim 1, It is characterized in that Each of the pre-sale basic information in the MySQL database is stored in a corresponding plurality of sub-tables; The process of entering the pre-sale basic information into the MySQL database includes: Determine a location where the pre-sale basic information is to be entered, where the location is any of the sub-tables in the MySQL database; The pre-sale basic information is entered into the position to be entered.
3. The method for pre-sale operation of goods according to claim 1, It is characterized in that The data persistence layer includes the SpuJpa class and the SkuJpa class. The SpuJpa class is used to define a function for obtaining Spu information from the MySQL database according to the input parameter spuId, and the SkuJpa class is used to define a function for obtaining Sku information from the MySQL database according to the input parameter spuId.
4. The method for pre-sale operation of goods according to claim 3, It is characterized in that The process of creating a data persistence layer based on the database entity class includes: Based on the database entity class, the SpuJpa class and the SkuJpa class are created using the tripartite framework QueryDSL-JPA.
5. The method for pre-sale operation of goods according to claim 1, It is characterized in that The process of matching the second type of business instructions in the integrated data model and generating a matching result according to the pre-sales basic information obtained by matching includes: According to the second type of business instructions, traverse the integrated data model to determine a plurality of pre-sale basic information corresponding to the second type of business instructions in the integrated data model as the first basic information; Integrate all the first basic information into a pre-matching result; Based on the integrated data model, the pre-matching result is compared and verified, and the pre-matching result is confirmed as a matching result after passing the comparison and verification.
6. The method for pre-sale operation of goods according to any one of claims 1 to 5, It is characterized in that The process of synchronizing the pre-sales basic information in the MySQL database to the large wide table of the ES database includes: By monitoring the binlog information of the MySQL database, the pre-sales basic information in the MySQL database is synchronized to the large wide table of the ES database; Alternatively, after the preset data change interface monitors the information update in the MySQL database, it sends an update instruction to the message middleware, so that the ES database retrieves and executes the update instruction in the message middleware to synchronize the pre-sales basic information in the MySQL database to the large wide table of the ES database.
7. A device for running goods before they are sold. It is characterized in that include: The first storage module is used to receive the pre-sale basic information to be entered, and enter the pre-sale basic information into the MySQL database; The second storage module is used to synchronize the pre-sales basic information in the MySQL database to the large wide table of the ES database; an execution module, configured to, upon receiving a first type of service instruction, execute the first type of service instruction based on the large wide table; A data integration module, configured to call an integration operation interface to retrieve the corresponding pre-sales basic information from the MySQL database and integrate the information into an integrated data model and temporarily store the integrated data model in a memory, and send the integrated data model to a user terminal so that the user terminal sends a second type of business instruction based on the integrated data model; a matching module, configured to, upon receiving the second type of business instruction sent by the user terminal, perform matching in the integrated data model according to the second type of business instruction, generate a matching result according to the pre-sales basic information obtained by matching, and return the matching result to the user terminal; The first type of service instructions include instructions for recommendation search services, and the second type of service instructions include instructions for detail matching services; The integration operation interface is a pre-created interface. The data integration module calls the integration operation interface to retrieve the corresponding pre-sales basic information from the MySQL database and integrates it into an integrated data model before temporarily storing it in the memory. It is also used to: Create a database entity class; the internal fields of the database entity class correspond to the field names and types of the MySQL database; Based on the database entity class, create a data persistence layer, the data persistence layer is used to define a function to obtain data information from the MySQL database according to input parameters; An integrated operation interface is created, where the integrated operation interface is used to call the data persistence layer.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, It is characterized in that When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.
9. A readable storage medium storing a computer program. It is characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Attribute tag based database access method
CN105159920A
Method and device for determining data wide table
CN110781203A
Data acquisition method and device based on SQL statement integration, equipment and medium
CN114691714A
