|
@@ -1,8 +1,13 @@
|
|
|
package com.miaxis.test;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.miaxis.TwzdApplication;
|
|
|
+import com.miaxis.common.core.domain.entity.UserInfo;
|
|
|
+import com.miaxis.feign.dto.WxGzhBatchUser;
|
|
|
import com.miaxis.feign.service.IWxSendService;
|
|
|
import com.miaxis.spread.service.impl.WxSpreadRelationServiceImpl;
|
|
|
+import com.miaxis.user.service.IUserInfoService;
|
|
|
import com.miaxis.wx.service.IWxGzhService;
|
|
|
import org.junit.Test;
|
|
|
import org.junit.runner.RunWith;
|
|
@@ -11,6 +16,8 @@ import org.springframework.test.context.ActiveProfiles;
|
|
|
import org.springframework.test.context.junit4.SpringRunner;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
|
|
|
@ActiveProfiles("prodtest")
|
|
|
@SpringBootTest(classes = TwzdApplication.class)
|
|
@@ -25,11 +32,62 @@ public class NormalTest {
|
|
|
IWxSendService wxSendService;
|
|
|
@Resource
|
|
|
IWxGzhService wxGzhService;
|
|
|
+ @Resource
|
|
|
+ IUserInfoService userInfoService;
|
|
|
@Test
|
|
|
public void test666() throws Exception {
|
|
|
String gzhToken = wxGzhService.getGzhToken();
|
|
|
- String res = wxSendService.userInfo(gzhToken, "ovKTX59m65qpQAd-Bh0AIc5KhW3Q", "zh_CN");
|
|
|
+// String res = wxSendService.userInfo(gzhToken, "ovKTX59m65qpQAd-Bh0AIc5KhW3Q", "zh_CN");
|
|
|
+ List<UserInfo> list = userInfoService.list();
|
|
|
+ int times = (list.size()-1)/100+1;
|
|
|
+ for (int i= 0; i < times-1; i++){
|
|
|
+ WxGzhBatchUser batchUser = new WxGzhBatchUser();
|
|
|
+ List<JSONObject> jlist = new ArrayList<JSONObject>();
|
|
|
+ for(int j=0+i*100;j<99+i*100;j++){
|
|
|
+ JSONObject jo = new JSONObject();
|
|
|
+ jo.put("lang","zh_CN");
|
|
|
+ jo.put("openid",list.get(j).getOpenid());
|
|
|
+ jlist.add(jo);
|
|
|
+ }
|
|
|
+ batchUser.setUser_list(jlist);
|
|
|
+ String res = wxSendService.batchUserInfo(gzhToken,batchUser);
|
|
|
+ System.out.println(res);
|
|
|
+ }
|
|
|
+ WxGzhBatchUser batchUser = new WxGzhBatchUser();
|
|
|
+ List<JSONObject> jlist = new ArrayList<JSONObject>();
|
|
|
+ for(int j=0+(times-1)*100;j<list.size()-1;j++){
|
|
|
+ JSONObject jo = new JSONObject();
|
|
|
+ jo.put("lang","zh_CN");
|
|
|
+ jo.put("openid",list.get(j).getOpenid());
|
|
|
+ jlist.add(jo);
|
|
|
+ }
|
|
|
+ batchUser.setUser_list(jlist);
|
|
|
+ String res = wxSendService.batchUserInfo(gzhToken,batchUser);
|
|
|
+ System.out.println("最后一次");
|
|
|
System.out.println(res);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ @Test
|
|
|
+ public void test777() throws Exception {
|
|
|
+ List<UserInfo> list = userInfoService.list(new QueryWrapper<UserInfo>().isNull("union_id"));
|
|
|
+ System.out.println(list.size());
|
|
|
+ int index =1 ;
|
|
|
+ for (UserInfo userInfo : list){
|
|
|
+ String res = wxSendService.userInfo( wxGzhService.getGzhToken(), userInfo.getOpenid(), "zh_CN");
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(res);
|
|
|
+ if (jsonObject.getString("unionid") ==null){
|
|
|
+ System.out.println( index);
|
|
|
+ index++;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ userInfo.setUnionId(jsonObject.getString("unionid"));
|
|
|
+
|
|
|
+ index++;
|
|
|
+ }
|
|
|
+ userInfoService.updateBatchById(list);
|
|
|
}
|
|
|
|
|
|
|