package com.cool.store.entity.fees;

import com.cool.store.entity.wallet.WalletTradeDO;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import javax.persistence.*;

/**
 * 钱包加盟缴费信息
 */
@Table(name = "zxjp_fees_wallet_pay_info")
@Data
@AllArgsConstructor
@NoArgsConstructor
public class WalletPayInfoDO {
    /**
     * id
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    /**
     * 门店id
     */
    @Column(name = "shop_id")
    private Long shopId;

    /**
     * 业务模块
     */
    @Column(name = "module")
    private String module;

    /**
     * 付款单号
     */
    @Column(name = "pay_no")
    private String payNo;

    /**
     * 付款人
     */
    @Column(name = "pay_user_name")
    private String payUserName;

    /**
     * 付款金额
     */
    @Column(name = "pay_amount")
    private BigDecimal payAmount;

    /**
     * 交易流水号
     */
    @Column(name = "trade_id")
    private String tradeId;

    /**
     * 付款状态，1已支付、2支付失败 3支付中
     */
    @Column(name = "pay_status")
    private Integer payStatus;

    /**
     * 支付时间
     */
    @Column(name = "pay_time")
    private Date payTime;

    /**
     * 认领状态0-待认领，1-已认领
     */
    @Column(name = "claim_status")
    private Integer claimStatus;

    /**
     * 费用类型列表
     */
    @Column(name = "expense_types")
    private String expenseTypes;

    /**
     * 备注
     */
    private String remark;

    /**
     * 创建人id
     */
    @Column(name = "create_user_id")
    private String createUserId;

    /**
     * 创建时间
     */
    @Column(name = "create_time")
    private Date createTime;

    /**
     * 批量分账批次号
     */
    @Column(name = "batch_code")
    private String batchCode;

    public WalletPayInfoDO(String module, Long shopId, String payNo, String payUserName, BigDecimal payAmount, String expenseType, String createUserId, String tradeId) {
        this.shopId = shopId;
        this.payNo = payNo;
        this.payUserName = payUserName;
        this.payAmount = payAmount;
        this.payTime = new Date();
        this.claimStatus = 0;
        this.expenseTypes = expenseType;
        this.createUserId = createUserId;
        this.module = module;
        this.tradeId = tradeId;
    }

    public WalletTradeDO convertToTradeDO(String module) {
        WalletTradeDO walletTradeDO = new WalletTradeDO();
        walletTradeDO.setModule(module);
        walletTradeDO.setPayNo(this.payNo);
        walletTradeDO.setTradeId(this.tradeId);
        walletTradeDO.setType(1);
        walletTradeDO.setPayUserName(this.payUserName);
        walletTradeDO.setPayAmount(this.payAmount);
        walletTradeDO.setPayStatus(this.payStatus);
        walletTradeDO.setPayTime(this.payTime);
        walletTradeDO.setRemark(this.remark);
        walletTradeDO.setCreateUserId(this.createUserId);
        walletTradeDO.setBatchCode(this.batchCode);
        return walletTradeDO;
    }
}