mirror of
https://github.com/HackPlan/RootPanel.git
synced 2026-04-23 19:21:04 +08:00
fixbugs
This commit is contained in:
@@ -26,13 +26,16 @@ exports.calcBilling = (account, isForce, callback) ->
|
||||
|
||||
modifier =
|
||||
$set:
|
||||
'attribute.last_billing_at': new Date account.attribute.last_billing_at.getTime() - billing_time * 60 * 1000
|
||||
'attribute.last_billing_at': new Date account.attribute.last_billing_at.getTime() + billing_time * 3600 * 1000
|
||||
$inc:
|
||||
'attribute.balance': -amount
|
||||
|
||||
if !account.attribute.arrears_at and account.attribute.balance < 0
|
||||
modifier.$set['attribute.arrears_at'] = new Date()
|
||||
|
||||
if account.attribute.balance > 0
|
||||
modifier.$set['attribute.arrears_at'] = null
|
||||
|
||||
mAccount.update _id: account._id, modifier, {}, ->
|
||||
mAccount.findId account._id, (account) ->
|
||||
callback account
|
||||
|
||||
@@ -67,7 +67,7 @@ exports.register = (username, email, passwd, callback = null) ->
|
||||
service: []
|
||||
plans: []
|
||||
balance: 0
|
||||
last_billing: new Date()
|
||||
last_billing_at: new Date()
|
||||
arrears_at: null
|
||||
resources_limit: []
|
||||
tokens: []
|
||||
@@ -146,7 +146,8 @@ exports.joinPlan = (account, plan, callback) ->
|
||||
exports.update _id: account._id,
|
||||
$addToSet:
|
||||
'attribute.plans': plan
|
||||
'attribute.resources_limit': billing.calcResourcesLimit account.attribute.plans
|
||||
$set:
|
||||
'attribute.resources_limit': billing.calcResourcesLimit account.attribute.plans
|
||||
, {}, callback
|
||||
|
||||
exports.leavePlan = (account, plan, callback) ->
|
||||
@@ -154,7 +155,8 @@ exports.leavePlan = (account, plan, callback) ->
|
||||
exports.update _id: account._id,
|
||||
$pull:
|
||||
'attribute.plans': plan
|
||||
'attribute.resources_limit': billing.calcResourcesLimit account.attribute.plans
|
||||
$set:
|
||||
'attribute.resources_limit': billing.calcResourcesLimit account.attribute.plans
|
||||
, {}, callback
|
||||
|
||||
exports.incBalance = (account, amount, callback) ->
|
||||
|
||||
@@ -10,6 +10,7 @@ exports.loadPlugins = (app) ->
|
||||
for name in config.plugin.availablePlugin
|
||||
i18n.loadPlugin path.join(__dirname, "../plugin/#{name}/locale"), name
|
||||
|
||||
p = exports.get name
|
||||
plugin = exports.get name
|
||||
|
||||
app.use ('/plugin/' + name), p.action
|
||||
if plugin.action
|
||||
app.use ('/plugin/' + name), plugin.action
|
||||
|
||||
@@ -23,7 +23,7 @@ exports.get '/', requestAuthenticate, (req, res) ->
|
||||
name: name
|
||||
isEnable: name in req.account.attribute.plans
|
||||
|
||||
account.attribute.remaining_time = Math.ceil(billing.calcRemainingTime(req.account) / 24)
|
||||
account.attribute.remaining_time = Math.ceil(billing.calcRemainingTime(account) / 24)
|
||||
|
||||
widgets = []
|
||||
async.map req.account.attribute.service, (item, callback) ->
|
||||
@@ -41,6 +41,6 @@ exports.get '/', requestAuthenticate, (req, res) ->
|
||||
widgets = widgets.concat item
|
||||
|
||||
res.render 'panel',
|
||||
account: req.account
|
||||
account: account
|
||||
plans: plans
|
||||
widgets: widgets
|
||||
|
||||
Reference in New Issue
Block a user