@be-link/pos-cli-nodejs 1.0.236 → 1.0.237

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@be-link/pos-cli-nodejs",
3
- "version": "1.0.236",
3
+ "version": "1.0.237",
4
4
  "description": "正向订单服务Nodejs客户端",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/pos/http.test.js CHANGED
@@ -1,4 +1,27 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
26
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
27
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -69,3 +92,11 @@ describe('callApi error envelope', () => {
69
92
  expect(error).toMatchObject({ code: 503 });
70
93
  }));
71
94
  });
95
+ it('高龄拦截码与可供旧客户端展示的完整恢复文案透传', () => __awaiter(void 0, void 0, void 0, function* () {
96
+ const { SENIOR_CONFIRMATION_REQUIRED, SENIOR_CONFIRMATION_RECOVERY_MESSAGE } = yield Promise.resolve().then(() => __importStar(require('./modules/orderCore/seniorConfirmationRecovery')));
97
+ jest.spyOn(console, 'error').mockImplementation(() => undefined);
98
+ mockPost.mockRejectedValue({ message: 'Request failed', response: { status: 400, data: { message: SENIOR_CONFIRMATION_RECOVERY_MESSAGE, code: SENIOR_CONFIRMATION_REQUIRED } } });
99
+ const error = yield (0, http_1.callApi)('https://pos.test/core/accept', {}).catch(caught => caught);
100
+ expect(error).toMatchObject({ code: SENIOR_CONFIRMATION_REQUIRED, message: SENIOR_CONFIRMATION_RECOVERY_MESSAGE, statusCode: 400 });
101
+ jest.restoreAllMocks();
102
+ }));
@@ -0,0 +1,2 @@
1
+ export declare const SENIOR_CONFIRMATION_REQUIRED = "SENIOR_CONFIRMATION_REQUIRED";
2
+ export declare const SENIOR_CONFIRMATION_RECOVERY_MESSAGE = "\u8BA2\u5355\u5DF2\u4ED8\u6B3E\uFF0C\u9700\u5B8C\u6210\u9AD8\u9F84\u51FA\u884C\u4EBA\u5065\u5EB7\u53CA\u514D\u8D23\u786E\u8BA4\u540E\u65B9\u53EF\u63A5\u5355\u3002\u8BF7\u5728\u8BA2\u5355\u8BE6\u60C5\u7EE7\u7EED\u786E\u8BA4\uFF1B\u5982\u65E0\u786E\u8BA4\u5165\u53E3\uFF0C\u8BF7\u66F4\u65B0\u6216\u91CD\u65B0\u6253\u5F00\u5C0F\u7A0B\u5E8F\uFF0C\u518D\u5230\u201C\u6211\u7684\u8BA2\u5355\u201D\u627E\u5230\u672C\u5355\u3002\u6682\u65F6\u65E0\u6CD5\u66F4\u65B0\u8BF7\u8054\u7CFB\u5BA2\u670D\uFF0C\u8BA2\u5355\u4FDD\u7559\u5F85\u786E\u8BA4\uFF0C\u8BF7\u52FF\u91CD\u590D\u4ED8\u6B3E\u3002";
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SENIOR_CONFIRMATION_RECOVERY_MESSAGE = exports.SENIOR_CONFIRMATION_REQUIRED = void 0;
4
+ // Stable code; keep the message readable for clients that only display msg/message.
5
+ exports.SENIOR_CONFIRMATION_REQUIRED = 'SENIOR_CONFIRMATION_REQUIRED';
6
+ exports.SENIOR_CONFIRMATION_RECOVERY_MESSAGE = '订单已付款,需完成高龄出行人健康及免责确认后方可接单。请在订单详情继续确认;如无确认入口,请更新或重新打开小程序,再到“我的订单”找到本单。暂时无法更新请联系客服,订单保留待确认,请勿重复付款。';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ jest.mock('../../http', () => ({ callApi: jest.fn() }));
16
+ const http_1 = require("../../http");
17
+ const service_1 = __importDefault(require("./service"));
18
+ it('确认记录两个接口保持完整请求和 kebab-case 路由', () => __awaiter(void 0, void 0, void 0, function* () {
19
+ const prepare = { version: 'V1', orderRequest: { tourismInfo: { touristIdList: ['senior'] } } };
20
+ yield service_1.default.prepareSeniorDisclaimer(prepare);
21
+ expect(http_1.callApi).toHaveBeenCalledWith(expect.stringMatching(/\/core\/prepare-senior-disclaimer$/), prepare);
22
+ const accept = { recordId: 'record-A', unionId: 'buyer-A' };
23
+ yield service_1.default.acceptSeniorDisclaimer(accept);
24
+ expect(http_1.callApi).toHaveBeenCalledWith(expect.stringMatching(/\/core\/accept-senior-disclaimer$/), accept);
25
+ }));
26
+ for (const [name, route] of [
27
+ ['getSeniorConfirmation', 'get-senior-confirmation'],
28
+ ['saveSeniorHealthDraft', 'save-senior-health-draft'],
29
+ ['markSeniorConfirmationRead', 'mark-senior-confirmation-read'],
30
+ ['acceptSeniorConfirmation', 'accept-senior-confirmation'],
31
+ ]) {
32
+ it(name + ' preserves request and route', () => __awaiter(void 0, void 0, void 0, function* () {
33
+ const request = { orderId: 'order-A', unionId: 'buyer-A', sessionId: 'session-A', touristId: 'person-A' };
34
+ yield service_1.default[name](request);
35
+ expect(http_1.callApi).toHaveBeenLastCalledWith(expect.stringMatching(new RegExp('/core/' + route + '$')), request);
36
+ }));
37
+ }
38
+ it('START的服务端正文及版本保持透传,不只保留token', () => __awaiter(void 0, void 0, void 0, function* () {
39
+ const reply = { readToken: 'reading-token', readText: '合成协议正文', documentVersion: 'approved-version' };
40
+ http_1.callApi.mockResolvedValue(reply);
41
+ const result = yield service_1.default.markSeniorConfirmationRead({ orderId: 'order-A', unionId: 'buyer-A', sessionId: 'session-A', touristId: 'person-A', kind: 'HEALTH', phase: 'START' });
42
+ expect(result).toEqual(reply);
43
+ }));
@@ -1,8 +1,18 @@
1
- import { Service } from './types';
1
+ import { Service, SeniorDisclaimerPreparation, SeniorConfirmationState } from './types';
2
2
  import BaseService from '../service';
