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.common.SortColumn;
import com.iformall.domain.po.base.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

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

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

    protected Long id;

    @TableField(exist = false)
	protected String idStr;



	@io.swagger.annotations.ApiModelProperty(value="租户ID",name="tenantId")
	private String tenantId;

	@Excel(name="交易单号",width = 20,orderNum = "1")
	@io.swagger.annotations.ApiModelProperty(value="订单ID",name="orderId")
	private Long orderId;

	@io.swagger.annotations.ApiModelProperty(value="订单支付类型(0:券1:付款码支付,2:C扫码支付,3,储值卡)",name="orderType")
	private Integer orderType;

	@io.swagger.annotations.ApiModelProperty(value="商户ID",name="merchantId")
	private Long merchantId;

	@io.swagger.annotations.ApiModelProperty(value="券包ID/存储卡ID",name="couponOrderId")
	private Long couponOrderId;

	@io.swagger.annotations.ApiModelProperty(value="券包类型(1.满减券,2.代金券,3.团购券,4.礼品券,5.停车券,6.多商户券,8.砍价券,9.团购券,100.消费卡)",name="couponType")
	private Integer couponType;

	@io.swagger.annotations.ApiModelProperty(value="订单金额",name="orderPayment")
	@SortColumn(column = "order_payment")
	private Integer orderPayment;

	@io.swagger.annotations.ApiModelProperty(value="接收金额（包含通道费）",name="receiverPayment")
	@SortColumn(column = "receiver_payment")
	private Integer receiverPayment;

	@TableField(exist = false)
    @io.swagger.annotations.ApiModelProperty(value="订单金额",name="orderPaymentStr")
	private String orderPaymentStr;

	@TableField(exist = false)
    @io.swagger.annotations.ApiModelProperty(value="接收金额（包含通道费）",name="receiverPaymentStr")
	private String receiverPaymentStr;

	@TableField(exist = false)
    @Excel(name = "承付金额(元)", width = 20, orderNum = "6")
    @io.swagger.annotations.ApiModelProperty(value="补贴额（包含通道费）",name="subsidyStr")
    private String subsidyStr;

	@io.swagger.annotations.ApiModelProperty(value=" 实收金额(不包含通道费)",name="realPayment")
	private Integer realPayment;
	@io.swagger.annotations.ApiModelProperty(value="补贴额（包含通道费）",name="subsidy")
	private Integer subsidy;

	@io.swagger.annotations.ApiModelProperty(value="线上补贴额/实收补贴额（通道费扣除）",name="realSubsidy")
	private Integer realSubsidy;

    @Excel(name = "结算状态", width = 20, orderNum = "7", replace = {"未结算_0", "已结算_1", "已结算_2", " _-1"})
	@io.swagger.annotations.ApiModelProperty(value="状态(0:未补贴, 1:已补贴, 2:已手工补贴)",name="status")
	private Integer status;

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

	@io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate")
	@SortColumn(column = "update_date")
	private Date updateDate;

	@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)
	protected List<Integer> statusS;

	@TableField(exist = false)
	protected String statusStr;

	@Excel(name = "冻结状态", width = 20, orderNum = "8", replace = {"冻结中_1", "正常_0", " _-1"})
    @io.swagger.annotations.ApiModelProperty(value = "是否冻结", name = "freeze")
    private Integer freeze;

	public String getOrderPaymentStr() {

		if(getOrderPayment()!=null) {
			orderPaymentStr = new BigDecimal(getOrderPayment()).divide(new BigDecimal(100)).toString();
		}
		return orderPaymentStr;
	}

	public String getReceiverPaymentStr() {
		if(getReceiverPayment()!=null) {
			receiverPaymentStr = new BigDecimal(getReceiverPayment()).divide(new BigDecimal(100)).toString();
		}
		return receiverPaymentStr;
	}

    public String getSubsidyStr() {
        if(getSubsidy()!=null) {
            subsidyStr = new BigDecimal(getSubsidy()).divide(new BigDecimal(100)).toString();
        }
        return subsidyStr;
    }

	@Excel(name = "结算类型", width = 20, orderNum = "4", replace = {"自主结算_1", "微信结算_2", " _-1"})
    @io.swagger.annotations.ApiModelProperty(value = "结算类型1自主结算2微信结算", name = "type")
	private Integer type;

	@Excel(name = "结算来源", width = 20, orderNum = "3", replace = {"补贴_0", "卡消费_1", "券核销_2", "砍价核销_3", "拼团核销_4", "收银分账_5", " _-1"})
    @io.swagger.annotations.ApiModelProperty(value = "结算来源0补贴1卡消费2券核销3砍价核销4拼团核销5收银分账", name = "source")
    private Integer source;
}
