package com.ruoyi.app.order.dto;

import cn.hutool.core.lang.TypeReference;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import lombok.Data;

import java.util.Map;

@Data
public class OrderPushBodyDto {
    private String ddId;
    private String state;
    //0:语音提醒新订单
    private int type=-1;
    //1 外卖订单 2 充值订单
    private int pushType=1;

    private String title;
    private String content;


    public OrderPushBodyDto(String title, String content, String ddId, String state, int type,int pushType) {
       this.title = title;
        this.content = content;
        this.ddId = ddId;
        this.state = state;
        this.type = type;
        this.pushType=pushType;
    }

    public OrderPushBodyDto(String ddId, String state, int type) {
        this.ddId = ddId;
        this.state = state;
        this.type = type;
    }

    public OrderPushBodyDto(String ddId, String state, int type,int pushType) {
        this.ddId = ddId;
        this.state = state;
        this.type = type;
        this.pushType=pushType;
    }

    public OrderPushBodyDto(String ddId, String state) {
        this.ddId = ddId;
        this.state = state;
        // type将使用类字段定义时的默认值-1
    }

    public static String getJson(String ddId, String state) {
        OrderPushBodyDto orderPushBodyDto = new OrderPushBodyDto(ddId, state);
        return JSONObject.toJSONString(orderPushBodyDto);
    }

    public static String getJson(String ddId, String state, int type) {
        OrderPushBodyDto orderPushBodyDto = new OrderPushBodyDto(ddId, state, type);
        return JSONObject.toJSONString(orderPushBodyDto);
    }

    public static String getJson(String ddId, String state, int type,int pushType) {
        OrderPushBodyDto orderPushBodyDto = new OrderPushBodyDto(ddId, state, type,pushType);
        return JSONObject.toJSONString(orderPushBodyDto);
    }


    public static Map<String, Object> getMap(String ddId, String state, int type,int pushType) {
        OrderPushBodyDto orderPushBodyDto = new OrderPushBodyDto(ddId, state, type,pushType);
        return JSON.parseObject(JSON.toJSONString(orderPushBodyDto), new TypeReference<Map<String, Object>>() {
        });
    }

    public static String margeMapGetJsonString(Map<String, Object> map1, Map<String, Object> map2){
        map1.putAll(map2);
        return JSON.toJSONString(map1);
    }
}
