package com.hzs.scm.purchase.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.purchase.IcPurchaseInB;
import com.hzs.common.domain.scm.purchase.ext.IcPurchaseInBExt;
import com.hzs.scm.purchase.mapper.IcPurchaseInBMapper;
import com.hzs.scm.purchase.service.IIcPurchaseInBService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 采购订单明细 服务实现类
 * </p>
 *
 * @author hzs
 * @since 2023-11-17
 */
@Service
public class IcPurchaseInBServiceImpl extends ServiceImpl<IcPurchaseInBMapper, IcPurchaseInB> implements IIcPurchaseInBService {

    @Override
    public List<IcPurchaseInBExt> queryPurchaseInbByPk(List<IcPurchaseInBExt> icPurchaseInbList) {
        return baseMapper.queryPurchaseInbByPk(icPurchaseInbList);
    }

    @Override
    public void updatePurchaseInbByPk(List<IcPurchaseInBExt> icPurchaseInbList) {
        baseMapper.updatePurchaseInbByPk(icPurchaseInbList);
    }

    @Override
    public void mergePurchaseInBiByPurchaseBack(List<IcPurchaseInBExt> icPurchaseInbList) {
        baseMapper.mergePurchaseInBiByPurchaseBack(icPurchaseInbList);
    }

    @Override
    public void deletePurchaseInbByList(List<IcPurchaseInB> purchaseInbList) {
        baseMapper.deletePurchaseInbByList(purchaseInbList);
    }

    @Override
    public void deletePurchaseInbByPkPurchase(Long pkPurchase, Long pkMember) {
        UpdateWrapper<IcPurchaseInB> 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_PURCHASE, pkPurchase);
        update(updateWrapper);
    }
}
