/**
  * 创建临时二维码Ticket
  *
  * @param accessToken
  * @param expireSeconds 有效时间,单位:秒
  * @param qrID 二维码标识
  * @return
  * @throws IOException
  * @throws WechatExceprion
  */
 @Bizlet("createTempQRImage")
 public static WechatQRCodeModel createTempQRImage(
     String accessToken, long expireSeconds, int qrID) throws IOException, WechatExceprion {
   String uri = "https://api.weixin.qq.com/cgi-bin/qrcode/create";
   NameValuePair[] queryStr = new NameValuePair[1];
   queryStr[0] = new NameValuePair(IWechatConstants.KEY_ACCESS_TOKEN, accessToken);
   JSONObject jsonObj = new JSONObject();
   jsonObj.put("expire_secondes", expireSeconds);
   jsonObj.put("action_name", WechatQRCodeModel.QR_IMAGE_TEMPORARY);
   JSONObject obj = new JSONObject();
   obj.put("scene_id", qrID);
   JSONObject obj1 = new JSONObject();
   obj1.put("scene", obj);
   jsonObj.put("action_info", obj1);
   RequestEntity requestEntity =
       new StringRequestEntity(
           jsonObj.toJSONString(),
           IWechatConstants.CONTENT_TYPE,
           IWechatConstants.DEFAULT_CHARSET);
   String result = HttpExecuter.executePostAsString(uri, queryStr, requestEntity);
   String returnCode = JSONObject.parseObject(result).getString(IWechatConstants.ERROR_CODE);
   if (returnCode == null || IWechatConstants.RETURN_CODE_SUCCESS.equals(returnCode)) {
     return JSONObject.parseObject(result, WechatQRCodeModel.class);
   } else throw new WechatExceprion("[AccountOperations#createTempQRImage]" + result);
 }
Exemple #2
0
 /** 根据经纬度获取地址 */
 public static AMapAddress getAddress(double longitude, double latitude) {
   AMapAddress address = null;
   String url = MessageFormat.format(aMapUrl, String.valueOf(longitude), String.valueOf(latitude));
   String str = HttpUtils.get(url);
   try {
     if (StringUtils.isNotBlank(url)) {
       JSONObject json = JSONObject.parseObject(str);
       if (null != json) {
         int status = json.getIntValue("status");
         if (status == 1) {
           JSONObject regeocode = json.getJSONObject("regeocode");
           if (null != regeocode) {
             JSONObject addressComponent = regeocode.getJSONObject("addressComponent");
             if (null != addressComponent) {
               // city 值不固定
               String province = addressComponent.getString("province");
               String citycode = addressComponent.getString("citycode");
               String city = addressComponent.getString("city");
               if (StringUtils.isNotBlank(city) && city.equals("[]")) {
                 city = "";
               }
               address = new AMapAddress();
               address.setCityCode(citycode);
               address.setProvince(province);
               address.setCity(city);
             }
           }
         }
       }
     }
   } catch (Exception e) {
   }
   return address;
 }
  @Override
  public Boolean dialEc2(Integer jobId, String destMobile) {

    StringBuffer sb = new StringBuffer();
    sb.append("accessId=" + ConstantsForAccount.CALLENGINE_ACCESS_ID);
    sb.append("&accessKey=" + ConstantsForAccount.CALLENGINE_ACCESS_KEY);
    sb.append("&username="******"&destNum=" + destMobile);

    System.out.println(sb.toString());

    System.out.println(new Date());

    String res =
        HttpRequestUtils.sendUTF8Post(
            ConstantsForAccount.CALLENGINE_URL,
            ConstantsForAccount.CALLENGINE_DIAL_METHOD,
            sb.toString(),
            "");
    System.out.println(res);

    if (res == null || res.equals("")) {
      return false;
    }

    JSONObject resJson = JSONObject.parseObject(res);
    String code = resJson.getString("code");
    if (code != null && code.equals("0")) {
      return true;
    } else {
      return false;
    }
  }
