package com.zanxiang.game.module.manage.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zanxiang.game.module.manage.pojo.params.PayCallCpLogParam;
import com.zanxiang.game.module.manage.pojo.vo.LogPayCpVO;
import com.zanxiang.game.module.manage.service.ILogPayCpService;
import com.zanxiang.game.module.mybatis.entity.PayCallCpLog;
import com.zanxiang.game.module.mybatis.mapper.PayCallCpMapper;
import com.zanxiang.module.util.bean.BeanUtil;
import org.springframework.stereotype.Service;

import java.util.Objects;

/**
 * @author : lingfeng
 * @time : 2022-06-23
 * @description : 通知CP记录表
 */
@Service
public class LogPayCpServiceImpl extends ServiceImpl<PayCallCpMapper, PayCallCpLog> implements ILogPayCpService {

    @Override
    public IPage<LogPayCpVO> callCpList(PayCallCpLogParam param) {
        return page(param.toPage(), new LambdaQueryWrapper<PayCallCpLog>()
                .eq(PayCallCpLog::getOrderId, param.getOrderId())).convert(this::toVo);
    }

    private LogPayCpVO toVo(PayCallCpLog payCallCpLog) {
        if (Objects.isNull(payCallCpLog)) {
            return null;
        }
        return BeanUtil.copy(payCallCpLog, LogPayCpVO.class);
    }

}
