## **全局參數說明**
參數 | 備注
---|---
**{SERVER_ID}** | 配置文件中的服務器ID
**{CHILD_ID}** | 配置文件中的服務器子進程ID
<br>
## **請求隊列總覽**
隊列名稱 | 備注
---|---
queue.getContact_**{SERVER_ID}**_**{CHILD_ID}** | 獲取好友詳情
queue.searchContact_**{SERVER_ID}**_**{CHILD_ID}** | 搜索微信號/QQ號/手機號
queue.addContact_**{SERVER_ID}**_**{CHILD_ID}** | 添加好友
queue.addNew_**{SERVER_ID}**_**{CHILD_ID}** | 通過好友請求
queue.syncContact_**{SERVER_ID}**_**{CHILD_ID}** | 同步聯系人
queue.modifyName_**{SERVER_ID}**_**{CHILD_ID}** | 修改備注名
queue.addChatRoomContact_**{SERVER_ID}**_**{CHILD_ID}** | 添加群成員為好友
<br>
### **獲取好友詳情**
* 請求隊列:queue.getContact_{SERVER_ID}_{CHILD_ID}
* 請求參數:
| Param | Type | Description | Required
| --- | --- | --- | --- |
| json | <code>JSONObject</code> | 隊列傳輸參數類型 | true
| [json.adminUserId] | <code>Long</code> | 平臺賬號ID | true
| [json.uin] | <code>String</code> | 微信號uin | true
| [json.userName] | <code>String</code> | 需要獲取詳情的好友或群成員微信號,wxid_xxxx | true
| [json.chatRoomName] | <code>String</code> | 群ID,獲取群成員時必填 |
| [json.queueName] | <code>String</code> | 獲取群成員時必填 |
* Example
```
queueName = "queue.getContact_{SERVER_ID}"
JSONObject jsonObject = new JSONObject();
jsonObject.put("adminUserId", adminUserDTO.getAdminUserId());
jsonObject.put("uin", uin);
jsonObject.put("userName", userName);
//jsonObject.put("chatRoomName", chatRoomName);
//jsonObject.put("queueName", receiveQueueName);
jmsTemplate.send(queueName, jsonObject);
```
> 處理成功后
>
> A、獲取好友,會向topic.modcontact推送一條處理結果,具體參考[TOPIC-PRODUCTER(API生產)]
>
> B、獲取群成員,則向receiveQueueName中推送結果。
<br>
### **搜索好友**
* 請求隊列:queue.searchContact_{SERVER_ID}_{CHILD_ID}
* 請求參數:
| Param | Type | Description | Required
| --- | --- | --- | --- |
| json | <code>JSONObject</code> | 隊列傳輸參數類型 | true
| [json.adminUserId] | <code>Long</code> | 平臺賬號ID | true
| [json.uin] | <code>String</code> | 微信號uin | true
| [json.userName] | <code>String</code> | 需要搜索的微信號/QQ號/手機號(微信號不能是wxid_xxx開頭的) | true
| [json.queueName] | <code>String</code> | 接收結果的隊列名稱(搜索完畢后會將結果推送至該隊列) | true
* Example
```
queueName = "queue.searchContact_{SERVER_ID}"
JSONObject jsonObject = new JSONObject();
jsonObject.put("adminUserId", xxx);
jsonObject.put("uin", uin);
jsonObject.put("userName", userName);
jsonObject.put("queueName", QueueManager.getValue("receiveSearchContact"));
jmsTemplate.send(queueName, jsonObject);
```
> 處理成功后會向[json.queueName]推送一條處理結果。
* Response example:
```
{
//請求參數會原封不動返回
"adminUserId":xxx,
"uin":"xxx",
"userName":"xxx",
"queueName":"xxxx",
//搜索結果如下
"status": 0,//狀態碼,0表示成功,其他表示失敗
"message": "",//錯誤信息
"user_name": "",//V1
"stranger": "",//V2
"nick_name": "",//昵稱
"small_head": "",//頭像
"quan_pin": ""//拼音
}
```
<br>
### **添加好友**
* 請求隊列:queue.addContact_{SERVER_ID}_{CHILD_ID}
* 請求參數:
| Param | Type | Description | Required
| --- | --- | --- | --- |
| json | <code>JSONObject</code> | 隊列傳輸參數類型 | true
| [json.adminUserId] | <code>Long</code> | 平臺賬號ID | true
| [json.uin] | <code>String</code> | 微信號uin | true
| [json.userName] | <code>String</code> | 需要添加的微信號/QQ號/手機號(微信號不能是wxid_xxx開頭的) | true
| [json.v1] | <code>String</code> | 搜索微信號返回結果中的V1 | true
| [json.v2] | <code>String</code> | 搜索微信號返回結果中的V2 | true
| [json.verify] | <code>String</code> | 驗證消息(打招呼內容) | true
| [json.type] | <code>int</code> | 添加類型<br>1QQ<br>2郵箱<br>3微信號<br>14群聊<br>15手機號<br>18附近的人<br>25漂流瓶<br>29搖一搖<br>30二維碼 | true
| [json.queueName] | <code>String</code> | 接收結果的隊列名稱(處理結果將推送至該隊列) | true
**Example**
```
queueName = "queue.addContact_{SERVER_ID}"
JSONObject jsonObject = new JSONObject();
jsonObject.put("adminUserId", adminUserDTO.getAdminUserId());
jsonObject.put("uin", uin);
jsonObject.put("userName", userName);
jsonObject.put("v1", v1);
jsonObject.put("v2", v2);
jsonObject.put("verify", verify);
jsonObject.put("type", type);
jsonObject.put("queueName", QueueManager.getValue("receiveAddContact"));
jmsTemplate.send(queueName, jsonObject);
```
處理成功后會向[json.queueName]推送一條處理結果。
response example:
```
{
//請求參數會原封不動返回
"adminUserId":xxx,
"uin":"xxx",
"userName":"xxx",
"v1":"xxxx",
"v2":"xxxx",
"verify":"xxxx",
"type":"xxxx",
"queueName":"xxxx",
//添加結果如下
"status": 0,//狀態碼,0表示成功,其他表示失敗
"message": "",//錯誤信息
}
```
<br>
### **通過好友請求**
* 請求隊列:queue.addNew_{SERVER_ID}_{CHILD_ID}
* 請求參數:
| Param | Type | Description | Required
| --- | --- | --- | --- |
| map | <code>Map</code> | 隊列傳輸參數類型 | true
| [map.loginer] | <code>Long</code> | 平臺賬號ID | true
| [map.uin] | <code>String</code> | 微信號uin | true
| [map.userName] | <code>String</code> | recommendInfo中的參數為UserName的v1開頭的加密字段 | true
| [map.opcode] | <code>String</code> | 固定填3 | true
| [map.verifyUserTicket] | <code>String</code> | recommendInfo中的參數為Ticket中v2開頭的加密字段 | true
| [map.verifyContent] | <code>String</code> | 填"" | true
| [map.type] | <code>int</code> | xml中的scene<br>添加類型<br>1QQ<br>2郵箱<br>3微信號<br>14群聊<br>15手機號<br>18附近的人<br>25漂流瓶<br>29搖一搖<br>30二維碼 | true
| [json.wechatUser] | <code>String</code> | 微信號信息json字符串 | web協議必填
* Example
```
<msg
fromusername="wxid_63ibkhndjl7i21"
encryptusername="v1_b164fe39f73761f1bc04e818df345253cfce2effa72ae9d36074ed4502602225319830f98279b47e2e11509f14b871f6@stranger"
fromnickname="合法人類。"
content="我是合法人類。" fullpy="hefarenlei" shortpy="HFRL" imagestatus="3"
scene="30"
country="CN" province="Fujian" city="Xiamen" sign="" percard="1" sex="2" alias="c752184" weibo="" albumflag="0" albumstyle="0" albumbgimgid="" snsflag="17" snsbgimgid="http://shmmsns.qpic.cn/mmsns/jJSbu4Te5ibibue2PRXqlEAVEC0sHHzG4o6W1U0nQSibnnlBicQcjjCv3WZFMWLl2AibCvEsDepdWGqA/0" snsbgobjectid="12784451061011583048" mhash="6d5533cadef8b74eb13b8aa623880570" mfullhash="6d5533cadef8b74eb13b8aa623880570" bigheadimgurl="http://wx.qlogo.cn/mmhead/ver_1/icbJ1Wiavd2eIpVB4O68OECEzx2QG7ZziaWCgUicdbHNwQQaeib7LU5IVXk3iajdy0ePQESVSQ66yVkQ5j10tCrRDPyJM2dXlx40f6BASALPPtgKk/0" smallheadimgurl="http://wx.qlogo.cn/mmhead/ver_1/icbJ1Wiavd2eIpVB4O68OECEzx2QG7ZziaWCgUicdbHNwQQaeib7LU5IVXk3iajdy0ePQESVSQ66yVkQ5j10tCrRDPyJM2dXlx40f6BASALPPtgKk/132"
ticket="v2_0e2e4a9a7aa9d162d9580ab57d42dc39e8d155a3fa8afd4e022ed72ebc43b0d3e7973927229c25db79c70bb0d8d2130d79ead73bba642762b8606d0228841842@stranger"
opcode="2" googlecontact="" qrticket="" chatroomusername="" sourceusername="" sourcenickname="">
<brandlist count="0" ver="671660875"/>
</msg>
```
```
queueName = "queue.addNew_{SERVER_ID}_{CHILD_ID}"
Map<String, Object> arg2 = new HashMap<>(16);
arg2.put("loginer", adminUserDTO.getAdminUserId());
arg2.put("uin", contact.getUin());
arg2.put("userName", contact.getContactUserName());
arg2.put("opcode", 3);
arg2.put("wechatUser", JSONUtil.toJson(wechatUser));
arg2.put("verifyContent", "");
arg2.put("verifyUserTicket", contact.getVerifyUserTicket());
arg2.put("type", 30);
jmsTemplate.send(queueName, arg2);
```
> 處理成功后會向topic.modcontact推送一條處理結果,具體參考[TOPIC-PRODUCTER(API生產)],根據結果組裝成rediskey去獲取好友信息。
* response example:
```
{
//添加結果如下
"uin": xxx,//所屬微信號uin
"userName": "",//所屬微信號
"field": "",//好友wxid
}
```
<br>
### **同步聯系人**
* 請求隊列:queue.syncContact_{SERVER_ID}_{CHILD_ID}
* 請求參數:
| Param | Type | Description | Required
| --- | --- | --- | --- |
| json | <code>JSONObject</code> | 隊列傳輸參數類型 | true
| [json.loginer] | <code>Long</code> | 平臺賬號ID | true
| [json.uin] | <code>String</code> | 微信號uin | true
* Example
```
queueName = "queue.syncContact_{SERVER_ID}"
JSONObject jsonObject = new com.alibaba.fastjson.JSONObject();
jsonObject.put("loginer", xxx);
jsonObject.put("uin", "xxx");
jmsTemplate.send(queueName, jsonObject);
```
> 處理成功后會向topic.getcontact推送一條處理結果,具體參考[TOPIC-PRODUCTER(API生產)],根據結果組裝成rediskey去獲取好友信息。
* response example:
redisKey:
```
格式:uin+":wechatContact:"+userName
例子:1150109773:wechatContact:wxid_az12gf9ugnoh22
備注:uin為騰訊官方每個微信的唯一標識;userName為wxid_開頭的微信號
```
redisValue(聯系人數據)
```
{
"wxid_8fseov8qf5di22":{
"ContactType": "",
"ExtInfoExt": "",
"Sex": 0,
"EncryptUsername": "",
"wechatUserName": "wxid_az12gf9ugnoh22",
"PYQuanPin": "Nicoleniconi",
"Remark": "淑萍",
"LabelLists": "",
"ChatroomVersion": 0,
"ExtInfo": "",
"ChatRoomOwner": "",
"VerifyFlag": 0,
"ContactFlag": 3,
"UserName": "wxid_8fseov8qf5di22",
"HeadImgUrl": "http://wx.qlogo.cn/mmhead/ver_1/DcynCqO2Wzia0vZP8oTDjhSFVE3cO0SEqxnnwdj4kSUa1aNuueVDzgG3PiauPLeHjHwM1qvUqTGgS3xqCLkF4uaYAeRBcF3AdmFn6nzNH3DyE/132",
"RemarkPYInitial": "SP",
"MsgType": 2,
"City": "",
"NickName": "Nicole_nico'ni",
"Province": "",
"Alias": "",
"Signature": "",
"RemarkName": "淑萍",
"RemarkPYQuanPin": "shuping",
"Uin": 0,
"SmallHeadImgUrl": "http://wx.qlogo.cn/mmhead/ver_1/DcynCqO2Wzia0vZP8oTDjhSFVE3cO0SEqxnnwdj4kSUa1aNuueVDzgG3PiauPLeHjHwM1qvUqTGgS3xqCLkF4uaYAeRBcF3AdmFn6nzNH3DyE/132",
"PYInitial": "NICOLENICONI",
"Seq": "wxid_8fseov8qf5di22",
"BigHeadImgUrl": "http://wx.qlogo.cn/mmhead/ver_1/DcynCqO2Wzia0vZP8oTDjhSFVE3cO0SEqxnnwdj4kSUa1aNuueVDzgG3PiauPLeHjHwM1qvUqTGgS3xqCLkF4uaYAeRBcF3AdmFn6nzNH3DyE/132"
},
......
}
```
<br>
### **修改備注名**
* 請求隊列:queue.modifyName_{SERVER_ID}_{CHILD_ID}
* 請求參數:
| Param | Type | Description | Required
| --- | --- | --- | --- |
| msg | <code>Map</code> | 隊列傳輸參數類型 | true
| [msg.loginer] | <code>Long</code> | 平臺賬號ID | true
| [msg.uin] | <code>String</code> | 微信號uin | true
| [msg.userName] | <code>String</code> | 需要修改的好友微信號 | true
| [msg.newRemarkName] | <code>String</code> | 備注名 | true
| [msg.wechatUser] | <code>String</code> | 微信號信息json字符串 | true
* Example
```
queueName = "queue.modifyName_{SERVER_ID}_{CHILD_ID}"
Map<String, Object> arg1 = new HashMap<>(16);
arg1.put("uin", uin);
arg1.put("userName", wechatContact.getUserName());
arg1.put("loginer", loginer);
arg1.put("newRemarkName", remarkName);
arg1.put("wechatUser", JSONUtil.toJson(user));
jmsTemplate.send(queueName, arg1);
```
> 處理成功后會向topic.modifycontact,具體參考[TOPIC-PRODUCTER(API生產)],根據結果組裝成rediskey去獲取好友信息。
* response example:
<br>
### **添加群成員為好友**
* 請求隊列:queue.addChatRoomContact{SERVER_ID}_{CHILD_ID}
* 請求參數:
| Param | Type | Description | Required
| --- | --- | --- | --- |
| json | <code>JSONObject</code> | 隊列傳輸參數類型 | true
| [json.loginer] | <code>Long</code> | 平臺賬號ID | true
| [json.uin] | <code>String</code> | 微信號uin | true
| [json.userName] | <code>String</code> | 需要添加的群成員微信號 | true
| [json.chatRoomName] | <code>String</code> | 群微信號 | true
| [json.verify] | <code>String</code> | 驗證消息 | true
| [json.queueName] | <code>String</code> | 接收返回值的隊列 | true
* Example
```
queueName = "queue.addChatRoomContact{SERVER_ID}_{CHILD_ID}"
JSONObject jsonObject = new com.alibaba.fastjson.JSONObject();
jsonObject.put("loginer", xxx);
jsonObject.put("uin", "xxx");
jsonObject.put("userName", "xxx");
jsonObject.put("chatRoomName", "xxx");
jsonObject.put("verify", "xxx");
jsonObject.put("queueName", "xxx");
jmsTemplate.send(queueName, jsonObject);
```
> 處理成功后會向topic.modifycontact,具體參考[TOPIC-PRODUCTER(API生產)],根據結果組裝成rediskey去獲取好友信息。
* response example:
```
//jsonObject為接收到的參數(返回時會全部返回)
jsonObject.put("status", 0);
jsonObject.put("message", "xxx");
jmsTemplate.send(jsonObject.getString("queueName"), jsonObject.toString);
```
<br>
## **聯系人模塊消息下發訂閱隊列**
### **獲取聯系人**
* 推送隊列:topic.getcontact
> 登錄初始化/用戶同步好友時推送該topic,根據mqType判斷.消費消息后根據字段組裝redis的key去獲取相應的內容
```
{
"uin": "xxxxxx",
"userName": "xxxxxxxxx",
"loginer": "18",
"field": "xxxxxxxx",
"mqType": 7,
"source": "ipad"
}
```
### **聯系人變更**
* 推送隊列:topic.modcontact
> 好友信息變動會推送該topic
```
{
"uin": "xxxxxx",//微信號uin
"userName": "xxxxxxxxx",//微信號wxid
"loginer": "18",
"field": "xxxxxxxx",//好友wxid
"mqType": 3,
"source": "ipad"
}
```
### **刪除好友**
* 推送隊列:topic.delcontact
> 被刪除或者其他會推送該topic
```
{
"uin": "xxxxxx",//微信號uin
"userName": "xxxxxxxxx",//微信號wxid
"loginer": "18",
"field": "xxxxxxxx",//好友wxid
"mqType": 4,
"source": "ipad"
}
```
### 獲取群
*推送隊列:topic.chatroommember
> 獲取群詳細信息/群信息變動會推送該topic
```
{
"uin": "xxxxxx",//微信號uin
"userName": "xxxxxxxxx",//微信號wxid
"loginer": "18",
"field": "xxxxxxxx@chatroom",//好友wxid
"mqType": 5,
"source": "ipad"
}
```
### 群成員變量
* 推送隊列:topic.modchatroommember
> 預留topic,暫未使用
```
{
"uin": "xxxxxx",//微信號uin
"userName": "xxxxxxxxx",//微信號wxid
"loginer": "18",
"field": "xxxxxxxx@chatroom",//好友wxid
"mqType": 5,
"source": "ipad"
}
```