hi,你好!欢迎访问本站!登录
本站由网站地图腾讯云宝塔系统阿里云强势驱动
当前位置:首页 - 教程 - 小程序 - 正文 君子好学,自强不息!

关于微信开放平台那些事,第三方平台开发_微信小程序

2020-09-15小程序搜奇网4°c
A+ A-

假如说,有多个营业,功用形式雷同的民众号/小程序,假如只是小程序开发,那是不是须要复制多套代码,改appid信息,在微信民众号背景,设置域名效劳器以及密钥等烦琐的信息,每改一个提交宣布一次,举行反复的步骤。跟着要保护的民众号/小程序数目逐渐增添,须要投入的资本以及本钱也随之增添。

有无想过,只须要开发一套民众号/小程序代码,以之为模板,再来一套背景治理体系,把在微信民众号背景做的那些事都搬到我们本身的体系中。来一个营业雷同的小程序,只须要治理员受权后,只要在我们的体系中点点几个按钮,就能够把小程序宣布上线,一次开发供 N 个民众号运用,供应标准化的接口效劳来满足营业的基本需求。经由过程扫描二维码受权给平台,协助 N 多个民众号代完成营业,不再须要明白烦琐参数设置,而且暗码不供应给开发者,保证平安,真正做到解放运营同砚和开发的双手,有更多的时候去谈女朋友,那该多好。没错,微信第三方平台开发就是来帮你节约更多时候去把妹的神器。

相干进修引荐:微信民众号开发教程

概述

微信民众平台-第三方平台(简称第三方平台)开放给一切经由过程开发者天资认证后的开发者运用。在获得民众号或小程序运营者(简称运营者)受权后,第三方平台开发者能够经由过程挪用微信开放平台的接口才,为民众号或小程序的运营者供应账号要求、小程序建立、技术开发、行业计划、运动营销、插件才等全方位效劳。同一个账号的运营者能够挑选多家合适本身的第三方为其供应产物才或托付运营。

从营业特性上来讲,第三方平台必需如图所示:

从细致的营业场景上说,第三方平台包含以下场景:

供应行业解决计划,如针对电商行业的解决计划,或针对旅游行业的解决计划等;

行业:(横向)供应越发专业的运营才,精细化运营用户民众号或小程序;

功用:(纵向)对民众平台功用的优化,如特地优化图文音讯视觉款式和排版的东西,或特地定制的 CRM 用户治理功用,或功用强大的小程序插件等。

接入第三方开发的条件是要有微信开放平台运用,细致建立步骤请参考

developers.weixin.qq.com/doc/oplatfo…

1、猎取考证单子

考证单子(component_verify_ticket),在第三方平台建立考核经由过程后,微信效劳器会向其 ”受权事宜吸收URL” 每隔 10 分钟以 POST 的体式格局推送 component_verify_ticket

吸收 POST 要求后,只需直接返回字符串 success。为了增强平安性,postdata 中的 xml 将运用效劳要求时的加解密 key 来举行加密,在收到推送后需举行解密。

public void saveTicket(HttpServletRequest request, HttpServletResponse response) throws IOException {
  String msgSignature = request.getParameter("msg_signature");// 微信加密署名
  String timeStamp = request.getParameter("timestamp");// 时候戳    
  String nonce = request.getParameter("nonce"); // 随机数  
  BufferedReader br = new BufferedReader(new InputStreamReader(request.getInputStream(),"UTF-8"));
  StringBuffer sb = new StringBuffer();
  String line = null;
  while ((line = br.readLine()) != null) {
    sb = sb.append(line);
  }
  String postData = sb.toString();
  try {
    AuthorizedUtils.saveComponentVerifyTicket(msgSignature, timeStamp, nonce, postData);
  } catch (Exception e) {
    logger.error("体系非常", e);
  } finally {
    // 相应音讯
    PrintWriter out = response.getWriter();
    out.print("success");
  }
}复制代码

2、猎取令牌

令牌(component_access_token)是第三方平台接口的挪用凭证。令牌的猎取是有限定的,每一个令牌的有效期为 2 小时,请自行做好令牌的治理,在令牌快逾期时(比方1小时50分),从新挪用接口猎取。

