新增DNA支付渠道

main
grimm 2025-09-12 10:05:40 +08:00
parent 603da708fb
commit ae8d370198
4 changed files with 341 additions and 0 deletions

View File

@ -2562,4 +2562,290 @@ public class PayController {
return json.toString(); return json.toString();
} }
@RequestMapping(value = "/pay/dnaAdNotify", method = {RequestMethod.POST,RequestMethod.GET})
public String dnaAdNotify(String app_id,
String ch_id,
String ch_order_id,
String order_id,
String cp_order_id,
String mem_id,
String order_status,
String pay_time,
String finish_time,
String product_id,
String product_name,
String product_price,
String server_id,
String role_id,
String ext, String sign) {
String result = "FAILURE";
if(app_id == null){
LOGGER.error("DnaAdCallback request app_id is null");
return result;
}
if(!app_id.equals(Constant.DNA_AD_APPID)){
LOGGER.error("DnaAdCallback request app_id is not exist channel app_id : " + app_id + "---local app_id : " + Constant.DNA_AD_APPID);
return result;
}
if(ch_id == null){
LOGGER.error("DnaAdCallback request ch_id is null");
return result;
}
if(ch_order_id == null){
LOGGER.error("DnaAdCallback request ch_order_id is null");
return result;
}
if(order_id == null){
LOGGER.error("DnaAdCallback request order_id is null");
return result;
}
if(cp_order_id == null){
LOGGER.error("DnaAdCallback request cp_order_id is null");
return result;
}
if(mem_id == null){
LOGGER.error("DnaAdCallback request mem_id is null");
return result;
}
if(order_status == null){
LOGGER.error("DnaAdCallback request order_status is null");
return result;
}
int orderStatus = Integer.parseInt(order_status);
if(pay_time == null){
LOGGER.error("DnaAdCallback request pay_time is null");
return result;
}
int payTime = Integer.parseInt(pay_time);
if(finish_time == null){
LOGGER.error("DnaAdCallback request finish_time is null");
return result;
}
int finishTime = Integer.parseInt(finish_time);
if(product_id == null){
LOGGER.error("DnaAdCallback request product_id is null");
return result;
}
if(product_name == null){
LOGGER.error("DnaAdCallback request product_name is null");
return result;
}
if(product_price == null){
LOGGER.error("DnaAdCallback request product_price is null");
return result;
}
float money = Float.parseFloat(product_price);
if(server_id == null){
LOGGER.error("DnaAdCallback request server_id is null");
return result;
}
if(role_id == null){
LOGGER.error("DnaAdCallback request role_id is null");
return result;
}
if(ext == null){
LOGGER.error("DnaAdCallback request ext is null");
return result;
}
if(sign == null){
LOGGER.error("Dna01Callback request sign is null");
return result;
}
StringBuffer signStr = new StringBuffer("app_id=" + app_id);
signStr.append("&ch_id=" + ch_id);
signStr.append("&ch_order_id=" + ch_order_id);
signStr.append("&cp_order_id=" + cp_order_id);
signStr.append("&ext=" + ext);
signStr.append("&finish_time=" + finishTime);
signStr.append("&mem_id=" + mem_id);
signStr.append("&order_id=" + order_id);
signStr.append("&order_status=" + orderStatus);
signStr.append("&pay_time=" + payTime);
signStr.append("&product_id=" + product_id);
signStr.append("&product_name=" + URLEncoder.encode(product_name));
signStr.append("&product_price=" + product_price);
signStr.append("&role_id=" + role_id);
signStr.append("&server_id=" + server_id);
signStr.append("&app_key=" + Constant.DNA_AD_APP_KEY);
String md5Str = MD5Util.encrypByMd5(signStr.toString());
if(!md5Str.equals(sign)){
LOGGER.error("DnaAdCallback sign error md5Sign:" + md5Str + " -- md5Str:" + signStr.toString() + " -- sign:" + sign);
return result;
}
//充值成功
if(orderStatus == 2){
// 统一发货接口
int payres = 0;
Float amount = money * 100;
try{
payres = payHandler.processOrderNew(cp_order_id, order_id,amount.intValue());
}catch(Exception e) {
LOGGER.error("DnaAdCallback error, {} 发货失败", e);
}
// 成功
if (payres == 1) {
return "SUCCESS";
} else if (payres == -1) {
LOGGER.error("DnaAdCallback:gameNoticeInterface, {} 订单不存在,", order_id);
return result;
} else if (payres == -2) {
LOGGER.error("DnaAdCallback:gameNoticeInterface, {} 订单参数错误,", order_id);
return result;
} else if (payres == -3) {
LOGGER.error("DnaAdCallback:gameNoticeInterface, {} 服务器配置错误,", order_id);
return result;
} else if (payres == -4) {
LOGGER.error("DnaAdCallback:gameNoticeInterface, {} 充值失败,", order_id);
return result;
} else {
LOGGER.error("DnaAdCallback:gameNoticeInterface, {} 返回错误,payres = {}", order_id,payres);
return result;
}
}
return result;
}
@RequestMapping(value = "/pay/dnaIosNotify", method = {RequestMethod.POST,RequestMethod.GET})
public String dnaIosNotify(String app_id,
String ch_id,
String ch_order_id,
String order_id,
String cp_order_id,
String mem_id,
String order_status,
String pay_time,
String finish_time,
String product_id,
String product_name,
String product_price,
String server_id,
String role_id,
String ext, String sign) {
String result = "FAILURE";
if(app_id == null){
LOGGER.error("DnaIosCallback request app_id is null");
return result;
}
if(!app_id.equals(Constant.DNA_IOS_APPID)){
LOGGER.error("DnaIosCallback request app_id is not exist channel app_id : " + app_id + "---local app_id : " + Constant.DNA_AD_APPID);
return result;
}
if(ch_id == null){
LOGGER.error("DnaIosCallback request ch_id is null");
return result;
}
if(ch_order_id == null){
LOGGER.error("DnaIosCallback request ch_order_id is null");
return result;
}
if(order_id == null){
LOGGER.error("DnaIosCallback request order_id is null");
return result;
}
if(cp_order_id == null){
LOGGER.error("DnaIosCallback request cp_order_id is null");
return result;
}
if(mem_id == null){
LOGGER.error("DnaIosCallback request mem_id is null");
return result;
}
if(order_status == null){
LOGGER.error("DnaIosCallback request order_status is null");
return result;
}
int orderStatus = Integer.parseInt(order_status);
if(pay_time == null){
LOGGER.error("DnaIosCallback request pay_time is null");
return result;
}
int payTime = Integer.parseInt(pay_time);
if(finish_time == null){
LOGGER.error("DnaIosCallback request finish_time is null");
return result;
}
int finishTime = Integer.parseInt(finish_time);
if(product_id == null){
LOGGER.error("DnaIosCallback request product_id is null");
return result;
}
if(product_name == null){
LOGGER.error("DnaIosCallback request product_name is null");
return result;
}
if(product_price == null){
LOGGER.error("DnaIosCallback request product_price is null");
return result;
}
float money = Float.parseFloat(product_price);
if(server_id == null){
LOGGER.error("DnaIosCallback request server_id is null");
return result;
}
if(role_id == null){
LOGGER.error("DnaIosCallback request role_id is null");
return result;
}
if(ext == null){
LOGGER.error("DnaAdCallback request ext is null");
return result;
}
if(sign == null){
LOGGER.error("DnaIosCallback request sign is null");
return result;
}
StringBuffer signStr = new StringBuffer("app_id=" + app_id);
signStr.append("&ch_id=" + ch_id);
signStr.append("&ch_order_id=" + ch_order_id);
signStr.append("&cp_order_id=" + cp_order_id);
signStr.append("&ext=" + ext);
signStr.append("&finish_time=" + finishTime);
signStr.append("&mem_id=" + mem_id);
signStr.append("&order_id=" + order_id);
signStr.append("&order_status=" + orderStatus);
signStr.append("&pay_time=" + payTime);
signStr.append("&product_id=" + product_id);
signStr.append("&product_name=" + URLEncoder.encode(product_name));
signStr.append("&product_price=" + product_price);
signStr.append("&role_id=" + role_id);
signStr.append("&server_id=" + server_id);
signStr.append("&app_key=" + Constant.DNA_IOS_APP_KEY);
String md5Str = MD5Util.encrypByMd5(signStr.toString());
if(!md5Str.equals(sign)){
LOGGER.error("DnaIosCallback sign error md5Sign:" + md5Str + " -- md5Str:" + signStr.toString() + " -- sign:" + sign);
return result;
}
//充值成功
if(orderStatus == 2){
// 统一发货接口
int payres = 0;
Float amount = money * 100;
try{
payres = payHandler.processOrderNew(cp_order_id, order_id,amount.intValue());
}catch(Exception e) {
LOGGER.error("DnaIosCallback error, {} 发货失败", e);
}
// 成功
if (payres == 1) {
return "SUCCESS";
} else if (payres == -1) {
LOGGER.error("DnaIosCallback:gameNoticeInterface, {} 订单不存在,", order_id);
return result;
} else if (payres == -2) {
LOGGER.error("DnaIosCallback:gameNoticeInterface, {} 订单参数错误,", order_id);
return result;
} else if (payres == -3) {
LOGGER.error("DnaIosCallback:gameNoticeInterface, {} 服务器配置错误,", order_id);
return result;
} else if (payres == -4) {
LOGGER.error("DnaIosCallback:gameNoticeInterface, {} 充值失败,", order_id);
return result;
} else {
LOGGER.error("DnaIosCallback:gameNoticeInterface, {} 返回错误,payres = {}", order_id,payres);
return result;
}
}
return result;
}
} }

