package com.gic.haoban.manage.service.service.fee.impl;
import com.gic.haoban.manage.api.dto.fee.HaobanQywxFeeDetailDTO;
import com.gic.haoban.manage.service.dao.mapper.fee.TabHaobanQywxFeeAccountStaffMapper;
import com.gic.haoban.manage.service.entity.fee.TabHaobanQywxFeeAccountStaff;
import com.gic.haoban.manage.service.service.fee.HaobanQywxFeeAccountStaffService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * 企业微信收费订单成员激活详情(TabHaobanQywxFeeAccountStaff)表服务实现类
 *
 * @author mozhu
 * @since 2022-08-03 16:12:32
 */
@Service
public class HaobanQywxFeeAccountStaffServiceImpl implements HaobanQywxFeeAccountStaffService {
    @Autowired
    private TabHaobanQywxFeeAccountStaffMapper tabHaobanQywxFeeAccountStaffMapper;

    /**
     * 新增数据
     *
     * @param tabHaobanQywxFeeAccountStaff 实例对象
     * @return 实例对象
     */
    @Override
    public TabHaobanQywxFeeAccountStaff save(TabHaobanQywxFeeAccountStaff account) {
        this.tabHaobanQywxFeeAccountStaffMapper.insert(account);
        return account ;
    }
    
    @Override
    public void deleteAll(String wxEnterpriseId) {
       this.tabHaobanQywxFeeAccountStaffMapper.deleteAll(wxEnterpriseId);
    }

    @Override
    public List<HaobanQywxFeeDetailDTO> feeDetail(String wxEnterpriseId) {
        return tabHaobanQywxFeeAccountStaffMapper.feeDetail(wxEnterpriseId);
    }

    @Override
    public HaobanQywxFeeDetailDTO feeIntercept(String wxEnterpriseId) {
        Date lastFeeInterceptTime = tabHaobanQywxFeeAccountStaffMapper.lastFeeInterceptTime(wxEnterpriseId);
        int count = tabHaobanQywxFeeAccountStaffMapper.lastFeeInterceptCount(wxEnterpriseId);
        HaobanQywxFeeDetailDTO haobanQywxFeeDetailDTO = new HaobanQywxFeeDetailDTO();
        haobanQywxFeeDetailDTO.setInterceptTime(lastFeeInterceptTime);
        haobanQywxFeeDetailDTO.setInterceptUserNum(count);
        return haobanQywxFeeDetailDTO;
    }
}