public static ComponentToken getComponentToken(String ticket) {
    
RedisService<ComponentToken> redisService = RedisService.load();

ComponentToken componentToken = redisService.load(ComponentToken.COMPONENTTOKEN_ID, ComponentToken.class);  
if (componentToken == null) {
  String encryptAppId = ThirdPlat.PLAT_APPID;
  String appId = EnDecryptUtil.d3esDecode(encryptAppId);
  String encryptSecret = ThirdPlat.PLAT_SECRET;
  String secret = EnDecryptUtil.d3esDecode(encryptSecret);
      
  String requestUrl = AuthAccessUrl.COMPONENT_ACCESS_URL;
  Map<String, String> map = new HashMap<>(); 
  map.put("component_appid", appId); //第三方平台appid
  map.put("component_appsecret", secret); //第三方平台appsecret
  map.put("component_verify_ticket", ticket); 
  String outputStr = JSONObject.toJSONString(map);
  logger.warn("要求数据"+outputStr);
  JSONObject jsonObject = HttpRequestUtils.httpRequest(requestUrl, "POST", outputStr);
    if (null != jsonObject) {
    long expires = System.currentTimeMillis() + 7200;
    try{
      expires = System.currentTimeMillis() + jsonObject.getIntValue("expires_in");        
    }catch (Exception e) {
    }
    try {
      componentToken = new ComponentToken();
      componentToken.setComponentAccessToken(jsonObject.getString("component_access_token"));
      componentToken.setExpiresIn(expires);
      redisService.save(componentToken, ComponentToken.class);
    } catch (Exception e) {
      componentToken = null;
      logger.error("体系非常", e);
    }
  }
} else {
  long sysTime = System.currentTimeMillis();
  if (sysTime >= componentToken.getExpiresIn()) {
    redisService.delete(ComponentToken.COMPONENTTOKEN_ID, ComponentToken.class);
    componentToken = getComponentToken(ticket);
  }else{
  }
}
return componentToken;
}复制代码

3、疾速建立小程序

疾速建立小程序接口优化了小程序注册认证的流程,能协助第三方平台敏捷拓展线下商户,拓展商户的效劳范围,占据小程序线下贸易先机。采纳法人人脸辨认体式格局替换小额打款等认证流程,极大的减轻了小程序主体、类目天资信息网络的人力本钱。第三方平台只需网络法人姓名、法人微信、企业称号、企业代码信息这四个信息,便能够向企业法人下发一条模板音讯来收集法人人脸信息,完成悉数注册、认证流程。以及法人收到建立胜利后的小程序APPID时,同时下发模板音讯给法人,提醒法人举行邮箱和暗码的设置,便于后续法人上岸小程序控制台举行治理。

经由过程该接口建立小程序默许为“已认证”。为下降接入小程序的本钱门坎,经由过程该接口建立的小程序无需交 300 元认证费。

public AjaxResult fastRegister(String merchantId) {
  Merchant merchant = merchantService.getById(merchantId);
  if (merchant == null) {
      logger.warn("疾速建立小程序---->失利,merchant为null");
      return AjaxResult.error("疾速建立小程序失利,merchant为null",null);
  } else {
      RedisService<ComponentVerifyTicket> redisService = RedisService.load();
      ComponentVerifyTicket componentVerifyTicket = redisService.load(ComponentVerifyTicket.COMPONENT_VERIFY_TICKET_ID,
              ComponentVerifyTicket.class);
    if (componentVerifyTicket == null) {
        logger.warn("疾速建立小程序---->失利,component_verify_ticket为null");
        return AjaxResult.error("疾速建立小程序失利,component_verify_ticket为null",null);
    } else {
        ComponentToken componentToken = AuthorizedUtils.getComponentToken(componentVerifyTicket.getComponentVerifyTicket());
        RegisterWeappOut out = new RegisterWeappOut();
        out.setName(merchant.getName())
                .setCode(merchant.getCode())
                .setCode_type(merchant.getCodeType())
                .setLegal_persona_wechat(merchant.getLegalPersonaWechat())
                .setLegal_persona_name(merchant.getLegalPersonaName())
                .setComponent_phone(merchant.getComponentPhone());
        JSONObject obj = BaseUtils.createRegisterWeapp(componentToken,out);
        if (obj.getInteger("errcode") == 0 && "ok".equalsIgnoreCase(obj.getString("errmsg"))) {
            return AjaxResult.success();
        } else {
            return AjaxResult.error(obj.getInteger("errcode"),obj.getString("errmsg"));
        }
    }
}
} 
复制代码

4、猎取预受权码

预受权码(pre_auth_code)是第三方平台方完成受权托管的必备信息,每一个预受权码有效期为 10 分钟。须要先猎取令牌才挪用。

public static String getPreAuthCode(String ticket) {
ComponentToken componentToken = getComponentToken(ticket);
String encryptAppId = ThirdPlat.PLAT_APPID;
String appId = EnDecryptUtil.d3esDecode(encryptAppId);
String url = AuthAccessUrl.PRE_AUTH_CODE_URL + componentToken.getComponentAccessToken();
Map<String, String> map = new HashMap<String, String>();
map.put("component_appid", appId);
    JSONObject jsonObject = HttpRequestUtils.httpRequest(url, "POST", JSONObject.toJSONString(map));   
return jsonObject.getString("pre_auth_code");
}复制代码

5、指导商户受权猎取受权信息

第三方效劳商构建受权链接安排本身的网站,用户点击后,弹出受权页面。

public AjaxResult getMchWebAuthUrl(@PathVariable("id") String id) {
RedisService<ComponentVerifyTicket> redisService = RedisService.load();
ComponentVerifyTicket componentVerifyTicket = redisService.load(ComponentVerifyTicket.COMPONENT_VERIFY_TICKET_ID,
    ComponentVerifyTicket.class);
if(componentVerifyTicket == null){
  return AjaxResult.error("引入用户进入受权页失利,component_verify_ticket为null",null);
}else{
  String preAuthCode = AuthorizedUtils.getPreAuthCode(componentVerifyTicket.getComponentVerifyTicket());
  String encryptAppId = ThirdPlat.PLAT_APPID;
  String appId = EnDecryptUtil.d3esDecode(encryptAppId);
  String auth_type = ThirdPlat.AUTH_TYPE;
  String requestUrl = AuthAccessUrl.WEB_AUTH_URL;
  try {
    requestUrl = requestUrl.replace("COMPONENT_APPID", appId).replace("PRE_AUTH_CODE", preAuthCode)
        .replace("REDIRECT_URI", URLEncoder.encode(ThirdPlat.REDIRECT_URI.replace("MERCHANTID", id),"UTF-8")).replace("AUTH_TYPE", auth_type);
  } catch (UnsupportedEncodingException e) {
    e.printStackTrace();
  }
  logger.warn("步骤2:引入用户进入受权页---->胜利,url为:" + requestUrl);
  return AjaxResult.success("操纵胜利",requestUrl);
  
}
}复制代码

6、设置小程序基本信息

设置小程序称号,当称号没有掷中关键词,则直接设置胜利;当称号掷中关键词,需提交证实材料,并须要考核。修正小程序的头像。修正功用引见。修正小程序隐私设置,即修正是不是可被搜刮。

