diff --git a/methods/changes/system.json b/methods/changes/system.json index 759741e..cb92dd1 100644 --- a/methods/changes/system.json +++ b/methods/changes/system.json @@ -1,4 +1,365 @@ [ + { + "version": "2026.09.22-wechat.wxaauth-cos-url", + "date": "2026-09-22", + "type": "updated", + "summary": "wechat.wxaauth 改为后端分步:图片字段传 COS 文件 URL,后端下载 → uploadmedia 换 media_id → wxaauth 提交", + "methods": [ + "wechat.wxaauth" + ], + "notes": [ + "后端分步:① 图片字段值为 http/https(COS URL)时,后端 GET 下载 Buffer → POST /wxa/sec/wxaapi/uploadmedia(multipart/form-data,media_type=image,media=临时文件)换 media_id;② 替换请求体后调 /wxa/sec/wxaapi/wxaauth 提交。非 URL 值视为已传 media_id 原样透传。", + "支持自动换 media_id 的图片字段:顶层 contact_cert_photo/business_license_copy/legal_persona_idcard_copy/legal_persona_media;pic_list 项的 pic_url;qualification_list 项 licence_list/certificate_list 的 value;statement_list 项的 value。", + "uploadmedia 实现细节:Buffer 写临时文件(文件名带 jpg/jpeg/png 扩展名,从 URL path 提取,默认 image.jpg)后按路径传 files:{media}(urllib 2.44 files 支持 Buffer 但文件名固定 bufferfileN 无扩展名,故落临时文件保证扩展名),finally 删除临时文件;40001/40014 清 authorizer token 重试一次。media_id 3 天内有效。", + "代码变更:app/lib/wechat_open_client.js 新增 uploadAuthMedia;app/service/systems/wechat.js 新增 resolveBodyMedia/resolveMediaValue/downloadFromUrl/resolveMediaFilename 并在 wxaauth 中调用。" + ], + "module": "wechat" + }, + { + "version": "2026.09.22-wechat.wxaauth", + "date": "2026-09-22", + "type": "added", + "summary": "新增 wechat.wxaauth 发起小程序认证(一步提交):前端上传材料换 media_id 后传入,后端调 wxa/sec/wxaapi/wxaauth,成功回写 auth_task_id/auth_apply_status", + "methods": [ + "wechat.wxaauth" + ], + "notes": [ + "新增接口 wechat.wxaauth(需登录免权限,权限集 18):前端负责上传材料换取 media_id 后一步提交;入参白名单透传(contact_type/contact_name 必填,其余 contact_*/business_license_*/legal_persona_*/pic_list 等 33 字段白名单)。", + "成功回写 wms_wechat_app.auth_task_id=taskid、auth_apply_status(auth_task_status 置空),返回 taskid/auth_url/apply_status;taskid 供 wechat.queryauth 查询进度(taskid 可选,库中 auth_task_id 兜底)。", + "已认证(verify_type_id>=0)拒绝重复发起;未授权权限集 18 拒绝。lib#wxaauth 40001/40014 清 authorizer token 重试一次。不拆表:认证状态继续复用 wms_wechat_app 现有字段,无迁移。", + "代码变更:app/lib/wechat_open_client.js 新增 wxaauth;app/service/systems/wechat.js 新增 wxaauth;systemMethods/wechat.js 白名单与出口同步。" + ], + "module": "wechat" + }, + { + "version": "2026.09.22-wechat.queryauth-verified-first", + "date": "2026-09-22", + "type": "updated", + "summary": "wechat.queryauth 改为先判已认证再查进度:已认证直接返回认证信息;未认证且有 taskid 才调微信查进度;taskid 可选(库中 auth_task_id 兜底);认证通过回写 verify_type_id=0", + "methods": [ + "wechat.queryauth" + ], + "notes": [ + "判定顺序:① 本地 wms_wechat_app.verify_type_id>=0(已认证)→ 直接返回本地认证信息(is_verified=true/verify_type_id/principal_name/signature/service_type_id/account_status),不调微信;② 未认证(null/-1)→ taskid(入参优先,其次库中 auth_task_id)调 wxa/sec/queryauth 查进度;③ 未认证且无 taskid → 返回 code 200「尚未认证且无认证任务」(is_verified=false)。", + "落库:查询成功回写 auth_task_id/auth_task_status/auth_apply_status;apply_status=4(认证通过)时同时回写 verify_type_id=0(微信认证),后续 queryauth 直接走已认证分支。", + "文档:system.json wechat.queryauth 条目 params(taskid 改可选)/response(新增 is_verified/verify_type_id/principal_name 等)同步。" + ], + "module": "wechat" + }, + { + "version": "2026.09.22-wechat.getAuthorizerInfo-db-fields", + "date": "2026-09-22", + "type": "added", + "summary": "新增 wechat.getAuthorizerInfo 基础信息接口;wms_wechat_app 补充授权账号基础信息与认证状态字段(13列);认证 taskid/状态随 queryauth 成功落库", + "methods": [ + "wechat.getAuthorizerInfo", + "wechat.queryauth" + ], + "notes": [ + "新增接口 wechat.getAuthorizerInfo(需登录免权限):调微信 POST /cgi-bin/component/api_get_authorizer_info(component_access_token)拉取 authorizer_info + authorization_info,将基础信息/认证类型/权限集落库 wms_wechat_app 后返回完整数据。", + "迁移 20260922180000-add-authorizer-info-fields-to-wms-wechat-app:wms_wechat_app 新增 principal_name/signature/alias/qrcode_url/service_type_id/verify_type_id/account_status/register_type/business_info/mini_program_info/auth_task_id/auth_task_status/auth_apply_status,开发+生产均已执行。", + "verify_type_info.id 语义:-1 未认证、0 微信认证、1 新浪微博认证、3 资质通过未名称认证、4 同3+微博;account_status:1 正常、14 已注销、16 已封禁、18 已告警、19 已冻结。", + "认证任务落库口径:taskid 由发起认证接口(wxa/sec/wxaapi/wxaauth,暂未接入)返回,queryauth 查询成功后回写 auth_task_id/auth_task_status/auth_apply_status。", + "代码变更:app/lib/wechat_open_client.js 新增 getAuthorizerDetail(完整返回);app/service/systems/wechat.js 新增 buildAuthorizerPatch/getAuthorizerInfo、queryauth 增加状态落库;app/controller/wechatOpen.js 授权回调/authorized/updateauthorized 事件改用 getAuthorizerDetail 全量字段落库;app/model/wechat_app.js、systemMethods/wechat.js 同步。" + ], + "module": "wechat" + }, + { + "version": "2026.09.22-wechat.getAuthUrl-scope", + "date": "2026-09-22", + "type": "updated", + "summary": "wechat.getAuthUrl 授权链接限定授权范围:auth_type=2(仅小程序)+ category_id_list=18|86(代码管理、体验版二维码)", + "methods": [ + "wechat.getAuthUrl" + ], + "notes": [ + "修正认知:auth_type 是授权账号类型(1公众号/2小程序/3公众号+小程序),不是权限范围;权限范围由 category_id_list(权限集 id 列表,竖线分隔)或商家在授权页自定义勾选控制。业务所需权限集:18=小程序代码管理(commit/submit_audit/queryauth/get_qrcode)、86=体验版二维码;getTemplateList/jscode2session/快速注册不需要商家权限集。", + "代码变更:app/service/systems/wechat.js#getAuthUrl 授权链接增加 category_id_list=18|86、auth_type 改为 2。前提:18/86 需在微信开放平台后台「权限集」配置并全网发布,否则商家授权页看不到;已授权商家需重新扫码授权才能获得 18/86。" + ], + "module": "wechat" + }, + { + "version": "2026.09.22-wechat.commit-ext-json-default", + "date": "2026-09-22", + "type": "updated", + "summary": "wechat.commit 的 ext_json 改为后端默认生成(仅 extEnable+extAppid),不再由前端传入", + "methods": [ + "wechat.commit" + ], + "notes": [ + "入参仅剩 template_id;ext_json 由后端生成 JSON.stringify({extEnable:true, extAppid: 当前小程序appid}),前端传值被忽略;响应新增 ext_json 回显。", + "代码变更:app/service/systems/wechat.js#commit;文档 system.json wechat.commit 条目 params/response 同步。" + ], + "module": "wechat" + }, + { + "version": "2026.09.22-wechat.commit-desc-from-template", + "date": "2026-09-22", + "type": "updated", + "summary": "wechat.commit 代码描述也改为从模板取:user_version 与 user_desc 均不再由外部传入", + "methods": [ + "wechat.commit" + ], + "notes": [ + "入参进一步瘦身:user_desc 也移除(外部传入被忽略);commit 流程:getTemplateList(0) → 按 template_id 找模板 → 取模板 user_version(≤64)与 user_desc 作为上传版本号/代码描述(缺失分别报「模板缺少合法版本号/缺少代码描述」)→ wxa/commit 成功后回写 wms_wechat_app.template_id/user_version;响应新增 user_desc。", + "代码变更:app/service/systems/wechat.js#commit;文档 system.json wechat.commit 条目 params/response 同步。" + ], + "module": "wechat" + }, + { + "version": "2026.09.22-wechat.userList", + "date": "2026-09-22", + "type": "added", + "summary": "新增微信模块 wechat.userList(需登录):拉取当前仓库小程序的用户列表(wms_user_oauth),支持 where/pagination/sort", + "methods": [ + "wechat.userList" + ], + "notes": [ + "system.json 新增 module=wechat 方法 wechat.userList(isNeedLogin=true、isNeedAuth=false、Authorization 头):按 ctx.user.store_id 取仓库启用小程序(wms_wechat_app,is_enabled=1;可选 app_id 指定单个,须属于当前仓库),查询 wms_user_oauth(provider=wechat,app_id IN 命中应用);入参 where(字段白名单 id/user_id/app_id/openid/unionid/nickname/sex/login_time/login_count/created_at/updated_at,operator 结构,经 prepareWhereContext 解析)、pagination(page/pageSize)、sort(sortField 白名单同上,默认 updated_at DESC)。", + "代码变更:app/service/systems/wechat.js#userList(findAndCountAll,attributes 排除 session_key/refresh_token/access_token/expire_in/expire_time/login_code 敏感字段,raw+is_bound);app/service/systemMethods/wechat.js 出口 + where 字段白名单过滤 + _noNeedRight/_noNeedLog/_noNeedAuth 白名单加入 userList。", + "无数据库变更(纯只读查询)。" + ], + "module": "wechat" + }, + { + "version": "2026.09.22-wechat.queryauth-fix", + "date": "2026-09-22", + "type": "updated", + "summary": "修复 wechat.queryauth:接口路径改为 wxa/sec/queryauth 并新增必填入参 taskid,响应改为 task_status/apply_status", + "methods": [ + "wechat.queryauth" + ], + "notes": [ + "根因:此前实现误用 /wxa/sec/wxaapi/queryauth 且未传 taskid,微信返回 40066 invalid url;官方接口为 POST /wxa/sec/queryauth?access_token=authorizer_access_token,请求体必填 taskid(发起认证接口 wxa/sec/wxaapi/wxaauth 返回)。", + "修复:lib#queryMiniProgramAuth 改路径并传 { taskid },40001/40014 清 authorizer token 重试;systems#queryauth 新增 taskid 必填校验,响应返回 task_status/apply_status/orderid/auth_url 等并附中文文案;文档 system.json queryauth 条目同步更新。" + ], + "module": "wechat" + }, + { + "version": "2026.09.22-wechat.submitAudit", + "date": "2026-09-22", + "type": "added", + "summary": "新增微信模块 wechat.submitAudit(需登录):提交代码审核,wms_wechat_app 新增审核状态字段(开发+生产已迁移)", + "methods": [ + "wechat.submitAudit" + ], + "notes": [ + "system.json 新增 module=wechat 方法 wechat.submitAudit(isNeedLogin=true、isNeedAuth=false、Authorization 头):入参白名单 item_list/feedback_info/feedback_stuff/preview_info/version_desc/privacy_api_not_use/order_info/ugc_declare;校验权限集 18;仅 audit_status!=1 时允许提交;POST wxa/submit_audit(authorizer_access_token,40001/40014 清缓存重试)成功后回写 audit_status=1、audit_id。", + "数据库:迁移 20260922170000-add-audit-fields-to-wms-wechat-app.js(user_version/audit_status/audit_id/audit_reason),开发与生产均已执行;commit 同步回写 user_version;审核结果事件 weapp_audit_success→audit_status=2、weapp_audit_fail→audit_status=3+audit_reason(按 ToUserName=user_name 定位)。" + ], + "module": "wechat" + }, + { + "version": "2026.09.22-wechat.getTrialQRCode", + "date": "2026-09-22", + "type": "added", + "summary": "新增微信模块 wechat.getTrialQRCode(需登录):获取体验版二维码(转存 COS 返回 URL)", + "methods": [ + "wechat.getTrialQRCode" + ], + "notes": [ + "system.json 新增 module=wechat 方法 wechat.getTrialQRCode(isNeedLogin=true、isNeedAuth=false、Authorization 头):入参 path(可选);按 ctx.user.store_id 取仓库启用小程序,hasFuncScope 校验权限集 18 或 86;GET wxa/get_qrcode(authorizer_access_token,path 自动 urlencode,40001/40014 清 authorizer token 缓存重试)返回 jpeg 图片,经 upload.uploadBuffer 转存 COS(key=qrcode/wechat/{warehouseId}/{yyyymmdd}/{ts}{rand}.jpg)后返回 URL。", + "代码变更:app/lib/wechat_open_client.js#getTrialQRCode;app/service/systems/wechat.js#getTrialQRCode/#buildTrialQrCodeKey;app/service/systemMethods/wechat.js 出口 + _noNeedRight/_noNeedAuth 白名单。" + ], + "module": "wechat" + }, + { + "version": "2026.09.22-wechat.commit", + "date": "2026-09-22", + "type": "added", + "summary": "新增微信模块 wechat.commit(需登录):上传代码并生成体验版,wms_wechat_app 新增 template_id 字段(开发+生产已迁移)", + "methods": [ + "wechat.commit" + ], + "notes": [ + "system.json 新增 module=wechat 方法 wechat.commit(isNeedLogin=true、isNeedAuth=false、Authorization 头):入参 template_id/ext_json/user_version(≤64)/user_desc;按 ctx.user.store_id 取仓库启用小程序,hasFuncScope(func_info, 18) 校验代码管理权限集,getTemplateList(0) 校验模板存在(微信 85014 兜底),POST wxa/commit(authorizer_access_token,40001/40014 清 authorizer token 缓存重试)成功后回写 wms_wechat_app.template_id。", + "数据库:迁移 20260922160000-add-template-id-to-wms-wechat-app.js(wms_wechat_app.template_id bigint unsigned nullable),已在开发(127.0.0.1:3307)与生产(112.124.21.102)执行并验证;app/model/wechat_app.js 同步 template_id 字段。" + ], + "module": "wechat" + }, + { + "version": "2026.09.22-wechat.getTemplateList", + "date": "2026-09-22", + "type": "added", + "summary": "新增微信模块 wechat.getTemplateList(需登录):获取普通模板库列表,Redis 缓存 24h", + "methods": [ + "wechat.getTemplateList" + ], + "notes": [ + "system.json 新增 module=wechat 方法 wechat.getTemplateList(isNeedLogin=true、isNeedAuth=false、Authorization 头):只拉普通模板(template_type=0,GET wxa/gettemplatelist + component_access_token,40001 自愈);Redis key wechat:template:list:normal 缓存 24h,有缓存直接返回(from_cache=true),无缓存拉取后写缓存。", + "代码变更:app/lib/wechat_open_client.js#getTemplateList(GET 请求封装);app/service/systems/wechat.js#getTemplateList;app/service/systemMethods/wechat.js 出口 + _noNeedRight/_noNeedAuth 白名单。" + ], + "module": "wechat" + }, + { + "version": "2026.09.22-wechat.getMyLoginCode", + "date": "2026-09-22", + "type": "added", + "summary": "新增 wechat.getMyLoginCode:获取当前微信登录用户的登录码(至少微信登录),无则生成写入、有则直接返回", + "methods": [ + "wechat.getMyLoginCode" + ], + "notes": [ + "systemMethods/wechat.js 白名单:_noNeedBind 新增 getMyLoginCode(微信登录态中间层,未绑定真实用户也可访问,业务层校验 ctx.oauth);systems/wechat.js 新增 getMyLoginCode:ctx.oauth 定位 wms_user_oauth,login_code 为空时 buildLoginCode(id) 生成(uuid={id}_{6位随机}、form=wechat 的 JSON base64)并回写,已有直接返回;system.json 微信模块新增该 method" + ], + "module": "wechat" + }, + { + "version": "2026.09.22-wechat.uploadHeadimg", + "date": "2026-09-22", + "type": "added", + "summary": "新增微信模块 wechat.uploadHeadimg(微信登录态中间层):上传裁剪后的 PNG 头像(<500K)并回写 headimgurl", + "methods": [ + "wechat.uploadHeadimg" + ], + "notes": [ + "system.json 新增 module=wechat 方法 wechat.uploadHeadimg(中间层鉴权,至少微信登录即可,未绑定也可):入参 image(PNG base64,支持 data URL 前缀);校验大小 <500K 与 PNG 文件头魔数后经 upload.uploadBuffer 上传 COS(key=headimg/wechat/{yyyymmdd}/{timestamp}{random}.png,不依赖仓库上下文),回写 wms_user_oauth.headimgurl 并返回 URL。", + "代码变更:app/service/systems/upload.js#uploadBuffer(Buffer 直传 COS);app/service/systems/wechat.js#uploadHeadimg/#buildHeadimgKey;app/service/systemMethods/wechat.js 出口 + _noNeedBind 白名单。" + ], + "module": "wechat" + }, + { + "version": "2026.09.22-wechat.updateInfo", + "date": "2026-09-22", + "type": "added", + "summary": "新增微信模块 wechat.updateInfo(微信登录态中间层):未绑定用户更新自己的昵称/头像", + "methods": [ + "wechat.updateInfo" + ], + "notes": [ + "system.json 新增 module=wechat 方法 wechat.updateInfo(中间层鉴权,需有效微信登录态 token):仅未绑定真实用户(wms_user_oauth.user_id=0)可更新 nickname(≤255)/headimgurl(≤500),可部分更新,至少一个字段;已绑定账号返回「账号已绑定,不支持修改微信资料」。", + "代码变更:app/service/systems/wechat.js#updateInfo;app/service/systemMethods/wechat.js 出口 + _noNeedBind 白名单加入 updateInfo。" + ], + "module": "wechat" + }, + { + "version": "2026.09.22-user.info-wechat-appId-filter", + "date": "2026-09-22", + "type": "updated", + "summary": "user.info 新增可选入参 wechat_appId:传入时按小程序归属仓库过滤工号列表(仅保留非仓库工号(货主)+ 该仓库工号)", + "methods": [ + "user.info" + ], + "notes": [ + "user.info 新增可选入参 wechat_appId:按 wms_wechat_app.appid(is_enabled=1)反查归属 warehouse_id,有仓库时过滤返回的 user.employees —— 保留 role_type!=warehouse(货主工号)或 store_id=该仓库 的工号;未传或查不到仓库保持原逻辑。", + "代码变更:app/service/systems/auth/user.js#info 增加 data.wechat_appId 处理(method 层 user.info 已透传 data)。" + ], + "module": "user" + }, + { + "version": "2026.09.22-wechat.registerMiniprogram", + "date": "2026-09-22", + "type": "added", + "summary": "新增微信模块 wechat.registerMiniprogram(需登录):快速注册企业小程序", + "methods": [ + "wechat.registerMiniprogram" + ], + "notes": [ + "system.json 新增 module=wechat 方法 wechat.registerMiniprogram(isNeedLogin=true、isNeedAuth=false、Authorization 头):入参 name/code/code_type/legal_persona_wechat/legal_persona_name(必填)+ component_phone(选填),校验后调微信 fastregisterweapp?action=create(component_access_token,40001 自愈重试);注册任务创建后法人微信收到模板消息做人脸核身,审核结果通过 notify_third_fasteregister 事件推送到授权事件接收 URL(后续需在 handleEvent 中处理该事件绑定仓库)。", + "代码变更:app/lib/wechat_open_client.js#fastRegisterWeapp(create/search 通用封装 + 40001 自愈);app/service/systems/wechat.js#registerMiniprogram;app/service/systemMethods/wechat.js 出口 + _noNeedRight/_noNeedAuth 白名单。" + ], + "module": "wechat" + }, + { + "version": "2026.09.22-wechat.queryauth", + "date": "2026-09-22", + "type": "added", + "summary": "新增微信模块 wechat.queryauth(需登录):查询当前仓库小程序的认证状态", + "methods": [ + "wechat.queryauth" + ], + "notes": [ + "system.json 新增 module=wechat 方法 wechat.queryauth(isNeedLogin=true、isNeedAuth=false、Authorization 头):按 ctx.user.store_id 取仓库启用小程序(wms_wechat_app,is_enabled=1,id ASC 取第一条),用 authorizer_access_token 调微信 wxa/sec/wxaapi/queryauth 返回 auth_state(0 未认证/1 认证中/2 认证通过/3 认证失败)并附 auth_state_text 中文文案。", + "代码变更:app/lib/wechat_open_client.js#queryMiniProgramAuth(authorizer_access_token 调 wxa/sec/wxaapi/queryauth,支持 DB 落库的 authorizer_refresh_token 兜底 Redis 丢失);app/service/systems/wechat.js#queryauth;app/service/systemMethods/wechat.js 出口 + _noNeedRight/_noNeedAuth 白名单加入 queryauth。" + ], + "module": "wechat" + }, + { + "version": "2026.09.21-wechat.pushLoginCode-legacy-code", + "date": "2026-09-21", + "type": "updated", + "summary": "弃用 wechat.getLoginWechatCode,wechat.pushLoginCode 改为复用旧 user.getLoginWechatCode 生成的登录码", + "methods": [ + "wechat.pushLoginCode" + ], + "notes": [ + "弃用新增的 wechat.getLoginWechatCode(移除 systems/method 层与文档);小程序端继续使用旧 user.getLoginWechatCode 生成/轮询 6 位字母+数字登录码(user:wechat:login:code:* / client key,TTL 60s)。", + "wechat.pushLoginCode(需登录免权限)改造:读旧码缓存(getWechatLoginCodeCacheKey)取 client_code,经 findYe4sBindingByAccountId 反查当前账号 ye4s_user,将 ye4s_user_id 双写旧登录码缓存(code key + client key,TTL 按剩余有效期),旧轮询方读到 ye4s_user_id 即走 loginByYe4sUserId 直登返回正常 WMS token。" + ], + "module": "wechat" + }, + { + "version": "2026.09.21-wechat.loginCode-flow", + "date": "2026-09-21", + "type": "added", + "summary": "新增微信模块 wechat.getLoginWechatCode / wechat.pushLoginCode:小程序端生成 6 位登录码轮询,PC 已登录用户确认后小程序端返回登录成功并绑定账号", + "methods": [ + "wechat.getLoginWechatCode", + "wechat.pushLoginCode" + ], + "notes": [ + "getLoginWechatCode(微信登录态中间层 _noNeedBind):不传 code 生成 6 位数字登录码写 Redis(key wechat:login:code:{code},TTL 300s,记录 oauth_id);传 code 轮询状态 pending/expired/success;success 时校验归属 oauth_id、一次性消费登录码、绑定 wms_user_oauth.user_id=确认账号(防换绑)并签发登录 token(id=账号ID、oauth_id 保留)。", + "pushLoginCode(需登录、免权限):PC/Web 已登录用户传 code,将对应缓存态置 success 并写入 account_id(TTL 120s 等待小程序领取);登录码归属校验防止他人码窃取登录。", + "代码变更:app/service/systems/wechat.js#getLoginWechatCode/#pushLoginCode/#createLoginCode/#getLoginCodeCacheKey、app/service/systemMethods/wechat.js(出口 + _noNeedBind 白名单 + _noNeedRight 加入 pushLoginCode)。" + ], + "module": "wechat" + }, + { + "version": "2026.09.21-wechat.loginByCode-appid-string", + "date": "2026-09-21", + "type": "updated", + "summary": "wechat.loginByCode 应用标识兼容字符串 appid:新增 appid(微信 AppID 字符串)入参按 uk_appid 反查,app_id(整数主键)保留向后兼容", + "methods": [ + "wechat.loginByCode" + ], + "notes": [ + "微信 AppID 是字符串(如 wx6e91ec813bcb7eec),小程序端应传 appid 字符串(模板小程序运行时取 wx.getAccountInfoSync().miniProgram.appId)而非数据库主键。", + "代码变更:app/service/systems/wechat.js 新增 resolveWechatApp(优先 app_id 主键,其次 appid 按 uk_appid 反查并过滤 is_enabled=1);loginByCode 经 resolveWechatApp 解析应用记录,wms_user_oauth.app_id 仍存 wms_wechat_app.id(整数外键)。文档 system.json loginByCode 入参补充 appid 字段说明。" + ], + "module": "wechat" + }, + { + "version": "2026.09.21-user.info-oauth-middle", + "date": "2026-09-21", + "type": "updated", + "summary": "user.info 支持微信登录态中间层:微信登录未绑定时返回微信层信息(is_bound=false),不 401", + "methods": [ + "user.info" + ], + "notes": [ + "systemMethods/user.js 构造器新增 _noNeedBind='info'(systemInit 第 5 参),微信登录态 token 可调用 user.info;auth.user.info 增加分支:未绑定真实用户(ctx.oauth 存在且无 ctx.user)时返回微信层信息(id=0/is_bound=false/oauth_id/openid/unionid/nickname/headimgurl/login_time/login_count,code 200),不 401;绑定/正常登录仍返回 findById 完整信息。", + "代码变更:app/service/systems/auth/user.js#info、app/service/systemMethods/user.js;撤销前版 wechat.getUserInfo(用户要求 getUserInfo 为公用接口,不收在 wechat 模块)。" + ], + "module": "user" + }, + { + "version": "2026.09.21-wechat.bindUser", + "date": "2026-09-21", + "type": "added", + "summary": "新增微信模块 wechat.bindUser(微信登录态中间层):用户名密码一致则绑定 wms_user_oauth.user_id 并签发绑定后的新 token", + "methods": [ + "wechat.bindUser" + ], + "notes": [ + "system.json 新增 module=wechat 方法 wechat.bindUser(中间层鉴权:需有效微信登录态 token,未绑定真实用户也可调用):入参 username(用户名/手机号/邮箱)+ password;复用 auth.user 的 findUserByIdentifier/checkUserStatus/verifyPassword 校验;一致则 wms_user_oauth.user_id 绑定账号并签发新 token(payload id=账号ID、oauth_id 保留);已绑定时仅允许本人凭据幂等调用,不允许换绑。", + "鉴权机制:app/service/main.js checkAuth 新增中间层白名单 _noNeedBind(systemInit 第 5 参),oauth token 有效即通过(user_id=0 也可),ctx.oauth/ctx.oauthId 注入微信身份,不查 API 权限;代码变更:app/service/systemMethods/wechat.js(bindUser 出口 + _noNeedBind 白名单)、app/service/systems/wechat.js#bindUser/#buildBindResult。" + ], + "module": "wechat" + }, + { + "version": "2026.09.21-wechat.loginByCode", + "date": "2026-09-21", + "type": "added", + "summary": "新增微信模块 wechat.loginByCode(免登录):小程序 wx.login code 换 openid/session_key 并查/建 wms_user_oauth,返回 token+user", + "methods": [ + "wechat.loginByCode" + ], + "notes": [ + "system.json 新增 module=wechat 方法 wechat.loginByCode(免登录 isNeedLogin=false):入参 code(wx.login 获取)+ app_id(wms_wechat_app.id);jscode2session(GET /sns/component/jscode2session)换 openid/session_key/unionid;wms_user_oauth 有记录则刷新 login_time/login_count/session_key,无记录则创建且 user_id=0(未绑定);JWT payload 记录 oauth_id(wms_user_oauth.id),区别于正常登录的用户 id 字段。", + "代码变更:app/lib/wechat_open_client.js#jscode2session(GET 请求封装);app/service/systems/wechat.js#loginByCode;app/service/systemMethods/wechat.js 免登录白名单加入 loginByCode。" + ], + "module": "wechat" + }, { "version": "2026.09.21-workbench.packOrder-business-users-restore", "date": "2026-09-21", diff --git a/methods/system.json b/methods/system.json index 57cd4d5..2db95c6 100644 --- a/methods/system.json +++ b/methods/system.json @@ -1,8 +1,8 @@ { "module": "system", "description": "系统接口标准入口,method 对应系统内置方法,全部使用 POST 请求,参数统一放在 body 内", - "version": "0.3.143", - "updatedAt": "2026-09-21", + "version": "0.3.169", + "updatedAt": "2026-09-22", "headers": [ { "name": "platform", @@ -4501,7 +4501,7 @@ }, { "method": "order.pendingOrder.parseAddress", - "description": "智能地址解析:使用 AI 将非结构化地址字符串解析为省/市/区/详细地址/收件人/手机号。支持单条解析与数组批量解析:address 传字符串时返回单条结果,addresses(或 address)传字符串数组时批量解析,响应 data.list 按输入顺序返回每条地址的解析结果(失败条目 flag=failure 不影响其他条目)。", + "description": "智能地址解析:使用内置省市区地址字典遍历方式将非结构化地址字符串解析为省/市/区/详细地址/手机号(不调用 AI)。支持单条解析与数组批量解析:address 传字符串时返回单条结果,addresses(或 address)传字符串数组时批量解析,响应 data.list 按输入顺序返回每条地址的解析结果(失败条目 flag=failure 不影响其他条目)。", "isNeedAuth": false, "isNeedLogin": true, "headers": [], @@ -4670,10 +4670,187 @@ ], "notes": [ "方法部署位置:systemMethods/order/pendingOrder/parseAddress", - "使用 DeepSeek AI 模型进行智能解析", + "使用本地省市区地址字典遍历识别(原 DeepSeek AI 方式已弃用)", "解析结果可直接回填到 createOrder 的收件人信息字段", "未识别到的字段返回空字符串", - "批量解析:addresses 或 address 传字符串数组,按每 10 条合并为一个请求并行发出,全部返回后按输入顺序聚合,单条失败不影响其他条目(模型 deepseek-v4-flash)" + "批量解析:addresses 或 address 传字符串数组,按输入顺序逐条遍历识别并聚合返回,单条失败不影响其他条目" + ] + }, + { + "method": "order.pendingOrder.parseAddressLocal", + "description": "本地地址解析接口:不调用 AI,接口内置省市区地址字典数据,对地址字符串遍历匹配识别省/市/区(含直辖市、省直辖县级市、不设区地级市、地级市代管县级市)。与 parseAddress 使用同一套本地字典遍历解析逻辑,两者解析结果等价。支持单条与批量:address 传字符串时返回单条结果,addresses(或 address)传字符串数组时批量解析返回 data.list;address 与 addresses 均不传时,使用接口内置的示例地址数据遍历识别并返回 data.list(data.source=sample)。", + "isNeedAuth": false, + "isNeedLogin": true, + "headers": [], + "params": [ + { + "name": "address", + "type": "string", + "required": false, + "source": "body", + "description": "原始地址字符串(选填),如\"张三 13800138000 广东省广州市天河区体育西路100号\"。也支持传字符串数组批量解析(与 addresses 二选一);两者均不传时使用内置示例地址数据" + }, + { + "name": "addresses", + "type": "string[]", + "required": false, + "source": "body", + "description": "批量地址字符串数组,单次最多 50 条,按数组顺序返回解析结果;不传 address 与 addresses 时返回内置示例地址数据的遍历识别结果" + } + ], + "requestBody": [], + "response": [ + { + "name": "code", + "type": "number", + "required": true, + "description": "1=成功,0=失败" + }, + { + "name": "message", + "type": "string", + "required": true, + "description": "提示消息" + }, + { + "name": "data", + "type": "object", + "required": false, + "description": "解析成功时返回 province/city/area/town/detailAddress/mobile" + }, + { + "name": "data.province", + "type": "string", + "required": false, + "description": "省份,如 广东省" + }, + { + "name": "data.city", + "type": "string", + "required": false, + "description": "城市,如 广州市" + }, + { + "name": "data.area", + "type": "string", + "required": false, + "description": "区/县,如 天河区" + }, + { + "name": "data.town", + "type": "string", + "required": false, + "description": "乡镇/街道,如 员村街道" + }, + { + "name": "data.detailAddress", + "type": "string", + "required": false, + "description": "详细地址,如 体育西路100号" + }, + { + "name": "data.mobile", + "type": "string", + "required": false, + "description": "收件人手机号,如 13800138000" + }, + { + "name": "data.list", + "type": "array", + "required": false, + "description": "批量解析或内置示例数据遍历识别时返回的结果数组,按输入顺序排列;每条含 address/flag/message/province/city/area/town/detailAddress/name/mobile,失败条目 flag=failure 且解析字段为空字符串" + }, + { + "name": "data.list[].address", + "type": "string", + "required": false, + "description": "原始地址字符串(原样返回)" + }, + { + "name": "data.list[].flag", + "type": "string", + "required": false, + "description": "该条解析状态:success=成功,failure=失败" + }, + { + "name": "data.list[].message", + "type": "string", + "required": false, + "description": "该条解析提示:成功为 ok,失败为具体错误原因" + }, + { + "name": "data.list[].province", + "type": "string", + "required": false, + "description": "省份,如 广东省" + }, + { + "name": "data.list[].city", + "type": "string", + "required": false, + "description": "城市,如 广州市" + }, + { + "name": "data.list[].area", + "type": "string", + "required": false, + "description": "区/县,如 天河区" + }, + { + "name": "data.list[].town", + "type": "string", + "required": false, + "description": "乡镇/街道,如 员村街道" + }, + { + "name": "data.list[].detailAddress", + "type": "string", + "required": false, + "description": "详细地址,如 体育西路100号" + }, + { + "name": "data.list[].name", + "type": "string", + "required": false, + "description": "收件人姓名(本地遍历不识别,固定返回空字符串)" + }, + { + "name": "data.list[].mobile", + "type": "string", + "required": false, + "description": "收件人手机号,如 13800138000" + }, + { + "name": "data.source", + "type": "string", + "required": false, + "description": "未传 address/addresses 时为 sample,表示结果来自内置示例地址数据" + } + ], + "errors": [ + { + "code": 400, + "message": "地址字符串不能为空" + }, + { + "code": 400, + "message": "地址数组不能为空" + }, + { + "code": 400, + "message": "单次批量解析最多支持 50 条地址" + }, + { + "code": 500, + "message": "地址解析失败(省市区均无法识别)" + } + ], + "notes": [ + "方法部署位置:systemMethods/order/pendingOrder/parseAddressLocal", + "不调用 AI 接口,本地遍历内置省市区地址字典(LOCAL_CITY_DICT,约 340 个地级市/自治州/地区/盟)识别省市区", + "辅助识别:CHINA_ADMIN_DIVISION_MAP(省直辖县级市/不设区地级市/代管县级市)、PROVINCE_LIST(省份全称与简称)", + "与 parseAddress 使用同一套本地字典遍历解析逻辑,两者解析结果等价", + "本地遍历不识别收件人姓名,name 固定返回空字符串" ] }, { @@ -30003,7 +30180,7 @@ }, { "method": "user.info", - "description": "获取当前用户信息", + "description": "获取当前用户信息(支持微信登录态中间层:微信登录未绑定真实用户时返回微信层信息 is_bound=false/id=0,不 401;绑定/正常登录返回用户完整信息)。可选入参 wechat_appId:传入时按该小程序归属仓库过滤工号列表,只保留非仓库工号(货主)与仅该仓库工号;未传或查不到仓库时保持原逻辑", "isNeedAuth": false, "isNeedLogin": true, "headers": [ @@ -30014,7 +30191,15 @@ "description": "Bearer token" } ], - "params": [], + "params": [ + { + "name": "wechat_appId", + "type": "string", + "required": false, + "source": "body", + "description": "小程序 AppID(可选):按 wms_wechat_app.appid 反查归属仓库,过滤 employees 列表" + } + ], "response": [], "errors": [] }, @@ -46732,6 +46917,820 @@ "description": "仓库ID(缺省取当前登录用户所属仓库)" } ] + }, + { + "method": "wechat.loginByCode", + "description": "微信小程序登录码登录(免登录):wx.login code + 应用标识(appid 字符串或 app_id 主键,二选一)换取 openid/session_key(jscode2session),查询/创建 wms_user_oauth(无记录时创建且 user_id=0 未绑定),返回 token+user;JWT payload 记录 oauth_id(wms_user_oauth.id,区别于正常登录的用户 id 字段)", + "isNeedAuth": false, + "isNeedLogin": false, + "headers": [], + "params": [ + { + "name": "code", + "type": "string", + "required": true, + "source": "body", + "description": "wx.login 获取的 code" + }, + { + "name": "app_id", + "type": "number", + "required": false, + "source": "body", + "description": "wms_wechat_app.id(整数主键,向后兼容,优先级高于 appid)" + }, + { + "name": "appid", + "type": "string", + "required": false, + "source": "body", + "description": "小程序原始 AppID(字符串,如 wx6e91ec813bcb7eec;模板小程序运行时取 wx.getAccountInfoSync().miniProgram.appId,按 uk_appid 反查授权记录)" + } + ], + "response": [ + { + "name": "token", + "type": "string", + "required": true, + "description": "JWT 登录令牌(payload 含 oauth_id)" + }, + { + "name": "user", + "type": "object", + "required": true, + "description": "登录用户信息(id/oauth_id/openid/unionid/nickname/headimgurl/login_time/login_count)" + } + ], + "errors": [ + { + "code": "400", + "message": "缺少 code/app_id/appid 参数或小程序未授权/已停用" + }, + { + "code": "500", + "message": "jscode2session 换取失败" + } + ] + }, + { + "method": "wechat.bindUser", + "description": "微信登录态绑定用户(中间层鉴权:需有效微信登录态 token,未绑定真实用户也可调用):传入 username+password,一致则将 wms_user_oauth.user_id 绑定到账号并签发绑定后的新 token(id=账号ID、oauth_id 保留);已绑定时仅允许本人凭据幂等调用,不允许换绑", + "isNeedAuth": false, + "isNeedLogin": true, + "headers": [ + { + "name": "Authorization", + "type": "string", + "required": true, + "description": "Bearer token(微信登录态 token,payload 含 oauth_id)" + } + ], + "params": [ + { + "name": "username", + "type": "string", + "required": true, + "source": "body", + "description": "用户名/手机号/邮箱" + }, + { + "name": "password", + "type": "string", + "required": true, + "source": "body", + "description": "登录密码" + } + ], + "response": [ + { + "name": "token", + "type": "string", + "required": true, + "description": "绑定后的新 JWT(id=账号ID、oauth_id 保留)" + }, + { + "name": "user", + "type": "object", + "required": true, + "description": "绑定后的用户信息(id/username/real_name/phone/oauth_id/openid/unionid/nickname/headimgurl)" + } + ], + "errors": [ + { + "code": "400", + "message": "用户名或密码错误/账号状态异常/已绑定其他账号无法换绑" + }, + { + "code": "401", + "message": "微信登录态不存在或已失效" + } + ] + }, + { + "method": "wechat.pushLoginCode", + "description": "确认登录码(需登录,PC/Web 已登录用户):传入旧链路 user.getLoginWechatCode 生成的 6 位登录码(字母+数字),使用当前鉴权账号反查 ye4s 绑定并将 ye4s_user_id 双写旧登录码缓存(user:wechat:login:code:{code} 与 client key),小程序端按旧链路轮询到后直接返回登录成功", + "isNeedAuth": false, + "isNeedLogin": true, + "headers": [ + { + "name": "Authorization", + "type": "string", + "required": true, + "description": "Bearer token(正常登录 token)" + } + ], + "params": [ + { + "name": "code", + "type": "string", + "required": true, + "source": "body", + "description": "旧链路 user.getLoginWechatCode 生成的 6 位登录码(字母+数字)" + } + ], + "response": [ + { + "name": "code", + "type": "string", + "required": true, + "description": "登录码" + }, + { + "name": "client_code", + "type": "string", + "required": true, + "description": "对应客户端编码(旧链路轮询用)" + }, + { + "name": "status", + "type": "string", + "required": true, + "description": "success 已确认" + } + ], + "errors": [ + { + "code": "400", + "message": "登录码格式不正确/不存在/已过期或当前账号未绑定微信登录账号" + }, + { + "code": "401", + "message": "未登录" + } + ] + }, + { + "method": "wechat.queryauth", + "description": "查询当前仓库小程序的认证状态(需登录):先查本地 wms_wechat_app.verify_type_id——已认证(>=0)直接返回认证信息不调微信;未认证且有 taskid(入参优先,其次库中 auth_task_id)调 POST wxa/sec/queryauth(authorizer_access_token,权限集 18)查进度;未认证且无 taskid 返回尚未认证状态(code 200,is_verified=false)。查询成功回写 auth_task_id/auth_task_status/auth_apply_status;apply_status=4(认证通过)回写 verify_type_id=0", + "isNeedAuth": false, + "isNeedLogin": true, + "headers": [ + { + "name": "Authorization", + "type": "string", + "required": true, + "description": "Bearer token(正常登录 token,携带仓库上下文)" + } + ], + "params": [ + { + "name": "taskid", + "type": "string", + "required": false, + "source": "body", + "description": "认证任务 id(发起认证接口 wxa/sec/wxaapi/wxaauth 返回);可选,缺省时使用库中 auth_task_id;小程序已认证时无需传入" + } + ], + "response": [ + { + "name": "is_verified", + "type": "boolean", + "required": true, + "description": "是否已认证:true 已认证(返回 verify_type_id/principal_name/signature 等本地认证信息,不调微信);false 未认证(附带 task_status/apply_status 进度)" + }, + { + "name": "verify_type_id", + "type": "number", + "required": false, + "description": "认证类型(仅已认证返回):0 微信认证、1 新浪微博、3 资质通过未名称认证、4 同3+微博;附 verify_type_text 中文文案" + }, + { + "name": "principal_name", + "type": "string", + "required": false, + "description": "认证主体名称(仅已认证返回)" + }, + { + "name": "task_status", + "type": "number", + "required": false, + "description": "任务流程状态(仅未认证且有任务时返回):0 初始、1 超时(24h)、2 授权拒绝、3 授权同意、4 发起人脸、5 人脸失败、6 人脸ok、7 已发验证码、8 手机验证失败、9 手机验证成功、11 创建审核单失败、12 创建审核单成功、14 验证失败、15 等待支付" + }, + { + "name": "apply_status", + "type": "number", + "required": false, + "description": "审核单状态:0 不存在、1 待支付、2 审核中、3 打回重填、4 认证通过(回写 verify_type_id=0)、5 最终失败" + }, + { + "name": "orderid", + "type": "number", + "required": false, + "description": "认证订单号" + }, + { + "name": "auth_url", + "type": "string", + "required": false, + "description": "小程序管理员授权链接" + } + ], + "errors": [ + { + "code": "400", + "message": "未识别仓库/未授权小程序/查询失败(微信 errcode 透传)" + } + ] + }, + { + "method": "wechat.wxaauth", + "description": "发起小程序认证(需登录,后端分步):前端把材料图片上传 COS 后传文件 URL,后端下载图片 → POST /wxa/sec/wxaapi/uploadmedia 换 media_id → 替换请求体 → POST /wxa/sec/wxaapi/wxaauth(authorizer_access_token,权限集 18)一步提交;成功回写 wms_wechat_app.auth_task_id/auth_apply_status,返回 taskid(供 wechat.queryauth 查进度)与 auth_url;小程序已认证时拒绝重复发起", + "isNeedAuth": false, + "isNeedLogin": true, + "headers": [ + { + "name": "Authorization", + "type": "string", + "required": true, + "description": "Bearer token(正常登录 token,携带仓库上下文)" + } + ], + "params": [ + { + "name": "contact_type", + "type": "number", + "required": true, + "source": "body", + "description": "联系人类型:1 法人、2 管理员" + }, + { + "name": "contact_name", + "type": "string", + "required": true, + "source": "body", + "description": "联系人姓名" + }, + { + "name": "其他字段", + "type": "object", + "required": false, + "source": "body", + "description": "白名单透传微信 wxaauth 请求体:contact_idcard_number/contact_mobile/contact_cert_photo/contact_nationality/contact_address/contact_email、business_license_copy/business_license_number/business_license_address/business_license_expiration_date、legal_persona_media/legal_persona_idcard_copy/legal_persona_name/legal_persona_idcard_number/legal_persona_address/legal_persona_idcard_expiration_date、business_license_type/apply_type/extra_wxa_secure_info/nickname、pic_list/qualification_list/qualification_extra/license_list/statement_list、store_name/store_main_industry/store_scale/store_floor/store_address/open_type/pay_type。图片字段(contact_cert_photo/business_license_copy/legal_persona_idcard_copy/legal_persona_media、pic_list 项的 pic_url、qualification_list 项 licence_list/certificate_list 的 value、statement_list 项的 value)支持传 COS 文件 URL(http/https),后端自动下载并换 media_id;传非 URL 时视为已传 media_id 原样透传" + } + ], + "response": [ + { + "name": "taskid", + "type": "string", + "required": true, + "description": "认证任务 ID(已回写 auth_task_id,供 queryauth 查询进度)" + }, + { + "name": "auth_url", + "type": "string", + "required": false, + "description": "小程序管理员认证链接" + }, + { + "name": "apply_status", + "type": "number", + "required": false, + "description": "审核单状态(0 不存在、1 待支付、2 审核中)" + } + ], + "errors": [ + { + "code": "400", + "message": "未识别仓库/未授权小程序/已认证/未授权权限集 18/缺少 contact_type 或 contact_name/微信失败(errcode 透传)" + } + ] + }, + { + "method": "wechat.getAuthorizerInfo", + "description": "获取并同步当前仓库小程序基础信息(需登录):调微信 POST /cgi-bin/component/api_get_authorizer_info(component_access_token)拉取授权账号详情(authorizer_info + authorization_info),将昵称/头像/原始ID/主体名称/签名/认证类型/账号状态/权限集等落库 wms_wechat_app 后返回完整数据;认证进度请用 wechat.queryauth", + "isNeedAuth": false, + "isNeedLogin": true, + "headers": [ + { + "name": "Authorization", + "type": "string", + "required": true, + "description": "Bearer token(正常登录 token,携带仓库上下文)" + } + ], + "params": [], + "response": [ + { + "name": "appid", + "type": "string", + "required": true, + "description": "当前仓库小程序 AppID" + }, + { + "name": "authorizer_info", + "type": "object", + "required": true, + "description": "授权账号基本信息:nick_name、head_img、user_name、principal_name、signature、alias、qrcode_url、service_type_info(id)、verify_type_info(id:-1 未认证/0 微信认证)、account_status、register_type、business_info、MiniProgramInfo(network/categories/visit_status)" + }, + { + "name": "authorization_info", + "type": "object", + "required": false, + "description": "授权信息:authorizer_appid、func_info(权限集列表)、authorizer_refresh_token(有 API 权限时返回,同步更新落库)" + } + ], + "errors": [ + { + "code": "400", + "message": "未识别仓库/当前仓库未授权小程序/微信接口失败(errcode 透传)" + }, + { + "code": "401", + "message": "未登录" + } + ] + }, + { + "method": "wechat.registerMiniprogram", + "description": "快速注册企业小程序(需登录):调微信 fastregisterweapp?action=create(component_access_token),提交企业信息创建注册任务,法人微信收到模板消息做人脸核身;审核结果通过 notify_third_fasteregister 事件推送到授权事件接收 URL", + "isNeedAuth": false, + "isNeedLogin": true, + "headers": [ + { + "name": "Authorization", + "type": "string", + "required": true, + "description": "Bearer token(正常登录 token)" + } + ], + "params": [ + { + "name": "name", + "type": "string", + "required": true, + "source": "body", + "description": "企业名(与工商登记一致;无主体名称个体工商户填「个体户+法人姓名」)" + }, + { + "name": "code", + "type": "string", + "required": true, + "source": "body", + "description": "企业代码" + }, + { + "name": "code_type", + "type": "number", + "required": true, + "source": "body", + "description": "企业代码类型:1 统一社会信用代码(18位)、2 组织机构代码(9位)、3 营业执照注册号(15位)" + }, + { + "name": "legal_persona_wechat", + "type": "string", + "required": true, + "source": "body", + "description": "法人微信号(不支持手机号/微信名)" + }, + { + "name": "legal_persona_name", + "type": "string", + "required": true, + "source": "body", + "description": "法人姓名(绑定银行卡)" + }, + { + "name": "component_phone", + "type": "string", + "required": false, + "source": "body", + "description": "第三方联系电话" + } + ], + "response": [ + { + "name": "errcode", + "type": "number", + "required": true, + "description": "0 成功" + }, + { + "name": "errmsg", + "type": "string", + "required": true, + "description": "错误信息" + } + ], + "errors": [ + { + "code": "400", + "message": "缺少必填参数/code_type 非法/注册失败(61070 法人姓名与微信号不一致、86004 无效微信号、89248 企业代码类型无效、91030 法人微信号每日调用超限等)" + } + ] + }, + { + "method": "wechat.updateInfo", + "description": "更新微信账号资料(微信登录态中间层,仅未绑定真实用户的微信账号):小程序端未绑定账号时更新自己的昵称/头像(nickname ≤255 字符、headimgurl ≤500 字符,可部分更新),已绑定账号不支持修改", + "isNeedAuth": false, + "isNeedLogin": true, + "headers": [ + { + "name": "Authorization", + "type": "string", + "required": true, + "description": "Bearer token(微信登录态 token,payload 含 oauth_id)" + } + ], + "params": [ + { + "name": "nickname", + "type": "string", + "required": false, + "source": "body", + "description": "昵称(≤255 字符)" + }, + { + "name": "headimgurl", + "type": "string", + "required": false, + "source": "body", + "description": "头像 URL(≤500 字符)" + } + ], + "response": [ + { + "name": "oauth_id", + "type": "number", + "required": true, + "description": "wms_user_oauth.id" + }, + { + "name": "nickname", + "type": "string", + "required": true, + "description": "更新后的昵称" + }, + { + "name": "headimgurl", + "type": "string", + "required": true, + "description": "更新后的头像 URL" + } + ], + "errors": [ + { + "code": "400", + "message": "缺少待更新字段/字段超长/账号已绑定不支持修改" + }, + { + "code": "401", + "message": "微信登录态不存在" + } + ] + }, + { + "method": "wechat.uploadHeadimg", + "description": "上传微信账号头像(微信登录态中间层,至少微信登录即可,未绑定也可):前端裁剪后以 base64 上传(data URL 或裸 base64),限制仅 PNG、大小小于 500K;校验 PNG 文件头魔数后经 COS 上传(key=headimg/wechat/{yyyymmdd}/{timestamp}{random}.png),并回写 wms_user_oauth.headimgurl,返回 URL", + "isNeedAuth": false, + "isNeedLogin": true, + "headers": [ + { + "name": "Authorization", + "type": "string", + "required": true, + "description": "Bearer token(微信登录态 token,payload 含 oauth_id)" + } + ], + "params": [ + { + "name": "image", + "type": "string", + "required": true, + "source": "body", + "description": "裁剪后的 PNG 图片 base64(支持 data:image/png;base64, 前缀,≤500K)" + } + ], + "response": [ + { + "name": "oauth_id", + "type": "number", + "required": true, + "description": "wms_user_oauth.id" + }, + { + "name": "url", + "type": "string", + "required": true, + "description": "上传后的头像 URL(同 headimgurl)" + }, + { + "name": "headimgurl", + "type": "string", + "required": true, + "description": "回写后的头像 URL" + } + ], + "errors": [ + { + "code": "400", + "message": "缺少 image 参数/图片数据解析失败/超过 500K/非 PNG 格式" + }, + { + "code": "401", + "message": "微信登录态不存在" + } + ] + }, + { + "method": "wechat.getMyLoginCode", + "description": "获取当前微信登录用户的登录码(至少微信登录态):wms_user_oauth 无 login_code 时生成(uuid={id}_{6位随机}、form=wechat 的 JSON base64)并写入,已有则直接返回", + "isNeedAuth": false, + "isNeedLogin": true, + "headers": [ + { + "name": "Authorization", + "type": "string", + "required": true, + "description": "Bearer token(微信登录态,JWT 含 oauth_id)" + } + ], + "params": [] + }, + { + "method": "wechat.getTemplateList", + "description": "获取小程序模板库列表(需登录):只拉取普通模板(template_type=0,GET wxa/gettemplatelist + component_access_token),Redis 缓存 24h(key wechat:template:list:normal);有缓存直接返回(from_cache=true),无缓存拉取后写入缓存", + "isNeedAuth": false, + "isNeedLogin": true, + "headers": [ + { + "name": "Authorization", + "type": "string", + "required": true, + "description": "Bearer token(正常登录 token)" + } + ], + "params": [], + "response": [ + { + "name": "list", + "type": "array", + "required": true, + "description": "模板信息列表(create_time/user_version/user_desc/template_id/draft_id/source_miniprogram_appid/source_miniprogram/template_type 等)" + }, + { + "name": "from_cache", + "type": "boolean", + "required": true, + "description": "是否来自缓存" + } + ], + "errors": [ + { + "code": "400", + "message": "获取模板列表失败(微信 errcode/errmsg 透传)" + } + ] + }, + { + "method": "wechat.commit", + "description": "上传代码并生成体验版(需登录):取当前仓库启用小程序,校验授权权限集 18,从普通模板库取模板(校验存在)并直接取模板的 user_version/user_desc 作为版本号与代码描述;ext_json 由后端默认生成({extEnable:true,extAppid:小程序appid},前端不传),调微信 POST wxa/commit(authorizer_access_token)上传代码,成功后回写 wms_wechat_app.template_id/user_version", + "isNeedAuth": false, + "isNeedLogin": true, + "headers": [ + { + "name": "Authorization", + "type": "string", + "required": true, + "description": "Bearer token(正常登录 token,携带仓库上下文)" + } + ], + "params": [ + { + "name": "template_id", + "type": "number", + "required": true, + "source": "body", + "description": "代码库中的代码模板 ID(getTemplateList 获取)" + } + ], + "response": [ + { + "name": "appid", + "type": "string", + "required": true, + "description": "小程序 AppID" + }, + { + "name": "template_id", + "type": "number", + "required": true, + "description": "已上传的模板 ID(同时回写 wms_wechat_app.template_id)" + }, + { + "name": "user_version", + "type": "string", + "required": true, + "description": "上传使用的版本号(取自模板库,同时回写 wms_wechat_app.user_version)" + }, + { + "name": "user_desc", + "type": "string", + "required": true, + "description": "上传使用的代码描述(取自模板库)" + }, + { + "name": "ext_json", + "type": "string", + "required": true, + "description": "后端生成的 ext.json({\"extEnable\":true,\"extAppid\":\"小程序appid\"})" + } + ], + "errors": [ + { + "code": "400", + "message": "未识别仓库/未授权小程序/未授权权限集 18/模板不存在或缺少版本号/代码描述/上传失败(微信 errcode 透传:85014 模板不存在、9402202 并发限制等)" + } + ] + }, + { + "method": "wechat.getTrialQRCode", + "description": "获取体验版二维码(需登录):取当前仓库启用小程序,校验授权权限集 18/86,调微信 GET wxa/get_qrcode(authorizer_access_token,path 可选自动 urlencode)获取二维码图片(jpeg),转存 COS 后返回 URL", + "isNeedAuth": false, + "isNeedLogin": true, + "headers": [ + { + "name": "Authorization", + "type": "string", + "required": true, + "description": "Bearer token(正常登录 token,携带仓库上下文)" + } + ], + "params": [ + { + "name": "path", + "type": "string", + "required": false, + "source": "body", + "description": "扫码后进入的页面路径(可选,如 page/index?action=1,自动 urlencode)" + } + ], + "response": [ + { + "name": "appid", + "type": "string", + "required": true, + "description": "小程序 AppID" + }, + { + "name": "url", + "type": "string", + "required": true, + "description": "二维码图片 URL(COS)" + } + ], + "errors": [ + { + "code": "400", + "message": "未识别仓库/未授权小程序/未授权权限集 18或86/获取失败(微信 errcode 透传)" + } + ] + }, + { + "method": "wechat.submitAudit", + "description": "提交代码审核(需登录):取当前仓库启用小程序,校验权限集 18;仅 audit_status!=1(无审核中的版本)时允许提交,调微信 POST wxa/submit_audit(authorizer_access_token),成功后记录 audit_status=1 与 audit_id;审核结果由 weapp_audit_success/weapp_audit_fail 事件回写状态(2 通过/3 驳回+原因)", + "isNeedAuth": false, + "isNeedLogin": true, + "headers": [ + { + "name": "Authorization", + "type": "string", + "required": true, + "description": "Bearer token(正常登录 token,携带仓库上下文)" + } + ], + "params": [ + { + "name": "item_list", + "type": "array", + "required": false, + "source": "body", + "description": "审核项列表(可选,含 address/tag/first_class 等类目信息)" + }, + { + "name": "version_desc", + "type": "string", + "required": false, + "source": "body", + "description": "版本描述(可选)" + }, + { + "name": "privacy_api_not_use", + "type": "boolean", + "required": false, + "source": "body", + "description": "不使用地理位置接口声明(可选)" + } + ], + "response": [ + { + "name": "appid", + "type": "string", + "required": true, + "description": "小程序 AppID" + }, + { + "name": "auditid", + "type": "number", + "required": true, + "description": "微信审核单 ID(同时回写 wms_wechat_app.audit_id)" + } + ], + "errors": [ + { + "code": "400", + "message": "未识别仓库/未授权小程序/未授权权限集 18/已有审核中的版本/提交失败(微信 errcode 透传:61039 检测未完成、85074 审核中勿重复提交等)" + } + ] + }, + { + "method": "wechat.userList", + "description": "拉取当前仓库小程序(wms_wechat_app)的用户列表(wms_user_oauth,需登录):按 ctx.user.store_id 取仓库启用小程序(可选 app_id 指定单个,须属于当前仓库),支持 where(operator 结构)、pagination(page/pageSize)、sort(sortField/sortOrder);响应排除 session_key/access_token/refresh_token 等敏感字段,附 is_bound(user_id>0 已绑定真实账号)", + "isNeedAuth": false, + "isNeedLogin": true, + "headers": [ + { + "name": "Authorization", + "type": "string", + "required": true, + "description": "Bearer token(正常登录 token,携带仓库上下文)" + } + ], + "params": [ + { + "name": "app_id", + "type": "number", + "required": false, + "source": "body", + "description": "指定 wms_wechat_app.id(可选,须属于当前仓库且启用;缺省取当前仓库全部启用小程序)" + }, + { + "name": "where", + "type": "object", + "required": false, + "source": "body", + "description": "查询条件(字段白名单:id/user_id/app_id/openid/unionid/nickname/sex/login_time/login_count/created_at/updated_at;条件值结构 { operator, value },operator 支持 eq/ne/gt/lt/ge/le/in/notin/between/like/contains/notlike/startswith/endswith/isnull/isnotnull)" + }, + { + "name": "pagination", + "type": "object", + "required": false, + "source": "body", + "description": "分页参数 { page, pageSize },默认 page=1、pageSize=20" + }, + { + "name": "sort", + "type": "object", + "required": false, + "source": "body", + "description": "排序参数 { sortField, sortOrder },sortField 白名单 id/user_id/app_id/openid/unionid/nickname/sex/login_time/login_count/created_at/updated_at,默认 updated_at DESC" + } + ], + "response": [ + { + "name": "list", + "type": "array", + "required": true, + "description": "用户列表(id/user_id/app_id/openid/unionid/nickname/sex/headimgurl/login_time/login_count/is_bound/created_at/updated_at)" + }, + { + "name": "pagination", + "type": "object", + "required": true, + "description": "分页信息 { page, pageSize, total }" + }, + { + "name": "apps", + "type": "array", + "required": false, + "description": "本次查询命中的小程序列表(id/appid/nickname)" + } + ], + "errors": [ + { + "code": "400", + "message": "未识别到当前仓库/当前仓库未授权小程序/指定小程序不属于当前仓库或已停用/where 参数解析失败" + } + ] } ] }