package com.seeyon.apps.src_hxinvoice.vo;

import com.alibaba.fastjson.JSONObject;

/**
 * 功能描述:<br>
 * <pre>
 *
 * </pre>
 *
 * @Author: HuangZhengguo
 * @Date: 2024/4/28
 */
public class HxinvoiceResponse {

    private boolean success;
    private int status;
    private String msg;
    private String data;
//    {"DDQQPCH”:"10001","ZTDM":"029999","ZTXX”:"订单处理失败”}
//    {"DDQQPCH”:"10001",“ZTDM”:"010000”,“ZTXX”:"发票请求接收成功”}
    public HxinvoiceResponse(JSONObject object) {
        if(object.containsKey("ZTDM")) {
            this.status = object.getString("ZTDM").equals("010000")?1:2;
        } else {
            this.status = object.getString("ZTDM").equals("000000")?1:2;
        }
        this.success = (1 == status);
        if(object.containsKey("ZTXX")) {
            this.msg = object.getString("ZTXX");
        } else {
            this.msg = object.getString("ZTXX");
        }
        if(object.containsKey("DDQQPCH")) {
            this.data = object.getString("DDQQPCH");
        } else {
            this.data = object.toString();
        }
    }

    public HxinvoiceResponse(JSONObject object,String type) {
        if("/sims-api/invoice/api/v6/OrderToFastRedInvoice".equals(type)){
            if(object.containsKey("ZTDM")) {
                this.status = object.getString("ZTDM").equals("000000")?1:2;
            } else {
                this.status = object.getString("ZTDM").equals("000000")?1:2;
            }
            this.success = (1 == status);
            if(object.containsKey("ZTXX")) {
                this.msg = object.getString("ZTXX");
            } else {
                this.msg = object.getString("ZTXX");
            }
            this.data = object.toString();
        }else if("/sims-api/invoice/api/v6/QueryFastRedInvoiceResult".equals(type)){
            if(object.containsKey("ZTDM")) {
                this.status = object.getString("ZTDM").equals("000000")?1:2;
            } else {
                this.status = object.getString("ZTDM").equals("000000")?1:2;
            }
            this.success = (1 == status);
            if(object.containsKey("ZTXX")) {
                this.msg = object.getString("ZTXX");
            } else {
                this.msg = object.getString("ZTXX");
            }
            this.data = object.toString();
        }


    }

    public boolean isSuccess() {
        return success;
    }

    public HxinvoiceResponse setSuccess(boolean success) {
        this.success = success;
        return this;
    }

    public int getStatus() {
        return status;
    }

    public HxinvoiceResponse setStatus(int status) {
        this.status = status;
        return this;
    }

    public String getMsg() {
        return msg;
    }

    public HxinvoiceResponse setMsg(String msg) {
        this.msg = msg;
        return this;
    }

    public String getData() {
        return data;
    }

    public HxinvoiceResponse setData(String data) {
        this.data = data;
        return this;
    }
}