public AjaxResult setBasicInfo(BasicInfo basicInfo) throws IOException {
  Merchant merchant = merchantService.getById(basicInfo.getMerchantId());
  if (merchant == null) {
      logger.warn("设置基本信息---->失利,merchant为null");
      return AjaxResult.error("设置基本信息失利,merchant为null",null);
  } else {
      AuthorizationInfo info = AuthorizedUtils.getAuthorizationInfo(merchant.getAppid());
      //修正头像
      if (StringUtils.isNotEmpty(basicInfo.getHeadImage())) {
          UploadIn uli = new UploadIn();
          uli.setType("image").setUrlPath(basicInfo.getHeadImage());
          JSONObject uploadJson = BaseUtils.upload(info,uli);
          String mediaId = uploadJson.getString("media_id");
          ModifyHeadImageIn mhi = new ModifyHeadImageIn();
          mhi.setHead_img_media_id(mediaId).setX1("0").setY1("0").setX2("1").setY2("1");
          JSONObject obj = BaseUtils.modifyHeadImage(info,mhi);
          if (!obj.getInteger(ResStatus.ERRCODE).equals(ResStatus.CODE) || !ResStatus.MSG.equalsIgnoreCase(obj.getString(ResStatus.ERRMSG))) {
              return AjaxResult.error(obj.getInteger(ResStatus.ERRCODE),obj.getString(ResStatus.ERRMSG));
          } else {
              merchant.setAppletsHeadImg(basicInfo.getHeadImage());
          }
      }
      //修正称号
      if (StringUtils.isNotEmpty(basicInfo.getNickname())) {
          UploadIn uli = new UploadIn();
          uli.setType("image").setUrlPath(merchant.getBusinessLicense());
          JSONObject uploadJson = BaseUtils.upload(info,uli);
          String mediaId = uploadJson.getString("media_id");
          SetNicknameIn sni = new SetNicknameIn();
          sni.setNick_name(basicInfo.getNickname());
          sni.setLicense(mediaId);
          JSONObject obj = BaseUtils.setNickname(info,sni);
          if (!obj.getInteger(ResStatus.ERRCODE).equals(ResStatus.CODE) || !ResStatus.MSG.equalsIgnoreCase(obj.getString(ResStatus.ERRMSG))) {
              return AjaxResult.error(obj.getInteger(ResStatus.ERRCODE),obj.getString(ResStatus.ERRMSG));
          } else {
              merchant.setAppletsName(basicInfo.getNickname());
              if (obj.containsKey("audit_id") && StringUtils.isNotEmpty(obj.getString("audit_id"))) {
                  merchant.setAuditId(obj.getString("audit_id"));
              }
          }
      }
      //修正功用引见
      if (StringUtils.isNotEmpty(basicInfo.getSignature())) {
          ModifySignatureIn msi = new ModifySignatureIn();
          msi.setSignature(basicInfo.getSignature());
          JSONObject obj = BaseUtils.modifySignature(info, msi);
          if (!obj.getInteger(ResStatus.ERRCODE).equals(ResStatus.CODE) || !ResStatus.MSG.equalsIgnoreCase(obj.getString(ResStatus.ERRMSG))) {
              return AjaxResult.error(obj.getInteger(ResStatus.ERRCODE),obj.getString(ResStatus.ERRMSG));
          } else {
              merchant.setAppletsSignature(basicInfo.getSignature());
          }
      }
      //修正隐私设置,即修正是不是可被搜刮
      if (StringUtils.isNotEmpty(basicInfo.getStatus())) {
          SearchStatusIn ssi = new SearchStatusIn();
          ssi.setStatus(basicInfo.getStatus());
          JSONObject obj = BaseUtils.changeWxaSearchStatus(info, ssi);
          if (!obj.getInteger(ResStatus.ERRCODE).equals(ResStatus.CODE) || !ResStatus.MSG.equalsIgnoreCase(obj.getString(ResStatus.ERRMSG))) {
              return AjaxResult.error(obj.getInteger(ResStatus.ERRCODE),obj.getString(ResStatus.ERRMSG));
          } else {
              merchant.setSearchStatus(basicInfo.getStatus());
          }
      }
      merchantService.updateById(merchant);
      return AjaxResult.success();
  }
}复制代码

7、付出受权

即填写商户号和商户号密钥,以及上传p12证书

8、设置效劳器域名

受权给第三方的小程序,其效劳器域名只能够为第三方平台的效劳器,当小程序经由过程第三方平台宣布代码上线后,小程序本来本身设置的效劳器域名将被删除,只保存第三方平台的域名,所以第三方平台在替代小程序宣布代码之前,须要挪用接口为小程序增加第三方平台本身的域名。

注重:

须要先将域名登记到第三方平台的小程序效劳器域名中,才够挪用接口举行设置。

最多能够增加1000个正当效劳器域名;个中,Request域名、Socket域名、Uploadfile域名、Download域名、Udp域名的设置数目均最大支撑200个。

每个月可提交修正要求50次。

public AjaxResult modifyDomain(ModifyDomain modifyDomain) {
  Merchant merchant = merchantService.getById(modifyDomain.getMerchantId());
  if (merchant == null) {
      logger.warn("设置效劳器域名---->失利,merchant为null");
      return AjaxResult.error("设置效劳器域名失利,merchant为null",null);
  } else {
      AuthorizationInfo info = AuthorizedUtils.getAuthorizationInfo(merchant.getAppid());
      ModifyDomainOut out = new ModifyDomainOut();
      out.setAction(modifyDomain.getAction());
      String[] requests = modifyDomain.getRequestdomain().split(",");
      List<String> requestList = Arrays.asList(requests);
      out.setRequestdomain(requestList);
      String[] wsrequests = modifyDomain.getWsrequestdomain().split(",");
      List<String> wsrequestList = Arrays.asList(wsrequests);
      out.setWsrequestdomain(wsrequestList);
      String[] uploads = modifyDomain.getUploaddomain().split(",");
      List<String> uploadList = Arrays.asList(uploads);
      out.setUploaddomain(uploadList);
      String[] downloads = modifyDomain.getDownloaddomain().split(",");
      List<String> downloadsList = Arrays.asList(downloads);
      out.setDownloaddomain(downloadsList);
      JSONObject obj = BaseUtils.modifyDomain(info, out);
      if("0".equals(obj.getString("errcode")) && "ok".equalsIgnoreCase(obj.getString("errmsg"))){
          return AjaxResult.success();
      } else {
          return AjaxResult.error(obj.getInteger("errcode"),obj.getString("errmsg"));
      }
  }
}复制代码

9、设置营业域名

受权给第三方的小程序,其营业域名只能够为第三方平台的效劳器,当小程序经由过程第三方宣布代码上线后,小程序本来本身设置的营业域名将被删除,只保存第三方平台的域名,所以第三方平台在替代小程序宣布代码之前,须要挪用接口为小程序增加营业域名。

注重:

须要先将营业域名登记到第三方平台的小程序营业域名中,才够挪用接口举行设置。

为受权的小程序设置域名时支撑设置子域名,比方第三方登记的营业域名如为 qq.com,则能够直接将 qq.com 及其子域名(如 xxx.qq.com)也设置到受权的小程序中。

最多能够增加100个业

public AjaxResult webviewDomain(WebviewDomain webviewDomain) {
  Merchant merchant = merchantService.getById(webviewDomain.getMerchantId());
  if (merchant == null) {
      logger.warn("设置营业域名---->失利,merchant为null");
      return AjaxResult.error("设置营业域名失利,merchant为null",null);
  } else {
      AuthorizationInfo info = AuthorizedUtils.getAuthorizationInfo(merchant.getAppid());
      SetWebViewDomainOut out = new SetWebViewDomainOut();
      out.setAction(webviewDomain.getAction());
      String[] webviews = webviewDomain.getWebviewdomain().split(",");
      List<String> webviewList = Arrays.asList(webviews);
      out.setWebviewdomain(webviewList);
      JSONObject obj = BaseUtils.setWebViewDomain(info, out);
      if("0".equals(obj.getString("errcode")) && "ok".equalsIgnoreCase(obj.getString("errmsg"))){
          return AjaxResult.success();
      } else {
          return AjaxResult.error(obj.getInteger("errcode"),obj.getString("errmsg"));
      }
  }
}复制代码

10、上传小程序代码

第三方平台须要先将草稿增加到代码模板库,或许从代码模板库中拔取某个代码模板,获得对应的模板 id(template_id);然后挪用本接口能够为已受权的小程序上传代码。

public AjaxResult commit(CommitModel model) {
  Merchant merchant = merchantService.selectMerchantById(model.getMerchantId());
  if (merchant == null) {
      logger.warn("上传代码---->失利,merchant为null");
      return AjaxResult.error("上传代码,merchant为null",null);
  }
  AuthorizationInfo info = AuthorizedUtils.getAuthorizationInfo(merchant.getAppid());
  CommitIn commitIn = new CommitIn();
  String value = model.getValue();
  String[] items = value.split("_");
  String version = items[2];
  commitIn.setTemplate_id(items[0])
          .setUser_desc(items[1])
          .setUser_version(version);

  //第三方自定义的设置
  JSONObject obj = new JSONObject();
  obj.put("extAppid", merchant.getAppid());
  Map<String, Object> map = new HashMap<>();
  map.put("merchantId", model.getMerchantId());
  map.put("userVersion", commitIn.getUser_version());
  obj.put("ext", map);
  map = new HashMap<>();
  Map<String, Object> maps = new HashMap<>();
  maps.put("pages/index/index", map);
  obj.put("extPages", maps);
  commitIn.setExt_json(JSONObject.toJSONString(obj));
  //接收微信返回的数据
  obj = CodeUtils.commit(info, commitIn);
  if("0".equals(obj.getString("errcode")) && "ok".equalsIgnoreCase(obj.getString("errmsg"))){
      AppletsRelease ar = appletsReleaseService.getOne(new LambdaQueryWrapper<AppletsRelease>()
              .eq(AppletsRelease::getMerchantId,merchant.getId()));
      if(ar == null){
          ar = new AppletsRelease();
          ar.setMerchantId(model.getMerchantId()).setHistoryversion(version);
      } else{
          ar.setHistoryversion(version);
      }
      appletsReleaseService.saveOrUpdate(ar);
      return AjaxResult.success();
  } else {
      return AjaxResult.error(obj.getInteger("errcode"),obj.getString("errmsg"));
  }
}复制代码

11、成员治理

第三方平台在协助旗下受权的小程序提交代码考核之前,可先让小程序运营者体验,体验之前须要将运营者的个人微信号增加到该小程序的体验者名单中。

注重: 假如运营者同时也是该小程序的治理员,则无需绑定,治理员默许有体验权限。

/**
* 绑定体验者
* @parambindTester
* @return
*/
@Override
public AjaxResult bindTester(BindTester bindTester) {
  Merchant merchant = merchantService.getById(bindTester.getMerchantId());
  if (merchant == null) {
      logger.warn("绑定体验者---->失利,merchant为null");
      return AjaxResult.error("绑定体验者失利,merchant为null",null);
  } else {
      AuthorizationInfo info = AuthorizedUtils.getAuthorizationInfo(merchant.getAppid());
      JSONObject obj = MemberUtils.bindTester(info, bindTester.getWechatId());
      if("0".equals(obj.getString("errcode")) && "ok".equalsIgnoreCase(obj.getString("errmsg"))){
      AppletsTester at = new AppletsTester();
        at.setMerchantId(bindTester.getMerchantId()).setWechatId(bindTester.getWechatId()).setUserStr(obj.getString("userstr"));
        appletsTesterService.insertAppletsTester(at);
        return AjaxResult.success();
    } else {
        return AjaxResult.error(obj.getInteger("errcode"),obj.getString("errmsg"));
    }
}
}

/**
* 消除体验者
* @paramtesterIds
* @return
*/
@Override
public AjaxResult unbindTester(Long[] testerIds) {
  for (Long id : testerIds) {
      AppletsTester tester = appletsTesterService.getById(id);
      if (tester == null) {
          logger.warn("消除体验者---->失利,tester为null");
          return AjaxResult.error("消除体验者,tester为null",null);
      }
      Merchant merchant = merchantService.getById(tester.getMerchantId());
      if (merchant == null) {
          logger.warn("消除体验者---->失利,merchant为null");
          return AjaxResult.error("消除体验者,merchant为null",null);
          }
        AuthorizationInfo info = AuthorizedUtils.getAuthorizationInfo(merchant.getAppid());
        JSONObject obj = MemberUtils.unbindTester(info, tester.getWechatId());
        if("0".equals(obj.getString("errcode")) && "ok".equalsIgnoreCase(obj.getString("errmsg"))){
            appletsTesterService.removeById(id);
        } else {
            return AjaxResult.error(obj.getInteger("errcode"),obj.getString("errmsg"));
        }
    }
    return AjaxResult.success();
}复制代码

12、猎取体验版二维码

public AjaxResult getQrcode(String merchantId) {
  Merchant merchant = merchantService.getById(merchantId);
  if (merchant == null) {
      logger.warn("猎取体验二维码---->失利,merchant为null");
      return AjaxResult.error("猎取体验二维码,merchant为null",null);
  }
  AuthorizationInfo info = AuthorizedUtils.getAuthorizationInfo(merchant.getAppid());
  String qrcodeUrl =  CodeUtils.getQrcode(info, "pages/index/index");
  return AjaxResult.success("操纵胜利",qrcodeUrl);
}复制代码

