package com.fjhx.service.order.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fjhx.entity.order.OrderDetails;
import com.fjhx.mapper.order.OrderDetailsMapper;
import com.fjhx.params.order.IssueVo;
import com.fjhx.params.order.OrderDetailsEx;
import com.fjhx.params.order.OrderDetailsVo;
import com.fjhx.service.order.OrderDetailsService;
import com.fjhx.utils.Assert;
import com.fjhx.utils.wrapperUtil.IWrapper;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 销售订单明细表 服务实现类
 * </p>
 *
 * @author ${author}
 * @since 2022-12-13
 */
@Service
public class OrderDetailsServiceImpl extends ServiceImpl<OrderDetailsMapper, OrderDetails> implements OrderDetailsService {

    @Override
    public Page<OrderDetails> getPage(Map<String, Object> condition) {

        IWrapper<OrderDetails> wrapper = IWrapper.getWrapper(condition);

        return page(condition, wrapper);
    }

    @Override
    public void add(OrderDetailsVo orderDetailsVo) {
        save(orderDetailsVo);
    }

    @Override
    public void edit(OrderDetailsVo orderDetailsVo) {
        updateById(orderDetailsVo);
    }

    @Override
    public void delete(OrderDetailsVo orderDetailsVo) {
        removeById(orderDetailsVo.getId());
    }

    @Override
    public List<OrderDetailsEx> listByOrderSalesId(Map<String, Object> condition) {
        Assert.notEmpty(condition.get("orderId"), "订单id不能为空");

        IWrapper<Object> wrapper = IWrapper.getWrapper(condition)
                .eq("od", OrderDetails::getOrderId);

        return baseMapper.listByOrderSalesId(wrapper);
    }

    @Override
    public void issue(IssueVo issueVo) {

    }

}
