def post(self): """ 获取当前可用的充值方式 """ form, error = AmountInputForm().request_validate() if error: return error.as_response() routers = ChannelListHelper.get_channel_payment_type_router( interface=InterfaceTypeEnum.CASHIER_H5, amount=form.amount.data, merchant=form.merchant.data, uid=g.user.uid, ) channels = ChannelListHelper.get_available_channels( form.merchant.data, PayTypeEnum.DEPOSIT, client_ip=form.client_ip.data, ) payment_type_list = ChannelListHelper.choice_one_channel_for_payment_type( channels, routers, form.merchant.data, form.amount.data, ) return ResponsePaymentType(bs_data=dict( payment_type_list=payment_type_list)).as_response()
def get(self): """ 查询可用的通道 :return: """ if not request.args: return ResponseSuccess( message="参数规则:?merchant=test&interface=&amount=&uid=" ).as_response() try: merchant = MerchantEnum.from_name(request.args['merchant']) except: return ResponseSuccess( message="请输入正确的 merchant,有效的 merchant 包括:%s" % MerchantEnum.get_names()).as_response() try: interface = request.args.get('interface') if interface: interface = InterfaceTypeEnum.from_name(interface) except: return ResponseSuccess( message="请输入正确的 interface,有效的 interface 包括:%s" % InterfaceTypeEnum.get_names()).as_response() try: amount = request.args.get('amount') or 0 if amount: amount = Decimal(amount) except: return ResponseSuccess(message="请输入正确的 amount") try: uid = request.args.get('uid') if uid: uid = int(uid) except: return ResponseSuccess(message="请输入正确的 uid") routers = ChannelListHelper.get_channel_payment_type_router( interface=interface, amount=amount, merchant=merchant, uid=uid, ) channels = ChannelListHelper.get_available_channels( merchant, PayTypeEnum.DEPOSIT) payment_type_list = ChannelListHelper.choice_one_channel_for_payment_type( channels, routers, merchant, amount) for item in payment_type_list: item['limit_min'] = str(item['limit_min']) item['limit_max'] = str(item['limit_max']) return ResponseSuccess(bs_data=payment_type_list).as_response()