package com.younike.common.utils.sign;

import com.younike.common.utils.integral.MyStringUtil;
import org.springframework.util.DigestUtils;

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

/**
 * 签名验证参数
 * 2021-9-11 Another
 */
public class SignUtils {


    /**
     * 2021-9-11 Another 获取 调用骑手端对外接口 请求头参数
     * @return
     */
    public static Map<String, String> getDeliverHeaderParam() {
        Map<String, String> map = new HashMap<>();
        String timestamp = System.currentTimeMillis() + "";
        map.put("merchantNo", "1");    // 骑手端数据库 优鲜信 的商户号设置的1，这边固定传1，若修改要对应一起修改
        map.put("timestamp", timestamp);

        // 获取 sign
        Map<String, String> params = new HashMap<>();
        params.put("merchantNo", "1");
        params.put("time_stamp", timestamp);
        String paramStr = MyStringUtil.mapSort(params).toString();
        String mySign = DigestUtils.md5DigestAsHex(paramStr.getBytes());

        map.put("sign", mySign);

        return map;
    }

}
