@pisell/pisellos 2.3.57 → 2.3.58
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/index.js +1 -0
- package/dist/model/strategy/adapter/promotion/index.js +0 -9
- package/dist/modules/Rules/index.js +14 -7
- package/dist/server/index.d.ts +6 -0
- package/dist/server/index.js +810 -729
- package/dist/server/modules/order/index.d.ts +1 -0
- package/dist/server/modules/order/index.js +9 -2
- package/dist/server/modules/order/types.d.ts +1 -1
- package/lib/core/index.js +1 -0
- package/lib/modules/Rules/index.js +20 -5
- package/lib/server/index.d.ts +6 -0
- package/lib/server/index.js +51 -0
- package/lib/server/modules/order/index.d.ts +1 -0
- package/lib/server/modules/order/index.js +9 -3
- package/lib/server/modules/order/types.d.ts +1 -1
- package/package.json +1 -1
package/dist/server/index.js
CHANGED
|
@@ -2931,6 +2931,87 @@ var Server = /*#__PURE__*/function () {
|
|
|
2931
2931
|
}
|
|
2932
2932
|
return refreshOrdersInBackground;
|
|
2933
2933
|
}()
|
|
2934
|
+
/**
|
|
2935
|
+
* 编辑正式订单时强制查询 Server 最新快照并覆盖本地缓存。
|
|
2936
|
+
* 商品成员增删由 OrderModule 在 SQLite/Store 更新完成后广播,
|
|
2937
|
+
* UI 可复用 order:onRemoteProductMembershipChanged 处理冲突。
|
|
2938
|
+
*/
|
|
2939
|
+
)
|
|
2940
|
+
}, {
|
|
2941
|
+
key: "checkRemoteOrderProductMembership",
|
|
2942
|
+
value: (function () {
|
|
2943
|
+
var _checkRemoteOrderProductMembership = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(orderId) {
|
|
2944
|
+
var normalizedOrderId, error, startTime, freshOrders, freshOrder;
|
|
2945
|
+
return _regeneratorRuntime().wrap(function _callee36$(_context36) {
|
|
2946
|
+
while (1) switch (_context36.prev = _context36.next) {
|
|
2947
|
+
case 0:
|
|
2948
|
+
normalizedOrderId = String(orderId !== null && orderId !== void 0 ? orderId : '').trim();
|
|
2949
|
+
if (!(!normalizedOrderId || normalizedOrderId.startsWith('local_order'))) {
|
|
2950
|
+
_context36.next = 4;
|
|
2951
|
+
break;
|
|
2952
|
+
}
|
|
2953
|
+
this.logInfo('checkRemoteOrderProductMembership: 跳过非正式订单', {
|
|
2954
|
+
orderId: orderId
|
|
2955
|
+
});
|
|
2956
|
+
return _context36.abrupt("return");
|
|
2957
|
+
case 4:
|
|
2958
|
+
if (this.order) {
|
|
2959
|
+
_context36.next = 8;
|
|
2960
|
+
break;
|
|
2961
|
+
}
|
|
2962
|
+
error = new Error('Order 模块未注册');
|
|
2963
|
+
this.logWarning('checkRemoteOrderProductMembership: Order 模块未注册', {
|
|
2964
|
+
orderId: normalizedOrderId
|
|
2965
|
+
});
|
|
2966
|
+
throw error;
|
|
2967
|
+
case 8:
|
|
2968
|
+
this.logInfo('checkRemoteOrderProductMembership 开始', {
|
|
2969
|
+
orderId: normalizedOrderId
|
|
2970
|
+
});
|
|
2971
|
+
startTime = Date.now();
|
|
2972
|
+
_context36.prev = 10;
|
|
2973
|
+
_context36.next = 13;
|
|
2974
|
+
return this.order.fetchOrdersByHttp([normalizedOrderId]);
|
|
2975
|
+
case 13:
|
|
2976
|
+
freshOrders = _context36.sent;
|
|
2977
|
+
freshOrder = freshOrders.find(function (order) {
|
|
2978
|
+
return String(order === null || order === void 0 ? void 0 : order.order_id) === normalizedOrderId;
|
|
2979
|
+
});
|
|
2980
|
+
if (freshOrder) {
|
|
2981
|
+
_context36.next = 17;
|
|
2982
|
+
break;
|
|
2983
|
+
}
|
|
2984
|
+
throw new Error('Server 未返回目标订单最新快照');
|
|
2985
|
+
case 17:
|
|
2986
|
+
_context36.next = 19;
|
|
2987
|
+
return this.order.upsertOrdersFromRemote([freshOrder], 'manual.editOpenRemoteCheck');
|
|
2988
|
+
case 19:
|
|
2989
|
+
this.logInfo('checkRemoteOrderProductMembership 完成', {
|
|
2990
|
+
orderId: normalizedOrderId,
|
|
2991
|
+
duration: "".concat(Date.now() - startTime, "ms")
|
|
2992
|
+
});
|
|
2993
|
+
_context36.next = 26;
|
|
2994
|
+
break;
|
|
2995
|
+
case 22:
|
|
2996
|
+
_context36.prev = 22;
|
|
2997
|
+
_context36.t0 = _context36["catch"](10);
|
|
2998
|
+
this.logError('checkRemoteOrderProductMembership 失败', {
|
|
2999
|
+
orderId: normalizedOrderId,
|
|
3000
|
+
duration: "".concat(Date.now() - startTime, "ms"),
|
|
3001
|
+
error: _context36.t0 instanceof Error ? _context36.t0.message : String(_context36.t0)
|
|
3002
|
+
});
|
|
3003
|
+
throw _context36.t0;
|
|
3004
|
+
case 26:
|
|
3005
|
+
case "end":
|
|
3006
|
+
return _context36.stop();
|
|
3007
|
+
}
|
|
3008
|
+
}, _callee36, this, [[10, 22]]);
|
|
3009
|
+
}));
|
|
3010
|
+
function checkRemoteOrderProductMembership(_x36) {
|
|
3011
|
+
return _checkRemoteOrderProductMembership.apply(this, arguments);
|
|
3012
|
+
}
|
|
3013
|
+
return checkRemoteOrderProductMembership;
|
|
3014
|
+
}()
|
|
2934
3015
|
/**
|
|
2935
3016
|
* 清空所有server模块的IndexedDB缓存
|
|
2936
3017
|
* @returns Promise<void>
|
|
@@ -2939,10 +3020,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
2939
3020
|
}, {
|
|
2940
3021
|
key: "clearAllIndexDB",
|
|
2941
3022
|
value: (function () {
|
|
2942
|
-
var _clearAllIndexDB = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3023
|
+
var _clearAllIndexDB = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37() {
|
|
2943
3024
|
var clearTasks, moduleNames, errorMessage;
|
|
2944
|
-
return _regeneratorRuntime().wrap(function
|
|
2945
|
-
while (1) switch (
|
|
3025
|
+
return _regeneratorRuntime().wrap(function _callee37$(_context37) {
|
|
3026
|
+
while (1) switch (_context37.prev = _context37.next) {
|
|
2946
3027
|
case 0:
|
|
2947
3028
|
console.log('[Server] 开始清空所有模块的IndexedDB缓存...');
|
|
2948
3029
|
this.logInfo('开始清空所有模块的 IndexedDB 缓存');
|
|
@@ -2977,41 +3058,41 @@ var Server = /*#__PURE__*/function () {
|
|
|
2977
3058
|
moduleNames.push('FloorPlan');
|
|
2978
3059
|
}
|
|
2979
3060
|
if (!(clearTasks.length === 0)) {
|
|
2980
|
-
|
|
3061
|
+
_context37.next = 15;
|
|
2981
3062
|
break;
|
|
2982
3063
|
}
|
|
2983
3064
|
console.warn('[Server] 没有找到已注册的模块,无需清空');
|
|
2984
3065
|
this.logWarning('没有找到已注册的模块,无需清空 IndexedDB');
|
|
2985
|
-
return
|
|
3066
|
+
return _context37.abrupt("return");
|
|
2986
3067
|
case 15:
|
|
2987
3068
|
this.logInfo('准备清空模块缓存', {
|
|
2988
3069
|
moduleNames: moduleNames
|
|
2989
3070
|
});
|
|
2990
|
-
|
|
2991
|
-
|
|
3071
|
+
_context37.prev = 16;
|
|
3072
|
+
_context37.next = 19;
|
|
2992
3073
|
return Promise.all(clearTasks);
|
|
2993
3074
|
case 19:
|
|
2994
3075
|
console.log("[Server] \u2705 \u5DF2\u6210\u529F\u6E05\u7A7A\u6240\u6709\u6A21\u5757\u7684IndexedDB\u7F13\u5B58: ".concat(moduleNames.join(', ')));
|
|
2995
3076
|
this.logInfo('成功清空所有模块的 IndexedDB 缓存', {
|
|
2996
3077
|
moduleNames: moduleNames
|
|
2997
3078
|
});
|
|
2998
|
-
|
|
3079
|
+
_context37.next = 29;
|
|
2999
3080
|
break;
|
|
3000
3081
|
case 23:
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
errorMessage =
|
|
3004
|
-
console.error('[Server] ❌ 清空IndexedDB缓存时发生错误:',
|
|
3082
|
+
_context37.prev = 23;
|
|
3083
|
+
_context37.t0 = _context37["catch"](16);
|
|
3084
|
+
errorMessage = _context37.t0 instanceof Error ? _context37.t0.message : String(_context37.t0);
|
|
3085
|
+
console.error('[Server] ❌ 清空IndexedDB缓存时发生错误:', _context37.t0);
|
|
3005
3086
|
this.logError('清空 IndexedDB 缓存时发生错误', {
|
|
3006
3087
|
moduleNames: moduleNames,
|
|
3007
3088
|
error: errorMessage
|
|
3008
3089
|
});
|
|
3009
|
-
throw
|
|
3090
|
+
throw _context37.t0;
|
|
3010
3091
|
case 29:
|
|
3011
3092
|
case "end":
|
|
3012
|
-
return
|
|
3093
|
+
return _context37.stop();
|
|
3013
3094
|
}
|
|
3014
|
-
},
|
|
3095
|
+
}, _callee37, this, [[16, 23]]);
|
|
3015
3096
|
}));
|
|
3016
3097
|
function clearAllIndexDB() {
|
|
3017
3098
|
return _clearAllIndexDB.apply(this, arguments);
|
|
@@ -3086,10 +3167,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
3086
3167
|
}, {
|
|
3087
3168
|
key: "handleRoute",
|
|
3088
3169
|
value: (function () {
|
|
3089
|
-
var _handleRoute = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3170
|
+
var _handleRoute = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee38(method, path, params) {
|
|
3090
3171
|
var startTime, handler, result, duration, _duration4, errorMessage;
|
|
3091
|
-
return _regeneratorRuntime().wrap(function
|
|
3092
|
-
while (1) switch (
|
|
3172
|
+
return _regeneratorRuntime().wrap(function _callee38$(_context38) {
|
|
3173
|
+
while (1) switch (_context38.prev = _context38.next) {
|
|
3093
3174
|
case 0:
|
|
3094
3175
|
startTime = Date.now();
|
|
3095
3176
|
this.logInfo("\u8DEF\u7531\u8BF7\u6C42\u5F00\u59CB: ".concat(method.toUpperCase(), " ").concat(path), {
|
|
@@ -3100,7 +3181,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
3100
3181
|
});
|
|
3101
3182
|
handler = this.getRouteHandler(method, path);
|
|
3102
3183
|
if (handler) {
|
|
3103
|
-
|
|
3184
|
+
_context38.next = 6;
|
|
3104
3185
|
break;
|
|
3105
3186
|
}
|
|
3106
3187
|
this.logError("\u8DEF\u7531\u672A\u627E\u5230: ".concat(method.toUpperCase(), " ").concat(path), {
|
|
@@ -3109,13 +3190,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
3109
3190
|
});
|
|
3110
3191
|
throw new Error("Route not found: ".concat(method.toUpperCase(), " ").concat(path));
|
|
3111
3192
|
case 6:
|
|
3112
|
-
|
|
3113
|
-
|
|
3193
|
+
_context38.prev = 6;
|
|
3194
|
+
_context38.next = 9;
|
|
3114
3195
|
return handler(_objectSpread(_objectSpread({}, params), {}, {
|
|
3115
3196
|
path: path
|
|
3116
3197
|
}));
|
|
3117
3198
|
case 9:
|
|
3118
|
-
result =
|
|
3199
|
+
result = _context38.sent;
|
|
3119
3200
|
duration = Date.now() - startTime;
|
|
3120
3201
|
this.logInfo("\u8DEF\u7531\u8BF7\u6C42\u5B8C\u6210: ".concat(method.toUpperCase(), " ").concat(path), {
|
|
3121
3202
|
method: method.toUpperCase(),
|
|
@@ -3124,12 +3205,12 @@ var Server = /*#__PURE__*/function () {
|
|
|
3124
3205
|
resultCode: result === null || result === void 0 ? void 0 : result.code,
|
|
3125
3206
|
resultStatus: result === null || result === void 0 ? void 0 : result.status
|
|
3126
3207
|
});
|
|
3127
|
-
return
|
|
3208
|
+
return _context38.abrupt("return", result);
|
|
3128
3209
|
case 15:
|
|
3129
|
-
|
|
3130
|
-
|
|
3210
|
+
_context38.prev = 15;
|
|
3211
|
+
_context38.t0 = _context38["catch"](6);
|
|
3131
3212
|
_duration4 = Date.now() - startTime;
|
|
3132
|
-
errorMessage =
|
|
3213
|
+
errorMessage = _context38.t0 instanceof Error ? _context38.t0.message : String(_context38.t0);
|
|
3133
3214
|
this.logError("\u8DEF\u7531\u5904\u7406\u9519\u8BEF: ".concat(method.toUpperCase(), " ").concat(path), {
|
|
3134
3215
|
method: method.toUpperCase(),
|
|
3135
3216
|
path: path,
|
|
@@ -3137,15 +3218,15 @@ var Server = /*#__PURE__*/function () {
|
|
|
3137
3218
|
error: errorMessage,
|
|
3138
3219
|
data: params.data
|
|
3139
3220
|
});
|
|
3140
|
-
console.error("[Server] \u8DEF\u7531\u5904\u7406\u9519\u8BEF: ".concat(method.toUpperCase(), " ").concat(path),
|
|
3141
|
-
throw
|
|
3221
|
+
console.error("[Server] \u8DEF\u7531\u5904\u7406\u9519\u8BEF: ".concat(method.toUpperCase(), " ").concat(path), _context38.t0);
|
|
3222
|
+
throw _context38.t0;
|
|
3142
3223
|
case 22:
|
|
3143
3224
|
case "end":
|
|
3144
|
-
return
|
|
3225
|
+
return _context38.stop();
|
|
3145
3226
|
}
|
|
3146
|
-
},
|
|
3227
|
+
}, _callee38, this, [[6, 15]]);
|
|
3147
3228
|
}));
|
|
3148
|
-
function handleRoute(
|
|
3229
|
+
function handleRoute(_x37, _x38, _x39) {
|
|
3149
3230
|
return _handleRoute.apply(this, arguments);
|
|
3150
3231
|
}
|
|
3151
3232
|
return handleRoute;
|
|
@@ -3289,36 +3370,36 @@ var Server = /*#__PURE__*/function () {
|
|
|
3289
3370
|
}, {
|
|
3290
3371
|
key: "getPaymentRouteModule",
|
|
3291
3372
|
value: function () {
|
|
3292
|
-
var _getPaymentRouteModule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3373
|
+
var _getPaymentRouteModule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee40() {
|
|
3293
3374
|
var _this6 = this;
|
|
3294
|
-
return _regeneratorRuntime().wrap(function
|
|
3295
|
-
while (1) switch (
|
|
3375
|
+
return _regeneratorRuntime().wrap(function _callee40$(_context40) {
|
|
3376
|
+
while (1) switch (_context40.prev = _context40.next) {
|
|
3296
3377
|
case 0:
|
|
3297
3378
|
if (!this.payment) {
|
|
3298
|
-
|
|
3379
|
+
_context40.next = 2;
|
|
3299
3380
|
break;
|
|
3300
3381
|
}
|
|
3301
|
-
return
|
|
3382
|
+
return _context40.abrupt("return", this.payment);
|
|
3302
3383
|
case 2:
|
|
3303
3384
|
if (!this.paymentRouteModule) {
|
|
3304
|
-
|
|
3385
|
+
_context40.next = 4;
|
|
3305
3386
|
break;
|
|
3306
3387
|
}
|
|
3307
|
-
return
|
|
3388
|
+
return _context40.abrupt("return", this.paymentRouteModule);
|
|
3308
3389
|
case 4:
|
|
3309
3390
|
if (!this.paymentRouteModuleInFlight) {
|
|
3310
|
-
|
|
3391
|
+
_context40.next = 6;
|
|
3311
3392
|
break;
|
|
3312
3393
|
}
|
|
3313
|
-
return
|
|
3394
|
+
return _context40.abrupt("return", this.paymentRouteModuleInFlight);
|
|
3314
3395
|
case 6:
|
|
3315
|
-
this.paymentRouteModuleInFlight = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3396
|
+
this.paymentRouteModuleInFlight = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee39() {
|
|
3316
3397
|
var module;
|
|
3317
|
-
return _regeneratorRuntime().wrap(function
|
|
3318
|
-
while (1) switch (
|
|
3398
|
+
return _regeneratorRuntime().wrap(function _callee39$(_context39) {
|
|
3399
|
+
while (1) switch (_context39.prev = _context39.next) {
|
|
3319
3400
|
case 0:
|
|
3320
3401
|
module = new PaymentServerModule('server_payment_route', '1.0.0');
|
|
3321
|
-
|
|
3402
|
+
_context39.next = 3;
|
|
3322
3403
|
return module.initialize(_this6.core, {
|
|
3323
3404
|
store: {
|
|
3324
3405
|
payMethods: []
|
|
@@ -3326,21 +3407,21 @@ var Server = /*#__PURE__*/function () {
|
|
|
3326
3407
|
});
|
|
3327
3408
|
case 3:
|
|
3328
3409
|
_this6.paymentRouteModule = module;
|
|
3329
|
-
return
|
|
3410
|
+
return _context39.abrupt("return", module);
|
|
3330
3411
|
case 5:
|
|
3331
3412
|
case "end":
|
|
3332
|
-
return
|
|
3413
|
+
return _context39.stop();
|
|
3333
3414
|
}
|
|
3334
|
-
},
|
|
3415
|
+
}, _callee39);
|
|
3335
3416
|
}))().finally(function () {
|
|
3336
3417
|
_this6.paymentRouteModuleInFlight = undefined;
|
|
3337
3418
|
});
|
|
3338
|
-
return
|
|
3419
|
+
return _context40.abrupt("return", this.paymentRouteModuleInFlight);
|
|
3339
3420
|
case 8:
|
|
3340
3421
|
case "end":
|
|
3341
|
-
return
|
|
3422
|
+
return _context40.stop();
|
|
3342
3423
|
}
|
|
3343
|
-
},
|
|
3424
|
+
}, _callee40, this);
|
|
3344
3425
|
}));
|
|
3345
3426
|
function getPaymentRouteModule() {
|
|
3346
3427
|
return _getPaymentRouteModule.apply(this, arguments);
|
|
@@ -3350,19 +3431,19 @@ var Server = /*#__PURE__*/function () {
|
|
|
3350
3431
|
}, {
|
|
3351
3432
|
key: "fetchQuotationAvailableFromAPI",
|
|
3352
3433
|
value: function () {
|
|
3353
|
-
var _fetchQuotationAvailableFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3434
|
+
var _fetchQuotationAvailableFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee41(data) {
|
|
3354
3435
|
var _this$app7;
|
|
3355
3436
|
var requester;
|
|
3356
|
-
return _regeneratorRuntime().wrap(function
|
|
3357
|
-
while (1) switch (
|
|
3437
|
+
return _regeneratorRuntime().wrap(function _callee41$(_context41) {
|
|
3438
|
+
while (1) switch (_context41.prev = _context41.next) {
|
|
3358
3439
|
case 0:
|
|
3359
3440
|
requester = ((_this$app7 = this.app) === null || _this$app7 === void 0 ? void 0 : _this$app7.request) || this.core.getPlugin('request');
|
|
3360
3441
|
if (requester !== null && requester !== void 0 && requester.get) {
|
|
3361
|
-
|
|
3442
|
+
_context41.next = 4;
|
|
3362
3443
|
break;
|
|
3363
3444
|
}
|
|
3364
3445
|
this.logError('fetchQuotationAvailableFromAPI: request 不可用');
|
|
3365
|
-
return
|
|
3446
|
+
return _context41.abrupt("return", {
|
|
3366
3447
|
code: 500,
|
|
3367
3448
|
message: 'request 不可用',
|
|
3368
3449
|
data: {
|
|
@@ -3371,14 +3452,14 @@ var Server = /*#__PURE__*/function () {
|
|
|
3371
3452
|
status: false
|
|
3372
3453
|
});
|
|
3373
3454
|
case 4:
|
|
3374
|
-
return
|
|
3455
|
+
return _context41.abrupt("return", requester.get('/shop/quotation/available', data));
|
|
3375
3456
|
case 5:
|
|
3376
3457
|
case "end":
|
|
3377
|
-
return
|
|
3458
|
+
return _context41.stop();
|
|
3378
3459
|
}
|
|
3379
|
-
},
|
|
3460
|
+
}, _callee41, this);
|
|
3380
3461
|
}));
|
|
3381
|
-
function fetchQuotationAvailableFromAPI(
|
|
3462
|
+
function fetchQuotationAvailableFromAPI(_x40) {
|
|
3382
3463
|
return _fetchQuotationAvailableFromAPI.apply(this, arguments);
|
|
3383
3464
|
}
|
|
3384
3465
|
return fetchQuotationAvailableFromAPI;
|
|
@@ -3550,29 +3631,29 @@ var Server = /*#__PURE__*/function () {
|
|
|
3550
3631
|
}, {
|
|
3551
3632
|
key: "onScheduleTimePointTimerFire",
|
|
3552
3633
|
value: (function () {
|
|
3553
|
-
var _onScheduleTimePointTimerFire = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3634
|
+
var _onScheduleTimePointTimerFire = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee42(subscriberId, timerId) {
|
|
3554
3635
|
var subscriber;
|
|
3555
|
-
return _regeneratorRuntime().wrap(function
|
|
3556
|
-
while (1) switch (
|
|
3636
|
+
return _regeneratorRuntime().wrap(function _callee42$(_context42) {
|
|
3637
|
+
while (1) switch (_context42.prev = _context42.next) {
|
|
3557
3638
|
case 0:
|
|
3558
3639
|
timerId && this.removeScheduleTimerRef(subscriberId, timerId);
|
|
3559
3640
|
if (this.productQuerySubscribers.has(subscriberId)) {
|
|
3560
|
-
|
|
3641
|
+
_context42.next = 3;
|
|
3561
3642
|
break;
|
|
3562
3643
|
}
|
|
3563
|
-
return
|
|
3644
|
+
return _context42.abrupt("return");
|
|
3564
3645
|
case 3:
|
|
3565
3646
|
subscriber = this.productQuerySubscribers.get(subscriberId);
|
|
3566
3647
|
this.refreshSubscriberScheduleAtExecution(subscriber);
|
|
3567
|
-
|
|
3648
|
+
_context42.next = 7;
|
|
3568
3649
|
return this.recomputeAndNotifySubscriber(subscriberId);
|
|
3569
3650
|
case 7:
|
|
3570
3651
|
case "end":
|
|
3571
|
-
return
|
|
3652
|
+
return _context42.stop();
|
|
3572
3653
|
}
|
|
3573
|
-
},
|
|
3654
|
+
}, _callee42, this);
|
|
3574
3655
|
}));
|
|
3575
|
-
function onScheduleTimePointTimerFire(
|
|
3656
|
+
function onScheduleTimePointTimerFire(_x41, _x42) {
|
|
3576
3657
|
return _onScheduleTimePointTimerFire.apply(this, arguments);
|
|
3577
3658
|
}
|
|
3578
3659
|
return onScheduleTimePointTimerFire;
|
|
@@ -3584,45 +3665,45 @@ var Server = /*#__PURE__*/function () {
|
|
|
3584
3665
|
}, {
|
|
3585
3666
|
key: "recomputeAndNotifySubscriber",
|
|
3586
3667
|
value: (function () {
|
|
3587
|
-
var _recomputeAndNotifySubscriber = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3668
|
+
var _recomputeAndNotifySubscriber = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee43(subscriberId) {
|
|
3588
3669
|
var subscriber, result, errorMessage;
|
|
3589
|
-
return _regeneratorRuntime().wrap(function
|
|
3590
|
-
while (1) switch (
|
|
3670
|
+
return _regeneratorRuntime().wrap(function _callee43$(_context43) {
|
|
3671
|
+
while (1) switch (_context43.prev = _context43.next) {
|
|
3591
3672
|
case 0:
|
|
3592
3673
|
subscriber = this.productQuerySubscribers.get(subscriberId);
|
|
3593
3674
|
if (subscriber) {
|
|
3594
|
-
|
|
3675
|
+
_context43.next = 3;
|
|
3595
3676
|
break;
|
|
3596
3677
|
}
|
|
3597
|
-
return
|
|
3678
|
+
return _context43.abrupt("return");
|
|
3598
3679
|
case 3:
|
|
3599
|
-
|
|
3600
|
-
|
|
3680
|
+
_context43.prev = 3;
|
|
3681
|
+
_context43.next = 6;
|
|
3601
3682
|
return this.computeProductQueryResult(subscriber.context);
|
|
3602
3683
|
case 6:
|
|
3603
|
-
result =
|
|
3684
|
+
result = _context43.sent;
|
|
3604
3685
|
subscriber.callback(result);
|
|
3605
3686
|
this.logInfo('recomputeAndNotifySubscriber: 已推送', {
|
|
3606
3687
|
subscriberId: subscriberId,
|
|
3607
3688
|
schedule_datetime: subscriber.context.schedule_datetime
|
|
3608
3689
|
});
|
|
3609
|
-
|
|
3690
|
+
_context43.next = 15;
|
|
3610
3691
|
break;
|
|
3611
3692
|
case 11:
|
|
3612
|
-
|
|
3613
|
-
|
|
3614
|
-
errorMessage =
|
|
3693
|
+
_context43.prev = 11;
|
|
3694
|
+
_context43.t0 = _context43["catch"](3);
|
|
3695
|
+
errorMessage = _context43.t0 instanceof Error ? _context43.t0.message : String(_context43.t0);
|
|
3615
3696
|
this.logError('recomputeAndNotifySubscriber: 推送失败', {
|
|
3616
3697
|
subscriberId: subscriberId,
|
|
3617
3698
|
error: errorMessage
|
|
3618
3699
|
});
|
|
3619
3700
|
case 15:
|
|
3620
3701
|
case "end":
|
|
3621
|
-
return
|
|
3702
|
+
return _context43.stop();
|
|
3622
3703
|
}
|
|
3623
|
-
},
|
|
3704
|
+
}, _callee43, this, [[3, 11]]);
|
|
3624
3705
|
}));
|
|
3625
|
-
function recomputeAndNotifySubscriber(
|
|
3706
|
+
function recomputeAndNotifySubscriber(_x43) {
|
|
3626
3707
|
return _recomputeAndNotifySubscriber.apply(this, arguments);
|
|
3627
3708
|
}
|
|
3628
3709
|
return recomputeAndNotifySubscriber;
|
|
@@ -3668,24 +3749,24 @@ var Server = /*#__PURE__*/function () {
|
|
|
3668
3749
|
}, {
|
|
3669
3750
|
key: "refreshMenuScheduleCacheAfterEmptyResult",
|
|
3670
3751
|
value: (function () {
|
|
3671
|
-
var _refreshMenuScheduleCacheAfterEmptyResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3752
|
+
var _refreshMenuScheduleCacheAfterEmptyResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee44() {
|
|
3672
3753
|
var _this8 = this;
|
|
3673
3754
|
var now;
|
|
3674
|
-
return _regeneratorRuntime().wrap(function
|
|
3675
|
-
while (1) switch (
|
|
3755
|
+
return _regeneratorRuntime().wrap(function _callee44$(_context44) {
|
|
3756
|
+
while (1) switch (_context44.prev = _context44.next) {
|
|
3676
3757
|
case 0:
|
|
3677
3758
|
if (!(!this.menu || !this.schedule)) {
|
|
3678
|
-
|
|
3759
|
+
_context44.next = 2;
|
|
3679
3760
|
break;
|
|
3680
3761
|
}
|
|
3681
|
-
return
|
|
3762
|
+
return _context44.abrupt("return", false);
|
|
3682
3763
|
case 2:
|
|
3683
3764
|
now = Date.now();
|
|
3684
3765
|
if (!(now - this.lastMenuScheduleRefreshAt < this.MENU_SCHEDULE_REFRESH_COOLDOWN_MS)) {
|
|
3685
|
-
|
|
3766
|
+
_context44.next = 5;
|
|
3686
3767
|
break;
|
|
3687
3768
|
}
|
|
3688
|
-
return
|
|
3769
|
+
return _context44.abrupt("return", false);
|
|
3689
3770
|
case 5:
|
|
3690
3771
|
if (!this.menuScheduleRefreshInFlight) {
|
|
3691
3772
|
this.lastMenuScheduleRefreshAt = now;
|
|
@@ -3699,15 +3780,15 @@ var Server = /*#__PURE__*/function () {
|
|
|
3699
3780
|
_this8.menuScheduleRefreshInFlight = null;
|
|
3700
3781
|
});
|
|
3701
3782
|
}
|
|
3702
|
-
|
|
3783
|
+
_context44.next = 8;
|
|
3703
3784
|
return this.menuScheduleRefreshInFlight;
|
|
3704
3785
|
case 8:
|
|
3705
|
-
return
|
|
3786
|
+
return _context44.abrupt("return", true);
|
|
3706
3787
|
case 9:
|
|
3707
3788
|
case "end":
|
|
3708
|
-
return
|
|
3789
|
+
return _context44.stop();
|
|
3709
3790
|
}
|
|
3710
|
-
},
|
|
3791
|
+
}, _callee44, this);
|
|
3711
3792
|
}));
|
|
3712
3793
|
function refreshMenuScheduleCacheAfterEmptyResult() {
|
|
3713
3794
|
return _refreshMenuScheduleCacheAfterEmptyResult.apply(this, arguments);
|
|
@@ -3725,16 +3806,16 @@ var Server = /*#__PURE__*/function () {
|
|
|
3725
3806
|
* const result = await this.handleSalesSearchRequest('single', '/shop/es/search/sales', { keyword: '1001' }, {})
|
|
3726
3807
|
*/
|
|
3727
3808
|
function () {
|
|
3728
|
-
var _handleSalesSearchRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3809
|
+
var _handleSalesSearchRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee45(kind, backendPath, data, config) {
|
|
3729
3810
|
var queryPayload, result, _ref61, callback, subscriberId, resetVisibleOrderIds, contextSignature, existing, shouldReset, visibleOrderIds, _iterator5, _step5, orderId;
|
|
3730
|
-
return _regeneratorRuntime().wrap(function
|
|
3731
|
-
while (1) switch (
|
|
3811
|
+
return _regeneratorRuntime().wrap(function _callee45$(_context45) {
|
|
3812
|
+
while (1) switch (_context45.prev = _context45.next) {
|
|
3732
3813
|
case 0:
|
|
3733
3814
|
queryPayload = data && _typeof(data) === 'object' ? _objectSpread({}, data) : {};
|
|
3734
|
-
|
|
3815
|
+
_context45.next = 3;
|
|
3735
3816
|
return this.fetchSalesSearchFromAPI(backendPath, queryPayload);
|
|
3736
3817
|
case 3:
|
|
3737
|
-
result =
|
|
3818
|
+
result = _context45.sent;
|
|
3738
3819
|
_ref61 = config || {}, callback = _ref61.callback, subscriberId = _ref61.subscriberId, resetVisibleOrderIds = _ref61.resetVisibleOrderIds;
|
|
3739
3820
|
if (subscriberId && typeof callback === 'function') {
|
|
3740
3821
|
contextSignature = this.buildSalesSearchSignature(kind, queryPayload);
|
|
@@ -3766,14 +3847,14 @@ var Server = /*#__PURE__*/function () {
|
|
|
3766
3847
|
visibleCount: visibleOrderIds.size
|
|
3767
3848
|
});
|
|
3768
3849
|
}
|
|
3769
|
-
return
|
|
3850
|
+
return _context45.abrupt("return", result);
|
|
3770
3851
|
case 7:
|
|
3771
3852
|
case "end":
|
|
3772
|
-
return
|
|
3853
|
+
return _context45.stop();
|
|
3773
3854
|
}
|
|
3774
|
-
},
|
|
3855
|
+
}, _callee45, this);
|
|
3775
3856
|
}));
|
|
3776
|
-
function handleSalesSearchRequest(
|
|
3857
|
+
function handleSalesSearchRequest(_x44, _x45, _x46, _x47) {
|
|
3777
3858
|
return _handleSalesSearchRequest.apply(this, arguments);
|
|
3778
3859
|
}
|
|
3779
3860
|
return handleSalesSearchRequest;
|
|
@@ -3788,20 +3869,20 @@ var Server = /*#__PURE__*/function () {
|
|
|
3788
3869
|
}, {
|
|
3789
3870
|
key: "fetchSalesSearchFromAPI",
|
|
3790
3871
|
value: (function () {
|
|
3791
|
-
var _fetchSalesSearchFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
3872
|
+
var _fetchSalesSearchFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee46(backendPath, data) {
|
|
3792
3873
|
var _this$app8;
|
|
3793
3874
|
var _response$data4, _response$code2, _response$status2, _response$message2, response, _payload, errorMessage;
|
|
3794
|
-
return _regeneratorRuntime().wrap(function
|
|
3795
|
-
while (1) switch (
|
|
3875
|
+
return _regeneratorRuntime().wrap(function _callee46$(_context46) {
|
|
3876
|
+
while (1) switch (_context46.prev = _context46.next) {
|
|
3796
3877
|
case 0:
|
|
3797
3878
|
if ((_this$app8 = this.app) !== null && _this$app8 !== void 0 && _this$app8.request) {
|
|
3798
|
-
|
|
3879
|
+
_context46.next = 3;
|
|
3799
3880
|
break;
|
|
3800
3881
|
}
|
|
3801
3882
|
this.logError('fetchSalesSearchFromAPI: app.request 不可用', {
|
|
3802
3883
|
backendPath: backendPath
|
|
3803
3884
|
});
|
|
3804
|
-
return
|
|
3885
|
+
return _context46.abrupt("return", {
|
|
3805
3886
|
code: 500,
|
|
3806
3887
|
message: 'app.request 不可用',
|
|
3807
3888
|
data: backendPath === '/shop/es/search' ? {
|
|
@@ -3813,29 +3894,29 @@ var Server = /*#__PURE__*/function () {
|
|
|
3813
3894
|
status: false
|
|
3814
3895
|
});
|
|
3815
3896
|
case 3:
|
|
3816
|
-
|
|
3817
|
-
|
|
3897
|
+
_context46.prev = 3;
|
|
3898
|
+
_context46.next = 6;
|
|
3818
3899
|
return this.app.request.post(backendPath, data, {
|
|
3819
3900
|
isShopApi: true
|
|
3820
3901
|
});
|
|
3821
3902
|
case 6:
|
|
3822
|
-
response =
|
|
3903
|
+
response = _context46.sent;
|
|
3823
3904
|
_payload = (_response$data4 = response === null || response === void 0 ? void 0 : response.data) !== null && _response$data4 !== void 0 ? _response$data4 : response;
|
|
3824
|
-
return
|
|
3905
|
+
return _context46.abrupt("return", {
|
|
3825
3906
|
code: (_response$code2 = response === null || response === void 0 ? void 0 : response.code) !== null && _response$code2 !== void 0 ? _response$code2 : 200,
|
|
3826
3907
|
status: (_response$status2 = response === null || response === void 0 ? void 0 : response.status) !== null && _response$status2 !== void 0 ? _response$status2 : true,
|
|
3827
3908
|
message: (_response$message2 = response === null || response === void 0 ? void 0 : response.message) !== null && _response$message2 !== void 0 ? _response$message2 : '',
|
|
3828
3909
|
data: _payload
|
|
3829
3910
|
});
|
|
3830
3911
|
case 11:
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
errorMessage =
|
|
3912
|
+
_context46.prev = 11;
|
|
3913
|
+
_context46.t0 = _context46["catch"](3);
|
|
3914
|
+
errorMessage = _context46.t0 instanceof Error ? _context46.t0.message : String(_context46.t0);
|
|
3834
3915
|
this.logError('fetchSalesSearchFromAPI: 请求失败', {
|
|
3835
3916
|
backendPath: backendPath,
|
|
3836
3917
|
error: errorMessage
|
|
3837
3918
|
});
|
|
3838
|
-
return
|
|
3919
|
+
return _context46.abrupt("return", {
|
|
3839
3920
|
code: 500,
|
|
3840
3921
|
message: errorMessage,
|
|
3841
3922
|
data: backendPath === '/shop/es/search' ? {
|
|
@@ -3848,11 +3929,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
3848
3929
|
});
|
|
3849
3930
|
case 16:
|
|
3850
3931
|
case "end":
|
|
3851
|
-
return
|
|
3932
|
+
return _context46.stop();
|
|
3852
3933
|
}
|
|
3853
|
-
},
|
|
3934
|
+
}, _callee46, this, [[3, 11]]);
|
|
3854
3935
|
}));
|
|
3855
|
-
function fetchSalesSearchFromAPI(
|
|
3936
|
+
function fetchSalesSearchFromAPI(_x48, _x49) {
|
|
3856
3937
|
return _fetchSalesSearchFromAPI.apply(this, arguments);
|
|
3857
3938
|
}
|
|
3858
3939
|
return fetchSalesSearchFromAPI;
|
|
@@ -4373,18 +4454,18 @@ var Server = /*#__PURE__*/function () {
|
|
|
4373
4454
|
}, {
|
|
4374
4455
|
key: "fetchOrderListFromAPI",
|
|
4375
4456
|
value: (function () {
|
|
4376
|
-
var _fetchOrderListFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4457
|
+
var _fetchOrderListFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee47(data) {
|
|
4377
4458
|
var _this$app9;
|
|
4378
4459
|
var _response$data5, response, _payload2, list, count, errorMessage;
|
|
4379
|
-
return _regeneratorRuntime().wrap(function
|
|
4380
|
-
while (1) switch (
|
|
4460
|
+
return _regeneratorRuntime().wrap(function _callee47$(_context47) {
|
|
4461
|
+
while (1) switch (_context47.prev = _context47.next) {
|
|
4381
4462
|
case 0:
|
|
4382
4463
|
if ((_this$app9 = this.app) !== null && _this$app9 !== void 0 && _this$app9.request) {
|
|
4383
|
-
|
|
4464
|
+
_context47.next = 3;
|
|
4384
4465
|
break;
|
|
4385
4466
|
}
|
|
4386
4467
|
this.logError('fetchOrderListFromAPI: app.request 不可用');
|
|
4387
|
-
return
|
|
4468
|
+
return _context47.abrupt("return", {
|
|
4388
4469
|
code: 500,
|
|
4389
4470
|
message: 'app.request 不可用',
|
|
4390
4471
|
data: {
|
|
@@ -4394,17 +4475,17 @@ var Server = /*#__PURE__*/function () {
|
|
|
4394
4475
|
status: false
|
|
4395
4476
|
});
|
|
4396
4477
|
case 3:
|
|
4397
|
-
|
|
4398
|
-
|
|
4478
|
+
_context47.prev = 3;
|
|
4479
|
+
_context47.next = 6;
|
|
4399
4480
|
return this.app.request.post('/shop/order/v2/list', data, {
|
|
4400
4481
|
isShopApi: true
|
|
4401
4482
|
});
|
|
4402
4483
|
case 6:
|
|
4403
|
-
response =
|
|
4484
|
+
response = _context47.sent;
|
|
4404
4485
|
_payload2 = (_response$data5 = response === null || response === void 0 ? void 0 : response.data) !== null && _response$data5 !== void 0 ? _response$data5 : response;
|
|
4405
4486
|
list = Array.isArray(_payload2 === null || _payload2 === void 0 ? void 0 : _payload2.list) ? _payload2.list : [];
|
|
4406
4487
|
count = typeof (_payload2 === null || _payload2 === void 0 ? void 0 : _payload2.count) === 'number' ? _payload2.count : list.length;
|
|
4407
|
-
return
|
|
4488
|
+
return _context47.abrupt("return", {
|
|
4408
4489
|
code: 200,
|
|
4409
4490
|
data: _objectSpread(_objectSpread({}, _payload2), {}, {
|
|
4410
4491
|
list: list,
|
|
@@ -4414,13 +4495,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
4414
4495
|
status: true
|
|
4415
4496
|
});
|
|
4416
4497
|
case 13:
|
|
4417
|
-
|
|
4418
|
-
|
|
4419
|
-
errorMessage =
|
|
4498
|
+
_context47.prev = 13;
|
|
4499
|
+
_context47.t0 = _context47["catch"](3);
|
|
4500
|
+
errorMessage = _context47.t0 instanceof Error ? _context47.t0.message : String(_context47.t0);
|
|
4420
4501
|
this.logError('fetchOrderListFromAPI: 请求失败', {
|
|
4421
4502
|
error: errorMessage
|
|
4422
4503
|
});
|
|
4423
|
-
return
|
|
4504
|
+
return _context47.abrupt("return", {
|
|
4424
4505
|
code: 500,
|
|
4425
4506
|
message: errorMessage,
|
|
4426
4507
|
data: {
|
|
@@ -4431,11 +4512,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
4431
4512
|
});
|
|
4432
4513
|
case 18:
|
|
4433
4514
|
case "end":
|
|
4434
|
-
return
|
|
4515
|
+
return _context47.stop();
|
|
4435
4516
|
}
|
|
4436
|
-
},
|
|
4517
|
+
}, _callee47, this, [[3, 13]]);
|
|
4437
4518
|
}));
|
|
4438
|
-
function fetchOrderListFromAPI(
|
|
4519
|
+
function fetchOrderListFromAPI(_x50) {
|
|
4439
4520
|
return _fetchOrderListFromAPI.apply(this, arguments);
|
|
4440
4521
|
}
|
|
4441
4522
|
return fetchOrderListFromAPI;
|
|
@@ -4447,17 +4528,17 @@ var Server = /*#__PURE__*/function () {
|
|
|
4447
4528
|
}, {
|
|
4448
4529
|
key: "fetchBookingListFromAPI",
|
|
4449
4530
|
value: (function () {
|
|
4450
|
-
var _fetchBookingListFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4531
|
+
var _fetchBookingListFromAPI = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee48(data) {
|
|
4451
4532
|
var memoryCacheEnabled, withFields, requestPayload, cacheKey, cached, rawList, bookingResult, _bookingResult$list, errorMessage;
|
|
4452
|
-
return _regeneratorRuntime().wrap(function
|
|
4453
|
-
while (1) switch (
|
|
4533
|
+
return _regeneratorRuntime().wrap(function _callee48$(_context48) {
|
|
4534
|
+
while (1) switch (_context48.prev = _context48.next) {
|
|
4454
4535
|
case 0:
|
|
4455
4536
|
if (this.order) {
|
|
4456
|
-
|
|
4537
|
+
_context48.next = 3;
|
|
4457
4538
|
break;
|
|
4458
4539
|
}
|
|
4459
4540
|
this.logError('fetchBookingListFromAPI: Order 模块不可用');
|
|
4460
|
-
return
|
|
4541
|
+
return _context48.abrupt("return", {
|
|
4461
4542
|
code: 500,
|
|
4462
4543
|
message: 'Order 模块不可用',
|
|
4463
4544
|
data: {
|
|
@@ -4467,18 +4548,18 @@ var Server = /*#__PURE__*/function () {
|
|
|
4467
4548
|
status: false
|
|
4468
4549
|
});
|
|
4469
4550
|
case 3:
|
|
4470
|
-
|
|
4551
|
+
_context48.prev = 3;
|
|
4471
4552
|
memoryCacheEnabled = this.isBookingRemoteMemoryCacheEnabled(data);
|
|
4472
4553
|
withFields = this.resolveBookingSalesWith(data);
|
|
4473
4554
|
requestPayload = this.normalizeBookingRemoteQueryPayload(data, withFields);
|
|
4474
4555
|
cacheKey = this.buildBookingRemoteCacheKey(requestPayload);
|
|
4475
4556
|
if (!memoryCacheEnabled) {
|
|
4476
|
-
|
|
4557
|
+
_context48.next = 13;
|
|
4477
4558
|
break;
|
|
4478
4559
|
}
|
|
4479
4560
|
cached = this.readBookingRemoteCache(cacheKey);
|
|
4480
4561
|
if (!cached) {
|
|
4481
|
-
|
|
4562
|
+
_context48.next = 13;
|
|
4482
4563
|
break;
|
|
4483
4564
|
}
|
|
4484
4565
|
this.logInfo('fetchBookingListFromAPI: 命中内存缓存', {
|
|
@@ -4486,14 +4567,14 @@ var Server = /*#__PURE__*/function () {
|
|
|
4486
4567
|
listCount: cached.bookingResult.count,
|
|
4487
4568
|
withFields: cached.withFields
|
|
4488
4569
|
});
|
|
4489
|
-
return
|
|
4570
|
+
return _context48.abrupt("return", this.buildBookingResponse(cached.bookingResult, {
|
|
4490
4571
|
cache_hit: true
|
|
4491
4572
|
}));
|
|
4492
4573
|
case 13:
|
|
4493
|
-
|
|
4574
|
+
_context48.next = 15;
|
|
4494
4575
|
return this.order.fetchOrdersBySSE(requestPayload);
|
|
4495
4576
|
case 15:
|
|
4496
|
-
rawList =
|
|
4577
|
+
rawList = _context48.sent;
|
|
4497
4578
|
bookingResult = sortBookings(filterBookingsFromOrders(rawList, data), data); // DEBUG: 挂到 window 上方便排查 SSE → 日历数据丢失问题
|
|
4498
4579
|
if (typeof globalThis !== 'undefined') {
|
|
4499
4580
|
globalThis.__SSE_BOOKING_DEBUG__ = {
|
|
@@ -4540,15 +4621,15 @@ var Server = /*#__PURE__*/function () {
|
|
|
4540
4621
|
cacheKey: cacheKey,
|
|
4541
4622
|
withFields: withFields
|
|
4542
4623
|
});
|
|
4543
|
-
return
|
|
4624
|
+
return _context48.abrupt("return", this.buildBookingResponse(bookingResult));
|
|
4544
4625
|
case 23:
|
|
4545
|
-
|
|
4546
|
-
|
|
4547
|
-
errorMessage =
|
|
4626
|
+
_context48.prev = 23;
|
|
4627
|
+
_context48.t0 = _context48["catch"](3);
|
|
4628
|
+
errorMessage = _context48.t0 instanceof Error ? _context48.t0.message : String(_context48.t0);
|
|
4548
4629
|
this.logError('fetchBookingListFromAPI: SSE 请求失败', {
|
|
4549
4630
|
error: errorMessage
|
|
4550
4631
|
});
|
|
4551
|
-
return
|
|
4632
|
+
return _context48.abrupt("return", {
|
|
4552
4633
|
code: 500,
|
|
4553
4634
|
message: errorMessage,
|
|
4554
4635
|
data: {
|
|
@@ -4559,11 +4640,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
4559
4640
|
});
|
|
4560
4641
|
case 28:
|
|
4561
4642
|
case "end":
|
|
4562
|
-
return
|
|
4643
|
+
return _context48.stop();
|
|
4563
4644
|
}
|
|
4564
|
-
},
|
|
4645
|
+
}, _callee48, this, [[3, 23]]);
|
|
4565
4646
|
}));
|
|
4566
|
-
function fetchBookingListFromAPI(
|
|
4647
|
+
function fetchBookingListFromAPI(_x51) {
|
|
4567
4648
|
return _fetchBookingListFromAPI.apply(this, arguments);
|
|
4568
4649
|
}
|
|
4569
4650
|
return fetchBookingListFromAPI;
|
|
@@ -4647,11 +4728,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
4647
4728
|
}, {
|
|
4648
4729
|
key: "runLocalPaymentUpdateInQueue",
|
|
4649
4730
|
value: function () {
|
|
4650
|
-
var _runLocalPaymentUpdateInQueue = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4731
|
+
var _runLocalPaymentUpdateInQueue = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee50(key, task, context) {
|
|
4651
4732
|
var _this12 = this;
|
|
4652
4733
|
var queuedAt, hasPreviousTask, previous, current, tail, _data, result, released;
|
|
4653
|
-
return _regeneratorRuntime().wrap(function
|
|
4654
|
-
while (1) switch (
|
|
4734
|
+
return _regeneratorRuntime().wrap(function _callee50$(_context50) {
|
|
4735
|
+
while (1) switch (_context50.prev = _context50.next) {
|
|
4655
4736
|
case 0:
|
|
4656
4737
|
queuedAt = Date.now();
|
|
4657
4738
|
hasPreviousTask = this.localPaymentUpdateQueues.has(key);
|
|
@@ -4663,20 +4744,20 @@ var Server = /*#__PURE__*/function () {
|
|
|
4663
4744
|
}));
|
|
4664
4745
|
current = previous.catch(function () {
|
|
4665
4746
|
return undefined;
|
|
4666
|
-
}).then( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4667
|
-
return _regeneratorRuntime().wrap(function
|
|
4668
|
-
while (1) switch (
|
|
4747
|
+
}).then( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee49() {
|
|
4748
|
+
return _regeneratorRuntime().wrap(function _callee49$(_context49) {
|
|
4749
|
+
while (1) switch (_context49.prev = _context49.next) {
|
|
4669
4750
|
case 0:
|
|
4670
4751
|
_this12.logInfo('handleUpdateLocalPayment: 串行队列开始执行', _objectSpread(_objectSpread({}, context), {}, {
|
|
4671
4752
|
queue_key: key,
|
|
4672
4753
|
queue_wait_ms: Date.now() - queuedAt
|
|
4673
4754
|
}));
|
|
4674
|
-
return
|
|
4755
|
+
return _context49.abrupt("return", task());
|
|
4675
4756
|
case 2:
|
|
4676
4757
|
case "end":
|
|
4677
|
-
return
|
|
4758
|
+
return _context49.stop();
|
|
4678
4759
|
}
|
|
4679
|
-
},
|
|
4760
|
+
}, _callee49);
|
|
4680
4761
|
})));
|
|
4681
4762
|
tail = current.then(function () {
|
|
4682
4763
|
return undefined;
|
|
@@ -4684,11 +4765,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
4684
4765
|
return undefined;
|
|
4685
4766
|
});
|
|
4686
4767
|
this.localPaymentUpdateQueues.set(key, tail);
|
|
4687
|
-
|
|
4688
|
-
|
|
4768
|
+
_context50.prev = 7;
|
|
4769
|
+
_context50.next = 10;
|
|
4689
4770
|
return current;
|
|
4690
4771
|
case 10:
|
|
4691
|
-
result =
|
|
4772
|
+
result = _context50.sent;
|
|
4692
4773
|
this.logInfo('handleUpdateLocalPayment: 串行队列执行完成', _objectSpread(_objectSpread({}, context), {}, {
|
|
4693
4774
|
queue_key: key,
|
|
4694
4775
|
total_duration_ms: Date.now() - queuedAt,
|
|
@@ -4696,19 +4777,19 @@ var Server = /*#__PURE__*/function () {
|
|
|
4696
4777
|
result_status: result === null || result === void 0 ? void 0 : result.status,
|
|
4697
4778
|
payment: result === null || result === void 0 || (_data = result.data) === null || _data === void 0 ? void 0 : _data.payment
|
|
4698
4779
|
}));
|
|
4699
|
-
return
|
|
4780
|
+
return _context50.abrupt("return", result);
|
|
4700
4781
|
case 15:
|
|
4701
|
-
|
|
4702
|
-
|
|
4782
|
+
_context50.prev = 15;
|
|
4783
|
+
_context50.t0 = _context50["catch"](7);
|
|
4703
4784
|
this.logError('handleUpdateLocalPayment: 串行队列执行失败', _objectSpread(_objectSpread({}, context), {}, {
|
|
4704
4785
|
queue_key: key,
|
|
4705
4786
|
total_duration_ms: Date.now() - queuedAt,
|
|
4706
|
-
error:
|
|
4707
|
-
error_detail: this.normalizeUnknownError(
|
|
4787
|
+
error: _context50.t0 instanceof Error ? _context50.t0.message : String(_context50.t0),
|
|
4788
|
+
error_detail: this.normalizeUnknownError(_context50.t0)
|
|
4708
4789
|
}));
|
|
4709
|
-
throw
|
|
4790
|
+
throw _context50.t0;
|
|
4710
4791
|
case 19:
|
|
4711
|
-
|
|
4792
|
+
_context50.prev = 19;
|
|
4712
4793
|
released = false;
|
|
4713
4794
|
if (this.localPaymentUpdateQueues.get(key) === tail) {
|
|
4714
4795
|
this.localPaymentUpdateQueues.delete(key);
|
|
@@ -4719,14 +4800,14 @@ var Server = /*#__PURE__*/function () {
|
|
|
4719
4800
|
released: released,
|
|
4720
4801
|
active_queue_count: this.localPaymentUpdateQueues.size
|
|
4721
4802
|
}));
|
|
4722
|
-
return
|
|
4803
|
+
return _context50.finish(19);
|
|
4723
4804
|
case 24:
|
|
4724
4805
|
case "end":
|
|
4725
|
-
return
|
|
4806
|
+
return _context50.stop();
|
|
4726
4807
|
}
|
|
4727
|
-
},
|
|
4808
|
+
}, _callee50, this, [[7, 15, 19, 24]]);
|
|
4728
4809
|
}));
|
|
4729
|
-
function runLocalPaymentUpdateInQueue(
|
|
4810
|
+
function runLocalPaymentUpdateInQueue(_x52, _x53, _x54) {
|
|
4730
4811
|
return _runLocalPaymentUpdateInQueue.apply(this, arguments);
|
|
4731
4812
|
}
|
|
4732
4813
|
return runLocalPaymentUpdateInQueue;
|
|
@@ -4734,11 +4815,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
4734
4815
|
}, {
|
|
4735
4816
|
key: "processLocalPaymentUpdate",
|
|
4736
4817
|
value: function () {
|
|
4737
|
-
var _processLocalPaymentUpdate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
4818
|
+
var _processLocalPaymentUpdate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee51(params) {
|
|
4738
4819
|
var _params$serviceCharge4, _params$cardReaderSur, _found$payment, _found$payment2;
|
|
4739
4820
|
var requestContext, found, surchargeUpdate, incomingPaymentUpdate, transactions, existingTransaction, hasRecordedSuccess, orderIsDraft, foundContext, alreadyRecordedFailure, updated;
|
|
4740
|
-
return _regeneratorRuntime().wrap(function
|
|
4741
|
-
while (1) switch (
|
|
4821
|
+
return _regeneratorRuntime().wrap(function _callee51$(_context51) {
|
|
4822
|
+
while (1) switch (_context51.prev = _context51.next) {
|
|
4742
4823
|
case 0:
|
|
4743
4824
|
requestContext = {
|
|
4744
4825
|
operation_id: params.operationId,
|
|
@@ -4751,11 +4832,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
4751
4832
|
};
|
|
4752
4833
|
this.logInfo('processLocalPaymentUpdate: 开始处理', requestContext);
|
|
4753
4834
|
if (this.order) {
|
|
4754
|
-
|
|
4835
|
+
_context51.next = 5;
|
|
4755
4836
|
break;
|
|
4756
4837
|
}
|
|
4757
4838
|
this.logError('processLocalPaymentUpdate: Order 模块未注册', requestContext);
|
|
4758
|
-
return
|
|
4839
|
+
return _context51.abrupt("return", {
|
|
4759
4840
|
code: 500,
|
|
4760
4841
|
status: false,
|
|
4761
4842
|
message: 'Order 模块未注册',
|
|
@@ -4763,20 +4844,20 @@ var Server = /*#__PURE__*/function () {
|
|
|
4763
4844
|
});
|
|
4764
4845
|
case 5:
|
|
4765
4846
|
this.logInfo('processLocalPaymentUpdate: 开始查询本地支付项', requestContext);
|
|
4766
|
-
|
|
4847
|
+
_context51.next = 8;
|
|
4767
4848
|
return this.order.getLocalPayment({
|
|
4768
4849
|
saleId: params.saleId,
|
|
4769
4850
|
paymentNumber: params.paymentNumber,
|
|
4770
4851
|
operationId: params.operationId
|
|
4771
4852
|
});
|
|
4772
4853
|
case 8:
|
|
4773
|
-
found =
|
|
4854
|
+
found = _context51.sent;
|
|
4774
4855
|
if (found) {
|
|
4775
|
-
|
|
4856
|
+
_context51.next = 12;
|
|
4776
4857
|
break;
|
|
4777
4858
|
}
|
|
4778
4859
|
this.logWarning('processLocalPaymentUpdate: 本地支付项不存在', requestContext);
|
|
4779
|
-
return
|
|
4860
|
+
return _context51.abrupt("return", {
|
|
4780
4861
|
code: 404,
|
|
4781
4862
|
status: false,
|
|
4782
4863
|
message: '本地支付项不存在',
|
|
@@ -4825,13 +4906,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
4825
4906
|
});
|
|
4826
4907
|
this.logInfo('processLocalPaymentUpdate: 查询命中', foundContext);
|
|
4827
4908
|
if (!(params.status === 'fail' && (found.payment.status === 'paid' || hasRecordedSuccess))) {
|
|
4828
|
-
|
|
4909
|
+
_context51.next = 23;
|
|
4829
4910
|
break;
|
|
4830
4911
|
}
|
|
4831
4912
|
this.logInfo('processLocalPaymentUpdate: 幂等返回', _objectSpread(_objectSpread({}, foundContext), {}, {
|
|
4832
4913
|
idempotent_reason: 'ignore_failure_after_success'
|
|
4833
4914
|
}));
|
|
4834
|
-
return
|
|
4915
|
+
return _context51.abrupt("return", {
|
|
4835
4916
|
code: 200,
|
|
4836
4917
|
status: true,
|
|
4837
4918
|
message: '',
|
|
@@ -4844,13 +4925,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
4844
4925
|
case 23:
|
|
4845
4926
|
alreadyRecordedFailure = params.status === 'fail' && (existingTransaction === null || existingTransaction === void 0 ? void 0 : existingTransaction.status) === 'fail';
|
|
4846
4927
|
if (!alreadyRecordedFailure) {
|
|
4847
|
-
|
|
4928
|
+
_context51.next = 27;
|
|
4848
4929
|
break;
|
|
4849
4930
|
}
|
|
4850
4931
|
this.logInfo('processLocalPaymentUpdate: 幂等返回', _objectSpread(_objectSpread({}, foundContext), {}, {
|
|
4851
4932
|
idempotent_reason: 'failure_already_recorded'
|
|
4852
4933
|
}));
|
|
4853
|
-
return
|
|
4934
|
+
return _context51.abrupt("return", {
|
|
4854
4935
|
code: 200,
|
|
4855
4936
|
status: true,
|
|
4856
4937
|
message: '',
|
|
@@ -4862,13 +4943,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
4862
4943
|
});
|
|
4863
4944
|
case 27:
|
|
4864
4945
|
if (!(params.status === 'success' && (existingTransaction === null || existingTransaction === void 0 ? void 0 : existingTransaction.status) === 'success' && found.payment.status === 'paid' && !orderIsDraft)) {
|
|
4865
|
-
|
|
4946
|
+
_context51.next = 30;
|
|
4866
4947
|
break;
|
|
4867
4948
|
}
|
|
4868
4949
|
this.logInfo('processLocalPaymentUpdate: 幂等返回', _objectSpread(_objectSpread({}, foundContext), {}, {
|
|
4869
4950
|
idempotent_reason: 'success_already_committed'
|
|
4870
4951
|
}));
|
|
4871
|
-
return
|
|
4952
|
+
return _context51.abrupt("return", {
|
|
4872
4953
|
code: 200,
|
|
4873
4954
|
status: true,
|
|
4874
4955
|
message: '',
|
|
@@ -4880,13 +4961,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
4880
4961
|
});
|
|
4881
4962
|
case 30:
|
|
4882
4963
|
if (!(params.status === 'success')) {
|
|
4883
|
-
|
|
4964
|
+
_context51.next = 33;
|
|
4884
4965
|
break;
|
|
4885
4966
|
}
|
|
4886
4967
|
this.logInfo('processLocalPaymentUpdate: 进入 success 恢复分支', _objectSpread(_objectSpread({}, foundContext), {}, {
|
|
4887
4968
|
force_submit_if_paid: found.payment.status === 'paid' && orderIsDraft
|
|
4888
4969
|
}));
|
|
4889
|
-
return
|
|
4970
|
+
return _context51.abrupt("return", this.processSuccessfulLocalPayment(_objectSpread(_objectSpread({}, params), {}, {
|
|
4890
4971
|
order: found.order,
|
|
4891
4972
|
payment: found.payment,
|
|
4892
4973
|
matchBy: found.matchedBy === 'payment_number' ? 'payment_number' : 'compat',
|
|
@@ -4897,8 +4978,8 @@ var Server = /*#__PURE__*/function () {
|
|
|
4897
4978
|
this.logInfo('processLocalPaymentUpdate: 进入 fail 本地更新分支', _objectSpread(_objectSpread({}, foundContext), {}, {
|
|
4898
4979
|
incoming_payment_update: incomingPaymentUpdate
|
|
4899
4980
|
}));
|
|
4900
|
-
|
|
4901
|
-
|
|
4981
|
+
_context51.prev = 34;
|
|
4982
|
+
_context51.next = 37;
|
|
4902
4983
|
return this.order.updateLocalPayment({
|
|
4903
4984
|
saleId: params.saleId,
|
|
4904
4985
|
paymentNumber: params.paymentNumber,
|
|
@@ -4906,25 +4987,25 @@ var Server = /*#__PURE__*/function () {
|
|
|
4906
4987
|
updates: incomingPaymentUpdate
|
|
4907
4988
|
});
|
|
4908
4989
|
case 37:
|
|
4909
|
-
updated =
|
|
4910
|
-
|
|
4990
|
+
updated = _context51.sent;
|
|
4991
|
+
_context51.next = 44;
|
|
4911
4992
|
break;
|
|
4912
4993
|
case 40:
|
|
4913
|
-
|
|
4914
|
-
|
|
4994
|
+
_context51.prev = 40;
|
|
4995
|
+
_context51.t0 = _context51["catch"](34);
|
|
4915
4996
|
this.logError('processLocalPaymentUpdate: fail 本地更新失败', _objectSpread(_objectSpread({}, foundContext), {}, {
|
|
4916
4997
|
incoming_payment_update: incomingPaymentUpdate,
|
|
4917
|
-
error:
|
|
4918
|
-
error_detail: this.normalizeUnknownError(
|
|
4998
|
+
error: _context51.t0 instanceof Error ? _context51.t0.message : String(_context51.t0),
|
|
4999
|
+
error_detail: this.normalizeUnknownError(_context51.t0)
|
|
4919
5000
|
}));
|
|
4920
|
-
throw
|
|
5001
|
+
throw _context51.t0;
|
|
4921
5002
|
case 44:
|
|
4922
5003
|
if (updated) {
|
|
4923
|
-
|
|
5004
|
+
_context51.next = 47;
|
|
4924
5005
|
break;
|
|
4925
5006
|
}
|
|
4926
5007
|
this.logWarning('processLocalPaymentUpdate: fail 本地更新未命中', foundContext);
|
|
4927
|
-
return
|
|
5008
|
+
return _context51.abrupt("return", {
|
|
4928
5009
|
code: 404,
|
|
4929
5010
|
status: false,
|
|
4930
5011
|
message: '本地支付项不存在',
|
|
@@ -4935,7 +5016,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
4935
5016
|
previous_payment: updated.previousPayment,
|
|
4936
5017
|
payment: updated.payment
|
|
4937
5018
|
}));
|
|
4938
|
-
return
|
|
5019
|
+
return _context51.abrupt("return", {
|
|
4939
5020
|
code: 200,
|
|
4940
5021
|
status: true,
|
|
4941
5022
|
message: '',
|
|
@@ -4947,11 +5028,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
4947
5028
|
});
|
|
4948
5029
|
case 49:
|
|
4949
5030
|
case "end":
|
|
4950
|
-
return
|
|
5031
|
+
return _context51.stop();
|
|
4951
5032
|
}
|
|
4952
|
-
},
|
|
5033
|
+
}, _callee51, this, [[34, 40]]);
|
|
4953
5034
|
}));
|
|
4954
|
-
function processLocalPaymentUpdate(
|
|
5035
|
+
function processLocalPaymentUpdate(_x55) {
|
|
4955
5036
|
return _processLocalPaymentUpdate.apply(this, arguments);
|
|
4956
5037
|
}
|
|
4957
5038
|
return processLocalPaymentUpdate;
|
|
@@ -4959,10 +5040,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
4959
5040
|
}, {
|
|
4960
5041
|
key: "processSuccessfulLocalPayment",
|
|
4961
5042
|
value: function () {
|
|
4962
|
-
var _processSuccessfulLocalPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5043
|
+
var _processSuccessfulLocalPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee52(params) {
|
|
4963
5044
|
var moduleName, baseSales, startedAt, recoveryContext, _order$order_id3, _result$payments, _result$syncResult$su, _result$syncResult$su2, _result$draftResult, _result$draftResult2, order, result, message;
|
|
4964
|
-
return _regeneratorRuntime().wrap(function
|
|
4965
|
-
while (1) switch (
|
|
5045
|
+
return _regeneratorRuntime().wrap(function _callee52$(_context52) {
|
|
5046
|
+
while (1) switch (_context52.prev = _context52.next) {
|
|
4966
5047
|
case 0:
|
|
4967
5048
|
moduleName = "local_payment_recovery_".concat(Date.now(), "_").concat(Math.random().toString(36).slice(2, 8));
|
|
4968
5049
|
baseSales = new BaseSalesImpl(moduleName);
|
|
@@ -4981,13 +5062,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
4981
5062
|
payment: params.payment
|
|
4982
5063
|
});
|
|
4983
5064
|
this.logInfo('processSuccessfulLocalPayment: 创建临时 BaseSales', recoveryContext);
|
|
4984
|
-
|
|
5065
|
+
_context52.prev = 5;
|
|
4985
5066
|
order = this.sanitizeLocalRecoveryOrder(params.order);
|
|
4986
5067
|
this.logInfo('processSuccessfulLocalPayment: 本地订单清洗完成', _objectSpread(_objectSpread({}, recoveryContext), {}, {
|
|
4987
5068
|
sanitized_order_id: (_order$order_id3 = order.order_id) !== null && _order$order_id3 !== void 0 ? _order$order_id3 : null,
|
|
4988
5069
|
removed_synthetic_order_id: params.order.order_id != null && order.order_id == null
|
|
4989
5070
|
}));
|
|
4990
|
-
|
|
5071
|
+
_context52.next = 10;
|
|
4991
5072
|
return baseSales.initialize(this.core, {
|
|
4992
5073
|
otherParams: {
|
|
4993
5074
|
platform: order.platform,
|
|
@@ -5000,14 +5081,14 @@ var Server = /*#__PURE__*/function () {
|
|
|
5000
5081
|
});
|
|
5001
5082
|
case 10:
|
|
5002
5083
|
this.logInfo('processSuccessfulLocalPayment: BaseSales 初始化完成', recoveryContext);
|
|
5003
|
-
|
|
5084
|
+
_context52.next = 13;
|
|
5004
5085
|
return baseSales.replaceTempOrder(order);
|
|
5005
5086
|
case 13:
|
|
5006
5087
|
this.logInfo('processSuccessfulLocalPayment: 本地订单 tempOrder 恢复完成', recoveryContext);
|
|
5007
5088
|
this.logInfo('processSuccessfulLocalPayment: 开始更新支付项并提交', _objectSpread(_objectSpread({}, recoveryContext), {}, {
|
|
5008
5089
|
incoming_payment_update: params.paymentUpdate
|
|
5009
5090
|
}));
|
|
5010
|
-
|
|
5091
|
+
_context52.next = 17;
|
|
5011
5092
|
return baseSales.updateOrderPayment(params.paymentNumber, params.paymentUpdate, {
|
|
5012
5093
|
submitWhenPaid: true,
|
|
5013
5094
|
matchBy: params.matchBy,
|
|
@@ -5016,7 +5097,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
5016
5097
|
smallTicketDataFlag: 1
|
|
5017
5098
|
});
|
|
5018
5099
|
case 17:
|
|
5019
|
-
result =
|
|
5100
|
+
result = _context52.sent;
|
|
5020
5101
|
this.logInfo('processSuccessfulLocalPayment: 支付恢复完成', _objectSpread(_objectSpread({}, recoveryContext), {}, {
|
|
5021
5102
|
duration_ms: Date.now() - startedAt,
|
|
5022
5103
|
payment: result.payment,
|
|
@@ -5038,7 +5119,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
5038
5119
|
} : null,
|
|
5039
5120
|
draft_error: result.draftError instanceof Error ? result.draftError.message : result.draftError
|
|
5040
5121
|
}));
|
|
5041
|
-
return
|
|
5122
|
+
return _context52.abrupt("return", {
|
|
5042
5123
|
code: 200,
|
|
5043
5124
|
status: true,
|
|
5044
5125
|
message: '',
|
|
@@ -5050,48 +5131,48 @@ var Server = /*#__PURE__*/function () {
|
|
|
5050
5131
|
}
|
|
5051
5132
|
});
|
|
5052
5133
|
case 22:
|
|
5053
|
-
|
|
5054
|
-
|
|
5055
|
-
message =
|
|
5134
|
+
_context52.prev = 22;
|
|
5135
|
+
_context52.t0 = _context52["catch"](5);
|
|
5136
|
+
message = _context52.t0 instanceof Error ? _context52.t0.message : String(_context52.t0);
|
|
5056
5137
|
this.logError('processSuccessfulLocalPayment: 支付恢复失败', _objectSpread(_objectSpread({}, recoveryContext), {}, {
|
|
5057
5138
|
duration_ms: Date.now() - startedAt,
|
|
5058
5139
|
error: message,
|
|
5059
|
-
error_detail: this.normalizeUnknownError(
|
|
5140
|
+
error_detail: this.normalizeUnknownError(_context52.t0)
|
|
5060
5141
|
}));
|
|
5061
|
-
return
|
|
5142
|
+
return _context52.abrupt("return", {
|
|
5062
5143
|
code: 500,
|
|
5063
5144
|
status: false,
|
|
5064
5145
|
message: message,
|
|
5065
5146
|
data: null
|
|
5066
5147
|
});
|
|
5067
5148
|
case 27:
|
|
5068
|
-
|
|
5069
|
-
|
|
5070
|
-
|
|
5149
|
+
_context52.prev = 27;
|
|
5150
|
+
_context52.prev = 28;
|
|
5151
|
+
_context52.next = 31;
|
|
5071
5152
|
return baseSales.destroy();
|
|
5072
5153
|
case 31:
|
|
5073
5154
|
this.logInfo('processSuccessfulLocalPayment: 临时 BaseSales 销毁完成', _objectSpread(_objectSpread({}, recoveryContext), {}, {
|
|
5074
5155
|
duration_ms: Date.now() - startedAt
|
|
5075
5156
|
}));
|
|
5076
|
-
|
|
5157
|
+
_context52.next = 37;
|
|
5077
5158
|
break;
|
|
5078
5159
|
case 34:
|
|
5079
|
-
|
|
5080
|
-
|
|
5160
|
+
_context52.prev = 34;
|
|
5161
|
+
_context52.t1 = _context52["catch"](28);
|
|
5081
5162
|
this.logError('processSuccessfulLocalPayment: 临时 BaseSales 销毁失败', _objectSpread(_objectSpread({}, recoveryContext), {}, {
|
|
5082
5163
|
duration_ms: Date.now() - startedAt,
|
|
5083
|
-
error:
|
|
5084
|
-
error_detail: this.normalizeUnknownError(
|
|
5164
|
+
error: _context52.t1 instanceof Error ? _context52.t1.message : String(_context52.t1),
|
|
5165
|
+
error_detail: this.normalizeUnknownError(_context52.t1)
|
|
5085
5166
|
}));
|
|
5086
5167
|
case 37:
|
|
5087
|
-
return
|
|
5168
|
+
return _context52.finish(27);
|
|
5088
5169
|
case 38:
|
|
5089
5170
|
case "end":
|
|
5090
|
-
return
|
|
5171
|
+
return _context52.stop();
|
|
5091
5172
|
}
|
|
5092
|
-
},
|
|
5173
|
+
}, _callee52, this, [[5, 22, 27, 38], [28, 34]]);
|
|
5093
5174
|
}));
|
|
5094
|
-
function processSuccessfulLocalPayment(
|
|
5175
|
+
function processSuccessfulLocalPayment(_x56) {
|
|
5095
5176
|
return _processSuccessfulLocalPayment.apply(this, arguments);
|
|
5096
5177
|
}
|
|
5097
5178
|
return processSuccessfulLocalPayment;
|
|
@@ -5182,32 +5263,32 @@ var Server = /*#__PURE__*/function () {
|
|
|
5182
5263
|
}, {
|
|
5183
5264
|
key: "getShortNumberOrDeviceId",
|
|
5184
5265
|
value: function () {
|
|
5185
|
-
var _getShortNumberOrDeviceId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5266
|
+
var _getShortNumberOrDeviceId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee53() {
|
|
5186
5267
|
var getAsyncIotDeviceInfo, res;
|
|
5187
|
-
return _regeneratorRuntime().wrap(function
|
|
5188
|
-
while (1) switch (
|
|
5268
|
+
return _regeneratorRuntime().wrap(function _callee53$(_context53) {
|
|
5269
|
+
while (1) switch (_context53.prev = _context53.next) {
|
|
5189
5270
|
case 0:
|
|
5190
5271
|
getAsyncIotDeviceInfo = this.getAppData('async_iot_device_info');
|
|
5191
5272
|
if (!getAsyncIotDeviceInfo) {
|
|
5192
|
-
|
|
5273
|
+
_context53.next = 7;
|
|
5193
5274
|
break;
|
|
5194
5275
|
}
|
|
5195
|
-
|
|
5276
|
+
_context53.next = 4;
|
|
5196
5277
|
return getAsyncIotDeviceInfo === null || getAsyncIotDeviceInfo === void 0 ? void 0 : getAsyncIotDeviceInfo();
|
|
5197
5278
|
case 4:
|
|
5198
|
-
res =
|
|
5279
|
+
res = _context53.sent;
|
|
5199
5280
|
if (!(res !== null && res !== void 0 && res.short_number)) {
|
|
5200
|
-
|
|
5281
|
+
_context53.next = 7;
|
|
5201
5282
|
break;
|
|
5202
5283
|
}
|
|
5203
|
-
return
|
|
5284
|
+
return _context53.abrupt("return", res === null || res === void 0 ? void 0 : res.short_number);
|
|
5204
5285
|
case 7:
|
|
5205
|
-
return
|
|
5286
|
+
return _context53.abrupt("return", String(this.getAppData('device_id') || 0).slice(-2));
|
|
5206
5287
|
case 8:
|
|
5207
5288
|
case "end":
|
|
5208
|
-
return
|
|
5289
|
+
return _context53.stop();
|
|
5209
5290
|
}
|
|
5210
|
-
},
|
|
5291
|
+
}, _callee53, this);
|
|
5211
5292
|
}));
|
|
5212
5293
|
function getShortNumberOrDeviceId() {
|
|
5213
5294
|
return _getShortNumberOrDeviceId.apply(this, arguments);
|
|
@@ -5234,16 +5315,16 @@ var Server = /*#__PURE__*/function () {
|
|
|
5234
5315
|
}, {
|
|
5235
5316
|
key: "normalizeCheckoutSubmitData",
|
|
5236
5317
|
value: function () {
|
|
5237
|
-
var _normalizeCheckoutSubmitData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5318
|
+
var _normalizeCheckoutSubmitData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee54(data, title) {
|
|
5238
5319
|
var next, externalSaleNumber, shouldClearLocalOrderId, hasCheckoutOrderNumbers, localOrder;
|
|
5239
|
-
return _regeneratorRuntime().wrap(function
|
|
5240
|
-
while (1) switch (
|
|
5320
|
+
return _regeneratorRuntime().wrap(function _callee54$(_context54) {
|
|
5321
|
+
while (1) switch (_context54.prev = _context54.next) {
|
|
5241
5322
|
case 0:
|
|
5242
5323
|
if (!(!data || _typeof(data) !== 'object')) {
|
|
5243
|
-
|
|
5324
|
+
_context54.next = 2;
|
|
5244
5325
|
break;
|
|
5245
5326
|
}
|
|
5246
|
-
return
|
|
5327
|
+
return _context54.abrupt("return", data);
|
|
5247
5328
|
case 2:
|
|
5248
5329
|
next = _objectSpread({}, data);
|
|
5249
5330
|
externalSaleNumber = next.external_sale_number;
|
|
@@ -5253,7 +5334,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
5253
5334
|
delete next.vouchers;
|
|
5254
5335
|
hasCheckoutOrderNumbers = !this.isBlankCheckoutValue(next.shop_order_number) && !this.isBlankCheckoutValue(next.shop_full_order_number);
|
|
5255
5336
|
if (!hasCheckoutOrderNumbers) {
|
|
5256
|
-
|
|
5337
|
+
_context54.next = 11;
|
|
5257
5338
|
break;
|
|
5258
5339
|
}
|
|
5259
5340
|
this.logInfo("".concat(title, ": checkout \u5DF2\u643A\u5E26\u8BA2\u5355\u53F7\uFF0C\u8DF3\u8FC7\u67E5\u91CD"), {
|
|
@@ -5263,10 +5344,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
5263
5344
|
shop_order_number: next.shop_order_number,
|
|
5264
5345
|
shop_full_order_number: next.shop_full_order_number
|
|
5265
5346
|
});
|
|
5266
|
-
return
|
|
5347
|
+
return _context54.abrupt("return", next);
|
|
5267
5348
|
case 11:
|
|
5268
5349
|
if (!this.isBlankCheckoutValue(externalSaleNumber)) {
|
|
5269
|
-
|
|
5350
|
+
_context54.next = 14;
|
|
5270
5351
|
break;
|
|
5271
5352
|
}
|
|
5272
5353
|
if (shouldClearLocalOrderId) {
|
|
@@ -5275,10 +5356,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
5275
5356
|
order_id: next.order_id
|
|
5276
5357
|
});
|
|
5277
5358
|
}
|
|
5278
|
-
return
|
|
5359
|
+
return _context54.abrupt("return", next);
|
|
5279
5360
|
case 14:
|
|
5280
5361
|
if (!(!this.order || typeof this.order.getLocalOrderFromMemoryByLookup !== 'function')) {
|
|
5281
|
-
|
|
5362
|
+
_context54.next = 17;
|
|
5282
5363
|
break;
|
|
5283
5364
|
}
|
|
5284
5365
|
if (shouldClearLocalOrderId) {
|
|
@@ -5287,12 +5368,12 @@ var Server = /*#__PURE__*/function () {
|
|
|
5287
5368
|
external_sale_number: externalSaleNumber
|
|
5288
5369
|
});
|
|
5289
5370
|
}
|
|
5290
|
-
return
|
|
5371
|
+
return _context54.abrupt("return", next);
|
|
5291
5372
|
case 17:
|
|
5292
|
-
|
|
5373
|
+
_context54.prev = 17;
|
|
5293
5374
|
localOrder = this.order.getLocalOrderFromMemoryByLookup(externalSaleNumber);
|
|
5294
5375
|
if (localOrder) {
|
|
5295
|
-
|
|
5376
|
+
_context54.next = 22;
|
|
5296
5377
|
break;
|
|
5297
5378
|
}
|
|
5298
5379
|
if (shouldClearLocalOrderId) {
|
|
@@ -5302,7 +5383,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
5302
5383
|
localOrderFound: false
|
|
5303
5384
|
});
|
|
5304
5385
|
}
|
|
5305
|
-
return
|
|
5386
|
+
return _context54.abrupt("return", next);
|
|
5306
5387
|
case 22:
|
|
5307
5388
|
if (this.isBlankCheckoutValue(next.shop_order_number)) {
|
|
5308
5389
|
next.shop_order_number = localOrder.shop_order_number;
|
|
@@ -5319,23 +5400,23 @@ var Server = /*#__PURE__*/function () {
|
|
|
5319
5400
|
shop_full_order_number: next.shop_full_order_number
|
|
5320
5401
|
});
|
|
5321
5402
|
// 删除 数据体中的 vouchers,对小票和后端来说他们不需要,这个字段只是单向同步给前端用的,而且目前对订单来说还没什么用
|
|
5322
|
-
return
|
|
5403
|
+
return _context54.abrupt("return", next);
|
|
5323
5404
|
case 28:
|
|
5324
|
-
|
|
5325
|
-
|
|
5405
|
+
_context54.prev = 28;
|
|
5406
|
+
_context54.t0 = _context54["catch"](17);
|
|
5326
5407
|
this.logWarning("".concat(title, ": checkout \u67E5\u627E\u672C\u5730\u8BA2\u5355\u5931\u8D25"), {
|
|
5327
5408
|
external_sale_number: externalSaleNumber,
|
|
5328
|
-
error: this.getUnknownErrorMessage(
|
|
5329
|
-
error_detail: this.normalizeUnknownError(
|
|
5409
|
+
error: this.getUnknownErrorMessage(_context54.t0),
|
|
5410
|
+
error_detail: this.normalizeUnknownError(_context54.t0)
|
|
5330
5411
|
});
|
|
5331
|
-
return
|
|
5412
|
+
return _context54.abrupt("return", next);
|
|
5332
5413
|
case 32:
|
|
5333
5414
|
case "end":
|
|
5334
|
-
return
|
|
5415
|
+
return _context54.stop();
|
|
5335
5416
|
}
|
|
5336
|
-
},
|
|
5417
|
+
}, _callee54, this, [[17, 28]]);
|
|
5337
5418
|
}));
|
|
5338
|
-
function normalizeCheckoutSubmitData(
|
|
5419
|
+
function normalizeCheckoutSubmitData(_x57, _x58) {
|
|
5339
5420
|
return _normalizeCheckoutSubmitData.apply(this, arguments);
|
|
5340
5421
|
}
|
|
5341
5422
|
return normalizeCheckoutSubmitData;
|
|
@@ -5343,81 +5424,81 @@ var Server = /*#__PURE__*/function () {
|
|
|
5343
5424
|
}, {
|
|
5344
5425
|
key: "ensureCheckoutOrderNumbers",
|
|
5345
5426
|
value: function () {
|
|
5346
|
-
var _ensureCheckoutOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5427
|
+
var _ensureCheckoutOrderNumbers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee55(data, title) {
|
|
5347
5428
|
var next, needsShopOrderNumber, needsShopFullOrderNumber, idGenerator;
|
|
5348
|
-
return _regeneratorRuntime().wrap(function
|
|
5349
|
-
while (1) switch (
|
|
5429
|
+
return _regeneratorRuntime().wrap(function _callee55$(_context55) {
|
|
5430
|
+
while (1) switch (_context55.prev = _context55.next) {
|
|
5350
5431
|
case 0:
|
|
5351
5432
|
if (!(!data || _typeof(data) !== 'object')) {
|
|
5352
|
-
|
|
5433
|
+
_context55.next = 2;
|
|
5353
5434
|
break;
|
|
5354
5435
|
}
|
|
5355
|
-
return
|
|
5436
|
+
return _context55.abrupt("return", data);
|
|
5356
5437
|
case 2:
|
|
5357
5438
|
next = _objectSpread({}, data);
|
|
5358
5439
|
needsShopOrderNumber = next.shop_order_number === undefined || next.shop_order_number === null || next.shop_order_number === '';
|
|
5359
5440
|
needsShopFullOrderNumber = next.shop_full_order_number === undefined || next.shop_full_order_number === null || next.shop_full_order_number === '';
|
|
5360
5441
|
if (!(!needsShopOrderNumber && !needsShopFullOrderNumber)) {
|
|
5361
|
-
|
|
5442
|
+
_context55.next = 7;
|
|
5362
5443
|
break;
|
|
5363
5444
|
}
|
|
5364
|
-
return
|
|
5445
|
+
return _context55.abrupt("return", next);
|
|
5365
5446
|
case 7:
|
|
5366
5447
|
idGenerator = this.getIdGeneratorPlugin();
|
|
5367
5448
|
if (idGenerator) {
|
|
5368
|
-
|
|
5449
|
+
_context55.next = 11;
|
|
5369
5450
|
break;
|
|
5370
5451
|
}
|
|
5371
5452
|
this.logWarning("".concat(title, ": idGenerator \u63D2\u4EF6\u4E0D\u53EF\u7528\uFF0C\u65E0\u6CD5\u751F\u6210\u8BA2\u5355\u53F7"), {
|
|
5372
5453
|
needsShopOrderNumber: needsShopOrderNumber,
|
|
5373
5454
|
needsShopFullOrderNumber: needsShopFullOrderNumber
|
|
5374
5455
|
});
|
|
5375
|
-
return
|
|
5456
|
+
return _context55.abrupt("return", next);
|
|
5376
5457
|
case 11:
|
|
5377
|
-
|
|
5458
|
+
_context55.prev = 11;
|
|
5378
5459
|
if (!(needsShopOrderNumber && idGenerator.generateShopOrderNumber)) {
|
|
5379
|
-
|
|
5460
|
+
_context55.next = 16;
|
|
5380
5461
|
break;
|
|
5381
5462
|
}
|
|
5382
|
-
|
|
5463
|
+
_context55.next = 15;
|
|
5383
5464
|
return idGenerator.generateShopOrderNumber({
|
|
5384
5465
|
biz: next.business_code || 'ticket'
|
|
5385
5466
|
});
|
|
5386
5467
|
case 15:
|
|
5387
|
-
next.shop_order_number =
|
|
5468
|
+
next.shop_order_number = _context55.sent;
|
|
5388
5469
|
case 16:
|
|
5389
5470
|
if (!(needsShopFullOrderNumber && idGenerator.generateReceiptId)) {
|
|
5390
|
-
|
|
5471
|
+
_context55.next = 20;
|
|
5391
5472
|
break;
|
|
5392
5473
|
}
|
|
5393
|
-
|
|
5474
|
+
_context55.next = 19;
|
|
5394
5475
|
return idGenerator.generateReceiptId({
|
|
5395
5476
|
biz: next.business_code || 'ticket'
|
|
5396
5477
|
});
|
|
5397
5478
|
case 19:
|
|
5398
|
-
next.shop_full_order_number =
|
|
5479
|
+
next.shop_full_order_number = _context55.sent;
|
|
5399
5480
|
case 20:
|
|
5400
5481
|
this.logInfo("".concat(title, ": checkout \u8BA2\u5355\u53F7\u5DF2\u51C6\u5907"), {
|
|
5401
5482
|
shop_order_number: next.shop_order_number,
|
|
5402
5483
|
shop_full_order_number: next.shop_full_order_number
|
|
5403
5484
|
});
|
|
5404
|
-
|
|
5485
|
+
_context55.next = 26;
|
|
5405
5486
|
break;
|
|
5406
5487
|
case 23:
|
|
5407
|
-
|
|
5408
|
-
|
|
5488
|
+
_context55.prev = 23;
|
|
5489
|
+
_context55.t0 = _context55["catch"](11);
|
|
5409
5490
|
this.logError("".concat(title, ": \u751F\u6210 checkout \u8BA2\u5355\u53F7\u5931\u8D25"), {
|
|
5410
|
-
error:
|
|
5491
|
+
error: _context55.t0 instanceof Error ? _context55.t0.message : String(_context55.t0)
|
|
5411
5492
|
});
|
|
5412
5493
|
case 26:
|
|
5413
|
-
return
|
|
5494
|
+
return _context55.abrupt("return", next);
|
|
5414
5495
|
case 27:
|
|
5415
5496
|
case "end":
|
|
5416
|
-
return
|
|
5497
|
+
return _context55.stop();
|
|
5417
5498
|
}
|
|
5418
|
-
},
|
|
5499
|
+
}, _callee55, this, [[11, 23]]);
|
|
5419
5500
|
}));
|
|
5420
|
-
function ensureCheckoutOrderNumbers(
|
|
5501
|
+
function ensureCheckoutOrderNumbers(_x59, _x60) {
|
|
5421
5502
|
return _ensureCheckoutOrderNumbers.apply(this, arguments);
|
|
5422
5503
|
}
|
|
5423
5504
|
return ensureCheckoutOrderNumbers;
|
|
@@ -5425,27 +5506,27 @@ var Server = /*#__PURE__*/function () {
|
|
|
5425
5506
|
}, {
|
|
5426
5507
|
key: "dispatchCheckoutSyncTask",
|
|
5427
5508
|
value: function () {
|
|
5428
|
-
var _dispatchCheckoutSyncTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5509
|
+
var _dispatchCheckoutSyncTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee56(params) {
|
|
5429
5510
|
var deviceTask, debugDeviceId, debugIdempotencyKey, _params$data, _params$data2, _params$data3, _params$data4, result;
|
|
5430
|
-
return _regeneratorRuntime().wrap(function
|
|
5431
|
-
while (1) switch (
|
|
5511
|
+
return _regeneratorRuntime().wrap(function _callee56$(_context56) {
|
|
5512
|
+
while (1) switch (_context56.prev = _context56.next) {
|
|
5432
5513
|
case 0:
|
|
5433
5514
|
this.registerDeviceTaskActions();
|
|
5434
5515
|
deviceTask = this.getDeviceTaskPlugin();
|
|
5435
|
-
|
|
5516
|
+
_context56.next = 4;
|
|
5436
5517
|
return this.getShortNumberOrDeviceId();
|
|
5437
5518
|
case 4:
|
|
5438
|
-
debugDeviceId =
|
|
5519
|
+
debugDeviceId = _context56.sent;
|
|
5439
5520
|
debugIdempotencyKey = this.buildCheckoutTaskIdempotencyKey(params.data);
|
|
5440
5521
|
if (deviceTask !== null && deviceTask !== void 0 && deviceTask.dispatch) {
|
|
5441
|
-
|
|
5522
|
+
_context56.next = 9;
|
|
5442
5523
|
break;
|
|
5443
5524
|
}
|
|
5444
5525
|
this.logError("".concat(params.title, ": deviceTask.dispatch \u4E0D\u53EF\u7528"));
|
|
5445
|
-
return
|
|
5526
|
+
return _context56.abrupt("return");
|
|
5446
5527
|
case 9:
|
|
5447
|
-
|
|
5448
|
-
|
|
5528
|
+
_context56.prev = 9;
|
|
5529
|
+
_context56.next = 12;
|
|
5449
5530
|
return deviceTask.dispatch({
|
|
5450
5531
|
action: 'sync_sales',
|
|
5451
5532
|
device_id: debugDeviceId,
|
|
@@ -5463,27 +5544,27 @@ var Server = /*#__PURE__*/function () {
|
|
|
5463
5544
|
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)
|
|
5464
5545
|
});
|
|
5465
5546
|
case 12:
|
|
5466
|
-
result =
|
|
5547
|
+
result = _context56.sent;
|
|
5467
5548
|
this.logInfo("".concat(params.title, ": sync_sales \u4EFB\u52A1\u5DF2\u6D3E\u53D1"), {
|
|
5468
5549
|
uuid: result === null || result === void 0 ? void 0 : result.uuid,
|
|
5469
5550
|
status: result === null || result === void 0 ? void 0 : result.status,
|
|
5470
5551
|
reused: result === null || result === void 0 ? void 0 : result.reused
|
|
5471
5552
|
});
|
|
5472
|
-
|
|
5553
|
+
_context56.next = 19;
|
|
5473
5554
|
break;
|
|
5474
5555
|
case 16:
|
|
5475
|
-
|
|
5476
|
-
|
|
5556
|
+
_context56.prev = 16;
|
|
5557
|
+
_context56.t0 = _context56["catch"](9);
|
|
5477
5558
|
this.logError("".concat(params.title, ": \u6D3E\u53D1 sync_sales \u4EFB\u52A1\u5931\u8D25"), {
|
|
5478
|
-
error:
|
|
5559
|
+
error: _context56.t0 instanceof Error ? _context56.t0.message : String(_context56.t0)
|
|
5479
5560
|
});
|
|
5480
5561
|
case 19:
|
|
5481
5562
|
case "end":
|
|
5482
|
-
return
|
|
5563
|
+
return _context56.stop();
|
|
5483
5564
|
}
|
|
5484
|
-
},
|
|
5565
|
+
}, _callee56, this, [[9, 16]]);
|
|
5485
5566
|
}));
|
|
5486
|
-
function dispatchCheckoutSyncTask(
|
|
5567
|
+
function dispatchCheckoutSyncTask(_x61) {
|
|
5487
5568
|
return _dispatchCheckoutSyncTask.apply(this, arguments);
|
|
5488
5569
|
}
|
|
5489
5570
|
return dispatchCheckoutSyncTask;
|
|
@@ -5491,26 +5572,26 @@ var Server = /*#__PURE__*/function () {
|
|
|
5491
5572
|
}, {
|
|
5492
5573
|
key: "dispatchPrintOtherReceiptTask",
|
|
5493
5574
|
value: function () {
|
|
5494
|
-
var _dispatchPrintOtherReceiptTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5575
|
+
var _dispatchPrintOtherReceiptTask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee57(params) {
|
|
5495
5576
|
var deviceTask, _params$deviceId, _params$syncedOrder, _params$syncedOrder2, _params$syncedOrder3, printIdentity, deviceId;
|
|
5496
|
-
return _regeneratorRuntime().wrap(function
|
|
5497
|
-
while (1) switch (
|
|
5577
|
+
return _regeneratorRuntime().wrap(function _callee57$(_context57) {
|
|
5578
|
+
while (1) switch (_context57.prev = _context57.next) {
|
|
5498
5579
|
case 0:
|
|
5499
5580
|
deviceTask = this.getDeviceTaskPlugin();
|
|
5500
5581
|
if (deviceTask !== null && deviceTask !== void 0 && deviceTask.dispatch) {
|
|
5501
|
-
|
|
5582
|
+
_context57.next = 4;
|
|
5502
5583
|
break;
|
|
5503
5584
|
}
|
|
5504
5585
|
this.logWarning('dispatchPrintOtherReceiptTask: deviceTask.dispatch 不可用');
|
|
5505
|
-
return
|
|
5586
|
+
return _context57.abrupt("return");
|
|
5506
5587
|
case 4:
|
|
5507
|
-
|
|
5588
|
+
_context57.prev = 4;
|
|
5508
5589
|
printIdentity = this.getPrintOrderIdentity(params.syncedOrder);
|
|
5509
|
-
|
|
5590
|
+
_context57.next = 8;
|
|
5510
5591
|
return this.getShortNumberOrDeviceId();
|
|
5511
5592
|
case 8:
|
|
5512
|
-
deviceId =
|
|
5513
|
-
|
|
5593
|
+
deviceId = _context57.sent;
|
|
5594
|
+
_context57.next = 11;
|
|
5514
5595
|
return deviceTask.dispatch({
|
|
5515
5596
|
action: 'print_all',
|
|
5516
5597
|
device_id: (_params$deviceId = params.deviceId) !== null && _params$deviceId !== void 0 ? _params$deviceId : deviceId,
|
|
@@ -5537,21 +5618,21 @@ var Server = /*#__PURE__*/function () {
|
|
|
5537
5618
|
source_id: printIdentity
|
|
5538
5619
|
});
|
|
5539
5620
|
case 11:
|
|
5540
|
-
|
|
5621
|
+
_context57.next = 16;
|
|
5541
5622
|
break;
|
|
5542
5623
|
case 13:
|
|
5543
|
-
|
|
5544
|
-
|
|
5624
|
+
_context57.prev = 13;
|
|
5625
|
+
_context57.t0 = _context57["catch"](4);
|
|
5545
5626
|
this.logError('dispatchPrintOtherReceiptTask: 派发失败', {
|
|
5546
|
-
error:
|
|
5627
|
+
error: _context57.t0 instanceof Error ? _context57.t0.message : String(_context57.t0)
|
|
5547
5628
|
});
|
|
5548
5629
|
case 16:
|
|
5549
5630
|
case "end":
|
|
5550
|
-
return
|
|
5631
|
+
return _context57.stop();
|
|
5551
5632
|
}
|
|
5552
|
-
},
|
|
5633
|
+
}, _callee57, this, [[4, 13]]);
|
|
5553
5634
|
}));
|
|
5554
|
-
function dispatchPrintOtherReceiptTask(
|
|
5635
|
+
function dispatchPrintOtherReceiptTask(_x62) {
|
|
5555
5636
|
return _dispatchPrintOtherReceiptTask.apply(this, arguments);
|
|
5556
5637
|
}
|
|
5557
5638
|
return dispatchPrintOtherReceiptTask;
|
|
@@ -5571,32 +5652,32 @@ var Server = /*#__PURE__*/function () {
|
|
|
5571
5652
|
}, {
|
|
5572
5653
|
key: "dispatchLocalReceiptPrint",
|
|
5573
5654
|
value: function () {
|
|
5574
|
-
var _dispatchLocalReceiptPrint = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5655
|
+
var _dispatchLocalReceiptPrint = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee58(params) {
|
|
5575
5656
|
var _payment_info;
|
|
5576
5657
|
var printableOrder;
|
|
5577
|
-
return _regeneratorRuntime().wrap(function
|
|
5578
|
-
while (1) switch (
|
|
5658
|
+
return _regeneratorRuntime().wrap(function _callee58$(_context58) {
|
|
5659
|
+
while (1) switch (_context58.prev = _context58.next) {
|
|
5579
5660
|
case 0:
|
|
5580
5661
|
if (!(params.requireFullyPaid && !this.isSalesOrderFullyPaid(params.order))) {
|
|
5581
|
-
|
|
5662
|
+
_context58.next = 2;
|
|
5582
5663
|
break;
|
|
5583
5664
|
}
|
|
5584
|
-
return
|
|
5665
|
+
return _context58.abrupt("return", {
|
|
5585
5666
|
printed: false,
|
|
5586
5667
|
order: params.order
|
|
5587
5668
|
});
|
|
5588
5669
|
case 2:
|
|
5589
|
-
|
|
5670
|
+
_context58.next = 4;
|
|
5590
5671
|
return this.withLocalSmallTicketData(params.order, {
|
|
5591
5672
|
requireFullyPaid: params.requireFullyPaid
|
|
5592
5673
|
});
|
|
5593
5674
|
case 4:
|
|
5594
|
-
printableOrder =
|
|
5675
|
+
printableOrder = _context58.sent;
|
|
5595
5676
|
if (hasSmallTicketData((_payment_info = printableOrder.payment_info) === null || _payment_info === void 0 ? void 0 : _payment_info.small_ticket_data)) {
|
|
5596
|
-
|
|
5677
|
+
_context58.next = 7;
|
|
5597
5678
|
break;
|
|
5598
5679
|
}
|
|
5599
|
-
return
|
|
5680
|
+
return _context58.abrupt("return", {
|
|
5600
5681
|
printed: false,
|
|
5601
5682
|
order: printableOrder
|
|
5602
5683
|
});
|
|
@@ -5606,7 +5687,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
5606
5687
|
printableOrder: printableOrder,
|
|
5607
5688
|
response: params.response
|
|
5608
5689
|
});
|
|
5609
|
-
|
|
5690
|
+
_context58.next = 10;
|
|
5610
5691
|
return this.dispatchPrintOtherReceiptTask({
|
|
5611
5692
|
checkoutData: params.checkoutData,
|
|
5612
5693
|
syncedOrder: printableOrder,
|
|
@@ -5615,17 +5696,17 @@ var Server = /*#__PURE__*/function () {
|
|
|
5615
5696
|
isManualPrint: params.isManualPrint
|
|
5616
5697
|
});
|
|
5617
5698
|
case 10:
|
|
5618
|
-
return
|
|
5699
|
+
return _context58.abrupt("return", {
|
|
5619
5700
|
printed: true,
|
|
5620
5701
|
order: printableOrder
|
|
5621
5702
|
});
|
|
5622
5703
|
case 11:
|
|
5623
5704
|
case "end":
|
|
5624
|
-
return
|
|
5705
|
+
return _context58.stop();
|
|
5625
5706
|
}
|
|
5626
|
-
},
|
|
5707
|
+
}, _callee58, this);
|
|
5627
5708
|
}));
|
|
5628
|
-
function dispatchLocalReceiptPrint(
|
|
5709
|
+
function dispatchLocalReceiptPrint(_x63) {
|
|
5629
5710
|
return _dispatchLocalReceiptPrint.apply(this, arguments);
|
|
5630
5711
|
}
|
|
5631
5712
|
return dispatchLocalReceiptPrint;
|
|
@@ -5660,47 +5741,47 @@ var Server = /*#__PURE__*/function () {
|
|
|
5660
5741
|
}, {
|
|
5661
5742
|
key: "syncMachinecodeRedeemStatusToLocalOrder",
|
|
5662
5743
|
value: function () {
|
|
5663
|
-
var _syncMachinecodeRedeemStatusToLocalOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5744
|
+
var _syncMachinecodeRedeemStatusToLocalOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee59(data, ids, status) {
|
|
5664
5745
|
var _this$order3;
|
|
5665
5746
|
var title, lookup, localOrder, voucherIdSet, vouchers, hasUpdatedVoucher, nextVouchers;
|
|
5666
|
-
return _regeneratorRuntime().wrap(function
|
|
5667
|
-
while (1) switch (
|
|
5747
|
+
return _regeneratorRuntime().wrap(function _callee59$(_context59) {
|
|
5748
|
+
while (1) switch (_context59.prev = _context59.next) {
|
|
5668
5749
|
case 0:
|
|
5669
5750
|
title = 'handleMachinecodeBatchMetadata';
|
|
5670
5751
|
lookup = this.resolveMachinecodeBatchMetadataLookup(data);
|
|
5671
5752
|
if (!(lookup === undefined)) {
|
|
5672
|
-
|
|
5753
|
+
_context59.next = 5;
|
|
5673
5754
|
break;
|
|
5674
5755
|
}
|
|
5675
5756
|
this.logWarning("".concat(title, ": order lookup \u7F3A\u5931\uFF0C\u8DF3\u8FC7\u672C\u5730\u8BA2\u5355\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
|
|
5676
5757
|
batchSize: ids.length,
|
|
5677
5758
|
status: status
|
|
5678
5759
|
});
|
|
5679
|
-
return
|
|
5760
|
+
return _context59.abrupt("return");
|
|
5680
5761
|
case 5:
|
|
5681
5762
|
if ((_this$order3 = this.order) !== null && _this$order3 !== void 0 && _this$order3.getLocalOrderByLookup) {
|
|
5682
|
-
|
|
5763
|
+
_context59.next = 8;
|
|
5683
5764
|
break;
|
|
5684
5765
|
}
|
|
5685
5766
|
this.logWarning("".concat(title, ": Order \u6A21\u5757\u672A\u6CE8\u518C\uFF0C\u8DF3\u8FC7\u672C\u5730\u8BA2\u5355\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
|
|
5686
5767
|
lookup: lookup,
|
|
5687
5768
|
status: status
|
|
5688
5769
|
});
|
|
5689
|
-
return
|
|
5770
|
+
return _context59.abrupt("return");
|
|
5690
5771
|
case 8:
|
|
5691
|
-
|
|
5772
|
+
_context59.next = 10;
|
|
5692
5773
|
return this.order.getLocalOrderByLookup(lookup);
|
|
5693
5774
|
case 10:
|
|
5694
|
-
localOrder =
|
|
5775
|
+
localOrder = _context59.sent;
|
|
5695
5776
|
if (localOrder) {
|
|
5696
|
-
|
|
5777
|
+
_context59.next = 14;
|
|
5697
5778
|
break;
|
|
5698
5779
|
}
|
|
5699
5780
|
this.logWarning("".concat(title, ": \u672C\u5730\u8BA2\u5355\u4E0D\u5B58\u5728\uFF0C\u8DF3\u8FC7\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
|
|
5700
5781
|
lookup: lookup,
|
|
5701
5782
|
status: status
|
|
5702
5783
|
});
|
|
5703
|
-
return
|
|
5784
|
+
return _context59.abrupt("return");
|
|
5704
5785
|
case 14:
|
|
5705
5786
|
voucherIdSet = new Set(ids.filter(function (id) {
|
|
5706
5787
|
return id !== undefined && id !== null && id !== '';
|
|
@@ -5708,14 +5789,14 @@ var Server = /*#__PURE__*/function () {
|
|
|
5708
5789
|
return String(id);
|
|
5709
5790
|
}));
|
|
5710
5791
|
if (!(voucherIdSet.size === 0)) {
|
|
5711
|
-
|
|
5792
|
+
_context59.next = 18;
|
|
5712
5793
|
break;
|
|
5713
5794
|
}
|
|
5714
5795
|
this.logWarning("".concat(title, ": voucher ids \u7F3A\u5931\uFF0C\u8DF3\u8FC7\u672C\u5730\u8BA2\u5355\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
|
|
5715
5796
|
lookup: lookup,
|
|
5716
5797
|
status: status
|
|
5717
5798
|
});
|
|
5718
|
-
return
|
|
5799
|
+
return _context59.abrupt("return");
|
|
5719
5800
|
case 18:
|
|
5720
5801
|
vouchers = Array.isArray(localOrder.vouchers) ? localOrder.vouchers : [];
|
|
5721
5802
|
hasUpdatedVoucher = false;
|
|
@@ -5729,7 +5810,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
5729
5810
|
});
|
|
5730
5811
|
});
|
|
5731
5812
|
if (hasUpdatedVoucher) {
|
|
5732
|
-
|
|
5813
|
+
_context59.next = 24;
|
|
5733
5814
|
break;
|
|
5734
5815
|
}
|
|
5735
5816
|
this.logWarning("".concat(title, ": \u672C\u5730\u8BA2\u5355\u672A\u547D\u4E2D\u4EFB\u4F55 voucher\uFF0C\u8DF3\u8FC7\u6838\u9500\u72B6\u6001\u66F4\u65B0"), {
|
|
@@ -5737,13 +5818,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
5737
5818
|
voucher_ids: Array.from(voucherIdSet),
|
|
5738
5819
|
status: status
|
|
5739
5820
|
});
|
|
5740
|
-
return
|
|
5821
|
+
return _context59.abrupt("return");
|
|
5741
5822
|
case 24:
|
|
5742
5823
|
if (!(typeof this.order.overwriteExistingOrder === 'function')) {
|
|
5743
|
-
|
|
5824
|
+
_context59.next = 29;
|
|
5744
5825
|
break;
|
|
5745
5826
|
}
|
|
5746
|
-
|
|
5827
|
+
_context59.next = 27;
|
|
5747
5828
|
return this.order.overwriteExistingOrder(_objectSpread(_objectSpread({}, localOrder), {}, {
|
|
5748
5829
|
vouchers: nextVouchers
|
|
5749
5830
|
}));
|
|
@@ -5753,13 +5834,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
5753
5834
|
updatedCount: voucherIdSet.size,
|
|
5754
5835
|
status: status
|
|
5755
5836
|
});
|
|
5756
|
-
return
|
|
5837
|
+
return _context59.abrupt("return");
|
|
5757
5838
|
case 29:
|
|
5758
5839
|
if (!(data !== null && data !== void 0 && data.external_sale_number && typeof this.order.markOrderSyncedByExternalSaleNumber === 'function')) {
|
|
5759
|
-
|
|
5840
|
+
_context59.next = 34;
|
|
5760
5841
|
break;
|
|
5761
5842
|
}
|
|
5762
|
-
|
|
5843
|
+
_context59.next = 32;
|
|
5763
5844
|
return this.order.markOrderSyncedByExternalSaleNumber({
|
|
5764
5845
|
externalSaleNumber: data.external_sale_number,
|
|
5765
5846
|
patch: {
|
|
@@ -5772,7 +5853,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
5772
5853
|
updatedCount: voucherIdSet.size,
|
|
5773
5854
|
status: status
|
|
5774
5855
|
});
|
|
5775
|
-
return
|
|
5856
|
+
return _context59.abrupt("return");
|
|
5776
5857
|
case 34:
|
|
5777
5858
|
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"), {
|
|
5778
5859
|
lookup: lookup,
|
|
@@ -5780,11 +5861,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
5780
5861
|
});
|
|
5781
5862
|
case 35:
|
|
5782
5863
|
case "end":
|
|
5783
|
-
return
|
|
5864
|
+
return _context59.stop();
|
|
5784
5865
|
}
|
|
5785
|
-
},
|
|
5866
|
+
}, _callee59, this);
|
|
5786
5867
|
}));
|
|
5787
|
-
function syncMachinecodeRedeemStatusToLocalOrder(
|
|
5868
|
+
function syncMachinecodeRedeemStatusToLocalOrder(_x64, _x65, _x66) {
|
|
5788
5869
|
return _syncMachinecodeRedeemStatusToLocalOrder.apply(this, arguments);
|
|
5789
5870
|
}
|
|
5790
5871
|
return syncMachinecodeRedeemStatusToLocalOrder;
|
|
@@ -5792,10 +5873,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
5792
5873
|
}, {
|
|
5793
5874
|
key: "handleOrderCheckoutSubmit",
|
|
5794
5875
|
value: function () {
|
|
5795
|
-
var _handleOrderCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5876
|
+
var _handleOrderCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee60(params) {
|
|
5796
5877
|
var backendPath, data, title, normalizedData, checkoutData, pendingResult, _this$core$context2, pendingOrder, platform, isAndroid;
|
|
5797
|
-
return _regeneratorRuntime().wrap(function
|
|
5798
|
-
while (1) switch (
|
|
5878
|
+
return _regeneratorRuntime().wrap(function _callee60$(_context60) {
|
|
5879
|
+
while (1) switch (_context60.prev = _context60.next) {
|
|
5799
5880
|
case 0:
|
|
5800
5881
|
backendPath = params.backendPath, data = params.data, title = params.title;
|
|
5801
5882
|
this.logInfo("".concat(title, ": \u5F00\u59CB\u5904\u7406"), {
|
|
@@ -5805,24 +5886,24 @@ var Server = /*#__PURE__*/function () {
|
|
|
5805
5886
|
order_number: data === null || data === void 0 ? void 0 : data.order_number
|
|
5806
5887
|
});
|
|
5807
5888
|
if (!(data !== null && data !== void 0 && data.sync_mode || data !== null && data !== void 0 && data.syncMode)) {
|
|
5808
|
-
|
|
5889
|
+
_context60.next = 4;
|
|
5809
5890
|
break;
|
|
5810
5891
|
}
|
|
5811
|
-
return
|
|
5892
|
+
return _context60.abrupt("return", this.handleSyncCheckoutSubmit({
|
|
5812
5893
|
backendPath: backendPath,
|
|
5813
5894
|
data: data,
|
|
5814
5895
|
title: title
|
|
5815
5896
|
}));
|
|
5816
5897
|
case 4:
|
|
5817
|
-
|
|
5898
|
+
_context60.next = 6;
|
|
5818
5899
|
return this.normalizeCheckoutSubmitData(data, title);
|
|
5819
5900
|
case 6:
|
|
5820
|
-
normalizedData =
|
|
5821
|
-
|
|
5901
|
+
normalizedData = _context60.sent;
|
|
5902
|
+
_context60.next = 9;
|
|
5822
5903
|
return this.ensureCheckoutOrderNumbers(normalizedData, title);
|
|
5823
5904
|
case 9:
|
|
5824
|
-
checkoutData =
|
|
5825
|
-
|
|
5905
|
+
checkoutData = _context60.sent;
|
|
5906
|
+
_context60.next = 12;
|
|
5826
5907
|
return this.handlePendingSyncCheckoutOrder({
|
|
5827
5908
|
backendPath: backendPath,
|
|
5828
5909
|
data: checkoutData,
|
|
@@ -5830,9 +5911,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
5830
5911
|
reason: 'checkout 已转入设备任务同步'
|
|
5831
5912
|
});
|
|
5832
5913
|
case 12:
|
|
5833
|
-
pendingResult =
|
|
5914
|
+
pendingResult = _context60.sent;
|
|
5834
5915
|
if (!((pendingResult === null || pendingResult === void 0 ? void 0 : pendingResult.status) === true)) {
|
|
5835
|
-
|
|
5916
|
+
_context60.next = 22;
|
|
5836
5917
|
break;
|
|
5837
5918
|
}
|
|
5838
5919
|
pendingOrder = pendingResult.data;
|
|
@@ -5841,10 +5922,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
5841
5922
|
if (!(pendingOrder && this.shouldBuildSmallTicketData(checkoutData) && this.isSalesOrderFullyPaid(pendingOrder) && (
|
|
5842
5923
|
// TODO 这里先加个兼容,如果是安卓,则需要 type=virtual 才走打印,如果是苹果则无限制
|
|
5843
5924
|
isAndroid ? checkoutData.type === 'virtual' : true))) {
|
|
5844
|
-
|
|
5925
|
+
_context60.next = 20;
|
|
5845
5926
|
break;
|
|
5846
5927
|
}
|
|
5847
|
-
|
|
5928
|
+
_context60.next = 20;
|
|
5848
5929
|
return this.dispatchLocalReceiptPrint({
|
|
5849
5930
|
checkoutData: checkoutData,
|
|
5850
5931
|
order: pendingOrder,
|
|
@@ -5852,7 +5933,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
5852
5933
|
requireFullyPaid: true
|
|
5853
5934
|
});
|
|
5854
5935
|
case 20:
|
|
5855
|
-
|
|
5936
|
+
_context60.next = 22;
|
|
5856
5937
|
return this.dispatchCheckoutSyncTask({
|
|
5857
5938
|
backendPath: backendPath,
|
|
5858
5939
|
data: checkoutData,
|
|
@@ -5860,23 +5941,23 @@ var Server = /*#__PURE__*/function () {
|
|
|
5860
5941
|
});
|
|
5861
5942
|
case 22:
|
|
5862
5943
|
if (pendingResult.data.order_id) {
|
|
5863
|
-
|
|
5944
|
+
_context60.next = 24;
|
|
5864
5945
|
break;
|
|
5865
5946
|
}
|
|
5866
|
-
return
|
|
5947
|
+
return _context60.abrupt("return", _objectSpread(_objectSpread({}, pendingResult), {}, {
|
|
5867
5948
|
data: _objectSpread(_objectSpread({}, pendingResult.data), {}, {
|
|
5868
5949
|
order_id: pendingResult.data.external_sale_number
|
|
5869
5950
|
})
|
|
5870
5951
|
}));
|
|
5871
5952
|
case 24:
|
|
5872
|
-
return
|
|
5953
|
+
return _context60.abrupt("return", pendingResult);
|
|
5873
5954
|
case 25:
|
|
5874
5955
|
case "end":
|
|
5875
|
-
return
|
|
5956
|
+
return _context60.stop();
|
|
5876
5957
|
}
|
|
5877
|
-
},
|
|
5958
|
+
}, _callee60, this);
|
|
5878
5959
|
}));
|
|
5879
|
-
function handleOrderCheckoutSubmit(
|
|
5960
|
+
function handleOrderCheckoutSubmit(_x67) {
|
|
5880
5961
|
return _handleOrderCheckoutSubmit.apply(this, arguments);
|
|
5881
5962
|
}
|
|
5882
5963
|
return handleOrderCheckoutSubmit;
|
|
@@ -5884,27 +5965,27 @@ var Server = /*#__PURE__*/function () {
|
|
|
5884
5965
|
}, {
|
|
5885
5966
|
key: "handleSyncCheckoutSubmit",
|
|
5886
5967
|
value: function () {
|
|
5887
|
-
var _handleSyncCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
5968
|
+
var _handleSyncCheckoutSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee61(params) {
|
|
5888
5969
|
var _this$app16;
|
|
5889
5970
|
var backendPath, data, title, syncResult, _normalized$data, normalized, response, syncedOrder, backendError, _normalized$data2, _normalized, message;
|
|
5890
|
-
return _regeneratorRuntime().wrap(function
|
|
5891
|
-
while (1) switch (
|
|
5971
|
+
return _regeneratorRuntime().wrap(function _callee61$(_context61) {
|
|
5972
|
+
while (1) switch (_context61.prev = _context61.next) {
|
|
5892
5973
|
case 0:
|
|
5893
5974
|
backendPath = params.backendPath, data = params.data, title = params.title;
|
|
5894
5975
|
if ((_this$app16 = this.app) !== null && _this$app16 !== void 0 && (_this$app16 = _this$app16.request) !== null && _this$app16 !== void 0 && _this$app16.post) {
|
|
5895
|
-
|
|
5976
|
+
_context61.next = 4;
|
|
5896
5977
|
break;
|
|
5897
5978
|
}
|
|
5898
5979
|
this.logError("".concat(title, ": sync checkout app.request \u4E0D\u53EF\u7528"));
|
|
5899
|
-
return
|
|
5980
|
+
return _context61.abrupt("return", {
|
|
5900
5981
|
code: 500,
|
|
5901
5982
|
status: false,
|
|
5902
5983
|
message: 'app.request 不可用',
|
|
5903
5984
|
data: null
|
|
5904
5985
|
});
|
|
5905
5986
|
case 4:
|
|
5906
|
-
|
|
5907
|
-
|
|
5987
|
+
_context61.prev = 4;
|
|
5988
|
+
_context61.next = 7;
|
|
5908
5989
|
return this.runCheckoutSync({
|
|
5909
5990
|
backendPath: backendPath,
|
|
5910
5991
|
data: data,
|
|
@@ -5912,13 +5993,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
5912
5993
|
persistCheckoutDataWithResponse: true
|
|
5913
5994
|
});
|
|
5914
5995
|
case 7:
|
|
5915
|
-
syncResult =
|
|
5996
|
+
syncResult = _context61.sent;
|
|
5916
5997
|
if (!syncResult.rejected) {
|
|
5917
|
-
|
|
5998
|
+
_context61.next = 11;
|
|
5918
5999
|
break;
|
|
5919
6000
|
}
|
|
5920
6001
|
normalized = this.normalizeCheckoutResponse(syncResult.errorResponse);
|
|
5921
|
-
return
|
|
6002
|
+
return _context61.abrupt("return", _objectSpread(_objectSpread({}, normalized), {}, {
|
|
5922
6003
|
status: false,
|
|
5923
6004
|
message: syncResult.message || (normalized === null || normalized === void 0 ? void 0 : normalized.message) || '后端明确拒绝 checkout',
|
|
5924
6005
|
data: (_normalized$data = normalized === null || normalized === void 0 ? void 0 : normalized.data) !== null && _normalized$data !== void 0 ? _normalized$data : null
|
|
@@ -5927,10 +6008,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
5927
6008
|
response = this.withSyncedOrderIdInCheckoutResponse(syncResult.normalizedResponse, syncResult.syncedOrder);
|
|
5928
6009
|
syncedOrder = syncResult.syncedOrder;
|
|
5929
6010
|
if (!(syncedOrder && this.shouldBuildSmallTicketData(syncResult.checkoutData) && this.isSalesOrderFullyPaid(syncedOrder))) {
|
|
5930
|
-
|
|
6011
|
+
_context61.next = 16;
|
|
5931
6012
|
break;
|
|
5932
6013
|
}
|
|
5933
|
-
|
|
6014
|
+
_context61.next = 16;
|
|
5934
6015
|
return this.dispatchLocalReceiptPrint({
|
|
5935
6016
|
checkoutData: syncResult.checkoutData,
|
|
5936
6017
|
order: syncedOrder,
|
|
@@ -5940,29 +6021,29 @@ var Server = /*#__PURE__*/function () {
|
|
|
5940
6021
|
isManualPrint: true
|
|
5941
6022
|
});
|
|
5942
6023
|
case 16:
|
|
5943
|
-
return
|
|
6024
|
+
return _context61.abrupt("return", response);
|
|
5944
6025
|
case 19:
|
|
5945
|
-
|
|
5946
|
-
|
|
5947
|
-
backendError = this.extractBackendErrorResponse(
|
|
6026
|
+
_context61.prev = 19;
|
|
6027
|
+
_context61.t0 = _context61["catch"](4);
|
|
6028
|
+
backendError = this.extractBackendErrorResponse(_context61.t0);
|
|
5948
6029
|
if (!backendError) {
|
|
5949
|
-
|
|
6030
|
+
_context61.next = 25;
|
|
5950
6031
|
break;
|
|
5951
6032
|
}
|
|
5952
6033
|
_normalized = this.normalizeCheckoutResponse(backendError);
|
|
5953
|
-
return
|
|
6034
|
+
return _context61.abrupt("return", _objectSpread(_objectSpread({}, _normalized), {}, {
|
|
5954
6035
|
status: false,
|
|
5955
6036
|
message: (backendError === null || backendError === void 0 ? void 0 : backendError.message) || (_normalized === null || _normalized === void 0 ? void 0 : _normalized.message) || '后端明确拒绝 checkout',
|
|
5956
6037
|
data: (_normalized$data2 = _normalized === null || _normalized === void 0 ? void 0 : _normalized.data) !== null && _normalized$data2 !== void 0 ? _normalized$data2 : null
|
|
5957
6038
|
}));
|
|
5958
6039
|
case 25:
|
|
5959
|
-
message = this.getUnknownErrorMessage(
|
|
6040
|
+
message = this.getUnknownErrorMessage(_context61.t0);
|
|
5960
6041
|
this.logError("".concat(title, ": sync checkout \u8BF7\u6C42\u672A\u660E\u786E\u6210\u529F"), {
|
|
5961
6042
|
backendPath: backendPath,
|
|
5962
6043
|
error: message,
|
|
5963
|
-
error_detail: this.normalizeUnknownError(
|
|
6044
|
+
error_detail: this.normalizeUnknownError(_context61.t0)
|
|
5964
6045
|
});
|
|
5965
|
-
return
|
|
6046
|
+
return _context61.abrupt("return", {
|
|
5966
6047
|
code: 500,
|
|
5967
6048
|
status: false,
|
|
5968
6049
|
message: message,
|
|
@@ -5970,11 +6051,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
5970
6051
|
});
|
|
5971
6052
|
case 28:
|
|
5972
6053
|
case "end":
|
|
5973
|
-
return
|
|
6054
|
+
return _context61.stop();
|
|
5974
6055
|
}
|
|
5975
|
-
},
|
|
6056
|
+
}, _callee61, this, [[4, 19]]);
|
|
5976
6057
|
}));
|
|
5977
|
-
function handleSyncCheckoutSubmit(
|
|
6058
|
+
function handleSyncCheckoutSubmit(_x68) {
|
|
5978
6059
|
return _handleSyncCheckoutSubmit.apply(this, arguments);
|
|
5979
6060
|
}
|
|
5980
6061
|
return handleSyncCheckoutSubmit;
|
|
@@ -5982,10 +6063,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
5982
6063
|
}, {
|
|
5983
6064
|
key: "handleOrderDraftSubmit",
|
|
5984
6065
|
value: function () {
|
|
5985
|
-
var _handleOrderDraftSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6066
|
+
var _handleOrderDraftSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee62(params) {
|
|
5986
6067
|
var data, title, normalizedData, createdAt, draftOrder, _draftOrder$summary, _draftOrder$summary2, _draftOrder$summary3, errorMessage;
|
|
5987
|
-
return _regeneratorRuntime().wrap(function
|
|
5988
|
-
while (1) switch (
|
|
6068
|
+
return _regeneratorRuntime().wrap(function _callee62$(_context62) {
|
|
6069
|
+
while (1) switch (_context62.prev = _context62.next) {
|
|
5989
6070
|
case 0:
|
|
5990
6071
|
data = params.data, title = params.title;
|
|
5991
6072
|
this.logInfo("".concat(title, ": \u5F00\u59CB\u5904\u7406"), {
|
|
@@ -5993,10 +6074,10 @@ var Server = /*#__PURE__*/function () {
|
|
|
5993
6074
|
external_sale_number: data === null || data === void 0 ? void 0 : data.external_sale_number,
|
|
5994
6075
|
order_number: data === null || data === void 0 ? void 0 : data.order_number
|
|
5995
6076
|
});
|
|
5996
|
-
|
|
6077
|
+
_context62.next = 4;
|
|
5997
6078
|
return this.normalizeCheckoutSubmitData(data, title);
|
|
5998
6079
|
case 4:
|
|
5999
|
-
normalizedData =
|
|
6080
|
+
normalizedData = _context62.sent;
|
|
6000
6081
|
createdAt = normalizedData.created_at || normalizedData.create_date || dayjs().format('YYYY-MM-DD HH:mm:ss');
|
|
6001
6082
|
draftOrder = _objectSpread(_objectSpread({}, normalizedData), {}, {
|
|
6002
6083
|
external_sale_number: normalizedData.external_sale_number || "LOCAL_DRAFT_".concat(Date.now(), "_").concat(Math.random().toString(36).slice(2, 10)),
|
|
@@ -6006,26 +6087,26 @@ var Server = /*#__PURE__*/function () {
|
|
|
6006
6087
|
is_draft_order: 1
|
|
6007
6088
|
});
|
|
6008
6089
|
if (!(!this.order || typeof this.order.upsertLocalDraftOrders !== 'function')) {
|
|
6009
|
-
|
|
6090
|
+
_context62.next = 10;
|
|
6010
6091
|
break;
|
|
6011
6092
|
}
|
|
6012
6093
|
this.logError("".concat(title, ": Order \u6A21\u5757\u4E0D\u652F\u6301\u672C\u5730\u8349\u7A3F\u5199\u5165"));
|
|
6013
|
-
return
|
|
6094
|
+
return _context62.abrupt("return", {
|
|
6014
6095
|
code: 500,
|
|
6015
6096
|
status: false,
|
|
6016
6097
|
message: 'Order 模块不支持本地草稿写入',
|
|
6017
6098
|
data: null
|
|
6018
6099
|
});
|
|
6019
6100
|
case 10:
|
|
6020
|
-
|
|
6021
|
-
|
|
6101
|
+
_context62.prev = 10;
|
|
6102
|
+
_context62.next = 13;
|
|
6022
6103
|
return this.order.upsertLocalDraftOrders([draftOrder]);
|
|
6023
6104
|
case 13:
|
|
6024
6105
|
this.logInfo("".concat(title, ": \u8349\u7A3F\u8BA2\u5355\u5DF2\u5199\u5165\u672C\u5730"), {
|
|
6025
6106
|
order_id: draftOrder.order_id,
|
|
6026
6107
|
external_sale_number: draftOrder.external_sale_number
|
|
6027
6108
|
});
|
|
6028
|
-
return
|
|
6109
|
+
return _context62.abrupt("return", {
|
|
6029
6110
|
code: 200,
|
|
6030
6111
|
status: true,
|
|
6031
6112
|
message: '',
|
|
@@ -6037,13 +6118,13 @@ var Server = /*#__PURE__*/function () {
|
|
|
6037
6118
|
})
|
|
6038
6119
|
});
|
|
6039
6120
|
case 17:
|
|
6040
|
-
|
|
6041
|
-
|
|
6042
|
-
errorMessage =
|
|
6121
|
+
_context62.prev = 17;
|
|
6122
|
+
_context62.t0 = _context62["catch"](10);
|
|
6123
|
+
errorMessage = _context62.t0 instanceof Error ? _context62.t0.message : String(_context62.t0);
|
|
6043
6124
|
this.logError("".concat(title, ": \u5199\u5165\u672C\u5730\u8349\u7A3F\u8BA2\u5355\u5931\u8D25"), {
|
|
6044
6125
|
error: errorMessage
|
|
6045
6126
|
});
|
|
6046
|
-
return
|
|
6127
|
+
return _context62.abrupt("return", {
|
|
6047
6128
|
code: 500,
|
|
6048
6129
|
status: false,
|
|
6049
6130
|
message: errorMessage,
|
|
@@ -6051,11 +6132,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
6051
6132
|
});
|
|
6052
6133
|
case 22:
|
|
6053
6134
|
case "end":
|
|
6054
|
-
return
|
|
6135
|
+
return _context62.stop();
|
|
6055
6136
|
}
|
|
6056
|
-
},
|
|
6137
|
+
}, _callee62, this, [[10, 17]]);
|
|
6057
6138
|
}));
|
|
6058
|
-
function handleOrderDraftSubmit(
|
|
6139
|
+
function handleOrderDraftSubmit(_x69) {
|
|
6059
6140
|
return _handleOrderDraftSubmit.apply(this, arguments);
|
|
6060
6141
|
}
|
|
6061
6142
|
return handleOrderDraftSubmit;
|
|
@@ -6063,26 +6144,26 @@ var Server = /*#__PURE__*/function () {
|
|
|
6063
6144
|
}, {
|
|
6064
6145
|
key: "handlePendingSyncCheckoutOrder",
|
|
6065
6146
|
value: function () {
|
|
6066
|
-
var _handlePendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6147
|
+
var _handlePendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee63(params) {
|
|
6067
6148
|
var _this13 = this;
|
|
6068
6149
|
var backendPath, data, title, reason, pendingOrder, _pendingOrder$payment, _pendingOrder$summary, _pendingOrder$summary2, _pendingOrder$summary3, changeGivenAmount, errorMessage;
|
|
6069
|
-
return _regeneratorRuntime().wrap(function
|
|
6070
|
-
while (1) switch (
|
|
6150
|
+
return _regeneratorRuntime().wrap(function _callee63$(_context63) {
|
|
6151
|
+
while (1) switch (_context63.prev = _context63.next) {
|
|
6071
6152
|
case 0:
|
|
6072
6153
|
backendPath = params.backendPath, data = params.data, title = params.title, reason = params.reason;
|
|
6073
|
-
|
|
6154
|
+
_context63.next = 3;
|
|
6074
6155
|
return this.buildPendingSyncCheckoutOrder(data);
|
|
6075
6156
|
case 3:
|
|
6076
|
-
pendingOrder =
|
|
6157
|
+
pendingOrder = _context63.sent;
|
|
6077
6158
|
if (pendingOrder) {
|
|
6078
|
-
|
|
6159
|
+
_context63.next = 7;
|
|
6079
6160
|
break;
|
|
6080
6161
|
}
|
|
6081
6162
|
this.logError("".concat(title, ": checkout \u5931\u8D25\u4E14\u8BA2\u5355\u7F3A\u5C11\u672C\u5730\u5B58\u50A8\u6807\u8BC6"), {
|
|
6082
6163
|
backendPath: backendPath,
|
|
6083
6164
|
reason: reason
|
|
6084
6165
|
});
|
|
6085
|
-
return
|
|
6166
|
+
return _context63.abrupt("return", {
|
|
6086
6167
|
code: 500,
|
|
6087
6168
|
status: false,
|
|
6088
6169
|
message: '订单缺少本地存储标识,无法写入待同步队列',
|
|
@@ -6090,22 +6171,22 @@ var Server = /*#__PURE__*/function () {
|
|
|
6090
6171
|
});
|
|
6091
6172
|
case 7:
|
|
6092
6173
|
if (!(!this.order || typeof this.order.upsertPendingSyncOrders !== 'function')) {
|
|
6093
|
-
|
|
6174
|
+
_context63.next = 10;
|
|
6094
6175
|
break;
|
|
6095
6176
|
}
|
|
6096
6177
|
this.logError("".concat(title, ": Order \u6A21\u5757\u4E0D\u652F\u6301\u672C\u5730\u5F85\u540C\u6B65\u5199\u5165"), {
|
|
6097
6178
|
backendPath: backendPath,
|
|
6098
6179
|
reason: reason
|
|
6099
6180
|
});
|
|
6100
|
-
return
|
|
6181
|
+
return _context63.abrupt("return", {
|
|
6101
6182
|
code: 500,
|
|
6102
6183
|
status: false,
|
|
6103
6184
|
message: 'Order 模块不支持本地待同步写入',
|
|
6104
6185
|
data: null
|
|
6105
6186
|
});
|
|
6106
6187
|
case 10:
|
|
6107
|
-
|
|
6108
|
-
|
|
6188
|
+
_context63.prev = 10;
|
|
6189
|
+
_context63.next = 13;
|
|
6109
6190
|
return this.order.upsertPendingSyncOrders([pendingOrder]);
|
|
6110
6191
|
case 13:
|
|
6111
6192
|
this.logInfo("".concat(title, ": \u8BA2\u5355\u5DF2\u5199\u5165\u672C\u5730\u5F85\u540C\u6B65"), {
|
|
@@ -6119,7 +6200,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
6119
6200
|
var _payment$metadata;
|
|
6120
6201
|
return sum + _this13.toAmountNumber(payment === null || payment === void 0 || (_payment$metadata = payment.metadata) === null || _payment$metadata === void 0 ? void 0 : _payment$metadata.change_given_amount);
|
|
6121
6202
|
}, 0);
|
|
6122
|
-
return
|
|
6203
|
+
return _context63.abrupt("return", {
|
|
6123
6204
|
code: 200,
|
|
6124
6205
|
status: true,
|
|
6125
6206
|
message: '',
|
|
@@ -6134,15 +6215,15 @@ var Server = /*#__PURE__*/function () {
|
|
|
6134
6215
|
})
|
|
6135
6216
|
});
|
|
6136
6217
|
case 18:
|
|
6137
|
-
|
|
6138
|
-
|
|
6139
|
-
errorMessage =
|
|
6218
|
+
_context63.prev = 18;
|
|
6219
|
+
_context63.t0 = _context63["catch"](10);
|
|
6220
|
+
errorMessage = _context63.t0 instanceof Error ? _context63.t0.message : String(_context63.t0);
|
|
6140
6221
|
this.logError("".concat(title, ": \u5199\u5165\u672C\u5730\u5F85\u540C\u6B65\u8BA2\u5355\u5931\u8D25"), {
|
|
6141
6222
|
backendPath: backendPath,
|
|
6142
6223
|
reason: reason,
|
|
6143
6224
|
error: errorMessage
|
|
6144
6225
|
});
|
|
6145
|
-
return
|
|
6226
|
+
return _context63.abrupt("return", {
|
|
6146
6227
|
code: 500,
|
|
6147
6228
|
status: false,
|
|
6148
6229
|
message: errorMessage,
|
|
@@ -6150,11 +6231,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
6150
6231
|
});
|
|
6151
6232
|
case 23:
|
|
6152
6233
|
case "end":
|
|
6153
|
-
return
|
|
6234
|
+
return _context63.stop();
|
|
6154
6235
|
}
|
|
6155
|
-
},
|
|
6236
|
+
}, _callee63, this, [[10, 18]]);
|
|
6156
6237
|
}));
|
|
6157
|
-
function handlePendingSyncCheckoutOrder(
|
|
6238
|
+
function handlePendingSyncCheckoutOrder(_x70) {
|
|
6158
6239
|
return _handlePendingSyncCheckoutOrder.apply(this, arguments);
|
|
6159
6240
|
}
|
|
6160
6241
|
return handlePendingSyncCheckoutOrder;
|
|
@@ -6162,44 +6243,44 @@ var Server = /*#__PURE__*/function () {
|
|
|
6162
6243
|
}, {
|
|
6163
6244
|
key: "buildPendingSyncCheckoutOrder",
|
|
6164
6245
|
value: function () {
|
|
6165
|
-
var _buildPendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6246
|
+
var _buildPendingSyncCheckoutOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee64(data) {
|
|
6166
6247
|
var hasStorageKey, pendingOrder, productMap, orderWithProductTitles;
|
|
6167
|
-
return _regeneratorRuntime().wrap(function
|
|
6168
|
-
while (1) switch (
|
|
6248
|
+
return _regeneratorRuntime().wrap(function _callee64$(_context64) {
|
|
6249
|
+
while (1) switch (_context64.prev = _context64.next) {
|
|
6169
6250
|
case 0:
|
|
6170
6251
|
if (!(!data || _typeof(data) !== 'object')) {
|
|
6171
|
-
|
|
6252
|
+
_context64.next = 2;
|
|
6172
6253
|
break;
|
|
6173
6254
|
}
|
|
6174
|
-
return
|
|
6255
|
+
return _context64.abrupt("return", null);
|
|
6175
6256
|
case 2:
|
|
6176
6257
|
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 !== '';
|
|
6177
6258
|
if (hasStorageKey) {
|
|
6178
|
-
|
|
6259
|
+
_context64.next = 5;
|
|
6179
6260
|
break;
|
|
6180
6261
|
}
|
|
6181
|
-
return
|
|
6262
|
+
return _context64.abrupt("return", null);
|
|
6182
6263
|
case 5:
|
|
6183
6264
|
pendingOrder = _objectSpread(_objectSpread({}, data), {}, {
|
|
6184
6265
|
need_sync: 1,
|
|
6185
6266
|
is_draft_order: 0
|
|
6186
6267
|
});
|
|
6187
|
-
|
|
6268
|
+
_context64.next = 8;
|
|
6188
6269
|
return this.buildSmallTicketProductMap(pendingOrder);
|
|
6189
6270
|
case 8:
|
|
6190
|
-
productMap =
|
|
6271
|
+
productMap = _context64.sent;
|
|
6191
6272
|
orderWithProductTitles = this.withPendingSyncProductTitles(pendingOrder, productMap);
|
|
6192
|
-
return
|
|
6273
|
+
return _context64.abrupt("return", this.withLocalSmallTicketData(orderWithProductTitles, {
|
|
6193
6274
|
requireFullyPaid: true,
|
|
6194
6275
|
productMap: productMap
|
|
6195
6276
|
}));
|
|
6196
6277
|
case 11:
|
|
6197
6278
|
case "end":
|
|
6198
|
-
return
|
|
6279
|
+
return _context64.stop();
|
|
6199
6280
|
}
|
|
6200
|
-
},
|
|
6281
|
+
}, _callee64, this);
|
|
6201
6282
|
}));
|
|
6202
|
-
function buildPendingSyncCheckoutOrder(
|
|
6283
|
+
function buildPendingSyncCheckoutOrder(_x71) {
|
|
6203
6284
|
return _buildPendingSyncCheckoutOrder.apply(this, arguments);
|
|
6204
6285
|
}
|
|
6205
6286
|
return buildPendingSyncCheckoutOrder;
|
|
@@ -6267,12 +6348,12 @@ var Server = /*#__PURE__*/function () {
|
|
|
6267
6348
|
}, {
|
|
6268
6349
|
key: "buildSmallTicketProductMap",
|
|
6269
6350
|
value: function () {
|
|
6270
|
-
var _buildSmallTicketProductMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6351
|
+
var _buildSmallTicketProductMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee66(order) {
|
|
6271
6352
|
var _this$products3,
|
|
6272
6353
|
_this15 = this;
|
|
6273
6354
|
var products, productIdSet, productIds, entries;
|
|
6274
|
-
return _regeneratorRuntime().wrap(function
|
|
6275
|
-
while (1) switch (
|
|
6355
|
+
return _regeneratorRuntime().wrap(function _callee66$(_context66) {
|
|
6356
|
+
while (1) switch (_context66.prev = _context66.next) {
|
|
6276
6357
|
case 0:
|
|
6277
6358
|
products = Array.isArray(order === null || order === void 0 ? void 0 : order.products) ? order.products : [];
|
|
6278
6359
|
productIdSet = new Set();
|
|
@@ -6294,45 +6375,45 @@ var Server = /*#__PURE__*/function () {
|
|
|
6294
6375
|
});
|
|
6295
6376
|
productIds = Array.from(productIdSet);
|
|
6296
6377
|
if (!(!productIds.length || typeof ((_this$products3 = this.products) === null || _this$products3 === void 0 ? void 0 : _this$products3.getProductById) !== 'function')) {
|
|
6297
|
-
|
|
6378
|
+
_context66.next = 6;
|
|
6298
6379
|
break;
|
|
6299
6380
|
}
|
|
6300
|
-
return
|
|
6381
|
+
return _context66.abrupt("return", {});
|
|
6301
6382
|
case 6:
|
|
6302
|
-
|
|
6383
|
+
_context66.next = 8;
|
|
6303
6384
|
return Promise.all(productIds.map( /*#__PURE__*/function () {
|
|
6304
|
-
var _ref67 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6385
|
+
var _ref67 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee65(id) {
|
|
6305
6386
|
var _this15$products, _this15$products$getP, product;
|
|
6306
|
-
return _regeneratorRuntime().wrap(function
|
|
6307
|
-
while (1) switch (
|
|
6387
|
+
return _regeneratorRuntime().wrap(function _callee65$(_context65) {
|
|
6388
|
+
while (1) switch (_context65.prev = _context65.next) {
|
|
6308
6389
|
case 0:
|
|
6309
|
-
|
|
6310
|
-
|
|
6390
|
+
_context65.prev = 0;
|
|
6391
|
+
_context65.next = 3;
|
|
6311
6392
|
return (_this15$products = _this15.products) === null || _this15$products === void 0 || (_this15$products$getP = _this15$products.getProductById) === null || _this15$products$getP === void 0 ? void 0 : _this15$products$getP.call(_this15$products, Number(id));
|
|
6312
6393
|
case 3:
|
|
6313
|
-
product =
|
|
6314
|
-
return
|
|
6394
|
+
product = _context65.sent;
|
|
6395
|
+
return _context65.abrupt("return", product ? [String(id), product] : null);
|
|
6315
6396
|
case 7:
|
|
6316
|
-
|
|
6317
|
-
|
|
6397
|
+
_context65.prev = 7;
|
|
6398
|
+
_context65.t0 = _context65["catch"](0);
|
|
6318
6399
|
_this15.logWarning('buildSmallTicketProductMap: 查询本地商品失败', {
|
|
6319
6400
|
product_id: id,
|
|
6320
|
-
error:
|
|
6401
|
+
error: _context65.t0 instanceof Error ? _context65.t0.message : String(_context65.t0)
|
|
6321
6402
|
});
|
|
6322
|
-
return
|
|
6403
|
+
return _context65.abrupt("return", null);
|
|
6323
6404
|
case 11:
|
|
6324
6405
|
case "end":
|
|
6325
|
-
return
|
|
6406
|
+
return _context65.stop();
|
|
6326
6407
|
}
|
|
6327
|
-
},
|
|
6408
|
+
}, _callee65, null, [[0, 7]]);
|
|
6328
6409
|
}));
|
|
6329
|
-
return function (
|
|
6410
|
+
return function (_x73) {
|
|
6330
6411
|
return _ref67.apply(this, arguments);
|
|
6331
6412
|
};
|
|
6332
6413
|
}()));
|
|
6333
6414
|
case 8:
|
|
6334
|
-
entries =
|
|
6335
|
-
return
|
|
6415
|
+
entries = _context66.sent;
|
|
6416
|
+
return _context66.abrupt("return", entries.reduce(function (map, entry) {
|
|
6336
6417
|
if (!entry) return map;
|
|
6337
6418
|
var _entry = _slicedToArray(entry, 2),
|
|
6338
6419
|
id = _entry[0],
|
|
@@ -6342,11 +6423,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
6342
6423
|
}, {}));
|
|
6343
6424
|
case 10:
|
|
6344
6425
|
case "end":
|
|
6345
|
-
return
|
|
6426
|
+
return _context66.stop();
|
|
6346
6427
|
}
|
|
6347
|
-
},
|
|
6428
|
+
}, _callee66, this);
|
|
6348
6429
|
}));
|
|
6349
|
-
function buildSmallTicketProductMap(
|
|
6430
|
+
function buildSmallTicketProductMap(_x72) {
|
|
6350
6431
|
return _buildSmallTicketProductMap.apply(this, arguments);
|
|
6351
6432
|
}
|
|
6352
6433
|
return buildSmallTicketProductMap;
|
|
@@ -6376,40 +6457,40 @@ var Server = /*#__PURE__*/function () {
|
|
|
6376
6457
|
}, {
|
|
6377
6458
|
key: "buildSalesDetailProductSnapshotMap",
|
|
6378
6459
|
value: function () {
|
|
6379
|
-
var _buildSalesDetailProductSnapshotMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6460
|
+
var _buildSalesDetailProductSnapshotMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee67(order) {
|
|
6380
6461
|
var _this$products4;
|
|
6381
6462
|
var productIds, getSnapshots;
|
|
6382
|
-
return _regeneratorRuntime().wrap(function
|
|
6383
|
-
while (1) switch (
|
|
6463
|
+
return _regeneratorRuntime().wrap(function _callee67$(_context67) {
|
|
6464
|
+
while (1) switch (_context67.prev = _context67.next) {
|
|
6384
6465
|
case 0:
|
|
6385
6466
|
productIds = this.collectSalesDetailProductIds(order);
|
|
6386
6467
|
getSnapshots = (_this$products4 = this.products) === null || _this$products4 === void 0 ? void 0 : _this$products4.getProductSnapshotsByIds;
|
|
6387
6468
|
if (!(!productIds.length || typeof getSnapshots !== 'function')) {
|
|
6388
|
-
|
|
6469
|
+
_context67.next = 4;
|
|
6389
6470
|
break;
|
|
6390
6471
|
}
|
|
6391
|
-
return
|
|
6472
|
+
return _context67.abrupt("return", {});
|
|
6392
6473
|
case 4:
|
|
6393
|
-
|
|
6394
|
-
|
|
6474
|
+
_context67.prev = 4;
|
|
6475
|
+
_context67.next = 7;
|
|
6395
6476
|
return getSnapshots.call(this.products, productIds);
|
|
6396
6477
|
case 7:
|
|
6397
|
-
return
|
|
6478
|
+
return _context67.abrupt("return", _context67.sent);
|
|
6398
6479
|
case 10:
|
|
6399
|
-
|
|
6400
|
-
|
|
6480
|
+
_context67.prev = 10;
|
|
6481
|
+
_context67.t0 = _context67["catch"](4);
|
|
6401
6482
|
this.logWarning('buildSalesDetailProductSnapshotMap: 查询本地商品快照失败', {
|
|
6402
6483
|
product_ids: productIds,
|
|
6403
|
-
error:
|
|
6484
|
+
error: _context67.t0 instanceof Error ? _context67.t0.message : String(_context67.t0)
|
|
6404
6485
|
});
|
|
6405
|
-
return
|
|
6486
|
+
return _context67.abrupt("return", {});
|
|
6406
6487
|
case 14:
|
|
6407
6488
|
case "end":
|
|
6408
|
-
return
|
|
6489
|
+
return _context67.stop();
|
|
6409
6490
|
}
|
|
6410
|
-
},
|
|
6491
|
+
}, _callee67, this, [[4, 10]]);
|
|
6411
6492
|
}));
|
|
6412
|
-
function buildSalesDetailProductSnapshotMap(
|
|
6493
|
+
function buildSalesDetailProductSnapshotMap(_x74) {
|
|
6413
6494
|
return _buildSalesDetailProductSnapshotMap.apply(this, arguments);
|
|
6414
6495
|
}
|
|
6415
6496
|
return buildSalesDetailProductSnapshotMap;
|
|
@@ -6465,28 +6546,28 @@ var Server = /*#__PURE__*/function () {
|
|
|
6465
6546
|
}, {
|
|
6466
6547
|
key: "withSalesDetailProductSnapshots",
|
|
6467
6548
|
value: function () {
|
|
6468
|
-
var _withSalesDetailProductSnapshots = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6549
|
+
var _withSalesDetailProductSnapshots = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee68(order) {
|
|
6469
6550
|
var _this16 = this;
|
|
6470
6551
|
var products, snapshotMap, hasChanged, enrichedProducts, enrichedOrder;
|
|
6471
|
-
return _regeneratorRuntime().wrap(function
|
|
6472
|
-
while (1) switch (
|
|
6552
|
+
return _regeneratorRuntime().wrap(function _callee68$(_context68) {
|
|
6553
|
+
while (1) switch (_context68.prev = _context68.next) {
|
|
6473
6554
|
case 0:
|
|
6474
6555
|
products = Array.isArray(order === null || order === void 0 ? void 0 : order.products) ? order.products : null;
|
|
6475
6556
|
if (products !== null && products !== void 0 && products.length) {
|
|
6476
|
-
|
|
6557
|
+
_context68.next = 3;
|
|
6477
6558
|
break;
|
|
6478
6559
|
}
|
|
6479
|
-
return
|
|
6560
|
+
return _context68.abrupt("return", order);
|
|
6480
6561
|
case 3:
|
|
6481
|
-
|
|
6562
|
+
_context68.next = 5;
|
|
6482
6563
|
return this.buildSalesDetailProductSnapshotMap(order);
|
|
6483
6564
|
case 5:
|
|
6484
|
-
snapshotMap =
|
|
6565
|
+
snapshotMap = _context68.sent;
|
|
6485
6566
|
if (Object.keys(snapshotMap).length) {
|
|
6486
|
-
|
|
6567
|
+
_context68.next = 8;
|
|
6487
6568
|
break;
|
|
6488
6569
|
}
|
|
6489
|
-
return
|
|
6570
|
+
return _context68.abrupt("return", order);
|
|
6490
6571
|
case 8:
|
|
6491
6572
|
hasChanged = false;
|
|
6492
6573
|
enrichedProducts = products.map(function (product) {
|
|
@@ -6496,22 +6577,22 @@ var Server = /*#__PURE__*/function () {
|
|
|
6496
6577
|
return nextProduct;
|
|
6497
6578
|
});
|
|
6498
6579
|
if (hasChanged) {
|
|
6499
|
-
|
|
6580
|
+
_context68.next = 12;
|
|
6500
6581
|
break;
|
|
6501
6582
|
}
|
|
6502
|
-
return
|
|
6583
|
+
return _context68.abrupt("return", order);
|
|
6503
6584
|
case 12:
|
|
6504
6585
|
enrichedOrder = _objectSpread(_objectSpread({}, order), {}, {
|
|
6505
6586
|
products: enrichedProducts
|
|
6506
6587
|
});
|
|
6507
|
-
return
|
|
6588
|
+
return _context68.abrupt("return", enrichedOrder);
|
|
6508
6589
|
case 14:
|
|
6509
6590
|
case "end":
|
|
6510
|
-
return
|
|
6591
|
+
return _context68.stop();
|
|
6511
6592
|
}
|
|
6512
|
-
},
|
|
6593
|
+
}, _callee68, this);
|
|
6513
6594
|
}));
|
|
6514
|
-
function withSalesDetailProductSnapshots(
|
|
6595
|
+
function withSalesDetailProductSnapshots(_x75) {
|
|
6515
6596
|
return _withSalesDetailProductSnapshots.apply(this, arguments);
|
|
6516
6597
|
}
|
|
6517
6598
|
return withSalesDetailProductSnapshots;
|
|
@@ -6642,31 +6723,31 @@ var Server = /*#__PURE__*/function () {
|
|
|
6642
6723
|
}, {
|
|
6643
6724
|
key: "enrichPaymentNamesByCode",
|
|
6644
6725
|
value: function () {
|
|
6645
|
-
var _enrichPaymentNamesByCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6726
|
+
var _enrichPaymentNamesByCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee69(order) {
|
|
6646
6727
|
var _this19 = this;
|
|
6647
6728
|
var payments, hasMissingName, paymentModule, payMethods, nameByCode, _iterator12, _step12, method, codeKey, name, hasResolvedName, enrichedPayments;
|
|
6648
|
-
return _regeneratorRuntime().wrap(function
|
|
6649
|
-
while (1) switch (
|
|
6729
|
+
return _regeneratorRuntime().wrap(function _callee69$(_context69) {
|
|
6730
|
+
while (1) switch (_context69.prev = _context69.next) {
|
|
6650
6731
|
case 0:
|
|
6651
6732
|
payments = Array.isArray(order === null || order === void 0 ? void 0 : order.payments) ? order.payments : [];
|
|
6652
6733
|
hasMissingName = payments.some(function (payment) {
|
|
6653
6734
|
return _this19.isBlankPaymentName(payment === null || payment === void 0 ? void 0 : payment.name) && _this19.shouldLookupPaymentMethodNameByCode(payment === null || payment === void 0 ? void 0 : payment.code);
|
|
6654
6735
|
});
|
|
6655
6736
|
if (hasMissingName) {
|
|
6656
|
-
|
|
6737
|
+
_context69.next = 4;
|
|
6657
6738
|
break;
|
|
6658
6739
|
}
|
|
6659
|
-
return
|
|
6740
|
+
return _context69.abrupt("return", order);
|
|
6660
6741
|
case 4:
|
|
6661
|
-
|
|
6662
|
-
|
|
6742
|
+
_context69.prev = 4;
|
|
6743
|
+
_context69.next = 7;
|
|
6663
6744
|
return this.getPaymentRouteModule();
|
|
6664
6745
|
case 7:
|
|
6665
|
-
paymentModule =
|
|
6666
|
-
|
|
6746
|
+
paymentModule = _context69.sent;
|
|
6747
|
+
_context69.next = 10;
|
|
6667
6748
|
return paymentModule.getPayMethodListAsync();
|
|
6668
6749
|
case 10:
|
|
6669
|
-
payMethods =
|
|
6750
|
+
payMethods = _context69.sent;
|
|
6670
6751
|
nameByCode = new Map();
|
|
6671
6752
|
_iterator12 = _createForOfIteratorHelper(payMethods || []);
|
|
6672
6753
|
try {
|
|
@@ -6693,28 +6774,28 @@ var Server = /*#__PURE__*/function () {
|
|
|
6693
6774
|
});
|
|
6694
6775
|
});
|
|
6695
6776
|
if (hasResolvedName) {
|
|
6696
|
-
|
|
6777
|
+
_context69.next = 18;
|
|
6697
6778
|
break;
|
|
6698
6779
|
}
|
|
6699
|
-
return
|
|
6780
|
+
return _context69.abrupt("return", order);
|
|
6700
6781
|
case 18:
|
|
6701
|
-
return
|
|
6782
|
+
return _context69.abrupt("return", _objectSpread(_objectSpread({}, order), {}, {
|
|
6702
6783
|
payments: enrichedPayments
|
|
6703
6784
|
}));
|
|
6704
6785
|
case 21:
|
|
6705
|
-
|
|
6706
|
-
|
|
6786
|
+
_context69.prev = 21;
|
|
6787
|
+
_context69.t0 = _context69["catch"](4);
|
|
6707
6788
|
this.logWarning('enrichPaymentNamesByCode: 支付方式名称回填失败', {
|
|
6708
|
-
error:
|
|
6789
|
+
error: _context69.t0 instanceof Error ? _context69.t0.message : String(_context69.t0)
|
|
6709
6790
|
});
|
|
6710
|
-
return
|
|
6791
|
+
return _context69.abrupt("return", order);
|
|
6711
6792
|
case 25:
|
|
6712
6793
|
case "end":
|
|
6713
|
-
return
|
|
6794
|
+
return _context69.stop();
|
|
6714
6795
|
}
|
|
6715
|
-
},
|
|
6796
|
+
}, _callee69, this, [[4, 21]]);
|
|
6716
6797
|
}));
|
|
6717
|
-
function enrichPaymentNamesByCode(
|
|
6798
|
+
function enrichPaymentNamesByCode(_x76) {
|
|
6718
6799
|
return _enrichPaymentNamesByCode.apply(this, arguments);
|
|
6719
6800
|
}
|
|
6720
6801
|
return enrichPaymentNamesByCode;
|
|
@@ -6722,66 +6803,66 @@ var Server = /*#__PURE__*/function () {
|
|
|
6722
6803
|
}, {
|
|
6723
6804
|
key: "withLocalSmallTicketData",
|
|
6724
6805
|
value: function () {
|
|
6725
|
-
var _withLocalSmallTicketData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6806
|
+
var _withLocalSmallTicketData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee70(order, options) {
|
|
6726
6807
|
var _options$productMap, enrichedOrder, productMap, smallTicketData;
|
|
6727
|
-
return _regeneratorRuntime().wrap(function
|
|
6728
|
-
while (1) switch (
|
|
6808
|
+
return _regeneratorRuntime().wrap(function _callee70$(_context70) {
|
|
6809
|
+
while (1) switch (_context70.prev = _context70.next) {
|
|
6729
6810
|
case 0:
|
|
6730
6811
|
if (this.shouldBuildSmallTicketData(order)) {
|
|
6731
|
-
|
|
6812
|
+
_context70.next = 2;
|
|
6732
6813
|
break;
|
|
6733
6814
|
}
|
|
6734
|
-
return
|
|
6815
|
+
return _context70.abrupt("return", order);
|
|
6735
6816
|
case 2:
|
|
6736
6817
|
if (!(options !== null && options !== void 0 && options.requireFullyPaid && !this.isSalesOrderFullyPaid(order))) {
|
|
6737
|
-
|
|
6818
|
+
_context70.next = 4;
|
|
6738
6819
|
break;
|
|
6739
6820
|
}
|
|
6740
|
-
return
|
|
6821
|
+
return _context70.abrupt("return", order);
|
|
6741
6822
|
case 4:
|
|
6742
|
-
|
|
6743
|
-
|
|
6823
|
+
_context70.prev = 4;
|
|
6824
|
+
_context70.next = 7;
|
|
6744
6825
|
return this.enrichPaymentNamesByCode(order);
|
|
6745
6826
|
case 7:
|
|
6746
|
-
enrichedOrder =
|
|
6827
|
+
enrichedOrder = _context70.sent;
|
|
6747
6828
|
if (!((_options$productMap = options === null || options === void 0 ? void 0 : options.productMap) !== null && _options$productMap !== void 0)) {
|
|
6748
|
-
|
|
6829
|
+
_context70.next = 12;
|
|
6749
6830
|
break;
|
|
6750
6831
|
}
|
|
6751
|
-
|
|
6752
|
-
|
|
6832
|
+
_context70.t0 = _options$productMap;
|
|
6833
|
+
_context70.next = 15;
|
|
6753
6834
|
break;
|
|
6754
6835
|
case 12:
|
|
6755
|
-
|
|
6836
|
+
_context70.next = 14;
|
|
6756
6837
|
return this.buildSmallTicketProductMap(enrichedOrder);
|
|
6757
6838
|
case 14:
|
|
6758
|
-
|
|
6839
|
+
_context70.t0 = _context70.sent;
|
|
6759
6840
|
case 15:
|
|
6760
|
-
productMap =
|
|
6841
|
+
productMap = _context70.t0;
|
|
6761
6842
|
smallTicketData = buildSmallTicketData({
|
|
6762
6843
|
order: enrichedOrder,
|
|
6763
6844
|
shopInfo: this.getSmallTicketShopInfo(),
|
|
6764
6845
|
productMap: productMap
|
|
6765
6846
|
});
|
|
6766
|
-
return
|
|
6847
|
+
return _context70.abrupt("return", _objectSpread(_objectSpread({}, enrichedOrder), {}, {
|
|
6767
6848
|
payment_info: _objectSpread(_objectSpread({}, enrichedOrder.payment_info || {}), {}, {
|
|
6768
6849
|
small_ticket_data: smallTicketData
|
|
6769
6850
|
})
|
|
6770
6851
|
}));
|
|
6771
6852
|
case 20:
|
|
6772
|
-
|
|
6773
|
-
|
|
6853
|
+
_context70.prev = 20;
|
|
6854
|
+
_context70.t1 = _context70["catch"](4);
|
|
6774
6855
|
this.logError('withLocalSmallTicketData: 生成本地小票数据失败', {
|
|
6775
|
-
error:
|
|
6856
|
+
error: _context70.t1 instanceof Error ? _context70.t1.message : String(_context70.t1)
|
|
6776
6857
|
});
|
|
6777
|
-
return
|
|
6858
|
+
return _context70.abrupt("return", order);
|
|
6778
6859
|
case 24:
|
|
6779
6860
|
case "end":
|
|
6780
|
-
return
|
|
6861
|
+
return _context70.stop();
|
|
6781
6862
|
}
|
|
6782
|
-
},
|
|
6863
|
+
}, _callee70, this, [[4, 20]]);
|
|
6783
6864
|
}));
|
|
6784
|
-
function withLocalSmallTicketData(
|
|
6865
|
+
function withLocalSmallTicketData(_x77, _x78) {
|
|
6785
6866
|
return _withLocalSmallTicketData.apply(this, arguments);
|
|
6786
6867
|
}
|
|
6787
6868
|
return withLocalSmallTicketData;
|
|
@@ -6843,22 +6924,22 @@ var Server = /*#__PURE__*/function () {
|
|
|
6843
6924
|
}, {
|
|
6844
6925
|
key: "handleUpdateLocalOrdersBatch",
|
|
6845
6926
|
value: (function () {
|
|
6846
|
-
var _handleUpdateLocalOrdersBatch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
6927
|
+
var _handleUpdateLocalOrdersBatch = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee71(orderIds) {
|
|
6847
6928
|
var _this$app17;
|
|
6848
6929
|
var existedBefore, _iterator13, _step13, id, fetched, message, fetchedMap, _iterator14, _step14, order, oid, freshOrders, succeedIds, failed, _iterator15, _step15, _id, fresh, _message2, overwritten, inserted;
|
|
6849
|
-
return _regeneratorRuntime().wrap(function
|
|
6850
|
-
while (1) switch (
|
|
6930
|
+
return _regeneratorRuntime().wrap(function _callee71$(_context71) {
|
|
6931
|
+
while (1) switch (_context71.prev = _context71.next) {
|
|
6851
6932
|
case 0:
|
|
6852
6933
|
this.logInfo('handleUpdateLocalOrdersBatch: 开始处理', {
|
|
6853
6934
|
count: orderIds.length,
|
|
6854
6935
|
orderIds: orderIds
|
|
6855
6936
|
});
|
|
6856
6937
|
if (this.order) {
|
|
6857
|
-
|
|
6938
|
+
_context71.next = 4;
|
|
6858
6939
|
break;
|
|
6859
6940
|
}
|
|
6860
6941
|
this.logError('handleUpdateLocalOrdersBatch: Order 模块未注册');
|
|
6861
|
-
return
|
|
6942
|
+
return _context71.abrupt("return", {
|
|
6862
6943
|
code: 500,
|
|
6863
6944
|
status: false,
|
|
6864
6945
|
message: 'Order 模块未注册',
|
|
@@ -6866,11 +6947,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
6866
6947
|
});
|
|
6867
6948
|
case 4:
|
|
6868
6949
|
if ((_this$app17 = this.app) !== null && _this$app17 !== void 0 && _this$app17.request) {
|
|
6869
|
-
|
|
6950
|
+
_context71.next = 7;
|
|
6870
6951
|
break;
|
|
6871
6952
|
}
|
|
6872
6953
|
this.logError('handleUpdateLocalOrdersBatch: app.request 不可用');
|
|
6873
|
-
return
|
|
6954
|
+
return _context71.abrupt("return", {
|
|
6874
6955
|
code: 500,
|
|
6875
6956
|
status: false,
|
|
6876
6957
|
message: 'app.request 不可用',
|
|
@@ -6893,21 +6974,21 @@ var Server = /*#__PURE__*/function () {
|
|
|
6893
6974
|
_iterator13.f();
|
|
6894
6975
|
}
|
|
6895
6976
|
fetched = [];
|
|
6896
|
-
|
|
6897
|
-
|
|
6977
|
+
_context71.prev = 11;
|
|
6978
|
+
_context71.next = 14;
|
|
6898
6979
|
return this.order.fetchOrdersByHttp(orderIds);
|
|
6899
6980
|
case 14:
|
|
6900
|
-
fetched =
|
|
6901
|
-
|
|
6981
|
+
fetched = _context71.sent;
|
|
6982
|
+
_context71.next = 22;
|
|
6902
6983
|
break;
|
|
6903
6984
|
case 17:
|
|
6904
|
-
|
|
6905
|
-
|
|
6906
|
-
message =
|
|
6985
|
+
_context71.prev = 17;
|
|
6986
|
+
_context71.t0 = _context71["catch"](11);
|
|
6987
|
+
message = _context71.t0 instanceof Error ? _context71.t0.message : String(_context71.t0);
|
|
6907
6988
|
this.logError('handleUpdateLocalOrdersBatch: 批量拉取失败', {
|
|
6908
6989
|
message: message
|
|
6909
6990
|
});
|
|
6910
|
-
return
|
|
6991
|
+
return _context71.abrupt("return", {
|
|
6911
6992
|
code: 500,
|
|
6912
6993
|
status: false,
|
|
6913
6994
|
message: message,
|
|
@@ -6917,36 +6998,36 @@ var Server = /*#__PURE__*/function () {
|
|
|
6917
6998
|
// 按返回结果中的 order_id 建索引,未命中即视为单笔失败
|
|
6918
6999
|
fetchedMap = new Map();
|
|
6919
7000
|
_iterator14 = _createForOfIteratorHelper(fetched);
|
|
6920
|
-
|
|
7001
|
+
_context71.prev = 24;
|
|
6921
7002
|
_iterator14.s();
|
|
6922
7003
|
case 26:
|
|
6923
7004
|
if ((_step14 = _iterator14.n()).done) {
|
|
6924
|
-
|
|
7005
|
+
_context71.next = 34;
|
|
6925
7006
|
break;
|
|
6926
7007
|
}
|
|
6927
7008
|
order = _step14.value;
|
|
6928
7009
|
oid = order === null || order === void 0 ? void 0 : order.order_id;
|
|
6929
7010
|
if (!(oid === undefined || oid === null)) {
|
|
6930
|
-
|
|
7011
|
+
_context71.next = 31;
|
|
6931
7012
|
break;
|
|
6932
7013
|
}
|
|
6933
|
-
return
|
|
7014
|
+
return _context71.abrupt("continue", 32);
|
|
6934
7015
|
case 31:
|
|
6935
7016
|
fetchedMap.set(String(oid), order);
|
|
6936
7017
|
case 32:
|
|
6937
|
-
|
|
7018
|
+
_context71.next = 26;
|
|
6938
7019
|
break;
|
|
6939
7020
|
case 34:
|
|
6940
|
-
|
|
7021
|
+
_context71.next = 39;
|
|
6941
7022
|
break;
|
|
6942
7023
|
case 36:
|
|
6943
|
-
|
|
6944
|
-
|
|
6945
|
-
_iterator14.e(
|
|
7024
|
+
_context71.prev = 36;
|
|
7025
|
+
_context71.t1 = _context71["catch"](24);
|
|
7026
|
+
_iterator14.e(_context71.t1);
|
|
6946
7027
|
case 39:
|
|
6947
|
-
|
|
7028
|
+
_context71.prev = 39;
|
|
6948
7029
|
_iterator14.f();
|
|
6949
|
-
return
|
|
7030
|
+
return _context71.finish(39);
|
|
6950
7031
|
case 42:
|
|
6951
7032
|
freshOrders = [];
|
|
6952
7033
|
succeedIds = [];
|
|
@@ -6972,23 +7053,23 @@ var Server = /*#__PURE__*/function () {
|
|
|
6972
7053
|
_iterator15.f();
|
|
6973
7054
|
}
|
|
6974
7055
|
if (!(freshOrders.length > 0)) {
|
|
6975
|
-
|
|
7056
|
+
_context71.next = 58;
|
|
6976
7057
|
break;
|
|
6977
7058
|
}
|
|
6978
|
-
|
|
6979
|
-
|
|
7059
|
+
_context71.prev = 48;
|
|
7060
|
+
_context71.next = 51;
|
|
6980
7061
|
return this.order.upsertOrdersFromRemote(freshOrders);
|
|
6981
7062
|
case 51:
|
|
6982
|
-
|
|
7063
|
+
_context71.next = 58;
|
|
6983
7064
|
break;
|
|
6984
7065
|
case 53:
|
|
6985
|
-
|
|
6986
|
-
|
|
6987
|
-
_message2 =
|
|
7066
|
+
_context71.prev = 53;
|
|
7067
|
+
_context71.t2 = _context71["catch"](48);
|
|
7068
|
+
_message2 = _context71.t2 instanceof Error ? _context71.t2.message : String(_context71.t2);
|
|
6988
7069
|
this.logError('handleUpdateLocalOrdersBatch: 合并写入失败', {
|
|
6989
7070
|
message: _message2
|
|
6990
7071
|
});
|
|
6991
|
-
return
|
|
7072
|
+
return _context71.abrupt("return", {
|
|
6992
7073
|
code: 500,
|
|
6993
7074
|
status: false,
|
|
6994
7075
|
message: _message2,
|
|
@@ -7007,7 +7088,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
7007
7088
|
insertedCount: inserted.length,
|
|
7008
7089
|
failedCount: failed.length
|
|
7009
7090
|
});
|
|
7010
|
-
return
|
|
7091
|
+
return _context71.abrupt("return", {
|
|
7011
7092
|
code: 200,
|
|
7012
7093
|
status: true,
|
|
7013
7094
|
message: '',
|
|
@@ -7019,11 +7100,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
7019
7100
|
});
|
|
7020
7101
|
case 62:
|
|
7021
7102
|
case "end":
|
|
7022
|
-
return
|
|
7103
|
+
return _context71.stop();
|
|
7023
7104
|
}
|
|
7024
|
-
},
|
|
7105
|
+
}, _callee71, this, [[11, 17], [24, 36, 39, 42], [48, 53]]);
|
|
7025
7106
|
}));
|
|
7026
|
-
function handleUpdateLocalOrdersBatch(
|
|
7107
|
+
function handleUpdateLocalOrdersBatch(_x79) {
|
|
7027
7108
|
return _handleUpdateLocalOrdersBatch.apply(this, arguments);
|
|
7028
7109
|
}
|
|
7029
7110
|
return handleUpdateLocalOrdersBatch;
|
|
@@ -7389,16 +7470,16 @@ var Server = /*#__PURE__*/function () {
|
|
|
7389
7470
|
}, {
|
|
7390
7471
|
key: "recomputeAndNotifyFloorPlanQuery",
|
|
7391
7472
|
value: (function () {
|
|
7392
|
-
var _recomputeAndNotifyFloorPlanQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7473
|
+
var _recomputeAndNotifyFloorPlanQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee72() {
|
|
7393
7474
|
var _iterator17, _step17, _step17$value, subscriberId, sub, result, errorMessage;
|
|
7394
|
-
return _regeneratorRuntime().wrap(function
|
|
7395
|
-
while (1) switch (
|
|
7475
|
+
return _regeneratorRuntime().wrap(function _callee72$(_context72) {
|
|
7476
|
+
while (1) switch (_context72.prev = _context72.next) {
|
|
7396
7477
|
case 0:
|
|
7397
7478
|
if (!(this.floorPlanQuerySubscribers.size === 0)) {
|
|
7398
|
-
|
|
7479
|
+
_context72.next = 2;
|
|
7399
7480
|
break;
|
|
7400
7481
|
}
|
|
7401
|
-
return
|
|
7482
|
+
return _context72.abrupt("return");
|
|
7402
7483
|
case 2:
|
|
7403
7484
|
this.logInfo('recomputeAndNotifyFloorPlanQuery: 开始推送', {
|
|
7404
7485
|
subscriberCount: this.floorPlanQuerySubscribers.size
|
|
@@ -7428,9 +7509,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
7428
7509
|
}
|
|
7429
7510
|
case 5:
|
|
7430
7511
|
case "end":
|
|
7431
|
-
return
|
|
7512
|
+
return _context72.stop();
|
|
7432
7513
|
}
|
|
7433
|
-
},
|
|
7514
|
+
}, _callee72, this);
|
|
7434
7515
|
}));
|
|
7435
7516
|
function recomputeAndNotifyFloorPlanQuery() {
|
|
7436
7517
|
return _recomputeAndNotifyFloorPlanQuery.apply(this, arguments);
|
|
@@ -7460,21 +7541,21 @@ var Server = /*#__PURE__*/function () {
|
|
|
7460
7541
|
* filter 逻辑暂为 mock,仅记录参数
|
|
7461
7542
|
*/
|
|
7462
7543
|
function () {
|
|
7463
|
-
var _computeOrderQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7544
|
+
var _computeOrderQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee73(data) {
|
|
7464
7545
|
var rawList, result;
|
|
7465
|
-
return _regeneratorRuntime().wrap(function
|
|
7466
|
-
while (1) switch (
|
|
7546
|
+
return _regeneratorRuntime().wrap(function _callee73$(_context73) {
|
|
7547
|
+
while (1) switch (_context73.prev = _context73.next) {
|
|
7467
7548
|
case 0:
|
|
7468
7549
|
this.logInfo('computeOrderQueryResult: 开始过滤', {
|
|
7469
7550
|
data: data
|
|
7470
7551
|
});
|
|
7471
7552
|
console.log('[Server] computeOrderQueryResult', data);
|
|
7472
7553
|
if (this.order) {
|
|
7473
|
-
|
|
7554
|
+
_context73.next = 5;
|
|
7474
7555
|
break;
|
|
7475
7556
|
}
|
|
7476
7557
|
this.logError('computeOrderQueryResult: Order 模块未注册');
|
|
7477
|
-
return
|
|
7558
|
+
return _context73.abrupt("return", {
|
|
7478
7559
|
code: 500,
|
|
7479
7560
|
message: 'Order 模块未注册',
|
|
7480
7561
|
data: {
|
|
@@ -7504,7 +7585,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
7504
7585
|
skip: result.skip,
|
|
7505
7586
|
rejected: result.rejected
|
|
7506
7587
|
});
|
|
7507
|
-
return
|
|
7588
|
+
return _context73.abrupt("return", {
|
|
7508
7589
|
code: 200,
|
|
7509
7590
|
data: result,
|
|
7510
7591
|
message: '',
|
|
@@ -7512,11 +7593,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
7512
7593
|
});
|
|
7513
7594
|
case 11:
|
|
7514
7595
|
case "end":
|
|
7515
|
-
return
|
|
7596
|
+
return _context73.stop();
|
|
7516
7597
|
}
|
|
7517
|
-
},
|
|
7598
|
+
}, _callee73, this);
|
|
7518
7599
|
}));
|
|
7519
|
-
function computeOrderQueryResult(
|
|
7600
|
+
function computeOrderQueryResult(_x80) {
|
|
7520
7601
|
return _computeOrderQueryResult.apply(this, arguments);
|
|
7521
7602
|
}
|
|
7522
7603
|
return computeOrderQueryResult;
|
|
@@ -7529,17 +7610,17 @@ var Server = /*#__PURE__*/function () {
|
|
|
7529
7610
|
}, {
|
|
7530
7611
|
key: "computeBookingQueryResult",
|
|
7531
7612
|
value: (function () {
|
|
7532
|
-
var _computeBookingQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7613
|
+
var _computeBookingQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee74(data) {
|
|
7533
7614
|
var rawOrders, result;
|
|
7534
|
-
return _regeneratorRuntime().wrap(function
|
|
7535
|
-
while (1) switch (
|
|
7615
|
+
return _regeneratorRuntime().wrap(function _callee74$(_context74) {
|
|
7616
|
+
while (1) switch (_context74.prev = _context74.next) {
|
|
7536
7617
|
case 0:
|
|
7537
7618
|
if (this.order) {
|
|
7538
|
-
|
|
7619
|
+
_context74.next = 3;
|
|
7539
7620
|
break;
|
|
7540
7621
|
}
|
|
7541
7622
|
this.logError('computeBookingQueryResult: Order 模块未注册');
|
|
7542
|
-
return
|
|
7623
|
+
return _context74.abrupt("return", {
|
|
7543
7624
|
code: 500,
|
|
7544
7625
|
message: 'Order 模块未注册',
|
|
7545
7626
|
data: {
|
|
@@ -7558,7 +7639,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
7558
7639
|
size: result.size,
|
|
7559
7640
|
skip: result.skip
|
|
7560
7641
|
});
|
|
7561
|
-
return
|
|
7642
|
+
return _context74.abrupt("return", {
|
|
7562
7643
|
code: 200,
|
|
7563
7644
|
data: result,
|
|
7564
7645
|
message: '',
|
|
@@ -7566,11 +7647,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
7566
7647
|
});
|
|
7567
7648
|
case 8:
|
|
7568
7649
|
case "end":
|
|
7569
|
-
return
|
|
7650
|
+
return _context74.stop();
|
|
7570
7651
|
}
|
|
7571
|
-
},
|
|
7652
|
+
}, _callee74, this);
|
|
7572
7653
|
}));
|
|
7573
|
-
function computeBookingQueryResult(
|
|
7654
|
+
function computeBookingQueryResult(_x81) {
|
|
7574
7655
|
return _computeBookingQueryResult.apply(this, arguments);
|
|
7575
7656
|
}
|
|
7576
7657
|
return computeBookingQueryResult;
|
|
@@ -7629,12 +7710,12 @@ var Server = /*#__PURE__*/function () {
|
|
|
7629
7710
|
}, {
|
|
7630
7711
|
key: "computeProductQueryResult",
|
|
7631
7712
|
value: (function () {
|
|
7632
|
-
var _computeProductQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
7713
|
+
var _computeProductQueryResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee75(context, options) {
|
|
7633
7714
|
var _menu_list_ids$length3,
|
|
7634
7715
|
_this21 = this;
|
|
7635
7716
|
var tTotal, menu_list_ids, ids, schedule_date, schedule_datetime, customer_id, extension_type, product_id, strategy_context, queryIds, 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;
|
|
7636
|
-
return _regeneratorRuntime().wrap(function
|
|
7637
|
-
while (1) switch (
|
|
7717
|
+
return _regeneratorRuntime().wrap(function _callee75$(_context75) {
|
|
7718
|
+
while (1) switch (_context75.prev = _context75.next) {
|
|
7638
7719
|
case 0:
|
|
7639
7720
|
tTotal = performance.now();
|
|
7640
7721
|
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, strategy_context = context.strategy_context;
|
|
@@ -7661,28 +7742,28 @@ var Server = /*#__PURE__*/function () {
|
|
|
7661
7742
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds
|
|
7662
7743
|
});
|
|
7663
7744
|
if (this.products) {
|
|
7664
|
-
|
|
7745
|
+
_context75.next = 8;
|
|
7665
7746
|
break;
|
|
7666
7747
|
}
|
|
7667
7748
|
this.logError('computeProductQueryResult: Products 模块未注册');
|
|
7668
|
-
return
|
|
7749
|
+
return _context75.abrupt("return", {
|
|
7669
7750
|
message: 'Products 模块未注册',
|
|
7670
7751
|
data: this.buildProductQueryResultPayload([], 0)
|
|
7671
7752
|
});
|
|
7672
7753
|
case 8:
|
|
7673
7754
|
if (!(queryIds.length > 0)) {
|
|
7674
|
-
|
|
7755
|
+
_context75.next = 20;
|
|
7675
7756
|
break;
|
|
7676
7757
|
}
|
|
7677
7758
|
uniqueIds = Array.from(new Set(queryIds));
|
|
7678
7759
|
_tPrice = performance.now();
|
|
7679
|
-
|
|
7760
|
+
_context75.next = 13;
|
|
7680
7761
|
return this.products.getProductsWithPrice(schedule_date, formatterContext, {
|
|
7681
7762
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds,
|
|
7682
7763
|
productIds: uniqueIds
|
|
7683
7764
|
});
|
|
7684
7765
|
case 13:
|
|
7685
|
-
productsWithPrice =
|
|
7766
|
+
productsWithPrice = _context75.sent;
|
|
7686
7767
|
perfMark('computeQuery.getProductsWithPrice(ids)', performance.now() - _tPrice, {
|
|
7687
7768
|
count: productsWithPrice.length,
|
|
7688
7769
|
ids: uniqueIds
|
|
@@ -7702,7 +7783,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
7702
7783
|
ids: uniqueIds,
|
|
7703
7784
|
count: extensionFilteredProducts.length
|
|
7704
7785
|
});
|
|
7705
|
-
return
|
|
7786
|
+
return _context75.abrupt("return", {
|
|
7706
7787
|
code: 200,
|
|
7707
7788
|
data: this.buildProductQueryResultPayload(extensionFilteredProducts),
|
|
7708
7789
|
message: '',
|
|
@@ -7710,17 +7791,17 @@ var Server = /*#__PURE__*/function () {
|
|
|
7710
7791
|
});
|
|
7711
7792
|
case 20:
|
|
7712
7793
|
if (!(product_id != null && Number.isFinite(Number(product_id)))) {
|
|
7713
|
-
|
|
7794
|
+
_context75.next = 32;
|
|
7714
7795
|
break;
|
|
7715
7796
|
}
|
|
7716
7797
|
pid = Number(product_id);
|
|
7717
7798
|
_tPrice2 = performance.now();
|
|
7718
|
-
|
|
7799
|
+
_context75.next = 25;
|
|
7719
7800
|
return this.products.getProductsWithPrice(schedule_date, formatterContext, {
|
|
7720
7801
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds
|
|
7721
7802
|
});
|
|
7722
7803
|
case 25:
|
|
7723
|
-
allProductsWithPrice =
|
|
7804
|
+
allProductsWithPrice = _context75.sent;
|
|
7724
7805
|
perfMark('computeQuery.getProductsWithPrice(single)', performance.now() - _tPrice2, {
|
|
7725
7806
|
count: allProductsWithPrice.length,
|
|
7726
7807
|
productId: pid
|
|
@@ -7740,7 +7821,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
7740
7821
|
productId: pid,
|
|
7741
7822
|
found: !!item
|
|
7742
7823
|
});
|
|
7743
|
-
return
|
|
7824
|
+
return _context75.abrupt("return", {
|
|
7744
7825
|
code: 200,
|
|
7745
7826
|
data: item,
|
|
7746
7827
|
message: item ? '' : '商品不存在或未发布',
|
|
@@ -7748,16 +7829,16 @@ var Server = /*#__PURE__*/function () {
|
|
|
7748
7829
|
});
|
|
7749
7830
|
case 32:
|
|
7750
7831
|
if (!this.shouldQueryProductsByExtensionTypes(extension_type)) {
|
|
7751
|
-
|
|
7832
|
+
_context75.next = 52;
|
|
7752
7833
|
break;
|
|
7753
7834
|
}
|
|
7754
7835
|
_tPrice3 = performance.now();
|
|
7755
|
-
|
|
7836
|
+
_context75.next = 36;
|
|
7756
7837
|
return this.products.getProductsWithPrice(schedule_date, formatterContext, {
|
|
7757
7838
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds
|
|
7758
7839
|
});
|
|
7759
7840
|
case 36:
|
|
7760
|
-
_filteredProducts2 =
|
|
7841
|
+
_filteredProducts2 = _context75.sent;
|
|
7761
7842
|
perfMark('computeQuery.getProductsWithPrice(extensionType)', performance.now() - _tPrice3, {
|
|
7762
7843
|
count: _filteredProducts2.length,
|
|
7763
7844
|
extension_type: extension_type
|
|
@@ -7796,7 +7877,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
7796
7877
|
filteredCount: _filteredProducts2.length,
|
|
7797
7878
|
extension_type: extension_type
|
|
7798
7879
|
});
|
|
7799
|
-
return
|
|
7880
|
+
return _context75.abrupt("return", {
|
|
7800
7881
|
code: 200,
|
|
7801
7882
|
data: this.buildProductQueryResultPayload(_filteredProducts2),
|
|
7802
7883
|
message: '',
|
|
@@ -7804,28 +7885,28 @@ var Server = /*#__PURE__*/function () {
|
|
|
7804
7885
|
});
|
|
7805
7886
|
case 52:
|
|
7806
7887
|
if (this.menu) {
|
|
7807
|
-
|
|
7888
|
+
_context75.next = 55;
|
|
7808
7889
|
break;
|
|
7809
7890
|
}
|
|
7810
7891
|
this.logError('computeProductQueryResult: Menu 模块未注册');
|
|
7811
|
-
return
|
|
7892
|
+
return _context75.abrupt("return", {
|
|
7812
7893
|
message: 'Menu 模块未注册',
|
|
7813
7894
|
data: this.buildProductQueryResultPayload([], 0)
|
|
7814
7895
|
});
|
|
7815
7896
|
case 55:
|
|
7816
7897
|
if (this.schedule) {
|
|
7817
|
-
|
|
7898
|
+
_context75.next = 58;
|
|
7818
7899
|
break;
|
|
7819
7900
|
}
|
|
7820
7901
|
this.logError('computeProductQueryResult: Schedule 模块未注册');
|
|
7821
|
-
return
|
|
7902
|
+
return _context75.abrupt("return", {
|
|
7822
7903
|
message: 'Schedule 模块未注册',
|
|
7823
7904
|
data: this.buildProductQueryResultPayload([], 0)
|
|
7824
7905
|
});
|
|
7825
7906
|
case 58:
|
|
7826
7907
|
activeMenuList = [];
|
|
7827
7908
|
if (!(menu_list_ids && Array.isArray(menu_list_ids) && menu_list_ids.length > 0)) {
|
|
7828
|
-
|
|
7909
|
+
_context75.next = 71;
|
|
7829
7910
|
break;
|
|
7830
7911
|
}
|
|
7831
7912
|
tMenu = performance.now();
|
|
@@ -7836,18 +7917,18 @@ var Server = /*#__PURE__*/function () {
|
|
|
7836
7917
|
});
|
|
7837
7918
|
};
|
|
7838
7919
|
activeMenuList = getActiveMenus();
|
|
7839
|
-
|
|
7840
|
-
if (!
|
|
7841
|
-
|
|
7920
|
+
_context75.t0 = !activeMenuList.length;
|
|
7921
|
+
if (!_context75.t0) {
|
|
7922
|
+
_context75.next = 68;
|
|
7842
7923
|
break;
|
|
7843
7924
|
}
|
|
7844
|
-
|
|
7925
|
+
_context75.next = 67;
|
|
7845
7926
|
return this.refreshMenuScheduleCacheAfterEmptyResult();
|
|
7846
7927
|
case 67:
|
|
7847
|
-
|
|
7928
|
+
_context75.t0 = _context75.sent;
|
|
7848
7929
|
case 68:
|
|
7849
|
-
if (!
|
|
7850
|
-
|
|
7930
|
+
if (!_context75.t0) {
|
|
7931
|
+
_context75.next = 70;
|
|
7851
7932
|
break;
|
|
7852
7933
|
}
|
|
7853
7934
|
activeMenuList = getActiveMenus();
|
|
@@ -7867,22 +7948,22 @@ var Server = /*#__PURE__*/function () {
|
|
|
7867
7948
|
});
|
|
7868
7949
|
tPrice = performance.now();
|
|
7869
7950
|
if (!(scopedProductIds.length > 0)) {
|
|
7870
|
-
|
|
7951
|
+
_context75.next = 82;
|
|
7871
7952
|
break;
|
|
7872
7953
|
}
|
|
7873
|
-
|
|
7954
|
+
_context75.next = 79;
|
|
7874
7955
|
return this.products.getProductsWithPrice(schedule_date, formatterContext, {
|
|
7875
7956
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds,
|
|
7876
7957
|
productIds: productScope.isAllProducts ? undefined : scopedProductIds
|
|
7877
7958
|
});
|
|
7878
7959
|
case 79:
|
|
7879
|
-
|
|
7880
|
-
|
|
7960
|
+
_context75.t1 = _context75.sent;
|
|
7961
|
+
_context75.next = 83;
|
|
7881
7962
|
break;
|
|
7882
7963
|
case 82:
|
|
7883
|
-
|
|
7964
|
+
_context75.t1 = [];
|
|
7884
7965
|
case 83:
|
|
7885
|
-
filteredProducts =
|
|
7966
|
+
filteredProducts = _context75.t1;
|
|
7886
7967
|
perfMark('computeQuery.getProductsWithPrice', performance.now() - tPrice, {
|
|
7887
7968
|
count: filteredProducts.length,
|
|
7888
7969
|
scopedProductCount: scopedProductIds.length
|
|
@@ -7923,7 +8004,7 @@ var Server = /*#__PURE__*/function () {
|
|
|
7923
8004
|
filteredCount: filteredProducts.length,
|
|
7924
8005
|
activeMenuCount: activeMenuList.length
|
|
7925
8006
|
});
|
|
7926
|
-
return
|
|
8007
|
+
return _context75.abrupt("return", {
|
|
7927
8008
|
code: 200,
|
|
7928
8009
|
data: this.buildProductQueryResultPayload(filteredProducts),
|
|
7929
8010
|
message: '',
|
|
@@ -7931,11 +8012,11 @@ var Server = /*#__PURE__*/function () {
|
|
|
7931
8012
|
});
|
|
7932
8013
|
case 99:
|
|
7933
8014
|
case "end":
|
|
7934
|
-
return
|
|
8015
|
+
return _context75.stop();
|
|
7935
8016
|
}
|
|
7936
|
-
},
|
|
8017
|
+
}, _callee75, this);
|
|
7937
8018
|
}));
|
|
7938
|
-
function computeProductQueryResult(
|
|
8019
|
+
function computeProductQueryResult(_x82, _x83) {
|
|
7939
8020
|
return _computeProductQueryResult.apply(this, arguments);
|
|
7940
8021
|
}
|
|
7941
8022
|
return computeProductQueryResult;
|
|
@@ -7971,72 +8052,72 @@ var Server = /*#__PURE__*/function () {
|
|
|
7971
8052
|
}, {
|
|
7972
8053
|
key: "recomputeAndNotifyProductQuery",
|
|
7973
8054
|
value: (function () {
|
|
7974
|
-
var _recomputeAndNotifyProductQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
8055
|
+
var _recomputeAndNotifyProductQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee76(options) {
|
|
7975
8056
|
var _iterator18, _step18, _step18$value, subscriberId, subscriber, result, errorMessage;
|
|
7976
|
-
return _regeneratorRuntime().wrap(function
|
|
7977
|
-
while (1) switch (
|
|
8057
|
+
return _regeneratorRuntime().wrap(function _callee76$(_context76) {
|
|
8058
|
+
while (1) switch (_context76.prev = _context76.next) {
|
|
7978
8059
|
case 0:
|
|
7979
8060
|
if (!(this.productQuerySubscribers.size === 0)) {
|
|
7980
|
-
|
|
8061
|
+
_context76.next = 2;
|
|
7981
8062
|
break;
|
|
7982
8063
|
}
|
|
7983
|
-
return
|
|
8064
|
+
return _context76.abrupt("return");
|
|
7984
8065
|
case 2:
|
|
7985
8066
|
this.logInfo('recomputeAndNotifyProductQuery: 开始推送', {
|
|
7986
8067
|
subscriberCount: this.productQuerySubscribers.size,
|
|
7987
8068
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds
|
|
7988
8069
|
});
|
|
7989
8070
|
_iterator18 = _createForOfIteratorHelper(this.productQuerySubscribers.entries());
|
|
7990
|
-
|
|
8071
|
+
_context76.prev = 4;
|
|
7991
8072
|
_iterator18.s();
|
|
7992
8073
|
case 6:
|
|
7993
8074
|
if ((_step18 = _iterator18.n()).done) {
|
|
7994
|
-
|
|
8075
|
+
_context76.next = 22;
|
|
7995
8076
|
break;
|
|
7996
8077
|
}
|
|
7997
8078
|
_step18$value = _slicedToArray(_step18.value, 2), subscriberId = _step18$value[0], subscriber = _step18$value[1];
|
|
7998
|
-
|
|
7999
|
-
|
|
8079
|
+
_context76.prev = 8;
|
|
8080
|
+
_context76.next = 11;
|
|
8000
8081
|
return this.computeProductQueryResult(subscriber.context, {
|
|
8001
8082
|
changedIds: options === null || options === void 0 ? void 0 : options.changedIds
|
|
8002
8083
|
});
|
|
8003
8084
|
case 11:
|
|
8004
|
-
result =
|
|
8085
|
+
result = _context76.sent;
|
|
8005
8086
|
subscriber.callback(result);
|
|
8006
8087
|
this.logInfo('recomputeAndNotifyProductQuery: 已推送', {
|
|
8007
8088
|
subscriberId: subscriberId
|
|
8008
8089
|
});
|
|
8009
|
-
|
|
8090
|
+
_context76.next = 20;
|
|
8010
8091
|
break;
|
|
8011
8092
|
case 16:
|
|
8012
|
-
|
|
8013
|
-
|
|
8014
|
-
errorMessage =
|
|
8093
|
+
_context76.prev = 16;
|
|
8094
|
+
_context76.t0 = _context76["catch"](8);
|
|
8095
|
+
errorMessage = _context76.t0 instanceof Error ? _context76.t0.message : String(_context76.t0);
|
|
8015
8096
|
this.logError('recomputeAndNotifyProductQuery: 推送失败', {
|
|
8016
8097
|
subscriberId: subscriberId,
|
|
8017
8098
|
error: errorMessage
|
|
8018
8099
|
});
|
|
8019
8100
|
case 20:
|
|
8020
|
-
|
|
8101
|
+
_context76.next = 6;
|
|
8021
8102
|
break;
|
|
8022
8103
|
case 22:
|
|
8023
|
-
|
|
8104
|
+
_context76.next = 27;
|
|
8024
8105
|
break;
|
|
8025
8106
|
case 24:
|
|
8026
|
-
|
|
8027
|
-
|
|
8028
|
-
_iterator18.e(
|
|
8107
|
+
_context76.prev = 24;
|
|
8108
|
+
_context76.t1 = _context76["catch"](4);
|
|
8109
|
+
_iterator18.e(_context76.t1);
|
|
8029
8110
|
case 27:
|
|
8030
|
-
|
|
8111
|
+
_context76.prev = 27;
|
|
8031
8112
|
_iterator18.f();
|
|
8032
|
-
return
|
|
8113
|
+
return _context76.finish(27);
|
|
8033
8114
|
case 30:
|
|
8034
8115
|
case "end":
|
|
8035
|
-
return
|
|
8116
|
+
return _context76.stop();
|
|
8036
8117
|
}
|
|
8037
|
-
},
|
|
8118
|
+
}, _callee76, this, [[4, 24, 27, 30], [8, 16]]);
|
|
8038
8119
|
}));
|
|
8039
|
-
function recomputeAndNotifyProductQuery(
|
|
8120
|
+
function recomputeAndNotifyProductQuery(_x84) {
|
|
8040
8121
|
return _recomputeAndNotifyProductQuery.apply(this, arguments);
|
|
8041
8122
|
}
|
|
8042
8123
|
return recomputeAndNotifyProductQuery;
|
|
@@ -8048,16 +8129,16 @@ var Server = /*#__PURE__*/function () {
|
|
|
8048
8129
|
}, {
|
|
8049
8130
|
key: "recomputeAndNotifyOrderQuery",
|
|
8050
8131
|
value: (function () {
|
|
8051
|
-
var _recomputeAndNotifyOrderQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
8132
|
+
var _recomputeAndNotifyOrderQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee77() {
|
|
8052
8133
|
var notifyStartAt, _iterator19, _step19, _step19$value, subscriberId, subscriber, computeStartAt, result, computeEndAt, callbackStartAt, callbackEndAt, errorMessage, notifyEndAt;
|
|
8053
|
-
return _regeneratorRuntime().wrap(function
|
|
8054
|
-
while (1) switch (
|
|
8134
|
+
return _regeneratorRuntime().wrap(function _callee77$(_context77) {
|
|
8135
|
+
while (1) switch (_context77.prev = _context77.next) {
|
|
8055
8136
|
case 0:
|
|
8056
8137
|
if (!(this.orderQuerySubscribers.size === 0)) {
|
|
8057
|
-
|
|
8138
|
+
_context77.next = 2;
|
|
8058
8139
|
break;
|
|
8059
8140
|
}
|
|
8060
|
-
return
|
|
8141
|
+
return _context77.abrupt("return");
|
|
8061
8142
|
case 2:
|
|
8062
8143
|
notifyStartAt = Date.now();
|
|
8063
8144
|
this.logInfo('recomputeAndNotifyOrderQuery: 开始推送', {
|
|
@@ -8065,20 +8146,20 @@ var Server = /*#__PURE__*/function () {
|
|
|
8065
8146
|
notifyStartAt: new Date(notifyStartAt).toISOString()
|
|
8066
8147
|
});
|
|
8067
8148
|
_iterator19 = _createForOfIteratorHelper(this.orderQuerySubscribers.entries());
|
|
8068
|
-
|
|
8149
|
+
_context77.prev = 5;
|
|
8069
8150
|
_iterator19.s();
|
|
8070
8151
|
case 7:
|
|
8071
8152
|
if ((_step19 = _iterator19.n()).done) {
|
|
8072
|
-
|
|
8153
|
+
_context77.next = 27;
|
|
8073
8154
|
break;
|
|
8074
8155
|
}
|
|
8075
8156
|
_step19$value = _slicedToArray(_step19.value, 2), subscriberId = _step19$value[0], subscriber = _step19$value[1];
|
|
8076
|
-
|
|
8157
|
+
_context77.prev = 9;
|
|
8077
8158
|
computeStartAt = Date.now();
|
|
8078
|
-
|
|
8159
|
+
_context77.next = 13;
|
|
8079
8160
|
return this.computeOrderQueryResult(subscriber.context);
|
|
8080
8161
|
case 13:
|
|
8081
|
-
result =
|
|
8162
|
+
result = _context77.sent;
|
|
8082
8163
|
computeEndAt = Date.now();
|
|
8083
8164
|
callbackStartAt = Date.now();
|
|
8084
8165
|
subscriber.callback(result);
|
|
@@ -8089,30 +8170,30 @@ var Server = /*#__PURE__*/function () {
|
|
|
8089
8170
|
callbackDurationMs: callbackEndAt - callbackStartAt,
|
|
8090
8171
|
totalDurationMs: callbackEndAt - computeStartAt
|
|
8091
8172
|
});
|
|
8092
|
-
|
|
8173
|
+
_context77.next = 25;
|
|
8093
8174
|
break;
|
|
8094
8175
|
case 21:
|
|
8095
|
-
|
|
8096
|
-
|
|
8097
|
-
errorMessage =
|
|
8176
|
+
_context77.prev = 21;
|
|
8177
|
+
_context77.t0 = _context77["catch"](9);
|
|
8178
|
+
errorMessage = _context77.t0 instanceof Error ? _context77.t0.message : String(_context77.t0);
|
|
8098
8179
|
this.logError('recomputeAndNotifyOrderQuery: 推送失败', {
|
|
8099
8180
|
subscriberId: subscriberId,
|
|
8100
8181
|
error: errorMessage
|
|
8101
8182
|
});
|
|
8102
8183
|
case 25:
|
|
8103
|
-
|
|
8184
|
+
_context77.next = 7;
|
|
8104
8185
|
break;
|
|
8105
8186
|
case 27:
|
|
8106
|
-
|
|
8187
|
+
_context77.next = 32;
|
|
8107
8188
|
break;
|
|
8108
8189
|
case 29:
|
|
8109
|
-
|
|
8110
|
-
|
|
8111
|
-
_iterator19.e(
|
|
8190
|
+
_context77.prev = 29;
|
|
8191
|
+
_context77.t1 = _context77["catch"](5);
|
|
8192
|
+
_iterator19.e(_context77.t1);
|
|
8112
8193
|
case 32:
|
|
8113
|
-
|
|
8194
|
+
_context77.prev = 32;
|
|
8114
8195
|
_iterator19.f();
|
|
8115
|
-
return
|
|
8196
|
+
return _context77.finish(32);
|
|
8116
8197
|
case 35:
|
|
8117
8198
|
notifyEndAt = Date.now();
|
|
8118
8199
|
this.logInfo('recomputeAndNotifyOrderQuery: 推送完成', {
|
|
@@ -8121,9 +8202,9 @@ var Server = /*#__PURE__*/function () {
|
|
|
8121
8202
|
});
|
|
8122
8203
|
case 37:
|
|
8123
8204
|
case "end":
|
|
8124
|
-
return
|
|
8205
|
+
return _context77.stop();
|
|
8125
8206
|
}
|
|
8126
|
-
},
|
|
8207
|
+
}, _callee77, this, [[5, 29, 32, 35], [9, 21]]);
|
|
8127
8208
|
}));
|
|
8128
8209
|
function recomputeAndNotifyOrderQuery() {
|
|
8129
8210
|
return _recomputeAndNotifyOrderQuery.apply(this, arguments);
|
|
@@ -8264,67 +8345,67 @@ var Server = /*#__PURE__*/function () {
|
|
|
8264
8345
|
}, {
|
|
8265
8346
|
key: "recomputeAndNotifyBookingQuery",
|
|
8266
8347
|
value: (function () {
|
|
8267
|
-
var _recomputeAndNotifyBookingQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
8348
|
+
var _recomputeAndNotifyBookingQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee78() {
|
|
8268
8349
|
var _iterator21, _step21, _step21$value, subscriberId, subscriber, result, errorMessage;
|
|
8269
|
-
return _regeneratorRuntime().wrap(function
|
|
8270
|
-
while (1) switch (
|
|
8350
|
+
return _regeneratorRuntime().wrap(function _callee78$(_context78) {
|
|
8351
|
+
while (1) switch (_context78.prev = _context78.next) {
|
|
8271
8352
|
case 0:
|
|
8272
8353
|
if (!(this.bookingQuerySubscribers.size === 0)) {
|
|
8273
|
-
|
|
8354
|
+
_context78.next = 2;
|
|
8274
8355
|
break;
|
|
8275
8356
|
}
|
|
8276
|
-
return
|
|
8357
|
+
return _context78.abrupt("return");
|
|
8277
8358
|
case 2:
|
|
8278
8359
|
this.logInfo('recomputeAndNotifyBookingQuery: 开始推送', {
|
|
8279
8360
|
subscriberCount: this.bookingQuerySubscribers.size
|
|
8280
8361
|
});
|
|
8281
8362
|
_iterator21 = _createForOfIteratorHelper(this.bookingQuerySubscribers.entries());
|
|
8282
|
-
|
|
8363
|
+
_context78.prev = 4;
|
|
8283
8364
|
_iterator21.s();
|
|
8284
8365
|
case 6:
|
|
8285
8366
|
if ((_step21 = _iterator21.n()).done) {
|
|
8286
|
-
|
|
8367
|
+
_context78.next = 22;
|
|
8287
8368
|
break;
|
|
8288
8369
|
}
|
|
8289
8370
|
_step21$value = _slicedToArray(_step21.value, 2), subscriberId = _step21$value[0], subscriber = _step21$value[1];
|
|
8290
|
-
|
|
8291
|
-
|
|
8371
|
+
_context78.prev = 8;
|
|
8372
|
+
_context78.next = 11;
|
|
8292
8373
|
return this.computeBookingQueryResult(subscriber.context);
|
|
8293
8374
|
case 11:
|
|
8294
|
-
result =
|
|
8375
|
+
result = _context78.sent;
|
|
8295
8376
|
subscriber.callback(result);
|
|
8296
8377
|
this.logInfo('recomputeAndNotifyBookingQuery: 已推送', {
|
|
8297
8378
|
subscriberId: subscriberId
|
|
8298
8379
|
});
|
|
8299
|
-
|
|
8380
|
+
_context78.next = 20;
|
|
8300
8381
|
break;
|
|
8301
8382
|
case 16:
|
|
8302
|
-
|
|
8303
|
-
|
|
8304
|
-
errorMessage =
|
|
8383
|
+
_context78.prev = 16;
|
|
8384
|
+
_context78.t0 = _context78["catch"](8);
|
|
8385
|
+
errorMessage = _context78.t0 instanceof Error ? _context78.t0.message : String(_context78.t0);
|
|
8305
8386
|
this.logError('recomputeAndNotifyBookingQuery: 推送失败', {
|
|
8306
8387
|
subscriberId: subscriberId,
|
|
8307
8388
|
error: errorMessage
|
|
8308
8389
|
});
|
|
8309
8390
|
case 20:
|
|
8310
|
-
|
|
8391
|
+
_context78.next = 6;
|
|
8311
8392
|
break;
|
|
8312
8393
|
case 22:
|
|
8313
|
-
|
|
8394
|
+
_context78.next = 27;
|
|
8314
8395
|
break;
|
|
8315
8396
|
case 24:
|
|
8316
|
-
|
|
8317
|
-
|
|
8318
|
-
_iterator21.e(
|
|
8397
|
+
_context78.prev = 24;
|
|
8398
|
+
_context78.t1 = _context78["catch"](4);
|
|
8399
|
+
_iterator21.e(_context78.t1);
|
|
8319
8400
|
case 27:
|
|
8320
|
-
|
|
8401
|
+
_context78.prev = 27;
|
|
8321
8402
|
_iterator21.f();
|
|
8322
|
-
return
|
|
8403
|
+
return _context78.finish(27);
|
|
8323
8404
|
case 30:
|
|
8324
8405
|
case "end":
|
|
8325
|
-
return
|
|
8406
|
+
return _context78.stop();
|
|
8326
8407
|
}
|
|
8327
|
-
},
|
|
8408
|
+
}, _callee78, this, [[4, 24, 27, 30], [8, 16]]);
|
|
8328
8409
|
}));
|
|
8329
8410
|
function recomputeAndNotifyBookingQuery() {
|
|
8330
8411
|
return _recomputeAndNotifyBookingQuery.apply(this, arguments);
|