Exemple #4
0
 public static AMapAddress getAddress(String addressStr, String city) {
   AMapAddress address = null;
   String url = MessageFormat.format(aMapGeoUrl2, addressStr, city);
   String str = HttpUtils.get(url);
   try {
     if (StringUtils.isNotBlank(str)) {
       JSONObject json = JSONObject.parseObject(str);
       if (null != json) {
         int status = json.getIntValue("status");
         if (status == 1) {
           JSONArray geocodes = json.getJSONArray("geocodes");
           if (null != geocodes && geocodes.size() > 0) {
             JSONObject jsonAddress = geocodes.getJSONObject(0);
             address = new AMapAddress();
             address.setCity(jsonAddress.getString("city"));
             address.setCityCode(jsonAddress.getString("citycode"));
             address.setProvince(jsonAddress.getString("province"));
           }
         }
       }
     }
   } catch (Exception e) {
     e.printStackTrace();
   }
   return address;
 }
  @POST
  @Path("userOnlineWithDecrypt")
  @Override
  public Map<String, Object> userOnlineWithDecrypt(Map<String, Object> parameters) {
    String code = ""; // 状态码
    String message = ""; // 返回消息
    if (parameters != null) {
      try {
        String resultJson = rbisService.offlineWithDecrypt(parameters);
        // 转换为json数据
        JSONObject jsonObject = JSONObject.parseObject(resultJson);
        // content  所有数据
        JSONObject content = (JSONObject) jsonObject.get("content");
        int state = content.getIntValue("code");

        if (state == 100) {
          code = "00";
          message = "用户成功上线!";
        } else {
          code = "11";
          message = content.getString("desc");
        }
      } catch (Exception e) {

        message = "系统错误,用户上线失败!";
      }
    }
    return CommonUtil.returnObjectMap(code, message, "", null);
  }
  @Override
  public Boolean hangupEc2(Integer jobId) {

    StringBuffer sb = new StringBuffer();
    sb.append("accessId=" + ConstantsForAccount.CALLENGINE_ACCESS_ID);
    sb.append("&accessKey=" + ConstantsForAccount.CALLENGINE_ACCESS_KEY);
    sb.append("&username="******"");

    if (res == null || res.equals("")) {
      return false;
    }

    JSONObject resJson = JSONObject.parseObject(res);
    String code = resJson.getString("code");
    if (code != null && code.equals("0")) {
      return true;
    }
    return false;
  }
  private List<ServerNode> doNodesDiscovery() throws Exception {
    if (logger_ != null) {
      if (logger_.isInfoEnabled()) logger_.info("nodes discovery start...");
    }

    List<String> serverNodes = registerPathNodeDataChangeWatcher(zkNodePath_);
    if (serverNodes == null) serverNodes = new ArrayList<>();

    List<ServerNode> newestServerNodes = new ArrayList<>();
    for (final String nodeKey : serverNodes) {
      final byte[] nodeValueBytes =
          zkClient_.getData().forPath(String.format("%s/%s", zkNodePath_, nodeKey));
      if (nodeValueBytes == null || nodeValueBytes.length <= 0) continue;
      final String nodeValueInfo = new String(nodeValueBytes, ZK_CHAR_SET);
      final ServerNodeInfo serverNode = JSONObject.parseObject(nodeValueInfo, ServerNodeInfo.class);
      newestServerNodes.add(serverNode);
    }
    if (serverNodes != null) serverNodes.clear();
    synchronized (this.serverNodes_) {
      this.serverNodes_.clear();
      this.serverNodes_.addAll(newestServerNodes);

      if (logger_ != null) {
        if (logger_.isInfoEnabled())
          logger_.info(
              String.format(
                  "current discovery's server nodes count (%d)", this.serverNodes_.size()));
      }
    }
    if (logger_ != null) {
      if (logger_.isInfoEnabled()) logger_.info("nodes discovery end...");
    }
    return this.nodes();
  }
Exemple #8
0
  /**
   * 验证手机验证码
   *
   * @param headers 头部信息
   * @param content post 请求参数
   * @return
   */
  @Path("/valid/code")
  @POST
  @Produces("application/json;charset=utf-8")
  public String validcode(String content) {

    if (StringUtils.isEmpty(content)) {
      return OpenResult.parameterError("无参数").buildJson();
    }
    JSONObject json = JSONObject.parseObject(content);
    String mobileno = json.getString("mobileno");
    String codetype = json.getString("codetype");
    String validcode = json.getString("validcode");
    if (StringUtils.isBlank(mobileno)
        || StringUtils.isBlank(codetype)
        || StringUtils.isBlank(validcode)) {
      return OpenResult.parameterError("参数错误").buildJson();
    }
    try {

      JSONObject result = registService.checkIdentifyingCode(mobileno, codetype, validcode);
      if (result != null) {
        int retcode = result.getIntValue("retcode");
        String msg = result.getString("msg");
        if (retcode != 0) {
          return OpenResult.serviceError(retcode, msg).buildJson();
        }
      } else {
        return OpenResult.unknown("服务异常").buildJson();
      }
      return result.toJSONString();
    } catch (StockServiceException e) {
      log.error("验证手机验证码异常:" + e);
      return OpenResult.serviceError(e.getRetcode(), e.getMsg()).buildJson();
    }
  }
Exemple #9
0
 @Path("/findpwd/validcode")
 @POST
 @Produces("application/json;charset=utf-8")
 public String validCodeForFindPwd(String content) {
   if (StringUtils.isEmpty(content)) {
     return OpenResult.parameterError("无参数").buildJson();
   }
   JSONObject json = JSONObject.parseObject(content);
   String userId = json.getString("userid");
   String mobileno = json.getString("mobileno");
   String validcode = json.getString("validcode");
   if (StringUtils.isEmpty(userId)
       || StringUtils.isEmpty(mobileno)
       || StringUtils.isEmpty(validcode)) {
     return OpenResult.parameterError("参数错误").buildJson();
   }
   try {
     JSONObject result = personalService.validCodeForFindPasswd(userId, mobileno, validcode);
     if (result != null) {
       if (result.getInteger("retcode") != 0) {
         return result.toJSONString();
       }
       MobileCodeResult codeResult = new MobileCodeResult();
       codeResult.setExpiredtime(result.getLong("expiredtime"));
       return OpenResult.ok().add("data", codeResult).buildJson();
     } else {
       return OpenResult.unknown("服务异常").buildJson();
     }
   } catch (StockServiceException e) {
     log.error("找回密码时验证验证码异常:" + e);
     return OpenResult.serviceError(e.getRetcode(), e.getMsg()).buildJson();
   }
 }
Exemple #10
0
 /**
  * 解析token数据
  *
  * @param data
  * @return
  */
 private boolean parseData(String data) {
   JSONObject jsonObject = JSONObject.parseObject(data);
   String tokenName = tokenName();
   String expiresInName = expiresInName();
   try {
     String token = jsonObject.get(tokenName).toString();
     if (StringUtils.isBlank(token)) {
       logger.error("token获取失败,获取结果" + data);
       return false;
     }
     this.token = token;
     this.tokenTime = (new Date()).getTime();
     String expiresIn = jsonObject.get(expiresInName).toString();
     if (StringUtils.isBlank(expiresIn)) {
       logger.error("token获取失败,获取结果" + expiresIn);
       return false;
     } else {
       this.expires = Long.valueOf(expiresIn);
     }
   } catch (Exception e) {
     logger.error(
         "token 结果解析失败,token参数名称: "
             + tokenName
             + "有效期参数名称:"
             + expiresInName
             + "token请求结果:"
             + data);
     e.printStackTrace();
     return false;
   }
   return true;
 }
Exemple #11
0
 /**
  * 发货通知
  *
  * @param access_token
  * @param openid
  * @param transid
  * @param out_trade_no
  * @return
  * @throws IOException
  * @throws NoSuchProviderException
  * @throws NoSuchAlgorithmException
  * @throws KeyManagementException
  * @throws InterruptedException
  * @throws ExecutionException
  */
 public static boolean delivernotify(
     String access_token, String openid, String transid, String out_trade_no)
     throws IOException, ExecutionException, InterruptedException {
   Map<String, String> paras = new HashMap<String, String>();
   paras.put("appid", ConfKit.get("AppId"));
   paras.put("openid", openid);
   paras.put("transid", transid);
   paras.put("out_trade_no", out_trade_no);
   paras.put("deliver_timestamp", (System.currentTimeMillis() / 1000) + "");
   paras.put("deliver_status", "1");
   paras.put("deliver_msg", "ok");
   // 签名
   String app_signature = deliverSign(paras);
   paras.put("app_signature", app_signature);
   paras.put("sign_method", "sha1");
   String json =
       HttpKit.post(DELIVERNOTIFY_URL.concat(access_token), JSONObject.toJSONString(paras));
   if (StringUtils.isNotBlank(json)) {
     JSONObject object = JSONObject.parseObject(json);
     if (object.containsKey("errcode")) {
       int errcode = object.getIntValue("errcode");
       return errcode == 0;
     }
   }
   return false;
 }
  public JSONObject clientVerifyVoiceprint(
      String id,
      String name,
      String codec,
      int sr,
      boolean bVerify,
      String rule,
      byte[] data,
      int passtype) {
    Map<String, String> parameters = new HashMap<String, String>();
    parameters.put(Constants.API_KEY, super.getClient().getKey());
    parameters.put(Constants.API_SECRET, super.getClient().getSecret());
    parameters.put(Constants.ID, id);
    parameters.put(Constants.NAME, name);
    parameters.put(Constants.CODEC, codec);
    parameters.put(Constants.SAMPLERATE, String.valueOf(sr));
    parameters.put(Constants.VERIFY, String.valueOf(bVerify));
    parameters.put(Constants.SPEECH_RULE, rule);
    parameters.put(Constants.PASSTYPE, String.valueOf(passtype));

    String tokenResult =
        HttpURLUtils.doUploadFile(
            super.getClient().getServerString() + Constants.URL_MODEL_VERIFY,
            parameters,
            Constants.FILEPARAM,
            "./testfile.wav",
            "multipart/form-data;",
            data);
    JSONObject tokenJson = (JSONObject) JSONObject.parseObject(tokenResult);

    return tokenJson;
  }
  public boolean generateAccessKey() {
    try {
      String respstr =
          HttpUtil.doGet(httphost + "/token/generate.json?type=DEVICE&" + _csrftoken_, cookie);
      JSONObject jo = JSONObject.parseObject(respstr);

      deviceAccessKey = jo.get("token") + "";
      respstr = HttpUtil.doGet(httphost + "/token/generate.json?type=USER&" + _csrftoken_, cookie);

      jo = JSONObject.parseObject(respstr);
      userAccessKey = jo.get("token") + "";

      return true;
    } catch (Exception ex) {
      return false;
    }
  }
Exemple #14
0
 public Map<String, Object> initJsonMap() {
   if (fieldsMap == null) {
     fieldsMap = JSONObject.parseObject(getJson());
     if (fieldsMap == null) {
       fieldsMap = new HashMap<String, Object>();
     }
   }
   return fieldsMap;
 }
Exemple #15
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;
	}
 public static Banner parse(String paramString) {
   try {
     Banner localBanner = (Banner) JSONObject.parseObject(paramString, Banner.class);
     return localBanner;
   } catch (Exception localException) {
     localException.printStackTrace();
   }
   return null;
 }
 public void setJson(String json) {
   this.json = json;
   try { // 转换json对象
     jsonObject = JSONObject.parseObject(json);
   } catch (Exception e) {
     e.printStackTrace();
     jsonObject = null;
   }
 }
Exemple #18
0
 public String format() throws JSONException {
   try {
     JSONObject json = JSONObject.parseObject(src);
   } catch (JSONException e) {
     // 对json进行简单的校验,如果不符合格式那么jsonobject在解析的时候会报错
     throw e;
   }
   return format(src);
 }
  @Test
  public void testFastJsonEnum() {
    FastJson_Msg_Bean bean = new FastJson_Msg_Bean(1, Enum_StatusCodeEnum.OK);
    String jsonStr = JSONObject.toJSONString(bean);
    logger.info(jsonStr);

    FastJson_Msg_Bean bean2 = JSONObject.parseObject(jsonStr, FastJson_Msg_Bean.class);
    logger.info(bean2);
  }
Exemple #20
0
 public void addField(String field, String value, String json) {
   if (StringUtil.isNotBlank(field) && StringUtil.isNotBlank(value)) {
     Map<String, Object> map = JSONObject.parseObject(json);
     if (map == null) {
       map = new HashMap<String, Object>();
     }
     map.put(field, value);
     setJson(JSONObject.toJSONString(map));
   }
 }
 /**
  * 将长链接转成短链接
  *
  * @param accessToken
  * @param longUrl 长链接URL
  * @return short_url
  * @throws IOException
  * @throws WechatExceprion
  */
 @Bizlet("connection2Short")
 public static String connection2Short(String accessToken, String longUrl)
     throws IOException, WechatExceprion {
   String uri = "https://api.weixin.qq.com/cgi-bin/shorturl";
   NameValuePair[] queryStr = new NameValuePair[1];
   queryStr[0] = new NameValuePair(IWechatConstants.KEY_ACCESS_TOKEN, accessToken);
   JSONObject jsonObj = new JSONObject();
   jsonObj.put("long_url", longUrl);
   RequestEntity requestEntity =
       new StringRequestEntity(
           jsonObj.toJSONString(),
           IWechatConstants.CONTENT_TYPE,
           IWechatConstants.DEFAULT_CHARSET);
   String result = HttpExecuter.executePostAsString(uri, queryStr, requestEntity);
   String returnCode = JSONObject.parseObject(result).getString(IWechatConstants.ERROR_CODE);
   if (returnCode == null || IWechatConstants.RETURN_CODE_SUCCESS.equals(returnCode)) {
     return JSONObject.parseObject(result).getString("short_url");
   } else throw new WechatExceprion("[AccountOperations#connection2Short]" + result);
 }
Exemple #22
0
 /**
  * 更新用户信息
  *
  * @param headers
  * @param content
  * @return
  */
 @Path("/update/userInfo")
 @POST
 @Produces("application/json;charset=utf-8")
 public String updateUserInfo(String content) {
   if (StringUtils.isEmpty(content)) {
     return OpenResult.parameterError("无参数").buildJson();
   }
   JSONObject json = JSONObject.parseObject(content);
   String userId = json.getString("userId");
   String sessionId = json.getString("sessionId");
   String validdate = json.getString("validdate");
   String postcode = json.getString("postcode");
   String regioncode = json.getString("regioncode");
   String address = json.getString("address");
   Integer sex = json.getInteger("sex");
   String description = json.getString("description");
   String reservedinfo = json.getString("reservedinfo");
   if (StringUtils.isEmpty(userId) || StringUtils.isEmpty(sessionId)) {
     return OpenResult.parameterError("参数错误").buildJson();
   }
   // 校验性别
   if (sex != null) {
     if (sex > 1 || sex < 0) {
       return OpenResult.parameterError("性别参数错误").buildJson();
     }
   }
   if (StringUtils.isNotEmpty(postcode)) {
     // 校验邮政编码
     boolean flag = registService.checkPostCode(postcode);
     if (!flag) {
       return OpenResult.parameterError("请输入正确的邮编").buildJson();
     }
   }
   if (checkSessionId(userId, sessionId)) {
     try {
       JSONObject userRes =
           registService.updateUserInfo(
               userId, validdate, postcode, regioncode, address, sex, description, reservedinfo);
       if (userRes != null) {
         int retcode = userRes.getIntValue("retcode");
         String msg = userRes.getString("msg");
         if (retcode != 0) {
           return OpenResult.parameterError(retcode, msg).buildJson();
         }
         return userRes.toJSONString();
       } else {
         return OpenResult.unknown("服务异常").buildJson();
       }
     } catch (StockServiceException e) {
       return OpenResult.serviceError(e.getRetcode(), e.getMsg()).buildJson();
     }
   } else {
     return OpenResult.noAccess("未授权").buildJson();
   }
 }
  @Override
  public void messageReceived(IoSession session, Object message) throws Exception {
    count++;
    String m = spliteString(message);
    String n = m;
    LogUtil.print(count + "-json:" + m);
    BaseResp base = JSONObject.parseObject(m, BaseResp.class);
    LogUtil.w(count + "-Base:" + base.toString());
    System.out.println("m--" + m);
    Message msg = new Message();

    // 0:成功 1:失败 2:bind 3:验证成功
    System.out.println("code:" + base.getResCode());
    switch (Integer.parseInt(base.getResCode())) {
      case 0:
        ReceivedMsgBean rmsg = JSONObject.parseObject(n, ReceivedMsgBean.class);
        System.out.println("rsmg:" + rmsg.toString());
        msg.what = ParamConstant.RECEIVED;
        msg.obj = rmsg;
        mPushService.myHandler.sendMessage(msg);
        break;
      case 1:
        LogUtil.e("服务器处理失败");
        break;
        //		case 2:
        //			ReceivedSessionBean bean = JSONObject.parseObject(m, ReceivedSessionBean.class);
        //			msg.what = mPushService.BIND;
        //			msg.obj = bean;
        //			mPushService.myHandler.sendMessage(msg);
        //			break;
      case 3:
        LogUtil.print("收到推送已向服务器验证");
        break;
      case 4:
        LogUtil.print("连接mina成功,拿到sessionId");
        break;

      default:
        break;
    }
  }
