package com.icloud.server.payutils.dto;

import lombok.*;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;

/**
 * 支付订单 DO
 *
 * @author
 */
@Table(name = "pay_order")
@Data
//@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Entity
public class PayOrderDO implements Serializable {

    /**
     * 订单编号，数据库自增
     */
    @Id
    @Column(name = "id")
    private Long id;
    /**
     * 商户编号
     *
     */
    @Column(name = "merchantId")
    private Long merchantid;
    /**
     * 应用编号
     *
     */
    @Column(name = "appId")
    private Long appid;
    /**
     * 用户openid
     */
    @Column(name = "openid")
    private String openid;
    private String nickname;
    private String headimgurl;
    /**
     * 渠道编号
     *
     */
    @Column(name = "channelId")
    private Long channelid;
    /**
     * 渠道编码
     *
     */
    @Column(name = "channelCode")
    private String channelcode;

    // ========== 商户相关字段 ==========

    /**
     * 商户订单编号
     * 例如说，内部系统 A 的订单号。需要保证每个 PayMerchantDO 唯一
     */
    @Column(name = "merchantOrderId")
    private String merchantorderid;
    /**
     * 商品标题
     */
    @Column(name = "subject")
    private String subject;
    /**
     * 商品描述信息
     */
    @Column(name = "body")
    private String body;
    /**
     * 异步通知地址
     */
    @Column(name = "notifyUrl")
    private String notifyurl;
    /**
     * 通知商户支付结果的回调状态
     *
     */
    @Column(name = "notifyStatus")
    private Integer notifystatus;
//    /**
//     * 商户拓展参数
//     */
//    private Map<String, String> merchantExtras;

    // ========== 订单相关字段 ==========

    /**
     * 支付金额，单位：分
     */
    @Column(name = "amount")
    private Long amount;
    /**
     * 渠道手续费，单位：百分比
     *
     */
    @Column(name = "channelFeeRate")
    private Double channelFeeRate;
    /**
     * 渠道手续金额，单位：分
     */
    @Column(name = "channelFeeAmount")
    private Long channelfeeamount;
    /**
     * 支付状态
     *
     */
    @Column(name = "status")
    private Integer status;
    /**
     * 用户 IP
     */
    @Column(name = "userIp")
    private String userip;
    /**
     * 订单失效时间
     */
    @Column(name = "expireTime")
    private Date expiretime;
    /**
     * 订单支付成功时间
     */
    @Column(name = "successTime")
    private Date successtime;
    /**
     * 订单支付通知时间，即支付渠道的通知时间
     */
    @Column(name = "notifyTime")
    private Date notifytime;
    /**
     * 支付成功的订单拓展单编号
     *
     * 关联 {@link PayOrderDO#getId()}
     */
    @Column(name = "successExtensionId")
    private Long successextensionid;

    // ========== 退款相关字段 ==========
    /**
     * 退款状态
     *
     */
    @Column(name = "refundStatus")
    private Integer refundstatus;
    /**
     * 退款次数
     */
    @Column(name = "refundTimes")
    private Integer refundtimes;
    /**
     * 退款总金额，单位：分
     */
    @Column(name = "refundAmount")
    private Long refundamount;

    // ========== 渠道相关字段 ==========
    /**
     * 渠道用户编号
     *
     * 例如说，微信 openid、支付宝账号
     */
    @Column(name = "channelUserId")
    private String channeluserid;
    /**
     * 渠道订单号
     */
    @Column(name = "channelOrderNo")
    private String channelorderno;

    @CreationTimestamp
    @Column(name = "create_time")
    private Date createtime;
    /**
     * 最后更新时间
     */

    @UpdateTimestamp
    @Column(name = "update_time")
    private Date updatetime;
    /**
     * 创建者，目前使用 SysUser 的 id 编号
     *
     * 使用 String 类型的原因是，未来可能会存在非数值的情况，留好拓展性。
     */
    @Column(name = "creator")
    private String creator;
    /**
     * 更新者，目前使用 SysUser 的 id 编号
     *
     * 使用 String 类型的原因是，未来可能会存在非数值的情况，留好拓展性。
     */

    @Column(name = "updater")
    private String updater;

    public String getNickname() {
        return nickname;
    }

