package com.jeequan.jeepay.core.model.bill;

import com.jeequan.jeepay.core.model.params.IsvParams;
import com.jeequan.jeepay.core.model.params.IsvsubMchParams;
import com.jeequan.jeepay.core.model.params.NormalMchParams;
import lombok.Data;

import java.util.List;
import java.util.Set;

/***
 * 渠道对账单请求参数类
 *
 * @author zx
 *
 * @date 2021/12/30 9:01
 */
@Data
public class ChannelBillRQ {

    public static final String INFO_TYPE_ISV = "isv";
    public static final String INFO_TYPE_SUB = "sub";
    public static final String INFO_TYPE_NORMAL = "normal";

    /**
     * 渠道商户号
     */
    private String channelMchNo;

    /**
     * 商户应用
     */
    private String infoId;

    /**
     * 渠道账单维度：isv - 服务商，sub - 特约商户，normal - 普通商户
     */
    private String infoType;

    /**
     * 服务商参数
     */
    private IsvParams isvParams;

    /**
     * 特约商户参数
     */
    private IsvsubMchParams isvsubMchParams;

    /**
     * 普通商户参数
     */
    private NormalMchParams normalMchParams;

    /**
     * channelMchNo 对应的 商户应用appId列表/服务商号列表
     */
    private List<String> infoIdList;

    /**
     * 【用于服务商对账维度】   <本地订单要忽略的应用AppId集合，渠道账单要忽略的子商户号集合>
     */
    private Set<String> ignoreCheckBillMchNos;


    public ChannelBillRQ() {
    }

    public ChannelBillRQ(String channelMchNo, String infoId, String infoType, IsvParams isvParams, IsvsubMchParams isvsubMchParams, NormalMchParams normalMchParams, List<String> infoIdList) {
        this.channelMchNo = channelMchNo;
        this.infoId = infoId;
        this.infoType = infoType;
        this.isvParams = isvParams;
        this.isvsubMchParams = isvsubMchParams;
        this.normalMchParams = normalMchParams;
        this.infoIdList = infoIdList;
    }

    public ChannelBillRQ(String channelMchNo, String infoId, String infoType, IsvParams isvParams, IsvsubMchParams isvsubMchParams,
                         NormalMchParams normalMchParams, List<String> infoIdList, Set<String> ignoreCheckBillMchNos) {
        this.channelMchNo = channelMchNo;
        this.infoId = infoId;
        this.infoType = infoType;
        this.isvParams = isvParams;
        this.isvsubMchParams = isvsubMchParams;
        this.normalMchParams = normalMchParams;
        this.infoIdList = infoIdList;
        this.ignoreCheckBillMchNos = ignoreCheckBillMchNos;
    }

    /** 构建服务商维度对账配置参数 */
    public static ChannelBillRQ buildIsvChannelBillRQ(String channelMchNo, String infoId, IsvParams isvParams, List<String> infoIdList, Set<String> ignoreCheckBillMchNos) {
        return new ChannelBillRQ(channelMchNo, infoId, INFO_TYPE_ISV, isvParams, null, null, infoIdList, ignoreCheckBillMchNos);
    }

    /** 构建服务商子商户维度对账配置参数 */
    public static ChannelBillRQ buildSubMchChannelBillRQ(String channelMchNo, String infoId, IsvsubMchParams isvsubMchParams, List<String> infoIdList) {
        return new ChannelBillRQ(channelMchNo, infoId, INFO_TYPE_SUB, null, isvsubMchParams, null, infoIdList);
    }

    /** 构建普通商户维度对账配置参数 */
    public static ChannelBillRQ buildNormalMchChannelBillRQ(String channelMchNo, String infoId, NormalMchParams normalMchParams, List<String> infoIdList) {
        return new ChannelBillRQ(channelMchNo, infoId, INFO_TYPE_NORMAL, null, null, normalMchParams, infoIdList);
    }

}
