@pisell/pisellos 2.2.272 → 2.2.274
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/core/index.d.ts +0 -2
- package/dist/core/index.js +0 -7
- package/dist/model/strategy/adapter/promotion/adapter.d.ts +0 -4
- package/dist/model/strategy/adapter/promotion/adapter.js +0 -23
- package/dist/model/strategy/adapter/promotion/evaluator.d.ts +0 -17
- package/dist/model/strategy/adapter/promotion/evaluator.js +6 -279
- package/dist/model/strategy/adapter/promotion/examples.d.ts +0 -86
- package/dist/model/strategy/adapter/promotion/examples.js +0 -99
- package/dist/model/strategy/adapter/promotion/index.d.ts +1 -1
- package/dist/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/model/strategy/adapter/promotion/type.d.ts +2 -90
- package/dist/model/strategy/adapter/promotion/type.js +0 -45
- package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +16 -12
- package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +6 -3
- package/dist/modules/OpenData/index.d.ts +0 -2
- package/dist/modules/OpenData/index.js +0 -8
- package/dist/modules/Order/index.d.ts +12 -31
- package/dist/modules/Order/index.js +562 -778
- package/dist/modules/Order/types.d.ts +22 -36
- package/dist/modules/Order/types.js +11 -0
- package/dist/modules/Order/utils/orderCollectionIdentity.js +2 -7
- package/dist/modules/Order/utils.js +6 -10
- package/dist/modules/Payment/index.d.ts +0 -2
- package/dist/modules/Payment/index.js +50 -79
- package/dist/modules/Payment/types.d.ts +27 -29
- package/dist/modules/Payment/types.js +3 -5
- package/dist/modules/Rules/index.d.ts +0 -1
- package/dist/modules/Rules/index.js +39 -55
- package/dist/modules/SalesSummary/utils.js +7 -1
- package/dist/server/index.d.ts +0 -16
- package/dist/server/index.js +1036 -1933
- package/dist/server/modules/order/index.d.ts +4 -49
- package/dist/server/modules/order/index.js +695 -1574
- package/dist/server/modules/order/types.d.ts +3 -11
- package/dist/server/modules/order/types.js +1 -1
- package/dist/solution/BaseSales/index.d.ts +25 -59
- package/dist/solution/BaseSales/index.js +490 -767
- package/dist/solution/BaseSales/utils/cartPromotion.d.ts +1 -3
- package/dist/solution/BaseSales/utils/cartPromotion.js +36 -93
- package/dist/solution/BaseSales/utils/parseSalesResponse.d.ts +1 -6
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.d.ts +5 -21
- package/dist/solution/BookingTicket/index.js +49 -126
- package/dist/solution/BookingTicket/types.d.ts +3 -0
- package/dist/solution/BookingTicket/utils/addProductDecision.js +6 -0
- package/dist/solution/BookingTicket/utils/cartView.js +44 -32
- package/dist/solution/BookingTicket/utils/weighingProductSku.d.ts +5 -0
- package/dist/solution/BookingTicket/utils/weighingProductSku.js +45 -0
- package/dist/solution/Sales/index.d.ts +0 -1
- package/dist/solution/Sales/index.js +2 -10
- package/dist/solution/ScanOrder/index.js +20 -31
- package/dist/solution/VenueBooking/index.js +19 -30
- package/dist/types/index.d.ts +0 -1
- package/lib/core/index.d.ts +0 -2
- package/lib/core/index.js +0 -4
- package/lib/model/strategy/adapter/promotion/adapter.d.ts +0 -4
- package/lib/model/strategy/adapter/promotion/adapter.js +0 -20
- package/lib/model/strategy/adapter/promotion/evaluator.d.ts +0 -17
- package/lib/model/strategy/adapter/promotion/evaluator.js +0 -235
- package/lib/model/strategy/adapter/promotion/examples.d.ts +0 -86
- package/lib/model/strategy/adapter/promotion/examples.js +0 -91
- package/lib/model/strategy/adapter/promotion/index.d.ts +1 -1
- package/lib/model/strategy/adapter/promotion/index.js +49 -0
- package/lib/model/strategy/adapter/promotion/type.d.ts +2 -90
- package/lib/model/strategy/adapter/promotion/type.js +0 -2
- package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +5 -2
- package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +2 -1
- package/lib/modules/OpenData/index.d.ts +0 -2
- package/lib/modules/OpenData/index.js +0 -5
- package/lib/modules/Order/index.d.ts +12 -31
- package/lib/modules/Order/index.js +142 -201
- package/lib/modules/Order/types.d.ts +22 -36
- package/lib/modules/Order/utils/orderCollectionIdentity.js +0 -3
- package/lib/modules/Order/utils.js +4 -11
- package/lib/modules/Payment/index.d.ts +0 -2
- package/lib/modules/Payment/index.js +13 -34
- package/lib/modules/Payment/types.d.ts +27 -29
- package/lib/modules/Payment/types.js +3 -3
- package/lib/modules/Rules/index.d.ts +0 -1
- package/lib/modules/Rules/index.js +22 -41
- package/lib/modules/SalesSummary/utils.js +5 -1
- package/lib/server/index.d.ts +0 -16
- package/lib/server/index.js +18 -670
- package/lib/server/modules/order/index.d.ts +4 -49
- package/lib/server/modules/order/index.js +66 -657
- package/lib/server/modules/order/types.d.ts +3 -11
- package/lib/solution/BaseSales/index.d.ts +25 -59
- package/lib/solution/BaseSales/index.js +79 -246
- package/lib/solution/BaseSales/utils/cartPromotion.d.ts +1 -3
- package/lib/solution/BaseSales/utils/cartPromotion.js +17 -65
- package/lib/solution/BaseSales/utils/parseSalesResponse.d.ts +1 -6
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.d.ts +5 -21
- package/lib/solution/BookingTicket/index.js +8 -59
- package/lib/solution/BookingTicket/types.d.ts +3 -0
- package/lib/solution/BookingTicket/utils/addProductDecision.js +4 -0
- package/lib/solution/BookingTicket/utils/cartView.js +43 -30
- package/lib/solution/BookingTicket/utils/weighingProductSku.d.ts +5 -0
- package/lib/solution/BookingTicket/utils/weighingProductSku.js +63 -0
- package/lib/solution/Sales/index.d.ts +0 -1
- package/lib/solution/Sales/index.js +3 -5
- package/lib/solution/ScanOrder/index.js +0 -8
- package/lib/solution/VenueBooking/index.js +0 -8
- package/lib/types/index.d.ts +0 -1
- package/package.json +1 -1
- package/dist/modules/Order/payment-utils.d.ts +0 -26
- package/dist/modules/Order/payment-utils.js +0 -225
- package/dist/utils/payment-number.d.ts +0 -9
- package/dist/utils/payment-number.js +0 -69
- package/lib/modules/Order/payment-utils.d.ts +0 -26
- package/lib/modules/Order/payment-utils.js +0 -224
- package/lib/utils/payment-number.d.ts +0 -9
- package/lib/utils/payment-number.js +0 -64
|
@@ -37,8 +37,6 @@ import Decimal from 'decimal.js';
|
|
|
37
37
|
import { cloneDeep, mergeWith } from 'lodash-es';
|
|
38
38
|
import { createModule } from "../BookingByStep/types";
|
|
39
39
|
import { composeLinePrice, createUuidV4, ensureProductSku, getProductSkuOptions, resolveIsFormSubject, sumOptionUnitPrice } from "../../modules/Order/utils";
|
|
40
|
-
import { ensureOrderPaymentNumber, isIdentifiedPendingOrderPayment, isPendingOrderPayment, mergeOrderPaymentListsByIdentity, resolveOrderPaymentIdentity } from "../../modules/Order/payment-utils";
|
|
41
|
-
import { resolvePaymentNumberDevicePrefix, resolvePaymentNumberDevicePrefixFromDeviceId } from "../../utils/payment-number";
|
|
42
40
|
import { applyOrderCollectionUidRemaps, getOrderCollectionPersistentId, getOrderCollectionReferenceUid, getOrderCollectionUid, isSameOrderCollectionItem, mergeOrderCollectionItems, normalizeOrderCollection, normalizeOrderCollections, setOrderCollectionUid } from "../../modules/Order/utils/orderCollectionIdentity";
|
|
43
41
|
import dayjs from 'dayjs';
|
|
44
42
|
export * from "./types";
|
|
@@ -74,10 +72,6 @@ function preserveManualProductDiscountProducts(previousProducts, nextProducts) {
|
|
|
74
72
|
function isBaseSalesHistoricalDiscountEntry(discount) {
|
|
75
73
|
return Boolean((discount === null || discount === void 0 ? void 0 : discount.isEditMode) || (discount === null || discount === void 0 ? void 0 : discount.isDisabled) || (discount === null || discount === void 0 ? void 0 : discount.order_discount_id) != null);
|
|
76
74
|
}
|
|
77
|
-
function getBaseSalesUniqueArrayMetadataKey(key) {
|
|
78
|
-
if (key === 'products' || key === 'bookings') return 'unique_identification_number';
|
|
79
|
-
return null;
|
|
80
|
-
}
|
|
81
75
|
var BASE_SALES_PERSISTENT_ID_FIELD_BY_KIND = {
|
|
82
76
|
product: 'order_detail_id',
|
|
83
77
|
booking: 'schedule_event_id',
|
|
@@ -149,15 +143,6 @@ function mergeBaseSalesCollectionItem(kind, currentItem, incomingItem, uidRemaps
|
|
|
149
143
|
return kind === 'product' ? mergeBaseSalesProductSnapshotFields(currentItem, mergedItem) : mergedItem;
|
|
150
144
|
}
|
|
151
145
|
function mergeBaseSalesOrderCollection(kind, currentValue, incomingValue, strategy, uidRemaps) {
|
|
152
|
-
if (kind === 'payment') {
|
|
153
|
-
return mergeOrderPaymentListsByIdentity(currentValue, incomingValue, strategy === 'preserve-local' ? {
|
|
154
|
-
preserveUnmatchedExisting: true
|
|
155
|
-
} : {
|
|
156
|
-
preserveUnmatchedExistingWhen: function preserveUnmatchedExistingWhen(payment) {
|
|
157
|
-
return isIdentifiedPendingOrderPayment(payment) || !getOrderCollectionPersistentId('payment', payment);
|
|
158
|
-
}
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
146
|
var currentItems = normalizeOrderCollection(kind, currentValue, {
|
|
162
147
|
ensureUid: false
|
|
163
148
|
}).items;
|
|
@@ -204,34 +189,6 @@ function normalizeBaseSalesRecordCollections(sourceRecord, options) {
|
|
|
204
189
|
}
|
|
205
190
|
return normalizedRecord;
|
|
206
191
|
}
|
|
207
|
-
function getBaseSalesMetadataUid(item, metadataKey) {
|
|
208
|
-
var _item$metadata$metada, _item$metadata;
|
|
209
|
-
var uid = (_item$metadata$metada = item === null || item === void 0 || (_item$metadata = item.metadata) === null || _item$metadata === void 0 ? void 0 : _item$metadata[metadataKey]) !== null && _item$metadata$metada !== void 0 ? _item$metadata$metada : item === null || item === void 0 ? void 0 : item[metadataKey];
|
|
210
|
-
if (uid === undefined || uid === null || uid === '') return null;
|
|
211
|
-
return String(uid);
|
|
212
|
-
}
|
|
213
|
-
function mergeBaseSalesUniqueArray(currentValue, loadedValue, metadataKey) {
|
|
214
|
-
var result = [];
|
|
215
|
-
var indexByUid = new Map();
|
|
216
|
-
var appendOrReplaceByUid = function appendOrReplaceByUid(item) {
|
|
217
|
-
var clonedItem = cloneDeep(item);
|
|
218
|
-
var uid = getBaseSalesMetadataUid(clonedItem, metadataKey);
|
|
219
|
-
if (!uid) {
|
|
220
|
-
result.push(clonedItem);
|
|
221
|
-
return;
|
|
222
|
-
}
|
|
223
|
-
var existingIndex = indexByUid.get(uid);
|
|
224
|
-
if (existingIndex !== undefined) {
|
|
225
|
-
result[existingIndex] = clonedItem;
|
|
226
|
-
return;
|
|
227
|
-
}
|
|
228
|
-
indexByUid.set(uid, result.length);
|
|
229
|
-
result.push(clonedItem);
|
|
230
|
-
};
|
|
231
|
-
currentValue.forEach(appendOrReplaceByUid);
|
|
232
|
-
loadedValue.forEach(appendOrReplaceByUid);
|
|
233
|
-
return result;
|
|
234
|
-
}
|
|
235
192
|
function mergeSalesDetailRecordWithTempOrder(currentTempOrder, loadedRecord, strategy) {
|
|
236
193
|
var normalizedLoadedRecord = normalizeBaseSalesRecordCollections(loadedRecord || {}, {
|
|
237
194
|
ensureUid: false
|
|
@@ -249,15 +206,6 @@ function mergeSalesDetailRecordWithTempOrder(currentTempOrder, loadedRecord, str
|
|
|
249
206
|
return mergeBaseSalesOrderCollection(collectionKind, Array.isArray(currentValue) ? currentValue : [], loadedValue, strategy, uidRemaps);
|
|
250
207
|
}
|
|
251
208
|
if (Array.isArray(currentValue) && Array.isArray(loadedValue)) {
|
|
252
|
-
if (key === 'payments' || key === 'payment') {
|
|
253
|
-
return mergeOrderPaymentListsByIdentity(currentValue, loadedValue, {
|
|
254
|
-
preserveUnmatchedExisting: true
|
|
255
|
-
});
|
|
256
|
-
}
|
|
257
|
-
var metadataKey = getBaseSalesUniqueArrayMetadataKey(key);
|
|
258
|
-
if (metadataKey) {
|
|
259
|
-
return mergeBaseSalesUniqueArray(currentValue, loadedValue, metadataKey);
|
|
260
|
-
}
|
|
261
209
|
return [].concat(_toConsumableArray(cloneDeep(currentValue)), _toConsumableArray(cloneDeep(loadedValue)));
|
|
262
210
|
}
|
|
263
211
|
if (Array.isArray(loadedValue)) return cloneDeep(loadedValue);
|
|
@@ -269,22 +217,6 @@ function mergeSalesDetailRecordWithTempOrder(currentTempOrder, loadedRecord, str
|
|
|
269
217
|
delete mergedRecord.request_unique_idempotency_token;
|
|
270
218
|
return normalizeBaseSalesRecordCollections(applyOrderCollectionUidRemaps(mergedRecord, uidRemaps));
|
|
271
219
|
}
|
|
272
|
-
function filterPendingPaymentsFromLoadedSalesDetail(sourceRecord) {
|
|
273
|
-
if (!sourceRecord || _typeof(sourceRecord) !== 'object') return sourceRecord;
|
|
274
|
-
var record = _objectSpread({}, sourceRecord);
|
|
275
|
-
if (Array.isArray(sourceRecord.payments)) {
|
|
276
|
-
record.payments = sourceRecord.payments.filter(function (payment) {
|
|
277
|
-
return !isPendingOrderPayment(payment);
|
|
278
|
-
});
|
|
279
|
-
}
|
|
280
|
-
// 兼容少量历史详情数据使用的单数 payment 字段。
|
|
281
|
-
if (Array.isArray(sourceRecord.payment)) {
|
|
282
|
-
record.payment = sourceRecord.payment.filter(function (payment) {
|
|
283
|
-
return !isPendingOrderPayment(payment);
|
|
284
|
-
});
|
|
285
|
-
}
|
|
286
|
-
return record;
|
|
287
|
-
}
|
|
288
220
|
export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
289
221
|
_inherits(BaseSalesImpl, _BaseModule);
|
|
290
222
|
var _super = _createSuper(BaseSalesImpl);
|
|
@@ -304,11 +236,6 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
304
236
|
});
|
|
305
237
|
_defineProperty(_assertThisInitialized(_this), "otherParams", {});
|
|
306
238
|
_defineProperty(_assertThisInitialized(_this), "cacheId", void 0);
|
|
307
|
-
/**
|
|
308
|
-
* 由已在初始化阶段解析过设备短号的业务解决方案写入。
|
|
309
|
-
* 未设置时,支付编号仍按原逻辑实时读取设备信息。
|
|
310
|
-
*/
|
|
311
|
-
_defineProperty(_assertThisInitialized(_this), "paymentNumberDevicePrefix", null);
|
|
312
239
|
/**
|
|
313
240
|
* window / request 暴露为 public:现存外部工具(如 BookingTicket Scan)通过
|
|
314
241
|
* `solution.window` / `solution.request` 直接访问插件,保持原有契约不破坏。
|
|
@@ -778,6 +705,40 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
778
705
|
if (!Number.isFinite(productId)) return null;
|
|
779
706
|
return productId;
|
|
780
707
|
}
|
|
708
|
+
|
|
709
|
+
/**
|
|
710
|
+
* Change Time / customer reprice 必须沿用商品列表的渠道口径。
|
|
711
|
+
* SalesSdk Provider 通常将渠道存为 platform,因此不能只读取 otherParams.channel。
|
|
712
|
+
*/
|
|
713
|
+
}, {
|
|
714
|
+
key: "getPriceQueryChannel",
|
|
715
|
+
value: function getPriceQueryChannel(channel) {
|
|
716
|
+
var _this$otherParams2, _ref5, _ref6, _this$otherParams3, _this$otherParams4;
|
|
717
|
+
var strategyContext = (_this$otherParams2 = this.otherParams) !== null && _this$otherParams2 !== void 0 && _this$otherParams2.strategy_context && _typeof(this.otherParams.strategy_context) === 'object' ? this.otherParams.strategy_context : {};
|
|
718
|
+
var value = (_ref5 = (_ref6 = channel !== null && channel !== void 0 ? channel : strategyContext.channel) !== null && _ref6 !== void 0 ? _ref6 : (_this$otherParams3 = this.otherParams) === null || _this$otherParams3 === void 0 ? void 0 : _this$otherParams3.channel) !== null && _ref5 !== void 0 ? _ref5 : (_this$otherParams4 = this.otherParams) === null || _this$otherParams4 === void 0 ? void 0 : _this$otherParams4.platform;
|
|
719
|
+
if (value === undefined || value === null || String(value).trim() === '') {
|
|
720
|
+
return undefined;
|
|
721
|
+
}
|
|
722
|
+
return String(value).trim();
|
|
723
|
+
}
|
|
724
|
+
/**
|
|
725
|
+
* /product/query 的智能定价评估只读取 strategy_context;
|
|
726
|
+
* application_code 仅作为接口兼容字段,不能替代 channel / business_code。
|
|
727
|
+
*/
|
|
728
|
+
}, {
|
|
729
|
+
key: "getPriceQueryStrategyContext",
|
|
730
|
+
value: function getPriceQueryStrategyContext(channel) {
|
|
731
|
+
var _this$otherParams5, _ref7, _strategyContext$busi, _this$otherParams6, _this$otherParams7;
|
|
732
|
+
var inherited = (_this$otherParams5 = this.otherParams) !== null && _this$otherParams5 !== void 0 && _this$otherParams5.strategy_context && _typeof(this.otherParams.strategy_context) === 'object' ? this.otherParams.strategy_context : {};
|
|
733
|
+
var strategyContext = _objectSpread({}, inherited);
|
|
734
|
+
var resolvedChannel = this.getPriceQueryChannel(channel);
|
|
735
|
+
var businessCode = (_ref7 = (_strategyContext$busi = strategyContext.business_code) !== null && _strategyContext$busi !== void 0 ? _strategyContext$busi : (_this$otherParams6 = this.otherParams) === null || _this$otherParams6 === void 0 ? void 0 : _this$otherParams6.businessCode) !== null && _ref7 !== void 0 ? _ref7 : (_this$otherParams7 = this.otherParams) === null || _this$otherParams7 === void 0 ? void 0 : _this$otherParams7.business_code;
|
|
736
|
+
if (resolvedChannel) strategyContext.channel = resolvedChannel;
|
|
737
|
+
if (businessCode !== undefined && businessCode !== null && String(businessCode).trim() !== '') {
|
|
738
|
+
strategyContext.business_code = String(businessCode).trim();
|
|
739
|
+
}
|
|
740
|
+
return strategyContext;
|
|
741
|
+
}
|
|
781
742
|
}, {
|
|
782
743
|
key: "getPriceQuerySchedule",
|
|
783
744
|
value: function getPriceQuerySchedule(params) {
|
|
@@ -810,7 +771,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
810
771
|
key: "loadProductsForPriceQuery",
|
|
811
772
|
value: function () {
|
|
812
773
|
var _loadProductsForPriceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(params) {
|
|
813
|
-
var ids, productsById,
|
|
774
|
+
var ids, productsById, channel, strategyContext, _response$data, response, list;
|
|
814
775
|
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
815
776
|
while (1) switch (_context7.prev = _context7.next) {
|
|
816
777
|
case 0:
|
|
@@ -824,9 +785,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
824
785
|
}
|
|
825
786
|
return _context7.abrupt("return", productsById);
|
|
826
787
|
case 4:
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
788
|
+
channel = this.getPriceQueryChannel(params.channel);
|
|
789
|
+
strategyContext = this.getPriceQueryStrategyContext(channel);
|
|
790
|
+
_context7.prev = 6;
|
|
791
|
+
_context7.next = 9;
|
|
792
|
+
return this.request.post('/product/query', _objectSpread({
|
|
830
793
|
ids: ids,
|
|
831
794
|
open_quotation: 1,
|
|
832
795
|
open_bundle: 1,
|
|
@@ -836,39 +799,41 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
836
799
|
customer_id: params.customerId,
|
|
837
800
|
schedule_date: params.schedule.schedule_date,
|
|
838
801
|
schedule_datetime: params.schedule.schedule_datetime,
|
|
839
|
-
application_code:
|
|
840
|
-
}, {
|
|
802
|
+
application_code: channel
|
|
803
|
+
}, Object.keys(strategyContext).length ? {
|
|
804
|
+
strategy_context: strategyContext
|
|
805
|
+
} : {}), {
|
|
841
806
|
osServer: true,
|
|
842
807
|
customToast: function customToast() {}
|
|
843
808
|
});
|
|
844
|
-
case
|
|
809
|
+
case 9:
|
|
845
810
|
response = _context7.sent;
|
|
846
811
|
list = (response === null || response === void 0 || (_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.list) || (response === null || response === void 0 ? void 0 : response.list) || [];
|
|
847
812
|
if (Array.isArray(list)) {
|
|
848
|
-
_context7.next =
|
|
813
|
+
_context7.next = 13;
|
|
849
814
|
break;
|
|
850
815
|
}
|
|
851
816
|
return _context7.abrupt("return", productsById);
|
|
852
|
-
case
|
|
817
|
+
case 13:
|
|
853
818
|
list.forEach(function (item) {
|
|
854
819
|
var _item$id;
|
|
855
820
|
var productId = Number((_item$id = item === null || item === void 0 ? void 0 : item.id) !== null && _item$id !== void 0 ? _item$id : item === null || item === void 0 ? void 0 : item.product_id);
|
|
856
821
|
if (Number.isFinite(productId)) productsById.set(productId, item);
|
|
857
822
|
});
|
|
858
823
|
return _context7.abrupt("return", productsById);
|
|
859
|
-
case
|
|
860
|
-
_context7.prev =
|
|
861
|
-
_context7.t0 = _context7["catch"](
|
|
824
|
+
case 17:
|
|
825
|
+
_context7.prev = 17;
|
|
826
|
+
_context7.t0 = _context7["catch"](6);
|
|
862
827
|
this.logWarning('loadProductsForPriceQuery: 商品批量重查失败,使用入参 fallback', {
|
|
863
828
|
ids: ids,
|
|
864
829
|
error: _context7.t0 instanceof Error ? _context7.t0.message : String(_context7.t0)
|
|
865
830
|
});
|
|
866
831
|
return _context7.abrupt("return", productsById);
|
|
867
|
-
case
|
|
832
|
+
case 21:
|
|
868
833
|
case "end":
|
|
869
834
|
return _context7.stop();
|
|
870
835
|
}
|
|
871
|
-
}, _callee7, this, [[
|
|
836
|
+
}, _callee7, this, [[6, 17]]);
|
|
872
837
|
}));
|
|
873
838
|
function loadProductsForPriceQuery(_x5) {
|
|
874
839
|
return _loadProductsForPriceQuery.apply(this, arguments);
|
|
@@ -921,10 +886,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
921
886
|
return groups.flatMap(function (group) {
|
|
922
887
|
var items = Array.isArray(group === null || group === void 0 ? void 0 : group.bundle_item) ? group.bundle_item : Array.isArray(group === null || group === void 0 ? void 0 : group.bundleItem) ? group.bundleItem : [];
|
|
923
888
|
return items.map(function (item) {
|
|
924
|
-
var _item$group_id,
|
|
889
|
+
var _item$group_id, _ref8, _item$bundle_group_id;
|
|
925
890
|
return _objectSpread(_objectSpread({}, item), {}, {
|
|
926
891
|
group_id: (_item$group_id = item === null || item === void 0 ? void 0 : item.group_id) !== null && _item$group_id !== void 0 ? _item$group_id : group === null || group === void 0 ? void 0 : group.id,
|
|
927
|
-
bundle_group_id: (
|
|
892
|
+
bundle_group_id: (_ref8 = (_item$bundle_group_id = item === null || item === void 0 ? void 0 : item.bundle_group_id) !== null && _item$bundle_group_id !== void 0 ? _item$bundle_group_id : item === null || item === void 0 ? void 0 : item.group_id) !== null && _ref8 !== void 0 ? _ref8 : group === null || group === void 0 ? void 0 : group.id
|
|
928
893
|
});
|
|
929
894
|
});
|
|
930
895
|
});
|
|
@@ -955,21 +920,21 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
955
920
|
}, {
|
|
956
921
|
key: "getAuthoritativeBundleUnitPrice",
|
|
957
922
|
value: function getAuthoritativeBundleUnitPrice(bundle) {
|
|
958
|
-
var
|
|
959
|
-
return (
|
|
923
|
+
var _ref9, _ref10, _ref11, _bundle$price;
|
|
924
|
+
return (_ref9 = (_ref10 = (_ref11 = (_bundle$price = bundle.price) !== null && _bundle$price !== void 0 ? _bundle$price : bundle.bundle_selling_price) !== null && _ref11 !== void 0 ? _ref11 : bundle.custom_price) !== null && _ref10 !== void 0 ? _ref10 : bundle.product_price) !== null && _ref9 !== void 0 ? _ref9 : bundle.base_price;
|
|
960
925
|
}
|
|
961
926
|
}, {
|
|
962
927
|
key: "mergeProductForPriceQuery",
|
|
963
928
|
value: function mergeProductForPriceQuery(product, authoritativeProduct) {
|
|
964
929
|
var _this5 = this,
|
|
965
930
|
_product$id,
|
|
966
|
-
|
|
931
|
+
_ref12,
|
|
967
932
|
_product$product_id2,
|
|
968
|
-
|
|
933
|
+
_ref13,
|
|
969
934
|
_product$product_vari,
|
|
970
|
-
|
|
935
|
+
_ref14,
|
|
971
936
|
_product$num,
|
|
972
|
-
|
|
937
|
+
_ref15,
|
|
973
938
|
_product$quantity,
|
|
974
939
|
_product$metadata4;
|
|
975
940
|
if (!authoritativeProduct) return product;
|
|
@@ -989,10 +954,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
989
954
|
});
|
|
990
955
|
return _objectSpread(_objectSpread(_objectSpread({}, product), authoritativeProduct), {}, {
|
|
991
956
|
id: (_product$id = product.id) !== null && _product$id !== void 0 ? _product$id : authoritativeProduct.id,
|
|
992
|
-
product_id: (
|
|
993
|
-
product_variant_id: (
|
|
994
|
-
num: (
|
|
995
|
-
quantity: (
|
|
957
|
+
product_id: (_ref12 = (_product$product_id2 = product.product_id) !== null && _product$product_id2 !== void 0 ? _product$product_id2 : authoritativeProduct.product_id) !== null && _ref12 !== void 0 ? _ref12 : authoritativeProduct.id,
|
|
958
|
+
product_variant_id: (_ref13 = (_product$product_vari = product.product_variant_id) !== null && _product$product_vari !== void 0 ? _product$product_vari : authoritativeProduct.product_variant_id) !== null && _ref13 !== void 0 ? _ref13 : 0,
|
|
959
|
+
num: (_ref14 = (_product$num = product.num) !== null && _product$num !== void 0 ? _product$num : product.quantity) !== null && _ref14 !== void 0 ? _ref14 : authoritativeProduct.num,
|
|
960
|
+
quantity: (_ref15 = (_product$quantity = product.quantity) !== null && _product$quantity !== void 0 ? _product$quantity : product.num) !== null && _ref15 !== void 0 ? _ref15 : authoritativeProduct.quantity,
|
|
996
961
|
product_sku: function () {
|
|
997
962
|
var authoritativeSku = ensureProductSku(authoritativeProduct);
|
|
998
963
|
var productSku = ensureProductSku(product);
|
|
@@ -1008,8 +973,8 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1008
973
|
}, {
|
|
1009
974
|
key: "getSubmitOrderSalesChannel",
|
|
1010
975
|
value: function getSubmitOrderSalesChannel() {
|
|
1011
|
-
var _this$
|
|
1012
|
-
return (_this$
|
|
976
|
+
var _this$otherParams8;
|
|
977
|
+
return (_this$otherParams8 = this.otherParams) === null || _this$otherParams8 === void 0 ? void 0 : _this$otherParams8.channel;
|
|
1013
978
|
}
|
|
1014
979
|
|
|
1015
980
|
/**
|
|
@@ -1068,24 +1033,24 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1068
1033
|
value: (function () {
|
|
1069
1034
|
var _syncOtherParamsToSubModules = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(changedParams) {
|
|
1070
1035
|
var _this6 = this;
|
|
1071
|
-
var
|
|
1072
|
-
|
|
1036
|
+
var _ref16,
|
|
1037
|
+
_ref16$cover,
|
|
1073
1038
|
cover,
|
|
1074
1039
|
nextSubModuleOtherParams,
|
|
1075
1040
|
_args10 = arguments;
|
|
1076
1041
|
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
1077
1042
|
while (1) switch (_context10.prev = _context10.next) {
|
|
1078
1043
|
case 0:
|
|
1079
|
-
|
|
1044
|
+
_ref16 = _args10.length > 1 && _args10[1] !== undefined ? _args10[1] : {}, _ref16$cover = _ref16.cover, cover = _ref16$cover === void 0 ? false : _ref16$cover;
|
|
1080
1045
|
nextSubModuleOtherParams = this.buildSubModuleOtherParams();
|
|
1081
1046
|
_context10.next = 4;
|
|
1082
1047
|
return Promise.all(Object.entries(this.store).map( /*#__PURE__*/function () {
|
|
1083
|
-
var
|
|
1084
|
-
var
|
|
1048
|
+
var _ref18 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(_ref17) {
|
|
1049
|
+
var _ref19, moduleName, subModule, targetModule;
|
|
1085
1050
|
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
1086
1051
|
while (1) switch (_context9.prev = _context9.next) {
|
|
1087
1052
|
case 0:
|
|
1088
|
-
|
|
1053
|
+
_ref19 = _slicedToArray(_ref17, 2), moduleName = _ref19[0], subModule = _ref19[1];
|
|
1089
1054
|
if (!_this6.reusedSharedSubModuleNames.has(moduleName)) {
|
|
1090
1055
|
_context9.next = 3;
|
|
1091
1056
|
break;
|
|
@@ -1111,7 +1076,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1111
1076
|
}, _callee9);
|
|
1112
1077
|
}));
|
|
1113
1078
|
return function (_x9) {
|
|
1114
|
-
return
|
|
1079
|
+
return _ref18.apply(this, arguments);
|
|
1115
1080
|
};
|
|
1116
1081
|
}()));
|
|
1117
1082
|
case 4:
|
|
@@ -1153,38 +1118,6 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1153
1118
|
var coreData = app === null || app === void 0 || (_app$models = app.models) === null || _app$models === void 0 || (_app$models$getStore = _app$models.getStore) === null || _app$models$getStore === void 0 || (_app$models$getStore$ = (_app$models$getStore$2 = _app$models$getStore.call(_app$models)).getDataByModel) === null || _app$models$getStore$ === void 0 ? void 0 : _app$models$getStore$.call(_app$models$getStore$2, 'core', 'core');
|
|
1154
1119
|
return coreData === null || coreData === void 0 ? void 0 : coreData[key];
|
|
1155
1120
|
}
|
|
1156
|
-
|
|
1157
|
-
/**
|
|
1158
|
-
* 复用业务解决方案初始化时已解析的支付设备短号。
|
|
1159
|
-
* 空值会清除缓存,使后续支付恢复实时读取设备信息的兼容路径。
|
|
1160
|
-
*/
|
|
1161
|
-
}, {
|
|
1162
|
-
key: "setPaymentNumberDevicePrefix",
|
|
1163
|
-
value: function setPaymentNumberDevicePrefix(prefix) {
|
|
1164
|
-
var normalized = String(prefix !== null && prefix !== void 0 ? prefix : '').trim();
|
|
1165
|
-
this.paymentNumberDevicePrefix = normalized || null;
|
|
1166
|
-
}
|
|
1167
|
-
}, {
|
|
1168
|
-
key: "getPaymentNumberDevicePrefixSync",
|
|
1169
|
-
value: function getPaymentNumberDevicePrefixSync() {
|
|
1170
|
-
var _this7 = this;
|
|
1171
|
-
if (!this.appPlugin) return 'LOCAL';
|
|
1172
|
-
return resolvePaymentNumberDevicePrefixFromDeviceId(function (key) {
|
|
1173
|
-
return _this7.getAppData(key);
|
|
1174
|
-
});
|
|
1175
|
-
}
|
|
1176
|
-
}, {
|
|
1177
|
-
key: "getPaymentNumberDevicePrefixAsync",
|
|
1178
|
-
value: function getPaymentNumberDevicePrefixAsync() {
|
|
1179
|
-
var _this8 = this;
|
|
1180
|
-
if (!this.appPlugin) return Promise.resolve('LOCAL');
|
|
1181
|
-
if (this.paymentNumberDevicePrefix) {
|
|
1182
|
-
return Promise.resolve(this.paymentNumberDevicePrefix);
|
|
1183
|
-
}
|
|
1184
|
-
return resolvePaymentNumberDevicePrefix(function (key) {
|
|
1185
|
-
return _this8.getAppData(key);
|
|
1186
|
-
});
|
|
1187
|
-
}
|
|
1188
1121
|
}, {
|
|
1189
1122
|
key: "syncAppDataToTempOrder",
|
|
1190
1123
|
value: function syncAppDataToTempOrder(tempOrder) {
|
|
@@ -1227,9 +1160,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1227
1160
|
key: "initialize",
|
|
1228
1161
|
value: function () {
|
|
1229
1162
|
var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(core) {
|
|
1230
|
-
var _this$
|
|
1231
|
-
|
|
1232
|
-
_this$
|
|
1163
|
+
var _this$otherParams9,
|
|
1164
|
+
_this7 = this,
|
|
1165
|
+
_this$otherParams10;
|
|
1233
1166
|
var options,
|
|
1234
1167
|
app,
|
|
1235
1168
|
targetCacheData,
|
|
@@ -1241,10 +1174,9 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1241
1174
|
options = _args11.length > 1 && _args11[1] !== undefined ? _args11[1] : {};
|
|
1242
1175
|
this.core = core;
|
|
1243
1176
|
this.initializeOptions = options || {};
|
|
1244
|
-
this.paymentNumberDevicePrefix = null;
|
|
1245
1177
|
// this.store = { ...this.store, ...(options.store as Partial<BaseSalesState>) };
|
|
1246
1178
|
this.otherParams = options.otherParams || {};
|
|
1247
|
-
this.cacheId = (_this$
|
|
1179
|
+
this.cacheId = (_this$otherParams9 = this.otherParams) === null || _this$otherParams9 === void 0 ? void 0 : _this$otherParams9.cacheId;
|
|
1248
1180
|
this.reusedSharedSubModuleNames.clear();
|
|
1249
1181
|
this.window = core.getPlugin('window');
|
|
1250
1182
|
this.request = core.getPlugin('request');
|
|
@@ -1252,52 +1184,52 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1252
1184
|
// 获取 logger 实例
|
|
1253
1185
|
this.appPlugin = core.getPlugin('app');
|
|
1254
1186
|
if (this.appPlugin) {
|
|
1255
|
-
_context11.next =
|
|
1187
|
+
_context11.next = 11;
|
|
1256
1188
|
break;
|
|
1257
1189
|
}
|
|
1258
1190
|
throw new Error('Checkout 解决方案需要 app 插件支持');
|
|
1259
|
-
case
|
|
1191
|
+
case 11:
|
|
1260
1192
|
app = this.appPlugin.getApp();
|
|
1261
1193
|
this.logger = app.logger;
|
|
1262
1194
|
targetCacheData = this.readSessionCacheData();
|
|
1263
1195
|
moduleNames = this.getRegisteredModuleNames();
|
|
1264
1196
|
moduleNames.forEach(function (step) {
|
|
1265
|
-
var reusedModule =
|
|
1197
|
+
var reusedModule = _this7.getReusableSharedSubModule(step);
|
|
1266
1198
|
if (reusedModule) {
|
|
1267
|
-
|
|
1268
|
-
|
|
1199
|
+
_this7.store[step] = reusedModule;
|
|
1200
|
+
_this7.reusedSharedSubModuleNames.add(step);
|
|
1269
1201
|
return;
|
|
1270
1202
|
}
|
|
1271
|
-
var targetModule =
|
|
1203
|
+
var targetModule = _this7.createSubModule(step);
|
|
1272
1204
|
if (!targetModule) {
|
|
1273
1205
|
throw new Error("\u6A21\u5757 ".concat(step, " \u4E0D\u5B58\u5728"));
|
|
1274
1206
|
}
|
|
1275
|
-
var hooks =
|
|
1276
|
-
|
|
1277
|
-
|
|
1207
|
+
var hooks = _this7.getSubModuleHooks(step);
|
|
1208
|
+
_this7.store[step] = targetModule;
|
|
1209
|
+
_this7.core.registerModule(targetModule, _objectSpread(_objectSpread({
|
|
1278
1210
|
initialState: (targetCacheData === null || targetCacheData === void 0 ? void 0 : targetCacheData[targetModule.name]) || {}
|
|
1279
1211
|
}, hooks ? {
|
|
1280
1212
|
hooks: hooks
|
|
1281
1213
|
} : {}), {}, {
|
|
1282
|
-
otherParams:
|
|
1214
|
+
otherParams: _this7.buildSubModuleOtherParams()
|
|
1283
1215
|
}));
|
|
1284
1216
|
});
|
|
1285
1217
|
if (!(this.store.schedule && !this.isScheduleListLoaded(this.store.schedule))) {
|
|
1286
|
-
_context11.next =
|
|
1218
|
+
_context11.next = 19;
|
|
1287
1219
|
break;
|
|
1288
1220
|
}
|
|
1289
|
-
_context11.next =
|
|
1221
|
+
_context11.next = 19;
|
|
1290
1222
|
return this.store.schedule.loadAllSchedule();
|
|
1291
|
-
case
|
|
1292
|
-
if (this.store.order && typeof ((_this$
|
|
1223
|
+
case 19:
|
|
1224
|
+
if (this.store.order && typeof ((_this$otherParams10 = this.otherParams) === null || _this$otherParams10 === void 0 ? void 0 : _this$otherParams10.enableTempOrderPersist) === 'boolean') {
|
|
1293
1225
|
this.store.order.setEnableTempOrderPersist(this.otherParams.enableTempOrderPersist);
|
|
1294
1226
|
}
|
|
1295
|
-
_context11.next =
|
|
1227
|
+
_context11.next = 22;
|
|
1296
1228
|
return this.getPaymentMethodsAsync();
|
|
1297
|
-
case
|
|
1229
|
+
case 22:
|
|
1298
1230
|
this.registerServerOrderChangeSync();
|
|
1299
1231
|
this.core.effects.emit("".concat(this.name, ":onInited"), {});
|
|
1300
|
-
case
|
|
1232
|
+
case 24:
|
|
1301
1233
|
case "end":
|
|
1302
1234
|
return _context11.stop();
|
|
1303
1235
|
}
|
|
@@ -1313,15 +1245,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1313
1245
|
value: function () {
|
|
1314
1246
|
var _destroy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
|
|
1315
1247
|
var _this$serverOrderChan2,
|
|
1316
|
-
|
|
1248
|
+
_this8 = this;
|
|
1317
1249
|
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
1318
1250
|
while (1) switch (_context12.prev = _context12.next) {
|
|
1319
1251
|
case 0:
|
|
1320
1252
|
(_this$serverOrderChan2 = this.serverOrderChangeUnsubscribe) === null || _this$serverOrderChan2 === void 0 || _this$serverOrderChan2.call(this);
|
|
1321
1253
|
this.serverOrderChangeUnsubscribe = null;
|
|
1322
1254
|
Object.keys(this.store).forEach(function (key) {
|
|
1323
|
-
if (
|
|
1324
|
-
var sub =
|
|
1255
|
+
if (_this8.reusedSharedSubModuleNames.has(key)) return;
|
|
1256
|
+
var sub = _this8.store[key];
|
|
1325
1257
|
if (sub && typeof sub.destroy === 'function') {
|
|
1326
1258
|
try {
|
|
1327
1259
|
sub.destroy();
|
|
@@ -1331,14 +1263,13 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1331
1263
|
}
|
|
1332
1264
|
});
|
|
1333
1265
|
this.currentSalesDetail = null;
|
|
1334
|
-
this.paymentNumberDevicePrefix = null;
|
|
1335
1266
|
this.queuedServerOrderChanges = [];
|
|
1336
1267
|
this.salesDetailLoadSequence += 1;
|
|
1337
|
-
_context12.next =
|
|
1268
|
+
_context12.next = 8;
|
|
1338
1269
|
return this.core.effects.emit("".concat(this.name, ":onDestroy"), {});
|
|
1339
|
-
case
|
|
1270
|
+
case 8:
|
|
1340
1271
|
_get(_getPrototypeOf(BaseSalesImpl.prototype), "destroy", this).call(this);
|
|
1341
|
-
case
|
|
1272
|
+
case 9:
|
|
1342
1273
|
case "end":
|
|
1343
1274
|
return _context12.stop();
|
|
1344
1275
|
}
|
|
@@ -1360,7 +1291,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1360
1291
|
key: "loadSalesDetail",
|
|
1361
1292
|
value: (function () {
|
|
1362
1293
|
var _loadSalesDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(orderIdOrParams) {
|
|
1363
|
-
var loadSequence,
|
|
1294
|
+
var loadSequence, _ref20, _ref21, _ref22, _ref23, _params$orderId, params, externalSaleNumber, preloadedSalesDetail, lookup, loadedRecord, message, remoteRecord, currentTempOrder, record;
|
|
1364
1295
|
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
1365
1296
|
while (1) switch (_context13.prev = _context13.next) {
|
|
1366
1297
|
case 0:
|
|
@@ -1378,7 +1309,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1378
1309
|
};
|
|
1379
1310
|
externalSaleNumber = params.externalSaleNumber || params.external_sale_number;
|
|
1380
1311
|
preloadedSalesDetail = params.preloadedSalesDetail;
|
|
1381
|
-
lookup = (
|
|
1312
|
+
lookup = (_ref20 = (_ref21 = (_ref22 = (_ref23 = (_params$orderId = params.orderId) !== null && _params$orderId !== void 0 ? _params$orderId : externalSaleNumber) !== null && _ref23 !== void 0 ? _ref23 : params.orderNumber) !== null && _ref22 !== void 0 ? _ref22 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.order_id) !== null && _ref21 !== void 0 ? _ref21 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.external_sale_number) !== null && _ref20 !== void 0 ? _ref20 : preloadedSalesDetail === null || preloadedSalesDetail === void 0 ? void 0 : preloadedSalesDetail.order_number;
|
|
1382
1313
|
if (!(!preloadedSalesDetail && (lookup === undefined || lookup === null || lookup === ''))) {
|
|
1383
1314
|
_context13.next = 11;
|
|
1384
1315
|
break;
|
|
@@ -1409,40 +1340,39 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1409
1340
|
message = loadedRecord && (loadedRecord.message || loadedRecord.msg) || "\u52A0\u8F7D\u9500\u552E\u8BE6\u60C5\u5931\u8D25: ".concat(lookup);
|
|
1410
1341
|
throw new Error(message);
|
|
1411
1342
|
case 22:
|
|
1412
|
-
remoteRecord =
|
|
1343
|
+
remoteRecord = preloadedSalesDetail !== null && preloadedSalesDetail !== void 0 ? preloadedSalesDetail : loadedRecord.data;
|
|
1413
1344
|
currentTempOrder = params.merge ? this.store.order.getTempOrder() : null;
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
_context13.next = 28;
|
|
1345
|
+
record = params.merge ? mergeSalesDetailRecordWithTempOrder(currentTempOrder, remoteRecord, 'preserve-local') : remoteRecord;
|
|
1346
|
+
_context13.next = 27;
|
|
1417
1347
|
return this.hydrateLatestLoadedSalesDetail(record, loadSequence);
|
|
1418
|
-
case
|
|
1348
|
+
case 27:
|
|
1419
1349
|
return _context13.abrupt("return", _context13.sent);
|
|
1420
|
-
case
|
|
1421
|
-
_context13.prev =
|
|
1350
|
+
case 28:
|
|
1351
|
+
_context13.prev = 28;
|
|
1422
1352
|
this.salesDetailLoadInFlightCount = Math.max(0, this.salesDetailLoadInFlightCount - 1);
|
|
1423
1353
|
if (!(this.salesDetailLoadInFlightCount === 0)) {
|
|
1424
|
-
_context13.next =
|
|
1354
|
+
_context13.next = 39;
|
|
1425
1355
|
break;
|
|
1426
1356
|
}
|
|
1427
|
-
_context13.prev =
|
|
1428
|
-
_context13.next =
|
|
1357
|
+
_context13.prev = 31;
|
|
1358
|
+
_context13.next = 34;
|
|
1429
1359
|
return this.drainQueuedServerOrderChanges();
|
|
1430
|
-
case
|
|
1431
|
-
_context13.next =
|
|
1360
|
+
case 34:
|
|
1361
|
+
_context13.next = 39;
|
|
1432
1362
|
break;
|
|
1433
|
-
case
|
|
1434
|
-
_context13.prev =
|
|
1435
|
-
_context13.t1 = _context13["catch"](
|
|
1363
|
+
case 36:
|
|
1364
|
+
_context13.prev = 36;
|
|
1365
|
+
_context13.t1 = _context13["catch"](31);
|
|
1436
1366
|
this.logError('drain queued server order changes failed', {
|
|
1437
1367
|
error: _context13.t1 instanceof Error ? _context13.t1.message : String(_context13.t1)
|
|
1438
1368
|
});
|
|
1369
|
+
case 39:
|
|
1370
|
+
return _context13.finish(28);
|
|
1439
1371
|
case 40:
|
|
1440
|
-
return _context13.finish(29);
|
|
1441
|
-
case 41:
|
|
1442
1372
|
case "end":
|
|
1443
1373
|
return _context13.stop();
|
|
1444
1374
|
}
|
|
1445
|
-
}, _callee13, this, [[4,,
|
|
1375
|
+
}, _callee13, this, [[4,, 28, 40], [31, 36]]);
|
|
1446
1376
|
}));
|
|
1447
1377
|
function loadSalesDetail(_x11) {
|
|
1448
1378
|
return _loadSalesDetail.apply(this, arguments);
|
|
@@ -1524,7 +1454,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1524
1454
|
}, {
|
|
1525
1455
|
key: "replaceTempOrder",
|
|
1526
1456
|
value: function () {
|
|
1527
|
-
var _replaceTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(tempOrder) {
|
|
1457
|
+
var _replaceTempOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(tempOrder, options) {
|
|
1528
1458
|
var nextTempOrder;
|
|
1529
1459
|
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
1530
1460
|
while (1) switch (_context14.prev = _context14.next) {
|
|
@@ -1536,7 +1466,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1536
1466
|
throw new Error('order 模块未初始化');
|
|
1537
1467
|
case 2:
|
|
1538
1468
|
_context14.next = 4;
|
|
1539
|
-
return this.store.order.replaceTempOrder(tempOrder);
|
|
1469
|
+
return this.store.order.replaceTempOrder(tempOrder, options);
|
|
1540
1470
|
case 4:
|
|
1541
1471
|
nextTempOrder = _context14.sent;
|
|
1542
1472
|
_context14.next = 7;
|
|
@@ -1551,7 +1481,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1551
1481
|
}
|
|
1552
1482
|
}, _callee14, this);
|
|
1553
1483
|
}));
|
|
1554
|
-
function replaceTempOrder(_x12) {
|
|
1484
|
+
function replaceTempOrder(_x12, _x13) {
|
|
1555
1485
|
return _replaceTempOrder.apply(this, arguments);
|
|
1556
1486
|
}
|
|
1557
1487
|
return replaceTempOrder;
|
|
@@ -1870,10 +1800,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1870
1800
|
}, {
|
|
1871
1801
|
key: "getHistoricalProductDiscountList",
|
|
1872
1802
|
value: function getHistoricalProductDiscountList(products) {
|
|
1873
|
-
var
|
|
1803
|
+
var _this9 = this;
|
|
1874
1804
|
var historyDiscountList = [];
|
|
1875
1805
|
products.forEach(function (item) {
|
|
1876
|
-
if (!
|
|
1806
|
+
if (!_this9.isPersistedOrderProduct(item)) return;
|
|
1877
1807
|
(item.discount_list || []).forEach(function (discount) {
|
|
1878
1808
|
var _discount$discount, _discount$metadata, _discount$discount2, _discount$discount3, _discount$discount4;
|
|
1879
1809
|
var discountId = ((_discount$discount = discount.discount) === null || _discount$discount === void 0 ? void 0 : _discount$discount.resource_id) || discount.id;
|
|
@@ -1933,11 +1863,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
1933
1863
|
}, {
|
|
1934
1864
|
key: "shouldSkipAutoApplyFetchedDiscountsInEditMode",
|
|
1935
1865
|
value: function shouldSkipAutoApplyFetchedDiscountsInEditMode(params) {
|
|
1936
|
-
var
|
|
1866
|
+
var _this10 = this;
|
|
1937
1867
|
if (params.discountAction !== 'edit') return false;
|
|
1938
1868
|
if (!params.products.length) return false;
|
|
1939
1869
|
var hasDraftProduct = params.products.some(function (product) {
|
|
1940
|
-
return !
|
|
1870
|
+
return !_this10.isPersistedOrderProduct(product);
|
|
1941
1871
|
});
|
|
1942
1872
|
if (hasDraftProduct) return false;
|
|
1943
1873
|
var hasSelectedDiscount = params.currentDiscountList.some(function (discount) {
|
|
@@ -2181,7 +2111,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2181
2111
|
}
|
|
2182
2112
|
}, _callee20, this, [[46, 65, 68, 71]]);
|
|
2183
2113
|
}));
|
|
2184
|
-
function loadDiscountConfig(
|
|
2114
|
+
function loadDiscountConfig(_x14) {
|
|
2185
2115
|
return _loadDiscountConfig.apply(this, arguments);
|
|
2186
2116
|
}
|
|
2187
2117
|
return loadDiscountConfig;
|
|
@@ -2279,7 +2209,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2279
2209
|
}
|
|
2280
2210
|
}, _callee21, this);
|
|
2281
2211
|
}));
|
|
2282
|
-
function bestDiscount(
|
|
2212
|
+
function bestDiscount(_x15) {
|
|
2283
2213
|
return _bestDiscount.apply(this, arguments);
|
|
2284
2214
|
}
|
|
2285
2215
|
return bestDiscount;
|
|
@@ -2342,7 +2272,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2342
2272
|
}
|
|
2343
2273
|
}, _callee22, this);
|
|
2344
2274
|
}));
|
|
2345
|
-
function replaceDiscountStoreLists(
|
|
2275
|
+
function replaceDiscountStoreLists(_x16) {
|
|
2346
2276
|
return _replaceDiscountStoreLists.apply(this, arguments);
|
|
2347
2277
|
}
|
|
2348
2278
|
return replaceDiscountStoreLists;
|
|
@@ -2401,7 +2331,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2401
2331
|
}
|
|
2402
2332
|
}, _callee23, this, [[0, 16]]);
|
|
2403
2333
|
}));
|
|
2404
|
-
function scanPromotionCode(
|
|
2334
|
+
function scanPromotionCode(_x17, _x18) {
|
|
2405
2335
|
return _scanPromotionCode.apply(this, arguments);
|
|
2406
2336
|
}
|
|
2407
2337
|
return scanPromotionCode;
|
|
@@ -2516,10 +2446,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2516
2446
|
product.discount_list = filterSelectedDiscountDetails(product.discount_list);
|
|
2517
2447
|
if (Array.isArray(product.product_bundle)) {
|
|
2518
2448
|
product.product_bundle = product.product_bundle.map(function (bundle) {
|
|
2519
|
-
var
|
|
2449
|
+
var _ref24, _bundle$original_pric;
|
|
2520
2450
|
var nextBundleDiscountList = filterSelectedDiscountDetails(bundle === null || bundle === void 0 ? void 0 : bundle.discount_list);
|
|
2521
2451
|
var shouldRestoreBundlePrice = nextBundleDiscountList.length === 0;
|
|
2522
|
-
var restoredBundlePrice = (
|
|
2452
|
+
var restoredBundlePrice = (_ref24 = (_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 && _ref24 !== void 0 ? _ref24 : bundle === null || bundle === void 0 ? void 0 : bundle.price;
|
|
2523
2453
|
return _objectSpread(_objectSpread(_objectSpread({}, bundle), shouldRestoreBundlePrice ? {
|
|
2524
2454
|
price: restoredBundlePrice,
|
|
2525
2455
|
bundle_selling_price: restoredBundlePrice
|
|
@@ -2592,7 +2522,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2592
2522
|
}
|
|
2593
2523
|
}, _callee24, this, [[0, 54], [17, 38, 41, 44]]);
|
|
2594
2524
|
}));
|
|
2595
|
-
function setDiscountSelected(
|
|
2525
|
+
function setDiscountSelected(_x19) {
|
|
2596
2526
|
return _setDiscountSelected.apply(this, arguments);
|
|
2597
2527
|
}
|
|
2598
2528
|
return setDiscountSelected;
|
|
@@ -2662,7 +2592,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2662
2592
|
}
|
|
2663
2593
|
}, _callee25, this, [[0, 21]]);
|
|
2664
2594
|
}));
|
|
2665
|
-
function applyDiscountCalculationResult(
|
|
2595
|
+
function applyDiscountCalculationResult(_x20) {
|
|
2666
2596
|
return _applyDiscountCalculationResult.apply(this, arguments);
|
|
2667
2597
|
}
|
|
2668
2598
|
return applyDiscountCalculationResult;
|
|
@@ -2681,7 +2611,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2681
2611
|
}
|
|
2682
2612
|
}, _callee26, this);
|
|
2683
2613
|
}));
|
|
2684
|
-
function submitScanOrder(
|
|
2614
|
+
function submitScanOrder(_x21) {
|
|
2685
2615
|
return _submitScanOrder.apply(this, arguments);
|
|
2686
2616
|
}
|
|
2687
2617
|
return submitScanOrder;
|
|
@@ -2696,7 +2626,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2696
2626
|
key: "submitSalesOrder",
|
|
2697
2627
|
value: (function () {
|
|
2698
2628
|
var _submitSalesOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(params) {
|
|
2699
|
-
var _this$
|
|
2629
|
+
var _this$otherParams11, _this$otherParams12, _this$otherParams13, _this$otherParams14;
|
|
2700
2630
|
var inferredPaymentStatus, submitParams;
|
|
2701
2631
|
return _regeneratorRuntime().wrap(function _callee27$(_context27) {
|
|
2702
2632
|
while (1) switch (_context27.prev = _context27.next) {
|
|
@@ -2711,10 +2641,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2711
2641
|
inferredPaymentStatus = this.getSubmitPaymentStatus(params === null || params === void 0 ? void 0 : params.paymentStatus);
|
|
2712
2642
|
submitParams = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
2713
2643
|
cacheId: this.cacheId,
|
|
2714
|
-
platform: (_this$
|
|
2715
|
-
businessCode: ((_this$
|
|
2644
|
+
platform: (_this$otherParams11 = this.otherParams) === null || _this$otherParams11 === void 0 ? void 0 : _this$otherParams11.platform,
|
|
2645
|
+
businessCode: ((_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.businessCode) || ((_this$otherParams13 = this.otherParams) === null || _this$otherParams13 === void 0 ? void 0 : _this$otherParams13.business_code),
|
|
2716
2646
|
channel: this.getSubmitOrderSalesChannel(),
|
|
2717
|
-
type: (_this$
|
|
2647
|
+
type: (_this$otherParams14 = this.otherParams) === null || _this$otherParams14 === void 0 ? void 0 : _this$otherParams14.type,
|
|
2718
2648
|
request_unique_idempotency_token: this.store.order.generateIdempotencyToken()
|
|
2719
2649
|
}, (params === null || params === void 0 ? void 0 : params.payments) !== undefined ? {
|
|
2720
2650
|
payments: params.payments
|
|
@@ -2734,16 +2664,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2734
2664
|
}
|
|
2735
2665
|
}, _callee27, this);
|
|
2736
2666
|
}));
|
|
2737
|
-
function submitSalesOrder(
|
|
2667
|
+
function submitSalesOrder(_x22) {
|
|
2738
2668
|
return _submitSalesOrder.apply(this, arguments);
|
|
2739
2669
|
}
|
|
2740
2670
|
return submitSalesOrder;
|
|
2741
2671
|
}())
|
|
2742
2672
|
}, {
|
|
2743
|
-
key: "
|
|
2673
|
+
key: "submitTempOrderAsync",
|
|
2744
2674
|
value: function () {
|
|
2745
|
-
var
|
|
2746
|
-
var
|
|
2675
|
+
var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
|
|
2676
|
+
var _this$otherParams15, _this$otherParams16, _this$otherParams17, _this$otherParams18;
|
|
2677
|
+
var inferredPaymentStatus, submitParams;
|
|
2747
2678
|
return _regeneratorRuntime().wrap(function _callee28$(_context28) {
|
|
2748
2679
|
while (1) switch (_context28.prev = _context28.next) {
|
|
2749
2680
|
case 0:
|
|
@@ -2752,49 +2683,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2752
2683
|
break;
|
|
2753
2684
|
}
|
|
2754
2685
|
throw new Error('BaseSales 解决方案需要 order 模块支持');
|
|
2755
|
-
case 2:
|
|
2756
|
-
return _context28.abrupt("return", this.store.order.saveTempOrderAsDraft(_objectSpread({
|
|
2757
|
-
cacheId: this.cacheId,
|
|
2758
|
-
platform: (_params$platform = params === null || params === void 0 ? void 0 : params.platform) !== null && _params$platform !== void 0 ? _params$platform : (_this$otherParams10 = this.otherParams) === null || _this$otherParams10 === void 0 ? void 0 : _this$otherParams10.platform,
|
|
2759
|
-
businessCode: (_ref22 = (_params$businessCode = params === null || params === void 0 ? void 0 : params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams11 = this.otherParams) === null || _this$otherParams11 === void 0 ? void 0 : _this$otherParams11.businessCode) !== null && _ref22 !== void 0 ? _ref22 : (_this$otherParams12 = this.otherParams) === null || _this$otherParams12 === void 0 ? void 0 : _this$otherParams12.business_code,
|
|
2760
|
-
channel: (_params$channel = params === null || params === void 0 ? void 0 : params.channel) !== null && _params$channel !== void 0 ? _params$channel : this.getSubmitOrderSalesChannel(),
|
|
2761
|
-
type: (_params$type = params === null || params === void 0 ? void 0 : params.type) !== null && _params$type !== void 0 ? _params$type : (_this$otherParams13 = this.otherParams) === null || _this$otherParams13 === void 0 ? void 0 : _this$otherParams13.type
|
|
2762
|
-
}, (params === null || params === void 0 ? void 0 : params.enhancePayload) !== undefined ? {
|
|
2763
|
-
enhancePayload: params.enhancePayload
|
|
2764
|
-
} : {})));
|
|
2765
|
-
case 3:
|
|
2766
|
-
case "end":
|
|
2767
|
-
return _context28.stop();
|
|
2768
|
-
}
|
|
2769
|
-
}, _callee28, this);
|
|
2770
|
-
}));
|
|
2771
|
-
function saveSalesOrderDraft(_x22) {
|
|
2772
|
-
return _saveSalesOrderDraft.apply(this, arguments);
|
|
2773
|
-
}
|
|
2774
|
-
return saveSalesOrderDraft;
|
|
2775
|
-
}()
|
|
2776
|
-
}, {
|
|
2777
|
-
key: "submitTempOrderAsync",
|
|
2778
|
-
value: function () {
|
|
2779
|
-
var _submitTempOrderAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(params) {
|
|
2780
|
-
var _this$otherParams14, _this$otherParams15, _this$otherParams16, _this$otherParams17;
|
|
2781
|
-
var inferredPaymentStatus, submitParams;
|
|
2782
|
-
return _regeneratorRuntime().wrap(function _callee29$(_context29) {
|
|
2783
|
-
while (1) switch (_context29.prev = _context29.next) {
|
|
2784
|
-
case 0:
|
|
2785
|
-
if (this.store.order) {
|
|
2786
|
-
_context29.next = 2;
|
|
2787
|
-
break;
|
|
2788
|
-
}
|
|
2789
|
-
throw new Error('BaseSales 解决方案需要 order 模块支持');
|
|
2790
2686
|
case 2:
|
|
2791
2687
|
inferredPaymentStatus = this.getSubmitPaymentStatus(params === null || params === void 0 ? void 0 : params.paymentStatus);
|
|
2792
2688
|
submitParams = _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
2793
2689
|
cacheId: this.cacheId,
|
|
2794
|
-
platform: (_this$
|
|
2795
|
-
businessCode: ((_this$
|
|
2690
|
+
platform: (_this$otherParams15 = this.otherParams) === null || _this$otherParams15 === void 0 ? void 0 : _this$otherParams15.platform,
|
|
2691
|
+
businessCode: ((_this$otherParams16 = this.otherParams) === null || _this$otherParams16 === void 0 ? void 0 : _this$otherParams16.businessCode) || ((_this$otherParams17 = this.otherParams) === null || _this$otherParams17 === void 0 ? void 0 : _this$otherParams17.business_code),
|
|
2796
2692
|
channel: this.getSubmitOrderSalesChannel(),
|
|
2797
|
-
type: (_this$
|
|
2693
|
+
type: (_this$otherParams18 = this.otherParams) === null || _this$otherParams18 === void 0 ? void 0 : _this$otherParams18.type
|
|
2798
2694
|
}, (params === null || params === void 0 ? void 0 : params.payments) !== undefined ? {
|
|
2799
2695
|
payments: params.payments
|
|
2800
2696
|
} : {}), inferredPaymentStatus !== undefined ? {
|
|
@@ -2806,12 +2702,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2806
2702
|
} : {}), (params === null || params === void 0 ? void 0 : params.enhancePayload) !== undefined ? {
|
|
2807
2703
|
enhancePayload: params.enhancePayload
|
|
2808
2704
|
} : {});
|
|
2809
|
-
return
|
|
2705
|
+
return _context28.abrupt("return", this.store.order.submitTempOrderAsync(submitParams));
|
|
2810
2706
|
case 5:
|
|
2811
2707
|
case "end":
|
|
2812
|
-
return
|
|
2708
|
+
return _context28.stop();
|
|
2813
2709
|
}
|
|
2814
|
-
},
|
|
2710
|
+
}, _callee28, this);
|
|
2815
2711
|
}));
|
|
2816
2712
|
function submitTempOrderAsync(_x23) {
|
|
2817
2713
|
return _submitTempOrderAsync.apply(this, arguments);
|
|
@@ -2821,14 +2717,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2821
2717
|
}, {
|
|
2822
2718
|
key: "printLocalOrderReceipt",
|
|
2823
2719
|
value: function () {
|
|
2824
|
-
var _printLocalOrderReceipt = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2825
|
-
var _this$
|
|
2720
|
+
var _printLocalOrderReceipt = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(lookup) {
|
|
2721
|
+
var _this$otherParams19, _this$otherParams20, _this$otherParams21, _this$otherParams22;
|
|
2826
2722
|
var hasLookup, lookupPayload, context, payload, response, _this$store$order$app, _this$store$order5, _data;
|
|
2827
|
-
return _regeneratorRuntime().wrap(function
|
|
2828
|
-
while (1) switch (
|
|
2723
|
+
return _regeneratorRuntime().wrap(function _callee29$(_context29) {
|
|
2724
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
2829
2725
|
case 0:
|
|
2830
2726
|
if (this.store.order) {
|
|
2831
|
-
|
|
2727
|
+
_context29.next = 2;
|
|
2832
2728
|
break;
|
|
2833
2729
|
}
|
|
2834
2730
|
throw new Error('BaseSales 解决方案需要 order 模块支持');
|
|
@@ -2840,10 +2736,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2840
2736
|
external_sale_number: lookup
|
|
2841
2737
|
};
|
|
2842
2738
|
context = {
|
|
2843
|
-
platform: (_this$
|
|
2844
|
-
businessCode: ((_this$
|
|
2739
|
+
platform: (_this$otherParams19 = this.otherParams) === null || _this$otherParams19 === void 0 ? void 0 : _this$otherParams19.platform,
|
|
2740
|
+
businessCode: ((_this$otherParams20 = this.otherParams) === null || _this$otherParams20 === void 0 ? void 0 : _this$otherParams20.businessCode) || ((_this$otherParams21 = this.otherParams) === null || _this$otherParams21 === void 0 ? void 0 : _this$otherParams21.business_code),
|
|
2845
2741
|
channel: this.getSubmitOrderSalesChannel(),
|
|
2846
|
-
type: (_this$
|
|
2742
|
+
type: (_this$otherParams22 = this.otherParams) === null || _this$otherParams22 === void 0 ? void 0 : _this$otherParams22.type
|
|
2847
2743
|
};
|
|
2848
2744
|
payload = hasLookup ? _objectSpread(_objectSpread({}, lookupPayload), {}, {
|
|
2849
2745
|
lookup_order_from_db: 1,
|
|
@@ -2859,26 +2755,26 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2859
2755
|
channel: context.channel,
|
|
2860
2756
|
type: context.type
|
|
2861
2757
|
});
|
|
2862
|
-
|
|
2758
|
+
_context29.next = 8;
|
|
2863
2759
|
return this.request.post('/local/print-order', payload, {
|
|
2864
2760
|
osServer: true,
|
|
2865
2761
|
customToast: function customToast() {}
|
|
2866
2762
|
});
|
|
2867
2763
|
case 8:
|
|
2868
|
-
response =
|
|
2764
|
+
response = _context29.sent;
|
|
2869
2765
|
if (hasLookup) {
|
|
2870
|
-
|
|
2766
|
+
_context29.next = 12;
|
|
2871
2767
|
break;
|
|
2872
2768
|
}
|
|
2873
|
-
|
|
2769
|
+
_context29.next = 12;
|
|
2874
2770
|
return (_this$store$order$app = (_this$store$order5 = this.store.order).applyLocalPrintOrderNumbers) === null || _this$store$order$app === void 0 ? void 0 : _this$store$order$app.call(_this$store$order5, response === null || response === void 0 || (_data = response.data) === null || _data === void 0 ? void 0 : _data.order);
|
|
2875
2771
|
case 12:
|
|
2876
|
-
return
|
|
2772
|
+
return _context29.abrupt("return", response);
|
|
2877
2773
|
case 13:
|
|
2878
2774
|
case "end":
|
|
2879
|
-
return
|
|
2775
|
+
return _context29.stop();
|
|
2880
2776
|
}
|
|
2881
|
-
},
|
|
2777
|
+
}, _callee29, this);
|
|
2882
2778
|
}));
|
|
2883
2779
|
function printLocalOrderReceipt(_x24) {
|
|
2884
2780
|
return _printLocalOrderReceipt.apply(this, arguments);
|
|
@@ -2901,20 +2797,20 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2901
2797
|
}, {
|
|
2902
2798
|
key: "syncPaymentsToOrder",
|
|
2903
2799
|
value: function () {
|
|
2904
|
-
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2905
|
-
var
|
|
2800
|
+
var _syncPaymentsToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(params) {
|
|
2801
|
+
var _ref25, _params$businessCode, _this$otherParams23, _this$otherParams24, _params$channel;
|
|
2906
2802
|
var businessCode, channel, syncParams, syncState, payments, syncResult, latestPayments, amountSnapshot, orderSnapshot, syncPayload;
|
|
2907
|
-
return _regeneratorRuntime().wrap(function
|
|
2908
|
-
while (1) switch (
|
|
2803
|
+
return _regeneratorRuntime().wrap(function _callee30$(_context30) {
|
|
2804
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
2909
2805
|
case 0:
|
|
2910
2806
|
if (this.store.order) {
|
|
2911
|
-
|
|
2807
|
+
_context30.next = 2;
|
|
2912
2808
|
break;
|
|
2913
2809
|
}
|
|
2914
2810
|
throw new Error('order 模块未初始化');
|
|
2915
2811
|
case 2:
|
|
2916
|
-
businessCode = (
|
|
2917
|
-
channel = (_params$
|
|
2812
|
+
businessCode = (_ref25 = (_params$businessCode = params.businessCode) !== null && _params$businessCode !== void 0 ? _params$businessCode : (_this$otherParams23 = this.otherParams) === null || _this$otherParams23 === void 0 ? void 0 : _this$otherParams23.businessCode) !== null && _ref25 !== void 0 ? _ref25 : (_this$otherParams24 = this.otherParams) === null || _this$otherParams24 === void 0 ? void 0 : _this$otherParams24.business_code;
|
|
2813
|
+
channel = (_params$channel = params.channel) !== null && _params$channel !== void 0 ? _params$channel : this.getSubmitOrderSalesChannel();
|
|
2918
2814
|
syncParams = _objectSpread(_objectSpread(_objectSpread({}, params), businessCode !== undefined ? {
|
|
2919
2815
|
businessCode: businessCode
|
|
2920
2816
|
} : {}), channel !== undefined ? {
|
|
@@ -2922,14 +2818,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2922
2818
|
} : {});
|
|
2923
2819
|
syncState = this.store.order.getOrderSyncState();
|
|
2924
2820
|
if (!(params.submitWhenPaid && syncState === 'submitting')) {
|
|
2925
|
-
|
|
2821
|
+
_context30.next = 9;
|
|
2926
2822
|
break;
|
|
2927
2823
|
}
|
|
2928
2824
|
this.queueLatestAutoPaymentSync();
|
|
2929
|
-
return
|
|
2825
|
+
return _context30.abrupt("return", this.store.order.syncPaymentsToOrder(syncParams));
|
|
2930
2826
|
case 9:
|
|
2931
2827
|
payments = params.payments || [];
|
|
2932
|
-
|
|
2828
|
+
_context30.next = 12;
|
|
2933
2829
|
return this.effectsEmit(BaseSalesHookNames.onPaymentSyncStart, {
|
|
2934
2830
|
payments: payments,
|
|
2935
2831
|
params: syncParams,
|
|
@@ -2937,11 +2833,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2937
2833
|
orderSnapshot: this.store.order.getOrderSnapshot()
|
|
2938
2834
|
});
|
|
2939
2835
|
case 12:
|
|
2940
|
-
|
|
2941
|
-
|
|
2836
|
+
_context30.prev = 12;
|
|
2837
|
+
_context30.next = 15;
|
|
2942
2838
|
return this.store.order.syncPaymentsToOrder(syncParams);
|
|
2943
2839
|
case 15:
|
|
2944
|
-
syncResult =
|
|
2840
|
+
syncResult = _context30.sent;
|
|
2945
2841
|
latestPayments = this.store.order.getOrderPayments();
|
|
2946
2842
|
amountSnapshot = this.store.order.getOrderAmountSnapshot();
|
|
2947
2843
|
orderSnapshot = this.store.order.getOrderSnapshot();
|
|
@@ -2959,25 +2855,25 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2959
2855
|
depositAmount: syncResult.depositAmount,
|
|
2960
2856
|
orderExpectedAmount: syncResult.orderExpectedAmount
|
|
2961
2857
|
};
|
|
2962
|
-
|
|
2858
|
+
_context30.next = 22;
|
|
2963
2859
|
return this.effectsEmit(BaseSalesHookNames.onPaymentSyncEnd, syncPayload);
|
|
2964
2860
|
case 22:
|
|
2965
2861
|
if (!(syncResult.isDepositFullyPaid && !syncResult.isOrderFullyPaid)) {
|
|
2966
|
-
|
|
2862
|
+
_context30.next = 25;
|
|
2967
2863
|
break;
|
|
2968
2864
|
}
|
|
2969
|
-
|
|
2865
|
+
_context30.next = 25;
|
|
2970
2866
|
return this.effectsEmit(BaseSalesHookNames.onDepositPaymentSyncEnd, syncPayload);
|
|
2971
2867
|
case 25:
|
|
2972
2868
|
this.scheduleQueuedAutoPaymentSyncFlush(0);
|
|
2973
|
-
return
|
|
2869
|
+
return _context30.abrupt("return", syncResult);
|
|
2974
2870
|
case 29:
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2871
|
+
_context30.prev = 29;
|
|
2872
|
+
_context30.t0 = _context30["catch"](12);
|
|
2873
|
+
_context30.next = 33;
|
|
2978
2874
|
return this.effectsEmit(BaseSalesHookNames.onPaymentSyncEnd, {
|
|
2979
2875
|
ok: false,
|
|
2980
|
-
error:
|
|
2876
|
+
error: _context30.t0,
|
|
2981
2877
|
payments: this.store.order.getOrderPayments(),
|
|
2982
2878
|
params: syncParams,
|
|
2983
2879
|
amountSnapshot: this.store.order.getOrderAmountSnapshot(),
|
|
@@ -2985,12 +2881,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
2985
2881
|
});
|
|
2986
2882
|
case 33:
|
|
2987
2883
|
this.scheduleQueuedAutoPaymentSyncFlush(0);
|
|
2988
|
-
throw
|
|
2884
|
+
throw _context30.t0;
|
|
2989
2885
|
case 35:
|
|
2990
2886
|
case "end":
|
|
2991
|
-
return
|
|
2887
|
+
return _context30.stop();
|
|
2992
2888
|
}
|
|
2993
|
-
},
|
|
2889
|
+
}, _callee30, this, [[12, 29]]);
|
|
2994
2890
|
}));
|
|
2995
2891
|
function syncPaymentsToOrder(_x25) {
|
|
2996
2892
|
return _syncPaymentsToOrder.apply(this, arguments);
|
|
@@ -3029,58 +2925,58 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3029
2925
|
}, {
|
|
3030
2926
|
key: "scheduleQueuedAutoPaymentSyncFlush",
|
|
3031
2927
|
value: function scheduleQueuedAutoPaymentSyncFlush() {
|
|
3032
|
-
var
|
|
2928
|
+
var _this11 = this;
|
|
3033
2929
|
var delay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 100;
|
|
3034
2930
|
if (!this.queuedAutoPaymentSync) return;
|
|
3035
2931
|
if (this.autoPaymentSyncTimer) return;
|
|
3036
2932
|
this.autoPaymentSyncTimer = setTimeout(function () {
|
|
3037
|
-
|
|
3038
|
-
void
|
|
2933
|
+
_this11.autoPaymentSyncTimer = null;
|
|
2934
|
+
void _this11.flushQueuedAutoPaymentSync();
|
|
3039
2935
|
}, delay);
|
|
3040
2936
|
}
|
|
3041
2937
|
}, {
|
|
3042
2938
|
key: "flushQueuedAutoPaymentSync",
|
|
3043
2939
|
value: function () {
|
|
3044
|
-
var _flushQueuedAutoPaymentSync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
2940
|
+
var _flushQueuedAutoPaymentSync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31() {
|
|
3045
2941
|
var payments;
|
|
3046
|
-
return _regeneratorRuntime().wrap(function
|
|
3047
|
-
while (1) switch (
|
|
2942
|
+
return _regeneratorRuntime().wrap(function _callee31$(_context31) {
|
|
2943
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
3048
2944
|
case 0:
|
|
3049
2945
|
if (this.store.order) {
|
|
3050
|
-
|
|
2946
|
+
_context31.next = 2;
|
|
3051
2947
|
break;
|
|
3052
2948
|
}
|
|
3053
|
-
return
|
|
2949
|
+
return _context31.abrupt("return");
|
|
3054
2950
|
case 2:
|
|
3055
2951
|
if (!(!this.queuedAutoPaymentSync || this.autoPaymentSyncFlushing)) {
|
|
3056
|
-
|
|
2952
|
+
_context31.next = 4;
|
|
3057
2953
|
break;
|
|
3058
2954
|
}
|
|
3059
|
-
return
|
|
2955
|
+
return _context31.abrupt("return");
|
|
3060
2956
|
case 4:
|
|
3061
2957
|
if (!(this.store.order.getOrderSyncState() === 'submitting')) {
|
|
3062
|
-
|
|
2958
|
+
_context31.next = 7;
|
|
3063
2959
|
break;
|
|
3064
2960
|
}
|
|
3065
2961
|
this.scheduleQueuedAutoPaymentSyncFlush();
|
|
3066
|
-
return
|
|
2962
|
+
return _context31.abrupt("return");
|
|
3067
2963
|
case 7:
|
|
3068
2964
|
this.autoPaymentSyncFlushing = true;
|
|
3069
|
-
|
|
2965
|
+
_context31.prev = 8;
|
|
3070
2966
|
case 9:
|
|
3071
2967
|
if (!this.queuedAutoPaymentSync) {
|
|
3072
|
-
|
|
2968
|
+
_context31.next = 18;
|
|
3073
2969
|
break;
|
|
3074
2970
|
}
|
|
3075
2971
|
this.queuedAutoPaymentSync = false;
|
|
3076
2972
|
payments = this.store.order.getOrderPayments();
|
|
3077
2973
|
if (payments.length) {
|
|
3078
|
-
|
|
2974
|
+
_context31.next = 14;
|
|
3079
2975
|
break;
|
|
3080
2976
|
}
|
|
3081
|
-
return
|
|
2977
|
+
return _context31.abrupt("continue", 9);
|
|
3082
2978
|
case 14:
|
|
3083
|
-
|
|
2979
|
+
_context31.next = 16;
|
|
3084
2980
|
return this.syncPaymentsToOrder({
|
|
3085
2981
|
payments: payments,
|
|
3086
2982
|
paymentStatus: this.getPaymentStatusForSync(payments),
|
|
@@ -3088,94 +2984,44 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3088
2984
|
smallTicketDataFlag: 1
|
|
3089
2985
|
});
|
|
3090
2986
|
case 16:
|
|
3091
|
-
|
|
2987
|
+
_context31.next = 9;
|
|
3092
2988
|
break;
|
|
3093
2989
|
case 18:
|
|
3094
|
-
|
|
2990
|
+
_context31.next = 23;
|
|
3095
2991
|
break;
|
|
3096
2992
|
case 20:
|
|
3097
|
-
|
|
3098
|
-
|
|
2993
|
+
_context31.prev = 20;
|
|
2994
|
+
_context31.t0 = _context31["catch"](8);
|
|
3099
2995
|
this.logError('queued auto sync payments failed', {
|
|
3100
|
-
error:
|
|
2996
|
+
error: _context31.t0 instanceof Error ? _context31.t0.message : String(_context31.t0)
|
|
3101
2997
|
});
|
|
3102
2998
|
case 23:
|
|
3103
|
-
|
|
2999
|
+
_context31.prev = 23;
|
|
3104
3000
|
this.autoPaymentSyncFlushing = false;
|
|
3105
3001
|
if (this.queuedAutoPaymentSync) {
|
|
3106
3002
|
this.scheduleQueuedAutoPaymentSyncFlush(0);
|
|
3107
3003
|
}
|
|
3108
|
-
return
|
|
3004
|
+
return _context31.finish(23);
|
|
3109
3005
|
case 27:
|
|
3110
3006
|
case "end":
|
|
3111
|
-
return
|
|
3007
|
+
return _context31.stop();
|
|
3112
3008
|
}
|
|
3113
|
-
},
|
|
3009
|
+
}, _callee31, this, [[8, 20, 23, 27]]);
|
|
3114
3010
|
}));
|
|
3115
3011
|
function flushQueuedAutoPaymentSync() {
|
|
3116
3012
|
return _flushQueuedAutoPaymentSync.apply(this, arguments);
|
|
3117
3013
|
}
|
|
3118
3014
|
return flushQueuedAutoPaymentSync;
|
|
3119
|
-
}()
|
|
3120
|
-
/**
|
|
3121
|
-
* 同步兼容入口。无法等待 IoT 短号时,按调用当下的 device_id 或 LOCAL 生成。
|
|
3122
|
-
*/
|
|
3015
|
+
}() /** 追加单个支付项到当前订单。 */
|
|
3123
3016
|
}, {
|
|
3124
3017
|
key: "addOrderPayment",
|
|
3125
3018
|
value: function addOrderPayment(payment) {
|
|
3126
|
-
var
|
|
3127
|
-
return this.addOrderPaymentWithDevicePrefix(payment, hasPaymentNumber ? 'LOCAL' : this.getPaymentNumberDevicePrefixSync());
|
|
3128
|
-
}
|
|
3129
|
-
|
|
3130
|
-
/**
|
|
3131
|
-
* 创建新支付项时优先使用业务解决方案初始化阶段缓存的设备短号;
|
|
3132
|
-
* 未缓存的通用 BaseSales 保持实时读取设备信息的兼容语义。
|
|
3133
|
-
*/
|
|
3134
|
-
}, {
|
|
3135
|
-
key: "addOrderPaymentAsync",
|
|
3136
|
-
value: (function () {
|
|
3137
|
-
var _addOrderPaymentAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(payment) {
|
|
3138
|
-
var paymentRecord, hasPaymentNumber, devicePrefix;
|
|
3139
|
-
return _regeneratorRuntime().wrap(function _callee33$(_context33) {
|
|
3140
|
-
while (1) switch (_context33.prev = _context33.next) {
|
|
3141
|
-
case 0:
|
|
3142
|
-
paymentRecord = payment;
|
|
3143
|
-
hasPaymentNumber = String(paymentRecord.payment_number || '').trim() !== '';
|
|
3144
|
-
if (!hasPaymentNumber) {
|
|
3145
|
-
_context33.next = 6;
|
|
3146
|
-
break;
|
|
3147
|
-
}
|
|
3148
|
-
_context33.t0 = 'LOCAL';
|
|
3149
|
-
_context33.next = 9;
|
|
3150
|
-
break;
|
|
3151
|
-
case 6:
|
|
3152
|
-
_context33.next = 8;
|
|
3153
|
-
return this.getPaymentNumberDevicePrefixAsync();
|
|
3154
|
-
case 8:
|
|
3155
|
-
_context33.t0 = _context33.sent;
|
|
3156
|
-
case 9:
|
|
3157
|
-
devicePrefix = _context33.t0;
|
|
3158
|
-
return _context33.abrupt("return", this.addOrderPaymentWithDevicePrefix(payment, devicePrefix));
|
|
3159
|
-
case 11:
|
|
3160
|
-
case "end":
|
|
3161
|
-
return _context33.stop();
|
|
3162
|
-
}
|
|
3163
|
-
}, _callee33, this);
|
|
3164
|
-
}));
|
|
3165
|
-
function addOrderPaymentAsync(_x26) {
|
|
3166
|
-
return _addOrderPaymentAsync.apply(this, arguments);
|
|
3167
|
-
}
|
|
3168
|
-
return addOrderPaymentAsync;
|
|
3169
|
-
}())
|
|
3170
|
-
}, {
|
|
3171
|
-
key: "addOrderPaymentWithDevicePrefix",
|
|
3172
|
-
value: function addOrderPaymentWithDevicePrefix(payment, devicePrefix) {
|
|
3173
|
-
var _this$otherParams24,
|
|
3019
|
+
var _this$otherParams25,
|
|
3174
3020
|
_paymentRecord$paymen,
|
|
3175
3021
|
_paymentRecord$create,
|
|
3176
|
-
|
|
3022
|
+
_ref26,
|
|
3177
3023
|
_paymentRecord$origin,
|
|
3178
|
-
|
|
3024
|
+
_this12 = this;
|
|
3179
3025
|
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
3180
3026
|
var paymentRecord = payment;
|
|
3181
3027
|
var paymentAmount = new Decimal(paymentRecord.amount || 0);
|
|
@@ -3186,26 +3032,25 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3186
3032
|
return this.store.order.getOrderPayments();
|
|
3187
3033
|
}
|
|
3188
3034
|
var metadata = paymentRecord.metadata && _typeof(paymentRecord.metadata) === 'object' ? _objectSpread({}, paymentRecord.metadata) : {};
|
|
3189
|
-
var shopWalletPassId = (_this$
|
|
3035
|
+
var shopWalletPassId = (_this$otherParams25 = this.otherParams) === null || _this$otherParams25 === void 0 ? void 0 : _this$otherParams25.shop_wallet_pass_id;
|
|
3190
3036
|
if (shopWalletPassId !== undefined && shopWalletPassId !== null) {
|
|
3191
3037
|
metadata.shop_wallet_pass_id = shopWalletPassId;
|
|
3192
3038
|
}
|
|
3193
|
-
|
|
3039
|
+
if (!metadata.unique_payment_number) {
|
|
3040
|
+
metadata.unique_payment_number = createUuidV4();
|
|
3041
|
+
}
|
|
3194
3042
|
var paymentTimestamp = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
3195
3043
|
var paymentTime = (_paymentRecord$paymen = paymentRecord.payment_time) !== null && _paymentRecord$paymen !== void 0 ? _paymentRecord$paymen : paymentTimestamp;
|
|
3196
3044
|
var createdAt = (_paymentRecord$create = paymentRecord.created_at) !== null && _paymentRecord$create !== void 0 ? _paymentRecord$create : paymentTimestamp;
|
|
3197
3045
|
var serviceCharge = paymentRecord.service_charge && _typeof(paymentRecord.service_charge) === 'object' ? paymentRecord.service_charge : null;
|
|
3198
|
-
var calculatedServiceFee = serviceCharge ? new Decimal((
|
|
3199
|
-
var payments = this.store.order.addOrderPayment(_objectSpread(_objectSpread(_objectSpread({},
|
|
3046
|
+
var calculatedServiceFee = serviceCharge ? new Decimal((_ref26 = (_paymentRecord$origin = paymentRecord.origin_amount) !== null && _paymentRecord$origin !== void 0 ? _paymentRecord$origin : paymentRecord.amount) !== null && _ref26 !== void 0 ? _ref26 : 0).times(serviceCharge.percentage || 0).plus(serviceCharge.amount || 0).toDecimalPlaces(2).toFixed(2) : undefined;
|
|
3047
|
+
var payments = this.store.order.addOrderPayment(_objectSpread(_objectSpread(_objectSpread({}, paymentRecord), calculatedServiceFee !== undefined ? {
|
|
3200
3048
|
service_fee: calculatedServiceFee
|
|
3201
3049
|
} : {}), {}, {
|
|
3202
3050
|
metadata: metadata,
|
|
3203
3051
|
payment_time: paymentTime,
|
|
3204
3052
|
created_at: createdAt
|
|
3205
3053
|
}));
|
|
3206
|
-
if (paymentRecord.status === 'payment_pending') {
|
|
3207
|
-
return payments;
|
|
3208
|
-
}
|
|
3209
3054
|
var amountSnapshot = this.store.order.getOrderAmountSnapshot();
|
|
3210
3055
|
var syncState = this.store.order.getOrderSyncState();
|
|
3211
3056
|
if (amountSnapshot) {
|
|
@@ -3219,7 +3064,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3219
3064
|
submitWhenPaid: true,
|
|
3220
3065
|
smallTicketDataFlag: 1
|
|
3221
3066
|
}).catch(function (error) {
|
|
3222
|
-
|
|
3067
|
+
_this12.logError('auto sync payments failed', {
|
|
3223
3068
|
error: error instanceof Error ? error.message : String(error)
|
|
3224
3069
|
});
|
|
3225
3070
|
});
|
|
@@ -3230,131 +3075,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3230
3075
|
/** 更新当前订单中的指定支付项。 */
|
|
3231
3076
|
}, {
|
|
3232
3077
|
key: "updateOrderPayment",
|
|
3233
|
-
value:
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
previousPayment,
|
|
3240
|
-
_this$store$order$get2,
|
|
3241
|
-
currentPayments,
|
|
3242
|
-
_syncResult,
|
|
3243
|
-
_options$smallTicketD,
|
|
3244
|
-
result,
|
|
3245
|
-
draftResult,
|
|
3246
|
-
draftError,
|
|
3247
|
-
becamePaid,
|
|
3248
|
-
shouldSubmit,
|
|
3249
|
-
syncResult,
|
|
3250
|
-
_options$smallTicketD2,
|
|
3251
|
-
_args34 = arguments;
|
|
3252
|
-
return _regeneratorRuntime().wrap(function _callee34$(_context34) {
|
|
3253
|
-
while (1) switch (_context34.prev = _context34.next) {
|
|
3254
|
-
case 0:
|
|
3255
|
-
options = _args34.length > 2 && _args34[2] !== undefined ? _args34[2] : {};
|
|
3256
|
-
if (this.store.order) {
|
|
3257
|
-
_context34.next = 3;
|
|
3258
|
-
break;
|
|
3259
|
-
}
|
|
3260
|
-
throw new Error('order 模块未初始化');
|
|
3261
|
-
case 3:
|
|
3262
|
-
matchMode = options.matchBy === 'compat' || options.matchBy === 'legacy' ? 'compat' : 'payment_number';
|
|
3263
|
-
previousMatch = resolveOrderPaymentIdentity(this.store.order.getOrderPayments(), paymentIdentity, matchMode);
|
|
3264
|
-
previousPayment = previousMatch === null || previousMatch === void 0 ? void 0 : previousMatch.payment;
|
|
3265
|
-
if (!((previousPayment === null || previousPayment === void 0 ? void 0 : previousPayment.status) === 'paid' && !options.applyUpdatesWhenPaid)) {
|
|
3266
|
-
_context34.next = 13;
|
|
3267
|
-
break;
|
|
3268
|
-
}
|
|
3269
|
-
currentPayments = this.store.order.getOrderPayments();
|
|
3270
|
-
if (!(options.submitWhenPaid && options.forceSubmitIfPaid)) {
|
|
3271
|
-
_context34.next = 12;
|
|
3272
|
-
break;
|
|
3273
|
-
}
|
|
3274
|
-
_context34.next = 11;
|
|
3275
|
-
return this.syncPaymentsToOrder({
|
|
3276
|
-
payments: currentPayments,
|
|
3277
|
-
paymentStatus: this.getPaymentStatusForSync(currentPayments),
|
|
3278
|
-
submitWhenPaid: true,
|
|
3279
|
-
smallTicketDataFlag: (_options$smallTicketD = options.smallTicketDataFlag) !== null && _options$smallTicketD !== void 0 ? _options$smallTicketD : 1
|
|
3280
|
-
});
|
|
3281
|
-
case 11:
|
|
3282
|
-
_syncResult = _context34.sent;
|
|
3283
|
-
case 12:
|
|
3284
|
-
return _context34.abrupt("return", _objectSpread({
|
|
3285
|
-
updated: false,
|
|
3286
|
-
payment: previousPayment,
|
|
3287
|
-
payments: currentPayments,
|
|
3288
|
-
summary: ((_this$store$order$get2 = this.store.order.getOrderAmountSnapshot()) === null || _this$store$order$get2 === void 0 ? void 0 : _this$store$order$get2.summary) || null
|
|
3289
|
-
}, _syncResult !== undefined ? {
|
|
3290
|
-
syncResult: _syncResult
|
|
3291
|
-
} : {}));
|
|
3292
|
-
case 13:
|
|
3293
|
-
_context34.next = 15;
|
|
3294
|
-
return this.store.order.updateOrderPayment(paymentIdentity, updates, {
|
|
3295
|
-
matchBy: matchMode
|
|
3296
|
-
});
|
|
3297
|
-
case 15:
|
|
3298
|
-
result = _context34.sent;
|
|
3299
|
-
if (!(options.persistDraft !== false)) {
|
|
3300
|
-
_context34.next = 29;
|
|
3301
|
-
break;
|
|
3302
|
-
}
|
|
3303
|
-
_context34.prev = 17;
|
|
3304
|
-
_context34.next = 20;
|
|
3305
|
-
return this.saveSalesOrderDraft();
|
|
3306
|
-
case 20:
|
|
3307
|
-
draftResult = _context34.sent;
|
|
3308
|
-
_context34.next = 29;
|
|
3309
|
-
break;
|
|
3310
|
-
case 23:
|
|
3311
|
-
_context34.prev = 23;
|
|
3312
|
-
_context34.t0 = _context34["catch"](17);
|
|
3313
|
-
draftError = _context34.t0;
|
|
3314
|
-
this.logError('updateOrderPayment: 保存支付草稿失败', {
|
|
3315
|
-
paymentIdentity: paymentIdentity,
|
|
3316
|
-
error: _context34.t0 instanceof Error ? _context34.t0.message : String(_context34.t0)
|
|
3317
|
-
});
|
|
3318
|
-
if (options.submitWhenPaid) {
|
|
3319
|
-
_context34.next = 29;
|
|
3320
|
-
break;
|
|
3321
|
-
}
|
|
3322
|
-
throw _context34.t0;
|
|
3323
|
-
case 29:
|
|
3324
|
-
becamePaid = (previousPayment === null || previousPayment === void 0 ? void 0 : previousPayment.status) !== 'paid' && ((_result$payment = result.payment) === null || _result$payment === void 0 ? void 0 : _result$payment.status) === 'paid';
|
|
3325
|
-
shouldSubmit = Boolean(options.submitWhenPaid && ((_result$payment2 = result.payment) === null || _result$payment2 === void 0 ? void 0 : _result$payment2.status) === 'paid' && (becamePaid || options.forceSubmitIfPaid));
|
|
3326
|
-
if (!shouldSubmit) {
|
|
3327
|
-
_context34.next = 35;
|
|
3328
|
-
break;
|
|
3329
|
-
}
|
|
3330
|
-
_context34.next = 34;
|
|
3331
|
-
return this.syncPaymentsToOrder({
|
|
3332
|
-
payments: result.payments,
|
|
3333
|
-
paymentStatus: this.getPaymentStatusForSync(result.payments),
|
|
3334
|
-
submitWhenPaid: true,
|
|
3335
|
-
smallTicketDataFlag: (_options$smallTicketD2 = options.smallTicketDataFlag) !== null && _options$smallTicketD2 !== void 0 ? _options$smallTicketD2 : 1
|
|
3336
|
-
});
|
|
3337
|
-
case 34:
|
|
3338
|
-
syncResult = _context34.sent;
|
|
3339
|
-
case 35:
|
|
3340
|
-
return _context34.abrupt("return", _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, result), draftResult !== undefined ? {
|
|
3341
|
-
draftResult: draftResult
|
|
3342
|
-
} : {}), draftError !== undefined ? {
|
|
3343
|
-
draftError: draftError
|
|
3344
|
-
} : {}), syncResult !== undefined ? {
|
|
3345
|
-
syncResult: syncResult
|
|
3346
|
-
} : {}));
|
|
3347
|
-
case 36:
|
|
3348
|
-
case "end":
|
|
3349
|
-
return _context34.stop();
|
|
3350
|
-
}
|
|
3351
|
-
}, _callee34, this, [[17, 23]]);
|
|
3352
|
-
}));
|
|
3353
|
-
function updateOrderPayment(_x27, _x28) {
|
|
3354
|
-
return _updateOrderPayment.apply(this, arguments);
|
|
3355
|
-
}
|
|
3356
|
-
return updateOrderPayment;
|
|
3357
|
-
}() /** 删除当前订单中的指定支付项。 */)
|
|
3078
|
+
value: function updateOrderPayment(paymentIdentity, updates) {
|
|
3079
|
+
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
3080
|
+
return this.store.order.updateOrderPayment(paymentIdentity, updates);
|
|
3081
|
+
}
|
|
3082
|
+
|
|
3083
|
+
/** 删除当前订单中的指定支付项。 */
|
|
3358
3084
|
}, {
|
|
3359
3085
|
key: "deleteOrderPayment",
|
|
3360
3086
|
value: function deleteOrderPayment(paymentIdentity) {
|
|
@@ -3369,31 +3095,6 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3369
3095
|
if (!this.store.order) throw new Error('order 模块未初始化');
|
|
3370
3096
|
return this.store.order.updateVoucherOrderPayments(payments, options);
|
|
3371
3097
|
}
|
|
3372
|
-
}, {
|
|
3373
|
-
key: "updateVoucherOrderPaymentsAsync",
|
|
3374
|
-
value: function () {
|
|
3375
|
-
var _updateVoucherOrderPaymentsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(payments, options) {
|
|
3376
|
-
return _regeneratorRuntime().wrap(function _callee35$(_context35) {
|
|
3377
|
-
while (1) switch (_context35.prev = _context35.next) {
|
|
3378
|
-
case 0:
|
|
3379
|
-
if (this.store.order) {
|
|
3380
|
-
_context35.next = 2;
|
|
3381
|
-
break;
|
|
3382
|
-
}
|
|
3383
|
-
throw new Error('order 模块未初始化');
|
|
3384
|
-
case 2:
|
|
3385
|
-
return _context35.abrupt("return", this.store.order.updateVoucherOrderPaymentsAsync(payments, options));
|
|
3386
|
-
case 3:
|
|
3387
|
-
case "end":
|
|
3388
|
-
return _context35.stop();
|
|
3389
|
-
}
|
|
3390
|
-
}, _callee35, this);
|
|
3391
|
-
}));
|
|
3392
|
-
function updateVoucherOrderPaymentsAsync(_x29, _x30) {
|
|
3393
|
-
return _updateVoucherOrderPaymentsAsync.apply(this, arguments);
|
|
3394
|
-
}
|
|
3395
|
-
return updateVoucherOrderPaymentsAsync;
|
|
3396
|
-
}()
|
|
3397
3098
|
}, {
|
|
3398
3099
|
key: "confirmPendingVoucherPayments",
|
|
3399
3100
|
value: function confirmPendingVoucherPayments() {
|
|
@@ -3470,20 +3171,20 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3470
3171
|
}, {
|
|
3471
3172
|
key: "initWalletData",
|
|
3472
3173
|
value: function () {
|
|
3473
|
-
var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3474
|
-
var _params$order_wait_pa,
|
|
3174
|
+
var _initWalletData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(params) {
|
|
3175
|
+
var _params$order_wait_pa, _ref27, _tempOrder$is_price_i;
|
|
3475
3176
|
var snapshot, tempOrder, amount, walletBusinessData, result;
|
|
3476
|
-
return _regeneratorRuntime().wrap(function
|
|
3477
|
-
while (1) switch (
|
|
3177
|
+
return _regeneratorRuntime().wrap(function _callee32$(_context32) {
|
|
3178
|
+
while (1) switch (_context32.prev = _context32.next) {
|
|
3478
3179
|
case 0:
|
|
3479
3180
|
if (this.store.order) {
|
|
3480
|
-
|
|
3181
|
+
_context32.next = 2;
|
|
3481
3182
|
break;
|
|
3482
3183
|
}
|
|
3483
3184
|
throw new Error('order 模块未初始化');
|
|
3484
3185
|
case 2:
|
|
3485
3186
|
if (this.store.payment) {
|
|
3486
|
-
|
|
3187
|
+
_context32.next = 4;
|
|
3487
3188
|
break;
|
|
3488
3189
|
}
|
|
3489
3190
|
throw new Error('payment 模块未初始化');
|
|
@@ -3492,10 +3193,10 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3492
3193
|
tempOrder = snapshot === null || snapshot === void 0 ? void 0 : snapshot.tempOrder;
|
|
3493
3194
|
amount = snapshot === null || snapshot === void 0 ? void 0 : snapshot.amount;
|
|
3494
3195
|
if (!(!tempOrder || !amount)) {
|
|
3495
|
-
|
|
3196
|
+
_context32.next = 9;
|
|
3496
3197
|
break;
|
|
3497
3198
|
}
|
|
3498
|
-
return
|
|
3199
|
+
return _context32.abrupt("return", {
|
|
3499
3200
|
walletRecommendList: [],
|
|
3500
3201
|
userIdentificationCodes: [],
|
|
3501
3202
|
transformList: [],
|
|
@@ -3514,15 +3215,15 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3514
3215
|
},
|
|
3515
3216
|
products: this.getWalletProductList(),
|
|
3516
3217
|
order_wait_pay_amount: (_params$order_wait_pa = params === null || params === void 0 ? void 0 : params.order_wait_pay_amount) !== null && _params$order_wait_pa !== void 0 ? _params$order_wait_pa : Number(amount.amountGap || 0),
|
|
3517
|
-
is_price_include_tax: (
|
|
3218
|
+
is_price_include_tax: (_ref27 = (_tempOrder$is_price_i = tempOrder.is_price_include_tax) !== null && _tempOrder$is_price_i !== void 0 ? _tempOrder$is_price_i : this.otherParams.is_price_include_tax) !== null && _ref27 !== void 0 ? _ref27 : 1
|
|
3518
3219
|
}, snapshot.identity.orderId ? {
|
|
3519
3220
|
payment_order_id: String(snapshot.identity.orderId)
|
|
3520
3221
|
} : {});
|
|
3521
|
-
|
|
3222
|
+
_context32.next = 12;
|
|
3522
3223
|
return this.store.payment.wallet.initializeWalletDataFromBusinessAsync(walletBusinessData);
|
|
3523
3224
|
case 12:
|
|
3524
|
-
result =
|
|
3525
|
-
|
|
3225
|
+
result = _context32.sent;
|
|
3226
|
+
_context32.next = 15;
|
|
3526
3227
|
return this.core.effects.emit("".concat(this.name, ":onWalletDataInitialized"), {
|
|
3527
3228
|
orderId: snapshot.identity.orderId,
|
|
3528
3229
|
customerId: walletBusinessData.customer_id,
|
|
@@ -3534,14 +3235,14 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3534
3235
|
timestamp: Date.now()
|
|
3535
3236
|
});
|
|
3536
3237
|
case 15:
|
|
3537
|
-
return
|
|
3238
|
+
return _context32.abrupt("return", result);
|
|
3538
3239
|
case 16:
|
|
3539
3240
|
case "end":
|
|
3540
|
-
return
|
|
3241
|
+
return _context32.stop();
|
|
3541
3242
|
}
|
|
3542
|
-
},
|
|
3243
|
+
}, _callee32, this);
|
|
3543
3244
|
}));
|
|
3544
|
-
function initWalletData(
|
|
3245
|
+
function initWalletData(_x26) {
|
|
3545
3246
|
return _initWalletData.apply(this, arguments);
|
|
3546
3247
|
}
|
|
3547
3248
|
return initWalletData;
|
|
@@ -3568,35 +3269,35 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3568
3269
|
}, {
|
|
3569
3270
|
key: "getPaymentMethodsAsync",
|
|
3570
3271
|
value: (function () {
|
|
3571
|
-
var _getPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3272
|
+
var _getPaymentMethodsAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33() {
|
|
3572
3273
|
var response, paymentMethods;
|
|
3573
|
-
return _regeneratorRuntime().wrap(function
|
|
3574
|
-
while (1) switch (
|
|
3274
|
+
return _regeneratorRuntime().wrap(function _callee33$(_context33) {
|
|
3275
|
+
while (1) switch (_context33.prev = _context33.next) {
|
|
3575
3276
|
case 0:
|
|
3576
|
-
|
|
3577
|
-
|
|
3277
|
+
_context33.prev = 0;
|
|
3278
|
+
_context33.next = 3;
|
|
3578
3279
|
return this.request.get('/pay/custom-payment/all', {
|
|
3579
3280
|
filterPaymentMethods: true
|
|
3580
3281
|
}, {
|
|
3581
3282
|
osServer: true
|
|
3582
3283
|
});
|
|
3583
3284
|
case 3:
|
|
3584
|
-
response =
|
|
3285
|
+
response = _context33.sent;
|
|
3585
3286
|
paymentMethods = (response === null || response === void 0 ? void 0 : response.data) || [];
|
|
3586
3287
|
this.paymentMethodsCache = Array.isArray(paymentMethods) ? _toConsumableArray(paymentMethods) : [];
|
|
3587
|
-
return
|
|
3288
|
+
return _context33.abrupt("return", this.getPaymentMethods());
|
|
3588
3289
|
case 9:
|
|
3589
|
-
|
|
3590
|
-
|
|
3290
|
+
_context33.prev = 9;
|
|
3291
|
+
_context33.t0 = _context33["catch"](0);
|
|
3591
3292
|
this.logWarning('getPaymentMethodsAsync: 获取支付方式列表失败,使用缓存列表', {
|
|
3592
|
-
error:
|
|
3293
|
+
error: _context33.t0 instanceof Error ? _context33.t0.message : String(_context33.t0)
|
|
3593
3294
|
});
|
|
3594
|
-
return
|
|
3295
|
+
return _context33.abrupt("return", this.getPaymentMethods());
|
|
3595
3296
|
case 13:
|
|
3596
3297
|
case "end":
|
|
3597
|
-
return
|
|
3298
|
+
return _context33.stop();
|
|
3598
3299
|
}
|
|
3599
|
-
},
|
|
3300
|
+
}, _callee33, this, [[0, 9]]);
|
|
3600
3301
|
}));
|
|
3601
3302
|
function getPaymentMethodsAsync() {
|
|
3602
3303
|
return _getPaymentMethodsAsync.apply(this, arguments);
|
|
@@ -3609,84 +3310,106 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3609
3310
|
return _toConsumableArray(this.paymentMethodsCache);
|
|
3610
3311
|
}
|
|
3611
3312
|
|
|
3612
|
-
/**
|
|
3313
|
+
/**
|
|
3314
|
+
* 按当前店铺的现金舍入配置计算金额,供现金支付 UI 使用。
|
|
3315
|
+
*
|
|
3316
|
+
* 舍入开关取自 CASHMANUAL 支付方式;舍入规则取自
|
|
3317
|
+
* otherParams.order_rounding_setting,金额算法统一由 PaymentModule 维护。
|
|
3318
|
+
*/
|
|
3613
3319
|
}, {
|
|
3614
3320
|
key: "roundAmount",
|
|
3615
|
-
value: function
|
|
3616
|
-
var
|
|
3617
|
-
|
|
3618
|
-
|
|
3619
|
-
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
-
|
|
3623
|
-
|
|
3624
|
-
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
|
|
3628
|
-
|
|
3321
|
+
value: (function () {
|
|
3322
|
+
var _roundAmount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(params) {
|
|
3323
|
+
var _cashManualPayment$me, _this$otherParams$ord2, _this$otherParams$ord3;
|
|
3324
|
+
var amount, cashManualPayment;
|
|
3325
|
+
return _regeneratorRuntime().wrap(function _callee34$(_context34) {
|
|
3326
|
+
while (1) switch (_context34.prev = _context34.next) {
|
|
3327
|
+
case 0:
|
|
3328
|
+
amount = params.amount;
|
|
3329
|
+
cashManualPayment = this.paymentMethodsCache.find(function (paymentMethod) {
|
|
3330
|
+
return paymentMethod.code === 'CASHMANUAL';
|
|
3331
|
+
});
|
|
3332
|
+
if (cashManualPayment !== null && cashManualPayment !== void 0 && (_cashManualPayment$me = cashManualPayment.metadata) !== null && _cashManualPayment$me !== void 0 && _cashManualPayment$me.order_rounding_switch) {
|
|
3333
|
+
_context34.next = 4;
|
|
3334
|
+
break;
|
|
3335
|
+
}
|
|
3336
|
+
return _context34.abrupt("return", {
|
|
3337
|
+
originalAmount: amount.toString(),
|
|
3338
|
+
roundedAmount: amount.toString(),
|
|
3339
|
+
roundingDifference: '0.00'
|
|
3340
|
+
});
|
|
3341
|
+
case 4:
|
|
3342
|
+
if (this.payment) {
|
|
3343
|
+
_context34.next = 6;
|
|
3344
|
+
break;
|
|
3345
|
+
}
|
|
3346
|
+
throw new Error('payment 模块未初始化');
|
|
3347
|
+
case 6:
|
|
3348
|
+
return _context34.abrupt("return", this.payment.roundAmountAsync(amount, (_this$otherParams$ord2 = this.otherParams.order_rounding_setting) === null || _this$otherParams$ord2 === void 0 ? void 0 : _this$otherParams$ord2.interval, (_this$otherParams$ord3 = this.otherParams.order_rounding_setting) === null || _this$otherParams$ord3 === void 0 ? void 0 : _this$otherParams$ord3.type));
|
|
3349
|
+
case 7:
|
|
3350
|
+
case "end":
|
|
3351
|
+
return _context34.stop();
|
|
3352
|
+
}
|
|
3353
|
+
}, _callee34, this);
|
|
3354
|
+
}));
|
|
3355
|
+
function roundAmount(_x27) {
|
|
3356
|
+
return _roundAmount.apply(this, arguments);
|
|
3629
3357
|
}
|
|
3630
|
-
|
|
3631
|
-
|
|
3632
|
-
originalAmount: amount.toFixed(2),
|
|
3633
|
-
roundedAmount: roundedAmount.toFixed(2),
|
|
3634
|
-
roundingDifference: roundedAmount.minus(amount).toFixed(2)
|
|
3635
|
-
};
|
|
3636
|
-
}
|
|
3637
|
-
|
|
3358
|
+
return roundAmount;
|
|
3359
|
+
}()
|
|
3638
3360
|
/**
|
|
3639
3361
|
* 发送支付链接。
|
|
3640
3362
|
*
|
|
3641
3363
|
* 如果没有 orderIds 或显式 submitBeforeSend,会先提交当前本地订单到云端;
|
|
3642
3364
|
* 只有成功拿到远端 order_id 后才调用 OrderModule 发送邮件。
|
|
3643
3365
|
*/
|
|
3366
|
+
)
|
|
3644
3367
|
}, {
|
|
3645
3368
|
key: "sendCustomerPayLink",
|
|
3646
3369
|
value: (function () {
|
|
3647
|
-
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3648
|
-
var orderIds,
|
|
3649
|
-
return _regeneratorRuntime().wrap(function
|
|
3650
|
-
while (1) switch (
|
|
3370
|
+
var _sendCustomerPayLink = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(params) {
|
|
3371
|
+
var orderIds, _ref28, _ref29, _submitResult$data$or, _submitResult$data, _submitResult$data2, submitResult, orderId;
|
|
3372
|
+
return _regeneratorRuntime().wrap(function _callee35$(_context35) {
|
|
3373
|
+
while (1) switch (_context35.prev = _context35.next) {
|
|
3651
3374
|
case 0:
|
|
3652
3375
|
if (this.store.order) {
|
|
3653
|
-
|
|
3376
|
+
_context35.next = 2;
|
|
3654
3377
|
break;
|
|
3655
3378
|
}
|
|
3656
3379
|
throw new Error('order 模块未初始化');
|
|
3657
3380
|
case 2:
|
|
3658
3381
|
orderIds = params.order_ids || params.orderIds || [];
|
|
3659
3382
|
if (!(!orderIds.length || params.submitBeforeSend)) {
|
|
3660
|
-
|
|
3383
|
+
_context35.next = 11;
|
|
3661
3384
|
break;
|
|
3662
3385
|
}
|
|
3663
|
-
|
|
3386
|
+
_context35.next = 6;
|
|
3664
3387
|
return this.submitSalesOrder({
|
|
3665
3388
|
smallTicketDataFlag: 1
|
|
3666
3389
|
});
|
|
3667
3390
|
case 6:
|
|
3668
|
-
submitResult =
|
|
3669
|
-
orderId = (
|
|
3391
|
+
submitResult = _context35.sent;
|
|
3392
|
+
orderId = (_ref28 = (_ref29 = (_submitResult$data$or = submitResult === null || submitResult === void 0 || (_submitResult$data = submitResult.data) === null || _submitResult$data === void 0 ? void 0 : _submitResult$data.order_id) !== null && _submitResult$data$or !== void 0 ? _submitResult$data$or : submitResult === null || submitResult === void 0 ? void 0 : submitResult.order_id) !== null && _ref29 !== void 0 ? _ref29 : submitResult === null || submitResult === void 0 || (_submitResult$data2 = submitResult.data) === null || _submitResult$data2 === void 0 ? void 0 : _submitResult$data2.id) !== null && _ref28 !== void 0 ? _ref28 : submitResult === null || submitResult === void 0 ? void 0 : submitResult.id;
|
|
3670
3393
|
if (orderId) {
|
|
3671
|
-
|
|
3394
|
+
_context35.next = 10;
|
|
3672
3395
|
break;
|
|
3673
3396
|
}
|
|
3674
3397
|
throw new Error('本地订单提交云端失败,无法发送支付链接');
|
|
3675
3398
|
case 10:
|
|
3676
3399
|
orderIds = [orderId];
|
|
3677
3400
|
case 11:
|
|
3678
|
-
return
|
|
3401
|
+
return _context35.abrupt("return", this.store.order.sendCustomerPayLink({
|
|
3679
3402
|
emails: params.emails,
|
|
3680
3403
|
notify_action: params.notify_action,
|
|
3681
3404
|
order_ids: orderIds
|
|
3682
3405
|
}));
|
|
3683
3406
|
case 12:
|
|
3684
3407
|
case "end":
|
|
3685
|
-
return
|
|
3408
|
+
return _context35.stop();
|
|
3686
3409
|
}
|
|
3687
|
-
},
|
|
3410
|
+
}, _callee35, this);
|
|
3688
3411
|
}));
|
|
3689
|
-
function sendCustomerPayLink(
|
|
3412
|
+
function sendCustomerPayLink(_x28) {
|
|
3690
3413
|
return _sendCustomerPayLink.apply(this, arguments);
|
|
3691
3414
|
}
|
|
3692
3415
|
return sendCustomerPayLink;
|
|
@@ -3699,27 +3422,27 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3699
3422
|
}, {
|
|
3700
3423
|
key: "calculateProductBookingPrice",
|
|
3701
3424
|
value: function () {
|
|
3702
|
-
var _calculateProductBookingPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3425
|
+
var _calculateProductBookingPrice = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(params) {
|
|
3703
3426
|
var _params$customer_id;
|
|
3704
3427
|
var quotation, customerId, authoritativeProduct, product;
|
|
3705
|
-
return _regeneratorRuntime().wrap(function
|
|
3706
|
-
while (1) switch (
|
|
3428
|
+
return _regeneratorRuntime().wrap(function _callee36$(_context36) {
|
|
3429
|
+
while (1) switch (_context36.prev = _context36.next) {
|
|
3707
3430
|
case 0:
|
|
3708
3431
|
quotation = this.store.quotation;
|
|
3709
3432
|
customerId = (_params$customer_id = params.customer_id) !== null && _params$customer_id !== void 0 ? _params$customer_id : this.getCurrentOrderCustomerId();
|
|
3710
|
-
|
|
3433
|
+
_context36.next = 4;
|
|
3711
3434
|
return this.loadProductForPriceQuery(params, customerId);
|
|
3712
3435
|
case 4:
|
|
3713
|
-
authoritativeProduct =
|
|
3436
|
+
authoritativeProduct = _context36.sent;
|
|
3714
3437
|
product = this.mergeProductForPriceQuery(params.product, authoritativeProduct);
|
|
3715
|
-
|
|
3438
|
+
_context36.next = 8;
|
|
3716
3439
|
return this.loadQuotationForPriceQuery({
|
|
3717
3440
|
quotation: quotation,
|
|
3718
3441
|
customer_id: customerId,
|
|
3719
3442
|
channel: params.channel
|
|
3720
3443
|
});
|
|
3721
3444
|
case 8:
|
|
3722
|
-
return
|
|
3445
|
+
return _context36.abrupt("return", calculateBaseSalesProductBookingPrice(_objectSpread(_objectSpread({}, params), {}, {
|
|
3723
3446
|
product: product,
|
|
3724
3447
|
fallback_price: authoritativeProduct ? undefined : params.fallback_price,
|
|
3725
3448
|
customer_id: customerId,
|
|
@@ -3727,11 +3450,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3727
3450
|
})));
|
|
3728
3451
|
case 9:
|
|
3729
3452
|
case "end":
|
|
3730
|
-
return
|
|
3453
|
+
return _context36.stop();
|
|
3731
3454
|
}
|
|
3732
|
-
},
|
|
3455
|
+
}, _callee36, this);
|
|
3733
3456
|
}));
|
|
3734
|
-
function calculateProductBookingPrice(
|
|
3457
|
+
function calculateProductBookingPrice(_x29) {
|
|
3735
3458
|
return _calculateProductBookingPrice.apply(this, arguments);
|
|
3736
3459
|
}
|
|
3737
3460
|
return calculateProductBookingPrice;
|
|
@@ -3739,7 +3462,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3739
3462
|
}, {
|
|
3740
3463
|
key: "getQuotationCustomerScopeInfo",
|
|
3741
3464
|
value: function getQuotationCustomerScopeInfo() {
|
|
3742
|
-
var
|
|
3465
|
+
var _this13 = this;
|
|
3743
3466
|
var quotation = this.store.quotation;
|
|
3744
3467
|
if (quotation && typeof quotation.getQuotationCustomerScopeInfo === 'function') {
|
|
3745
3468
|
return quotation.getQuotationCustomerScopeInfo();
|
|
@@ -3751,7 +3474,7 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3751
3474
|
}).map(function (item) {
|
|
3752
3475
|
var localSeen = new Set();
|
|
3753
3476
|
var customers = item.customer.filter(function (customer) {
|
|
3754
|
-
var customerId =
|
|
3477
|
+
var customerId = _this13.normalizePriceContextCustomerId(customer === null || customer === void 0 ? void 0 : customer.id);
|
|
3755
3478
|
if (!customerId || localSeen.has(customerId)) return false;
|
|
3756
3479
|
localSeen.add(customerId);
|
|
3757
3480
|
if (!customerById.has(customerId)) customerById.set(customerId, customer);
|
|
@@ -3801,32 +3524,32 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3801
3524
|
}, {
|
|
3802
3525
|
key: "calculateProductBookingPrices",
|
|
3803
3526
|
value: function () {
|
|
3804
|
-
var _calculateProductBookingPrices = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3527
|
+
var _calculateProductBookingPrices = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(paramsList) {
|
|
3805
3528
|
var _paramsList$0$custome,
|
|
3806
3529
|
_paramsList$,
|
|
3807
|
-
|
|
3530
|
+
_this14 = this,
|
|
3808
3531
|
_paramsList$2;
|
|
3809
3532
|
var quotation, customerId, productMapsByGroup, groups;
|
|
3810
|
-
return _regeneratorRuntime().wrap(function
|
|
3811
|
-
while (1) switch (
|
|
3533
|
+
return _regeneratorRuntime().wrap(function _callee38$(_context38) {
|
|
3534
|
+
while (1) switch (_context38.prev = _context38.next) {
|
|
3812
3535
|
case 0:
|
|
3813
3536
|
if (paramsList.length) {
|
|
3814
|
-
|
|
3537
|
+
_context38.next = 2;
|
|
3815
3538
|
break;
|
|
3816
3539
|
}
|
|
3817
|
-
return
|
|
3540
|
+
return _context38.abrupt("return", []);
|
|
3818
3541
|
case 2:
|
|
3819
3542
|
quotation = this.store.quotation;
|
|
3820
3543
|
customerId = (_paramsList$0$custome = (_paramsList$ = paramsList[0]) === null || _paramsList$ === void 0 ? void 0 : _paramsList$.customer_id) !== null && _paramsList$0$custome !== void 0 ? _paramsList$0$custome : this.getCurrentOrderCustomerId();
|
|
3821
3544
|
productMapsByGroup = new Map();
|
|
3822
3545
|
groups = new Map();
|
|
3823
3546
|
paramsList.forEach(function (params) {
|
|
3824
|
-
var
|
|
3547
|
+
var _this14$otherParams;
|
|
3825
3548
|
var product = params.product || {};
|
|
3826
|
-
var productId =
|
|
3549
|
+
var productId = _this14.getPriceQueryProductId(product);
|
|
3827
3550
|
if (productId === null) return;
|
|
3828
|
-
var schedule =
|
|
3829
|
-
var channel = params.channel || ((
|
|
3551
|
+
var schedule = _this14.getPriceQuerySchedule(params);
|
|
3552
|
+
var channel = params.channel || ((_this14$otherParams = _this14.otherParams) === null || _this14$otherParams === void 0 ? void 0 : _this14$otherParams.channel);
|
|
3830
3553
|
var groupKey = [schedule.schedule_date, schedule.schedule_datetime, channel || ''].join('|');
|
|
3831
3554
|
var group = groups.get(groupKey) || {
|
|
3832
3555
|
ids: new Set(),
|
|
@@ -3836,51 +3559,51 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3836
3559
|
group.ids.add(productId);
|
|
3837
3560
|
groups.set(groupKey, group);
|
|
3838
3561
|
});
|
|
3839
|
-
|
|
3562
|
+
_context38.next = 9;
|
|
3840
3563
|
return Promise.all(Array.from(groups.entries()).map( /*#__PURE__*/function () {
|
|
3841
|
-
var
|
|
3842
|
-
var
|
|
3843
|
-
return _regeneratorRuntime().wrap(function
|
|
3844
|
-
while (1) switch (
|
|
3564
|
+
var _ref31 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(_ref30) {
|
|
3565
|
+
var _ref32, groupKey, group, productsById;
|
|
3566
|
+
return _regeneratorRuntime().wrap(function _callee37$(_context37) {
|
|
3567
|
+
while (1) switch (_context37.prev = _context37.next) {
|
|
3845
3568
|
case 0:
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
return
|
|
3569
|
+
_ref32 = _slicedToArray(_ref30, 2), groupKey = _ref32[0], group = _ref32[1];
|
|
3570
|
+
_context37.next = 3;
|
|
3571
|
+
return _this14.loadProductsForPriceQuery({
|
|
3849
3572
|
ids: Array.from(group.ids),
|
|
3850
3573
|
schedule: group.schedule,
|
|
3851
3574
|
customerId: customerId,
|
|
3852
3575
|
channel: group.channel
|
|
3853
3576
|
});
|
|
3854
3577
|
case 3:
|
|
3855
|
-
productsById =
|
|
3578
|
+
productsById = _context37.sent;
|
|
3856
3579
|
productMapsByGroup.set(groupKey, productsById);
|
|
3857
3580
|
case 5:
|
|
3858
3581
|
case "end":
|
|
3859
|
-
return
|
|
3582
|
+
return _context37.stop();
|
|
3860
3583
|
}
|
|
3861
|
-
},
|
|
3584
|
+
}, _callee37);
|
|
3862
3585
|
}));
|
|
3863
|
-
return function (
|
|
3864
|
-
return
|
|
3586
|
+
return function (_x31) {
|
|
3587
|
+
return _ref31.apply(this, arguments);
|
|
3865
3588
|
};
|
|
3866
3589
|
}()));
|
|
3867
3590
|
case 9:
|
|
3868
|
-
|
|
3591
|
+
_context38.next = 11;
|
|
3869
3592
|
return this.loadQuotationForPriceQuery({
|
|
3870
3593
|
quotation: quotation,
|
|
3871
3594
|
customer_id: customerId,
|
|
3872
3595
|
channel: (_paramsList$2 = paramsList[0]) === null || _paramsList$2 === void 0 ? void 0 : _paramsList$2.channel
|
|
3873
3596
|
});
|
|
3874
3597
|
case 11:
|
|
3875
|
-
return
|
|
3876
|
-
var
|
|
3598
|
+
return _context38.abrupt("return", paramsList.map(function (params) {
|
|
3599
|
+
var _this14$otherParams2, _productMapsByGroup$g;
|
|
3877
3600
|
var productInput = params.product || {};
|
|
3878
|
-
var productId =
|
|
3879
|
-
var schedule =
|
|
3880
|
-
var channel = params.channel || ((
|
|
3601
|
+
var productId = _this14.getPriceQueryProductId(productInput);
|
|
3602
|
+
var schedule = _this14.getPriceQuerySchedule(params);
|
|
3603
|
+
var channel = params.channel || ((_this14$otherParams2 = _this14.otherParams) === null || _this14$otherParams2 === void 0 ? void 0 : _this14$otherParams2.channel);
|
|
3881
3604
|
var groupKey = [schedule.schedule_date, schedule.schedule_datetime, channel || ''].join('|');
|
|
3882
3605
|
var authoritativeProduct = productId === null ? null : ((_productMapsByGroup$g = productMapsByGroup.get(groupKey)) === null || _productMapsByGroup$g === void 0 ? void 0 : _productMapsByGroup$g.get(productId)) || null;
|
|
3883
|
-
var product =
|
|
3606
|
+
var product = _this14.mergeProductForPriceQuery(productInput, authoritativeProduct);
|
|
3884
3607
|
return calculateBaseSalesProductBookingPrice(_objectSpread(_objectSpread({}, params), {}, {
|
|
3885
3608
|
product: product,
|
|
3886
3609
|
fallback_price: authoritativeProduct ? undefined : params.fallback_price,
|
|
@@ -3890,11 +3613,11 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3890
3613
|
}));
|
|
3891
3614
|
case 12:
|
|
3892
3615
|
case "end":
|
|
3893
|
-
return
|
|
3616
|
+
return _context38.stop();
|
|
3894
3617
|
}
|
|
3895
|
-
},
|
|
3618
|
+
}, _callee38, this);
|
|
3896
3619
|
}));
|
|
3897
|
-
function calculateProductBookingPrices(
|
|
3620
|
+
function calculateProductBookingPrices(_x30) {
|
|
3898
3621
|
return _calculateProductBookingPrices.apply(this, arguments);
|
|
3899
3622
|
}
|
|
3900
3623
|
return calculateProductBookingPrices;
|
|
@@ -3902,34 +3625,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3902
3625
|
}, {
|
|
3903
3626
|
key: "addProductToOrder",
|
|
3904
3627
|
value: function () {
|
|
3905
|
-
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3628
|
+
var _addProductToOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39(product, booking, options) {
|
|
3906
3629
|
var products;
|
|
3907
|
-
return _regeneratorRuntime().wrap(function
|
|
3908
|
-
while (1) switch (
|
|
3630
|
+
return _regeneratorRuntime().wrap(function _callee39$(_context39) {
|
|
3631
|
+
while (1) switch (_context39.prev = _context39.next) {
|
|
3909
3632
|
case 0:
|
|
3910
|
-
|
|
3633
|
+
_context39.prev = 0;
|
|
3911
3634
|
if (this.store.order) {
|
|
3912
|
-
|
|
3635
|
+
_context39.next = 3;
|
|
3913
3636
|
break;
|
|
3914
3637
|
}
|
|
3915
3638
|
throw new Error('order 模块未初始化');
|
|
3916
3639
|
case 3:
|
|
3917
|
-
|
|
3918
|
-
return this.store.order.addProductToOrder(product, booking);
|
|
3640
|
+
_context39.next = 5;
|
|
3641
|
+
return this.store.order.addProductToOrder(product, booking, options);
|
|
3919
3642
|
case 5:
|
|
3920
|
-
products =
|
|
3921
|
-
return
|
|
3643
|
+
products = _context39.sent;
|
|
3644
|
+
return _context39.abrupt("return", products);
|
|
3922
3645
|
case 9:
|
|
3923
|
-
|
|
3924
|
-
|
|
3925
|
-
throw
|
|
3646
|
+
_context39.prev = 9;
|
|
3647
|
+
_context39.t0 = _context39["catch"](0);
|
|
3648
|
+
throw _context39.t0;
|
|
3926
3649
|
case 12:
|
|
3927
3650
|
case "end":
|
|
3928
|
-
return
|
|
3651
|
+
return _context39.stop();
|
|
3929
3652
|
}
|
|
3930
|
-
},
|
|
3653
|
+
}, _callee39, this, [[0, 9]]);
|
|
3931
3654
|
}));
|
|
3932
|
-
function addProductToOrder(
|
|
3655
|
+
function addProductToOrder(_x32, _x33, _x34) {
|
|
3933
3656
|
return _addProductToOrder.apply(this, arguments);
|
|
3934
3657
|
}
|
|
3935
3658
|
return addProductToOrder;
|
|
@@ -3937,34 +3660,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3937
3660
|
}, {
|
|
3938
3661
|
key: "updateOrderProduct",
|
|
3939
3662
|
value: function () {
|
|
3940
|
-
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3663
|
+
var _updateOrderProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40(params) {
|
|
3941
3664
|
var products;
|
|
3942
|
-
return _regeneratorRuntime().wrap(function
|
|
3943
|
-
while (1) switch (
|
|
3665
|
+
return _regeneratorRuntime().wrap(function _callee40$(_context40) {
|
|
3666
|
+
while (1) switch (_context40.prev = _context40.next) {
|
|
3944
3667
|
case 0:
|
|
3945
|
-
|
|
3668
|
+
_context40.prev = 0;
|
|
3946
3669
|
if (this.store.order) {
|
|
3947
|
-
|
|
3670
|
+
_context40.next = 3;
|
|
3948
3671
|
break;
|
|
3949
3672
|
}
|
|
3950
3673
|
throw new Error('order 模块未初始化');
|
|
3951
3674
|
case 3:
|
|
3952
|
-
|
|
3675
|
+
_context40.next = 5;
|
|
3953
3676
|
return this.store.order.updateOrderProduct(params);
|
|
3954
3677
|
case 5:
|
|
3955
|
-
products =
|
|
3956
|
-
return
|
|
3678
|
+
products = _context40.sent;
|
|
3679
|
+
return _context40.abrupt("return", products);
|
|
3957
3680
|
case 9:
|
|
3958
|
-
|
|
3959
|
-
|
|
3960
|
-
throw
|
|
3681
|
+
_context40.prev = 9;
|
|
3682
|
+
_context40.t0 = _context40["catch"](0);
|
|
3683
|
+
throw _context40.t0;
|
|
3961
3684
|
case 12:
|
|
3962
3685
|
case "end":
|
|
3963
|
-
return
|
|
3686
|
+
return _context40.stop();
|
|
3964
3687
|
}
|
|
3965
|
-
},
|
|
3688
|
+
}, _callee40, this, [[0, 9]]);
|
|
3966
3689
|
}));
|
|
3967
|
-
function updateOrderProduct(
|
|
3690
|
+
function updateOrderProduct(_x35) {
|
|
3968
3691
|
return _updateOrderProduct.apply(this, arguments);
|
|
3969
3692
|
}
|
|
3970
3693
|
return updateOrderProduct;
|
|
@@ -3972,34 +3695,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
3972
3695
|
}, {
|
|
3973
3696
|
key: "updateOrderProducts",
|
|
3974
3697
|
value: function () {
|
|
3975
|
-
var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3698
|
+
var _updateOrderProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(paramsList) {
|
|
3976
3699
|
var products;
|
|
3977
|
-
return _regeneratorRuntime().wrap(function
|
|
3978
|
-
while (1) switch (
|
|
3700
|
+
return _regeneratorRuntime().wrap(function _callee41$(_context41) {
|
|
3701
|
+
while (1) switch (_context41.prev = _context41.next) {
|
|
3979
3702
|
case 0:
|
|
3980
|
-
|
|
3703
|
+
_context41.prev = 0;
|
|
3981
3704
|
if (this.store.order) {
|
|
3982
|
-
|
|
3705
|
+
_context41.next = 3;
|
|
3983
3706
|
break;
|
|
3984
3707
|
}
|
|
3985
3708
|
throw new Error('order 模块未初始化');
|
|
3986
3709
|
case 3:
|
|
3987
|
-
|
|
3710
|
+
_context41.next = 5;
|
|
3988
3711
|
return this.store.order.updateOrderProducts(paramsList);
|
|
3989
3712
|
case 5:
|
|
3990
|
-
products =
|
|
3991
|
-
return
|
|
3713
|
+
products = _context41.sent;
|
|
3714
|
+
return _context41.abrupt("return", products);
|
|
3992
3715
|
case 9:
|
|
3993
|
-
|
|
3994
|
-
|
|
3995
|
-
throw
|
|
3716
|
+
_context41.prev = 9;
|
|
3717
|
+
_context41.t0 = _context41["catch"](0);
|
|
3718
|
+
throw _context41.t0;
|
|
3996
3719
|
case 12:
|
|
3997
3720
|
case "end":
|
|
3998
|
-
return
|
|
3721
|
+
return _context41.stop();
|
|
3999
3722
|
}
|
|
4000
|
-
},
|
|
3723
|
+
}, _callee41, this, [[0, 9]]);
|
|
4001
3724
|
}));
|
|
4002
|
-
function updateOrderProducts(
|
|
3725
|
+
function updateOrderProducts(_x36) {
|
|
4003
3726
|
return _updateOrderProducts.apply(this, arguments);
|
|
4004
3727
|
}
|
|
4005
3728
|
return updateOrderProducts;
|
|
@@ -4007,34 +3730,34 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4007
3730
|
}, {
|
|
4008
3731
|
key: "updateOrderProductQuantity",
|
|
4009
3732
|
value: function () {
|
|
4010
|
-
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3733
|
+
var _updateOrderProductQuantity = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(params) {
|
|
4011
3734
|
var products;
|
|
4012
|
-
return _regeneratorRuntime().wrap(function
|
|
4013
|
-
while (1) switch (
|
|
3735
|
+
return _regeneratorRuntime().wrap(function _callee42$(_context42) {
|
|
3736
|
+
while (1) switch (_context42.prev = _context42.next) {
|
|
4014
3737
|
case 0:
|
|
4015
|
-
|
|
3738
|
+
_context42.prev = 0;
|
|
4016
3739
|
if (this.store.order) {
|
|
4017
|
-
|
|
3740
|
+
_context42.next = 3;
|
|
4018
3741
|
break;
|
|
4019
3742
|
}
|
|
4020
3743
|
throw new Error('order 模块未初始化');
|
|
4021
3744
|
case 3:
|
|
4022
|
-
|
|
3745
|
+
_context42.next = 5;
|
|
4023
3746
|
return this.store.order.updateOrderProductQuantity(params);
|
|
4024
3747
|
case 5:
|
|
4025
|
-
products =
|
|
4026
|
-
return
|
|
3748
|
+
products = _context42.sent;
|
|
3749
|
+
return _context42.abrupt("return", products);
|
|
4027
3750
|
case 9:
|
|
4028
|
-
|
|
4029
|
-
|
|
4030
|
-
throw
|
|
3751
|
+
_context42.prev = 9;
|
|
3752
|
+
_context42.t0 = _context42["catch"](0);
|
|
3753
|
+
throw _context42.t0;
|
|
4031
3754
|
case 12:
|
|
4032
3755
|
case "end":
|
|
4033
|
-
return
|
|
3756
|
+
return _context42.stop();
|
|
4034
3757
|
}
|
|
4035
|
-
},
|
|
3758
|
+
}, _callee42, this, [[0, 9]]);
|
|
4036
3759
|
}));
|
|
4037
|
-
function updateOrderProductQuantity(
|
|
3760
|
+
function updateOrderProductQuantity(_x37) {
|
|
4038
3761
|
return _updateOrderProductQuantity.apply(this, arguments);
|
|
4039
3762
|
}
|
|
4040
3763
|
return updateOrderProductQuantity;
|
|
@@ -4057,12 +3780,12 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4057
3780
|
}, {
|
|
4058
3781
|
key: "setOrderProductLineNote",
|
|
4059
3782
|
value: (function () {
|
|
4060
|
-
var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3783
|
+
var _setOrderProductLineNote = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(identity, note) {
|
|
4061
3784
|
var params, products;
|
|
4062
|
-
return _regeneratorRuntime().wrap(function
|
|
4063
|
-
while (1) switch (
|
|
3785
|
+
return _regeneratorRuntime().wrap(function _callee43$(_context43) {
|
|
3786
|
+
while (1) switch (_context43.prev = _context43.next) {
|
|
4064
3787
|
case 0:
|
|
4065
|
-
|
|
3788
|
+
_context43.prev = 0;
|
|
4066
3789
|
params = {
|
|
4067
3790
|
product_id: identity.product_id,
|
|
4068
3791
|
product_variant_id: identity.product_variant_id,
|
|
@@ -4077,22 +3800,22 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4077
3800
|
params.product_sku = identity.product_sku;
|
|
4078
3801
|
}
|
|
4079
3802
|
if (identity.product_bundle !== undefined) params.product_bundle = identity.product_bundle;
|
|
4080
|
-
|
|
3803
|
+
_context43.next = 7;
|
|
4081
3804
|
return this.updateOrderProduct(params);
|
|
4082
3805
|
case 7:
|
|
4083
|
-
products =
|
|
4084
|
-
return
|
|
3806
|
+
products = _context43.sent;
|
|
3807
|
+
return _context43.abrupt("return", products);
|
|
4085
3808
|
case 11:
|
|
4086
|
-
|
|
4087
|
-
|
|
4088
|
-
throw
|
|
3809
|
+
_context43.prev = 11;
|
|
3810
|
+
_context43.t0 = _context43["catch"](0);
|
|
3811
|
+
throw _context43.t0;
|
|
4089
3812
|
case 14:
|
|
4090
3813
|
case "end":
|
|
4091
|
-
return
|
|
3814
|
+
return _context43.stop();
|
|
4092
3815
|
}
|
|
4093
|
-
},
|
|
3816
|
+
}, _callee43, this, [[0, 11]]);
|
|
4094
3817
|
}));
|
|
4095
|
-
function setOrderProductLineNote(
|
|
3818
|
+
function setOrderProductLineNote(_x38, _x39) {
|
|
4096
3819
|
return _setOrderProductLineNote.apply(this, arguments);
|
|
4097
3820
|
}
|
|
4098
3821
|
return setOrderProductLineNote;
|
|
@@ -4107,32 +3830,32 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4107
3830
|
}, {
|
|
4108
3831
|
key: "removeProductsFromOrder",
|
|
4109
3832
|
value: (function () {
|
|
4110
|
-
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4111
|
-
return _regeneratorRuntime().wrap(function
|
|
4112
|
-
while (1) switch (
|
|
3833
|
+
var _removeProductsFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44(identities, options) {
|
|
3834
|
+
return _regeneratorRuntime().wrap(function _callee44$(_context44) {
|
|
3835
|
+
while (1) switch (_context44.prev = _context44.next) {
|
|
4113
3836
|
case 0:
|
|
4114
|
-
|
|
3837
|
+
_context44.prev = 0;
|
|
4115
3838
|
if (this.store.order) {
|
|
4116
|
-
|
|
3839
|
+
_context44.next = 3;
|
|
4117
3840
|
break;
|
|
4118
3841
|
}
|
|
4119
3842
|
throw new Error('order 模块未初始化');
|
|
4120
3843
|
case 3:
|
|
4121
|
-
|
|
4122
|
-
return this.store.order.removeProductsFromOrder(identities);
|
|
3844
|
+
_context44.next = 5;
|
|
3845
|
+
return this.store.order.removeProductsFromOrder(identities, options);
|
|
4123
3846
|
case 5:
|
|
4124
|
-
return
|
|
3847
|
+
return _context44.abrupt("return", _context44.sent);
|
|
4125
3848
|
case 8:
|
|
4126
|
-
|
|
4127
|
-
|
|
4128
|
-
throw
|
|
3849
|
+
_context44.prev = 8;
|
|
3850
|
+
_context44.t0 = _context44["catch"](0);
|
|
3851
|
+
throw _context44.t0;
|
|
4129
3852
|
case 11:
|
|
4130
3853
|
case "end":
|
|
4131
|
-
return
|
|
3854
|
+
return _context44.stop();
|
|
4132
3855
|
}
|
|
4133
|
-
},
|
|
3856
|
+
}, _callee44, this, [[0, 8]]);
|
|
4134
3857
|
}));
|
|
4135
|
-
function removeProductsFromOrder(
|
|
3858
|
+
function removeProductsFromOrder(_x40, _x41) {
|
|
4136
3859
|
return _removeProductsFromOrder.apply(this, arguments);
|
|
4137
3860
|
}
|
|
4138
3861
|
return removeProductsFromOrder;
|
|
@@ -4140,18 +3863,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4140
3863
|
}, {
|
|
4141
3864
|
key: "removeProductFromOrder",
|
|
4142
3865
|
value: function () {
|
|
4143
|
-
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4144
|
-
return _regeneratorRuntime().wrap(function
|
|
4145
|
-
while (1) switch (
|
|
3866
|
+
var _removeProductFromOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(identity, options) {
|
|
3867
|
+
return _regeneratorRuntime().wrap(function _callee45$(_context45) {
|
|
3868
|
+
while (1) switch (_context45.prev = _context45.next) {
|
|
4146
3869
|
case 0:
|
|
4147
|
-
return
|
|
3870
|
+
return _context45.abrupt("return", this.removeProductsFromOrder([identity], options));
|
|
4148
3871
|
case 1:
|
|
4149
3872
|
case "end":
|
|
4150
|
-
return
|
|
3873
|
+
return _context45.stop();
|
|
4151
3874
|
}
|
|
4152
|
-
},
|
|
3875
|
+
}, _callee45, this);
|
|
4153
3876
|
}));
|
|
4154
|
-
function removeProductFromOrder(
|
|
3877
|
+
function removeProductFromOrder(_x42, _x43) {
|
|
4155
3878
|
return _removeProductFromOrder.apply(this, arguments);
|
|
4156
3879
|
}
|
|
4157
3880
|
return removeProductFromOrder;
|
|
@@ -4201,23 +3924,23 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4201
3924
|
}, {
|
|
4202
3925
|
key: "applyPromotion",
|
|
4203
3926
|
value: (function () {
|
|
4204
|
-
var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4205
|
-
return _regeneratorRuntime().wrap(function
|
|
4206
|
-
while (1) switch (
|
|
3927
|
+
var _applyPromotion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46() {
|
|
3928
|
+
return _regeneratorRuntime().wrap(function _callee46$(_context46) {
|
|
3929
|
+
while (1) switch (_context46.prev = _context46.next) {
|
|
4207
3930
|
case 0:
|
|
4208
3931
|
if (this.store.order) {
|
|
4209
|
-
|
|
3932
|
+
_context46.next = 2;
|
|
4210
3933
|
break;
|
|
4211
3934
|
}
|
|
4212
3935
|
throw new Error('order 模块未初始化');
|
|
4213
3936
|
case 2:
|
|
4214
|
-
|
|
3937
|
+
_context46.next = 4;
|
|
4215
3938
|
return this.store.order.applyPromotion();
|
|
4216
3939
|
case 4:
|
|
4217
3940
|
case "end":
|
|
4218
|
-
return
|
|
3941
|
+
return _context46.stop();
|
|
4219
3942
|
}
|
|
4220
|
-
},
|
|
3943
|
+
}, _callee46, this);
|
|
4221
3944
|
}));
|
|
4222
3945
|
function applyPromotion() {
|
|
4223
3946
|
return _applyPromotion.apply(this, arguments);
|
|
@@ -4244,18 +3967,18 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4244
3967
|
}, {
|
|
4245
3968
|
key: "getProductList",
|
|
4246
3969
|
value: function () {
|
|
4247
|
-
var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4248
|
-
var _this$
|
|
3970
|
+
var _getProductList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47() {
|
|
3971
|
+
var _this$otherParams26;
|
|
4249
3972
|
var menu_list_ids, _this$store$products, res;
|
|
4250
|
-
return _regeneratorRuntime().wrap(function
|
|
4251
|
-
while (1) switch (
|
|
3973
|
+
return _regeneratorRuntime().wrap(function _callee47$(_context47) {
|
|
3974
|
+
while (1) switch (_context47.prev = _context47.next) {
|
|
4252
3975
|
case 0:
|
|
4253
3976
|
// 可以直接通过配置里的 menu 读取
|
|
4254
|
-
menu_list_ids = ((_this$
|
|
3977
|
+
menu_list_ids = ((_this$otherParams26 = this.otherParams) === null || _this$otherParams26 === void 0 || (_this$otherParams26 = _this$otherParams26.dineInConfig) === null || _this$otherParams26 === void 0 ? void 0 : _this$otherParams26['menu.associated_menus'].map(function (n) {
|
|
4255
3978
|
return Number(n.value);
|
|
4256
3979
|
})) || [];
|
|
4257
|
-
|
|
4258
|
-
|
|
3980
|
+
_context47.prev = 1;
|
|
3981
|
+
_context47.next = 4;
|
|
4259
3982
|
return (_this$store$products = this.store.products) === null || _this$store$products === void 0 ? void 0 : _this$store$products.loadProducts({
|
|
4260
3983
|
menu_list_ids: menu_list_ids,
|
|
4261
3984
|
cacheId: this.cacheId,
|
|
@@ -4263,17 +3986,17 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4263
3986
|
schedule_datetime: dayjs().format('YYYY-MM-DD HH:mm:ss')
|
|
4264
3987
|
});
|
|
4265
3988
|
case 4:
|
|
4266
|
-
res =
|
|
4267
|
-
return
|
|
3989
|
+
res = _context47.sent;
|
|
3990
|
+
return _context47.abrupt("return", res);
|
|
4268
3991
|
case 8:
|
|
4269
|
-
|
|
4270
|
-
|
|
4271
|
-
throw
|
|
3992
|
+
_context47.prev = 8;
|
|
3993
|
+
_context47.t0 = _context47["catch"](1);
|
|
3994
|
+
throw _context47.t0;
|
|
4272
3995
|
case 11:
|
|
4273
3996
|
case "end":
|
|
4274
|
-
return
|
|
3997
|
+
return _context47.stop();
|
|
4275
3998
|
}
|
|
4276
|
-
},
|
|
3999
|
+
}, _callee47, this, [[1, 8]]);
|
|
4277
4000
|
}));
|
|
4278
4001
|
function getProductList() {
|
|
4279
4002
|
return _getProductList.apply(this, arguments);
|
|
@@ -4288,33 +4011,33 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
4288
4011
|
}, {
|
|
4289
4012
|
key: "setOtherParams",
|
|
4290
4013
|
value: function () {
|
|
4291
|
-
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4292
|
-
var _this$
|
|
4293
|
-
var
|
|
4294
|
-
|
|
4014
|
+
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48(params) {
|
|
4015
|
+
var _this$otherParams27;
|
|
4016
|
+
var _ref33,
|
|
4017
|
+
_ref33$cover,
|
|
4295
4018
|
cover,
|
|
4296
|
-
|
|
4297
|
-
return _regeneratorRuntime().wrap(function
|
|
4298
|
-
while (1) switch (
|
|
4019
|
+
_args48 = arguments;
|
|
4020
|
+
return _regeneratorRuntime().wrap(function _callee48$(_context48) {
|
|
4021
|
+
while (1) switch (_context48.prev = _context48.next) {
|
|
4299
4022
|
case 0:
|
|
4300
|
-
|
|
4023
|
+
_ref33 = _args48.length > 1 && _args48[1] !== undefined ? _args48[1] : {}, _ref33$cover = _ref33.cover, cover = _ref33$cover === void 0 ? false : _ref33$cover;
|
|
4301
4024
|
if (cover) {
|
|
4302
4025
|
this.otherParams = _objectSpread({}, params);
|
|
4303
4026
|
} else {
|
|
4304
4027
|
this.otherParams = _objectSpread(_objectSpread({}, this.otherParams), params);
|
|
4305
4028
|
}
|
|
4306
|
-
this.cacheId = (_this$
|
|
4307
|
-
|
|
4029
|
+
this.cacheId = (_this$otherParams27 = this.otherParams) === null || _this$otherParams27 === void 0 ? void 0 : _this$otherParams27.cacheId;
|
|
4030
|
+
_context48.next = 5;
|
|
4308
4031
|
return this.syncOtherParamsToSubModules(params, {
|
|
4309
4032
|
cover: cover
|
|
4310
4033
|
});
|
|
4311
4034
|
case 5:
|
|
4312
4035
|
case "end":
|
|
4313
|
-
return
|
|
4036
|
+
return _context48.stop();
|
|
4314
4037
|
}
|
|
4315
|
-
},
|
|
4038
|
+
}, _callee48, this);
|
|
4316
4039
|
}));
|
|
4317
|
-
function setOtherParams(
|
|
4040
|
+
function setOtherParams(_x44) {
|
|
4318
4041
|
return _setOtherParams.apply(this, arguments);
|
|
4319
4042
|
}
|
|
4320
4043
|
return setOtherParams;
|