package com.czg.service.market.service.impl;

import cn.hutool.core.util.StrUtil;
import com.czg.utils.PageUtil;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import com.czg.market.entity.MkShopRechargeFlow;
import com.czg.market.service.MkRechargeFlowService;
import com.czg.service.market.mapper.MkRechargeFlowMapper;
import org.springframework.stereotype.Service;

/**
 * 充值流水表 服务层实现。
 *
 * @author zs
 * @since 2025-09-16
 */
@Service
public class MkRechargeFlowServiceImpl extends ServiceImpl<MkRechargeFlowMapper, MkShopRechargeFlow> implements MkRechargeFlowService{
    @Override
    public Page<MkShopRechargeFlow> pageInfo(Long shopId, String startTime, String ednTime, String type) {
        QueryWrapper queryWrapper = new QueryWrapper().eq(MkShopRechargeFlow::getShopId, shopId);
        if (StrUtil.isNotBlank(startTime)) {
            queryWrapper.ge(MkShopRechargeFlow::getCreateTime, startTime);
        }

        if (StrUtil.isNotBlank(ednTime)) {
            queryWrapper.le(MkShopRechargeFlow::getCreateTime, ednTime);
        }

        if (StrUtil.isNotBlank(type)) {
            queryWrapper.eq(MkShopRechargeFlow::getType, type);
        }

        return page(PageUtil.buildPage(), queryWrapper.orderBy(MkShopRechargeFlow::getCreateTime, false));
    }
}
