package com.slodon.b2b2c.starter.mq.entity;

import lombok.Data;

import java.io.Serializable;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @program: slodon
 * @Description 消息发送信息
 * @Author wuxy
 */
@Data
public class MessageSendVO implements Serializable {

    //商户对应id或者会员对应id
    private long receiveId;
    //模版类型
    private String tplType;
    //跳转链接信息
    private String msgLinkInfo;
    //模版参数，从前往后对应，若无模板参数，则设置为空
    private String[] templateParam;
    //微信参数构造
    private List<MessageSendProperty> propertyList;

    public MessageSendVO(long receiveId, String tplType, String msgLinkInfo, String[] templateParam) {
        this.receiveId = receiveId;
        this.tplType = tplType;
        this.msgLinkInfo = msgLinkInfo;
        this.templateParam = templateParam;
    }

    public MessageSendVO(List<MessageSendProperty> propertyList, Integer receiveId, String tplType, String msgLinkInfo, String[] templateParam) {
        this.receiveId = receiveId;
        this.tplType = tplType;
        this.msgLinkInfo = msgLinkInfo;
        this.templateParam = templateParam;
        this.propertyList = propertyList;
    }

    /**
     *  TODO 20220309 为保证项目运行生成方法 此处原来缺失报错
     */
    public MessageSendVO(List<MessageSendProperty> templateParamList,  List<MessageSendProperty> propertyList,Object o, Integer receiveId, String tplType, String msgLinkInfo) {
        this.receiveId = receiveId;
        this.tplType = tplType;
        this.msgLinkInfo = msgLinkInfo;
        this.templateParam = templateParamList.stream().map(m-> m.getPropertyValue()).toArray(String[]::new);
        this.propertyList = propertyList;
    }
    /**
     *  TODO 20220309 为保证项目运行生成方法 此处原来缺失报错
     */
    public MessageSendVO(List<MessageSendProperty> templateParamList, Integer receiveId, Long storeId, String tplType, String msgLinkInfo) {
        if(null == receiveId || "".equals(receiveId) ){
            this.receiveId = storeId;
        }else{
            this.receiveId = receiveId;
        }
        this.tplType = tplType;
        this.msgLinkInfo = msgLinkInfo;
        this.templateParam = templateParamList.stream().map(m-> m.getPropertyValue()).toArray(String[]::new);
    }
}