3
3
  import { IPositiveOrderInvoice } from '../../../types';
4
4
  declare class OrderCoreService extends BaseService implements Service.OrderCoreController {
5
5
  protected prefixUrl: string;
6
+ getSeniorConfirmation(request: Service.Request.getSeniorConfirmation): Promise<SeniorConfirmationState>;
7
+ saveSeniorHealthDraft(request: Service.Request.saveSeniorHealthDraft): Promise<void>;
8
+ markSeniorConfirmationRead(request: Service.Request.markSeniorConfirmationRead): Promise<{
9
+ readToken: string;
10
+ }>;
11
+ acceptSeniorConfirmation(request: Service.Request.acceptSeniorConfirmation): Promise<void>;
12
+ prepareSeniorDisclaimer(request: Service.Request.prepareSeniorDisclaimer): Promise<SeniorDisclaimerPreparation>;
13
+ acceptSeniorDisclaimer(request: Service.Request.acceptSeniorDisclaimer): Promise<{
14
+ recordId: string;
15
+ }>;
6
16
  orderFulfill(request: Service.Request.orderFulfill): Promise<void>;
7
17
  updateOrderInvoice(request: IPositiveOrderInvoice): Promise<string>;
8
18
  orderCreateInvoice(request: IPositiveOrderInvoice): Promise<IPositiveOrderInvoice>;
@@ -10,6 +10,24 @@ class OrderCoreService extends service_1.default {
10
10
  super(...arguments);
11
11
  this.prefixUrl = '/core';
12
12
  }
13
+ getSeniorConfirmation(request) {
14
+ return (0, http_1.callApi)(this.getApiUrl(this.getSeniorConfirmation), request);
15
+ }
16
+ saveSeniorHealthDraft(request) {
17
+ return (0, http_1.callApi)(this.getApiUrl(this.saveSeniorHealthDraft), request);
18
+ }
19
+ markSeniorConfirmationRead(request) {
20
+ return (0, http_1.callApi)(this.getApiUrl(this.markSeniorConfirmationRead), request);
21
+ }
22
+ acceptSeniorConfirmation(request) {
23
+ return (0, http_1.callApi)(this.getApiUrl(this.acceptSeniorConfirmation), request);
24
+ }
25
+ prepareSeniorDisclaimer(request) {
26
+ return (0, http_1.callApi)(this.getApiUrl(this.prepareSeniorDisclaimer), request);
27
+ }
28
+ acceptSeniorDisclaimer(request) {
29
+ return (0, http_1.callApi)(this.getApiUrl(this.acceptSeniorDisclaimer), request);
30
+ }
13
31
  orderFulfill(request) {
14
32
  return (0, http_1.callApi)(this.getApiUrl(this.orderFulfill), request);
15
33
  }
@@ -1,8 +1,121 @@
1
1
  import * as PosConstants from 'vitality-meta/enums/pos';
2
2
  import * as DTO from '../../../types';
3
3
  export type RescheduleSource = 'WEB' | 'BIZ_FLOW' | 'ORDER_CHANGE';
4
+ export interface SeniorDisclaimerTourist {
5
+ id: string;
6
+ name: string;
7
+ age: number;
8
+ maskedIdCard: string;
9
+ }
10
+ export interface SeniorDisclaimerPreparation {
11
+ required: boolean;
12
+ accepted?: boolean;
13
+ recordId?: string;
14
+ title?: string;
15
+ content?: string;
16
+ contentHash?: string;
17
+ agreementVersion?: string;
18
+ minimumReadSeconds?: number;
19
+ tourists?: SeniorDisclaimerTourist[];
20
+ departureDate?: string;
21
+ itemName?: string;
22
+ }
23
+ export interface SeniorHealthAnswers {
24
+ emergencyContact: {
25
+ name: string;
26
+ relationship: string;
27
+ phone: string;
28
+ nonTraveler: boolean;
29
+ };
30
+ diseaseGroup1: string[];
31
+ diseaseGroup2: string[];
32
+ allergyDetails: string;
33
+ otherDetails: string;
34
+ recentDiscomfort: string;
35
+ regularMedication: string;
36
+ mobility: string;
37
+ canAdapt: string;
38
+ }
39
+ export interface SeniorConfirmationPerson extends SeniorDisclaimerTourist {
40
+ gender: string;
41
+ mobile: string;
42
+ birthday: string;
43
+ }
44
+ export interface SeniorHealthProgress {
45
+ touristId: string;
46
+ answers: SeniorHealthAnswers | null;
47
+ confirmedAt: number | null;
48
+ disclaimerConfirmedAt: number | null;
49
+ disclaimerText?: string;
50
+ }
51
+ export interface SeniorConfirmationState {
52
+ required: boolean;
53
+ paid: boolean;
54
+ completed: boolean;
55
+ orderId: string;
56
+ sessionId?: string;
57
+ stateLabel?: string;
58
+ itemName?: string;
59
+ departureDate?: string;
60
+ returnDate?: string;
61
+ tourists?: SeniorConfirmationPerson[];
62
+ healthRecords?: SeniorHealthProgress[];
63
+ relationships?: Record<string, string>;
64
+ documents?: {
65
+ version: string;
66
+ notice: string;
67
+ confirmationText: string;
68
+ healthConfirmationText: string;
69
+ healthText: string;
70
+ disclaimerText: string;
71
+ diseaseGroups: Array<Array<{
72
+ id: string;
73
+ label: string;
74
+ }>>;
75
+ questions: Array<{
76
+ key: string;
77
+ label: string;
78
+ options: Array<{
79
+ value: string;
80
+ label: string;
81
+ }>;
82
+ }>;
83
+ };
84
+ }
4
85
  export declare namespace Service {
5
86
  namespace Request {
87
+ interface getSeniorConfirmation {
88
+ orderId: string;
89
+ unionId: string;
90
+ }
91
+ interface saveSeniorHealthDraft extends getSeniorConfirmation {
92
+ sessionId: string;
93
+ touristId: string;
94
+ answers: SeniorHealthAnswers;
95
+ }
96
+ interface markSeniorConfirmationRead extends getSeniorConfirmation {
97
+ sessionId: string;
98
+ kind: 'HEALTH' | 'DISCLAIMER';
99
+ touristId: string;
100
+ phase: 'START' | 'BOTTOM';
101
+ readToken?: string;
102
+ answers?: SeniorHealthAnswers;
103
+ relationships?: Record<string, string>;
104
+ }
105
+ interface acceptSeniorConfirmation extends getSeniorConfirmation {
106
+ sessionId: string;
107
+ kind: 'HEALTH' | 'DISCLAIMER';
108
+ touristId: string;
109
+ readToken: string;
110
+ }
111
+ interface prepareSeniorDisclaimer {
112
+ version: 'V1' | 'V2';
113
+ orderRequest: orderCreate | orderCreateV2;
114
+ }
115
+ interface acceptSeniorDisclaimer {
116
+ recordId: string;
117
+ unionId: string;
118
+ }
6
119
  interface createOrderInvoice {
7
120
  /** 快照:订单ID */
8
121
  tradeOrderId?: string;
@@ -33,6 +146,7 @@ export declare namespace Service {
33
146
  };
34
147
  }
35
148
  interface orderCreate {
149
+ seniorDisclaimerRecordId?: string;
36
150
  /** 基础信息 */
37
151
  basicInfo: {
38
152
  /** 用户id */
@@ -126,6 +240,7 @@ export declare namespace Service {
126
240
  storeAdjustmentReason?: string;
127
241
  }
128
242
  interface orderCreateV2 {
243
+ seniorDisclaimerRecordId?: string;
129
244
  /** 基础信息 */
130
245
  basicInfo: {
131
246
  /** 用户id */
@@ -534,6 +649,18 @@ export declare namespace Service {
534
649
  }[];
535
650
  }
536
651
  interface OrderCoreController {
652
+ getSeniorConfirmation(request: Request.getSeniorConfirmation): Promise<SeniorConfirmationState>;
653
+ saveSeniorHealthDraft(request: Request.saveSeniorHealthDraft): Promise<void>;
654
+ markSeniorConfirmationRead(request: Request.markSeniorConfirmationRead): Promise<{
655
+ readToken: string;
656
+ readText?: string;
657
+ documentVersion?: string;
658
+ }>;
659
+ acceptSeniorConfirmation(request: Request.acceptSeniorConfirmation): Promise<void>;
660
+ prepareSeniorDisclaimer(request: Request.prepareSeniorDisclaimer): Promise<SeniorDisclaimerPreparation>;
661
+ acceptSeniorDisclaimer(request: Request.acceptSeniorDisclaimer): Promise<{
662
+ recordId: string;
663
+ }>;
537
664
  /**
538
665
  * 订单发票修改
539
666
  * @path /core/update-order-invoice