package cn.newfeifan.mall.module.distri.dal.mysql.socialstatuschangelog;


import cn.newfeifan.mall.framework.common.pojo.PageResult;
import cn.newfeifan.mall.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.newfeifan.mall.framework.mybatis.core.mapper.BaseMapperX;
import cn.newfeifan.mall.module.distri.dal.dataobject.socialstatuschangelog.SocialStatusChangeLogDO;
import cn.newfeifan.mall.module.distri.enums.SocialStatusEnum;
import org.apache.ibatis.annotations.Mapper;
import cn.newfeifan.mall.module.distri.controller.admin.socialstatuschangelog.vo.*;


/**
 * 会员身价变化日志 Mapper
 *
 * @author 非繁人
 */
@Mapper
public interface SocialStatusChangeLogMapper extends BaseMapperX<SocialStatusChangeLogDO> {

    default PageResult<SocialStatusChangeLogDO> selectPage(SocialStatusChangeLogPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<SocialStatusChangeLogDO>()
                .eqIfPresent(SocialStatusChangeLogDO::getSocialStatusChangeCategoryId, reqVO.getSocialStatusChangeCategoryId())
                .eqIfPresent(SocialStatusChangeLogDO::getVariationValue, reqVO.getVariationValue())
                .eqIfPresent(SocialStatusChangeLogDO::getObjectId, reqVO.getObjectId())
                .eqIfPresent(SocialStatusChangeLogDO::getEffective, reqVO.getEffective())
                .eqIfPresent(SocialStatusChangeLogDO::getDescription, reqVO.getDescription())
                .betweenIfPresent(SocialStatusChangeLogDO::getPlanEffectiveTime, reqVO.getPlanEffectiveTime())
                .betweenIfPresent(SocialStatusChangeLogDO::getActualEffectiveTime, reqVO.getActualEffectiveTime())
                .betweenIfPresent(SocialStatusChangeLogDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(SocialStatusChangeLogDO::getUserId, reqVO.getUserId())
                .orderByDesc(SocialStatusChangeLogDO::getId));
    }

     default PageResult<SocialStatusChangeLogDO> getUserSignLog(SocialStatusChangeLogPageReqVO pageReqVO){
        return selectPage(pageReqVO ,new LambdaQueryWrapperX<SocialStatusChangeLogDO>()
                .eq(SocialStatusChangeLogDO::getUserId, pageReqVO.getUserId())
                .eq(SocialStatusChangeLogDO::getSocialStatusChangeCategoryId, SocialStatusEnum.SIGN_IN_SOCIAL.getStatus())
                .orderByDesc(SocialStatusChangeLogDO::getCreateTime)
        );
     }
}
