Exemplo n.º 1
0
 /**
  * JsonObject 转换为User对象
  *
  * @param userJson
  * @return
  */
 private static WechatUserDto jsonObject2User(JSONObject userJson) {
   String subscribe = userJson.getString("subscribe");
   String openId = userJson.getString("openid");
   String nickname = userJson.getString("nickname");
   int sex = userJson.getIntValue("sex");
   String language = userJson.getString("language");
   String city = userJson.getString("city");
   String province = userJson.getString("province");
   String country = userJson.getString("country");
   String headImgUrl = userJson.getString("headimgurl");
   long subscribeTime = userJson.getLong("subscribe_time");
   String unionid = userJson.getString("unionid");
   String remark = userJson.getString("remark");
   int groupid = userJson.getIntValue("groupid");
   WechatUserDto responseUser = new WechatUserDto();
   responseUser.setCity(city);
   responseUser.setSubscribe(subscribe);
   responseUser.setOpenId(openId);
   responseUser.setNickname(nickname);
   responseUser.setSex(sex);
   responseUser.setLanguage(language);
   responseUser.setProvince(province);
   responseUser.setCountry(country);
   responseUser.setHeadImgUrl(headImgUrl);
   responseUser.setSubscribeTime(subscribeTime);
   responseUser.setUnionId(unionid);
   responseUser.setRemark(remark);
   responseUser.getGroup().setId(groupid);
   return responseUser;
 }
Exemplo n.º 2
0
  @Override
  public UserDataResponse parse(String paramString) {
    UserDataResponse response = null;
    try {
      response = new UserDataResponse();
      JSONObject jsonObject = JSON.parseObject(paramString);
      response.StateCode = jsonObject.getString(ERROR_CODE);
      response.Msg = jsonObject.getString(MSG);
      JSONObject object = jsonObject.getJSONObject("Data");

      UserData userData = new UserData();
      if (object != null) {
        userData.Birthday = object.getString("Birthday"); // 生日
        userData.Age = object.getString("Age"); // 年龄
        userData.Email = object.getString("Email"); // 邮箱
        userData.Gender = object.getString("Gender"); // 性别
        userData.QQ = object.getString("QQ"); // QQ
        userData.Name = object.getString("Name"); // 姓名

        userData.GradeName = object.getString("GradeName"); // 等级名称
        userData.NestGradeName = object.getString("NestGradeName"); // 下一等级名称
        userData.Point = object.getIntValue("Point"); // 积分
        userData.Exp = object.getIntValue("Exp"); // 经验
        userData.NeedExp = object.getIntValue("NeedExp"); // 这一级的总经验
      }

      // userData.Nickname = jsonObject.getString("Nickname");// 昵称

      response.userData = userData;

    } catch (Exception e) {
      e.printStackTrace();
    }
    return response;
  }
  public MessageDetialInfo parseJsonThreadPage(String js, int page) {
    js = js.replaceAll("\"content\":\\+(\\d+),", "\"content\":\"+$1\",");
    js = js.replaceAll("\"subject\":\\+(\\d+),", "\"subject\":\"+$1\",");

    js = js.replaceAll("\"content\":(0\\d+),", "\"content\":\"$1\",");
    js = js.replaceAll("\"subject\":(0\\d+),", "\"subject\":\"$1\",");
    js = js.replaceAll("\"author\":(0\\d+),", "\"author\":\"$1\",");
    final String start = "\"__P\":{\"aid\":";
    final String end = "\"this_visit_rows\":";
    if (js.indexOf(start) != -1 && js.indexOf(end) != -1) {
      Log.w(TAG, "here comes an invalid response");
      String validJs = js.substring(0, js.indexOf(start));
      validJs += js.substring(js.indexOf(end));
      js = validJs;
    }
    JSONObject o = null;
    try {
      o = (JSONObject) JSON.parseObject(js).get("data");
    } catch (Exception e) {
      Log.e(TAG, "can not parse :\n" + js);
    }
    if (o == null) return null;

    MessageDetialInfo data = new MessageDetialInfo();

    JSONObject o1;
    o1 = (JSONObject) o.get("0");
    if (o1 == null) return null;

    JSONObject userInfoMap = (JSONObject) o1.get("userInfo");

    List<MessageArticlePageInfo> messageEntryList = convertJSobjToList(o1, userInfoMap, page);
    if (messageEntryList == null) return null;
    data.setMessageEntryList(messageEntryList);
    data.set__currentPage(o1.getIntValue("currentPage"));
    data.set__nextPage(o1.getIntValue("nextPage"));
    String alluser = o1.getString("allUsers"), allusertmp = "";
    alluser = alluser.replaceAll("	", " ");
    String alluserarray[] = alluser.split(" ");
    for (int i = 1; i < alluserarray.length; i += 2) {
      allusertmp += alluserarray[i] + ",";
    }
    if (allusertmp.length() > 0) allusertmp = allusertmp.substring(0, allusertmp.length() - 1);
    data.set_Alluser(allusertmp);
    if (data.getMessageEntryList().get(0) != null) {
      String title = data.getMessageEntryList().get(0).getSubject();
      if (!StringUtil.isEmpty(title)) {
        data.set_Title(title);
      } else {
        data.set_Title("");
      }
    }
    return data;
  }
