package com.yiqi.order.domain.dto;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.yiqi.common.annotation.Excel;
import com.yiqi.common.core.domain.BaseEntity;
import com.yiqi.common.enums.OrderSourceType;
import com.yiqi.common.enums.RechargeTypeEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotEmpty;
import java.math.BigDecimal;
import java.util.List;

/**
 * 充值订单对象 order_recharge
 *
 * @author ruoyi
 * @date 2023-09-27
 */
@ApiModel("充值订单对象")
@Data
public class OrderRechargeCreateDTO extends BaseEntity {
    private static final long serialVersionUID = 1L;
    /**
     * 订单编号
     */
    @Excel(name = "订单编号")
    @ApiModelProperty("订单编号")
    private String orderNo;

    /**
     * 组织ID
     */
    @Excel(name = "组织ID")
    @ApiModelProperty("组织ID")

    private Long orgId;

    /**
     * 来源类型
     */
    @Excel(name = "来源类型")
    @ApiModelProperty("来源类型")
    private String sourceType;

    /**
     * 客户ID
     */
    @Excel(name = "客户ID")
    @ApiModelProperty("客户ID")

    private Long appUserId;

    @ApiModelProperty("优惠券ID集合")
    private List<Long> couponIds;

    /**
     * 支付金额
     */
    @Excel(name = "支付金额")
    @ApiModelProperty("支付金额")
    private BigDecimal payAmount;


    /**
     * 支付方式（0=微信，1=支付宝，2=现金，3=充值卡）
     */
    @Excel(name = "支付方式", readConverterExp = "0==微信，1=支付宝，2=现金，3=充值卡  9=组合支付")
    @ApiModelProperty("支付方式（0=微信，1=支付宝，2=现金，3=充值卡, 9=组合支付）")
    private String payType;

    /**
     * 组合支付现金金额
     */
    @Excel(name = "组合支付现金金额")
    @ApiModelProperty("组合支付现金金额")
    private BigDecimal cashPayAmount;


    @Excel(name = "其他支付金额")
    @ApiModelProperty("其他支付金额")
    private BigDecimal otherPayAmount;

    /**
     * 充值金额
     */
    @Excel(name = "充值金额")
    @ApiModelProperty("充值金额")
    private BigDecimal rechargeAmount;

    /**
     * 赠送金额
     */
    @Excel(name = "赠送金额")
    @ApiModelProperty("赠送金额")
    private BigDecimal giveAmount;

    /**
     * 赠送积分
     */
    @Excel(name = "赠送积分")
    @ApiModelProperty("赠送积分")
    private Integer givePointAmount;


    @ApiModelProperty("福利金额")
    private BigDecimal welfareAmount;

    /**
     * 充值套餐ID
     */
    @Excel(name = "充值套餐ID")
    @ApiModelProperty("充值套餐ID")

    private Long rechargeTypeId;

    /**
     * 是否分段支付
     */
    @Excel(name = "是否分段支付")
    @ApiModelProperty("是否分段支付 N: 否  Y: 是")
    private String isInstalment;

    /**
     * 下单渠道（APP=APP，WXAPP=小程序）
     */
    @Excel(name = "下单渠道", readConverterExp = "APP=APP，WXAPP=小程序")
    @ApiModelProperty("下单渠道（APP=APP，WXAPP=小程序, OFFLINE=线下门店）")
    private String orderSource;


    /**
     * 充值类型
     */
    @Excel(name = "充值类型")
    @ApiModelProperty("充值类型")
    private String rechargeType;

    /** 卡号 */
    @Excel(name = "卡号")
    @ApiModelProperty("卡号")
    private String cardNo;

    /** 卡密 */
    @ApiModelProperty("卡密")
    private String password;

    @ApiModelProperty("用户付款码")
    private String authCode;

    @ApiModelProperty("付款平台(APP=APP、WEAPP=小程序)")
    @NotEmpty(message = "付款平台不能为空")
    private String platform;

    public static OrderRechargeCreateDTO buildDirectChargingCardByOrder(Long appUserId){
        OrderRechargeCreateDTO orderRechargeCreateDTO = new OrderRechargeCreateDTO();
        orderRechargeCreateDTO.setRechargeType(RechargeTypeEnum.CARD.getCode());
        orderRechargeCreateDTO.setAppUserId(appUserId);
        orderRechargeCreateDTO.setOrderSource(OrderSourceType.HQ.getCode());
        return orderRechargeCreateDTO;
    }
}
