@tbox.cn/app-provider-mock 0.2.0 → 0.4.0

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.
@@ -2,7 +2,9 @@
2
2
  * Mock parking 实现(provider-mock 自持——R3-1 裁决)。演示面最小集:报价/车辆/记录/
3
3
  * 综合信息/权益/寻车 + 三步支付链 mock 闭环(reconcile 恒 PAID 收口)。demo ref 恒
4
4
  * `demo:` 前缀,厂商中立;车牌未提供时以演示车(demo-plate)兜底。
5
+ * config 消费:PARKING_CFG_DEFAULTS 为契约单源(fail-soft 快照;双锁测试 tests/config-schema.test.ts)。
5
6
  */
7
+ import { resolveConfig, type CfgDefaults } from './config';
6
8
  import type {
7
9
  ParkingBenefit,
8
10
  ParkingInfo,
@@ -21,56 +23,83 @@ export type MockParkingService = ParkingQueryPort & ParkingPaymentPort & Parking
21
23
 
22
24
  const now = () => new Date().toISOString();
23
25
 
24
- /**
25
- * kind 必须下发:客户端按它分流(discount = 自动生效、不进勾选区;points = 积分入口),
26
- * 服务端 projectPaymentOptions 也只认 kind==='points'。缺省时整套分流静默失效——
27
- * 等级权益会退化成一个可勾选项,积分入口则从不出现。
28
- */
29
- const DEMO_BENEFITS: ParkingBenefit[] = [
30
- { benefitRef: 'demo:benefit:member-discount', title: '会员 95 折', description: 'mock 演示权益', kind: 'discount', autoSelected: true, estimatedDiscountCents: 75 },
31
- { benefitRef: 'demo:benefit:points-offset', title: '积分抵 5 元', description: 'mock 演示权益', kind: 'points', autoSelected: false, estimatedDiscountCents: 500, requiredPoints: 500, previewPayableCents: 1000 },
32
- ];
33
-
34
- function demoQuote(q: ParkingQueryContext, plateNo: string): QuoteSnapshot {
35
- return {
36
- quoteRef: `demo:quote:${plateNo}`,
37
- plateNo,
38
- mallId: q.scope.mallId ?? 'demo',
39
- entryAt: now(),
40
- feeItems: [{ name: '停车费(3 小时)', amountCents: 1500 }],
41
- totalCents: 1500,
42
- discountCents: 0,
43
- payableCents: 1500,
44
- appliedBenefits: [],
45
- revision: 1,
46
- paymentState: 'UNPAID',
47
- };
48
- }
26
+ /** config 契约单源(键集/缺省/整数约束;tests/config-schema.test.ts 双锁) */
27
+ export const PARKING_CFG_DEFAULTS = {
28
+ parkName: '示例停车场',
29
+ feeName: '停车费(3 小时)',
30
+ feeCents: 1500,
31
+ remainingSpaces: 128,
32
+ firstHourRate: '免费',
33
+ memberBenefitEnabled: true,
34
+ memberBenefitDiscountCents: 75,
35
+ pointsBenefitEnabled: true,
36
+ invoiceEnabled: true,
37
+ vehicleFloor: 'B1',
38
+ vehicleZone: 'A 区',
39
+ vehicleSpaceNo: 'A-128',
40
+ } as const satisfies CfgDefaults;
41
+ export const PARKING_CFG_INT_KEYS = ['feeCents', 'remainingSpaces', 'memberBenefitDiscountCents'];
49
42
 
50
43
  export class MockParkingServiceImpl implements MockParkingService {
51
44
  private vehicles = new Map<string, ParkingVehicle>();
52
- private records: ParkingPaymentRecord[] = [
53
- {
54
- recordRef: 'demo:record:1',
55
- plateNo: 'demo-plate',
56
- amountCents: 1500,
57
- paidAt: now(),
58
- status: 'PAID',
59
- parkName: '示例停车场',
60
- orderCompleted: true,
61
- },
62
- ];
63
-
64
- constructor(mallId = 'mall-demo') {
45
+ private records: ParkingPaymentRecord[];
46
+ /** 配置快照(fail-soft,构造期一次解析;键集 ≡ PARKING_CFG_DEFAULTS) */
47
+ private readonly cfg: typeof PARKING_CFG_DEFAULTS;
48
+
49
+ constructor(mallId = 'mall-demo', config: unknown = {}) {
65
50
  this.mallId = mallId;
66
51
  void this.mallId;
52
+ this.cfg = resolveConfig(config, PARKING_CFG_DEFAULTS, PARKING_CFG_INT_KEYS);
53
+ this.records = [
54
+ {
55
+ recordRef: 'demo:record:1',
56
+ plateNo: 'demo-plate',
57
+ amountCents: this.cfg.feeCents,
58
+ paidAt: now(),
59
+ status: 'PAID',
60
+ parkName: this.cfg.parkName,
61
+ orderCompleted: true,
62
+ },
63
+ ];
67
64
  }
68
65
 
69
66
  private mallId: string;
70
67
 
68
+ /**
69
+ * kind 必须下发:客户端按它分流(discount = 自动生效、不进勾选区;points = 积分入口),
70
+ * 服务端 projectPaymentOptions 也只认 kind==='points'。缺省时整套分流静默失效——
71
+ * 等级权益会退化成一个可勾选项,积分入口则从不出现。
72
+ */
73
+ private benefits(): ParkingBenefit[] {
74
+ const benefits: ParkingBenefit[] = [];
75
+ if (this.cfg.memberBenefitEnabled) {
76
+ benefits.push({ benefitRef: 'demo:benefit:member-discount', title: '会员 95 折', description: 'mock 演示权益', kind: 'discount', autoSelected: true, estimatedDiscountCents: this.cfg.memberBenefitDiscountCents });
77
+ }
78
+ if (this.cfg.pointsBenefitEnabled) {
79
+ benefits.push({ benefitRef: 'demo:benefit:points-offset', title: '积分抵 5 元', description: 'mock 演示权益', kind: 'points', autoSelected: false, estimatedDiscountCents: 500, requiredPoints: 500, previewPayableCents: 1000 });
80
+ }
81
+ return benefits;
82
+ }
83
+
84
+ private quote(q: ParkingQueryContext, plateNo: string): QuoteSnapshot {
85
+ return {
86
+ quoteRef: `demo:quote:${plateNo}`,
87
+ plateNo,
88
+ mallId: q.scope.mallId ?? 'demo',
89
+ entryAt: now(),
90
+ feeItems: [{ name: this.cfg.feeName, amountCents: this.cfg.feeCents }],
91
+ totalCents: this.cfg.feeCents,
92
+ discountCents: 0,
93
+ payableCents: this.cfg.feeCents,
94
+ appliedBenefits: [],
95
+ revision: 1,
96
+ paymentState: 'UNPAID',
97
+ };
98
+ }
99
+
71
100
  async queryFee(q: ParkingQueryContext, input: { plateNo?: string; vehicleRef?: string }): Promise<readonly QuoteSnapshot[]> {
72
101
  const plateNo = input.plateNo ?? (input.vehicleRef ? this.vehicles.get(input.vehicleRef)?.plateNo : undefined) ?? 'demo-plate';
73
- const quote = demoQuote(q, plateNo);
102
+ const quote = this.quote(q, plateNo);
74
103
  return quote ? [quote] : [];
75
104
  }
76
105
 
@@ -93,7 +122,7 @@ export class MockParkingServiceImpl implements MockParkingService {
93
122
  }
94
123
 
95
124
  async getInvoiceSettings(): Promise<{ parkingInvoiceEnabled: boolean }> {
96
- return { parkingInvoiceEnabled: true };
125
+ return { parkingInvoiceEnabled: this.cfg.invoiceEnabled };
97
126
  }
98
127
 
99
128
  async listInvoiceableOrders(_q: ParkingQueryContext, page: number, pageSize: number): Promise<ParkingRecordPage> {
@@ -105,21 +134,21 @@ export class MockParkingServiceImpl implements MockParkingService {
105
134
  async queryParkingInfo(_q: ParkingQueryContext, kind: ParkingInfo['kind']): Promise<ParkingInfo> {
106
135
  return {
107
136
  kind,
108
- title: '示例停车场',
137
+ title: this.cfg.parkName,
109
138
  entries: [
110
- { label: '剩余车位', value: '128' },
111
- { label: '首小时费率', value: '免费' },
112
- { label: '会员权益', value: '会员 95 折' },
139
+ { label: '剩余车位', value: String(this.cfg.remainingSpaces) },
140
+ { label: '首小时费率', value: this.cfg.firstHourRate },
141
+ { label: '会员权益', value: this.cfg.memberBenefitEnabled ? '会员 95 折' : '—' },
113
142
  ],
114
143
  };
115
144
  }
116
145
 
117
146
  async queryApplicableBenefits(_q: ParkingQueryContext, _plateNo: string): Promise<readonly ParkingBenefit[]> {
118
- return DEMO_BENEFITS;
147
+ return this.benefits();
119
148
  }
120
149
 
121
150
  async locateVehicle(_q: ParkingQueryContext, _plateNo: string): Promise<ParkingLocation | null> {
122
- return { floorName: 'B1', zoneName: 'A 区', spaceNo: 'A-128', walkingRoute: '电梯左转 50 米' };
151
+ return { floorName: this.cfg.vehicleFloor, zoneName: this.cfg.vehicleZone, spaceNo: this.cfg.vehicleSpaceNo, walkingRoute: '电梯左转 50 米' };
123
152
  }
124
153
 
125
154
  // ===== 支付三步链(mock:reconcile 恒 PAID 收口) =====
@@ -129,7 +158,7 @@ export class MockParkingServiceImpl implements MockParkingService {
129
158
  }
130
159
 
131
160
  async getOrderInfo(_q: ParkingQueryContext, _paymentRef: string): Promise<{ orderInfo?: string; channel: string; payableFeeCents: number | undefined }> {
132
- return { orderInfo: 'demo-order-info', channel: '50', payableFeeCents: 1500 };
161
+ return { orderInfo: 'demo-order-info', channel: '50', payableFeeCents: this.cfg.feeCents };
133
162
  }
134
163
 
135
164
  async getPaymentSign(_q: ParkingQueryContext, _paymentRef: string): Promise<{ orderInfo: string }> {
@@ -145,8 +174,8 @@ export class MockParkingServiceImpl implements MockParkingService {
145
174
  }
146
175
 
147
176
  async reprice(q: ParkingQueryContext, quoteRef: string, benefitRefs: readonly string[]): Promise<QuoteSnapshot> {
148
- const base = demoQuote(q, 'demo-plate');
149
- const discount = DEMO_BENEFITS.filter((b) => benefitRefs.includes(b.benefitRef))
177
+ const base = this.quote(q, 'demo-plate');
178
+ const discount = this.benefits().filter((b) => benefitRefs.includes(b.benefitRef))
150
179
  .reduce((sum, b) => sum + (b.estimatedDiscountCents ?? 0), 0);
151
180
  return {
152
181
  ...base,
@@ -1,7 +1,9 @@
1
1
  /**
2
2
  * Mock promotion 实现(provider-mock 自持——R3-1 裁决)。演示面最小集:搜索/精查/推荐/
3
3
  * 资产列表/活动列表/领取闭环(acquire 恒 SUCCEEDED)。demo ref 恒 `demo:` 前缀,厂商中立。
4
+ * config 消费:PROMOTION_CFG_DEFAULTS 为契约单源(fail-soft 快照;双锁测试 tests/config-schema.test.ts)。
4
5
  */
6
+ import { resolveConfig, type CfgDefaults } from './config';
5
7
  import type {
6
8
  PromotionOffer,
7
9
  PromotionOfferPage,
@@ -27,51 +29,16 @@ export type MockPromotionService = PromotionOfferQueryPort &
27
29
  const now = () => new Date().toISOString();
28
30
  const inDays = (d: number) => new Date(Date.now() + d * 86400_000).toISOString();
29
31
 
30
- const DEMO_OFFERS: PromotionOffer[] = [
31
- {
32
- offerRef: 'demo:coupon:1001',
33
- offerType: 'COUPON',
34
- title: '满 100 减 20 元券',
35
- subtitle: '全场通用(mock 演示)',
36
- tags: ['通用'],
37
- validity: { start: now(), end: inDays(30) },
38
- facets: [{ kind: 'COUPON', discountType: 'AMOUNT', value: 2000, thresholdCents: 10000 }],
39
- availability: { status: 'AVAILABLE', reasonCodes: [], evaluatedAt: now(), authoritative: false },
40
- participation: { mode: 'CLAIM_THEN_PURCHASE', steps: [{ title: '领取', description: '点击领取后自动存入卡包' }] },
41
- },
42
- {
43
- offerRef: 'demo:groupon:2001',
44
- offerType: 'GROUPON',
45
- title: '餐饮双人套餐 5 折',
46
- subtitle: 'mock 演示团购',
47
- tags: ['餐饮'],
48
- validity: { start: now(), end: inDays(15) },
49
- facets: [{ kind: 'GROUPON', requiredParticipants: 2 }],
50
- availability: { status: 'AVAILABLE', reasonCodes: [], evaluatedAt: now(), authoritative: false },
51
- participation: { mode: 'CLAIM_THEN_PURCHASE', steps: [{ title: '购买', description: '按团购价下单' }] },
52
- },
53
- ];
54
-
55
- const DEMO_ENTITLEMENTS: PromotionEntitlement[] = [
56
- {
57
- entitlementRef: 'demo:entitlement:1',
58
- offerRef: 'demo:coupon:1001',
59
- title: '满 100 减 20 元券',
60
- entitlementType: 'COUPON',
61
- status: 'EFFECTIVE',
62
- codeMasked: 'DEMO-****-1001',
63
- },
64
- ];
65
-
66
- const DEMO_ACTIVITIES: PromotionActivity[] = [
67
- {
68
- activityRef: 'demo:activity:3001',
69
- title: '示例商场周年庆',
70
- subtitle: 'mock 演示活动',
71
- registrationRequired: false,
72
- offerRefs: ['demo:coupon:1001'],
73
- },
74
- ];
32
+ /** config 契约单源(键集/缺省/整数约束;tests/config-schema.test.ts 双锁) */
33
+ export const PROMOTION_CFG_DEFAULTS = {
34
+ couponTitle: '满 100 减 20 元券',
35
+ couponValueCents: 2000,
36
+ couponThresholdCents: 10000,
37
+ couponValidityDays: 30,
38
+ grouponEnabled: true,
39
+ activityTitle: '示例商场周年庆',
40
+ } as const satisfies CfgDefaults;
41
+ export const PROMOTION_CFG_INT_KEYS = ['couponValueCents', 'couponThresholdCents', 'couponValidityDays'];
75
42
 
76
43
  const emptyPage = (): PromotionOfferPage & PromotionEntitlementPage & PromotionActivityPage => ({
77
44
  items: [],
@@ -79,11 +46,65 @@ const emptyPage = (): PromotionOfferPage & PromotionEntitlementPage & PromotionA
79
46
  });
80
47
 
81
48
  export class MockPromotionServiceImpl implements MockPromotionService {
49
+ /** 配置快照(fail-soft,构造期一次解析;键集 ≡ PROMOTION_CFG_DEFAULTS) */
50
+ private readonly cfg: typeof PROMOTION_CFG_DEFAULTS;
51
+ /** 供/资产/活动三表(构造期按 cfg 构建——请求级实例,成本可忽略) */
52
+ private readonly offers: PromotionOffer[];
53
+ private readonly entitlements: PromotionEntitlement[];
54
+ private readonly activities: PromotionActivity[];
55
+
56
+ constructor(config: unknown = {}) {
57
+ this.cfg = resolveConfig(config, PROMOTION_CFG_DEFAULTS, PROMOTION_CFG_INT_KEYS);
58
+ const ts = now();
59
+ const couponOffer: PromotionOffer = {
60
+ offerRef: 'demo:coupon:1001',
61
+ offerType: 'COUPON',
62
+ title: this.cfg.couponTitle,
63
+ subtitle: '全场通用(mock 演示)',
64
+ tags: ['通用'],
65
+ validity: { start: ts, end: inDays(this.cfg.couponValidityDays) },
66
+ facets: [{ kind: 'COUPON', discountType: 'AMOUNT', value: this.cfg.couponValueCents, thresholdCents: this.cfg.couponThresholdCents }],
67
+ availability: { status: 'AVAILABLE', reasonCodes: [], evaluatedAt: ts, authoritative: false },
68
+ participation: { mode: 'CLAIM_THEN_PURCHASE', steps: [{ title: '领取', description: '点击领取后自动存入卡包' }] },
69
+ };
70
+ const grouponOffer: PromotionOffer = {
71
+ offerRef: 'demo:groupon:2001',
72
+ offerType: 'GROUPON',
73
+ title: '餐饮双人套餐 5 折',
74
+ subtitle: 'mock 演示团购',
75
+ tags: ['餐饮'],
76
+ validity: { start: ts, end: inDays(15) },
77
+ facets: [{ kind: 'GROUPON', requiredParticipants: 2 }],
78
+ availability: { status: 'AVAILABLE', reasonCodes: [], evaluatedAt: ts, authoritative: false },
79
+ participation: { mode: 'CLAIM_THEN_PURCHASE', steps: [{ title: '购买', description: '按团购价下单' }] },
80
+ };
81
+ this.offers = this.cfg.grouponEnabled ? [couponOffer, grouponOffer] : [couponOffer];
82
+ this.entitlements = [
83
+ {
84
+ entitlementRef: 'demo:entitlement:1',
85
+ offerRef: 'demo:coupon:1001',
86
+ title: this.cfg.couponTitle,
87
+ entitlementType: 'COUPON',
88
+ status: 'EFFECTIVE',
89
+ codeMasked: 'DEMO-****-1001',
90
+ },
91
+ ];
92
+ this.activities = [
93
+ {
94
+ activityRef: 'demo:activity:3001',
95
+ title: this.cfg.activityTitle,
96
+ subtitle: 'mock 演示活动',
97
+ registrationRequired: false,
98
+ offerRefs: ['demo:coupon:1001'],
99
+ },
100
+ ];
101
+ }
102
+
82
103
  async searchOffers(_q: PromotionQueryContext, input: PromotionSearchInput): Promise<PromotionOfferPage> {
83
104
  const keyword = input.keyword?.trim();
84
105
  const items = keyword
85
- ? DEMO_OFFERS.filter((o) => o.title.includes(keyword) || o.tags.some((t) => t.includes(keyword)))
86
- : DEMO_OFFERS;
106
+ ? this.offers.filter((o) => o.title.includes(keyword) || o.tags.some((t) => t.includes(keyword)))
107
+ : this.offers;
87
108
  return { items, hasMore: false };
88
109
  }
89
110
 
@@ -91,34 +112,34 @@ export class MockPromotionServiceImpl implements MockPromotionService {
91
112
  _q: PromotionQueryContext,
92
113
  input: { offerRef?: string; entitlementRef?: string; keyword?: string },
93
114
  ): Promise<PromotionOffer | null> {
94
- if (input.offerRef) return DEMO_OFFERS.find((o) => o.offerRef === input.offerRef) ?? null;
115
+ if (input.offerRef) return this.offers.find((o) => o.offerRef === input.offerRef) ?? null;
95
116
  if (input.entitlementRef) {
96
- const ent = DEMO_ENTITLEMENTS.find((e) => e.entitlementRef === input.entitlementRef);
97
- if (ent?.offerRef) return DEMO_OFFERS.find((o) => o.offerRef === ent.offerRef) ?? null;
117
+ const ent = this.entitlements.find((e) => e.entitlementRef === input.entitlementRef);
118
+ if (ent?.offerRef) return this.offers.find((o) => o.offerRef === ent.offerRef) ?? null;
98
119
  return null;
99
120
  }
100
- if (input.keyword) return DEMO_OFFERS.find((o) => o.title.includes(input.keyword!)) ?? null;
121
+ if (input.keyword) return this.offers.find((o) => o.title.includes(input.keyword!)) ?? null;
101
122
  return null;
102
123
  }
103
124
 
104
125
  async recommendOffers(): Promise<readonly PromotionOffer[]> {
105
- return DEMO_OFFERS;
126
+ return this.offers;
106
127
  }
107
128
 
108
129
  async listEntitlements(_q: PromotionQueryContext, _input: PromotionSearchInput): Promise<PromotionEntitlementPage> {
109
- return { items: DEMO_ENTITLEMENTS, hasMore: false };
130
+ return { items: this.entitlements, hasMore: false };
110
131
  }
111
132
 
112
133
  async getEntitlementDetail(_q: PromotionQueryContext, entitlementRef: string): Promise<PromotionEntitlement | null> {
113
- return DEMO_ENTITLEMENTS.find((e) => e.entitlementRef === entitlementRef) ?? null;
134
+ return this.entitlements.find((e) => e.entitlementRef === entitlementRef) ?? null;
114
135
  }
115
136
 
116
137
  async listActivities(): Promise<PromotionActivityPage> {
117
- return { items: DEMO_ACTIVITIES, hasMore: false };
138
+ return { items: this.activities, hasMore: false };
118
139
  }
119
140
 
120
141
  async getActivityDetail(_q: PromotionQueryContext, activityRef: string): Promise<PromotionActivityDetail | null> {
121
- const activity = DEMO_ACTIVITIES.find((a) => a.activityRef === activityRef);
142
+ const activity = this.activities.find((a) => a.activityRef === activityRef);
122
143
  if (!activity) return null;
123
144
  return { ...activity, sessions: [], description: 'mock 演示活动详情' };
124
145
  }
@@ -10,7 +10,9 @@
10
10
  * - merchantId 连字符格式(demo-shop-NNNN):LLM 从卡片 value 提取友好;getShop 入参 trim。
11
11
  * - catalog 空实现(对齐真实档 C 端):演示面不覆盖商品目录,门店链路为演示重点。
12
12
  * - 构造器接受 seed(默认 DEMO_BUILDINGS):测试可注入定制数据。
13
+ * - config 消费:SHOPPING_CFG_DEFAULTS 为契约单源(fail-soft 快照;extraShop* 追加演示门店)。
13
14
  */
15
+ import { resolveConfig, type CfgDefaults } from './config';
14
16
  import type {
15
17
  CatalogQueryPort,
16
18
  CategoryRecord,
@@ -48,6 +50,18 @@ interface DemoBuilding {
48
50
  floors: DemoFloor[];
49
51
  }
50
52
 
53
+ /** config 契约单源(键集/缺省/整数约束;tests/config-schema.test.ts 双锁) */
54
+ export const SHOPPING_CFG_DEFAULTS = {
55
+ extraShopName: '', // '' = 不追加门店(空串 = 缺省/不生效语义)
56
+ extraShopCategory: '餐饮',
57
+ extraShopFloor: '3 楼',
58
+ extraShopUnit: '304',
59
+ extraShopOpen: true,
60
+ } as const satisfies CfgDefaults;
61
+ export const SHOPPING_CFG_INT_KEYS: readonly string[] = [];
62
+ /** 楼层白名单(消费点守卫 + schema enum 同值——防手编楼层不在目录内) */
63
+ export const SHOPPING_FLOORS = ['B1', '1 楼', '2 楼', '3 楼', '4 楼'] as const;
64
+
51
65
  /** seed 单一真源:1 楼栋 A 栋 / 6 类目 / 12 店(西贝休息中演示营业状态多样性;NIKE 双店支撑快捷命令) */
52
66
  const DEMO_BUILDINGS: DemoBuilding[] = [
53
67
  {
@@ -137,16 +151,40 @@ function toFloorRecord(floor: DemoFloor): FloorRecord {
137
151
 
138
152
  export class MockShoppingServiceImpl implements
139
153
  CatalogQueryPort, ShopDirectoryQueryPort, CommercialCategoryQueryPort, MallDirectoryQueryPort {
154
+ /** 配置快照(fail-soft,构造期一次解析;键集 ≡ SHOPPING_CFG_DEFAULTS) */
155
+ private readonly cfg: typeof SHOPPING_CFG_DEFAULTS;
140
156
  private readonly buildings: readonly DemoBuilding[];
141
157
  private readonly shops: ShopRecord[];
142
158
  private readonly categories: CategoryRecord[];
143
159
 
144
- constructor(seed: readonly DemoBuilding[] = DEMO_BUILDINGS) {
145
- this.buildings = seed;
146
- this.shops = flattenShops(seed);
160
+ constructor(seed: readonly DemoBuilding[] = DEMO_BUILDINGS, config: unknown = {}) {
161
+ this.cfg = resolveConfig(config, SHOPPING_CFG_DEFAULTS, SHOPPING_CFG_INT_KEYS);
162
+ const withExtra = this.withExtraShop(seed);
163
+ this.buildings = withExtra;
164
+ this.shops = flattenShops(withExtra);
147
165
  this.categories = aggregateCategories(this.shops);
148
166
  }
149
167
 
168
+ /** extraShopName 非空 → 指定楼层追加演示门店(名称 trim 判空 + 楼层白名单回退——消费点守卫) */
169
+ private withExtraShop(seed: readonly DemoBuilding[]): readonly DemoBuilding[] {
170
+ const name = this.cfg.extraShopName.trim();
171
+ if (!name) return seed;
172
+ const floor = (SHOPPING_FLOORS as readonly string[]).includes(this.cfg.extraShopFloor)
173
+ ? this.cfg.extraShopFloor
174
+ : '3 楼';
175
+ const extra: ShopSeed = {
176
+ merchantId: 'demo-shop-1013',
177
+ name,
178
+ businessCategories: [this.cfg.extraShopCategory],
179
+ unitName: this.cfg.extraShopUnit,
180
+ status: this.cfg.extraShopOpen ? { code: 'enabled', label: '营业中' } : { code: 'disabled', label: '休息中' },
181
+ };
182
+ return seed.map((b) => ({
183
+ ...b,
184
+ floors: b.floors.map((f) => (f.floorName === floor ? { ...f, shops: [...f.shops, extra] } : f)),
185
+ }));
186
+ }
187
+
150
188
  // ===== ShopDirectoryQueryPort =====
151
189
 
152
190
  async searchShops(criteria: ShopSearchCriteria): Promise<ShoppingPage<ShopRecord>> {
package/tbox.module.json CHANGED
@@ -1,6 +1,8 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
3
  "name": "provider-mock",
4
+ "title": "Mock",
5
+ "description": "全槽本地演示供给:免真实厂商接入的完整商圈演示",
4
6
  "version": "0.1.0",
5
7
  "kind": "business",
6
8
  "risk": {
@@ -24,119 +26,136 @@
24
26
  "credentialType": "-",
25
27
  "local": true,
26
28
  "provider": "mock",
27
- "implementation": "mock-member@1"
29
+ "implementation": "mock-member@1",
30
+ "configSchema": "schemas/member.config.json"
28
31
  },
29
32
  {
30
33
  "service": "member.profile",
31
34
  "credentialType": "-",
32
35
  "local": true,
33
36
  "provider": "mock",
34
- "implementation": "mock-member@1"
37
+ "implementation": "mock-member@1",
38
+ "configSchema": "schemas/member.config.json"
35
39
  },
36
40
  {
37
41
  "service": "member.card",
38
42
  "credentialType": "-",
39
43
  "local": true,
40
44
  "provider": "mock",
41
- "implementation": "mock-member@1"
45
+ "implementation": "mock-member@1",
46
+ "configSchema": "schemas/member.config.json"
42
47
  },
43
48
  {
44
49
  "service": "member.benefits",
45
50
  "credentialType": "-",
46
51
  "local": true,
47
52
  "provider": "mock",
48
- "implementation": "mock-member@1"
53
+ "implementation": "mock-member@1",
54
+ "configSchema": "schemas/member.config.json"
49
55
  },
50
56
  {
51
57
  "service": "member.enrollment",
52
58
  "credentialType": "-",
53
59
  "local": true,
54
60
  "provider": "mock",
55
- "implementation": "mock-member@1"
61
+ "implementation": "mock-member@1",
62
+ "configSchema": "schemas/member.config.json"
56
63
  },
57
64
  {
58
65
  "service": "parking.query",
59
66
  "credentialType": "-",
60
67
  "local": true,
61
68
  "provider": "mock",
62
- "implementation": "mock-parking@1"
69
+ "implementation": "mock-parking@1",
70
+ "configSchema": "schemas/parking.config.json"
63
71
  },
64
72
  {
65
73
  "service": "parking.payment",
66
74
  "credentialType": "-",
67
75
  "local": true,
68
76
  "provider": "mock",
69
- "implementation": "mock-parking@1"
77
+ "implementation": "mock-parking@1",
78
+ "configSchema": "schemas/parking.config.json"
70
79
  },
71
80
  {
72
81
  "service": "parking.vehicle",
73
82
  "credentialType": "-",
74
83
  "local": true,
75
84
  "provider": "mock",
76
- "implementation": "mock-parking@1"
85
+ "implementation": "mock-parking@1",
86
+ "configSchema": "schemas/parking.config.json"
77
87
  },
78
88
  {
79
89
  "service": "promotion.offers",
80
90
  "credentialType": "-",
81
91
  "local": true,
82
92
  "provider": "mock",
83
- "implementation": "mock-promotion@1"
93
+ "implementation": "mock-promotion@1",
94
+ "configSchema": "schemas/promotion.config.json"
84
95
  },
85
96
  {
86
97
  "service": "promotion.entitlements",
87
98
  "credentialType": "-",
88
99
  "local": true,
89
100
  "provider": "mock",
90
- "implementation": "mock-promotion@1"
101
+ "implementation": "mock-promotion@1",
102
+ "configSchema": "schemas/promotion.config.json"
91
103
  },
92
104
  {
93
105
  "service": "promotion.activities",
94
106
  "credentialType": "-",
95
107
  "local": true,
96
108
  "provider": "mock",
97
- "implementation": "mock-promotion@1"
109
+ "implementation": "mock-promotion@1",
110
+ "configSchema": "schemas/promotion.config.json"
98
111
  },
99
112
  {
100
113
  "service": "promotion.acquisition",
101
114
  "credentialType": "-",
102
115
  "local": true,
103
116
  "provider": "mock",
104
- "implementation": "mock-promotion@1"
117
+ "implementation": "mock-promotion@1",
118
+ "configSchema": "schemas/promotion.config.json"
105
119
  },
106
120
  {
107
121
  "service": "shopping-guide.catalog",
108
122
  "credentialType": "-",
109
123
  "local": true,
110
124
  "provider": "mock",
111
- "implementation": "mock-shopping@1"
125
+ "implementation": "mock-shopping@1",
126
+ "configSchema": "schemas/shopping.config.json"
112
127
  },
113
128
  {
114
129
  "service": "shopping-guide.shops",
115
130
  "credentialType": "-",
116
131
  "local": true,
117
132
  "provider": "mock",
118
- "implementation": "mock-shopping@1"
133
+ "implementation": "mock-shopping@1",
134
+ "configSchema": "schemas/shopping.config.json"
119
135
  },
120
136
  {
121
137
  "service": "shopping-guide.categories",
122
138
  "credentialType": "-",
123
139
  "local": true,
124
140
  "provider": "mock",
125
- "implementation": "mock-shopping@1"
141
+ "implementation": "mock-shopping@1",
142
+ "configSchema": "schemas/shopping.config.json"
126
143
  },
127
144
  {
128
145
  "service": "shopping-guide.directory",
129
146
  "credentialType": "-",
130
147
  "local": true,
131
148
  "provider": "mock",
132
- "implementation": "mock-shopping@1"
149
+ "implementation": "mock-shopping@1",
150
+ "configSchema": "schemas/shopping.config.json"
133
151
  },
134
152
  {
135
153
  "service": "mall.info",
136
154
  "credentialType": "-",
137
155
  "local": true,
138
156
  "provider": "mock",
139
- "implementation": "mock-mall-info@1"
157
+ "implementation": "mock-mall-info@1",
158
+ "configSchema": "schemas/mall-info.config.json"
140
159
  }
141
160
  ]
142
161
  },