一.总流程图

二.审核通过后,点击迁移之前,拉取旧公众号的openid数据 这里使用weixin4j(也可使用其他工具 或者微信原生sdk)

     审核通过后管理员收到的通知 收到该通知后先别忙着点确认进行迁移  首先应该把此时旧公众号的openid全部拉出来存到数据库 用于之后的转换openid

1.该表用来储存拉取的旧openid 用来记录对应的新openid

package cn.betatown.member.model.weixin;import java.io.Serializable;import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;import cn.betatown.model.BaseStringEntity;/****旧openid记录表  此表用于记录转换前的旧openid  并记录openid转换情况*/
@Entity
@Table(name = "M_WEIXIN_OPENID_HIS")
public class WeixinOpenIdHis extends BaseStringEntity implements Serializable {private static final long serialVersionUID = 5700734079006338566L;/*** 旧openid*/@Column(name = "OLD_OPENID",length = 40,nullable = false)private String oldOpenId;/*** 新openid*/@Column(name = "NEW_OPENID", length = 200)private String newOpenId;/*** 手机号码*/@Column(name = "MOBILE_NUMBER", length = 40)private String mobileNumber;/*** 会员id*/@Column(name = "MEMBER_ID", length = 40)private String memberId;public String getOldOpenId() {return oldOpenId;}public String getNewOpenId() {return newOpenId;}public String getMobileNumber() {return mobileNumber;}public String getMemberId() {return memberId;}public void setOldOpenId(String oldOpenId) {this.oldOpenId = oldOpenId;}public void setNewOpenId(String newOpenId) {this.newOpenId = newOpenId;}public void setMobileNumber(String mobileNumber) {this.mobileNumber = mobileNumber;}public void setMemberId(String memberId) {this.memberId = memberId;}public WeixinOpenIdHis() {super();// TODO Auto-generated constructor stub}public WeixinOpenIdHis(String oldOpenId) {super();this.oldOpenId = oldOpenId;}}2.拉取旧公众号的所有openid 存入数据库package cn.betatown.member.action.member;import java.util.ArrayList;
import java.util.List;import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;import com.bstek.dorado.annotation.Expose;
import com.foxinmy.weixin4j.exception.WeixinException;
import com.foxinmy.weixin4j.mp.WeixinProxy;
import com.foxinmy.weixin4j.mp.model.Following;import cn.betatown.WchatConfig;
import cn.betatown.common.service.ServiceException;import cn.betatown.common.utils.status.StatusHouse;import cn.betatown.common.utils.web.JsonWriter;
import cn.betatown.member.model.weixin.WeixinOpenIdHis;
import cn.betatown.member.service.member.MemberService;
import cn.betatown.security.model.User;
import cn.betatown.security.service.SecurityService;
import net.sf.json.JSONArray;/*** * @ClassName: MemberAct* @Description: TODO(APP会员视图控制层)* @author xuan.yuan* @date 2019年5月10日 下午12:06:22* */@Controller
public class MemberAct2 {private static Logger logger = LoggerFactory.getLogger(MemberAct2.class);@Autowiredprivate MemberService memberService;@Autowiredprivate SecurityService securityService;/*** 迁移之前拉取所有openid  存入数据库 以便迁移完成后转换openid* @return* @author xuan.yuan* @date 2019年5月10日 下午3:15:49*/@Exposepublic String getAllOpenId(){try {logger.info("executeGetAllopenId(..) start ... ");WchatConfig wchatConfig = WchatConfig.getInstance();//weixin4jWeixinProxy weixinProxy = wchatConfig.getWeixinProxy();//weixin4jList<String> openIds = new ArrayList<String>();String nextOpenId = null;do{Following following = weixinProxy.getFollowingOpenIds(nextOpenId);//weixin4j 获取openidsint count = following.getCount();//拉取的OPENID个数,最大值为10000int total = following.getTotal();//关注总数nextOpenId = following.getNextOpenId();//拉取列表的后一个用户的OPENIDlogger.info("关注总数:【"+total+"】本次拉取:【"+count+"】末尾openid:【"+nextOpenId+"】");openIds = following.getOpenIds();//列表数据,OPENID的列表if(null!=openIds&&openIds.size()>0){for (String openId : openIds) {WeixinOpenIdHis weixinOpenIdHis = new WeixinOpenIdHis(openId);memberService.executeSaveOpenIdHis(weixinOpenIdHis);//将旧openid存入数据库中  用作之后的转换openid源数据logger.info(count+".successOpenid【"+openId+"】");count--;}}}while(null!=openIds&&openIds.size()>0);logger.info("executeGetAllopenId(..) end ... ");return "ok";} catch (WeixinException e) {logger.error(e.getMessage());return e.getErrorDesc();}catch (Exception e){logger.error(e.getMessage());return e.getMessage();}}/*** 迁移完成后转换openid* @return*/@Exposepublic String changeAllOpenId(){//       User user = securityService.getLoginUser();if (user == null) {throw new ServiceException(StatusHouse.COMMON_STATUS_NO_LOGIN_OR_TIMEOUT);}logger.info("executeChangeOpenId(..) start ... ");WchatConfig wchatConfig = WchatConfig.getInstance();WeixinProxy weixinProxy = wchatConfig.getWeixinProxy();try {String token = weixinProxy.getTokenManager().getAccessToken();//新公众号的令牌List<String> oldOpenIds = memberService.pageWeixinOpenIdHis(100, 1);//分批获取之前存储的旧openidint count = 1;while(null!=oldOpenIds&&oldOpenIds.size()>0&&count<450){logger.info("第"+count+"批开始···size="+oldOpenIds.size());String changeUrl = "http://api.weixin.qq.com/cgi-bin/changeopenid?access_token="+token;  //微信提供中的openId转换接口HttpHeaders headers = new HttpHeaders();//请求头  MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");//这里非常重要 必须是json模式 否则调微信接口报错headers.setContentType(type);jsonChangeOpenid jsonChangeOpenid = new jsonChangeOpenid("wx55ee94e1a6154fb2", oldOpenIds);//此处为原帐号的appid需要转换的openIdS 最大100条,这些必须是旧账号目前关注的才行String requestJson = JsonWriter.toJson(jsonChangeOpenid);logger.info("requestJson==>"+requestJson);HttpEntity<String> httpEntity = new HttpEntity<String>(requestJson,headers);RestTemplate restTemplate = new RestTemplate();ResponseEntity<String> response = restTemplate.postForEntity(changeUrl, httpEntity,String.class);logger.info("微信返回:"+response.getBody());net.sf.json.JSONObject jsonObject= net.sf.json.JSONObject.fromObject(response.getBody());if(jsonObject.get("errmsg").equals("ok")){JSONArray resultList = jsonObject.getJSONArray("result_list");for (Object object : resultList) {net.sf.json.JSONObject newOpenIdList = net.sf.json.JSONObject.fromObject(object);if(newOpenIdList.get("err_msg").equals("ok")){try {memberService.executeChangeOpenId(newOpenIdList.getString("ori_openid"), newOpenIdList.getString("new_openid"));//根据自己的业务逻辑用新openid 替换 旧openidlogger.error("success旧openID:"+newOpenIdList.get("ori_openid"));} catch (Exception e) {logger.error("旧openID:"+newOpenIdList.get("ori_openid")+"失败原因:"+e);continue;}}else{logger.error("旧openID:"+newOpenIdList.get("ori_openid")+"失败原因:"+newOpenIdList.get("err_msg"));}}}else{logger.error("errorCode:"+jsonObject.get("errcode")+"errmsg:"+jsonObject.get("errmsg"));return "errorCode:"+jsonObject.get("errcode")+"errmsg:"+jsonObject.get("errmsg");}logger.info("第"+count+"批结束···size="+oldOpenIds.size());//循环执行oldOpenIds = memberService.pageWeixinOpenIdHis(100, 1);count++;};logger.info("executeChangeOpenId(..) end ... ");return "ok";} catch (WeixinException e) {logger.error(e.getMessage());return e.getErrorDesc();}catch (Exception e) {logger.error(e.getMessage());return e.getMessage();}}return "ok";}

二.管理员点击确认迁移

1、审核通过后,系统将会下发迁移确认通知给两个帐号管理员的微信号,双方15天内点击确认迁移则自动开启迁移流程(注:必须在审核成功后的15天内确认迁移通知,超时未确认迁移则迁移失败,如需继续迁移需另外申请并支付审核费用;如审核成功后未收到迁移确认通知,可在公众号后台进入帐号迁移页面申请发送通知,每天只可下发一次);

2、双方点击确认迁移后,为保证数据不受影响,原帐号会马上冻结,同时系统下发通知给原账号粉丝,告知迁移事宜,粉丝如有异议,可在1天内取消关注,取消关注的用户不会被迁移;

点击确认迁移后粉丝收到的迁移通知

3、1天后(1天粉丝确认)自动触发迁移,包括粉丝、群发素材、违规记录,耗时时间与数据量大小相关,一般将在1-3个天内完成(1-3天粉丝、群发素材、违规记录迁移),系统给粉丝发送迁移中通知 给管理员发送迁移中通知。

点击确认迁移整整1天后 管理员会收到这个迁移开始通知 此时自动触发迁移

收到上面的通知以后粉丝会陆续收到该通知

4、迁移完成后,新帐号名称同步。微信方面整个迁移流程结束。(迁移完成后没有明确的完成指示,我们公众号粉丝8万左右,一天就完了,只要转换openid接口能调通 说明迁移全部完成了)

三.按照自己的需求配置新公众号各白名单 支付授权目录····等配置信息到服务器
调用上面代码中的openid转换接口转换openid

官方说明:http://kf.qq.com/faq/1901177NrqMr190117nqYJze.html openid转换接口

!!!迁移没完成前调用转换接口会报

!!!公众号id参数给错也会报上面错误

!!! 转换方法请求头类型不是json 也会报 63178:from_appid参数错误,和调用的账号并没有迁移关系

微信公众号迁移流程 《openid转换》相关推荐

