package com.hzs.scm.trans.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.trans.IcTransInB;
import com.hzs.common.domain.scm.trans.ext.IcTransInBExt;
import com.hzs.scm.trans.mapper.IcTransInBMapper;
import com.hzs.scm.trans.service.IIcTransInBService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 采购订单明细 服务实现类
 * </p>
 *
 * @author hzs
 * @since 2023-12-04
 */
@Service
public class IcTransInBServiceImpl extends ServiceImpl<IcTransInBMapper, IcTransInB> implements IIcTransInBService {

    @Override
    public List<IcTransInBExt> queryTransferInbByPk(Integer orderType, List<IcTransInBExt> transInbList) {
        return baseMapper.queryTransferInbByPk(orderType, transInbList);
    }

    @Override
    public void deleteTransferInbByList(List<IcTransInB> transInbList) {
        baseMapper.deletePurchaseInbByList(transInbList);
    }

    @Override
    public void deleteTransferInbByPkPurchase(Long pkTransfer, Long pkMember) {
        UpdateWrapper<IcTransInB> 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_TRANSFER_IN, pkTransfer);
        update(updateWrapper);
    }
}
