def get(self): """ 商户配置查询 :return: """ if not request.args: return ResponseSuccess(message="参数规则:?merchant=test").as_response() try: merchant = MerchantEnum.from_name(request.args['merchant']) except: return ResponseSuccess(message="请输入正确的商户名称,有效的商户名称包括:%s" % MerchantEnum.get_names()).as_response() merchant_info = MerchantInfo.query_merchant(merchant) if not merchant_info: return ResponseSuccess(message="未创建商户").as_response() bs_data = dict( balance=dict( balance_total=str(merchant_info.balance_total), balance_available=str(merchant_info.balance_available), balance_income=str(merchant_info.balance_income), balance_frozen=str(merchant_info.balance_frozen), ), merchant=merchant.name, domains=MerchantDomainConfig.get_domains(merchant), # db=DBEnum(merchant.name).get_db_name(), ) deposit_fees = MerchantFeeConfig.query_active_configs( query_fields=dict( merchant=merchant, payment_way=PayTypeEnum.DEPOSIT, )) deposit_fees = MerchantFeeConfig.filter_latest_items(deposit_fees) if not deposit_fees: return MerchantConfigDepositError(bs_data=bs_data).as_response() bs_data['deposit_fees'] = [x.short_description for x in deposit_fees] withdraw_fees = MerchantFeeConfig.query_latest_one(query_fields=dict( merchant=merchant, payment_way=PayTypeEnum.WITHDRAW, )) if not withdraw_fees: return MerchantConfigWithdrawError(bs_data=bs_data).as_response() bs_data['withdraw_fees'] = withdraw_fees.short_description channels = ChannelListHelper.get_available_channels( merchant, PayTypeEnum.DEPOSIT) bs_data['deposit_channels'] = [x.short_description for x in channels] channels = ChannelListHelper.get_available_channels( merchant, PayTypeEnum.WITHDRAW) bs_data['withdraw_channels'] = [x.short_description for x in channels] return ResponseSuccess(bs_data=bs_data).as_response()
def post(self): """ 获取当前可用的充值方式 """ form, error = DomainForm().request_validate() if error: return error.as_response() channel_list = ChannelListHelper.get_available_channels( form.merchant.data, PayTypeEnum.WITHDRAW) withdraw_banks = [] for channel in channel_list: banks = [ dict(desc=bank.desc, value=bank.value) for bank in channel.banks ] withdraw_banks += banks value_list = [] banks_lst = [] for item in withdraw_banks: if item['value'] not in value_list: value_list.append(item['value']) banks_lst.append(item) banks_result = dict(banks=banks_lst) return ResponseBankWithdraw(bs_data=banks_result).as_response()
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()