generated from root/miduo_server
79 lines
2.9 KiB
Java
79 lines
2.9 KiB
Java
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.*;
|
||
|
||
/**
|
||
* 悠谷游戏
|
||
*/
|
||
@RestController
|
||
public class FengtiIOSRechargeController {
|
||
|
||
@Resource
|
||
private PayLogic payLogic;
|
||
|
||
private static final String Md5_Key = "69059243697666791013328131742528";
|
||
|
||
public static final String Callback_Key = "65128019344497803431230471351187";
|
||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(FengtiIOSRechargeController.class);
|
||
|
||
@RequestMapping(value = "/Web/fengtiIOSCallback")
|
||
public String fengtiIOSCallback(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);
|
||
LOGGER.info("疯体,解析xml参数:{}",data);
|
||
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");
|
||
|
||
LOGGER.info("疯体ios 加密sign参数,ntdata:{},sign:{}, key:{}",ntData,sign,Md5_Key);
|
||
String mySign = MD5Util.encrypByMd5(ntData + sign + Md5_Key);
|
||
if (mySign.equals(md5Sign)) {
|
||
return true;
|
||
}
|
||
LOGGER.error("疯体ios==>sign验证异常, localSign={},md5Sign={},map={}", mySign, md5Sign, map);
|
||
return false;
|
||
}
|
||
}
|