  1. 微信公众号迁移丨如何迁移微信公众号 最详细公众号迁移流程和方法

    微信公众号迁移丨如何迁移微信公众号 最详细微信公众号迁移流程和方法 微信公众号如何迁移?微信公众号迁移公证书需要准备哪些资料? 怎么迁移微信公众号! 教你迁移微信公众号_迁移完成后,原账号就注销了,无 ...

  2. 手把手教你微信公众号迁移_四步教你怎么迁移微信公众号

    教你迁移微信公众号_迁移完成后,原账号就注销了,无法再登陆公众号后台,登进去是这样的界面 微信公众号迁移说难不难,说简单也不简单.下面用4步来教会你们操作微信公众号迁移,每一点都写的非常详细,记得收藏 ...

  3. 微信公众号迁移主体变更需提供哪些材料以及迁移的完整流程

    微信公众号不同主体提交迁移前仍须迁移函和迁移公证,微信公号平台会委托第三方独立审查子公司对迁移函和迁移公证进行审查,迁移时还仍须缴交给审查公司300元迁移审查费.迁移.公证书在线办理可咨询57运营网, ...

  4. openid转换接口--微信公众号迁移

    微信公众号迁移,原文地址:openid转换接口 请求postman格式: https://api.weixin.qq.com/cgi-bin/changeopenid?access_token=你的t ...

