package com.jsowell.pile.service.impl;

import com.jsowell.common.util.StringUtils;
import com.jsowell.pile.domain.ClearingBillInfo;
import com.jsowell.pile.dto.GetClearingBillDTO;
import com.jsowell.pile.mapper.ClearingBillInfoMapper;
import com.jsowell.pile.service.ClearingBillInfoService;
import com.jsowell.pile.vo.web.MerchantClearingBillVO;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ClearingBillInfoServiceImpl implements ClearingBillInfoService{

    @Resource
    private ClearingBillInfoMapper clearingBillInfoMapper;

    @Override
    public int deleteByPrimaryKey(Integer id) {
        return clearingBillInfoMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(ClearingBillInfo record) {
        return clearingBillInfoMapper.insert(record);
    }

    @Override
    public int insertSelective(ClearingBillInfo record) {
        return clearingBillInfoMapper.insertSelective(record);
    }

    @Override
    public ClearingBillInfo selectByPrimaryKey(Integer id) {
        return clearingBillInfoMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(ClearingBillInfo record) {
        return clearingBillInfoMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(ClearingBillInfo record) {
        return clearingBillInfoMapper.updateByPrimaryKey(record);
    }

    @Override
    public List<ClearingBillInfo> selectByMerchantId(String merchantId, String billStatus) {
        return clearingBillInfoMapper.selectByMerchantId(merchantId, billStatus);
    }

    @Override
    public void updateStatus(List<Integer> clearingBillIds, String billStatus) {
        if (CollectionUtils.isEmpty(clearingBillIds) || StringUtils.isBlank(billStatus)) {
            return;
        }
        clearingBillInfoMapper.updateStatus(clearingBillIds, billStatus);
    }

    /**
     * 后管用 查询运营商账单列表
     * @param dto
     * @return
     */
    @Override
    public List<MerchantClearingBillVO> getMerchantClearingBillList(GetClearingBillDTO dto) {
        return clearingBillInfoMapper.getMerchantClearingBillList(dto);
    }

}
