config = $this->getAlipay(); } /** * 版本管理 */ public function index() { $auth = false; if(!empty($this->config['app_auth_token'])){ $auth = true; } $model = []; if($auth){ //获取平台推送的最新模板代码 if($result = TemplateCodeModel::getNew($this->app_type,20)){ $model['code_new'] = $result; //最新模板 } $alipay = new Driver($this->applet_id); //线上小程序版本列表 if($result = $alipay->openMiniVersionListQuery()){ //如果已有线上版本 if(isset($result['app_version_infos']) and sizeof($result['app_version_infos'])>0){ $model['app_version_infos'] = $result['app_version_infos']; $model['version'] = $result['app_version_infos'][0]; //筛选线上版本 for($n=0;$napplet_id); //上传代码 if(!$alipay->openMiniVersionUpload($model)){ return $this->renderError($alipay->getError()); } //生成体验版本 if(!$alipay->openMiniExperienceCreate($model['user_version'])){ return $this->renderError($alipay->getError()); } return $this->renderSuccess('操作成功', url('alipay.release/index')); } /** * 获取体验版二维码 */ public function trialQrcode($version) { $alipay = new Driver($this->applet_id); //生成体验版本 $alipay->openMiniExperienceCreate($version); if($model = $alipay->openMiniExperienceQuery($version)){ return $this->renderSuccess('', '', $model); } return $this->renderError($alipay->getError()); } /** * 提交代码审核 * $id=版本号,$speed_up=是否加急 */ public function submitAudit($id,$speed_up='false') { $values = SettingModel::getItem('ability'); //审核通过后是否自动上线 if($values['applet_online'] == 1){ $auto_online = 'true'; }else{ $auto_online = 'false'; } $model = TemplateCodeModel::getCode($this->app_type,$id,20); $alipay = new Driver($this->applet_id); if(!$alipay->openMiniVersionAuditApply($model,$auto_online,$speed_up)){ return $this->renderError($alipay->getError()); } return $this->renderSuccess('操作成功', url('alipay.release/index')); } /** * 撤回代码审核 */ public function undoAudit($id='') { $alipay = new Driver($this->applet_id); if(!$alipay->openMiniVersionAuditCancel($id)){ return $this->renderError($alipay->getError()); } return $this->renderSuccess('操作成功', url('alipay.release/index')); } /** * 发布已通过审核的小程序 */ public function release($id) { $alipay = new Driver($this->applet_id); if(!$alipay->openMiniVersionOnline($id)){ return $this->renderError($alipay->getError()); } return $this->renderSuccess('操作成功', url('alipay.release/index')); } /** * 退回到开发版本 */ public function auditedCancel($id) { $alipay = new Driver($this->applet_id); if(!$alipay->openMiniVersionAuditedCancel($id)){ return $this->renderError($alipay->getError()); } return $this->renderSuccess('操作成功', url('alipay.release/index')); } /** * 发布已通过审核的小程序 * $version=版本号 */ public function versionDetail($version) { $alipay = new Driver($this->applet_id); if(!$model = $alipay->openMiniVersionDetailQuery($version)){ return $this->renderError($alipay->getError()); } return $this->renderSuccess('操作成功', '', $model); } /** * 上架/下架小程序 * $id=版本号 * $status=当前状态 */ public function status($id,$status) { $alipay = new Driver($this->applet_id); if($status == 'RELEASE'){ //下架操作 if(!$alipay->openMiniVersionOffline($id)){ return $this->renderError($alipay->getError()); } }else{ //上架操作 if(!$alipay->openMiniVersionOnline($id)){ return $this->renderError($alipay->getError()); } } return $this->renderSuccess('操作成功', url('alipay.release/index')); } /** * 版本回退 */ public function fallback() { $wx = new Driver; if ($this->request->isGet()) { //获取可回退的小程序版本 if(!$result = $wx->getHistoryVersion($this->applet_id)){ return $this->renderError($wx->getError()); } $list = $result['version_list']; for($n=0;$nrenderSuccess('', '', compact('list')); } $data = $this->postData('data'); // 回退到指定版本 if ($wx->revertCodeRelease($this->applet_id,$data['app_version'])) { return $this->renderSuccess('操作成功', url('wxapp.release/index')); } $error = $wx->getError() ?: '操作失败'; return $this->renderError($error); } }