  5. vue axios封装 获取微信公众号用户的openid

    目录 axios封装 openid vue vue+ts axios封装 一般会在项目的src目录中,新建一个文件夹,作为网络请求模块,用来封装axios, 创建axios实例: axios.crea ...

  6. 微信公众号为指定openid用户推送消息

    微信公众号为指定openid用户推送消息 微信提供的开放接口中,有两个给指定openid的用户发送信息的接口,适用场景应该是向 预约用户或者中奖用户发送消息. 第一个接口:客服发送消息 请求方式: P ...

  7. 微信公众号获取用户openId(扩展:小程序获取openId和手机号)

    微信公众号获取用户openId 拼接的参数[可以直接配菜单中]: https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxb2363dd ...

  8. Java 微信公众号迁移

    背景:公众号换主体,要迁移,粉丝(openId)的业务数据要做处理. 第一步:参照我的另一篇文章,Java 导出微信公众号粉丝. 第二部:数据处理(master-worker模式) 程序主入口:Mai ...

  9. 微信公众号支付 流程

    1.支付参数准备(图就不上了) 公众号的APPID.商户号MchID.商户API支付秘钥(商户平台的账户中心下:需要用户自行下载证书及安装). 2.平台配置 商户平台-->产品中心-->开 ...

  10. 快递Api接口 微信公众号开发流程

