package com.dy.pipIrrStatistics.card; 
 | 
  
 | 
import com.dy.common.webUtil.QueryResultVo; 
 | 
import com.dy.pipIrrGlobal.daoSe.SeVcOperateMapper; 
 | 
import com.dy.pipIrrGlobal.voSt.VoClientStatistics; 
 | 
import com.dy.pipIrrStatistics.card.qo.CommonQO; 
 | 
import com.dy.pipIrrStatistics.card.qo.StartStopDateQO; 
 | 
import com.dy.pipIrrStatistics.card.qo.TotalRechargeQO; 
 | 
import lombok.extern.slf4j.Slf4j; 
 | 
import org.apache.dubbo.common.utils.PojoUtils; 
 | 
import org.springframework.beans.factory.annotation.Autowired; 
 | 
import org.springframework.stereotype.Service; 
 | 
  
 | 
import java.time.LocalDate; 
 | 
import java.util.List; 
 | 
import java.util.Map; 
 | 
import java.util.Optional; 
 | 
  
 | 
/** 
 | 
 * @author ZhuBaoMin 
 | 
 * @date 2024-08-08 9:14 
 | 
 * @LastEditTime 2024-08-08 9:14 
 | 
 * @Description 
 | 
 */ 
 | 
  
 | 
@Slf4j 
 | 
@Service 
 | 
public class VirtualCardSv { 
 | 
    @Autowired 
 | 
    private SeVcOperateMapper seVcOperateMapper; 
 | 
  
