package com.muchinfo.mtp3pojos.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

/**
 * <p>
 * 交易委托单表 - 导历史
 * </p>
 *
 * @author XKF
 * @since 2024-07-02
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("TRADE_ORDERDETAIL")
@ApiModel(value="TradeOrderdetail对象", description="交易委托单表 - 导历史")
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class TradeOrderdetail extends Model<TradeOrderdetail> {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "委托单号(100+Unix秒时间戳(10位)+2位(MarketServiceID)+xxxx)")
      @TableId(value = "ORDERID")
    private Long orderid;

    @ApiModelProperty(value = "交易日(yyyyMMdd)")
    @TableField("TRADEDATE")
    private String tradedate;

    @ApiModelProperty(value = "委托单据类型 - 1:建仓 2:平仓 3:先平后建")
    @TableField("BUILDTYPE")
    private Integer buildtype;

    @ApiModelProperty(value = "关联预埋单号(止盈止损单时填写)")
    @TableField("PREORDERID")
    private Long preorderid;

    @ApiModelProperty(value = "撤单单号(撤单时填写)")
    @TableField("CANCELORDERID")
    private Long cancelorderid;

    @ApiModelProperty(value = "关联单号(交割单)")
    @TableField("RELATEDID")
    private Long relatedid;

    @ApiModelProperty(value = "市场ID")
    @TableField("MARKETID")
    private Long marketid;

    @ApiModelProperty(value = "商品ID")
    @TableField("GOODSID")
    private Long goodsid;

    @ApiModelProperty(value = "账户ID[报价币种]")
    @TableField("ACCOUNTID")
    private Long accountid;

    @ApiModelProperty(value = "所属会员UserID")
    @TableField("MEMBERUSERID")
    private Long memberuserid;

    @ApiModelProperty(value = "买卖 - 0:买 1:卖 ")
    @TableField("BUYORSELL")
    private Integer buyorsell;

    @ApiModelProperty(value = "取价方式 - 1:市价 2: 限价 3:浮动价")
    @TableField("PRICEMODE")
    private Integer pricemode;

    @ApiModelProperty(value = "委托价格")
    @TableField("ORDERPRICE")
    private BigDecimal orderprice;

    @ApiModelProperty(value = "市价最大偏移范围 [浮动价 - 点差]")
    @TableField("MARKETMAXSUB")
    private BigDecimal marketmaxsub;

    @ApiModelProperty(value = "委托数量")
    @TableField("ORDERQTY")
    private Long orderqty;

    @ApiModelProperty(value = "成交数量")
    @TableField("TRADEQTY")
    private Long tradeqty;

    @ApiModelProperty(value = "撤单数量")
    @TableField("CANCELQTY")
    private Long cancelqty;

    @ApiModelProperty(value = "开仓数量(先建后平操作,需要记录)")
    @TableField("OPENQTY")
    private Long openqty;

    @ApiModelProperty(value = "平仓数量(先建后平操作 需要记录)")
    @TableField("CLOSEQTY")
    private Long closeqty;

    @ApiModelProperty(value = "开仓成交数量(先建后平操作,需要记录)")
    @TableField("OPENTRADEQTY")
    private Long opentradeqty;

    @ApiModelProperty(value = "平仓成交数量(先建后平操作,需要记录)")
    @TableField("CLOSETRADEQTY")
    private Long closetradeqty;

    @ApiModelProperty(value = "冻结保证金(冻结交易金额)")
    @TableField("FREEZEMARGIN")
    private BigDecimal freezemargin;

    @ApiModelProperty(value = "解冻保证金")
    @TableField("UNFREEZEMARGIN")
    private BigDecimal unfreezemargin;

    @ApiModelProperty(value = "冻结手续费")
    @TableField("FREEZECHARGE")
    private BigDecimal freezecharge;

    @ApiModelProperty(value = "解冻手续费")
    @TableField("UNFREEZECHARGE")
    private BigDecimal unfreezecharge;

    @ApiModelProperty(value = "开仓冻结手续费(先建后平操作,需要记录)")
    @TableField("OPENFREEZECHARGE")
    private BigDecimal openfreezecharge;

    @ApiModelProperty(value = "平仓冻结手续费(先建后平操作,需要记录)")
    @TableField("CLOSEFREEZECHARGE")
    private BigDecimal closefreezecharge;

    @ApiModelProperty(value = "开仓解冻手续费(先建后平操作,需要记录)")
    @TableField("OPENUNFREEZECHARGE")
    private BigDecimal openunfreezecharge;

    @ApiModelProperty(value = "平仓解冻手续费(先建后平操作,需要记录)")
    @TableField("CLOSEUNFREEZECHARGE")
    private BigDecimal closeunfreezecharge;

    @ApiModelProperty(value = "有效类型 - 1当日有效 2本周有效 3指定日期有效 4一直有效 5指定时间有效")
    @TableField("VALIDTYPE")
    private Integer validtype;

    @ApiModelProperty(value = "有效期限 ")
    @TableField("VALIDTIME")
    private Date validtime;

    @ApiModelProperty(value = "当时间有效类型为 “立即执行否则取消 IOC” 时，需要此项 - 0:任意量  1:最小量（暂时不支持） 2:全部量")
    @TableField("VOLUMETYPE")
    private Integer volumetype;

    @ApiModelProperty(value = "操作类型 - 1:正常下单 2:斩仓 3:转单 4:结算撤单 5:系统卖出(适用于先平后建的卖出) 6:行情源报价 7:（结算)到期强平 8:（结算)协议转让 9:系统对冲单 10:（结算)到期无效 11:交割协议转让 12:交割协议平仓 13:交割成交(所有权) 14:管理端强行平仓 15:管理端协议转让 ... 23:融资买入 --枚举“orderoperatetype")
    @TableField("OPERATETYPE")
    private Integer operatetype;

    @ApiModelProperty(value = "委托时间")
    @TableField("ORDERTIME")
    private Date ordertime;

    @ApiModelProperty(value = "委托来源 -  1:客户端 2:管理端 3:风控服务 4:交割服务 5:交易服务 6:交易日结 7:商品强平 8:管理端商品退市强平 9:交易接口 10:交割服务商被动(受托竞价) 11:预埋触发")
    @TableField("ORDERSRC")
    private Integer ordersrc;

    @ApiModelProperty(value = "委托状态 - 参考枚举'orderstatus' - 1:委托请求  2:待冻结  3:委托成功  4:委托失败  5:配对成功  6:已撤  7:部成  8:已成  9:部成部撤  10:成交失败  11:委托拒绝  12:经过摘牌(先摘后挂专用)  13:冻结成功(通道交易专用)  14:通道已撤  15:通道部成部撤  16:成交失败违约(荷兰式竞拍专用)  17:冻结PD成功  18:冻结PD失败  19:冻结能量成功  20:冻结能量失败  21:预约已报价  22:过期未付  23:优惠券处理中  24:仓单生成失败  25:首付扣款失败  26:履约失败  27:撤单解冻贷款失败")
    @TableField("ORDERSTATUS")
    private Integer orderstatus;

    @ApiModelProperty(value = "登录账号(LoginID)")
    @TableField("OPERATORID")
    private Long operatorid;

    @ApiModelProperty(value = "更新时间")
    @TableField("UPDATETIME")
    private Date updatetime;

    @ApiModelProperty(value = "客户端委托时间")
    @TableField("CLIENTORDERTIME")
    private Date clientordertime;

    @ApiModelProperty(value = "客户端流水号")
    @TableField("CLIENTTICKET")
    private String clientticket;

    @ApiModelProperty(value = "发起端唯一id")
    @TableField("UUID")
    private String uuid;

    @ApiModelProperty(value = "客户端类型 - 0:保留为未填终端类型 1:PC管理端 2:PC交易端 3:手机客户端_安卓 4:网页客户端 5:微信客户端 6:手机客户端_苹果 7:网上开户客户端 8:无效终端编号 9:报价终端(中江) ")
    @TableField("CLIENTTYPE")
    private Integer clienttype;

    @ApiModelProperty(value = "错误代码")
    @TableField("RETCODE")
    private Long retcode;

    @ApiModelProperty(value = "交易属性")
    @TableField("TRADEPROPERTY")
    private Integer tradeproperty;

    @ApiModelProperty(value = "挂牌点选类型 - 1:挂牌 2:摘牌 3:先摘后挂")
    @TableField("LISTINGSELECTTYPE")
    private Integer listingselecttype;

    @ApiModelProperty(value = "摘牌类型 - 1:价格最优 2:点选成交")
    @TableField("DELISTINGTYPE")
    private Integer delistingtype;

    @ApiModelProperty(value = "保证金收取方式  1：比率  2：固定")
    @TableField("MARGINALGORITHM")
    private Integer marginalgorithm;

    @ApiModelProperty(value = "即市保证金设置值")
    @TableField("MARGINVALUE")
    private BigDecimal marginvalue;

    @ApiModelProperty(value = "建仓手续费收取方式  1：比率  2：固定")
    @TableField("OPENFEEALGORITHM")
    private Integer openfeealgorithm;

    @ApiModelProperty(value = "建仓会员手续费设置值")
    @TableField("OPENMEMBERCHARGEVALUE")
    private BigDecimal openmemberchargevalue;

    @ApiModelProperty(value = "建仓交易所手续费设置值")
    @TableField("OPENEXCHAGECHARGEVALUE")
    private BigDecimal openexchagechargevalue;

    @ApiModelProperty(value = "平仓手续费收取方式 1：比率  2：固定")
    @TableField("CLOSEFEEALGORITHM")
    private Integer closefeealgorithm;

    @ApiModelProperty(value = "平仓会员手续费设置值")
    @TableField("CLOSEMEMBERCHARGEVALUE")
    private BigDecimal closememberchargevalue;

    @ApiModelProperty(value = "平仓交易所手续费设置值")
    @TableField("CLOSEEXCHAGECHARGEVALUE")
    private BigDecimal closeexchagechargevalue;

    @ApiModelProperty(value = "期权类型 - 1:认购(看涨) 2:认沽(看跌) ")
    @TableField("OPTIONTYPE")
    private Integer optiontype;

    @ApiModelProperty(value = "权利金")
    @TableField("PREMIUM")
    private BigDecimal premium;

    @ApiModelProperty(value = "是否预申报- 0:否 1:是")
    @TableField("ISPREEXERCISE")
    private Integer ispreexercise;

    @ApiModelProperty(value = "预申报价格")
    @TableField("PREEXERCISEPRICE")
    private BigDecimal preexerciseprice;

    @ApiModelProperty(value = "是否确认行权- 0:否 1:是")
    @TableField("ISCONFIRMEXERCISE")
    private Integer isconfirmexercise;

    @ApiModelProperty(value = "报价单ID")
    @TableField("QUOTEID")
    private Long quoteid;

    @ApiModelProperty(value = "账户ID[合约币种]")
    @TableField("GCACCOUNTID")
    private Long gcaccountid;

    @ApiModelProperty(value = "会话ID")
    @TableField("SESSIONID")
    private Long sessionid;

    @ApiModelProperty(value = "冻结数量")
    @TableField("FREEZEQTY")
    private Long freezeqty;

    @ApiModelProperty(value = "资金标识 - 1:余额 2;待付")
    @TableField("AMOUNTFLAG")
    private Integer amountflag;

    @ApiModelProperty(value = "委托标识 - 1:按量 2:按金额")
    @TableField("ORDERFLAG")
    private Integer orderflag;

    @ApiModelProperty(value = "排序单号(委托顺序与账户返回顺序不一致，账户返回时生成此字段排序)")
    @TableField("ORDERINDEXID")
    private Long orderindexid;

    @ApiModelProperty(value = "汇率")
    @TableField("EXCHANGERATE")
    private BigDecimal exchangerate;


    @Override
    public Serializable pkVal() {
        return this.orderid;
    }

}
