Showing
12 changed files
with
496 additions
and
0 deletions
1 | +package com.cjs.site.model.sand; | ||
2 | + | ||
3 | +import java.io.Serializable; | ||
4 | + | ||
5 | +/** | ||
6 | + * Created by bruce on 2019-04-22 15:22 | ||
7 | + */ | ||
8 | +public class PayRequest implements Serializable { | ||
9 | + | ||
10 | + private static final long serialVersionUID = -684989773316236069L; | ||
11 | + | ||
12 | + private String payTool; | ||
13 | + private String orderCode; | ||
14 | + private String totalAmount; | ||
15 | + private String subject; | ||
16 | + private String notifyUrl; | ||
17 | + private String extend; | ||
18 | + | ||
19 | + public String getPayTool() { | ||
20 | + return payTool; | ||
21 | + } | ||
22 | + | ||
23 | + public void setPayTool(String payTool) { | ||
24 | + this.payTool = payTool; | ||
25 | + } | ||
26 | + | ||
27 | + public String getOrderCode() { | ||
28 | + return orderCode; | ||
29 | + } | ||
30 | + | ||
31 | + public void setOrderCode(String orderCode) { | ||
32 | + this.orderCode = orderCode; | ||
33 | + } | ||
34 | + | ||
35 | + public String getTotalAmount() { | ||
36 | + return totalAmount; | ||
37 | + } | ||
38 | + | ||
39 | + public void setTotalAmount(String totalAmount) { | ||
40 | + this.totalAmount = totalAmount; | ||
41 | + } | ||
42 | + | ||
43 | + public String getSubject() { | ||
44 | + return subject; | ||
45 | + } | ||
46 | + | ||
47 | + public void setSubject(String subject) { | ||
48 | + this.subject = subject; | ||
49 | + } | ||
50 | + | ||
51 | + public String getNotifyUrl() { | ||
52 | + return notifyUrl; | ||
53 | + } | ||
54 | + | ||
55 | + public void setNotifyUrl(String notifyUrl) { | ||
56 | + this.notifyUrl = notifyUrl; | ||
57 | + } | ||
58 | + | ||
59 | + public String getExtend() { | ||
60 | + return extend; | ||
61 | + } | ||
62 | + | ||
63 | + public void setExtend(String extend) { | ||
64 | + this.extend = extend; | ||
65 | + } | ||
66 | +} |
1 | +package com.cjs.site.model.sand; | ||
2 | + | ||
3 | +import java.io.Serializable; | ||
4 | + | ||
5 | +/** | ||
6 | + * Created by bruce on 2019-04-23 10:57 | ||
7 | + */ | ||
8 | +public class PayResponse implements Serializable { | ||
9 | + | ||
10 | + private static final long serialVersionUID = 6091779814488467202L; | ||
11 | + | ||
12 | + private String orderCode; | ||
13 | + private String totalAmount; | ||
14 | + private String qrCode; | ||
15 | + private String merchExtendParams; | ||
16 | + | ||
17 | + public String getOrderCode() { | ||
18 | + return orderCode; | ||
19 | + } | ||
20 | + | ||
21 | + public void setOrderCode(String orderCode) { | ||
22 | + this.orderCode = orderCode; | ||
23 | + } | ||
24 | + | ||
25 | + public String getTotalAmount() { | ||
26 | + return totalAmount; | ||
27 | + } | ||
28 | + | ||
29 | + public void setTotalAmount(String totalAmount) { | ||
30 | + this.totalAmount = totalAmount; | ||
31 | + } | ||
32 | + | ||
33 | + public String getQrCode() { | ||
34 | + return qrCode; | ||
35 | + } | ||
36 | + | ||
37 | + public void setQrCode(String qrCode) { | ||
38 | + this.qrCode = qrCode; | ||
39 | + } | ||
40 | + | ||
41 | + public String getMerchExtendParams() { | ||
42 | + return merchExtendParams; | ||
43 | + } | ||
44 | + | ||
45 | + public void setMerchExtendParams(String merchExtendParams) { | ||
46 | + this.merchExtendParams = merchExtendParams; | ||
47 | + } | ||
48 | +} |
1 | +package com.cjs.site.model.sand; | ||
2 | + | ||
3 | +import java.io.Serializable; | ||
4 | + | ||
5 | +/** | ||
6 | + * Created by bruce on 2019-04-22 15:15 | ||
7 | + */ | ||
8 | +public class RequestHead implements Serializable { | ||
9 | + | ||
10 | + private static final long serialVersionUID = 7473550115648267063L; | ||
11 | + | ||
12 | + private String version = "1.0"; | ||
13 | + private String method; | ||
14 | + private String mid; | ||
15 | + private String reqTime; | ||
16 | + | ||
17 | + public String getVersion() { | ||
18 | + return version; | ||
19 | + } | ||
20 | + | ||
21 | + public void setVersion(String version) { | ||
22 | + this.version = version; | ||
23 | + } | ||
24 | + | ||
25 | + public String getMethod() { | ||
26 | + return method; | ||
27 | + } | ||
28 | + | ||
29 | + public void setMethod(String method) { | ||
30 | + this.method = method; | ||
31 | + } | ||
32 | + | ||
33 | + public String getMid() { | ||
34 | + return mid; | ||
35 | + } | ||
36 | + | ||
37 | + public void setMid(String mid) { | ||
38 | + this.mid = mid; | ||
39 | + } | ||
40 | + | ||
41 | + public String getReqTime() { | ||
42 | + return reqTime; | ||
43 | + } | ||
44 | + | ||
45 | + public void setReqTime(String reqTime) { | ||
46 | + this.reqTime = reqTime; | ||
47 | + } | ||
48 | +} |
1 | +package com.cjs.site.model.sand; | ||
2 | + | ||
3 | +import java.io.Serializable; | ||
4 | + | ||
5 | +/** | ||
6 | + * Created by bruce on 2019-04-22 15:17 | ||
7 | + */ | ||
8 | +public class ResponseHead implements Serializable{ | ||
9 | + | ||
10 | + private static final long serialVersionUID = 240250866504894146L; | ||
11 | + | ||
12 | + private String version; | ||
13 | + private String respCode; | ||
14 | + private String respMsg; | ||
15 | + private String respTime; | ||
16 | + | ||
17 | + public String getVersion() { | ||
18 | + return version; | ||
19 | + } | ||
20 | + | ||
21 | + public void setVersion(String version) { | ||
22 | + this.version = version; | ||
23 | + } | ||
24 | + | ||
25 | + public String getRespCode() { | ||
26 | + return respCode; | ||
27 | + } | ||
28 | + | ||
29 | + public void setRespCode(String respCode) { | ||
30 | + this.respCode = respCode; | ||
31 | + } | ||
32 | + | ||
33 | + public String getRespMsg() { | ||
34 | + return respMsg; | ||
35 | + } | ||
36 | + | ||
37 | + public void setRespMsg(String respMsg) { | ||
38 | + this.respMsg = respMsg; | ||
39 | + } | ||
40 | + | ||
41 | + public String getRespTime() { | ||
42 | + return respTime; | ||
43 | + } | ||
44 | + | ||
45 | + public void setRespTime(String respTime) { | ||
46 | + this.respTime = respTime; | ||
47 | + } | ||
48 | +} |
1 | +package com.cjs.site.model.sand; | ||
2 | + | ||
3 | +import java.io.Serializable; | ||
4 | + | ||
5 | +/** | ||
6 | + * Created by bruce on 2019-04-22 15:07 | ||
7 | + */ | ||
8 | +public class SandRequest<T> implements Serializable { | ||
9 | + | ||
10 | + private static final long serialVersionUID = 7088026548440318367L; | ||
11 | + | ||
12 | + private RequestHead head; | ||
13 | + private T body; | ||
14 | + | ||
15 | + public RequestHead getHead() { | ||
16 | + return head; | ||
17 | + } | ||
18 | + | ||
19 | + public void setHead(RequestHead head) { | ||
20 | + this.head = head; | ||
21 | + } | ||
22 | + | ||
23 | + public T getBody() { | ||
24 | + return body; | ||
25 | + } | ||
26 | + | ||
27 | + public void setBody(T body) { | ||
28 | + this.body = body; | ||
29 | + } | ||
30 | +} |
1 | +package com.cjs.site.model.sand; | ||
2 | + | ||
3 | +import java.io.Serializable; | ||
4 | + | ||
5 | +/** | ||
6 | + * Created by bruce on 2019-04-22 15:04 | ||
7 | + */ | ||
8 | +public class SandResponse<T> implements Serializable { | ||
9 | + | ||
10 | + private static final long serialVersionUID = -487270155711328784L; | ||
11 | + | ||
12 | + private ResponseHead head; | ||
13 | + private T body; | ||
14 | + | ||
15 | + public ResponseHead getHead() { | ||
16 | + return head; | ||
17 | + } | ||
18 | + | ||
19 | + public void setHead(ResponseHead head) { | ||
20 | + this.head = head; | ||
21 | + } | ||
22 | + | ||
23 | + public T getBody() { | ||
24 | + return body; | ||
25 | + } | ||
26 | + | ||
27 | + public void setBody(T body) { | ||
28 | + this.body = body; | ||
29 | + } | ||
30 | +} |
... | @@ -34,6 +34,10 @@ public class OutpropApplyInfo extends BaseInfo { | ... | @@ -34,6 +34,10 @@ public class OutpropApplyInfo extends BaseInfo { |
34 | private Double packFee; //提货封装费 | 34 | private Double packFee; //提货封装费 |
35 | private Integer resultCode; //T2接口调用结果 | 35 | private Integer resultCode; //T2接口调用结果 |
36 | 36 | ||
37 | + /***********2019-04-18开发新需求添加字段************/ | ||
38 | + private Integer trusteeshipCycle;//托管周期 | ||
39 | + private Double warehousingCharges;//托管费用 | ||
40 | + | ||
37 | public String getPositionStr() { | 41 | public String getPositionStr() { |
38 | return positionStr; | 42 | return positionStr; |
39 | } | 43 | } |
... | @@ -210,4 +214,19 @@ public class OutpropApplyInfo extends BaseInfo { | ... | @@ -210,4 +214,19 @@ public class OutpropApplyInfo extends BaseInfo { |
210 | this.resultCode = resultCode; | 214 | this.resultCode = resultCode; |
211 | } | 215 | } |
212 | 216 | ||
217 | + public Integer getTrusteeshipCycle() { | ||
218 | + return trusteeshipCycle; | ||
219 | + } | ||
220 | + | ||
221 | + public void setTrusteeshipCycle(Integer trusteeshipCycle) { | ||
222 | + this.trusteeshipCycle = trusteeshipCycle; | ||
223 | + } | ||
224 | + | ||
225 | + public Double getWarehousingCharges() { | ||
226 | + return warehousingCharges; | ||
227 | + } | ||
228 | + | ||
229 | + public void setWarehousingCharges(Double warehousingCharges) { | ||
230 | + this.warehousingCharges = warehousingCharges; | ||
231 | + } | ||
213 | } | 232 | } | ... | ... |
1 | +package com.cjs.site.util.sand; | ||
2 | + | ||
3 | +import com.cjs.site.model.sand.*; | ||
4 | +import com.cjs.site.util.lang.JsonUtil; | ||
5 | +import org.apache.http.client.utils.DateUtils; | ||
6 | +import sun.misc.BASE64Decoder; | ||
7 | +import sun.misc.BASE64Encoder; | ||
8 | + | ||
9 | +import java.io.*; | ||
10 | +import java.net.URL; | ||
11 | +import java.net.URLConnection; | ||
12 | +import java.net.URLDecoder; | ||
13 | +import java.net.URLEncoder; | ||
14 | +import java.util.*; | ||
15 | + | ||
16 | +/** | ||
17 | + * Created by bruce on 2019-04-22 11:03 | ||
18 | + */ | ||
19 | +public class SandPayUtil { | ||
20 | + | ||
21 | + public static void main(String[] args) { | ||
22 | + SandRequest<PayRequest> request = new SandRequest<PayRequest>(); | ||
23 | + RequestHead head = new RequestHead(); | ||
24 | + head.setMethod("sandpay.trade.precreate"); | ||
25 | + head.setMid("9649413565184"); | ||
26 | + head.setReqTime(getReqTime()); | ||
27 | + request.setHead(head); | ||
28 | + | ||
29 | + PayRequest body = new PayRequest(); | ||
30 | + body.setNotifyUrl("http://192.168.16.167:8764/notify"); | ||
31 | + body.setOrderCode(randomChar()); | ||
32 | + body.setPayTool("0401"); | ||
33 | + body.setSubject("藏品支付"); | ||
34 | + body.setTotalAmount(convertAmount(0.01D)); | ||
35 | + body.setExtend("apply_no"); | ||
36 | + request.setBody(body); | ||
37 | + String json = sendPost("http://61.129.71.103:8003/qr/api/order/create", JsonUtil.toJson(request)); | ||
38 | + Map<String, String> map = string2Map(json); | ||
39 | + SandResponse response = JsonUtil.fromJson(map.get("data"), SandResponse.class); | ||
40 | + assert response != null; | ||
41 | + if (response.getHead().getRespCode().equals(SandConstans.SUCCESS_CODE)) { | ||
42 | + PayResponse payResponse = JsonUtil.fromJson(JsonUtil.toJson(response.getBody()), PayResponse.class); | ||
43 | + assert payResponse != null; | ||
44 | + System.out.println(payResponse); | ||
45 | + } else { | ||
46 | + System.out.println(response.getHead().getRespMsg()); | ||
47 | + } | ||
48 | + } | ||
49 | + | ||
50 | + public static String sendPost(String url, String data) { | ||
51 | + PrintWriter out = null; | ||
52 | + BufferedReader in = null; | ||
53 | + StringBuilder result = new StringBuilder(); | ||
54 | + | ||
55 | + Map<String, String> params = new HashMap<String, String>(); | ||
56 | + params.put("charset", "utf-8"); | ||
57 | + params.put("data", data); | ||
58 | + params.put("signType", "01"); | ||
59 | + params.put("sign", getBase64(data)); | ||
60 | + | ||
61 | + try { | ||
62 | + URL realUrl = new URL(url); | ||
63 | + URLConnection conn = realUrl.openConnection(); | ||
64 | + conn.setRequestProperty("accept", "*/*"); | ||
65 | + conn.setRequestProperty("connection", "Keep-Alive"); | ||
66 | + conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); | ||
67 | + conn.setDoOutput(true); | ||
68 | + conn.setDoInput(true); | ||
69 | + out = new PrintWriter(conn.getOutputStream()); | ||
70 | + out.print(map2String(params)); | ||
71 | + out.flush(); | ||
72 | + in = new BufferedReader(new InputStreamReader(conn.getInputStream())); | ||
73 | + String line; | ||
74 | + while ((line = in.readLine()) != null) { | ||
75 | + result.append(line); | ||
76 | + } | ||
77 | + } catch (Exception e) { | ||
78 | + e.printStackTrace(); | ||
79 | + result.append(e.getMessage()); | ||
80 | + } finally { | ||
81 | + try { | ||
82 | + if (out != null) { | ||
83 | + out.close(); | ||
84 | + } | ||
85 | + if (in != null) { | ||
86 | + in.close(); | ||
87 | + } | ||
88 | + } catch (IOException ex) { | ||
89 | + ex.printStackTrace(); | ||
90 | + } | ||
91 | + } | ||
92 | + try { | ||
93 | + return URLDecoder.decode(result.toString(), "utf-8"); | ||
94 | + } catch (UnsupportedEncodingException e) { | ||
95 | + e.printStackTrace(); | ||
96 | + return "转码出错"; | ||
97 | + } | ||
98 | + | ||
99 | + } | ||
100 | + | ||
101 | + private static String getReqTime() { | ||
102 | + return DateUtils.formatDate(new Date(), "yyyyMMddHHmm"); | ||
103 | + } | ||
104 | + | ||
105 | + private static String convertAmount(Double amount) { | ||
106 | + Double result = amount * 100; | ||
107 | + return String.format("%012d", result.intValue()); | ||
108 | + } | ||
109 | + | ||
110 | + private static String getBase64(String str) { | ||
111 | + byte[] b = null; | ||
112 | + String s = null; | ||
113 | + try { | ||
114 | + b = str.getBytes("utf-8"); | ||
115 | + } catch (UnsupportedEncodingException e) { | ||
116 | + e.printStackTrace(); | ||
117 | + } | ||
118 | + if (b != null) { | ||
119 | + s = new BASE64Encoder().encode(b); | ||
120 | + } | ||
121 | + return s; | ||
122 | + } | ||
123 | + | ||
124 | + private static String getFromBase64(String s) { | ||
125 | + byte[] b; | ||
126 | + String result = null; | ||
127 | + if (s != null) { | ||
128 | + BASE64Decoder decoder = new BASE64Decoder(); | ||
129 | + try { | ||
130 | + b = decoder.decodeBuffer(s); | ||
131 | + result = new String(b, "utf-8"); | ||
132 | + } catch (Exception e) { | ||
133 | + e.printStackTrace(); | ||
134 | + } | ||
135 | + } | ||
136 | + return result; | ||
137 | + } | ||
138 | + | ||
139 | + private static String map2String(Map<String, String> params) { | ||
140 | + List<String> keys = new ArrayList<String>(params.keySet()); | ||
141 | + Collections.sort(keys); | ||
142 | + StringBuilder prestr = new StringBuilder(); | ||
143 | + for (int i = 0; i < keys.size(); i++) { | ||
144 | + String key = keys.get(i); | ||
145 | + String value = params.get(key); | ||
146 | + try { | ||
147 | + value = URLEncoder.encode(value, "UTF-8"); | ||
148 | + } catch (UnsupportedEncodingException e) { | ||
149 | + e.printStackTrace(); | ||
150 | + } | ||
151 | + if (i == keys.size() - 1) { | ||
152 | + prestr.append(key).append("=").append(value); | ||
153 | + } else { | ||
154 | + prestr.append(key).append("=").append(value).append("&"); | ||
155 | + } | ||
156 | + } | ||
157 | + return prestr.toString(); | ||
158 | + } | ||
159 | + | ||
160 | + public static Map<String, String> string2Map(String str) { | ||
161 | + if (null == str || "".equals(str)) { | ||
162 | + return null; | ||
163 | + } | ||
164 | + String[] strings = str.split("&"); | ||
165 | + int mapLength = strings.length; | ||
166 | + if ((strings.length % 2) != 0) { | ||
167 | + mapLength = mapLength + 1; | ||
168 | + } | ||
169 | + | ||
170 | + Map<String, String> map = new HashMap<String, String>(mapLength); | ||
171 | + for (String string : strings) { | ||
172 | + String[] strArray = string.split("="); | ||
173 | + map.put(strArray[0], strArray[1]); | ||
174 | + } | ||
175 | + return map; | ||
176 | + } | ||
177 | + | ||
178 | + private static String randomChar() { | ||
179 | + return UUID.randomUUID().toString().replace("-", ""); | ||
180 | + } | ||
181 | + | ||
182 | +} |
... | @@ -50,6 +50,8 @@ | ... | @@ -50,6 +50,8 @@ |
50 | <th class="left-font">藏品名称</th> | 50 | <th class="left-font">藏品名称</th> |
51 | <th>可提数量</th> | 51 | <th>可提数量</th> |
52 | <th>提货数量</th> | 52 | <th>提货数量</th> |
53 | + <th>托管周期(天)</th> | ||
54 | + <th>仓储费(元)</th> | ||
53 | <c:if test="${pack == '1' }"> | 55 | <c:if test="${pack == '1' }"> |
54 | <th>封装方式</th> | 56 | <th>封装方式</th> |
55 | <th>封装费用</th> | 57 | <th>封装费用</th> |
... | @@ -63,6 +65,8 @@ | ... | @@ -63,6 +65,8 @@ |
63 | <td class="left-font">${pick.otcName }</td> | 65 | <td class="left-font">${pick.otcName }</td> |
64 | <td>${pick.enableAmount }</td> | 66 | <td>${pick.enableAmount }</td> |
65 | <td>${pick.occurAmount }</td> | 67 | <td>${pick.occurAmount }</td> |
68 | + <th>300</th> | ||
69 | + <th>300</th> | ||
66 | <c:if test="${pack == '1' }"> | 70 | <c:if test="${pack == '1' }"> |
67 | <td>${pick.packType }</td> | 71 | <td>${pick.packType }</td> |
68 | <td><fmt:formatNumber pattern="###.00" value="${pick.packFee }" /> 元/个</td> | 72 | <td><fmt:formatNumber pattern="###.00" value="${pick.packFee }" /> 元/个</td> | ... | ... |
... | @@ -89,6 +89,8 @@ | ... | @@ -89,6 +89,8 @@ |
89 | <th class="left-font">藏品名称</th> | 89 | <th class="left-font">藏品名称</th> |
90 | <th>可提数量</th> | 90 | <th>可提数量</th> |
91 | <th>提货数量</th> | 91 | <th>提货数量</th> |
92 | + <th>托管周期(天)</th> | ||
93 | + <th>仓储费(元)</th> | ||
92 | <c:if test="${pack == '1' }"> | 94 | <c:if test="${pack == '1' }"> |
93 | <th>封装方式</th> | 95 | <th>封装方式</th> |
94 | <th>封装费用</th> | 96 | <th>封装费用</th> |
... | @@ -102,6 +104,8 @@ | ... | @@ -102,6 +104,8 @@ |
102 | <td class="left-font">${pick.otcName }</td> | 104 | <td class="left-font">${pick.otcName }</td> |
103 | <td>${pick.enableAmount }</td> | 105 | <td>${pick.enableAmount }</td> |
104 | <td>${pick.occurAmount }</td> | 106 | <td>${pick.occurAmount }</td> |
107 | + <th>300</th> | ||
108 | + <th>300</th> | ||
105 | <c:if test="${pack == '1' }"> | 109 | <c:if test="${pack == '1' }"> |
106 | <td>${pick.packType }</td> | 110 | <td>${pick.packType }</td> |
107 | <td><fmt:formatNumber pattern="###.00" value="${pick.packFee }" /> 元/个</td> | 111 | <td><fmt:formatNumber pattern="###.00" value="${pick.packFee }" /> 元/个</td> | ... | ... |
... | @@ -65,6 +65,9 @@ | ... | @@ -65,6 +65,9 @@ |
65 | <th class="left-font">藏品名称</th> | 65 | <th class="left-font">藏品名称</th> |
66 | <th>可提数量</th> | 66 | <th>可提数量</th> |
67 | <th>提货数量</th> | 67 | <th>提货数量</th> |
68 | + <th>仓储单价</th> | ||
69 | + <th>托管周期(天)</th> | ||
70 | + <th>仓储费(元)</th> | ||
68 | <c:if test="${pack == '1' }"> | 71 | <c:if test="${pack == '1' }"> |
69 | <th>封装方式</th> | 72 | <th>封装方式</th> |
70 | <th>封装费用</th> | 73 | <th>封装费用</th> |
... | @@ -78,6 +81,9 @@ | ... | @@ -78,6 +81,9 @@ |
78 | <td class="left-font">${pick.otcName }</td> | 81 | <td class="left-font">${pick.otcName }</td> |
79 | <td>${pick.enableAmount }</td> | 82 | <td>${pick.enableAmount }</td> |
80 | <td>${pick.occurAmount }</td> | 83 | <td>${pick.occurAmount }</td> |
84 | + <th>0.01元/件</th> | ||
85 | + <th>300</th> | ||
86 | + <th>300</th> | ||
81 | <c:if test="${pack == '1' }"> | 87 | <c:if test="${pack == '1' }"> |
82 | <td>${pick.packType }</td> | 88 | <td>${pick.packType }</td> |
83 | <td><fmt:formatNumber pattern="###.00" value="${pick.packFee }" /> 元/个</td> | 89 | <td><fmt:formatNumber pattern="###.00" value="${pick.packFee }" /> 元/个</td> | ... | ... |
-
Please register or login to post a comment