@pisell/pisellos 2.3.101 → 2.3.102
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 +18 -2
- package/dist/model/strategy/adapter/dataVariant/evaluator.js +287 -101
- package/dist/model/strategy/adapter/dataVariant/type.d.ts +25 -0
- package/dist/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/modules/Discount/index.d.ts +2 -0
- package/dist/modules/Discount/index.js +38 -5
- package/dist/modules/Discount/types.d.ts +11 -0
- package/dist/modules/Order/index.d.ts +14 -0
- package/dist/modules/Order/index.js +617 -368
- package/dist/modules/Order/types.d.ts +11 -3
- package/dist/modules/Order/utils/virtualSettlement.d.ts +63 -0
- package/dist/modules/Order/utils/virtualSettlement.js +284 -0
- package/dist/modules/Order/utils.d.ts +1 -0
- package/dist/modules/Order/utils.js +63 -24
- package/dist/modules/Product/types.d.ts +23 -0
- package/dist/modules/SalesSummary/index.d.ts +1 -0
- package/dist/modules/SalesSummary/index.js +4 -3
- package/dist/modules/SalesSummary/types.d.ts +1 -0
- package/dist/modules/SalesSummary/utils.d.ts +1 -0
- package/dist/modules/SalesSummary/utils.js +21 -1
- package/dist/solution/BaseSales/index.d.ts +10 -1
- package/dist/solution/BaseSales/index.js +1099 -784
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +1 -0
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +72 -9
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/utils/addProductDecision.js +2 -1
- package/lib/model/strategy/adapter/dataVariant/evaluator.d.ts +18 -2
- package/lib/model/strategy/adapter/dataVariant/evaluator.js +137 -6
- package/lib/model/strategy/adapter/dataVariant/type.d.ts +25 -0
- package/lib/modules/Discount/index.d.ts +2 -0
- package/lib/modules/Discount/index.js +31 -2
- package/lib/modules/Discount/types.d.ts +11 -0
- package/lib/modules/Order/index.d.ts +14 -0
- package/lib/modules/Order/index.js +195 -15
- package/lib/modules/Order/types.d.ts +11 -3
- package/lib/modules/Order/utils/virtualSettlement.d.ts +63 -0
- package/lib/modules/Order/utils/virtualSettlement.js +262 -0
- package/lib/modules/Order/utils.d.ts +1 -0
- package/lib/modules/Order/utils.js +57 -20
- package/lib/modules/Product/types.d.ts +23 -0
- package/lib/modules/SalesSummary/index.d.ts +1 -0
- package/lib/modules/SalesSummary/index.js +4 -2
- package/lib/modules/SalesSummary/types.d.ts +1 -0
- package/lib/modules/SalesSummary/utils.d.ts +1 -0
- package/lib/modules/SalesSummary/utils.js +17 -1
- package/lib/solution/BaseSales/index.d.ts +10 -1
- package/lib/solution/BaseSales/index.js +211 -9
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +1 -0
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +38 -0
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/utils/addProductDecision.js +1 -0
- package/package.json +1 -1
|
@@ -35,6 +35,10 @@ export interface DataVariantItem {
|
|
|
35
35
|
module_data_id?: number;
|
|
36
36
|
/** 关联策略模型 metadata.id / data_variant_rule.id */
|
|
37
37
|
data_variant_rule_id: number | string;
|
|
38
|
+
/** 业务类型;多货币结算候选不会走普通字段覆盖 */
|
|
39
|
+
business_type?: 'multi_currency_settlement' | string;
|
|
40
|
+
/** 数据状态;多货币结算仅处理 enable 记录 */
|
|
41
|
+
status?: 'enable' | 'disable' | string;
|
|
38
42
|
/** 命中策略后需要覆盖到商品上的字段 */
|
|
39
43
|
data: Record<string, any>;
|
|
40
44
|
created_at?: string | null;
|
|
@@ -53,11 +57,30 @@ export interface DataVariantProduct {
|
|
|
53
57
|
id?: number | string;
|
|
54
58
|
[key: string]: any;
|
|
55
59
|
}>;
|
|
60
|
+
/**
|
|
61
|
+
* 商品接口已经完成规则计算时返回的命中结果。
|
|
62
|
+
* 数组按 Data Variant 优先级从高到低排列;空数组表示已计算但无命中。
|
|
63
|
+
*/
|
|
64
|
+
metadata?: {
|
|
65
|
+
data_variant_ids?: Array<number | string>;
|
|
66
|
+
[key: string]: any;
|
|
67
|
+
};
|
|
56
68
|
/** 后端 /product/query with dataVariants 返回的智能定价变体列表 */
|
|
57
69
|
data_variants?: DataVariantItem[];
|
|
70
|
+
/** 当前上下文解析后的可选结算货币,不覆盖商品原始多货币配置 */
|
|
71
|
+
available_settlement_options?: AvailableSettlementOption[];
|
|
58
72
|
_dataVariant?: DataVariantAppliedInfo;
|
|
59
73
|
[key: string]: any;
|
|
60
74
|
}
|
|
75
|
+
export interface AvailableSettlementOption extends Record<string, any> {
|
|
76
|
+
settlement_type: 'legal_currency' | 'virtual_currency' | string;
|
|
77
|
+
currency_product_id?: number;
|
|
78
|
+
price: string;
|
|
79
|
+
data_variant_id?: number;
|
|
80
|
+
data_variant_rule_id: number | string;
|
|
81
|
+
available: boolean;
|
|
82
|
+
disabled_reason?: string;
|
|
83
|
+
}
|
|
61
84
|
/**
|
|
62
85
|
* 餐牌商品配置项。
|
|
63
86
|
*/
|
|
@@ -131,6 +154,8 @@ export interface MatchedDataVariant {
|
|
|
131
154
|
*/
|
|
132
155
|
export interface DataVariantAppliedInfo {
|
|
133
156
|
appliedRuleIds: string[];
|
|
157
|
+
/** 本地策略实际应用的 Data Variant ID,按优先级从高到低排列。 */
|
|
158
|
+
appliedVariantIds?: Array<number | string>;
|
|
134
159
|
appliedFields: string[];
|
|
135
160
|
original: DataVariantProduct;
|
|
136
161
|
}
|
|
@@ -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";
|
|
@@ -25,9 +25,11 @@ export declare class DiscountModule extends BaseModule implements Module, Discou
|
|
|
25
25
|
with_wallet_pass_holder: 0 | 1;
|
|
26
26
|
with_available_wallet_flag?: 0 | 1;
|
|
27
27
|
with_available_wallet_pass_flag?: 0 | 1;
|
|
28
|
+
with_virtual_currency?: 0 | 1;
|
|
28
29
|
request_timezone: string;
|
|
29
30
|
order_id?: number | string;
|
|
30
31
|
}): Promise<DiscountPrepareConfigResult>;
|
|
32
|
+
private normalizeVirtualCurrencyList;
|
|
31
33
|
batchSearch(code: string, options?: {
|
|
32
34
|
customerId?: number;
|
|
33
35
|
orderId?: number;
|
|
@@ -165,8 +165,8 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
165
165
|
key: "loadPrepareConfig",
|
|
166
166
|
value: function () {
|
|
167
167
|
var _loadPrepareConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(params) {
|
|
168
|
-
var _params$with_availabl, _params$with_availabl2, _prepareConfig$data, _prepareConfig$data2, _prepareConfig$data3, _prepareConfig$data4, _prepareConfig$data5;
|
|
169
|
-
var prepareConfig, rawDiscountList, availableWalletList, availableWalletPassList, availableWalletIds, goodPassList;
|
|
168
|
+
var _params$with_availabl, _params$with_availabl2, _params$with_virtual_, _prepareConfig$data, _prepareConfig$data2, _prepareConfig$data3, _prepareConfig$data4, _prepareConfig$data5, _prepareConfig$data6;
|
|
169
|
+
var prepareConfig, rawDiscountList, availableWalletList, availableWalletPassList, availableWalletIds, virtualCurrencyList, goodPassList;
|
|
170
170
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
171
171
|
while (1) switch (_context4.prev = _context4.next) {
|
|
172
172
|
case 0:
|
|
@@ -176,7 +176,8 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
176
176
|
_context4.next = 3;
|
|
177
177
|
return this.request.post("/order/prepare/config", _objectSpread(_objectSpread({}, params), {}, {
|
|
178
178
|
with_available_wallet_flag: (_params$with_availabl = params.with_available_wallet_flag) !== null && _params$with_availabl !== void 0 ? _params$with_availabl : 1,
|
|
179
|
-
with_available_wallet_pass_flag: (_params$with_availabl2 = params.with_available_wallet_pass_flag) !== null && _params$with_availabl2 !== void 0 ? _params$with_availabl2 : 1
|
|
179
|
+
with_available_wallet_pass_flag: (_params$with_availabl2 = params.with_available_wallet_pass_flag) !== null && _params$with_availabl2 !== void 0 ? _params$with_availabl2 : 1,
|
|
180
|
+
with_virtual_currency: (_params$with_virtual_ = params.with_virtual_currency) !== null && _params$with_virtual_ !== void 0 ? _params$with_virtual_ : 1
|
|
180
181
|
}));
|
|
181
182
|
case 3:
|
|
182
183
|
prepareConfig = _context4.sent;
|
|
@@ -188,12 +189,14 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
188
189
|
})), _toConsumableArray(availableWalletPassList.map(function (item) {
|
|
189
190
|
return item === null || item === void 0 ? void 0 : item.product_id;
|
|
190
191
|
}))));
|
|
192
|
+
virtualCurrencyList = this.normalizeVirtualCurrencyList(prepareConfig === null || prepareConfig === void 0 || (_prepareConfig$data6 = prepareConfig.data) === null || _prepareConfig$data6 === void 0 ? void 0 : _prepareConfig$data6.virtual_currency_list);
|
|
191
193
|
goodPassList = this.filterEnabledDiscountList(rawDiscountList) || []; // this.setDiscountList(goodPassList);
|
|
192
194
|
return _context4.abrupt("return", {
|
|
193
195
|
discountList: goodPassList,
|
|
194
|
-
availableWalletIds: availableWalletIds
|
|
196
|
+
availableWalletIds: availableWalletIds,
|
|
197
|
+
virtualCurrencyList: virtualCurrencyList
|
|
195
198
|
});
|
|
196
|
-
case
|
|
199
|
+
case 11:
|
|
197
200
|
case "end":
|
|
198
201
|
return _context4.stop();
|
|
199
202
|
}
|
|
@@ -204,6 +207,36 @@ export var DiscountModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
204
207
|
}
|
|
205
208
|
return loadPrepareConfig;
|
|
206
209
|
}()
|
|
210
|
+
}, {
|
|
211
|
+
key: "normalizeVirtualCurrencyList",
|
|
212
|
+
value: function normalizeVirtualCurrencyList(value) {
|
|
213
|
+
if (!Array.isArray(value)) return [];
|
|
214
|
+
return value.flatMap(function (item) {
|
|
215
|
+
var _item$balance;
|
|
216
|
+
var id = Number(item === null || item === void 0 ? void 0 : item.id);
|
|
217
|
+
var productId = Number(item === null || item === void 0 ? void 0 : item.product_id);
|
|
218
|
+
if (!Number.isFinite(id) || id <= 0 || !Number.isFinite(productId) || productId <= 0) {
|
|
219
|
+
return [];
|
|
220
|
+
}
|
|
221
|
+
var displayExtension = Array.isArray(item === null || item === void 0 ? void 0 : item.extension_data) ? item.extension_data.find(function (extension) {
|
|
222
|
+
return (extension === null || extension === void 0 ? void 0 : extension.field_key) === 'virtual_currency_display';
|
|
223
|
+
}) : undefined;
|
|
224
|
+
var display = displayExtension === null || displayExtension === void 0 ? void 0 : displayExtension.value;
|
|
225
|
+
if (typeof display === 'string') {
|
|
226
|
+
try {
|
|
227
|
+
display = JSON.parse(display);
|
|
228
|
+
} catch (_unused) {
|
|
229
|
+
display = {};
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
return [_objectSpread(_objectSpread({}, item), {}, {
|
|
233
|
+
id: id,
|
|
234
|
+
product_id: productId,
|
|
235
|
+
balance: String((_item$balance = item === null || item === void 0 ? void 0 : item.balance) !== null && _item$balance !== void 0 ? _item$balance : '0'),
|
|
236
|
+
virtual_currency_display: display && _typeof(display) === 'object' && !Array.isArray(display) ? display : {}
|
|
237
|
+
})];
|
|
238
|
+
});
|
|
239
|
+
}
|
|
207
240
|
}, {
|
|
208
241
|
key: "batchSearch",
|
|
209
242
|
value: function () {
|
|
@@ -71,6 +71,17 @@ export interface DiscountWithReason {
|
|
|
71
71
|
export interface DiscountPrepareConfigResult {
|
|
72
72
|
discountList: Discount[];
|
|
73
73
|
availableWalletIds: number[];
|
|
74
|
+
virtualCurrencyList?: VirtualCurrencyAsset[];
|
|
75
|
+
}
|
|
76
|
+
export interface VirtualCurrencyAsset extends Record<string, any> {
|
|
77
|
+
id: number;
|
|
78
|
+
product_id: number;
|
|
79
|
+
balance: string;
|
|
80
|
+
product_name?: string;
|
|
81
|
+
format_title?: Record<string, any>;
|
|
82
|
+
code?: string;
|
|
83
|
+
encoded?: string;
|
|
84
|
+
virtual_currency_display?: Record<string, any>;
|
|
74
85
|
}
|
|
75
86
|
interface ExtensionData {
|
|
76
87
|
id: number;
|
|
@@ -60,6 +60,8 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
60
60
|
* orderModule.updateOtherParams({ cacheId: 'cache-2', channel: 'pos' });
|
|
61
61
|
*/
|
|
62
62
|
updateOtherParams(params: Record<string, any>): void;
|
|
63
|
+
/** PC/H5 属于在线店铺;其它或缺失平台统一沿用 POS 行为。 */
|
|
64
|
+
isOnlineStorePlatform(): boolean;
|
|
63
65
|
/**
|
|
64
66
|
* 记录信息日志
|
|
65
67
|
*/
|
|
@@ -82,6 +84,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
82
84
|
}): Promise<Discount[]>;
|
|
83
85
|
getDiscountList(): Discount[];
|
|
84
86
|
getAvailableWalletIds(): number[];
|
|
87
|
+
getVirtualCurrencyList(): import("../Discount/types").VirtualCurrencyAsset[];
|
|
85
88
|
private syncScannedDiscountsToOriginalDiscountList;
|
|
86
89
|
private ensureEditDiscountConfigForProductChange;
|
|
87
90
|
scanCode(code: string, customerId?: number): Promise<{
|
|
@@ -400,6 +403,13 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
400
403
|
* this.hasLinkedBookingUid({ metadata: { booking_uid: 'booking-1' } });
|
|
401
404
|
*/
|
|
402
405
|
private hasLinkedBookingUid;
|
|
406
|
+
private isMultiCurrencySettlementEnabled;
|
|
407
|
+
private isActiveVirtualSettlementOrder;
|
|
408
|
+
private shouldUseVirtualSettlementSummary;
|
|
409
|
+
private normalizeVirtualSettlementProductIfEnabled;
|
|
410
|
+
private assertAndLockProductSettlement;
|
|
411
|
+
private syncTempOrderSettlementState;
|
|
412
|
+
private prepareVirtualSettlementTempOrder;
|
|
403
413
|
/**
|
|
404
414
|
* 预约商品加车后的统一收尾:促销、折扣、summary 重算与持久化(批量拆行时只调用一次)。
|
|
405
415
|
*
|
|
@@ -472,6 +482,10 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
472
482
|
* 普通整单 note 保持不变;以商品行为主体的 Sales Notes 同步删除。
|
|
473
483
|
*/
|
|
474
484
|
clearOrderCartLines(): Promise<OrderTempOrder>;
|
|
485
|
+
/**
|
|
486
|
+
* 切换购物车结算单位时清理所有会影响新币种的订单状态,但保留当前客户。
|
|
487
|
+
*/
|
|
488
|
+
clearOrderForSettlementSwitch(): Promise<OrderTempOrder>;
|
|
475
489
|
buildCurrentSubmitPayloadForLocalPrint(params?: {
|
|
476
490
|
cacheId?: string;
|
|
477
491
|
platform?: string;
|