def __update_channel(self, data, latest, count): ProxyChannelConfig.update_channel(**data) channels = list(ProxyChannelConfig.query_all()) self.assertEqual(count, len(channels)) all_configs = list(ProxyChannelConfig.filter_latest_items(channels)) self.assertEqual(latest, len(all_configs))
def post(self): """ 代付通道管理: 代付通道列表 :return: """ channel_list = [] channels = ProxyChannelConfig.query_all() channels = ProxyChannelConfig.filter_latest_items(channels) for channel in channels: channel_enum = channel.channel_enum channel_conf = channel_enum.conf channel_list.append( dict(channel_id=channel_enum.value, channel_desc=channel_enum.desc, id=channel_conf['mch_id'], provider=channel_conf['provider'], fee=channel.fee, fee_type=dict( desc=PaymentFeeTypeEnum(channel.fee_type).desc, value=PaymentFeeTypeEnum(channel.fee_type).value), limit_per_min=channel.limit_per_min, limit_per_max=channel.limit_per_max, limit_day_max=channel.limit_day_max, trade_start_time=":".join([ str(channel.trade_begin_hour), str(channel.trade_begin_minute) ]), trade_end_time=":".join([ str(channel.trade_end_hour), str(channel.trade_end_minute) ]), main_time=dict(maintain_begin=channel.maintain_begin if channel.maintain_begin else None, maintain_end=channel.maintain_end if channel.maintain_begin else None), state=dict(desc=channel.state.desc, value=channel.state.value), reason=channel.get_reason_desc(), banks=[bank.value for bank in channel.banks])) channel_list = sorted(channel_list, key=lambda item: item['state']['value']) data = dict(counts=len(channel_list), withdraws=channel_list) return WithdrawListResult(bs_data=data).as_response()
def post(self): """ 获取当前可用的代付通道 """ """ 1. 是否支持银行 banks like bank 1. 提现金额 _limit_per_max, _limit_per_min 2. 时间 _maintain_begin, _maintain_end """ form, error = WithDrawSupperBankForm().request_validate() if error: return error.as_response() merchant = form.merchant_name.data channels = ProxyChannelConfig.query_all() proxy_channels = ProxyChannelConfig.filter_latest_items(channels) valid_channels = [] withdraw_channel = {} for channel in proxy_channels: if form.bank_type.data not in channel.banks: continue if not channel.is_channel_valid(merchant.is_test, form.amount.data): continue withdraw_channel_key = channel.channel_enum.conf[ 'provider'] + channel.channel_enum.conf['mch_id'] withdraw_channel[withdraw_channel_key] = channel.channel_id valid_channels.append(channel) valid_channels = [ dict(key=channel, value=withdraw_channel[channel]) for channel in withdraw_channel.keys() ] return WithdrawChannelResult(bs_data=dict( entries=valid_channels)).as_response()