package org.jeecg.modules.shop.commission.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.jeecg.modules.shop.commission.entity.PartnerCommission;
import org.jeecg.modules.shop.commission.entity.vo.CommissionCountVO;
import org.jeecg.modules.shop.commission.entity.vo.PartnerCommissionVO;
import org.jeecg.modules.shop.commission.mapper.PartnerCommissionMapper;
import org.jeecg.modules.shop.commission.service.IPartnerCommissionService;
import org.jeecg.modules.shop.user.util.partnerUserHolder;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.math.BigDecimal;

/**
 * @Description: 合作伙伴佣金
 * @Author: jeecg-boot
 * @Date:   2025-07-15
 * @Version: V1.0
 */
@Service
public class PartnerCommissionServiceImpl extends ServiceImpl<PartnerCommissionMapper, PartnerCommission> implements IPartnerCommissionService {

    @Override
    public IPage<PartnerCommissionVO> pagList(Integer pageNo, Integer pageSize) {
        IPage<PartnerCommissionVO> page = new Page<>(pageNo, pageSize);
        String userId = partnerUserHolder.currentLoginUserId();
        return baseMapper.pagList(page,userId);
    }

    @Override
    public CommissionCountVO moneyCount() {
        String userId = partnerUserHolder.currentLoginUserId();
        return baseMapper.moneyCount(userId);
    }

    @Override
    public BigDecimal getCommissionByUserAndYear(String userId, String year) {
        return baseMapper.getCommissionByUserAndYear(userId,year);
    }

    @Override
    public BigDecimal getOrderCommissionByUserAndYear(String userId, String year) {
        return baseMapper.getOrderCommissionByUserAndYear(userId,year);
    }
}
