use of com.code.server.constant.response.ResponseVo in project summer by foxsugar.
the class PayCallback method callback.
/**
* 接受微信回调
*
* @param
*/
@RequestMapping(value = "/callback")
public String callback(HttpServletRequest request, HttpServletResponse response) {
System.out.println("接受回调参数");
// 获取微信返回结果
String parameterstr = PayUtil.ObtainParameterString(request);
System.out.println("parameterstr:" + parameterstr);
// 解析xmlString
Element element = PayUtil.ParsingXML(parameterstr);
SortedMap<String, String> secondParams = new TreeMap<>();
secondParams.put("appid", element.elementText("appid"));
secondParams.put("bank_type", element.elementText("bank_type"));
secondParams.put("cash_fee", element.elementText("cash_fee"));
secondParams.put("fee_type", element.elementText("fee_type"));
secondParams.put("is_subscribe", element.elementText("is_subscribe"));
secondParams.put("mch_id", element.elementText("mch_id"));
secondParams.put("nonce_str", element.elementText("nonce_str"));
secondParams.put("openid", element.elementText("openid"));
secondParams.put("out_trade_no", element.elementText("out_trade_no"));
secondParams.put("result_code", element.elementText("result_code"));
secondParams.put("return_code", element.elementText("return_code"));
secondParams.put("time_end", element.elementText("time_end"));
secondParams.put("total_fee", element.elementText("total_fee"));
secondParams.put("trade_type", element.elementText("trade_type"));
secondParams.put("transaction_id", element.elementText("transaction_id"));
String paySign = PayUtil.createSign("UTF-8", serverConfig.getKey(), secondParams);
System.out.println(paySign);
// 解析返回结果
String returnXML = null;
System.out.println("回调成功");
// 业务返回成功
Charge charge = chargeService.getChargeByOrderid(element.elementText("out_trade_no"));
if ("SUCCESS".equals(element.elementText("result_code"))) {
String transaction_id = element.elementText("transaction_id");
charge.setTransaction_id(transaction_id);
System.out.println("业务成功");
System.out.println(charge.getMoney());
System.out.println(element.elementText("cash_fee"));
System.out.println(paySign);
System.out.println(element.elementText("sign"));
int money_total = Integer.valueOf(element.elementText("total_fee")) / 100;
if (paySign.equals(element.elementText("sign")) && charge.getMoney() == money_total) {
if (0 == charge.getStatus()) {
System.out.println("修改订单状态");
// 修改支付订单状态 已支付
charge.setStatus(1);
charge.setCallbacktime(new Date());
chargeService.save(charge);
UserBean UserBeanRedis = userRedisService.getUserBean(charge.getUserid());
int addMoney = Integer.valueOf(element.elementText("total_fee")) / 10;
// 龙七分档
if (chargeMoney.containsKey(money_total)) {
addMoney = chargeMoney.get(money_total);
}
if (UserBeanRedis != null) {
// userRedisService.setUserMoney(charge.getUserid(),UserBeanRedis.getMoney() + Double.valueOf(element.elementText("total_fee")) / 10);
userRedisService.addUserMoney(charge.getUserid(), addMoney);
} else {
// 查询玩家
User user = userService.getUserByUserId(charge.getUserid());
System.out.println("修改玩家豆豆");
// 修改玩家豆豆
user.setMoney(user.getMoney() + addMoney);
userService.save(user);
}
System.out.println("通知客户端刷新充值");
Map<String, String> rs = new HashMap<>();
MsgSender.sendMsg2Player(new ResponseVo("userService", "refresh", rs), charge.getUserid());
} else {
Map<String, String> rs = new HashMap<>();
rs.put("err_code", element.elementText("err_code"));
rs.put("err_code_des", element.elementText("err_code_des"));
ResponseVo vo = new ResponseVo("userService", "refresh", rs);
vo.setCode(ErrorCode.ORDER_WAS_PAID);
MsgSender.sendMsg2Player(vo, charge.getUserid());
}
/*returnXML = "<xml>";
returnXML += "<return_code>![CDATA[SUCCESS]]</return_code>";
returnXML += "<return_msg>![CDATA[OK]]</return_msg>";
returnXML += "</xml>";*/
returnXML = "SUCCESS";
} else {
Map<String, String> rs = new HashMap<>();
rs.put("err_code", element.elementText("err_code"));
rs.put("err_code_des", element.elementText("err_code_des"));
ResponseVo vo = new ResponseVo("userService", "refresh", rs);
vo.setCode(ErrorCode.PARAMETER_SIGN_MONEY_ERROR);
MsgSender.sendMsg2Player(vo, charge.getUserid());
returnXML = "SUCCESS";
}
} else {
// 余额不足
if ("NOTENOUGH".equals(element.elementText("err_code"))) {
Map<String, String> rs = new HashMap<>();
rs.put("err_code", element.elementText("err_code"));
rs.put("err_code_des", element.elementText("err_code_des"));
ResponseVo vo = new ResponseVo("userService", "refresh", rs);
vo.setCode(ErrorCode.BALANCE_INSUFFICIENT);
MsgSender.sendMsg2Player(vo, charge.getUserid());
// 订单已支付
} else if ("ORDERPAID".equals(element.elementText("err_code"))) {
Map<String, String> rs = new HashMap<>();
rs.put("err_code", element.elementText("err_code"));
rs.put("err_code_des", element.elementText("err_code_des"));
ResponseVo vo = new ResponseVo("userService", "refresh", rs);
vo.setCode(ErrorCode.ORDER_WAS_PAID);
MsgSender.sendMsg2Player(vo, charge.getUserid());
// 订单已关闭
} else if ("ORDERCLOSED".equals(element.elementText("err_code"))) {
Map<String, String> rs = new HashMap<>();
rs.put("err_code", element.elementText("err_code"));
rs.put("err_code_des", element.elementText("err_code_des"));
ResponseVo vo = new ResponseVo("userService", "refresh", rs);
vo.setCode(ErrorCode.ORDER_WAS_CLOSED);
MsgSender.sendMsg2Player(vo, charge.getUserid());
}
returnXML = "SUCCESS";
}
System.out.println("回调结束,返回微信成功信息");
System.out.println(returnXML);
try {
response.getWriter().write(returnXML);
response.getWriter().flush();
} catch (IOException e) {
e.printStackTrace();
}
return returnXML;
}
use of com.code.server.constant.response.ResponseVo in project summer by foxsugar.
the class ClubServiceMsgDispatch method dispatchMsg.
public void dispatchMsg(KafkaMsgKey msgKey, JsonNode params) {
String service = params.get("service").asText();
String method = params.get("method").asText();
JsonNode node = params.get("params");
int rtn = dispatchUserService(msgKey, method, node, params);
if (rtn != 0) {
ResponseVo vo = new ResponseVo(service, method, rtn);
kafkaMsgProducer.send2Partition(IKafaTopic.GATE_TOPIC, msgKey.getPartition(), "" + msgKey.getUserId(), vo);
}
}
use of com.code.server.constant.response.ResponseVo in project summer by foxsugar.
the class GameClubService method getClubRecord.
/**
* 获得俱乐部战绩
*
* @param msgKey
* @param userId
* @param clubId
* @return
*/
public int getClubRecord(KafkaMsgKey msgKey, long userId, String clubId) {
Club club = ClubManager.getInstance().getClubById(clubId);
if (club == null) {
return ErrorCode.CLUB_NO_THIS;
}
if (club.getPresident() != userId) {
return ErrorCode.CLUB_NOT_PRESIDENT;
}
ClubRecord clubRecord = clubRecordService.getClubRecordDao().getClubRecordById(clubId);
sendMsg(msgKey, new ResponseVo("clubService", "getClubRecord", clubRecord));
return 0;
}
use of com.code.server.constant.response.ResponseVo in project summer by foxsugar.
the class GameClubService method markUser.
/**
* mark 用户
*
* @param msgKey
* @param userId
* @param clubId
* @param markUser
* @param mark
* @return
*/
public int markUser(KafkaMsgKey msgKey, long userId, String clubId, long markUser, String mark) {
Club club = ClubManager.getInstance().getClubById(clubId);
if (club == null) {
return ErrorCode.CLUB_NO_THIS;
}
if (userId != club.getPresident()) {
return ErrorCode.CLUB_CANNOT_NO_PRESIDENT;
}
ClubMember clubMember = club.getClubInfo().getMember().get("" + markUser);
clubMember.setMark(mark);
sendMsg(msgKey, new ResponseVo("clubService", "markUser", "ok"));
return 0;
}
use of com.code.server.constant.response.ResponseVo in project summer by foxsugar.
the class GameClubService method getFreeUser.
/**
* 获得空闲的玩家
*
* @param msgKey
* @param clubId
* @return
*/
public int getFreeUser(KafkaMsgKey msgKey, String clubId) {
Club club = ClubManager.getInstance().getClubById(clubId);
if (club == null) {
return ErrorCode.CLUB_NO_THIS;
}
List<ClubMember> list = new ArrayList<>();
club.getClubInfo().getMember().values().forEach(clubMember -> {
String gateId = RedisManager.getUserRedisService().getGateId(clubMember.getUserId());
boolean online = gateId != null;
if (online) {
boolean isInRoom = RedisManager.getUserRedisService().getRoomId(clubMember.getUserId()) != null;
if (!isInRoom) {
list.add(clubMember);
}
}
});
sendMsg(msgKey, new ResponseVo("clubService", "getFreeUser", list));
return 0;
}
Aggregations