Exemplo n.º 4
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();
    }
  }
Exemplo n.º 5
0
 @Override
 public void handleMessage(Message msg) {
   super.handleMessage(msg);
   switch (msg.what) {
     case 1:
       setmap(urlstr);
       calssAdapter = new CalssAdapter(array, ReplyPhoto.this);
       calss.setAdapter(calssAdapter);
       break;
     case 2:
       Toast.makeText(ReplyPhoto.this, "获取分类失败,请检查网络", Toast.LENGTH_SHORT).show();
       break;
     case 3:
       Toast.makeText(ReplyPhoto.this, "暂无分类", Toast.LENGTH_SHORT).show();
       break;
     case 4:
       dialog.dismiss();
       Toast.makeText(ReplyPhoto.this, "失败", Toast.LENGTH_SHORT).show();
       break;
     case 5:
       dialog.dismiss();
       JSONObject jsonObject = JSON.parseObject(str);
       int a = jsonObject.getIntValue("ret");
       if (a == 200) {
         JSONObject jsonObject1 = jsonObject.getJSONObject("data");
         int b = jsonObject1.getIntValue("code");
         if (b == 0) {
           //                            Bimp.tempSelectBitmap.clear();
           Bimp.tempSelectBitmap.clear();
           Bimp.max = 0;
           Intent intent = new Intent("data.broadcast.action");
           sendBroadcast(intent);
           for (int i = 0; i < PublicWay.activityList.size(); i++) {
             if (null != PublicWay.activityList.get(i)) {
               PublicWay.activityList.get(i).finish();
             }
           }
           //                            finish();
           Intent intent1 = new Intent();
           intent1.setAction("com.servicedemo4");
           intent1.putExtra("getmeeage", "4");
           ReplyPhoto.this.sendBroadcast(intent1);
         } else {
           handlers.sendEmptyMessage(4);
         }
       } else {
         handlers.sendEmptyMessage(4);
       }
       break;
   }
 }
  private List<MessageArticlePageInfo> convertJSobjToList(
      JSONObject rowMap, JSONObject userInfoMap, int page) {
    List<MessageArticlePageInfo> __R = new ArrayList<MessageArticlePageInfo>();
    if (rowMap == null) return null;
    JSONObject rowObj = (JSONObject) rowMap.get("0");
    for (int i = 1; rowObj != null; i++) {
      MessageArticlePageInfo row = new MessageArticlePageInfo();

      row.setContent(rowObj.getString("content"));
      row.setLou(20 * (page - 1) + i);
      row.setSubject(rowObj.getString("subject"));
      int time = rowObj.getIntValue("time");
      if (time > 0) {
        row.setTime(StringUtil.TimeStamp2Date(String.valueOf(time)));
      } else {
        row.setTime("");
      }
      row.setFrom(rowObj.getString("from"));
      fillUserInfo(row, userInfoMap);
      fillFormated_html_data(row, i);
      __R.add(row);
      rowObj = (JSONObject) rowMap.get(String.valueOf(i));
    }
    return __R;
  }
Exemplo n.º 7
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();
    }
  }
