diff --git a/src/main/java/com/jmfy/controller/IAPManagerController.java b/src/main/java/com/jmfy/controller/IAPManagerController.java index 886e0b1..8ac9b89 100644 --- a/src/main/java/com/jmfy/controller/IAPManagerController.java +++ b/src/main/java/com/jmfy/controller/IAPManagerController.java @@ -40,96 +40,75 @@ public class IAPManagerController { } String sig = map.get("sig"); + String[] serverParam = map.get("channel_id").split("-"); + + int gameServer = Integer.parseInt(serverParam[serverParam.length-5]); + int userId = Integer.parseInt(serverParam[serverParam.length-4]); + int goodsId = Integer.parseInt(serverParam[serverParam.length-3]); + int sendBox = Integer.parseInt(serverParam[serverParam.length-2]); + + String openid = map.get("openid"); + String payitem = map.get("payitem"); + String billno = map.get("billno"); + String amt = map.get("amt"); + String channel_id = map.get("channel_id"); + String token = map.get("token"); + String final_appkey; -// if (online == 0){ -// final_appkey = YsjConstant.Midas_Buy_Ios_Appkey; -// }else { + if (sendBox == 0){ + final_appkey = YsjConstant.Midas_Buy_Ios_Appkey; + }else { final_appkey = YsjConstant.Midas_Buy_Ios_Appkey_Test; -// } + } + + LOGGER.info("final_appkey : "+ final_appkey); boolean checkSign = SnsSigCheck.verifySig("GET", "/delivery/iapmanager", map, final_appkey+"&", sig); if (!checkSign){ + JsonResult jsonResult = new JsonResult(); + jsonResult.setRet(5); + jsonResult.setMsg("sign error"); LOGGER.info("sign error ..."); + LOGGER.info("======> end midas request..."); + return jsonResult; } LOGGER.info("checkSign Success !!! "); + CUser cUser = cuserDao.findUserInfo(gameServer,userId); + LOGGER.info("cUser : "+ cUser.toString()); + String ip; + String port; + //TODO RPC 发货 + Result result = null; + if (cUser != null){ + String[] split = cUser.getCoreAddress().split(":"); + ip = split[0]; + port = split[1]; + + LOGGER.info("RPC address --> IP : "+ ip + "; PORT : "+ port); + + ClientAdapterPo rPCClient = null; + String serviceKey = getServiceKey(ServiceKey.RPCCore,ip,port); + LOGGER.info("serviceKey : "+ serviceKey); + try { + LOGGER.info("before RPC ... "); + rPCClient = ClientAdapterPo.getClientAdapterPo(serviceKey); +// result = rPCClient.getClient().iapDeliveryGood(openid,userId,payitem,billno,amt,channel_id,token); + result = rPCClient.getClient().testdeliveryGood(userId,"1002#200#2"); + LOGGER.info("after RPC ... "); + } catch (Exception e) { + e.printStackTrace(); + } finally { + rPCClient.returnObject(serviceKey); + } + } + JsonResult jsonResult = new JsonResult(); - jsonResult.setRet(0); - jsonResult.setMsg("ok"); - LOGGER.info("======>test ok iap end midas request..."); + jsonResult.setRet(result.getResultCode()); + jsonResult.setMsg(result.getResultMsg()); + LOGGER.info("RPC result : ResultCode : "+ result.getResultCode()+"; ResultMsg : "+ result.getResultMsg()); + LOGGER.info("======> end midas request..."); return jsonResult; - -// String sig = map.get("sig"); -// String[] serverParam = map.get("appmeta").split("\\*"); -// int plat = Integer.parseInt(serverParam[0]); -// int channel = Integer.parseInt(serverParam[1]); -// int gameServer = Integer.parseInt(serverParam[2]); -// int area = Integer.parseInt(serverParam[3]); -// int userId = Integer.parseInt(serverParam[4]); -// int online = Integer.parseInt(serverParam[5]); -// String serverOrder = serverParam[6]; - -// String openid = map.get("openid"); -// String payitem = map.get("payitem"); -// String billno = map.get("billno"); -// String amt = map.get("amt"); -// String channel_id = map.get("channel_id"); -// String token = map.get("token"); -// -// String final_appkey; -// if (online == 0){ -// final_appkey = YsjConstant.Midas_Buy_Ios_Appkey; -// }else { -// final_appkey = YsjConstant.Midas_Buy_Ios_Appkey_Test; -// } -// -// LOGGER.info("final_appkey : "+ final_appkey); -// -// boolean checkSign = SnsSigCheck.verifySig("GET", "/delivery/iapmanager", map, final_appkey+"&", sig); -// if (!checkSign){ -// JsonResult jsonResult = new JsonResult(); -// jsonResult.setRet(5); -// jsonResult.setMsg("sign error"); -// LOGGER.info("sign error ..."); -// LOGGER.info("======> end midas request..."); -// return jsonResult; -// } -// LOGGER.info("checkSign Success !!! "); -// -// CUser cUser = cuserDao.findUserInfo(gameServer,userId); -// LOGGER.info("cUser : "+ cUser.toString()); -// String ip; -// String port; -// //TODO RPC 发货 -// Result result = null; -// if (cUser != null){ -// String[] split = cUser.getCoreAddress().split(":"); -// ip = split[0]; -// port = split[1]; -// -// LOGGER.info("RPC address --> IP : "+ ip + "; PORT : "+ port); -// -// ClientAdapterPo rPCClient = null; -// String serviceKey = getServiceKey(ServiceKey.RPCCore,ip,port); -// LOGGER.info("serviceKey : "+ serviceKey); -// try { -// LOGGER.info("before RPC ... "); -// rPCClient = ClientAdapterPo.getClientAdapterPo(serviceKey); -// result = rPCClient.getClient().deliveryGood(openid,userId,payitem,billno,amt,channel_id,token,serverOrder); -// LOGGER.info("after RPC ... "); -// } catch (Exception e) { -// e.printStackTrace(); -// } finally { -// rPCClient.returnObject(serviceKey); -// } -// } -// -// JsonResult jsonResult = new JsonResult(); -// jsonResult.setRet(result.getResultCode()); -// jsonResult.setMsg(result.getResultMsg()); -// LOGGER.info("RPC result : ResultCode : "+ result.getResultCode()+"; ResultMsg : "+ result.getResultMsg()); -// LOGGER.info("======> end midas request..."); -// return jsonResult; } catch (Exception e) { e.printStackTrace(); JsonResult jsonResult = new JsonResult(); diff --git a/src/main/java/com/jmfy/util/YsjConstant.java b/src/main/java/com/jmfy/util/YsjConstant.java index 3032fc7..c7fc430 100644 --- a/src/main/java/com/jmfy/util/YsjConstant.java +++ b/src/main/java/com/jmfy/util/YsjConstant.java @@ -17,9 +17,9 @@ public class YsjConstant { public static String Midas_Buy_Ios_Appid = "1450013495"; - public static String Midas_Buy_Android_Appkey = "l3JABkBf3iOWXGlFomyr9v8zTGMIFc27"; +// public static String Midas_Buy_Android_Appkey = "l3JABkBf3iOWXGlFomyr9v8zTGMIFc27"; -// public static String Midas_Buy_Android_Appkey = "LAhW7WH0jVRjGVkj1wL3fG1YJmCcO6TR";//TODO + public static String Midas_Buy_Android_Appkey = "LAhW7WH0jVRjGVkj1wL3fG1YJmCcO6TR";//TODO public static String Midas_Buy_Android_Appkey_Test = "LAhW7WH0jVRjGVkj1wL3fG1YJmCcO6TR"; diff --git a/src/main/thrift/idl/core.thrift b/src/main/thrift/idl/core.thrift index bd20b12..fe793ae 100644 --- a/src/main/thrift/idl/core.thrift +++ b/src/main/thrift/idl/core.thrift @@ -10,5 +10,9 @@ service RPCRequestIFace{ Result deliveryGood(1:string openid, 2:i32 userId, 3:string payitem, 4:string billno, 5:string amt, 6:string channel_id, 7:string token, 8:string serverOrder) throws (1:common.InvalidOperException ouch); + + Result iapDeliveryGood(1:string openid, 2:i32 userId, 3:string payitem, 4:string billno, 5:string amt, + 6:string channel_id, 7:string token) throws (1:common.InvalidOperException ouch); + Result testdeliveryGood(1:i32 userId, 2:string payitem) throws (1:common.InvalidOperException ouch); } \ No newline at end of file