def post(self): """ 通道管理: 获取通道配置信息 :return: """ form, error = ChannelConfigQueryForm().request_validate() if error: return error.as_response() pay_type = form.pay_type.data config_channels_dict = ChannelListHelper.get_config_channels( pay_type, ret_dict=True) if pay_type == PayTypeEnum.DEPOSIT: configs = [ c for c in ChannelConfigEnum if c.value not in config_channels_dict and c.conf['payment_type'] ] else: configs = [ c for c in ChannelConfigEnum if c.value not in config_channels_dict and not c.conf['payment_type'] ] channel_config_list = [ dict( channel_id=i.value, channel_desc=i.desc, id=i.conf["id"], provider=i.conf["provider"], name=i.conf["name"], payment_type=i.conf["payment_type"].desc if i.conf['payment_type'] else '', payment_method=i.conf["payment_method"].desc if i.conf['payment_method'] else '', ) for i in configs ] data = dict( channel_config=channel_config_list, payment_fee_type=PaymentFeeTypeEnum.get_desc_value_pairs(), settlement_type=SettleTypeEnum.get_name_value_pairs(), channel_state=ChannelStateEnum.get_desc_value_pairs(), banks=PaymentBankEnum.get_desc_value_pairs(), # banks=[item.value for item in PaymentBankEnum], interfaces=InterfaceTypeEnum.get_name_value_pairs(), payment_method=PayMethodEnum.get_desc_value_pairs(), merchant_name=MerchantEnum.get_name_value_pairs(), payment_types=PaymentTypeEnum.get_desc_name_pairs(), ) return ChannelConfigResult(bs_data=data).as_response()
def post(self): """ 获取创建商户所需的配置信息 :return: """ result = dict( merchant_names=MerchantEnum.get_name_type_pairs(), payment_methods=PayMethodEnum.get_desc_value_pairs(), withdraw_type=DeliverTypeEnum.get_desc_value_pairs(), channels_withdraw=ChannelConfigEnum.get_withdraw_desc_name_pairs(), channels_deposit=ChannelConfigEnum.get_deposit_desc_name_pairs(), ) return MerchantConfigResult(bs_data=result).as_response()
class MerchantListResult(ResponseSuccess): data_model = MerchantList ############################################## # 新建商户信息 ############################################## DepositTypeList = api.model( "Deposit", { "name": fields.String( required=True, description=PayMethodEnum.description_value_desc(), example=PayMethodEnum.ZHIFUBAO_H5.value, ), "value": fields.String(required=True, description='费率', example='3.2'), "fee_type": fields.String( required=True, description=PaymentFeeTypeEnum.description_value_desc(), example=PaymentFeeTypeEnum.PERCENT_PER_ORDER.value, ) }) WithdrawType = api.model( "WithdrawType", { "value":
required=True, description='通道号', example=PayTypeEnum.description() ), }) bank = fields.String( required=True, description='支持的银行', example=PaymentBankEnum.description() ) payment_methods = fields.String( required=True, description='支付方法', example=PayMethodEnum.description() ) DescValuePair = api.model("DescValuePair", { "desc": fields.String( description="支付方式描述", example=PayMethodEnum.WEIXIN_H5.desc, ), "value": fields.String( description='支付方式数值', example=PayMethodEnum.WEIXIN_H5.value, ), }) maintain_datetime = api.model('maintain_datetime', { "maintain_begin": fields.String(
), "amount": fields.String( description='订单金额', example="560.03", ), "create_time": fields.String(description='订单发起时间', example="2019-07-29"), "status": fields.String(description='订单状态', example=OrderStateEnum.get_desc_list()), "order_type": fields.String(description='订单类型', example=PayTypeEnum.get_desc_list()), "pay_method": fields.String(description='支付方式', example=PayMethodEnum.get_desc_list()), # 转账字段 "out_account": fields.String( description='出款手机手号码', example="", ), "in_account": fields.String( description='收款手机号码', example="", ), "comment": fields.String( description='备注信息',
def post(self): """ 充值通道列表 :return: """ router2_dict = ChannelListHelper.get_router2_dict() channel_list = [] channels = ChannelConfig.query_all() channels = ChannelConfig.filter_latest_items(channels) for channel in channels: channel_enum = channel.channel_enum channel_conf = channel_enum.conf merchants = list() router = router2_dict.get(channel_enum) if router: merchants = router.merchants channel_list.append( dict( channel_id=channel_enum.value, channel_desc=channel_enum.desc, id=channel_conf['mch_id'], provider=channel_conf['provider'], payment_type=dict(desc=PaymentTypeEnum( channel_conf['payment_type']).desc, value=PaymentTypeEnum( channel_conf['payment_type']).value), payment_method=dict( desc=PayMethodEnum( channel_conf['payment_method']).desc, value=PayMethodEnum( channel_conf['payment_method']).value), 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, settlement_type=dict( key=SettleTypeEnum(channel.settlement_type).value, value=SettleTypeEnum(channel.settlement_type).name), trade_start_time=":".join([ str(channel.trade_begin_hour), str(channel.trade_begin_minute) ]), # trade_start_time=dict(trade_begin_hour=channel.trade_begin_hour, # trade_begin_minute=channel.trade_begin_minute), trade_end_time=":".join([ str(channel.trade_end_hour), str(channel.trade_end_minute) ]), # trade_end_time=dict(trade_end_hour=channel.trade_end_hour, # trade_end_minute=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_end else None), state=dict(desc=channel.state.desc, value=channel.state.value), reason=channel.get_reason_desc(), priority=channel.priority, merchants=[x.name for x in merchants], )) channel_list = sorted(channel_list, key=lambda item: item['state']['value']) data = dict(counts=len(channel_list), channels=channel_list) return ChannelListResult(bs_data=data).as_response()
def payment_method(self) -> PayMethodEnum: if self._p_method: return PayMethodEnum(self._p_method)