コード例 #1
0
 @Override
 public Message kfCloseSessionEvent(Message message) {
   Message result = new Message();
   result.setFromUserName(message.getToUserName());
   result.setToUserName(message.getFromUserName());
   result.setCreateTime(System.currentTimeMillis() / 1000);
   result.setMsgType(MsgType.text);
   String content = this.robotMsgByKeyword("评价客服", message.getFromUserName());
   if (content != null) {
     content = content.replaceAll("#kfAccount", message.getKfAccount());
   }
   result.setContent(content);
   return result;
 }
コード例 #2
0
  /**
   * 消息处理
   *
   * @param message
   * @return
   */
  @Override
  public Message multiService(Message message) {
    String content = this.robotMsgByKeyword(message.getContent(), message.getFromUserName());
    if (null == content) {
      String toUserName = message.getFromUserName();
      message.setFromUserName(message.getToUserName());
      message.setToUserName(toUserName);
      message.setMsgType(MsgType.transfer_customer_service);
      return message;
    }

    Message result = new Message();
    result.setFromUserName(message.getToUserName());
    result.setToUserName(message.getFromUserName());
    result.setCreateTime(System.currentTimeMillis());
    result.setMsgType(MsgType.text);
    result.setContent(content);
    return result;
  }
コード例 #3
0
 /**
  * 序列化关注渠道
  *
  * @param message
  */
 private String serializeSubscribe(Message message) {
   String eventKey = message.getEventKey();
   String openId = message.getFromUserName();
   if (eventKey != null && eventKey.startsWith("qrscene_")) {
     eventKey = eventKey.substring("qrscene_".length());
   } else if (eventKey == null || eventKey.equals("")) {
     eventKey = DEFAULT_EVENT_KEY;
   }
   this.subscribeService.save(new Subscribe(openId, eventKey));
   return eventKey;
 }
コード例 #4
0
 @Override
 public Message subscribe(Message message) {
   String eventKey = serializeSubscribe(message); // 序列化渠道
   Message result = new Message();
   result.setFromUserName(message.getToUserName());
   result.setToUserName(message.getFromUserName());
   result.setCreateTime(System.currentTimeMillis());
   result.setMsgType(MsgType.text);
   String content = this.robotMsgByEventKey(PREFIX_QR_SUBSCRIBE, eventKey);
   result.setContent(content);
   return result;
 }
コード例 #5
0
  @Override
  public Message clickEvent(Message message, IWxApi wxApi) {
    String opendid = message.getFromUserName();
    Message result = new Message();
    result.setFromUserName(message.getToUserName());
    result.setToUserName(message.getFromUserName());
    result.setCreateTime(System.currentTimeMillis());
    result.setMsgType(MsgType.text);
    String content;
    if (CLICK_LOGIN_BIND.equals(message.getEventKey())) { // 免登陆功能按钮key
      // 免登陆功能按钮
      Map<String, String> paramsMap = new HashMap<>();
      paramsMap.put("openId", opendid);
      FenlibaoApi<AutoLogin> fenlibaoApi =
          this.httpsPost(
              this.connectionSettings.getServerBind(),
              paramsMap,
              new TypeReference<FenlibaoApi<AutoLogin>>() {});

      if (fenlibaoApi == null
          || fenlibaoApi.getData() != null
              && fenlibaoApi.getData().getWeixinStatus() != WeixinStatus.BINDED) {
        // 绑定提示
        content = this.robotMsgByKeyword("开启免登录", message.getFromUserName());
      } else {
        content = this.robotMsgByKeyword("取消免登录", message.getFromUserName());
      }

    } else if (CLICK_WEIXIN_CUSTOMER.equals(message.getEventKey())) { // 微信客服
      int dayOfWeek = this.getDayOfWeek();
      if (dayOfWeek > 1 && dayOfWeek < 7) {
        content = this.robotMsgByKeyword("工作日客服消息", message.getFromUserName());
      } else {
        content = this.robotMsgByKeyword("休息日客服消息", message.getFromUserName());
      }
    } else {
      content = this.robotMsgByKeyword(message.getEventKey(), message.getFromUserName());
    }

    if (content != null) {
      result.setContent(content);
      return result;
    } else {
      return null;
    }
  }