@pisell/pisellos 2.1.119 → 2.1.121

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.
Files changed (231) hide show
  1. package/dist/apis/picoding.d.ts +0 -0
  2. package/dist/apis/picoding.js +1 -0
  3. package/dist/model/index.d.ts +1 -0
  4. package/dist/model/index.js +1 -0
  5. package/dist/model/strategy/adapter/index.d.ts +7 -0
  6. package/dist/model/strategy/adapter/index.js +7 -0
  7. package/dist/model/strategy/adapter/itemRule/adapter.d.ts +59 -0
  8. package/dist/model/strategy/adapter/itemRule/adapter.js +439 -0
  9. package/dist/model/strategy/adapter/itemRule/evaluator.d.ts +43 -0
  10. package/dist/model/strategy/adapter/itemRule/evaluator.js +169 -0
  11. package/dist/model/strategy/adapter/itemRule/examples.d.ts +64 -0
  12. package/dist/model/strategy/adapter/itemRule/examples.js +315 -0
  13. package/dist/model/strategy/adapter/itemRule/index.d.ts +5 -0
  14. package/dist/model/strategy/adapter/itemRule/index.js +5 -0
  15. package/dist/model/strategy/adapter/itemRule/type.d.ts +206 -0
  16. package/dist/model/strategy/adapter/itemRule/type.js +101 -0
  17. package/dist/model/strategy/adapter/promotion/adapter.d.ts +66 -0
  18. package/dist/model/strategy/adapter/promotion/adapter.js +271 -0
  19. package/dist/model/strategy/adapter/promotion/evaluator.d.ts +213 -0
  20. package/dist/model/strategy/adapter/promotion/evaluator.js +1206 -0
  21. package/dist/model/strategy/adapter/promotion/examples.d.ts +138 -0
  22. package/dist/model/strategy/adapter/promotion/examples.js +166 -0
  23. package/dist/model/strategy/adapter/promotion/index.d.ts +4 -0
  24. package/dist/model/strategy/adapter/promotion/index.js +0 -0
  25. package/dist/model/strategy/adapter/promotion/type.d.ts +447 -0
  26. package/dist/model/strategy/adapter/promotion/type.js +209 -0
  27. package/dist/model/strategy/adapter/type.d.ts +28 -0
  28. package/dist/model/strategy/adapter/type.js +1 -0
  29. package/dist/model/strategy/adapter/walletPass/evaluator.d.ts +84 -0
  30. package/dist/model/strategy/adapter/walletPass/evaluator.js +502 -0
  31. package/dist/model/strategy/adapter/walletPass/example.d.ts +4 -0
  32. package/dist/model/strategy/adapter/walletPass/example.js +258 -0
  33. package/dist/model/strategy/adapter/walletPass/index.d.ts +32 -0
  34. package/dist/model/strategy/adapter/walletPass/index.js +182 -0
  35. package/dist/model/strategy/adapter/walletPass/locales.d.ts +1 -0
  36. package/dist/model/strategy/adapter/walletPass/locales.js +26 -0
  37. package/dist/model/strategy/adapter/walletPass/type.d.ts +187 -0
  38. package/dist/model/strategy/adapter/walletPass/type.js +1 -0
  39. package/dist/model/strategy/adapter/walletPass/utils.d.ts +50 -0
  40. package/dist/model/strategy/adapter/walletPass/utils.js +1104 -0
  41. package/dist/model/strategy/engine.d.ts +106 -0
  42. package/dist/model/strategy/engine.js +611 -0
  43. package/dist/model/strategy/index.d.ts +3 -0
  44. package/dist/model/strategy/index.js +8 -0
  45. package/dist/model/strategy/strategy-example.d.ts +5 -0
  46. package/dist/model/strategy/strategy-example.js +331 -0
  47. package/dist/model/strategy/type.d.ts +228 -0
  48. package/dist/model/strategy/type.js +94 -0
  49. package/dist/modules/Cart/utils/cartProduct.js +1 -0
  50. package/dist/modules/OpenData/index.d.ts +24 -0
  51. package/dist/modules/OpenData/index.js +173 -0
  52. package/dist/modules/OpenData/types.d.ts +73 -0
  53. package/dist/modules/OpenData/types.js +1 -0
  54. package/dist/modules/OpenData/utils.d.ts +2 -0
  55. package/dist/modules/OpenData/utils.js +75 -0
  56. package/dist/modules/Order/index.d.ts +58 -1
  57. package/dist/modules/Order/index.js +796 -29
  58. package/dist/modules/Order/types.d.ts +144 -12
  59. package/dist/modules/Order/utils.d.ts +28 -0
  60. package/dist/modules/Order/utils.js +250 -1
  61. package/dist/modules/Product/index.d.ts +1 -1
  62. package/dist/modules/Product/utils.js +2 -2
  63. package/dist/modules/ProductList/index.d.ts +1 -1
  64. package/dist/modules/ProductList/index.js +2 -1
  65. package/dist/modules/Quotation/index.d.ts +48 -0
  66. package/dist/modules/Quotation/index.js +245 -0
  67. package/dist/modules/Quotation/types.d.ts +42 -0
  68. package/dist/modules/Quotation/types.js +1 -0
  69. package/dist/modules/Rules/index.js +4 -1
  70. package/dist/modules/SalesSummary/index.d.ts +63 -0
  71. package/dist/modules/SalesSummary/index.js +174 -0
  72. package/dist/modules/SalesSummary/types.d.ts +59 -0
  73. package/dist/modules/SalesSummary/types.js +1 -0
  74. package/dist/modules/SalesSummary/utils.d.ts +30 -0
  75. package/dist/modules/SalesSummary/utils.js +513 -0
  76. package/dist/modules/ScanOrderLogger/index.d.ts +21 -0
  77. package/dist/modules/ScanOrderLogger/index.js +161 -0
  78. package/dist/modules/ScanOrderLogger/providers/feishu.d.ts +2 -0
  79. package/dist/modules/ScanOrderLogger/providers/feishu.js +95 -0
  80. package/dist/modules/ScanOrderLogger/providers/grafana.d.ts +2 -0
  81. package/dist/modules/ScanOrderLogger/providers/grafana.js +50 -0
  82. package/dist/modules/ScanOrderLogger/types.d.ts +46 -0
  83. package/dist/modules/ScanOrderLogger/types.js +1 -0
  84. package/dist/modules/Schedule/getDateIsInSchedule.js +11 -18
  85. package/dist/modules/Summary/utils.d.ts +3 -3
  86. package/dist/modules/Summary/utils.js +4 -4
  87. package/dist/modules/index.d.ts +4 -0
  88. package/dist/modules/index.js +5 -1
  89. package/dist/solution/BookingByStep/index.d.ts +1 -1
  90. package/dist/solution/BookingByStep/types.d.ts +3 -1
  91. package/dist/solution/BookingByStep/types.js +5 -1
  92. package/dist/solution/BookingTicket/index.d.ts +1 -1
  93. package/dist/solution/ScanOrder/index.d.ts +90 -0
  94. package/dist/solution/ScanOrder/index.js +1853 -0
  95. package/dist/solution/ScanOrder/types.d.ts +210 -0
  96. package/dist/solution/ScanOrder/types.js +16 -0
  97. package/dist/solution/ScanOrder/utils.d.ts +93 -0
  98. package/dist/solution/ScanOrder/utils.js +397 -0
  99. package/dist/solution/VenueBooking/index.d.ts +163 -0
  100. package/dist/solution/VenueBooking/index.js +2931 -0
  101. package/dist/solution/VenueBooking/sales-section-4-annotated.json +343 -0
  102. package/dist/solution/VenueBooking/types.d.ts +130 -0
  103. package/dist/solution/VenueBooking/types.js +21 -0
  104. package/dist/solution/VenueBooking/utils/dateSummary.d.ts +10 -0
  105. package/dist/solution/VenueBooking/utils/dateSummary.js +102 -0
  106. package/dist/solution/VenueBooking/utils/resource.d.ts +4 -0
  107. package/dist/solution/VenueBooking/utils/resource.js +94 -0
  108. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +29 -0
  109. package/dist/solution/VenueBooking/utils/slotMerge.js +203 -0
  110. package/dist/solution/VenueBooking/utils/timeSlot.d.ts +32 -0
  111. package/dist/solution/VenueBooking/utils/timeSlot.js +256 -0
  112. package/dist/solution/VenueBooking/utils.d.ts +1 -0
  113. package/dist/solution/VenueBooking/utils.js +1 -0
  114. package/dist/solution/index.d.ts +2 -0
  115. package/dist/solution/index.js +3 -1
  116. package/lib/apis/picoding.d.ts +0 -0
  117. package/lib/apis/picoding.js +0 -0
  118. package/lib/model/index.d.ts +1 -0
  119. package/lib/model/index.js +23 -0
  120. package/lib/model/strategy/adapter/index.d.ts +7 -0
  121. package/lib/model/strategy/adapter/index.js +57 -0
  122. package/lib/model/strategy/adapter/itemRule/adapter.d.ts +59 -0
  123. package/lib/model/strategy/adapter/itemRule/adapter.js +338 -0
  124. package/lib/model/strategy/adapter/itemRule/evaluator.d.ts +43 -0
  125. package/lib/model/strategy/adapter/itemRule/evaluator.js +124 -0
  126. package/lib/model/strategy/adapter/itemRule/examples.d.ts +64 -0
  127. package/lib/model/strategy/adapter/itemRule/examples.js +269 -0
  128. package/lib/model/strategy/adapter/itemRule/index.d.ts +5 -0
  129. package/lib/model/strategy/adapter/itemRule/index.js +58 -0
  130. package/lib/model/strategy/adapter/itemRule/type.d.ts +206 -0
  131. package/lib/model/strategy/adapter/itemRule/type.js +46 -0
  132. package/lib/model/strategy/adapter/promotion/adapter.d.ts +66 -0
  133. package/lib/model/strategy/adapter/promotion/adapter.js +217 -0
  134. package/lib/model/strategy/adapter/promotion/evaluator.d.ts +213 -0
  135. package/lib/model/strategy/adapter/promotion/evaluator.js +844 -0
  136. package/lib/model/strategy/adapter/promotion/examples.d.ts +138 -0
  137. package/lib/model/strategy/adapter/promotion/examples.js +192 -0
  138. package/lib/model/strategy/adapter/promotion/index.d.ts +4 -0
  139. package/lib/model/strategy/adapter/promotion/index.js +49 -0
  140. package/lib/model/strategy/adapter/promotion/type.d.ts +447 -0
  141. package/lib/model/strategy/adapter/promotion/type.js +51 -0
  142. package/lib/model/strategy/adapter/type.d.ts +28 -0
  143. package/lib/model/strategy/adapter/type.js +17 -0
  144. package/lib/model/strategy/adapter/walletPass/evaluator.d.ts +84 -0
  145. package/lib/model/strategy/adapter/walletPass/evaluator.js +424 -0
  146. package/lib/model/strategy/adapter/walletPass/example.d.ts +4 -0
  147. package/lib/model/strategy/adapter/walletPass/example.js +207 -0
  148. package/lib/model/strategy/adapter/walletPass/index.d.ts +32 -0
  149. package/lib/model/strategy/adapter/walletPass/index.js +142 -0
  150. package/lib/model/strategy/adapter/walletPass/locales.d.ts +1 -0
  151. package/lib/model/strategy/adapter/walletPass/locales.js +54 -0
  152. package/lib/model/strategy/adapter/walletPass/type.d.ts +187 -0
  153. package/lib/model/strategy/adapter/walletPass/type.js +17 -0
  154. package/lib/model/strategy/adapter/walletPass/utils.d.ts +50 -0
  155. package/lib/model/strategy/adapter/walletPass/utils.js +791 -0
  156. package/lib/model/strategy/engine.d.ts +106 -0
  157. package/lib/model/strategy/engine.js +450 -0
  158. package/lib/model/strategy/index.d.ts +3 -0
  159. package/lib/model/strategy/index.js +38 -0
  160. package/lib/model/strategy/strategy-example.d.ts +5 -0
  161. package/lib/model/strategy/strategy-example.js +318 -0
  162. package/lib/model/strategy/type.d.ts +228 -0
  163. package/lib/model/strategy/type.js +44 -0
  164. package/lib/modules/Cart/utils/cartProduct.js +1 -0
  165. package/lib/modules/OpenData/index.d.ts +24 -0
  166. package/lib/modules/OpenData/index.js +119 -0
  167. package/lib/modules/OpenData/types.d.ts +73 -0
  168. package/lib/modules/OpenData/types.js +17 -0
  169. package/lib/modules/OpenData/utils.d.ts +2 -0
  170. package/lib/modules/OpenData/utils.js +111 -0
  171. package/lib/modules/Order/index.d.ts +58 -1
  172. package/lib/modules/Order/index.js +437 -1
  173. package/lib/modules/Order/types.d.ts +144 -12
  174. package/lib/modules/Order/utils.d.ts +28 -0
  175. package/lib/modules/Order/utils.js +250 -2
  176. package/lib/modules/Product/index.d.ts +1 -1
  177. package/lib/modules/Product/utils.js +2 -2
  178. package/lib/modules/ProductList/index.d.ts +1 -1
  179. package/lib/modules/ProductList/index.js +2 -1
  180. package/lib/modules/Quotation/index.d.ts +48 -0
  181. package/lib/modules/Quotation/index.js +149 -0
  182. package/lib/modules/Quotation/types.d.ts +42 -0
  183. package/lib/modules/Quotation/types.js +17 -0
  184. package/lib/modules/Rules/index.js +4 -1
  185. package/lib/modules/SalesSummary/index.d.ts +63 -0
  186. package/lib/modules/SalesSummary/index.js +105 -0
  187. package/lib/modules/SalesSummary/types.d.ts +59 -0
  188. package/lib/modules/SalesSummary/types.js +17 -0
  189. package/lib/modules/SalesSummary/utils.d.ts +30 -0
  190. package/lib/modules/SalesSummary/utils.js +452 -0
  191. package/lib/modules/ScanOrderLogger/index.d.ts +21 -0
  192. package/lib/modules/ScanOrderLogger/index.js +135 -0
  193. package/lib/modules/ScanOrderLogger/providers/feishu.d.ts +2 -0
  194. package/lib/modules/ScanOrderLogger/providers/feishu.js +82 -0
  195. package/lib/modules/ScanOrderLogger/providers/grafana.d.ts +2 -0
  196. package/lib/modules/ScanOrderLogger/providers/grafana.js +52 -0
  197. package/lib/modules/ScanOrderLogger/types.d.ts +46 -0
  198. package/lib/modules/ScanOrderLogger/types.js +17 -0
  199. package/lib/modules/Schedule/getDateIsInSchedule.js +9 -11
  200. package/lib/modules/Summary/utils.d.ts +3 -3
  201. package/lib/modules/Summary/utils.js +4 -4
  202. package/lib/modules/index.d.ts +4 -0
  203. package/lib/modules/index.js +9 -1
  204. package/lib/solution/BookingByStep/index.d.ts +1 -1
  205. package/lib/solution/BookingByStep/types.d.ts +3 -1
  206. package/lib/solution/BookingByStep/types.js +10 -0
  207. package/lib/solution/BookingTicket/index.d.ts +1 -1
  208. package/lib/solution/ScanOrder/index.d.ts +90 -0
  209. package/lib/solution/ScanOrder/index.js +1071 -0
  210. package/lib/solution/ScanOrder/types.d.ts +210 -0
  211. package/lib/solution/ScanOrder/types.js +36 -0
  212. package/lib/solution/ScanOrder/utils.d.ts +93 -0
  213. package/lib/solution/ScanOrder/utils.js +359 -0
  214. package/lib/solution/VenueBooking/index.d.ts +163 -0
  215. package/lib/solution/VenueBooking/index.js +1578 -0
  216. package/lib/solution/VenueBooking/sales-section-4-annotated.json +343 -0
  217. package/lib/solution/VenueBooking/types.d.ts +130 -0
  218. package/lib/solution/VenueBooking/types.js +44 -0
  219. package/lib/solution/VenueBooking/utils/dateSummary.d.ts +10 -0
  220. package/lib/solution/VenueBooking/utils/dateSummary.js +101 -0
  221. package/lib/solution/VenueBooking/utils/resource.d.ts +4 -0
  222. package/lib/solution/VenueBooking/utils/resource.js +80 -0
  223. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +29 -0
  224. package/lib/solution/VenueBooking/utils/slotMerge.js +208 -0
  225. package/lib/solution/VenueBooking/utils/timeSlot.d.ts +32 -0
  226. package/lib/solution/VenueBooking/utils/timeSlot.js +200 -0
  227. package/lib/solution/VenueBooking/utils.d.ts +1 -0
  228. package/lib/solution/VenueBooking/utils.js +69 -0
  229. package/lib/solution/index.d.ts +2 -0
  230. package/lib/solution/index.js +5 -1
  231. package/package.json +1 -1