Exemplo n.º 8
0
  @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);
  }
Exemplo n.º 9
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;
 }
Exemplo n.º 10
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;
 }
Exemplo n.º 11
0
  private boolean parseJson(String json) {
    boolean flag = false;
    if (!TextUtils.isEmpty(json)) {
      Log.i("discovery", "discovery  json!=null");
      JSONObject obj = FjsonUtil.parseObject(json);
      if (null == obj) {
        return false;
      }
      if (200 == obj.getIntValue("code")) {
        Log.i("discovery", "discovery  code==200");
        Page++;
        List<DiscoveryItemBean> mlist =
            FjsonUtil.parseArray(obj.getString("data"), DiscoveryItemBean.class);
        if (null == mlist) {
          return false;
        } else {
          for (int i = 0; i < mlist.size(); i++) {
            if (mlist.get(i).getNews() == null || mlist.get(i).getNews().size() < 1) {
              DiscoveryItemBean bean = mlist.get(i);
              mlist.remove(bean);
              i--;
            }
          }
          newAdapter.appendData(mlist, isClearOld);
          isClearOld = false;
          return true;
        }

      } else {
        Page--;
      }
    }
    return flag;
  }
Exemplo n.º 12
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;
 }
Exemplo n.º 13
0
  /**
   * 获取用户列表
   *
   * @param nextOpenId nextOpenId
   * @param accessToken
   * @return 用户列表
   * @throws ServiceException 服务异常
   */
  public static UserOpenIdListResponse getUserOpenIdList(String nextOpenId, String accessToken)
      throws ServiceException {
    // url and params
    nextOpenId = StringUtils.isEmpty(nextOpenId) ? "" : nextOpenId;
    String url = getRequestUrl(WechatUrlConstants.USER_GET, accessToken);
    url = url.replace("NEXT_OPENID", nextOpenId);

    // call wx and get response
    JSONObject responseJson = getWxJSONObjectResponseFromHttpGetMethod(url);
    int total = responseJson.getIntValue("total");
    JSONObject dataJson = responseJson.getJSONObject("data");
    JSONArray openidArray = dataJson.getJSONArray("openid");
    List<String> openIdList = new ArrayList<String>();
    for (int index = 0; index < openidArray.size(); index++) {
      String openId = openidArray.getString(index);
      openIdList.add(openId);
    }
    String respNextOpenid = responseJson.getString("next_openid");

    UserOpenIdListResponse result = new UserOpenIdListResponse();
    result.setTotal(total);
    result.setNextOpenid(respNextOpenid);
    result.setOpenIdList(openIdList);
    return result;
  }
 /**
  *
  *
  * <pre>解析封装职位分类列表  </pre>
  *
  * @param array JsonArray
  * @return
  * @throws JSONException
  */
 private static List<PositionClassify> parsePositionClassList(JSONArray array, String pcode)
     throws JSONException {
   List<PositionClassify> positionClasss = null;
   if (!StringUtils.isEmpty(array)) {
     int nn = array.size();
     PositionClassify positionClassify = null;
     positionClasss = new ArrayList<PositionClassify>(nn);
     for (int i = 0; i < nn; i++) {
       JSONObject jObject = array.getJSONObject(i);
       positionClassify = new PositionClassify();
       String code = jObject.getString("code");
       positionClassify.setCode(code);
       positionClassify.setPcode(pcode);
       positionClassify.setValue(jObject.getString("value"));
       boolean has = jObject.getIntValue("hassub") == 1;
       positionClassify.setHasSub(has);
       if (has) {
         JSONArray subArray = jObject.getJSONArray("sublist");
         if (!StringUtils.isEmpty(subArray)) {
           positionClassify.setSubList(parsePositionClassList(subArray, code));
         }
       }
       positionClasss.add(positionClassify);
       mapPositionClassifies.put(code, positionClassify);
     }
   }
   return positionClasss;
 }
Exemplo n.º 15
0
 public void test_0() throws Exception {
   StringReader reader = new StringReader("{a:1,b:2}");
   String text = IOUtils.toString(reader);
   JSONObject json = (JSONObject) JSON.parse(text);
   Assert.assertEquals(2, json.size());
   Assert.assertEquals(1, json.getIntValue("a"));
   Assert.assertEquals(2, json.getIntValue("b"));
 }
