zm
2020-05-18 a18bfacbf56b401f6e0fdae8710fbca4df8cff77
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package com.changhong.epc.rely.api.tool;
 
import java.util.Map;
import java.util.Random;
import java.util.TreeMap;
 
import com.iemsoft.framework.cloud.core.password.MD5;
import com.iemsoft.framework.cloud.core.tools.DateTool;
 
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class TheThirdParty {
    public static Map<String, Object> getParam(Map<String, Object> p,com.changhong.epc.constter.system.Service se){
        Map<String, Object> param = new TreeMap<>(p);
        param.put("id", se.getAccessId() /*"1000000"*/+ DateTool.currentFormatDate(DateTool.DATE_TO_STRING_SHORT_PATTERN) + String.format("%09d", new Random().nextInt(999999999)));
        param.put("sign", countSign(param,se));
        return param;
    }
    
    
    protected static String countSign(Map<String, Object> param,com.changhong.epc.constter.system.Service se) {
        StringBuilder sb = new StringBuilder();
        for (Map.Entry<String, Object> map : param.entrySet()) {
            /* 拼接条件 */
            sb.append(map.getKey())
                .append('=')
                .append(map.getValue())
                .append('&');    
        }
        sb.append("key=").append(se.getSecurityKey());
        log.debug("加密参数为:\n{}",sb);
        log.debug("加密后的参数:\n{}",MD5.toMD5(sb.toString()));
        return MD5.toMD5(sb.toString());
    }
    
//    public static ChangHongProperties getProp(){
//        return SpringUtil.getBean(ChangHongProperties.class);
//    }
}