package com.jeequan.jeepay.thirdparty.channel.flpay.model;


import cn.hutool.core.util.RandomUtil;
import com.alibaba.fastjson.JSONObject;
import lombok.Getter;
import lombok.Setter;

import java.util.HashMap;
import java.util.Map;

/**
 * TODO
 * 福禄公共参数请求封装
 * @author crystal
 * @date 2024/2/29 11:53
 */
@Setter
@Getter
public class ReqEntity {


    /**
     *appid
     */
    private String appId;

    /**
     * 时间戳
     */
    private String timestamp;

    /**
     * 随机字符串
     */
    private String nonce;

    /**
     * 请求唯一表示，代表订单号 长度不能超过12
     */
    private String sign;

    /**
     * 请求回调地址
     */
    private String bizContent;


    public ReqEntity(String appId, JSONObject bizData) {
        this.appId = appId;
        this.nonce = RandomUtil.randomString(20);
        if(bizData != null){
            this.bizContent = bizData.toJSONString();
        }else{
            this.bizContent = "{}";
        }
        String timestamp = System.currentTimeMillis() + "";
        this.timestamp = timestamp;
    }

    public Map<String, Object> toMap() {
        Map<String, Object> params = new HashMap<>(5);
        params.put("appId",this.appId);
        params.put("timestamp",this.timestamp);
        params.put("nonce",this.nonce);
        params.put("bizContent",this.bizContent);
        return params;
    }
}
