@pisell/pisellos 0.10.22 → 0.10.24
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/promotion/index.js +9 -0
- package/dist/modules/OpenData/index.d.ts +1 -0
- package/dist/modules/OpenData/index.js +28 -9
- package/dist/modules/Order/index.js +2 -2
- package/dist/solution/Sales/index.js +5 -3
- package/lib/model/strategy/adapter/promotion/index.js +1 -46
- package/lib/modules/OpenData/index.d.ts +1 -0
- package/lib/modules/OpenData/index.js +13 -0
- package/lib/modules/Order/index.js +1 -1
- package/lib/solution/Sales/index.js +2 -1
- package/package.json +1 -1
|
@@ -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";
|
|
@@ -28,6 +28,7 @@ export declare class OpenDataModule extends BaseModule implements Module {
|
|
|
28
28
|
* openDataModule.updateOtherParams({ openCache: true, cacheId: 'cache-2' })
|
|
29
29
|
*/
|
|
30
30
|
updateOtherParams(params: Record<string, any>): void;
|
|
31
|
+
private shouldSkipInvoiceTemplateDocument;
|
|
31
32
|
fetchOpenData(params: OpenDataFetchParams): Promise<OpenDataConfig>;
|
|
32
33
|
getOpenData(): OpenDataConfig | null;
|
|
33
34
|
getInvoiceLayoutConfig(): InvoiceLayoutConfig;
|
|
@@ -128,6 +128,12 @@ export var OpenDataModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
128
128
|
this.cacheId = this.otherParams.cacheId;
|
|
129
129
|
this.fatherModule = this.otherParams.fatherModule;
|
|
130
130
|
}
|
|
131
|
+
}, {
|
|
132
|
+
key: "shouldSkipInvoiceTemplateDocument",
|
|
133
|
+
value: function shouldSkipInvoiceTemplateDocument() {
|
|
134
|
+
var _this$otherParams;
|
|
135
|
+
return String(((_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.platform) || '').trim().toLowerCase() === 'h5';
|
|
136
|
+
}
|
|
131
137
|
}, {
|
|
132
138
|
key: "fetchOpenData",
|
|
133
139
|
value: function () {
|
|
@@ -205,6 +211,9 @@ export var OpenDataModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
205
211
|
key: "getInvoiceTemplateSettings",
|
|
206
212
|
value: function getInvoiceTemplateSettings() {
|
|
207
213
|
var _this$store$data2;
|
|
214
|
+
if (this.shouldSkipInvoiceTemplateDocument()) {
|
|
215
|
+
return getDefaultInvoiceTemplateSettings();
|
|
216
|
+
}
|
|
208
217
|
if (isRecord(this.store.invoiceTemplateSettings)) {
|
|
209
218
|
var _this$store$data;
|
|
210
219
|
var documentId = resolveInvoiceDocumentId((_this$store$data = this.store.data) === null || _this$store$data === void 0 ? void 0 : _this$store$data['documents.invoice_template']);
|
|
@@ -278,10 +287,20 @@ export var OpenDataModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
278
287
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
279
288
|
while (1) switch (_context4.prev = _context4.next) {
|
|
280
289
|
case 0:
|
|
290
|
+
if (!this.shouldSkipInvoiceTemplateDocument()) {
|
|
291
|
+
_context4.next = 2;
|
|
292
|
+
break;
|
|
293
|
+
}
|
|
294
|
+
return _context4.abrupt("return", {
|
|
295
|
+
settings: getDefaultInvoiceTemplateSettings(),
|
|
296
|
+
documentId: null,
|
|
297
|
+
cacheKey: null
|
|
298
|
+
});
|
|
299
|
+
case 2:
|
|
281
300
|
rawTemplate = config['documents.invoice_template'];
|
|
282
301
|
documentId = resolveInvoiceDocumentId(rawTemplate);
|
|
283
302
|
if (documentId) {
|
|
284
|
-
_context4.next =
|
|
303
|
+
_context4.next = 6;
|
|
285
304
|
break;
|
|
286
305
|
}
|
|
287
306
|
return _context4.abrupt("return", {
|
|
@@ -289,10 +308,10 @@ export var OpenDataModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
289
308
|
documentId: null,
|
|
290
309
|
cacheKey: null
|
|
291
310
|
});
|
|
292
|
-
case
|
|
311
|
+
case 6:
|
|
293
312
|
cacheKey = this.buildInvoiceTemplateCacheKey(target, documentId);
|
|
294
313
|
if (!(this.store.invoiceTemplateTarget === target && this.store.invoiceTemplateDocumentId === documentId && this.store.invoiceTemplateCacheKey === cacheKey && isRecord(this.store.invoiceTemplateSettings))) {
|
|
295
|
-
_context4.next =
|
|
314
|
+
_context4.next = 9;
|
|
296
315
|
break;
|
|
297
316
|
}
|
|
298
317
|
return _context4.abrupt("return", {
|
|
@@ -300,10 +319,10 @@ export var OpenDataModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
300
319
|
documentId: documentId,
|
|
301
320
|
cacheKey: cacheKey
|
|
302
321
|
});
|
|
303
|
-
case
|
|
322
|
+
case 9:
|
|
304
323
|
cachedSettings = this.invoiceTemplateDocumentCache.get(cacheKey);
|
|
305
324
|
if (!cachedSettings) {
|
|
306
|
-
_context4.next =
|
|
325
|
+
_context4.next = 12;
|
|
307
326
|
break;
|
|
308
327
|
}
|
|
309
328
|
return _context4.abrupt("return", {
|
|
@@ -311,7 +330,7 @@ export var OpenDataModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
311
330
|
documentId: documentId,
|
|
312
331
|
cacheKey: cacheKey
|
|
313
332
|
});
|
|
314
|
-
case
|
|
333
|
+
case 12:
|
|
315
334
|
request = this.invoiceTemplateDocumentInFlight.get(cacheKey);
|
|
316
335
|
if (!request) {
|
|
317
336
|
cacheRevision = this.invoiceTemplateCacheRevision;
|
|
@@ -331,9 +350,9 @@ export var OpenDataModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
331
350
|
});
|
|
332
351
|
this.invoiceTemplateDocumentInFlight.set(cacheKey, request);
|
|
333
352
|
}
|
|
334
|
-
_context4.next =
|
|
353
|
+
_context4.next = 16;
|
|
335
354
|
return request;
|
|
336
|
-
case
|
|
355
|
+
case 16:
|
|
337
356
|
_context4.t0 = _context4.sent;
|
|
338
357
|
_context4.t1 = documentId;
|
|
339
358
|
_context4.t2 = cacheKey;
|
|
@@ -342,7 +361,7 @@ export var OpenDataModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
342
361
|
documentId: _context4.t1,
|
|
343
362
|
cacheKey: _context4.t2
|
|
344
363
|
});
|
|
345
|
-
case
|
|
364
|
+
case 20:
|
|
346
365
|
case "end":
|
|
347
366
|
return _context4.stop();
|
|
348
367
|
}
|
|
@@ -294,14 +294,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
294
294
|
}
|
|
295
295
|
if (Array.isArray(product.product_bundle)) {
|
|
296
296
|
product.product_bundle = product.product_bundle.map(function (bundle) {
|
|
297
|
-
var _ref11, _bundle$original_pric;
|
|
297
|
+
var _ref11, _bundle$original_pric, _bundle$bundle_sellin;
|
|
298
298
|
var hasBundleDiscount = Array.isArray(bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) && bundle.discount_list.length > 0;
|
|
299
299
|
if (hasBundleDiscount) return bundle;
|
|
300
300
|
var restoredPrice = (_ref11 = (_bundle$original_pric = bundle === null || bundle === void 0 ? void 0 : bundle.original_price) !== null && _bundle$original_pric !== void 0 ? _bundle$original_pric : bundle === null || bundle === void 0 ? void 0 : bundle.product_price) !== null && _ref11 !== void 0 ? _ref11 : bundle === null || bundle === void 0 ? void 0 : bundle.price;
|
|
301
301
|
if (restoredPrice === undefined || restoredPrice === null || restoredPrice === '') return bundle;
|
|
302
302
|
return _objectSpread(_objectSpread({}, bundle), {}, {
|
|
303
303
|
price: restoredPrice,
|
|
304
|
-
bundle_selling_price: restoredPrice
|
|
304
|
+
bundle_selling_price: (_bundle$bundle_sellin = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_selling_price) !== null && _bundle$bundle_sellin !== void 0 ? _bundle$bundle_sellin : restoredPrice
|
|
305
305
|
});
|
|
306
306
|
});
|
|
307
307
|
}
|
|
@@ -73,6 +73,7 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
73
73
|
key: "initialize",
|
|
74
74
|
value: function () {
|
|
75
75
|
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(core) {
|
|
76
|
+
var _this$otherParams;
|
|
76
77
|
var options,
|
|
77
78
|
appPlugin,
|
|
78
79
|
_args = arguments;
|
|
@@ -117,7 +118,8 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
117
118
|
initialState: {},
|
|
118
119
|
otherParams: {
|
|
119
120
|
fatherModule: this.name,
|
|
120
|
-
openCache: false
|
|
121
|
+
openCache: false,
|
|
122
|
+
platform: (_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.platform
|
|
121
123
|
}
|
|
122
124
|
});
|
|
123
125
|
_context.next = 18;
|
|
@@ -524,8 +526,8 @@ export var SalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
524
526
|
}, {
|
|
525
527
|
key: "getTimelineBucketMinutes",
|
|
526
528
|
value: function getTimelineBucketMinutes() {
|
|
527
|
-
var _this$
|
|
528
|
-
var dynamicBucket = Number((_this$
|
|
529
|
+
var _this$otherParams2;
|
|
530
|
+
var dynamicBucket = Number((_this$otherParams2 = this.otherParams) === null || _this$otherParams2 === void 0 ? void 0 : _this$otherParams2.timelineBucketMinutes);
|
|
529
531
|
if (!Number.isFinite(dynamicBucket) || dynamicBucket <= 0) return this.defaultTimelineBucketMinutes;
|
|
530
532
|
return Math.floor(dynamicBucket);
|
|
531
533
|
}
|
|
@@ -1,46 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "BUY_X_GET_Y_FREE_STRATEGY", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function () {
|
|
9
|
-
return _examples.BUY_X_GET_Y_FREE_STRATEGY;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
Object.defineProperty(exports, "ITEM_REWARD_STRATEGY", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () {
|
|
15
|
-
return _examples.ITEM_REWARD_STRATEGY;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
Object.defineProperty(exports, "PromotionAdapter", {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: function () {
|
|
21
|
-
return _adapter.PromotionAdapter;
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
Object.defineProperty(exports, "PromotionEvaluator", {
|
|
25
|
-
enumerable: true,
|
|
26
|
-
get: function () {
|
|
27
|
-
return _evaluator.PromotionEvaluator;
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
Object.defineProperty(exports, "X_ITEMS_FOR_Y_PRICE_STRATEGY", {
|
|
31
|
-
enumerable: true,
|
|
32
|
-
get: function () {
|
|
33
|
-
return _examples.X_ITEMS_FOR_Y_PRICE_STRATEGY;
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
Object.defineProperty(exports, "default", {
|
|
37
|
-
enumerable: true,
|
|
38
|
-
get: function () {
|
|
39
|
-
return _adapter.default;
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
var _evaluator = require("./evaluator");
|
|
43
|
-
var _adapter = _interopRequireWildcard(require("./adapter"));
|
|
44
|
-
var _examples = require("./examples");
|
|
45
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
46
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
1
|
+
"use strict";
|
|
@@ -28,6 +28,7 @@ export declare class OpenDataModule extends BaseModule implements Module {
|
|
|
28
28
|
* openDataModule.updateOtherParams({ openCache: true, cacheId: 'cache-2' })
|
|
29
29
|
*/
|
|
30
30
|
updateOtherParams(params: Record<string, any>): void;
|
|
31
|
+
private shouldSkipInvoiceTemplateDocument;
|
|
31
32
|
fetchOpenData(params: OpenDataFetchParams): Promise<OpenDataConfig>;
|
|
32
33
|
getOpenData(): OpenDataConfig | null;
|
|
33
34
|
getInvoiceLayoutConfig(): InvoiceLayoutConfig;
|
|
@@ -152,6 +152,9 @@ class OpenDataModule extends _BaseModule.BaseModule {
|
|
|
152
152
|
this.cacheId = this.otherParams.cacheId;
|
|
153
153
|
this.fatherModule = this.otherParams.fatherModule;
|
|
154
154
|
}
|
|
155
|
+
shouldSkipInvoiceTemplateDocument() {
|
|
156
|
+
return String(this.otherParams?.platform || '').trim().toLowerCase() === 'h5';
|
|
157
|
+
}
|
|
155
158
|
async fetchOpenData(params) {
|
|
156
159
|
const fetchRevision = ++this.fetchRevision;
|
|
157
160
|
const getData = this.appPlugin?.getData?.();
|
|
@@ -190,6 +193,9 @@ class OpenDataModule extends _BaseModule.BaseModule {
|
|
|
190
193
|
return (0, _utils.normalizeInvoiceLayoutFromTemplateSettings)(this.getInvoiceTemplateSettings());
|
|
191
194
|
}
|
|
192
195
|
getInvoiceTemplateSettings() {
|
|
196
|
+
if (this.shouldSkipInvoiceTemplateDocument()) {
|
|
197
|
+
return (0, _utils.getDefaultInvoiceTemplateSettings)();
|
|
198
|
+
}
|
|
193
199
|
if (isRecord(this.store.invoiceTemplateSettings)) {
|
|
194
200
|
const documentId = resolveInvoiceDocumentId(this.store.data?.['documents.invoice_template']);
|
|
195
201
|
if (documentId) {
|
|
@@ -226,6 +232,13 @@ class OpenDataModule extends _BaseModule.BaseModule {
|
|
|
226
232
|
this.store.invoiceTemplateCacheKey = resolved.cacheKey;
|
|
227
233
|
}
|
|
228
234
|
async resolveInvoiceTemplateSettings(config, target) {
|
|
235
|
+
if (this.shouldSkipInvoiceTemplateDocument()) {
|
|
236
|
+
return {
|
|
237
|
+
settings: (0, _utils.getDefaultInvoiceTemplateSettings)(),
|
|
238
|
+
documentId: null,
|
|
239
|
+
cacheKey: null
|
|
240
|
+
};
|
|
241
|
+
}
|
|
229
242
|
const rawTemplate = config['documents.invoice_template'];
|
|
230
243
|
const documentId = resolveInvoiceDocumentId(rawTemplate);
|
|
231
244
|
if (!documentId) {
|
|
@@ -94,7 +94,8 @@ class SalesImpl extends _BaseModule.BaseModule {
|
|
|
94
94
|
initialState: {},
|
|
95
95
|
otherParams: {
|
|
96
96
|
fatherModule: this.name,
|
|
97
|
-
openCache: false
|
|
97
|
+
openCache: false,
|
|
98
|
+
platform: this.otherParams?.platform
|
|
98
99
|
}
|
|
99
100
|
});
|
|
100
101
|
await this.core.effects.emit(`${this.name}:onInited`, {});
|