MybatisPlus 分页 复杂查询

本文介绍了一个支付对账系统的查询逻辑实现方法,通过多种条件组合查询支付交易记录,包括支付类型、对账结果、支付渠道等。利用EntityWrapper进行SQL条件拼接,实现了灵活的分页查询。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 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));

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值