package com.jeequan.jeepay.db.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.jeequan.jeepay.core.model.BaseModel;
import com.jeequan.jeepay.core.utils.SeqKit;
import com.jeequan.jeepay.model.RedPacketAccountOperate;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

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

/**
 * <p>
 * 
 * </p>
 *
 * @author [mybatis plus generator]
 * @since 2024-01-17
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("t_red_packet_account")
@NoArgsConstructor
public class RedPacketAccount extends BaseModel {

    private static final long serialVersionUID=1L;

    /**
     * 红包账户id
     */
    @TableId(type = IdType.INPUT)
    private String accountId;

    /**
     * 所属付款用户id
     */
    private String payUserId;

    /**
     * 所属用户
     */
    private String mchNo;

    /**
     * 所属门店
     */
    private String storeId;

    /**
     * 所属门店名称
     */
    private String storeName;

    /**
     * 头像
     */
    private String headImg;

    /**
     * 昵称
     */
    private String nickName;

    /**
     * 手机号
     */
    private String phone;

    /**
     * 余额
     */
    private Long balance;

    /**
     * 最后一次消费时间
     */
    private Date lastTransTime;

    /**
     * 更新时间
     */
    private Date updatedAt;

    /**
     * 创建时间
     */
    private Date createdAt;

    /**
     * 来源：WECHAT 微信 ALIPAY 支付宝 YSFPAY 云闪付 UNIONPAY 银联 OTHER 其他
     */
    private String type;

    /**
     * 初次关联的订单号
     */
    private String fastFlowNo;


    public RedPacketAccount(RedPacketAccountOperate operate, Long balance) {
        this.accountId = SeqKit.genAccountNo();
        this.payUserId = operate.getPayUserId();
        this.mchNo = operate.getMchNo();
        this.storeId = operate.getStoreId();
        this.storeName = operate.getStoreName();
        this.balance = balance;
        this.fastFlowNo = operate.getFlowNo();
        this.type = operate.getPayType();
    }

    public static LambdaQueryWrapper<RedPacketAccount> gw(RedPacketAccount info) {
        return new LambdaQueryWrapper<>(info);
    }
}
