package com.wzj.soopin.statistics.service.impl;

import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.text.CharSequenceUtil;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wzj.soopin.member.domain.po.Feedback;
import com.wzj.soopin.statistics.mapper.MemberEvaluationStatisticsMapper;
import com.wzj.soopin.statistics.service.MemberEvaluationStatisticsService;
import org.springframework.stereotype.Service;

import java.util.Objects;

/**
 * 会员商品评价业务层实现
 *
 * @author Bulbasaur
 * @since 2020-02-25 14:10:16
 */
@Service
public class MemberEvaluationStatisticsServiceImpl extends ServiceImpl<MemberEvaluationStatisticsMapper, Feedback> implements MemberEvaluationStatisticsService {


    @Override
    public long todayMemberEvaluation() {
        return this.count(new LambdaQueryWrapper<Feedback>().ge(Feedback::getCreateTime, DateUtil.beginOfDay(new DateTime())));
    }

    @Override
    public long getWaitReplyNum() {
        QueryWrapper<Feedback> queryWrapper = Wrappers.query();
//        queryWrapper.eq(CharSequenceUtil.equals(Objects.requireNonNull(UserContext.getCurrentUser()).getRole().name(), UserEnums.STORE.name()),
//                "store_id", UserContext.getCurrentUser().getStoreId());
//        queryWrapper.eq("reply_status", false);
        return this.count(queryWrapper);
    }

}
