liufumingren 7b11f7052d feat(subject): 主体到期暂停设备上报,新增续期订单与支付回调
- 主体状态缓存(Redis 优先、进程内兜底):设备心跳与上报判断不再查库,续期/停用后主动失效
- 上报写接口按缓存校验期限:过期 403 subject_expired、停用 subject_disabled、主体缺失 subject_missing
- 心跳与 /api/scanner/me 返回 subject 状态,桌面端据此暂停推送并在续期后自动补传积压
- 新增续期订单(subject_orders)与接口,支付回调 POST /api/pay/notify 幂等、支持 HMAC 签名,
  另提供内部令牌模拟支付用于联调
- 顺带提交工作区中已完成的「登录协议」后端改动(agreement):与本次改动共用 router.js / config.default.js

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-10-20 18:55:57 +08:00

27 lines
802 B
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

'use strict';
const { Controller } = require('egg');
/**
* 运维/内部:模拟支付成功(`POST /api/internal/subject-orders/:orderNo/pay`)
*
* 需要内部令牌(`middleware/internalAuth()`),不需要渠道签名;
* 与真实回调走同一个 `service.subjectOrder.payNotify()`,所以续期结果完全一致。
*/
class InternalSubjectOrderController extends Controller {
async pay() {
const { ctx } = this;
const orderNo = String(ctx.params.orderNo || '').trim();
if (!orderNo) ctx.throw(400, 'orderNo 不能为空');
const data = await ctx.service.subjectOrder.payNotify({
orderNo,
transactionId: `MOCK-${Date.now()}`,
channel: 'mock',
});
ctx.body = { ok: true, data };
}
}
module.exports = InternalSubjectOrderController;