package io.renren.modules.sys.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.renren.common.service.impl.CrudServiceImpl;
import io.renren.modules.sys.dao.RdAccountDailyStatDao;
import io.renren.modules.sys.dto.RdAccountDailyStatDTO;
import io.renren.modules.sys.entity.RdAccountDailyStatEntity;
import io.renren.modules.sys.service.RdAccountDailyStatService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * 账户日流水
 *
 * @author Mark sunlightcs@gmail.com
 * @since 1.0.0 2022-06-03
 */
@Service
public class RdAccountDailyStatServiceImpl extends CrudServiceImpl<RdAccountDailyStatDao, RdAccountDailyStatEntity, RdAccountDailyStatDTO> implements RdAccountDailyStatService {

    @Override
    public QueryWrapper<RdAccountDailyStatEntity> getWrapper(Map<String, Object> params){
        String id = (String)params.get("id");
        String advertiserId = (String)params.get("advertiserId");
        String startDate = (String)params.get("startDate");
        String endDate = (String)params.get("endDate");

        QueryWrapper<RdAccountDailyStatEntity> wrapper = new QueryWrapper<>();
        wrapper.eq(StringUtils.isNotBlank(id), "id", id).eq("status",1)
                .eq(StringUtils.isNotBlank(advertiserId), "advertiser_id", advertiserId)
                .ge(StringUtils.isNotBlank(startDate), "date", startDate)
                .le(StringUtils.isNotBlank(endDate), "date", endDate)
                .orderByDesc("id");

        return wrapper;
    }


}