1 package com.foxinmy.weixin4j.pay.payment.mch;
2
3 import com.foxinmy.weixin4j.util.Consts;
4 import com.foxinmy.weixin4j.util.DateUtil;
5 import com.foxinmy.weixin4j.util.MapUtil;
6
7 import java.io.UnsupportedEncodingException;
8 import java.net.URLEncoder;
9 import java.util.HashMap;
10 import java.util.Map;
11
12
13
14
15
16
17
18
19
20
21 public class RedpacketRisk {
22 private Map<String, String> risk;
23
24 public RedpacketRisk() {
25 this.risk = new HashMap<String, String>();
26 }
27
28
29
30
31
32
33 public RedpacketRisk postTimestamp() {
34 risk.put("posttime", DateUtil.timestamp2string());
35 return this;
36 }
37
38
39
40
41
42
43
44 public RedpacketRisk mobile(String mobile) {
45 risk.put("mobile", mobile);
46 return this;
47 }
48
49
50
51
52
53
54
55 public RedpacketRisk clientVersion(String clientVersion) {
56 risk.put("clientversion", clientVersion);
57 return this;
58 }
59
60
61
62
63
64
65
66 public RedpacketRisk deviceid(String deviceid) {
67 risk.put("deviceid", deviceid);
68 return this;
69 }
70
71 public Map<String, String> getRisk() {
72 return risk;
73 }
74
75 public void setRisk(Map<String, String> risk) {
76 this.risk = risk;
77 }
78
79 public String toContent() {
80 if (risk.isEmpty())
81 return null;
82 try {
83 return URLEncoder.encode(MapUtil.toJoinString(risk, false, false),
84 Consts.UTF_8.name());
85 } catch (UnsupportedEncodingException e) {
86 return null;
87 }
88 }
89 }