package com.ruoyi.system.user.service.impl;

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

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ruoyi.common.constant.RoleConstants;
import com.ruoyi.common.enums.UserType;
import com.ruoyi.common.utils.MathUtils;
import com.ruoyi.common.utils.bean.BeanUtils;
import com.ruoyi.system.user.domain.UserQuery;
import com.ruoyi.system.user.mapper.UserMapper;
import com.ruoyi.system.user.service.UserDashboard;

@Service
public class UserDashboardImpl implements UserDashboard {

    @Autowired
    private UserMapper userMapper;


    private Integer selectMchCount(UserQuery query) {
        UserQuery mchQuery = new UserQuery();
        BeanUtils.copyProperties(query, mchQuery);
        mchQuery.setRoleKey(RoleConstants.MCH);
        return userMapper.selectCount(mchQuery);
    }

    private Integer selectAgentCount(UserQuery query) {
        UserQuery agentQuery = new UserQuery();
        BeanUtils.copyProperties(query, agentQuery);
        agentQuery.setRoleKey(RoleConstants.AGENT);
        return userMapper.selectCount(agentQuery);
    }

    // 获取普通用户的数量
    private Integer selectNormalCount(UserQuery query) {
        UserQuery normalQuery = new UserQuery();
        BeanUtils.copyProperties(query, normalQuery);
        normalQuery.setUserType(UserType.USER.getCode());
        return MathUtils.dv(userMapper.selectCount(normalQuery));
    }

}
