docs(api): 同步微信模块 system.json 接口文档与变更记录(wechat.* 系列方法)
This commit is contained in:
parent
68a7e1b17d
commit
fa112891a9
@ -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",
|
||||
|
||||
1013
methods/system.json
1013
methods/system.json
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user