package com.neusoft.smart.pos.order.repository;

import com.neusoft.smart.pos.order.persistent.domain.OrderDelivery;
import com.neusoft.smart.pos.order.persistent.domain.OrderDeliveryExample;
import com.neusoft.smart.pos.order.persistent.mapper.OrderDeliveryMapper;
import lombok.val;
import org.springframework.stereotype.Component;

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

/**
 * @author tmg
 * @date 2019-12-24 10：43
 * @description 订单地址管理使用Repository
 */
@Component
public class OrderDeliveryRepository {
    @Resource
    private OrderDeliveryMapper orderDeliveryMapper;

    /**
     * 订单信息保存方法
     * @return
     */
    public Integer saveOrderDelivery(OrderDelivery orderDelivery){
        return orderDeliveryMapper.insertSelective(orderDelivery);
    }

    /**
     * 订单信息保存方法
     * @return
     */
    public Integer saveRecordOrderDetails(OrderDelivery orderDelivery){
        return orderDeliveryMapper.insertSelective(orderDelivery);
    }

    /**
     * 订单信息保存方法
     * @return
     */
    public void saveRecordOrderDeliveryAddsBatch(List<OrderDelivery> orderDeliveryList){
        orderDeliveryMapper.batchInsert(orderDeliveryList);
    }

    /**
     * 订单明细信息查询方法
     * @return
     */
    public List<OrderDelivery> queryOrderDeliverys(String orderNumber){
        val example = new OrderDeliveryExample();
        example.createCriteria().andOrderNumberEqualTo(orderNumber);
        return orderDeliveryMapper.selectByExample(example);
    }

    /**
     * 订单删除使用方法
     * @return
     */
    public Integer deleteOrderDeliveryByOrderNumber(String orderNumber){
        OrderDeliveryExample example = new OrderDeliveryExample();
        example.createCriteria().andOrderNumberEqualTo(orderNumber);
        return orderDeliveryMapper.deleteByExample(example);
    }

    /**
     * 订单删除使用方法
     * @return
     */
    public Integer deleteOrderTransactionByOrderNumber(List<String> orderNumberList){
        OrderDeliveryExample example = new OrderDeliveryExample();
        example.createCriteria().andOrderNumberIn(orderNumberList);
        return orderDeliveryMapper.deleteByExample(example);
    }
}
