package com.hzs.scm.io.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hzs.common.core.constant.SaOrderFieldConstants;
import com.hzs.common.core.constant.SystemFieldConstants;
import com.hzs.common.core.enums.EYesNo;
import com.hzs.common.core.utils.DateUtils;
import com.hzs.common.domain.scm.io.IoOrderItems;
import com.hzs.common.domain.scm.io.ext.IoOrderItemsExt;
import com.hzs.scm.io.mapper.IoOrderItemsMapper;
import com.hzs.scm.io.service.IIoOrderItemsService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 业务领用订单明细 服务实现类
 * </p>
 *
 * @author hzs
 * @since 2024-04-22
 */
@Service
public class IoOrderItemsServiceImpl extends ServiceImpl<IoOrderItemsMapper, IoOrderItems> implements IIoOrderItemsService {

    @Override
    public void deleteOrderItemsService(List<IoOrderItems> ioOrderItemsList, Long pkMember) {
        baseMapper.deleteOrderItemsService(ioOrderItemsList, pkMember);
    }

    @Override
    public void deleteOrderItemsByPkOrder(Long pkOrder, Long pkMember) {
        UpdateWrapper<IoOrderItems> updateWrapper = new UpdateWrapper<>();
        updateWrapper.set(SystemFieldConstants.DEL_FLAG, EYesNo.NO.getIntValue());
        updateWrapper.set(SystemFieldConstants.PK_MODIFIED, pkMember);
        updateWrapper.set(SystemFieldConstants.MODIFIED_TIME, DateUtils.currentDateTime());
        updateWrapper.eq(SaOrderFieldConstants.PK_ORDER, pkOrder);
        update(updateWrapper);
    }

    @Override
    public List<IoOrderItemsExt> queryListIoOrderItemsByPk(Integer pkCountry, Long pkOrder) {
        return baseMapper.queryListIoOrderItemsByPk(pkCountry, pkOrder);
    }

    @Override
    public List<IoOrderItems> queryIoOrderItemsByList(List<Long> idList) {
        QueryWrapper<IoOrderItems> queryWrapper = new QueryWrapper<>();
        queryWrapper.in(SystemFieldConstants.PK_ID, idList);
        return baseMapper.selectList(queryWrapper);
    }
}
