payment_details i18n

This commit is contained in:
jysperm
2014-10-07 03:54:59 +08:00
parent 0d274cd50b
commit 53eddd4866
8 changed files with 57 additions and 31 deletions

View File

@@ -20,9 +20,15 @@
* 类名使用大驼峰命名,如 `SampleClass`
* 优先使用单引号
* 总是省略所有跨行的括号和花括号,尽可能省略掉函数调用的括号
* 变量名使用全小写用下划线分割,函数名使用小驼峰
## 命名
* 尽量不缩写术语
* 总是使用 `callback` 命名回调函数
* `t_` 前缀表示这是一个待翻译的字符串 ID
* `l_` 前缀表示这是一个已经翻译好的字符串
## HTML
* CSS 类名和 ID 使用全小写用连字符分割

View File

@@ -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)

View File

@@ -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

View File

@@ -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')

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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": "比特币支付 <a href='https://blockchain.info/tx/__order_id__'>__short_order_id__</a>"
}
}