Exemple #24
0
  /**
   * 获取手机验证码
   *
   * @param headers
   * @param content
   * @return
   */
  @Path("/get/code")
  @POST
  @Produces("application/json;charset=utf-8")
  public String getCode(String content) {
    // 参数是否为空
    if (StringUtils.isEmpty("content")) {
      return OpenResult.parameterError("无参数").buildJson();
    }
    JSONObject json = JSONObject.parseObject(content);
    String mobileno = json.getString("mobileno");

    // 手机注册验证码:201;手机找回密码:205,重置密码:253
    String codetype = json.getString("codetype");
    if (StringUtils.isEmpty(mobileno) || StringUtils.isEmpty(codetype)) {
      return OpenResult.parameterError("参数错误").buildJson();
    }
    // 验证手机号格式是否正确
    boolean flag = ValidateUtil.isMobile(mobileno);
    if (!flag) {
      return OpenResult.serviceError(10119, "手机号码有误").buildJson();
    }
    // 手机号是否已被注册
    JSONObject result = registService.mobileUnique(mobileno);

    if (result != null) {
      if (result.getIntValue("retcode") != 0) {
        return OpenResult.serviceError(result.getIntValue("retcode"), result.getString("msg"))
            .buildJson();
      }
    } else {
      return OpenResult.unknown("服务异常").buildJson();
    }
    try {
      // 获取手机验证码
      result = registService.getIdentifyingCode(mobileno);
      if (result != null) {
        int retcode = result.getIntValue("retcode");
        String msg = result.getString("msg");
        if (retcode != 0) {
          return OpenResult.serviceError(retcode, msg).buildJson();
        }
      } else {
        return OpenResult.unknown("服务异常").buildJson();
      }
      MobileCodeResult mobileCodeResult = new MobileCodeResult();
      Long expiredtime = result.getLong("expiredtime");
      mobileCodeResult.setExpiredtime(expiredtime);
      return OpenResult.ok().add("data", mobileCodeResult).buildJson();
    } catch (StockServiceException e) {
      log.error("注册时获取手机验证码异常:" + e);
      return OpenResult.serviceError(e.getRetcode(), e.getMsg()).buildJson();
    }
  }
Exemple #25
0
 /**
  * 创建分组
  *
  * @param name 分组名字(30个字符以内)
  * @return
  * @throws WeChatException
  */
 public Group createGroup(String name) throws WeChatException {
   JSONObject nameJson = new JSONObject();
   JSONObject groupJson = new JSONObject();
   nameJson.put("name", name);
   groupJson.put("group", nameJson);
   String requestData = groupJson.toString();
   logger.info("request data " + requestData);
   String resultStr = HttpUtils.post(GROUP_CREATE_POST_URL + this.accessToken, requestData);
   logger.info("return data " + resultStr);
   WeChatUtil.isSuccess(resultStr);
   return JSONObject.parseObject(resultStr).getObject("group", Group.class);
 }