Exemplo n.º 16
0
 public void test_1() throws Exception {
   InputStream input = new ByteArrayInputStream("{a:1,b:2}".getBytes());
   String text = IOUtils.toString(input);
   JSONObject json = (JSONObject) JSON.parse(text);
   Assert.assertEquals(2, json.size());
   Assert.assertEquals(1, json.getIntValue("a"));
   Assert.assertEquals(2, json.getIntValue("b"));
 }
Exemplo n.º 17
0
 @Override
 public MessageBlock decode(byte[] bytes) throws ProtocolException {
   try {
     String str = new String(bytes, "utf-8");
     JSONObject json = JSONObject.parseObject(str);
     Object data = json.get("data");
     MessageBlock mb = new MessageBlock(data);
     mb.setSerial(json.getLongValue("serial"));
     mb.setUid(json.getLongValue("uid"));
     mb.setCmd(json.getIntValue("cmd"));
     mb.setVersion(json.getFloatValue("version"));
     mb.setStatus(json.getIntValue("status"));
     mb.setErr(json.getString("err"));
     return mb;
   } catch (UnsupportedEncodingException e) {
     throw new ProtocolException("decode bytes[] with utf-8 error");
   }
 }
Exemplo n.º 18
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();
   }
 }
Exemplo n.º 19
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();
    }
  }
 /**
  * @param dealerId
  * @throws BusinessException
  */
 @Override
 public void addTrialErpDealerBuyService(String dealerId) throws BusinessException {
   Map<String, Object> params = Maps.newHashMap();
   DealerInfo dealerInfo = dealerInfoService.selectByPrimaryKey(dealerId);
   UserInfo dealerUserm = userInfoService.selectByPrimaryKey(dealerId);
   params.put("dealerId", dealerId);
   params.put("dealerName", dealerInfo.getDealerName());
   params.put("dealerMobile", dealerUserm.getUserMobile());
   params.put("dealerUser", dealerInfo.getDealerUser());
   params.put(
       "dealerMail",
       StringUtils.isEmpty(dealerUserm.getUserMail())
           ? "*****@*****.**"
           : dealerUserm.getUserMail());
   params.put(
       "dealerSex",
       dealerInfo.getDealerGender() == null ? 1 : (dealerInfo.getDealerGender() == 2 ? 1 : 0));
   params.put("dealerKey", dealerId);
   params.put(
       "outOfTime",
       com.zttx.web.utils.CalendarUtils.addDay(
           com.zttx.web.utils.CalendarUtils.getCurrentLong(), 60));
   params.put("userName", dealerUserm.getUserMobile());
   JSONObject _resJson = AppParameterUtils.getErpTrailJSONObject(params);
   if (_resJson == null
       || !_resJson.containsKey("code")
       || _resJson.getIntValue("code") != 121000) {
     throw new BusinessException("ERP 接口调用失败");
   }
   DealerBuyService _dealerBuyService =
       this.findBy(dealerId, CommonConstant.WebServiceItems.SERVICE_SYSTEM_STIALERP);
   if (_dealerBuyService != null) {
     throw new BusinessException("ERP试用服务已经开通,请刷页面!");
   }
   _dealerBuyService = new DealerBuyService();
   _dealerBuyService.setBeginTime(CalendarUtils.getCurrentLong());
   _dealerBuyService.setEndTime(
       CalendarUtils.addDay(com.zttx.web.utils.CalendarUtils.getCurrentLong(), 60));
   _dealerBuyService.setBuyTime(CalendarUtils.getCurrentLong());
   _dealerBuyService.setServiceId(CommonConstant.WebServiceItems.SERVICE_SYSTEM_STIALERP);
   _dealerBuyService.setServicerCate(Short.valueOf("1"));
   _dealerBuyService.setChargType(Short.valueOf("1"));
   _dealerBuyService.setBuyMoney(BigDecimal.ZERO);
   _dealerBuyService.setRefrenceId(SerialnoUtils.buildPrimaryKey());
   _dealerBuyService.setDealerId(dealerId);
   this.insertSelective(_dealerBuyService);
   // DealerInfo的服务起起时间
   dealerInfo.setBeginTime(CalendarUtils.getCurrentLong());
   dealerInfo.setEndTime(
       CalendarUtils.addDay(com.zttx.web.utils.CalendarUtils.getCurrentLong(), 60));
   dealerInfoService.updateByPrimaryKeySelective(dealerInfo);
 }
