generated from root/miduo_server
动游消息返回修改
parent
acc0687da5
commit
7f934e0962
|
@ -35,7 +35,7 @@ public class DyRechargeController {
|
|||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(DyRechargeController.class);
|
||||
@Resource
|
||||
private CUserDao cuserDao;
|
||||
private PayLogic payLogic;
|
||||
|
||||
@RequestMapping(value = "/DyCallback")
|
||||
public String DyCallback(HttpServletRequest request) throws Exception {
|
||||
|
@ -49,7 +49,7 @@ public class DyRechargeController {
|
|||
if (parameterMap.isEmpty()) {
|
||||
LOGGER.info("data is null");
|
||||
jsonObject.addProperty("code","-19");
|
||||
jsonObject.addProperty("msg","fail");
|
||||
jsonObject.addProperty("msg","回调信息为空");
|
||||
return jsonObject;
|
||||
}
|
||||
try {
|
||||
|
@ -58,26 +58,57 @@ public class DyRechargeController {
|
|||
if (!paramBean.getSign().equals(mySign)) {
|
||||
LOGGER.info("sign err");
|
||||
jsonObject.addProperty("code","-17");
|
||||
jsonObject.addProperty("msg","fail");
|
||||
jsonObject.addProperty("msg","sign验证失败");
|
||||
return jsonObject;
|
||||
}
|
||||
jsonObject = insertOrder(paramBean);
|
||||
}catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
LOGGER.info("callback==>err " + e.toString());
|
||||
jsonObject.addProperty("code","-19");
|
||||
jsonObject.addProperty("msg","fail");
|
||||
jsonObject.addProperty("code","-18");
|
||||
jsonObject.addProperty("msg","未知异常");
|
||||
return jsonObject;
|
||||
}
|
||||
|
||||
return jsonObject;
|
||||
}
|
||||
|
||||
private JsonObject insertOrder(DyParamBean data) {
|
||||
String callbackInfo = data.getExtension();
|
||||
String orderNo = data.getGameorder();
|
||||
String amount = data.getTotal();
|
||||
Date time = new Date(System.currentTimeMillis());
|
||||
return initOrder(callbackInfo,orderNo,amount,time,data.getRoleid(), PaySdkEnum.DY);
|
||||
|
||||
JsonObject object = new JsonObject();
|
||||
String msg = payLogic.initOrder(callbackInfo, orderNo, amount, time, data.getRoleid(), PaySdkEnum.DY);
|
||||
switch (msg){
|
||||
case "USER_IS_NOT":
|
||||
object.addProperty("code","-11");
|
||||
object.addProperty("msg","USER_IS_NOT");
|
||||
break;
|
||||
case "ORDER_IS_EXIST":
|
||||
object.addProperty("code","-12");
|
||||
object.addProperty("msg","ORDER_IS_EXIST");
|
||||
break;
|
||||
case "REDIS_ADDRESS_NULL":
|
||||
object.addProperty("code","-18");
|
||||
object.addProperty("msg","REDIS_ADDRESS_NULL");
|
||||
break;
|
||||
case "GAME_SERVER_RESULT_ERROR":
|
||||
object.addProperty("code","-18");
|
||||
object.addProperty("msg","GAME_SERVER_RESULT_ERROR");
|
||||
break;
|
||||
case "FAIL":
|
||||
object.addProperty("code","-18");
|
||||
object.addProperty("msg","FAIL");
|
||||
break;
|
||||
case "SUCCESS":
|
||||
object.addProperty("code","0");
|
||||
object.addProperty("msg","SUCCESS");
|
||||
break;
|
||||
default:break;
|
||||
}
|
||||
return object;
|
||||
}
|
||||
private static String getMySign(DyParamBean paramBean){
|
||||
String paramStr = "extension="+paramBean.getExtension()
|
||||
|
@ -111,97 +142,4 @@ public class DyRechargeController {
|
|||
LOGGER.info(paramBean.toString());
|
||||
return paramBean;
|
||||
}
|
||||
|
||||
public JsonObject initOrder(String collBackInfo, String orderId, String amount, Date time, String openId, PaySdkEnum sdk){
|
||||
JsonObject jsonObject = new JsonObject();
|
||||
try {
|
||||
|
||||
// 角色id_物品id_ccId_平台
|
||||
String[] collback = collBackInfo.split("_");
|
||||
LOGGER.info("支付透传参数,分割前:{},分割后:{},长度:{},支付:{}",collBackInfo, ArrayUtils.toString(collback,","),collback.length,sdk.getName());
|
||||
String uid = collback.length > 0 ? collback[0] : "0";
|
||||
String goodsId = collback.length > 1 ? collback[1] : "0";
|
||||
String ccId = collback.length > 2 ? collback[2] : "0";
|
||||
String platform = collback.length > 3 ? collback[3] : "ANDROID";
|
||||
|
||||
CUserInfo cUserInfo = cuserDao.findUserInfo(Integer.valueOf(uid));
|
||||
if (cUserInfo == null) {
|
||||
LOGGER.info("该用户无此角色" + uid);
|
||||
jsonObject.addProperty("code","-11");
|
||||
jsonObject.addProperty("msg","fail");
|
||||
return jsonObject;
|
||||
}
|
||||
|
||||
CPayOrder cPayOrder = cuserDao.getCpayOrderByOrderId(orderId);
|
||||
|
||||
if (cPayOrder != null) {
|
||||
LOGGER.info("callback==>creditId={},uId={} orderId is exit!!!", cUserInfo.getId(), cUserInfo.getOpenId());
|
||||
jsonObject.addProperty("code","-12");
|
||||
jsonObject.addProperty("msg","fail");
|
||||
return jsonObject;
|
||||
} else {
|
||||
DateFormat dateTimeformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
String date = dateTimeformat.format(time);
|
||||
cPayOrder = new CPayOrder();
|
||||
cPayOrder.setOrderId(orderId);
|
||||
cPayOrder.setServerId(cUserInfo.getServerid());
|
||||
cPayOrder.setDelivery_time(date);
|
||||
cPayOrder.setUserId(uid);
|
||||
cPayOrder.setAmount(amount);
|
||||
cPayOrder.setGoodsId(goodsId);
|
||||
cPayOrder.setCc_id(ccId);
|
||||
cPayOrder.setPaySdk(sdk.getName());
|
||||
cPayOrder.setPlatform(platform);
|
||||
|
||||
Result result = null;
|
||||
String userAddress = cuserDao.findUserAddress(cUserInfo.getId());
|
||||
if (userAddress != null) {
|
||||
LOGGER.info("callback==>userAddress={} ", userAddress);
|
||||
String[] split = userAddress.split(":");
|
||||
String ip = split[0];
|
||||
String port = split[1];
|
||||
LOGGER.info("RPC address --> IP : " + ip + "; PORT : " + port);
|
||||
ClientAdapterPo<RPCRequestIFace.Client> rPCClient = null;
|
||||
String serviceKey = JsonUtil.getServiceKey(ServiceKey.RPCCore, ip, port);
|
||||
LOGGER.info("serviceKey : " + serviceKey);
|
||||
try {
|
||||
rPCClient = ClientAdapterPo.getClientAdapterPo(serviceKey);
|
||||
result = rPCClient.getClient().deliveryRecharge(cUserInfo.getId(), goodsId, openId, orderId, 0, (int)Double.parseDouble(amount));
|
||||
} catch (Exception e) {
|
||||
LOGGER.info("callback=>", e);
|
||||
} finally {
|
||||
if (rPCClient != null) {
|
||||
rPCClient.returnObject(serviceKey);
|
||||
} else {
|
||||
LOGGER.info("callback=> rPCClient is null ");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
LOGGER.info("not get the user url,the openID={} ", uid);
|
||||
jsonObject.addProperty("code","-11");
|
||||
jsonObject.addProperty("msg","fail");
|
||||
return jsonObject;
|
||||
}
|
||||
if (result != null && result.getResultCode() == 1) {
|
||||
LOGGER.info(" callback==>RPC result : ResultCode : " + result.getResultCode() + "; ResultMsg : " + result.getResultMsg());
|
||||
cuserDao.addCpayOrder(cPayOrder);
|
||||
} else {
|
||||
System.out.println("测试代码");
|
||||
jsonObject.addProperty("code","-18");
|
||||
jsonObject.addProperty("msg","fail");
|
||||
return jsonObject;
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
LOGGER.info("callback==>err " + e.toString());
|
||||
jsonObject.addProperty("code","-18");
|
||||
jsonObject.addProperty("msg","fail");
|
||||
return jsonObject;
|
||||
}
|
||||
jsonObject.addProperty("code","0");
|
||||
jsonObject.addProperty("msg","success");
|
||||
return jsonObject;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,28 +1,23 @@
|
|||
package com.jmfy.controller;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.jmfy.dto.CPayOrder;
|
||||
import com.jmfy.dto.CUserDao;
|
||||
import com.jmfy.dto.CUserInfo;
|
||||
import com.jmfy.paramBean.MHTGnWebRechargeRequestBean;
|
||||
import com.jmfy.paramBean.PaySdkEnum;
|
||||
import com.jmfy.thrift.idl.RPCRequestIFace;
|
||||
import com.jmfy.thrift.idl.Result;
|
||||
import com.jmfy.thrift.pool.ClientAdapterPo;
|
||||
import com.jmfy.thrift.pool.ServiceKey;
|
||||
import com.jmfy.util.JsonUtil;
|
||||
import com.jmfy.util.MD5Util;
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.lang.reflect.Field;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @Author hj
|
||||
|
@ -30,12 +25,11 @@ import java.util.*;
|
|||
* @Description:
|
||||
* @Version 1.0
|
||||
*/
|
||||
@SuppressWarnings("ALL")
|
||||
@Component
|
||||
public class PayLogic {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(PayLogic.class);
|
||||
|
||||
private static Gson gson = new Gson();
|
||||
|
||||
@Resource
|
||||
private CUserDao cuserDao;
|
||||
|
||||
|
@ -54,16 +48,16 @@ public class PayLogic {
|
|||
|
||||
CUserInfo cUserInfo = cuserDao.findUserInfo(Integer.valueOf(uid));
|
||||
//0为了兼容
|
||||
if (!uid.equals("0")&&cUserInfo == null) {
|
||||
if (!"0".equals(uid) && cUserInfo == null) {
|
||||
LOGGER.info("该用户无此角色" + uid);
|
||||
return "FAIL";
|
||||
return "USER_IS_NOT";
|
||||
}
|
||||
|
||||
CPayOrder cPayOrder = cuserDao.getCpayOrderByOrderId(orderId);
|
||||
|
||||
if (cPayOrder != null) {
|
||||
LOGGER.info("callback==>creditId={},uId={} orderId is exit!!!", cUserInfo.getId(), cUserInfo.getOpenId());
|
||||
return "FAIL";
|
||||
return "ORDER_IS_EXIST";
|
||||
} else {
|
||||
DateFormat dateTimeformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
String date = dateTimeformat.format(time);
|
||||
|
@ -103,14 +97,14 @@ public class PayLogic {
|
|||
}
|
||||
} else {
|
||||
LOGGER.info("not get the user url,the openID={} ", uid);
|
||||
return "FAIL";
|
||||
return "REDIS_ADDRESS_NULL";
|
||||
}
|
||||
if (result != null && result.getResultCode() == 1) {
|
||||
LOGGER.info(" callback==>RPC result : ResultCode : " + result.getResultCode() + "; ResultMsg : " + result.getResultMsg());
|
||||
cuserDao.addCpayOrder(cPayOrder);
|
||||
} else {
|
||||
System.out.println("测试代码");
|
||||
return "FAIL";
|
||||
LOGGER.error("发送订单到游戏服,返回数据异常");
|
||||
return "GAME_SERVER_RESULT_ERROR";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package com.jmfy.controller;
|
||||
|
||||
import com.jmfy.dto.CUserDao;
|
||||
import com.jmfy.paramBean.PaySdkEnum;
|
||||
import com.jmfy.util.JsonUtil;
|
||||
import com.jmfy.util.MD5Util;
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package com.jmfy.controller;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.jmfy.dto.CUserDao;
|
||||
import com.jmfy.paramBean.PaySdkEnum;
|
||||
import com.jmfy.paramBean.XPParamBean;
|
||||
import com.jmfy.util.JsonUtil;
|
||||
|
@ -23,13 +21,9 @@ import java.util.HashMap;
|
|||
*/
|
||||
@RestController
|
||||
public class XPRechargeController {
|
||||
@Resource
|
||||
private CUserDao cuserDao;
|
||||
@Resource
|
||||
private PayLogic payLogic;
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(XPRechargeController.class);
|
||||
private static Gson gson = new Gson();
|
||||
|
||||
|
||||
@RequestMapping(value = "/XPCallback")
|
||||
public String MHTGnCallback(HttpServletRequest request) throws Exception {
|
||||
|
@ -98,8 +92,6 @@ public class XPRechargeController {
|
|||
if(collback.length==1) {
|
||||
callbackInfo = data.getRoleId()+"_"+callbackInfo;
|
||||
}
|
||||
|
||||
|
||||
return payLogic.initOrder(callbackInfo,orderNo,amount,time,data.getOpenId(), PaySdkEnum.XP);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue