61 lines
1.8 KiB
Lua
61 lines
1.8 KiB
Lua
|
|
DBStatistics = {}
|
||
|
|
local db = {}
|
||
|
|
local lastGetTime = {}
|
||
|
|
local timeOut = 60 * 1000
|
||
|
|
|
||
|
|
DBStatistics.clean = function()
|
||
|
|
end
|
||
|
|
|
||
|
|
DBStatistics.custtype_report = function(callback)
|
||
|
|
if db.custtype_report == nil or lastGetTime.custtype_report == nil or DateEx.nowMS - lastGetTime.custtype_report > 0 then
|
||
|
|
lastGetTime.custtype_report = DateEx.nowMS + timeOut
|
||
|
|
NetProto.send.custtype_report(
|
||
|
|
nil,
|
||
|
|
function(content)
|
||
|
|
if content.success then
|
||
|
|
db.custtype_report = content
|
||
|
|
end
|
||
|
|
callback(content)
|
||
|
|
end
|
||
|
|
)
|
||
|
|
else
|
||
|
|
Utl.doCallback(callback, db.custtype_report)
|
||
|
|
end
|
||
|
|
end
|
||
|
|
|
||
|
|
DBStatistics.order_report = function(callback)
|
||
|
|
if db.order_report == nil or lastGetTime.order_report == nil or DateEx.nowMS - lastGetTime.order_report > 0 then
|
||
|
|
lastGetTime.order_report = DateEx.nowMS + timeOut
|
||
|
|
NetProto.send.order_report(
|
||
|
|
nil,
|
||
|
|
function(content)
|
||
|
|
if content.success then
|
||
|
|
db.order_report = content
|
||
|
|
end
|
||
|
|
callback(content)
|
||
|
|
end
|
||
|
|
)
|
||
|
|
else
|
||
|
|
Utl.doCallback(callback, db.order_report)
|
||
|
|
end
|
||
|
|
end
|
||
|
|
|
||
|
|
DBStatistics.target_report = function(callback)
|
||
|
|
if db.target_report == nil or lastGetTime.target_report == nil or DateEx.nowMS - lastGetTime.target_report > 0 then
|
||
|
|
lastGetTime.target_report = DateEx.nowMS + timeOut
|
||
|
|
NetProto.send.target_report(
|
||
|
|
nil,
|
||
|
|
function(content)
|
||
|
|
if content.success then
|
||
|
|
db.target_report = content
|
||
|
|
end
|
||
|
|
callback(content)
|
||
|
|
end
|
||
|
|
)
|
||
|
|
else
|
||
|
|
Utl.doCallback(callback, db.target_report)
|
||
|
|
end
|
||
|
|
end
|
||
|
|
|
||
|
|
return DBStatistics
|