Beispiel #1
0
    def get(self):
        """
        通道配置查询
        :return:
        """
        deposit_channels = ChannelListHelper.get_config_channels(
            PayTypeEnum.DEPOSIT)
        withdraw_channels = ChannelListHelper.get_config_channels(
            PayTypeEnum.WITHDRAW)

        bs_data = dict(
            deposit_channels=[x.short_description for x in deposit_channels],
            withdraw_channels=[x.short_description for x in withdraw_channels],
        )
        return ResponseSuccess(bs_data=bs_data).as_response()
Beispiel #2
0
    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()