package cn.pluss.platform.klk.entity;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.RandomUtil;
import cn.pluss.platform.yinsheng.ReqEntity;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.util.Date;

/**请求参数
 * @author lyf
 */
@Getter
@Setter
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class ReqKlkEntity {
    /**
     *  接入方交易请求发起的系统时间（秒） long timestamp = System.currentTimeMillis()/1000【必传】
     */
    private String timestamp;

    private final String appid = "OP00000354";
    /**
     * 12个字符的随机字符串【必传】
     */
    private final String nonceStr = "qazwsxedc987";

    private String charset = "utf-8";

    private String sign;
    /**
     * 加签用的证书序列号
     */
    private final String serialNo = "00dfba8194c41b84cf";

    private String version = "3.0";



    public static ReqKlkEntity get(String jsonString) {
        ReqKlkEntity entity = new ReqKlkEntity();
        entity.timestamp = String.valueOf(System.currentTimeMillis() / 1000);
        String format = "appid"+"\n"+"serialNo"+"\n"+"timeStamp"+"\n"+"nonceStr"+"\n"+"body"+"\n";
        entity.sign = format.replace("appid", entity.appid).replace("serialNo", entity.serialNo)
                  .replace("timeStamp", entity.timestamp).replace("nonceStr",entity.nonceStr)
                  .replace("body",jsonString);
        return entity;
    }

    public static void main(String[] args) {
        System.out.println(get("req_data\": {\n" +
                "        \"member_id\": \"AAA200154561278\",\n" +
                "        \"mer_order_id\": \"202112030923011\"\n" +
                "    }\n"));
    }
}