# coding: utf-8

"""
    用户全部 API 文档

    No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

    The version of the OpenAPI document: v1
    Generated by OpenAPI Generator (https://openapi-generator.tech)

    Do not edit the class manually.
"""  # noqa: E501


from __future__ import annotations
import pprint
import re  # noqa: F401
import json

from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from ZSGF.Client.models.bk_agent_resp_info import BkAgentRespInfo
from ZSGF.Client.models.charge_info import ChargeInfo
from ZSGF.Client.models.enterprise_pay_info import EnterprisePayInfo
from ZSGF.Client.models.fulfillment_detail import FulfillmentDetail
from ZSGF.Client.models.goods_detail import GoodsDetail
from ZSGF.Client.models.hb_fq_pay_info import HbFqPayInfo
from ZSGF.Client.models.intact_charge_info import IntactChargeInfo
from ZSGF.Client.models.payment_info_with_id import PaymentInfoWithId
from ZSGF.Client.models.tap_pay_info import TapPayInfo
from ZSGF.Client.models.trade_fund_bill import TradeFundBill
from ZSGF.Client.models.trade_settle_info import TradeSettleInfo
from ZSGF.Client.models.voucher_detail import VoucherDetail
from typing import Optional, Set
from typing_extensions import Self

class AlipayTradeQueryResponse(BaseModel):
    """
    AlipayTradeQueryResponse
    """ # noqa: E501
    code: Optional[StrictStr] = None
    msg: Optional[StrictStr] = None
    sub_code: Optional[StrictStr] = Field(default=None, alias="subCode")
    sub_msg: Optional[StrictStr] = Field(default=None, alias="subMsg")
    is_error: Optional[StrictBool] = Field(default=None, alias="isError")
    additional_status: Optional[StrictStr] = Field(default=None, alias="additionalStatus")
    alipay_store_id: Optional[StrictStr] = Field(default=None, alias="alipayStoreId")
    alipay_sub_merchant_id: Optional[StrictStr] = Field(default=None, alias="alipaySubMerchantId")
    async_pay_apply_status: Optional[StrictStr] = Field(default=None, alias="asyncPayApplyStatus")
    auth_trade_pay_mode: Optional[StrictStr] = Field(default=None, alias="authTradePayMode")
    biz_settle_mode: Optional[StrictStr] = Field(default=None, alias="bizSettleMode")
    bkagent_resp_info: Optional[BkAgentRespInfo] = Field(default=None, alias="bkagentRespInfo")
    body: Optional[StrictStr] = None
    buyer_logon_id: Optional[StrictStr] = Field(default=None, alias="buyerLogonId")
    buyer_open_id: Optional[StrictStr] = Field(default=None, alias="buyerOpenId")
    buyer_pay_amount: Optional[StrictStr] = Field(default=None, alias="buyerPayAmount")
    buyer_user_id: Optional[StrictStr] = Field(default=None, alias="buyerUserId")
    buyer_user_name: Optional[StrictStr] = Field(default=None, alias="buyerUserName")
    buyer_user_type: Optional[StrictStr] = Field(default=None, alias="buyerUserType")
    cashier_type: Optional[StrictStr] = Field(default=None, alias="cashierType")
    charge_amount: Optional[StrictStr] = Field(default=None, alias="chargeAmount")
    charge_flags: Optional[StrictStr] = Field(default=None, alias="chargeFlags")
    charge_info_list: Optional[List[ChargeInfo]] = Field(default=None, alias="chargeInfoList")
    credit_biz_order_id: Optional[StrictStr] = Field(default=None, alias="creditBizOrderId")
    credit_pay_mode: Optional[StrictStr] = Field(default=None, alias="creditPayMode")
    discount_amount: Optional[StrictStr] = Field(default=None, alias="discountAmount")
    discount_goods_detail: Optional[StrictStr] = Field(default=None, alias="discountGoodsDetail")
    enterprise_pay_info: Optional[EnterprisePayInfo] = Field(default=None, alias="enterprisePayInfo")
    ext_infos: Optional[StrictStr] = Field(default=None, alias="extInfos")
    fulfillment_detail_list: Optional[List[FulfillmentDetail]] = Field(default=None, alias="fulfillmentDetailList")
    fund_bill_list: Optional[List[TradeFundBill]] = Field(default=None, alias="fundBillList")
    hb_fq_pay_info: Optional[HbFqPayInfo] = Field(default=None, alias="hbFqPayInfo")
    hyb_amount: Optional[StrictStr] = Field(default=None, alias="hybAmount")
    industry_sepc_detail: Optional[StrictStr] = Field(default=None, alias="industrySepcDetail")
    industry_sepc_detail_acc: Optional[StrictStr] = Field(default=None, alias="industrySepcDetailAcc")
    industry_sepc_detail_gov: Optional[StrictStr] = Field(default=None, alias="industrySepcDetailGov")
    intact_charge_info_list: Optional[List[IntactChargeInfo]] = Field(default=None, alias="intactChargeInfoList")
    invoice_amount: Optional[StrictStr] = Field(default=None, alias="invoiceAmount")
    mdiscount_amount: Optional[StrictStr] = Field(default=None, alias="mdiscountAmount")
    medical_insurance_info: Optional[StrictStr] = Field(default=None, alias="medicalInsuranceInfo")
    open_id: Optional[StrictStr] = Field(default=None, alias="openId")
    out_trade_no: Optional[StrictStr] = Field(default=None, alias="outTradeNo")
    passback_params: Optional[StrictStr] = Field(default=None, alias="passbackParams")
    pay_amount: Optional[StrictStr] = Field(default=None, alias="payAmount")
    pay_currency: Optional[StrictStr] = Field(default=None, alias="payCurrency")
    payment_info_with_id_list: Optional[List[PaymentInfoWithId]] = Field(default=None, alias="paymentInfoWithIdList")
    period_scene: Optional[StrictStr] = Field(default=None, alias="periodScene")
    point_amount: Optional[StrictStr] = Field(default=None, alias="pointAmount")
    pre_auth_pay_amount: Optional[StrictStr] = Field(default=None, alias="preAuthPayAmount")
    receipt_amount: Optional[StrictStr] = Field(default=None, alias="receiptAmount")
    receipt_currency_type: Optional[StrictStr] = Field(default=None, alias="receiptCurrencyType")
    req_goods_detail: Optional[List[GoodsDetail]] = Field(default=None, alias="reqGoodsDetail")
    send_pay_date: Optional[StrictStr] = Field(default=None, alias="sendPayDate")
    settle_amount: Optional[StrictStr] = Field(default=None, alias="settleAmount")
    settle_currency: Optional[StrictStr] = Field(default=None, alias="settleCurrency")
    settle_trans_rate: Optional[StrictStr] = Field(default=None, alias="settleTransRate")
    settlement_id: Optional[StrictStr] = Field(default=None, alias="settlementId")
    store_id: Optional[StrictStr] = Field(default=None, alias="storeId")
    store_name: Optional[StrictStr] = Field(default=None, alias="storeName")
    subject: Optional[StrictStr] = None
    tap_pay_info: Optional[TapPayInfo] = Field(default=None, alias="tapPayInfo")
    terminal_id: Optional[StrictStr] = Field(default=None, alias="terminalId")
    total_amount: Optional[StrictStr] = Field(default=None, alias="totalAmount")
    trade_no: Optional[StrictStr] = Field(default=None, alias="tradeNo")
    trade_settle_info: Optional[TradeSettleInfo] = Field(default=None, alias="tradeSettleInfo")
    trade_status: Optional[StrictStr] = Field(default=None, alias="tradeStatus")
    trans_currency: Optional[StrictStr] = Field(default=None, alias="transCurrency")
    trans_pay_rate: Optional[StrictStr] = Field(default=None, alias="transPayRate")
    voucher_detail_list: Optional[List[VoucherDetail]] = Field(default=None, alias="voucherDetailList")
    __properties: ClassVar[List[str]] = ["code", "msg", "subCode", "subMsg", "isError", "additionalStatus", "alipayStoreId", "alipaySubMerchantId", "asyncPayApplyStatus", "authTradePayMode", "bizSettleMode", "bkagentRespInfo", "body", "buyerLogonId", "buyerOpenId", "buyerPayAmount", "buyerUserId", "buyerUserName", "buyerUserType", "cashierType", "chargeAmount", "chargeFlags", "chargeInfoList", "creditBizOrderId", "creditPayMode", "discountAmount", "discountGoodsDetail", "enterprisePayInfo", "extInfos", "fulfillmentDetailList", "fundBillList", "hbFqPayInfo", "hybAmount", "industrySepcDetail", "industrySepcDetailAcc", "industrySepcDetailGov", "intactChargeInfoList", "invoiceAmount", "mdiscountAmount", "medicalInsuranceInfo", "openId", "outTradeNo", "passbackParams", "payAmount", "payCurrency", "paymentInfoWithIdList", "periodScene", "pointAmount", "preAuthPayAmount", "receiptAmount", "receiptCurrencyType", "reqGoodsDetail", "sendPayDate", "settleAmount", "settleCurrency", "settleTransRate", "settlementId", "storeId", "storeName", "subject", "tapPayInfo", "terminalId", "totalAmount", "tradeNo", "tradeSettleInfo", "tradeStatus", "transCurrency", "transPayRate", "voucherDetailList"]

    model_config = ConfigDict(
        populate_by_name=True,
        validate_assignment=True,
        protected_namespaces=(),
    )


    def to_str(self) -> str:
        """Returns the string representation of the model using alias"""
        return pprint.pformat(self.model_dump(by_alias=True))

    def to_json(self) -> str:
        """Returns the JSON representation of the model using alias"""
        # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
        return json.dumps(self.to_dict())

    @classmethod
    def from_json(cls, json_str: str) -> Optional[Self]:
        """Create an instance of AlipayTradeQueryResponse from a JSON string"""
        return cls.from_dict(json.loads(json_str))

    def to_dict(self) -> Dict[str, Any]:
        """Return the dictionary representation of the model using alias.

        This has the following differences from calling pydantic's
        `self.model_dump(by_alias=True)`:

        * `None` is only added to the output dict for nullable fields that
          were set at model initialization. Other fields with value `None`
          are ignored.
        * OpenAPI `readOnly` fields are excluded.
        """
        excluded_fields: Set[str] = set([
            "is_error",
        ])

        _dict = self.model_dump(
            by_alias=True,
            exclude=excluded_fields,
            exclude_none=True,
        )
        # override the default output from pydantic by calling `to_dict()` of bkagent_resp_info
        if self.bkagent_resp_info:
            _dict['bkagentRespInfo'] = self.bkagent_resp_info.to_dict()
        # override the default output from pydantic by calling `to_dict()` of each item in charge_info_list (list)
        _items = []
        if self.charge_info_list:
            for _item_charge_info_list in self.charge_info_list:
                if _item_charge_info_list:
                    _items.append(_item_charge_info_list.to_dict())
            _dict['chargeInfoList'] = _items
        # override the default output from pydantic by calling `to_dict()` of enterprise_pay_info
        if self.enterprise_pay_info:
            _dict['enterprisePayInfo'] = self.enterprise_pay_info.to_dict()
        # override the default output from pydantic by calling `to_dict()` of each item in fulfillment_detail_list (list)
        _items = []
        if self.fulfillment_detail_list:
            for _item_fulfillment_detail_list in self.fulfillment_detail_list:
                if _item_fulfillment_detail_list:
                    _items.append(_item_fulfillment_detail_list.to_dict())
            _dict['fulfillmentDetailList'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in fund_bill_list (list)
        _items = []
        if self.fund_bill_list:
            for _item_fund_bill_list in self.fund_bill_list:
                if _item_fund_bill_list:
                    _items.append(_item_fund_bill_list.to_dict())
            _dict['fundBillList'] = _items
        # override the default output from pydantic by calling `to_dict()` of hb_fq_pay_info
        if self.hb_fq_pay_info:
            _dict['hbFqPayInfo'] = self.hb_fq_pay_info.to_dict()
        # override the default output from pydantic by calling `to_dict()` of each item in intact_charge_info_list (list)
        _items = []
        if self.intact_charge_info_list:
            for _item_intact_charge_info_list in self.intact_charge_info_list:
                if _item_intact_charge_info_list:
                    _items.append(_item_intact_charge_info_list.to_dict())
            _dict['intactChargeInfoList'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in payment_info_with_id_list (list)
        _items = []
        if self.payment_info_with_id_list:
            for _item_payment_info_with_id_list in self.payment_info_with_id_list:
                if _item_payment_info_with_id_list:
                    _items.append(_item_payment_info_with_id_list.to_dict())
            _dict['paymentInfoWithIdList'] = _items
        # override the default output from pydantic by calling `to_dict()` of each item in req_goods_detail (list)
        _items = []
        if self.req_goods_detail:
            for _item_req_goods_detail in self.req_goods_detail:
                if _item_req_goods_detail:
                    _items.append(_item_req_goods_detail.to_dict())
            _dict['reqGoodsDetail'] = _items
        # override the default output from pydantic by calling `to_dict()` of tap_pay_info
        if self.tap_pay_info:
            _dict['tapPayInfo'] = self.tap_pay_info.to_dict()
        # override the default output from pydantic by calling `to_dict()` of trade_settle_info
        if self.trade_settle_info:
            _dict['tradeSettleInfo'] = self.trade_settle_info.to_dict()
        # override the default output from pydantic by calling `to_dict()` of each item in voucher_detail_list (list)
        _items = []
        if self.voucher_detail_list:
            for _item_voucher_detail_list in self.voucher_detail_list:
                if _item_voucher_detail_list:
                    _items.append(_item_voucher_detail_list.to_dict())
            _dict['voucherDetailList'] = _items
        # set to None if code (nullable) is None
        # and model_fields_set contains the field
        if self.code is None and "code" in self.model_fields_set:
            _dict['code'] = None

        # set to None if msg (nullable) is None
        # and model_fields_set contains the field
        if self.msg is None and "msg" in self.model_fields_set:
            _dict['msg'] = None

        # set to None if sub_code (nullable) is None
        # and model_fields_set contains the field
        if self.sub_code is None and "sub_code" in self.model_fields_set:
            _dict['subCode'] = None

        # set to None if sub_msg (nullable) is None
        # and model_fields_set contains the field
        if self.sub_msg is None and "sub_msg" in self.model_fields_set:
            _dict['subMsg'] = None

        # set to None if additional_status (nullable) is None
        # and model_fields_set contains the field
        if self.additional_status is None and "additional_status" in self.model_fields_set:
            _dict['additionalStatus'] = None

        # set to None if alipay_store_id (nullable) is None
        # and model_fields_set contains the field
        if self.alipay_store_id is None and "alipay_store_id" in self.model_fields_set:
            _dict['alipayStoreId'] = None

        # set to None if alipay_sub_merchant_id (nullable) is None
        # and model_fields_set contains the field
        if self.alipay_sub_merchant_id is None and "alipay_sub_merchant_id" in self.model_fields_set:
            _dict['alipaySubMerchantId'] = None

        # set to None if async_pay_apply_status (nullable) is None
        # and model_fields_set contains the field
        if self.async_pay_apply_status is None and "async_pay_apply_status" in self.model_fields_set:
            _dict['asyncPayApplyStatus'] = None

        # set to None if auth_trade_pay_mode (nullable) is None
        # and model_fields_set contains the field
        if self.auth_trade_pay_mode is None and "auth_trade_pay_mode" in self.model_fields_set:
            _dict['authTradePayMode'] = None

        # set to None if biz_settle_mode (nullable) is None
        # and model_fields_set contains the field
        if self.biz_settle_mode is None and "biz_settle_mode" in self.model_fields_set:
            _dict['bizSettleMode'] = None

        # set to None if body (nullable) is None
        # and model_fields_set contains the field
        if self.body is None and "body" in self.model_fields_set:
            _dict['body'] = None

        # set to None if buyer_logon_id (nullable) is None
        # and model_fields_set contains the field
        if self.buyer_logon_id is None and "buyer_logon_id" in self.model_fields_set:
            _dict['buyerLogonId'] = None

        # set to None if buyer_open_id (nullable) is None
        # and model_fields_set contains the field
        if self.buyer_open_id is None and "buyer_open_id" in self.model_fields_set:
            _dict['buyerOpenId'] = None

        # set to None if buyer_pay_amount (nullable) is None
        # and model_fields_set contains the field
        if self.buyer_pay_amount is None and "buyer_pay_amount" in self.model_fields_set:
            _dict['buyerPayAmount'] = None

        # set to None if buyer_user_id (nullable) is None
        # and model_fields_set contains the field
        if self.buyer_user_id is None and "buyer_user_id" in self.model_fields_set:
            _dict['buyerUserId'] = None

        # set to None if buyer_user_name (nullable) is None
        # and model_fields_set contains the field
        if self.buyer_user_name is None and "buyer_user_name" in self.model_fields_set:
            _dict['buyerUserName'] = None

        # set to None if buyer_user_type (nullable) is None
        # and model_fields_set contains the field
        if self.buyer_user_type is None and "buyer_user_type" in self.model_fields_set:
            _dict['buyerUserType'] = None

        # set to None if cashier_type (nullable) is None
        # and model_fields_set contains the field
        if self.cashier_type is None and "cashier_type" in self.model_fields_set:
            _dict['cashierType'] = None

        # set to None if charge_amount (nullable) is None
        # and model_fields_set contains the field
        if self.charge_amount is None and "charge_amount" in self.model_fields_set:
            _dict['chargeAmount'] = None

        # set to None if charge_flags (nullable) is None
        # and model_fields_set contains the field
        if self.charge_flags is None and "charge_flags" in self.model_fields_set:
            _dict['chargeFlags'] = None

        # set to None if charge_info_list (nullable) is None
        # and model_fields_set contains the field
        if self.charge_info_list is None and "charge_info_list" in self.model_fields_set:
            _dict['chargeInfoList'] = None

        # set to None if credit_biz_order_id (nullable) is None
        # and model_fields_set contains the field
        if self.credit_biz_order_id is None and "credit_biz_order_id" in self.model_fields_set:
            _dict['creditBizOrderId'] = None

        # set to None if credit_pay_mode (nullable) is None
        # and model_fields_set contains the field
        if self.credit_pay_mode is None and "credit_pay_mode" in self.model_fields_set:
            _dict['creditPayMode'] = None

        # set to None if discount_amount (nullable) is None
        # and model_fields_set contains the field
        if self.discount_amount is None and "discount_amount" in self.model_fields_set:
            _dict['discountAmount'] = None

        # set to None if discount_goods_detail (nullable) is None
        # and model_fields_set contains the field
        if self.discount_goods_detail is None and "discount_goods_detail" in self.model_fields_set:
            _dict['discountGoodsDetail'] = None

        # set to None if ext_infos (nullable) is None
        # and model_fields_set contains the field
        if self.ext_infos is None and "ext_infos" in self.model_fields_set:
            _dict['extInfos'] = None

        # set to None if fulfillment_detail_list (nullable) is None
        # and model_fields_set contains the field
        if self.fulfillment_detail_list is None and "fulfillment_detail_list" in self.model_fields_set:
            _dict['fulfillmentDetailList'] = None

        # set to None if fund_bill_list (nullable) is None
        # and model_fields_set contains the field
        if self.fund_bill_list is None and "fund_bill_list" in self.model_fields_set:
            _dict['fundBillList'] = None

        # set to None if hyb_amount (nullable) is None
        # and model_fields_set contains the field
        if self.hyb_amount is None and "hyb_amount" in self.model_fields_set:
            _dict['hybAmount'] = None

        # set to None if industry_sepc_detail (nullable) is None
        # and model_fields_set contains the field
        if self.industry_sepc_detail is None and "industry_sepc_detail" in self.model_fields_set:
            _dict['industrySepcDetail'] = None

        # set to None if industry_sepc_detail_acc (nullable) is None
        # and model_fields_set contains the field
        if self.industry_sepc_detail_acc is None and "industry_sepc_detail_acc" in self.model_fields_set:
            _dict['industrySepcDetailAcc'] = None

        # set to None if industry_sepc_detail_gov (nullable) is None
        # and model_fields_set contains the field
        if self.industry_sepc_detail_gov is None and "industry_sepc_detail_gov" in self.model_fields_set:
            _dict['industrySepcDetailGov'] = None

        # set to None if intact_charge_info_list (nullable) is None
        # and model_fields_set contains the field
        if self.intact_charge_info_list is None and "intact_charge_info_list" in self.model_fields_set:
            _dict['intactChargeInfoList'] = None

        # set to None if invoice_amount (nullable) is None
        # and model_fields_set contains the field
        if self.invoice_amount is None and "invoice_amount" in self.model_fields_set:
            _dict['invoiceAmount'] = None

        # set to None if mdiscount_amount (nullable) is None
        # and model_fields_set contains the field
        if self.mdiscount_amount is None and "mdiscount_amount" in self.model_fields_set:
            _dict['mdiscountAmount'] = None

        # set to None if medical_insurance_info (nullable) is None
        # and model_fields_set contains the field
        if self.medical_insurance_info is None and "medical_insurance_info" in self.model_fields_set:
            _dict['medicalInsuranceInfo'] = None

        # set to None if open_id (nullable) is None
        # and model_fields_set contains the field
        if self.open_id is None and "open_id" in self.model_fields_set:
            _dict['openId'] = None

        # set to None if out_trade_no (nullable) is None
        # and model_fields_set contains the field
        if self.out_trade_no is None and "out_trade_no" in self.model_fields_set:
            _dict['outTradeNo'] = None

        # set to None if passback_params (nullable) is None
        # and model_fields_set contains the field
        if self.passback_params is None and "passback_params" in self.model_fields_set:
            _dict['passbackParams'] = None

        # set to None if pay_amount (nullable) is None
        # and model_fields_set contains the field
        if self.pay_amount is None and "pay_amount" in self.model_fields_set:
            _dict['payAmount'] = None

        # set to None if pay_currency (nullable) is None
        # and model_fields_set contains the field
        if self.pay_currency is None and "pay_currency" in self.model_fields_set:
            _dict['payCurrency'] = None

        # set to None if payment_info_with_id_list (nullable) is None
        # and model_fields_set contains the field
        if self.payment_info_with_id_list is None and "payment_info_with_id_list" in self.model_fields_set:
            _dict['paymentInfoWithIdList'] = None

        # set to None if period_scene (nullable) is None
        # and model_fields_set contains the field
        if self.period_scene is None and "period_scene" in self.model_fields_set:
            _dict['periodScene'] = None

        # set to None if point_amount (nullable) is None
        # and model_fields_set contains the field
        if self.point_amount is None and "point_amount" in self.model_fields_set:
            _dict['pointAmount'] = None

        # set to None if pre_auth_pay_amount (nullable) is None
        # and model_fields_set contains the field
        if self.pre_auth_pay_amount is None and "pre_auth_pay_amount" in self.model_fields_set:
            _dict['preAuthPayAmount'] = None

        # set to None if receipt_amount (nullable) is None
        # and model_fields_set contains the field
        if self.receipt_amount is None and "receipt_amount" in self.model_fields_set:
            _dict['receiptAmount'] = None

        # set to None if receipt_currency_type (nullable) is None
        # and model_fields_set contains the field
        if self.receipt_currency_type is None and "receipt_currency_type" in self.model_fields_set:
            _dict['receiptCurrencyType'] = None

        # set to None if req_goods_detail (nullable) is None
        # and model_fields_set contains the field
        if self.req_goods_detail is None and "req_goods_detail" in self.model_fields_set:
            _dict['reqGoodsDetail'] = None

        # set to None if send_pay_date (nullable) is None
        # and model_fields_set contains the field
        if self.send_pay_date is None and "send_pay_date" in self.model_fields_set:
            _dict['sendPayDate'] = None

        # set to None if settle_amount (nullable) is None
        # and model_fields_set contains the field
        if self.settle_amount is None and "settle_amount" in self.model_fields_set:
            _dict['settleAmount'] = None

        # set to None if settle_currency (nullable) is None
        # and model_fields_set contains the field
        if self.settle_currency is None and "settle_currency" in self.model_fields_set:
            _dict['settleCurrency'] = None

        # set to None if settle_trans_rate (nullable) is None
        # and model_fields_set contains the field
        if self.settle_trans_rate is None and "settle_trans_rate" in self.model_fields_set:
            _dict['settleTransRate'] = None

        # set to None if settlement_id (nullable) is None
        # and model_fields_set contains the field
        if self.settlement_id is None and "settlement_id" in self.model_fields_set:
            _dict['settlementId'] = None

        # set to None if store_id (nullable) is None
        # and model_fields_set contains the field
        if self.store_id is None and "store_id" in self.model_fields_set:
            _dict['storeId'] = None

        # set to None if store_name (nullable) is None
        # and model_fields_set contains the field
        if self.store_name is None and "store_name" in self.model_fields_set:
            _dict['storeName'] = None

        # set to None if subject (nullable) is None
        # and model_fields_set contains the field
        if self.subject is None and "subject" in self.model_fields_set:
            _dict['subject'] = None

        # set to None if terminal_id (nullable) is None
        # and model_fields_set contains the field
        if self.terminal_id is None and "terminal_id" in self.model_fields_set:
            _dict['terminalId'] = None

        # set to None if total_amount (nullable) is None
        # and model_fields_set contains the field
        if self.total_amount is None and "total_amount" in self.model_fields_set:
            _dict['totalAmount'] = None

        # set to None if trade_no (nullable) is None
        # and model_fields_set contains the field
        if self.trade_no is None and "trade_no" in self.model_fields_set:
            _dict['tradeNo'] = None

        # set to None if trade_status (nullable) is None
        # and model_fields_set contains the field
        if self.trade_status is None and "trade_status" in self.model_fields_set:
            _dict['tradeStatus'] = None

        # set to None if trans_currency (nullable) is None
        # and model_fields_set contains the field
        if self.trans_currency is None and "trans_currency" in self.model_fields_set:
            _dict['transCurrency'] = None

        # set to None if trans_pay_rate (nullable) is None
        # and model_fields_set contains the field
        if self.trans_pay_rate is None and "trans_pay_rate" in self.model_fields_set:
            _dict['transPayRate'] = None

        # set to None if voucher_detail_list (nullable) is None
        # and model_fields_set contains the field
        if self.voucher_detail_list is None and "voucher_detail_list" in self.model_fields_set:
            _dict['voucherDetailList'] = None

        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of AlipayTradeQueryResponse from a dict"""
        if obj is None:
            return None

        if not isinstance(obj, dict):
            return cls.model_validate(obj)

        _obj = cls.model_validate({
            "code": obj.get("code"),
            "msg": obj.get("msg"),
            "subCode": obj.get("subCode"),
            "subMsg": obj.get("subMsg"),
            "isError": obj.get("isError"),
            "additionalStatus": obj.get("additionalStatus"),
            "alipayStoreId": obj.get("alipayStoreId"),
            "alipaySubMerchantId": obj.get("alipaySubMerchantId"),
            "asyncPayApplyStatus": obj.get("asyncPayApplyStatus"),
            "authTradePayMode": obj.get("authTradePayMode"),
            "bizSettleMode": obj.get("bizSettleMode"),
            "bkagentRespInfo": BkAgentRespInfo.from_dict(obj["bkagentRespInfo"]) if obj.get("bkagentRespInfo") is not None else None,
            "body": obj.get("body"),
            "buyerLogonId": obj.get("buyerLogonId"),
            "buyerOpenId": obj.get("buyerOpenId"),
            "buyerPayAmount": obj.get("buyerPayAmount"),
            "buyerUserId": obj.get("buyerUserId"),
            "buyerUserName": obj.get("buyerUserName"),
            "buyerUserType": obj.get("buyerUserType"),
            "cashierType": obj.get("cashierType"),
            "chargeAmount": obj.get("chargeAmount"),
            "chargeFlags": obj.get("chargeFlags"),
            "chargeInfoList": [ChargeInfo.from_dict(_item) for _item in obj["chargeInfoList"]] if obj.get("chargeInfoList") is not None else None,
            "creditBizOrderId": obj.get("creditBizOrderId"),
            "creditPayMode": obj.get("creditPayMode"),
            "discountAmount": obj.get("discountAmount"),
            "discountGoodsDetail": obj.get("discountGoodsDetail"),
            "enterprisePayInfo": EnterprisePayInfo.from_dict(obj["enterprisePayInfo"]) if obj.get("enterprisePayInfo") is not None else None,
            "extInfos": obj.get("extInfos"),
            "fulfillmentDetailList": [FulfillmentDetail.from_dict(_item) for _item in obj["fulfillmentDetailList"]] if obj.get("fulfillmentDetailList") is not None else None,
            "fundBillList": [TradeFundBill.from_dict(_item) for _item in obj["fundBillList"]] if obj.get("fundBillList") is not None else None,
            "hbFqPayInfo": HbFqPayInfo.from_dict(obj["hbFqPayInfo"]) if obj.get("hbFqPayInfo") is not None else None,
            "hybAmount": obj.get("hybAmount"),
            "industrySepcDetail": obj.get("industrySepcDetail"),
            "industrySepcDetailAcc": obj.get("industrySepcDetailAcc"),
            "industrySepcDetailGov": obj.get("industrySepcDetailGov"),
            "intactChargeInfoList": [IntactChargeInfo.from_dict(_item) for _item in obj["intactChargeInfoList"]] if obj.get("intactChargeInfoList") is not None else None,
            "invoiceAmount": obj.get("invoiceAmount"),
            "mdiscountAmount": obj.get("mdiscountAmount"),
            "medicalInsuranceInfo": obj.get("medicalInsuranceInfo"),
            "openId": obj.get("openId"),
            "outTradeNo": obj.get("outTradeNo"),
            "passbackParams": obj.get("passbackParams"),
            "payAmount": obj.get("payAmount"),
            "payCurrency": obj.get("payCurrency"),
            "paymentInfoWithIdList": [PaymentInfoWithId.from_dict(_item) for _item in obj["paymentInfoWithIdList"]] if obj.get("paymentInfoWithIdList") is not None else None,
            "periodScene": obj.get("periodScene"),
            "pointAmount": obj.get("pointAmount"),
            "preAuthPayAmount": obj.get("preAuthPayAmount"),
            "receiptAmount": obj.get("receiptAmount"),
            "receiptCurrencyType": obj.get("receiptCurrencyType"),
            "reqGoodsDetail": [GoodsDetail.from_dict(_item) for _item in obj["reqGoodsDetail"]] if obj.get("reqGoodsDetail") is not None else None,
            "sendPayDate": obj.get("sendPayDate"),
            "settleAmount": obj.get("settleAmount"),
            "settleCurrency": obj.get("settleCurrency"),
            "settleTransRate": obj.get("settleTransRate"),
            "settlementId": obj.get("settlementId"),
            "storeId": obj.get("storeId"),
            "storeName": obj.get("storeName"),
            "subject": obj.get("subject"),
            "tapPayInfo": TapPayInfo.from_dict(obj["tapPayInfo"]) if obj.get("tapPayInfo") is not None else None,
            "terminalId": obj.get("terminalId"),
            "totalAmount": obj.get("totalAmount"),
            "tradeNo": obj.get("tradeNo"),
            "tradeSettleInfo": TradeSettleInfo.from_dict(obj["tradeSettleInfo"]) if obj.get("tradeSettleInfo") is not None else None,
            "tradeStatus": obj.get("tradeStatus"),
            "transCurrency": obj.get("transCurrency"),
            "transPayRate": obj.get("transPayRate"),
            "voucherDetailList": [VoucherDetail.from_dict(_item) for _item in obj["voucherDetailList"]] if obj.get("voucherDetailList") is not None else None
        })
        return _obj


