generated from root/miduo_server
108 lines
3.6 KiB
Java
108 lines
3.6 KiB
Java
package com.jmfy.controller;
|
|
|
|
import com.google.gson.Gson;
|
|
import com.jmfy.dto.CUserDao;
|
|
import com.jmfy.paramBean.PaySdkEnum;
|
|
import com.jmfy.paramBean.XPParamBean2;
|
|
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.util.*;
|
|
|
|
/**
|
|
* @discribe 喜扑ios
|
|
*/
|
|
@Deprecated
|
|
@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 XPCallback2(HttpServletRequest request) throws Exception {
|
|
return process(request,"c6b1b36a27195504134161f264969dec");
|
|
}
|
|
|
|
/* @RequestMapping(value = "/Web/XPCallback2")
|
|
public String XPCallback2Ios(HttpServletRequest request) throws Exception {
|
|
return process(request,"c6b1b36a27195504134161f264969dec");
|
|
}
|
|
|
|
@RequestMapping(value = "/Web/XPCallback2")
|
|
public String XPCallbackTest2(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();
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|