    之前的文章,已经分析过快递Api接口可能被使用的需求及场景:今天呢,简单给大家介绍一下微信公众号中怎么来使用快递Api接口,来完成我们的需求和业务场景. 开发语言:Nodejs,其中用到了Neo4j图 ...

最新文章

  1. c语言作业 统计成绩,C语言作业 输入多名学生3门课程成绩,并统计成绩的平均分和总分,并根据总分输出名次。...
  2. 腾讯AI战略详解:技术社会与创新图景 | 2017互联网科技创新白皮书重磅首发
  3. 剑指offer 面试36题
  4. PHP深复制与浅复制
  5. 第三次学JAVA再学不好就吃翔(part90)--TreeSet
  6. php7.0 yield,PHP7中生成器的新特性 yield-from amp;amp; return-values
  7. 阿里云云效何勉:云原生是“精益实践”的最佳助力
  8. SQL笔记-检索出ID为Int或Long中不连续的第一个点
  9. 服务器多个网站开启quarz,GitHub - WuLex/QuartzSynchroData: 多个不同站点服务器数据同步到总服务器(数据中心)...
  10. Sunny Day ijk英语
  11. Bootstrap3栅格系统布局实例
  12. Atitit s2018 s3 doc list alldvc.docx .docx s2018 s3f doc compc s2018 s3f doc homepc sum doc dvcCom
  13. (机器人学导论--运动学)(三)DH表达法顺向运动学
  14. CodeBlocks20.03+汉化包云盘下载及用法
  15. python利用pandas实现excel数据分组汇总
  16. 手把手教你---猿如意之八大高效利器使用
  17. 大数据开发岗面试30天冲刺 - 日积月累,每日五题【Day01】——Hive1
  18. 操作MySQL出错提示“BLOB/TEXT column used in key specification without a key length”解决办法
  19. 【总结】PHP常见面试题汇总(一)。。。
  20. 解决树莓派程序中的中文乱码问题

热门文章

  1. win7显示u盘efi分区_win7下找不到u盘efi分区
  2. 鸿蒙大陆v2.8正式版,鸿蒙大陆正式版地图下载-鸿蒙大陆下载 V2.22--pc6下载站
  3. Python基础语法1
  4. bccomp php扩展,PHP 中文工具包 ChineseUtil v2.0 发布,引入 FFI 提升性能节省内存
  5. 大雪满弓刀之林冲 [转]
  6. 怎样写商业计划书 【转载】
  7. win7桌面计算机图标变了,Win7桌面图标变成未知的文件了怎么办
  8. 开题报告的选题依据怎么写?
  9. 计算机表格折线图添加图例,如何将Excel表格中插入的折线图中的圆圈设置为方块或三角形...
  10. python三大神器