@tbox.cn/app-provider-mock 1.0.0-alpha.12 → 1.0.0-alpha.14

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.
@@ -1,5 +1,5 @@
1
1
  import { ServiceAdapterFactory, ServerContext } from '@tbox.cn/app-agent-sdk-server';
2
- import { MemberAccountPort, MemberProfilePort, MemberCardPort, MemberBenefitsPort, MemberEnrollmentPort, MemberAccountSnapshot, MemberProfileSnapshot, MemberCardSnapshot, Points, MemberBenefitsSnapshot, PointUsageRecord, DiscountRule, MemberEnrollmentInput, MemberEnrollmentResult, MemberEnrollmentFormDefinition, ParkingQueryPort, ParkingPaymentPort, ParkingVehiclePort, ParkingQueryContext, QuoteSnapshot, ParkingVehicle, ParkingRecordPage, ParkingPaymentRecord, ParkingInfo, ParkingBenefit, ParkingLocation, PromotionOfferQueryPort, PromotionEntitlementPort, PromotionActivityPort, PromotionAcquisitionPort, PromotionQueryContext, PromotionSearchInput, PromotionOfferPage, PromotionOffer, PromotionEntitlementPage, PromotionEntitlement, PromotionActivityPage, PromotionActivityDetail, PromotionOperation, CatalogQueryPort, ShopDirectoryQueryPort, CommercialCategoryQueryPort, MallDirectoryQueryPort, ShopSearchCriteria, ShoppingPage, ShopRecord, ShoppingQueryContext, CategoryRecord, MallDirectoryRecord, ProductSearchCriteria, ProductRecord, ProductFacetsRecord } from '@tbox.cn/app-contracts-mall';
2
+ import { MemberAccountPort, MemberProfilePort, MemberCardPort, MemberBenefitsPort, MemberEnrollmentPort, MemberAccountSnapshot, MemberProfileSnapshot, MemberCardSnapshot, Points, MemberBenefitsSnapshot, PointUsageRecord, DiscountRule, MemberEnrollmentInput, MemberEnrollmentResult, MemberEnrollmentFormDefinition, ParkingQueryPort, ParkingPaymentPort, ParkingVehiclePort, ParkingQueryContext, QuoteSnapshot, ParkingVehicle, ParkingRecordPage, ParkingPaymentRecord, ParkingInfo, ParkingBenefit, ParkingLocation, PromotionOfferQueryPort, PromotionEntitlementPort, PromotionActivityPort, PromotionAcquisitionPort, PromotionQueryContext, PromotionSearchInput, PromotionOfferPage, PromotionOffer, PromotionEntitlementPage, PromotionEntitlement, PromotionActivityPage, PromotionActivityDetail, PromotionOperation, CatalogQueryPort, ShopDirectoryQueryPort, CommercialCategoryQueryPort, MallDirectoryQueryPort, ShopSearchCriteria, ShoppingPage, ShopRecord, ShoppingQueryContext, CategoryRecord, MallDirectoryRecord, ProductSearchCriteria, ProductRecord, ProductFacetsRecord, ActivityPlayQueryPort, ActivityPlayPrizeQueryPort, ActivityPlayQueryContext, ActivityPlayListInput, ActivityPlayPage, ActivityPlayActivity, ActivityPlayPrizeQueryContext, ActivityPlayPrizeListResult, ActivityPlayPrizeDetail } from '@tbox.cn/app-contracts-mall';
3
3
  import { Router } from 'express';
4
4
 
5
5
  /**
@@ -227,6 +227,27 @@ declare const MOCK_MALL_INFO_IMPL = "mock-mall-info@1";
227
227
  /** mock mall.info adapter 工厂(对齐真实厂商 adapter 工厂形态) */
228
228
  declare const mockMallInfoFactory: ServiceAdapterFactory;
229
229
 
230
+ /**
231
+ * Mock activity-play 实现(provider-mock 自持——query/prizes 双槽,2026-11-25 加装)。
232
+ * 契约语义与 hupo adapter 对齐:listActivities = 静态列表 + keyword/limit 适配层过滤
233
+ * (大小写不敏感包含、上限钳制 50——与 hupo limitOf 同值同语义);getActivity /
234
+ * getMyPrizeDetail 未知或不可见 → null;不缓存、不编造缺席字段。
235
+ * 演示数据形态:
236
+ * - 三活动覆盖状态枚举三态(大转盘 active / 砸金蛋 ended / 签到抽奖 not_started),
237
+ * 玩法名对齐验收建议(大转盘、砸金蛋、签到——勿混入旧营销词汇);ref 恒 `demo:`
238
+ * 前缀,厂商中立;
239
+ * - 奖品恒三枚覆盖三状态桶(可用券 / 已用票 / UNKNOWN 兜底实物),同一部署所有
240
+ * subjectId 同结果(mock 语义:单 demo 用户/部署——与 member/auth 注释同口径);
241
+ * 演示常量零配置冻结,时间戳为含时区固定时刻(不随时间漂移——状态演示稳定)。
242
+ */
243
+
244
+ declare class MockActivityPlayServiceImpl implements ActivityPlayQueryPort, ActivityPlayPrizeQueryPort {
245
+ listActivities(_q: ActivityPlayQueryContext, input: ActivityPlayListInput): Promise<ActivityPlayPage>;
246
+ getActivity(_q: ActivityPlayQueryContext, activityId: string): Promise<ActivityPlayActivity | null>;
247
+ listMyPrizes(_q: ActivityPlayPrizeQueryContext): Promise<ActivityPlayPrizeListResult>;
248
+ getMyPrizeDetail(_q: ActivityPlayPrizeQueryContext, prizeRecordRef: string): Promise<ActivityPlayPrizeDetail | null>;
249
+ }
250
+
230
251
  /**
231
252
  * Mock 入会落地点路由(入会体验闭环 C5):POST /api/m/provider-mock/demo/member-enroll。
232
253
  *
@@ -251,6 +272,7 @@ declare function createMockEnrollRouter(): Router;
251
272
  declare const MOCK_PROVIDER = "mock";
252
273
  declare const MOCK_MEMBER_IMPL = "mock-member@1";
253
274
  declare const MOCK_PARKING_IMPL = "mock-parking@1";
275
+ declare const MOCK_ACTIVITY_PLAY_IMPL = "mock-activity-play@1";
254
276
  declare const MOCK_PROMOTION_IMPL = "mock-promotion@1";
255
277
  declare const MOCK_SHOPPING_IMPL = "mock-shopping@1";
256
278
 
@@ -262,4 +284,4 @@ declare const serverModule: {
262
284
  register(ctx: ServerContext): void;
263
285
  };
264
286
 
265
- export { MOCK_MALL_INFO_IMPL, MOCK_MALL_INFO_PROVIDER, MOCK_MEMBER_IMPL, MOCK_PARKING_IMPL, MOCK_PROMOTION_IMPL, MOCK_PROVIDER, MOCK_SHELL_USER_ID, MOCK_SHOPPING_IMPL, MockMemberServiceImpl, MockParkingServiceImpl, MockPromotionServiceImpl, MockShoppingServiceImpl, __resetMockMemberState, __resetMockParkingState, createMockEnrollRouter, enrollMockMember, isMockMemberEnrolled, isMockMemberLoggedOut, logoutMockMember, mockMallInfoFactory, serverModule };
287
+ export { MOCK_ACTIVITY_PLAY_IMPL, MOCK_MALL_INFO_IMPL, MOCK_MALL_INFO_PROVIDER, MOCK_MEMBER_IMPL, MOCK_PARKING_IMPL, MOCK_PROMOTION_IMPL, MOCK_PROVIDER, MOCK_SHELL_USER_ID, MOCK_SHOPPING_IMPL, MockActivityPlayServiceImpl, MockMemberServiceImpl, MockParkingServiceImpl, MockPromotionServiceImpl, MockShoppingServiceImpl, __resetMockMemberState, __resetMockParkingState, createMockEnrollRouter, enrollMockMember, isMockMemberEnrolled, isMockMemberLoggedOut, logoutMockMember, mockMallInfoFactory, serverModule };
@@ -666,6 +666,134 @@ var mockMallInfoFactory = (input) => {
666
666
  };
667
667
  };
668
668
 
669
+ // src/server/activity-play.ts
670
+ var IMG = {
671
+ wheel: "https://mdn.alipayobjects.com/huamei_b00jk5/afts/img/A*UiQ2S7W7eaUAAAAARAAAAAgAegitAQ/fmt.webp",
672
+ eggs: "https://mdn.alipayobjects.com/huamei_b00jk5/afts/img/A*GzryQrxX2WEAAAAATYAAAAgAegitAQ/fmt.webp",
673
+ signIn: "https://mdn.alipayobjects.com/huamei_b00jk5/afts/img/A*yXl6Ta2WcjIAAAAARyAAAAgAegitAQ/fmt.webp"
674
+ };
675
+ var ACTIVITIES = [
676
+ {
677
+ activityId: "demo:activity:wheel",
678
+ title: "\u5927\u8F6C\u76D8\u8D62\u597D\u793C",
679
+ description: "\u8F6C\u52A8\u5E78\u8FD0\u5927\u8F6C\u76D8\uFF0C\u8D62\u5496\u5561\u5238\u3001\u7535\u5F71\u7968\u7B49\u597D\u793C\uFF08mock \u6F14\u793A\uFF09",
680
+ imageUrl: IMG.wheel,
681
+ detailCoverUrl: IMG.wheel,
682
+ participationRules: { ruleTexts: ["\u6BCF\u4EBA\u6BCF\u5929 3 \u6B21\u62BD\u5956\u673A\u4F1A", "\u540C\u4E00\u8BA2\u5355\u4E0D\u91CD\u590D\u4E2D\u5956"] },
683
+ rewardSummary: {
684
+ items: [
685
+ { title: "10 \u5143\u5496\u5561\u5238", tierName: "\u4E00\u7B49\u5956" },
686
+ { title: "\u7535\u5F71\u7968 \xD71", tierName: "\u4E8C\u7B49\u5956" },
687
+ { title: "5 \u79EF\u5206", tierName: "\u53C2\u4E0E\u5956" }
688
+ ]
689
+ },
690
+ startsAt: "2026-11-20T10:00:00+08:00",
691
+ endsAt: "2026-12-20T22:00:00+08:00",
692
+ status: "active"
693
+ },
694
+ {
695
+ activityId: "demo:activity:eggs",
696
+ title: "\u7838\u91D1\u86CB\u62BD\u7EA2\u5305",
697
+ description: "\u6D88\u8D39\u6EE1 58 \u5143\u5373\u53EF\u7838\u91D1\u86CB\uFF0C\u767E\u5206\u767E\u4E2D\u5956\uFF08mock \u6F14\u793A\uFF09",
698
+ imageUrl: IMG.eggs,
699
+ startsAt: "2026-11-01T10:00:00+08:00",
700
+ endsAt: "2026-11-15T22:00:00+08:00",
701
+ status: "ended"
702
+ },
703
+ {
704
+ activityId: "demo:activity:sign-in",
705
+ title: "\u8FDE\u7EED\u7B7E\u5230\u62BD\u5927\u5956",
706
+ description: "\u8FDE\u7EED\u7B7E\u5230 7 \u5929\u89E3\u9501\u62BD\u5956\u8D44\u683C\uFF0C\u7EC8\u6781\u5927\u5956\u7B49\u4F60\u62FF\uFF08mock \u6F14\u793A\uFF09",
707
+ imageUrl: IMG.signIn,
708
+ startsAt: "2026-12-01T00:00:00+08:00",
709
+ endsAt: "2026-12-31T22:00:00+08:00",
710
+ status: "not_started"
711
+ }
712
+ ];
713
+ var PRIZES = [
714
+ {
715
+ prizeRecordRef: "demo:prize:coffee",
716
+ title: "10 \u5143\u5496\u5561\u5238",
717
+ prizeType: "COUPON",
718
+ claimStatus: "CLAIMABLE",
719
+ useStatus: "USABLE",
720
+ activityId: "demo:activity:wheel",
721
+ activityTitle: "\u5927\u8F6C\u76D8\u8D62\u597D\u793C",
722
+ imageUrl: IMG.wheel,
723
+ wonAt: "2026-11-21T15:30:00+08:00",
724
+ usageRuleText: "\u5168\u573A\u901A\u7528\uFF0C\u5355\u7B14\u6EE1 10 \u5143\u53EF\u7528\uFF0C\u6709\u6548\u671F 30 \u5929"
725
+ },
726
+ {
727
+ prizeRecordRef: "demo:prize:movie",
728
+ title: "\u7535\u5F71\u7968 \xD71",
729
+ prizeType: "TICKET",
730
+ claimStatus: "CLAIMED",
731
+ useStatus: "USED",
732
+ activityId: "demo:activity:eggs",
733
+ activityTitle: "\u7838\u91D1\u86CB\u62BD\u7EA2\u5305",
734
+ imageUrl: IMG.eggs,
735
+ wonAt: "2026-11-10T19:05:00+08:00",
736
+ usageRuleText: "\u5168\u56FD\u901A\u7528\u573A\u6B21\uFF0C\u6709\u6548\u671F 14 \u5929"
737
+ },
738
+ {
739
+ prizeRecordRef: "demo:prize:bottle",
740
+ title: "\u9650\u91CF\u4FDD\u6E29\u676F",
741
+ prizeType: "UNKNOWN",
742
+ claimStatus: "CLAIMABLE",
743
+ useStatus: "UNKNOWN",
744
+ activityId: "demo:activity:wheel",
745
+ activityTitle: "\u5927\u8F6C\u76D8\u8D62\u597D\u793C",
746
+ imageUrl: IMG.wheel,
747
+ wonAt: "2026-11-22T11:00:00+08:00",
748
+ usageRuleText: "\u9886\u53D6\u540E 7 \u5929\u5185\u5230\u670D\u52A1\u53F0\u51ED\u4E2D\u5956\u8BB0\u5F55\u9886\u53D6"
749
+ }
750
+ ];
751
+ var PRIZE_DETAIL_EXTRA = {
752
+ "demo:prize:coffee": {
753
+ redemptionMethod: "\u95E8\u5E97\u51FA\u793A\u6838\u9500\u7801",
754
+ redemptionInstruction: "\u5230\u4EFB\u610F\u53C2\u4E0E\u95E8\u5E97\u51FA\u793A\u4F1A\u5458\u6838\u9500\u7801\uFF0C\u5E97\u5458\u626B\u7801\u540E\u5373\u53EF\u4F7F\u7528",
755
+ prizeUrl: "https://render.alipay.com/p/s/demo-prize-coffee"
756
+ },
757
+ "demo:prize:movie": {
758
+ redemptionMethod: "\u7EBF\u4E0A\u9009\u5EA7\u5151\u6362",
759
+ redemptionInstruction: "\u5728\u8D2D\u7968\u9875\u9009\u62E9\u573A\u6B21\u540E\u5151\u6362\uFF0C\u5F71\u7968\u552E\u7F44\u53EF\u987A\u5EF6\u4E00\u6B21",
760
+ prizeUrl: "https://render.alipay.com/p/s/demo-prize-movie"
761
+ },
762
+ "demo:prize:bottle": {
763
+ redemptionMethod: "\u5546\u573A\u670D\u52A1\u53F0\u9886\u53D6",
764
+ redemptionInstruction: "\u51ED\u4F1A\u5458\u4E2D\u5956\u8BB0\u5F55\u5230 1 \u5C42\u670D\u52A1\u53F0\u9886\u53D6\u5B9E\u7269\u5956\u54C1"
765
+ }
766
+ };
767
+ function matchesKeyword(activity, keyword) {
768
+ const haystack = `${activity.title}
769
+ ${activity.description ?? ""}`.toLowerCase();
770
+ return haystack.includes(keyword);
771
+ }
772
+ function limitOf(input) {
773
+ const DEFAULT = 20;
774
+ const MAX = 50;
775
+ const n = input?.limit;
776
+ return typeof n === "number" && Number.isFinite(n) && n >= 1 ? Math.min(Math.floor(n), MAX) : DEFAULT;
777
+ }
778
+ var MockActivityPlayServiceImpl = class {
779
+ async listActivities(_q, input) {
780
+ const keyword = typeof input?.keyword === "string" ? input.keyword.trim().toLowerCase() : "";
781
+ const filtered = keyword ? ACTIVITIES.filter((a) => matchesKeyword(a, keyword)) : [...ACTIVITIES];
782
+ return { items: filtered.slice(0, limitOf(input)) };
783
+ }
784
+ async getActivity(_q, activityId) {
785
+ return ACTIVITIES.find((a) => a.activityId === activityId) ?? null;
786
+ }
787
+ async listMyPrizes(_q) {
788
+ return { total: PRIZES.length, items: [...PRIZES] };
789
+ }
790
+ async getMyPrizeDetail(_q, prizeRecordRef) {
791
+ const hit = PRIZES.find((p) => p.prizeRecordRef === prizeRecordRef);
792
+ const extra = PRIZE_DETAIL_EXTRA[prizeRecordRef];
793
+ return hit && extra ? { ...hit, ...extra } : null;
794
+ }
795
+ };
796
+
669
797
  // src/server/mock-enroll-route.ts
670
798
  import { Router } from "express";
671
799
  import { getRequestContext } from "@tbox.cn/app-agent-sdk-server";
@@ -706,6 +834,7 @@ function createMockEnrollRouter() {
706
834
  var MOCK_PROVIDER = "mock";
707
835
  var MOCK_MEMBER_IMPL = "mock-member@1";
708
836
  var MOCK_PARKING_IMPL = "mock-parking@1";
837
+ var MOCK_ACTIVITY_PLAY_IMPL = "mock-activity-play@1";
709
838
  var MOCK_PROMOTION_IMPL = "mock-promotion@1";
710
839
  var MOCK_SHOPPING_IMPL = "mock-shopping@1";
711
840
  var memberFactory = () => new MockMemberServiceImpl({});
@@ -718,6 +847,7 @@ var shoppingFactory = (input) => {
718
847
  return new MockShoppingServiceImpl(void 0);
719
848
  };
720
849
  var mallInfoFactory = (input) => mockMallInfoFactory(input);
850
+ var activityPlayFactory = () => new MockActivityPlayServiceImpl();
721
851
  function createMockAlipayLoginExchange(deps) {
722
852
  return {
723
853
  provider: "alipay",
@@ -775,6 +905,7 @@ var serverModule = {
775
905
  ctx.integrations?.registerAdapter(MOCK_PROVIDER, MOCK_PROMOTION_IMPL, promotionFactory);
776
906
  ctx.integrations?.registerAdapter(MOCK_PROVIDER, MOCK_SHOPPING_IMPL, shoppingFactory);
777
907
  ctx.integrations?.registerAdapter(MOCK_MALL_INFO_PROVIDER, MOCK_MALL_INFO_IMPL, mallInfoFactory);
908
+ ctx.integrations?.registerAdapter(MOCK_PROVIDER, MOCK_ACTIVITY_PLAY_IMPL, activityPlayFactory);
778
909
  ctx.authExchanges.register(createMockAlipayLoginExchange({
779
910
  integrations: ctx.integrations,
780
911
  // 登录期求值(域装配 register 晚于本包仍生效;零拓扑 mock 档经隐式声明实例派生 mall-demo)
@@ -784,6 +915,7 @@ var serverModule = {
784
915
  }
785
916
  };
786
917
  export {
918
+ MOCK_ACTIVITY_PLAY_IMPL,
787
919
  MOCK_MALL_INFO_IMPL,
788
920
  MOCK_MALL_INFO_PROVIDER,
789
921
  MOCK_MEMBER_IMPL,
@@ -792,6 +924,7 @@ export {
792
924
  MOCK_PROVIDER,
793
925
  MOCK_SHELL_USER_ID,
794
926
  MOCK_SHOPPING_IMPL,
927
+ MockActivityPlayServiceImpl,
795
928
  MockMemberServiceImpl,
796
929
  MockParkingServiceImpl,
797
930
  MockPromotionServiceImpl,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tbox.cn/app-provider-mock",
3
- "version": "1.0.0-alpha.12",
3
+ "version": "1.0.0-alpha.14",
4
4
  "type": "module",
5
5
  "description": "商圈 Mock Provider 包(极简零配置):18 槽 local 供给开箱即用(含 auth.alipay-login 标签供给——登录换码路由仍走 member.account 绑定);免传输/凭据/实例配置/集成配置;config 消费与配置验证面见 @tbox.cn/app-provider-mocktest。",
6
6
  "exports": {
@@ -14,10 +14,10 @@
14
14
  }
15
15
  },
16
16
  "dependencies": {
17
- "@tbox.cn/app-contracts": "1.0.0-alpha.12",
18
- "@tbox.cn/app-agent-sdk-client": "1.0.0-alpha.12",
19
- "@tbox.cn/app-agent-sdk-server": "1.0.0-alpha.12",
20
- "@tbox.cn/app-contracts-mall": "1.0.0-alpha.12"
17
+ "@tbox.cn/app-contracts": "1.0.0-alpha.14",
18
+ "@tbox.cn/app-agent-sdk-server": "1.0.0-alpha.14",
19
+ "@tbox.cn/app-contracts-mall": "1.0.0-alpha.14",
20
+ "@tbox.cn/app-agent-sdk-client": "1.0.0-alpha.14"
21
21
  },
22
22
  "devDependencies": {
23
23
  "@types/express": "4.17.25",
@@ -0,0 +1,171 @@
1
+ /**
2
+ * Mock activity-play 实现(provider-mock 自持——query/prizes 双槽,2026-11-25 加装)。
3
+ * 契约语义与 hupo adapter 对齐:listActivities = 静态列表 + keyword/limit 适配层过滤
4
+ * (大小写不敏感包含、上限钳制 50——与 hupo limitOf 同值同语义);getActivity /
5
+ * getMyPrizeDetail 未知或不可见 → null;不缓存、不编造缺席字段。
6
+ * 演示数据形态:
7
+ * - 三活动覆盖状态枚举三态(大转盘 active / 砸金蛋 ended / 签到抽奖 not_started),
8
+ * 玩法名对齐验收建议(大转盘、砸金蛋、签到——勿混入旧营销词汇);ref 恒 `demo:`
9
+ * 前缀,厂商中立;
10
+ * - 奖品恒三枚覆盖三状态桶(可用券 / 已用票 / UNKNOWN 兜底实物),同一部署所有
11
+ * subjectId 同结果(mock 语义:单 demo 用户/部署——与 member/auth 注释同口径);
12
+ * 演示常量零配置冻结,时间戳为含时区固定时刻(不随时间漂移——状态演示稳定)。
13
+ */
14
+ import type {
15
+ ActivityPlayActivity,
16
+ ActivityPlayPage,
17
+ ActivityPlayListInput,
18
+ ActivityPlayQueryContext,
19
+ ActivityPlayPrizeDetail,
20
+ ActivityPlayPrizeListResult,
21
+ } from '@tbox.cn/app-contracts-mall';
22
+ import type {
23
+ ActivityPlayQueryPort,
24
+ ActivityPlayPrizeQueryPort,
25
+ ActivityPlayPrizeQueryContext,
26
+ } from '@tbox.cn/app-contracts-mall';
27
+
28
+ /** 演示素材(复用 promotion 同图库——公开 webp 占位) */
29
+ const IMG = {
30
+ wheel: 'https://mdn.alipayobjects.com/huamei_b00jk5/afts/img/A*UiQ2S7W7eaUAAAAARAAAAAgAegitAQ/fmt.webp',
31
+ eggs: 'https://mdn.alipayobjects.com/huamei_b00jk5/afts/img/A*GzryQrxX2WEAAAAATYAAAAgAegitAQ/fmt.webp',
32
+ signIn: 'https://mdn.alipayobjects.com/huamei_b00jk5/afts/img/A*yXl6Ta2WcjIAAAAARyAAAAgAegitAQ/fmt.webp',
33
+ } as const;
34
+
35
+ const ACTIVITIES: readonly ActivityPlayActivity[] = [
36
+ {
37
+ activityId: 'demo:activity:wheel',
38
+ title: '大转盘赢好礼',
39
+ description: '转动幸运大转盘,赢咖啡券、电影票等好礼(mock 演示)',
40
+ imageUrl: IMG.wheel,
41
+ detailCoverUrl: IMG.wheel,
42
+ participationRules: { ruleTexts: ['每人每天 3 次抽奖机会', '同一订单不重复中奖'] },
43
+ rewardSummary: {
44
+ items: [
45
+ { title: '10 元咖啡券', tierName: '一等奖' },
46
+ { title: '电影票 ×1', tierName: '二等奖' },
47
+ { title: '5 积分', tierName: '参与奖' },
48
+ ],
49
+ },
50
+ startsAt: '2026-11-20T10:00:00+08:00',
51
+ endsAt: '2026-12-20T22:00:00+08:00',
52
+ status: 'active',
53
+ },
54
+ {
55
+ activityId: 'demo:activity:eggs',
56
+ title: '砸金蛋抽红包',
57
+ description: '消费满 58 元即可砸金蛋,百分百中奖(mock 演示)',
58
+ imageUrl: IMG.eggs,
59
+ startsAt: '2026-11-01T10:00:00+08:00',
60
+ endsAt: '2026-11-15T22:00:00+08:00',
61
+ status: 'ended',
62
+ },
63
+ {
64
+ activityId: 'demo:activity:sign-in',
65
+ title: '连续签到抽大奖',
66
+ description: '连续签到 7 天解锁抽奖资格,终极大奖等你拿(mock 演示)',
67
+ imageUrl: IMG.signIn,
68
+ startsAt: '2026-12-01T00:00:00+08:00',
69
+ endsAt: '2026-12-31T22:00:00+08:00',
70
+ status: 'not_started',
71
+ },
72
+ ];
73
+
74
+ /** 奖品三枚基础面(状态桶全覆盖:USABLE / USED / UNKNOWN——UNKNOWN 展示契约兜底桶);
75
+ * detail 字段(redemptionMethod/Instruction/prizeUrl)仅详情面返回——与真实供给分面
76
+ * 语义一致(list 走 strict recordSchema,未知键显性拒绝)。 */
77
+ const PRIZES = [
78
+ {
79
+ prizeRecordRef: 'demo:prize:coffee',
80
+ title: '10 元咖啡券',
81
+ prizeType: 'COUPON',
82
+ claimStatus: 'CLAIMABLE',
83
+ useStatus: 'USABLE',
84
+ activityId: 'demo:activity:wheel',
85
+ activityTitle: '大转盘赢好礼',
86
+ imageUrl: IMG.wheel,
87
+ wonAt: '2026-11-21T15:30:00+08:00',
88
+ usageRuleText: '全场通用,单笔满 10 元可用,有效期 30 天',
89
+ },
90
+ {
91
+ prizeRecordRef: 'demo:prize:movie',
92
+ title: '电影票 ×1',
93
+ prizeType: 'TICKET',
94
+ claimStatus: 'CLAIMED',
95
+ useStatus: 'USED',
96
+ activityId: 'demo:activity:eggs',
97
+ activityTitle: '砸金蛋抽红包',
98
+ imageUrl: IMG.eggs,
99
+ wonAt: '2026-11-10T19:05:00+08:00',
100
+ usageRuleText: '全国通用场次,有效期 14 天',
101
+ },
102
+ {
103
+ prizeRecordRef: 'demo:prize:bottle',
104
+ title: '限量保温杯',
105
+ prizeType: 'UNKNOWN',
106
+ claimStatus: 'CLAIMABLE',
107
+ useStatus: 'UNKNOWN',
108
+ activityId: 'demo:activity:wheel',
109
+ activityTitle: '大转盘赢好礼',
110
+ imageUrl: IMG.wheel,
111
+ wonAt: '2026-11-22T11:00:00+08:00',
112
+ usageRuleText: '领取后 7 天内到服务台凭中奖记录领取',
113
+ },
114
+ ] as const;
115
+
116
+ /** 详情面扩展(prizeRecordRef → redemptionMethod/Instruction/prizeUrl) */
117
+ const PRIZE_DETAIL_EXTRA: Readonly<Record<string, { redemptionMethod: string; redemptionInstruction: string; prizeUrl?: string }>> = {
118
+ 'demo:prize:coffee': {
119
+ redemptionMethod: '门店出示核销码',
120
+ redemptionInstruction: '到任意参与门店出示会员核销码,店员扫码后即可使用',
121
+ prizeUrl: 'https://render.alipay.com/p/s/demo-prize-coffee',
122
+ },
123
+ 'demo:prize:movie': {
124
+ redemptionMethod: '线上选座兑换',
125
+ redemptionInstruction: '在购票页选择场次后兑换,影票售罄可顺延一次',
126
+ prizeUrl: 'https://render.alipay.com/p/s/demo-prize-movie',
127
+ },
128
+ 'demo:prize:bottle': {
129
+ redemptionMethod: '商场服务台领取',
130
+ redemptionInstruction: '凭会员中奖记录到 1 层服务台领取实物奖品',
131
+ },
132
+ };
133
+
134
+ /** keyword 匹配(与 hupo 适配层同语义——名称/说明大小写不敏感包含) */
135
+ function matchesKeyword(activity: ActivityPlayActivity, keyword: string): boolean {
136
+ const haystack = `${activity.title}\n${activity.description ?? ''}`.toLowerCase();
137
+ return haystack.includes(keyword);
138
+ }
139
+
140
+ /** limit 兜底(与 hupo limitOf 同值同语义:init 20 / 上限 50 钳制——消费方 schema 先拦) */
141
+ function limitOf(input: ActivityPlayListInput | undefined): number {
142
+ const DEFAULT = 20;
143
+ const MAX = 50;
144
+ const n = input?.limit;
145
+ return typeof n === 'number' && Number.isFinite(n) && n >= 1 ? Math.min(Math.floor(n), MAX) : DEFAULT;
146
+ }
147
+
148
+ export class MockActivityPlayServiceImpl implements ActivityPlayQueryPort, ActivityPlayPrizeQueryPort {
149
+ async listActivities(_q: ActivityPlayQueryContext, input: ActivityPlayListInput): Promise<ActivityPlayPage> {
150
+ const keyword = typeof input?.keyword === 'string' ? input.keyword.trim().toLowerCase() : '';
151
+ const filtered = keyword ? ACTIVITIES.filter((a) => matchesKeyword(a, keyword)) : [...ACTIVITIES];
152
+ return { items: filtered.slice(0, limitOf(input)) };
153
+ }
154
+
155
+ async getActivity(_q: ActivityPlayQueryContext, activityId: string): Promise<ActivityPlayActivity | null> {
156
+ return ACTIVITIES.find((a) => a.activityId === activityId) ?? null;
157
+ }
158
+
159
+ async listMyPrizes(_q: ActivityPlayPrizeQueryContext): Promise<ActivityPlayPrizeListResult> {
160
+ return { total: PRIZES.length, items: [...PRIZES] };
161
+ }
162
+
163
+ async getMyPrizeDetail(
164
+ _q: ActivityPlayPrizeQueryContext,
165
+ prizeRecordRef: string,
166
+ ): Promise<ActivityPlayPrizeDetail | null> {
167
+ const hit = PRIZES.find((p) => p.prizeRecordRef === prizeRecordRef);
168
+ const extra = PRIZE_DETAIL_EXTRA[prizeRecordRef];
169
+ return hit && extra ? { ...hit, ...extra } : null;
170
+ }
171
+ }
@@ -1,7 +1,8 @@
1
1
  /**
2
2
  * Mock Provider 包服务端入口(provider 拆包 F1b)。
3
3
  *
4
- * 17 槽 local 供给(member×5 / parking×3 / promotion×4 / guide×4 + mall.info;manifest
4
+ * 20 槽 local 供给(member×5 / parking×3 / promotion×4 / guide×4 + mall.info +
5
+ * auth.alipay-login 换码 + activity-play.query/prizes 演示供给;manifest
5
6
  * contributes.providers.slots,local:true): 模块 ports
6
7
  * slot 一行化后经 createIntegrationsRegistry.resolveService 解析——local 短路免传输/
7
8
  * 凭据/实例配置。实现自持(provider 不得依赖业务模块——workspace-dag 铁律),
@@ -43,11 +44,13 @@ import { MockParkingServiceImpl } from './parking';
43
44
  import { MockPromotionServiceImpl } from './promotion';
44
45
  import { MockShoppingServiceImpl } from './shopping';
45
46
  import { MOCK_MALL_INFO_PROVIDER, MOCK_MALL_INFO_IMPL, mockMallInfoFactory } from './mall-info';
47
+ import { MockActivityPlayServiceImpl } from './activity-play';
46
48
  import { createMockEnrollRouter } from './mock-enroll-route';
47
49
 
48
50
  export const MOCK_PROVIDER = 'mock';
49
51
  export const MOCK_MEMBER_IMPL = 'mock-member@1';
50
52
  export const MOCK_PARKING_IMPL = 'mock-parking@1';
53
+ export const MOCK_ACTIVITY_PLAY_IMPL = 'mock-activity-play@1';
51
54
  export const MOCK_PROMOTION_IMPL = 'mock-promotion@1';
52
55
  export const MOCK_SHOPPING_IMPL = 'mock-shopping@1';
53
56
 
@@ -56,6 +59,7 @@ export { MockParkingServiceImpl, __resetMockParkingState } from './parking';
56
59
  export { MockPromotionServiceImpl } from './promotion';
57
60
  export { MockShoppingServiceImpl } from './shopping';
58
61
  export { MOCK_MALL_INFO_PROVIDER, MOCK_MALL_INFO_IMPL, mockMallInfoFactory } from './mall-info';
62
+ export { MockActivityPlayServiceImpl } from './activity-play';
59
63
  export { createMockEnrollRouter } from './mock-enroll-route';
60
64
 
61
65
  const memberFactory: ServiceAdapterFactory = () => new MockMemberServiceImpl({});
@@ -76,6 +80,9 @@ const shoppingFactory: ServiceAdapterFactory = (input) => {
76
80
  };
77
81
  /** mall.info:动态商场演示源(任意合法 mallId → 确定性别名;对齐真实厂商 mall-info adapter 通用形态) */
