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

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hzs.common.core.constant.ScmFieldConstants;
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.general.IcGeneralOutB;
import com.hzs.common.domain.scm.general.ext.IcGeneralOutBExt;
import com.hzs.common.domain.scm.inventory.IcInventoryB;
import com.hzs.common.domain.scm.inventory.ext.IcInventoryBExt;
import com.hzs.scm.inventory.mapper.IcInventoryBMapper;
import com.hzs.scm.inventory.service.IIcInventoryBService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 库存盘点单明细 服务实现类
 * </p>
 *
 * @author hzs
 * @since 2023-12-20
 */
@Service
public class IcInventoryBServiceImpl extends ServiceImpl<IcInventoryBMapper, IcInventoryB> implements IIcInventoryBService {

    @Override
    public List<IcInventoryBExt> queryInventoryBiByPk(Integer orderType, List<IcInventoryBExt> icInventoryBiExtList) {
        return baseMapper.queryInventoryBiByPk(orderType, icInventoryBiExtList);
    }

    @Override
    public List<IcInventoryBExt> queryInventoryBiByPk(Integer pkCountry, Long pkOrder) {
        return baseMapper.queryInventoryBiByPkId(pkCountry, pkOrder);
    }

    @Override
    public void deleteInventoryBiByList(List<IcInventoryB> icInventorybList, Long pkMember) {
        baseMapper.deleteInventoryBiByList(icInventorybList, pkMember);
    }

    @Override
    public void deleteInventoryBiByPkInventory(Long pkInventory, Long pkMember) {
        UpdateWrapper<IcInventoryB> 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(ScmFieldConstants.PK_INVENTORY, pkInventory);
        update(updateWrapper);
    }
}
