package com.zsElectric.boot.thirdParty.model;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;

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

/**
 * 充电券购买响应参数 (data加密前的内容)
 *
 * @author wzq
 */
@Data
public class ChargeOrderPayResponseData implements Serializable {

    @Serial
    private static final long serialVersionUID = 1L;

    /**
     * 充值结果 (0-成功 1-失败)
     */
    @JsonProperty("result")
    private Integer result;

    /**
     * 结果消息
     */
    @JsonProperty("message")
    private String message;

    /**
     * 用户ID
     */
    @JsonProperty("userId")
    private Long userId;

    /**
     * 充值金额
     */
    @JsonProperty("rechargeMoney")
    private BigDecimal rechargeMoney;

    /**
     * 充值后余额
     */
    @JsonProperty("balanceAfter")
    private BigDecimal balanceAfter;

    /**
     * 第三方订单号
     */
    @JsonProperty("orderNo")
    private String orderNo;

    /**
     * 创建成功响应数据
     */
    public static ChargeOrderPayResponseData success(Long userId, BigDecimal rechargeMoney, BigDecimal balanceAfter, String orderNo) {
        ChargeOrderPayResponseData data = new ChargeOrderPayResponseData();
        data.setResult(0);
        data.setMessage("充值成功");
        data.setUserId(userId);
        data.setRechargeMoney(rechargeMoney);
        data.setBalanceAfter(balanceAfter);
        data.setOrderNo(orderNo);
        return data;
    }

    /**
     * 创建失败响应数据
     */
    public static ChargeOrderPayResponseData fail(String message) {
        ChargeOrderPayResponseData data = new ChargeOrderPayResponseData();
        data.setResult(1);
        data.setMessage(message);
        return data;
    }
}
