package com.iformall.domain.po;

import cn.afterturn.easypoi.excel.annotation.Excel;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.iformall.domain.po.base.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

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

@TableName(value = "wx_order")
@Data
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
public class WxOrder extends BaseEntity {

    protected Long id;


    @TableField(exist = false)
	private String merchantName;

	public String getcUserName() {
		return cUserName;
	}

    public String getCUserName() {
        return cUserName;
    }

	@Excel(name = "会员", width = 20, orderNum = "2")
	@TableField(exist = false)
	private String cUserName;

	@Excel(name = "会员手机号", width = 20, orderNum = "3")
	@TableField(exist = false)
	private String phone;

	@Excel(name = "订单编号", width = 20, orderNum = "1")
	@io.swagger.annotations.ApiModelProperty(value="订单码;正反向交易保持一致。",name="orderNumber")
	private Long orderNumber;
	@io.swagger.annotations.ApiModelProperty(value="租户ID",name="tenantId")
	private String tenantId;
	@io.swagger.annotations.ApiModelProperty(value="c端用户id",name="cUserId")
	private Long cUserId;
    @io.swagger.annotations.ApiModelProperty(value="渠道ID",name="couponChannelId")
    private Long couponChannelId;
	@io.swagger.annotations.ApiModelProperty(value="产品ID(type-0:couponId, 1:buserId, 3:merchantId)",name="productId")
	private Long productId;
	@io.swagger.annotations.ApiModelProperty(value="类型(0:券,1:B刷卡支付,2:C扫码支付,3:储值卡, 10:POS支付)",name="type")
	private Integer type;
	@io.swagger.annotations.ApiModelProperty(value="0: 付款 1: 退款",name="paymentType")
	private Integer paymentType;

	@io.swagger.annotations.ApiModelProperty(value="支付金额(分)：允许有负数，退款时为负值。",name="payment")
	private Integer payment;
	@io.swagger.annotations.ApiModelProperty(value="支付时间",name="paymentTime")
	private Date paymentTime;

	@Excel(name = "订单状态", width = 20, orderNum = "9", replace = {"待付款_0", "已支付_1", "已取消_2", "待退款_3", "已退款_4", "退款失败_5", " _-1"})
	@io.swagger.annotations.ApiModelProperty(value="订单状态：-1全部;正向交易：0-已下单/待付款;1-已支付;2-已取消(限定时间内未付款)反向交易：3-已退款; 4-退款失败,5-退款失败; 砍价:6-砍价中,7-砍价完成,8-砍价失败",name="orderStatus")
	private Integer orderStatus;

	@Excel(name = "订单日期", width = 20, orderNum = "7", format = "yyyy-MM-dd")
	@io.swagger.annotations.ApiModelProperty(value="创建时间/砍价开始时间",name="createDate")
	private Date createDate;
	@io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate")
	private Date updateDate;
	@io.swagger.annotations.ApiModelProperty(value="支付描述，订单支付时用",name="detail")
	private String detail;

	@io.swagger.annotations.ApiModelProperty(value="砍价结束时间",name="pressEndDate")
	private Date pressEndDate;
	@io.swagger.annotations.ApiModelProperty(value="砍价人数",name="pressCurrentNum")
	private Integer pressCurrentNum;
	@io.swagger.annotations.ApiModelProperty(value="已砍价格",name="pressCurrentValue")
	private Integer pressCurrentValue;

    @io.swagger.annotations.ApiModelProperty(value = "拼团ID", name = "orderGroupId")
    private Long orderGroupId;

    @io.swagger.annotations.ApiModelProperty(value = "formId", name = "formId")
    private String formId;

	@io.swagger.annotations.ApiModelProperty(value = "POS系统订单ID", name = "posOrderId")
	private Long posOrderId;
	@io.swagger.annotations.ApiModelProperty(value="POS系统订单创建时间",name="posOrderCreateTime")
	private Long posOrderCreateTime;
	@io.swagger.annotations.ApiModelProperty(value="POS SN",name="posOrderCreateSn")
	private String posOrderCreateSn;

	@io.swagger.annotations.ApiModelProperty(value="实际支付金额(分),收银台用券时使用",name="realPayment")
	private Integer realPayment;

    @TableField(exist = false)
    protected List<Integer> statusS;

    @TableField(exist = false)
    protected String statusStr;

	@Excel(name = "商品名称", width = 20, orderNum = "5")
	@TableField(exist = false)
	private String title;

	@Excel(name = "商品属性", width = 20, orderNum = "4", replace = {"消费卡_1", "优惠券_2", "砍价_3", "拼团_4", " _-1"})
	@TableField(exist = false)
	private Integer attribute;

	@TableField(exist = false)
	private Integer pay;

	@Excel(name = "支付金额(元)", width = 20, orderNum = "8")
	@TableField(exist = false)
	private String payStr;

	public String getPayStr() {
		return pay != null ? new BigDecimal(pay).divide(new BigDecimal(100)).toPlainString() : payStr;
	}

	public String getPaymentStr() {
		return payment != null ? new BigDecimal(payment).divide(new BigDecimal(100)).toPlainString() : payStr;
	}

	@Excel(name = "订单金额(元)", width = 20, orderNum = "6")
	@TableField(exist = false)
	private String paymentStr;

}
