cp199108@163.com

仓管费

package com.cjs.site.model.sand;
import java.io.Serializable;
/**
* Created by bruce on 2019-04-22 15:22
*/
public class PayRequest implements Serializable {
private static final long serialVersionUID = -684989773316236069L;
private String payTool;
private String orderCode;
private String totalAmount;
private String subject;
private String notifyUrl;
private String extend;
public String getPayTool() {
return payTool;
}
public void setPayTool(String payTool) {
this.payTool = payTool;
}
public String getOrderCode() {
return orderCode;
}
public void setOrderCode(String orderCode) {
this.orderCode = orderCode;
}
public String getTotalAmount() {
return totalAmount;
}
public void setTotalAmount(String totalAmount) {
this.totalAmount = totalAmount;
}
public String getSubject() {
return subject;
}
public void setSubject(String subject) {
this.subject = subject;
}
public String getNotifyUrl() {
return notifyUrl;
}
public void setNotifyUrl(String notifyUrl) {
this.notifyUrl = notifyUrl;
}
public String getExtend() {
return extend;
}
public void setExtend(String extend) {
this.extend = extend;
}
}
package com.cjs.site.model.sand;
import java.io.Serializable;
/**
* Created by bruce on 2019-04-23 10:57
*/
public class PayResponse implements Serializable {
private static final long serialVersionUID = 6091779814488467202L;
private String orderCode;
private String totalAmount;
private String qrCode;
private String merchExtendParams;
public String getOrderCode() {
return orderCode;
}
public void setOrderCode(String orderCode) {
this.orderCode = orderCode;
}
public String getTotalAmount() {
return totalAmount;
}
public void setTotalAmount(String totalAmount) {
this.totalAmount = totalAmount;
}
public String getQrCode() {
return qrCode;
}
public void setQrCode(String qrCode) {
this.qrCode = qrCode;
}
public String getMerchExtendParams() {
return merchExtendParams;
}
public void setMerchExtendParams(String merchExtendParams) {
this.merchExtendParams = merchExtendParams;
}
}
package com.cjs.site.model.sand;
import java.io.Serializable;
/**
* Created by bruce on 2019-04-22 15:15
*/
public class RequestHead implements Serializable {
private static final long serialVersionUID = 7473550115648267063L;
private String version = "1.0";
private String method;
private String mid;
private String reqTime;
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public String getMethod() {
return method;
}
public void setMethod(String method) {
this.method = method;
}
public String getMid() {
return mid;
}
public void setMid(String mid) {
this.mid = mid;
}
public String getReqTime() {
return reqTime;
}
public void setReqTime(String reqTime) {
this.reqTime = reqTime;
}
}
package com.cjs.site.model.sand;
import java.io.Serializable;
/**
* Created by bruce on 2019-04-22 15:17
*/
public class ResponseHead implements Serializable{
private static final long serialVersionUID = 240250866504894146L;
private String version;
private String respCode;
private String respMsg;
private String respTime;
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public String getRespCode() {
return respCode;
}
public void setRespCode(String respCode) {
this.respCode = respCode;
}
public String getRespMsg() {
return respMsg;
}
public void setRespMsg(String respMsg) {
this.respMsg = respMsg;
}
public String getRespTime() {
return respTime;
}
public void setRespTime(String respTime) {
this.respTime = respTime;
}
}
package com.cjs.site.model.sand;
import java.io.Serializable;
/**
* Created by bruce on 2019-04-22 15:07
*/
public class SandRequest<T> implements Serializable {
private static final long serialVersionUID = 7088026548440318367L;
private RequestHead head;
private T body;
public RequestHead getHead() {
return head;
}
public void setHead(RequestHead head) {
this.head = head;
}
public T getBody() {
return body;
}
public void setBody(T body) {
this.body = body;
}
}
package com.cjs.site.model.sand;
import java.io.Serializable;
/**
* Created by bruce on 2019-04-22 15:04
*/
public class SandResponse<T> implements Serializable {
private static final long serialVersionUID = -487270155711328784L;
private ResponseHead head;
private T body;
public ResponseHead getHead() {
return head;
}
public void setHead(ResponseHead head) {
this.head = head;
}
public T getBody() {
return body;
}
public void setBody(T body) {
this.body = body;
}
}
......@@ -34,6 +34,10 @@ public class OutpropApplyInfo extends BaseInfo {
private Double packFee; //提货封装费
private Integer resultCode; //T2接口调用结果
/***********2019-04-18开发新需求添加字段************/
private Integer trusteeshipCycle;//托管周期
private Double warehousingCharges;//托管费用
public String getPositionStr() {
return positionStr;
}
......@@ -210,4 +214,19 @@ public class OutpropApplyInfo extends BaseInfo {
this.resultCode = resultCode;
}
public Integer getTrusteeshipCycle() {
return trusteeshipCycle;
}
public void setTrusteeshipCycle(Integer trusteeshipCycle) {
this.trusteeshipCycle = trusteeshipCycle;
}
public Double getWarehousingCharges() {
return warehousingCharges;
}
public void setWarehousingCharges(Double warehousingCharges) {
this.warehousingCharges = warehousingCharges;
}
}
......
package com.cjs.site.util.sand;
/**
* Created by bruce on 2019-04-23 15:01
*/
public class SandConstans {
//衫德支付返回成功code码
public final static String SUCCESS_CODE = "000000";
}
package com.cjs.site.util.sand;
import com.cjs.site.model.sand.*;
import com.cjs.site.util.lang.JsonUtil;
import org.apache.http.client.utils.DateUtils;
import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;
import java.io.*;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.util.*;
/**
* Created by bruce on 2019-04-22 11:03
*/
public class SandPayUtil {
public static void main(String[] args) {
SandRequest<PayRequest> request = new SandRequest<PayRequest>();
RequestHead head = new RequestHead();
head.setMethod("sandpay.trade.precreate");
head.setMid("9649413565184");
head.setReqTime(getReqTime());
request.setHead(head);
PayRequest body = new PayRequest();
body.setNotifyUrl("http://192.168.16.167:8764/notify");
body.setOrderCode(randomChar());
body.setPayTool("0401");
body.setSubject("藏品支付");
body.setTotalAmount(convertAmount(0.01D));
body.setExtend("apply_no");
request.setBody(body);
String json = sendPost("http://61.129.71.103:8003/qr/api/order/create", JsonUtil.toJson(request));
Map<String, String> map = string2Map(json);
SandResponse response = JsonUtil.fromJson(map.get("data"), SandResponse.class);
assert response != null;
if (response.getHead().getRespCode().equals(SandConstans.SUCCESS_CODE)) {
PayResponse payResponse = JsonUtil.fromJson(JsonUtil.toJson(response.getBody()), PayResponse.class);
assert payResponse != null;
System.out.println(payResponse);
} else {
System.out.println(response.getHead().getRespMsg());
}
}
public static String sendPost(String url, String data) {
PrintWriter out = null;
BufferedReader in = null;
StringBuilder result = new StringBuilder();
Map<String, String> params = new HashMap<String, String>();
params.put("charset", "utf-8");
params.put("data", data);
params.put("signType", "01");
params.put("sign", getBase64(data));
try {
URL realUrl = new URL(url);
URLConnection conn = realUrl.openConnection();
conn.setRequestProperty("accept", "*/*");
conn.setRequestProperty("connection", "Keep-Alive");
conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
conn.setDoOutput(true);
conn.setDoInput(true);
out = new PrintWriter(conn.getOutputStream());
out.print(map2String(params));
out.flush();
in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line;
while ((line = in.readLine()) != null) {
result.append(line);
}
} catch (Exception e) {
e.printStackTrace();
result.append(e.getMessage());
} finally {
try {
if (out != null) {
out.close();
}
if (in != null) {
in.close();
}
} catch (IOException ex) {
ex.printStackTrace();
}
}
try {
return URLDecoder.decode(result.toString(), "utf-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
return "转码出错";
}
}
private static String getReqTime() {
return DateUtils.formatDate(new Date(), "yyyyMMddHHmm");
}
private static String convertAmount(Double amount) {
Double result = amount * 100;
return String.format("%012d", result.intValue());
}
private static String getBase64(String str) {
byte[] b = null;
String s = null;
try {
b = str.getBytes("utf-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
if (b != null) {
s = new BASE64Encoder().encode(b);
}
return s;
}
private static String getFromBase64(String s) {
byte[] b;
String result = null;
if (s != null) {
BASE64Decoder decoder = new BASE64Decoder();
try {
b = decoder.decodeBuffer(s);
result = new String(b, "utf-8");
} catch (Exception e) {
e.printStackTrace();
}
}
return result;
}
private static String map2String(Map<String, String> params) {
List<String> keys = new ArrayList<String>(params.keySet());
Collections.sort(keys);
StringBuilder prestr = new StringBuilder();
for (int i = 0; i < keys.size(); i++) {
String key = keys.get(i);
String value = params.get(key);
try {
value = URLEncoder.encode(value, "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
if (i == keys.size() - 1) {
prestr.append(key).append("=").append(value);
} else {
prestr.append(key).append("=").append(value).append("&");
}
}
return prestr.toString();
}
public static Map<String, String> string2Map(String str) {
if (null == str || "".equals(str)) {
return null;
}
String[] strings = str.split("&");
int mapLength = strings.length;
if ((strings.length % 2) != 0) {
mapLength = mapLength + 1;
}
Map<String, String> map = new HashMap<String, String>(mapLength);
for (String string : strings) {
String[] strArray = string.split("=");
map.put(strArray[0], strArray[1]);
}
return map;
}
private static String randomChar() {
return UUID.randomUUID().toString().replace("-", "");
}
}
......@@ -50,6 +50,8 @@
<th class="left-font">藏品名称</th>
<th>可提数量</th>
<th>提货数量</th>
<th>托管周期(天)</th>
<th>仓储费(元)</th>
<c:if test="${pack == '1' }">
<th>封装方式</th>
<th>封装费用</th>
......@@ -63,6 +65,8 @@
<td class="left-font">${pick.otcName }</td>
<td>${pick.enableAmount }</td>
<td>${pick.occurAmount }</td>
<th>300</th>
<th>300</th>
<c:if test="${pack == '1' }">
<td>${pick.packType }</td>
<td><fmt:formatNumber pattern="###.00" value="${pick.packFee }" />&nbsp;元/个</td>
......
......@@ -89,6 +89,8 @@
<th class="left-font">藏品名称</th>
<th>可提数量</th>
<th>提货数量</th>
<th>托管周期(天)</th>
<th>仓储费(元)</th>
<c:if test="${pack == '1' }">
<th>封装方式</th>
<th>封装费用</th>
......@@ -102,6 +104,8 @@
<td class="left-font">${pick.otcName }</td>
<td>${pick.enableAmount }</td>
<td>${pick.occurAmount }</td>
<th>300</th>
<th>300</th>
<c:if test="${pack == '1' }">
<td>${pick.packType }</td>
<td><fmt:formatNumber pattern="###.00" value="${pick.packFee }" />&nbsp;元/个</td>
......
......@@ -65,6 +65,9 @@
<th class="left-font">藏品名称</th>
<th>可提数量</th>
<th>提货数量</th>
<th>仓储单价</th>
<th>托管周期(天)</th>
<th>仓储费(元)</th>
<c:if test="${pack == '1' }">
<th>封装方式</th>
<th>封装费用</th>
......@@ -78,6 +81,9 @@
<td class="left-font">${pick.otcName }</td>
<td>${pick.enableAmount }</td>
<td>${pick.occurAmount }</td>
<th>0.01元/件</th>
<th>300</th>
<th>300</th>
<c:if test="${pack == '1' }">
<td>${pick.packType }</td>
<td><fmt:formatNumber pattern="###.00" value="${pick.packFee }" />&nbsp;元/个</td>
......