ShouldBeCompletedQuery.java 2.45 KB
package cn.fw.valhalla.sdk.param;

import lombok.Data;
import org.springframework.util.CollectionUtils;

import javax.validation.constraints.NotBlank;
import java.time.YearMonth;
import java.time.ZoneId;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

/**
 * 应成交台数查询
 *
 * @author : kurisu
 * @version : 1.0
 * @className : ShouldBeCompletedQuery
 * @description : 应成交台数查询
 * @date : 2022-10-20 11:33
 */
@Data
public class ShouldBeCompletedQuery {
    private final static String SEPARATOR = ",";
    /**
     * 跟进人员id
     */
    private Long userId;
    /**
     * 门店ids
     */
    @NotBlank(message = "门店不能为空")
    private String shopIds;
    /**
     * 跟进开始时间 [时间戳 默认为本月月初]
     */
    private Long startTime;
    /**
     * 跟进截止时间 [时间戳 默认为本月月底]
     */
    private Long endTime;

    public String getStartTime() {
        if (Objects.isNull(startTime)) {
            long second = YearMonth.now().atDay(1).atStartOfDay(ZoneId.systemDefault()).toEpochSecond();
            return String.valueOf(second);
        }
        String timeStr = String.valueOf(startTime);
        return timeStr.length() >= 10 ? timeStr.substring(0, 10) : timeStr;
    }

    public String getEndTime() {
        if (Objects.isNull(endTime)) {
            long second = YearMonth.now().atEndOfMonth().atStartOfDay(ZoneId.systemDefault()).toEpochSecond();
            return String.valueOf(second);
        }
        String timeStr = String.valueOf(endTime);
        return timeStr.length() >= 10 ? timeStr.substring(0, 10) : timeStr;
    }

    public List<Long> getShopId() {
        return Arrays.stream(shopIds.split(SEPARATOR)).map(Long::valueOf).collect(Collectors.toList());
    }

    /**
     * 设置门店
     *
     * @param shopId 门店id数组
     */
    public void setShopId(final Long... shopId) {
        if (shopId == null || shopId.length == 0) {
            return;
        }
        this.shopIds = Arrays.stream(shopId).map(String::valueOf).collect(Collectors.joining(SEPARATOR));
    }

    /**
     * 设置门店
     *
     * @param shopIdList 门店id集合
     */
    public void setShopId(final List<Long> shopIdList) {
        if (CollectionUtils.isEmpty(shopIdList)) {
            return;
        }
        this.shopIds = shopIdList.stream().map(String::valueOf).collect(Collectors.joining(SEPARATOR));
    }
}