@pisell/pisellos 2.3.17 → 2.3.18
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 +0 -9
- package/dist/modules/Order/index.d.ts +1 -0
- package/dist/modules/Order/index.js +37 -22
- package/dist/modules/SalesSummary/index.d.ts +7 -3
- package/dist/modules/SalesSummary/index.js +67 -39
- package/dist/modules/SalesSummary/types.d.ts +1 -0
- package/dist/modules/SurchargeList/index.d.ts +6 -4
- package/dist/modules/SurchargeList/index.js +62 -39
- package/dist/modules/SurchargeList/types.d.ts +6 -2
- package/dist/solution/BaseSales/index.js +11 -8
- package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +2 -1
- package/dist/solution/BookingTicket/index.d.ts +1 -13
- package/lib/model/strategy/adapter/promotion/index.js +0 -49
- package/lib/modules/Order/index.d.ts +1 -0
- package/lib/modules/Order/index.js +18 -7
- package/lib/modules/SalesSummary/index.d.ts +7 -3
- package/lib/modules/SalesSummary/index.js +28 -11
- package/lib/modules/SalesSummary/types.d.ts +1 -0
- package/lib/modules/SurchargeList/index.d.ts +6 -4
- package/lib/modules/SurchargeList/index.js +41 -21
- package/lib/modules/SurchargeList/types.d.ts +6 -2
- package/lib/solution/BaseSales/index.js +7 -5
- package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +2 -1
- package/lib/solution/BookingTicket/index.d.ts +1 -13
- package/package.json +1 -1
|
@@ -1,9 +0,0 @@
|
|
|
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 } from "./examples";
|
|
@@ -197,6 +197,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
197
197
|
private clearManualDepositOverride;
|
|
198
198
|
private getOriginalSalesSnapshot;
|
|
199
199
|
private isSnapshotPayableAmountUnchanged;
|
|
200
|
+
private hasShopDiscountChangedFromSnapshot;
|
|
200
201
|
private restoreOriginalSnapshotIfProductsUnchanged;
|
|
201
202
|
private clearPersistedAmountFieldsForFullRecalc;
|
|
202
203
|
private getPaymentTargetAmount;
|
|
@@ -1995,11 +1995,20 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
1995
1995
|
});
|
|
1996
1996
|
return currentAmountGap === snapshotAmountGap;
|
|
1997
1997
|
}
|
|
1998
|
+
}, {
|
|
1999
|
+
key: "hasShopDiscountChangedFromSnapshot",
|
|
2000
|
+
value: function hasShopDiscountChangedFromSnapshot(tempOrder, snapshot) {
|
|
2001
|
+
var _snapshot$shop_discou;
|
|
2002
|
+
var snapshotSummary = snapshot.summary && _typeof(snapshot.summary) === 'object' ? snapshot.summary : {};
|
|
2003
|
+
var snapshotShopDiscount = (_snapshot$shop_discou = snapshot.shop_discount) !== null && _snapshot$shop_discou !== void 0 ? _snapshot$shop_discou : snapshotSummary.shop_discount;
|
|
2004
|
+
if (snapshotShopDiscount === undefined || snapshotShopDiscount === null || snapshotShopDiscount === '') {
|
|
2005
|
+
return !new Decimal(tempOrder.shop_discount || 0).equals(0);
|
|
2006
|
+
}
|
|
2007
|
+
return !new Decimal(tempOrder.shop_discount || 0).equals(snapshotShopDiscount || 0);
|
|
2008
|
+
}
|
|
1998
2009
|
}, {
|
|
1999
2010
|
key: "restoreOriginalSnapshotIfProductsUnchanged",
|
|
2000
|
-
value: function restoreOriginalSnapshotIfProductsUnchanged(tempOrder) {
|
|
2001
|
-
var snapshot = this.getOriginalSalesSnapshot(tempOrder);
|
|
2002
|
-
if (!snapshot) return null;
|
|
2011
|
+
value: function restoreOriginalSnapshotIfProductsUnchanged(tempOrder, snapshot) {
|
|
2003
2012
|
var currentFingerprint = this.buildOrderProductsFingerprint(tempOrder.products);
|
|
2004
2013
|
if (currentFingerprint !== snapshot.productFingerprint) {
|
|
2005
2014
|
var currentStructuralFingerprint = this.buildOrderProductsStructuralFingerprint(tempOrder.products);
|
|
@@ -2660,8 +2669,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2660
2669
|
key: "recalculateSummary",
|
|
2661
2670
|
value: function () {
|
|
2662
2671
|
var _recalculateSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(options) {
|
|
2663
|
-
var _ref47, _salesSummaryResult$e;
|
|
2664
|
-
var tempOrder, snapshotSummary, shouldFullRecalculateFromSnapshot, summaryProducts, salesSummary, existedSummary, totalRefundAmount, paidPaymentSummary, emptyBaseSummary, emptySummaryBase, emptySummaryWithDeposit, emptySummary, salesSummaryResult, roundingAmount, payServiceChargeAmount, hasSalesSummaryAmount, expectAmount, amountPaymentPatch, normalizedExpectAmountPatch, summaryForGap, summary;
|
|
2672
|
+
var _this$otherParams2, _ref47, _salesSummaryResult$e;
|
|
2673
|
+
var tempOrder, originalSnapshot, hasShopDiscountChanged, shouldReuseOriginalSnapshot, snapshotSummary, shouldFullRecalculateFromSnapshot, summaryProducts, salesSummary, existedSummary, totalRefundAmount, paidPaymentSummary, emptyBaseSummary, emptySummaryBase, emptySummaryWithDeposit, emptySummary, salesSummaryResult, roundingAmount, payServiceChargeAmount, hasSalesSummaryAmount, expectAmount, amountPaymentPatch, normalizedExpectAmountPatch, summaryForGap, summary;
|
|
2665
2674
|
return _regeneratorRuntime().wrap(function _callee11$(_context13) {
|
|
2666
2675
|
while (1) switch (_context13.prev = _context13.next) {
|
|
2667
2676
|
case 0:
|
|
@@ -2673,14 +2682,17 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2673
2682
|
return _context13.abrupt("return", null);
|
|
2674
2683
|
case 3:
|
|
2675
2684
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
2676
|
-
|
|
2685
|
+
originalSnapshot = this.getOriginalSalesSnapshot(tempOrder);
|
|
2686
|
+
hasShopDiscountChanged = originalSnapshot ? this.hasShopDiscountChangedFromSnapshot(tempOrder, originalSnapshot) : false;
|
|
2687
|
+
shouldReuseOriginalSnapshot = originalSnapshot && !hasShopDiscountChanged;
|
|
2688
|
+
snapshotSummary = shouldReuseOriginalSnapshot ? this.restoreOriginalSnapshotIfProductsUnchanged(tempOrder, originalSnapshot) : null;
|
|
2677
2689
|
if (!snapshotSummary) {
|
|
2678
|
-
_context13.next =
|
|
2690
|
+
_context13.next = 10;
|
|
2679
2691
|
break;
|
|
2680
2692
|
}
|
|
2681
2693
|
return _context13.abrupt("return", snapshotSummary);
|
|
2682
|
-
case
|
|
2683
|
-
shouldFullRecalculateFromSnapshot = Boolean(
|
|
2694
|
+
case 10:
|
|
2695
|
+
shouldFullRecalculateFromSnapshot = Boolean(originalSnapshot);
|
|
2684
2696
|
summaryProducts = shouldFullRecalculateFromSnapshot ? cloneDeep(tempOrder.products || []) : tempOrder.products;
|
|
2685
2697
|
if (shouldFullRecalculateFromSnapshot) {
|
|
2686
2698
|
this.clearPersistedAmountFieldsForFullRecalc(summaryProducts || []);
|
|
@@ -2690,7 +2702,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2690
2702
|
totalRefundAmount = existedSummary.total_refund_amount || '0.00';
|
|
2691
2703
|
paidPaymentSummary = this.calculatePaidPaymentSummary(tempOrder.payments || []);
|
|
2692
2704
|
if (salesSummary) {
|
|
2693
|
-
_context13.next =
|
|
2705
|
+
_context13.next = 26;
|
|
2694
2706
|
break;
|
|
2695
2707
|
}
|
|
2696
2708
|
emptyBaseSummary = _objectSpread(_objectSpread(_objectSpread({}, createEmptySummary()), existedSummary), {}, {
|
|
@@ -2717,14 +2729,16 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2717
2729
|
summary: emptySummary
|
|
2718
2730
|
});
|
|
2719
2731
|
return _context13.abrupt("return", this.store.summary);
|
|
2720
|
-
case
|
|
2721
|
-
_context13.next =
|
|
2722
|
-
return salesSummary.getSummary({
|
|
2732
|
+
case 26:
|
|
2733
|
+
_context13.next = 28;
|
|
2734
|
+
return salesSummary.getSummary(_objectSpread({
|
|
2723
2735
|
products: summaryProducts,
|
|
2724
2736
|
isPriceIncludeTax: tempOrder.is_price_include_tax,
|
|
2725
2737
|
shopDiscount: tempOrder.shop_discount
|
|
2726
|
-
})
|
|
2727
|
-
|
|
2738
|
+
}, (_this$otherParams2 = this.otherParams) !== null && _this$otherParams2 !== void 0 && _this$otherParams2.channel ? {
|
|
2739
|
+
channel: this.otherParams.channel
|
|
2740
|
+
} : {}));
|
|
2741
|
+
case 28:
|
|
2728
2742
|
salesSummaryResult = _context13.sent;
|
|
2729
2743
|
if (shouldFullRecalculateFromSnapshot) {
|
|
2730
2744
|
tempOrder.products = summaryProducts;
|
|
@@ -2771,7 +2785,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2771
2785
|
summary: summary
|
|
2772
2786
|
});
|
|
2773
2787
|
return _context13.abrupt("return", this.store.summary);
|
|
2774
|
-
case
|
|
2788
|
+
case 46:
|
|
2775
2789
|
case "end":
|
|
2776
2790
|
return _context13.stop();
|
|
2777
2791
|
}
|
|
@@ -4439,14 +4453,14 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4439
4453
|
}, {
|
|
4440
4454
|
key: "buildCurrentSubmitPayloadForLocalPrint",
|
|
4441
4455
|
value: function buildCurrentSubmitPayloadForLocalPrint(params) {
|
|
4442
|
-
var _params$cacheId, _this$
|
|
4456
|
+
var _params$cacheId, _this$otherParams3, _ref68, _params$businessCode, _this$otherParams4, _this$otherParams5;
|
|
4443
4457
|
var tempOrder = this.ensureTempOrder();
|
|
4444
4458
|
this.persistTempOrder();
|
|
4445
4459
|
var payload = buildSubmitPayload({
|
|
4446
4460
|
tempOrder: tempOrder,
|
|
4447
4461
|
cacheId: (_params$cacheId = params === null || params === void 0 ? void 0 : params.cacheId) !== null && _params$cacheId !== void 0 ? _params$cacheId : this.cacheId,
|
|
4448
|
-
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$
|
|
4449
|
-
businessCode: (_ref68 = (_params$businessCode = params === null || params === void 0 ? void 0 : params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$
|
|
4462
|
+
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3.platform),
|
|
4463
|
+
businessCode: (_ref68 = (_params$businessCode = params === null || params === void 0 ? void 0 : params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams4 = this.otherParams) === null || _this$otherParams4 === void 0 ? void 0 : _this$otherParams4.businessCode) !== null && _ref68 !== void 0 ? _ref68 : (_this$otherParams5 = this.otherParams) === null || _this$otherParams5 === void 0 ? void 0 : _this$otherParams5.business_code,
|
|
4450
4464
|
channel: params === null || params === void 0 ? void 0 : params.channel,
|
|
4451
4465
|
type: params === null || params === void 0 ? void 0 : params.type,
|
|
4452
4466
|
summary: this.store.summary || createEmptySummary(),
|
|
@@ -4552,7 +4566,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4552
4566
|
key: "runSubmitTempOrder",
|
|
4553
4567
|
value: function () {
|
|
4554
4568
|
var _runSubmitTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(params) {
|
|
4555
|
-
var _params$cacheId2, _this$
|
|
4569
|
+
var _params$cacheId2, _this$otherParams6, _ref72, _ref73, _submitSnapshot$busin, _this$otherParams7, _this$otherParams8, _submitSnapshot$type;
|
|
4556
4570
|
var tempOrder, shouldConfirmPendingVoucherPayments, hasPaymentOverride, preparedPaymentOverride, latestSummary, effectiveCacheId, hasPaymentStatusOverride, hasSmallTicketDataFlagOverride, enhancePayload, submitSnapshot, payload, result, _payload$payments, _payload$payments2, backendErrorResponse, submittedOrderId, resultRecord;
|
|
4557
4571
|
return _regeneratorRuntime().wrap(function _callee29$(_context32) {
|
|
4558
4572
|
while (1) switch (_context32.prev = _context32.next) {
|
|
@@ -4613,8 +4627,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
4613
4627
|
payload = buildSubmitPayload({
|
|
4614
4628
|
tempOrder: tempOrder,
|
|
4615
4629
|
cacheId: effectiveCacheId,
|
|
4616
|
-
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$
|
|
4617
|
-
businessCode: (_ref72 = (_ref73 = (_submitSnapshot$busin = submitSnapshot.businessCode) !== null && _submitSnapshot$busin !== void 0 ? _submitSnapshot$busin : params === null || params === void 0 ? void 0 : params.businessCode) !== null && _ref73 !== void 0 ? _ref73 : (_this$
|
|
4630
|
+
platform: (params === null || params === void 0 ? void 0 : params.platform) || ((_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.platform),
|
|
4631
|
+
businessCode: (_ref72 = (_ref73 = (_submitSnapshot$busin = submitSnapshot.businessCode) !== null && _submitSnapshot$busin !== void 0 ? _submitSnapshot$busin : params === null || params === void 0 ? void 0 : params.businessCode) !== null && _ref73 !== void 0 ? _ref73 : (_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.businessCode) !== null && _ref72 !== void 0 ? _ref72 : (_this$otherParams8 = this.otherParams) === null || _this$otherParams8 === void 0 ? void 0 : _this$otherParams8.business_code,
|
|
4618
4632
|
channel: params === null || params === void 0 ? void 0 : params.channel,
|
|
4619
4633
|
type: (_submitSnapshot$type = submitSnapshot.type) !== null && _submitSnapshot$type !== void 0 ? _submitSnapshot$type : params === null || params === void 0 ? void 0 : params.type,
|
|
4620
4634
|
summary: latestSummary,
|
|
@@ -5371,6 +5385,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
5371
5385
|
products: cloneDeep(nextTempOrder.products || []),
|
|
5372
5386
|
payments: cloneDeep(nextTempOrder.payments || []),
|
|
5373
5387
|
surcharges: cloneDeep(nextTempOrder.surcharges || []),
|
|
5388
|
+
shop_discount: nextTempOrder.shop_discount || '0.00',
|
|
5374
5389
|
productFingerprint: this.buildOrderProductsFingerprint(nextTempOrder.products || [])
|
|
5375
5390
|
}
|
|
5376
5391
|
});
|
|
@@ -9,16 +9,19 @@ export declare class SalesSummaryModule extends BaseModule implements Module, Sa
|
|
|
9
9
|
private store;
|
|
10
10
|
private request;
|
|
11
11
|
private surchargeListModuleName;
|
|
12
|
+
private otherParams;
|
|
13
|
+
private surchargeListChannel;
|
|
12
14
|
constructor(name?: string, version?: string);
|
|
13
15
|
initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
|
|
14
16
|
/**
|
|
15
|
-
* 更新父级解决方案透传的运行态参数,并在 surcharge
|
|
17
|
+
* 更新父级解决方案透传的运行态参数,并在 surcharge 模块名或渠道变化时刷新附加费列表。
|
|
16
18
|
*
|
|
17
19
|
* @example
|
|
18
|
-
* await salesSummaryModule.updateOtherParams({ surchargeListModuleName: 'custom_surchargeList' });
|
|
20
|
+
* await salesSummaryModule.updateOtherParams({ channel: 'pos', surchargeListModuleName: 'custom_surchargeList' });
|
|
19
21
|
*/
|
|
20
22
|
updateOtherParams(params: Record<string, any>): Promise<void>;
|
|
21
|
-
|
|
23
|
+
private resolveChannel;
|
|
24
|
+
getSurchargeList(channel?: string): Promise<void>;
|
|
22
25
|
private getAppData;
|
|
23
26
|
private getTaxConfig;
|
|
24
27
|
getSummary(params: {
|
|
@@ -26,6 +29,7 @@ export declare class SalesSummaryModule extends BaseModule implements Module, Sa
|
|
|
26
29
|
isPriceIncludeTax?: number;
|
|
27
30
|
taxRate?: number;
|
|
28
31
|
shopDiscount?: string | number;
|
|
32
|
+
channel?: string;
|
|
29
33
|
}): Promise<{
|
|
30
34
|
tax_title: string;
|
|
31
35
|
tax_rate: number | undefined;
|
|
@@ -30,6 +30,7 @@ var salesSummaryDataKeys = {
|
|
|
30
30
|
taxTitle: 'tax_title',
|
|
31
31
|
taxCountryCode: 'tax_country_code'
|
|
32
32
|
};
|
|
33
|
+
var DEFAULT_SURCHARGE_CHANNEL = 'online-store';
|
|
33
34
|
export var SalesSummaryModule = /*#__PURE__*/function (_BaseModule) {
|
|
34
35
|
_inherits(SalesSummaryModule, _BaseModule);
|
|
35
36
|
var _super = _createSuper(SalesSummaryModule);
|
|
@@ -43,13 +44,15 @@ export var SalesSummaryModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
43
44
|
_defineProperty(_assertThisInitialized(_this), "store", void 0);
|
|
44
45
|
_defineProperty(_assertThisInitialized(_this), "request", void 0);
|
|
45
46
|
_defineProperty(_assertThisInitialized(_this), "surchargeListModuleName", 'surchargeList');
|
|
47
|
+
_defineProperty(_assertThisInitialized(_this), "otherParams", {});
|
|
48
|
+
_defineProperty(_assertThisInitialized(_this), "surchargeListChannel", DEFAULT_SURCHARGE_CHANNEL);
|
|
46
49
|
return _this;
|
|
47
50
|
}
|
|
48
51
|
_createClass(SalesSummaryModule, [{
|
|
49
52
|
key: "initialize",
|
|
50
53
|
value: function () {
|
|
51
54
|
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(core, options) {
|
|
52
|
-
var _options$initialState, _options$initialState2,
|
|
55
|
+
var _options$initialState, _options$initialState2, _this$otherParams;
|
|
53
56
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
54
57
|
while (1) switch (_context.prev = _context.next) {
|
|
55
58
|
case 0:
|
|
@@ -57,24 +60,25 @@ export var SalesSummaryModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
57
60
|
this.store = options.store;
|
|
58
61
|
this.appPlugin = this.core.getPlugin('app');
|
|
59
62
|
this.request = this.core.getPlugin('request');
|
|
63
|
+
this.otherParams = options.otherParams || {};
|
|
60
64
|
this.store.surchargeList = ((_options$initialState = options.initialState) === null || _options$initialState === void 0 ? void 0 : _options$initialState.surchargeList) || [];
|
|
61
65
|
this.store.summary = ((_options$initialState2 = options.initialState) === null || _options$initialState2 === void 0 ? void 0 : _options$initialState2.summary) || createEmptySalesSummary();
|
|
62
|
-
this.surchargeListModuleName = ((
|
|
66
|
+
this.surchargeListModuleName = ((_this$otherParams = this.otherParams) === null || _this$otherParams === void 0 ? void 0 : _this$otherParams.surchargeListModuleName) || 'surchargeList';
|
|
63
67
|
if (this.appPlugin) {
|
|
64
|
-
_context.next =
|
|
68
|
+
_context.next = 10;
|
|
65
69
|
break;
|
|
66
70
|
}
|
|
67
71
|
throw new Error('SalesSummaryModule 需要 app 插件支持');
|
|
68
|
-
case
|
|
72
|
+
case 10:
|
|
69
73
|
if (this.request) {
|
|
70
|
-
_context.next =
|
|
74
|
+
_context.next = 12;
|
|
71
75
|
break;
|
|
72
76
|
}
|
|
73
77
|
throw new Error('SalesSummaryModule 需要 request 插件支持');
|
|
74
|
-
case
|
|
75
|
-
_context.next =
|
|
78
|
+
case 12:
|
|
79
|
+
_context.next = 14;
|
|
76
80
|
return this.getSurchargeList();
|
|
77
|
-
case
|
|
81
|
+
case 14:
|
|
78
82
|
case "end":
|
|
79
83
|
return _context.stop();
|
|
80
84
|
}
|
|
@@ -86,30 +90,32 @@ export var SalesSummaryModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
86
90
|
return initialize;
|
|
87
91
|
}()
|
|
88
92
|
/**
|
|
89
|
-
* 更新父级解决方案透传的运行态参数,并在 surcharge
|
|
93
|
+
* 更新父级解决方案透传的运行态参数,并在 surcharge 模块名或渠道变化时刷新附加费列表。
|
|
90
94
|
*
|
|
91
95
|
* @example
|
|
92
|
-
* await salesSummaryModule.updateOtherParams({ surchargeListModuleName: 'custom_surchargeList' });
|
|
96
|
+
* await salesSummaryModule.updateOtherParams({ channel: 'pos', surchargeListModuleName: 'custom_surchargeList' });
|
|
93
97
|
*/
|
|
94
98
|
}, {
|
|
95
99
|
key: "updateOtherParams",
|
|
96
100
|
value: (function () {
|
|
97
101
|
var _updateOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params) {
|
|
98
|
-
var nextSurchargeListModuleName;
|
|
102
|
+
var previousChannel, nextSurchargeListModuleName, nextChannel, shouldReload;
|
|
99
103
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
100
104
|
while (1) switch (_context2.prev = _context2.next) {
|
|
101
105
|
case 0:
|
|
106
|
+
previousChannel = this.resolveChannel();
|
|
102
107
|
nextSurchargeListModuleName = (params === null || params === void 0 ? void 0 : params.surchargeListModuleName) || 'surchargeList';
|
|
103
|
-
|
|
104
|
-
|
|
108
|
+
nextChannel = this.resolveChannel(params);
|
|
109
|
+
shouldReload = nextSurchargeListModuleName !== this.surchargeListModuleName || nextChannel !== previousChannel;
|
|
110
|
+
this.otherParams = params || {};
|
|
111
|
+
this.surchargeListModuleName = nextSurchargeListModuleName;
|
|
112
|
+
if (!shouldReload) {
|
|
113
|
+
_context2.next = 9;
|
|
105
114
|
break;
|
|
106
115
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
_context2.next = 6;
|
|
111
|
-
return this.getSurchargeList();
|
|
112
|
-
case 6:
|
|
116
|
+
_context2.next = 9;
|
|
117
|
+
return this.getSurchargeList(nextChannel);
|
|
118
|
+
case 9:
|
|
113
119
|
case "end":
|
|
114
120
|
return _context2.stop();
|
|
115
121
|
}
|
|
@@ -120,49 +126,63 @@ export var SalesSummaryModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
120
126
|
}
|
|
121
127
|
return updateOtherParams;
|
|
122
128
|
}())
|
|
129
|
+
}, {
|
|
130
|
+
key: "resolveChannel",
|
|
131
|
+
value: function resolveChannel() {
|
|
132
|
+
var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.otherParams;
|
|
133
|
+
return (params === null || params === void 0 ? void 0 : params.channel) || DEFAULT_SURCHARGE_CHANNEL;
|
|
134
|
+
}
|
|
123
135
|
}, {
|
|
124
136
|
key: "getSurchargeList",
|
|
125
137
|
value: function () {
|
|
126
138
|
var _getSurchargeList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
127
|
-
var
|
|
139
|
+
var channel,
|
|
140
|
+
surchargeListModule,
|
|
141
|
+
surchargeList,
|
|
142
|
+
_args3 = arguments;
|
|
128
143
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
129
144
|
while (1) switch (_context3.prev = _context3.next) {
|
|
130
145
|
case 0:
|
|
131
|
-
|
|
146
|
+
channel = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : this.resolveChannel();
|
|
147
|
+
_context3.prev = 1;
|
|
132
148
|
surchargeListModule = this.core.getModule(this.surchargeListModuleName);
|
|
133
149
|
if (!(surchargeListModule !== null && surchargeListModule !== void 0 && surchargeListModule.getSurchargeList)) {
|
|
134
|
-
_context3.next =
|
|
150
|
+
_context3.next = 9;
|
|
135
151
|
break;
|
|
136
152
|
}
|
|
137
|
-
_context3.next =
|
|
138
|
-
return surchargeListModule.getSurchargeList(
|
|
139
|
-
|
|
153
|
+
_context3.next = 6;
|
|
154
|
+
return surchargeListModule.getSurchargeList({
|
|
155
|
+
channel: channel
|
|
156
|
+
});
|
|
157
|
+
case 6:
|
|
140
158
|
this.store.surchargeList = _context3.sent;
|
|
159
|
+
this.surchargeListChannel = channel;
|
|
141
160
|
return _context3.abrupt("return");
|
|
142
|
-
case
|
|
143
|
-
_context3.next =
|
|
161
|
+
case 9:
|
|
162
|
+
_context3.next = 11;
|
|
144
163
|
return this.request.get('/order/custom-surcharge/available/v2', {
|
|
145
|
-
|
|
146
|
-
channel: 'online-store',
|
|
164
|
+
channel: channel,
|
|
147
165
|
is_assemble_product_data: 1,
|
|
148
166
|
is_assemble_schedule_data: 1,
|
|
149
167
|
with: ['relationSchedule']
|
|
150
168
|
});
|
|
151
|
-
case
|
|
169
|
+
case 11:
|
|
152
170
|
surchargeList = _context3.sent;
|
|
153
171
|
this.store.surchargeList = (surchargeList === null || surchargeList === void 0 ? void 0 : surchargeList.data) || [];
|
|
154
|
-
|
|
172
|
+
this.surchargeListChannel = channel;
|
|
173
|
+
_context3.next = 21;
|
|
155
174
|
break;
|
|
156
|
-
case
|
|
157
|
-
_context3.prev =
|
|
158
|
-
_context3.t0 = _context3["catch"](
|
|
175
|
+
case 16:
|
|
176
|
+
_context3.prev = 16;
|
|
177
|
+
_context3.t0 = _context3["catch"](1);
|
|
159
178
|
console.warn('[SalesSummaryModule] 加载附加费配置失败', _context3.t0);
|
|
160
179
|
this.store.surchargeList = [];
|
|
161
|
-
|
|
180
|
+
this.surchargeListChannel = channel;
|
|
181
|
+
case 21:
|
|
162
182
|
case "end":
|
|
163
183
|
return _context3.stop();
|
|
164
184
|
}
|
|
165
|
-
}, _callee3, this, [[
|
|
185
|
+
}, _callee3, this, [[1, 16]]);
|
|
166
186
|
}));
|
|
167
187
|
function getSurchargeList() {
|
|
168
188
|
return _getSurchargeList.apply(this, arguments);
|
|
@@ -194,11 +214,19 @@ export var SalesSummaryModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
194
214
|
value: function () {
|
|
195
215
|
var _getSummary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(params) {
|
|
196
216
|
var _this$store$surcharge, _ref;
|
|
197
|
-
var _params$products, products, isPriceIncludeTax, taxRate, shopDiscount, taxConfig, summarySchedule, needScheduleIds, scheduleList, scheduleById, _iterator, _step, item, summary, summaryWithTaxMeta;
|
|
217
|
+
var _params$products, products, isPriceIncludeTax, taxRate, shopDiscount, channel, summaryChannel, taxConfig, summarySchedule, needScheduleIds, scheduleList, scheduleById, _iterator, _step, item, summary, summaryWithTaxMeta;
|
|
198
218
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
199
219
|
while (1) switch (_context4.prev = _context4.next) {
|
|
200
220
|
case 0:
|
|
201
|
-
_params$products = params.products, products = _params$products === void 0 ? [] : _params$products, isPriceIncludeTax = params.isPriceIncludeTax, taxRate = params.taxRate, shopDiscount = params.shopDiscount;
|
|
221
|
+
_params$products = params.products, products = _params$products === void 0 ? [] : _params$products, isPriceIncludeTax = params.isPriceIncludeTax, taxRate = params.taxRate, shopDiscount = params.shopDiscount, channel = params.channel;
|
|
222
|
+
summaryChannel = channel || this.resolveChannel();
|
|
223
|
+
if (!(summaryChannel !== this.surchargeListChannel)) {
|
|
224
|
+
_context4.next = 5;
|
|
225
|
+
break;
|
|
226
|
+
}
|
|
227
|
+
_context4.next = 5;
|
|
228
|
+
return this.getSurchargeList(summaryChannel);
|
|
229
|
+
case 5:
|
|
202
230
|
taxConfig = this.getTaxConfig();
|
|
203
231
|
summarySchedule = this.core.getModule("".concat(this.name.split('_')[0], "_schedule"));
|
|
204
232
|
needScheduleIds = (((_this$store$surcharge = this.store.surchargeList) === null || _this$store$surcharge === void 0 || (_this$store$surcharge = _this$store$surcharge.map(function (item) {
|
|
@@ -237,7 +265,7 @@ export var SalesSummaryModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
237
265
|
});
|
|
238
266
|
this.store.summary = summaryWithTaxMeta;
|
|
239
267
|
return _context4.abrupt("return", summaryWithTaxMeta);
|
|
240
|
-
case
|
|
268
|
+
case 15:
|
|
241
269
|
case "end":
|
|
242
270
|
return _context4.stop();
|
|
243
271
|
}
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import { Module, ModuleOptions, PisellCore } from '../../types';
|
|
2
2
|
import { BaseModule } from '../BaseModule';
|
|
3
|
-
import { SurchargeListItem, SurchargeListModuleAPI } from './types';
|
|
3
|
+
import { SurchargeListItem, SurchargeListModuleAPI, SurchargeListQuery } from './types';
|
|
4
4
|
export * from './types';
|
|
5
5
|
export declare class SurchargeListModule extends BaseModule implements Module, SurchargeListModuleAPI {
|
|
6
6
|
protected defaultName: string;
|
|
7
7
|
protected defaultVersion: string;
|
|
8
8
|
private request;
|
|
9
9
|
private store;
|
|
10
|
-
private
|
|
10
|
+
private loadingPromises;
|
|
11
|
+
private requestVersion;
|
|
11
12
|
constructor(name?: string, version?: string);
|
|
12
13
|
initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
private resolveChannel;
|
|
15
|
+
getSurchargeList(query?: SurchargeListQuery): Promise<SurchargeListItem[]>;
|
|
16
|
+
refreshSurchargeList(query?: SurchargeListQuery): Promise<SurchargeListItem[]>;
|
|
15
17
|
private loadSurchargeList;
|
|
16
18
|
}
|
|
@@ -17,6 +17,7 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
17
17
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
18
18
|
import { BaseModule } from "../BaseModule";
|
|
19
19
|
export * from "./types";
|
|
20
|
+
var DEFAULT_SURCHARGE_CHANNEL = 'online-store';
|
|
20
21
|
export var SurchargeListModule = /*#__PURE__*/function (_BaseModule) {
|
|
21
22
|
_inherits(SurchargeListModule, _BaseModule);
|
|
22
23
|
var _super = _createSuper(SurchargeListModule);
|
|
@@ -28,14 +29,15 @@ export var SurchargeListModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
28
29
|
_defineProperty(_assertThisInitialized(_this), "defaultVersion", '1.0.0');
|
|
29
30
|
_defineProperty(_assertThisInitialized(_this), "request", void 0);
|
|
30
31
|
_defineProperty(_assertThisInitialized(_this), "store", void 0);
|
|
31
|
-
_defineProperty(_assertThisInitialized(_this), "
|
|
32
|
+
_defineProperty(_assertThisInitialized(_this), "loadingPromises", new Map());
|
|
33
|
+
_defineProperty(_assertThisInitialized(_this), "requestVersion", 0);
|
|
32
34
|
return _this;
|
|
33
35
|
}
|
|
34
36
|
_createClass(SurchargeListModule, [{
|
|
35
37
|
key: "initialize",
|
|
36
38
|
value: function () {
|
|
37
39
|
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(core, options) {
|
|
38
|
-
var _options$initialState, _options$initialState2, _options$initialState3;
|
|
40
|
+
var _options$initialState, _options$initialState2, _options$initialState3, _options$otherParams, _options$initialState4;
|
|
39
41
|
var hasInitialSurchargeList;
|
|
40
42
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
41
43
|
while (1) switch (_context.prev = _context.next) {
|
|
@@ -45,13 +47,14 @@ export var SurchargeListModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
45
47
|
this.request = this.core.getPlugin('request');
|
|
46
48
|
hasInitialSurchargeList = Array.isArray((_options$initialState = options.initialState) === null || _options$initialState === void 0 ? void 0 : _options$initialState.surchargeList);
|
|
47
49
|
this.store.surchargeList = hasInitialSurchargeList ? (_options$initialState2 = options.initialState) === null || _options$initialState2 === void 0 ? void 0 : _options$initialState2.surchargeList : [];
|
|
48
|
-
this.store.
|
|
50
|
+
this.store.channel = ((_options$initialState3 = options.initialState) === null || _options$initialState3 === void 0 ? void 0 : _options$initialState3.channel) || ((_options$otherParams = options.otherParams) === null || _options$otherParams === void 0 ? void 0 : _options$otherParams.channel) || DEFAULT_SURCHARGE_CHANNEL;
|
|
51
|
+
this.store.isLoaded = Boolean((_options$initialState4 = options.initialState) === null || _options$initialState4 === void 0 ? void 0 : _options$initialState4.isLoaded) || hasInitialSurchargeList;
|
|
49
52
|
if (this.request) {
|
|
50
|
-
_context.next =
|
|
53
|
+
_context.next = 9;
|
|
51
54
|
break;
|
|
52
55
|
}
|
|
53
56
|
throw new Error('SurchargeListModule 需要 request 插件支持');
|
|
54
|
-
case
|
|
57
|
+
case 9:
|
|
55
58
|
case "end":
|
|
56
59
|
return _context.stop();
|
|
57
60
|
}
|
|
@@ -62,34 +65,43 @@ export var SurchargeListModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
62
65
|
}
|
|
63
66
|
return initialize;
|
|
64
67
|
}()
|
|
68
|
+
}, {
|
|
69
|
+
key: "resolveChannel",
|
|
70
|
+
value: function resolveChannel(query) {
|
|
71
|
+
return (query === null || query === void 0 ? void 0 : query.channel) || DEFAULT_SURCHARGE_CHANNEL;
|
|
72
|
+
}
|
|
65
73
|
}, {
|
|
66
74
|
key: "getSurchargeList",
|
|
67
75
|
value: function () {
|
|
68
|
-
var _getSurchargeList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
76
|
+
var _getSurchargeList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(query) {
|
|
77
|
+
var channel, loadingPromise, nextPromise;
|
|
69
78
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
70
79
|
while (1) switch (_context2.prev = _context2.next) {
|
|
71
80
|
case 0:
|
|
72
|
-
|
|
73
|
-
|
|
81
|
+
channel = this.resolveChannel(query);
|
|
82
|
+
if (!(this.store.isLoaded && this.store.channel === channel)) {
|
|
83
|
+
_context2.next = 3;
|
|
74
84
|
break;
|
|
75
85
|
}
|
|
76
86
|
return _context2.abrupt("return", this.store.surchargeList);
|
|
77
|
-
case
|
|
78
|
-
|
|
79
|
-
|
|
87
|
+
case 3:
|
|
88
|
+
loadingPromise = this.loadingPromises.get(channel);
|
|
89
|
+
if (!loadingPromise) {
|
|
90
|
+
_context2.next = 6;
|
|
80
91
|
break;
|
|
81
92
|
}
|
|
82
|
-
return _context2.abrupt("return",
|
|
83
|
-
case 4:
|
|
84
|
-
this.loadingPromise = this.loadSurchargeList();
|
|
85
|
-
return _context2.abrupt("return", this.loadingPromise);
|
|
93
|
+
return _context2.abrupt("return", loadingPromise);
|
|
86
94
|
case 6:
|
|
95
|
+
nextPromise = this.loadSurchargeList(channel);
|
|
96
|
+
this.loadingPromises.set(channel, nextPromise);
|
|
97
|
+
return _context2.abrupt("return", nextPromise);
|
|
98
|
+
case 9:
|
|
87
99
|
case "end":
|
|
88
100
|
return _context2.stop();
|
|
89
101
|
}
|
|
90
102
|
}, _callee2, this);
|
|
91
103
|
}));
|
|
92
|
-
function getSurchargeList() {
|
|
104
|
+
function getSurchargeList(_x3) {
|
|
93
105
|
return _getSurchargeList.apply(this, arguments);
|
|
94
106
|
}
|
|
95
107
|
return getSurchargeList;
|
|
@@ -97,19 +109,22 @@ export var SurchargeListModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
97
109
|
}, {
|
|
98
110
|
key: "refreshSurchargeList",
|
|
99
111
|
value: function () {
|
|
100
|
-
var _refreshSurchargeList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
112
|
+
var _refreshSurchargeList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(query) {
|
|
113
|
+
var channel, nextPromise;
|
|
101
114
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
102
115
|
while (1) switch (_context3.prev = _context3.next) {
|
|
103
116
|
case 0:
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
117
|
+
channel = this.resolveChannel(query);
|
|
118
|
+
nextPromise = this.loadSurchargeList(channel);
|
|
119
|
+
this.loadingPromises.set(channel, nextPromise);
|
|
120
|
+
return _context3.abrupt("return", nextPromise);
|
|
121
|
+
case 4:
|
|
107
122
|
case "end":
|
|
108
123
|
return _context3.stop();
|
|
109
124
|
}
|
|
110
125
|
}, _callee3, this);
|
|
111
126
|
}));
|
|
112
|
-
function refreshSurchargeList() {
|
|
127
|
+
function refreshSurchargeList(_x4) {
|
|
113
128
|
return _refreshSurchargeList.apply(this, arguments);
|
|
114
129
|
}
|
|
115
130
|
return refreshSurchargeList;
|
|
@@ -117,42 +132,50 @@ export var SurchargeListModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
117
132
|
}, {
|
|
118
133
|
key: "loadSurchargeList",
|
|
119
134
|
value: function () {
|
|
120
|
-
var _loadSurchargeList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
121
|
-
var surchargeList;
|
|
135
|
+
var _loadSurchargeList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(channel) {
|
|
136
|
+
var currentRequestVersion, surchargeList, nextSurchargeList;
|
|
122
137
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
123
138
|
while (1) switch (_context4.prev = _context4.next) {
|
|
124
139
|
case 0:
|
|
125
|
-
|
|
126
|
-
_context4.
|
|
140
|
+
currentRequestVersion = ++this.requestVersion;
|
|
141
|
+
_context4.prev = 1;
|
|
142
|
+
_context4.next = 4;
|
|
127
143
|
return this.request.get('/order/custom-surcharge/available/v2', {
|
|
128
|
-
channel:
|
|
144
|
+
channel: channel,
|
|
129
145
|
is_assemble_product_data: 1,
|
|
130
146
|
is_assemble_schedule_data: 1,
|
|
131
147
|
with: ['relationSchedule']
|
|
132
148
|
});
|
|
133
|
-
case
|
|
149
|
+
case 4:
|
|
134
150
|
surchargeList = _context4.sent;
|
|
135
|
-
|
|
136
|
-
this.
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
151
|
+
nextSurchargeList = (surchargeList === null || surchargeList === void 0 ? void 0 : surchargeList.data) || [];
|
|
152
|
+
if (currentRequestVersion === this.requestVersion) {
|
|
153
|
+
this.store.surchargeList = nextSurchargeList;
|
|
154
|
+
this.store.channel = channel;
|
|
155
|
+
this.store.isLoaded = true;
|
|
156
|
+
}
|
|
157
|
+
return _context4.abrupt("return", nextSurchargeList);
|
|
158
|
+
case 10:
|
|
159
|
+
_context4.prev = 10;
|
|
160
|
+
_context4.t0 = _context4["catch"](1);
|
|
141
161
|
console.warn('[SurchargeListModule] 加载附加费配置失败', _context4.t0);
|
|
142
|
-
this.
|
|
143
|
-
|
|
144
|
-
|
|
162
|
+
if (currentRequestVersion === this.requestVersion) {
|
|
163
|
+
this.store.surchargeList = [];
|
|
164
|
+
this.store.channel = channel;
|
|
165
|
+
this.store.isLoaded = true;
|
|
166
|
+
}
|
|
167
|
+
return _context4.abrupt("return", []);
|
|
145
168
|
case 15:
|
|
146
169
|
_context4.prev = 15;
|
|
147
|
-
this.
|
|
170
|
+
this.loadingPromises.delete(channel);
|
|
148
171
|
return _context4.finish(15);
|
|
149
172
|
case 18:
|
|
150
173
|
case "end":
|
|
151
174
|
return _context4.stop();
|
|
152
175
|
}
|
|
153
|
-
}, _callee4, this, [[
|
|
176
|
+
}, _callee4, this, [[1, 10, 15, 18]]);
|
|
154
177
|
}));
|
|
155
|
-
function loadSurchargeList() {
|
|
178
|
+
function loadSurchargeList(_x5) {
|
|
156
179
|
return _loadSurchargeList.apply(this, arguments);
|
|
157
180
|
}
|
|
158
181
|
return loadSurchargeList;
|
|
@@ -4,8 +4,12 @@ export interface SurchargeListItem {
|
|
|
4
4
|
export interface SurchargeListState {
|
|
5
5
|
surchargeList: SurchargeListItem[];
|
|
6
6
|
isLoaded: boolean;
|
|
7
|
+
channel?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface SurchargeListQuery {
|
|
10
|
+
channel?: string;
|
|
7
11
|
}
|
|
8
12
|
export interface SurchargeListModuleAPI {
|
|
9
|
-
getSurchargeList(): Promise<SurchargeListItem[]>;
|
|
10
|
-
refreshSurchargeList(): Promise<SurchargeListItem[]>;
|
|
13
|
+
getSurchargeList(query?: SurchargeListQuery): Promise<SurchargeListItem[]>;
|
|
14
|
+
refreshSurchargeList(query?: SurchargeListQuery): Promise<SurchargeListItem[]>;
|
|
11
15
|
}
|
|
@@ -2604,18 +2604,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2604
2604
|
}, {
|
|
2605
2605
|
key: "getWalletProductList",
|
|
2606
2606
|
value: function getWalletProductList() {
|
|
2607
|
-
var _this$store$order5, _tempOrder$products
|
|
2607
|
+
var _this$store$order5, _tempOrder$products;
|
|
2608
2608
|
var tempOrder = (_this$store$order5 = this.store.order) === null || _this$store$order5 === void 0 ? void 0 : _this$store$order5.getTempOrder();
|
|
2609
2609
|
if (!(tempOrder !== null && tempOrder !== void 0 && (_tempOrder$products = tempOrder.products) !== null && _tempOrder$products !== void 0 && _tempOrder$products.length)) return [];
|
|
2610
2610
|
// 过滤出有 product_id的商品来,如果没有代表他是自定义商品,不需要参与 wallet
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
var walletProducts = products.map(function (product) {
|
|
2615
|
-
var _product$
|
|
2611
|
+
// debugger
|
|
2612
|
+
// const products = tempOrder?.products?.filter(n => n.product_id)
|
|
2613
|
+
|
|
2614
|
+
var walletProducts = tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.products.map(function (product) {
|
|
2615
|
+
var _product$holder_id, _product$product_vari2, _product$is_charge_ta, _metadata$main_produc, _metadata$main_produc2;
|
|
2616
2616
|
var metadata = product.metadata || {};
|
|
2617
|
+
var rawHolderId = (_product$holder_id = product.holder_id) !== null && _product$holder_id !== void 0 ? _product$holder_id : metadata.holder_id;
|
|
2618
|
+
var holderIdValue = Array.isArray(rawHolderId) ? rawHolderId[0] : rawHolderId;
|
|
2619
|
+
var holder_id = Number.isInteger(Number(holderIdValue)) ? Number(holderIdValue) : undefined;
|
|
2617
2620
|
return {
|
|
2618
|
-
product_id: product.product_id,
|
|
2621
|
+
product_id: product.product_id || 0,
|
|
2619
2622
|
product_variant_id: String((_product$product_vari2 = product.product_variant_id) !== null && _product$product_vari2 !== void 0 ? _product$product_vari2 : ''),
|
|
2620
2623
|
quantity: product.num || 1,
|
|
2621
2624
|
is_price_include_tax: tempOrder.is_price_include_tax,
|
|
@@ -2623,7 +2626,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2623
2626
|
tax_fee: product.tax_fee,
|
|
2624
2627
|
selling_price: Number(product.selling_price || 0),
|
|
2625
2628
|
discount_list: product.discount_list || [],
|
|
2626
|
-
holder_id:
|
|
2629
|
+
holder_id: holder_id,
|
|
2627
2630
|
original_price: product.original_price,
|
|
2628
2631
|
main_product_original_price: (_metadata$main_produc = metadata.main_product_original_price) !== null && _metadata$main_produc !== void 0 ? _metadata$main_produc : product.original_price,
|
|
2629
2632
|
main_product_selling_price: (_metadata$main_produc2 = metadata.main_product_selling_price) !== null && _metadata$main_produc2 !== void 0 ? _metadata$main_produc2 : product.selling_price,
|
|
@@ -66,7 +66,8 @@ function normalizeBundleItems(bundleItems) {
|
|
|
66
66
|
price: (_bundleItem$price3 = bundleItem.price) !== null && _bundleItem$price3 !== void 0 ? _bundleItem$price3 : unitStr,
|
|
67
67
|
bundle_selling_price: unitStr,
|
|
68
68
|
original_price: (_ref8 = (_ref9 = (_bundleItem$original_ = bundleItem.original_price) !== null && _bundleItem$original_ !== void 0 ? _bundleItem$original_ : bundleItem.product_price) !== null && _ref9 !== void 0 ? _ref9 : bundleItem.price) !== null && _ref8 !== void 0 ? _ref8 : unitStr,
|
|
69
|
-
option: normalizeOptionItems(bundleItem === null || bundleItem === void 0 ? void 0 : bundleItem.option)
|
|
69
|
+
option: normalizeOptionItems(bundleItem === null || bundleItem === void 0 ? void 0 : bundleItem.option),
|
|
70
|
+
discount_list: preferPriceField ? [] : bundleItem.discount_list
|
|
70
71
|
});
|
|
71
72
|
// bundle_selling_price 落「正净额」:markdown = |price| − Σoptions;markup/原价维持原值。
|
|
72
73
|
normalizedItem.bundle_selling_price = getBundleSellingMagnitude(magnitudeSource).toFixed(2);
|
|
@@ -441,19 +441,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
441
441
|
* 加车两阶段主决策(规格弹窗 / 资源编辑 / 直接加车)。
|
|
442
442
|
* 与 ticketBooking `handleSelectProduct` + `handleBooking4Service` 等价。
|
|
443
443
|
*/
|
|
444
|
-
decideAddProduct(item: any, options?: Partial<AddProductDecideContext>):
|
|
445
|
-
action: "reloadCatalog";
|
|
446
|
-
} | {
|
|
447
|
-
action: "add";
|
|
448
|
-
cacheItem: any;
|
|
449
|
-
} | {
|
|
450
|
-
action: "requiresDetail";
|
|
451
|
-
payload: AddProductRequiresDetailPayload;
|
|
452
|
-
} | {
|
|
453
|
-
action: "requiresBookingEdit";
|
|
454
|
-
cacheItem: any;
|
|
455
|
-
payload: import("./utils/addProductDecision").AddProductRequiresBookingEditPayload;
|
|
456
|
-
};
|
|
444
|
+
decideAddProduct(item: any, options?: Partial<AddProductDecideContext>): import("./utils/addProductDecision").AddProductDecision;
|
|
457
445
|
/** 规格弹窗 callback 后的第二段决策。 */
|
|
458
446
|
decideAfterDetail(cacheItem: any, options?: Partial<AddProductDecideContext>): import("./utils/addProductDecision").AddProductDecision;
|
|
459
447
|
/**
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
|
|
29
|
-
// src/model/strategy/adapter/promotion/index.ts
|
|
30
|
-
var promotion_exports = {};
|
|
31
|
-
__export(promotion_exports, {
|
|
32
|
-
BUY_X_GET_Y_FREE_STRATEGY: () => import_examples.BUY_X_GET_Y_FREE_STRATEGY,
|
|
33
|
-
PromotionAdapter: () => import_adapter.PromotionAdapter,
|
|
34
|
-
PromotionEvaluator: () => import_evaluator.PromotionEvaluator,
|
|
35
|
-
X_ITEMS_FOR_Y_PRICE_STRATEGY: () => import_examples.X_ITEMS_FOR_Y_PRICE_STRATEGY,
|
|
36
|
-
default: () => import_adapter2.default
|
|
37
|
-
});
|
|
38
|
-
module.exports = __toCommonJS(promotion_exports);
|
|
39
|
-
var import_evaluator = require("./evaluator");
|
|
40
|
-
var import_adapter = require("./adapter");
|
|
41
|
-
var import_adapter2 = __toESM(require("./adapter"));
|
|
42
|
-
var import_examples = require("./examples");
|
|
43
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
44
|
-
0 && (module.exports = {
|
|
45
|
-
BUY_X_GET_Y_FREE_STRATEGY,
|
|
46
|
-
PromotionAdapter,
|
|
47
|
-
PromotionEvaluator,
|
|
48
|
-
X_ITEMS_FOR_Y_PRICE_STRATEGY
|
|
49
|
-
});
|
|
@@ -197,6 +197,7 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
197
197
|
private clearManualDepositOverride;
|
|
198
198
|
private getOriginalSalesSnapshot;
|
|
199
199
|
private isSnapshotPayableAmountUnchanged;
|
|
200
|
+
private hasShopDiscountChangedFromSnapshot;
|
|
200
201
|
private restoreOriginalSnapshotIfProductsUnchanged;
|
|
201
202
|
private clearPersistedAmountFieldsForFullRecalc;
|
|
202
203
|
private getPaymentTargetAmount;
|
|
@@ -1470,10 +1470,15 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
1470
1470
|
});
|
|
1471
1471
|
return currentAmountGap === snapshotAmountGap;
|
|
1472
1472
|
}
|
|
1473
|
-
|
|
1474
|
-
const
|
|
1475
|
-
|
|
1476
|
-
|
|
1473
|
+
hasShopDiscountChangedFromSnapshot(tempOrder, snapshot) {
|
|
1474
|
+
const snapshotSummary = snapshot.summary && typeof snapshot.summary === "object" ? snapshot.summary : {};
|
|
1475
|
+
const snapshotShopDiscount = snapshot.shop_discount ?? snapshotSummary.shop_discount;
|
|
1476
|
+
if (snapshotShopDiscount === void 0 || snapshotShopDiscount === null || snapshotShopDiscount === "") {
|
|
1477
|
+
return !new import_decimal.default(tempOrder.shop_discount || 0).equals(0);
|
|
1478
|
+
}
|
|
1479
|
+
return !new import_decimal.default(tempOrder.shop_discount || 0).equals(snapshotShopDiscount || 0);
|
|
1480
|
+
}
|
|
1481
|
+
restoreOriginalSnapshotIfProductsUnchanged(tempOrder, snapshot) {
|
|
1477
1482
|
const currentFingerprint = this.buildOrderProductsFingerprint(tempOrder.products);
|
|
1478
1483
|
if (currentFingerprint !== snapshot.productFingerprint) {
|
|
1479
1484
|
const currentStructuralFingerprint = this.buildOrderProductsStructuralFingerprint(tempOrder.products);
|
|
@@ -1974,14 +1979,18 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
1974
1979
|
return this.applyLastOrderDepositSnapshot(tempOrder, nextSummary);
|
|
1975
1980
|
}
|
|
1976
1981
|
async recalculateSummary(options) {
|
|
1982
|
+
var _a;
|
|
1977
1983
|
const tempOrder = (options == null ? void 0 : options.createIfMissing) ? this.ensureTempOrder() : this.store.tempOrder;
|
|
1978
1984
|
if (!tempOrder)
|
|
1979
1985
|
return null;
|
|
1980
1986
|
this.sanitizeTempOrderProducts(tempOrder);
|
|
1981
|
-
const
|
|
1987
|
+
const originalSnapshot = this.getOriginalSalesSnapshot(tempOrder);
|
|
1988
|
+
const hasShopDiscountChanged = originalSnapshot ? this.hasShopDiscountChangedFromSnapshot(tempOrder, originalSnapshot) : false;
|
|
1989
|
+
const shouldReuseOriginalSnapshot = originalSnapshot && !hasShopDiscountChanged;
|
|
1990
|
+
const snapshotSummary = shouldReuseOriginalSnapshot ? this.restoreOriginalSnapshotIfProductsUnchanged(tempOrder, originalSnapshot) : null;
|
|
1982
1991
|
if (snapshotSummary)
|
|
1983
1992
|
return snapshotSummary;
|
|
1984
|
-
const shouldFullRecalculateFromSnapshot = Boolean(
|
|
1993
|
+
const shouldFullRecalculateFromSnapshot = Boolean(originalSnapshot);
|
|
1985
1994
|
const summaryProducts = shouldFullRecalculateFromSnapshot ? (0, import_lodash_es.cloneDeep)(tempOrder.products || []) : tempOrder.products;
|
|
1986
1995
|
if (shouldFullRecalculateFromSnapshot) {
|
|
1987
1996
|
this.clearPersistedAmountFieldsForFullRecalc(summaryProducts || []);
|
|
@@ -2028,7 +2037,8 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
2028
2037
|
const salesSummaryResult = await salesSummary.getSummary({
|
|
2029
2038
|
products: summaryProducts,
|
|
2030
2039
|
isPriceIncludeTax: tempOrder.is_price_include_tax,
|
|
2031
|
-
shopDiscount: tempOrder.shop_discount
|
|
2040
|
+
shopDiscount: tempOrder.shop_discount,
|
|
2041
|
+
...((_a = this.otherParams) == null ? void 0 : _a.channel) ? { channel: this.otherParams.channel } : {}
|
|
2032
2042
|
});
|
|
2033
2043
|
if (shouldFullRecalculateFromSnapshot) {
|
|
2034
2044
|
tempOrder.products = summaryProducts;
|
|
@@ -3947,6 +3957,7 @@ var OrderModule = class extends import_BaseModule.BaseModule {
|
|
|
3947
3957
|
products: (0, import_lodash_es.cloneDeep)(nextTempOrder.products || []),
|
|
3948
3958
|
payments: (0, import_lodash_es.cloneDeep)(nextTempOrder.payments || []),
|
|
3949
3959
|
surcharges: (0, import_lodash_es.cloneDeep)(nextTempOrder.surcharges || []),
|
|
3960
|
+
shop_discount: nextTempOrder.shop_discount || "0.00",
|
|
3950
3961
|
productFingerprint: this.buildOrderProductsFingerprint(nextTempOrder.products || [])
|
|
3951
3962
|
}
|
|
3952
3963
|
};
|
|
@@ -9,16 +9,19 @@ export declare class SalesSummaryModule extends BaseModule implements Module, Sa
|
|
|
9
9
|
private store;
|
|
10
10
|
private request;
|
|
11
11
|
private surchargeListModuleName;
|
|
12
|
+
private otherParams;
|
|
13
|
+
private surchargeListChannel;
|
|
12
14
|
constructor(name?: string, version?: string);
|
|
13
15
|
initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
|
|
14
16
|
/**
|
|
15
|
-
* 更新父级解决方案透传的运行态参数,并在 surcharge
|
|
17
|
+
* 更新父级解决方案透传的运行态参数,并在 surcharge 模块名或渠道变化时刷新附加费列表。
|
|
16
18
|
*
|
|
17
19
|
* @example
|
|
18
|
-
* await salesSummaryModule.updateOtherParams({ surchargeListModuleName: 'custom_surchargeList' });
|
|
20
|
+
* await salesSummaryModule.updateOtherParams({ channel: 'pos', surchargeListModuleName: 'custom_surchargeList' });
|
|
19
21
|
*/
|
|
20
22
|
updateOtherParams(params: Record<string, any>): Promise<void>;
|
|
21
|
-
|
|
23
|
+
private resolveChannel;
|
|
24
|
+
getSurchargeList(channel?: string): Promise<void>;
|
|
22
25
|
private getAppData;
|
|
23
26
|
private getTaxConfig;
|
|
24
27
|
getSummary(params: {
|
|
@@ -26,6 +29,7 @@ export declare class SalesSummaryModule extends BaseModule implements Module, Sa
|
|
|
26
29
|
isPriceIncludeTax?: number;
|
|
27
30
|
taxRate?: number;
|
|
28
31
|
shopDiscount?: string | number;
|
|
32
|
+
channel?: string;
|
|
29
33
|
}): Promise<{
|
|
30
34
|
tax_title: string;
|
|
31
35
|
tax_rate: number | undefined;
|
|
@@ -33,12 +33,15 @@ var salesSummaryDataKeys = {
|
|
|
33
33
|
taxTitle: "tax_title",
|
|
34
34
|
taxCountryCode: "tax_country_code"
|
|
35
35
|
};
|
|
36
|
+
var DEFAULT_SURCHARGE_CHANNEL = "online-store";
|
|
36
37
|
var SalesSummaryModule = class extends import_BaseModule.BaseModule {
|
|
37
38
|
constructor(name, version) {
|
|
38
39
|
super(name, version);
|
|
39
40
|
this.defaultName = "salesSummary";
|
|
40
41
|
this.defaultVersion = "1.0.0";
|
|
41
42
|
this.surchargeListModuleName = "surchargeList";
|
|
43
|
+
this.otherParams = {};
|
|
44
|
+
this.surchargeListChannel = DEFAULT_SURCHARGE_CHANNEL;
|
|
42
45
|
}
|
|
43
46
|
async initialize(core, options) {
|
|
44
47
|
var _a, _b, _c;
|
|
@@ -46,9 +49,10 @@ var SalesSummaryModule = class extends import_BaseModule.BaseModule {
|
|
|
46
49
|
this.store = options.store;
|
|
47
50
|
this.appPlugin = this.core.getPlugin("app");
|
|
48
51
|
this.request = this.core.getPlugin("request");
|
|
52
|
+
this.otherParams = options.otherParams || {};
|
|
49
53
|
this.store.surchargeList = ((_a = options.initialState) == null ? void 0 : _a.surchargeList) || [];
|
|
50
54
|
this.store.summary = ((_b = options.initialState) == null ? void 0 : _b.summary) || (0, import_utils.createEmptySalesSummary)();
|
|
51
|
-
this.surchargeListModuleName = ((_c =
|
|
55
|
+
this.surchargeListModuleName = ((_c = this.otherParams) == null ? void 0 : _c.surchargeListModuleName) || "surchargeList";
|
|
52
56
|
if (!this.appPlugin) {
|
|
53
57
|
throw new Error("SalesSummaryModule 需要 app 插件支持");
|
|
54
58
|
}
|
|
@@ -58,41 +62,50 @@ var SalesSummaryModule = class extends import_BaseModule.BaseModule {
|
|
|
58
62
|
await this.getSurchargeList();
|
|
59
63
|
}
|
|
60
64
|
/**
|
|
61
|
-
* 更新父级解决方案透传的运行态参数,并在 surcharge
|
|
65
|
+
* 更新父级解决方案透传的运行态参数,并在 surcharge 模块名或渠道变化时刷新附加费列表。
|
|
62
66
|
*
|
|
63
67
|
* @example
|
|
64
|
-
* await salesSummaryModule.updateOtherParams({ surchargeListModuleName: 'custom_surchargeList' });
|
|
68
|
+
* await salesSummaryModule.updateOtherParams({ channel: 'pos', surchargeListModuleName: 'custom_surchargeList' });
|
|
65
69
|
*/
|
|
66
70
|
async updateOtherParams(params) {
|
|
71
|
+
const previousChannel = this.resolveChannel();
|
|
67
72
|
const nextSurchargeListModuleName = (params == null ? void 0 : params.surchargeListModuleName) || "surchargeList";
|
|
68
|
-
|
|
69
|
-
|
|
73
|
+
const nextChannel = this.resolveChannel(params);
|
|
74
|
+
const shouldReload = nextSurchargeListModuleName !== this.surchargeListModuleName || nextChannel !== previousChannel;
|
|
75
|
+
this.otherParams = params || {};
|
|
70
76
|
this.surchargeListModuleName = nextSurchargeListModuleName;
|
|
71
|
-
|
|
77
|
+
if (shouldReload) {
|
|
78
|
+
await this.getSurchargeList(nextChannel);
|
|
79
|
+
}
|
|
72
80
|
}
|
|
73
|
-
|
|
81
|
+
resolveChannel(params = this.otherParams) {
|
|
82
|
+
return (params == null ? void 0 : params.channel) || DEFAULT_SURCHARGE_CHANNEL;
|
|
83
|
+
}
|
|
84
|
+
async getSurchargeList(channel = this.resolveChannel()) {
|
|
74
85
|
try {
|
|
75
86
|
const surchargeListModule = this.core.getModule(
|
|
76
87
|
this.surchargeListModuleName
|
|
77
88
|
);
|
|
78
89
|
if (surchargeListModule == null ? void 0 : surchargeListModule.getSurchargeList) {
|
|
79
|
-
this.store.surchargeList = await surchargeListModule.getSurchargeList();
|
|
90
|
+
this.store.surchargeList = await surchargeListModule.getSurchargeList({ channel });
|
|
91
|
+
this.surchargeListChannel = channel;
|
|
80
92
|
return;
|
|
81
93
|
}
|
|
82
94
|
const surchargeList = await this.request.get(
|
|
83
95
|
"/order/custom-surcharge/available/v2",
|
|
84
96
|
{
|
|
85
|
-
|
|
86
|
-
channel: "online-store",
|
|
97
|
+
channel,
|
|
87
98
|
is_assemble_product_data: 1,
|
|
88
99
|
is_assemble_schedule_data: 1,
|
|
89
100
|
with: ["relationSchedule"]
|
|
90
101
|
}
|
|
91
102
|
);
|
|
92
103
|
this.store.surchargeList = (surchargeList == null ? void 0 : surchargeList.data) || [];
|
|
104
|
+
this.surchargeListChannel = channel;
|
|
93
105
|
} catch (error) {
|
|
94
106
|
console.warn("[SalesSummaryModule] 加载附加费配置失败", error);
|
|
95
107
|
this.store.surchargeList = [];
|
|
108
|
+
this.surchargeListChannel = channel;
|
|
96
109
|
}
|
|
97
110
|
}
|
|
98
111
|
getAppData(key) {
|
|
@@ -114,7 +127,11 @@ var SalesSummaryModule = class extends import_BaseModule.BaseModule {
|
|
|
114
127
|
}
|
|
115
128
|
async getSummary(params) {
|
|
116
129
|
var _a, _b;
|
|
117
|
-
const { products = [], isPriceIncludeTax, taxRate, shopDiscount } = params;
|
|
130
|
+
const { products = [], isPriceIncludeTax, taxRate, shopDiscount, channel } = params;
|
|
131
|
+
const summaryChannel = channel || this.resolveChannel();
|
|
132
|
+
if (summaryChannel !== this.surchargeListChannel) {
|
|
133
|
+
await this.getSurchargeList(summaryChannel);
|
|
134
|
+
}
|
|
118
135
|
const taxConfig = this.getTaxConfig();
|
|
119
136
|
const summarySchedule = this.core.getModule(
|
|
120
137
|
`${this.name.split("_")[0]}_schedule`
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import { Module, ModuleOptions, PisellCore } from '../../types';
|
|
2
2
|
import { BaseModule } from '../BaseModule';
|
|
3
|
-
import { SurchargeListItem, SurchargeListModuleAPI } from './types';
|
|
3
|
+
import { SurchargeListItem, SurchargeListModuleAPI, SurchargeListQuery } from './types';
|
|
4
4
|
export * from './types';
|
|
5
5
|
export declare class SurchargeListModule extends BaseModule implements Module, SurchargeListModuleAPI {
|
|
6
6
|
protected defaultName: string;
|
|
7
7
|
protected defaultVersion: string;
|
|
8
8
|
private request;
|
|
9
9
|
private store;
|
|
10
|
-
private
|
|
10
|
+
private loadingPromises;
|
|
11
|
+
private requestVersion;
|
|
11
12
|
constructor(name?: string, version?: string);
|
|
12
13
|
initialize(core: PisellCore, options: ModuleOptions): Promise<void>;
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
private resolveChannel;
|
|
15
|
+
getSurchargeList(query?: SurchargeListQuery): Promise<SurchargeListItem[]>;
|
|
16
|
+
refreshSurchargeList(query?: SurchargeListQuery): Promise<SurchargeListItem[]>;
|
|
15
17
|
private loadSurchargeList;
|
|
16
18
|
}
|
|
@@ -25,15 +25,17 @@ __export(SurchargeList_exports, {
|
|
|
25
25
|
module.exports = __toCommonJS(SurchargeList_exports);
|
|
26
26
|
var import_BaseModule = require("../BaseModule");
|
|
27
27
|
__reExport(SurchargeList_exports, require("./types"), module.exports);
|
|
28
|
+
var DEFAULT_SURCHARGE_CHANNEL = "online-store";
|
|
28
29
|
var SurchargeListModule = class extends import_BaseModule.BaseModule {
|
|
29
30
|
constructor(name, version) {
|
|
30
31
|
super(name, version);
|
|
31
32
|
this.defaultName = "surchargeList";
|
|
32
33
|
this.defaultVersion = "1.0.0";
|
|
33
|
-
this.
|
|
34
|
+
this.loadingPromises = /* @__PURE__ */ new Map();
|
|
35
|
+
this.requestVersion = 0;
|
|
34
36
|
}
|
|
35
37
|
async initialize(core, options) {
|
|
36
|
-
var _a, _b, _c;
|
|
38
|
+
var _a, _b, _c, _d, _e;
|
|
37
39
|
this.core = core;
|
|
38
40
|
this.store = options.store;
|
|
39
41
|
this.request = this.core.getPlugin("request");
|
|
@@ -41,44 +43,62 @@ var SurchargeListModule = class extends import_BaseModule.BaseModule {
|
|
|
41
43
|
(_a = options.initialState) == null ? void 0 : _a.surchargeList
|
|
42
44
|
);
|
|
43
45
|
this.store.surchargeList = hasInitialSurchargeList ? (_b = options.initialState) == null ? void 0 : _b.surchargeList : [];
|
|
44
|
-
this.store.
|
|
46
|
+
this.store.channel = ((_c = options.initialState) == null ? void 0 : _c.channel) || ((_d = options.otherParams) == null ? void 0 : _d.channel) || DEFAULT_SURCHARGE_CHANNEL;
|
|
47
|
+
this.store.isLoaded = Boolean((_e = options.initialState) == null ? void 0 : _e.isLoaded) || hasInitialSurchargeList;
|
|
45
48
|
if (!this.request) {
|
|
46
49
|
throw new Error("SurchargeListModule 需要 request 插件支持");
|
|
47
50
|
}
|
|
48
51
|
}
|
|
49
|
-
|
|
50
|
-
|
|
52
|
+
resolveChannel(query) {
|
|
53
|
+
return (query == null ? void 0 : query.channel) || DEFAULT_SURCHARGE_CHANNEL;
|
|
54
|
+
}
|
|
55
|
+
async getSurchargeList(query) {
|
|
56
|
+
const channel = this.resolveChannel(query);
|
|
57
|
+
if (this.store.isLoaded && this.store.channel === channel) {
|
|
51
58
|
return this.store.surchargeList;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
59
|
+
}
|
|
60
|
+
const loadingPromise = this.loadingPromises.get(channel);
|
|
61
|
+
if (loadingPromise)
|
|
62
|
+
return loadingPromise;
|
|
63
|
+
const nextPromise = this.loadSurchargeList(channel);
|
|
64
|
+
this.loadingPromises.set(channel, nextPromise);
|
|
65
|
+
return nextPromise;
|
|
56
66
|
}
|
|
57
|
-
async refreshSurchargeList() {
|
|
58
|
-
|
|
59
|
-
|
|
67
|
+
async refreshSurchargeList(query) {
|
|
68
|
+
const channel = this.resolveChannel(query);
|
|
69
|
+
const nextPromise = this.loadSurchargeList(channel);
|
|
70
|
+
this.loadingPromises.set(channel, nextPromise);
|
|
71
|
+
return nextPromise;
|
|
60
72
|
}
|
|
61
|
-
async loadSurchargeList() {
|
|
73
|
+
async loadSurchargeList(channel) {
|
|
74
|
+
const currentRequestVersion = ++this.requestVersion;
|
|
62
75
|
try {
|
|
63
76
|
const surchargeList = await this.request.get(
|
|
64
77
|
"/order/custom-surcharge/available/v2",
|
|
65
78
|
{
|
|
66
|
-
channel
|
|
79
|
+
channel,
|
|
67
80
|
is_assemble_product_data: 1,
|
|
68
81
|
is_assemble_schedule_data: 1,
|
|
69
82
|
with: ["relationSchedule"]
|
|
70
83
|
}
|
|
71
84
|
);
|
|
72
|
-
|
|
73
|
-
this.
|
|
74
|
-
|
|
85
|
+
const nextSurchargeList = (surchargeList == null ? void 0 : surchargeList.data) || [];
|
|
86
|
+
if (currentRequestVersion === this.requestVersion) {
|
|
87
|
+
this.store.surchargeList = nextSurchargeList;
|
|
88
|
+
this.store.channel = channel;
|
|
89
|
+
this.store.isLoaded = true;
|
|
90
|
+
}
|
|
91
|
+
return nextSurchargeList;
|
|
75
92
|
} catch (error) {
|
|
76
93
|
console.warn("[SurchargeListModule] 加载附加费配置失败", error);
|
|
77
|
-
this.
|
|
78
|
-
|
|
79
|
-
|
|
94
|
+
if (currentRequestVersion === this.requestVersion) {
|
|
95
|
+
this.store.surchargeList = [];
|
|
96
|
+
this.store.channel = channel;
|
|
97
|
+
this.store.isLoaded = true;
|
|
98
|
+
}
|
|
99
|
+
return [];
|
|
80
100
|
} finally {
|
|
81
|
-
this.
|
|
101
|
+
this.loadingPromises.delete(channel);
|
|
82
102
|
}
|
|
83
103
|
}
|
|
84
104
|
};
|
|
@@ -4,8 +4,12 @@ export interface SurchargeListItem {
|
|
|
4
4
|
export interface SurchargeListState {
|
|
5
5
|
surchargeList: SurchargeListItem[];
|
|
6
6
|
isLoaded: boolean;
|
|
7
|
+
channel?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface SurchargeListQuery {
|
|
10
|
+
channel?: string;
|
|
7
11
|
}
|
|
8
12
|
export interface SurchargeListModuleAPI {
|
|
9
|
-
getSurchargeList(): Promise<SurchargeListItem[]>;
|
|
10
|
-
refreshSurchargeList(): Promise<SurchargeListItem[]>;
|
|
13
|
+
getSurchargeList(query?: SurchargeListQuery): Promise<SurchargeListItem[]>;
|
|
14
|
+
refreshSurchargeList(query?: SurchargeListQuery): Promise<SurchargeListItem[]>;
|
|
11
15
|
}
|
|
@@ -1696,15 +1696,17 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1696
1696
|
return this.store.order.discardPendingVoucherPayments();
|
|
1697
1697
|
}
|
|
1698
1698
|
getWalletProductList() {
|
|
1699
|
-
var _a, _b
|
|
1699
|
+
var _a, _b;
|
|
1700
1700
|
const tempOrder = (_a = this.store.order) == null ? void 0 : _a.getTempOrder();
|
|
1701
1701
|
if (!((_b = tempOrder == null ? void 0 : tempOrder.products) == null ? void 0 : _b.length))
|
|
1702
1702
|
return [];
|
|
1703
|
-
const
|
|
1704
|
-
const walletProducts = products.map((product) => {
|
|
1703
|
+
const walletProducts = tempOrder == null ? void 0 : tempOrder.products.map((product) => {
|
|
1705
1704
|
const metadata = product.metadata || {};
|
|
1705
|
+
const rawHolderId = product.holder_id ?? metadata.holder_id;
|
|
1706
|
+
const holderIdValue = Array.isArray(rawHolderId) ? rawHolderId[0] : rawHolderId;
|
|
1707
|
+
const holder_id = Number.isInteger(Number(holderIdValue)) ? Number(holderIdValue) : void 0;
|
|
1706
1708
|
return {
|
|
1707
|
-
product_id: product.product_id,
|
|
1709
|
+
product_id: product.product_id || 0,
|
|
1708
1710
|
product_variant_id: String(product.product_variant_id ?? ""),
|
|
1709
1711
|
quantity: product.num || 1,
|
|
1710
1712
|
is_price_include_tax: tempOrder.is_price_include_tax,
|
|
@@ -1712,7 +1714,7 @@ var BaseSalesImpl = class extends import_BaseModule.BaseModule {
|
|
|
1712
1714
|
tax_fee: product.tax_fee,
|
|
1713
1715
|
selling_price: Number(product.selling_price || 0),
|
|
1714
1716
|
discount_list: product.discount_list || [],
|
|
1715
|
-
holder_id
|
|
1717
|
+
holder_id,
|
|
1716
1718
|
original_price: product.original_price,
|
|
1717
1719
|
main_product_original_price: metadata.main_product_original_price ?? product.original_price,
|
|
1718
1720
|
main_product_selling_price: metadata.main_product_selling_price ?? product.selling_price,
|
|
@@ -88,7 +88,8 @@ function normalizeBundleItems(bundleItems, preferPriceField = false) {
|
|
|
88
88
|
price: bundleItem.price ?? unitStr,
|
|
89
89
|
bundle_selling_price: unitStr,
|
|
90
90
|
original_price: bundleItem.original_price ?? bundleItem.product_price ?? bundleItem.price ?? unitStr,
|
|
91
|
-
option: normalizeOptionItems(bundleItem == null ? void 0 : bundleItem.option)
|
|
91
|
+
option: normalizeOptionItems(bundleItem == null ? void 0 : bundleItem.option),
|
|
92
|
+
discount_list: preferPriceField ? [] : bundleItem.discount_list
|
|
92
93
|
};
|
|
93
94
|
normalizedItem.bundle_selling_price = (0, import_utils.getBundleSellingMagnitude)(magnitudeSource).toFixed(2);
|
|
94
95
|
if ((normalizedItem.price_type ?? normalizedItem.custom_price_type) === "markdown" && (normalizedItem.price_type_ext === "" || normalizedItem.price_type_ext === void 0 || normalizedItem.price_type_ext === null)) {
|
|
@@ -441,19 +441,7 @@ export declare class BookingTicketImpl extends BaseSalesImpl implements Module {
|
|
|
441
441
|
* 加车两阶段主决策(规格弹窗 / 资源编辑 / 直接加车)。
|
|
442
442
|
* 与 ticketBooking `handleSelectProduct` + `handleBooking4Service` 等价。
|
|
443
443
|
*/
|
|
444
|
-
decideAddProduct(item: any, options?: Partial<AddProductDecideContext>):
|
|
445
|
-
action: "reloadCatalog";
|
|
446
|
-
} | {
|
|
447
|
-
action: "add";
|
|
448
|
-
cacheItem: any;
|
|
449
|
-
} | {
|
|
450
|
-
action: "requiresDetail";
|
|
451
|
-
payload: AddProductRequiresDetailPayload;
|
|
452
|
-
} | {
|
|
453
|
-
action: "requiresBookingEdit";
|
|
454
|
-
cacheItem: any;
|
|
455
|
-
payload: import("./utils/addProductDecision").AddProductRequiresBookingEditPayload;
|
|
456
|
-
};
|
|
444
|
+
decideAddProduct(item: any, options?: Partial<AddProductDecideContext>): import("./utils/addProductDecision").AddProductDecision;
|
|
457
445
|
/** 规格弹窗 callback 后的第二段决策。 */
|
|
458
446
|
decideAfterDetail(cacheItem: any, options?: Partial<AddProductDecideContext>): import("./utils/addProductDecision").AddProductDecision;
|
|
459
447
|
/**
|