package com.hai.service.impl;

import com.hai.dao.OutRechargeOrderRecordMapper;
import com.hai.entity.OutRechargeOrderRecord;
import com.hai.entity.OutRechargeOrderRecordExample;
import com.hai.service.OutRechargeOrderRecordService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service("outRechargeOrderRecordService")
public class OutRechargeOrderRecordServiceImpl implements OutRechargeOrderRecordService {

    @Resource
    private OutRechargeOrderRecordMapper rechargeOrderRecordMapper;

    @Override
    public List<OutRechargeOrderRecord> getListRechargeOrderRecord() {
        return null;
    }

    @Override
    public OutRechargeOrderRecord findById(Long id) {
        return null;
    }

    @Override
    public OutRechargeOrderRecord findByOrderNo(String orderNo) {
        OutRechargeOrderRecordExample example = new OutRechargeOrderRecordExample();
        example.createCriteria().andRechargeOrderNoEqualTo(orderNo);
        if (rechargeOrderRecordMapper.selectByExample(example).size() == 0) {
            return null;
        } else {
            return rechargeOrderRecordMapper.selectByExample(example).get(0);
        }
    }

    @Override
    public OutRechargeOrderRecord findByOrderId(Long orderId) {
        OutRechargeOrderRecordExample example = new OutRechargeOrderRecordExample();
        example.createCriteria().andRechargeOrderIdEqualTo(orderId);
        if (rechargeOrderRecordMapper.selectByExample(example).size() == 0) {
            return null;
        } else {
            return rechargeOrderRecordMapper.selectByExample(example).get(0);
        }
    }


    @Override
    public void insertOrder(OutRechargeOrderRecord rechargeOrderRecord) {
        rechargeOrderRecordMapper.insert(rechargeOrderRecord);
    }

    @Override
    public void updateOrder(OutRechargeOrderRecord rechargeOrderRecord) {
        rechargeOrderRecordMapper.updateByPrimaryKey(rechargeOrderRecord);
    }
}
