@pisell/pisellos 2.2.183 → 2.2.184
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/model/strategy/adapter/promotion/evaluator.js +3 -2
- package/dist/model/strategy/adapter/promotion/index.js +9 -0
- package/dist/modules/Order/index.d.ts +2 -0
- package/dist/modules/Order/index.js +100 -38
- package/dist/modules/Order/types.d.ts +1 -0
- package/dist/modules/Product/index.d.ts +1 -1
- package/dist/solution/BaseSales/index.js +38 -39
- package/dist/solution/BaseSales/utils/cartPromotion.d.ts +12 -0
- package/dist/solution/BaseSales/utils/cartPromotion.js +271 -130
- package/dist/solution/BookingByStep/index.d.ts +1 -1
- package/dist/solution/BookingTicket/index.js +9 -0
- package/lib/model/strategy/adapter/promotion/evaluator.js +2 -1
- package/lib/model/strategy/adapter/promotion/index.js +49 -0
- package/lib/modules/Order/index.d.ts +2 -0
- package/lib/modules/Order/index.js +63 -13
- package/lib/modules/Order/types.d.ts +1 -0
- package/lib/modules/Product/index.d.ts +1 -1
- package/lib/solution/BaseSales/index.js +0 -1
- package/lib/solution/BaseSales/utils/cartPromotion.d.ts +12 -0
- package/lib/solution/BaseSales/utils/cartPromotion.js +118 -12
- package/lib/solution/BookingByStep/index.d.ts +1 -1
- package/lib/solution/BookingTicket/index.js +7 -0
- package/package.json +1 -1
|
@@ -747,9 +747,10 @@ export var PromotionEvaluator = /*#__PURE__*/function () {
|
|
|
747
747
|
return b.price - a.price;
|
|
748
748
|
});
|
|
749
749
|
|
|
750
|
-
// 3.
|
|
750
|
+
// 3. 计算可以凑成多少组(cumulative 缺省视为 true,与 adapter 一致)
|
|
751
751
|
var totalUnits = unitProducts.length;
|
|
752
|
-
var
|
|
752
|
+
var isCumulative = cumulative !== false;
|
|
753
|
+
var groupCount = isCumulative ? Math.floor(totalUnits / x) : totalUnits >= x ? 1 : 0;
|
|
753
754
|
var promotionUnits = groupCount * x;
|
|
754
755
|
|
|
755
756
|
// 4. 分离参与促销的和不参与的商品
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// 导出评估器
|
|
2
|
+
export { PromotionEvaluator } from "./evaluator";
|
|
3
|
+
|
|
4
|
+
// 导出适配器
|
|
5
|
+
export { PromotionAdapter } from "./adapter";
|
|
6
|
+
export { default } from "./adapter";
|
|
7
|
+
|
|
8
|
+
// 导出策略配置示例常量
|
|
9
|
+
export { X_ITEMS_FOR_Y_PRICE_STRATEGY, BUY_X_GET_Y_FREE_STRATEGY } from "./examples";
|
|
@@ -312,6 +312,8 @@ export declare class OrderModule extends BaseModule implements Module, OrderModu
|
|
|
312
312
|
recalcOnHydrate?: boolean;
|
|
313
313
|
}): Promise<OrderTempOrder>;
|
|
314
314
|
private normalizeTempOrderForRuntime;
|
|
315
|
+
private normalizeHydratedProductOptionItem;
|
|
316
|
+
private resolveHydratedProductOptions;
|
|
315
317
|
private normalizeHydratedOrderProduct;
|
|
316
318
|
getLastOrderInfo(): Record<string, any> | undefined;
|
|
317
319
|
getOrderInfo(order_id: number): Promise<any>;
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
4
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
1
5
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
2
6
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
7
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
@@ -2108,7 +2112,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2108
2112
|
}) : null;
|
|
2109
2113
|
productToAdd = (linked === null || linked === void 0 ? void 0 : linked.product) || product;
|
|
2110
2114
|
incomingFingerprint = buildProductLineFingerprint(productToAdd.product_option_item, productToAdd.product_bundle);
|
|
2111
|
-
normalizedIncoming = normalizeOrderProduct(productToAdd);
|
|
2115
|
+
normalizedIncoming = mergeOrderProductDisplayFields(productToAdd, normalizeOrderProduct(productToAdd));
|
|
2112
2116
|
normalizedIncoming.discount_list = normalizeOrderProductDiscountList(normalizedIncoming.discount_list);
|
|
2113
2117
|
hasIncomingGoodPass = this.hasGoodPassDiscount(normalizedIncoming);
|
|
2114
2118
|
shouldForceNewLine = !!booking;
|
|
@@ -2156,11 +2160,11 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2156
2160
|
} else {
|
|
2157
2161
|
targetProduct = matchedProduct;
|
|
2158
2162
|
targetUid = (_targetProduct$metada = targetProduct.metadata) === null || _targetProduct$metada === void 0 ? void 0 : _targetProduct$metada.unique_identification_number;
|
|
2159
|
-
normalizedProduct = normalizeOrderProduct(_objectSpread(_objectSpread({}, productToAdd), {}, {
|
|
2163
|
+
normalizedProduct = mergeOrderProductDisplayFields(targetProduct, normalizeOrderProduct(_objectSpread(_objectSpread({}, productToAdd), {}, {
|
|
2160
2164
|
metadata: _objectSpread(_objectSpread({}, productToAdd.metadata || {}), {}, {
|
|
2161
2165
|
unique_identification_number: targetUid
|
|
2162
2166
|
})
|
|
2163
|
-
}));
|
|
2167
|
+
})));
|
|
2164
2168
|
normalizedProduct.discount_list = normalizeOrderProductDiscountList(normalizedProduct.discount_list);
|
|
2165
2169
|
tempOrder.products[matchedIndex] = _objectSpread(_objectSpread(_objectSpread({}, targetProduct), normalizedProduct), {}, {
|
|
2166
2170
|
metadata: _objectSpread(_objectSpread(_objectSpread({}, targetProduct.metadata || {}), normalizedProduct.metadata || {}), {}, {
|
|
@@ -2286,7 +2290,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
2286
2290
|
}
|
|
2287
2291
|
// normalizeOrderProduct 幂等:v2 metadata 存在 → 保留 main_product_* 折扣重算 composite;
|
|
2288
2292
|
// 否则 → 把顶层 selling_price 视作 source,派生 main_product_* 并写 price_schema_version: 2。
|
|
2289
|
-
normalizedProduct = normalizeOrderProduct(nextProduct);
|
|
2293
|
+
normalizedProduct = mergeOrderProductDisplayFields(nextProduct, normalizeOrderProduct(nextProduct));
|
|
2290
2294
|
normalizedProduct.discount_list = normalizeOrderProductDiscountList(normalizedProduct.discount_list);
|
|
2291
2295
|
if (booking) {
|
|
2292
2296
|
productUid = String(((_normalizedProduct$me = normalizedProduct.metadata) === null || _normalizedProduct$me === void 0 ? void 0 : _normalizedProduct$me.unique_identification_number) || ((_targetProduct$metada3 = targetProduct.metadata) === null || _targetProduct$metada3 === void 0 ? void 0 : _targetProduct$metada3.unique_identification_number) || unique_identification_number || createUuidV4());
|
|
@@ -3187,6 +3191,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3187
3191
|
_context32.next = 2;
|
|
3188
3192
|
return this.request.get("/order/sales/".concat(order_id), {
|
|
3189
3193
|
with: ['products', 'bookings', 'payments', 'customer', 'summary', 'contacts_info']
|
|
3194
|
+
}, {
|
|
3195
|
+
osServer: true
|
|
3190
3196
|
});
|
|
3191
3197
|
case 2:
|
|
3192
3198
|
res = _context32.sent;
|
|
@@ -3266,7 +3272,8 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3266
3272
|
delete nextTempOrder.holder_id;
|
|
3267
3273
|
nextTempOrder.metadata = raw.metadata && _typeof(raw.metadata) === 'object' ? _objectSpread({}, raw.metadata) : {};
|
|
3268
3274
|
nextTempOrder.holder = raw.holder && _typeof(raw.holder) === 'object' ? _objectSpread({}, raw.holder) : null;
|
|
3269
|
-
|
|
3275
|
+
var rawProducts = Array.isArray(raw.products) ? raw.products : [];
|
|
3276
|
+
nextTempOrder.products = rawProducts.length > 0 ? rawProducts.map(function (p) {
|
|
3270
3277
|
return _this10.normalizeHydratedOrderProduct(p);
|
|
3271
3278
|
}) : [];
|
|
3272
3279
|
nextTempOrder.bookings = Array.isArray(raw.bookings) ? raw.bookings.map(function (b) {
|
|
@@ -3293,12 +3300,66 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3293
3300
|
}) : {
|
|
3294
3301
|
productsByUid: {}
|
|
3295
3302
|
};
|
|
3303
|
+
var tempOrderExtend = nextTempOrder._extend;
|
|
3304
|
+
var productsByUid = tempOrderExtend.productsByUid || {};
|
|
3305
|
+
var _iterator8 = _createForOfIteratorHelper(nextTempOrder.products.entries()),
|
|
3306
|
+
_step8;
|
|
3307
|
+
try {
|
|
3308
|
+
for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
|
|
3309
|
+
var _product$metadata6, _ref23, _ref24, _existed$origin, _rawProduct$metadata;
|
|
3310
|
+
var _step8$value = _slicedToArray(_step8.value, 2),
|
|
3311
|
+
index = _step8$value[0],
|
|
3312
|
+
product = _step8$value[1];
|
|
3313
|
+
var uid = (_product$metadata6 = product.metadata) === null || _product$metadata6 === void 0 ? void 0 : _product$metadata6.unique_identification_number;
|
|
3314
|
+
if (!uid) continue;
|
|
3315
|
+
var existed = productsByUid[uid] && _typeof(productsByUid[uid]) === 'object' ? productsByUid[uid] : {};
|
|
3316
|
+
var rawProduct = rawProducts[index] && _typeof(rawProducts[index]) === 'object' ? rawProducts[index] : product;
|
|
3317
|
+
var origin = (_ref23 = (_ref24 = (_existed$origin = existed.origin) !== null && _existed$origin !== void 0 ? _existed$origin : rawProduct._origin) !== null && _ref24 !== void 0 ? _ref24 : (_rawProduct$metadata = rawProduct.metadata) === null || _rawProduct$metadata === void 0 ? void 0 : _rawProduct$metadata.origin) !== null && _ref23 !== void 0 ? _ref23 : rawProduct;
|
|
3318
|
+
productsByUid[uid] = _objectSpread(_objectSpread({}, existed), {}, {
|
|
3319
|
+
origin: cloneDeep(origin)
|
|
3320
|
+
});
|
|
3321
|
+
}
|
|
3322
|
+
} catch (err) {
|
|
3323
|
+
_iterator8.e(err);
|
|
3324
|
+
} finally {
|
|
3325
|
+
_iterator8.f();
|
|
3326
|
+
}
|
|
3327
|
+
tempOrderExtend.productsByUid = productsByUid;
|
|
3296
3328
|
if ((options === null || options === void 0 ? void 0 : options.ensureIdentity) !== false) {
|
|
3297
3329
|
this.ensureExternalSaleNumber(nextTempOrder);
|
|
3298
3330
|
}
|
|
3299
3331
|
nextTempOrder.vouchers = raw.vouchers || [];
|
|
3300
3332
|
return nextTempOrder;
|
|
3301
3333
|
}
|
|
3334
|
+
}, {
|
|
3335
|
+
key: "normalizeHydratedProductOptionItem",
|
|
3336
|
+
value: function normalizeHydratedProductOptionItem(optionItem) {
|
|
3337
|
+
var _ref25, _optionItem$num, _ref26, _optionItem$price;
|
|
3338
|
+
var rawNum = (_ref25 = (_optionItem$num = optionItem === null || optionItem === void 0 ? void 0 : optionItem.num) !== null && _optionItem$num !== void 0 ? _optionItem$num : optionItem === null || optionItem === void 0 ? void 0 : optionItem.quantity) !== null && _ref25 !== void 0 ? _ref25 : 1;
|
|
3339
|
+
var parsedNum = Number(rawNum);
|
|
3340
|
+
var rawPrice = (_ref26 = (_optionItem$price = optionItem === null || optionItem === void 0 ? void 0 : optionItem.price) !== null && _optionItem$price !== void 0 ? _optionItem$price : optionItem === null || optionItem === void 0 ? void 0 : optionItem.add_price) !== null && _ref26 !== void 0 ? _ref26 : 0;
|
|
3341
|
+
var parsedPrice = Number(rawPrice);
|
|
3342
|
+
return {
|
|
3343
|
+
option_group_item_id: optionItem === null || optionItem === void 0 ? void 0 : optionItem.option_group_item_id,
|
|
3344
|
+
option_group_id: optionItem === null || optionItem === void 0 ? void 0 : optionItem.option_group_id,
|
|
3345
|
+
num: Number.isFinite(parsedNum) && parsedNum > 0 ? parsedNum : 1,
|
|
3346
|
+
price: Number.isFinite(parsedPrice) ? parsedPrice : 0
|
|
3347
|
+
};
|
|
3348
|
+
}
|
|
3349
|
+
}, {
|
|
3350
|
+
key: "resolveHydratedProductOptions",
|
|
3351
|
+
value: function resolveHydratedProductOptions(row) {
|
|
3352
|
+
var _row$product_sku,
|
|
3353
|
+
_this11 = this;
|
|
3354
|
+
if (Array.isArray(row.product_option_item) && row.product_option_item.length > 0) {
|
|
3355
|
+
return row.product_option_item;
|
|
3356
|
+
}
|
|
3357
|
+
var skuOptions = (_row$product_sku = row.product_sku) === null || _row$product_sku === void 0 ? void 0 : _row$product_sku.option;
|
|
3358
|
+
if (!Array.isArray(skuOptions)) return [];
|
|
3359
|
+
return skuOptions.map(function (optionItem) {
|
|
3360
|
+
return _this11.normalizeHydratedProductOptionItem(optionItem || {});
|
|
3361
|
+
});
|
|
3362
|
+
}
|
|
3302
3363
|
}, {
|
|
3303
3364
|
key: "normalizeHydratedOrderProduct",
|
|
3304
3365
|
value: function normalizeHydratedOrderProduct(product) {
|
|
@@ -3306,7 +3367,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3306
3367
|
if (row.num === undefined && row.product_quantity !== undefined) {
|
|
3307
3368
|
row.num = row.product_quantity;
|
|
3308
3369
|
}
|
|
3309
|
-
|
|
3370
|
+
row.product_option_item = this.resolveHydratedProductOptions(row);
|
|
3310
3371
|
if (!Array.isArray(row.product_bundle)) row.product_bundle = [];
|
|
3311
3372
|
if (!row.metadata || _typeof(row.metadata) !== 'object') row.metadata = {};
|
|
3312
3373
|
var existingIdentity = row.metadata.unique_identification_number || row.unique_identification_number;
|
|
@@ -3316,6 +3377,7 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3316
3377
|
var normalized = normalizeOrderProduct(row);
|
|
3317
3378
|
normalized.discount_list = normalizeOrderProductDiscountList(normalized.discount_list);
|
|
3318
3379
|
var result = _objectSpread(_objectSpread(_objectSpread({}, row), normalized), {}, {
|
|
3380
|
+
product_sku: row.product_sku,
|
|
3319
3381
|
metadata: _objectSpread(_objectSpread({}, row.metadata), normalized.metadata)
|
|
3320
3382
|
});
|
|
3321
3383
|
if (result.metadata) delete result.metadata.price_schema_version;
|
|
@@ -3370,67 +3432,67 @@ export var OrderModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
3370
3432
|
var amount = new Decimal(discount.amount || 0).times(qty).plus(((_discount$metadata = discount.metadata) === null || _discount$metadata === void 0 ? void 0 : _discount$metadata.product_discount_difference) || 0);
|
|
3371
3433
|
savedMap.set(discountKey, (savedMap.get(discountKey) || new Decimal(0)).plus(amount));
|
|
3372
3434
|
};
|
|
3373
|
-
var
|
|
3374
|
-
|
|
3435
|
+
var _iterator9 = _createForOfIteratorHelper(productList),
|
|
3436
|
+
_step9;
|
|
3375
3437
|
try {
|
|
3376
|
-
for (
|
|
3377
|
-
var product =
|
|
3438
|
+
for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
|
|
3439
|
+
var product = _step9.value;
|
|
3378
3440
|
var qty = product.num || 1;
|
|
3379
|
-
var
|
|
3380
|
-
|
|
3441
|
+
var _iterator11 = _createForOfIteratorHelper(product.discount_list || []),
|
|
3442
|
+
_step11;
|
|
3381
3443
|
try {
|
|
3382
|
-
for (
|
|
3383
|
-
var pd =
|
|
3444
|
+
for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
|
|
3445
|
+
var pd = _step11.value;
|
|
3384
3446
|
addDiscountAmount(pd, qty);
|
|
3385
3447
|
}
|
|
3386
3448
|
} catch (err) {
|
|
3387
|
-
|
|
3449
|
+
_iterator11.e(err);
|
|
3388
3450
|
} finally {
|
|
3389
|
-
|
|
3451
|
+
_iterator11.f();
|
|
3390
3452
|
}
|
|
3391
|
-
var
|
|
3392
|
-
|
|
3453
|
+
var _iterator12 = _createForOfIteratorHelper(product.product_bundle || []),
|
|
3454
|
+
_step12;
|
|
3393
3455
|
try {
|
|
3394
|
-
for (
|
|
3395
|
-
var
|
|
3396
|
-
var bundle =
|
|
3397
|
-
var bundleQty = new Decimal(Number(qty) || 1).times(Number((
|
|
3398
|
-
var
|
|
3399
|
-
|
|
3456
|
+
for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) {
|
|
3457
|
+
var _ref27, _bundle$num;
|
|
3458
|
+
var bundle = _step12.value;
|
|
3459
|
+
var bundleQty = new Decimal(Number(qty) || 1).times(Number((_ref27 = (_bundle$num = bundle === null || bundle === void 0 ? void 0 : bundle.num) !== null && _bundle$num !== void 0 ? _bundle$num : bundle === null || bundle === void 0 ? void 0 : bundle.quantity) !== null && _ref27 !== void 0 ? _ref27 : 1) || 1).toNumber();
|
|
3460
|
+
var _iterator13 = _createForOfIteratorHelper((bundle === null || bundle === void 0 ? void 0 : bundle.discount_list) || []),
|
|
3461
|
+
_step13;
|
|
3400
3462
|
try {
|
|
3401
|
-
for (
|
|
3402
|
-
var _pd =
|
|
3463
|
+
for (_iterator13.s(); !(_step13 = _iterator13.n()).done;) {
|
|
3464
|
+
var _pd = _step13.value;
|
|
3403
3465
|
addDiscountAmount(_pd, bundleQty);
|
|
3404
3466
|
}
|
|
3405
3467
|
} catch (err) {
|
|
3406
|
-
|
|
3468
|
+
_iterator13.e(err);
|
|
3407
3469
|
} finally {
|
|
3408
|
-
|
|
3470
|
+
_iterator13.f();
|
|
3409
3471
|
}
|
|
3410
3472
|
}
|
|
3411
3473
|
} catch (err) {
|
|
3412
|
-
|
|
3474
|
+
_iterator12.e(err);
|
|
3413
3475
|
} finally {
|
|
3414
|
-
|
|
3476
|
+
_iterator12.f();
|
|
3415
3477
|
}
|
|
3416
3478
|
}
|
|
3417
3479
|
} catch (err) {
|
|
3418
|
-
|
|
3480
|
+
_iterator9.e(err);
|
|
3419
3481
|
} finally {
|
|
3420
|
-
|
|
3482
|
+
_iterator9.f();
|
|
3421
3483
|
}
|
|
3422
|
-
var
|
|
3423
|
-
|
|
3484
|
+
var _iterator10 = _createForOfIteratorHelper(discountList),
|
|
3485
|
+
_step10;
|
|
3424
3486
|
try {
|
|
3425
|
-
for (
|
|
3426
|
-
var d =
|
|
3487
|
+
for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
|
|
3488
|
+
var d = _step10.value;
|
|
3427
3489
|
var key = d.id;
|
|
3428
3490
|
d.savedAmount = d.isSelected && key != null && savedMap.has(key) ? savedMap.get(key).toNumber() : 0;
|
|
3429
3491
|
}
|
|
3430
3492
|
} catch (err) {
|
|
3431
|
-
|
|
3493
|
+
_iterator10.e(err);
|
|
3432
3494
|
} finally {
|
|
3433
|
-
|
|
3495
|
+
_iterator10.f();
|
|
3434
3496
|
}
|
|
3435
3497
|
}
|
|
3436
3498
|
}]);
|
|
@@ -49,5 +49,5 @@ export declare class Product extends BaseModule implements Module {
|
|
|
49
49
|
getCategories(): ProductCategory[];
|
|
50
50
|
setOtherParams(key: string, value: any): void;
|
|
51
51
|
getOtherParams(): any;
|
|
52
|
-
getProductType(): "
|
|
52
|
+
getProductType(): "normal" | "duration" | "session";
|
|
53
53
|
}
|
|
@@ -606,103 +606,102 @@ export var BaseSalesImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
606
606
|
orderId: orderIdOrParams
|
|
607
607
|
};
|
|
608
608
|
externalSaleNumber = params.externalSaleNumber || params.external_sale_number;
|
|
609
|
-
debugger;
|
|
610
609
|
if (params.forceRemote) {
|
|
611
|
-
_context5.next =
|
|
610
|
+
_context5.next = 35;
|
|
612
611
|
break;
|
|
613
612
|
}
|
|
614
613
|
if (!(params.orderId !== undefined)) {
|
|
615
|
-
_context5.next =
|
|
614
|
+
_context5.next = 11;
|
|
616
615
|
break;
|
|
617
616
|
}
|
|
618
|
-
_context5.next =
|
|
617
|
+
_context5.next = 8;
|
|
619
618
|
return this.store.order.getLocalOrderByOrderId(params.orderId);
|
|
620
|
-
case
|
|
619
|
+
case 8:
|
|
621
620
|
_context5.t0 = _context5.sent;
|
|
622
|
-
_context5.next =
|
|
621
|
+
_context5.next = 26;
|
|
623
622
|
break;
|
|
624
|
-
case
|
|
623
|
+
case 11:
|
|
625
624
|
if (!externalSaleNumber) {
|
|
626
|
-
_context5.next =
|
|
625
|
+
_context5.next = 17;
|
|
627
626
|
break;
|
|
628
627
|
}
|
|
629
|
-
_context5.next =
|
|
628
|
+
_context5.next = 14;
|
|
630
629
|
return this.store.order.getLocalOrderByExternalSaleNumber(externalSaleNumber);
|
|
631
|
-
case
|
|
630
|
+
case 14:
|
|
632
631
|
_context5.t1 = _context5.sent;
|
|
633
|
-
_context5.next =
|
|
632
|
+
_context5.next = 25;
|
|
634
633
|
break;
|
|
635
|
-
case
|
|
634
|
+
case 17:
|
|
636
635
|
if (!params.orderNumber) {
|
|
637
|
-
_context5.next =
|
|
636
|
+
_context5.next = 23;
|
|
638
637
|
break;
|
|
639
638
|
}
|
|
640
|
-
_context5.next =
|
|
639
|
+
_context5.next = 20;
|
|
641
640
|
return this.store.order.getLocalOrderByOrderNumber(params.orderNumber);
|
|
642
|
-
case
|
|
641
|
+
case 20:
|
|
643
642
|
_context5.t2 = _context5.sent;
|
|
644
|
-
_context5.next =
|
|
643
|
+
_context5.next = 24;
|
|
645
644
|
break;
|
|
646
|
-
case
|
|
645
|
+
case 23:
|
|
647
646
|
_context5.t2 = null;
|
|
648
|
-
case
|
|
647
|
+
case 24:
|
|
649
648
|
_context5.t1 = _context5.t2;
|
|
650
|
-
case
|
|
649
|
+
case 25:
|
|
651
650
|
_context5.t0 = _context5.t1;
|
|
652
|
-
case
|
|
651
|
+
case 26:
|
|
653
652
|
localRecord = _context5.t0;
|
|
654
653
|
if (!localRecord) {
|
|
655
|
-
_context5.next =
|
|
654
|
+
_context5.next = 35;
|
|
656
655
|
break;
|
|
657
656
|
}
|
|
658
|
-
_context5.next =
|
|
657
|
+
_context5.next = 30;
|
|
659
658
|
return this.store.order.hydrateTempOrderFromRecord(localRecord, {
|
|
660
659
|
recalcOnHydrate: false
|
|
661
660
|
});
|
|
662
|
-
case
|
|
661
|
+
case 30:
|
|
663
662
|
_sales = _context5.sent;
|
|
664
663
|
this.currentSalesDetail = _sales;
|
|
665
|
-
_context5.next =
|
|
664
|
+
_context5.next = 34;
|
|
666
665
|
return this.core.effects.emit("".concat(this.name, ":onSalesOrderLoaded"), {
|
|
667
666
|
sales: _sales
|
|
668
667
|
});
|
|
669
|
-
case
|
|
668
|
+
case 34:
|
|
670
669
|
return _context5.abrupt("return", _sales);
|
|
671
|
-
case
|
|
670
|
+
case 35:
|
|
672
671
|
if (!(params.orderId === undefined || params.orderId === null)) {
|
|
673
|
-
_context5.next =
|
|
672
|
+
_context5.next = 37;
|
|
674
673
|
break;
|
|
675
674
|
}
|
|
676
675
|
throw new Error('加载销售详情需要 orderId,或本地库中存在对应 externalSaleNumber/orderNumber');
|
|
677
|
-
case
|
|
678
|
-
_context5.next =
|
|
676
|
+
case 37:
|
|
677
|
+
_context5.next = 39;
|
|
679
678
|
return this.store.order.getOrderInfoByRemote(Number(params.orderId));
|
|
680
|
-
case
|
|
679
|
+
case 39:
|
|
681
680
|
res = _context5.sent;
|
|
682
681
|
if (!(!res || res.code !== 200)) {
|
|
683
|
-
_context5.next =
|
|
682
|
+
_context5.next = 43;
|
|
684
683
|
break;
|
|
685
684
|
}
|
|
686
685
|
message = res && (res.message || res.msg) || "\u52A0\u8F7D\u9500\u552E\u8BE6\u60C5\u5931\u8D25: ".concat(params.orderId);
|
|
687
686
|
throw new Error(message);
|
|
688
|
-
case
|
|
689
|
-
_context5.next =
|
|
687
|
+
case 43:
|
|
688
|
+
_context5.next = 45;
|
|
690
689
|
return this.store.order.hydrateTempOrderFromRecord(res.data, {
|
|
691
690
|
recalcOnHydrate: false
|
|
692
691
|
});
|
|
693
|
-
case
|
|
692
|
+
case 45:
|
|
694
693
|
sales = _context5.sent;
|
|
695
|
-
_context5.next =
|
|
694
|
+
_context5.next = 48;
|
|
696
695
|
return this.store.order.saveDraft();
|
|
697
|
-
case
|
|
696
|
+
case 48:
|
|
698
697
|
this.currentSalesDetail = sales;
|
|
699
|
-
_context5.next =
|
|
698
|
+
_context5.next = 51;
|
|
700
699
|
return this.core.effects.emit("".concat(this.name, ":onSalesOrderLoaded"), {
|
|
701
700
|
sales: sales
|
|
702
701
|
});
|
|
703
|
-
case
|
|
702
|
+
case 51:
|
|
704
703
|
return _context5.abrupt("return", sales);
|
|
705
|
-
case
|
|
704
|
+
case 52:
|
|
706
705
|
case "end":
|
|
707
706
|
return _context5.stop();
|
|
708
707
|
}
|
|
@@ -176,6 +176,18 @@ export declare function getOrderProductOriginalPriceForPromotion(product: any):
|
|
|
176
176
|
export declare function mergeIdenticalPromotionCartLines(products: any[]): any[];
|
|
177
177
|
/** 获取行 uid(统一以 `metadata.unique_identification_number` 为唯一键) */
|
|
178
178
|
export declare function getOrderProductUid(product: any): string;
|
|
179
|
+
/**
|
|
180
|
+
* 促销评估前合并同 SKU 拆分行(含促销/原价行),避免加购后仅前 2 件享受优惠。
|
|
181
|
+
* 带 `booking_uid` 的预约行不参与合并(每次加车独立 booking + 商品行)。
|
|
182
|
+
*
|
|
183
|
+
* @example
|
|
184
|
+
* consolidateMainProductsForPromotion([
|
|
185
|
+
* { item: promoLineNum2, originalListIndex: 0 },
|
|
186
|
+
* { item: regularLineNum2, originalListIndex: 1 },
|
|
187
|
+
* ]);
|
|
188
|
+
* // => 单行 num=4,清除 _promotion 后重新评估
|
|
189
|
+
*/
|
|
190
|
+
export declare function buildConsolidateKeyForPromotion(item: any): string;
|
|
179
191
|
/**
|
|
180
192
|
* 从策略配置的 product_match 规则提取可参与商品列表。
|
|
181
193
|
*
|