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 java.math.BigDecimal;
import java.util.Date;
import java.util.List;

@TableName(value = "wx_card_spend")
@Data
@EqualsAndHashCode(callSuper = true)
public class WxCardSpend extends BaseEntity {
	private static final long serialVersionUID = 1L;
	
    protected Long id;

    @io.swagger.annotations.ApiModelProperty(value="租户ID",name="tenantId")
	private String tenantId;
	@io.swagger.annotations.ApiModelProperty(value="储值卡ID",name="cardId")
	private Long cardId;
	@io.swagger.annotations.ApiModelProperty(value="持有人ID",name="ownerId")
	private Long ownerId;
	@io.swagger.annotations.ApiModelProperty(value="商户ID",name="merchantId")
	private Long merchantId;

	@Excel(name = "订单号", width = 20, orderNum = "5")
	@io.swagger.annotations.ApiModelProperty(value="订单账号",name="orderId")
	private Long orderId;
	@io.swagger.annotations.ApiModelProperty(value="POS订单账号",name="posOrderId")
	private Long posOrderId;
    @io.swagger.annotations.ApiModelProperty(value="ip地址",name="ip")
    private String ip;
	@io.swagger.annotations.ApiModelProperty(value="抵扣金额",name="deductionAmount")
	private Integer deductionAmount;
	@io.swagger.annotations.ApiModelProperty(value="支付金额(包含通道费)",name="payment")
	private Integer payment;
	@io.swagger.annotations.ApiModelProperty(value="实收金额(不包含通道费)",name="realPayment")
	private Integer realPayment;

	@io.swagger.annotations.ApiModelProperty(value="卡剩余总金额",name="cardRemainAmount")
	private Integer cardRemainAmount;
	@io.swagger.annotations.ApiModelProperty(value="卡支付前总金额",name="cardBeforeAmount")
	private Integer cardBeforeAmount;
	@io.swagger.annotations.ApiModelProperty(value="卡剩余总金额",name="cardRemainRealAmount")
	private Integer cardRemainRealAmount;
	@io.swagger.annotations.ApiModelProperty(value="卡支付前总金额",name="cardBeforeRealAmount")
	private Integer cardBeforeRealAmount;

	@Excel(name="交易时间",width = 20,orderNum = "6",format="yyyy-MM-dd HH:mm")
    @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate")
	private Date createDate;
	@io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate")
	private Date updateDate;

	@Excel(name = "支付状态", width = 20, orderNum = "11", replace = {"未支付_0", "已分账_1", "已人工分账_2"})
    @io.swagger.annotations.ApiModelProperty(value="支付状态(0:未分帐, 1:已分账, 2:已人工分账, 10:预支付(POS))",name="payStatus")
	private Integer payStatus;

	@io.swagger.annotations.ApiModelProperty(value="来源(0：C端小程序扫一扫, 1：POS支付)",name="payFrom")
	private Integer payFrom;

	@TableField(exist = false)
	@Excel(name = "消费金额(元)", width = 20, orderNum = "7")
	private String deductionAmountStr;

	@TableField(exist = false)
	@Excel(name = "应付金额(元)", width = 20, orderNum = "9")
	private String paymentStr;

	@TableField(exist = false)
	@Excel(name = "实付金额(扣除手续费/元)", width = 20, orderNum = "8")
	private String realPaymentStr;


	@TableField(exist = false)
	protected List<Integer> payStatusS;
	@TableField(exist = false)
	protected String payStatusStr;

	@TableField(exist = false)
	@io.swagger.annotations.ApiModelProperty(value="开始时间",name="startdate")
	private Date startdate;

	@TableField(exist = false)
	@io.swagger.annotations.ApiModelProperty(value="结束时间",name="enddate")
	private Date enddate;

	@TableField(exist = false)
	@io.swagger.annotations.ApiModelProperty(value="时段(0,工作日白天,1,工作日晚上,2周末白天,3周末晚上)",name="timeSlot")
	private Integer timeSlot;

	@TableField(exist = false)
	private Integer businessId;

	@TableField(exist = false)
	private Integer subBusinessId;

	public String getCardRemainAmountStr() {
		return new BigDecimal(cardRemainAmount == null ? 0 : cardRemainAmount).divide(new BigDecimal(100)).toPlainString();
	}

	@TableField(exist = false)
	@Excel(name = "卡余额(元) ", width = 20, orderNum = "10")
	private String cardRemainAmountStr;

	public String getDeductionAmountStr() {
		if(getDeductionAmount()!=null) {
			deductionAmountStr = new BigDecimal(getDeductionAmount()).divide(new BigDecimal(100)).toString();
		}
		return deductionAmountStr;
	}

	public String getPaymentStr() {
		if(getPayment()!=null) {
			paymentStr = new BigDecimal(getPayment()).divide(new BigDecimal(100)).toString();
		}
		return paymentStr;
	}

	public String getRealPaymentStr() {
		if(getRealPayment()!=null) {
			realPaymentStr = new BigDecimal(getRealPayment()).divide(new BigDecimal(100)).toString();
		}
		return realPaymentStr;
	}
	
}
