package com.dcsoft.system.consume.service.impl;

import com.dcsoft.common.core.utils.DateUtils;
import com.dcsoft.common.core.web.domain.AjaxResult;
import com.dcsoft.common.datascope.annotation.DataScope;
import com.dcsoft.system.consume.domain.*;
import com.dcsoft.system.consume.mapper.ConsumeRecordMapper;
import com.dcsoft.system.consume.service.IConsumeRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 消费记录Service业务层处理
 *
 * @author nichun
 * @date 2023-09-08
 */
@Service
public class ConsumeRecordServiceImpl implements IConsumeRecordService
{
    @Autowired
    private ConsumeRecordMapper consumeRecordMapper;

    /**
     * 查询消费记录
     *
     * @param id 消费记录主键
     * @return 消费记录
     */
    @Override
    public ConsumeRecord selectConsumeRecordById(Long id)
    {
        return consumeRecordMapper.selectConsumeRecordById(id);
    }

    /**
     * 查询消费记录列表
     *
     * @param consumeRecord 消费记录
     * @return 消费记录
     */
    @Override
    @DataScope(deptAlias = "d", userAlias = "u")
    public List<ConsumeRecord> selectConsumeRecordList(ConsumeRecord consumeRecord)
    {
        return consumeRecordMapper.selectConsumeRecordList(consumeRecord);
    }

    /**
     * 新增消费记录
     *
     * @param consumeRecord 消费记录
     * @return 结果
     */
    @Override
    public int insertConsumeRecord(ConsumeRecord consumeRecord)
    {
        consumeRecord.setCreateTime(DateUtils.getNowDate());
        return consumeRecordMapper.insertConsumeRecord(consumeRecord);
    }

    /**
     * 修改消费记录
     *
     * @param consumeRecord 消费记录
     * @return 结果
     */
    @Override
    public int updateConsumeRecord(ConsumeRecord consumeRecord)
    {
        consumeRecord.setUpdateTime(DateUtils.getNowDate());
        return consumeRecordMapper.updateConsumeRecord(consumeRecord);
    }

    /**
     * 批量删除消费记录
     *
     * @param ids 需要删除的消费记录主键
     * @return 结果
     */
    @Override
    public int deleteConsumeRecordByIds(Long[] ids)
    {
        return consumeRecordMapper.deleteConsumeRecordByIds(ids);
    }

    /**
     * 删除消费记录信息
     *
     * @param id 消费记录主键
     * @return 结果
     */
    @Override
    public int deleteConsumeRecordById(Long id)
    {
        return consumeRecordMapper.deleteConsumeRecordById(id);
    }

    @Override
    public List<BusinessSummary> selectBusinessSummaryList(BusinessSummary businessSummary) {
        return consumeRecordMapper.selectBusinessSummaryList(businessSummary);
    }

    @Override
    public List<ConsumeTime> selectConsumeTimeList(ConsumeTime consumeTime) {
        return consumeRecordMapper.selectConsumeTimeList(consumeTime);
    }


    @Override
    @DataScope(deptAlias = "d")
    public List<ConsumeSelf> selectConsumeSelfList(ConsumeSelf consumeSelf) {
        return consumeRecordMapper.selectConsumeSelfList(consumeSelf);
    }

    @Override
    @DataScope(deptAlias = "d")
    public List<ConsumeBranch> selectConsumeBranchList(ConsumeBranch consumeBranch) {
        return consumeRecordMapper.selectConsumeBranchList(consumeBranch);
    }

    @Override
    public AjaxResult consumeChart() {
        List<Map<String,Object>> list=consumeRecordMapper.consumeChart();
        return AjaxResult.success(list);
    }

    @Override
    public AjaxResult consumeBarChart() {
        List<Map<String,Object>> list=consumeRecordMapper.consumeBarChart();
        return AjaxResult.success(list);
    }

    @Override
    public AjaxResult dklineChart() {
        List<Map<String,Object>> list=consumeRecordMapper.dklineChart();
        return AjaxResult.success(list);
    }

    @Override
    public AjaxResult pieChart() {
        List<Map<String,Object>> list=consumeRecordMapper.pieChart();
        return AjaxResult.success(list);
    }

    @Override
    public ConsumeBranch selectConsumeBranchByOther(ConsumeBranch consumeBranch) {
        return  consumeRecordMapper.selectConsumeBranchByOther(consumeBranch);
    }

    @Override
    public List<ConsumeRecord> selectAmendConsumeList()
    {
        return consumeRecordMapper.selectAmendConsumeList();
    }

    @Override
    public int syncConsume() {
        return consumeRecordMapper.syncConsume();
    }


}
