Beispiel #1
0
	@SuppressWarnings("unchecked")
	public MessageReturn checkSid(String sid, int gameIdp, int serverIdp, int channelIdp, int channelSubIdp, int mobiledeviceIdp,
			int statisticAnalysisIdp) {
		MessageReturn messageReturn = new MessageReturn();

		final int gameId = gameIdp;
		final int serverId = serverIdp;
		final int channelId = channelIdp;
		final int channelSubId = channelSubIdp;
		final int mobiledeviceId = mobiledeviceIdp;
		final int statisticAnalysisId = statisticAnalysisIdp;
		LogHelper.log("UserUc->checkSid gameId:" + String.valueOf(gameId));
		LogHelper.log("UserUc->checkSid serverId:" + String.valueOf(serverId));

		String checkSidUrl = "http://payunite.ulaoda.com/UCCheckSid.ashx?sid=" + sid + "&gameId=" + gameId;
		LogHelper.log("UserUc->checkSid url:" + checkSidUrl);
		Map<String, String> retMap = null;
		try {
			String retValue = Utility.getWebContent(checkSidUrl);
			if (!Utility.isEmpty(retValue)) {
				retMap = (Map<String, String>) JSONObject.parseObject(retValue, Map.class);
			} else {
				LogHelper.log("UserUc->checkSid retMap is empty:" + checkSidUrl);
			}
		} catch (IOException e) {
			e.printStackTrace();
			LogHelper.log("UserUc->checkSid exception:" + e.getMessage());
		}

		if (retMap != null) {
			int errNo = Utility.getInt(retMap.get("ErrNo"));
			if (errNo < 0) {
				messageReturn.setErr(errNo, retMap.get("ErrMsg"));
			} else {
				Map<String, String> tempMap = new HashMap<String, String>();
				String ucid = retMap.get("ucid");
				tempMap.put("UserId", retMap.get("ucid"));
				tempMap.put("UserName", retMap.get("nickName"));

				final String channelUserId = tempMap.get("UserId");

				// 模拟登录
				new Thread() {
					public void run() {
						LogHelper.log("UserUc->checkSid thread begin" + String.valueOf(serverId));
						UserUnite.getInstance().login(gameId, serverId, channelId, channelSubId, channelUserId, mobiledeviceId,
								statisticAnalysisId);
						LogHelper.log("UserUc->checkSid thread end" + String.valueOf(serverId));
					}
				}.start();

				// 针对于傲剑游戏提供的时间签名
				setTimeSignForAojian(messageReturn, gameId, tempMap, channelId, ucid);
			}
		}
		return messageReturn;
	}
