package com.ycwl.basic.order.dto;

import lombok.Data;

import java.math.BigDecimal;
import java.util.Map;

/**
 * 支付参数响应DTO
 */
@Data
public class PaymentParamsResponse {
    
    /**
     * 订单ID
     */
    private Long orderId;
    
    /**
     * 订单号
     */
    private String orderNo;
    
    /**
     * 支付金额
     */
    private BigDecimal payAmount;
    
    /**
     * 是否需要支付（false表示免费订单）
     */
    private Boolean needPay;
    
    /**
     * 支付参数（微信小程序调起支付所需的参数）
     * 包含：appId, timeStamp, nonceStr, package, signType, paySign等
     */
    private Map<String, Object> paymentParams;
    
    /**
     * 支付描述信息
     */
    private String description;
    
    /**
     * 商品名称
     */
    private String goodsName;
    
    /**
     * 创建成功的支付参数响应
     */
    public static PaymentParamsResponse success(Long orderId, String orderNo, BigDecimal payAmount, 
                                              Boolean needPay, Map<String, Object> paymentParams) {
        PaymentParamsResponse response = new PaymentParamsResponse();
        response.orderId = orderId;
        response.orderNo = orderNo;
        response.payAmount = payAmount;
        response.needPay = needPay;
        response.paymentParams = paymentParams;
        return response;
    }
    
    /**
     * 创建免费订单的响应
     */
    public static PaymentParamsResponse free(Long orderId, String orderNo) {
        PaymentParamsResponse response = new PaymentParamsResponse();
        response.orderId = orderId;
        response.orderNo = orderNo;
        response.payAmount = BigDecimal.ZERO;
        response.needPay = false;
        response.paymentParams = null;
        return response;
    }
}