|
|
@ -8,6 +8,7 @@ import com.qs.serve.common.model.consts.GySysConst; |
|
|
|
import com.qs.serve.common.model.enums.HttpCode; |
|
|
|
import com.qs.serve.common.util.Assert; |
|
|
|
import com.qs.serve.common.util.AuthContextUtils; |
|
|
|
import com.qs.serve.common.util.CollectionUtil; |
|
|
|
import com.qs.serve.common.util.JsonUtil; |
|
|
|
import com.qs.serve.modules.wx.common.conf.WxMpConfig; |
|
|
|
import com.qs.serve.modules.wx.common.consts.WxStatusConst; |
|
|
@ -24,10 +25,13 @@ import me.chanjar.weixin.common.bean.oauth2.WxOAuth2AccessToken; |
|
|
|
import me.chanjar.weixin.common.error.WxErrorException; |
|
|
|
import me.chanjar.weixin.common.service.WxOAuth2Service; |
|
|
|
import me.chanjar.weixin.mp.api.WxMpService; |
|
|
|
import me.chanjar.weixin.mp.api.WxMpUserService; |
|
|
|
import me.chanjar.weixin.mp.bean.result.WxMpUser; |
|
|
|
import me.chanjar.weixin.mp.bean.result.WxMpUserList; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
/** |
|
|
@ -45,6 +49,40 @@ public class WxUserServiceImpl extends ServiceImpl<WxUserMapper, WxUser> impleme |
|
|
|
@Autowired(required = false) |
|
|
|
private WxAppService wxAppService; |
|
|
|
|
|
|
|
private List<String> getOpenIds(WxMpUserService wxMpUserService,String nextOpenId){ |
|
|
|
WxMpUserList wxMpUserList = null; |
|
|
|
List<String> openIds = new ArrayList<>(); |
|
|
|
try { |
|
|
|
wxMpUserList = wxMpUserService.userList(nextOpenId); |
|
|
|
openIds = wxMpUserList.getOpenids(); |
|
|
|
String currNextOpenId = wxMpUserList.getNextOpenid(); |
|
|
|
if(openIds.size() == 10000) { |
|
|
|
openIds.addAll(getOpenIds(wxMpUserService,currNextOpenId)); |
|
|
|
} |
|
|
|
} catch (WxErrorException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
return openIds; |
|
|
|
} |
|
|
|
|
|
|
|
public void test(){ |
|
|
|
WxMpUserService wxMpUserService = wxMpConfig.wxMpService().getUserService(); |
|
|
|
List<String> allOpenIds = this.getOpenIds(wxMpUserService,null); |
|
|
|
if(CollectionUtil.isEmpty(allOpenIds)){ |
|
|
|
List<List<String>> tmpList = CollectionUtil.createList(allOpenIds,800); |
|
|
|
for (List<String> openIdList : tmpList) { |
|
|
|
LambdaQueryWrapper<WxUser> lqw = new LambdaQueryWrapper<>(); |
|
|
|
lqw.eq(WxUser::getSubscribe,0); |
|
|
|
lqw.in(WxUser::getOpenId,openIdList); |
|
|
|
WxUser wxUser = new WxUser(); |
|
|
|
wxUser.setSubscribe(1); |
|
|
|
this.update(wxUser,lqw); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
public WxUser getCurrentWxUser() { |
|
|
|
LoginUser loginUser = AuthContextUtils.getLoginUser(); |
|
|
|