package com.hfkj.service.goods.impl;

import com.hfkj.dao.BsOrderMeituanMapper;
import com.hfkj.entity.BsOrderMeituan;
import com.hfkj.entity.BsOrderMeituanExample;
import com.hfkj.service.goods.BsOrderMeiTuanService;
import org.springframework.stereotype.Service;

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

@Service("bsOrderMeiTuanService")
public class BsOrderMeiTuanServiceImpl implements BsOrderMeiTuanService {

    @Resource
    private BsOrderMeituanMapper bsOrderMeituanMapper;

    @Override
    public void create(BsOrderMeituan orderMeiTuan) {
        bsOrderMeituanMapper.insert(orderMeiTuan);
    }

    @Override
    public void update(BsOrderMeituan orderMeiTuan) {
        bsOrderMeituanMapper.updateByPrimaryKeySelective(orderMeiTuan);
    }

    @Override
    public void delete(Long id, Boolean fullDelete) {

    }

    @Override
    public BsOrderMeituan queryDetail(Long id) {
        return null;
    }

    @Override
    public BsOrderMeituan findOrderMeiTuan(String childOrderNo) {
        BsOrderMeituanExample example = new BsOrderMeituanExample();
        BsOrderMeituanExample.Criteria criteria = example.createCriteria();
        criteria.andChildOrderNoEqualTo(childOrderNo);

        List<BsOrderMeituan> list = bsOrderMeituanMapper.selectByExample(example);

        if (!list.isEmpty()) {
            return list.get(0);
        }

        return null;
    }

    @Override
    public BsOrderMeituan findOrderMeiTuanByTradeNo(String tradeNo) {
        BsOrderMeituanExample example = new BsOrderMeituanExample();
        BsOrderMeituanExample.Criteria criteria = example.createCriteria();
        criteria.andTradeNoEqualTo(tradeNo);

        List<BsOrderMeituan> list = bsOrderMeituanMapper.selectByExample(example);

        if (!list.isEmpty()) {
            return list.get(0);
        }

        return null;
    }
}
