An e-commerce sales backstepping method and system based on inventory difference and a medium
Patent Information
- Application Number
- CN202611137195.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-29
- Publication Date
- 2026-10-30
AI Technical Summary
[0009]为了解决现有技术中因补货干扰、异常波动、跨天间隔和同日数据覆盖等噪声导致无法从含噪库存时间序列中可靠反推商品逐日真实销量,以及补货期间真实需求丢失、异常波动污染统计量、跨天间隔无法逐日归属、不可靠日期被后续数据静默覆盖等问题,本发明提供一种基于库存差分的电商销量反推方法、系统及介质,以解决上述技术缺陷问题
(1)本发明通过四分支状态机中的补货分支对补货差分不消费负值,而是基于历史日销量池中的历史日销量样本生成当日估计销量,从而避免产生负销量;同时通过补货真实需求估计量公式反推补货期间的真实需求,完整保留了补货期间的真实需求信息。
Smart Images

Figure CN123015061A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of e-commerce data processing technology, specifically to a method, system, and medium for reverse e-commerce sales calculation based on inventory differences. Background Technology
[0002] In the cross-border e-commerce industry, product sales volume is a core data basis for product selection decisions, inventory management, competitor analysis, and market capacity assessment. However, due to business strategy considerations, mainstream e-commerce platforms generally do not disclose the actual sales volume data of products. Product selection personnel can only observe indirect information such as inventory quantity, price, and sales ranking published by the platform.
[0003] Currently, the industry commonly uses inventory difference estimation to predict product sales. This involves differencing inventory snapshots of the same product at different points in time, using the change in inventory as an estimate of sales during that period. However, the actual inventory time series on e-commerce platforms contains significant non-sales inventory fluctuations, meaning that simple difference results cannot be directly equated with actual sales. This is mainly reflected in the following four aspects: (1) Replenishment interference problem: When sellers replenish stock when inventory is low, the inventory between adjacent snapshots increases instead of decreasing, resulting in a negative inventory difference. If the negative value is included in the sales volume, negative sales volume will be obtained. If it is discarded directly, the real demand during the replenishment period will be lost. Both of these approaches will cause systemic deviations.
[0004] (2) Abnormal fluctuation interference: Affected by factors such as platform data update delays, collection errors, and batch transfers, the inventory sequence often experiences single large jumps, far exceeding the normal sales rate. If these are directly included in the sales volume, it will seriously exaggerate the daily sales volume and pollute subsequent statistics such as the mean and ranking calculated based on the sales volume.
[0005] (3) Sales attribution across days: Due to the limitations of collection frequency and anti-crawling strategies, the time interval between two adjacent snapshots often spans multiple natural days. The total inventory reduction during this period cannot be accurately attributed to each day, and existing methods cannot provide reliable daily sales figures.
[0006] (4) The problem of unreliable data being covered by subsequent reliable data: There may be multiple inventory difference records within the same natural day. If a record is judged to be unreliable due to replenishment or anomaly and is replaced by historical average estimation, another seemingly normal difference record arriving on the same day will directly cover the already made estimate, causing the abnormal contamination to flow back into the result.
[0007] To address the aforementioned issues, some improvements have been proposed in existing technologies. For example, the differential method, which excludes replenishment, identifies and marks intervals of increased inventory as replenishment, ignoring sales within these intervals. However, this method completely discards sales within replenishment intervals, leading to a systematic underestimation of actual demand, and still fails to resolve issues such as abnormal fluctuations, cross-day intervals, and same-day coverage. Another approach is pure statistical forecasting, which directly performs time-series forecasting on historical sales data, using the predicted values to fill in the current day's sales. However, this method lacks sufficient historical samples in the initial stages of product listing or when sales data is sparse, making the forecasts unreliable, and it cannot be corrected using actual inventory information collected on the current day.
[0008] In summary, existing sales volume deduction methods cannot simultaneously handle four types of noise: replenishment interference, abnormal fluctuations, cross-day intervals, and same-day coverage. Therefore, they cannot reliably deduce the actual daily sales volume of products from noisy inventory time series. Consequently, there is an urgent need in this field for an e-commerce sales volume deduction method and system capable of systematically identifying and classifying these four types of noise. Summary of the Invention
[0009] To address the problems in existing technologies, such as the inability to reliably deduce the daily actual sales volume of goods from noisy inventory time series due to noise caused by replenishment interference, abnormal fluctuations, cross-day intervals, and same-day data overwriting, as well as the loss of real demand during replenishment, abnormal fluctuations polluting statistics, the inability to assign cross-day intervals to each day, and unreliable dates being silently overwritten by subsequent data, this invention provides an e-commerce sales volume deduction method, system, and medium based on inventory difference, to solve the aforementioned technical defects.
[0010] This invention proposes a method for inferring e-commerce sales based on inventory differences, comprising the following steps: S1. Obtain the inventory snapshot sequence of the target product within a preset time period, and generate an inventory difference record based on two adjacent inventory snapshots; the inventory difference record includes the start time, start inventory, end time, end inventory, and inventory difference. S2. Establish a date occupancy status dictionary for the target product, with the natural day identifier as the key, and a historical daily sales pool with the natural day identifier as the key; each natural day identifier in the date occupancy status dictionary corresponds to an occupancy status, which includes the actual status, replenishment status, abnormal status, and estimated status; S3. Traverse the inventory difference records in chronological order. For each inventory difference record to be processed, query the date occupancy status dictionary to obtain the current occupancy status of the natural day to which the end time of the inventory difference record belongs. If the current occupancy status is any of the replenishment status, abnormal status, or estimated status, skip the inventory difference record. S4. For inventory difference records that were not skipped in step S3, perform branch scheduling processing according to multiple mutually exclusive branches. The multiple branches include at least cross-day branches, replenishment branches, abnormal branches and normal branches, and generate daily sales records for the natural day to which the end time belongs. S5. Write the daily sales records generated in step S4 into the historical daily sales pool, so that the historical daily sales pool continues to accumulate during the traversal process, and can be reused when calculating the average sales of the inventory difference records to be processed later, thereby obtaining the daily sales records of the target product for each natural day within a preset time period.
[0011] This invention also proposes an e-commerce sales back-calculation system based on inventory difference, used to implement the method described above. The system includes: The inventory difference construction module is used to obtain the inventory snapshot sequence of the target product within a preset time period and generate an inventory difference record based on two adjacent inventory snapshots. The inventory difference record includes the start time, start inventory, end time, end inventory, and inventory difference. The date occupancy status maintenance module is used to create a date occupancy status dictionary for target products with natural day identifiers as keys, as well as a historical daily sales pool with natural day identifiers as keys. Each natural day identifier in the date occupancy status dictionary corresponds to an occupancy status, which includes actual status, replenishment status, abnormal status, and estimated status. The date occupancy prediction module is used to traverse the inventory difference records in chronological order. For each inventory difference record to be processed, the date occupancy status dictionary is queried to obtain the current occupancy status of the natural day to which the end time of the inventory difference record belongs. If the current occupancy status is any of the replenishment status, abnormal status, or estimated status, the inventory difference record is skipped. The branch scheduling processing module is used to perform branch scheduling processing on multiple mutually exclusive branches for inventory difference records that have not been skipped. The multiple branches include at least cross-day branches, replenishment branches, abnormal branches and normal branches, and generate daily sales records for the natural day to which the end time belongs. The historical daily sales pool management module is used to write the generated daily sales records into the historical daily sales pool, so that the historical daily sales pool continues to accumulate during the traversal process, and can be reused when calculating the average sales of the inventory difference records to be processed later, thereby obtaining the daily sales records of the target product for each natural day within a preset time period.
[0012] The present invention also proposes a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the e-commerce sales back-calculation method based on inventory difference as described above.
[0013] Compared with the prior art, the beneficial effects of the present invention are as follows: (1) The present invention avoids negative sales by using the replenishment branch in the four-branch state machine to generate the estimated sales for the day based on the historical daily sales sample in the historical daily sales pool; at the same time, it uses the formula of the actual replenishment demand estimation to back-infer the actual demand during the replenishment period, thus completely preserving the actual demand information during the replenishment period.
[0014] (2) This invention identifies abnormal fluctuations by using both absolute quantity and relative comparison as conditions through abnormal branches. Records that are judged to be abnormal are marked as abnormal states and excluded from the aggregation of real sales. Instead, the estimated sales are generated by using historical daily sales samples in the historical daily sales pool, which effectively avoids the pollution of subsequent statistics by single-day abnormalities.
[0015] (3) The present invention generates estimated sales based on historical daily sales samples in the historical daily sales pool for each missing natural day from the day following the start time to the end time through cross-day branching, and fills in the missing data day by day, so that each day in the cross-day interval has a traceable estimated value.
[0016] (4) The present invention records the current occupancy status of each natural day through a date occupancy status dictionary. Once a certain day is determined to be in any of the following states: replenishment status, abnormal status, or estimated status, any subsequent writes to that day will be rejected. This mechanism prevents the pollution backflow caused by unreliable dates being rewritten as normal sales.
[0017] (5) In this invention, the four-branch state machine, the date occupancy state protection, and the historical daily sales pool self-feeding together constitute a self-consistent noisy time series latent variable inversion system. Specifically, the date occupancy state protection ensures that the branch decision result of the state machine will not be overwritten by subsequent records of the same day and become invalid, the historical daily sales pool self-feeding ensures that the cross-day daily estimation will not degenerate into unusable due to the lack of previous date samples, and the branch decision result of the state machine scheduling provides a state source for the update of the date occupancy state; the three cooperate with each other, and the above-mentioned synergistic effect cannot be achieved by using any component alone, together constituting a complete noisy time series latent variable inversion system. Attached Figure Description
[0018] Other features, objects, and advantages of the present invention will become more apparent from the following detailed description of non-limiting embodiments, taken with reference to the accompanying drawings: Figure 1 This is a flowchart of the e-commerce sales back-calculation method based on inventory difference according to the present invention; Figure 2 This is a structural diagram of the e-commerce sales back-calculation system based on inventory difference of the present invention; Figure 3 This is a schematic diagram of the structure of a computer system suitable for implementing the embodiments of the present invention. Detailed Implementation
[0019] The present invention will now be described in further detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and not intended to limit it. Furthermore, it should be noted that, for ease of description, only the parts relevant to the invention are shown in the accompanying drawings.
[0020] It should be noted that, unless otherwise specified, the embodiments and features described in the present invention can be combined with each other. The present invention will now be described in detail with reference to the accompanying drawings and embodiments.
[0021] Figure 1 A flowchart illustrating an e-commerce sales backward calculation method based on inventory differentials is shown. Figure 1 As shown, the method includes steps S1 to S5.
[0022] In step S1, an inventory snapshot sequence of the target product within a preset time period is obtained, and an inventory difference record is generated based on two adjacent inventory snapshots. Specifically, first, the target product for which sales back-calculation needs to be performed is determined; this target product is uniquely identified by its product identifier. Then, a preset time period is set, which can be configured according to actual business needs, such as the most recent 30 days or the most recent 90 days. All inventory snapshots of the target product within the preset time period are retrieved from the database and sorted in ascending order according to the collection time to obtain the inventory snapshot sequence. An inventory snapshot is a periodically collected inventory record of a product at a specific moment, and its core fields include the product identifier, collection time, and current inventory. In specific implementations, web crawler technology can be used to scrape inventory snapshot data from the product details page of an e-commerce platform according to a preset collection period.
[0023] For two adjacent inventory snapshots in an inventory snapshot sequence, the preceding snapshot is taken as the old snapshot, and the following snapshot is taken as the new snapshot, generating an inventory difference record. The inventory difference record includes a start time, a start inventory, an end time, an end inventory, and the inventory difference component. The start time is the collection time of the old snapshot, the start inventory is the current inventory of the old snapshot, the end time is the collection time of the new snapshot, and the end inventory is the current inventory of the new snapshot. The inventory difference component is calculated using the following formula:
[0024] in, Indicates the difference in inventory. Indicates the initial inventory. This indicates the end of the inventory period. When... When inventory decreases, it indicates that sales occurred during that period; when This indicates an increase in inventory, reflecting that replenishment has occurred during that period. The replenishment status is determined as follows: when... When replenishment status is active, it is 1, indicating replenishment; otherwise, it is 0. The time interval is calculated using the following formula:
[0025] in, This indicates a time interval, in seconds. Indicates the end time. This indicates the start time. The entire inventory snapshot sequence is traversed in this manner to generate inventory difference records corresponding to all adjacent snapshot pairs. In engineering implementation, the construction of inventory difference records can be achieved as follows: After sorting the inventory snapshot data by product identifier and collection time, each snapshot is processed sequentially using a loop, paired with the next snapshot to generate difference records, and the generated difference records are stored in a difference record list for use in subsequent steps.
[0026] In step S2, a date occupancy status dictionary with natural day identifiers as keys and a historical daily sales pool with natural day identifiers as keys are established for the target product. Specifically, before starting to traverse the inventory difference records, two data structures are initialized for the target product. The first data structure is a date occupancy status dictionary with natural day identifiers as keys. Each key in this dictionary is a natural day identifier in the format of year-month-day, and the corresponding value is the current occupancy status for that natural day. Initially, this dictionary is empty. As the branch scheduling process proceeds, the occupancy status for each natural day is gradually written in. The occupancy status values in this dictionary include four types: true status, replenishment status, abnormal status, and estimated status. Among them, true status indicates that there are already sales records based on the true difference for that day, and it is written by the normal branch; replenishment status indicates that the day has been occupied by the replenishment branch, and it is written by the replenishment branch; abnormal status indicates that the day has been occupied by the abnormal branch, and it is written by the abnormal branch; estimated status indicates that the day has been occupied by the cross-day estimated branch, and it is written by the cross-day branch. The occupancy invariant rule is as follows: when the occupancy status in the occupancy status dictionary for a given date is any of the following: replenishment status, abnormal status, or estimated status, any subsequent writes to that date, whether estimates or actual aggregate values, are rejected. Once the occupancy status of a date is marked as unreliable, it is no longer allowed to be overwritten by subsequent records. This is the core mechanism of this invention to prevent unreliable dates from being overwritten.
[0027] The second data structure is a historical daily sales pool with the natural day identifier as the key. This pool uses the natural day identifier as the key and the daily sales volume for that day as the value. Its initial value comes from the historical daily sales records of the target product that have already been put into inventory; that is, it reads the daily sales records of this product that have been reverse-engineered and persistently stored before the start of this calculation from the database and loads them into memory for use in this calculation. During this calculation, each time a new daily sales record is generated, regardless of whether the record is the actual sales volume or the estimated sales volume, it is immediately written back to this pool. The historical daily sales pool is used to read historical sales samples when calculating the rolling window mean in subsequent steps. A daily sales record is the sales result of a certain product on a certain natural day, and its fields include the date of origin, sales volume, whether it is an estimate, whether it is abnormal, and the estimated actual demand for replenishment. The data structure includes: `Attribution Date` (the calendar day to which the sales record belongs), `Sales Volume` (the amount of sales sold on that day), `Is It an Estimated Value` (to indicate whether the sales volume is an estimate rather than a true value based on the actual difference), `Is It Abnormal` (to indicate whether the day is considered to have abnormal fluctuations), and `Replenishment Period Actual Demand Estimate` (to record the estimated replenishment demand derived from reverse engineering in the replenishment branch). In the engineering implementation, the date occupancy status dictionary and historical daily sales pool can be maintained independently by product dimension. When switching between different products, the dictionary and pool of the previous product need to be cleared to avoid cross-referencing of mean samples from different products.
[0028] In step S3, the inventory difference records are traversed in chronological order. For each pending inventory difference record, the date occupancy status dictionary is queried to obtain the current occupancy status of the natural day to which the end time of the inventory difference record belongs. If the current occupancy status is any of the replenishment status, abnormal status, or estimated status, the inventory difference record is skipped. Specifically, all inventory difference records generated in step S1 are sorted in ascending order by the timestamp of the end time, and then each inventory difference record is traversed sequentially. For the currently traversed inventory difference record, its end time field is first extracted to determine the natural day to which the end time belongs. Then, the date occupancy status dictionary is queried to obtain the current occupancy status of that natural day. If the occupancy status of that natural day in the date occupancy status dictionary is any of the replenishment status, abnormal status, or estimated status, the current inventory difference record is skipped, and subsequent branch scheduling processing is not performed. This mechanism constitutes the first line of defense against unreliable dates being overwritten by subsequent records, ensuring that dates that have been determined to be in a replenishment status, abnormal status, or estimated status are not overwritten by subsequent seemingly normal difference records. If the occupancy status of a given day in the date occupancy status dictionary is either real or not yet occupied, the current inventory difference record is marked as not skipped and proceeds to the branch scheduling process in step S4.
[0029] In step S4, for inventory difference records not skipped in step S3, branch scheduling is performed according to multiple mutually exclusive branches. These branches include at least cross-day branches, replenishment branches, abnormal branches, and normal branches, generating daily sales records for the calendar day to which the end time belongs. Specifically, branch scheduling is executed in the following priority order: date occupancy prediction (step S3) takes precedence over cross-day branches, cross-day branches take precedence over replenishment branches, replenishment branches take precedence over abnormal branches, and abnormal branches take precedence over normal branches. Each branch is mutually exclusive in turn; once the condition of any branch is matched, the processing logic of that branch is executed, and the condition judgment of subsequent branches is not executed. The mutual exclusion of each branch ensures that each inventory difference record is processed by at most one branch in the branch scheduling.
[0030] The handling method for cross-day branches is as follows: First, calculate the number of days spanning between the start and end dates. Specifically, extract the start date of the inventory difference record and determine its corresponding date, and extract the end date and determine its corresponding date. The number of days spanning is calculated using the following formula:
[0031] in, Indicates the number of days spanned. Indicates the calendar day to which the end time belongs. Indicates the calendar day to which the start time belongs. If When one or more calendar days are missing between the start and end dates, cross-day branching is performed. The sequence of calendar days to be completed is determined, which consists of all calendar days from the day after the start date to the end date. Each missing date in this sequence is iterated over; for each missing date, the dates preceding that date are taken. The daily sales records for each calendar day are used to calculate the arithmetic mean of these daily sales records as the estimated sales for the calendar day to be processed. The estimated sales are calculated using the following formula:
[0032] in, Indicates the target calendar day Estimated sales volume Indicates the target calendar day The previous Daily sales records for a calendar day. From 1 to integers, This is a preset positive integer representing the length of the scrolling window. In specific implementations, The value can be 30. Then, the occupation status of the pending natural day in the date occupation status dictionary is set to estimated status, and the estimated sales of the pending natural day are written into the historical daily sales pool as the corresponding daily sales record. After the cross-day branch is processed, subsequent branches are skipped.
[0033] The replenishment branch is handled as follows: Check if the inventory difference is less than zero. If the inventory difference is less than zero, meaning there was an increase in inventory between two adjacent snapshots and replenishment occurred, then execute the replenishment branch. This branch does not consume negative inventory differences; instead, it takes the inventory difference up to the calendar day preceding the end time. The daily sales records for each calendar day are used to calculate the arithmetic mean of these daily sales records as the estimated sales for that calendar day. `<value>` is a preset positive integer representing the length of the scrolling window; its specific value is the same as that of the cross-day branch. The estimated sales volume is calculated using the same formula as the cross-day branch. Then, the occupancy status of that natural day in the date occupancy status dictionary is set to replenishment status, and the estimated sales volume is written as the corresponding daily sales record into the historical daily sales pool. Simultaneously, the actual demand estimate during the replenishment period is calculated using the following formula:
[0034] in, This indicates the estimated actual demand for replenishment. This indicates the end of inventory. Indicates the initial inventory. Indicates the calendar day to which the end time belongs. The estimated sales volume is calculated using a formula that subtracts the initial inventory from the ending inventory and adds the estimated sales volume for the day to obtain an estimate of the replenishment quantity, taking the maximum value to ensure the result is non-negative. When historical daily sales samples are lacking and an estimated sales volume cannot be generated, the occupation status of that calendar day in the date occupation status dictionary is still set to replenishment status to prevent subsequent same-day ordinary differencing from treating this unreliable date as actual sales. After the replenishment branch is processed, subsequent branches are skipped.
[0035] The handling of abnormal branches is as follows: Determine whether the inventory difference record meets the anomaly detection criteria. The anomaly detection criteria are:
[0036] in, Indicates the difference in inventory. Indicates the initial inventory. The first threshold is preset. This is a preset second threshold. When both conditions are met simultaneously, it is considered an abnormal fluctuation. In specific implementation, It can take the value 100. The value can be 0.7. If it is determined to be an abnormal fluctuation, an abnormal branch will be executed. The inventory difference record will be marked as an abnormal fluctuation and excluded from the aggregation of true sales. The value will be taken before the calendar day to which the end time belongs. The daily sales records for each calendar day are used to calculate the arithmetic mean of these daily sales records as the estimated sales for that calendar day. `<value>` is a preset positive integer representing the length of the scrolling window; its specific value is the same as that of the cross-day branch. The estimated sales volume is calculated using the same formula as the cross-day branch. Then, the occupancy status of that natural day in the date occupancy status dictionary is set to an abnormal state, and the estimated sales volume is written as the corresponding daily sales record to the historical daily sales pool. When historical daily sales samples are lacking and estimated sales cannot be generated, the occupancy status of that natural day in the date occupancy status dictionary is still set to an abnormal state to prevent it from being overwritten by subsequent records. After the abnormal branch is processed, subsequent branches are skipped.
[0037] The normal branch is handled as follows: When the inventory difference record does not meet the conditions for any of the following branches: cross-day branch, replenishment branch, or abnormal branch, normal branch processing is executed. The portion of the inventory difference that is greater than zero is aggregated into the actual sales of the calendar day to which the end time belongs. Specifically, if there is no actual sales record for that calendar day, a new actual sales record is created; if there is already an actual sales record for that calendar day, the portion of the inventory difference that is greater than zero is added to the existing actual sales of that record. Then, the occupation status of that calendar day in the date occupation status dictionary is set to actual status, and the aggregated actual sales are written as the corresponding daily sales record to the historical daily sales pool.
[0038] In step S5, the daily sales records generated in step S4 are written to the historical daily sales pool. This historical daily sales pool continuously accumulates during the traversal process, allowing it to be reused when calculating the average sales of subsequent inventory difference records. This yields the daily sales records for the target product for each natural day within a preset time period. Specifically, after each branch in step S4 is processed, one or more daily sales records are generated and written to the historical daily sales pool. The writing method is as follows: the natural day corresponding to the daily sales record is used as the key, and the sales value of that daily sales record is used as the value. If a record already exists in the historical daily sales pool for that natural day, the new value overwrites the old value, avoiding duplicate writing that could lead to data inconsistency. Since each branch in step S4 needs to read historical sales samples from the historical daily sales pool to calculate the rolling window average when generating estimated sales, and step S5 writes the generated daily sales records to the historical daily sales pool after branch scheduling, this ensures that the samples in the historical daily sales pool are continuously enriched as the calculation process progresses. When performing backfilling across multiple days, the estimate for the next day can refer to the estimate for the previous date that was just generated, making the entire backfilling process a self-consistent rolling estimate. After all inventory difference records have been processed, the historical daily sales pool stores the daily sales records of the target product for each natural day ending within the preset time period. These records are the back-calculated daily sales results, which can be used as the final output for subsequent market capacity forecasting or other downstream analysis. In the engineering implementation, after the inventory difference records have been traversed, the daily sales records in the historical daily sales pool are persistently stored in the database for subsequent calculations or queries.
[0039] In step S3, during the chronological traversal of inventory difference records, a product switching preprocessing step is also included. Specifically, during the traversal, it is monitored whether the product identifier corresponding to the currently traversed inventory difference record is the same as the product identifier of the previous inventory difference record. When a new inventory difference record is traversed, the product identifier corresponding to that record is extracted and compared with the product identifier of the previously processed inventory difference record. If the product identifier of the current record is different from the product identifier of the previous record, it indicates that a switch to a new product is required for processing. At this time, the daily sales result corresponding to the previous product identifier is first written to the database for persistent storage, ensuring that the complete reverse calculation result is retained in the persistent storage layer. Then, the temporary cached data in the date occupancy status dictionary and the historical daily sales pool corresponding to the previous product identifier is cleared, retaining only the historical data in the database. In this way, when processing the inventory difference record of a new product begins, the date occupancy status dictionary and the historical daily sales pool are both in their initial state, avoiding the cross-use of sample data from different products.
[0040] After completing the sales back-calculation steps S1 to S5, this invention also provides an implementation method for market capacity prediction. In this implementation, the actual average monthly sales of monitored products are used directly, while the power-law predicted sales of unmonitored tail products are obtained by extrapolation through a power-law distribution. The sum of the two is the predicted total monthly sales value for the market segment. This method avoids the overlay of measured data caused by simultaneously applying the power-law curve to both monitored and unmonitored products, significantly reducing fitting bias. This prediction method can also output the monitored percentage and the tail percentage for decision-making reference.
[0041] First, obtain the average monthly sales of each product within the target market segment. The average monthly sales are calculated based on the daily sales records output in step S5. Specifically, for each product within the target market segment, the daily sales for each natural day within a preset time period are calculated from the daily sales records obtained in step S5, and its average monthly sales are calculated. The average monthly sales can be calculated by dividing the sum of the daily sales over the most recent thirty days by thirty days, or the statistical period can be set according to actual business needs. Next, filter out invalid data where the average monthly sales are not greater than zero. Products with average monthly sales not greater than zero indicate that the product had no actual sales or invalid sales data within the statistical period, and are removed from subsequent analysis. After filtering, sort the remaining products in descending order of average monthly sales, assign a ranking number to each product, and generate a product sequence with ranking numbers.
[0042] Next, a power-law distribution is fitted to the product sequence. The power-law distribution characterizes the proportional relationship between average monthly sales and the product's ranking number. Specifically, the natural logarithm of each product's ranking number is taken as the independent variable, and the natural logarithm of average monthly sales is taken as the dependent variable. Least squares linear regression is performed in the double logarithmic space to fit the power-law distribution parameters. The expression for the power-law distribution is:
[0043] in, Indicates the ranking sequence number. Indicates ranking Average monthly sales of the product in this position. This is the proportionality coefficient. The decay exponent and , The larger the value, the stronger the head effect. The smaller the value, the higher the proportion of the long tail. The regression equation is in the form of:
[0044] in, Indicates ranking Average monthly sales of the product in this position. Indicates the ranking sequence number. This is the proportionality coefficient. The decay exponent and The result was obtained through linear regression. and The estimated value is then obtained. and The fitted value. In practice, at least three valid data points are required for fitting.
[0045] Then, the goodness of fit of the power-law distribution is calculated. This reflects the goodness of fit of the power-law model to the data, with a value ranging from 0 to 1. A value closer to 1 indicates a better fit. When the goodness of fit is lower than a preset confidence threshold, a low-confidence alarm is output. In practice, the confidence threshold can be set to 0.7. Finally, the target track's... Total monthly sales forecast. This total monthly sales forecast is the sum of the actual average monthly sales of monitored products and the power-law predicted sales of unmonitored bottom-tier products. Specifically, the top-tier products in the target market... The monthly sales forecast for the top performer is calculated using the following formula:
[0046] in, In front of the track Forecast of monthly sales for top performers To monitor the quantity of goods, Estimate the total number of products for the track. Indicates ranking The actual monthly average sales volume of the product. The proportionality coefficient of the power-law distribution. The decay exponent of the power-law distribution is and , Indicates ranking The power-law prediction of sales for top-ranked products. This formula means: [The formula is incomplete and requires further context to be fully translated.] For monitored products, their actual average monthly sales volume is used directly. Summation and ranking Ranked first Power-law prediction of sales for unmonitored tail-end items. Summing the two parts gives the sum of the points before the track. Total monthly sales forecast. All monitored products will use actual average monthly sales, and will not be covered by a power-law model.
[0047] In this invention, the absolute threshold, relative comparison threshold, number of days in the historical mean rolling window, minimum number of effective data points for power-law fitting, goodness-of-fit threshold for confidence alarm, and total number of products estimated for the track are all configurable parameters, and the specific values can be adjusted by the implementer according to actual business needs.
[0048] Figure 2A schematic diagram of the structure of the e-commerce sales back-calculation system based on inventory difference provided in an embodiment of the present invention is shown. Figure 2 As shown, the system provided by this invention includes an inventory difference construction module, a date occupancy status maintenance module, a date occupancy prediction module, a branch scheduling processing module, and a historical daily sales pool management module.
[0049] The inventory difference construction module is used to obtain the inventory snapshot sequence of the target product within a preset time period and generate an inventory difference record based on two adjacent inventory snapshots. The inventory difference record includes the start time, start inventory, end time, end inventory, and inventory difference, corresponding to the functional implementation of method step S1.
[0050] The date occupancy status maintenance module is used to create a date occupancy status dictionary for the target product, with each date identifier as the key, and a historical daily sales pool with each date identifier as the key. This corresponds to the functionality of method step S2. Each date identifier in the date occupancy status dictionary corresponds to an occupancy status, which includes actual status, replenishment status, abnormal status, and estimated status.
[0051] The date occupancy prediction module iterates through inventory difference records in chronological order. For each pending inventory difference record, it queries the date occupancy status dictionary to obtain the current occupancy status of the natural day to which the record's end time belongs. If the current occupancy status is any of replenishment, abnormal, or estimated, the inventory difference record is skipped, corresponding to step S3. The branch scheduling processing module executes branch scheduling processing on the inventory difference records that have not been skipped, according to multiple mutually exclusive branches. These branches include at least cross-day branches, replenishment branches, abnormal branches, and normal branches, generating the daily sales record for the natural day to which the end time belongs, corresponding to step S4.
[0052] The historical daily sales pool management module is used to write the generated daily sales records into the historical daily sales pool, so that the historical daily sales pool continues to accumulate during the traversal process, and can be reused when calculating the average sales of the inventory difference records to be processed later, thereby obtaining the daily sales records of the target product for each natural day of the end time within the preset time period, which corresponds to the function implementation of method step S5.
[0053] The method of the present invention will be further described below with reference to specific embodiments.
[0054] In one embodiment of a normal sales scenario, the inventory snapshot sequence for a certain product is as follows: 1000 units on May 10th, and 950 units on May 11th. (Inventory difference) The replenishment status is marked as 0, indicating the number of days spanning between the start date (May 10th) and the end date (May 11th). The conditions for cross-day branching are not met. The inventory difference is not less than zero, which does not meet the conditions for replenishment branching, nor does it meet the abnormal judgment conditions. Therefore, it enters the normal branching. The 50 units with a value greater than zero in the inventory difference are aggregated into the actual sales volume on May 11, and the occupied status is set to the actual status.
[0055] In one embodiment of a replenishment-based inventory calculation scenario, the inventory snapshot sequence for a certain product is as follows: 100 units on May 10th, 300 units on May 11th, and the historical average daily sales volume for this product is 15 units. (Inventory difference) The replenishment status is marked as 1, indicating entry into the replenishment branch. Daily sales are taken from the historical daily sales pool up to the level of that day. The arithmetic mean of historical daily sales samples over a calendar day is 15 units. The estimated actual replenishment demand is calculated using the following formula:
[0056] This means the seller actually replenished approximately 200 units, and about 15 units were reserved based on actual demand that day. The day's inventory status was set to replenishment status. If another normal differential record arrives on the same day, it will be intercepted and skipped by the date occupancy prediction in step S3, and May 11th will not be rewritten as normal sales.
[0057] In one embodiment of an anomaly isolation scenario, the inventory snapshot sequence of a certain product is as follows: 1000 units on May 10th, 50 units on May 11th, and the historical average daily sales of this product is 20 units. (Inventory difference) The replenishment status is marked as 0. If the absolute quantity of 950 is greater than the first threshold of 100, and the ratio of 950 to the initial inventory of 1000 (0.95) is greater than the second threshold of 0.7, both conditions are met, and the situation is considered an abnormal fluctuation. The system then enters the abnormal branch, where the sales volume for that day is taken from the historical daily sales pool up to that day. The arithmetic mean of historical daily sales samples over a given number of calendar days, i.e., 20 units. Mark this as an anomaly, setting its occupancy status to an anomaly state, without affecting subsequent mean calculations and statistics.
[0058] In one embodiment of a cross-day daily reconstruction scenario, the inventory snapshot sequence of a certain product is as follows: Inventory on May 20th was 1000 units, and on May 23rd was 850 units, with no data collection points during this period. The number of days spanning between the start date (May 20th) and the end date (May 23rd) is also considered. If the value is greater than 1, proceed to the cross-day branch. Estimates are generated daily for May 21st, May 22nd, and May 23rd. The estimated sales for May 21st are based on the figures prior to that day. The arithmetic mean of historical daily sales samples over a certain number of calendar days is used to generate estimated sales, which are then written into the historical daily sales pool. The estimated sales for May 22 can be referenced from the estimated value for May 21, and the estimated sales for May 23 can be referenced from the estimated values for May 21 and May 22, forming a self-consistent rolling estimate.
[0059] In one embodiment of a hybrid capacity prediction scenario, a certain market segment has monitored 20 products, with an estimated total of 1000 products. A power-law fit is performed on the average monthly sales of these 20 products to obtain the power-law distribution parameters. and The predicted total monthly sales for the top 1000 products in the track is calculated as the sum of the actual average monthly sales of the top 20 monitored products plus the power-law predicted sales of the unmonitored products ranked 21st to 1000th. Monitored products are represented solely by their actual average monthly sales, without using a power-law model.
[0060] In one embodiment of the quantitative comparison experiment, the historical inventory sequence of a certain product is as follows: May 10th inventory was 1000 units as the baseline; May 11th inventory was 950 units, representing a normal sales scenario; May 12th inventory was 1200 units, indicating replenishment, with sales continuing during this period; May 13th inventory was 200 units, showing an abnormal jump far exceeding the normal sales rate; May 16th inventory was 150 units, with no data collection points from May 14th to May 16th, representing a cross-day scenario. This sequence simultaneously contains three types of noise: replenishment, abnormality, and cross-day noise. When processing this sequence using the naive difference method, the inventory difference on May 12th was negative and truncated to zero, resulting in the loss of sales on the replenishment day; the inventory difference on May 13th was positive and extremely large, and was included in the sales volume as is, leading to a severely inflated daily sales volume and polluting subsequent statistics; the entire sales volume from May 14th to May 16th could not be reliably assigned to each day. This sequence generates one negative sales volume, one abnormally inflated sales volume, and three distorted dates. When processing the same sequence using the method of this invention, the order is processed as follows: May 12th enters the replenishment branch, the occupancy status is set to replenishment, and sales are calculated using the historical average and the actual demand is inferred; May 13th enters the anomaly branch, the occupancy status is set to an anomaly state, and sales are calculated using the historical average, without contaminating subsequent statistics; from May 14th to May 16th, the order is processed in the cross-day branch, with daily estimates and self-consistent rolling write-back to the historical daily sales pool. This sequence generates zero negative sales, zero contaminated dates, and five reliable daily sales. Compared to the naive difference method, this invention eliminates all negative sales and abnormal contaminated dates in this noisy sequence, reducing the proportion of unreliable dates from 60% to 0%.
[0061] The following is for reference. Figure 3 It shows a schematic diagram of the structure of a computer system 300 suitable for implementing terminal devices or servers of the present invention. Figure 3The terminal device or server shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments of the present invention.
[0062] like Figure 3 As shown, the computer system 300 includes a central processing unit (CPU) 301, which can perform various appropriate actions and processes based on programs stored in read-only memory (ROM) 302 or programs loaded from storage section 308 into random access memory (RAM) 303. The RAM 303 also stores various programs and data required for the operation of the computer system 300. The CPU 301, ROM 302, and RAM 303 are interconnected via a bus 304. An input / output (I / O) interface 305 is also connected to the bus 304.
[0063] The following components are connected to I / O interface 305: an input section 306 including a keyboard, mouse, etc.; an output section 307 including a liquid crystal display (LCD) and speakers, etc.; a storage section 308 including a hard disk, etc.; and a communication section 309 including a network interface card such as a LAN card and a modem, etc. The communication section 309 performs communication processing via a network such as the Internet. A drive 310 is also connected to I / O interface 305 as needed. A removable medium 311, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed on drive 310 as needed so that computer programs read from it can be installed into storage section 308 as needed.
[0064] In particular, according to embodiments of the present invention, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of the present invention include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication section 309, and / or installed from removable medium 311. When the computer program is executed by central processing unit (CPU) 301, it performs the functions defined in the methods of the present invention. It should be noted that the computer-readable medium described in the present invention can be a computer-readable signal medium or a computer-readable medium or any combination thereof. The computer-readable medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of computer-readable media may include, but are not limited to: electrical connections having one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this invention, a computer-readable medium can be any tangible medium containing or storing a program that can be used by or in connection with an instruction execution system, apparatus, or device. In this invention, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium can also be any computer-readable medium other than a computer-readable medium that can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on a computer-readable medium can be transmitted using any suitable medium, including but not limited to: wireless, wire, optical fiber, RF, etc., or any suitable combination thereof.
[0065] Computer program code for performing the operations of this invention can be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, and C++, as well as conventional procedural programming languages such as C or similar languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0066] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present invention. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0067] The above description is merely a preferred embodiment of the present invention and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of the invention is not limited to the specific combination of the above-described technical features, but also includes other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the inventive concept. For example, technical solutions formed by substituting the above-described features with (but not limited to) technical features with similar functions disclosed in this invention.
Claims
1. A method for inferring e-commerce sales based on inventory difference, characterized in that, Includes the following steps: S1. Obtain the inventory snapshot sequence of the target product within a preset time period, and generate an inventory difference record based on two adjacent inventory snapshots; The inventory difference record includes start time, start inventory, end time, end inventory, and inventory difference. S2. Establish a date occupancy status dictionary with natural day identifier as the key and a historical daily sales pool with natural day identifier as the key for the target product; In the date occupancy status dictionary, each natural day identifier corresponds to an occupancy status, which includes actual status, replenishment status, abnormal status, and estimated status. S3. Traverse the inventory difference records in chronological order. For each inventory difference record to be processed, query the date occupancy status dictionary to obtain the current occupancy status of the natural day to which the end time of the inventory difference record belongs. If the current occupancy status is any one of replenishment status, abnormal status, or estimated status, then skip the inventory difference record; S4. For the inventory difference records that were not skipped in step S3, perform branch scheduling processing according to multiple mutually exclusive branches. The multiple branches include at least cross-day branches, replenishment branches, abnormal branches and normal branches, and generate the daily sales record of the natural day to which the end time belongs. S5. Write the daily sales records generated in step S4 into the historical daily sales pool, so that the historical daily sales pool continues to accumulate during the traversal process, and can be reused when calculating the average sales of the inventory difference records to be processed later, thereby obtaining the daily sales records of the target product for each natural day within the preset time period.
2. The e-commerce sales backward estimation method based on inventory difference according to claim 1, characterized in that, In step S4, for the inventory difference records that were not skipped in step S3, branch scheduling processing is performed according to multiple mutually exclusive branches, specifically including the following sub-steps: S41. Calculate the number of days spanned between the start and end times of the inventory difference records that were not skipped in step S3; S42. Determine whether the number of days spanning across days is greater than 1; if so, execute the cross-day branching process. If not, proceed to step S43; S43. Determine whether the inventory difference is less than 0; if so, execute the replenishment branch processing. If not, proceed to step S44; S44. Call the exception determination logic to verify the inventory difference record; if it is determined to be abnormal, execute the exception branch processing; If the condition is determined to be non-abnormal, then the normal branch processing is executed.
3. The e-commerce sales backward estimation method based on inventory difference according to claim 2, characterized in that, The cross-day branching process specifically includes the following sub-steps: S421. Determine the sequence of natural days to be completed, wherein the sequence of natural days is all natural days from the day following the natural day to the natural day of the end time; S422. Traverse each unprocessed natural day in the natural day sequence, read the historical daily sales sample in the historical daily sales pool, calculate the average sales within a preset rolling window, and determine the average sales as the estimated sales for the unprocessed natural day. S423. The estimated sales volume of each pending natural day is used as the corresponding daily sales volume record, and the daily sales volume record is written into the historical daily sales volume pool. The occupancy status of the pending natural day in the date occupancy status dictionary is updated to the estimated status.
4. The e-commerce sales backward estimation method based on inventory difference according to claim 2, characterized in that, The replenishment branch processing specifically includes the following sub-steps: S431. Read the historical daily sales samples stored in the historical daily sales pool, calculate the average sales within a preset rolling window, and determine the average sales as the estimated sales for the day. S432. Retrieve the starting inventory, ending inventory, and estimated sales volume for the day determined in step S431 from the inventory difference record, and substitute them into a preset formula to calculate the estimated actual replenishment demand. The calculation formula is as follows: ; in, This indicates the estimated actual demand for replenishment. This indicates the end of inventory. Indicates the initial inventory. This indicates the estimated sales volume for the day; S433. The estimated sales volume of the day is used as the daily sales volume record, and the daily sales volume record is written into the historical daily sales volume pool. The occupancy status of the natural day to which the end time belongs in the date occupancy status dictionary is updated to the replenishment status.
5. The e-commerce sales backward estimation method based on inventory difference according to claim 2, characterized in that, The anomaly detection logic is invoked to verify the inventory difference record; if an anomaly is detected, the anomaly branch processing is executed, which specifically includes the following sub-steps: S441. Extract the absolute value of the inventory difference and the initial inventory value from the inventory difference record; S442. Determine whether the absolute value of the inventory difference component is greater than a preset first threshold, and whether the ratio of the absolute value of the inventory difference component to the starting inventory value is greater than a preset second threshold; if both conditions are met, it is determined to be an abnormal fluctuation. S443. After determining that the fluctuation is abnormal, read the historical daily sales samples in the historical daily sales pool, calculate the average sales within the preset rolling window, and determine the average sales as the estimated sales for the day. S444. The estimated sales volume of the day is used as the daily sales volume record, and the daily sales volume record is written into the historical daily sales volume pool. The occupancy status of the natural day to which the end time belongs in the date occupancy status dictionary is updated to an abnormal status.
6. The e-commerce sales backward estimation method based on inventory difference according to claim 2, characterized in that, The normal branch processing specifically includes the following sub-steps: S451. The portion of the inventory difference that is greater than zero is added to the actual sales volume of the natural day to which the end time belongs; S452. Update the occupancy status of the natural day to which the end time belongs in the date occupancy status dictionary to the actual status, and write the actual sales volume as the corresponding daily sales volume record into the historical daily sales volume pool.
7. The e-commerce sales backward estimation method based on inventory difference according to claim 1, characterized in that, In step S3, during the process of traversing the inventory difference records in chronological order, a product switching preprocessing step is also included, which specifically includes the following sub-steps: S31. Monitor whether the product identifier corresponding to the current inventory difference record is the same as the product identifier of the previous inventory difference record; S32. If they are different, write the daily sales result corresponding to the previous product identifier into the database. S33. Clear the date occupancy status dictionary and the historical daily sales pool corresponding to the previous product identifier.
8. The e-commerce sales backward estimation method based on inventory difference according to claim 1, characterized in that, It also includes the e-commerce market capacity forecasting step, which specifically includes the following sub-steps: S61. Obtain the average monthly sales of each product in the target track. The average monthly sales are obtained based on the daily sales records output in step S5. S62. After filtering out invalid data with monthly average sales not greater than zero, sort the data in descending order according to the monthly average sales to generate a product sequence with a ranking number. S63. Fit power law distribution parameters to the product sequence. The power law distribution is used to characterize the proportional relationship between the average monthly sales and the ranking number. S64. Calculate the goodness of fit of the power law distribution. When the goodness of fit is lower than the preset confidence threshold, output a low confidence alarm message. S65. Calculate the total monthly sales forecast of the top N products in the target track. The total monthly sales forecast is the sum of the actual average monthly sales of the monitored products and the power-law predicted sales of the unmonitored bottom products.
9. An e-commerce sales back-calculation system based on inventory difference, used to implement the method as described in any one of claims 1 to 8, characterized in that, The system includes: The inventory difference construction module is used to obtain the inventory snapshot sequence of the target product within a preset time period, and generate an inventory difference record based on two adjacent inventory snapshots; the inventory difference record includes a start time, a start inventory, an end time, an end inventory, and an inventory difference. The date occupancy status maintenance module is used to establish a date occupancy status dictionary with natural day identifiers as keys for the target product, as well as a historical daily sales pool with natural day identifiers as keys; each natural day identifier in the date occupancy status dictionary corresponds to an occupancy status, and the occupancy status includes actual status, replenishment status, abnormal status, and estimated status; The date occupancy prediction module is used to traverse the inventory difference records in chronological order. For each inventory difference record to be processed, the module queries the date occupancy status dictionary to obtain the current occupancy status of the natural day to which the end time of the inventory difference record belongs. If the current occupancy status is any one of replenishment status, abnormal status, or estimated status, the inventory difference record is skipped. The branch scheduling processing module is used to perform branch scheduling processing on the inventory difference records that have not been skipped according to multiple mutually exclusive branches. The multiple branches include at least cross-day branches, replenishment branches, abnormal branches and normal branches, and generate the daily sales record of the natural day to which the end time belongs. The historical daily sales pool management module is used to write the generated daily sales records into the historical daily sales pool, so that the historical daily sales pool continues to accumulate during the traversal process, and can be reused when calculating the average sales of the inventory difference records to be processed later, thereby obtaining the daily sales records of the target product for each natural day within the preset time period.
10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the steps of the e-commerce sales backward calculation method based on inventory difference as described in any one of claims 1 to 8.