@@ -0,0 +1,142 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/model/strategy/adapter/walletPass/index.ts
20
+ var walletPass_exports = {};
21
+ __export(walletPass_exports, {
22
+ default: () => WalletPassAdapter
23
+ });
24
+ module.exports = __toCommonJS(walletPass_exports);
25
+ var import_utils = require("./utils");
26
+ var WalletPassAdapter = class {
27
+ constructor() {
28
+ this.name = "WalletPassAdapter";
29
+ this.version = "1.0.0";
30
+ }
31
+ /**
32
+ * 准备运行时上下文
33
+ * 将业务数据转换为策略引擎可识别的 RuntimeContext
34
+ */
35
+ prepareContext(businessData) {
36
+ var _a, _b;
37
+ const { orderTotalAmount, products, voucher, strategyConfig } = businessData;
38
+ const productIds = products.map((p) => p.product_id);
39
+ const applicableProductIds = (0, import_utils.getApplicableProductIds)(voucher);
40
+ const deductTaxAndFee = ((_b = (_a = strategyConfig == null ? void 0 : strategyConfig.metadata) == null ? void 0 : _a.custom) == null ? void 0 : _b.deductTaxAndFee) ?? true;
41
+ const { applicableTotal, applicableCount } = this.calculateApplicableProducts(
42
+ products,
43
+ applicableProductIds,
44
+ deductTaxAndFee
45
+ );
46
+ return {
47
+ entities: {
48
+ voucher,
49
+ products,
50
+ order: {
51
+ orderTotalAmount,
52
+ products
53
+ }
54
+ },
55
+ attributes: {
56
+ // 订单消费金额
57
+ orderTotalAmount,
58
+ // 适用商品金额
59
+ applicableProductTotalAmount: applicableTotal,
60
+ // 适用商品购买数量
61
+ applicableProductCount: applicableCount,
62
+ // 当前评估的 voucher ID
63
+ voucherProductId: voucher.product_id,
64
+ // 订单中的商品ID
65
+ productIds
66
+ },
67
+ metadata: {
68
+ timestamp: Date.now()
69
+ }
70
+ };
71
+ }
72
+ /**
73
+ * 转换执行结果
74
+ * 将策略引擎的通用结果转换为业务层需要的格式
75
+ */
76
+ transformResult(result, businessData) {
77
+ const strategyConfig = businessData == null ? void 0 : businessData.strategyConfig;
78
+ const businessConfig = (strategyConfig == null ? void 0 : strategyConfig.metadata.custom) || {};
79
+ const voucher = businessData == null ? void 0 : businessData.voucher;
80
+ const applicableProductIds = voucher ? (0, import_utils.getApplicableProductIds)(voucher) : null;
81
+ if (!result.applicable) {
82
+ return {
83
+ isApplicable: false,
84
+ canUseCount: 0,
85
+ maxDeduction: 0,
86
+ deductTaxAndFee: false,
87
+ applicableProductIds: [],
88
+ reason: result.message,
89
+ reasonCode: result.code,
90
+ strategyResult: result
91
+ };
92
+ }
93
+ const maxDeduction = businessConfig.maxDeductionAmount || 0;
94
+ const canUseCount = businessConfig.maxUsagePerOrder || 0;
95
+ const deductTaxAndFee = businessConfig.deductTaxAndFee || false;
96
+ return {
97
+ isApplicable: true,
98
+ canUseCount,
99
+ maxDeduction,
100
+ deductTaxAndFee,
101
+ applicableProductIds: applicableProductIds || [],
102
+ strategyResult: result
103
+ };
104
+ }
105
+ /**
106
+ * 格式化配置
107
+ */
108
+ formatConfig(result, businessData) {
109
+ return { result, businessData };
110
+ }
111
+ /**
112
+ * 计算适用商品的总金额和数量
113
+ */
114
+ calculateApplicableProducts(products, applicableProductIds, deductTaxAndFee = true) {
115
+ let total = 0;
116
+ let count = 0;
117
+ if (applicableProductIds !== null && applicableProductIds.length === 0) {
118
+ return { applicableTotal: 0, applicableCount: 0 };
119
+ }
120
+ products.forEach((product) => {
121
+ const productQuantity = (0, import_utils.getProductQuantity)(product);
122
+ const isMainProductApplicable = applicableProductIds === null || applicableProductIds.includes(product.product_id);
123
+ if (isMainProductApplicable) {
124
+ total += (0, import_utils.getMainProductPrice)(product, deductTaxAndFee) * productQuantity;
125
+ count += productQuantity;
126
+ }
127
+ if (product.product_bundle && product.product_bundle.length > 0) {
128
+ product.product_bundle.forEach((bundleItem) => {
129
+ if ((0, import_utils.getBundleItemIsOriginalPrice)(bundleItem)) {
130
+ const isBundleItemApplicable = applicableProductIds === null || applicableProductIds.includes(bundleItem.bundle_product_id);
131
+ if (isBundleItemApplicable) {
132
+ const bundleItemQuantity = bundleItem.num * productQuantity;
133
+ total += (0, import_utils.getBundleItemPrice)(bundleItem, productQuantity, deductTaxAndFee);
134
+ count += bundleItemQuantity;
135
+ }
136
+ }
137
+ });
138
+ }
139
+ });
140
+ return { applicableTotal: total, applicableCount: count };
141
+ }
142
+ };
@@ -0,0 +1 @@
1
+ export declare const locales: Record<string, Record<string, string>>;
@@ -0,0 +1,54 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/model/strategy/adapter/walletPass/locales.ts
20
+ var locales_exports = {};
21
+ __export(locales_exports, {
22
+ locales: () => locales
23
+ });
24
+ module.exports = __toCommonJS(locales_exports);
25
+ var locales = {
26
+ "zh-CN": {
27
+ "not_meet_the_required_conditions": "未达到使用条件",
28
+ "exceeds_the_maximum_deduction_limit": "超出最大抵扣金额限制",
29
+ "usage_limit_reached": "已达到使用次数上限",
30
+ "max_passes_per_item_reached": "该商品已达到卡券使用上限",
31
+ "not_available_for_this_channel": "当前渠道不可使用",
32
+ "not_valid_for_this_order_type": "当前订单类型不适用"
33
+ },
34
+ "en": {
35
+ "not_meet_the_required_conditions": "Not meet the required conditions.",
36
+ "exceeds_the_maximum_deduction_limit": "Exceeds the maximum deduction limit.",
37
+ "usage_limit_reached": "Usage limit reached.",
38
+ "max_passes_per_item_reached": "Max passes per item reached.",
39
+ "not_available_for_this_channel": "Not available for this channel.",
40
+ "not_valid_for_this_order_type": "Not valid for this order type."
41
+ },
42
+ "zh-HK": {
43
+ "not_meet_the_required_conditions": "未達使用條件",
44
+ "exceeds_the_maximum_deduction_limit": "超出最大抵扣金額限制",
45
+ "usage_limit_reached": "已達使用次數上限",
46
+ "max_passes_per_item_reached": "該商品已達卡券使用上限",
47
+ "not_available_for_this_channel": "當前渠道不可使用",
48
+ "not_valid_for_this_order_type": "當前訂單類型不適用"
49
+ }
50
+ };
51
+ // Annotate the CommonJS export names for ESM import in node:
52
+ 0 && (module.exports = {
53
+ locales
54
+ });
@@ -0,0 +1,187 @@
1
+ import { EvaluationResult, StrategyConfig } from '../../type';
2
+ /**
3
+ * Voucher 数据结构
4
+ */
5
+ export interface Voucher {
6
+ id: number;
7
+ amount: number;
8
+ balance: number;
9
+ type?: string;
10
+ usedCount?: number;
11
+ available_product_type?: 'product_all' | 'product_collection' | 'products';
12
+ available_product_ids?: number[];
13
+ product_id: number;
14
+ unified_available_status: number;
15
+ /** 用户手动编辑的金额,优先于 recommended_usage_amount 使用 */
16
+ edit_current_amount?: number;
17
+ /** 前端基于策略返回的 不可用状态 */
18
+ _unified_available_status?: number;
19
+ /** 前端基于策略返回的 可用最大金额 */
20
+ _available_max_amount?: number;
21
+ /** 前端基于策略返回的 不可用原因 */
22
+ reason?: string;
23
+ /** 前端基于策略返回的 不可用原因码 */
24
+ reasonCode?: string;
25
+ /** 后端计算推荐使用金额 */
26
+ recommended_usage_amount: number;
27
+ /** 后端计算推荐使用金额(仅商品) 不包含税费附加费 */
28
+ recommended_pure_product_usage_amount: number;
29
+ /** 实际抵扣金额 */
30
+ actualDeduction: number;
31
+ /** 抵扣详情 */
32
+ deductionDetails: any[];
33
+ config?: {
34
+ /** 最大抵扣金额 */
35
+ maxDeductionAmount: number;
36
+ /** 每单最多使用张数(同一 product_id 的券)。默认为 0,表示不限制数量。 */
37
+ maxUsagePerOrder: number;
38
+ /** 是否抵扣税费与附加费 */
39
+ deductTaxAndFee: boolean;
40
+ /** 适用粒度(多商品共用) 默认开启勾选项 */
41
+ allowCrossProduct: boolean;
42
+ /** 可用商品数量上限 (仅多商品) 默认为0,表示不限制商品数量。 */
43
+ applicableProductLimit: number;
44
+ /** 单订单行每单位可用同一 Wallet Pass 券次数;该行总券次上限 = maxPassesPerItem × 该行 quantity(按行唯一键区分)。0 表示不限制。 */
45
+ maxPassesPerItem: number;
46
+ /** 是否抵扣单规格价格 (Option Price),默认 false。开启后折扣范围包含 option 的 add_price */
47
+ deductOptionPrice: boolean;
48
+ };
49
+ }
50
+ /**
51
+ * 商品数据结构
52
+ */
53
+ export interface Product {
54
+ product_id: number;
55
+ /** 订单明细 id,参与行唯一键兜底解析 */
56
+ id?: number;
57
+ /** 行级唯一串,参与行唯一键解析 */
58
+ product_unique_string?: string;
59
+ price: number;
60
+ quantity: number;
61
+ name?: string;
62
+ selling_price?: number;
63
+ /** 主商品折扣前金额,不包含套餐子商品 */
64
+ main_product_original_price?: number;
65
+ /** 主商品折扣后金额,不包含套餐子商品 */
66
+ main_product_selling_price?: number;
67
+ /** 单规格(Option)列表 */
68
+ product_options?: {
69
+ id: number;
70
+ add_price: number | string;
71
+ num: number;
72
+ [key: string]: any;
73
+ }[];
74
+ /** 主商品税费 */
75
+ tax_fee: number;
76
+ metadata: {
77
+ /** 行唯一标识,优先用于 Wallet Pass 按行配额 */
78
+ product_unique?: string;
79
+ unique_identification_number?: string;
80
+ main_product_attached_bundle_tax_fee?: number;
81
+ main_product_attached_bundle_surcharge_fee?: number;
82
+ surcharge_rounding_remainder?: number;
83
+ tax_fee_rounding_remainder?: number;
84
+ main_product_selling_price: number;
85
+ };
86
+ is_price_include_tax: 0 | 1;
87
+ product_bundle: {
88
+ is_price_include_tax: 0 | 1;
89
+ bundle_id: number;
90
+ bundle_product_id: number;
91
+ bundle_variant_id: number;
92
+ price_type: string;
93
+ price_type_ext: string;
94
+ bundle_selling_price: number;
95
+ num: number;
96
+ is_charge_tax: number;
97
+ tax_fee: number;
98
+ metadata: {
99
+ surcharge_fee: number;
100
+ surcharge_rounding_remainder?: number;
101
+ tax_fee_rounding_remainder?: number;
102
+ };
103
+ }[];
104
+ }
105
+ /**
106
+ * Voucher 评估结果
107
+ */
108
+ export interface VoucherEvaluationResult {
109
+ voucher: Voucher;
110
+ /** 是否可用 */
111
+ isApplicable: boolean;
112
+ /** 每单可使用张数 */
113
+ canUseCount: number;
114
+ /** 最大抵扣金额 */
115
+ maxDeduction: number;
116
+ /** 是否抵扣税费与附加费 */
117
+ deductTaxAndFee: boolean;
118
+ /** 适用商品ID列表 */
119
+ applicableProductIds: number[];
120
+ /** 不可用原因 */
121
+ reason?: string;
122
+ /** 不可用原因码 */
123
+ reasonCode?: string;
124
+ strategyResult?: EvaluationResult;
125
+ }
126
+ /**
127
+ * 评估器输入参数
128
+ */
129
+ export interface EvaluatorInput {
130
+ /** 订单总金额 */
131
+ orderTotalAmount: number;
132
+ /** 商品列表 */
133
+ products: Product[];
134
+ /** 代金券列表 */
135
+ vouchers: Voucher[];
136
+ /** 策略配置列表 */
137
+ strategyConfigs?: StrategyConfig<{
138
+ /** 最大抵扣金额 */
139
+ maxDeductionAmount: number;
140
+ /** 每单最多使用张数(同一 product_id 的券)。默认为 0,表示不限制数量。 */
141
+ maxUsagePerOrder: number;
142
+ /** 是否抵扣税费与附加费 */
143
+ deductTaxAndFee: boolean;
144
+ /** 适用粒度(多商品共用) 默认开启勾选项 */
145
+ allowCrossProduct: boolean;
146
+ /** 可用商品数量上限 (仅多商品) 默认为0,表示不限制商品数量。 */
147
+ applicableProductLimit: number;
148
+ /** 单订单行每单位可用同一 Wallet Pass 券次数;行总上限 = maxPassesPerItem × 该行 quantity(按行唯一键计)。0 表示不限制。 */
149
+ maxPassesPerItem: number;
150
+ /** 是否抵扣单规格价格 (Option Price),默认 false */
151
+ deductOptionPrice: boolean;
152
+ }>[];
153
+ }
154
+ /**
155
+ * WalletPassAdapter 业务数据输入
156
+ */
157
+ export interface WalletPassBusinessData {
158
+ /** 订单总金额 */
159
+ orderTotalAmount: number;
160
+ /** 商品列表 */
161
+ products: Product[];
162
+ /** 当前评估的 voucher */
163
+ voucher: Voucher;
164
+ /** 策略配置 */
165
+ strategyConfig: StrategyConfig;
166
+ }
167
+ /**
168
+ * WalletPassAdapter 转换结果
169
+ */
170
+ export interface WalletPassTransformResult {
171
+ /** 是否可用 */
172
+ isApplicable: boolean;
173
+ /** 每单可使用张数 */
174
+ canUseCount: number;
175
+ /** 最大抵扣金额 */
176
+ maxDeduction: number;
177
+ /** 是否抵扣税费与附加费 */
178
+ deductTaxAndFee: boolean;
179
+ /** 适用商品ID列表 */
180
+ applicableProductIds: number[];
181
+ /** 不可用原因 */
182
+ reason?: string;
183
+ /** 不可用原因码 */
184
+ reasonCode?: string;
185
+ /** 原始策略评估结果 */
186
+ strategyResult?: EvaluationResult;
187
+ }
@@ -0,0 +1,17 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from === "object" || typeof from === "function") {
7
+ for (let key of __getOwnPropNames(from))
8
+ if (!__hasOwnProp.call(to, key) && key !== except)
9
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
+ }
11
+ return to;
12
+ };
13
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
14
+
15
+ // src/model/strategy/adapter/walletPass/type.ts
16
+ var type_exports = {};
17
+ module.exports = __toCommonJS(type_exports);
@@ -0,0 +1,50 @@
1
+ import { Product, Voucher } from './type';
2
+ /** 订单商品数量 */
3
+ export declare const getProductQuantity: (product: any) => any;
4
+ /**
5
+ * 订单商品行唯一键,用于 maxPassesPerItem 按行、按件配额(同 SPU 不同规格视为不同行)。
6
+ */
7
+ export declare function resolveWalletPassLineKey(product: any, indexInOrder: number): string;
8
+ export declare const getApplicableProductIds: (voucher: Voucher) => number[] | null;
9
+ /**
10
+ * 优惠券处理函数
11
+ * @param applicableVouchers 可用的券列表
12
+ * @param orderTotalAmount 订单总金额
13
+ * @param products 订单商品列表
14
+ * @returns 返回推荐券列表和全部列表,每个券包含 _available_max_amount 和 _unified_available_status
15
+ */
16
+ export declare function processVouchers(applicableVouchers: Voucher[], orderTotalAmount: number, products: Product[]): {
17
+ recommended: any[];
18
+ transformList: any[];
19
+ };
20
+ /**
21
+ * 重新计算优惠券状态(基于已选券的增量计算)
22
+ * @param allVouchers 所有原始券列表
23
+ * @param selectedVouchers 已选中的券列表(按选中顺序)
24
+ * @param orderTotalAmount 订单总金额
25
+ * @param products 订单商品列表
26
+ * @returns 返回更新后的所有券列表和已选券的详细抵扣信息
27
+ */
28
+ export declare function recalculateVouchers(allVouchers: any[], selectedVouchers: any[], orderTotalAmount: number, products: any[]): {
29
+ allWithUpdatedStatus: any[];
30
+ selectedWithDetails: any[];
31
+ };
32
+ /**
33
+ * 获取主商品价格(单价,不含舍入余数)
34
+ * @param product 商品
35
+ * @param isDeductTaxAndFee 是否抵扣税费与附加费
36
+ * @returns 商品单价
37
+ */
38
+ export declare const getMainProductPrice: (product: Product, isDeductTaxAndFee: boolean) => number;
39
+ /**
40
+ * 获取套餐子商品价格(不含舍入余数)
41
+ * @param bundleItem 套餐子商品
42
+ * @param parentQuantity 父商品数量
43
+ * @param isDeductTaxAndFee 是否抵扣税费与附加费
44
+ * @returns 子商品总价格(不含舍入余数)
45
+ */
46
+ export declare const getBundleItemPrice: (bundleItem: any, parentQuantity: number, isDeductTaxAndFee: boolean) => number;
47
+ export declare const getBundleItemIsOriginalPrice: (item: any) => boolean;
48
+ export declare const getBundleItemIsMarkupPrice: (item: any) => boolean;
49
+ export declare const getBundleItemIsDiscountPrice: (item: any) => boolean;
50
+ export declare const getBundleItemIsMarkupOrDiscountPrice: (item: any) => boolean;