generated from root/miduo_server
游心sdk
parent
a42c363e0c
commit
13c257c3b7
|
@ -0,0 +1,97 @@
|
||||||
|
package com.jmfy.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import com.jmfy.paramBean.PaySdkEnum;
|
||||||
|
|
||||||
|
import com.jmfy.paramBean.YxylParamBean;
|
||||||
|
import com.jmfy.util.JsonUtil;
|
||||||
|
import com.jmfy.util.MD5Util;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
public class YxylRechargeController {
|
||||||
|
@Resource
|
||||||
|
private PayLogic payLogic;
|
||||||
|
|
||||||
|
private static String PAYKEY = "3060c6296167c105ab19bfa1c2197c1a";
|
||||||
|
|
||||||
|
private static final Logger LOGGER = LoggerFactory.getLogger(YxylRechargeController.class);
|
||||||
|
|
||||||
|
|
||||||
|
@RequestMapping(value = "/YxylCallback")
|
||||||
|
public String YxylCallback(HttpServletRequest request) throws Exception {
|
||||||
|
return process(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String process(HttpServletRequest request) throws IOException {
|
||||||
|
|
||||||
|
HashMap<String, String> parameterMap = JsonUtil.getInstence().getParameterMap2(request);
|
||||||
|
if (parameterMap.isEmpty()) {
|
||||||
|
LOGGER.info("data is null");
|
||||||
|
return "fail";
|
||||||
|
}
|
||||||
|
String response;
|
||||||
|
try {
|
||||||
|
YxylParamBean paramBean = getData(parameterMap);
|
||||||
|
String mySign = getMySign(paramBean);
|
||||||
|
if (!paramBean.getSign().equals(mySign)) {
|
||||||
|
LOGGER.info("sign err");
|
||||||
|
return "sign";
|
||||||
|
}
|
||||||
|
response = insertOrder(paramBean);
|
||||||
|
}catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
LOGGER.info("callback==>err " + e.toString());
|
||||||
|
response = "FAIL";
|
||||||
|
}
|
||||||
|
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
private String insertOrder(YxylParamBean data) {
|
||||||
|
String callbackInfo = data.getExtraInfo();
|
||||||
|
String orderNo = data.getBillno();
|
||||||
|
String amount = data.getAmount();
|
||||||
|
Date time = new Date(System.currentTimeMillis());
|
||||||
|
|
||||||
|
return payLogic.initOrder(callbackInfo,orderNo,amount,time,data.getUid(), PaySdkEnum.YX);
|
||||||
|
}
|
||||||
|
private static String getMySign(YxylParamBean paramBean){
|
||||||
|
String paramStr = paramBean.getOrderId()
|
||||||
|
+paramBean.getUid()
|
||||||
|
+paramBean.getServerId()
|
||||||
|
+paramBean.getAmount()
|
||||||
|
+paramBean.getExtraInfo()
|
||||||
|
+paramBean.getOrderTime()
|
||||||
|
+paramBean.getBillno()
|
||||||
|
+paramBean.getTest()
|
||||||
|
+PAYKEY;
|
||||||
|
String sign = MD5Util.encrypByMd5(paramStr);
|
||||||
|
LOGGER.info("加密前字符串:{}",paramStr);
|
||||||
|
LOGGER.info("加密后得:{}",sign);
|
||||||
|
return sign;
|
||||||
|
}
|
||||||
|
|
||||||
|
private YxylParamBean getData(HashMap<String, String> parameterMap) {
|
||||||
|
YxylParamBean paramBean = new YxylParamBean();
|
||||||
|
paramBean.setOrderId(parameterMap.getOrDefault("orderId",""));
|
||||||
|
paramBean.setUid(parameterMap.getOrDefault("uid",""));
|
||||||
|
paramBean.setAmount(parameterMap.getOrDefault("amount",""));
|
||||||
|
paramBean.setServerId(parameterMap.getOrDefault("serverId",""));
|
||||||
|
paramBean.setExtraInfo(parameterMap.getOrDefault("extraInfo",""));
|
||||||
|
paramBean.setTest(parameterMap.getOrDefault("test",""));
|
||||||
|
paramBean.setOrderTime(parameterMap.getOrDefault("orderTime",""));
|
||||||
|
paramBean.setBillno(parameterMap.getOrDefault("billno",""));
|
||||||
|
paramBean.setSign(parameterMap.getOrDefault("sign",""));
|
||||||
|
LOGGER.info(paramBean.toString());
|
||||||
|
return paramBean;
|
||||||
|
}
|
||||||
|
}
|
|
@ -12,6 +12,7 @@ public enum PaySdkEnum {
|
||||||
XP(2,"喜扑"),
|
XP(2,"喜扑"),
|
||||||
CH(3,"草花"),
|
CH(3,"草花"),
|
||||||
QUICK(4,"QUICK"),
|
QUICK(4,"QUICK"),
|
||||||
|
YX(5,"YX"),
|
||||||
;
|
;
|
||||||
|
|
||||||
private int id;
|
private int id;
|
||||||
|
|
|
@ -0,0 +1,100 @@
|
||||||
|
package com.jmfy.paramBean;
|
||||||
|
|
||||||
|
public class YxylParamBean {
|
||||||
|
private String orderId;
|
||||||
|
private String uid;
|
||||||
|
private String amount;
|
||||||
|
private String serverId;
|
||||||
|
private String extraInfo;
|
||||||
|
private String test;
|
||||||
|
private String orderTime;
|
||||||
|
private String billno;
|
||||||
|
private String sign;
|
||||||
|
|
||||||
|
public String getOrderId() {
|
||||||
|
return orderId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOrderId(String orderId) {
|
||||||
|
this.orderId = orderId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUid() {
|
||||||
|
return uid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUid(String uid) {
|
||||||
|
this.uid = uid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAmount() {
|
||||||
|
return amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAmount(String amount) {
|
||||||
|
this.amount = amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getServerId() {
|
||||||
|
return serverId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setServerId(String serverId) {
|
||||||
|
this.serverId = serverId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getExtraInfo() {
|
||||||
|
return extraInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setExtraInfo(String extraInfo) {
|
||||||
|
this.extraInfo = extraInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTest() {
|
||||||
|
return test;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTest(String test) {
|
||||||
|
this.test = test;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getOrderTime() {
|
||||||
|
return orderTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOrderTime(String orderTime) {
|
||||||
|
this.orderTime = orderTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBillno() {
|
||||||
|
return billno;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBillno(String billno) {
|
||||||
|
this.billno = billno;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSign() {
|
||||||
|
return sign;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSign(String sign) {
|
||||||
|
this.sign = sign;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "YxylParamBean{" +
|
||||||
|
"orderId='" + orderId + '\'' +
|
||||||
|
", uid='" + uid + '\'' +
|
||||||
|
", amount='" + amount + '\'' +
|
||||||
|
", serverId='" + serverId + '\'' +
|
||||||
|
", extraInfo='" + extraInfo + '\'' +
|
||||||
|
", test='" + test + '\'' +
|
||||||
|
", orderTime='" + orderTime + '\'' +
|
||||||
|
", billno='" + billno + '\'' +
|
||||||
|
", sign='" + sign + '\'' +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue