package cn.pluss.platform.mercSplitSetting.impl;

import cn.pluss.platform.entity.MerchantSplitSetting;
import cn.pluss.platform.mapper.MerchantSplitSettingMapper;
import cn.pluss.platform.mercSplitSetting.MerchantSplitSettingService;
import cn.pluss.platform.vo.MerchantSplitSettingVO;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 商户分账配置表 服务实现类
 * </p>
 *
 * @author bzg
 * @since 2021-11-26
 */
@Service
public class MerchantSplitSettingServiceImpl extends ServiceImpl<MerchantSplitSettingMapper, MerchantSplitSetting> implements MerchantSplitSettingService {

    @Override
    public Page<MerchantSplitSettingVO> pageData(Page<MerchantSplitSettingVO> page, MerchantSplitSettingVO vo) {
        return baseMapper.pageInfo(page,vo);
    }

    @Override
    public List<MerchantSplitSetting> listChieMerchantCode(String merchantCode) {
        QueryWrapper<MerchantSplitSetting> queryWrapper = new QueryWrapper<MerchantSplitSetting>()
                .eq("chieMerchantCode",merchantCode);
        return baseMapper.selectList(queryWrapper);
    }

    @Override
    public void removeList(List<MerchantSplitSetting> oldList) {
        if(oldList.isEmpty()){
            return;
        }
        oldList.forEach(e->{
            baseMapper.deleteById(e.getId());
        });
    }
}
