A kind of order bulk statistics method, computer equipment and storage based on server-side
Medium
Technical field
The invention belongs to Internet technical field more particularly to a kind of order bulk statistics method based on server-side, meters
Calculate machine equipment and storage medium.
Background technology
At present internet be broadcast live platform for user's amount of supplementing with money, daily order flowing water have reached it is relatively large, lead to
It needs big data technology to be supported to be counted in the case of often, service is then forwarded to by the data after big data stroke analysis
End uses.
As it can be seen that in the prior art, server-side must be strongly dependent upon big data technology, the realization method list of order bulk statistics
One.
Invention content
The embodiment of the present application is by providing a kind of order bulk statistics method, computer equipment and storage based on server-side
Medium, solve in the prior art server-side to the strong Dependence Problem of big data technology.
In a first aspect, this application provides a kind of order bulk statistics method based on server-side, which is characterized in that described
Method is applied in server device, including:
The statistics date of the first stroke order is obtained using function getFirstOrderByType (type);
Based on the statistics date of the first stroke order, first day statistics start time is obtained;
Add one day time to obtain described first day statistics finish time described first day statistics start time;
Based on described first day statistics start time and described first day statistics finish time, count described first day
Quantity on order, and using function addStaticData (data) be written order statistical form in;
Using last statistics finish time as statistics start time next time, by timed task system according to preset
Time interval call function historyDataRun () count the quantity on order of every day successively, and be written the order
In statistical form, completed until current all orders count.
Optionally, after current all orders statistics is completed, the method further includes:
Using function getMonthStatCacheTime () obtain finishing touch order the statistics date, it is described last
Order is contained in current all orders;
Based on the statistics date of the finishing touch order, the statistics finish time of the previous day is obtained;
The time that the statistics finish time of described the previous day subtracts one day is obtained into the statistics start time of described the previous day;
The statistics finish time of statistics start time and described the previous day based on described the previous day, by timed task system
Count described previous again according to preset time interval and preset statistics number call function currentDataRun ()
It quantity on order, and will be in the quantity on order that counted again update to the order statistical form.
Optionally, described based on described first day statistics start time and described first day statistics finish time, system
First day quantity on order is counted, and order statistical form is written using function addStaticData (data) and includes:
Based on described first day statistics start time and described first day statistics finish time, according to different payments
Mode counts first day quantity on order, and is written in order statistical form using function addStaticData (data).
Optionally, the means of payment includes wechat payment, Alipay payment or Unionpay's payment.
Present invention also provides a kind of order bulk statistics device based on server-side, which is characterized in that described device packet
It includes:
Acquiring unit, the statistics day for obtaining the first stroke order using function getFirstOrderByType (type)
Phase;
The acquiring unit is additionally operable to the statistics date based on the first stroke order, when obtaining first day statistics and starting
It carves;
The acquiring unit is additionally operable to add one day time to obtain described first described first day statistics start time
It statistics finish time;
Statistic unit was used for based on described first day statistics start time and described first day statistics finish time,
First day quantity on order is counted, and is written in order statistical form using function addStaticData (data);
The statistic unit is additionally operable to using last statistics finish time as statistics start time next time, by fixed
When task system count the order numbers of every day successively according to preset time interval call function historyDataRun ()
Amount, and be written in the order statistical form, it is completed until current all orders count.
Optionally, the acquiring unit is additionally operable to obtain finishing touch using function getMonthStatCacheTime ()
The statistics date of order, the finishing touch order are contained in current all orders;
The acquiring unit is additionally operable to the statistics date based on the finishing touch order, and the statistics for obtaining the previous day terminates
Moment;
The acquiring unit is additionally operable to obtain the time that the statistics finish time of described the previous day subtracts one day described previous
It statistics start time;
The statistics that the statistic unit is additionally operable to statistics start time and described the previous day based on described the previous day terminates
Moment, by timed task system according to preset time interval and preset statistics number call function currentDataRun
() updates the quantity on order counted again to the order statistical form to count the quantity on order of described the previous day again
In.
Optionally, the statistic unit was specifically used for based on described first day statistics start time and described first day
Finish time is counted, counts first day quantity on order according to the different means of payment, and use function
AddStaticData (data) is written in order statistical form.
Optionally, the means of payment includes wechat payment, Alipay payment or Unionpay's payment.
The third aspect, present invention also provides a kind of computer readable storage medium, the computer readable storage medium
It is stored with computer program, which is characterized in that the computer program realizes following steps when being executed by processor:
The statistics date of the first stroke order is obtained using function getFirstOrderByType (type);
Based on the statistics date of the first stroke order, first day statistics start time is obtained;
Add one day time to obtain described first day statistics finish time described first day statistics start time;
Based on described first day statistics start time and described first day statistics finish time, count described first day
Quantity on order, and using function addStaticData (data) be written order statistical form in;
Using last statistics finish time as statistics start time next time, by timed task system according to preset
Time interval call function historyDataRun () count the quantity on order of every day successively, and be written the order
In statistical form, completed until current all orders count.
Fourth aspect this application provides a kind of computer equipment, including processor, memory and is stored in memory
Computer program that is upper and can running on a processor, which is characterized in that the processor executes real when the computer program
Existing following steps:
The statistics date of the first stroke order is obtained using function getFirstOrderByType (type);
Based on the statistics date of the first stroke order, first day statistics start time is obtained;
Add one day time to obtain described first day statistics finish time described first day statistics start time;
Based on described first day statistics start time and described first day statistics finish time, count described first day
Quantity on order, and using function addStaticData (data) be written order statistical form in;
Using last statistics finish time as statistics start time next time, by timed task system according to preset
Time interval call function historyDataRun () count the quantity on order of every day successively, and be written the order
In statistical form, completed until current all orders count.
The embodiment of the present application is applied in server device, by using function getFirstOrderByType (type)
On the statistics date for obtaining the first stroke order, first day statistics start time is obtained, by described first day statistics start time
Add one day time to obtain described first day statistics finish time, to count first day quantity on order, and uses
Function addStaticData (data) is written in order statistical form, using last statistics finish time as system next time
Start time is counted, is united successively according to preset time interval call function historyDataRun () by timed task system
The quantity on order of every day is counted, and is written in the order statistical form, is completed until current all orders count.As it can be seen that clothes
Business end, which needs not rely on big data technology, can complete order bulk statistics, enrich the realization method of order bulk statistics.
Description of the drawings
Fig. 1 is the flow chart of the order bulk statistics method based on server-side provided in the embodiment of the present application;
Fig. 2 is the structural schematic diagram of the order bulk statistics device based on server-side provided in the embodiment of the present application;
Fig. 3 is the structural schematic diagram of the computer readable storage medium provided in the embodiment of the present application;
Fig. 4 is the structural schematic diagram of the computer equipment provided in the embodiment of the present application.
Specific implementation mode
The embodiment of the present application provides a kind of order bulk statistics method, computer equipment and storage Jie based on server-side
Matter, solve in the prior art server-side to the strong Dependence Problem of big data technology.Server-side can be made to be no longer dependent on big number
Order bulk statistics can be completed according to technology, enrich the realization method of order bulk statistics.
The technical solution of the embodiment of the present application is in order to solve the above technical problems, general thought is as follows:
The statistics date of the first stroke order is obtained using function getFirstOrderByType (type);
Based on the statistics date of the first stroke order, first day statistics start time is obtained;
Add one day time to obtain described first day statistics finish time described first day statistics start time;
Based on described first day statistics start time and described first day statistics finish time, count described first day
Quantity on order, and using function addStaticData (data) be written order statistical form in;
Using last statistics finish time as statistics start time next time, by timed task system according to preset
Time interval call function historyDataRun () count the quantity on order of every day successively, and be written the order
In statistical form, completed until current all orders count.
The embodiment of the present application is applied in server device, by using function getFirstOrderByType (type)
On the statistics date for obtaining the first stroke order, first day statistics start time is obtained, by described first day statistics start time
Add one day time to obtain described first day statistics finish time, to count first day quantity on order, and uses
Function addStaticData (data) is written in order statistical form, using last statistics finish time as system next time
Start time is counted, is united successively according to preset time interval call function historyDataRun () by timed task system
The quantity on order of every day is counted, and is written in the order statistical form, is completed until current all orders count.Server-side is not
It needs dependence big data technology that can complete order bulk statistics, enriches the realization method of order bulk statistics.
In order to better understand the above technical scheme, below in conjunction with attached drawing and specific embodiment, to above-mentioned technical proposal
It is further elaborated.It should be appreciated that specific embodiment described herein is not used to limit only to explain the application
Determine the application.
The embodiment of the present application can be based on but be not limited to Redis (Remote Dictionary Server, long-range dictionary clothes
Be engaged in device), MySQL (Structured Query Language, structured query language) and timed task systems technology carry out reality
It is existing, it is introduced based on the embodiment of the present application only techniques described above, is not used to limit the application.It is understood that
In some other realization methods, similar other storage systems, data base management system and timed task can also be used
System.
The related introduction of above-mentioned technology is as follows:
Redis:It is a key-value storage system.Redis provides some abundant data structures, including lists
(chained list), sets (set), ordered sets (ordered set) and hashes (Hash type), certainly also have and
Strings (character string) structure the same Memcached.Data cached functions of the Redis as an efficient network, performance
High, Redis can support the read-write frequency per second more than 100K+.
Mysql:It is a kind of associated data library management system, linked database saves the data in different tables, without
It is that all data are placed in one big warehouse, which adds speed and improves flexibility, is currently that WEB is managed more
Common data management system.
Timed task system:The system that certain tasks can be periodically executed, can setup parameter timing request setting interface.
In order to illustrate technical solution described herein, illustrated below by specific embodiment.
Embodiment one:
Referring to Fig. 1, the order bulk statistics method provided in this embodiment based on server-side includes the following steps:
S101, the statistics date that the first stroke order is obtained using function getFirstOrderByType (type);
Specifically, MySql order tables can be inquired by using function getFirstOrderByType (type) to obtain
The statistics date of the first stroke order.It includes but not limited to logical that function getFirstOrderByType (type), which implements process,
Cross linked database, inquiry SELECT o.id, o.notify_time, FROM_UNIXTIME (o.notify_time, ' %
Y-%m-%d') as time FROM`order`as o INNER JOIN $ joinTable as g WHERE o.id=g.id
AND o.state IN (1,2) AND o.notify_time>1 sentences of 0ORDER BY o.id ASC limit obtain first
Order data, wherein notify_time are the statistics date of the first stroke order.It is understood that this method is only to realize
The one way in which of step S101 is not used to limit the application.
Furthermore, it is possible to the statistics date of the first stroke order is stored in Redis cachings by set () method, for next time
It is used when statistics.
S102, the statistics date based on the first stroke order, obtain first day statistics start time;
Preferably, the initial time on the statistics date of the first stroke order can be used, i.e., zero is used as first in zero second when zero
It statistics start time, it is of course also possible to using other moment, as long as ensure the moment the first stroke order the statistics moment
Before, too many restriction is not done herein.
S103, at the end of being added one day time obtained first day statistics described first day statistics start time
It carves;
Wherein, it is in order to more meet actual statistics custom, according to the ability and reality of equipment by way of daily counting
Border situation can also select to be counted by other time intervals, not do too many restriction herein.
S104, based on described first day statistics start time and described first day statistics finish time, described in statistics
First day quantity on order, and be written in order statistical form using function addStaticData (data);
Wherein, order statistical form can be newly-built statistical form, first day quantity on order can be encapsulated into data,
Then it is written in order statistical form using function addStaticData (data).
S105, using last statistics finish time as statistics start time next time, pressed by timed task system
The quantity on order of every day is counted successively according to preset time interval call function historyDataRun (), and institute is written
It states in order statistical form, is completed until current all orders count.
Wherein, time interval can be one minute, 30 seconds or other times, specifically can be according to the ability and reality of equipment
It needs, rational time interval is set, it, can faster completion statistics when time interval is arranged shorter.
It is understood that first day statistics start time was obtained by step S102, so every day does not wrap
It includes first day, refers within first day every day after first day to current time.
Specifically, the implementation procedure of one day quantity on order of statistics can be packaged into function historyDataRun (),
Call the function according to preset time interval by timed task system again, then can in the short time current all orders,
I.e. History Order, all statistics is completed.
As it can be seen that in the present embodiment, server-side, which is not need to rely on big data technology, can complete order bulk statistics, enrich
The realization methods of order bulk statistics.
Under the premise of History Order counts completion, daily quantity on order subsequently can be only safeguarded, work as when needing to inquire
When preceding quantity on order, as long as the same day current quantity on order is added History Order quantity.But in view of in some tools
In the case of body is realized, pay invoice the problem of there may be effective property, such as the previous day order, when talent's payment, then
The quantity on order of yesterday can be updated again in every day.
So further, after the completion of current all orders statistics, i.e., in the statistical basis of completion History Order,
It can also include the following steps:
A. function getMonthStatCacheTime () is used to obtain the statistics date of finishing touch order;
Wherein, finishing touch order is the finishing touch order in current all orders, i.e. History Order in step S105
In finishing touch order.
Wherein it is possible to the statistics date of finishing touch order is used into function setMonthStatTime (time), wherein
Using in set (time) method deposit Redis cachings, used when for counting next time.
B. on the statistics date based on the finishing touch order, the statistics finish time of the previous day is obtained;
Specifically, can will be carved at the beginning of the statistics date of finishing touch order, i.e., zero zero second is as previous when zero
It statistics finish time.It is understood that the previous day refers to that the statistics date of the finishing touch order is corresponding previous
It, that is, finishing touch order statistics the date yesterday.
C. the time that the statistics finish time of described the previous day subtracts one day is obtained into the statistics start time of described the previous day;
D. the statistics finish time of the statistics start time and described the previous day based on described the previous day, by timed task system
Before system counts described again according to preset time interval and preset statistics number call function currentDataRun ()
One day quantity on order, and will be in the quantity on order that counted again update to the order statistical form.
Wherein it is possible to according to the ability and actual needs of equipment, rational time interval and statistics number, statistics time are set
Number.It will be evident that when time interval is arranged smaller, statistics number is arranged more, and data are more accurate.
Specifically, using function getMonthStatCacheTime () method, inquires History Order and count on the same day
Time time, as the statistics end time of finishing touch order, time-86400 starts as the statistics of finishing touch order
Time, then the quantity on order using orderStat (time-86400, time) method statistics to the previous day.It then again will be above-mentioned
Method is encapsulated into function currentDataRun (), by timed task system according to preset time interval and preset system
Metering number call function currentDataRun () carrys out circle statistics.
As it can be seen that the quantity on order by updating the previous day, can improve the accuracy of quantity on order.It is ordered daily subsequent
In single statistics, since statistics is completed in History Order, only the order of yesterday and today can be counted, realized every day
Real-time query order statistics effect, solve the problems, such as big data statistics and caused by order count delay.
It should also be noted that, the present embodiment can also count quantity on order according to the different means of payment.In order to
Data analysis is carried out to all kinds of different statistical data.Wherein, the means of payment includes but not limited to wechat payment, Alipay payment
Or Unionpay's payment, do not do too many restriction herein.
It should also be noted that, the realization of the present embodiment is based on server device, server device is including but not limited to straight
Broadcast the web server used in platform.
Further, the present embodiment can also include the steps that order inquiries, specially use function getData
(param), the order data that statistics is completed is inquired, wherein param is the parameter of inquiry, wherein includes to look into Param parameters
At the beginning of inquiry, the end time, type etc..So that administrative staff can be according to items such as time started, end time and types
Part real-time query quantity on order.
In order to make it easy to understand, this implementation is explained from the angle of application scenarios again below.
The considerations of user A is for cost and time, it is desirable to by realizing that the order batch of live streaming platform is united based on server-side
Meter, so as to real-time query quantity on order.First, the statistics date 2018-1-1 of the first stroke order of live streaming platform is obtained,
It will then be carved at the beginning of first day and be set as 2018-1-1 00:00:00, the time plus one day will be carved at the beginning of first day,
The finish time for obtaining first day is 2018-1-2 00:00:00, the order of finish time is carved at the beginning of obtaining first day
Quantity, as first day quantity on order, and be stored in order statistical form, then using first day finish time as second day
Start time obtains second day quantity on order with same method, and so on, it calculates arrive current date 2018-2- always
15 quantity on order, so far, History Order statistics are completed.In the subsequent time, only need to count yesterday and today again daily
Quantity on order safeguard order statistical form.The order statistical of yesterday is to obtain the statistics closing day of finishing touch order
Phase, on the day of 2018-2-15, the statistics Close Date of finishing touch order is 2018-2-15, then at the end of the statistics of yesterday
It is 2018-2-15 00 to carve:00:00, one day time is subtracted, the statistics start time 2018-2-14 00 of yesterday is obtained:00:
00, according to mode every two hours primary, that daily statistics is 6 times, the quantity on order of yesterday is recalculated, and update to order and count
In table.This day 2018-2-20 has been arrived later, and user A intentionally gets the total number of orders of live streaming platform, then by calculating 2018-2-
The quantity on order on 20 same day plus History Order quantity can quick obtaining to the required data of user A.
Based on same inventive concept, this application provides a kind of order bulk statistics device based on server-side refers to figure
2, embodiment two is introduced below in conjunction with Fig. 2.
Embodiment two:
Referring to Fig. 2, the order bulk statistics device provided in this embodiment based on server-side includes:
Acquiring unit 201, the statistics for obtaining the first stroke order using function getFirstOrderByType (type)
Date;
The acquiring unit 201 is additionally operable to the statistics date based on the first stroke order, obtains first day statistics and opens
Begin the moment;
The acquiring unit 201 is additionally operable to add one day time to obtain described described first day statistics start time
One day statistics finish time;
Statistic unit 202, at the end of based on described first day statistics start time and first day statistics
It carves, counts first day quantity on order, and be written in order statistical form using function addStaticData (data);
The statistic unit 202 is additionally operable to using last statistics finish time as statistics start time next time,
Ordering for every day is counted successively according to preset time interval call function historyDataRun () by timed task system
Odd number amount, and be written in the order statistical form, it is completed until current all orders count.
The order bulk statistics device based on server-side and the embodiment of the present application one that the embodiment of the present application two provides provide
The order bulk statistics method based on server-side belong to same design, specific implementation process refers to specification full text, herein
It repeats no more.
Based on same inventive concept, this application provides a kind of computer readable storage mediums, refer to Fig. 3, below will knot
Fig. 3 is closed embodiment three is introduced.
Embodiment three:
A kind of computer readable storage medium 300 is present embodiments provided, the computer readable storage medium 300 stores
There are computer program 311, the computer program 311 to realize following steps when being executed by processor:
The statistics date of the first stroke order is obtained using function getFirstOrderByType (type);
Based on the statistics date of the first stroke order, first day statistics start time is obtained;
Add one day time to obtain described first day statistics finish time described first day statistics start time;
Based on described first day statistics start time and described first day statistics finish time, count described first day
Quantity on order, and using function addStaticData (data) be written order statistical form in;
Using last statistics finish time as statistics start time next time, by timed task system according to preset
Time interval call function historyDataRun () count the quantity on order of every day successively, and be written the order
In statistical form, completed until current all orders count.
In specific implementation process, when which is executed by processor, it may be implemented any in embodiment one
Embodiment, details are not described herein again.
Based on same inventive concept, this application provides a kind of computer equipments, refer to Fig. 4, below in conjunction with Fig. 4 to reality
Example four is applied to be introduced.
Example IV:
This application provides a kind of computer equipment 400, including processor 420, memory 410 and it is stored in memory
On 410 and the computer program 411 that can be run on processor 420, the processor 420 execute the computer program 411
Shi Shixian following steps:
The statistics date of the first stroke order is obtained using function getFirstOrderByType (type);
Based on the statistics date of the first stroke order, first day statistics start time is obtained;
Add one day time to obtain described first day statistics finish time described first day statistics start time;
Based on described first day statistics start time and described first day statistics finish time, count described first day
Quantity on order, and using function addStaticData (data) be written order statistical form in;
Using last statistics finish time as statistics start time next time, by timed task system according to preset
Time interval call function historyDataRun () count the quantity on order of every day successively, and be written the order
In statistical form, completed until current all orders count.
By the computer equipment that the present embodiment is introduced be implement the embodiment of the present application one in it is a kind of based on server-side
Equipment used by order bulk statistics method, so based on the method described in the embodiment of the present application one, belonging to this field
Technical staff can understand the specific implementation mode and its various change form of the computer equipment of the present embodiment, so herein
How method in the embodiment of the present application is realized if being no longer discussed in detail for the computer equipment.As long as the affiliated technology people in this field
Member implements equipment used by the method in the embodiment of the present application, belongs to the range to be protected of the application, no longer superfluous herein
It states.
It should be understood by those skilled in the art that, embodiments herein can be provided as method, system or computer program
Product.Therefore, complete hardware embodiment, complete software embodiment or reality combining software and hardware aspects can be used in the application
Apply the form of example.Moreover, the application can be used in one or more wherein include computer usable program code computer
The computer program product implemented in usable storage medium (including but not limited to magnetic disk storage CD-ROM, optical memory etc.)
Form.
The application is with reference to method, the flow of equipment (system) and computer program product according to the embodiment of the present application
Figure and/or block diagram describe.It should be understood that can be realized by computer program instructions every first-class in flowchart and/or the block diagram
The combination of flow and/or box in journey and/or box and flowchart and/or the block diagram.These computer programs can be provided
Instruct the processor of all-purpose computer, special purpose computer, Embedded Processor or other programmable data processing devices to produce
A raw machine so that the instruction executed by computer or the processor of other programmable data processing devices is generated for real
The device for the function of being specified in present one flow of flow chart or one box of multiple flows and/or block diagram or multiple boxes.
These computer program instructions, which may also be stored in, can guide computer or other programmable data processing devices with spy
Determine in the computer-readable memory that mode works so that instruction generation stored in the computer readable memory includes referring to
Enable the manufacture of device, the command device realize in one flow of flow chart or multiple flows and/or one box of block diagram or
The function of being specified in multiple boxes.
These computer program instructions also can be loaded onto a computer or other programmable data processing device so that count
Series of operation steps are executed on calculation machine or other programmable devices to generate computer implemented processing, in computer or
The instruction executed on other programmable devices is provided for realizing in one flow of flow chart or multiple flows and/or block diagram one
The step of function of being specified in a box or multiple boxes.
Although the preferred embodiment of the application has been described, created once a person skilled in the art knows basic
Property concept, then additional changes and modifications may be made to these embodiments.So it includes excellent that the following claims are intended to be interpreted as
It selects embodiment and falls into all change and modification of the application range.
Obviously, those skilled in the art can carry out the application essence of the various modification and variations without departing from the application
God and range.In this way, if these modifications and variations of the application belong to the range of the application claim and its equivalent technologies
Within, then the application is also intended to include these modifications and variations.