Exemple #26
0
  @Path("/get/userInfo")
  @POST
  @Produces("application/json;charset=utf-8")
  public String getUserInfo(@Context HttpServletRequest request, String content) {
    if (StringUtils.isEmpty(content)) {
      return OpenResult.parameterError("无参数").buildJson();
    }
    JSONObject json = JSONObject.parseObject(content);
    String idNumber = json.getString("idNumber");
    String captcha = json.getString("captcha");
    String uuId = json.getString("uuId");
    if (StringUtils.isEmpty(idNumber)
        || StringUtils.isEmpty(captcha)
        || StringUtils.isEmpty(uuId)) {
      return OpenResult.parameterError("参数错误").buildJson();
    }
    try {
      if (!ValidateUtil.isIdNumber(idNumber)) {
        return OpenResult.parameterError(10103, "身份证号有误,请正确填写您的18位身份证号").buildJson();
      }
      if (!ImageCaptchaValidator.validateResponse(uuId, captcha)) {
        return OpenResult.parameterError(10203, "验证码不正确").buildJson();
      }
      JSONObject result = personalService.queryUserInfo(idNumber);
      if (result != null) {
        int retcode = result.getIntValue("retcode");
        if (retcode != 0) {
          return result.toJSONString();
        }
        NoPwdResult pwdResult = new NoPwdResult();
        String mobileNo = result.getString("mobileno");
        mobileNo = InfoMasker.masker(mobileNo, 3, 4, "*", 1);
        pwdResult.setMobileno(mobileNo);

        JSONObject userInfo = new JSONObject();
        userInfo.put("mobileno", result.getString("mobileno"));
        userInfo.put("userid", result.getString("userid"));
        userInfo.put("email", result.getString("email"));
        setMemcacheJSON(idNumber, userInfo);

        return OpenResult.ok().add("data", pwdResult).buildJson();
      } else {
        return OpenResult.unknown("服务异常").buildJson();
      }

    } catch (StockRestException e) {
      log.error("找回密码时获取用户信息异常:" + e);
      return OpenResult.serviceError(e.getRetcode(), e.getMsg()).buildJson();
    } catch (StockServiceException e) {
      log.error("找回密码时获取用户信息异常:" + e);
      return OpenResult.serviceError(e.getRetcode(), e.getMsg()).buildJson();
    }
  }