Exemplo n.º 21
0
  @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());
      }
    }
  }
Exemplo n.º 22
0
    /** 初始化数据 */
    private static void _init() {
      Map<Integer, ConfSkillGroup> dataMap = new HashMap<>();

      // JSON数据
      String confJSON = _readConfFile();
      if (StringUtils.isBlank(confJSON)) return;

      // 填充实体数据
      JSONArray confs = (JSONArray) JSONArray.parse(confJSON);
      for (int i = 0; i < confs.size(); i++) {
        JSONObject conf = confs.getJSONObject(i);
        ConfSkillGroup object =
            new ConfSkillGroup(
                conf.getIntValue("sn"),
                parseIntArray(conf.getString("activeSkills")),
                parseIntArray(conf.getString("passiveSkills")),
                conf.getIntValue("defaultSkill"),
                parseIntArray(conf.getString("relSkill")));
        dataMap.put(conf.getInteger("sn"), object);
      }

      // 保存数据
      _map = Collections.unmodifiableMap(dataMap);
    }
Exemplo n.º 23
0
  public static MessageDataItem fromJson(JSONObject json) {
    MessageDataItem item = new MessageDataItem();
    item.setSenderId(json.getString("sendId"));
    String[] ct = json.getString("content").split("private");
    item.setContent(ct[0]);
    item.setTitle(ct[1]);
    item.setSendTime(json.getString("sendTime"));
    item.setSendReceiveFlag(json.getBoolean("sendReceiveFlag"));
    item.setReadFlag(json.getBoolean("readFlag"));
    // item.setImage
    item.setReceiveDeleteFlag(json.getBoolean("receiveDeleteFlag"));
    item.setId(json.getString("tid"));
    item.setMessageType(json.getIntValue("messageType"));
    item.setSendDeleteFlag(json.getBoolean("sendDeleteFlag"));

    return item;
  }
 @Override
 public void onReceive(Context context, Intent intent) {
   JSONObject json = JSONObject.parseObject(intent.getStringExtra("json"));
   int id = json.getIntValue("id");
   boolean isMe;
   if (id == app.getMyInfo().getUserId()) {
     isMe = true;
   } else {
     isMe = false;
   }
   ChatMessage chatMessage = new ChatMessage(json, isMe);
   chatMessageList.add(chatMessage);
   mainList.setSelection(chatMessageList.size() - 1);
   if (!isMe) {
     // TODO 铃声或震动
     alert.alert();
   }
 }
Exemplo n.º 25
0
  public static Barrage parse(String jsonStr) {
    Barrage barrage = null;

    try {
      JSONObject object = JSON.parseObject(jsonStr);
      barrage = new Barrage();
      barrage.setContent(object.getString("barrage"));
      barrage.setPostTime(object.getString("posttime"));
      barrage.setVideoTime(object.getIntValue("videotime"));
      String colorStr = object.getString("color");
      barrage.setColor(colorStr);
    } catch (Exception e) {
      e.printStackTrace();
      Log.e(TAG, "get exception when parse, cause: " + e.getMessage());
    }

    return barrage;
  }
 @Override
 public void onReceive(Context context, Intent intent) {
   DLog.i("Tradition收到聊天消息");
   JSONObject json = JSONObject.parseObject(intent.getStringExtra("json"));
   int id = json.getIntValue("id");
   boolean isMe;
   if (id == app.getMyInfo().getUserId()) {
     isMe = true;
   } else {
     isMe = false;
   }
   ChatMessage chatMessage = new ChatMessage(json, isMe);
   chatMessageList.add(chatMessage);
   mainList.setSelection(chatMessageList.size() - 1);
   if (!isMe && ring != null) {
     ring.play();
   }
 }
