@pisell/pisellos 2.2.324 → 2.2.326
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/model/strategy/adapter/walletPass/locales.js +9 -0
- package/dist/modules/Order/index.d.ts +1 -1
- package/dist/modules/Payment/utils.d.ts +2 -0
- package/dist/modules/Payment/utils.js +6 -6
- package/dist/modules/Payment/walletpass.d.ts +2 -0
- package/dist/modules/Payment/walletpass.js +75 -34
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/server/index.d.ts +3 -0
- package/dist/server/index.js +792 -645
- package/dist/server/modules/products/index.d.ts +6 -2
- package/dist/server/modules/products/index.js +476 -400
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.js +6 -5
- package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +1 -1
- package/dist/solution/UnifiedBookingSales/index.js +34 -23
- package/lib/model/strategy/adapter/promotion/index.js +46 -1
- package/lib/model/strategy/adapter/walletPass/locales.js +9 -0
- package/lib/modules/Order/index.d.ts +1 -1
- package/lib/modules/Payment/utils.d.ts +2 -0
- package/lib/modules/Payment/utils.js +7 -7
- package/lib/modules/Payment/walletpass.d.ts +2 -0
- package/lib/modules/Payment/walletpass.js +42 -11
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/server/index.d.ts +3 -0
- package/lib/server/index.js +79 -7
- package/lib/server/modules/products/index.d.ts +6 -2
- package/lib/server/modules/products/index.js +40 -7
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.js +2 -1
- package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +1 -1
- package/lib/solution/UnifiedBookingSales/index.js +3 -2
- package/package.json +1 -1
package/dist/server/index.js
CHANGED
|
@@ -129,6 +129,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
129
129
|
_defineProperty(this, "deviceTaskActionsRegistered", false);
|
|
130
130
|
_defineProperty(this, "localPaymentUpdateQueues", new Map());
|
|
131
131
|
_defineProperty(this, "paymentIdentityRefreshes", new Map());
|
|
132
|
+
_defineProperty(this, "receiptFulfillmentConfigInFlight", new Map());
|
|
132
133
|
_defineProperty(this, "floorPlanQuerySubscribers", new Map());
|
|
133
134
|
// 模块注册表 - 定义所有可用的模块配置
|
|
134
135
|
_defineProperty(this, "moduleRegistry", {
|
|
@@ -1477,7 +1478,8 @@ var Server = /*#__PURE__*/function () {
|
|
|
1477
1478
|
locales: _this.normalizeRequestedReceiptLocales(input.locales),
|
|
1478
1479
|
invoiceTemplateSettings: input.template_settings === undefined ? undefined : _this.normalizePrintInvoiceTemplateSettings(input.template_settings),
|
|
1479
1480
|
applyTemplateVisibility: true,
|
|
1480
|
-
includeReceiptKeys: input.template_settings !== undefined
|
|
1481
|
+
includeReceiptKeys: input.template_settings !== undefined,
|
|
1482
|
+
refreshResourceReference: true
|
|
1481
1483
|
});
|
|
1482
1484
|
case 22:
|
|
1483
1485
|
rebuiltOrder = _context22.sent;
|
|
@@ -5939,6 +5941,123 @@ var Server = /*#__PURE__*/function () {
|
|
|
5939
5941
|
});
|
|
5940
5942
|
return values.join(',');
|
|
5941
5943
|
}
|
|
5944
|
+
|
|
5945
|
+
/** Refresh derived references on receipt copies; manual references and stored orders stay intact. */
|
|
5946
|
+
}, {
|
|
5947
|
+
key: "withCurrentReceiptResourceReference",
|
|
5948
|
+
value: (function () {
|
|
5949
|
+
var _withCurrentReceiptResourceReference = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee61(order) {
|
|
5950
|
+
var _order$buzzer,
|
|
5951
|
+
_this$app17,
|
|
5952
|
+
_this18 = this;
|
|
5953
|
+
var resourceReference, businessCode, channel, shopId, tenantId, key, inFlight, _this$getAppData, mode;
|
|
5954
|
+
return _regeneratorRuntime().wrap(function _callee61$(_context61) {
|
|
5955
|
+
while (1) switch (_context61.prev = _context61.next) {
|
|
5956
|
+
case 0:
|
|
5957
|
+
resourceReference = this.buildCheckoutResourceIdentifierBuzzer(order.bookings);
|
|
5958
|
+
if (!(!resourceReference || resourceReference === String((_order$buzzer = order.buzzer) !== null && _order$buzzer !== void 0 ? _order$buzzer : ''))) {
|
|
5959
|
+
_context61.next = 3;
|
|
5960
|
+
break;
|
|
5961
|
+
}
|
|
5962
|
+
return _context61.abrupt("return", order);
|
|
5963
|
+
case 3:
|
|
5964
|
+
businessCode = String(order.business_code || '').trim();
|
|
5965
|
+
channel = String(order.order_sales_channel || '').trim();
|
|
5966
|
+
shopId = this.getAppData('shop_id');
|
|
5967
|
+
tenantId = this.getAppData('tenant_id');
|
|
5968
|
+
if (!(!businessCode || !channel || !shopId || !((_this$app17 = this.app) !== null && _this$app17 !== void 0 && (_this$app17 = _this$app17.request) !== null && _this$app17 !== void 0 && _this$app17.post))) {
|
|
5969
|
+
_context61.next = 9;
|
|
5970
|
+
break;
|
|
5971
|
+
}
|
|
5972
|
+
return _context61.abrupt("return", order);
|
|
5973
|
+
case 9:
|
|
5974
|
+
// A receipt can be printed outside a Sales instance. Read the order's own
|
|
5975
|
+
// business/channel settings rather than borrowing the currently open page.
|
|
5976
|
+
key = JSON.stringify([String(shopId), String(tenantId !== null && tenantId !== void 0 ? tenantId : ''), businessCode, channel]);
|
|
5977
|
+
inFlight = this.receiptFulfillmentConfigInFlight.get(key);
|
|
5978
|
+
if (!inFlight) {
|
|
5979
|
+
inFlight = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee60() {
|
|
5980
|
+
var _response$data5;
|
|
5981
|
+
var response;
|
|
5982
|
+
return _regeneratorRuntime().wrap(function _callee60$(_context60) {
|
|
5983
|
+
while (1) switch (_context60.prev = _context60.next) {
|
|
5984
|
+
case 0:
|
|
5985
|
+
_context60.next = 2;
|
|
5986
|
+
return _this18.app.request.post("/open/my-pisell/".concat(shopId, "/setting"), {
|
|
5987
|
+
scope: 'board',
|
|
5988
|
+
target: "".concat(businessCode, "+").concat(channel),
|
|
5989
|
+
section_code: ['fulfillment']
|
|
5990
|
+
}, _objectSpread({
|
|
5991
|
+
pisell2: true,
|
|
5992
|
+
isPisell2: true,
|
|
5993
|
+
prefix: false,
|
|
5994
|
+
customToast: function customToast() {}
|
|
5995
|
+
}, tenantId ? {
|
|
5996
|
+
headers: {
|
|
5997
|
+
'Tenant-Id': String(tenantId)
|
|
5998
|
+
}
|
|
5999
|
+
} : {}));
|
|
6000
|
+
case 2:
|
|
6001
|
+
response = _context60.sent;
|
|
6002
|
+
if (!((response === null || response === void 0 ? void 0 : response.status) === false || (response === null || response === void 0 ? void 0 : response.code) != null && Number(response.code) !== 200)) {
|
|
6003
|
+
_context60.next = 5;
|
|
6004
|
+
break;
|
|
6005
|
+
}
|
|
6006
|
+
throw new Error('Receipt fulfillment settings are unavailable');
|
|
6007
|
+
case 5:
|
|
6008
|
+
return _context60.abrupt("return", response === null || response === void 0 || (_response$data5 = response.data) === null || _response$data5 === void 0 ? void 0 : _response$data5['fulfillment.fulfillment_ref_mode']);
|
|
6009
|
+
case 6:
|
|
6010
|
+
case "end":
|
|
6011
|
+
return _context60.stop();
|
|
6012
|
+
}
|
|
6013
|
+
}, _callee60);
|
|
6014
|
+
}))();
|
|
6015
|
+
this.receiptFulfillmentConfigInFlight.set(key, inFlight);
|
|
6016
|
+
}
|
|
6017
|
+
_context61.prev = 12;
|
|
6018
|
+
_context61.next = 15;
|
|
6019
|
+
return inFlight;
|
|
6020
|
+
case 15:
|
|
6021
|
+
mode = _context61.sent;
|
|
6022
|
+
if (!(mode !== 'resource_identifier' || String(this.getAppData('shop_id')) !== String(shopId) || String((_this$getAppData = this.getAppData('tenant_id')) !== null && _this$getAppData !== void 0 ? _this$getAppData : '') !== String(tenantId !== null && tenantId !== void 0 ? tenantId : ''))) {
|
|
6023
|
+
_context61.next = 18;
|
|
6024
|
+
break;
|
|
6025
|
+
}
|
|
6026
|
+
return _context61.abrupt("return", order);
|
|
6027
|
+
case 18:
|
|
6028
|
+
return _context61.abrupt("return", _objectSpread(_objectSpread({}, order), {}, {
|
|
6029
|
+
buzzer: resourceReference
|
|
6030
|
+
}));
|
|
6031
|
+
case 21:
|
|
6032
|
+
_context61.prev = 21;
|
|
6033
|
+
_context61.t0 = _context61["catch"](12);
|
|
6034
|
+
// Offline/manual printing still works. Without a confirmed policy, do not
|
|
6035
|
+
// mistake a manually entered pickup reference for an obsolete table name.
|
|
6036
|
+
this.logWarning('withCurrentReceiptResourceReference: 配置不可用,保留原取单号', {
|
|
6037
|
+
order_id: order.order_id,
|
|
6038
|
+
target: "".concat(businessCode, "+").concat(channel),
|
|
6039
|
+
error: _context61.t0 instanceof Error ? _context61.t0.message : String(_context61.t0)
|
|
6040
|
+
});
|
|
6041
|
+
return _context61.abrupt("return", order);
|
|
6042
|
+
case 25:
|
|
6043
|
+
_context61.prev = 25;
|
|
6044
|
+
// Only coalesce concurrent outputs; settings changes and failures must be
|
|
6045
|
+
// re-read on the next receipt instead of becoming a permanent cache.
|
|
6046
|
+
if (this.receiptFulfillmentConfigInFlight.get(key) === inFlight) {
|
|
6047
|
+
this.receiptFulfillmentConfigInFlight.delete(key);
|
|
6048
|
+
}
|
|
6049
|
+
return _context61.finish(25);
|
|
6050
|
+
case 28:
|
|
6051
|
+
case "end":
|
|
6052
|
+
return _context61.stop();
|
|
6053
|
+
}
|
|
6054
|
+
}, _callee61, this, [[12, 21, 25, 28]]);
|
|
6055
|
+
}));
|
|
6056
|
+
function withCurrentReceiptResourceReference(_x63) {
|
|
6057
|
+
return _withCurrentReceiptResourceReference.apply(this, arguments);
|
|
6058
|
+
}
|
|
6059
|
+
return withCurrentReceiptResourceReference;
|
|
6060
|
+
}())
|
|
5942
6061
|
}, {
|
|
5943
6062
|
key: "getCheckoutResourceIdentifier",
|
|
5944
6063
|
value: function getCheckoutResourceIdentifier(resource, fallbackName) {
|
|
@@ -5971,16 +6090,16 @@ var Server = /*#__PURE__*/function () {
|
|
|
5971
6090
|
}, {
|
|
5972
6091
|
key: "normalizeCheckoutSubmitData",
|
|
5973
6092
|
value: function () {
|
|
5974
|
-
var _normalizeCheckoutSubmitData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6093
|
+
var _normalizeCheckoutSubmitData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee62(data, title) {
|
|
5975
6094
|
var next, externalSaleNumber, shouldClearLocalOrderId, hasCheckoutOrderNumbers, localOrder;
|
|
5976
|
-
return _regeneratorRuntime().wrap(function
|
|
5977
|
-
while (1) switch (
|
|
6095
|
+
return _regeneratorRuntime().wrap(function _callee62$(_context62) {
|
|
6096
|
+
while (1) switch (_context62.prev = _context62.next) {
|
|
5978
6097
|
case 0:
|
|
5979
6098
|
if (!(!data || _typeof(data) !== 'object')) {
|
|
5980
|
-
|
|
6099
|
+
_context62.next = 2;
|
|
5981
6100
|
break;
|
|
5982
6101
|
}
|
|
5983
|
-
return
|
|
6102
|
+
return _context62.abrupt("return", data);
|
|
5984
6103
|
case 2:
|
|
5985
6104
|
next = _objectSpread({}, data);
|
|
5986
6105
|
externalSaleNumber = next.external_sale_number;
|
|
@@ -5990,7 +6109,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
5990
6109
|
delete next.vouchers;
|
|
5991
6110
|
hasCheckoutOrderNumbers = !this.isBlankCheckoutValue(next.shop_order_number) && !this.isBlankCheckoutValue(next.shop_full_order_number);
|
|
5992
6111
|
if (!hasCheckoutOrderNumbers) {
|
|
5993
|
-
|
|
6112
|
+
_context62.next = 11;
|
|
5994
6113
|
break;
|
|
5995
6114
|
}
|
|
5996
6115
|
this.logInfo("".concat(title, ": checkout \u5DF2\u643A\u5E26\u8BA2\u5355\u53F7\uFF0C\u8DF3\u8FC7\u67E5\u91CD"), {
|
|
@@ -6000,10 +6119,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
6000
6119
|
shop_order_number: next.shop_order_number,
|
|
6001
6120
|
shop_full_order_number: next.shop_full_order_number
|
|
6002
6121
|
});
|
|
6003
|
-
return
|
|
6122
|
+
return _context62.abrupt("return", next);
|
|
6004
6123
|
case 11:
|
|
6005
6124
|
if (!this.isBlankCheckoutValue(externalSaleNumber)) {
|
|
6006
|
-
|
|
6125
|
+
_context62.next = 14;
|
|
6007
6126
|
break;
|
|
6008
6127
|
}
|
|
6009
6128
|
if (shouldClearLocalOrderId) {
|
|
@@ -6012,10 +6131,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
6012
6131
|
order_id: next.order_id
|
|
6013
6132
|
});
|
|
6014
6133
|
}
|
|
6015
|
-
return
|
|
6134
|
+
return _context62.abrupt("return", next);
|
|
6016
6135
|
case 14:
|
|
6017
6136
|
if (!(!this.order || typeof this.order.getLocalOrderFromMemoryByLookup !== 'function')) {
|
|
6018
|
-
|
|
6137
|
+
_context62.next = 17;
|
|
6019
6138
|
break;
|
|
6020
6139
|
}
|
|
6021
6140
|
if (shouldClearLocalOrderId) {
|
|
@@ -6024,12 +6143,12 @@ var Server = /*#__PURE__*/function () {
|
|
|
6024
6143
|
external_sale_number: externalSaleNumber
|
|
6025
6144
|
});
|
|
6026
6145
|
}
|
|
6027
|
-
return
|
|
6146
|
+
return _context62.abrupt("return", next);
|
|
6028
6147
|
case 17:
|
|
6029
|
-
|
|
6148
|
+
_context62.prev = 17;
|
|
6030
6149
|
localOrder = this.order.getLocalOrderFromMemoryByLookup(externalSaleNumber);
|
|
6031
6150
|
if (localOrder) {
|
|
6032
|
-
|
|
6151
|
+
_context62.next = 22;
|
|
6033
6152
|
break;
|
|
6034
6153
|
}
|
|
6035
6154
|
if (shouldClearLocalOrderId) {
|
|
@@ -6039,7 +6158,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6039
6158
|
localOrderFound: false
|
|
6040
6159
|
});
|
|
6041
6160
|
}
|
|
6042
|
-
return
|
|
6161
|
+
return _context62.abrupt("return", next);
|
|
6043
6162
|
case 22:
|
|
6044
6163
|
if (this.isBlankCheckoutValue(next.shop_order_number)) {
|
|
6045
6164
|
next.shop_order_number = localOrder.shop_order_number;
|
|
@@ -6056,23 +6175,23 @@ var Server = /*#__PURE__*/function () {
|
|
|
6056
6175
|
shop_full_order_number: next.shop_full_order_number
|
|
6057
6176
|
});
|
|
6058
6177
|
// 删除 数据体中的 vouchers,对小票和后端来说他们不需要,这个字段只是单向同步给前端用的,而且目前对订单来说还没什么用
|
|
6059
|
-
return
|
|
6178
|
+
return _context62.abrupt("return", next);
|
|
6060
6179
|
case 28:
|
|
6061
|
-
|
|
6062
|
-
|
|
6180
|
+
_context62.prev = 28;
|
|
6181
|
+
_context62.t0 = _context62["catch"](17);
|
|
6063
6182
|
this.logWarning("".concat(title, ": checkout \u67E5\u627E\u672C\u5730\u8BA2\u5355\u5931\u8D25"), {
|
|
6064
6183
|
external_sale_number: externalSaleNumber,
|
|
6065
|
-
error: this.getUnknownErrorMessage(
|
|
6066
|
-
error_detail: this.normalizeUnknownError(
|
|
6184
|
+
error: this.getUnknownErrorMessage(_context62.t0),
|
|
6185
|
+
error_detail: this.normalizeUnknownError(_context62.t0)
|
|
6067
6186
|
});
|
|
6068
|
-
return
|
|
6187
|
+
return _context62.abrupt("return", next);
|
|
6069
6188
|
case 32:
|
|
6070
6189
|
case "end":
|
|
6071
|
-
return
|
|
6190
|
+
return _context62.stop();
|
|
6072
6191
|
}
|
|
6073
|
-
},
|
|
6192
|
+
}, _callee62, this, [[17, 28]]);
|
|
6074
6193
|
}));
|
|
6075
|
-
function normalizeCheckoutSubmitData(
|
|
6194
|
+
function normalizeCheckoutSubmitData(_x64, _x65) {
|
|
6076
6195
|
return _normalizeCheckoutSubmitData.apply(this, arguments);
|
|
6077
6196
|
}
|
|
6078
6197
|
return normalizeCheckoutSubmitData;
|
|
@@ -6080,81 +6199,94 @@ var Server = /*#__PURE__*/function () {
|
|
|
6080
6199
|
}, {
|
|
6081
6200
|
key: "ensureCheckoutOrderNumbers",
|
|
6082
6201
|
value: function () {
|
|
6083
|
-
var _ensureCheckoutOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6084
|
-
var next, needsShopOrderNumber, needsShopFullOrderNumber, idGenerator;
|
|
6085
|
-
return _regeneratorRuntime().wrap(function
|
|
6086
|
-
while (1) switch (
|
|
6202
|
+
var _ensureCheckoutOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee63(data, title) {
|
|
6203
|
+
var next, needsShopOrderNumber, needsShopFullOrderNumber, idGenerator, _idGenerator$getConfi, _biz;
|
|
6204
|
+
return _regeneratorRuntime().wrap(function _callee63$(_context63) {
|
|
6205
|
+
while (1) switch (_context63.prev = _context63.next) {
|
|
6087
6206
|
case 0:
|
|
6088
6207
|
if (!(!data || _typeof(data) !== 'object')) {
|
|
6089
|
-
|
|
6208
|
+
_context63.next = 2;
|
|
6090
6209
|
break;
|
|
6091
6210
|
}
|
|
6092
|
-
return
|
|
6211
|
+
return _context63.abrupt("return", data);
|
|
6093
6212
|
case 2:
|
|
6094
6213
|
next = _objectSpread({}, data);
|
|
6095
6214
|
needsShopOrderNumber = next.shop_order_number === undefined || next.shop_order_number === null || next.shop_order_number === '';
|
|
6096
6215
|
needsShopFullOrderNumber = next.shop_full_order_number === undefined || next.shop_full_order_number === null || next.shop_full_order_number === '';
|
|
6097
6216
|
if (!(!needsShopOrderNumber && !needsShopFullOrderNumber)) {
|
|
6098
|
-
|
|
6217
|
+
_context63.next = 7;
|
|
6099
6218
|
break;
|
|
6100
6219
|
}
|
|
6101
|
-
return
|
|
6220
|
+
return _context63.abrupt("return", this.finalizeCheckoutSalesNotes(next, title));
|
|
6102
6221
|
case 7:
|
|
6103
6222
|
idGenerator = this.getIdGeneratorPlugin();
|
|
6104
6223
|
if (idGenerator) {
|
|
6105
|
-
|
|
6224
|
+
_context63.next = 11;
|
|
6106
6225
|
break;
|
|
6107
6226
|
}
|
|
6108
6227
|
this.logWarning("".concat(title, ": idGenerator \u63D2\u4EF6\u4E0D\u53EF\u7528\uFF0C\u65E0\u6CD5\u751F\u6210\u8BA2\u5355\u53F7"), {
|
|
6109
6228
|
needsShopOrderNumber: needsShopOrderNumber,
|
|
6110
6229
|
needsShopFullOrderNumber: needsShopFullOrderNumber
|
|
6111
6230
|
});
|
|
6112
|
-
return
|
|
6231
|
+
return _context63.abrupt("return", this.finalizeCheckoutSalesNotes(next, title));
|
|
6113
6232
|
case 11:
|
|
6114
|
-
|
|
6233
|
+
_context63.prev = 11;
|
|
6115
6234
|
if (!(needsShopOrderNumber && idGenerator.generateShopOrderNumber)) {
|
|
6116
|
-
|
|
6235
|
+
_context63.next = 16;
|
|
6117
6236
|
break;
|
|
6118
6237
|
}
|
|
6119
|
-
|
|
6238
|
+
_context63.next = 15;
|
|
6120
6239
|
return idGenerator.generateShopOrderNumber({
|
|
6121
6240
|
biz: next.business_code || 'ticket'
|
|
6122
6241
|
});
|
|
6123
6242
|
case 15:
|
|
6124
|
-
next.shop_order_number =
|
|
6243
|
+
next.shop_order_number = _context63.sent;
|
|
6125
6244
|
case 16:
|
|
6126
|
-
if (!
|
|
6127
|
-
|
|
6245
|
+
if (!needsShopFullOrderNumber) {
|
|
6246
|
+
_context63.next = 26;
|
|
6247
|
+
break;
|
|
6248
|
+
}
|
|
6249
|
+
_biz = next.business_code || 'ticket';
|
|
6250
|
+
if (!(((_idGenerator$getConfi = idGenerator.getConfig) === null || _idGenerator$getConfi === void 0 || (_idGenerator$getConfi = _idGenerator$getConfi.call(idGenerator, _biz)) === null || _idGenerator$getConfi === void 0 ? void 0 : _idGenerator$getConfi.enableShortNumber) === false)) {
|
|
6251
|
+
_context63.next = 22;
|
|
6252
|
+
break;
|
|
6253
|
+
}
|
|
6254
|
+
next.shop_full_order_number = next.shop_order_number;
|
|
6255
|
+
_context63.next = 26;
|
|
6256
|
+
break;
|
|
6257
|
+
case 22:
|
|
6258
|
+
if (!idGenerator.generateReceiptId) {
|
|
6259
|
+
_context63.next = 26;
|
|
6128
6260
|
break;
|
|
6129
6261
|
}
|
|
6130
|
-
|
|
6262
|
+
_context63.next = 25;
|
|
6131
6263
|
return idGenerator.generateReceiptId({
|
|
6132
|
-
biz:
|
|
6264
|
+
biz: _biz
|
|
6133
6265
|
});
|
|
6134
|
-
case
|
|
6135
|
-
next.shop_full_order_number =
|
|
6136
|
-
case
|
|
6266
|
+
case 25:
|
|
6267
|
+
next.shop_full_order_number = _context63.sent;
|
|
6268
|
+
case 26:
|
|
6137
6269
|
this.logInfo("".concat(title, ": checkout \u8BA2\u5355\u53F7\u5DF2\u51C6\u5907"), {
|
|
6138
6270
|
shop_order_number: next.shop_order_number,
|
|
6139
6271
|
shop_full_order_number: next.shop_full_order_number
|
|
6140
6272
|
});
|
|
6141
|
-
|
|
6273
|
+
_context63.next = 32;
|
|
6142
6274
|
break;
|
|
6143
|
-
case
|
|
6144
|
-
|
|
6145
|
-
|
|
6275
|
+
case 29:
|
|
6276
|
+
_context63.prev = 29;
|
|
6277
|
+
_context63.t0 = _context63["catch"](11);
|
|
6146
6278
|
this.logError("".concat(title, ": \u751F\u6210 checkout \u8BA2\u5355\u53F7\u5931\u8D25"), {
|
|
6147
|
-
error:
|
|
6279
|
+
error: _context63.t0 instanceof Error ? _context63.t0.message : String(_context63.t0)
|
|
6148
6280
|
});
|
|
6149
|
-
case
|
|
6150
|
-
return
|
|
6151
|
-
case
|
|
6281
|
+
case 32:
|
|
6282
|
+
return _context63.abrupt("return", this.finalizeCheckoutSalesNotes(next, title));
|
|
6283
|
+
case 33:
|
|
6152
6284
|
case "end":
|
|
6153
|
-
return
|
|
6285
|
+
return _context63.stop();
|
|
6154
6286
|
}
|
|
6155
|
-
},
|
|
6287
|
+
}, _callee63, this, [[11, 29]]);
|
|
6156
6288
|
}));
|
|
6157
|
-
function ensureCheckoutOrderNumbers(
|
|
6289
|
+
function ensureCheckoutOrderNumbers(_x66, _x67) {
|
|
6158
6290
|
return _ensureCheckoutOrderNumbers.apply(this, arguments);
|
|
6159
6291
|
}
|
|
6160
6292
|
return ensureCheckoutOrderNumbers;
|
|
@@ -6201,27 +6333,27 @@ var Server = /*#__PURE__*/function () {
|
|
|
6201
6333
|
}, {
|
|
6202
6334
|
key: "dispatchCheckoutSyncTask",
|
|
6203
6335
|
value: function () {
|
|
6204
|
-
var _dispatchCheckoutSyncTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6336
|
+
var _dispatchCheckoutSyncTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee64(params) {
|
|
6205
6337
|
var deviceTask, debugDeviceId, debugIdempotencyKey, _params$data, _params$data2, _params$data3, _params$data4, result;
|
|
6206
|
-
return _regeneratorRuntime().wrap(function
|
|
6207
|
-
while (1) switch (
|
|
6338
|
+
return _regeneratorRuntime().wrap(function _callee64$(_context64) {
|
|
6339
|
+
while (1) switch (_context64.prev = _context64.next) {
|
|
6208
6340
|
case 0:
|
|
6209
6341
|
this.registerDeviceTaskActions();
|
|
6210
6342
|
deviceTask = this.getDeviceTaskPlugin();
|
|
6211
|
-
|
|
6343
|
+
_context64.next = 4;
|
|
6212
6344
|
return this.getShortNumberOrDeviceId();
|
|
6213
6345
|
case 4:
|
|
6214
|
-
debugDeviceId =
|
|
6346
|
+
debugDeviceId = _context64.sent;
|
|
6215
6347
|
debugIdempotencyKey = this.buildCheckoutTaskIdempotencyKey(params.data);
|
|
6216
6348
|
if (deviceTask !== null && deviceTask !== void 0 && deviceTask.dispatch) {
|
|
6217
|
-
|
|
6349
|
+
_context64.next = 9;
|
|
6218
6350
|
break;
|
|
6219
6351
|
}
|
|
6220
6352
|
this.logError("".concat(params.title, ": deviceTask.dispatch \u4E0D\u53EF\u7528"));
|
|
6221
|
-
return
|
|
6353
|
+
return _context64.abrupt("return");
|
|
6222
6354
|
case 9:
|
|
6223
|
-
|
|
6224
|
-
|
|
6355
|
+
_context64.prev = 9;
|
|
6356
|
+
_context64.next = 12;
|
|
6225
6357
|
return deviceTask.dispatch({
|
|
6226
6358
|
action: 'sync_sales',
|
|
6227
6359
|
device_id: debugDeviceId,
|
|
@@ -6241,27 +6373,27 @@ var Server = /*#__PURE__*/function () {
|
|
|
6241
6373
|
source_id: ((_params$data2 = params.data) === null || _params$data2 === void 0 ? void 0 : _params$data2.order_id) || ((_params$data3 = params.data) === null || _params$data3 === void 0 ? void 0 : _params$data3.external_sale_number) || ((_params$data4 = params.data) === null || _params$data4 === void 0 ? void 0 : _params$data4.shop_order_number)
|
|
6242
6374
|
});
|
|
6243
6375
|
case 12:
|
|
6244
|
-
result =
|
|
6376
|
+
result = _context64.sent;
|
|
6245
6377
|
this.logInfo("".concat(params.title, ": sync_sales \u4EFB\u52A1\u5DF2\u6D3E\u53D1"), {
|
|
6246
6378
|
uuid: result === null || result === void 0 ? void 0 : result.uuid,
|
|
6247
6379
|
status: result === null || result === void 0 ? void 0 : result.status,
|
|
6248
6380
|
reused: result === null || result === void 0 ? void 0 : result.reused
|
|
6249
6381
|
});
|
|
6250
|
-
|
|
6382
|
+
_context64.next = 19;
|
|
6251
6383
|
break;
|
|
6252
6384
|
case 16:
|
|
6253
|
-
|
|
6254
|
-
|
|
6385
|
+
_context64.prev = 16;
|
|
6386
|
+
_context64.t0 = _context64["catch"](9);
|
|
6255
6387
|
this.logError("".concat(params.title, ": \u6D3E\u53D1 sync_sales \u4EFB\u52A1\u5931\u8D25"), {
|
|
6256
|
-
error:
|
|
6388
|
+
error: _context64.t0 instanceof Error ? _context64.t0.message : String(_context64.t0)
|
|
6257
6389
|
});
|
|
6258
6390
|
case 19:
|
|
6259
6391
|
case "end":
|
|
6260
|
-
return
|
|
6392
|
+
return _context64.stop();
|
|
6261
6393
|
}
|
|
6262
|
-
},
|
|
6394
|
+
}, _callee64, this, [[9, 16]]);
|
|
6263
6395
|
}));
|
|
6264
|
-
function dispatchCheckoutSyncTask(
|
|
6396
|
+
function dispatchCheckoutSyncTask(_x68) {
|
|
6265
6397
|
return _dispatchCheckoutSyncTask.apply(this, arguments);
|
|
6266
6398
|
}
|
|
6267
6399
|
return dispatchCheckoutSyncTask;
|
|
@@ -6269,26 +6401,26 @@ var Server = /*#__PURE__*/function () {
|
|
|
6269
6401
|
}, {
|
|
6270
6402
|
key: "dispatchPrintOtherReceiptTask",
|
|
6271
6403
|
value: function () {
|
|
6272
|
-
var _dispatchPrintOtherReceiptTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6404
|
+
var _dispatchPrintOtherReceiptTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee65(params) {
|
|
6273
6405
|
var deviceTask, _params$deviceId, _params$syncedOrder, _params$syncedOrder2, _params$syncedOrder3, printIdentity, deviceId;
|
|
6274
|
-
return _regeneratorRuntime().wrap(function
|
|
6275
|
-
while (1) switch (
|
|
6406
|
+
return _regeneratorRuntime().wrap(function _callee65$(_context65) {
|
|
6407
|
+
while (1) switch (_context65.prev = _context65.next) {
|
|
6276
6408
|
case 0:
|
|
6277
6409
|
deviceTask = this.getDeviceTaskPlugin();
|
|
6278
6410
|
if (deviceTask !== null && deviceTask !== void 0 && deviceTask.dispatch) {
|
|
6279
|
-
|
|
6411
|
+
_context65.next = 4;
|
|
6280
6412
|
break;
|
|
6281
6413
|
}
|
|
6282
6414
|
this.logWarning('dispatchPrintOtherReceiptTask: deviceTask.dispatch 不可用');
|
|
6283
|
-
return
|
|
6415
|
+
return _context65.abrupt("return");
|
|
6284
6416
|
case 4:
|
|
6285
|
-
|
|
6417
|
+
_context65.prev = 4;
|
|
6286
6418
|
printIdentity = this.getPrintOrderIdentity(params.syncedOrder);
|
|
6287
|
-
|
|
6419
|
+
_context65.next = 8;
|
|
6288
6420
|
return this.getShortNumberOrDeviceId();
|
|
6289
6421
|
case 8:
|
|
6290
|
-
deviceId =
|
|
6291
|
-
|
|
6422
|
+
deviceId = _context65.sent;
|
|
6423
|
+
_context65.next = 11;
|
|
6292
6424
|
return deviceTask.dispatch({
|
|
6293
6425
|
action: 'print_all',
|
|
6294
6426
|
device_id: (_params$deviceId = params.deviceId) !== null && _params$deviceId !== void 0 ? _params$deviceId : deviceId,
|
|
@@ -6317,21 +6449,21 @@ var Server = /*#__PURE__*/function () {
|
|
|
6317
6449
|
source_id: printIdentity
|
|
6318
6450
|
});
|
|
6319
6451
|
case 11:
|
|
6320
|
-
|
|
6452
|
+
_context65.next = 16;
|
|
6321
6453
|
break;
|
|
6322
6454
|
case 13:
|
|
6323
|
-
|
|
6324
|
-
|
|
6455
|
+
_context65.prev = 13;
|
|
6456
|
+
_context65.t0 = _context65["catch"](4);
|
|
6325
6457
|
this.logError('dispatchPrintOtherReceiptTask: 派发失败', {
|
|
6326
|
-
error:
|
|
6458
|
+
error: _context65.t0 instanceof Error ? _context65.t0.message : String(_context65.t0)
|
|
6327
6459
|
});
|
|
6328
6460
|
case 16:
|
|
6329
6461
|
case "end":
|
|
6330
|
-
return
|
|
6462
|
+
return _context65.stop();
|
|
6331
6463
|
}
|
|
6332
|
-
},
|
|
6464
|
+
}, _callee65, this, [[4, 13]]);
|
|
6333
6465
|
}));
|
|
6334
|
-
function dispatchPrintOtherReceiptTask(
|
|
6466
|
+
function dispatchPrintOtherReceiptTask(_x69) {
|
|
6335
6467
|
return _dispatchPrintOtherReceiptTask.apply(this, arguments);
|
|
6336
6468
|
}
|
|
6337
6469
|
return dispatchPrintOtherReceiptTask;
|
|
@@ -6351,34 +6483,35 @@ var Server = /*#__PURE__*/function () {
|
|
|
6351
6483
|
}, {
|
|
6352
6484
|
key: "dispatchLocalReceiptPrint",
|
|
6353
6485
|
value: function () {
|
|
6354
|
-
var _dispatchLocalReceiptPrint = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6486
|
+
var _dispatchLocalReceiptPrint = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee66(params) {
|
|
6355
6487
|
var _payment_info2;
|
|
6356
6488
|
var printableOrder;
|
|
6357
|
-
return _regeneratorRuntime().wrap(function
|
|
6358
|
-
while (1) switch (
|
|
6489
|
+
return _regeneratorRuntime().wrap(function _callee66$(_context66) {
|
|
6490
|
+
while (1) switch (_context66.prev = _context66.next) {
|
|
6359
6491
|
case 0:
|
|
6360
6492
|
if (!(params.requireFullyPaid && !this.isSalesOrderFullyPaid(params.order))) {
|
|
6361
|
-
|
|
6493
|
+
_context66.next = 2;
|
|
6362
6494
|
break;
|
|
6363
6495
|
}
|
|
6364
|
-
return
|
|
6496
|
+
return _context66.abrupt("return", {
|
|
6365
6497
|
printed: false,
|
|
6366
6498
|
order: params.order
|
|
6367
6499
|
});
|
|
6368
6500
|
case 2:
|
|
6369
|
-
|
|
6501
|
+
_context66.next = 4;
|
|
6370
6502
|
return this.withLocalSmallTicketData(params.order, {
|
|
6371
6503
|
requireFullyPaid: params.requireFullyPaid,
|
|
6372
6504
|
invoiceTemplateSettings: params.invoiceTemplateSettings,
|
|
6373
|
-
applyTemplateVisibility: true
|
|
6505
|
+
applyTemplateVisibility: true,
|
|
6506
|
+
refreshResourceReference: true
|
|
6374
6507
|
});
|
|
6375
6508
|
case 4:
|
|
6376
|
-
printableOrder =
|
|
6509
|
+
printableOrder = _context66.sent;
|
|
6377
6510
|
if (hasSmallTicketData((_payment_info2 = printableOrder.payment_info) === null || _payment_info2 === void 0 ? void 0 : _payment_info2.small_ticket_data)) {
|
|
6378
|
-
|
|
6511
|
+
_context66.next = 7;
|
|
6379
6512
|
break;
|
|
6380
6513
|
}
|
|
6381
|
-
return
|
|
6514
|
+
return _context66.abrupt("return", {
|
|
6382
6515
|
printed: false,
|
|
6383
6516
|
order: printableOrder
|
|
6384
6517
|
});
|
|
@@ -6388,7 +6521,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6388
6521
|
printableOrder: printableOrder,
|
|
6389
6522
|
response: params.response
|
|
6390
6523
|
});
|
|
6391
|
-
|
|
6524
|
+
_context66.next = 10;
|
|
6392
6525
|
return this.dispatchPrintOtherReceiptTask({
|
|
6393
6526
|
checkoutData: params.checkoutData,
|
|
6394
6527
|
syncedOrder: printableOrder,
|
|
@@ -6399,17 +6532,17 @@ var Server = /*#__PURE__*/function () {
|
|
|
6399
6532
|
invoiceTemplateSettings: params.invoiceTemplateSettings
|
|
6400
6533
|
});
|
|
6401
6534
|
case 10:
|
|
6402
|
-
return
|
|
6535
|
+
return _context66.abrupt("return", {
|
|
6403
6536
|
printed: true,
|
|
6404
6537
|
order: requiresInvoiceDataFiltering(params.invoiceTemplateSettings) ? params.order : printableOrder
|
|
6405
6538
|
});
|
|
6406
6539
|
case 11:
|
|
6407
6540
|
case "end":
|
|
6408
|
-
return
|
|
6541
|
+
return _context66.stop();
|
|
6409
6542
|
}
|
|
6410
|
-
},
|
|
6543
|
+
}, _callee66, this);
|
|
6411
6544
|
}));
|
|
6412
|
-
function dispatchLocalReceiptPrint(
|
|
6545
|
+
function dispatchLocalReceiptPrint(_x70) {
|
|
6413
6546
|
return _dispatchLocalReceiptPrint.apply(this, arguments);
|
|
6414
6547
|
}
|
|
6415
6548
|
return dispatchLocalReceiptPrint;
|
|
@@ -6436,15 +6569,15 @@ var Server = /*#__PURE__*/function () {
|
|
|
6436
6569
|
}, {
|
|
6437
6570
|
key: "mergeLocalPrintOrderInput",
|
|
6438
6571
|
value: function mergeLocalPrintOrderInput(localOrder, inputOrder) {
|
|
6439
|
-
var
|
|
6440
|
-
var definedInput = Object.fromEntries(Object.entries(inputOrder || {}).filter(function (
|
|
6441
|
-
var
|
|
6442
|
-
value =
|
|
6572
|
+
var _ref73, _localOrder$order_id, _ref74, _external_sale_number4;
|
|
6573
|
+
var definedInput = Object.fromEntries(Object.entries(inputOrder || {}).filter(function (_ref71) {
|
|
6574
|
+
var _ref72 = _slicedToArray(_ref71, 2),
|
|
6575
|
+
value = _ref72[1];
|
|
6443
6576
|
return value !== undefined;
|
|
6444
6577
|
}));
|
|
6445
6578
|
return _objectSpread(_objectSpread(_objectSpread({}, localOrder), definedInput), {}, {
|
|
6446
|
-
order_id: (
|
|
6447
|
-
external_sale_number: (
|
|
6579
|
+
order_id: (_ref73 = (_localOrder$order_id = localOrder.order_id) !== null && _localOrder$order_id !== void 0 ? _localOrder$order_id : definedInput.order_id) !== null && _ref73 !== void 0 ? _ref73 : definedInput.orderId,
|
|
6580
|
+
external_sale_number: (_ref74 = (_external_sale_number4 = localOrder.external_sale_number) !== null && _external_sale_number4 !== void 0 ? _external_sale_number4 : definedInput.external_sale_number) !== null && _ref74 !== void 0 ? _ref74 : definedInput.externalSaleNumber
|
|
6448
6581
|
});
|
|
6449
6582
|
}
|
|
6450
6583
|
}, {
|
|
@@ -6468,57 +6601,57 @@ var Server = /*#__PURE__*/function () {
|
|
|
6468
6601
|
}, {
|
|
6469
6602
|
key: "syncMachinecodeRedeemStatusToLocalOrder",
|
|
6470
6603
|
value: function () {
|
|
6471
|
-
var _syncMachinecodeRedeemStatusToLocalOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6604
|
+
var _syncMachinecodeRedeemStatusToLocalOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee67(data, ids, status) {
|
|
6472
6605
|
var _this$order5, _data$order_id2;
|
|
6473
6606
|
var title, lookup, localOrder, orderId, voucherIdSet, vouchers, hasUpdatedVoucher, nextVouchers;
|
|
6474
|
-
return _regeneratorRuntime().wrap(function
|
|
6475
|
-
while (1) switch (
|
|
6607
|
+
return _regeneratorRuntime().wrap(function _callee67$(_context67) {
|
|
6608
|
+
while (1) switch (_context67.prev = _context67.next) {
|
|
6476
6609
|
case 0:
|
|
6477
6610
|
title = 'handleMachinecodeBatchMetadata';
|
|
6478
6611
|
lookup = this.resolveMachinecodeBatchMetadataLookup(data);
|
|
6479
6612
|
if (!(lookup === undefined)) {
|
|
6480
|
-
|
|
6613
|
+
_context67.next = 5;
|
|
6481
6614
|
break;
|
|
6482
6615
|
}
|
|
6483
6616
|
this.logWarning("".concat(title, ": order lookup \u7F3A\u5931\uFF0C\u8DF3\u8FC7\u672C\u5730\u8BA2\u5355\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
|
|
6484
6617
|
batchSize: ids.length,
|
|
6485
6618
|
status: status
|
|
6486
6619
|
});
|
|
6487
|
-
return
|
|
6620
|
+
return _context67.abrupt("return");
|
|
6488
6621
|
case 5:
|
|
6489
6622
|
if ((_this$order5 = this.order) !== null && _this$order5 !== void 0 && _this$order5.getLocalOrderByLookup) {
|
|
6490
|
-
|
|
6623
|
+
_context67.next = 8;
|
|
6491
6624
|
break;
|
|
6492
6625
|
}
|
|
6493
6626
|
this.logWarning("".concat(title, ": Order \u6A21\u5757\u672A\u6CE8\u518C\uFF0C\u8DF3\u8FC7\u672C\u5730\u8BA2\u5355\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
|
|
6494
6627
|
lookup: lookup,
|
|
6495
6628
|
status: status
|
|
6496
6629
|
});
|
|
6497
|
-
return
|
|
6630
|
+
return _context67.abrupt("return");
|
|
6498
6631
|
case 8:
|
|
6499
|
-
|
|
6632
|
+
_context67.next = 10;
|
|
6500
6633
|
return this.order.getLocalOrderByLookup(lookup);
|
|
6501
6634
|
case 10:
|
|
6502
|
-
localOrder =
|
|
6635
|
+
localOrder = _context67.sent;
|
|
6503
6636
|
orderId = (_data$order_id2 = data === null || data === void 0 ? void 0 : data.order_id) !== null && _data$order_id2 !== void 0 ? _data$order_id2 : data === null || data === void 0 ? void 0 : data.orderId;
|
|
6504
6637
|
if (!(!localOrder && orderId !== undefined && orderId !== null && orderId !== '' && String(orderId) !== String(lookup))) {
|
|
6505
|
-
|
|
6638
|
+
_context67.next = 16;
|
|
6506
6639
|
break;
|
|
6507
6640
|
}
|
|
6508
|
-
|
|
6641
|
+
_context67.next = 15;
|
|
6509
6642
|
return this.order.getLocalOrderByLookup(orderId);
|
|
6510
6643
|
case 15:
|
|
6511
|
-
localOrder =
|
|
6644
|
+
localOrder = _context67.sent;
|
|
6512
6645
|
case 16:
|
|
6513
6646
|
if (localOrder) {
|
|
6514
|
-
|
|
6647
|
+
_context67.next = 19;
|
|
6515
6648
|
break;
|
|
6516
6649
|
}
|
|
6517
6650
|
this.logWarning("".concat(title, ": \u672C\u5730\u8BA2\u5355\u4E0D\u5B58\u5728\uFF0C\u8DF3\u8FC7\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
|
|
6518
6651
|
lookup: lookup,
|
|
6519
6652
|
status: status
|
|
6520
6653
|
});
|
|
6521
|
-
return
|
|
6654
|
+
return _context67.abrupt("return");
|
|
6522
6655
|
case 19:
|
|
6523
6656
|
voucherIdSet = new Set(ids.filter(function (id) {
|
|
6524
6657
|
return id !== undefined && id !== null && id !== '';
|
|
@@ -6526,14 +6659,14 @@ var Server = /*#__PURE__*/function () {
|
|
|
6526
6659
|
return String(id);
|
|
6527
6660
|
}));
|
|
6528
6661
|
if (!(voucherIdSet.size === 0)) {
|
|
6529
|
-
|
|
6662
|
+
_context67.next = 23;
|
|
6530
6663
|
break;
|
|
6531
6664
|
}
|
|
6532
6665
|
this.logWarning("".concat(title, ": voucher ids \u7F3A\u5931\uFF0C\u8DF3\u8FC7\u672C\u5730\u8BA2\u5355\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
|
|
6533
6666
|
lookup: lookup,
|
|
6534
6667
|
status: status
|
|
6535
6668
|
});
|
|
6536
|
-
return
|
|
6669
|
+
return _context67.abrupt("return");
|
|
6537
6670
|
case 23:
|
|
6538
6671
|
vouchers = Array.isArray(localOrder.vouchers) ? localOrder.vouchers : [];
|
|
6539
6672
|
hasUpdatedVoucher = false;
|
|
@@ -6547,7 +6680,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6547
6680
|
});
|
|
6548
6681
|
});
|
|
6549
6682
|
if (hasUpdatedVoucher) {
|
|
6550
|
-
|
|
6683
|
+
_context67.next = 29;
|
|
6551
6684
|
break;
|
|
6552
6685
|
}
|
|
6553
6686
|
this.logWarning("".concat(title, ": \u672C\u5730\u8BA2\u5355\u672A\u547D\u4E2D\u4EFB\u4F55 voucher\uFF0C\u8DF3\u8FC7\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
|
|
@@ -6555,13 +6688,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
6555
6688
|
voucher_ids: Array.from(voucherIdSet),
|
|
6556
6689
|
status: status
|
|
6557
6690
|
});
|
|
6558
|
-
return
|
|
6691
|
+
return _context67.abrupt("return");
|
|
6559
6692
|
case 29:
|
|
6560
6693
|
if (!(typeof this.order.overwriteExistingOrder === 'function')) {
|
|
6561
|
-
|
|
6694
|
+
_context67.next = 34;
|
|
6562
6695
|
break;
|
|
6563
6696
|
}
|
|
6564
|
-
|
|
6697
|
+
_context67.next = 32;
|
|
6565
6698
|
return this.order.overwriteExistingOrder(_objectSpread(_objectSpread({}, localOrder), {}, {
|
|
6566
6699
|
vouchers: nextVouchers
|
|
6567
6700
|
}));
|
|
@@ -6571,13 +6704,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
6571
6704
|
updatedCount: voucherIdSet.size,
|
|
6572
6705
|
status: status
|
|
6573
6706
|
});
|
|
6574
|
-
return
|
|
6707
|
+
return _context67.abrupt("return");
|
|
6575
6708
|
case 34:
|
|
6576
6709
|
if (!(data !== null && data !== void 0 && data.external_sale_number && typeof this.order.markOrderSyncedByExternalSaleNumber === 'function')) {
|
|
6577
|
-
|
|
6710
|
+
_context67.next = 39;
|
|
6578
6711
|
break;
|
|
6579
6712
|
}
|
|
6580
|
-
|
|
6713
|
+
_context67.next = 37;
|
|
6581
6714
|
return this.order.markOrderSyncedByExternalSaleNumber({
|
|
6582
6715
|
externalSaleNumber: data.external_sale_number,
|
|
6583
6716
|
patch: {
|
|
@@ -6590,7 +6723,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6590
6723
|
updatedCount: voucherIdSet.size,
|
|
6591
6724
|
status: status
|
|
6592
6725
|
});
|
|
6593
|
-
return
|
|
6726
|
+
return _context67.abrupt("return");
|
|
6594
6727
|
case 39:
|
|
6595
6728
|
this.logWarning("".concat(title, ": Order \u6A21\u5757\u4E0D\u652F\u6301\u672C\u5730\u8BA2\u5355\u8986\u76D6\uFF0C\u8DF3\u8FC7\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
|
|
6596
6729
|
lookup: lookup,
|
|
@@ -6598,11 +6731,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
6598
6731
|
});
|
|
6599
6732
|
case 40:
|
|
6600
6733
|
case "end":
|
|
6601
|
-
return
|
|
6734
|
+
return _context67.stop();
|
|
6602
6735
|
}
|
|
6603
|
-
},
|
|
6736
|
+
}, _callee67, this);
|
|
6604
6737
|
}));
|
|
6605
|
-
function syncMachinecodeRedeemStatusToLocalOrder(
|
|
6738
|
+
function syncMachinecodeRedeemStatusToLocalOrder(_x71, _x72, _x73) {
|
|
6606
6739
|
return _syncMachinecodeRedeemStatusToLocalOrder.apply(this, arguments);
|
|
6607
6740
|
}
|
|
6608
6741
|
return syncMachinecodeRedeemStatusToLocalOrder;
|
|
@@ -6610,30 +6743,30 @@ var Server = /*#__PURE__*/function () {
|
|
|
6610
6743
|
}, {
|
|
6611
6744
|
key: "handleOrderCheckoutSubmit",
|
|
6612
6745
|
value: function () {
|
|
6613
|
-
var _handleOrderCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6746
|
+
var _handleOrderCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee68(params) {
|
|
6614
6747
|
var _params$data5, _params$data6, _this$order6, _this$order6$getLocal;
|
|
6615
6748
|
var backendPath, title, lookup, localOrder, extractedInvoice, extractedTemplateSettings, data, invoiceLayoutConfig, invoiceTemplateSettings, receiptAutoPrintPaymentStatuses, normalizedData, numberedData, checkoutData, pendingResult, pendingOrder;
|
|
6616
|
-
return _regeneratorRuntime().wrap(function
|
|
6617
|
-
while (1) switch (
|
|
6749
|
+
return _regeneratorRuntime().wrap(function _callee68$(_context68) {
|
|
6750
|
+
while (1) switch (_context68.prev = _context68.next) {
|
|
6618
6751
|
case 0:
|
|
6619
6752
|
backendPath = params.backendPath, title = params.title;
|
|
6620
6753
|
lookup = ((_params$data5 = params.data) === null || _params$data5 === void 0 ? void 0 : _params$data5.order_id) || ((_params$data6 = params.data) === null || _params$data6 === void 0 ? void 0 : _params$data6.external_sale_number);
|
|
6621
|
-
|
|
6622
|
-
if (!
|
|
6623
|
-
|
|
6754
|
+
_context68.t0 = lookup;
|
|
6755
|
+
if (!_context68.t0) {
|
|
6756
|
+
_context68.next = 7;
|
|
6624
6757
|
break;
|
|
6625
6758
|
}
|
|
6626
|
-
|
|
6759
|
+
_context68.next = 6;
|
|
6627
6760
|
return (_this$order6 = this.order) === null || _this$order6 === void 0 || (_this$order6$getLocal = _this$order6.getLocalOrderByLookup) === null || _this$order6$getLocal === void 0 ? void 0 : _this$order6$getLocal.call(_this$order6, lookup);
|
|
6628
6761
|
case 6:
|
|
6629
|
-
|
|
6762
|
+
_context68.t0 = _context68.sent;
|
|
6630
6763
|
case 7:
|
|
6631
|
-
localOrder =
|
|
6764
|
+
localOrder = _context68.t0;
|
|
6632
6765
|
if (!(requiresLocalPaymentRefresh(params.data) || requiresLocalPaymentRefresh(localOrder))) {
|
|
6633
|
-
|
|
6766
|
+
_context68.next = 10;
|
|
6634
6767
|
break;
|
|
6635
6768
|
}
|
|
6636
|
-
return
|
|
6769
|
+
return _context68.abrupt("return", {
|
|
6637
6770
|
code: 409,
|
|
6638
6771
|
status: false,
|
|
6639
6772
|
message: PAYMENT_REFRESH_MESSAGE,
|
|
@@ -6657,10 +6790,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
6657
6790
|
order_number: data === null || data === void 0 ? void 0 : data.order_number
|
|
6658
6791
|
});
|
|
6659
6792
|
if (!(data !== null && data !== void 0 && data.sync_mode || data !== null && data !== void 0 && data.syncMode)) {
|
|
6660
|
-
|
|
6793
|
+
_context68.next = 19;
|
|
6661
6794
|
break;
|
|
6662
6795
|
}
|
|
6663
|
-
return
|
|
6796
|
+
return _context68.abrupt("return", this.handleSyncCheckoutSubmit({
|
|
6664
6797
|
backendPath: backendPath,
|
|
6665
6798
|
data: data,
|
|
6666
6799
|
title: title,
|
|
@@ -6669,16 +6802,16 @@ var Server = /*#__PURE__*/function () {
|
|
|
6669
6802
|
receiptAutoPrintPaymentStatuses: receiptAutoPrintPaymentStatuses
|
|
6670
6803
|
}));
|
|
6671
6804
|
case 19:
|
|
6672
|
-
|
|
6805
|
+
_context68.next = 21;
|
|
6673
6806
|
return this.normalizeCheckoutSubmitData(data, title);
|
|
6674
6807
|
case 21:
|
|
6675
|
-
normalizedData =
|
|
6676
|
-
|
|
6808
|
+
normalizedData = _context68.sent;
|
|
6809
|
+
_context68.next = 24;
|
|
6677
6810
|
return this.ensureCheckoutOrderNumbers(normalizedData, title);
|
|
6678
6811
|
case 24:
|
|
6679
|
-
numberedData =
|
|
6812
|
+
numberedData = _context68.sent;
|
|
6680
6813
|
checkoutData = this.normalizeCheckoutCollections(stripOsPrivatePayloadFields(this.applyCheckoutFulfillmentBuzzer(numberedData, title)));
|
|
6681
|
-
|
|
6814
|
+
_context68.next = 28;
|
|
6682
6815
|
return this.handlePendingSyncCheckoutOrder({
|
|
6683
6816
|
backendPath: backendPath,
|
|
6684
6817
|
data: checkoutData,
|
|
@@ -6687,18 +6820,18 @@ var Server = /*#__PURE__*/function () {
|
|
|
6687
6820
|
invoiceTemplateSettings: invoiceTemplateSettings
|
|
6688
6821
|
});
|
|
6689
6822
|
case 28:
|
|
6690
|
-
pendingResult =
|
|
6823
|
+
pendingResult = _context68.sent;
|
|
6691
6824
|
if (!((pendingResult === null || pendingResult === void 0 ? void 0 : pendingResult.status) === true)) {
|
|
6692
|
-
|
|
6825
|
+
_context68.next = 43;
|
|
6693
6826
|
break;
|
|
6694
6827
|
}
|
|
6695
6828
|
pendingOrder = pendingResult.data;
|
|
6696
6829
|
if (!(pendingOrder && this.shouldBuildSmallTicketData(checkoutData, invoiceTemplateSettings) && this.shouldAutoPrintReceiptForPaymentStatus(pendingOrder, receiptAutoPrintPaymentStatuses) && this.shouldAutoPrintCheckoutReceipt())) {
|
|
6697
|
-
|
|
6830
|
+
_context68.next = 41;
|
|
6698
6831
|
break;
|
|
6699
6832
|
}
|
|
6700
|
-
|
|
6701
|
-
|
|
6833
|
+
_context68.prev = 32;
|
|
6834
|
+
_context68.next = 35;
|
|
6702
6835
|
return this.dispatchLocalReceiptPrint({
|
|
6703
6836
|
checkoutData: checkoutData,
|
|
6704
6837
|
order: pendingOrder,
|
|
@@ -6708,19 +6841,19 @@ var Server = /*#__PURE__*/function () {
|
|
|
6708
6841
|
invoiceTemplateSettings: invoiceTemplateSettings
|
|
6709
6842
|
});
|
|
6710
6843
|
case 35:
|
|
6711
|
-
|
|
6844
|
+
_context68.next = 41;
|
|
6712
6845
|
break;
|
|
6713
6846
|
case 37:
|
|
6714
|
-
|
|
6715
|
-
|
|
6847
|
+
_context68.prev = 37;
|
|
6848
|
+
_context68.t1 = _context68["catch"](32);
|
|
6716
6849
|
// The sale is already persisted. A failed receipt must not cancel its
|
|
6717
6850
|
// sync task or send an unfiltered fallback to the printer.
|
|
6718
|
-
pendingResult.receipt_print_error = this.getUnknownErrorMessage(
|
|
6851
|
+
pendingResult.receipt_print_error = this.getUnknownErrorMessage(_context68.t1);
|
|
6719
6852
|
this.logError("".concat(title, ": \u5C0F\u7968\u751F\u6210\u5931\u8D25\uFF0C\u8BA2\u5355\u4ECD\u7EE7\u7EED\u540C\u6B65"), {
|
|
6720
6853
|
error: pendingResult.receipt_print_error
|
|
6721
6854
|
});
|
|
6722
6855
|
case 41:
|
|
6723
|
-
|
|
6856
|
+
_context68.next = 43;
|
|
6724
6857
|
return this.dispatchCheckoutSyncTask({
|
|
6725
6858
|
backendPath: backendPath,
|
|
6726
6859
|
data: checkoutData,
|
|
@@ -6730,23 +6863,23 @@ var Server = /*#__PURE__*/function () {
|
|
|
6730
6863
|
});
|
|
6731
6864
|
case 43:
|
|
6732
6865
|
if (pendingResult.data.order_id) {
|
|
6733
|
-
|
|
6866
|
+
_context68.next = 45;
|
|
6734
6867
|
break;
|
|
6735
6868
|
}
|
|
6736
|
-
return
|
|
6869
|
+
return _context68.abrupt("return", _objectSpread(_objectSpread({}, pendingResult), {}, {
|
|
6737
6870
|
data: _objectSpread(_objectSpread({}, pendingResult.data), {}, {
|
|
6738
6871
|
order_id: pendingResult.data.external_sale_number
|
|
6739
6872
|
})
|
|
6740
6873
|
}));
|
|
6741
6874
|
case 45:
|
|
6742
|
-
return
|
|
6875
|
+
return _context68.abrupt("return", pendingResult);
|
|
6743
6876
|
case 46:
|
|
6744
6877
|
case "end":
|
|
6745
|
-
return
|
|
6878
|
+
return _context68.stop();
|
|
6746
6879
|
}
|
|
6747
|
-
},
|
|
6880
|
+
}, _callee68, this, [[32, 37]]);
|
|
6748
6881
|
}));
|
|
6749
|
-
function handleOrderCheckoutSubmit(
|
|
6882
|
+
function handleOrderCheckoutSubmit(_x74) {
|
|
6750
6883
|
return _handleOrderCheckoutSubmit.apply(this, arguments);
|
|
6751
6884
|
}
|
|
6752
6885
|
return handleOrderCheckoutSubmit;
|
|
@@ -6754,27 +6887,27 @@ var Server = /*#__PURE__*/function () {
|
|
|
6754
6887
|
}, {
|
|
6755
6888
|
key: "handleSyncCheckoutSubmit",
|
|
6756
6889
|
value: function () {
|
|
6757
|
-
var _handleSyncCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6758
|
-
var _this$
|
|
6890
|
+
var _handleSyncCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee69(params) {
|
|
6891
|
+
var _this$app18;
|
|
6759
6892
|
var backendPath, data, title, invoiceLayoutConfig, invoiceTemplateSettings, receiptAutoPrintPaymentStatuses, syncResult, _normalized$data, normalized, response, syncedOrder, backendError, _normalized$data2, _normalized, message;
|
|
6760
|
-
return _regeneratorRuntime().wrap(function
|
|
6761
|
-
while (1) switch (
|
|
6893
|
+
return _regeneratorRuntime().wrap(function _callee69$(_context69) {
|
|
6894
|
+
while (1) switch (_context69.prev = _context69.next) {
|
|
6762
6895
|
case 0:
|
|
6763
6896
|
backendPath = params.backendPath, data = params.data, title = params.title, invoiceLayoutConfig = params.invoiceLayoutConfig, invoiceTemplateSettings = params.invoiceTemplateSettings, receiptAutoPrintPaymentStatuses = params.receiptAutoPrintPaymentStatuses;
|
|
6764
|
-
if ((_this$
|
|
6765
|
-
|
|
6897
|
+
if ((_this$app18 = this.app) !== null && _this$app18 !== void 0 && (_this$app18 = _this$app18.request) !== null && _this$app18 !== void 0 && _this$app18.post) {
|
|
6898
|
+
_context69.next = 4;
|
|
6766
6899
|
break;
|
|
6767
6900
|
}
|
|
6768
6901
|
this.logError("".concat(title, ": sync checkout app.request \u4E0D\u53EF\u7528"));
|
|
6769
|
-
return
|
|
6902
|
+
return _context69.abrupt("return", {
|
|
6770
6903
|
code: 500,
|
|
6771
6904
|
status: false,
|
|
6772
6905
|
message: 'app.request 不可用',
|
|
6773
6906
|
data: null
|
|
6774
6907
|
});
|
|
6775
6908
|
case 4:
|
|
6776
|
-
|
|
6777
|
-
|
|
6909
|
+
_context69.prev = 4;
|
|
6910
|
+
_context69.next = 7;
|
|
6778
6911
|
return this.runCheckoutSync({
|
|
6779
6912
|
backendPath: backendPath,
|
|
6780
6913
|
data: data,
|
|
@@ -6784,13 +6917,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
6784
6917
|
invoiceTemplateSettings: invoiceTemplateSettings
|
|
6785
6918
|
});
|
|
6786
6919
|
case 7:
|
|
6787
|
-
syncResult =
|
|
6920
|
+
syncResult = _context69.sent;
|
|
6788
6921
|
if (!syncResult.rejected) {
|
|
6789
|
-
|
|
6922
|
+
_context69.next = 11;
|
|
6790
6923
|
break;
|
|
6791
6924
|
}
|
|
6792
6925
|
normalized = this.normalizeCheckoutResponse(syncResult.errorResponse);
|
|
6793
|
-
return
|
|
6926
|
+
return _context69.abrupt("return", _objectSpread(_objectSpread({}, normalized), {}, {
|
|
6794
6927
|
status: false,
|
|
6795
6928
|
message: syncResult.message || (normalized === null || normalized === void 0 ? void 0 : normalized.message) || '后端明确拒绝 checkout',
|
|
6796
6929
|
data: (_normalized$data = normalized === null || normalized === void 0 ? void 0 : normalized.data) !== null && _normalized$data !== void 0 ? _normalized$data : null
|
|
@@ -6799,11 +6932,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
6799
6932
|
response = this.withSyncedOrderIdInCheckoutResponse(syncResult.normalizedResponse, syncResult.syncedOrder);
|
|
6800
6933
|
syncedOrder = syncResult.syncedOrder;
|
|
6801
6934
|
if (!(syncedOrder && this.shouldBuildSmallTicketData(syncResult.checkoutData, invoiceTemplateSettings) && this.shouldAutoPrintReceiptForPaymentStatus(syncedOrder, receiptAutoPrintPaymentStatuses) && (receiptAutoPrintPaymentStatuses === undefined || this.shouldAutoPrintCheckoutReceipt()))) {
|
|
6802
|
-
|
|
6935
|
+
_context69.next = 23;
|
|
6803
6936
|
break;
|
|
6804
6937
|
}
|
|
6805
|
-
|
|
6806
|
-
|
|
6938
|
+
_context69.prev = 14;
|
|
6939
|
+
_context69.next = 17;
|
|
6807
6940
|
return this.dispatchLocalReceiptPrint({
|
|
6808
6941
|
checkoutData: syncResult.checkoutData,
|
|
6809
6942
|
order: syncedOrder,
|
|
@@ -6813,41 +6946,41 @@ var Server = /*#__PURE__*/function () {
|
|
|
6813
6946
|
invoiceTemplateSettings: invoiceTemplateSettings
|
|
6814
6947
|
});
|
|
6815
6948
|
case 17:
|
|
6816
|
-
|
|
6949
|
+
_context69.next = 23;
|
|
6817
6950
|
break;
|
|
6818
6951
|
case 19:
|
|
6819
|
-
|
|
6820
|
-
|
|
6952
|
+
_context69.prev = 19;
|
|
6953
|
+
_context69.t0 = _context69["catch"](14);
|
|
6821
6954
|
// Checkout already succeeded remotely; report the receipt failure
|
|
6822
6955
|
// separately instead of implying that payment/order creation failed.
|
|
6823
|
-
response.receipt_print_error = this.getUnknownErrorMessage(
|
|
6956
|
+
response.receipt_print_error = this.getUnknownErrorMessage(_context69.t0);
|
|
6824
6957
|
this.logError("".concat(title, ": \u5C0F\u7968\u751F\u6210\u5931\u8D25\uFF0C\u8BA2\u5355\u5DF2\u540C\u6B65"), {
|
|
6825
6958
|
error: response.receipt_print_error
|
|
6826
6959
|
});
|
|
6827
6960
|
case 23:
|
|
6828
|
-
return
|
|
6961
|
+
return _context69.abrupt("return", response);
|
|
6829
6962
|
case 26:
|
|
6830
|
-
|
|
6831
|
-
|
|
6832
|
-
backendError = this.extractBackendErrorResponse(
|
|
6963
|
+
_context69.prev = 26;
|
|
6964
|
+
_context69.t1 = _context69["catch"](4);
|
|
6965
|
+
backendError = this.extractBackendErrorResponse(_context69.t1);
|
|
6833
6966
|
if (!backendError) {
|
|
6834
|
-
|
|
6967
|
+
_context69.next = 32;
|
|
6835
6968
|
break;
|
|
6836
6969
|
}
|
|
6837
6970
|
_normalized = this.normalizeCheckoutResponse(backendError);
|
|
6838
|
-
return
|
|
6971
|
+
return _context69.abrupt("return", _objectSpread(_objectSpread({}, _normalized), {}, {
|
|
6839
6972
|
status: false,
|
|
6840
6973
|
message: (backendError === null || backendError === void 0 ? void 0 : backendError.message) || (_normalized === null || _normalized === void 0 ? void 0 : _normalized.message) || '后端明确拒绝 checkout',
|
|
6841
6974
|
data: (_normalized$data2 = _normalized === null || _normalized === void 0 ? void 0 : _normalized.data) !== null && _normalized$data2 !== void 0 ? _normalized$data2 : null
|
|
6842
6975
|
}));
|
|
6843
6976
|
case 32:
|
|
6844
|
-
message = this.getUnknownErrorMessage(
|
|
6977
|
+
message = this.getUnknownErrorMessage(_context69.t1);
|
|
6845
6978
|
this.logError("".concat(title, ": sync checkout \u8BF7\u6C42\u672A\u660E\u786E\u6210\u529F"), {
|
|
6846
6979
|
backendPath: backendPath,
|
|
6847
6980
|
error: message,
|
|
6848
|
-
error_detail: this.normalizeUnknownError(
|
|
6981
|
+
error_detail: this.normalizeUnknownError(_context69.t1)
|
|
6849
6982
|
});
|
|
6850
|
-
return
|
|
6983
|
+
return _context69.abrupt("return", {
|
|
6851
6984
|
code: 500,
|
|
6852
6985
|
status: false,
|
|
6853
6986
|
message: message,
|
|
@@ -6855,11 +6988,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
6855
6988
|
});
|
|
6856
6989
|
case 35:
|
|
6857
6990
|
case "end":
|
|
6858
|
-
return
|
|
6991
|
+
return _context69.stop();
|
|
6859
6992
|
}
|
|
6860
|
-
},
|
|
6993
|
+
}, _callee69, this, [[4, 26], [14, 19]]);
|
|
6861
6994
|
}));
|
|
6862
|
-
function handleSyncCheckoutSubmit(
|
|
6995
|
+
function handleSyncCheckoutSubmit(_x75) {
|
|
6863
6996
|
return _handleSyncCheckoutSubmit.apply(this, arguments);
|
|
6864
6997
|
}
|
|
6865
6998
|
return handleSyncCheckoutSubmit;
|
|
@@ -6867,10 +7000,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
6867
7000
|
}, {
|
|
6868
7001
|
key: "handleOrderDraftSubmit",
|
|
6869
7002
|
value: function () {
|
|
6870
|
-
var _handleOrderDraftSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7003
|
+
var _handleOrderDraftSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee70(params) {
|
|
6871
7004
|
var title, extractedInvoice, _this$extractInvoiceT, data, normalizedData, createdAt, draftOrder, _draftOrder$summary, _draftOrder$summary2, _draftOrder$summary3, errorMessage;
|
|
6872
|
-
return _regeneratorRuntime().wrap(function
|
|
6873
|
-
while (1) switch (
|
|
7005
|
+
return _regeneratorRuntime().wrap(function _callee70$(_context70) {
|
|
7006
|
+
while (1) switch (_context70.prev = _context70.next) {
|
|
6874
7007
|
case 0:
|
|
6875
7008
|
title = params.title;
|
|
6876
7009
|
extractedInvoice = this.extractInvoiceLayoutConfig(params.data, {
|
|
@@ -6884,10 +7017,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
6884
7017
|
external_sale_number: data === null || data === void 0 ? void 0 : data.external_sale_number,
|
|
6885
7018
|
order_number: data === null || data === void 0 ? void 0 : data.order_number
|
|
6886
7019
|
});
|
|
6887
|
-
|
|
7020
|
+
_context70.next = 6;
|
|
6888
7021
|
return this.normalizeCheckoutSubmitData(data, title);
|
|
6889
7022
|
case 6:
|
|
6890
|
-
normalizedData =
|
|
7023
|
+
normalizedData = _context70.sent;
|
|
6891
7024
|
createdAt = normalizedData.created_at || normalizedData.create_date || dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
6892
7025
|
draftOrder = _objectSpread(_objectSpread({}, normalizedData), {}, {
|
|
6893
7026
|
external_sale_number: normalizedData.external_sale_number || "LOCAL_DRAFT_".concat(Date.now(), "_").concat(Math.random().toString(36).slice(2, 10)),
|
|
@@ -6897,26 +7030,26 @@ var Server = /*#__PURE__*/function () {
|
|
|
6897
7030
|
is_draft_order: 1
|
|
6898
7031
|
});
|
|
6899
7032
|
if (!(!this.order || typeof this.order.upsertLocalDraftOrders !== 'function')) {
|
|
6900
|
-
|
|
7033
|
+
_context70.next = 12;
|
|
6901
7034
|
break;
|
|
6902
7035
|
}
|
|
6903
7036
|
this.logError("".concat(title, ": Order \u6A21\u5757\u4E0D\u652F\u6301\u672C\u5730\u8349\u7A3F\u5199\u5165"));
|
|
6904
|
-
return
|
|
7037
|
+
return _context70.abrupt("return", {
|
|
6905
7038
|
code: 500,
|
|
6906
7039
|
status: false,
|
|
6907
7040
|
message: 'Order 模块不支持本地草稿写入',
|
|
6908
7041
|
data: null
|
|
6909
7042
|
});
|
|
6910
7043
|
case 12:
|
|
6911
|
-
|
|
6912
|
-
|
|
7044
|
+
_context70.prev = 12;
|
|
7045
|
+
_context70.next = 15;
|
|
6913
7046
|
return this.order.upsertLocalDraftOrders([draftOrder]);
|
|
6914
7047
|
case 15:
|
|
6915
7048
|
this.logInfo("".concat(title, ": \u8349\u7A3F\u8BA2\u5355\u5DF2\u5199\u5165\u672C\u5730"), {
|
|
6916
7049
|
order_id: draftOrder.order_id,
|
|
6917
7050
|
external_sale_number: draftOrder.external_sale_number
|
|
6918
7051
|
});
|
|
6919
|
-
return
|
|
7052
|
+
return _context70.abrupt("return", {
|
|
6920
7053
|
code: 200,
|
|
6921
7054
|
status: true,
|
|
6922
7055
|
message: '',
|
|
@@ -6928,13 +7061,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
6928
7061
|
})
|
|
6929
7062
|
});
|
|
6930
7063
|
case 19:
|
|
6931
|
-
|
|
6932
|
-
|
|
6933
|
-
errorMessage =
|
|
7064
|
+
_context70.prev = 19;
|
|
7065
|
+
_context70.t0 = _context70["catch"](12);
|
|
7066
|
+
errorMessage = _context70.t0 instanceof Error ? _context70.t0.message : String(_context70.t0);
|
|
6934
7067
|
this.logError("".concat(title, ": \u5199\u5165\u672C\u5730\u8349\u7A3F\u8BA2\u5355\u5931\u8D25"), {
|
|
6935
7068
|
error: errorMessage
|
|
6936
7069
|
});
|
|
6937
|
-
return
|
|
7070
|
+
return _context70.abrupt("return", {
|
|
6938
7071
|
code: 500,
|
|
6939
7072
|
status: false,
|
|
6940
7073
|
message: errorMessage,
|
|
@@ -6942,11 +7075,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
6942
7075
|
});
|
|
6943
7076
|
case 24:
|
|
6944
7077
|
case "end":
|
|
6945
|
-
return
|
|
7078
|
+
return _context70.stop();
|
|
6946
7079
|
}
|
|
6947
|
-
},
|
|
7080
|
+
}, _callee70, this, [[12, 19]]);
|
|
6948
7081
|
}));
|
|
6949
|
-
function handleOrderDraftSubmit(
|
|
7082
|
+
function handleOrderDraftSubmit(_x76) {
|
|
6950
7083
|
return _handleOrderDraftSubmit.apply(this, arguments);
|
|
6951
7084
|
}
|
|
6952
7085
|
return handleOrderDraftSubmit;
|
|
@@ -6954,26 +7087,26 @@ var Server = /*#__PURE__*/function () {
|
|
|
6954
7087
|
}, {
|
|
6955
7088
|
key: "handlePendingSyncCheckoutOrder",
|
|
6956
7089
|
value: function () {
|
|
6957
|
-
var _handlePendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6958
|
-
var
|
|
7090
|
+
var _handlePendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee71(params) {
|
|
7091
|
+
var _this19 = this;
|
|
6959
7092
|
var backendPath, data, title, reason, invoiceTemplateSettings, pendingOrder, _pendingOrder$payment, _pendingOrder$summary, _pendingOrder$summary2, _pendingOrder$summary3, changeGivenAmount, errorMessage;
|
|
6960
|
-
return _regeneratorRuntime().wrap(function
|
|
6961
|
-
while (1) switch (
|
|
7093
|
+
return _regeneratorRuntime().wrap(function _callee71$(_context71) {
|
|
7094
|
+
while (1) switch (_context71.prev = _context71.next) {
|
|
6962
7095
|
case 0:
|
|
6963
7096
|
backendPath = params.backendPath, data = params.data, title = params.title, reason = params.reason, invoiceTemplateSettings = params.invoiceTemplateSettings;
|
|
6964
|
-
|
|
7097
|
+
_context71.next = 3;
|
|
6965
7098
|
return this.buildPendingSyncCheckoutOrder(data, invoiceTemplateSettings);
|
|
6966
7099
|
case 3:
|
|
6967
|
-
pendingOrder =
|
|
7100
|
+
pendingOrder = _context71.sent;
|
|
6968
7101
|
if (pendingOrder) {
|
|
6969
|
-
|
|
7102
|
+
_context71.next = 7;
|
|
6970
7103
|
break;
|
|
6971
7104
|
}
|
|
6972
7105
|
this.logError("".concat(title, ": checkout \u5931\u8D25\u4E14\u8BA2\u5355\u7F3A\u5C11\u672C\u5730\u5B58\u50A8\u6807\u8BC6"), {
|
|
6973
7106
|
backendPath: backendPath,
|
|
6974
7107
|
reason: reason
|
|
6975
7108
|
});
|
|
6976
|
-
return
|
|
7109
|
+
return _context71.abrupt("return", {
|
|
6977
7110
|
code: 500,
|
|
6978
7111
|
status: false,
|
|
6979
7112
|
message: '订单缺少本地存储标识,无法写入待同步队列',
|
|
@@ -6981,22 +7114,22 @@ var Server = /*#__PURE__*/function () {
|
|
|
6981
7114
|
});
|
|
6982
7115
|
case 7:
|
|
6983
7116
|
if (!(!this.order || typeof this.order.upsertPendingSyncOrders !== 'function')) {
|
|
6984
|
-
|
|
7117
|
+
_context71.next = 10;
|
|
6985
7118
|
break;
|
|
6986
7119
|
}
|
|
6987
7120
|
this.logError("".concat(title, ": Order \u6A21\u5757\u4E0D\u652F\u6301\u672C\u5730\u5F85\u540C\u6B65\u5199\u5165"), {
|
|
6988
7121
|
backendPath: backendPath,
|
|
6989
7122
|
reason: reason
|
|
6990
7123
|
});
|
|
6991
|
-
return
|
|
7124
|
+
return _context71.abrupt("return", {
|
|
6992
7125
|
code: 500,
|
|
6993
7126
|
status: false,
|
|
6994
7127
|
message: 'Order 模块不支持本地待同步写入',
|
|
6995
7128
|
data: null
|
|
6996
7129
|
});
|
|
6997
7130
|
case 10:
|
|
6998
|
-
|
|
6999
|
-
|
|
7131
|
+
_context71.prev = 10;
|
|
7132
|
+
_context71.next = 13;
|
|
7000
7133
|
return this.order.upsertPendingSyncOrders([pendingOrder]);
|
|
7001
7134
|
case 13:
|
|
7002
7135
|
this.logInfo("".concat(title, ": \u8BA2\u5355\u5DF2\u5199\u5165\u672C\u5730\u5F85\u540C\u6B65"), {
|
|
@@ -7008,9 +7141,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
7008
7141
|
});
|
|
7009
7142
|
changeGivenAmount = pendingOrder === null || pendingOrder === void 0 || (_pendingOrder$payment = pendingOrder.payments) === null || _pendingOrder$payment === void 0 ? void 0 : _pendingOrder$payment.reduce(function (sum, payment) {
|
|
7010
7143
|
var _payment$metadata;
|
|
7011
|
-
return sum +
|
|
7144
|
+
return sum + _this19.toAmountNumber(payment === null || payment === void 0 || (_payment$metadata = payment.metadata) === null || _payment$metadata === void 0 ? void 0 : _payment$metadata.change_given_amount);
|
|
7012
7145
|
}, 0);
|
|
7013
|
-
return
|
|
7146
|
+
return _context71.abrupt("return", {
|
|
7014
7147
|
code: 200,
|
|
7015
7148
|
status: true,
|
|
7016
7149
|
message: '',
|
|
@@ -7025,15 +7158,15 @@ var Server = /*#__PURE__*/function () {
|
|
|
7025
7158
|
})
|
|
7026
7159
|
});
|
|
7027
7160
|
case 18:
|
|
7028
|
-
|
|
7029
|
-
|
|
7030
|
-
errorMessage =
|
|
7161
|
+
_context71.prev = 18;
|
|
7162
|
+
_context71.t0 = _context71["catch"](10);
|
|
7163
|
+
errorMessage = _context71.t0 instanceof Error ? _context71.t0.message : String(_context71.t0);
|
|
7031
7164
|
this.logError("".concat(title, ": \u5199\u5165\u672C\u5730\u5F85\u540C\u6B65\u8BA2\u5355\u5931\u8D25"), {
|
|
7032
7165
|
backendPath: backendPath,
|
|
7033
7166
|
reason: reason,
|
|
7034
7167
|
error: errorMessage
|
|
7035
7168
|
});
|
|
7036
|
-
return
|
|
7169
|
+
return _context71.abrupt("return", {
|
|
7037
7170
|
code: 500,
|
|
7038
7171
|
status: false,
|
|
7039
7172
|
message: errorMessage,
|
|
@@ -7041,11 +7174,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
7041
7174
|
});
|
|
7042
7175
|
case 23:
|
|
7043
7176
|
case "end":
|
|
7044
|
-
return
|
|
7177
|
+
return _context71.stop();
|
|
7045
7178
|
}
|
|
7046
|
-
},
|
|
7179
|
+
}, _callee71, this, [[10, 18]]);
|
|
7047
7180
|
}));
|
|
7048
|
-
function handlePendingSyncCheckoutOrder(
|
|
7181
|
+
function handlePendingSyncCheckoutOrder(_x77) {
|
|
7049
7182
|
return _handlePendingSyncCheckoutOrder.apply(this, arguments);
|
|
7050
7183
|
}
|
|
7051
7184
|
return handlePendingSyncCheckoutOrder;
|
|
@@ -7053,45 +7186,45 @@ var Server = /*#__PURE__*/function () {
|
|
|
7053
7186
|
}, {
|
|
7054
7187
|
key: "buildPendingSyncCheckoutOrder",
|
|
7055
7188
|
value: function () {
|
|
7056
|
-
var _buildPendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7189
|
+
var _buildPendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee72(data, invoiceTemplateSettings) {
|
|
7057
7190
|
var hasStorageKey, pendingOrder, productMap, orderWithProductTitles;
|
|
7058
|
-
return _regeneratorRuntime().wrap(function
|
|
7059
|
-
while (1) switch (
|
|
7191
|
+
return _regeneratorRuntime().wrap(function _callee72$(_context72) {
|
|
7192
|
+
while (1) switch (_context72.prev = _context72.next) {
|
|
7060
7193
|
case 0:
|
|
7061
7194
|
if (!(!data || _typeof(data) !== 'object')) {
|
|
7062
|
-
|
|
7195
|
+
_context72.next = 2;
|
|
7063
7196
|
break;
|
|
7064
7197
|
}
|
|
7065
|
-
return
|
|
7198
|
+
return _context72.abrupt("return", null);
|
|
7066
7199
|
case 2:
|
|
7067
7200
|
hasStorageKey = data.external_sale_number !== undefined && data.external_sale_number !== null && data.external_sale_number !== '' ? true : data.order_id !== undefined && data.order_id !== null && data.order_id !== '';
|
|
7068
7201
|
if (hasStorageKey) {
|
|
7069
|
-
|
|
7202
|
+
_context72.next = 5;
|
|
7070
7203
|
break;
|
|
7071
7204
|
}
|
|
7072
|
-
return
|
|
7205
|
+
return _context72.abrupt("return", null);
|
|
7073
7206
|
case 5:
|
|
7074
7207
|
pendingOrder = this.normalizeCheckoutCollections(_objectSpread(_objectSpread({}, data), {}, {
|
|
7075
7208
|
need_sync: 1,
|
|
7076
7209
|
is_draft_order: 0
|
|
7077
7210
|
}));
|
|
7078
|
-
|
|
7211
|
+
_context72.next = 8;
|
|
7079
7212
|
return this.buildSmallTicketProductMap(pendingOrder);
|
|
7080
7213
|
case 8:
|
|
7081
|
-
productMap =
|
|
7214
|
+
productMap = _context72.sent;
|
|
7082
7215
|
orderWithProductTitles = this.withPendingSyncProductTitles(pendingOrder, productMap);
|
|
7083
|
-
return
|
|
7216
|
+
return _context72.abrupt("return", this.withLocalSmallTicketData(orderWithProductTitles, {
|
|
7084
7217
|
requireFullyPaid: true,
|
|
7085
7218
|
productMap: productMap,
|
|
7086
7219
|
invoiceTemplateSettings: invoiceTemplateSettings
|
|
7087
7220
|
}));
|
|
7088
7221
|
case 11:
|
|
7089
7222
|
case "end":
|
|
7090
|
-
return
|
|
7223
|
+
return _context72.stop();
|
|
7091
7224
|
}
|
|
7092
|
-
},
|
|
7225
|
+
}, _callee72, this);
|
|
7093
7226
|
}));
|
|
7094
|
-
function buildPendingSyncCheckoutOrder(
|
|
7227
|
+
function buildPendingSyncCheckoutOrder(_x78, _x79) {
|
|
7095
7228
|
return _buildPendingSyncCheckoutOrder.apply(this, arguments);
|
|
7096
7229
|
}
|
|
7097
7230
|
return buildPendingSyncCheckoutOrder;
|
|
@@ -7119,20 +7252,20 @@ var Server = /*#__PURE__*/function () {
|
|
|
7119
7252
|
}, {
|
|
7120
7253
|
key: "shouldAutoPrintCheckoutReceipt",
|
|
7121
7254
|
value: function shouldAutoPrintCheckoutReceipt() {
|
|
7122
|
-
var _this$core$context2, _this$core$context2$g, _this$
|
|
7255
|
+
var _this$core$context2, _this$core$context2$g, _this$app19, _this$app19$getStorag;
|
|
7123
7256
|
if (((_this$core$context2 = this.core.context) === null || _this$core$context2 === void 0 || (_this$core$context2$g = _this$core$context2.getPlatform) === null || _this$core$context2$g === void 0 ? void 0 : _this$core$context2$g.call(_this$core$context2)) !== 'android') return true;
|
|
7124
|
-
return ((_this$
|
|
7257
|
+
return ((_this$app19 = this.app) === null || _this$app19 === void 0 || (_this$app19 = _this$app19.storage) === null || _this$app19 === void 0 || (_this$app19$getStorag = _this$app19.getStorage) === null || _this$app19$getStorag === void 0 ? void 0 : _this$app19$getStorag.call(_this$app19, AUTO_PRINT_STORAGE_KEY)) !== 'false';
|
|
7125
7258
|
}
|
|
7126
7259
|
|
|
7127
7260
|
/** Only receipt auto-printing uses this policy; vouchers retain their paid-order gate. */
|
|
7128
7261
|
}, {
|
|
7129
7262
|
key: "shouldAutoPrintReceiptForPaymentStatus",
|
|
7130
7263
|
value: function shouldAutoPrintReceiptForPaymentStatus(order, statuses) {
|
|
7131
|
-
var
|
|
7264
|
+
var _this20 = this;
|
|
7132
7265
|
if (statuses === undefined) return this.isSalesOrderFullyPaid(order);
|
|
7133
7266
|
var paymentStatus = String((order === null || order === void 0 ? void 0 : order.payment_status) || '').toLowerCase();
|
|
7134
7267
|
return statuses.some(function (status) {
|
|
7135
|
-
return status === 'paid' ?
|
|
7268
|
+
return status === 'paid' ? _this20.isSalesOrderFullyPaid(order) : paymentStatus === status;
|
|
7136
7269
|
});
|
|
7137
7270
|
}
|
|
7138
7271
|
}, {
|
|
@@ -7161,7 +7294,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
7161
7294
|
}, {
|
|
7162
7295
|
key: "isSalesOrderFullyPaid",
|
|
7163
7296
|
value: function isSalesOrderFullyPaid(order) {
|
|
7164
|
-
var _order$summary$amount, _order$summary,
|
|
7297
|
+
var _order$summary$amount, _order$summary, _ref75, _ref76, _order$summary$expect, _order$summary2, _order$summary3;
|
|
7165
7298
|
if (!order || _typeof(order) !== 'object') return false;
|
|
7166
7299
|
var paymentStatus = String(order.payment_status || '').toLowerCase();
|
|
7167
7300
|
if (paymentStatus === 'paid' || paymentStatus === 'finished') return true;
|
|
@@ -7173,20 +7306,20 @@ var Server = /*#__PURE__*/function () {
|
|
|
7173
7306
|
return this.toAmountNumber(amountGap) <= 0;
|
|
7174
7307
|
}
|
|
7175
7308
|
var paidAmount = this.sumPaidOrderPayments(order.payments);
|
|
7176
|
-
var targetAmount = this.toAmountNumber((
|
|
7309
|
+
var targetAmount = this.toAmountNumber((_ref75 = (_ref76 = (_order$summary$expect = (_order$summary2 = order.summary) === null || _order$summary2 === void 0 ? void 0 : _order$summary2.expect_amount) !== null && _order$summary$expect !== void 0 ? _order$summary$expect : (_order$summary3 = order.summary) === null || _order$summary3 === void 0 ? void 0 : _order$summary3.total_amount) !== null && _ref76 !== void 0 ? _ref76 : order.expect_amount) !== null && _ref75 !== void 0 ? _ref75 : order.total_amount);
|
|
7177
7310
|
if (targetAmount <= 0) return paidAmount > 0;
|
|
7178
7311
|
return paidAmount >= targetAmount;
|
|
7179
7312
|
}
|
|
7180
7313
|
}, {
|
|
7181
7314
|
key: "sumPaidOrderPayments",
|
|
7182
7315
|
value: function sumPaidOrderPayments(payments) {
|
|
7183
|
-
var
|
|
7316
|
+
var _this21 = this;
|
|
7184
7317
|
if (!Array.isArray(payments)) return 0;
|
|
7185
7318
|
return payments.reduce(function (sum, payment) {
|
|
7186
7319
|
var _payment$amount;
|
|
7187
7320
|
var status = String((payment === null || payment === void 0 ? void 0 : payment.status) || '').toLowerCase();
|
|
7188
7321
|
if (status !== 'paid') return sum;
|
|
7189
|
-
return sum +
|
|
7322
|
+
return sum + _this21.toAmountNumber((_payment$amount = payment === null || payment === void 0 ? void 0 : payment.amount) !== null && _payment$amount !== void 0 ? _payment$amount : payment === null || payment === void 0 ? void 0 : payment.origin_amount);
|
|
7190
7323
|
}, 0);
|
|
7191
7324
|
}
|
|
7192
7325
|
}, {
|
|
@@ -7200,12 +7333,12 @@ var Server = /*#__PURE__*/function () {
|
|
|
7200
7333
|
}, {
|
|
7201
7334
|
key: "buildSmallTicketProductMap",
|
|
7202
7335
|
value: function () {
|
|
7203
|
-
var _buildSmallTicketProductMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7336
|
+
var _buildSmallTicketProductMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee74(order) {
|
|
7204
7337
|
var _this$products3,
|
|
7205
|
-
|
|
7338
|
+
_this22 = this;
|
|
7206
7339
|
var products, productIdSet, productIds, entries;
|
|
7207
|
-
return _regeneratorRuntime().wrap(function
|
|
7208
|
-
while (1) switch (
|
|
7340
|
+
return _regeneratorRuntime().wrap(function _callee74$(_context74) {
|
|
7341
|
+
while (1) switch (_context74.prev = _context74.next) {
|
|
7209
7342
|
case 0:
|
|
7210
7343
|
products = Array.isArray(order === null || order === void 0 ? void 0 : order.products) ? order.products : [];
|
|
7211
7344
|
productIdSet = new Set();
|
|
@@ -7217,8 +7350,8 @@ var Server = /*#__PURE__*/function () {
|
|
|
7217
7350
|
}
|
|
7218
7351
|
if (Array.isArray(product === null || product === void 0 ? void 0 : product.product_bundle)) {
|
|
7219
7352
|
product.product_bundle.forEach(function (bundle) {
|
|
7220
|
-
var
|
|
7221
|
-
var bundleProductId = (
|
|
7353
|
+
var _ref77, _bundle$bundle_produc;
|
|
7354
|
+
var bundleProductId = (_ref77 = (_bundle$bundle_produc = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc !== void 0 ? _bundle$bundle_produc : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref77 !== void 0 ? _ref77 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id;
|
|
7222
7355
|
if (bundleProductId !== undefined && bundleProductId !== null && bundleProductId !== '') {
|
|
7223
7356
|
productIdSet.add(bundleProductId);
|
|
7224
7357
|
}
|
|
@@ -7227,45 +7360,45 @@ var Server = /*#__PURE__*/function () {
|
|
|
7227
7360
|
});
|
|
7228
7361
|
productIds = Array.from(productIdSet);
|
|
7229
7362
|
if (!(!productIds.length || typeof ((_this$products3 = this.products) === null || _this$products3 === void 0 ? void 0 : _this$products3.getProductById) !== 'function')) {
|
|
7230
|
-
|
|
7363
|
+
_context74.next = 6;
|
|
7231
7364
|
break;
|
|
7232
7365
|
}
|
|
7233
|
-
return
|
|
7366
|
+
return _context74.abrupt("return", {});
|
|
7234
7367
|
case 6:
|
|
7235
|
-
|
|
7368
|
+
_context74.next = 8;
|
|
7236
7369
|
return Promise.all(productIds.map( /*#__PURE__*/function () {
|
|
7237
|
-
var
|
|
7238
|
-
var
|
|
7239
|
-
return _regeneratorRuntime().wrap(function
|
|
7240
|
-
while (1) switch (
|
|
7370
|
+
var _ref78 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee73(id) {
|
|
7371
|
+
var _this22$products, _this22$products$getP, product;
|
|
7372
|
+
return _regeneratorRuntime().wrap(function _callee73$(_context73) {
|
|
7373
|
+
while (1) switch (_context73.prev = _context73.next) {
|
|
7241
7374
|
case 0:
|
|
7242
|
-
|
|
7243
|
-
|
|
7244
|
-
return (
|
|
7375
|
+
_context73.prev = 0;
|
|
7376
|
+
_context73.next = 3;
|
|
7377
|
+
return (_this22$products = _this22.products) === null || _this22$products === void 0 || (_this22$products$getP = _this22$products.getProductById) === null || _this22$products$getP === void 0 ? void 0 : _this22$products$getP.call(_this22$products, Number(id));
|
|
7245
7378
|
case 3:
|
|
7246
|
-
product =
|
|
7247
|
-
return
|
|
7379
|
+
product = _context73.sent;
|
|
7380
|
+
return _context73.abrupt("return", product ? [String(id), product] : null);
|
|
7248
7381
|
case 7:
|
|
7249
|
-
|
|
7250
|
-
|
|
7251
|
-
|
|
7382
|
+
_context73.prev = 7;
|
|
7383
|
+
_context73.t0 = _context73["catch"](0);
|
|
7384
|
+
_this22.logWarning('buildSmallTicketProductMap: 查询本地商品失败', {
|
|
7252
7385
|
product_id: id,
|
|
7253
|
-
error:
|
|
7386
|
+
error: _context73.t0 instanceof Error ? _context73.t0.message : String(_context73.t0)
|
|
7254
7387
|
});
|
|
7255
|
-
return
|
|
7388
|
+
return _context73.abrupt("return", null);
|
|
7256
7389
|
case 11:
|
|
7257
7390
|
case "end":
|
|
7258
|
-
return
|
|
7391
|
+
return _context73.stop();
|
|
7259
7392
|
}
|
|
7260
|
-
},
|
|
7393
|
+
}, _callee73, null, [[0, 7]]);
|
|
7261
7394
|
}));
|
|
7262
|
-
return function (
|
|
7263
|
-
return
|
|
7395
|
+
return function (_x81) {
|
|
7396
|
+
return _ref78.apply(this, arguments);
|
|
7264
7397
|
};
|
|
7265
7398
|
}()));
|
|
7266
7399
|
case 8:
|
|
7267
|
-
entries =
|
|
7268
|
-
return
|
|
7400
|
+
entries = _context74.sent;
|
|
7401
|
+
return _context74.abrupt("return", entries.reduce(function (map, entry) {
|
|
7269
7402
|
if (!entry) return map;
|
|
7270
7403
|
var _entry = _slicedToArray(entry, 2),
|
|
7271
7404
|
id = _entry[0],
|
|
@@ -7275,11 +7408,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
7275
7408
|
}, {}));
|
|
7276
7409
|
case 10:
|
|
7277
7410
|
case "end":
|
|
7278
|
-
return
|
|
7411
|
+
return _context74.stop();
|
|
7279
7412
|
}
|
|
7280
|
-
},
|
|
7413
|
+
}, _callee74, this);
|
|
7281
7414
|
}));
|
|
7282
|
-
function buildSmallTicketProductMap(
|
|
7415
|
+
function buildSmallTicketProductMap(_x80) {
|
|
7283
7416
|
return _buildSmallTicketProductMap.apply(this, arguments);
|
|
7284
7417
|
}
|
|
7285
7418
|
return buildSmallTicketProductMap;
|
|
@@ -7299,8 +7432,8 @@ var Server = /*#__PURE__*/function () {
|
|
|
7299
7432
|
addProductId((_product$product_id2 = product === null || product === void 0 ? void 0 : product.product_id) !== null && _product$product_id2 !== void 0 ? _product$product_id2 : product === null || product === void 0 ? void 0 : product.id);
|
|
7300
7433
|
if (Array.isArray(product === null || product === void 0 ? void 0 : product.product_bundle)) {
|
|
7301
7434
|
product.product_bundle.forEach(function (bundle) {
|
|
7302
|
-
var
|
|
7303
|
-
addProductId((
|
|
7435
|
+
var _ref79, _bundle$bundle_produc2;
|
|
7436
|
+
addProductId((_ref79 = (_bundle$bundle_produc2 = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc2 !== void 0 ? _bundle$bundle_produc2 : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref79 !== void 0 ? _ref79 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id);
|
|
7304
7437
|
});
|
|
7305
7438
|
}
|
|
7306
7439
|
});
|
|
@@ -7309,40 +7442,40 @@ var Server = /*#__PURE__*/function () {
|
|
|
7309
7442
|
}, {
|
|
7310
7443
|
key: "buildSalesDetailProductSnapshotMap",
|
|
7311
7444
|
value: function () {
|
|
7312
|
-
var _buildSalesDetailProductSnapshotMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7445
|
+
var _buildSalesDetailProductSnapshotMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee75(order) {
|
|
7313
7446
|
var _this$products4;
|
|
7314
7447
|
var productIds, getSnapshots;
|
|
7315
|
-
return _regeneratorRuntime().wrap(function
|
|
7316
|
-
while (1) switch (
|
|
7448
|
+
return _regeneratorRuntime().wrap(function _callee75$(_context75) {
|
|
7449
|
+
while (1) switch (_context75.prev = _context75.next) {
|
|
7317
7450
|
case 0:
|
|
7318
7451
|
productIds = this.collectSalesDetailProductIds(order);
|
|
7319
7452
|
getSnapshots = (_this$products4 = this.products) === null || _this$products4 === void 0 ? void 0 : _this$products4.getProductSnapshotsByIds;
|
|
7320
7453
|
if (!(!productIds.length || typeof getSnapshots !== 'function')) {
|
|
7321
|
-
|
|
7454
|
+
_context75.next = 4;
|
|
7322
7455
|
break;
|
|
7323
7456
|
}
|
|
7324
|
-
return
|
|
7457
|
+
return _context75.abrupt("return", {});
|
|
7325
7458
|
case 4:
|
|
7326
|
-
|
|
7327
|
-
|
|
7459
|
+
_context75.prev = 4;
|
|
7460
|
+
_context75.next = 7;
|
|
7328
7461
|
return getSnapshots.call(this.products, productIds);
|
|
7329
7462
|
case 7:
|
|
7330
|
-
return
|
|
7463
|
+
return _context75.abrupt("return", _context75.sent);
|
|
7331
7464
|
case 10:
|
|
7332
|
-
|
|
7333
|
-
|
|
7465
|
+
_context75.prev = 10;
|
|
7466
|
+
_context75.t0 = _context75["catch"](4);
|
|
7334
7467
|
this.logWarning('buildSalesDetailProductSnapshotMap: 查询本地商品快照失败', {
|
|
7335
7468
|
product_ids: productIds,
|
|
7336
|
-
error:
|
|
7469
|
+
error: _context75.t0 instanceof Error ? _context75.t0.message : String(_context75.t0)
|
|
7337
7470
|
});
|
|
7338
|
-
return
|
|
7471
|
+
return _context75.abrupt("return", {});
|
|
7339
7472
|
case 14:
|
|
7340
7473
|
case "end":
|
|
7341
|
-
return
|
|
7474
|
+
return _context75.stop();
|
|
7342
7475
|
}
|
|
7343
|
-
},
|
|
7476
|
+
}, _callee75, this, [[4, 10]]);
|
|
7344
7477
|
}));
|
|
7345
|
-
function buildSalesDetailProductSnapshotMap(
|
|
7478
|
+
function buildSalesDetailProductSnapshotMap(_x82) {
|
|
7346
7479
|
return _buildSalesDetailProductSnapshotMap.apply(this, arguments);
|
|
7347
7480
|
}
|
|
7348
7481
|
return buildSalesDetailProductSnapshotMap;
|
|
@@ -7376,9 +7509,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
7376
7509
|
if (!Array.isArray(product === null || product === void 0 ? void 0 : product.product_bundle)) return product;
|
|
7377
7510
|
var hasChanged = false;
|
|
7378
7511
|
var productBundle = product.product_bundle.map(function (bundle) {
|
|
7379
|
-
var
|
|
7512
|
+
var _ref80, _bundle$bundle_produc3;
|
|
7380
7513
|
if (!bundle || _typeof(bundle) !== 'object') return bundle;
|
|
7381
|
-
var rawProductId = (
|
|
7514
|
+
var rawProductId = (_ref80 = (_bundle$bundle_produc3 = bundle === null || bundle === void 0 ? void 0 : bundle.bundle_product_id) !== null && _bundle$bundle_produc3 !== void 0 ? _bundle$bundle_produc3 : bundle === null || bundle === void 0 ? void 0 : bundle._bundle_product_id) !== null && _ref80 !== void 0 ? _ref80 : bundle === null || bundle === void 0 ? void 0 : bundle.product_id;
|
|
7382
7515
|
if (rawProductId === undefined || rawProductId === null || rawProductId === '') return bundle;
|
|
7383
7516
|
var productId = Number(rawProductId);
|
|
7384
7517
|
if (!Number.isFinite(productId)) return bundle;
|
|
@@ -7398,53 +7531,53 @@ var Server = /*#__PURE__*/function () {
|
|
|
7398
7531
|
}, {
|
|
7399
7532
|
key: "withSalesDetailProductSnapshots",
|
|
7400
7533
|
value: function () {
|
|
7401
|
-
var _withSalesDetailProductSnapshots = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7402
|
-
var
|
|
7534
|
+
var _withSalesDetailProductSnapshots = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee76(order) {
|
|
7535
|
+
var _this23 = this;
|
|
7403
7536
|
var products, snapshotMap, hasChanged, enrichedProducts, enrichedOrder;
|
|
7404
|
-
return _regeneratorRuntime().wrap(function
|
|
7405
|
-
while (1) switch (
|
|
7537
|
+
return _regeneratorRuntime().wrap(function _callee76$(_context76) {
|
|
7538
|
+
while (1) switch (_context76.prev = _context76.next) {
|
|
7406
7539
|
case 0:
|
|
7407
7540
|
products = Array.isArray(order === null || order === void 0 ? void 0 : order.products) ? order.products : null;
|
|
7408
7541
|
if (products !== null && products !== void 0 && products.length) {
|
|
7409
|
-
|
|
7542
|
+
_context76.next = 3;
|
|
7410
7543
|
break;
|
|
7411
7544
|
}
|
|
7412
|
-
return
|
|
7545
|
+
return _context76.abrupt("return", order);
|
|
7413
7546
|
case 3:
|
|
7414
|
-
|
|
7547
|
+
_context76.next = 5;
|
|
7415
7548
|
return this.buildSalesDetailProductSnapshotMap(order);
|
|
7416
7549
|
case 5:
|
|
7417
|
-
snapshotMap =
|
|
7550
|
+
snapshotMap = _context76.sent;
|
|
7418
7551
|
if (Object.keys(snapshotMap).length) {
|
|
7419
|
-
|
|
7552
|
+
_context76.next = 8;
|
|
7420
7553
|
break;
|
|
7421
7554
|
}
|
|
7422
|
-
return
|
|
7555
|
+
return _context76.abrupt("return", order);
|
|
7423
7556
|
case 8:
|
|
7424
7557
|
hasChanged = false;
|
|
7425
7558
|
enrichedProducts = products.map(function (product) {
|
|
7426
|
-
var productWithBundleSnapshots =
|
|
7427
|
-
var nextProduct =
|
|
7559
|
+
var productWithBundleSnapshots = _this23.withBundleCatalogSnapshots(product, snapshotMap);
|
|
7560
|
+
var nextProduct = _this23.withProductCatalogSnapshots(productWithBundleSnapshots, snapshotMap);
|
|
7428
7561
|
if (nextProduct !== product) hasChanged = true;
|
|
7429
7562
|
return nextProduct;
|
|
7430
7563
|
});
|
|
7431
7564
|
if (hasChanged) {
|
|
7432
|
-
|
|
7565
|
+
_context76.next = 12;
|
|
7433
7566
|
break;
|
|
7434
7567
|
}
|
|
7435
|
-
return
|
|
7568
|
+
return _context76.abrupt("return", order);
|
|
7436
7569
|
case 12:
|
|
7437
7570
|
enrichedOrder = _objectSpread(_objectSpread({}, order), {}, {
|
|
7438
7571
|
products: enrichedProducts
|
|
7439
7572
|
});
|
|
7440
|
-
return
|
|
7573
|
+
return _context76.abrupt("return", enrichedOrder);
|
|
7441
7574
|
case 14:
|
|
7442
7575
|
case "end":
|
|
7443
|
-
return
|
|
7576
|
+
return _context76.stop();
|
|
7444
7577
|
}
|
|
7445
|
-
},
|
|
7578
|
+
}, _callee76, this);
|
|
7446
7579
|
}));
|
|
7447
|
-
function withSalesDetailProductSnapshots(
|
|
7580
|
+
function withSalesDetailProductSnapshots(_x83) {
|
|
7448
7581
|
return _withSalesDetailProductSnapshots.apply(this, arguments);
|
|
7449
7582
|
}
|
|
7450
7583
|
return withSalesDetailProductSnapshots;
|
|
@@ -7452,13 +7585,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
7452
7585
|
}, {
|
|
7453
7586
|
key: "withPendingSyncProductTitles",
|
|
7454
7587
|
value: function withPendingSyncProductTitles(order, productMap) {
|
|
7455
|
-
var
|
|
7588
|
+
var _this24 = this;
|
|
7456
7589
|
var products = Array.isArray(order.products) ? order.products : null;
|
|
7457
7590
|
if (!(products !== null && products !== void 0 && products.length)) return order;
|
|
7458
7591
|
return _objectSpread(_objectSpread({}, order), {}, {
|
|
7459
7592
|
products: products.map(function (product) {
|
|
7460
7593
|
return _objectSpread(_objectSpread({}, product), {}, {
|
|
7461
|
-
product_title:
|
|
7594
|
+
product_title: _this24.buildProductTitleSnapshot(product, productMap)
|
|
7462
7595
|
});
|
|
7463
7596
|
})
|
|
7464
7597
|
});
|
|
@@ -7469,7 +7602,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
7469
7602
|
var _product$product_id4,
|
|
7470
7603
|
_product$product,
|
|
7471
7604
|
_fallbackProduct$prod,
|
|
7472
|
-
|
|
7605
|
+
_this25 = this;
|
|
7473
7606
|
var productId = (_product$product_id4 = product.product_id) !== null && _product$product_id4 !== void 0 ? _product$product_id4 : product.id;
|
|
7474
7607
|
var fallbackProduct = productId !== undefined && productId !== null ? productMap[productId] || productMap[String(productId)] : null;
|
|
7475
7608
|
var ownTitle = product.product_title || product.title || product.name || ((_product$product = product.product) === null || _product$product === void 0 ? void 0 : _product$product.title);
|
|
@@ -7477,7 +7610,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
7477
7610
|
var currentLocale = this.getProductTitleSnapshotCurrentLocale();
|
|
7478
7611
|
var autoTitle = this.resolveFirstProductTitleValue(ownTitle) || this.resolveFirstProductTitleValue(fallbackTitle);
|
|
7479
7612
|
return PRODUCT_TITLE_SNAPSHOT_KEYS.reduce(function (snapshot, key) {
|
|
7480
|
-
snapshot[key] =
|
|
7613
|
+
snapshot[key] = _this25.resolveProductTitleValue(ownTitle, key, currentLocale) || _this25.resolveProductTitleValue(fallbackTitle, key, currentLocale) || (key === 'auto' || key === 'original' ? autoTitle : null);
|
|
7481
7614
|
return snapshot;
|
|
7482
7615
|
}, {});
|
|
7483
7616
|
}
|
|
@@ -7502,7 +7635,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
7502
7635
|
}, {
|
|
7503
7636
|
key: "resolveProductTitleValue",
|
|
7504
7637
|
value: function resolveProductTitleValue(value, key, currentLocale) {
|
|
7505
|
-
var
|
|
7638
|
+
var _ref81, _ref82, _value$key;
|
|
7506
7639
|
if (value === undefined || value === null || value === '') return null;
|
|
7507
7640
|
if (_typeof(value) !== 'object') {
|
|
7508
7641
|
var title = String(value);
|
|
@@ -7512,7 +7645,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
7512
7645
|
}
|
|
7513
7646
|
var normalizedKey = key.replace('-', '_');
|
|
7514
7647
|
var dashedKey = key.replace('_', '-');
|
|
7515
|
-
var rawValue = (
|
|
7648
|
+
var rawValue = (_ref81 = (_ref82 = (_value$key = value[key]) !== null && _value$key !== void 0 ? _value$key : value[normalizedKey]) !== null && _ref82 !== void 0 ? _ref82 : value[dashedKey]) !== null && _ref81 !== void 0 ? _ref81 : key === 'auto' ? value.default : undefined;
|
|
7516
7649
|
if (rawValue === undefined || rawValue === null || rawValue === '') return null;
|
|
7517
7650
|
if (_typeof(rawValue) === 'object') return this.resolveFirstProductTitleValue(rawValue);
|
|
7518
7651
|
return String(rawValue);
|
|
@@ -7575,31 +7708,31 @@ var Server = /*#__PURE__*/function () {
|
|
|
7575
7708
|
}, {
|
|
7576
7709
|
key: "enrichPaymentNamesByCode",
|
|
7577
7710
|
value: function () {
|
|
7578
|
-
var _enrichPaymentNamesByCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7579
|
-
var
|
|
7711
|
+
var _enrichPaymentNamesByCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee77(order) {
|
|
7712
|
+
var _this26 = this;
|
|
7580
7713
|
var payments, hasMissingName, paymentModule, payMethods, nameByCode, _iterator12, _step12, method, codeKey, name, hasResolvedName, enrichedPayments;
|
|
7581
|
-
return _regeneratorRuntime().wrap(function
|
|
7582
|
-
while (1) switch (
|
|
7714
|
+
return _regeneratorRuntime().wrap(function _callee77$(_context77) {
|
|
7715
|
+
while (1) switch (_context77.prev = _context77.next) {
|
|
7583
7716
|
case 0:
|
|
7584
7717
|
payments = Array.isArray(order === null || order === void 0 ? void 0 : order.payments) ? order.payments : [];
|
|
7585
7718
|
hasMissingName = payments.some(function (payment) {
|
|
7586
|
-
return
|
|
7719
|
+
return _this26.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name) && _this26.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code);
|
|
7587
7720
|
});
|
|
7588
7721
|
if (hasMissingName) {
|
|
7589
|
-
|
|
7722
|
+
_context77.next = 4;
|
|
7590
7723
|
break;
|
|
7591
7724
|
}
|
|
7592
|
-
return
|
|
7725
|
+
return _context77.abrupt("return", order);
|
|
7593
7726
|
case 4:
|
|
7594
|
-
|
|
7595
|
-
|
|
7727
|
+
_context77.prev = 4;
|
|
7728
|
+
_context77.next = 7;
|
|
7596
7729
|
return this.getPaymentRouteModule();
|
|
7597
7730
|
case 7:
|
|
7598
|
-
paymentModule =
|
|
7599
|
-
|
|
7731
|
+
paymentModule = _context77.sent;
|
|
7732
|
+
_context77.next = 10;
|
|
7600
7733
|
return paymentModule.getPayMethodListAsync();
|
|
7601
7734
|
case 10:
|
|
7602
|
-
payMethods =
|
|
7735
|
+
payMethods = _context77.sent;
|
|
7603
7736
|
nameByCode = new Map();
|
|
7604
7737
|
_iterator12 = _createForOfIteratorHelper(payMethods || []);
|
|
7605
7738
|
try {
|
|
@@ -7616,9 +7749,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
7616
7749
|
}
|
|
7617
7750
|
hasResolvedName = false;
|
|
7618
7751
|
enrichedPayments = payments.map(function (payment) {
|
|
7619
|
-
if (!
|
|
7620
|
-
if (!
|
|
7621
|
-
var name = nameByCode.get(
|
|
7752
|
+
if (!_this26.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name)) return payment;
|
|
7753
|
+
if (!_this26.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code)) return payment;
|
|
7754
|
+
var name = nameByCode.get(_this26.getPaymentCodeKey(payment === null || payment === void 0 ? void 0 : payment.code));
|
|
7622
7755
|
if (!name) return payment;
|
|
7623
7756
|
hasResolvedName = true;
|
|
7624
7757
|
return _objectSpread(_objectSpread({}, payment), {}, {
|
|
@@ -7626,28 +7759,28 @@ var Server = /*#__PURE__*/function () {
|
|
|
7626
7759
|
});
|
|
7627
7760
|
});
|
|
7628
7761
|
if (hasResolvedName) {
|
|
7629
|
-
|
|
7762
|
+
_context77.next = 18;
|
|
7630
7763
|
break;
|
|
7631
7764
|
}
|
|
7632
|
-
return
|
|
7765
|
+
return _context77.abrupt("return", order);
|
|
7633
7766
|
case 18:
|
|
7634
|
-
return
|
|
7767
|
+
return _context77.abrupt("return", _objectSpread(_objectSpread({}, order), {}, {
|
|
7635
7768
|
payments: enrichedPayments
|
|
7636
7769
|
}));
|
|
7637
7770
|
case 21:
|
|
7638
|
-
|
|
7639
|
-
|
|
7771
|
+
_context77.prev = 21;
|
|
7772
|
+
_context77.t0 = _context77["catch"](4);
|
|
7640
7773
|
this.logWarning('enrichPaymentNamesByCode: 支付方式名称回填失败', {
|
|
7641
|
-
error:
|
|
7774
|
+
error: _context77.t0 instanceof Error ? _context77.t0.message : String(_context77.t0)
|
|
7642
7775
|
});
|
|
7643
|
-
return
|
|
7776
|
+
return _context77.abrupt("return", order);
|
|
7644
7777
|
case 25:
|
|
7645
7778
|
case "end":
|
|
7646
|
-
return
|
|
7779
|
+
return _context77.stop();
|
|
7647
7780
|
}
|
|
7648
|
-
},
|
|
7781
|
+
}, _callee77, this, [[4, 21]]);
|
|
7649
7782
|
}));
|
|
7650
|
-
function enrichPaymentNamesByCode(
|
|
7783
|
+
function enrichPaymentNamesByCode(_x84) {
|
|
7651
7784
|
return _enrichPaymentNamesByCode.apply(this, arguments);
|
|
7652
7785
|
}
|
|
7653
7786
|
return enrichPaymentNamesByCode;
|
|
@@ -7655,25 +7788,25 @@ var Server = /*#__PURE__*/function () {
|
|
|
7655
7788
|
}, {
|
|
7656
7789
|
key: "withLocalSmallTicketData",
|
|
7657
7790
|
value: function () {
|
|
7658
|
-
var _withLocalSmallTicketData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7659
|
-
var mustApplyVisibility, _options$productMap, normalizedCollections, normalizedOrder, collapsedDuplicateCounts,
|
|
7660
|
-
return _regeneratorRuntime().wrap(function
|
|
7661
|
-
while (1) switch (
|
|
7791
|
+
var _withLocalSmallTicketData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee78(order, options) {
|
|
7792
|
+
var mustApplyVisibility, _options$productMap, normalizedCollections, normalizedOrder, collapsedDuplicateCounts, _ref83, _ref84, _order_id, receiptOrder, enrichedOrder, productMap, smallTicketData;
|
|
7793
|
+
return _regeneratorRuntime().wrap(function _callee78$(_context78) {
|
|
7794
|
+
while (1) switch (_context78.prev = _context78.next) {
|
|
7662
7795
|
case 0:
|
|
7663
7796
|
mustApplyVisibility = (options === null || options === void 0 ? void 0 : options.applyTemplateVisibility) === true && requiresInvoiceDataFiltering(options.invoiceTemplateSettings);
|
|
7664
7797
|
if (!(!this.shouldBuildSmallTicketData(order) && !mustApplyVisibility)) {
|
|
7665
|
-
|
|
7798
|
+
_context78.next = 3;
|
|
7666
7799
|
break;
|
|
7667
7800
|
}
|
|
7668
|
-
return
|
|
7801
|
+
return _context78.abrupt("return", order);
|
|
7669
7802
|
case 3:
|
|
7670
7803
|
if (!(options !== null && options !== void 0 && options.requireFullyPaid && !this.isSalesOrderFullyPaid(order))) {
|
|
7671
|
-
|
|
7804
|
+
_context78.next = 5;
|
|
7672
7805
|
break;
|
|
7673
7806
|
}
|
|
7674
|
-
return
|
|
7807
|
+
return _context78.abrupt("return", order);
|
|
7675
7808
|
case 5:
|
|
7676
|
-
|
|
7809
|
+
_context78.prev = 5;
|
|
7677
7810
|
normalizedCollections = normalizeOrderCollections(order, {
|
|
7678
7811
|
ensureUid: false
|
|
7679
7812
|
});
|
|
@@ -7687,28 +7820,42 @@ var Server = /*#__PURE__*/function () {
|
|
|
7687
7820
|
return count > 0;
|
|
7688
7821
|
})) {
|
|
7689
7822
|
this.logWarning('withLocalSmallTicketData: 折叠重复订单子项', {
|
|
7690
|
-
order_identifier: (
|
|
7823
|
+
order_identifier: (_ref83 = (_ref84 = (_order_id = normalizedOrder.order_id) !== null && _order_id !== void 0 ? _order_id : normalizedOrder.external_sale_number) !== null && _ref84 !== void 0 ? _ref84 : normalizedOrder.shop_order_number) !== null && _ref83 !== void 0 ? _ref83 : null,
|
|
7691
7824
|
collapsed_duplicate_counts: collapsedDuplicateCounts
|
|
7692
7825
|
});
|
|
7693
7826
|
}
|
|
7694
|
-
|
|
7695
|
-
|
|
7696
|
-
case 12:
|
|
7697
|
-
enrichedOrder = _context76.sent;
|
|
7698
|
-
if (!((_options$productMap = options === null || options === void 0 ? void 0 : options.productMap) !== null && _options$productMap !== void 0)) {
|
|
7699
|
-
_context76.next = 17;
|
|
7827
|
+
if (!(options !== null && options !== void 0 && options.refreshResourceReference)) {
|
|
7828
|
+
_context78.next = 16;
|
|
7700
7829
|
break;
|
|
7701
7830
|
}
|
|
7702
|
-
|
|
7703
|
-
|
|
7831
|
+
_context78.next = 13;
|
|
7832
|
+
return this.withCurrentReceiptResourceReference(normalizedOrder);
|
|
7833
|
+
case 13:
|
|
7834
|
+
_context78.t0 = _context78.sent;
|
|
7835
|
+
_context78.next = 17;
|
|
7704
7836
|
break;
|
|
7837
|
+
case 16:
|
|
7838
|
+
_context78.t0 = normalizedOrder;
|
|
7705
7839
|
case 17:
|
|
7706
|
-
|
|
7707
|
-
|
|
7708
|
-
|
|
7709
|
-
_context76.t0 = _context76.sent;
|
|
7840
|
+
receiptOrder = _context78.t0;
|
|
7841
|
+
_context78.next = 20;
|
|
7842
|
+
return this.enrichPaymentNamesByCode(receiptOrder);
|
|
7710
7843
|
case 20:
|
|
7711
|
-
|
|
7844
|
+
enrichedOrder = _context78.sent;
|
|
7845
|
+
if (!((_options$productMap = options === null || options === void 0 ? void 0 : options.productMap) !== null && _options$productMap !== void 0)) {
|
|
7846
|
+
_context78.next = 25;
|
|
7847
|
+
break;
|
|
7848
|
+
}
|
|
7849
|
+
_context78.t1 = _options$productMap;
|
|
7850
|
+
_context78.next = 28;
|
|
7851
|
+
break;
|
|
7852
|
+
case 25:
|
|
7853
|
+
_context78.next = 27;
|
|
7854
|
+
return this.buildSmallTicketProductMap(enrichedOrder);
|
|
7855
|
+
case 27:
|
|
7856
|
+
_context78.t1 = _context78.sent;
|
|
7857
|
+
case 28:
|
|
7858
|
+
productMap = _context78.t1;
|
|
7712
7859
|
smallTicketData = buildSmallTicketData({
|
|
7713
7860
|
order: enrichedOrder,
|
|
7714
7861
|
shopInfo: this.getSmallTicketShopInfo(),
|
|
@@ -7717,31 +7864,31 @@ var Server = /*#__PURE__*/function () {
|
|
|
7717
7864
|
includeReceiptKeys: options === null || options === void 0 ? void 0 : options.includeReceiptKeys,
|
|
7718
7865
|
templateSettings: options !== null && options !== void 0 && options.applyTemplateVisibility ? options.invoiceTemplateSettings : undefined
|
|
7719
7866
|
});
|
|
7720
|
-
return
|
|
7867
|
+
return _context78.abrupt("return", _objectSpread(_objectSpread({}, enrichedOrder), {}, {
|
|
7721
7868
|
payment_info: _objectSpread(_objectSpread({}, enrichedOrder.payment_info || {}), {}, {
|
|
7722
7869
|
small_ticket_data: smallTicketData
|
|
7723
7870
|
})
|
|
7724
7871
|
}));
|
|
7725
|
-
case
|
|
7726
|
-
|
|
7727
|
-
|
|
7872
|
+
case 33:
|
|
7873
|
+
_context78.prev = 33;
|
|
7874
|
+
_context78.t2 = _context78["catch"](5);
|
|
7728
7875
|
this.logError('withLocalSmallTicketData: 生成本地小票数据失败', {
|
|
7729
|
-
error:
|
|
7876
|
+
error: _context78.t2 instanceof Error ? _context78.t2.message : String(_context78.t2)
|
|
7730
7877
|
});
|
|
7731
7878
|
if (!mustApplyVisibility) {
|
|
7732
|
-
|
|
7879
|
+
_context78.next = 38;
|
|
7733
7880
|
break;
|
|
7734
7881
|
}
|
|
7735
|
-
throw
|
|
7736
|
-
case
|
|
7737
|
-
return
|
|
7738
|
-
case
|
|
7882
|
+
throw _context78.t2;
|
|
7883
|
+
case 38:
|
|
7884
|
+
return _context78.abrupt("return", order);
|
|
7885
|
+
case 39:
|
|
7739
7886
|
case "end":
|
|
7740
|
-
return
|
|
7887
|
+
return _context78.stop();
|
|
7741
7888
|
}
|
|
7742
|
-
},
|
|
7889
|
+
}, _callee78, this, [[5, 33]]);
|
|
7743
7890
|
}));
|
|
7744
|
-
function withLocalSmallTicketData(
|
|
7891
|
+
function withLocalSmallTicketData(_x85, _x86) {
|
|
7745
7892
|
return _withLocalSmallTicketData.apply(this, arguments);
|
|
7746
7893
|
}
|
|
7747
7894
|
return withLocalSmallTicketData;
|
|
@@ -7756,37 +7903,37 @@ var Server = /*#__PURE__*/function () {
|
|
|
7756
7903
|
}, {
|
|
7757
7904
|
key: "fetchAndPersistSalesOrderByLookup",
|
|
7758
7905
|
value: function () {
|
|
7759
|
-
var _fetchAndPersistSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7760
|
-
var _this$order7, _this$order8, _this$
|
|
7761
|
-
var backendPath, _this$order$getLocalO, _this$order9, response, _response$code3, responseStatusCode, code, message, fresh, localBeforeRefresh, orderToPersist, remotePayments, paidPayments, paymentIdsComplete, savedOrder, _errorRecord$response, backendError, errorRecord, _responseStatusCode,
|
|
7762
|
-
return _regeneratorRuntime().wrap(function
|
|
7763
|
-
while (1) switch (
|
|
7906
|
+
var _fetchAndPersistSalesOrderByLookup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee79(lookup, data, title, paymentIdentityOrder) {
|
|
7907
|
+
var _this$order7, _this$order8, _this$app20;
|
|
7908
|
+
var backendPath, _this$order$getLocalO, _this$order9, response, _response$code3, responseStatusCode, code, message, fresh, localBeforeRefresh, orderToPersist, remotePayments, paidPayments, paymentIdsComplete, savedOrder, _errorRecord$response, backendError, errorRecord, _responseStatusCode, _ref85, _backendError$code2, backendStatusCode, _code, _message2, _message3;
|
|
7909
|
+
return _regeneratorRuntime().wrap(function _callee79$(_context79) {
|
|
7910
|
+
while (1) switch (_context79.prev = _context79.next) {
|
|
7764
7911
|
case 0:
|
|
7765
7912
|
if (!(!((_this$order7 = this.order) !== null && _this$order7 !== void 0 && _this$order7.getLocalOrderByLookup) || !((_this$order8 = this.order) !== null && _this$order8 !== void 0 && _this$order8.upsertOrdersFromRemote))) {
|
|
7766
|
-
|
|
7913
|
+
_context79.next = 3;
|
|
7767
7914
|
break;
|
|
7768
7915
|
}
|
|
7769
7916
|
this.logError("".concat(title, ": Order \u6A21\u5757\u672A\u6CE8\u518C"));
|
|
7770
|
-
return
|
|
7917
|
+
return _context79.abrupt("return", {
|
|
7771
7918
|
code: 500,
|
|
7772
7919
|
message: 'Order 模块未注册',
|
|
7773
7920
|
order: null
|
|
7774
7921
|
});
|
|
7775
7922
|
case 3:
|
|
7776
|
-
if ((_this$
|
|
7777
|
-
|
|
7923
|
+
if ((_this$app20 = this.app) !== null && _this$app20 !== void 0 && (_this$app20 = _this$app20.request) !== null && _this$app20 !== void 0 && _this$app20.get) {
|
|
7924
|
+
_context79.next = 6;
|
|
7778
7925
|
break;
|
|
7779
7926
|
}
|
|
7780
7927
|
this.logError("".concat(title, ": app.request \u4E0D\u53EF\u7528"));
|
|
7781
|
-
return
|
|
7928
|
+
return _context79.abrupt("return", {
|
|
7782
7929
|
code: 500,
|
|
7783
7930
|
message: 'app.request 不可用',
|
|
7784
7931
|
order: null
|
|
7785
7932
|
});
|
|
7786
7933
|
case 6:
|
|
7787
7934
|
backendPath = this.buildOrderSalesDetailBackendPath(String(lookup), data);
|
|
7788
|
-
|
|
7789
|
-
|
|
7935
|
+
_context79.prev = 7;
|
|
7936
|
+
_context79.next = 10;
|
|
7790
7937
|
return this.app.request.get(backendPath, {
|
|
7791
7938
|
lookup_mode: 'multi'
|
|
7792
7939
|
}, {
|
|
@@ -7794,9 +7941,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
7794
7941
|
customToast: function customToast() {}
|
|
7795
7942
|
});
|
|
7796
7943
|
case 10:
|
|
7797
|
-
response =
|
|
7944
|
+
response = _context79.sent;
|
|
7798
7945
|
if (!this.isCheckoutResponseRejected(response)) {
|
|
7799
|
-
|
|
7946
|
+
_context79.next = 17;
|
|
7800
7947
|
break;
|
|
7801
7948
|
}
|
|
7802
7949
|
responseStatusCode = typeof (response === null || response === void 0 ? void 0 : response.status) === 'number' ? response.status : undefined;
|
|
@@ -7808,7 +7955,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
7808
7955
|
code: code,
|
|
7809
7956
|
message: message
|
|
7810
7957
|
});
|
|
7811
|
-
return
|
|
7958
|
+
return _context79.abrupt("return", {
|
|
7812
7959
|
code: code,
|
|
7813
7960
|
message: message,
|
|
7814
7961
|
order: null
|
|
@@ -7816,56 +7963,56 @@ var Server = /*#__PURE__*/function () {
|
|
|
7816
7963
|
case 17:
|
|
7817
7964
|
fresh = this.extractOrderDataFromCheckoutResponse(response);
|
|
7818
7965
|
if (!(!fresh || fresh.order_id === undefined || fresh.order_id === null || String(fresh.order_id).trim() === '')) {
|
|
7819
|
-
|
|
7966
|
+
_context79.next = 21;
|
|
7820
7967
|
break;
|
|
7821
7968
|
}
|
|
7822
7969
|
this.logInfo("".concat(title, ": \u540E\u7AEF\u8FD4\u56DE\u8BA2\u5355\u4E3A\u7A7A"), {
|
|
7823
7970
|
lookup: lookup,
|
|
7824
7971
|
backendPath: backendPath
|
|
7825
7972
|
});
|
|
7826
|
-
return
|
|
7973
|
+
return _context79.abrupt("return", {
|
|
7827
7974
|
code: 500,
|
|
7828
7975
|
message: '后端返回订单为空',
|
|
7829
7976
|
order: null
|
|
7830
7977
|
});
|
|
7831
7978
|
case 21:
|
|
7832
|
-
|
|
7833
|
-
if (
|
|
7834
|
-
|
|
7979
|
+
_context79.t0 = (_this$order$getLocalO = (_this$order9 = this.order).getLocalOrderFromMemoryByLookup) === null || _this$order$getLocalO === void 0 ? void 0 : _this$order$getLocalO.call(_this$order9, lookup);
|
|
7980
|
+
if (_context79.t0) {
|
|
7981
|
+
_context79.next = 31;
|
|
7835
7982
|
break;
|
|
7836
7983
|
}
|
|
7837
7984
|
if (!this.shouldForceRemoteSalesDetail(data)) {
|
|
7838
|
-
|
|
7985
|
+
_context79.next = 29;
|
|
7839
7986
|
break;
|
|
7840
7987
|
}
|
|
7841
|
-
|
|
7988
|
+
_context79.next = 26;
|
|
7842
7989
|
return this.order.getLocalOrderByLookup(lookup);
|
|
7843
7990
|
case 26:
|
|
7844
|
-
|
|
7845
|
-
|
|
7991
|
+
_context79.t1 = _context79.sent;
|
|
7992
|
+
_context79.next = 30;
|
|
7846
7993
|
break;
|
|
7847
7994
|
case 29:
|
|
7848
|
-
|
|
7995
|
+
_context79.t1 = null;
|
|
7849
7996
|
case 30:
|
|
7850
|
-
|
|
7997
|
+
_context79.t0 = _context79.t1;
|
|
7851
7998
|
case 31:
|
|
7852
|
-
localBeforeRefresh =
|
|
7999
|
+
localBeforeRefresh = _context79.t0;
|
|
7853
8000
|
orderToPersist = fresh;
|
|
7854
8001
|
if (!paymentIdentityOrder) {
|
|
7855
|
-
|
|
8002
|
+
_context79.next = 44;
|
|
7856
8003
|
break;
|
|
7857
8004
|
}
|
|
7858
8005
|
if (!(String(fresh.order_id) !== String(paymentIdentityOrder.order_id) || fresh.external_sale_number && paymentIdentityOrder.external_sale_number && fresh.external_sale_number !== paymentIdentityOrder.external_sale_number || !Array.isArray(fresh.payments))) {
|
|
7859
|
-
|
|
8006
|
+
_context79.next = 36;
|
|
7860
8007
|
break;
|
|
7861
8008
|
}
|
|
7862
8009
|
throw new Error('远端订单身份不匹配或缺少付款明细,暂不补齐付款 ID');
|
|
7863
8010
|
case 36:
|
|
7864
8011
|
if (!(!localBeforeRefresh || Number(localBeforeRefresh.need_sync || 0) === 1 || Number(localBeforeRefresh.is_draft_order || 0) === 1)) {
|
|
7865
|
-
|
|
8012
|
+
_context79.next = 38;
|
|
7866
8013
|
break;
|
|
7867
8014
|
}
|
|
7868
|
-
return
|
|
8015
|
+
return _context79.abrupt("return", {
|
|
7869
8016
|
code: 200,
|
|
7870
8017
|
message: '',
|
|
7871
8018
|
order: localBeforeRefresh || paymentIdentityOrder
|
|
@@ -7887,7 +8034,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
7887
8034
|
return matches.length === 1 && paymentId !== undefined && paymentId !== null && String(paymentId).trim() !== '';
|
|
7888
8035
|
});
|
|
7889
8036
|
if (paymentIdsComplete) {
|
|
7890
|
-
|
|
8037
|
+
_context79.next = 43;
|
|
7891
8038
|
break;
|
|
7892
8039
|
}
|
|
7893
8040
|
throw new Error('远端付款 ID 尚未齐全或付款身份匹配不唯一,保留本地付款等待重试');
|
|
@@ -7899,46 +8046,46 @@ var Server = /*#__PURE__*/function () {
|
|
|
7899
8046
|
});
|
|
7900
8047
|
case 44:
|
|
7901
8048
|
if (!requiresLocalPaymentRefresh(localBeforeRefresh)) {
|
|
7902
|
-
|
|
8049
|
+
_context79.next = 51;
|
|
7903
8050
|
break;
|
|
7904
8051
|
}
|
|
7905
8052
|
if (!(String(fresh.order_id) !== String(localBeforeRefresh.order_id))) {
|
|
7906
|
-
|
|
8053
|
+
_context79.next = 47;
|
|
7907
8054
|
break;
|
|
7908
8055
|
}
|
|
7909
8056
|
throw new Error('远端订单身份不匹配,请重新刷新');
|
|
7910
8057
|
case 47:
|
|
7911
|
-
|
|
8058
|
+
_context79.next = 49;
|
|
7912
8059
|
return this.order.completeLocalPaymentRefresh(orderToPersist);
|
|
7913
8060
|
case 49:
|
|
7914
|
-
|
|
8061
|
+
_context79.next = 53;
|
|
7915
8062
|
break;
|
|
7916
8063
|
case 51:
|
|
7917
|
-
|
|
8064
|
+
_context79.next = 53;
|
|
7918
8065
|
return this.order.upsertOrdersFromRemote([orderToPersist]);
|
|
7919
8066
|
case 53:
|
|
7920
|
-
|
|
8067
|
+
_context79.next = 55;
|
|
7921
8068
|
return this.order.getLocalOrderByLookup(lookup);
|
|
7922
8069
|
case 55:
|
|
7923
|
-
savedOrder =
|
|
8070
|
+
savedOrder = _context79.sent;
|
|
7924
8071
|
if (!(!savedOrder && fresh.order_id !== undefined && fresh.order_id !== null && String(fresh.order_id) !== String(lookup))) {
|
|
7925
|
-
|
|
8072
|
+
_context79.next = 60;
|
|
7926
8073
|
break;
|
|
7927
8074
|
}
|
|
7928
|
-
|
|
8075
|
+
_context79.next = 59;
|
|
7929
8076
|
return this.order.getLocalOrderByLookup(fresh.order_id);
|
|
7930
8077
|
case 59:
|
|
7931
|
-
savedOrder =
|
|
8078
|
+
savedOrder = _context79.sent;
|
|
7932
8079
|
case 60:
|
|
7933
8080
|
if (savedOrder) {
|
|
7934
|
-
|
|
8081
|
+
_context79.next = 63;
|
|
7935
8082
|
break;
|
|
7936
8083
|
}
|
|
7937
8084
|
this.logError("".concat(title, ": \u8BA2\u5355\u5199\u5165\u540E\u56DE\u8BFB\u5931\u8D25"), {
|
|
7938
8085
|
lookup: lookup,
|
|
7939
8086
|
remote_order_id: fresh.order_id
|
|
7940
8087
|
});
|
|
7941
|
-
return
|
|
8088
|
+
return _context79.abrupt("return", {
|
|
7942
8089
|
code: 500,
|
|
7943
8090
|
message: '订单写入后回读失败',
|
|
7944
8091
|
order: null
|
|
@@ -7948,54 +8095,54 @@ var Server = /*#__PURE__*/function () {
|
|
|
7948
8095
|
lookup: lookup,
|
|
7949
8096
|
remote_order_id: fresh.order_id
|
|
7950
8097
|
});
|
|
7951
|
-
return
|
|
8098
|
+
return _context79.abrupt("return", {
|
|
7952
8099
|
code: 200,
|
|
7953
8100
|
message: '',
|
|
7954
8101
|
order: savedOrder
|
|
7955
8102
|
});
|
|
7956
8103
|
case 67:
|
|
7957
|
-
|
|
7958
|
-
|
|
7959
|
-
backendError = this.extractBackendErrorResponse(
|
|
7960
|
-
errorRecord =
|
|
8104
|
+
_context79.prev = 67;
|
|
8105
|
+
_context79.t2 = _context79["catch"](7);
|
|
8106
|
+
backendError = this.extractBackendErrorResponse(_context79.t2);
|
|
8107
|
+
errorRecord = _context79.t2;
|
|
7961
8108
|
_responseStatusCode = typeof (errorRecord === null || errorRecord === void 0 || (_errorRecord$response = errorRecord.response) === null || _errorRecord$response === void 0 ? void 0 : _errorRecord$response.status) === 'number' ? errorRecord.response.status : undefined;
|
|
7962
8109
|
if (!(backendError || _responseStatusCode !== undefined)) {
|
|
7963
|
-
|
|
8110
|
+
_context79.next = 78;
|
|
7964
8111
|
break;
|
|
7965
8112
|
}
|
|
7966
8113
|
backendStatusCode = typeof (backendError === null || backendError === void 0 ? void 0 : backendError.status) === 'number' ? backendError.status : undefined;
|
|
7967
|
-
_code = this.normalizeRemoteSalesOrderErrorCode((
|
|
7968
|
-
_message2 = (backendError === null || backendError === void 0 ? void 0 : backendError.message) || this.getUnknownErrorMessage(
|
|
8114
|
+
_code = this.normalizeRemoteSalesOrderErrorCode((_ref85 = (_backendError$code2 = backendError === null || backendError === void 0 ? void 0 : backendError.code) !== null && _backendError$code2 !== void 0 ? _backendError$code2 : backendStatusCode) !== null && _ref85 !== void 0 ? _ref85 : _responseStatusCode);
|
|
8115
|
+
_message2 = (backendError === null || backendError === void 0 ? void 0 : backendError.message) || this.getUnknownErrorMessage(_context79.t2);
|
|
7969
8116
|
this.logInfo("".concat(title, ": \u540E\u7AEF\u8BA2\u5355\u67E5\u8BE2\u5931\u8D25"), {
|
|
7970
8117
|
lookup: lookup,
|
|
7971
8118
|
backendPath: backendPath,
|
|
7972
8119
|
code: _code,
|
|
7973
8120
|
message: _message2
|
|
7974
8121
|
});
|
|
7975
|
-
return
|
|
8122
|
+
return _context79.abrupt("return", {
|
|
7976
8123
|
code: _code,
|
|
7977
8124
|
message: _message2,
|
|
7978
8125
|
order: null
|
|
7979
8126
|
});
|
|
7980
8127
|
case 78:
|
|
7981
|
-
_message3 = this.getUnknownErrorMessage(
|
|
8128
|
+
_message3 = this.getUnknownErrorMessage(_context79.t2);
|
|
7982
8129
|
this.logInfo("".concat(title, ": \u8BF7\u6C42\u5931\u8D25"), {
|
|
7983
8130
|
lookup: lookup,
|
|
7984
8131
|
backendPath: backendPath,
|
|
7985
8132
|
error: _message3
|
|
7986
8133
|
});
|
|
7987
|
-
return
|
|
8134
|
+
return _context79.abrupt("return", {
|
|
7988
8135
|
code: 500,
|
|
7989
8136
|
message: _message3,
|
|
7990
8137
|
order: null
|
|
7991
8138
|
});
|
|
7992
8139
|
case 81:
|
|
7993
8140
|
case "end":
|
|
7994
|
-
return
|
|
8141
|
+
return _context79.stop();
|
|
7995
8142
|
}
|
|
7996
|
-
},
|
|
8143
|
+
}, _callee79, this, [[7, 67]]);
|
|
7997
8144
|
}));
|
|
7998
|
-
function fetchAndPersistSalesOrderByLookup(
|
|
8145
|
+
function fetchAndPersistSalesOrderByLookup(_x87, _x88, _x89, _x90) {
|
|
7999
8146
|
return _fetchAndPersistSalesOrderByLookup.apply(this, arguments);
|
|
8000
8147
|
}
|
|
8001
8148
|
return fetchAndPersistSalesOrderByLookup;
|
|
@@ -8057,34 +8204,34 @@ var Server = /*#__PURE__*/function () {
|
|
|
8057
8204
|
}, {
|
|
8058
8205
|
key: "handleUpdateLocalOrdersBatch",
|
|
8059
8206
|
value: (function () {
|
|
8060
|
-
var _handleUpdateLocalOrdersBatch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
8061
|
-
var _this$
|
|
8207
|
+
var _handleUpdateLocalOrdersBatch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee80(orderIds) {
|
|
8208
|
+
var _this$app21;
|
|
8062
8209
|
var existedBefore, _iterator13, _step13, id, fetched, message, fetchedMap, _iterator14, _step14, order, oid, freshOrders, succeedIds, failed, _iterator15, _step15, _id, fresh, _message4, overwritten, inserted;
|
|
8063
|
-
return _regeneratorRuntime().wrap(function
|
|
8064
|
-
while (1) switch (
|
|
8210
|
+
return _regeneratorRuntime().wrap(function _callee80$(_context80) {
|
|
8211
|
+
while (1) switch (_context80.prev = _context80.next) {
|
|
8065
8212
|
case 0:
|
|
8066
8213
|
this.logInfo('handleUpdateLocalOrdersBatch: 开始处理', {
|
|
8067
8214
|
count: orderIds.length,
|
|
8068
8215
|
orderIds: orderIds
|
|
8069
8216
|
});
|
|
8070
8217
|
if (this.order) {
|
|
8071
|
-
|
|
8218
|
+
_context80.next = 4;
|
|
8072
8219
|
break;
|
|
8073
8220
|
}
|
|
8074
8221
|
this.logError('handleUpdateLocalOrdersBatch: Order 模块未注册');
|
|
8075
|
-
return
|
|
8222
|
+
return _context80.abrupt("return", {
|
|
8076
8223
|
code: 500,
|
|
8077
8224
|
status: false,
|
|
8078
8225
|
message: 'Order 模块未注册',
|
|
8079
8226
|
data: null
|
|
8080
8227
|
});
|
|
8081
8228
|
case 4:
|
|
8082
|
-
if ((_this$
|
|
8083
|
-
|
|
8229
|
+
if ((_this$app21 = this.app) !== null && _this$app21 !== void 0 && _this$app21.request) {
|
|
8230
|
+
_context80.next = 7;
|
|
8084
8231
|
break;
|
|
8085
8232
|
}
|
|
8086
8233
|
this.logError('handleUpdateLocalOrdersBatch: app.request 不可用');
|
|
8087
|
-
return
|
|
8234
|
+
return _context80.abrupt("return", {
|
|
8088
8235
|
code: 500,
|
|
8089
8236
|
status: false,
|
|
8090
8237
|
message: 'app.request 不可用',
|
|
@@ -8107,21 +8254,21 @@ var Server = /*#__PURE__*/function () {
|
|
|
8107
8254
|
_iterator13.f();
|
|
8108
8255
|
}
|
|
8109
8256
|
fetched = [];
|
|
8110
|
-
|
|
8111
|
-
|
|
8257
|
+
_context80.prev = 11;
|
|
8258
|
+
_context80.next = 14;
|
|
8112
8259
|
return this.order.fetchOrdersByHttp(orderIds);
|
|
8113
8260
|
case 14:
|
|
8114
|
-
fetched =
|
|
8115
|
-
|
|
8261
|
+
fetched = _context80.sent;
|
|
8262
|
+
_context80.next = 22;
|
|
8116
8263
|
break;
|
|
8117
8264
|
case 17:
|
|
8118
|
-
|
|
8119
|
-
|
|
8120
|
-
message =
|
|
8265
|
+
_context80.prev = 17;
|
|
8266
|
+
_context80.t0 = _context80["catch"](11);
|
|
8267
|
+
message = _context80.t0 instanceof Error ? _context80.t0.message : String(_context80.t0);
|
|
8121
8268
|
this.logError('handleUpdateLocalOrdersBatch: 批量拉取失败', {
|
|
8122
8269
|
message: message
|
|
8123
8270
|
});
|
|
8124
|
-
return
|
|
8271
|
+
return _context80.abrupt("return", {
|
|
8125
8272
|
code: 500,
|
|
8126
8273
|
status: false,
|
|
8127
8274
|
message: message,
|
|
@@ -8131,36 +8278,36 @@ var Server = /*#__PURE__*/function () {
|
|
|
8131
8278
|
// 按返回结果中的 order_id 建索引,未命中即视为单笔失败
|
|
8132
8279
|
fetchedMap = new Map();
|
|
8133
8280
|
_iterator14 = _createForOfIteratorHelper(fetched);
|
|
8134
|
-
|
|
8281
|
+
_context80.prev = 24;
|
|
8135
8282
|
_iterator14.s();
|
|
8136
8283
|
case 26:
|
|
8137
8284
|
if ((_step14 = _iterator14.n()).done) {
|
|
8138
|
-
|
|
8285
|
+
_context80.next = 34;
|
|
8139
8286
|
break;
|
|
8140
8287
|
}
|
|
8141
8288
|
order = _step14.value;
|
|
8142
8289
|
oid = order === null || order === void 0 ? void 0 : order.order_id;
|
|
8143
8290
|
if (!(oid === undefined || oid === null)) {
|
|
8144
|
-
|
|
8291
|
+
_context80.next = 31;
|
|
8145
8292
|
break;
|
|
8146
8293
|
}
|
|
8147
|
-
return
|
|
8294
|
+
return _context80.abrupt("continue", 32);
|
|
8148
8295
|
case 31:
|
|
8149
8296
|
fetchedMap.set(String(oid), order);
|
|
8150
8297
|
case 32:
|
|
8151
|
-
|
|
8298
|
+
_context80.next = 26;
|
|
8152
8299
|
break;
|
|
8153
8300
|
case 34:
|
|
8154
|
-
|
|
8301
|
+
_context80.next = 39;
|
|
8155
8302
|
break;
|
|
8156
8303
|
case 36:
|
|
8157
|
-
|
|
8158
|
-
|
|
8159
|
-
_iterator14.e(
|
|
8304
|
+
_context80.prev = 36;
|
|
8305
|
+
_context80.t1 = _context80["catch"](24);
|
|
8306
|
+
_iterator14.e(_context80.t1);
|
|
8160
8307
|
case 39:
|
|
8161
|
-
|
|
8308
|
+
_context80.prev = 39;
|
|
8162
8309
|
_iterator14.f();
|
|
8163
|
-
return
|
|
8310
|
+
return _context80.finish(39);
|
|
8164
8311
|
case 42:
|
|
8165
8312
|
freshOrders = [];
|
|
8166
8313
|
succeedIds = [];
|
|
@@ -8186,23 +8333,23 @@ var Server = /*#__PURE__*/function () {
|
|
|
8186
8333
|
_iterator15.f();
|
|
8187
8334
|
}
|
|
8188
8335
|
if (!(freshOrders.length > 0)) {
|
|
8189
|
-
|
|
8336
|
+
_context80.next = 58;
|
|
8190
8337
|
break;
|
|
8191
8338
|
}
|
|
8192
|
-
|
|
8193
|
-
|
|
8339
|
+
_context80.prev = 48;
|
|
8340
|
+
_context80.next = 51;
|
|
8194
8341
|
return this.order.upsertOrdersFromRemote(freshOrders);
|
|
8195
8342
|
case 51:
|
|
8196
|
-
|
|
8343
|
+
_context80.next = 58;
|
|
8197
8344
|
break;
|
|
8198
8345
|
case 53:
|
|
8199
|
-
|
|
8200
|
-
|
|
8201
|
-
_message4 =
|
|
8346
|
+
_context80.prev = 53;
|
|
8347
|
+
_context80.t2 = _context80["catch"](48);
|
|
8348
|
+
_message4 = _context80.t2 instanceof Error ? _context80.t2.message : String(_context80.t2);
|
|
8202
8349
|
this.logError('handleUpdateLocalOrdersBatch: 合并写入失败', {
|
|
8203
8350
|
message: _message4
|
|
8204
8351
|
});
|
|
8205
|
-
return
|
|
8352
|
+
return _context80.abrupt("return", {
|
|
8206
8353
|
code: 500,
|
|
8207
8354
|
status: false,
|
|
8208
8355
|
message: _message4,
|
|
@@ -8221,7 +8368,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
8221
8368
|
insertedCount: inserted.length,
|
|
8222
8369
|
failedCount: failed.length
|
|
8223
8370
|
});
|
|
8224
|
-
return
|
|
8371
|
+
return _context80.abrupt("return", {
|
|
8225
8372
|
code: 200,
|
|
8226
8373
|
status: true,
|
|
8227
8374
|
message: '',
|
|
@@ -8233,11 +8380,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
8233
8380
|
});
|
|
8234
8381
|
case 62:
|
|
8235
8382
|
case "end":
|
|
8236
|
-
return
|
|
8383
|
+
return _context80.stop();
|
|
8237
8384
|
}
|
|
8238
|
-
},
|
|
8385
|
+
}, _callee80, this, [[11, 17], [24, 36, 39, 42], [48, 53]]);
|
|
8239
8386
|
}));
|
|
8240
|
-
function handleUpdateLocalOrdersBatch(
|
|
8387
|
+
function handleUpdateLocalOrdersBatch(_x91) {
|
|
8241
8388
|
return _handleUpdateLocalOrdersBatch.apply(this, arguments);
|
|
8242
8389
|
}
|
|
8243
8390
|
return handleUpdateLocalOrdersBatch;
|
|
@@ -8314,8 +8461,8 @@ var Server = /*#__PURE__*/function () {
|
|
|
8314
8461
|
}, {
|
|
8315
8462
|
key: "extractOrderDataFromCheckoutResponse",
|
|
8316
8463
|
value: function extractOrderDataFromCheckoutResponse(response) {
|
|
8317
|
-
var _response$
|
|
8318
|
-
var candidates = [response === null || response === void 0 || (_response$
|
|
8464
|
+
var _response$data6, _response$data7;
|
|
8465
|
+
var candidates = [response === null || response === void 0 || (_response$data6 = response.data) === null || _response$data6 === void 0 ? void 0 : _response$data6.order, response === null || response === void 0 || (_response$data7 = response.data) === null || _response$data7 === void 0 ? void 0 : _response$data7.sales, response === null || response === void 0 ? void 0 : response.data, response === null || response === void 0 ? void 0 : response.order, response === null || response === void 0 ? void 0 : response.sales, response];
|
|
8319
8466
|
for (var _i6 = 0, _candidates2 = candidates; _i6 < _candidates2.length; _i6++) {
|
|
8320
8467
|
var candidate = _candidates2[_i6];
|
|
8321
8468
|
if (!candidate || _typeof(candidate) !== 'object') continue;
|
|
@@ -8484,10 +8631,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
8484
8631
|
value: function extractBackendErrorResponse(error) {
|
|
8485
8632
|
var _error$response3,
|
|
8486
8633
|
_error$response4,
|
|
8487
|
-
|
|
8634
|
+
_this27 = this;
|
|
8488
8635
|
var candidates = [error === null || error === void 0 || (_error$response3 = error.response) === null || _error$response3 === void 0 ? void 0 : _error$response3.data, error === null || error === void 0 ? void 0 : error.data, error === null || error === void 0 || (_error$response4 = error.response) === null || _error$response4 === void 0 ? void 0 : _error$response4.body, error === null || error === void 0 ? void 0 : error.body];
|
|
8489
8636
|
return candidates.find(function (candidate) {
|
|
8490
|
-
return
|
|
8637
|
+
return _this27.isExplicitBackendErrorResponse(candidate);
|
|
8491
8638
|
}) || null;
|
|
8492
8639
|
}
|
|
8493
8640
|
}, {
|
|
@@ -8606,16 +8753,16 @@ var Server = /*#__PURE__*/function () {
|
|
|
8606
8753
|
}, {
|
|
8607
8754
|
key: "recomputeAndNotifyFloorPlanQuery",
|
|
8608
8755
|
value: (function () {
|
|
8609
|
-
var _recomputeAndNotifyFloorPlanQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
8756
|
+
var _recomputeAndNotifyFloorPlanQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee81() {
|
|
8610
8757
|
var _iterator17, _step17, _step17$value, subscriberId, sub, result, errorMessage;
|
|
8611
|
-
return _regeneratorRuntime().wrap(function
|
|
8612
|
-
while (1) switch (
|
|
8758
|
+
return _regeneratorRuntime().wrap(function _callee81$(_context81) {
|
|
8759
|
+
while (1) switch (_context81.prev = _context81.next) {
|
|
8613
8760
|
case 0:
|
|
8614
8761
|
if (!(this.floorPlanQuerySubscribers.size === 0)) {
|
|
8615
|
-
|
|
8762
|
+
_context81.next = 2;
|
|
8616
8763
|
break;
|
|
8617
8764
|
}
|
|
8618
|
-
return
|
|
8765
|
+
return _context81.abrupt("return");
|
|
8619
8766
|
case 2:
|
|
8620
8767
|
this.logInfo('recomputeAndNotifyFloorPlanQuery: 开始推送', {
|
|
8621
8768
|
subscriberCount: this.floorPlanQuerySubscribers.size
|
|
@@ -8645,9 +8792,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
8645
8792
|
}
|
|
8646
8793
|
case 5:
|
|
8647
8794
|
case "end":
|
|
8648
|
-
return
|
|
8795
|
+
return _context81.stop();
|
|
8649
8796
|
}
|
|
8650
|
-
},
|
|
8797
|
+
}, _callee81, this);
|
|
8651
8798
|
}));
|
|
8652
8799
|
function recomputeAndNotifyFloorPlanQuery() {
|
|
8653
8800
|
return _recomputeAndNotifyFloorPlanQuery.apply(this, arguments);
|
|
@@ -8677,20 +8824,20 @@ var Server = /*#__PURE__*/function () {
|
|
|
8677
8824
|
* filter 逻辑暂为 mock,仅记录参数
|
|
8678
8825
|
*/
|
|
8679
8826
|
function () {
|
|
8680
|
-
var _computeOrderQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
8827
|
+
var _computeOrderQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee82(data) {
|
|
8681
8828
|
var rawList, result;
|
|
8682
|
-
return _regeneratorRuntime().wrap(function
|
|
8683
|
-
while (1) switch (
|
|
8829
|
+
return _regeneratorRuntime().wrap(function _callee82$(_context82) {
|
|
8830
|
+
while (1) switch (_context82.prev = _context82.next) {
|
|
8684
8831
|
case 0:
|
|
8685
8832
|
this.logInfo('computeOrderQueryResult: 开始过滤', {
|
|
8686
8833
|
data: data
|
|
8687
8834
|
});
|
|
8688
8835
|
if (this.order) {
|
|
8689
|
-
|
|
8836
|
+
_context82.next = 4;
|
|
8690
8837
|
break;
|
|
8691
8838
|
}
|
|
8692
8839
|
this.logError('computeOrderQueryResult: Order 模块未注册');
|
|
8693
|
-
return
|
|
8840
|
+
return _context82.abrupt("return", {
|
|
8694
8841
|
code: 500,
|
|
8695
8842
|
message: 'Order 模块未注册',
|
|
8696
8843
|
data: {
|
|
@@ -8722,7 +8869,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
8722
8869
|
skip: result.skip,
|
|
8723
8870
|
rejected: result.rejected
|
|
8724
8871
|
});
|
|
8725
|
-
return
|
|
8872
|
+
return _context82.abrupt("return", {
|
|
8726
8873
|
code: 200,
|
|
8727
8874
|
data: result,
|
|
8728
8875
|
message: '',
|
|
@@ -8730,11 +8877,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
8730
8877
|
});
|
|
8731
8878
|
case 10:
|
|
8732
8879
|
case "end":
|
|
8733
|
-
return
|
|
8880
|
+
return _context82.stop();
|
|
8734
8881
|
}
|
|
8735
|
-
},
|
|
8882
|
+
}, _callee82, this);
|
|
8736
8883
|
}));
|
|
8737
|
-
function computeOrderQueryResult(
|
|
8884
|
+
function computeOrderQueryResult(_x92) {
|
|
8738
8885
|
return _computeOrderQueryResult.apply(this, arguments);
|
|
8739
8886
|
}
|
|
8740
8887
|
return computeOrderQueryResult;
|
|
@@ -8747,17 +8894,17 @@ var Server = /*#__PURE__*/function () {
|
|
|
8747
8894
|
}, {
|
|
8748
8895
|
key: "computeBookingQueryResult",
|
|
8749
8896
|
value: (function () {
|
|
8750
|
-
var _computeBookingQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
8897
|
+
var _computeBookingQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee83(data) {
|
|
8751
8898
|
var rawOrders, result;
|
|
8752
|
-
return _regeneratorRuntime().wrap(function
|
|
8753
|
-
while (1) switch (
|
|
8899
|
+
return _regeneratorRuntime().wrap(function _callee83$(_context83) {
|
|
8900
|
+
while (1) switch (_context83.prev = _context83.next) {
|
|
8754
8901
|
case 0:
|
|
8755
8902
|
if (this.order) {
|
|
8756
|
-
|
|
8903
|
+
_context83.next = 3;
|
|
8757
8904
|
break;
|
|
8758
8905
|
}
|
|
8759
8906
|
this.logError('computeBookingQueryResult: Order 模块未注册');
|
|
8760
|
-
return
|
|
8907
|
+
return _context83.abrupt("return", {
|
|
8761
8908
|
code: 500,
|
|
8762
8909
|
message: 'Order 模块未注册',
|
|
8763
8910
|
data: {
|
|
@@ -8776,7 +8923,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
8776
8923
|
size: result.size,
|
|
8777
8924
|
skip: result.skip
|
|
8778
8925
|
});
|
|
8779
|
-
return
|
|
8926
|
+
return _context83.abrupt("return", {
|
|
8780
8927
|
code: 200,
|
|
8781
8928
|
data: result,
|
|
8782
8929
|
message: '',
|
|
@@ -8784,11 +8931,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
8784
8931
|
});
|
|
8785
8932
|
case 8:
|
|
8786
8933
|
case "end":
|
|
8787
|
-
return
|
|
8934
|
+
return _context83.stop();
|
|
8788
8935
|
}
|
|
8789
|
-
},
|
|
8936
|
+
}, _callee83, this);
|
|
8790
8937
|
}));
|
|
8791
|
-
function computeBookingQueryResult(
|
|
8938
|
+
function computeBookingQueryResult(_x93) {
|
|
8792
8939
|
return _computeBookingQueryResult.apply(this, arguments);
|
|
8793
8940
|
}
|
|
8794
8941
|
return computeBookingQueryResult;
|
|
@@ -8847,12 +8994,12 @@ var Server = /*#__PURE__*/function () {
|
|
|
8847
8994
|
}, {
|
|
8848
8995
|
key: "computeProductQueryResult",
|
|
8849
8996
|
value: (function () {
|
|
8850
|
-
var _computeProductQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
8997
|
+
var _computeProductQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee84(context, options) {
|
|
8851
8998
|
var _menu_list_ids$length3,
|
|
8852
|
-
|
|
8999
|
+
_this28 = this;
|
|
8853
9000
|
var tTotal, menu_list_ids, ids, schedule_date, schedule_datetime, customer_id, extension_type, product_id, application_code, strategy_context, isVisibleProduct, queryIds, startupPreloadTask, formatterContext, uniqueIds, _tPrice, productsWithPrice, _filteredProducts, extensionFilteredProducts, _published$find, pid, _tPrice2, allProductsWithPrice, published, item, _tPrice3, _filteredProducts2, _tStatus, _beforeStatusCount, _tExtensionType, _beforeExtensionTypeCount, _tSort, activeMenuList, tMenu, getActiveMenus, tFilter, productScope, scopedProductIds, tPrice, filteredProducts, tStatus, beforeStatusCount, tExtensionType, beforeExtensionTypeCount, tSort;
|
|
8854
|
-
return _regeneratorRuntime().wrap(function
|
|
8855
|
-
while (1) switch (
|
|
9001
|
+
return _regeneratorRuntime().wrap(function _callee84$(_context84) {
|
|
9002
|
+
while (1) switch (_context84.prev = _context84.next) {
|
|
8856
9003
|
case 0:
|
|
8857
9004
|
tTotal = performance.now();
|
|
8858
9005
|
menu_list_ids = context.menu_list_ids, ids = context.ids, schedule_date = context.schedule_date, schedule_datetime = context.schedule_datetime, customer_id = context.customer_id, extension_type = context.extension_type, product_id = context.product_id, application_code = context.application_code, strategy_context = context.strategy_context; // 仅 Kiosk 查询额外按商品销售渠道过滤。
|
|
@@ -8881,10 +9028,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
8881
9028
|
// SQLite/IndexDB,造成 preload 读到空数据并重复请求。正常运行期该字段为 null,不增加等待。
|
|
8882
9029
|
startupPreloadTask = this.startupModulePreloadInFlight;
|
|
8883
9030
|
if (!startupPreloadTask) {
|
|
8884
|
-
|
|
9031
|
+
_context84.next = 9;
|
|
8885
9032
|
break;
|
|
8886
9033
|
}
|
|
8887
|
-
|
|
9034
|
+
_context84.next = 9;
|
|
8888
9035
|
return startupPreloadTask;
|
|
8889
9036
|
case 9:
|
|
8890
9037
|
// Menu/Schedule preload 会替换 store 中的数组;必须在等待完成后再读取,
|
|
@@ -8896,28 +9043,28 @@ var Server = /*#__PURE__*/function () {
|
|
|
8896
9043
|
strategy_context: strategy_context
|
|
8897
9044
|
});
|
|
8898
9045
|
if (this.products) {
|
|
8899
|
-
|
|
9046
|
+
_context84.next = 13;
|
|
8900
9047
|
break;
|
|
8901
9048
|
}
|
|
8902
9049
|
this.logError('computeProductQueryResult: Products 模块未注册');
|
|
8903
|
-
return
|
|
9050
|
+
return _context84.abrupt("return", {
|
|
8904
9051
|
message: 'Products 模块未注册',
|
|
8905
9052
|
data: this.buildProductQueryResultPayload([], 0)
|
|
8906
9053
|
});
|
|
8907
9054
|
case 13:
|
|
8908
9055
|
if (!(queryIds.length > 0)) {
|
|
8909
|
-
|
|
9056
|
+
_context84.next = 25;
|
|
8910
9057
|
break;
|
|
8911
9058
|
}
|
|
8912
9059
|
uniqueIds = Array.from(new Set(queryIds));
|
|
8913
9060
|
_tPrice = performance.now();
|
|
8914
|
-
|
|
9061
|
+
_context84.next = 18;
|
|
8915
9062
|
return this.products.getProductsWithPrice(schedule_date, formatterContext, {
|
|
8916
9063
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds,
|
|
8917
9064
|
productIds: uniqueIds
|
|
8918
9065
|
});
|
|
8919
9066
|
case 18:
|
|
8920
|
-
productsWithPrice =
|
|
9067
|
+
productsWithPrice = _context84.sent;
|
|
8921
9068
|
perfMark('computeQuery.getProductsWithPrice(ids)', performance.now() - _tPrice, {
|
|
8922
9069
|
count: productsWithPrice.length,
|
|
8923
9070
|
ids: uniqueIds
|
|
@@ -8935,7 +9082,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
8935
9082
|
ids: uniqueIds,
|
|
8936
9083
|
count: extensionFilteredProducts.length
|
|
8937
9084
|
});
|
|
8938
|
-
return
|
|
9085
|
+
return _context84.abrupt("return", {
|
|
8939
9086
|
code: 200,
|
|
8940
9087
|
data: this.buildProductQueryResultPayload(extensionFilteredProducts),
|
|
8941
9088
|
message: '',
|
|
@@ -8943,17 +9090,17 @@ var Server = /*#__PURE__*/function () {
|
|
|
8943
9090
|
});
|
|
8944
9091
|
case 25:
|
|
8945
9092
|
if (!(product_id != null && Number.isFinite(Number(product_id)))) {
|
|
8946
|
-
|
|
9093
|
+
_context84.next = 37;
|
|
8947
9094
|
break;
|
|
8948
9095
|
}
|
|
8949
9096
|
pid = Number(product_id);
|
|
8950
9097
|
_tPrice2 = performance.now();
|
|
8951
|
-
|
|
9098
|
+
_context84.next = 30;
|
|
8952
9099
|
return this.products.getProductsWithPrice(schedule_date, formatterContext, {
|
|
8953
9100
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds
|
|
8954
9101
|
});
|
|
8955
9102
|
case 30:
|
|
8956
|
-
allProductsWithPrice =
|
|
9103
|
+
allProductsWithPrice = _context84.sent;
|
|
8957
9104
|
perfMark('computeQuery.getProductsWithPrice(single)', performance.now() - _tPrice2, {
|
|
8958
9105
|
count: allProductsWithPrice.length,
|
|
8959
9106
|
productId: pid
|
|
@@ -8971,7 +9118,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
8971
9118
|
productId: pid,
|
|
8972
9119
|
found: !!item
|
|
8973
9120
|
});
|
|
8974
|
-
return
|
|
9121
|
+
return _context84.abrupt("return", {
|
|
8975
9122
|
code: 200,
|
|
8976
9123
|
data: item,
|
|
8977
9124
|
message: item ? '' : '商品不存在或未发布',
|
|
@@ -8979,16 +9126,16 @@ var Server = /*#__PURE__*/function () {
|
|
|
8979
9126
|
});
|
|
8980
9127
|
case 37:
|
|
8981
9128
|
if (!this.shouldQueryProductsByExtensionTypes(extension_type)) {
|
|
8982
|
-
|
|
9129
|
+
_context84.next = 57;
|
|
8983
9130
|
break;
|
|
8984
9131
|
}
|
|
8985
9132
|
_tPrice3 = performance.now();
|
|
8986
|
-
|
|
9133
|
+
_context84.next = 41;
|
|
8987
9134
|
return this.products.getProductsWithPrice(schedule_date, formatterContext, {
|
|
8988
9135
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds
|
|
8989
9136
|
});
|
|
8990
9137
|
case 41:
|
|
8991
|
-
_filteredProducts2 =
|
|
9138
|
+
_filteredProducts2 = _context84.sent;
|
|
8992
9139
|
perfMark('computeQuery.getProductsWithPrice(extensionType)', performance.now() - _tPrice3, {
|
|
8993
9140
|
count: _filteredProducts2.length,
|
|
8994
9141
|
extension_type: extension_type
|
|
@@ -9025,7 +9172,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
9025
9172
|
filteredCount: _filteredProducts2.length,
|
|
9026
9173
|
extension_type: extension_type
|
|
9027
9174
|
});
|
|
9028
|
-
return
|
|
9175
|
+
return _context84.abrupt("return", {
|
|
9029
9176
|
code: 200,
|
|
9030
9177
|
data: this.buildProductQueryResultPayload(_filteredProducts2),
|
|
9031
9178
|
message: '',
|
|
@@ -9033,50 +9180,50 @@ var Server = /*#__PURE__*/function () {
|
|
|
9033
9180
|
});
|
|
9034
9181
|
case 57:
|
|
9035
9182
|
if (this.menu) {
|
|
9036
|
-
|
|
9183
|
+
_context84.next = 60;
|
|
9037
9184
|
break;
|
|
9038
9185
|
}
|
|
9039
9186
|
this.logError('computeProductQueryResult: Menu 模块未注册');
|
|
9040
|
-
return
|
|
9187
|
+
return _context84.abrupt("return", {
|
|
9041
9188
|
message: 'Menu 模块未注册',
|
|
9042
9189
|
data: this.buildProductQueryResultPayload([], 0)
|
|
9043
9190
|
});
|
|
9044
9191
|
case 60:
|
|
9045
9192
|
if (this.schedule) {
|
|
9046
|
-
|
|
9193
|
+
_context84.next = 63;
|
|
9047
9194
|
break;
|
|
9048
9195
|
}
|
|
9049
9196
|
this.logError('computeProductQueryResult: Schedule 模块未注册');
|
|
9050
|
-
return
|
|
9197
|
+
return _context84.abrupt("return", {
|
|
9051
9198
|
message: 'Schedule 模块未注册',
|
|
9052
9199
|
data: this.buildProductQueryResultPayload([], 0)
|
|
9053
9200
|
});
|
|
9054
9201
|
case 63:
|
|
9055
9202
|
activeMenuList = [];
|
|
9056
9203
|
if (!(menu_list_ids && Array.isArray(menu_list_ids) && menu_list_ids.length > 0)) {
|
|
9057
|
-
|
|
9204
|
+
_context84.next = 76;
|
|
9058
9205
|
break;
|
|
9059
9206
|
}
|
|
9060
9207
|
tMenu = performance.now();
|
|
9061
9208
|
getActiveMenus = function getActiveMenus() {
|
|
9062
|
-
return
|
|
9063
|
-
var
|
|
9064
|
-
return ((
|
|
9209
|
+
return _this28.menu.getMenuByIds(menu_list_ids).filter(function (menu) {
|
|
9210
|
+
var _this28$schedule;
|
|
9211
|
+
return ((_this28$schedule = _this28.schedule) === null || _this28$schedule === void 0 ? void 0 : _this28$schedule.getDateIsInSchedule(schedule_datetime, menu.schedule)) || false;
|
|
9065
9212
|
});
|
|
9066
9213
|
};
|
|
9067
9214
|
activeMenuList = getActiveMenus();
|
|
9068
|
-
|
|
9069
|
-
if (!
|
|
9070
|
-
|
|
9215
|
+
_context84.t0 = !activeMenuList.length;
|
|
9216
|
+
if (!_context84.t0) {
|
|
9217
|
+
_context84.next = 73;
|
|
9071
9218
|
break;
|
|
9072
9219
|
}
|
|
9073
|
-
|
|
9220
|
+
_context84.next = 72;
|
|
9074
9221
|
return this.refreshMenuScheduleCacheAfterEmptyResult();
|
|
9075
9222
|
case 72:
|
|
9076
|
-
|
|
9223
|
+
_context84.t0 = _context84.sent;
|
|
9077
9224
|
case 73:
|
|
9078
|
-
if (!
|
|
9079
|
-
|
|
9225
|
+
if (!_context84.t0) {
|
|
9226
|
+
_context84.next = 75;
|
|
9080
9227
|
break;
|
|
9081
9228
|
}
|
|
9082
9229
|
activeMenuList = getActiveMenus();
|
|
@@ -9096,22 +9243,22 @@ var Server = /*#__PURE__*/function () {
|
|
|
9096
9243
|
});
|
|
9097
9244
|
tPrice = performance.now();
|
|
9098
9245
|
if (!(scopedProductIds.length > 0)) {
|
|
9099
|
-
|
|
9246
|
+
_context84.next = 87;
|
|
9100
9247
|
break;
|
|
9101
9248
|
}
|
|
9102
|
-
|
|
9249
|
+
_context84.next = 84;
|
|
9103
9250
|
return this.products.getProductsWithPrice(schedule_date, formatterContext, {
|
|
9104
9251
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds,
|
|
9105
9252
|
productIds: productScope.isAllProducts ? undefined : scopedProductIds
|
|
9106
9253
|
});
|
|
9107
9254
|
case 84:
|
|
9108
|
-
|
|
9109
|
-
|
|
9255
|
+
_context84.t1 = _context84.sent;
|
|
9256
|
+
_context84.next = 88;
|
|
9110
9257
|
break;
|
|
9111
9258
|
case 87:
|
|
9112
|
-
|
|
9259
|
+
_context84.t1 = [];
|
|
9113
9260
|
case 88:
|
|
9114
|
-
filteredProducts =
|
|
9261
|
+
filteredProducts = _context84.t1;
|
|
9115
9262
|
perfMark('computeQuery.getProductsWithPrice', performance.now() - tPrice, {
|
|
9116
9263
|
count: filteredProducts.length,
|
|
9117
9264
|
scopedProductCount: scopedProductIds.length
|
|
@@ -9150,7 +9297,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
9150
9297
|
filteredCount: filteredProducts.length,
|
|
9151
9298
|
activeMenuCount: activeMenuList.length
|
|
9152
9299
|
});
|
|
9153
|
-
return
|
|
9300
|
+
return _context84.abrupt("return", {
|
|
9154
9301
|
code: 200,
|
|
9155
9302
|
data: this.buildProductQueryResultPayload(filteredProducts),
|
|
9156
9303
|
message: '',
|
|
@@ -9158,11 +9305,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
9158
9305
|
});
|
|
9159
9306
|
case 104:
|
|
9160
9307
|
case "end":
|
|
9161
|
-
return
|
|
9308
|
+
return _context84.stop();
|
|
9162
9309
|
}
|
|
9163
|
-
},
|
|
9310
|
+
}, _callee84, this);
|
|
9164
9311
|
}));
|
|
9165
|
-
function computeProductQueryResult(
|
|
9312
|
+
function computeProductQueryResult(_x94, _x95) {
|
|
9166
9313
|
return _computeProductQueryResult.apply(this, arguments);
|
|
9167
9314
|
}
|
|
9168
9315
|
return computeProductQueryResult;
|
|
@@ -9200,74 +9347,74 @@ var Server = /*#__PURE__*/function () {
|
|
|
9200
9347
|
}, {
|
|
9201
9348
|
key: "recomputeAndNotifyProductQuery",
|
|
9202
9349
|
value: (function () {
|
|
9203
|
-
var _recomputeAndNotifyProductQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
9350
|
+
var _recomputeAndNotifyProductQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee85(options) {
|
|
9204
9351
|
var _iterator18, _step18, _step18$value, subscriberId, subscriber, result, errorMessage;
|
|
9205
|
-
return _regeneratorRuntime().wrap(function
|
|
9206
|
-
while (1) switch (
|
|
9352
|
+
return _regeneratorRuntime().wrap(function _callee85$(_context85) {
|
|
9353
|
+
while (1) switch (_context85.prev = _context85.next) {
|
|
9207
9354
|
case 0:
|
|
9208
9355
|
if (!(this.productQuerySubscribers.size === 0)) {
|
|
9209
|
-
|
|
9356
|
+
_context85.next = 2;
|
|
9210
9357
|
break;
|
|
9211
9358
|
}
|
|
9212
|
-
return
|
|
9359
|
+
return _context85.abrupt("return");
|
|
9213
9360
|
case 2:
|
|
9214
9361
|
this.logInfo('recomputeAndNotifyProductQuery: 开始推送', {
|
|
9215
9362
|
subscriberCount: this.productQuerySubscribers.size,
|
|
9216
9363
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds
|
|
9217
9364
|
});
|
|
9218
9365
|
_iterator18 = _createForOfIteratorHelper(this.productQuerySubscribers.entries());
|
|
9219
|
-
|
|
9366
|
+
_context85.prev = 4;
|
|
9220
9367
|
_iterator18.s();
|
|
9221
9368
|
case 6:
|
|
9222
9369
|
if ((_step18 = _iterator18.n()).done) {
|
|
9223
|
-
|
|
9370
|
+
_context85.next = 23;
|
|
9224
9371
|
break;
|
|
9225
9372
|
}
|
|
9226
9373
|
_step18$value = _slicedToArray(_step18.value, 2), subscriberId = _step18$value[0], subscriber = _step18$value[1];
|
|
9227
|
-
|
|
9228
|
-
|
|
9374
|
+
_context85.prev = 8;
|
|
9375
|
+
_context85.next = 11;
|
|
9229
9376
|
return this.computeProductQueryResult(subscriber.context, {
|
|
9230
9377
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds
|
|
9231
9378
|
});
|
|
9232
9379
|
case 11:
|
|
9233
|
-
result =
|
|
9234
|
-
|
|
9380
|
+
result = _context85.sent;
|
|
9381
|
+
_context85.next = 14;
|
|
9235
9382
|
return subscriber.callback(result);
|
|
9236
9383
|
case 14:
|
|
9237
9384
|
this.logInfo('recomputeAndNotifyProductQuery: 已推送', {
|
|
9238
9385
|
subscriberId: subscriberId
|
|
9239
9386
|
});
|
|
9240
|
-
|
|
9387
|
+
_context85.next = 21;
|
|
9241
9388
|
break;
|
|
9242
9389
|
case 17:
|
|
9243
|
-
|
|
9244
|
-
|
|
9245
|
-
errorMessage =
|
|
9390
|
+
_context85.prev = 17;
|
|
9391
|
+
_context85.t0 = _context85["catch"](8);
|
|
9392
|
+
errorMessage = _context85.t0 instanceof Error ? _context85.t0.message : String(_context85.t0);
|
|
9246
9393
|
this.logError('recomputeAndNotifyProductQuery: 推送失败', {
|
|
9247
9394
|
subscriberId: subscriberId,
|
|
9248
9395
|
error: errorMessage
|
|
9249
9396
|
});
|
|
9250
9397
|
case 21:
|
|
9251
|
-
|
|
9398
|
+
_context85.next = 6;
|
|
9252
9399
|
break;
|
|
9253
9400
|
case 23:
|
|
9254
|
-
|
|
9401
|
+
_context85.next = 28;
|
|
9255
9402
|
break;
|
|
9256
9403
|
case 25:
|
|
9257
|
-
|
|
9258
|
-
|
|
9259
|
-
_iterator18.e(
|
|
9404
|
+
_context85.prev = 25;
|
|
9405
|
+
_context85.t1 = _context85["catch"](4);
|
|
9406
|
+
_iterator18.e(_context85.t1);
|
|
9260
9407
|
case 28:
|
|
9261
|
-
|
|
9408
|
+
_context85.prev = 28;
|
|
9262
9409
|
_iterator18.f();
|
|
9263
|
-
return
|
|
9410
|
+
return _context85.finish(28);
|
|
9264
9411
|
case 31:
|
|
9265
9412
|
case "end":
|
|
9266
|
-
return
|
|
9413
|
+
return _context85.stop();
|
|
9267
9414
|
}
|
|
9268
|
-
},
|
|
9415
|
+
}, _callee85, this, [[4, 25, 28, 31], [8, 17]]);
|
|
9269
9416
|
}));
|
|
9270
|
-
function recomputeAndNotifyProductQuery(
|
|
9417
|
+
function recomputeAndNotifyProductQuery(_x96) {
|
|
9271
9418
|
return _recomputeAndNotifyProductQuery.apply(this, arguments);
|
|
9272
9419
|
}
|
|
9273
9420
|
return recomputeAndNotifyProductQuery;
|
|
@@ -9279,16 +9426,16 @@ var Server = /*#__PURE__*/function () {
|
|
|
9279
9426
|
}, {
|
|
9280
9427
|
key: "recomputeAndNotifyOrderQuery",
|
|
9281
9428
|
value: (function () {
|
|
9282
|
-
var _recomputeAndNotifyOrderQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
9429
|
+
var _recomputeAndNotifyOrderQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee86() {
|
|
9283
9430
|
var notifyStartAt, _iterator19, _step19, _step19$value, subscriberId, subscriber, computeStartAt, result, computeEndAt, callbackStartAt, callbackEndAt, errorMessage, notifyEndAt;
|
|
9284
|
-
return _regeneratorRuntime().wrap(function
|
|
9285
|
-
while (1) switch (
|
|
9431
|
+
return _regeneratorRuntime().wrap(function _callee86$(_context86) {
|
|
9432
|
+
while (1) switch (_context86.prev = _context86.next) {
|
|
9286
9433
|
case 0:
|
|
9287
9434
|
if (!(this.orderQuerySubscribers.size === 0)) {
|
|
9288
|
-
|
|
9435
|
+
_context86.next = 2;
|
|
9289
9436
|
break;
|
|
9290
9437
|
}
|
|
9291
|
-
return
|
|
9438
|
+
return _context86.abrupt("return");
|
|
9292
9439
|
case 2:
|
|
9293
9440
|
notifyStartAt = Date.now();
|
|
9294
9441
|
this.logInfo('recomputeAndNotifyOrderQuery: 开始推送', {
|
|
@@ -9296,20 +9443,20 @@ var Server = /*#__PURE__*/function () {
|
|
|
9296
9443
|
notifyStartAt: new Date(notifyStartAt).toISOString()
|
|
9297
9444
|
});
|
|
9298
9445
|
_iterator19 = _createForOfIteratorHelper(this.orderQuerySubscribers.entries());
|
|
9299
|
-
|
|
9446
|
+
_context86.prev = 5;
|
|
9300
9447
|
_iterator19.s();
|
|
9301
9448
|
case 7:
|
|
9302
9449
|
if ((_step19 = _iterator19.n()).done) {
|
|
9303
|
-
|
|
9450
|
+
_context86.next = 27;
|
|
9304
9451
|
break;
|
|
9305
9452
|
}
|
|
9306
9453
|
_step19$value = _slicedToArray(_step19.value, 2), subscriberId = _step19$value[0], subscriber = _step19$value[1];
|
|
9307
|
-
|
|
9454
|
+
_context86.prev = 9;
|
|
9308
9455
|
computeStartAt = Date.now();
|
|
9309
|
-
|
|
9456
|
+
_context86.next = 13;
|
|
9310
9457
|
return this.computeOrderQueryResult(subscriber.context);
|
|
9311
9458
|
case 13:
|
|
9312
|
-
result =
|
|
9459
|
+
result = _context86.sent;
|
|
9313
9460
|
computeEndAt = Date.now();
|
|
9314
9461
|
callbackStartAt = Date.now();
|
|
9315
9462
|
subscriber.callback(result);
|
|
@@ -9320,30 +9467,30 @@ var Server = /*#__PURE__*/function () {
|
|
|
9320
9467
|
callbackDurationMs: callbackEndAt - callbackStartAt,
|
|
9321
9468
|
totalDurationMs: callbackEndAt - computeStartAt
|
|
9322
9469
|
});
|
|
9323
|
-
|
|
9470
|
+
_context86.next = 25;
|
|
9324
9471
|
break;
|
|
9325
9472
|
case 21:
|
|
9326
|
-
|
|
9327
|
-
|
|
9328
|
-
errorMessage =
|
|
9473
|
+
_context86.prev = 21;
|
|
9474
|
+
_context86.t0 = _context86["catch"](9);
|
|
9475
|
+
errorMessage = _context86.t0 instanceof Error ? _context86.t0.message : String(_context86.t0);
|
|
9329
9476
|
this.logError('recomputeAndNotifyOrderQuery: 推送失败', {
|
|
9330
9477
|
subscriberId: subscriberId,
|
|
9331
9478
|
error: errorMessage
|
|
9332
9479
|
});
|
|
9333
9480
|
case 25:
|
|
9334
|
-
|
|
9481
|
+
_context86.next = 7;
|
|
9335
9482
|
break;
|
|
9336
9483
|
case 27:
|
|
9337
|
-
|
|
9484
|
+
_context86.next = 32;
|
|
9338
9485
|
break;
|
|
9339
9486
|
case 29:
|
|
9340
|
-
|
|
9341
|
-
|
|
9342
|
-
_iterator19.e(
|
|
9487
|
+
_context86.prev = 29;
|
|
9488
|
+
_context86.t1 = _context86["catch"](5);
|
|
9489
|
+
_iterator19.e(_context86.t1);
|
|
9343
9490
|
case 32:
|
|
9344
|
-
|
|
9491
|
+
_context86.prev = 32;
|
|
9345
9492
|
_iterator19.f();
|
|
9346
|
-
return
|
|
9493
|
+
return _context86.finish(32);
|
|
9347
9494
|
case 35:
|
|
9348
9495
|
notifyEndAt = Date.now();
|
|
9349
9496
|
this.logInfo('recomputeAndNotifyOrderQuery: 推送完成', {
|
|
@@ -9352,9 +9499,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
9352
9499
|
});
|
|
9353
9500
|
case 37:
|
|
9354
9501
|
case "end":
|
|
9355
|
-
return
|
|
9502
|
+
return _context86.stop();
|
|
9356
9503
|
}
|
|
9357
|
-
},
|
|
9504
|
+
}, _callee86, this, [[5, 29, 32, 35], [9, 21]]);
|
|
9358
9505
|
}));
|
|
9359
9506
|
function recomputeAndNotifyOrderQuery() {
|
|
9360
9507
|
return _recomputeAndNotifyOrderQuery.apply(this, arguments);
|
|
@@ -9372,7 +9519,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
9372
9519
|
}, {
|
|
9373
9520
|
key: "notifySalesSearchSubscribers",
|
|
9374
9521
|
value: function notifySalesSearchSubscribers(payload) {
|
|
9375
|
-
var
|
|
9522
|
+
var _this29 = this;
|
|
9376
9523
|
if (this.salesSearchSubscribers.size === 0) return;
|
|
9377
9524
|
var changedOrders = this.extractChangedOrdersFromPayload(payload);
|
|
9378
9525
|
if (changedOrders.length === 0) {
|
|
@@ -9390,21 +9537,21 @@ var Server = /*#__PURE__*/function () {
|
|
|
9390
9537
|
subscriber = _step20$value[1];
|
|
9391
9538
|
try {
|
|
9392
9539
|
var changedVisibleOrders = changedOrders.filter(function (order) {
|
|
9393
|
-
var orderId =
|
|
9540
|
+
var orderId = _this29.getSalesSearchOrderId(order);
|
|
9394
9541
|
return !!orderId && subscriber.visibleOrderIds.has(orderId);
|
|
9395
9542
|
});
|
|
9396
9543
|
if (changedVisibleOrders.length === 0) {
|
|
9397
9544
|
return 1; // continue
|
|
9398
9545
|
}
|
|
9399
|
-
subscriber.callback(
|
|
9400
|
-
|
|
9546
|
+
subscriber.callback(_this29.buildSalesSearchDeltaResponse(subscriber, changedVisibleOrders));
|
|
9547
|
+
_this29.logInfo('notifySalesSearchSubscribers: 已推送 delta', {
|
|
9401
9548
|
subscriberId: subscriberId,
|
|
9402
9549
|
kind: subscriber.kind,
|
|
9403
9550
|
count: changedVisibleOrders.length
|
|
9404
9551
|
});
|
|
9405
9552
|
} catch (error) {
|
|
9406
9553
|
var errorMessage = error instanceof Error ? error.message : String(error);
|
|
9407
|
-
|
|
9554
|
+
_this29.logError('notifySalesSearchSubscribers: 推送失败', {
|
|
9408
9555
|
subscriberId: subscriberId,
|
|
9409
9556
|
error: errorMessage
|
|
9410
9557
|
});
|
|
@@ -9495,67 +9642,67 @@ var Server = /*#__PURE__*/function () {
|
|
|
9495
9642
|
}, {
|
|
9496
9643
|
key: "recomputeAndNotifyBookingQuery",
|
|
9497
9644
|
value: (function () {
|
|
9498
|
-
var _recomputeAndNotifyBookingQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
9645
|
+
var _recomputeAndNotifyBookingQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee87() {
|
|
9499
9646
|
var _iterator21, _step21, _step21$value, subscriberId, subscriber, result, errorMessage;
|
|
9500
|
-
return _regeneratorRuntime().wrap(function
|
|
9501
|
-
while (1) switch (
|
|
9647
|
+
return _regeneratorRuntime().wrap(function _callee87$(_context87) {
|
|
9648
|
+
while (1) switch (_context87.prev = _context87.next) {
|
|
9502
9649
|
case 0:
|
|
9503
9650
|
if (!(this.bookingQuerySubscribers.size === 0)) {
|
|
9504
|
-
|
|
9651
|
+
_context87.next = 2;
|
|
9505
9652
|
break;
|
|
9506
9653
|
}
|
|
9507
|
-
return
|
|
9654
|
+
return _context87.abrupt("return");
|
|
9508
9655
|
case 2:
|
|
9509
9656
|
this.logInfo('recomputeAndNotifyBookingQuery: 开始推送', {
|
|
9510
9657
|
subscriberCount: this.bookingQuerySubscribers.size
|
|
9511
9658
|
});
|
|
9512
9659
|
_iterator21 = _createForOfIteratorHelper(this.bookingQuerySubscribers.entries());
|
|
9513
|
-
|
|
9660
|
+
_context87.prev = 4;
|
|
9514
9661
|
_iterator21.s();
|
|
9515
9662
|
case 6:
|
|
9516
9663
|
if ((_step21 = _iterator21.n()).done) {
|
|
9517
|
-
|
|
9664
|
+
_context87.next = 22;
|
|
9518
9665
|
break;
|
|
9519
9666
|
}
|
|
9520
9667
|
_step21$value = _slicedToArray(_step21.value, 2), subscriberId = _step21$value[0], subscriber = _step21$value[1];
|
|
9521
|
-
|
|
9522
|
-
|
|
9668
|
+
_context87.prev = 8;
|
|
9669
|
+
_context87.next = 11;
|
|
9523
9670
|
return this.computeBookingQueryResult(subscriber.context);
|
|
9524
9671
|
case 11:
|
|
9525
|
-
result =
|
|
9672
|
+
result = _context87.sent;
|
|
9526
9673
|
subscriber.callback(result);
|
|
9527
9674
|
this.logInfo('recomputeAndNotifyBookingQuery: 已推送', {
|
|
9528
9675
|
subscriberId: subscriberId
|
|
9529
9676
|
});
|
|
9530
|
-
|
|
9677
|
+
_context87.next = 20;
|
|
9531
9678
|
break;
|
|
9532
9679
|
case 16:
|
|
9533
|
-
|
|
9534
|
-
|
|
9535
|
-
errorMessage =
|
|
9680
|
+
_context87.prev = 16;
|
|
9681
|
+
_context87.t0 = _context87["catch"](8);
|
|
9682
|
+
errorMessage = _context87.t0 instanceof Error ? _context87.t0.message : String(_context87.t0);
|
|
9536
9683
|
this.logError('recomputeAndNotifyBookingQuery: 推送失败', {
|
|
9537
9684
|
subscriberId: subscriberId,
|
|
9538
9685
|
error: errorMessage
|
|
9539
9686
|
});
|
|
9540
9687
|
case 20:
|
|
9541
|
-
|
|
9688
|
+
_context87.next = 6;
|
|
9542
9689
|
break;
|
|
9543
9690
|
case 22:
|
|
9544
|
-
|
|
9691
|
+
_context87.next = 27;
|
|
9545
9692
|
break;
|
|
9546
9693
|
case 24:
|
|
9547
|
-
|
|
9548
|
-
|
|
9549
|
-
_iterator21.e(
|
|
9694
|
+
_context87.prev = 24;
|
|
9695
|
+
_context87.t1 = _context87["catch"](4);
|
|
9696
|
+
_iterator21.e(_context87.t1);
|
|
9550
9697
|
case 27:
|
|
9551
|
-
|
|
9698
|
+
_context87.prev = 27;
|
|
9552
9699
|
_iterator21.f();
|
|
9553
|
-
return
|
|
9700
|
+
return _context87.finish(27);
|
|
9554
9701
|
case 30:
|
|
9555
9702
|
case "end":
|
|
9556
|
-
return
|
|
9703
|
+
return _context87.stop();
|
|
9557
9704
|
}
|
|
9558
|
-
},
|
|
9705
|
+
}, _callee87, this, [[4, 24, 27, 30], [8, 16]]);
|
|
9559
9706
|
}));
|
|
9560
9707
|
function recomputeAndNotifyBookingQuery() {
|
|
9561
9708
|
return _recomputeAndNotifyBookingQuery.apply(this, arguments);
|