package com.younike.hlpay.dto;

import com.google.common.collect.ImmutableSet;
import com.younike.common.utils.StringUtils;
import com.younike.hlpay.constant.HeliPayContants;
import com.younike.hlpay.util.DesUtils;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.util.Set;

@Setter
@Getter
@ToString
public class AppPayPublicCreateOrderVo {


    private String P1_bizType;
    private String P2_orderId;
    private String P3_customerNumber;
    private String P4_payType;
    private String P5_appid;
    private String P6_deviceInfo;
    private String P7_isRaw;
    private String P8_openid;
    private String P9_orderAmount;
    private String P10_currency;
    private String P11_appType;
    private String P12_notifyUrl;
    private String P13_successToUrl;
    private String P14_orderIp;
    private String P15_goodsName;
    private String P16_goodsDetail;
    private String P17_limitCreditPay;
    private String P18_desc;
    private String P19_subscribeAppId;
    /**特殊参数,排除签名*/
    private String P20_subMerchantId;
    private String P21_goodsTag;
    private String P22_guid;
    private String P23_marketingRule;
    private String timeExpire;
    /**支付宝行业数据回流信息,排除签名*/
    private String industryRefluxInfo;
    /**支付宝点餐码 排除签名*/
    private String foodOrderType;
    /**排除签名*/
    private String termInfo;
    /**
     * 银联js用户id类型
     * userAuthCode:表示为临时授权码;openId:表示为用户id
     * 不送默认是userAuthCode
     * 排除签名
     */
    private String openIdType;
    /**商户自定义门店编码,排除签名*/
    private String storeId;
    private String ruleJson;
    private String splitBillType;
    private String sign;

    public void setRuleJson(String ruleJson) {
        System.out.println("ruleJson 明文 result:" + 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 void setP23MarketingRule(String p23MarketingRule) {
        System.out.println("p23MarketingRule 明文 result:" + p23MarketingRule);
        if (StringUtils.isNotBlank(p23MarketingRule)) {
            try {
                p23MarketingRule = DesUtils.encode(HeliPayContants.DES_APPPAY, p23MarketingRule);
            } catch (Exception e) {
                System.out.println("error:" + e.getMessage());
            }
            System.out.println("p23MarketingRule 3des result:" + p23MarketingRule);
        }
        this.P23_marketingRule = p23MarketingRule;
    }

    /**
     * 需要加签的属性参数,要求加签的参数空值也签名
     * 看接口文档
     */
    public static final Set<String> NEED_SIGN_PARAMS = ImmutableSet.of("P1_bizType", "P2_orderId", "P3_customerNumber",
            "P4_payType", "P5_appid", "P6_deviceInfo", "P7_isRaw", "P8_openid", "P9_orderAmount", "P10_currency",
            "P11_appType", "P12_notifyUrl", "P13_successToUrl", "P14_orderIp", "P15_goodsName", "P16_goodsDetail", "P17_limitCreditPay",
            "P18_desc");
}
