package com.yiqi.system.service.impl;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

import com.yiqi.common.enums.SourceType;
import com.yiqi.common.enums.SysConfigKey;
import com.yiqi.common.utils.SecurityUtils;
import com.yiqi.system.domain.ManageFactory;
import com.yiqi.system.domain.SysStore;
import com.yiqi.system.service.ISysConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.yiqi.system.mapper.SysSettlementRateMapper;
import com.yiqi.system.domain.SysSettlementRate;
import com.yiqi.system.service.ISysSettlementRateService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

/**
 * 结算费率Service业务层处理
 *
 * @author ruoyi
 * @date 2023-10-17
 */
@Service
public class SysSettlementRateServiceImpl extends ServiceImpl<SysSettlementRateMapper,SysSettlementRate> implements ISysSettlementRateService {

    @Autowired
    private ISysConfigService configService;

    /**
     * 查询结算费率
     *
     * @param id 结算费率主键
     * @return 结算费率
     */
    @Override
    public SysSettlementRate selectSysSettlementRateById(Long id) {
        return baseMapper.selectSysSettlementRateById(id);
    }

    /**
     * 查询结算费率列表
     *
     * @param sysSettlementRate 结算费率
     * @return 结算费率
     */
    @Override
    public List<SysSettlementRate> selectSysSettlementRateList(SysSettlementRate sysSettlementRate) {
        List<SysSettlementRate> list = new ArrayList<>();
        if (SourceType.FACTORY.getCode().equals(sysSettlementRate.getSourceType())){
            list = baseMapper.selectSysSettlementRateListByFactory(sysSettlementRate);
        }
        if (SourceType.STORE.getCode().equals(sysSettlementRate.getSourceType())){
            list = baseMapper.selectSysSettlementRateListByStore(sysSettlementRate);
        }
        return list;
    }

    /**
     * 新增结算费率
     *
     * @param sysSettlementRate 结算费率
     * @return 结果
     */
    @Override
    public int insertSysSettlementRate(SysSettlementRate sysSettlementRate) {
        sysSettlementRate.buildCreateData();
        return baseMapper.insertSysSettlementRate(sysSettlementRate);
    }

    /**
     * 修改结算费率
     *
     * @param sysSettlementRate 结算费率
     * @return 结果
     */
    @Override
    public int updateSysSettlementRate(SysSettlementRate sysSettlementRate) {
        sysSettlementRate.buildUpdateData();
        return baseMapper.updateSysSettlementRate(sysSettlementRate);
    }

    /**
     * 批量删除结算费率
     *
     * @param ids 需要删除的结算费率主键
     * @return 结果
     */
    @Override
    public int deleteSysSettlementRateByIds(Long[] ids) {
        return baseMapper.deleteSysSettlementRateByIds(ids);
    }

}
