Class: bank

bank

new bank(opts)

银行对象
Name Type Description
opts Object 配置属性 格式:{uri:'网络地址'}

Methods

accounts(opts, cb)

获取账户信息列表
Name Type Default Description
opts Object {} optional 参数
cb callback function(err,result){} optional 回调
Examples
opts参数:{
 token: (可选, 如果不填,自动从storage中取值)
 userId: 用户id(可选,默认查询所有跟自己相关的账户)
 accountId: 账户id(可选,默认查询所有账户)
 page: 第几页(可选)
 rows: 一页显示几行(可选)
 search: 模糊搜索用户(可选)
}
cb参数格式:
result参数:{
     "page": 1,
     "pages": 2,
     "total": 3,
     "rows": [
         {
             "id": "账户id",
             "name": "账户名",
             "status": "账户状态",
              "user": {
                  "id": "用户id",
                  "userId": "用户ObjectId",
                  "name": "用户名",
                  .....
              },
              "holds": {
                  (ctcode): {
                      name: 币种名称
                      overdraw: 透支数量
                      amount: 数量
                      amountLocked: 被锁定数量
                      amountValid: 有效数量
                  }
              }
          }
     ]
    }
err参数:{
 err: 错误码,
 msg: 错误信息
}

exchange(opts, cb)

兑换
Name Type Default Description
opts Object {} optional 参数
cb callback function(err,result){} optional 回调
Examples
fromUserId,fromAccountId,toUserId,toAccountId都不填默认当前用户默认账户不同币种兑换
opts参数:{
  token: (可选, 如果不填,自动从storage中取值)
  fromUserId: 转出用户(可选,sso.user.id,如果不填,取当前用户)
  fromAccountId: 转出账户(可选,如果不填,取默认帐户),
  toUserId: 转入用户(可选,sso.user.id,如果不填,取当前用户)
  toAccountId: 转入账户(可选,如果不填,取默认帐户),
  fromCTCode: 转出币种编码(必填)
  fromAmount: 转出多少(必填)
  toCTCode: 转入币种编码(必填)
  toAmount: 转入多少(必填)
  payId: 支付单号(可选)
  attach: 附加信息(可选)
  orderId: 商户自编订单号(可选)
  memo: 备注信息(可选)
}
result参数:{
  fromCTCode: 转出币种编码
  fromAmount: 转出多少
  toCTCode: 转入币种编码
  toAmount: 转入多少
 }
err参数:{
 err: 错误码,
 msg: 错误信息
}

exchangeRate(opts, cb)

币种间兑率
Name Type Default Description
opts Object {} optional 参数
cb callback function(err,result){} optional 回调
Examples
opts参数:{
}
result参数:{
  "cny:tb":10,
  "ny:jb":1000,
  "dbj:tb":10,
  "dbj:jb":10000
 }
err参数:{
 err: 错误码,
 msg: 错误信息
}

history(opts, cb)

获取交易历史
Name Type Default Description
opts Object {} optional 参数
cb callback function(err,result){} optional 回调
Examples
opts参数:{
  token: (可选, 如果不填,自动从storage中取值)
  userId: 用户id(可选,默认查询所有跟自己相关的交易记录,可传数组).
  startDate: 开始时间(可选).
  endDate: 结束时间(可选).
  ctCode: 币种(可选).
  statType: 统计类型(可选,0:按天,1:按月,2:按年).
  page: 第几页(可选).
  rows: 一页显示几行(可选).
}
result参数:{
 }
err参数:{
 err: 错误码,
 msg: 错误信息
}

isCP(opts, cb)

是否为cp用户
Name Type Default Description
opts Object {} optional 参数
cb callback function(err,result){} optional 回调
Examples
opts参数:{
  token: (可选)
  userId: 用户id(可选)
}
result参数:{
 ret:'true|false'
 }
err参数:{
 err: 错误码,
 msg: 错误信息
}

isVaildPasswd(opts, cb)

密码是否有效
Name Type Default Description
opts Object {} optional 参数
cb callback function(err,result){} optional 回调
Examples
opts参数:{
  token: (可选)
  userId: 用户id(可选,token不提供为必填)
  passwd: 密码(必填)
}
result参数:{
 ret:'true|false'
 }
err参数:{
 err: 错误码,
 msg: 错误信息
}

preauth(opts, cb)