Exemple #27
0
 public void get() throws ClassNotFoundException, SQLException, IOException {
   Class.forName("com.mysql.jdbc.Driver");
   String url = "jdbc:mysql://localhost:3306/cpsystem";
   String usernameMysql = "root";
   String passwordMysql = "root";
   Connection conn = DriverManager.getConnection(url, usernameMysql, passwordMysql);
   Statement stmt = conn.createStatement();
   HttpServletRequest request = ServletActionContext.getRequest();
   JSONObject dt = JSONObject.parseObject(request.getParameter("dt"));
   String account = (String) dt.get("account");
   String sql = "select * from user where phone='" + account + "'";
   ResultSet userinfo = stmt.executeQuery(sql);
   JSONObject json = new JSONObject();
   JSONObject info = new JSONObject();
   if (userinfo.next()) {
     if (userinfo.getInt("type") == 1) { // driver
       info.put("id", userinfo.getInt("id"));
       info.put("phone", userinfo.getString("phone"));
       info.put("email", userinfo.getString("email"));
       info.put("name", userinfo.getString("name"));
       info.put("type", userinfo.getInt("type"));
       sql = "select * from driver_info where id=" + userinfo.getInt("id");
       stmt = conn.createStatement();
       ResultSet driverinfo = stmt.executeQuery(sql);
       if (driverinfo.next()) {
         info.put("success_count", driverinfo.getInt("success_count"));
         info.put("success_thismonth", driverinfo.getInt("success_thismonth"));
         info.put("send_count", driverinfo.getInt("send_count"));
         info.put("send_thismonth", driverinfo.getInt("send_thismonth"));
       }
       json.put("info", info);
       HttpServletResponse response = ServletActionContext.getResponse();
       response.setCharacterEncoding("utf-8");
       response.getWriter().write(json.toString());
     } else if (userinfo.getInt("type") == 2) { // passenger
       info.put("id", userinfo.getInt("id"));
       info.put("phone", userinfo.getString("phone"));
       info.put("email", userinfo.getString("email"));
       info.put("type", userinfo.getString("type"));
       sql = "select * from passenger_info where id=" + userinfo.getInt("id");
       stmt = conn.createStatement();
       ResultSet passengerinfo = stmt.executeQuery(sql);
       if (passengerinfo.next()) {
         info.put("take_count", passengerinfo.getInt("take_count"));
         info.put("take_thismonth", passengerinfo.getInt("take_thismonth"));
       }
       json.put("info", info);
       HttpServletResponse response = ServletActionContext.getResponse();
       response.setCharacterEncoding("utf-8");
       response.getWriter().write(json.toString());
     }
   }
 }
 /**
  * @param需要提供订单id,物品的消耗情况
  * @need 订单进行结算,将状态修改为40,插入一条销售记录,并计算出对应订单的销售金*额的并修改(信息来源配送人员)
  */
 @RequestMapping(value = "/order_balance_update", method = RequestMethod.POST)
 @ResponseBody
 public JSONObject order_balance_update(
     HttpSession httpSession, long order_id, String sell_items) {
   staff staff = (staff) httpSession.getAttribute("staff"); // 获取员工
   if (staff == null) {
     return CommonUtil.constructResponse(0, "员工不存在", null);
   }
   JSONObject jsonObject = JSONObject.parseObject(sell_items);
   JSONArray goods = (JSONArray) jsonObject.get("foods");
   List<Snacks> snacks = orderItemService.getOrderitemByDefaultOrderId_4(order_id);
   Float order_cost_money = Float.valueOf(0);
   Float order_sell_money = Float.valueOf(0);
   for (Object j : goods) {
     JSONObject jo = JSONObject.parseObject(j.toString());
     for (Snacks s : snacks) {
       long snacks_id = Long.valueOf(jo.get("snacks_id").toString());
       if (snacks_id == s.getSnacks_id()) {
         Integer nu = jo.getInteger("snacks_num");
         if (nu == null || nu < 0 || nu > s.getSnacks_number()) {
           return CommonUtil.constructResponse(0, "食品数量返回错误", null);
         } else {
           order_cost_money += nu * s.getSnacks_cost_price();
           order_sell_money += nu * s.getSnacks_sell_price();
         }
       }
     }
   }
   for (Object j : goods) {
     JSONObject jo = JSONObject.parseObject(j.toString());
     long snacks_id = Long.valueOf(jo.get("snacks_id").toString());
     Integer snacks_number = jo.getInteger("snacks_num");
     sellItemService.insertsell_items(snacks_id, snacks_number, order_id);
   }
   orderService.update_order_price_1(order_id, order_cost_money, order_sell_money);
   loadTask.delTask(order_id + "", "BalanceJob");
   loadTask.delTask(order_id + "", "BalanceJob_1");
   return CommonUtil.constructResponse(1, "结算完成", 0);
 }
  public JSONObject clientGetSysInfo(int passtype) {
    Map<String, String> parameters = new HashMap<String, String>();
    parameters.put(Constants.API_KEY, super.getClient().getKey());
    parameters.put(Constants.API_SECRET, super.getClient().getSecret());
    parameters.put(Constants.PASSTYPE, String.valueOf(passtype));

    String tokenResult =
        HttpURLUtils.doPost(
            super.getClient().getServerString() + Constants.URL_SYSTEM_GETINFO, parameters);
    JSONObject tokenJson = (JSONObject) JSONObject.parseObject(tokenResult);
    Log.i("reqUrl", super.getClient().getServerString() + Constants.URL_SYSTEM_GETINFO);
    return tokenJson;
  }
  @Override
  public void onGetChannelCount(String response) {
    JSONObject jsonObject = JSONObject.parseObject(response);
    channelCount = jsonObject.getIntValue("count");

    if (channelCount > 0) {
      try {
        RestHelper.getInstance(context).getChannelList();
      } catch (Exception e) {
        toast(e.getMessage());
      }
    }
  }