13、提交考核

public AjaxResult submitAudit(SubmitAudit submit) {
  Merchant merchant = merchantService.getById(submit.getMerchantId());
  if (merchant == null) {
      logger.warn("猎取体验二维码---->失利,merchant为null");
      return AjaxResult.error("猎取体验二维码,merchant为null", null);
  }
  AuthorizationInfo info = AuthorizedUtils.getAuthorizationInfo(merchant.getAppid());
  List<String> categorys = submit.getCategory();
  submit.setFirst_id(categorys.get(0).split("-")[0])
          .setFirst_class(categorys.get(0).split("-")[1])
          .setSecond_id(categorys.get(1).split("-")[0])
          .setSecond_class(categorys.get(1).split("-")[1])
          .setTag(submit.getTag().replace(",", " "));
  List<SubmitAudit> submits = new ArrayList<>();
  submits.add(submit);
  JSONObject sa = CodeUtils.submitAudit(info, submits);
  if (sa.getInteger(ResStatus.ERRCODE).equals(ResStatus.CODE) && ResStatus.MSG.equalsIgnoreCase(sa.getString(ResStatus.ERRMSG))) {
      JSONObject obj = CodeUtils.getAuditStatus(info, sa.getString("auditid"));
      if (obj.getInteger(ResStatus.ERRCODE).equals(ResStatus.CODE) && ResStatus.MSG.equalsIgnoreCase(obj.getString(ResStatus.ERRMSG))) {
          AppletsRelease ar = appletsReleaseService.getOne(new LambdaQueryWrapper<AppletsRelease>()
                  .eq(AppletsRelease::getMerchantId,merchant.getId()));
          if (ar == null) {
              return AjaxResult.error("请先上传代码");
          }
          ar.setMerchantId(submit.getMerchantId())
                  .setAuditId(sa.getString("auditid"))
                  .setStatus(obj.getString("status"))
                  .setRemark(obj.getString("screenshot"));
          if (AppletsRelease.STATUS_0.equals(ar.getStatus())) {
              ar.setRemark(AppletsRelease.MSG_0);
          } else if (AppletsRelease.STATUS_1.equals(ar.getStatus())) {
              ar.setReason(obj.getString("reason"))
                      .setScreenshot(obj.getString("screenshot"))
                      .setRemark(AppletsRelease.MSG_1);
          } else if (AppletsRelease.STATUS_2.equals(ar.getStatus())) {
              ar.setRemark(AppletsRelease.MSG_2);
          } else if (AppletsRelease.STATUS_3.equals(ar.getStatus())) {
              ar.setRemark(AppletsRelease.MSG_3);
          } else if (AppletsRelease.STATUS_4.equals(ar.getStatus())) {
              ar.setRemark(AppletsRelease.MSG_4);
          }
          appletsReleaseService.updateById(ar);
          return AjaxResult.success();
      } else {
          return AjaxResult.error(obj.getInteger(ResStatus.ERRCODE), obj.getString(ResStatus.ERRMSG));
      }
  } else {
      return AjaxResult.error(sa.getInteger(ResStatus.ERRCODE), sa.getString(ResStatus.ERRMSG));
  }
}复制代码

14、考核撤回

注重: 单个帐号天天考核撤回次数最多不凌驾 1 次,一个月不凌驾 10 次。

public AjaxResult undoCodeAudit(String[] ids) {
  StringBuilder sb = new StringBuilder();
  for (String id : ids) {
      Merchant merchant = merchantService.getById(id);
      AuthorizationInfo info = AuthorizedUtils.getAuthorizationInfo(merchant.getAppid());
      JSONObject obj = CodeUtils.undoCodeAudit(info);
      if (obj.getInteger(ResStatus.ERRCODE).equals(ResStatus.CODE) && ResStatus.MSG.equalsIgnoreCase(obj.getString(ResStatus.ERRMSG))) {
          AppletsRelease ar = appletsReleaseService.getOne(new LambdaQueryWrapper<AppletsRelease>()
                  .eq(AppletsRelease::getMerchantId,merchant.getId()));
          ar.setStatus(AppletsRelease.MSG_3);
          appletsReleaseService.updateById(ar);
      } else{
          sb.append(merchant.getName()+",");
      }
  }
  if (sb.length() == 0) {
      return AjaxResult.success();
  } else {
      String name = sb.substring(0, sb.length()-1);
      return AjaxResult.error(name+"考核撤回失利");
  }
}复制代码

