From c21563c183a6a8da49990a4e6937df441e005e13 Mon Sep 17 00:00:00 2001 From: grimm <1769111741@qq.com> Date: Mon, 31 Mar 2025 22:24:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0F5sdk?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/jmfy/controller/PayController.java | 111 ++++++++++++++++++ .../com/jmfy/controller/SDKController.java | 3 + src/main/java/com/jmfy/sdk/SdkVerfy.java | 31 ++++- src/main/java/com/jmfy/util/Constant.java | 6 + 4 files changed, 150 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/jmfy/controller/PayController.java b/src/main/java/com/jmfy/controller/PayController.java index ce2743d..21cd14a 100644 --- a/src/main/java/com/jmfy/controller/PayController.java +++ b/src/main/java/com/jmfy/controller/PayController.java @@ -1855,4 +1855,115 @@ public class PayController { } } + /** + * F5支付回调 + * @param appId + * @param orderId + * @param defaultAmount + * @param defaultCurrency + * @param gameAmount + * @param gameCurrency + * @param productId + * @param payChannel + * @param userId + * @param serverId + * @param orderStatus + * @param statusMsg + * @param ots + * @param payDoneTime + * @param extInfo + * @param osign + * @return + */ + @RequestMapping(value = "/pay/f5Notify", method = {RequestMethod.POST,RequestMethod.GET}) + public String f5Notify(@RequestParam("appId") String appId, + @RequestParam("orderId") String orderId, + @RequestParam("defaultAmount") double defaultAmount, + @RequestParam("defaultCurrency") String defaultCurrency, + @RequestParam("gameAmount") int gameAmount, + @RequestParam("gameCurrency") String gameCurrency, + String productId, + @RequestParam("payChannel") String payChannel, + @RequestParam("userId") long userId, + @RequestParam("serverId") String serverId, + @RequestParam("orderStatus") int orderStatus, + @RequestParam("statusMsg") String statusMsg, + @RequestParam("ots") int ots, + String payDoneTime, + @RequestParam("extInfo") String extInfo, + @RequestParam("osign") String osign) { + JSONObject json = new JSONObject(); + json.put("appId", Constant.F5_APPID); + json.put("userId", userId); + try { + LOGGER.info("f5Notify--01, appId={},orderId={},defaultAmount={},defaultCurrency={},gameAmount={}," + + "gameCurrency={},productId={},payChannel={},userId={},serverId={}," + + "orderStatus={},statusMsg={},ots={},payDoneTime={},extInfo={},osign={}", appId,orderId,defaultAmount + ,defaultCurrency,gameAmount,gameCurrency,productId,payChannel,userId,serverId,orderStatus,statusMsg,ots,payDoneTime,extInfo,osign); + if(productId == null){ + productId = ""; + } + if(payDoneTime == null){ + payDoneTime = ""; + } + String signStr = appId + orderId + defaultAmount + defaultCurrency + gameAmount + gameCurrency + productId + + userId + serverId + orderStatus + ots + payDoneTime + extInfo + Constant.F5_SECURE_KEY; + String mySign=MD5Util.encrypByMd5(signStr); + + if(!mySign.equals(osign)){ + LOGGER.error("错误信息:签名不一致 mySign={},osign={}", mySign,osign); + json.put("code", "-1"); + json.put("msg", "签名不一致"); + json.put("deliverStatus", 2); + return json.toString(); + } + //extInfo为游戏订单号 + if(StringUtils.isEmpty(extInfo)){ + LOGGER.error("错误信息:extInfo empty"); + json.put("code", "-2"); + json.put("msg", "extInfo empty"); + json.put("deliverStatus", 2); + return json.toString(); + } + //渠道订单号不能为空 + if(StringUtils.isEmpty(orderId)){ + LOGGER.error("错误信息:orderId empty"); + json.put("code", "-2"); + json.put("msg", "orderId empty"); + json.put("deliverStatus", 2); + return json.toString(); + } + // 统一发货接口 + int payres = 0; + Double amountDouble = defaultAmount * 100; + payres = payHandler.processOrderNew(extInfo, orderId,amountDouble.intValue()); + // 成功 + if (payres == 1) { + json.put("code", 200); + json.put("msg", "SUCCESS"); + json.put("deliverStatus", 1); + return json.toString(); + } else if (payres == -1) { + LOGGER.error("pay:gameNoticeInterface, {} 订单不存在,", orderId); + json.put("msg", "订单不存在"); + } else if (payres == -2) { + LOGGER.error("pay:gameNoticeInterface, {} 订单参数错误,", orderId); + json.put("msg", "订单参数错误"); + } else if (payres == -3) { + LOGGER.error("pay:gameNoticeInterface, {} 服务器配置错误,", orderId); + json.put("msg", "服务器配置错误"); + } else if (payres == -4) { + LOGGER.error("pay:gameNoticeInterface, {} 充值失败,", orderId); + json.put("msg", "充值失败"); + } else { + LOGGER.error("pay:gameNoticeInterface, {} 返回错误,payres = {}", orderId,payres); + json.put("msg", "game exception"); + } + } catch (Exception ex) { + ex.printStackTrace(); + } + json.put("code", -3); + return json.toString(); + } + } diff --git a/src/main/java/com/jmfy/controller/SDKController.java b/src/main/java/com/jmfy/controller/SDKController.java index 7c54e6f..6bf2b98 100644 --- a/src/main/java/com/jmfy/controller/SDKController.java +++ b/src/main/java/com/jmfy/controller/SDKController.java @@ -155,6 +155,9 @@ public class SDKController { case "QKZB02"://quick直播2 uid = SdkVerfy.quickGameVerfy2(userId, sdksign, sdktoken); break; + case "F5"://quick直播2 + uid = SdkVerfy.f5Verify(userId, sdktoken); + break; default: uid = "-1"; } diff --git a/src/main/java/com/jmfy/sdk/SdkVerfy.java b/src/main/java/com/jmfy/sdk/SdkVerfy.java index f4b6c7d..559308b 100644 --- a/src/main/java/com/jmfy/sdk/SdkVerfy.java +++ b/src/main/java/com/jmfy/sdk/SdkVerfy.java @@ -596,8 +596,10 @@ public class SdkVerfy { try { // 请求参数 Map params = new HashMap(); - params.put("super_user_id", userId); params.put("token", sdktoken); + params.put("appId", Constant.F5_APPID); + String osign = MD5Util.encrypByMd5(Constant.F5_APPID + sdktoken + Constant.F5_SECURE_KEY); + params.put("osign", osign); // String jsonStr = JSON.toJSONString(params); String resurl = HttpUtil.postForm(Constant.SUPER_VERIFY_URL, params); JSONObject jsonObject = JSONObject.fromObject(resurl); @@ -612,4 +614,31 @@ public class SdkVerfy { } return "-1"; } + + /** + * + * @param userId + * @param sdktoken + * @return + */ + public static String f5Verify(String userId, String sdktoken) { + try { + // 请求参数 + Map params = new HashMap(); + params.put("super_user_id", userId); + params.put("token", sdktoken); + // String jsonStr = JSON.toJSONString(params); + String resurl = HttpUtil.postForm(Constant.F5_VERIFY_URL, params); + JSONObject jsonObject = JSONObject.fromObject(resurl); + LOGGER.info("res:{}", jsonObject.toString()); + // code状态为200时 登陆成功 其他为失败 + if (jsonObject.getInt("code") == 200) { + return userId; + } + return jsonObject.getString("msg"); + } catch (Exception e) { + e.printStackTrace(); + } + return "-1"; + } } diff --git a/src/main/java/com/jmfy/util/Constant.java b/src/main/java/com/jmfy/util/Constant.java index 76b70d7..44bc85a 100644 --- a/src/main/java/com/jmfy/util/Constant.java +++ b/src/main/java/com/jmfy/util/Constant.java @@ -144,4 +144,10 @@ public class Constant { public static final String QUICK_PRODUCT_CODE_2 = "19804280896394556877394266362523"; public static final String QUICK_MD5_KEY_2 = "lgnyk8tgfaa9iait77scencrxb1vemgp"; public static final String QUICK_CALLBACK_KEY_2 = "27512079957341517989513927959071"; + + //F5渠道 + public static final String F5_APPID = "0977b6d3e84611ef8f2202c85f0429f5"; + public static final String F5_APP_KEY = "4KFXCMH1dyTMrzBQbbkLFEOY3DCTtHOD"; + public static final String F5_SECURE_KEY = "Dw4bOiwgtHwjxCZ6dr68CwjcuVepTQu5"; + public static final String F5_VERIFY_URL = "https://api.wingsdk.com/cpapi/v2/user/authorize.do"; }