Sha256: b27ad40d97ffea0946ba30ff7e41b156659b8f3e3069fffb90b5d7fa1f89626c

Contents?: true

Size: 1.48 KB

Versions: 7

Compression:

Stored size: 1.48 KB

Contents

# coding: utf-8

module Reapal
  module Api
    module User
      module BalanceQuery

        # 1.2 查询余额(API)
        #
        # @param contracts [ String ] 用户协议号
        #
        # @return [ Hash ] 结果集
        #   * :result [String] 业务结果:'S/F/P'
        #   * :request_params [Hash] 请求参数
        #   * :response [Object] 请求返回对象
        #   * :error_code [String] 错误代号
        #   * :error_msg [String] 错误信息
        #   * :data: 具体业务返回信息
        #     * :totalAmount [BigDecimal] 账户总额
        #     * :usableAmount [BigDecimal] 可用金额
        #     * :tenderAmount [BigDecimal] 投标金额
        #
        def balance_query(contracts)
          service = 'reapal.trust.balanceQuery'
          post_path = '/agreement/agreeApi.htm'

          params = {
            contracts: contracts,
            queryTime: Time.now.strftime('%Y-%m-%d %H:%M:%S'),
          }

          res = operate_post(:query, service, params, post_path, ['0113'], ['0000'])

          if 'S' == res[:result] || ('P' == res[:result] && res[:data][:resultCode].nil?)
            res[:result] = 'S'

            res[:data] = {
              totalAmount: res[:data][:totalAmount].to_d,
              usableAmount: res[:data][:usableAmount].to_d,
              tenderAmount: res[:data][:tenderAmount].to_d,
            }
          end

          Reapal.logger.info res

          res
        end

      end # module Agree
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
reapal-0.18.0 lib/reapal/api/user/balance_query.rb
reapal-0.17.0 lib/reapal/api/user/balance_query.rb
reapal-0.16.0 lib/reapal/api/user/balance_query.rb
reapal-0.15.0 lib/reapal/api/user/balance_query.rb
reapal-0.14.0 lib/reapal/api/user/balance_query.rb
reapal-0.13.0 lib/reapal/api/user/balance_query.rb
reapal-0.12.0 lib/reapal/api/user/balance_query.rb