    public void setNickname(String nickname) {
        this.nickname = nickname;
    }

    public String getHeadimgurl() {
        return headimgurl;
    }

    public void setHeadimgurl(String headimgurl) {
        this.headimgurl = headimgurl;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getMerchantid() {
        return merchantid;
    }

    public void setMerchantid(Long merchantid) {
        this.merchantid = merchantid;
    }

    public Long getAppid() {
        return appid;
    }

    public void setAppid(Long appid) {
        this.appid = appid;
    }

    public Long getChannelid() {
        return channelid;
    }

    public void setChannelid(Long channelid) {
        this.channelid = channelid;
    }

    public String getChannelcode() {
        return channelcode;
    }

    public void setChannelcode(String channelcode) {
        this.channelcode = channelcode;
    }

    public String getMerchantorderid() {
        return merchantorderid;
    }

    public void setMerchantorderid(String merchantorderid) {
        this.merchantorderid = merchantorderid;
    }

    public String getSubject() {
        return subject;
    }

    public void setSubject(String subject) {
        this.subject = subject;
    }

    public String getBody() {
        return body;
    }

    public void setBody(String body) {
        this.body = body;
    }

    public String getNotifyurl() {
        return notifyurl;
    }

    public void setNotifyurl(String notifyurl) {
        this.notifyurl = notifyurl;
    }

    public Integer getNotifystatus() {
        return notifystatus;
    }

    public void setNotifystatus(Integer notifystatus) {
        this.notifystatus = notifystatus;
    }

    public Long getAmount() {
        return amount;
    }

    public void setAmount(Long amount) {
        this.amount = amount;
    }

    public Double getChannelFeeRate() {
        return channelFeeRate;
    }

    public void setChannelFeeRate(Double channelFeeRate) {
        this.channelFeeRate = channelFeeRate;
    }

    public Long getChannelfeeamount() {
        return channelfeeamount;
    }

    public void setChannelfeeamount(Long channelfeeamount) {
        this.channelfeeamount = channelfeeamount;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public String getUserip() {
        return userip;
    }

    public void setUserip(String userip) {
        this.userip = userip;
    }

    public Date getExpiretime() {
        return expiretime;
    }

    public void setExpiretime(Date expiretime) {
        this.expiretime = expiretime;
    }

    public Date getSuccesstime() {
        return successtime;
    }

    public void setSuccesstime(Date successtime) {
        this.successtime = successtime;
    }

    public Date getNotifytime() {
        return notifytime;
    }

    public void setNotifytime(Date notifytime) {
        this.notifytime = notifytime;
    }

    public Long getSuccessextensionid() {
        return successextensionid;
    }

    public void setSuccessextensionid(Long successextensionid) {
        this.successextensionid = successextensionid;
    }

    public Integer getRefundstatus() {
        return refundstatus;
    }

    public void setRefundstatus(Integer refundstatus) {
        this.refundstatus = refundstatus;
    }

    public Integer getRefundtimes() {
        return refundtimes;
    }

    public void setRefundtimes(Integer refundtimes) {
        this.refundtimes = refundtimes;
    }

    public Long getRefundamount() {
        return refundamount;
    }

    public void setRefundamount(Long refundamount) {
        this.refundamount = refundamount;
    }

    public String getChanneluserid() {
        return channeluserid;
    }

    public void setChanneluserid(String channeluserid) {
        this.channeluserid = channeluserid;
    }

    public String getChannelorderno() {
        return channelorderno;
    }

    public void setChannelorderno(String channelorderno) {
        this.channelorderno = channelorderno;
    }

    public Date getCreatetime() {
        return createtime;
    }

    public void setCreatetime(Date createtime) {
        this.createtime = createtime;
    }

    public Date getUpdatetime() {
        return updatetime;
    }

    public void setUpdatetime(Date updatetime) {
        this.updatetime = updatetime;
    }

    public String getCreator() {
        return creator;
    }

    public void setCreator(String creator) {
        this.creator = creator;
    }

    public String getUpdater() {
        return updater;
    }

    public void setUpdater(String updater) {
        this.updater = updater;
    }

    public String getOpenid() {
        return openid;
    }

    public void setOpenid(String openid) {
        this.openid = openid;
    }
}
