diff --git a/DOC/Coding-Style.md b/DOC/Coding-Style.md index e0d2cb2..0d0f5ff 100644 --- a/DOC/Coding-Style.md +++ b/DOC/Coding-Style.md @@ -20,9 +20,15 @@ * 类名使用大驼峰命名,如 `SampleClass` * 优先使用单引号 * 总是省略所有跨行的括号和花括号,尽可能省略掉函数调用的括号 - * 变量名使用全小写用下划线分割,函数名使用小驼峰 +## 命名 + +* 尽量不缩写术语 +* 总是使用 `callback` 命名回调函数 +* `t_` 前缀表示这是一个待翻译的字符串 ID +* `l_` 前缀表示这是一个已经翻译好的字符串 + ## HTML * CSS 类名和 ID 使用全小写用连字符分割 diff --git a/core/pluggable.coffee b/core/pluggable.coffee index e1d6da9..8c7de47 100644 --- a/core/pluggable.coffee +++ b/core/pluggable.coffee @@ -39,6 +39,10 @@ exports.hooks = # name switch_buttons: [] + pay: + # type, filter: function(account, deposit_log, callback(l_details)) + display_payment_details: [] + service: 'service_name': # action: function(account, callback) diff --git a/core/router/panel.coffee b/core/router/panel.coffee index 6caf820..83cbacb 100644 --- a/core/router/panel.coffee +++ b/core/router/panel.coffee @@ -26,7 +26,22 @@ exports.get '/pay', requireAuthenticate, renderAccount, (req, res) -> sort: created_at: -1 limit: LIMIT - .toArray callback + .toArray (err, deposit_logs) -> + async.each deposit_logs, (deposit_log, callback) -> + matched_hook = _.find pluggable.selectHook(req.account, 'view.pay.display_payment_details'), (hook) -> + return hook?.type == deposit_log.payload.type + + unless matched_hook + return callback() + + matched_hook.filter req.account, deposit_log, (l_payment_details) -> + deposit_log.l_payment_details = l_payment_details + + callback() + + , -> + console.log deposit_logs + callback null, deposit_logs billing_log: (callback) -> mBalanceLog.find diff --git a/core/view/panel/pay.jade b/core/view/panel/pay.jade index 42341bd..4260fc3 100644 --- a/core/view/panel/pay.jade +++ b/core/view/panel/pay.jade @@ -3,9 +3,6 @@ extends ../layout prepend header title #{t('common.charge')} | #{config.web.name} -append header - link(rel='stylesheet', href='/style/panel/pay.css') - block main .row header= t('common.charge') @@ -26,14 +23,10 @@ block main tr td= moment(item.created_at).format('YYYY-MM-DD HH:mm:ss') td #{item.amount.toFixed(2)} #{t('plan.currency.' + config.billing.currency)} - if item.attribute.type == 'taobao' - td 淘宝支付 订单号:#{item.attribute.order_id} - else if item.attribute.type == 'bitcoin' - td - | 比特币支付   - a(href= 'https://blockchain.info/tx/#{item.attribute.order_id}')= item.attribute.order_id.slice(0, 40) + if item.l_payment_details + td!= item.l_payment_details else - td #{item.attribute.type} #{item.attribute.order_id} + td #{item.payload.type} #{item.payload.order_id} .row header= t('view.pay.billing_log') diff --git a/core/view/ticket/list.jade b/core/view/ticket/list.jade index 7b240de..f80b421 100644 --- a/core/view/ticket/list.jade +++ b/core/view/ticket/list.jade @@ -1,21 +1,21 @@ extends ../layout -mixin displayTicketStatus(t_status) - - status = t('ticket_status.' + t_status) +mixin displayTicketStatus(status) + - l_status = t('ticket_status.' + status) - if t_status == 'closed' - span.text-muted= status - else if t_status == 'open' - span.text-primary= status - else if t_status == 'pending' - span.text-warning= status - else if t_status == 'finish' - span.text-success= status + if status == 'closed' + span.text-muted= l_status + else if status == 'open' + span.text-primary= l_status + else if status == 'pending' + span.text-warning= l_status + else if status == 'finish' + span.text-success= l_status else - | #{status} + | #{l_status} -mixin displayTicketsTable(t_status, tickets) - h4= t('ticket_status.' + t_status) +mixin displayTicketsTable(status, tickets) + h4= t('ticket_status.' + status) table.table.table-hover thead diff --git a/core/view/ticket/view.jade b/core/view/ticket/view.jade index 5299a25..296909d 100644 --- a/core/view/ticket/view.jade +++ b/core/view/ticket/view.jade @@ -11,16 +11,16 @@ block main header | #{ticket.title}   - - status = t('ticket_status.' + t_status) + - l_status = t('ticket_status.' + status) if ticket.status == 'closed' - span.small.text-muted= status + span.small.text-muted= l_status else if ticket.status == 'open' - span.small.text-primary= status + span.small.text-primary= l_status else if ticket.status == 'pending' - span.small.text-warning= status + span.small.text-warning= l_status else if ticket.status == 'finish' - span.small.text-success= status + span.small.text-success= l_status p!= ticket.content_html diff --git a/plugin/bitcoin/index.coffee b/plugin/bitcoin/index.coffee index 36a5b03..db3a37e 100644 --- a/plugin/bitcoin/index.coffee +++ b/plugin/bitcoin/index.coffee @@ -30,6 +30,13 @@ exports.registerHook 'billing.payment_methods', , (err, html) -> callback html +exports.registerHook 'view.pay.display_payment_details', + type: 'bitcoin' + filter: (account, deposit_log, callback) -> + callback account.t 'plugins.bitcoin.view.payment_details', + order_id: deposit_log.payload.order_id + short_order_id: deposit_log.payload.order_id[0 .. 40] + app.post '/bitcoin/coinbase_callback', (req, res) -> mAccount.findOne 'pluggable.bitcoin.bitcoin_deposit_address': req.body.address diff --git a/plugin/bitcoin/locale/zh_CN.json b/plugin/bitcoin/locale/zh_CN.json index dd88ecf..b184658 100644 --- a/plugin/bitcoin/locale/zh_CN.json +++ b/plugin/bitcoin/locale/zh_CN.json @@ -2,6 +2,7 @@ "": "比特币", "view": { "payment_tips": "你可以直接向该地址发送比特币。在经过一次确认后,系统会实时地,自动为你折算充值金额,最小支付金额为 0.0005.", - "exchange_rate_tips": "实时汇率:10 CNY = __rate10__ BTC" + "exchange_rate_tips": "实时汇率:10 CNY = __rate10__ BTC", + "payment_details": "比特币支付 __short_order_id__" } }