package cn.superdesk.uniorder.openapicall.thirdpart.szhtxx.paperInvoice.dto.response.SID4ToInvalid;

import cn.superdesk.uniorder.common.json.AnJsonUtils;
import cn.superdesk.uniorder.openapicall.thirdpart.szhtxx.paperInvoice.dto.response._SzhtxxPaperInvoiceBaseResponse;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import lombok.extern.slf4j.Slf4j;

import java.io.UnsupportedEncodingException;

/**
 * @Description: 4. 发票作废 SID=4
 * 在金税卡及防伪开票数据中作废已开发票。
 * @Author: linjinyu
 * @CreateDate: 2022/4/27 7:02 下午
 * @UpdateUser: linjinyu
 * @UpdateDate: 2022/4/27 7:02 下午
 * @UpdateRemark: 修改内容
 * @Version: 1.0
 */
@Slf4j
@JsonIgnoreProperties(ignoreUnknown = true)
@SuperBuilder(toBuilder = true)
@AllArgsConstructor
@NoArgsConstructor
@Data
public class SID4ToInvalidResponseBody extends _SzhtxxPaperInvoiceBaseResponse {

    @ApiModelProperty("密文-解密-反序列化")
    private SID4ToInvalidResponseBodyEncmsgVo encmsgVo;

    public SID4ToInvalidResponseBody unPacking() {

        try {
            String jsonStr = this.base64ReplaceAndDecode(this.ENCMSG);
            log.info("\nunPacking\n{}\n{}", this.ENCMSG, jsonStr);
            encmsgVo = AnJsonUtils.toObject(jsonStr, SID4ToInvalidResponseBodyEncmsgVo.class);
        } catch (UnsupportedEncodingException unsupportedEncodingException) {
            unsupportedEncodingException.printStackTrace();
        }

        return this;
    }
}