Exemplo n.º 27
0
  /**
   * 查询用户所在分组
   *
   * @param openId 用户的OpenID
   * @return 用户所属的groupid
   */
  public Integer getIdGroup(String openId) {
    JSONObject jsonObject = new JSONObject();
    jsonObject.put("openid", openId);

    String requestData = jsonObject.toString();
    logger.info("request data " + requestData);
    String resultStr = HttpUtils.post(GROUP_GETID_POST_URL + this.accessToken, requestData);
    logger.info("return data " + resultStr);
    try {
      WeChatUtil.isSuccess(resultStr);
    } catch (WeChatException e) {
      logger.error(e.getMessage());
      e.printStackTrace();
      return null;
    }
    JSONObject resultJson = JSONObject.parseObject(resultStr);
    int groupId = resultJson.getIntValue("groupid");
    return groupId;
  }
Exemplo n.º 28
0
  private boolean renew4Commit(WfAwt prev, WfTask currtask, WfInstance wfInst, String currUserId) {
    String instId = prev.getInstId();
    if (WFConstants.TxTypes.COUNTERSIGN.equals(currtask.getTxType())) {
      prev.setCompleteFlag("Y");
      this.updateById(prev);
      WfAwt parm = new WfAwt();
      parm.setInstId(instId);
      parm.setCompleteFlag("N");
      int incompletedCount = this.selectCount(parm);
      if (incompletedCount == 0) {
        return true; // 没有未完成的待办事宜
      }

      String csOptJson = currtask.getSignChoices();
      JSONObject csOpt = (JSONObject) JSONObject.parse(csOptJson);
      parm.setCompleteFlag("Y");
      int completedCount = this.selectCount(parm);
      if (Boolean.TRUE.toString().equals(csOpt.getString("AllHandledThenGo"))) {
        parm.setCompleteFlag(null);
        int allCount = this.selectCount(parm);
        if (allCount != completedCount) {
          updateCurrAssigners4CS(wfInst, currUserId); // not finished, return
          return false;
        }
      } else {
        if (Boolean.TRUE.toString().equals(csOpt.getString("PartHandledThenGo"))) {
          int AtLeastHandled = csOpt.getIntValue("AtLeastHandled");
          if (AtLeastHandled == 0) {
            AtLeastHandled = 1;
          }
          if (completedCount < AtLeastHandled) {
            updateCurrAssigners4CS(wfInst, currUserId);
            return false;
          }
        }
      }
    } else {
      wfInst.setOptUsersPre(currUserId + ",");
    }
    return true;
  }
Exemplo n.º 29
0
 public void setmap(String str) {
   JSONObject jsonObject = JSON.parseObject(str);
   JSONObject jsonObject1 = jsonObject.getJSONObject("data");
   int a = jsonObject1.getIntValue("code");
   if (a == 0) {
     JSONArray jsonArray = jsonObject1.getJSONArray("info");
     for (int i = 0; i < jsonArray.size(); i++) {
       JSONObject jsonObject2 = jsonArray.getJSONObject(i);
       hashMap = new HashMap<>();
       hashMap.put("id", jsonObject2.getString("id") == null ? "" : jsonObject2.getString("id"));
       hashMap.put(
           "title", jsonObject2.getString("title") == null ? "" : jsonObject2.getString("title"));
       hashMap.put(
           "path", jsonObject2.getString("path") == null ? "" : jsonObject2.getString("path"));
       hashMap.put("select", "0");
       array.add(hashMap);
     }
   } else {
     handlers.sendEmptyMessage(3);
   }
 }
  @Override
  public void setInfo(Object obj, int code) {
    // TODO Auto-generated method stub
    pd.dismiss();
    JSONObject json = JsonUtils.parseJson((String) obj);
    if (json.getIntValue("code") == 1) {
      list.clear();
      JSONArray jsonList = json.getJSONArray("list");
      JSONObject jsonObject;
      for (int i = 0; i < jsonList.size(); i++) {
        jsonObject = jsonList.getJSONObject(i);
        WBModel wList = new WBModel();
        wList.setWbName("普天小王子");
        wList.setWbMac(jsonObject.getString("mac"));
        list.add(wList);
      }

      adapter.notifyDataSetChanged();
    } else {
      Toast.makeText(context, "获取名单失败", Toast.LENGTH_SHORT).show();
    }
  }