package com.hai.goods.service.impl;

import com.hai.dao.GoodsOrderMapper;
import com.hai.entity.GoodsOrder;
import com.hai.entity.GoodsOrderExample;
import com.hai.goods.service.GoodsOrderExtService;
import org.springframework.stereotype.Service;

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

@Service("goodsOrderExtService")
public class GoodsOrderServiceImpl implements GoodsOrderExtService {

    @Resource
    private GoodsOrderMapper goodsOrderMapper;

    @Override
    public void insertGoodsOrder(GoodsOrder goodsOrder) {
        goodsOrderMapper.insert(goodsOrder);
    }

    @Override
    public void updateGoodsOrder(GoodsOrder goodsOrder) {
        goodsOrderMapper.updateByPrimaryKey(goodsOrder);
    }

    @Override
    public List<GoodsOrder> getGoodsOrderList(Map<String, Object> map) {
        return null;
    }

    @Override
    public GoodsOrder findGoodsOrderById(Long id) {
        return null;
    }

    @Override
    public GoodsOrder findGoodsOrder(String orderNo) {

        GoodsOrderExample example = new GoodsOrderExample();
        example.createCriteria().andStatusNotEqualTo("0").andOrderNoEqualTo(orderNo);

        List<GoodsOrder> list = goodsOrderMapper.selectByExample(example);

        if (list.size() > 0) {
            return list.get(0);
        }

        return null;
    }

    @Override
    public GoodsOrder findGoodsOrderByLogisticsNo(String logisticsNo) {
        GoodsOrderExample example = new GoodsOrderExample();
        example.createCriteria().andStatusNotEqualTo("0").andLogisticsNoEqualTo(logisticsNo);

        List<GoodsOrder> list = goodsOrderMapper.selectByExample(example);

        if (list.size() > 0) {
            return list.get(0);
        }

        return null;
    }

    @Override
    public void deleteGoodsOrder(Long id) {

    }
}
