Пример #1
0
    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()
Пример #2
0
 def payment_method(self) -> PayMethodEnum:
     if self._p_method:
         return PayMethodEnum(self._p_method)