预授权
Name Type Default Description
opts Object {} optional 参数
cb callback function(err,result){} optional 回调
Examples
userId,accountId必填之一
opts参数:{
  token: (可选, 如果不填,自动从storage中取值)
  userId: 被预授权用户(可选,sso.user.id)
  accountId: 被预授权账户(可选,如果不填,取默认帐户),
  ctCode: 币种编码(必填)
  amount: 数量(必填,allAmount为1时可不填)
  allAmount: 转出全部(可选,为1时amount被忽略)
}
result参数:{
 ctCode: 币种,
 amount: 数量,
 amountValid: 有效余额,
 totalAmount: 总授权数量
 }
err参数:{
 err: 错误码,
 msg: 错误信息
}

preauthCancel(opts, cb)

预授权取消
Name Type Default Description
opts Object {} optional 参数
cb callback function(err,result){} optional 回调
Examples
userId,accountId必填之一
opts参数:{
  token: (可选, 如果不填,自动从storage中取值)
  userId: 被预授权用户(可选,sso.user.id)
  accountId: 被预授权账户(可选,如果不填,取默认帐户),
  ctCode: 币种编码(必填)
  amount: 数量(必填,allAmount为1时可不填)
  allAmount: 转出全部(可选,为1时amount被忽略)
}
result参数:{
 ctCode: 币种,
 amount: 数量,
 amountValid: 有效余额,
 totalAmount: 总授权数量
 }
err参数:{
 err: 错误码,
 msg: 错误信息
}

preauthList(opts, cb)

预授权列表
Name Type Default Description
opts Object {} optional 参数
cb callback function(err,result){} optional 回调
Examples
opts参数:{
 token: (可选, 如果不填,自动从storage中取值)
 page: 第几页(可选)
 rows: 一页显示几行(可选)
}
result参数:{
 }
err参数:{
 err: 错误码,
 msg: 错误信息
}

query(opts, cb)

获取账户信息
Name Type Default Description
opts Object {} optional 参数
cb callback function(err,result){} optional 回调
Examples
opts参数:{
 token: (可选, 如果不填,自动从storage中取值)
 userId: 用户id(sso.user.id, 可选,如果不填,取当前登陆用户)
 accountId: 账户id(可选, 如果不填,取用户默认帐户)
 ctCode: [要查询的币种编码数组](可选, 如果不填,取全部)
}
cb参数格式:
result参数:{
 id: (帐户id)
 name: "账户名",
 holds: {
     (ctcode): {
          overdraw: 透支数量
          amount: 数量
          amountLocked: 被锁定数量
          amountValid: 有效数量
     }
 }
err参数:{
 err: 错误码,
 msg: 错误信息
}

resetPasswd(opts, cb)

重置账号密码
Name Type Default Description
opts Object {} optional 参数
cb callback function(err,result){} optional 回调
Examples
opts参数:{
  token: (可选, 如果不填,自动从storage中取值)
  key: 手机号(必填)
  code: 验证码(必填)
  passwd: 新密码(必填)
}
result参数:{
 }
err参数:{
 err: 错误码,
 msg: 错误信息
}

status(opts, cb)

更新账户状态
Name Type Default Description
opts Object {} optional 参数
cb callback function(err,result){} optional 回调
Examples
opts参数:{
  token: (可选, 如果不填,自动从storage中取值)
  userId: 用户ObjectId(必填).
  status: 状态(必填)
}
result参数:{
 }
err参数:{
 err: 错误码,
 msg: 错误信息
}

transfer(opts, cb)

转账
Name Type Default Description
opts Object {} optional 参数
cb callback function(err,result){} optional 回调
Examples
fromUserId,fromAccountId,toUserId,toAccountId必填之一
opts参数:{
  token: (可选, 如果不填,自动从storage中取值)
  fromUserId: 转出用户(可选,sso.user.id,如果不填,取当前用户)
  fromAccountId: 转出账户(可选,如果不填,取默认帐户),
  toUserId: 转入用户(可选,sso.user.id,如果不填,取当前用户)
  toAccountId: 转入账户(可选,如果不填,取默认帐户),
  ctCode: 币种编码(必填)
  amount: 数量(必填,allAmount为1时可不填)
  allAmount: 转出全部(可选,为1时amount被忽略)
  payId: 支付单号(可选)
  attach: 附加信息(可选)
  orderId: 商户自编订单号(可选)
  memo: 备注信息(可选)
}
result参数:{
 ctCode: 币种,
 amount: 数量
 }
err参数:{
 err: 错误码,
 msg: 错误信息
}

updatePasswd(opts, cb)

更新账号密码
Name Type Default Description
opts Object {} optional 参数
cb callback function(err,result){} optional 回调
Examples
opts参数:{
  token: (可选, 如果不填,自动从storage中取值)
  passwd: 旧密码(必填)
  newPasswd: 新密码(必填),
}
result参数:{
 }
err参数:{
 err: 错误码,
 msg: 错误信息
}