@pisell/pisellos 2.2.326 → 2.2.328
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/dist/model/strategy/adapter/dataVariant/evaluator.d.ts +2 -1
- package/dist/model/strategy/adapter/dataVariant/evaluator.js +60 -15
- package/dist/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/modules/OpenData/index.d.ts +8 -1
- package/dist/modules/OpenData/index.js +276 -95
- package/dist/modules/Order/index.d.ts +1 -1
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/server/index.d.ts +3 -0
- package/dist/server/index.js +857 -598
- package/dist/server/modules/order/index.d.ts +1 -0
- package/dist/server/modules/order/index.js +51 -51
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/Sales/index.d.ts +2 -5
- package/dist/solution/Sales/index.js +117 -143
- package/dist/solution/Sales/types.d.ts +6 -0
- package/dist/solution/Sales/types.js +2 -0
- package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +2 -1
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +40 -6
- package/lib/modules/OpenData/index.d.ts +8 -1
- package/lib/modules/OpenData/index.js +123 -21
- package/lib/modules/Order/index.d.ts +1 -1
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/server/index.d.ts +3 -0
- package/lib/server/index.js +155 -18
- package/lib/server/modules/order/index.d.ts +1 -0
- package/lib/server/modules/order/index.js +4 -3
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/Sales/index.d.ts +2 -5
- package/lib/solution/Sales/index.js +32 -66
- package/lib/solution/Sales/types.d.ts +6 -0
- package/lib/solution/Sales/types.js +1 -0
- package/package.json +1 -1
|
@@ -44,7 +44,7 @@ export declare class DataVariantEvaluator {
|
|
|
44
44
|
* 返回 null 表示接口没有提供该字段;空 Map 表示已计算但没有任何命中。
|
|
45
45
|
*/
|
|
46
46
|
private getAuthoritativeVariantPriorities;
|
|
47
|
-
private
|
|
47
|
+
private normalizeId;
|
|
48
48
|
private buildGlobalEffectiveRuleMap;
|
|
49
49
|
private resolveProduct;
|
|
50
50
|
/**
|
|
@@ -90,6 +90,7 @@ export declare class DataVariantEvaluator {
|
|
|
90
90
|
private timeToMinutes;
|
|
91
91
|
private isProductInMenuScope;
|
|
92
92
|
private mergeMatchedVariants;
|
|
93
|
+
private mergeSkuVariants;
|
|
93
94
|
private getProductDataVariants;
|
|
94
95
|
private normalizeStrategyConfigs;
|
|
95
96
|
private isStrategyActive;
|
|
@@ -230,7 +230,7 @@ export var DataVariantEvaluator = /*#__PURE__*/function () {
|
|
|
230
230
|
try {
|
|
231
231
|
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
232
232
|
var rawId = _step4.value;
|
|
233
|
-
var id = this.
|
|
233
|
+
var id = this.normalizeId(rawId);
|
|
234
234
|
if (id === null || seen.has(id)) continue;
|
|
235
235
|
seen.add(id);
|
|
236
236
|
orderedIds.push(id);
|
|
@@ -245,8 +245,8 @@ export var DataVariantEvaluator = /*#__PURE__*/function () {
|
|
|
245
245
|
}));
|
|
246
246
|
}
|
|
247
247
|
}, {
|
|
248
|
-
key: "
|
|
249
|
-
value: function
|
|
248
|
+
key: "normalizeId",
|
|
249
|
+
value: function normalizeId(value) {
|
|
250
250
|
if (value === undefined || value === null) return null;
|
|
251
251
|
var normalized = String(value).trim();
|
|
252
252
|
return normalized || null;
|
|
@@ -305,7 +305,7 @@ export var DataVariantEvaluator = /*#__PURE__*/function () {
|
|
|
305
305
|
var variant = _step6.value;
|
|
306
306
|
if (variant.business_type === 'multi_currency_settlement') continue;
|
|
307
307
|
if (authoritativeVariantPriorities !== null) {
|
|
308
|
-
var variantId = this.
|
|
308
|
+
var variantId = this.normalizeId(variant.id);
|
|
309
309
|
var priority = variantId === null ? undefined : authoritativeVariantPriorities.get(variantId);
|
|
310
310
|
if (priority === undefined) continue;
|
|
311
311
|
matchedVariants.push({
|
|
@@ -357,7 +357,7 @@ export var DataVariantEvaluator = /*#__PURE__*/function () {
|
|
|
357
357
|
var ruleId = String(variant.data_variant_rule_id);
|
|
358
358
|
var isDefault = Number(variant.data_variant_rule_id) === 0;
|
|
359
359
|
var rule = isDefault ? undefined : globalEffectiveRuleMap.get(ruleId);
|
|
360
|
-
var variantId = _this3.
|
|
360
|
+
var variantId = _this3.normalizeId(variant.id);
|
|
361
361
|
var authoritativePriority = variantId === null ? undefined : authoritativeVariantPriorities === null || authoritativeVariantPriorities === void 0 ? void 0 : authoritativeVariantPriorities.get(variantId);
|
|
362
362
|
var available;
|
|
363
363
|
var priority;
|
|
@@ -849,10 +849,15 @@ export var DataVariantEvaluator = /*#__PURE__*/function () {
|
|
|
849
849
|
var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
|
|
850
850
|
key = _Object$entries$_i[0],
|
|
851
851
|
value = _Object$entries$_i[1];
|
|
852
|
-
if (value === undefined) continue;
|
|
852
|
+
if (value === undefined || key === 'variant_overrides') continue;
|
|
853
853
|
result[key] = value;
|
|
854
854
|
appliedFields.add(key);
|
|
855
855
|
}
|
|
856
|
+
var mergedVariants = this.mergeSkuVariants(result.variant, matched.data.variant_overrides);
|
|
857
|
+
if (mergedVariants) {
|
|
858
|
+
result.variant = mergedVariants;
|
|
859
|
+
appliedFields.add('variant');
|
|
860
|
+
}
|
|
856
861
|
appliedRuleIds.push(matched.ruleId);
|
|
857
862
|
}
|
|
858
863
|
} catch (err) {
|
|
@@ -863,7 +868,7 @@ export var DataVariantEvaluator = /*#__PURE__*/function () {
|
|
|
863
868
|
result._dataVariant = {
|
|
864
869
|
appliedRuleIds: appliedRuleIds,
|
|
865
870
|
appliedVariantIds: Array.from(new Set(_toConsumableArray(sortedVariants).reverse().map(function (matched) {
|
|
866
|
-
return _this8.
|
|
871
|
+
return _this8.normalizeId(matched.variant.id);
|
|
867
872
|
}).filter(function (id) {
|
|
868
873
|
return id !== null;
|
|
869
874
|
}))),
|
|
@@ -872,6 +877,46 @@ export var DataVariantEvaluator = /*#__PURE__*/function () {
|
|
|
872
877
|
};
|
|
873
878
|
return result;
|
|
874
879
|
}
|
|
880
|
+
}, {
|
|
881
|
+
key: "mergeSkuVariants",
|
|
882
|
+
value: function mergeSkuVariants(variants, overrides) {
|
|
883
|
+
var _this9 = this;
|
|
884
|
+
if (!Array.isArray(variants) || !Array.isArray(overrides)) return;
|
|
885
|
+
var overridesById = new Map();
|
|
886
|
+
var _iterator18 = _createForOfIteratorHelper(overrides),
|
|
887
|
+
_step18;
|
|
888
|
+
try {
|
|
889
|
+
for (_iterator18.s(); !(_step18 = _iterator18.n()).done;) {
|
|
890
|
+
var override = _step18.value;
|
|
891
|
+
var rawId = override === null || override === void 0 ? void 0 : override.id;
|
|
892
|
+
if (typeof rawId !== 'number' && typeof rawId !== 'string') continue;
|
|
893
|
+
var id = this.normalizeId(rawId);
|
|
894
|
+
if (id === null) continue;
|
|
895
|
+
var fields = Object.entries(override).filter(function (_ref5) {
|
|
896
|
+
var _ref6 = _slicedToArray(_ref5, 2),
|
|
897
|
+
key = _ref6[0],
|
|
898
|
+
value = _ref6[1];
|
|
899
|
+
return key !== 'id' && value !== undefined;
|
|
900
|
+
});
|
|
901
|
+
if (fields.length === 0) continue;
|
|
902
|
+
overridesById.set(id, _objectSpread(_objectSpread({}, overridesById.get(id)), Object.fromEntries(fields)));
|
|
903
|
+
}
|
|
904
|
+
} catch (err) {
|
|
905
|
+
_iterator18.e(err);
|
|
906
|
+
} finally {
|
|
907
|
+
_iterator18.f();
|
|
908
|
+
}
|
|
909
|
+
if (overridesById.size === 0) return;
|
|
910
|
+
var hasUpdates = false;
|
|
911
|
+
var merged = variants.map(function (variant) {
|
|
912
|
+
var id = _this9.normalizeId(variant === null || variant === void 0 ? void 0 : variant.id);
|
|
913
|
+
var fields = id === null ? undefined : overridesById.get(id);
|
|
914
|
+
if (!fields) return variant;
|
|
915
|
+
hasUpdates = true;
|
|
916
|
+
return _objectSpread(_objectSpread({}, variant), fields);
|
|
917
|
+
});
|
|
918
|
+
return hasUpdates ? merged : undefined;
|
|
919
|
+
}
|
|
875
920
|
}, {
|
|
876
921
|
key: "getProductDataVariants",
|
|
877
922
|
value: function getProductDataVariants(product) {
|
|
@@ -915,11 +960,11 @@ export var DataVariantEvaluator = /*#__PURE__*/function () {
|
|
|
915
960
|
key: "flattenConditionRules",
|
|
916
961
|
value: function flattenConditionRules(group) {
|
|
917
962
|
var rules = [];
|
|
918
|
-
var
|
|
919
|
-
|
|
963
|
+
var _iterator19 = _createForOfIteratorHelper(group.rules),
|
|
964
|
+
_step19;
|
|
920
965
|
try {
|
|
921
|
-
for (
|
|
922
|
-
var rule =
|
|
966
|
+
for (_iterator19.s(); !(_step19 = _iterator19.n()).done;) {
|
|
967
|
+
var rule = _step19.value;
|
|
923
968
|
if (this.isConditionGroup(rule)) {
|
|
924
969
|
rules.push.apply(rules, _toConsumableArray(this.flattenConditionRules(rule)));
|
|
925
970
|
} else {
|
|
@@ -927,9 +972,9 @@ export var DataVariantEvaluator = /*#__PURE__*/function () {
|
|
|
927
972
|
}
|
|
928
973
|
}
|
|
929
974
|
} catch (err) {
|
|
930
|
-
|
|
975
|
+
_iterator19.e(err);
|
|
931
976
|
} finally {
|
|
932
|
-
|
|
977
|
+
_iterator19.f();
|
|
933
978
|
}
|
|
934
979
|
return rules;
|
|
935
980
|
}
|
|
@@ -941,10 +986,10 @@ export var DataVariantEvaluator = /*#__PURE__*/function () {
|
|
|
941
986
|
}, {
|
|
942
987
|
key: "normalizeNumberArray",
|
|
943
988
|
value: function normalizeNumberArray(value) {
|
|
944
|
-
var
|
|
989
|
+
var _this10 = this;
|
|
945
990
|
if (!Array.isArray(value)) return [];
|
|
946
991
|
return value.map(function (item) {
|
|
947
|
-
return
|
|
992
|
+
return _this10.toNumber(item);
|
|
948
993
|
}).filter(function (item) {
|
|
949
994
|
return item > 0;
|
|
950
995
|
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// 导出评估器
|
|
2
|
+
export { PromotionEvaluator } from "./evaluator";
|
|
3
|
+
|
|
4
|
+
// 导出适配器
|
|
5
|
+
export { PromotionAdapter } from "./adapter";
|
|
6
|
+
export { default } from "./adapter";
|
|
7
|
+
|
|
8
|
+
// 导出策略配置示例常量
|
|
9
|
+
export { X_ITEMS_FOR_Y_PRICE_STRATEGY, BUY_X_GET_Y_FREE_STRATEGY, ITEM_REWARD_STRATEGY } from "./examples";
|
|
@@ -19,6 +19,8 @@ export declare class OpenDataModule extends BaseModule implements Module {
|
|
|
19
19
|
private otherParams;
|
|
20
20
|
private fetchRevision;
|
|
21
21
|
private invoiceTemplateCacheRevision;
|
|
22
|
+
private printInvoiceTemplates;
|
|
23
|
+
private lastManualPrintKey?;
|
|
22
24
|
private invoiceTemplateDocumentCache;
|
|
23
25
|
private invoiceTemplateDocumentInFlight;
|
|
24
26
|
constructor(name?: string, version?: string);
|
|
@@ -32,13 +34,18 @@ export declare class OpenDataModule extends BaseModule implements Module {
|
|
|
32
34
|
updateOtherParams(params: Record<string, any>): void;
|
|
33
35
|
private shouldSkipInvoiceTemplateDocument;
|
|
34
36
|
fetchOpenData(params: OpenDataFetchParams): Promise<OpenDataConfig>;
|
|
37
|
+
private requestOpenData;
|
|
38
|
+
loadCloudInvoiceTemplate(target: string): Promise<InvoiceTemplateSettings>;
|
|
39
|
+
/** 手动和云单打印共用已成功解析的模板及进行中的请求。每个订单仍单独派单。 */
|
|
40
|
+
loadPrintInvoiceTemplate(target: string, mode: 'manual' | 'cloud'): Promise<InvoiceTemplateSettings>;
|
|
41
|
+
private fetchPrintInvoiceTemplate;
|
|
35
42
|
getOpenData(): OpenDataConfig | null;
|
|
36
43
|
getInvoiceLayoutConfig(): InvoiceLayoutConfig;
|
|
37
44
|
getInvoiceTemplateSettings(): InvoiceTemplateSettings;
|
|
38
45
|
ensureInvoiceTemplateSettings(target: string, openDataConfig?: OpenDataConfig): Promise<InvoiceTemplateSettings>;
|
|
39
46
|
private commitInvoiceTemplateSettings;
|
|
40
47
|
private resolveInvoiceTemplateSettings;
|
|
41
|
-
private
|
|
48
|
+
private buildInvoiceCacheKey;
|
|
42
49
|
private fetchInvoiceTemplateDocument;
|
|
43
50
|
private logInvoiceTemplateDocumentFallback;
|
|
44
51
|
getLastFetchedAt(): number | null;
|