generated from root/miduo_server
喜扑ios 支付
parent
91e6250a0d
commit
bcec0fd334
|
@ -0,0 +1,119 @@
|
|||
package com.jmfy.controller;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.jmfy.dto.CUserDao;
|
||||
import com.jmfy.paramBean.MHTGnWebRechargeRequestBean;
|
||||
import com.jmfy.paramBean.PaySdkEnum;
|
||||
import com.jmfy.paramBean.XPParamBean2;
|
||||
import com.jmfy.util.JsonUtil;
|
||||
import com.jmfy.util.MD5Util;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
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.lang.reflect.Field;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @discribe 喜扑ios
|
||||
*/
|
||||
|
||||
@RestController
|
||||
public class XPiosRechargeController {
|
||||
@Resource
|
||||
private CUserDao cuserDao;
|
||||
@Resource
|
||||
private PayLogic payLogic;
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(XPiosRechargeController.class);
|
||||
private static Gson gson = new Gson();
|
||||
|
||||
|
||||
@RequestMapping(value = "/Web/XPCallback2")
|
||||
public String MHTGnCallback(HttpServletRequest request) throws Exception {
|
||||
return process(request,"c6b1b36a27195504134161f264969dec");
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/Web/XPCallback2")
|
||||
public String MHTGnIosCallback(HttpServletRequest request) throws Exception {
|
||||
return process(request,"c6b1b36a27195504134161f264969dec");
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/Web/XPCallback2")
|
||||
public String MHTGnTestCallback(HttpServletRequest request) throws Exception {
|
||||
return process(request,"c6b1b36a27195504134161f264969dec");
|
||||
}
|
||||
protected String process(HttpServletRequest request,String appsecret) throws Exception{
|
||||
HashMap<String, String> parameterMap = JsonUtil.getInstence().getParameterMap2(request);
|
||||
if (parameterMap.isEmpty()) {
|
||||
LOGGER.info("data is null");
|
||||
return "FAIL";
|
||||
}
|
||||
|
||||
XPParamBean2 data = getData(parameterMap);
|
||||
|
||||
if (data == null) {
|
||||
LOGGER.info("data is null");
|
||||
return "FAIL";
|
||||
}
|
||||
|
||||
String response = "SUCCESS";
|
||||
try {
|
||||
//String consumerid = data.getConsumerid();
|
||||
String sign = data.getNewsign();
|
||||
|
||||
String sig = getMySign(data, appsecret);
|
||||
|
||||
if (!sig.equals(sign)) {
|
||||
LOGGER.info("callback==>roleUid={},sin derify fail,mine sign={},other sign={} ", data.getRoleId(), sig,sign);
|
||||
return "sign fail";
|
||||
}
|
||||
|
||||
response = insertOrder(data);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
LOGGER.info("callback==>err " + e.toString());
|
||||
response = "FAIL";
|
||||
}
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
private XPParamBean2 getData(HashMap<String, String> parameterMap) {
|
||||
XPParamBean2 rechargeRequestBean = gson.fromJson( new Gson().toJson(parameterMap), XPParamBean2.class);
|
||||
return rechargeRequestBean;
|
||||
}
|
||||
|
||||
|
||||
private String insertOrder(XPParamBean2 data) {
|
||||
// 角色id_物品id_cc值
|
||||
String callbackInfo = data.getCallbackInfo();
|
||||
String orderNo = data.getOrderId();
|
||||
String amount = data.getMoney();
|
||||
Date time = new Date(System.currentTimeMillis());
|
||||
LOGGER.info("xp ios callback==>consumerId={},orderId={} amount={} ", callbackInfo, orderNo,amount);
|
||||
return payLogic.initOrder(callbackInfo,orderNo,amount,time,data.getRoleId(), PaySdkEnum.XP);
|
||||
}
|
||||
|
||||
private static String getMySign(XPParamBean2 data,String appsecret) throws IllegalAccessException {
|
||||
String para= data.getAppId()+data.getOrderId()+data.getOpenId()+data.getServerId()
|
||||
+data.getRoleId()+data.getMoney()+data.getAmount()+data.getCallbackInfo()+appsecret;
|
||||
return MD5Util.encrypByMd5(para).toLowerCase();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,122 @@
|
|||
package com.jmfy.paramBean;
|
||||
|
||||
public class XPParamBean2 {
|
||||
String appId;
|
||||
String serverId;
|
||||
String roleId;
|
||||
String money;
|
||||
String callbackInfo;
|
||||
String openId;
|
||||
String orderId;
|
||||
int orderStatus;
|
||||
String amount;
|
||||
String remark;
|
||||
String newsign;
|
||||
String payType;
|
||||
int exchange_rate;
|
||||
|
||||
|
||||
public String getAppId() {
|
||||
return appId;
|
||||
}
|
||||
|
||||
public void setAppId(String appId) {
|
||||
this.appId = appId;
|
||||
}
|
||||
|
||||
public String getServerId() {
|
||||
return serverId;
|
||||
}
|
||||
|
||||
public void setServerId(String serverId) {
|
||||
this.serverId = serverId;
|
||||
}
|
||||
|
||||
public String getRoleId() {
|
||||
return roleId;
|
||||
}
|
||||
|
||||
public void setRoleId(String roleId) {
|
||||
this.roleId = roleId;
|
||||
}
|
||||
|
||||
public String getMoney() {
|
||||
return money;
|
||||
}
|
||||
|
||||
public void setMoney(String money) {
|
||||
this.money = money;
|
||||
}
|
||||
|
||||
public String getCallbackInfo() {
|
||||
return callbackInfo;
|
||||
}
|
||||
|
||||
public void setCallbackInfo(String callbackInfo) {
|
||||
this.callbackInfo = callbackInfo;
|
||||
}
|
||||
|
||||
public String getOpenId() {
|
||||
return openId;
|
||||
}
|
||||
|
||||
public void setOpenId(String openId) {
|
||||
this.openId = openId;
|
||||
}
|
||||
|
||||
public String getOrderId() {
|
||||
return orderId;
|
||||
}
|
||||
|
||||
public void setOrderId(String orderId) {
|
||||
this.orderId = orderId;
|
||||
}
|
||||
|
||||
public int getOrderStatus() {
|
||||
return orderStatus;
|
||||
}
|
||||
|
||||
public void setOrderStatus(int orderStatus) {
|
||||
this.orderStatus = orderStatus;
|
||||
}
|
||||
|
||||
public String getAmount() {
|
||||
return amount;
|
||||
}
|
||||
|
||||
public void setAmount(String amount) {
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
public String getRemark() {
|
||||
return remark;
|
||||
}
|
||||
|
||||
public void setRemark(String remark) {
|
||||
this.remark = remark;
|
||||
}
|
||||
|
||||
public String getNewsign() {
|
||||
return newsign;
|
||||
}
|
||||
|
||||
public void setNewsign(String newsign) {
|
||||
this.newsign = newsign;
|
||||
}
|
||||
|
||||
public String getPayType() {
|
||||
return payType;
|
||||
}
|
||||
|
||||
public void setPayType(String payType) {
|
||||
this.payType = payType;
|
||||
}
|
||||
|
||||
public int getExchange_rate() {
|
||||
return exchange_rate;
|
||||
}
|
||||
|
||||
public void setExchange_rate(int exchange_rate) {
|
||||
this.exchange_rate = exchange_rate;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue