package org.springblade.dataextraction.params;

import java.util.Date;

import org.springblade.dataextraction.enity.FinOrderFetchTask;
import org.springframework.web.multipart.MultipartFile;

import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.NullSerializer;

import cn.hutool.core.util.StrUtil;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * 创建订购数据提取任务表单参数
 * @author William
 * @date 2022年11月1日 下午12:11:33
 */
@Data
public class FinOrderFetchTaskParams {
	@ApiModelProperty(value = "用户圈定方式（1-输入单个手机号码；2-导入批量手机号码；3-条件筛选）", required = true)
	private Integer utype; // 用户圈定方式.。1：输入单个手机号码；2：导入批量手机号码；3：条件筛选；

	@ApiModelProperty(value = "圈定_用户类型。1：订购；2：退订；3：有效", required = false)
	private Integer cUsertype; // 圈定_用户类型。1：订购；2：退订；3：有效

	@ApiModelProperty(value = "圈定筛选条件-有效月份。yyyymm格式", required = false)
	private Integer cVmonth; // 圈定筛选条件-有效月份。yyyymm格式

	@ApiModelProperty(value = "手机号码：utype=1时为必填项，其他不用传值", required = false)
	private String userId; // 手机号码。utype=1情形使用

	@JsonSerialize(nullsUsing = NullSerializer.class)
	@ApiModelProperty(value = "圈定筛选条件-订购起始日期，6位数字，条件筛选时必传", required = false)
	private Integer orderDayStart; // 圈定筛选条件-订购起始日期

	@JsonSerialize(nullsUsing = NullSerializer.class)
	@ApiModelProperty(value = "圈定筛选条件-订购截止日期，6位数字，条件筛选时必传", required = false)
	private Integer orderDayEnd; // 圈定筛选条件-订购截止日期

	@JsonSerialize(nullsUsing = NullSerializer.class)
	@ApiModelProperty(value = "圈定筛选条件-退订起始日期，6位数字，条件筛选时必传", required = false)
	private Integer cancelDayStart; // 圈定筛选条件-退订起始日期

	@JsonSerialize(nullsUsing = NullSerializer.class)
	@ApiModelProperty(value = "圈定筛选条件-退订截止日期，6位数字，条件筛选时必传", required = false)
	private Integer cancelDayEnd; // 圈定筛选条件-退订截止日期

	@JsonSerialize(nullsUsing = NullSerializer.class)
	@ApiModelProperty(value = "提取筛选条件-起始月份，6位数字", required = true)
	private Integer monthStart; // 提取筛选条件-起始月份

	@JsonSerialize(nullsUsing = NullSerializer.class)
	@ApiModelProperty(value = "提取筛选条件-截止月份，6位数字", required = true)
	private Integer monthEnd; // 提取筛选条件-截止月份

	@ApiModelProperty(value = "圈定筛选条件-产品大类ID，多个ID以逗号分隔", required = false)
	private String cpType; // 圈定筛选条件-产品大类ID。多个ID以逗号分隔

	@ApiModelProperty(value = "圈定筛选条件-唯一产品类别ID，逗号分割，最大限10个ID", required = false)
	private String fullCptype; // 圈定筛选条件-唯一产品类别ID。逗号分割，最大限10个ID

	@ApiModelProperty(value = "圈定筛选条件-产品ID，逗号分割，最大限10个ID", required = false)
	@TableField(value = "C_SPID")
	private String spid; // 圈定筛选条件-产品ID。逗号分割，最大限10个ID

	@ApiModelProperty(value = "圈定筛选条件-省份，逗号分割，最大限10个省份", required = false)
	private String province; // 圈定筛选条件-省份。逗号分割，最大限10个省份

	@ApiModelProperty(value = "圈定筛选条件-地市，逗号分割，最大限10个地市", required = false)
	private String area; // 圈定筛选条件-地市。逗号分割，最大限10个地市

	@ApiModelProperty(value = "圈定筛选条件-订购渠道类别", required = false)
	private String belongto; // 圈定筛选条件-订购渠道类别

	@ApiModelProperty(value = "圈定筛选条件-退订渠道类别", required = false)
	private String belongtoCancel; // 圈定筛选条件-退订渠道类别

	@ApiModelProperty(value = "圈定筛选条件-订购渠道ID", required = false)
	private String orderChannel; // 圈定筛选条件-订购渠道ID

	@ApiModelProperty(value = "圈定筛选条件-退订渠道ID", required = false)
	private String cancelChannel; // 圈定筛选条件-退订渠道ID

	@ApiModelProperty(value = "提取订购数据类型。1：订购记录（月份范围）；2：退订记录（月份范围）；3：有效用户（某个月）", required = false)
	private Integer fetchType; // 提取订购数据类型。1：订购记录（月份范围）；2：退订记录（月份范围）；3：有效用户（某个月）。

	@ApiModelProperty(value = "提取筛选条件-产品ID。逗号分割，最大限10个ID", required = false)
	@TableField(value = "F_SPID2")
	private String spid2; // 提取筛选条件-产品ID。逗号分割，最大限10个ID

	@ApiModelProperty(value = "提取结果-需要提取会员领取。0：不需要；1：需要；", required = false)
	private Integer fetchflag1; // 提取结果-需要提取会员领取。0：不需要；1：需要；

	@ApiModelProperty(value = "提取结果-需要提取流量消耗。0：不需要；1：需要；", required = false)
	private Integer fetchflag2; // 提取结果-需要提取流量消耗。0：不需要；1：需要；

	@ApiModelProperty(value = "提取结果-需要提取投诉量。0：不需要；1：需要", required = false)
	private Integer fetchflag3; // 提取结果-需要提取投诉量。0：不需要；1：需要

	@ApiModelProperty(value = "订购类型（1：订购；2：退订；3：有效）", required = false)
	private Integer orderType;// 1：订购；2：退订；3：有效

	@ApiModelProperty(value = "手机号文件，utype=2时必填", required = false)
	private MultipartFile file;

	@ApiModelProperty(value = "是否勾选自订购以来（0：否；1：是；）", required = false)
	private Integer sinceOrder;

	@JsonSerialize(nullsUsing = NullSerializer.class)
	@ApiModelProperty(value = "自订购以来的-起始月份，6位数字", required = true)
	private Integer monthStartForSincet; // 自订购以来的-起始月份

	@JsonSerialize(nullsUsing = NullSerializer.class)
	@ApiModelProperty(value = "自订购以来的-截止月份，6位数字", required = true)
	private Integer monthEndForSincet; // 自订购以来的-截止月份

	@ApiModelProperty(value = "最大允许导入的用户数", required = false)
	@TableField(value = "FETCHED_NUMS")
	private Integer fetchedNums;

	@ApiModelProperty(value = "扩展数据", required = false)
	@TableField(value = "CONDITION_JSON")
	private String conditionJson;

	@ApiModelProperty(value = "是否是cb侧(0：否；1：是)", required = false)
	private Integer outPutIsCB;

	@ApiModelProperty(value = "是否导出（1-输出；0-不输出，默认为1）", required = false)
	private Integer outputProvince;

	@ApiModelProperty(value = "是否导出（1-输出；0-不输出，默认为1）", required = false)
	private Integer outputArea;

	@ApiModelProperty(value = "是否导出（1-输出；0-不输出，默认为1）", required = false)
	private Integer outputSpid;

	@ApiModelProperty(value = "是否导出（1-输出；0-不输出，默认为1）", required = false)
	private Integer outputPrmid;

	@ApiModelProperty(value = "是否导出（1-输出；0-不输出，默认为1）", required = false)
	private Integer outputSpname;

	@ApiModelProperty(value = "是否导出（1-输出；0-不输出，默认为1）", required = false)
	private Integer outputOrdertime;

	@ApiModelProperty(value = "是否导出（1-输出；0-不输出，默认为1）", required = false)
	private Integer outputOrderchannelid;

	@ApiModelProperty(value = "是否导出（1-输出；0-不输出，默认为1）", required = false)
	private Integer outputOrderchannelname;

	@ApiModelProperty(value = "是否导出（1-输出；0-不输出，默认为1）", required = false)
	private Integer outputOrderbelongto;

	@ApiModelProperty(value = "是否导出（1-输出；0-不输出，默认为1）", required = false)
	private Integer outputCanceltime;

	@ApiModelProperty(value = "是否导出（1-输出；0-不输出，默认为1）", required = false)
	private Integer outputCancelchannelid;

	@ApiModelProperty(value = "是否导出（1-输出；0-不输出，默认为1）", required = false)
	private Integer outputCancelchannelname;

	@ApiModelProperty(value = "是否导出（1-输出；0-不输出，默认为1）", required = false)
	private Integer outputCancelbelongto;

	public FinOrderFetchTask convert() {
		FinOrderFetchTaskParams param = this;
		FinOrderFetchTask task = new FinOrderFetchTask();
		task.setArea(StrUtil.isBlankOrUndefined(param.getArea()) ? null : param.getArea());
		task.setBelongto(StrUtil.isBlankOrUndefined(param.getBelongto()) ? null : param.getBelongto());
		task.setBelongtoCancel(
				StrUtil.isBlankOrUndefined(param.getBelongtoCancel()) ? null : param.getBelongtoCancel());
		task.setCancelChannel(StrUtil.isBlankOrUndefined(param.getCancelChannel()) ? null : param.getCancelChannel());
		task.setCancelDayEnd(param.getCancelDayEnd());
		task.setCancelDayStart(param.getCancelDayStart());
		task.setCpType(StrUtil.isBlankOrUndefined(param.getCpType()) ? null : param.getCpType());
		task.setCUsertype(param.getCUsertype());
		task.setCVmonth(param.getCVmonth());
		task.setFetchflag1(param.getFetchflag1());
		task.setFetchflag2(param.getFetchflag2());
		task.setFetchflag3(param.getFetchflag3());
		task.setFetchType(param.getFetchType());
		task.setFile(param.getFile());
		task.setFullCptype(StrUtil.isBlankOrUndefined(param.getFullCptype()) ? null : param.getFullCptype());
		task.setMonthEnd(param.getMonthEnd());
		task.setMonthStart(param.getMonthStart());
		task.setOrderChannel(StrUtil.isBlankOrUndefined(param.getOrderChannel()) ? null : param.getOrderChannel());
		task.setOrderDayEnd(param.getOrderDayEnd());
		task.setOrderDayStart(param.getOrderDayStart());
		task.setOrderType(param.getOrderType());
		task.setProvince(StrUtil.isBlankOrUndefined(param.getProvince()) ? null : param.getProvince());
		task.setSpid(StrUtil.isBlankOrUndefined(param.getSpid()) ? null : param.getSpid());
		task.setSpid2(StrUtil.isBlankOrUndefined(param.getSpid2()) ? null : param.getSpid2());
		task.setUserId(StrUtil.isBlankOrUndefined(param.getUserId()) ? null : param.getUserId());
		task.setUtype(param.getUtype());
		task.setUnlimited(param.getSinceOrder());
		if (param.getFetchedNums() != null) {
			task.setFetchedNums(param.getFetchedNums());
		}
		task.setConditionJson(param.getConditionJson());
		task.setOutPutIsCB(param.outPutIsCB);
		task.setCreateTime(new Date());
		task.setOrderType(null);

		if (outputArea != null) {
			task.setOutputArea(outputArea);
		}

		if (outputCancelbelongto != null) {
			task.setOutputCancelbelongto(outputCancelbelongto);
		}

		if (outputCancelchannelid != null) {
			task.setOutputCancelchannelid(outputCancelchannelid);
		}

		if (outputCancelchannelname != null) {
			task.setOutputCancelchannelname(outputCancelchannelname);
		}

		if (outputCanceltime != null) {
			task.setOutputCanceltime(outputCanceltime);
		}

		if (outputOrderbelongto != null) {
			task.setOutputOrderbelongto(outputOrderbelongto);
		}

		if (outputOrderchannelid != null) {
			task.setOutputOrderchannelid(outputOrderchannelid);
		}

		if (outputOrderchannelname != null) {
			task.setOutputOrderchannelname(outputOrderchannelname);
		}

		if (outputOrdertime != null) {
			task.setOutputOrdertime(outputOrdertime);
		}

		if (outputPrmid != null) {
			task.setOutputPrmid(outputPrmid);
		}

		if (outputProvince != null) {
			task.setOutputProvince(outputProvince);
		}
		if (outputSpid != null) {
			task.setOutputSpid(outputSpid);
		}
		if (outputSpname != null) {
			task.setOutputSpname(outputSpname);
		}

		return task;
	}
}
