MybatisPlus 分页 复杂查询

 Page page=new Page(param.getCurrent(),param.getSize());
        Wrapper w= new EntityWrapper();
        w.eq("trade_type",tradeType); //支付类型
        w.eq("check_result",checkResult); //对账结果
        String payChannel = param.getPayChannel();
        //支付渠道名称
        if(!StringUtils.isEmpty(payChannel)){
            w.eq("pay_channel",payChannel);
        }
        //差错原因
        Integer diffType = param.getDiffType();
        if(diffType!=null && diffType!=-1){
            w.eq("diff_type",diffType);
        }
        //操作处理
        Integer dealResult = param.getDealResult();
        if(dealResult!=null && dealResult!=-1){
            w.eq("deal_result",dealResult);
        }
        //对账日期开始-结束
        String checkDateBegin = param.getCheckDateBegin();
        if(!StringUtils.isEmpty(checkDateBegin))
            w.and("UNIX_TIMESTAMP(check_date)>=UNIX_TIMESTAMP({0})",checkDateBegin);
        String checkDateEnd = param.getCheckDateEnd();
        if(!StringUtils.isEmpty(checkDateEnd))
            w.and("UNIX_TIMESTAMP(check_date)<=UNIX_TIMESTAMP({0})",checkDateEnd);
        //油站编码
        String oilStationCode = param.getOilStationCode();
        if(!StringUtils.isEmpty(oilStationCode))
            w.eq("oil_station_code",oilStationCode);
        //用户ID
        String userId = param.getUserId();
        if(!StringUtils.isEmpty(userId))
            w.eq("user_id",userId);
        //支付日期开始-结束
        String tradeCreatedTimeBegin = param.getTradeCreatedTimeBegin();
        if(!StringUtils.isEmpty(tradeCreatedTimeBegin))
            w.and("UNIX_TIMESTAMP(trade_created_time)>=UNIX_TIMESTAMP({0})",tradeCreatedTimeBegin);
        String tradeCreatedTimeEnd = param.getTradeCreatedTimeEnd();
        if(!StringUtils.isEmpty(tradeCreatedTimeBegin))
            w.and("UNIX_TIMESTAMP(trade_created_time)<=UNIX_TIMESTAMP({0})",tradeCreatedTimeEnd);
        w.eq("status",1);
        page.setRecords(baseMapper.selectPage(page,w));

 

展开阅读全文

没有更多推荐了,返回首页