package com.yiqi.order.domain.dto;

import com.yiqi.common.enums.OrderType;
import com.yiqi.common.enums.PayWayType;
import com.yiqi.common.utils.DateUtils;
import com.yiqi.order.domain.OrderCloth;
import com.yiqi.order.domain.OrderGoods;
import com.yiqi.order.domain.OrderRecharge;
import com.yiqi.order.domain.OrderRechargeInstalment;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.math.BigDecimal;

/**
 * @author xiaohei
 * @date 2024/1/1
 */
@ApiModel("第三方支付信息")
@Data
public class PayOrderFaceToFaceDTO extends PayOrderDTO {

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

    /**
     * 付款码支付
     *
     * @param orderCloth
     * @param authCode
     * @return
     */
    public static PayOrderFaceToFaceDTO buildClothOrderPayData(OrderCloth orderCloth, String authCode) {
        PayOrderFaceToFaceDTO payOrderFaceToFaceDTO = new PayOrderFaceToFaceDTO();
        payOrderFaceToFaceDTO.setOrderNo(orderCloth.getOrderNo());
        payOrderFaceToFaceDTO.setPayAmount(orderCloth.getPayAmount());
        payOrderFaceToFaceDTO.setSubjectTitle(OrderType.cloth.getInfo());
        payOrderFaceToFaceDTO.setAuthCode(authCode);
        payOrderFaceToFaceDTO.setPayType(orderCloth.getPayType());
        payOrderFaceToFaceDTO.setExpireTime(DateUtils.addMinutes(DateUtils.getNowDate(), 5));
        return payOrderFaceToFaceDTO;
    }

    /**
     * 支付充值订单
     *
     * @param rechargeSn 传的都是每次支付的订单编号，非主订单编号
     * @param authCode   付款码
     * @return
     */
    public static PayOrderFaceToFaceDTO createRechargeOrderPayData(String rechargeSn, BigDecimal payAmount, String payType, String authCode) {
        PayOrderFaceToFaceDTO payOrderFaceToFaceDTO = new PayOrderFaceToFaceDTO();
        payOrderFaceToFaceDTO.setOrderNo(rechargeSn);
        payOrderFaceToFaceDTO.setPayAmount(payAmount);
        payOrderFaceToFaceDTO.setSubjectTitle(OrderType.recharge.getInfo());
        payOrderFaceToFaceDTO.setPayType(payType);
        payOrderFaceToFaceDTO.setExpireTime(DateUtils.addMinutes(DateUtils.getNowDate(), 5));
        payOrderFaceToFaceDTO.setAuthCode(authCode);
        return payOrderFaceToFaceDTO;
    }

    /**
     * 支付充值订单
     *
     * @param instalment 传的都是每次支付的订单编号，非主订单编号
     * @param authCode   付款码
     * @return
     */
    public static PayOrderFaceToFaceDTO buildRechargeOrderPayData(OrderRechargeInstalment instalment, String authCode) {
        PayOrderFaceToFaceDTO payOrderFaceToFaceDTO = new PayOrderFaceToFaceDTO();
        payOrderFaceToFaceDTO.setOrderNo(instalment.getOrderNo());
        payOrderFaceToFaceDTO.setPayAmount(instalment.getPayAmount());
        payOrderFaceToFaceDTO.setSubjectTitle(OrderType.recharge.getInfo());
        payOrderFaceToFaceDTO.setPayType(instalment.getPayType());
        payOrderFaceToFaceDTO.setExpireTime(DateUtils.addMinutes(instalment.getCreateTime(), 5));
        payOrderFaceToFaceDTO.setAuthCode(authCode);
        return payOrderFaceToFaceDTO;
    }
//    /**
//     * 分段支付充值订单
//     * @param instalment
//     * @param authCode
//     * @return
//     */
//    public static PayOrderFaceToFaceDTO buildRechargeOrderMorePayData(OrderRechargeInstalment instalment, String authCode){
//        PayOrderFaceToFaceDTO payOrderFaceToFaceDTO = new PayOrderFaceToFaceDTO();
//        payOrderFaceToFaceDTO.setOrderNo(instalment.getOrderNo());
//        payOrderFaceToFaceDTO.setPayAmount(instalment.getPayAmount());
//        payOrderFaceToFaceDTO.setSubjectTitle(OrderType.recharge.getInfo());
//        payOrderFaceToFaceDTO.setPayType(instalment.getPayType());
//        payOrderFaceToFaceDTO.setExpireTime(DateUtils.addMinutes(instalment.getCreateTime(), 5));
//        payOrderFaceToFaceDTO.setAuthCode(authCode);
//        return payOrderFaceToFaceDTO;
//    }

    public static PayOrderFaceToFaceDTO buildGoodsOrderPayData(OrderGoods orderGoods, String authCode) {
        PayOrderFaceToFaceDTO payOrderFaceToFaceDTO = new PayOrderFaceToFaceDTO();
        payOrderFaceToFaceDTO.setOrderNo(orderGoods.getOrderNo());
        payOrderFaceToFaceDTO.setPayAmount(orderGoods.getPayAmount());
        payOrderFaceToFaceDTO.setSubjectTitle(OrderType.recharge.getInfo());
        payOrderFaceToFaceDTO.setPayType(orderGoods.getPayType());
        payOrderFaceToFaceDTO.setExpireTime(DateUtils.addMinutes(orderGoods.getCreateTime(), 5));
        payOrderFaceToFaceDTO.setAuthCode(authCode);
        return payOrderFaceToFaceDTO;
    }
}