15、宣布已经由过程考核的小程序

public AjaxResult releaseApplets(String[] ids) {
  StringBuilder sb = new StringBuilder();
  for (String id : ids) {
      Merchant merchant = merchantService.getById(id);
      AuthorizationInfo info = AuthorizedUtils.getAuthorizationInfo(merchant.getAppid());
      JSONObject obj = CodeUtils.release(info);
      if (obj.getInteger(ResStatus.ERRCODE).equals(ResStatus.CODE) && ResStatus.MSG.equalsIgnoreCase(obj.getString(ResStatus.ERRMSG))) {
          AppletsRelease ar = appletsReleaseService.getOne(new LambdaQueryWrapper<AppletsRelease>()
                  .eq(AppletsRelease::getMerchantId,merchant.getId()));
          ar.setStatus(AppletsRelease.STATUS_5);
          appletsReleaseService.updateById(ar);
      } else{
          sb.append(merchant.getName()+",");
      }
  }
  if (sb.length() == 0) {
      return AjaxResult.success();
  } else {
      String name = sb.substring(0, sb.length()-1);
      return AjaxResult.error(name+"宣布失利");
  }
}复制代码

16、小程序版本回退

假如没有上一个线上版本,将没法回退

只能向上回退一个版本,即当前版本回退后,不能再挪用版本回退接口。

public AjaxResult revertCodeRelease(String[] ids) {
  StringBuilder sb = new StringBuilder();
  for (String id : ids) {
      Merchant merchant = merchantService.getById(id);
      AuthorizationInfo info = AuthorizedUtils.getAuthorizationInfo(merchant.getAppid());
      JSONObject obj = CodeUtils.revertCodeRelease(info);
      if (!(obj.getInteger(ResStatus.ERRCODE).equals(ResStatus.CODE) && ResStatus.MSG.equalsIgnoreCase(obj.getString(ResStatus.ERRMSG)))) {
          sb.append(merchant.getName()+",");
      }
  }
  if (sb.length() == 0) {
      return AjaxResult.success();
  } else {
      String name = sb.substring(0, sb.length()-1);
      return AjaxResult.error(null,name+"考核撤回失利");
  }
}复制代码

17、猎取小程序码

public AjaxResult getMiniQrcode(@PathVariable("merchantId") String merchantId) {
  Merchant merchant = merchantService.getById(merchantId);
  if (merchant == null) {
      logger.warn("猎取小程序码---->失利,merchant为null");
      return AjaxResult.error("猎取小程序码,merchant为null",null);
  }
  String qrcode;
  if (StringUtils.isNotEmpty(merchant.getAppletImage())) {
      qrcode = merchant.getAppletImage();
  } else {
      AuthorizationInfo info = AuthorizedUtils.getAuthorizationInfo(merchant.getAppid());
      qrcode = WxUtils.getMiniQrcode(merchantId, "pages/index/index", "merchant", "miniQrcode", info.getAuthorizer_access_token());
      merchant.setAppletImage(qrcode);
      merchantService.updateById(merchant);
  }
  return AjaxResult.success("操纵胜利",qrcode);
}复制代码

相干进修引荐:微信小程序教程

以上就是关于微信开放平台那些事,第三方平台开发的细致内容,更多请关注ki4网别的相干文章!

  选择打赏方式
微信赞助

打赏

QQ钱包

打赏

支付宝赞助

打赏

  移步手机端
关于微信开放平台那些事,第三方平台开发_微信小程序

1、打开你手机的二维码扫描APP
2、扫描左则的二维码
3、点击扫描获得的网址
4、可以在手机端阅读此文章

本文来源:搜奇网

本文地址:https://www.sou7.cn/300745.html

关注我们:微信搜索“搜奇网”添加我为好友

版权声明: 本文仅代表作者个人观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。请记住本站网址https://www.sou7.cn/搜奇网。

推荐阅读