package com.younike.hlpay.dto;

import com.google.common.collect.ImmutableSet;
import com.younike.hlpay.constant.HeliPayContants;
import com.younike.hlpay.util.DesUtils;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.apache.commons.lang3.StringUtils;

import java.util.Set;

@Setter
@Getter
@ToString
public class AppPayRefundOrderVo {

    private String P1_bizType;
    private String P2_orderId;
    private String P3_customerNumber;
    private String P4_refundOrderId;
    private String P5_amount;
    private String P6_callbackUrl;
    private String P7_desc;
    private String P8_orderSerialNumber;
    /**排除签名*/
    private String acqAddnData;
    /**排除签名*/
    private String ruleJson;
    private String sign;

    public void setRuleJson(String ruleJson) {
        System.out.println("ruleJson 明文:" + ruleJson);
        if (StringUtils.isNotBlank(ruleJson)) {
            try {
                ruleJson = DesUtils.encode(HeliPayContants.DES_APPPAY, ruleJson);
            } catch (Exception e) {
                System.out.println("error:" + e.getMessage());
            }
            System.out.println("ruleJson 3des result:" + ruleJson);
        }
        this.ruleJson = ruleJson;
    }

    /**
     * 需要加签的属性参数,要求加签的参数空值也签名
     * 看接口文档
     */
    public static final Set<String> NEED_SIGN_PARAMS = ImmutableSet.of("P1_bizType", "P2_orderId",
            "P3_customerNumber", "P4_refundOrderId", "P5_amount", "P6_callbackUrl");
}
