package com.jpsoft.shinestar.modules.base.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import org.springframework.format.annotation.DateTimeFormat;


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

/**
 * @author 墨鱼_mo
 * @date 2020-10-17 12:33
 */
@Data
public class OrderInfo {

    private String id;

    @ApiModelProperty(value = "商品描述")
    private String body;

    @ApiModelProperty(value = "订单费用")
    private BigDecimal totalFee;

    @ApiModelProperty(value = "支付状态")
    private Integer payStatus;

    @ApiModelProperty(value = "支付名称")
    private String payName;

    @ApiModelProperty(value = "支付金额")
    private BigDecimal payFee;

    @ApiModelProperty(value = "支付时间")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm",timezone ="GMT+8")
    private Date payTime;

    @ApiModelProperty(value = "系统订单号")
    private String outOrderNo;

    @ApiModelProperty(value = "微信订单号")
    private String transactionId;

    @ApiModelProperty(value = "支付人标识")
    private String openId;


    /**
     * 1：正常，2：关闭，3：退款
     */
    @ApiModelProperty(value = "订单状态")
    private String status = "1";

    /**
     *是否删除
     */
    @ApiModelProperty(value = "是否删除")
    private Boolean delFlag;
    /**
     *创建人
     */
    @ApiModelProperty(value = "创建人")
    private String createBy;
    /**
     *创建时间
     */
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm",timezone ="GMT+8")
    @ApiModelProperty(value = "创建时间")
    private Date createTime;
    /**
     *更新人
     */
    @ApiModelProperty(value = "更新人")
    private String updateBy;
    /**
     *更新时间
     */
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm",timezone ="GMT+8")
    @ApiModelProperty(value = "更新时间")
    private Date updateTime;

    @ApiModelProperty(value = "类别")
    private String type;

    @ApiModelProperty(value = "支付方式（string）")
    private String payNameStr;

    @ApiModelProperty(value = "学生id")
    private Long personId;

    @ApiModelProperty(value = "商品id")
    private String goodsId;

    @ApiModelProperty(value = "学校id")
    private String companyId;

    @ApiModelProperty(value = "购买者id")
    private String payPopedomId;

    @ApiModelProperty(value = "推广者")
    private String popularizePersonId;

    @ApiModelProperty(value = "订单所属方")
    private String belongPopedomId;
    @ApiModelProperty(value = "详情")
    private String detail;


    public String getPayNameStr() {
        if (StringUtils.isBlank(payName)){
            return "未支付";
        }
        else if ("wechat".equals(payName)){
            return "微信支付";
        }
        else if ("alipay".equals(payName)){
            return "支付宝支付";
        }
        else if ("cash".equals(payName)){
            return "现金";
        }
        else if ("transfer".equals(payName)){
            return "对公转账";
        }
        else if ("individual".equals(payName)){
            return "个人账户";
        }

        return payNameStr;
    }

    public String getPayStatusStr() {
        if (payStatus.equals(10)){
            return "未支付";
        }
        else if (payStatus.equals(20)){
            return "已支付";
        }
        else if (payStatus.equals(30)){
            return "已关闭";
        }
        else{
            return "已退款";
        }
    }


}
