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

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.RandomUtil;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.io.Serializable;
import java.util.Date;

@Setter
@Getter
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class ReqEntity implements Serializable {

    private String timeStamp;

    private String method;

    private String charset = "utf-8";

    private String sign;

    private String check;

    private String bizContent;

    private String reqId;

    private String certId = "826521773920170";

    private String version = "1.1";

    public static ReqEntity get(ReqMethod.Method reqMethod) {
        Date date = new Date();
        ReqEntity entity = new ReqEntity();
        entity.timeStamp = DateUtil.format(date, "yyyy-MM-dd HH:mm:ss");
        entity.method = reqMethod.getMethod();
        entity.reqId = "SYB_" + RandomUtil.randomString(4) + DateUtil.format(date, "yyMMddHHmmss");
        entity.setVersion(reqMethod.getVersion());
        return entity;
    }
}