View File

@ -161,6 +161,12 @@ public class SDKController {
case "F5_GW"://F5渠道 case "F5_GW"://F5渠道
uid = SdkVerfy.f5GwVerify(userId, sdktoken); uid = SdkVerfy.f5GwVerify(userId, sdktoken);
break; break;
case "DNA_AD"://dna安卓渠道
uid = SdkVerfy.dnaVerify(userId, sdktoken,1);
break;
case "DNA_IOS"://dnaios渠道
uid = SdkVerfy.dnaVerify(userId, sdktoken,2);
break;
default: default:
uid = "-1"; uid = "-1";
} }

View File

@ -670,6 +670,49 @@ public class SdkVerfy {
return "-1"; return "-1";
} }
/**
* DNA
* @param userId
* @param sdktoken
* @return
*/
public static String dnaVerify(String userId, String sdktoken,int type) {
try {
String url = "https://unapi.gmdna.com/cp/user/check";
Map<String,String> params = new HashMap<>();
String appId = "";
String appKey = "";
if(type == 1){
appId = Constant.DNA_AD_APPID;
appKey = Constant.DNA_AD_APP_KEY;
}else{
appId = Constant.DNA_IOS_APPID;
appKey = Constant.DNA_IOS_APP_KEY;
}
params.put("user_token",sdktoken);
params.put("mem_id",userId);
params.put("app_id",appId);
String str = "app_id="+appId + "&mem_id="+userId +"&user_token=" + sdktoken + "&app_key=" + appKey;
String sign = MD5Util.encrypByMd5(str);
params.put("sign",sign);
String resurl = HttpUtil.postForm(url, params);
LOGGER.info("dna请求结果:{}",resurl);
if (resurl != null) {
JSONObject jsonObject = JSONObject.fromObject(resurl);
String status = jsonObject.getString("status");
if("1".equals(status)){
return userId;
}
String msg = jsonObject.getString("msg");
LOGGER.info("dna登陆失败信息:{}",msg);
return "-1";
}
} catch (Exception e) {
e.printStackTrace();
}
return "-1";
}
public static void main(String[] args) throws IOException { public static void main(String[] args) throws IOException {
Map<String, String> params = new HashMap<String, String>(); Map<String, String> params = new HashMap<String, String>();
params.put("token", "1_o1ioab9ktedQF3Lj5SkinbGOt9GexZX1"); params.put("token", "1_o1ioab9ktedQF3Lj5SkinbGOt9GexZX1");

View File

@ -158,4 +158,10 @@ public class Constant {
public static final String F5_GW_SECURE_KEY = "sgDNFbfuVz2BmJvtIfikl5oAupmbxwym"; public static final String F5_GW_SECURE_KEY = "sgDNFbfuVz2BmJvtIfikl5oAupmbxwym";
public static final String F5_GW_PAY_KEY = "rHBzPzP3xGb2UvufRPIDiR6jJXKxgVDU"; public static final String F5_GW_PAY_KEY = "rHBzPzP3xGb2UvufRPIDiR6jJXKxgVDU";
public static final String F5_GW_VERIFY_URL = "https://api.wingsdk.com/cpapi/v2/user/authorize.do"; public static final String F5_GW_VERIFY_URL = "https://api.wingsdk.com/cpapi/v2/user/authorize.do";
//DNA渠道
public static final String DNA_AD_APPID = "54";
public static final String DNA_AD_APP_KEY = "d3efca4c80cbbf4d56bf63ffad99a590";
public static final String DNA_IOS_APPID = "55";
public static final String DNA_IOS_APP_KEY = "d1931d53a8d86925d798479bae03a557";
} }