package com.seer.teach.pay.app.channel.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.seer.teach.pay.app.pay.controller.resp.AppPayChannelResp;
import com.seer.teach.pay.app.channel.convert.AppPayChannelConvert;
import com.seer.teach.pay.app.channel.service.AppPayChannelService;
import com.seer.teach.pay.entity.PayChannelEntity;
import com.seer.teach.pay.service.IPayChannelService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

@Slf4j
@Service
@RequiredArgsConstructor
public class AppPayChannelServiceImpl implements AppPayChannelService {

    private final IPayChannelService payChannelService;

    /**
     * 获取支付渠道列表
     * @return
     */
    @Override
    public List<AppPayChannelResp> getPayChannelList() {
        //只查询启用的支付渠道列表
        List<PayChannelEntity> payChannelList = payChannelService.list(new LambdaQueryWrapper<PayChannelEntity>()
                        .eq(PayChannelEntity::getStatus, 1)
                        .orderByAsc(PayChannelEntity::getSort));
        if(payChannelList.isEmpty()){
            return null;
        }
        return AppPayChannelConvert.INSTANCE.convertList(payChannelList);
    }
}
