package com.fdkankan.platform.order.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.fdkankan.common.constant.TbStatus;
import com.fdkankan.platform.order.entity.TradeLog;
import com.fdkankan.platform.order.mapper.ITradeLogMapper;
import com.fdkankan.platform.order.service.ITradeLogService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 交易成功记录表 服务实现类
 * </p>
 *
 * @author 
 * @since 2021-12-24
 */
@Service
public class TradeLogServiceImpl extends ServiceImpl<ITradeLogMapper, TradeLog> implements ITradeLogService {

    @Override
    public TradeLog getByOrderSn(String orderSn) {
        LambdaQueryWrapper<TradeLog> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(TradeLog::getTbStatus, TbStatus.VALID.code());
        queryWrapper.eq(TradeLog::getOrderSn,orderSn);
        List<TradeLog> list = this.list(queryWrapper);
        if(list == null || list.size() <= 0){
            return null;
        }
        return list.get(0);
    }
}