 | 
    /** 
 | 
     * 指定时间段内注册虚拟卡的农户 
 | 
     * @param qo 
 | 
     * @return 
 | 
     */ 
 | 
    public QueryResultVo<List<VoClientStatistics>> getRegisterVcClients(CommonQO qo) { 
 | 
        /** 
 | 
         * 补齐起止时间,如果开始时间为空,则默认为当前日期 
 | 
         */ 
 | 
        String timeStart = qo.getTimeStart(); 
 | 
        String timeStop = qo.getTimeStop(); 
 | 
        if(timeStart != null) { 
 | 
            timeStart = timeStart + " 00:00:00"; 
 | 
        }else { 
 | 
            timeStart = LocalDate.now() + " 00:00:00"; 
 | 
        } 
 | 
        if(timeStop != null) { 
 | 
            timeStop = timeStop + " 23:59:59"; 
 | 
        } 
 | 
        qo.setTimeStart(timeStart); 
 | 
        qo.setTimeStop(timeStop); 
 | 
  
 | 
        // 生成查询参数 
 | 
        Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(qo) ; 
 | 
  
 | 
        // 获取符合条件的记录数 
 | 
        Long itemTotal = Optional.ofNullable(seVcOperateMapper.getRegisterVcClientsCount(params)).orElse(0L); 
 | 
  
 | 
        QueryResultVo<List<VoClientStatistics>> rsVo = new QueryResultVo<>() ; 
 | 
  
 | 
        rsVo.pageSize = qo.pageSize ; 
 | 
        rsVo.pageCurr = qo.pageCurr ; 
 | 
  
 | 
        rsVo.calculateAndSet(itemTotal, params); 
 | 
        rsVo.obj = seVcOperateMapper.getRegisterVcClients(params); 
 | 
        return rsVo ; 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * 指定时间段内注册总数量 
 | 
     * @param qo 
 | 
     * @return 
 | 
     */ 
 | 
    public Long getRegisterCount(StartStopDateQO qo) { 
 | 
        /** 
 | 
         * 补齐起止时间,如果开始时间为空,则默认为当前日期 
 | 
         */ 
 | 
        String timeStart = qo.getTimeStart(); 
 | 
        String timeStop = qo.getTimeStop(); 
 | 
        if(timeStart != null) { 
 | 
            timeStart = timeStart + " 00:00:00"; 
 | 
        }else { 
 | 
            timeStart = LocalDate.now() + " 00:00:00"; 
 | 
        } 
 | 
        if(timeStop != null) { 
 | 
            timeStop = timeStop + " 23:59:59"; 
 | 
        } 
 | 
        qo.setTimeStart(timeStart); 
 | 
        qo.setTimeStop(timeStop); 
 | 
  
 | 
        // 生成查询参数 
 | 
        Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(qo) ; 
 | 
  
 | 
        // 获取符合条件的记录数 
 | 
        return Optional.ofNullable(seVcOperateMapper.getRegisterCount(params)).orElse(0L); 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * 指定时间段充值总数量 
 | 
     * @param qo 
 | 
     * @return 
 | 
     */ 
 | 
    public Long getRechargeCount(StartStopDateQO qo) { 
 | 
        /** 
 | 
         * 补齐起止时间,如果开始时间为空,则默认为当前日期 
 | 
         */ 
 | 
        String timeStart = qo.getTimeStart(); 
 | 
        String timeStop = qo.getTimeStop(); 
 | 
        if(timeStart != null) { 
 | 
            timeStart = timeStart + " 00:00:00"; 
 | 
        }else { 
 | 
            timeStart = LocalDate.now() + " 00:00:00"; 
 | 
        } 
 | 
        if(timeStop != null) { 
 | 
            timeStop = timeStop + " 23:59:59"; 
 | 
        } 
 | 
        qo.setTimeStart(timeStart); 
 | 
        qo.setTimeStop(timeStop); 
 | 
  
 | 
        // 生成查询参数 
 | 
        Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(qo) ; 
 | 
  
 | 
        return Optional.ofNullable(seVcOperateMapper.getRechargeCount(params)).orElse(0L); 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * 当前余额总量 
 | 
     * @return 
 | 
     */ 
 | 
    public Double getTotalBalance() { 
 | 
        return Optional.ofNullable(seVcOperateMapper.getTotalBalance()).orElse(0.0); 
 | 
    } 
 | 
  
 | 
    /** 
 | 
     * 指定时间段内虚拟卡充值金额超过指定值的农户 
 | 
     * @param qo 
 | 
     * @return 
 | 
     */ 
 | 
    public QueryResultVo<List<VoClientStatistics>> getLargeRechargeClients(TotalRechargeQO qo) { 
 | 
        /** 
 | 
         * 补齐起止时间,如果开始时间为空,则默认为当前日期 
 | 
         */ 
 | 
        String timeStart = qo.getTimeStart(); 
 | 
        String timeStop = qo.getTimeStop(); 
 | 
        if(timeStart != null) { 
 | 
            timeStart = timeStart + " 00:00:00"; 
 | 
        }else { 
 | 
            timeStart = LocalDate.now() + " 00:00:00"; 
 | 
        } 
 | 
        if(timeStop != null) { 
 | 
            timeStop = timeStop + " 23:59:59"; 
 | 
        } 
 | 
        qo.setTimeStart(timeStart); 
 | 
        qo.setTimeStop(timeStop); 
 | 
  
 | 
        // 生成查询参数 
 | 
        Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(qo) ; 
 | 
  
 | 
        // 获取符合条件的记录数 
 | 
        Long itemTotal = Optional.ofNullable(seVcOperateMapper.getLargeRechargeClientsCount(params)).orElse(0L); 
 | 
  
 | 
        QueryResultVo<List<VoClientStatistics>> rsVo = new QueryResultVo<>() ; 
 | 
  
 | 
        rsVo.pageSize = qo.pageSize ; 
 | 
        rsVo.pageCurr = qo.pageCurr ; 
 | 
  
 | 
        rsVo.calculateAndSet(itemTotal, params); 
 | 
        rsVo.obj = seVcOperateMapper.getLargeRechargeClients(params); 
 | 
        return rsVo ; 
 | 
    } 
 | 
} 
 |