78
82
  const mallInfoFactory: ServiceAdapterFactory = (input) => mockMallInfoFactory(input);
83
+ /** activity-play:双槽(query/prizes)一实现——结构类型满足两 Port(shopping 四槽同范式);
84
+ * 演示面 = 三活动状态枚举 + 三奖品状态桶,不消费 config(演示常量自持 impl——零配置语义)。 */
85
+ const activityPlayFactory: ServiceAdapterFactory = () => new MockActivityPlayServiceImpl();
79
86
 
80
87
  /**
81
88
  * scoped mock 换码器(register 期闭包 ctx.integrations——matches 谓词零 IO 纪律):
@@ -175,6 +182,7 @@ export const serverModule = {
175
182
  ctx.integrations?.registerAdapter(MOCK_PROVIDER, MOCK_PROMOTION_IMPL, promotionFactory);
176
183
  ctx.integrations?.registerAdapter(MOCK_PROVIDER, MOCK_SHOPPING_IMPL, shoppingFactory);
177
184
  ctx.integrations?.registerAdapter(MOCK_MALL_INFO_PROVIDER, MOCK_MALL_INFO_IMPL, mallInfoFactory);
185
+ ctx.integrations?.registerAdapter(MOCK_PROVIDER, MOCK_ACTIVITY_PLAY_IMPL, activityPlayFactory);
178
186
  // scoped mock 换码器(member.account 绑 mock 的部署命中;其他部署不路由本包)
179
187
  ctx.authExchanges.register(createMockAlipayLoginExchange({
180
188
  integrations: ctx.integrations,
package/tbox.module.json CHANGED
@@ -149,6 +149,20 @@
149
149
  "local": true,
150
150
  "provider": "mock",
151
151
  "implementation": "mock-auth@1"
152
+ },
153
+ {
154
+ "service": "activity-play.query",
155
+ "credentialType": "-",
156
+ "local": true,
157
+ "provider": "mock",
158
+ "implementation": "mock-activity-play@1"
159
+ },
160
+ {
161
+ "service": "activity-play.prizes",
162
+ "credentialType": "-",
163
+ "local": true,
164
+ "provider": "mock",
165
+ "implementation": "mock-activity-play@1"
152
166
  }
153
167
  ]
154
168
  },
@@ -0,0 +1,85 @@
1
+ /**
2
+ * provider-mock activity-play 演示供给单测(2026-11-25 加装——query/prizes 双槽)。
3
+ * 契约锁:Port 四方法形、demo ref 厂商中立、状态枚举/桶覆盖(活动三态、奖品
4
+ * USABLE/USED/UNKNOWN)、keyword/limit 适配层语义与 hupo 同值(大小写不敏感包含 +
5
+ * limit 钳制兜底——消费方 schema 先拦越界)、详情 null 语义、注册形态(双槽同
6
+ * implementation——结构类型满足两 Port)。
7
+ */
8
+ import { describe, expect, it } from 'vitest';
9
+ import { MockActivityPlayServiceImpl, MOCK_ACTIVITY_PLAY_IMPL, MOCK_PROVIDER, serverModule } from '../src/server/index';
10
+ import {
11
+ activityPlayActivitySchema,
12
+ activityPlayPrizeDetailSchema,
13
+ activityPlayPrizeRecordSchema,
14
+ } from '@tbox.cn/app-contracts-mall';
15
+
16
+ const q = { mallId: 'mall-demo' } as never; // query context 形参(mock 实现忽略——单测体面占位)
17
+ const pq = { mallId: 'mall-demo', subjectId: 'guest_123' } as never; // prize context(同上)
18
+
19
+ const impl = new MockActivityPlayServiceImpl();
20
+
21
+ describe('provider-mock activity-play:契约面与注册形态', () => {
22
+ it('双槽 Port 四方法齐(契约方法锁——防少方法回归)', () => {
23
+ expect(typeof impl.listActivities).toBe('function');
24
+ expect(typeof impl.getActivity).toBe('function');
25
+ expect(typeof impl.listMyPrizes).toBe('function');
26
+ expect(typeof impl.getMyPrizeDetail).toBe('function');
27
+ });
28
+
29
+ it('注册形态:provider=mock + 双槽恒同 implementation', () => {
30
+ expect(MOCK_PROVIDER).toBe('mock');
31
+ expect(MOCK_ACTIVITY_PLAY_IMPL).toBe('mock-activity-play@1');
32
+ expect(serverModule.declaration.moduleId).toBe('provider-mock');
33
+ });
34
+ });
35
+
36
+ describe('provider-mock activity-play:活动查询(演示面)', () => {
37
+ it('列表 = 三活动(active/ended/not_started 三态覆盖),全部过契约 strict schema', async () => {
38
+ const { items } = await impl.listActivities(q, {});
39
+ expect(items).toHaveLength(3);
40
+ expect([...new Set(items.map((a) => a.status))].sort()).toEqual(['active', 'ended', 'not_started']);
41
+ for (const a of items) expect(activityPlayActivitySchema.safeParse(a).success).toBe(true);
42
+ });
43
+
44
+ it('keyword 包含过滤(名称/说明命中;未命词 → 空集)', async () => {
45
+ const hit = await impl.listActivities(q, { keyword: '砸金蛋' });
46
+ expect(hit.items.map((a) => a.activityId)).toEqual(['demo:activity:eggs']);
47
+ const miss = await impl.listActivities(q, { keyword: '不存在的关键词' });
48
+ expect(miss.items).toEqual([]);
49
+ });
50
+
51
+ it('limit=1 → 截为一条(钳制兜底——消费方 schema 先拦越界)', async () => {
52
+ const { items } = await impl.listActivities(q, { limit: 1 });
53
+ expect(items).toHaveLength(1);
54
+ });
55
+
56
+ it('getActivity:hit 返回同一活动;未知/不可见 → null', async () => {
57
+ expect((await impl.getActivity(q, 'demo:activity:wheel'))?.title).toBe('大转盘赢好礼');
58
+ expect(await impl.getActivity(q, 'demo:activity:nosuch')).toBeNull();
59
+ });
60
+ });
61
+
62
+ describe('provider-mock activity-play:本人奖品(演示面)', () => {
63
+ it('列表 = 三枚(USABLE/USED/UNKNOWN 三桶),schema 全过 + demo ref 中立', async () => {
64
+ const r = await impl.listMyPrizes(pq);
65
+ expect(r.total).toBe(3);
66
+ expect([...new Set(r.items.map((p) => p.useStatus))].sort()).toEqual(['UNKNOWN', 'USABLE', 'USED']);
67
+ for (const p of r.items) {
68
+ expect(activityPlayPrizeRecordSchema.safeParse(p).success).toBe(true);
69
+ expect(p.prizeRecordRef.startsWith('demo:')).toBe(true);
70
+ }
71
+ });
72
+
73
+ it('详情:hit 含领取方式/说明形态并过 detail schema;未知 ref → null', async () => {
74
+ const d = await impl.getMyPrizeDetail(pq, 'demo:prize:coffee');
75
+ expect(d?.redemptionMethod).toBeDefined();
76
+ expect(activityPlayPrizeDetailSchema.safeParse(d).success).toBe(true);
77
+ expect(await impl.getMyPrizeDetail(pq, 'demo:prize:nosuch')).toBeNull();
78
+ });
79
+
80
+ it('零状态——重复查询幂等(同一部署恒同结果)', async () => {
81
+ const a = await impl.listMyPrizes(pq);
82
+ const b = await impl.listMyPrizes(pq);
83
+ expect(a.items.map((p) => p.prizeRecordRef)).toEqual(b.items.map((p) => p.prizeRecordRef));
84
+ });
85
+ });
@@ -92,7 +92,7 @@ const zeroTopology = {
92
92
  describe('F2 端到端:provider-mock 经槽位轴解析', () => {
93
93
  it('register(经 ctx.integrations)→ resolveService 三槽产出 mock 实现', async () => {
94
94
  const { ctx, registry } = fixtureCtx();
95
- expect(registry.listAdapters()).toEqual(['mock\u0000mock-member@1', 'mock\u0000mock-parking@1', 'mock\u0000mock-promotion@1', 'mock\u0000mock-shopping@1', 'mock\u0000mock-mall-info@1']);
95
+ expect(registry.listAdapters()).toEqual(['mock\u0000mock-member@1', 'mock\u0000mock-parking@1', 'mock\u0000mock-promotion@1', 'mock\u0000mock-shopping@1', 'mock\u0000mock-mall-info@1', 'mock\u0000mock-activity-play@1']);
96
96
 
97
97
  const member = (await ctx.integrations!.resolveService({
98
98
  service: 'member.account',
@@ -187,7 +187,7 @@ describe('provider-mock:mock 实现 Port 面与厂商中立', () => {
187
187
  });
188
188
 
189
189
  describe('provider-mock:serverModule 形态(无卡模块 + adapter 注册)', () => {
190
- it('cards 空 map + register 注册六 adapter/换码器/路由(真实 ServerContext 面)', () => {
190
+ it('cards 空 map + register 注册六 adapter + 换码器 + 路由(真实 ServerContext 面;activity-play 演示槽 2026-11-25)', () => {
191
191
  expect(Object.keys(serverModule.cards)).toHaveLength(0);
192
192
  expect(serverModule.declaration.moduleId).toBe('provider-mock');
193
193
  const registered: Array<[string, string, unknown]> = [];
@@ -205,6 +205,7 @@ describe('provider-mock:serverModule 形态(无卡模块 + adapter 注册)
205
205
  'mock\u0000mock-promotion@1',
206
206
  'mock\u0000mock-shopping@1',
207
207
  'mock\u0000mock-mall-info@1',
208
+ 'mock\u0000mock-activity-play@1',
208
209
  ]);
209
210
  // 入会闭环接线:scoped alipay 换码器 + demo 入会路由
210
211
  expect(exchangers).toEqual(['alipay']);