package cn.superdesk.uniorder.service.unified.impl;

import cn.superdesk.uniorder.common.rest.response.R;
import cn.superdesk.uniorder.dao.entity.unified.UnifiedEncourage;
import cn.superdesk.uniorder.dao.entity.unified.UnifiedServiceGroup;
import cn.superdesk.uniorder.dao.mapper.unified.UnifiedEncourageMapper;
import cn.superdesk.uniorder.dto.vo.unified.UnifiedEncouragePage;
import cn.superdesk.uniorder.dto.vo.wechat.WxChannelItemList;
import cn.superdesk.uniorder.service.unified.UnifiedEncourageService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

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

@Service
public class UnifiedEncourageServiceImpl implements UnifiedEncourageService {

    @Autowired
    private UnifiedEncourageMapper unifiedEncourageMapper;


    @Override
    public int insertSelective(UnifiedEncourage unifiedEncourage) {
        return unifiedEncourageMapper.insertSelective(unifiedEncourage);
    }

    @Override
    public int updateByPrimaryKeySelective(UnifiedEncourage unifiedEncourage) {
        return unifiedEncourageMapper.updateByPrimaryKeySelective(unifiedEncourage);
    }

    @Override
    public void deleteObj(Long id) {
        unifiedEncourageMapper.deleteByPrimaryKey(id);
    }

    @Override
    public UnifiedEncourage findById(Long id) {
        return unifiedEncourageMapper.selectByPrimaryKey(id);
    }


    @Override
    public List<UnifiedEncourage> findAll(Map<String, Object> queryMap) {
        return unifiedEncourageMapper.findAll(queryMap);
    }

    @Override
    public PageInfo<UnifiedEncourage> findByPaging(Map<String, Object> params, Integer pageNo, Integer pageSize) {
        return null;
    }

    @Override
    public R<List<UnifiedEncouragePage>> getPage(Map<String, Object> params, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);

        List<UnifiedEncouragePage> ls = unifiedEncourageMapper.getPageData(params);

        PageInfo<UnifiedEncouragePage> page = new PageInfo<UnifiedEncouragePage>(ls);
        PageHelper.clearPage();
        return new R<List<UnifiedEncouragePage>>(page.getPageNum(), page.getPageSize(), (int) page.getTotal(), ls);
    }

    @Override
    public UnifiedServiceGroup findServiceGroupByCode(String businessCode) {
        return unifiedEncourageMapper.findServiceGroupByCode(businessCode);
    }

    @Override
    public BigDecimal getAmountProfit(Map<String, Object> amountProfitQuery) {
        return unifiedEncourageMapper.getAmountProfit(amountProfitQuery);
    }

    @Override
    public BigDecimal getAmountEncourage(Map<String, Object> amountProfitQuery) {
        return unifiedEncourageMapper.getAmountEncourage(amountProfitQuery);
    }

    @Override
    public BigDecimal getOrderAmount(Map<String, Object> amountQuery) {
        return unifiedEncourageMapper.getOrderAmount(amountQuery);
    }

    @Override
    public Integer getVirtCountByChannelId(Map<String, Object> virtCountQuery) {
        return unifiedEncourageMapper.getVirtCountByChannelId(virtCountQuery);
    }

    @Override
    public BigDecimal getAmountBack(Map<String, Object> amountProfitQuery) {
        return unifiedEncourageMapper.getAmountBack(amountProfitQuery);
    }

    @Override
    public BigDecimal getAmountGetCash(Map<String, Object> amountGetCashQuery) {
        return unifiedEncourageMapper.getAmountGetCash(amountGetCashQuery);
    }

    @Override
    public List<WxChannelItemList> getChannelItemList(Map<String, Object> channelListQuery) {
        return unifiedEncourageMapper.getChannelItemList(channelListQuery);
    }

    @Override
    public List<UnifiedEncouragePage> getEncourageList(Map<String, Object> amountGetCashQuery) {
        List<UnifiedEncouragePage> ls = unifiedEncourageMapper.getPageData(amountGetCashQuery);
        return ls;
    }
}
