lib/reapal/api/user/bind_card_query.rb in reapal-0.3.0 vs lib/reapal/api/user/bind_card_query.rb in reapal-0.9.0

- old
+ new

@@ -23,16 +23,16 @@ # * :bank_code 银行代码 # * :bank_card 银行卡后四位 # * :type 业务类型 A: 充值和提现; D: 充值; W: 提现 # * :is_safety 绑卡类别 0: 普通卡; 1:安全卡 # * :is_required_field 分支行信息 0: 省市分支行信息(系统默认信息); 1:用户自己所填信息 - # * :account_province 开户行所在省 + # * :account_province 开户行所在省 # * :account_city 开户行所在市 # * :branch 开户行分行 # * :subbranch 开户行支行 # - def bind_card_query(contracts, type = "W") + def bind_card_query(contracts, type='W') service = 'reapal.trust.bindQuery' post_path = '/reagw/user/restApi.htm' params = { contracts: contracts, @@ -40,15 +40,24 @@ queryTime: Time.now.strftime('%Y-%m-%d %H:%M:%S') } res = operate_post(:query, service, params, post_path, Http::ErrorCode.bind_card, ['0000']) - if 'S' == res[:result] - # TODO: (tony) 返回的银行字符串解析成数据,便于使用方 - # res[:data][:bank_cards] = parse_cards_info(res[:data][:bank_cards]) + if 'S' == res[:result] || ('P' == res[:result] && res[:data][:resultCode].nil?) + res[:result] = 'S' + + res[:data][:bank_cards] = parse_cards_info(res[:data][:bankCards]) end res + end + + private + + def parse_cards_info(bank_cards) + cards_info = bank_cards.first.split("|") + + cards_info end end # module end end