package com.kym.entity.admin;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.kym.entity.BaseEntity;
import com.kym.entity.typehandle.InvoiceDetailBuyerInformationTypeHandle;
import com.kym.entity.typehandle.InvoiceDetailSellerInformationTypeHandle;
import com.kym.entity.wechat.FaPiao;
import com.kym.entity.wechat.FapiaoApplications;
import com.kym.entity.wechat.InvoiceBaseInfo;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 * 发票详情表
 * </p>
 *
 * @author skyline
 * @since 2024-03-19
 */
@Getter
@Setter
@TableName(schema = "charge_admin",value = "t_invoice_detail",autoResultMap = true)
@Accessors(chain = true)
public class InvoiceDetail extends BaseEntity {

    private static final long serialVersionUID = 1L;

    /**
     * 微信发票申请id
     */
    private String applyId;

    /**
     * 开票时间
     */
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime fapiaoTime;

    /**
     * 发票状态：ISSUE_ACCEPTED-开票申请已受理，ISSUED-发票已开具，REVERSE_ACCEPTED-冲红申请已受理，REVERSED-发票已冲红
     */
    private String status;

    /**
     * 蓝票
     */
    @TableField(typeHandler = JacksonTypeHandler.class)
    private FapiaoApplications.FapiaoInfo blueFapiao;

    /**
     * 红票
     */
    @TableField(typeHandler = JacksonTypeHandler.class)
    private Object redFapiao;

    /**
     * 卡包信息
     */
    @TableField(typeHandler = JacksonTypeHandler.class)
    private Object cardInformation;

    /**
     * 总开票金额（分）
     */
    private Integer totalAmount;

    /**
     * 税额（分）
     */
    private Integer taxAmount;

    /**
     * 不含税金额（分）
     */
    private Integer amount;

    /**
     * 售卖方信息
     */
    @TableField(typeHandler = InvoiceDetailSellerInformationTypeHandle.class)
    private InvoiceBaseInfo.SellerInfo sellerInformation;

    /**
     * 购买方信息
     */
    @TableField(typeHandler = InvoiceDetailBuyerInformationTypeHandle.class)
    private FaPiao.BuyerInformation buyerInformation;

    /**
     * 扩展信息
     */
    @TableField(typeHandler = JacksonTypeHandler.class)
    private Object extraInformation;

    /**
     * 发票明细
     */
    @TableField(typeHandler = JacksonTypeHandler.class)
    private List<FapiaoApplications.FapiaoItem> items;

    /**
     * 发票 PDF 下载地址
     */
    private String invoiceUrl;

    /**
     * 发票 OFD 下载地址
     */
    private String ofdUrl;

    /**
     * 发票 XML 下载地址
     */
    private String xmlUrl;

    /**
     * 备注
     */
    private String remark;
}