Beispiel #2
0
	/**
	 * 在我们平台创建订单
	 * 
	 * @param playerId
	 *            角色编号,供订单充值成功后调用游戏服务器,传给游戏方
	 * @param channelUserId
	 *            渠道用户编号
	 * @param channleId
	 *            我们定义的渠道编号
	 * @param channelSubId
	 *            我们定义的渠道子编号
	 * @param gameId
	 *            我们定义的游戏编号
	 * @param serverId
	 *            我们定义的服务器编号
	 * @param orderId
	 *            渠道方的订单编号
	 * @param amount
	 *            渠道方的订单金额
	 * @param payWay
	 *            渠道方的充值方式
	 * @param payWayName
	 *            渠道方的充值方式名称
	 * @return
	 */
	public MessageReturn checkOrder(String playerId, String channelUserId, int channelId, int channelSubId, int gameId, int serverId,
			String orderId, float amount, int payWay, String payWayName) {

		MessageReturn messageReturn = new MessageReturn();

		LogHelper.log("channelUserId:" + channelUserId);
		LogHelper.log("channelId:" + channelId);
		LogHelper.log("channelSubId:" + channelSubId);
		LogHelper.log("gameId:" + gameId);
		LogHelper.log("orderId:" + orderId);
		LogHelper.log("amount:" + amount);

		// 创建一下订单,不需要告知游戏方,因为会在客户端通知游戏方,订单提交成功
		// 对于订单处理成功,渠道方会调用我们的一个地址,在那里需要通知游戏方订单处理成功
		String userName = UserUnite.getUserNameByChannelUserId(channelId, channelSubId, channelUserId);
		LogHelper.log("userName:"******"", 1, refMyErr);
		int userId = 0;
		if (user != null) {
			userId = user.getUserId();

			LogHelper.log("user is not null userId:" + userId);
		}
		LogHelper.log("userId:" + userId);

		wh.order.model.Order order = null;
		// 需要先判断一下UC的这个订单是否回调web 充值端已经创建,如果已经创建则不再创建
		wh.order.model.Order queryModel = new wh.order.model.Order();
		queryModel.setTel(channelUserId + "_UCUSERIDORDERID_" + orderId);
		queryModel.setStatus((byte) 1);
		RefObject<Integer> totalCount = new RefObject<Integer>(0);
		java.util.List<wh.order.model.Order> list = wh.order.bll.Order.getInstance().getList(queryModel, totalCount, true, 1, 1, "", 0,
				refMyErr);

		if (list.size() > 0) {
			order = list.get(0);
			messageReturn.setRetObject(order.getOrderId());//统一传游老大订单编号
		}

		// 如果web服务端并没有创建orderBean,那就根据Uc传过来的参数创建OrderBean
		// 谁创建orderBean谁创建orderChannelBean
		if (order == null) {
			order = new wh.order.model.Order();
			order.setGameId(gameId);
			order.setServerId(serverId);
			order.setUserId(userId);
			order.setChargedUserId(userId);
			order.setChargedUserName(userName);
			order.setPaySourceType(OrderEnum.PaySourceType.Android客户端.getValue());
			order.setOrderType(OrderEnum.OrderType.已提交.getValue());
			order.setAccountType(OrderEnum.AccountType.D币.getValue());
			order.setChargeType(OrderEnum.ChargeType.充值游戏.getValue());
			order.setCreateDate(new Date());
			order.setModifyDate(new Date());

			order.setTel(channelUserId + "_UCUSERIDORDERID_" + orderId);
			order.setPayAccount(BigDecimal.valueOf((amount)));
			order.setRealPayAccount(BigDecimal.valueOf(amount));

			// 75为其他渠道充值
			order.setPayType((byte) 75);
			order.setStatus((byte) 1);

			// 注:因从客户端传过来的ServerId实际为SequenceNumber,所以在此要转化一下
			order.setServerId(ServerTools.getServerIdBySequenceNumber(order.getGameId(), order.getServerId(), "UserUC-checkOrder"));

			messageReturn = wh.order.bll.Order.getInstance().createUpdate(order);

			// 将数据写入OrderChannel表中
			// OrderChannel 需要的参数
			// localOrderId 本地订单编号ok
			// regChannelId 注册渠道编号---user.getChannelId()
			// ocChannelId 实际渠道编号---channel.txt
			// gameChannelId 游戏方渠道编号--->大渠道实际,小渠道7
			// status=1
			wh.order.model.OrderChannel orderChannelModel = new OrderChannel();
			orderChannelModel.setLocalOrderId(Utility.getInt(messageReturn.getRetObject()));
			orderChannelModel.setRegChannelId(user.getChannelId());
			orderChannelModel.setOcChannelId(channelId);
			orderChannelModel.setGameChannelId(channelId);
			orderChannelModel.setStatus((byte) 1);
			wh.order.bll.OrderChannel.getInstance().createUpdate(orderChannelModel);

			wh.order.model.OrderLog orderLog = new wh.order.model.OrderLog();
			orderLog.setCreateDate(new Date());
			orderLog.setLogName("playerid");
			orderLog.setDescription(playerId);
			orderLog.setOrderId(Utility.getInt(messageReturn.getRetObject()));
			orderLog.setStatus((byte) 1);
			orderLog.setUserId(userId);
			wh.order.bll.OrderLog.getInstance().createUpdate(orderLog);
		}

		return messageReturn;
	}