generated from root/miduo_server
乘风游戏支付
parent
6201c2a6ce
commit
6fa6ea67a0
|
@ -0,0 +1,81 @@
|
||||||
|
package com.jmfy.controller;
|
||||||
|
|
||||||
|
import com.jmfy.paramBean.PaySdkEnum;
|
||||||
|
import com.jmfy.util.FengTiDesUtil;
|
||||||
|
import com.jmfy.util.JsonUtil;
|
||||||
|
import com.jmfy.util.MD5Util;
|
||||||
|
import com.jmfy.util.XmlUtil;
|
||||||
|
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.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 悠谷游戏
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
public class ChengfengRechargeController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private PayLogic payLogic;
|
||||||
|
|
||||||
|
private static final String Md5_Key = "87826953070847860565318328257005";
|
||||||
|
|
||||||
|
public static final String Callback_Key = "87826953070847860565318328257005";
|
||||||
|
|
||||||
|
private static final Logger LOGGER = LoggerFactory.getLogger(ChengfengRechargeController.class);
|
||||||
|
|
||||||
|
@RequestMapping(value = "/Web/chengfengCallback")
|
||||||
|
public String chengfengCallback(HttpServletRequest request) throws Exception {
|
||||||
|
String result = "error";
|
||||||
|
|
||||||
|
HashMap<String, String> requestMap = JsonUtil.getInstence().getParameterMap2(request);
|
||||||
|
if (requestMap.isEmpty()) {
|
||||||
|
LOGGER.info("疯体 request data is null");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
boolean sign = verifySign(requestMap);
|
||||||
|
if (!sign) {
|
||||||
|
LOGGER.info("疯体---》sign error");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
String ntData = requestMap.get("nt_data");
|
||||||
|
String decode = FengTiDesUtil.decode(ntData, Callback_Key);
|
||||||
|
HashMap<String, String> data = (HashMap<String, String>) XmlUtil.readStringXmlOut(decode);
|
||||||
|
|
||||||
|
String orderno = data.get("out_order_no"); // 支付订单号
|
||||||
|
double amount = Double.parseDouble(data.get("amount")) * 100; //充值金额(单位:元)(需要换算成分)
|
||||||
|
String gameExt = data.get("extras_params"); //透传参数,如CP下单有值提交,则会原样回传,不得超过255个字符
|
||||||
|
String[] callback = gameExt.split("_");
|
||||||
|
return payLogic.initOrder(gameExt, orderno, String.valueOf(amount), new Date(), callback[0], PaySdkEnum.FENGTIIOS);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 验证sign
|
||||||
|
* @param map
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private boolean verifySign(Map<String, String> map) {
|
||||||
|
String ntData = map.get("nt_data");
|
||||||
|
String decodeNtData = FengTiDesUtil.decode(ntData, Callback_Key);
|
||||||
|
String sign = map.get("sign");
|
||||||
|
String decodeSign = FengTiDesUtil.decode(sign, Callback_Key);
|
||||||
|
String md5Sign = map.get("md5Sign");
|
||||||
|
|
||||||
|
StringBuilder localSign = new StringBuilder();
|
||||||
|
localSign.append(decodeNtData).append(decodeSign).append(Md5_Key);
|
||||||
|
String mySign = MD5Util.encrypByMd5(localSign.toString());
|
||||||
|
if (mySign.equals(md5Sign)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
LOGGER.error("疯体==>,sign fail, localSign={},md5Sign={},map={}", localSign, md5Sign, map);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue