package com.czg.account.vo;

import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.annotation.Table;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * 用户余额流水 实体类。
 *
 * @author zs
 * @since 2025-02-13
 */
@Data

@NoArgsConstructor
@AllArgsConstructor
public class ShopUserFlowInfoVO implements Serializable {

    @Serial
    private static final long serialVersionUID = 1L;

    @Id(keyType = KeyType.Auto)
    private Long id;

    private Long userId;

    private Long shopId;
    /**
     * 充值金额
     */
    private BigDecimal amount;
    /**
     * 当前余额
     */
    private BigDecimal balance;
    /**
     * 已退款金额
     */
    private BigDecimal refundAmount;

    /**
     * 类型：
     * cashIn 现金充值，
     * wechatIn 微信小程序充值，
     * alipayIn 支付宝小程序充值，
     * awardIn 充值奖励，
     * rechargeRefund 充值退款
     * <p>
     * orderPay 订单消费，
     * orderRefund 订单退款，
     * <p>
     * adminIn 管理员充值
     * adminOut管理员消费
     */
    private String bizCode;
    /**
     * 备注
     */
    private String remark;

    /**
     * 关联id，
     * 订单支付/订单退款/霸王餐时 订单id
     * 支付/退款 tb_order_payment.id
     */
    private Long relationId;
    /**
     * 充值记录id  当前表的id
     * 退款使用
     */
    private Long rechargeId;


    @Column(onInsertValue = "now()")
    private LocalDateTime createTime;
    /**
     * 退款失败原因
     */
    private String failMsg;
    private String shopName;


    public BigDecimal getAmount() {
        if (amount == null) {
            return BigDecimal.ZERO;
        }
        return amount;
    }

    public BigDecimal getRefundAmount() {
        if (refundAmount == null) {
            return BigDecimal.ZERO;
        }
        return refundAmount;
    }
}
